blob: 87adcd00f824d7982b5a2cf312367cb00e61226e [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
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070015# a special value that is used to indicate that a given macro is known to be
16# undefined during optimization
17kCppUndefinedMacro = "<<<undefined>>>"
18
19# this is the set of known macros we want to totally optimize out from the
20# final headers
21kernel_known_macros = {
22 "__KERNEL__": kCppUndefinedMacro,
23 "__KERNEL_STRICT_NAMES":"1",
24 "__CHECKER__": kCppUndefinedMacro,
25 "__CHECK_ENDIAN__": kCppUndefinedMacro,
Elliott Hughes9195a252014-04-08 10:15:06 -070026 "CONFIG_64BIT": "__LP64__",
Elliott Hughesd3e64a32013-09-30 17:41:08 -070027 "CONFIG_X86_32": "__i386__",
Ben Cheng460fa702013-10-23 14:38:25 -070028 "__EXPORTED_HEADERS__": "1",
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070029 }
30
31# define to true if you want to remove all defined(CONFIG_FOO) tests
32# from the clean headers. testing shows that this is not strictly necessary
33# but just generates cleaner results
34kernel_remove_config_macros = True
35
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080036# maps an architecture to a set of default macros that would be provided by
37# toolchain preprocessor
38kernel_default_arch_macros = {
Elliott Hughes8ed7a232014-05-15 12:01:11 -070039 "arm": {"__ARMEB__": kCppUndefinedMacro, "__ARM_EABI__": "1"},
Colin Crossd1973ca2014-01-21 19:50:58 -080040 "arm64": {},
Duane Sanda69eaec2014-06-19 14:38:07 -070041 "mips": {"__MIPSEB__": kCppUndefinedMacro,
42 "__MIPSEL__": "1",
43 "CONFIG_32BIT": "_ABIO32",
44 "CONFIG_CPU_LITTLE_ENDIAN": "1",
45 "__SANE_USERSPACE_TYPES__": "1",},
Elliott Hughesd3e64a32013-09-30 17:41:08 -070046 "x86": {},
The Android Open Source Project4e468ed2008-12-17 18:03:48 -080047 }
48
Raghu Gandhama864c2c2013-01-16 16:42:47 -080049kernel_arch_token_replacements = {
50 "arm": {},
Colin Crossd1973ca2014-01-21 19:50:58 -080051 "arm64": {},
Raghu Gandhama864c2c2013-01-16 16:42:47 -080052 "mips": {"off_t":"__kernel_off_t"},
Elliott Hughesd3e64a32013-09-30 17:41:08 -070053 "x86": {},
Raghu Gandhama864c2c2013-01-16 16:42:47 -080054 }
Elliott Hughes199346a2014-02-11 20:01:11 -080055
Elliott Hughes38dba2e2016-08-10 15:51:06 -070056# Replace tokens in the output according to this mapping.
Martin Storsjoc9205db2010-12-08 11:39:05 +010057kernel_token_replacements = {
Elliott Hughes38dba2e2016-08-10 15:51:06 -070058 # The kernel's ARG_MAX is actually the "minimum" maximum (see fs/exec.c).
59 "ARG_MAX": "_KERNEL_ARG_MAX",
Elliott Hughes199346a2014-02-11 20:01:11 -080060 # The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>.
61 "__unused": "__linux_unused",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -070062 # The non-64 stuff is legacy; msqid64_ds/ipc64_perm is what userspace wants.
63 "msqid_ds": "__kernel_legacy_msqid_ds",
64 "semid_ds": "__kernel_legacy_semid_ds",
65 "shmid_ds": "__kernel_legacy_shmid_ds",
66 "ipc_perm": "__kernel_legacy_ipc_perm",
Elliott Hughes199346a2014-02-11 20:01:11 -080067 # 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",
Elliott Hughes0990d4f2014-04-30 09:45:40 -070070 # The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few.
71 "SIGRTMIN": "__SIGRTMIN",
72 "SIGRTMAX": "__SIGRTMAX",
Elliott Hughesf8a22432015-09-22 12:34:13 -070073 # We want to support both BSD and Linux member names in struct udphdr.
74 "udphdr": "__kernel_udphdr",
Martin Storsjoc9205db2010-12-08 11:39:05 +010075 }
76
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070077# this is the set of known static inline functions that we want to keep
78# in the final ARM headers. this is only used to keep optimized byteswapping
79# static functions and stuff like that.
Elliott Hughes9195a252014-04-08 10:15:06 -070080# TODO: this isn't working!
Colin Crossd1973ca2014-01-21 19:50:58 -080081kernel_known_arm_statics = set(
82 [ "___arch__swab32", # asm-arm/byteorder.h
Ben Cheng8bea2b62013-10-16 15:28:56 -070083 ]
84 )
85
Colin Crossd1973ca2014-01-21 19:50:58 -080086kernel_known_arm64_statics = set(
87 [
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070088 ]
89 )
90
Raghu Gandham82fa43f2012-03-27 11:37:17 -070091kernel_known_mips_statics = set(
92 [
93 ]
94 )
95
Elliott Hughesd3e64a32013-09-30 17:41:08 -070096kernel_known_x86_statics = set(
97 [ "___arch__swab32", # asm-x86/byteorder.h
98 "___arch__swab64", # asm-x86/byteorder.h
99 ]
100 )
101
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700102kernel_known_generic_statics = set(
Elliott Hughes9195a252014-04-08 10:15:06 -0700103 [
104 "ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h
105 "ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700106 ]
107 )
108
109# this maps an architecture to the set of static inline functions that
110# we want to keep in the final headers
111#
112kernel_known_statics = {
113 "arm" : kernel_known_arm_statics,
Colin Crossd1973ca2014-01-21 19:50:58 -0800114 "arm64" : kernel_known_arm64_statics,
Elliott Hughesd3e64a32013-09-30 17:41:08 -0700115 "mips" : kernel_known_mips_statics,
Shin-ichiro KAWASAKI37429ff2009-07-01 15:41:52 +0900116 "x86" : kernel_known_x86_statics,
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700117 }
118
The Android Open Source Project6d6c82c2009-01-09 17:50:54 -0800119# this is a list of macros which we want to specifically exclude from
120# the generated files.
121#
122kernel_ignored_macros = set(
Yabin Cui2d8f9b52015-02-09 13:58:28 -0800123 [
124
The Android Open Source Project6d6c82c2009-01-09 17:50:54 -0800125 ]
126 )
127
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700128# this is the standard disclaimer
129#
130kernel_disclaimer = """\
131/****************************************************************************
132 ****************************************************************************
133 ***
134 *** This header was automatically generated from a Linux kernel header
135 *** of the same name, to make information necessary for userspace to
136 *** call into the kernel available to libc. It contains only constants,
137 *** structures, and macros generated from the original header, and thus,
138 *** contains no copyrightable information.
139 ***
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200140 *** To edit the content of this header, modify the corresponding
141 *** source file (e.g. under external/kernel-headers/original/) then
142 *** run bionic/libc/kernel/tools/update_all.py
143 ***
144 *** Any manual change here will be lost the next time this script will
145 *** be run. You've been warned!
146 ***
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700147 ****************************************************************************
148 ****************************************************************************/
149"""
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200150
151# This is the warning line that will be inserted every N-th line in the output
152kernel_warning = """\
153/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
154"""