2 /* Copyright (C) 2010 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 #include "ares_nowarn.h"
27 # define CARES_MASK_SINT 0x7FFF
28 # define CARES_MASK_UINT 0xFFFF
29 #elif (SIZEOF_INT == 4)
30 # define CARES_MASK_SINT 0x7FFFFFFF
31 # define CARES_MASK_UINT 0xFFFFFFFF
32 #elif (SIZEOF_INT == 8)
33 # define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFF
34 # define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFF
35 #elif (SIZEOF_INT == 16)
36 # define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
37 # define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
41 ** unsigned size_t to signed int
44 int aresx_uztosi(size_t uznum)
46 #ifdef __INTEL_COMPILER
47 # pragma warning(push)
48 # pragma warning(disable:810) /* conversion may lose significant bits */
51 return (int)(uznum & (size_t) CARES_MASK_SINT);
53 #ifdef __INTEL_COMPILER
59 ** signed long to signed int
62 int aresx_sltosi(long slnum)
64 #ifdef __INTEL_COMPILER
65 # pragma warning(push)
66 # pragma warning(disable:810) /* conversion may lose significant bits */
69 DEBUGASSERT(slnum >= 0);
70 return (int)(slnum & (long) CARES_MASK_SINT);
72 #ifdef __INTEL_COMPILER
78 ** signed ssize_t to signed int
81 int aresx_sztosi(ssize_t sznum)
83 #ifdef __INTEL_COMPILER
84 # pragma warning(push)
85 # pragma warning(disable:810) /* conversion may lose significant bits */
88 DEBUGASSERT(sznum >= 0);
89 return (int)(sznum & (ssize_t) CARES_MASK_SINT);
91 #ifdef __INTEL_COMPILER
97 ** signed ssize_t to unsigned int
100 unsigned int aresx_sztoui(ssize_t sznum)
102 #ifdef __INTEL_COMPILER
103 # pragma warning(push)
104 # pragma warning(disable:810) /* conversion may lose significant bits */
107 DEBUGASSERT(sznum >= 0);
108 return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT);
110 #ifdef __INTEL_COMPILER
111 # pragma warning(pop)