[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
memcmp and cross-compilation (was: Re: memcmp-tests module)
From: |
Simon Josefsson |
Subject: |
memcmp and cross-compilation (was: Re: memcmp-tests module) |
Date: |
Tue, 20 May 2008 09:34:30 +0200 |
User-agent: |
Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux) |
Simon Josefsson <address@hidden> writes:
> Simon Josefsson <address@hidden> writes:
>
>> MinGW apparently needs gnulib's memcmp module
>
> That was rather surprising to me, so I started investigating why that is
> the case.
The reason was that Autoconf's AC_FUNC_MEMCMP uses AC_RUN_IFELSE with a
cross-compile default of no. I prefer to assume memcmp exists on
cross-compile targets since I assume C89 or later in my projects. That
is probably not the right choice for autoconf, but I think it is for
gnulib. Thus it seems gnulib needs to extend autoconf's test somewhat?
I'll suggest something for review.
autoconf lib/autoconf/functions.m4:
# AC_FUNC_MEMCMP
# --------------
AC_DEFUN([AC_FUNC_MEMCMP],
[AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
/* Some versions of memcmp are not 8-bit clean. */
char c0 = '\100', c1 = '\200', c2 = '\201';
if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
return 1;
/* The Next x86 OpenStep bug shows up only when comparing 16 bytes
or more and with at least one buffer not starting on a 4-byte boundary.
William Lewis provided this test program. */
{
char foo[21];
char bar[21];
int i;
for (i = 0; i < 4; i++)
{
char *a = foo + i;
char *b = bar + i;
strcpy (a, "--------01111111");
strcpy (b, "--------10000000");
if (memcmp (a, b, 16) >= 0)
return 1;
}
return 0;
}
]])],
[ac_cv_func_memcmp_working=yes],
[ac_cv_func_memcmp_working=no],
[ac_cv_func_memcmp_working=no])])
test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
])# AC_FUNC_MEMCMP
/Simon
Re: rpl_memcmp on mingw with g++?, Bruno Haible, 2008/05/20