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# path to the directory containing the original kernel headers 16kernel_original_path = os.path.normpath( find_program_dir() + '/../../../../external/kernel-headers/original' ) 17 18# path to the default location of the cleaned-up headers 19kernel_cleaned_path = os.path.normpath( find_program_dir() + '/..' ) 20 21# a special value that is used to indicate that a given macro is known to be 22# undefined during optimization 23kCppUndefinedMacro = "<<<undefined>>>" 24 25# this is the set of known macros we want to totally optimize out from the 26# final headers 27kernel_known_macros = { 28 "__KERNEL__": kCppUndefinedMacro, 29 "__KERNEL_STRICT_NAMES":"1", 30 "__CHECKER__": kCppUndefinedMacro, 31 "__CHECK_ENDIAN__": kCppUndefinedMacro, 32 "CONFIG_64BIT": "__LP64__", 33 "CONFIG_X86_32": "__i386__", 34 "__EXPORTED_HEADERS__": "1", 35 } 36 37# define to true if you want to remove all defined(CONFIG_FOO) tests 38# from the clean headers. testing shows that this is not strictly necessary 39# but just generates cleaner results 40kernel_remove_config_macros = True 41 42# maps an architecture to a set of default macros that would be provided by 43# toolchain preprocessor 44kernel_default_arch_macros = { 45 "arm": {"__ARMEB__": kCppUndefinedMacro, "__ARM_EABI__": "1"}, 46 "arm64": {}, 47 "mips": {"__MIPSEB__": kCppUndefinedMacro, 48 "__MIPSEL__": "1", 49 "CONFIG_32BIT": "_ABIO32", 50 "CONFIG_CPU_LITTLE_ENDIAN": "1", 51 "__SANE_USERSPACE_TYPES__": "1",}, 52 "x86": {}, 53 } 54 55kernel_arch_token_replacements = { 56 "arm": {}, 57 "arm64": {}, 58 "mips": {"off_t":"__kernel_off_t"}, 59 "x86": {}, 60 } 61 62# Replace tokens in the output according to this mapping 63kernel_token_replacements = { 64 "asm": "__asm__", 65 # The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>. 66 "__unused": "__linux_unused", 67 # The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside. 68 "_NSIG": "_KERNEL__NSIG", 69 "NSIG": "_KERNEL_NSIG", 70 # The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few. 71 "SIGRTMIN": "__SIGRTMIN", 72 "SIGRTMAX": "__SIGRTMAX", 73 } 74 75# this is the set of known static inline functions that we want to keep 76# in the final ARM headers. this is only used to keep optimized byteswapping 77# static functions and stuff like that. 78# TODO: this isn't working! 79kernel_known_arm_statics = set( 80 [ "___arch__swab32", # asm-arm/byteorder.h 81 ] 82 ) 83 84kernel_known_arm64_statics = set( 85 [ 86 ] 87 ) 88 89kernel_known_mips_statics = set( 90 [ 91 ] 92 ) 93 94kernel_known_x86_statics = set( 95 [ "___arch__swab32", # asm-x86/byteorder.h 96 "___arch__swab64", # asm-x86/byteorder.h 97 ] 98 ) 99 100kernel_known_generic_statics = set( 101 [ 102 "ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h 103 "ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h 104 ] 105 ) 106 107# this maps an architecture to the set of static inline functions that 108# we want to keep in the final headers 109# 110kernel_known_statics = { 111 "arm" : kernel_known_arm_statics, 112 "arm64" : kernel_known_arm64_statics, 113 "mips" : kernel_known_mips_statics, 114 "x86" : kernel_known_x86_statics, 115 } 116 117# this is a list of macros which we want to specifically exclude from 118# the generated files. 119# 120kernel_ignored_macros = set( 121 [ 122 123 ] 124 ) 125 126# this is the standard disclaimer 127# 128kernel_disclaimer = """\ 129/**************************************************************************** 130 **************************************************************************** 131 *** 132 *** This header was automatically generated from a Linux kernel header 133 *** of the same name, to make information necessary for userspace to 134 *** call into the kernel available to libc. It contains only constants, 135 *** structures, and macros generated from the original header, and thus, 136 *** contains no copyrightable information. 137 *** 138 *** To edit the content of this header, modify the corresponding 139 *** source file (e.g. under external/kernel-headers/original/) then 140 *** run bionic/libc/kernel/tools/update_all.py 141 *** 142 *** Any manual change here will be lost the next time this script will 143 *** be run. You've been warned! 144 *** 145 **************************************************************************** 146 ****************************************************************************/ 147""" 148 149# This is the warning line that will be inserted every N-th line in the output 150kernel_warning = """\ 151/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 152""" 153