Check uint16_t and uint8_t support correctly

Fixes #177.
This commit is contained in:
Petri Lehtinen 2014-04-30 12:05:07 +03:00
parent 960ead07f2
commit db285b3764
3 changed files with 40 additions and 2 deletions

View File

@ -149,10 +149,12 @@ else ()
message (FATAL_ERROR "Could not detect a valid 32-bit integer type") message (FATAL_ERROR "Could not detect a valid 32-bit integer type")
endif () endif ()
check_type_size (uint32_t UINT32_T)
check_type_size (__uint32 __UINT32)
check_type_size ("unsigned long" UNSIGNED_LONG_INT) check_type_size ("unsigned long" UNSIGNED_LONG_INT)
check_type_size ("unsigned int" UNSIGNED_INT) check_type_size ("unsigned int" UNSIGNED_INT)
check_type_size ("unsigned short" UNSIGNED_SHORT)
check_type_size (uint32_t UINT32_T)
check_type_size (__uint32 __UINT32)
if (HAVE_UINT32_T) if (HAVE_UINT32_T)
set (JSON_UINT32 uint32_t) set (JSON_UINT32 uint32_t)
elseif (HAVE___UINT32) elseif (HAVE___UINT32)
@ -165,6 +167,30 @@ else ()
message (FATAL_ERROR "Could not detect a valid unsigned 32-bit integer type") message (FATAL_ERROR "Could not detect a valid unsigned 32-bit integer type")
endif () endif ()
check_type_size (uint16_t UINT16_T)
check_type_size (__uint16 __UINT16)
if (HAVE_UINT16_T)
set (JSON_UINT16 uint16_t)
elseif (HAVE___UINT16)
set (JSON_UINT16 __uint16)
elseif (HAVE_UNSIGNED_INT AND (${UNSIGNED_INT} EQUAL 2))
set (JSON_UINT16 "unsigned int")
elseif (HAVE_UNSIGNED_SHORT AND (${UNSIGNED_SHORT} EQUAL 2))
set (JSON_UINT16 "unsigned short")
else ()
message (FATAL_ERROR "Could not detect a valid unsigned 16-bit integer type")
endif ()
check_type_size (uint8_t UINT8_T)
check_type_size (__uint8 __UINT8)
if (HAVE_UINT8_T)
set (JSON_UINT8 uint8_t)
elseif (HAVE___UINT8)
set (JSON_UINT8 __uint8)
else ()
set (JSON_UINT8 "unsigned char")
endif ()
# Check for ssize_t and SSIZE_T existance. # Check for ssize_t and SSIZE_T existance.
check_type_size(ssize_t SSIZE_T) check_type_size(ssize_t SSIZE_T)
check_type_size(SSIZE_T UPPERCASE_SSIZE_T) check_type_size(SSIZE_T UPPERCASE_SSIZE_T)

View File

@ -31,6 +31,16 @@
# define uint32_t @JSON_UINT32@ # define uint32_t @JSON_UINT32@
#endif #endif
#cmakedefine HAVE_UINT16_T 1
#ifndef HAVE_UINT16_T
# define uint16_t @JSON_UINT16@
#endif
#cmakedefine HAVE_UINT8_T 1
#ifndef HAVE_UINT8_T
# define uint8_t @JSON_UINT8@
#endif
#cmakedefine HAVE_SSIZE_T 1 #cmakedefine HAVE_SSIZE_T 1
#ifndef HAVE_SSIZE_T #ifndef HAVE_SSIZE_T

View File

@ -19,6 +19,8 @@ AC_CHECK_HEADERS([endian.h fcntl.h locale.h sched.h unistd.h sys/param.h sys/sta
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_INT32_T AC_TYPE_INT32_T
AC_TYPE_UINT32_T AC_TYPE_UINT32_T
AC_TYPE_UINT16_T
AC_TYPE_UINT8_T
AC_TYPE_LONG_LONG_INT AC_TYPE_LONG_LONG_INT
AC_C_INLINE AC_C_INLINE