Skip to content

[libc] add pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock … #100543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 28, 2024

Conversation

Eric977
Copy link
Contributor

@Eric977 Eric977 commented Jul 25, 2024

add pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock
#99697

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc label Jul 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 25, 2024

@llvm/pr-subscribers-libc

Author: Eric977 (Eric977)

Changes

add pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock
#99697


Full diff: https://github.com/llvm/llvm-project/pull/100543.diff

10 Files Affected:

  • (modified) libc/config/linux/aarch64/entrypoints.txt (+2)
  • (modified) libc/config/linux/riscv/entrypoints.txt (+2)
  • (modified) libc/config/linux/x86_64/entrypoints.txt (+2)
  • (modified) libc/src/pthread/CMakeLists.txt (+22)
  • (added) libc/src/pthread/pthread_rwlock_clockrdlock.cpp (+51)
  • (added) libc/src/pthread/pthread_rwlock_clockrdlock.h (+23)
  • (added) libc/src/pthread/pthread_rwlock_clockwrlock.cpp (+52)
  • (added) libc/src/pthread/pthread_rwlock_clockwrlock.h (+23)
  • (modified) libc/test/integration/src/pthread/CMakeLists.txt (+2)
  • (modified) libc/test/integration/src/pthread/pthread_rwlock_test.cpp (+38-3)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 2334fed773702..260424291f3ab 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -692,6 +692,8 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.pthread.pthread_mutexattr_setrobust
     libc.src.pthread.pthread_mutexattr_settype
     libc.src.pthread.pthread_once
+    libc.src.pthread.pthread_rwlock_clockrdlock
+    libc.src.pthread.pthread_rwlock_clockwrlock
     libc.src.pthread.pthread_rwlock_destroy
     libc.src.pthread.pthread_rwlock_init
     libc.src.pthread.pthread_rwlock_rdlock
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 07466805b34cd..ead1fabc397ee 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -703,6 +703,8 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.pthread.pthread_mutexattr_setrobust
     libc.src.pthread.pthread_mutexattr_settype
     libc.src.pthread.pthread_once
+    libc.src.pthread.pthread_rwlock_clockrdlock
+    libc.src.pthread.pthread_rwlock_clockwrlock
     libc.src.pthread.pthread_rwlock_destroy
     libc.src.pthread.pthread_rwlock_init
     libc.src.pthread.pthread_rwlock_rdlock
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 035ceb8ca57bf..6911b2972f80c 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -790,6 +790,8 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.pthread.pthread_mutexattr_setrobust
     libc.src.pthread.pthread_mutexattr_settype
     libc.src.pthread.pthread_once
+    libc.src.pthread.pthread_rwlock_clockrdlock
+    libc.src.pthread.pthread_rwlock_clockwrlock
     libc.src.pthread.pthread_rwlock_destroy
     libc.src.pthread.pthread_rwlock_init
     libc.src.pthread.pthread_rwlock_rdlock
diff --git a/libc/src/pthread/CMakeLists.txt b/libc/src/pthread/CMakeLists.txt
index dc748b22e0378..70d10e6c4e3f8 100644
--- a/libc/src/pthread/CMakeLists.txt
+++ b/libc/src/pthread/CMakeLists.txt
@@ -556,6 +556,28 @@ add_entrypoint_object(
     libc.src.__support.threads.linux.rwlock
 )
 
+add_entrypoint_object(
+  pthread_rwlock_clockrdlock
+  SRCS
+    pthread_rwlock_clockrdlock.cpp
+  HDRS
+    pthread_rwlock_clockrdlock.h
+  DEPENDS
+    libc.include.pthread
+    libc.src.__support.threads.linux.rwlock
+)
+
+add_entrypoint_object(
+  pthread_rwlock_clockwrlock
+  SRCS
+    pthread_rwlock_clockwrlock.cpp
+  HDRS
+    pthread_rwlock_clockwrlock.h
+  DEPENDS
+    libc.include.pthread
+    libc.src.__support.threads.linux.rwlock
+)
+
 add_entrypoint_object(
   pthread_rwlock_timedrdlock
   SRCS
diff --git a/libc/src/pthread/pthread_rwlock_clockrdlock.cpp b/libc/src/pthread/pthread_rwlock_clockrdlock.cpp
new file mode 100644
index 0000000000000..421bbbab0011a
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlock_clockrdlock.cpp
@@ -0,0 +1,51 @@
+//===-- Implementation of the Rwlock's clockrdlock function
+//--------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/pthread/pthread_rwlock_clockrdlock.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/threads/linux/rwlock.h"
+
+#include <errno.h>
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+static_assert(
+    sizeof(RwLock) == sizeof(pthread_rwlock_t) &&
+        alignof(RwLock) == alignof(pthread_rwlock_t),
+    "The public pthread_rwlock_t type must be of the same size and alignment "
+    "as the internal rwlock type.");
+
+LLVM_LIBC_FUNCTION(int, pthread_rwlock_clockrdlock,
+                   (pthread_rwlock_t * rwlock, clockid_t clockid,
+                    const struct timespec *abstime)) {
+  if (!rwlock)
+    return EINVAL;
+  if (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME)
+    return EINVAL;
+  bool is_realtime = (clockid == CLOCK_REALTIME);
+  RwLock *rw = reinterpret_cast<RwLock *>(rwlock);
+  LIBC_ASSERT(abstime && "clockrdlock called with a null timeout");
+  auto timeout = internal::AbsTimeout::from_timespec(
+      *abstime, /*is_realtime=*/is_realtime);
+  if (LIBC_LIKELY(timeout.has_value()))
+    return static_cast<int>(rw->read_lock(timeout.value()));
+
+  switch (timeout.error()) {
+  case internal::AbsTimeout::Error::Invalid:
+    return EINVAL;
+  case internal::AbsTimeout::Error::BeforeEpoch:
+    return ETIMEDOUT;
+  }
+  __builtin_unreachable();
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/pthread/pthread_rwlock_clockrdlock.h b/libc/src/pthread/pthread_rwlock_clockrdlock.h
new file mode 100644
index 0000000000000..dd11d3cdf0814
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlock_clockrdlock.h
@@ -0,0 +1,23 @@
+//===-- Implementation header for Rwlock's clockrdlock function -------*-
+// C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCK_CLOCKRDLOCK_H
+#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCK_CLOCKRDLOCK_H
+
+#include "src/__support/macros/config.h"
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+int pthread_rwlock_clockrdlock(pthread_rwlock_t *rwlock, clockid_t clockid,
+                               const struct timespec *abstime);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCK_CLOCKRDLOCK_H
diff --git a/libc/src/pthread/pthread_rwlock_clockwrlock.cpp b/libc/src/pthread/pthread_rwlock_clockwrlock.cpp
new file mode 100644
index 0000000000000..8c65970670c07
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlock_clockwrlock.cpp
@@ -0,0 +1,52 @@
+//===-- Implementation of the Rwlock's clockwrlock function
+//--------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/pthread/pthread_rwlock_clockwrlock.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/threads/linux/rwlock.h"
+#include "src/__support/time/linux/abs_timeout.h"
+
+#include <errno.h>
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+static_assert(
+    sizeof(RwLock) == sizeof(pthread_rwlock_t) &&
+        alignof(RwLock) == alignof(pthread_rwlock_t),
+    "The public pthread_rwlock_t type must be of the same size and alignment "
+    "as the internal rwlock type.");
+
+LLVM_LIBC_FUNCTION(int, pthread_rwlock_clockwrlock,
+                   (pthread_rwlock_t * rwlock, clockid_t clockid,
+                    const struct timespec *abstime)) {
+  if (!rwlock)
+    return EINVAL;
+  if (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME)
+    return EINVAL;
+  bool is_realtime = (clockid == CLOCK_REALTIME);
+  RwLock *rw = reinterpret_cast<RwLock *>(rwlock);
+  LIBC_ASSERT(abstime && "clockwrlock called with a null timeout");
+  auto timeout = internal::AbsTimeout::from_timespec(
+      *abstime, /*is_realtime=*/is_realtime);
+  if (LIBC_LIKELY(timeout.has_value()))
+    return static_cast<int>(rw->write_lock(timeout.value()));
+
+  switch (timeout.error()) {
+  case internal::AbsTimeout::Error::Invalid:
+    return EINVAL;
+  case internal::AbsTimeout::Error::BeforeEpoch:
+    return ETIMEDOUT;
+  }
+  __builtin_unreachable();
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/pthread/pthread_rwlock_clockwrlock.h b/libc/src/pthread/pthread_rwlock_clockwrlock.h
new file mode 100644
index 0000000000000..ee0ec15a521a9
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlock_clockwrlock.h
@@ -0,0 +1,23 @@
+//===-- Implementation header for Rwlock's clockwrlock function -------*-
+// C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCK_CLOCKWRLOCK_H
+#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCK_CLOCKWRLOCK_H
+
+#include "src/__support/macros/config.h"
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+int pthread_rwlock_clockwrlock(pthread_rwlock_t *rwlock, clockid_t clockid,
+                               const struct timespec *abstime);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCK_CLOCKWRLOCK_H
diff --git a/libc/test/integration/src/pthread/CMakeLists.txt b/libc/test/integration/src/pthread/CMakeLists.txt
index fa5fd3ad55d5f..eb26822597c2f 100644
--- a/libc/test/integration/src/pthread/CMakeLists.txt
+++ b/libc/test/integration/src/pthread/CMakeLists.txt
@@ -32,9 +32,11 @@ add_integration_test(
     libc.src.pthread.pthread_rwlock_rdlock
     libc.src.pthread.pthread_rwlock_tryrdlock
     libc.src.pthread.pthread_rwlock_timedrdlock
+    libc.src.pthread.pthread_rwlock_clockrdlock
     libc.src.pthread.pthread_rwlock_wrlock
     libc.src.pthread.pthread_rwlock_trywrlock
     libc.src.pthread.pthread_rwlock_timedwrlock
+    libc.src.pthread.pthread_rwlock_clockwrlock
     libc.src.pthread.pthread_rwlock_unlock
     libc.src.pthread.pthread_create
     libc.src.pthread.pthread_join
diff --git a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
index 455003b6af811..39194ce55fe30 100644
--- a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
@@ -15,6 +15,8 @@
 #include "src/__support/threads/sleep.h"
 #include "src/pthread/pthread_create.h"
 #include "src/pthread/pthread_join.h"
+#include "src/pthread/pthread_rwlock_clockrdlock.h"
+#include "src/pthread/pthread_rwlock_clockwrlock.h"
 #include "src/pthread/pthread_rwlock_destroy.h"
 #include "src/pthread/pthread_rwlock_init.h"
 #include "src/pthread/pthread_rwlock_rdlock.h"
@@ -112,6 +114,8 @@ static void nullptr_test() {
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_wrlock(nullptr), EINVAL);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedrdlock(nullptr, &ts), EINVAL);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedwrlock(nullptr, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(nullptr, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(nullptr, &ts), EINVAL);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_tryrdlock(nullptr), EINVAL);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_trywrlock(nullptr), EINVAL);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_unlock(nullptr), EINVAL);
@@ -159,16 +163,26 @@ static void unusual_timespec_test() {
   timespec ts = {0, -1};
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedrdlock(&rwlock, &ts), EINVAL);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedwrlock(&rwlock, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts), EINVAL);
   ts.tv_nsec = 1'000'000'000;
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedrdlock(&rwlock, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts), EINVAL);
   ts.tv_nsec += 1;
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedwrlock(&rwlock, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts), EINVAL);
   ts.tv_nsec = 0;
   ts.tv_sec = -1;
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedrdlock(&rwlock, &ts),
             ETIMEDOUT);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedwrlock(&rwlock, &ts),
             ETIMEDOUT);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts),
+            ETIMEDOUT);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts),
+            ETIMEDOUT);
 }
 
 static void timedlock_with_deadlock_test() {
@@ -184,6 +198,9 @@ static void timedlock_with_deadlock_test() {
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedwrlock(&rwlock, &ts),
             ETIMEDOUT);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedrdlock(&rwlock, &ts), 0);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts),
+            ETIMEDOUT);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), 0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_unlock(&rwlock), 0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_unlock(&rwlock), 0);
   // notice that ts is already expired, but the following should still succeed.
@@ -270,9 +287,11 @@ enum class Operation : int {
   WRITE = 1,
   TIMED_READ = 2,
   TIMED_WRITE = 3,
-  TRY_READ = 4,
-  TRY_WRITE = 5,
-  COUNT = 6
+  CLOCK_READ = 4,
+  CLOCK_WRITE = 5,
+  TRY_READ = 6,
+  TRY_WRITE = 7,
+  COUNT = 8
 };
 
 LIBC_NAMESPACE::RawMutex *io_mutex;
@@ -358,6 +377,22 @@ static void randomized_thread_operation(SharedData *data, ThreadGuard &guard) {
     }
     break;
   }
+  case Operation::CLOCK_READ: {
+    timespec ts = get_ts();
+    if (LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&data->lock, &ts) == 0) {
+      read_ops();
+      LIBC_NAMESPACE::pthread_rwlock_unlock(&data->lock);
+    }
+    break;
+  }
+  case Operation::CLOCK_WRITE: {
+    timespec ts = get_ts();
+    if (LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&data->lock, &ts) == 0) {
+      write_ops();
+      LIBC_NAMESPACE::pthread_rwlock_unlock(&data->lock);
+    }
+    break;
+  }
   case Operation::TRY_READ: {
     if (LIBC_NAMESPACE::pthread_rwlock_tryrdlock(&data->lock) == 0) {
       read_ops();

@Eric977
Copy link
Contributor Author

Eric977 commented Jul 25, 2024

Hi @SchrodingerZhu, could you please review this pull request? Thank you!

@SchrodingerZhu
Copy link
Contributor

sure. I will take a look at this ASAP

Copy link
Contributor

@SchrodingerZhu SchrodingerZhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the function definitions to headergen:

- name: pthread_rwlock_timedwrlock

and
FunctionSpec<

@Eric977
Copy link
Contributor Author

Eric977 commented Jul 27, 2024

Hi @SchrodingerZhu, I have add the function definitions.

@Eric977 Eric977 requested a review from SchrodingerZhu July 27, 2024 10:41
@SchrodingerZhu
Copy link
Contributor

Thank you for this PR! First, my apology that I somehow break the pthread integration test in a recent patch. You can re-enable the test temporarily via the following the patch. I am trying to address this in a separate PR already.

diff --git a/libc/src/__support/threads/CMakeLists.txt b/libc/src/__support/threads/CMakeLists.txt
index f1a2f162acfc..ab474b23bcbf 100644
--- a/libc/src/__support/threads/CMakeLists.txt
+++ b/libc/src/__support/threads/CMakeLists.txt
@@ -101,7 +101,7 @@ endif()
 
 set(tid_dep)
 if (LLVM_LIBC_FULL_BUILD)
-  list(APPEND tid_dep libc.src.__support.thread)
+  list(APPEND tid_dep libc.src.__support.threads.thread)
 else()
   list(APPEND tid_dep libc.src.__support.OSUtil.osutil)
   list(APPEND tid_dep libc.include.sys_syscall)

You should be able to see that your integration test cases are broken due to some minor issues. Could you address them? Thank you!

[162/169] Building CXX object libc/test/integration/src/pthread/CMakeFi...src.pthread.pthread_rwlock_test.__build__.dir/pthread_rwlock_test.cpp.o
FAILED: libc/test/integration/src/pthread/CMakeFiles/libc.test.integration.src.pthread.pthread_rwlock_test.__build__.dir/pthread_rwlock_test.cpp.o 
sccache /usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -I/home/schrodinger/development/llvm-project/libc -isystem /home/schrodinger/development/llvm-project/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O2 -g -DNDEBUG -std=gnu++17 -mcpu=native -fpie -ffreestanding -fno-exceptions -fno-rtti -DLIBC_FULL_BUILD -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -DLIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY=1 -DLIBC_COPT_ENABLE_TID_CACHE=1 -MD -MT libc/test/integration/src/pthread/CMakeFiles/libc.test.integration.src.pthread.pthread_rwlock_test.__build__.dir/pthread_rwlock_test.cpp.o -MF libc/test/integration/src/pthread/CMakeFiles/libc.test.integration.src.pthread.pthread_rwlock_test.__build__.dir/pthread_rwlock_test.cpp.o.d -o libc/test/integration/src/pthread/CMakeFiles/libc.test.integration.src.pthread.pthread_rwlock_test.__build__.dir/pthread_rwlock_test.cpp.o -c /home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:117:68: error: too few arguments to function call, expected 3, have 2
  117 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(nullptr, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockrdlock.h:17:5: note: 'pthread_rwlock_clockrdlock' declared here
   17 | int pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:118:68: error: too few arguments to function call, expected 3, have 2
  118 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(nullptr, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockwrlock.h:17:5: note: 'pthread_rwlock_clockwrlock' declared here
   17 | int pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:166:68: error: too few arguments to function call, expected 3, have 2
  166 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockrdlock.h:17:5: note: 'pthread_rwlock_clockrdlock' declared here
   17 | int pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:167:68: error: too few arguments to function call, expected 3, have 2
  167 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockwrlock.h:17:5: note: 'pthread_rwlock_clockwrlock' declared here
   17 | int pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:170:68: error: too few arguments to function call, expected 3, have 2
  170 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockrdlock.h:17:5: note: 'pthread_rwlock_clockrdlock' declared here
   17 | int pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:171:68: error: too few arguments to function call, expected 3, have 2
  171 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockwrlock.h:17:5: note: 'pthread_rwlock_clockwrlock' declared here
   17 | int pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:174:68: error: too few arguments to function call, expected 3, have 2
  174 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockrdlock.h:17:5: note: 'pthread_rwlock_clockrdlock' declared here
   17 | int pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:175:68: error: too few arguments to function call, expected 3, have 2
  175 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts), EINVAL);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockwrlock.h:17:5: note: 'pthread_rwlock_clockwrlock' declared here
   17 | int pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:182:68: error: too few arguments to function call, expected 3, have 2
  182 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts),
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  183 |             ETIMEDOUT);
      |             ~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockrdlock.h:17:5: note: 'pthread_rwlock_clockrdlock' declared here
   17 | int pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:184:68: error: too few arguments to function call, expected 3, have 2
  184 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts),
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  185 |             ETIMEDOUT);
      |             ~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockwrlock.h:17:5: note: 'pthread_rwlock_clockwrlock' declared here
   17 | int pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:201:68: error: too few arguments to function call, expected 3, have 2
  201 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, &ts),
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  202 |             ETIMEDOUT);
      |             ~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockwrlock.h:17:5: note: 'pthread_rwlock_clockwrlock' declared here
   17 | int pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:203:68: error: too few arguments to function call, expected 3, have 2
  203 |   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, &ts), 0);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:62:35: note: expanded from macro 'ASSERT_EQ'
   62 |   __CHECK_EQ(__FILE__, __LINE__, (val1), (val2), true)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/IntegrationTest/test.h:33:8: note: expanded from macro '__CHECK_EQ'
   33 |   if ((val1) != (val2)) {                                                      \
      |        ^~~~
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockrdlock.h:17:5: note: 'pthread_rwlock_clockrdlock' declared here
   17 | int pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:382:68: error: too few arguments to function call, expected 3, have 2
  382 |     if (LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&data->lock, &ts) == 0) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                 ^
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockrdlock.h:17:5: note: 'pthread_rwlock_clockrdlock' declared here
   17 | int pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/schrodinger/development/llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:390:68: error: too few arguments to function call, expected 3, have 2
  390 |     if (LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&data->lock, &ts) == 0) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                 ^
/home/schrodinger/development/llvm-project/libc/src/pthread/pthread_rwlock_clockwrlock.h:17:5: note: 'pthread_rwlock_clockwrlock' declared here
   17 | int pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict rwlock,
      |     ^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |                                clockid_t clockid,
      |                                ~~~~~~~~~~~~~~~~~~
   19 |                                const timespec *__restrict abstime);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 errors generated.
[165/169] Running integration test libc.test.integration.src.pthread.pthread_test
ninja: build stopped: subcommand failed.

@SchrodingerZhu
Copy link
Contributor

Could you also add the following to our documentation? Thank you!

diff --git a/libc/docs/dev/undefined_behavior.rst b/libc/docs/dev/undefined_behavior.rst
index b712780222aa..6c3963f069bb 100644
--- a/libc/docs/dev/undefined_behavior.rst
+++ b/libc/docs/dev/undefined_behavior.rst
@@ -116,3 +116,8 @@ inherited from parent process triggered inside the instruction window between ``
 and ``exec*``. As libc failed to maintain its internal states correctly, even though the
 functions used inside the signal handlers are marked as ``async-signal-safe`` (such as
 ``getpid``), they will still return wrong values or lead to other even worse situations.
+
+Unrecognized ``clockid_t`` values for ``pthread_rwlock_clock*`` APIs
+----------------------------------------------------------------------
+POSIX.1-2024 only demands support for ``CLOCK_REALTIME`` and ``CLOCK_MONOTONIC``. Currently,
+as in LLVM libc, if other clock ids are used, they will be treated as monotonic clocks.

@Eric977
Copy link
Contributor Author

Eric977 commented Jul 28, 2024

Sorry, I have rebase to resolve conflict, nothing change for previous three commit.

Copy link

github-actions bot commented Jul 28, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@SchrodingerZhu SchrodingerZhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SchrodingerZhu SchrodingerZhu merged commit 44df89c into llvm:main Jul 28, 2024
7 checks passed
Copy link

@Eric977 Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@SchrodingerZhu
Copy link
Contributor

Thank you for the patch

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 28, 2024

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-fullbuild-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/3242

Here is the relevant piece of the build log for the reference:

Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[172/179] Running integration test libc.test.integration.src.unistd.getcwd_test
[173/179] Running integration test libc.test.integration.src.unistd.execv_test
[174/179] Linking CXX executable projects/libc/test/integration/src/unistd/libc.test.integration.src.unistd.fork_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[175/179] Running integration test libc.test.integration.src.unistd.fork_test
[176/179] Running integration test libc.test.integration.src.threads.thrd_test
[177/179] Linking CXX executable projects/libc/test/integration/src/unistd/libc.test.integration.src.unistd.execve_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[178/179] Running integration test libc.test.integration.src.unistd.execve_test
command timed out: 1200 seconds without output running [b'python', b'../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py', b'--debug'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1292.193744
Step 10 (libc-integration-tests) failure: libc-integration-tests (failure)
...
[145/179] Linking CXX static library projects/libc/test/integration/src/unistd/liblibc.test.integration.src.unistd.execve_test.libc.a
[146/179] Running integration test libc.test.integration.src.pthread.pthread_equal_test
[147/179] Running integration test libc.test.integration.src.pthread.pthread_create_test
[148/179] Building CXX object projects/libc/test/integration/src/threads/CMakeFiles/libc.test.integration.src.threads.mtx_test.__build__.dir/mtx_test.cpp.o
[149/179] Building CXX object projects/libc/test/integration/src/threads/CMakeFiles/libc.test.integration.src.threads.thrd_exit_test.__build__.dir/thrd_exit_test.cpp.o
[150/179] Linking CXX executable projects/libc/test/integration/src/threads/libc.test.integration.src.threads.thrd_equal_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[151/179] Running integration test libc.test.integration.src.threads.thrd_equal_test
[152/179] Building CXX object projects/libc/test/integration/src/threads/CMakeFiles/libc.test.integration.src.threads.tss_test.__build__.dir/tss_test.cpp.o
[153/179] Linking CXX executable projects/libc/test/integration/src/threads/libc.test.integration.src.threads.cnd_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[154/179] Linking CXX executable projects/libc/test/integration/src/threads/libc.test.integration.src.threads.thrd_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[155/179] Running integration test libc.test.integration.src.pthread.pthread_test
[156/179] Linking CXX executable projects/libc/test/integration/src/threads/libc.test.integration.src.threads.call_once_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[157/179] Building CXX object projects/libc/test/integration/src/unistd/CMakeFiles/libc.test.integration.src.unistd.getcwd_test.__build__.dir/getcwd_test.cpp.o
[158/179] Running integration test libc.test.integration.src.threads.call_once_test
[159/179] Building CXX object projects/libc/test/integration/src/unistd/CMakeFiles/libc.test.integration.src.unistd.execv_test.__build__.dir/execv_test.cpp.o
[160/179] Building CXX object projects/libc/test/integration/src/unistd/CMakeFiles/libc.test.integration.src.unistd.fork_test.__build__.dir/fork_test.cpp.o
[161/179] Linking CXX executable projects/libc/test/integration/src/threads/libc.test.integration.src.threads.thrd_exit_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[162/179] Linking CXX executable projects/libc/test/integration/src/threads/libc.test.integration.src.threads.mtx_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[163/179] Running integration test libc.test.integration.src.threads.cnd_test
[164/179] Running integration test libc.test.integration.src.threads.thrd_exit_test
[165/179] Linking CXX executable projects/libc/test/integration/src/threads/libc.test.integration.src.threads.tss_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[166/179] Running integration test libc.test.integration.src.threads.tss_test
[167/179] Running integration test libc.test.integration.src.pthread.pthread_mutex_test
[168/179] Building CXX object projects/libc/test/integration/src/unistd/CMakeFiles/libc.test.integration.src.unistd.execve_test.__build__.dir/execve_test.cpp.o
[169/179] Running integration test libc.test.integration.src.threads.mtx_test
[170/179] Linking CXX executable projects/libc/test/integration/src/unistd/libc.test.integration.src.unistd.execv_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[171/179] Linking CXX executable projects/libc/test/integration/src/unistd/libc.test.integration.src.unistd.getcwd_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[172/179] Running integration test libc.test.integration.src.unistd.getcwd_test
[173/179] Running integration test libc.test.integration.src.unistd.execv_test
[174/179] Linking CXX executable projects/libc/test/integration/src/unistd/libc.test.integration.src.unistd.fork_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[175/179] Running integration test libc.test.integration.src.unistd.fork_test
[176/179] Running integration test libc.test.integration.src.threads.thrd_test
[177/179] Linking CXX executable projects/libc/test/integration/src/unistd/libc.test.integration.src.unistd.execve_test.__build__
/usr/bin/ld: warning: cannot create .note.gnu.build-id section, --build-id ignored
[178/179] Running integration test libc.test.integration.src.unistd.execve_test

command timed out: 1200 seconds without output running [b'python', b'../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py', b'--debug'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1292.193744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants