diff options
author | Ron <ron@debian.org> | 2013-12-07 20:31:56 +0400 |
---|---|---|
committer | Ron <ron@debian.org> | 2013-12-07 20:31:56 +0400 |
commit | ef80120166c3a2552f77008f40c59a84577a36b5 (patch) | |
tree | 9040bc356b2f053d3007b5a92ee8bb74b135296d | |
parent | 8aa51a2074b2dd272d9a7e3f164d8efdd6c229cc (diff) |
Prefer the stdint types if available
This is similar to the change we did in libogg some time back,
it means the generated header is less likely to vary unnecessarily
between system architectures.
-rw-r--r-- | configure.ac | 86 | ||||
-rw-r--r-- | include/speex/speex_config_types.h.in | 13 |
2 files changed, 66 insertions, 33 deletions
diff --git a/configure.ac b/configure.ac index 40606ea..0626347 100644 --- a/configure.ac +++ b/configure.ac @@ -250,38 +250,64 @@ AM_CONDITIONAL(BUILD_VORBIS_PSY, [test "x$vorbis_psy" = "xyes"]) PKG_CHECK_MODULES([SPEEXDSP], [speexdsp], [AC_DEFINE([USE_SPEEXDSP], [], [Use SpeexDSP library])], [speexdsp_failed=yes]) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(long) - -if test x$has_char16 = "xyes" ; then - case 1 in - $ac_cv_sizeof_short) SIZE16="short";; - $ac_cv_sizeof_int) SIZE16="int";; - esac -else - case 2 in - $ac_cv_sizeof_short) SIZE16="short";; - $ac_cv_sizeof_int) SIZE16="int";; - esac -fi -if test x$has_char16 = "xyes" ; then - case 2 in - $ac_cv_sizeof_int) SIZE32="int";; - $ac_cv_sizeof_long) SIZE32="long";; - $ac_cv_sizeof_short) SIZE32="short";; - esac -else - case 4 in - $ac_cv_sizeof_int) SIZE32="int";; - $ac_cv_sizeof_long) SIZE32="long";; - $ac_cv_sizeof_short) SIZE32="short";; - esac -fi +AC_CHECK_SIZEOF([int16_t]) +AC_CHECK_SIZEOF([uint16_t]) +AC_CHECK_SIZEOF([u_int16_t]) +AC_CHECK_SIZEOF([int32_t]) +AC_CHECK_SIZEOF([uint32_t]) +AC_CHECK_SIZEOF([u_int32_t]) +AC_CHECK_SIZEOF([short]) +AC_CHECK_SIZEOF([int]) +AC_CHECK_SIZEOF([long]) + +AS_IF([test "$has_char16" = "yes"], + [ + SIZEOF16=1 + SIZEOF32=2 + ],[ + SIZEOF16=2 + SIZEOF32=4 + ]) + +case $SIZEOF16 in + $ac_cv_sizeof_int16_t) SIZE16="int16_t";; + $ac_cv_sizeof_short) SIZE16="short";; + $ac_cv_sizeof_int) SIZE16="int";; +esac + +case $SIZEOF16 in + $ac_cv_sizeof_uint16_t) USIZE16="uint16_t";; + $ac_cv_sizeof_u_int16_t) USIZE16="u_int16_t";; + $ac_cv_sizeof_short) USIZE16="unsigned short";; + $ac_cv_sizeof_int) USIZE16="unsigned int";; +esac + +case $SIZEOF32 in + $ac_cv_sizeof_int32_t) SIZE32="int32_t";; + $ac_cv_sizeof_int) SIZE32="int";; + $ac_cv_sizeof_long) SIZE32="long";; + $ac_cv_sizeof_short) SIZE32="short";; +esac + +case $SIZEOF32 in + $ac_cv_sizeof_uint32_t) USIZE32="uint32_t";; + $ac_cv_sizeof_u_int32_t) USIZE32="u_int32_t";; + $ac_cv_sizeof_short) USIZE32="unsigned short";; + $ac_cv_sizeof_int) USIZE32="unsigned int";; + $ac_cv_sizeof_long) USIZE32="unsigned long";; +esac + +AS_IF([test -z "$SIZE16"],[AC_MSG_ERROR([No 16 bit type found on this platform!])]) +AS_IF([test -z "$SIZE32"],[AC_MSG_ERROR([No 32 bit type found on this platform!])]) +AS_IF([test -z "$USIZE16"],[AC_MSG_ERROR([No unsigned 16 bit type found on this platform!])]) +AS_IF([test -z "$USIZE32"],[AC_MSG_ERROR([No unsigned 32 bit type found on this platform!])]) + +AC_SUBST([SIZE16]) +AC_SUBST([USIZE16]) +AC_SUBST([SIZE32]) +AC_SUBST([USIZE32]) -AC_SUBST(SIZE16) -AC_SUBST(SIZE32) AC_CONFIG_FILES([ Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec diff --git a/include/speex/speex_config_types.h.in b/include/speex/speex_config_types.h.in index 3fab2ae..02b82fd 100644 --- a/include/speex/speex_config_types.h.in +++ b/include/speex/speex_config_types.h.in @@ -1,11 +1,18 @@ #ifndef __SPEEX_TYPES_H__ #define __SPEEX_TYPES_H__ -/* these are filled in by configure */ +#if defined HAVE_STDINT_H +# include <stdint.h> +#elif defined HAVE_INTTYPES_H +# include <inttypes.h> +#elif defined HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + typedef @SIZE16@ spx_int16_t; -typedef unsigned @SIZE16@ spx_uint16_t; +typedef @USIZE16@ spx_uint16_t; typedef @SIZE32@ spx_int32_t; -typedef unsigned @SIZE32@ spx_uint32_t; +typedef @USIZE32@ spx_uint32_t; #endif |