From ed6d2d1cd5305c3d5e393dcc9d1efc8b2ffc8079 Mon Sep 17 00:00:00 2001 From: pantonshire Date: Mon, 25 May 2026 07:45:50 +0100 Subject: [PATCH] symbol visibility --- include/export.h | 7 +++++++ meson.build | 1 + src/array_list.c | 5 +++-- src/eventloop.c | 15 ++++++++------- src/str.c | 3 ++- 5 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 include/export.h diff --git a/include/export.h b/include/export.h new file mode 100644 index 0000000..7b96193 --- /dev/null +++ b/include/export.h @@ -0,0 +1,7 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#pragma once + +#define EXPORT __attribute__((visibility("default"))) diff --git a/meson.build b/meson.build index 9582585..dcbcc82 100644 --- a/meson.build +++ b/meson.build @@ -56,6 +56,7 @@ tlsl_lib = shared_library( sources, include_directories: includes, c_args: args, + gnu_symbol_visibility: 'hidden', ) tlsl_dep = declare_dependency( diff --git a/src/array_list.c b/src/array_list.c index d5b8d90..9b0005e 100644 --- a/src/array_list.c +++ b/src/array_list.c @@ -4,9 +4,10 @@ #include +#include "export.h" #include "public/array_list.h" -int array_list_raw_alloc(struct array_list *al, size_t cap, size_t elem_size) { +EXPORT int array_list_raw_alloc(struct array_list *al, size_t cap, size_t elem_size) { void *buf; if (!(buf = realloc(al->buf, cap * elem_size))) @@ -16,7 +17,7 @@ int array_list_raw_alloc(struct array_list *al, size_t cap, size_t elem_size) { return 0; } -void array_list_raw_cleanup(struct array_list *al) { +EXPORT void array_list_raw_cleanup(struct array_list *al) { if (al->buf && al->cap) { free(al->buf); al->buf = NULL; diff --git a/src/eventloop.c b/src/eventloop.c index 2ca398b..c945080 100644 --- a/src/eventloop.c +++ b/src/eventloop.c @@ -2,11 +2,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. +#include "export.h" #include "eventloop_platform.h" #include "public/container_of.h" #include "public/list.h" -int tlsl_eventloop_init(struct tlsl_eventloop *el) { +EXPORT int tlsl_eventloop_init(struct tlsl_eventloop *el) { int platform_res; intrusive_list_init_empty(&el->event_list); @@ -18,7 +19,7 @@ int tlsl_eventloop_init(struct tlsl_eventloop *el) { return 0; } -void tlsl_eventloop_cleanup(struct tlsl_eventloop *el) { +EXPORT void tlsl_eventloop_cleanup(struct tlsl_eventloop *el) { struct intrusive_list *li; struct tlsl_event *e; @@ -34,7 +35,7 @@ void tlsl_eventloop_cleanup(struct tlsl_eventloop *el) { el->valid = false; } -int tlsl_eventloop_wait( +EXPORT int tlsl_eventloop_wait( struct tlsl_eventloop *el, tlsl_event_id_t *id_out, uint32_t *flags_out, @@ -43,16 +44,16 @@ int tlsl_eventloop_wait( return tlsl_platform_el_wait(el, id_out, flags_out, timeout_ms); } -int tlsl_eventloop_clear(struct tlsl_eventloop *el, struct tlsl_event *e) { +EXPORT int tlsl_eventloop_clear(struct tlsl_eventloop *el, struct tlsl_event *e) { return tlsl_platform_el_event_clear(el, e); } -void tlsl_eventloop_remove(struct tlsl_eventloop *el, struct tlsl_event *e) { +EXPORT void tlsl_eventloop_remove(struct tlsl_eventloop *el, struct tlsl_event *e) { tlsl_platform_el_event_remove(el, e); tlsl_platform_el_event_cleanup(el, e); } -int tlsl_eventloop_add_timer( +EXPORT int tlsl_eventloop_add_timer( struct tlsl_eventloop *el, struct tlsl_event *e, uint64_t millis, @@ -66,7 +67,7 @@ int tlsl_eventloop_add_timer( return 0; } -int tlsl_eventloop_add_fd( +EXPORT int tlsl_eventloop_add_fd( struct tlsl_eventloop *el, struct tlsl_event *e, int fd, diff --git a/src/str.c b/src/str.c index cefda8e..3efde3f 100644 --- a/src/str.c +++ b/src/str.c @@ -5,9 +5,10 @@ #include #include +#include "export.h" #include "public/str.h" -str_buf_t sbuf_from_sview(str_view_t s) { +EXPORT str_buf_t sbuf_from_sview(str_view_t s) { char *buf; if (sview_is_null(s) || sview_is_empty(s))