summaryrefslogtreecommitdiffstats
path: root/games/eduke32/tools.diff
blob: da638e62ee8bf6096a21363d7445afe09fe2438f (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
From a7a6cd043749947773cbf3e85ed66ffd6273f659 Mon Sep 17 00:00:00 2001
From: Richard Gobeille <richard@voidpoint.com>
Date: Mon, 20 Dec 2021 02:58:04 -0800
Subject: [PATCH] tools: fix compilation of Build utilities

---
 GNUmakefile                       |  2 +-
 source/build/include/baselayer.h  |  3 +--
 source/build/include/compat.h     | 13 +++++++++++++
 source/build/include/sjson.h      |  2 --
 source/build/src/baselayer.cpp    | 12 ++----------
 source/build/src/sdlayer.cpp      |  2 +-
 source/build/src/winlayer.cpp     |  2 +-
 source/tools/src/generateicon.cpp |  1 +
 8 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index 7ebbd71a8..c8c174fb3 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -437,7 +437,7 @@ tools_obj := $(obj)/$(tools)
 
 tools_cflags := $(engine_cflags)
 
-tools_deps := engine_tools
+tools_deps := engine_tools mimalloc
 
 tools_targets := \
     arttool \
diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h
index 008318003..b6d61135c 100644
--- a/source/build/include/baselayer.h
+++ b/source/build/include/baselayer.h
@@ -19,8 +19,7 @@ extern int app_main(int argc, char const * const * argv);
 extern const char* AppProperName;
 extern const char* AppTechnicalName;
 
-void engineCreateAllocator(void);
-void engineDestroyAllocator(void);
+void engineSetupAllocator(void);
 
 #ifdef DEBUGGINGAIDS
 # define DEBUG_MASK_DRAWING
diff --git a/source/build/include/compat.h b/source/build/include/compat.h
index 5dd6d0b1d..fd536253a 100644
--- a/source/build/include/compat.h
+++ b/source/build/include/compat.h
@@ -1297,6 +1297,19 @@ void *handle_memerr(void);
 
 extern sm_allocator g_sm_heap;
 
+static FORCE_INLINE void engineCreateAllocator(void)
+{
+    // 8 buckets of 2MB each--we don't really need to burn a lot of memory here for this thing to do its job
+    g_sm_heap = _sm_allocator_create(SMM_MAX_BUCKET_COUNT, 2097152);
+    _sm_allocator_thread_cache_create(g_sm_heap, sm::CACHE_HOT, { 20480, 32768, 32768, 1536, 4096, 8192, 128, 4096 });
+}
+
+static FORCE_INLINE void engineDestroyAllocator(void)
+{
+    _sm_allocator_thread_cache_destroy(g_sm_heap);
+    _sm_allocator_destroy(g_sm_heap);
+}
+
 #ifdef BITNESS64
 # define ALLOC_ALIGNMENT 16
 #else
diff --git a/source/build/include/sjson.h b/source/build/include/sjson.h
index b691bca2a..74a98ea05 100644
--- a/source/build/include/sjson.h
+++ b/source/build/include/sjson.h
@@ -144,8 +144,6 @@
 #ifndef SJSON_H_
 #define SJSON_H_
 
-extern "C" void engineDestroyAllocator(void);
-
 #ifdef _MSC_VER
 #   ifndef __cplusplus
 
diff --git a/source/build/src/baselayer.cpp b/source/build/src/baselayer.cpp
index c1fe589ee..bc81e0616 100644
--- a/source/build/src/baselayer.cpp
+++ b/source/build/src/baselayer.cpp
@@ -139,17 +139,9 @@ static int osdfunc_heapinfo(osdcmdptr_t UNUSED(parm))
     return OSDCMD_OK;
 }
 
-void engineDestroyAllocator(void)
+void engineSetupAllocator(void)
 {
-    _sm_allocator_thread_cache_destroy(g_sm_heap);
-    _sm_allocator_destroy(g_sm_heap);
-}
-
-void engineCreateAllocator(void)
-{
-    // 8 buckets of 2MB each--we don't really need to burn a lot of memory here for this thing to do its job
-    g_sm_heap = _sm_allocator_create(SMM_MAX_BUCKET_COUNT, 2097152);
-    _sm_allocator_thread_cache_create(g_sm_heap, sm::CACHE_HOT, { 20480, 32768, 32768, 1536, 4096, 8192, 128, 4096 });
+    engineCreateAllocator();
 
 #ifdef SMMALLOC_STATS_SUPPORT
     OSD_RegisterFunction("bucketlist", "bucketlist: list bucket statistics", osdfunc_bucketlist);
diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp
index 27ab392ea..fa76bebf8 100644
--- a/source/build/src/sdlayer.cpp
+++ b/source/build/src/sdlayer.cpp
@@ -452,7 +452,7 @@ int SDL_main(int argc, char *argv[])
 int main(int argc, char *argv[])
 #endif
 {
-    engineCreateAllocator();
+    engineSetupAllocator();
 
 #if SDL_MAJOR_VERSION >= 2 && (SDL_MINOR_VERSION > 0 || SDL_PATCHLEVEL >= 8)
     if (EDUKE32_SDL_LINKED_PREREQ(linked, 2, 0, 8))
diff --git a/source/build/src/winlayer.cpp b/source/build/src/winlayer.cpp
index 367c0ec03..ccf9fa25f 100644
--- a/source/build/src/winlayer.cpp
+++ b/source/build/src/winlayer.cpp
@@ -281,7 +281,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
     _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF);
 #endif
 
-    engineCreateAllocator();
+    engineSetupAllocator();
 
     mutex_init(&m_initprintf);
 
diff --git a/source/tools/src/generateicon.cpp b/source/tools/src/generateicon.cpp
index 16f7096e3..81f46b28b 100644
--- a/source/tools/src/generateicon.cpp
+++ b/source/tools/src/generateicon.cpp
@@ -61,6 +61,7 @@ int main(int argc, char **argv)
 
     memset(&icon, 0, sizeof(icon));
 
+    engineCreateAllocator();
     kpzload(argv[1], (intptr_t*)&icon.pixels, &icon.width, &icon.height);
     if (!icon.pixels) {
         Bfprintf(stderr, "Failure loading %s\n", argv[1]);
-- 
GitLab