Re: [RFC] Splitting kernel headers and deprecating __KERNEL__

Krzysztof Halasa
2004-12-15T00:18:57Z

Werner Almesberger <wa@almesberger.net> writes:

> A first step towards enabling converence would be to _guarantee_
> that glibc types are _identical_ to the kernel types, e.g.
>
> /usr/include/stdint.h:
> #include <linux-user/types.h> /* only __u32 and such */
>
> typedef __u32 uint32_t;
> ...
>
> (If they just "happen to be the same", people may still not trust
> this, and will feel justified inventing their own schemes. And as
> ugly as uint32_t may look, it's still infinitely better than code
> where each library contributes its own set of sized integers ...)

Not sure about this. I think such types should be defined by the
kernel, for it's use only. The libc (and any other userspace
software) may probably use them (if they have to), but must not
(re)define them.
The userspace should probably best use standard types. This is
userspace to know if their uint32_t has standard meaning equivalent
to __u32 or if it's actually a function name.

So i think we should have:

kernel-include/headers.h:
#define __u32 ...

struct some_structure {
__u32 var;
}str1;

and then userspace.c (libc et al) should:

#include linux/headers.h

str1 v;
uint32_t variable = v.var;

or maybe with some type conversion:

long long v2 = v.var;
unsigned char v3 = v.var;
--
Krzysztof Halasa