From 8ee939ea9f395f95357612d64d9be8e9a6529e46 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 19 Nov 2008 20:56:22 +0000 Subject: 2008-11-19 Jeff Johnston * libc/sys/linux/bits/dirent.h: New header file. * libc/sys/linux/sys/dirent.h: Include instead of . * 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. --- newlib/libc/posix/Makefile.am | 2 +- newlib/libc/posix/Makefile.in | 22 ++++++++-------------- newlib/libc/posix/_isatty.c | 6 +++++- newlib/libc/posix/reallocf.c | 40 ---------------------------------------- 4 files changed, 14 insertions(+), 56 deletions(-) delete mode 100644 newlib/libc/posix/reallocf.c (limited to 'newlib/libc/posix') diff --git a/newlib/libc/posix/Makefile.am b/newlib/libc/posix/Makefile.am index d953b21df..7da0872c0 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 51bf4692a..61895dbc8 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 7260211ef..7d6ccae7c 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 +#include 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/posix/reallocf.c b/newlib/libc/posix/reallocf.c deleted file mode 100644 index 4c482fade..000000000 --- a/newlib/libc/posix/reallocf.c +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 1998, M. Warner Losh - * 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. - */ - -#include - -#include - -void * -reallocf(void *ptr, size_t size) -{ - void *nptr; - - nptr = realloc(ptr, size); - if (!nptr && ptr) - free(ptr); - return (nptr); -} -- cgit v1.2.3