From 538329318964e4bfb420b6787f0f30c39ec3394c Mon Sep 17 00:00:00 2001 From: midipix Date: May 25 2024 17:46:48 +0000 Subject: code base: set the visilbity of internal library interfaces to hidden. --- diff --git a/project/extras.mk b/project/extras.mk index f07c781..f8c9852 100644 --- a/project/extras.mk +++ b/project/extras.mk @@ -2,5 +2,7 @@ CFLAGS_SHARED_ATTR += -DTPAX_PRE_ALPHA -DTPAX_EXPORT CFLAGS_STATIC_ATTR += -DTPAX_PRE_ALPHA -DTPAX_STATIC CFLAGS_APP_ATTR += -DTPAX_APP +CFLAGS_CONFIG += $(CFLAGS_ATTR_VISIBILITY_HIDDEN) + src/driver/tpax_driver_ctx.o: version.tag src/driver/tpax_driver_ctx.lo: version.tag diff --git a/project/headers.mk b/project/headers.mk index b33a797..e495f1b 100644 --- a/project/headers.mk +++ b/project/headers.mk @@ -11,5 +11,6 @@ INTERNAL_HEADERS = \ $(SOURCE_DIR)/src/internal/tpax_getdents_impl.h \ $(SOURCE_DIR)/src/internal/tpax_readlink_impl.h \ $(SOURCE_DIR)/src/internal/tpax_tmpfile_impl.h \ + $(SOURCE_DIR)/src/internal/tpax_visibility_impl.h \ ALL_HEADERS = $(API_HEADERS) $(INTERNAL_HEADERS) diff --git a/src/internal/tpax_dprintf_impl.c b/src/internal/tpax_dprintf_impl.c index b8d2b0b..bb2a1d2 100644 --- a/src/internal/tpax_dprintf_impl.c +++ b/src/internal/tpax_dprintf_impl.c @@ -10,7 +10,9 @@ #include #include -int tpax_dprintf(int fd, const char * fmt, ...) +#include "tpax_visibility_impl.h" + +tpax_hidden int tpax_dprintf(int fd, const char * fmt, ...) { int ret; int cnt; diff --git a/src/internal/tpax_errinfo_impl.c b/src/internal/tpax_errinfo_impl.c index 5fd2247..0e68f51 100644 --- a/src/internal/tpax_errinfo_impl.c +++ b/src/internal/tpax_errinfo_impl.c @@ -7,8 +7,9 @@ #include #include "tpax_driver_impl.h" #include "tpax_errinfo_impl.h" +#include "tpax_visibility_impl.h" -int tpax_record_error( +tpax_hidden int tpax_record_error( const struct tpax_driver_ctx * dctx, int esyscode, int elibcode, diff --git a/src/internal/tpax_tmpfile_impl.c b/src/internal/tpax_tmpfile_impl.c index 9dd9d40..dbc7765 100644 --- a/src/internal/tpax_tmpfile_impl.c +++ b/src/internal/tpax_tmpfile_impl.c @@ -14,6 +14,8 @@ #include #include +#include "tpax_visibility_impl.h" + #define PPRIX64 "%"PRIx64 /* mkostemp might be guarded by non-standard macros */ @@ -55,7 +57,7 @@ static int tpax_mkostemp(char * tmplate) return fd; } -int tpax_tmpfile(void) +tpax_hidden int tpax_tmpfile(void) { int fd; void * addr; diff --git a/src/internal/tpax_visibility_impl.h b/src/internal/tpax_visibility_impl.h new file mode 100644 index 0000000..6812494 --- /dev/null +++ b/src/internal/tpax_visibility_impl.h @@ -0,0 +1,26 @@ +#ifndef TPAX_VISIBILITY_IMPL_H +#define TPAX_VISIBILITY_IMPL_H + +/**********************************************************************/ +/* PE targets: __dllexport suffices for the purpose of exporting only */ +/* the desired subset of global symbols; this makes the visibility */ +/* attribute not only redundant, but also tricky if not properly */ +/* supported by the toolchain. */ +/* */ +/* When targeting Midipix, __PE__, __dllexport and __dllimport are */ +/* always defined by the toolchain. Otherwise, the absnece of these */ +/* macros has been detected by sofort's ccenv.sh during ./configure, */ +/* and they have accordingly been added to CFLAGS_OS. */ +/**********************************************************************/ + +#ifdef __PE__ +#define tpax_hidden +#else +#ifdef _ATTR_VISIBILITY_HIDDEN +#define tpax_hidden _ATTR_VISIBILITY_HIDDEN +#else +#define tpax_hidden +#endif +#endif + +#endif diff --git a/src/skin/tpax_skin_default.c b/src/skin/tpax_skin_default.c index 4de94b4..68491df 100644 --- a/src/skin/tpax_skin_default.c +++ b/src/skin/tpax_skin_default.c @@ -1,7 +1,8 @@ #include "tpax_driver_impl.h" +#include "tpax_visibility_impl.h" #include "argv/argv.h" -const struct argv_option tpax_default_options[] = { +const tpax_hidden struct argv_option tpax_default_options[] = { {"version", 0,TAG_VERSION,ARGV_OPTARG_NONE,0,0,0, "show version information"},