tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: ptrdiff_t in the kernel
On Wed, Dec 04, 2013 at 12:07:42PM -0200, Lourival Vieira Neto wrote:
> >>> No, <stddef.h> is not allowed in the kernel. Symbols from it are
> >>> provided via other means.
> >>
> >> I know. In fact, I'm asking if it would be alright to allow that.
> >> AFAIK, it would be inoffensive if available in the kernel.
> >
> > Actually, it would be offensive.
>
> Why?
I would also like to know why that would be offensive!
I'm always disappointed when I have to write something like this in order
to share code between the userland and kernel,
#if defined(_KERNEL) || defined(_STANDALONE)
#include <sys/types.h> /* for bool, size_t---XXX not right? */
#else
#include <stdbool.h> /* for bool */
#include <sys/types.h> /* for size_t */
#endif
Apparently, <stddef.h> is the correct header for size_t, so that is more
properly written like this,
#if defined(_KERNEL) || defined(_STANDALONE)
#include <sys/types.h> /* for bool, size_t---XXX not right? */
#else
#include <stdbool.h> /* for bool */
#include <stddef.h> /* for size_t */
#endif
I would prefer for this to suffice both for the kernel and userland:
#include <stdbool.h> /* for bool */
#include <stddef.h> /* for size_t */
ISTM that the reasons things are not that simple are merely historical
reasons, but I am open to other explanations.
Dave
--
David Young
dyoung%pobox.com@localhost Urbana, IL (217) 721-9981
Home |
Main Index |
Thread Index |
Old Index