wchar_h.m4 9.2 KB

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