2002-05-24 Jeff Johnston <jjohnstn@redhat.com>

* libc/include/string.h: Add strnlen and strerror_r prototypes.
        * libc/string/Makefile.am: Add strnlen.c and strerror_r.c support.
        * libc/string/Makefile.in: Regenerated.
        * libc/string/strerror_r.c: New file.
        * libc/string/strnlen.c: New file.
        * libc/sys/linux/Makefile.am: Add rename.c.
        * libc/sys/linux/Makefile.in: Regenerated.
        * libc/sys/linux/rename.c: New file to override default rename.
This commit is contained in:
Jeff Johnston 2002-05-24 23:44:39 +00:00
parent 8b3e5e2d6e
commit d29587b478
9 changed files with 157 additions and 27 deletions

View File

@ -1,3 +1,14 @@
2002-05-24 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/string.h: Add strnlen and strerror_r prototypes.
* libc/string/Makefile.am: Add strnlen.c and strerror_r.c support.
* libc/string/Makefile.in: Regenerated.
* libc/string/strerror_r.c: New file.
* libc/string/strnlen.c: New file.
* libc/sys/linux/Makefile.am: Add rename.c.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/rename.c: New file to override default rename.
2002-05-24 Thomas Fitzsimmons <fitzsim@redhat.com>
* libc/sys/linux/sys/cdefs.h: Add __weak_reference macros.

View File

@ -61,9 +61,11 @@ char *_EXFUN(rindex,(const char *, int));
int _EXFUN(strcasecmp,(const char *, const char *));
char *_EXFUN(strdup,(const char *));
char *_EXFUN(_strdup_r,(struct _reent *, const char *));
char *_EXFUN(strerror_r,(int, char *, size_t));
size_t _EXFUN(strlcat,(char *, const char *, size_t));
size_t _EXFUN(strlcpy,(char *, const char *, size_t));
int _EXFUN(strncasecmp,(const char *, const char *, size_t));
size_t _EXFUN(strnlen,(const char *, size_t));
char *_EXFUN(strsep,(char **, const char *));
char *_EXFUN(strlwr,(char *));
char *_EXFUN(strupr,(char *));

View File

@ -23,6 +23,7 @@ LIB_SOURCES = \
strcpy.c \
strcspn.c \
strerror.c \
strerror_r.c \
strlcat.c \
strlcpy.c \
strlen.c \
@ -31,6 +32,7 @@ LIB_SOURCES = \
strncmp.c \
strncasecmp.c \
strncpy.c \
strnlen.c \
strpbrk.c \
strrchr.c \
strsep.c \
@ -62,8 +64,8 @@ bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
index.def rindex.def strcspn.def strpbrk.def swab.def \
memchr.def strcat.def strerror.def strrchr.def \
memcmp.def strchr.def strlen.def strspn.def \
memchr.def strcat.def strerror.def strerror_r.def strrchr.def \
memcmp.def strchr.def strlen.def strnlen.def strspn.def \
strcasecmp.def strncasecmp.def strlwr.def strupr.def
SUFFIXES = .def

View File

@ -121,6 +121,7 @@ LIB_SOURCES = \
strcpy.c \
strcspn.c \
strerror.c \
strerror_r.c \
strlcat.c \
strlcpy.c \
strlen.c \
@ -129,6 +130,7 @@ LIB_SOURCES = \
strncmp.c \
strncasecmp.c \
strncpy.c \
strnlen.c \
strpbrk.c \
strrchr.c \
strsep.c \
@ -156,8 +158,8 @@ bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
index.def rindex.def strcspn.def strpbrk.def swab.def \
memchr.def strcat.def strerror.def strrchr.def \
memcmp.def strchr.def strlen.def strspn.def \
memchr.def strcat.def strerror.def strerror_r.def strrchr.def \
memcmp.def strchr.def strlen.def strnlen.def strspn.def \
strcasecmp.def strncasecmp.def strlwr.def strupr.def
@ -180,11 +182,12 @@ lib_a_LIBADD =
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = bcmp.o bcopy.o bzero.o index.o \
@USE_LIBTOOL_FALSE@memchr.o memcmp.o memcpy.o memmove.o memset.o \
@USE_LIBTOOL_FALSE@rindex.o strcat.o strchr.o strcmp.o strcasecmp.o \
@USE_LIBTOOL_FALSE@strcoll.o strcpy.o strcspn.o strerror.o strlcat.o \
@USE_LIBTOOL_FALSE@strlcpy.o strlen.o strlwr.o strncat.o strncmp.o \
@USE_LIBTOOL_FALSE@strncasecmp.o strncpy.o strpbrk.o strrchr.o strsep.o \
@USE_LIBTOOL_FALSE@strspn.o strtok.o strtok_r.o strupr.o strxfrm.o \
@USE_LIBTOOL_FALSE@strstr.o swab.o u_strerr.o
@USE_LIBTOOL_FALSE@strcoll.o strcpy.o strcspn.o strerror.o strerror_r.o \
@USE_LIBTOOL_FALSE@strlcat.o strlcpy.o strlen.o strlwr.o strncat.o \
@USE_LIBTOOL_FALSE@strncmp.o strncasecmp.o strncpy.o strnlen.o \
@USE_LIBTOOL_FALSE@strpbrk.o strrchr.o strsep.o strspn.o strtok.o \
@USE_LIBTOOL_FALSE@strtok_r.o strupr.o strxfrm.o strstr.o swab.o \
@USE_LIBTOOL_FALSE@u_strerr.o
LTLIBRARIES = $(noinst_LTLIBRARIES)
libstring_la_LIBADD =
@ -192,11 +195,11 @@ libstring_la_LIBADD =
@USE_LIBTOOL_TRUE@index.lo memchr.lo memcmp.lo memcpy.lo memmove.lo \
@USE_LIBTOOL_TRUE@memset.lo rindex.lo strcat.lo strchr.lo strcmp.lo \
@USE_LIBTOOL_TRUE@strcasecmp.lo strcoll.lo strcpy.lo strcspn.lo \
@USE_LIBTOOL_TRUE@strerror.lo strlcat.lo strlcpy.lo strlen.lo strlwr.lo \
@USE_LIBTOOL_TRUE@strncat.lo strncmp.lo strncasecmp.lo strncpy.lo \
@USE_LIBTOOL_TRUE@strpbrk.lo strrchr.lo strsep.lo strspn.lo strtok.lo \
@USE_LIBTOOL_TRUE@strtok_r.lo strupr.lo strxfrm.lo strstr.lo swab.lo \
@USE_LIBTOOL_TRUE@u_strerr.lo
@USE_LIBTOOL_TRUE@strerror.lo strerror_r.lo strlcat.lo strlcpy.lo \
@USE_LIBTOOL_TRUE@strlen.lo strlwr.lo strncat.lo strncmp.lo \
@USE_LIBTOOL_TRUE@strncasecmp.lo strncpy.lo strnlen.lo strpbrk.lo \
@USE_LIBTOOL_TRUE@strrchr.lo strsep.lo strspn.lo strtok.lo strtok_r.lo \
@USE_LIBTOOL_TRUE@strupr.lo strxfrm.lo strstr.lo swab.lo u_strerr.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@ -0,0 +1,53 @@
/*
FUNCTION
<<strerror_r>>---convert error number to string and copy to buffer
INDEX
strerror_r
ANSI_SYNOPSIS
#include <string.h>
char *strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>);
TRAD_SYNOPSIS
#include <string.h>
char *strerror_r(<[errnum]>, <[buffer]>, <[n]>)
int <[errnum]>;
char *<[buffer]>;
size_t <[n]>;
DESCRIPTION
<<strerror_r>> converts the error number <[errnum]> into a
string and copies the result into the supplied <[buffer]> for
a length up to <[n]>, including the NUL terminator. The value of
<[errnum]> is usually a copy of <<errno>>. If <<errnum>> is not a known
error number, the result is the empty string.
See <<strerror>> for how strings are mapped to <<errnum>>.
RETURNS
This function returns a pointer to a string. Your application must
not modify that string.
PORTABILITY
<<strerror_r>> is a gnu extension.
<<strerror_r>> requires no supporting OS subroutines.
*/
#undef __STRICT_ANSI__
#include <errno.h>
#include <string.h>
char *
_DEFUN (strerror_r, (errnum, buffer, n),
int errnum _AND
char *buffer _AND
size_t n)
{
char *error;
error = strerror (errnum);
return strncpy (buffer, (const char *)error, n);
}

View File

@ -0,0 +1,49 @@
/*
FUNCTION
<<strnlen>>---character string length
INDEX
strnlen
ANSI_SYNOPSIS
#include <string.h>
size_t strnlen(const char *<[str]>, size_t <[n]>);
TRAD_SYNOPSIS
#include <string.h>
size_t strnlen(<[str]>, <[n]>)
char *<[src]>;
size_t <[n]>;
DESCRIPTION
The <<strnlen>> function works out the length of the string
starting at <<*<[str]>>> by counting chararacters until it
reaches a NUL character or the maximum: <[n]> number of
characters have been inspected.
RETURNS
<<strnlen>> returns the character count or <[n]>.
PORTABILITY
<<strnlen>> is a Gnu extension.
<<strnlen>> requires no supporting OS subroutines.
*/
#undef __STRICT_ANSI__
#include <_ansi.h>
#include <string.h>
size_t
_DEFUN (strnlen, (str, n),
_CONST char *str _AND
size_t n)
{
_CONST char *start = str;
while (*str && n-- > 0)
str++;
return str - start;
}

View File

@ -13,8 +13,8 @@ LIB_SOURCES = \
brk.c flockfile.c funlockfile.c gethostname.c getoptlong.c getreent.c ids.c \
inode.c io.c io64.c linux.c mmap.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \
resource.c sched.c select.c shm_open.c shm_unlink.c seteuid.c signal.c \
siglongjmp.c socket.c sleep.c stack.c \
rename.c resource.c sched.c select.c seteuid.c shm_open.c \
shm_unlink.c signal.c siglongjmp.c socket.c sleep.c stack.c \
sysconf.c sysctl.c systat.c system.c tcdrain.c termios.c time.c \
usleep.c wait.c

View File

@ -104,8 +104,8 @@ LIB_SOURCES = \
brk.c flockfile.c funlockfile.c gethostname.c getoptlong.c getreent.c ids.c \
inode.c io.c io64.c linux.c mmap.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \
resource.c sched.c select.c shm_open.c shm_unlink.c seteuid.c signal.c \
siglongjmp.c socket.c sleep.c stack.c \
rename.c resource.c sched.c select.c seteuid.c shm_open.c \
shm_unlink.c signal.c siglongjmp.c socket.c sleep.c stack.c \
sysconf.c sysctl.c systat.c system.c tcdrain.c termios.c time.c \
usleep.c wait.c
@ -141,10 +141,10 @@ LIBS = @LIBS@
@USE_LIBTOOL_FALSE@gethostname.o getoptlong.o getreent.o ids.o inode.o \
@USE_LIBTOOL_FALSE@io.o io64.o linux.o mmap.o pread.o pread64.o \
@USE_LIBTOOL_FALSE@process.o pwrite.o pwrite64.o raise.o realpath.o \
@USE_LIBTOOL_FALSE@resource.o sched.o select.o shm_open.o shm_unlink.o \
@USE_LIBTOOL_FALSE@seteuid.o signal.o siglongjmp.o socket.o sleep.o \
@USE_LIBTOOL_FALSE@stack.o sysconf.o sysctl.o systat.o system.o \
@USE_LIBTOOL_FALSE@tcdrain.o termios.o time.o usleep.o wait.o
@USE_LIBTOOL_FALSE@rename.o resource.o sched.o select.o seteuid.o \
@USE_LIBTOOL_FALSE@shm_open.o shm_unlink.o signal.o siglongjmp.o \
@USE_LIBTOOL_FALSE@socket.o sleep.o stack.o sysconf.o sysctl.o systat.o \
@USE_LIBTOOL_FALSE@system.o tcdrain.o termios.o time.o usleep.o wait.o
LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@liblinux_la_DEPENDENCIES =
@ -152,11 +152,12 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@funlockfile.lo gethostname.lo getoptlong.lo \
@USE_LIBTOOL_TRUE@getreent.lo ids.lo inode.lo io.lo io64.lo linux.lo \
@USE_LIBTOOL_TRUE@mmap.lo pread.lo pread64.lo process.lo pwrite.lo \
@USE_LIBTOOL_TRUE@pwrite64.lo raise.lo realpath.lo resource.lo sched.lo \
@USE_LIBTOOL_TRUE@select.lo shm_open.lo shm_unlink.lo seteuid.lo \
@USE_LIBTOOL_TRUE@signal.lo siglongjmp.lo socket.lo sleep.lo stack.lo \
@USE_LIBTOOL_TRUE@sysconf.lo sysctl.lo systat.lo system.lo tcdrain.lo \
@USE_LIBTOOL_TRUE@termios.lo time.lo usleep.lo wait.lo
@USE_LIBTOOL_TRUE@pwrite64.lo raise.lo realpath.lo rename.lo \
@USE_LIBTOOL_TRUE@resource.lo sched.lo select.lo seteuid.lo shm_open.lo \
@USE_LIBTOOL_TRUE@shm_unlink.lo signal.lo siglongjmp.lo socket.lo \
@USE_LIBTOOL_TRUE@sleep.lo stack.lo sysconf.lo sysctl.lo systat.lo \
@USE_LIBTOOL_TRUE@system.lo tcdrain.lo termios.lo time.lo usleep.lo \
@USE_LIBTOOL_TRUE@wait.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@ -0,0 +1,9 @@
/* libc/sys/linux/rename.c - rename a file */
/* Copyright 2002, Red Hat Inc. */
#include <stdio.h>
#include <machine/syscall.h>
_syscall2(int,rename,const char *,old,const char *,new)