Split and remove lttng-share header file
authorDavid Goulet <dgoulet@efficios.com>
Fri, 20 Jan 2012 21:30:23 +0000 (16:30 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 20 Jan 2012 21:30:23 +0000 (16:30 -0500)
This header is split into two files: defaults.h and macros.h.

A third header is introduce here which is common.h including runas.h and
macros.h which are part of the common library. Since the defaults.h
contains only defaults values, it seems ok to keep it seperate from the
common library having only macros and function calls.

Signed-off-by: David Goulet <dgoulet@efficios.com>
27 files changed:
src/bin/lttng-consumerd/lttng-consumerd.c
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng-sessiond/ust-consumer.c
src/bin/lttng/command.h
src/common/Makefile.am
src/common/common.h [new file with mode: 0644]
src/common/compat/compat-epoll.c
src/common/compat/compat-poll.c
src/common/compat/poll.h
src/common/consumer.c
src/common/defaults.h [new file with mode: 0644]
src/common/hashtable/hashtable.c
src/common/kernel-consumer/kernel-consumer.c
src/common/lttng-share.h [deleted file]
src/common/macros.h [new file with mode: 0644]
src/common/sessiond-comm/sessiond-comm.c
src/common/sessiond-comm/sessiond-comm.h
src/common/ust-consumer/ust-consumer.c
src/lib/lttng-ctl/lttng-ctl.c
tests/test_kernel_data_trace.c
tests/test_ust_data_trace.c

index 8cb264ab1bd74b413a4b0a32b50cf80bfdbb5343..b501be8730ca8b4d22a997fbb10001d394aaf906 100644 (file)
@@ -45,6 +45,7 @@
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/kernel-consumer/kernel-consumer.h>
 #include <common/ust-consumer/ust-consumer.h>
+#include <common/defaults.h>
 
 #include "lttng-consumerd.h"
 
@@ -253,15 +254,15 @@ int main(int argc, char **argv)
                switch (opt_type) {
                case LTTNG_CONSUMER_KERNEL:
                        snprintf(command_sock_path, PATH_MAX, KCONSUMERD_CMD_SOCK_PATH,
-                                       LTTNG_RUNDIR);
+                                       DEFAULT_LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER64_UST:
                        snprintf(command_sock_path, PATH_MAX,
-                                       USTCONSUMERD64_CMD_SOCK_PATH, LTTNG_RUNDIR);
+                                       USTCONSUMERD64_CMD_SOCK_PATH, DEFAULT_LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER32_UST:
                        snprintf(command_sock_path, PATH_MAX,
-                                       USTCONSUMERD32_CMD_SOCK_PATH, LTTNG_RUNDIR);
+                                       USTCONSUMERD32_CMD_SOCK_PATH, DEFAULT_LTTNG_RUNDIR);
                        break;
                default:
                        WARN("Unknown consumerd type");
@@ -284,15 +285,15 @@ int main(int argc, char **argv)
                switch (opt_type) {
                case LTTNG_CONSUMER_KERNEL:
                        snprintf(error_sock_path, PATH_MAX, KCONSUMERD_ERR_SOCK_PATH,
-                                       LTTNG_RUNDIR);
+                                       DEFAULT_LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER64_UST:
                        snprintf(error_sock_path, PATH_MAX,
-                                       USTCONSUMERD64_ERR_SOCK_PATH, LTTNG_RUNDIR);
+                                       USTCONSUMERD64_ERR_SOCK_PATH, DEFAULT_LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER32_UST:
                        snprintf(error_sock_path, PATH_MAX,
-                                       USTCONSUMERD32_ERR_SOCK_PATH, LTTNG_RUNDIR);
+                                       USTCONSUMERD32_ERR_SOCK_PATH, DEFAULT_LTTNG_RUNDIR);
                        break;
                default:
                        WARN("Unknown consumerd type");
index df411b2283e3fa2d1e853a2c61ef80bca6ba03d6..d7fdbaec634d439b02de77a87c4054709256d1ff 100644 (file)
@@ -21,7 +21,8 @@
 
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
+#include <common/common.h>
+#include <common/defaults.h>
 
 #include "channel.h"
 #include "kernel.h"
index 6264521dee126d7585d1cb721f9ee13227d12457..2ebd5acbdd79dec5f7441362ccf89bd925c74c95 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <common/kernel-ctl/kernel-ctl.h>
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
+#include <common/common.h>
 
 #include "kernel.h"
 
index 521c78868118b409b4c122a80fb837cc267bbde8..8b512f01d8dcda417c41c0c11dcb3aaca7ca1d5f 100644 (file)
@@ -42,7 +42,8 @@
 #include <common/lttngerr.h>
 #include <common/kernel-consumer/kernel-consumer.h>
 #include <common/ust-consumer/ust-consumer.h>
-#include <common/runas.h>
+#include <common/common.h>
+#include <common/defaults.h>
 #include <common/compat/poll.h>
 
 #include "lttng-sessiond.h"
@@ -4278,7 +4279,7 @@ int main(int argc, char **argv)
        is_root = !getuid();
 
        if (is_root) {
-               rundir = strdup(LTTNG_RUNDIR);
+               rundir = strdup(DEFAULT_LTTNG_RUNDIR);
 
                /* Create global run dir with root access */
                ret = create_lttng_rundir(rundir);
@@ -4325,7 +4326,7 @@ int main(int argc, char **argv)
                 * Create rundir from home path. This will create something like
                 * $HOME/.lttng
                 */
-               ret = asprintf(&rundir, LTTNG_HOME_RUNDIR, home_path);
+               ret = asprintf(&rundir, DEFAULT_LTTNG_HOME_RUNDIR, home_path);
                if (ret < 0) {
                        ret = -ENOMEM;
                        goto error;
index 68edeb9ee06c46fbf0500020bc64bc658645c1b0..ba2cefaaeff64f8e4ae53150b794e5d43f085561 100644 (file)
@@ -26,9 +26,8 @@
 #include <urcu.h>
 
 #include <common/sessiond-comm/sessiond-comm.h>
-#include <common/runas.h>
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
+#include <common/common.h>
 
 #include "session.h"
 
index d1225c07c4f286f3b15c392dff0ed63133783bd1..79e4a2f4e28b7e64a1f83fa242cf4677a570a7c4 100644 (file)
@@ -23,7 +23,8 @@
 #include <unistd.h>
 
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
+#include <common/common.h>
+#include <common/defaults.h>
 
 #include "trace-kernel.h"
 
index a947dada5b8972b574d304e5504009718a7dcdaa..ed6658d7f8a6389e2e4f74e7d2a876c26db16ee0 100644 (file)
@@ -22,7 +22,8 @@
 #include <unistd.h>
 
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
+#include <common/common.h>
+#include <common/defaults.h>
 
 #include "trace-ust.h"
 
index 057f675e43239d88ed68e5a7d9abb0f1bc704fde..bd91b3c39decb8102b8c1b856fcc505ef0519cb9 100644 (file)
@@ -28,8 +28,7 @@
 #include <urcu/compiler.h>
 
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
-#include <common/runas.h>
+#include <common/common.h>
 
 #include "ust-app.h"
 #include "ust-consumer.h"
index c0d5069e7e4a1310abbbf9df4e86353fff4a6e70..63381cea4df702a4bf998702fdbead9429fd8275 100644 (file)
@@ -23,7 +23,8 @@
 #include <unistd.h>
 
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
+#include <common/common.h>
+#include <common/defaults.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/consumer.h>
 
index d7670f26df1c296b34e14e71748ad77a012c4646..9caa7b4034333fc6fd70e41fe17fbfa071e594cf 100644 (file)
@@ -21,7 +21,8 @@
 
 #include <lttng/lttng.h>
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
+#include <common/common.h>
+#include <common/defaults.h>
 
 #include "conf.h"
 #include "utils.h"
index 6b11d50843cf351d56f17b52668c5338e80a3e99..ade89de867914de7e5fcc0a596559161464ff5ac 100644 (file)
@@ -4,11 +4,11 @@ SUBDIRS = hashtable kernel-ctl sessiond-comm kernel-consumer ust-consumer
 
 AM_CFLAGS = -fno-strict-aliasing
 
-noinst_HEADERS = lttng-share.h lttngerr.h lttng-kernel.h
+noinst_HEADERS = lttngerr.h lttng-kernel.h defaults.h macros.h
 
 noinst_LTLIBRARIES = libcommon.la
 
-libcommon_la_SOURCES = runas.c runas.h
+libcommon_la_SOURCES = runas.c runas.h common.h
 
 # Consumer library
 noinst_LTLIBRARIES += libconsumer.la
diff --git a/src/common/common.h b/src/common/common.h
new file mode 100644 (file)
index 0000000..952a10a
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; only version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef _COMMON_H
+#define _COMMON_H
+
+#include "lttngerr.h"
+#include "macros.h"
+#include "runas.h"
+
+#endif /* _COMMON_H */
index 5e969ee01115896f1286297966d22d94f216efb1..460bc3b373b4ffb1c7d4f00f381ca49cac1c6890 100644 (file)
@@ -24,6 +24,7 @@
 #include <config.h>
 
 #include <common/lttngerr.h>
+#include <common/defaults.h>
 
 #include "poll.h"
 
@@ -195,9 +196,9 @@ void compat_epoll_set_max_size(void)
        int ret, fd;
        char buf[64];
 
-       poll_max_size = LTTNG_POLL_DEFAULT_SIZE;
+       poll_max_size = DEFAULT_POLL_SIZE;
 
-       fd = open(LTTNG_EPOLL_PROC_PATH, O_RDONLY);
+       fd = open(COMPAT_EPOLL_PROC_PATH, O_RDONLY);
        if (fd < 0) {
                return;
        }
@@ -211,7 +212,7 @@ void compat_epoll_set_max_size(void)
        poll_max_size = atoi(buf);
        if (poll_max_size <= 0) {
                /* Extra precaution */
-               poll_max_size = LTTNG_POLL_DEFAULT_SIZE;
+               poll_max_size = DEFAULT_POLL_SIZE;
        }
 
        DBG("epoll set max size is %d", poll_max_size);
index 50ef37472dc0a94db9eec258f21ce632f7d615d3..7b15c737e6a0333ce5044ce2402d62d35aa1f643 100644 (file)
@@ -20,6 +20,7 @@
 #include <sys/time.h>
 
 #include <lttngerr.h>
+#include <common/defaults.h>
 
 #include "poll.h"
 
@@ -177,7 +178,7 @@ void compat_poll_set_max_size(void)
        struct rlimit lim;
 
        /* Default value */
-       poll_max_size = LTTNG_POLL_DEFAULT_SIZE;
+       poll_max_size = DEFAULT_POLL_SIZE;
 
        ret = getrlimit(RLIMIT_NOFILE, &lim);
        if (ret < 0) {
@@ -188,7 +189,7 @@ void compat_poll_set_max_size(void)
        poll_max_size = lim.rlim_cur;
        if (poll_max_size <= 0) {
                /* Extra precaution */
-               poll_max_size = LTTNG_POLL_DEFAULT_SIZE;
+               poll_max_size = DEFAULT_POLL_SIZE;
        }
 
        DBG("poll set max size set to %u", poll_max_size);
index a7766400d95adcc5a4b8ed9fb5bb4ce7d0bd21b3..6dca76d81827324f3767efc90bd06948a7b22fba 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-#include <common/lttng-share.h>
-
-/*
- * Value taken from the hard limit allowed by the kernel when using setrlimit
- * with RLIMIT_NOFILE on an Intel i7 CPU and Linux 3.0.3.
- */
-#define LTTNG_POLL_DEFAULT_SIZE 65535
+#include <common/common.h>
 
 /*
  * Maximum number of fd we can monitor.
@@ -58,7 +52,7 @@ static inline void __lttng_poll_free(void *events)
 #include <sys/epoll.h>
 
 /* See man epoll(7) for this define path */
-#define LTTNG_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
+#define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
 
 enum {
        /* Polling variables compatibility for epoll */
index 9e7256568c5027fea5b49b1002ca84c6ac28fe07..cba9e64063fb0c2a948867b3a15335ec7d44c418 100644 (file)
@@ -29,8 +29,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <common/common.h>
 #include <common/lttngerr.h>
-#include <common/lttng-share.h>
 #include <common/kernel-ctl/kernel-ctl.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/kernel-consumer/kernel-consumer.h>
diff --git a/src/common/defaults.h b/src/common/defaults.h
new file mode 100644 (file)
index 0000000..6be44c7
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; only version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef _DEFAULTS_H
+#define _DEFAULTS_H
+
+/* Default size of a hash table */
+#define DEFAULT_HT_SIZE                 4
+
+/* Default lttng run directory */
+#define DEFAULT_LTTNG_RUNDIR                "/var/run/lttng"
+#define DEFAULT_LTTNG_HOME_RUNDIR           "%s/.lttng"
+
+/* Default unix socket path */
+#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK     DEFAULT_LTTNG_RUNDIR "/client-lttng-sessiond"
+#define DEFAULT_GLOBAL_APPS_UNIX_SOCK       DEFAULT_LTTNG_RUNDIR "/apps-lttng-sessiond"
+#define DEFAULT_HOME_APPS_UNIX_SOCK         DEFAULT_LTTNG_HOME_RUNDIR "/apps-lttng-sessiond"
+#define DEFAULT_HOME_CLIENT_UNIX_SOCK       DEFAULT_LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
+
+/*
+ * Value taken from the hard limit allowed by the kernel when using setrlimit
+ * with RLIMIT_NOFILE on an Intel i7 CPU and Linux 3.0.3.
+ */
+#define DEFAULT_POLL_SIZE 65535
+
+/* Default channel attributes */
+#define DEFAULT_CHANNEL_NAME            "channel0"
+#define DEFAULT_CHANNEL_OVERWRITE       0       /* usec */
+/* DEFAULT_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
+#define DEFAULT_CHANNEL_SUBBUF_SIZE     4096    /* bytes */
+/* DEFAULT_CHANNEL_SUBBUF_NUM must always be a power of 2 */
+#define DEFAULT_CHANNEL_SUBBUF_NUM      8
+#define DEFAULT_CHANNEL_SWITCH_TIMER    0       /* usec */
+#define DEFAULT_CHANNEL_READ_TIMER             200     /* usec */
+#define DEFAULT_CHANNEL_OUTPUT          LTTNG_EVENT_MMAP
+
+#define DEFAULT_METADATA_SUBBUF_SIZE    4096
+#define DEFAULT_METADATA_SUBBUF_NUM     2
+
+/* Kernel has different defaults */
+
+/* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
+#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE  262144    /* bytes */
+/* DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2 */
+#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM   4
+/* See lttng-kernel.h enum lttng_kernel_output for channel output */
+#define DEFAULT_KERNEL_CHANNEL_OUTPUT       LTTNG_EVENT_SPLICE
+
+/* User space defaults */
+
+/* Must be a power of 2 */
+#define DEFAULT_UST_CHANNEL_SUBBUF_SIZE     4096    /* bytes */
+/* Must be a power of 2 */
+#define DEFAULT_UST_CHANNEL_SUBBUF_NUM      4
+/* See lttng-ust.h enum lttng_ust_output */
+#define DEFAULT_UST_CHANNEL_OUTPUT          LTTNG_EVENT_MMAP
+
+/*
+ * Default timeout value for the sem_timedwait() call. Blocking forever is not
+ * wanted so a timeout is used to control the data flow and not freeze the
+ * session daemon.
+ */
+#define DEFAULT_SEM_WAIT_TIMEOUT            30    /* in seconds */
+
+#endif /* _DEFAULTS_H */
index 4f64778df2d31244e319ac81f422fc5ee444339d..2080107005739f5d4cb61c5f9761a14d7b375998 100644 (file)
@@ -21,8 +21,8 @@
 #include <urcu.h>
 #include <urcu/compiler.h>
 
-#include <common/lttng-share.h>
-#include <common/lttngerr.h>
+#include <common/common.h>
+#include <common/defaults.h>
 
 #include "hashtable.h"
 #include "utils.h"
index 87436371fd693dc7b94004eddfe5e576a1618fa1..3489ab6ed866970eec6915701ffef029d27d6c36 100644 (file)
@@ -29,9 +29,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <common/common.h>
 #include <common/kernel-ctl/kernel-ctl.h>
-#include <common/lttngerr.h>
-#include <common/runas.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 
 #include "kernel-consumer.h"
diff --git a/src/common/lttng-share.h b/src/common/lttng-share.h
deleted file mode 100644 (file)
index e859ead..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
- *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; only version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef _LTTNG_SHARE_H
-#define _LTTNG_SHARE_H
-
-#include <stdlib.h>
-
-/* Default size of a hash table */
-#define DEFAULT_HT_SIZE                 4
-
-/* Default channel attributes */
-#define DEFAULT_CHANNEL_NAME            "channel0"
-#define DEFAULT_CHANNEL_OVERWRITE       0       /* usec */
-/* DEFAULT_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
-#define DEFAULT_CHANNEL_SUBBUF_SIZE     4096    /* bytes */
-/* DEFAULT_CHANNEL_SUBBUF_NUM must always be a power of 2 */
-#define DEFAULT_CHANNEL_SUBBUF_NUM      8
-#define DEFAULT_CHANNEL_SWITCH_TIMER    0       /* usec */
-#define DEFAULT_CHANNEL_READ_TIMER             200     /* usec */
-#define DEFAULT_CHANNEL_OUTPUT          LTTNG_EVENT_MMAP
-
-#define DEFAULT_METADATA_SUBBUF_SIZE    4096
-#define DEFAULT_METADATA_SUBBUF_NUM     2
-
-/* Kernel has different defaults */
-
-/* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
-#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE  262144    /* bytes */
-/* DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2 */
-#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM   4
-/* See lttng-kernel.h enum lttng_kernel_output for channel output */
-#define DEFAULT_KERNEL_CHANNEL_OUTPUT       LTTNG_EVENT_SPLICE
-
-/* User space defaults */
-
-/* Must be a power of 2 */
-#define DEFAULT_UST_CHANNEL_SUBBUF_SIZE     4096    /* bytes */
-/* Must be a power of 2 */
-#define DEFAULT_UST_CHANNEL_SUBBUF_NUM      4
-/* See lttng-ust.h enum lttng_ust_output */
-#define DEFAULT_UST_CHANNEL_OUTPUT          LTTNG_EVENT_MMAP
-
-/*
- * Default timeout value for the sem_timedwait() call. Blocking forever is not
- * wanted so a timeout is used to control the data flow and not freeze the
- * session daemon.
- */
-#define DEFAULT_SEM_WAIT_TIMEOUT            30    /* in seconds */
-
-/*
- * Takes a pointer x and transform it so we can use it to access members
- * without a function call. Here an example:
- *
- *    #define GET_SIZE(x) LTTNG_REF(x)->size
- *
- *    struct { int size; } s;
- *
- *    printf("size : %d\n", GET_SIZE(&s));
- *
- * For this example we can't use something like this for compatibility purpose
- * since this will fail:
- *
- *    #define GET_SIZE(x) x->size;
- *
- * This is mostly use for the compatibility layer of lttng-tools. See
- * poll/epoll for a good example. Since x can be on the stack or allocated
- * memory using malloc(), we must use generic accessors for compat in order to
- * *not* use a function to access members and not the variable name.
- */
-#define LTTNG_REF(x) ((typeof(*x) *)(x))
-
-/*
- * Memory allocation zeroed
- */
-#define zmalloc(x) calloc(1, x)
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(array)   (sizeof(array) / (sizeof((array)[0])))
-#endif
-
-
-#endif /* _LTTNG_SHARE_H */
diff --git a/src/common/macros.h b/src/common/macros.h
new file mode 100644 (file)
index 0000000..3c72285
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; only version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef _MACROS_H
+#define _MACROS_H
+
+#include <stdlib.h>
+
+/*
+ * Takes a pointer x and transform it so we can use it to access members
+ * without a function call. Here an example:
+ *
+ *    #define GET_SIZE(x) LTTNG_REF(x)->size
+ *
+ *    struct { int size; } s;
+ *
+ *    printf("size : %d\n", GET_SIZE(&s));
+ *
+ * For this example we can't use something like this for compatibility purpose
+ * since this will fail:
+ *
+ *    #define GET_SIZE(x) x->size;
+ *
+ * This is mostly use for the compatibility layer of lttng-tools. See
+ * poll/epoll for a good example. Since x can be on the stack or allocated
+ * memory using malloc(), we must use generic accessors for compat in order to
+ * *not* use a function to access members and not the variable name.
+ */
+#define LTTNG_REF(x) ((typeof(*x) *)(x))
+
+/*
+ * Memory allocation zeroed
+ */
+#define zmalloc(x) calloc(1, x)
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(array)   (sizeof(array) / (sizeof((array)[0])))
+#endif
+
+#endif /* _MACROS_H */
index 59b76aae1c125827792d781f2b0362567f70e63b..4171b79f2ea2a9e44e09f11ee32c2cd8db3d2fd5 100644 (file)
@@ -28,6 +28,8 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include <common/defaults.h>
+
 #include "sessiond-comm.h"
 
 /*
index 48cf933216c431ece31185b7fc55bb4ee5816f8b..10748bbfa29b5495dfc09ddca6538290a804b4e9 100644 (file)
@@ -1,48 +1,41 @@
-#ifndef _LTTNG_SESSIOND_COMM_H
-#define _LTTNG_SESSIOND_COMM_H
-
 /*
  * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
  *                      Julien Desfossez <julien.desfossez@polymtl.ca>
  *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; only version 2
- * of the License.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; only version 2 of the License.
  * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
  * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
 /*
- * This header is meant for liblttng and libust internal use ONLY.
- * These declarations should NOT be considered stable API.
+ * This header is meant for liblttng and libust internal use ONLY. These
+ * declarations should NOT be considered stable API.
  */
 
+#ifndef _LTTNG_SESSIOND_COMM_H
+#define _LTTNG_SESSIOND_COMM_H
+
 #define _GNU_SOURCE
 #include <limits.h>
 #include <lttng/lttng.h>
 #include <sys/socket.h>
 
-#define LTTNG_RUNDIR                        "/var/run/lttng"
-#define LTTNG_HOME_RUNDIR                   "%s/.lttng"
-
-/* Default unix socket path */
-#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK     LTTNG_RUNDIR "/client-lttng-sessiond"
-#define DEFAULT_GLOBAL_APPS_UNIX_SOCK       LTTNG_RUNDIR "/apps-lttng-sessiond"
-#define DEFAULT_HOME_APPS_UNIX_SOCK         LTTNG_HOME_RUNDIR "/apps-lttng-sessiond"
-#define DEFAULT_HOME_CLIENT_UNIX_SOCK       LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
-
 /* Queue size of listen(2) */
 #define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
 
+/* Maximum number of FDs that can be sent over a Unix socket */
+#define LTTCOMM_MAX_SEND_FDS           4
+
 /*
  * Get the error code index from 0 since LTTCOMM_OK start at 1000
  */
@@ -284,7 +277,6 @@ extern int lttcomm_accept_unix_sock(int sock);
 extern int lttcomm_listen_unix_sock(int sock);
 extern int lttcomm_close_unix_sock(int sock);
 
-#define LTTCOMM_MAX_SEND_FDS   4
 /* Send a message accompanied by fd(s) over a unix socket. */
 extern ssize_t lttcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd);
 /* Recv a message accompanied by fd(s) from a unix socket */
index 16c09af8a14befab07fc824999282f375c607a0e..5f5e9582574011577297bf36123a64958a752793 100644 (file)
@@ -30,8 +30,7 @@
 #include <unistd.h>
 #include <lttng/ust-ctl.h>
 
-#include <common/lttngerr.h>
-#include <common/runas.h>
+#include <common/common.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 
 #include "ust-consumer.h"
index 2125c600ac3ba0244e949e6251f2a9c0a48899f8..838afedba2a712297f73687b44e446a17fec4537 100644 (file)
@@ -29,8 +29,9 @@
 #include <unistd.h>
 
 #include <common/sessiond-comm/sessiond-comm.h>
-#include <common/lttng-share.h>
 #include <common/lttngerr.h>
+#include <common/common.h>
+#include <common/defaults.h>
 #include <lttng/lttng.h>
 
 /* Socket to session daemon for communication */
index c079e2c664e63c1dcf0676f7b2e2261dfa2a1f5d..30d79a4eb44ccb0bc840d2b656679b02f7e6c2c5 100644 (file)
@@ -26,7 +26,7 @@
 #include <time.h>
 
 #include <bin/lttng-sessiond/trace-kernel.h>
-#include <common/lttng-share.h>
+#include <common/defaults.h>
 
 #include "utils.h"
 
index e4d42b40ab3b148a78a66d9352436979fbfd870f..78a31215f77b1dd14bbb871a71b7a5bd9a83334e 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <lttng/lttng.h>
 #include <bin/lttng-sessiond/lttng-ust-abi.h>
-#include <common/lttng-share.h>
+#include <common/defaults.h>
 #include <bin/lttng-sessiond/trace-ust.h>
 
 #include "utils.h"
This page took 0.038948 seconds and 4 git commands to generate.