summaryrefslogtreecommitdiff
path: root/string/strchr.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-10-09 19:21:56 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-10-09 19:21:56 +0200
commit525c181a5a9a95e24d2111b7792608151a40eb84 (patch)
tree8ba16eeb3fb7327e5c3c5bba9c5786d4bb6ccec1 /string/strchr.c
parent4dd9e35bfd35d3138bc44169baba098005bad51e (diff)
parent7bb5f8a836b916d6ebf7b6921b136e99cea2442d (diff)
Merge commit 'refs/top-bases/t/bigmem' into t/bigmem
Diffstat (limited to 'string/strchr.c')
-rw-r--r--string/strchr.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/string/strchr.c b/string/strchr.c
index 5f900750a3..25c2fe4771 100644
--- a/string/strchr.c
+++ b/string/strchr.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
@@ -25,9 +25,13 @@
#undef strchr
+#ifndef STRCHR
+# define STRCHR strchr
+#endif
+
/* Find the first occurrence of C in S. */
char *
-strchr (const char *s, int c_in)
+STRCHR (const char *s, int c_in)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
@@ -60,13 +64,8 @@ strchr (const char *s, int 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);
@@ -180,7 +179,7 @@ strchr (const char *s, int c_in)
}
#ifdef weak_alias
-#undef index
+# undef index
weak_alias (strchr, index)
#endif
libc_hidden_builtin_def (strchr)