[libc-commits] [PATCH] D75380: [libc] Add linux implementations of thrd_create and thrd_join functions.
Petr Hosek via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Mar 5 12:07:09 PST 2020
phosek accepted this revision.
phosek added a comment.
LGTM
================
Comment at: libc/src/threads/linux/thrd_create.cpp:50
+ if (stack == MAP_FAILED) {
+ if (llvmlibc_errno == ENOMEM)
+ return thrd_nomem;
----------------
Nit: this might be more readable as a ternary expression.
================
Comment at: libc/src/threads/linux/thrd_create.cpp:65
+ SYS_clone, clone_flags,
+ (uintptr_t)stack + ThreadParams::DefaultStackSize - 1, &thread->__tid,
+ clear_tid_address, 0);
----------------
`reinterpret_cast<uintptr_t>(stack)` instead of C-style cast.
================
Comment at: libc/src/threads/linux/thrd_create.cpp:71
+
+ if (clone_result < 0) {
+ int error_val = -clone_result;
----------------
Could this be `else if (clone_result < 0)`? `clone_result` cannot be `== 0` and `< 0` at the same time so those cases are disjoint.
================
Comment at: libc/src/threads/linux/thrd_create.cpp:73
+ int error_val = -clone_result;
+ if (error_val == ENOMEM)
+ return thrd_nomem;
----------------
Nit: the same here, ternary expression would be more readable.
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