fix initial values of reallocated fluids
[bpt/guile.git] / m4 / wchar_h.m4
CommitLineData
e65fc94b
LC
1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2
49114fd4 3dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
e65fc94b
LC
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Eric Blake.
9
49114fd4 10# wchar_h.m4 serial 38
e65fc94b
LC
11
12AC_DEFUN([gl_WCHAR_H],
13[
14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
61cd9dc9
LC
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.
61cd9dc9
LC
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])
aa7a939c 27
0f00f2c3
LC
28 AC_REQUIRE([gl_FEATURES_H])
29
aa7a939c
LC
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
61cd9dc9
LC
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([[
49114fd4
LC
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>. */
0f00f2c3 45#if !(defined __GLIBC__ && !defined __UCLIBC__)
61cd9dc9
LC
46# include <stddef.h>
47# include <stdio.h>
48# include <time.h>
49#endif
50#include <wchar.h>
49114fd4
LC
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 ])
61cd9dc9 58])
e65fc94b 59
61cd9dc9
LC
60dnl Check whether <wchar.h> is usable at all.
61AC_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
49114fd4
LC
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>
61cd9dc9
LC
80#include <wchar.h>
81extern int zero (void);
82int main () { return zero(); }
83]])])
84 if AC_TRY_EVAL([ac_compile]); then
85 mv conftest.$ac_objext conftest1.$ac_objext
86 AC_LANG_CONFTEST([
87 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
49114fd4
LC
88/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
89 <wchar.h>.
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
91 included before <wchar.h>. */
92#include <stddef.h>
93#include <stdio.h>
94#include <time.h>
61cd9dc9
LC
95#include <wchar.h>
96int zero (void) { return 0; }
97]])])
98 if AC_TRY_EVAL([ac_compile]); then
99 mv conftest.$ac_objext conftest2.$ac_objext
100 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
101 :
102 else
103 gl_cv_header_wchar_h_correct_inline=no
104 fi
105 fi
106 fi
107 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
108 ])
109 if test $gl_cv_header_wchar_h_correct_inline = no; then
110 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
111This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
112C99 mode. You have four options:
113 - Add the flag -fgnu89-inline to CC and reconfigure, or
114 - Fix your include files, using parts of
115 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
116 - Use a gcc version older than 4.3, or
117 - Don't use the flags -std=c99 or -std=gnu99.
118Configuration aborted.])
e65fc94b 119 fi
e65fc94b
LC
120])
121
aa7a939c
LC
122dnl Unconditionally enables the replacement of <wchar.h>.
123AC_DEFUN([gl_REPLACE_WCHAR_H],
124[
61cd9dc9
LC
125 dnl This is a no-op, because <wchar.h> is always overridden.
126 :
aa7a939c
LC
127])
128
e65fc94b
LC
129AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
130[
131 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
132 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
a927b6c1 133 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
f4c79b3c 134 dnl Define it also as a C macro, for the benefit of the unit tests.
a927b6c1 135 gl_MODULE_INDICATOR_FOR_TESTS([$1])
e65fc94b
LC
136])
137
138AC_DEFUN([gl_WCHAR_H_DEFAULTS],
139[
49114fd4
LC
140 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
141 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
142 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
143 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
144 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
145 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
146 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
147 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
148 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
149 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
150 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
151 GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR])
152 GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP])
153 GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY])
154 GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE])
155 GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET])
156 GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN])
157 GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN])
158 GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY])
159 GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY])
160 GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY])
161 GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY])
162 GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT])
163 GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT])
164 GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP])
165 GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP])
166 GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP])
167 GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
168 GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL])
169 GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM])
170 GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP])
171 GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR])
172 GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR])
173 GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN])
174 GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN])
175 GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK])
176 GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR])
177 GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK])
178 GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH])
e65fc94b 179 dnl Assume proper GNU behavior unless another module says otherwise.
f240aacb
LC
180 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
181 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
182 HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC])
183 HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN])
184 HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
185 HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS])
186 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB])
187 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS])
188 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS])
49114fd4
LC
189 HAVE_WMEMCHR=1; AC_SUBST([HAVE_WMEMCHR])
190 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP])
191 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY])
192 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE])
193 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET])
194 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN])
195 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN])
196 HAVE_WCSCPY=1; AC_SUBST([HAVE_WCSCPY])
197 HAVE_WCPCPY=1; AC_SUBST([HAVE_WCPCPY])
198 HAVE_WCSNCPY=1; AC_SUBST([HAVE_WCSNCPY])
199 HAVE_WCPNCPY=1; AC_SUBST([HAVE_WCPNCPY])
200 HAVE_WCSCAT=1; AC_SUBST([HAVE_WCSCAT])
201 HAVE_WCSNCAT=1; AC_SUBST([HAVE_WCSNCAT])
202 HAVE_WCSCMP=1; AC_SUBST([HAVE_WCSCMP])
203 HAVE_WCSNCMP=1; AC_SUBST([HAVE_WCSNCMP])
204 HAVE_WCSCASECMP=1; AC_SUBST([HAVE_WCSCASECMP])
205 HAVE_WCSNCASECMP=1; AC_SUBST([HAVE_WCSNCASECMP])
206 HAVE_WCSCOLL=1; AC_SUBST([HAVE_WCSCOLL])
207 HAVE_WCSXFRM=1; AC_SUBST([HAVE_WCSXFRM])
208 HAVE_WCSDUP=1; AC_SUBST([HAVE_WCSDUP])
209 HAVE_WCSCHR=1; AC_SUBST([HAVE_WCSCHR])
210 HAVE_WCSRCHR=1; AC_SUBST([HAVE_WCSRCHR])
211 HAVE_WCSCSPN=1; AC_SUBST([HAVE_WCSCSPN])
212 HAVE_WCSSPN=1; AC_SUBST([HAVE_WCSSPN])
213 HAVE_WCSPBRK=1; AC_SUBST([HAVE_WCSPBRK])
214 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR])
215 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK])
216 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH])
f240aacb
LC
217 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
218 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
219 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
220 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
221 REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
222 REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT])
223 REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC])
224 REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN])
225 REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS])
226 REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
227 REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB])
228 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
229 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
230 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
49114fd4 231 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
e65fc94b 232])