Skip to content

Commit 7ba9a73

Browse files
committed
Remove more _Atomic keywords from public headers
It's been thirteen years and C++ still hasn't implemented this wonderful simple builtin keyword. In C++23 a solution was provided for making this work in C++ which is libcxx's stdatomic.h. Including that header schleps in literally 253 unique header files!! Many of the header files it needs are libc header files like pthread.h where we need to have the _Atomic() keyword, but since <atomic> depends on pthreads we can't have it include the <stdatomic.h> header that defines _Atomic for C++ users, and instead we simply make the type non-atomic, hoping and praying only C code shall use those internal data structures. This just shows how STL clowns can't be trusted to define the innermost primitives of a language. They should instead be focusing on being the best at algorithms and data structures.
1 parent 4a1ae86 commit 7ba9a73

File tree

4 files changed

+4
-49
lines changed

4 files changed

+4
-49
lines changed

libc/thread/threads.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum {
2727
typedef uintptr_t thrd_t;
2828
typedef void (*tss_dtor_t)(void *);
2929
typedef int (*thrd_start_t)(void *);
30-
typedef _Atomic(uint32_t) once_flag;
30+
typedef uint32_t once_flag;
3131

3232
void call_once(once_flag *, void (*)(void));
3333
int thrd_create(thrd_t *, thrd_start_t, void *);

libc/type2str.h

Lines changed: 0 additions & 46 deletions
This file was deleted.

libc/x/x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ char *utf32to8(const wchar_t *, size_t, size_t *) __wur;
8181
char *xhomedir(void) __wur;
8282
char *xstripext(const char *) __wur;
8383
char *xstripexts(const char *) __wur;
84-
void *xload(_Atomic(void *) *, const void *, size_t, size_t);
84+
void *xload(void *, const void *, size_t, size_t);
8585
int rmrf(const char *);
8686
char *xbasename(const char *) paramsnonnull()
8787
returnspointerwithnoaliases dontthrow dontcallback __wur returnsnonnull;

libc/x/xload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
* @param m is byte length of inflated data
4141
* @return pointer to inflated data
4242
*/
43-
void *xload(_Atomic(void *) *a, const void *p, size_t n, size_t m) {
43+
void *xload(void *a_, const void *p, size_t n, size_t m) {
44+
_Atomic(void *) *a = (_Atomic(void *) *)a_;
4445
void *r, *z;
4546
if ((r = atomic_load_explicit(a, memory_order_acquire)))
4647
return r;

0 commit comments

Comments
 (0)