From d3ec485651d2121103806a1d6521edc94b3770f8 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 5 Mar 2005 01:23:29 +0000 Subject: [PATCH] ITS#3583: memcmp replacement compilation error fix --- configure | 92 ++++++++++++++++++++----------------- configure.in | 6 +++ include/ac/string.h | 5 ++ include/portable.h.in | 3 ++ libraries/liblutil/memcmp.c | 7 ++- 5 files changed, 67 insertions(+), 46 deletions(-) diff --git a/configure b/configure index d96b94dee0..423fc28749 100755 --- a/configure +++ b/configure @@ -24015,13 +24015,21 @@ fi echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" + +if test $ac_cv_func_memcmp_clean = no ; then + cat >> confdefs.h <<\EOF +#define NEED_MEMCMP_REPLACEMENT 1 +EOF + +fi + echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:24020: checking for strftime" >&5 +echo "configure:24028: checking for strftime" >&5 if eval "test \"\${ac_cv_func_strftime+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -24067,7 +24075,7 @@ else echo "$ac_t""no" 1>&6 # strftime is in -lintl on SCO UNIX. echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6 -echo "configure:24071: checking for strftime in -lintl" >&5 +echo "configure:24079: checking for strftime in -lintl" >&5 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -24075,7 +24083,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -24114,12 +24122,12 @@ fi echo $ac_n "checking for inet_aton()""... $ac_c" 1>&6 -echo "configure:24118: checking for inet_aton()" >&5 +echo "configure:24126: checking for inet_aton()" >&5 if eval "test \"\${ol_cv_func_inet_aton+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_func_inet_aton=yes else @@ -24163,12 +24171,12 @@ EOF echo $ac_n "checking for _spawnlp""... $ac_c" 1>&6 -echo "configure:24167: checking for _spawnlp" >&5 +echo "configure:24175: checking for _spawnlp" >&5 if eval "test \"\${ac_cv_func__spawnlp+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__spawnlp=yes" else @@ -24216,12 +24224,12 @@ fi echo $ac_n "checking for _snprintf""... $ac_c" 1>&6 -echo "configure:24220: checking for _snprintf" >&5 +echo "configure:24228: checking for _snprintf" >&5 if eval "test \"\${ac_cv_func__snprintf+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__snprintf=yes" else @@ -24271,12 +24279,12 @@ fi echo $ac_n "checking for _vsnprintf""... $ac_c" 1>&6 -echo "configure:24275: checking for _vsnprintf" >&5 +echo "configure:24283: checking for _vsnprintf" >&5 if eval "test \"\${ac_cv_func__vsnprintf+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__vsnprintf=yes" else @@ -24326,12 +24334,12 @@ fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:24330: checking for vprintf" >&5 +echo "configure:24338: checking for vprintf" >&5 if eval "test \"\${ac_cv_func_vprintf+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24367: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -24379,12 +24387,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:24383: checking for _doprnt" >&5 +echo "configure:24391: checking for _doprnt" >&5 if eval "test \"\${ac_cv_func__doprnt+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -24437,12 +24445,12 @@ if test $ac_cv_func_vprintf = yes ; then for ac_func in snprintf vsnprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:24441: checking for $ac_func" >&5 +echo "configure:24449: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -24549,12 +24557,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:24553: checking for $ac_func" >&5 +echo "configure:24561: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -24606,12 +24614,12 @@ done for ac_func in getopt getpeereid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:24610: checking for $ac_func" >&5 +echo "configure:24618: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -24667,19 +24675,19 @@ if test "$ac_cv_func_getopt" != yes; then fi if test "$ac_cv_func_getpeereid" != yes; then echo $ac_n "checking for msg_accrights in msghdr""... $ac_c" 1>&6 -echo "configure:24671: checking for msg_accrights in msghdr" >&5 +echo "configure:24679: checking for msg_accrights in msghdr" >&5 if eval "test \"\${ol_cv_msghdr_msg_accrights+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { struct msghdr m; m.msg_accrightslen=0 ; return 0; } EOF -if { (eval echo configure:24683: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:24691: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_msghdr_msg_accrights=yes else @@ -24723,17 +24731,17 @@ if test "$ol_enable_slapi" != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:24727: checking for $ac_hdr" >&5 +echo "configure:24735: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:24737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:24745: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -24764,7 +24772,7 @@ done { echo "configure: error: could not locate " 1>&2; exit 1; } fi echo $ac_n "checking for lt_dlinit in -lltdl""... $ac_c" 1>&6 -echo "configure:24768: checking for lt_dlinit in -lltdl" >&5 +echo "configure:24776: checking for lt_dlinit in -lltdl" >&5 ac_lib_var=`echo ltdl'_'lt_dlinit | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -24772,7 +24780,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lltdl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else diff --git a/configure.in b/configure.in index 247e0a0747..11d9ab9cc0 100644 --- a/configure.in +++ b/configure.in @@ -2422,6 +2422,12 @@ AC_DEFINE(LBER_TAG_T,long) dnl ---------------------------------------------------------------- dnl Checks for library functions. AC_FUNC_MEMCMP + +if test $ac_cv_func_memcmp_clean = no ; then + AC_DEFINE(NEED_MEMCMP_REPLACEMENT,1, + [define if memcmp is not 8-bit clean or is otherwise broken]) +fi + dnl AM_FUNC_MKTIME dnl checks for sys/time.h and unistd.h AC_FUNC_STRFTIME dnl AM_FUNC_STRTOD diff --git a/include/ac/string.h b/include/ac/string.h index 11ddb19489..c35605ae08 100644 --- a/include/ac/string.h +++ b/include/ac/string.h @@ -89,6 +89,11 @@ int (strncasecmp)(); else AC_MEMCPY( (d), (s), (n) ); \ } while(0) +#ifdef NEED_MEMCMP_REPLACEMENT + int (lutil_memcmp)(const void *b1, const void *b2, size_t len); +#define memcmp lutil_memcmp +#endif + #define STRLENOF(s) (sizeof(s)-1) #if defined( HAVE_NONPOSIX_STRERROR_R ) diff --git a/include/portable.h.in b/include/portable.h.in index 4d510aab82..cd9d6dbf83 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -926,6 +926,9 @@ /* The number of bytes in type wchar_t */ #undef SIZEOF_WCHAR_T +/* define if memcmp is not 8-bit clean or is otherwise broken */ +#undef NEED_MEMCMP_REPLACEMENT + /* define to you inet_aton(3) is available */ #undef HAVE_INET_ATON diff --git a/libraries/liblutil/memcmp.c b/libraries/liblutil/memcmp.c index 2dcd8c1b03..c4d2537ef8 100644 --- a/libraries/liblutil/memcmp.c +++ b/libraries/liblutil/memcmp.c @@ -21,14 +21,13 @@ * Memory Compare */ int -(memcmp)(const void *v1, const void *v2, int n) +(lutil_memcmp)(const void *v1, const void *v2, size_t n) { if (n != 0) { const unsigned char *s1=v1, *s2=v2; do { - if (*s1++ != *s2++) - return (*--s1 - *--s2); + if (*s1++ != *s2++) return *--s1 - *--s2; } while (--n != 0); } - return (0); + return 0; } -- 2.39.5