Thread (7 messages) 7 messages, 3 authors, 2017-03-06

Re: [PATCH] uapi: fix asm/signal.h userspace compilation errors

From: Carlos O'Donell <hidden>
Date: 2017-03-06 15:10:33
Also in: linux-alpha, linux-arch, linux-arm-kernel, linuxppc-dev, lkml, sparclinux

On Fri, Mar 3, 2017 at 8:23 PM, Carlos O'Donell [off-list ref] wrote:
On Thu, Mar 2, 2017 at 10:48 AM, Dmitry V. Levin [off-list ref] wrote:
quoted
On Thu, Mar 02, 2017 at 10:22:18AM -0500, Carlos O'Donell wrote:
quoted
On Wed, Mar 1, 2017 at 11:20 AM, Arnd Bergmann [off-list ref] wrote:
quoted
On Sun, Feb 26, 2017 at 2:01 AM, Dmitry V. Levin [off-list ref] wrote:
quoted
Include <stddef.h> (guarded by #ifndef __KERNEL__) to fix asm/signal.h
userspace compilation errors like this:

/usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'
  size_t ss_size;

As no uapi header provides a definition of size_t, inclusion
of <stddef.h> seems to be the most conservative fix available.
[...]
quoted
quoted
I'm not sure if this is the best fix. We generally should not include one
standard header from another standard header. Would it be possible
to use __kernel_size_t instead of size_t?
In glibc we handle this with special use of __need_size_t with GCC's
provided stddef.h.

For example glibc's signal.h does this:

# define __need_size_t
# include <stddef.h>
Just to make it clear, do you suggest this approach for asm/signal.h as well?
The best practice from the glibc community looks like this:

(a) Create a bits/types/*.h header for the type you need.

e.g.
./time/bits/types/struct_timeval.h
./time/bits/types/struct_itimerspec.h
./time/bits/types/time_t.h
./time/bits/types/struct_timespec.h
./time/bits/types/struct_tm.h
./time/bits/types/clockid_t.h
./time/bits/types/clock_t.h
./time/bits/types/timer_t.h

(b) If neccessary the bits/types/*.h header is a wrapper:
~~~
#define __need_size_t
#include <stddef.h>
~~~
to get access to the compiler provided type.

This way all of the code you need simplifies to includes for the types you need.

e.g.

time/sys/time.h:
...
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
...

This is what we've been doing in glibc starting last September as we
cleaned up all the convoluted conditional logic to get the types we
needed in the headers that needed them.

Cheers,
Carlos.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help