summarylogtreecommitdiffstats
path: root/firebird-gcc6.patch
blob: 1bc69073c13d9091cbf0a7d12e5a34413c73f077 (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
From acb2b707dae178dd5a7a03eb3e21d885ba971974 Mon Sep 17 00:00:00 2001
From: AlexPeshkoff <alexander.peshkoff@gmail.com>
Date: Tue, 23 Jan 2018 19:44:06 +0300
Subject: [PATCH] Make it build with gcc6, also fixed most annoying warnings

---
 builds/posix/prefix.linux         |  2 +-
 builds/posix/prefix.linux_amd64   |  2 +-
 builds/posix/prefix.linux_generic |  2 +-
 src/common/classes/alloc.cpp      | 11 ++++-
 src/common/classes/alloc.h        | 84 ++++++++++++++++++++++-----------------
 src/include/fb_blk.h              | 17 ++++----
 src/jrd/gdsassert.h               |  2 +-
 7 files changed, 68 insertions(+), 52 deletions(-)

diff --git a/builds/posix/prefix.linux b/builds/posix/prefix.linux
index 61f01813e4..b37373215e 100644
--- a/builds/posix/prefix.linux
+++ b/builds/posix/prefix.linux
@@ -18,7 +18,7 @@
 #
 # 2 Oct 2002, Nickolay Samofatov - Major cleanup
 
-COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -pipe -MMD -fPIC -fmessage-length=0
+COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -pipe -MMD -fPIC -fmessage-length=0 -std=gnu++03 -fno-delete-null-pointer-checks
 OPTIMIZE_FLAGS=-O3 -march=i586 -mtune=i686 -fno-omit-frame-pointer
 WARN_FLAGS=-Wall -Wno-switch -Wno-parentheses -Wno-unknown-pragmas -Wno-unused-variable
 
diff --git a/builds/posix/prefix.linux_amd64 b/builds/posix/prefix.linux_amd64
index 8a22b2c2e9..4f20d0aaea 100644
--- a/builds/posix/prefix.linux_amd64
+++ b/builds/posix/prefix.linux_amd64
@@ -18,7 +18,7 @@
 #
 # 2 Oct 2002, Nickolay Samofatov - Major cleanup
 
-COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -DAMD64 -pipe -MMD -fPIC -fmessage-length=0
+COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -DAMD64 -pipe -MMD -fPIC -fmessage-length=0 -std=gnu++03 -fno-delete-null-pointer-checks
 OPTIMIZE_FLAGS=-O3 -fno-omit-frame-pointer 
 WARN_FLAGS=-Wall -Wno-switch -Wno-parentheses -Wno-unknown-pragmas -Wno-unused-variable
 CXXFLAGS:= $(CXXFLAGS) -fno-rtti
diff --git a/builds/posix/prefix.linux_generic b/builds/posix/prefix.linux_generic
index 1a25abebff..130f43bcf6 100644
--- a/builds/posix/prefix.linux_generic
+++ b/builds/posix/prefix.linux_generic
@@ -18,7 +18,7 @@
 #
 # 2 Oct 2002, Nickolay Samofatov - Major cleanup
 
-COMMON_FLAGS=-DLINUX -pipe -MMD -fPIC -DFB_SEND_FLAGS=MSG_NOSIGNAL -fsigned-char
+COMMON_FLAGS=-DLINUX -pipe -MMD -fPIC -DFB_SEND_FLAGS=MSG_NOSIGNAL -fsigned-char -std=gnu++03 -fno-delete-null-pointer-checks
 
 PROD_FLAGS=-ggdb -O3 -DNDEBUG $(COMMON_FLAGS)
 DEV_FLAGS=-ggdb -p -Wall -Wno-switch $(COMMON_FLAGS)
diff --git a/src/common/classes/alloc.cpp b/src/common/classes/alloc.cpp
index 7a7a76caab..84238cf25c 100644
--- a/src/common/classes/alloc.cpp
+++ b/src/common/classes/alloc.cpp
@@ -2199,6 +2199,13 @@ void* MemoryPool::globalAlloc(size_t s) THROW_BAD_ALLOC
 }
 #endif // LIBC_CALLS_NEW
 
+void* MemoryPool::calloc(size_t size ALLOC_PARAMS)
+{
+	void* block = allocate(size ALLOC_PASS_ARGS);
+	memset(block, 0, size);
+	return block;
+}
+
 #if defined(DEV_BUILD)
 void AutoStorage::ProbeStack() const
 {
@@ -2224,11 +2231,11 @@ void AutoStorage::ProbeStack() const
 
 void* operator new(size_t s) THROW_BAD_ALLOC
 {
-	return Firebird::MemoryPool::globalAlloc(s);
+	return Firebird::MemoryPool::globalAlloc(s ALLOC_ARGS);
 }
 void* operator new[](size_t s) THROW_BAD_ALLOC
 {
-	return Firebird::MemoryPool::globalAlloc(s);
+	return Firebird::MemoryPool::globalAlloc(s ALLOC_ARGS);
 }
 
 void operator delete(void* mem) throw()
diff --git a/src/common/classes/alloc.h b/src/common/classes/alloc.h
index 6a27a7b4fb..81a26feffa 100644
--- a/src/common/classes/alloc.h
+++ b/src/common/classes/alloc.h
@@ -73,6 +73,16 @@
 
 #endif
 
+#ifdef DEBUG_GDS_ALLOC
+#define ALLOC_ARGS , __FILE__, __LINE__
+#define ALLOC_PARAMS , const char* file, int line
+#define ALLOC_PASS_ARGS , file, line
+#else
+#define ALLOC_ARGS
+#define ALLOC_PARAMS
+#define ALLOC_PASS_ARGS
+#endif // DEBUG_GDS_ALLOC
+
 namespace Firebird {
 
 // Maximum number of B+ tree pages kept spare for tree allocation
@@ -395,15 +405,11 @@ class MemoryPool
 	// This method is needed when C++ runtime can call
 	// redefined by us operator new before initialization of global variables.
 #ifdef LIBC_CALLS_NEW
-	static void* globalAlloc(size_t s) THROW_BAD_ALLOC;
+	static void* globalAlloc(size_t s ALLOC_PARAMS) THROW_BAD_ALLOC;
 #else // LIBC_CALLS_NEW
-	static void* globalAlloc(size_t s) THROW_BAD_ALLOC
+	static void* globalAlloc(size_t s ALLOC_PARAMS) THROW_BAD_ALLOC
 	{
-		return processMemoryPool->allocate(s
-#ifdef DEBUG_GDS_ALLOC
-	  		,__FILE__, __LINE__
-#endif
-		);
+		return processMemoryPool->allocate(s ALLOC_PASS_ARGS);
 	}
 #endif // LIBC_CALLS_NEW
 
@@ -424,19 +430,7 @@ class MemoryPool
 	}
 
 	// Allocate zero-initialized block of memory
-	void* calloc(size_t size
-#ifdef DEBUG_GDS_ALLOC
-		, const char* file = NULL, int line = 0
-#endif
-	) {
-		void* result = allocate(size
-#ifdef DEBUG_GDS_ALLOC
-			, file, line
-#endif
-		);
-		memset(result, 0, size);
-		return result;
-	}
+	void* calloc(size_t size ALLOC_PARAMS);
 
 	// Initialize and finalize global memory pool
 	static void init();
@@ -498,40 +492,58 @@ using Firebird::MemoryPool;
 
 inline static MemoryPool* getDefaultMemoryPool() { return Firebird::MemoryPool::processMemoryPool; }
 
-#if (( ! __GNUC__ ) || ( __GNUC__ < 6 ))
+// operators new and delete
 
-// Global versions of operators new and delete
 void* operator new(size_t s) THROW_BAD_ALLOC;
 void* operator new[](size_t s) THROW_BAD_ALLOC;
 
-#endif
-
 void operator delete(void* mem) throw();
 void operator delete[](void* mem) throw();
 
+inline void* operator new(size_t s, Firebird::MemoryPool& pool ALLOC_PARAMS) THROW_BAD_ALLOC
+{
+	return pool.allocate(s ALLOC_PASS_ARGS);
+}
+inline void* operator new[](size_t s, Firebird::MemoryPool& pool ALLOC_PARAMS) THROW_BAD_ALLOC
+{
+	return pool.allocate(s ALLOC_PASS_ARGS);
+}
+
+inline void operator delete(void* mem, Firebird::MemoryPool& pool ALLOC_PARAMS) throw()
+{
+	MemoryPool::globalFree(mem);
+}
+inline void operator delete[](void* mem, Firebird::MemoryPool& pool ALLOC_PARAMS) throw()
+{
+	MemoryPool::globalFree(mem);
+}
+
 #ifdef DEBUG_GDS_ALLOC
-inline void* operator new(size_t s, Firebird::MemoryPool& pool, const char* file, int line)
+
+inline void* operator new(size_t s ALLOC_PARAMS) THROW_BAD_ALLOC
 {
-	return pool.allocate(s, file, line);
+	return MemoryPool::globalAlloc(s ALLOC_PASS_ARGS);
 }
-inline void* operator new[](size_t s, Firebird::MemoryPool& pool, const char* file, int line)
+inline void* operator new[](size_t s ALLOC_PARAMS) THROW_BAD_ALLOC
 {
-	return pool.allocate(s, file, line);
+	return MemoryPool::globalAlloc(s ALLOC_PASS_ARGS);
 }
-#define FB_NEW(pool) new(pool, __FILE__, __LINE__)
-#define FB_NEW_RPT(pool, count) new(pool, count, __FILE__, __LINE__)
-#else
-inline void* operator new(size_t s, Firebird::MemoryPool& pool)
+
+inline void operator delete(void* mem ALLOC_PARAMS) throw()
 {
-	return pool.allocate(s);
+	MemoryPool::globalFree(mem);
 }
-inline void* operator new[](size_t s, Firebird::MemoryPool& pool)
+inline void operator delete[](void* mem ALLOC_PARAMS) throw()
 {
-	return pool.allocate(s);
+	MemoryPool::globalFree(mem);
 }
+
+#define FB_NEW(pool) new(pool, __FILE__, __LINE__)
+#define FB_NEW_RPT(pool, count) new(pool, count, __FILE__, __LINE__)
+#else // DEBUG_GDS_ALLOC
 #define FB_NEW(pool) new(pool)
 #define FB_NEW_RPT(pool, count) new(pool, count)
-#endif
+#endif // DEBUG_GDS_ALLOC
 
 
 namespace Firebird
diff --git a/src/include/fb_blk.h b/src/include/fb_blk.h
index b57443f3c4..fdd894408b 100644
--- a/src/include/fb_blk.h
+++ b/src/include/fb_blk.h
@@ -170,8 +170,8 @@ class pool_alloc : public TypedHandle<BLOCK_TYPE>
 
 private:
     // These operators are off-limits
-	void* operator new(size_t s) { return 0; }
-    void* operator new[](size_t s) { return 0; }
+	void* operator new(size_t s);
+    void* operator new[](size_t s);
 };
 
 template<typename RPT, BlockType BLOCK_TYPE = type_unknown>
@@ -193,16 +193,13 @@ class pool_alloc_rpt : public TypedHandle<BLOCK_TYPE>
 
 private:
     // These operations are not supported on static repeat-base objects
-    void* operator new[](size_t s, MemoryPool& p)
-        { return 0; }
-    void operator delete[](void* mem, MemoryPool& p)
-        { }
-    void operator delete[](void* mem)
-		{ }
+    void* operator new[](size_t s, MemoryPool& p);
+    void operator delete[](void* mem, MemoryPool& p);
+    void operator delete[](void* mem);
 
     // These operators are off-limits
-	void* operator new(size_t s) { return 0; }
-    void* operator new[](size_t s) { return 0; }
+	void* operator new(size_t s);
+    void* operator new[](size_t s);
 };
 
 #endif	// INCLUDE_FB_BLK
diff --git a/src/jrd/gdsassert.h b/src/jrd/gdsassert.h
index 9431479fc7..dd90c38823 100644
--- a/src/jrd/gdsassert.h
+++ b/src/jrd/gdsassert.h
@@ -28,7 +28,7 @@
 #include <stdlib.h>		// abort()
 #include <stdio.h>
 
-#define FB_ASSERT_FAILURE_STRING	"Assertion (%s) failure: %s %"LINEFORMAT"\n"
+#define FB_ASSERT_FAILURE_STRING	"Assertion (%s) failure: %s %" LINEFORMAT "\n"
 
 #ifdef SUPERCLIENT