[libc-commits] [PATCH] D75380: [libc] Add linux implementations of thrd_create and thrd_join functions.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Mar 2 12:03:54 PST 2020


sivachandra added inline comments.


================
Comment at: libc/src/threads/linux/thrd_create.cpp:27
+
+static void start_thread(thrd_t *thread, thrd_start_t func, void *arg) {
+  __llvm_libc::syscall(SYS_exit, thread->__retval = func(arg));
----------------
abrachet wrote:
> Make this `[[noreturn]]`
Sanitizers blow up at this point. I do not understand sanitizers enough yet to explain why. I will be sharing a more holistic treatment of sanitizers in LLVM-libc soon so I will try to include talking about this there.

FWIW, I have shared this problem with the sanitizer experts I have access to and they are investigating.


================
Comment at: libc/src/threads/linux/thrd_join.cpp:27
+
+  while (true) {
+    // We cannot do a FUTEX_WAIT_PRIVATE here as the kernel does a
----------------
abrachet wrote:
> Is it safe to do `while (atomic_load(clear_tid_address))`?
Should be fine so changed it to that.


================
Comment at: libc/src/threads/linux/thread_utils.h:16-18
+#define DEFAULT_STACK_SIZE (1 << 15) // 32 KB
+
+#define CLEAR_TID_VALUE 0xABCD1234
----------------
abrachet wrote:
> These can be `constexpr`
I created a struct with static members for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75380





More information about the libc-commits mailing list