fix compiler warning: conversion may lose significant bits
[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 #include "ares_nowarn.h"
21
22 #if (SIZEOF_INT == 2)
23 #  define CARES_MASK_SINT  0x7FFF
24 #  define CARES_MASK_UINT  0xFFFF
25 #elif (SIZEOF_INT == 4)
26 #  define CARES_MASK_SINT  0x7FFFFFFF
27 #  define CARES_MASK_UINT  0xFFFFFFFF
28 #elif (SIZEOF_INT == 8)
29 #  define CARES_MASK_SINT  0x7FFFFFFFFFFFFFFF
30 #  define CARES_MASK_UINT  0xFFFFFFFFFFFFFFFF
31 #elif (SIZEOF_INT == 16)
32 #  define CARES_MASK_SINT  0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
33 #  define CARES_MASK_UINT  0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
34 #endif
35
36 /*
37 ** size_t to signed int
38 */
39
40 int aresx_uztosi(size_t uznum)
41 {
42 #ifdef __INTEL_COMPILER
43 #  pragma warning(push)
44 #  pragma warning(disable:810) /* conversion may lose significant bits */
45 #endif
46
47   return (int)(uznum & (size_t) CARES_MASK_SINT);
48
49 #ifdef __INTEL_COMPILER
50 #  pragma warning(pop)
51 #endif
52 }
53
54 /*
55 ** signed long to signed int
56 */
57
58 int aresx_sltosi(long slnum)
59 {
60 #ifdef __INTEL_COMPILER
61 #  pragma warning(push)
62 #  pragma warning(disable:810) /* conversion may lose significant bits */
63 #endif
64
65   return (int)(slnum & (long) CARES_MASK_SINT);
66
67 #ifdef __INTEL_COMPILER
68 #  pragma warning(pop)
69 #endif
70 }