From efe42da0590267264820c4b92e7d1d3c70b4e093 Mon Sep 17 00:00:00 2001
From: Adriano dos Santos Fernandes
Date: Mon, 27 Dec 2021 10:30:34 -0300
Subject: [PATCH] Fix MacOS UDR and Legacy_UserManager plugins not working due
to not exported entry point. (#7088)
Add FB_DLL_EXPORT to public headers.
Use default visibility also for Linux/Unix (in addition to MacOS) as
user application can also be compiled with -fvisibility=hidden.
---
doc/Using_OO_API.html | 2 +-
examples/dbcrypt/CryptKeyHolder.cpp | 2 +-
examples/dbcrypt/DbCrypt.cpp | 2 +-
examples/interfaces/ifaceExamples.h | 8 --------
src/auth/AuthDbg.cpp | 2 +-
.../SecureRemotePassword/manage/SrpManagement.cpp | 10 +---------
src/auth/SecurityDatabase/LegacyManagement.epp | 2 +-
src/auth/SecurityDatabase/LegacyServer.cpp | 2 +-
src/common/common.h | 6 ------
src/extlib/ib_util.cpp | 7 +++----
src/include/firebird.h | 7 -------
src/include/firebird/UdrCppEngine.h | 2 +-
src/intl/ld.cpp | 8 ++++----
src/intl/ld.h | 8 --------
src/intl/ld_proto.h | 8 ++++----
src/jrd/ibase.h | 12 ++++++++++++
src/jrd/jrd.cpp | 2 +-
src/plugins/udr_engine/UdrEngine.cpp | 2 +-
src/remote/client/interface.cpp | 6 +++---
src/utilities/ntrace/traceplugin.cpp | 2 +-
src/yvalve/gds.cpp | 4 ++--
src/yvalve/gds_proto.h | 6 ++++--
22 files changed, 43 insertions(+), 67 deletions(-)
diff --git a/doc/Using_OO_API.html b/doc/Using_OO_API.html
index cd90d0820a..dd32893529 100644
--- a/doc/Using_OO_API.html
+++ b/doc/Using_OO_API.html
@@ -1318,7 +1318,7 @@ only for some specific OS you can make this place a bit simpler. In
minimum case the function should register module and all factories in
plugin manager:
extern
-"C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster*
+"C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster*
master)
{
IPluginManager*
diff --git a/examples/dbcrypt/CryptKeyHolder.cpp b/examples/dbcrypt/CryptKeyHolder.cpp
index 1e92481e9f..f69d2a3fe5 100644
--- a/examples/dbcrypt/CryptKeyHolder.cpp
+++ b/examples/dbcrypt/CryptKeyHolder.cpp
@@ -281,7 +281,7 @@ Factory factory;
} // anonymous namespace
-extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master)
{
IPluginManager* pluginManager = master->getPluginManager();
diff --git a/examples/dbcrypt/DbCrypt.cpp b/examples/dbcrypt/DbCrypt.cpp
index 3a60e0d6f4..2348528877 100644
--- a/examples/dbcrypt/DbCrypt.cpp
+++ b/examples/dbcrypt/DbCrypt.cpp
@@ -268,7 +268,7 @@ Factory factory;
} // anonymous namespace
-extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master)
{
IPluginManager* pluginManager = master->getPluginManager();
diff --git a/examples/interfaces/ifaceExamples.h b/examples/interfaces/ifaceExamples.h
index 40b54787a4..1b55e1e5a0 100644
--- a/examples/interfaces/ifaceExamples.h
+++ b/examples/interfaces/ifaceExamples.h
@@ -38,14 +38,6 @@ typedef int FbSampleAtomic;
#include
#include
-#if defined(_WIN32)
-#define FB_DLL_EXPORT __declspec(dllexport)
-#elif defined(__APPLE__)
-#define FB_DLL_EXPORT __attribute__((visibility("default")))
-#else
-#define FB_DLL_EXPORT
-#endif
-
using namespace Firebird;
#define SAMPLES_DIALECT SQL_DIALECT_V6
diff --git a/src/auth/AuthDbg.cpp b/src/auth/AuthDbg.cpp
index 377c9dfbb5..e66ad2cea0 100644
--- a/src/auth/AuthDbg.cpp
+++ b/src/auth/AuthDbg.cpp
@@ -38,7 +38,7 @@
static Firebird::SimpleFactory clientFactory;
static Firebird::SimpleFactory serverFactory;
-extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
{
Firebird::CachedMasterInterface::set(master);
diff --git a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp
index 2d8477600a..33de81de94 100644
--- a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp
+++ b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp
@@ -37,14 +37,6 @@
#include "../auth/SecureRemotePassword/Message.h"
#include "../common/classes/auto.h"
-#ifndef FB_EXPORTED
-#if defined(DARWIN)
-#define FB_EXPORTED __attribute__((visibility("default")))
-#else
-#define FB_EXPORTED
-#endif // OS choice (DARWIN)
-#endif // FB_EXPORTED
-
namespace {
const unsigned int INIT_KEY = ((~0) - 1);
@@ -987,7 +979,7 @@ static Firebird::SimpleFactory factory;
} // namespace Auth
-extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
{
Firebird::CachedMasterInterface::set(master);
Firebird::PluginManagerInterfacePtr()->registerPluginFactory(Firebird::IPluginManager::TYPE_AUTH_USER_MANAGEMENT, Auth::RemotePassword::plugName, &Auth::factory);
diff --git a/src/auth/SecurityDatabase/LegacyManagement.epp b/src/auth/SecurityDatabase/LegacyManagement.epp
index 2157bbc283..aebddadb15 100644
--- a/src/auth/SecurityDatabase/LegacyManagement.epp
+++ b/src/auth/SecurityDatabase/LegacyManagement.epp
@@ -763,7 +763,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi
// register plugin
static Firebird::SimpleFactory factory;
-extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
{
Firebird::CachedMasterInterface::set(master);
Firebird::PluginManagerInterfacePtr()->registerPluginFactory(
diff --git a/src/auth/SecurityDatabase/LegacyServer.cpp b/src/auth/SecurityDatabase/LegacyServer.cpp
index d051b33a7b..ff588f6991 100644
--- a/src/auth/SecurityDatabase/LegacyServer.cpp
+++ b/src/auth/SecurityDatabase/LegacyServer.cpp
@@ -423,7 +423,7 @@ void registerLegacyServer(IPluginManager* iPlugin)
#ifdef PLUG_MODULE
-extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master)
{
CachedMasterInterface::set(master);
diff --git a/src/common/common.h b/src/common/common.h
index 58abaaf695..af1ec6b0cd 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -244,8 +244,6 @@
#define API_ROUTINE __attribute__((visibility("default")))
#define API_ROUTINE_VARARG API_ROUTINE
-#define INTERNAL_API_ROUTINE API_ROUTINE
-#define FB_EXPORTED __attribute__((visibility("default")))
#define O_DIRECT F_NOCACHE
#endif /* Darwin Platforms */
@@ -600,10 +598,6 @@ extern "C" int remove(const char* path);
#define CLIB_ROUTINE
#endif
-#ifndef FB_EXPORTED
-#define FB_EXPORTED
-#endif
-
/* alignment macros */
diff --git a/src/extlib/ib_util.cpp b/src/extlib/ib_util.cpp
index 8f74f5ed9d..ffefb106a4 100644
--- a/src/extlib/ib_util.cpp
+++ b/src/extlib/ib_util.cpp
@@ -21,19 +21,18 @@
#include
#include "ib_udf.h"
#include "firebird.h"
-
-typedef void* VoidPtr;
+#include "ibase.h"
// initialized by the engine
static void* (*allocFunc)(long) = NULL;
-extern "C" void FB_EXPORTED ib_util_init(void* (*aAllocFunc)(long))
+extern "C" FB_DLL_EXPORT void ib_util_init(void* (*aAllocFunc)(long))
{
allocFunc = aAllocFunc;
}
-extern "C" VoidPtr FB_EXPORTED ib_util_malloc(long size)
+extern "C" FB_DLL_EXPORT void* ib_util_malloc(long size)
{
return allocFunc ? allocFunc(size) : malloc(size);
}
diff --git a/src/include/firebird.h b/src/include/firebird.h
index 87f0a110f8..6b8cb181d0 100644
--- a/src/include/firebird.h
+++ b/src/include/firebird.h
@@ -43,13 +43,6 @@
#define DEBUG_GDS_ALLOC
#endif
-#if defined(WIN_NT)
-#define FB_DLL_EXPORT __declspec(dllexport)
-#elif defined(DARWIN)
-#define FB_DLL_EXPORT API_ROUTINE
-#else
-#define FB_DLL_EXPORT
-#endif
//#if defined(SOLX86)
// this pragmas is used only with gcc 2.95!
//#define __PRAGMA_REDEFINE_EXTNAME
diff --git a/src/include/firebird/UdrCppEngine.h b/src/include/firebird/UdrCppEngine.h
index 26ef5a0e90..d9aac7e5d3 100644
--- a/src/include/firebird/UdrCppEngine.h
+++ b/src/include/firebird/UdrCppEngine.h
@@ -43,7 +43,7 @@
} \
} \
\
- extern "C" FB_BOOLEAN* FB_UDR_PLUGIN_ENTRY_POINT(::Firebird::IStatus* status, \
+ extern "C" FB_DLL_EXPORT FB_BOOLEAN* FB_UDR_PLUGIN_ENTRY_POINT(::Firebird::IStatus* status, \
FB_BOOLEAN* theirUnloadFlag, ::Firebird::IUdrPlugin* udrPlugin) \
{ \
::Firebird::Udr::FactoryRegistration::finish(status, udrPlugin); \
diff --git a/src/intl/ld.cpp b/src/intl/ld.cpp
index cf2e90fbcd..be9aed159a 100644
--- a/src/intl/ld.cpp
+++ b/src/intl/ld.cpp
@@ -468,7 +468,7 @@ struct
};
-INTL_BOOL FB_DLL_EXPORT LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* /*config_info*/)
+FB_DLL_EXPORT INTL_BOOL LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* /*config_info*/)
{
// ASF: We can't read config_info if version < INTL_VERSION_2,
// since it wasn't pushed in the stack by the engine.
@@ -491,7 +491,7 @@ INTL_BOOL FB_DLL_EXPORT LD_lookup_charset(charset* cs, const ASCII* name, const
}
-INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name,
+FB_DLL_EXPORT INTL_BOOL LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name,
USHORT attributes, const UCHAR* specific_attributes,
ULONG specific_attributes_length, INTL_BOOL ignore_attributes,
const ASCII* config_info)
@@ -557,7 +557,7 @@ INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_n
}
-ULONG FB_DLL_EXPORT LD_setup_attributes(
+FB_DLL_EXPORT ULONG LD_setup_attributes(
const ASCII* textTypeName, const ASCII* charSetName, const ASCII* configInfo,
ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst)
{
@@ -583,7 +583,7 @@ ULONG FB_DLL_EXPORT LD_setup_attributes(
}
-void FB_DLL_EXPORT LD_version(USHORT* version)
+FB_DLL_EXPORT void LD_version(USHORT* version)
{
// We support version 1 and 2.
if (*version != INTL_VERSION_1)
diff --git a/src/intl/ld.h b/src/intl/ld.h
index 5fe70e2508..e02aac4e3f 100644
--- a/src/intl/ld.h
+++ b/src/intl/ld.h
@@ -55,14 +55,6 @@
#define UINT16 USHORT
-#if defined(WIN_NT)
-#define FB_DLL_EXPORT __declspec(dllexport)
-#elif defined(DARWIN)
-#define FB_DLL_EXPORT API_ROUTINE
-#else
-#define FB_DLL_EXPORT
-#endif
-
/* Following this line is LD.H from Borland Language Driver Kit */
diff --git a/src/intl/ld_proto.h b/src/intl/ld_proto.h
index 6a6636dfa1..f20fdf076a 100644
--- a/src/intl/ld_proto.h
+++ b/src/intl/ld_proto.h
@@ -38,13 +38,13 @@ struct CsConvertImpl
extern USHORT version;
-INTL_BOOL FB_DLL_EXPORT LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* config_info);
-INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name,
+FB_DLL_EXPORT INTL_BOOL LD_lookup_charset(charset* cs, const ASCII* name, const ASCII* config_info);
+FB_DLL_EXPORT INTL_BOOL LD_lookup_texttype(texttype* tt, const ASCII* texttype_name, const ASCII* charset_name,
USHORT attributes, const UCHAR* specific_attributes,
ULONG specific_attributes_length, INTL_BOOL ignore_attributes,
const ASCII* config_info);
-void FB_DLL_EXPORT LD_version(USHORT* version);
-ULONG FB_DLL_EXPORT LD_setup_attributes(
+FB_DLL_EXPORT void LD_version(USHORT* version);
+FB_DLL_EXPORT ULONG LD_setup_attributes(
const ASCII* textTypeName, const ASCII* charSetName, const ASCII* configInfo,
ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst);
diff --git a/src/jrd/ibase.h b/src/jrd/ibase.h
index 1b601a7833..33ead12f03 100644
--- a/src/jrd/ibase.h
+++ b/src/jrd/ibase.h
@@ -64,6 +64,18 @@
#define FB_API_DEPRECATED
#endif
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
+#define FB_DLL_EXPORT __declspec(dllexport)
+#elif defined __has_attribute
+#if __has_attribute (visibility)
+#define FB_DLL_EXPORT __attribute__ ((visibility("default")))
+#else
+#define FB_DLL_EXPORT
+#endif
+#else
+#define FB_DLL_EXPORT
+#endif
+
#include "types_pub.h"
/********************************/
diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp
index e7b14d07c1..a90cbd1cf5 100644
--- a/src/jrd/jrd.cpp
+++ b/src/jrd/jrd.cpp
@@ -439,7 +439,7 @@ void registerEngine(IPluginManager* iPlugin)
} // namespace Jrd
-extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master)
{
CachedMasterInterface::set(master);
registerEngine(PluginManagerInterfacePtr());
diff --git a/src/plugins/udr_engine/UdrEngine.cpp b/src/plugins/udr_engine/UdrEngine.cpp
index 6666925fc3..97de607356 100644
--- a/src/plugins/udr_engine/UdrEngine.cpp
+++ b/src/plugins/udr_engine/UdrEngine.cpp
@@ -762,7 +762,7 @@ class IExternalEngineFactoryImpl : public SimpleFactory
{
} factory;
-extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master)
{
CachedMasterInterface::set(master);
diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp
index 48abe5c342..d1c2fa7c2e 100644
--- a/src/remote/client/interface.cpp
+++ b/src/remote/client/interface.cpp
@@ -700,7 +700,7 @@ void registerRedirector(Firebird::IPluginManager* iPlugin)
} // namespace Remote
/*
-extern "C" void FB_PLUGIN_ENTRY_POINT(IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* master)
{
IPluginManager* pi = master->getPluginManager();
registerRedirector(pi);
@@ -1634,7 +1634,7 @@ void Attachment::freeClientData(CheckStatusWrapper* status, bool force)
// telling the user that an unrecoverable network error occurred and that
// if there was any uncommitted work, its gone...... Oh well....
ex.stuffException(status);
-
+
if (!fb_utils::isNetworkError(status->getErrors()[1]) && (!force))
{
return;
@@ -3981,7 +3981,7 @@ Firebird::IEvents* Attachment::queEvents(CheckStatusWrapper* status, Firebird::I
port->connect(packet);
rem_port* port_async = port->port_async;
- port_async->port_events_threadId =
+ port_async->port_events_threadId =
Thread::start(event_thread, port_async, THREAD_high, &port_async->port_events_thread);
port_async->port_context = rdb;
diff --git a/src/utilities/ntrace/traceplugin.cpp b/src/utilities/ntrace/traceplugin.cpp
index f29d5dcb2b..703c24482a 100644
--- a/src/utilities/ntrace/traceplugin.cpp
+++ b/src/utilities/ntrace/traceplugin.cpp
@@ -125,7 +125,7 @@ void registerTrace(Firebird::IPluginManager* iPlugin)
}
-extern "C" void FB_EXPORTED FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
+extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
{
Firebird::CachedMasterInterface::set(master);
registerTrace(Firebird::PluginManagerInterfacePtr());
diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp
index a7b56c9f8e..2f70a0e234 100644
--- a/src/yvalve/gds.cpp
+++ b/src/yvalve/gds.cpp
@@ -3731,13 +3731,13 @@ static void sanitize(Firebird::string& locale)
}
-void FB_EXPORTED gds__default_printer(void* /*arg*/, SSHORT offset, const TEXT* line)
+void API_ROUTINE_VARARG gds__default_printer(void* /*arg*/, SSHORT offset, const TEXT* line)
{
printf("%4d %s\n", offset, line);
}
-void FB_EXPORTED gds__trace_printer(void* /*arg*/, SSHORT offset, const TEXT* line)
+void API_ROUTINE_VARARG gds__trace_printer(void* /*arg*/, SSHORT offset, const TEXT* line)
{
// Assume that line is not too long
char buffer[PRETTY_BUFFER_SIZE + 10];
diff --git a/src/yvalve/gds_proto.h b/src/yvalve/gds_proto.h
index 384cce4be1..8f1e91fe04 100644
--- a/src/yvalve/gds_proto.h
+++ b/src/yvalve/gds_proto.h
@@ -134,8 +134,10 @@ SINT64 API_ROUTINE isc_portable_integer(const UCHAR*, SSHORT);
void gds__cleanup();
void gds__ulstr(char* buffer, FB_UINT64 value, const int minlen, const char filler);
-void FB_EXPORTED gds__default_printer(void*, SSHORT, const TEXT*);
-void FB_EXPORTED gds__trace_printer(void*, SSHORT, const TEXT*);
+// These functions uses cdecl convention in Windows, so use API_ROUTINE_VARARG instead of API_ROUTINE (stdcall).
+void API_ROUTINE_VARARG gds__default_printer(void*, SSHORT, const TEXT*);
+void API_ROUTINE_VARARG gds__trace_printer(void*, SSHORT, const TEXT*);
+
#ifdef NOT_USED_OR_REPLACED
void gds__print_pool(Firebird::MemoryPool*, const TEXT*, ...);
#endif