[libc-commits] [PATCH] D121334: [libc] Use the constexpr constructor to initialize exit handlers mutex.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Mar 9 17:10:38 PST 2022


sivachandra added inline comments.


================
Comment at: libc/src/stdlib/CMakeLists.txt:280
+  COMPILE_OPTIONS
+    -O3
   DEPENDS
----------------
abrachet wrote:
> Why is this necessary?
This is actually required for a follow up change. Removed it now.


================
Comment at: libc/src/stdlib/atexit.cpp:18
 
-mtx_t lock;
-// TODO need an easier way to use mtx_t internally, or use pthread_mutex_t
-// with PTHREAD_MUTEX_INITIALIZER when it lands.
-struct Init {
-  Init() { __llvm_libc::mtx_init(&lock, mtx_plain); }
-} init;
+Mutex handler_list_mtx(false, false, false);
 
----------------
michaelrj wrote:
> this seems like it won't work if `linux/mutex.h` isn't included, should this be locked down by host OS?
At that level, it was already that way. For, the functions `__llvm_libc::mtx_lock` etc are only available for the linux target. The way to look at this is that, the code in this file does not depend or use an OS specific piece directly - `threads/mutex.h` is the abstraction layer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121334



More information about the libc-commits mailing list