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

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Mon Jul 21 05:58:17 PDT 2025


================
@@ -0,0 +1,16 @@
+//===-- Definition of pthread_barrier_t type ------------------------------===//
+//
+// 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_TYPES_PTHREAD_BARRIER_T_H
+#define LLVM_LIBC_TYPES_PTHREAD_BARRIER_T_H
+
+typedef struct {
----------------
SchrodingerZhu wrote:

@brooksmoses alignof CndVar does not work here because this is for the public header. 

```
 unsigned expected;
  unsigned waiting;
  bool blocking;
  char entering[(sizeof CndVar)];
  char exiting[(sizeof CndVar)];
  char m[(sizeof Mutex)];
  ```
  
  Something like this is good. Feel free to use `__prefix` as we are inside libc.
  
  
  However, `char m[(sizeof Mutex)]` does not provide the alignment info.
  
  Please check https://github.com/llvm/llvm-project/blob/main/libc/include/llvm-libc-types/__mutex_type.h and https://github.com/llvm/llvm-project/blob/main/libc/include/llvm-libc-types/pthread_mutex_t.h

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


More information about the libc-commits mailing list