logging.h \
macros.h \
patient.h \
+ procname.h \
safe-snprintf.h
noinst_HEADERS += \
compat/dlfcn.h \
+ compat/errno.h \
compat/mmap.h \
+ compat/pthread.h \
compat/tid.h
# These headers should be moved to the public headers when tested and
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#ifndef _UST_COMMON_COMPAT_ERRNO_H
+#define _UST_COMMON_COMPAT_ERRNO_H
+
+#include <errno.h>
+
+#ifndef ENODATA
+#define ENODATA ENOMSG
+#endif
+
+#endif /* _UST_COMMON_COMPAT_ERRNO_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2016 Raphaël Beamonte <raphael.beamonte@gmail.com>
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#ifndef _UST_COMMON_COMPAT_PTHREAD_H
+#define _UST_COMMON_COMPAT_PTHREAD_H
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <lttng/ust-abi.h>
+
+#ifdef __FreeBSD__
+#include <pthread_np.h>
+#endif
+
+#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ /*
+ * Some implementations don't error out, replicate this behavior for
+ * consistency.
+ */
+ if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
+ return ERANGE;
+ }
+
+ return pthread_setname_np(pthread_self(), name);
+}
+#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ return pthread_setname_np(name);
+}
+#elif defined(HAVE_PTHREAD_SET_NAME_NP_WITH_TID)
+
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ /* Replicate pthread_setname_np's behavior */
+ if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
+ return ERANGE;
+ }
+
+ pthread_set_name_np(pthread_self(), name);
+ return 0;
+}
+#elif defined(__linux__)
+
+/* Fallback on prtctl on Linux */
+#include <sys/prctl.h>
+
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ /* Replicate pthread_setname_np's behavior */
+ if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
+ return ERANGE;
+ }
+ return prctl(PR_SET_NAME, name, 0, 0, 0);
+}
+#else
+#error "Please add pthread set name support for your OS."
+#endif
+
+
+#if defined(HAVE_PTHREAD_GETNAME_NP_WITH_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ return pthread_getname_np(pthread_self(), name, len);
+}
+#elif defined(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ return pthread_getname_np(name, len);
+}
+#elif defined(HAVE_PTHREAD_GET_NAME_NP_WITH_TID)
+
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ pthread_get_name_np(pthread_self(), name, len);
+ return 0;
+}
+#elif defined(__linux__)
+
+/* Fallback on prtctl on Linux */
+#include <sys/prctl.h>
+
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ return prctl(PR_GET_NAME, name, 0, 0, 0);
+}
+
+#else
+#error "Please add pthread get name support for your OS."
+#endif
+
+#endif /* _UST_COMMON_COMPAT_PTHREAD_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2016 Raphaël Beamonte <raphael.beamonte@gmail.com>
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#ifndef _UST_COMMON_PROCNAME_H
+#define _UST_COMMON_PROCNAME_H
+
+#include <string.h>
+#include <lttng/ust-abi.h>
+
+#include "common/compat/pthread.h"
+
+#define LTTNG_UST_PROCNAME_SUFFIX "-ust"
+
+/*
+ * If a pthread setname/set_name function is available, declare
+ * the setustprocname() function that will add '-ust' to the end
+ * of the current process name, while truncating it if needed.
+ */
+static inline
+int lttng_ust_setustprocname(void)
+{
+ int ret = 0, len;
+ char name[LTTNG_UST_ABI_PROCNAME_LEN];
+ int limit = LTTNG_UST_ABI_PROCNAME_LEN - strlen(LTTNG_UST_PROCNAME_SUFFIX) - 1;
+
+ /*
+ * Get the current thread name.
+ */
+ ret = lttng_pthread_getname_np(name, LTTNG_UST_ABI_PROCNAME_LEN);
+ if (ret) {
+ goto error;
+ }
+
+ len = strlen(name);
+ if (len > limit) {
+ len = limit;
+ }
+
+ ret = sprintf(name + len, LTTNG_UST_PROCNAME_SUFFIX);
+ if (ret != strlen(LTTNG_UST_PROCNAME_SUFFIX)) {
+ goto error;
+ }
+
+ ret = lttng_pthread_setname_np(name);
+
+error:
+ return ret;
+}
+
+#endif /* _UST_COMMON_PROCNAME_H */
#include "frontend.h"
#include "shm.h"
#include "rb-init.h"
-#include "liblttng-ust/compat.h" /* For ENODATA */
+#include "common/compat/errno.h" /* For ENODATA */
/* Print DBG() messages about events lost only every 1048576 hits */
#define DBG_PRINT_NR_LOST (1UL << 20)
#include "common/logging.h"
#include "../liblttng-ust/ust-events-internal.h"
-#include "../liblttng-ust/compat.h"
+#include "common/compat/pthread.h"
#define USTCOMM_CODE_OFFSET(code) \
(code == LTTNG_UST_OK ? 0 : (code - LTTNG_UST_ERR + 1))
tracepoint-internal.h \
ust-events-internal.h \
clock.h \
- compat.h \
wait.h \
jhash.h \
lttng-ust-uuid.h \
+++ /dev/null
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2016 Raphaël Beamonte <raphael.beamonte@gmail.com>
- * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- */
-
-#ifndef _UST_COMPAT_H
-#define _UST_COMPAT_H
-
-#include <pthread.h>
-#include <errno.h>
-#include <string.h>
-
-#ifdef __FreeBSD__
-#include <pthread_np.h>
-#endif
-
-#include <lttng/ust-abi.h>
-
-#define LTTNG_UST_PROCNAME_SUFFIX "-ust"
-
-
-#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- /*
- * Some implementations don't error out, replicate this behavior for
- * consistency.
- */
- if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
- return ERANGE;
- }
-
- return pthread_setname_np(pthread_self(), name);
-}
-#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- return pthread_setname_np(name);
-}
-#elif defined(HAVE_PTHREAD_SET_NAME_NP_WITH_TID)
-
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- /* Replicate pthread_setname_np's behavior */
- if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
- return ERANGE;
- }
-
- pthread_set_name_np(pthread_self(), name);
- return 0;
-}
-#elif defined(__linux__)
-
-/* Fallback on prtctl on Linux */
-#include <sys/prctl.h>
-
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- /* Replicate pthread_setname_np's behavior */
- if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
- return ERANGE;
- }
- return prctl(PR_SET_NAME, name, 0, 0, 0);
-}
-#else
-#error "Please add pthread set name support for your OS."
-#endif
-
-
-#if defined(HAVE_PTHREAD_GETNAME_NP_WITH_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- return pthread_getname_np(pthread_self(), name, len);
-}
-#elif defined(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- return pthread_getname_np(name, len);
-}
-#elif defined(HAVE_PTHREAD_GET_NAME_NP_WITH_TID)
-
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- pthread_get_name_np(pthread_self(), name, len);
- return 0;
-}
-#elif defined(__linux__)
-
-/* Fallback on prtctl on Linux */
-#include <sys/prctl.h>
-
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- return prctl(PR_GET_NAME, name, 0, 0, 0);
-}
-
-#else
-#error "Please add pthread get name support for your OS."
-#endif
-
-/*
- * If a pthread setname/set_name function is available, declare
- * the setustprocname() function that will add '-ust' to the end
- * of the current process name, while truncating it if needed.
- */
-static inline
-int lttng_ust_setustprocname(void)
-{
- int ret = 0, len;
- char name[LTTNG_UST_ABI_PROCNAME_LEN];
- int limit = LTTNG_UST_ABI_PROCNAME_LEN - strlen(LTTNG_UST_PROCNAME_SUFFIX) - 1;
-
- /*
- * Get the current thread name.
- */
- ret = lttng_pthread_getname_np(name, LTTNG_UST_ABI_PROCNAME_LEN);
- if (ret) {
- goto error;
- }
-
- len = strlen(name);
- if (len > limit) {
- len = limit;
- }
-
- ret = sprintf(name + len, LTTNG_UST_PROCNAME_SUFFIX);
- if (ret != strlen(LTTNG_UST_PROCNAME_SUFFIX)) {
- goto error;
- }
-
- ret = lttng_pthread_setname_np(name);
-
-error:
- return ret;
-}
-
-#include <errno.h>
-
-#ifndef ENODATA
-#define ENODATA ENOMSG
-#endif
-
-#endif /* _UST_COMPAT_H */
#include <lttng/ust-error.h>
#include "common/logging.h"
-#include "liblttng-ust/compat.h"
-
/* Operations on the fd set. */
#define IS_FD_VALID(fd) ((fd) >= 0 && (fd) < lttng_ust_max_fd)
#define GET_FD_SET_FOR_FD(fd, fd_sets) (&((fd_sets)[(fd) / FD_SETSIZE]))
#include <lttng/ringbuffer-context.h>
#include <urcu/tls-compat.h>
#include <assert.h>
-#include "compat.h"
+#include "common/compat/pthread.h"
#include "lttng-tracer-core.h"
#include "context-internal.h"
#include "common/dynamic-type.h"
#include "common/ust-context-provider.h"
#include "error.h"
-#include "compat.h"
#include "lttng-ust-uuid.h"
#include "tracepoint-internal.h"
#include <stdint.h>
#include <lttng/ust-events.h>
#include "lttng-tracer-core.h"
-#include "compat.h"
/* Tracer properties */
#define CTF_MAGIC_NUMBER 0xC1FC1FC1
#include "common/macros.h"
#include "tracepoint-internal.h"
#include "lttng-tracer-core.h"
-#include "compat.h"
+#include "common/compat/pthread.h"
+#include "common/procname.h"
#include "common/ringbuffer/rb-init.h"
#include "lttng-ust-statedump.h"
#include "clock.h"
#include <stdint.h>
#include <unistd.h>
#include <lttng/ust-events.h>
-#include "compat.h"
#define LTTNG_UST_STATEDUMP_PROVIDER
#include <lttng/tracepoint.h>
#include "lttng-ust-statedump.h"
#include "jhash.h"
#include "getenv.h"
-#include "compat.h"
#include "ust-events-internal.h"
#define TRACEPOINT_DEFINE
#include <stdio.h>
#include <string.h>
-#include "../../../src/liblttng-ust/compat.h"
+#include "common/compat/pthread.h"
+#include "common/procname.h"
#include "tap.h"