stdatomic.h

This commit is contained in:
flysand7 2023-08-26 22:35:18 +11:00
parent 8f739d3a10
commit fa1f9ec0e6
6 changed files with 25 additions and 2 deletions

4
include/cia/sync.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once

13
include/stdatomic.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include <wchar.h>
#include <stddef.h>
#if defined(__has_include_next)
#if __has_include_next(<stdatomic.h>)
#include_next <stdatomic.h>
#else
#define __STDC_NO_ATOMICS__
#endif
#endif

View File

@ -4,6 +4,7 @@
#include <cia/def.h>
typedef u64 size_t;
typedef i64 ptrdiff_t;
#if !defined(NULL)
#define NULL ((void *)0)

4
include/wchar.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
typedef u32 wchar_t;

View File

@ -51,7 +51,7 @@ time is discouraged.
| <signal.h> | Signal handling. | none |
| <stdalign.h> | Alignment. | none |
| <stdarg.h> | Variable arguments. | none |
| <stdatomic.h> | Atomics. | none |
| <stdatomic.h> | Atomics. | [1] |
| <stdbit.h> | Bit and byte utilities | none |
| <stdbool.h> | Boolean type and values. | none |
| <stddef.h> | Common definitions. | none |

View File

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
#include <stdatomic.h>
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");