summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2024-12-14 02:28:22 +0000
committerGitHub <noreply@github.com>2024-12-13 18:28:22 -0800
commit01a1b113b40fedea4f95753275e28a9838c60591 (patch)
treeeba925634bacbc038ee0a512f3acb1de392bdbaa /include
parentfc8d1165c8beb6d6d54b54c2a56387c99b8d7861 (diff)
libultra/libc cleanup (#1757)
* libultra/libc cleanup * Format * Correct prototype for strchr * Different prototypes for bzero, bcmp, bcopy under __GNUC__ to match builtin prototypes * Correct alloca prototype
Diffstat (limited to 'include')
-rw-r--r--include/PR/os_libc.h11
-rw-r--r--include/PR/xstdio.h50
-rw-r--r--include/libc/alloca.h4
-rw-r--r--include/libc/stddef.h4
-rw-r--r--include/libc/string.h2
5 files changed, 43 insertions, 28 deletions
diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h
index dfbf6cd43..aaff9fea9 100644
--- a/include/PR/os_libc.h
+++ b/include/PR/os_libc.h
@@ -3,10 +3,15 @@
#include "stdarg.h"
-
-void bcopy(void* __src, void* __dest, int __n);
-int bcmp(void* __s1, void* __s2, int __n);
+#ifdef __GNUC__
+void bzero(void* begin, unsigned int length);
+int bcmp(const void* __s1, const void* __s2, unsigned int __n);
+void bcopy(const void* __src, void* __dest, unsigned int __n);
+#else
void bzero(void* begin, int length);
+int bcmp(const void* __s1, const void* __s2, int __n);
+void bcopy(const void* __src, void* __dest, int __n);
+#endif
void osSyncPrintf(const char* fmt, ...);
diff --git a/include/PR/xstdio.h b/include/PR/xstdio.h
index 34d02ddeb..a2541ab4a 100644
--- a/include/PR/xstdio.h
+++ b/include/PR/xstdio.h
@@ -1,38 +1,44 @@
#ifndef PR_XSTDIO_H
#define PR_XSTDIO_H
-#include "ultratypes.h"
#include "stdarg.h"
+// IDO doesn't support long double types, improve portability for compilers supporting them
+#ifdef __sgi
+#define LONG_DOUBLE_TYPE double
+#else
+#define LONG_DOUBLE_TYPE long double
+#endif
+
typedef struct {
- /* 0x0 */ union {
- /* 0x0 */ s64 ll;
- /* 0x0 */ f64 ld;
+ /* 0x00 */ union {
+ long long ll;
+ LONG_DOUBLE_TYPE ld;
} v;
- /* 0x8 */ char* s;
- /* 0xC */ s32 n0;
- /* 0x10 */ s32 nz0;
- /* 0x14 */ s32 n1;
- /* 0x18 */ s32 nz1;
- /* 0x1C */ s32 n2;
- /* 0x20 */ s32 nz2;
- /* 0x24 */ s32 prec;
- /* 0x28 */ s32 width;
+ /* 0x08 */ char* s;
+ /* 0x0C */ int n0;
+ /* 0x10 */ int nz0;
+ /* 0x14 */ int n1;
+ /* 0x18 */ int nz1;
+ /* 0x1C */ int n2;
+ /* 0x20 */ int nz2;
+ /* 0x24 */ int prec;
+ /* 0x28 */ int width;
/* 0x2C */ size_t nchar;
- /* 0x30 */ u32 flags;
- /* 0x34 */ u8 qual;
+ /* 0x30 */ unsigned int flags;
+ /* 0x34 */ char qual;
} _Pft;
typedef void* (*PrintCallback)(void*, const char*, size_t);
-#define FLAGS_SPACE 1
-#define FLAGS_PLUS 2
-#define FLAGS_MINUS 4
-#define FLAGS_HASH 8
-#define FLAGS_ZERO 16
+#define FLAGS_SPACE (1 << 0)
+#define FLAGS_PLUS (1 << 1)
+#define FLAGS_MINUS (1 << 2)
+#define FLAGS_HASH (1 << 3)
+#define FLAGS_ZERO (1 << 4)
int _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap);
-void _Litob(_Pft* args, u8 type);
-void _Ldtob(_Pft* args, u8 type);
+void _Litob(_Pft* args, char code);
+void _Ldtob(_Pft* args, char code);
#endif
diff --git a/include/libc/alloca.h b/include/libc/alloca.h
index fa49dd133..dabd6bcd5 100644
--- a/include/libc/alloca.h
+++ b/include/libc/alloca.h
@@ -1,7 +1,7 @@
#ifndef LIBC_ALLOCA_H
#define LIBC_ALLOCA_H
-void* alloca(u32);
-#define alloca __builtin_alloca
+void* alloca(size_t);
+#define alloca(size) __builtin_alloca(size)
#endif
diff --git a/include/libc/stddef.h b/include/libc/stddef.h
index 3b4ed699c..604352fd3 100644
--- a/include/libc/stddef.h
+++ b/include/libc/stddef.h
@@ -1,6 +1,10 @@
#ifndef LIBC_STDDEF_H
#define LIBC_STDDEF_H
+#ifndef NULL
+#define NULL ((void*)0)
+#endif
+
#if !defined(_SIZE_T)
#define _SIZE_T
#if defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64)
diff --git a/include/libc/string.h b/include/libc/string.h
index 8c6139f3c..fa95a5312 100644
--- a/include/libc/string.h
+++ b/include/libc/string.h
@@ -3,7 +3,7 @@
#include "stddef.h"
-const char* strchr(const char* s, int c);
+char* strchr(const char* s, int c);
size_t strlen(const char* s);
void* memcpy(void* s1, const void* s2, size_t n);