... and use behind the respective ifdef HAVE_FOO guards instead of the
HAVE_DECL___GLIBC__ currently.
Since day one, glibc has declarations for the functions, which was
forwarding the normal functions to them, via asm linkage, et al.
Aka `extern int open(....) asm_linkage("open64").
In addition, a lot of libraries have grown to depend on the declarations
being available and functions being statically exposed via libc.so.
Whereas musl pre 1.2.4 (circa 2023) have exposed the symbols
statically, without a declaration for well over a decade. Newer musl,
no longer expose the symbol in their runtime but have retained the
define trick, stating it will be removed in the future.
Looking at the bionic front things are somewhat similar. Newer bionic
(circa 2019) have a declaration and an inline wrapper open64 function
forwarding to open. Throughout 2019, open64 did forward to misc other
internal functions thought.
Older pre 2019 bionic had a declaration alongside plug exposing the
symbol statically in their C runtime.... since 2014. Not sure what they
did prior to 2014, it's a target out of scope for us.
Considering the above, the most robust approach is to do a check/has
function checking.
With that, we no longer need the __GLIBC__ guard for the respective
functions.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
#####################################################################
AC_CHECK_FUNCS_ONCE(__xstat)
+AC_CHECK_FUNCS_ONCE([open64 stat64 fopen64])
AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
CC_CHECK_FUNC_BUILTIN([__builtin_clz])
# Function and structure checks
################################################################################
-foreach decl : ['__xstat', '__secure_getenv', 'secure_getenv']
- if cc.has_function(decl, args : '-D_GNU_SOURCE')
- cdata.set('HAVE_@0@'.format(decl.to_upper()), true)
+_funcs = [
+ '__xstat',
+ 'open64', 'stat64', 'fopen64',
+ '__secure_getenv', 'secure_getenv',
+]
+foreach func : _funcs
+ if cc.has_function(func, args : '-D_GNU_SOURCE')
+ cdata.set('HAVE_@0@'.format(func.to_upper()), true)
endif
endforeach
WRAP_OPEN();
-#if HAVE_DECL___GLIBC__
+#ifdef HAVE_FOPEN64
WRAP_2ARGS(FILE*, NULL, fopen64, const char*);
+#endif
+#ifdef HAVE_STAT64
WRAP_2ARGS(int, -1, stat64, struct stat64*);
+#endif
+#if HAVE_DECL___GLIBC__
struct __stat64_t64;
extern int __stat64_time64 (const char *file, struct __stat64_t64 *buf);
WRAP_2ARGS(int, -1, __stat64_time64, struct __stat64_t64*);
+#endif
+#ifdef HAVE_OPEN64
WRAP_OPEN(64);
#endif