2008-11-19 Jeff Johnston <jjohnstn@redhat.com>

* libc/sys/linux/bits/dirent.h: New header file.
        * libc/sys/linux/sys/dirent.h: Include <bits/dirent.h> instead of
        <linux/dirent.h>.
        * libc/posix/Makefile.am: Remove reallocf.
        * libc/posix/Makefile.in: Regenerated.
        * libc/posix/reallocf.c: Moved to...
        * libc/stdlib/reallocf.c: Here
        * libc/stdlib/malloc.c: Add reallocf documentation.
        * libc/include/stdlib.h: Add reallocf and _reallocf_r prototypes.
        * libc/stdlib/Makefile.am: Add reallocf.
        * libc/stdlib/Makefile.in: Regenerated.
        * libc/posix/_isatty.c: Set errno.
This commit is contained in:
Jeff Johnston
2008-11-19 20:56:22 +00:00
parent e231c7dae9
commit 8ee939ea9f
11 changed files with 146 additions and 32 deletions

View File

@ -47,6 +47,7 @@ GENERAL_SOURCES = \
rand.c \
rand_r.c \
realloc.c \
reallocf.c \
strtod.c \
strtol.c \
strtoul.c \

View File

@ -87,11 +87,11 @@ am__objects_1 = lib_a-__adjust.$(OBJEXT) lib_a-__atexit.$(OBJEXT) \
lib_a-mlock.$(OBJEXT) lib_a-mprec.$(OBJEXT) \
lib_a-mstats.$(OBJEXT) lib_a-rand.$(OBJEXT) \
lib_a-rand_r.$(OBJEXT) lib_a-realloc.$(OBJEXT) \
lib_a-strtod.$(OBJEXT) lib_a-strtol.$(OBJEXT) \
lib_a-strtoul.$(OBJEXT) lib_a-wcstol.$(OBJEXT) \
lib_a-wcstoul.$(OBJEXT) lib_a-wcstombs.$(OBJEXT) \
lib_a-wcstombs_r.$(OBJEXT) lib_a-wctomb.$(OBJEXT) \
lib_a-wctomb_r.$(OBJEXT)
lib_a-reallocf.$(OBJEXT) lib_a-strtod.$(OBJEXT) \
lib_a-strtol.$(OBJEXT) lib_a-strtoul.$(OBJEXT) \
lib_a-wcstol.$(OBJEXT) lib_a-wcstoul.$(OBJEXT) \
lib_a-wcstombs.$(OBJEXT) lib_a-wcstombs_r.$(OBJEXT) \
lib_a-wctomb.$(OBJEXT) lib_a-wctomb_r.$(OBJEXT)
am__objects_2 = lib_a-cxa_atexit.$(OBJEXT) \
lib_a-cxa_finalize.$(OBJEXT) lib_a-drand48.$(OBJEXT) \
lib_a-ecvtbuf.$(OBJEXT) lib_a-efgcvt.$(OBJEXT) \
@ -135,9 +135,9 @@ am__objects_7 = __adjust.lo __atexit.lo __call_atexit.lo __exp10.lo \
gdtoa-gethex.lo gdtoa-hexnan.lo getenv.lo getenv_r.lo labs.lo \
ldiv.lo ldtoa.lo malloc.lo mblen.lo mblen_r.lo mbstowcs.lo \
mbstowcs_r.lo mbtowc.lo mbtowc_r.lo mlock.lo mprec.lo \
mstats.lo rand.lo rand_r.lo realloc.lo strtod.lo strtol.lo \
strtoul.lo wcstol.lo wcstoul.lo wcstombs.lo wcstombs_r.lo \
wctomb.lo wctomb_r.lo
mstats.lo rand.lo rand_r.lo realloc.lo reallocf.lo strtod.lo \
strtol.lo strtoul.lo wcstol.lo wcstoul.lo wcstombs.lo \
wcstombs_r.lo wctomb.lo wctomb_r.lo
am__objects_8 = cxa_atexit.lo cxa_finalize.lo drand48.lo ecvtbuf.lo \
efgcvt.lo erand48.lo jrand48.lo lcong48.lo lrand48.lo \
mrand48.lo msize.lo mtrim.lo nrand48.lo rand48.lo seed48.lo \
@ -388,6 +388,7 @@ GENERAL_SOURCES = \
rand.c \
rand_r.c \
realloc.c \
reallocf.c \
strtod.c \
strtol.c \
strtoul.c \
@ -857,6 +858,12 @@ lib_a-realloc.o: realloc.c
lib_a-realloc.obj: realloc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-realloc.obj `if test -f 'realloc.c'; then $(CYGPATH_W) 'realloc.c'; else $(CYGPATH_W) '$(srcdir)/realloc.c'; fi`
lib_a-reallocf.o: reallocf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-reallocf.o `test -f 'reallocf.c' || echo '$(srcdir)/'`reallocf.c
lib_a-reallocf.obj: reallocf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-reallocf.obj `if test -f 'reallocf.c'; then $(CYGPATH_W) 'reallocf.c'; else $(CYGPATH_W) '$(srcdir)/reallocf.c'; fi`
lib_a-strtod.o: strtod.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtod.o `test -f 'strtod.c' || echo '$(srcdir)/'`strtod.c

View File

@ -22,6 +22,8 @@ INDEX
malloc
INDEX
realloc
INDEX
reallocf
INDEX
free
INDEX
@ -32,6 +34,8 @@ INDEX
_malloc_r
INDEX
_realloc_r
INDEX
_reallocf_r
INDEX
_free_r
INDEX
@ -43,6 +47,7 @@ ANSI_SYNOPSIS
#include <stdlib.h>
void *malloc(size_t <[nbytes]>);
void *realloc(void *<[aptr]>, size_t <[nbytes]>);
void *reallocf(void *<[aptr]>, size_t <[nbytes]>);
void free(void *<[aptr]>);
void *memalign(size_t <[align]>, size_t <[nbytes]>);
@ -52,6 +57,8 @@ ANSI_SYNOPSIS
void *_malloc_r(void *<[reent]>, size_t <[nbytes]>);
void *_realloc_r(void *<[reent]>,
void *<[aptr]>, size_t <[nbytes]>);
void *_reallocf_r(void *<[reent]>,
void *<[aptr]>, size_t <[nbytes]>);
void _free_r(void *<[reent]>, void *<[aptr]>);
void *_memalign_r(void *<[reent]>,
@ -68,6 +75,10 @@ TRAD_SYNOPSIS
char *<[aptr]>;
size_t <[nbytes]>;
char *reallocf(<[aptr]>, <[nbytes]>)
char *<[aptr]>;
size_t <[nbytes]>;
void free(<[aptr]>)
char *<[aptr]>;
@ -87,6 +98,11 @@ TRAD_SYNOPSIS
char *<[aptr]>;
size_t <[nbytes]>;
char *_reallocf_r(<[reent]>, <[aptr]>, <[nbytes]>)
char *<[reent]>;
char *<[aptr]>;
size_t <[nbytes]>;
void _free_r(<[reent]>, <[aptr]>)
char *<[reent]>;
char *<[aptr]>;
@ -124,6 +140,11 @@ memory storage pool by calling <<free>> with the address of the object
as the argument. You can also use <<realloc>> for this purpose by
calling it with <<0>> as the <[nbytes]> argument.
The <<reallocf>> function behaves just like <<realloc>> except if the
function is required to allocate new storage and this fails. In this
case <<reallocf>> will free the original object passed in whereas
<<realloc>> will not.
The <<memalign>> function returns a block of size <[nbytes]> aligned
to a <[align]> boundary. The <[align]> argument must be a power of
two.
@ -134,9 +155,9 @@ available in the block. This may or may not be more than the size
requested from <<malloc>>, due to alignment or minimum size
constraints.
The alternate functions <<_malloc_r>>, <<_realloc_r>>, <<_free_r>>,
<<_memalign_r>>, and <<_malloc_usable_size_r>> are reentrant versions.
The extra argument <[reent]> is a pointer to a reentrancy structure.
The alternate functions <<_malloc_r>>, <<_realloc_r>>, <<_reallocf_r>>,
<<_free_r>>, <<_memalign_r>>, and <<_malloc_usable_size_r>> are reentrant
versions. The extra argument <[reent]> is a pointer to a reentrancy structure.
If you have multiple threads of execution which may call any of these
routines, or if any of these routines may be called reentrantly, then

View File

@ -0,0 +1,55 @@
/*-
* Copyright (c) 1998, M. Warner Losh <imp@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* Documented in malloc.c. */
#include <sys/cdefs.h>
#include <stdlib.h>
_PTR
_DEFUN (_reallocf_r, (reentptr, ptr, size),
struct _reent *reentptr _AND
_PTR ptr _AND
size_t size)
{
void *nptr;
nptr = _realloc_r(reentptr, ptr, size);
if (!nptr && ptr)
_free_r(reentptr, ptr);
return (nptr);
}
#ifndef _REENT_ONLY
_PTR
_DEFUN (reallocf, (ptr, size),
_PTR ptr _AND
size_t size)
{
return _reallocf_r(_REENT, ptr, size);
}
#endif