diff --git a/include/cia/sync.h b/include/cia/sync.h new file mode 100644 index 0000000..58336ac --- /dev/null +++ b/include/cia/sync.h @@ -0,0 +1,4 @@ + +#pragma once + + diff --git a/include/stdatomic.h b/include/stdatomic.h new file mode 100644 index 0000000..bda28ec --- /dev/null +++ b/include/stdatomic.h @@ -0,0 +1,13 @@ + +#pragma once + +#include +#include + +#if defined(__has_include_next) + #if __has_include_next() + #include_next + #else + #define __STDC_NO_ATOMICS__ + #endif +#endif diff --git a/include/stddef.h b/include/stddef.h index 8e6f00e..2a7ab5b 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -4,6 +4,7 @@ #include typedef u64 size_t; +typedef i64 ptrdiff_t; #if !defined(NULL) #define NULL ((void *)0) diff --git a/include/wchar.h b/include/wchar.h new file mode 100644 index 0000000..6bde1bc --- /dev/null +++ b/include/wchar.h @@ -0,0 +1,4 @@ + +#pragma once + +typedef u32 wchar_t; diff --git a/readme.md b/readme.md index 668e9b2..8ef6372 100644 --- a/readme.md +++ b/readme.md @@ -51,7 +51,7 @@ time is discouraged. | | Signal handling. | none | | | Alignment. | none | | | Variable arguments. | none | -| | Atomics. | none | +| | Atomics. | [1] | | | Bit and byte utilities | none | | | Boolean type and values. | none | | | Common definitions. | none | diff --git a/tests/threaded.c b/tests/threaded.c index 67f3f54..f34fe5c 100644 --- a/tests/threaded.c +++ b/tests/threaded.c @@ -2,6 +2,7 @@ #include #include #include +#include static void print_string_n(char *str, u64 len) { fwrite(str, 1, len, stdout); @@ -32,7 +33,7 @@ static void print_int(i64 number) { print_string(p); } -volatile i64 counter = 0; +volatile _Atomic i64 counter = 0; int thrd_func(void *arg) { print_string("child thread: ok!\n");