diff --git a/libs/mysql/socket.c b/libs/mysql/socket.c index 51ab16579..1184ecb0a 100644 --- a/libs/mysql/socket.c +++ b/libs/mysql/socket.c @@ -74,7 +74,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(__OpenBSD__)) if( s != INVALID_SOCKET ) setsockopt(s,SOL_SOCKET,SO_NOSIGPIPE,NULL,0); # endif @@ -121,7 +121,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(__OpenBSD__) h = gethostbyname(host); # else struct hostent hbase; diff --git a/src/std/socket.c b/src/std/socket.c index f717dc9ae..40a68e4ff 100644 --- a/src/std/socket.c +++ b/src/std/socket.c @@ -199,7 +199,7 @@ HL_PRIM int hl_host_resolve( vbyte *host ) { ip = inet_addr((char*)host); if( ip == INADDR_NONE ) { struct hostent *h; -# if defined(HL_WIN) || defined(HL_MAC) || defined(HL_IOS) || defined(HL_TVOS) || defined (HL_CYGWIN) || defined(HL_CONSOLE) +# if defined(HL_WIN) || defined(HL_MAC) || defined(HL_IOS) || defined(HL_TVOS) || defined (HL_CYGWIN) || defined(HL_CONSOLE) || defined(__OpenBSD__) h = gethostbyname((char*)host); # else struct hostent hbase; @@ -226,7 +226,7 @@ HL_PRIM vbyte *hl_host_to_string( int ip ) { HL_PRIM vbyte *hl_host_reverse( int ip ) { struct hostent *h; hl_blocking(true); -# if defined(HL_WIN) || defined(HL_MAC) || defined(HL_IOS) || defined(HL_TVOS) || defined(HL_CYGWIN) || defined(HL_CONSOLE) +# if defined(HL_WIN) || defined(HL_MAC) || defined(HL_IOS) || defined(HL_TVOS) || defined(HL_CYGWIN) || defined(HL_CONSOLE) || defined(__OpenBSD__) h = gethostbyaddr((char *)&ip,4,AF_INET); # elif defined(__ANDROID__) hl_error("hl_host_reverse() not available for this platform"); diff --git a/src/std/thread.c b/src/std/thread.c index 1b0f4f153..fceba9d23 100644 --- a/src/std/thread.c +++ b/src/std/thread.c @@ -25,6 +25,11 @@ typedef struct _hl_semaphore hl_semaphore; typedef struct _hl_condition hl_condition; +#ifdef __OpenBSD__ +#include +#define pthread_setname_np(a,b) pthread_set_name_np(a,b) +#endif + #if !defined(HL_THREADS) struct _hl_mutex { @@ -811,6 +816,8 @@ HL_PRIM int hl_thread_id() { return (pid_t)tid64; #elif defined(SYS_gettid) && !defined(HL_TVOS) return syscall(SYS_gettid); +#elif defined(__OpenBSD__) + return getthrid(); #else return -1; #endif