Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -7,6 +7,6 @@ # Currently libomptarget cannot be compiled on Windows or MacOS X. # Since the device plugins are only supported on Linux anyway, # there is no point in trying to compile libomptarget on other OSes. -if (NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) +if (NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")) add_subdirectory(libomptarget) endif() Index: runtime/src/kmp.h =================================================================== --- runtime/src/kmp.h +++ runtime/src/kmp.h @@ -1027,6 +1027,10 @@ /* TODO: tune for KMP_OS_NETBSD */ #define KMP_INIT_WAIT 1024U /* initial number of spin-tests */ #define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */ +#elif KMP_OS_OPENBSD +/* TODO: tune for KMP_OS_OPENBSD */ +#define KMP_INIT_WAIT 1024U /* initial number of spin-tests */ +#define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */ #endif #if KMP_ARCH_X86 || KMP_ARCH_X86_64 Index: runtime/src/kmp_ftn_entry.h =================================================================== --- runtime/src/kmp_ftn_entry.h +++ runtime/src/kmp_ftn_entry.h @@ -348,7 +348,7 @@ #else int gtid; -#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD +#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD gtid = __kmp_entry_gtid(); #elif KMP_OS_WINDOWS if (!__kmp_init_parallel || Index: runtime/src/kmp_platform.h =================================================================== --- runtime/src/kmp_platform.h +++ runtime/src/kmp_platform.h @@ -21,6 +21,7 @@ #define KMP_OS_LINUX 0 #define KMP_OS_FREEBSD 0 #define KMP_OS_NETBSD 0 +#define KMP_OS_OPENBSD 0 #define KMP_OS_DARWIN 0 #define KMP_OS_WINDOWS 0 #define KMP_OS_CNK 0 @@ -56,18 +57,23 @@ #define KMP_OS_NETBSD 1 #endif +#if (defined __OpenBSD__) +#undef KMP_OS_OPENBSD +#define KMP_OS_OPENBSD 1 +#endif + #if (defined __bgq__) #undef KMP_OS_CNK #define KMP_OS_CNK 1 #endif #if (1 != \ - KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_NETBSD + KMP_OS_DARWIN + \ - KMP_OS_WINDOWS) + KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_NETBSD + KMP_OS_OPENBSD + \ + KMP_OS_DARWIN + KMP_OS_WINDOWS) #error Unknown OS #endif -#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DARWIN +#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD || KMP_OS_DARWIN #undef KMP_OS_UNIX #define KMP_OS_UNIX 1 #endif @@ -94,7 +100,7 @@ #endif #if KMP_OS_UNIX -#if defined __x86_64 +#if defined __x86_64__ #undef KMP_ARCH_X86_64 #define KMP_ARCH_X86_64 1 #elif defined __i386 Index: runtime/src/kmp_runtime.cpp =================================================================== --- runtime/src/kmp_runtime.cpp +++ runtime/src/kmp_runtime.cpp @@ -7508,8 +7508,8 @@ #if KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 -#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_WINDOWS || \ - KMP_OS_DARWIN +#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD || \ + KMP_OS_WINDOWS || KMP_OS_DARWIN int teamsize_cutoff = 4; @@ -7531,12 +7531,12 @@ } #else #error "Unknown or unsupported OS" -#endif // KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_WINDOWS || -// KMP_OS_DARWIN +#endif // KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD || +// KMP_OS_WINDOWS || KMP_OS_DARWIN #elif KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_AARCH || KMP_ARCH_MIPS -#if KMP_OS_LINUX || KMP_OS_WINDOWS +#if KMP_OS_LINUX || KMP_OS_WINDOWS || KMP_OPENBSD // basic tuning Index: runtime/src/kmp_wrapper_malloc.h =================================================================== --- runtime/src/kmp_wrapper_malloc.h +++ runtime/src/kmp_wrapper_malloc.h @@ -96,7 +96,7 @@ #if KMP_OS_WINDOWS #include // Windows* OS: _alloca() declared in "malloc.h". #define alloca _alloca // Allow to use alloca() with no underscore. -#elif KMP_OS_FREEBSD || KMP_OS_NETBSD +#elif KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD // Declared in "stdlib.h". #elif KMP_OS_UNIX #include // Linux* OS and OS X*: alloc() declared in "alloca". Index: runtime/src/z_Linux_util.cpp =================================================================== --- runtime/src/z_Linux_util.cpp +++ runtime/src/z_Linux_util.cpp @@ -24,7 +24,7 @@ #include "kmp_wait_release.h" #include "kmp_wrapper_getpid.h" -#if !KMP_OS_FREEBSD && !KMP_OS_NETBSD +#if !KMP_OS_FREEBSD && !KMP_OS_NETBSD && !KMP_OS_OPENBSD #include #endif #include // HUGE_VAL. @@ -447,7 +447,7 @@ static kmp_int32 __kmp_set_stack_info(int gtid, kmp_info_t *th) { int stack_data; #if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD - /* Linux* OS only -- no pthread_getattr_np support on OS X* */ + /* Uses pthread_getattr_np -- not supported on all operating systems */ pthread_attr_t attr; int status; size_t size = 0; @@ -499,7 +499,7 @@ sigset_t new_set, old_set; #endif /* KMP_BLOCK_SIGNALS */ void *exit_val; -#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD +#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD void *volatile padding = 0; #endif int gtid; @@ -547,7 +547,7 @@ KMP_CHECK_SYSFAIL("pthread_sigmask", status); #endif /* KMP_BLOCK_SIGNALS */ -#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD +#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD if (__kmp_stkoffset > 0 && gtid > 0) { padding = KMP_ALLOCA(gtid * __kmp_stkoffset); } @@ -1787,7 +1787,7 @@ int r = 0; -#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD +#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD r = sysconf(_SC_NPROCESSORS_ONLN); @@ -2045,9 +2045,9 @@ found = 1; }; // if -#elif KMP_OS_FREEBSD || KMP_OS_NETBSD +#elif KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD - // FIXME(FreeBSD, NetBSD): Implement this + // FIXME(FreeBSD, NetBSD, OpenBSD): Implement this found = 1; #else