blob: e7312ef2187030cad4715c8a329c571aaf6863f7 [file] [log] [blame]
Christopher Ferris08b60742014-06-05 11:17:06 -07001Bionic comes with a processed set of all of the uapi Linux kernel headers that
2can safely be included by userland applications and libraries.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08003
Christopher Ferris08b60742014-06-05 11:17:06 -07004These clean headers are automatically generated by several scripts located
5in the 'bionic/kernel/tools' directory. The tools process the original
6unmodified kernel headers in order to get rid of many annoying
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08007declarations and constructs that usually result in compilation failure.
8
Christopher Ferris08b60742014-06-05 11:17:06 -07009The 'clean headers' only contain type and macro definitions, with the
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080010exception of a couple static inline functions used for performance
Christopher Ferris08b60742014-06-05 11:17:06 -070011reason (e.g. optimized CPU-specific byte-swapping routines).
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080012
Christopher Ferris08b60742014-06-05 11:17:06 -070013They can be included from C++, or when compiling code in strict ANSI mode.
14They can be also included before or after any Bionic C library header.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080015
Christopher Ferris08b60742014-06-05 11:17:06 -070016Description of the directories involved in generating the parsed kernel headers:
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080017
Andrew Hsieh126601d2012-03-23 23:07:36 +080018 * 'external/kernel-headers/original/'
Christopher Ferris08b60742014-06-05 11:17:06 -070019 Contains the uapi kernel headers found in the android kernel. Note this
20 also includes the header files that are generated by building the kernel
21 sources.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080022
Christopher Ferris08b60742014-06-05 11:17:06 -070023 * 'bionic/libc/kernel/uapi'
24 Contains the cleaned kernel headers and mirrors the directory structure
25 in 'external/kernel-headers/original/uapi/'.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080026
Christopher Ferris08b60742014-06-05 11:17:06 -070027 * 'bionic/libc/kernel/tools'
28 Contains various Python and shell scripts used to get and re-generate
29 the headers.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080030
Christopher Ferris08b60742014-06-05 11:17:06 -070031The tools to get/parse the headers:
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080032
Christopher Ferris08b60742014-06-05 11:17:06 -070033 * tools/generate_uapi_headers.sh
34 Checks out the android kernel and generates all uapi header files.
35 copies all the changed files into external/kernel-headers.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080036
37 * tools/clean_header.py
Christopher Ferris08b60742014-06-05 11:17:06 -070038 Prints the clean version of a given kernel header. With the -u option,
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080039 this will also update the corresponding clean header file if its
Christopher Ferris08b60742014-06-05 11:17:06 -070040 content has changed. You can also process more than one file with -u.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080041
42 * tools/update_all.py
Christopher Ferris08b60742014-06-05 11:17:06 -070043 Automatically update all clean headers from the content of
44 'external/kernel-headers/original'.
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080045
46
47HOW TO UPDATE THE HEADERS WHEN NEEDED:
48======================================
49
50IMPORTANT IMPORTANT:
51
52 WHEN UPDATING THE HEADERS, ALWAYS CHECK THAT THE NEW CLEAN HEADERS DO
53 NOT BREAK THE KERNEL <-> USER ABI, FOR EXAMPLE BY CHANGING THE SIZE
54 OF A GIVEN TYPE. THIS TASK CANNOT BE EASILY AUTOMATED AT THE MOMENT
55
Christopher Ferris08b60742014-06-05 11:17:06 -070056Grab the latest headers from the android kernel by running this command:
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080057
Christopher Ferrisea271fd2014-07-15 19:02:33 -070058 bionic/libc/kernel/tools/generate_uapi_headers.sh --download-kernel
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080059
Christopher Ferris08b60742014-06-05 11:17:06 -070060Next, run this command to copy the parsed files to bionic/libc/kernel/uapi:
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080061
Christopher Ferrisea271fd2014-07-15 19:02:33 -070062 bionic/libc/kernel/tools/update_all.py
63
64Finally, run this command to regenerate the syscalls list:
65
66 bionic/libc/tools/gensyscalls.py
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080067
Christopher Ferris08b60742014-06-05 11:17:06 -070068After this, you will need to build/test the tree to make sure that these
69changes do not introduce any errors.