16017a59fbbaf029b3761c4d45f7bc20310085b3
[deliverable/binutils-gdb.git] / gnulib / import / m4 / wchar_h.m4
1 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2
3 dnl Copyright (C) 2007-2016 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl Written by Eric Blake.
9
10 # wchar_h.m4 serial 40
11
12 AC_DEFUN([gl_WCHAR_H],
13 [
14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
16 dnl Prepare for creating substitute <wchar.h>.
17 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
18 dnl character support).
19 dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
20 gl_CHECK_NEXT_HEADERS([wchar.h])
21 if test $ac_cv_header_wchar_h = yes; then
22 HAVE_WCHAR_H=1
23 else
24 HAVE_WCHAR_H=0
25 fi
26 AC_SUBST([HAVE_WCHAR_H])
27
28 AC_REQUIRE([gl_FEATURES_H])
29
30 AC_REQUIRE([gt_TYPE_WINT_T])
31 if test $gt_cv_c_wint_t = yes; then
32 HAVE_WINT_T=1
33 else
34 HAVE_WINT_T=0
35 fi
36 AC_SUBST([HAVE_WINT_T])
37
38 dnl Check for declarations of anything we want to poison if the
39 dnl corresponding gnulib module is not in use.
40 gl_WARN_ON_USE_PREPARE([[
41 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
42 <wchar.h>.
43 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
44 included before <wchar.h>. */
45 #if !(defined __GLIBC__ && !defined __UCLIBC__)
46 # include <stddef.h>
47 # include <stdio.h>
48 # include <time.h>
49 #endif
50 #include <wchar.h>
51 ]],
52 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
53 wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset
54 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
55 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
56 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth
57 ])
58 ])
59
60 dnl Check whether <wchar.h> is usable at all.
61 AC_DEFUN([gl_WCHAR_H_INLINE_OK],
62 [
63 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
64 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
65 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
66 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
67 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
68 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
69 [gl_cv_header_wchar_h_correct_inline],
70 [gl_cv_header_wchar_h_correct_inline=yes
71 AC_LANG_CONFTEST([
72 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
73 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
74 <wchar.h>.
75 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
76 included before <wchar.h>. */
77 #include <stddef.h>
78 #include <stdio.h>
79 #include <time.h>
80 #include <wchar.h>
81 extern int zero (void);
82 int main () { return zero(); }
83 ]])])
84 dnl Do not rename the object file from conftest.$ac_objext to
85 dnl conftest1.$ac_objext, as this will cause the link to fail on
86 dnl z/OS when using the XPLINK object format (due to duplicate
87 dnl CSECT names). Instead, temporarily redefine $ac_compile so
88 dnl that the object file has the latter name from the start.
89 save_ac_compile="$ac_compile"
90 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/`
91 if AC_TRY_EVAL([ac_compile]); then
92 AC_LANG_CONFTEST([
93 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
94 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
95 <wchar.h>.
96 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
97 included before <wchar.h>. */
98 #include <stddef.h>
99 #include <stdio.h>
100 #include <time.h>
101 #include <wchar.h>
102 int zero (void) { return 0; }
103 ]])])
104 dnl See note above about renaming object files.
105 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/`
106 if AC_TRY_EVAL([ac_compile]); then
107 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
108 :
109 else
110 gl_cv_header_wchar_h_correct_inline=no
111 fi
112 fi
113 fi
114 ac_compile="$save_ac_compile"
115 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
116 ])
117 if test $gl_cv_header_wchar_h_correct_inline = no; then
118 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
119 This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
120 C99 mode. You have four options:
121 - Add the flag -fgnu89-inline to CC and reconfigure, or
122 - Fix your include files, using parts of
123 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
124 - Use a gcc version older than 4.3, or
125 - Don't use the flags -std=c99 or -std=gnu99.
126 Configuration aborted.])
127 fi
128 ])
129
130 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
131 [
132 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
133 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
134 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
135 dnl Define it also as a C macro, for the benefit of the unit tests.
136 gl_MODULE_INDICATOR_FOR_TESTS([$1])
137 ])
138
139 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
140 [
141 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
142 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
143 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
144 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
145 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
146 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
147 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
148 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
149 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
150 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
151 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
152 GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR])
153 GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP])
154 GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY])
155 GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE])
156 GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET])
157 GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN])
158 GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN])
159 GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY])
160 GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY])
161 GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY])
162 GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY])
163 GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT])
164 GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT])
165 GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP])
166 GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP])
167 GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP])
168 GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
169 GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL])
170 GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM])
171 GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP])
172 GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR])
173 GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR])
174 GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN])
175 GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN])
176 GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK])
177 GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR])
178 GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK])
179 GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH])
180 dnl Assume proper GNU behavior unless another module says otherwise.
181 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
182 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
183 HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC])
184 HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN])
185 HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
186 HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS])
187 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB])
188 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS])
189 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS])
190 HAVE_WMEMCHR=1; AC_SUBST([HAVE_WMEMCHR])
191 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP])
192 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY])
193 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE])
194 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET])
195 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN])
196 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN])
197 HAVE_WCSCPY=1; AC_SUBST([HAVE_WCSCPY])
198 HAVE_WCPCPY=1; AC_SUBST([HAVE_WCPCPY])
199 HAVE_WCSNCPY=1; AC_SUBST([HAVE_WCSNCPY])
200 HAVE_WCPNCPY=1; AC_SUBST([HAVE_WCPNCPY])
201 HAVE_WCSCAT=1; AC_SUBST([HAVE_WCSCAT])
202 HAVE_WCSNCAT=1; AC_SUBST([HAVE_WCSNCAT])
203 HAVE_WCSCMP=1; AC_SUBST([HAVE_WCSCMP])
204 HAVE_WCSNCMP=1; AC_SUBST([HAVE_WCSNCMP])
205 HAVE_WCSCASECMP=1; AC_SUBST([HAVE_WCSCASECMP])
206 HAVE_WCSNCASECMP=1; AC_SUBST([HAVE_WCSNCASECMP])
207 HAVE_WCSCOLL=1; AC_SUBST([HAVE_WCSCOLL])
208 HAVE_WCSXFRM=1; AC_SUBST([HAVE_WCSXFRM])
209 HAVE_WCSDUP=1; AC_SUBST([HAVE_WCSDUP])
210 HAVE_WCSCHR=1; AC_SUBST([HAVE_WCSCHR])
211 HAVE_WCSRCHR=1; AC_SUBST([HAVE_WCSRCHR])
212 HAVE_WCSCSPN=1; AC_SUBST([HAVE_WCSCSPN])
213 HAVE_WCSSPN=1; AC_SUBST([HAVE_WCSSPN])
214 HAVE_WCSPBRK=1; AC_SUBST([HAVE_WCSPBRK])
215 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR])
216 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK])
217 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH])
218 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
219 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
220 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
221 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
222 REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
223 REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT])
224 REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC])
225 REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN])
226 REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS])
227 REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
228 REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB])
229 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
230 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
231 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
232 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
233 ])
This page took 0.034711 seconds and 3 git commands to generate.