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 kernel_archs = [ 'arm', 'arm64', 'mips', 'x86' ] 10 11 # the list of include directories that belong to the kernel 12 # tree. used when looking for sources... 13 kernel_dirs = [ "linux", "asm", "asm-generic", "mtd" ] 14 15 # a special value that is used to indicate that a given macro is known to be 16 # undefined during optimization 17 kCppUndefinedMacro = "<<<undefined>>>" 18 19 # this is the set of known macros we want to totally optimize out from the 20 # final headers 21 kernel_known_macros = { 22 "__KERNEL__": kCppUndefinedMacro, 23 "__KERNEL_STRICT_NAMES":"1", 24 "__CHECKER__": kCppUndefinedMacro, 25 "__CHECK_ENDIAN__": kCppUndefinedMacro, 26 "CONFIG_64BIT": "__LP64__", 27 "CONFIG_X86_32": "__i386__", 28 "__EXPORTED_HEADERS__": "1", 29 "__HAVE_BUILTIN_BSWAP16__": "1", 30 "__HAVE_BUILTIN_BSWAP32__": "1", 31 "__HAVE_BUILTIN_BSWAP64__": "1", 32 } 33 34 # define to true if you want to remove all defined(CONFIG_FOO) tests 35 # from the clean headers. testing shows that this is not strictly necessary 36 # but just generates cleaner results 37 kernel_remove_config_macros = True 38 39 # maps an architecture to a set of default macros that would be provided by 40 # toolchain preprocessor 41 kernel_default_arch_macros = { 42 "arm": {"__ARMEB__": kCppUndefinedMacro, "__ARM_EABI__": "1"}, 43 "arm64": {}, 44 "mips": {"__MIPSEB__": kCppUndefinedMacro, 45 "__MIPSEL__": "1", 46 "CONFIG_32BIT": "_ABIO32", 47 "CONFIG_CPU_LITTLE_ENDIAN": "1", 48 "__SANE_USERSPACE_TYPES__": "1",}, 49 "x86": {}, 50 } 51 52 kernel_arch_token_replacements = { 53 "arm": {}, 54 "arm64": {}, 55 "mips": {"off_t":"__kernel_off_t"}, 56 "x86": {}, 57 } 58 59 # Replace tokens in the output according to this mapping. 60 kernel_token_replacements = { 61 # The kernel's ARG_MAX is actually the "minimum" maximum (see fs/exec.c). 62 "ARG_MAX": "_KERNEL_ARG_MAX", 63 # The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>. 64 "__unused": "__linux_unused", 65 # The kernel usage of C++ keywords causes problems for C++ code so rename. 66 "private": "__linux_private", 67 "virtual": "__linux_virtual", 68 # The non-64 stuff is legacy; msqid64_ds/ipc64_perm is what userspace wants. 69 "msqid_ds": "__kernel_legacy_msqid_ds", 70 "semid_ds": "__kernel_legacy_semid_ds", 71 "shmid_ds": "__kernel_legacy_shmid_ds", 72 "ipc_perm": "__kernel_legacy_ipc_perm", 73 # The kernel semun isn't usable (https://github.com/android-ndk/ndk/issues/400). 74 "semun": "__kernel_legacy_semun", 75 # The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside. 76 "_NSIG": "_KERNEL__NSIG", 77 "NSIG": "_KERNEL_NSIG", 78 # The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few. 79 "SIGRTMIN": "__SIGRTMIN", 80 "SIGRTMAX": "__SIGRTMAX", 81 # We want to support both BSD and Linux member names in struct udphdr. 82 "udphdr": "__kernel_udphdr", 83 # The kernel's struct epoll_event just has __u64 for the data. 84 "epoll_event": "__kernel_uapi_epoll_event", 85 # This causes problems when trying to export the headers for the ndk. 86 "__attribute_const__": "__attribute__((__const__))", 87 } 88 89 # This is the set of known static inline functions that we want to keep 90 # in the final kernel headers. 91 kernel_known_arm_statics = set( 92 [ 93 ] 94 ) 95 96 kernel_known_arm64_statics = set( 97 [ 98 ] 99 ) 100 101 kernel_known_mips_statics = set( 102 [ 103 ] 104 ) 105 106 kernel_known_x86_statics = set( 107 [ 108 ] 109 ) 110 111 kernel_known_generic_statics = set( 112 [ 113 "ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h 114 "ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h 115 # Byte swapping inlines from uapi/linux/swab.h 116 # The below functions are the ones we are guaranting we export. 117 "__swab16", 118 "__swab32", 119 "__swab64", 120 "__swab16p", 121 "__swab32p", 122 "__swab64p", 123 "__swab16s", 124 "__swab32s", 125 "__swab64s", 126 "__swahw32", 127 "__swahb32", 128 "__swahw32p", 129 "__swahb32p", 130 "__swahw32s", 131 "__swahb32s", 132 # These are required to support the above functions. 133 "__fswahw32", 134 "__fswahb32", 135 ] 136 ) 137 138 # this maps an architecture to the set of static inline functions that 139 # we want to keep in the final headers 140 # 141 kernel_known_statics = { 142 "arm" : kernel_known_arm_statics, 143 "arm64" : kernel_known_arm64_statics, 144 "mips" : kernel_known_mips_statics, 145 "x86" : kernel_known_x86_statics, 146 } 147 148 # this is a list of macros which we want to specifically exclude from 149 # the generated files. 150 # 151 kernel_ignored_macros = set( 152 [ 153 154 ] 155 ) 156 157 # this is the standard disclaimer 158 # 159 kernel_disclaimer = """\ 160 /**************************************************************************** 161 **************************************************************************** 162 *** 163 *** This header was automatically generated from a Linux kernel header 164 *** of the same name, to make information necessary for userspace to 165 *** call into the kernel available to libc. It contains only constants, 166 *** structures, and macros generated from the original header, and thus, 167 *** contains no copyrightable information. 168 *** 169 *** To edit the content of this header, modify the corresponding 170 *** source file (e.g. under external/kernel-headers/original/) then 171 *** run bionic/libc/kernel/tools/update_all.py 172 *** 173 *** Any manual change here will be lost the next time this script will 174 *** be run. You've been warned! 175 *** 176 **************************************************************************** 177 ****************************************************************************/ 178 """ 179