[libc-commits] [libc] [libc] implement recursive mutex and fix wrong initializer (PR #193992)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Sat Apr 25 03:25:46 PDT 2026


================
@@ -10,47 +10,58 @@
 #define LLVM_LIBC_SRC___SUPPORT_THREADS_UNIX_MUTEX_H
 
 #include "hdr/types/pid_t.h"
+#include "hdr/types/size_t.h"
+#include "src/__support/CPP/atomic.h"
 #include "src/__support/CPP/optional.h"
 #include "src/__support/libc_assert.h"
 #include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"
+#include "src/__support/threads/identifier.h"
 #include "src/__support/threads/mutex_common.h"
 #include "src/__support/threads/raw_mutex.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 // TODO: support shared/recursive/robust mutexes.
 class Mutex final : private RawMutex {
-  // reserved timed, may be useful when combined with other flags.
-  unsigned char timed;
-  unsigned char recursive;
-  unsigned char robust;
-  unsigned char pshared;
+  // Use bitfields to allow encoding more attributes.
+  // TODO: also track errorchecking mutex type explicitly?
----------------
kaladron wrote:

Can you expand more on why you would track this explcitly, and then perhaps file it as an issue?  I worry about TODOs in the codebase that only get noticed a decade late =)

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


More information about the libc-commits mailing list