aboutsummaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2008-11-19 20:56:22 +0000
committerJeff Johnston <jjohnstn@redhat.com>2008-11-19 20:56:22 +0000
commit8ee939ea9f395f95357612d64d9be8e9a6529e46 (patch)
tree69f67c24be31e64b3973adbbacef499e6f753299 /newlib
parente231c7dae90002f4aa9a6e8bdb445a0bd6c392ae (diff)
downloadnewlib-8ee939ea9f395f95357612d64d9be8e9a6529e46.zip
newlib-8ee939ea9f395f95357612d64d9be8e9a6529e46.tar.gz
newlib-8ee939ea9f395f95357612d64d9be8e9a6529e46.tar.bz2
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.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog15
-rw-r--r--newlib/libc/include/stdlib.h4
-rw-r--r--newlib/libc/posix/Makefile.am2
-rw-r--r--newlib/libc/posix/Makefile.in22
-rw-r--r--newlib/libc/posix/_isatty.c6
-rw-r--r--newlib/libc/stdlib/Makefile.am1
-rw-r--r--newlib/libc/stdlib/Makefile.in23
-rw-r--r--newlib/libc/stdlib/malloc.c27
-rw-r--r--newlib/libc/stdlib/reallocf.c (renamed from newlib/libc/posix/reallocf.c)23
-rw-r--r--newlib/libc/sys/linux/bits/dirent.h53
-rw-r--r--newlib/libc/sys/linux/sys/dirent.h2
11 files changed, 146 insertions, 32 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index f8b1ccc..f94117f 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,18 @@
+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.
+
2008-11-19 Craig Howland <howland@LGSInnovations.com>
* libc/unix/collate.c (__collate_err): simplify to remove unnecessary
diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index 5f2f608..be4fa44 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -104,6 +104,9 @@ char * _EXFUN(mktemp,(char *));
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR)));
int _EXFUN(rand,(_VOID));
_PTR _EXFUN(realloc,(_PTR __r, size_t __size));
+#ifndef __STRICT_ANSI__
+_PTR _EXFUN(reallocf,(_PTR __r, size_t __size));
+#endif
_VOID _EXFUN(srand,(unsigned __seed));
double _EXFUN(strtod,(const char *__n, char **__end_PTR));
double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR));
@@ -129,6 +132,7 @@ int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn)));
int _EXFUN(putenv,(char *__string));
int _EXFUN(_putenv_r,(struct _reent *, char *__string));
+_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));
int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite));
int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite));
diff --git a/newlib/libc/posix/Makefile.am b/newlib/libc/posix/Makefile.am
index d953b21..7da0872 100644
--- a/newlib/libc/posix/Makefile.am
+++ b/newlib/libc/posix/Makefile.am
@@ -7,7 +7,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = \
closedir.c collate.c collcmp.c creat.c \
fnmatch.c glob.c _isatty.c isatty.c \
- opendir.c readdir.c readdir.c reallocf.c \
+ opendir.c readdir.c readdir.c \
regcomp.c regerror.c regexec.c regfree.c \
rewinddir.c sleep.c usleep.c \
telldir.c
diff --git a/newlib/libc/posix/Makefile.in b/newlib/libc/posix/Makefile.in
index 51bf469..61895db 100644
--- a/newlib/libc/posix/Makefile.in
+++ b/newlib/libc/posix/Makefile.in
@@ -62,11 +62,11 @@ am__objects_1 = lib_a-closedir.$(OBJEXT) lib_a-collate.$(OBJEXT) \
lib_a-fnmatch.$(OBJEXT) lib_a-glob.$(OBJEXT) \
lib_a-_isatty.$(OBJEXT) lib_a-isatty.$(OBJEXT) \
lib_a-opendir.$(OBJEXT) lib_a-readdir.$(OBJEXT) \
- lib_a-readdir.$(OBJEXT) lib_a-reallocf.$(OBJEXT) \
- lib_a-regcomp.$(OBJEXT) lib_a-regerror.$(OBJEXT) \
- lib_a-regexec.$(OBJEXT) lib_a-regfree.$(OBJEXT) \
- lib_a-rewinddir.$(OBJEXT) lib_a-sleep.$(OBJEXT) \
- lib_a-usleep.$(OBJEXT) lib_a-telldir.$(OBJEXT)
+ lib_a-readdir.$(OBJEXT) lib_a-regcomp.$(OBJEXT) \
+ lib_a-regerror.$(OBJEXT) lib_a-regexec.$(OBJEXT) \
+ lib_a-regfree.$(OBJEXT) lib_a-rewinddir.$(OBJEXT) \
+ lib_a-sleep.$(OBJEXT) lib_a-usleep.$(OBJEXT) \
+ lib_a-telldir.$(OBJEXT)
am__objects_2 = lib_a-scandir.$(OBJEXT) lib_a-seekdir.$(OBJEXT)
am__objects_3 = lib_a-execl.$(OBJEXT) lib_a-execle.$(OBJEXT) \
lib_a-execlp.$(OBJEXT) lib_a-execv.$(OBJEXT) \
@@ -87,8 +87,8 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
libposix_la_LIBADD =
am__objects_6 = closedir.lo collate.lo collcmp.lo creat.lo fnmatch.lo \
glob.lo _isatty.lo isatty.lo opendir.lo readdir.lo readdir.lo \
- reallocf.lo regcomp.lo regerror.lo regexec.lo regfree.lo \
- rewinddir.lo sleep.lo usleep.lo telldir.lo
+ regcomp.lo regerror.lo regexec.lo regfree.lo rewinddir.lo \
+ sleep.lo usleep.lo telldir.lo
am__objects_7 = scandir.lo seekdir.lo
am__objects_8 = execl.lo execle.lo execlp.lo execv.lo execve.lo \
execvp.lo wordexp.lo wordfree.lo
@@ -292,7 +292,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = \
closedir.c collate.c collcmp.c creat.c \
fnmatch.c glob.c _isatty.c isatty.c \
- opendir.c readdir.c readdir.c reallocf.c \
+ opendir.c readdir.c readdir.c \
regcomp.c regerror.c regexec.c regfree.c \
rewinddir.c sleep.c usleep.c \
telldir.c
@@ -452,12 +452,6 @@ lib_a-readdir.o: readdir.c
lib_a-readdir.obj: readdir.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-readdir.obj `if test -f 'readdir.c'; then $(CYGPATH_W) 'readdir.c'; else $(CYGPATH_W) '$(srcdir)/readdir.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-regcomp.o: regcomp.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-regcomp.o `test -f 'regcomp.c' || echo '$(srcdir)/'`regcomp.c
diff --git a/newlib/libc/posix/_isatty.c b/newlib/libc/posix/_isatty.c
index 7260211..7d6ccae 100644
--- a/newlib/libc/posix/_isatty.c
+++ b/newlib/libc/posix/_isatty.c
@@ -3,15 +3,19 @@
/* Dumb implementation so programs will at least run. */
#include <sys/stat.h>
+#include <errno.h>
int
_DEFUN(_isatty, (fd), int fd)
{
struct stat buf;
- if (fstat (fd, &buf) < 0)
+ if (fstat (fd, &buf) < 0) {
+ errno = EBADF;
return 0;
+ }
if (S_ISCHR (buf.st_mode))
return 1;
+ errno = ENOTTY;
return 0;
}
diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am
index ce3bcbc..e63ea03 100644
--- a/newlib/libc/stdlib/Makefile.am
+++ b/newlib/libc/stdlib/Makefile.am
@@ -47,6 +47,7 @@ GENERAL_SOURCES = \
rand.c \
rand_r.c \
realloc.c \
+ reallocf.c \
strtod.c \
strtol.c \
strtoul.c \
diff --git a/newlib/libc/stdlib/Makefile.in b/newlib/libc/stdlib/Makefile.in
index 632e92d..be947cb 100644
--- a/newlib/libc/stdlib/Makefile.in
+++ b/newlib/libc/stdlib/Makefile.in
@@ -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
diff --git a/newlib/libc/stdlib/malloc.c b/newlib/libc/stdlib/malloc.c
index 83453ab..160a13e 100644
--- a/newlib/libc/stdlib/malloc.c
+++ b/newlib/libc/stdlib/malloc.c
@@ -23,6 +23,8 @@ INDEX
INDEX
realloc
INDEX
+ reallocf
+INDEX
free
INDEX
memalign
@@ -33,6 +35,8 @@ INDEX
INDEX
_realloc_r
INDEX
+ _reallocf_r
+INDEX
_free_r
INDEX
_memalign_r
@@ -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
diff --git a/newlib/libc/posix/reallocf.c b/newlib/libc/stdlib/reallocf.c
index 4c482fa..a9d3293 100644
--- a/newlib/libc/posix/reallocf.c
+++ b/newlib/libc/stdlib/reallocf.c
@@ -24,17 +24,32 @@
* SUCH DAMAGE.
*/
+/* Documented in malloc.c. */
+
#include <sys/cdefs.h>
#include <stdlib.h>
-void *
-reallocf(void *ptr, size_t size)
+_PTR
+_DEFUN (_reallocf_r, (reentptr, ptr, size),
+ struct _reent *reentptr _AND
+ _PTR ptr _AND
+ size_t size)
{
void *nptr;
- nptr = realloc(ptr, size);
+ nptr = _realloc_r(reentptr, ptr, size);
if (!nptr && ptr)
- free(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
diff --git a/newlib/libc/sys/linux/bits/dirent.h b/newlib/libc/sys/linux/bits/dirent.h
new file mode 100644
index 0000000..e6eb17a
--- /dev/null
+++ b/newlib/libc/sys/linux/bits/dirent.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_DIRENT_H
+# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
+#endif
+
+struct dirent
+ {
+#ifndef __USE_FILE_OFFSET64
+ __ino_t d_ino;
+ __off_t d_off;
+#else
+ __ino64_t d_ino;
+ __off64_t d_off;
+#endif
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256]; /* We must not include limits.h! */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct dirent64
+ {
+ __ino64_t d_ino;
+ __off64_t d_off;
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256]; /* We must not include limits.h! */
+ };
+#endif
+
+#define d_fileno d_ino /* Backwards compatibility. */
+
+#undef _DIRENT_HAVE_D_NAMLEN
+#define _DIRENT_HAVE_D_RECLEN
+#define _DIRENT_HAVE_D_OFF
+#define _DIRENT_HAVE_D_TYPE
diff --git a/newlib/libc/sys/linux/sys/dirent.h b/newlib/libc/sys/linux/sys/dirent.h
index 4bbae42..58d7745 100644
--- a/newlib/libc/sys/linux/sys/dirent.h
+++ b/newlib/libc/sys/linux/sys/dirent.h
@@ -7,7 +7,7 @@
#define _SYS_DIRENT_H
#include <sys/types.h>
-#include <linux/dirent.h>
+#include <bits/dirent.h>
#define _LIBC 1
#define NOT_IN_libc 1
#include <sys/lock.h>