Skip to content

Commit

Permalink
Fix building sockets code on NetBSD / OpenBSD (#297)
Browse files Browse the repository at this point in the history
NetBSD / OpenBSD does not have gethostbyname_r().

OpenBSD does not have SO_NOSIGPIPE.
  • Loading branch information
brad0 authored Dec 20, 2024
1 parent 2675092 commit 71ef529
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions libs/common/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void psock_init() {

PSOCK psock_create() {
PSOCK s = socket(AF_INET,SOCK_STREAM,0);
# if defined(OS_MAC) || defined(OS_BSD)
# if defined(OS_MAC) || (defined(OS_BSD) && !defined(SO_NOSIGPIPE))
if( s != INVALID_SOCKET )
setsockopt(s,SOL_SOCKET,SO_NOSIGPIPE,NULL,0);
# endif
Expand Down Expand Up @@ -120,7 +120,7 @@ PHOST phost_resolve( const char *host ) {
PHOST ip = inet_addr(host);
if( ip == INADDR_NONE ) {
struct hostent *h;
# if defined(OS_WINDOWS) || defined(OS_MAC) || defined(OS_CYGWIN)
# if defined(OS_WINDOWS) || defined(OS_MAC) || defined(OS_CYGWIN) || defined(__NetBSD__) || defined(__OpenBSD__)
h = gethostbyname(host);
# else
struct hostent hbase;
Expand Down
2 changes: 1 addition & 1 deletion libs/std/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ static value host_resolve( value host ) {
ip = inet_addr(val_string(host));
if( ip == INADDR_NONE ) {
struct hostent *h;
# if defined(NEKO_WINDOWS) || defined(NEKO_MAC) || defined(NEKO_CYGWIN)
# if defined(NEKO_WINDOWS) || defined(NEKO_MAC) || defined(NEKO_CYGWIN) || defined(__NetBSD__) || defined(__OpenBSD__)
h = gethostbyname(val_string(host));
# else
struct hostent hbase;
Expand Down

0 comments on commit 71ef529

Please sign in to comment.