From: Kurt Zeilenga Date: Tue, 17 Nov 1998 22:49:15 +0000 (+0000) Subject: Add sizeof checks to configure.in. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~1102 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=05e597d8693d40b3f4333e9abb884be8dc92b709;p=openldap Add sizeof checks to configure.in. Add ac/bytes.h to provided sized types. Use new sized type in md5/sha1 header through simple typedef. Should substitute old type for new everywhere. --- diff --git a/acconfig.h b/acconfig.h index c73e7cebbf..2df045b279 100644 --- a/acconfig.h +++ b/acconfig.h @@ -15,6 +15,9 @@ /* define this if needed to get threadsafe functions */ #undef _THREADSAFE +/* define this if cross compiling */ +#undef CROSS_COMPILING + /* define this if toupper() requires tolower() check */ #undef C_UPPER_LOWER diff --git a/configure b/configure index 38d7af2798..0464c0fba3 100755 --- a/configure +++ b/configure @@ -1658,7 +1658,7 @@ fi if test $cross_compiling = yes -a $ol_enable_x_compile = yes; then - echo "configure: warning: cross compiling.... go for it" 1>&2 + echo "configure: warning: cross compiling.... some functionality will be removed." 1>&2 elif test $cross_compiling = no -a $ol_enable_x_compile = yes; then echo "configure: warning: programs compiled here do run here..." 1>&2 @@ -6386,17 +6386,20 @@ fi if test $cross_compiling = yes ; then - echo "configure: warning: Assuming BYTE_ORDER is defined" 1>&2 + cat >> confdefs.h <<\EOF +#define CROSS_COMPILING 1 +EOF + else echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:6393: checking whether byte ordering is bigendian" >&5 +echo "configure:6396: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -6407,11 +6410,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:6411: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6414: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -6422,7 +6425,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:6426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6429: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -6442,7 +6445,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -6476,13 +6479,129 @@ if test $ac_cv_c_bigendian = yes; then #define WORDS_BIGENDIAN 1 EOF +fi + + echo $ac_n "checking size of short""... $ac_c" 1>&6 +echo "configure:6486: checking size of short" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(short)); + exit(0); +} +EOF +if { (eval echo configure:6505: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_short=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_short=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_short" 1>&6 +cat >> confdefs.h <&6 +echo "configure:6525: checking size of int" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(int)); + exit(0); +} +EOF +if { (eval echo configure:6544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_int=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_int=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_int" 1>&6 +cat >> confdefs.h <&6 +echo "configure:6564: checking size of long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long)); + exit(0); +} +EOF +if { (eval echo configure:6583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long=0 +fi +rm -fr conftest* fi fi +echo "$ac_t""$ac_cv_sizeof_long" 1>&6 +cat >> confdefs.h <&6 -echo "configure:6486: checking for 8-bit clean memcmp" >&5 +echo "configure:6605: checking for 8-bit clean memcmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6490,7 +6609,7 @@ else ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -6518,12 +6637,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o" echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:6522: checking for strftime" >&5 +echo "configure:6641: checking for strftime" >&5 if eval "test \"`echo '$''{'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; then +if { (eval echo configure:6669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -6568,7 +6687,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:6572: checking for strftime in -lintl" >&5 +echo "configure:6691: checking for strftime in -lintl" >&5 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6576,7 +6695,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6710: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6614,12 +6733,12 @@ fi fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:6618: checking for vprintf" >&5 +echo "configure:6737: checking for vprintf" >&5 if eval "test \"`echo '$''{'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; then +if { (eval echo configure:6765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -6666,12 +6785,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:6670: checking for _doprnt" >&5 +echo "configure:6789: checking for _doprnt" >&5 if eval "test \"`echo '$''{'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; then +if { (eval echo configure:6817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -6723,12 +6842,12 @@ if test $ac_cv_func_vprintf = yes ; then for ac_func in vsnprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6727: checking for $ac_func" >&5 +echo "configure:6846: checking for $ac_func" >&5 if eval "test \"`echo '$''{'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; then +if { (eval echo configure:6874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6778,7 +6897,7 @@ done fi echo $ac_n "checking for wait3 that fills in rusage""... $ac_c" 1>&6 -echo "configure:6782: checking for wait3 that fills in rusage" >&5 +echo "configure:6901: checking for wait3 that fills in rusage" >&5 if eval "test \"`echo '$''{'ac_cv_func_wait3_rusage'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6786,7 +6905,7 @@ else ac_cv_func_wait3_rusage=no else cat > conftest.$ac_ext < #include @@ -6817,7 +6936,7 @@ main() { } } EOF -if { (eval echo configure:6821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_func_wait3_rusage=yes else @@ -6874,12 +6993,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6878: checking for $ac_func" >&5 +echo "configure:6997: checking for $ac_func" >&5 if eval "test \"`echo '$''{'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; then +if { (eval echo configure:7025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6930,12 +7049,12 @@ done for ac_func in getopt strdup tempnam do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6934: checking for $ac_func" >&5 +echo "configure:7053: checking for $ac_func" >&5 if eval "test \"`echo '$''{'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; then +if { (eval echo configure:7081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6988,13 +7107,13 @@ done # Check Configuration echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:6992: checking declaration of sys_errlist" >&5 +echo "configure:7111: checking declaration of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -7004,7 +7123,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:7008: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7127: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_sys_errlist=yes else @@ -7025,20 +7144,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then EOF echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6 -echo "configure:7029: checking existence of sys_errlist" >&5 +echo "configure:7148: checking existence of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:7042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:7161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ol_cv_have_sys_errlist=yes else diff --git a/configure.in b/configure.in index e201016c39..15a8067f37 100644 --- a/configure.in +++ b/configure.in @@ -213,7 +213,7 @@ dnl Checks the compiler and UNIX Variants AC_PROG_CC if test $cross_compiling = yes -a $ol_enable_x_compile = yes; then - AC_WARN([cross compiling.... go for it]) + AC_WARN([cross compiling.... some functionality will be removed.]) elif test $cross_compiling = no -a $ol_enable_x_compile = yes; then AC_WARN([programs compiled here do run here...]) @@ -949,15 +949,14 @@ OL_C_UPPER_LOWER AC_C_CONST if test $cross_compiling = yes ; then - AC_MSG_WARN([Assuming BYTE_ORDER is defined]) + AC_DEFINE(CROSS_COMPILING, 1) else AC_C_BIGENDIAN + AC_CHECK_SIZEOF(short) + AC_CHECK_SIZEOF(int) + AC_CHECK_SIZEOF(long) fi -dnl AC_CHECK_SIZEOF(short) -dnl AC_CHECK_SIZEOF(int) -dnl AC_CHECK_SIZEOF(long) - dnl ---------------------------------------------------------------- dnl Checks for library functions. AC_FUNC_MEMCMP diff --git a/include/ac/bytes.h b/include/ac/bytes.h new file mode 100644 index 0000000000..5d479442c5 --- /dev/null +++ b/include/ac/bytes.h @@ -0,0 +1,61 @@ +/* Generic bytes.h */ + +#ifndef _AC_BYTES_H +#define _AC_BYTES_H + +#if defined( LDAP_INT4_TYPE ) && defined( LDAP_INT2_TYPE ) + /* cross compilers should define LDAP_INT{2,4}_TYPE in CPPFLAS */ + typedef LDAP_INT4_TYPE LDAP_INT4; + typedef signed LDAP_INT4_TYPE LDAP_SINT4; + typedef unsigned LDAP_INT4_TYPE LDAP_UINT4; + + typedef LDAP_INT2_TYPE LDAP_INT2; + typedef signed LDAP_INT2_TYPE LDAP_SINT2; + typedef unsigned LDAP_INT2_TYPE LDAP_UINT2; + +#else + /* use autoconf defines to provide sized typedefs */ +# if SIZEOF_LONG == 4 + typedef long LDAP_INT4; + typedef signed long LDAP_SINT4; + typedef unsigned long LDAP_UINT4; +# elif SIZEOF_INT == 4 + typedef int LDAP_INT4; + typedef signed int LDAP_SINT4; + typedef unsigned int LDAP_UINT4; + +# endif + +# if SIZEOF_SHORT == 2 + typedef short LDAP_INT2; + typedef signed short LDAP_SINT2; + typedef unsigned short LDAP_UINT2; +# elif SIZEOF_INT == 2 + typedef int LDAP_INT2; + typedef signed int LDAP_SINT2; + typedef unsigned int LDAP_UINT2; +# endif +#endif + +#ifndef BYTE_ORDER +/* cross compilers should define BYTE_ORDER in CPPFLAGS */ + +/* + * Definitions for byte order, according to byte significance from low + * address to high. + */ +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ + +/* assume autoconf's AC_C_BIGENDIAN has been ran */ +/* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */ +# ifdef WORDS_BIGENDIAN +# define BYTE_ORDER BIG_ENDIAN +# else +# define BYTE_ORDER LITTLE_ENDIAN +# endif + +#endif /* BYTE_ORDER */ + +#endif /* _AC_BYTES_H */ diff --git a/include/lutil_md5.h b/include/lutil_md5.h index e7d8b0682f..e3fa617089 100644 --- a/include/lutil_md5.h +++ b/include/lutil_md5.h @@ -4,6 +4,7 @@ #define _LDAP_MD5_H_ #include +#include LDAP_BEGIN_DECL @@ -13,10 +14,7 @@ LDAP_BEGIN_DECL important. ANSI guarantees that "unsigned long" will be big enough, and always using it seems to have few disadvantages. */ -#ifndef LDAP_UINT32 -#define LDAP_UINT32 -typedef unsigned long uint32; -#endif +typedef LDAP_UINT4 uint32; struct ldap_MD5Context { uint32 buf[4]; diff --git a/include/lutil_sha1.h b/include/lutil_sha1.h index b20d490305..963545f5d6 100644 --- a/include/lutil_sha1.h +++ b/include/lutil_sha1.h @@ -5,6 +5,7 @@ #define _LDAP_SHA1_H_ #include +#include LDAP_BEGIN_DECL @@ -14,11 +15,7 @@ LDAP_BEGIN_DECL * 100% Public Domain */ -/* XXX I wonder if this will work on 64bit architectures... */ -#ifndef LDAP_UINT32 -#define LDAP_UINT32 -typedef unsigned long uint32; -#endif +typedef LDAP_UINT4 uint32; typedef struct { uint32 state[5]; diff --git a/include/portable.h.in b/include/portable.h.in index 8fe0bce187..ad52db8d65 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -119,6 +119,9 @@ is provided ``as is'' without express or implied warranty. /* define this if needed to get threadsafe functions */ #undef _THREADSAFE +/* define this if cross compiling */ +#undef CROSS_COMPILING + /* define this if toupper() requires tolower() check */ #undef C_UPPER_LOWER @@ -260,6 +263,15 @@ is provided ``as is'' without express or implied warranty. LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ +/* The number of bytes in a int. */ +#undef SIZEOF_INT + +/* The number of bytes in a long. */ +#undef SIZEOF_LONG + +/* The number of bytes in a short. */ +#undef SIZEOF_SHORT + /* Define if you have the bcopy function. */ #undef HAVE_BCOPY