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 non-empty, that means that in 32# addition to removing the structure, add a #include to the file. 33kernel_structs_to_remove = { 34 # Remove these structures since they are still the same as 35 # timeval, itimerval. Also, add an include of linux/time.h 36 # since __kernel_old_timeval is being changed to timeval, and 37 # is only present in linux/time.h. 38 "__kernel_old_timeval": "linux/time.h", 39 "__kernel_old_itimerval": None, 40 # Replace all of the below structures with #include <bits/STRUCT.h> 41 "__kernel_sockaddr_storage": "bits/sockaddr_storage.h", 42 "epoll_event": "bits/epoll_event.h", 43 "flock": "bits/flock.h", 44 "flock64": "bits/flock64.h", 45 "in_addr": "bits/in_addr.h", 46 "ip_mreq_source": "bits/ip_mreq_source.h", 47 "ip_msfilter": "bits/ip_msfilter.h", 48 "tcphdr": "bits/tcphdr.h", 49 "timespec": "bits/timespec.h", 50 } 51 52# define to true if you want to remove all defined(CONFIG_FOO) tests 53# from the clean headers. testing shows that this is not strictly necessary 54# but just generates cleaner results 55kernel_remove_config_macros = True 56 57# Maps an architecture to a set of default macros that would be provided by 58# the toolchain's preprocessor. Currently only used to remove confusing 59# big-endian junk from the 32-bit arm headers. 60kernel_default_arch_macros = { 61 "arm": {"__ARMEB__": kCppUndefinedMacro, "__ARM_EABI__": "1"}, 62 } 63 64# Replace tokens in the output according to this mapping. 65kernel_token_replacements = { 66 # The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>. 67 "__unused": "__linux_unused", 68 # The kernel usage of C++ keywords causes problems for C++ code so rename. 69 "class": "__linux_class", 70 "private": "__linux_private", 71 "virtual": "__linux_virtual", 72 # The non-64 stuff is legacy; msqid64_ds/ipc64_perm is what userspace wants. 73 "msqid_ds": "__kernel_legacy_msqid_ds", 74 "semid_ds": "__kernel_legacy_semid_ds", 75 "shmid_ds": "__kernel_legacy_shmid_ds", 76 "ipc_perm": "__kernel_legacy_ipc_perm", 77 # The kernel semun isn't usable (https://github.com/android-ndk/ndk/issues/400). 78 "semun": "__kernel_legacy_semun", 79 # The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside. 80 "_NSIG": "_KERNEL__NSIG", 81 "NSIG": "_KERNEL_NSIG", 82 # The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few. 83 "SIGRTMIN": "__SIGRTMIN", 84 "SIGRTMAX": "__SIGRTMAX", 85 # We want to support both BSD and Linux member names in struct udphdr. 86 "udphdr": "__kernel_udphdr", 87 # This causes problems when trying to export the headers for the ndk. 88 "__attribute_const__": "__attribute__((__const__))", 89 # The kernel started using struct __kernel_old_timeval in some places, 90 # which is the exact same as struct timeval. Replace that name with 91 # timeval so that kernel structures all use the same named structure. 92 # If struct __kernel_old_timeval and struct timeval become different, 93 # then a different solution needs to be implemented. 94 "__kernel_old_timeval": "timeval", 95 # Do the same for __kernel_old_itimerval as for timeval. 96 "__kernel_old_itimerval": "itimerval", 97 # Do the same for __kernel_sockaddr_storage. 98 "__kernel_sockaddr_storage": "sockaddr_storage", 99 # Replace __packed with __attribute__((__packed__)) to avoid depending 100 # on sys/cdefs.h 101 "__packed": "__attribute__((__packed__))", 102 # Remove unused macros (http://b/262917450). 103 "__force": "", 104 "__user": "", 105 # Rename the kernel's sigaction so we can expose our POSIX one publicly, 106 # but translate to the kernel's one internally. 107 "sigaction": "__kernel_sigaction", 108 } 109 110 111# Static inline functions that we want to keep. 112kernel_known_generic_statics = set( 113 [ 114 "ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h 115 "ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h 116 # Byte swapping inlines from uapi/linux/swab.h 117 # The below functions are the ones we are guaranting we export. 118 "__swab16", 119 "__swab32", 120 "__swab64", 121 "__swab16p", 122 "__swab32p", 123 "__swab64p", 124 "__swab16s", 125 "__swab32s", 126 "__swab64s", 127 "__swahw32", 128 "__swahb32", 129 "__swahw32p", 130 "__swahb32p", 131 "__swahw32s", 132 "__swahb32s", 133 # These are required to support the above functions. 134 "__fswahw32", 135 "__fswahb32", 136 # This is used by various macros in <linux/ioprio.h>. 137 "ioprio_value", 138 139 # Contact opensource-licensing@ before adding to this set. 140 ] 141 ) 142