Skip to content

Commit

Permalink
gcc fix weeee
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Mar 19, 2024
1 parent cf0c99d commit 1f86faf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ExternalProject_Add(mupen64plus-core
BUILD_COMMAND ${MAKE_CMD} all -f ${M64P_CORE_DIR}/projects/unix/Makefile
SRCDIR=${CMAKE_CURRENT_SOURCE_DIR}/mupen64plus-core/src
SUBDIR=${CMAKE_CURRENT_SOURCE_DIR}/mupen64plus-core/subprojects
OSD=0 NEW_DYNAREC=1 NO_ASM=$<BOOL:${NO_ASM}> KEYBINDINGS=0 ACCURATE_FPU=1 OPTFLAGS=-O0
OSD=0 NEW_DYNAREC=1 NO_ASM=$<BOOL:${NO_ASM}> KEYBINDINGS=0 ACCURATE_FPU=1
TARGET=${CORE_FILE} DEBUG=${MAKE_DEBUG}
CC=${MAKE_CC_COMPILER} CXX=${MAKE_CXX_COMPILER}
OPTFLAGS=${MAKE_OPTFLAGS}
Expand Down
10 changes: 10 additions & 0 deletions Source/3rdParty/mupen64plus-core/projects/unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,16 @@ endif

ifeq ($(ACCURATE_FPU), 1)
CFLAGS += -DACCURATE_FPU_BEHAVIOR
# -O2 & -O3 enable -ftree-pre in GCC
# which break some FPU functions and cause
# a lot of test failures in n64-systemtest,
# so fix that by disabling -ftree-pre
# TODO: test with different GCC versions
# NOTE: tested with GCC 13.2.1
CC_VERSION := $(shell $(CC) --version)
ifneq ($(findstring GCC,$(CC_VERSION)), )
CFLAGS += -fno-tree-pre
endif
endif

ifeq ($(DEBUGGER), 1)
Expand Down
7 changes: 4 additions & 3 deletions Source/3rdParty/mupen64plus-core/src/device/r4300/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <math.h>
#include <stdint.h>
#include <float.h>
#include <string.h>

#include <stdio.h> // TODO: remove

Expand Down Expand Up @@ -418,7 +419,7 @@ M64P_FPU_INLINE int cvt_s_w(uint32_t* fcr31, const int32_t* source, float* dest)

float value = (float)*source;

if (fpu_check_exceptions(fcr31)) return 1;
if (fpu_check_exceptions(fcr31)) return 1;
if (fpu_check_output_float(fcr31, &value)) return 1;

*dest = value;
Expand Down Expand Up @@ -482,9 +483,9 @@ M64P_FPU_INLINE int cvt_s_d(uint32_t* fcr31, const double* source, float* dest)

fpu_reset_exceptions();

float value = *(float*)source;
float value = (float)*source;

if (fpu_check_exceptions(fcr31)) return 1;
if (fpu_check_exceptions(fcr31)) return 1;
if (fpu_check_output_float(fcr31, &value)) return 1;

*dest = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,13 @@ DECLARE_INSTRUCTION(ABS_D)
{
DECLARE_R4300
if (check_cop1_unusable(r4300)) { return; }
abs_d(r4300_cp1_fcr31(&r4300->cp1), (r4300_cp1_regs_double(&r4300->cp1))[cffs], (r4300_cp1_regs_double(&r4300->cp1))[cffd]);
if (abs_d(r4300_cp1_fcr31(&r4300->cp1), (r4300_cp1_regs_double(&r4300->cp1))[cffs], (r4300_cp1_regs_double(&r4300->cp1))[cffd]))
{
uint32_t* cp0_regs = r4300_cp0_regs(&r4300->cp0);
cp0_regs[CP0_CAUSE_REG] = CP0_CAUSE_EXCCODE_FPE;
exception_general(r4300);
return;
}
ADD_TO_PC(1);
}

Expand Down

0 comments on commit 1f86faf

Please sign in to comment.