mirror of https://github.com/getdnsapi/getdns.git
Enable building on Windows with Visual Studio.
The change mostly consists of removing or replacing non-standard (usually POSIX) header includes. Guards for replacements for inet_ntop(), inet_pton() and gettimeofday() are updated; the first two are macros on Windows, so the guards are changed to HAVE_DECL. gettimeofday() is present on MinGW builds but not Visual Studio, so that has a function check.
This commit is contained in:
parent
b8df26194e
commit
5db0d03b13
|
@ -1495,6 +1495,8 @@ dnl ---------------------------------------------------------------------------
|
||||||
|
|
||||||
AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h sys/select.h endian.h limits.h sys/limits.h],,, [AC_INCLUDES_DEFAULT])
|
AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h sys/select.h endian.h limits.h sys/limits.h],,, [AC_INCLUDES_DEFAULT])
|
||||||
|
|
||||||
|
AC_REPLACE_FUNCS(gettimeofday)
|
||||||
|
|
||||||
dnl Check the printf-format attribute (if any)
|
dnl Check the printf-format attribute (if any)
|
||||||
dnl result in HAVE_ATTR_FORMAT.
|
dnl result in HAVE_ATTR_FORMAT.
|
||||||
dnl
|
dnl
|
||||||
|
@ -1729,6 +1731,10 @@ int inet_pton(int af, const char* src, void* dst);
|
||||||
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
|
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETTIMEOFDAY
|
||||||
|
int gettimeofday(struct timeval* tv, void* tz);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
# ifndef _CUSTOM_VSNPRINTF
|
# ifndef _CUSTOM_VSNPRINTF
|
||||||
# define _CUSTOM_VSNPRINTF
|
# define _CUSTOM_VSNPRINTF
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "anchor.h"
|
#include "anchor.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <strings.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "types-internal.h"
|
#include "types-internal.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef GETDNS_ON_WINDOWS
|
#ifndef HAVE_GETTIMEOFDAY
|
||||||
int gettimeofday(struct timeval* tv, struct timezone* tz)
|
|
||||||
|
int gettimeofday(struct timeval* tv, void* tz)
|
||||||
{
|
{
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
uint64_t now = 0;
|
uint64_t now = 0;
|
||||||
|
@ -70,4 +71,4 @@ int gettimeofday(struct timeval* tv, struct timezone* tz)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* GETDNS_ON_WINDOWS */
|
#endif /* HAVE_GETTIMEOFDAY */
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#ifndef HAVE_INET_NTOP
|
#ifndef HAVE_DECL_INET_NTOP
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -215,4 +215,4 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
|
||||||
return (dst);
|
return (dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !HAVE_INET_NTOP */
|
#endif /* !HAVE_DECL_INET_NTOP */
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_DECL_INET_PTON
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -228,3 +230,4 @@ inet_pton6(src, dst)
|
||||||
memcpy(dst, tmp, NS_IN6ADDRSZ);
|
memcpy(dst, tmp, NS_IN6ADDRSZ);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_DECL_INET_PTON */
|
||||||
|
|
|
@ -55,7 +55,6 @@ typedef unsigned short in_port_t;
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,6 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "getdns/getdns.h"
|
#include "getdns/getdns.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
|
|
@ -36,10 +36,14 @@
|
||||||
#define _GETDNS_EXTRA_H_
|
#define _GETDNS_EXTRA_H_
|
||||||
|
|
||||||
#include <getdns/getdns.h>
|
#include <getdns/getdns.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#if defined(_WIN32)
|
||||||
|
/* For struct timeval, see getdns_context_get_num_pending_requests */
|
||||||
|
#include <winsock2.h>
|
||||||
|
#else
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
#ifndef GLDNS_SBUFFER_H
|
#ifndef GLDNS_SBUFFER_H
|
||||||
#define GLDNS_SBUFFER_H
|
#define GLDNS_SBUFFER_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "gldns/gbuffer.h"
|
#include "gldns/gbuffer.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <strings.h>
|
|
||||||
|
|
||||||
gldns_lookup_table gldns_directive_types[] = {
|
gldns_lookup_table gldns_directive_types[] = {
|
||||||
{ GLDNS_DIR_TTL, "$TTL" },
|
{ GLDNS_DIR_TTL, "$TTL" },
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gldns/parseutil.h"
|
#include "gldns/parseutil.h"
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
#ifdef HAVE_TIME_H
|
#ifdef HAVE_TIME_H
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#ifdef HAVE_NETDB_H
|
#ifdef HAVE_NETDB_H
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit dd093e585a237e0321d303ec35e84c393ef739f4
|
Subproject commit ae85ab134df4762d8f6396fee93c04ed1ebdf152
|
|
@ -37,7 +37,6 @@
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <strings.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "types-internal.h"
|
#include "types-internal.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
|
|
@ -49,8 +49,16 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
|
||||||
#include "util/storage/lookup3.h"
|
#include "util/storage/lookup3.h"
|
||||||
#include <stdio.h> /* defines printf for tests */
|
#include <stdio.h> /* defines printf for tests */
|
||||||
#include <time.h> /* defines time_t for timings in the test */
|
#include <time.h> /* defines time_t for timings in the test */
|
||||||
/*#include <stdint.h> defines uint32_t etc (from config.h) */
|
|
||||||
#include <sys/param.h> /* attempt to define endianness */
|
#if defined(HAVE_TARGET_ENDIANNESS)
|
||||||
|
# if defined(TARGET_IS_BIG_ENDIAN)
|
||||||
|
# define HASH_LITTLE_ENDIAN 0
|
||||||
|
# define HASH_BIG_ENDIAN 1
|
||||||
|
# else
|
||||||
|
# define HASH_LITTLE_ENDIAN 1
|
||||||
|
# define HASH_BIG_ENDIAN 0
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
# include <sys/types.h> /* attempt to define endianness (solaris) */
|
# include <sys/types.h> /* attempt to define endianness (solaris) */
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,15 +73,6 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
|
||||||
#include <sys/endian.h> /* attempt to define endianness */
|
#include <sys/endian.h> /* attempt to define endianness */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* random initial value */
|
|
||||||
static uint32_t raninit = (uint32_t)0xdeadbeef;
|
|
||||||
|
|
||||||
void
|
|
||||||
hash_set_raninit(uint32_t v)
|
|
||||||
{
|
|
||||||
raninit = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* My best guess at if you are big-endian or little-endian. This may
|
* My best guess at if you are big-endian or little-endian. This may
|
||||||
* need adjustment.
|
* need adjustment.
|
||||||
|
@ -103,6 +102,16 @@ hash_set_raninit(uint32_t v)
|
||||||
# define HASH_LITTLE_ENDIAN 0
|
# define HASH_LITTLE_ENDIAN 0
|
||||||
# define HASH_BIG_ENDIAN 0
|
# define HASH_BIG_ENDIAN 0
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* defined(TARGET_IS_BIG_ENDIAN) */
|
||||||
|
|
||||||
|
/* random initial value */
|
||||||
|
static uint32_t raninit = (uint32_t)0xdeadbeef;
|
||||||
|
|
||||||
|
void
|
||||||
|
hash_set_raninit(uint32_t v)
|
||||||
|
{
|
||||||
|
raninit = v;
|
||||||
|
}
|
||||||
|
|
||||||
#define hashsize(n) ((uint32_t)1<<(n))
|
#define hashsize(n) ((uint32_t)1<<(n))
|
||||||
#define hashmask(n) (hashsize(n)-1)
|
#define hashmask(n) (hashsize(n)-1)
|
||||||
|
|
|
@ -219,6 +219,7 @@ void* ub_thread_key_get(ub_thread_key_type key);
|
||||||
#else /* we do not HAVE_SOLARIS_THREADS and no PTHREADS */
|
#else /* we do not HAVE_SOLARIS_THREADS and no PTHREADS */
|
||||||
/******************* WINDOWS THREADS ************************/
|
/******************* WINDOWS THREADS ************************/
|
||||||
#ifdef HAVE_WINDOWS_THREADS
|
#ifdef HAVE_WINDOWS_THREADS
|
||||||
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
/* Use a mutex */
|
/* Use a mutex */
|
||||||
|
|
Loading…
Reference in New Issue