aboutsummaryrefslogtreecommitdiff
blob: daf0ae2f2ba10a42f4267b827e7c8b6f8f12a5ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
From 7573870bb856ade326033824d7a2ba6fb4fcdfaf Mon Sep 17 00:00:00 2001
From: Jookia <contact@jookia.org>
Date: Wed, 7 Sep 2022 10:44:48 +1000
Subject: [PATCH 1/2] libs: Namespace PhysFS lzmasdk

---
 src/libs/physfs/physfs_archiver_7z.c | 1 +
 src/libs/physfs/physfs_lzmasdk.h     | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libs/physfs/physfs_archiver_7z.c b/src/libs/physfs/physfs_archiver_7z.c
index 604fd13981a..4095f031710 100644
--- a/src/libs/physfs/physfs_archiver_7z.c
+++ b/src/libs/physfs/physfs_archiver_7z.c
@@ -12,6 +12,7 @@
 #if PHYSFS_SUPPORTS_7Z
 
 #include "physfs_lzmasdk.h"
+using namespace physfs_lzmasdk;
 
 typedef struct
 {
diff --git a/src/libs/physfs/physfs_lzmasdk.h b/src/libs/physfs/physfs_lzmasdk.h
index 239f8f0d1a2..f0abaa136a8 100644
--- a/src/libs/physfs/physfs_lzmasdk.h
+++ b/src/libs/physfs/physfs_lzmasdk.h
@@ -7,13 +7,15 @@ Igor Pavlov. http://www.7-zip.org/sdk.html
 --ryan. */
 
 
-
 /* 7zTypes.h -- Basic types
 2013-11-12 : Igor Pavlov : Public domain */
 
 #ifndef __7Z_TYPES_H
 #define __7Z_TYPES_H
 
+// Jookia: Added to avoid conflict with other LZMA libraries
+namespace physfs_lzmasdk {
+
 #ifdef _WIN32
 /* #include <windows.h> */
 #endif
@@ -6030,6 +6032,8 @@ static SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
   return SZ_OK;
 }
 
+}
+
 #endif  /* _INCLUDE_PHYSFS_LZMASDK_H_ */
 
 /* end of physfs_lzmasdk.h ... */

From 7fb29da0ec0aff0c35c3dce2e8da14205103d5b5 Mon Sep 17 00:00:00 2001
From: Jookia <contact@jookia.org>
Date: Wed, 7 Sep 2022 10:56:40 +1000
Subject: [PATCH 2/2] cpu: Rename data types that conflict under ODR

---
 src/cpu/core_dyn_x86.cpp            |  4 ++--
 src/cpu/core_dyn_x86/cache.h        |  2 +-
 src/cpu/core_dyn_x86/decoder.h      | 10 +++++-----
 src/cpu/core_dyn_x86/risc_x64.h     | 12 ++++++------
 src/cpu/core_dyn_x86/risc_x86.h     |  8 ++++----
 src/cpu/core_dyn_x86/string.h       |  4 ++--
 src/cpu/core_dynrec.cpp             | 10 +++++-----
 src/cpu/core_dynrec/cache.h         |  2 +-
 src/cpu/core_dynrec/decoder_basic.h | 10 +++++-----
 src/cpu/core_normal/string.h        |  4 ++--
 10 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/cpu/core_dyn_x86.cpp b/src/cpu/core_dyn_x86.cpp
index 27c3dab5a6c..63beea5d495 100644
--- a/src/cpu/core_dyn_x86.cpp
+++ b/src/cpu/core_dyn_x86.cpp
@@ -98,7 +98,7 @@ enum BranchTypes {
 };
 
 
-enum BlockReturn {
+enum BlockReturnDynX86 {
 	BR_Normal=0,
 	BR_Cycles,
 	BR_Link1,BR_Link2,
@@ -363,7 +363,7 @@ Bits CPU_Core_Dyn_X86_Run(void) {
 run_block:
 	cache.block.running=0;
 	core_dyn.pagefault = false;
-	BlockReturn ret=gen_runcode((uint8_t*)cache_rwtox(block->cache.start));
+	BlockReturnDynX86 ret=gen_runcode((uint8_t*)cache_rwtox(block->cache.start));
 
 	if (sizeof(CPU_Cycles) > 4) {
 		// HACK: All dynrec cores for each processor assume CPU_Cycles is 32-bit wide.
diff --git a/src/cpu/core_dyn_x86/cache.h b/src/cpu/core_dyn_x86/cache.h
index c3d71212a8b..bf7d557306b 100644
--- a/src/cpu/core_dyn_x86/cache.h
+++ b/src/cpu/core_dyn_x86/cache.h
@@ -495,7 +495,7 @@ static INLINE void cache_addq(uint64_t val) {
 	cache.pos=pos;
 }
 
-static void gen_return(BlockReturn retcode);
+static void gen_return(BlockReturnDynX86 retcode);
 
 static uint8_t * cache_code_start_ptr=NULL;
 static uint8_t * cache_code=NULL;
diff --git a/src/cpu/core_dyn_x86/decoder.h b/src/cpu/core_dyn_x86/decoder.h
index 61dadd9083e..5f0691fa125 100644
--- a/src/cpu/core_dyn_x86/decoder.h
+++ b/src/cpu/core_dyn_x86/decoder.h
@@ -42,7 +42,7 @@ union pagefault_restore {
 	uint32_t dword;
 };
 
-static struct DynDecode {
+static struct DynDecodeDynX86 {
 	PhysPt code;
 	PhysPt code_start;
 	PhysPt eip_location;
@@ -360,11 +360,11 @@ static INLINE void dyn_set_eip_last(void) {
 }
 
 
-enum save_info_type {db_exception, cycle_check, normal, fpu_restore, trap, page_fault};
+enum save_info_type_dynx86 {db_exception, cycle_check, normal, fpu_restore, trap, page_fault};
 
 
 static struct {
-	save_info_type type;
+	save_info_type_dynx86 type;
 	DynState state;
 	uint8_t * branch_pos;
 	uint32_t eip_change;
@@ -379,7 +379,7 @@ static struct {
 Bitu used_save_info=0;
 
 
-static BlockReturn DynRunException(uint32_t eip_add,uint32_t cycle_sub,uint32_t dflags) {
+static BlockReturnDynX86 DynRunException(uint32_t eip_add,uint32_t cycle_sub,uint32_t dflags) {
 	reg_flags=(dflags&FMASK_TEST) | (reg_flags&(~FMASK_TEST));
 	reg_eip+=eip_add;
 	CPU_Cycles-=cycle_sub;
@@ -392,7 +392,7 @@ static BlockReturn DynRunException(uint32_t eip_add,uint32_t cycle_sub,uint32_t
 	return BR_Normal;
 }
 
-static BlockReturn DynRunPageFault(uint32_t eip_add,uint32_t cycle_sub,uint32_t pf_restore,uint32_t dflags) {
+static BlockReturnDynX86 DynRunPageFault(uint32_t eip_add,uint32_t cycle_sub,uint32_t pf_restore,uint32_t dflags) {
 	pagefault_restore pf_restore_struct;
 	pf_restore_struct.dword = pf_restore;
 	reg_flags=(dflags&FMASK_TEST) | (reg_flags&(~FMASK_TEST));
diff --git a/src/cpu/core_dyn_x86/risc_x64.h b/src/cpu/core_dyn_x86/risc_x64.h
index b1f660ca0f8..0c7d21ff270 100644
--- a/src/cpu/core_dyn_x86/risc_x64.h
+++ b/src/cpu/core_dyn_x86/risc_x64.h
@@ -269,13 +269,13 @@ class GenReg {
 	}
 };
 
-static BlockReturn gen_runcodeInit(uint8_t *code);
-static BlockReturn (*gen_runcode)(uint8_t *code) = gen_runcodeInit;
+static BlockReturnDynX86 gen_runcodeInit(uint8_t *code);
+static BlockReturnDynX86 (*gen_runcode)(uint8_t *code) = gen_runcodeInit;
 
-static BlockReturn gen_runcodeInit(uint8_t *code) {
+static BlockReturnDynX86 gen_runcodeInit(uint8_t *code) {
 	uint8_t* oldpos = cache.pos;
 	cache.pos = &cache_code_link_blocks[128];
-	gen_runcode = (BlockReturn(*)(uint8_t*))cache_rwtox(cache.pos);
+	gen_runcode = (BlockReturnDynX86(*)(uint8_t*))cache_rwtox(cache.pos);
 
 	opcode(5).Emit8Reg(0x50);  // push rbp
 	opcode(15).Emit8Reg(0x50); // push r15
@@ -1235,7 +1235,7 @@ static void gen_test_host_byte(void * data, uint8_t imm) {
 	opcode(0).setimm(imm,1).setabsaddr(data).Emit8(0xF6); // test byte[], uint8_t
 }
 
-static void gen_return(BlockReturn retcode) {
+static void gen_return(BlockReturnDynX86 retcode) {
 	gen_protectflags();
 	opcode(1).setea(4,-1,0,CALLSTACK).Emit8(0x8B); // mov ecx, [rsp+8/40]
 	opcode(0).set64().setrm(4).setimm(CALLSTACK+8,1).Emit8(0x83); // add rsp,16/48
@@ -1247,7 +1247,7 @@ static void gen_return(BlockReturn retcode) {
 	opcode(4).setea(4,-1,0,CALLSTACK-8).Emit8(0xFF); // jmp [rsp+CALLSTACK-8]
 }
 
-static void gen_return_fast(BlockReturn retcode,bool ret_exception=false) {
+static void gen_return_fast(BlockReturnDynX86 retcode,bool ret_exception=false) {
 	if (GCC_UNLIKELY(x64gen.flagsactive)) IllegalOption("gen_return_fast");
 	opcode(1).setabsaddr(&reg_flags).Emit8(0x8B); // mov ECX, [cpu_regs.flags]
 	if (!ret_exception) {
diff --git a/src/cpu/core_dyn_x86/risc_x86.h b/src/cpu/core_dyn_x86/risc_x86.h
index 8d0b2174712..29e62678577 100644
--- a/src/cpu/core_dyn_x86/risc_x86.h
+++ b/src/cpu/core_dyn_x86/risc_x86.h
@@ -84,8 +84,8 @@ class GenReg {
 	}
 };
 
-static BlockReturn gen_runcode(uint8_t * code) {
-	BlockReturn retval;
+static BlockReturnDynX86 gen_runcode(uint8_t * code) {
+	BlockReturnDynX86 retval;
 #if defined (_MSC_VER)
 	__asm {
 /* Prepare the flags */
@@ -1072,7 +1072,7 @@ static void gen_test_host_byte(void * data, uint8_t imm) {
 	cache_addb(imm);
 }
 
-static void gen_return(BlockReturn retcode) {
+static void gen_return(BlockReturnDynX86 retcode) {
 	gen_protectflags();
 	cache_addb(0x59);			//POP ECX, the flags
 	if (retcode==0) cache_addw(0xc033);		//MOV EAX, 0
@@ -1083,7 +1083,7 @@ static void gen_return(BlockReturn retcode) {
 	cache_addb(0xc3);			//RET
 }
 
-static void gen_return_fast(BlockReturn retcode,bool ret_exception=false) {
+static void gen_return_fast(BlockReturnDynX86 retcode,bool ret_exception=false) {
 	if (GCC_UNLIKELY(x86gen.flagsactive)) IllegalOption("gen_return_fast");
 	cache_addw(0x0d8b);			//MOV ECX, the flags
 	cache_addd((uintptr_t)&cpu_regs.flags);
diff --git a/src/cpu/core_dyn_x86/string.h b/src/cpu/core_dyn_x86/string.h
index 01fbef2b412..f5f7cca5c70 100644
--- a/src/cpu/core_dyn_x86/string.h
+++ b/src/cpu/core_dyn_x86/string.h
@@ -18,7 +18,7 @@
 
 #include "inout.h"
 
-enum STRING_OP {
+enum STRING_OP_DYNX86 {
 	STR_OUTSB=0,STR_OUTSW,STR_OUTSD,
 	STR_INSB=4,STR_INSW,STR_INSD,
 	STR_MOVSB=8,STR_MOVSW,STR_MOVSD,
@@ -28,7 +28,7 @@ enum STRING_OP {
 	STR_CMPSB=24,STR_CMPSW,STR_CMPSD
 };
 
-static void dyn_string(STRING_OP op) {
+static void dyn_string(STRING_OP_DYNX86 op) {
 	DynReg * si_base=decode.segprefix ? decode.segprefix : DREG(DS);
 	DynReg * di_base=DREG(ES);
 	DynReg * tmp_reg;bool usesi;bool usedi;bool cmp=false;
diff --git a/src/cpu/core_dynrec.cpp b/src/cpu/core_dynrec.cpp
index a0097db347f..af275cbefa9 100644
--- a/src/cpu/core_dynrec.cpp
+++ b/src/cpu/core_dynrec.cpp
@@ -97,7 +97,7 @@
 #define DRCD_REG_WORD(reg,dwrd) ((dwrd)?((void*)(&cpu_regs.regs[reg].dword[DW_INDEX])):((void*)(&cpu_regs.regs[reg].word[W_INDEX])))
 
 
-enum BlockReturn {
+enum BlockReturnDynRec {
 	BR_Normal=0,
 	BR_Cycles,
 	BR_Link1,BR_Link2,
@@ -120,7 +120,7 @@ static void IllegalOptionDynrec(const char* msg) {
 }
 
 static struct {
-	BlockReturn (*runcode)(uint8_t*);		// points to code that can start a block
+	BlockReturnDynRec (*runcode)(uint8_t*);		// points to code that can start a block
 	Bitu callback;				// the occurred callback
 	Bitu readdata;				// spare space used when reading from memory
 	uint32_t protected_regs[8];	// space to save/restore register values
@@ -192,7 +192,7 @@ static bool winrt_warning = true;
 #endif
 
 
-CacheBlockDynRec * LinkBlocks(BlockReturn ret) {
+CacheBlockDynRec * LinkBlocks(BlockReturnDynRec ret) {
 	CacheBlockDynRec * block=NULL;
 	// the last instruction was a control flow modifying instruction
 	uint32_t temp_ip=SegPhys(cs)+reg_eip;
@@ -307,8 +307,8 @@ Bits CPU_Core_Dynrec_Run(void) {
 run_block:
 		cache.block.running=0;
 		// now we're ready to run the dynamic code block
-//		BlockReturn ret=((BlockReturn (*)(void))(block->cache.start))();
-		BlockReturn ret=core_dynrec.runcode(block->cache.xstart);
+//		BlockReturnDynRec ret=((BlockReturnDynRec (*)(void))(block->cache.start))();
+		BlockReturnDynRec ret=core_dynrec.runcode(block->cache.xstart);
 
         if (sizeof(CPU_Cycles) > 4) {
             // HACK: All dynrec cores for each processor assume CPU_Cycles is 32-bit wide.
diff --git a/src/cpu/core_dynrec/cache.h b/src/cpu/core_dynrec/cache.h
index 7c6fb3c0755..32598b899d8 100644
--- a/src/cpu/core_dynrec/cache.h
+++ b/src/cpu/core_dynrec/cache.h
@@ -601,7 +601,7 @@ static INLINE void cache_addq(uint64_t val) {
 }
 
 
-static void dyn_return(BlockReturn retcode,bool ret_exception);
+static void dyn_return(BlockReturnDynRec retcode,bool ret_exception);
 static void dyn_run_code(void);
 
 static bool cache_initialized = false;
diff --git a/src/cpu/core_dynrec/decoder_basic.h b/src/cpu/core_dynrec/decoder_basic.h
index ca7f0c8bc2a..6b468223e25 100644
--- a/src/cpu/core_dynrec/decoder_basic.h
+++ b/src/cpu/core_dynrec/decoder_basic.h
@@ -93,7 +93,7 @@ static DualOps grp1_table[8]={
 
 
 // decoding information used during translation of a code block
-static struct DynDecode {
+static struct DynDecodeDynRec {
 	PhysPt code;			// pointer to next byte in the instruction stream
 	PhysPt code_start;		// pointer to the start of the current code block
 	PhysPt op_start;		// pointer to the start of the current instruction
@@ -614,11 +614,11 @@ template <typename T> static DRC_PTR_SIZE_IM INLINE gen_call_function_mm(const T
 
 
 
-enum save_info_type {db_exception, cycle_check, string_break, trap};
+enum save_info_type_dynrec {db_exception, cycle_check, string_break, trap};
 
 
 // function that is called on exceptions
-static BlockReturn DynRunException(uint32_t eip_add,uint32_t cycle_sub) {
+static BlockReturnDynRec DynRunException(uint32_t eip_add,uint32_t cycle_sub) {
 	reg_eip+=eip_add;
 	CPU_Cycles-=cycle_sub;
 	if (cpu.exception.which==SMC_CURRENT_BLOCK) return BR_SMCBlock;
@@ -630,7 +630,7 @@ static BlockReturn DynRunException(uint32_t eip_add,uint32_t cycle_sub) {
 // array with information about code that is generated at the
 // end of a cache block because it is rarely reached (like exceptions)
 static struct {
-	save_info_type type;
+	save_info_type_dynrec type;
 	DRC_PTR_SIZE_IM branch_pos;
 	uint32_t eip_change;
 	Bitu cycles;
@@ -640,7 +640,7 @@ Bitu used_save_info_dynrec=0;
 
 
 // return from current block, with returncode
-static void dyn_return(BlockReturn retcode,bool ret_exception=false) {
+static void dyn_return(BlockReturnDynRec retcode,bool ret_exception=false) {
 	if (!ret_exception) {
 		gen_mov_dword_to_reg_imm(FC_RETOP,retcode);
 	}
diff --git a/src/cpu/core_normal/string.h b/src/cpu/core_normal/string.h
index a796ba2fc2a..4daa8b508d8 100644
--- a/src/cpu/core_normal/string.h
+++ b/src/cpu/core_normal/string.h
@@ -19,7 +19,7 @@
 #include "inout.h"
 #include "logging.h"
 
-enum STRING_OP {
+enum STRING_OP_NORMAL {
 	// simple string ops
 	R_OUTSB,R_OUTSW,R_OUTSD,
 	R_INSB, R_INSW, R_INSD,
@@ -35,7 +35,7 @@ enum STRING_OP {
 
 extern int cpu_rep_max;
 
-void DoString(STRING_OP type) {
+void DoString(STRING_OP_NORMAL type) {
 	static PhysPt  si_base,di_base;
 	static uint32_t	si_index,di_index;
 	static uint32_t	add_mask;