strtoumax: fix typo in previous commit.
[gnulib.git] / m4 / memcmp.m4
1 # memcmp.m4 serial 16
2 dnl Copyright (C) 2002-2004, 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
7 AC_DEFUN([gl_FUNC_MEMCMP],
8 [
9   dnl We don't use AC_FUNC_MEMCMP any more, because it is no longer maintained
10   dnl in Autoconf and because it invokes AC_LIBOBJ.
11   AC_CACHE_CHECK([for working memcmp], [gl_cv_func_memcmp_working],
12     [AC_RUN_IFELSE(
13        [AC_LANG_PROGRAM(
14           [AC_INCLUDES_DEFAULT],
15           [[/* Some versions of memcmp are not 8-bit clean.  */
16             char c0 = '\100', c1 = '\200', c2 = '\201';
17             if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
18               return 1;
19             /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
20                or more and with at least one buffer not starting on a 4-byte
21                boundary.  William Lewis provided this test program.   */
22             {
23               char foo[21];
24               char bar[21];
25               int i;
26               for (i = 0; i < 4; i++)
27                 {
28                   char *a = foo + i;
29                   char *b = bar + i;
30                   strcpy (a, "--------01111111");
31                   strcpy (b, "--------10000000");
32                   if (memcmp (a, b, 16) >= 0)
33                     return 1;
34                 }
35               return 0;
36             }
37           ]])],
38        [gl_cv_func_memcmp_working=yes],
39        [gl_cv_func_memcmp_working=no],
40        [dnl When cross-compiling, guess memcmp works when it exists.
41         dnl This is useful for mingw.
42         AC_LINK_IFELSE(
43           [AC_LANG_PROGRAM(
44              [[#include <string.h>]],
45              [[int ret = memcmp ("foo", "bar", 0);]])],
46           [gl_cv_func_memcmp_working="guessing yes"],
47           [gl_cv_func_memcmp_working="guessing no"])
48        ])
49     ])
50   case "$gl_cv_func_memcmp_working" in
51     *yes) gl_func_memcmp=yes ;;
52     *)    gl_func_memcmp=no ;;
53   esac
54   if test $gl_func_memcmp = no; then
55     AC_DEFINE([memcmp], [rpl_memcmp],
56       [Define to rpl_memcmp if the replacement function should be used.])
57   fi
58 ])
59
60 # Prerequisites of lib/memcmp.c.
61 AC_DEFUN([gl_PREREQ_MEMCMP], [:])