aboutsummaryrefslogtreecommitdiff
path: root/lib/warnless.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-12-02 18:46:13 +0100
committerYang Tse <yangsita@gmail.com>2010-12-02 18:46:13 +0100
commit07f60235b06a172a98082d11f065c13f7ecb1ec0 (patch)
tree2a50907dac005783e8b6701b7e476fd679575586 /lib/warnless.c
parent5580fb2b9cb392f909d39b04292d75b3611197f0 (diff)
fix compiler warning: rounding, sign extension, or loss of accuracy may result
Diffstat (limited to 'lib/warnless.c')
-rw-r--r--lib/warnless.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/lib/warnless.c b/lib/warnless.c
index 471e4b2c7..3bd23df03 100644
--- a/lib/warnless.c
+++ b/lib/warnless.c
@@ -37,7 +37,7 @@
# define CURL_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
# define CURL_MASK_USHORT 0xFFFFFFFFFFFFFFFF
#else
-# error "SIZEOF_SHORT not defined"
+# error "SIZEOF_SHORT not defined"
#endif
#if (SIZEOF_INT == 2)
@@ -53,7 +53,7 @@
# define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
# define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
#else
-# error "SIZEOF_INT not defined"
+# error "SIZEOF_INT not defined"
#endif
#if (CURL_SIZEOF_LONG == 2)
@@ -69,7 +69,39 @@
# define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
# define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
#else
-# error "SIZEOF_LONG not defined"
+# 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
/*
@@ -179,3 +211,21 @@ unsigned short curlx_sltous(long slnum)
# pragma warning(pop)
#endif
}
+
+/*
+** unsigned size_t to signed ssize_t
+*/
+
+ssize_t curlx_uztosz(size_t uznum)
+{
+#ifdef __INTEL_COMPILER
+# pragma warning(push)
+# pragma warning(disable:810) /* conversion may lose significant bits */
+#endif
+
+ return (ssize_t)(uznum & (size_t) CURL_MASK_SSIZE_T);
+
+#ifdef __INTEL_COMPILER
+# pragma warning(pop)
+#endif
+}