From b6627e2c19506bd30328969ea8aab73fa0945f36 Mon Sep 17 00:00:00 2001 From: Yu Jiung Date: Wed, 9 Nov 2016 11:15:33 +0900 Subject: Imported Upstream version 1.10.0 Change-Id: Ic7f3b0ad7dca62abe4cfa642a5eb5e190eb7a8c9 --- ares_nowarn.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 106 insertions(+), 4 deletions(-) (limited to 'ares_nowarn.c') diff --git a/ares_nowarn.c b/ares_nowarn.c index 701add5..a4dce89 100644 --- a/ares_nowarn.c +++ b/ares_nowarn.c @@ -1,5 +1,5 @@ -/* Copyright (C) 2010-2011 by Daniel Stenberg +/* Copyright (C) 2010-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -23,9 +23,6 @@ #if defined(__INTEL_COMPILER) && defined(__unix__) -#ifdef HAVE_SYS_SOCKET_H -# include -#endif #ifdef HAVE_NETINET_IN_H # include #endif @@ -39,6 +36,19 @@ #include "ares_nowarn.h" +#if (SIZEOF_SHORT == 2) +# define CARES_MASK_SSHORT 0x7FFF +# define CARES_MASK_USHORT 0xFFFF +#elif (SIZEOF_SHORT == 4) +# define CARES_MASK_SSHORT 0x7FFFFFFF +# define CARES_MASK_USHORT 0xFFFFFFFF +#elif (SIZEOF_SHORT == 8) +# define CARES_MASK_SSHORT 0x7FFFFFFFFFFFFFFF +# define CARES_MASK_USHORT 0xFFFFFFFFFFFFFFFF +#else +# error "SIZEOF_SHORT not defined" +#endif + #if (SIZEOF_INT == 2) # define CARES_MASK_SINT 0x7FFF # define CARES_MASK_UINT 0xFFFF @@ -51,8 +61,44 @@ #elif (SIZEOF_INT == 16) # define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF # define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +#else +# error "SIZEOF_INT not defined" +#endif + +#if (CARES_SIZEOF_LONG == 2) +# define CARES_MASK_SLONG 0x7FFFL +# define CARES_MASK_ULONG 0xFFFFUL +#elif (CARES_SIZEOF_LONG == 4) +# define CARES_MASK_SLONG 0x7FFFFFFFL +# define CARES_MASK_ULONG 0xFFFFFFFFUL +#elif (CARES_SIZEOF_LONG == 8) +# define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFL +# define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL +#elif (CARES_SIZEOF_LONG == 16) +# define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL +# define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL +#else +# error "CARES_SIZEOF_LONG not defined" +#endif + +/* +** unsigned size_t to signed long +*/ + +long aresx_uztosl(size_t uznum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ #endif + return (long)(uznum & (size_t) CARES_MASK_SLONG); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + /* ** unsigned size_t to signed int */ @@ -71,6 +117,43 @@ int aresx_uztosi(size_t uznum) #endif } +/* +** unsigned size_t to signed short +*/ + +short aresx_uztoss(size_t uznum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + return (short)(uznum & (size_t) CARES_MASK_SSHORT); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + +/* +** signed int to signed short +*/ + +short aresx_sitoss(int sinum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + DEBUGASSERT(sinum >= 0); + return (short)(sinum & (int) CARES_MASK_SSHORT); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + /* ** signed long to signed int */ @@ -128,6 +211,25 @@ unsigned int aresx_sztoui(ssize_t sznum) #endif } +/* +** signed int to unsigned short +*/ + +unsigned short aresx_sitous(int sinum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + DEBUGASSERT(sinum >= 0); + return (unsigned short)(sinum & (int) CARES_MASK_USHORT); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + #if defined(__INTEL_COMPILER) && defined(__unix__) int aresx_FD_ISSET(int fd, fd_set *fdset) -- cgit v1.2.3