Re: Missing include file in include/uapi/linux/errqueue.h?
On Sun, Jul 10, 2016 at 9:56 AM, Willem de Bruijn <will...@google.com> wrote: > On Sun, Jul 10, 2016 at 1:43 AM, Brooks Moses <bmo...@google.com> wrote: >> On Sat, Jul 9, 2016 at 10:36 AM, Brooks Moses <bmo...@google.com> wrote: >>> I've been attempting to qualify the Linux 4.5.2 user-space headers for >>> a toolchain release, and ran into what looks like a missing include >>> file in include/uapi/linux/errqueue.h. In particular, >>> https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c >>> adds the following to this file: >>> >>> +struct scm_timestamping { >>> + struct timespec ts[3]; >>> +}; >>> >>> However, struct timespec is defined in time.h, which isn't included >>> either in 4.5.2 or in current head. Is this simply a missing #include >>> line, > > It is. I missed that in my original patch. > >> or am I misunderstanding something? >> >> As a followup: Unfortunately the obvious fix -- adding "#include >> " -- causes other problems, since linux/time.h is >> incompatible with the glibc time.h such that including both of them >> into the same compilation unit causes errors about redefined types. > > If these conflicts between libc and uapi time.h can be resolved through > include/uapi/linux/libc-compat.h, then we can apply the obvious fix of > including linux/time.h in linux/errqueue.h. The below patch (bar whitespace mangling by gmail) avoids redefinition conflicts for me if linux/time.h is included after time.h. The other direction would also require changes to the userspace headers, as stated in libc-compat.h. >> And we, at least, have some programs that want to include >> linux/errqueue.h and (glibc's) time.h. The fix of adding "#include >> " to linux/errqueue.h seems to work for us, but I'm not sure >> that won't cause problems in the other direction for other people. > > That breaks kernel compilation. A simpler other option is to explicitly include either of the time.h files depending on the environment, similar to uapi/linux/lightnvm.h. timespec itself is also explicitly defined in uapi/linux/coda.h, but that won't avoid redefinition if time.h is included afterwards. The rough libc-compat.h patch: diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h index 07bdce1..6b1cdc6 100644 --- a/include/uapi/linux/errqueue.h +++ b/include/uapi/linux/errqueue.h @@ -2,6 +2,7 @@ #define _UAPI_LINUX_ERRQUEUE_H #include +#include struct sock_extended_err { __u32 ee_errno; diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index e4f048e..ef33ea9 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -146,6 +146,16 @@ #define __UAPI_DEF_XATTR 1 #endif +#if defined(_TIME_H) +#define __UAPI_DEF_TIMESPEC0 +#define __UAPI_DEF_ITIMERSPEC 0 +#define __UAPI_DEF_ABSTIME 0 +#else +#define __UAPI_DEF_TIMESPEC1 +#define __UAPI_DEF_ITIMERSPEC 1 +#define __UAPI_DEF_ABSTIME 1 +#endif /* _TIME_H */ + /* If we did not see any headers from any supported C libraries, * or we are being included in the kernel, then define everything * that we need. */ @@ -182,6 +192,11 @@ /* Definitions for xattr.h */ #define __UAPI_DEF_XATTR 1 +/* Definitions for time.h */ +#define __UAPI_DEF_TIMESPEC1 +#define __UAPI_DEF_ITIMERSPEC 1 +#define __UAPI_DEF_ABSTIME 1 + #endif /* __GLIBC__ */ #endif /* _UAPI_LIBC_COMPAT_H */ diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h index e75e1b6..7129c54 100644 --- a/include/uapi/linux/time.h +++ b/include/uapi/linux/time.h @@ -1,9 +1,10 @@ #ifndef _UAPI_LINUX_TIME_H #define _UAPI_LINUX_TIME_H +#include #include - +#if __UAPI_DEF_TIMESPEC #ifndef _STRUCT_TIMESPEC #define _STRUCT_TIMESPEC struct timespec { @@ -11,6 +12,7 @@ struct timespec { longtv_nsec;/* nanoseconds */ }; #endif +#endif struct timeval { __kernel_time_t tv_sec; /* seconds */ @@ -31,10 +33,12 @@ struct timezone { #defineITIMER_VIRTUAL 1 #defineITIMER_PROF 2 +#if __UAPI_DEF_TIMESPEC struct itimerspec { struct timespec it_interval;/* timer period */ struct timespec it_value; /* timer expiration */ }; +#endif struct itimerval { struct timeval it_interval; /* timer interval */ @@ -64,6 +68,8 @@ struct itimerval { /* * The various flags for setting POSIX.1b interval timers: */ +#if __UAPI_DEF_ABSTIME #define TIMER_ABSTIME 0x01 +#endif #endif /* _UAPI_LINUX_TIME_H */
Re: Missing include file in include/uapi/linux/errqueue.h?
On Sun, Jul 10, 2016 at 9:56 AM, Willem de Bruijn wrote: > On Sun, Jul 10, 2016 at 1:43 AM, Brooks Moses wrote: >> On Sat, Jul 9, 2016 at 10:36 AM, Brooks Moses wrote: >>> I've been attempting to qualify the Linux 4.5.2 user-space headers for >>> a toolchain release, and ran into what looks like a missing include >>> file in include/uapi/linux/errqueue.h. In particular, >>> https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c >>> adds the following to this file: >>> >>> +struct scm_timestamping { >>> + struct timespec ts[3]; >>> +}; >>> >>> However, struct timespec is defined in time.h, which isn't included >>> either in 4.5.2 or in current head. Is this simply a missing #include >>> line, > > It is. I missed that in my original patch. > >> or am I misunderstanding something? >> >> As a followup: Unfortunately the obvious fix -- adding "#include >> " -- causes other problems, since linux/time.h is >> incompatible with the glibc time.h such that including both of them >> into the same compilation unit causes errors about redefined types. > > If these conflicts between libc and uapi time.h can be resolved through > include/uapi/linux/libc-compat.h, then we can apply the obvious fix of > including linux/time.h in linux/errqueue.h. The below patch (bar whitespace mangling by gmail) avoids redefinition conflicts for me if linux/time.h is included after time.h. The other direction would also require changes to the userspace headers, as stated in libc-compat.h. >> And we, at least, have some programs that want to include >> linux/errqueue.h and (glibc's) time.h. The fix of adding "#include >> " to linux/errqueue.h seems to work for us, but I'm not sure >> that won't cause problems in the other direction for other people. > > That breaks kernel compilation. A simpler other option is to explicitly include either of the time.h files depending on the environment, similar to uapi/linux/lightnvm.h. timespec itself is also explicitly defined in uapi/linux/coda.h, but that won't avoid redefinition if time.h is included afterwards. The rough libc-compat.h patch: diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h index 07bdce1..6b1cdc6 100644 --- a/include/uapi/linux/errqueue.h +++ b/include/uapi/linux/errqueue.h @@ -2,6 +2,7 @@ #define _UAPI_LINUX_ERRQUEUE_H #include +#include struct sock_extended_err { __u32 ee_errno; diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index e4f048e..ef33ea9 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -146,6 +146,16 @@ #define __UAPI_DEF_XATTR 1 #endif +#if defined(_TIME_H) +#define __UAPI_DEF_TIMESPEC0 +#define __UAPI_DEF_ITIMERSPEC 0 +#define __UAPI_DEF_ABSTIME 0 +#else +#define __UAPI_DEF_TIMESPEC1 +#define __UAPI_DEF_ITIMERSPEC 1 +#define __UAPI_DEF_ABSTIME 1 +#endif /* _TIME_H */ + /* If we did not see any headers from any supported C libraries, * or we are being included in the kernel, then define everything * that we need. */ @@ -182,6 +192,11 @@ /* Definitions for xattr.h */ #define __UAPI_DEF_XATTR 1 +/* Definitions for time.h */ +#define __UAPI_DEF_TIMESPEC1 +#define __UAPI_DEF_ITIMERSPEC 1 +#define __UAPI_DEF_ABSTIME 1 + #endif /* __GLIBC__ */ #endif /* _UAPI_LIBC_COMPAT_H */ diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h index e75e1b6..7129c54 100644 --- a/include/uapi/linux/time.h +++ b/include/uapi/linux/time.h @@ -1,9 +1,10 @@ #ifndef _UAPI_LINUX_TIME_H #define _UAPI_LINUX_TIME_H +#include #include - +#if __UAPI_DEF_TIMESPEC #ifndef _STRUCT_TIMESPEC #define _STRUCT_TIMESPEC struct timespec { @@ -11,6 +12,7 @@ struct timespec { longtv_nsec;/* nanoseconds */ }; #endif +#endif struct timeval { __kernel_time_t tv_sec; /* seconds */ @@ -31,10 +33,12 @@ struct timezone { #defineITIMER_VIRTUAL 1 #defineITIMER_PROF 2 +#if __UAPI_DEF_TIMESPEC struct itimerspec { struct timespec it_interval;/* timer period */ struct timespec it_value; /* timer expiration */ }; +#endif struct itimerval { struct timeval it_interval; /* timer interval */ @@ -64,6 +68,8 @@ struct itimerval { /* * The various flags for setting POSIX.1b interval timers: */ +#if __UAPI_DEF_ABSTIME #define TIMER_ABSTIME 0x01 +#endif #endif /* _UAPI_LINUX_TIME_H */
Re: Missing include file in include/uapi/linux/errqueue.h?
On Sun, Jul 10, 2016 at 1:43 AM, Brooks Moses <bmo...@google.com> wrote: > On Sat, Jul 9, 2016 at 10:36 AM, Brooks Moses <bmo...@google.com> wrote: >> I've been attempting to qualify the Linux 4.5.2 user-space headers for >> a toolchain release, and ran into what looks like a missing include >> file in include/uapi/linux/errqueue.h. In particular, >> https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c >> adds the following to this file: >> >> +struct scm_timestamping { >> + struct timespec ts[3]; >> +}; >> >> However, struct timespec is defined in time.h, which isn't included >> either in 4.5.2 or in current head. Is this simply a missing #include >> line, It is. I missed that in my original patch. > or am I misunderstanding something? > > As a followup: Unfortunately the obvious fix -- adding "#include > " -- causes other problems, since linux/time.h is > incompatible with the glibc time.h such that including both of them > into the same compilation unit causes errors about redefined types. If these conflicts between libc and uapi time.h can be resolved through include/uapi/linux/libc-compat.h, then we can apply the obvious fix of including linux/time.h in linux/errqueue.h. > And we, at least, have some programs that want to include > linux/errqueue.h and (glibc's) time.h. The fix of adding "#include > " to linux/errqueue.h seems to work for us, but I'm not sure > that won't cause problems in the other direction for other people. That breaks kernel compilation.
Re: Missing include file in include/uapi/linux/errqueue.h?
On Sun, Jul 10, 2016 at 1:43 AM, Brooks Moses wrote: > On Sat, Jul 9, 2016 at 10:36 AM, Brooks Moses wrote: >> I've been attempting to qualify the Linux 4.5.2 user-space headers for >> a toolchain release, and ran into what looks like a missing include >> file in include/uapi/linux/errqueue.h. In particular, >> https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c >> adds the following to this file: >> >> +struct scm_timestamping { >> + struct timespec ts[3]; >> +}; >> >> However, struct timespec is defined in time.h, which isn't included >> either in 4.5.2 or in current head. Is this simply a missing #include >> line, It is. I missed that in my original patch. > or am I misunderstanding something? > > As a followup: Unfortunately the obvious fix -- adding "#include > " -- causes other problems, since linux/time.h is > incompatible with the glibc time.h such that including both of them > into the same compilation unit causes errors about redefined types. If these conflicts between libc and uapi time.h can be resolved through include/uapi/linux/libc-compat.h, then we can apply the obvious fix of including linux/time.h in linux/errqueue.h. > And we, at least, have some programs that want to include > linux/errqueue.h and (glibc's) time.h. The fix of adding "#include > " to linux/errqueue.h seems to work for us, but I'm not sure > that won't cause problems in the other direction for other people. That breaks kernel compilation.
Re: Missing include file in include/uapi/linux/errqueue.h?
On Sat, Jul 9, 2016 at 10:36 AM, Brooks Moses <bmo...@google.com> wrote: > I've been attempting to qualify the Linux 4.5.2 user-space headers for > a toolchain release, and ran into what looks like a missing include > file in include/uapi/linux/errqueue.h. In particular, > https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c > adds the following to this file: > > +struct scm_timestamping { > + struct timespec ts[3]; > +}; > > However, struct timespec is defined in time.h, which isn't included > either in 4.5.2 or in current head. Is this simply a missing #include > line, or am I misunderstanding something? As a followup: Unfortunately the obvious fix -- adding "#include " -- causes other problems, since linux/time.h is incompatible with the glibc time.h such that including both of them into the same compilation unit causes errors about redefined types. And we, at least, have some programs that want to include linux/errqueue.h and (glibc's) time.h. The fix of adding "#include " to linux/errqueue.h seems to work for us, but I'm not sure that won't cause problems in the other direction for other people. - Brooks
Re: Missing include file in include/uapi/linux/errqueue.h?
On Sat, Jul 9, 2016 at 10:36 AM, Brooks Moses wrote: > I've been attempting to qualify the Linux 4.5.2 user-space headers for > a toolchain release, and ran into what looks like a missing include > file in include/uapi/linux/errqueue.h. In particular, > https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c > adds the following to this file: > > +struct scm_timestamping { > + struct timespec ts[3]; > +}; > > However, struct timespec is defined in time.h, which isn't included > either in 4.5.2 or in current head. Is this simply a missing #include > line, or am I misunderstanding something? As a followup: Unfortunately the obvious fix -- adding "#include " -- causes other problems, since linux/time.h is incompatible with the glibc time.h such that including both of them into the same compilation unit causes errors about redefined types. And we, at least, have some programs that want to include linux/errqueue.h and (glibc's) time.h. The fix of adding "#include " to linux/errqueue.h seems to work for us, but I'm not sure that won't cause problems in the other direction for other people. - Brooks
Missing include file in include/uapi/linux/errqueue.h?
Hello! I've been attempting to qualify the Linux 4.5.2 user-space headers for a toolchain release, and ran into what looks like a missing include file in include/uapi/linux/errqueue.h. In particular, https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c adds the following to this file: +struct scm_timestamping { + struct timespec ts[3]; +}; However, struct timespec is defined in time.h, which isn't included either in 4.5.2 or in current head. Is this simply a missing #include line, or am I misunderstanding something? I also note that this is the second user-space header in the Linux 4.5.2 release we've run into that simply fails to compile when included by itself. Is there not a test target that tests for this? Would it be welcome if I were to work on adding one? Thanks, - Brooks
Missing include file in include/uapi/linux/errqueue.h?
Hello! I've been attempting to qualify the Linux 4.5.2 user-space headers for a toolchain release, and ran into what looks like a missing include file in include/uapi/linux/errqueue.h. In particular, https://github.com/torvalds/linux/commit/f24b9be5957b38bb420b838115040dc2031b7d0c adds the following to this file: +struct scm_timestamping { + struct timespec ts[3]; +}; However, struct timespec is defined in time.h, which isn't included either in 4.5.2 or in current head. Is this simply a missing #include line, or am I misunderstanding something? I also note that this is the second user-space header in the Linux 4.5.2 release we've run into that simply fails to compile when included by itself. Is there not a test target that tests for this? Would it be welcome if I were to work on adding one? Thanks, - Brooks