[libc-commits] [libc] [libc][semaphore] Add unnamed semaphore implementation (PR #190851)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Wed Apr 8 11:59:41 PDT 2026


https://github.com/SchrodingerZhu requested changes to this pull request.

LGTM overall with Just one small change:

Can you change `LIBC_INLINE void init(unsigned int initial_value)` to

```
LIBC_INLINE constexpr Semaphore(unsigned int value) : value(value), canary(0x53454D31U) {}
```

Then update `reinterpret_cast<Semaphore *>(sem)->init(value);`
to
```
#include "src/__support/CPP/new.h"
new (sem) Semaphore {value}?
```

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


More information about the libc-commits mailing list