aboutsummaryrefslogtreecommitdiffstats
path: root/lib/warnless.c
diff options
context:
space:
mode:
authorBertrand SIMONNET <bsimonnet@google.com>2015-07-09 11:05:09 -0700
committerBertrand SIMONNET <bsimonnet@google.com>2015-07-09 16:29:59 -0700
commit8eb97d044bca094e812492eb49a5cc1790cf1296 (patch)
tree517e658ceab73e16b9dc6f194a8518699002b480 /lib/warnless.c
parentf551028d5caab29d4b4a4ae8c159c76c3cfd4887 (diff)
downloadandroid_external_curl-8eb97d044bca094e812492eb49a5cc1790cf1296.tar.gz
android_external_curl-8eb97d044bca094e812492eb49a5cc1790cf1296.tar.bz2
android_external_curl-8eb97d044bca094e812492eb49a5cc1790cf1296.zip
Don't rely on hardcoded type size.
Instead of hard coding the type size computed in configure (which prevents cross compilation), use either the type sizes defined by bionic or sizeof instruction. BUG: 22347561 Change-Id: Ia1d8ba914e2f410754d0bd49618956d19d517d25
Diffstat (limited to 'lib/warnless.c')
-rw-r--r--lib/warnless.c94
1 files changed, 15 insertions, 79 deletions
diff --git a/lib/warnless.c b/lib/warnless.c
index 8c130d3..8d4bbdf 100644
--- a/lib/warnless.c
+++ b/lib/warnless.c
@@ -21,6 +21,7 @@
***************************************************************************/
#include "curl_setup.h"
+#include "stdint.h"
#if defined(__INTEL_COMPILER) && defined(__unix__)
@@ -40,82 +41,17 @@
#define CURL_MASK_SCHAR 0x7F
#define CURL_MASK_UCHAR 0xFF
-#if (SIZEOF_SHORT == 2)
-# define CURL_MASK_SSHORT 0x7FFF
-# define CURL_MASK_USHORT 0xFFFF
-#elif (SIZEOF_SHORT == 4)
-# define CURL_MASK_SSHORT 0x7FFFFFFF
-# define CURL_MASK_USHORT 0xFFFFFFFF
-#elif (SIZEOF_SHORT == 8)
-# define CURL_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
-# define CURL_MASK_USHORT 0xFFFFFFFFFFFFFFFF
-#else
-# error "SIZEOF_SHORT not defined"
-#endif
-
-#if (SIZEOF_INT == 2)
-# define CURL_MASK_SINT 0x7FFF
-# define CURL_MASK_UINT 0xFFFF
-#elif (SIZEOF_INT == 4)
-# define CURL_MASK_SINT 0x7FFFFFFF
-# define CURL_MASK_UINT 0xFFFFFFFF
-#elif (SIZEOF_INT == 8)
-# define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFF
-# define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFF
-#elif (SIZEOF_INT == 16)
-# define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
-# define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
-#else
-# error "SIZEOF_INT not defined"
-#endif
-
-#if (CURL_SIZEOF_LONG == 2)
-# define CURL_MASK_SLONG 0x7FFFL
-# define CURL_MASK_ULONG 0xFFFFUL
-#elif (CURL_SIZEOF_LONG == 4)
-# define CURL_MASK_SLONG 0x7FFFFFFFL
-# define CURL_MASK_ULONG 0xFFFFFFFFUL
-#elif (CURL_SIZEOF_LONG == 8)
-# define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFL
-# define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL
-#elif (CURL_SIZEOF_LONG == 16)
-# define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
-# define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
-#else
-# error "CURL_SIZEOF_LONG not defined"
-#endif
-
-#if (CURL_SIZEOF_CURL_OFF_T == 2)
-# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFF)
-# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFF)
-#elif (CURL_SIZEOF_CURL_OFF_T == 4)
-# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFF)
-# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFF)
-#elif (CURL_SIZEOF_CURL_OFF_T == 8)
-# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
-# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFF)
-#elif (CURL_SIZEOF_CURL_OFF_T == 16)
-# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
-# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
-#else
-# error "CURL_SIZEOF_CURL_OFF_T not defined"
-#endif
-
-#if (SIZEOF_SIZE_T == SIZEOF_SHORT)
-# define CURL_MASK_SSIZE_T CURL_MASK_SSHORT
-# define CURL_MASK_USIZE_T CURL_MASK_USHORT
-#elif (SIZEOF_SIZE_T == SIZEOF_INT)
-# define CURL_MASK_SSIZE_T CURL_MASK_SINT
-# define CURL_MASK_USIZE_T CURL_MASK_UINT
-#elif (SIZEOF_SIZE_T == CURL_SIZEOF_LONG)
-# define CURL_MASK_SSIZE_T CURL_MASK_SLONG
-# define CURL_MASK_USIZE_T CURL_MASK_ULONG
-#elif (SIZEOF_SIZE_T == CURL_SIZEOF_CURL_OFF_T)
-# define CURL_MASK_SSIZE_T CURL_MASK_SCOFFT
-# define CURL_MASK_USIZE_T CURL_MASK_UCOFFT
-#else
-# error "SIZEOF_SIZE_T not defined"
-#endif
+#define CURL_MASK_USHORT USHRT_MAX
+#define CURL_MASK_SSHORT SHRT_MAX
+
+#define CURL_MASK_SINT INT_MAX
+#define CURL_MASK_UINT UINT_MAX
+
+#define CURL_MASK_SLONG LONG_MAX
+#define CURL_MASK_ULONG ULONG_MAX
+
+#define CURL_MASK_UCOFFT UINT64_MAX
+#define CURL_MASK_SCOFFT INT64_MAX
/*
** unsigned long to unsigned short
@@ -329,8 +265,8 @@ ssize_t curlx_uztosz(size_t uznum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
- DEBUGASSERT(uznum <= (size_t) CURL_MASK_SSIZE_T);
- return (ssize_t)(uznum & (size_t) CURL_MASK_SSIZE_T);
+ DEBUGASSERT(uznum <= (size_t) SSIZE_MAX);
+ return (ssize_t)(uznum & (size_t) SSIZE_MAX);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
@@ -349,7 +285,7 @@ size_t curlx_sotouz(curl_off_t sonum)
#endif
DEBUGASSERT(sonum >= 0);
- return (size_t)(sonum & (curl_off_t) CURL_MASK_USIZE_T);
+ return (size_t)(sonum & (curl_off_t) SIZE_MAX);
#ifdef __INTEL_COMPILER
# pragma warning(pop)