comparison include/freeDiameter/extension.h @ 1493:a89913941dcf

extensions: hide symbols by default Hide extension.fdx symbols by default, by setting the target property <LANG>C_VISIBILITY_PRESET hidden. This requires cmake 2.8+ Explicitly export fd_ext_init() and fd_ext_fini(), using gcc or clang's __attribute__((visibility()))
author Luke Mewburn <luke@mewburn.net>
date Mon, 30 Mar 2020 15:31:48 +1100
parents 1e1d6f94cd94
children 449b766ded50
comparison
equal deleted inserted replaced
1492:fadf8947c0fb 1493:a89913941dcf
46 46
47 /* Macro that define the entry point of the extension */ 47 /* Macro that define the entry point of the extension */
48 #define EXTENSION_ENTRY(_name, _function, _depends...) \ 48 #define EXTENSION_ENTRY(_name, _function, _depends...) \
49 const char *fd_ext_depends[] = { _name , ## _depends , NULL }; \ 49 const char *fd_ext_depends[] = { _name , ## _depends , NULL }; \
50 static int extension_loaded = 0; \ 50 static int extension_loaded = 0; \
51 \
52 __attribute__((visibility("default"))) \
51 int fd_ext_init(int major, int minor, char * conffile) { \ 53 int fd_ext_init(int major, int minor, char * conffile) { \
52 if ((major != FD_PROJECT_VERSION_MAJOR) \ 54 if ((major != FD_PROJECT_VERSION_MAJOR) \
53 || (minor != FD_PROJECT_VERSION_MINOR)) { \ 55 || (minor != FD_PROJECT_VERSION_MINOR)) { \
54 TRACE_ERROR("This extension (" _name ") was compiled for a different version of freeDiameter."); \ 56 TRACE_ERROR("This extension (" _name ") was compiled for a different version of freeDiameter."); \
55 TRACE_DEBUG(INFO, "daemon %d.%d != ext %d.%d", \ 57 TRACE_DEBUG(INFO, "daemon %d.%d != ext %d.%d", \
61 TRACE_ERROR("Extension (" _name ") cannot be loaded twice!"); \ 63 TRACE_ERROR("Extension (" _name ") cannot be loaded twice!"); \
62 return ENOTSUP; \ 64 return ENOTSUP; \
63 } \ 65 } \
64 extension_loaded++; \ 66 extension_loaded++; \
65 return (_function)(conffile); \ 67 return (_function)(conffile); \
66 } 68 }
69
70 /* Optional exit point (finish function) of the extension */
71 __attribute__((visibility("default")))
72 void fd_ext_fini(void);
67 73
68 #ifdef __cplusplus 74 #ifdef __cplusplus
69 } 75 }
70 #endif 76 #endif
71 77
"Welcome to our mercurial repository"