From 5542236837c5c41435f8282ec92799f480c36f18 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 21 Jul 2015 22:50:29 -0700 Subject: Port the 0x7efe...feff pattern to GCC 6. See Steve Ellcey's bug report in: https://sourceware.org/ml/libc-alpha/2015-07/msg00673.html * string/memrchr.c (MEMRCHR): * string/rawmemchr.c (RAWMEMCHR): * string/strchr.c (strchr): * string/strchrnul.c (STRCHRNUL): Rewrite code to avoid issues with signed shift overflow. --- string/strchrnul.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'string/strchrnul.c') diff --git a/string/strchrnul.c b/string/strchrnul.c index 2678f1de0a..daf0b3f659 100644 --- a/string/strchrnul.c +++ b/string/strchrnul.c @@ -66,13 +66,8 @@ STRCHRNUL (s, c_in) The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ - switch (sizeof (longword)) - { - case 4: magic_bits = 0x7efefeffL; break; - case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break; - default: - abort (); - } + magic_bits = -1; + magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1; /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); -- cgit 1.4.1