Define _GNU_SOURCE for all implementation files rather than getcpu.h
[lttng-ust.git] / libringbuffer / smp.c
1 /*
2 * libringbuffer/smp.c
3 *
4 * Copyright 2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * Dual LGPL v2.1/GPL v2 license.
7 */
8
9 #define _GNU_SOURCE
10 #include <unistd.h>
11 #include "usterr.h"
12 #include <pthread.h>
13 #include "smp.h"
14
15 int __num_possible_cpus;
16
17 void _get_num_possible_cpus(void)
18 {
19 int result;
20
21 /* On Linux, when some processors are offline
22 * _SC_NPROCESSORS_CONF counts the offline
23 * processors, whereas _SC_NPROCESSORS_ONLN
24 * does not. If we used _SC_NPROCESSORS_ONLN,
25 * getcpu() could return a value greater than
26 * this sysconf, in which case the arrays
27 * indexed by processor would overflow.
28 */
29 result = sysconf(_SC_NPROCESSORS_CONF);
30 if (result == -1)
31 return;
32 __num_possible_cpus = result;
33 }
This page took 0.030866 seconds and 5 git commands to generate.