Update static functions/macro definitions.
Fix the list of static functions coming from swab.h to match the
ones exported by glibc.
Force the definition of __HAVE_BUILTIN_BSWAP{16,32,64}__ so the headers
use the builtin.
Add a unit test to guarantee that kernel header updates do not break this.
Test: Built and booted angler.
Test: Built the bionic unit tests for arm, arm64, mips, x86, x86_64.
Test: Ran the new test on angler and glibc.
Change-Id: I4ce229e3f198c204186d72bf22dd97b5cdf239e4
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index 620bb31..c22f684 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -26,6 +26,9 @@
"CONFIG_64BIT": "__LP64__",
"CONFIG_X86_32": "__i386__",
"__EXPORTED_HEADERS__": "1",
+ "__HAVE_BUILTIN_BSWAP16__": "1",
+ "__HAVE_BUILTIN_BSWAP32__": "1",
+ "__HAVE_BUILTIN_BSWAP64__": "1",
}
# define to true if you want to remove all defined(CONFIG_FOO) tests
@@ -77,14 +80,14 @@
"udphdr": "__kernel_udphdr",
# The kernel's struct epoll_event just has __u64 for the data.
"epoll_event": "__kernel_uapi_epoll_event",
+ # This causes problems when trying to export the headers for the ndk.
+ "__attribute_const__": "__attribute__((__const__))",
}
-# 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.
-# TODO: this isn't working!
+# This is the set of known static inline functions that we want to keep
+# in the final kernel headers.
kernel_known_arm_statics = set(
- [ "___arch__swab32", # asm-arm/byteorder.h
+ [
]
)
@@ -99,8 +102,7 @@
)
kernel_known_x86_statics = set(
- [ "___arch__swab32", # asm-x86/byteorder.h
- "___arch__swab64", # asm-x86/byteorder.h
+ [
]
)
@@ -108,6 +110,26 @@
[
"ipt_get_target", # uapi/linux/netfilter_ipv4/ip_tables.h
"ip6t_get_target", # uapi/linux/netfilter_ipv6/ip6_tables.h
+ # Byte swapping inlines from uapi/linux/swab.h
+ # The below functions are the ones we are guaranting we export.
+ "__swab16",
+ "__swab32",
+ "__swab64",
+ "__swab16p",
+ "__swab32p",
+ "__swab64p",
+ "__swab16s",
+ "__swab32s",
+ "__swab64s",
+ "__swahw32",
+ "__swahb32",
+ "__swahw32p",
+ "__swahb32p",
+ "__swahw32s",
+ "__swahb32s",
+ # These are required to support the above functions.
+ "__fswahw32",
+ "__fswahb32",
]
)