aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-07-22 23:53:50 +0000
committerJeff Johnston <jjohnstn@redhat.com>2002-07-22 23:53:50 +0000
commitf5f27f07787e822e773e14b1dced1a01cbe28050 (patch)
tree1fd3a655aaf7929ab718631dc948faec9ea948bb /newlib/libc
parentd541ba3ec0fd2de71ed3f9f2962189a4e6bde297 (diff)
downloadnewlib-f5f27f07787e822e773e14b1dced1a01cbe28050.zip
newlib-f5f27f07787e822e773e14b1dced1a01cbe28050.tar.gz
newlib-f5f27f07787e822e773e14b1dced1a01cbe28050.tar.bz2
2002-07-22 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h (fcloseall, _fcloseall_r): Added prototypes. * libc/stdio/Makefile.am: Added fcloseall.c support. * libc/stdio/Makefile.in: Regenerated. * libc/stdio/fcloseall.c: New file. * libc/stdio64/Makefile.am: Remove missing .def references. * libc/stdio64/Makefile.in: Regenerated.
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/include/stdio.h2
-rw-r--r--newlib/libc/stdio/Makefile.am2
-rw-r--r--newlib/libc/stdio/Makefile.in68
-rw-r--r--newlib/libc/stdio/fcloseall.c88
-rw-r--r--newlib/libc/stdio64/Makefile.am3
-rw-r--r--newlib/libc/stdio64/Makefile.in7
6 files changed, 130 insertions, 40 deletions
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index 9e93ed5..debeb2b 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -204,6 +204,7 @@ int _EXFUN(rename, (const char *, const char *));
#endif
#ifndef __STRICT_ANSI__
int _EXFUN(asprintf, (char **, const char *, ...));
+int _EXFUN(fcloseall, (_VOID));
int _EXFUN(fseeko, (FILE *, off_t, int));
off_t _EXFUN(ftello, ( FILE *));
int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST));
@@ -250,6 +251,7 @@ int _EXFUN(putchar_unlocked, (int));
*/
int _EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...));
+int _EXFUN(_fcloseall_r, (struct _reent *));
FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *));
FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
int _EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...));
diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am
index 1053de2..aee96d8 100644
--- a/newlib/libc/stdio/Makefile.am
+++ b/newlib/libc/stdio/Makefile.am
@@ -8,6 +8,7 @@ LIB_SOURCES = \
asprintf.c \
clearerr.c \
fclose.c \
+ fcloseall.c \
fdopen.c \
feof.c \
ferror.c \
@@ -113,6 +114,7 @@ vfiprintf.$(oext): vfprintf.c
CHEWOUT_FILES = \
clearerr.def \
fclose.def \
+ fcloseall.def \
fdopen.def \
feof.def \
ferror.def \
diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in
index c973eec..54d21da 100644
--- a/newlib/libc/stdio/Makefile.in
+++ b/newlib/libc/stdio/Makefile.in
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -114,6 +114,7 @@ LIB_SOURCES = \
asprintf.c \
clearerr.c \
fclose.c \
+ fcloseall.c \
fdopen.c \
feof.c \
ferror.c \
@@ -206,6 +207,7 @@ libstdio_la_LDFLAGS = -Xcompiler -nostdlib
CHEWOUT_FILES = \
clearerr.def \
fclose.def \
+ fcloseall.def \
fdopen.def \
feof.def \
ferror.def \
@@ -275,21 +277,22 @@ LIBS = @LIBS@
@USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = vfiprintf.$(oext) \
@USE_LIBTOOL_FALSE@vfprintf.$(oext)
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = asprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@clearerr.$(OBJEXT) fclose.$(OBJEXT) fdopen.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@feof.$(OBJEXT) ferror.$(OBJEXT) fflush.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fgetc.$(OBJEXT) fgetpos.$(OBJEXT) fgets.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fileno.$(OBJEXT) findfp.$(OBJEXT) fiprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@flags.$(OBJEXT) fopen.$(OBJEXT) fprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fputc.$(OBJEXT) fputs.$(OBJEXT) fread.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@freopen.$(OBJEXT) fscanf.$(OBJEXT) fseek.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fseeko.$(OBJEXT) fsetpos.$(OBJEXT) ftell.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@ftello.$(OBJEXT) fvwrite.$(OBJEXT) fwalk.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fwrite.$(OBJEXT) getc.$(OBJEXT) getchar.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@getc_u.$(OBJEXT) getchar_u.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@getdelim.$(OBJEXT) getline.$(OBJEXT) gets.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@getw.$(OBJEXT) iprintf.$(OBJEXT) makebuf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@mktemp.$(OBJEXT) perror.$(OBJEXT) printf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@putc.$(OBJEXT) putchar.$(OBJEXT) putc_u.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@clearerr.$(OBJEXT) fclose.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fcloseall.$(OBJEXT) fdopen.$(OBJEXT) feof.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@ferror.$(OBJEXT) fflush.$(OBJEXT) fgetc.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fgetpos.$(OBJEXT) fgets.$(OBJEXT) fileno.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@findfp.$(OBJEXT) fiprintf.$(OBJEXT) flags.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fopen.$(OBJEXT) fprintf.$(OBJEXT) fputc.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fputs.$(OBJEXT) fread.$(OBJEXT) freopen.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fscanf.$(OBJEXT) fseek.$(OBJEXT) fseeko.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fsetpos.$(OBJEXT) ftell.$(OBJEXT) ftello.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fvwrite.$(OBJEXT) fwalk.$(OBJEXT) fwrite.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@getc.$(OBJEXT) getchar.$(OBJEXT) getc_u.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@getchar_u.$(OBJEXT) getdelim.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@getline.$(OBJEXT) gets.$(OBJEXT) getw.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@iprintf.$(OBJEXT) makebuf.$(OBJEXT) mktemp.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@perror.$(OBJEXT) printf.$(OBJEXT) putc.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@putchar.$(OBJEXT) putc_u.$(OBJEXT) \
@USE_LIBTOOL_FALSE@putchar_u.$(OBJEXT) puts.$(OBJEXT) putw.$(OBJEXT) \
@USE_LIBTOOL_FALSE@refill.$(OBJEXT) remove.$(OBJEXT) rename.$(OBJEXT) \
@USE_LIBTOOL_FALSE@rewind.$(OBJEXT) rget.$(OBJEXT) scanf.$(OBJEXT) \
@@ -307,21 +310,22 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@libstdio_la_DEPENDENCIES = vfiprintf.$(oext) \
@USE_LIBTOOL_TRUE@vfprintf.$(oext)
@USE_LIBTOOL_TRUE@libstdio_la_OBJECTS = asprintf.lo clearerr.lo \
-@USE_LIBTOOL_TRUE@fclose.lo fdopen.lo feof.lo ferror.lo fflush.lo \
-@USE_LIBTOOL_TRUE@fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \
-@USE_LIBTOOL_TRUE@fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo \
-@USE_LIBTOOL_TRUE@fputs.lo fread.lo freopen.lo fscanf.lo fseek.lo \
-@USE_LIBTOOL_TRUE@fseeko.lo fsetpos.lo ftell.lo ftello.lo fvwrite.lo \
-@USE_LIBTOOL_TRUE@fwalk.lo fwrite.lo getc.lo getchar.lo getc_u.lo \
-@USE_LIBTOOL_TRUE@getchar_u.lo getdelim.lo getline.lo gets.lo getw.lo \
-@USE_LIBTOOL_TRUE@iprintf.lo makebuf.lo mktemp.lo perror.lo printf.lo \
-@USE_LIBTOOL_TRUE@putc.lo putchar.lo putc_u.lo putchar_u.lo puts.lo \
-@USE_LIBTOOL_TRUE@putw.lo refill.lo remove.lo rename.lo rewind.lo \
-@USE_LIBTOOL_TRUE@rget.lo scanf.lo setbuf.lo setbuffer.lo setlinebuf.lo \
-@USE_LIBTOOL_TRUE@setvbuf.lo siprintf.lo snprintf.lo sprintf.lo \
-@USE_LIBTOOL_TRUE@sscanf.lo stdio.lo tmpfile.lo tmpnam.lo ungetc.lo \
-@USE_LIBTOOL_TRUE@vasprintf.lo vfscanf.lo vprintf.lo vscanf.lo \
-@USE_LIBTOOL_TRUE@vsnprintf.lo vsprintf.lo vsscanf.lo wbuf.lo wsetup.lo
+@USE_LIBTOOL_TRUE@fclose.lo fcloseall.lo fdopen.lo feof.lo ferror.lo \
+@USE_LIBTOOL_TRUE@fflush.lo fgetc.lo fgetpos.lo fgets.lo fileno.lo \
+@USE_LIBTOOL_TRUE@findfp.lo fiprintf.lo flags.lo fopen.lo fprintf.lo \
+@USE_LIBTOOL_TRUE@fputc.lo fputs.lo fread.lo freopen.lo fscanf.lo \
+@USE_LIBTOOL_TRUE@fseek.lo fseeko.lo fsetpos.lo ftell.lo ftello.lo \
+@USE_LIBTOOL_TRUE@fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \
+@USE_LIBTOOL_TRUE@getc_u.lo getchar_u.lo getdelim.lo getline.lo gets.lo \
+@USE_LIBTOOL_TRUE@getw.lo iprintf.lo makebuf.lo mktemp.lo perror.lo \
+@USE_LIBTOOL_TRUE@printf.lo putc.lo putchar.lo putc_u.lo putchar_u.lo \
+@USE_LIBTOOL_TRUE@puts.lo putw.lo refill.lo remove.lo rename.lo \
+@USE_LIBTOOL_TRUE@rewind.lo rget.lo scanf.lo setbuf.lo setbuffer.lo \
+@USE_LIBTOOL_TRUE@setlinebuf.lo setvbuf.lo siprintf.lo snprintf.lo \
+@USE_LIBTOOL_TRUE@sprintf.lo sscanf.lo stdio.lo tmpfile.lo tmpnam.lo \
+@USE_LIBTOOL_TRUE@ungetc.lo vasprintf.lo vfscanf.lo vprintf.lo \
+@USE_LIBTOOL_TRUE@vscanf.lo vsnprintf.lo vsprintf.lo vsscanf.lo wbuf.lo \
+@USE_LIBTOOL_TRUE@wsetup.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)
diff --git a/newlib/libc/stdio/fcloseall.c b/newlib/libc/stdio/fcloseall.c
new file mode 100644
index 0000000..a34d821
--- /dev/null
+++ b/newlib/libc/stdio/fcloseall.c
@@ -0,0 +1,88 @@
+/*
+FUNCTION
+<<fcloseall>>---close all files
+
+INDEX
+ fcloseall
+INDEX
+ _fcloseall_r
+
+ANSI_SYNOPSIS
+ #include <stdio.h>
+ int fcloseall(void);
+ int _fcloseall_r (struct _reent *<[ptr]>);
+
+TRAD_SYNOPSIS
+ #include <stdio.h>
+ int fcloseall()
+
+ int _fcloseall_r (<[ptr]>)
+ struct _reent *<[ptr]>;
+
+DESCRIPTION
+<<fcloseall>> closes all files in the current reentrancy struct's domain.
+The function <<_fcloseall_r>> is the same function, except the reentrancy
+struct is passed in as the <[ptr]> argument.
+
+This function is not recommended as it closes all streams, including
+the std streams.
+
+RETURNS
+<<fclose>> returns <<0>> if all closes are successful. Otherwise,
+EOF is returned.
+
+PORTABILITY
+<<fcloseall>> is a glibc extension.
+
+Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>,
+<<read>>, <<sbrk>>, <<write>>.
+*/
+
+/* This file based upon fwalk.c. */
+
+/*
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "local.h"
+
+int
+_fcloseall_r (ptr)
+ struct _reent *ptr;
+{
+ register FILE *fp;
+ register int n, ret = 0;
+ register struct _glue *g;
+
+ for (g = &ptr->__sglue; g != NULL; g = g->_next)
+ for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++)
+ if (fp->_flags != 0)
+ ret |= fclose (fp);
+ return ret;
+}
+
+#ifndef _REENT_ONLY
+
+int
+fcloseall (void)
+{
+ return _fcloseall_r (_REENT);
+}
+
+#endif
diff --git a/newlib/libc/stdio64/Makefile.am b/newlib/libc/stdio64/Makefile.am
index a392cff..2ae728d 100644
--- a/newlib/libc/stdio64/Makefile.am
+++ b/newlib/libc/stdio64/Makefile.am
@@ -38,10 +38,7 @@ CHEWOUT_FILES = \
freopen64.def \
fseeko64.def \
fsetpos64.def \
- fstat64r.def \
ftello64.def \
- lseek64r.def \
- open64r.def \
tmpfile64.def
SUFFIXES = .def
diff --git a/newlib/libc/stdio64/Makefile.in b/newlib/libc/stdio64/Makefile.in
index 388b1ad..78c72c1 100644
--- a/newlib/libc/stdio64/Makefile.in
+++ b/newlib/libc/stdio64/Makefile.in
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -140,10 +140,7 @@ CHEWOUT_FILES = \
freopen64.def \
fseeko64.def \
fsetpos64.def \
- fstat64r.def \
ftello64.def \
- lseek64r.def \
- open64r.def \
tmpfile64.def