summaryrefslogtreecommitdiff
path: root/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S')
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S19
1 files changed, 18 insertions, 1 deletions
diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
index 8ec7d3fcd..246c95504 100644
--- a/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
+++ b/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
@@ -20,6 +20,7 @@
#include <tls.h>
#define _ERRNO_H 1
#include <bits/errno.h>
+#include <kernel-features.h>
/* For the calculation see asm/vsyscall.h. */
#define VSYSCALL_ADDR_vgetcpu 0xffffffffff600800
@@ -38,10 +39,26 @@ ENTRY (sched_getcpu)
#ifdef SHARED
movq __vdso_getcpu(%rip), %rax
PTR_DEMANGLE (%rax)
+ callq *%rax
#else
+# ifdef __NR_getcpu
+ movl $__NR_getcpu, %eax
+ syscall
+# ifndef __ASSUME_GETCPU_SYSCALL
+ cmpq $-ENOSYS, %rax
+ jne 1f
+# endif
+# endif
+# ifndef __ASSUME_GETCPU_SYSCALL
movq $VSYSCALL_ADDR_vgetcpu, %rax
-#endif
callq *%rax
+1:
+# else
+# ifndef __NR_getcpu
+# error "cannot happen"
+# endif
+# endif
+#endif
cmpq $-4095, %rax
jae SYSCALL_ERROR_LABEL