aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2014-04-30 12:05:07 +0300
committerPetri Lehtinen <petri@digip.org>2014-04-30 12:05:51 +0300
commitdb285b37649ffffabbb767029d4ca83af2e6f83d (patch)
tree25570470a635176ba447a1b23fb58bf776467ce4
parent960ead07f2d9d7c3b709273eebe2b0556826111a (diff)
downloadjansson-db285b37649ffffabbb767029d4ca83af2e6f83d.zip
jansson-db285b37649ffffabbb767029d4ca83af2e6f83d.tar.gz
jansson-db285b37649ffffabbb767029d4ca83af2e6f83d.tar.bz2
Check uint16_t and uint8_t support correctly
Fixes #177.
-rw-r--r--CMakeLists.txt30
-rw-r--r--cmake/config.h.cmake10
-rw-r--r--configure.ac2
3 files changed, 40 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7be3f0..82f397b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,10 +149,12 @@ else ()
message (FATAL_ERROR "Could not detect a valid 32-bit integer type")
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 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)
set (JSON_UINT32 uint32_t)
elseif (HAVE___UINT32)
@@ -165,6 +167,30 @@ else ()
message (FATAL_ERROR "Could not detect a valid unsigned 32-bit integer type")
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_type_size(ssize_t SSIZE_T)
check_type_size(SSIZE_T UPPERCASE_SSIZE_T)
diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake
index b27b9a3..16e7eb7 100644
--- a/cmake/config.h.cmake
+++ b/cmake/config.h.cmake
@@ -31,6 +31,16 @@
# define uint32_t @JSON_UINT32@
#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
#ifndef HAVE_SSIZE_T
diff --git a/configure.ac b/configure.ac
index 68d6fd6..98eeb88 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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.
AC_TYPE_INT32_T
AC_TYPE_UINT32_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT8_T
AC_TYPE_LONG_LONG_INT
AC_C_INLINE