# HG changeset patch # User David Demelier # Date 1634734520 -7200 # Node ID 5facd2f604b64d110fea4935100e9dddce3a57f3 # Parent 96c5f34247d2a1861749097b449bb6cc0376f971 irccd: fix various glibc warnings and build diff -r 96c5f34247d2 -r 5facd2f604b6 irccd/CMakeLists.txt --- a/irccd/CMakeLists.txt Wed Oct 20 14:15:23 2021 +0200 +++ b/irccd/CMakeLists.txt Wed Oct 20 14:55:20 2021 +0200 @@ -16,6 +16,19 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # +# +# Overview of projects and targets here. Irccd is a host program that loads C +# native plugins, to do so it exports the public API by its own and plugins +# must not link to the library code itself. But for unit testing the project +# we don't want to compile over and over the same files that *must* link +# against the library code so we split: +# +# - libirccd-static (static library): contains the public API for C plugins. +# - irccd-static (static library): contains all irccd(1) code *without* the +# main entry point. This code isn't publicly exposed to the plugins. +# - irccd (executable): contains main and config parser code. +# + project(irccd) set( @@ -69,7 +82,10 @@ flex_target(lex ${irccd_SOURCE_DIR}/lex.l ${irccd_BINARY_DIR}/lex.c) add_flex_bison_dependency(lex yacc) -# Intermediate library (for unit tests purposes). +# +# irccd-static +# ------------------------------------------------------------------- +# add_library( irccd-static OBJECT ${SOURCES} @@ -81,10 +97,18 @@ PRIVATE $ PUBLIC $ ) -target_link_libraries(irccd-static libirccd-static Threads::Threads) +target_link_libraries( + irccd-static + ${CMAKE_DL_LIBS} + Threads::Threads + libirccd-static +) set_target_properties(irccd-static PROPERTIES PREFIX "") -# Final irccd executable. +# +# irccd(1) +# ------------------------------------------------------------------- +# add_executable(irccd ${irccd_SOURCE_DIR}/main.c) target_link_libraries(irccd irccd-static) set_target_properties(irccd PROPERTIES ENABLE_EXPORTS On) diff -r 96c5f34247d2 -r 5facd2f604b6 irccd/dl-plugin.c --- a/irccd/dl-plugin.c Wed Oct 20 14:15:23 2021 +0200 +++ b/irccd/dl-plugin.c Wed Oct 20 14:55:20 2021 +0200 @@ -32,44 +32,50 @@ #include "dl-plugin.h" +#if defined(__GNUC__) +# define SYM(sig, f) (__extension__ (sig)(f)) +#else +# define SYM(sig, f) ((sig)(f)) +#endif + /* Invoke with arguments and return value. */ -#define INVOKE(pg, name, sig, ...) \ -do { \ - struct self *self = pg->data; \ - sig fn; \ - \ - if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ - return fn(__VA_ARGS__); \ +#define INVOKE(pg, name, sig, ...) \ +do { \ + struct self *self = pg->data; \ + sig fn; \ + \ + if (self->handle && (fn = SYM(sig, dlsym(self->handle, symbol(self, name))))) \ + return fn(__VA_ARGS__); \ } while (0) /* Invoke with argument and without return value. */ -#define INVOKE_NR(pg, name, sig, ...) \ -do { \ - struct self *self = pg->data; \ - sig fn; \ - \ - if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ - fn(__VA_ARGS__); \ +#define INVOKE_NR(pg, name, sig, ...) \ +do { \ + struct self *self = pg->data; \ + sig fn; \ + \ + if (self->handle && (fn = SYM(sig, dlsym(self->handle, symbol(self, name))))) \ + fn(__VA_ARGS__); \ } while (0) /* Invoke without arguments and with return value. */ -#define INVOKE_NA(pg, name, sig) \ -do { \ - struct self *self = pg->data; \ - sig fn; \ - \ - if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ - return fn(); \ +#define INVOKE_NA(pg, name, sig) \ +do { \ + struct self *self = pg->data; \ + sig fn; \ + \ + if (self->handle && (fn = SYM(sig, dlsym(self->handle, symbol(self, name))))) \ + return fn(); \ } while (0) /* Invoke without arguments and without return value. */ -#define INVOKE_NA_NR(pg, name, sig) \ -do { \ - struct self *self = pg->data; \ - sig fn; \ - \ - if (self->handle && (fn = (sig)dlsym(self->handle, symbol(self, name))))\ - fn(); \ +#define INVOKE_NA_NR(pg, name, sig) \ +do { \ + struct self *self = pg->data; \ + sig fn; \ + \ + if (self->handle && (fn = SYM(sig, dlsym(self->handle, symbol(self, name))))) \ + fn(); \ } while (0) struct self { diff -r 96c5f34247d2 -r 5facd2f604b6 lib/CMakeLists.txt --- a/lib/CMakeLists.txt Wed Oct 20 14:15:23 2021 +0200 +++ b/lib/CMakeLists.txt Wed Oct 20 14:55:20 2021 +0200 @@ -59,7 +59,7 @@ add_library(libirccd-static STATIC ${LIBBSD_SOURCES} ${SOURCES}) target_link_libraries(libirccd-static PUBLIC libirccd-utlist) -target_compile_definitions(libirccd-static PUBLIC _XOPEN_SOURCE=0700) +target_compile_definitions(libirccd-static PUBLIC _XOPEN_SOURCE=700) target_include_directories( libirccd-static PUBLIC