summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2021-11-05 23:44:58 -0300
committerGitHub <noreply@github.com>2021-11-05 23:44:58 -0300
commite70a8fbb992eb05d606406ae70974e56bcf912dc (patch)
treedd94abeae41e75bb177bd7e4c3a04bc38262f20f /include
parent49f55ff0052340d29cffe2767fdc7d2ee5adb9f4 (diff)
Add `stddef.h` and libc headers cleanup (#396)
* Move headers to include/libc * stddef * move math.h * General cleanup * move fabs, sqrtf and sqrt to math.h * move alloca and assert * whoops
Diffstat (limited to 'include')
-rw-r--r--include/assert.h4
-rw-r--r--include/convert.h2
-rw-r--r--include/functions.h7
-rw-r--r--include/ichain.h6
-rw-r--r--include/libc/alloca.h (renamed from include/alloca.h)0
-rw-r--r--include/libc/assert.h4
-rw-r--r--include/libc/math.h (renamed from include/math.h)11
-rw-r--r--include/libc/stdarg.h (renamed from include/stdarg.h)9
-rw-r--r--include/libc/stdbool.h (renamed from include/stdbool.h)6
-rw-r--r--include/libc/stddef.h20
-rw-r--r--include/libc/stdint.h (renamed from include/stdint.h)8
-rw-r--r--include/libc/stdlib.h (renamed from include/stdlib.h)12
-rw-r--r--include/macros.h2
-rw-r--r--include/os.h2
-rw-r--r--include/osint.h2
-rw-r--r--include/xstdio.h3
-rw-r--r--include/z64.h11
17 files changed, 65 insertions, 44 deletions
diff --git a/include/assert.h b/include/assert.h
deleted file mode 100644
index 04831e48f..000000000
--- a/include/assert.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef _ASSERT_H_
-#define _ASSERT_H_
-
-#endif
diff --git a/include/convert.h b/include/convert.h
index 456e4b198..c453e18e3 100644
--- a/include/convert.h
+++ b/include/convert.h
@@ -1,7 +1,7 @@
#ifndef _ULTRA64_CONVERT_H_
#define _ULTRA64_CONVERT_H_
-#include "stdint.h"
+#include "libc/stdint.h"
#define OS_CLOCK_RATE 62500000LL
#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4)
diff --git a/include/functions.h b/include/functions.h
index 1cacc5fed..ad01b7a82 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -3,13 +3,6 @@
#include "z64.h"
-float fabsf(float f);
-#pragma intrinsic(fabsf)
-float sqrtf(float f);
-#pragma intrinsic(sqrtf)
-double sqrt(double d);
-#pragma intrinsic(sqrt)
-
void bootproc(void);
void Idle_ThreadEntry(void* arg);
void ViConfig_UpdateVi(u32 arg0);
diff --git a/include/ichain.h b/include/ichain.h
index 8b1112191..f9131545c 100644
--- a/include/ichain.h
+++ b/include/ichain.h
@@ -1,6 +1,8 @@
#ifndef _ICHAIN_H_
#define _ICHAIN_H_
+#include "libc/stddef.h"
+
typedef struct {
u32 cont: 1;
u32 type: 4;
@@ -8,8 +10,6 @@ typedef struct {
s32 value: 16;
} InitChainEntry;
-#define OFFSETOF(structure, member) ((size_t)&(((structure*)0)->member))
-
typedef enum {
/* 0x0 */ ICHAINTYPE_U8, // sets byte
/* 0x1 */ ICHAINTYPE_S8,
@@ -38,7 +38,7 @@ typedef enum {
* * cont ----- ICHAIN_CONTINUE (or ICHAIN_STOP) to continue (or stop) parsing
*/
#define ICHAIN(type, member, value, cont) \
- { cont, type, OFFSETOF(Actor, member), value }
+ { cont, type, offsetof(Actor, member), value }
#define ICHAIN_U8(member, val, cont) ICHAIN(ICHAINTYPE_U8, member, val, cont)
#define ICHAIN_S8(member, val, cont) ICHAIN(ICHAINTYPE_S8, member, val, cont)
diff --git a/include/alloca.h b/include/libc/alloca.h
index 4e8720f7e..4e8720f7e 100644
--- a/include/alloca.h
+++ b/include/libc/alloca.h
diff --git a/include/libc/assert.h b/include/libc/assert.h
new file mode 100644
index 000000000..1bc72e314
--- /dev/null
+++ b/include/libc/assert.h
@@ -0,0 +1,4 @@
+#ifndef ASSERT_H
+#define ASSERT_H
+
+#endif
diff --git a/include/math.h b/include/libc/math.h
index 20fa352fa..c6756d959 100644
--- a/include/math.h
+++ b/include/libc/math.h
@@ -1,5 +1,5 @@
-#ifndef _MATH_H_
-#define _MATH_H_
+#ifndef MATH_H
+#define MATH_H
#include "PR/ultratypes.h"
@@ -26,4 +26,11 @@ typedef union {
extern f32 __libm_qnan_f;
+float fabsf(float f);
+#pragma intrinsic(fabsf)
+float sqrtf(float f);
+#pragma intrinsic(sqrtf)
+double sqrt(double d);
+#pragma intrinsic(sqrt)
+
#endif
diff --git a/include/stdarg.h b/include/libc/stdarg.h
index 26a67e580..77b8b8866 100644
--- a/include/stdarg.h
+++ b/include/libc/stdarg.h
@@ -1,5 +1,5 @@
-#ifndef _STDARG_H_
-#define _STDARG_H_
+#ifndef STDARG_H
+#define STDARG_H
#include "ultra64.h"
@@ -41,5 +41,6 @@ typedef char *va_list;
: __va_stack_arg(list, mode))))[-1]
#define va_end(__list)
-#endif
-#endif
+#endif /* __GNUC__ */
+
+#endif /* STDARG_H */
diff --git a/include/stdbool.h b/include/libc/stdbool.h
index 519806b31..d441054c1 100644
--- a/include/stdbool.h
+++ b/include/libc/stdbool.h
@@ -1,5 +1,5 @@
-#ifndef _STDBOOL
-#define _STDBOOL
+#ifndef STDBOOL
+#define STDBOOL
#define __bool_true_false_are_defined 1
@@ -11,4 +11,4 @@
#endif /* __cplusplus */
-#endif /* _STDBOOL */
+#endif /* STDBOOL */
diff --git a/include/libc/stddef.h b/include/libc/stddef.h
new file mode 100644
index 000000000..4f55e5725
--- /dev/null
+++ b/include/libc/stddef.h
@@ -0,0 +1,20 @@
+#ifndef STDDEF_H
+#define STDDEF_H
+
+#include "PR/ultratypes.h"
+
+typedef u32 size_t;
+
+typedef s32 ptrdiff_t;
+
+#ifndef NULL
+#define NULL (void*)0
+#endif
+
+#ifdef __GNUC__
+#define offsetof(structure, member) __builtin_offsetof (structure, member)
+#else
+#define offsetof(structure, member) ((size_t)&(((structure*)0)->member))
+#endif
+
+#endif /* STDDEF_H */
diff --git a/include/stdint.h b/include/libc/stdint.h
index 67e9e6862..1696615a7 100644
--- a/include/stdint.h
+++ b/include/libc/stdint.h
@@ -1,7 +1,7 @@
-#ifndef _STDINT_H_
-#define _STDINT_H_
+#ifndef STDINT_H
+#define STDINT_H
-#include "ultra64.h"
+#include "PR/ultratypes.h"
typedef s32 intptr_t;
typedef u32 uintptr_t;
@@ -26,4 +26,4 @@ typedef u32 uintptr_t;
#define UINTPTR_MAX 0xffffffff
-#endif /* _STDINT_H_ */
+#endif /* STDINT_H */
diff --git a/include/stdlib.h b/include/libc/stdlib.h
index a7b44961a..57d352a13 100644
--- a/include/stdlib.h
+++ b/include/libc/stdlib.h
@@ -1,27 +1,25 @@
-#ifndef _STDLIB_H_
-#define _STDLIB_H_
+#ifndef STDLIB_H
+#define STDLIB_H
+
+#include "libc/stddef.h"
typedef struct {
/* 0x0 */ int quot;
/* 0x4 */ int rem;
} div_t;
-
typedef struct {
/* 0x0 */ long quot;
/* 0x4 */ long rem;
} ldiv_t;
-
typedef struct {
/* 0x0 */ long long quot;
/* 0x8 */ long long rem;
} lldiv_t;
-typedef unsigned long size_t;
-
typedef int ssize_t;
typedef long wchar_t;
-#endif
+#endif /* STDLIB_H */
diff --git a/include/macros.h b/include/macros.h
index 7dd84fc8e..2cff3c814 100644
--- a/include/macros.h
+++ b/include/macros.h
@@ -1,7 +1,7 @@
#ifndef _MACROS_H_
#define _MACROS_H_
-#include "stdint.h"
+#include "libc/stdint.h"
#include "convert.h"
#include "z64.h"
diff --git a/include/os.h b/include/os.h
index f89239874..e9a5da37d 100644
--- a/include/os.h
+++ b/include/os.h
@@ -1,7 +1,7 @@
#ifndef _OS_H_
#define _OS_H_
-#include "stdlib.h"
+#include "libc/stdlib.h"
#include "ultra64/thread.h"
#include "ultra64/message.h"
diff --git a/include/osint.h b/include/osint.h
index f4da044c6..71781ab6d 100644
--- a/include/osint.h
+++ b/include/osint.h
@@ -3,7 +3,7 @@
// TODO should be in libultra/os
-#include "stdarg.h"
+#include "libc/stdarg.h"
#include "os.h"
#include "os_internal.h"
#include "ultraerror.h"
diff --git a/include/xstdio.h b/include/xstdio.h
index bb297e590..102a25ee4 100644
--- a/include/xstdio.h
+++ b/include/xstdio.h
@@ -1,6 +1,7 @@
#ifndef _XSTDIO_H_
#define _XSTDIO_H_
-#include "stdarg.h"
+
+#include "libc/stdarg.h"
typedef struct {
/* 0x0 */ union {
diff --git a/include/z64.h b/include/z64.h
index 6def660e0..99f05d653 100644
--- a/include/z64.h
+++ b/include/z64.h
@@ -1,16 +1,17 @@
#ifndef _Z64_H_
#define _Z64_H_
-#include "stdarg.h"
-#include "stdbool.h"
-#include "stdint.h"
+#include "libc/math.h"
+#include "libc/stdarg.h"
+#include "libc/stdbool.h"
+#include "libc/stddef.h"
+#include "libc/stdint.h"
+#include "libc/stdlib.h"
#include "ultra64.h"
#include "io/controller.h"
#include "osint.h"
-#include "math.h"
#include "os.h"
-#include "stdlib.h"
#include "xstdio.h"
#include "bgm.h"