[gnome-builder] build: add checks for sched_getcpu() and use them
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] build: add checks for sched_getcpu() and use them
- Date: Mon, 23 Nov 2020 23:45:38 +0000 (UTC)
commit 2e506f0b597500bf44a8ebbe2653399bc8255f2a
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 23 14:35:06 2020 -0800
build: add checks for sched_getcpu() and use them
meson.build | 3 +++
src/main.c | 14 ++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 7a5c7fe6c..e1f7f0a57 100644
--- a/meson.build
+++ b/meson.build
@@ -279,6 +279,9 @@ check_functions = [
['HAVE_PTSNAME', 'ptsname'],
['HAVE_PTSNAME_R', 'ptsname_r'],
['HAVE_UNLOCKPT', 'unlockpt'],
+
+ # scheduling
+ ['HAVE_SCHED_GETCPU', 'sched_getcpu'],
]
foreach func: check_functions
config_h.set(func[0], cc.has_function(func[1]))
diff --git a/src/main.c b/src/main.c
index c68c86bf6..072acb6a1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,6 +49,16 @@
static SysprofCaptureWriter *trace_writer;
static G_LOCK_DEFINE (tracer);
+static inline int
+current_cpu (void)
+{
+#ifdef HAVE_SCHED_GETCPU
+ return sched_getcpu ();
+#else
+ return 0;
+#endif
+}
+
static void
trace_load (void)
{
@@ -76,7 +86,7 @@ trace_function (const gchar *func,
G_LOCK (tracer);
sysprof_capture_writer_add_mark (trace_writer,
begin_time_usec * 1000L,
- sched_getcpu (),
+ current_cpu (),
getpid (),
(end_time_usec - begin_time_usec) * 1000L,
"tracing",
@@ -96,7 +106,7 @@ trace_log (GLogLevelFlags log_level,
G_LOCK (tracer);
sysprof_capture_writer_add_log (trace_writer,
SYSPROF_CAPTURE_CURRENT_TIME,
- sched_getcpu (),
+ current_cpu (),
getpid (),
log_level,
domain,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]