mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
libga68: Hide internal functions
Test if the target supports the visibility attribute and apply it to internal functions. libga68/ChangeLog: * acinclude.m4: New file. Add visibility attribute test. * configure.ac: Use the new test. * Makefile.in: Regenerate. * aclocal.m4: Likewise. * config.h.in: Likewise. * configure: Likewise. * ga68.h (GA68_HIDDEN): New macro. (_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>
This commit is contained in:
@@ -127,7 +127,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
|
||||
$(top_srcdir)/../config/override.m4 \
|
||||
$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
|
||||
$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
|
||||
$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
|
||||
14
libga68/acinclude.m4
Normal file
14
libga68/acinclude.m4
Normal file
@@ -0,0 +1,14 @@
|
||||
dnl Check whether the target supports hidden visibility.
|
||||
AC_DEFUN([LIBGA68_CHECK_ATTRIBUTE_VISIBILITY], [
|
||||
AC_CACHE_CHECK([whether the target supports hidden visibility],
|
||||
libga68_cv_have_attribute_visibility, [
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void __attribute__((visibility("hidden"))) foo(void) { }]], [])],
|
||||
[libga68_cv_have_attribute_visibility=yes],
|
||||
[libga68_cv_have_attribute_visibility=no])
|
||||
CFLAGS="$save_CFLAGS"])
|
||||
if test $libga68_cv_have_attribute_visibility = yes; then
|
||||
AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
|
||||
[Define to 1 if the target supports __attribute__((visibility(...))).])
|
||||
fi])
|
||||
1
libga68/aclocal.m4
vendored
1
libga68/aclocal.m4
vendored
@@ -1201,3 +1201,4 @@ m4_include([../ltoptions.m4])
|
||||
m4_include([../ltsugar.m4])
|
||||
m4_include([../ltversion.m4])
|
||||
m4_include([../lt~obsolete.m4])
|
||||
m4_include([acinclude.m4])
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if the target supports __attribute__((visibility(...))). */
|
||||
#undef HAVE_ATTRIBUTE_VISIBILITY
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
|
||||
37
libga68/configure
vendored
37
libga68/configure
vendored
@@ -12991,6 +12991,43 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
|
||||
|
||||
|
||||
# Check whether the target supports hidden visibility.
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target supports hidden visibility" >&5
|
||||
$as_echo_n "checking whether the target supports hidden visibility... " >&6; }
|
||||
if ${libga68_cv_have_attribute_visibility+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
void __attribute__((visibility("hidden"))) foo(void) { }
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
libga68_cv_have_attribute_visibility=yes
|
||||
else
|
||||
libga68_cv_have_attribute_visibility=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libga68_cv_have_attribute_visibility" >&5
|
||||
$as_echo "$libga68_cv_have_attribute_visibility" >&6; }
|
||||
if test $libga68_cv_have_attribute_visibility = yes; then
|
||||
|
||||
$as_echo "#define HAVE_ATTRIBUTE_VISIBILITY 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
# Search for needed functions in host libraries.
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing malloc" >&5
|
||||
$as_echo_n "checking for library containing malloc... " >&6; }
|
||||
|
||||
@@ -169,6 +169,9 @@ AC_LANG([C])
|
||||
CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
|
||||
AC_SUBST(CC_FOR_BUILD)
|
||||
|
||||
# Check whether the target supports hidden visibility.
|
||||
LIBGA68_CHECK_ATTRIBUTE_VISIBILITY
|
||||
|
||||
# Search for needed functions in host libraries.
|
||||
AC_SEARCH_LIBS([malloc], [c])
|
||||
AC_SEARCH_LIBS([cosf], [m])
|
||||
|
||||
@@ -33,9 +33,16 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATTRIBUTE_VISIBILITY
|
||||
# define GA68_HIDDEN __attribute__ ((__visibility__ ("hidden")))
|
||||
#else
|
||||
# define GA68_HIDDEN
|
||||
#endif
|
||||
|
||||
/* ga68-error.c */
|
||||
|
||||
void _libga68_abort (const char *fmt, ...)
|
||||
GA68_HIDDEN
|
||||
__attribute__ ((__format__ (__printf__, 1, 2), __nonnull__ (1),
|
||||
__noreturn__));
|
||||
|
||||
@@ -61,12 +68,12 @@ void _libga68_bounds_mismatch (const char *filename, unsigned int lineno,
|
||||
|
||||
/* ga68-alloc.c */
|
||||
|
||||
void _libga68_init_heap (void);
|
||||
void _libga68_init_heap (void) GA68_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) GA68_HIDDEN;
|
||||
void *_libga68_realloc (void *ptr, size_t size) GA68_HIDDEN;
|
||||
void *_libga68_realloc_unchecked (void *ptr, size_t size) GA68_HIDDEN;
|
||||
void _libga68_free_internal (void *ptr) GA68_HIDDEN;
|
||||
|
||||
/* ga68-standenv.c */
|
||||
|
||||
@@ -106,10 +113,10 @@ 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) GA68_HIDDEN;
|
||||
int _libga68_u8_mbtouc (uint32_t *puc, const uint8_t *s, size_t n) GA68_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) GA68_HIDDEN;
|
||||
uint32_t *_libga68_u8_to_u32 (const uint8_t *s, size_t n,
|
||||
uint32_t *resultbuf, size_t *lengthp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user