Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 1 | Bionic comes with a processed set of all of the uapi Linux kernel headers that |
| 2 | can safely be included by userland applications and libraries. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 3 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 4 | These clean headers are automatically generated by several scripts located |
| 5 | in the 'bionic/kernel/tools' directory. The tools process the original |
| 6 | unmodified kernel headers in order to get rid of many annoying |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 7 | declarations and constructs that usually result in compilation failure. |
| 8 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 9 | The 'clean headers' only contain type and macro definitions, with the |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 10 | exception of a couple static inline functions used for performance |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 11 | reason (e.g. optimized CPU-specific byte-swapping routines). |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 12 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 13 | They can be included from C++, or when compiling code in strict ANSI mode. |
| 14 | They can be also included before or after any Bionic C library header. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 15 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 16 | Description of the directories involved in generating the parsed kernel headers: |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 17 | |
Andrew Hsieh | 126601d | 2012-03-23 23:07:36 +0800 | [diff] [blame] | 18 | * 'external/kernel-headers/original/' |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 19 | 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 Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 22 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 23 | * '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 Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 26 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 27 | * 'bionic/libc/kernel/tools' |
| 28 | Contains various Python and shell scripts used to get and re-generate |
| 29 | the headers. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 30 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 31 | The tools to get/parse the headers: |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 32 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 33 | * 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 Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 36 | |
| 37 | * tools/clean_header.py |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 38 | Prints the clean version of a given kernel header. With the -u option, |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 39 | this will also update the corresponding clean header file if its |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 40 | content has changed. You can also process more than one file with -u. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 41 | |
| 42 | * tools/update_all.py |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 43 | Automatically update all clean headers from the content of |
| 44 | 'external/kernel-headers/original'. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 45 | |
| 46 | |
| 47 | HOW TO UPDATE THE HEADERS WHEN NEEDED: |
| 48 | ====================================== |
| 49 | |
| 50 | IMPORTANT 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 Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 56 | Grab the latest headers from the android kernel by running this command: |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 57 | |
Christopher Ferris | ea271fd | 2014-07-15 19:02:33 -0700 | [diff] [blame] | 58 | bionic/libc/kernel/tools/generate_uapi_headers.sh --download-kernel |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 59 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 60 | Next, run this command to copy the parsed files to bionic/libc/kernel/uapi: |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 61 | |
Christopher Ferris | ea271fd | 2014-07-15 19:02:33 -0700 | [diff] [blame] | 62 | bionic/libc/kernel/tools/update_all.py |
| 63 | |
| 64 | Finally, run this command to regenerate the syscalls list: |
| 65 | |
| 66 | bionic/libc/tools/gensyscalls.py |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 67 | |
Christopher Ferris | 08b6074 | 2014-06-05 11:17:06 -0700 | [diff] [blame] | 68 | After this, you will need to build/test the tree to make sure that these |
| 69 | changes do not introduce any errors. |