[PATCH] libga68: Hide internal functions
Jose E. Marchesi
jose.marchesi@oracle.com
Sat Dec 27 11:31:48 GMT 2025
Hi Pietro.
Thanks for the patch.
> libga68/ChangeLog:
>
> * ga68.h (_libga68_abort): Add visibility hidden attribute.
> (_libga68_init_heap): Likewise.
> (_libga68_malloc_internal): Likewise.
> (_libga68_realloc): Likewise.
> (_libga68_realloc_unchecked): Likewise.
> (_libga68_free_internal): Likewise.
> (_libga68_u8_uctomb): Likewise.
> (_libga68_u8_mbtouc): Likewise.
> (_libga68_u32_to_u8): Likewise.
>
> Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
> ---
> libga68/ga68.h | 29 +++++++++++++++++++----------
> 1 file changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/libga68/ga68.h b/libga68/ga68.h
> index ed8b71fce79..360c8d1ee84 100644
> --- a/libga68/ga68.h
> +++ b/libga68/ga68.h
> @@ -37,7 +37,8 @@
>
> void _libga68_abort (const char *fmt, ...)
> __attribute__ ((__format__ (__printf__, 1, 2), __nonnull__ (1),
> - __noreturn__));
> + __noreturn__,
> + __visibility__ ("hidden")));
I think we should check whether the target supports the attribute, like
libgfortran does.
In libgfortran/acinclude.m4 there is the macro:
dnl Check whether the target supports hidden visibility.
AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
AC_CACHE_CHECK([whether the target supports hidden visibility],
libgfor_cv_have_attribute_visibility, [
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void __attribute__((visibility("hidden"))) foo(void) { }]], [])],
libgfor_cv_have_attribute_visibility=yes,
libgfor_cv_have_attribute_visibility=no)
CFLAGS="$save_CFLAGS"])
if test $libgfor_cv_have_attribute_visibility = yes; then
AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
[Define to 1 if the target supports __attribute__((visibility(...))).])
fi])
>
> void _libga68_assert (const char *filename, unsigned int lineno);
> void _libga68_derefnil (const char *filename, unsigned int lineno);
> @@ -61,12 +62,16 @@ void _libga68_bounds_mismatch (const char *filename, unsigned int lineno,
>
> /* ga68-alloc.c */
>
> -void _libga68_init_heap (void);
> +void _libga68_init_heap (void) __attribute__ ((__visibility__ ("hidden")));
> void *_libga68_malloc (size_t size);
> -void *_libga68_malloc_internal (size_t size);
> -void *_libga68_realloc (void *ptr, size_t size);
> -void *_libga68_realloc_unchecked (void *ptr, size_t size);
> -void _libga68_free_internal (void *ptr);
> +void *_libga68_malloc_internal (size_t size)
> + __attribute__ ((__visibility__ ("hidden")));
> +void *_libga68_realloc (void *ptr, size_t size)
> + __attribute__ ((__visibility__ ("hidden")));
> +void *_libga68_realloc_unchecked (void *ptr, size_t size)
> + __attribute__ ((__visibility__ ("hidden")));
> +void _libga68_free_internal (void *ptr)
> + __attribute__ ((__visibility__ ("hidden")));
>
> /* ga68-standenv.c */
>
> @@ -106,12 +111,16 @@ long long int _libga68_posixlseek (int fd, long long int offset, int whence);
>
> int _libga68_u32_cmp2 (const uint32_t *s1, size_t n1, size_t stride1,
> const uint32_t *s2, size_t n2, size_t stride2);
> -int _libga68_u8_uctomb (uint8_t *s, uint32_t uc, ptrdiff_t n);
> -int _libga68_u8_mbtouc (uint32_t *puc, const uint8_t *s, size_t n);
> +int _libga68_u8_uctomb (uint8_t *s, uint32_t uc, ptrdiff_t n)
> + __attribute__ ((__visibility__ ("hidden")));
> +int _libga68_u8_mbtouc (uint32_t *puc, const uint8_t *s, size_t n)
> + __attribute__ ((__visibility__ ("hidden")));
> uint8_t *_libga68_u32_to_u8 (const uint32_t *s, size_t n, size_t stride,
> - uint8_t *resultbuf, size_t *lengthp);
> + uint8_t *resultbuf, size_t *lengthp)
> + __attribute__ ((__visibility__ ("hidden")));
> uint32_t *_libga68_u8_to_u32 (const uint8_t *s, size_t n,
> - uint32_t *resultbuf, size_t *lengthp);
> + uint32_t *resultbuf, size_t *lengthp)
> + __attribute__ ((__visibility__ ("hidden")));
>
> /* libga68.c */
>
>
> base-commit: d53956a04837e468534e7ef89b5bee2fbc2cea8c
More information about the Algol68
mailing list