X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=include%2Fust%2Fcore.h;h=b9f5b9793887a27cb433444f26f8399f1ef60ca9;hb=9f3fdbc68877e1f12b6cedb15ef76d9af9b48bac;hp=d1fdb2dfdb2c7faa9eb6805a37b6f99bace22a22;hpb=4fbf9cd1ede72e98638a5f81ecdce11416b4afea;p=lttng-ust.git diff --git a/include/ust/core.h b/include/ust/core.h index d1fdb2df..b9f5b979 100644 --- a/include/ust/core.h +++ b/include/ust/core.h @@ -138,4 +138,35 @@ static __inline__ int get_count_order(unsigned int count) #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) #endif +#ifndef UST_VALGRIND + +static __inline__ int ust_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 ust_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 */ + #endif /* UST_CORE_H */