SilentPatchIII/VC/SA: Add GCC/Clang-compatible safebuffers equivalent

And switch to a common define for this attribute (this fixes
compile warnings on MinGW GCC)
This commit is contained in:
Echo J 2024-11-06 23:29:46 +02:00
parent 2b5c5b7ce0
commit ccfa4eda99
4 changed files with 14 additions and 5 deletions

View file

@ -6,6 +6,15 @@
#include <rwcore.h>
// FIXME: Common.h might be a better place for this (but SA doesn't include it)
#ifdef _MSC_VER
#define NOBUFFERCHECKS __declspec(safebuffers)
#elif defined(__GNUC__) && !defined(__clang__)
#define NOBUFFERCHECKS __attribute__((optimize("-fno-stack-protector")))
#else
#define NOBUFFERCHECKS __attribute__((no_stack_protector))
#endif
constexpr double RAD_TO_DEG (180.0/M_PI);
constexpr double DEG_TO_RAD (M_PI/180.0);
@ -570,4 +579,4 @@ public:
return angle;
}
};
};

View file

@ -380,7 +380,7 @@ void __declspec(naked) RadarBoundsCheckEntityBlip()
extern char** ppUserFilesDir = AddressByVersion<char**>(0x580C16, 0x580F66, 0x580E66);
static LARGE_INTEGER FrameTime;
__declspec(safebuffers) int32_t GetTimeSinceLastFrame()
NOBUFFERCHECKS int32_t GetTimeSinceLastFrame()
{
LARGE_INTEGER curTime;
QueryPerformanceCounter(&curTime);

View file

@ -950,7 +950,7 @@ char* GetMyDocumentsPathSA()
}
static LARGE_INTEGER FrameTime;
__declspec(safebuffers) int32_t GetTimeSinceLastFrame()
NOBUFFERCHECKS int32_t GetTimeSinceLastFrame()
{
LARGE_INTEGER curTime;
QueryPerformanceCounter(&curTime);
@ -3961,7 +3961,7 @@ DarkVehiclesFix4_MakeItDark:
}
// 1.0 ONLY ENDS HERE
__declspec(safebuffers) static int _Timers_ftol_internal( double timer, double& remainder )
NOBUFFERCHECKS static int _Timers_ftol_internal( double timer, double& remainder )
{
double integral;
remainder = modf( timer + remainder, &integral );

View file

@ -699,7 +699,7 @@ void __declspec(naked) CreateInstance_BikeFix()
extern char** ppUserFilesDir = AddressByVersion<char**>(0x6022AA, 0x60228A, 0x601ECA);
static LARGE_INTEGER FrameTime;
__declspec(safebuffers) int32_t GetTimeSinceLastFrame()
NOBUFFERCHECKS int32_t GetTimeSinceLastFrame()
{
LARGE_INTEGER curTime;
QueryPerformanceCounter(&curTime);