From: Charles Briere <[email protected]> Linking libcutils for Android that uses ashmem
Signed-off-by: Charles Briere <[email protected]> --- configure.ac | 14 ++++++++++++++ src/bin/lttng-sessiond/shm.c | 5 +++-- src/common/compat/shm.h | 37 +++++++++++++++++++++++++++++++++++++ src/common/defaults.h | 1 + 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/common/compat/shm.h diff --git a/configure.ac b/configure.ac index e219689..16852b1 100644 --- a/configure.ac +++ b/configure.ac @@ -194,6 +194,20 @@ AC_CHECK_LIB([rt], [shm_open], AM_CONDITIONAL([LTTNG_BUILD_WITH_LIBUUID], [test "x$have_libuuid" = "xyes"]) AM_CONDITIONAL([LTTNG_BUILD_WITH_LIBC_UUID], [test "x$have_libc_uuid" = "xyes"]) +# Check for libcutils +AC_CHECK_LIB([cutils], [ashmem_create], + [AC_SUBST(LIBCUTILS_LIBS, '-lcutils')], + [AC_SUBST(LIBCUTILS_LIBS, '')], +) +AC_CHECK_HEADERS([cutils/ashmem.h], + [AC_CHECK_DECLS([ashmem_create], [], [], [[#include <cutils/ashmem.h>]])], +) + +AS_CASE([$host],[*-*-linux-androideabi], + [AM_CONDITIONAL(TARGET_IS_ANDROID, true)], + [AM_CONDITIONAL(TARGET_IS_ANDROID, false)] +) + # URCU library version needed or newer liburcu_version=">= 0.8.0" diff --git a/src/bin/lttng-sessiond/shm.c b/src/bin/lttng-sessiond/shm.c index e9ed714..dba3679 100644 --- a/src/bin/lttng-sessiond/shm.c +++ b/src/bin/lttng-sessiond/shm.c @@ -30,7 +30,7 @@ #include <common/error.h> -#include "shm.h" +#include <common/compat/shm.h> /* * Using fork to set umask in the child process (not multi-thread safe). We @@ -73,7 +73,8 @@ static int get_wait_shm(char *shm_path, size_t mmap_size, int global) * Try creating shm (or get rw access). We don't do an exclusive open, * because we allow other processes to create+ftruncate it concurrently. */ - wait_shm_fd = shm_open(shm_path, O_RDWR | O_CREAT, mode); + wait_shm_fd = lttng_shm_open(shm_path, O_RDWR | O_CREAT, mode); + if (wait_shm_fd < 0) { PERROR("shm_open wait shm"); goto error; diff --git a/src/common/compat/shm.h b/src/common/compat/shm.h new file mode 100644 index 0000000..28e498a --- /dev/null +++ b/src/common/compat/shm.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 - Charles Briere <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _COMPAT_SYS_SHM_H +#define _COMPAT_SYS_SHM_H + +# if defined(HAVE_SYS_SHM_H) + +#include <sys/shm.h> + +#define lttng_shm_open(name, oflag, mode) \ + shm_open(name, oflag, mode) + +# elif defined(HAVE_CUTILS_ASHMEM_H) + +#include <cutils/ashmem.h> + +#define lttng_shm_open(name, oflag, mode) \ + open(name, oflag, mode) + +# endif /* HAVE_SYS_SHM_H */ + +#endif /*_COMPAT_SYS_SHM_H */ diff --git a/src/common/defaults.h b/src/common/defaults.h index 25d7b32..8951179 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -143,6 +143,7 @@ #define DEFAULT_HOME_APPS_UNIX_SOCK \ DEFAULT_LTTNG_HOME_RUNDIR "/" LTTNG_UST_SOCK_FILENAME #define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH \ + DEFAULT_LTTNG_RUNDIR \ "/" LTTNG_UST_WAIT_FILENAME #define DEFAULT_HOME_APPS_WAIT_SHM_PATH \ DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "-%d" -- 2.1.2 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
