From ba61b48fd75b27a26e9bd31c5a5f07c1037222bf Mon Sep 17 00:00:00 2001 From: rofl0r Date: Mon, 6 Apr 2015 17:57:09 +0100 Subject: [PATCH] fix compilation with openbsd closes #52 --- configure | 5 +++++ src/core.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ee69f7a..fe1ad71 100755 --- a/configure +++ b/configure @@ -14,6 +14,10 @@ isbsd() { uname -s | grep BSD >/dev/null } +isopenbsd() { + uname -s | grep OpenBSD >/dev/null +} + usage() { echo "supported arguments" echo "--prefix=/path default: $prefix" @@ -104,6 +108,7 @@ if ismac ; then elif isbsd ; then echo LIBDL=>>config.mak echo "CFLAGS+=-DIS_BSD">>config.mak + isopenbsd && echo "CFLAGS+=-DIS_OPENBSD">>config.mak make_cmd=gmake fi diff --git a/src/core.c b/src/core.c index 49caf64..25483c2 100644 --- a/src/core.c +++ b/src/core.c @@ -785,8 +785,12 @@ void proxy_freeaddrinfo(struct addrinfo *res) { free(res); } -#ifdef IS_MAC -/* getservbyname on mac is using thread local storage, so we dont need mutex */ +#if defined(IS_MAC) || defined(IS_OPENBSD) +#ifdef IS_OPENBSD /* OpenBSD has its own incompatible getservbyname_r */ +#define getservbyname_r mygetservbyname_r +#endif +/* getservbyname on mac is using thread local storage, so we dont need mutex + TODO: check if the same applies to OpenBSD */ static int getservbyname_r(const char* name, const char* proto, struct servent* result_buf, char* buf, size_t buflen, struct servent** result) { PFUNC(); @@ -853,6 +857,9 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin p->ai_flags = hints->ai_flags; p->ai_protocol = hints->ai_protocol; } else { +#ifndef AI_V4MAPPED +#define AI_V4MAPPED 0 +#endif p->ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG); }