looking to clarify the uapi/ refactoring, and some oddities
Robert P. J. Day
rpjday at crashcourse.ca
Fri Oct 26 07:30:11 EDT 2012
after reading the overview of the uapi refactoring, let me summarize
what i *think* is going on, point out some oddities, and ask some
questions. (good writeup is here: http://lwn.net/Articles/507794/)
first, a question -- is the uapi reorg meant to completely obsolete
"make headers_install"? with userspace API content now broken off
into its own uapi/ subdirectories, does this not make that target
entirely superfluous? or is there something else happening here?
i can see the Kbuild infrastructure is still there but, theoretically,
why would it be necessary anymore given the refactoring?
next, as i read it, all of the kernel header file content can be
broken into exactly three (reasonable) categories:
* kernel-only
* shared between kernel and userspace
* userspace only
so far, so good, so let's look at each category.
header files that contain kernel-only content should now reside in a
"normal" include directory like include/linux and, as i read it, they
shouldn't need any "__KERNEL__" preprocessor checks anymore, but
there's still a lot of that:
$ cd include/linux
$ grep -r "#if.*__KERNEL__" * | wc -l
101
$
admittedly, those checks don't *hurt*, but is the plan that all of
that eventually gets cleared out?
in the other category/categories, we have all userspace content that
should now be moved under some uapi/ directory. now those files
*might* have checks of the form:
#ifndef __KERNEL__
to reflect userspace-only content, that's fine. what they *shouldn't*
have is:
#ifdef __KERNEL__
since that reflects kernel space content and shouldn't be in a uapi/
directory, correct? unless, as i see it, it's a test that affects an
actual structure definition, then there's really no way around it,
like this in acct.h:
#ifdef __KERNEL__
__u32 ac_etime; /* Elapsed Time */
#else
float ac_etime; /* Elapsed Time */
#endif
and i mentioned the strangeness with coda.h yesterday as well;
here's the regular file:
#if defined(__linux__)
typedef unsigned long long u_quad_t;
#else <-- that's a bit strange
#endif
#include <uapi/linux/coda.h>
and here's the uapi version:
... snip ...
#ifdef KERNEL <--- why is this here?
typedef unsigned long u_long;
typedef unsigned int u_int;
typedef unsigned short u_short;
typedef u_long ino_t;
typedef u_long dev_t;
typedef void * caddr_t;
... snip ...
anyway, i'm sure this all works fine, but it certainly seems that
there's a lot of leftover cruft that could still be deleted. is that
still part of the plan?
rday
p.s. amusingly, what's still left in some of the uapi/ headers are
*comments* referring to kernel checks that obviously don't exist
anymore. eg., in include/uapi/linux/virtio_config.h:
/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
* anyone can use the definitions to implement compatible drivers/servers.
i might throw together some cheap patches to get rid of that stuff.
it offends my pedantic sensibilities. :-)
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
More information about the Kernelnewbies
mailing list