aboutsummaryrefslogtreecommitdiff
path: root/libc/kernel/tools
Commit message (Collapse)AuthorAgeFilesLines
* Define sockaddr_storage in bionicColin Cross2021-07-141-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Bionic currently renames the kernel's __kernel_sockaddr_storage to sockaddr_storage. We would like to reuse the bionic kernel headers for musl, but musl defines its own sockaddr_storage, causing redefinition errors when the musl and kernel headers are both included. Give bionic its own definition of sockaddr_storage so the kernel one can be left as __kernel_sockaddr_storage, avoiding the conflict in musl. Some of the structs in netinet/in.h contain sockaddr_storage members. There are definitions in linux/in.h, but they now use the __kernel_sockaddr_storage naming. To avoid having to copy the structs from linux/in.h into netinet/in.h, add some #define hackery to rename __kernel_sockaddr_storage to sockaddr_storage when including linux/in.h from netinet/in.h. Bug: 190084016 Test: m checkbuild Test: bionic-unit-tests Change-Id: I8f654511722b3a4a8e0bb146e4418ebcd370305c
* Merge "Support replacing nested kernel structs"Treehugger Robot2021-07-121-2/+7
|\
| * Support replacing nested kernel structsColin Cross2021-06-291-2/+7
| | | | | | | | | | | | | | | | When replacing structs with bits/ includes, count the number of opening and closing braces to find the end of the struct. Test: tools/update_all.py Change-Id: Ic9712a385da517710ceffccbdb223c89ae0b5f65
* | Update to v5.13 kernel headers.Christopher Ferris2021-07-011-1/+0
|/ | | | | | | | | | | Kernel headers coming from: Git: https://android.googlesource.com/kernel/common/ Branch: android-mainline Tag: android-mainline-5.13 Test: Builds, bionic unit tests. Change-Id: Ia4360ca4a2808206f64187dcb234d73c5752624b
* Merge "Fix last python3 issues."Christopher Ferris2021-04-211-5/+5
|\
| * Fix last python3 issues.Christopher Ferris2021-04-201-5/+5
| | | | | | | | | | | | | | | | | | | | Includes pointing to the python3 version of the clang bindings. Also, remove stale .gitignore line. Test: Ran bionic/libc/kernel/tools/update_all.py and verified Test: the files generated the same exact way. Change-Id: I4eb9dd7382bca013f70d921b6ef48c7e7478615a
* | Fix overly-zealous strip.Dan Albert2021-04-201-2/+2
|/ | | | | | | | | The argument to this is the characters to strip, so `line.strip(line)` just returns the empty string. Test: None? Bug: None Change-Id: I4f62bffcd00936e4eef837a28b78023fcad54bb0
* Update for python3.Christopher Ferris2021-04-195-46/+28
| | | | | | | | | | | | | This fixes all of the problems with our kernel scripts, but not the clang python script problems. I also removed the updateGitFiles function since that code was just silently failing any way. I replaced all calls with updateFiles. Test: Ran script using python2 to verify it still works. Test: Run script in python3 verifying that it starts to run. Change-Id: I223a31a8324c59e6bc4067f48a6110361b3e26e8
* Force everything to use python3 for consistency.Elliott Hughes2021-04-153-3/+3
| | | | | | | | | | Rather than "whatever people have installed as 'python' on their machine". I've removed check-symbols.py because that's been broken for years and we never even noticed, and I'm not sure it's worth fixing. Test: treehugger, manual Change-Id: Ieb996bbdf790a18d4b1fb46a409cc240ba2a2a49
* Clean up header files from kernel directory.Christopher Ferris2020-12-031-3/+11
| | | | | | | | | | | | Add a make distclean for each supported arch before generating headers and at the end so these files are not left hanging around in the kernel directory. Bug: 174795055 Test: Verified all generated files are deleted after running. Test: Verified this generates the exact same files as before this change. Change-Id: I0f66f580af2ea50c190eb532032017e782d7cae6
* More cleanup for #inclusivefixit.Elliott Hughes2020-07-311-1/+1
| | | | | | | Found manually with grep, since the script seems to miss stuff. Test: treehugger Change-Id: I5933cbade9792801d4a0bec1ccb077efa6ad8fbc
* Update the generate script.Christopher Ferris2020-06-041-5/+0
| | | | | | | | | | | | The arm kvm.h file has been deprecated, so nobody should be including it. Therefore, remove the hack to copy the file out of the tools directory. Also, update to remove the arm kvm.h file. Test: Ran generate and update script and verified only the arm kvm.h Test: was deleted. Test: Builds and boots on a walleye. Change-Id: I95dcc8877bdb2da2858b0b9d0aa95d1d2072cf9a
* Update to v5.7 kernel headers.Christopher Ferris2020-06-021-3/+3
| | | | | | | | | | | | | | | Kernel headers coming from: Git: https://android.googlesource.com/kernel/common/ Branch: android-mainline Tag: android-mainline-5.7 Update the generate_uapi_headers.sh where the types.h file is now in the right place, but kvm.h is not. Test: Booted cuttlefish/bonito. Test: Ran bionic-unit-tests on cuttlefish/bonito. Change-Id: Ice9ce370a658e320b80f564b34a4431927fcf100
* Update to v5.6 kernel headers.Christopher Ferris2020-04-103-7/+238
| | | | | | | | | | | | | | | | | | | | Kernel headers coming from: Git: https://android.googlesource.com/kernel/common/ Branch: android-mainline Tag: android-mainline-5.6 Add a new method for removing structures. This is to deal with the kernel headers changing some definitions of timeval to __kernel_old_timeval and itimerval to __kernel_old_itimerval. Remove the __kernel_old_XX strutures and change the other structures to the previous definitions. This only works so long as these structures stay the same, if they diverge, then a different strategy will need to be implemented. Test: Booted cuttlefish/walleye. Test: Ran bionic-unit-tests on cuttlefish/walleye. Change-Id: I0a61f4fa6e4155c602e0414d9b38c2e1637829af
* Update to v5.5 kernel headers.Christopher Ferris2020-02-071-0/+10
| | | | | | | | | | | | | | | Kernel headers coming from: Git: https://android.googlesource.com/kernel/common/ Branch: android-mainline Tag: android-mainline-5.5 Test: Boots on walleye. Test: Ran bionic-unit-tests on walleye. Test: Boots on cuttlefish. Test: Ran bionic-unit-tests on cuttlefish. Change-Id: I57387d3c31e0ba5ad125ffe291cecf365c7b374e Merged-In: I57387d3c31e0ba5ad125ffe291cecf365c7b374e
* Stop generating unused headers.Elliott Hughes2020-02-032-8/+2
| | | | | | | | These just cause confusion because they often have different values/layouts, but they're never actually used. Test: treehugger Change-Id: I424034088e017c919f62fcefa7d6d3f903f31cfb
* _FILE_OFFSET_BITS=64 support for fcntl.Elliott Hughes2020-01-291-0/+2
| | | | | | | | | | | | | | | | | | | On Android, fcntl is always implemented by fcntl64(2). This means that an LP32 binary can `fcntl(F_SETLK, struct flock)` (because fcntl64(2) passes through to the 32-bit fcntl(2) to handle F_SETLK), and it can also `fcntl(F_SETLK64, struct flock64)`. What it can't do before this patch is set _FILE_OFFSET_BITS=64 and then `fcntl(F_SETLK, struct flock)` where that `struct flock` is actually implicitly `struct flock64`. Move the kernel uapi structs out of the way, define them ourselves based on __LP64__ and _FILE_OFFSET_BITS, and fix up the relevant F_ constants. (Also add a .clang-format to turn off clang-format in libc/include/.) Bug: N/A Test: treehugger (and strace!) Change-Id: Iccd6c83d9133e1efcf93a7b49a6ae0f1bbd3d58b
* Clone with --depth 1 in generate_uapi_headers.sh --download-kernel.Josh Gao2019-12-131-1/+1
| | | | | Test: manual Change-Id: Id60b354fb1914470315976dd103d2665a6fefab8
* Update to android-mainline kernel headers v5.4.Christopher Ferris2019-12-121-32/+23
| | | | | | | | | | | | Update generate_uapi_headers.sh to checkout the android mainline kernel. Also, add a small modification to look for the kernel directory in common not linux-stable. Remove deprecated android headers from android/uapi/linux. Also, remove f_accessory.h since it's in the android mainline kernel. Test: Builds and runs on walleye. Change-Id: Ia371305e19f56e6bcc2db6d5b4d299819f07ffc6
* Update to kernel headers v5.2.6.Christopher Ferris2019-08-051-1/+3
| | | | | | | Also, fix a bug in update_all.py when the syscalls file does not change. Test: Builds and boots on a taimen. Change-Id: If85b00daef2c176f804a0861894f5bbca9c6d5df
* clean_header: Run outside of $ANDROID_BUILD_TOPDaniel Mentz2019-04-151-2/+11
| | | | | | | | | | | Enable the use case where we run clean_header.py from outside of $ANDROID_BUILD_TOP. Previously, this script required the current working directory to be under $ANDROID_BUILD_TOP. Running it from a different directory resulted in the following error message: clean_header.py: error: Not in android tree pointed at by ANDROID_BUILD_TOP (....) Change-Id: I48210ea1a0033228a9aaa4124d28247b07cee6d4
* clean_header: Fix error handling for no-such-file caseDaniel Mentz2019-04-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | The function cleanupFile should always return a single value (as opposed to a tuple or list). In addition, if it encounters an error, it is expected to return a value that evaluates to False. As it stands, however, it returns (None, None) in certain error cases. Change this function to return None, in those cases. We previously saw the following error message, when we tried to run clean_header.py on a non-existent file. Traceback (most recent call last): File "clean_header.py", line 208, in <module> b.updateGitFiles() File "utils.py", line 164, in updateGitFiles self._writeFile(dst) File "utils.py", line 136, in _writeFile f.write(self.new_data[dst]) TypeError: expected a string or other character buffer object Change-Id: I5f717dd1a4388f598f0fd4bfd5e6129017de9095
* <bits/glibc-syscalls.h>: only regenerate when we have new uapi headers.Elliott Hughes2019-04-111-6/+61
| | | | | Test: update_all.py Change-Id: Iaa92dce263197f5a0e7d2dce5e00a31372dcb3e9
* clean_header: Don't print extraneous newline charDaniel Mentz2019-03-291-1/+6
| | | | | | | | | | | | | Don't print an extraneous newline character at the end of the include file if clean_header.py is used in the non-update mode. This is necessary to achieve consistent results in the update and non-update modes. Running clean_header in the non-update mode and redirecting the output to a file should have the same result as using the update mode and have the script write to the file directly. Change-Id: I6b176c5365840d66e4499bacd205f1fa77302a2b
* clean_header: Write to correct dst_fileDaniel Mentz2019-03-291-2/+2
| | | | | | | | | | | | | | | | Write to correct dst_file when in update mode. This enables use cases like the following: ../../../bionic/libc/kernel/tools/clean_header.py -k original-kernel-headers/ -d kernel-headers/ -u linux/ion.h Previously, we had to cd into kernel-headers/ and then run ../../../../bionic/libc/kernel/tools/clean_header.py -k ../original-kernel-headers/ -d . -u linux/ion.h because the tool didn't allow the relative path to be different from the destination path. Change-Id: I8c5e284ce7a6737d77a2f5ead3e7e5db01317425
* Rewrite removeVarsAndFuncs.Christopher Ferris2019-01-101-120/+423
| | | | | | | | | | | | | | | | | | | | | | | The current version has these bugs: - Adding a semicolon after a function results in the removal of structures following the function. - Function like macros get removed on accident rather than on purpose. - It removes extern "C" { completely, which might not be a bug, but doesn't seem right. I couldn't easily fix any of these problems because the code depends heavily on the header being correct. New unit tests added for the function to cover all of these cases. A follow-on CL will include the updated headers. Bug: 112290385 Test: Passes all new unit tests. Test: When run on the current kernel headers, the generated headers are Test: nearly the same, missing data is being added. Change-Id: Ib22a5f2e78873544e8a9d54e385af1156b2a72bb
* Fix handling of #elif.Christopher Ferris2018-10-261-264/+385
| | | | | | | | | | | | | | | | | | | | | | | | | When a construct like: if defined(something) blocks1 elif 1 blocks2 else blocks3 endif The parser would put the first clause but then simply omit the elif and put all of blocks2 without a terminating #endif. The code also did something similar when the #else was an #endif. Also convert all of the unit tests to real unit tests and only run them if you run cpp.py by itself. Added new unit tests to cover the new cases. Test: Ran cpp.py unit tests. Test: Reran update_all.py and verified nothing changed, and that running Test: it on the new kernel headers that exposed this problem. Change-Id: Ie168511303c4e15afdb60c37baef75a966ca29a8
* Modify the script to use the linux source tree.Christopher Ferris2018-05-241-21/+25
| | | | | | | | | | | The current code checks out the android kernel tree. Long ago, we moved to using the linux kernel source code. Modify the script to actually do this. Bug: 6653610 Test: Ran the script using the --download_kernel option and without. Change-Id: I769e769edea272f4f8c9c8d2e76bd336059c66e3
* Remove ion.h from bionic uapi headers.Christopher Ferris2018-04-241-0/+3
| | | | | | | Bug: 77976082 Test: Ran the generate script and verified ion.h is deleted. Change-Id: I33b3aeef66f08f35dd496a073931b2fe2c80a1d6
* Use in_addr in ip_mreq_source and ip_msfilter.Elliott Hughes2017-12-143-67/+46
| | | | | | | | | | | | | | | | | | This adds a new mechanism to say "replace struct S with #include <bits/S.h>". Also switch epoll_event over to the new mechanism. Also use the kernel's struct sockaddr_storage directly rather than behind an unnecessary #define. This patch also removes some dead code in the header scrubber. This code still needs rewriting completely. I learned that a "block" isn't necessarily a single struct definition, say; it might be a run of them. It seems like a block is a run of preprocessor directives or a run of regular code. Bug: https://issuetracker.google.com/36987220 Test: new test Change-Id: Ic6a5c09559766a4babe3cd4c3ea538b885e07308
* Merge "Change ARG_MAX/_SC_ARG_MAX back to a constant."Elliott Hughes2017-11-161-2/+0
|\
| * Change ARG_MAX/_SC_ARG_MAX back to a constant.Elliott Hughes2017-11-151-2/+0
| | | | | | | | | | | | | | | | As per the lkml thread https://lkml.org/lkml/2017/11/1/946. Bug: http://b/65818597 Test: ran tests Change-Id: I7a0610e6903e6761f2b31416e2f5017bd7a60659
* | Update to kernel headers v4.14.Christopher Ferris2017-11-152-3/+1
|/ | | | | | | | | | | | | Remove the hiding of the kernel structure binder_fd_array_object. This structure now matches the structure used in the binder code. Load the libclang_android.so shared library directly for parsing. This file changed name in a recent update to the prebuilts. Test: Compiles arm/arm64/x86/x86_64. Test: Boots on hikey and boots on a sailfish. Test: Ran bionic unit tests on hikey and sailfish. Change-Id: I141a4b93ac3511cd58f4d12bb3c0d4efaa4c2742
* Use env to invoke pythonStephen Crane2017-08-311-1/+1
| | | | | | | | /usr/bin/python may be python3. We should respect PATH to find the python executable so it can be locally overridden to be python2. Test: Build libc, repo upload Change-Id: Iaddd7cd4a1c2177c32786e4fa0fc664ab0ad36de
* Update to kernel headers v4.12.3.Christopher Ferris2017-07-271-0/+2
| | | | | Test: Built angler. Change-Id: Icbcf4fac2334de8409b049ed7a3b4c24b4e98ce9
* Enable exporting the non-uapi scsi headers.Elliott Hughes2017-05-251-1/+1
| | | | | | | | | | | Callers are supposed to #include <scsi/sg.h> but if we tell soong to add bionic/libc/kernel/android/ to the include path, the uapi headers in there would be (unintentionally) accessible as either <linux/name.h> or <uapi/linux/name.h>. Bug: N/A (hit while upgrading strace to 4.17) Test: builds Change-Id: I8d47dd51da688c38f747a255d401dfb2c209c805
* Remove the repetitive warnings from the uapi headers.Elliott Hughes2017-05-253-26/+7
| | | | | | | | | | | | | | Having WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS every four lines made the headers harder to read, made the diffs much worse each time we upgraded, and wasn't really providing any benefit. Before the next uapi update, let's just stop doing this. Bug: N/A Test: builds, manually inspected files look right Change-Id: Id7088cf750894c9d24950f3d53587fe3156c4f7d
* Make `union semun` usable.Elliott Hughes2017-05-181-0/+2
| | | | | | | | | | | | | | This is a bit bogus because it's been removed from glibc (though not thoroughly) and is never useful on Android (because the system calls in question are compiled out of Android kernels, and SELinux would disallow them even if you weren't running an Android kernel). This also means that on glibc you need to include <linux/sem.h> for this and on bionic you need <sys/sem.h> (and for either if you #include the other file, you won't get this union). Bug: https://github.com/android-ndk/ndk/issues/400 Test: added new test Change-Id: I47f721da77515531f616d6ad8479bfbc9b60ee47
* Update static functions/macro definitions.Christopher Ferris2017-04-211-7/+29
| | | | | | | | | | | | | | | | 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
* Merge "Refactor the kernel update scripts."Christopher Ferris2017-03-033-135/+95
|\
| * Refactor the kernel update scripts.Christopher Ferris2017-03-023-135/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous versions of the scripts did a lot of redundant changes and were hard to follow. I rewrote most of update_all.py so that it's clear about what's going on. I updated clean_header.py to change the cleanupFile function so that there is no magic about where the destination file is going to wind up. Now the caller specifies the final location. I updated utils.py so that if you are trying to do an update in one location, but your lunch target is from another location, it causes an error. Bug: 35726570 Change-Id: Ic5a44d90c2774a627eecde34c0c403bc925a497c Test: Ran the updater and verified it works properly. Test: Verified that doing an update in one tree to another tree Test: fails.
* | Use <linux/eventpoll.h> to implement <sys/epoll.h>.Elliott Hughes2017-02-231-0/+2
|/ | | | | | Bug: https://github.com/android-ndk/ndk/issues/302 Test: builds Change-Id: Ia3074326a128c38f2488e342c028cc030801cfd9
* Update to kernel headers v4.7.2.Christopher Ferris2016-08-291-0/+3
| | | | | | | | | | | | | | | | Modify the kernel header update script to rename C++ keyword struct members to something else. This fixes problems when including these kernel files in C++ code. Also, make a manual change to linux/fib_rules.h and comment out the value FRA_PAD since it conflicts with a special android kernel value FRA_UID_START that has not been upstreamed yet. Test: Built aosp_angler, aosp_x86_64, aosp_mips (bionic only) Test: Booted on angler and ran bionic unit tests Test: Built these changes in internal master Change-Id: Ia22b7e3ca409404696dba76311f49157f4a9ceed
* Flesh out <sys/msg.h>, <sys/sem.h>, <sys/shm.h>.Elliott Hughes2016-08-181-0/+5
| | | | | | | | | | | | Also fix <sys/ipc.h>. Not useful except to systems/bringup folks for testing. Trivial tests added, and double-checked under strace to see that things look right. x86 -- which works differently to everything else -- tested on the host. Bug: http://b/27952303 Change-Id: I328534e994ae9e90755f545478fba03038c0bb94
* Fix sysconf(_SC_ARG_MAX).Elliott Hughes2016-08-101-2/+3
| | | | | | | | ARG_MAX hasn't been a constant since Linux 2.6.23. Bug: http://lists.landley.net/pipermail/toybox-landley.net/2016-August/008592.html Change-Id: I1eddb562751604c75b89fa610d79be0655c53693 Test: ran the bionic tests on device and against glibc
* More kernel header cleanup.Christopher Ferris2016-07-223-9/+50
| | | | | | | | | | | | | | | | | | | Modify the generate script to add a new option and copy the types.h arm header file since it's not currently being created properly. Also manually generate the arm types.h uapi header since it's not being properly generated right now. Modify both generate scripts to delete the target directories before adding the files to handle moved/deleted header files. Move the common/scsi headers into android and delete the common directory. Change the scripts to reflect this change. Update the scsi headers since they've been modified in upstream kernels. Bug: 30072483 Change-Id: Ia43d4b238b6a041350d60cc30184ecbd4829d7d5
* <netinet/udp.h> should include <linux/udp.h>.Elliott Hughes2015-09-221-0/+2
| | | | | | | | | | | | | | | The comment about "other stuff" referred to pre-uapi headers. Everything in the current <linux/udp.h> should be exposed to userspace. The only problem is that BSD and Linux use different names for the members of struct udphdr. We can move the Linux udphdr out of the way and use an anonymous union to get the best of both worlds. (Though unfortunately this means that code that includes <linux/udp.h> directly instead of using <netinet/udp.h> now won't have any definition of struct udphdr. We've taken the stance in the past that you shouldn't include a linux/ header if there's a standard equivalent --- you should rely on us transitively including it for you.) Change-Id: Ie625892441b0edd8df3b76d3fcf2cbe299077bc4
* Add support for manually modified kernel headers.Christopher Ferris2015-09-175-100/+156
| | | | | | | | | | | | | | This changes the scripts so that if some kernel files exists in external/kernel-headers/modified, that they will be preferred over the same files found in original. This is to support the case where the kernel headers cannot be taken without some small modifications. Included with this change, is a general cleanup of the python scripts. This also modifies the generate uapi headers script to indicate if the source of the modified headers has changed. Change-Id: Id13523b244ced52a2ecd9f1399c43996dd8296fa
* Update the search path for libclang.soTao Bao2015-04-221-1/+4
| | | | | | | | | Prebuilt shared libraries (libclang.so, libLLVM.so and etc) have been moved to prebuilts/sdk/tools/linux/lib64. Update the search path in cpp.py to match the change. Bug: 20485471 Change-Id: Ib7784db4d5529d16a1e2bfc07cb0237929bc5a64
* Define MAXHOSTNAMELEN explicitly in source files.Yabin Cui2015-02-091-4/+2
| | | | | | Bug: 19093777 Bug: 19092844 Change-Id: I0778507ca2d5c008abb9a6d6315d0909263a8817