From: Guido Draheim Date: Thu, 1 Mar 2018 17:52:42 +0000 (+0100) Subject: add stdint.h intptr_t emulation #29 #30 X-Git-Tag: v0.13.69~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=75ddc796529b191437514be2bbf6a2f561a74a6f;p=zziplib add stdint.h intptr_t emulation #29 #30 --- diff --git a/config.h.in b/config.h.in index c9379b7..bea5c35 100644 --- a/config.h.in +++ b/config.h.in @@ -125,6 +125,9 @@ /* The number of bytes in type int */ #undef SIZEOF_INT +/* The number of bytes in type int * */ +#undef SIZEOF_INT_P + /* The number of bytes in type long */ #undef SIZEOF_LONG diff --git a/configure b/configure index d2f1f98..e3ad915 100755 --- a/configure +++ b/configure @@ -13095,6 +13095,46 @@ cat >>confdefs.h <<_ACEOF _ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 +$as_echo_n "checking size of int *... " >&6; } +if ${ac_cv_sizeof_int_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + for ac_size in 4 8 1 2 16 ; do # List sizes in rough order of prevalence. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include "confdefs.h" +#include + + +int +main () +{ +switch (0) case 0: case (sizeof (int *) == $ac_size):; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sizeof_int_p=$ac_size +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test x$ac_cv_sizeof_int_p != x ; then break; fi +done + +fi + +if test x$ac_cv_sizeof_int_p = x ; then + as_fn_error $? "cannot determine a size for int *" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int_p" >&5 +$as_echo "$ac_cv_sizeof_int_p" >&6; } + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT_P $ac_cv_sizeof_int_p +_ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : diff --git a/configure.ac b/configure.ac index 774d1cc..bdbde30 100644 --- a/configure.ac +++ b/configure.ac @@ -108,9 +108,10 @@ dnl AC_TYPE_SSIZE_T AC_CHECK_TYPE(ssize_t,int) AC_CHECK_TYPE(off64_t,_zzip_off_t) AC_CHECK_TYPE(__int64,long long) -AC_COMPILE_CHECK_SIZEOF(short) -AC_COMPILE_CHECK_SIZEOF(int) -AC_COMPILE_CHECK_SIZEOF(long) +AC_COMPILE_CHECK_SIZEOF([short]) +AC_COMPILE_CHECK_SIZEOF([int]) +AC_COMPILE_CHECK_SIZEOF([long]) +AC_COMPILE_CHECK_SIZEOF([int *]) AC_C_BIGENDIAN AX_CHECK_ALIGNED_ACCESS_REQUIRED dnl ------------------------------------------------------------- diff --git a/zzip/stdint.h b/zzip/stdint.h index 4552c5b..9526976 100644 --- a/zzip/stdint.h +++ b/zzip/stdint.h @@ -38,8 +38,19 @@ typedef unsigned long uint32_t; typedef signed long int32_t; # endif +/* either (long long) on Unix or (__int64) on Windows */ typedef unsigned _zzip___int64 uint64_t; typedef _zzip___int64 int64_t; -#endif +# if defined ZZIP_SIZEOF_INT_P +# if ZZIP_SIZEOF_INT_P == ZZIP_SIZEOF_LONG+0 + typedef long intptr_t; +# elif ZZIP_SIZEOF_INT_P == ZZIP_SIZEOF_INT+0 + typedef int intptr_t; +# else + typedef int64_t intptr_t; +# endif +# endif + +#endif /* ZZIP_HAVE_... */ #endif /*_ZZIP_STDINT_H*/