[Openmp-commits] [openmp] 27f6eed - Enable OpenBSD support.
via Openmp-commits
openmp-commits at lists.llvm.org
Wed Oct 30 02:38:44 PDT 2019
Author: AndreyChurbanov
Date: 2019-10-30T12:37:44+03:00
New Revision: 27f6eedc57f95b812d49319bb3db08d59156775f
URL: https://github.com/llvm/llvm-project/commit/27f6eedc57f95b812d49319bb3db08d59156775f
DIFF: https://github.com/llvm/llvm-project/commit/27f6eedc57f95b812d49319bb3db08d59156775f.diff
LOG: Enable OpenBSD support.
Patch by devnexen (David CARLIER)
Differential Revision: https://reviews.llvm.org/D69220
Added:
Modified:
openmp/runtime/src/kmp_ftn_entry.h
openmp/runtime/src/kmp_wrapper_getpid.h
openmp/runtime/src/z_Linux_util.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_ftn_entry.h b/openmp/runtime/src/kmp_ftn_entry.h
index e480e0151e1c..b70726ce723e 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 70db857bcbae..257772ad92bc 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 0ee12927e4bf..9f79a6182d01 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
More information about the Openmp-commits
mailing list