[libc-commits] [PATCH] D79828: [libc] Add implementation of call_once from threads.h.
Alex Brachet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed May 13 01:02:41 PDT 2020
abrachet added inline comments.
================
Comment at: libc/src/threads/call_once.cpp:21
+ atomic_uint *atomic_flag = reinterpret_cast<atomic_uint *>(flag);
+ unsigned int not_called = 0;
+
----------------
Should we use `ONCE_FLAG_INIT` instead of 0?
================
Comment at: libc/test/src/threads/call_once_test.cpp:27
+ static once_flag flag = ONCE_FLAG_INIT;
+ call_once(&flag, call_once_func);
+
----------------
This and the `mtx_*` functions are not prefaced with `__llvm_libc::`
================
Comment at: libc/test/src/threads/call_once_test.cpp:29-31
+ mtx_lock(&thread_count_mtx);
+ ++thread_count;
+ mtx_unlock(&thread_count_mtx);
----------------
Maybe we could just make `thread_count` an atomic type so we're only testing `call_once` and not `mtx_*`?
Are there some architectures don't have support for locking instructions and must call into libc to support atomic types?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79828/new/
https://reviews.llvm.org/D79828
More information about the libc-commits
mailing list