Add the syscall wrapper function and tests. It's implemented using a
macro to guarantee the minimum number of arguments.
Details
- Reviewers
sivachandra lntue - Commits
- rG1801c356f61f: [libc] add syscall function
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can we call it syscall_impl instead of internal_syscall ?
libc/include/llvm-libc-macros/linux/unistd-macros.h | ||
---|---|---|
22 | 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) | |
libc/src/unistd/linux/syscall.cpp | ||
19 | This need not be a vararg function - it can take exactly 7 arguments, the syscall number plus 6 other args. | |
libc/test/src/unistd/syscall_test.cpp | ||
28 | This is very misleading as there is no member named syscall in the namespace __llvm_libc. So, can you add a comment below line 22 explaining how the macro substitution helps in actually picking the namespace qualified __llvm_libc_syscall. |
libc/include/llvm-libc-macros/linux/unistd-macros.h | ||
---|---|---|
22 | 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)? |
minor fix
libc/include/llvm-libc-macros/linux/unistd-macros.h | ||
---|---|---|
22 | 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. |
For better type checking, we should do something like this: