+# so we don't get confused by the cache (wish there was a better way
+# to check particular headers for the same type...)
+
+unset ac_cv_type_int8_t
+unset ac_cv_type_uint8_t
+unset ac_cv_type_int16_t
+unset ac_cv_type_uint16_t
+unset ac_cv_type_int32_t
+unset ac_cv_type_uint32_t
+unset ac_cv_type_int64_t
+unset ac_cv_type_uint64_t
+
+### See what's provided by inttypes.h
+if test "$ac_cv_header_inttypes_h" = yes; then
+ AC_CHECK_TYPE([int8_t],[scm_inttypes_has_int8=1],,[#include <inttypes.h>])
+ AC_CHECK_TYPE([uint8_t],[scm_inttypes_has_uint8=1],,[#include <inttypes.h>])
+ AC_CHECK_TYPE([int16_t],[scm_inttypes_has_int16=1],,[#include <inttypes.h>])
+ AC_CHECK_TYPE([uint16_t],[scm_inttypes_has_uint16=1],,[#include <inttypes.h>])
+ AC_CHECK_TYPE([int32_t],[scm_inttypes_has_int32=1],,[#include <inttypes.h>])
+ AC_CHECK_TYPE([uint32_t],[scm_inttypes_has_uint32=1],,[#include <inttypes.h>])
+ AC_CHECK_TYPE([int64_t],[scm_inttypes_has_int64=1],,[#include <inttypes.h>])
+ AC_CHECK_TYPE([uint64_t],[scm_inttypes_has_uint64=1],,[#include <inttypes.h>])
+fi
+
+# Try hard to find definitions for some required scm_t_*int* types.
+
+### Required type scm_t_int8
+if test "$ac_cv_sizeof_char" -eq 1; then
+ SCM_I_GSC_T_INT8='"char"'
+elif test "$scm_stdint_has_int8"; then
+ SCM_I_GSC_T_INT8='"int8_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_int8"; then
+ SCM_I_GSC_T_INT8='"int8_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_int8.])
+fi
+AC_SUBST([SCM_I_GSC_T_INT8])
+
+### Required type scm_t_uint8
+if test "$ac_cv_sizeof_unsigned_char" -eq 1; then
+ SCM_I_GSC_T_UINT8='"unsigned char"'
+elif test "$scm_stdint_has_uint8"; then
+ SCM_I_GSC_T_UINT8='"uint8_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_uint8"; then
+ SCM_I_GSC_T_UINT8='"uint8_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_uint8.])
+fi
+AC_SUBST([SCM_I_GSC_T_UINT8])
+
+
+### Required type scm_t_int16 (ANSI C says int or short might work)
+if test "$ac_cv_sizeof_int" -eq 2; then
+ SCM_I_GSC_T_INT16='"int"'
+elif test "$ac_cv_sizeof_short" -eq 2; then
+ SCM_I_GSC_T_INT16='"short"'
+elif test "$scm_stdint_has_int16"; then
+ SCM_I_GSC_T_INT16='"int16_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_int16"; then
+ SCM_I_GSC_T_INT16='"int16_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_int16.])
+fi
+AC_SUBST([SCM_I_GSC_T_INT16])
+
+### Required type scm_t_uint16 (ANSI C says int or short might work)
+if test "$ac_cv_sizeof_unsigned_int" -eq 2; then
+ SCM_I_GSC_T_UINT16='"unsigned int"'
+elif test "$ac_cv_sizeof_unsigned_short" -eq 2; then
+ SCM_I_GSC_T_UINT16='"unsigned short"'
+elif test "$scm_stdint_has_uint16"; then
+ SCM_I_GSC_T_UINT16='"uint16_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_uint16"; then
+ SCM_I_GSC_T_UINT16='"uint16_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_uint16.])
+fi
+AC_SUBST([SCM_I_GSC_T_UINT16])
+
+
+### Required type scm_t_int32 (ANSI C says int, short, or long might work)
+if test "$ac_cv_sizeof_int" -eq 4; then
+ SCM_I_GSC_T_INT32='"int"'
+elif test "$ac_cv_sizeof_long" -eq 4; then
+ SCM_I_GSC_T_INT32='"long"'
+elif test "$ac_cv_sizeof_short" -eq 4; then
+ SCM_I_GSC_T_INT32='"short"'
+elif test "$scm_stdint_has_int32"; then
+ SCM_I_GSC_T_INT32='"int32_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_int32"; then
+ SCM_I_GSC_T_INT32='"int32_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_int32.])
+fi
+AC_SUBST([SCM_I_GSC_T_INT32])
+
+### Required type scm_t_uint32 (ANSI C says int, short, or long might work)
+if test "$ac_cv_sizeof_unsigned_int" -eq 4; then
+ SCM_I_GSC_T_UINT32='"unsigned int"'
+elif test "$ac_cv_sizeof_unsigned_long" -eq 4; then
+ SCM_I_GSC_T_UINT32='"unsigned long"'
+elif test "$ac_cv_sizeof_unsigned_short" -eq 4; then
+ SCM_I_GSC_T_UINT32='"unsigned short"'
+elif test "$scm_stdint_has_uint32"; then
+ SCM_I_GSC_T_UINT32='"uint32_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_uint32"; then
+ SCM_I_GSC_T_UINT32='"uint32_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_uint32.])
+fi
+AC_SUBST([SCM_I_GSC_T_UINT32])
+
+### Optional type scm_t_int64 (ANSI C says int, short, or long might work)
+### Also try long long if we have it.
+SCM_I_GSC_T_INT64=0
+if test "$ac_cv_sizeof_int" -eq 8; then
+ SCM_I_GSC_T_INT64='"int"'
+elif test "$ac_cv_sizeof_long" -eq 8; then
+ SCM_I_GSC_T_INT64='"long"'
+elif test "$ac_cv_sizeof_short" -eq 8; then
+ SCM_I_GSC_T_INT64='"short"'
+elif test "$ac_cv_sizeof_long_long" -eq 8; then
+ SCM_I_GSC_T_INT64='"long long"'
+elif test "$scm_stdint_has_int64"; then
+ SCM_I_GSC_T_INT64='"int64_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_int64"; then
+ SCM_I_GSC_T_INT64='"int64_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_int64.])
+fi
+AC_SUBST([SCM_I_GSC_T_INT64])
+
+### Optional type scm_t_uint64 (ANSI C says int, short, or long might work)
+### Also try long long if we have it.
+SCM_I_GSC_T_UINT64=0
+if test "$ac_cv_sizeof_unsigned_int" -eq 8; then
+ SCM_I_GSC_T_UINT64='"unsigned int"'
+elif test "$ac_cv_sizeof_unsigned_long" -eq 8; then
+ SCM_I_GSC_T_UINT64='"unsigned long"'
+elif test "$ac_cv_sizeof_unsigned_short" -eq 8; then
+ SCM_I_GSC_T_UINT64='"unsigned short"'
+elif test "$ac_cv_sizeof_unsigned_long_long" -eq 8; then
+ SCM_I_GSC_T_UINT64='"unsigned long long"'
+elif test "$scm_stdint_has_uint64"; then
+ SCM_I_GSC_T_UINT64='"uint64_t"'
+ SCM_I_GSC_NEEDS_STDINT_H=1
+elif test "$scm_inttypes_has_uint64"; then
+ SCM_I_GSC_T_UINT64='"uint64_t"'
+ SCM_I_GSC_NEEDS_INTTYPES_H=1
+else
+ AC_MSG_ERROR([Can't find appropriate type for scm_t_uint64.])
+fi
+AC_SUBST([SCM_I_GSC_T_UINT64])
+
+
+AC_SUBST([SCM_I_GSC_NEEDS_STDINT_H])
+AC_SUBST([SCM_I_GSC_NEEDS_INTTYPES_H])
+