Add support for removing structs that cross blocks.
The latest kernel has a struct that needs to be removed,
but the struct crosses blocks. Add support for removing a
struct that does cross blocks. This support is very primitive,
and will not parse any really complicated struct that uses
defines in complicated ways.
Combine the kernel_structs_to_remove and kernel_struct_replacements
structure into a single map. This allows marking a structure
to be removed as replaced with an #include <bits/STRUCT.h>.
The new support for the remove of structures is all in the
removeStructs function.
Raise an exception if the struct parsing does not work properly.
Add new unit tests for all of the new code.
In addition, fix the algorithm for deleting the uapi directory
before it gets updated. A new file BUILD was checking in that
directory, so delete everything in the directory except that
BUILD file.
Test: Unit tests pass.
Test: Running update_all.py results in the no unexpected changes.
Change-Id: I9a8cef0321beaf71d03b5b874327747a7edb6119
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index 2089285..99bbc3e 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -35,16 +35,23 @@
"__kernel_old_timeval": "1",
}
-# this is the set of known kernel data structures we want to remove from
-# the final headers
-kernel_structs_to_remove = set(
- [
- # Remove the structures since they are still the same as
- # timeval, itimerval.
- "__kernel_old_timeval",
- "__kernel_old_itimerval",
- ]
- )
+# This is the set of known kernel data structures we want to remove from
+# the final headers. If the map value is False, that means that in
+# addition to removing the structure, add an #include <bits/STRUCT.h>
+# to the file.
+kernel_structs_to_remove = {
+ # Remove the structures since they are still the same as
+ # timeval, itimerval.
+ "__kernel_old_timeval": True,
+ "__kernel_old_itimerval": True,
+ # Replace all of the below structures with #include <bits/STRUCT.h>
+ "epoll_event": False,
+ "flock": False,
+ "flock64": False,
+ "in_addr": False,
+ "ip_mreq_source": False,
+ "ip_msfilter": False,
+ }
# 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
@@ -100,20 +107,6 @@
}
-# This is the set of struct definitions that we want to replace with
-# a #include of <bits/struct.h> instead.
-kernel_struct_replacements = set(
- [
- "epoll_event",
- "flock",
- "flock64",
- "in_addr",
- "ip_mreq_source",
- "ip_msfilter",
- ]
- )
-
-
# This is the set of known static inline functions that we want to keep
# in the final kernel headers.
kernel_known_generic_statics = set(