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
This commit is contained in:
Tharo
2024-12-14 02:28:22 +00:00
committed by GitHub
parent fc8d1165c8
commit 01a1b113b4
12 changed files with 263 additions and 251 deletions
+8 -3
View File
@@ -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, ...);
+28 -22
View File
@@ -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
+2 -2
View File
@@ -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
+4
View File
@@ -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)
+1 -1
View File
@@ -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);