[libc-commits] [libc] [libc] Implement clone(2) and use it in thread spawning (PR #224257)
via libc-commits
libc-commits at lists.llvm.org
Thu Sep 17 03:33:15 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libc/src/__support/OSUtil/linux/syscall_wrappers/aarch64/clone.h libc/src/__support/OSUtil/linux/syscall_wrappers/clone.h libc/src/__support/OSUtil/linux/syscall_wrappers/riscv/clone.h libc/src/__support/OSUtil/linux/syscall_wrappers/x86_64/clone.h libc/src/sched/clone.h libc/src/sched/linux/clone.cpp libc/test/src/sched/linux/clone_test.cpp libc/src/__support/threads/linux/thread.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/__support/threads/linux/thread.cpp b/libc/src/__support/threads/linux/thread.cpp
index 6582e599e..df294e2e4 100644
--- a/libc/src/__support/threads/linux/thread.cpp
+++ b/libc/src/__support/threads/linux/thread.cpp
@@ -208,8 +208,8 @@ int Thread::run(ThreadStyle style, ThreadRunner runner, void *arg, void *stack,
// stack we pass to the clone syscall. Thread initialization structures
// (StartArgs, ThreadAttributes, and the clear_tid Futex) are allocated on
// the new thread's stack memory so their lifetime is managed with the stack
- // without requiring heap allocation. A pointer to StartArgs is passed directly
- // to start_thread via the clone syscall wrapper's argument.
+ // without requiring heap allocation. A pointer to StartArgs is passed
+ // directly to start_thread via the clone syscall wrapper's argument.
static constexpr size_t INTERNAL_STACK_DATA_SIZE =
sizeof(StartArgs) + sizeof(ThreadAttributes) + sizeof(Futex);
diff --git a/libc/test/src/sched/linux/clone_test.cpp b/libc/test/src/sched/linux/clone_test.cpp
index 6ed553692..9a0430a97 100644
--- a/libc/test/src/sched/linux/clone_test.cpp
+++ b/libc/test/src/sched/linux/clone_test.cpp
@@ -156,8 +156,7 @@ TEST_F(LlvmLibcSchedCloneTest, ChildTidSeparateVm) {
TidArgs args;
args.parent_tid = LIBC_NAMESPACE::gettid();
void *stack_top = get_child_stack_top();
- pid_t pid =
- LIBC_NAMESPACE::clone(check_tid_child, stack_top, SIGCHLD, &args);
+ pid_t pid = LIBC_NAMESPACE::clone(check_tid_child, stack_top, SIGCHLD, &args);
ASSERT_ERRNO_SUCCESS();
ASSERT_GT(pid, 0);
@@ -174,8 +173,8 @@ TEST_F(LlvmLibcSchedCloneTest, ChildTidSharedVm) {
TidArgs args;
args.parent_tid = LIBC_NAMESPACE::gettid();
void *stack_top = get_child_stack_top();
- pid_t pid = LIBC_NAMESPACE::clone(
- check_tid_child, stack_top, CLONE_VM | CLONE_VFORK | SIGCHLD, &args);
+ pid_t pid = LIBC_NAMESPACE::clone(check_tid_child, stack_top,
+ CLONE_VM | CLONE_VFORK | SIGCHLD, &args);
ASSERT_ERRNO_SUCCESS();
ASSERT_GT(pid, 0);
``````````
</details>
https://github.com/llvm/llvm-project/pull/224257
More information about the libc-commits
mailing list