Skip to content

Commit 71ef529

Browse files
authored
Fix building sockets code on NetBSD / OpenBSD (#297)
NetBSD / OpenBSD does not have gethostbyname_r(). OpenBSD does not have SO_NOSIGPIPE.
1 parent 2675092 commit 71ef529

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

libs/common/socket.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void psock_init() {
7373

7474
PSOCK psock_create() {
7575
PSOCK s = socket(AF_INET,SOCK_STREAM,0);
76-
# if defined(OS_MAC) || defined(OS_BSD)
76+
# if defined(OS_MAC) || (defined(OS_BSD) && !defined(SO_NOSIGPIPE))
7777
if( s != INVALID_SOCKET )
7878
setsockopt(s,SOL_SOCKET,SO_NOSIGPIPE,NULL,0);
7979
# endif
@@ -120,7 +120,7 @@ PHOST phost_resolve( const char *host ) {
120120
PHOST ip = inet_addr(host);
121121
if( ip == INADDR_NONE ) {
122122
struct hostent *h;
123-
# if defined(OS_WINDOWS) || defined(OS_MAC) || defined(OS_CYGWIN)
123+
# if defined(OS_WINDOWS) || defined(OS_MAC) || defined(OS_CYGWIN) || defined(__NetBSD__) || defined(__OpenBSD__)
124124
h = gethostbyname(host);
125125
# else
126126
struct hostent hbase;

libs/std/socket.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static value host_resolve( value host ) {
371371
ip = inet_addr(val_string(host));
372372
if( ip == INADDR_NONE ) {
373373
struct hostent *h;
374-
# if defined(NEKO_WINDOWS) || defined(NEKO_MAC) || defined(NEKO_CYGWIN)
374+
# if defined(NEKO_WINDOWS) || defined(NEKO_MAC) || defined(NEKO_CYGWIN) || defined(__NetBSD__) || defined(__OpenBSD__)
375375
h = gethostbyname(val_string(host));
376376
# else
377377
struct hostent hbase;

0 commit comments

Comments
 (0)