• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Bionic Kernel Header Files
2==========================
3
4Bionic comes with a processed set of all of the uapi Linux kernel headers that
5can safely be included by userland applications and libraries.
6
7These clean headers are automatically generated by several scripts located
8in the 'bionic/kernel/tools' directory. The tools process the original
9unmodified kernel headers in order to get rid of many annoying
10declarations and constructs that usually result in compilation failure.
11
12The 'clean headers' only contain type and macro definitions, with the
13exception of a couple static inline functions used for performance
14reason (e.g. optimized CPU-specific byte-swapping routines).
15
16They can be included from C++, or when compiling code in strict ANSI mode.
17They can be also included before or after any Bionic C library header.
18
19Description of the directories involved in generating the parsed kernel headers:
20
21  * 'external/kernel-headers/original/'
22    Contains the uapi kernel headers found in the android kernel. Note this
23    also includes the header files that are generated by building the kernel
24    sources.
25
26  * 'bionic/libc/kernel/uapi'
27    Contains the cleaned kernel headers and mirrors the directory structure
28    in 'external/kernel-headers/original/uapi/'.
29
30  * 'bionic/libc/kernel/tools'
31    Contains various Python and shell scripts used to get and re-generate
32    the headers.
33
34The tools to get/parse the headers:
35
36  * tools/generate_uapi_headers.sh
37    Checks out the android kernel and generates all uapi header files.
38    copies all the changed files into external/kernel-headers.
39
40  * tools/clean_header.py
41    Prints the clean version of a given kernel header. With the -u option,
42    this will also update the corresponding clean header file if its
43    content has changed. You can also process more than one file with -u.
44
45  * tools/update_all.py
46    Automatically update all clean headers from the content of
47    'external/kernel-headers/original'.
48
49How To Update The Headers
50=========================
51
52IMPORTANT IMPORTANT:
53
54WHEN UPDATING THE HEADERS, ALWAYS CHECK THAT THE NEW CLEAN HEADERS DO
55NOT BREAK THE KERNEL <-> USER ABI, FOR EXAMPLE BY CHANGING THE SIZE
56OF A GIVEN TYPE. THIS TASK CANNOT BE EASILY AUTOMATED AT THE MOMENT.
57
58Download the Linux kernel source code:
59
60  > mkdir kernel_src
61  > cd kernel_src
62  kernel_src> git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
63
64Then checkout the stable tag for the new kernel headers to import:
65
66  kernel_src> cd linux-stable
67  kernel_src/linux-stable> git checkout tags/vXXX
68
69Before running the command to import the headers, make sure that you have
70done a lunch TARGET. The script uses a variable set by the lunch command
71to determine which directory to use as the destination directory.
72
73After running lunch, run this command to import the headers into the android
74source tree:
75
76  bionic/libc/kernel/tools/generate_uapi_headers.sh --use-kernel-dir kernel_src
77
78Next, run this command to copy the parsed files to bionic/libc/kernel/uapi:
79
80  bionic/libc/kernel/tools/update_all.py
81
82Finally, run this command to regenerate the syscalls list:
83
84  bionic/libc/tools/gensyscalls.py
85
86After this, you will need to build/test the tree to make sure that these
87changes do not introduce any errors.
88