Common Source Code Project for Qt (a.k.a for FM-7).
Revision | d54f358a6032863d081f527269a26511184d861f (tree) |
---|---|
Zeit | 2018-06-14 21:56:53 |
Autor | K.Ohta <whatisthis.sowhat@gmai...> |
Commiter | K.Ohta |
[VM][I386] Remove compiler warning conversion float64 (a.k.a UINT64) <-> double. This still not regard when sizeof(double) != sizeof(UINT64).
@@ -54,7 +54,7 @@ UINT32 I386_OPS_BASE::i386_load_protected_mode_segment( I386_SREG *seg, UINT64 * | ||
54 | 54 | } |
55 | 55 | |
56 | 56 | entry = seg->selector & ~0x7; |
57 | - if (limit == 0 || entry + 7 > limit) | |
57 | + if ((limit == 0) || ((UINT32)(entry + 7) > limit)) | |
58 | 58 | return 0; |
59 | 59 | |
60 | 60 | v1 = READ32PL0(base + entry ); |
@@ -89,7 +89,7 @@ void I386_OPS_BASE::i386_load_call_gate(I386_CALL_GATE *gate) | ||
89 | 89 | } |
90 | 90 | |
91 | 91 | entry = gate->segment & ~0x7; |
92 | - if (limit == 0 || entry + 7 > limit) | |
92 | + if ((limit == 0) || ((UINT32)(entry + 7) > limit)) | |
93 | 93 | return; |
94 | 94 | |
95 | 95 | v1 = READ32PL0(base + entry ); |
@@ -923,7 +923,7 @@ void I386_OPS_BASE::i386_trap(int irq, int irq_gate, int trap_level) | ||
923 | 923 | else |
924 | 924 | stack_limit = 6; |
925 | 925 | // TODO: Add check for error code (2 extra bytes) |
926 | - if(REG32(ESP) < stack_limit) | |
926 | + if((int)(REG32(ESP)) < stack_limit) | |
927 | 927 | { |
928 | 928 | logerror("IRQ: Stack has no space left (needs %i bytes).\n",stack_limit); |
929 | 929 | FAULT_EXP(FAULT_SS,0) |
@@ -1787,7 +1787,7 @@ void I386_OPS_BASE::i386_protected_mode_call( UINT16 seg, UINT32 off, int indire | ||
1787 | 1787 | } |
1788 | 1788 | if(operand32 != 0) |
1789 | 1789 | { |
1790 | - if(newESP < ((gate.dword_count & 0x1f) + 16)) | |
1790 | + if(newESP < (UINT32)((gate.dword_count & 0x1f) + 16)) | |
1791 | 1791 | { |
1792 | 1792 | logerror("CALL: Call gate: New stack has no room for 32-bit return address and parameters.\n"); |
1793 | 1793 | FAULT(FAULT_SS,0) // #SS(0) |
@@ -1800,7 +1800,7 @@ void I386_OPS_BASE::i386_protected_mode_call( UINT16 seg, UINT32 off, int indire | ||
1800 | 1800 | } |
1801 | 1801 | else |
1802 | 1802 | { |
1803 | - if(newESP < ((gate.dword_count & 0x1f) + 8)) | |
1803 | + if(newESP < (UINT32)((gate.dword_count & 0x1f) + 8)) | |
1804 | 1804 | { |
1805 | 1805 | logerror("CALL: Call gate: New stack has no room for 16-bit return address and parameters.\n"); |
1806 | 1806 | FAULT(FAULT_SS,0) // #SS(0) |
@@ -2696,7 +2696,7 @@ void I386_OPS_BASE::i386_protected_mode_iret(int operand32) | ||
2696 | 2696 | |
2697 | 2697 | void I386_OPS_BASE::build_cycle_table() |
2698 | 2698 | { |
2699 | - int i, j; | |
2699 | + uint32_t i, j; | |
2700 | 2700 | for (j=0; j < X86_NUM_CPUS; j++) |
2701 | 2701 | { |
2702 | 2702 | // cycle_table_rm[j] = (UINT8 *)malloc(CYCLES_NUM_OPCODES); |
@@ -2986,7 +2986,7 @@ void I386_OPS_BASE::build_opcode_table(UINT32 features) | ||
2986 | 2986 | _cpustate->lock_table[1][i] = false; |
2987 | 2987 | } |
2988 | 2988 | |
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++) | |
2990 | 2990 | { |
2991 | 2991 | const X86_OPCODE *op = &x86_opcode_table[i]; |
2992 | 2992 |
@@ -1816,6 +1816,8 @@ protected: | ||
1816 | 1816 | INLINE int floatx80_is_inf(floatx80 fx); |
1817 | 1817 | INLINE int floatx80_is_denormal(floatx80 fx); |
1818 | 1818 | INLINE floatx80 floatx80_abs(floatx80 fx); |
1819 | + | |
1820 | + INLINE UINT64 __SWAP64(UINT64 in); | |
1819 | 1821 | INLINE double fx80_to_double(floatx80 fx); |
1820 | 1822 | INLINE floatx80 double_to_fx80(double in); |
1821 | 1823 | INLINE floatx80 READ80( UINT32 ea); |
@@ -2809,15 +2811,57 @@ INLINE floatx80 I386_OPS_BASE::floatx80_abs(floatx80 fx) | ||
2809 | 2811 | return fx; |
2810 | 2812 | } |
2811 | 2813 | |
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 | + | |
2812 | 2837 | INLINE double I386_OPS_BASE::fx80_to_double(floatx80 fx) |
2813 | 2838 | { |
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; | |
2816 | 2850 | } |
2817 | 2851 | |
2818 | 2852 | INLINE floatx80 I386_OPS_BASE::double_to_fx80(double in) |
2819 | 2853 | { |
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); | |
2821 | 2865 | } |
2822 | 2866 | |
2823 | 2867 | INLINE floatx80 I386_OPS_BASE::READ80( UINT32 ea) |