mailing list of musl libc
 help / color / mirror / code / Atom feed
ed5e331c0ffdc8f953503731b402a1b419441569 blob 919 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
#define _GNU_SOURCE
#include <stdlib.h>
#include <errno.h>
#include <sched.h>
#include "syscall.h"
#include "atomic.h"

#ifdef VDSO_GETCPU_SYM

void *__vdsosym(const char *, const char *);

static void *volatile vdso_func;

typedef long (*getcpu_f)(unsigned *, unsigned *, void *);

long getcpu_init(unsigned *cpu, unsigned *node, void *unused)
{
  void *p = __vdsosym(VDSO_GETCPU_VER, VDSO_GETCPU_SYM);
  getcpu_f f = (getcpu_f)p;
  a_cas_p(&vdso_func, (void *)getcpu_init, p);
  return f ? f(cpu, node, unused) : -ENOSYS;
}

static void *volatile vdso_func = (void *)getcpu_init;

#endif

int sched_getcpu(void)
{
  int r;
  unsigned cpu;

#ifdef VDSO_CGT_SYM
  getcpu_f f = (getcpu_f)vdso_func;
  if (f) {
    r = f(&cpu, NULL, NULL);
    if (!r) return cpu;
    if (r != -ENOSYS) return __syscall_ret(r);
  }
#endif

  r = __syscall(SYS_getcpu, &cpu, NULL, NULL);
  if (!r) return cpu;
  return __syscall_ret(r);
}
debug log:

solving ed5e331 ...
found ed5e331 in https://inbox.vuxu.org/musl/1456839940-10330-1-git-send-email-nathan@nathan7.eu/

applying [1/1] https://inbox.vuxu.org/musl/1456839940-10330-1-git-send-email-nathan@nathan7.eu/
diff --git a/src/sched/sched_getcpu.c b/src/sched/sched_getcpu.c
new file mode 100644
index 0000000..ed5e331

Checking patch src/sched/sched_getcpu.c...
Applied patch src/sched/sched_getcpu.c cleanly.

index at:
100644 ed5e331c0ffdc8f953503731b402a1b419441569	src/sched/sched_getcpu.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).