X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=libringbuffer%2Fsmp.h;h=b04401e1d9a94f2d36e35d394e83035ba0eb2fd2;hb=071dec4386ff4c89d8b0f92ab1a8dbf079abd50c;hp=3d138a9a890ce69afede6b5975a334556823be39;hpb=a6352fd40a2090fd883a6c369144bf405c9e9ec4;p=lttng-ust.git diff --git a/libringbuffer/smp.h b/libringbuffer/smp.h index 3d138a9a..b04401e1 100644 --- a/libringbuffer/smp.h +++ b/libringbuffer/smp.h @@ -1,15 +1,14 @@ -#ifndef _LIBRINGBUFFER_SMP_H -#define _LIBRINGBUFFER_SMP_H - /* - * libringbuffer/smp.h + * SPDX-License-Identifier: LGPL-2.1-only * - * Copyright 2011 (c) - Mathieu Desnoyers - * - * Dual LGPL v2.1/GPL v2 license. + * Copyright (C) 2011-2012 Mathieu Desnoyers */ -#include +#ifndef _LIBRINGBUFFER_SMP_H +#define _LIBRINGBUFFER_SMP_H + +#include "ust-helper.h" +#include "getcpu.h" /* * 4kB of per-cpu data available. Enough to hold the control structures, @@ -17,7 +16,9 @@ */ #define PER_CPU_MEM_SIZE 4096 +LTTNG_HIDDEN extern int __num_possible_cpus; +LTTNG_HIDDEN extern void _get_num_possible_cpus(void); static inline @@ -28,45 +29,6 @@ int num_possible_cpus(void) 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 (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)++)