[sanitizer_common] Define internal_usleep on Solaris
authorRainer Orth <ro@gcc.gnu.org>
Tue, 13 Jul 2021 09:15:03 +0000 (11:15 +0200)
committerRainer Orth <ro@gcc.gnu.org>
Tue, 13 Jul 2021 09:15:03 +0000 (11:15 +0200)
The Solaris/amd64 buildbot
<https://lab.llvm.org/staging/#/builders/101/builds/2845> has recently been
broken several times, at least one of those remains unfixed:

  [63/446] Generating Sanitizer-x86_64-Test
  [...]
  Undefined first referenced
   symbol       in file
  _ZN11__sanitizer15internal_usleepEy /opt/llvm-buildbot/home/solaris11-amd64/clang-solaris11-amd64/stage1/projects/compiler-rt/lib/sanitizer_common/tests/libRTSanitizerCommon.test.x86_64.a(sanitizer_common.cpp.o)
  ld: fatal: symbol referencing errors

Thist patch fixes it by defining the missing `internal_usleep`.

Tested on `amd64-pc-solaris2.11.`

Differential Revision: https://reviews.llvm.org/D105878

compiler-rt/lib/sanitizer_common/sanitizer_solaris.cpp

index c43c26dc615f6ee32c42ebd4837f65ee80579df9..3e283d1c610642a953829588826a920f0cce95d0 100644 (file)
@@ -160,6 +160,13 @@ DECLARE__REAL_AND_INTERNAL(uptr, sched_yield, void) {
   return sched_yield();
 }
 
+DECLARE__REAL_AND_INTERNAL(void, usleep, u64 useconds) {
+  struct timespec ts;
+  ts.tv_sec = useconds / 1000000;
+  ts.tv_nsec = (useconds % 1000000) * 1000;
+  nanosleep(&ts, nullptr);
+}
+
 DECLARE__REAL_AND_INTERNAL(uptr, execve, const char *filename,
                            char *const argv[], char *const envp[]) {
   return _REAL(execve)(filename, argv, envp);