defaults.py revision 6d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dc
1a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# this module contains all the defaults used by the generation of cleaned-up headers 2a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# for the Bionic C library 3a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# 4a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 5a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectimport time, os, sys 6a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectfrom utils import * 7a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 8a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# the list of supported architectures 9a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# 10a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_archs = [ 'arm', 'x86' ] 11a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 12a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# the list of include directories that belong to the kernel 13a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# tree. used when looking for sources... 14a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# 15a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_dirs = [ "linux", "asm", "asm-generic", "mtd" ] 16a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 17a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# path to the directory containing the original kernel headers 18a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# 19a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_original_path = os.path.normpath( find_program_dir() + '/../original' ) 20a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 21a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# a special value that is used to indicate that a given macro is known to be 22a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# undefined during optimization 23a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source ProjectkCppUndefinedMacro = "<<<undefined>>>" 24a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 25a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# this is the set of known macros we want to totally optimize out from the 26a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# final headers 27a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_known_macros = { 28a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "__KERNEL__": kCppUndefinedMacro, 29a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "__KERNEL_STRICT_NAMES":"1", 30a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "__CHECKER__": kCppUndefinedMacro, 31a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "__CHECK_ENDIAN__": kCppUndefinedMacro, 32a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project } 33a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 34a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# define to true if you want to remove all defined(CONFIG_FOO) tests 35a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# from the clean headers. testing shows that this is not strictly necessary 36a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# but just generates cleaner results 37a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_remove_config_macros = True 38a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 394e468ed2eb86a2406e14f1eca82072ee501d05fdThe Android Open Source Project# maps an architecture to a set of default macros that would be provided by 404e468ed2eb86a2406e14f1eca82072ee501d05fdThe Android Open Source Project# toolchain preprocessor 414e468ed2eb86a2406e14f1eca82072ee501d05fdThe Android Open Source Projectkernel_default_arch_macros = { 424e468ed2eb86a2406e14f1eca82072ee501d05fdThe Android Open Source Project "arm": {}, 434e468ed2eb86a2406e14f1eca82072ee501d05fdThe Android Open Source Project "x86": {"__i386__": "1"}, 444e468ed2eb86a2406e14f1eca82072ee501d05fdThe Android Open Source Project } 454e468ed2eb86a2406e14f1eca82072ee501d05fdThe Android Open Source Project 46a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# this is the set of known static inline functions that we want to keep 47a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# in the final ARM headers. this is only used to keep optimized byteswapping 48a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# static functions and stuff like that. 49a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_known_arm_statics = set( 50a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project [ "___arch__swab32", # asm-arm/byteorder.h 51a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project ] 52a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project ) 53a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 54a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_known_x86_statics = set( 55a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project [ "___arch__swab32", # asm-x86/byteorder.h 56a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "___arch__swab64", # asm-x86/byteorder.h 57a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project ] 58a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project ) 59a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 60a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_known_generic_statics = set( 61a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project [ "__invalid_size_argument_for_IOC", # asm-generic/ioctl.h 62a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "__cmsg_nxthdr", # linux/socket.h 63a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "cmsg_nxthdr", # linux/socket.h 64a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "ipt_get_target", 65a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project ] 66a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project ) 67a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 68a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# this maps an architecture to the set of static inline functions that 69a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# we want to keep in the final headers 70a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# 71a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_known_statics = { 72a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "arm" : kernel_known_arm_statics, 73a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project "x86" : kernel_known_x86_statics 74a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project } 75a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project 766d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project# this is a list of macros which we want to specifically exclude from 776d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project# the generated files. 786d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project# 796d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Projectkernel_ignored_macros = set( 806d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project [ "MAXHOSTNAMELEN", # for some reason, Linux defines it to 64 816d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project # while most of the BSD code expects this to be 256 826d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project # so ignore the kernel-provided definition and 836d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project # define it in the Bionic headers instead 846d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project ] 856d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project ) 866d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dcThe Android Open Source Project 87a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# this is the standard disclaimer 88a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project# 89a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Projectkernel_disclaimer = """\ 90a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project/**************************************************************************** 91a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project **************************************************************************** 92a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project *** 93a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project *** This header was automatically generated from a Linux kernel header 94a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project *** of the same name, to make information necessary for userspace to 95a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project *** call into the kernel available to libc. It contains only constants, 96a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project *** structures, and macros generated from the original header, and thus, 97a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project *** contains no copyrightable information. 98a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project *** 99a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project **************************************************************************** 100a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project ****************************************************************************/ 101a27d2baa0c1a2ec70f47ea9199b1dd6762c8a34The Android Open Source Project""" 102