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
diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h index 95c2320..f2bdcf6 100644 --- a/libc/include/android/legacy_signal_inlines.h +++ b/libc/include/android/legacy_signal_inlines.h
@@ -89,7 +89,7 @@ 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 @@ 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 @@ 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 e1a155f..699e257 100644 --- a/libc/include/bits/signal_types.h +++ b/libc/include/bits/signal_types.h
@@ -61,7 +61,7 @@ #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__)