home | list info | list archive | date index | thread index

[OCLUG-Tech] one or two questions about uapi/ content in kernel source

  • Subject: [OCLUG-Tech] one or two questions about uapi/ content in kernel source
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Wed, 28 May 2014 07:53:21 -0400 (EDT)
  (got some time off so i'm rooting around in the current kernel
source tree and i'll be asking lots of questions of the collective
wisdom of this group.)

  once upon a time (as most people remember), lots of kernel header
files were replete with tests of the form:

  #ifdef __KERNEL__
  #ifndef __KERNEL__

which defined the userspace content to be exported to userspace (the
files to be unifdef'ed listed in Kbuild files all over the place). and
this was allegegly tidied up with the introduction of the uapi/
directory structure, where all userspace content was collected into
one of:

  * include/uapi/...
  * arch/<arch>/include/uapi/...

one would think that that would have made the Kbuild files and all the
__KERNEL__ tests obsolete but i guess it's no surprise that there's
still a lot of that cruft lying around.

  as a simple example, here's a snippet from include/linux/acct.h:

  #ifndef _LINUX_ACCT_H
  #define _LINUX_ACCT_H

  #include <uapi/linux/acct.h>

which clearly pulls in the uapi content for that header file as well.
but over in that second (uapi) file, we still find a (deprecated?)
__KERNEL__ test:

  /* m68k had no padding here. */
  #if !defined(CONFIG_M68K) || !defined(__KERNEL__)
        __u16           ac_ahz;                 /* AHZ */
  #endif
        __u32           ac_exitcode;            /* Exitcode */

and if i run "make headers_install" to see the end result generated
under <kernel>/usr/include/, i can see the userspace-generated acct.h
file contains the snippet:

  /* m68k had no padding here. */
        __u16           ac_ahz;                 /* AHZ */
        __u32           ac_exitcode;            /* Exitcode */

which is correct, but what's the value of the existing __KERNEL__
test(s) in any of the uapi/ header files?

  a lot of the existing KBuild files are empty, but they still exist
under the uapi/ directories, where they seem to have the same purpose
as before.

  is this leftover junk because the remaining uapi/ header files have
not properly been cleaned of all those __KERNEL__ tests? or is there
still something that those __KERNEL__ tests are being used for?
thanks.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================