# check availability of various common functions (non-fatal if missing)
functions = [
- '__lxstat',
- '__lxstat64',
- '__xstat',
- '__xstat64',
'elf_aux_info',
'fallocate',
'getauxval',
'getuid',
'getutxid',
'if_indextoname',
- 'lstat',
- 'lstat64',
'mmap',
'newlocale',
'pipe2',
'setgroups',
'setns',
'setrlimit',
- 'stat',
- 'stat64',
'symlink',
'sysctlbyname',
]
+stat_functions = [
+ '__lxstat',
+ '__lxstat64',
+ '__xstat',
+ '__xstat64',
+ 'lstat',
+ 'lstat64',
+ 'stat',
+ 'stat64',
+]
+
+functions += stat_functions
+
foreach function : functions
if cc.has_function(function)
conf.set('WITH_@0@'.format(function.to_upper()), 1)
endforeach
+foreach function : stat_functions
+ if cc.has_header_symbol('sys/stat.h', function)
+ conf.set('WITH_@0@_DECL'.format(function.to_upper()), 1)
+ endif
+endforeach
+
+
# various header checks
headers = [
* - If __xstat & __xstat64 exist, then stat & stat64 will not exist
* as symbols in the library, so the latter should not be mocked.
*
+ * - If __xstat exists in the library, but not the header than it
+ * it is just there for binary back compat and should not be
+ * mocked
+ *
* The same all applies to lstat()
*/
+#if !defined(WITH___XSTAT_DECL)
+# if defined(WITH_STAT)
+# if !defined(WITH___XSTAT) && !defined(WITH_STAT64) || defined(__APPLE__)
+# define MOCK_STAT
+# endif
+# endif
+# if defined(WITH_STAT64)
+# define MOCK_STAT64
+# endif
+#else /* WITH___XSTAT_DECL */
+# if defined(WITH___XSTAT) && !defined(WITH___XSTAT64)
+# define MOCK___XSTAT
+# endif
+# if defined(WITH___XSTAT64)
+# define MOCK___XSTAT64
+# endif
+#endif /* WITH___XSTAT_DECL */
-#if defined(WITH_STAT)
-# if !defined(WITH___XSTAT) && !defined(WITH_STAT64) || defined(__APPLE__)
-# define MOCK_STAT
+#if !defined(WITH___LXSTAT_DECL)
+# if defined(WITH_LSTAT)
+# if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64) || defined(__APPLE__)
+# define MOCK_LSTAT
+# endif
# endif
-#endif
-#if defined(WITH_STAT64) && !defined(WITH___XSTAT64)
-# define MOCK_STAT64
-#endif
-#if defined(WITH___XSTAT) && !defined(WITH___XSTAT64)
-# define MOCK___XSTAT
-#endif
-#if defined(WITH___XSTAT64)
-# define MOCK___XSTAT64
-#endif
-#if defined(WITH_LSTAT)
-# if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64) || defined(__APPLE__)
-# define MOCK_LSTAT
+# if defined(WITH_LSTAT64)
+# define MOCK_LSTAT64
# endif
-#endif
-#if defined(WITH_LSTAT64) && !defined(WITH___LXSTAT64)
-# define MOCK_LSTAT64
-#endif
-#if defined(WITH___LXSTAT) && !defined(WITH___LXSTAT64)
-# define MOCK___LXSTAT
-#endif
-#if defined(WITH___LXSTAT64)
-# define MOCK___LXSTAT64
-#endif
+#else /* WITH___LXSTAT_DECL */
+# if defined(WITH___LXSTAT) && !defined(WITH___LXSTAT64)
+# define MOCK___LXSTAT
+# endif
+# if defined(WITH___LXSTAT64)
+# define MOCK___LXSTAT64
+# endif
+#endif /* WITH___LXSTAT_DECL */
#ifdef MOCK_STAT
static int (*real_stat)(const char *path, struct stat *sb);