mirror of git://git.musl-libc.org/musl
add sched_getcpu
This is a GNU extension, but a fairly minor one, for a system call that otherwise has no libc wrapper.
This commit is contained in:
parent
29b1357537
commit
98d335735d
|
@ -76,6 +76,7 @@ void free(void *);
|
||||||
|
|
||||||
typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t;
|
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_cpucount(size_t, const cpu_set_t *);
|
||||||
|
int sched_getcpu(void);
|
||||||
int sched_getaffinity(pid_t, size_t, cpu_set_t *);
|
int sched_getaffinity(pid_t, size_t, cpu_set_t *);
|
||||||
int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
|
int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <sched.h>
|
||||||
|
#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);
|
||||||
|
}
|
Loading…
Reference in New Issue