Skip to content

Commit

Permalink
libplatsch: add proper API export macro
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Marco Felsch committed Aug 7, 2024
1 parent a5c7b1d commit c1b108b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions libplatsch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

#include <stdint.h>

#if __GNUC__ >= 4
# define LIBPLATSCH_API __attribute__((visibility ("default")))
#else
# define LIBPLATSCH_API
#endif

struct platsch_ctx;

struct platsch_draw_buf {
Expand All @@ -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__ */
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ platsch_lib = both_libraries(
'platsch',
version : '0.1',
sources : ['libplatsch.c'],
gnu_symbol_visibility : 'hidden',
dependencies : [libdrm_dep],
install : true
)
Expand Down

0 comments on commit c1b108b

Please sign in to comment.