blob: 3968605837783a74bd5174077445318d0231e397 [file] [log] [blame]
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -07001# 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#
Ben Cheng8bea2b62013-10-16 15:28:56 -070010kernel_archs = [ 'aarch64', 'arm', 'mips', 'x86' ]
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070011
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#
David 'Digit' Turnerfc269312010-10-11 22:11:06 +020019kernel_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() + '/..' )
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070024
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,
Elliott Hughesd3e64a32013-09-30 17:41:08 -070036 "CONFIG_X86_32": "__i386__",
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070037 }
38
39# define to true if you want to remove all defined(CONFIG_FOO) tests
40# from the clean headers. testing shows that this is not strictly necessary
41# but just generates cleaner results
42kernel_remove_config_macros = True
43
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080044# maps an architecture to a set of default macros that would be provided by
45# toolchain preprocessor
46kernel_default_arch_macros = {
Ben Cheng8bea2b62013-10-16 15:28:56 -070047 "aarch64": {},
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080048 "arm": {},
Raghu Gandham988ff8f2012-09-21 17:13:25 -070049 "mips": {"CONFIG_32BIT":"1"},
Elliott Hughesd3e64a32013-09-30 17:41:08 -070050 "x86": {},
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080051 }
52
Raghu Gandhama864c2c2013-01-16 16:42:47 -080053kernel_arch_token_replacements = {
Ben Cheng8bea2b62013-10-16 15:28:56 -070054 "aarch64": {},
Raghu Gandhama864c2c2013-01-16 16:42:47 -080055 "arm": {},
Raghu Gandhama864c2c2013-01-16 16:42:47 -080056 "mips": {"off_t":"__kernel_off_t"},
Elliott Hughesd3e64a32013-09-30 17:41:08 -070057 "x86": {},
Raghu Gandhama864c2c2013-01-16 16:42:47 -080058 }
Martin Storsjoc9205db2010-12-08 11:39:05 +010059# Replace tokens in the output according to this mapping
60kernel_token_replacements = {
David 'Digit' Turnerb969b5a2011-01-11 17:23:10 +010061 "asm": "__asm__",
Raghu Gandham0e772872012-09-25 17:49:17 -070062 "__unused": "__linux_unused", # The kernel usage of __unused conflicts with the macro defined in sys/cdefs.h
Martin Storsjoc9205db2010-12-08 11:39:05 +010063 }
64
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070065# this is the set of known static inline functions that we want to keep
66# in the final ARM headers. this is only used to keep optimized byteswapping
67# static functions and stuff like that.
Ben Cheng8bea2b62013-10-16 15:28:56 -070068kernel_known_aarch64_statics = set(
69 [
70 ]
71 )
72
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070073kernel_known_arm_statics = set(
Elliott Hughesd3e64a32013-09-30 17:41:08 -070074 [ "___arch__swab32", # asm-arm/byteorder.h
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070075 ]
76 )
77
Raghu Gandham82fa43f2012-03-27 11:37:17 -070078kernel_known_mips_statics = set(
79 [
80 ]
81 )
82
Elliott Hughesd3e64a32013-09-30 17:41:08 -070083kernel_known_x86_statics = set(
84 [ "___arch__swab32", # asm-x86/byteorder.h
85 "___arch__swab64", # asm-x86/byteorder.h
86 ]
87 )
88
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070089kernel_known_generic_statics = set(
90 [ "__invalid_size_argument_for_IOC", # asm-generic/ioctl.h
91 "__cmsg_nxthdr", # linux/socket.h
92 "cmsg_nxthdr", # linux/socket.h
93 "ipt_get_target",
Vilmos Nebehajc1a534b2010-06-28 15:13:23 +020094 "ip6t_get_target",
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070095 ]
96 )
97
98# this maps an architecture to the set of static inline functions that
99# we want to keep in the final headers
100#
101kernel_known_statics = {
Ben Cheng8bea2b62013-10-16 15:28:56 -0700102 "aarch64" : kernel_known_aarch64_statics,
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700103 "arm" : kernel_known_arm_statics,
Elliott Hughesd3e64a32013-09-30 17:41:08 -0700104 "mips" : kernel_known_mips_statics,
Shin-ichiro KAWASAKI37429ff2009-07-01 15:41:52 +0900105 "x86" : kernel_known_x86_statics,
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700106 }
107
The Android Open Source Project6d6c82c2009-01-09 17:50:54 -0800108# this is a list of macros which we want to specifically exclude from
109# the generated files.
110#
111kernel_ignored_macros = set(
112 [ "MAXHOSTNAMELEN", # for some reason, Linux defines it to 64
113 # while most of the BSD code expects this to be 256
114 # so ignore the kernel-provided definition and
115 # define it in the Bionic headers instead
116 ]
117 )
118
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700119# this is the standard disclaimer
120#
121kernel_disclaimer = """\
122/****************************************************************************
123 ****************************************************************************
124 ***
125 *** This header was automatically generated from a Linux kernel header
126 *** of the same name, to make information necessary for userspace to
127 *** call into the kernel available to libc. It contains only constants,
128 *** structures, and macros generated from the original header, and thus,
129 *** contains no copyrightable information.
130 ***
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200131 *** To edit the content of this header, modify the corresponding
132 *** source file (e.g. under external/kernel-headers/original/) then
133 *** run bionic/libc/kernel/tools/update_all.py
134 ***
135 *** Any manual change here will be lost the next time this script will
136 *** be run. You've been warned!
137 ***
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700138 ****************************************************************************
139 ****************************************************************************/
140"""
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200141
142# This is the warning line that will be inserted every N-th line in the output
143kernel_warning = """\
144/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
145"""