[libc-commits] [libc] [libc] Implement barriers for pthreads (PR #148948)

Brooks Moses via libc-commits libc-commits at lists.llvm.org
Thu Jul 17 12:47:19 PDT 2025


================
@@ -0,0 +1,31 @@
+//===-- Linux implementation of the pthread_barrier_init 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 "pthread_barrier_init.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/threads/barrier.h"
+
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+static_assert(
+    sizeof(Barrier) <= sizeof(pthread_barrier_t),
----------------
brooksmoses wrote:

You should also check that alignof(pthread_barrier_t) and alignof(Barrier) are the same.

Also, as @SchrodingerZhu noted, this should probably go in libc/src/__support/threads/barrier.h.

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


More information about the libc-commits mailing list