blob: b4d823e1d8bd335da5f44ada766dc24867584a26 [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
Colin Crossd1973ca2014-01-21 19:50:58 -08009kernel_archs = [ 'arm', 'arm64', 'mips', 'x86' ]
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070010
11# the list of include directories that belong to the kernel
12# tree. used when looking for sources...
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070013kernel_dirs = [ "linux", "asm", "asm-generic", "mtd" ]
14
15# path to the directory containing the original kernel headers
David 'Digit' Turnerfc269312010-10-11 22:11:06 +020016kernel_original_path = os.path.normpath( find_program_dir() + '/../../../../external/kernel-headers/original' )
17
18# path to the default location of the cleaned-up headers
David 'Digit' Turnerfc269312010-10-11 22:11:06 +020019kernel_cleaned_path = os.path.normpath( find_program_dir() + '/..' )
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070020
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,
Elliott Hughes9195a252014-04-08 10:15:06 -070032 "CONFIG_64BIT": "__LP64__",
Elliott Hughesd3e64a32013-09-30 17:41:08 -070033 "CONFIG_X86_32": "__i386__",
Ben Cheng460fa702013-10-23 14:38:25 -070034 "__EXPORTED_HEADERS__": "1",
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070035 }
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
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080042# maps an architecture to a set of default macros that would be provided by
43# toolchain preprocessor
44kernel_default_arch_macros = {
45 "arm": {},
Colin Crossd1973ca2014-01-21 19:50:58 -080046 "arm64": {},
Raghu Gandham988ff8f2012-09-21 17:13:25 -070047 "mips": {"CONFIG_32BIT":"1"},
Elliott Hughesd3e64a32013-09-30 17:41:08 -070048 "x86": {},
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080049 }
50
Raghu Gandhama864c2c2013-01-16 16:42:47 -080051kernel_arch_token_replacements = {
52 "arm": {},
Colin Crossd1973ca2014-01-21 19:50:58 -080053 "arm64": {},
Raghu Gandhama864c2c2013-01-16 16:42:47 -080054 "mips": {"off_t":"__kernel_off_t"},
Elliott Hughesd3e64a32013-09-30 17:41:08 -070055 "x86": {},
Raghu Gandhama864c2c2013-01-16 16:42:47 -080056 }
Elliott Hughes199346a2014-02-11 20:01:11 -080057
Martin Storsjoc9205db2010-12-08 11:39:05 +010058# Replace tokens in the output according to this mapping
59kernel_token_replacements = {
David 'Digit' Turnerb969b5a2011-01-11 17:23:10 +010060 "asm": "__asm__",
Elliott Hughes199346a2014-02-11 20:01:11 -080061 # The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>.
62 "__unused": "__linux_unused",
63 # The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside.
64 "_NSIG": "_KERNEL__NSIG",
65 "NSIG": "_KERNEL_NSIG",
Martin Storsjoc9205db2010-12-08 11:39:05 +010066 }
67
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070068# this is the set of known static inline functions that we want to keep
69# in the final ARM headers. this is only used to keep optimized byteswapping
70# static functions and stuff like that.
Elliott Hughes9195a252014-04-08 10:15:06 -070071# TODO: this isn't working!
Colin Crossd1973ca2014-01-21 19:50:58 -080072kernel_known_arm_statics = set(
73 [ "___arch__swab32", # asm-arm/byteorder.h
Ben Cheng8bea2b62013-10-16 15:28:56 -070074 ]
75 )
76
Colin Crossd1973ca2014-01-21 19:50:58 -080077kernel_known_arm64_statics = set(
78 [
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070079 ]
80 )
81
Raghu Gandham82fa43f2012-03-27 11:37:17 -070082kernel_known_mips_statics = set(
83 [
84 ]
85 )
86
Elliott Hughesd3e64a32013-09-30 17:41:08 -070087kernel_known_x86_statics = set(
88 [ "___arch__swab32", # asm-x86/byteorder.h
89 "___arch__swab64", # asm-x86/byteorder.h
90 ]
91 )
92
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070093kernel_known_generic_statics = set(
Elliott Hughes9195a252014-04-08 10:15:06 -070094 [
95 "ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h
96 "ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070097 ]
98 )
99
100# this maps an architecture to the set of static inline functions that
101# we want to keep in the final headers
102#
103kernel_known_statics = {
104 "arm" : kernel_known_arm_statics,
Colin Crossd1973ca2014-01-21 19:50:58 -0800105 "arm64" : kernel_known_arm64_statics,
Elliott Hughesd3e64a32013-09-30 17:41:08 -0700106 "mips" : kernel_known_mips_statics,
Shin-ichiro KAWASAKI37429ff2009-07-01 15:41:52 +0900107 "x86" : kernel_known_x86_statics,
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700108 }
109
The Android Open Source Project6d6c82c2009-01-09 17:50:54 -0800110# this is a list of macros which we want to specifically exclude from
111# the generated files.
112#
113kernel_ignored_macros = set(
114 [ "MAXHOSTNAMELEN", # for some reason, Linux defines it to 64
115 # while most of the BSD code expects this to be 256
116 # so ignore the kernel-provided definition and
117 # define it in the Bionic headers instead
118 ]
119 )
120
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700121# this is the standard disclaimer
122#
123kernel_disclaimer = """\
124/****************************************************************************
125 ****************************************************************************
126 ***
127 *** This header was automatically generated from a Linux kernel header
128 *** of the same name, to make information necessary for userspace to
129 *** call into the kernel available to libc. It contains only constants,
130 *** structures, and macros generated from the original header, and thus,
131 *** contains no copyrightable information.
132 ***
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200133 *** To edit the content of this header, modify the corresponding
134 *** source file (e.g. under external/kernel-headers/original/) then
135 *** run bionic/libc/kernel/tools/update_all.py
136 ***
137 *** Any manual change here will be lost the next time this script will
138 *** be run. You've been warned!
139 ***
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700140 ****************************************************************************
141 ****************************************************************************/
142"""
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200143
144# This is the warning line that will be inserted every N-th line in the output
145kernel_warning = """\
146/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
147"""