-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use correct types for syscalls #19559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the tests pass then LGTM.
IIRC there was a reason we did it this way when porting the musl syscall layer, but I can't remember exactly what that was.. so lets just go with this if the tests pass.
return g_pid; | ||
} | ||
|
||
weak int __syscall_getppid() { | ||
weak pid_t __syscall_getppid() { | ||
return g_ppid; | ||
} | ||
|
||
weak int __syscall_linkat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath, int flags) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also use pointer types here for oldpath/newpath? and elsewhere?
return g_ppid; | ||
} | ||
|
||
weak int __syscall_linkat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath, int flags) { | ||
return -EMLINK; // no hardlinks for us | ||
} | ||
|
||
weak int __syscall_getgroups32(int size, intptr_t list) { | ||
if (size < 1) { | ||
weak int __syscall_getgroups32(int count, intptr_t list) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should list be gid_t*
(avoiding the case below?)
if (internal_fstat(fd, &st)) | ||
return -1; | ||
return (uptr)st.st_size; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these new functions needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid the all the changes/additions to the sanitizers? This change seems a lot more risky once you add those in?
Also changing the socket syscalls to be varargs seems a little out of scope and perhaps separable.
int __syscall_chmod(intptr_t path, int mode); | ||
int __syscall_getpid(void); | ||
typedef unsigned socklen_t; | ||
typedef unsigned long nfds_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicating these definitions here seems a little sad.
Let me mark this as a draft, there are many more changes needed than expected. For example, doing this: -int __syscall_openat(int dirfd, intptr_t path, int flags, ...); // mode is optional
+int __syscall_openat(int dirfd, const char *path, int flags, ...); // mode is optional Will fail within the sanitizers (which uses the internal
emscripten/tools/system_libs.py Lines 1925 to 1928 in b182182
Details
The solution is to rework the sanitizers to avoid musl's syscall layer, similar to the NetBSD and macOS implementations. emscripten/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp Lines 165 to 167 in b182182
|
Yeah I think this is one reason things are the way they today.. to allow the SYSCALL stuff to work. Perhaps we could land the initial/smaller version of this change that doesn't cause some much churn? |
f7a239f
to
7b111a0
Compare
7b111a0
to
768961e
Compare
Split from: #13007.