Ring buffer: use shmp (shared-memory pointers) for per-channel shm structures
[lttng-ust.git] / libringbuffer / smp.c
diff --git a/libringbuffer/smp.c b/libringbuffer/smp.c
new file mode 100644 (file)
index 0000000..3f86ac8
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * libust/smp.c
+ *
+ * Copyright 2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <unistd.h>
+#include "ust/core.h"
+#include "usterr.h"
+#include <pthread.h>
+#include "smp.h"
+
+int __num_possible_cpus;
+
+void _get_num_possible_cpus(void)
+{
+       int result;
+
+       /* On Linux, when some processors are offline
+        * _SC_NPROCESSORS_CONF counts the offline
+        * processors, whereas _SC_NPROCESSORS_ONLN
+        * does not. If we used _SC_NPROCESSORS_ONLN,
+        * getcpu() could return a value greater than
+        * this sysconf, in which case the arrays
+        * indexed by processor would overflow.
+        */
+       result = sysconf(_SC_NPROCESSORS_CONF);
+       if (result == -1)
+               return;
+       __num_possible_cpus = result;
+}
This page took 0.023009 seconds and 4 git commands to generate.