Permalink
Browse files

c-ares: libuv-ify c-ares

  • Loading branch information...
1 parent 3e425ab commit 15cfcfd309526cb687c677124f33dea6e4d14cb9 @bnoordhuis bnoordhuis committed with piscisaureus Apr 25, 2012
Showing with 62 additions and 46 deletions.
  1. +1 −1 Makefile
  2. +50 −2 include/ares.h
  3. +6 −43 src/ares/ares_nowarn.c
  4. +4 −0 src/ares/ares_setup.h
  5. +1 −0 uv.gyp
View
@@ -24,7 +24,7 @@ ifdef MSVC
uname_S := MINGW
endif
-CPPFLAGS += -Iinclude -Iinclude/uv-private
+CPPFLAGS += -Iinclude -Iinclude/uv-private -Isrc/ares
CARES_OBJS =
CARES_OBJS += src/ares/ares__close_sockets.o
View
@@ -19,8 +19,6 @@
#define ARES__H
#include "ares_version.h" /* c-ares version defines */
-#include "ares_build.h" /* c-ares build definitions */
-#include "ares_rules.h" /* c-ares rules enforcement */
/*
* Define WIN32 when build target is Win32 API
@@ -31,6 +29,56 @@
# define WIN32
#endif
+/*************************** libuv patch ***************/
+
+/*
+ * We want to avoid autoconf altogether since there are a finite number of
+ * operating systems and simply build c-ares. Therefore we do not want the
+ * configurations provided by ares_build.h since we are always statically
+ * linking c-ares into libuv. Having a system dependent ares_build.h forces
+ * all users of ares.h to include the correct ares_build.h. We do not care
+ * about the linking checks provided by ares_rules.h. This would complicate
+ * the libuv build process.
+ */
+
+
+#if defined(WIN32)
+/* Configure process defines this to 1 when it finds out that system */
+/* header file ws2tcpip.h must be included by the external interface. */
+/* #undef CARES_PULL_WS2TCPIP_H */
+# include <winsock2.h>
+# include <ws2tcpip.h>
+# include <windows.h>
+
+#else /* Not Windows */
+
+# include <sys/time.h>
+# include <sys/types.h>
+# include <sys/socket.h>
+#endif
+
+#if 0
+/* The size of `long', as computed by sizeof. */
+#define CARES_SIZEOF_LONG 4
+#endif
+
+/* Integral data type used for ares_socklen_t. */
+#define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
+
+#if 0
+/* The size of `ares_socklen_t', as computed by sizeof. */
+#define CARES_SIZEOF_ARES_SOCKLEN_T 4
+#endif
+
+/* Data type definition of ares_socklen_t. */
+typedef int ares_socklen_t;
+
+#if 0 /* libuv disabled */
+#include "ares_rules.h" /* c-ares rules enforcement */
+#endif
+
+/*********************** end libuv patch ***************/
+
#include <sys/types.h>
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
@@ -39,50 +39,13 @@
#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
+#define CARES_MASK_USHORT (~(unsigned short) 0)
+#define CARES_MASK_UINT (~(unsigned int) 0)
+#define CARES_MASK_ULONG (~(unsigned long) 0)
-#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
-
-#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
+#define CARES_MASK_SSHORT (CARES_MASK_USHORT >> 1)
+#define CARES_MASK_SINT (CARES_MASK_UINT >> 1)
+#define CARES_MASK_SLONG (CARES_MASK_ULONG >> 1)
/*
** unsigned size_t to signed long
@@ -75,6 +75,9 @@
/* please, do it beyond the point further indicated in this file. */
/* ================================================================ */
+#if 1 /* libuv hack */
+#include <errno.h> /* needed on windows */
+#else
/*
* c-ares external interface definitions are also used internally,
* and might also include required system header files to define them.
@@ -87,6 +90,7 @@
*/
#include <ares_rules.h>
+#endif /* libuv hack */
/* ================================================================= */
/* No system header file shall be included in this file before this */
View
@@ -29,6 +29,7 @@
'include',
'include/uv-private',
'src/',
+ 'src/ares',
],
'direct_dependent_settings': {
'include_dirs': [ 'include' ],

0 comments on commit 15cfcfd

Please sign in to comment.