summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2025-05-29 21:07:22 +0000
committermidipix <writeonce@midipix.org>2025-05-29 22:02:07 +0000
commit2baf678ee420b74c3b08a225f111787645ac18a6 (patch)
tree3820388cd96464fcce23947a851cee3dc0100a1f /src
parentfb9d36cced3944104441b68db3102f9697051670 (diff)
downloadperk-2baf678ee420b74c3b08a225f111787645ac18a6.tar.bz2
perk-2baf678ee420b74c3b08a225f111787645ac18a6.tar.xz
code base: set the visilbity of internal library interfaces to hidden.
Diffstat (limited to 'src')
-rw-r--r--src/internal/perk_dprintf_impl.c4
-rw-r--r--src/internal/perk_errinfo_impl.c3
-rw-r--r--src/internal/perk_hdrdump_impl.c7
-rw-r--r--src/internal/perk_visibility_impl.h26
-rw-r--r--src/skin/pe_skin_default.c3
-rw-r--r--src/skin/pe_skin_perk.c3
6 files changed, 39 insertions, 7 deletions
diff --git a/src/internal/perk_dprintf_impl.c b/src/internal/perk_dprintf_impl.c
index 30d3d11..8e834e4 100644
--- a/src/internal/perk_dprintf_impl.c
+++ b/src/internal/perk_dprintf_impl.c
@@ -4,7 +4,9 @@
#include <unistd.h>
#include <errno.h>
-int pe_dprintf(int fd, const char * fmt, ...)
+#include "perk_visibility_impl.h"
+
+perk_hidden int pe_dprintf(int fd, const char * fmt, ...)
{
int ret;
int cnt;
diff --git a/src/internal/perk_errinfo_impl.c b/src/internal/perk_errinfo_impl.c
index 22b084e..d930c1a 100644
--- a/src/internal/perk_errinfo_impl.c
+++ b/src/internal/perk_errinfo_impl.c
@@ -7,8 +7,9 @@
#include <perk/perk.h>
#include "perk_driver_impl.h"
#include "perk_errinfo_impl.h"
+#include "perk_visibility_impl.h"
-int pe_record_error(
+perk_hidden int pe_record_error(
const struct pe_driver_ctx * dctx,
int esyscode,
int elibcode,
diff --git a/src/internal/perk_hdrdump_impl.c b/src/internal/perk_hdrdump_impl.c
index 6bf1867..314edef 100644
--- a/src/internal/perk_hdrdump_impl.c
+++ b/src/internal/perk_hdrdump_impl.c
@@ -11,6 +11,7 @@
#include <perk/perk_consts.h>
#include <perk/perk_structs.h>
#include "perk_hdrdump_impl.h"
+#include "perk_visibility_impl.h"
#define PE_TABWIDTH 8
#define PE_HDRSPACE 40
@@ -24,7 +25,7 @@ static const char pe_hex_header_dot[] =
static const char pe_hex_footer[] =
"|---------------------------------------------------| |-----------------|\n\n";
-size_t pe_output_hex_header(
+perk_hidden size_t pe_output_hex_header(
char * buf,
const char * sname,
uint64_t faddr,
@@ -94,7 +95,7 @@ size_t pe_output_hex_header(
return ch - buf;
}
-size_t pe_output_hex_footer(char * buf)
+perk_hidden size_t pe_output_hex_footer(char * buf)
{
size_t nlen;
@@ -107,7 +108,7 @@ size_t pe_output_hex_footer(char * buf)
return PE_HDRSPACE + nlen;
}
-size_t pe_output_raw_element(
+perk_hidden size_t pe_output_raw_element(
char * ch,
const void * rdata,
const char * mname,
diff --git a/src/internal/perk_visibility_impl.h b/src/internal/perk_visibility_impl.h
new file mode 100644
index 0000000..df45efc
--- /dev/null
+++ b/src/internal/perk_visibility_impl.h
@@ -0,0 +1,26 @@
+#ifndef PERK_VISIBILITY_IMPL_H
+#define PERK_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 perk_hidden
+#else
+#ifdef _ATTR_VISIBILITY_HIDDEN
+#define perk_hidden _ATTR_VISIBILITY_HIDDEN
+#else
+#define perk_hidden
+#endif
+#endif
+
+#endif
diff --git a/src/skin/pe_skin_default.c b/src/skin/pe_skin_default.c
index b27daf5..5ca7387 100644
--- a/src/skin/pe_skin_default.c
+++ b/src/skin/pe_skin_default.c
@@ -1,7 +1,8 @@
#include "perk_driver_impl.h"
+#include "perk_visibility_impl.h"
#include "argv/argv.h"
-const struct argv_option pe_default_options[] = {
+const perk_hidden struct argv_option pe_default_options[] = {
{"version", 'v',TAG_VERSION,ARGV_OPTARG_NONE,0,0,0,
"show version information"},
diff --git a/src/skin/pe_skin_perk.c b/src/skin/pe_skin_perk.c
index 20c84a8..a6ea35f 100644
--- a/src/skin/pe_skin_perk.c
+++ b/src/skin/pe_skin_perk.c
@@ -1,7 +1,8 @@
#include "perk_driver_impl.h"
+#include "perk_visibility_impl.h"
#include "argv/argv.h"
-const struct argv_option pe_perk_options[] = {
+const perk_hidden struct argv_option pe_perk_options[] = {
{"version", 'v',TAG_VERSION,ARGV_OPTARG_NONE,0,0,0,
"show version information"},