Skip to content

Commit 592eb5b

Browse files
feliwirFighter19
andcommitted
[CORE][CMAKE] Fix Linux compilation of WWLib
Co-authored-by: Patrick Zacharias <[email protected]>
1 parent fc867b8 commit 592eb5b

File tree

22 files changed

+85
-56
lines changed

22 files changed

+85
-56
lines changed

Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ set(WWLIB_SRC
7171
#md5.h
7272
mempool.h
7373
mmsys.h
74-
mpu.cpp
75-
MPU.H
7674
multilist.cpp
7775
multilist.h
7876
mutex.cpp
@@ -91,8 +89,6 @@ set(WWLIB_SRC
9189
RANDOM.H
9290
rawfile.cpp
9391
RAWFILE.H
94-
rcfile.cpp
95-
rcfile.h
9692
readline.cpp
9793
readline.h
9894
realcrc.cpp
@@ -102,8 +98,6 @@ set(WWLIB_SRC
10298
refcount.h
10399
#regexpr.cpp
104100
#regexpr.h
105-
registry.cpp
106-
registry.h
107101
#search.h
108102
sharebuf.h
109103
Signaler.h
@@ -134,14 +128,10 @@ set(WWLIB_SRC
134128
uarray.h
135129
vector.cpp
136130
Vector.H
137-
verchk.cpp
138-
verchk.h
139131
visualc.h
140132
widestring.cpp
141133
widestring.h
142134
win.h
143-
WWCOMUtil.cpp
144-
WWCOMUtil.h
145135
wwfile.cpp
146136
WWFILE.H
147137
wwstring.cpp
@@ -152,6 +142,21 @@ set(WWLIB_SRC
152142
XSTRAW.H
153143
)
154144

145+
if(WIN32)
146+
list(APPEND WWLIB_SRC
147+
mpu.cpp
148+
MPU.H
149+
rcfile.cpp
150+
rcfile.h
151+
registry.cpp
152+
registry.h
153+
verchk.cpp
154+
verchk.h
155+
WWCOMUtil.cpp
156+
WWCOMUtil.h
157+
)
158+
endif()
159+
155160
# Targets to build.
156161
add_library(core_wwlib STATIC)
157162
set_target_properties(core_wwlib PROPERTIES OUTPUT_NAME wwlib)

Core/Libraries/Source/WWVegas/WWLib/CRC.H

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
#define CRC_H
4242

4343
#include <stdlib.h>
44-
#ifdef _UNIX
45-
#include "osdep.h"
46-
#endif
44+
45+
// TheSuperHackers @compile feliwir 17/04/2025 include _ltrotl macros
46+
#include <Utility/intrin_compat.h>
4747

4848
/*
4949
** This is a CRC engine class. It will process submitted data and generate a CRC from it.

Core/Libraries/Source/WWVegas/WWLib/FastAllocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "FastAllocator.h"
20-
#include <new.h>
20+
#include <new>
2121

2222
static FastAllocatorGeneral* generalAllocator; //This general allocator will do all allocations for us.
2323

Core/Libraries/Source/WWVegas/WWLib/Vector.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#include <assert.h>
6262
#include <stdlib.h>
6363
#include <string.h>
64-
#include <new.h>
64+
#include <new>
6565

6666
#ifdef _MSC_VER
6767
#pragma warning (disable : 4702) // unreachable code, happens with some uses of these templates

Core/Libraries/Source/WWVegas/WWLib/WWFILE.H

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
#ifndef WWFILE_Hx
4141
#define WWFILE_Hx
4242

43-
#ifdef _UNIX
44-
#include "osdep.h"
45-
#endif
46-
4743
#define YEAR(dt) (((dt & 0xFE000000) >> (9 + 16)) + 1980)
4844
#define MONTH(dt) ((dt & 0x01E00000) >> (5 + 16))
4945
#define DAY(dt) ((dt & 0x001F0000) >> (0 + 16))

Core/Libraries/Source/WWVegas/WWLib/always.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#include <assert.h>
4444
#include <new>
4545

46+
// TheSuperHackers @compile feliwir 17/04/2025 include utility macros for cross-platform compatibility
47+
#include <Utility/compat.h>
48+
4649
// Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use.
4750
#pragma warning(disable : 4530)
4851

Core/Libraries/Source/WWVegas/WWLib/argv.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
#include "always.h"
4848
#endif
4949

50-
#ifdef _UNIX
51-
#include "osdep.h"
52-
#endif
53-
5450
// Used to parse command line that is passed into WinMain.
5551
// It also has the ability to load a file with values to append to the command line.
5652
// Normally in WinMain() there would be a call Argv::Init(lpCmdLine, fileprefix).

Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
#include "wwdebug.h"
2222
#include "thread.h"
2323
#pragma warning (disable : 4201) // Nonstandard extension - nameless struct
24-
#include <windows.h>
2524
#include "systimer.h"
2625
#include <Utility/intrin_compat.h>
2726

27+
#ifdef _WIN32
28+
#include <windows.h>
29+
#endif
30+
2831
#ifdef _UNIX
2932
# include <time.h> // for time(), localtime() and timezone variable.
3033
#endif
@@ -57,7 +60,7 @@ int CPUDetectClass::ProcessorFamily;
5760
int CPUDetectClass::ProcessorModel;
5861
int CPUDetectClass::ProcessorRevision;
5962
int CPUDetectClass::ProcessorSpeed;
60-
__int64 CPUDetectClass::ProcessorTicksPerSecond; // Ticks per second
63+
sint64 CPUDetectClass::ProcessorTicksPerSecond; // Ticks per second
6164
double CPUDetectClass::InvProcessorTicksPerSecond; // 1.0 / Ticks per second
6265

6366
unsigned CPUDetectClass::FeatureBits;
@@ -125,10 +128,10 @@ const char* CPUDetectClass::Get_Processor_Manufacturer_Name()
125128

126129
#define ASM_RDTSC _asm _emit 0x0f _asm _emit 0x31
127130

128-
static unsigned Calculate_Processor_Speed(__int64& ticks_per_second)
131+
static unsigned Calculate_Processor_Speed(sint64& ticks_per_second)
129132
{
130-
unsigned __int64 timer0=0;
131-
unsigned __int64 timer1=0;
133+
sint64 timer0=0;
134+
sint64 timer1=0;
132135

133136
timer0=_rdtsc();
134137

@@ -138,8 +141,8 @@ static unsigned Calculate_Processor_Speed(__int64& ticks_per_second)
138141
timer1=_rdtsc();
139142
}
140143

141-
__int64 t=timer1-timer0;
142-
ticks_per_second=(__int64)((1000.0/(double)elapsed)*(double)t); // Ticks per second
144+
sint64 t=timer1-timer0;
145+
ticks_per_second=(sint64)((1000.0/(double)elapsed)*(double)t); // Ticks per second
143146
return unsigned((double)t/(double)(elapsed*1000));
144147
}
145148

@@ -898,8 +901,8 @@ void CPUDetectClass::Init_Memory()
898901

899902
void CPUDetectClass::Init_OS()
900903
{
901-
OSVERSIONINFO os;
902904
#ifdef WIN32
905+
OSVERSIONINFO os;
903906
os.dwOSVersionInfoSize = sizeof(os);
904907
GetVersionEx(&os);
905908

@@ -940,9 +943,11 @@ void CPUDetectClass::Init_Processor_Log()
940943

941944
SYSLOG(("Operating System: "));
942945
switch (OSVersionPlatformId) {
946+
#ifdef _WIN32
943947
case VER_PLATFORM_WIN32s: SYSLOG(("Windows 3.1")); break;
944948
case VER_PLATFORM_WIN32_WINDOWS: SYSLOG(("Windows 9x")); break;
945949
case VER_PLATFORM_WIN32_NT: SYSLOG(("Windows NT")); break;
950+
#endif
946951
}
947952
SYSLOG(("\r\n"));
948953

@@ -1223,6 +1228,7 @@ void Get_OS_Info(
12231228
switch (OSVersionPlatformId) {
12241229
default:
12251230
break;
1231+
#ifdef _WIN32
12261232
case VER_PLATFORM_WIN32_WINDOWS:
12271233
{
12281234
for(int i=0;i<sizeof(Windows9xVersionTable)/sizeof(os_info);++i) {
@@ -1304,5 +1310,6 @@ void Get_OS_Info(
13041310

13051311
// No more-specific version detected; fallback to XX
13061312
os_info.Code="WINXX";
1313+
#endif
13071314
}
13081315
}

Core/Libraries/Source/WWVegas/WWLib/hash.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
#include "hash.h"
3939
#include "wwdebug.h"
4040
#include "realcrc.h"
41-
#ifdef _UNIX
42-
#include "osdep.h"
43-
#endif
4441

4542
#include <string.h>
4643

Core/Libraries/Source/WWVegas/WWLib/mempool.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#include "bittype.h"
5454
#include "wwdebug.h"
5555
#include "mutex.h"
56-
#include <new.h>
56+
#include <new>
5757
#include <stdlib.h>
5858
#include <stddef.h>
5959

@@ -157,8 +157,14 @@ class AutoPoolClass
157157
** Macro to declare the allocator for your class. Put this in the cpp file for
158158
** the class.
159159
*/
160+
#if defined(_MSC_VER) && _MSC_VER < 1300
160161
#define DEFINE_AUTO_POOL(T,BLOCKSIZE) \
161162
ObjectPoolClass<T,BLOCKSIZE> AutoPoolClass<T,BLOCKSIZE>::Allocator;
163+
#else
164+
#define DEFINE_AUTO_POOL(T,BLOCKSIZE) \
165+
template<>\
166+
ObjectPoolClass<T,BLOCKSIZE> AutoPoolClass<T,BLOCKSIZE>::Allocator = {}
167+
#endif
162168

163169

164170
/***********************************************************************************************

Core/Libraries/Source/WWVegas/WWLib/mutex.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818

1919
#include "mutex.h"
2020
#include "wwdebug.h"
21+
#ifdef _WIN32
2122
#include <windows.h>
22-
23+
#endif
2324

2425
// ----------------------------------------------------------------------------
2526

Core/Libraries/Source/WWVegas/WWLib/refcount.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040

4141

4242
#include "refcount.h"
43-
#include <windows.h>
4443

44+
// TheSuperHackers @compile feliwir 17/04/2025 include __debugbreak macros
45+
#include <Utility/intrin_compat.h>
4546

4647
#ifndef NDEBUG
4748

@@ -174,7 +175,7 @@ void RefCountClass::Add_Ref(void) const
174175

175176
// See if programmer set break on for a specific address.
176177
if (this == BreakOnReference) {
177-
DebugBreak(); // trigger the debugger
178+
__debugbreak(); // trigger the debugger
178179
}
179180
Inc_Total_Refs(this);
180181
}
@@ -201,7 +202,7 @@ void RefCountClass::Dec_Total_Refs(const RefCountClass * obj)
201202

202203
// See if programmer set break on for a specific address.
203204
if (obj == BreakOnReference) {
204-
DebugBreak(); // trigger the debugger
205+
__debugbreak(); // trigger the debugger
205206
}
206207
}
207208

Core/Libraries/Source/WWVegas/WWLib/systimer.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,25 @@
3838
#ifndef _SYSTIMER_H
3939

4040
#include "always.h"
41+
#ifdef _WIN32
4142
#include <windows.h>
4243
#include "mmsys.h"
4344

4445
#define TIMEGETTIME SystemTime.Get
4546
#define MS_TIMER_SECOND 1000
47+
#else
48+
#include <sys/time.h>
49+
50+
inline unsigned long systimerGetMS(void)
51+
{
52+
struct timeval tv;
53+
gettimeofday(&tv, NULL);
54+
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
55+
}
56+
57+
#define TIMEGETTIME systimerGetMS
58+
#define MS_TIMER_SECOND 1000
59+
#endif
4660

4761
/*
4862
** Class that just wraps around timeGetTime()

Core/Libraries/Source/WWVegas/WWLib/thread.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
#include "thread.h"
2222
#include "Except.h"
2323
#include "wwdebug.h"
24-
#include <process.h>
25-
#include <windows.h>
2624
#pragma warning ( push )
2725
#pragma warning ( disable : 4201 )
2826
#include "systimer.h"
2927
#pragma warning ( pop )
3028

29+
#ifdef _WIN32
30+
#include <process.h>
31+
#include <windows.h>
32+
#endif
3133

3234
ThreadClass::ThreadClass(const char *thread_name, ExceptionHandlerType exception_handler) : handle(0), running(false), thread_priority(0)
3335
{

Core/Libraries/Source/WWVegas/WWLib/thread.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#if defined(_MSC_VER)
2323
#pragma once
2424
#endif
25-
#ifdef _UNIX
26-
#include "osdep.h"
27-
#endif
2825

2926
#include "always.h"
3027
#include "Vector.H"

Core/Libraries/Source/WWVegas/WWLib/widestring.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@
4949
#include "wwstring.h"
5050
#include "trim.h"
5151
#include <wchar.h>
52-
#ifdef _UNIX
53-
#include "osdep.h"
54-
#endif
5552

5653
//////////////////////////////////////////////////////////////////////
5754
//

Core/Libraries/Source/WWVegas/WWLib/win.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
** 4069, 4200, 4237, 4103, 4001, 4035, 4164. Makes you wonder, eh?
5050
*/
5151

52+
#ifdef _WINDOWS
53+
5254
// When including windows, lets just bump the warning level back to 3...
5355
#if (_MSC_VER >= 1200)
5456
#pragma warning(push, 3)
@@ -69,7 +71,6 @@
6971
#pragma warning(pop)
7072
#endif
7173

72-
#ifdef _WINDOWS
7374
extern HINSTANCE ProgramInstance;
7475
extern HWND MainWindow;
7576
extern bool GameInFocus;

Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#include <memory.h>
4040
#include "WWFILE.H"
4141

42+
// TheSuperHackers @compile feliwir 17/04/2025 include _vsnprintf macros
43+
#include <Utility/compat.h>
44+
4245
#pragma warning(disable : 4514)
4346

4447
int FileClass::Printf(char *str, ...)

0 commit comments

Comments
 (0)