*** empty log message ***
[findutils.git] / m4 / memcmp.m4
blob7fdfe9ad709a909a4a837aec74312c726c40750e
1 #serial 4
3 dnl A replacement for autoconf's AC_FUNC_MEMCMP that detects
4 dnl the losing memcmp on some x86 Next systems.
5 AC_DEFUN(jm_AC_FUNC_MEMCMP,
6 [AC_CACHE_CHECK([for working memcmp], jm_cv_func_memcmp_working,
7 [AC_TRY_RUN(
8 [int
9 main ()
11   /* Some versions of memcmp are not 8-bit clean.  */
12   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
13   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
14     exit (1);
16   /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
17      or more and with at least one buffer not starting on a 4-byte boundary.
18      William Lewis provided this test program.   */
19   {
20     char foo[21];
21     char bar[21];
22     int i;
23     for (i = 0; i < 4; i++)
24       {
25         char *a = foo + i;
26         char *b = bar + i;
27         strcpy (a, "--------01111111");
28         strcpy (b, "--------10000000");
29         if (memcmp (a, b, 16) >= 0)
30           exit (1);
31       }
32     exit (0);
33   }
34 }],
35    jm_cv_func_memcmp_working=yes,
36    jm_cv_func_memcmp_working=no,
37    jm_cv_func_memcmp_working=no)])
38 test $jm_cv_func_memcmp_working = no \
39   && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
40 AC_SUBST(LIBOBJS)dnl
43 AC_DEFUN(jm_FUNC_MEMCMP,
44 [AC_REQUIRE([jm_AC_FUNC_MEMCMP])dnl
45  if test $jm_cv_func_memcmp_working = no; then
46    AC_DEFINE_UNQUOTED(memcmp, rpl_memcmp,
47      [Define to rpl_memcmp if the replacement function should be used.])
48  fi