1# All the defaults used to generate the cleaned-up uapi headers for bionic. 2 3# the list of include directories that belong to the kernel 4# tree. used when looking for sources... 5kernel_dirs = [ "linux", "asm", "asm-generic", "mtd" ] 6 7# a special value that is used to indicate that a given macro is known to be 8# undefined during optimization 9kCppUndefinedMacro = "<<<undefined>>>" 10 11# this is the set of known macros we want to totally optimize out from the 12# final headers 13kernel_known_macros = { 14 "__KERNEL__": kCppUndefinedMacro, 15 "__KERNEL_STRICT_NAMES":"1", 16 "__CHECKER__": kCppUndefinedMacro, 17 "__CHECK_ENDIAN__": kCppUndefinedMacro, 18 "CONFIG_64BIT": "__LP64__", 19 "CONFIG_X86_32": "__i386__", 20 "__EXPORTED_HEADERS__": "1", 21 "__HAVE_BUILTIN_BSWAP16__": "1", 22 "__HAVE_BUILTIN_BSWAP32__": "1", 23 "__HAVE_BUILTIN_BSWAP64__": "1", 24 # Use this to remove the struct __kernel_old_timeval definition. 25 # Otherwise, there will be two struct timeval definitions when 26 # __kernel_old_timeval is renamed to timeval. 27 "__kernel_old_timeval": "1", 28 } 29 30# This is the set of known kernel data structures we want to remove from 31# the final headers. If the map value is False, that means that in 32# addition to removing the structure, add an #include <bits/STRUCT.h> 33# to the file. 34kernel_structs_to_remove = { 35 # Remove the structures since they are still the same as 36 # timeval, itimerval. 37 "__kernel_old_timeval": True, 38 "__kernel_old_itimerval": True, 39 # Replace all of the below structures with #include <bits/STRUCT.h> 40 "epoll_event": False, 41 "flock": False, 42 "flock64": False, 43 "in_addr": False, 44 "ip_mreq_source": False, 45 "ip_msfilter": False, 46 "timespec": False, 47 } 48 49# define to true if you want to remove all defined(CONFIG_FOO) tests 50# from the clean headers. testing shows that this is not strictly necessary 51# but just generates cleaner results 52kernel_remove_config_macros = True 53 54# Maps an architecture to a set of default macros that would be provided by 55# the toolchain's preprocessor. Currently only used to remove confusing 56# big-endian junk from the 32-bit arm headers. 57kernel_default_arch_macros = { 58 "arm": {"__ARMEB__": kCppUndefinedMacro, "__ARM_EABI__": "1"}, 59 } 60 61# Replace tokens in the output according to this mapping. 62kernel_token_replacements = { 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 # This causes problems when trying to export the headers for the ndk. 84 "__attribute_const__": "__attribute__((__const__))", 85 # The kernel started using struct __kernel_old_timeval in some places, 86 # which is the exact same as struct timeval. Replace that name with 87 # timeval so that kernel structures all use the same named structure. 88 # If struct __kernel_old_timeval and struct timeval become different, 89 # then a different solution needs to be implemented. 90 "__kernel_old_timeval": "timeval", 91 # Do the same for __kernel_old_itimerval as for timeval. 92 "__kernel_old_itimerval": "itimerval", 93 # Replace __packed with __attribute__((__packed__)) to avoid depending 94 # on sys/cdefs.h 95 "__packed": "__attribute__((__packed__))", 96 # Remove unused macros (http://b/262917450). 97 "__force": "", 98 "__user": "", 99 } 100 101 102# This is the set of known static inline functions that we want to keep 103# in the final kernel headers. 104kernel_known_generic_statics = set( 105 [ 106 "ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h 107 "ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h 108 # Byte swapping inlines from uapi/linux/swab.h 109 # The below functions are the ones we are guaranting we export. 110 "__swab16", 111 "__swab32", 112 "__swab64", 113 "__swab16p", 114 "__swab32p", 115 "__swab64p", 116 "__swab16s", 117 "__swab32s", 118 "__swab64s", 119 "__swahw32", 120 "__swahb32", 121 "__swahw32p", 122 "__swahb32p", 123 "__swahw32s", 124 "__swahb32s", 125 # These are required to support the above functions. 126 "__fswahw32", 127 "__fswahb32", 128 ] 129 ) 130 131# this is the standard disclaimer 132# 133kernel_disclaimer = """\ 134/**************************************************************************** 135 **************************************************************************** 136 *** 137 *** This header was automatically generated from a Linux kernel header 138 *** of the same name, to make information necessary for userspace to 139 *** call into the kernel available to libc. It contains only constants, 140 *** structures, and macros generated from the original header, and thus, 141 *** contains no copyrightable information. 142 *** 143 *** To edit the content of this header, modify the corresponding 144 *** source file (e.g. under external/kernel-headers/original/) then 145 *** run bionic/libc/kernel/tools/update_all.py 146 *** 147 *** Any manual change here will be lost the next time this script will 148 *** be run. You've been warned! 149 *** 150 **************************************************************************** 151 ****************************************************************************/ 152""" 153