-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
std: move os/darwin.zig and related to c/darwin.zig #14921
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
Conversation
Move to c/darwin.zig as they really are libSystem/libc imports/wrappers. As an added bonus, get rid of the nasty `usingnamespace`s which are now unneeded. Finally, add `os.ptrace` but currently only implemented on darwin.
4ca57d7
to
52c15e4
Compare
Hey, just a note in case it would change your definition for os.ptrace - On Linux, it seems the fourth argument to ptrace is a pointer-sized type, as it can be used as an address or a bitmask (my attempt was here: #14839) |
I'll let @andrewrk decide how to go about doing this. This PR doesn't conflict with his addition of |
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.
I like the idea of moving "must link to c" to a dir with name c. However, mixing error abstractions with mere bindings feels inconsistent to os/windows.zig, which only has error abstractions and data.
If we go that route of mixing bindings + error abstractions, then I would favor keeping the error abstraction next to the binding or file reference to the binding unless we abstract over multiple OSes.
Any thoughts? I'm also asking to have a clue how I should (re)structure my PR #14726.
@@ -3085,3 +3094,471 @@ pub const PT_DENY_ATTACH = 31; | |||
pub const caddr_t = ?[*]u8; | |||
|
|||
pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: caddr_t, data: c_int) c_int; | |||
|
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.
Would be nice to add an indication that "error abstracted functions", so that "mere bindings" are separated from "error abstractions". Maybe something like the following for each section
// ======= Bindings =======
// ======= Error abstractions =======
?
Or keep things next to another.
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.
I am not sure I follow. Why would we want any wrapper for ptrace
here and not directly in os.zig
?
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.
I am happy with adding separating comments but I think it's somewhat premature - I don't even yet know how to structure this file, and currently it's a bit of a mess. The reason I created this PR was revert an erroneous decision by me of introducing os/darwin.zig
which seems backwards as everything on macOS is done via libSystem
anyhow. Also, this way we avoid unnecessary and pointless usingnamespace
s.
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 would we want any wrapper for ptrace here and not directly in os.zig?
Since the function name is identical (+ we have no posix.zig yet to distinguish unifiable and non-unifiable posix semantics), definitely yes. If the function name is not identical or it would offer semantics not available on other OSes, then this would sound less good.
I don't even yet know how to structure this file, and currently it's a bit of a mess
Ah, kk. (This is resolved)
I think Windows is a little special as there are many layers the user can opt into: use |
Andrew has merged his parallel builds branch adding more goodies including raw ptrace syscall wrapper on Linux, so here's my plan. I will merge this as-is, and then while adding HCS PoC for macOS, I will try to add a draft |
Move to c/darwin.zig as they really are libSystem/libc imports/wrappers.
As an added bonus, get rid of the nasty
usingnamespace
s which are now unneeded.Finally, add
os.ptrace
but currently only implemented on darwin.