Commit Graph

93 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
Corinna Vinschen 09870c6e95 stdio.h: Expose cuserid with __GNU_VISIBLE
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-11-29 11:22:42 +01:00
Sebastian Huber 201bbec6e4 Add attributes to malloc-like functions
These attributes help static analysis tools to produce less false
positives, e.g. double free warnings.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-10 07:40:06 +02:00
Yaakov Selkowitz 70ee6b17df ansification: remove _EXFUN, _EXFUN_NOTHROW
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:29 -06:00
Yaakov Selkowitz 67ee0cac4c ansification: remove _VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:20 -06:00
Yaakov Selkowitz e6321aa6a6 ansification: remove _PTR
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:16 -06:00
Yaakov Selkowitz 0bda30e1ff ansification: remove _CONST
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:08 -06:00
Yaakov Selkowitz 576093d46b 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-29 11:25:42 -06:00
Corinna Vinschen e18b7ffa48 stdio.h: Don't define unlocked macros using static inline on C++
In C++, the usage of static inline functions for getchar_unlocked and
putchar_unlocked may result in error messages like

  error: ‘_putchar_unlocked’ was not declared in this scope

Fix this by not using the _getchar_unlocked and _putchar_unlocked
macros in C++.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-09-04 10:52:33 +02:00
Ken Brown f665b1cef3 cygwin: Implement renameat2
Define the RENAME_NOREPLACE flag in <cygwin/fs.h> as defined on Linux
in <linux/fs.h>.  The other RENAME_* flags defined on Linux are not
supported.
2017-08-19 18:06:49 +02:00
Sebastian Huber b0f271d1db Proper locking for getchar() and putchar()
Add internal inline functions _getchar_unlocked() and
_putchar_unlocked() if __CUSTOM_FILE_IO__ is not defined.  These
functions get _REENT only once.  Use them for getchar_unlocked() and
putchar_unlocked().  Define getchar() and putchar() to these unlocked
internal functions if __SINGLE_THREAD__ is defined, otherwise use the
external functions to use proper locking of the FILE object.

Assumes that __SINGLE_THREAD__ is not defined if __CYGWIN__ is defined.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-08-07 07:54:58 +02:00
Yaakov Selkowitz c347bb6469 stdio.h: guard function macros with !__cplusplus
While POSIX allows these functions to also be defined as macros in C, in
C++ this is not allowed, and prevents these names (particularly feof) from
being used in a custom namespace.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-06-14 10:18:14 -05:00
Yaakov Selkowitz b14a1dbc86 Define va_list in stdio.h and wchar.h
This typedef, along with that of FILE in wchar.h, were XSI prior to
inclusion in POSIX.1-2008.

Fixes: https://sourceware.org/ml/newlib/2016/msg00640.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-08-12 11:43:14 -05:00
Yaakov Selkowitz 95644157c1 Feature test macros: ctermid, cuserid
The proper location for these functions has always been <stdio.h>, however
XPG4 and SUSv2 did mandate a duplicate declaration in <unistd.h>.  cuserid
was dropped in SUSv3 (it was marked legacy since XPG4) and the ctermid
declaration in <unistd.h> was made optional and obsolete in SUSv4.

Fixes: https://cygwin.com/ml/cygwin/2016-05/msg00002.html
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-05-23 11:20:29 -05:00
Yaakov Selkowitz 1e6205b1ae stdio: fseeko/ftello are also POSIX.1-2001
_LARGEFILE_SOURCE, which controls only these two functions, is implicitly
defined by _XOPEN_SOURCE >= 500.  However, they are also later added to
POSIX.1-2001 (and therefore available by default).

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-22 10:50:31 -05:00
Yaakov Selkowitz feec81e571 Feature test macros overhaul: stdio.h
Throughout, remove references to __STRICT_ANSI__ and use the proper
internal macros and versions for C99, POSIX, ATFILE for the various *at
functions, or LARGEFILE for fseeko and ftello.

[v]asprintf are GNU extensions, but the *iprintf, *iscanf, and
*asnprintf functions are unique to newlib.

getw and putw were removed from POSIX.1-2001. funopen is BSD, and
fopencookie is GNU.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:04 -05:00
Corinna Vinschen 6b97fabf1b Use __sputc_r inline code when building with gcc
Per the preceeding comment this inline code is disabled since 1993(!)
because of a bug in GCC at the time.  This is long gone and the equivalent
inline code is used in the BSDs for quite some time.  Enable this code for
newlib as well.

	* libc/include/stdio.h (__sputc_r): Enable GCC inline code.  Add
	handling for targets defining __SCLE.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 23:25:11 +01:00
Jon Turney c5fee55606 stdio.h: Use __POSIX_VISIBLE etc. guards for POSIX 1003.1:2001 functions
Current mesa expects stdio.h to prototype fileno() when compiling with gcc
-std=c99 -D_XOPEN_SOURCE

Fix the 'POSIX 1003.1:2001' block in stdio.h to prototype functions if not
__STRICT_ANSI__, or _BSD_SOURCE, _POSIX_C_SOURCE or _XOPEN_SOURCE are defined
appropriately

As far as I can tell, despite being in this block, setbuffer() and setlinebuf()
are BSDisms which aren't in POSIX 1003.1:2001

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-02-08 10:39:31 +01:00
Corinna Vinschen 5a97e28f6a * libc/include/stdio.h (FILE): Protect typedef from redefinition.
* libc/include/wchar.h: Ditto.
2015-03-05 17:15:24 +00:00
Yaakov Selkowitz 968738f9b1 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 14:55:21 +00:00
Yaakov Selkowitz 6485fc66f2 * libc/include/stdio.h (__SNLK): Define.
* libc/include/stdio_ext.h (FSETLOCKING_QUERY, FSETLOCKING_INTERNAL,
FSETLOCKING_BYCALLER): Define.
(__fsetlocking): Declare.
* libc/stdio/Makefile.am: Build fsetlocking.c.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/fsetlocking.c: New file.
* libc/stdio/local.h (_newlib_flockfile_start): Make _flockfile
call dependent on __SNLK flag.
(_newlib_flockfile_exit, _newlib_flockfile_end): Ditto for
_funlockfile calls.
Define all locking macros as empty if __SINGLE_THREAD__.
* libc/stdio/stdio.tex: Include fsetlocking.def.
2014-12-15 18:22:56 +00:00
Corinna Vinschen c6332722d9 * libc/include/stdio.h: Fix type signature of __sfeof and __sferror
(and thus feof and ferror) for C++.
2014-12-11 17:42:19 +00:00
Corinna Vinschen 7bc7b551f5 * libc/include/stdio.h (tempnam): Declare as __BSD_VISIBLE or
__XSI_VISIBLE or if __POSIX_VISIBLE >= 200112.
2014-05-09 14:25:32 +00:00
Corinna Vinschen 783e4d51e2 * libc/include/stdio.h (fcloseall): Declare as __GNU_VISIBLE only.
(renameat): Drop explicit __CYGWIN__ dependency.
2014-05-09 08:42:39 +00:00
Corinna Vinschen 7e9b678464 * libc/include/stdio.h: Declare various C99 printf/scanf functions for
C++11, too.
2014-05-05 12:53:47 +00:00
Jeff Johnston 439f4e7a87 2014-01-06 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/include/sys/_default_fcntl.h (AT_FDCWD): Define according
        to POSIX.
        (AT_EACCESS): Likewise.
        (AT_SYMLINK_NOFOLLOW): Likewise.
        (AT_SYMLINK_FOLLOW): Likewise.
        (AT_REMOVEDIR): Likewise.
        (openat): Declare according to POSIX.
        * libc/include/stdio.h (renameat): Likewise.
        * libc/include/sys/stat.h (fchmodat): Likewise.
        (fstatat): Likewise.
        (mkdirat): Likewise.
        (mkfifoat): Likewise.
        (mknodat): Likewise.
        (utimensat): Likewise.
        (futimens): Likewise.
        * libc/include/sys/unistd.h (faccessat): Likewise.
        (fchownat): Likewise.
        (linkat): Likewise.
        (readlinkat): Likewise.
        (symlinkat): Likewise.
        (unlinkat): Likewise.
2014-01-06 20:59:38 +00:00
Joel Sherrill 481cb456a4 2013-11-18 Sahil Patnayakuni <sahilp@oarcorp.com>
* libc/include/stdio.h, libc/machine/powerpc/vfscanf.c,
	libc/machine/spu/fgetpos.c, libc/machine/spu/fgets.c,
	libc/machine/spu/fopen.c, libc/machine/spu/fputs.c,
	libc/machine/spu/fread.c, libc/machine/spu/freopen.c,
	libc/machine/spu/fwrite.c, libc/machine/spu/setbuf.c,
	libc/machine/spu/vfprintf.c, libc/machine/spu/vfscanf.c,
	libc/machine/spu/vsnprintf.c, libc/machine/spu/vsprintf.c,
	libc/machine/spu/vsscanf.c, libc/stdio/asnprintf.c,
	libc/stdio/asprintf.c, libc/stdio/dprintf.c,
	libc/stdio/fgetpos.c, libc/stdio/fgets.c,
	libc/stdio/fmemopen.c, libc/stdio/fopen.c,
	libc/stdio/fprintf.c, libc/stdio/fputs.c,
	libc/stdio/fread.c, libc/stdio/freopen.c,
	libc/stdio/fscanf.c, libc/stdio/fwrite.c,
	libc/stdio/printf.c, libc/stdio/scanf.c,
	libc/stdio/setbuf.c, libc/stdio/snprintf.c,
	libc/stdio/sprintf.c, libc/stdio/sscanf.c,
	libc/stdio/vdprintf.c, libc/stdio/vprintf.c,
	libc/stdio/vscanf.c, libc/stdio/vsnprintf.c,
	libc/stdio/vsprintf.c, libc/stdio/vsscanf.c: Add restrict keyword.
2013-11-18 17:28:06 +00:00
Hans-Peter Nilsson 72a386373e * libc/include/stdio.h [!__LARGE64_FILES] (funopen): Fix typo
in last change.
2013-10-24 01:21:33 +00:00
Corinna Vinschen 0c3d8e5ab5 * libc/include/stdio.h (funopen): Change prototype of
__readfn and __writefn parameter to match new definition of
	FILE's _read and _write methods.
	(_funopen_r): Ditto.
	(funopen): Ditto.
	(_funopen_r): Ditto.
	* libc/include/sys/config.h (_READ_WRITE_BUFSIZE_TYPE) Define
	as type int if not already defined.  Add comment to explain.
	* libc/include/sys/reent.h: Include stddef.h.
	(struct __sFILE): Change type of last parameter in declaration
	of _read and _write methods to _READ_WRITE_BUFSIZE_TYPE.
	(struct __sFILE64): Ditto.
	* libc/stdio/local.h (__sread): Declare with last parameter set
	to _READ_WRITE_BUFSIZE_TYPE.
	(__seofread): Ditto.
	(__swrite): Ditto.
	(__swrite64): Ditto.
	* libc/stdio/fvwrite.c (__sfvwrite_r): Change type of local
	variables w and s to _READ_WRITE_RETURN_TYPE.
	* libc/stdio/fflush.c (__sflush_r): Change type of local variables
	n and t to _READ_WRITE_BUFSIZE_TYPE and _READ_WRITE_RETURN_TYPE.
	Add local variables flags to keep _flags value.
	* libc/stdio/fmemopen.c (fmemreader): Align to above change.
	(fmemwriter): Ditto.
	* libc/stdio/fopencookie.c (fcreader): Ditto.
	(fcwriter): Ditto.
	* libc/stdio/funopen.c (funread): Ditto.
	(funwrite): Ditto.
	(funreader): Ditto.
	(funwriter): Ditto.
	* libc/stdio/open_memstream.c (memwriter): Ditto.
	* libc/stdio/stdio.c (__sread): Ditto.
	(__seofread): Ditto.
	(__swrite): Ditto.
	* libc/stdio64/stdio64.c (__swrite64): Ditto.
2013-10-23 10:04:43 +00:00
Jeff Johnston 27ad840ea5 2013-06-26 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h: Specify std streams always in terms
        of _REENT.
        * libc/include/wchar.h: Ditto.
        * libc/include/sys/reent.h: Remove _RENT_ONLY check around
        setting of _REENT macro.
2013-06-26 21:34:16 +00:00
Corinna Vinschen de1e3bb2c9 * libc/include/locale.h (NULL): Fetch definition via stddef.h.
* libc/include/stdio.h (NULL): Ditto.
	* libc/include/stdlib.h (NULL): Ditto.
	* libc/include/string.h (NULL): Ditto.
	* libc/include/wchar.h (NULL): Ditto.
	* libc/include/rpc/types.h (NULL): Ditto.
	* libc/include/time.h (NULL): Ditto.  Include stddef.h earlier.
2012-11-01 11:51:12 +00:00
Corinna Vinschen 1f232abc89 Throughout, run newlib with -Wall -Werror option and fix bugs and
compiler warnings found this way.

	* libc/stdio/freopen.c (_freopen_r): Fix bug setting _flags.

	* libc/include/stdio.h (_rename): Define when building newlib.
	* libc/include/sys/signal.h (_kill): Ditto.
	* libc/include/sys/stat.h (_mkdir): Ditto.
	* libc/include/sys/time.h (_gettimeofday): Ditto.
	* libc/include/sys/times.h (_times): Ditto.
	* libc/include/sys/wait.h (_wait): Ditto.
	* libc/locale/lmessages.c (empty): Don't define for Cygwin.
	* libc/locale/lmonetary.c (cnv): Ditto.
	* libc/locale/nl_langinfo.c (nl_langinfo): Ditto for variable s.
	* libc/posix/collate.c: Throughout cast to avoid compiler warning.
	* libc/posix/engine.c (matcher): Initialize dp to avoid compiler
	warning.
	* libc/posix/glob.c: Disable on Cygwin.  Explain why.
	* libc/posix/regcomp.c: Fix "uninitialized" compiler warnings.
	(dissect): Deliberately silence gcc compiler warning.  Add comment to
	explain why.
	* libc/posix/wordexp.c (wordexp): Remove num_bytes variable since result
	is never used.
	* libc/posix/popen.c (popen): Ditto for variable last.
	* libc/reent/mkdirr.c: Include sys/stat.h.
	* libc/reent/renamer.c: Include stdio.h.
	* libc/search/hash.c:  Throughout use underscored variants of the stat
	function family.
	(init_hash): Add missing definition for the __USE_INTERNAL_STAT64 case.
	* libc/search/hash_bigkey.c (__big_insert): Add parenthesis to avoid
	compiler warning.
	* libc/search/hash_page.c (overflow_page): Initalize freep to NULL to
	avoid compiler warning.
	* libc/stdio/asiprintf.c (_asiprintf_r): Cast unsigned char * to char *
	to avoid compiler warning.
	(asiprintf): Ditto.
	* libc/stdio/asprintf.c (_asprintf_r): Ditto.
	(asprintf): Ditto.
	* libc/stdio/vasiprintf.c (_vasiprintf_r): Ditto.
	* libc/stdio/vasprintf.c (_vasprintf_r): Ditto.
	* libc/stdio/mktemp.c (_gettemp): Cast to unsigned char in call to
	isdigit to avoid compiler warning.
	* libc/stdio/vfprintf.c (_VFPRINTF_R): Initialize variables used for
	grouping to avoid compiler warning.  Only define and set nseps and
	nrepeats if they are really used.
	* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Ditto.  Only define state if
	it is really used.
	* libc/stdio/vfscanf.c (u_char): Revert to be defined as unsigned char.
	(__SVFSCANF_R): Cast fmt in call to __mbtowc.
	* libc/stdlib/mbtowc_r.c (JIS_state_table): Disable when building
	Cygwin.
	(JIS_action_table): Ditto.
	* libc/stdlib/wctomb_r.c (__utf8_wctomb): Add parenthesis to avoid
	compiler warning.
	* libc/string/strcasestr.c: Deliberately silence gcc compiler warning.
	Add comment to explain why.
	* libc/time/strptime.c (strptime): Cast to unsigned char in calls to
	isspace to avoid compiler warning.
	* libm/math/e_atan2.c (__ieee754_atan2): Add parenthesis to avoid
	compiler warning.
	* libm/math/e_exp.c (__ieee754_exp): Initialize k to 0 to avoid
	compiler warning.  Drop setting it to 0 later.
	* libm/math/ef_exp.c (__ieee754_expf): Ditto.
	* libm/math/e_pow.c (__ieee754_pow): Add braces to avoid compiler
	warning.
	* libm/math/ef_pow.c (__ieee754_powf): Ditto.
	* libm/math/er_lgamma.c (__ieee754_lgamma_r): Initialize nadj to 0 to
	avoid compiler warning.
	* libm/math/erf_lgamma.c (__ieee754_lgammaf_r): Ditto.
	* libm/math/e_rem_pio2.c (__ieee754_rem_pio2): Ditto for variable z.
	* libm/common/sf_round.c (roundf): Remove signbit variable since result
	is never used.
2012-08-08 11:04:18 +00:00
Corinna Vinschen be7f7a7503 * libc/time/strftime.c: Add support for era and alt_digits data from
LC_TIME locale category.  Conditionalize using _WANT_C99_TIME_FORMATS
	flag.
	(STRTOUL): Define differently for building strftime or wcsftime.
	(STRCPY): Ditto.
	(STRCHR): Ditto.
	(STRLEN): Ditto.
	(CHECK_LENGTH): Define to simplify code.
	(era_info_t): New type to store era info.
	(get_era_info): New function to fetch era info matching incoming
	struct tm.
	(free_era_info): New function to free era info.
	(alt_digits_t): New type to store alternative digits.
	(get_alt_digits): New function to convert alt_digits string into
	alt_digits_t structure.
	(free_alt_digits): New function to free alt_digits info.
	(conv_to_alt_digits): New function to convert unsigned value into
	alternative digits.
	(strftime): Conditionalize on _WANT_C99_TIME_FORMATS.  If
	_WANT_C99_TIME_FORMATS is defined, define as just a wrapper function
	providing era_info and alt_digits pointers and call ...
	(__strftime): Rename from strftime and make static if
	_WANT_C99_TIME_FORMATS is defined.  Add parameters for era_info and
	alt_digits pointers.  Handle conversion modifiers according to
	POSIX-1.2008.  Redefine %F and %Y according to POSIX.  Add default case
	to allow to bail out on invalid conversion specifiers.
	* libc/include/sys/config.h: Move Cygwin build flags to Cygwin's
	config.h.

	* libc/include/stdio.h: Remove __CYGWIN_USE_BIG_TYPES__ condition.
2010-02-26 09:41:44 +00:00
Eric Blake ad0ae5d83a Fix some *at declarations.
* libc/include/stdio.h (symlinkat): Move this...
* libc/include/sys/_default_fcntl.h (unlinkat): ...and this...
* libc/include/sys/unistd.h (symlinkat, unlinkat): ...here, to
match POSIX.
2009-12-08 13:50:41 +00:00
Jeff Johnston 1e1b6f8003 2009-10-16 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/config.h[__CYGWIN__]: Set __USE_XOPEN2K flag
        if not __STRICT_ANSI__ or stdc version C99 or greater.
        * libc/include/stdio.h[__STRICT_ANSI__]: Add __USE_XOPEN2K check
        for fseeko and ftello prototypes.
2009-10-20 16:44:11 +00:00
Eric Blake ce1eb6bba0 Add fpurge.
* libc/stdio/fpurge.c (fpurge, _fpurge_r): New file.
* libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES, fpurge):
Build it.
* libc/stdio/Makefile.in: Regenerated.
* libc/include/stdio.h (fpurge, _fpurge_r): New declarations.
* libc/stdio/stdio.tex: Build documentation.
2009-07-03 11:58:04 +00:00
Corinna Vinschen 56c5c08a5d * libc/include/stdio.h (_ELIDABLE_INLINE): Move definition from here...
* libc/include/_ansi.h (_ELIDABLE_INLINE): ..to here.
2009-04-04 15:44:19 +00:00
Jeff Johnston d74c61c2be 2009-04-03 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* libc/include/stdio.h [__SCLE] (__sgetc_r): Prototype before define
        to avoid a warning with -Wmissing-prototypes.
2009-04-03 22:46:15 +00:00
Corinna Vinschen 71675a3908 * libc/include/stdio.h (_mkstemp_r, _mktemp_r): Move declarations
to stdlib.h.
	* libc/include/stdlib.h (mktemp, _mktemp_r): Warn when using.
	* libc/stdio/mktemp.c: Explain the security risk when using
	mktemp.
2009-03-14 12:14:08 +00:00
Corinna Vinschen 6121968b19 * 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 09:55:52 +00:00
Jeff Johnston 7dd0c33097 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-11 17:27:56 +00:00
Jeff Johnston 0751f22675 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-10 23:43:12 +00:00
Jeff Johnston 0aca33c823 2008-11-24 Craig Howland <howland@LGSInnovations.com>
* libc/stdlib/wcstoull_r.c:  Add EINVAL return for bad base value,
        include wchar.h for prototype, remove extraneous includes, use
        C99/POSIX ULLONG_MAX (but allow for poor limits.h).
        * libc/stdlib/wcstoull.c:  Fix usage comments (mistakes and to add
        base value check noted above), remove extraneous includes.
        * libc/stdio/asnprintf.c:  Add #include "local.h" to get function
        prototype for _svfprintf_r().
        * libc/stdio/vasnprintf.c:  Ditto.
        * libc/stdio/local.h:  Add function prototype for __submore().
        * libc/include/stdio.h:  Add function prototypes for _fseeko_r and
        _ftello_r.
        * libc/posix/namespace.h:  Commented out define for write to
        eliminate write() prototype being missing for collate.c (which is
        the only file that presently includes namespace.h).
        * libc/include/reent.h:  Added _rename_r.
        * libc/reent/renamer.c:  Corrected function prototypes in synopses.
        * libc/locale/ldpart.c:  Use struct stat64 when calling fstat64.
2008-11-24 21:27:33 +00:00
Corinna Vinschen 14773e10a0 * libc/include/stdio.h (__SMOD): Remove definition of unused flag.
* libc/include/sys/reent.h (struct __sFILE): Add _flags2 member.
	* libc/stdio/findfp.c (std): Initialize _flags2.
	(__sfp): Ditto.
	* libc/stdio/refill.c (__srefill_r): Drop resetting __SMOD flag.
	* libc/stdio/vfscanf.c (__ssrefill_r): Ditto.
	* libc/stdio/fseek.c (_fseek_r): Drop checking __SMOD flag.
	* libc/stdio64/fseeko64.c (_fseeko64_r): Ditto.
2008-11-24 17:15:43 +00:00
Corinna Vinschen ca48eb65e9 * libc/include/stdio.h (renameat): Declare for Cygwin.
(symlinkat): Ditto.
	* libc/include/sys/unistd.h (readlink): Align declaration to POSIX.
	(faccessat): Declare for Cygwin.
	(fchownat): Ditto.
	(linkat): Ditto.
	(readlinkat): Ditto.
	* libc/include/sys/_default_fcntl.h (AT_FDCWD): Define for Cygwin.
	(AT_EACCESS): Ditto.
	(AT_SYMLINK_NOFOLLOW): Ditto.
	(AT_SYMLINK_FOLLOW): Ditto.
	(AT_REMOVEDIR): Ditto.
	(futimesat): Declare for Cygwin.
	(openat): Ditto.
	(unlinkat): Ditto.
	* libc/include/sys/stat.h (fchmodat): Ditto.
	(fstatat): Ditto.
	(mkdirat): Ditto.
	(mkfifoat): Ditto.
	(mknodat): Ditto.
2008-04-23 11:13:24 +00:00
Eric Blake 6ddcdb9da5 Implement fmemopen and open_memstream.
* libc/stdio/fmemopen.c (_fmemopen_r, fmemopen): New file.
* libc/stdio/open_memstream.c (_open_memstream_r, open_memstream):
New file.
* libc/stdio/fopencookie.c (fcwriter): Minor optimization.
* libc/include/stdio.h (dprintf, vdprintf): Group all POSIX 200x
functions together.
(fmemopen, open_memstream): Declare new functions.
* libc/stdio/stdio.tex: Document them.
* libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES): Add
fmemopen and open_memstream.
* libc/stdio/Makefile.in: Regenerate.
2007-08-02 20:23:06 +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
Eric Blake b9db529222 Add support for asnprintf, and improve *printf documentation.
* libc/stdio/Makefile.am (ELIX_SOURCES): Rename...
	(ELIX_2_SOURCES): ...to this.
	(ELIX_4_SOURCES): Add new variable.  Build asnprintf.
	(GENERAL_SOURCES): Move dprintf to ELIX_4_SOURCES.
	(CHEWOUT_FILES): Include diprintf in documentation.
	* libc/stdio/Makefile.in: Regenerate.
	* libc/stdio/diprintf.c: Improve documentation.
	* libc/stdio/dprintf.c: Likewise.
	* libc/stdio/siprintf.c: Likewise.
	* libc/stdio/sprintf.c: Likewise.
	* libc/stdio/vfprintf.c: Likewise.
	* libc/stdio/viprintf.c: Likewise.
	* libc/stdio/vsniprintf.c: Consolidate documentation.
	* libc/stdio/asiprintf.c: Refer to documentation.
	* libc/stdio/asprintf.c: Likewise.
	* libc/stdio/fiprintf.c: Likewise.
	* libc/stdio/fprintf.c: Likewise.
	* libc/stdio/iprintf.c: Likewise.
	* libc/stdio/printf.c: Likewise.
	* libc/stdio/sniprintf.c: Likewise.
	* libc/stdio/vdiprintf.c: Likewise.
	* libc/stdio/vdprintf.c: Likewise.
	* libc/stdio/vsiprintf.c: Likewise.
	* libc/stdio/fvwrite.c (__sfvwrite_r): Handle asnprintf.
	* libc/stdio/asniprintf.c (asniprintf, _asniprintf_r): New file.
	* libc/stdio/asnprintf.c (asnprintf, _asnprintf_r): New file.
	* libc/stdio/vasniprintf.c (vasniprintf, _vasniprintf_r): New
	file.
	* libc/stdio/vasnprintf.c (vasnprintf, _vasnprintf_r): New file.
	* libc/stdio/vdprintf.c (_vdprintf_r): Rewrite to avoid malloc in
	typical case.
	* libc/stdio/vdiprintf.c (_vdiprintf_r): Likewise.
	* libc/include/stdio.h: Add prototypes for new functions; sort
	existing functions.
2007-05-04 02:55:16 +00:00
Eric Blake 503e2d1c76 * libc/include/stdio.h (_ELIDABLE_INLINE): Work even when using
CFLAGS=-O0.
2007-04-10 12:49:18 +00:00