[libc-commits] [libc] [libc] Remove cross-entrypoint dependencies from pthread_create (PR #225383)
via libc-commits
libc-commits at lists.llvm.org
Tue Sep 22 05:28:18 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Pavel Labath (labath)
<details>
<summary>Changes</summary>
pthread_create was previously calling public entrypoints (pthread_attr_init, pthread_attr_destroy, pthread_attr_getstack, pthread_attr_getguardsize, pthread_attr_getdetachstate), which violates the rule against internal cross-entrypoint dependencies.
To fix this, I create an internal header (src/pthread/pthread_attr.h) defining DEFAULT_PTHREAD_ATTR, modeled after DEFAULT_MUTEXATTR in the mutex code.
pthread_create now defaults to &DEFAULT_PTHREAD_ATTR when the attr pointer is null, and accesses the struct members directly instead of going through getter functions. This also makes it clear that getting the values cannot fail. I also update pthread_attr_init to reuse DEFAULT_PTHREAD_ATTR to avoid duplicating the default values.
While in there, update the includes to use proxy headers instead of including <pthread.h> directly, and drop the dependency on errno since pthread_create returns errors directly rather than setting errno.
Assisted-by: Gemini
---
Full diff: https://github.com/llvm/llvm-project/pull/225383.diff
4 Files Affected:
- (modified) libc/src/pthread/CMakeLists.txt (+21-10)
- (added) libc/src/pthread/pthread_attr.h (+38)
- (modified) libc/src/pthread/pthread_attr_init.cpp (+2-12)
- (modified) libc/src/pthread/pthread_create.cpp (+18-43)
``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````
</details>
https://github.com/llvm/llvm-project/pull/225383
More information about the libc-commits
mailing list