This makes it much more probable to cross-compile without integer-size issues.
Only uint32_t since for some reason cross-compiling from 64bit to 32bit causes problems when using uint64_t. --- configure | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 6 ++++ engine/hash.h | 22 +++++++++++++- 3 files changed, 111 insertions(+), 2 deletions(-) Note: this is only a PoC patch, which allows to get rid of "integer constant is too large for 'long' type" warning compiling fuseki*.c. The fact it does not work with uint64_t is suspect. I'm waiting for the regression tests to complete without this patch before testing that one - but even if it improves the mark, that would not say the patch is 100% correct. diff --git a/configure b/configure index 015369e..145db1f 100755 --- a/configure +++ b/configure @@ -1947,6 +1947,59 @@ rm -f conftest.val } # ac_fn_c_compute_int +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_find_uintX_t + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -4864,6 +4917,38 @@ _ACEOF +# crude: assumes that build machine has uint64_t it host machine has it +ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" +case $ac_cv_c_uint64_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT64_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint64_t $ac_cv_c_uint64_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + +#if test $ac_cv_c_uint64_t = no; then +#fi + for ac_func in vsnprintf gettimeofday usleep times do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/configure.in b/configure.in index 397ecdb..bb24732 100644 --- a/configure.in +++ b/configure.in @@ -181,6 +181,12 @@ fi AC_CHECK_SIZEOF(long,,[#include <stdio.h>]) +# crude: assumes that build machine has uint64_t it host machine has it +AC_TYPE_UINT64_T +AC_TYPE_UINT32_T +#if test $ac_cv_c_uint64_t = no; then +#fi + dnl vsnprintf not universally available dnl usleep not available in Unicos and mingw32 AC_CHECK_FUNCS(vsnprintf gettimeofday usleep times) diff --git a/engine/hash.h b/engine/hash.h index 02ff7bc..69d3fe7 100644 --- a/engine/hash.h +++ b/engine/hash.h @@ -51,9 +51,27 @@ * risk for hash collisions probably isn't worth the increased storage * cost. */ +#if HAVE_STDINT_H +# include <stdint.h> +#endif +#if defined UINT32_MAX || defined uint32_t +typedef uint32_t Hashvalue; +# define SIZEOF_HASHVALUE (4) +# if SIZEOF_HASHVALUE == SIZEOF_LONG +# define HASHVALUE_PRINT_FORMAT "%0*lx" +# elif (SIZEOF_HASHVALUE * 2) == SIZEOF_LONG +# define HASHVALUE_PRINT_FORMAT "%0*x" +# elif SIZEOF_HASHVALUE == (2 * SIZEOF_LONG) +# define HASHVALUE_PRINT_FORMAT "%0*llx" +# else +# error "bug yann for a fix" +# endif +#else +# error "where is my uint32_t !?" typedef unsigned long Hashvalue; -#define SIZEOF_HASHVALUE SIZEOF_LONG -#define HASHVALUE_PRINT_FORMAT "%0*lx" +# define SIZEOF_HASHVALUE SIZEOF_LONG +# define HASHVALUE_PRINT_FORMAT "%0*lx" +#endif /* for testing: Enables a lot of checks. */ #define CHECK_HASHING 0 -- 1.7.2.3 _______________________________________________ gnugo-devel mailing list gnugo-devel@gnu.org http://lists.gnu.org/mailman/listinfo/gnugo-devel