[libc-commits] [PATCH] D134716: [libc] Add implementation of pthread_once.

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Sep 27 11:36:16 PDT 2022


michaelrj added inline comments.


================
Comment at: libc/src/__support/threads/linux/callonce.cpp:46
+  if (futex_word->compare_exchange_strong(status, WAITING) ||
+      status == WAITING) {
+    __llvm_libc::syscall(SYS_futex, &futex_word->val, FUTEX_WAIT_PRIVATE,
----------------
sivachandra wrote:
> michaelrj wrote:
> > you just defined status to be `START`, so this condition seems like it can never be true.
> If `compare_exchange_strong` fails, it will write the current value of `futex_word` into `status` (which is a reference parameter to `compare_exchange_strong`.
ah, that makes sense. LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134716/new/

https://reviews.llvm.org/D134716



More information about the libc-commits mailing list