[libc-commits] [PATCH] D134919: [libc] add syscall function

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Sep 30 15:46:03 PDT 2022


michaelrj added inline comments.


================
Comment at: libc/include/llvm-libc-macros/linux/unistd-macros.h:22
+// ignored.
+#define syscall(...) __llvm_libc_syscall(__VA_ARGS__, 1, 2, 3, 4, 5, 6)
+
----------------
sivachandra wrote:
> sivachandra wrote:
> > For better type checking, we should do something like this:
> > 
> > ```
> > #define __syscall_helper(sysno, arg1, arg2, arg3, arg4, arg5, arg6, ...) \
> >     __llvm_libc_syscall((long)(sysno), (long)(arg1), (long)(arg2), (long)(arg3), \
> >                         (long)(arg4), (long)(arg5), (long)(arg6))
> > #define syscall(...) __syscall_helper(__VA_ARGS__, 1, 2, 3, 4, 5, 6, 7)
> > ```
> If you don't add a 7th argument below on line 25, will the macro on line 22 work when invoked like this: `syscall(SYS_getpid)`?
As far as I can tell it's fine in C++20, but possibly not in other versions (which is why my tests were passing), so I've added the 7th argument back as 0, to make it clearer that 1 matches to arg1, and so on.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134919/new/

https://reviews.llvm.org/D134919



More information about the libc-commits mailing list