compiler warning: fix
[platform/upstream/c-ares.git] / ares_nowarn.c
1
2 /* Copyright (C) 2010 by Daniel Stenberg
3  *
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.
15  */
16
17
18 #include "ares_setup.h"
19
20 #ifdef HAVE_ASSERT_H
21 #  include <assert.h>
22 #endif
23
24 #define BUILDING_ARES_NOWARN_C 1
25
26 #include "ares_nowarn.h"
27
28 #if (SIZEOF_INT == 2)
29 #  define CARES_MASK_SINT  0x7FFF
30 #  define CARES_MASK_UINT  0xFFFF
31 #elif (SIZEOF_INT == 4)
32 #  define CARES_MASK_SINT  0x7FFFFFFF
33 #  define CARES_MASK_UINT  0xFFFFFFFF
34 #elif (SIZEOF_INT == 8)
35 #  define CARES_MASK_SINT  0x7FFFFFFFFFFFFFFF
36 #  define CARES_MASK_UINT  0xFFFFFFFFFFFFFFFF
37 #elif (SIZEOF_INT == 16)
38 #  define CARES_MASK_SINT  0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
39 #  define CARES_MASK_UINT  0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
40 #endif
41
42 /*
43 ** unsigned size_t to signed int
44 */
45
46 int aresx_uztosi(size_t uznum)
47 {
48 #ifdef __INTEL_COMPILER
49 #  pragma warning(push)
50 #  pragma warning(disable:810) /* conversion may lose significant bits */
51 #endif
52
53   return (int)(uznum & (size_t) CARES_MASK_SINT);
54
55 #ifdef __INTEL_COMPILER
56 #  pragma warning(pop)
57 #endif
58 }
59
60 /*
61 ** signed long to signed int
62 */
63
64 int aresx_sltosi(long slnum)
65 {
66 #ifdef __INTEL_COMPILER
67 #  pragma warning(push)
68 #  pragma warning(disable:810) /* conversion may lose significant bits */
69 #endif
70
71   DEBUGASSERT(slnum >= 0);
72   return (int)(slnum & (long) CARES_MASK_SINT);
73
74 #ifdef __INTEL_COMPILER
75 #  pragma warning(pop)
76 #endif
77 }
78
79 /*
80 ** signed ssize_t to signed int
81 */
82
83 int aresx_sztosi(ssize_t sznum)
84 {
85 #ifdef __INTEL_COMPILER
86 #  pragma warning(push)
87 #  pragma warning(disable:810) /* conversion may lose significant bits */
88 #endif
89
90   DEBUGASSERT(sznum >= 0);
91   return (int)(sznum & (ssize_t) CARES_MASK_SINT);
92
93 #ifdef __INTEL_COMPILER
94 #  pragma warning(pop)
95 #endif
96 }
97
98 /*
99 ** signed ssize_t to unsigned int
100 */
101
102 unsigned int aresx_sztoui(ssize_t sznum)
103 {
104 #ifdef __INTEL_COMPILER
105 #  pragma warning(push)
106 #  pragma warning(disable:810) /* conversion may lose significant bits */
107 #endif
108
109   DEBUGASSERT(sznum >= 0);
110   return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT);
111
112 #ifdef __INTEL_COMPILER
113 #  pragma warning(pop)
114 #endif
115 }
116
117 #if defined(__INTEL_COMPILER) && defined(__unix__)
118
119 int aresx_FD_ISSET(int fd, fd_set *fdset)
120 {
121   #pragma warning(push)
122   #pragma warning(disable:1469) /* clobber ignored */
123   return FD_ISSET(fd, fdset);
124   #pragma warning(pop)
125 }
126
127 void aresx_FD_SET(int fd, fd_set *fdset)
128 {
129   #pragma warning(push)
130   #pragma warning(disable:1469) /* clobber ignored */
131   FD_SET(fd, fdset);
132   #pragma warning(pop)
133 }
134
135 void aresx_FD_ZERO(fd_set *fdset)
136 {
137   #pragma warning(push)
138   #pragma warning(disable:593) /* variable was set but never used */
139   FD_ZERO(fdset);
140   #pragma warning(pop)
141 }
142
143 #endif /* __INTEL_COMPILER && __unix__ */