diff options
Diffstat (limited to 'string/rawmemchr.c')
-rw-r--r-- | string/rawmemchr.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/string/rawmemchr.c b/string/rawmemchr.c index 05b22be24e..fa3176d6ac 100644 --- a/string/rawmemchr.c +++ b/string/rawmemchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -53,9 +53,7 @@ /* Find the first occurrence of C in S. */ __ptr_t -RAWMEMCHR (s, c_in) - const __ptr_t s; - int c_in; +RAWMEMCHR (const __ptr_t s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -86,15 +84,8 @@ RAWMEMCHR (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. */ - - if (sizeof (longword) != 4 && sizeof (longword) != 8) - abort (); - -#if LONG_MAX <= LONG_MAX_32_BITS - magic_bits = 0x7efefeff; -#else - magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff; -#endif + 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); |