mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-28 16:11:29 +00:00
Add OpenBSD support to OpenMP
Summary: This patch permits OpenMP to build and work (with both gcc and clang) on OpenBSD. It mostly follows what was done for FreeBSD and NetBSD, except OpenBSD does not have pthread_getattr_np support, so it follows OS X in that one instance. Reviewers: #openmp, krytarowski Reviewed By: krytarowski Subscribers: guansong, jfb, emaste, mgorny, krytarowski, #openmp Tags: #openmp Differential Revision: https://reviews.llvm.org/D34280 llvm-svn: 348726
This commit is contained in:
parent
a56ac949ec
commit
7e1ea993e0
@ -1058,6 +1058,10 @@ extern kmp_uint64 __kmp_now_nsec();
|
||||
/* TODO: tune for KMP_OS_HURD */
|
||||
#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
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define KMP_OS_DRAGONFLY 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
|
||||
@ -61,6 +62,11 @@
|
||||
#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
|
||||
@ -73,12 +79,12 @@
|
||||
|
||||
#if (1 != \
|
||||
KMP_OS_LINUX + KMP_OS_DRAGONFLY + KMP_OS_FREEBSD + KMP_OS_NETBSD + \
|
||||
KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD)
|
||||
KMP_OS_OPENBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD)
|
||||
#error Unknown OS
|
||||
#endif
|
||||
|
||||
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
|
||||
KMP_OS_DARWIN || KMP_OS_HURD
|
||||
KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD
|
||||
#undef KMP_OS_UNIX
|
||||
#define KMP_OS_UNIX 1
|
||||
#endif
|
||||
|
@ -7671,7 +7671,7 @@ __kmp_determine_reduction_method(
|
||||
#if KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64
|
||||
|
||||
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
|
||||
KMP_OS_WINDOWS || KMP_OS_DARWIN || KMP_OS_HURD
|
||||
KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN || KMP_OS_HURD
|
||||
|
||||
int teamsize_cutoff = 4;
|
||||
|
||||
@ -7695,7 +7695,7 @@ __kmp_determine_reduction_method(
|
||||
#else
|
||||
#error "Unknown or unsupported OS"
|
||||
#endif // KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD \
|
||||
// || KMP_OS_WINDOWS || KMP_OS_DARWIN
|
||||
// || KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN || KMP_OS_HURD
|
||||
|
||||
#elif KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_AARCH || KMP_ARCH_MIPS
|
||||
|
||||
|
@ -94,7 +94,7 @@
|
||||
#if KMP_OS_WINDOWS
|
||||
#include <malloc.h> // Windows* OS: _alloca() declared in "malloc.h".
|
||||
#define alloca _alloca // Allow to use alloca() with no underscore.
|
||||
#elif KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD
|
||||
#elif KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD
|
||||
// Declared in "stdlib.h".
|
||||
#elif KMP_OS_UNIX
|
||||
#include <alloca.h> // Linux* OS and OS X*: alloc() declared in "alloca".
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "kmp_wait_release.h"
|
||||
#include "kmp_wrapper_getpid.h"
|
||||
|
||||
#if !KMP_OS_DRAGONFLY && !KMP_OS_FREEBSD && !KMP_OS_NETBSD
|
||||
#if !KMP_OS_DRAGONFLY && !KMP_OS_FREEBSD && !KMP_OS_NETBSD && !KMP_OS_OPENBSD
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#include <math.h> // HUGE_VAL.
|
||||
@ -499,7 +499,7 @@ static void *__kmp_launch_worker(void *thr) {
|
||||
#endif /* KMP_BLOCK_SIGNALS */
|
||||
void *exit_val;
|
||||
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
|
||||
KMP_OS_HURD
|
||||
KMP_OS_OPENBSD || KMP_OS_HURD
|
||||
void *volatile padding = 0;
|
||||
#endif
|
||||
int gtid;
|
||||
@ -547,7 +547,8 @@ static void *__kmp_launch_worker(void *thr) {
|
||||
KMP_CHECK_SYSFAIL("pthread_sigmask", status);
|
||||
#endif /* KMP_BLOCK_SIGNALS */
|
||||
|
||||
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD
|
||||
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
|
||||
KMP_OS_OPENBSD
|
||||
if (__kmp_stkoffset > 0 && gtid > 0) {
|
||||
padding = KMP_ALLOCA(gtid * __kmp_stkoffset);
|
||||
}
|
||||
@ -1768,7 +1769,7 @@ static int __kmp_get_xproc(void) {
|
||||
int r = 0;
|
||||
|
||||
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
|
||||
KMP_OS_HURD
|
||||
KMP_OS_OPENBSD || KMP_OS_HURD
|
||||
|
||||
r = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
|
||||
@ -2014,9 +2015,9 @@ int __kmp_is_address_mapped(void *addr) {
|
||||
found = 1;
|
||||
}
|
||||
|
||||
#elif KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD
|
||||
#elif KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_OPENBSD
|
||||
|
||||
// FIXME(DragonFly, FreeBSD, NetBSD): Implement this
|
||||
// FIXME(DragonFly, FreeBSD, NetBSD, OpenBSD): Implement this
|
||||
found = 1;
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user