-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Turn errno into an enum #4233
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
Turn errno into an enum #4233
Conversation
104b62f
to
b20057d
Compare
@@ -817,8 +817,8 @@ pub const Loop = struct { | |||
@atomicStore(i32, &self.os_data.fs_queue_item, 1, AtomicOrder.SeqCst); | |||
const rc = os.linux.futex_wake(&self.os_data.fs_queue_item, os.linux.FUTEX_WAKE, 1); | |||
switch (os.linux.getErrno(rc)) { | |||
0 => {}, | |||
os.EINVAL => unreachable, | |||
@intToEnum(os.linux.Errno, 0) => {}, |
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.
it seems clear to me that there should be a tag value of Errno which represents "no error" and has value 0.
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 thought that.... and then thought that getErrno
returning an optional would work better: what do you think of that?
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 don't think that's the correct data layout. These ABIs have 0 as an in-bound value.
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.
Lacking that for now, #3806 could put 0
out of range, and hence make it so 0
is null
The problem: |
Fixes the assertion failure seen in ziglang#4233
@LemonBoy we need an extern enum because we want to have a duplicate value (e.g. alias EWOULDBLOCK to EAGAIN) |
Nobody said you cannot use an extern enum, you just have to use a correct type for the tag |
But we do want @enumToInt to produce a u12... |
We always want things we can't have... I think that matching the libcs by using a |
Fixes the assertion failure seen in #4233
@andrewrk what do you think?
|
5ab97ba
to
20657a1
Compare
20657a1
to
b197ec7
Compare
Is there some tangible benefit from having the errno tag |
Has already saved me a few times:
|
You need a
Then use an unsigned tag type. |
I was.
Then we match neither linux ABI or libcs. |
Alright, that's a possible footgun.
The "linux ABI" for the syscall error codes states that they are |
I'm not necessarily saying "no" to this, but this pull request is not mergeable as is and doesn't appear to be on the path to that anytime soon. |
I don't think either of these are desirable language changes. I don't like the idea of bending the language over backwards to accommodate errno. |
Currently compiler is dieing with a segfault when I test locally.