]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
linux: Introduce INTERNAL_VSYSCALL
authorEvan Green <evan@rivosinc.com>
Tue, 27 Feb 2024 22:56:38 +0000 (14:56 -0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Fri, 1 Mar 2024 15:14:56 +0000 (07:14 -0800)
Add an INTERNAL_VSYSCALL() macro that makes a vDSO call, falling back to
a regular syscall, but without setting errno. Instead, the return value
is plumbed straight out of the macro.

Signed-off-by: Evan Green <evan@rivosinc.com>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
sysdeps/unix/sysv/linux/sysdep-vdso.h

index 189319ad98da43be46bcf87d6bc0cacaff3be2b3..2f53ada6e57aaf94a8ab3263338ccfe1285f3855 100644 (file)
     sc_ret;                                                                  \
   })
 
+#define INTERNAL_VSYSCALL(name, nr, args...)                                 \
+  ({                                                                         \
+    long int sc_ret = -ENOSYS;                                               \
+                                                                             \
+    __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name);            \
+    if (vdsop != NULL)                                                       \
+       sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args);                  \
+    if (sc_ret == -ENOSYS)                                                   \
+       sc_ret = INTERNAL_SYSCALL_CALL (name, ##args);                        \
+    sc_ret;                                                                  \
+  })
+
 #endif /* SYSDEP_VDSO_LINUX_H  */