aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2022-03-23 18:07:26 -0700
committerPeter Collingbourne <pcc@google.com>2022-03-24 11:11:11 -0700
commit08b968b282756b44a4980a9417909c6710cdaafe (patch)
tree516d23eccdae7200fbaaa3eafb9e0e3e590af881
parentacd91c22e934732646d70e0390973a273bf6c0ec (diff)
downloadbionic-08b968b282756b44a4980a9417909c6710cdaafe.tar.gz
Avoid usage of LONG_BIT in signal headers.
Clang has its own limits.h which is ahead of ours on the inclusion path. This header uses include_next to include our header, but only in hosted mode. This means that in freestanding mode we don't get our limits.h macro definitions, including LONG_BIT. This ends up causing our signal.h to produce errors when included in freestanding mode on 32-bit platforms. Fix the errors by replacing usage of LONG_BIT with (8 * sizeof(long)) in the signal headers. Change-Id: I18ec7b6876d5f862beae09f0c011128eef97c869
-rw-r--r--libc/include/android/legacy_signal_inlines.h6
-rw-r--r--libc/include/bits/signal_types.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h
index 95c2320db..f2bdcf695 100644
--- a/libc/include/android/legacy_signal_inlines.h
+++ b/libc/include/android/legacy_signal_inlines.h
@@ -89,7 +89,7 @@ static __inline int sigismember(const sigset_t *set, int signum) {
errno = EINVAL;
return -1;
}
- return (int)((local_set[bit / LONG_BIT] >> (bit % LONG_BIT)) & 1);
+ return (int)((local_set[bit / (8 * sizeof(long))] >> (bit % (8 * sizeof(long)))) & 1);
}
static __inline int sigaddset(sigset_t *set, int signum) {
@@ -100,7 +100,7 @@ static __inline int sigaddset(sigset_t *set, int signum) {
errno = EINVAL;
return -1;
}
- local_set[bit / LONG_BIT] |= 1UL << (bit % LONG_BIT);
+ local_set[bit / (8 * sizeof(long))] |= 1UL << (bit % (8 * sizeof(long)));
return 0;
}
@@ -112,7 +112,7 @@ static __inline int sigdelset(sigset_t *set, int signum) {
errno = EINVAL;
return -1;
}
- local_set[bit / LONG_BIT] &= ~(1UL << (bit % LONG_BIT));
+ local_set[bit / (8 * sizeof(long))] &= ~(1UL << (bit % (8 * sizeof(long))));
return 0;
}
diff --git a/libc/include/bits/signal_types.h b/libc/include/bits/signal_types.h
index e1a155f5b..699e2572d 100644
--- a/libc/include/bits/signal_types.h
+++ b/libc/include/bits/signal_types.h
@@ -61,7 +61,7 @@ typedef __sighandler_t sighandler_t; /* glibc compatibility. */
#if defined(__LP64__)
typedef sigset_t sigset64_t;
#else
-typedef struct { unsigned long __bits[_KERNEL__NSIG/LONG_BIT]; } sigset64_t;
+typedef struct { unsigned long __bits[_KERNEL__NSIG/(8*sizeof(long))]; } sigset64_t;
#endif
#if defined(__LP64__)