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

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Wed Jul 16 06:16:17 PDT 2025


================
@@ -0,0 +1,44 @@
+//===-- A platform independent abstraction layer for barriers --*- 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___SUPPORT_SRC_THREADS_LINUX_BARRIER_H
+#define LLVM_LIBC___SUPPORT_SRC_THREADS_LINUX_BARRIER_H
+
+#include "include/llvm-libc-types/pthread_barrier_t.h"
+#include "include/llvm-libc-types/pthread_barrierattr_t.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/threads/CndVar.h"
+#include "src/__support/threads/mutex.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+// NOTE: if the size of this class changes, you must ensure that the size of
+// pthread_barrier_t (found in include/llvm-libc/types/pthread_barrier_t.h) is
+// the same size
+
+extern const int BARRIER_FIRST_EXITED;
+
+class Barrier {
----------------
SchrodingerZhu wrote:

Add a static assert for layout compatibility.

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


More information about the libc-commits mailing list