The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | # this module contains all the defaults used by the generation of cleaned-up headers |
| 2 | # for the Bionic C library |
| 3 | # |
| 4 | |
| 5 | import time, os, sys |
| 6 | from utils import * |
| 7 | |
| 8 | # the list of supported architectures |
| 9 | # |
Ben Cheng | 8bea2b6 | 2013-10-16 15:28:56 -0700 | [diff] [blame] | 10 | kernel_archs = [ 'aarch64', 'arm', 'mips', 'x86' ] |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 11 | |
| 12 | # the list of include directories that belong to the kernel |
| 13 | # tree. used when looking for sources... |
| 14 | # |
| 15 | kernel_dirs = [ "linux", "asm", "asm-generic", "mtd" ] |
| 16 | |
| 17 | # path to the directory containing the original kernel headers |
| 18 | # |
David 'Digit' Turner | fc26931 | 2010-10-11 22:11:06 +0200 | [diff] [blame] | 19 | kernel_original_path = os.path.normpath( find_program_dir() + '/../../../../external/kernel-headers/original' ) |
| 20 | |
| 21 | # path to the default location of the cleaned-up headers |
| 22 | # |
| 23 | kernel_cleaned_path = os.path.normpath( find_program_dir() + '/..' ) |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 24 | |
| 25 | # a special value that is used to indicate that a given macro is known to be |
| 26 | # undefined during optimization |
| 27 | kCppUndefinedMacro = "<<<undefined>>>" |
| 28 | |
| 29 | # this is the set of known macros we want to totally optimize out from the |
| 30 | # final headers |
| 31 | kernel_known_macros = { |
| 32 | "__KERNEL__": kCppUndefinedMacro, |
| 33 | "__KERNEL_STRICT_NAMES":"1", |
| 34 | "__CHECKER__": kCppUndefinedMacro, |
| 35 | "__CHECK_ENDIAN__": kCppUndefinedMacro, |
Elliott Hughes | d3e64a3 | 2013-09-30 17:41:08 -0700 | [diff] [blame] | 36 | "CONFIG_X86_32": "__i386__", |
Ben Cheng | 460fa70 | 2013-10-23 14:38:25 -0700 | [diff] [blame] | 37 | "__EXPORTED_HEADERS__": "1", |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | # define to true if you want to remove all defined(CONFIG_FOO) tests |
| 41 | # from the clean headers. testing shows that this is not strictly necessary |
| 42 | # but just generates cleaner results |
| 43 | kernel_remove_config_macros = True |
| 44 | |
The Android Open Source Project | 4e468ed | 2008-12-17 18:03:48 -0800 | [diff] [blame] | 45 | # maps an architecture to a set of default macros that would be provided by |
| 46 | # toolchain preprocessor |
| 47 | kernel_default_arch_macros = { |
Ben Cheng | 8bea2b6 | 2013-10-16 15:28:56 -0700 | [diff] [blame] | 48 | "aarch64": {}, |
The Android Open Source Project | 4e468ed | 2008-12-17 18:03:48 -0800 | [diff] [blame] | 49 | "arm": {}, |
Raghu Gandham | 988ff8f | 2012-09-21 17:13:25 -0700 | [diff] [blame] | 50 | "mips": {"CONFIG_32BIT":"1"}, |
Elliott Hughes | d3e64a3 | 2013-09-30 17:41:08 -0700 | [diff] [blame] | 51 | "x86": {}, |
The Android Open Source Project | 4e468ed | 2008-12-17 18:03:48 -0800 | [diff] [blame] | 52 | } |
| 53 | |
Raghu Gandham | a864c2c | 2013-01-16 16:42:47 -0800 | [diff] [blame] | 54 | kernel_arch_token_replacements = { |
Ben Cheng | 8bea2b6 | 2013-10-16 15:28:56 -0700 | [diff] [blame] | 55 | "aarch64": {}, |
Raghu Gandham | a864c2c | 2013-01-16 16:42:47 -0800 | [diff] [blame] | 56 | "arm": {}, |
Raghu Gandham | a864c2c | 2013-01-16 16:42:47 -0800 | [diff] [blame] | 57 | "mips": {"off_t":"__kernel_off_t"}, |
Elliott Hughes | d3e64a3 | 2013-09-30 17:41:08 -0700 | [diff] [blame] | 58 | "x86": {}, |
Raghu Gandham | a864c2c | 2013-01-16 16:42:47 -0800 | [diff] [blame] | 59 | } |
Martin Storsjo | c9205db | 2010-12-08 11:39:05 +0100 | [diff] [blame] | 60 | # Replace tokens in the output according to this mapping |
| 61 | kernel_token_replacements = { |
David 'Digit' Turner | b969b5a | 2011-01-11 17:23:10 +0100 | [diff] [blame] | 62 | "asm": "__asm__", |
Raghu Gandham | 0e77287 | 2012-09-25 17:49:17 -0700 | [diff] [blame] | 63 | "__unused": "__linux_unused", # The kernel usage of __unused conflicts with the macro defined in sys/cdefs.h |
Martin Storsjo | c9205db | 2010-12-08 11:39:05 +0100 | [diff] [blame] | 64 | } |
| 65 | |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 66 | # this is the set of known static inline functions that we want to keep |
| 67 | # in the final ARM headers. this is only used to keep optimized byteswapping |
| 68 | # static functions and stuff like that. |
Ben Cheng | 8bea2b6 | 2013-10-16 15:28:56 -0700 | [diff] [blame] | 69 | kernel_known_aarch64_statics = set( |
| 70 | [ |
| 71 | ] |
| 72 | ) |
| 73 | |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 74 | kernel_known_arm_statics = set( |
Elliott Hughes | d3e64a3 | 2013-09-30 17:41:08 -0700 | [diff] [blame] | 75 | [ "___arch__swab32", # asm-arm/byteorder.h |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 76 | ] |
| 77 | ) |
| 78 | |
Raghu Gandham | 82fa43f | 2012-03-27 11:37:17 -0700 | [diff] [blame] | 79 | kernel_known_mips_statics = set( |
| 80 | [ |
| 81 | ] |
| 82 | ) |
| 83 | |
Elliott Hughes | d3e64a3 | 2013-09-30 17:41:08 -0700 | [diff] [blame] | 84 | kernel_known_x86_statics = set( |
| 85 | [ "___arch__swab32", # asm-x86/byteorder.h |
| 86 | "___arch__swab64", # asm-x86/byteorder.h |
| 87 | ] |
| 88 | ) |
| 89 | |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 90 | kernel_known_generic_statics = set( |
| 91 | [ "__invalid_size_argument_for_IOC", # asm-generic/ioctl.h |
| 92 | "__cmsg_nxthdr", # linux/socket.h |
| 93 | "cmsg_nxthdr", # linux/socket.h |
| 94 | "ipt_get_target", |
Vilmos Nebehaj | c1a534b | 2010-06-28 15:13:23 +0200 | [diff] [blame] | 95 | "ip6t_get_target", |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 96 | ] |
| 97 | ) |
| 98 | |
| 99 | # this maps an architecture to the set of static inline functions that |
| 100 | # we want to keep in the final headers |
| 101 | # |
| 102 | kernel_known_statics = { |
Ben Cheng | 8bea2b6 | 2013-10-16 15:28:56 -0700 | [diff] [blame] | 103 | "aarch64" : kernel_known_aarch64_statics, |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 104 | "arm" : kernel_known_arm_statics, |
Elliott Hughes | d3e64a3 | 2013-09-30 17:41:08 -0700 | [diff] [blame] | 105 | "mips" : kernel_known_mips_statics, |
Shin-ichiro KAWASAKI | 37429ff | 2009-07-01 15:41:52 +0900 | [diff] [blame] | 106 | "x86" : kernel_known_x86_statics, |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 107 | } |
| 108 | |
The Android Open Source Project | 6d6c82c | 2009-01-09 17:50:54 -0800 | [diff] [blame] | 109 | # this is a list of macros which we want to specifically exclude from |
| 110 | # the generated files. |
| 111 | # |
| 112 | kernel_ignored_macros = set( |
| 113 | [ "MAXHOSTNAMELEN", # for some reason, Linux defines it to 64 |
| 114 | # while most of the BSD code expects this to be 256 |
| 115 | # so ignore the kernel-provided definition and |
| 116 | # define it in the Bionic headers instead |
| 117 | ] |
| 118 | ) |
| 119 | |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 120 | # this is the standard disclaimer |
| 121 | # |
| 122 | kernel_disclaimer = """\ |
| 123 | /**************************************************************************** |
| 124 | **************************************************************************** |
| 125 | *** |
| 126 | *** This header was automatically generated from a Linux kernel header |
| 127 | *** of the same name, to make information necessary for userspace to |
| 128 | *** call into the kernel available to libc. It contains only constants, |
| 129 | *** structures, and macros generated from the original header, and thus, |
| 130 | *** contains no copyrightable information. |
| 131 | *** |
David 'Digit' Turner | fc26931 | 2010-10-11 22:11:06 +0200 | [diff] [blame] | 132 | *** To edit the content of this header, modify the corresponding |
| 133 | *** source file (e.g. under external/kernel-headers/original/) then |
| 134 | *** run bionic/libc/kernel/tools/update_all.py |
| 135 | *** |
| 136 | *** Any manual change here will be lost the next time this script will |
| 137 | *** be run. You've been warned! |
| 138 | *** |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 139 | **************************************************************************** |
| 140 | ****************************************************************************/ |
| 141 | """ |
David 'Digit' Turner | fc26931 | 2010-10-11 22:11:06 +0200 | [diff] [blame] | 142 | |
| 143 | # This is the warning line that will be inserted every N-th line in the output |
| 144 | kernel_warning = """\ |
| 145 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ |
| 146 | """ |