1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
22 ***************************************************************************/
28 #define CURL_MASK_SCHAR 0x7F
29 #define CURL_MASK_UCHAR 0xFF
31 #if (SIZEOF_SHORT == 2)
32 # define CURL_MASK_SSHORT 0x7FFF
33 # define CURL_MASK_USHORT 0xFFFF
34 #elif (SIZEOF_SHORT == 4)
35 # define CURL_MASK_SSHORT 0x7FFFFFFF
36 # define CURL_MASK_USHORT 0xFFFFFFFF
37 #elif (SIZEOF_SHORT == 8)
38 # define CURL_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
39 # define CURL_MASK_USHORT 0xFFFFFFFFFFFFFFFF
43 # define CURL_MASK_SINT 0x7FFF
44 # define CURL_MASK_UINT 0xFFFF
45 #elif (SIZEOF_INT == 4)
46 # define CURL_MASK_SINT 0x7FFFFFFF
47 # define CURL_MASK_UINT 0xFFFFFFFF
48 #elif (SIZEOF_INT == 8)
49 # define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFF
50 # define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFF
51 #elif (SIZEOF_INT == 16)
52 # define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
53 # define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
56 #if (CURL_SIZEOF_LONG == 2)
57 # define CURL_MASK_SLONG 0x7FFFL
58 # define CURL_MASK_ULONG 0xFFFFUL
59 #elif (SIZEOF_LONG == 4)
60 # define CURL_MASK_SLONG 0x7FFFFFFFL
61 # define CURL_MASK_ULONG 0xFFFFFFFFUL
62 #elif (SIZEOF_LONG == 8)
63 # define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFL
64 # define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL
65 #elif (SIZEOF_LONG == 16)
66 # define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
67 # define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
71 ** unsigned long to unsigned short
74 unsigned short curlx_ultous(unsigned long ulnum)
76 #ifdef __INTEL_COMPILER
77 # pragma warning(push)
78 # pragma warning(disable:810) /* conversion may lose significant bits */
81 return (unsigned short)(ulnum & (unsigned long) CURL_MASK_USHORT);
83 #ifdef __INTEL_COMPILER
89 ** unsigned long to unsigned char
92 unsigned char curlx_ultouc(unsigned long ulnum)
94 #ifdef __INTEL_COMPILER
95 # pragma warning(push)
96 # pragma warning(disable:810) /* conversion may lose significant bits */
99 return (unsigned char)(ulnum & (unsigned long) CURL_MASK_UCHAR);
101 #ifdef __INTEL_COMPILER
102 # pragma warning(pop)
107 ** size_t to signed int
110 int curlx_uztosi(size_t uznum)
112 #ifdef __INTEL_COMPILER
113 # pragma warning(push)
114 # pragma warning(disable:810) /* conversion may lose significant bits */
117 return (int)(uznum & (size_t) CURL_MASK_SINT);
119 #ifdef __INTEL_COMPILER
120 # pragma warning(pop)