[Openmp-commits] [PATCH] D69220: [OpenMP] Enable OpenBSD support
David CARLIER via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Sun Oct 20 04:37:08 PDT 2019
devnexen updated this revision to Diff 225781.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69220/new/
https://reviews.llvm.org/D69220
Files:
openmp/runtime/src/kmp_ftn_entry.h
openmp/runtime/src/kmp_wrapper_getpid.h
openmp/runtime/src/z_Linux_util.cpp
Index: openmp/runtime/src/z_Linux_util.cpp
===================================================================
--- openmp/runtime/src/z_Linux_util.cpp
+++ 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,37 @@
}
}
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
Index: openmp/runtime/src/kmp_wrapper_getpid.h
===================================================================
--- openmp/runtime/src/kmp_wrapper_getpid.h
+++ openmp/runtime/src/kmp_wrapper_getpid.h
@@ -28,7 +28,8 @@
#define __kmp_gettid() pthread_getthreadid_np()
#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
Index: openmp/runtime/src/kmp_ftn_entry.h
===================================================================
--- openmp/runtime/src/kmp_ftn_entry.h
+++ openmp/runtime/src/kmp_ftn_entry.h
@@ -531,7 +531,7 @@
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 ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69220.225781.patch
Type: text/x-patch
Size: 2208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20191020/3adb1873/attachment.bin>
More information about the Openmp-commits
mailing list