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>
This commit is contained in:
parent
5c78499ae2
commit
feec81e571
|
@ -128,7 +128,7 @@ typedef _fpos64_t fpos64_t;
|
|||
#define L_tmpnam FILENAME_MAX
|
||||
#endif
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE
|
||||
#define P_tmpdir "/tmp"
|
||||
#endif
|
||||
|
||||
|
@ -230,7 +230,7 @@ int _EXFUN(rename, (const char *, const char *));
|
|||
int _EXFUN(_rename, (const char *, const char *));
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K)
|
||||
#if __LARGEFILE_VISIBLE
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(fseeko, (FILE *, _off_t, int));
|
||||
_off_t _EXFUN(ftello, ( FILE *));
|
||||
|
@ -242,16 +242,32 @@ off_t _EXFUN(ftello, ( FILE *));
|
|||
#if __GNU_VISIBLE
|
||||
int _EXFUN(fcloseall, (_VOID));
|
||||
#endif
|
||||
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
|
||||
#ifndef _REENT_ONLY
|
||||
#if __ISO_C_VISIBLE >= 1999
|
||||
int _EXFUN(snprintf, (char *__restrict, size_t, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(vfscanf, (FILE *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(vscanf, (const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
|
||||
int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
#endif
|
||||
#if __GNU_VISIBLE
|
||||
int _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
int _EXFUN(vasprintf, (char **, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
#endif
|
||||
#if __MISC_VISIBLE /* Newlib-specific */
|
||||
int _EXFUN(asiprintf, (char **, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
char * _EXFUN(asnprintf, (char *__restrict, size_t *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
#ifndef diprintf
|
||||
int _EXFUN(diprintf, (int, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
|
@ -268,8 +284,6 @@ int _EXFUN(siprintf, (char *, const char *, ...)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
int _EXFUN(siscanf, (const char *, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
|
||||
int _EXFUN(snprintf, (char *__restrict, size_t, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(sniprintf, (char *, size_t, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(vasiprintf, (char **, const char *, __VALIST)
|
||||
|
@ -278,56 +292,50 @@ char * _EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(vasprintf, (char **, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(vdiprintf, (int, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(vfscanf, (FILE *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(viprintf, (const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 1, 0))));
|
||||
int _EXFUN(viscanf, (const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
|
||||
int _EXFUN(vscanf, (const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
|
||||
int _EXFUN(vsiprintf, (char *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(vsiscanf, (const char *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
#endif /* __MISC_VISIBLE */
|
||||
#endif /* !_REENT_ONLY */
|
||||
#endif /* !__STRICT_ANSI__ */
|
||||
|
||||
/*
|
||||
* Routines in POSIX 1003.1:2001.
|
||||
*/
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
||||
#if __POSIX_VISIBLE
|
||||
#ifndef _REENT_ONLY
|
||||
FILE * _EXFUN(fdopen, (int, const char *));
|
||||
#endif
|
||||
int _EXFUN(fileno, (FILE *));
|
||||
#endif
|
||||
#if __MISC_VISIBLE || __POSIX_VISIBLE >= 199209
|
||||
int _EXFUN(pclose, (FILE *));
|
||||
FILE * _EXFUN(popen, (const char *, const char *));
|
||||
#endif
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || __BSD_VISIBLE
|
||||
#if __BSD_VISIBLE
|
||||
void _EXFUN(setbuffer, (FILE *, char *, int));
|
||||
int _EXFUN(setlinebuf, (FILE *));
|
||||
#endif
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
||||
#if __MISC_VISIBLE || (__XSI_VISIBLE && __POSIX_VISIBLE < 200112)
|
||||
int _EXFUN(getw, (FILE *));
|
||||
int _EXFUN(putw, (int, FILE *));
|
||||
#endif
|
||||
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
||||
int _EXFUN(getc_unlocked, (FILE *));
|
||||
int _EXFUN(getchar_unlocked, (void));
|
||||
void _EXFUN(flockfile, (FILE *));
|
||||
|
@ -341,7 +349,7 @@ int _EXFUN(putchar_unlocked, (int));
|
|||
* Routines in POSIX 1003.1:200x.
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
# ifndef _REENT_ONLY
|
||||
# ifndef dprintf
|
||||
int _EXFUN(dprintf, (int, const char *__restrict, ...)
|
||||
|
@ -351,13 +359,13 @@ FILE * _EXFUN(fmemopen, (void *__restrict, size_t, const char *__restrict));
|
|||
/* getdelim - see __getdelim for now */
|
||||
/* getline - see __getline for now */
|
||||
FILE * _EXFUN(open_memstream, (char **, size_t *));
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
|
||||
int _EXFUN(renameat, (int, const char *, int, const char *));
|
||||
#endif
|
||||
int _EXFUN(vdprintf, (int, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
# endif
|
||||
#endif
|
||||
#if __ATFILE_VISIBLE
|
||||
int _EXFUN(renameat, (int, const char *, int, const char *));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Recursive versions of the above.
|
||||
|
@ -501,7 +509,7 @@ int _EXFUN(fpurge, (FILE *));
|
|||
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *));
|
||||
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
#if __MISC_VISIBLE
|
||||
void _EXFUN(clearerr_unlocked, (FILE *));
|
||||
int _EXFUN(feof_unlocked, (FILE *));
|
||||
int _EXFUN(ferror_unlocked, (FILE *));
|
||||
|
@ -551,7 +559,7 @@ int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
|
|||
* Stdio function-access interface.
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if __BSD_VISIBLE
|
||||
# ifdef __LARGE64_FILES
|
||||
FILE *_EXFUN(funopen,(const _PTR __cookie,
|
||||
int (*__readfn)(_PTR __c, char *__buf,
|
||||
|
@ -588,7 +596,9 @@ FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
|
|||
(fpos_t (*)())0, (int (*)())0)
|
||||
# define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \
|
||||
(fpos_t (*)())0, (int (*)())0)
|
||||
#endif /* __BSD_VISIBLE */
|
||||
|
||||
#if __GNU_VISIBLE
|
||||
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);
|
||||
|
@ -612,7 +622,7 @@ FILE *_EXFUN(fopencookie,(void *__cookie,
|
|||
const char *__mode, cookie_io_functions_t __functions));
|
||||
FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie,
|
||||
const char *__mode, cookie_io_functions_t __functions));
|
||||
#endif /* ! __STRICT_ANSI__ */
|
||||
#endif /* __GNU_VISIBLE */
|
||||
|
||||
#ifndef __CUSTOM_FILE_IO__
|
||||
/*
|
||||
|
@ -694,14 +704,14 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
|||
#define ferror(p) __sferror(p)
|
||||
#define clearerr(p) __sclearerr(p)
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
#if __MISC_VISIBLE
|
||||
#define feof_unlocked(p) __sfeof(p)
|
||||
#define ferror_unlocked(p) __sferror(p)
|
||||
#define clearerr_unlocked(p) __sclearerr(p)
|
||||
#endif /* __BSD_VISIBLE */
|
||||
#endif /* __MISC_VISIBLE */
|
||||
#endif /* _REENT_SMALL */
|
||||
|
||||
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
|
||||
#if 0 /* __POSIX_VISIBLE - FIXME: must initialize stdio first, use fn */
|
||||
#define fileno(p) __sfileno(p)
|
||||
#endif
|
||||
|
||||
|
@ -712,11 +722,13 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
|||
#endif /* lint */
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if __MISC_VISIBLE
|
||||
/* fast always-buffered version, true iff error */
|
||||
#define fast_putc(x,p) (--(p)->_w < 0 ? \
|
||||
__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
|
||||
#endif
|
||||
|
||||
#if __XSI_VISIBLE
|
||||
#define L_cuserid 9 /* posix says it goes in stdio.h :( */
|
||||
#ifdef __CYGWIN__
|
||||
#define L_ctermid 16
|
||||
|
@ -728,7 +740,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
|||
#define getchar() getc(stdin)
|
||||
#define putchar(x) putc(x, stdout)
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
||||
#define getchar_unlocked() getc_unlocked(stdin)
|
||||
#define putchar_unlocked(x) putc_unlocked(x, stdout)
|
||||
#endif
|
||||
|
|
|
@ -82,6 +82,7 @@ It is not portable. See also the <<funopen>> interface from BSD.
|
|||
Supporting OS subroutines required: <<sbrk>>.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/lock.h>
|
||||
|
|
Loading…
Reference in New Issue