statx: fix compile errors with glibc<2.28
PATCH 1/1 statx: fix compile errors with glibc<2.28
glibc 2.28 has shipped with a wrapper for the statx() system call. Currently the build is broken against it, because sys/stat.h suddenly declares all the same types that lapi/stat.h does. Fix it by taking the sys/stat.h ones if glibc>=2.28.
include/lapi/stat.h:26:8: error: redefinition of ‘struct statx_timestamp’ include/lapi/stat.h:73:8: error: redefinition of ‘struct statx’
--- include/lapi/stat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/lapi/stat.h +2 -2
@@ -20,7 +20,7 @@* * __reserved is held in case we need a yet finer resolution. */ -#if defined(HAVE_STRUCT_STATX_TIMESTAMP ) +#if defined(__GLIBC_PREREQ) &&__GLIBC_PREREQ (2 ,28 )#include <sys/stat.h> #else struct statx_timestamp {
@@ -66,7 +66,7 @@ struct statx_timestamp {* will have values installed for compatibility purposes so that stat() and * co. can be emulated in userspace. */ -#if defined(HAVE_STRUCT_STATX ) +#if defined(__GLIBC_PREREQ) &&__GLIBC_PREREQ (2 ,28 )#include <sys/stat.h> #else struct statx {
Signature · 1 line
2.9.5
PATCH 1/1 statx: fix compile errors with glibc<2.28
Hi!
Quoted 7 lines
glibc 2.28 has shipped with a wrapper for the
statx()system call. Currently the build is broken against it, becausesys/stat.hsuddenly declares all the same types thatlapi/stat.hdoes. Fix it by taking thesys/stat.hones if glibc>=2.28.
include/lapi/stat.h:26:8: error: redefinition of ???structstatx_timestamp???include/lapi/stat.h:73:8: error: redefinition of ???struct statx???
What's wrong with the configure checks we do have?
See m4/ltp-statx.m4:
AC_CHECK_TYPES([struct statx],,,[[#include <sys/stat.h>]]) AC_CHECK_TYPES([struct statx_timestamp],,,[[#include <sys/stat.h>]])
That should check exactly if these structures are defined and export the HAVE_STRUCT_* macros?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 statx: fix compile errors with glibc<2.28
Quoted 12 lines · Cyril Hrubis
Hi!
Quoted 6 lines
glibc 2.28 has shipped with a wrapper for the
statx()system call. Currently the build is broken against it, becausesys/stat.hsuddenly declares all the same types thatlapi/stat.hdoes. Fix it by taking thesys/stat.hones if glibc>=2.28.
include/lapi/stat.h:26:8: error: redefinition of ???struct
statx_timestamp???Quoted 1 line
include/lapi/stat.h:73:8: error: redefinition of ???struct statx???What's wrong with the configure checks we do have?
Quoted 8 lines
See m4/ltp-statx.m4:
AC_CHECK_TYPES([struct statx],,,[[#include <sys/stat.h>]])AC_CHECK_TYPES([struct statx_timestamp],,,[[#include <sys/stat.h>]])That should check exactly if these structures are defined and export the HAVE_STRUCT_* macros?
Confusing...
It does not works for me. I checked the LTP "include/config.h" file after performing ./configure,
the HAVE_STRUCT_* macros undefined.
# cat include/config.h |grep -i statx /* Define to 1 if you have the `statx' function. */ #define HAVE_STATX 1 /* Define to 1 if the system has the type `struct statx'. */ /* #undef HAVE_STRUCT_STATX */ /* Define to 1 if the system has the type `struct statx_timestamp'. */ /* #undef HAVE_STRUCT_STATX_TIMESTAMP */ And I also confirmed the struct statx has been defined in "bits/statx.h" which was included by "sys/stat.h" on my platform(glibc>=2.28).
# grep "struct statx" /usr/include/bits/statx.h
struct statx_timestamp
struct statx
struct statx_timestamp stx_atime;
struct statx_timestamp stx_btime;
struct statx_timestamp stx_ctime;
struct statx_timestamp stx_mtime;
unsigned int __mask, struct statx *__restrict __buf)Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20180919/37a50c7f/attachment.html>
PATCH 1/1 statx: fix compile errors with glibc<2.28
Hi!
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
glibc 2.28 has shipped with a wrapper for the
statx()system call. Currently the build is broken against it, becausesys/stat.hsuddenly declares all the same types thatlapi/stat.hdoes. Fix it by taking thesys/stat.hones if glibc>=2.28.
include/lapi/stat.h:26:8: error: redefinition of ???struct
statx_timestamp???Quoted 1 line
include/lapi/stat.h:73:8: error: redefinition of ???struct statx???What's wrong with the configure checks we do have?
Quoted 9 lines
Quoted 8 lines
See m4/ltp-statx.m4:
AC_CHECK_TYPES([struct statx],,,[[#include <sys/stat.h>]])AC_CHECK_TYPES([struct statx_timestamp],,,[[#include <sys/stat.h>]])That should check exactly if these structures are defined and export the HAVE_STRUCT_* macros?
Check the config.log somewhere there is a test program that failed the compilation that tests for the struct statx and struct statx_timestamp.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 statx: fix compile errors
In reply to Li Wangstruct statx is only defined in sys/stat.h when _GNU_SOURCE is defined. The testcases do define _GNU_SOURCE, but not the m4 struct check.
--- m4/ltp-statx.m4 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
m4/ltp-statx.m4 +7 -2
@@ -23,6 +23,11 @@ dnl AC_DEFUN([LTP_CHECK_STATX],[ AC_CHECK_FUNCS(statx,,,[[#include <sys/stat.h>]]) AC_CHECK_HEADER(linux/fs.h,,,) -AC_CHECK_TYPES([struct statx],,,[[#include <sys/stat.h>]]) -AC_CHECK_TYPES([struct statx_timestamp],,,[[#include <sys/stat.h>]]) +AC_CHECK_TYPES([struct statx],,,[[ + #define _GNU_SOURCE + #include <sys/stat.h> +]]) +AC_CHECK_TYPES([struct statx_timestamp],,,[[ + #define _GNU_SOURCE + #include <sys/stat.h>]]) ])
Signature · 1 line
2.17.1
PATCH v2 1/1 statx: fix compile errors
Hi!
Quoted 2 lines
struct statx is only defined in
sys/stat.hwhen_GNU_SOURCEis defined. The testcases do define_GNU_SOURCE, but not the m4 struct check.
Ah, that is the missing bit, good catch, applied.
Signature · 2 lines
Cyril Hrubis [email protected]