aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-08-13 15:32:20 +0000
committerYang Tse <yangsita@gmail.com>2008-08-13 15:32:20 +0000
commitfeb03e471786e9c543ef6e807a4a748046c0ce2b (patch)
treeb2c7571bd167c31f8702240a0e9c6f1fec295df5
parent64e3a091c34482b666c3c50c312829cd7fa140c9 (diff)
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.
-rw-r--r--CHANGES13
-rw-r--r--acinclude.m443
-rw-r--r--include/curl/curlbuild.h.dist72
-rw-r--r--include/curl/curlbuild.h.in3
-rw-r--r--include/curl/curlrules.h18
-rw-r--r--lib/Makefile.netware2
-rw-r--r--lib/config-symbian.h3
-rw-r--r--lib/config-tpf.h3
-rw-r--r--lib/strtoofft.h2
-rw-r--r--src/main.c2
10 files changed, 127 insertions, 34 deletions
diff --git a/CHANGES b/CHANGES
index 7a839420b..b1c613d85 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,19 @@
Changelog
+Yang Tse (13 Aug 2008)
+- 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.
+
+- Make SIZE_OF_LONG mandatory. It is not possible to build the library without
+ it. It will be defined by the configure process in generated config.h. And
+ can be defined in hand-crafted system-specific config.h files to the numeric
+ size that sizeof(long) would return for that specific platform. It might be
+ ABI dependant, if this is the case, the definition is equally ABI dependant,
+ its value normally will be 4 or 8. It can also be defined in curlbuild.h.dist
+ and maybe it is easier and more appropriate to make the definition here.
+
Daniel Fandrich (12 Aug 2008)
- Fixed a buffer overflow problem in Curl_proxyCONNECT that could occur
when a server responded with long headers and data. Luckily, the buffer
diff --git a/acinclude.m4 b/acinclude.m4
index 433a4e22e..8240a7da1 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -3613,6 +3613,43 @@ _EOF
])
+dnl CURL_CONFIGURE_LONG
+dnl -------------------------------------------------
+dnl Find out the size of long as reported by sizeof() and define
+dnl CURL_SIZEOF_LONG as appropriate to be used in template file
+dnl include/curl/curlbuild.h.in to properly configure the library.
+dnl The size of long is a build time characteristic and as such
+dnl must be recorded in curlbuild.h
+
+AC_DEFUN([CURL_CONFIGURE_LONG], [
+ if test ! -z "$ac_cv_sizeof_long"; then
+ AC_MSG_WARN([AC_CHECK_SIZEOF(long) was called before CURL_CONFIGURE_LONG])
+ fi
+ AC_MSG_CHECKING([size of long])
+ curl_sizeof_long="unknown"
+ for tmp_size in '16' '8' '4' '2' '1' ; do
+ if test "$curl_sizeof_long" = "unknown"; then
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ typedef char dummy_arr[sizeof(long) == $tmp_size ? 1 : -1];
+ ]],[[
+ dummy_arr[1] = (long)1;
+ ]])
+ ],[
+ curl_sizeof_long="$tmp_size"
+ ])
+ fi
+ done
+ if test "$curl_sizeof_long" = "unknown"; then
+ AC_MSG_ERROR([cannot find out size of long])
+ else
+ AC_MSG_RESULT([$curl_sizeof_long])
+ CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$curl_sizeof_long])
+ ac_cv_sizeof_long="$curl_sizeof_long"
+ fi
+])
+
+
dnl CURL_INCLUDES_INTTYPES
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
@@ -3722,13 +3759,9 @@ AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
fi
#
- AC_CHECK_SIZEOF(long)
+ CURL_CONFIGURE_LONG
AC_CHECK_SIZEOF(void*)
#
- if test -z "$ac_cv_sizeof_long" ||
- test "$ac_cv_sizeof_long" -eq "0"; then
- AC_MSG_ERROR([cannot find out size of long.])
- fi
if test -z "$ac_cv_sizeof_voidp" ||
test "$ac_cv_sizeof_voidp" -eq "0"; then
AC_MSG_ERROR([cannot find out size of void*.])
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"
@@ -402,11 +409,37 @@
# 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 <inttypes.h>
#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
@@ -120,13 +125,22 @@
#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.
*/
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)];
/* ================================================================ */
diff --git a/lib/Makefile.netware b/lib/Makefile.netware
index b5025cfed..886874319 100644
--- a/lib/Makefile.netware
+++ b/lib/Makefile.netware
@@ -595,6 +595,7 @@ $(CURL_INC)/curl/curlbuild.h: Makefile.netware FORCE
@echo $(DL)#ifndef __CURL_CURLBUILD_H$(DL) >> $@
@echo $(DL)#define __CURL_CURLBUILD_H$(DL) >> $@
ifeq ($(LIBARCH),LIBC)
+ @echo $(DL)#define CURL_SIZEOF_LONG 4$(DL) >> $@
@echo $(DL)#define CURL_OFF_T long long$(DL) >> $@
@echo $(DL)#define CURL_FMT_OFF_T "lld"$(DL) >> $@
@echo $(DL)#define CURL_FMT_OFF_TU "llu"$(DL) >> $@
@@ -603,6 +604,7 @@ ifeq ($(LIBARCH),LIBC)
@echo $(DL)#define CURL_SUFFIX_CURL_OFF_T LL$(DL) >> $@
@echo $(DL)#define CURL_SUFFIX_CURL_OFF_TU ULL$(DL) >> $@
else
+ @echo $(DL)#define CURL_SIZEOF_LONG 4$(DL) >> $@
@echo $(DL)#define CURL_OFF_T long$(DL) >> $@
@echo $(DL)#define CURL_FMT_OFF_T "ld"$(DL) >> $@
@echo $(DL)#define CURL_FMT_OFF_TU "lu"$(DL) >> $@
diff --git a/lib/config-symbian.h b/lib/config-symbian.h
index d4b5f0979..a39669c48 100644
--- a/lib/config-symbian.h
+++ b/lib/config-symbian.h
@@ -712,9 +712,6 @@
/* Define to the type of arg 5 for `select'. */
#define SELECT_TYPE_ARG5 (struct timeval *)
-/* The size of `long', as computed by sizeof. */
-#define SIZEOF_LONG 4
-
/* The size of `off_t', as computed by sizeof. */
#define SIZEOF_OFF_T 8
diff --git a/lib/config-tpf.h b/lib/config-tpf.h
index 70b799a3d..f8d193e17 100644
--- a/lib/config-tpf.h
+++ b/lib/config-tpf.h
@@ -593,9 +593,6 @@
/* Define to the type of arg 5 for `select'. */
#define SELECT_TYPE_ARG5 (struct timeval *)
-/* The size of a `long', as computed by sizeof. */
-#define SIZEOF_LONG 8
-
/* The size of a `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 8
diff --git a/lib/strtoofft.h b/lib/strtoofft.h
index a9ccca017..c556404d5 100644
--- a/lib/strtoofft.h
+++ b/lib/strtoofft.h
@@ -41,7 +41,7 @@
* of 'long' the conversion funtion to use is strtol().
*/
-#if (CURL_SIZEOF_CURL_OFF_T > SIZEOF_LONG)
+#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
# ifdef HAVE_STRTOLL
# define curlx_strtoofft strtoll
# else
diff --git a/src/main.c b/src/main.c
index 0eaf8f7f5..948fd6756 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1387,7 +1387,7 @@ static int str2num(long *val, const char *str)
*/
static int str2offset(curl_off_t *val, const char *str)
{
-#if (CURL_SIZEOF_CURL_OFF_T > SIZEOF_LONG)
+#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
/* Ugly, but without going through a bunch of rigmarole, we don't have the
* definitions for LLONG_{MIN,MAX} or LONG_LONG_{MIN,MAX}.
*/