diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-05-01 16:56:02 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-05-01 17:00:31 -0400 |
commit | 941bd884cc0221d051840ce6d21650339e711863 (patch) | |
tree | c1c372cb94e568319483373b0b9403995ed2e841 /src | |
parent | 375840c7d8e1f58a9bf40ced72fbe82635f49489 (diff) | |
download | musl-941bd884cc0221d051840ce6d21650339e711863.tar.gz musl-941bd884cc0221d051840ce6d21650339e711863.tar.xz musl-941bd884cc0221d051840ce6d21650339e711863.zip |
optimize sigisemptyset
the static const zero set ended up getting put in bss instead of rodata, wasting writable memory, and the call to memcmp was size-inefficient. generally for nonstandard extension functions we try to avoid poking at any internals directly, but the way the zero set was setup was arguably already doing so.
Diffstat (limited to 'src')
-rw-r--r-- | src/signal/sigisemptyset.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/signal/sigisemptyset.c b/src/signal/sigisemptyset.c index 312c66cf..68b86624 100644 --- a/src/signal/sigisemptyset.c +++ b/src/signal/sigisemptyset.c @@ -4,6 +4,7 @@ int sigisemptyset(const sigset_t *set) { - static const unsigned long zeroset[_NSIG/8/sizeof(long)]; - return !memcmp(set, &zeroset, _NSIG/8); + for (size_t i=0; i<_NSIG/8/sizeof *set->__bits; i++) + if (set->__bits[i]) return 0; + return 1; } |