2 /* Copyright (C) 2010-2011 by Daniel Stenberg
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of M.I.T. not be used in
10 * advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission.
12 * M.I.T. makes no representations about the suitability of
13 * this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
18 #include "ares_setup.h"
24 #if defined(__INTEL_COMPILER) && defined(__unix__)
26 #ifdef HAVE_SYS_SOCKET_H
27 # include <sys/socket.h>
29 #ifdef HAVE_NETINET_IN_H
30 # include <netinet/in.h>
32 #ifdef HAVE_ARPA_INET_H
33 # include <arpa/inet.h>
36 #endif /* __INTEL_COMPILER && __unix__ */
38 #define BUILDING_ARES_NOWARN_C 1
40 #include "ares_nowarn.h"
43 # define CARES_MASK_SINT 0x7FFF
44 # define CARES_MASK_UINT 0xFFFF
45 #elif (SIZEOF_INT == 4)
46 # define CARES_MASK_SINT 0x7FFFFFFF
47 # define CARES_MASK_UINT 0xFFFFFFFF
48 #elif (SIZEOF_INT == 8)
49 # define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFF
50 # define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFF
51 #elif (SIZEOF_INT == 16)
52 # define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
53 # define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
57 ** unsigned size_t to signed int
60 int aresx_uztosi(size_t uznum)
62 #ifdef __INTEL_COMPILER
63 # pragma warning(push)
64 # pragma warning(disable:810) /* conversion may lose significant bits */
67 return (int)(uznum & (size_t) CARES_MASK_SINT);
69 #ifdef __INTEL_COMPILER
75 ** signed long to signed int
78 int aresx_sltosi(long slnum)
80 #ifdef __INTEL_COMPILER
81 # pragma warning(push)
82 # pragma warning(disable:810) /* conversion may lose significant bits */
85 DEBUGASSERT(slnum >= 0);
86 return (int)(slnum & (long) CARES_MASK_SINT);
88 #ifdef __INTEL_COMPILER
94 ** signed ssize_t to signed int
97 int aresx_sztosi(ssize_t sznum)
99 #ifdef __INTEL_COMPILER
100 # pragma warning(push)
101 # pragma warning(disable:810) /* conversion may lose significant bits */
104 DEBUGASSERT(sznum >= 0);
105 return (int)(sznum & (ssize_t) CARES_MASK_SINT);
107 #ifdef __INTEL_COMPILER
108 # pragma warning(pop)
113 ** signed ssize_t to unsigned int
116 unsigned int aresx_sztoui(ssize_t sznum)
118 #ifdef __INTEL_COMPILER
119 # pragma warning(push)
120 # pragma warning(disable:810) /* conversion may lose significant bits */
123 DEBUGASSERT(sznum >= 0);
124 return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT);
126 #ifdef __INTEL_COMPILER
127 # pragma warning(pop)
131 #if defined(__INTEL_COMPILER) && defined(__unix__)
133 int aresx_FD_ISSET(int fd, fd_set *fdset)
135 #pragma warning(push)
136 #pragma warning(disable:1469) /* clobber ignored */
137 return FD_ISSET(fd, fdset);
141 void aresx_FD_SET(int fd, fd_set *fdset)
143 #pragma warning(push)
144 #pragma warning(disable:1469) /* clobber ignored */
149 void aresx_FD_ZERO(fd_set *fdset)
151 #pragma warning(push)
152 #pragma warning(disable:593) /* variable was set but never used */
157 unsigned short aresx_htons(unsigned short usnum)
159 #pragma warning(push)
160 #pragma warning(disable:810) /* conversion may lose significant bits */
165 unsigned short aresx_ntohs(unsigned short usnum)
167 #pragma warning(push)
168 #pragma warning(disable:810) /* conversion may lose significant bits */
173 #endif /* __INTEL_COMPILER && __unix__ */