summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openmp/runtime/src/kmp_ftn_entry.h2
-rw-r--r--openmp/runtime/src/kmp_wrapper_getpid.h2
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp33
3 files changed, 33 insertions, 4 deletions
diff --git a/openmp/runtime/src/kmp_ftn_entry.h b/openmp/runtime/src/kmp_ftn_entry.h
index e480e0151e1..b70726ce723 100644
--- a/openmp/runtime/src/kmp_ftn_entry.h
+++ b/openmp/runtime/src/kmp_ftn_entry.h
@@ -531,7 +531,7 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_THREAD_NUM)(void) {
int gtid;
#if KMP_OS_DARWIN || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
- KMP_OS_HURD
+ KMP_OS_HURD|| KMP_OS_OPENBSD
gtid = __kmp_entry_gtid();
#elif KMP_OS_WINDOWS
if (!__kmp_init_parallel ||
diff --git a/openmp/runtime/src/kmp_wrapper_getpid.h b/openmp/runtime/src/kmp_wrapper_getpid.h
index 70db857bcba..257772ad92b 100644
--- a/openmp/runtime/src/kmp_wrapper_getpid.h
+++ b/openmp/runtime/src/kmp_wrapper_getpid.h
@@ -29,6 +29,8 @@
#elif KMP_OS_NETBSD
#include <lwp.h>
#define __kmp_gettid() _lwp_self()
+#elif KMP_OS_OPENBSD
+#define __kmp_gettid() syscall(SYS_getthrid)
#elif defined(SYS_gettid)
// Hopefully other Unix systems define SYS_gettid syscall for getting os thread
// id
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 0ee12927e4b..9f79a6182d0 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -54,7 +54,7 @@
#include <sys/sysctl.h>
#include <sys/user.h>
#include <pthread_np.h>
-#elif KMP_OS_NETBSD
+#elif KMP_OS_NETBSD || KMP_OS_OPENBSD
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
@@ -2130,9 +2130,36 @@ int __kmp_is_address_mapped(void *addr) {
}
}
KMP_INTERNAL_FREE(kiv);
-#elif KMP_OS_DRAGONFLY || KMP_OS_OPENBSD
+#elif KMP_OS_OPENBSD
+
+ int mib[3];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC_VMMAP;
+ mib[2] = getpid();
+
+ size_t size;
+ uint64_t end;
+ rc = sysctl(mib, 3, NULL, &size, NULL, 0);
+ KMP_ASSERT(!rc);
+ KMP_ASSERT(size);
+ end = size;
+
+ struct kinfo_vmentry kiv = {.kve_start = 0};
+
+ while ((rc = sysctl(mib, 3, &kiv, &size, NULL, 0)) == 0) {
+ KMP_ASSERT(size);
+ if (kiv.kve_end == end)
+ break;
+
+ if (kiv.kve_start >= (uint64_t)addr && kiv.kve_end <= (uint64_t)addr) {
+ found = 1;
+ break;
+ }
+ kiv.kve_start += 1;
+ }
+#elif KMP_OS_DRAGONFLY
- // FIXME(DragonFly, OpenBSD): Implement this
+ // FIXME(DragonFly): Implement this
found = 1;
#else
OpenPOWER on IntegriCloud