From 782117dbbd882291a8c0f6617f3385bbdf3a30cf Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 25 Aug 2023 02:28:51 +0200 Subject: [PATCH] Fixed some GCC pedantic warnings. --- src/cpu/386.c | 2 -- src/cpu/softfloat/config.h | 5 +++++ src/cpu/x86.c | 2 ++ src/cpu/x86.h | 2 ++ src/cpu/x87.h | 2 +- src/cpu/x87_ops.h | 42 ++++++++++++++++++++++++++----------- src/cpu/x87_ops_loadstore.h | 10 ++++++--- src/cpu/x87_ops_misc.h | 5 ++++- 8 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/cpu/386.c b/src/cpu/386.c index 1b255fe5f..e84981893 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -40,8 +40,6 @@ extern int codegen_flags_changed; -static int fpu_cycles = 0; - #ifdef ENABLE_386_LOG int x386_do_log = ENABLE_386_LOG; diff --git a/src/cpu/softfloat/config.h b/src/cpu/softfloat/config.h index 3889b5c02..9e39c2d29 100644 --- a/src/cpu/softfloat/config.h +++ b/src/cpu/softfloat/config.h @@ -1,3 +1,6 @@ +#ifndef EMU_SF_CONFIG_H +#define EMU_SF_CONFIG_H + #include typedef int8_t flag; @@ -44,3 +47,5 @@ typedef int64_t Bit64s; *----------------------------------------------------------------------------*/ #define BX_CONST64(a) a##LL #define BX_CPP_INLINE static __inline + +#endif /*EMU_SF_CONFIG_H*/ diff --git a/src/cpu/x86.c b/src/cpu/x86.c index 1ec023ad3..9abb95139 100644 --- a/src/cpu/x86.c +++ b/src/cpu/x86.c @@ -78,6 +78,8 @@ uint32_t easeg; int reset_on_hlt; int hlt_reset_pending; +int fpu_cycles = 0; + #ifdef ENABLE_X86_LOG void dumpregs(int); diff --git a/src/cpu/x86.h b/src/cpu/x86.h index 5736dc665..f52e430ac 100644 --- a/src/cpu/x86.h +++ b/src/cpu/x86.h @@ -70,6 +70,8 @@ extern uint32_t *mod1seg[8]; extern uint32_t *eal_r; extern uint32_t *eal_w; +extern int fpu_cycles; + #define fetchdat rmdat #define setznp168 setznp16 diff --git a/src/cpu/x87.h b/src/cpu/x87.h index 1d889a544..f4e24f1ca 100644 --- a/src/cpu/x87.h +++ b/src/cpu/x87.h @@ -144,7 +144,7 @@ void codegen_set_rounding_mode(int mode); #include "softfloat/softfloatx80.h" -static __inline const int +static __inline int is_IA_masked(void) { return (fpu_state.cwd & FPU_CW_Invalid); diff --git a/src/cpu/x87_ops.h b/src/cpu/x87_ops.h index d1c55f2e9..1d9220255 100644 --- a/src/cpu/x87_ops.h +++ b/src/cpu/x87_ops.h @@ -169,13 +169,17 @@ x87_pop(void) static __inline int16_t x87_fround16(double b) { + double da; + double dc; int16_t a; int16_t c; switch ((cpu_state.npxc >> 10) & 3) { case 0: /*Nearest*/ - a = (int16_t) floor(b); - c = (int16_t) floor(b + 1.0); + da = floor(b); + dc = floor(b + 1.0); + a = (int16_t) da; + c = (int16_t) dc; if ((b - a) < (c - b)) return a; else if ((b - a) > (c - b)) @@ -183,9 +187,11 @@ x87_fround16(double b) else return (a & 1) ? c : a; case 1: /*Down*/ - return (int16_t) floor(b); + da = floor(b); + return (int16_t) da; case 2: /*Up*/ - return (int16_t) ceil(b); + da = ceil(b); + return (int16_t) da; case 3: /*Chop*/ return (int16_t) b; } @@ -202,13 +208,17 @@ x87_fround16_64(double b) static __inline int32_t x87_fround32(double b) { + double da; + double dc; int32_t a; int32_t c; switch ((cpu_state.npxc >> 10) & 3) { case 0: /*Nearest*/ - a = (int32_t) floor(b); - c = (int32_t) floor(b + 1.0); + da = floor(b); + dc = floor(b + 1.0); + a = (int32_t) da; + c = (int32_t) dc; if ((b - a) < (c - b)) return a; else if ((b - a) > (c - b)) @@ -216,9 +226,11 @@ x87_fround32(double b) else return (a & 1) ? c : a; case 1: /*Down*/ - return (int32_t) floor(b); + da = floor(b); + return (int32_t) da; case 2: /*Up*/ - return (int32_t) ceil(b); + da = ceil(b); + return (int32_t) da; case 3: /*Chop*/ return (int32_t) b; } @@ -235,13 +247,17 @@ x87_fround32_64(double b) static __inline int64_t x87_fround(double b) { + double da; + double dc; int64_t a; int64_t c; switch ((cpu_state.npxc >> 10) & 3) { case 0: /*Nearest*/ - a = (int64_t) floor(b); - c = (int64_t) floor(b + 1.0); + da = floor(b); + dc = floor(b + 1.0); + a = (int64_t) da; + c = (int64_t) dc; if ((b - a) < (c - b)) return a; else if ((b - a) > (c - b)) @@ -249,9 +265,11 @@ x87_fround(double b) else return (a & 1) ? c : a; case 1: /*Down*/ - return (int64_t) floor(b); + da = floor(b); + return (int64_t) da; case 2: /*Up*/ - return (int64_t) ceil(b); + da = ceil(b); + return (int64_t) da; case 3: /*Chop*/ return (int64_t) b; } diff --git a/src/cpu/x87_ops_loadstore.h b/src/cpu/x87_ops_loadstore.h index 9cec01490..d77c0ca2b 100644 --- a/src/cpu/x87_ops_loadstore.h +++ b/src/cpu/x87_ops_loadstore.h @@ -147,6 +147,7 @@ opFILDiq_a32(uint32_t fetchdat) static int FBSTP_a16(uint32_t fetchdat) { + double dt; double tempd; int c; FP_ENTER(); @@ -156,15 +157,18 @@ FBSTP_a16(uint32_t fetchdat) if (tempd < 0.0) tempd = -tempd; for (c = 0; c < 9; c++) { - uint8_t tempc = (uint8_t) floor(fmod(tempd, 10.0)); + dt = floor(fmod(tempd, 10.0)); + uint8_t tempc = (uint8_t) dt; tempd -= floor(fmod(tempd, 10.0)); tempd /= 10.0; - tempc |= ((uint8_t) floor(fmod(tempd, 10.0))) << 4; + dt = floor(fmod(tempd, 10.0)); + tempc |= ((uint8_t) dt) << 4; tempd -= floor(fmod(tempd, 10.0)); tempd /= 10.0; writememb(easeg, cpu_state.eaaddr + c, tempc); } - tempc = (uint8_t) floor(fmod(tempd, 10.0)); + dt = floor(fmod(tempd, 10.0)); + tempc = (uint8_t) dt; if (ST(0) < 0.0) tempc |= 0x80; writememb(easeg, cpu_state.eaaddr + 9, tempc); diff --git a/src/cpu/x87_ops_misc.h b/src/cpu/x87_ops_misc.h index 0c951815e..d854f83db 100644 --- a/src/cpu/x87_ops_misc.h +++ b/src/cpu/x87_ops_misc.h @@ -818,9 +818,12 @@ opFSINCOS(uint32_t fetchdat) static int opFRNDINT(uint32_t fetchdat) { + double dst0; + FP_ENTER(); cpu_state.pc++; - ST(0) = (double) x87_fround(ST(0)); + dst0 = x87_fround(ST(0)); + ST(0) = (double) dst0; FP_TAG_VALID; CLOCK_CYCLES_FPU((fpu_type >= FPU_487SX) ? (x87_timings.frndint) : (x87_timings.frndint * cpu_multi)); CONCURRENCY_CYCLES((fpu_type >= FPU_487SX) ? (x87_concurrency.frndint) : (x87_concurrency.frndint * cpu_multi));