Move internal headers to 'src/' dir
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 2 Apr 2021 18:45:42 +0000 (14:45 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Apr 2021 15:46:59 +0000 (11:46 -0400)
Move internal headers from the global 'include' directory to their
respective private directories under 'src/'. Remove the 'ust-' prefix
when appropriate as they are now included with the 'common/' path which
makes it easier to distinguish public and internal headers.

This is part of an effort to standardize our autotools setup across
projects to simplify maintenance.

Change-Id: If5510bbe9294ba1f0dcd4b101b363e7ef64e255d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
92 files changed:
.gitignore
configure.ac
include/Makefile.am
include/ust-bitfield.h [deleted file]
include/ust-bitmap.h [deleted file]
include/ust-comm.h [deleted file]
include/ust-compat.h [deleted file]
include/ust-context-provider.h [deleted file]
include/ust-dlfcn.h [deleted file]
include/ust-dynamic-type.h [deleted file]
include/ust-elf.h [deleted file]
include/ust-fd.h [deleted file]
include/ust-helper.h [deleted file]
include/ust-share.h [deleted file]
include/ust-snprintf.h [deleted file]
include/ust-tid.h [deleted file]
include/usterr-signal-safe.h [deleted file]
src/Makefile.am
src/common/.placeholder [deleted file]
src/common/Makefile.am [new file with mode: 0644]
src/common/align.h [new file with mode: 0644]
src/common/bitfield.h [new file with mode: 0644]
src/common/bitmap.h [new file with mode: 0644]
src/common/compat/dlfcn.h [new file with mode: 0644]
src/common/compat/tid.h [new file with mode: 0644]
src/common/dynamic-type.h [new file with mode: 0644]
src/common/elf.h [new file with mode: 0644]
src/common/logging.h [new file with mode: 0644]
src/common/macros.h [new file with mode: 0644]
src/common/patient.h [new file with mode: 0644]
src/common/safe-snprintf.h [new file with mode: 0644]
src/common/ust-context-provider.h [new file with mode: 0644]
src/common/ust-fd.h [new file with mode: 0644]
src/common/ustcomm.h [new file with mode: 0644]
src/libcounter/counter-api.h
src/libcounter/counter.c
src/libcounter/shm.c
src/libcounter/shm.h
src/liblttng-ust-comm/lttng-ust-comm.c
src/liblttng-ust-comm/lttng-ust-fd-tracker.c
src/liblttng-ust-ctl/ustctl.c
src/liblttng-ust-dl/lttng-ust-dl.c
src/liblttng-ust-fd/lttng-ust-fd.c
src/liblttng-ust-fork/ustfork.c
src/liblttng-ust-java-agent/jni/common/lttng_ust_context.c
src/liblttng-ust-libc-wrapper/lttng-ust-malloc.c
src/liblttng-ust-libc-wrapper/lttng-ust-pthread.c
src/liblttng-ust/context-internal.h
src/liblttng-ust/event-notifier-notification.c
src/liblttng-ust/getenv.c
src/liblttng-ust/lttng-bytecode-specialize.c
src/liblttng-ust/lttng-bytecode-validator.c
src/liblttng-ust/lttng-bytecode.c
src/liblttng-ust/lttng-bytecode.h
src/liblttng-ust/lttng-clock.c
src/liblttng-ust/lttng-context-cgroup-ns.c
src/liblttng-ust/lttng-context-ipc-ns.c
src/liblttng-ust/lttng-context-net-ns.c
src/liblttng-ust/lttng-context-perf-counters.c
src/liblttng-ust/lttng-context-provider.c
src/liblttng-ust/lttng-context-time-ns.c
src/liblttng-ust/lttng-context-uts-ns.c
src/liblttng-ust/lttng-context-vtid.c
src/liblttng-ust/lttng-context.c
src/liblttng-ust/lttng-events.c
src/liblttng-ust/lttng-getcpu.c
src/liblttng-ust/lttng-probes.c
src/liblttng-ust/lttng-ring-buffer-client-template.h
src/liblttng-ust/lttng-ring-buffer-metadata-client-template.h
src/liblttng-ust/lttng-tracer-core.h
src/liblttng-ust/lttng-ust-abi.c
src/liblttng-ust/lttng-ust-comm.c
src/liblttng-ust/lttng-ust-dynamic-type.c
src/liblttng-ust/lttng-ust-elf.c
src/liblttng-ust/lttng-ust-statedump.c
src/liblttng-ust/tracef.c
src/liblttng-ust/tracelog.c
src/liblttng-ust/tracepoint.c
src/liblttng-ust/ust-core.c
src/liblttng-ust/ust-events-internal.h
src/libringbuffer/frontend_types.h
src/libringbuffer/ring_buffer_backend.c
src/libringbuffer/ring_buffer_frontend.c
src/libringbuffer/shm.c
src/libringbuffer/shm.h
src/snprintf/core.c
src/snprintf/patient_write.c
src/snprintf/snprintf.c
tests/compile/test-app-ctx/hello.c
tests/unit/libringbuffer/shm.c
tests/unit/snprintf/snprintf.c
tests/unit/ust-elf/ust-elf.c

index 42171575269fcd4dc83e9d899bc447a73d2316d0..37d46f9fd5fcc4bbf16710abd0604b771f5110a5 100644 (file)
@@ -123,6 +123,7 @@ cscope.*
 /doc/examples/Makefile
 /doc/man/Makefile
 /include/Makefile
+/src/common/Makefile
 /src/libcounter/Makefile
 /src/liblttng-ust-comm/Makefile
 /src/liblttng-ust-ctl/Makefile
index 80226c789f0d9a8ae9d6200cc1e14e6d6c73a1ca..00b70f2a7c8194c8da6c24bd33e245e2b66a05b7 100644 (file)
@@ -518,6 +518,7 @@ AC_CONFIG_FILES([
   doc/Makefile
   doc/man/Makefile
   include/Makefile
+  src/common/Makefile
   src/libcounter/Makefile
   src/liblttng-ust-comm/Makefile
   src/liblttng-ust-ctl/Makefile
index 854b4785ee9c852ff5e639fb7ec9b69680df6bd2..5ef7c9e5f86325759f1ce51c0dc840afd08b37ee 100644 (file)
@@ -42,34 +42,3 @@ nobase_include_HEADERS = \
 nobase_nodist_include_HEADERS = \
        lttng/ust-config.h \
        lttng/ust-version.h
-
-
-###                        ###
-### Global private headers ###
-###                        ###
-
-noinst_HEADERS = \
-       usterr-signal-safe.h \
-       ust-snprintf.h \
-       ust-bitmap.h \
-       ust-comm.h \
-       ust-compat.h \
-       ust-elf.h \
-       ust-tid.h \
-       ust-bitfield.h \
-       ust-dlfcn.h \
-       ust-dynamic-type.h \
-       ust-helper.h \
-       ust-share.h
-
-
-# These headers should be moved to the public headers when tested and
-# documented. The symbols are still part of the ABI.
-
-# Used by the Java jni interface.
-noinst_HEADERS += \
-       ust-context-provider.h
-
-# Used by liblttng-ust-fd
-noinst_HEADERS += \
-       ust-fd.h
diff --git a/include/ust-bitfield.h b/include/ust-bitfield.h
deleted file mode 100644 (file)
index 105dae5..0000000
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2010-2019 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _BABELTRACE_BITFIELD_H
-#define _BABELTRACE_BITFIELD_H
-
-#include <stdint.h>    /* C99 5.2.4.2 Numerical limits */
-#include <limits.h>    /* C99 5.2.4.2 Numerical limits */
-#include <stdbool.h>   /* C99 7.16 bool type */
-#include <lttng/ust-endian.h>  /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
-
-/*
- * This header strictly follows the C99 standard, except for use of the
- * compiler-specific __typeof__.
- */
-
-/*
- * This bitfield header requires the compiler representation of signed
- * integers to be two's complement.
- */
-#if (-1 != ~0)
-#error "bitfield.h requires the compiler representation of signed integers to be two's complement."
-#endif
-
-#define _bt_is_signed_type(type)       ((type) -1 < (type) 1)
-
-/*
- * Produce a build-time error if the condition `cond` is non-zero.
- * Evaluates as a size_t expression.
- */
-#ifdef __cplusplus
-#define _BT_BUILD_ASSERT(cond) ([]{static_assert((cond), "");}, 0)
-#else
-#define _BT_BUILD_ASSERT(cond)                                 \
-       sizeof(struct { int f:(2 * !!(cond) - 1); })
-#endif
-
-/*
- * Cast value `v` to an unsigned integer of the same size as `v`.
- */
-#define _bt_cast_value_to_unsigned(v)                                  \
-       (sizeof(v) == sizeof(uint8_t) ? (uint8_t) (v) :                 \
-       sizeof(v) == sizeof(uint16_t) ? (uint16_t) (v) :                \
-       sizeof(v) == sizeof(uint32_t) ? (uint32_t) (v) :                \
-       sizeof(v) == sizeof(uint64_t) ? (uint64_t) (v) :                \
-       _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
-
-/*
- * Cast value `v` to an unsigned integer type of the size of type `type`
- * *without* sign-extension.
- *
- * The unsigned cast ensures that we're not shifting a negative value,
- * which is undefined in C. However, this limits the maximum type size
- * of `type` to 64-bit. Generate a compile-time error if the size of
- * `type` is larger than 64-bit.
- */
-#define _bt_cast_value_to_unsigned_type(type, v)                       \
-       (sizeof(type) == sizeof(uint8_t) ?                              \
-               (uint8_t) _bt_cast_value_to_unsigned(v) :               \
-       sizeof(type) == sizeof(uint16_t) ?                              \
-               (uint16_t) _bt_cast_value_to_unsigned(v) :              \
-       sizeof(type) == sizeof(uint32_t) ?                              \
-               (uint32_t) _bt_cast_value_to_unsigned(v) :              \
-       sizeof(type) == sizeof(uint64_t) ?                              \
-               (uint64_t) _bt_cast_value_to_unsigned(v) :              \
-       _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
-
-/*
- * _bt_fill_mask evaluates to a "type" integer with all bits set.
- */
-#define _bt_fill_mask(type)    ((type) ~(type) 0)
-
-/*
- * Left shift a value `v` of `shift` bits.
- *
- * The type of `v` can be signed or unsigned integer.
- * The value of `shift` must be less than the size of `v` (in bits),
- * otherwise the behavior is undefined.
- * Evaluates to the result of the shift operation.
- *
- * According to the C99 standard, left shift of a left hand-side signed
- * type is undefined if it has a negative value or if the result cannot
- * be represented in the result type. This bitfield header discards the
- * bits that are left-shifted beyond the result type representation,
- * which is the behavior of an unsigned type left shift operation.
- * Therefore, always perform left shift on an unsigned type.
- *
- * This macro should not be used if `shift` can be greater or equal than
- * the bitwidth of `v`. See `_bt_safe_lshift`.
- */
-#define _bt_lshift(v, shift)                                           \
-       ((__typeof__(v)) (_bt_cast_value_to_unsigned(v) << (shift)))
-
-/*
- * Generate a mask of type `type` with the `length` least significant bits
- * cleared, and the most significant bits set.
- */
-#define _bt_make_mask_complement(type, length)                         \
-       _bt_lshift(_bt_fill_mask(type), length)
-
-/*
- * Generate a mask of type `type` with the `length` least significant bits
- * set, and the most significant bits cleared.
- */
-#define _bt_make_mask(type, length)                                    \
-       ((type) ~_bt_make_mask_complement(type, length))
-
-/*
- * Right shift a value `v` of `shift` bits.
- *
- * The type of `v` can be signed or unsigned integer.
- * The value of `shift` must be less than the size of `v` (in bits),
- * otherwise the behavior is undefined.
- * Evaluates to the result of the shift operation.
- *
- * According to the C99 standard, right shift of a left hand-side signed
- * type which has a negative value is implementation defined. This
- * bitfield header relies on the right shift implementation carrying the
- * sign bit. If the compiler implementation has a different behavior,
- * emulate carrying the sign bit.
- *
- * This macro should not be used if `shift` can be greater or equal than
- * the bitwidth of `v`. See `_bt_safe_rshift`.
- */
-#if ((-1 >> 1) == -1)
-#define _bt_rshift(v, shift)   ((v) >> (shift))
-#else
-#define _bt_rshift(v, shift)                                           \
-       ((__typeof__(v)) ((_bt_cast_value_to_unsigned(v) >> (shift)) |  \
-               ((v) < 0 ? _bt_make_mask_complement(__typeof__(v),      \
-                       sizeof(v) * CHAR_BIT - (shift)) : 0)))
-#endif
-
-/*
- * Right shift a signed or unsigned integer with `shift` value being an
- * arbitrary number of bits. `v` is modified by this macro. The shift
- * is transformed into a sequence of `_nr_partial_shifts` consecutive
- * shift operations, each of a number of bits smaller than the bitwidth
- * of `v`, ending with a shift of the number of left over bits.
- */
-#define _bt_safe_rshift(v, shift)                                      \
-do {                                                                   \
-       unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
-       unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
-                                                                       \
-       for (; _nr_partial_shifts; _nr_partial_shifts--)                \
-               (v) = _bt_rshift(v, sizeof(v) * CHAR_BIT - 1);          \
-       (v) = _bt_rshift(v, _leftover_bits);                            \
-} while (0)
-
-/*
- * Left shift a signed or unsigned integer with `shift` value being an
- * arbitrary number of bits. `v` is modified by this macro. The shift
- * is transformed into a sequence of `_nr_partial_shifts` consecutive
- * shift operations, each of a number of bits smaller than the bitwidth
- * of `v`, ending with a shift of the number of left over bits.
- */
-#define _bt_safe_lshift(v, shift)                                      \
-do {                                                                   \
-       unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
-       unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
-                                                                       \
-       for (; _nr_partial_shifts; _nr_partial_shifts--)                \
-               (v) = _bt_lshift(v, sizeof(v) * CHAR_BIT - 1);          \
-       (v) = _bt_lshift(v, _leftover_bits);                            \
-} while (0)
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- *
- * Save integer to the bitfield, which starts at the "start" bit, has "len"
- * bits.
- * The inside of a bitfield is from high bits to low bits.
- * Uses native endianness.
- * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
- * For signed "v", sign-extend v if bitfield is larger than v.
- *
- * On little endian, bytes are placed from the less significant to the most
- * significant. Also, consecutive bitfields are placed from lower bits to higher
- * bits.
- *
- * On big endian, bytes are places from most significant to less significant.
- * Also, consecutive bitfields are placed from higher to lower bits.
- */
-
-#define _bt_bitfield_write_le(ptr, type, start, length, v)             \
-do {                                                                   \
-       __typeof__(v) _v = (v);                                 \
-       type *_ptr = (void *) (ptr);                                    \
-       unsigned long _start = (start), _length = (length);             \
-       type _mask, _cmask;                                             \
-       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
-       unsigned long _start_unit, _end_unit, _this_unit;               \
-       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
-                                                                       \
-       if (!_length)                                                   \
-               break;                                                  \
-                                                                       \
-       _end = _start + _length;                                        \
-       _start_unit = _start / _ts;                                     \
-       _end_unit = (_end + (_ts - 1)) / _ts;                           \
-                                                                       \
-       /* Trim v high bits */                                          \
-       if (_length < sizeof(_v) * CHAR_BIT)                            \
-               _v &= _bt_make_mask(__typeof__(_v), _length);           \
-                                                                       \
-       /* We can now append v with a simple "or", shift it piece-wise */ \
-       _this_unit = _start_unit;                                       \
-       if (_start_unit == _end_unit - 1) {                             \
-               _mask = _bt_make_mask(type, _start % _ts);              \
-               if (_end % _ts)                                         \
-                       _mask |= _bt_make_mask_complement(type, _end % _ts); \
-               _cmask = _bt_lshift((type) (_v), _start % _ts);         \
-               _cmask &= ~_mask;                                       \
-               _ptr[_this_unit] &= _mask;                              \
-               _ptr[_this_unit] |= _cmask;                             \
-               break;                                                  \
-       }                                                               \
-       if (_start % _ts) {                                             \
-               _cshift = _start % _ts;                                 \
-               _mask = _bt_make_mask(type, _cshift);                   \
-               _cmask = _bt_lshift((type) (_v), _cshift);              \
-               _cmask &= ~_mask;                                       \
-               _ptr[_this_unit] &= _mask;                              \
-               _ptr[_this_unit] |= _cmask;                             \
-               _bt_safe_rshift(_v, _ts - _cshift);                     \
-               _start += _ts - _cshift;                                \
-               _this_unit++;                                           \
-       }                                                               \
-       for (; _this_unit < _end_unit - 1; _this_unit++) {              \
-               _ptr[_this_unit] = (type) _v;                           \
-               _bt_safe_rshift(_v, _ts);                               \
-               _start += _ts;                                          \
-       }                                                               \
-       if (_end % _ts) {                                               \
-               _mask = _bt_make_mask_complement(type, _end % _ts);     \
-               _cmask = (type) _v;                                     \
-               _cmask &= ~_mask;                                       \
-               _ptr[_this_unit] &= _mask;                              \
-               _ptr[_this_unit] |= _cmask;                             \
-       } else                                                          \
-               _ptr[_this_unit] = (type) _v;                           \
-} while (0)
-
-#define _bt_bitfield_write_be(ptr, type, start, length, v)             \
-do {                                                                   \
-       __typeof__(v) _v = (v);                                         \
-       type *_ptr = (void *) (ptr);                                    \
-       unsigned long _start = (start), _length = (length);             \
-       type _mask, _cmask;                                             \
-       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
-       unsigned long _start_unit, _end_unit, _this_unit;               \
-       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
-                                                                       \
-       if (!_length)                                                   \
-               break;                                                  \
-                                                                       \
-       _end = _start + _length;                                        \
-       _start_unit = _start / _ts;                                     \
-       _end_unit = (_end + (_ts - 1)) / _ts;                           \
-                                                                       \
-       /* Trim v high bits */                                          \
-       if (_length < sizeof(_v) * CHAR_BIT)                            \
-               _v &= _bt_make_mask(__typeof__(_v), _length);           \
-                                                                       \
-       /* We can now append v with a simple "or", shift it piece-wise */ \
-       _this_unit = _end_unit - 1;                                     \
-       if (_start_unit == _end_unit - 1) {                             \
-               _mask = _bt_make_mask(type, (_ts - (_end % _ts)) % _ts); \
-               if (_start % _ts)                                       \
-                       _mask |= _bt_make_mask_complement(type, _ts - (_start % _ts)); \
-               _cmask = _bt_lshift((type) (_v), (_ts - (_end % _ts)) % _ts); \
-               _cmask &= ~_mask;                                       \
-               _ptr[_this_unit] &= _mask;                              \
-               _ptr[_this_unit] |= _cmask;                             \
-               break;                                                  \
-       }                                                               \
-       if (_end % _ts) {                                               \
-               _cshift = _end % _ts;                                   \
-               _mask = _bt_make_mask(type, _ts - _cshift);             \
-               _cmask = _bt_lshift((type) (_v), _ts - _cshift);        \
-               _cmask &= ~_mask;                                       \
-               _ptr[_this_unit] &= _mask;                              \
-               _ptr[_this_unit] |= _cmask;                             \
-               _bt_safe_rshift(_v, _cshift);                           \
-               _end -= _cshift;                                        \
-               _this_unit--;                                           \
-       }                                                               \
-       for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
-               _ptr[_this_unit] = (type) _v;                           \
-               _bt_safe_rshift(_v, _ts);                               \
-               _end -= _ts;                                            \
-       }                                                               \
-       if (_start % _ts) {                                             \
-               _mask = _bt_make_mask_complement(type, _ts - (_start % _ts)); \
-               _cmask = (type) _v;                                     \
-               _cmask &= ~_mask;                                       \
-               _ptr[_this_unit] &= _mask;                              \
-               _ptr[_this_unit] |= _cmask;                             \
-       } else                                                          \
-               _ptr[_this_unit] = (type) _v;                           \
-} while (0)
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- * bt_bitfield_write_le - write integer to a bitfield in little endian
- * bt_bitfield_write_be - write integer to a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, start, length, v)                 \
-       _bt_bitfield_write_le(ptr, type, start, length, v)
-
-#define bt_bitfield_write_le(ptr, type, start, length, v)              \
-       _bt_bitfield_write_le(ptr, type, start, length, v)
-
-#define bt_bitfield_write_be(ptr, type, start, length, v)              \
-       _bt_bitfield_write_be(ptr, unsigned char, start, length, v)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, start, length, v)                 \
-       _bt_bitfield_write_be(ptr, type, start, length, v)
-
-#define bt_bitfield_write_le(ptr, type, start, length, v)              \
-       _bt_bitfield_write_le(ptr, unsigned char, start, length, v)
-
-#define bt_bitfield_write_be(ptr, type, start, length, v)              \
-       _bt_bitfield_write_be(ptr, type, start, length, v)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#define _bt_bitfield_read_le(ptr, type, start, length, vptr)           \
-do {                                                                   \
-       __typeof__(*(vptr)) *_vptr = (vptr);                            \
-       __typeof__(*_vptr) _v;                                          \
-       type *_ptr = (type *) (ptr);                                    \
-       unsigned long _start = (start), _length = (length);             \
-       type _mask, _cmask;                                             \
-       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
-       unsigned long _start_unit, _end_unit, _this_unit;               \
-       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
-                                                                       \
-       if (!_length) {                                                 \
-               *_vptr = 0;                                             \
-               break;                                                  \
-       }                                                               \
-                                                                       \
-       _end = _start + _length;                                        \
-       _start_unit = _start / _ts;                                     \
-       _end_unit = (_end + (_ts - 1)) / _ts;                           \
-                                                                       \
-       _this_unit = _end_unit - 1;                                     \
-       if (_bt_is_signed_type(__typeof__(_v))                          \
-           && (_ptr[_this_unit] & _bt_lshift((type) 1, (_end % _ts ? _end % _ts : _ts) - 1))) \
-               _v = ~(__typeof__(_v)) 0;                               \
-       else                                                            \
-               _v = 0;                                                 \
-       if (_start_unit == _end_unit - 1) {                             \
-               _cmask = _ptr[_this_unit];                              \
-               _cmask = _bt_rshift(_cmask, _start % _ts);              \
-               if ((_end - _start) % _ts) {                            \
-                       _mask = _bt_make_mask(type, _end - _start);     \
-                       _cmask &= _mask;                                \
-               }                                                       \
-               _bt_safe_lshift(_v, _end - _start);                     \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
-               *_vptr = _v;                                            \
-               break;                                                  \
-       }                                                               \
-       if (_end % _ts) {                                               \
-               _cshift = _end % _ts;                                   \
-               _mask = _bt_make_mask(type, _cshift);                   \
-               _cmask = _ptr[_this_unit];                              \
-               _cmask &= _mask;                                        \
-               _bt_safe_lshift(_v, _cshift);                           \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
-               _end -= _cshift;                                        \
-               _this_unit--;                                           \
-       }                                                               \
-       for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
-               _bt_safe_lshift(_v, _ts);                               \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
-               _end -= _ts;                                            \
-       }                                                               \
-       if (_start % _ts) {                                             \
-               _mask = _bt_make_mask(type, _ts - (_start % _ts));      \
-               _cmask = _ptr[_this_unit];                              \
-               _cmask = _bt_rshift(_cmask, _start % _ts);              \
-               _cmask &= _mask;                                        \
-               _bt_safe_lshift(_v, _ts - (_start % _ts));              \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
-       } else {                                                        \
-               _bt_safe_lshift(_v, _ts);                               \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
-       }                                                               \
-       *_vptr = _v;                                                    \
-} while (0)
-
-#define _bt_bitfield_read_be(ptr, type, start, length, vptr)           \
-do {                                                                   \
-       __typeof__(*(vptr)) *_vptr = (vptr);                            \
-       __typeof__(*_vptr) _v;                                          \
-       type *_ptr = (void *) (ptr);                                    \
-       unsigned long _start = (start), _length = (length);             \
-       type _mask, _cmask;                                             \
-       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
-       unsigned long _start_unit, _end_unit, _this_unit;               \
-       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
-                                                                       \
-       if (!_length) {                                                 \
-               *_vptr = 0;                                             \
-               break;                                                  \
-       }                                                               \
-                                                                       \
-       _end = _start + _length;                                        \
-       _start_unit = _start / _ts;                                     \
-       _end_unit = (_end + (_ts - 1)) / _ts;                           \
-                                                                       \
-       _this_unit = _start_unit;                                       \
-       if (_bt_is_signed_type(__typeof__(_v))                          \
-           && (_ptr[_this_unit] & _bt_lshift((type) 1, _ts - (_start % _ts) - 1))) \
-               _v = ~(__typeof__(_v)) 0;                               \
-       else                                                            \
-               _v = 0;                                                 \
-       if (_start_unit == _end_unit - 1) {                             \
-               _cmask = _ptr[_this_unit];                              \
-               _cmask = _bt_rshift(_cmask, (_ts - (_end % _ts)) % _ts); \
-               if ((_end - _start) % _ts) {                            \
-                       _mask = _bt_make_mask(type, _end - _start);     \
-                       _cmask &= _mask;                                \
-               }                                                       \
-               _bt_safe_lshift(_v, _end - _start);                     \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
-               *_vptr = _v;                                            \
-               break;                                                  \
-       }                                                               \
-       if (_start % _ts) {                                             \
-               _cshift = _start % _ts;                                 \
-               _mask = _bt_make_mask(type, _ts - _cshift);             \
-               _cmask = _ptr[_this_unit];                              \
-               _cmask &= _mask;                                        \
-               _bt_safe_lshift(_v, _ts - _cshift);                     \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
-               _start += _ts - _cshift;                                \
-               _this_unit++;                                           \
-       }                                                               \
-       for (; _this_unit < _end_unit - 1; _this_unit++) {              \
-               _bt_safe_lshift(_v, _ts);                               \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
-               _start += _ts;                                          \
-       }                                                               \
-       if (_end % _ts) {                                               \
-               _mask = _bt_make_mask(type, _end % _ts);                \
-               _cmask = _ptr[_this_unit];                              \
-               _cmask = _bt_rshift(_cmask, _ts - (_end % _ts));        \
-               _cmask &= _mask;                                        \
-               _bt_safe_lshift(_v, _end % _ts);                        \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
-       } else {                                                        \
-               _bt_safe_lshift(_v, _ts);                               \
-               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
-       }                                                               \
-       *_vptr = _v;                                                    \
-} while (0)
-
-/*
- * bt_bitfield_read - read integer from a bitfield in native endianness
- * bt_bitfield_read_le - read integer from a bitfield in little endian
- * bt_bitfield_read_be - read integer from a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_read(ptr, type, start, length, vptr)               \
-       _bt_bitfield_read_le(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_le(ptr, type, start, length, vptr)            \
-       _bt_bitfield_read_le(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_be(ptr, type, start, length, vptr)            \
-       _bt_bitfield_read_be(ptr, unsigned char, start, length, vptr)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_read(ptr, type, start, length, vptr)               \
-       _bt_bitfield_read_be(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_le(ptr, type, start, length, vptr)            \
-       _bt_bitfield_read_le(ptr, unsigned char, start, length, vptr)
-
-#define bt_bitfield_read_be(ptr, type, start, length, vptr)            \
-       _bt_bitfield_read_be(ptr, type, start, length, vptr)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#endif /* _BABELTRACE_BITFIELD_H */
diff --git a/include/ust-bitmap.h b/include/ust-bitmap.h
deleted file mode 100644 (file)
index 29cc22e..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * LTTng Bitmap API
- */
-
-#ifndef _LTTNG_BITMAP_H
-#define _LTTNG_BITMAP_H
-
-#include <urcu/compiler.h>
-#include <urcu/system.h>
-#include <urcu/uatomic.h>
-#include <stdbool.h>
-
-static inline void lttng_bitmap_index(unsigned int index, unsigned int *word,
-               unsigned int *bit)
-{
-       *word = index / CAA_BITS_PER_LONG;
-       *bit = index % CAA_BITS_PER_LONG;
-}
-
-static inline void lttng_bitmap_set_bit(unsigned int index, unsigned long *p)
-{
-       unsigned int word, bit;
-       unsigned long val;
-
-       lttng_bitmap_index(index, &word, &bit);
-       val = 1U << bit;
-       uatomic_or(p + word, val);
-}
-
-static inline void lttng_bitmap_clear_bit(unsigned int index, unsigned long *p)
-{
-       unsigned int word, bit;
-       unsigned long val;
-
-       lttng_bitmap_index(index, &word, &bit);
-       val = ~(1U << bit);
-       uatomic_and(p + word, val);
-}
-
-static inline bool lttng_bitmap_test_bit(unsigned int index, unsigned long *p)
-{
-       unsigned int word, bit;
-
-       lttng_bitmap_index(index, &word, &bit);
-       return (CMM_LOAD_SHARED(p[word]) >> bit) & 0x1;
-}
-
-#endif /* _LTTNG_BITMAP_H */
diff --git a/include/ust-comm.h b/include/ust-comm.h
deleted file mode 100644 (file)
index 775b6be..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
- * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-/*
- * This header is meant for liblttng and libust internal use ONLY.
- * These declarations should NOT be considered stable API.
- */
-
-#ifndef _LTTNG_UST_COMM_H
-#define _LTTNG_UST_COMM_H
-
-#include <stdint.h>
-#include <limits.h>
-#include <unistd.h>
-#include <lttng/ust-abi.h>
-#include <lttng/ust-error.h>
-#include <lttng/ust-compiler.h>
-#include <lttng/ust-ctl.h>
-
-/*
- * Default timeout the application waits for the sessiond to send its
- * "register done" command. Can be overridden with the environment
- * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
- * found, the application proceeds directly without any delay.
- */
-#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS       3000
-
-#define LTTNG_DEFAULT_RUNDIR                           LTTNG_SYSTEM_RUNDIR
-#define LTTNG_DEFAULT_HOME_RUNDIR                      ".lttng"
-
-/* Queue size of listen(2) */
-#define LTTNG_UST_COMM_MAX_LISTEN                      10
-#define LTTNG_UST_COMM_REG_MSG_PADDING                 64
-
-struct lttng_ust_event_field;
-struct lttng_ust_ctx_field;
-struct lttng_ust_enum_entry;
-struct lttng_integer_type;
-struct lttng_ust_session;
-
-struct ustctl_reg_msg {
-       uint32_t magic;
-       uint32_t major;
-       uint32_t minor;
-       uint32_t pid;
-       uint32_t ppid;
-       uint32_t uid;
-       uint32_t gid;
-       uint32_t bits_per_long;
-       uint32_t uint8_t_alignment;
-       uint32_t uint16_t_alignment;
-       uint32_t uint32_t_alignment;
-       uint32_t uint64_t_alignment;
-       uint32_t long_alignment;
-       uint32_t socket_type;                   /* enum ustctl_socket_type */
-       char name[LTTNG_UST_ABI_PROCNAME_LEN];  /* process name */
-       char padding[LTTNG_UST_COMM_REG_MSG_PADDING];
-} __attribute__((packed));
-
-/*
- * Data structure for the commands sent from sessiond to UST.
- */
-#define USTCOMM_MSG_PADDING1           32
-#define USTCOMM_MSG_PADDING2           32
-struct ustcomm_ust_msg {
-       uint32_t handle;
-       uint32_t cmd;
-       char padding[USTCOMM_MSG_PADDING1];
-       union {
-               struct lttng_ust_abi_channel channel;
-               struct lttng_ust_abi_stream stream;
-               struct lttng_ust_abi_event event;
-               struct lttng_ust_abi_context context;
-               struct lttng_ust_abi_tracer_version version;
-               struct lttng_ust_abi_tracepoint_iter tracepoint;
-               struct {
-                       uint32_t data_size;     /* following filter data */
-                       uint32_t reloc_offset;
-                       uint64_t seqnum;
-               } __attribute__((packed)) filter;
-               struct {
-                       uint32_t count; /* how many names follow */
-               } __attribute__((packed)) exclusion;
-               struct {
-                       uint32_t data_size;     /* following capture data */
-                       uint32_t reloc_offset;
-                       uint64_t seqnum;
-               } __attribute__((packed)) capture;
-               struct lttng_ust_abi_counter counter;
-               struct lttng_ust_abi_counter_global counter_global;
-               struct lttng_ust_abi_counter_cpu counter_cpu;
-               /*
-                * For lttng_ust_abi_EVENT_NOTIFIER_CREATE, a struct
-                * lttng_ust_abi_event_notifier implicitly follows struct
-                * ustcomm_ust_msg.
-                */
-               struct {
-                       /* Length of struct lttng_ust_abi_event_notifier */
-                       uint32_t len;
-               } event_notifier;
-               char padding[USTCOMM_MSG_PADDING2];
-       } u;
-} __attribute__((packed));
-
-/*
- * Data structure for the response from UST to the session daemon.
- * cmd_type is sent back in the reply for validation.
- */
-#define USTCOMM_REPLY_PADDING1         32
-#define USTCOMM_REPLY_PADDING2         32
-struct ustcomm_ust_reply {
-       uint32_t handle;
-       uint32_t cmd;
-       int32_t ret_code;       /* enum ustcomm_return_code */
-       uint32_t ret_val;       /* return value */
-       char padding[USTCOMM_REPLY_PADDING1];
-       union {
-               struct {
-                       uint64_t memory_map_size;
-               } __attribute__((packed)) channel;
-               struct {
-                       uint64_t memory_map_size;
-               } __attribute__((packed)) stream;
-               struct lttng_ust_abi_tracer_version version;
-               struct lttng_ust_abi_tracepoint_iter tracepoint;
-               char padding[USTCOMM_REPLY_PADDING2];
-       } u;
-} __attribute__((packed));
-
-struct ustcomm_notify_hdr {
-       uint32_t notify_cmd;
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_EVENT_MSG_PADDING       32
-struct ustcomm_notify_event_msg {
-       uint32_t session_objd;
-       uint32_t channel_objd;
-       char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       int32_t loglevel;
-       uint32_t signature_len;
-       uint32_t fields_len;
-       uint32_t model_emf_uri_len;
-       char padding[USTCOMM_NOTIFY_EVENT_MSG_PADDING];
-       /* followed by signature, fields, and model_emf_uri */
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING     32
-struct ustcomm_notify_event_reply {
-       int32_t ret_code;       /* 0: ok, negative: error code */
-       uint32_t event_id;
-       char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_ENUM_MSG_PADDING                32
-struct ustcomm_notify_enum_msg {
-       uint32_t session_objd;
-       char enum_name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       uint32_t entries_len;
-       char padding[USTCOMM_NOTIFY_ENUM_MSG_PADDING];
-       /* followed by enum entries */
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING     32
-struct ustcomm_notify_enum_reply {
-       int32_t ret_code;       /* 0: ok, negative: error code */
-       uint64_t enum_id;
-       char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_CHANNEL_MSG_PADDING     32
-struct ustcomm_notify_channel_msg {
-       uint32_t session_objd;
-       uint32_t channel_objd;
-       uint32_t ctx_fields_len;
-       char padding[USTCOMM_NOTIFY_CHANNEL_MSG_PADDING];
-       /* followed by context fields */
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING   32
-struct ustcomm_notify_channel_reply {
-       int32_t ret_code;       /* 0: ok, negative: error code */
-       uint32_t chan_id;
-       uint32_t header_type;   /* enum ustctl_channel_header */
-       char padding[USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING];
-} __attribute__((packed));
-
-/*
- * LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
- * struct lttng_ust_field_iter field.
- */
-
-int ustcomm_create_unix_sock(const char *pathname)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_connect_unix_sock(const char *pathname,
-       long timeout)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_accept_unix_sock(int sock)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_listen_unix_sock(int sock)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_close_unix_sock(int sock)
-       __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
-       __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len)
-       __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
-       __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
-       __attribute__((visibility("hidden")));
-
-const char *ustcomm_get_readable_code(int code)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
-       uint32_t expected_handle, uint32_t expected_cmd)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_send_app_cmd(int sock,
-               struct ustcomm_ust_msg *lum,
-               struct ustcomm_ust_reply *lur)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_recv_fd(int sock)
-       __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_channel_from_sessiond(int sock,
-               void **chan_data, uint64_t len, int *wakeup_fd)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_recv_stream_from_sessiond(int sock,
-               uint64_t *memory_map_size,
-               int *shm_fd, int *wakeup_fd)
-       __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_event_notifier_notif_fd_from_sessiond(int sock,
-               int *event_notifier_notif_fd)
-       __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_counter_from_sessiond(int sock,
-               void **counter_data, uint64_t len)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_recv_counter_shm_from_sessiond(int sock,
-               int *shm_fd)
-       __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_send_reg_msg(int sock,
-               enum ustctl_socket_type type,
-               uint32_t bits_per_long,
-               uint32_t uint8_t_alignment,
-               uint32_t uint16_t_alignment,
-               uint32_t uint32_t_alignment,
-               uint32_t uint64_t_alignment,
-               uint32_t long_alignment)
-       __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_register_event(int sock,
-       struct lttng_ust_session *session,
-       int session_objd,               /* session descriptor */
-       int channel_objd,               /* channel descriptor */
-       const char *event_name,         /* event name (input) */
-       int loglevel,
-       const char *signature,          /* event signature (input) */
-       size_t nr_fields,               /* fields */
-       const struct lttng_ust_event_field **fields,
-       const char *model_emf_uri,
-       uint32_t *id)                   /* event id (output) */
-       __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_register_enum(int sock,
-       int session_objd,               /* session descriptor */
-       const char *enum_name,          /* enum name (input) */
-       size_t nr_entries,              /* entries */
-       const struct lttng_ust_enum_entry **entries,
-       uint64_t *id)                   /* enum id (output) */
-       __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_register_channel(int sock,
-       struct lttng_ust_session *session,
-       int session_objd,               /* session descriptor */
-       int channel_objd,               /* channel descriptor */
-       size_t nr_ctx_fields,
-       struct lttng_ust_ctx_field *ctx_fields,
-       uint32_t *chan_id,              /* channel id (output) */
-       int *header_type)               /* header type (output) */
-       __attribute__((visibility("hidden")));
-
-int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec)
-       __attribute__((visibility("hidden")));
-
-int ustcomm_setsockopt_snd_timeout(int sock, unsigned int msec)
-       __attribute__((visibility("hidden")));
-
-#endif /* _LTTNG_UST_COMM_H */
diff --git a/include/ust-compat.h b/include/ust-compat.h
deleted file mode 100644 (file)
index c148e1b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_COMPAT_H
-#define _LTTNG_UST_COMPAT_H
-
-#include <unistd.h>
-#include <limits.h>
-
-#ifdef __FreeBSD__
-#include <machine/param.h>
-#endif
-
-#ifdef _SC_PAGE_SIZE
-#define LTTNG_UST_PAGE_SIZE    sysconf(_SC_PAGE_SIZE)
-#elif defined(PAGE_SIZE)
-#define LTTNG_UST_PAGE_SIZE    PAGE_SIZE
-#else
-#error "Please add page size detection for your OS."
-#endif
-
-#define LTTNG_UST_PAGE_MASK    (~(LTTNG_UST_PAGE_SIZE - 1))
-
-#define __LTTNG_UST_ALIGN_MASK(v, mask)        (((v) + (mask)) & ~(mask))
-#define LTTNG_UST_ALIGN(v, align)      __LTTNG_UST_ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
-#define LTTNG_UST_PAGE_ALIGN(addr)     LTTNG_UST_ALIGN(addr, LTTNG_UST_PAGE_SIZE)
-
-#endif
diff --git a/include/ust-context-provider.h b/include/ust-context-provider.h
deleted file mode 100644 (file)
index 85beac9..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * The context provider feature is part of the ABI and used by the Java jni
- * interface. This header should be moved to the public header directory once
- * some test code and documentation is written.
- */
-
-#ifndef _LTTNG_UST_CONTEXT_PROVIDER_H
-#define _LTTNG_UST_CONTEXT_PROVIDER_H
-
-#include <stddef.h>
-#include <lttng/ust-events.h>
-
-#include "ust-dynamic-type.h"
-
-struct lttng_ust_registered_context_provider;
-
-/*
- * Context value
- *
- * IMPORTANT: this structure is part of the ABI between the probe and
- * UST. Additional selectors may be added in the future, mapping to new
- * union fields, which means the overall size of this structure may
- * increase. This means this structure should never be nested within a
- * public structure interface, nor embedded in an array.
- */
-
-struct lttng_ust_ctx_value {
-       enum lttng_ust_dynamic_type sel;        /* Type selector */
-       union {
-               int64_t s64;
-               uint64_t u64;
-               const char *str;
-               double d;
-       } u;
-};
-
-/*
- * Context provider
- *
- * IMPORTANT: this structure is part of the ABI between the probe and
- * UST. Fields need to be only added at the end, never reordered, never
- * removed.
- *
- * The field @struct_size should be used to determine the size of the
- * structure. It should be queried before using additional fields added
- * at the end of the structure.
- */
-
-struct lttng_ust_context_provider {
-       uint32_t struct_size;
-
-       const char *name;
-       size_t (*get_size)(void *priv, size_t offset);
-       void (*record)(void *priv, struct lttng_ust_lib_ring_buffer_ctx *ctx,
-                      struct lttng_ust_channel_buffer *chan);
-       void (*get_value)(void *priv, struct lttng_ust_ctx_value *value);
-       void *priv;
-
-       /* End of base ABI. Fields below should be used after checking struct_size. */
-};
-
-/*
- * Returns an opaque pointer on success, which must be passed to
- * lttng_ust_context_provider_unregister for unregistration. Returns
- * NULL on error.
- */
-struct lttng_ust_registered_context_provider *lttng_ust_context_provider_register(struct lttng_ust_context_provider *provider);
-
-void lttng_ust_context_provider_unregister(struct lttng_ust_registered_context_provider *reg_provider);
-
-#endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */
diff --git a/include/ust-dlfcn.h b/include/ust-dlfcn.h
deleted file mode 100644 (file)
index 0681f8f..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * dlfcn.h compatibility layer.
- */
-
-#ifndef _LTTNG_UST_DLFCN_H
-#define _LTTNG_UST_DLFCN_H
-
-#ifdef _DLFCN_H
-#error "Please include ust-dlfcn.h before dlfcn.h."
-#endif /* _DLFCN_H */
-
-#ifdef __GLIBC__
-/*
- * glibc declares dlsym() and dlerror() with __attribute__((leaf)) (see
- * THROW annotation). Unfortunately, this is not in sync with reality,
- * as those functions call the memory allocator. Work-around this glibc
- * bug by declaring our own symbols.
- *
- * There has been a similar issue for dlopen() and dlclose(), as
- * constructors and destructors are called from these functions, so they
- * are clearly non-leaf. Work-around the issue for those too for older
- * glibc where these have not been fixed.
- */
-#define dlopen glibc_dlopen_proto_lies_about_leafness
-#define dlclose glibc_dlclose_proto_lies_about_leafness
-#define dlsym glibc_dlsym_proto_lies_about_leafness
-#define dlerror glibc_dlerror_proto_lies_about_leafness
-#define dlmopen glibc_dlmopen_proto_lies_about_leafness
-#define dlvsym glibc_dlvsym_proto_lies_about_leafness
-#include <dlfcn.h>
-#undef dlvsym
-#undef dlmopen
-#undef dlerror
-#undef dlsym
-#undef dlclose
-#undef dlopen
-
-extern void *dlopen(__const char *__file, int __mode);
-extern int dlclose(void *__handle) __nonnull ((1));
-extern void *dlsym(void *__restrict __handle,
-               __const char *__restrict __name) __nonnull ((2));
-extern char *dlerror(void);
-#ifdef __USE_GNU
-extern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode);
-extern void *dlvsym(void *__restrict __handle,
-               __const char *__restrict __name,
-               __const char *__restrict __version);
-#endif
-#else
-#include <dlfcn.h>
-#endif /* __GLIBC__ */
-
-#endif /* _LTTNG_UST_DLFCN_H */
diff --git a/include/ust-dynamic-type.h b/include/ust-dynamic-type.h
deleted file mode 100644 (file)
index e63fc4c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_DYNAMIC_TYPE_H
-#define _LTTNG_UST_DYNAMIC_TYPE_H
-
-#include <lttng/ust-events.h>
-
-enum lttng_ust_dynamic_type {
-       LTTNG_UST_DYNAMIC_TYPE_NONE,
-       LTTNG_UST_DYNAMIC_TYPE_S8,
-       LTTNG_UST_DYNAMIC_TYPE_S16,
-       LTTNG_UST_DYNAMIC_TYPE_S32,
-       LTTNG_UST_DYNAMIC_TYPE_S64,
-       LTTNG_UST_DYNAMIC_TYPE_U8,
-       LTTNG_UST_DYNAMIC_TYPE_U16,
-       LTTNG_UST_DYNAMIC_TYPE_U32,
-       LTTNG_UST_DYNAMIC_TYPE_U64,
-       LTTNG_UST_DYNAMIC_TYPE_FLOAT,
-       LTTNG_UST_DYNAMIC_TYPE_DOUBLE,
-       LTTNG_UST_DYNAMIC_TYPE_STRING,
-       _NR_LTTNG_UST_DYNAMIC_TYPES,
-};
-
-int lttng_ust_dynamic_type_choices(size_t *nr_choices,
-               const struct lttng_ust_event_field ***choices)
-       __attribute__((visibility("hidden")));
-
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value)
-       __attribute__((visibility("hidden")));
-
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
-       __attribute__((visibility("hidden")));
-
-#endif /* _LTTNG_UST_DYNAMIC_TYPE_H */
diff --git a/include/ust-elf.h b/include/ust-elf.h
deleted file mode 100644 (file)
index 29a9426..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- * Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
- */
-
-#ifndef _LTTNG_UST_ELF_H
-#define _LTTNG_UST_ELF_H
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdio.h>
-
-struct lttng_ust_elf_ehdr {
-       uint16_t e_type;
-       uint16_t e_machine;
-       uint32_t e_version;
-       uint64_t e_entry;
-       uint64_t e_phoff;
-       uint64_t e_shoff;
-       uint32_t e_flags;
-       uint16_t e_ehsize;
-       uint16_t e_phentsize;
-       uint16_t e_phnum;
-       uint16_t e_shentsize;
-       uint16_t e_shnum;
-       uint16_t e_shstrndx;
-};
-
-struct lttng_ust_elf_phdr {
-       uint32_t p_type;
-       uint64_t p_offset;
-       uint64_t p_filesz;
-       uint64_t p_memsz;
-       uint64_t p_align;
-       uint64_t p_vaddr;
-};
-
-struct lttng_ust_elf_shdr {
-       uint32_t sh_name;
-       uint32_t sh_type;
-       uint64_t sh_flags;
-       uint64_t sh_addr;
-       uint64_t sh_offset;
-       uint64_t sh_size;
-       uint32_t sh_link;
-       uint32_t sh_info;
-       uint64_t sh_addralign;
-       uint64_t sh_entsize;
-};
-
-struct lttng_ust_elf_nhdr {
-       uint32_t n_namesz;
-       uint32_t n_descsz;
-       uint32_t n_type;
-};
-
-struct lttng_ust_elf {
-       /* Offset in bytes to start of section names string table. */
-       off_t section_names_offset;
-       /* Size in bytes of section names string table. */
-       size_t section_names_size;
-       char *path;
-       int fd;
-       struct lttng_ust_elf_ehdr *ehdr;
-       uint8_t bitness;
-       uint8_t endianness;
-};
-
-struct lttng_ust_elf *lttng_ust_elf_create(const char *path);
-void lttng_ust_elf_destroy(struct lttng_ust_elf *elf);
-uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf);
-int lttng_ust_elf_get_memsz(struct lttng_ust_elf *elf, uint64_t *memsz);
-int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id,
-                       size_t *length, int *found);
-int lttng_ust_elf_get_debug_link(struct lttng_ust_elf *elf, char **filename,
-                       uint32_t *crc, int *found);
-
-#endif /* _LTTNG_UST_ELF_H */
diff --git a/include/ust-fd.h b/include/ust-fd.h
deleted file mode 100644 (file)
index ddebaa9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_FD_H
-#define _LTTNG_UST_FD_H
-
-/*
- * The fd tracker feature is part of the ABI and used by liblttng-ust-fd.
- * However, some test code and documentation needs to be written before it is
- * exposed to users with a public header.
- */
-
-#include <stdio.h>
-
-void lttng_ust_init_fd_tracker(void);
-int lttng_ust_add_fd_to_tracker(int fd);
-void lttng_ust_delete_fd_from_tracker(int fd);
-void lttng_ust_lock_fd_tracker(void);
-void lttng_ust_unlock_fd_tracker(void);
-
-int lttng_ust_safe_close_fd(int fd, int (*close_cb)(int));
-int lttng_ust_safe_fclose_stream(FILE *stream, int (*fclose_cb)(FILE *stream));
-int lttng_ust_safe_closefrom_fd(int lowfd, int (*close_cb)(int));
-
-#endif /* _LTTNG_UST_FD_H */
diff --git a/include/ust-helper.h b/include/ust-helper.h
deleted file mode 100644 (file)
index f169551..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_HELPER_H
-#define _LTTNG_UST_HELPER_H
-
-#include <stdlib.h>
-
-#include <lttng/ust-arch.h>
-
-static inline
-void *zmalloc(size_t len)
-       __attribute__((always_inline));
-static inline
-void *zmalloc(size_t len)
-{
-       return calloc(len, 1);
-}
-
-#define max_t(type, x, y)                              \
-       ({                                              \
-               type __max1 = (x);                      \
-               type __max2 = (y);                      \
-               __max1 > __max2 ? __max1: __max2;       \
-       })
-
-#define min_t(type, x, y)                              \
-       ({                                              \
-               type __min1 = (x);                      \
-               type __min2 = (y);                      \
-               __min1 <= __min2 ? __min1: __min2;      \
-       })
-
-#define LTTNG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
-/*
- * Use of __builtin_return_address(0) sometimes seems to cause stack
- * corruption on 32-bit PowerPC. Disable this feature on that
- * architecture for now by always using the NULL value for the ip
- * context.
- */
-#if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
-#define LTTNG_UST_CALLER_IP()          NULL
-#else
-#define LTTNG_UST_CALLER_IP()          __builtin_return_address(0)
-#endif
-
-#endif /* _LTTNG_UST_HELPER_H */
diff --git a/include/ust-share.h b/include/ust-share.h
deleted file mode 100644 (file)
index e0ee095..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_SHARE_H
-#define _LTTNG_SHARE_H
-
-#include <stdlib.h>
-#include <sys/uio.h>
-
-ssize_t ust_patient_write(int fd, const void *buf, size_t count)
-       __attribute__((visibility("hidden")));
-
-ssize_t ust_patient_writev(int fd, struct iovec *iov, int iovcnt)
-       __attribute__((visibility("hidden")));
-
-ssize_t ust_patient_send(int fd, const void *buf, size_t count, int flags)
-       __attribute__((visibility("hidden")));
-
-#endif /* _LTTNG_SHARE_H */
diff --git a/include/ust-snprintf.h b/include/ust-snprintf.h
deleted file mode 100644 (file)
index 3f66389..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- * Copyright (C) 2009 Pierre-Marc Fournier
- */
-
-#ifndef UST_SNPRINTF
-#define UST_SNPRINTF
-
-#include <stdarg.h>
-#include <stddef.h>
-
-int ust_safe_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
-       __attribute__((visibility("hidden")));
-
-int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...)
-       __attribute__((visibility("hidden")))
-       __attribute__((format(printf, 3, 4)));
-
-#endif /* UST_SNPRINTF */
diff --git a/include/ust-tid.h b/include/ust-tid.h
deleted file mode 100644 (file)
index eae1db9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * gettid compatibility layer.
- */
-
-#ifndef _LTTNG_UST_TID_H
-#define _LTTNG_UST_TID_H
-
-#ifdef __linux__
-#include <sys/syscall.h>
-#endif
-
-#if defined(__NR_gettid)
-
-#include <unistd.h>
-static inline pid_t lttng_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 lttng_gettid(void)
-{
-       return getpid();
-}
-
-#endif
-
-#endif /* _LTTNG_UST_TID_H */
diff --git a/include/usterr-signal-safe.h b/include/usterr-signal-safe.h
deleted file mode 100644 (file)
index 6123c0b..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _USTERR_SIGNAL_SAFE_H
-#define _USTERR_SIGNAL_SAFE_H
-
-#include <string.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <ust-share.h>
-#include "ust-tid.h"
-#include "ust-snprintf.h"
-
-enum ust_err_loglevel {
-       UST_ERR_LOGLEVEL_UNKNOWN = 0,
-       UST_ERR_LOGLEVEL_NORMAL,
-       UST_ERR_LOGLEVEL_DEBUG,
-};
-
-extern volatile enum ust_err_loglevel ust_err_loglevel
-       __attribute__((visibility("hidden")));
-
-void ust_err_init(void)
-       __attribute__((visibility("hidden")));
-
-#ifdef LTTNG_UST_DEBUG
-static inline bool ust_err_debug_enabled(void)
-{
-       return true;
-}
-#else /* #ifdef LTTNG_UST_DEBUG */
-static inline bool ust_err_debug_enabled(void)
-{
-       return ust_err_loglevel == UST_ERR_LOGLEVEL_DEBUG;
-}
-#endif /* #else #ifdef LTTNG_UST_DEBUG */
-
-/*
- * The default component for error messages.
- */
-#ifndef UST_COMPONENT
-#define UST_COMPONENT libust
-#endif
-
-/* To stringify the expansion of a define */
-#define UST_XSTR(d) UST_STR(d)
-#define UST_STR(s) #s
-
-#define UST_ERR_MAX_LEN        512
-
-/*
- * We sometimes print in the tracing path, and tracing can occur in
- * signal handlers, so we must use a print method which is signal safe.
- */
-/* Can't use dynamic allocation. Limit ourselves to UST_ERR_MAX_LEN chars. */
-/* Add end of string in case of buffer overflow. */
-#define sigsafe_print_err(fmt, args...)                                        \
-do {                                                                   \
-       if (ust_err_debug_enabled()) {                                  \
-               char ____buf[UST_ERR_MAX_LEN];                          \
-               int ____saved_errno;                                    \
-                                                                       \
-               ____saved_errno = errno;        /* signal-safety */     \
-               ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \
-               ____buf[sizeof(____buf) - 1] = 0;                       \
-               ust_patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \
-               errno = ____saved_errno;        /* signal-safety */     \
-               fflush(stderr);                                         \
-       }                                                               \
-} while (0)
-
-#define UST_STR_COMPONENT UST_XSTR(UST_COMPONENT)
-
-#define ERRMSG(fmt, args...)                   \
-       do {                                    \
-               sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \
-               (long) getpid(),                \
-               (long) lttng_gettid(),          \
-               ## args, __func__);             \
-       } while(0)
-
-
-#define DBG(fmt, args...)      ERRMSG(fmt, ## args)
-#define DBG_raw(fmt, args...)  sigsafe_print_err(fmt, ## args)
-#define WARN(fmt, args...)     ERRMSG("Warning: " fmt, ## args)
-#define ERR(fmt, args...)      ERRMSG("Error: " fmt, ## args)
-#define BUG(fmt, args...)      ERRMSG("BUG: " fmt, ## args)
-
-#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-/*
- * Version using XSI strerror_r.
- */
-#define PERROR(call, args...)                                          \
-       do {                                                            \
-               if (ust_err_debug_enabled()) {                          \
-                       char perror_buf[200] = "Error in strerror_r()"; \
-                       strerror_r(errno, perror_buf,                   \
-                                       sizeof(perror_buf));            \
-                       ERRMSG("Error: " call ": %s", ## args,          \
-                                       perror_buf);                    \
-               }                                                       \
-       } while(0)
-#else
-/*
- * Version using GNU strerror_r, for linux with appropriate defines.
- */
-#define PERROR(call, args...)                                          \
-       do {                                                            \
-               if (ust_err_debug_enabled()) {                          \
-                       char *perror_buf;                               \
-                       char perror_tmp[200];                           \
-                       perror_buf = strerror_r(errno, perror_tmp,      \
-                                       sizeof(perror_tmp));            \
-                       ERRMSG("Error: " call ": %s", ## args,          \
-                                       perror_buf);                    \
-               }                                                       \
-       } while(0)
-#endif
-
-#define BUG_ON(condition)                                      \
-       do {                                                    \
-               if (caa_unlikely(condition))                    \
-                       ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \
-       } while(0)
-#define WARN_ON(condition)                                     \
-       do {                                                    \
-               if (caa_unlikely(condition))                    \
-                       WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \
-       } while(0)
-#define WARN_ON_ONCE(condition) WARN_ON(condition)
-
-#endif /* _USTERR_SIGNAL_SAFE_H */
index 87fcdb8f2649920ddb70d7ad8785b38020988fff..d92530539c6f9435ea335f1ac6eae525e218f432 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: LGPL-2.1-only
 
 SUBDIRS = \
+       common \
        snprintf \
        libringbuffer \
        liblttng-ust-comm \
diff --git a/src/common/.placeholder b/src/common/.placeholder
deleted file mode 100644 (file)
index 959eb25..0000000
+++ /dev/null
@@ -1 +0,0 @@
-# Git doesn't support empty folders
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
new file mode 100644 (file)
index 0000000..276c06a
--- /dev/null
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+###                        ###
+### Global private headers ###
+###                        ###
+
+noinst_HEADERS = \
+       align.h \
+       bitfield.h \
+       bitmap.h \
+       dynamic-type.h \
+       elf.h \
+       logging.h \
+       macros.h \
+       patient.h \
+       safe-snprintf.h \
+       ustcomm.h
+
+noinst_HEADERS += \
+       compat/dlfcn.h \
+       compat/tid.h
+
+# These headers should be moved to the public headers when tested and
+# documented. The symbols are still part of the ABI.
+
+# Used by the Java jni interface.
+noinst_HEADERS += \
+       ust-context-provider.h
+
+# Used by liblttng-ust-fd
+noinst_HEADERS += \
+       ust-fd.h
diff --git a/src/common/align.h b/src/common/align.h
new file mode 100644 (file)
index 0000000..ef04fe4
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_ALIGN_H
+#define _UST_COMMON_ALIGN_H
+
+#include <unistd.h>
+#include <limits.h>
+
+#ifdef __FreeBSD__
+#include <machine/param.h>
+#endif
+
+#ifdef _SC_PAGE_SIZE
+#define LTTNG_UST_PAGE_SIZE    sysconf(_SC_PAGE_SIZE)
+#elif defined(PAGE_SIZE)
+#define LTTNG_UST_PAGE_SIZE    PAGE_SIZE
+#else
+#error "Please add page size detection for your OS."
+#endif
+
+#define LTTNG_UST_PAGE_MASK    (~(LTTNG_UST_PAGE_SIZE - 1))
+
+#define __LTTNG_UST_ALIGN_MASK(v, mask)        (((v) + (mask)) & ~(mask))
+#define LTTNG_UST_ALIGN(v, align)      __LTTNG_UST_ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
+#define LTTNG_UST_PAGE_ALIGN(addr)     LTTNG_UST_ALIGN(addr, LTTNG_UST_PAGE_SIZE)
+
+#endif /* _UST_COMMON_ALIGN_H */
diff --git a/src/common/bitfield.h b/src/common/bitfield.h
new file mode 100644 (file)
index 0000000..7cb5b32
--- /dev/null
@@ -0,0 +1,509 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2010-2019 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_BITFIELD_H
+#define _UST_COMMON_BITFIELD_H
+
+#include <stdint.h>    /* C99 5.2.4.2 Numerical limits */
+#include <limits.h>    /* C99 5.2.4.2 Numerical limits */
+#include <stdbool.h>   /* C99 7.16 bool type */
+#include <lttng/ust-endian.h>  /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
+
+/*
+ * This header strictly follows the C99 standard, except for use of the
+ * compiler-specific __typeof__.
+ */
+
+/*
+ * This bitfield header requires the compiler representation of signed
+ * integers to be two's complement.
+ */
+#if (-1 != ~0)
+#error "bitfield.h requires the compiler representation of signed integers to be two's complement."
+#endif
+
+#define _bt_is_signed_type(type)       ((type) -1 < (type) 1)
+
+/*
+ * Produce a build-time error if the condition `cond` is non-zero.
+ * Evaluates as a size_t expression.
+ */
+#ifdef __cplusplus
+#define _BT_BUILD_ASSERT(cond) ([]{static_assert((cond), "");}, 0)
+#else
+#define _BT_BUILD_ASSERT(cond)                                 \
+       sizeof(struct { int f:(2 * !!(cond) - 1); })
+#endif
+
+/*
+ * Cast value `v` to an unsigned integer of the same size as `v`.
+ */
+#define _bt_cast_value_to_unsigned(v)                                  \
+       (sizeof(v) == sizeof(uint8_t) ? (uint8_t) (v) :                 \
+       sizeof(v) == sizeof(uint16_t) ? (uint16_t) (v) :                \
+       sizeof(v) == sizeof(uint32_t) ? (uint32_t) (v) :                \
+       sizeof(v) == sizeof(uint64_t) ? (uint64_t) (v) :                \
+       _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
+
+/*
+ * Cast value `v` to an unsigned integer type of the size of type `type`
+ * *without* sign-extension.
+ *
+ * The unsigned cast ensures that we're not shifting a negative value,
+ * which is undefined in C. However, this limits the maximum type size
+ * of `type` to 64-bit. Generate a compile-time error if the size of
+ * `type` is larger than 64-bit.
+ */
+#define _bt_cast_value_to_unsigned_type(type, v)                       \
+       (sizeof(type) == sizeof(uint8_t) ?                              \
+               (uint8_t) _bt_cast_value_to_unsigned(v) :               \
+       sizeof(type) == sizeof(uint16_t) ?                              \
+               (uint16_t) _bt_cast_value_to_unsigned(v) :              \
+       sizeof(type) == sizeof(uint32_t) ?                              \
+               (uint32_t) _bt_cast_value_to_unsigned(v) :              \
+       sizeof(type) == sizeof(uint64_t) ?                              \
+               (uint64_t) _bt_cast_value_to_unsigned(v) :              \
+       _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
+
+/*
+ * _bt_fill_mask evaluates to a "type" integer with all bits set.
+ */
+#define _bt_fill_mask(type)    ((type) ~(type) 0)
+
+/*
+ * Left shift a value `v` of `shift` bits.
+ *
+ * The type of `v` can be signed or unsigned integer.
+ * The value of `shift` must be less than the size of `v` (in bits),
+ * otherwise the behavior is undefined.
+ * Evaluates to the result of the shift operation.
+ *
+ * According to the C99 standard, left shift of a left hand-side signed
+ * type is undefined if it has a negative value or if the result cannot
+ * be represented in the result type. This bitfield header discards the
+ * bits that are left-shifted beyond the result type representation,
+ * which is the behavior of an unsigned type left shift operation.
+ * Therefore, always perform left shift on an unsigned type.
+ *
+ * This macro should not be used if `shift` can be greater or equal than
+ * the bitwidth of `v`. See `_bt_safe_lshift`.
+ */
+#define _bt_lshift(v, shift)                                           \
+       ((__typeof__(v)) (_bt_cast_value_to_unsigned(v) << (shift)))
+
+/*
+ * Generate a mask of type `type` with the `length` least significant bits
+ * cleared, and the most significant bits set.
+ */
+#define _bt_make_mask_complement(type, length)                         \
+       _bt_lshift(_bt_fill_mask(type), length)
+
+/*
+ * Generate a mask of type `type` with the `length` least significant bits
+ * set, and the most significant bits cleared.
+ */
+#define _bt_make_mask(type, length)                                    \
+       ((type) ~_bt_make_mask_complement(type, length))
+
+/*
+ * Right shift a value `v` of `shift` bits.
+ *
+ * The type of `v` can be signed or unsigned integer.
+ * The value of `shift` must be less than the size of `v` (in bits),
+ * otherwise the behavior is undefined.
+ * Evaluates to the result of the shift operation.
+ *
+ * According to the C99 standard, right shift of a left hand-side signed
+ * type which has a negative value is implementation defined. This
+ * bitfield header relies on the right shift implementation carrying the
+ * sign bit. If the compiler implementation has a different behavior,
+ * emulate carrying the sign bit.
+ *
+ * This macro should not be used if `shift` can be greater or equal than
+ * the bitwidth of `v`. See `_bt_safe_rshift`.
+ */
+#if ((-1 >> 1) == -1)
+#define _bt_rshift(v, shift)   ((v) >> (shift))
+#else
+#define _bt_rshift(v, shift)                                           \
+       ((__typeof__(v)) ((_bt_cast_value_to_unsigned(v) >> (shift)) |  \
+               ((v) < 0 ? _bt_make_mask_complement(__typeof__(v),      \
+                       sizeof(v) * CHAR_BIT - (shift)) : 0)))
+#endif
+
+/*
+ * Right shift a signed or unsigned integer with `shift` value being an
+ * arbitrary number of bits. `v` is modified by this macro. The shift
+ * is transformed into a sequence of `_nr_partial_shifts` consecutive
+ * shift operations, each of a number of bits smaller than the bitwidth
+ * of `v`, ending with a shift of the number of left over bits.
+ */
+#define _bt_safe_rshift(v, shift)                                      \
+do {                                                                   \
+       unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
+       unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
+                                                                       \
+       for (; _nr_partial_shifts; _nr_partial_shifts--)                \
+               (v) = _bt_rshift(v, sizeof(v) * CHAR_BIT - 1);          \
+       (v) = _bt_rshift(v, _leftover_bits);                            \
+} while (0)
+
+/*
+ * Left shift a signed or unsigned integer with `shift` value being an
+ * arbitrary number of bits. `v` is modified by this macro. The shift
+ * is transformed into a sequence of `_nr_partial_shifts` consecutive
+ * shift operations, each of a number of bits smaller than the bitwidth
+ * of `v`, ending with a shift of the number of left over bits.
+ */
+#define _bt_safe_lshift(v, shift)                                      \
+do {                                                                   \
+       unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
+       unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
+                                                                       \
+       for (; _nr_partial_shifts; _nr_partial_shifts--)                \
+               (v) = _bt_lshift(v, sizeof(v) * CHAR_BIT - 1);          \
+       (v) = _bt_lshift(v, _leftover_bits);                            \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ *
+ * Save integer to the bitfield, which starts at the "start" bit, has "len"
+ * bits.
+ * The inside of a bitfield is from high bits to low bits.
+ * Uses native endianness.
+ * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
+ * For signed "v", sign-extend v if bitfield is larger than v.
+ *
+ * On little endian, bytes are placed from the less significant to the most
+ * significant. Also, consecutive bitfields are placed from lower bits to higher
+ * bits.
+ *
+ * On big endian, bytes are places from most significant to less significant.
+ * Also, consecutive bitfields are placed from higher to lower bits.
+ */
+
+#define _bt_bitfield_write_le(ptr, type, start, length, v)             \
+do {                                                                   \
+       __typeof__(v) _v = (v);                                 \
+       type *_ptr = (void *) (ptr);                                    \
+       unsigned long _start = (start), _length = (length);             \
+       type _mask, _cmask;                                             \
+       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
+       unsigned long _start_unit, _end_unit, _this_unit;               \
+       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+                                                                       \
+       if (!_length)                                                   \
+               break;                                                  \
+                                                                       \
+       _end = _start + _length;                                        \
+       _start_unit = _start / _ts;                                     \
+       _end_unit = (_end + (_ts - 1)) / _ts;                           \
+                                                                       \
+       /* Trim v high bits */                                          \
+       if (_length < sizeof(_v) * CHAR_BIT)                            \
+               _v &= _bt_make_mask(__typeof__(_v), _length);           \
+                                                                       \
+       /* We can now append v with a simple "or", shift it piece-wise */ \
+       _this_unit = _start_unit;                                       \
+       if (_start_unit == _end_unit - 1) {                             \
+               _mask = _bt_make_mask(type, _start % _ts);              \
+               if (_end % _ts)                                         \
+                       _mask |= _bt_make_mask_complement(type, _end % _ts); \
+               _cmask = _bt_lshift((type) (_v), _start % _ts);         \
+               _cmask &= ~_mask;                                       \
+               _ptr[_this_unit] &= _mask;                              \
+               _ptr[_this_unit] |= _cmask;                             \
+               break;                                                  \
+       }                                                               \
+       if (_start % _ts) {                                             \
+               _cshift = _start % _ts;                                 \
+               _mask = _bt_make_mask(type, _cshift);                   \
+               _cmask = _bt_lshift((type) (_v), _cshift);              \
+               _cmask &= ~_mask;                                       \
+               _ptr[_this_unit] &= _mask;                              \
+               _ptr[_this_unit] |= _cmask;                             \
+               _bt_safe_rshift(_v, _ts - _cshift);                     \
+               _start += _ts - _cshift;                                \
+               _this_unit++;                                           \
+       }                                                               \
+       for (; _this_unit < _end_unit - 1; _this_unit++) {              \
+               _ptr[_this_unit] = (type) _v;                           \
+               _bt_safe_rshift(_v, _ts);                               \
+               _start += _ts;                                          \
+       }                                                               \
+       if (_end % _ts) {                                               \
+               _mask = _bt_make_mask_complement(type, _end % _ts);     \
+               _cmask = (type) _v;                                     \
+               _cmask &= ~_mask;                                       \
+               _ptr[_this_unit] &= _mask;                              \
+               _ptr[_this_unit] |= _cmask;                             \
+       } else                                                          \
+               _ptr[_this_unit] = (type) _v;                           \
+} while (0)
+
+#define _bt_bitfield_write_be(ptr, type, start, length, v)             \
+do {                                                                   \
+       __typeof__(v) _v = (v);                                         \
+       type *_ptr = (void *) (ptr);                                    \
+       unsigned long _start = (start), _length = (length);             \
+       type _mask, _cmask;                                             \
+       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
+       unsigned long _start_unit, _end_unit, _this_unit;               \
+       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+                                                                       \
+       if (!_length)                                                   \
+               break;                                                  \
+                                                                       \
+       _end = _start + _length;                                        \
+       _start_unit = _start / _ts;                                     \
+       _end_unit = (_end + (_ts - 1)) / _ts;                           \
+                                                                       \
+       /* Trim v high bits */                                          \
+       if (_length < sizeof(_v) * CHAR_BIT)                            \
+               _v &= _bt_make_mask(__typeof__(_v), _length);           \
+                                                                       \
+       /* We can now append v with a simple "or", shift it piece-wise */ \
+       _this_unit = _end_unit - 1;                                     \
+       if (_start_unit == _end_unit - 1) {                             \
+               _mask = _bt_make_mask(type, (_ts - (_end % _ts)) % _ts); \
+               if (_start % _ts)                                       \
+                       _mask |= _bt_make_mask_complement(type, _ts - (_start % _ts)); \
+               _cmask = _bt_lshift((type) (_v), (_ts - (_end % _ts)) % _ts); \
+               _cmask &= ~_mask;                                       \
+               _ptr[_this_unit] &= _mask;                              \
+               _ptr[_this_unit] |= _cmask;                             \
+               break;                                                  \
+       }                                                               \
+       if (_end % _ts) {                                               \
+               _cshift = _end % _ts;                                   \
+               _mask = _bt_make_mask(type, _ts - _cshift);             \
+               _cmask = _bt_lshift((type) (_v), _ts - _cshift);        \
+               _cmask &= ~_mask;                                       \
+               _ptr[_this_unit] &= _mask;                              \
+               _ptr[_this_unit] |= _cmask;                             \
+               _bt_safe_rshift(_v, _cshift);                           \
+               _end -= _cshift;                                        \
+               _this_unit--;                                           \
+       }                                                               \
+       for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
+               _ptr[_this_unit] = (type) _v;                           \
+               _bt_safe_rshift(_v, _ts);                               \
+               _end -= _ts;                                            \
+       }                                                               \
+       if (_start % _ts) {                                             \
+               _mask = _bt_make_mask_complement(type, _ts - (_start % _ts)); \
+               _cmask = (type) _v;                                     \
+               _cmask &= ~_mask;                                       \
+               _ptr[_this_unit] &= _mask;                              \
+               _ptr[_this_unit] |= _cmask;                             \
+       } else                                                          \
+               _ptr[_this_unit] = (type) _v;                           \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ * bt_bitfield_write_le - write integer to a bitfield in little endian
+ * bt_bitfield_write_be - write integer to a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, start, length, v)                 \
+       _bt_bitfield_write_le(ptr, type, start, length, v)
+
+#define bt_bitfield_write_le(ptr, type, start, length, v)              \
+       _bt_bitfield_write_le(ptr, type, start, length, v)
+
+#define bt_bitfield_write_be(ptr, type, start, length, v)              \
+       _bt_bitfield_write_be(ptr, unsigned char, start, length, v)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, start, length, v)                 \
+       _bt_bitfield_write_be(ptr, type, start, length, v)
+
+#define bt_bitfield_write_le(ptr, type, start, length, v)              \
+       _bt_bitfield_write_le(ptr, unsigned char, start, length, v)
+
+#define bt_bitfield_write_be(ptr, type, start, length, v)              \
+       _bt_bitfield_write_be(ptr, type, start, length, v)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#define _bt_bitfield_read_le(ptr, type, start, length, vptr)           \
+do {                                                                   \
+       __typeof__(*(vptr)) *_vptr = (vptr);                            \
+       __typeof__(*_vptr) _v;                                          \
+       type *_ptr = (type *) (ptr);                                    \
+       unsigned long _start = (start), _length = (length);             \
+       type _mask, _cmask;                                             \
+       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
+       unsigned long _start_unit, _end_unit, _this_unit;               \
+       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+                                                                       \
+       if (!_length) {                                                 \
+               *_vptr = 0;                                             \
+               break;                                                  \
+       }                                                               \
+                                                                       \
+       _end = _start + _length;                                        \
+       _start_unit = _start / _ts;                                     \
+       _end_unit = (_end + (_ts - 1)) / _ts;                           \
+                                                                       \
+       _this_unit = _end_unit - 1;                                     \
+       if (_bt_is_signed_type(__typeof__(_v))                          \
+           && (_ptr[_this_unit] & _bt_lshift((type) 1, (_end % _ts ? _end % _ts : _ts) - 1))) \
+               _v = ~(__typeof__(_v)) 0;                               \
+       else                                                            \
+               _v = 0;                                                 \
+       if (_start_unit == _end_unit - 1) {                             \
+               _cmask = _ptr[_this_unit];                              \
+               _cmask = _bt_rshift(_cmask, _start % _ts);              \
+               if ((_end - _start) % _ts) {                            \
+                       _mask = _bt_make_mask(type, _end - _start);     \
+                       _cmask &= _mask;                                \
+               }                                                       \
+               _bt_safe_lshift(_v, _end - _start);                     \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+               *_vptr = _v;                                            \
+               break;                                                  \
+       }                                                               \
+       if (_end % _ts) {                                               \
+               _cshift = _end % _ts;                                   \
+               _mask = _bt_make_mask(type, _cshift);                   \
+               _cmask = _ptr[_this_unit];                              \
+               _cmask &= _mask;                                        \
+               _bt_safe_lshift(_v, _cshift);                           \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+               _end -= _cshift;                                        \
+               _this_unit--;                                           \
+       }                                                               \
+       for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
+               _bt_safe_lshift(_v, _ts);                               \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+               _end -= _ts;                                            \
+       }                                                               \
+       if (_start % _ts) {                                             \
+               _mask = _bt_make_mask(type, _ts - (_start % _ts));      \
+               _cmask = _ptr[_this_unit];                              \
+               _cmask = _bt_rshift(_cmask, _start % _ts);              \
+               _cmask &= _mask;                                        \
+               _bt_safe_lshift(_v, _ts - (_start % _ts));              \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+       } else {                                                        \
+               _bt_safe_lshift(_v, _ts);                               \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+       }                                                               \
+       *_vptr = _v;                                                    \
+} while (0)
+
+#define _bt_bitfield_read_be(ptr, type, start, length, vptr)           \
+do {                                                                   \
+       __typeof__(*(vptr)) *_vptr = (vptr);                            \
+       __typeof__(*_vptr) _v;                                          \
+       type *_ptr = (void *) (ptr);                                    \
+       unsigned long _start = (start), _length = (length);             \
+       type _mask, _cmask;                                             \
+       unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */    \
+       unsigned long _start_unit, _end_unit, _this_unit;               \
+       unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+                                                                       \
+       if (!_length) {                                                 \
+               *_vptr = 0;                                             \
+               break;                                                  \
+       }                                                               \
+                                                                       \
+       _end = _start + _length;                                        \
+       _start_unit = _start / _ts;                                     \
+       _end_unit = (_end + (_ts - 1)) / _ts;                           \
+                                                                       \
+       _this_unit = _start_unit;                                       \
+       if (_bt_is_signed_type(__typeof__(_v))                          \
+           && (_ptr[_this_unit] & _bt_lshift((type) 1, _ts - (_start % _ts) - 1))) \
+               _v = ~(__typeof__(_v)) 0;                               \
+       else                                                            \
+               _v = 0;                                                 \
+       if (_start_unit == _end_unit - 1) {                             \
+               _cmask = _ptr[_this_unit];                              \
+               _cmask = _bt_rshift(_cmask, (_ts - (_end % _ts)) % _ts); \
+               if ((_end - _start) % _ts) {                            \
+                       _mask = _bt_make_mask(type, _end - _start);     \
+                       _cmask &= _mask;                                \
+               }                                                       \
+               _bt_safe_lshift(_v, _end - _start);                     \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+               *_vptr = _v;                                            \
+               break;                                                  \
+       }                                                               \
+       if (_start % _ts) {                                             \
+               _cshift = _start % _ts;                                 \
+               _mask = _bt_make_mask(type, _ts - _cshift);             \
+               _cmask = _ptr[_this_unit];                              \
+               _cmask &= _mask;                                        \
+               _bt_safe_lshift(_v, _ts - _cshift);                     \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+               _start += _ts - _cshift;                                \
+               _this_unit++;                                           \
+       }                                                               \
+       for (; _this_unit < _end_unit - 1; _this_unit++) {              \
+               _bt_safe_lshift(_v, _ts);                               \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+               _start += _ts;                                          \
+       }                                                               \
+       if (_end % _ts) {                                               \
+               _mask = _bt_make_mask(type, _end % _ts);                \
+               _cmask = _ptr[_this_unit];                              \
+               _cmask = _bt_rshift(_cmask, _ts - (_end % _ts));        \
+               _cmask &= _mask;                                        \
+               _bt_safe_lshift(_v, _end % _ts);                        \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+       } else {                                                        \
+               _bt_safe_lshift(_v, _ts);                               \
+               _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+       }                                                               \
+       *_vptr = _v;                                                    \
+} while (0)
+
+/*
+ * bt_bitfield_read - read integer from a bitfield in native endianness
+ * bt_bitfield_read_le - read integer from a bitfield in little endian
+ * bt_bitfield_read_be - read integer from a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_read(ptr, type, start, length, vptr)               \
+       _bt_bitfield_read_le(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_le(ptr, type, start, length, vptr)            \
+       _bt_bitfield_read_le(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_be(ptr, type, start, length, vptr)            \
+       _bt_bitfield_read_be(ptr, unsigned char, start, length, vptr)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_read(ptr, type, start, length, vptr)               \
+       _bt_bitfield_read_be(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_le(ptr, type, start, length, vptr)            \
+       _bt_bitfield_read_le(ptr, unsigned char, start, length, vptr)
+
+#define bt_bitfield_read_be(ptr, type, start, length, vptr)            \
+       _bt_bitfield_read_be(ptr, type, start, length, vptr)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#endif /* _BABELTRACE_BITFIELD_H */
diff --git a/src/common/bitmap.h b/src/common/bitmap.h
new file mode 100644 (file)
index 0000000..838a6a1
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng Bitmap API
+ */
+
+#ifndef _UST_COMMON_BITMAP_H
+#define _UST_COMMON_BITMAP_H
+
+#include <urcu/compiler.h>
+#include <urcu/system.h>
+#include <urcu/uatomic.h>
+#include <stdbool.h>
+
+static inline void lttng_bitmap_index(unsigned int index, unsigned int *word,
+               unsigned int *bit)
+{
+       *word = index / CAA_BITS_PER_LONG;
+       *bit = index % CAA_BITS_PER_LONG;
+}
+
+static inline void lttng_bitmap_set_bit(unsigned int index, unsigned long *p)
+{
+       unsigned int word, bit;
+       unsigned long val;
+
+       lttng_bitmap_index(index, &word, &bit);
+       val = 1U << bit;
+       uatomic_or(p + word, val);
+}
+
+static inline void lttng_bitmap_clear_bit(unsigned int index, unsigned long *p)
+{
+       unsigned int word, bit;
+       unsigned long val;
+
+       lttng_bitmap_index(index, &word, &bit);
+       val = ~(1U << bit);
+       uatomic_and(p + word, val);
+}
+
+static inline bool lttng_bitmap_test_bit(unsigned int index, unsigned long *p)
+{
+       unsigned int word, bit;
+
+       lttng_bitmap_index(index, &word, &bit);
+       return (CMM_LOAD_SHARED(p[word]) >> bit) & 0x1;
+}
+
+#endif /* _UST_COMMON_BITMAP_H */
diff --git a/src/common/compat/dlfcn.h b/src/common/compat/dlfcn.h
new file mode 100644 (file)
index 0000000..c5861ca
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * dlfcn.h compatibility layer.
+ */
+
+#ifndef _UST_COMMON_COMPAT_DLFCN_H
+#define _UST_COMMON_COMPAT_DLFCN_H
+
+#ifdef _DLFCN_H
+#error "Please include compat/dlfcn.h before dlfcn.h."
+#endif /* _DLFCN_H */
+
+#ifdef __GLIBC__
+/*
+ * glibc declares dlsym() and dlerror() with __attribute__((leaf)) (see
+ * THROW annotation). Unfortunately, this is not in sync with reality,
+ * as those functions call the memory allocator. Work-around this glibc
+ * bug by declaring our own symbols.
+ *
+ * There has been a similar issue for dlopen() and dlclose(), as
+ * constructors and destructors are called from these functions, so they
+ * are clearly non-leaf. Work-around the issue for those too for older
+ * glibc where these have not been fixed.
+ */
+#define dlopen glibc_dlopen_proto_lies_about_leafness
+#define dlclose glibc_dlclose_proto_lies_about_leafness
+#define dlsym glibc_dlsym_proto_lies_about_leafness
+#define dlerror glibc_dlerror_proto_lies_about_leafness
+#define dlmopen glibc_dlmopen_proto_lies_about_leafness
+#define dlvsym glibc_dlvsym_proto_lies_about_leafness
+#include <dlfcn.h>
+#undef dlvsym
+#undef dlmopen
+#undef dlerror
+#undef dlsym
+#undef dlclose
+#undef dlopen
+
+extern void *dlopen(__const char *__file, int __mode);
+extern int dlclose(void *__handle) __nonnull ((1));
+extern void *dlsym(void *__restrict __handle,
+               __const char *__restrict __name) __nonnull ((2));
+extern char *dlerror(void);
+#ifdef __USE_GNU
+extern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode);
+extern void *dlvsym(void *__restrict __handle,
+               __const char *__restrict __name,
+               __const char *__restrict __version);
+#endif
+#else
+#include <dlfcn.h>
+#endif /* __GLIBC__ */
+
+#endif /* _UST_COMMON_COMPAT_DLFCN_H */
diff --git a/src/common/compat/tid.h b/src/common/compat/tid.h
new file mode 100644 (file)
index 0000000..aecae9b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * gettid compatibility layer.
+ */
+
+#ifndef _UST_COMMON_COMPAT_GETTID_H
+#define _UST_COMMON_COMPAT_GETTID_H
+
+#ifdef __linux__
+#include <sys/syscall.h>
+#endif
+
+#if defined(__NR_gettid)
+
+#include <unistd.h>
+static inline pid_t lttng_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 lttng_gettid(void)
+{
+       return getpid();
+}
+
+#endif
+
+#endif /* _UST_COMMON_COMPAT_GETTID_H */
diff --git a/src/common/dynamic-type.h b/src/common/dynamic-type.h
new file mode 100644 (file)
index 0000000..84f55f9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_DYNAMIC_TYPE_H
+#define _UST_COMMON_DYNAMIC_TYPE_H
+
+#include <lttng/ust-events.h>
+
+enum lttng_ust_dynamic_type {
+       LTTNG_UST_DYNAMIC_TYPE_NONE,
+       LTTNG_UST_DYNAMIC_TYPE_S8,
+       LTTNG_UST_DYNAMIC_TYPE_S16,
+       LTTNG_UST_DYNAMIC_TYPE_S32,
+       LTTNG_UST_DYNAMIC_TYPE_S64,
+       LTTNG_UST_DYNAMIC_TYPE_U8,
+       LTTNG_UST_DYNAMIC_TYPE_U16,
+       LTTNG_UST_DYNAMIC_TYPE_U32,
+       LTTNG_UST_DYNAMIC_TYPE_U64,
+       LTTNG_UST_DYNAMIC_TYPE_FLOAT,
+       LTTNG_UST_DYNAMIC_TYPE_DOUBLE,
+       LTTNG_UST_DYNAMIC_TYPE_STRING,
+       _NR_LTTNG_UST_DYNAMIC_TYPES,
+};
+
+int lttng_ust_dynamic_type_choices(size_t *nr_choices,
+               const struct lttng_ust_event_field ***choices)
+       __attribute__((visibility("hidden")));
+
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value)
+       __attribute__((visibility("hidden")));
+
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
+       __attribute__((visibility("hidden")));
+
+#endif /* _UST_COMMON_DYNAMIC_TYPE_H */
diff --git a/src/common/elf.h b/src/common/elf.h
new file mode 100644 (file)
index 0000000..ea0351d
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
+ */
+
+#ifndef _UST_COMMON_ELF_H
+#define _UST_COMMON_ELF_H
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+
+struct lttng_ust_elf_ehdr {
+       uint16_t e_type;
+       uint16_t e_machine;
+       uint32_t e_version;
+       uint64_t e_entry;
+       uint64_t e_phoff;
+       uint64_t e_shoff;
+       uint32_t e_flags;
+       uint16_t e_ehsize;
+       uint16_t e_phentsize;
+       uint16_t e_phnum;
+       uint16_t e_shentsize;
+       uint16_t e_shnum;
+       uint16_t e_shstrndx;
+};
+
+struct lttng_ust_elf_phdr {
+       uint32_t p_type;
+       uint64_t p_offset;
+       uint64_t p_filesz;
+       uint64_t p_memsz;
+       uint64_t p_align;
+       uint64_t p_vaddr;
+};
+
+struct lttng_ust_elf_shdr {
+       uint32_t sh_name;
+       uint32_t sh_type;
+       uint64_t sh_flags;
+       uint64_t sh_addr;
+       uint64_t sh_offset;
+       uint64_t sh_size;
+       uint32_t sh_link;
+       uint32_t sh_info;
+       uint64_t sh_addralign;
+       uint64_t sh_entsize;
+};
+
+struct lttng_ust_elf_nhdr {
+       uint32_t n_namesz;
+       uint32_t n_descsz;
+       uint32_t n_type;
+};
+
+struct lttng_ust_elf {
+       /* Offset in bytes to start of section names string table. */
+       off_t section_names_offset;
+       /* Size in bytes of section names string table. */
+       size_t section_names_size;
+       char *path;
+       int fd;
+       struct lttng_ust_elf_ehdr *ehdr;
+       uint8_t bitness;
+       uint8_t endianness;
+};
+
+struct lttng_ust_elf *lttng_ust_elf_create(const char *path);
+void lttng_ust_elf_destroy(struct lttng_ust_elf *elf);
+uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf);
+int lttng_ust_elf_get_memsz(struct lttng_ust_elf *elf, uint64_t *memsz);
+int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id,
+                       size_t *length, int *found);
+int lttng_ust_elf_get_debug_link(struct lttng_ust_elf *elf, char **filename,
+                       uint32_t *crc, int *found);
+
+#endif /* _UST_COMMON_ELF_H */
diff --git a/src/common/logging.h b/src/common/logging.h
new file mode 100644 (file)
index 0000000..4001c88
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _USTERR_SIGNAL_SAFE_H
+#define _USTERR_SIGNAL_SAFE_H
+
+#include <string.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include "common/patient.h"
+#include "common/compat/tid.h"
+#include "common/safe-snprintf.h"
+
+enum ust_err_loglevel {
+       UST_ERR_LOGLEVEL_UNKNOWN = 0,
+       UST_ERR_LOGLEVEL_NORMAL,
+       UST_ERR_LOGLEVEL_DEBUG,
+};
+
+extern volatile enum ust_err_loglevel ust_err_loglevel
+       __attribute__((visibility("hidden")));
+
+void ust_err_init(void)
+       __attribute__((visibility("hidden")));
+
+#ifdef LTTNG_UST_DEBUG
+static inline bool ust_err_debug_enabled(void)
+{
+       return true;
+}
+#else /* #ifdef LTTNG_UST_DEBUG */
+static inline bool ust_err_debug_enabled(void)
+{
+       return ust_err_loglevel == UST_ERR_LOGLEVEL_DEBUG;
+}
+#endif /* #else #ifdef LTTNG_UST_DEBUG */
+
+/*
+ * The default component for error messages.
+ */
+#ifndef UST_COMPONENT
+#define UST_COMPONENT libust
+#endif
+
+/* To stringify the expansion of a define */
+#define UST_XSTR(d) UST_STR(d)
+#define UST_STR(s) #s
+
+#define UST_ERR_MAX_LEN        512
+
+/*
+ * We sometimes print in the tracing path, and tracing can occur in
+ * signal handlers, so we must use a print method which is signal safe.
+ */
+/* Can't use dynamic allocation. Limit ourselves to UST_ERR_MAX_LEN chars. */
+/* Add end of string in case of buffer overflow. */
+#define sigsafe_print_err(fmt, args...)                                        \
+do {                                                                   \
+       if (ust_err_debug_enabled()) {                                  \
+               char ____buf[UST_ERR_MAX_LEN];                          \
+               int ____saved_errno;                                    \
+                                                                       \
+               ____saved_errno = errno;        /* signal-safety */     \
+               ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \
+               ____buf[sizeof(____buf) - 1] = 0;                       \
+               ust_patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \
+               errno = ____saved_errno;        /* signal-safety */     \
+               fflush(stderr);                                         \
+       }                                                               \
+} while (0)
+
+#define UST_STR_COMPONENT UST_XSTR(UST_COMPONENT)
+
+#define ERRMSG(fmt, args...)                   \
+       do {                                    \
+               sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \
+               (long) getpid(),                \
+               (long) lttng_gettid(),          \
+               ## args, __func__);             \
+       } while(0)
+
+
+#define DBG(fmt, args...)      ERRMSG(fmt, ## args)
+#define DBG_raw(fmt, args...)  sigsafe_print_err(fmt, ## args)
+#define WARN(fmt, args...)     ERRMSG("Warning: " fmt, ## args)
+#define ERR(fmt, args...)      ERRMSG("Error: " fmt, ## args)
+#define BUG(fmt, args...)      ERRMSG("BUG: " fmt, ## args)
+
+#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+/*
+ * Version using XSI strerror_r.
+ */
+#define PERROR(call, args...)                                          \
+       do {                                                            \
+               if (ust_err_debug_enabled()) {                          \
+                       char perror_buf[200] = "Error in strerror_r()"; \
+                       strerror_r(errno, perror_buf,                   \
+                                       sizeof(perror_buf));            \
+                       ERRMSG("Error: " call ": %s", ## args,          \
+                                       perror_buf);                    \
+               }                                                       \
+       } while(0)
+#else
+/*
+ * Version using GNU strerror_r, for linux with appropriate defines.
+ */
+#define PERROR(call, args...)                                          \
+       do {                                                            \
+               if (ust_err_debug_enabled()) {                          \
+                       char *perror_buf;                               \
+                       char perror_tmp[200];                           \
+                       perror_buf = strerror_r(errno, perror_tmp,      \
+                                       sizeof(perror_tmp));            \
+                       ERRMSG("Error: " call ": %s", ## args,          \
+                                       perror_buf);                    \
+               }                                                       \
+       } while(0)
+#endif
+
+#define BUG_ON(condition)                                      \
+       do {                                                    \
+               if (caa_unlikely(condition))                    \
+                       ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \
+       } while(0)
+#define WARN_ON(condition)                                     \
+       do {                                                    \
+               if (caa_unlikely(condition))                    \
+                       WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \
+       } while(0)
+#define WARN_ON_ONCE(condition) WARN_ON(condition)
+
+#endif /* _USTERR_SIGNAL_SAFE_H */
diff --git a/src/common/macros.h b/src/common/macros.h
new file mode 100644 (file)
index 0000000..308a1df
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_MACROS_H
+#define _UST_COMMON_MACROS_H
+
+#include <stdlib.h>
+
+#include <lttng/ust-arch.h>
+
+/*
+ * Memory allocation zeroed
+ */
+static inline
+void *zmalloc(size_t len)
+       __attribute__((always_inline));
+static inline
+void *zmalloc(size_t len)
+{
+       return calloc(len, 1);
+}
+
+#define max_t(type, x, y)                              \
+       ({                                              \
+               type __max1 = (x);                      \
+               type __max2 = (y);                      \
+               __max1 > __max2 ? __max1: __max2;       \
+       })
+
+#define min_t(type, x, y)                              \
+       ({                                              \
+               type __min1 = (x);                      \
+               type __min2 = (y);                      \
+               __min1 <= __min2 ? __min1: __min2;      \
+       })
+
+#define LTTNG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/*
+ * Use of __builtin_return_address(0) sometimes seems to cause stack
+ * corruption on 32-bit PowerPC. Disable this feature on that
+ * architecture for now by always using the NULL value for the ip
+ * context.
+ */
+#if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
+#define LTTNG_UST_CALLER_IP()          NULL
+#else
+#define LTTNG_UST_CALLER_IP()          __builtin_return_address(0)
+#endif
+
+#endif /* _UST_COMMON_MACROS_H */
diff --git a/src/common/patient.h b/src/common/patient.h
new file mode 100644 (file)
index 0000000..98b07b1
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_PATIENT_H
+#define _UST_COMMON_PATIENT_H
+
+#include <stdlib.h>
+#include <sys/uio.h>
+
+ssize_t ust_patient_write(int fd, const void *buf, size_t count)
+       __attribute__((visibility("hidden")));
+
+ssize_t ust_patient_writev(int fd, struct iovec *iov, int iovcnt)
+       __attribute__((visibility("hidden")));
+
+ssize_t ust_patient_send(int fd, const void *buf, size_t count, int flags)
+       __attribute__((visibility("hidden")));
+
+#endif /* _UST_COMMON_PATIENT_H */
diff --git a/src/common/safe-snprintf.h b/src/common/safe-snprintf.h
new file mode 100644 (file)
index 0000000..3cc4f67
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ */
+
+#ifndef _UST_COMMON_SAFE_SNPRINTF_H
+#define _UST_COMMON_SAFE_SNPRINTF_H
+
+#include <stdarg.h>
+#include <stddef.h>
+
+int ust_safe_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
+       __attribute__((visibility("hidden")));
+
+int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...)
+       __attribute__((visibility("hidden")))
+       __attribute__((format(printf, 3, 4)));
+
+#endif /* _UST_COMMON_SAFE_SNPRINTF_H */
diff --git a/src/common/ust-context-provider.h b/src/common/ust-context-provider.h
new file mode 100644 (file)
index 0000000..57dda8f
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * The context provider feature is part of the ABI and used by the Java jni
+ * interface. This header should be moved to the public header directory once
+ * some test code and documentation is written.
+ */
+
+#ifndef _LTTNG_UST_CONTEXT_PROVIDER_H
+#define _LTTNG_UST_CONTEXT_PROVIDER_H
+
+#include <stddef.h>
+#include <lttng/ust-events.h>
+
+#include "common/dynamic-type.h"
+
+struct lttng_ust_registered_context_provider;
+
+/*
+ * Context value
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Additional selectors may be added in the future, mapping to new
+ * union fields, which means the overall size of this structure may
+ * increase. This means this structure should never be nested within a
+ * public structure interface, nor embedded in an array.
+ */
+
+struct lttng_ust_ctx_value {
+       enum lttng_ust_dynamic_type sel;        /* Type selector */
+       union {
+               int64_t s64;
+               uint64_t u64;
+               const char *str;
+               double d;
+       } u;
+};
+
+/*
+ * Context provider
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Fields need to be only added at the end, never reordered, never
+ * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
+ */
+
+struct lttng_ust_context_provider {
+       uint32_t struct_size;
+
+       const char *name;
+       size_t (*get_size)(void *priv, size_t offset);
+       void (*record)(void *priv, struct lttng_ust_lib_ring_buffer_ctx *ctx,
+                      struct lttng_ust_channel_buffer *chan);
+       void (*get_value)(void *priv, struct lttng_ust_ctx_value *value);
+       void *priv;
+
+       /* End of base ABI. Fields below should be used after checking struct_size. */
+};
+
+/*
+ * Returns an opaque pointer on success, which must be passed to
+ * lttng_ust_context_provider_unregister for unregistration. Returns
+ * NULL on error.
+ */
+struct lttng_ust_registered_context_provider *lttng_ust_context_provider_register(struct lttng_ust_context_provider *provider);
+
+void lttng_ust_context_provider_unregister(struct lttng_ust_registered_context_provider *reg_provider);
+
+#endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */
diff --git a/src/common/ust-fd.h b/src/common/ust-fd.h
new file mode 100644 (file)
index 0000000..ddebaa9
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _LTTNG_UST_FD_H
+#define _LTTNG_UST_FD_H
+
+/*
+ * The fd tracker feature is part of the ABI and used by liblttng-ust-fd.
+ * However, some test code and documentation needs to be written before it is
+ * exposed to users with a public header.
+ */
+
+#include <stdio.h>
+
+void lttng_ust_init_fd_tracker(void);
+int lttng_ust_add_fd_to_tracker(int fd);
+void lttng_ust_delete_fd_from_tracker(int fd);
+void lttng_ust_lock_fd_tracker(void);
+void lttng_ust_unlock_fd_tracker(void);
+
+int lttng_ust_safe_close_fd(int fd, int (*close_cb)(int));
+int lttng_ust_safe_fclose_stream(FILE *stream, int (*fclose_cb)(FILE *stream));
+int lttng_ust_safe_closefrom_fd(int lowfd, int (*close_cb)(int));
+
+#endif /* _LTTNG_UST_FD_H */
diff --git a/src/common/ustcomm.h b/src/common/ustcomm.h
new file mode 100644 (file)
index 0000000..81ce885
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY.
+ * These declarations should NOT be considered stable API.
+ */
+
+#ifndef _UST_COMMON_USTCOMM_H
+#define _UST_COMMON_USTCOMM_H
+
+#include <stdint.h>
+#include <limits.h>
+#include <unistd.h>
+#include <lttng/ust-abi.h>
+#include <lttng/ust-error.h>
+#include <lttng/ust-compiler.h>
+#include <lttng/ust-ctl.h>
+
+/*
+ * Default timeout the application waits for the sessiond to send its
+ * "register done" command. Can be overridden with the environment
+ * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
+ * found, the application proceeds directly without any delay.
+ */
+#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS       3000
+
+#define LTTNG_DEFAULT_RUNDIR                           LTTNG_SYSTEM_RUNDIR
+#define LTTNG_DEFAULT_HOME_RUNDIR                      ".lttng"
+
+/* Queue size of listen(2) */
+#define LTTNG_UST_COMM_MAX_LISTEN                      10
+#define LTTNG_UST_COMM_REG_MSG_PADDING                 64
+
+struct lttng_ust_event_field;
+struct lttng_ust_ctx_field;
+struct lttng_ust_enum_entry;
+struct lttng_integer_type;
+struct lttng_ust_session;
+
+struct ustctl_reg_msg {
+       uint32_t magic;
+       uint32_t major;
+       uint32_t minor;
+       uint32_t pid;
+       uint32_t ppid;
+       uint32_t uid;
+       uint32_t gid;
+       uint32_t bits_per_long;
+       uint32_t uint8_t_alignment;
+       uint32_t uint16_t_alignment;
+       uint32_t uint32_t_alignment;
+       uint32_t uint64_t_alignment;
+       uint32_t long_alignment;
+       uint32_t socket_type;                   /* enum ustctl_socket_type */
+       char name[LTTNG_UST_ABI_PROCNAME_LEN];  /* process name */
+       char padding[LTTNG_UST_COMM_REG_MSG_PADDING];
+} __attribute__((packed));
+
+/*
+ * Data structure for the commands sent from sessiond to UST.
+ */
+#define USTCOMM_MSG_PADDING1           32
+#define USTCOMM_MSG_PADDING2           32
+struct ustcomm_ust_msg {
+       uint32_t handle;
+       uint32_t cmd;
+       char padding[USTCOMM_MSG_PADDING1];
+       union {
+               struct lttng_ust_abi_channel channel;
+               struct lttng_ust_abi_stream stream;
+               struct lttng_ust_abi_event event;
+               struct lttng_ust_abi_context context;
+               struct lttng_ust_abi_tracer_version version;
+               struct lttng_ust_abi_tracepoint_iter tracepoint;
+               struct {
+                       uint32_t data_size;     /* following filter data */
+                       uint32_t reloc_offset;
+                       uint64_t seqnum;
+               } __attribute__((packed)) filter;
+               struct {
+                       uint32_t count; /* how many names follow */
+               } __attribute__((packed)) exclusion;
+               struct {
+                       uint32_t data_size;     /* following capture data */
+                       uint32_t reloc_offset;
+                       uint64_t seqnum;
+               } __attribute__((packed)) capture;
+               struct lttng_ust_abi_counter counter;
+               struct lttng_ust_abi_counter_global counter_global;
+               struct lttng_ust_abi_counter_cpu counter_cpu;
+               /*
+                * For lttng_ust_abi_EVENT_NOTIFIER_CREATE, a struct
+                * lttng_ust_abi_event_notifier implicitly follows struct
+                * ustcomm_ust_msg.
+                */
+               struct {
+                       /* Length of struct lttng_ust_abi_event_notifier */
+                       uint32_t len;
+               } event_notifier;
+               char padding[USTCOMM_MSG_PADDING2];
+       } u;
+} __attribute__((packed));
+
+/*
+ * Data structure for the response from UST to the session daemon.
+ * cmd_type is sent back in the reply for validation.
+ */
+#define USTCOMM_REPLY_PADDING1         32
+#define USTCOMM_REPLY_PADDING2         32
+struct ustcomm_ust_reply {
+       uint32_t handle;
+       uint32_t cmd;
+       int32_t ret_code;       /* enum ustcomm_return_code */
+       uint32_t ret_val;       /* return value */
+       char padding[USTCOMM_REPLY_PADDING1];
+       union {
+               struct {
+                       uint64_t memory_map_size;
+               } __attribute__((packed)) channel;
+               struct {
+                       uint64_t memory_map_size;
+               } __attribute__((packed)) stream;
+               struct lttng_ust_abi_tracer_version version;
+               struct lttng_ust_abi_tracepoint_iter tracepoint;
+               char padding[USTCOMM_REPLY_PADDING2];
+       } u;
+} __attribute__((packed));
+
+struct ustcomm_notify_hdr {
+       uint32_t notify_cmd;
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_EVENT_MSG_PADDING       32
+struct ustcomm_notify_event_msg {
+       uint32_t session_objd;
+       uint32_t channel_objd;
+       char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       int32_t loglevel;
+       uint32_t signature_len;
+       uint32_t fields_len;
+       uint32_t model_emf_uri_len;
+       char padding[USTCOMM_NOTIFY_EVENT_MSG_PADDING];
+       /* followed by signature, fields, and model_emf_uri */
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING     32
+struct ustcomm_notify_event_reply {
+       int32_t ret_code;       /* 0: ok, negative: error code */
+       uint32_t event_id;
+       char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_ENUM_MSG_PADDING                32
+struct ustcomm_notify_enum_msg {
+       uint32_t session_objd;
+       char enum_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       uint32_t entries_len;
+       char padding[USTCOMM_NOTIFY_ENUM_MSG_PADDING];
+       /* followed by enum entries */
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING     32
+struct ustcomm_notify_enum_reply {
+       int32_t ret_code;       /* 0: ok, negative: error code */
+       uint64_t enum_id;
+       char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_CHANNEL_MSG_PADDING     32
+struct ustcomm_notify_channel_msg {
+       uint32_t session_objd;
+       uint32_t channel_objd;
+       uint32_t ctx_fields_len;
+       char padding[USTCOMM_NOTIFY_CHANNEL_MSG_PADDING];
+       /* followed by context fields */
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING   32
+struct ustcomm_notify_channel_reply {
+       int32_t ret_code;       /* 0: ok, negative: error code */
+       uint32_t chan_id;
+       uint32_t header_type;   /* enum ustctl_channel_header */
+       char padding[USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING];
+} __attribute__((packed));
+
+/*
+ * LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
+ * struct lttng_ust_field_iter field.
+ */
+
+int ustcomm_create_unix_sock(const char *pathname)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_connect_unix_sock(const char *pathname,
+       long timeout)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_accept_unix_sock(int sock)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_listen_unix_sock(int sock)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_close_unix_sock(int sock)
+       __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
+       __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len)
+       __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
+       __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
+       __attribute__((visibility("hidden")));
+
+const char *ustcomm_get_readable_code(int code)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
+       uint32_t expected_handle, uint32_t expected_cmd)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_send_app_cmd(int sock,
+               struct ustcomm_ust_msg *lum,
+               struct ustcomm_ust_reply *lur)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_recv_fd(int sock)
+       __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_channel_from_sessiond(int sock,
+               void **chan_data, uint64_t len, int *wakeup_fd)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_recv_stream_from_sessiond(int sock,
+               uint64_t *memory_map_size,
+               int *shm_fd, int *wakeup_fd)
+       __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_event_notifier_notif_fd_from_sessiond(int sock,
+               int *event_notifier_notif_fd)
+       __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_counter_from_sessiond(int sock,
+               void **counter_data, uint64_t len)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_recv_counter_shm_from_sessiond(int sock,
+               int *shm_fd)
+       __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_send_reg_msg(int sock,
+               enum ustctl_socket_type type,
+               uint32_t bits_per_long,
+               uint32_t uint8_t_alignment,
+               uint32_t uint16_t_alignment,
+               uint32_t uint32_t_alignment,
+               uint32_t uint64_t_alignment,
+               uint32_t long_alignment)
+       __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_register_event(int sock,
+       struct lttng_ust_session *session,
+       int session_objd,               /* session descriptor */
+       int channel_objd,               /* channel descriptor */
+       const char *event_name,         /* event name (input) */
+       int loglevel,
+       const char *signature,          /* event signature (input) */
+       size_t nr_fields,               /* fields */
+       const struct lttng_ust_event_field **fields,
+       const char *model_emf_uri,
+       uint32_t *id)                   /* event id (output) */
+       __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_register_enum(int sock,
+       int session_objd,               /* session descriptor */
+       const char *enum_name,          /* enum name (input) */
+       size_t nr_entries,              /* entries */
+       const struct lttng_ust_enum_entry **entries,
+       uint64_t *id)                   /* enum id (output) */
+       __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_register_channel(int sock,
+       struct lttng_ust_session *session,
+       int session_objd,               /* session descriptor */
+       int channel_objd,               /* channel descriptor */
+       size_t nr_ctx_fields,
+       struct lttng_ust_ctx_field *ctx_fields,
+       uint32_t *chan_id,              /* channel id (output) */
+       int *header_type)               /* header type (output) */
+       __attribute__((visibility("hidden")));
+
+int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec)
+       __attribute__((visibility("hidden")));
+
+int ustcomm_setsockopt_snd_timeout(int sock, unsigned int msec)
+       __attribute__((visibility("hidden")));
+
+#endif /* _UST_COMMON_USTCOMM_H */
index 540bd11f2e75216310af63f50fe187c12e799deb..f140325d32bf3088a4df3bcfe0a3c261a3e4d75a 100644 (file)
@@ -15,7 +15,7 @@
 #include "counter-internal.h"
 #include <urcu/compiler.h>
 #include <urcu/uatomic.h>
-#include "ust-bitmap.h"
+#include "common/bitmap.h"
 #include "../libringbuffer/getcpu.h"
 
 /*
index a825ac95e0020b0814770499b449ba157ec36a38..0393bed30ab2fe81f9a44c41b695a08bd6e82c34 100644 (file)
 #include <urcu/system.h>
 #include <urcu/compiler.h>
 #include <stdbool.h>
-#include <ust-helper.h>
+
+#include "common/macros.h"
+#include "common/align.h"
+#include "common/bitmap.h"
+
 #include "smp.h"
 #include "shm.h"
-#include "ust-compat.h"
-
-#include "ust-bitmap.h"
 
 static size_t lttng_counter_get_dimension_nr_elements(struct lib_counter_dimension *dimension)
 {
index b8a07e132d2985aaf7b0caace7368de2562f22e0..c1d6718ac03dc8a34c6d26052de623666918de9d 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <lttng/ust-utils.h>
 
-#include <ust-helper.h>
-#include <ust-fd.h>
+#include "common/macros.h"
+#include "common/ust-fd.h"
 #include "../libringbuffer/mmap.h"
 
 /*
index 8ec251d7686908c544470ad81a577c98d3586bc3..689edb0a5a1917a9bc6591af81688442e52affbb 100644 (file)
@@ -10,7 +10,7 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include <urcu/compiler.h>
 #include "shm_types.h"
 
index d5d193d75ff60c39cd5d14bd9a068dc74d67bf1f..2d445cbadc0bda6cafd15cb1bb3594d713d4d2d2 100644 (file)
 #include <fcntl.h>
 
 #include <lttng/ust-ctl.h>
-#include <ust-comm.h>
-#include <ust-fd.h>
-#include <ust-helper.h>
+#include "common/ustcomm.h"
+#include "common/ust-fd.h"
+#include "common/macros.h"
 #include <lttng/ust-error.h>
-#include <ust-dynamic-type.h>
-#include <usterr-signal-safe.h>
+#include "common/dynamic-type.h"
+#include "common/logging.h"
 
 #include "../liblttng-ust/ust-events-internal.h"
 #include "../liblttng-ust/compat.h"
index 18456e08ee88169f4dc9235e96d520664e74a309..3879a90df41d8867b53626c40b789deeeb3cfcb8 100644 (file)
 #include <urcu/tls-compat.h>
 #include <urcu/system.h>
 
-#include <ust-fd.h>
-#include <ust-helper.h>
+#include "common/ust-fd.h"
+#include "common/macros.h"
 #include <lttng/ust-error.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 
 #include "../liblttng-ust/compat.h"
 #include "../liblttng-ust/lttng-tracer-core.h"
index a12e9dd377a008a308e2a9433ca5f370c7d49dd9..a4e9d0e9849b0d555f9e323d62f72480396254cc 100644 (file)
 #include <lttng/ust-abi.h>
 #include <lttng/ust-endian.h>
 
-#include <usterr-signal-safe.h>
-#include <ust-comm.h>
-#include <ust-helper.h>
-#include "ust-compat.h"
+#include "common/logging.h"
+#include "common/ustcomm.h"
+#include "common/macros.h"
+#include "common/align.h"
 
 #include "../libringbuffer/backend.h"
 #include "../libringbuffer/frontend.h"
index 1394ce1963fce5e31ec53dc41e1b39ebf21237c3..6444e3fbc0a76bef294ad16c7821c610ce994dde 100644 (file)
@@ -7,17 +7,20 @@
  */
 
 #define _LGPL_SOURCE
+
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
 #include <limits.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <ust-dlfcn.h>
-#include <ust-elf.h>
+#include "common/elf.h"
 #include <lttng/ust-events.h>
-#include <ust-helper.h>
-#include "usterr-signal-safe.h"
+#include "common/macros.h"
+#include "common/logging.h"
 
 #include "../liblttng-ust/ust-events-internal.h"
 
index 14a23d9f557b79f12d44146d52a498b895ac76dd..5efc0acde29583479bee79d1f3a251ab854507f7 100644 (file)
@@ -9,10 +9,10 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <ust-fd.h>
+#include "common/ust-fd.h"
 #include <dlfcn.h>
 
-#include <ust-helper.h>
+#include "common/macros.h"
 
 static int (*__lttng_ust_fd_plibc_close)(int fd);
 static int (*__lttng_ust_fd_plibc_fclose)(FILE *stream);
index b10f24d23f4e9a7f42b891cdaa44366e0e444ce9..3eb62d2a296567b96ee118881dc92d372a36eb90 100644 (file)
@@ -5,7 +5,9 @@
  * Copyright (C) 2011-2012  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
-#include <ust-dlfcn.h>
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
 #include <unistd.h>
 #include <stdio.h>
 #include <signal.h>
index 7ba4403a05588daee1176181671673de08fc4e9f..8570b211e753e1ddd4c1469bf502976b56b3649c 100644 (file)
@@ -12,9 +12,9 @@
 #include <inttypes.h>
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-context.h>
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
 
-#include "ust-helper.h"
+#include "common/macros.h"
 #include "lttng_ust_context.h"
 
 enum lttng_ust_jni_type {
index e1ff8e807f7a9fb22dc6f783230ce6f1b1693e4f..a93c7c1a016742ef54a7b87eedb1bbb2bd9a2e50 100644 (file)
  * circular dependency loop between this malloc wrapper, liburcu and
  * libc.
  */
-#include <ust-dlfcn.h>
+
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <assert.h>
@@ -24,8 +27,8 @@
 
 #include <lttng/ust-libc-wrapper.h>
 
-#include <ust-helper.h>
-#include "ust-compat.h"
+#include "common/macros.h"
+#include "common/align.h"
 
 #define TRACEPOINT_DEFINE
 #define TRACEPOINT_CREATE_PROBES
index 06bf791b20c2c66f6b3a6b95f3f11dbc99c53be0..c6633fe8592384a0d2b8947270add8775c7de2bc 100644 (file)
@@ -9,8 +9,11 @@
  * circular dependency loop between this malloc wrapper, liburcu and
  * libc.
  */
-#include <ust-dlfcn.h>
-#include <ust-helper.h>
+
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
+#include "common/macros.h"
 #include <pthread.h>
 
 #define TRACEPOINT_DEFINE
index 209ffd436553a8c85d10854c1d34e321f58afe51..87e3bbf50228bddd9e20c132fdd8853aaf519e36 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <lttng/ust-events.h>
 #include "ust-events-internal.h"
-#include "ust-context-provider.h"
+#include "common/ust-context-provider.h"
 
 int lttng_context_init_all(struct lttng_ust_ctx **ctx)
        __attribute__((visibility("hidden")));
index b3e2c94f1bd7a2d7180ad64256bcb325ea393e85..aab66ab26dc2e6076b1d5b8275e6d0904a47866c 100644 (file)
 #include <limits.h>
 
 #include <lttng/ust-endian.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include <urcu/rculist.h>
 
 #include "lttng-tracer-core.h"
 #include "ust-events-internal.h"
 #include "../libmsgpack/msgpack.h"
 #include "lttng-bytecode.h"
-#include "ust-share.h"
+#include "common/patient.h"
 
 /*
  * We want this write to be atomic AND non-blocking, meaning that we
index ea8edbcdf5244878f5a7fd4f900068f0502e4fe7..0a7bffd8c2f3d4f3b0ec9d85fffc660805c23f00 100644 (file)
@@ -9,8 +9,8 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <sys/types.h>
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
 #include "getenv.h"
 
 enum lttng_env_secure {
index 31bc3d05f6d043072854415cdeebe3736353664b..3d7b5c2a61435a3c7becf30f51b6b47329830170 100644 (file)
@@ -16,7 +16,7 @@
 #include "context-internal.h"
 #include "lttng-bytecode.h"
 #include "ust-events-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
 
 static int lttng_fls(int val)
 {
index 267c5c19635a3ab56fe454ee80357c3fc1b60a7c..91c4cace96c1675a3509214dc35028e8f8941b2f 100644 (file)
@@ -17,7 +17,7 @@
 #include "lttng-hash-helper.h"
 #include "string-utils.h"
 #include "ust-events-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
 
 /*
  * Number of merge points for hash table size. Hash table initialized to
index ea5827a447adffb671c879fdf6730e7ac601944f..68108192d08158ca68e868e76fdcf590778862a5 100644 (file)
@@ -15,7 +15,7 @@
 #include "context-internal.h"
 #include "lttng-bytecode.h"
 #include "ust-events-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
 
 static const char *opnames[] = {
        [ BYTECODE_OP_UNKNOWN ] = "UNKNOWN",
index ffbaf18772e46faa9474265c46a0e33800709d0c..a72369e12f9ef3ac757c98941aa43466323ce985 100644 (file)
 #include <errno.h>
 #include <stdio.h>
 #include <stdbool.h>
-#include <ust-helper.h>
+#include "common/macros.h"
 #include <lttng/ust-events.h>
-#include <ust-context-provider.h>
+#include "common/ust-context-provider.h"
 #include <stdint.h>
 #include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include <inttypes.h>
 #include <limits.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include "bytecode.h"
 #include "ust-events-internal.h"
 
index 27ecccd91cc2da6e1ad97bb1b80ede3a66030a42..edda7ae933544650f0d0494a2c016ecb572afa74 100644 (file)
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <usterr-signal-safe.h>
+
 #include <lttng/ust-clock.h>
 #include <urcu/system.h>
 #include <urcu/arch.h>
 
+#include "common/logging.h"
+
 #include "clock.h"
 #include "getenv.h"
 
index fece0808c27c21846c0dd8499b090894197e1224..305ed8cd40ac56f9ce3ba290670c233b3fa0b59c 100644 (file)
@@ -15,7 +15,7 @@
 #include <unistd.h>
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
 #include <urcu/tls-compat.h>
 #include <lttng/ringbuffer-context.h>
 
index 2ec62416c1cd4fbc3dc42e39a94e789bf8bf2036..c5867fb494771edc760030d500c5e75228964fb2 100644 (file)
@@ -15,7 +15,7 @@
 #include <unistd.h>
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
 #include <urcu/tls-compat.h>
 #include <lttng/ringbuffer-context.h>
 
index 76707cba5a11280b466b33a105af89eb782e5e3a..e7c8f9f9c5a181a830af4d2544980c5600e0465c 100644 (file)
@@ -16,7 +16,7 @@
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
 #include <urcu/tls-compat.h>
 
 #include "context-internal.h"
index 6f6209112a81b4bf681eae06f5fe3e40c37d6c78..39b51f3b5f8f08b2e96d53c789583ade998da3c3 100644 (file)
@@ -25,9 +25,9 @@
 #include <urcu/system.h>
 #include <urcu/arch.h>
 #include <urcu/rculist.h>
-#include <ust-helper.h>
+#include "common/macros.h"
 #include <urcu/ref.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include <signal.h>
 #include <urcu/tls-compat.h>
 #include "perf_event.h"
index c70da2089992a71a102d5faf3d6438039b044e7e..caeb387bd6b3b31ca7bb40305aced74393e11fd9 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
 
 #include "context-internal.h"
 #include "lttng-tracer-core.h"
 #include "jhash.h"
 #include "context-provider-internal.h"
-#include <ust-helper.h>
+#include "common/macros.h"
 
 struct lttng_ust_registered_context_provider {
        const struct lttng_ust_context_provider *provider;
index cb907c4a2654d4021438e6416e24de0f9f25c8ef..75e3e36506f1bf7608ec9818830779d3584c36b6 100644 (file)
@@ -16,7 +16,7 @@
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
 #include <urcu/tls-compat.h>
 #include "lttng-tracer-core.h"
 #include "ns.h"
index 5ba06f6e182f5a9c043e7f3cb60ee49412e21a79..b28fe8749a7f3f22da94fb9291a9e6b962216cc7 100644 (file)
@@ -16,7 +16,7 @@
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
 #include <urcu/tls-compat.h>
 
 #include "context-internal.h"
index 3530d2668757269d6139369bbae19b0a14912c1f..ce8dcd2c951e8df66de95af938c4237a5f08d814 100644 (file)
@@ -14,7 +14,7 @@
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
 #include <urcu/tls-compat.h>
 
 #include "context-internal.h"
index 7043c1571d78b00fe555bc38756fd54f992e4aa7..aeafa9fc255dcb11ca6288ba52dae2947fdaba6d 100644 (file)
@@ -9,11 +9,11 @@
 #define _LGPL_SOURCE
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
 #include <lttng/urcu/pointer.h>
 #include <lttng/urcu/urcu-ust.h>
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
 #include <stddef.h>
 #include <string.h>
 #include <assert.h>
index b61a2293f4a8a83039f3a645da09e9fb60cab479..ed11b3b5cdbf512c81eacbfddd6c329bb5a0f83e 100644 (file)
 #include <lttng/tracepoint.h>
 #include <lttng/ust-events.h>
 
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
 #include <lttng/ust-ctl.h>
-#include <ust-comm.h>
-#include <ust-fd.h>
-#include <ust-dynamic-type.h>
-#include <ust-context-provider.h>
+#include "common/ustcomm.h"
+#include "common/ust-fd.h"
+#include "common/dynamic-type.h"
+#include "common/ust-context-provider.h"
 #include "error.h"
 #include "compat.h"
 #include "lttng-ust-uuid.h"
index 762f8152fec1aacc157407da1ea2b2566a991379..d4d91da65b32a05d048c390575ffdb0ff2e22bdd 100644 (file)
@@ -8,7 +8,7 @@
 #include <error.h>
 #include <dlfcn.h>
 #include <stdlib.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include <lttng/ust-getcpu.h>
 #include <urcu/system.h>
 #include <urcu/arch.h>
index 03fbe36b44d3f93c5701c5f1330e768efc9e2cdf..553770ea2954049fdaa311477c16f71e2e8521ca 100644 (file)
@@ -15,7 +15,7 @@
 #include <lttng/tracepoint.h>
 #include "tracepoint-internal.h"
 #include <assert.h>
-#include <ust-helper.h>
+#include "common/macros.h"
 #include <ctype.h>
 
 #include "lttng-tracer-core.h"
index a63786bc892ea93c990e7e3144a246f51c10a526..d7f7769832e629869aea2ae84a17431f6064a6ab 100644 (file)
@@ -12,8 +12,8 @@
 
 #include <ust-events-internal.h>
 #include <lttng/urcu/pointer.h>
-#include "ust-bitfield.h"
-#include "ust-compat.h"
+#include "common/bitfield.h"
+#include "common/align.h"
 #include "clock.h"
 #include "context-internal.h"
 #include "lttng-tracer.h"
index fe080dca99cdb92b890687c8055ed42ad64bf1e7..2406567ef117e886e2683ab397e70d7aba3c6fc3 100644 (file)
@@ -11,8 +11,8 @@
 #include <stdint.h>
 
 #include <ust-events-internal.h>
-#include "ust-bitfield.h"
-#include "ust-compat.h"
+#include "common/bitfield.h"
+#include "common/align.h"
 #include "lttng-tracer.h"
 #include "../libringbuffer/frontend_types.h"
 #include <urcu/tls-compat.h>
index 7714dbf4baad2f744acb3f17686c6c84b17a1cf8..e127a6607729deb8cf5f861b1c1e86299a7a8d0f 100644 (file)
@@ -14,7 +14,7 @@
 #include <urcu/list.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-context.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 
 /*
  * The longuest possible namespace proc path is with the cgroup ns
index 61105ace6dccd9d83e00865454e7580252b21199..e443e4bcd27965f81ce6c999017a65c7a467d647 100644 (file)
@@ -35,8 +35,9 @@
 #include <lttng/ust-error.h>
 #include <lttng/ust-events.h>
 #include <lttng/ust-version.h>
-#include <ust-fd.h>
-#include <usterr-signal-safe.h>
+
+#include "common/ust-fd.h"
+#include "common/logging.h"
 
 #include "../libringbuffer/frontend_types.h"
 #include "../libringbuffer/frontend.h"
@@ -47,7 +48,7 @@
 #include "string-utils.h"
 #include "ust-events-internal.h"
 #include "context-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
 
 #define OBJ_NAME_LEN   16
 
index c0a7311fa66e7797c62c8a207a429e28ad190dcf..137107cd976f697df2e24a8d9763304365a3e9fe 100644 (file)
 #include <lttng/ust-thread.h>
 #include <lttng/ust-tracer.h>
 #include <urcu/tls-compat.h>
-#include <ust-comm.h>
-#include <ust-fd.h>
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/ustcomm.h"
+#include "common/ust-fd.h"
+#include "common/logging.h"
+#include "common/macros.h"
 #include "tracepoint-internal.h"
 #include "lttng-tracer-core.h"
 #include "compat.h"
@@ -53,7 +53,7 @@
 #include "getenv.h"
 #include "ust-events-internal.h"
 #include "context-internal.h"
-#include "ust-compat.h"
+#include "common/align.h"
 #include "lttng-counter-client.h"
 #include "lttng-rb-clients.h"
 
index 3012869971e9ea3a321d4ff8c4a8fdbc16425192..d98e45ba24ca66d745da4d6cf93d37e59775244a 100644 (file)
@@ -12,8 +12,8 @@
 #include <stddef.h>
 #include <inttypes.h>
 
-#include <ust-helper.h>
-#include <ust-dynamic-type.h>
+#include "common/macros.h"
+#include "common/dynamic-type.h"
 
 #define ctf_enum_value(_string, _value)                                        \
        __LTTNG_COMPOUND_LITERAL(struct lttng_ust_enum_entry, {         \
index 3e0b8890559bd968c45d523fd643c35005f01b99..5980536548d26ba95a65a927a56ac558c5e01ffd 100644 (file)
 
 #include <lttng/ust-utils.h>
 
-#include <ust-elf.h>
-#include <ust-fd.h>
+#include "common/elf.h"
+#include "common/ust-fd.h"
 
 #include "lttng-tracer-core.h"
 #include "lttng-ust-elf.h"
-#include "ust-helper.h"
+#include "common/macros.h"
 
 #define BUF_LEN        4096
 
index eaee338a79d5b740591f015e58bd63c81dd22434..cd8bc7c8247022f9da56428e40b573050cc5f334 100644 (file)
@@ -16,8 +16,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <ust-elf.h>
-#include <ust-helper.h>
+#include "common/elf.h"
+#include "common/macros.h"
 #include "lttng-tracer-core.h"
 #include "lttng-ust-statedump.h"
 #include "jhash.h"
index 4c7e805da9d59d7805e1e6beaa7f0609e8e65f63..3c4ce490511fa3630bb114e6b60d04c193a803be 100644 (file)
@@ -6,7 +6,7 @@
 
 #define _LGPL_SOURCE
 #include <stdio.h>
-#include <ust-helper.h>
+#include "common/macros.h"
 
 #define TRACEPOINT_CREATE_PROBES
 #define TRACEPOINT_DEFINE
index d69301d80210d084a631c81f2193b14550965468..735d04a946baecfb9a8f8b7b1752af7d23a41672 100644 (file)
@@ -6,7 +6,7 @@
 
 #define _LGPL_SOURCE
 #include <stdio.h>
-#include <ust-helper.h>
+#include "common/macros.h"
 
 #define TRACEPOINT_CREATE_PROBES
 #define TRACEPOINT_DEFINE
index 00fcc740101b5f443d77fba5b8596f3053643302..e5a970adc19207f1a81ea92c2d8d52fe5c56a2e4 100644 (file)
@@ -23,8 +23,8 @@
 #include <lttng/tracepoint.h>
 #include <lttng/ust-abi.h>     /* for LTTNG_UST_ABI_SYM_NAME_LEN */
 
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
 
 #include "tracepoint-internal.h"
 #include "lttng-tracer-core.h"
index 2633832b801bab42ad311b73ab23752449d77caf..d4829904304c2314bfefe78c6f4f7e5b5d6b466e 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "context-internal.h"
 #include "ust-events-internal.h"
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include "lttng-tracer-core.h"
 #include "lttng-rb-clients.h"
 #include "lttng-counter-client.h"
index d84d32ee1af7be827d2b6ac571f3d4297b73ba1d..21d40e171ed21b6957c50347b2fd155ebbf72b43 100644 (file)
@@ -15,8 +15,8 @@
 
 #include <lttng/ust-events.h>
 
-#include <ust-helper.h>
-#include "ust-context-provider.h"
+#include "common/macros.h"
+#include "common/ust-context-provider.h"
 
 struct lttng_ust_abi_obj;
 struct lttng_event_notifier_group;
index 4e7d2e8f7526bcca829161b683af1fed2d60c277..467ece73778b2c21cde7eb60db6b9d9b1ed605c9 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <lttng/ringbuffer-context.h>
 #include "ringbuffer-config.h"
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include "backend_types.h"
 #include "shm_internal.h"
 #include "shm_types.h"
index 6ba0d8b1d44fe4fbb4dbe8989e773a355691c4d2..b0a7c513f80da21b30234ebef939d5c3ec034086 100644 (file)
@@ -20,7 +20,7 @@
 #include "frontend.h"
 #include "smp.h"
 #include "shm.h"
-#include "ust-compat.h"
+#include "common/align.h"
 
 /**
  * lib_ring_buffer_backend_allocate - allocate a channel buffer
index 1b9ec40d3cc9b001a5bd951457438cf2445c53e3..296368f36e695138741bcf356f64c1d206f04027 100644 (file)
@@ -50,7 +50,7 @@
 #include <urcu/ref.h>
 #include <urcu/tls-compat.h>
 #include <poll.h>
-#include <ust-helper.h>
+#include "common/macros.h"
 
 #include <lttng/ust-utils.h>
 #include <lttng/ringbuffer-context.h>
index e4f818fce8f366f4f5a5899ee9e79eb96014febb..a5de019cd8dac4e91fb8fdbbab3101e4788c04da 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <lttng/ust-utils.h>
 
-#include <ust-helper.h>
-#include <ust-fd.h>
+#include "common/macros.h"
+#include "common/ust-fd.h"
 #include "mmap.h"
 
 /*
index c3ce4ef891a998549844c09c5b5f41ceac133c4d..6e4f7f7b85221a9029a38514b03eeaf36944a801 100644 (file)
@@ -10,7 +10,7 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <unistd.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 #include <urcu/compiler.h>
 #include "shm_types.h"
 
index 8c4eddeca1a208f90bc2be16cac9153e3adb82ea..9841c68dbdc286be2d4c508b005eb4c4054fd477 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
 
 volatile enum ust_err_loglevel ust_err_loglevel;
 
index 5a7fed43165ed46b4782b7844d9735d6853eb8ce..517a16ad2ebca5b1a1086d622da5d265bd6efdd5 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <errno.h>
 
-#include <ust-share.h>
+#include "common/patient.h"
 
 /*
  * This write is patient because it restarts if it was incomplete.
index 7e37a5e5886d449776b095d913a014f63f6a0b9d..c297cb70d1f3286b4d40800462b1b23168ae0e94 100644 (file)
@@ -15,7 +15,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include "local.h"
-#include "ust-snprintf.h"
+#include "common/safe-snprintf.h"
 
 #define DUMMY_LEN      1
 
index 9cc8f1a82b99209961177f0fb620dac85af9c3df..26cca016df7d4c0a17f661bbac0fec34eb1c7a59 100644 (file)
@@ -31,7 +31,7 @@ struct mmsghdr;
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-context.h>
 /* Internal header. */
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
 
 static __thread unsigned int test_count;
 
index d543991a2aca0fb931c34d00b73c38577728115a..c00921700cc59d641aa8ba4850c18be5395acaec 100644 (file)
@@ -13,7 +13,7 @@
 #include <fcntl.h>
 
 #include "../../../src/libringbuffer/shm.h"
-#include "ust-compat.h"
+#include "common/align.h"
 
 #include "tap.h"
 
index 00fd02a0c91d4d79475836680207058c9711e1b3..79f31357bb6d0f370a08a2d48e3571027dbf290a 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "ust-snprintf.h"
+#include "common/safe-snprintf.h"
 
 #include "tap.h"
 
index 0073a999fb94a46ef006ab693e91d72324ad3806..7e924a9099b563852a8d7875e0983e19e16beb00 100644 (file)
@@ -11,7 +11,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <ust-elf.h>
+#include "common/elf.h"
 #include "tap.h"
 
 #define NUM_ARCH 4
This page took 0.142085 seconds and 4 git commands to generate.