|
|
Message-Id: <1456778974-8825-1-git-send-email-nathan@nathan7.eu>
Date: Mon, 29 Feb 2016 21:49:34 +0100
From: Nathan Zadoks <nathan@...han7.eu>
To: musl@...ts.openwall.com
Cc: Nathan Zadoks <nathan@...han7.eu>
Subject: [PATCH] add sched_getcpu
This is a GNU extension, but a fairly minor one, for a system call that
otherwise has no libc wrapper.
Adding it was discussed previously, without any objections:
http://www.openwall.com/lists/musl/2015/05/08/24
---
include/sched.h | 3 +++
src/sched/sched_getcpu.c | 11 +++++++++++
2 files changed, 14 insertions(+)
create mode 100644 src/sched/sched_getcpu.c
diff --git a/include/sched.h b/include/sched.h
index 3e34a72..17f5e06 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -76,6 +76,9 @@ void free(void *);
typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t;
int __sched_cpucount(size_t, const cpu_set_t *);
+#ifdef _GNU_SOURCE
+int sched_getcpu(void);
+#endif
int sched_getaffinity(pid_t, size_t, cpu_set_t *);
int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
diff --git a/src/sched/sched_getcpu.c b/src/sched/sched_getcpu.c
new file mode 100644
index 0000000..f34d84a
--- /dev/null
+++ b/src/sched/sched_getcpu.c
@@ -0,0 +1,11 @@
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <sched.h>
+#include "syscall.h"
+
+int sched_getcpu(void)
+{
+ int c, s;
+ s = __syscall(SYS_getcpu, &c, NULL, NULL);
+ return __syscall_ret((s == 0) ? c : s);
+}
--
2.7.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.