Skip to content

Commit

Permalink
fix compilation with openbsd
Browse files Browse the repository at this point in the history
closes rofl0r#52
  • Loading branch information
rofl0r committed Apr 8, 2015
1 parent 377b474 commit ba61b48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit ba61b48

Please sign in to comment.