Add Solaris support

pull/212/head
papadave 2018-01-08 16:28:43 +08:00
parent d28f4df8e2
commit a85553ad67
5 changed files with 23 additions and 2 deletions

6
configure vendored
View File

@ -30,6 +30,10 @@ isopenbsd() {
uname -s | grep OpenBSD >/dev/null
}
issolaris() {
[ "`uname -s`" = SunOS ]
}
check_compile() {
printf "checking %s ... " "$1"
printf "$3" > "$tmpc"
@ -174,6 +178,8 @@ elif isbsd ; then
echo "CFLAGS+=-DIS_BSD">>config.mak
isopenbsd && echo "CFLAGS+=-DIS_OPENBSD">>config.mak
make_cmd=gmake
elif issolaris; then
echo "CFLAGS+=-DIS_SOLARIS -D__EXTENSIONS__" >> config.mak
fi
echo "Done, now run $make_cmd && $make_cmd install"

View File

@ -3,6 +3,7 @@
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#define _DARWIN_C_SOURCE
#define _XOPEN_SOURCE 600
#include <limits.h>
#include <pthread.h>
#include <unistd.h>

View File

@ -787,8 +787,8 @@ void proxy_freeaddrinfo(struct addrinfo *res) {
free(res);
}
#if defined(IS_MAC) || defined(IS_OPENBSD)
#ifdef IS_OPENBSD /* OpenBSD has its own incompatible getservbyname_r */
#if defined(IS_MAC) || defined(IS_OPENBSD) || defined(IS_SOLARIS)
#if defined(IS_OPENBSD) || defined(IS_SOLARIS) /* OpenBSD and Solaris 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

View File

@ -38,6 +38,12 @@
#include "core.h"
#include "common.h"
#ifdef IS_SOLARIS
#ifndef s6_addr32
#define s6_addr32 _S6_un._S6_u32
#endif
#endif
#define satosin(x) ((struct sockaddr_in *) &(x))
#define SOCKADDR(x) (satosin(x)->sin_addr.s_addr)
#define SOCKADDR_2(x) (satosin(x)->sin_addr)
@ -330,7 +336,11 @@ int close(int fd) {
}
static int is_v4inv6(const struct in6_addr *a) {
return a->s6_addr32[0] == 0 && a->s6_addr32[1] == 0 &&
#ifdef IS_SOLARIS
a->s6_addr[8] == 0 && a->s6_addr[9] == 0 && a->s6_addr[10] == 0xff && a->s6_addr[11] == 0xff;
#else
a->s6_addr16[4] == 0 && a->s6_addr16[5] == 0xffff;
#endif
}
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
INIT();

View File

@ -10,7 +10,11 @@
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#undef _XOPEN_SOURCE
#ifdef IS_SOLARIS /* Solaris doesn't recognize this macro greater than 600 */
#define _XOPEN_SOURCE 600
#else
#define _XOPEN_SOURCE 700
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>