diff options
Diffstat (limited to 'string/memrchr.c')
-rw-r--r-- | string/memrchr.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/string/memrchr.c b/string/memrchr.c index 0c8fd84901..b9b0c9e802 100644 --- a/string/memrchr.c +++ b/string/memrchr.c @@ -1,5 +1,5 @@ /* memrchr -- find the last occurrence of a byte in a memory block - 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 @@ -61,10 +61,7 @@ __memrchr #else MEMRCHR #endif - (s, c_in, n) - const __ptr_t s; - int c_in; - size_t n; + (const __ptr_t s, int c_in, size_t n) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -96,15 +93,8 @@ MEMRCHR 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); |