diff options
author | Zack Weinberg <zackw@panix.com> | 2016-11-20 23:00:02 -0500 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-06-08 13:58:17 -0400 |
commit | 199fc19d3aaaf57944ef036e15904febe877fc93 (patch) | |
tree | 5056d2447de58c0bb197d87740098220f556b242 /wcsmbs/wchar.h | |
parent | 4615f5aefeaa45345484a9ce8e3d0ea977c80d80 (diff) | |
download | glibc-199fc19d3aaaf57944ef036e15904febe877fc93.tar.gz glibc-199fc19d3aaaf57944ef036e15904febe877fc93.tar.xz glibc-199fc19d3aaaf57944ef036e15904febe877fc93.zip |
Remove __need macros from stdio.h and wchar.h.
wint_t is a little finicky because it might be defined by stddef.h, which belongs to the compiler. In addition to the _types_, a bunch of other declarations shared between wctype.h and wchar.h are factored out to their own header. * libio/bits/types/FILE.h, libio/bits/types/__FILE.h * wcsmbs/bits/types/mbstate_t.h, wcsmbs/bits/types/__mbstate_t.h * wcsmbs/bits/types/wint_t.h: New single-type definition files. * wctype/bits/wctype-wchar.h: New file holding declarations shared between wctype.h and wchar.h. * libio/Makefile, wcsmbs/Makefile, wctype/Makefile: Install them. * include/bits/types/FILE.h, include/bits/types/__FILE.h * include/bits/types/mbstate_t.h, include/bits/types/__mbstate_t.h * include/bits/types/wint_t.h, include/bits/wcsmbs-wchar.h: New wrappers. * include/stdio.h, include/wchar.h, include/wctype.h: No need to handle __need macros. * grp/grp.h, gshadow/gshadow.h, hurd/hurd.h, iconv/gconv.h * libio/stdio.h, mach/mach.h, misc/mntent.h, pwd/pwd.h * shadow/shadow.h, stdio-common/printf.h, wcsmbs/uchar.h * wcsmbs/wchar.h, wctype/wctype.h * sysdeps/generic/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h Use the new files instead of __need macros.
Diffstat (limited to 'wcsmbs/wchar.h')
-rw-r--r-- | wcsmbs/wchar.h | 119 |
1 files changed, 28 insertions, 91 deletions
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index 79be9fc41d..d389428daa 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -21,82 +21,32 @@ */ #ifndef _WCHAR_H +#define _WCHAR_H 1 -#if !defined __need_mbstate_t && !defined __need_wint_t -# define _WCHAR_H 1 -# define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION -# include <bits/libc-header-start.h> -#endif +#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION +#include <bits/libc-header-start.h> -#ifdef _WCHAR_H -/* Get FILE definition. */ -# define __need___FILE -# if defined __USE_UNIX98 || defined __USE_XOPEN2K -# define __need_FILE -# endif -# include <stdio.h> -/* Get va_list definition. */ -# define __need___va_list -# include <stdarg.h> +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#include <stddef.h> -# include <bits/wchar.h> +#define __need___va_list +#include <stdarg.h> -/* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */ -# define __need_size_t -# define __need_wchar_t -# define __need_NULL -#endif -#if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__ -# undef __need_wint_t -# define __need_wint_t -# include <stddef.h> - -/* We try to get wint_t from <stddef.h>, but not all GCC versions define it - there. So define it ourselves if it remains undefined. */ -# ifndef _WINT_T -/* Integral type unchanged by default argument promotions that can - hold any value corresponding to members of the extended character - set, as well as at least one value that does not correspond to any - member of the extended character set. */ -# define _WINT_T -typedef unsigned int wint_t; -# endif +#include <bits/wchar.h> +#include <bits/types/wint_t.h> +#include <bits/types/mbstate_t.h> +#include <bits/types/__FILE.h> -/* Tell the caller that we provide correct C++ prototypes. */ -# if defined __cplusplus && __GNUC_PREREQ (4, 4) -# define __CORRECT_ISO_CPP_WCHAR_H_PROTO -# endif +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +# include <bits/types/FILE.h> #endif -#if (defined _WCHAR_H || defined __need_mbstate_t) && !defined ____mbstate_t_defined -# define ____mbstate_t_defined 1 -/* Conversion state information. */ -typedef struct -{ - int __count; - union - { -# ifdef __WINT_TYPE__ - __WINT_TYPE__ __wch; -# else - wint_t __wch; -# endif - char __wchb[4]; - } __value; /* Value so far. */ -} __mbstate_t; +/* Tell the caller that we provide correct C++ prototypes. */ +#if defined __cplusplus && __GNUC_PREREQ (4, 4) +# define __CORRECT_ISO_CPP_WCHAR_H_PROTO #endif -#undef __need_mbstate_t - - -/* The rest of the file is only used if used if __need_mbstate_t is not - defined. */ -#ifdef _WCHAR_H - -# ifndef __mbstate_t_defined -/* Public type. */ -typedef __mbstate_t mbstate_t; -# define __mbstate_t_defined 1 -# endif #ifndef WCHAR_MIN /* These constants might also be defined in <inttypes.h>. */ @@ -108,13 +58,18 @@ typedef __mbstate_t mbstate_t; # define WEOF (0xffffffffu) #endif -/* For XPG4 compliance we have to define the stuff from <wctype.h> here - as well. */ -#if defined __USE_XOPEN && !defined __USE_UNIX98 -# include <wctype.h> +/* All versions of XPG prior to the publication of ISO C99 required + the bulk of <wctype.h>'s declarations to appear in this header + (because <wctype.h> did not exist prior to C99). In POSIX.1-2001 + those declarations were marked as XSI extensions; in -2008 they + were additionally marked as obsolescent. _GNU_SOURCE mode + anticipates the removal of these declarations in the next revision + of POSIX. */ +#if (defined __USE_XOPEN && !defined __USE_GNU \ + && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI)) +# include <bits/wctype-wchar.h> #endif - __BEGIN_DECLS /* This incomplete type is defined in <time.h> but needed here because @@ -823,17 +778,6 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, __locale_t __loc) __THROW; # endif -/* The X/Open standard demands that most of the functions defined in - the <wctype.h> header must also appear here. This is probably - because some X/Open members wrote their implementation before the - ISO C standard was published and introduced the better solution. - We have to provide these definitions for compliance reasons but we - do this nonsense only if really necessary. */ -#if defined __USE_UNIX98 && !defined __USE_GNU -# define __need_iswxxx -# include <wctype.h> -#endif - /* Define some macros helping to catch buffer overflows. */ #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include <bits/wchar2.h> @@ -845,11 +789,4 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, __END_DECLS -#endif /* _WCHAR_H defined */ - #endif /* wchar.h */ - -/* Undefine all __need_* constants in case we are included to get those - constants but the whole file was already read. */ -#undef __need_mbstate_t -#undef __need_wint_t |