From 0035e3316689bf0b107bd95b4d8db78ad955bbcf Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 22 Oct 2024 22:36:42 -0600 Subject: [PATCH] Source fixes for clangd --- include/ctype.h | 23 +++++++++++++++-------- include/dolphin/os.h | 2 +- include/game/gamework.h | 2 +- include/math.h | 12 ++++++++---- include/stdlib.h | 4 ++++ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/ctype.h b/include/ctype.h index 559e7278..46064191 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -1,6 +1,7 @@ #ifndef _CTYPE_H #define _CTYPE_H +#include "dolphin/types.h" extern unsigned char __ctype_map[256]; extern unsigned char __lower_map[256]; @@ -22,19 +23,25 @@ extern unsigned char __upper_map[256]; #define __whitespace (__motion_char | __space_char) #define __control (__motion_char | __control_char) +#ifdef __MWERKS__ +#define DECL_WEAK __declspec(weak) +#else +#define DECL_WEAK __attribute__((weak)) +#endif + #ifdef __cplusplus extern "C" { #endif - __declspec(weak) int isalpha(int __c); - __declspec(weak) int isdigit(int __c); - __declspec(weak) int isspace(int __c); - __declspec(weak) int isupper(int __c); - __declspec(weak) int isxdigit(int __c); + DECL_WEAK int isalpha(int __c); + DECL_WEAK int isdigit(int __c); + DECL_WEAK int isspace(int __c); + DECL_WEAK int isupper(int __c); + DECL_WEAK int isxdigit(int __c); - __declspec(weak) int tolower(int __c); - __declspec(weak) int toupper(int __c); + DECL_WEAK int tolower(int __c); + DECL_WEAK int toupper(int __c); // added underscore to avoid naming conflicts inline int _isalpha(int c) { return (int)(__ctype_map[(u8)c] & __letter); } @@ -48,4 +55,4 @@ extern "C" #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/include/dolphin/os.h b/include/dolphin/os.h index d231c662..83f15519 100644 --- a/include/dolphin/os.h +++ b/include/dolphin/os.h @@ -19,7 +19,7 @@ extern "C" { #ifdef __MWERKS__ #define AT_ADDRESS(xyz) : (xyz) #else -#define AT_ADDRESS +#define AT_ADDRESS(xyz) #endif typedef s64 OSTime; typedef u32 OSTick; diff --git a/include/game/gamework.h b/include/game/gamework.h index 0e3b4807..869cfad1 100644 --- a/include/game/gamework.h +++ b/include/game/gamework.h @@ -7,7 +7,7 @@ void GWInit(void); void GWGameStatReset(void); -s32 GWMessSpeedGet(void); +// s32 GWMessSpeedGet(void); s32 GWMessDelayGet(void); void GWMGRecordSet(s32 index, u32 value); u32 GWMGRecordGet(s32 index); diff --git a/include/math.h b/include/math.h index 419d4d50..8549b25f 100644 --- a/include/math.h +++ b/include/math.h @@ -7,6 +7,7 @@ #define _MATH_INLINE static inline #endif +#ifdef __MWERKS__ extern inline float sqrtf(float x) { volatile float y; @@ -21,6 +22,9 @@ extern inline float sqrtf(float x) } return x; } +#else +float sqrtf(float x); +#endif double atan(double x); double copysign(double x, double y); @@ -38,15 +42,15 @@ double fmod(double x, double y); double log(double x); double pow(double x, double y); float tanf(float x); -float sinf(float x); -float cosf(float x); -float atan2f(float y, float x); -float acosf(float x); +#ifdef __MWERKS__ extern inline double fabs(double x) { return __fabs(x); } +#else +double fabs(double x); +#endif _MATH_INLINE float fabsf(float x) { return (float)fabs((double)x); } _MATH_INLINE float sinf(float x) { return (float)sin((double)x); } diff --git a/include/stdlib.h b/include/stdlib.h index c6e1d71d..aaf69e6d 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -1,6 +1,10 @@ #ifndef _STDLIB_H #define _STDLIB_H +#ifdef __MWERKS__ #define abs(x) __abs(x) +#else +int abs(int x); +#endif #endif