[sysprof] examples: only use sched_getcpu() on Linux



commit d25975cf89435ee394a7886aa738b388e1e36f5b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 3 17:29:14 2019 -0700

    examples: only use sched_getcpu() on Linux

 examples/app.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/examples/app.c b/examples/app.c
index e3bfb1e..acf6444 100644
--- a/examples/app.c
+++ b/examples/app.c
@@ -7,7 +7,10 @@
 
 #define _GNU_SOURCE
 
-#include <sched.h>
+#ifdef __linux__
+# include <sched.h>
+#endif
+
 #include <signal.h>
 #include <sysprof-capture.h>
 #include <unistd.h>
@@ -68,7 +71,11 @@ do_some_work (SysprofCaptureWriter *writer)
 
       sysprof_capture_writer_add_mark (writer,
                                        begin_time_nsec,            /* Begin time in nsec */
+#ifdef __linux__
                                        sched_getcpu (),            /* -1 to ignore */
+#else
+                                       -1,
+#endif
                                        getpid (),                  /* -1 to ignore */
                                        real_duration,              /* duration in nsec */
                                        "Example",                  /* Group name, 23 chars+\0 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]