-/* Copyright (C) 1991,93,96,97,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003 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);
# include <config.h>
#endif
-#undef __ptr_t
-#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
-# define __ptr_t void *
-#else /* Not C++ or ANSI C. */
-# define __ptr_t char *
-#endif /* C++ or ANSI C. */
+#include <string.h>
#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 HAVE_LIMITS_H || defined _LIBC
-# include <limits.h>
-#endif
+#include <limits.h>
+#include <stdlib.h>
#define LONG_MAX_32_BITS 2147483647
-#ifndef LONG_MAX
-# define LONG_MAX LONG_MAX_32_BITS
-#endif
-
#include <sys/types.h>
#if HAVE_BP_SYM_H || defined _LIBC
# include <bp-sym.h>
#undef __memchr
/* Search no more than N bytes of S for C. */
-__ptr_t
-__memchr (s, c_in, n)
- const __ptr_t s;
- int c_in;
- size_t n;
+void *
+__memchr (void const *s, int c_in, size_t n)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
& (sizeof (longword) - 1)) != 0;
--n, ++char_ptr)
if (*char_ptr == c)
- return (__ptr_t) char_ptr;
+ return (void *) char_ptr;
/* All these elucidatory comments refer to 4-byte longwords,
but the theory applies equally well to 8-byte longwords. */
const unsigned char *cp = (const unsigned char *) (longword_ptr - 1);
if (cp[0] == c)
- return (__ptr_t) cp;
+ return (void *) cp;
if (cp[1] == c)
- return (__ptr_t) &cp[1];
+ return (void *) &cp[1];
if (cp[2] == c)
- return (__ptr_t) &cp[2];
+ return (void *) &cp[2];
if (cp[3] == c)
- return (__ptr_t) &cp[3];
+ return (void *) &cp[3];
#if LONG_MAX > 2147483647
if (cp[4] == c)
- return (__ptr_t) &cp[4];
+ return (void *) &cp[4];
if (cp[5] == c)
- return (__ptr_t) &cp[5];
+ return (void *) &cp[5];
if (cp[6] == c)
- return (__ptr_t) &cp[6];
+ return (void *) &cp[6];
if (cp[7] == c)
- return (__ptr_t) &cp[7];
+ return (void *) &cp[7];
#endif
}
while (n-- > 0)
{
if (*char_ptr == c)
- return (__ptr_t) char_ptr;
+ return (void *) char_ptr;
else
++char_ptr;
}
-/* Copyright (C) 1991, 1993, 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1995, 1997, 1998, 2003 Free Software
+ Foundation, Inc.
+
Contributed by Torbjorn Granlund (tege@sics.se).
NOTE: The canonical source of this file is maintained with the GNU C Library.
# include "config.h"
#endif
-#undef __ptr_t
-#if defined __cplusplus || (defined __STDC__ && __STDC__)
-# define __ptr_t void *
-#else /* Not C++ or ANSI C. */
-# undef const
-# define const
-# define __ptr_t char *
-#endif /* C++ or ANSI C. */
-
-#ifndef __P
-# if defined __GNUC__ || (defined __STDC__ && __STDC__)
-# define __P(args) args
-# else
-# define __P(args) ()
-# endif /* GCC. */
-#endif /* Not __P. */
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#endif
+#include <string.h>
#undef memcmp
A and B are known to be different.
This is needed only on little-endian machines. */
-static int memcmp_bytes __P((op_t, op_t));
-
# ifdef __GNUC__
__inline
# endif
}
#endif
-static int memcmp_common_alignment __P((long, long, size_t));
-
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
memory operations on `op_t's. */
return 0;
}
-static int memcmp_not_common_alignment __P((long, long, size_t));
-
/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
`op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
operations on `op_t', but SRCP1 *should be unaligned*. */
extern int errno;
#endif
-#if HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
/* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according
to the LC_COLLATE locale. S1 and S2 do not overlap, and are not
-/* Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 2000, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
# include <config.h>
#endif
+#include <stddef.h>
+
/* Copy LEN bytes starting at SRCADDR to DESTADDR. Result undefined
if the source overlaps with the destination.
Return DESTADDR. */
-char *
-memcpy (char *destaddr, const char *srcaddr, int len)
+void *
+memcpy (void *destaddr, void const *srcaddr, size_t len)
{
char *dest = destaddr;
+ char const *src = srcaddr;
while (len-- > 0)
- *destaddr++ = *srcaddr++;
- return dest;
+ *dest++ = *src++;
+ return destaddr;
}
# include <config.h>
#endif
+#include <stddef.h>
+
void *
-memmove (dest, source, length)
- char *dest;
- const char *source;
- unsigned length;
+memmove (void *dest0, void const *source0, size_t length)
{
- char *d0 = dest;
+ char *dest = dest0;
+ char const *source = source0;
if (source < dest)
/* Moving from low mem to hi mem; start at end. */
for (source += length, dest += length; length; --length)
for (; length; --length)
*dest++ = *source++;
}
- return (void *) d0;
+ return dest0;
}
/* memrchr -- find the last occurrence of a byte in a memory block
- Copyright (C) 1991, 93, 96, 97, 99, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003 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);
#endif
#include <stdlib.h>
-
-#undef __ptr_t
-#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
-# define __ptr_t void *
-#else /* Not C++ or ANSI C. */
-# define __ptr_t char *
-#endif /* C++ or ANSI C. */
+#include <string.h>
#if defined (_LIBC)
-# include <string.h>
# include <memcopy.h>
#else
# define reg_char char
#endif
-#if defined (HAVE_LIMITS_H) || defined (_LIBC)
-# include <limits.h>
-#endif
+#include <limits.h>
#define LONG_MAX_32_BITS 2147483647
-#ifndef LONG_MAX
-# define LONG_MAX LONG_MAX_32_BITS
-#endif
-
#include <sys/types.h>
#undef __memrchr
#endif
/* Search no more than N bytes of S for C. */
-__ptr_t
-__memrchr (s, c_in, n)
- const __ptr_t s;
- int c_in;
- size_t n;
+void *
+__memrchr (void const *s, int c_in, size_t n)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
& (sizeof (longword) - 1)) != 0;
--n)
if (*--char_ptr == c)
- return (__ptr_t) char_ptr;
+ return (void *) char_ptr;
/* All these elucidatory comments refer to 4-byte longwords,
but the theory applies equally well to 8-byte longwords. */
#if LONG_MAX > 2147483647
if (cp[7] == c)
- return (__ptr_t) &cp[7];
+ return (void *) &cp[7];
if (cp[6] == c)
- return (__ptr_t) &cp[6];
+ return (void *) &cp[6];
if (cp[5] == c)
- return (__ptr_t) &cp[5];
+ return (void *) &cp[5];
if (cp[4] == c)
- return (__ptr_t) &cp[4];
+ return (void *) &cp[4];
#endif
if (cp[3] == c)
- return (__ptr_t) &cp[3];
+ return (void *) &cp[3];
if (cp[2] == c)
- return (__ptr_t) &cp[2];
+ return (void *) &cp[2];
if (cp[1] == c)
- return (__ptr_t) &cp[1];
+ return (void *) &cp[1];
if (cp[0] == c)
- return (__ptr_t) cp;
+ return (void *) cp;
}
n -= sizeof (longword);
while (n-- > 0)
{
if (*--char_ptr == c)
- return (__ptr_t) char_ptr;
+ return (void *) char_ptr;
}
return 0;
/* memset.c -- set an area of memory to a given value
- Copyright (C) 1991 Free Software Foundation, Inc.
+ Copyright (C) 1991, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-char *
-memset (char *str, int c, unsigned int len)
+#include <stddef.h>
+
+void *
+memset (void *str, int c, size_t len)
{
register char *st = str;
-# memchr.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memchr.m4 serial 2
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
# Prerequisites of lib/memchr.c.
AC_DEFUN([jm_PREREQ_MEMCHR], [
- AC_CHECK_HEADERS_ONCE(limits.h stdlib.h)
AC_CHECK_HEADERS(bp-sym.h)
])
-# memcmp.m4 serial 8
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memcmp.m4 serial 9
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
])
# Prerequisites of lib/memcmp.c.
-AC_DEFUN([gl_PREREQ_MEMCMP], [
- AC_CHECK_HEADERS_ONCE(string.h)
-])
+AC_DEFUN([gl_PREREQ_MEMCMP], [:])
-# memcoll.m4 serial 2
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memcoll.m4 serial 3
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
[
dnl Prerequisites of lib/memcoll.c.
AC_REQUIRE([AC_FUNC_MEMCMP])
- AC_CHECK_HEADERS_ONCE(string.h)
AC_FUNC_STRCOLL
])
-# memrchr.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memrchr.m4 serial 2
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
])
# Prerequisites of lib/memrchr.c.
-AC_DEFUN([gl_PREREQ_MEMRCHR], [
- AC_CHECK_HEADERS_ONCE(limits.h)
-])
+AC_DEFUN([gl_PREREQ_MEMRCHR], [:])