From c1b108b8349b640f35c4a31b34b8c9e771c1b7e8 Mon Sep 17 00:00:00 2001 From: Marco Felsch Date: Wed, 7 Aug 2024 09:00:03 +0200 Subject: [PATCH] libplatsch: add proper API export macro At the moment we rely on the 'default' visibility which was okay since all global functions are API functions. This is error prone as one could expose symbols by accident. Therefore change the behavior by setting the default visibility to 'hidden' and introducing a new macro to export selected API functions. Signed-off-by: Marco Felsch --- libplatsch.h | 20 +++++++++++++------- meson.build | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libplatsch.h b/libplatsch.h index b25d08f..f65500a 100644 --- a/libplatsch.h +++ b/libplatsch.h @@ -3,6 +3,12 @@ #include +#if __GNUC__ >= 4 +# define LIBPLATSCH_API __attribute__((visibility ("default"))) +#else +# define LIBPLATSCH_API +#endif + struct platsch_ctx; struct platsch_draw_buf { @@ -17,14 +23,14 @@ struct platsch_draw_buf { typedef void (*custom_draw_cb)(struct platsch_draw_buf *buf, void *priv); -void platsch_draw(struct platsch_ctx *ctx); -void platsch_register_custom_draw_cb(struct platsch_ctx *ctx, - custom_draw_cb cb, void *priv); +LIBPLATSCH_API void platsch_draw(struct platsch_ctx *ctx); +LIBPLATSCH_API void platsch_register_custom_draw_cb(struct platsch_ctx *ctx, + custom_draw_cb cb, void *priv); -struct platsch_ctx *platsch_create_ctx(const char *dir, const char *base); -struct platsch_ctx *platsch_alloc_ctx(const char *dir, const char *base); -int platsch_init_ctx(struct platsch_ctx *ctx); +LIBPLATSCH_API struct platsch_ctx *platsch_create_ctx(const char *dir, const char *base); +LIBPLATSCH_API struct platsch_ctx *platsch_alloc_ctx(const char *dir, const char *base); +LIBPLATSCH_API int platsch_init_ctx(struct platsch_ctx *ctx); -void platsch_destroy_ctx(struct platsch_ctx *ctx); +LIBPLATSCH_API void platsch_destroy_ctx(struct platsch_ctx *ctx); #endif /* __LIBPLATSCH_H__ */ diff --git a/meson.build b/meson.build index 2e33ddb..08b2b43 100644 --- a/meson.build +++ b/meson.build @@ -16,6 +16,7 @@ platsch_lib = both_libraries( 'platsch', version : '0.1', sources : ['libplatsch.c'], + gnu_symbol_visibility : 'hidden', dependencies : [libdrm_dep], install : true )