Commit Graph

24 Commits

Author SHA1 Message Date
Keith Packard 9042d0ce65 Use remove-advertising-clause script to edit BSD licenses
This edits licenses held by Berkeley and NetBSD, both of which
have removed the advertising requirement from their licenses.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-29 19:03:31 +01:00
Yaakov Selkowitz 9087163804 ansification: remove _DEFUN
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:26 -06:00
Yaakov Selkowitz 6783860a2e ansification: remove _AND
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:05 -06:00
Yaakov Selkowitz c7ef9668cf stdio: remove TRAD_SYNOPSIS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-12-01 03:41:51 -06:00
Corinna Vinschen 91a8eacec6 Add missing checks for __SNLK flag
* libc/stdio/fclose.c (_fclose_r): Make _flockfile/_funlockfile calls
        dependent on __SNLK flag.
        * libc/stdio/findfp.c (__fp_lock): Ditto.
        (__fp_unlock): Ditto.
        * libc/stdio/freopen.c (_freopen_r): Ditto.
        * libc/stdio64/freopen64.c (_freopen64_r): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-08 21:23:22 +01:00
Corinna Vinschen 7a7e4d4d95 Introduce _STDIO_BSD_SEMANTICS flag to switch fclose/exit file flushing
semantics from POSIX to BSD.
	* libc/stdio/fclose.c (_fclose_r): Conditionalize file flushing on
	_STDIO_BSD_SEMANTICS.  Call __sflush_r rather than _fflush_r.  Add
	comment.
	* libc/stdio/fflush.c (__sflushw_r): New function, only available
	if _STDIO_BSD_SEMANTICS is defined.
	* libc/stdio/findfp.c (_cleanup_r): Call _fwalk_reent rather than
	_fwalk.  Conditionalize cleanup function call on _STDIO_BSD_SEMANTICS.
	Add comments.  Add FIXME.
	* libc/stdio/local.h (__sflushw_r): Declare if _STDIO_BSD_SEMANTICS is
	defined.
2014-01-17 10:55:32 +00:00
Joel Sherrill 1ebc8da242 2013-03-26 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/stdio/local.h (_STDIO_WITH_THREAD_CANCELLATION_SUPPORT):
	New define.
	* libc/stdio/fclose.c: Use
	_STDIO_WITH_THREAD_CANCELLATION_SUPPORT.
	* libc/stdio/freopen.c: Likewise.
	* libc/stdio64/freopen64.c: Likewise.
2013-03-26 16:07:55 +00:00
Corinna Vinschen 4aa28d8ae2 * libc/stdio/local.h (_newlib_flockfile_start): New macro to
secure stream related critical section against thread cancellation.
	(_newlib_flockfile_exit): Ditto.
	(_newlib_sfp_lock_end): Ditto.
	(_newlib_sfp_lock_start): Ditto for the list of streams.
	(_newlib_sfp_lock_exit): Ditto.
	(_newlib_sfp_lock_end): Ditto.
	Use aforementioned macros in place of _flockfile/_funlockfile
	and __sfp_lock_acquire/__sfp_lock_release throughout the code.
	* libc/stdio/fclose.c: Explicitely disable and re-enable thread
	cancellation.  Explain why.
	* libc/stdio/freopen.c: Ditto.
	* libc/stdio64/freopen64.c: Ditto.
2012-05-30 08:58:42 +00:00
Corinna Vinschen 656df313e0 * libc/stdio/fclose.c: Only use sfp lock to guard non-atomic
changes of flags and fp lock.
	* libc/stdio/freopen.c: Ditto.
	* libc/stdio/freopen64.c: Ditto.
	* libc/stdio/fgetc.c: Revert change from 2009-04-24, remove sfp locks
	which guard entire function to avoid potential deadlocks when using
	stdio functions in multiple thraeds.
	* libc/stdio/fgets.c: Ditto.
	* libc/stdio/fgetwc.c: Ditto.
	* libc/stdio/fgetws.c: Ditto.
	* libc/stdio/fread.c: Ditto.
	* libc/stdio/fseek.c: Ditto.
	* libc/stdio/getc.c: Ditto.
	* libc/stdio/getdelim.c: Ditto.
	* libc/stdio/gets.c: Ditto.
	* libc/stdio/vfscanf.c: Ditto.
	* libc/stdio/vfwscanf.c: Ditto.

	* libc/stdio/fflush.c (_fflush_r): Split out core functionality into
	new function __sflush_r.  Just lock file and call __sflush_r from here.
	* libc/stdio/fwalk.c (_fwalk): Remove static helper function and move
	functionality back into main function. Don't walk a file with flags
	value of 1.  Add comment.
	(_fwalk_reent): Ditto.
	* libc/stdio/local.h (__sflush_r): Declare.
	* libc/stdio/refill.c (__srefill): Before calling fwalk, set flags
	value to 1 so this file pointer isn't walked.  Revert flags afterwards
	and call __sflush_r for this fp if necessary.  Add comments.
2011-01-28 10:49:11 +00:00
Eric Blake 08146e5adb Fix fflush issues.
* libc/stdio/fflush.c (_fflush_r): New function.
(fflush): Fix reentrancy and large offset behavior.
* libc/include/stdio.h (_fflush_r): Add prototype.
* libc/stdio/fclose.c (_fclose_r): All fflush callers changed.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/fseek.c (_fseek_r): Likewise.
* libc/stdio/ftell.c (_ftell_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Likewise.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/setvbuf.c (setvbuf): Likewise.
* libc/stdio/ungetc.c (_ungetc_r): Likewise.
* libc/stdio/vfprintf.c (__sbprintf): Likewise.
* libc/stdio/wbuf.c (__swbuf_r): Likewise.
* libc/stdio64/freopen64.c (_freopen64_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.  Defer to
32-bit version if not large file.
* libc/stdio64/ftello64.c (_ftello64_r): Likewise.
* libc/stdio64/tmpfile64.c (_tmpfile64_r): Avoid compile warning.
2007-07-13 20:37:53 +00:00
Eric Blake 17c61d6a2c Implement funopen, fopencookie.
* libc/include/sys/reent.h (struct __sFILE, struct __sFILE64):
Switch to reentrant callbacks.
* libc/include/stdio.h (funopen): Fix declaration.
(fopencookie): Declare.
* libc/stdio/local.h (__sread, __swrite, __sseek, __sclose)
(__sseek64, __swrite64): Fix prototypes.
[__SCLE]: Pull in setmode declaration.
* libc/stdio/stdio.c (__sread, __swrite, __sseek, __sclose): Fix
reentrancy.
* libc/stdio64/stdio64.c (__sseek64_r, __swrite64_r): Delete.
(__sseek64, __swrite64): Fix reentrancy.
* libc/stdio/fseek.c (_fseek_r): Account for overflow, and fix
reentrancy.
* libc/stdio/ftell.c (_ftell_r): Likewise.
* libc/stdio/flags.c (__sflags): Don't lose __SAPP on "a+".
* libc/stdio/fclose.c (_fclose_r): Fix reentrancy.
* libc/stdio/freopen.c (_freopen_r): Likewise.
* libc/stdio/fvwrite.c (__sfvwrite_r): Likewise.
* libc/stdio/refill.c (__srefill_r): Likewise.
* libc/stdio/siscanf.c (eofread): Likewise.
* libc/stdio/sscanf.c (eofread): Likewise.
* libc/stdio/vsiscanf.c (eofread1): Likewise.
* libc/stdio/vsscanf.c (eofread1): Likewise.
* libc/stdio64/freopen64.c (_freopen64_r): Likewise.
* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
* libc/stdio64/ftello64.c (_ftello64_r): Likewise.
* libc/stdio/fflush.c (fflush): Improve reentrancy, although more
could be fixed.
* libc/stdio/fopencookie.c (_fopencookie_r, fopencookie): New file.
* libc/stdio/funopen.c (_funopen_r, funopen): New file.
* libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES): Build
new files.
* libc/stdio/Makefile.in: Regenerate.
2007-06-04 18:10:17 +00:00
Jeff Johnston 14ba5e14d9 2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
	(__smakebuf): Rename...
	(__smakebuf_r): to this.
	* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
	* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
	allocation, then rename...
	(__smakebuf_r): ...to this and fix reentrancy.
	* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
	allocation, then rename...
	(__swsetup_r): ...to this and fix reentrancy.
	* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
	* libc/stdio/refill.c (__srefill_r): Likewise.
	* libc/stdio/fclose.c (_fclose_r): Likewise.
	* libc/stdio/fread.c (_fread_r): Likewise.
	* libc/stdio/freopen.c (_freopen_r): Likewise.
	* libc/stdio/wbuf.c (__swbuf_r): Likewise.
	* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
	* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
	failed asprintf allocation, and fix reentrancy.
	* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
	as required by POSIX.
	* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
	* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
	* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
2007-03-15 18:40:48 +00:00
Jeff Johnston 4c0b8a072b 2006-12-14 Jeff Johnston <jjohnstn@redhat.com>
Eric Blake  <ebb9@byu.net>

        * libc/stdio/fflush.c (fflush): On seekable streams, always flush
        read but unused data.
        * libc/stdio/fclose.c (_fclose_r): Always flush streams, since
        even read streams may have side effects that must happen.
2006-12-14 22:47:12 +00:00
Jeff Johnston e5e148d15b 2006-09-26 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h[_REENT_SMALL]: Do not allow macros
        for clearerr, feof, or fileno.
        * libc/include/sys/reent.h[_REENT_SMALL](struct _reent): Change
        the dummy std stream scheme to use pointers to const external
        fake files, one for each standard stream.
        * libc/stdio/local.h (CHECK_INIT): Change to take a file pointer
        argument.  For _REENT_SMALL, reset the file pointer if it
        matches one of the fake std stream pointers.
        * libc/stdio/clearerr.c: Fix CHECK_INIT macro to add file pointer
        argument.
        * libc/stdio/fclose.c: Ditto.
        * libc/stdio/feof.c: Ditto.
        * libc/stdio/ferror.c: Ditto.
        * libc/stdio/fflush.c: Ditto.
        * libc/stdio/fgetc.c: Ditto.
        * libc/stdio/fgets.c: Ditto.
        * libc/stdio/fileno.c: Ditto.
        * libc/stdio/findfp.c: Ditto.
        * libc/stdio/fputc.c: Ditto.
        * libc/stdio/fputs.c: Ditto.
        * libc/stdio/fread.c: Ditto.
        * libc/stdio/freopen.c: Ditto.
        * libc/stdio/fseek.c: Ditto.
        * libc/stdio/ftell.c: Ditto.
        * libc/stdio/fwrite.c: Ditto.
        * libc/stdio/getc.c: Ditto.
        * libc/stdio/getdelim.c: Ditto.
        * libc/stdio/putc.c: Ditto.
        * libc/stdio/refill.c: Ditto.
        * libc/stdio/setvbuf.c: Ditto.
        * libc/stdio/ungetc.c: Ditto.
        * libc/stdio/vfprintf.c: Ditto.
        * libc/stdio/vfscanf.c: Ditto.
        * libc/stdio/wbuf.c: Ditto.: Ditto.
        * libc/stdio/wsetup.c: Ditto.
        * libc/stdio64/freopen64.c: Ditto.
        * libc/stdio64/fseeko64.c: Ditto.
        * libc/stdio64/ftello64.c: Ditto.
        * libc/machine/powerpc/vfprintf.c: Ditto.
        * libc/machine/powerpc/vfscanf.c: Ditto.
2006-09-26 21:22:19 +00:00
Jeff Johnston 1159e0fd94 2005-02-07 Antony King <antony.king@st.com>
* libc/stdio/clearerr.c (clearerr): Ensure CHECK_INIT() is
        called before _flockfile to prevent lock object use before
        initialisation. _REENT_SMALL_CHECK_INIT() and CHECK_INIT()
        take a struct _reent * instead of a FILE *.
        * libc/stdio/fclose.c (_fclose_r): Ditto.
        * libc/stdio/feof.c (feof): Ditto.
        * libc/stdio/ferror.c (ferror): Ditto.
        * libc/stdio/fflush.c (fflush): Ditto.
        * libc/stdio/fgetc.c (fgetc): Ditto.
        * libc/stdio/fgets.c (fgets): Ditto.
        * libc/stdio/fileno.c (fileno): Ditto.
        * libc/stdio/fputc.c (fputc): Ditto.
        * libc/stdio/fputs.c (fputs): Ditto.
        * libc/stdio/fread.c (fread): Ditto.
        * libc/stdio/freopen.c (_freopen_r): Ditto.
        * libc/stdio/fseek.c (_fseek_r): Ditto.
        * libc/stdio/ftell.c (_ftell_r): Ditto.
        * libc/stdio/fwrite.c (fwrite): Ditto.
        * libc/stdio/getc.c (getc): Ditto.
        * libc/stdio/getdelim.c (__getdelim): Ditto.
        * libc/stdio/putc.c (putc): Ditto.
        * libc/stdio/setvbuf.c (setvbuf): Ditto.
        * libc/stdio/ungetc.c (_ungetc_r): Ditto.
        * libc/stdio/vfprintf.c (_VFPRINTF_R): Ditto.
        * libc/stdio64/freopen64.c (_freopen64_r): Ditto.
        * libc/stdio64/fseeko64.c (_fseeko64_r): Ditto.
        * libc/stdio64/ftello64.c (_ftello64_r): Ditto.
        * libc/stdio/local.h (CHECK_INIT): Argument is now a struct
        _reent * instead of a FILE * and so replace incorrect use of
        _REENT with argument.
        * libc/sys/arm/syscalls.c (CHECK_INIT): Ditto.
        * libc/stdio/getchar.c (getchar): _REENT_SMALL_CHECK_INIT() and
        CHECK_INIT() take a struct _reent * instead of a FILE *.
        * libc/stdio/iprintf.c (iprintf, _iprintf_r): Ditto.
        * libc/stdio/iscanf.c (iscanf, _iscanf_r): Ditto.
        * libc/stdio/perror.c (perror): Ditto.
        * libc/stdio/printf.c (printf, _printf_r): Ditto.
        * libc/stdio/putchar.c (putchar): Ditto.
        * libc/stdio/puts.c (puts): Ditto.
        * libc/stdio/refill.c (__srefill): Ditto.
        * libc/stdio/scanf.c (scanf, _scanf_r): Ditto.
        * libc/stdio/vfscanf.c (VFSCANF, _VFSCANF_R): Ditto.
        * libc/stdio/viprintf.c (viprintf, _viprintf_r): Ditto.
        * libc/stdio/viscanf.c (viscanf, _viscanf_r): Ditto.
        * libc/stdio/vprintf.c (vprintf, _vprintf_r): Ditto.
        * libc/stdio/vscanf.c (vscanf, _vscanf_r): Ditto.
        * libc/stdio/wbuf.c (__swbuf): Ditto.
        * libc/stdio/wsetup.c (__swsetup): Ditto.
        * libc/stdlib/mallocr.c (malloc_stats): Ditto.
        * libc/stdlib/mstats.c (_mstats_r): Ditto.
        * libc/include/sys/reent.h (_REENT_SMALL_CHECK_INIT): Ditto.
        * libc/machine/powerpc/vfscanf.c (vfscanf): Ditto.
        * libc/stdio/fgetpos.c (_fgetpos_r): Removed unnecessary calls
        to _flockfile and _funlockfile; rely on locking in _ftell_r.
        * libc/stdio64/fgetpos64.c (_fgetpos64_r): Ditto (_ftello64_r).
        * libc/machine/powerpc/vfprintf.c (__sbprintf): Removed unnecessary
        initialision of _data field in FILE structure.
        * libc/machine/powerpc/vfprintf.c (VFPRINTF): Added CHECK_INIT() call.
2005-02-08 01:33:19 +00:00
Jeff Johnston d0bd3e6f56 2004-06-11 Antony King <antony.king@st.com>
* libc/include/sys/_types.h: Include <sys/lock.h> and change
        _flock_t to be of type _LOCK_RECURSIVE_T.
        * libc/include/sys/reent.h: (_REENT_INIT): Reformat.
        (_REENT_INIT_PTR): Ditto.  Use memset where appropriate.
        (_global_impure_ptr): New declaration.
        (_GLOBAL_REENT): Change to be _global_impure_ptr.
        * libc/include/sys/stdio.h: Include <sys/lock.h> and
        <sys/reent.h>.
        (_flockfile)[!_SINGLE_THREAD]: Add code for lock call.
        (_funlockfile)[!SINGLE_THREAD]: Ditto.
        * libc/reent/impure.c: Set _global_impure_ptr to _impure_ptr.
        * libc/stdio/fclose.c: Remove casting of fp lock to
        _LOCK_RECURSIVE_T.
        * libc/stdio/findfp.c: Ditto.
        * libc/stdio/fopen.c: Ditto.
        * libc/stdio/freopen.c: Ditto.
        * libc/stdio/vfprintf.c: Ditto.
        * libc/stdio64/fopen64.c: Ditto.
        * libc/stdlib/envlock.c: Add default stubs that use generic
        locking code.
        * libc/stdlib/mlock.c: Ditto.

        Jeff Johnston  <jjohnstn@redhat.com>
        * libc/sys/linux/sys/_types.h (__flock_mutex_t): New subtype.
        (_flock_t): Change to be a struct containing a single member
        named mutex which is of type __flock_mutex_t.
2004-06-11 20:37:10 +00:00
Jeff Johnston 05b315770a 2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* libc/stdio/asprintf.c libc/stdio/clearerr.c,
        libc/stdio/fclose.c libc/stdio/fcloseall.c libc/stdio/fdopen.c,
        libc/stdio/feof.c libc/stdio/ferror.c libc/stdio/fflush.c,
        libc/stdio/fgetc.c libc/stdio/fgetpos.c libc/stdio/fgets.c,
        libc/stdio/fileno.c libc/stdio/findfp.c libc/stdio/fiprintf.c,
        libc/stdio/flags.c libc/stdio/fopen.c libc/stdio/fprintf.c,
        libc/stdio/fputc.c libc/stdio/fputs.c libc/stdio/fread.c,
        libc/stdio/freopen.c libc/stdio/fscanf.c libc/stdio/fseek.c,
        libc/stdio/fseeko.c libc/stdio/fsetpos.c libc/stdio/ftell.c,
        libc/stdio/ftello.c libc/stdio/fvwrite.c libc/stdio/fwalk.c,
        libc/stdio/fwrite.c libc/stdio/getc.c libc/stdio/getc_u.c,
        libc/stdio/getchar.c libc/stdio/getchar_u.c,
        libc/stdio/getdelim.c libc/stdio/getline.c libc/stdio/gets.c,
        libc/stdio/getw.c libc/stdio/iprintf.c libc/stdio/local.h,
        libc/stdio/makebuf.c libc/stdio/mktemp.c libc/stdio/perror.c,
        libc/stdio/printf.c libc/stdio/putc.c libc/stdio/putc_u.c,
        libc/stdio/putchar.c libc/stdio/putchar_u.c libc/stdio/puts.c,
        libc/stdio/putw.c libc/stdio/refill.c libc/stdio/remove.c,
        libc/stdio/rename.c libc/stdio/rewind.c libc/stdio/rget.c,
        libc/stdio/scanf.c libc/stdio/setbuf.c libc/stdio/setbuffer.c,
        libc/stdio/setlinebuf.c libc/stdio/setvbuf.c,
        libc/stdio/siprintf.c libc/stdio/snprintf.c,
        libc/stdio/sprintf.c libc/stdio/sscanf.c libc/stdio/stdio.c,
        libc/stdio/tmpfile.c libc/stdio/tmpnam.c libc/stdio/ungetc.c,
        libc/stdio/vasprintf.c libc/stdio/vfieeefp.h,
        libc/stdio/vfprintf.c libc/stdio/vfscanf.c,
        libc/stdio/vprintf.c libc/stdio/vscanf.c,
        libc/stdio/vsnprintf.c libc/stdio/vsprintf.c,
        libc/stdio/vsscanf.c libc/stdio/wbuf.c,
        libc/stdio/wsetup.c: Perform minor formatting changes.  Move
        copyright notices to top of file, ensure that <_ansi.h> is
        included, be consistent with open parentheses, use _DEFUN macro,
        include "local.h" where needed, and remove various compiler
        warnings.
2004-04-23 20:01:55 +00:00
Jeff Johnston 47dcaf565d 2004-04-08 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* libc/stdio/fclose.c (_fclose_r): New function.
        * libc/stdio/freopen.c (_freopen_r): Call _fclose_r.
        * libc/stdio/fcloseall.c (_fcloseall_r): Call _fwalk_reent.
        * libc/stdio64/freopen64.c (_freopen64_r): Use _fclose_r.
        * libc/include/stdio.h (_fclose_r): New prototype.
        * libc/stdio/fopen.c: Fix typo in comment.

2004-04-08  Jeff Johnston  <jjohnstn@redhat.com>

        * libc/stdio/fwalk.c (_fwalk_reent): New version of _fwalk
        to handle _r reentrant functions.
2004-04-08 22:26:50 +00:00
Jeff Johnston 10dcf7e718 2004-03-25 Thomas Pfaff <tpfaff@gmx.net>
* libc/stdio/fclose.c (fclose): Protect file pointer list when
        releasing a file.
         * libc/stdio/fcloseall.c (_fcloseall_r): Close all files via
        fwalk.
        * libc/stdio/fdopen.c (_fdopen_r): Add calls to
        _flockfile/_funlockfile.
        * libc/stdio/findfp.c: Move __sfp_lock. Change __sfp_lock type
        to recursive.
        Change __lock_acquire/__lock_release calls for __sfp_lock to
        __sfp_lock_acquire/__sfp_lock_release throughout.
        (std): Make sure that file lock is only initialized once.
        (__sfp): Move _file initialization. Initialize file lock.
        (__sfp_lock_acquire): New function.
        (__sfp_lock_release): Ditto.
        (__fp_lock_all): Remove __sfp_lock_acquire call.
        (__fp_unlock_all): Remove __sfp_lock_release call.
        * libc/stdio/fopen.c (_fopen_r): Protect file pointer list.
        Add calls to _flockfile/_funlockfile. Remove
        __lock_init_recursive call.
        * libc/stdio/freopen.c (_freopen_r): Protect file pointer list.
        * libc/stdio/fwalk.c (__fwalk): New static function.
        (_fwalk): Protect file pointer list. Use __fwalk to walk through
        file pointers.
        * libc/stdio/local.h: Add defines for
        __sfp_lock_acquire/__sfp_lock_release when
        single threaded. Add function prototypes otherwise.
        * libc/stdio64/fdopen64.c (_fdopen64_r): Add calls to
        _flockfile/_funlockfile.
        * libc/stdio/fopen64.c (_fopen64_r): Protect file pointer list.
        Add calls to _flockfile/_funlockfile. Remove
         __lock_init_recursive call.
        * libc/stdio/freopen64.c (_freopen64_r): Protect file pointer
        list.
2004-03-25 22:29:18 +00:00
Jeff Johnston 403f752cb2 2004-01-19 Thomas Pfaff <tpfaff@gmx.net>
* libc/stdio/fclose.c (fclose): Release FILE as the last step.
        * libc/stdio/freopen.c (freopen): Ditto.
2004-01-19 21:30:34 +00:00
Jeff Johnston 6a15098793 2004-01-15 Thomas Pfaff <tpfaff@gmx.net>
* libc/stdio/fclose.c: Include sys/lock.h.
        (fclose): Destroy lock when file is closed.
        * libc/stdio/findfp.c (__sfp): Initialize file pointers _lock
        member.
        * libc/stdio/freopen.c: Include sys/lock.h.
        (_freopen_r): Destroy lock when file is closed.
        * libc/stdio/vfprintf.c (__sbprintf): Initialize file pointers
        _lock member.
2004-01-15 19:12:17 +00:00
Jeff Johnston 9fc9e1c916 2003-08-22 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/reent.h: Add _GLOBAL_REENT macro.
	* libc/stdio: Globally remove/replace all references to fp->_data.
	Replace with _REENT or _GLOBAL_REENT where appropriate.
	* libc/stdio/asprintf.c: Ditto.
	* libc/stdio/fclose.c: Ditto.
	* libc/stdio/fvwrite.c: Ditto.
	* libc/stdio/makebuf.c: Ditto.
	* libc/stdio/refill.c: Ditto.
	* libc/stdio/local.h: Ditto.
	* libc/stdio/setvbuf.c: Ditto.
	* libc/stdio/sscanf.c: Ditto.
	* libc/stdio/stdio.c: Ditto.
	* libc/stdio/ungetc.c: Ditto.
	* libc/stdio/vfscanf.c: Ditto.
	* libc/stdio/vsscanf.c: Ditto.
	* libc/stdio/fopen.c: Ditto.  Also use _fseek_r in _fopen_r.
	* libc/stdio/vasprintf.c: Ditto.  Also call _vfprintf_r directly.
	* libc/stdio/vsnprintf.c: Ditto.
	* libc/stdio/vsprintf.c: Ditto.
	* libc/stdio/fcloseall.c(fcloseall): Use _GLOBAL_REENT macro
	instead of _REENT to walk file list.
	* libc/stdio/fflush.c: Ditto.
	* libc/stdio/fgetpos.c: Add reentrant version and have regular
	version call reentrant version with _REENT argument.
	* libc/stdio/fsetpos.c: Ditto.
	* libc/stdio/fseek.c: Ditto.
	* libc/stdio/fseeko.c: Ditto.
	* libc/stdio/ftell.c: Ditto.
	* libc/stdio/ftello.c: Ditto.
	* libc/stdio/freopen.c: Ditto.
	* libc/stdio/findfp.c: Use _GLOBAL_REENT pointer when adding
	new files to chain.  Also use _GLOBAL_REENT pointer for
	cleaning up.
	* libc/stdio/fiprintf.c: Reformatted to minimize duplicate code.
	* libc/stdio/siprintf.c: Ditto.
	* libc/stdio/iprintf.c: Ditto.
	* libc/stdio/fprintf.c: Ditto.
	* libc/stdio/printf.c: Ditto.
	* libc/stdio/snprintf.c: Call _vfprintf_r directly.
	* libc/stdio/sprintf.c: Ditto.
	* libc/stdio/vprintf.c: Ditto.  Also add _REENT_ONLY check.
	* libc/stdio/rewind.c: Call _fseek_r directly.
	* libc/stdio/tmpfile.c: Call _fopen_r and _remove_r directly.
	* libc/stdio/vfprintf.c (_VFPRINTF_R): Change _r routines to use
	data pointer.
	(get_arg): Add extra struct _reent pointer argument.
	* libc/stdio64/fgetpos64.c: Add _r versions, remove any reference
	to fp->_data.
	* libc/stdio64/fopen64.c: Ditto.
	* libc/stdio64/freopen64.c: Ditto.
	* libc/stdio64/fsetpos64.c: Ditto.
	* libc/stdio64/ftello64.c: Ditto.
	* libc/stdio64/local64.h: Ditto.
	* libc/stdio64/stdio64.c: Ditto.
	* libc/stdio64/fseeko64.c: Ditto plus use _fstat_r instead of
	_fstat64_r for the meantime.
2003-08-22 18:52:25 +00:00
Thomas Fitzsimmons e71372faea * libc/include/sys/stdio.h: New file.
* libc/sys/linux/sys/stdio.h: New file.
	* libc/include/stdio.h: Add declarations for flockfile,
	ftrylockfile, and funlockfile.  Include <sys/stdio.h>.
	* libc/stdio/clearerr.c: Add file locking.
	* libc/stdio/fclose.c: Likewise.
	* libc/stdio/feof.c: Likewise.
	* libc/stdio/ferror.c: Likewise.
	* libc/stdio/fflush.c: Likewise.
	* libc/stdio/fgetc.c: Likewise.
	* libc/stdio/fgetpos.c: Likewise.
	* libc/stdio/fgets.c: Likewise.
	* libc/stdio/fileno.c: Likewise.
	* libc/stdio/fputc.c: Likewise.
	* libc/stdio/fputs.c: Likewise.
	* libc/stdio/fread.c: Likewise.
	* libc/stdio/freopen.c: Likewise.
	* libc/stdio/fseek.c: Likewise.
	* libc/stdio/ftell.c: Likewise.
	* libc/stdio/fwrite.c: Likewise.
	* libc/stdio/getc.c: Likewise.
	* libc/stdio/putc.c: Likewise.
	* libc/stdio/setvbuf.c: Likewise.
	* libc/stdio/ungetc.c: Likewise.
	* libc/stdio/vfprintf.c: Likewise.
2002-05-08 00:12:49 +00:00
Christopher Faylor 8a0efa53e4 import newlib-2000-02-17 snapshot 2000-02-17 19:39:52 +00:00