Skip to content

Commit c1b108b

Browse files
author
Marco Felsch
committed
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 <[email protected]>
1 parent a5c7b1d commit c1b108b

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

libplatsch.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
#include <stdint.h>
55

6+
#if __GNUC__ >= 4
7+
# define LIBPLATSCH_API __attribute__((visibility ("default")))
8+
#else
9+
# define LIBPLATSCH_API
10+
#endif
11+
612
struct platsch_ctx;
713

814
struct platsch_draw_buf {
@@ -17,14 +23,14 @@ struct platsch_draw_buf {
1723

1824
typedef void (*custom_draw_cb)(struct platsch_draw_buf *buf, void *priv);
1925

20-
void platsch_draw(struct platsch_ctx *ctx);
21-
void platsch_register_custom_draw_cb(struct platsch_ctx *ctx,
22-
custom_draw_cb cb, void *priv);
26+
LIBPLATSCH_API void platsch_draw(struct platsch_ctx *ctx);
27+
LIBPLATSCH_API void platsch_register_custom_draw_cb(struct platsch_ctx *ctx,
28+
custom_draw_cb cb, void *priv);
2329

24-
struct platsch_ctx *platsch_create_ctx(const char *dir, const char *base);
25-
struct platsch_ctx *platsch_alloc_ctx(const char *dir, const char *base);
26-
int platsch_init_ctx(struct platsch_ctx *ctx);
30+
LIBPLATSCH_API struct platsch_ctx *platsch_create_ctx(const char *dir, const char *base);
31+
LIBPLATSCH_API struct platsch_ctx *platsch_alloc_ctx(const char *dir, const char *base);
32+
LIBPLATSCH_API int platsch_init_ctx(struct platsch_ctx *ctx);
2733

28-
void platsch_destroy_ctx(struct platsch_ctx *ctx);
34+
LIBPLATSCH_API void platsch_destroy_ctx(struct platsch_ctx *ctx);
2935

3036
#endif /* __LIBPLATSCH_H__ */

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ platsch_lib = both_libraries(
1616
'platsch',
1717
version : '0.1',
1818
sources : ['libplatsch.c'],
19+
gnu_symbol_visibility : 'hidden',
1920
dependencies : [libdrm_dep],
2021
install : true
2122
)

0 commit comments

Comments
 (0)