aboutsummaryrefslogtreecommitdiff
path: root/wcsmbs
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2016-11-20 23:00:02 -0500
committerZack Weinberg <zackw@panix.com>2017-06-08 13:58:17 -0400
commit199fc19d3aaaf57944ef036e15904febe877fc93 (patch)
tree5056d2447de58c0bb197d87740098220f556b242 /wcsmbs
parent4615f5aefeaa45345484a9ce8e3d0ea977c80d80 (diff)
downloadglibc-199fc19d3aaaf57944ef036e15904febe877fc93.tar
glibc-199fc19d3aaaf57944ef036e15904febe877fc93.tar.gz
glibc-199fc19d3aaaf57944ef036e15904febe877fc93.tar.bz2
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')
-rw-r--r--wcsmbs/Makefile3
-rw-r--r--wcsmbs/bits/types/__mbstate_t.h23
-rw-r--r--wcsmbs/bits/types/mbstate_t.h8
-rw-r--r--wcsmbs/bits/types/wint_t.h23
-rw-r--r--wcsmbs/uchar.h9
-rw-r--r--wcsmbs/wchar.h119
6 files changed, 85 insertions, 100 deletions
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index d6b214b2ab..08b1de11a8 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -22,7 +22,8 @@ subdir := wcsmbs
include ../Makeconfig
-headers := wchar.h bits/wchar.h bits/wchar2.h bits/wchar-ldbl.h uchar.h
+headers := wchar.h bits/wchar.h bits/wchar2.h bits/wchar-ldbl.h uchar.h \
+ bits/types/__mbstate_t.h bits/types/mbstate_t.h bits/types/wint_t.h
routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \
diff --git a/wcsmbs/bits/types/__mbstate_t.h b/wcsmbs/bits/types/__mbstate_t.h
new file mode 100644
index 0000000000..1d8a4e28d1
--- /dev/null
+++ b/wcsmbs/bits/types/__mbstate_t.h
@@ -0,0 +1,23 @@
+#ifndef ____mbstate_t_defined
+#define ____mbstate_t_defined 1
+
+/* 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. */
+#ifndef __WINT_TYPE__
+# define __WINT_TYPE__ unsigned int
+#endif
+
+/* Conversion state information. */
+typedef struct
+{
+ int __count;
+ union
+ {
+ __WINT_TYPE__ __wch;
+ char __wchb[4];
+ } __value; /* Value so far. */
+} __mbstate_t;
+
+#endif
diff --git a/wcsmbs/bits/types/mbstate_t.h b/wcsmbs/bits/types/mbstate_t.h
new file mode 100644
index 0000000000..8d1baa5c3b
--- /dev/null
+++ b/wcsmbs/bits/types/mbstate_t.h
@@ -0,0 +1,8 @@
+#ifndef __mbstate_t_defined
+#define __mbstate_t_defined 1
+
+#include <bits/types/__mbstate_t.h>
+
+typedef __mbstate_t mbstate_t;
+
+#endif
diff --git a/wcsmbs/bits/types/wint_t.h b/wcsmbs/bits/types/wint_t.h
new file mode 100644
index 0000000000..fbd63dbc84
--- /dev/null
+++ b/wcsmbs/bits/types/wint_t.h
@@ -0,0 +1,23 @@
+#ifndef __wint_t_defined
+#define __wint_t_defined 1
+
+/* Some versions of stddef.h provide wint_t, even though neither the
+ C nor C++ standards, nor POSIX, specifies this. We assume that
+ stddef.h will define the macro _WINT_T if and only if it provides
+ wint_t, and conversely, that it will avoid providing wint_t if
+ _WINT_T is already defined. */
+#ifndef _WINT_T
+#define _WINT_T 1
+
+/* 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. */
+#ifndef __WINT_TYPE__
+# define __WINT_TYPE__ unsigned int
+#endif
+
+typedef __WINT_TYPE__ wint_t;
+
+#endif /* _WINT_T */
+#endif /* bits/types/wint_t.h */
diff --git a/wcsmbs/uchar.h b/wcsmbs/uchar.h
index a6569825fd..f937519cf4 100644
--- a/wcsmbs/uchar.h
+++ b/wcsmbs/uchar.h
@@ -27,15 +27,8 @@
#define __need_size_t
#include <stddef.h>
-#define __need_mbstate_t
-#include <wchar.h>
-
-#ifndef __mbstate_t_defined
-/* Public type. */
-typedef __mbstate_t mbstate_t;
-# define __mbstate_t_defined 1
-#endif
+#include <bits/types/mbstate_t.h>
#if defined __GNUC__ && !defined __USE_ISOCXX11
/* Define the 16-bit and 32-bit character types. Use the information
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