From patchwork Tue Dec 26 06:10:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 25098 Received: (qmail 78719 invoked by alias); 26 Dec 2017 06:10:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 78672 invoked by uid 89); 26 Dec 2017 06:10:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=32515, 9511 X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH 2/3] Minimize use of _IO_ and _G_ symbols in public headers. Date: Tue, 26 Dec 2017 01:10:51 -0500 Message-Id: <20171226061052.20907-3-zackw@panix.com> In-Reply-To: <20171226061052.20907-1-zackw@panix.com> References: <20171226061052.20907-1-zackw@panix.com> MIME-Version: 1.0 This is groundwork for removing the inclusion of (bits/)libio.h from stdio.h. It doesn't make a whole lot of sense by itself, but it is also much more mechanical than the next piece, which involves moving the definition of struct _IO_FILE. * libio/bits/types/__fpos64_t.h, libio/bits/types/__fpos_t.h * libio/bits/types/cookie_io_functions_t.h: New single-type headers. * include/bits/types/__fpos64_t.h, include/bits/types/__fpos_t.h * include/bits/types/cookie_io_functions_t.h: New wrappers. * libio/Makefile: Install the new headers. * libio/stdio.h: Get __gnuc_va_list directly from stdarg.h. Get __fpos_t, __fpos64_t, and cookie_io_functions_t from the new headers. Don't use _G_ names when defining va_list, fpos_t, or fpos64_t. Define BUFSIZ unconditionally as 8192, and EOF unconditionally as (-1). Declare stdin, stdout, and stderr with type FILE. Use cookie_io_functions_t instead of _IO_cookie_io_functions_t, __gnuc_va_list instead of _G_va_list, and __ssize_t instead of _IO_ssize_t. Move getc and putc macros and inclusion of bits/libio.h to bottom of file. * libio/bits/stdio.h, libio/bits/stdio2.h: Use __ssize_t instead of _IO_ssize_t, and __gnuc_va_list instead of _G_va_list. * bits/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h: Get definitions of __fpos_t and __fpos64_t from the new headers. Define _G_fpos_t as __fpos_t and _G_fpos64_t as __fpos64_t. * libio/bits/libio.h: Include stdio.h and don't repeat anything that it does. Define _IO_BUFSIZ as BUFSIZ, _IO_fpos_t as __fpos_t, _IO_fpos64_t as __fpos64_t, _IO_va_list as __gnuc_va_list, __io_read_fn as cookie_read_fn_t, __io_write_fn as cookie_write_fn_t, __io_seek_fn as cookie_seek_fn_t, __io_close_fn as cookie_close_fn_t, and _IO_cookie_io_functions_t as cookie_io_functions_t. --- NEWS | 3 + bits/_G_config.h | 17 ++--- include/bits/types/__fpos64_t.h | 1 + include/bits/types/__fpos_t.h | 1 + include/bits/types/cookie_io_functions_t.h | 1 + libio/Makefile | 3 +- libio/bits/libio.h | 87 ++++------------------- libio/bits/stdio.h | 4 +- libio/bits/stdio2.h | 28 ++++---- libio/bits/types/__fpos64_t.h | 13 ++++ libio/bits/types/__fpos_t.h | 13 ++++ libio/bits/types/cookie_io_functions_t.h | 41 +++++++++++ libio/stdio.h | 107 +++++++++++++++-------------- stdio-common/vfprintf.c | 7 +- sysdeps/unix/sysv/linux/bits/_G_config.h | 16 ++--- 15 files changed, 173 insertions(+), 169 deletions(-) create mode 100644 include/bits/types/__fpos64_t.h create mode 100644 include/bits/types/__fpos_t.h create mode 100644 include/bits/types/cookie_io_functions_t.h create mode 100644 libio/bits/types/__fpos64_t.h create mode 100644 libio/bits/types/__fpos_t.h create mode 100644 libio/bits/types/cookie_io_functions_t.h diff --git a/NEWS b/NEWS index 95f368340b..7a75891e6b 100644 --- a/NEWS +++ b/NEWS @@ -121,6 +121,9 @@ Deprecated and removed features, and other changes affecting compatibility: any remaining external users. _G_config.h was never intended for public use, but predates the bits convention. +* The C++ name mangling for interfaces involving the types fpos_t and + fpos64_t has changed. + Changes to build and runtime requirements: * bison version 2.7 or later is required to generate code in the 'intl' diff --git a/bits/_G_config.h b/bits/_G_config.h index 2b60d29f5f..6da3c5f0f6 100644 --- a/bits/_G_config.h +++ b/bits/_G_config.h @@ -19,20 +19,17 @@ #include #include +#include +#include + +#define _G_fpos_t __fpos_t +#define _G_fpos64_t __fpos64_t + #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # include #endif -typedef struct -{ - __off_t __pos; - __mbstate_t __state; -} _G_fpos_t; -typedef struct -{ - __off64_t __pos; - __mbstate_t __state; -} _G_fpos64_t; + #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # include typedef union diff --git a/include/bits/types/__fpos64_t.h b/include/bits/types/__fpos64_t.h new file mode 100644 index 0000000000..68cc4e8b66 --- /dev/null +++ b/include/bits/types/__fpos64_t.h @@ -0,0 +1 @@ +#include diff --git a/include/bits/types/__fpos_t.h b/include/bits/types/__fpos_t.h new file mode 100644 index 0000000000..2dcdc98d75 --- /dev/null +++ b/include/bits/types/__fpos_t.h @@ -0,0 +1 @@ +#include diff --git a/include/bits/types/cookie_io_functions_t.h b/include/bits/types/cookie_io_functions_t.h new file mode 100644 index 0000000000..87f7930c6e --- /dev/null +++ b/include/bits/types/cookie_io_functions_t.h @@ -0,0 +1 @@ +#include diff --git a/libio/Makefile b/libio/Makefile index 6eb03ab1fa..b0cf4d44fc 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -25,7 +25,8 @@ include ../Makeconfig headers := stdio.h libio.h _G_config.h \ bits/stdio.h bits/libio.h bits/_G_config.h \ bits/sys_errlist.h bits/stdio2.h bits/stdio-ldbl.h bits/libio-ldbl.h \ - bits/types/FILE.h bits/types/__FILE.h + bits/types/FILE.h bits/types/__FILE.h bits/types/__fpos_t.h \ + bits/types/__fpos64_t.h bits/types/cookie_io_functions_t.h routines := \ filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ diff --git a/libio/bits/libio.h b/libio/bits/libio.h index 485b4577e6..05668c4280 100644 --- a/libio/bits/libio.h +++ b/libio/bits/libio.h @@ -32,10 +32,12 @@ # error "Never include directly; use instead." #endif +#include + #include /* ALL of these should be defined in _G_config.h */ -#define _IO_fpos_t _G_fpos_t -#define _IO_fpos64_t _G_fpos64_t +#define _IO_fpos_t __fpos_t +#define _IO_fpos64_t __fpos64_t #define _IO_size_t size_t #define _IO_ssize_t __ssize_t #define _IO_off_t __off_t @@ -44,40 +46,13 @@ #define _IO_uid_t __uid_t #define _IO_iconv_t _G_iconv_t #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE -#define _IO_BUFSIZ _G_BUFSIZ -#define _IO_va_list _G_va_list +#define _IO_BUFSIZ BUFSIZ #define _IO_wint_t wint_t +#define _IO_va_list __gnuc_va_list -/* This define avoids name pollution if we're using GNU stdarg.h */ -#define __need___va_list -#include -#ifdef __GNUC_VA_LIST -# undef _IO_va_list -# define _IO_va_list __gnuc_va_list -#endif /* __GNUC_VA_LIST */ - -#ifndef __P -# include -#endif /*!__P*/ - +#define _STDIO_USES_IOSTREAM #define _IO_UNIFIED_JUMPTABLES 1 -#ifndef EOF -# define EOF (-1) -#endif -#ifndef NULL -# if defined __GNUG__ && \ - (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) -# define NULL (__null) -# else -# if !defined(__cplusplus) -# define NULL ((void*)0) -# else -# define NULL (0) -# endif -# endif -#endif - #define _IOS_INPUT 1 #define _IOS_OUTPUT 2 #define _IOS_ATEND 4 @@ -330,49 +305,13 @@ extern _IO_FILE *_IO_stderr attribute_hidden; #endif -/* Functions to do I/O and file management for a stream. */ - -/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF. - Return number of bytes read. */ -typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); - -/* Write N bytes pointed to by BUF to COOKIE. Write all N bytes - unless there is an error. Return number of bytes written. If - there is an error, return 0 and do not write anything. If the file - has been opened for append (__mode.__append set), then set the file - pointer to the end of the file and then do the write; if not, just - write at the current file pointer. */ -typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf, - size_t __n); - -/* Move COOKIE's file position to *POS bytes from the - beginning of the file (if W is SEEK_SET), - the current position (if W is SEEK_CUR), - or the end of the file (if W is SEEK_END). - Set *POS to the new file position. - Returns zero if successful, nonzero if not. */ -typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w); - -/* Close COOKIE. */ -typedef int __io_close_fn (void *__cookie); - - +/* Compatibility names for cookie I/O functions. */ #ifdef __USE_GNU -/* User-visible names for the above. */ -typedef __io_read_fn cookie_read_function_t; -typedef __io_write_fn cookie_write_function_t; -typedef __io_seek_fn cookie_seek_function_t; -typedef __io_close_fn cookie_close_function_t; - -/* The structure with the cookie function pointers. */ -typedef struct -{ - __io_read_fn *read; /* Read bytes. */ - __io_write_fn *write; /* Write bytes. */ - __io_seek_fn *seek; /* Seek/tell file position. */ - __io_close_fn *close; /* Close file. */ -} _IO_cookie_io_functions_t; -typedef _IO_cookie_io_functions_t cookie_io_functions_t; +typedef cookie_read_function_t __io_read_fn; +typedef cookie_write_function_t __io_write_fn; +typedef cookie_seek_function_t __io_seek_fn; +typedef cookie_close_function_t __io_close_fn; +typedef cookie_io_functions_t _IO_cookie_io_functions_t; struct _IO_cookie_file; diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h index 21ad2fb20c..601fc27569 100644 --- a/libio/bits/stdio.h +++ b/libio/bits/stdio.h @@ -33,7 +33,7 @@ # if !(__USE_FORTIFY_LEVEL > 0 && defined __fortify_function) /* Write formatted output to stdout from argument list ARG. */ __STDIO_INLINE int -vprintf (const char *__restrict __fmt, _G_va_list __arg) +vprintf (const char *__restrict __fmt, __gnuc_va_list __arg) { return vfprintf (stdout, __fmt, __arg); } @@ -111,7 +111,7 @@ putchar_unlocked (int __c) # ifdef __USE_GNU /* Like `getdelim', but reads up to a newline. */ -__STDIO_INLINE _IO_ssize_t +__STDIO_INLINE __ssize_t getline (char **__lineptr, size_t *__n, FILE *__stream) { return __getdelim (__lineptr, __n, '\n', __stream); diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h index e9f9d6952b..16fd38aebb 100644 --- a/libio/bits/stdio2.h +++ b/libio/bits/stdio2.h @@ -24,7 +24,7 @@ extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen, const char *__restrict __format, ...) __THROW; extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen, const char *__restrict __format, - _G_va_list __ap) __THROW; + __gnuc_va_list __ap) __THROW; #ifdef __va_arg_pack __fortify_function int @@ -41,7 +41,7 @@ __NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...)) __fortify_function int __NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt, - _G_va_list __ap)) + __gnuc_va_list __ap)) { return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, __bos (__s), __fmt, __ap); @@ -54,7 +54,7 @@ extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag, ...) __THROW; extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, size_t __slen, const char *__restrict __format, - _G_va_list __ap) __THROW; + __gnuc_va_list __ap) __THROW; # ifdef __va_arg_pack __fortify_function int @@ -72,7 +72,7 @@ __NTH (snprintf (char *__restrict __s, size_t __n, __fortify_function int __NTH (vsnprintf (char *__restrict __s, size_t __n, - const char *__restrict __fmt, _G_va_list __ap)) + const char *__restrict __fmt, __gnuc_va_list __ap)) { return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, __bos (__s), __fmt, __ap); @@ -86,9 +86,9 @@ extern int __fprintf_chk (FILE *__restrict __stream, int __flag, const char *__restrict __format, ...); extern int __printf_chk (int __flag, const char *__restrict __format, ...); extern int __vfprintf_chk (FILE *__restrict __stream, int __flag, - const char *__restrict __format, _G_va_list __ap); + const char *__restrict __format, __gnuc_va_list __ap); extern int __vprintf_chk (int __flag, const char *__restrict __format, - _G_va_list __ap); + __gnuc_va_list __ap); # ifdef __va_arg_pack __fortify_function int @@ -111,7 +111,7 @@ printf (const char *__restrict __fmt, ...) # endif __fortify_function int -vprintf (const char *__restrict __fmt, _G_va_list __ap) +vprintf (const char *__restrict __fmt, __gnuc_va_list __ap) { #ifdef __USE_EXTERN_INLINES return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); @@ -122,7 +122,7 @@ vprintf (const char *__restrict __fmt, _G_va_list __ap) __fortify_function int vfprintf (FILE *__restrict __stream, - const char *__restrict __fmt, _G_va_list __ap) + const char *__restrict __fmt, __gnuc_va_list __ap) { return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); } @@ -131,7 +131,7 @@ vfprintf (FILE *__restrict __stream, extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern int __vdprintf_chk (int __fd, int __flag, - const char *__restrict __fmt, _G_va_list __arg) + const char *__restrict __fmt, __gnuc_va_list __arg) __attribute__ ((__format__ (__printf__, 3, 0))); # ifdef __va_arg_pack @@ -147,7 +147,7 @@ dprintf (int __fd, const char *__restrict __fmt, ...) # endif __fortify_function int -vdprintf (int __fd, const char *__restrict __fmt, _G_va_list __ap) +vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap) { return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); } @@ -159,7 +159,7 @@ extern int __asprintf_chk (char **__restrict __ptr, int __flag, const char *__restrict __fmt, ...) __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur; extern int __vasprintf_chk (char **__restrict __ptr, int __flag, - const char *__restrict __fmt, _G_va_list __arg) + const char *__restrict __fmt, __gnuc_va_list __arg) __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur; extern int __obstack_printf_chk (struct obstack *__restrict __obstack, int __flag, const char *__restrict __format, @@ -168,7 +168,7 @@ extern int __obstack_printf_chk (struct obstack *__restrict __obstack, extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack, int __flag, const char *__restrict __format, - _G_va_list __args) + __gnuc_va_list __args) __THROW __attribute__ ((__format__ (__printf__, 3, 0))); # ifdef __va_arg_pack @@ -205,14 +205,14 @@ __NTH (obstack_printf (struct obstack *__restrict __obstack, __fortify_function int __NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt, - _G_va_list __ap)) + __gnuc_va_list __ap)) { return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); } __fortify_function int __NTH (obstack_vprintf (struct obstack *__restrict __obstack, - const char *__restrict __fmt, _G_va_list __ap)) + const char *__restrict __fmt, __gnuc_va_list __ap)) { return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); diff --git a/libio/bits/types/__fpos64_t.h b/libio/bits/types/__fpos64_t.h new file mode 100644 index 0000000000..dbfdd1ff8e --- /dev/null +++ b/libio/bits/types/__fpos64_t.h @@ -0,0 +1,13 @@ +#ifndef _____fpos64_t_defined +#define _____fpos64_t_defined 1 + +#include +#include + +typedef struct +{ + __off64_t __pos; + __mbstate_t __state; +} __fpos64_t; + +#endif diff --git a/libio/bits/types/__fpos_t.h b/libio/bits/types/__fpos_t.h new file mode 100644 index 0000000000..dd00762bf8 --- /dev/null +++ b/libio/bits/types/__fpos_t.h @@ -0,0 +1,13 @@ +#ifndef _____fpos_t_defined +#define _____fpos_t_defined 1 + +#include +#include + +typedef struct +{ + __off_t __pos; + __mbstate_t __state; +} __fpos_t; + +#endif diff --git a/libio/bits/types/cookie_io_functions_t.h b/libio/bits/types/cookie_io_functions_t.h new file mode 100644 index 0000000000..2942f85c3a --- /dev/null +++ b/libio/bits/types/cookie_io_functions_t.h @@ -0,0 +1,41 @@ +#ifndef __cookie_io_functions_t_defined +#define __cookie_io_functions_t_defined 1 + +#include + +/* Functions to do I/O and file management for a stream. */ + +/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF. + Return number of bytes read. */ +typedef __ssize_t cookie_read_function_t (void *__cookie, char *__buf, size_t __nbytes); + +/* Write NBYTES bytes pointed to by BUF to COOKIE. Write all NBYTES bytes + unless there is an error. Return number of bytes written. If + there is an error, return 0 and do not write anything. If the file + has been opened for append (__mode.__append set), then set the file + pointer to the end of the file and then do the write; if not, just + write at the current file pointer. */ +typedef __ssize_t cookie_write_function_t (void *__cookie, const char *__buf, + size_t __nbytes); + +/* Move COOKIE's file position to *POS bytes from the + beginning of the file (if W is SEEK_SET), + the current position (if W is SEEK_CUR), + or the end of the file (if W is SEEK_END). + Set *POS to the new file position. + Returns zero if successful, nonzero if not. */ +typedef int cookie_seek_function_t (void *__cookie, __off64_t *__pos, int __w); + +/* Close COOKIE. */ +typedef int cookie_close_function_t (void *__cookie); + +/* The structure with the cookie function pointers. */ +typedef struct +{ + cookie_read_function_t *read; /* Read bytes. */ + cookie_write_function_t *write; /* Write bytes. */ + cookie_seek_function_t *seek; /* Seek/tell file position. */ + cookie_close_function_t *close; /* Close file. */ +} cookie_io_functions_t; + +#endif diff --git a/libio/stdio.h b/libio/stdio.h index 6798cf1afb..8cf6412993 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -32,18 +32,23 @@ __BEGIN_DECLS #define __need_NULL #include +#define __need___va_list +#include + #include +#include +#include #include #include -#define _STDIO_USES_IOSTREAM - -#include +#ifdef __USE_GNU +# include +#endif #if defined __USE_XOPEN || defined __USE_XOPEN2K8 # ifdef __GNUC__ # ifndef _VA_LIST_DEFINED -typedef _G_va_list va_list; +typedef __gnuc_va_list va_list; # define _VA_LIST_DEFINED # endif # else @@ -75,12 +80,12 @@ typedef __ssize_t ssize_t; /* The type of the second argument to `fgetpos' and `fsetpos'. */ #ifndef __USE_FILE_OFFSET64 -typedef _G_fpos_t fpos_t; +typedef __fpos_t fpos_t; #else -typedef _G_fpos64_t fpos_t; +typedef __fpos64_t fpos_t; #endif #ifdef __USE_LARGEFILE64 -typedef _G_fpos64_t fpos64_t; +typedef __fpos64_t fpos64_t; #endif /* The possibilities for the third argument to `setvbuf'. */ @@ -90,16 +95,11 @@ typedef _G_fpos64_t fpos64_t; /* Default buffer size. */ -#ifndef BUFSIZ -# define BUFSIZ _IO_BUFSIZ -#endif +#define BUFSIZ 8192 -/* End of file character. - Some things throughout the library rely on this being -1. */ -#ifndef EOF -# define EOF (-1) -#endif +/* End of file character. */ +#define EOF (-1) /* The possibilities for the third argument to `fseek'. @@ -132,9 +132,9 @@ typedef _G_fpos64_t fpos64_t; /* Standard streams. */ -extern struct _IO_FILE *stdin; /* Standard input stream. */ -extern struct _IO_FILE *stdout; /* Standard output stream. */ -extern struct _IO_FILE *stderr; /* Standard error output stream. */ +extern FILE *stdin; /* Standard input stream. */ +extern FILE *stdout; /* Standard output stream. */ +extern FILE *stderr; /* Standard error output stream. */ /* C89/C99 say they're macros. Make them happy. */ #define stdin stdin #define stdout stdout @@ -270,7 +270,7 @@ extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur; and uses the given functions for input and output. */ extern FILE *fopencookie (void *__restrict __magic_cookie, const char *__restrict __modes, - _IO_cookie_io_functions_t __io_funcs) __THROW __wur; + cookie_io_functions_t __io_funcs) __THROW __wur; #endif #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) @@ -325,15 +325,15 @@ extern int sprintf (char *__restrict __s, This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, - _G_va_list __arg); + __gnuc_va_list __arg); /* Write formatted output to stdout from argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ -extern int vprintf (const char *__restrict __format, _G_va_list __arg); +extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); /* Write formatted output to S from argument list ARG. */ extern int vsprintf (char *__restrict __s, const char *__restrict __format, - _G_va_list __arg) __THROWNL; + __gnuc_va_list __arg) __THROWNL; #if defined __USE_ISOC99 || defined __USE_UNIX98 /* Maximum chars of output to write in MAXLEN. */ @@ -342,7 +342,7 @@ extern int snprintf (char *__restrict __s, size_t __maxlen, __THROWNL __attribute__ ((__format__ (__printf__, 3, 4))); extern int vsnprintf (char *__restrict __s, size_t __maxlen, - const char *__restrict __format, _G_va_list __arg) + const char *__restrict __format, __gnuc_va_list __arg) __THROWNL __attribute__ ((__format__ (__printf__, 3, 0))); #endif @@ -350,7 +350,7 @@ extern int vsnprintf (char *__restrict __s, size_t __maxlen, /* Write formatted output to a string dynamically allocated with `malloc'. Store the address of the string in *PTR. */ extern int vasprintf (char **__restrict __ptr, const char *__restrict __f, - _G_va_list __arg) + __gnuc_va_list __arg) __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur; extern int __asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) @@ -363,7 +363,7 @@ extern int asprintf (char **__restrict __ptr, #ifdef __USE_XOPEN2K8 /* Write formatted output to a file descriptor. */ extern int vdprintf (int __fd, const char *__restrict __fmt, - _G_va_list __arg) + __gnuc_va_list __arg) __attribute__ ((__format__ (__printf__, 2, 0))); extern int dprintf (int __fd, const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); @@ -418,19 +418,19 @@ extern int __isoc99_sscanf (const char *__restrict __s, This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, - _G_va_list __arg) + __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; /* Read formatted input from stdin into argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ -extern int vscanf (const char *__restrict __format, _G_va_list __arg) +extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; /* Read formatted input from S into argument list ARG. */ extern int vsscanf (const char *__restrict __s, - const char *__restrict __format, _G_va_list __arg) + const char *__restrict __format, __gnuc_va_list __arg) __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); # if !defined __USE_GNU \ @@ -442,26 +442,26 @@ extern int vsscanf (const char *__restrict __s, s, S or [. */ extern int __REDIRECT (vfscanf, (FILE *__restrict __s, - const char *__restrict __format, _G_va_list __arg), + const char *__restrict __format, __gnuc_va_list __arg), __isoc99_vfscanf) __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; extern int __REDIRECT (vscanf, (const char *__restrict __format, - _G_va_list __arg), __isoc99_vscanf) + __gnuc_va_list __arg), __isoc99_vscanf) __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; extern int __REDIRECT_NTH (vsscanf, (const char *__restrict __s, const char *__restrict __format, - _G_va_list __arg), __isoc99_vsscanf) + __gnuc_va_list __arg), __isoc99_vsscanf) __attribute__ ((__format__ (__scanf__, 2, 0))); # else extern int __isoc99_vfscanf (FILE *__restrict __s, const char *__restrict __format, - _G_va_list __arg) __wur; + __gnuc_va_list __arg) __wur; extern int __isoc99_vscanf (const char *__restrict __format, - _G_va_list __arg) __wur; + __gnuc_va_list __arg) __wur; extern int __isoc99_vsscanf (const char *__restrict __s, const char *__restrict __format, - _G_va_list __arg) __THROW; + __gnuc_va_list __arg) __THROW; # define vfscanf __isoc99_vfscanf # define vscanf __isoc99_vscanf # define vsscanf __isoc99_vsscanf @@ -483,10 +483,6 @@ extern int getc (FILE *__stream); marked with __THROW. */ extern int getchar (void); -/* The C standard explicitly says this is a macro, so we always do the - optimization for it. */ -#define getc(_fp) _IO_getc (_fp) - #ifdef __USE_POSIX199506 /* These are defined in POSIX.1:1996. @@ -523,10 +519,6 @@ extern int putc (int __c, FILE *__stream); marked with __THROW. */ extern int putchar (int __c); -/* The C standard explicitly says this can be a macro, - so we always do the optimization for it. */ -#define putc(_ch, _fp) _IO_putc (_ch, _fp) - #ifdef __USE_MISC /* Faster version when locking is not necessary. @@ -600,12 +592,12 @@ extern char *fgets_unlocked (char *__restrict __s, int __n, cancellation point. But due to similarity with an POSIX interface or due to the implementation they are cancellation points and therefore not marked with __THROW. */ -extern _IO_ssize_t __getdelim (char **__restrict __lineptr, - size_t *__restrict __n, int __delimiter, - FILE *__restrict __stream) __wur; -extern _IO_ssize_t getdelim (char **__restrict __lineptr, - size_t *__restrict __n, int __delimiter, - FILE *__restrict __stream) __wur; +extern __ssize_t __getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) __wur; +extern __ssize_t getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) __wur; /* Like `getdelim', but reads up to a newline. @@ -613,9 +605,9 @@ extern _IO_ssize_t getdelim (char **__restrict __lineptr, cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ -extern _IO_ssize_t getline (char **__restrict __lineptr, - size_t *__restrict __n, - FILE *__restrict __stream) __wur; +extern __ssize_t getline (char **__restrict __lineptr, + size_t *__restrict __n, + FILE *__restrict __stream) __wur; #endif @@ -828,7 +820,7 @@ extern int obstack_printf (struct obstack *__restrict __obstack, __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))); extern int obstack_vprintf (struct obstack *__restrict __obstack, const char *__restrict __format, - _G_va_list __args) + __gnuc_va_list __args) __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))); #endif /* Use GNU. */ @@ -853,6 +845,17 @@ extern void funlockfile (FILE *__stream) __THROW; # include #endif +/* Internal definitions used by optimizing inlines. */ +#include + +/* The C standard explicitly says this can be a macro, + so we always do the optimization for it. */ +#define getc(_fp) _IO_getc (_fp) + +/* The C standard explicitly says this can be a macro, + so we always do the optimization for it. */ +#define putc(_ch, _fp) _IO_putc (_ch, _fp) + /* If we are compiling with optimizing read this file. It contains several optimizing inline functions and macros. */ #ifdef __USE_EXTERN_INLINES diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c index e272237307..c2d833c002 100644 --- a/stdio-common/vfprintf.c +++ b/stdio-common/vfprintf.c @@ -39,13 +39,8 @@ Beside this it is also shared between the normal and wide character implementation as defined in ISO/IEC 9899:1990/Amendment 1:1995. */ - #include -#define FILE _IO_FILE -#undef va_list -#define va_list _IO_va_list -#undef BUFSIZ -#define BUFSIZ _IO_BUFSIZ + /* In some cases we need extra space for all the output which is not counted in the width of the string. We assume 32 characters is enough. */ diff --git a/sysdeps/unix/sysv/linux/bits/_G_config.h b/sysdeps/unix/sysv/linux/bits/_G_config.h index 9994869098..338150291f 100644 --- a/sysdeps/unix/sysv/linux/bits/_G_config.h +++ b/sysdeps/unix/sysv/linux/bits/_G_config.h @@ -19,20 +19,16 @@ #include #include +#include +#include + +#define _G_fpos_t __fpos_t +#define _G_fpos64_t __fpos64_t + #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # include #endif -typedef struct -{ - __off_t __pos; - __mbstate_t __state; -} _G_fpos_t; -typedef struct -{ - __off64_t __pos; - __mbstate_t __state; -} _G_fpos64_t; #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # include typedef union