__max1 > __max2 ? __max1: __max2; })
-/* MUTEXES */
-
-#include <pthread.h>
-
-#define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER;
-#define DECLARE_MUTEX(m) extern pthread_mutex_t (m);
-
/* MALLOCATION */
#include <stdlib.h>
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
#endif
-#ifndef UST_VALGRIND
-
-/*
- * If getcpu(2) is not implemented in the Kernel use CPU 0 as fallback.
- */
-static __inline__ int ust_get_cpu(void)
-{
- int cpu = sched_getcpu();
-
- if (caa_likely(cpu >= 0))
- return cpu;
- return 0;
-}
-
-#else /* #else #ifndef UST_VALGRIND */
-
-/*
- * Valgrind does not support the sched_getcpu() vsyscall.
- * It causes it to detect a segfault in the program and stop it.
- * So if we want to check libust with valgrind, we have to refrain
- * from using this call. TODO: it would probably be better to return
- * other values too, to better test it.
- */
-static __inline__ int ust_get_cpu(void)
-{
- return 0;
-}
-
-#endif /* #else #ifndef UST_VALGRIND */
-
#endif /* UST_CORE_H */
* control and probe registration. All operations within this file are
* called by the communication thread, under ust_lock protection.
*/
-static DEFINE_MUTEX(sessions_mutex);
+static pthread_mutex_t sessions_mutex = PTHREAD_MUTEX_INITIALIZER;
void ust_lock(void)
{
noinst_LTLIBRARIES = libringbuffer.la
libringbuffer_la_SOURCES = \
- smp.h smp.c \
+ smp.h smp.c getcpu.h \
shm.c shm.h shm_types.h shm_internal.h \
ring_buffer_backend.c \
ring_buffer_frontend.c \
int cpu, nesting;
rcu_read_lock();
- cpu = ust_get_cpu();
+ cpu = lttng_ust_get_cpu();
nesting = ++lib_ring_buffer_nesting; /* TLS */
cmm_barrier();
--- /dev/null
+#ifndef _LTTNG_GETCPU_H
+#define _LTTNG_GETCPU_H
+
+/*
+ * Copyright (c) 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define _GNU_SOURCE
+#include <urcu/compiler.h>
+#include <sched.h>
+
+#ifdef UST_VALGRIND
+
+/*
+ * Fallback on cpu 0 if liblttng-ust is build with Valgrind support.
+ * get_cpu() returns the current CPU number. It may change due to
+ * migration, so it is only statistically accurate.
+ */
+static inline
+int lttng_ust_get_cpu(void)
+{
+ return 0;
+}
+
+#else
+
+/*
+ * If getcpu is not implemented in the kernel, use cpu 0 as fallback.
+ */
+static inline
+int lttng_ust_get_cpu(void)
+{
+ int cpu;
+
+ cpu = sched_getcpu();
+ if (caa_unlikely(cpu < 0))
+ return 0;
+ return cpu;
+}
+
+#endif
+
+#endif /* _LTTNG_GETCPU_H */
*/
#include <lttng/core.h>
+#include "getcpu.h"
/*
* 4kB of per-cpu data available. Enough to hold the control structures,
return __num_possible_cpus;
}
-/*
- * get_cpu() returns the current CPU number. It may change due to
- * migration, so it is only statistically accurate.
- */
-#ifndef UST_VALGRIND
-static inline
-int get_cpu(void)
-{
- int cpu;
-
- cpu = sched_getcpu();
- if (caa_likely(cpu >= 0))
- return cpu;
- /*
- * If getcpu(2) is not implemented in the Kernel use CPU 0 as fallback.
- */
- return 0;
-}
-
-#else /* #else #ifndef UST_VALGRIND */
-static inline
-int get_cpu(void)
-{
- /*
- * Valgrind does not support the sched_getcpu() vsyscall.
- * It causes it to detect a segfault in the program and stop it.
- * So if we want to check libust with valgrind, we have to refrain
- * from using this call. TODO: it would probably be better to return
- * other values too, to better test it.
- */
- return 0;
-}
-#endif /* #else #ifndef UST_VALGRIND */
-
-static inline
-void put_cpu(void)
-{
-}
-
#define for_each_possible_cpu(cpu) \
for ((cpu) = 0; (cpu) < num_possible_cpus(); (cpu)++)