[libc-commits] [PATCH] D79828: [libc] Add implementation of call_once from threads.h.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed May 13 10:17:20 PDT 2020


sivachandra added inline comments.


================
Comment at: libc/test/src/threads/call_once_test.cpp:27
+  static once_flag flag = ONCE_FLAG_INIT;
+  call_once(&flag, call_once_func);
+
----------------
abrachet wrote:
> This and the `mtx_*` functions are not prefaced with `__llvm_libc::`
That was a blunder! Thanks for catching.


================
Comment at: libc/test/src/threads/call_once_test.cpp:29-31
+  mtx_lock(&thread_count_mtx);
+  ++thread_count;
+  mtx_unlock(&thread_count_mtx);
----------------
abrachet wrote:
> 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?
About the various architectures, like how we require the compiler provide freestanding headers, I think we should require that the compiler provide `stdatomic.h`.  It isn't unreasonable: atomics library should be provided by the compiler or by the libc. We want the compiler to do it as they already have knowledge of the target architecture.


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