Skip to content

Commit f178feb

Browse files
committed
Added stdbool, stddef, and stdint.
1 parent 2f21dba commit f178feb

5 files changed

Lines changed: 95 additions & 10 deletions

File tree

src/ce-libc/bits/wchar_t.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#ifndef __cplusplus
4+
5+
typedef __WCHAR_TYPE__ wchar_t;
6+
7+
#endif

src/ce-libc/stdbool.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include "_prelude.h"
4+
5+
STDC_BEGIN_HEADER
6+
7+
#if __STDC_VERSION__ < 201700L && !defined(__cplusplus)
8+
9+
typedef _Bool bool;
10+
11+
# define true ((bool)1)
12+
# define false ((bool)0)
13+
14+
#endif
15+
16+
STDC_END_HEADER

src/ce-libc/stddef.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include "_prelude.h"
4+
5+
STDC_BEGIN_HEADER
6+
7+
#define NULL ((void *)0)
8+
9+
typedef __SIZE_TYPE__ size_t;
10+
11+
typedef __PTRDIFF_TYPE__ ptrdiff_t;
12+
13+
STDC_END_HEADER

src/ce-libc/stdint.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#pragma once
2+
3+
#include "_prelude.h"
4+
5+
STDC_BEGIN_HEADER
6+
7+
typedef __INT8_TYPE__ int8_t;
8+
typedef __INT16_TYPE__ int16_t;
9+
typedef __INT32_TYPE__ int32_t;
10+
typedef __INT64_TYPE__ int64_t;
11+
12+
typedef __UINT8_TYPE__ uint8_t;
13+
typedef __UINT16_TYPE__ uint16_t;
14+
typedef __UINT32_TYPE__ uint32_t;
15+
typedef __UINT64_TYPE__ uint64_t;
16+
17+
typedef __INTPTR_TYPE__ intptr_t;
18+
typedef __UINTPTR_TYPE__ uintptr_t;
19+
20+
typedef __INTMAX_TYPE__ intmax_t;
21+
typedef __UINTMAX_TYPE__ uintmax_t;
22+
23+
typedef __INT_LEAST8_TYPE__ int_least8_t;
24+
typedef __INT_LEAST16_TYPE__ int_least16_t;
25+
typedef __INT_LEAST32_TYPE__ int_least32_t;
26+
typedef __INT_LEAST64_TYPE__ int_least64_t;
27+
28+
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
29+
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
30+
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
31+
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
32+
33+
typedef __INT_FAST8_TYPE__ int_fast8_t;
34+
typedef __INT_FAST16_TYPE__ int_fast16_t;
35+
typedef __INT_FAST32_TYPE__ int_fast32_t;
36+
typedef __INT_FAST64_TYPE__ int_fast64_t;
37+
38+
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
39+
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
40+
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
41+
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
42+
43+
STDC_END_HEADER

src/ce-libc/stdlib.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#pragma once
22

33
#include "_prelude.h"
4+
45
#include <stddef.h>
56

7+
#include "bits/wchar_t.h"
8+
69
STDC_BEGIN_HEADER
710

811
/* --- 7.22 - General utilities --------------------------------------------- */
912

1013
#ifndef NULL
11-
#define NULL ((void *)0)
14+
# define NULL ((void *)0)
1215
#endif
1316

1417
#define EXIT_FAILURE (-1)
@@ -18,19 +21,22 @@ STDC_BEGIN_HEADER
1821
#define RAND_MAX (32767)
1922

2023
#define MB_CUR_MA (0) // undefined for the moment
21-
typedef struct {
22-
int quot;
23-
int rem;
24+
typedef struct
25+
{
26+
int quot;
27+
int rem;
2428
} div_t;
2529

26-
typedef struct {
27-
long quot;
28-
long rem;
30+
typedef struct
31+
{
32+
long quot;
33+
long rem;
2934
} ldiv_t;
3035

31-
typedef struct {
32-
long long quot;
33-
long long rem;
36+
typedef struct
37+
{
38+
long long quot;
39+
long long rem;
3440
} lldiv_t;
3541

3642
/* --- 7.22.1 - Numeric conversion functions -------------------------------- */

0 commit comments

Comments
 (0)