diff options
Diffstat (limited to 'firebird-gcc6.patch')
-rw-r--r-- | firebird-gcc6.patch | 272 |
1 files changed, 272 insertions, 0 deletions
diff --git a/firebird-gcc6.patch b/firebird-gcc6.patch new file mode 100644 index 000000000000..1bc69073c13d --- /dev/null +++ b/firebird-gcc6.patch @@ -0,0 +1,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 + |