Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MacOS UDR and Legacy_UserManager plugins not working due to not exported entry point. #7088

Merged
merged 4 commits into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/Using_OO_API.html
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ <h1><font size="4" style="font-size: 14pt">Plugin module
minimum case the function should register module and all factories in
plugin manager:</font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">extern
&quot;C&quot; void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster*
&quot;C&quot; FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster*
master)</font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">{</font></p>
<p style="margin-bottom: 0cm"><font size="4" style="font-size: 14pt">IPluginManager*
Expand Down Expand Up @@ -3793,4 +3793,4 @@ <h1><font size="4" style="font-size: 14pt">Non-interface objects used

</p>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion examples/dbcrypt/CryptKeyHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Factory factory;

} // anonymous namespace

extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* m)
extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m)
{
master = m;
IPluginManager* pluginManager = master->getPluginManager();
Expand Down
2 changes: 1 addition & 1 deletion examples/dbcrypt/DbCrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,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();

Expand Down
8 changes: 1 addition & 7 deletions examples/extauth/ExtAuth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,7 @@ Factory<ExtAuthServer> serverFactory;
} // anonymous namespace


#if defined(_WIN32)
#define FB_DLL_EXPORT __declspec(dllexport)
#else
#define FB_DLL_EXPORT
#endif

extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* m)
extern "C" FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m)
{
master = m;
IPluginManager* pluginManager = master->getPluginManager();
Expand Down
8 changes: 0 additions & 8 deletions examples/interfaces/ifaceExamples.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ typedef int FbSampleAtomic;

#include <firebird/Interface.h>

#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
9 changes: 1 addition & 8 deletions examples/replication/fbSampleReplicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ class Factory : public IPluginFactoryImpl<Factory, CheckStatusWrapper>

extern "C"
{
#if defined(__WIN32__)
void __declspec(dllexport) FB_PLUGIN_ENTRY_POINT(IMaster* m);
#else
void FB_PLUGIN_ENTRY_POINT(IMaster* m)
__attribute__((visibility("default")));
#endif // __WIN32__

void FB_PLUGIN_ENTRY_POINT(IMaster* m)
FB_DLL_EXPORT void FB_PLUGIN_ENTRY_POINT(IMaster* m)
{
master = m;
IPluginManager* pm = m->getPluginManager();
Expand Down
2 changes: 1 addition & 1 deletion src/auth/AuthDbg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
static Firebird::SimpleFactory<Auth::DebugClient> clientFactory;
static Firebird::SimpleFactory<Auth::DebugServer> 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);

Expand Down
10 changes: 1 addition & 9 deletions src/auth/SecureRemotePassword/manage/SrpManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
#include "../common/classes/auto.h"
#include "../common/classes/ParsedList.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 SZ_LOGIN = 31;
Expand Down Expand Up @@ -986,7 +978,7 @@ static Firebird::SimpleFactory<Auth::SrpManagement> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/auth/SecurityDatabase/LegacyManagement.epp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi
// register plugin
static Firebird::SimpleFactory<Auth::SecurityDatabaseManagement> 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(
Expand Down
2 changes: 1 addition & 1 deletion src/auth/SecurityDatabase/LegacyServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,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);

Expand Down
6 changes: 0 additions & 6 deletions src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,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 */
Expand Down Expand Up @@ -603,10 +601,6 @@ extern "C" int remove(const char* path);
#define CLIB_ROUTINE
#endif

#ifndef FB_EXPORTED
#define FB_EXPORTED
#endif

#ifdef HAS_NOEXCEPT
#define NOEXCEPT noexcept
#define NOEXCEPT_ARG(X) noexcept((X))
Expand Down
8 changes: 3 additions & 5 deletions src/extlib/ib_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
*/

#include <stdlib.h>
#include "ib_util.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);
}
7 changes: 0 additions & 7 deletions src/include/firebird.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/include/firebird/UdrCppEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down
12 changes: 12 additions & 0 deletions src/include/ibase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure - does __attribute__ ((visibility("default"))) work in non-GCC case? I.e. is not check for unix too wide, may be something like check for defined(__GNUC__) should be added?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another problem here is that __declspec() must be used BEFORE function name while attribute() - AFTER it. I.e. declaration void FB_DLL_EXPORT foo() won't work with GCC.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure - does attribute ((visibility("default"))) work in non-GCC case? I.e. is not check for unix too wide, may be something like check for defined(GNUC) should be added?

Or maybe this?

https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html

#else
#define FB_DLL_EXPORT
#endif
#else
#define FB_DLL_EXPORT
#endif

#include "./firebird/impl/types_pub.h"

/***********************/
Expand Down
8 changes: 4 additions & 4 deletions src/intl/ld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions src/intl/ld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
8 changes: 4 additions & 4 deletions src/intl/ld_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/jrd/jrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,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());
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/crypt/chacha/ChaCha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ SimpleFactory<ChaCha<8> > factory64;

} // anonymous namespace

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)
{
CachedMasterInterface::set(master);
PluginManagerInterfacePtr()->registerPluginFactory(IPluginManager::TYPE_WIRE_CRYPT, "ChaCha", &factory);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/udr_engine/UdrEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class IExternalEngineFactoryImpl : public SimpleFactory<Engine>
{
} 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);

Expand Down
2 changes: 1 addition & 1 deletion src/remote/client/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,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);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/ntrace/traceplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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());
Expand Down
4 changes: 2 additions & 2 deletions src/yvalve/gds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3977,13 +3977,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];
Expand Down
6 changes: 4 additions & 2 deletions src/yvalve/gds_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down