Skip to content

Commit

Permalink
modify asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
abxh committed Apr 15, 2024
1 parent 42a692c commit 5dc014e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/nextpow2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

size_t nextpow2(size_t x) {
assert(x != 0);
#if defined(UINT64_MAX) && UINTPTR_MAX == UINT32_MAX
assert(x <= 1073741824);
#endif
#if defined(UINT64_MAX) && UINTPTR_MAX == UINT64_MAX
assert(x <= 4611686018427387904);
#endif

#ifdef __GNUC__
#if __GNUC__ > 3 || (__GNUC__ == 3 && (__GNUC_MINOR__ > 4 || __GNUC_MINOR__ == 4)) // Test for GCC >= 3.4.0
Expand All @@ -23,7 +29,7 @@ size_t nextpow2(size_t x) {
#endif
#endif

#if UINTPTR_MAX == UINT32_MAX || UINTPTR_MAX == UINT64_MAX
#if defined(UINT32_MAX) && (UINTPTR_MAX == UINT32_MAX || UINTPTR_MAX == UINT64_MAX)
x--;
x |= x >> 1;
x |= x >> 2;
Expand Down

0 comments on commit 5dc014e

Please sign in to comment.