diff options
author | Bertrand SIMONNET <bsimonnet@google.com> | 2015-07-16 20:13:50 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-07-16 20:13:51 +0000 |
commit | f95ed38c51a977d83271113e9b21f4157fda3768 (patch) | |
tree | 517e658ceab73e16b9dc6f194a8518699002b480 | |
parent | 4124fb44c6f964205d2197f4390946c51222dc39 (diff) | |
parent | 8eb97d044bca094e812492eb49a5cc1790cf1296 (diff) | |
download | external_curl-f95ed38c51a977d83271113e9b21f4157fda3768.tar.gz external_curl-f95ed38c51a977d83271113e9b21f4157fda3768.tar.bz2 external_curl-f95ed38c51a977d83271113e9b21f4157fda3768.zip |
Merge "Don't rely on hardcoded type size."
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | include/curl/curlbuild.h.in | 3 | ||||
-rw-r--r-- | include/curl/curlrules.h | 14 | ||||
-rw-r--r-- | lib/curl_setup.h | 32 | ||||
-rw-r--r-- | lib/parsedate.c | 4 | ||||
-rw-r--r-- | lib/warnless.c | 94 |
6 files changed, 16 insertions, 145 deletions
diff --git a/configure.ac b/configure.ac index 57ac11fc..a5e8b4ce 100644 --- a/configure.ac +++ b/configure.ac @@ -174,14 +174,6 @@ dnl INITIAL_LDFLAGS=$LDFLAGS INITIAL_LIBS=$LIBS -dnl -dnl Detect the canonical host and target build environment -dnl - -AC_CANONICAL_HOST -dnl Get system canonical name -AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS]) - dnl Checks for programs. dnl Our curl_off_t internal and external configure settings @@ -2966,12 +2958,6 @@ AC_HEADER_TIME CURL_CHECK_STRUCT_TIMEVAL CURL_VERIFY_RUNTIMELIBS -AC_CHECK_SIZEOF(size_t) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(short) -CURL_CONFIGURE_LONG -AC_CHECK_SIZEOF(time_t) AC_CHECK_SIZEOF(off_t) soname_bump=no diff --git a/include/curl/curlbuild.h.in b/include/curl/curlbuild.h.in index e29f195d..7cb2b6ef 100644 --- a/include/curl/curlbuild.h.in +++ b/include/curl/curlbuild.h.in @@ -158,9 +158,6 @@ # include <sys/poll.h> #endif -/* The size of `long', as computed by sizeof. */ -#undef CURL_SIZEOF_LONG - /* Integral data type used for curl_socklen_t. */ #undef CURL_TYPEOF_CURL_SOCKLEN_T diff --git a/include/curl/curlrules.h b/include/curl/curlrules.h index 7c2ede35..1163e95f 100644 --- a/include/curl/curlrules.h +++ b/include/curl/curlrules.h @@ -75,11 +75,6 @@ * Verify that some macros are actually defined. */ -#ifndef CURL_SIZEOF_LONG -# error "CURL_SIZEOF_LONG definition is missing!" - Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing -#endif - #ifndef CURL_TYPEOF_CURL_SOCKLEN_T # error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!" Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing @@ -134,15 +129,6 @@ #define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 /* - * Verify that the size previously defined and expected for long - * is the same as the one reported by sizeof() at compile time. - */ - -typedef char - __curl_rule_01__ - [CurlchkszEQ(long, CURL_SIZEOF_LONG)]; - -/* * Verify that the size previously defined and expected for * curl_off_t is actually the the same as the one reported * by sizeof() at compile time. diff --git a/lib/curl_setup.h b/lib/curl_setup.h index ab0c1394..df8b1e70 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 3e168f5a..62167889 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 8c130d34..8d4bbdf5 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) |