summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-10-28 08:22:11 +0000
committerJim Meyering <jim@meyering.net>2000-10-28 08:22:11 +0000
commitc3c259f0bef8cfd8d47606475348f088f7b0e120 (patch)
treeeab4631ce45068de65b9f99c8973f88227e71802
parentf6ea3a0653cef313e2caf3f69a1e9ab2397b4d42 (diff)
downloadgnulib-c3c259f0bef8cfd8d47606475348f088f7b0e120.tar.gz
Update from libc.
Adjust for portability: [HAVE_STDLIB_H]: Include stdlib.h. [HAVE_BP_SYM_H || _LIBC]: Guard inclusion of bp-sym.h. Undef __memchr, too. [!weak_alias]: Define __memchr to memchr.
-rw-r--r--lib/memchr.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/memchr.c b/lib/memchr.c
index 8c3b59c1bb..4b28e481f8 100644
--- a/lib/memchr.c
+++ b/lib/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991,93,96,97,99,2000 Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
with help from Dan Sahlin (dan@sics.se) and
commentary by Jim Blandy (jimb@ai.mit.edu);
@@ -34,11 +34,18 @@ USA. */
# define __ptr_t char *
#endif /* C++ or ANSI C. */
-#if defined (_LIBC)
+#if defined _LIBC
# include <string.h>
+# include <memcopy.h>
+#else
+# define reg_char char
+#endif
+
+#if HAVE_STDLIB_H || defined _LIBC
+# include <stdlib.h>
#endif
-#if defined (HAVE_LIMITS_H) || defined (_LIBC)
+#if HAVE_LIMITS_H || defined _LIBC
# include <limits.h>
#endif
@@ -49,21 +56,28 @@ USA. */
#endif
#include <sys/types.h>
+#if HAVE_BP_SYM_H || defined _LIBC
+# include <bp-sym.h>
+#else
+# define BP_SYM(sym) sym
+#endif
+#undef memchr
+#undef __memchr
/* Search no more than N bytes of S for C. */
-
__ptr_t
-memchr (s, c, n)
+__memchr (s, c_in, n)
const __ptr_t s;
- int c;
+ int c_in;
size_t n;
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
unsigned long int longword, magic_bits, charmask;
+ unsigned reg_char c;
- c = (unsigned char) c;
+ c = (unsigned char) c_in;
/* Handle the first few characters by reading one character at a time.
Do this until CHAR_PTR is aligned on a longword boundary. */
@@ -197,3 +211,6 @@ memchr (s, c, n)
return 0;
}
+#ifdef weak_alias
+weak_alias (__memchr, BP_SYM (memchr))
+#endif