warnless.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 
00023 #include "curl_setup.h"
00024 
00025 #if defined(__INTEL_COMPILER) && defined(__unix__)
00026 
00027 #ifdef HAVE_NETINET_IN_H
00028 #  include <netinet/in.h>
00029 #endif
00030 #ifdef HAVE_ARPA_INET_H
00031 #  include <arpa/inet.h>
00032 #endif
00033 
00034 #endif /* __INTEL_COMPILER && __unix__ */
00035 
00036 #define BUILDING_WARNLESS_C 1
00037 
00038 #include "warnless.h"
00039 
00040 #define CURL_MASK_SCHAR  0x7F
00041 #define CURL_MASK_UCHAR  0xFF
00042 
00043 #if (SIZEOF_SHORT == 2)
00044 #  define CURL_MASK_SSHORT  0x7FFF
00045 #  define CURL_MASK_USHORT  0xFFFF
00046 #elif (SIZEOF_SHORT == 4)
00047 #  define CURL_MASK_SSHORT  0x7FFFFFFF
00048 #  define CURL_MASK_USHORT  0xFFFFFFFF
00049 #elif (SIZEOF_SHORT == 8)
00050 #  define CURL_MASK_SSHORT  0x7FFFFFFFFFFFFFFF
00051 #  define CURL_MASK_USHORT  0xFFFFFFFFFFFFFFFF
00052 #else
00053 #  error "SIZEOF_SHORT not defined"
00054 #endif
00055 
00056 #if (SIZEOF_INT == 2)
00057 #  define CURL_MASK_SINT  0x7FFF
00058 #  define CURL_MASK_UINT  0xFFFF
00059 #elif (SIZEOF_INT == 4)
00060 #  define CURL_MASK_SINT  0x7FFFFFFF
00061 #  define CURL_MASK_UINT  0xFFFFFFFF
00062 #elif (SIZEOF_INT == 8)
00063 #  define CURL_MASK_SINT  0x7FFFFFFFFFFFFFFF
00064 #  define CURL_MASK_UINT  0xFFFFFFFFFFFFFFFF
00065 #elif (SIZEOF_INT == 16)
00066 #  define CURL_MASK_SINT  0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
00067 #  define CURL_MASK_UINT  0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
00068 #else
00069 #  error "SIZEOF_INT not defined"
00070 #endif
00071 
00072 #if (CURL_SIZEOF_LONG == 2)
00073 #  define CURL_MASK_SLONG  0x7FFFL
00074 #  define CURL_MASK_ULONG  0xFFFFUL
00075 #elif (CURL_SIZEOF_LONG == 4)
00076 #  define CURL_MASK_SLONG  0x7FFFFFFFL
00077 #  define CURL_MASK_ULONG  0xFFFFFFFFUL
00078 #elif (CURL_SIZEOF_LONG == 8)
00079 #  define CURL_MASK_SLONG  0x7FFFFFFFFFFFFFFFL
00080 #  define CURL_MASK_ULONG  0xFFFFFFFFFFFFFFFFUL
00081 #elif (CURL_SIZEOF_LONG == 16)
00082 #  define CURL_MASK_SLONG  0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
00083 #  define CURL_MASK_ULONG  0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
00084 #else
00085 #  error "CURL_SIZEOF_LONG not defined"
00086 #endif
00087 
00088 #if (CURL_SIZEOF_CURL_OFF_T == 2)
00089 #  define CURL_MASK_SCOFFT  CURL_OFF_T_C(0x7FFF)
00090 #  define CURL_MASK_UCOFFT  CURL_OFF_TU_C(0xFFFF)
00091 #elif (CURL_SIZEOF_CURL_OFF_T == 4)
00092 #  define CURL_MASK_SCOFFT  CURL_OFF_T_C(0x7FFFFFFF)
00093 #  define CURL_MASK_UCOFFT  CURL_OFF_TU_C(0xFFFFFFFF)
00094 #elif (CURL_SIZEOF_CURL_OFF_T == 8)
00095 #  define CURL_MASK_SCOFFT  CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
00096 #  define CURL_MASK_UCOFFT  CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFF)
00097 #elif (CURL_SIZEOF_CURL_OFF_T == 16)
00098 #  define CURL_MASK_SCOFFT  CURL_OFF_T_C(0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
00099 #  define CURL_MASK_UCOFFT  CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
00100 #else
00101 #  error "CURL_SIZEOF_CURL_OFF_T not defined"
00102 #endif
00103 
00104 #if (SIZEOF_SIZE_T == SIZEOF_SHORT)
00105 #  define CURL_MASK_SSIZE_T  CURL_MASK_SSHORT
00106 #  define CURL_MASK_USIZE_T  CURL_MASK_USHORT
00107 #elif (SIZEOF_SIZE_T == SIZEOF_INT)
00108 #  define CURL_MASK_SSIZE_T  CURL_MASK_SINT
00109 #  define CURL_MASK_USIZE_T  CURL_MASK_UINT
00110 #elif (SIZEOF_SIZE_T == CURL_SIZEOF_LONG)
00111 #  define CURL_MASK_SSIZE_T  CURL_MASK_SLONG
00112 #  define CURL_MASK_USIZE_T  CURL_MASK_ULONG
00113 #elif (SIZEOF_SIZE_T == CURL_SIZEOF_CURL_OFF_T)
00114 #  define CURL_MASK_SSIZE_T  CURL_MASK_SCOFFT
00115 #  define CURL_MASK_USIZE_T  CURL_MASK_UCOFFT
00116 #else
00117 #  error "SIZEOF_SIZE_T not defined"
00118 #endif
00119 
00120 /*
00121 ** unsigned long to unsigned short
00122 */
00123 
00124 unsigned short curlx_ultous(unsigned long ulnum)
00125 {
00126 #ifdef __INTEL_COMPILER
00127 #  pragma warning(push)
00128 #  pragma warning(disable:810) /* conversion may lose significant bits */
00129 #endif
00130 
00131   DEBUGASSERT(ulnum <= (unsigned long) CURL_MASK_USHORT);
00132   return (unsigned short)(ulnum & (unsigned long) CURL_MASK_USHORT);
00133 
00134 #ifdef __INTEL_COMPILER
00135 #  pragma warning(pop)
00136 #endif
00137 }
00138 
00139 /*
00140 ** unsigned long to unsigned char
00141 */
00142 
00143 unsigned char curlx_ultouc(unsigned long ulnum)
00144 {
00145 #ifdef __INTEL_COMPILER
00146 #  pragma warning(push)
00147 #  pragma warning(disable:810) /* conversion may lose significant bits */
00148 #endif
00149 
00150   DEBUGASSERT(ulnum <= (unsigned long) CURL_MASK_UCHAR);
00151   return (unsigned char)(ulnum & (unsigned long) CURL_MASK_UCHAR);
00152 
00153 #ifdef __INTEL_COMPILER
00154 #  pragma warning(pop)
00155 #endif
00156 }
00157 
00158 /*
00159 ** unsigned long to signed int
00160 */
00161 
00162 int curlx_ultosi(unsigned long ulnum)
00163 {
00164 #ifdef __INTEL_COMPILER
00165 #  pragma warning(push)
00166 #  pragma warning(disable:810) /* conversion may lose significant bits */
00167 #endif
00168 
00169   DEBUGASSERT(ulnum <= (unsigned long) CURL_MASK_SINT);
00170   return (int)(ulnum & (unsigned long) CURL_MASK_SINT);
00171 
00172 #ifdef __INTEL_COMPILER
00173 #  pragma warning(pop)
00174 #endif
00175 }
00176 
00177 /*
00178 ** unsigned size_t to signed curl_off_t
00179 */
00180 
00181 curl_off_t curlx_uztoso(size_t uznum)
00182 {
00183 #ifdef __INTEL_COMPILER
00184 #  pragma warning(push)
00185 #  pragma warning(disable:810) /* conversion may lose significant bits */
00186 #endif
00187 
00188   DEBUGASSERT(uznum <= (size_t) CURL_MASK_SCOFFT);
00189   return (curl_off_t)(uznum & (size_t) CURL_MASK_SCOFFT);
00190 
00191 #ifdef __INTEL_COMPILER
00192 #  pragma warning(pop)
00193 #endif
00194 }
00195 
00196 /*
00197 ** unsigned size_t to signed int
00198 */
00199 
00200 int curlx_uztosi(size_t uznum)
00201 {
00202 #ifdef __INTEL_COMPILER
00203 #  pragma warning(push)
00204 #  pragma warning(disable:810) /* conversion may lose significant bits */
00205 #endif
00206 
00207   DEBUGASSERT(uznum <= (size_t) CURL_MASK_SINT);
00208   return (int)(uznum & (size_t) CURL_MASK_SINT);
00209 
00210 #ifdef __INTEL_COMPILER
00211 #  pragma warning(pop)
00212 #endif
00213 }
00214 
00215 /*
00216 ** unsigned size_t to unsigned long
00217 */
00218 
00219 unsigned long curlx_uztoul(size_t uznum)
00220 {
00221 #ifdef __INTEL_COMPILER
00222 # pragma warning(push)
00223 # pragma warning(disable:810) /* conversion may lose significant bits */
00224 #endif
00225 
00226 #if (CURL_SIZEOF_LONG < SIZEOF_SIZE_T)
00227   DEBUGASSERT(uznum <= (size_t) CURL_MASK_ULONG);
00228 #endif
00229   return (unsigned long)(uznum & (size_t) CURL_MASK_ULONG);
00230 
00231 #ifdef __INTEL_COMPILER
00232 # pragma warning(pop)
00233 #endif
00234 }
00235 
00236 /*
00237 ** unsigned size_t to unsigned int
00238 */
00239 
00240 unsigned int curlx_uztoui(size_t uznum)
00241 {
00242 #ifdef __INTEL_COMPILER
00243 # pragma warning(push)
00244 # pragma warning(disable:810) /* conversion may lose significant bits */
00245 #endif
00246 
00247 #if (SIZEOF_INT < SIZEOF_SIZE_T)
00248   DEBUGASSERT(uznum <= (size_t) CURL_MASK_UINT);
00249 #endif
00250   return (unsigned int)(uznum & (size_t) CURL_MASK_UINT);
00251 
00252 #ifdef __INTEL_COMPILER
00253 # pragma warning(pop)
00254 #endif
00255 }
00256 
00257 /*
00258 ** signed long to signed int
00259 */
00260 
00261 int curlx_sltosi(long slnum)
00262 {
00263 #ifdef __INTEL_COMPILER
00264 #  pragma warning(push)
00265 #  pragma warning(disable:810) /* conversion may lose significant bits */
00266 #endif
00267 
00268   DEBUGASSERT(slnum >= 0);
00269 #if (SIZEOF_INT < CURL_SIZEOF_LONG)
00270   DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_SINT);
00271 #endif
00272   return (int)(slnum & (long) CURL_MASK_SINT);
00273 
00274 #ifdef __INTEL_COMPILER
00275 #  pragma warning(pop)
00276 #endif
00277 }
00278 
00279 /*
00280 ** signed long to unsigned int
00281 */
00282 
00283 unsigned int curlx_sltoui(long slnum)
00284 {
00285 #ifdef __INTEL_COMPILER
00286 #  pragma warning(push)
00287 #  pragma warning(disable:810) /* conversion may lose significant bits */
00288 #endif
00289 
00290   DEBUGASSERT(slnum >= 0);
00291 #if (SIZEOF_INT < CURL_SIZEOF_LONG)
00292   DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_UINT);
00293 #endif
00294   return (unsigned int)(slnum & (long) CURL_MASK_UINT);
00295 
00296 #ifdef __INTEL_COMPILER
00297 #  pragma warning(pop)
00298 #endif
00299 }
00300 
00301 /*
00302 ** signed long to unsigned short
00303 */
00304 
00305 unsigned short curlx_sltous(long slnum)
00306 {
00307 #ifdef __INTEL_COMPILER
00308 #  pragma warning(push)
00309 #  pragma warning(disable:810) /* conversion may lose significant bits */
00310 #endif
00311 
00312   DEBUGASSERT(slnum >= 0);
00313   DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_USHORT);
00314   return (unsigned short)(slnum & (long) CURL_MASK_USHORT);
00315 
00316 #ifdef __INTEL_COMPILER
00317 #  pragma warning(pop)
00318 #endif
00319 }
00320 
00321 /*
00322 ** unsigned size_t to signed ssize_t
00323 */
00324 
00325 ssize_t curlx_uztosz(size_t uznum)
00326 {
00327 #ifdef __INTEL_COMPILER
00328 #  pragma warning(push)
00329 #  pragma warning(disable:810) /* conversion may lose significant bits */
00330 #endif
00331 
00332   DEBUGASSERT(uznum <= (size_t) CURL_MASK_SSIZE_T);
00333   return (ssize_t)(uznum & (size_t) CURL_MASK_SSIZE_T);
00334 
00335 #ifdef __INTEL_COMPILER
00336 #  pragma warning(pop)
00337 #endif
00338 }
00339 
00340 /*
00341 ** signed curl_off_t to unsigned size_t
00342 */
00343 
00344 size_t curlx_sotouz(curl_off_t sonum)
00345 {
00346 #ifdef __INTEL_COMPILER
00347 #  pragma warning(push)
00348 #  pragma warning(disable:810) /* conversion may lose significant bits */
00349 #endif
00350 
00351   DEBUGASSERT(sonum >= 0);
00352   return (size_t)(sonum & (curl_off_t) CURL_MASK_USIZE_T);
00353 
00354 #ifdef __INTEL_COMPILER
00355 #  pragma warning(pop)
00356 #endif
00357 }
00358 
00359 /*
00360 ** signed ssize_t to signed int
00361 */
00362 
00363 int curlx_sztosi(ssize_t sznum)
00364 {
00365 #ifdef __INTEL_COMPILER
00366 #  pragma warning(push)
00367 #  pragma warning(disable:810) /* conversion may lose significant bits */
00368 #endif
00369 
00370   DEBUGASSERT(sznum >= 0);
00371 #if (SIZEOF_INT < SIZEOF_SIZE_T)
00372   DEBUGASSERT((size_t) sznum <= (size_t) CURL_MASK_SINT);
00373 #endif
00374   return (int)(sznum & (ssize_t) CURL_MASK_SINT);
00375 
00376 #ifdef __INTEL_COMPILER
00377 #  pragma warning(pop)
00378 #endif
00379 }
00380 
00381 /*
00382 ** unsigned int to unsigned short
00383 */
00384 
00385 unsigned short curlx_uitous(unsigned int uinum)
00386 {
00387 #ifdef __INTEL_COMPILER
00388 #  pragma warning(push)
00389 #  pragma warning(disable:810) /* conversion may lose significant bits */
00390 #endif
00391 
00392   DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_USHORT);
00393   return (unsigned short) (uinum & (unsigned int) CURL_MASK_USHORT);
00394 
00395 #ifdef __INTEL_COMPILER
00396 #  pragma warning(pop)
00397 #endif
00398 }
00399 
00400 /*
00401 ** unsigned int to unsigned char
00402 */
00403 
00404 unsigned char curlx_uitouc(unsigned int uinum)
00405 {
00406 #ifdef __INTEL_COMPILER
00407 #  pragma warning(push)
00408 #  pragma warning(disable:810) /* conversion may lose significant bits */
00409 #endif
00410 
00411   DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_UCHAR);
00412   return (unsigned char) (uinum & (unsigned int) CURL_MASK_UCHAR);
00413 
00414 #ifdef __INTEL_COMPILER
00415 #  pragma warning(pop)
00416 #endif
00417 }
00418 
00419 /*
00420 ** unsigned int to signed int
00421 */
00422 
00423 int curlx_uitosi(unsigned int uinum)
00424 {
00425 #ifdef __INTEL_COMPILER
00426 #  pragma warning(push)
00427 #  pragma warning(disable:810) /* conversion may lose significant bits */
00428 #endif
00429 
00430   DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_SINT);
00431   return (int) (uinum & (unsigned int) CURL_MASK_SINT);
00432 
00433 #ifdef __INTEL_COMPILER
00434 #  pragma warning(pop)
00435 #endif
00436 }
00437 
00438 /*
00439 ** signed int to unsigned size_t
00440 */
00441 
00442 size_t curlx_sitouz(int sinum)
00443 {
00444 #ifdef __INTEL_COMPILER
00445 #  pragma warning(push)
00446 #  pragma warning(disable:810) /* conversion may lose significant bits */
00447 #endif
00448 
00449   DEBUGASSERT(sinum >= 0);
00450   return (size_t) sinum;
00451 
00452 #ifdef __INTEL_COMPILER
00453 #  pragma warning(pop)
00454 #endif
00455 }
00456 
00457 #ifdef USE_WINSOCK
00458 
00459 /*
00460 ** curl_socket_t to signed int
00461 */
00462 
00463 int curlx_sktosi(curl_socket_t s)
00464 {
00465   return (int)((ssize_t) s);
00466 }
00467 
00468 /*
00469 ** signed int to curl_socket_t
00470 */
00471 
00472 curl_socket_t curlx_sitosk(int i)
00473 {
00474   return (curl_socket_t)((ssize_t) i);
00475 }
00476 
00477 #endif /* USE_WINSOCK */
00478 
00479 #if defined(WIN32) || defined(_WIN32)
00480 
00481 ssize_t curlx_read(int fd, void *buf, size_t count)
00482 {
00483   return (ssize_t)read(fd, buf, curlx_uztoui(count));
00484 }
00485 
00486 ssize_t curlx_write(int fd, const void *buf, size_t count)
00487 {
00488   return (ssize_t)write(fd, buf, curlx_uztoui(count));
00489 }
00490 
00491 #endif /* WIN32 || _WIN32 */
00492 
00493 #if defined(__INTEL_COMPILER) && defined(__unix__)
00494 
00495 int curlx_FD_ISSET(int fd, fd_set *fdset)
00496 {
00497   #pragma warning(push)
00498   #pragma warning(disable:1469) /* clobber ignored */
00499   return FD_ISSET(fd, fdset);
00500   #pragma warning(pop)
00501 }
00502 
00503 void curlx_FD_SET(int fd, fd_set *fdset)
00504 {
00505   #pragma warning(push)
00506   #pragma warning(disable:1469) /* clobber ignored */
00507   FD_SET(fd, fdset);
00508   #pragma warning(pop)
00509 }
00510 
00511 void curlx_FD_ZERO(fd_set *fdset)
00512 {
00513   #pragma warning(push)
00514   #pragma warning(disable:593) /* variable was set but never used */
00515   FD_ZERO(fdset);
00516   #pragma warning(pop)
00517 }
00518 
00519 unsigned short curlx_htons(unsigned short usnum)
00520 {
00521 #if (__INTEL_COMPILER == 910) && defined(__i386__)
00522   return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
00523 #else
00524   #pragma warning(push)
00525   #pragma warning(disable:810) /* conversion may lose significant bits */
00526   return htons(usnum);
00527   #pragma warning(pop)
00528 #endif
00529 }
00530 
00531 unsigned short curlx_ntohs(unsigned short usnum)
00532 {
00533 #if (__INTEL_COMPILER == 910) && defined(__i386__)
00534   return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
00535 #else
00536   #pragma warning(push)
00537   #pragma warning(disable:810) /* conversion may lose significant bits */
00538   return ntohs(usnum);
00539   #pragma warning(pop)
00540 #endif
00541 }
00542 
00543 #endif /* __INTEL_COMPILER && __unix__ */


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:07