summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-12 23:41:43 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-12 23:41:43 +0000
commit2602f4efbd36f395d2186f9609cbd16734416a67 (patch)
tree4bec015e5ac1dfd77149e07f37acad156d55249c
parent0d9a2dc982d379b5b16382b9e44329414521aeba (diff)
Encode module API version in the init_module symbol; fixes conflic with glibc-exported init_module
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11863 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/modules.h18
-rw-r--r--src/dynamic.cpp4
2 files changed, 16 insertions, 6 deletions
diff --git a/include/modules.h b/include/modules.h
index 16a64c497..9207a2bd9 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -104,7 +104,9 @@ struct ModResult {
}
};
-/** If you change the module API in any way, increment this value. */
+/** If you change the module API in any way, increment this value.
+ * This MUST be a pure integer, with no parenthesis
+ */
#define API_VERSION 133
class ServerConfig;
@@ -1733,6 +1735,16 @@ class CoreExport ModuleManager : public classbase
const std::vector<std::string> GetAllModuleNames(int filter);
};
+/** Do not mess with these functions unless you know the C preprocessor
+ * well enough to explain why they are needed. The order is important.
+ */
+#define MODULE_INIT_STR MODULE_INIT_STR_FN_2(MODULE_INIT_SYM)
+#define MODULE_INIT_STR_FN_2(x) MODULE_INIT_STR_FN_1(x)
+#define MODULE_INIT_STR_FN_1(x) #x
+#define MODULE_INIT_SYM MODULE_INIT_SYM_FN_2(API_VERSION)
+#define MODULE_INIT_SYM_FN_2(x) MODULE_INIT_SYM_FN_1(x)
+#define MODULE_INIT_SYM_FN_1(x) inspircd_module_ ## x
+
/** This definition is used as shorthand for the various classes
* and functions needed to make a module loadable by the OS.
* It defines the class factory and external init_module function.
@@ -1740,7 +1752,7 @@ class CoreExport ModuleManager : public classbase
#ifdef WINDOWS
#define MODULE_INIT(y) \
- extern "C" DllExport Module * init_module() \
+ extern "C" DllExport Module * MODULE_INIT_SYM() \
{ \
return new y; \
} \
@@ -1758,7 +1770,7 @@ class CoreExport ModuleManager : public classbase
#else
#define MODULE_INIT(y) \
- extern "C" DllExport Module * init_module() \
+ extern "C" DllExport Module * MODULE_INIT_SYM() \
{ \
return new y; \
}
diff --git a/src/dynamic.cpp b/src/dynamic.cpp
index b993b8af5..637a57db4 100644
--- a/src/dynamic.cpp
+++ b/src/dynamic.cpp
@@ -11,8 +11,6 @@
* ---------------------------------------------------
*/
-/* $Core */
-
#include "inspircd.h"
#include "dynamic.h"
#ifndef WIN32
@@ -53,7 +51,7 @@ Module* DLLManager::callInit()
return NULL;
init_t initfn;
- initfn.vptr = dlsym(h, "init_module");
+ initfn.vptr = dlsym(h, MODULE_INIT_STR);
if (!initfn.vptr)
{
err = dlerror();