From: Eric Blake Date: Mon, 21 Apr 2008 15:57:07 +0000 (-0600) Subject: Work around preprocessors that don't handle UINTMAX_MAX. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=218c1d232b2568450b4581f93d544e4d3af59c36;p=pspp Work around preprocessors that don't handle UINTMAX_MAX. * lib/memchr2.c (memchr2): Avoid embedded #if. Reported by Alain Guibert, fix suggested by Bruno Haible. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 9153749202..9266f7fe73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-04-21 Eric Blake + + Work around preprocessors that don't handle UINTMAX_MAX. + * lib/memchr2.c (memchr2): Avoid embedded #if. + Reported by Alain Guibert, fix suggested by Bruno Haible. + 2008-04-21 Simon Josefsson * doc/posix-functions/strftime.texi (strftime): Explain better @@ -120,7 +126,7 @@ Reported by Daniel Bergström . 2007-12-25 KJK::Hyperion - Bruno Haible + Bruno Haible * lib/localename.c (gl_locale_name_canonicalize) [WIN32_NATIVE]: New function. diff --git a/lib/memchr2.c b/lib/memchr2.c index d5b0a787a8..38533434d4 100644 --- a/lib/memchr2.c +++ b/lib/memchr2.c @@ -83,18 +83,19 @@ memchr2 (void const *s, int c1_in, int c2_in, size_t n) charmask2 = c2 | (c2 << 8); charmask1 |= charmask1 << 16; charmask2 |= charmask2 << 16; -#if 0xffffffffU < UINTMAX_MAX - magic_bits |= magic_bits << 32; - charmask1 |= charmask1 << 32; - charmask2 |= charmask2 << 32; - if (8 < sizeof longword1) - for (i = 64; i < sizeof longword1 * 8; i *= 2) - { - magic_bits |= magic_bits << i; - charmask1 |= charmask1 << i; - charmask2 |= charmask2 << i; - } -#endif + if (0xffffffffU < UINTMAX_MAX) + { + magic_bits |= magic_bits << 32; + charmask1 |= charmask1 << 32; + charmask2 |= charmask2 << 32; + if (8 < sizeof longword1) + for (i = 64; i < sizeof longword1 * 8; i *= 2) + { + magic_bits |= magic_bits << i; + charmask1 |= charmask1 << i; + charmask2 |= charmask2 << i; + } + } magic_bits = (UINTMAX_MAX >> 1) & (magic_bits | 1); /* Instead of the traditional loop which tests each character,