diff --git a/Makefile b/Makefile index 3b6e3f00..e79b7a0c 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/include/ares.h b/include/ares.h index c5e40695..96eccabd 100644 --- a/include/ares.h +++ b/include/ares.h @@ -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 +# include +# include + +#else /* Not Windows */ + +# include +# include +# include +#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 /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish diff --git a/src/ares/ares_nowarn.c b/src/ares/ares_nowarn.c index dc33bcff..e29efd33 100644 --- a/src/ares/ares_nowarn.c +++ b/src/ares/ares_nowarn.c @@ -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 diff --git a/src/ares/ares_setup.h b/src/ares/ares_setup.h index 4df79611..18e14557 100644 --- a/src/ares/ares_setup.h +++ b/src/ares/ares_setup.h @@ -75,6 +75,9 @@ /* please, do it beyond the point further indicated in this file. */ /* ================================================================ */ +#if 1 /* libuv hack */ +#include /* 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 +#endif /* libuv hack */ /* ================================================================= */ /* No system header file shall be included in this file before this */ diff --git a/uv.gyp b/uv.gyp index 10b5c5eb..c14df2cc 100644 --- a/uv.gyp +++ b/uv.gyp @@ -29,6 +29,7 @@ 'include', 'include/uv-private', 'src/', + 'src/ares', ], 'direct_dependent_settings': { 'include_dirs': [ 'include' ],