public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/syscall-refactor] Add inline_syscall and internal_syscall
@ 2020-06-29 21:44 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2020-06-29 21:44 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=24cecdb3a70a9f45824000fd4f208135212b7134

commit 24cecdb3a70a9f45824000fd4f208135212b7134
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu May 21 14:17:15 2020 -0300

    Add inline_syscall and internal_syscall

Diff:
---
 sysdeps/unix/sysdep.h            | 50 ++++++++++++++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/sysdep.h | 12 ++++++++++
 2 files changed, 62 insertions(+)

diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h
index 3c687a717a..76e68e7e25 100644
--- a/sysdeps/unix/sysdep.h
+++ b/sysdeps/unix/sysdep.h
@@ -118,6 +118,56 @@
     sc_ret;								     \
   })
 
+
+#ifndef __ASSEMBLER__
+# ifndef ARGIFY
+#  define ARGIFY(__x) ((__syscall_arg_t) (__x))
+typedef long int __syscall_arg_t;
+# endif
+#endif
+
+#define __internal_syscall_0(name) 					\
+  __internal_syscall0 (name)
+#define __internal_syscall_1(name, a1) 					\
+  __internal_syscall1 (name, ARGIFY (a1))
+#define __internal_syscall_2(name, a1, a2) 				\
+  __internal_syscall2 (name, ARGIFY (a1), ARGIFY (a2))
+#define __internal_syscall_3(name, a1, a2, a3) 				\
+  __internal_syscall3 (name, ARGIFY (a1), ARGIFY (a2), ARGIFY (a3))
+#define __internal_syscall_4(name, a1, a2, a3, a4) 			\
+  __internal_syscall4 (name, ARGIFY (a1), ARGIFY (a2), ARGIFY (a3),	\
+		       ARGIFY (a4))
+#define __internal_syscall_5(name, a1, a2, a3, a4, a5) 			\
+  __internal_syscall5 (name, ARGIFY (a1), ARGIFY (a2), ARGIFY (a3),	\
+		       ARGIFY (a4), ARGIFY (a5))
+#define __internal_syscall_6(name, a1, a2, a3, a4, a5, a6) 		\
+  __internal_syscall6 (name, ARGIFY (a1), ARGIFY (a2), ARGIFY (a3),	\
+		       ARGIFY (a4), ARGIFY (a5), ARGIFY (a6))
+#define __internal_syscall_7(name, a1, a2, a3, a4, a5, a6, a7) 		\
+  __internal_syscall7 (name, ARGIFY (a1), ARGIFY (a2), ARGIFY (a3),	\
+		       ARGIFY (a4), ARGIFY (a5), ARGIFY (a6), ARGIFY (a7))
+
+#define internal_syscall(...)						\
+  __INTERNAL_SYSCALL_DISP(__internal_syscall_,__VA_ARGS__)
+
+#define inline_syscall(...)						\
+  __syscall_ret (internal_syscall (__VA_ARGS__))
+
+#define internal_syscall_cancel(...) 					\
+  ({									\
+    long int __sc_ret;							\
+    int __sc_cancel_oldtype = -1;					\
+    if (! SINGLE_THREAD_P)						\
+      __sc_cancel_oldtype = LIBC_CANCEL_ASYNC ();			\
+    __sc_ret = internal_syscall (__VA_ARGS__);				\
+    if (__sc_cancel_oldtype != -1)					\
+      LIBC_CANCEL_RESET (__sc_cancel_oldtype);				\
+    __sc_ret;								\
+  })
+
+#define inline_syscall_cancel(...)					\
+  __syscall_ret (internal_syscall_cancel(__VA_ARGS__))
+
 /* Machine-dependent sysdep.h files are expected to define the macro
    PSEUDO (function_name, syscall_name) to emit assembly code to define the
    C-callable function FUNCTION_NAME to do system call SYSCALL_NAME.
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index 71ecc19cd5..f3104c8ef3 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -59,6 +59,18 @@
     -1l;					\
   })
 
+#ifndef __ASSEMBLER__
+static inline long __syscall_ret (unsigned long int val)
+{
+  if (__glibc_unlikely (val > -4096UL))
+    {
+       __set_errno (-val);
+       return -1;
+    }
+  return val;
+}
+#endif
+
 /* Provide a dummy argument that can be used to force register
    alignment for register pairs if required by the syscall ABI.  */
 #ifdef __ASSUME_ALIGNED_REGISTER_PAIRS


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-29 21:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 21:44 [glibc/azanella/syscall-refactor] Add inline_syscall and internal_syscall Adhemerval Zanella

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 read-only IMAP folder(s) and NNTP newsgroup(s).