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 9# 10kernel_archs = [ 'arm', 'x86', 'mips' ] 11 12# the list of include directories that belong to the kernel 13# tree. used when looking for sources... 14# 15kernel_dirs = [ "linux", "asm", "asm-generic", "mtd" ] 16 17# path to the directory containing the original kernel headers 18# 19kernel_original_path = os.path.normpath( find_program_dir() + '/../../../../external/kernel-headers/original' ) 20 21# path to the default location of the cleaned-up headers 22# 23kernel_cleaned_path = os.path.normpath( find_program_dir() + '/..' ) 24 25# a special value that is used to indicate that a given macro is known to be 26# undefined during optimization 27kCppUndefinedMacro = "<<<undefined>>>" 28 29# this is the set of known macros we want to totally optimize out from the 30# final headers 31kernel_known_macros = { 32 "__KERNEL__": kCppUndefinedMacro, 33 "__KERNEL_STRICT_NAMES":"1", 34 "__CHECKER__": kCppUndefinedMacro, 35 "__CHECK_ENDIAN__": kCppUndefinedMacro, 36 } 37 38# define to true if you want to remove all defined(CONFIG_FOO) tests 39# from the clean headers. testing shows that this is not strictly necessary 40# but just generates cleaner results 41kernel_remove_config_macros = True 42 43# maps an architecture to a set of default macros that would be provided by 44# toolchain preprocessor 45kernel_default_arch_macros = { 46 "arm": {}, 47 "x86": {"__i386__": "1", "CONFIG_X86_32": "1"}, 48 "mips": {"CONFIG_32BIT":"1"}, 49 } 50 51kernel_arch_token_replacements = { 52 "arm": {}, 53 "x86": {}, 54 "mips": {"off_t":"__kernel_off_t"}, 55 } 56# Replace tokens in the output according to this mapping 57kernel_token_replacements = { 58 "asm": "__asm__", 59 "__unused": "__linux_unused", # The kernel usage of __unused conflicts with the macro defined in sys/cdefs.h 60 } 61 62# this is the set of known static inline functions that we want to keep 63# in the final ARM headers. this is only used to keep optimized byteswapping 64# static functions and stuff like that. 65kernel_known_arm_statics = set( 66 [ "___arch__swab32", # asm-arm/byteorder.h 67 ] 68 ) 69 70kernel_known_x86_statics = set( 71 [ "___arch__swab32", # asm-x86/byteorder.h 72 "___arch__swab64", # asm-x86/byteorder.h 73 ] 74 ) 75 76kernel_known_mips_statics = set( 77 [ 78 ] 79 ) 80 81kernel_known_generic_statics = set( 82 [ "__invalid_size_argument_for_IOC", # asm-generic/ioctl.h 83 "__cmsg_nxthdr", # linux/socket.h 84 "cmsg_nxthdr", # linux/socket.h 85 "ipt_get_target", 86 "ip6t_get_target", 87 ] 88 ) 89 90# this maps an architecture to the set of static inline functions that 91# we want to keep in the final headers 92# 93kernel_known_statics = { 94 "arm" : kernel_known_arm_statics, 95 "x86" : kernel_known_x86_statics, 96 "mips" : kernel_known_mips_statics 97 } 98 99# this is a list of macros which we want to specifically exclude from 100# the generated files. 101# 102kernel_ignored_macros = set( 103 [ "MAXHOSTNAMELEN", # for some reason, Linux defines it to 64 104 # while most of the BSD code expects this to be 256 105 # so ignore the kernel-provided definition and 106 # define it in the Bionic headers instead 107 ] 108 ) 109 110# this is the standard disclaimer 111# 112kernel_disclaimer = """\ 113/**************************************************************************** 114 **************************************************************************** 115 *** 116 *** This header was automatically generated from a Linux kernel header 117 *** of the same name, to make information necessary for userspace to 118 *** call into the kernel available to libc. It contains only constants, 119 *** structures, and macros generated from the original header, and thus, 120 *** contains no copyrightable information. 121 *** 122 *** To edit the content of this header, modify the corresponding 123 *** source file (e.g. under external/kernel-headers/original/) then 124 *** run bionic/libc/kernel/tools/update_all.py 125 *** 126 *** Any manual change here will be lost the next time this script will 127 *** be run. You've been warned! 128 *** 129 **************************************************************************** 130 ****************************************************************************/ 131""" 132 133# This is the warning line that will be inserted every N-th line in the output 134kernel_warning = """\ 135/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 136""" 137