All of lore.kernel.org
 help / color / mirror / Atom feed
* Including both linux/time.h and linux/input.h causes failure
@ 2020-01-29 15:14 Elichai Turkel
       [not found] ` <CALN7hC+f+D8xsaJBt+MCXDfk51oHCoQeUVmFydNdkW+_DeqTiw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Elichai Turkel @ 2020-01-29 15:14 UTC (permalink / raw)
  To: linux-api-u79uwXL29TY76Z2rM5mHXA

Hi,
The following header: <wrapper.h>:
```
#include <linux/input.h>
#include <linux/time.h>
```
Will cause the compiler to fail because of redefinition of a lot of
time related structs, that are declared once in `linux/time.h` and
then again via `bits/types/struct_timeval.h` which is included through
`linux/input.h > sys/time.h -> bits/types/struct_timeval.h`



Command: `gcc -I./headers_install/x86/include wrapper.h`
output:
```
In file included from wrapper.h:13:
./headers_install/x86/include/linux/time.h:16:8: error: redefinition
of ‘struct timeval’
   16 | struct timeval {
      |        ^~~~~~~
In file included from /usr/include/sys/time.h:25,
                 from ./headers_install/x86/include/linux/input.h:13,
                 from wrapper.h:8:
/usr/include/bits/types/struct_timeval.h:8:8: note: originally defined here
    8 | struct timeval
      |        ^~~~~~~
In file included from wrapper.h:13:
./headers_install/x86/include/linux/time.h:21:8: error: redefinition
of ‘struct timezone’
   21 | struct timezone {
      |        ^~~~~~~~
In file included from ./headers_install/x86/include/linux/input.h:13,
                 from wrapper.h:8:
/usr/include/sys/time.h:52:8: note: originally defined here
   52 | struct timezone
      |        ^~~~~~~~
In file included from wrapper.h:13:
./headers_install/x86/include/linux/time.h:30: warning: "ITIMER_REAL" redefined
   30 | #define ITIMER_REAL  0
      |
In file included from ./headers_install/x86/include/linux/input.h:13,
                 from wrapper.h:8:
/usr/include/sys/time.h:92: note: this is the location of the previous
definition
   92 | #define ITIMER_REAL ITIMER_REAL
      |
In file included from wrapper.h:13:
./headers_install/x86/include/linux/time.h:31: warning:
"ITIMER_VIRTUAL" redefined
   31 | #define ITIMER_VIRTUAL  1
      |
In file included from ./headers_install/x86/include/linux/input.h:13,
                 from wrapper.h:8:
/usr/include/sys/time.h:95: note: this is the location of the previous
definition
   95 | #define ITIMER_VIRTUAL ITIMER_VIRTUAL
      |
In file included from wrapper.h:13:
./headers_install/x86/include/linux/time.h:32: warning: "ITIMER_PROF" redefined
   32 | #define ITIMER_PROF  2
      |
In file included from ./headers_install/x86/include/linux/input.h:13,
                 from wrapper.h:8:
/usr/include/sys/time.h:99: note: this is the location of the previous
definition
   99 | #define ITIMER_PROF ITIMER_PROF
      |
In file included from wrapper.h:13:
./headers_install/x86/include/linux/time.h:39:8: error: redefinition
of ‘struct itimerval’
   39 | struct itimerval {
      |        ^~~~~~~~~
In file included from ./headers_install/x86/include/linux/input.h:13,
                 from wrapper.h:8:
/usr/include/sys/time.h:104:8: note: originally defined here
  104 | struct itimerval
      |        ^~~~~~~~~

```

-- 
PGP: 5607C93B5F86650C

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Including both linux/time.h and linux/input.h causes failure
       [not found] ` <CALN7hC+f+D8xsaJBt+MCXDfk51oHCoQeUVmFydNdkW+_DeqTiw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-01-29 17:16   ` Carlos O'Donell
       [not found]     ` <88ab5e38-254a-430d-67cf-1840b0e51c35-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Carlos O'Donell @ 2020-01-29 17:16 UTC (permalink / raw)
  To: Elichai Turkel, linux-api-u79uwXL29TY76Z2rM5mHXA

On 1/29/20 10:14 AM, Elichai Turkel wrote:
> Hi,
> The following header: <wrapper.h>:
> ```
> #include <linux/input.h>
> #include <linux/time.h>
> ```
> Will cause the compiler to fail because of redefinition of a lot of
> time related structs, that are declared once in `linux/time.h` and
> then again via `bits/types/struct_timeval.h` which is included through
> `linux/input.h > sys/time.h -> bits/types/struct_timeval.h`
 
This is another header-coordination issue between the kernel and libc.

In this case it's linux/time.h vs. sys/time.h.

"Synchronizing Headers"
https://sourceware.org/glibc/wiki/Synchronizing_Headers
- Just added your case.

It's not immediate clear to me if the UAPI header is clean enough to
use directly in glibc or not, and that's often the simplest way to fix
things.

When you can't just use the kernel header definitions then you have
to work through the conflict and decide if you want to allow both headers
to be potentially included and in which orders to support it.

Why do you need both headers included?

-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Including both linux/time.h and linux/input.h causes failure
       [not found]     ` <88ab5e38-254a-430d-67cf-1840b0e51c35-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2020-01-30 14:12       ` Elichai Turkel
  0 siblings, 0 replies; 3+ messages in thread
From: Elichai Turkel @ 2020-01-30 14:12 UTC (permalink / raw)
  To: linux-api-u79uwXL29TY76Z2rM5mHXA

Mostly I need the uid_t type for syscalls(getuid/setuid)
Which is defined in sys/types.h but that header also includes time
related stuff.

For context I'm writing a libc equivilant library (in rust).

Thanks,
Elichai.

On Wed, Jan 29, 2020 at 7:16 PM Carlos O'Donell <codonell-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>
> On 1/29/20 10:14 AM, Elichai Turkel wrote:
> > Hi,
> > The following header: <wrapper.h>:
> > ```
> > #include <linux/input.h>
> > #include <linux/time.h>
> > ```
> > Will cause the compiler to fail because of redefinition of a lot of
> > time related structs, that are declared once in `linux/time.h` and
> > then again via `bits/types/struct_timeval.h` which is included through
> > `linux/input.h > sys/time.h -> bits/types/struct_timeval.h`
>
> This is another header-coordination issue between the kernel and libc.
>
> In this case it's linux/time.h vs. sys/time.h.
>
> "Synchronizing Headers"
> https://sourceware.org/glibc/wiki/Synchronizing_Headers
> - Just added your case.
>
> It's not immediate clear to me if the UAPI header is clean enough to
> use directly in glibc or not, and that's often the simplest way to fix
> things.
>
> When you can't just use the kernel header definitions then you have
> to work through the conflict and decide if you want to allow both headers
> to be potentially included and in which orders to support it.
>
> Why do you need both headers included?
>
> --
> Cheers,
> Carlos.
>


-- 
PGP: 5607C93B5F86650C

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-30 14:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 15:14 Including both linux/time.h and linux/input.h causes failure Elichai Turkel
     [not found] ` <CALN7hC+f+D8xsaJBt+MCXDfk51oHCoQeUVmFydNdkW+_DeqTiw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-01-29 17:16   ` Carlos O'Donell
     [not found]     ` <88ab5e38-254a-430d-67cf-1840b0e51c35-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-01-30 14:12       ` Elichai Turkel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.