Merge branch 'master' into dev
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Feb 2012 22:29:04 +0000 (17:29 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Feb 2012 22:29:04 +0000 (17:29 -0500)
50 files changed:
README
configure.ac
doc/examples/easy-ust/Makefile
doc/examples/gen-tp/Makefile
include/Makefile.am
include/lttng/bitfield.h
include/lttng/ust-endian.h [new file with mode: 0644]
include/lttng/ust-events.h
include/lttng/ust-tid.h [new file with mode: 0644]
include/usterr-signal-safe.h
include/usterr.h
liblttng-ust-comm/lttng-ust-comm.c
liblttng-ust-fork/Makefile.am
liblttng-ust-fork/ustfork.c
liblttng-ust-libc-wrapper/Makefile.am
liblttng-ust/Makefile.am
liblttng-ust/clock.h
liblttng-ust/compat.h
liblttng-ust/jhash.h
liblttng-ust/ltt-events.c
liblttng-ust/ltt-ring-buffer-client.h
liblttng-ust/ltt-ring-buffer-metadata-client.h
liblttng-ust/lttng-context-procname.c
liblttng-ust/lttng-context-vtid.c
liblttng-ust/lttng-ust-comm.c
liblttng-ust/lttng-ust-uuid.h [new file with mode: 0644]
libringbuffer/backend_internal.h
libringbuffer/getcpu.h
libringbuffer/ring_buffer_frontend.c
libringbuffer/shm.c
snprintf/fflush.c
snprintf/fileext.h
snprintf/fvwrite.c
snprintf/fvwrite.h
snprintf/local.h
snprintf/snprintf.c
snprintf/various.h
snprintf/vfprintf.c
snprintf/wsetup.c
tests/demo/Makefile.am
tests/demo/README
tests/dlopen/Makefile.am
tests/hello-static-lib/Makefile.am
tests/hello.cxx/Makefile.am
tests/hello/Makefile.am
tests/hello/Makefile.example [deleted file]
tests/hello/Makefile.example.bsd [new file with mode: 0644]
tests/hello/Makefile.example.linux [new file with mode: 0644]
tests/ust-basic-tracing/ust-basic-tracing.c
tests/ust-multi-test/ust-multi-test.c

diff --git a/README b/README
index e2b52aa026f74a3ff598c774bc034baefe01c5aa..78ed56f68067bbdefef3bfb771110eb439377590 100644 (file)
--- a/README
+++ b/README
@@ -67,7 +67,7 @@ USAGE:
       "TRACEPOINT_DEFINE" and include the tracepoint provider.
     - Use "-I." for the compilation unit containing the tracepoint
       provider include (e.g. tp.c).
-    - Link application with "-ldl".
+    - Link application with "-ldl" on Linux, with "-lc" on BSD.
     - If building the provider directly into the application,
       link the application with "-llttng-ust".
     - If building a static library for the provider, link the static
@@ -75,7 +75,7 @@ USAGE:
     - Include the tracepoint provider header into all C files using
       the provider.
     - Example:
-        tests/hello/  hello.c tp.c ust_tests_hello.h Makefile.example
+        tests/hello/  hello.c tp.c ust_tests_hello.h Makefile.example.*
 
   2) Compile the Tracepoint Provider separately from the application,
      using dynamic linking:
@@ -87,7 +87,7 @@ USAGE:
       files that use the provider.
     - Compile the tracepoint provider with "-I.".
     - Link the tracepoint provider with "-llttng-ust".
-    - Link application with "-ldl".
+    - Link application with "-ldl" on Linux, "-lc" on BSD.
     - Set a LD_PRELOAD environment to preload the tracepoint provider
       shared object before starting the application when tracing is
       needed.
index 0bcc408139d2d12c4b3e098c8418adbe95ef2174..d4f879eb5f6f5d1664348fc728b9571a9555e3c4 100644 (file)
@@ -42,13 +42,45 @@ AC_PROG_MAKE_SET
 LT_INIT
 
 ## Checks for libraries.
-AC_CHECK_LIB([dl], [dlopen])
+AC_CHECK_LIB([dl], [dlopen],
+[
+       have_libdl=yes
+],
+[
+       #libdl not found, check for dlopen in libc.
+       AC_CHECK_LIB([c], [dlopen],
+       [
+               have_libc_dl=yes
+       ],
+       [
+               AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
+       ])
+])
+AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBDL], [test "x$have_libdl" = "xyes"])
+AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBC_DL], [test "x$have_libc_dl" = "xyes"])
+
 AC_CHECK_LIB([pthread], [pthread_create])
 
 # Check for libuuid
-AC_CHECK_LIB([uuid], [uuid_generate], [],
-       [AC_MSG_ERROR([Cannot find libuuid. Use [LDFLAGS]=-Ldir to specify its location.])]
+AC_CHECK_LIB([uuid], [uuid_generate],
+[
+       AC_DEFINE_UNQUOTED([LTTNG_UST_HAVE_LIBUUID], 1, [Has libuuid support.])
+       have_libuuid=yes
+],
+[
+       # libuuid not found, check for uuid_create in libc.
+       AC_CHECK_LIB([c], [uuid_create],
+       [
+               AC_DEFINE_UNQUOTED([LTTNG_UST_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
+               have_libc_uuid=yes
+       ],
+       [
+               AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
+       ])
+]
 )
+AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBUUID], [test "x$have_libuuid" = "xyes"])
+AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBC_UUID], [test "x$have_libc_uuid" = "xyes"])
 
 # Checks for header files.
 #AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
@@ -143,6 +175,7 @@ changequote([,])dnl
          fi
          ;;
        x86_64) LIBFORMAT="elf64-x86-64" ;;
+       amd64) LIBFORMAT="elf64-x86-64" ;;
        powerpc) LIBFORMAT="elf32-powerpc" ;;
        ppc64) LIBFORMAT="elf64-powerpc" ;;
        powerpc64) LIBFORMAT="elf64-powerpc" ;;
index 597071b58621f9e2c5bbc033a5d130dec4b588e5..3d043df428f51f02e1c9c05cfbb8be082f0b8924 100644 (file)
@@ -16,7 +16,8 @@
 # the "html" target helps for documentation (req. code2html)
 
 CC = gcc
-LIBS = -ldl -llttng-ust
+LIBS = -ldl -llttng-ust                # On Linux
+#LIBS = -lc -llttng-ust                # On BSD
 CFLAGS = -I.
 
 all: sample
index b29eed4cf707821d8d695274d7387f2a72399150..518f017498b279814aa992c10d03133cc2b6fb45 100644 (file)
@@ -16,7 +16,9 @@
 # provider probe.
 
 CC = gcc
-LIBS = -ldl -llttng-ust
+
+LIBS = -ldl -llttng-ust                #On Linux
+#LIBS = -lc -llttng-ust                #On BSD
 
 all: sample
 
index e339b32e74d11e85823580478136282928c618cb..571e32f92066d4a6f582f448195b8d67e7f623c6 100644 (file)
@@ -13,6 +13,7 @@ nobase_include_HEADERS = \
        lttng/ust-tracer.h \
        lttng/ust-config.h \
        lttng/ust.h \
+       lttng/ust-endian.h \
        lttng/ringbuffer-config.h \
        lttng/align.h \
        lttng/bug.h
@@ -24,6 +25,7 @@ noinst_HEADERS = \
        usterr-signal-safe.h \
        ust_snprintf.h \
        ust-comm.h \
+       lttng/ust-tid.h \
        lttng/bitfield.h \
        helper.h \
        share.h
index df8ab0b2b67a224bed60a9b86d866494a288f37f..61cb1805c8b71f7fb2e050b7eaebefd95a9762b3 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <stdint.h>    /* C99 5.2.4.2 Numerical limits */
 #include <limits.h>    /* C99 5.2.4.2 Numerical limits */
-#include <endian.h>    /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
+#include <lttng/ust-endian.h>  /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
 #include <assert.h>
 
 /* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */
diff --git a/include/lttng/ust-endian.h b/include/lttng/ust-endian.h
new file mode 100644 (file)
index 0000000..2426b14
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _LTTNG_UST_ENDIAN_H
+#define _LTTNG_UST_ENDIAN_H
+
+/*
+ * lttng/ust-endian.h
+ *
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * endian.h compatibility layer.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#ifdef __linux__
+#include <endian.h>
+#elif defined(__FreeBSD__)
+#include <machine/endian.h>
+#else
+#error "Please add support for your OS."
+#endif
+
+#ifndef FLOAT_WORD_ORDER
+#ifdef __FLOAT_WORD_ORDER
+#define FLOAT_WORD_ORDER       __FLOAT_WORD_ORDER
+#else /* __FLOAT_WORD_ORDER */
+#define FLOAT_WORD_ORDER       BYTE_ORDER
+#endif /* __FLOAT_WORD_ORDER */
+#endif /* FLOAT_WORD_ORDER */
+
+#endif /* _LTTNG_UST_ENDIAN_H */
index 2f00440bdc173dbced449363e252860c190cd178..96435c481c7b5aa117ed04b893a057bd531dfdfd 100644 (file)
 
 #include <urcu/list.h>
 #include <urcu/hlist.h>
-#include <uuid/uuid.h>
 #include <stdint.h>
 #include <lttng/ust-abi.h>
 #include <lttng/ust-tracer.h>
-#include <endian.h>
+#include <lttng/ust-endian.h>
 #include <float.h>
 
+#define LTTNG_UST_UUID_LEN             16
+
 struct ltt_channel;
 struct ltt_session;
 struct lttng_ust_lib_ring_buffer_ctx;
@@ -76,7 +77,7 @@ struct lttng_enum_entry {
                  .size = sizeof(_type) * CHAR_BIT,             \
                  .alignment = lttng_alignof(_type) * CHAR_BIT, \
                  .signedness = lttng_is_signed_type(_type),    \
-                 .reverse_byte_order = _byte_order != __BYTE_ORDER,    \
+                 .reverse_byte_order = _byte_order != BYTE_ORDER,      \
                  .base = _base,                                \
                  .encoding = lttng_encode_##_encoding,         \
                },                                              \
@@ -109,7 +110,7 @@ struct lttng_integer_type {
                                - _float_mant_dig(_type),       \
                  .mant_dig = _float_mant_dig(_type),           \
                  .alignment = lttng_alignof(_type) * CHAR_BIT, \
-                 .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \
+                 .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \
                },                                              \
        }                                                       \
 
@@ -323,7 +324,7 @@ struct ltt_channel {
        /* Channel ID, available for consumer too */
        unsigned int id;
        /* Copy of session UUID for consumer (availability through shm) */
-       uuid_t uuid;                    /* Trace session unique ID */
+       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
 };
 
 struct ltt_session {
@@ -336,7 +337,7 @@ struct ltt_session {
        struct cds_list_head wildcards; /* Wildcard list head */
        struct cds_list_head list;      /* Session list */
        unsigned int free_chan_id;      /* Next chan ID to allocate */
-       uuid_t uuid;                    /* Trace session unique ID */
+       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
        unsigned int metadata_dumped:1;
 };
 
diff --git a/include/lttng/ust-tid.h b/include/lttng/ust-tid.h
new file mode 100644 (file)
index 0000000..57272db
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef _LTTNG_UST_TID_H
+#define _LTTNG_UST_TID_H
+
+/*
+ * lttng/ust-tid.h
+ *
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * gettid compatibility layer.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
+#if defined(_syscall0)
+_syscall0(pid_t, gettid)
+#elif defined(__NR_gettid)
+#include <unistd.h>
+static inline pid_t gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+#else
+#include <sys/types.h>
+#include <unistd.h>
+
+/* Fall-back on getpid for tid if not available. */
+static inline pid_t gettid(void)
+{
+       return getpid();
+}
+#endif
+
+#endif /* _LTTNG_UST_TID_H */
index 375eff7c569b63d5794a6cc7932de4da81548499..8e2c1cd2413ed748dd781f5d797e56bb52942d13 100644 (file)
@@ -26,8 +26,8 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
-
 #include <share.h>
+#include "lttng/ust-tid.h"
 
 enum ust_loglevel {
        UST_LOGLEVEL_UNKNOWN = 0,
@@ -85,7 +85,7 @@ do {                                                                  \
        do {                                    \
                sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n",    \
                (long) getpid(),                \
-               (long) syscall(SYS_gettid),     \
+               (long) gettid(),                \
                ## args, __func__);             \
                fflush(stderr);                 \
        } while(0)
@@ -115,7 +115,10 @@ do {                                                                       \
 #define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
 #define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
 
-#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)
+#if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+/*
+ * Version using XSI strerror_r.
+ */
 #define PERROR(call, args...)\
        do { \
                char buf[200] = "Error in strerror_r()"; \
@@ -123,6 +126,9 @@ do {                                                                        \
                ERRMSG("Error: " call ": %s", ## args, buf); \
        } while(0);
 #else
+/*
+ * Version using GNU strerror_r, for linux with appropriate defines.
+ */
 #define PERROR(call, args...)\
        do { \
                char *buf; \
index 35d576ec1815ab755cd80b8a8b2659fbacfe62ee..c25348d74ce9d8869965c629d15c61d3dcf54950 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#include "lttng/ust-tid.h"
 #include "share.h"
 
 enum ust_loglevel {
@@ -57,7 +58,7 @@ static inline int ust_debug(void)
        do {                                                    \
                fprintf(stderr, UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" XSTR(__LINE__) ")\n",                          \
                        (long) getpid(),                        \
-                       (long) syscall(SYS_gettid),             \
+                       (long) gettid(),                        \
                        ## args,                                \
                        __func__);                              \
        } while(0)
@@ -86,7 +87,10 @@ static inline int ust_debug(void)
 #define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
 #define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
 
-#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)
+#if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+/*
+ * Version using XSI strerror_r.
+ */
 #define PERROR(call, args...)\
        do { \
                char buf[200] = "Error in strerror_r()"; \
@@ -94,6 +98,9 @@ static inline int ust_debug(void)
                ERRMSG("Error: " call ": %s", ## args, buf); \
        } while(0);
 #else
+/*
+ * Version using GNU strerror_r, for linux with appropriate defines.
+ */
 #define PERROR(call, args...)\
        do { \
                char *buf; \
index 3277191c397f101e0cffa6dc30fdf0d3f9ed8049..7e55cff556c6ced0314329401fdbe866480cf160 100644 (file)
@@ -29,6 +29,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
 
 #include <ust-comm.h>
 
@@ -119,12 +120,17 @@ int ustcomm_connect_unix_sock(const char *pathname)
         * libust threads require the close-on-exec flag for all
         * resources so it does not leak file descriptors upon exec.
         */
-       fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+       fd = socket(PF_UNIX, SOCK_STREAM, 0);
        if (fd < 0) {
                perror("socket");
                ret = fd;
                goto error;
        }
+       ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
+       if (ret < 0) {
+               perror("fcntl");
+               goto error_fcntl;
+       }
 
        memset(&sun, 0, sizeof(sun));
        sun.sun_family = AF_UNIX;
@@ -144,6 +150,7 @@ int ustcomm_connect_unix_sock(const char *pathname)
        return fd;
 
 error_connect:
+error_fcntl:
        close(fd);
 error:
        return ret;
index e0e42a3f4d707f3e01500e2296f0a25b973327f3..49466f6481d6a39a0b3c1623956c2d1f2e1907ec 100644 (file)
@@ -4,6 +4,13 @@ AM_CFLAGS = -fno-strict-aliasing
 lib_LTLIBRARIES = liblttng-ust-fork.la
 liblttng_ust_fork_la_SOURCES = ustfork.c
 liblttng_ust_fork_la_LIBADD = \
-       -ldl \
        $(top_builddir)/liblttng-ust/liblttng-ust.la
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+liblttng_ust_fork_la_LIBADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+liblttng_ust_fork_la_LIBADD += -lc
+endif
+
 libustfork_CFLAGS = -DUST_COMPONENT=liblttng-ust-fork -fno-strict-aliasing
index ac191971fd7b18cca7143fd79f5c1efeec00fcaf..8fade56e84c5413bd30c679d7f3fd5c30b4e3c70 100644 (file)
@@ -28,8 +28,6 @@
 
 #include <lttng/ust.h>
 
-struct user_desc;
-
 pid_t fork(void)
 {
        static pid_t (*plibc_func)(void) = NULL;
@@ -56,6 +54,10 @@ pid_t fork(void)
        return retval;
 }
 
+#ifdef __linux__
+
+struct user_desc;
+
 struct ustfork_clone_info {
        int (*fn)(void *);
        void *arg;
@@ -117,3 +119,41 @@ int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...)
        }
        return retval;
 }
+
+#elif defined (__FreeBSD__)
+
+pid_t rfork(int flags)
+{
+       static pid_t (*plibc_func)(void) = NULL;
+       sigset_t sigset;
+       pid_t retval;
+
+       if (plibc_func == NULL) {
+               plibc_func = dlsym(RTLD_NEXT, "rfork");
+               if (plibc_func == NULL) {
+                       fprintf(stderr, "libustfork: unable to find \"rfork\" symbol\n");
+                       return -1;
+               }
+       }
+
+       ust_before_fork(&sigset);
+       /* Do the real rfork */
+       retval = plibc_func();
+       if (retval == 0) {
+               /* child */
+               ust_after_fork_child(&sigset);
+       } else {
+               ust_after_fork_parent(&sigset);
+       }
+       return retval;
+}
+
+/*
+ * On BSD, no need to override vfork, because it runs in the context of
+ * the parent, with parent waiting until execve or exit is executed in
+ * the child.
+ */
+
+#else
+#warning "Unknown OS. You might want to ensure that fork/clone/vfork/fork handling is complete."
+#endif
index 6220f76c6c64ec2d6d239f87ee0f4270f08d9c68..5b3f7f0da586872bce4f7e04ee9fa664072f9dba 100644 (file)
@@ -5,9 +5,16 @@ lib_LTLIBRARIES = liblttng-ust-libc-wrapper.la
 liblttng_ust_libc_wrapper_la_SOURCES = \
        lttng-ust-malloc.c \
        ust_libc.h
-liblttng_ust_libc_wrapper_la_LIBADD = -ldl \
+liblttng_ust_libc_wrapper_la_LIBADD = \
        -L$(top_builddir)/liblttng-ust/.libs \
        -llttng-ust
 
+if LTTNG_UST_BUILD_WITH_LIBDL
+liblttng_ust_libc_wrapper_la_LIBADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+liblttng_ust_libc_wrapper_la_LIBADD += -lc
+endif
+
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index 9d9477b9eaad88f84c463b2d8359cb00d9c12f1c..75a2ba8ab19932ef4782d37ae48a85f103cceb5f 100644 (file)
@@ -33,7 +33,8 @@ liblttng_ust_runtime_la_SOURCES = \
        compat.h \
        wait.h \
        jhash.h \
-       error.h
+       error.h \
+       lttng-ust-uuid.h
 
 liblttng_ust_support_la_SOURCES = \
        ltt-tracer.h \
@@ -55,10 +56,16 @@ liblttng_ust_support_la_LIBADD = \
 liblttng_ust_la_LIBADD = \
        -lpthread \
        -lrt \
-       -luuid \
        -llttng-ust-tracepoint \
        $(top_builddir)/snprintf/libustsnprintf.la \
        $(top_builddir)/liblttng-ust-comm/liblttng-ust-comm.la \
        liblttng-ust-runtime.la liblttng-ust-support.la
 
+if LTTNG_UST_BUILD_WITH_LIBUUID
+liblttng_ust_la_LIBADD += -luuid
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_UUID
+liblttng_ust_la_LIBADD += -lc
+endif
+
 liblttng_ust_la_CFLAGS = -DUST_COMPONENT="liblttng_ust" -fno-strict-aliasing
index 82a7b45cd5294a3f35c63e172ea8105d0e5c2e0d..88eca432a5733f7e4bc35f1878b911617a5119d5 100644 (file)
 #include <stdint.h>
 #include <stddef.h>
 #include <stdio.h>
-
-/*
- * Includes final \0.
- */
-#define CLOCK_UUID_LEN         37
+#include "lttng-ust-uuid.h"
 
 /* TRACE CLOCK */
 
@@ -56,7 +52,7 @@ uint64_t trace_clock_freq(void)
 }
 
 static __inline__
-const int trace_clock_uuid(char *uuid)
+int trace_clock_uuid(char *uuid)
 {
        int ret = 0;
        size_t len;
@@ -71,12 +67,12 @@ const int trace_clock_uuid(char *uuid)
        if (!fp) {
                return -ENOENT;
        }
-       len = fread(uuid, 1, CLOCK_UUID_LEN - 1, fp);
-       if (len < CLOCK_UUID_LEN - 1) {
+       len = fread(uuid, 1, LTTNG_UST_UUID_STR_LEN - 1, fp);
+       if (len < LTTNG_UST_UUID_STR_LEN - 1) {
                ret = -EINVAL;
                goto end;
        }
-       uuid[CLOCK_UUID_LEN - 1] = '\0';
+       uuid[LTTNG_UST_UUID_STR_LEN - 1] = '\0';
 end:
        fclose(fp);
        return ret;
index 8ee4470a0b381289986e48742274fa287d835e1a..004e60ace8d86771652405c2076f555969bd12d8 100644 (file)
  * modified is included with the above copyright notice.
  */
 
-#include <sys/syscall.h>
+/*
+ * lttng_ust_getprocname.
+ */
+#ifdef __linux__
+
+#include <sys/prctl.h>
+
+#define LTTNG_UST_PROCNAME_LEN 17
+
+static inline
+void lttng_ust_getprocname(char *name)
+{
+       (void) prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0);
+}
+
+#elif defined(__FreeBSD__)
+#include <stdlib.h>
+#include <string.h>
 
-#ifdef __UCLIBC__
-#define __getcpu(cpu, node, cache)     syscall(__NR_getcpu, cpu, node, cache)
+/*
+ * Limit imposed by Linux UST-sessiond ABI.
+ */
+#define LTTNG_UST_PROCNAME_LEN 17
+
+/*
+ * Acts like linux prctl, the string is not necessarily 0-terminated if
+ * 16-byte long.
+ */
 static inline
-int sched_getcpu(void)
+void lttng_ust_getprocname(char *name)
 {
-       int c, s;
+       const char *bsd_name;
 
-       s = __getcpu(&c, NULL, NULL);
-       return (s == -1) ? s : c;
+       bsd_name = getprogname();
+       if (!bsd_name)
+               name[0] = '\0';
+       memcpy(name, bsd_name, LTTNG_UST_PROCNAME_LEN - 1);
 }
-#endif /* __UCLIBC__ */
+
+#endif
+
+#include <errno.h>
+
+#ifndef ENODATA
+#define ENODATA        ENOMSG
+#endif
+
 #endif /* _UST_COMPAT_H */
index 944dc0471fb3d5a90d0f54d9e516d61f377f6f5b..da1e7dd02c7b994bbdda9e5f8f7ce6eae27d4f5b 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 #include <urcu/compiler.h>
-#include <endian.h>
+#include <lttng/ust-endian.h>
 
 /*
  * Hash function
index b67a15c67b51fef30683b99a0c929dffef06fcfb..40cf3f916ee4c0056f2cde795bb857f4920a5230 100644 (file)
 
 #define _GNU_SOURCE
 #include <stdio.h>
-#include <endian.h>
 #include <urcu/list.h>
 #include <urcu/hlist.h>
 #include <pthread.h>
-#include <uuid/uuid.h>
 #include <errno.h>
 #include <sys/shm.h>
 #include <sys/ipc.h>
@@ -22,7 +20,7 @@
 #include <stddef.h>
 #include <inttypes.h>
 #include <time.h>
-#include <sys/prctl.h>
+#include <lttng/ust-endian.h>
 #include "clock.h"
 
 #include <urcu-bp.h>
@@ -36,6 +34,8 @@
 #include <usterr-signal-safe.h>
 #include <helper.h>
 #include "error.h"
+#include "compat.h"
+#include "lttng-ust-uuid.h"
 
 #include "tracepoint-internal.h"
 #include "ltt-tracer.h"
@@ -44,8 +44,6 @@
 #include "../libringbuffer/shm.h"
 #include "jhash.h"
 
-#define PROCNAME_LEN 17
-
 /*
  * The sessions mutex is the centralized mutex across UST tracing
  * control and probe registration. All operations within this file are
@@ -297,6 +295,7 @@ void synchronize_trace(void)
 struct ltt_session *ltt_session_create(void)
 {
        struct ltt_session *session;
+       int ret;
 
        session = zmalloc(sizeof(struct ltt_session));
        if (!session)
@@ -304,7 +303,10 @@ struct ltt_session *ltt_session_create(void)
        CDS_INIT_LIST_HEAD(&session->chan);
        CDS_INIT_LIST_HEAD(&session->events);
        CDS_INIT_LIST_HEAD(&session->wildcards);
-       uuid_generate(session->uuid);
+       ret = lttng_ust_uuid_generate(session->uuid);
+       if (ret != 0) {
+               session->uuid[0] = '\0';
+       }
        cds_list_add(&session->list, &sessions);
        return session;
 }
@@ -1089,11 +1091,12 @@ static
 int _ltt_session_metadata_statedump(struct ltt_session *session)
 {
        unsigned char *uuid_c = session->uuid;
-       char uuid_s[37], clock_uuid_s[CLOCK_UUID_LEN];
+       char uuid_s[LTTNG_UST_UUID_STR_LEN],
+               clock_uuid_s[LTTNG_UST_UUID_STR_LEN];
        struct ltt_channel *chan;
        struct ltt_event *event;
        int ret = 0;
-       char procname[PROCNAME_LEN] = "";
+       char procname[LTTNG_UST_PROCNAME_LEN] = "";
 
        if (!CMM_ACCESS_ONCE(session->active))
                return 0;
@@ -1147,8 +1150,8 @@ int _ltt_session_metadata_statedump(struct ltt_session *session)
                goto end;
 
        /* ignore error, just use empty string if error. */
-       (void) prctl(PR_GET_NAME, (unsigned long) procname, 0, 0, 0);
-       procname[PROCNAME_LEN - 1] = '\0';
+       lttng_ust_getprocname(procname);
+       procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
        ret = lttng_metadata_printf(session,
                "env {\n"
                "       vpid = %d;\n"
index ce9d263ce6c7be248c534564973de1ce0ce1a5f7..cedbc31d94a819e13f9e11cea68621b99bda66f3 100644 (file)
@@ -12,6 +12,7 @@
 #include <lttng/ust-events.h>
 #include "lttng/bitfield.h"
 #include "clock.h"
+#include "lttng-ust-uuid.h"
 #include "ltt-tracer.h"
 #include "../libringbuffer/frontend_types.h"
 
@@ -31,7 +32,7 @@ struct packet_header {
                                         * Trace magic number.
                                         * contains endianness information.
                                         */
-       uint8_t uuid[16];
+       uint8_t uuid[LTTNG_UST_UUID_LEN];
        uint32_t stream_id;
 
        struct {
index 7e79b116fa613a672be0efaeb0a2c1987536c762..dcbaacb61c1c1d583473ed367d4396e5de72bea9 100644 (file)
@@ -16,7 +16,7 @@
 
 struct metadata_packet_header {
        uint32_t magic;                 /* 0x75D11D57 */
-       uint8_t  uuid[16];              /* Unique Universal Identifier */
+       uint8_t  uuid[LTTNG_UST_UUID_LEN]; /* Unique Universal Identifier */
        uint32_t checksum;              /* 0 if unused */
        uint32_t content_size;          /* in bits */
        uint32_t packet_size;           /* in bits */
index b9bae82eba91be79fdd2ca1749fe2e5f2066b570..b737084bf69aae013cee43c11e7ffa3484067ce5 100644 (file)
@@ -7,13 +7,11 @@
  * Dual LGPL v2.1/GPL v2 license.
  */
 
-#include <sys/prctl.h>
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-config.h>
 #include <assert.h>
-
-#define PROCNAME_LEN   17      /* includes \0 */
+#include "compat.h"
 
 /*
  * We cache the result to ensure we don't trigger a system call for
@@ -26,12 +24,9 @@ static char cached_procname[17];
 static inline
 char *wrapper_getprocname(void)
 {
-       int ret;
-
        if (caa_unlikely(!cached_procname[0])) {
-               ret = prctl(PR_GET_NAME, (unsigned long) cached_procname,
-                       0, 0, 0);
-               assert(!ret);
+               lttng_ust_getprocname(cached_procname);
+               cached_procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
        }
        return cached_procname;
 }
@@ -46,7 +41,7 @@ size_t procname_get_size(size_t offset)
 {
        size_t size = 0;
 
-       size += PROCNAME_LEN;
+       size += LTTNG_UST_PROCNAME_LEN;
        return size;
 }
 
@@ -58,7 +53,7 @@ void procname_record(struct lttng_ctx_field *field,
        char *procname;
 
        procname = wrapper_getprocname();
-       chan->ops->event_write(ctx, procname, PROCNAME_LEN);
+       chan->ops->event_write(ctx, procname, LTTNG_UST_PROCNAME_LEN);
 }
 
 int lttng_add_procname_to_ctx(struct lttng_ctx **ctx)
@@ -81,7 +76,7 @@ int lttng_add_procname_to_ctx(struct lttng_ctx **ctx)
        field->event_field.type.u.array.elem_type.u.basic.integer.reverse_byte_order = 0;
        field->event_field.type.u.array.elem_type.u.basic.integer.base = 10;
        field->event_field.type.u.array.elem_type.u.basic.integer.encoding = lttng_encode_UTF8;
-       field->event_field.type.u.array.length = PROCNAME_LEN;
+       field->event_field.type.u.array.length = LTTNG_UST_PROCNAME_LEN;
        field->get_size = procname_get_size;
        field->record = procname_record;
        return 0;
index 6f7e078d22d2910072748adfd0ee59b8c9a695b4..3fe86405c112307a47e6c1abe0a9c62fe8b2175b 100644 (file)
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-config.h>
-
-#ifdef __linux__
-#include <syscall.h>
-#endif
-
-#if defined(_syscall0)
-_syscall0(pid_t, gettid)
-#elif defined(__NR_gettid)
-static inline pid_t gettid(void)
-{
-       return syscall(__NR_gettid);
-}
-#else
-#warning "use pid as tid"
-static inline pid_t gettid(void)
-{
-       return getpid();
-}
-#endif
+#include <lttng/ust-tid.h>
 
 /*
  * We cache the result to ensure we don't trigger a system call for
index 44e8bab4c24ca4aa2a77b72727288c9b24c8e67d..36f57efb25f4d97c31bcb04b7fd207f2807b9a8c 100644 (file)
@@ -22,7 +22,6 @@
 #define _LGPL_SOURCE
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/prctl.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -46,6 +45,7 @@
 #include <usterr-signal-safe.h>
 #include "tracepoint-internal.h"
 #include "ltt-tracer-core.h"
+#include "compat.h"
 
 /*
  * Has lttng ust comm constructor been called ?
@@ -159,7 +159,6 @@ static
 int register_app_to_sessiond(int socket)
 {
        ssize_t ret;
-       int prctl_ret;
        struct {
                uint32_t major;
                uint32_t minor;
@@ -178,11 +177,7 @@ int register_app_to_sessiond(int socket)
        reg_msg.uid = getuid();
        reg_msg.gid = getgid();
        reg_msg.bits_per_long = CAA_BITS_PER_LONG;
-       prctl_ret = prctl(PR_GET_NAME, (unsigned long) reg_msg.name, 0, 0, 0);
-       if (prctl_ret) {
-               ERR("Error executing prctl");
-               return -errno;
-       }
+       lttng_ust_getprocname(reg_msg.name);
 
        ret = ustcomm_send_unix_sock(socket, &reg_msg, sizeof(reg_msg));
        if (ret >= 0 && ret != sizeof(reg_msg))
diff --git a/liblttng-ust/lttng-ust-uuid.h b/liblttng-ust/lttng-ust-uuid.h
new file mode 100644 (file)
index 0000000..418eb92
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef _LTTNG_UST_UUID_H
+#define _LTTNG_UST_UUID_H
+
+/*
+ * Copyright (C) 2011   Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <config.h>
+#include <lttng/ust-events.h> /* For LTTNG_UST_UUID_LEN */
+/*
+ * Includes final \0.
+ */
+#define LTTNG_UST_UUID_STR_LEN         37
+
+#ifdef LTTNG_UST_HAVE_LIBUUID
+#include <uuid/uuid.h>
+
+static inline
+int lttng_ust_uuid_generate(unsigned char *uuid_out)
+{
+       uuid_generate(uuid_out);
+       return 0;
+}
+
+#elif defined(LTTNG_UST_HAVE_LIBC_UUID)
+#include <uuid.h>
+#include <stdint.h>
+
+static inline
+int lttng_ust_uuid_generate(unsigned char *uuid_out)
+{
+       uint32_t status;
+
+       uuid_create((uuid_t *) uuid_out, &status);
+       if (status == uuid_s_ok)
+               return 0;
+       else
+               return -1;
+}
+
+#else
+#error "LTTng-UST needs to have a UUID generator configured."
+#endif
+
+#endif /* _LTTNG_UST_UUID_H */
index 36d53dfd531357037501a539cd8c991c9d2ca4d9..c9ed81be0e5b5c559ba8de23846a6052ecc8ddea 100644 (file)
@@ -436,7 +436,7 @@ do {                                                                \
 
 /* arch-agnostic implementation */
 
-static inline int fls(unsigned int x)
+static inline int lttng_ust_fls(unsigned int x)
 {
        int r = 32;
 
@@ -469,7 +469,7 @@ static inline int get_count_order(unsigned int count)
 {
        int order;
 
-       order = fls(count) - 1;
+       order = lttng_ust_fls(count) - 1;
        if (count & (count - 1))
                order++;
        return order;
index 104ba7601c6bc58598833d4e7acc9374e6262e4f..3474bfe0c04f9f218eac190b001b08600f9d8272 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include <urcu/compiler.h>
-#include <sched.h>
 
 #ifdef UST_VALGRIND
 
@@ -37,6 +36,30 @@ int lttng_ust_get_cpu(void)
 
 #else
 
+/*
+ * sched_getcpu.
+ */
+#ifdef __linux__
+
+#ifdef __UCLIBC__
+#include <sys/syscall.h>
+#define __getcpu(cpu, node, cache)     syscall(__NR_getcpu, cpu, node, cache)
+/*
+ * If getcpu is not implemented in the kernel, use cpu 0 as fallback.
+ */
+static inline
+int lttng_ust_get_cpu(void)
+{
+       int cpu, ret;
+
+       ret = __getcpu(&cpu, NULL, NULL);
+       if (caa_unlikely(ret < 0))
+               return 0;
+       return c;
+}
+#else /* __UCLIBC__ */
+#include <sched.h>
+
 /*
  * If getcpu is not implemented in the kernel, use cpu 0 as fallback.
  */
@@ -50,6 +73,23 @@ int lttng_ust_get_cpu(void)
                return 0;
        return cpu;
 }
+#endif /* __UCLIBC__ */
+
+#elif defined(__FreeBSD__)
+
+/*
+ * FreeBSD does not allow query of CPU ID. Always use CPU number 0, with
+ * the assocated performance degradation on SMP.
+ */
+static inline
+int lttng_ust_get_cpu(void)
+{
+       return 0;
+}
+
+#else
+#error "Please add support for your OS into liblttng-ust/compat.h."
+#endif
 
 #endif
 
index ca19648f1d04f544d4f931bb29344fd3e43b65f4..5629876983ee56ca7d5d1c4509d45d4dca5f5f38 100644 (file)
@@ -53,6 +53,7 @@
 #include "backend.h"
 #include "frontend.h"
 #include "shm.h"
+#include "../liblttng-ust/compat.h"    /* For ENODATA */
 
 #ifndef max
 #define max(a, b)      ((a) > (b) ? (a) : (b))
index 4afb0c6e25b57f0083d1feb4532b54cbb2b612ec..c10e58a23cc281fb06128c93d16697efc2d0b019 100644 (file)
@@ -36,7 +36,7 @@ struct shm_object *shm_object_table_append(struct shm_object_table *table,
        int shmfd, waitfd[2], ret, i, sigblocked = 0;
        struct shm_object *obj;
        char *memory_map;
-       char tmp_name[NAME_MAX] = "ust-shm-tmp-XXXXXX";
+       char tmp_name[NAME_MAX] = "/ust-shm-tmp-XXXXXX";
        sigset_t all_sigs, orig_sigs;
 
        if (table->allocated_len >= table->size)
index fc52bb300f678df0fcde1253fca78083070e039a..32cc6602ea91aae89fd4a94e9c7794b83aa2a3ab 100644 (file)
@@ -36,7 +36,7 @@
 #include "local.h"
 
 /* Flush a single file, or (if fp is NULL) all files.  */
-int ust_safe_fflush(LFILE *fp)
+int ust_safe_fflush(LTTNG_UST_LFILE *fp)
 {
 
        if (fp == NULL)
@@ -50,7 +50,7 @@ int ust_safe_fflush(LFILE *fp)
 }
 
 int
-__sflush(LFILE *fp)
+__sflush(LTTNG_UST_LFILE *fp)
 {
        unsigned char *p;
        int n, t;
index 2d070430248d28971c43db9216fe1fa7f7ba51cd..422cf8234a92902e546936969e8b5abd8377b9c4 100644 (file)
 /*
  * file extension
  */
-struct __sfileext {
-       struct  __sbuf _ub; /* ungetc buffer */
+struct __lttng_ust_sfileext {
+       struct  __lttng_ust_sbuf _ub; /* ungetc buffer */
        struct wchar_io_data _wcio;     /* wide char io status */
 };
 
-#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base))
+#define _EXT(fp) ((struct __lttng_ust_sfileext *)((fp)->_ext._base))
 #define _UB(fp) _EXT(fp)->_ub
 
 #define _FILEEXT_INIT(fp) \
index 62f713e073a9f9a53353777c40c85a09f982e9bb..fb075f1ba90014eb8ac8059644b77df48caeab8f 100644 (file)
  * to the three different kinds of output buffering is handled here.
  */
 int
-__sfvwrite(LFILE *fp, struct __suio *uio)
+__sfvwrite(LTTNG_UST_LFILE *fp, struct __lttng_ust_suio *uio)
 {
        size_t len;
        char *p;
-       struct __siov *iov;
+       struct __lttng_ust_siov *iov;
        int w, s;
        char *nl;
        int nlknown, nldist;
index 19b633dbd42263b4d13c1ea3b73d0fb3b94cf16d..6553621213c109bbc1cd2009a23d068478e6ca8c 100644 (file)
 /*
  * I/O descriptors for __sfvwrite().
  */
-struct __siov {
+struct __lttng_ust_siov {
        void    *iov_base;
        size_t  iov_len;
 };
-struct __suio {
-       struct  __siov *uio_iov;
+struct __lttng_ust_suio {
+       struct  __lttng_ust_siov *uio_iov;
        int     uio_iovcnt;
        int     uio_resid;
 };
 
-extern int __sfvwrite(LFILE *, struct __suio *);
+extern int __sfvwrite(LTTNG_UST_LFILE *, struct __lttng_ust_suio *);
index c322cafc2be57a3e4f6ea2a2597e05ceaf484d55..d9251bf61c8021c5695aa526771d6a3214673442 100644 (file)
 #include "wcio.h"
 #include "fileext.h"
 
-int    __sflush(LFILE *);
-LFILE  *__sfp(void);
-int    __srefill(LFILE *);
+int    __sflush(LTTNG_UST_LFILE *);
+LTTNG_UST_LFILE        *__sfp(void);
+int    __srefill(LTTNG_UST_LFILE *);
 int    __sread(void *, char *, int);
 int    __swrite(void *, const char *, int);
 fpos_t __sseek(void *, fpos_t, int);
 int    __sclose(void *);
 void   __sinit(void);
 void   _cleanup(void);
-void   __smakebuf(LFILE *);
-int    __swhatbuf(LFILE *, size_t *, int *);
-int    _fwalk(int (*)(LFILE *));
-int    __swsetup(LFILE *);
+void   __smakebuf(LTTNG_UST_LFILE *);
+int    __swhatbuf(LTTNG_UST_LFILE *, size_t *, int *);
+int    _fwalk(int (*)(LTTNG_UST_LFILE *));
+int    __swsetup(LTTNG_UST_LFILE *);
 int    __sflags(const char *, int *);
-wint_t __fgetwc_unlock(LFILE *);
+wint_t __fgetwc_unlock(LTTNG_UST_LFILE *);
 
 extern void __atexit_register_cleanup(void (*)(void));
 extern int __sdidinit;
 
 /*
- * Return true if the given LFILE cannot be written now.
+ * Return true if the given LTTNG_UST_LFILE cannot be written now.
  */
 #define        cantwrite(fp) \
        ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
index b0ea5d3b0373cd46e282335d303beb136e1f21f4..bbc66a0743982a6bde5a925a689dbbaa4a7a441e 100644 (file)
@@ -42,8 +42,8 @@ int ust_safe_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
 {
        int ret;
        char dummy;
-       LFILE f;
-       struct __sfileext fext;
+       LTTNG_UST_LFILE f;
+       struct __lttng_ust_sfileext fext;
 
        /* While snprintf(3) specifies size_t stdio uses an int internally */
        if (n > INT_MAX)
index 882f517e7cc099ec781ece3b365dafb8f86e3991..30bedd048be2e9558762e8b13dce9b13c57dfb54 100644 (file)
@@ -35,7 +35,7 @@
 
 #include <stdarg.h>
 
-struct __sbuf {
+struct __lttng_ust_sbuf {
         unsigned char *_base;
         int     _size;
 };
@@ -64,13 +64,13 @@ struct __sbuf {
  * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
  * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
  */
-typedef struct __sFILE {
+typedef struct __lttng_ust_sFILE {
         unsigned char *_p;      /* current position in (some) buffer */
         int     _r;             /* read space left for getc() */
         int     _w;             /* write space left for putc() */
         short   _flags;         /* flags, below; this FILE is free if 0 */
         short   _file;          /* fileno, if Unix descriptor, else -1 */
-        struct  __sbuf _bf;     /* the buffer (at least 1 byte, if !NULL) */
+        struct  __lttng_ust_sbuf _bf;     /* the buffer (at least 1 byte, if !NULL) */
         int     _lbfsize;       /* 0 or -_bf._size, for inline putc */
 
         /* operations */
@@ -81,7 +81,7 @@ typedef struct __sFILE {
         int     (*_write)(void *, const char *, int);
 
         /* extension data, to avoid further ABI breakage */
-        struct  __sbuf _ext;
+        struct  __lttng_ust_sbuf _ext;
         /* data for long sequences of ungetc() */
         unsigned char *_up;     /* saved _p when _p is doing ungetc data */
         int     _ur;            /* saved _r when _r is counting ungetc data */
@@ -91,12 +91,12 @@ typedef struct __sFILE {
         unsigned char _nbuf[1]; /* guarantee a getc() buffer */
 
         /* separate buffer for fgetln() when line crosses buffer boundary */
-        struct  __sbuf _lb;     /* buffer for fgetln() */
+        struct  __lttng_ust_sbuf _lb;     /* buffer for fgetln() */
 
         /* Unix stdio files get aligned to block boundaries on fseek() */
         int     _blksize;       /* stat.st_blksize (may be != _bf._size) */
         fpos_t  _offset;        /* current lseek offset */
-} LFILE;
+} LTTNG_UST_LFILE;
 
 #define __SLBF  0x0001          /* line buffered */
 #define __SNBF  0x0002          /* unbuffered */
@@ -117,8 +117,8 @@ typedef struct __sFILE {
 
 #define __sferror(p)    (((p)->_flags & __SERR) != 0)
 
-extern int ust_safe_fflush(LFILE *fp);
-extern int ust_safe_vfprintf(LFILE *fp, const char *fmt0, va_list ap);
+extern int ust_safe_fflush(LTTNG_UST_LFILE *fp);
+extern int ust_safe_vfprintf(LTTNG_UST_LFILE *fp, const char *fmt0, va_list ap);
 
 extern size_t ust_safe_mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
 
index 1b8fba6721a8d1af6ed806959c1f2daf11c5d8e3..cedd4fb7eb9e408c498b3ba901cd4180ef0d4569 100644 (file)
@@ -92,7 +92,7 @@ static int __grow_type_table(unsigned char **typetable, int *tablesize);
  * then reset it so that it can be reused.
  */
 static int
-__sprint(LFILE *fp, struct __suio *uio)
+__sprint(LTTNG_UST_LFILE *fp, struct __lttng_ust_suio *uio)
 {
        int err;
 
@@ -112,10 +112,10 @@ __sprint(LFILE *fp, struct __suio *uio)
  * worries about ungetc buffers and so forth.
  */
 //static int
-//__sbprintf(LFILE *fp, const char *fmt, va_list ap)
+//__sbprintf(LTTNG_UST_LFILE *fp, const char *fmt, va_list ap)
 //{
 //     int ret;
-//     LFILE fake;
+//     LTTNG_UST_LFILE fake;
 //     struct __sfileext fakeext;
 //     unsigned char buf[BUFSIZ];
 //
@@ -189,13 +189,13 @@ static int exponent(char *, int, int);
 #define CHARINT                0x0800          /* 8 bit integer */
 #define MAXINT         0x1000          /* largest integer size (intmax_t) */
 
-int ust_safe_vfprintf(LFILE *fp, const char *fmt0, va_list ap)
+int ust_safe_vfprintf(LTTNG_UST_LFILE *fp, const char *fmt0, va_list ap)
 {
        char *fmt;              /* format string */
        int ch;                 /* character from fmt */
        int n, n2;              /* handy integers (short term usage) */
        char *cp;               /* handy char pointer (short term usage) */
-       struct __siov *iovp;    /* for PRINT macro */
+       struct __lttng_ust_siov *iovp;  /* for PRINT macro */
        int flags;              /* flags as above */
        int ret;                /* return value accumulator */
        int width;              /* width from format (%8d), or 0 */
@@ -241,8 +241,8 @@ int ust_safe_vfprintf(LFILE *fp, const char *fmt0, va_list ap)
        int size;               /* size of converted field or string */
        const char *xdigs = NULL;       /* digits for %[xX] conversion */
 #define NIOV 8
-       struct __suio uio;      /* output information: summary */
-       struct __siov iov[NIOV];/* ... and individual io vectors */
+       struct __lttng_ust_suio uio;    /* output information: summary */
+       struct __lttng_ust_siov iov[NIOV];/* ... and individual io vectors */
        char buf[BUF];          /* buffer with space for digits of uintmax_t */
        char ox[2];             /* space for 0x; ox[1] is either x, X, or \0 */
        union arg *argtable;    /* args, built due to positional arg */
index 433df29870db8feb8b84efecbe9efbfcd072b468..a15b8eaa2a2c98d05a593af48943077ff230f354 100644 (file)
@@ -42,7 +42,7 @@
  * _wsetup returns 0 if OK to write, nonzero otherwise.
  */
 int
-__swsetup(LFILE *fp)
+__swsetup(LTTNG_UST_LFILE *fp)
 {
        /* make sure stdio is set up */
 //     if (!__sdidinit)
index f96980ed6514ae91d2a0024011282de573c41f39..e4570ff0a694d9fea50f14f5ed8e89696832e7a1 100644 (file)
@@ -33,5 +33,11 @@ liblttng_ust_provider_ust_tests_demo3_la_LDFLAGS = \
 
 noinst_PROGRAMS = demo
 demo_SOURCES = demo.c ust_tests_demo.h
-# The demo program only depends on libdl.
-demo_LDFLAGS = -ldl
+# The demo program only depends on libdl/libc for dlopen().
+if LTTNG_UST_BUILD_WITH_LIBDL
+demo_LDADD = -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+demo_LDADD = -lc
+endif
+
index cc51b67c763ef6a06e0c4db0e5f1d67b7c781ffe..03ee4ee1ea7e2c6dabf1c9b22e88fa5b2fbf717c 100644 (file)
@@ -4,7 +4,8 @@ demo-trace shell script preloads the provider shared objects before
 executing the demo. Executing "demo" without the shell wrapper will not
 provide any tracing support. This ensures the demo binary can be
 distributed on distros without depending on having liblttng-ust.so in
-place. Note: the "demo" program must be compiled with "-ldl".
+place. Note: the "demo" program must be compiled with "-ldl" on Linux,
+with "-lc" on BSD.
 
 The simplest command to trace the demo program are:
 lttng create
index 89fd9dbfc57b993a16d700654b4cd429cbb76247..de05346c710b37251d2861946f169d8c4d4b6d79 100644 (file)
@@ -6,7 +6,14 @@ libdummy_la_SOURCES = libdummy.c
 libdummy_la_LIBADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
 libdummy_la_LDFLAGS = -rpath /nowhere
 dlopen_SOURCES = dlopen.c
-dlopen_LDADD = -ldl $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+dlopen_LDADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+dlopen_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+dlopen_LDADD += -lc
+endif
 
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index 0eff080cdd2bb4746299b9fd90a1d9a6bf203ce0..6633489424a388db1f375e5aefa3e14f8746f66e 100644 (file)
@@ -8,7 +8,14 @@ liblttng_ust_provider_ust_test_hello_la_LIBADD = \
 
 noinst_PROGRAMS = hello
 hello_SOURCES = hello.c
-hello_LDADD = -ldl liblttng-ust-provider-ust-test-hello.la
+hello_LDADD = liblttng-ust-provider-ust-test-hello.la
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+hello_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+hello_LDADD += -lc
+endif
 
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index 3e84796a731b4ecf965e57bae6d0f0f967190e99..f56f431c70f9800c74ffa37b2d63dfd4a88e9f32 100644 (file)
@@ -4,5 +4,12 @@ noinst_PROGRAMS = hello
 hello_SOURCES = hello.cpp tp.c ust_tests_hello.h
 hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
 
+if LTTNG_UST_BUILD_WITH_LIBDL
+hello_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+hello_LDADD += -lc
+endif
+
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index d866b6da6a1a9851c4061badeadef113243c9e4e..847e64d907200685a2f3a8c41560bf19f835bbce 100644 (file)
@@ -4,5 +4,12 @@ noinst_PROGRAMS = hello
 hello_SOURCES = hello.c tp.c ust_tests_hello.h
 hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
 
+if LTTNG_UST_BUILD_WITH_LIBDL
+hello_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+hello_LDADD += -lc
+endif
+
 noinst_SCRIPTS = run
 EXTRA_DIST = run
diff --git a/tests/hello/Makefile.example b/tests/hello/Makefile.example
deleted file mode 100644 (file)
index c983f4c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Example makefile for build outside of the LTTng-UST tree.
-
-hello:
-       ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c
-
-.PHONY: clean
-clean:
-       rm -f hello
diff --git a/tests/hello/Makefile.example.bsd b/tests/hello/Makefile.example.bsd
new file mode 100644 (file)
index 0000000..607171c
--- /dev/null
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+       ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+       rm -f hello
diff --git a/tests/hello/Makefile.example.linux b/tests/hello/Makefile.example.linux
new file mode 100644 (file)
index 0000000..c983f4c
--- /dev/null
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+       ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+       rm -f hello
index 967a120055a70a60b1783abe0a2130d1bf5e37a5..0705a48c5975f3934229ec02ae1edc6846ae4a7d 100644 (file)
@@ -42,6 +42,7 @@
 #include <ust-comm.h>
 #include "../../libringbuffer/backend.h"
 #include "../../libringbuffer/frontend.h"
+#include "../../liblttng-ust/compat.h" /* For ENODATA */
 
 #define MAX_NR_STREAMS 64
 #define MAX_NR_EVENTS  128
@@ -222,7 +223,7 @@ int consume_stream(struct lttng_ust_shm_handle *handle, int cpu, char *outfile)
        }
 
        /* copy */
-       outfd = open(outfile, O_WRONLY | O_CREAT | O_LARGEFILE | O_TRUNC,
+       outfd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC,
                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
        if (outfd < 0) {
                perror("open output");
index 5975789f8a95372f9fe0803bb2caa9eb0fbe0bcc..dc91b847e39abbc5a210eb3a318c8c990d0f1425 100644 (file)
@@ -42,6 +42,7 @@
 #include <ust-comm.h>
 #include <../../libringbuffer/backend.h>
 #include <../../libringbuffer/frontend.h>
+#include "../../liblttng-ust/compat.h" /* For ENODATA */
 
 #define NR_SESSIONS    4
 #define NR_CHANNELS    1
@@ -229,7 +230,7 @@ int consume_stream(struct lttng_ust_shm_handle *handle, int cpu, char *outfile)
        }
 
        /* copy */
-       outfd = open(outfile, O_WRONLY | O_CREAT | O_LARGEFILE | O_TRUNC,
+       outfd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC,
                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
        if (outfd < 0) {
                perror("open output");
This page took 0.052826 seconds and 4 git commands to generate.