aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--sysdeps/alpha/memchr.S8
-rw-r--r--sysdeps/generic/bp-checks.h134
-rw-r--r--sysdeps/generic/memchr.c4
-rw-r--r--sysdeps/i386/memchr.S6
-rw-r--r--sysdeps/ia64/memchr.S6
-rw-r--r--sysdeps/m68k/memchr.S8
-rw-r--r--sysdeps/sparc/sparc32/memchr.S8
-rw-r--r--sysdeps/sparc/sparc64/memchr.S8
-rw-r--r--sysdeps/vax/memchr.s5
10 files changed, 126 insertions, 77 deletions
diff --git a/ChangeLog b/ChangeLog
index 86ba936..4c79067 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,22 @@
* string/Makefile (o-objects.ob): Add variable to pull
unbounded versions of memcpy, memset and memchr into libc_b.
+ * sysdeps/generic/bp-checks.h: Use unbounded __memchr
+ rather than non-existent __ubp_memchr.
+ (CHECK_STRINGopt, CHECK_FCNTL, BOUNDED_N, BOUNDED_1): New macros.
+ (_CHECK_STRING, _CHECK_N): New macros.
+ (CHECK_STRING, CHECK_N, CHECK_Nopt): Rewrite in terms of _CHECK_*.
+ (CHECK_IOCTL): Move inside `#if !__ASSEMBLER__'.
+ * sysdeps/alpha/memchr.S: Change strong name to "__memchr".
+ Add weak alias "memchr".
+ * sysdeps/generic/memchr.c: Likewise.
+ * sysdeps/i386/memchr.S: Likewise.
+ * sysdeps/ia64/memchr.S: Likewise.
+ * sysdeps/m68k/memchr.S: Likewise.
+ * sysdeps/sparc/sparc32/memchr.S: Likewise.
+ * sysdeps/sparc/sparc64/memchr.S: Likewise.
+ * sysdeps/vax/memchr.s: Likewise.
+
2000-07-17 Bruno Haible <haible@clisp.cons.org>
* iconv/gconv_open.c (__gconv_open): Initialize the __data
diff --git a/sysdeps/alpha/memchr.S b/sysdeps/alpha/memchr.S
index 0ea4aa1..58899f3 100644
--- a/sysdeps/alpha/memchr.S
+++ b/sysdeps/alpha/memchr.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David Mosberger (davidm@cs.arizona.edu).
@@ -37,7 +37,7 @@ For correctness consider that:
.set noreorder
.set noat
-ENTRY(memchr)
+ENTRY(__memchr)
#ifdef PROF
ldgp gp, 0(pv)
lda AT, _mcount
@@ -167,4 +167,6 @@ $not_found:
mov zero, v0 #-e0 :
ret # .. e1 :
- END(memchr)
+ END(__memchr)
+
+weak_alias (__stpcpy, stpcpy)
diff --git a/sysdeps/generic/bp-checks.h b/sysdeps/generic/bp-checks.h
index ea71cf8..349bd81 100644
--- a/sysdeps/generic/bp-checks.h
+++ b/sysdeps/generic/bp-checks.h
@@ -21,83 +21,101 @@
Boston, MA 02111-1307, USA. */
#ifndef _bp_checks_h_
-# define _bp_checks_h_ 1
+#define _bp_checks_h_ 1
-# if !__ASSEMBLER__
+#if __BOUNDED_POINTERS__
-# if __BOUNDED_POINTERS__
-
-/* GKM FIXME: when gcc is ready, add real bounds checks */
-# define BOUNDS_VIOLATED (__builtin_trap (), 0)
-extern int __ubp_memchr (const char *__unbounded, int, unsigned);
+# define BOUNDS_VIOLATED (__builtin_trap (), 0)
+extern int __memchr (const char *__unbounded, int, unsigned);
/* Verify that pointer's value >= low. Return pointer value. */
-# define CHECK_BOUNDS_LOW(ARG) \
+# define CHECK_BOUNDS_LOW(ARG) \
(((__ptrvalue (ARG) < __ptrlow (ARG)) && BOUNDS_VIOLATED), \
__ptrvalue (ARG))
/* Verify that pointer's value < high. Return pointer value. */
-# define CHECK_BOUNDS_HIGH(ARG) \
+# define CHECK_BOUNDS_HIGH(ARG) \
(((__ptrvalue (ARG) > __ptrhigh (ARG)) && BOUNDS_VIOLATED), \
__ptrvalue (ARG))
-/* Check bounds of a pointer seated to a single object. */
-# define CHECK_1(ARG) CHECK_N ((ARG), 1)
+# define _CHECK_N(ARG, N, COND) \
+ (((COND) \
+ && (__ptrvalue (ARG) < __ptrlow (ARG) \
+ || __ptrvalue (ARG) + (N) > __ptrhigh (ARG)) \
+ && BOUNDS_VIOLATED), \
+ __ptrvalue (ARG))
-/* Same as CHECK_1, but tolerate ARG == NULL. */
-# define CHECK_1opt(ARG) CHECK_Nopt ((ARG), 1)
+# define _CHECK_STRING(ARG, COND) \
+ (((COND) \
+ && (__ptrvalue (ARG) < __ptrlow (ARG) \
+ || !__memchr (__ptrvalue (ARG), '\0', \
+ (__ptrhigh (ARG) - __ptrvalue (ARG)))) \
+ && BOUNDS_VIOLATED), \
+ __ptrvalue (ARG))
/* Check bounds of a pointer seated to an array of N objects. */
-# define CHECK_N(ARG, N) \
- (((__ptrvalue (ARG) < __ptrlow (ARG) \
- || __ptrvalue (ARG) + (N) > __ptrhigh (ARG)) \
- && BOUNDS_VIOLATED), __ptrvalue (ARG))
-
+# define CHECK_N(ARG, N) _CHECK_N ((ARG), (N), 1)
/* Same as CHECK_N, but tolerate ARG == NULL. */
-# define CHECK_Nopt(ARG, N) \
- (((__ptrvalue (ARG) \
- && (__ptrvalue (ARG) < __ptrlow (ARG) \
- || __ptrvalue (ARG) + (N) > __ptrhigh (ARG))) \
- && BOUNDS_VIOLATED), __ptrvalue (ARG))
-
-/* Check for NUL-terminator within string's bounds. */
-# define CHECK_STRING(ARG) \
- (((__ptrvalue (ARG) < __ptrlow (ARG) \
- || !__ubp_memchr (__ptrvalue (ARG), '\0', \
- (__ptrhigh (ARG) - __ptrvalue (ARG)))) \
- && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
+# define CHECK_Nopt(ARG, N) _CHECK_N ((ARG), (N), __ptrvalue (ARG))
-# define CHECK_SIGSET(SET) CHECK_N ((SET), _NSIG / (8 * sizeof *(SET)))
-# define CHECK_SIGSETopt(SET) CHECK_Nopt ((SET), _NSIG / (8 * sizeof *(SET)))
+/* Check bounds of a pointer seated to a single object. */
+# define CHECK_1(ARG) CHECK_N ((ARG), 1)
+/* Same as CHECK_1, but tolerate ARG == NULL. */
+# define CHECK_1opt(ARG) CHECK_Nopt ((ARG), 1)
-# else /* !__BOUNDED_POINTERS__ */
+/* Check for NUL-terminator within string's bounds. */
+# define CHECK_STRING(ARG) _CHECK_STRING ((ARG), 1)
+/* Same as CHECK_STRING, but tolerate ARG == NULL. */
+# define CHECK_STRINGopt(ARG) _CHECK_STRING ((ARG), __ptrvalue (ARG))
+
+/* Check bounds of signal syscall args with type sigset_t. */
+# define CHECK_SIGSET(SET) CHECK_N ((SET), _NSIG / (8 * sizeof *(SET)))
+/* Same as CHECK_SIGSET, but tolerate SET == NULL. */
+# define CHECK_SIGSETopt(SET) CHECK_Nopt ((SET), _NSIG / (8 * sizeof *(SET)))
+
+# if defined (_IOC_SIZESHIFT) && defined (_IOC_SIZEBITS)
+/* Extract the size of the ioctl data and check its bounds. */
+# define CHECK_IOCTL(ARG, CMD) \
+ CHECK_N ((const char *) (ARG), \
+ (((CMD) >> _IOC_SIZESHIFT) & ((1 << _IOC_SIZEBITS) - 1)))
+# else
+/* We don't know the size of the ioctl data, so the best we can do
+ is check that the first byte is within bounds. */
+# define CHECK_IOCTL(ARG, CMD) CHECK_1 ((const char *) ARG)
+# endif
+
+/* Check bounds of `struct flock *' for the locking fcntl commands. */
+# define CHECK_FCNTL(ARG, CMD) \
+ (((CMD) == F_GETLK || (CMD) == F_SETLK || (CMD) == F_SETLKW) \
+ ? CHECK_1 ((struct flock *) ARG) : (unsigned long) (ARG))
+
+/* Return a bounded pointer with value PTR that satisfies CHECK_N (PTR, N). */
+# define BOUNDED_N(PTR, N) \
+ ({ __typeof (*(PTR)) *__bounded _p_; \
+ __ptrvalue _p_ = __ptrlow _p_ = __ptrvalue (PTR); \
+ __ptrhigh _p_ = __ptrvalue _p_ + (N); \
+ _p_; })
+
+#else /* !__BOUNDED_POINTERS__ */
/* Do nothing if not compiling with -fbounded-pointers. */
-# define BOUNDS_VIOLATED
-# define CHECK_BOUNDS_LOW(ARG) (ARG)
-# define CHECK_BOUNDS_HIGH(ARG) (ARG)
-# define CHECK_1(ARG) (ARG)
-# define CHECK_1opt(ARG) (ARG)
-# define CHECK_N(ARG, N) (ARG)
-# define CHECK_Nopt(ARG, N) (ARG)
-# define CHECK_STRING(ARG) (ARG)
-# define CHECK_SIGSET(SET) (SET)
-# define CHECK_SIGSETopt(SET) (SET)
-
-# endif /* !__BOUNDED_POINTERS__ */
-
-# if defined (_IOC_SIZESHIFT) && defined (_IOC_SIZEBITS)
-
-/* Extract the size of the ioctl parameter argument and check its bounds. */
-# define CHECK_IOCTL(ARG, CMD) \
- CHECK_N ((ARG), (((CMD) >> _IOC_SIZESHIFT) & ((1 << _IOC_SIZEBITS) - 1)))
-
-# else
-# define CHECK_IOCTL(ARG, CMD) __ptrvalue (ARG)
-# endif
-
-# endif /* !__ASSEMBLER__ */
+# define BOUNDS_VIOLATED
+# define CHECK_BOUNDS_LOW(ARG) (ARG)
+# define CHECK_BOUNDS_HIGH(ARG) (ARG)
+# define CHECK_1(ARG) (ARG)
+# define CHECK_1opt(ARG) (ARG)
+# define CHECK_N(ARG, N) (ARG)
+# define CHECK_Nopt(ARG, N) (ARG)
+# define CHECK_STRING(ARG) (ARG)
+# define CHECK_SIGSET(SET) (SET)
+# define CHECK_SIGSETopt(SET) (SET)
+# define CHECK_IOCTL(ARG, CMD) (ARG)
+# define CHECK_FCNTL(ARG, CMD) (ARG)
+# define BOUNDED_N(PTR, N) (PTR)
+
+#endif /* !__BOUNDED_POINTERS__ */
+
+#define BOUNDED_1(PTR) BOUNDED_N (PTR, 1)
#endif /* _bp_checks_h_ */
diff --git a/sysdeps/generic/memchr.c b/sysdeps/generic/memchr.c
index 60bd8c6..a616daa 100644
--- a/sysdeps/generic/memchr.c
+++ b/sysdeps/generic/memchr.c
@@ -50,13 +50,14 @@
#endif
#include <sys/types.h>
+#include <bp-sym.h>
#undef memchr
/* Search no more than N bytes of S for C. */
__ptr_t
-memchr (s, c_in, n)
+__memchr (s, c_in, n)
const __ptr_t s;
int c_in;
size_t n;
@@ -200,3 +201,4 @@ memchr (s, c_in, n)
return 0;
}
+weak_alias (__memrchr, BP_SYM (memrchr))
diff --git a/sysdeps/i386/memchr.S b/sysdeps/i386/memchr.S
index 9ff4126..098e413 100644
--- a/sysdeps/i386/memchr.S
+++ b/sysdeps/i386/memchr.S
@@ -42,7 +42,7 @@
#define LEN CHR+4
.text
-ENTRY (BP_SYM (memchr))
+ENTRY (BP_SYM (__memchr))
ENTER
/* Save callee-safe registers used in this function. */
@@ -325,4 +325,6 @@ L(pop): popl %edi /* pop saved registers */
LEAVE
RET_PTR
-END (BP_SYM (memchr))
+END (BP_SYM (__memchr))
+
+weak_alias (BP_SYM (__memchr), BP_SYM (memchr))
diff --git a/sysdeps/ia64/memchr.S b/sysdeps/ia64/memchr.S
index 600f5c7..40f2bd0 100644
--- a/sysdeps/ia64/memchr.S
+++ b/sysdeps/ia64/memchr.S
@@ -56,7 +56,7 @@
#define str in0
-ENTRY(memchr)
+ENTRY(__memchr)
alloc saved_pfs = ar.pfs, 3, 0, 29, 32
#include "softpipe.h"
.rotr value[MEMLAT+1], addr[MEMLAT+3], aux[2], poschr[2]
@@ -121,4 +121,6 @@ ENTRY(memchr)
mov ar.lc = saved_lc
br.ret.sptk.many b0
-END(memchr)
+END(__memchr)
+
+weak_alias (__memchr, memchr)
diff --git a/sysdeps/m68k/memchr.S b/sysdeps/m68k/memchr.S
index a1599f8..968c129 100644
--- a/sysdeps/m68k/memchr.S
+++ b/sysdeps/m68k/memchr.S
@@ -1,7 +1,7 @@
/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in the
first N bytes of STR.
For Motorola 68000.
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Schwab <schwab@gnu.org>.
@@ -24,7 +24,7 @@
#include "asm-syntax.h"
TEXT
-ENTRY(memchr)
+ENTRY(__memchr)
/* Save the callee-saved registers we use. */
moveml R(d2)-R(d4),MEM_PREDEC(sp)
@@ -223,6 +223,6 @@ L(L9:)
movel R(a0),R(d0)
moveml MEM_POSTINC(sp),R(d2)-R(d4)
rts
-END(strchr)
+END(__memchr)
-weak_alias (strchr, index)
+weak_alias (__memchr, memchr)
diff --git a/sysdeps/sparc/sparc32/memchr.S b/sysdeps/sparc/sparc32/memchr.S
index 270216e..b770af1 100644
--- a/sysdeps/sparc/sparc32/memchr.S
+++ b/sysdeps/sparc/sparc32/memchr.S
@@ -1,7 +1,7 @@
/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
than N.
For SPARC v7.
- Copyright (C) 1996,1999 Free Software Foundation, Inc.
+ Copyright (C) 1996,1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
David S. Miller <davem@caip.rutgers.edu>.
@@ -67,7 +67,7 @@
1: retl
sub %o0, 1, %o0
-ENTRY(memchr)
+ENTRY(__memchr)
andcc %o1, 0xff, %o1
sll %o1, 8, %g7
andcc %o0, 3, %g0
@@ -140,4 +140,6 @@ ENTRY(memchr)
sub %o0, 3, %o0
4: retl
sub %o0, 4, %o0
-END(memchr)
+END(__memchr)
+
+weak_alias (__memchr, memchr)
diff --git a/sysdeps/sparc/sparc64/memchr.S b/sysdeps/sparc/sparc64/memchr.S
index 1662f60..36446b6 100644
--- a/sysdeps/sparc/sparc64/memchr.S
+++ b/sysdeps/sparc/sparc64/memchr.S
@@ -1,7 +1,7 @@
/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
than N.
For SPARC v9.
- Copyright (C) 1998,1999 Free Software Foundation, Inc.
+ Copyright (C) 1998,1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
Jakub Jelinek <jj@ultra.linux.cz>.
@@ -57,7 +57,7 @@
.text
.align 32
-ENTRY(memchr)
+ENTRY(__memchr)
and %o1, 0xff, %o1 /* IEU0 Group */
#ifdef USE_BPR
brz,pn %o2, 12f /* CTI+IEU1 */
@@ -256,4 +256,6 @@ ENTRY(memchr)
23: retl /* CTI+IEU1 Group */
add %o0, -1, %o0 /* IEU0 */
-END(memchr)
+END(__memchr)
+
+weak_alias (__memchr, memchr)
diff --git a/sysdeps/vax/memchr.s b/sysdeps/vax/memchr.s
index 18120b0..22a8c2d 100644
--- a/sysdeps/vax/memchr.s
+++ b/sysdeps/vax/memchr.s
@@ -45,7 +45,7 @@
#include "DEFS.h"
-ENTRY(memchr, 0)
+ENTRY(__memchr, 0)
movq 4(ap),r1 # r1 = cp; r2 = c
movl 12(ap),r0 # r0 = n
movzwl $65535,r4 # handy constant
@@ -67,3 +67,6 @@ ENTRY(memchr, 0)
decw r0 # from 0 to 65535
subl2 r0,r4 # adjust n
brb 0b # and loop
+
+weak_alias (__memchr, memchr)
+ \ No newline at end of file