Re: [PATCH tip/timers/core] uapi glibc compat: make linux/time.h compile after libc time.h files

From: John Stultz
Date: Wed Aug 17 2016 - 15:34:51 EST


On Wed, Aug 10, 2016 at 8:45 AM, Willem de Bruijn
<willemdebruijn.kernel@xxxxxxxxx> wrote:
> From: Willem de Bruijn <willemb@xxxxxxxxxx>
>
> Add libc-compat workaround for definitions in linux/time.h that
> duplicate those in libc time.h, sys/time.h and bits/time.h.
>
> With this change, userspace builds succeeds when linux/time.h is
> included after those libc files. The inverse requires changes to
> those userspace headers.
>
> Without this patch, when compiling the following program after
> make headers_install:
>
> echo -e "#include <time.h>\n#include <linux/time.h>" | \
> gcc -Wall -Werror -Iusr/include -c -xc -
>
> gcc gives these errors:
>
> #include <time.h>
> #include <linux/time.h>
>
> In file included from ../test_time.c:3:0:
> /usr/include/time.h:120:8: error: redefinition of âstruct timespecâ
> struct timespec
> ^
> In file included from ../test_time.c:2:0:
> ./usr/include/linux/time.h:9:8: note: originally defined here
> struct timespec {
> ^
> In file included from ../test_time.c:3:0:
> /usr/include/time.h:161:8: error: redefinition of âstruct itimerspecâ
> struct itimerspec
> ^
> In file included from ../test_time.c:2:0:
> ./usr/include/linux/time.h:34:8: note: originally defined here
> struct itimerspec {
>
> and this warning by indirect inclusion of bits/time.h:
>
> In file included from ../test_time.c:4:0:
> ./usr/include/linux/time.h:67:0: error: "TIMER_ABSTIME" redefined [-Werror]
> #define TIMER_ABSTIME 0x01
> ^
> In file included from /usr/include/time.h:41:0,
> from ../test_time.c:3:
> /usr/include/x86_64-linux-gnu/bits/time.h:82:0: note: this is the location of the previous definition
> # define TIMER_ABSTIME 1
> ^
>
> Ran the same program for sys/time.h and bits/time.h. The _SYS_TIME_H
> test resolves similar errors for timeval, timezone, itimerval and
> warnings for ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF.
>
> Signed-off-by: Willem de Bruijn <willemb@xxxxxxxxxx>
> ---
> include/uapi/linux/libc-compat.h | 50 ++++++++++++++++++++++++++++++++++++++++
> include/uapi/linux/time.h | 15 ++++++++++++
> 2 files changed, 65 insertions(+)


So I don't have any objection to this. But I'm not sure if I'm the
right path for such a change to go through.

>From the commit history, it seems David Miller or Andrew Morton would
be the right folks to take this.

thanks
-john