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