3 dnl Copyright (C) 2011-2024 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.
8 AC_DEFUN([gl_FUNC_WMEMCMP],
10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 dnl We cannot use AC_CHECK_FUNCS here, because the MSVC 9 header files
13 dnl provide this function as an inline function definition.
14 AC_CACHE_CHECK([for wmemcmp], [gl_cv_func_wmemcmp],
19 [[return ! wmemcmp ((const wchar_t *) 0, (const wchar_t *) 0, 0);]])
21 [gl_cv_func_wmemcmp=yes],
22 [gl_cv_func_wmemcmp=no])
24 if test $gl_cv_func_wmemcmp = no; then
27 AC_CACHE_CHECK([whether wmemcmp works for all wide characters],
28 [gl_cv_func_wmemcmp_works],
34 wchar_t a = (wchar_t) 0x76547654;
35 wchar_t b = (wchar_t) 0x9abc9abc;
36 int cmp = wmemcmp (&a, &b, 1);
44 [gl_cv_func_wmemcmp_works=yes],
45 [gl_cv_func_wmemcmp_works=no],
47 # Guess no on glibc versions < 2.15.
49 AC_EGREP_CPP([Unlucky],
52 #ifdef __GNU_LIBRARY__
53 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 15)
58 [gl_cv_func_wmemcmp_works="guessing no"],
59 [gl_cv_func_wmemcmp_works="guessing yes"])
61 # Guess no on musl systems.
62 *-musl* | midipix*) gl_cv_func_wmemcmp_works="guessing no" ;;
63 # If we don't know, obey --enable-cross-guesses.
64 *) gl_cv_func_wmemcmp_works="$gl_cross_guess_normal" ;;
68 case "$gl_cv_func_wmemcmp_works" in
70 *) REPLACE_WMEMCMP=1 ;;