2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* 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,
|
2020-01-29 02:54:53 +08:00
|
|
|
* and/or other materials related to such
|
2000-02-18 03:39:52 +08:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @(#)stdio.h 5.3 (Berkeley) 3/15/86
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: to fit things in six character monocase externals, the
|
|
|
|
* stdio code uses the prefix `__s' for stdio objects, typically
|
|
|
|
* followed by a three-character attempt at a mnemonic.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STDIO_H_
|
|
|
|
#define _STDIO_H_
|
|
|
|
|
|
|
|
#include "_ansi.h"
|
|
|
|
|
|
|
|
#define _FSTDIO /* ``function stdio'' */
|
|
|
|
|
|
|
|
#define __need_size_t
|
2012-11-01 19:51:12 +08:00
|
|
|
#define __need_NULL
|
2014-01-07 04:59:38 +08:00
|
|
|
#include <sys/cdefs.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-08-12 16:16:52 +08:00
|
|
|
/* typedef only __gnuc_va_list, used throughout the header */
|
2000-02-18 03:39:52 +08:00
|
|
|
#define __need___va_list
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2016-08-12 16:16:52 +08:00
|
|
|
/* typedef va_list only when required */
|
|
|
|
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#ifndef _VA_LIST_DEFINED
|
|
|
|
typedef __gnuc_va_list va_list;
|
|
|
|
#define _VA_LIST_DEFINED
|
|
|
|
#endif
|
|
|
|
#else /* !__GNUC__ */
|
|
|
|
#include <stdarg.h>
|
|
|
|
#endif
|
|
|
|
#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/*
|
2002-07-18 07:25:44 +08:00
|
|
|
* <sys/reent.h> defines __FILE, _fpos_t.
|
2000-02-18 03:39:52 +08:00
|
|
|
* They must be defined there because struct _reent needs them (and we don't
|
|
|
|
* want reent.h to include this file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/reent.h>
|
2002-06-22 02:29:23 +08:00
|
|
|
#include <sys/types.h>
|
2002-05-08 08:12:49 +08:00
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_BEGIN_STD_C
|
|
|
|
|
2015-03-06 01:15:24 +08:00
|
|
|
#if !defined(__FILE_defined)
|
2002-07-18 07:25:44 +08:00
|
|
|
typedef __FILE FILE;
|
2015-03-06 01:15:24 +08:00
|
|
|
# define __FILE_defined
|
|
|
|
#endif
|
2002-07-18 07:25:44 +08:00
|
|
|
|
2003-03-08 04:41:49 +08:00
|
|
|
#ifdef __CYGWIN__
|
|
|
|
typedef _fpos64_t fpos_t;
|
|
|
|
#else
|
|
|
|
typedef _fpos_t fpos_t;
|
2002-07-18 07:25:44 +08:00
|
|
|
#ifdef __LARGE64_FILES
|
|
|
|
typedef _fpos64_t fpos64_t;
|
|
|
|
#endif
|
2003-03-08 04:41:49 +08:00
|
|
|
#endif /* !__CYGWIN__ */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2002-06-22 02:29:23 +08:00
|
|
|
#include <sys/stdio.h>
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#define __SLBF 0x0001 /* line buffered */
|
|
|
|
#define __SNBF 0x0002 /* unbuffered */
|
|
|
|
#define __SRD 0x0004 /* OK to read */
|
|
|
|
#define __SWR 0x0008 /* OK to write */
|
|
|
|
/* RD and WR are never simultaneously asserted */
|
|
|
|
#define __SRW 0x0010 /* open for reading & writing */
|
|
|
|
#define __SEOF 0x0020 /* found EOF */
|
|
|
|
#define __SERR 0x0040 /* found error */
|
|
|
|
#define __SMBF 0x0080 /* _buf is from malloc */
|
|
|
|
#define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */
|
|
|
|
#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
|
|
|
|
#define __SOPT 0x0400 /* do fseek() optimisation */
|
|
|
|
#define __SNPT 0x0800 /* do not do fseek() optimisation */
|
|
|
|
#define __SOFF 0x1000 /* set iff _offset is in fact correct */
|
2008-12-10 Corinna Vinschen <corinna@vinschen.de>
Implement basic wide char stdio functionality, based on FreeBSD.
* libc/include/stdio.h (__SORD): Define.
(__SWID): Define.
* libc/include/wchar.h: Add declarations for new wide char functions.
(getwc): Define as macro.
(getwchar): Ditto.
(putwc): Ditto.
(putwchar): Ditto.
* libc/include/sys/reent.h (struct __sFILE): Add _mbstate member.
(struct __sFILE64): Ditto.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add fgetwc.c, fgetws.c,
fputwc.c, fputws.c, fwide.c, getwc.c, getwchar.c, putwc.c, putwchar.c
and ungetwc.c.
(CHEWOUT_FILES): Add fgetwc.def, fgetws.def, fputwc.def, fputws.def,
fwide.def, getwc.def, getwchar.def, putwc.def, putwchar.def and
ungetwc.def.
Add header dependency rules for the new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fgetwc.c: New file, implementing fgetwc and _fgetwc_r.
* libc/stdio/fgetws.c: New file, implementing fgetws and _fgetws_r.
* libc/stdio/findfp.c (std): Initialize FILE's _mbstate member.
(__sfmoreglue): Ditto.
* libc/stdio/fputs.c (_fputs_r): Set stream orientation.
* libc/stdio/fputwc.c: New file, implementing fputwc and _fputwc_r.
* libc/stdio/fputws.c: New file, implementing fputws and _fputws_r.
* libc/stdio/fread.c (_fread_r): Set stream orientation.
* libc/stdio/freopen.c (_freopen_r): Reset stream orientation. Reset
_mbstate.
* libc/stdio/fseek.c (_fseek_r): Reset _mbstate.
* libc/stdio/fwide.c: New file, implementing fwide and _fwide_r.
* libc/stdio/fwrite.c (_fwrite_r): Set stream orientation.
* libc/stdio/getwc.c: New file, implementing getwc and _getwc_r.
* libc/stdio/getwchar.c: New file, implementing getwchar and
_getwchar_r.
* libc/stdio/local.h (ORIENT): New macro.
* libc/stdio/puts.c (_puts_r): Set stream orientation.
* libc/stdio/putwc.c: New file, implementing putwc and _putwc_r.
* libc/stdio/putwchar.c: New file, implementing putwchar and
_putwchar_r.
* libc/stdio/refill.c (__srefill_r): Set stream orientation.
* libc/stdio/stdio.tex: Add documentation for new functions.
* libc/stdio/ungetc.c (_ungetc_r): Set stream orientation.
* libc/stdio/ungetwc.c: New file, implementing ungetwc and _ungetwc_r.
* libc/stdio/vfscanf.c (__SVFSCANF_R): Set stream orientation.
* libc/stdio/wbuf.c (__swbuf_r): Ditto.
2008-12-11 07:43:12 +08:00
|
|
|
#define __SORD 0x2000 /* true => stream orientation (byte/wide) decided */
|
2003-05-13 17:46:48 +08:00
|
|
|
#if defined(__CYGWIN__)
|
2002-07-18 07:25:44 +08:00
|
|
|
# define __SCLE 0x4000 /* convert line endings CR/LF <-> NL */
|
2000-05-03 11:57:19 +08:00
|
|
|
#endif
|
2002-07-18 07:25:44 +08:00
|
|
|
#define __SL64 0x8000 /* is 64-bit offset large file */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2008-12-10 Corinna Vinschen <corinna@vinschen.de>
Implement basic wide char stdio functionality, based on FreeBSD.
* libc/include/stdio.h (__SORD): Define.
(__SWID): Define.
* libc/include/wchar.h: Add declarations for new wide char functions.
(getwc): Define as macro.
(getwchar): Ditto.
(putwc): Ditto.
(putwchar): Ditto.
* libc/include/sys/reent.h (struct __sFILE): Add _mbstate member.
(struct __sFILE64): Ditto.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add fgetwc.c, fgetws.c,
fputwc.c, fputws.c, fwide.c, getwc.c, getwchar.c, putwc.c, putwchar.c
and ungetwc.c.
(CHEWOUT_FILES): Add fgetwc.def, fgetws.def, fputwc.def, fputws.def,
fwide.def, getwc.def, getwchar.def, putwc.def, putwchar.def and
ungetwc.def.
Add header dependency rules for the new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fgetwc.c: New file, implementing fgetwc and _fgetwc_r.
* libc/stdio/fgetws.c: New file, implementing fgetws and _fgetws_r.
* libc/stdio/findfp.c (std): Initialize FILE's _mbstate member.
(__sfmoreglue): Ditto.
* libc/stdio/fputs.c (_fputs_r): Set stream orientation.
* libc/stdio/fputwc.c: New file, implementing fputwc and _fputwc_r.
* libc/stdio/fputws.c: New file, implementing fputws and _fputws_r.
* libc/stdio/fread.c (_fread_r): Set stream orientation.
* libc/stdio/freopen.c (_freopen_r): Reset stream orientation. Reset
_mbstate.
* libc/stdio/fseek.c (_fseek_r): Reset _mbstate.
* libc/stdio/fwide.c: New file, implementing fwide and _fwide_r.
* libc/stdio/fwrite.c (_fwrite_r): Set stream orientation.
* libc/stdio/getwc.c: New file, implementing getwc and _getwc_r.
* libc/stdio/getwchar.c: New file, implementing getwchar and
_getwchar_r.
* libc/stdio/local.h (ORIENT): New macro.
* libc/stdio/puts.c (_puts_r): Set stream orientation.
* libc/stdio/putwc.c: New file, implementing putwc and _putwc_r.
* libc/stdio/putwchar.c: New file, implementing putwchar and
_putwchar_r.
* libc/stdio/refill.c (__srefill_r): Set stream orientation.
* libc/stdio/stdio.tex: Add documentation for new functions.
* libc/stdio/ungetc.c (_ungetc_r): Set stream orientation.
* libc/stdio/ungetwc.c: New file, implementing ungetwc and _ungetwc_r.
* libc/stdio/vfscanf.c (__SVFSCANF_R): Set stream orientation.
* libc/stdio/wbuf.c (__swbuf_r): Ditto.
2008-12-11 07:43:12 +08:00
|
|
|
/* _flags2 flags */
|
2014-12-16 02:22:56 +08:00
|
|
|
#define __SNLK 0x0001 /* stdio functions do not lock streams themselves */
|
2008-12-10 Corinna Vinschen <corinna@vinschen.de>
Implement basic wide char stdio functionality, based on FreeBSD.
* libc/include/stdio.h (__SORD): Define.
(__SWID): Define.
* libc/include/wchar.h: Add declarations for new wide char functions.
(getwc): Define as macro.
(getwchar): Ditto.
(putwc): Ditto.
(putwchar): Ditto.
* libc/include/sys/reent.h (struct __sFILE): Add _mbstate member.
(struct __sFILE64): Ditto.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add fgetwc.c, fgetws.c,
fputwc.c, fputws.c, fwide.c, getwc.c, getwchar.c, putwc.c, putwchar.c
and ungetwc.c.
(CHEWOUT_FILES): Add fgetwc.def, fgetws.def, fputwc.def, fputws.def,
fwide.def, getwc.def, getwchar.def, putwc.def, putwchar.def and
ungetwc.def.
Add header dependency rules for the new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fgetwc.c: New file, implementing fgetwc and _fgetwc_r.
* libc/stdio/fgetws.c: New file, implementing fgetws and _fgetws_r.
* libc/stdio/findfp.c (std): Initialize FILE's _mbstate member.
(__sfmoreglue): Ditto.
* libc/stdio/fputs.c (_fputs_r): Set stream orientation.
* libc/stdio/fputwc.c: New file, implementing fputwc and _fputwc_r.
* libc/stdio/fputws.c: New file, implementing fputws and _fputws_r.
* libc/stdio/fread.c (_fread_r): Set stream orientation.
* libc/stdio/freopen.c (_freopen_r): Reset stream orientation. Reset
_mbstate.
* libc/stdio/fseek.c (_fseek_r): Reset _mbstate.
* libc/stdio/fwide.c: New file, implementing fwide and _fwide_r.
* libc/stdio/fwrite.c (_fwrite_r): Set stream orientation.
* libc/stdio/getwc.c: New file, implementing getwc and _getwc_r.
* libc/stdio/getwchar.c: New file, implementing getwchar and
_getwchar_r.
* libc/stdio/local.h (ORIENT): New macro.
* libc/stdio/puts.c (_puts_r): Set stream orientation.
* libc/stdio/putwc.c: New file, implementing putwc and _putwc_r.
* libc/stdio/putwchar.c: New file, implementing putwchar and
_putwchar_r.
* libc/stdio/refill.c (__srefill_r): Set stream orientation.
* libc/stdio/stdio.tex: Add documentation for new functions.
* libc/stdio/ungetc.c (_ungetc_r): Set stream orientation.
* libc/stdio/ungetwc.c: New file, implementing ungetwc and _ungetwc_r.
* libc/stdio/vfscanf.c (__SVFSCANF_R): Set stream orientation.
* libc/stdio/wbuf.c (__swbuf_r): Ditto.
2008-12-11 07:43:12 +08:00
|
|
|
#define __SWID 0x2000 /* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* The following three definitions are for ANSI C, which took them
|
|
|
|
* from System V, which stupidly took internal interface macros and
|
|
|
|
* made them official arguments to setvbuf(), without renaming them.
|
|
|
|
* Hence, these ugly _IOxxx names are *supposed* to appear in user code.
|
|
|
|
*
|
|
|
|
* Although these happen to match their counterparts above, the
|
|
|
|
* implementation does not rely on that (so these could be renumbered).
|
|
|
|
*/
|
|
|
|
#define _IOFBF 0 /* setvbuf should set fully buffered */
|
|
|
|
#define _IOLBF 1 /* setvbuf should set line buffered */
|
|
|
|
#define _IONBF 2 /* setvbuf should set unbuffered */
|
|
|
|
|
|
|
|
#define EOF (-1)
|
|
|
|
|
2001-08-03 06:28:40 +08:00
|
|
|
#ifdef __BUFSIZ__
|
|
|
|
#define BUFSIZ __BUFSIZ__
|
|
|
|
#else
|
|
|
|
#define BUFSIZ 1024
|
|
|
|
#endif
|
|
|
|
|
2001-02-01 04:11:48 +08:00
|
|
|
#ifdef __FOPEN_MAX__
|
|
|
|
#define FOPEN_MAX __FOPEN_MAX__
|
|
|
|
#else
|
|
|
|
#define FOPEN_MAX 20
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __FILENAME_MAX__
|
|
|
|
#define FILENAME_MAX __FILENAME_MAX__
|
|
|
|
#else
|
|
|
|
#define FILENAME_MAX 1024
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __L_tmpnam__
|
|
|
|
#define L_tmpnam __L_tmpnam__
|
|
|
|
#else
|
|
|
|
#define L_tmpnam FILENAME_MAX
|
|
|
|
#endif
|
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __BSD_VISIBLE || __XSI_VISIBLE
|
2000-02-18 03:39:52 +08:00
|
|
|
#define P_tmpdir "/tmp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SEEK_SET
|
|
|
|
#define SEEK_SET 0 /* set file offset to offset */
|
|
|
|
#endif
|
|
|
|
#ifndef SEEK_CUR
|
|
|
|
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
|
|
|
#endif
|
|
|
|
#ifndef SEEK_END
|
|
|
|
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TMP_MAX 26
|
|
|
|
|
2002-05-17 Jeff Johnston <jjohnstn@redhat.com>
* Makefile.am: Copy and install headers from sys/machine/include
directory. Also pass $toollibdir to lower-level directories.
* Makefile.in: Regenerated.
* libc/include/stdio.h[!_REENT_ONLY]: Change stdin, stdout, and
stderr to use _REENT macro instead of _impure_ptr directly.
* libc/include/sys/config.h[__i386__][__linux__]: Define
__DYNAMIC_REENT__.
* libc/include/sys/reent.h[!_REENT_ONLY]: Change _REENT macro to be
call to __getreent() function if !__SINGLE_THREAD__ and
__DYNAMIC_REENT__ is set.
* libc/reent/Makefile.am: Add support for getreent.c.
* libc/reent/Makefile.in: Regenerated.
* libc/string/strerror.c: Add check if EOPNOTSUPP and ENOTSUP are same.
* libc/sys/linux/Makefile.am: Add support for new files.
* libc/sys/linux/configure.in: Add $EXTRA_DIRS variable.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/configure: Ditto.
* libc/sys/linux/io.c: Add poll syscall. Also weak-alias
__close, __read, __write, __poll, __open, __lseek, __fcntl from
their __libc_ counterparts.
* libc/sys/linux/io64.c: Add __libc_ prefix to lseek64 and open64
and weak-alias to regular names.
* libc/sys/linux/pread64.c: Rename to __libc_pread64 and weak-alias
to pread64 and __pread64.
* libc/sys/linux/process.c: Weak_alias __libc_getpid to __getpid.
* libc/sys/linux/pwrite64.c: Rename to __libc_pwrite64 and
weak-alias to pwrite64.
* libc/sys/linux/sched.c: Weak-alias __libc_sched_getparam,
__libc_sched_getscheduler, __libc_sched_get_priority_max,
__libc_sched_get_priority_min, and __libc_sched_setschedule to
name with __ instead of __libc_.
* libc/sys/linux/siglongjmp.c: Include <machine/weakalias.h>.
Rename siglongjmp to __libc_siglongjmp and weak-alias to siglongjmp.
Call __libc_longjmp instead of longjmp, from __libc_siglongjmp.
* libc/sys/linux/signal.c: Rename raise to __libc_raise and weak-alias
to raise.
* libc/sys/linux/socket.c: Weak-alias __libc_connect to __connect and
__libc_send to __send.
* libc/sys/linux/time.c: Weak-alias __libc_gettimeofday to
__gettimeofday.
* libc/sys/linux/wait.c: Rename wait to __libc_wait and weak-alias
it to wait. Rename wait3 to __libc_wait3 and weak-alias it to wait3.
* libc/sys/linux/include/setjmp.h: Use __jmp_buf in sigjmp_buf
type and typedef __jmp_buf to jmp_buf.
* libc/sys/linux/machine/i386/Makefile.am: Add syscalls.c and
setjmp.S.
* libc/sys/linux/machine/i386/Makefile.in: Regenerated.
* libc/sys/linux/machine/i386/crt0.c: Add support to clear .bss
section.
* libc/sys/linux/machine/i386/socketcall.h: Change to use __libc_
prefix for function macros and then use weak_alias() to regular names.
* libc/sys/linux/machine/i386/syscall.h: Ditto.
* libc/sys/linux/sys/errno.h: Define EOPNOTSUP to be ENOTSUP.
* libc/sys/linux/sys/stdio.h: Define _flockfile and _funlockfile
to be flockfile() and funlockfile() respectively.
* libc/sys/linux/sys/types.h
* libc/reent/getreent.c: New file.
* libc/sys/linux/flockfile.c: Ditto.
* libc/sys/linux/funlockfile.c: Ditto.
* libc/sys/linux/getreent.c: Ditto.
* libc/sys/linux/pread.c: Ditto.
* libc/sys/linux/pwrite.c: Ditto.
* libc/sys/linux/raise.c: Ditto.
* libc/sys/linux/system.c: Ditto.
* libc/sys/linux/tcdrain.c: Ditto.
* libc/sys/linux/machine/i386/i386mach.h: Ditto.
* libc/sys/linux/machine/i386/setjmp.S: Ditto.
* libc/sys/linux/machine/i386/syscalls.c: Ditto.
* libc/sys/linux/machine/i386/weakalias.h: Ditto.
* libc/sys/linux/machine/i386/include/setjmp.h: Ditto.
2002-05-18 07:39:39 +08:00
|
|
|
#define stdin (_REENT->_stdin)
|
|
|
|
#define stdout (_REENT->_stdout)
|
|
|
|
#define stderr (_REENT->_stderr)
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#define _stdin_r(x) ((x)->_stdin)
|
|
|
|
#define _stdout_r(x) ((x)->_stdout)
|
|
|
|
#define _stderr_r(x) ((x)->_stderr)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions defined in ANSI C standard.
|
|
|
|
*/
|
|
|
|
|
* libc/include/stdio.h (__VALIST): Guard against multiple definition.
* libc/include/wchar.h: Include stdarg.h.
(__VALIST): Define conditionally.
(fwprintf, swprintf, vfwprintf, vswprintf, vwprintf, wprintf: Declare.
(_fwprintf_r, _swprintf_r, _vfwprintf_r, _vswprintf_r, _vwprintf_r,
_wprintf_r): Declare.
* libc/stdio/Makefile.am: Add new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fwprintf.c: New file.
* libc/stdio/local.h (_svfwprintf_r, _svfiwprintf_r): Declare.
(__CH_CLASS, __STATE, __ACTION): Move definition from vfprintf.c here
and move to the __ namespace.
(__chclass, __state_table, __action_table): Declare.
* libc/stdio/stdio.tex: Add new documentation references.
* libc/stdio/swprintf.c: New file.
* libc/stdio/vfprintf.c (__SPRINT): New macro to call the right
__sprint_r function according to compilation unit. Use throughout.
(__ssprint_r): Rename STRING_ONLY variant from __sprint_r.
Make externaly available. Only define if INTEGER_ONLY is defined.
(__sprint_r): Make externaly available. Only define if INTEGER_ONLY
is defined. Handle stream orientation.
(__sbprintf): Copy FILE's _flags2 member as well.
(__chclass, __state_table, __action_table): Prepend __ to name and
make externally available.
* libc/stdio/vfwprintf.c: New file.
* libc/stdio/vswprintf.c: New file.
* libc/stdio/vwprintf.c: New file.
* libc/stdio/wprintf.c: New file.
2009-03-06 17:55:52 +08:00
|
|
|
#ifndef __VALIST
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define __VALIST __gnuc_va_list
|
|
|
|
#else
|
|
|
|
#define __VALIST char*
|
|
|
|
#endif
|
* libc/include/stdio.h (__VALIST): Guard against multiple definition.
* libc/include/wchar.h: Include stdarg.h.
(__VALIST): Define conditionally.
(fwprintf, swprintf, vfwprintf, vswprintf, vwprintf, wprintf: Declare.
(_fwprintf_r, _swprintf_r, _vfwprintf_r, _vswprintf_r, _vwprintf_r,
_wprintf_r): Declare.
* libc/stdio/Makefile.am: Add new files.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fwprintf.c: New file.
* libc/stdio/local.h (_svfwprintf_r, _svfiwprintf_r): Declare.
(__CH_CLASS, __STATE, __ACTION): Move definition from vfprintf.c here
and move to the __ namespace.
(__chclass, __state_table, __action_table): Declare.
* libc/stdio/stdio.tex: Add new documentation references.
* libc/stdio/swprintf.c: New file.
* libc/stdio/vfprintf.c (__SPRINT): New macro to call the right
__sprint_r function according to compilation unit. Use throughout.
(__ssprint_r): Rename STRING_ONLY variant from __sprint_r.
Make externaly available. Only define if INTEGER_ONLY is defined.
(__sprint_r): Make externaly available. Only define if INTEGER_ONLY
is defined. Handle stream orientation.
(__sbprintf): Copy FILE's _flags2 member as well.
(__chclass, __state_table, __action_table): Prepend __ to name and
make externally available.
* libc/stdio/vfwprintf.c: New file.
* libc/stdio/vswprintf.c: New file.
* libc/stdio/vwprintf.c: New file.
* libc/stdio/wprintf.c: New file.
2009-03-06 17:55:52 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2016-05-21 05:55:50 +08:00
|
|
|
#if __POSIX_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
char * ctermid (char *);
|
2016-05-21 05:55:50 +08:00
|
|
|
#endif
|
2018-11-29 18:22:42 +08:00
|
|
|
#if __GNU_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)
|
2017-12-04 13:54:48 +08:00
|
|
|
char * cuserid (char *);
|
2016-05-21 05:55:50 +08:00
|
|
|
#endif
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE * tmpfile (void);
|
|
|
|
char * tmpnam (char *);
|
2014-05-09 22:25:32 +08:00
|
|
|
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
2018-09-28 17:12:48 +08:00
|
|
|
char * tempnam (const char *, const char *) __malloc_like __result_use_check;
|
2017-12-04 13:54:48 +08:00
|
|
|
#endif
|
|
|
|
int fclose (FILE *);
|
|
|
|
int fflush (FILE *);
|
|
|
|
FILE * freopen (const char *__restrict, const char *__restrict, FILE *__restrict);
|
|
|
|
void setbuf (FILE *__restrict, char *__restrict);
|
|
|
|
int setvbuf (FILE *__restrict, char *__restrict, int, size_t);
|
|
|
|
int fprintf (FILE *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
int fscanf (FILE *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)));
|
|
|
|
int printf (const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 1, 2)));
|
|
|
|
int scanf (const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 1, 2)));
|
|
|
|
int sscanf (const char *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)));
|
|
|
|
int vfprintf (FILE *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
int vprintf (const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 1, 0)));
|
|
|
|
int vsprintf (char *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
int fgetc (FILE *);
|
|
|
|
char * fgets (char *__restrict, int, FILE *__restrict);
|
|
|
|
int fputc (int, FILE *);
|
|
|
|
int fputs (const char *__restrict, FILE *__restrict);
|
|
|
|
int getc (FILE *);
|
|
|
|
int getchar (void);
|
|
|
|
char * gets (char *);
|
|
|
|
int putc (int, FILE *);
|
|
|
|
int putchar (int);
|
|
|
|
int puts (const char *);
|
|
|
|
int ungetc (int, FILE *);
|
|
|
|
size_t fread (void *__restrict, size_t _size, size_t _n, FILE *__restrict);
|
|
|
|
size_t fwrite (const void *__restrict , size_t _size, size_t _n, FILE *);
|
2021-11-09 11:22:27 +08:00
|
|
|
#ifdef _LIBC
|
2017-12-04 13:54:48 +08:00
|
|
|
int fgetpos (FILE *, _fpos_t *);
|
2003-03-15 02:39:05 +08:00
|
|
|
#else
|
2017-12-04 13:54:48 +08:00
|
|
|
int fgetpos (FILE *__restrict, fpos_t *__restrict);
|
2003-03-15 02:39:05 +08:00
|
|
|
#endif
|
2017-12-04 13:54:48 +08:00
|
|
|
int fseek (FILE *, long, int);
|
2021-11-09 11:22:27 +08:00
|
|
|
#ifdef _LIBC
|
2017-12-04 13:54:48 +08:00
|
|
|
int fsetpos (FILE *, const _fpos_t *);
|
2003-03-15 02:39:05 +08:00
|
|
|
#else
|
2017-12-04 13:54:48 +08:00
|
|
|
int fsetpos (FILE *, const fpos_t *);
|
|
|
|
#endif
|
|
|
|
long ftell ( FILE *);
|
|
|
|
void rewind (FILE *);
|
|
|
|
void clearerr (FILE *);
|
|
|
|
int feof (FILE *);
|
|
|
|
int ferror (FILE *);
|
|
|
|
void perror (const char *);
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef _REENT_ONLY
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE * fopen (const char *__restrict _name, const char *__restrict _type);
|
|
|
|
int sprintf (char *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
int remove (const char *);
|
|
|
|
int rename (const char *, const char *);
|
2021-11-09 11:22:27 +08:00
|
|
|
#ifdef _LIBC
|
2017-12-04 13:54:48 +08:00
|
|
|
int _rename (const char *, const char *);
|
2012-08-08 19:04:18 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
2016-03-21 03:21:59 +08:00
|
|
|
#if __LARGEFILE_VISIBLE || __POSIX_VISIBLE >= 200112
|
2021-11-09 11:22:27 +08:00
|
|
|
#ifdef _LIBC
|
2017-12-04 13:54:48 +08:00
|
|
|
int fseeko (FILE *, _off_t, int);
|
|
|
|
_off_t ftello (FILE *);
|
2003-03-15 02:39:05 +08:00
|
|
|
#else
|
2017-12-04 13:54:48 +08:00
|
|
|
int fseeko (FILE *, off_t, int);
|
|
|
|
off_t ftello (FILE *);
|
2003-03-15 02:39:05 +08:00
|
|
|
#endif
|
2009-10-21 00:44:11 +08:00
|
|
|
#endif
|
2014-05-09 16:42:39 +08:00
|
|
|
#if __GNU_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
int fcloseall (void);
|
2014-05-09 16:42:39 +08:00
|
|
|
#endif
|
2004-11-24 08:45:41 +08:00
|
|
|
#ifndef _REENT_ONLY
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __ISO_C_VISIBLE >= 1999
|
2017-12-04 13:54:48 +08:00
|
|
|
int snprintf (char *__restrict, size_t, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int vsnprintf (char *__restrict, size_t, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int vfscanf (FILE *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)));
|
|
|
|
int vscanf (const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 1, 0)));
|
|
|
|
int vsscanf (const char *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)));
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif
|
|
|
|
#if __GNU_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
int asprintf (char **__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
int vasprintf (char **, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif
|
|
|
|
#if __MISC_VISIBLE /* Newlib-specific */
|
2017-12-04 13:54:48 +08:00
|
|
|
int asiprintf (char **, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
char * asniprintf (char *, size_t *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
char * asnprintf (char *__restrict, size_t *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
2007-08-03 04:23:06 +08:00
|
|
|
#ifndef diprintf
|
2017-12-04 13:54:48 +08:00
|
|
|
int diprintf (int, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
#endif
|
|
|
|
int fiprintf (FILE *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
int fiscanf (FILE *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)));
|
|
|
|
int iprintf (const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 1, 2)));
|
|
|
|
int iscanf (const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 1, 2)));
|
|
|
|
int siprintf (char *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
int siscanf (const char *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)));
|
|
|
|
int sniprintf (char *, size_t, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int vasiprintf (char **, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
char * vasniprintf (char *, size_t *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
char * vasnprintf (char *, size_t *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int vdiprintf (int, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
int vfiprintf (FILE *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
int vfiscanf (FILE *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)));
|
|
|
|
int viprintf (const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 1, 0)));
|
|
|
|
int viscanf (const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 1, 0)));
|
|
|
|
int vsiprintf (char *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
int vsiscanf (const char *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)));
|
|
|
|
int vsniprintf (char *, size_t, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif /* __MISC_VISIBLE */
|
2007-05-04 10:55:16 +08:00
|
|
|
#endif /* !_REENT_ONLY */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
/*
|
2007-08-03 04:23:06 +08:00
|
|
|
* Routines in POSIX 1003.1:2001.
|
2000-02-18 03:39:52 +08:00
|
|
|
*/
|
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __POSIX_VISIBLE
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef _REENT_ONLY
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE * fdopen (int, const char *);
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
2017-12-04 13:54:48 +08:00
|
|
|
int fileno (FILE *);
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif
|
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE >= 199209
|
2017-12-04 13:54:48 +08:00
|
|
|
int pclose (FILE *);
|
|
|
|
FILE * popen (const char *, const char *);
|
2016-02-05 01:07:44 +08:00
|
|
|
#endif
|
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __BSD_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
void setbuffer (FILE *, char *, int);
|
|
|
|
int setlinebuf (FILE *);
|
2016-02-05 01:07:44 +08:00
|
|
|
#endif
|
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __MISC_VISIBLE || (__XSI_VISIBLE && __POSIX_VISIBLE < 200112)
|
2017-12-04 13:54:48 +08:00
|
|
|
int getw (FILE *);
|
|
|
|
int putw (int, FILE *);
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif
|
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
int getc_unlocked (FILE *);
|
|
|
|
int getchar_unlocked (void);
|
|
|
|
void flockfile (FILE *);
|
|
|
|
int ftrylockfile (FILE *);
|
|
|
|
void funlockfile (FILE *);
|
|
|
|
int putc_unlocked (int, FILE *);
|
|
|
|
int putchar_unlocked (int);
|
2016-02-05 01:07:44 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2007-08-03 04:23:06 +08:00
|
|
|
/*
|
|
|
|
* Routines in POSIX 1003.1:200x.
|
|
|
|
*/
|
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __POSIX_VISIBLE >= 200809
|
2007-08-03 04:23:06 +08:00
|
|
|
# ifndef _REENT_ONLY
|
|
|
|
# ifndef dprintf
|
2017-12-04 13:54:48 +08:00
|
|
|
int dprintf (int, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
2007-08-03 04:23:06 +08:00
|
|
|
# endif
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE * fmemopen (void *__restrict, size_t, const char *__restrict);
|
2007-08-03 04:23:06 +08:00
|
|
|
/* getdelim - see __getdelim for now */
|
|
|
|
/* getline - see __getline for now */
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE * open_memstream (char **, size_t *);
|
|
|
|
int vdprintf (int, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
2007-08-03 04:23:06 +08:00
|
|
|
# endif
|
|
|
|
#endif
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __ATFILE_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
int renameat (int, const char *, int, const char *);
|
2017-08-17 21:12:15 +08:00
|
|
|
# ifdef __CYGWIN__
|
2017-12-04 13:54:48 +08:00
|
|
|
int renameat2 (int, const char *, int, const char *, unsigned int);
|
2017-08-17 21:12:15 +08:00
|
|
|
# endif
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif
|
2007-08-03 04:23:06 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* Recursive versions of the above.
|
|
|
|
*/
|
|
|
|
|
2017-12-04 13:54:48 +08:00
|
|
|
int _asiprintf_r (struct _reent *, char **, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 5)));
|
|
|
|
char * _asnprintf_r (struct _reent *, char *__restrict, size_t *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 5)));
|
|
|
|
int _asprintf_r (struct _reent *, char **__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int _diprintf_r (struct _reent *, int, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int _dprintf_r (struct _reent *, int, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int _fclose_r (struct _reent *, FILE *);
|
|
|
|
int _fcloseall_r (struct _reent *);
|
|
|
|
FILE * _fdopen_r (struct _reent *, int, const char *);
|
|
|
|
int _fflush_r (struct _reent *, FILE *);
|
|
|
|
int _fgetc_r (struct _reent *, FILE *);
|
|
|
|
int _fgetc_unlocked_r (struct _reent *, FILE *);
|
|
|
|
char * _fgets_r (struct _reent *, char *__restrict, int, FILE *__restrict);
|
|
|
|
char * _fgets_unlocked_r (struct _reent *, char *__restrict, int, FILE *__restrict);
|
2021-11-09 11:22:27 +08:00
|
|
|
#ifdef _LIBC
|
2017-12-04 13:54:48 +08:00
|
|
|
int _fgetpos_r (struct _reent *, FILE *__restrict, _fpos_t *__restrict);
|
|
|
|
int _fsetpos_r (struct _reent *, FILE *, const _fpos_t *);
|
2008-12-11 Craig Howland <howland@LGSInnovations.com>
* libc/include/sys/lock.h: Add void cast to avoid "statement has no
effect" warnings from gcc.
* libc/include/sys/stdio.h: Ditto.
* libc/include/sys/time.h: Correct gettimeofday() prototype.
* libc/stdlib/__exp10.c: Add #include "std.h" for function prototype.
* libc/stdlib/__ten_mu.c: Ditto.
* libc/stdlib/std.h: Correct __exp10's ANSI prototype.
* libc/stdlib/ldtoa.c: Change eiisinf definition to ANSI form. (Are
already others in file without _ansi method, so did not bother.)
* libc/stdlib/system.c: Use _ansi forms for function prototypes and
definitions.
* libc/time/mktime.c: Ditto.
* libc/misc/__dprintf.c: Ditto.
* libc/include/stdio.h: Add function prototypes for _fgetc_r,
_fgetpos_r, _fsetpos_r, _freopen_r, _rewind_r, freopen64, _freopen64_r,
_funopen_r, and _fopencookie_r.
* libc/include/reent.h: Add function prototype for _stat64_r, align
_execve_r prototype with POSIX definition for execve.
* libc/reent/execr.c: Align function prototype with POSIX definition.
* libc/stdio/asniprintf.c: Add #include "local.h".
* libc/stdio/vasniprintf.c: Ditto.
* libc/stdio/fread.c: Remove unused variable newcount.
* libc/stdio/local.h: Add function prototype for __sccl.
* libc/stdio/open_memstream.c: Remove unused variable flags.
* libc/stdio/vfscanf.c: Proper prototyping for ccfn, remove prototype
for __sccl since now in local.h.
* libc/string/memcpy.c: Add #include <string.h> (for real and for
traditional synopsis), remove extraneous stddef.h and limits.h.
* libc/syscalls/sysclose.c: Add #include <unistd.h>.
* libc/syscalls/sysfork.c: Ditto.
* libc/syscalls/sysgetpid.c: Ditto.
* libc/syscalls/sysexecve.c: Add #include <unistd.h>, align function
prototype with POSIX definition.
* libc/syscalls/sysfstat.c: Add #include <sys/stat.h>.
* libc/syscalls/sysgettod.c: Correct sys/times.h to sys/time.h.
* libc/syscalls/syskill.c: Add #include <signal.h>.
* libc/syscalls/syslink.c: Add #include <unistd.h>, fix prototype.
* libc/syscalls/sysunlink.c: Ditto.
* libc/syscalls/sysstat.c: Add #include <sys/stat.h>, fix prototype.
* libc/syscalls/syswait.c: Add #include <sys/wait.h>, fix prototype.
2008-12-12 01:27:56 +08:00
|
|
|
#else
|
2017-12-04 13:54:48 +08:00
|
|
|
int _fgetpos_r (struct _reent *, FILE *, fpos_t *);
|
|
|
|
int _fsetpos_r (struct _reent *, FILE *, const fpos_t *);
|
|
|
|
#endif
|
|
|
|
int _fiprintf_r (struct _reent *, FILE *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int _fiscanf_r (struct _reent *, FILE *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)));
|
|
|
|
FILE * _fmemopen_r (struct _reent *, void *__restrict, size_t, const char *__restrict);
|
|
|
|
FILE * _fopen_r (struct _reent *, const char *__restrict, const char *__restrict);
|
|
|
|
FILE * _freopen_r (struct _reent *, const char *__restrict, const char *__restrict, FILE *__restrict);
|
|
|
|
int _fprintf_r (struct _reent *, FILE *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int _fpurge_r (struct _reent *, FILE *);
|
|
|
|
int _fputc_r (struct _reent *, int, FILE *);
|
|
|
|
int _fputc_unlocked_r (struct _reent *, int, FILE *);
|
|
|
|
int _fputs_r (struct _reent *, const char *__restrict, FILE *__restrict);
|
|
|
|
int _fputs_unlocked_r (struct _reent *, const char *__restrict, FILE *__restrict);
|
|
|
|
size_t _fread_r (struct _reent *, void *__restrict, size_t _size, size_t _n, FILE *__restrict);
|
|
|
|
size_t _fread_unlocked_r (struct _reent *, void *__restrict, size_t _size, size_t _n, FILE *__restrict);
|
|
|
|
int _fscanf_r (struct _reent *, FILE *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)));
|
|
|
|
int _fseek_r (struct _reent *, FILE *, long, int);
|
|
|
|
int _fseeko_r (struct _reent *, FILE *, _off_t, int);
|
|
|
|
long _ftell_r (struct _reent *, FILE *);
|
|
|
|
_off_t _ftello_r (struct _reent *, FILE *);
|
|
|
|
void _rewind_r (struct _reent *, FILE *);
|
|
|
|
size_t _fwrite_r (struct _reent *, const void *__restrict, size_t _size, size_t _n, FILE *__restrict);
|
|
|
|
size_t _fwrite_unlocked_r (struct _reent *, const void *__restrict, size_t _size, size_t _n, FILE *__restrict);
|
|
|
|
int _getc_r (struct _reent *, FILE *);
|
|
|
|
int _getc_unlocked_r (struct _reent *, FILE *);
|
|
|
|
int _getchar_r (struct _reent *);
|
|
|
|
int _getchar_unlocked_r (struct _reent *);
|
|
|
|
char * _gets_r (struct _reent *, char *);
|
|
|
|
int _iprintf_r (struct _reent *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
int _iscanf_r (struct _reent *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)));
|
|
|
|
FILE * _open_memstream_r (struct _reent *, char **, size_t *);
|
|
|
|
void _perror_r (struct _reent *, const char *);
|
|
|
|
int _printf_r (struct _reent *, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 3)));
|
|
|
|
int _putc_r (struct _reent *, int, FILE *);
|
|
|
|
int _putc_unlocked_r (struct _reent *, int, FILE *);
|
|
|
|
int _putchar_unlocked_r (struct _reent *, int);
|
|
|
|
int _putchar_r (struct _reent *, int);
|
|
|
|
int _puts_r (struct _reent *, const char *);
|
|
|
|
int _remove_r (struct _reent *, const char *);
|
|
|
|
int _rename_r (struct _reent *,
|
|
|
|
const char *_old, const char *_new);
|
|
|
|
int _scanf_r (struct _reent *, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)));
|
|
|
|
int _siprintf_r (struct _reent *, char *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int _siscanf_r (struct _reent *, const char *, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)));
|
|
|
|
int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 5)));
|
|
|
|
int _snprintf_r (struct _reent *, char *__restrict, size_t, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 5)));
|
|
|
|
int _sprintf_r (struct _reent *, char *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 4)));
|
|
|
|
int _sscanf_r (struct _reent *, const char *__restrict, const char *__restrict, ...)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)));
|
|
|
|
char * _tempnam_r (struct _reent *, const char *, const char *);
|
|
|
|
FILE * _tmpfile_r (struct _reent *);
|
|
|
|
char * _tmpnam_r (struct _reent *, char *);
|
|
|
|
int _ungetc_r (struct _reent *, int, FILE *);
|
|
|
|
int _vasiprintf_r (struct _reent *, char **, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 0)));
|
|
|
|
char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 0)));
|
|
|
|
int _vasprintf_r (struct _reent *, char **, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int _vdiprintf_r (struct _reent *, int, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int _vdprintf_r (struct _reent *, int, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int _vfiprintf_r (struct _reent *, FILE *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int _vfiscanf_r (struct _reent *, FILE *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)));
|
|
|
|
int _vfprintf_r (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int _vfscanf_r (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)));
|
|
|
|
int _viprintf_r (struct _reent *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
int _viscanf_r (struct _reent *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)));
|
|
|
|
int _vprintf_r (struct _reent *, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 2, 0)));
|
|
|
|
int _vscanf_r (struct _reent *, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)));
|
|
|
|
int _vsiprintf_r (struct _reent *, char *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int _vsiscanf_r (struct _reent *, const char *, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)));
|
|
|
|
int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 0)));
|
|
|
|
int _vsnprintf_r (struct _reent *, char *__restrict, size_t, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 4, 0)));
|
|
|
|
int _vsprintf_r (struct _reent *, char *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__printf__, 3, 0)));
|
|
|
|
int _vsscanf_r (struct _reent *, const char *__restrict, const char *__restrict, __VALIST)
|
|
|
|
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)));
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2009-07-03 19:58:04 +08:00
|
|
|
/* Other extensions. */
|
|
|
|
|
2017-12-04 13:54:48 +08:00
|
|
|
int fpurge (FILE *);
|
|
|
|
ssize_t __getdelim (char **, size_t *, int, FILE *);
|
|
|
|
ssize_t __getline (char **, size_t *, FILE *);
|
2002-06-22 02:29:23 +08:00
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __MISC_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
void clearerr_unlocked (FILE *);
|
|
|
|
int feof_unlocked (FILE *);
|
|
|
|
int ferror_unlocked (FILE *);
|
|
|
|
int fileno_unlocked (FILE *);
|
|
|
|
int fflush_unlocked (FILE *);
|
|
|
|
int fgetc_unlocked (FILE *);
|
|
|
|
int fputc_unlocked (int, FILE *);
|
|
|
|
size_t fread_unlocked (void *__restrict, size_t _size, size_t _n, FILE *__restrict);
|
|
|
|
size_t fwrite_unlocked (const void *__restrict , size_t _size, size_t _n, FILE *);
|
Implement BSD/GNU unlocked stdio extensions.
* libc/include/stdio.h (clearerr_unlocked, feof_unlocked,
ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked,
fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked,
fwrite_unlocked): Declare.
* libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked,
fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked,
putwc_unlocked, putwchar_unlocked): Declare.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c,
feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c,
fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c,
fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c.
Add necessary dependencies.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/clearerr.c: Document unlocked variant.
* libc/stdio/clearerr_u.c: New file.
* libc/stdio/feof.c: Document unlocked variant.
* libc/stdio/feof_u.c: New file.
* libc/stdio/ferror.c: Document unlocked variant.
* libc/stdio/ferror_u.c: New file.
* libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fflush_u.c: New file.
* libc/stdio/fgetc.c: Document unlocked variants.
* libc/stdio/fgetc_u.c: New file.
* libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgets_u.c: New file.
* libc/stdio/fgetwc.c: Document unlocked variants.
(__fgetwc): Make non-static.
* libc/stdio/fgetwc_u.c: New file.
* libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgetws_u.c: New file.
* libc/stdio/fileno.c: Document unlocked variant.
* libc/stdio/fileno_u.c: New file.
* libc/stdio/fputc.c: Document unlocked variants.
* libc/stdio/fputc_u.c: New file.
* libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputs_u.c: New file.
* libc/stdio/fputwc.c: Document unlocked variants.
(__fputwc): Make non-static.
* libc/stdio/fputwc_u.c: New file.
* libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputws_u.c: New file.
* libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fread_u.c: New file.
* libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fwrite_u.c: New file.
* libc/stdio/getwc_u.c: New file.
* libc/stdio/getwchar.c: Document unlocked variants.
* libc/stdio/getwchar_u.c: New file.
* libc/stdio/local.h: Define locking macros as empty ifdef
__IMPL_UNLOCKED__.
(__fgetwc, __fputwc): Declare.
* libc/stdio/putwc_u.c: New file.
* libc/stdio/putwchar.c: Document unlocked variants.
* libc/stdio/putwchar_u.c: New file.
2014-12-18 22:55:21 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if __GNU_VISIBLE
|
2017-12-04 13:54:48 +08:00
|
|
|
char * fgets_unlocked (char *__restrict, int, FILE *__restrict);
|
|
|
|
int fputs_unlocked (const char *__restrict, FILE *__restrict);
|
Implement BSD/GNU unlocked stdio extensions.
* libc/include/stdio.h (clearerr_unlocked, feof_unlocked,
ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked,
fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked,
fwrite_unlocked): Declare.
* libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked,
fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked,
putwc_unlocked, putwchar_unlocked): Declare.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c,
feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c,
fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c,
fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c.
Add necessary dependencies.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/clearerr.c: Document unlocked variant.
* libc/stdio/clearerr_u.c: New file.
* libc/stdio/feof.c: Document unlocked variant.
* libc/stdio/feof_u.c: New file.
* libc/stdio/ferror.c: Document unlocked variant.
* libc/stdio/ferror_u.c: New file.
* libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fflush_u.c: New file.
* libc/stdio/fgetc.c: Document unlocked variants.
* libc/stdio/fgetc_u.c: New file.
* libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgets_u.c: New file.
* libc/stdio/fgetwc.c: Document unlocked variants.
(__fgetwc): Make non-static.
* libc/stdio/fgetwc_u.c: New file.
* libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgetws_u.c: New file.
* libc/stdio/fileno.c: Document unlocked variant.
* libc/stdio/fileno_u.c: New file.
* libc/stdio/fputc.c: Document unlocked variants.
* libc/stdio/fputc_u.c: New file.
* libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputs_u.c: New file.
* libc/stdio/fputwc.c: Document unlocked variants.
(__fputwc): Make non-static.
* libc/stdio/fputwc_u.c: New file.
* libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputws_u.c: New file.
* libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fread_u.c: New file.
* libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fwrite_u.c: New file.
* libc/stdio/getwc_u.c: New file.
* libc/stdio/getwchar.c: Document unlocked variants.
* libc/stdio/getwchar_u.c: New file.
* libc/stdio/local.h: Define locking macros as empty ifdef
__IMPL_UNLOCKED__.
(__fgetwc, __fputwc): Declare.
* libc/stdio/putwc_u.c: New file.
* libc/stdio/putwchar.c: Document unlocked variants.
* libc/stdio/putwchar_u.c: New file.
2014-12-18 22:55:21 +08:00
|
|
|
#endif
|
|
|
|
|
2002-07-18 07:25:44 +08:00
|
|
|
#ifdef __LARGE64_FILES
|
2021-11-09 11:22:27 +08:00
|
|
|
#if !defined(__CYGWIN__) || defined(_LIBC)
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE * fdopen64 (int, const char *);
|
|
|
|
FILE * fopen64 (const char *, const char *);
|
|
|
|
FILE * freopen64 (const char *, const char *, FILE *);
|
|
|
|
_off64_t ftello64 (FILE *);
|
|
|
|
_off64_t fseeko64 (FILE *, _off64_t, int);
|
|
|
|
int fgetpos64 (FILE *, _fpos64_t *);
|
|
|
|
int fsetpos64 (FILE *, const _fpos64_t *);
|
|
|
|
FILE * tmpfile64 (void);
|
|
|
|
|
|
|
|
FILE * _fdopen64_r (struct _reent *, int, const char *);
|
|
|
|
FILE * _fopen64_r (struct _reent *,const char *, const char *);
|
|
|
|
FILE * _freopen64_r (struct _reent *, const char *, const char *, FILE *);
|
|
|
|
_off64_t _ftello64_r (struct _reent *, FILE *);
|
|
|
|
_off64_t _fseeko64_r (struct _reent *, FILE *, _off64_t, int);
|
|
|
|
int _fgetpos64_r (struct _reent *, FILE *, _fpos64_t *);
|
|
|
|
int _fsetpos64_r (struct _reent *, FILE *, const _fpos64_t *);
|
|
|
|
FILE * _tmpfile64_r (struct _reent *);
|
2003-03-08 04:41:49 +08:00
|
|
|
#endif /* !__CYGWIN__ */
|
2002-07-18 07:25:44 +08:00
|
|
|
#endif /* __LARGE64_FILES */
|
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-05 02:10:17 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* Routines internal to the implementation.
|
|
|
|
*/
|
|
|
|
|
2017-12-04 13:54:48 +08:00
|
|
|
int __srget_r (struct _reent *, FILE *);
|
|
|
|
int __swbuf_r (struct _reent *, int, FILE *);
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stdio function-access interface.
|
|
|
|
*/
|
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __BSD_VISIBLE
|
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-05 02:10:17 +08:00
|
|
|
# ifdef __LARGE64_FILES
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE *funopen (const void *__cookie,
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__readfn)(void *__c, char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__writefn)(void *__c, const char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
_fpos64_t (*__seekfn)(void *__c, _fpos64_t __off, int __whence),
|
2017-12-04 13:54:48 +08:00
|
|
|
int (*__closefn)(void *__c));
|
|
|
|
FILE *_funopen_r (struct _reent *, const void *__cookie,
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__readfn)(void *__c, char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__writefn)(void *__c, const char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
_fpos64_t (*__seekfn)(void *__c, _fpos64_t __off, int __whence),
|
2017-12-04 13:54:48 +08:00
|
|
|
int (*__closefn)(void *__c));
|
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-05 02:10:17 +08:00
|
|
|
# else
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE *funopen (const void *__cookie,
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__readfn)(void *__cookie, char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__writefn)(void *__cookie, const char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
fpos_t (*__seekfn)(void *__cookie, fpos_t __off, int __whence),
|
2017-12-04 13:54:48 +08:00
|
|
|
int (*__closefn)(void *__cookie));
|
|
|
|
FILE *_funopen_r (struct _reent *, const void *__cookie,
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__readfn)(void *__cookie, char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
int (*__writefn)(void *__cookie, const char *__buf,
|
2013-10-23 18:04:43 +08:00
|
|
|
_READ_WRITE_BUFSIZE_TYPE __n),
|
2017-12-04 10:53:22 +08:00
|
|
|
fpos_t (*__seekfn)(void *__cookie, fpos_t __off, int __whence),
|
2017-12-04 13:54:48 +08:00
|
|
|
int (*__closefn)(void *__cookie));
|
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-05 02:10:17 +08:00
|
|
|
# endif /* !__LARGE64_FILES */
|
|
|
|
|
|
|
|
# define fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \
|
|
|
|
(fpos_t (*)())0, (int (*)())0)
|
|
|
|
# define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \
|
|
|
|
(fpos_t (*)())0, (int (*)())0)
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif /* __BSD_VISIBLE */
|
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-05 02:10:17 +08:00
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __GNU_VISIBLE
|
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-05 02:10:17 +08:00
|
|
|
typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n);
|
|
|
|
typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf,
|
|
|
|
size_t __n);
|
|
|
|
# ifdef __LARGE64_FILES
|
|
|
|
typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off,
|
|
|
|
int __whence);
|
|
|
|
# else
|
|
|
|
typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence);
|
|
|
|
# endif /* !__LARGE64_FILES */
|
|
|
|
typedef int cookie_close_function_t(void *__cookie);
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* These four struct member names are dictated by Linux; hopefully,
|
|
|
|
they don't conflict with any macros. */
|
|
|
|
cookie_read_function_t *read;
|
|
|
|
cookie_write_function_t *write;
|
|
|
|
cookie_seek_function_t *seek;
|
|
|
|
cookie_close_function_t *close;
|
|
|
|
} cookie_io_functions_t;
|
2017-12-04 13:54:48 +08:00
|
|
|
FILE *fopencookie (void *__cookie,
|
|
|
|
const char *__mode, cookie_io_functions_t __functions);
|
|
|
|
FILE *_fopencookie_r (struct _reent *, void *__cookie,
|
|
|
|
const char *__mode, cookie_io_functions_t __functions);
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif /* __GNU_VISIBLE */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2007-02-02 00:33:05 +08:00
|
|
|
#ifndef __CUSTOM_FILE_IO__
|
2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* The __sfoo macros are here so that we can
|
|
|
|
* define function versions in the C library.
|
|
|
|
*/
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++))
|
2000-05-03 11:57:19 +08:00
|
|
|
|
|
|
|
#ifdef __SCLE
|
2007-03-30 08:49:56 +08:00
|
|
|
/* For a platform with CR/LF, additional logic is required by
|
|
|
|
__sgetc_r which would otherwise simply be a macro; therefore we
|
|
|
|
use an inlined function. The function is only meant to be inlined
|
|
|
|
in place as used and the function body should never be emitted.
|
|
|
|
|
|
|
|
There are two possible means to this end when compiling with GCC,
|
|
|
|
one when compiling with a standard C99 compiler, and for other
|
|
|
|
compilers we're just stuck. At the moment, this issue only
|
2009-04-04 23:44:19 +08:00
|
|
|
affects the Cygwin target, so we'll most likely be using GCC. */
|
2007-03-30 08:49:56 +08:00
|
|
|
|
2009-04-04 06:46:15 +08:00
|
|
|
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p);
|
|
|
|
|
2007-03-30 08:49:56 +08:00
|
|
|
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p)
|
2000-05-03 11:57:19 +08:00
|
|
|
{
|
2006-06-15 04:49:11 +08:00
|
|
|
int __c = __sgetc_raw_r(__ptr, __p);
|
2000-05-03 11:57:19 +08:00
|
|
|
if ((__p->_flags & __SCLE) && (__c == '\r'))
|
|
|
|
{
|
2006-06-15 04:49:11 +08:00
|
|
|
int __c2 = __sgetc_raw_r(__ptr, __p);
|
2000-05-03 11:57:19 +08:00
|
|
|
if (__c2 == '\n')
|
|
|
|
__c = __c2;
|
|
|
|
else
|
|
|
|
ungetc(__c2, __p);
|
|
|
|
}
|
|
|
|
return __c;
|
|
|
|
}
|
|
|
|
#else
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p)
|
2000-05-03 11:57:19 +08:00
|
|
|
#endif
|
|
|
|
|
2016-03-13 06:25:11 +08:00
|
|
|
#ifdef __GNUC__
|
2007-03-30 08:49:56 +08:00
|
|
|
_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
2016-03-13 06:25:11 +08:00
|
|
|
#ifdef __SCLE
|
|
|
|
if ((_p->_flags & __SCLE) && _c == '\n')
|
|
|
|
__sputc_r (_ptr, '\r', _p);
|
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
|
|
|
|
return (*_p->_p++ = _c);
|
|
|
|
else
|
2006-06-15 04:49:11 +08:00
|
|
|
return (__swbuf_r(_ptr, _c, _p));
|
2000-02-18 03:39:52 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* This has been tuned to generate reasonable code on the vax using pcc
|
|
|
|
*/
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sputc_raw_r(__ptr, __c, __p) \
|
|
|
|
(--(__p)->_w < 0 ? \
|
|
|
|
(__p)->_w >= (__p)->_lbfsize ? \
|
|
|
|
(*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \
|
|
|
|
(int)*(__p)->_p++ : \
|
|
|
|
__swbuf_r(__ptr, '\n', __p) : \
|
|
|
|
__swbuf_r(__ptr, (int)(__c), __p) : \
|
|
|
|
(*(__p)->_p = (__c), (int)*(__p)->_p++))
|
2000-05-03 11:57:19 +08:00
|
|
|
#ifdef __SCLE
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sputc_r(__ptr, __c, __p) \
|
|
|
|
((((__p)->_flags & __SCLE) && ((__c) == '\n')) \
|
|
|
|
? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \
|
|
|
|
__sputc_raw_r((__ptr), (__c), (__p)))
|
2000-05-03 11:57:19 +08:00
|
|
|
#else
|
2006-06-15 04:49:11 +08:00
|
|
|
#define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p)
|
2000-05-03 11:57:19 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
|
2014-12-12 01:42:19 +08:00
|
|
|
#define __sfeof(p) ((int)(((p)->_flags & __SEOF) != 0))
|
|
|
|
#define __sferror(p) ((int)(((p)->_flags & __SERR) != 0))
|
2000-02-18 03:39:52 +08:00
|
|
|
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
|
|
|
|
#define __sfileno(p) ((p)->_file)
|
|
|
|
|
2017-06-14 03:51:18 +08:00
|
|
|
#ifndef __cplusplus
|
2006-09-27 05:22:19 +08:00
|
|
|
#ifndef _REENT_SMALL
|
2000-02-18 03:39:52 +08:00
|
|
|
#define feof(p) __sfeof(p)
|
|
|
|
#define ferror(p) __sferror(p)
|
|
|
|
#define clearerr(p) __sclearerr(p)
|
Implement BSD/GNU unlocked stdio extensions.
* libc/include/stdio.h (clearerr_unlocked, feof_unlocked,
ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked,
fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked,
fwrite_unlocked): Declare.
* libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked,
fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked,
putwc_unlocked, putwchar_unlocked): Declare.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c,
feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c,
fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c,
fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c.
Add necessary dependencies.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/clearerr.c: Document unlocked variant.
* libc/stdio/clearerr_u.c: New file.
* libc/stdio/feof.c: Document unlocked variant.
* libc/stdio/feof_u.c: New file.
* libc/stdio/ferror.c: Document unlocked variant.
* libc/stdio/ferror_u.c: New file.
* libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fflush_u.c: New file.
* libc/stdio/fgetc.c: Document unlocked variants.
* libc/stdio/fgetc_u.c: New file.
* libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgets_u.c: New file.
* libc/stdio/fgetwc.c: Document unlocked variants.
(__fgetwc): Make non-static.
* libc/stdio/fgetwc_u.c: New file.
* libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgetws_u.c: New file.
* libc/stdio/fileno.c: Document unlocked variant.
* libc/stdio/fileno_u.c: New file.
* libc/stdio/fputc.c: Document unlocked variants.
* libc/stdio/fputc_u.c: New file.
* libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputs_u.c: New file.
* libc/stdio/fputwc.c: Document unlocked variants.
(__fputwc): Make non-static.
* libc/stdio/fputwc_u.c: New file.
* libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputws_u.c: New file.
* libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fread_u.c: New file.
* libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fwrite_u.c: New file.
* libc/stdio/getwc_u.c: New file.
* libc/stdio/getwchar.c: Document unlocked variants.
* libc/stdio/getwchar_u.c: New file.
* libc/stdio/local.h: Define locking macros as empty ifdef
__IMPL_UNLOCKED__.
(__fgetwc, __fputwc): Declare.
* libc/stdio/putwc_u.c: New file.
* libc/stdio/putwchar.c: Document unlocked variants.
* libc/stdio/putwchar_u.c: New file.
2014-12-18 22:55:21 +08:00
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __MISC_VISIBLE
|
Implement BSD/GNU unlocked stdio extensions.
* libc/include/stdio.h (clearerr_unlocked, feof_unlocked,
ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked,
fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked,
fwrite_unlocked): Declare.
* libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked,
fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked,
putwc_unlocked, putwchar_unlocked): Declare.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c,
feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c,
fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c,
fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c.
Add necessary dependencies.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/clearerr.c: Document unlocked variant.
* libc/stdio/clearerr_u.c: New file.
* libc/stdio/feof.c: Document unlocked variant.
* libc/stdio/feof_u.c: New file.
* libc/stdio/ferror.c: Document unlocked variant.
* libc/stdio/ferror_u.c: New file.
* libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fflush_u.c: New file.
* libc/stdio/fgetc.c: Document unlocked variants.
* libc/stdio/fgetc_u.c: New file.
* libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgets_u.c: New file.
* libc/stdio/fgetwc.c: Document unlocked variants.
(__fgetwc): Make non-static.
* libc/stdio/fgetwc_u.c: New file.
* libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgetws_u.c: New file.
* libc/stdio/fileno.c: Document unlocked variant.
* libc/stdio/fileno_u.c: New file.
* libc/stdio/fputc.c: Document unlocked variants.
* libc/stdio/fputc_u.c: New file.
* libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputs_u.c: New file.
* libc/stdio/fputwc.c: Document unlocked variants.
(__fputwc): Make non-static.
* libc/stdio/fputwc_u.c: New file.
* libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputws_u.c: New file.
* libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fread_u.c: New file.
* libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fwrite_u.c: New file.
* libc/stdio/getwc_u.c: New file.
* libc/stdio/getwchar.c: Document unlocked variants.
* libc/stdio/getwchar_u.c: New file.
* libc/stdio/local.h: Define locking macros as empty ifdef
__IMPL_UNLOCKED__.
(__fgetwc, __fputwc): Declare.
* libc/stdio/putwc_u.c: New file.
* libc/stdio/putwchar.c: Document unlocked variants.
* libc/stdio/putwchar_u.c: New file.
2014-12-18 22:55:21 +08:00
|
|
|
#define feof_unlocked(p) __sfeof(p)
|
|
|
|
#define ferror_unlocked(p) __sferror(p)
|
|
|
|
#define clearerr_unlocked(p) __sclearerr(p)
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif /* __MISC_VISIBLE */
|
Implement BSD/GNU unlocked stdio extensions.
* libc/include/stdio.h (clearerr_unlocked, feof_unlocked,
ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked,
fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked,
fwrite_unlocked): Declare.
* libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked,
fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked,
putwc_unlocked, putwchar_unlocked): Declare.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c,
feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c,
fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c,
fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c.
Add necessary dependencies.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/clearerr.c: Document unlocked variant.
* libc/stdio/clearerr_u.c: New file.
* libc/stdio/feof.c: Document unlocked variant.
* libc/stdio/feof_u.c: New file.
* libc/stdio/ferror.c: Document unlocked variant.
* libc/stdio/ferror_u.c: New file.
* libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fflush_u.c: New file.
* libc/stdio/fgetc.c: Document unlocked variants.
* libc/stdio/fgetc_u.c: New file.
* libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgets_u.c: New file.
* libc/stdio/fgetwc.c: Document unlocked variants.
(__fgetwc): Make non-static.
* libc/stdio/fgetwc_u.c: New file.
* libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgetws_u.c: New file.
* libc/stdio/fileno.c: Document unlocked variant.
* libc/stdio/fileno_u.c: New file.
* libc/stdio/fputc.c: Document unlocked variants.
* libc/stdio/fputc_u.c: New file.
* libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputs_u.c: New file.
* libc/stdio/fputwc.c: Document unlocked variants.
(__fputwc): Make non-static.
* libc/stdio/fputwc_u.c: New file.
* libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputws_u.c: New file.
* libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fread_u.c: New file.
* libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fwrite_u.c: New file.
* libc/stdio/getwc_u.c: New file.
* libc/stdio/getwchar.c: Document unlocked variants.
* libc/stdio/getwchar_u.c: New file.
* libc/stdio/local.h: Define locking macros as empty ifdef
__IMPL_UNLOCKED__.
(__fgetwc, __fputwc): Declare.
* libc/stdio/putwc_u.c: New file.
* libc/stdio/putwchar.c: Document unlocked variants.
* libc/stdio/putwchar_u.c: New file.
2014-12-18 22:55:21 +08:00
|
|
|
#endif /* _REENT_SMALL */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if 0 /* __POSIX_VISIBLE - FIXME: must initialize stdio first, use fn */
|
2000-02-18 03:39:52 +08:00
|
|
|
#define fileno(p) __sfileno(p)
|
|
|
|
#endif
|
|
|
|
|
2017-08-07 13:35:19 +08:00
|
|
|
static __inline int
|
|
|
|
_getchar_unlocked(void)
|
|
|
|
{
|
|
|
|
struct _reent *_ptr;
|
|
|
|
|
|
|
|
_ptr = _REENT;
|
|
|
|
return (__sgetc_r(_ptr, _stdin_r(_ptr)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
_putchar_unlocked(int _c)
|
|
|
|
{
|
|
|
|
struct _reent *_ptr;
|
|
|
|
|
|
|
|
_ptr = _REENT;
|
|
|
|
return (__sputc_r(_ptr, _c, _stdout_r(_ptr)));
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __SINGLE_THREAD__
|
|
|
|
#define getc(_p) __sgetc_r(_REENT, _p)
|
|
|
|
#define putc(_c, _p) __sputc_r(_REENT, _c, _p)
|
|
|
|
#define getchar() _getchar_unlocked()
|
|
|
|
#define putchar(_c) _putchar_unlocked(_c)
|
|
|
|
#endif /* __SINGLE_THREAD__ */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2017-08-07 13:35:19 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
|
|
|
#define getchar_unlocked() _getchar_unlocked()
|
|
|
|
#define putchar_unlocked(_c) _putchar_unlocked(_c)
|
|
|
|
#endif
|
2017-09-04 16:52:33 +08:00
|
|
|
#endif /* __cplusplus */
|
2017-08-07 13:35:19 +08:00
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __MISC_VISIBLE
|
2000-02-18 03:39:52 +08:00
|
|
|
/* fast always-buffered version, true iff error */
|
|
|
|
#define fast_putc(x,p) (--(p)->_w < 0 ? \
|
2006-06-15 04:49:11 +08:00
|
|
|
__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
|
2016-03-15 05:40:44 +08:00
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2016-05-21 05:55:50 +08:00
|
|
|
#if __GNU_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)
|
2000-02-18 03:39:52 +08:00
|
|
|
#define L_cuserid 9 /* posix says it goes in stdio.h :( */
|
|
|
|
#endif
|
2016-05-21 05:55:50 +08:00
|
|
|
#if __POSIX_VISIBLE
|
|
|
|
#define L_ctermid 16
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif
|
|
|
|
|
2017-08-07 13:35:19 +08:00
|
|
|
#else /* __CUSTOM_FILE_IO__ */
|
2007-02-02 00:33:05 +08:00
|
|
|
|
|
|
|
#define getchar() getc(stdin)
|
|
|
|
#define putchar(x) putc(x, stdout)
|
|
|
|
|
2016-03-15 05:40:44 +08:00
|
|
|
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
Implement BSD/GNU unlocked stdio extensions.
* libc/include/stdio.h (clearerr_unlocked, feof_unlocked,
ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked,
fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked,
fwrite_unlocked): Declare.
* libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked,
fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked,
putwc_unlocked, putwchar_unlocked): Declare.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c,
feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c,
fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c,
fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c.
Add necessary dependencies.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/clearerr.c: Document unlocked variant.
* libc/stdio/clearerr_u.c: New file.
* libc/stdio/feof.c: Document unlocked variant.
* libc/stdio/feof_u.c: New file.
* libc/stdio/ferror.c: Document unlocked variant.
* libc/stdio/ferror_u.c: New file.
* libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fflush_u.c: New file.
* libc/stdio/fgetc.c: Document unlocked variants.
* libc/stdio/fgetc_u.c: New file.
* libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgets_u.c: New file.
* libc/stdio/fgetwc.c: Document unlocked variants.
(__fgetwc): Make non-static.
* libc/stdio/fgetwc_u.c: New file.
* libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fgetws_u.c: New file.
* libc/stdio/fileno.c: Document unlocked variant.
* libc/stdio/fileno_u.c: New file.
* libc/stdio/fputc.c: Document unlocked variants.
* libc/stdio/fputc_u.c: New file.
* libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputs_u.c: New file.
* libc/stdio/fputwc.c: Document unlocked variants.
(__fputwc): Make non-static.
* libc/stdio/fputwc_u.c: New file.
* libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fputws_u.c: New file.
* libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fread_u.c: New file.
* libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides.
Document unlocked variants.
* libc/stdio/fwrite_u.c: New file.
* libc/stdio/getwc_u.c: New file.
* libc/stdio/getwchar.c: Document unlocked variants.
* libc/stdio/getwchar_u.c: New file.
* libc/stdio/local.h: Define locking macros as empty ifdef
__IMPL_UNLOCKED__.
(__fgetwc, __fputwc): Declare.
* libc/stdio/putwc_u.c: New file.
* libc/stdio/putwchar.c: Document unlocked variants.
* libc/stdio/putwchar_u.c: New file.
2014-12-18 22:55:21 +08:00
|
|
|
#define getchar_unlocked() getc_unlocked(stdin)
|
|
|
|
#define putchar_unlocked(x) putc_unlocked(x, stdout)
|
|
|
|
#endif
|
|
|
|
|
2017-08-07 13:35:19 +08:00
|
|
|
#endif /* !__CUSTOM_FILE_IO__ */
|
|
|
|
|
2002-06-28 07:58:38 +08:00
|
|
|
_END_STD_C
|
|
|
|
|
ssp: add Object Size Checking for stdio.h, part 1
The implementation is mostly from NetBSD, except for switching fgets to
pure inline, and the addition of fgets_unlocked, fread, and fread_unlocked
for parity with glibc. The following functions are also guarded in glibc:
asprintf, dprintf, fprintf, printf, vasprintf, vdprintf, vfprintf, vprintf.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-28 13:24:16 +08:00
|
|
|
#if __SSP_FORTIFY_LEVEL > 0
|
|
|
|
#include <ssp/stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#endif /* _STDIO_H_ */
|