From feb03e471786e9c543ef6e807a4a748046c0ce2b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 13 Aug 2008 15:32:20 +0000 Subject: The size of long is a build time characteristic and as such it is now recorded in curlbuild.h as CURL_SIZEOF_LONG. Definition now done from configure process and in CVS curlbuild.h.dist for non-configure systems. --- include/curl/curlbuild.h.dist | 72 +++++++++++++++++++++++++++++++------------ include/curl/curlbuild.h.in | 3 ++ include/curl/curlrules.h | 18 +++++++++-- 3 files changed, 72 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/curl/curlbuild.h.dist b/include/curl/curlbuild.h.dist index 06e06adef..7dd26a698 100644 --- a/include/curl/curlbuild.h.dist +++ b/include/curl/curlbuild.h.dist @@ -139,6 +139,7 @@ /* ================================================================ */ #if defined(__DJGPP__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -148,6 +149,7 @@ # define CURL_SUFFIX_CURL_OFF_TU UL #elif defined(__SALFORDC__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -158,6 +160,7 @@ #elif defined(__BORLANDC__) # if (__BORLANDC__ < 0x520) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -166,6 +169,7 @@ # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # else +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T __int64 # define CURL_FMT_OFF_T "I64d" # define CURL_FMT_OFF_TU "I64u" @@ -176,6 +180,7 @@ # endif #elif defined(__TURBOC__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -186,6 +191,7 @@ #elif defined(__WATCOMC__) # if defined(__386__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T __int64 # define CURL_FMT_OFF_T "I64d" # define CURL_FMT_OFF_TU "I64u" @@ -194,6 +200,7 @@ # define CURL_SUFFIX_CURL_OFF_T i64 # define CURL_SUFFIX_CURL_OFF_TU ui64 # else +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -205,6 +212,7 @@ #elif defined(__POCC__) # if (__POCC__ < 280) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -213,6 +221,7 @@ # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # elif defined(_MSC_VER) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T __int64 # define CURL_FMT_OFF_T "I64d" # define CURL_FMT_OFF_TU "I64u" @@ -221,6 +230,7 @@ # define CURL_SUFFIX_CURL_OFF_T i64 # define CURL_SUFFIX_CURL_OFF_TU ui64 # else +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -231,6 +241,7 @@ # endif #elif defined(__LCC__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -241,6 +252,7 @@ #elif defined(__SYMBIAN32__) # if defined(__GCC32__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -250,6 +262,7 @@ # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__CW32__) # pragma longlong on +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -258,6 +271,7 @@ # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__VC32__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T __int64 # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -268,6 +282,7 @@ # endif #elif defined(__MWERKS__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -277,6 +292,7 @@ # define CURL_SUFFIX_CURL_OFF_TU ULL #elif defined(_WIN32_WCE) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T __int64 # define CURL_FMT_OFF_T "I64d" # define CURL_FMT_OFF_TU "I64u" @@ -286,6 +302,7 @@ # define CURL_SUFFIX_CURL_OFF_TU ui64 #elif defined(__MINGW32__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "I64d" # define CURL_FMT_OFF_TU "I64u" @@ -294,27 +311,9 @@ # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL -#elif defined(_MSC_VER) -# if (_MSC_VER >= 900) -# define CURL_OFF_T __int64 -# define CURL_FMT_OFF_T "I64d" -# define CURL_FMT_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURL_OFF_T long -# define CURL_FMT_OFF_T "ld" -# define CURL_FMT_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif - #elif defined(__VMS) # if defined(__alpha) || defined(__ia64) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -323,6 +322,7 @@ # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # else +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -334,6 +334,7 @@ #elif defined(__OS400__) # if defined(__ILEC400__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -346,6 +347,7 @@ #elif defined(__MVS__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_LONG_LONG) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -354,6 +356,7 @@ # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(_LP64) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -362,6 +365,7 @@ # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # else +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -375,6 +379,7 @@ #elif defined(__370__) # if defined(__IBMC__) || defined(__IBMCPP__) # if defined(_LONG_LONG) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -383,6 +388,7 @@ # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(_LP64) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -391,6 +397,7 @@ # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # else +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" @@ -401,12 +408,38 @@ # endif # endif +/* ===================================== */ +/* KEEP MSVC THE PENULTIMATE ENTRY */ +/* ===================================== */ + +#elif defined(_MSC_VER) +# if (_MSC_VER >= 900) +# define CURL_SIZEOF_LONG 4 +# define CURL_OFF_T __int64 +# define CURL_FMT_OFF_T "I64d" +# define CURL_FMT_OFF_TU "I64u" +# define CURL_FORMAT_OFF_T "%I64d" +# define CURL_SIZEOF_CURL_OFF_T 8 +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# else +# define CURL_SIZEOF_LONG 4 +# define CURL_OFF_T long +# define CURL_FMT_OFF_T "ld" +# define CURL_FMT_OFF_TU "lu" +# define CURL_FORMAT_OFF_T "%ld" +# define CURL_SIZEOF_CURL_OFF_T 4 +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif + /* ===================================== */ /* KEEP GENERIC GCC THE LAST ENTRY */ /* ===================================== */ #elif defined(__GNUC__) # if defined(__i386__) +# define CURL_SIZEOF_LONG 4 # define CURL_OFF_T long long # define CURL_FMT_OFF_T "lld" # define CURL_FMT_OFF_TU "llu" @@ -415,6 +448,7 @@ # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__x86_64__) +# define CURL_SIZEOF_LONG 8 # define CURL_OFF_T long # define CURL_FMT_OFF_T "ld" # define CURL_FMT_OFF_TU "lu" diff --git a/include/curl/curlbuild.h.in b/include/curl/curlbuild.h.in index 7ed27f7a7..e0d35a555 100644 --- a/include/curl/curlbuild.h.in +++ b/include/curl/curlbuild.h.in @@ -108,6 +108,9 @@ # include #endif +/* The expected size of long , as to be computed by sizeof. */ +#undef CURL_SIZEOF_LONG + /* Signed integral data type used for curl_off_t. */ #undef CURL_OFF_T diff --git a/include/curl/curlrules.h b/include/curl/curlrules.h index cda33b21b..4a7671fcd 100644 --- a/include/curl/curlrules.h +++ b/include/curl/curlrules.h @@ -76,6 +76,11 @@ * 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_OFF_T # error "CURL_OFF_T definition is missing!" Error Compilation_aborted_CURL_OFF_T_is_missing @@ -119,6 +124,15 @@ #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 @@ -126,7 +140,7 @@ */ typedef char - __curl_rule_01__ + __curl_rule_02__ [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)]; /* @@ -136,7 +150,7 @@ typedef char */ typedef char - __curl_rule_02__ + __curl_rule_03__ [CurlchkszGE(curl_off_t, long)]; /* ================================================================ */ -- cgit v1.2.3