[Openmp-commits] [PATCH] D59451: Fix gettid warnings and one test on FreeBSD

Dimitry Andric via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Mar 16 04:54:01 PDT 2019


dim created this revision.
dim added reviewers: emaste, jlpeyton, krytarowski, mgorny, protze.joachim.
Herald added subscribers: jdoerfert, jfb.
Herald added a project: OpenMP.

While building the 8.0 releases on FreeBSD, I encountered the following
warnings in openmp quite a few times:

  In file included from projects/openmp/runtime/src/kmp_settings.cpp:27:
  projects/openmp/runtime/src/kmp_wrapper_getpid.h:35:2: warning: #warning is a language extension [-Wpedantic]
  #warning No gettid found, use getpid instead
   ^
  projects/openmp/runtime/src/kmp_wrapper_getpid.h:35:2: warning: No gettid found, use getpid instead [-W#warnings]
  2 warnings generated.

I added a gettid wrapper that uses FreeBSD's `pthread_getthreadid_np(3)`
function for this.

Another problem occurred while running the regression tests, where the
ompt/misc/interoperability.cpp failed to compile, with:

  projects/openmp/runtime/test/ompt/misc/interoperability.cpp:7:10: fatal error: 'alloca.h' file not found
  #include <alloca.h>
           ^~~~~~~~~~

Like on NetBSD, `alloca(3)` is defined in `<stdlib.h>` instead.  Also,
to make this test case link, I had to `-lpthread` to the command line,
otherwise it would fail with:

  ld: /tmp/lit_tmp_o4Emdi/interoperability-ce6e27.o: undefined reference to symbol 'pthread_create@@FBSD_1.0'


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D59451

Files:
  runtime/src/kmp_wrapper_getpid.h
  runtime/test/ompt/misc/interoperability.cpp


Index: runtime/test/ompt/misc/interoperability.cpp
===================================================================
--- runtime/test/ompt/misc/interoperability.cpp
+++ runtime/test/ompt/misc/interoperability.cpp
@@ -1,9 +1,9 @@
-// RUN: %libomp-cxx-compile-and-run | %sort-threads | FileCheck %s
+// RUN: %libomp-cxx-compile -lpthread && %libomp-run | %sort-threads | FileCheck %s
 // REQUIRES: ompt
 
 #include <iostream>
 #include <thread>
-#if !defined(__NetBSD__)
+#if !defined(__FreeBSD__) && !defined(__NetBSD__)
 #include <alloca.h>
 #else
 #include <cstdlib>
Index: runtime/src/kmp_wrapper_getpid.h
===================================================================
--- runtime/src/kmp_wrapper_getpid.h
+++ runtime/src/kmp_wrapper_getpid.h
@@ -23,6 +23,9 @@
 #if KMP_OS_DARWIN
 // OS X
 #define __kmp_gettid() syscall(SYS_thread_selfid)
+#elif KMP_OS_FREEBSD
+#include <pthread_np.h>
+#define __kmp_gettid() pthread_getthreadid_np()
 #elif KMP_OS_NETBSD
 #include <lwp.h>
 #define __kmp_gettid() _lwp_self()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59451.190954.patch
Type: text/x-patch
Size: 1020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190316/cdfa128f/attachment.bin>


More information about the Openmp-commits mailing list