Files
MINGW-packages/mingw-w64-firebird/005-firebird-sources-fixes.patch
2024-01-15 02:42:12 +08:00

256 lines
7.9 KiB
Diff

diff --git a/src/common/classes/FpeControl.h b/src/common/classes/FpeControl.h
index 5e03522..08fd4ea 100644
--- a/src/common/classes/FpeControl.h
+++ b/src/common/classes/FpeControl.h
@@ -30,7 +30,7 @@
#define CLASSES_FPE_CONTROL_H
#include <math.h>
-#if defined(WIN_NT)
+#if defined(_MSC_VER)
#include <float.h>
#else
#include <fenv.h>
@@ -78,7 +78,7 @@ public:
}
}
-#if defined(WIN_NT)
+#if defined(_MSC_VER)
static void maskAll() throw()
{
_clearfp(); // always call _clearfp() before setting control word
@@ -215,7 +215,7 @@ private:
inline bool isNegativeInf(double x)
{
-#ifdef WIN_NT
+#ifdef _MSC_VER
return _fpclass(x) == _FPCLASS_NINF;
#else
return x == -INFINITY;
diff --git a/src/common/isc.cpp b/src/common/isc.cpp
index 9183d8b..6bd2694 100644
--- a/src/common/isc.cpp
+++ b/src/common/isc.cpp
@@ -147,7 +147,7 @@ public:
if (!InitializeSecurityDescriptor(p_security_desc, SECURITY_DESCRIPTOR_REVISION) ||
!SetSecurityDescriptorDacl(p_security_desc, TRUE, NULL, FALSE))
{
- delete p_security_desc;
+ operator delete(p_security_desc);
attributes.lpSecurityDescriptor = NULL;
}
}
@@ -155,7 +155,7 @@ public:
~SecurityAttributes()
{
if (attributes.lpSecurityDescriptor)
- delete attributes.lpSecurityDescriptor;
+ operator delete(attributes.lpSecurityDescriptor);
}
operator LPSECURITY_ATTRIBUTES()
diff --git a/src/common/isc_sync.cpp b/src/common/isc_sync.cpp
index 7916df5..4081fea 100644
--- a/src/common/isc_sync.cpp
+++ b/src/common/isc_sync.cpp
@@ -1786,7 +1786,11 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject
}
PathName mappedName;
+#ifdef MINGW
+ if (!getMappedFileName(address, mappedName))
+#else
if (!getMappedFileName(address, mappedName) || mappedName != expanded_filename)
+#endif
{
UnmapViewOfFile(address);
CloseHandle(file_obj);
@@ -2035,7 +2039,7 @@ static const int DEFAULT_INTERLOCKED_SPIN_COUNT_SMP = 200;
static SLONG pid = 0;
-typedef WINBASEAPI BOOL (WINAPI *pfnSwitchToThread) ();
+typedef BOOL (WINAPI *pfnSwitchToThread) ();
static inline BOOL switchToThread()
{
static pfnSwitchToThread fnSwitchToThread = NULL;
diff --git a/src/common/os/guid.h b/src/common/os/guid.h
index 74b1378..855d9cf 100644
--- a/src/common/os/guid.h
+++ b/src/common/os/guid.h
@@ -55,7 +55,7 @@ const int GUID_BODY_SIZE = 36;
// Some versions of MSVC cannot recognize hh specifier but MSVC 2015 has it
const char* const GUID_FORMAT =
- "{%08X-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}";
+ "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}";
const int GUID_FORMAT_ARGS = 11;
void GenerateRandomBytes(void* buffer, FB_SIZE_T size);
diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp
index 40871dc..35623d0 100644
--- a/src/common/unicode_util.cpp
+++ b/src/common/unicode_util.cpp
@@ -56,9 +56,12 @@
using namespace Firebird;
namespace {
-#if defined(WIN_NT)
+#if defined(_MSC_VER)
const char* const inTemplate = "icuin%s.dll";
const char* const ucTemplate = "icuuc%s.dll";
+#elif defined(MINGW)
+const char* const inTemplate = "libicuin%s.dll";
+const char* const ucTemplate = "libicuuc%s.dll";
#elif defined(DARWIN)
const char* const inTemplate = "lib/libicui18n.%s.dylib";
const char* const ucTemplate = "lib/libicuuc.%s.dylib";
@@ -1329,7 +1332,7 @@ UnicodeUtil::ConversionICU& UnicodeUtil::getConversionICU()
for (int major = 79; major >= 3;)
{
-#ifdef WIN_NT
+#ifdef _MSC_VER
int minor = 0;
#else
int minor = 9;
diff --git a/src/common/utils_proto.h b/src/common/utils_proto.h
index e70e3c0..bc68121 100644
--- a/src/common/utils_proto.h
+++ b/src/common/utils_proto.h
@@ -116,10 +116,10 @@ namespace fb_utils
#if FB_INT64_COMPARE_FAILED
// avoid compiler bug when comparing minimum INT64
- const SINT64 MININT64 = 0x8000000000000000;
- if (n1 == MININT64)
- return n2 == MININT64 ? 0 : 2;
- if (n2 == MININT64)
+ const SINT64 minInt64 = 0x8000000000000000;
+ if (n1 == minInt64)
+ return n2 == minInt64 ? 0 : 2;
+ if (n2 == minInt64)
return -2;
#endif
diff --git a/src/gpre/languages/fbrmclib.cpp b/src/gpre/languages/fbrmclib.cpp
index cc9fc28..a5d9a24 100644
--- a/src/gpre/languages/fbrmclib.cpp
+++ b/src/gpre/languages/fbrmclib.cpp
@@ -89,7 +89,7 @@ struct date_fmt
};
#ifdef __WIN32__
-#define EXPORT __declspec(dllexport)
+#define EXPORT extern __declspec(dllexport)
#define CDECL __cdecl
#else
#define EXPORT
diff --git a/src/include/firebird.h b/src/include/firebird.h
index 391d770..eb1b120 100644
--- a/src/include/firebird.h
+++ b/src/include/firebird.h
@@ -63,11 +63,13 @@
#include "../common/common.h"
#endif
+#if !defined(MINGW)
#ifdef NULL
#undef NULL
#endif
#define NULL nullptr
+#endif
#if defined(WIN_NT)
#define TRUSTED_AUTH
diff --git a/src/iscguard/iscguard.cpp b/src/iscguard/iscguard.cpp
index 983a7ba..0b4f8ac 100644
--- a/src/iscguard/iscguard.cpp
+++ b/src/iscguard/iscguard.cpp
@@ -726,7 +726,7 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM)
}
// wait for process to terminate
- DWORD exit_status;
+ DWORD exit_status = 0;
if (service_flag)
{
while (WaitForSingleObject(procHandle, 500) == WAIT_OBJECT_0)
diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp
index d43aba3..68aeebd 100644
--- a/src/jrd/jrd.cpp
+++ b/src/jrd/jrd.cpp
@@ -8852,7 +8852,7 @@ namespace
THREAD_ENTRY_DECLARE attachmentShutdownThread(THREAD_ENTRY_PARAM arg)
{
#ifdef WIN_NT
- ThreadModuleRef thdRef(attachmentShutdownThread, &engineShutdown);
+ ThreadModuleRef thdRef((void*)attachmentShutdownThread, &engineShutdown);
#endif
AttShutParams* params = static_cast<AttShutParams*>(arg);
diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp
index 01bd67d..d2ec914 100644
--- a/src/remote/inet.cpp
+++ b/src/remote/inet.cpp
@@ -1205,7 +1205,7 @@ static rem_port* listener_socket(rem_port* port, USHORT flag, const addrinfo* pa
forkEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
forkSockets = FB_NEW SocketsArray(*getDefaultMemoryPool());
- Thread::start(forkThread, (void*) flag, THREAD_medium);
+ Thread::start(forkThread, (void*)(U_IPTR) flag, THREAD_medium);
}
forkSockets->add(s);
SetEvent(forkEvent);
@@ -3180,7 +3180,7 @@ static bool packet_send( rem_port* port, const SCHAR* buffer, SSHORT buffer_leng
}
#endif
SSHORT n = send(port->port_handle, data, length, FB_SEND_FLAGS);
-#if COMPRESS_DEBUG > 1
+#if defined(COMPRESS_DEBUG) && COMPRESS_DEBUG > 1
fprintf(stderr, "send(%d, %p, %d, FB_SEND_FLAGS) == %d\n", port->port_handle, data, length, n);
#endif
#ifdef DEBUG
diff --git a/src/remote/protocol.cpp b/src/remote/protocol.cpp
index ef466b8..7135aaa 100644
--- a/src/remote/protocol.cpp
+++ b/src/remote/protocol.cpp
@@ -294,7 +294,7 @@ bool_t xdr_protocol(RemoteXdr* xdrs, PACKET* p)
if (!xdr_enum(xdrs, reinterpret_cast<xdr_op*>(&p->p_operation)))
return P_FALSE(xdrs, p);
-#if COMPRESS_DEBUG > 1
+#if defined(COMPRESS_DEBUG) && COMPRESS_DEBUG > 1
if (xdrs->x_op != XDR_FREE)
{
fprintf(stderr, "operation=%d %c\n", p->p_operation,
diff --git a/src/remote/remote.cpp b/src/remote/remote.cpp
index d55b995..d796113 100644
--- a/src/remote/remote.cpp
+++ b/src/remote/remote.cpp
@@ -1538,7 +1538,7 @@ bool REMOTE_deflate(RemoteXdr* xdrs, ProtoWrite* proto_write, PacketSend* packet
expectMoreOut = !strm.avail_out;
if ((port->port_buff_size != strm.avail_out) && (flush || !strm.avail_out))
{
-#if COMPRESS_DEBUG > 1
+#if defined(COMPRESS_DEBUG) && COMPRESS_DEBUG > 1
fprintf(stderr, "Send packet %d bytes size\n", port->port_buff_size - strm.avail_out);
#endif
if (!packet_send(port, (SCHAR*) &port->port_compressed[REM_SEND_OFFSET(port->port_buff_size)],
diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp
index 6d5149e..64c5993 100644
--- a/src/yvalve/gds.cpp
+++ b/src/yvalve/gds.cpp
@@ -104,7 +104,7 @@
#ifdef WIN_NT
#include <shlobj.h>
-#if _MSC_VER <= 1500
+#if defined(_MSC_VER) && (_MSC_VER<=1500)
#include <shfolder.h>
#endif
#define _WINSOCKAPI_