[libc-commits] [libc] [libc] add `pthread_cond_*` public interfaces (PR #193656)
Alexey Samsonov via libc-commits
libc-commits at lists.llvm.org
Wed Apr 22 22:47:12 PDT 2026
================
@@ -0,0 +1,33 @@
+//===-- Implementation of pthread_cond_signal -----------------------------===//
+//
+// 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 "pthread_cond_signal.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/null_check.h"
+#include "src/__support/threads/CndVar.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+static_assert(
+ sizeof(CndVar) == sizeof(pthread_cond_t) &&
+ alignof(CndVar) == alignof(pthread_cond_t),
+ "The public pthread_cond_t type must be of the same size and alignment "
+ "as the internal condition variable type.");
+
+LLVM_LIBC_FUNCTION(int, pthread_cond_signal, (pthread_cond_t * cond)) {
+ LIBC_CRASH_ON_NULLPTR(cond);
+ // TODO: use cpp:start_lifetime_as once
+ // https://github.com/llvm/llvm-project/pull/193326 is merged
+ auto *cndvar = reinterpret_cast<CndVar *>(cond);
----------------
vonosmas wrote:
I feel that for consistency we may use `pthread_cond_utils.h` even in a smaller functions like this one? Or do we ever anticipate that on some platforms we'll only build smaller set of functions (init, destroy, signal), w/o pullig in more heavy timedwait?
https://github.com/llvm/llvm-project/pull/193656
More information about the libc-commits
mailing list