1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, 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.
21 ***************************************************************************/
25 #define BUILDING_WARNLESS_C 1
29 #define CURL_MASK_SCHAR 0x7F
30 #define CURL_MASK_UCHAR 0xFF
32 #if (SIZEOF_SHORT == 2)
33 # define CURL_MASK_SSHORT 0x7FFF
34 # define CURL_MASK_USHORT 0xFFFF
35 #elif (SIZEOF_SHORT == 4)
36 # define CURL_MASK_SSHORT 0x7FFFFFFF
37 # define CURL_MASK_USHORT 0xFFFFFFFF
38 #elif (SIZEOF_SHORT == 8)
39 # define CURL_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
40 # define CURL_MASK_USHORT 0xFFFFFFFFFFFFFFFF
42 # error "SIZEOF_SHORT not defined"
46 # define CURL_MASK_SINT 0x7FFF
47 # define CURL_MASK_UINT 0xFFFF
48 #elif (SIZEOF_INT == 4)
49 # define CURL_MASK_SINT 0x7FFFFFFF
50 # define CURL_MASK_UINT 0xFFFFFFFF
51 #elif (SIZEOF_INT == 8)
52 # define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFF
53 # define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFF
54 #elif (SIZEOF_INT == 16)
55 # define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
56 # define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
58 # error "SIZEOF_INT not defined"
61 #if (CURL_SIZEOF_LONG == 2)
62 # define CURL_MASK_SLONG 0x7FFFL
63 # define CURL_MASK_ULONG 0xFFFFUL
64 #elif (CURL_SIZEOF_LONG == 4)
65 # define CURL_MASK_SLONG 0x7FFFFFFFL
66 # define CURL_MASK_ULONG 0xFFFFFFFFUL
67 #elif (CURL_SIZEOF_LONG == 8)
68 # define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFL
69 # define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL
70 #elif (CURL_SIZEOF_LONG == 16)
71 # define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
72 # define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
74 # error "CURL_SIZEOF_LONG not defined"
77 #if (CURL_SIZEOF_CURL_OFF_T == 2)
78 # define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFF)
79 # define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFF)
80 #elif (CURL_SIZEOF_CURL_OFF_T == 4)
81 # define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFF)
82 # define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFF)
83 #elif (CURL_SIZEOF_CURL_OFF_T == 8)
84 # define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
85 # define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFF)
86 #elif (CURL_SIZEOF_CURL_OFF_T == 16)
87 # define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
88 # define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
90 # error "CURL_SIZEOF_CURL_OFF_T not defined"
93 #if (SIZEOF_SIZE_T == SIZEOF_SHORT)
94 # define CURL_MASK_SSIZE_T CURL_MASK_SSHORT
95 # define CURL_MASK_USIZE_T CURL_MASK_USHORT
96 #elif (SIZEOF_SIZE_T == SIZEOF_INT)
97 # define CURL_MASK_SSIZE_T CURL_MASK_SINT
98 # define CURL_MASK_USIZE_T CURL_MASK_UINT
99 #elif (SIZEOF_SIZE_T == CURL_SIZEOF_LONG)
100 # define CURL_MASK_SSIZE_T CURL_MASK_SLONG
101 # define CURL_MASK_USIZE_T CURL_MASK_ULONG
102 #elif (SIZEOF_SIZE_T == CURL_SIZEOF_CURL_OFF_T)
103 # define CURL_MASK_SSIZE_T CURL_MASK_SCOFFT
104 # define CURL_MASK_USIZE_T CURL_MASK_UCOFFT
106 # error "SIZEOF_SIZE_T not defined"
110 ** unsigned long to unsigned short
113 unsigned short curlx_ultous(unsigned long ulnum)
115 #ifdef __INTEL_COMPILER
116 # pragma warning(push)
117 # pragma warning(disable:810) /* conversion may lose significant bits */
120 return (unsigned short)(ulnum & (unsigned long) CURL_MASK_USHORT);
122 #ifdef __INTEL_COMPILER
123 # pragma warning(pop)
128 ** unsigned long to unsigned char
131 unsigned char curlx_ultouc(unsigned long ulnum)
133 #ifdef __INTEL_COMPILER
134 # pragma warning(push)
135 # pragma warning(disable:810) /* conversion may lose significant bits */
138 return (unsigned char)(ulnum & (unsigned long) CURL_MASK_UCHAR);
140 #ifdef __INTEL_COMPILER
141 # pragma warning(pop)
146 ** unsigned size_t to signed int
149 int curlx_uztosi(size_t uznum)
151 #ifdef __INTEL_COMPILER
152 # pragma warning(push)
153 # pragma warning(disable:810) /* conversion may lose significant bits */
156 return (int)(uznum & (size_t) CURL_MASK_SINT);
158 #ifdef __INTEL_COMPILER
159 # pragma warning(pop)
164 ** signed long to signed int
167 int curlx_sltosi(long slnum)
169 #ifdef __INTEL_COMPILER
170 # pragma warning(push)
171 # pragma warning(disable:810) /* conversion may lose significant bits */
174 DEBUGASSERT(slnum >= 0);
175 return (int)(slnum & (long) CURL_MASK_SINT);
177 #ifdef __INTEL_COMPILER
178 # pragma warning(pop)
183 ** signed long to unsigned int
186 unsigned int curlx_sltoui(long slnum)
188 #ifdef __INTEL_COMPILER
189 # pragma warning(push)
190 # pragma warning(disable:810) /* conversion may lose significant bits */
193 DEBUGASSERT(slnum >= 0);
194 return (unsigned int)(slnum & (long) CURL_MASK_UINT);
196 #ifdef __INTEL_COMPILER
197 # pragma warning(pop)
202 ** signed long to unsigned short
205 unsigned short curlx_sltous(long slnum)
207 #ifdef __INTEL_COMPILER
208 # pragma warning(push)
209 # pragma warning(disable:810) /* conversion may lose significant bits */
212 DEBUGASSERT(slnum >= 0);
213 return (unsigned short)(slnum & (long) CURL_MASK_USHORT);
215 #ifdef __INTEL_COMPILER
216 # pragma warning(pop)
221 ** unsigned size_t to signed ssize_t
224 ssize_t curlx_uztosz(size_t uznum)
226 #ifdef __INTEL_COMPILER
227 # pragma warning(push)
228 # pragma warning(disable:810) /* conversion may lose significant bits */
231 return (ssize_t)(uznum & (size_t) CURL_MASK_SSIZE_T);
233 #ifdef __INTEL_COMPILER
234 # pragma warning(pop)
239 ** signed curl_off_t to unsigned size_t
242 size_t curlx_sotouz(curl_off_t sonum)
244 #ifdef __INTEL_COMPILER
245 # pragma warning(push)
246 # pragma warning(disable:810) /* conversion may lose significant bits */
249 DEBUGASSERT(sonum >= 0);
250 return (size_t)(sonum & (curl_off_t) CURL_MASK_USIZE_T);
252 #ifdef __INTEL_COMPILER
253 # pragma warning(pop)
257 #if defined(__INTEL_COMPILER) && defined(__unix__)
259 int curlx_FD_ISSET(int fd, fd_set *fdset)
261 #pragma warning(push)
262 #pragma warning(disable:1469) /* clobber ignored */
263 return FD_ISSET(fd, fdset);
267 void curlx_FD_SET(int fd, fd_set *fdset)
269 #pragma warning(push)
270 #pragma warning(disable:1469) /* clobber ignored */
275 void curlx_FD_ZERO(fd_set *fdset)
277 #pragma warning(push)
278 #pragma warning(disable:593) /* variable was set but never used */
283 #endif /* __INTEL_COMPILER && __unix__ */