[Openmp-commits] [PATCH] D69220: [OpenMP] Enable OpenBSD support

Andrey Churbanov via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Oct 30 02:40:25 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG27f6eedc57f9: Enable OpenBSD support. (authored by AndreyChurbanov).

Changed prior to commit:
  https://reviews.llvm.org/D69220?vs=225858&id=227052#toc

Repository:
  rG LLVM Github Monorepo

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,36 @@
     }
   }
   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
@@ -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
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.227052.patch
Type: text/x-patch
Size: 2142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20191030/783a0599/attachment.bin>


More information about the Openmp-commits mailing list