Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
c-ares: libuv-ify c-ares
  • Loading branch information
bnoordhuis authored and piscisaureus committed Jun 29, 2012
1 parent 3e425ab commit 15cfcfd
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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
Expand Down
52 changes: 50 additions & 2 deletions include/ares.h
Expand Up @@ -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
Expand All @@ -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
Expand Down
49 changes: 6 additions & 43 deletions src/ares/ares_nowarn.c
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/ares/ares_setup.h
Expand Up @@ -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.
Expand All @@ -87,6 +90,7 @@
*/

#include <ares_rules.h>
#endif /* libuv hack */

/* ================================================================= */
/* No system header file shall be included in this file before this */
Expand Down
1 change: 1 addition & 0 deletions uv.gyp
Expand Up @@ -29,6 +29,7 @@
'include',
'include/uv-private',
'src/',
'src/ares',
],
'direct_dependent_settings': {
'include_dirs': [ 'include' ],
Expand Down

0 comments on commit 15cfcfd

Please sign in to comment.