platform_bionic/libc/kernel
Elliott Hughes 64f355ffbd Use in_addr in ip_mreq_source and ip_msfilter.
This adds a new mechanism to say "replace struct S with #include <bits/S.h>".

Also switch epoll_event over to the new mechanism.

Also use the kernel's struct sockaddr_storage directly rather than behind
an unnecessary #define.

This patch also removes some dead code in the header scrubber. This code
still needs rewriting completely. I learned that a "block" isn't necessarily
a single struct definition, say; it might be a run of them. It seems like
a block is a run of preprocessor directives or a run of regular code.

Bug: https://issuetracker.google.com/36987220
Test: new test
Change-Id: Ic6a5c09559766a4babe3cd4c3ea538b885e07308
2017-12-14 10:07:27 -08:00
..
android Update to kernel headers v4.12.3. 2017-07-27 16:01:39 -07:00
tools Use in_addr in ip_mreq_source and ip_msfilter. 2017-12-14 10:07:27 -08:00
uapi Use in_addr in ip_mreq_source and ip_msfilter. 2017-12-14 10:07:27 -08:00
README.TXT Update the kernel header documentation. 2016-07-08 15:29:51 -07:00

Bionic Kernel Header Files
==========================

Bionic comes with a processed set of all of the uapi Linux kernel headers that
can safely be included by userland applications and libraries.

These clean headers are automatically generated by several scripts located
in the 'bionic/kernel/tools' directory. The tools process the original
unmodified kernel headers in order to get rid of many annoying
declarations and constructs that usually result in compilation failure.

The 'clean headers' only contain type and macro definitions, with the
exception of a couple static inline functions used for performance
reason (e.g. optimized CPU-specific byte-swapping routines).

They can be included from C++, or when compiling code in strict ANSI mode.
They can be also included before or after any Bionic C library header.

Description of the directories involved in generating the parsed kernel headers:

  * 'external/kernel-headers/original/'
    Contains the uapi kernel headers found in the android kernel. Note this
    also includes the header files that are generated by building the kernel
    sources.

  * 'bionic/libc/kernel/uapi'
    Contains the cleaned kernel headers and mirrors the directory structure
    in 'external/kernel-headers/original/uapi/'.

  * 'bionic/libc/kernel/tools'
    Contains various Python and shell scripts used to get and re-generate
    the headers.

The tools to get/parse the headers:

  * tools/generate_uapi_headers.sh
    Checks out the android kernel and generates all uapi header files.
    copies all the changed files into external/kernel-headers.

  * tools/clean_header.py
    Prints the clean version of a given kernel header. With the -u option,
    this will also update the corresponding clean header file if its
    content has changed. You can also process more than one file with -u.

  * tools/update_all.py
    Automatically update all clean headers from the content of
    'external/kernel-headers/original'.

How To Update The Headers
=========================

IMPORTANT IMPORTANT:

WHEN UPDATING THE HEADERS, ALWAYS CHECK THAT THE NEW CLEAN HEADERS DO
NOT BREAK THE KERNEL <-> USER ABI, FOR EXAMPLE BY CHANGING THE SIZE
OF A GIVEN TYPE. THIS TASK CANNOT BE EASILY AUTOMATED AT THE MOMENT.

Download the Linux kernel source code:

  > mkdir kernel_src
  > cd kernel_src
  kernel_src> git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

Then checkout the stable tag for the new kernel headers to import:

  kernel_src> cd linux-stable
  kernel_src/linux-stable> git checkout tags/vXXX

Before running the command to import the headers, make sure that you have
done a lunch TARGET. The script uses a variable set by the lunch command
to determine which directory to use as the destination directory.

After running lunch, run this command to import the headers into the android
source tree:

  bionic/libc/kernel/tools/generate_uapi_headers.sh --use-kernel-dir kernel_src

Next, run this command to copy the parsed files to bionic/libc/kernel/uapi:

  bionic/libc/kernel/tools/update_all.py

Finally, run this command to regenerate the syscalls list:

  bionic/libc/tools/gensyscalls.py

After this, you will need to build/test the tree to make sure that these
changes do not introduce any errors.