Skip to content

Conversation

@srijan-paul
Copy link
Contributor

@srijan-paul srijan-paul commented Sep 1, 2024

The backing integer for the MASK struct is a u32, but the bool fields sum up to a u13.
I've added 19 bits of padding.

Alternatively, we could add 3 bits of padding and make it a u16 backed packed struct?
EDIT: Looks using std.c.darwing.exception_mask_t would be a better idea here.
Is there a reason why the std library doesn't use C types in these places?

Reference: #21094

P.S: Should we consider having a test block for this just to see if it compiles? Something like:

test {
   std.testing.expectEqual(32, @bitSizeOf(MASK));
}

@srijan-paul srijan-paul changed the title fix the std.c.EXC.MASK field on darwin fix compile error on the std.c.EXC.MASK field on darwin Sep 1, 2024
@FnControlOption
Copy link
Contributor

Alternatively, we could add 3 bits of padding and make it a u16 backed packed struct?

I would use exception_mask_t instead (or whichever type has the same size as c_uint)

Reference: https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/exception_types.h#L207

@srijan-paul
Copy link
Contributor Author

or whichever type has the same size as c_uint

In that case, why not use c_uint directly?

@FnControlOption
Copy link
Contributor

exception_mask_t is already defined as c_uint in std.c.darwin, but packed structs in the standard library don’t use C types for some reason

@srijan-paul
Copy link
Contributor Author

Interesting. I wonder why that decision was taken.
I could change the u32 to exception_mask_t in this PR.

@alexrp alexrp merged commit d714cf3 into ziglang:master Jan 26, 2025
10 checks passed
alexrp added a commit that referenced this pull request Jan 27, 2025
Turns out this was already fixed in #21964.

I have no idea why GitHub showed an incorrect diff in #21273, or how applying the diff to master was even possible, but here we are.
andrewrk pushed a commit that referenced this pull request Jan 27, 2025
Turns out this was already fixed in #21964.

I have no idea why GitHub showed an incorrect diff in #21273, or how applying the diff to master was even possible, but here we are.
Fri3dNstuff pushed a commit to Fri3dNstuff/zig that referenced this pull request Jan 27, 2025
Fri3dNstuff pushed a commit to Fri3dNstuff/zig that referenced this pull request Jan 27, 2025
Turns out this was already fixed in ziglang#21964.

I have no idea why GitHub showed an incorrect diff in ziglang#21273, or how applying the diff to master was even possible, but here we are.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants