2008-10-21 16:00:00 +02:00
|
|
|
# this module contains all the defaults used by the generation of cleaned-up headers
|
|
|
|
# for the Bionic C library
|
|
|
|
#
|
|
|
|
|
|
|
|
import time, os, sys
|
|
|
|
from utils import *
|
|
|
|
|
|
|
|
# the list of supported architectures
|
2014-01-22 04:50:58 +01:00
|
|
|
kernel_archs = [ 'arm', 'arm64', 'mips', 'x86' ]
|
2008-10-21 16:00:00 +02:00
|
|
|
|
|
|
|
# the list of include directories that belong to the kernel
|
|
|
|
# tree. used when looking for sources...
|
|
|
|
kernel_dirs = [ "linux", "asm", "asm-generic", "mtd" ]
|
|
|
|
|
|
|
|
# a special value that is used to indicate that a given macro is known to be
|
|
|
|
# undefined during optimization
|
|
|
|
kCppUndefinedMacro = "<<<undefined>>>"
|
|
|
|
|
|
|
|
# this is the set of known macros we want to totally optimize out from the
|
|
|
|
# final headers
|
|
|
|
kernel_known_macros = {
|
|
|
|
"__KERNEL__": kCppUndefinedMacro,
|
|
|
|
"__KERNEL_STRICT_NAMES":"1",
|
|
|
|
"__CHECKER__": kCppUndefinedMacro,
|
|
|
|
"__CHECK_ENDIAN__": kCppUndefinedMacro,
|
2014-04-08 19:15:06 +02:00
|
|
|
"CONFIG_64BIT": "__LP64__",
|
2013-10-01 02:41:08 +02:00
|
|
|
"CONFIG_X86_32": "__i386__",
|
2013-10-23 23:38:25 +02:00
|
|
|
"__EXPORTED_HEADERS__": "1",
|
2008-10-21 16:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# define to true if you want to remove all defined(CONFIG_FOO) tests
|
|
|
|
# from the clean headers. testing shows that this is not strictly necessary
|
|
|
|
# but just generates cleaner results
|
|
|
|
kernel_remove_config_macros = True
|
|
|
|
|
2008-12-18 03:03:48 +01:00
|
|
|
# maps an architecture to a set of default macros that would be provided by
|
|
|
|
# toolchain preprocessor
|
|
|
|
kernel_default_arch_macros = {
|
2014-05-15 21:01:11 +02:00
|
|
|
"arm": {"__ARMEB__": kCppUndefinedMacro, "__ARM_EABI__": "1"},
|
2014-01-22 04:50:58 +01:00
|
|
|
"arm64": {},
|
2014-06-19 23:38:07 +02:00
|
|
|
"mips": {"__MIPSEB__": kCppUndefinedMacro,
|
|
|
|
"__MIPSEL__": "1",
|
|
|
|
"CONFIG_32BIT": "_ABIO32",
|
|
|
|
"CONFIG_CPU_LITTLE_ENDIAN": "1",
|
|
|
|
"__SANE_USERSPACE_TYPES__": "1",},
|
2013-10-01 02:41:08 +02:00
|
|
|
"x86": {},
|
2008-12-18 03:03:48 +01:00
|
|
|
}
|
|
|
|
|
2013-01-17 01:42:47 +01:00
|
|
|
kernel_arch_token_replacements = {
|
|
|
|
"arm": {},
|
2014-01-22 04:50:58 +01:00
|
|
|
"arm64": {},
|
2013-01-17 01:42:47 +01:00
|
|
|
"mips": {"off_t":"__kernel_off_t"},
|
2013-10-01 02:41:08 +02:00
|
|
|
"x86": {},
|
2013-01-17 01:42:47 +01:00
|
|
|
}
|
2014-02-12 05:01:11 +01:00
|
|
|
|
2016-08-11 00:51:06 +02:00
|
|
|
# Replace tokens in the output according to this mapping.
|
2010-12-08 11:39:05 +01:00
|
|
|
kernel_token_replacements = {
|
2016-08-11 00:51:06 +02:00
|
|
|
# The kernel's ARG_MAX is actually the "minimum" maximum (see fs/exec.c).
|
|
|
|
"ARG_MAX": "_KERNEL_ARG_MAX",
|
2014-02-12 05:01:11 +01:00
|
|
|
# The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>.
|
|
|
|
"__unused": "__linux_unused",
|
2016-08-17 03:14:26 +02:00
|
|
|
# The non-64 stuff is legacy; msqid64_ds/ipc64_perm is what userspace wants.
|
|
|
|
"msqid_ds": "__kernel_legacy_msqid_ds",
|
|
|
|
"semid_ds": "__kernel_legacy_semid_ds",
|
|
|
|
"shmid_ds": "__kernel_legacy_shmid_ds",
|
|
|
|
"ipc_perm": "__kernel_legacy_ipc_perm",
|
2014-02-12 05:01:11 +01:00
|
|
|
# The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside.
|
|
|
|
"_NSIG": "_KERNEL__NSIG",
|
|
|
|
"NSIG": "_KERNEL_NSIG",
|
2014-04-30 18:45:40 +02:00
|
|
|
# The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few.
|
|
|
|
"SIGRTMIN": "__SIGRTMIN",
|
|
|
|
"SIGRTMAX": "__SIGRTMAX",
|
2015-09-22 21:34:13 +02:00
|
|
|
# We want to support both BSD and Linux member names in struct udphdr.
|
|
|
|
"udphdr": "__kernel_udphdr",
|
2010-12-08 11:39:05 +01:00
|
|
|
}
|
|
|
|
|
2008-10-21 16:00:00 +02:00
|
|
|
# this is the set of known static inline functions that we want to keep
|
|
|
|
# in the final ARM headers. this is only used to keep optimized byteswapping
|
|
|
|
# static functions and stuff like that.
|
2014-04-08 19:15:06 +02:00
|
|
|
# TODO: this isn't working!
|
2014-01-22 04:50:58 +01:00
|
|
|
kernel_known_arm_statics = set(
|
|
|
|
[ "___arch__swab32", # asm-arm/byteorder.h
|
2013-10-17 00:28:56 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2014-01-22 04:50:58 +01:00
|
|
|
kernel_known_arm64_statics = set(
|
|
|
|
[
|
2008-10-21 16:00:00 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2012-03-27 20:37:17 +02:00
|
|
|
kernel_known_mips_statics = set(
|
|
|
|
[
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2013-10-01 02:41:08 +02:00
|
|
|
kernel_known_x86_statics = set(
|
|
|
|
[ "___arch__swab32", # asm-x86/byteorder.h
|
|
|
|
"___arch__swab64", # asm-x86/byteorder.h
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2008-10-21 16:00:00 +02:00
|
|
|
kernel_known_generic_statics = set(
|
2014-04-08 19:15:06 +02:00
|
|
|
[
|
|
|
|
"ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h
|
|
|
|
"ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h
|
2008-10-21 16:00:00 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
# this maps an architecture to the set of static inline functions that
|
|
|
|
# we want to keep in the final headers
|
|
|
|
#
|
|
|
|
kernel_known_statics = {
|
|
|
|
"arm" : kernel_known_arm_statics,
|
2014-01-22 04:50:58 +01:00
|
|
|
"arm64" : kernel_known_arm64_statics,
|
2013-10-01 02:41:08 +02:00
|
|
|
"mips" : kernel_known_mips_statics,
|
2009-07-01 08:41:52 +02:00
|
|
|
"x86" : kernel_known_x86_statics,
|
2008-10-21 16:00:00 +02:00
|
|
|
}
|
|
|
|
|
2009-01-10 02:50:54 +01:00
|
|
|
# this is a list of macros which we want to specifically exclude from
|
|
|
|
# the generated files.
|
|
|
|
#
|
|
|
|
kernel_ignored_macros = set(
|
2015-02-09 22:58:28 +01:00
|
|
|
[
|
|
|
|
|
2009-01-10 02:50:54 +01:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2008-10-21 16:00:00 +02:00
|
|
|
# this is the standard disclaimer
|
|
|
|
#
|
|
|
|
kernel_disclaimer = """\
|
|
|
|
/****************************************************************************
|
|
|
|
****************************************************************************
|
|
|
|
***
|
|
|
|
*** This header was automatically generated from a Linux kernel header
|
|
|
|
*** of the same name, to make information necessary for userspace to
|
|
|
|
*** call into the kernel available to libc. It contains only constants,
|
|
|
|
*** structures, and macros generated from the original header, and thus,
|
|
|
|
*** contains no copyrightable information.
|
|
|
|
***
|
2010-10-11 22:11:06 +02:00
|
|
|
*** To edit the content of this header, modify the corresponding
|
|
|
|
*** source file (e.g. under external/kernel-headers/original/) then
|
|
|
|
*** run bionic/libc/kernel/tools/update_all.py
|
|
|
|
***
|
|
|
|
*** Any manual change here will be lost the next time this script will
|
|
|
|
*** be run. You've been warned!
|
|
|
|
***
|
2008-10-21 16:00:00 +02:00
|
|
|
****************************************************************************
|
|
|
|
****************************************************************************/
|
|
|
|
"""
|
2010-10-11 22:11:06 +02:00
|
|
|
|
|
|
|
# This is the warning line that will be inserted every N-th line in the output
|
|
|
|
kernel_warning = """\
|
|
|
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
|
|
|
"""
|