mirror of https://github.com/zeldaret/mm.git
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
This commit is contained in:
parent
49f55ff005
commit
e70a8fbb99
4
Makefile
4
Makefile
|
@ -79,7 +79,7 @@ endif
|
|||
|
||||
# Check code syntax with host compiler
|
||||
CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label
|
||||
CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu90 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -include stdarg.h $(CHECK_WARNINGS)
|
||||
CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS)
|
||||
|
||||
CPP := cpp
|
||||
ELF2ROM := tools/buildtools/elf2rom
|
||||
|
@ -92,7 +92,7 @@ ASFLAGS := -march=vr4300 -32 -Iinclude
|
|||
MIPS_VERSION := -mips2
|
||||
|
||||
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
|
||||
CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -Wab,-r4300_mul -woff 624,649,838,712
|
||||
CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712
|
||||
|
||||
ifeq ($(shell getconf LONG_BIT), 32)
|
||||
# Work around memory allocation bug in QEMU
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#ifndef _ASSERT_H_
|
||||
#define _ASSERT_H_
|
||||
|
||||
#endif
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef ASSERT_H
|
||||
#define ASSERT_H
|
||||
|
||||
#endif
|
|
@ -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
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _MACROS_H_
|
||||
#define _MACROS_H_
|
||||
|
||||
#include "stdint.h"
|
||||
#include "libc/stdint.h"
|
||||
#include "convert.h"
|
||||
#include "z64.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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _XSTDIO_H_
|
||||
#define _XSTDIO_H_
|
||||
#include "stdarg.h"
|
||||
|
||||
#include "libc/stdarg.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ union {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "math.h"
|
||||
#include "libc/math.h"
|
||||
#include "macros.h"
|
||||
|
||||
// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "math.h"
|
||||
#include "libc/math.h"
|
||||
#include "macros.h"
|
||||
|
||||
// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "math.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
static s16 sintable[0x400] = {
|
||||
0x0000, 0x0032, 0x0064, 0x0096, 0x00C9, 0x00FB, 0x012D, 0x0160, 0x0192, 0x01C4, 0x01F7, 0x0229, 0x025B, 0x028E,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "PR/ultratypes.h"
|
||||
#include "osint.h"
|
||||
#include "stdint.h"
|
||||
#include "libc/stdint.h"
|
||||
#include "global.h"
|
||||
|
||||
uintptr_t osVirtualToPhysical(void* virtualAddress) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "z_select.h"
|
||||
#include "alloca.h"
|
||||
#include "libc/alloca.h"
|
||||
#include "overlays/gamestates/ovl_title/z_title.h"
|
||||
|
||||
void Select_LoadTitle(SelectContext* this) {
|
||||
|
|
Loading…
Reference in New Issue