[libc-commits] [libc] [libc] rework mutex (PR #92168)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Fri May 24 10:33:49 PDT 2024


================
@@ -22,12 +22,35 @@ add_header_library(
     libc.src.__support.time.linux.abs_timeout
 )
 
+set(raw_mutex_additional_flags)
+if (LIBC_CONF_TIMEOUT_ENSURE_MONOTONICITY)
+  set(raw_mutex_additional_flags -DLIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY)
+endif()
+
+add_header_library(
+  raw_mutex
+  HDRS
+    mutex.h
+  DEPENDS
+    .futex_utils
+    libc.src.__support.threads.sleep
+    libc.src.__support.time.linux.abs_timeout
+    libc.src.__support.time.linux.monotonicity
+    libc.src.__support.CPP.optional
+    libc.hdr.types.pid_t
+  COMPILE_OPTIONS
+    -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=${LIBC_CONF_RAW_MUTEX_DEFAULT_SPIN_COUNT}
----------------
nickdesaulniers wrote:

Same, is there a way such that if `-DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT` isn't set, we still default to 100? Or better yet, warn?

```c
#ifndef LIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT
#error "please set a default Mutex spin count"
#endif
```

https://github.com/llvm/llvm-project/pull/92168


More information about the libc-commits mailing list