Open paranlee opened 11 months ago
This might be doable, but we must do heavy testing if we replace the existing pthread code. This might be a risky work without those testing.
Do all compilers and C libraries support C11 thread APIs now?
I tested thrd_*
on GCC, Clang but i need to examining the evidence for the proof.
thred.h
and thrd_*
We can find n1548 standard [1].
7.25.5 Thread functions 7.25.5.1 The thrd_create function Synopsis
1 #include
int thrd_create(thrd_t thr, thrd_start_t func, void arg);
Description
2 The thrd_create function creates a new thread executing func(arg). If the thrd_create function succeeds, it sets the object pointed to by thr to the identifier of the newly created thread. (A thread’s identifier may be reused for a different thread once the original thread has exited and either been detached or joined to another thread.) The completion of the thrd_create function synchronizes with the beginning of the execution of the new thread.
Returns
3 The thrd_create function returns thrd_success on success, or thrd_nomem if no memory could be allocated for the thread requested, or thrd_error if the request could not be honored.
Support for the standard ISO/IEC 9899:2011 (C11) in GCC (draft n1570, PDF)
GCC 4.9 Changes: “ISO C11 support is now at a similar level of completeness to ISO C99 support [2].
Threading [Optional] | Library issue (glibc 2.28, musl 1.1.5)
thread.h
Support commit [3]
Test Case For C11 Standard [4]
bionic - threads.h: Add C11 thread support [6].
Product: glibc
Component: nptl
Version: 2.15
glibc - thread.h
Support [5]
C11
There clang -fsanitize=thread
option, but not working on C11 issue [9].
NOTE: Many of -fsanitize=...
[10]
[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf [2] https://gcc.gnu.org/wiki/C11Status [3] https://github.com/llvm/llvm-project/commit/fe8017476c7788806859a0fbac0c82be38874b47 [4] https://github.com/llvm/llvm-project/tree/main/clang/test/C/C11 [5] https://sourceware.org/bugzilla/show_bug.cgi?id=14092#c10 [6] https://android.googlesource.com/platform/bionic/+/420671135237cdf40c98d2336fb8712b7f0a2861 [7] https://www.phoronix.com/news/MTgyMzM [8] https://reviews.llvm.org/rGab506adf7d3ced6abcaf42f92de3d6cd15fa19e8 [9] https://github.com/google/sanitizers/issues/1603 [10] https://github.com/llvm/llvm-project/commit/279a4d0d67c874e80c171666822f2fabdd6fa926
C11 Standard
thrd
thrd
thread support in the C11 standard. Since the Linux kernel is also being refactored to C11, How we think about the proposal to refactorpthread_*
tothrd
for a future development?