From 4fa13e4132cf8adb2f07bb34927e62e525c8cc79 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sat, 2 Sep 2023 15:34:29 -0400 Subject: Move libultra function declarations to libultra headers (#1196) * Delete unused headers * Move PR and io to ultra64 * move headers to ultra64 * more cleanups * more reorganizing * i think that should be all * format * ifdef guards cleanup * Add IO_READ and IO_WRITE macros for future use * warnings * review Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * warnings again * warn * ifdef guards * fix merge * fix merge * fix merge * bss * padutils.h * bss * bss * bss * fix merge * bss * bss * bss * fix merge * fixes * fixes * bss * bss * fix merge * fix * fix * fix includepaths * fix paths * bss * fix * ultra64/ -> PR/ * header guards * fix ehader guards * fix * fix++ * format * bss is borken * prevent 2 * :despair: * bss * rename assert to dbg_hungup * fix * a * fix * bss * fix * bss * bss --------- Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> --- include/libc/alloca.h | 4 ++-- include/libc/assert.h | 4 ---- include/libc/math.h | 10 ++++++---- include/libc/stdarg.h | 6 ++---- include/libc/stdbool.h | 4 ++-- include/libc/stddef.h | 4 ++-- include/libc/stdint.h | 4 ++-- include/libc/stdlib.h | 7 +++++-- include/libc/string.h | 12 ++++++++++++ 9 files changed, 33 insertions(+), 22 deletions(-) delete mode 100644 include/libc/assert.h create mode 100644 include/libc/string.h (limited to 'include/libc') diff --git a/include/libc/alloca.h b/include/libc/alloca.h index 4e8720f7e..fa49dd133 100644 --- a/include/libc/alloca.h +++ b/include/libc/alloca.h @@ -1,5 +1,5 @@ -#ifndef ALLOCA_H -#define ALLOCA_H +#ifndef LIBC_ALLOCA_H +#define LIBC_ALLOCA_H void* alloca(u32); #define alloca __builtin_alloca diff --git a/include/libc/assert.h b/include/libc/assert.h deleted file mode 100644 index 1bc72e314..000000000 --- a/include/libc/assert.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef ASSERT_H -#define ASSERT_H - -#endif diff --git a/include/libc/math.h b/include/libc/math.h index 1cdac0fb3..618ab52b5 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -1,5 +1,5 @@ -#ifndef MATH_H -#define MATH_H +#ifndef LIBC_MATH_H +#define LIBC_MATH_H #include "PR/ultratypes.h" @@ -27,8 +27,10 @@ extern f32 __libm_qnan_f; float fabsf(float f); #pragma intrinsic(fabsf) -float sqrtf(float f); -#pragma intrinsic(sqrtf) +#ifdef __GNUC__ +#define fabsf(f) __builtin_fabsf((float)(f)) +#endif + double sqrt(double d); #pragma intrinsic(sqrt) diff --git a/include/libc/stdarg.h b/include/libc/stdarg.h index 77b8b8866..55f694385 100644 --- a/include/libc/stdarg.h +++ b/include/libc/stdarg.h @@ -1,7 +1,5 @@ -#ifndef STDARG_H -#define STDARG_H - -#include "ultra64.h" +#ifndef LIBC_STDARG_H +#define LIBC_STDARG_H // When building with GCC, use the official vaarg macros to avoid warnings // and possibly bad codegen. diff --git a/include/libc/stdbool.h b/include/libc/stdbool.h index d441054c1..52546edb3 100644 --- a/include/libc/stdbool.h +++ b/include/libc/stdbool.h @@ -1,5 +1,5 @@ -#ifndef STDBOOL -#define STDBOOL +#ifndef LIBC_STDBOOL_H +#define LIBC_STDBOOL_H #define __bool_true_false_are_defined 1 diff --git a/include/libc/stddef.h b/include/libc/stddef.h index 4f55e5725..e867d8e2a 100644 --- a/include/libc/stddef.h +++ b/include/libc/stddef.h @@ -1,5 +1,5 @@ -#ifndef STDDEF_H -#define STDDEF_H +#ifndef LIBC_STDDEF_H +#define LIBC_STDDEF_H #include "PR/ultratypes.h" diff --git a/include/libc/stdint.h b/include/libc/stdint.h index 20288d40d..854fd2546 100644 --- a/include/libc/stdint.h +++ b/include/libc/stdint.h @@ -1,5 +1,5 @@ -#ifndef STDINT_H -#define STDINT_H +#ifndef LIBC_STDINT_H +#define LIBC_STDINT_H #include "PR/ultratypes.h" diff --git a/include/libc/stdlib.h b/include/libc/stdlib.h index 57d352a13..ec15b4f6c 100644 --- a/include/libc/stdlib.h +++ b/include/libc/stdlib.h @@ -1,5 +1,5 @@ -#ifndef STDLIB_H -#define STDLIB_H +#ifndef LIBC_STDLIB_H +#define LIBC_STDLIB_H #include "libc/stddef.h" @@ -22,4 +22,7 @@ typedef int ssize_t; typedef long wchar_t; +ldiv_t ldiv(long numer, long denom); +lldiv_t lldiv(long long numer, long long denom); + #endif /* STDLIB_H */ diff --git a/include/libc/string.h b/include/libc/string.h new file mode 100644 index 000000000..9c6a1cb08 --- /dev/null +++ b/include/libc/string.h @@ -0,0 +1,12 @@ +#ifndef LIBC_STRING_H +#define LIBC_STRING_H + +#include "libc/stddef.h" + + +const char* strchr(const char* s, int c); +size_t strlen(const char* s); +void* memcpy(void* s1, const void* s2, size_t n); + + +#endif -- cgit v1.2.3