• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revisiond54f358a6032863d081f527269a26511184d861f (tree)
Time2018-06-14 21:56:53
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][I386] Remove compiler warning conversion float64 (a.k.a UINT64) <-> double. This still not regard when sizeof(double) != sizeof(UINT64).

Change Summary

Incremental Difference

--- a/source/src/vm/libcpu_newdev/libcpu_i386/i386_opdef.cpp
+++ b/source/src/vm/libcpu_newdev/libcpu_i386/i386_opdef.cpp
@@ -54,7 +54,7 @@ UINT32 I386_OPS_BASE::i386_load_protected_mode_segment( I386_SREG *seg, UINT64 *
5454 }
5555
5656 entry = seg->selector & ~0x7;
57- if (limit == 0 || entry + 7 > limit)
57+ if ((limit == 0) || ((UINT32)(entry + 7) > limit))
5858 return 0;
5959
6060 v1 = READ32PL0(base + entry );
@@ -89,7 +89,7 @@ void I386_OPS_BASE::i386_load_call_gate(I386_CALL_GATE *gate)
8989 }
9090
9191 entry = gate->segment & ~0x7;
92- if (limit == 0 || entry + 7 > limit)
92+ if ((limit == 0) || ((UINT32)(entry + 7) > limit))
9393 return;
9494
9595 v1 = READ32PL0(base + entry );
@@ -923,7 +923,7 @@ void I386_OPS_BASE::i386_trap(int irq, int irq_gate, int trap_level)
923923 else
924924 stack_limit = 6;
925925 // TODO: Add check for error code (2 extra bytes)
926- if(REG32(ESP) < stack_limit)
926+ if((int)(REG32(ESP)) < stack_limit)
927927 {
928928 logerror("IRQ: Stack has no space left (needs %i bytes).\n",stack_limit);
929929 FAULT_EXP(FAULT_SS,0)
@@ -1787,7 +1787,7 @@ void I386_OPS_BASE::i386_protected_mode_call( UINT16 seg, UINT32 off, int indire
17871787 }
17881788 if(operand32 != 0)
17891789 {
1790- if(newESP < ((gate.dword_count & 0x1f) + 16))
1790+ if(newESP < (UINT32)((gate.dword_count & 0x1f) + 16))
17911791 {
17921792 logerror("CALL: Call gate: New stack has no room for 32-bit return address and parameters.\n");
17931793 FAULT(FAULT_SS,0) // #SS(0)
@@ -1800,7 +1800,7 @@ void I386_OPS_BASE::i386_protected_mode_call( UINT16 seg, UINT32 off, int indire
18001800 }
18011801 else
18021802 {
1803- if(newESP < ((gate.dword_count & 0x1f) + 8))
1803+ if(newESP < (UINT32)((gate.dword_count & 0x1f) + 8))
18041804 {
18051805 logerror("CALL: Call gate: New stack has no room for 16-bit return address and parameters.\n");
18061806 FAULT(FAULT_SS,0) // #SS(0)
@@ -2696,7 +2696,7 @@ void I386_OPS_BASE::i386_protected_mode_iret(int operand32)
26962696
26972697 void I386_OPS_BASE::build_cycle_table()
26982698 {
2699- int i, j;
2699+ uint32_t i, j;
27002700 for (j=0; j < X86_NUM_CPUS; j++)
27012701 {
27022702 // cycle_table_rm[j] = (UINT8 *)malloc(CYCLES_NUM_OPCODES);
@@ -2986,7 +2986,7 @@ void I386_OPS_BASE::build_opcode_table(UINT32 features)
29862986 _cpustate->lock_table[1][i] = false;
29872987 }
29882988
2989- for (i=0; i < sizeof(x86_opcode_table)/sizeof(X86_OPCODE); i++)
2989+ for (i=0; i < (int)(sizeof(x86_opcode_table) / sizeof(X86_OPCODE)); i++)
29902990 {
29912991 const X86_OPCODE *op = &x86_opcode_table[i];
29922992
--- a/source/src/vm/libcpu_newdev/libcpu_i386/i386_opdef.h
+++ b/source/src/vm/libcpu_newdev/libcpu_i386/i386_opdef.h
@@ -1816,6 +1816,8 @@ protected:
18161816 INLINE int floatx80_is_inf(floatx80 fx);
18171817 INLINE int floatx80_is_denormal(floatx80 fx);
18181818 INLINE floatx80 floatx80_abs(floatx80 fx);
1819+
1820+ INLINE UINT64 __SWAP64(UINT64 in);
18191821 INLINE double fx80_to_double(floatx80 fx);
18201822 INLINE floatx80 double_to_fx80(double in);
18211823 INLINE floatx80 READ80( UINT32 ea);
@@ -2809,15 +2811,57 @@ INLINE floatx80 I386_OPS_BASE::floatx80_abs(floatx80 fx)
28092811 return fx;
28102812 }
28112813
2814+inline UINT64 I386_OPS_BASE::__SWAP64(UINT64 in)
2815+{
2816+ typedef union {
2817+ struct {
2818+ uint8_t h7, h6, h5, h4, h3, h2, h, l;
2819+ } b;
2820+ UINT64 ld;
2821+ } d1_t;
2822+
2823+ d1_t id, od;
2824+ id.ld = in;
2825+ od.b.h7 = id.b.l;
2826+ od.b.h6 = id.b.h;
2827+ od.b.h5 = id.b.h2;
2828+ od.b.h4 = id.b.h3;
2829+ od.b.h3 = id.b.h4;
2830+ od.b.h2 = id.b.h5;
2831+ od.b.h = id.b.h6;
2832+ od.b.l = id.b.h7;
2833+
2834+ return od.ld;
2835+}
2836+
28122837 INLINE double I386_OPS_BASE::fx80_to_double(floatx80 fx)
28132838 {
2814- UINT64 d = floatx80_to_float64(fx);
2815- return *(double*)&d;
2839+ union {
2840+ UINT64 ld;
2841+ double fd; // WIP: If sizeof(double) != sizeof(UINT64).(or IEEE 754 format has changed).
2842+ } d;
2843+ UINT64 nd;
2844+ nd = floatx80_to_float64(fx);
2845+#if __FLOAT_WORD_ORDER != __BYTE_ORDER
2846+ nd = __SWAP64(nd);
2847+#endif
2848+ d.ld = nd;
2849+ return d.fd;
28162850 }
28172851
28182852 INLINE floatx80 I386_OPS_BASE::double_to_fx80(double in)
28192853 {
2820- return float64_to_floatx80(*(UINT64*)&in);
2854+ union {
2855+ UINT64 ld;
2856+ double fd; // WIP: If sizeof(double) != sizeof(UINT64).(or IEEE 754 format has changed).
2857+ } d;
2858+ UINT64 nd;
2859+ d.fd = in;
2860+ nd = d.ld;
2861+#if __FLOAT_WORD_ORDER != __BYTE_ORDER
2862+ nd = __SWAP64(nd);
2863+#endif
2864+ return float64_to_floatx80(nd);
28212865 }
28222866
28232867 INLINE floatx80 I386_OPS_BASE::READ80( UINT32 ea)
Show on old repository browser