Builds for OpenBSD!

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4620 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-11-08 03:36:08 +00:00
parent 6cdf207dcd
commit 52aa6eed0d
6 changed files with 46 additions and 7 deletions

View File

@ -27,6 +27,16 @@ CFLAGS += -Dstatic_assert=_Static_assert
LDFLAGS += \ LDFLAGS += \
-lbsd \ -lbsd \
-lnetwork -lnetwork
else ifeq ($(UNAME_S),OpenBSD)
BUILD_TYPES := debug release
CFLAGS += \
-Wno-unknown-warning-option
LDFLAGS += \
-lexecinfo \
-lc++abi
HAVE_ANDROID := 0
HAVE_LINUX_IOS := 0
HAVE_WIN := 0
else else
$(error Unexpected host platform $(UNAME_S).) $(error Unexpected host platform $(UNAME_S).)
endif endif
@ -292,6 +302,14 @@ else ifeq ($(UNAME_S),Haiku)
deps/libuv/src/unix/no-proctitle.c \ deps/libuv/src/unix/no-proctitle.c \
deps/libuv/src/unix/posix-hrtime.c \ deps/libuv/src/unix/posix-hrtime.c \
deps/libuv/src/unix/posix-poll.c deps/libuv/src/unix/posix-poll.c
else ifeq ($(UNAME_S),OpenBSD)
UV_SOURCES_unix += \
deps/libuv/src/unix/bsd-ifaddrs.c \
deps/libuv/src/unix/kqueue.c \
deps/libuv/src/unix/no-proctitle.c \
deps/libuv/src/unix/openbsd.c \
deps/libuv/src/unix/posix-hrtime.c \
deps/libuv/src/unix/random-getentropy.c
endif endif
UV_SOURCES_android := \ UV_SOURCES_android := \
deps/libuv/src/unix/random-getentropy.c deps/libuv/src/unix/random-getentropy.c
@ -558,9 +576,11 @@ debug release $(MACOS_TARGETS) $(IOS_TARGETS) $(IOSSIM_TARGETS): LDFLAGS += \
-lssl \ -lssl \
-lcrypto -lcrypto
ifneq ($(UNAME_S),Haiku) ifneq ($(UNAME_S),Haiku)
ifneq ($(UNAME_S),OpenBSD)
debug release $(MACOS_TARGETS) $(IOS_TARGETS) $(IOSSIM_TARGETS): LDFLAGS += \ debug release $(MACOS_TARGETS) $(IOS_TARGETS) $(IOSSIM_TARGETS): LDFLAGS += \
-ldl -ldl
endif endif
endif
$(WINDOWS_TARGETS): LDFLAGS += \ $(WINDOWS_TARGETS): LDFLAGS += \
-lssl \ -lssl \
-lcrypto \ -lcrypto \

View File

@ -1680,7 +1680,7 @@ static inline size_t js_def_malloc_usable_size(void *ptr)
return malloc_size(ptr); return malloc_size(ptr);
#elif defined(_WIN32) #elif defined(_WIN32)
return _msize(ptr); return _msize(ptr);
#elif defined(EMSCRIPTEN) || defined(__HAIKU__) #elif defined(EMSCRIPTEN) || defined(__HAIKU__) || defined(__OpenBSD__)
return 0; return 0;
#elif defined(__linux__) #elif defined(__linux__)
return malloc_usable_size(ptr); return malloc_usable_size(ptr);
@ -1754,7 +1754,7 @@ static const JSMallocFunctions def_malloc_funcs = {
malloc_size, malloc_size,
#elif defined(_WIN32) #elif defined(_WIN32)
(size_t (*)(const void *))_msize, (size_t (*)(const void *))_msize,
#elif defined(EMSCRIPTEN) || defined(__HAIKU__) #elif defined(EMSCRIPTEN) || defined(__HAIKU__) || defined(__OpenBSD__)
NULL, NULL,
#elif defined(__linux__) #elif defined(__linux__)
(size_t (*)(const void *))malloc_usable_size, (size_t (*)(const void *))malloc_usable_size,

View File

@ -18,10 +18,13 @@
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__HAIKU__) #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__HAIKU__)
#include <signal.h> #include <signal.h>
#include <sys/prctl.h>
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#if defined(__linux__)
#include <sys/prctl.h>
#endif
#if defined(__APPLE__) #if defined(__APPLE__)
#include <TargetConditionals.h> #include <TargetConditionals.h>
#endif #endif
@ -362,7 +365,7 @@ static void _shed_privileges()
perror("setrlimit(RLIMIT_NPROC, {0, 0})"); perror("setrlimit(RLIMIT_NPROC, {0, 0})");
exit(-1); exit(-1);
} }
#if !defined(__MACH__) #if !defined(__MACH__) && !defined(__OpenBSD__)
if (setrlimit(RLIMIT_LOCKS, &zeroLimit) != 0) if (setrlimit(RLIMIT_LOCKS, &zeroLimit) != 0)
{ {
perror("setrlimit(RLIMIT_LOCKS, {0, 0})"); perror("setrlimit(RLIMIT_LOCKS, {0, 0})");
@ -484,7 +487,7 @@ static int _tf_command_sandbox(const char* file, int argc, char* argv[])
return 2; return 2;
} }
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__HAIKU__) #if defined(__linux__)
prctl(PR_SET_PDEATHSIG, SIGHUP); prctl(PR_SET_PDEATHSIG, SIGHUP);
#endif #endif
tf_task_t* task = tf_task_create(); tf_task_t* task = tf_task_create();
@ -607,7 +610,7 @@ static void _startup(int argc, char* argv[])
_backtrace_error, _backtrace_error,
NULL); NULL);
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__HAIKU__) #if defined(__linux__)
prctl(PR_SET_PDEATHSIG, SIGKILL); prctl(PR_SET_PDEATHSIG, SIGKILL);
#endif #endif
tf_mem_replace_uv_allocator(); tf_mem_replace_uv_allocator();

View File

@ -394,17 +394,29 @@ size_t tf_mem_get_uv_malloc_size()
return s_uv_malloc_size; return s_uv_malloc_size;
} }
#if defined(__OpenBSD__)
void* _tf_tls_alloc(size_t size)
#else
void* _tf_tls_alloc(size_t size, const char* file, int line) void* _tf_tls_alloc(size_t size, const char* file, int line)
#endif
{ {
return _tf_alloc(&s_tls_malloc_size, size); return _tf_alloc(&s_tls_malloc_size, size);
} }
#if defined(__OpenBSD__)
void* _tf_tls_realloc(void* ptr, size_t size)
#else
void* _tf_tls_realloc(void* ptr, size_t size, const char* file, int line) void* _tf_tls_realloc(void* ptr, size_t size, const char* file, int line)
#endif
{ {
return _tf_realloc(&s_tls_malloc_size, ptr, size); return _tf_realloc(&s_tls_malloc_size, ptr, size);
} }
#if defined(__OpenBSD__)
void _tf_tls_free(void* ptr)
#else
void _tf_tls_free(void* ptr, const char* file, int line) void _tf_tls_free(void* ptr, const char* file, int line)
#endif
{ {
_tf_free(&s_tls_malloc_size, ptr); _tf_free(&s_tls_malloc_size, ptr);
} }

View File

@ -33,7 +33,7 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#if !defined(__APPLE__) #if !defined(__APPLE__) && !defined(__OpenBSD__)
#include <malloc.h> #include <malloc.h>
#endif #endif

View File

@ -16,6 +16,10 @@
#define WEXITSTATUS(x) (x) #define WEXITSTATUS(x) (x)
#endif #endif
#if defined(__OpenBSD__)
#include <sys/wait.h>
#endif
#if defined(__APPLE__) #if defined(__APPLE__)
#include <TargetConditionals.h> #include <TargetConditionals.h>
#endif #endif