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

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Sep 27 10:27:40 PDT 2022


sivachandra 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,
----------------
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`.


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