commit 4fb283481e04e126d68ef82fcf89f39fd256a5e9
parent c2489bde82a548d0f724af1bacc04797823d5f97
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Fri, 6 Jun 2025 00:32:43 +0200
Added detection and used "externally_visible" function attribute
Diffstat:
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
@@ -4259,6 +4259,27 @@ int main(void) {return test_hidden_func();}
]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}"
+AC_CACHE_CHECK([whether $CC supports __attribute__ ((externally_visible))],[mhd_cv_cc_attr_extern_vis],
+ [
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+int test_func(void) __attribute__ ((externally_visible));
+__attribute__ ((externally_visible)) int
+test_func(void) {return 0; }
+
+int main(void) { return test_func(); }
+ ]])
+ ],
+ [mhd_cv_cc_attr_extern_vis="yes"],[mhd_cv_cc_attr_extern_vis="no"]
+ )
+ ]
+)
+AS_VAR_IF([mhd_cv_cc_attr_extern_vis],["yes"],
+ [
+ AC_DEFINE([HAVE_ATTR_EXTERN_VISIBLE],[1],
+ [Define to '1' if your compiler supports __attribute__((externally_visible))]
+ )
+ ]
+)
AC_CACHE_CHECK([whether $CC supports __attribute__ ((warn_unused_result))],[mhd_cv_cc_attr_warn_unused_res],
[
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
diff --git a/src/incl_priv/mhd_sys_options.h b/src/incl_priv/mhd_sys_options.h
@@ -72,6 +72,13 @@
# define MHD_EXTERN_USED /* empty */
#endif
+#if defined(HAVE_ATTR_EXTERN_VISIBLE) \
+ && (defined(PIC) || defined(DLL_EXPORT) || defined(MHD_W32DLL))
+# define mhd_EXTERNALLY_ACCESSIBLE __attribute__ ((externally_visible))
+#else
+# define mhd_EXTERNALLY_ACCESSIBLE /* empty */
+#endif
+
#if defined(MHD_EXTERN_) && defined(BUILDING_MHD_LIB)
# undef MHD_EXTERN_
#endif /* MHD_EXTERN_ && BUILDING_MHD_LIB */
@@ -80,7 +87,8 @@
# ifdef BUILDING_MHD_LIB
/* Building MHD itself */
# define MHD_EXTERN_ \
- extern MHD_VISIBILITY_EXTERN MHD_EXPORTED MHD_EXTERN_USED
+ extern MHD_VISIBILITY_EXTERN MHD_EXPORTED \
+ mhd_EXTERNALLY_ACCESSIBLE MHD_EXTERN_USED
# else /* ! BUILDING_MHD_LIB */
/* Test or example code, using MHD as a library */
# define MHD_EXTERN_ extern