zig icon indicating copy to clipboard operation
zig copied to clipboard

std.os: fix alignment of Sigaction.handler_fn

Open ryanschneider opened this issue 3 years ago • 4 comments

This fix (proposed independently by @Vexu here (https://github.com/ziglang/zig/issues/13216#issuecomment-1282297305) and @marler8997 here (https://github.com/marler8997/ziglibc/pull/3#issuecomment-1294881409) allows one to pass os.SIG.IGN or other non-pointer aligned values for the handler_fn on word-aligned architectures like aarch64.

The PR is two separate commits simply because this is my first PR to zig and I wanted to make sure that the CI picks up the failing case first and will be fixed w/ the 2nd commit, IMO the PR can be squashed before merging.

I added the align(1) to all the lib/std/c implementations, even the ones like dragonfly that only (currently) target x86 for consistency but am happy to remove those changes if preferred.

Fixes #13216.

ryanschneider avatar Nov 03 '22 00:11 ryanschneider

Hmm just realized that the existing test calls w/ RESETHAND so my test additions don't fully test that IGN works as expected (but do confirm that the alignment issues are fixed), I'll improve the test a bit more.

ryanschneider avatar Nov 03 '22 15:11 ryanschneider

Ok I namespaced the handler_called_count and made sure the test fully tests the IGN case. PT(another)L.

ryanschneider avatar Nov 03 '22 15:11 ryanschneider

ci.ziglang fails in debug mode with

+ echo Looking for non-conforming code formatting...
+ stage3/bin/zig fmt --check .. --exclude ../test/cases/ --exclude ../build-debug --exclude ../build-release --exclude /workspace/zig-cache-local-debug --exclude /workspace/zig-cache-global-debug
Looking for non-conforming code formatting...
../lib/std/os/test.zig

Is there maybe some unformatted code?

matu3ba avatar Nov 04 '22 07:11 matu3ba

Oops ya I thought I had my editor setup to run zig fmt but must not have it configured fully correctly, it didn't catch some of the empty lines I added having spaces on them, repushed just now will check the CI results when done.

ryanschneider avatar Nov 04 '22 15:11 ryanschneider