summaryrefslogtreecommitdiff
path: root/deps/cares/src/ares_nowarn.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/cares/src/ares_nowarn.c')
-rw-r--r--deps/cares/src/ares_nowarn.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/deps/cares/src/ares_nowarn.c b/deps/cares/src/ares_nowarn.c
index 397e70b018..d4bd272c6d 100644
--- a/deps/cares/src/ares_nowarn.c
+++ b/deps/cares/src/ares_nowarn.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 2010-2012 by Daniel Stenberg
+/* Copyright (C) 2010-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -21,6 +21,10 @@
# include <assert.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
#if defined(__INTEL_COMPILER) && defined(__unix__)
#ifdef HAVE_NETINET_IN_H
@@ -36,13 +40,43 @@
#include "ares_nowarn.h"
-#define CARES_MASK_USHORT (~(unsigned short) 0)
-#define CARES_MASK_UINT (~(unsigned int) 0)
-#define CARES_MASK_ULONG (~(unsigned long) 0)
+#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
-#define CARES_MASK_SSHORT (CARES_MASK_USHORT >> 1)
-#define CARES_MASK_SINT (CARES_MASK_UINT >> 1)
-#define CARES_MASK_SLONG (CARES_MASK_ULONG >> 1)
+#if (SIZEOF_INT == 2)
+# define CARES_MASK_SINT 0x7FFF
+# define CARES_MASK_UINT 0xFFFF
+#elif (SIZEOF_INT == 4)
+# define CARES_MASK_SINT 0x7FFFFFFF
+# define CARES_MASK_UINT 0xFFFFFFFF
+#elif (SIZEOF_INT == 8)
+# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFF
+# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFF
+#elif (SIZEOF_INT == 16)
+# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+#else
+# error "SIZEOF_INT not defined"
+#endif
+
+#ifndef HAVE_LIMITS_H
+/* systems without <limits.h> we guess have 32 bit longs */
+#define CARES_MASK_SLONG 0x7FFFFFFFL
+#define CARES_MASK_ULONG 0xFFFFFFFFUL
+#else
+#define CARES_MASK_ULONG ULONG_MAX
+#define CARES_MASK_SLONG LONG_MAX
+#endif
/*
** unsigned size_t to signed long