This check is important for the case where getcpu(2) is not implemented by the Kernel. So, the CPU 0 is the fallback.
Signed-off-by: David Goulet <[email protected]> --- libust/tracer.h | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libust/tracer.h b/libust/tracer.h index 64996b2..dd524af 100644 --- a/libust/tracer.h +++ b/libust/tracer.h @@ -345,8 +345,14 @@ static __inline__ void ltt_write_trace_header(struct ust_trace *trace, static __inline__ int ust_get_cpu(void) { + int cpu = 0; #ifndef UST_VALGRIND - return sched_getcpu(); + if ((cpu = sched_getcpu()) < 0) { + /* If getcpu(2) is not implemented in the Kernel + * use CPU 0 as fallback. + */ + cpu = 0; + } #else /* Valgrind does not support the sched_getcpu() vsyscall. * It causes it to detect a segfault in the program and stop it. @@ -354,7 +360,7 @@ static __inline__ int ust_get_cpu(void) * from using this call. TODO: it would probably be better to return * other values too, to better test it. */ - return 0; + return cpu; #endif } -- 1.7.4 _______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
