From: Nathan Zadoks Date: Wed, 2 Mar 2016 16:26:26 +0000 (+0100) Subject: add sched_getcpu X-Git-Tag: v1.1.15~94 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=98d335735d64ee34a34cb9c08ea2cb51a076d2a1;p=oweals%2Fmusl.git add sched_getcpu This is a GNU extension, but a fairly minor one, for a system call that otherwise has no libc wrapper. --- diff --git a/include/sched.h b/include/sched.h index 3e34a72c..7e88f097 100644 --- a/include/sched.h +++ b/include/sched.h @@ -76,6 +76,7 @@ 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 *); +int sched_getcpu(void); 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 00000000..760e4d5b --- /dev/null +++ b/src/sched/sched_getcpu.c @@ -0,0 +1,13 @@ +#define _GNU_SOURCE +#include +#include "syscall.h" + +int sched_getcpu(void) +{ + int r; + unsigned cpu; + + r = __syscall(SYS_getcpu, &cpu, 0, 0); + if (!r) return cpu; + return __syscall_ret(r); +}