1# this module contains all the defaults used by the generation of cleaned-up headers 2# for the Bionic C library 3# 4 5import time, os, sys 6from utils import * 7 8# the list of supported architectures 9kernel_archs = [ 'arm', 'arm64', 'mips', 'x86' ] 10 11# the list of include directories that belong to the kernel 12# tree. used when looking for sources... 13kernel_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 17kCppUndefinedMacro = "<<<undefined>>>" 18 19# this is the set of known macros we want to totally optimize out from the 20# final headers 21kernel_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 } 30 31# define to true if you want to remove all defined(CONFIG_FOO) tests 32# from the clean headers. testing shows that this is not strictly necessary 33# but just generates cleaner results 34kernel_remove_config_macros = True 35 36# maps an architecture to a set of default macros that would be provided by 37# toolchain preprocessor 38kernel_default_arch_macros = { 39 "arm": {"__ARMEB__": kCppUndefinedMacro, "__ARM_EABI__": "1"}, 40 "arm64": {}, 41 "mips": {"__MIPSEB__": kCppUndefinedMacro, 42 "__MIPSEL__": "1", 43 "CONFIG_32BIT": "_ABIO32", 44 "CONFIG_CPU_LITTLE_ENDIAN": "1", 45 "__SANE_USERSPACE_TYPES__": "1",}, 46 "x86": {}, 47 } 48 49kernel_arch_token_replacements = { 50 "arm": {}, 51 "arm64": {}, 52 "mips": {"off_t":"__kernel_off_t"}, 53 "x86": {}, 54 } 55 56# Replace tokens in the output according to this mapping. 57kernel_token_replacements = { 58 # The kernel's ARG_MAX is actually the "minimum" maximum (see fs/exec.c). 59 "ARG_MAX": "_KERNEL_ARG_MAX", 60 # The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>. 61 "__unused": "__linux_unused", 62 # The kernel usage of C++ keywords causes problems for C++ code so rename. 63 "private": "__linux_private", 64 "virtual": "__linux_virtual", 65 # The non-64 stuff is legacy; msqid64_ds/ipc64_perm is what userspace wants. 66 "msqid_ds": "__kernel_legacy_msqid_ds", 67 "semid_ds": "__kernel_legacy_semid_ds", 68 "shmid_ds": "__kernel_legacy_shmid_ds", 69 "ipc_perm": "__kernel_legacy_ipc_perm", 70 # The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside. 71 "_NSIG": "_KERNEL__NSIG", 72 "NSIG": "_KERNEL_NSIG", 73 # The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few. 74 "SIGRTMIN": "__SIGRTMIN", 75 "SIGRTMAX": "__SIGRTMAX", 76 # We want to support both BSD and Linux member names in struct udphdr. 77 "udphdr": "__kernel_udphdr", 78 # The kernel's struct epoll_event just has __u64 for the data. 79 "epoll_event": "__kernel_uapi_epoll_event", 80 } 81 82# this is the set of known static inline functions that we want to keep 83# in the final ARM headers. this is only used to keep optimized byteswapping 84# static functions and stuff like that. 85# TODO: this isn't working! 86kernel_known_arm_statics = set( 87 [ "___arch__swab32", # asm-arm/byteorder.h 88 ] 89 ) 90 91kernel_known_arm64_statics = set( 92 [ 93 ] 94 ) 95 96kernel_known_mips_statics = set( 97 [ 98 ] 99 ) 100 101kernel_known_x86_statics = set( 102 [ "___arch__swab32", # asm-x86/byteorder.h 103 "___arch__swab64", # asm-x86/byteorder.h 104 ] 105 ) 106 107kernel_known_generic_statics = set( 108 [ 109 "ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h 110 "ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h 111 ] 112 ) 113 114# this maps an architecture to the set of static inline functions that 115# we want to keep in the final headers 116# 117kernel_known_statics = { 118 "arm" : kernel_known_arm_statics, 119 "arm64" : kernel_known_arm64_statics, 120 "mips" : kernel_known_mips_statics, 121 "x86" : kernel_known_x86_statics, 122 } 123 124# this is a list of macros which we want to specifically exclude from 125# the generated files. 126# 127kernel_ignored_macros = set( 128 [ 129 130 ] 131 ) 132 133# this is the standard disclaimer 134# 135kernel_disclaimer = """\ 136/**************************************************************************** 137 **************************************************************************** 138 *** 139 *** This header was automatically generated from a Linux kernel header 140 *** of the same name, to make information necessary for userspace to 141 *** call into the kernel available to libc. It contains only constants, 142 *** structures, and macros generated from the original header, and thus, 143 *** contains no copyrightable information. 144 *** 145 *** To edit the content of this header, modify the corresponding 146 *** source file (e.g. under external/kernel-headers/original/) then 147 *** run bionic/libc/kernel/tools/update_all.py 148 *** 149 *** Any manual change here will be lost the next time this script will 150 *** be run. You've been warned! 151 *** 152 **************************************************************************** 153 ****************************************************************************/ 154""" 155 156# This is the warning line that will be inserted every N-th line in the output 157kernel_warning = """\ 158/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 159""" 160