aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/curl_setup.h32
-rw-r--r--lib/parsedate.c4
-rw-r--r--lib/warnless.c94
3 files changed, 16 insertions, 114 deletions
diff --git a/lib/curl_setup.h b/lib/curl_setup.h
index ab0c139..df8b1e7 100644
--- a/lib/curl_setup.h
+++ b/lib/curl_setup.h
@@ -393,33 +393,6 @@
#endif
/*
- * Default sizeof(off_t) in case it hasn't been defined in config file.
- */
-
-#ifndef SIZEOF_OFF_T
-# if defined(__VMS) && !defined(__VAX)
-# if defined(_LARGEFILE)
-# define SIZEOF_OFF_T 8
-# endif
-# elif defined(__OS400__) && defined(__ILEC400__)
-# if defined(_LARGE_FILES)
-# define SIZEOF_OFF_T 8
-# endif
-# elif defined(__MVS__) && defined(__IBMC__)
-# if defined(_LP64) || defined(_LARGE_FILES)
-# define SIZEOF_OFF_T 8
-# endif
-# elif defined(__370__) && defined(__IBMC__)
-# if defined(_LP64) || defined(_LARGE_FILES)
-# define SIZEOF_OFF_T 8
-# endif
-# endif
-# ifndef SIZEOF_OFF_T
-# define SIZEOF_OFF_T 4
-# endif
-#endif
-
-/*
* Arg 2 type for gethostname in case it hasn't been defined in config file.
*/
@@ -597,11 +570,6 @@ int netware_init(void);
#define USE_LIBIDN
#endif
-#ifndef SIZEOF_TIME_T
-/* assume default size of time_t to be 32 bit */
-#define SIZEOF_TIME_T 4
-#endif
-
#define LIBIDN_REQUIRED_VERSION "0.4.1"
#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
diff --git a/lib/parsedate.c b/lib/parsedate.c
index 3e168f5..6216788 100644
--- a/lib/parsedate.c
+++ b/lib/parsedate.c
@@ -491,13 +491,11 @@ static int parsedate(const char *date, time_t *output)
/* lacks vital info, fail */
return PARSEDATE_FAIL;
-#if SIZEOF_TIME_T < 5
/* 32 bit time_t can only hold dates to the beginning of 2038 */
- if(yearnum > 2037) {
+ if(sizeof(time_t) < 5 && yearnum > 2037) {
*output = 0x7fffffff;
return PARSEDATE_LATER;
}
-#endif
if(yearnum < 1970) {
*output = 0;
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)