mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 14:53:15 -05:00
mingw32 porting.
git-svn-id: file:///svn/unbound/trunk@1118 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
092a325270
commit
afda1a8bcc
10 changed files with 5007 additions and 6236 deletions
44
config.h.in
44
config.h.in
|
|
@ -124,6 +124,9 @@
|
|||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#undef HAVE_PWD_H
|
||||
|
||||
/* Define to 1 if you have the `random' function. */
|
||||
#undef HAVE_RANDOM
|
||||
|
||||
/* Define to 1 if you have the `sbrk' function. */
|
||||
#undef HAVE_SBRK
|
||||
|
||||
|
|
@ -133,12 +136,18 @@
|
|||
/* Define to 1 if you have the `sigprocmask' function. */
|
||||
#undef HAVE_SIGPROCMASK
|
||||
|
||||
/* Define to 1 if you have the `sleep' function. */
|
||||
#undef HAVE_SLEEP
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Using Solaris threads */
|
||||
#undef HAVE_SOLARIS_THREADS
|
||||
|
||||
/* Define to 1 if you have the `srandom' function. */
|
||||
#undef HAVE_SRANDOM
|
||||
|
||||
/* Define if you have the SSL libraries installed. */
|
||||
#undef HAVE_SSL
|
||||
|
||||
|
|
@ -196,6 +205,9 @@
|
|||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `usleep' function. */
|
||||
#undef HAVE_USLEEP
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
|
|
@ -217,6 +229,9 @@
|
|||
/* Define to the maximum message length to pass to syslog. */
|
||||
#undef MAXSYSLOGMSGLEN
|
||||
|
||||
/* Define if mkdir has one argument. */
|
||||
#undef MKDIR_HAS_ONE_ARG
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
|
|
@ -292,11 +307,9 @@
|
|||
/* in_port_t */
|
||||
#undef in_port_t
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
|
||||
if it is not supported. */
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to `short' if <sys/types.h> does not define. */
|
||||
#undef int16_t
|
||||
|
|
@ -313,7 +326,7 @@
|
|||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
/* Define to `long' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
|
|
@ -322,7 +335,7 @@
|
|||
/* Define to 'int' if not defined */
|
||||
#undef rlim_t
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define to 'int' if not defined */
|
||||
|
|
@ -501,6 +514,25 @@ struct sockaddr_storage;
|
|||
#include "compat/fake-rfc2553.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SLEEP
|
||||
#define sleep(x) Sleep((x)*1000) /* on win32 */
|
||||
#endif /* HAVE_SLEEP */
|
||||
#ifndef HAVE_USLEEP
|
||||
#define usleep(x) Sleep((x)/1000 + 1) /* on win32 */
|
||||
#endif /* HAVE_USLEEP */
|
||||
#ifndef HAVE_RANDOM
|
||||
#define random rand /* on win32, for tests only (bad random) */
|
||||
#endif /* HAVE_RANDOM */
|
||||
#ifndef HAVE_SRANDOM
|
||||
#define srandom(x) srand(x) /* on win32, for tests only (bad random) */
|
||||
#endif /* HAVE_SRANDOM */
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#define FD_SET_T (u_int)
|
||||
#else
|
||||
#define FD_SET_T
|
||||
#endif
|
||||
|
||||
#include "ldns/ldns.h"
|
||||
|
||||
#ifdef UNBOUND_ALLOC_STATS
|
||||
|
|
|
|||
39
configure.ac
39
configure.ac
|
|
@ -724,7 +724,24 @@ AC_CHECK_GETADDRINFO_WITH_INCLUDES
|
|||
if test $ac_cv_func_getaddrinfo = no; then
|
||||
AC_LIBOBJ([fake-rfc2553])
|
||||
fi
|
||||
AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill])
|
||||
AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom])
|
||||
|
||||
# check mkdir
|
||||
AC_MSG_CHECKING([whether mkdir has one arg])
|
||||
AC_TRY_COMPILE([
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
], [
|
||||
(void)mkdir("directory");
|
||||
],
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(MKDIR_HAS_ONE_ARG, 1, [Define if mkdir has one argument.])
|
||||
,
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
# check ioctlsocket
|
||||
AC_MSG_CHECKING(for ioctlsocket)
|
||||
|
|
@ -934,6 +951,26 @@ struct sockaddr_storage;
|
|||
#include "compat/fake-rfc2553.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SLEEP
|
||||
#define sleep(x) Sleep((x)*1000) /* on win32 */
|
||||
#endif /* HAVE_SLEEP */
|
||||
#ifndef HAVE_USLEEP
|
||||
#define usleep(x) Sleep((x)/1000 + 1) /* on win32 */
|
||||
#endif /* HAVE_USLEEP */
|
||||
#ifndef HAVE_RANDOM
|
||||
#define random rand /* on win32, for tests only (bad random) */
|
||||
#endif /* HAVE_RANDOM */
|
||||
#ifndef HAVE_SRANDOM
|
||||
#define srandom(x) srand(x) /* on win32, for tests only (bad random) */
|
||||
#endif /* HAVE_SRANDOM */
|
||||
|
||||
/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#define FD_SET_T (u_int)
|
||||
#else
|
||||
#define FD_SET_T
|
||||
#endif
|
||||
|
||||
#include "ldns/ldns.h"
|
||||
|
||||
#ifdef UNBOUND_ALLOC_STATS
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
13 June 2008: Wouter
|
||||
- port mingw32, more signal ifdefs, detect sleep, usleep,
|
||||
random, srandom (used inside the tests).
|
||||
- signed or unsigned FD_SET is cast.
|
||||
|
||||
10 June 2008: Wouter
|
||||
- fixup warnings compiling on eeepc xandros linux.
|
||||
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ pollit(struct ub_ctx* ctx, struct timeval* t)
|
|||
fd_set r;
|
||||
#ifndef S_SPLINT_S
|
||||
FD_ZERO(&r);
|
||||
FD_SET(ctx->rrpipe[0], &r);
|
||||
FD_SET(FD_SET_T ctx->rrpipe[0], &r);
|
||||
#endif
|
||||
if(select(ctx->rrpipe[0]+1, &r, NULL, NULL, t) == -1) {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ find_create_proxy(struct sockaddr_storage* from, socklen_t from_len,
|
|||
p->addr_len = from_len;
|
||||
p->next = *proxies;
|
||||
*proxies = p;
|
||||
FD_SET(p->s, rorig);
|
||||
FD_SET(FD_SET_T p->s, rorig);
|
||||
if(p->s+1 > *max)
|
||||
*max = p->s+1;
|
||||
return p;
|
||||
|
|
@ -548,8 +548,13 @@ service_tcp_listen(int s, fd_set* rorig, int* max, struct tcp_proxy** proxies,
|
|||
fd_set_nonblock(p->client_s);
|
||||
fd_set_nonblock(p->server_s);
|
||||
if(connect(p->server_s, (struct sockaddr*)srv_addr, srv_len) == -1) {
|
||||
#ifdef EINPROGRESS
|
||||
if(errno != EINPROGRESS) {
|
||||
log_err("tcp connect: %s", strerror(errno));
|
||||
#else
|
||||
if(WSAGetLastError() != WSAEWOULDBLOCK) {
|
||||
log_err("tcp connect: %d", WSAGetLastError());
|
||||
#endif
|
||||
close(p->server_s);
|
||||
close(p->client_s);
|
||||
free(p);
|
||||
|
|
@ -560,8 +565,8 @@ service_tcp_listen(int s, fd_set* rorig, int* max, struct tcp_proxy** proxies,
|
|||
dl_tv_add(&p->timeout, tcp_timeout);
|
||||
|
||||
/* listen to client and server */
|
||||
FD_SET(p->client_s, rorig);
|
||||
FD_SET(p->server_s, rorig);
|
||||
FD_SET(FD_SET_T p->client_s, rorig);
|
||||
FD_SET(FD_SET_T p->server_s, rorig);
|
||||
if(p->client_s+1 > *max)
|
||||
*max = p->client_s+1;
|
||||
if(p->server_s+1 > *max)
|
||||
|
|
@ -689,8 +694,8 @@ service_tcp_relay(struct tcp_proxy** tcp_proxies, struct timeval* now,
|
|||
if(!tcp_relay_read(p->server_s, &p->answerlist,
|
||||
&p->answerlast, now, delay, pkt)) {
|
||||
close(p->server_s);
|
||||
FD_CLR(p->server_s, worig);
|
||||
FD_CLR(p->server_s, rorig);
|
||||
FD_CLR(FD_SET_T p->server_s, worig);
|
||||
FD_CLR(FD_SET_T p->server_s, rorig);
|
||||
p->server_s = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -705,8 +710,8 @@ service_tcp_relay(struct tcp_proxy** tcp_proxies, struct timeval* now,
|
|||
delete_it = 1;
|
||||
if(p->querylist && p->server_s != -1 &&
|
||||
dl_tv_smaller(&p->querylist->wait, now))
|
||||
FD_SET(p->server_s, worig);
|
||||
else FD_CLR(p->server_s, worig);
|
||||
FD_SET(FD_SET_T p->server_s, worig);
|
||||
else FD_CLR(FD_SET_T p->server_s, worig);
|
||||
}
|
||||
|
||||
/* can we send on further answers */
|
||||
|
|
@ -720,8 +725,8 @@ service_tcp_relay(struct tcp_proxy** tcp_proxies, struct timeval* now,
|
|||
delete_it = 1;
|
||||
if(p->answerlist && dl_tv_smaller(&p->answerlist->wait,
|
||||
now))
|
||||
FD_SET(p->client_s, worig);
|
||||
else FD_CLR(p->client_s, worig);
|
||||
FD_SET(FD_SET_T p->client_s, worig);
|
||||
else FD_CLR(FD_SET_T p->client_s, worig);
|
||||
if(!p->answerlist && p->server_s == -1)
|
||||
delete_it = 1;
|
||||
}
|
||||
|
|
@ -733,11 +738,11 @@ service_tcp_relay(struct tcp_proxy** tcp_proxies, struct timeval* now,
|
|||
if(delete_it) {
|
||||
struct tcp_proxy* np = p->next;
|
||||
*prev = np;
|
||||
FD_CLR(p->client_s, rorig);
|
||||
FD_CLR(p->client_s, worig);
|
||||
FD_CLR(FD_SET_T p->client_s, rorig);
|
||||
FD_CLR(FD_SET_T p->client_s, worig);
|
||||
if(p->server_s != -1) {
|
||||
FD_CLR(p->server_s, rorig);
|
||||
FD_CLR(p->server_s, worig);
|
||||
FD_CLR(FD_SET_T p->server_s, rorig);
|
||||
FD_CLR(FD_SET_T p->server_s, worig);
|
||||
}
|
||||
tcp_proxy_delete(p);
|
||||
p = np;
|
||||
|
|
@ -853,8 +858,8 @@ service_loop(int udp_s, int listen_s, struct ringbuf* ring,
|
|||
#ifndef S_SPLINT_S
|
||||
FD_ZERO(&rorig);
|
||||
FD_ZERO(&worig);
|
||||
FD_SET(udp_s, &rorig);
|
||||
FD_SET(listen_s, &rorig);
|
||||
FD_SET(FD_SET_T udp_s, &rorig);
|
||||
FD_SET(FD_SET_T listen_s, &rorig);
|
||||
#endif
|
||||
max = udp_s + 1;
|
||||
if(listen_s + 1 > max) max = listen_s + 1;
|
||||
|
|
@ -926,10 +931,19 @@ service(char* bind_str, int bindport, char* serv_str, size_t memsize,
|
|||
if(!pkt)
|
||||
fatal_exit("out of memory");
|
||||
if( signal(SIGINT, delayer_sigh) == SIG_ERR ||
|
||||
signal(SIGTERM, delayer_sigh) == SIG_ERR ||
|
||||
#ifdef SIGHUP
|
||||
signal(SIGHUP, delayer_sigh) == SIG_ERR ||
|
||||
#endif
|
||||
#ifdef SIGQUIT
|
||||
signal(SIGQUIT, delayer_sigh) == SIG_ERR ||
|
||||
signal(SIGALRM, delayer_sigh) == SIG_ERR)
|
||||
#endif
|
||||
#ifdef SIGBREAK
|
||||
signal(SIGBREAK, delayer_sigh) == SIG_ERR ||
|
||||
#endif
|
||||
#ifdef SIGALRM
|
||||
signal(SIGALRM, delayer_sigh) == SIG_ERR ||
|
||||
#endif
|
||||
signal(SIGTERM, delayer_sigh) == SIG_ERR)
|
||||
fatal_exit("could not bind to signal");
|
||||
/* bind UDP port */
|
||||
if((s = socket(str_is_ip6(bind_str)?AF_INET6:AF_INET,
|
||||
|
|
|
|||
|
|
@ -557,7 +557,11 @@ harvest_main(struct harvest_data* data)
|
|||
static void
|
||||
hv_mkdir(char* dir)
|
||||
{
|
||||
#ifdef MKDIR_HAS_ONE_ARG
|
||||
if(mkdir(dir) == -1) {
|
||||
#else
|
||||
if(mkdir(dir, 0755) == -1) {
|
||||
#endif
|
||||
if(errno == EEXIST)
|
||||
return;
|
||||
perror(dir);
|
||||
|
|
|
|||
|
|
@ -202,9 +202,16 @@ perfsetup(struct perfinfo* info)
|
|||
fatal_exit("gettimeofday: %s", strerror(errno));
|
||||
sig_info = info;
|
||||
if( signal(SIGINT, perf_sigh) == SIG_ERR ||
|
||||
signal(SIGTERM, perf_sigh) == SIG_ERR ||
|
||||
#ifdef SIGQUIT
|
||||
signal(SIGQUIT, perf_sigh) == SIG_ERR ||
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
signal(SIGHUP, perf_sigh) == SIG_ERR ||
|
||||
signal(SIGQUIT, perf_sigh) == SIG_ERR)
|
||||
#endif
|
||||
#ifdef SIGBREAK
|
||||
signal(SIGBREAK, perf_sigh) == SIG_ERR ||
|
||||
#endif
|
||||
signal(SIGTERM, perf_sigh) == SIG_ERR)
|
||||
fatal_exit("could not bind to signal");
|
||||
info->io = (struct perfio*)calloc(sizeof(struct perfio), info->io_num);
|
||||
if(!info->io) fatal_exit("out of memory");
|
||||
|
|
@ -223,7 +230,7 @@ perfsetup(struct perfinfo* info)
|
|||
if(info->io[i].fd > info->maxfd)
|
||||
info->maxfd = info->io[i].fd;
|
||||
#ifndef S_SPLINT_S
|
||||
FD_SET(info->io[i].fd, &info->rset);
|
||||
FD_SET(FD_SET_T info->io[i].fd, &info->rset);
|
||||
info->io[i].timeout.tv_usec = ((START_IO_INTERVAL*i)%1000)
|
||||
*1000;
|
||||
info->io[i].timeout.tv_sec = (START_IO_INTERVAL*i)/1000;
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ send_em(char* svr, int num, char** qs)
|
|||
printf("orderly exit\n");
|
||||
}
|
||||
|
||||
#ifdef SIGPIPE
|
||||
/** SIGPIPE handler */
|
||||
static RETSIGTYPE sigh(int sig)
|
||||
{
|
||||
|
|
@ -190,6 +191,7 @@ static RETSIGTYPE sigh(int sig)
|
|||
printf("Got unhandled signal %d\n", sig);
|
||||
exit(1);
|
||||
}
|
||||
#endif /* SIGPIPE */
|
||||
|
||||
/** getopt global, in case header files fail to declare it. */
|
||||
extern int optind;
|
||||
|
|
@ -206,10 +208,12 @@ int main(int argc, char** argv)
|
|||
log_init(0, 0, 0);
|
||||
checklock_start();
|
||||
|
||||
#ifdef SIGPIPE
|
||||
if(signal(SIGPIPE, &sigh) == SIG_ERR) {
|
||||
perror("could not install signal handler");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* command line options */
|
||||
if(argc == 1) {
|
||||
|
|
|
|||
|
|
@ -296,18 +296,10 @@ int event_add(struct event* ev, struct timeval* tv)
|
|||
if( (ev->ev_events&(EV_READ|EV_WRITE)) && ev->ev_fd != -1) {
|
||||
ev->ev_base->fds[ev->ev_fd] = ev;
|
||||
if(ev->ev_events&EV_READ) {
|
||||
#ifdef _WINSOCK2_H
|
||||
FD_SET((u_int)ev->ev_fd, &ev->ev_base->reads);
|
||||
#else
|
||||
FD_SET(ev->ev_fd, &ev->ev_base->reads);
|
||||
#endif
|
||||
FD_SET(FD_SET_T ev->ev_fd, &ev->ev_base->reads);
|
||||
}
|
||||
if(ev->ev_events&EV_WRITE) {
|
||||
#ifdef _WINSOCK2_H
|
||||
FD_SET((u_int)ev->ev_fd, &ev->ev_base->writes);
|
||||
#else
|
||||
FD_SET(ev->ev_fd, &ev->ev_base->writes);
|
||||
#endif
|
||||
FD_SET(FD_SET_T ev->ev_fd, &ev->ev_base->writes);
|
||||
}
|
||||
if(ev->ev_fd > ev->ev_base->maxfd)
|
||||
ev->ev_base->maxfd = ev->ev_fd;
|
||||
|
|
@ -337,13 +329,8 @@ int event_del(struct event* ev)
|
|||
(void)rbtree_delete(ev->ev_base->times, &ev->node);
|
||||
if((ev->ev_events&(EV_READ|EV_WRITE)) && ev->ev_fd != -1) {
|
||||
ev->ev_base->fds[ev->ev_fd] = NULL;
|
||||
#ifdef _WINSOCK2_H
|
||||
FD_CLR((u_int)ev->ev_fd, &ev->ev_base->reads);
|
||||
FD_CLR((u_int)ev->ev_fd, &ev->ev_base->writes);
|
||||
#else
|
||||
FD_CLR(ev->ev_fd, &ev->ev_base->reads);
|
||||
FD_CLR(ev->ev_fd, &ev->ev_base->writes);
|
||||
#endif
|
||||
FD_CLR(FD_SET_T ev->ev_fd, &ev->ev_base->reads);
|
||||
FD_CLR(FD_SET_T ev->ev_fd, &ev->ev_base->writes);
|
||||
}
|
||||
ev->added = 0;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue