mirror of
https://github.com/zeldaret/oot.git
synced 2025-10-20 13:40:02 +00:00
libc cleanup (#1568)
* libc cleanup * Suggested changes, small alloca tweak * Remove printf include
This commit is contained in:
parent
4e55168eaa
commit
3475651701
46 changed files with 571 additions and 432 deletions
|
@ -1,7 +0,0 @@
|
|||
#ifndef ALLOCA_H
|
||||
#define ALLOCA_H
|
||||
|
||||
void* alloca(u32);
|
||||
#define alloca __builtin_alloca
|
||||
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ATTRIBUTES_H
|
||||
#define ATTRIBUTES_H
|
||||
|
||||
#ifndef __GNUC__
|
||||
#if !defined(__GNUC__) && !defined(__attribute__)
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define FAULT_H
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "attributes.h"
|
||||
#include "padmgr.h"
|
||||
|
||||
// These are the same as the 3-bit ansi color codes
|
||||
|
|
34
include/fp.h
34
include/fp.h
|
@ -1,34 +0,0 @@
|
|||
#ifndef FP_H
|
||||
#define FP_H
|
||||
#include "ultra64.h"
|
||||
|
||||
extern f32 qNaN0x3FFFFF;
|
||||
extern f32 qNaN0x10000;
|
||||
extern f32 sNaN0x3FFFFF;
|
||||
|
||||
f32 floorf(f32 x);
|
||||
f64 floor(f64 x);
|
||||
s32 lfloorf(f32 x);
|
||||
s32 lfloor(f64 x);
|
||||
|
||||
f32 ceilf(f32 x);
|
||||
f64 ceil(f64 x);
|
||||
s32 lceilf(f32 x);
|
||||
s32 lceil(f64 x);
|
||||
|
||||
f32 truncf(f32 x);
|
||||
f64 trunc(f64 x);
|
||||
s32 ltruncf(f32 x);
|
||||
s32 ltrunc(f64 x);
|
||||
|
||||
f32 nearbyintf(f32 x);
|
||||
f64 nearbyint(f64 x);
|
||||
s32 lnearbyintf(f32 x);
|
||||
s32 lnearbyint(f64 x);
|
||||
|
||||
f32 roundf(f32 x);
|
||||
f64 round(f64 x);
|
||||
s32 lroundf(f32 x);
|
||||
s32 lround(f64 x);
|
||||
|
||||
#endif
|
|
@ -5,15 +5,21 @@
|
|||
#include "macros.h"
|
||||
|
||||
f32 fabsf(f32 f);
|
||||
#ifndef __sgi
|
||||
#define fabsf(f) __builtin_fabsf((f32)(f))
|
||||
#else
|
||||
#ifdef __sgi
|
||||
#pragma intrinsic(fabsf)
|
||||
#else
|
||||
#define fabsf(f) __builtin_fabsf((f32)(f))
|
||||
#endif
|
||||
|
||||
f32 sqrtf(f32 f);
|
||||
#ifdef __sgi
|
||||
#pragma intrinsic(sqrtf)
|
||||
#endif
|
||||
|
||||
f64 sqrt(f64 f);
|
||||
#ifdef __sgi
|
||||
#pragma intrinsic(sqrt)
|
||||
#endif
|
||||
|
||||
void cleararena(void);
|
||||
void bootproc(void);
|
||||
|
@ -30,12 +36,9 @@ void Locale_ResetRegion(void);
|
|||
u32 func_80001F48(void);
|
||||
u32 func_80001F8C(void);
|
||||
u32 Locale_IsRegionNative(void);
|
||||
NORETURN void __assert(const char* exp, const char* file, s32 line);
|
||||
void isPrintfInit(void);
|
||||
void osSyncPrintfUnused(const char* fmt, ...);
|
||||
void osSyncPrintf(const char* fmt, ...);
|
||||
void rmonPrintf(const char* fmt, ...);
|
||||
void* is_proutSyncPrintf(void* arg, const char* str, u32 count);
|
||||
void* is_proutSyncPrintf(void* arg, const char* str, size_t count);
|
||||
NORETURN void func_80002384(const char* exp, const char* file, u32 line);
|
||||
OSPiHandle* osDriveRomInit(void);
|
||||
void Mio0_Decompress(Yaz0Header* hdr, u8* dst);
|
||||
|
@ -57,8 +60,6 @@ void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, s3
|
|||
void LogUtils_LogThreadId(const char* name, s32 line);
|
||||
void LogUtils_HungupThread(const char* name, s32 line);
|
||||
void LogUtils_ResetHungup(void);
|
||||
s32 vsprintf(char* dst, const char* fmt, va_list args);
|
||||
s32 sprintf(char* dst, const char* fmt, ...);
|
||||
void __osPiCreateAccessQueue(void);
|
||||
void __osPiGetAccess(void);
|
||||
void __osPiRelAccess(void);
|
||||
|
@ -75,7 +76,6 @@ void __osDispatchThread(void);
|
|||
void __osCleanupThread(void);
|
||||
void __osDequeueThread(OSThread** queue, OSThread* thread);
|
||||
void osDestroyThread(OSThread* thread);
|
||||
void bzero(void* __s, s32 __n);
|
||||
void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri pri);
|
||||
void __osSetSR(u32);
|
||||
u32 __osGetSR(void);
|
||||
|
@ -92,12 +92,8 @@ void osViSetMode(OSViMode* mode);
|
|||
u32 __osProbeTLB(void*);
|
||||
u32 osGetMemSize(void);
|
||||
void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg msg);
|
||||
s32 _Printf(PrintCallback, void* arg, const char* fmt, va_list ap);
|
||||
void osUnmapTLBAll(void);
|
||||
s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction);
|
||||
const char* strchr(const char* str, s32 ch);
|
||||
u32 strlen(const char* str);
|
||||
void* memcpy(void* dst, const void* src, size_t size);
|
||||
void osInvalICache(void* vaddr, s32 nbytes);
|
||||
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 count);
|
||||
void osInvalDCache(void* vaddr, s32 nbytes);
|
||||
|
@ -108,7 +104,6 @@ OSPri osGetThreadPri(OSThread* thread);
|
|||
s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data);
|
||||
void osViSwapBuffer(void* frameBufPtr);
|
||||
s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size);
|
||||
u32 bcmp(void* __sl, void* __s2, u32 __n);
|
||||
OSTime osGetTime(void);
|
||||
void __osTimerServicesInit(void);
|
||||
void __osTimerInterrupt(void);
|
||||
|
@ -116,7 +111,6 @@ void __osSetTimerIntr(OSTime time);
|
|||
OSTime __osInsertTimer(OSTimer* timer);
|
||||
u32 osGetCount(void);
|
||||
void __osSetCompare(u32);
|
||||
void* bcopy(void* __src, void* __dest, u32 __n);
|
||||
s32 __osDisableInt(void);
|
||||
void __osRestoreInt(s32);
|
||||
void __osViInit(void);
|
||||
|
@ -132,10 +126,6 @@ void osMapTLBRdb(void);
|
|||
void osYieldThread(void);
|
||||
u32 __osGetCause(void);
|
||||
s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data);
|
||||
void _Litob(_Pft* args, u8 type);
|
||||
ldiv_t ldiv(s32 num, s32 denom);
|
||||
lldiv_t lldiv(s64 num, s64 denom);
|
||||
void _Ldtob(_Pft* args, u8 type);
|
||||
s32 __osSiRawWriteIo(void* devAddr, u32 val);
|
||||
void osCreateViManager(OSPri pri);
|
||||
OSViContext* __osViGetCurrentContext(void);
|
||||
|
|
9
include/libc/alloca.h
Normal file
9
include/libc/alloca.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef ALLOCA_H
|
||||
#define ALLOCA_H
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
void* alloca(size_t);
|
||||
#define alloca(size) __builtin_alloca(size)
|
||||
|
||||
#endif
|
45
include/libc/assert.h
Normal file
45
include/libc/assert.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef ASSERT_H
|
||||
#define ASSERT_H
|
||||
|
||||
#if !defined(__GNUC__) && !defined(__attribute__)
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
// Runtime assertions
|
||||
|
||||
__attribute__((noreturn)) void __assert(const char* assertion, const char* file, int line);
|
||||
|
||||
// assert for matching
|
||||
#ifndef NDEBUG
|
||||
# ifndef NON_MATCHING
|
||||
# define ASSERT(cond, msg, file, line) ((cond) ? ((void)0) : __assert(msg, file, line))
|
||||
# else
|
||||
# define ASSERT(cond, msg, file, line) ((cond) ? ((void)0) : __assert(#cond, __FILE__, __LINE__))
|
||||
# endif
|
||||
#else
|
||||
# define ASSERT(cond, msg, file, line) ((void)0)
|
||||
#endif
|
||||
|
||||
// standard assert macro
|
||||
#ifndef NDEBUG
|
||||
# define assert(cond) ASSERT(cond, #cond, __FILE__, __LINE__)
|
||||
#else
|
||||
# define assert(cond) ((void)0)
|
||||
#endif
|
||||
|
||||
// Static/compile-time assertions
|
||||
|
||||
#if defined(__GNUC__) || (__STDC_VERSION__ >= 201112L)
|
||||
# define static_assert(cond, msg) _Static_assert(cond, msg)
|
||||
#else
|
||||
# ifndef GLUE
|
||||
# define GLUE(a, b) a##b
|
||||
# endif
|
||||
# ifndef GLUE2
|
||||
# define GLUE2(a, b) GLUE(a, b)
|
||||
# endif
|
||||
|
||||
# define static_assert(cond, msg) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -5,24 +5,37 @@
|
|||
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#define M_SQRT2 1.41421356237309504880f
|
||||
#define FLT_MAX 340282346638528859811704183484516925440.0f
|
||||
#define MAXFLOAT 3.40282347e+38f
|
||||
#define SHT_MAX 32767.0f
|
||||
#define SHT_MINV (1.0f / SHT_MAX)
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u32 hi;
|
||||
u32 lo;
|
||||
} word;
|
||||
float floorf(float);
|
||||
double floor(double);
|
||||
long lfloorf(float);
|
||||
long lfloor(double);
|
||||
|
||||
f64 d;
|
||||
} du;
|
||||
float ceilf(float);
|
||||
double ceil(double);
|
||||
long lceilf(float);
|
||||
long lceil(double);
|
||||
|
||||
typedef union {
|
||||
u32 i;
|
||||
f32 f;
|
||||
} fu;
|
||||
float truncf(float);
|
||||
double trunc(double);
|
||||
long ltruncf(float);
|
||||
long ltrunc(double);
|
||||
|
||||
extern f32 __libm_qnan_f;
|
||||
float nearbyintf(float);
|
||||
double nearbyint(double);
|
||||
long lnearbyintf(float);
|
||||
long lnearbyint(double);
|
||||
|
||||
float roundf(float);
|
||||
double round(double);
|
||||
long lroundf(float);
|
||||
long lround(double);
|
||||
|
||||
extern float qNaN0x3FFFFF;
|
||||
extern float qNaN0x10000;
|
||||
extern float sNaN0x3FFFFF;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,43 +1,57 @@
|
|||
#ifndef STDARG_H
|
||||
#define STDARG_H
|
||||
|
||||
// When building with GCC, use the official vaarg macros to avoid warnings
|
||||
// and possibly bad codegen.
|
||||
// When building with GCC, use the official vaarg macros to avoid warnings and possibly bad codegen.
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define va_list __builtin_va_list
|
||||
|
||||
#define va_list __builtin_va_list
|
||||
#define va_start __builtin_va_start
|
||||
#define va_arg __builtin_va_arg
|
||||
#define va_end __builtin_va_end
|
||||
#define va_arg __builtin_va_arg
|
||||
#define va_end __builtin_va_end
|
||||
|
||||
#else
|
||||
|
||||
#ifndef _VA_LIST_
|
||||
# define _VA_LIST_
|
||||
typedef char* va_list;
|
||||
#define _FP 1
|
||||
#define _INT 0
|
||||
#endif
|
||||
|
||||
#define _INT 0
|
||||
#define _FP 1
|
||||
#define _STRUCT 2
|
||||
|
||||
#define _VA_FP_SAVE_AREA 0x10
|
||||
#define _VA_ALIGN(p, a) (((u32)(((char*)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4))
|
||||
#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN)))
|
||||
|
||||
#define __va_stack_arg(list, mode) \
|
||||
( \
|
||||
((list) = (char*)_VA_ALIGN(list, __builtin_alignof(mode)) + \
|
||||
_VA_ALIGN(sizeof(mode), 4)), \
|
||||
(((char*)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode))))
|
||||
#define _VA_ALIGN(p, a) (((unsigned int)(((char*)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4))
|
||||
|
||||
#define __va_double_arg(list, mode) \
|
||||
( \
|
||||
(((s32)list & 0x1) /* 1 byte aligned? */ \
|
||||
? (list = (char*)((s32)list + 7), (char*)((s32)list - 6 - _VA_FP_SAVE_AREA)) \
|
||||
: (((s32)list & 0x2) /* 2 byte aligned? */ \
|
||||
? (list = (char*)((s32)list + 10), (char*)((s32)list - 24 - _VA_FP_SAVE_AREA)) \
|
||||
: __va_stack_arg(list, mode))))
|
||||
#define va_start(list, parmN) (list = ((va_list)&parmN + sizeof(parmN)))
|
||||
|
||||
#define va_arg(list, mode) ((mode*)(((__builtin_classof(mode) == _FP && \
|
||||
__builtin_alignof(mode) == sizeof(f64)) \
|
||||
? __va_double_arg(list, mode) \
|
||||
: __va_stack_arg(list, mode))))[-1]
|
||||
#define __va_stack_arg(list, mode) \
|
||||
( \
|
||||
((list) = (char*)_VA_ALIGN(list, __builtin_alignof(mode)) + \
|
||||
_VA_ALIGN(sizeof(mode), 4)), \
|
||||
(((char*)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode))) \
|
||||
)
|
||||
|
||||
#define __va_double_arg(list, mode) \
|
||||
( \
|
||||
(((long)list & 0x1) /* 1 byte aligned? */ \
|
||||
? (list = (char*)((long)list + 7), (char*)((long)list - 6 - _VA_FP_SAVE_AREA)) \
|
||||
: (((long)list & 0x2) /* 2 byte aligned? */ \
|
||||
? (list = (char*)((long)list + 10), (char*)((long)list - 24 - _VA_FP_SAVE_AREA)) \
|
||||
: __va_stack_arg(list, mode))) \
|
||||
)
|
||||
|
||||
#define va_arg(list, mode) \
|
||||
((mode*)(((__builtin_classof(mode) == _FP && \
|
||||
__builtin_alignof(mode) == sizeof(double)) \
|
||||
? __va_double_arg(list, mode) \
|
||||
: __va_stack_arg(list, mode))))[-1]
|
||||
|
||||
/* No cleanup processing is required for the end of a varargs list: */
|
||||
#define va_end(__list)
|
||||
|
||||
#endif
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#define bool u32
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define bool _Bool
|
||||
#else
|
||||
#define bool unsigned int
|
||||
#endif
|
||||
|
||||
#define false 0
|
||||
#define true 1
|
||||
|
||||
|
|
|
@ -3,10 +3,16 @@
|
|||
|
||||
#define NULL ((void*)0)
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
|
||||
#if !defined(_MIPS_SZLONG) || (_MIPS_SZLONG == 32)
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
#if defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64)
|
||||
typedef unsigned long size_t;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
|
9
include/libc/stdio.h
Normal file
9
include/libc/stdio.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef STDIO_H
|
||||
#define STDIO_H
|
||||
|
||||
#include "stdarg.h"
|
||||
|
||||
int sprintf(char* dst, const char* fmt, ...);
|
||||
int vsprintf(char* dst, const char* fmt, va_list args);
|
||||
|
||||
#endif
|
|
@ -1,16 +1,17 @@
|
|||
#ifndef STDLIB_H
|
||||
#define STDLIB_H
|
||||
|
||||
#include "ultra64.h"
|
||||
|
||||
typedef struct lldiv_t {
|
||||
s64 quot;
|
||||
s64 rem;
|
||||
long long quot;
|
||||
long long rem;
|
||||
} lldiv_t;
|
||||
|
||||
typedef struct ldiv_t {
|
||||
s32 quot;
|
||||
s32 rem;
|
||||
long quot;
|
||||
long rem;
|
||||
} ldiv_t;
|
||||
|
||||
ldiv_t ldiv(long num, long denom);
|
||||
lldiv_t lldiv(long long num, long long denom);
|
||||
|
||||
#endif
|
||||
|
|
11
include/libc/string.h
Normal file
11
include/libc/string.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
char* strchr(const char*, int);
|
||||
size_t strlen(const char*);
|
||||
|
||||
void* memcpy(void*, const void*, size_t);
|
||||
|
||||
#endif
|
|
@ -171,14 +171,6 @@ extern struct GraphicsContext* __gfxCtx;
|
|||
|
||||
#define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } }
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define ASSERT(cond, msg, file, line) ((void)0)
|
||||
#elif defined(REAL_ASSERT_MACRO)
|
||||
#define ASSERT(cond, msg, file, line) ((cond) ? ((void)0) : __assert(#cond, __FILE__, __LINE__))
|
||||
#else
|
||||
#define ASSERT(cond, msg, file, line) ((cond) ? ((void)0) : __assert(msg, file, line))
|
||||
#endif
|
||||
|
||||
#define gDPSetTileCustom(pkt, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
|
||||
do { \
|
||||
gDPPipeSync(pkt); \
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
* The strings are used in the message_data_static files themselves, as you can only concat strings with other strings
|
||||
*/
|
||||
|
||||
#ifndef GLUE
|
||||
#define GLUE(a, b) a##b
|
||||
#endif
|
||||
|
||||
#define STRINGIFY(s) #s
|
||||
#define EXPAND_AND_STRINGIFY(s) STRINGIFY(s)
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
#ifndef ULTRA64_H
|
||||
#define ULTRA64_H
|
||||
|
||||
#include "ultra64/ultratypes.h"
|
||||
#include "unk.h"
|
||||
|
||||
#include "libc/assert.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/stdarg.h"
|
||||
#include "libc/stdbool.h"
|
||||
#include "libc/stddef.h"
|
||||
#include "libc/stdint.h"
|
||||
#include "libc/stdio.h"
|
||||
#include "libc/stdlib.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/string.h"
|
||||
|
||||
#include "ultra64/ultratypes.h"
|
||||
#include "unk.h"
|
||||
|
||||
#include "ultra64/libc.h"
|
||||
#include "ultra64/xstdio.h"
|
||||
#include "ultra64/exception.h"
|
||||
#include "ultra64/rcp.h"
|
||||
#include "ultra64/thread.h"
|
||||
|
@ -22,7 +27,6 @@
|
|||
#include "ultra64/vi.h"
|
||||
#include "ultra64/pi.h"
|
||||
#include "ultra64/controller.h"
|
||||
#include "ultra64/printf.h"
|
||||
#include "ultra64/mbi.h"
|
||||
#include "ultra64/pfs.h"
|
||||
#include "ultra64/motor.h"
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
#ifndef ULTRA64_GU_H
|
||||
#define ULTRA64_GU_H
|
||||
|
||||
#include "ultratypes.h"
|
||||
|
||||
#define GU_PI 3.1415926
|
||||
|
||||
#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5))
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u32 hi;
|
||||
u32 lo;
|
||||
} word;
|
||||
|
||||
f64 d;
|
||||
} du;
|
||||
|
||||
typedef union {
|
||||
u32 i;
|
||||
f32 f;
|
||||
} fu;
|
||||
|
||||
extern f32 __libm_qnan_f;
|
||||
|
||||
#endif
|
||||
|
|
12
include/ultra64/libc.h
Normal file
12
include/ultra64/libc.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef ULTRA64_LIBC_H
|
||||
#define ULTRA64_LIBC_H
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
void osSyncPrintf(const char* fmt, ...);
|
||||
|
||||
void bzero(void* __s, size_t __n);
|
||||
int bcmp(const void* __sl, const void* __s2, size_t __n);
|
||||
void bcopy(const void* __src, void* __dest, size_t __n);
|
||||
|
||||
#endif
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef ULTRA64_PRINTF_H
|
||||
#define ULTRA64_PRINTF_H
|
||||
|
||||
#include "ultratypes.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ union {
|
||||
/* 0x0 */ s64 ll;
|
||||
/* 0x0 */ f64 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;
|
||||
/* 0x2C */ u32 nchar;
|
||||
/* 0x30 */ u32 flags;
|
||||
/* 0x34 */ u8 qual;
|
||||
} _Pft; // size = 0x38
|
||||
|
||||
typedef void* (*PrintCallback)(void*, const char*, u32);
|
||||
|
||||
#define FLAGS_SPACE 1
|
||||
#define FLAGS_PLUS 2
|
||||
#define FLAGS_MINUS 4
|
||||
#define FLAGS_HASH 8
|
||||
#define FLAGS_ZERO 16
|
||||
|
||||
#endif
|
44
include/ultra64/xstdio.h
Normal file
44
include/ultra64/xstdio.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef ULTRA64_PRINTF_H
|
||||
#define ULTRA64_PRINTF_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 {
|
||||
/* 0x00 */ union {
|
||||
long long ll;
|
||||
LONG_DOUBLE_TYPE ld;
|
||||
} v;
|
||||
/* 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 */ unsigned int flags;
|
||||
/* 0x34 */ char qual;
|
||||
} _Pft; // size = 0x38
|
||||
|
||||
typedef void* (*PrintCallback)(void*, const char*, size_t);
|
||||
|
||||
int _Printf(PrintCallback, void* arg, const char* fmt, va_list ap);
|
||||
void _Litob(_Pft* args, char code);
|
||||
void _Ldtob(_Pft* args, char code);
|
||||
|
||||
#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)
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue