Skip to content

Commit

Permalink
Remove more _Atomic keywords from public headers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jart committed Jul 24, 2024
1 parent 4a1ae86 commit 7ba9a73
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 49 deletions.
2 changes: 1 addition & 1 deletion libc/thread/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum {
typedef uintptr_t thrd_t;
typedef void (*tss_dtor_t)(void *);
typedef int (*thrd_start_t)(void *);
typedef _Atomic(uint32_t) once_flag;
typedef uint32_t once_flag;

void call_once(once_flag *, void (*)(void));
int thrd_create(thrd_t *, thrd_start_t, void *);
Expand Down
46 changes: 0 additions & 46 deletions libc/type2str.h

This file was deleted.

2 changes: 1 addition & 1 deletion libc/x/x.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ char *utf32to8(const wchar_t *, size_t, size_t *) __wur;
char *xhomedir(void) __wur;
char *xstripext(const char *) __wur;
char *xstripexts(const char *) __wur;
void *xload(_Atomic(void *) *, const void *, size_t, size_t);
void *xload(void *, const void *, size_t, size_t);
int rmrf(const char *);
char *xbasename(const char *) paramsnonnull()
returnspointerwithnoaliases dontthrow dontcallback __wur returnsnonnull;
Expand Down
3 changes: 2 additions & 1 deletion libc/x/xload.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
* @param m is byte length of inflated data
* @return pointer to inflated data
*/
void *xload(_Atomic(void *) *a, const void *p, size_t n, size_t m) {
void *xload(void *a_, const void *p, size_t n, size_t m) {
_Atomic(void *) *a = (_Atomic(void *) *)a_;
void *r, *z;
if ((r = atomic_load_explicit(a, memory_order_acquire)))
return r;
Expand Down

0 comments on commit 7ba9a73

Please sign in to comment.