DO NOT MERGE : Update timezone data to 2016i.
am: dd0155f7d4

Change-Id: Ic7148f07431257aeb798732eaaca79a21d24ea03
diff --git a/.clang-format b/.clang-format
index 9b7478c..b8c6428 100644
--- a/.clang-format
+++ b/.clang-format
@@ -6,7 +6,6 @@
 CommentPragmas: NOLINT:.*
 DerivePointerAlignment: false
 IndentWidth: 2
-ContinuationIndentWidth: 2
 PointerAlignment: Left
 TabWidth: 2
 UseTab: Never
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..dbe5c97
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,2 @@
+subdirs = ["*"]
+
diff --git a/Android.mk b/Android.mk
index 9f0f0c3..888404c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,20 +1,4 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
 LOCAL_PATH := $(call my-dir)
 
-include $(call all-makefiles-under,$(LOCAL_PATH)) \
-	$(call all-makefiles-under,$(LOCAL_PATH)/libc)
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..125b469
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,3 @@
+[Hook Scripts]
+versioner = tools/versioner/preupload.sh
+notice = tools/update_notice.sh
diff --git a/README.md b/README.md
index c6b9278..6f8edf4 100644
--- a/README.md
+++ b/README.md
@@ -153,10 +153,13 @@
      the appropriate POSIX header file in libc/include/ includes the
      relevant file or files.
   4. Add function declarations to the appropriate header file.
-  5. Add at least basic tests. Even a test that deliberately supplies
+  5. Add the function name to the correct section in libc/libc.map.txt and
+     run `./libc/tools/genversion-scripts.py`.
+  6. Add at least basic tests. Even a test that deliberately supplies
      an invalid argument helps check that we're generating the right symbol
-     and have the right declaration in the header file. (And strace(1) can
-     confirm that the correct system call is being made.)
+     and have the right declaration in the header file, and that you correctly
+     updated the maps in step 5. (You can use strace(1) to confirm that the
+     correct system call is being made.)
 
 
 Updating kernel header files
@@ -208,23 +211,27 @@
     $ adb shell \
         /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static64
 
+Note that we use our own custom gtest runner that offers a superset of the
+options documented at
+<https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#running-test-programs-advanced-options>,
+in particular for test isolation and parallelism (both on by default).
+
 ### Host tests
 
 The host tests require that you have `lunch`ed either an x86 or x86_64 target.
 
-    $ mma
-    $ mm bionic-unit-tests-run-on-host32
-    $ mm bionic-unit-tests-run-on-host64  # For 64-bit *targets* only.
+    $ ./tests/run-on-host.sh 32
+    $ ./tests/run-on-host.sh 64   # For x86_64-bit *targets* only.
+
+You can supply gtest flags as extra arguments to this script.
 
 ### Against glibc
 
 As a way to check that our tests do in fact test the correct behavior (and not
 just the behavior we think is correct), it is possible to run the tests against
-the host's glibc. The executables are already in your path.
+the host's glibc.
 
-    $ mma
-    $ bionic-unit-tests-glibc32
-    $ bionic-unit-tests-glibc64
+    $ ./tests/run-on-host.sh glibc
 
 
 Gathering test coverage
@@ -261,6 +268,25 @@
 The coverage report is now available at `covreport/index.html`.
 
 
+Running the benchmarks
+----------------------
+
+### Device benchmarks
+
+    $ mma
+    $ adb remount
+    $ adb sync
+    $ adb shell /data/nativetest/bionic-benchmarks/bionic-benchmarks
+    $ adb shell /data/nativetest64/bionic-benchmarks/bionic-benchmarks
+
+You can use `--benchmark_filter=getpid` to just run benchmarks with "getpid"
+in their name.
+
+### Host benchmarks
+
+See the "Host tests" section of "Running the tests" above.
+
+
 Attaching GDB to the tests
 --------------------------
 
diff --git a/android-changes-for-ndk-developers.md b/android-changes-for-ndk-developers.md
new file mode 100644
index 0000000..11648fa
--- /dev/null
+++ b/android-changes-for-ndk-developers.md
@@ -0,0 +1,223 @@
+# Android changes for NDK developers
+
+This document details important changes related to native code
+loading in various Android releases.
+
+Required tools: the NDK has an _arch_-linux-android-readelf binary
+(e.g. arm-linux-androideabi-readelf or i686-linux-android-readelf)
+for each architecture (under toolchains/), but you can use readelf for
+any architecture, as we will be doing basic inspection only. On Linux
+you need to have the “binutils” package installed for readelf,
+and “pax-utils” for scanelf.
+
+
+## Private API (Enforced for API level >= 24)
+
+Native libraries must use only public API, and must not link against
+non-NDK platform libraries. Starting with API 24 this rule is enforced and
+applications are no longer able to load non-NDK platform libraries. The
+rule is enforced by the dynamic linker, so non-public libraries
+are not accessible regardless of the way code tries to load them:
+System.loadLibrary, DT_NEEDED entries, and direct calls to dlopen(3)
+will all work exactly the same.
+
+Users should have a consistent app experience across updates,
+and developers shouldn't have to make emergency app updates to
+handle platform changes. For that reason, we recommend against using
+private C/C++ symbols. Private symbols aren't tested as part of the
+Compatibility Test Suite (CTS) that all Android devices must pass. They
+may not exist, or they may behave differently. This makes apps that use
+them more likely to fail on specific devices, or on future releases ---
+as many developers found when Android 6.0 Marshmallow switched from
+OpenSSL to BoringSSL.
+
+In order to reduce the user impact of this transition, we've identified
+a set of libraries that see significant use from Google Play's
+most-installed apps, and that are feasible for us to support in the
+short term (including libandroid_runtime.so, libcutils.so, libcrypto.so,
+and libssl.so). In order to give you more time to transition, we will
+temporarily support these libraries; so if you see a warning that means
+your code will not work in a future release -- please fix it now!
+
+```
+$ readelf --dynamic libBroken.so | grep NEEDED
+ 0x00000001 (NEEDED)                     Shared library: [libnativehelper.so]
+ 0x00000001 (NEEDED)                     Shared library: [libutils.so]
+ 0x00000001 (NEEDED)                     Shared library: [libstagefright_foundation.so]
+ 0x00000001 (NEEDED)                     Shared library: [libmedia_jni.so]
+ 0x00000001 (NEEDED)                     Shared library: [liblog.so]
+ 0x00000001 (NEEDED)                     Shared library: [libdl.so]
+ 0x00000001 (NEEDED)                     Shared library: [libz.so]
+ 0x00000001 (NEEDED)                     Shared library: [libstdc++.so]
+ 0x00000001 (NEEDED)                     Shared library: [libm.so]
+ 0x00000001 (NEEDED)                     Shared library: [libc.so]
+```
+
+*Potential problems*: starting from API 24 the dynamic linker will not
+load private libraries, preventing the application from loading.
+
+*Resolution*: rewrite your native code to rely only on public API. As a
+short term workaround, platform libraries without complex dependencies
+(libcutils.so) can be copied to the project. As a long term solution
+the relevant code must be copied to the project tree. SSL/Media/JNI
+internal/binder APIs should not be accessed from the native code. When
+necessary, native code should call appropriate public Java API methods.
+
+A complete list of public libraries is available within the NDK, under
+platforms/android-API/usr/lib.
+
+Note: SSL/crypto is a special case, applications must NOT use platform
+libcrypto and libssl libraries directly, even on older platforms. All
+applications should use GMS Security Provider to ensure they are protected
+from known vulnerabilities.
+
+
+## Missing Section Headers (Enforced for API level >= 24)
+
+Each ELF file has additional information contained in the section
+headers. These headers must be present now, because the dynamic linker
+uses them for sanity checking. Some developers strip them in an
+attempt to obfuscate the binary and prevent reverse engineering. (This
+doesn't really help because it is possible to reconstruct the stripped
+information using widely-available tools.)
+
+```
+$ readelf --header libBroken.so | grep 'section headers'
+  Start of section headers:          0 (bytes into file)
+  Size of section headers:           0 (bytes)
+  Number of section headers:         0
+```
+
+*Resolution*: remove the extra steps from your build that strip section
+headers.
+
+## Text Relocations (Enforced for API level >= 23)
+
+Starting with API 23, shared objects must not contain text
+relocations. That is, the code must be loaded as is and must not be
+modified. Such an approach reduces load time and improves security.
+
+The usual reason for text relocations is non-position independent
+hand-written assembler. This is not common. Use the scanelf tool as
+described in our documentation for further diagnostics:
+
+```
+$ scanelf -qT libTextRel.so
+  libTextRel.so: (memory/data?) [0x15E0E2] in (optimized out: previous simd_broken_op1) [0x15E0E0]
+  libTextRel.so: (memory/data?) [0x15E3B2] in (optimized out: previous simd_broken_op2) [0x15E3B0]
+  ...
+```
+
+If you have no scanelf tool available, it is possible to do a basic
+check with readelf instead, look for either a TEXTREL entry or the
+TEXTREL flag. Either alone is sufficient. (The value corresponding to the
+TEXTREL entry is irrelevant and typically 0 --- simply the presence of
+the TEXTREL entry declares that the .so contains text relocations). This
+example has both indicators present:
+
+```
+$ readelf --dynamic libTextRel.so | grep TEXTREL
+ 0x00000016 (TEXTREL)                    0x0
+ 0x0000001e (FLAGS)                      SYMBOLIC TEXTREL BIND_NOW
+```
+
+Note: it is technically possible to have a shared object with the TEXTREL
+entry/flag but without any actual text relocations. This doesn't happen
+with the NDK, but if you're generating ELF files yourself make sure
+you're not generating ELF files that claim to have text relocations,
+because the Android dynamic linker trusts the entry/flag.
+
+*Potential problems*: Relocations enforce code pages being writable, and
+wastefully increase the number of dirty pages in memory. The dynamic
+linker has issued warnings about text relocations since Android K
+(API 19), but on API 23 and above it refuses to load code with text
+relocations.
+
+*Resolution*: rewrite assembler to be position independent to ensure
+no text relocations are necessary. The
+[Gentoo Textrels guide](https://wiki.gentoo.org/wiki/Hardened/Textrels_Guide)
+has instructions for fixing text relocations, and more detailed
+[scanelf documentation](https://wiki.gentoo.org/wiki/Hardened/PaX_Utilities).
+
+
+## Invalid DT_NEEDED Entries (Enforced for API level >= 23)
+
+While library dependencies (DT_NEEDED entries in the ELF headers) can be
+absolute paths, that doesn't make sense on Android because you have
+no control over where your library will be installed by the system. A
+DT_NEEDED entry should be the same as the needed library's SONAME,
+leaving the business of finding the library at runtime to the dynamic
+linker.
+
+Before API 23, Android's dynamic linker ignored the full path, and
+used only the basename (the part after the last ‘/') when looking
+up the required libraries. Since API 23 the runtime linker will honor
+the DT_NEEDED exactly and so it won't be able to load the library if
+it is not present in that exact location on the device.
+
+Even worse, some build systems have bugs that cause them to insert
+DT_NEEDED entries that point to a file on the build host, something that
+cannot be found on the device.
+
+```
+$ readelf --dynamic libSample.so | grep NEEDED
+ 0x00000001 (NEEDED)                     Shared library: [libm.so]
+ 0x00000001 (NEEDED)                     Shared library: [libc.so]
+ 0x00000001 (NEEDED)                     Shared library: [libdl.so]
+ 0x00000001 (NEEDED)                     Shared library:
+[C:\Users\build\Android\ci\jni\libBroken.so]
+```
+
+*Potential problems*: before API 23 the DT_NEEDED entry's basename was
+used, but starting from API 23 the Android runtime will try to load the
+library using the path specified, and that path won't exist on the
+device. There are broken third-party toolchains/build systems that use
+a path on a build host instead of the SONAME.
+
+*Resolution*: make sure all required libraries are referenced by SONAME
+only. It is better to let the runtime linker to find and load those
+libraries as the location may change from device to device.
+
+
+## Missing SONAME (Enforced for API level >= 23)
+
+Each ELF shared object (“native library”) must have a SONAME (Shared
+Object Name) attribute. The NDK toolchain adds this attribute by default,
+so its absence indicates either a misconfigured alternative toolchain
+or a misconfiguration in your build system. A missing SONAME may lead
+to runtime issues such as the wrong library being loaded: the filename
+is used instead when this attribute is missing.
+
+```
+$ readelf --dynamic libWithSoName.so | grep SONAME
+ 0x0000000e (SONAME)                     Library soname: [libWithSoName.so]
+```
+
+*Potential problems*: namespace conflicts may lead to the wrong library
+being loaded at runtime, which leads to crashes when required symbols
+are not found, or you try to use an ABI-incompatible library that isn't
+the library you were expecting.
+
+*Resolution*: the current NDK generates the correct SONAME by
+default. Ensure you're using the current NDK and that you haven't
+configured your build system to generate incorrect SONAME entries (using
+the -soname linker option).
+
+
+## Writable and Executable Segments (AOSP master)
+
+Each segment in an ELF file has associated flags that tell the
+dynamic linker what permissions to give the corresponding page in
+memory. For security, data shouldn't be executable and code shouldn't be
+writable. This means that the W (for Writable) and E (for Executable)
+flags should be mutually exclusive. This wasn't historically enforced,
+but is now.
+
+```
+$ readelf --program-headers -W libBadFlags.so | grep WE
+  LOAD           0x000000 0x00000000 0x00000000 0x4c01d 0x4c01d RWE 0x1000
+```
+
+*Resolution*: right now we're not actually sure where these are coming
+from, so if you find and fix these in your app, please let us know how
+they snuck in!
diff --git a/benchmarks/Android.bp b/benchmarks/Android.bp
new file mode 100644
index 0000000..12f4940
--- /dev/null
+++ b/benchmarks/Android.bp
@@ -0,0 +1,64 @@
+//
+// Copyright (C) 2013 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_defaults {
+    name: "bionic-benchmarks-defaults",
+    cflags: [
+        "-O2",
+        "-fno-builtin",
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+        "-Wunused",
+    ],
+    srcs: [
+        "math_benchmark.cpp",
+        "property_benchmark.cpp",
+        "pthread_benchmark.cpp",
+        "semaphore_benchmark.cpp",
+        "stdio_benchmark.cpp",
+        "string_benchmark.cpp",
+        "time_benchmark.cpp",
+        "unistd_benchmark.cpp",
+    ],
+}
+
+// Build benchmarks for the device (with bionic's .so). Run with:
+//   adb shell bionic-benchmarks32
+//   adb shell bionic-benchmarks64
+cc_benchmark {
+    name: "bionic-benchmarks",
+    defaults: ["bionic-benchmarks-defaults"],
+}
+
+// We don't build a static benchmark executable because it's not usually
+// useful. If you're trying to run the current benchmarks on an older
+// release, it's (so far at least) always because you want to measure the
+// performance of the old release's libc, and a static benchmark isn't
+// going to let you do that.
+
+// Build benchmarks for the host (against glibc!). Run with:
+cc_benchmark_host {
+    name: "bionic-benchmarks-glibc",
+    defaults: ["bionic-benchmarks-defaults"],
+    host_ldlibs: ["-lrt"],
+    target: {
+        darwin: {
+            // Only supported on linux systems.
+            enabled: false,
+        },
+    },
+}
diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
deleted file mode 100644
index 6f2651e..0000000
--- a/benchmarks/Android.mk
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-benchmark_cflags := \
-    -O2 \
-    -fno-builtin \
-    -Wall \
-    -Wextra \
-    -Werror \
-    -Wunused \
-
-benchmark_cppflags := \
-
-benchmark_src_files := \
-    math_benchmark.cpp \
-    property_benchmark.cpp \
-    pthread_benchmark.cpp \
-    semaphore_benchmark.cpp \
-    stdio_benchmark.cpp \
-    string_benchmark.cpp \
-    time_benchmark.cpp \
-    unistd_benchmark.cpp \
-
-# Build benchmarks for the device (with bionic's .so). Run with:
-#   adb shell bionic-benchmarks32
-#   adb shell bionic-benchmarks64
-include $(CLEAR_VARS)
-LOCAL_MODULE := bionic-benchmarks
-LOCAL_MODULE_STEM_32 := bionic-benchmarks32
-LOCAL_MODULE_STEM_64 := bionic-benchmarks64
-LOCAL_MULTILIB := both
-LOCAL_CFLAGS := $(benchmark_cflags)
-LOCAL_CPPFLAGS := $(benchmark_cppflags)
-LOCAL_SRC_FILES := $(benchmark_src_files)
-include $(BUILD_NATIVE_BENCHMARK)
-
-# We don't build a static benchmark executable because it's not usually
-# useful. If you're trying to run the current benchmarks on an older
-# release, it's (so far at least) always because you want to measure the
-# performance of the old release's libc, and a static benchmark isn't
-# going to let you do that.
-
-# Only supported on linux systems.
-ifeq ($(HOST_OS),linux)
-
-# Build benchmarks for the host (against glibc!). Run with:
-include $(CLEAR_VARS)
-LOCAL_MODULE := bionic-benchmarks-glibc
-LOCAL_MODULE_STEM_32 := bionic-benchmarks-glibc32
-LOCAL_MODULE_STEM_64 := bionic-benchmarks-glibc64
-LOCAL_MULTILIB := both
-LOCAL_CFLAGS := $(benchmark_cflags)
-LOCAL_CPPFLAGS := $(benchmark_cppflags)
-LOCAL_LDFLAGS := -lrt
-LOCAL_SRC_FILES := $(benchmark_src_files)
-LOCAL_STATIC_LIBRARIES := libgoogle-benchmark
-# TODO: BUILD_HOST_NATIVE_BENCHMARK
-include $(BUILD_HOST_EXECUTABLE)
-
-endif
-
-ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
-include $(LOCAL_PATH)/../build/run-on-host.mk
-
-ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
-bionic-benchmarks-run-on-host32: bionic-benchmarks bionic-prepare-run-on-host
-	ANDROID_DATA=$(TARGET_OUT_DATA) \
-	ANDROID_ROOT=$(TARGET_OUT) \
-		$(TARGET_OUT_EXECUTABLES)/bionic-benchmarks32 $(BIONIC_BENCHMARKS_FLAGS)
-endif
-
-ifeq ($(TARGET_IS_64_BIT),true)
-bionic-benchmarks-run-on-host64: bionic-benchmarks bionic-prepare-run-on-host
-	ANDROID_DATA=$(TARGET_OUT_DATA) \
-	ANDROID_ROOT=$(TARGET_OUT) \
-		$(TARGET_OUT_EXECUTABLES)/bionic-benchmarks64 $(BIONIC_BENCHMARKS_FLAGS)
-endif
-
-endif
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index 2f72d60..4e82117 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -36,7 +36,7 @@
     Arg(1)->Arg(4)->Arg(16)->Arg(64)->Arg(128)->Arg(256)->Arg(512)
 
 struct LocalPropertyTestState {
-  LocalPropertyTestState(int nprops) : nprops(nprops), valid(false) {
+  explicit LocalPropertyTestState(int nprops) : nprops(nprops), valid(false) {
     static const char prop_name_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.";
 
     const char* android_data = getenv("ANDROID_DATA");
diff --git a/benchmarks/run-on-host.sh b/benchmarks/run-on-host.sh
new file mode 100755
index 0000000..bc63628
--- /dev/null
+++ b/benchmarks/run-on-host.sh
@@ -0,0 +1,33 @@
+#!/bin/bash -e
+
+. $(dirname $0)/../build/run-on-host.sh
+
+if [ "$1" = glibc ]; then
+    m -j bionic-benchmarks-glibc
+    (
+        cd ${ANDROID_BUILD_TOP}
+        export ANDROID_DATA=${TARGET_OUT_DATA}
+        export ANDROID_ROOT=${TARGET_OUT}
+        ${HOST_OUT}/nativetest64/bionic-benchmarks-glibc/bionic-benchmarks-glibc $@
+    )
+    exit 0
+elif [ "$1" != 32 -a "$1" != 64 ]; then
+    echo "Usage: $0 [ 32 | 64 | glibc ] [gtest flags]"
+    exit 1
+fi
+
+if [ ${HOST_OS}-${HOST_ARCH} = linux-x86 -o ${HOST_OS}-${HOST_ARCH} = linux-x86_64 ]; then
+
+    prepare $1 bionic-benchmarks
+
+    if [ ${TARGET_ARCH} = x86 -o ${TARGET_ARCH} = x86_64 ]; then
+        (
+            cd ${ANDROID_BUILD_TOP}
+            export ANDROID_DATA=${TARGET_OUT_DATA}
+            export ANDROID_ROOT=${TARGET_OUT}
+            ${NATIVETEST}/bionic-benchmarks/bionic-benchmarks $@
+        )
+    else
+        echo "$0 not supported on TARGET_ARCH=$TARGET_ARCH"
+    fi
+fi
diff --git a/benchmarks/semaphore_benchmark.cpp b/benchmarks/semaphore_benchmark.cpp
index d260803..b932a2b3 100644
--- a/benchmarks/semaphore_benchmark.cpp
+++ b/benchmarks/semaphore_benchmark.cpp
@@ -96,22 +96,27 @@
     sched_setscheduler(0, SCHED_IDLE, &param);
 
     BM_semaphore_sem_post_running = 1;
+    setup = true;
   }
 
   ~SemaphoreFixture() {
-    sched_setscheduler(0, SCHED_OTHER, &param);
+    if (setup) {
+      // Only do this if the test was actually run.
+      sched_setscheduler(0, SCHED_OTHER, &param);
 
-    if (BM_semaphore_sem_post_running > 0) {
-      BM_semaphore_sem_post_running = 0;
+      if (BM_semaphore_sem_post_running > 0) {
+        BM_semaphore_sem_post_running = 0;
+      }
+      do {
+        sem_post(&semaphore);
+        sched_yield();
+      } while (BM_semaphore_sem_post_running != -1);
     }
-    do {
-      sem_post(&semaphore);
-      sched_yield();
-    } while (BM_semaphore_sem_post_running != -1);
   }
 
   sem_t semaphore;
   sched_param param;
+  bool setup = false;
 };
 
 BENCHMARK_F(SemaphoreFixture, semaphore_sem_post)(benchmark::State& state) {
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp
index cc07128..a556d17 100644
--- a/benchmarks/stdio_benchmark.cpp
+++ b/benchmarks/stdio_benchmark.cpp
@@ -20,8 +20,7 @@
 
 #include <benchmark/benchmark.h>
 
-#define KB 1024
-#define MB 1024*KB
+constexpr auto KB = 1024;
 
 #define AT_COMMON_SIZES \
     Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(8)->Arg(16)->Arg(32)->Arg(64)->Arg(512)-> \
diff --git a/benchmarks/string_benchmark.cpp b/benchmarks/string_benchmark.cpp
index c04409d..0a38512 100644
--- a/benchmarks/string_benchmark.cpp
+++ b/benchmarks/string_benchmark.cpp
@@ -19,8 +19,7 @@
 
 #include <benchmark/benchmark.h>
 
-#define KB 1024
-#define MB 1024*KB
+constexpr auto KB = 1024;
 
 #define AT_COMMON_SIZES \
     Arg(8)->Arg(64)->Arg(512)->Arg(1*KB)->Arg(8*KB)->Arg(16*KB)->Arg(32*KB)->Arg(64*KB)
diff --git a/build/run-on-host.mk b/build/run-on-host.mk
deleted file mode 100644
index dc7e5d5..0000000
--- a/build/run-on-host.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Include once
-ifneq ($(bionic_run_on_host_mk_included),true)
-bionic_run_on_host_mk_included:=true
-
-ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86))
-LINKER = linker64
-else
-LINKER = linker
-endif
-
-ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
-# gtest needs ANDROID_DATA/local/tmp for death test output.
-# Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
-# bionic itself should always work relative to ANDROID_DATA or ANDROID_ROOT.
-bionic-prepare-run-on-host: $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT)/etc/hosts $(TARGET_OUT_EXECUTABLES)/sh
-	if [ ! -d /system ]; then \
-	  echo "Attempting to create /system"; \
-	  sudo mkdir -p -m 0777 /system; \
-	fi
-	mkdir -p $(TARGET_OUT_DATA)/local/tmp
-	ln -fs `realpath $(TARGET_OUT)/bin` /system/
-	ln -fs `realpath $(TARGET_OUT)/etc` /system/
-	ln -fs `realpath $(TARGET_OUT)/lib` /system/
-	if [ -d "$(TARGET_OUT)/lib64" ]; then \
-	  ln -fs `realpath $(TARGET_OUT)/lib64` /system/; \
-	fi
-endif
-endif
diff --git a/build/run-on-host.sh b/build/run-on-host.sh
new file mode 100644
index 0000000..c3a2751
--- /dev/null
+++ b/build/run-on-host.sh
@@ -0,0 +1,47 @@
+#!/bin/bash -e
+
+source ${ANDROID_BUILD_TOP}/build/envsetup.sh
+
+TARGET_ARCH=$(get_build_var TARGET_ARCH)
+TARGET_OUT=$(get_build_var TARGET_OUT)
+TARGET_OUT_EXECUTABLES=$(get_build_var TARGET_OUT_EXECUTABLES)
+TARGET_OUT_DATA=$(get_build_var TARGET_OUT_DATA)
+HOST_OS=$(get_build_var HOST_OS)
+HOST_ARCH=$(get_build_var HOST_ARCH)
+HOST_OUT=$(get_build_var HOST_OUT)
+
+function prepare()
+{
+    BITS=$1
+    shift
+
+    NATIVETEST=${TARGET_OUT_DATA}/nativetest
+    if [ "${BITS}" = 64 ]; then
+        NATIVETEST=${NATIVETEST}64
+    fi
+
+    if [ ${TARGET_ARCH} = arm -o ${TARGET_ARCH} = mips -o ${TARGET_ARCH} = x86 ]; then
+        LINKER=${TARGET_OUT_EXECUTABLES}/linker
+    else
+        LINKER="${TARGET_OUT_EXECUTABLES}/linker64 ${TARGET_OUT_EXECUTABLES}/linker"
+    fi
+
+    if [ ${TARGET_ARCH} = x86 -o ${TARGET_ARCH} = x86_64 ]; then
+        m -j ${LINKER} ${TARGET_OUT}/etc/hosts ${TARGET_OUT_EXECUTABLES}/sh $@
+
+        if [ ! -d /system ]; then
+            echo "Attempting to create /system";
+            sudo mkdir -p -m 0777 /system;
+        fi
+        (
+            cd ${ANDROID_BUILD_TOP}
+            mkdir -p ${TARGET_OUT_DATA}/local/tmp
+            ln -fs `realpath ${TARGET_OUT}/bin` /system/
+            ln -fs `realpath ${TARGET_OUT}/etc` /system/
+            ln -fs `realpath ${TARGET_OUT}/lib` /system/
+            if [ -d "${TARGET_OUT}/lib64" ]; then
+                ln -fs `realpath ${TARGET_OUT}/lib64` /system/;
+            fi
+        )
+    fi
+}
diff --git a/libc/Android.bp b/libc/Android.bp
index 4cae16c..62ca943 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -7,7 +7,6 @@
     "bionic/getpriority.c",
     "bionic/initgroups.c",
     "bionic/isatty.c",
-    "bionic/memmem.c",
     "bionic/pututline.c",
     "bionic/sched_cpualloc.c",
     "bionic/sched_cpucount.c",
@@ -16,45 +15,14 @@
     "bionic/sigsetmask.c",
     "bionic/system_properties_compat.c",
     "stdio/fread.c",
+    "stdio/parsefloat.c",
     "stdio/refill.c",
-    "stdio/snprintf.c",
-    "stdio/sprintf.c",
     "stdio/stdio.cpp",
     "stdio/stdio_ext.cpp",
+    "stdio/vfscanf.c",
+    "stdio/vfwscanf.c",
     "stdlib/atexit.c",
     "stdlib/exit.c",
-
-    // Fortify implementations of libc functions.
-    "bionic/__FD_chk.cpp",
-    "bionic/__fgets_chk.cpp",
-    "bionic/__fread_chk.cpp",
-    "bionic/__fwrite_chk.cpp",
-    "bionic/__getcwd_chk.cpp",
-    "bionic/__memchr_chk.cpp",
-    "bionic/__memmove_chk.cpp",
-    "bionic/__memrchr_chk.cpp",
-    "bionic/__poll_chk.cpp",
-    "bionic/__pread64_chk.cpp",
-    "bionic/__pread_chk.cpp",
-    "bionic/__pwrite64_chk.cpp",
-    "bionic/__pwrite_chk.cpp",
-    "bionic/__read_chk.cpp",
-    "bionic/__readlink_chk.cpp",
-    "bionic/__readlinkat_chk.cpp",
-    "bionic/__recvfrom_chk.cpp",
-    "bionic/__stpcpy_chk.cpp",
-    "bionic/__stpncpy_chk.cpp",
-    "bionic/__strchr_chk.cpp",
-    "bionic/__strlcat_chk.cpp",
-    "bionic/__strlcpy_chk.cpp",
-    "bionic/__strlen_chk.cpp",
-    "bionic/__strncat_chk.cpp",
-    "bionic/__strncpy_chk.cpp",
-    "bionic/__strrchr_chk.cpp",
-    "bionic/__umask_chk.cpp",
-    "bionic/__vsnprintf_chk.cpp",
-    "bionic/__vsprintf_chk.cpp",
-    "bionic/__write_chk.cpp",
 ]
 
 // Various kinds of cruft.
@@ -68,58 +36,38 @@
     "bionic/time64.c",
 ]
 
+libc_common_flags = [
+    "-D_LIBC=1",
+    "-Wall",
+    "-Wextra",
+    "-Wunused",
+    "-Wno-deprecated-declarations",
+    "-Wframe-larger-than=2048",
+
+    // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
+    "-Werror=pointer-to-int-cast",
+    "-Werror=int-to-pointer-cast",
+    "-Werror=type-limits",
+    "-Werror",
+]
+
 // Define some common cflags
 // ========================================================
 cc_defaults {
     name: "libc_defaults",
-    cflags: [
-        "-D_LIBC=1",
-        "-Wall",
-        "-Wextra",
-        "-Wunused",
-
-        // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
-        "-Werror=pointer-to-int-cast",
-        "-Werror=int-to-pointer-cast",
-        "-Werror=type-limits",
-        "-Werror",
-    ],
-    // TODO: split out the asflags.
-    asflags: [
-        "-D_LIBC=1",
-        "-Wall",
-        "-Wextra",
-        "-Wunused",
-
-        // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
-        "-Werror=pointer-to-int-cast",
-        "-Werror=int-to-pointer-cast",
-        "-Werror=type-limits",
-        "-Werror",
-    ],
+    cflags: libc_common_flags,
+    asflags: libc_common_flags,
     conlyflags: ["-std=gnu99"],
     cppflags: [],
     include_dirs: ["external/jemalloc/include"],
 
-    arch: {
-        // Clang/llvm has incompatible long double (fp128) for x86_64.
-        // https://llvm.org/bugs/show_bug.cgi?id=23897
-        x86_64: {
-            clang: false,
-        },
-        // b/25291096, Clang/llvm compiled libc.so for mips/mips64 failed to boot.
-        mips: {
-            clang: false,
-        },
-        mips64: {
-            clang: false,
-        },
-    },
-
     stl: "none",
     system_shared_libs: [],
-    sanitize: ["never"],
+    sanitize: {
+        never: true,
+    },
     native_coverage: false,
+    clang: true,
 }
 
 // ANDROIDMK TRANSLATION ERROR: unsupported directive
@@ -148,7 +96,7 @@
             srcs: ["arch-arm64/bionic/__set_tls.c"],
         },
         x86: {
-            srcs: ["arch-x86/bionic/__set_tls.c"],
+            srcs: ["arch-x86/bionic/__set_tls.cpp"],
         },
         x86_64: {
             srcs: ["arch-x86_64/bionic/__set_tls.c"],
@@ -186,7 +134,6 @@
     ],
 
     cflags: [
-        "-fvisibility=hidden",
         "-Wno-unused-parameter",
         // Don't use ridiculous amounts of stack.
         "-DALL_STATE",
@@ -197,12 +144,13 @@
         // The name of the tm_gmtoff field in our struct tm.
         "-DTM_GMTOFF=tm_gmtoff",
         // Where we store our tzdata.
-        "-DTZDIR=\\\"/system/usr/share/zoneinfo\\\"",
-        // Include timezone and daylight globals.
+        "-DTZDIR=\"/system/usr/share/zoneinfo\"",
+        // Include `tzname`, `timezone`, and `daylight` globals.
+        "-DHAVE_POSIX_DECLS=0",
         "-DUSG_COMPAT=1",
         // Use the empty string (instead of "   ") as the timezone abbreviation
         // fallback.
-        "-DWILDABBR=\\\"\\\"",
+        "-DWILDABBR=\"\"",
         "-DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU",
         "-Dlint",
     ],
@@ -229,9 +177,9 @@
     cflags: [
         "-DANDROID_CHANGES",
         "-DINET6",
-        "-fvisibility=hidden",
         "-Wno-unused-parameter",
         "-include netbsd-compat.h",
+        "-Wframe-larger-than=66000",
     ],
 
     local_include_dirs: [
@@ -260,7 +208,6 @@
         "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
         "upstream-freebsd/lib/libc/stdlib/qsort.c",
         "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
-        "upstream-freebsd/lib/libc/stdlib/realpath.c",
         "upstream-freebsd/lib/libc/string/wcpcpy.c",
         "upstream-freebsd/lib/libc/string/wcpncpy.c",
         "upstream-freebsd/lib/libc/string/wcscasecmp.c",
@@ -331,6 +278,25 @@
     name: "libc_freebsd",
 }
 
+cc_library_static {
+    defaults: ["libc_defaults"],
+    srcs: [
+        "upstream-freebsd/lib/libc/stdlib/realpath.c",
+    ],
+
+    cflags: [
+        "-Wno-sign-compare",
+        "-include freebsd-compat.h",
+        "-Wframe-larger-than=15000",
+    ],
+
+    local_include_dirs: [
+        "upstream-freebsd/android/include",
+    ],
+
+    name: "libc_freebsd_large_stack",
+}
+
 // ========================================================
 // libc_netbsd.a - upstream NetBSD C library code
 // ========================================================
@@ -343,8 +309,6 @@
     defaults: ["libc_defaults"],
     srcs: [
         "upstream-netbsd/common/lib/libc/stdlib/random.c",
-        "upstream-netbsd/lib/libc/gen/ftw.c",
-        "upstream-netbsd/lib/libc/gen/nftw.c",
         "upstream-netbsd/lib/libc/gen/nice.c",
         "upstream-netbsd/lib/libc/gen/popen.c",
         "upstream-netbsd/lib/libc/gen/psignal.c",
@@ -417,7 +381,6 @@
         "upstream-openbsd/lib/libc/gen/daemon.c",
         "upstream-openbsd/lib/libc/gen/err.c",
         "upstream-openbsd/lib/libc/gen/errx.c",
-        "upstream-openbsd/lib/libc/gen/exec.c",
         "upstream-openbsd/lib/libc/gen/fnmatch.c",
         "upstream-openbsd/lib/libc/gen/ftok.c",
         "upstream-openbsd/lib/libc/gen/getprogname.c",
@@ -437,11 +400,8 @@
         "upstream-openbsd/lib/libc/locale/mbstowcs.c",
         "upstream-openbsd/lib/libc/locale/mbtowc.c",
         "upstream-openbsd/lib/libc/locale/wcscoll.c",
-        "upstream-openbsd/lib/libc/locale/wcstod.c",
-        "upstream-openbsd/lib/libc/locale/wcstof.c",
         "upstream-openbsd/lib/libc/locale/wcstoimax.c",
         "upstream-openbsd/lib/libc/locale/wcstol.c",
-        "upstream-openbsd/lib/libc/locale/wcstold.c",
         "upstream-openbsd/lib/libc/locale/wcstoll.c",
         "upstream-openbsd/lib/libc/locale/wcstombs.c",
         "upstream-openbsd/lib/libc/locale/wcstoul.c",
@@ -450,6 +410,7 @@
         "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
         "upstream-openbsd/lib/libc/locale/wctob.c",
         "upstream-openbsd/lib/libc/locale/wctomb.c",
+        "upstream-openbsd/lib/libc/net/base64.c",
         "upstream-openbsd/lib/libc/net/htonl.c",
         "upstream-openbsd/lib/libc/net/htons.c",
         "upstream-openbsd/lib/libc/net/inet_lnaof.c",
@@ -461,88 +422,48 @@
         "upstream-openbsd/lib/libc/net/ntohl.c",
         "upstream-openbsd/lib/libc/net/ntohs.c",
         "upstream-openbsd/lib/libc/net/res_random.c",
-        "upstream-openbsd/lib/libc/stdio/asprintf.c",
-        "upstream-openbsd/lib/libc/stdio/clrerr.c",
-        "upstream-openbsd/lib/libc/stdio/dprintf.c",
-        "upstream-openbsd/lib/libc/stdio/feof.c",
-        "upstream-openbsd/lib/libc/stdio/ferror.c",
         "upstream-openbsd/lib/libc/stdio/fflush.c",
-        "upstream-openbsd/lib/libc/stdio/fgetc.c",
         "upstream-openbsd/lib/libc/stdio/fgetln.c",
         "upstream-openbsd/lib/libc/stdio/fgets.c",
         "upstream-openbsd/lib/libc/stdio/fgetwc.c",
         "upstream-openbsd/lib/libc/stdio/fgetws.c",
         "upstream-openbsd/lib/libc/stdio/flags.c",
         "upstream-openbsd/lib/libc/stdio/fmemopen.c",
-        "upstream-openbsd/lib/libc/stdio/fprintf.c",
         "upstream-openbsd/lib/libc/stdio/fpurge.c",
-        "upstream-openbsd/lib/libc/stdio/fputc.c",
         "upstream-openbsd/lib/libc/stdio/fputs.c",
         "upstream-openbsd/lib/libc/stdio/fputwc.c",
         "upstream-openbsd/lib/libc/stdio/fputws.c",
-        "upstream-openbsd/lib/libc/stdio/fscanf.c",
         "upstream-openbsd/lib/libc/stdio/fvwrite.c",
         "upstream-openbsd/lib/libc/stdio/fwalk.c",
         "upstream-openbsd/lib/libc/stdio/fwide.c",
-        "upstream-openbsd/lib/libc/stdio/fwprintf.c",
         "upstream-openbsd/lib/libc/stdio/fwrite.c",
-        "upstream-openbsd/lib/libc/stdio/fwscanf.c",
-        "upstream-openbsd/lib/libc/stdio/getc.c",
-        "upstream-openbsd/lib/libc/stdio/getchar.c",
         "upstream-openbsd/lib/libc/stdio/getdelim.c",
-        "upstream-openbsd/lib/libc/stdio/getline.c",
         "upstream-openbsd/lib/libc/stdio/gets.c",
-        "upstream-openbsd/lib/libc/stdio/getwc.c",
-        "upstream-openbsd/lib/libc/stdio/getwchar.c",
         "upstream-openbsd/lib/libc/stdio/makebuf.c",
         "upstream-openbsd/lib/libc/stdio/mktemp.c",
         "upstream-openbsd/lib/libc/stdio/open_memstream.c",
         "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
         "upstream-openbsd/lib/libc/stdio/perror.c",
-        "upstream-openbsd/lib/libc/stdio/printf.c",
-        "upstream-openbsd/lib/libc/stdio/putc.c",
-        "upstream-openbsd/lib/libc/stdio/putchar.c",
         "upstream-openbsd/lib/libc/stdio/puts.c",
-        "upstream-openbsd/lib/libc/stdio/putwc.c",
-        "upstream-openbsd/lib/libc/stdio/putwchar.c",
-        "upstream-openbsd/lib/libc/stdio/remove.c",
-        "upstream-openbsd/lib/libc/stdio/rewind.c",
         "upstream-openbsd/lib/libc/stdio/rget.c",
-        "upstream-openbsd/lib/libc/stdio/scanf.c",
-        "upstream-openbsd/lib/libc/stdio/setbuf.c",
-        "upstream-openbsd/lib/libc/stdio/setbuffer.c",
         "upstream-openbsd/lib/libc/stdio/setvbuf.c",
-        "upstream-openbsd/lib/libc/stdio/sscanf.c",
-        "upstream-openbsd/lib/libc/stdio/swprintf.c",
-        "upstream-openbsd/lib/libc/stdio/swscanf.c",
         "upstream-openbsd/lib/libc/stdio/tempnam.c",
         "upstream-openbsd/lib/libc/stdio/tmpnam.c",
         "upstream-openbsd/lib/libc/stdio/ungetc.c",
         "upstream-openbsd/lib/libc/stdio/ungetwc.c",
         "upstream-openbsd/lib/libc/stdio/vasprintf.c",
         "upstream-openbsd/lib/libc/stdio/vdprintf.c",
-        "upstream-openbsd/lib/libc/stdio/vfprintf.c",
-        "upstream-openbsd/lib/libc/stdio/vfscanf.c",
-        "upstream-openbsd/lib/libc/stdio/vfwprintf.c",
-        "upstream-openbsd/lib/libc/stdio/vfwscanf.c",
-        "upstream-openbsd/lib/libc/stdio/vprintf.c",
-        "upstream-openbsd/lib/libc/stdio/vscanf.c",
-        "upstream-openbsd/lib/libc/stdio/vsnprintf.c",
-        "upstream-openbsd/lib/libc/stdio/vsprintf.c",
         "upstream-openbsd/lib/libc/stdio/vsscanf.c",
         "upstream-openbsd/lib/libc/stdio/vswprintf.c",
         "upstream-openbsd/lib/libc/stdio/vswscanf.c",
-        "upstream-openbsd/lib/libc/stdio/vwprintf.c",
-        "upstream-openbsd/lib/libc/stdio/vwscanf.c",
         "upstream-openbsd/lib/libc/stdio/wbuf.c",
-        "upstream-openbsd/lib/libc/stdio/wprintf.c",
-        "upstream-openbsd/lib/libc/stdio/wscanf.c",
         "upstream-openbsd/lib/libc/stdio/wsetup.c",
         "upstream-openbsd/lib/libc/stdlib/abs.c",
         "upstream-openbsd/lib/libc/stdlib/atoi.c",
         "upstream-openbsd/lib/libc/stdlib/atol.c",
         "upstream-openbsd/lib/libc/stdlib/atoll.c",
         "upstream-openbsd/lib/libc/stdlib/getenv.c",
+        "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
         "upstream-openbsd/lib/libc/stdlib/insque.c",
         "upstream-openbsd/lib/libc/stdlib/imaxabs.c",
         "upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
@@ -592,6 +513,27 @@
     ],
 }
 
+cc_library_static {
+    name: "libc_openbsd_large_stack",
+    defaults: ["libc_defaults"],
+    srcs: [
+        "upstream-openbsd/lib/libc/stdio/vfprintf.c",
+        "upstream-openbsd/lib/libc/stdio/vfwprintf.c",
+    ],
+    cflags: [
+        "-include openbsd-compat.h",
+        "-Wno-sign-compare",
+        "-Wframe-larger-than=5000",
+    ],
+
+    local_include_dirs: [
+        "stdio",
+        "upstream-openbsd/android/include",
+        "upstream-openbsd/lib/libc/include",
+        "upstream-openbsd/lib/libc/gdtoa/",
+    ],
+}
+
 // ========================================================
 // libc_openbsd.a - upstream OpenBSD C library code
 // ========================================================
@@ -619,12 +561,6 @@
         "upstream-openbsd/lib/libc/string/strncmp.c",
         "upstream-openbsd/lib/libc/string/strncpy.c",
     ],
-    multilib: {
-        lib32: {
-            // LP32 cruft
-            srcs: ["upstream-openbsd/lib/libc/stdio/putw.c"],
-        },
-    },
 
     arch: {
         arm: {
@@ -744,10 +680,7 @@
 
     local_include_dirs: [
         "private",
-        "stdio",
         "upstream-openbsd/android/include",
-        "upstream-openbsd/lib/libc/include",
-        "upstream-openbsd/lib/libc/gdtoa/",
     ],
 
     name: "libc_openbsd",
@@ -791,7 +724,6 @@
     cflags: [
         "-Wno-sign-compare",
         "-Wno-uninitialized",
-        "-fvisibility=hidden",
         "-include openbsd-compat.h",
     ],
 
@@ -830,14 +762,12 @@
         "bionic/setjmp_cookie.cpp",
 
         "bionic/__memcpy_chk.cpp",
-        "bionic/__memset_chk.cpp",
         "bionic/__strcat_chk.cpp",
         "bionic/__strcpy_chk.cpp",
         "bionic/strchr.cpp",
         "bionic/strnlen.c",
         "bionic/strrchr.cpp",
     ],
-    cflags: ["-Wframe-larger-than=2048"],
 
     arch: {
         arm: {
@@ -862,7 +792,6 @@
             ],
             exclude_srcs: [
                 "bionic/__memcpy_chk.cpp",
-                "bionic/__memset_chk.cpp",
             ],
             cortex_a7: {
                 srcs: [
@@ -1109,22 +1038,23 @@
                 "arch-mips/string/memcpy.S",
                 "arch-mips/string/memset.S",
                 "arch-mips/string/strcmp.S",
-                "arch-mips/string/strlen.c",
 
                 "arch-mips/bionic/__bionic_clone.S",
-                "arch-mips/bionic/bzero.S",
                 "arch-mips/bionic/cacheflush.cpp",
                 "arch-mips/bionic/_exit_with_stack_teardown.S",
+                "arch-mips/bionic/libgcc_compat.c",
                 "arch-mips/bionic/setjmp.S",
                 "arch-mips/bionic/syscall.S",
                 "arch-mips/bionic/vfork.S",
+
+                "arch-mips/string/mips_strlen.c",
             ],
             rev6: {
                 srcs: [
-                    "arch-mips/string/mips_strlen.c",
+                    "arch-mips/string/strlen.c",
                 ],
                 exclude_srcs: [
-                    "arch-mips/string/strlen.c",
+                    "arch-mips/string/mips_strlen.c",
                 ],
             },
         },
@@ -1160,8 +1090,6 @@
                 "arch-x86/atom/string/sse2-wcsrchr-atom.S",
                 "arch-x86/atom/string/sse2-wcslen-atom.S",
                 "arch-x86/atom/string/sse2-wcscmp-atom.S",
-                "arch-x86/silvermont/string/sse2-bcopy-slm.S",
-                "arch-x86/silvermont/string/sse2-bzero-slm.S",
                 "arch-x86/silvermont/string/sse2-memcpy-slm.S",
                 "arch-x86/silvermont/string/sse2-memmove-slm.S",
                 "arch-x86/silvermont/string/sse2-memset-slm.S",
@@ -1187,10 +1115,8 @@
             ],
             atom: {
                 srcs: [
-                    "arch-x86/atom/string/sse2-bzero-atom.S",
                     "arch-x86/atom/string/sse2-memset-atom.S",
                     "arch-x86/atom/string/sse2-strlen-atom.S",
-                    "arch-x86/atom/string/ssse3-bcopy-atom.S",
                     "arch-x86/atom/string/ssse3-memcmp-atom.S",
                     "arch-x86/atom/string/ssse3-memcpy-atom.S",
                     "arch-x86/atom/string/ssse3-memmove-atom.S",
@@ -1200,8 +1126,6 @@
                 ],
                 exclude_srcs: [
                     "arch-x86/generic/string/memcmp.S",
-                    "arch-x86/silvermont/string/sse2-bcopy-slm.S",
-                    "arch-x86/silvermont/string/sse2-bzero-slm.S",
                     "arch-x86/silvermont/string/sse2-memcpy-slm.S",
                     "arch-x86/silvermont/string/sse2-memmove-slm.S",
                     "arch-x86/silvermont/string/sse2-memset-slm.S",
@@ -1311,6 +1235,7 @@
         "bionic/error.cpp",
         "bionic/eventfd_read.cpp",
         "bionic/eventfd_write.cpp",
+        "bionic/exec.cpp",
         "bionic/faccessat.cpp",
         "bionic/fchmod.cpp",
         "bionic/fchmodat.cpp",
@@ -1318,16 +1243,21 @@
         "bionic/fgetxattr.cpp",
         "bionic/flistxattr.cpp",
         "bionic/flockfile.cpp",
+        "bionic/fortify.cpp",
         "bionic/fpclassify.cpp",
         "bionic/fsetxattr.cpp",
         "bionic/ftruncate.cpp",
+        "bionic/ftw.cpp",
         "bionic/futimens.cpp",
         "bionic/getcwd.cpp",
+        "bionic/getdomainname.cpp",
         "bionic/gethostname.cpp",
+        "bionic/getpagesize.cpp",
         "bionic/getpgrp.cpp",
         "bionic/getpid.cpp",
         "bionic/gettid.cpp",
         "bionic/__gnu_basename.cpp",
+        "bionic/grp_pwd.cpp",
         "bionic/ifaddrs.cpp",
         "bionic/inotify_init.cpp",
         "bionic/ioctl.cpp",
@@ -1343,18 +1273,22 @@
         "bionic/lockf.cpp",
         "bionic/lstat.cpp",
         "bionic/malloc_info.cpp",
+        "bionic/mblen.cpp",
         "bionic/mbrtoc16.cpp",
         "bionic/mbrtoc32.cpp",
         "bionic/mbstate.cpp",
+        "bionic/memmem.cpp",
         "bionic/mempcpy.cpp",
         "bionic/mkdir.cpp",
         "bionic/mkfifo.cpp",
         "bionic/mknod.cpp",
         "bionic/mntent.cpp",
         "bionic/mremap.cpp",
+        "bionic/netdb.cpp",
         "bionic/NetdClientDispatch.cpp",
         "bionic/net_if.cpp",
         "bionic/netinet_in.cpp",
+        "bionic/nl_types.cpp",
         "bionic/open.cpp",
         "bionic/pathconf.cpp",
         "bionic/pause.cpp",
@@ -1387,12 +1321,17 @@
         "bionic/sigdelset.cpp",
         "bionic/sigemptyset.cpp",
         "bionic/sigfillset.cpp",
+        "bionic/sighold.cpp",
+        "bionic/sigignore.cpp",
         "bionic/sigismember.cpp",
         "bionic/signal.cpp",
         "bionic/signalfd.cpp",
+        "bionic/sigpause.cpp",
         "bionic/sigpending.cpp",
         "bionic/sigprocmask.cpp",
         "bionic/sigqueue.cpp",
+        "bionic/sigrelse.cpp",
+        "bionic/sigset.cpp",
         "bionic/sigsuspend.cpp",
         "bionic/sigtimedwait.cpp",
         "bionic/sigwait.cpp",
@@ -1405,12 +1344,16 @@
         "bionic/strerror_r.cpp",
         "bionic/strsignal.cpp",
         "bionic/strtold.cpp",
-        "bionic/stubs.cpp",
         "bionic/symlink.cpp",
+        "bionic/sync_file_range.cpp",
         "bionic/sysinfo.cpp",
         "bionic/syslog.cpp",
+        "bionic/sys_msg.cpp",
+        "bionic/sys_sem.cpp",
+        "bionic/sys_shm.cpp",
         "bionic/sys_siglist.c",
         "bionic/sys_signame.c",
+        "bionic/sys_time.cpp",
         "bionic/system_properties.cpp",
         "bionic/tdestroy.cpp",
         "bionic/termios.cpp",
@@ -1418,13 +1361,12 @@
         "bionic/tmpfile.cpp",
         "bionic/umount.cpp",
         "bionic/unlink.cpp",
-        "bionic/utimes.cpp",
         "bionic/wait.cpp",
         "bionic/wchar.cpp",
+        "bionic/wcstod.cpp",
         "bionic/wctype.cpp",
         "bionic/wmempcpy.cpp",
     ],
-    cflags: ["-Wframe-larger-than=2048"],
 
     multilib: {
         lib32: {
@@ -1474,7 +1416,6 @@
         "bionic/pthread_sigmask.cpp",
         "bionic/pthread_spinlock.cpp",
     ],
-    cflags: ["-Wframe-larger-than=2048"],
 
     cppflags: ["-Wold-style-cast"],
     include_dirs: ["bionic/libstdc++/include"],
@@ -1482,36 +1423,11 @@
 }
 
 // ========================================================
-// libc_cxa.a - Things traditionally in libstdc++
-// ========================================================
-
-cc_library_static {
-    defaults: ["libc_defaults"],
-    srcs: [
-        "bionic/__cxa_guard.cpp",
-        "bionic/__cxa_pure_virtual.cpp",
-        "bionic/new.cpp",
-    ],
-    cflags: ["-fvisibility=hidden"],
-    include_dirs: ["bionic/libstdc++/include"],
-    name: "libc_cxa",
-    clang: true, // GCC refuses to hide new/delete
-
-    // b/17574078: Need to disable coverage until we have a prebuilt libprofile_rt.
-    // Since this is a static library built with clang, it needs to link
-    // libprofile_rt when it is linked into the final binary. Since the final binary
-    // is built with GCC, it won't link libprofile_rt. We can't very easily just add
-    // libprofile_rt to all link lines the way we've done for libgcov because
-    // libprofile_rt isn't prebuilt, and it would be tricky to write a rule that
-    // would make sure libprofile_rt is built.
-    native_coverage: false,
-}
-
-// ========================================================
 // libc_syscalls.a
 // ========================================================
 
 cc_library_static {
+    defaults: ["libc_defaults"],
     arch: {
         arm: {
             srcs: ["arch-arm/syscalls/**/*.S"],
@@ -1593,17 +1509,19 @@
 
     whole_static_libs: [
         "libc_bionic_ndk",
-        "libc_cxa",
         "libc_freebsd",
+        "libc_freebsd_large_stack",
         "libc_gdtoa",
         "libc_malloc",
         "libc_netbsd",
+        "libc_openbsd_large_stack",
         "libc_openbsd_ndk",
         "libc_stack_protector",
         "libc_syscalls",
         "libc_tzcode",
         "libm",
         "libjemalloc",
+        "libstdc++",
     ],
 }
 
@@ -1624,18 +1542,20 @@
     whole_static_libs: [
         "libc_bionic",
         "libc_bionic_ndk",
-        "libc_cxa",
         "libc_dns",
         "libc_freebsd",
+        "libc_freebsd_large_stack",
         "libc_gdtoa",
         "libc_malloc",
         "libc_netbsd",
         "libc_openbsd",
+        "libc_openbsd_large_stack",
         "libc_openbsd_ndk",
         "libc_pthread",
         "libc_stack_protector",
         "libc_syscalls",
         "libc_tzcode",
+        "libstdc++",
     ],
 
     arch: {
@@ -1699,30 +1619,34 @@
             asflags: ["-DPLATFORM_SDK_VERSION=%d"],
         },
     },
-    srcs: ["bionic/malloc_common.cpp"],
     static: {
         srcs: [
             "bionic/dl_iterate_phdr_static.cpp",
+            "bionic/malloc_common.cpp",
             "bionic/libc_init_static.cpp",
         ],
         cflags: ["-DLIBC_STATIC"],
-        whole_static_libs: ["libc_init_static"],
+        whole_static_libs: ["libc_init_static", "libjemalloc"],
     },
     shared: {
         srcs: [
             "arch-common/bionic/crtbegin_so.c",
             "arch-common/bionic/crtbrand.S",
+            "bionic/malloc_common.cpp",
             "bionic/libc_init_dynamic.cpp",
             "bionic/NetdClient.cpp",
             "arch-common/bionic/crtend_so.S",
         ],
+        whole_static_libs: ["libjemalloc"],
     },
 
     required: ["tzdata"],
 
     // Leave the symbols in the shared library so that stack unwinders can produce
     // meaningful name resolution.
-    strip: "keep_symbols",
+    strip: {
+        keep_symbols: true,
+    },
 
     // WARNING: The only library libc.so should depend on is libdl.so!  If you add other libraries,
     // make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries.  This
@@ -1733,16 +1657,7 @@
     // you wanted!
 
     shared_libs: ["libdl"],
-    whole_static_libs: ["libc_common", "libjemalloc"],
-
-    // We'd really like to do this for all architectures, but since this wasn't done
-    // before, these symbols must continue to be exported on LP32 for binary
-    // compatibility.
-    multilib: {
-        lib64: {
-            ldflags: ["-Wl,--exclude-libs,libgcc.a"],
-        },
-    },
+    whole_static_libs: ["libc_common"],
 
     nocrt: true,
 
@@ -1753,24 +1668,20 @@
 
             // Don't re-export new/delete and friends, even if the compiler really wants to.
             version_script: "libc.arm.map",
-            product_variables: {
-                brillo: {
-                    version_script: "libc.arm.brillo.map",
-                },
-            },
 
             shared: {
-                srcs: ["arch-arm/bionic/exidx_dynamic.c"],
+                srcs: [
+                    "arch-arm/bionic/exidx_dynamic.c",
+
+                    // special for arm
+                    "arch-arm/bionic/atexit_legacy.c",
+                ],
+                // special for arm
+                cflags: ["-DCRT_LEGACY_WORKAROUND"],
             },
             static: {
                 srcs: ["arch-arm/bionic/exidx_static.c"],
             },
-
-            // special for arm
-            cflags: ["-DCRT_LEGACY_WORKAROUND"],
-            srcs: [
-                "arch-arm/bionic/atexit_legacy.c",
-            ],
         },
         arm64: {
             // Don't re-export new/delete and friends, even if the compiler really wants to.
@@ -1779,11 +1690,6 @@
         mips: {
             // Don't re-export new/delete and friends, even if the compiler really wants to.
             version_script: "libc.mips.map",
-            product_variables: {
-                brillo: {
-                    version_script: "libc.mips.brillo.map",
-                },
-            },
         },
         mips64: {
             // Don't re-export new/delete and friends, even if the compiler really wants to.
@@ -1795,11 +1701,6 @@
 
             // Don't re-export new/delete and friends, even if the compiler really wants to.
             version_script: "libc.x86.map",
-            product_variables: {
-                brillo: {
-                    version_script: "libc.x86.brillo.map",
-                },
-            },
         },
         x86_64: {
             // Don't re-export new/delete and friends, even if the compiler really wants to.
@@ -1838,13 +1739,27 @@
         static_libs: ["libc_logging"],
     },
 
-    //TODO: This is to work around b/24465209. Remove after root cause is fixed
+    //TODO (dimitry): This is to work around b/24465209. Remove after root cause is fixed
     arch: {
         arm: {
             ldflags: ["-Wl,--hash-style=both"],
+            version_script: "libstdc++.arm.map",
+        },
+        arm64: {
+            version_script: "libstdc++.arm64.map",
+        },
+        mips: {
+            version_script: "libstdc++.mips.map",
+        },
+        mips64: {
+            version_script: "libstdc++.mips64.map",
         },
         x86: {
             ldflags: ["-Wl,--hash-style=both"],
+            version_script: "libstdc++.x86.map",
+        },
+        x86_64: {
+            version_script: "libstdc++.x86_64.map",
         },
     },
 }
@@ -1952,7 +1867,7 @@
         "crt_defaults",
         "crt_so_defaults",
     ],
-    deps: [
+    objs: [
         "crtbegin_so1",
         "crtbrand",
     ],
@@ -2010,7 +1925,7 @@
 cc_object {
     name: "crtbegin_static",
 
-    deps: [
+    objs: [
         "crtbegin_static1",
         "crtbrand",
     ],
@@ -2056,7 +1971,7 @@
 cc_object {
     name: "crtbegin_dynamic",
 
-    deps: [
+    objs: [
         "crtbegin_dynamic1",
         "crtbrand",
     ],
@@ -2073,3 +1988,147 @@
 
     defaults: ["crt_defaults"],
 }
+
+// The following module lives in prebuilts/ndk because we need to preprocess the
+// headers to include ifdef guards for __ANDROID_API__. Update with
+// bionic/tools/update_headers.sh.
+// ndk_headers {
+//     name: "common_libc",
+//     from: "include",
+//     to: "",
+//     srcs: ["include/**/*.h"],
+// }
+
+ndk_headers {
+    name: "libc_linux",
+    from: "kernel/uapi/linux",
+    to: "linux",
+    srcs: ["kernel/uapi/linux/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_android",
+    from: "kernel/android/uapi/linux",
+    to: "linux",
+    srcs: ["kernel/android/uapi/linux/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_asm_generic",
+    from: "kernel/uapi/asm-generic",
+    to: "asm-generic",
+    srcs: ["kernel/uapi/asm-generic/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_asm_arm",
+    from: "kernel/uapi/asm-arm",
+    to: "arm-linux-androideabi",
+    srcs: ["kernel/uapi/asm-arm/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_asm_arm64",
+    from: "kernel/uapi/asm-arm64",
+    to: "aarch64-linux-android",
+    srcs: ["kernel/uapi/asm-arm64/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_asm_mips",
+    from: "kernel/uapi/asm-mips",
+    to: "mipsel-linux-android",
+    srcs: ["kernel/uapi/asm-mips/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_asm_mips64",
+    from: "kernel/uapi/asm-mips",
+    to: "mips64el-linux-android",
+    srcs: ["kernel/uapi/asm-mips/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_asm_x86",
+    from: "kernel/uapi/asm-x86",
+    to: "i686-linux-android",
+    srcs: ["kernel/uapi/asm-x86/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_asm_x86_64",
+    from: "kernel/uapi/asm-x86",
+    to: "x86_64-linux-android",
+    srcs: ["kernel/uapi/asm-x86/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_machine_arm",
+    from: "arch-arm/include",
+    to: "arm-linux-androideabi",
+    srcs: ["arch-arm/include/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_machine_arm64",
+    from: "arch-arm64/include",
+    to: "aarch64-linux-android",
+    srcs: ["arch-arm64/include/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_machine_mips",
+    from: "arch-mips/include",
+    to: "mipsel-linux-android",
+    srcs: ["arch-mips/include/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_machine_mips64",
+    from: "arch-mips/include",
+    to: "mips64el-linux-android",
+    srcs: ["arch-mips/include/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_machine_x86",
+    from: "arch-x86/include",
+    to: "i686-linux-android",
+    srcs: ["arch-x86/include/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_headers {
+    name: "libc_machine_x86_64",
+    from: "arch-x86_64/include",
+    to: "x86_64-linux-android",
+    srcs: ["arch-x86_64/include/**/*.h"],
+    license: "NOTICE",
+}
+
+ndk_library {
+    name: "libc.ndk",
+    symbol_file: "libc.map.txt",
+    first_version: "9",
+}
+
+ndk_library {
+    name: "libstdc++.ndk",
+    symbol_file: "libstdc++.map.txt",
+    first_version: "9",
+}
+
+subdirs = ["malloc_debug"]
diff --git a/libc/Android.mk b/libc/Android.mk
index 1ca84c1..888404c 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -1,1520 +1,4 @@
 LOCAL_PATH := $(call my-dir)
 
-bionic_coverage ?= false
-
-# Make everything depend on any changes to included makefiles.
-libc_common_additional_dependencies := $(LOCAL_PATH)/Android.mk
-
-# Load config for TARGET_ARCH
-my_2nd_arch_prefix :=
-include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/$(TARGET_ARCH).mk
-libc_common_additional_dependencies += \
-    $(LOCAL_PATH)/arch-$(TARGET_ARCH)/$(TARGET_ARCH).mk
-
-
-ifdef TARGET_2ND_ARCH
-# Load config for TARGET_2ND_ARCH
-my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
-include $(LOCAL_PATH)/arch-$(TARGET_2ND_ARCH)/$(TARGET_2ND_ARCH).mk
-my_2nd_arch_prefix :=
-libc_common_additional_dependencies += \
-    $(LOCAL_PATH)/arch-$(TARGET_2ND_ARCH)/$(TARGET_2ND_ARCH).mk
-endif
-
-# crt obj files
-# ========================================================
-# crtbrand.c needs <stdint.h> and a #define for the platform SDK version.
-libc_crt_target_cflags := \
-    -I$(LOCAL_PATH)/include \
-    -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) \
-
-my_2nd_arch_prefix :=
-include $(LOCAL_PATH)/crt.mk
-ifdef TARGET_2ND_ARCH
-my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
-include $(LOCAL_PATH)/crt.mk
-my_2nd_arch_prefix :=
-endif
-
-# Define the common source files for all the libc instances
-# =========================================================
-libc_common_src_files := \
-    bionic/ether_aton.c \
-    bionic/ether_ntoa.c \
-    bionic/fts.c \
-    bionic/getpriority.c \
-    bionic/initgroups.c \
-    bionic/isatty.c \
-    bionic/memmem.c \
-    bionic/pututline.c \
-    bionic/sched_cpualloc.c \
-    bionic/sched_cpucount.c \
-    bionic/sigblock.c \
-    bionic/siginterrupt.c \
-    bionic/sigsetmask.c \
-    bionic/system_properties_compat.c \
-    stdio/fread.c \
-    stdio/refill.c \
-    stdio/snprintf.c\
-    stdio/sprintf.c \
-    stdio/stdio.cpp \
-    stdio/stdio_ext.cpp \
-    stdlib/atexit.c \
-    stdlib/exit.c \
-
-# Fortify implementations of libc functions.
-libc_common_src_files += \
-    bionic/__FD_chk.cpp \
-    bionic/__fgets_chk.cpp \
-    bionic/__fread_chk.cpp \
-    bionic/__fwrite_chk.cpp \
-    bionic/__getcwd_chk.cpp \
-    bionic/__memchr_chk.cpp \
-    bionic/__memmove_chk.cpp \
-    bionic/__memrchr_chk.cpp \
-    bionic/__poll_chk.cpp \
-    bionic/__pread64_chk.cpp \
-    bionic/__pread_chk.cpp \
-    bionic/__pwrite64_chk.cpp \
-    bionic/__pwrite_chk.cpp \
-    bionic/__read_chk.cpp \
-    bionic/__readlink_chk.cpp \
-    bionic/__readlinkat_chk.cpp \
-    bionic/__recvfrom_chk.cpp \
-    bionic/__stpcpy_chk.cpp \
-    bionic/__stpncpy_chk.cpp \
-    bionic/__strchr_chk.cpp \
-    bionic/__strlcat_chk.cpp \
-    bionic/__strlcpy_chk.cpp \
-    bionic/__strlen_chk.cpp \
-    bionic/__strncat_chk.cpp \
-    bionic/__strncpy_chk.cpp \
-    bionic/__strrchr_chk.cpp \
-    bionic/__umask_chk.cpp \
-    bionic/__vsnprintf_chk.cpp \
-    bionic/__vsprintf_chk.cpp \
-    bionic/__write_chk.cpp
-
-libc_bionic_ndk_src_files := \
-    bionic/abort.cpp \
-    bionic/accept.cpp \
-    bionic/accept4.cpp \
-    bionic/access.cpp \
-    bionic/arpa_inet.cpp \
-    bionic/assert.cpp \
-    bionic/atof.cpp \
-    bionic/bionic_netlink.cpp \
-    bionic/bionic_systrace.cpp \
-    bionic/bionic_time_conversions.cpp \
-    bionic/brk.cpp \
-    bionic/c16rtomb.cpp \
-    bionic/c32rtomb.cpp \
-    bionic/chmod.cpp \
-    bionic/chown.cpp \
-    bionic/clearenv.cpp \
-    bionic/clock.cpp \
-    bionic/clock_getcpuclockid.cpp \
-    bionic/clock_nanosleep.cpp \
-    bionic/clone.cpp \
-    bionic/close.cpp \
-    bionic/__cmsg_nxthdr.cpp \
-    bionic/connect.cpp \
-    bionic/ctype.cpp \
-    bionic/dirent.cpp \
-    bionic/dup2.cpp \
-    bionic/epoll_create.cpp \
-    bionic/epoll_pwait.cpp \
-    bionic/epoll_wait.cpp \
-    bionic/__errno.cpp \
-    bionic/error.cpp \
-    bionic/eventfd_read.cpp \
-    bionic/eventfd_write.cpp \
-    bionic/faccessat.cpp \
-    bionic/fchmod.cpp \
-    bionic/fchmodat.cpp \
-    bionic/ffs.cpp \
-    bionic/fgetxattr.cpp \
-    bionic/flistxattr.cpp \
-    bionic/flockfile.cpp \
-    bionic/fpclassify.cpp \
-    bionic/fsetxattr.cpp \
-    bionic/ftruncate.cpp \
-    bionic/futimens.cpp \
-    bionic/getcwd.cpp \
-    bionic/gethostname.cpp \
-    bionic/getpgrp.cpp \
-    bionic/getpid.cpp \
-    bionic/gettid.cpp \
-    bionic/__gnu_basename.cpp \
-    bionic/ifaddrs.cpp \
-    bionic/inotify_init.cpp \
-    bionic/ioctl.cpp \
-    bionic/lchown.cpp \
-    bionic/lfs64_support.cpp \
-    bionic/__libc_current_sigrtmax.cpp \
-    bionic/__libc_current_sigrtmin.cpp \
-    bionic/libc_init_common.cpp \
-    bionic/libc_logging.cpp \
-    bionic/libgen.cpp \
-    bionic/link.cpp \
-    bionic/locale.cpp \
-    bionic/lockf.cpp \
-    bionic/lstat.cpp \
-    bionic/malloc_info.cpp \
-    bionic/mbrtoc16.cpp \
-    bionic/mbrtoc32.cpp \
-    bionic/mbstate.cpp \
-    bionic/mempcpy.cpp \
-    bionic/mkdir.cpp \
-    bionic/mkfifo.cpp \
-    bionic/mknod.cpp \
-    bionic/mntent.cpp \
-    bionic/mremap.cpp \
-    bionic/NetdClientDispatch.cpp \
-    bionic/net_if.cpp \
-    bionic/netinet_in.cpp \
-    bionic/open.cpp \
-    bionic/pathconf.cpp \
-    bionic/pause.cpp \
-    bionic/pipe.cpp \
-    bionic/poll.cpp \
-    bionic/posix_fadvise.cpp \
-    bionic/posix_fallocate.cpp \
-    bionic/posix_madvise.cpp \
-    bionic/posix_timers.cpp \
-    bionic/ptrace.cpp \
-    bionic/pty.cpp \
-    bionic/raise.cpp \
-    bionic/rand.cpp \
-    bionic/readlink.cpp \
-    bionic/reboot.cpp \
-    bionic/recv.cpp \
-    bionic/rename.cpp \
-    bionic/rmdir.cpp \
-    bionic/scandir.cpp \
-    bionic/sched_getaffinity.cpp \
-    bionic/sched_getcpu.cpp \
-    bionic/semaphore.cpp \
-    bionic/send.cpp \
-    bionic/setegid.cpp \
-    bionic/__set_errno.cpp \
-    bionic/seteuid.cpp \
-    bionic/setpgrp.cpp \
-    bionic/sigaction.cpp \
-    bionic/sigaddset.cpp \
-    bionic/sigdelset.cpp \
-    bionic/sigemptyset.cpp \
-    bionic/sigfillset.cpp \
-    bionic/sigismember.cpp \
-    bionic/signal.cpp \
-    bionic/signalfd.cpp \
-    bionic/sigpending.cpp \
-    bionic/sigprocmask.cpp \
-    bionic/sigqueue.cpp \
-    bionic/sigsuspend.cpp \
-    bionic/sigtimedwait.cpp \
-    bionic/sigwait.cpp \
-    bionic/sigwaitinfo.cpp \
-    bionic/socket.cpp \
-    bionic/stat.cpp \
-    bionic/statvfs.cpp \
-    bionic/strchrnul.cpp \
-    bionic/strerror.cpp \
-    bionic/strerror_r.cpp \
-    bionic/strsignal.cpp \
-    bionic/strtold.cpp \
-    bionic/stubs.cpp \
-    bionic/symlink.cpp \
-    bionic/sysinfo.cpp \
-    bionic/syslog.cpp \
-    bionic/sys_siglist.c \
-    bionic/sys_signame.c \
-    bionic/system_properties.cpp \
-    bionic/tdestroy.cpp \
-    bionic/termios.cpp \
-    bionic/thread_private.cpp \
-    bionic/tmpfile.cpp \
-    bionic/umount.cpp \
-    bionic/unlink.cpp \
-    bionic/utimes.cpp \
-    bionic/wait.cpp \
-    bionic/wchar.cpp \
-    bionic/wctype.cpp \
-    bionic/wmempcpy.cpp \
-
-libc_bionic_src_files :=
-
-# The following implementations depend on pthread data, so we can't include
-# them in libc_ndk.a.
-libc_bionic_src_files += \
-    bionic/__cxa_thread_atexit_impl.cpp \
-    bionic/fork.cpp \
-
-# The data that backs getauxval is initialized in the libc init functions which
-# are invoked by the linker. If this file is included in libc_ndk.a, only one of
-# the copies of the global data will be initialized, resulting in nullptr
-# dereferences.
-libc_bionic_src_files += bionic/getauxval.cpp
-
-# These four require getauxval, which isn't available on older platforms.
-libc_bionic_src_files += bionic/getentropy_linux.c
-libc_bionic_src_files += bionic/sysconf.cpp
-libc_bionic_src_files += bionic/vdso.cpp
-libc_bionic_src_files += bionic/setjmp_cookie.cpp
-
-libc_bionic_src_files += \
-    bionic/__memcpy_chk.cpp \
-    bionic/__memset_chk.cpp \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-    bionic/strchr.cpp \
-    bionic/strnlen.c \
-    bionic/strrchr.cpp \
-
-libc_cxa_src_files := \
-    bionic/__cxa_guard.cpp \
-    bionic/__cxa_pure_virtual.cpp \
-    bionic/new.cpp \
-
-libc_upstream_freebsd_src_files := \
-    upstream-freebsd/lib/libc/gen/ldexp.c \
-    upstream-freebsd/lib/libc/gen/sleep.c \
-    upstream-freebsd/lib/libc/gen/usleep.c \
-    upstream-freebsd/lib/libc/stdlib/getopt_long.c \
-    upstream-freebsd/lib/libc/stdlib/qsort.c \
-    upstream-freebsd/lib/libc/stdlib/quick_exit.c \
-    upstream-freebsd/lib/libc/stdlib/realpath.c \
-    upstream-freebsd/lib/libc/string/wcpcpy.c \
-    upstream-freebsd/lib/libc/string/wcpncpy.c \
-    upstream-freebsd/lib/libc/string/wcscasecmp.c \
-    upstream-freebsd/lib/libc/string/wcscat.c \
-    upstream-freebsd/lib/libc/string/wcschr.c \
-    upstream-freebsd/lib/libc/string/wcscmp.c \
-    upstream-freebsd/lib/libc/string/wcscpy.c \
-    upstream-freebsd/lib/libc/string/wcscspn.c \
-    upstream-freebsd/lib/libc/string/wcsdup.c \
-    upstream-freebsd/lib/libc/string/wcslcat.c \
-    upstream-freebsd/lib/libc/string/wcslen.c \
-    upstream-freebsd/lib/libc/string/wcsncasecmp.c \
-    upstream-freebsd/lib/libc/string/wcsncat.c \
-    upstream-freebsd/lib/libc/string/wcsncmp.c \
-    upstream-freebsd/lib/libc/string/wcsncpy.c \
-    upstream-freebsd/lib/libc/string/wcsnlen.c \
-    upstream-freebsd/lib/libc/string/wcspbrk.c \
-    upstream-freebsd/lib/libc/string/wcsrchr.c \
-    upstream-freebsd/lib/libc/string/wcsspn.c \
-    upstream-freebsd/lib/libc/string/wcstok.c \
-    upstream-freebsd/lib/libc/string/wmemchr.c \
-    upstream-freebsd/lib/libc/string/wmemcmp.c \
-    upstream-freebsd/lib/libc/string/wmemmove.c \
-    upstream-freebsd/lib/libc/string/wmemset.c \
-
-libc_upstream_netbsd_src_files := \
-    upstream-netbsd/common/lib/libc/stdlib/random.c \
-    upstream-netbsd/lib/libc/gen/ftw.c \
-    upstream-netbsd/lib/libc/gen/nftw.c \
-    upstream-netbsd/lib/libc/gen/nice.c \
-    upstream-netbsd/lib/libc/gen/popen.c \
-    upstream-netbsd/lib/libc/gen/psignal.c \
-    upstream-netbsd/lib/libc/gen/utime.c \
-    upstream-netbsd/lib/libc/gen/utmp.c \
-    upstream-netbsd/lib/libc/inet/nsap_addr.c \
-    upstream-netbsd/lib/libc/regex/regcomp.c \
-    upstream-netbsd/lib/libc/regex/regerror.c \
-    upstream-netbsd/lib/libc/regex/regexec.c \
-    upstream-netbsd/lib/libc/regex/regfree.c \
-    upstream-netbsd/lib/libc/stdlib/bsearch.c \
-    upstream-netbsd/lib/libc/stdlib/div.c \
-    upstream-netbsd/lib/libc/stdlib/drand48.c \
-    upstream-netbsd/lib/libc/stdlib/erand48.c \
-    upstream-netbsd/lib/libc/stdlib/jrand48.c \
-    upstream-netbsd/lib/libc/stdlib/lcong48.c \
-    upstream-netbsd/lib/libc/stdlib/ldiv.c \
-    upstream-netbsd/lib/libc/stdlib/lldiv.c \
-    upstream-netbsd/lib/libc/stdlib/lrand48.c \
-    upstream-netbsd/lib/libc/stdlib/mrand48.c \
-    upstream-netbsd/lib/libc/stdlib/nrand48.c \
-    upstream-netbsd/lib/libc/stdlib/_rand48.c \
-    upstream-netbsd/lib/libc/stdlib/rand_r.c \
-    upstream-netbsd/lib/libc/stdlib/reallocarr.c \
-    upstream-netbsd/lib/libc/stdlib/seed48.c \
-    upstream-netbsd/lib/libc/stdlib/srand48.c \
-    upstream-netbsd/lib/libc/string/memccpy.c \
-    upstream-netbsd/lib/libc/string/strcasestr.c \
-    upstream-netbsd/lib/libc/string/strcoll.c \
-    upstream-netbsd/lib/libc/string/strxfrm.c \
-
-libc_upstream_openbsd_gdtoa_src_files := \
-    upstream-openbsd/android/gdtoa_support.cpp \
-    upstream-openbsd/lib/libc/gdtoa/dmisc.c \
-    upstream-openbsd/lib/libc/gdtoa/dtoa.c \
-    upstream-openbsd/lib/libc/gdtoa/gdtoa.c \
-    upstream-openbsd/lib/libc/gdtoa/gethex.c \
-    upstream-openbsd/lib/libc/gdtoa/gmisc.c \
-    upstream-openbsd/lib/libc/gdtoa/hd_init.c \
-    upstream-openbsd/lib/libc/gdtoa/hdtoa.c \
-    upstream-openbsd/lib/libc/gdtoa/hexnan.c \
-    upstream-openbsd/lib/libc/gdtoa/ldtoa.c \
-    upstream-openbsd/lib/libc/gdtoa/misc.c \
-    upstream-openbsd/lib/libc/gdtoa/smisc.c \
-    upstream-openbsd/lib/libc/gdtoa/strtod.c \
-    upstream-openbsd/lib/libc/gdtoa/strtodg.c \
-    upstream-openbsd/lib/libc/gdtoa/strtof.c \
-    upstream-openbsd/lib/libc/gdtoa/strtord.c \
-    upstream-openbsd/lib/libc/gdtoa/sum.c \
-    upstream-openbsd/lib/libc/gdtoa/ulp.c \
-
-libc_upstream_openbsd_gdtoa_src_files_32 := \
-    $(libc_upstream_openbsd_gdtoa_src_files) \
-
-libc_upstream_openbsd_gdtoa_src_files_64 := \
-    $(libc_upstream_openbsd_gdtoa_src_files) \
-    upstream-openbsd/lib/libc/gdtoa/strtorQ.c \
-
-# These two depend on getentropy_linux.c, which isn't in libc_ndk.a.
-libc_upstream_openbsd_src_files := \
-    upstream-openbsd/lib/libc/crypt/arc4random.c \
-    upstream-openbsd/lib/libc/crypt/arc4random_uniform.c \
-
-libc_upstream_openbsd_src_files += \
-    upstream-openbsd/lib/libc/string/memchr.c \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/memrchr.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/stpncpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-    upstream-openbsd/lib/libc/string/strcpy.c \
-    upstream-openbsd/lib/libc/string/strlcat.c \
-    upstream-openbsd/lib/libc/string/strlcpy.c \
-    upstream-openbsd/lib/libc/string/strncat.c \
-    upstream-openbsd/lib/libc/string/strncmp.c \
-    upstream-openbsd/lib/libc/string/strncpy.c \
-
-libc_upstream_openbsd_ndk_src_files := \
-    upstream-openbsd/lib/libc/compat-43/killpg.c \
-    upstream-openbsd/lib/libc/gen/alarm.c \
-    upstream-openbsd/lib/libc/gen/ctype_.c \
-    upstream-openbsd/lib/libc/gen/daemon.c \
-    upstream-openbsd/lib/libc/gen/err.c \
-    upstream-openbsd/lib/libc/gen/errx.c \
-    upstream-openbsd/lib/libc/gen/exec.c \
-    upstream-openbsd/lib/libc/gen/fnmatch.c \
-    upstream-openbsd/lib/libc/gen/ftok.c \
-    upstream-openbsd/lib/libc/gen/getprogname.c \
-    upstream-openbsd/lib/libc/gen/isctype.c \
-    upstream-openbsd/lib/libc/gen/setprogname.c \
-    upstream-openbsd/lib/libc/gen/time.c \
-    upstream-openbsd/lib/libc/gen/tolower_.c \
-    upstream-openbsd/lib/libc/gen/toupper_.c \
-    upstream-openbsd/lib/libc/gen/verr.c \
-    upstream-openbsd/lib/libc/gen/verrx.c \
-    upstream-openbsd/lib/libc/gen/vwarn.c \
-    upstream-openbsd/lib/libc/gen/vwarnx.c \
-    upstream-openbsd/lib/libc/gen/warn.c \
-    upstream-openbsd/lib/libc/gen/warnx.c \
-    upstream-openbsd/lib/libc/locale/btowc.c \
-    upstream-openbsd/lib/libc/locale/mbrlen.c \
-    upstream-openbsd/lib/libc/locale/mbstowcs.c \
-    upstream-openbsd/lib/libc/locale/mbtowc.c \
-    upstream-openbsd/lib/libc/locale/wcscoll.c \
-    upstream-openbsd/lib/libc/locale/wcstod.c \
-    upstream-openbsd/lib/libc/locale/wcstof.c \
-    upstream-openbsd/lib/libc/locale/wcstoimax.c \
-    upstream-openbsd/lib/libc/locale/wcstol.c \
-    upstream-openbsd/lib/libc/locale/wcstold.c \
-    upstream-openbsd/lib/libc/locale/wcstoll.c \
-    upstream-openbsd/lib/libc/locale/wcstombs.c \
-    upstream-openbsd/lib/libc/locale/wcstoul.c \
-    upstream-openbsd/lib/libc/locale/wcstoull.c \
-    upstream-openbsd/lib/libc/locale/wcstoumax.c \
-    upstream-openbsd/lib/libc/locale/wcsxfrm.c \
-    upstream-openbsd/lib/libc/locale/wctob.c \
-    upstream-openbsd/lib/libc/locale/wctomb.c \
-    upstream-openbsd/lib/libc/net/htonl.c \
-    upstream-openbsd/lib/libc/net/htons.c \
-    upstream-openbsd/lib/libc/net/inet_lnaof.c \
-    upstream-openbsd/lib/libc/net/inet_makeaddr.c \
-    upstream-openbsd/lib/libc/net/inet_netof.c \
-    upstream-openbsd/lib/libc/net/inet_ntoa.c \
-    upstream-openbsd/lib/libc/net/inet_ntop.c \
-    upstream-openbsd/lib/libc/net/inet_pton.c \
-    upstream-openbsd/lib/libc/net/ntohl.c \
-    upstream-openbsd/lib/libc/net/ntohs.c \
-    upstream-openbsd/lib/libc/net/res_random.c \
-    upstream-openbsd/lib/libc/stdio/asprintf.c \
-    upstream-openbsd/lib/libc/stdio/clrerr.c \
-    upstream-openbsd/lib/libc/stdio/dprintf.c \
-    upstream-openbsd/lib/libc/stdio/feof.c \
-    upstream-openbsd/lib/libc/stdio/ferror.c \
-    upstream-openbsd/lib/libc/stdio/fflush.c \
-    upstream-openbsd/lib/libc/stdio/fgetc.c \
-    upstream-openbsd/lib/libc/stdio/fgetln.c \
-    upstream-openbsd/lib/libc/stdio/fgets.c \
-    upstream-openbsd/lib/libc/stdio/fgetwc.c \
-    upstream-openbsd/lib/libc/stdio/fgetws.c \
-    upstream-openbsd/lib/libc/stdio/flags.c \
-    upstream-openbsd/lib/libc/stdio/fmemopen.c \
-    upstream-openbsd/lib/libc/stdio/fprintf.c \
-    upstream-openbsd/lib/libc/stdio/fpurge.c \
-    upstream-openbsd/lib/libc/stdio/fputc.c \
-    upstream-openbsd/lib/libc/stdio/fputs.c \
-    upstream-openbsd/lib/libc/stdio/fputwc.c \
-    upstream-openbsd/lib/libc/stdio/fputws.c \
-    upstream-openbsd/lib/libc/stdio/fscanf.c \
-    upstream-openbsd/lib/libc/stdio/fvwrite.c \
-    upstream-openbsd/lib/libc/stdio/fwalk.c \
-    upstream-openbsd/lib/libc/stdio/fwide.c \
-    upstream-openbsd/lib/libc/stdio/fwprintf.c \
-    upstream-openbsd/lib/libc/stdio/fwrite.c \
-    upstream-openbsd/lib/libc/stdio/fwscanf.c \
-    upstream-openbsd/lib/libc/stdio/getc.c \
-    upstream-openbsd/lib/libc/stdio/getchar.c \
-    upstream-openbsd/lib/libc/stdio/getdelim.c \
-    upstream-openbsd/lib/libc/stdio/getline.c \
-    upstream-openbsd/lib/libc/stdio/gets.c \
-    upstream-openbsd/lib/libc/stdio/getwc.c \
-    upstream-openbsd/lib/libc/stdio/getwchar.c \
-    upstream-openbsd/lib/libc/stdio/makebuf.c \
-    upstream-openbsd/lib/libc/stdio/mktemp.c \
-    upstream-openbsd/lib/libc/stdio/open_memstream.c \
-    upstream-openbsd/lib/libc/stdio/open_wmemstream.c \
-    upstream-openbsd/lib/libc/stdio/perror.c \
-    upstream-openbsd/lib/libc/stdio/printf.c \
-    upstream-openbsd/lib/libc/stdio/putc.c \
-    upstream-openbsd/lib/libc/stdio/putchar.c \
-    upstream-openbsd/lib/libc/stdio/puts.c \
-    upstream-openbsd/lib/libc/stdio/putwc.c \
-    upstream-openbsd/lib/libc/stdio/putwchar.c \
-    upstream-openbsd/lib/libc/stdio/remove.c \
-    upstream-openbsd/lib/libc/stdio/rewind.c \
-    upstream-openbsd/lib/libc/stdio/rget.c \
-    upstream-openbsd/lib/libc/stdio/scanf.c \
-    upstream-openbsd/lib/libc/stdio/setbuf.c \
-    upstream-openbsd/lib/libc/stdio/setbuffer.c \
-    upstream-openbsd/lib/libc/stdio/setvbuf.c \
-    upstream-openbsd/lib/libc/stdio/sscanf.c \
-    upstream-openbsd/lib/libc/stdio/swprintf.c \
-    upstream-openbsd/lib/libc/stdio/swscanf.c \
-    upstream-openbsd/lib/libc/stdio/tempnam.c \
-    upstream-openbsd/lib/libc/stdio/tmpnam.c \
-    upstream-openbsd/lib/libc/stdio/ungetc.c \
-    upstream-openbsd/lib/libc/stdio/ungetwc.c \
-    upstream-openbsd/lib/libc/stdio/vasprintf.c \
-    upstream-openbsd/lib/libc/stdio/vdprintf.c \
-    upstream-openbsd/lib/libc/stdio/vfprintf.c \
-    upstream-openbsd/lib/libc/stdio/vfscanf.c \
-    upstream-openbsd/lib/libc/stdio/vfwprintf.c \
-    upstream-openbsd/lib/libc/stdio/vfwscanf.c \
-    upstream-openbsd/lib/libc/stdio/vprintf.c \
-    upstream-openbsd/lib/libc/stdio/vscanf.c \
-    upstream-openbsd/lib/libc/stdio/vsnprintf.c \
-    upstream-openbsd/lib/libc/stdio/vsprintf.c \
-    upstream-openbsd/lib/libc/stdio/vsscanf.c \
-    upstream-openbsd/lib/libc/stdio/vswprintf.c \
-    upstream-openbsd/lib/libc/stdio/vswscanf.c \
-    upstream-openbsd/lib/libc/stdio/vwprintf.c \
-    upstream-openbsd/lib/libc/stdio/vwscanf.c \
-    upstream-openbsd/lib/libc/stdio/wbuf.c \
-    upstream-openbsd/lib/libc/stdio/wprintf.c \
-    upstream-openbsd/lib/libc/stdio/wscanf.c \
-    upstream-openbsd/lib/libc/stdio/wsetup.c \
-    upstream-openbsd/lib/libc/stdlib/abs.c \
-    upstream-openbsd/lib/libc/stdlib/atoi.c \
-    upstream-openbsd/lib/libc/stdlib/atol.c \
-    upstream-openbsd/lib/libc/stdlib/atoll.c \
-    upstream-openbsd/lib/libc/stdlib/getenv.c \
-    upstream-openbsd/lib/libc/stdlib/insque.c \
-    upstream-openbsd/lib/libc/stdlib/imaxabs.c \
-    upstream-openbsd/lib/libc/stdlib/imaxdiv.c \
-    upstream-openbsd/lib/libc/stdlib/labs.c \
-    upstream-openbsd/lib/libc/stdlib/llabs.c \
-    upstream-openbsd/lib/libc/stdlib/lsearch.c \
-    upstream-openbsd/lib/libc/stdlib/reallocarray.c \
-    upstream-openbsd/lib/libc/stdlib/remque.c \
-    upstream-openbsd/lib/libc/stdlib/setenv.c \
-    upstream-openbsd/lib/libc/stdlib/strtoimax.c \
-    upstream-openbsd/lib/libc/stdlib/strtol.c \
-    upstream-openbsd/lib/libc/stdlib/strtoll.c \
-    upstream-openbsd/lib/libc/stdlib/strtoul.c \
-    upstream-openbsd/lib/libc/stdlib/strtoull.c \
-    upstream-openbsd/lib/libc/stdlib/strtoumax.c \
-    upstream-openbsd/lib/libc/stdlib/system.c \
-    upstream-openbsd/lib/libc/stdlib/tfind.c \
-    upstream-openbsd/lib/libc/stdlib/tsearch.c \
-    upstream-openbsd/lib/libc/string/strcasecmp.c \
-    upstream-openbsd/lib/libc/string/strcspn.c \
-    upstream-openbsd/lib/libc/string/strdup.c \
-    upstream-openbsd/lib/libc/string/strndup.c \
-    upstream-openbsd/lib/libc/string/strpbrk.c \
-    upstream-openbsd/lib/libc/string/strsep.c \
-    upstream-openbsd/lib/libc/string/strspn.c \
-    upstream-openbsd/lib/libc/string/strstr.c \
-    upstream-openbsd/lib/libc/string/strtok.c \
-    upstream-openbsd/lib/libc/string/wmemcpy.c \
-    upstream-openbsd/lib/libc/string/wcslcpy.c \
-    upstream-openbsd/lib/libc/string/wcsstr.c \
-    upstream-openbsd/lib/libc/string/wcswidth.c \
-
-libc_pthread_src_files := \
-    bionic/pthread_atfork.cpp \
-    bionic/pthread_attr.cpp \
-    bionic/pthread_barrier.cpp \
-    bionic/pthread_cond.cpp \
-    bionic/pthread_create.cpp \
-    bionic/pthread_detach.cpp \
-    bionic/pthread_equal.cpp \
-    bionic/pthread_exit.cpp \
-    bionic/pthread_getcpuclockid.cpp \
-    bionic/pthread_getschedparam.cpp \
-    bionic/pthread_gettid_np.cpp \
-    bionic/pthread_internal.cpp \
-    bionic/pthread_join.cpp \
-    bionic/pthread_key.cpp \
-    bionic/pthread_kill.cpp \
-    bionic/pthread_mutex.cpp \
-    bionic/pthread_once.cpp \
-    bionic/pthread_rwlock.cpp \
-    bionic/pthread_self.cpp \
-    bionic/pthread_setname_np.cpp \
-    bionic/pthread_setschedparam.cpp \
-    bionic/pthread_sigmask.cpp \
-    bionic/pthread_spinlock.cpp \
-
-libc_arch_static_src_files := \
-    bionic/dl_iterate_phdr_static.cpp \
-
-# Various kinds of cruft.
-# ========================================================
-libc_common_src_files += \
-    bionic/ndk_cruft.cpp \
-
-libc_bionic_ndk_src_files_32 += \
-    bionic/mmap.cpp \
-
-libc_common_src_files_32 += \
-    bionic/legacy_32_bit_support.cpp \
-    bionic/time64.c \
-
-libc_netbsd_src_files_32 += \
-    upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
-
-libc_openbsd_src_files_32 += \
-    upstream-openbsd/lib/libc/stdio/putw.c \
-
-
-# Define some common cflags
-# ========================================================
-libc_common_cflags := \
-    -D_LIBC=1 \
-    -Wall -Wextra -Wunused \
-
-use_clang := $(USE_CLANG_PLATFORM_BUILD)
-
-# Clang/llvm has incompatible long double (fp128) for x86_64.
-# https://llvm.org/bugs/show_bug.cgi?id=23897
-ifeq ($(TARGET_ARCH),x86_64)
-  use_clang := false
-endif
-
-# b/25291096, Clang/llvm compiled libc.so for mips/mips64 failed to boot.
-ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
-  use_clang := false
-endif
-
-ifeq ($(use_clang),)
-  use_clang := true
-endif
-
-# Try to catch typical 32-bit assumptions that break with 64-bit pointers.
-libc_common_cflags += \
-    -Werror=pointer-to-int-cast \
-    -Werror=int-to-pointer-cast \
-    -Werror=type-limits \
-    -Werror \
-
-ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
-  libc_common_cflags += -DDEBUG
-endif
-
-libc_malloc_src := bionic/jemalloc_wrapper.cpp
-libc_common_c_includes += external/jemalloc/include
-
-# Define some common conlyflags
-libc_common_conlyflags := \
-    -std=gnu99
-
-# Define some common cppflags
-libc_common_cppflags := \
-
-# Define some common includes
-# ========================================================
-libc_common_c_includes += \
-    $(LOCAL_PATH)/stdio   \
-
-# ========================================================
-# Add in the arch or 32-bit specific flags
-# Must be called with $(eval).
-# $(1): the LOCAL_ variable name
-# $(2): the bionic variable name to pull in
-define patch-up-arch-specific-flags
-$(1)_$(TARGET_ARCH) += $($(2)_$(TARGET_ARCH))
-$(1)_32 += $($(2)_32)
-ifdef TARGET_2ND_ARCH
-$(1)_$(TARGET_2ND_ARCH) += $($(2)_$(TARGET_2ND_ARCH))
-endif
-endef
-
-
-# ========================================================
-# libc_stack_protector.a - stack protector code
-# ========================================================
-#
-# Code that implements the stack protector (or that runs
-# before TLS has been set up) needs to be compiled with
-# -fno-stack-protector, since it accesses the stack canary
-# TLS slot.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    bionic/__libc_init_main_thread.cpp \
-    bionic/__stack_chk_fail.cpp \
-
-LOCAL_SRC_FILES_arm64 := arch-arm64/bionic/__set_tls.c
-LOCAL_SRC_FILES_x86 := arch-x86/bionic/__set_tls.c
-LOCAL_SRC_FILES_x86_64 := arch-x86_64/bionic/__set_tls.c
-
-LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_MODULE := libc_stack_protector
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# libc_init_static.cpp also needs to be built without stack protector,
-# because it's responsible for setting up TLS for static executables.
-# This isn't the case for dynamic executables because the dynamic linker
-# has already set up the main thread's TLS.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := bionic/libc_init_static.cpp
-LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_MODULE := libc_init_static
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_tzcode.a - upstream 'tzcode' code
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-c-files-under,tzcode)
-# tzcode doesn't include wcsftime, so we use the OpenBSD one.
-LOCAL_SRC_FILES += upstream-openbsd/lib/libc/time/wcsftime.c
-
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -fvisibility=hidden \
-    -Wno-unused-parameter \
-
-# Don't use ridiculous amounts of stack.
-LOCAL_CFLAGS += -DALL_STATE
-# Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
-LOCAL_CFLAGS += -DSTD_INSPIRED
-# Obviously, we want to be thread-safe.
-LOCAL_CFLAGS += -DTHREAD_SAFE
-# The name of the tm_gmtoff field in our struct tm.
-LOCAL_CFLAGS += -DTM_GMTOFF=tm_gmtoff
-# Where we store our tzdata.
-LOCAL_CFLAGS += -DTZDIR=\"/system/usr/share/zoneinfo\"
-# Include timezone and daylight globals.
-LOCAL_CFLAGS += -DUSG_COMPAT=1
-# Use the empty string (instead of "   ") as the timezone abbreviation fallback.
-LOCAL_CFLAGS += -DWILDABBR=\"\"
-LOCAL_CFLAGS += -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU
-LOCAL_CFLAGS += -Dlint
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) $(LOCAL_PATH)/tzcode/
-LOCAL_MODULE := libc_tzcode
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_dns.a - modified NetBSD DNS code
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    $(call all-c-files-under,dns) \
-    upstream-netbsd/lib/libc/isc/ev_streams.c \
-    upstream-netbsd/lib/libc/isc/ev_timers.c \
-    upstream-netbsd/lib/libc/resolv/mtctxres.c \
-
-LOCAL_CFLAGS += \
-    $(libc_common_cflags) \
-    -DANDROID_CHANGES \
-    -DINET6 \
-    -fvisibility=hidden \
-    -Wno-unused-parameter \
-    -include netbsd-compat.h \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) \
-    $(LOCAL_PATH)/dns/include \
-    $(LOCAL_PATH)/private \
-    $(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
-    $(LOCAL_PATH)/upstream-netbsd/android/include \
-
-LOCAL_MODULE := libc_dns
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_freebsd.a - upstream FreeBSD C library code
-# ========================================================
-#
-# These files are built with the freebsd-compat.h header file
-# automatically included.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_upstream_freebsd_src_files)
-LOCAL_CFLAGS := \
-    $(libc_common_cflags) \
-    -Wno-sign-compare -Wno-uninitialized \
-    -include freebsd-compat.h \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) \
-    $(LOCAL_PATH)/upstream-freebsd/android/include \
-    $(LOCAL_PATH)/upstream-freebsd/lib/libc/include \
-
-LOCAL_MODULE := libc_freebsd
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES_EXCLUDE,libc_freebsd_src_files_exclude))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_netbsd.a - upstream NetBSD C library code
-# ========================================================
-#
-# These files are built with the netbsd-compat.h header file
-# automatically included.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_upstream_netbsd_src_files)
-LOCAL_CFLAGS := \
-    $(libc_common_cflags) \
-    -Wno-sign-compare \
-    -Wno-uninitialized \
-    -Wno-unused-parameter \
-    -DPOSIX_MISTAKE \
-    -include netbsd-compat.h \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) \
-    $(LOCAL_PATH)/upstream-netbsd/android/include \
-    $(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
-
-LOCAL_MODULE := libc_netbsd
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_netbsd_src_files))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_openbsd_ndk.a - upstream OpenBSD C library code
-# that can be safely included in the libc_ndk.a (doesn't
-# contain any troublesome global data or constructors).
-# ========================================================
-#
-# These files are built with the openbsd-compat.h header file
-# automatically included.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_upstream_openbsd_ndk_src_files)
-LOCAL_CLANG := $(use_clang)
-
-LOCAL_CFLAGS := \
-    $(libc_common_cflags) \
-    -Wno-sign-compare \
-    -Wno-uninitialized \
-    -Wno-unused-parameter \
-    -include openbsd-compat.h \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) \
-    $(LOCAL_PATH)/private \
-    $(LOCAL_PATH)/upstream-openbsd/android/include \
-    $(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
-    $(LOCAL_PATH)/upstream-openbsd/lib/libc/gdtoa/ \
-
-LOCAL_MODULE := libc_openbsd_ndk
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_openbsd.a - upstream OpenBSD C library code
-# ========================================================
-#
-# These files are built with the openbsd-compat.h header file
-# automatically included.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files)
-LOCAL_CLANG := $(use_clang)
-
-LOCAL_CFLAGS := \
-    $(libc_common_cflags) \
-    -Wno-sign-compare \
-    -Wno-uninitialized \
-    -Wno-unused-parameter \
-    -include openbsd-compat.h \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) \
-    $(LOCAL_PATH)/private \
-    $(LOCAL_PATH)/upstream-openbsd/android/include \
-    $(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
-    $(LOCAL_PATH)/upstream-openbsd/lib/libc/gdtoa/ \
-
-LOCAL_MODULE := libc_openbsd
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_openbsd_src_files))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES_EXCLUDE,libc_openbsd_src_files_exclude))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_gdtoa.a - upstream OpenBSD C library gdtoa code
-# ========================================================
-#
-# These files are built with the openbsd-compat.h header file
-# automatically included.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES_32 := $(libc_upstream_openbsd_gdtoa_src_files_32)
-LOCAL_SRC_FILES_64 := $(libc_upstream_openbsd_gdtoa_src_files_64)
-LOCAL_CLANG := $(use_clang)
-
-LOCAL_CFLAGS := \
-    $(libc_common_cflags) \
-    -Wno-sign-compare -Wno-uninitialized \
-    -fvisibility=hidden \
-    -include openbsd-compat.h \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) \
-    $(LOCAL_PATH)/private \
-    $(LOCAL_PATH)/upstream-openbsd/android/include \
-    $(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
-
-LOCAL_MODULE := libc_gdtoa
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_bionic.a - home-grown C library code
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_bionic_src_files)
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -Wframe-larger-than=2048 \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags) -Wold-style-cast
-LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
-LOCAL_MODULE := libc_bionic
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_bionic_src_files))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES_EXCLUDE,libc_bionic_src_files_exclude))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_bionic_ndk.a - The portions of libc_bionic that can
-# be safely used in libc_ndk.a (no troublesome global data
-# or constructors).
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_bionic_ndk_src_files)
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -Wframe-larger-than=2048 \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags) -Wold-style-cast
-LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
-LOCAL_MODULE := libc_bionic_ndk
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_bionic_ndk_src_files))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_pthread.a - pthreads parts that previously lived in
-# libc_bionic.a. Relocated to their own library because
-# they can't be included in libc_ndk.a (as they layout of
-# pthread_t has changed over the years and has ABI
-# compatibility issues).
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_pthread_src_files)
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -Wframe-larger-than=2048 \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags) -Wold-style-cast
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_MODULE := libc_pthread
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_cxa.a - Things traditionally in libstdc++
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_cxa_src_files)
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -fvisibility=hidden \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
-LOCAL_MODULE := libc_cxa
-LOCAL_CLANG := true # GCC refuses to hide new/delete
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-# b/17574078: Need to disable coverage until we have a prebuilt libprofile_rt.
-# Since this is a static library built with clang, it needs to link
-# libprofile_rt when it is linked into the final binary. Since the final binary
-# is built with GCC, it won't link libprofile_rt. We can't very easily just add
-# libprofile_rt to all link lines the way we've done for libgcov because
-# libprofile_rt isn't prebuilt, and it would be tricky to write a rule that
-# would make sure libprofile_rt is built.
-LOCAL_NATIVE_COVERAGE := false
-
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_syscalls.a
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES_$(TARGET_ARCH) := $(call all-S-files-under,arch-$(TARGET_ARCH)/syscalls)
-ifdef TARGET_2ND_ARCH
-LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call all-S-files-under,arch-$(TARGET_2ND_ARCH)/syscalls)
-endif
-LOCAL_MODULE := libc_syscalls
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_aeabi.a
-# This is an LP32 ARM-only library that needs to be built with -fno-builtin
-# to avoid infinite recursion. For the other architectures we just build an
-# empty library to keep this makefile simple.
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES_arm := arch-arm/bionic/__aeabi.c
-LOCAL_MODULE := libc_aeabi
-LOCAL_CLANG := $(use_clang)
-LOCAL_CFLAGS := $(libc_common_cflags) -fno-builtin
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# ========================================================
-# libc_ndk.a
-# Compatibility library for the NDK. This library contains
-# all the parts of libc that are safe to statically link.
-# We can't safely statically link things that can only run
-# on a certain version of the OS. Examples include
-# anything that talks to netd (a large portion of the DNS
-# code) and anything that is dependent on the layout of a
-# data structure that has changed across releases (such as
-# pthread_t).
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libc_ndk
-LOCAL_CLANG := $(use_clang)
-LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CFLAGS := $(libc_common_cflags) -fvisibility=hidden -O0
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-
-LOCAL_SRC_FILES := \
-    $(libc_common_src_files) \
-    $(libc_arch_dynamic_src_files) \
-    $(libc_ndk_stub_src_files) \
-    bionic/malloc_common.cpp \
-
-LOCAL_SRC_FILES_arm += \
-    arch-common/bionic/crtbegin_so.c \
-    arch-arm/bionic/atexit_legacy.c \
-    arch-common/bionic/crtend_so.S \
-
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -DLIBC_STATIC \
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-    libc_bionic_ndk \
-    libc_cxa \
-    libc_freebsd \
-    libc_gdtoa \
-    libc_malloc \
-    libc_netbsd \
-    libc_openbsd_ndk \
-    libc_stack_protector \
-    libc_syscalls \
-    libc_tzcode \
-    libm \
-    libjemalloc \
-
-LOCAL_WHOLE_STATIC_LIBRARIES_arm := libc_aeabi
-LOCAL_CXX_STL := none
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_common_src_files))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_dynamic_src_files))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_ASFLAGS,LOCAL_CFLAGS))
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-include $(BUILD_STATIC_LIBRARY)
-
-# ========================================================
-# libc_common.a
-# ========================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libc_common_src_files)
-LOCAL_CFLAGS := $(libc_common_cflags)
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_MODULE := libc_common
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-    libc_bionic \
-    libc_bionic_ndk \
-    libc_cxa \
-    libc_dns \
-    libc_freebsd \
-    libc_gdtoa \
-    libc_malloc \
-    libc_netbsd \
-    libc_openbsd \
-    libc_openbsd_ndk \
-    libc_pthread \
-    libc_stack_protector \
-    libc_syscalls \
-    libc_tzcode \
-
-LOCAL_WHOLE_STATIC_LIBRARIES_arm := libc_aeabi
-
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-
-# TODO: split out the asflags.
-LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_common_src_files))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_ASFLAGS,LOCAL_CFLAGS))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_nomalloc.a
-# ========================================================
-#
-# This is a version of the static C library that does not
-# include malloc. It's useful in situations when the user wants
-# to provide their own malloc implementation, or wants to
-# explicitly disallow the use of malloc, such as in the
-# dynamic linker.
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    $(libc_arch_static_src_files) \
-
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -DLIBC_STATIC \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-
-LOCAL_MODULE := libc_nomalloc
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_WHOLE_STATIC_LIBRARIES := libc_common libc_init_static
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc_malloc.a: the _prefixed_ malloc functions (like dlcalloc).
-# ========================================================
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(libc_malloc_src)
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -fvisibility=hidden \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_MODULE := libc_malloc
-LOCAL_CLANG := $(use_clang)
-LOCAL_CXX_STL := none
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc.a
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    $(libc_arch_static_src_files) \
-    bionic/malloc_common.cpp \
-    bionic/libc_init_static.cpp \
-
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -DLIBC_STATIC \
-
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_MODULE := libc
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_WHOLE_STATIC_LIBRARIES := libc_common libc_init_static libjemalloc
-
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
-include $(BUILD_STATIC_LIBRARY)
-
-
-# ========================================================
-# libc.so
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS := $(libc_common_cflags)
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-LOCAL_SRC_FILES := \
-    arch-common/bionic/crtbegin_so.c \
-    arch-common/bionic/crtbrand.S \
-    $(libc_arch_dynamic_src_files) \
-    bionic/malloc_common.cpp \
-    bionic/libc_init_dynamic.cpp \
-    bionic/NetdClient.cpp \
-    arch-common/bionic/crtend_so.S \
-
-LOCAL_MODULE := libc
-LOCAL_CLANG := $(use_clang)
-LOCAL_REQUIRED_MODULES := tzdata
-LOCAL_ADDITIONAL_DEPENDENCIES := \
-    $(libc_common_additional_dependencies) \
-    $(LOCAL_PATH)/libc.arm.map \
-    $(LOCAL_PATH)/libc.arm64.map \
-    $(LOCAL_PATH)/libc.mips.map \
-    $(LOCAL_PATH)/libc.mips64.map \
-    $(LOCAL_PATH)/libc.x86.map \
-    $(LOCAL_PATH)/libc.x86_64.map \
-    $(LOCAL_PATH)/libc.arm.brillo.map \
-    $(LOCAL_PATH)/libc.mips.brillo.map \
-    $(LOCAL_PATH)/libc.x86.brillo.map \
-
-# Leave the symbols in the shared library so that stack unwinders can produce
-# meaningful name resolution.
-LOCAL_STRIP_MODULE := keep_symbols
-
-# Do not pack libc.so relocations; see http://b/20645321 for details.
-LOCAL_PACK_MODULE_RELOCATIONS := false
-
-# WARNING: The only library libc.so should depend on is libdl.so!  If you add other libraries,
-# make sure to add -Wl,--exclude-libs=libgcc.a to the LOCAL_LDFLAGS for those libraries.  This
-# ensures that symbols that are pulled into those new libraries from libgcc.a are not declared
-# external; if that were the case, then libc would not pull those symbols from libgcc.a as it
-# should, instead relying on the external symbols from the dependent libraries.  That would
-# create a "cloaked" dependency on libgcc.a in libc though the libraries, which is not what
-# you wanted!
-
-LOCAL_SHARED_LIBRARIES := libdl
-LOCAL_WHOLE_STATIC_LIBRARIES := libc_common libjemalloc
-
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-
-# TODO: This is to work around b/24465209. Remove after root cause is fixed
-LOCAL_LDFLAGS_arm := -Wl,--hash-style=both
-LOCAL_LDFLAGS_x86 := -Wl,--hash-style=both
-
-# Don't re-export new/delete and friends, even if the compiler really wants to.
-ifdef BRILLO
-LOCAL_LDFLAGS_arm    += -Wl,--version-script,$(LOCAL_PATH)/libc.arm.brillo.map
-LOCAL_LDFLAGS_mips   += -Wl,--version-script,$(LOCAL_PATH)/libc.mips.brillo.map
-LOCAL_LDFLAGS_x86    += -Wl,--version-script,$(LOCAL_PATH)/libc.x86.brillo.map
-else
-LOCAL_LDFLAGS_arm    += -Wl,--version-script,$(LOCAL_PATH)/libc.arm.map
-LOCAL_LDFLAGS_mips   += -Wl,--version-script,$(LOCAL_PATH)/libc.mips.map
-LOCAL_LDFLAGS_x86    += -Wl,--version-script,$(LOCAL_PATH)/libc.x86.map
-endif
-
-LOCAL_LDFLAGS_arm64  += -Wl,--version-script,$(LOCAL_PATH)/libc.arm64.map
-LOCAL_LDFLAGS_mips64 += -Wl,--version-script,$(LOCAL_PATH)/libc.mips64.map
-LOCAL_LDFLAGS_x86_64 += -Wl,--version-script,$(LOCAL_PATH)/libc.x86_64.map
-
-# We'd really like to do this for all architectures, but since this wasn't done
-# before, these symbols must continue to be exported on LP32 for binary
-# compatibility.
-LOCAL_LDFLAGS_64 := -Wl,--exclude-libs,libgcc.a
-
-# Unfortunately --exclude-libs clobbers our version script, so we have to
-# prevent the build system from using this flag.
-LOCAL_NO_EXCLUDE_LIBS := true
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_dynamic_src_files))
-
-LOCAL_NO_CRT := true
-LOCAL_ASFLAGS += $(libc_crt_target_cflags)
-
-# special for arm
-LOCAL_CFLAGS_arm += -DCRT_LEGACY_WORKAROUND
-LOCAL_SRC_FILES_arm += \
-    arch-arm/bionic/atexit_legacy.c
-
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-include $(BUILD_SHARED_LIBRARY)
-
-# ========================================================
-# libc_logging.a
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS := $(libc_common_cflags)
-LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_C_INCLUDES := $(libc_common_c_includes)
-
-LOCAL_SRC_FILES := \
-    bionic/libc_logging.cpp \
-
-LOCAL_MODULE := libc_logging
-
-LOCAL_CLANG := $(use_clang)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-
-$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
-include $(BUILD_STATIC_LIBRARY)
-
-# ========================================================
-# libstdc++.so
-# ========================================================
-libstdcxx_common_src_files := \
-    bionic/__cxa_guard.cpp \
-    bionic/__cxa_pure_virtual.cpp \
-    bionic/new.cpp \
-
-include $(CLEAR_VARS)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
-LOCAL_CFLAGS := $(libc_common_cflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-
-# TODO: This is to work around b/24465209. Remove after root cause is fixed
-LOCAL_LDFLAGS_arm := -Wl,--hash-style=both
-LOCAL_LDFLAGS_x86 := -Wl,--hash-style=both
-
-LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
-LOCAL_MODULE:= libstdc++
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES := libc
-LOCAL_STATIC_LIBRARIES := libc_logging
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-include $(BUILD_SHARED_LIBRARY)
+include $(call all-makefiles-under,$(LOCAL_PATH))
 
-# ========================================================
-# libstdc++.a
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
-LOCAL_CFLAGS := $(libc_common_cflags)
-LOCAL_CPPFLAGS := $(libc_common_cppflags)
-LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
-LOCAL_MODULE:= libstdc++
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_CXX_STL := none
-LOCAL_SYSTEM_SHARED_LIBRARIES := libc
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/libc/NOTICE b/libc/NOTICE
index 2121246..a2f2b0a 100644
--- a/libc/NOTICE
+++ b/libc/NOTICE
@@ -122,6 +122,111 @@
 
 -------------------------------------------------------------------
 
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+Optimized by Bruce D. Evans.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+Optimized by Bruce D. Evans.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+Optimized by Bruce D. Evans.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+Copyright (c) 2009-2011, Bruce D. Evans, Steven G. Kargl, David Schultz.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+The argument reduction and testing for exceptional cases was
+written by Steven G. Kargl with input from Bruce D. Evans
+and David A. Schultz.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
+
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+-------------------------------------------------------------------
+
+====================================================
+Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
+
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+-------------------------------------------------------------------
+
 Based on the UCB version with the ID appearing below.
 This is ANSIish only when "multibyte character == plain character".
 
@@ -261,6 +366,22 @@
 
 -------------------------------------------------------------------
 
+Copyright (C) 2007 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-------------------------------------------------------------------
+
 Copyright (C) 2008 The Android Open Source Project
 
 Licensed under the Apache License, Version 2.0 (the "License");
@@ -407,6 +528,32 @@
 -------------------------------------------------------------------
 
 Copyright (C) 2010 The Android Open Source Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (C) 2010 The Android Open Source Project
 Copyright (c) 2008 ARM Ltd
 All rights reserved.
 
@@ -655,6 +802,48 @@
 
 -------------------------------------------------------------------
 
+Copyright (C) 2014 The Android Open Source Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (C) 2015 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-------------------------------------------------------------------
+
 Copyright (C) 2015 The Android Open Source Project
 
 Licensed under the Apache License, Version 2.0 (the "License");
@@ -1193,6 +1382,39 @@
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
+3. All advertising materials mentioning features or use of this software
+   must display the following acknowledgement:
+   This product includes software developed by the University of
+   California, Berkeley and its contributors.
+4. Neither the name of the University nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 1985, 1993
+   The Regents of the University of California.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
 3. Neither the name of the University nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.
@@ -1404,6 +1626,39 @@
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
+3. All advertising materials mentioning features or use of this software
+   must display the following acknowledgement:
+   This product includes software developed by the University of
+   California, Berkeley and its contributors.
+4. Neither the name of the University nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 1988, 1993
+   The Regents of the University of California.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
 3. Neither the name of the University nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.
@@ -1457,23 +1712,6 @@
 Copyright (c) 1989 The Regents of the University of California.
 All rights reserved.
 
-Redistribution and use in source and binary forms are permitted
-provided that the above copyright notice and this paragraph are
-duplicated in all such forms and that any documentation,
-advertising materials, and other materials related to such
-distribution and use acknowledge that the software was developed
-by the University of California, Berkeley. The name of the
-University may not be used to endorse or promote products derived
-from this software without specific prior written permission.
-THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1989 The Regents of the University of California.
-All rights reserved.
-
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:
@@ -1658,35 +1896,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 1989, 1993, 1994
-   The Regents of the University of California.  All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c) 1990 Regents of the University of California.
 All rights reserved.
 
@@ -1751,37 +1960,6 @@
 Copyright (c) 1990 The Regents of the University of California.
 All rights reserved.
 
-This code is derived from locore.s.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1990 The Regents of the University of California.
-All rights reserved.
-
 This code is derived from software contributed to Berkeley by
 Chris Torek.
 
@@ -2295,6 +2473,39 @@
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
+3. All advertising materials mentioning features or use of this software
+   must display the following acknowledgement:
+   This product includes software developed by the University of
+   California, Berkeley and its contributors.
+4. Neither the name of the University nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 1992, 1993
+   The Regents of the University of California.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
 3. Neither the name of the University nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.
@@ -2643,7 +2854,7 @@
 -------------------------------------------------------------------
 
 Copyright (c) 1997 Mark Brinicombe
-Copyright (c) 2010 Android Open Source Project.
+Copyright (C) 2010 The Android Open Source Project
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -3036,42 +3247,6 @@
 All rights reserved.
 
 This code is derived from software contributed to The NetBSD Foundation
-by Atsushi Onoe.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-   This product includes software developed by the NetBSD
-   Foundation, Inc. and its contributors.
-4. Neither the name of The NetBSD Foundation nor the names of its
-   contributors may be used to endorse or promote products derived
-   from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2000 The NetBSD Foundation, Inc.
-All rights reserved.
-
-This code is derived from software contributed to The NetBSD Foundation
 by Dieter Baron and Thomas Klausner.
 
 Redistribution and use in source and binary forms, with or without
@@ -3185,6 +3360,32 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2001-2011 The FreeBSD Project.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2002 Daniel Hartmeier
 All rights reserved.
 
@@ -3446,6 +3647,34 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2003 Dag-Erling Smørgrav
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer
+   in this position and unchanged.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
 All rights reserved.
 
@@ -3472,6 +3701,59 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
+Copyright (c) 2002 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2003 Networks Associates Technology, Inc.
 All rights reserved.
 
@@ -3524,6 +3806,104 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Sponsored in part by the Defense Advanced Research Projects
+Agency (DARPA) and Air Force Research Laboratory, Air Force
+Materiel Command, USAF, under agreement number F39502-99-1-0512.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2003, Steven G. Kargl
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2004 Stefan Farfeleder
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2004 The NetBSD Foundation, Inc.
 All rights reserved.
 
@@ -3739,6 +4119,110 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2005 Tim J. Robbins.
 All rights reserved.
 
@@ -3782,6 +4266,200 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2005-2008 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007 David Schultz
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+Derived from s_modf.c, which has the following Copyright:
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007 Steven G. Kargl
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007 The NetBSD Foundation, Inc.
+All rights reserved.
+
+This code is derived from software written by Stephen L. Moshier.
+It is redistributed by the NetBSD Foundation by permission of the author.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2007 Todd C. Miller <Todd.Miller@courtesan.com>
 
 Permission to use, copy, modify, and distribute this software for any
@@ -3853,9 +4531,8 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 2008  Android Open Source Project (query id randomization)
-Copyright (c) 1985, 1993
-   The Regents of the University of California.  All rights reserved.
+Copyright (c) 2007-2008 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
@@ -3865,18 +4542,63 @@
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-    This product includes software developed by the University of
-    California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2007-2013 Bruce D. Evans
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -4019,6 +4741,34 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2009-2013 Steven G. Kargl
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Optimized by Bruce D. Evans.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2010 MIPS Technologies, Inc.
 
 All rights reserved.
@@ -4051,6 +4801,32 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2010 The NetBSD Foundation, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
 
 Permission to use, copy, modify, and distribute this software for any
@@ -4153,6 +4929,58 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2011 David Schultz
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice unmodified, this list of conditions, and the following
+   disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
+Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
                    David Chisnall <theraven@FreeBSD.org>
 All rights reserved.
@@ -4359,6 +5187,32 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2012, Linaro Limited
    All rights reserved.
 
@@ -4518,6 +5372,32 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2013 David Chisnall
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2013 The NetBSD Foundation, Inc.
 All rights reserved.
 
@@ -4547,6 +5427,37 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2013-2014, NVIDIA Corporation.  All rights reserved.
+Johnny Qiu <joqiu@nvidia.com>
+Shu Zhang <chazhang@nvidia.com>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c) 2014
      Imagination Technologies Limited.
 
@@ -4709,32 +5620,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c)1999, 2000, 2001 Citrus Project,
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c)2001 Citrus Project,
 All rights reserved.
 
@@ -4787,6 +5672,34 @@
 
 -------------------------------------------------------------------
 
+Copyright 1989 The Regents of the University of California.
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+   3. Neither the name of the University nor the names of its contributors
+      may be used to endorse or promote products derived from this software
+      without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+
+-------------------------------------------------------------------
+
 Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
 Copyright 2008 Damien Miller <djm@openbsd.org>
 All rights reserved.
@@ -4823,37 +5736,14 @@
 
 -------------------------------------------------------------------
 
-Copyright 2008  Android Open Source Project (source port randomization)
-Copyright (c) 1985, 1989, 1993
-   The Regents of the University of California.  All rights reserved.
+From: @(#)s_ilogb.c 5.1 93/09/24
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-    This product includes software developed by the University of
-    California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
 
 -------------------------------------------------------------------
 
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index d5dd206..42c8f01 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -232,14 +232,14 @@
 int     __rt_sigpending:rt_sigpending(sigset_t*, size_t)  all
 int     __rt_sigprocmask:rt_sigprocmask(int, const sigset_t*, sigset_t*, size_t)  all
 int     __rt_sigsuspend:rt_sigsuspend(const sigset_t*, size_t)  all
-int     __rt_sigtimedwait:rt_sigtimedwait(const sigset_t*, struct siginfo_t*, struct timespec_t*, size_t)  all
+int     __rt_sigtimedwait:rt_sigtimedwait(const sigset_t*, siginfo_t*, const timespec*, size_t)  all
 int     ___rt_sigqueueinfo:rt_sigqueueinfo(pid_t, int, siginfo_t*)  all
 int     __signalfd4:signalfd4(int, const sigset_t*, size_t, int)  all
 
 # sockets
 int           __socket:socket(int, int, int)              arm,arm64,mips,mips64,x86_64
 int           socketpair(int, int, int, int*)    arm,arm64,mips,mips64,x86_64
-int           bind(int, struct sockaddr*, int)  arm,arm64,mips,mips64,x86_64
+int           bind(int, struct sockaddr*, socklen_t)  arm,arm64,mips,mips64,x86_64
 int           __connect:connect(int, struct sockaddr*, socklen_t)   arm,arm64,mips,mips64,x86_64
 int           listen(int, int)                   arm,arm64,mips,mips64,x86_64
 int           __accept4:accept4(int, struct sockaddr*, socklen_t*, int)  arm,arm64,mips,mips64,x86_64
@@ -250,8 +250,8 @@
 int           shutdown(int, int)  arm,arm64,mips,mips64,x86_64
 int           setsockopt(int, int, int, const void*, socklen_t)  arm,arm64,mips,mips64,x86_64
 int           getsockopt(int, int, int, void*, socklen_t*)    arm,arm64,mips,mips64,x86_64
-int           sendmsg(int, const struct msghdr*, unsigned int)  arm,arm64,mips,mips64,x86_64
-int           recvmsg(int, struct msghdr*, unsigned int)   arm,arm64,mips,mips64,x86_64
+ssize_t       recvmsg(int, struct msghdr*, unsigned int)   arm,arm64,mips,mips64,x86_64
+ssize_t       sendmsg(int, const struct msghdr*, unsigned int)  arm,arm64,mips,mips64,x86_64
 int           recvmmsg(int, struct mmsghdr*, unsigned int, int, const struct timespec*)   arm,arm64,mips,mips64,x86_64
 int           sendmmsg(int, struct mmsghdr*, unsigned int, int)   arm,arm64,mips,mips64,x86_64
 
@@ -322,13 +322,19 @@
 ssize_t process_vm_readv(pid_t, const struct iovec*, unsigned long, const struct iovec*, unsigned long, unsigned long)  all
 ssize_t process_vm_writev(pid_t, const struct iovec*, unsigned long, const struct iovec*, unsigned long, unsigned long)  all
 
+int quotactl(int, const char*, int, char*)  all
+
 int __set_tid_address:set_tid_address(int*)  all
 
 int setfsgid(gid_t)  all
 int setfsuid(uid_t)  all
 
+int setdomainname(const char*, size_t)  all
 int sethostname(const char*, size_t)  all
 
+int __sync_file_range:sync_file_range(int, off64_t, off64_t, unsigned int) arm64,mips,mips64,x86,x86_64
+int __sync_file_range2:sync_file_range2(int, unsigned int, off64_t, off64_t) arm
+
 pid_t wait4(pid_t, int*, int, struct rusage*)  all
 int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*)  all
 
@@ -344,7 +350,7 @@
 int     __set_thread_area:set_thread_area(void*) x86
 
 # vdso stuff.
-int clock_gettime(clockid_t, timespec*)                 arm,mips,mips64
-int __clock_gettime:clock_gettime(clockid_t, timespec*) arm64,x86,x86_64
-int gettimeofday(timeval*, timezone*)                   arm,mips,mips64
-int __gettimeofday:gettimeofday(timeval*, timezone*)    arm64,x86,x86_64
+int clock_gettime(clockid_t, timespec*)                 mips,mips64
+int __clock_gettime:clock_gettime(clockid_t, timespec*) arm,arm64,x86,x86_64
+int gettimeofday(timeval*, timezone*)                   mips,mips64
+int __gettimeofday:gettimeofday(timeval*, timezone*)    arm,arm64,x86,x86_64
diff --git a/libc/arch-arm/arm.mk b/libc/arch-arm/arm.mk
deleted file mode 100644
index 76f465e..0000000
--- a/libc/arch-arm/arm.mk
+++ /dev/null
@@ -1,63 +0,0 @@
-# 32-bit arm.
-
-libc_bionic_src_files_arm += \
-    arch-arm/generic/bionic/memcmp.S \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-
-libc_bionic_src_files_exclude_arm += \
-    bionic/__memcpy_chk.cpp \
-    bionic/__memset_chk.cpp \
-
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/strcpy.c \
-
-#
-# Inherently architecture-specific code.
-#
-
-libc_bionic_src_files_arm += \
-    arch-arm/bionic/abort_arm.S \
-    arch-arm/bionic/atomics_arm.c \
-    arch-arm/bionic/__bionic_clone.S \
-    arch-arm/bionic/_exit_with_stack_teardown.S \
-    arch-arm/bionic/libgcc_compat.c \
-    arch-arm/bionic/popcount_tab.c \
-    arch-arm/bionic/__restore.S \
-    arch-arm/bionic/setjmp.S \
-    arch-arm/bionic/syscall.S \
-    arch-arm/bionic/vfork.S \
-
-libc_arch_static_src_files_arm := arch-arm/bionic/exidx_static.c
-libc_arch_dynamic_src_files_arm := arch-arm/bionic/exidx_dynamic.c
-
-## CPU variant specific source files
-ifeq ($(strip $(TARGET_$(my_2nd_arch_prefix)CPU_VARIANT)),)
-  $(warning TARGET_$(my_2nd_arch_prefix)ARCH is arm, but TARGET_$(my_2nd_arch_prefix)CPU_VARIANT is not defined)
-endif
-ifneq ($(TARGET_$(my_2nd_arch_prefix)CPU_VARIANT),generic)
-cpu_variant_mk := $(LOCAL_PATH)/arch-arm/$(TARGET_$(my_2nd_arch_prefix)CPU_VARIANT)/$(TARGET_$(my_2nd_arch_prefix)CPU_VARIANT).mk
-ifeq ($(wildcard $(cpu_variant_mk)),)
-$(error "TARGET_$(my_2nd_arch_prefix)CPU_VARIANT not set or set to an unknown value. Possible values are cortex-a7, cortex-a8, cortex-a9, cortex-a15, krait, denver. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
-endif
-include $(cpu_variant_mk)
-libc_common_additional_dependencies += $(cpu_variant_mk)
-
-cpu_variant_mk :=
-endif
-
-
-libc_crt_target_cflags_arm := \
-    -I$(LOCAL_PATH)/arch-arm/include \
-    -mthumb-interwork
-
-libc_crt_target_so_cflags_arm :=
-
-libc_crt_target_crtbegin_file_arm := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin.c
-
-libc_crt_target_crtbegin_so_file_arm := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c
diff --git a/libc/arch-arm/bionic/__bionic_clone.S b/libc/arch-arm/bionic/__bionic_clone.S
index b771357..6669b93 100644
--- a/libc/arch-arm/bionic/__bionic_clone.S
+++ b/libc/arch-arm/bionic/__bionic_clone.S
@@ -29,7 +29,7 @@
 #include <private/bionic_asm.h>
 
 // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
-ENTRY(__bionic_clone)
+ENTRY_PRIVATE(__bionic_clone)
     mov     ip, sp
     # save registers to parent stack
     stmfd   sp!, {r4, r5, r6, r7}
@@ -51,7 +51,7 @@
 
     # Are we the child?
     movs    r0, r0
-    beq     1f
+    beq     .L_bc_child
 
     # In the parent, reload saved registers then either return or set errno.
     ldmfd   sp!, {r4, r5, r6, r7}
@@ -60,11 +60,10 @@
     neg     r0, r0
     b       __set_errno_internal
 
-1:  # The child.
-    # Setting lr to 0 will make the unwinder stop at __start_thread
+.L_bc_child:
+    # Setting lr to 0 will make the unwinder stop at __start_thread.
     mov    lr, #0
     # Call __start_thread with the 'fn' and 'arg' we stored on the child stack.
     pop    {r0, r1}
     b      __start_thread
 END(__bionic_clone)
-.hidden __bionic_clone
diff --git a/libc/arch-arm/bionic/libgcc_compat.c b/libc/arch-arm/bionic/libgcc_compat.c
index 10faf2d..abd1422 100644
--- a/libc/arch-arm/bionic/libgcc_compat.c
+++ b/libc/arch-arm/bionic/libgcc_compat.c
@@ -1,4 +1,30 @@
-/* Generated by genlibgcc_compat.py */
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 extern char __adddf3;
 extern char __addsf3;
diff --git a/libc/arch-arm/bionic/setjmp.S b/libc/arch-arm/bionic/setjmp.S
index 91d158a..6ee162e 100644
--- a/libc/arch-arm/bionic/setjmp.S
+++ b/libc/arch-arm/bionic/setjmp.S
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 1997 Mark Brinicombe
- * Copyright (c) 2010 Android Open Source Project.
+ * Copyright (C) 2010 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S b/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S
index 3692f04..da40f6c 100644
--- a/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S
+++ b/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,174 @@
  * SUCH DAMAGE.
  */
 
-// Indicate which memcpy base file to include.
-#define MEMCPY_BASE "memcpy_base.S"
+#include <private/bionic_asm.h>
 
-#include "__strcat_chk_common.S"
+    .syntax unified
+
+    .thumb
+    .thumb_func
+
+// Get the length of src string, then get the source of the dst string.
+// Check that the two lengths together don't exceed the threshold, then
+// do a memcpy of the data.
+ENTRY(__strcat_chk)
+    pld     [r0, #0]
+    push    {r0, lr}
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset r0, 0
+    .cfi_rel_offset lr, 4
+    push    {r4, r5}
+    .cfi_adjust_cfa_offset 8
+    .cfi_rel_offset r4, 0
+    .cfi_rel_offset r5, 4
+
+    mov     lr, r2
+
+    // Save the dst register to r5
+    mov     r5, r0
+
+    // Zero out r4
+    eor     r4, r4, r4
+
+    // r1 contains the address of the string to count.
+.L_strlen_start:
+    mov     r0, r1
+    ands    r3, r1, #7
+    beq     .L_mainloop
+
+    // Align to a double word (64 bits).
+    rsb     r3, r3, #8
+    lsls    ip, r3, #31
+    beq     .L_align_to_32
+
+    ldrb    r2, [r1], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_32:
+    bcc     .L_align_to_64
+    ands    ip, r3, #2
+    beq     .L_align_to_64
+
+    ldrb    r2, [r1], #1
+    cbz     r2, .L_update_count_and_finish
+    ldrb    r2, [r1], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_64:
+    tst     r3, #4
+    beq     .L_mainloop
+    ldr     r3, [r1], #4
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+
+    .p2align 2
+.L_mainloop:
+    ldrd    r2, r3, [r1], #8
+
+    pld     [r1, #64]
+
+    sub     ip, r2, #0x01010101
+    bic     ip, ip, r2
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_first_register
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+    b       .L_mainloop
+
+.L_update_count_and_finish:
+    sub     r3, r1, r0
+    sub     r3, r3, #1
+    b       .L_finish
+
+.L_zero_in_first_register:
+    sub     r3, r1, r0
+    lsls    r2, ip, #17
+    bne     .L_sub8_and_finish
+    bcs     .L_sub7_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub6_and_finish
+
+    sub     r3, r3, #5
+    b       .L_finish
+
+.L_sub8_and_finish:
+    sub     r3, r3, #8
+    b       .L_finish
+
+.L_sub7_and_finish:
+    sub     r3, r3, #7
+    b       .L_finish
+
+.L_sub6_and_finish:
+    sub     r3, r3, #6
+    b       .L_finish
+
+.L_zero_in_second_register:
+    sub     r3, r1, r0
+    lsls    r2, ip, #17
+    bne     .L_sub4_and_finish
+    bcs     .L_sub3_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub2_and_finish
+
+    sub     r3, r3, #1
+    b       .L_finish
+
+.L_sub4_and_finish:
+    sub     r3, r3, #4
+    b       .L_finish
+
+.L_sub3_and_finish:
+    sub     r3, r3, #3
+    b       .L_finish
+
+.L_sub2_and_finish:
+    sub     r3, r3, #2
+
+.L_finish:
+    cmp     r4, #0
+    bne     .L_strlen_done
+
+    // Time to get the dst string length.
+    mov     r1, r5
+
+    // Save the original source address to r5.
+    mov     r5, r0
+
+    // Save the current length (adding 1 for the terminator).
+    add     r4, r3, #1
+    b       .L_strlen_start
+
+    // r0 holds the pointer to the dst string.
+    // r3 holds the dst string length.
+    // r4 holds the src string length + 1.
+.L_strlen_done:
+    add     r2, r3, r4
+    cmp     r2, lr
+    itt     hi
+    movhi   r0, lr
+    bhi     __strcat_chk_fail
+
+    // Set up the registers for the memcpy code.
+    mov     r1, r5
+    pld     [r1, #64]
+    mov     r2, r4
+    add     r0, r0, r3
+    pop     {r4, r5}
+    .cfi_adjust_cfa_offset -8
+    .cfi_restore r4
+    .cfi_restore r5
+
+#include "memcpy_base.S"
+
+    // Undo the above cfi directives
+    .cfi_adjust_cfa_offset 8
+    .cfi_rel_offset r4, 0
+    .cfi_rel_offset r5, 4
+END(__strcat_chk)
diff --git a/libc/arch-arm/cortex-a15/bionic/__strcat_chk_common.S b/libc/arch-arm/cortex-a15/bionic/__strcat_chk_common.S
deleted file mode 100644
index de66967..0000000
--- a/libc/arch-arm/cortex-a15/bionic/__strcat_chk_common.S
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <private/bionic_asm.h>
-#include <private/libc_events.h>
-
-    .syntax unified
-
-    .thumb
-    .thumb_func
-
-// Get the length of src string, then get the source of the dst string.
-// Check that the two lengths together don't exceed the threshold, then
-// do a memcpy of the data.
-ENTRY(__strcat_chk)
-    pld     [r0, #0]
-    push    {r0, lr}
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset r0, 0
-    .cfi_rel_offset lr, 4
-    push    {r4, r5}
-    .cfi_adjust_cfa_offset 8
-    .cfi_rel_offset r4, 0
-    .cfi_rel_offset r5, 4
-
-    mov     lr, r2
-
-    // Save the dst register to r5
-    mov     r5, r0
-
-    // Zero out r4
-    eor     r4, r4, r4
-
-    // r1 contains the address of the string to count.
-.L_strlen_start:
-    mov     r0, r1
-    ands    r3, r1, #7
-    beq     .L_mainloop
-
-    // Align to a double word (64 bits).
-    rsb     r3, r3, #8
-    lsls    ip, r3, #31
-    beq     .L_align_to_32
-
-    ldrb    r2, [r1], #1
-    cbz     r2, .L_update_count_and_finish
-
-.L_align_to_32:
-    bcc     .L_align_to_64
-    ands    ip, r3, #2
-    beq     .L_align_to_64
-
-    ldrb    r2, [r1], #1
-    cbz     r2, .L_update_count_and_finish
-    ldrb    r2, [r1], #1
-    cbz     r2, .L_update_count_and_finish
-
-.L_align_to_64:
-    tst     r3, #4
-    beq     .L_mainloop
-    ldr     r3, [r1], #4
-
-    sub     ip, r3, #0x01010101
-    bic     ip, ip, r3
-    ands    ip, ip, #0x80808080
-    bne     .L_zero_in_second_register
-
-    .p2align 2
-.L_mainloop:
-    ldrd    r2, r3, [r1], #8
-
-    pld     [r1, #64]
-
-    sub     ip, r2, #0x01010101
-    bic     ip, ip, r2
-    ands    ip, ip, #0x80808080
-    bne     .L_zero_in_first_register
-
-    sub     ip, r3, #0x01010101
-    bic     ip, ip, r3
-    ands    ip, ip, #0x80808080
-    bne     .L_zero_in_second_register
-    b       .L_mainloop
-
-.L_update_count_and_finish:
-    sub     r3, r1, r0
-    sub     r3, r3, #1
-    b       .L_finish
-
-.L_zero_in_first_register:
-    sub     r3, r1, r0
-    lsls    r2, ip, #17
-    bne     .L_sub8_and_finish
-    bcs     .L_sub7_and_finish
-    lsls    ip, ip, #1
-    bne     .L_sub6_and_finish
-
-    sub     r3, r3, #5
-    b       .L_finish
-
-.L_sub8_and_finish:
-    sub     r3, r3, #8
-    b       .L_finish
-
-.L_sub7_and_finish:
-    sub     r3, r3, #7
-    b       .L_finish
-
-.L_sub6_and_finish:
-    sub     r3, r3, #6
-    b       .L_finish
-
-.L_zero_in_second_register:
-    sub     r3, r1, r0
-    lsls    r2, ip, #17
-    bne     .L_sub4_and_finish
-    bcs     .L_sub3_and_finish
-    lsls    ip, ip, #1
-    bne     .L_sub2_and_finish
-
-    sub     r3, r3, #1
-    b       .L_finish
-
-.L_sub4_and_finish:
-    sub     r3, r3, #4
-    b       .L_finish
-
-.L_sub3_and_finish:
-    sub     r3, r3, #3
-    b       .L_finish
-
-.L_sub2_and_finish:
-    sub     r3, r3, #2
-
-.L_finish:
-    cmp     r4, #0
-    bne     .L_strlen_done
-
-    // Time to get the dst string length.
-    mov     r1, r5
-
-    // Save the original source address to r5.
-    mov     r5, r0
-
-    // Save the current length (adding 1 for the terminator).
-    add     r4, r3, #1
-    b       .L_strlen_start
-
-    // r0 holds the pointer to the dst string.
-    // r3 holds the dst string length.
-    // r4 holds the src string length + 1.
-.L_strlen_done:
-    add     r2, r3, r4
-    cmp     r2, lr
-    bhi     .L_strcat_chk_failed
-
-    // Set up the registers for the memcpy code.
-    mov     r1, r5
-    pld     [r1, #64]
-    mov     r2, r4
-    add     r0, r0, r3
-    pop     {r4, r5}
-    .cfi_adjust_cfa_offset -8
-    .cfi_restore r4
-    .cfi_restore r5
-
-#include MEMCPY_BASE
-
-    // Undo the above cfi directives
-    .cfi_adjust_cfa_offset 8
-    .cfi_rel_offset r4, 0
-    .cfi_rel_offset r5, 4
-.L_strcat_chk_failed:
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-error_code:
-    .word   BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
-END(__strcat_chk)
-
-    .data
-error_string:
-    .string "strcat: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S b/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S
index d8cb3d9..026adcc 100644
--- a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S
+++ b/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,136 @@
  * SUCH DAMAGE.
  */
 
-// Indicate which memcpy base file to include.
-#define MEMCPY_BASE "memcpy_base.S"
+#include <private/bionic_asm.h>
 
-#include "__strcpy_chk_common.S"
+    .syntax unified
+
+    .thumb
+    .thumb_func
+
+// Get the length of the source string first, then do a memcpy of the data
+// instead of a strcpy.
+ENTRY(__strcpy_chk)
+    pld     [r0, #0]
+    push    {r0, lr}
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset r0, 0
+    .cfi_rel_offset lr, 4
+
+    mov     lr, r2
+    mov     r0, r1
+
+    ands    r3, r1, #7
+    beq     .L_mainloop
+
+    // Align to a double word (64 bits).
+    rsb     r3, r3, #8
+    lsls    ip, r3, #31
+    beq     .L_align_to_32
+
+    ldrb    r2, [r0], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_32:
+    bcc     .L_align_to_64
+    ands    ip, r3, #2
+    beq     .L_align_to_64
+
+    ldrb    r2, [r0], #1
+    cbz     r2, .L_update_count_and_finish
+    ldrb    r2, [r0], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_64:
+    tst     r3, #4
+    beq     .L_mainloop
+    ldr     r3, [r0], #4
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+
+    .p2align 2
+.L_mainloop:
+    ldrd    r2, r3, [r0], #8
+
+    pld     [r0, #64]
+
+    sub     ip, r2, #0x01010101
+    bic     ip, ip, r2
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_first_register
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+    b       .L_mainloop
+
+.L_update_count_and_finish:
+    sub     r3, r0, r1
+    sub     r3, r3, #1
+    b       .L_check_size
+
+.L_zero_in_first_register:
+    sub     r3, r0, r1
+    lsls    r2, ip, #17
+    bne     .L_sub8_and_finish
+    bcs     .L_sub7_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub6_and_finish
+
+    sub     r3, r3, #5
+    b       .L_check_size
+
+.L_sub8_and_finish:
+    sub     r3, r3, #8
+    b       .L_check_size
+
+.L_sub7_and_finish:
+    sub     r3, r3, #7
+    b       .L_check_size
+
+.L_sub6_and_finish:
+    sub     r3, r3, #6
+    b       .L_check_size
+
+.L_zero_in_second_register:
+    sub     r3, r0, r1
+    lsls    r2, ip, #17
+    bne     .L_sub4_and_finish
+    bcs     .L_sub3_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub2_and_finish
+
+    sub     r3, r3, #1
+    b       .L_check_size
+
+.L_sub4_and_finish:
+    sub     r3, r3, #4
+    b       .L_check_size
+
+.L_sub3_and_finish:
+    sub     r3, r3, #3
+    b       .L_check_size
+
+.L_sub2_and_finish:
+    sub     r3, r3, #2
+
+.L_check_size:
+    pld     [r1, #0]
+    pld     [r1, #64]
+    ldr     r0, [sp]
+
+    // Add 1 for copy length to get the string terminator.
+    add     r2, r3, #1
+
+    cmp     r2, lr
+    itt     hi
+    movhi   r0, r2
+    bhi     __strcpy_chk_fail
+
+#include "memcpy_base.S"
+
+END(__strcpy_chk)
diff --git a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk_common.S b/libc/arch-arm/cortex-a15/bionic/__strcpy_chk_common.S
deleted file mode 100644
index 69ebcb4..0000000
--- a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk_common.S
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <private/bionic_asm.h>
-#include <private/libc_events.h>
-
-    .syntax unified
-
-    .thumb
-    .thumb_func
-
-// Get the length of the source string first, then do a memcpy of the data
-// instead of a strcpy.
-ENTRY(__strcpy_chk)
-    pld     [r0, #0]
-    push    {r0, lr}
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset r0, 0
-    .cfi_rel_offset lr, 4
-
-    mov     lr, r2
-    mov     r0, r1
-
-    ands    r3, r1, #7
-    beq     .L_mainloop
-
-    // Align to a double word (64 bits).
-    rsb     r3, r3, #8
-    lsls    ip, r3, #31
-    beq     .L_align_to_32
-
-    ldrb    r2, [r0], #1
-    cbz     r2, .L_update_count_and_finish
-
-.L_align_to_32:
-    bcc     .L_align_to_64
-    ands    ip, r3, #2
-    beq     .L_align_to_64
-
-    ldrb    r2, [r0], #1
-    cbz     r2, .L_update_count_and_finish
-    ldrb    r2, [r0], #1
-    cbz     r2, .L_update_count_and_finish
-
-.L_align_to_64:
-    tst     r3, #4
-    beq     .L_mainloop
-    ldr     r3, [r0], #4
-
-    sub     ip, r3, #0x01010101
-    bic     ip, ip, r3
-    ands    ip, ip, #0x80808080
-    bne     .L_zero_in_second_register
-
-    .p2align 2
-.L_mainloop:
-    ldrd    r2, r3, [r0], #8
-
-    pld     [r0, #64]
-
-    sub     ip, r2, #0x01010101
-    bic     ip, ip, r2
-    ands    ip, ip, #0x80808080
-    bne     .L_zero_in_first_register
-
-    sub     ip, r3, #0x01010101
-    bic     ip, ip, r3
-    ands    ip, ip, #0x80808080
-    bne     .L_zero_in_second_register
-    b       .L_mainloop
-
-.L_update_count_and_finish:
-    sub     r3, r0, r1
-    sub     r3, r3, #1
-    b       .L_check_size
-
-.L_zero_in_first_register:
-    sub     r3, r0, r1
-    lsls    r2, ip, #17
-    bne     .L_sub8_and_finish
-    bcs     .L_sub7_and_finish
-    lsls    ip, ip, #1
-    bne     .L_sub6_and_finish
-
-    sub     r3, r3, #5
-    b       .L_check_size
-
-.L_sub8_and_finish:
-    sub     r3, r3, #8
-    b       .L_check_size
-
-.L_sub7_and_finish:
-    sub     r3, r3, #7
-    b       .L_check_size
-
-.L_sub6_and_finish:
-    sub     r3, r3, #6
-    b       .L_check_size
-
-.L_zero_in_second_register:
-    sub     r3, r0, r1
-    lsls    r2, ip, #17
-    bne     .L_sub4_and_finish
-    bcs     .L_sub3_and_finish
-    lsls    ip, ip, #1
-    bne     .L_sub2_and_finish
-
-    sub     r3, r3, #1
-    b       .L_check_size
-
-.L_sub4_and_finish:
-    sub     r3, r3, #4
-    b       .L_check_size
-
-.L_sub3_and_finish:
-    sub     r3, r3, #3
-    b       .L_check_size
-
-.L_sub2_and_finish:
-    sub     r3, r3, #2
-
-.L_check_size:
-    pld     [r1, #0]
-    pld     [r1, #64]
-    ldr     r0, [sp]
-    cmp     r3, lr
-    bhs     .L_strcpy_chk_failed
-
-    // Add 1 for copy length to get the string terminator.
-    add     r2, r3, #1
-
-#include MEMCPY_BASE
-
-.L_strcpy_chk_failed:
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-error_code:
-    .word   BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
-END(__strcpy_chk)
-
-    .data
-error_string:
-    .string "strcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a15/bionic/memcpy.S b/libc/arch-arm/cortex-a15/bionic/memcpy.S
index 537f3de..9407a08 100644
--- a/libc/arch-arm/cortex-a15/bionic/memcpy.S
+++ b/libc/arch-arm/cortex-a15/bionic/memcpy.S
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2008 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,8 +25,58 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+/*
+ * Copyright (c) 2013 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
-// Indicate which memcpy base file to include.
-#define MEMCPY_BASE "memcpy_base.S"
+#include <private/bionic_asm.h>
 
-#include "memcpy_common.S"
+        .text
+        .syntax unified
+        .fpu    neon
+
+ENTRY(__memcpy_chk)
+        cmp r2, r3
+        bls memcpy
+
+        // Preserve lr for backtrace.
+        push        {lr}
+        .cfi_def_cfa_offset 4
+        .cfi_rel_offset lr, 0
+        bl          __memcpy_chk_fail
+END(__memcpy_chk)
+
+// Prototype: void *memcpy (void *dst, const void *src, size_t count).
+ENTRY(memcpy)
+        pld     [r1, #64]
+        push    {r0, lr}
+        .cfi_def_cfa_offset 8
+        .cfi_rel_offset r0, 0
+        .cfi_rel_offset lr, 4
+
+#include "memcpy_base.S"
+END(memcpy)
diff --git a/libc/arch-arm/cortex-a15/bionic/memcpy_base.S b/libc/arch-arm/cortex-a15/bionic/memcpy_base.S
index aac737d..1d152bb 100644
--- a/libc/arch-arm/cortex-a15/bionic/memcpy_base.S
+++ b/libc/arch-arm/cortex-a15/bionic/memcpy_base.S
@@ -68,11 +68,6 @@
         cmp     r2, #16
         blo     .L_copy_less_than_16_unknown_align
 
-        // TODO: The aligned copy code is extremely slow copying some large
-        //       buffers so always go through the unaligned path for now.
-        //cmp     r2, #832
-        //bge     .L_check_alignment
-
 .L_copy_unknown_alignment:
         // Unknown alignment of src and dst.
         // Assumes that the first few bytes have already been prefetched.
@@ -157,178 +152,3 @@
         strbcs      lr, [r0]
 
         pop         {r0, pc}
-
-.L_check_alignment:
-        // If src and dst cannot both be aligned to a word boundary,
-        // use the unaligned copy version.
-        eor     r3, r0, r1
-        ands    r3, r3, #0x3
-        bne     .L_copy_unknown_alignment
-
-        // To try and improve performance, stack layout changed,
-        // i.e., not keeping the stack looking like users expect
-        // (highest numbered register at highest address).
-        strd    r4, r5, [sp, #-8]!
-        .cfi_adjust_cfa_offset 8
-        .cfi_rel_offset r4, 0
-        .cfi_rel_offset r5, 4
-        strd    r6, r7, [sp, #-8]!
-        .cfi_adjust_cfa_offset 8
-        .cfi_rel_offset r6, 0
-        .cfi_rel_offset r7, 4
-        strd    r8, r9, [sp, #-8]!
-        .cfi_adjust_cfa_offset 8
-        .cfi_rel_offset r8, 0
-        .cfi_rel_offset r9, 4
-
-        // Optimized for already aligned dst code.
-        ands    ip, r0, #3
-        bne     .L_dst_not_word_aligned
-
-.L_word_aligned:
-        // Align the destination buffer to 8 bytes, to make sure double
-        // loads and stores don't cross a cache line boundary,
-        // as they are then more expensive even if the data is in the cache
-        // (require two load/store issue cycles instead of one).
-        // If only one of the buffers is not 8 bytes aligned,
-        // then it's more important to align dst than src,
-        // because there is more penalty for stores
-        // than loads that cross a cacheline boundary.
-        // This check and realignment are only done if there is >= 832
-        // bytes to copy.
-
-        // Dst is word aligned, but check if it is already double word aligned.
-        ands    r3, r0, #4
-        beq     1f
-        ldr     r3, [r1], #4
-        str     r3, [r0], #4
-        sub     r2, #4
-
-1:      // Can only get here if > 64 bytes to copy, so don't do check r2.
-        sub     r2, #64
-
-2:      // Every loop iteration copies 64 bytes.
-        .irp    offset, #0, #8, #16, #24, #32
-        ldrd    r4, r5, [r1, \offset]
-        strd    r4, r5, [r0, \offset]
-        .endr
-
-        ldrd    r4, r5, [r1, #40]
-        ldrd    r6, r7, [r1, #48]
-        ldrd    r8, r9, [r1, #56]
-
-        // Keep the pld as far from the next load as possible.
-        // The amount to prefetch was determined experimentally using
-        // large sizes, and verifying the prefetch size does not affect
-        // the smaller copies too much.
-        // WARNING: If the ldrd and strd instructions get too far away
-        //          from each other, performance suffers. Three loads
-        //          in a row is the best tradeoff.
-        pld     [r1, #(64*16)]
-        strd    r4, r5, [r0, #40]
-        strd    r6, r7, [r0, #48]
-        strd    r8, r9, [r0, #56]
-
-        add     r0, r0, #64
-        add     r1, r1, #64
-        subs    r2, r2, #64
-        bge     2b
-
-        // Fix-up the remaining count and make sure we have >= 32 bytes left.
-        adds    r2, r2, #32
-        blo     4f
-
-        // Copy 32 bytes. These cache lines were already preloaded.
-        .irp    offset, #0, #8, #16, #24
-        ldrd    r4, r5, [r1, \offset]
-        strd    r4, r5, [r0, \offset]
-        .endr
-        add     r1, r1, #32
-        add     r0, r0, #32
-        sub     r2, r2, #32
-4:      // Less than 32 left.
-        add     r2, r2, #32
-        tst     r2, #0x10
-        beq     5f
-        // Copy 16 bytes.
-        .irp    offset, #0, #8
-        ldrd    r4, r5, [r1, \offset]
-        strd    r4, r5, [r0, \offset]
-        .endr
-        add     r1, r1, #16
-        add     r0, r0, #16
-
-5:      // Copy up to 15 bytes (count in r2).
-        movs    ip, r2, lsl #29
-        bcc     1f
-        // Copy 8 bytes.
-        ldrd    r4, r5, [r1], #8
-        strd    r4, r5, [r0], #8
-1:      bge         2f
-        // Copy 4 bytes.
-        ldr     r4, [r1], #4
-        str     r4, [r0], #4
-2:      // Copy 0 to 4 bytes.
-        lsls    r2, r2, #31
-        itt     ne
-        ldrbne  lr, [r1], #1
-        strbne  lr, [r0], #1
-        itttt   cs
-        ldrbcs  ip, [r1], #1
-        ldrbcs  lr, [r1]
-        strbcs  ip, [r0], #1
-        strbcs  lr, [r0]
-
-        // Restore registers: optimized pop {r0, pc}
-        ldrd    r8, r9, [sp], #8
-        .cfi_adjust_cfa_offset -8
-        .cfi_restore r8
-        .cfi_restore r9
-        ldrd    r6, r7, [sp], #8
-        .cfi_adjust_cfa_offset -8
-        .cfi_restore r6
-        .cfi_restore r7
-        ldrd    r4, r5, [sp], #8
-        .cfi_adjust_cfa_offset -8
-        .cfi_restore r4
-        .cfi_restore r5
-        pop     {r0, pc}
-
-        // Put the cfi directives back for the below instructions.
-        .cfi_adjust_cfa_offset 24
-        .cfi_rel_offset r4, 0
-        .cfi_rel_offset r5, 4
-        .cfi_rel_offset r6, 8
-        .cfi_rel_offset r7, 12
-        .cfi_rel_offset r8, 16
-        .cfi_rel_offset r9, 20
-
-.L_dst_not_word_aligned:
-        // Align dst to word.
-        rsb     ip, ip, #4
-        cmp     ip, #2
-
-        itt     gt
-        ldrbgt  lr, [r1], #1
-        strbgt  lr, [r0], #1
-
-        itt     ge
-        ldrbge  lr, [r1], #1
-        strbge  lr, [r0], #1
-
-        ldrb    lr, [r1], #1
-        strb    lr, [r0], #1
-
-        sub     r2, r2, ip
-
-        // Src is guaranteed to be at least word aligned by this point.
-        b       .L_word_aligned
-
-        // Undo any cfi directives from above.
-        .cfi_adjust_cfa_offset -24
-        .cfi_restore r4
-        .cfi_restore r5
-        .cfi_restore r6
-        .cfi_restore r7
-        .cfi_restore r8
-        .cfi_restore r9
diff --git a/libc/arch-arm/cortex-a15/bionic/memcpy_common.S b/libc/arch-arm/cortex-a15/bionic/memcpy_common.S
deleted file mode 100644
index 464fb46..0000000
--- a/libc/arch-arm/cortex-a15/bionic/memcpy_common.S
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * Copyright (c) 2013 ARM Ltd
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the company may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <private/bionic_asm.h>
-#include <private/libc_events.h>
-
-        .text
-        .syntax unified
-        .fpu    neon
-
-ENTRY(__memcpy_chk)
-        cmp     r2, r3
-        bhi     .L_memcpy_chk_fail
-
-        // Fall through to memcpy...
-END(__memcpy_chk)
-
-// Prototype: void *memcpy (void *dst, const void *src, size_t count).
-ENTRY(memcpy)
-        pld     [r1, #64]
-        push    {r0, lr}
-        .cfi_def_cfa_offset 8
-        .cfi_rel_offset r0, 0
-        .cfi_rel_offset lr, 4
-
-#include MEMCPY_BASE
-
-        // Undo the cfi instructions from above.
-        .cfi_def_cfa_offset 0
-        .cfi_restore r0
-        .cfi_restore lr
-.L_memcpy_chk_fail:
-        // Preserve lr for backtrace.
-        push    {lr}
-        .cfi_adjust_cfa_offset 4
-        .cfi_rel_offset lr, 0
-
-        ldr     r0, error_message
-        ldr     r1, error_code
-1:
-        add     r0, pc
-        bl      __fortify_chk_fail
-error_code:
-        .word   BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
-error_message:
-        .word   error_string-(1b+8)
-END(memcpy)
-
-        .data
-error_string:
-        .string "memcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a15/bionic/memset.S b/libc/arch-arm/cortex-a15/bionic/memset.S
index e4a1ec8..2542f3f 100644
--- a/libc/arch-arm/cortex-a15/bionic/memset.S
+++ b/libc/arch-arm/cortex-a15/bionic/memset.S
@@ -26,9 +26,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
         /*
          * Optimized memset() for ARM.
@@ -41,31 +39,16 @@
 
 ENTRY(__memset_chk)
         cmp         r2, r3
-        bls         .L_done
+        bls         memset
 
         // Preserve lr for backtrace.
         push        {lr}
         .cfi_def_cfa_offset 4
         .cfi_rel_offset lr, 0
 
-        ldr         r0, error_message
-        ldr         r1, error_code
-1:
-        add         r0, pc
-        bl          __fortify_chk_fail
-error_code:
-        .word       BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
-error_message:
-        .word       error_string-(1b+8)
+        bl          __memset_chk_fail
 END(__memset_chk)
 
-ENTRY(bzero)
-        mov         r2, r1
-        mov         r1, #0
-.L_done:
-        // Fall through to memset...
-END(bzero)
-
 ENTRY(memset)
         stmfd       sp!, {r0}
         .cfi_def_cfa_offset 4
@@ -185,7 +168,3 @@
         ldmfd       sp!, {r0}
         bx          lr
 END(memset)
-
-        .data
-error_string:
-        .string     "memset: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a15/bionic/strcmp.S b/libc/arch-arm/cortex-a15/bionic/strcmp.S
index acedf0e..5c8914b 100644
--- a/libc/arch-arm/cortex-a15/bionic/strcmp.S
+++ b/libc/arch-arm/cortex-a15/bionic/strcmp.S
@@ -26,7 +26,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
 
 #ifdef __ARMEB__
diff --git a/libc/arch-arm/cortex-a15/cortex-a15.mk b/libc/arch-arm/cortex-a15/cortex-a15.mk
deleted file mode 100644
index 20202a7..0000000
--- a/libc/arch-arm/cortex-a15/cortex-a15.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-
-libc_bionic_src_files_exclude_arm += \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a15/bionic/memcpy.S \
-    arch-arm/cortex-a15/bionic/memset.S \
-    arch-arm/cortex-a15/bionic/stpcpy.S \
-    arch-arm/cortex-a15/bionic/strcat.S \
-    arch-arm/cortex-a15/bionic/__strcat_chk.S \
-    arch-arm/cortex-a15/bionic/strcmp.S \
-    arch-arm/cortex-a15/bionic/strcpy.S \
-    arch-arm/cortex-a15/bionic/__strcpy_chk.S \
-    arch-arm/cortex-a15/bionic/strlen.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/denver/bionic/memmove.S \
diff --git a/libc/arch-arm/cortex-a53.a57/cortex-a53.a57.mk b/libc/arch-arm/cortex-a53.a57/cortex-a53.a57.mk
deleted file mode 100644
index 6455d04..0000000
--- a/libc/arch-arm/cortex-a53.a57/cortex-a53.a57.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# This file represents the best optimized routines that are the middle
-# ground when running on a big/little system that is cortex-a57/cortex-a53.
-# The cortex-a7 optimized routines, and the cortex-a53 optimized routines
-# decrease performance on cortex-a57 processors by as much as 20%.
-
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-
-libc_bionic_src_files_exclude_arm += \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a15/bionic/memcpy.S \
-    arch-arm/cortex-a15/bionic/memset.S \
-    arch-arm/cortex-a15/bionic/stpcpy.S \
-    arch-arm/cortex-a15/bionic/strcat.S \
-    arch-arm/cortex-a15/bionic/__strcat_chk.S \
-    arch-arm/cortex-a15/bionic/strcmp.S \
-    arch-arm/cortex-a15/bionic/strcpy.S \
-    arch-arm/cortex-a15/bionic/__strcpy_chk.S \
-    arch-arm/cortex-a15/bionic/strlen.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/denver/bionic/memmove.S \
diff --git a/libc/arch-arm/cortex-a53/bionic/__strcat_chk.S b/libc/arch-arm/cortex-a53/bionic/__strcat_chk.S
index c5bc98a..da40f6c 100644
--- a/libc/arch-arm/cortex-a53/bionic/__strcat_chk.S
+++ b/libc/arch-arm/cortex-a53/bionic/__strcat_chk.S
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,174 @@
  * SUCH DAMAGE.
  */
 
-// Indicate which memcpy base file to include.
-#define MEMCPY_BASE "arch-arm/cortex-a53/bionic/memcpy_base.S"
+#include <private/bionic_asm.h>
 
-#include "arch-arm/cortex-a15/bionic/__strcat_chk_common.S"
+    .syntax unified
+
+    .thumb
+    .thumb_func
+
+// Get the length of src string, then get the source of the dst string.
+// Check that the two lengths together don't exceed the threshold, then
+// do a memcpy of the data.
+ENTRY(__strcat_chk)
+    pld     [r0, #0]
+    push    {r0, lr}
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset r0, 0
+    .cfi_rel_offset lr, 4
+    push    {r4, r5}
+    .cfi_adjust_cfa_offset 8
+    .cfi_rel_offset r4, 0
+    .cfi_rel_offset r5, 4
+
+    mov     lr, r2
+
+    // Save the dst register to r5
+    mov     r5, r0
+
+    // Zero out r4
+    eor     r4, r4, r4
+
+    // r1 contains the address of the string to count.
+.L_strlen_start:
+    mov     r0, r1
+    ands    r3, r1, #7
+    beq     .L_mainloop
+
+    // Align to a double word (64 bits).
+    rsb     r3, r3, #8
+    lsls    ip, r3, #31
+    beq     .L_align_to_32
+
+    ldrb    r2, [r1], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_32:
+    bcc     .L_align_to_64
+    ands    ip, r3, #2
+    beq     .L_align_to_64
+
+    ldrb    r2, [r1], #1
+    cbz     r2, .L_update_count_and_finish
+    ldrb    r2, [r1], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_64:
+    tst     r3, #4
+    beq     .L_mainloop
+    ldr     r3, [r1], #4
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+
+    .p2align 2
+.L_mainloop:
+    ldrd    r2, r3, [r1], #8
+
+    pld     [r1, #64]
+
+    sub     ip, r2, #0x01010101
+    bic     ip, ip, r2
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_first_register
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+    b       .L_mainloop
+
+.L_update_count_and_finish:
+    sub     r3, r1, r0
+    sub     r3, r3, #1
+    b       .L_finish
+
+.L_zero_in_first_register:
+    sub     r3, r1, r0
+    lsls    r2, ip, #17
+    bne     .L_sub8_and_finish
+    bcs     .L_sub7_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub6_and_finish
+
+    sub     r3, r3, #5
+    b       .L_finish
+
+.L_sub8_and_finish:
+    sub     r3, r3, #8
+    b       .L_finish
+
+.L_sub7_and_finish:
+    sub     r3, r3, #7
+    b       .L_finish
+
+.L_sub6_and_finish:
+    sub     r3, r3, #6
+    b       .L_finish
+
+.L_zero_in_second_register:
+    sub     r3, r1, r0
+    lsls    r2, ip, #17
+    bne     .L_sub4_and_finish
+    bcs     .L_sub3_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub2_and_finish
+
+    sub     r3, r3, #1
+    b       .L_finish
+
+.L_sub4_and_finish:
+    sub     r3, r3, #4
+    b       .L_finish
+
+.L_sub3_and_finish:
+    sub     r3, r3, #3
+    b       .L_finish
+
+.L_sub2_and_finish:
+    sub     r3, r3, #2
+
+.L_finish:
+    cmp     r4, #0
+    bne     .L_strlen_done
+
+    // Time to get the dst string length.
+    mov     r1, r5
+
+    // Save the original source address to r5.
+    mov     r5, r0
+
+    // Save the current length (adding 1 for the terminator).
+    add     r4, r3, #1
+    b       .L_strlen_start
+
+    // r0 holds the pointer to the dst string.
+    // r3 holds the dst string length.
+    // r4 holds the src string length + 1.
+.L_strlen_done:
+    add     r2, r3, r4
+    cmp     r2, lr
+    itt     hi
+    movhi   r0, lr
+    bhi     __strcat_chk_fail
+
+    // Set up the registers for the memcpy code.
+    mov     r1, r5
+    pld     [r1, #64]
+    mov     r2, r4
+    add     r0, r0, r3
+    pop     {r4, r5}
+    .cfi_adjust_cfa_offset -8
+    .cfi_restore r4
+    .cfi_restore r5
+
+#include "memcpy_base.S"
+
+    // Undo the above cfi directives
+    .cfi_adjust_cfa_offset 8
+    .cfi_rel_offset r4, 0
+    .cfi_rel_offset r5, 4
+END(__strcat_chk)
diff --git a/libc/arch-arm/cortex-a53/bionic/__strcpy_chk.S b/libc/arch-arm/cortex-a53/bionic/__strcpy_chk.S
index 1f8945d..026adcc 100644
--- a/libc/arch-arm/cortex-a53/bionic/__strcpy_chk.S
+++ b/libc/arch-arm/cortex-a53/bionic/__strcpy_chk.S
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,136 @@
  * SUCH DAMAGE.
  */
 
-// Indicate which memcpy base file to include.
-#define MEMCPY_BASE "arch-arm/cortex-a53/bionic/memcpy_base.S"
+#include <private/bionic_asm.h>
 
-#include "arch-arm/cortex-a15/bionic/__strcpy_chk_common.S"
+    .syntax unified
+
+    .thumb
+    .thumb_func
+
+// Get the length of the source string first, then do a memcpy of the data
+// instead of a strcpy.
+ENTRY(__strcpy_chk)
+    pld     [r0, #0]
+    push    {r0, lr}
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset r0, 0
+    .cfi_rel_offset lr, 4
+
+    mov     lr, r2
+    mov     r0, r1
+
+    ands    r3, r1, #7
+    beq     .L_mainloop
+
+    // Align to a double word (64 bits).
+    rsb     r3, r3, #8
+    lsls    ip, r3, #31
+    beq     .L_align_to_32
+
+    ldrb    r2, [r0], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_32:
+    bcc     .L_align_to_64
+    ands    ip, r3, #2
+    beq     .L_align_to_64
+
+    ldrb    r2, [r0], #1
+    cbz     r2, .L_update_count_and_finish
+    ldrb    r2, [r0], #1
+    cbz     r2, .L_update_count_and_finish
+
+.L_align_to_64:
+    tst     r3, #4
+    beq     .L_mainloop
+    ldr     r3, [r0], #4
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+
+    .p2align 2
+.L_mainloop:
+    ldrd    r2, r3, [r0], #8
+
+    pld     [r0, #64]
+
+    sub     ip, r2, #0x01010101
+    bic     ip, ip, r2
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_first_register
+
+    sub     ip, r3, #0x01010101
+    bic     ip, ip, r3
+    ands    ip, ip, #0x80808080
+    bne     .L_zero_in_second_register
+    b       .L_mainloop
+
+.L_update_count_and_finish:
+    sub     r3, r0, r1
+    sub     r3, r3, #1
+    b       .L_check_size
+
+.L_zero_in_first_register:
+    sub     r3, r0, r1
+    lsls    r2, ip, #17
+    bne     .L_sub8_and_finish
+    bcs     .L_sub7_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub6_and_finish
+
+    sub     r3, r3, #5
+    b       .L_check_size
+
+.L_sub8_and_finish:
+    sub     r3, r3, #8
+    b       .L_check_size
+
+.L_sub7_and_finish:
+    sub     r3, r3, #7
+    b       .L_check_size
+
+.L_sub6_and_finish:
+    sub     r3, r3, #6
+    b       .L_check_size
+
+.L_zero_in_second_register:
+    sub     r3, r0, r1
+    lsls    r2, ip, #17
+    bne     .L_sub4_and_finish
+    bcs     .L_sub3_and_finish
+    lsls    ip, ip, #1
+    bne     .L_sub2_and_finish
+
+    sub     r3, r3, #1
+    b       .L_check_size
+
+.L_sub4_and_finish:
+    sub     r3, r3, #4
+    b       .L_check_size
+
+.L_sub3_and_finish:
+    sub     r3, r3, #3
+    b       .L_check_size
+
+.L_sub2_and_finish:
+    sub     r3, r3, #2
+
+.L_check_size:
+    pld     [r1, #0]
+    pld     [r1, #64]
+    ldr     r0, [sp]
+
+    // Add 1 for copy length to get the string terminator.
+    add     r2, r3, #1
+
+    cmp     r2, lr
+    itt     hi
+    movhi   r0, r2
+    bhi     __strcpy_chk_fail
+
+#include "memcpy_base.S"
+
+END(__strcpy_chk)
diff --git a/libc/arch-arm/cortex-a53/bionic/memcpy.S b/libc/arch-arm/cortex-a53/bionic/memcpy.S
index 664f574..9407a08 100644
--- a/libc/arch-arm/cortex-a53/bionic/memcpy.S
+++ b/libc/arch-arm/cortex-a53/bionic/memcpy.S
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2008 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,8 +25,58 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+/*
+ * Copyright (c) 2013 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
-// Indicate which memcpy base file to include.
-#define MEMCPY_BASE "arch-arm/cortex-a53/bionic/memcpy_base.S"
+#include <private/bionic_asm.h>
 
-#include "arch-arm/cortex-a15/bionic/memcpy_common.S"
+        .text
+        .syntax unified
+        .fpu    neon
+
+ENTRY(__memcpy_chk)
+        cmp r2, r3
+        bls memcpy
+
+        // Preserve lr for backtrace.
+        push        {lr}
+        .cfi_def_cfa_offset 4
+        .cfi_rel_offset lr, 0
+        bl          __memcpy_chk_fail
+END(__memcpy_chk)
+
+// Prototype: void *memcpy (void *dst, const void *src, size_t count).
+ENTRY(memcpy)
+        pld     [r1, #64]
+        push    {r0, lr}
+        .cfi_def_cfa_offset 8
+        .cfi_rel_offset r0, 0
+        .cfi_rel_offset lr, 4
+
+#include "memcpy_base.S"
+END(memcpy)
diff --git a/libc/arch-arm/cortex-a53/cortex-a53.mk b/libc/arch-arm/cortex-a53/cortex-a53.mk
deleted file mode 100644
index 9b431ae..0000000
--- a/libc/arch-arm/cortex-a53/cortex-a53.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-
-libc_bionic_src_files_exclude_arm += \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a53/bionic/memcpy.S \
-    arch-arm/cortex-a53/bionic/__strcat_chk.S \
-    arch-arm/cortex-a53/bionic/__strcpy_chk.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a7/bionic/memset.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a15/bionic/stpcpy.S \
-    arch-arm/cortex-a15/bionic/strcat.S \
-    arch-arm/cortex-a15/bionic/strcmp.S \
-    arch-arm/cortex-a15/bionic/strcpy.S \
-    arch-arm/cortex-a15/bionic/strlen.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/denver/bionic/memmove.S \
diff --git a/libc/arch-arm/cortex-a7/bionic/memset.S b/libc/arch-arm/cortex-a7/bionic/memset.S
index 6365b06..e4fb1b4 100644
--- a/libc/arch-arm/cortex-a7/bionic/memset.S
+++ b/libc/arch-arm/cortex-a7/bionic/memset.S
@@ -26,9 +26,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
         /*
          * Optimized memset() for ARM.
@@ -41,31 +39,16 @@
 
 ENTRY(__memset_chk)
         cmp         r2, r3
-        bls         .L_done
+        bls         memset
 
         // Preserve lr for backtrace.
         push        {lr}
         .cfi_def_cfa_offset 4
         .cfi_rel_offset lr, 0
 
-        ldr         r0, error_message
-        ldr         r1, error_code
-1:
-        add         r0, pc
-        bl          __fortify_chk_fail
-error_code:
-        .word       BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
-error_message:
-        .word       error_string-(1b+8)
+        bl          __memset_chk_fail
 END(__memset_chk)
 
-ENTRY(bzero)
-        mov         r2, r1
-        mov         r1, #0
-.L_done:
-        // Fall through to memset...
-END(bzero)
-
 ENTRY(memset)
         mov         r3, r0
         // At this point only d0, d1 are going to be used below.
@@ -174,7 +157,3 @@
         strbcs      r1, [r3], #1
         bx          lr
 END(memset)
-
-        .data
-error_string:
-        .string     "memset: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a7/cortex-a7.mk b/libc/arch-arm/cortex-a7/cortex-a7.mk
deleted file mode 100644
index f570d0f..0000000
--- a/libc/arch-arm/cortex-a7/cortex-a7.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-
-libc_bionic_src_files_exclude_arm += \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a7/bionic/memset.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a15/bionic/memcpy.S \
-    arch-arm/cortex-a15/bionic/stpcpy.S \
-    arch-arm/cortex-a15/bionic/strcat.S \
-    arch-arm/cortex-a15/bionic/__strcat_chk.S \
-    arch-arm/cortex-a15/bionic/strcmp.S \
-    arch-arm/cortex-a15/bionic/strcpy.S \
-    arch-arm/cortex-a15/bionic/__strcpy_chk.S \
-    arch-arm/cortex-a15/bionic/strlen.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/denver/bionic/memmove.S \
diff --git a/libc/arch-arm/cortex-a8/cortex-a8.mk b/libc/arch-arm/cortex-a8/cortex-a8.mk
deleted file mode 100644
index 9af03d9..0000000
--- a/libc/arch-arm/cortex-a8/cortex-a8.mk
+++ /dev/null
@@ -1 +0,0 @@
-include bionic/libc/arch-arm/cortex-a15/cortex-a15.mk
diff --git a/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S b/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S
index 45517f1..776c782 100644
--- a/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S
+++ b/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
     .syntax unified
     .fpu    neon
@@ -180,6 +179,8 @@
 .L_strlen_done:
     add     r2, r3, r4
     cmp     r2, lr
+    itt     hi
+    movhi   r0, lr
     bhi     __strcat_chk_fail
 
     // Set up the registers for the memcpy code.
@@ -195,26 +196,3 @@
 #define MEMCPY_BASE         __strcat_chk_memcpy_base
 #define MEMCPY_BASE_ALIGNED __strcat_chk_memcpy_base_aligned
 #include "memcpy_base.S"
-
-ENTRY_PRIVATE(__strcat_chk_fail)
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset r0, 0
-    .cfi_rel_offset lr, 4
-    .cfi_adjust_cfa_offset 8
-    .cfi_rel_offset r4, 0
-    .cfi_rel_offset r5, 4
-
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-error_code:
-    .word   BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
-END(__strcat_chk_fail)
-
-    .data
-error_string:
-    .string "strcat: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S b/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S
index 67eca08..1d5e70b 100644
--- a/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S
+++ b/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
     .syntax unified
     .fpu    neon
@@ -150,36 +149,18 @@
     pld     [r1, #0]
     pld     [r1, #64]
     ldr     r0, [sp]
-    cmp     r3, lr
-    bhs     __strcpy_chk_fail
 
     // Add 1 for copy length to get the string terminator.
     add     r2, r3, #1
 
+    cmp     r2, lr
+    itt     hi
+    movhi   r0, r2
+    bhi     __strcpy_chk_fail
+
     // Fall through into the memcpy_base function.
 END(__strcpy_chk)
 
 #define MEMCPY_BASE         __strcpy_chk_memcpy_base
 #define MEMCPY_BASE_ALIGNED __strcpy_chk_memcpy_base_aligned
 #include "memcpy_base.S"
-
-ENTRY_PRIVATE(__strcpy_chk_fail)
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset r0, 0
-    .cfi_rel_offset lr, 4
-
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-
-error_code:
-    .word   BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
-END(__strcpy_chk_fail)
-
-    .data
-error_string:
-    .string "strcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a9/bionic/memcpy.S b/libc/arch-arm/cortex-a9/bionic/memcpy.S
index db3e26f..93a8629 100644
--- a/libc/arch-arm/cortex-a9/bionic/memcpy.S
+++ b/libc/arch-arm/cortex-a9/bionic/memcpy.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
 /*
  * This code assumes it is running on a processor that supports all arm v7
@@ -42,9 +41,14 @@
 
 ENTRY(__memcpy_chk)
         cmp         r2, r3
-        bhi         __memcpy_chk_fail
+        bls         memcpy
 
-        // Fall through to memcpy...
+        // Preserve lr for backtrace.
+        push        {lr}
+        .cfi_def_cfa_offset 4
+        .cfi_rel_offset lr, 0
+
+        bl          __memcpy_chk_fail
 END(__memcpy_chk)
 
 ENTRY(memcpy)
@@ -59,24 +63,3 @@
 #define MEMCPY_BASE         __memcpy_base
 #define MEMCPY_BASE_ALIGNED __memcpy_base_aligned
 #include "memcpy_base.S"
-
-ENTRY_PRIVATE(__memcpy_chk_fail)
-        // Preserve lr for backtrace.
-        push    {lr}
-        .cfi_def_cfa_offset 4
-        .cfi_rel_offset lr, 0
-
-        ldr     r0, error_message
-        ldr     r1, error_code
-1:
-        add     r0, pc
-        bl      __fortify_chk_fail
-error_code:
-        .word   BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
-error_message:
-        .word   error_string-(1b+4)
-END(__memcpy_chk_fail)
-
-        .data
-error_string:
-        .string     "memcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a9/bionic/memset.S b/libc/arch-arm/cortex-a9/bionic/memset.S
index b39fcc4..d00231b 100644
--- a/libc/arch-arm/cortex-a9/bionic/memset.S
+++ b/libc/arch-arm/cortex-a9/bionic/memset.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
 /*
  * This code assumes it is running on a processor that supports all arm v7
@@ -39,32 +38,16 @@
 
 ENTRY(__memset_chk)
         cmp         r2, r3
-        bls         .L_done
+        bls         memset
 
         // Preserve lr for backtrace.
         push        {lr}
         .cfi_def_cfa_offset 4
         .cfi_rel_offset lr, 0
 
-        ldr         r0, error_message
-        ldr         r1, error_code
-1:
-        add         r0, pc
-        bl          __fortify_chk_fail
-error_code:
-        .word       BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
-error_message:
-        .word       error_string-(1b+8)
+        bl          __memset_chk_fail
 END(__memset_chk)
 
-ENTRY(bzero)
-        mov     r2, r1
-        mov     r1, #0
-
-.L_done:
-        // Fall through to memset...
-END(bzero)
-
 /* memset() returns its first argument.  */
 ENTRY(memset)
         // The neon memset only wins for less than 132.
@@ -176,7 +159,3 @@
         strbcs      r1, [r0]
         ldmfd       sp!, {r0, r4-r7, pc}
 END(memset)
-
-        .data
-error_string:
-        .string     "memset: prevented write past end of buffer"
diff --git a/libc/arch-arm/cortex-a9/bionic/strcmp.S b/libc/arch-arm/cortex-a9/bionic/strcmp.S
index 4ff26c0..ba191d6 100644
--- a/libc/arch-arm/cortex-a9/bionic/strcmp.S
+++ b/libc/arch-arm/cortex-a9/bionic/strcmp.S
@@ -26,7 +26,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
 
 #ifdef __ARMEB__
diff --git a/libc/arch-arm/cortex-a9/cortex-a9.mk b/libc/arch-arm/cortex-a9/cortex-a9.mk
deleted file mode 100644
index 8a26d6b..0000000
--- a/libc/arch-arm/cortex-a9/cortex-a9.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-    upstream-openbsd/lib/libc/string/strcpy.c \
-
-libc_bionic_src_files_exclude_arm += \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a9/bionic/memcpy.S \
-    arch-arm/cortex-a9/bionic/memset.S \
-    arch-arm/cortex-a9/bionic/stpcpy.S \
-    arch-arm/cortex-a9/bionic/strcat.S \
-    arch-arm/cortex-a9/bionic/__strcat_chk.S \
-    arch-arm/cortex-a9/bionic/strcmp.S \
-    arch-arm/cortex-a9/bionic/strcpy.S \
-    arch-arm/cortex-a9/bionic/__strcpy_chk.S \
-    arch-arm/cortex-a9/bionic/strlen.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/denver/bionic/memmove.S \
diff --git a/libc/arch-arm/denver/bionic/__strcat_chk.S b/libc/arch-arm/denver/bionic/__strcat_chk.S
index a2e9c22..9f7db59 100644
--- a/libc/arch-arm/denver/bionic/__strcat_chk.S
+++ b/libc/arch-arm/denver/bionic/__strcat_chk.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
     .syntax unified
 
@@ -177,7 +176,9 @@
 .L_strlen_done:
     add     r2, r3, r4
     cmp     r2, lr
-    bhi     __strcat_chk_failed
+    itt     hi
+    movhi   r0, lr
+    bhi     __strcat_chk_fail
 
     // Set up the registers for the memcpy code.
     mov     r1, r5
@@ -191,26 +192,3 @@
 #define MEMCPY_BASE_ALIGNED __strcat_chk_memcpy_base_aligned
 
 #include "memcpy_base.S"
-
-ENTRY_PRIVATE(__strcat_chk_failed)
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset r0, 0
-    .cfi_rel_offset lr, 4
-    .cfi_adjust_cfa_offset 8
-    .cfi_rel_offset r4, 0
-    .cfi_rel_offset r5, 4
-
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-error_code:
-    .word   BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
-END(__strcat_chk_failed)
-
-    .data
-error_string:
-    .string "strcat: prevented write past end of buffer"
diff --git a/libc/arch-arm/denver/bionic/__strcpy_chk.S b/libc/arch-arm/denver/bionic/__strcpy_chk.S
index db76686..9b7ea91 100644
--- a/libc/arch-arm/denver/bionic/__strcpy_chk.S
+++ b/libc/arch-arm/denver/bionic/__strcpy_chk.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
     .syntax unified
 
@@ -148,33 +147,18 @@
     pld     [r1, #0]
     pld     [r1, #64]
     ldr     r0, [sp]
-    cmp     r3, lr
-    bhs     __strcpy_chk_failed
 
     // Add 1 for copy length to get the string terminator.
     add     r2, r3, #1
+
+    cmp     r2, lr
+    itt     hi
+    movhi   r0, r2
+    bhi     __strcpy_chk_fail
+
+    // Fall through into the memcpy_base function.
 END(__strcpy_chk)
 
 #define MEMCPY_BASE         __strcpy_chk_memcpy_base
 #define MEMCPY_BASE_ALIGNED __strcpy_chk_memcpy_base_aligned
 #include "memcpy_base.S"
-
-ENTRY_PRIVATE(__strcpy_chk_failed)
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset r0, 0
-    .cfi_rel_offset lr, 4
-
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-error_code:
-    .word   BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
-END(__strcpy_chk_failed)
-
-    .data
-error_string:
-    .string "strcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/denver/bionic/memcpy.S b/libc/arch-arm/denver/bionic/memcpy.S
index 410b663..d4e0fb4 100644
--- a/libc/arch-arm/denver/bionic/memcpy.S
+++ b/libc/arch-arm/denver/bionic/memcpy.S
@@ -56,7 +56,6 @@
 // Prototype: void *memcpy (void *dst, const void *src, size_t count).
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
         .text
         .syntax unified
@@ -64,9 +63,14 @@
 
 ENTRY(__memcpy_chk)
         cmp     r2, r3
-        bhi     __memcpy_chk_fail
+        bls     memcpy
 
-        // Fall through to memcpy...
+        // Preserve lr for backtrace.
+        push    {lr}
+        .cfi_def_cfa_offset 4
+        .cfi_rel_offset lr, 0
+
+        bl      __memcpy_chk_fail
 END(__memcpy_chk)
 
 ENTRY(memcpy)
@@ -80,24 +84,3 @@
 #define MEMCPY_BASE         __memcpy_base
 #define MEMCPY_BASE_ALIGNED __memcpy_base_aligned
 #include "memcpy_base.S"
-
-ENTRY_PRIVATE(__memcpy_chk_fail)
-        // Preserve lr for backtrace.
-        push    {lr}
-        .cfi_def_cfa_offset 4
-        .cfi_rel_offset lr, 0
-
-        ldr     r0, error_message
-        ldr     r1, error_code
-1:
-        add     r0, pc
-        bl      __fortify_chk_fail
-error_code:
-        .word   BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
-error_message:
-        .word   error_string-(1b+8)
-END(__memcpy_chk_fail)
-
-        .data
-error_string:
-        .string "memcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/denver/bionic/memmove.S b/libc/arch-arm/denver/bionic/memmove.S
index 132190b..94302f3 100644
--- a/libc/arch-arm/denver/bionic/memmove.S
+++ b/libc/arch-arm/denver/bionic/memmove.S
@@ -28,7 +28,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
         .text
         .syntax unified
diff --git a/libc/arch-arm/denver/bionic/memset.S b/libc/arch-arm/denver/bionic/memset.S
index d77c244..88ffe5c 100644
--- a/libc/arch-arm/denver/bionic/memset.S
+++ b/libc/arch-arm/denver/bionic/memset.S
@@ -27,9 +27,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
         /*
          * Optimized memset() for ARM.
@@ -43,32 +41,16 @@
 
 ENTRY(__memset_chk)
         cmp         r2, r3
-        bls         .L_done
+        bls         memset
 
         // Preserve lr for backtrace.
         push        {lr}
         .cfi_def_cfa_offset 4
         .cfi_rel_offset lr, 0
 
-
-        ldr         r0, error_message
-        ldr         r1, error_code
-1:
-        add         r0, pc
-        bl          __fortify_chk_fail
-error_code:
-        .word       BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
-error_message:
-        .word       error_string-(1b+8)
+        bl          __memset_chk_fail
 END(__memset_chk)
 
-ENTRY(bzero)
-        mov         r2, r1
-        mov         r1, #0
-.L_done:
-        // Fall through to memset...
-END(bzero)
-
 ENTRY(memset)
         pldw        [r0]
         mov         r3, r0
@@ -202,7 +184,3 @@
 2:
         bx          lr
 END(memset)
-
-        .data
-error_string:
-        .string     "memset: prevented write past end of buffer"
diff --git a/libc/arch-arm/denver/denver.mk b/libc/arch-arm/denver/denver.mk
deleted file mode 100644
index f167991..0000000
--- a/libc/arch-arm/denver/denver.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-
-libc_bionic_src_files_exclude_arm += \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-
-libc_bionic_src_files_arm += \
-    arch-arm/denver/bionic/memcpy.S \
-    arch-arm/denver/bionic/memmove.S \
-    arch-arm/denver/bionic/memset.S \
-    arch-arm/denver/bionic/__strcat_chk.S \
-    arch-arm/denver/bionic/__strcpy_chk.S \
-
-# Use cortex-a15 versions of strcat/strcpy/strlen.
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a15/bionic/stpcpy.S \
-    arch-arm/cortex-a15/bionic/strcat.S \
-    arch-arm/cortex-a15/bionic/strcmp.S \
-    arch-arm/cortex-a15/bionic/strcpy.S \
-    arch-arm/cortex-a15/bionic/strlen.S \
diff --git a/libc/arch-arm/generic/bionic/memcmp.S b/libc/arch-arm/generic/bionic/memcmp.S
index 6643d55..e648720 100644
--- a/libc/arch-arm/generic/bionic/memcmp.S
+++ b/libc/arch-arm/generic/bionic/memcmp.S
@@ -26,7 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
 
 
diff --git a/libc/arch-arm/generic/bionic/memcpy.S b/libc/arch-arm/generic/bionic/memcpy.S
index 65cba4c..a3ebb95 100644
--- a/libc/arch-arm/generic/bionic/memcpy.S
+++ b/libc/arch-arm/generic/bionic/memcpy.S
@@ -26,9 +26,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
         /*
          * Optimized memcpy() for ARM.
@@ -41,9 +39,14 @@
 
 ENTRY(__memcpy_chk)
         cmp         r2, r3
-        bhi         __memcpy_chk_fail
+        bls         memcpy
 
-        // Fall through to memcpy...
+        // Preserve lr for backtrace.
+        push        {lr}
+        .cfi_def_cfa_offset 4
+        .cfi_rel_offset lr, 0
+
+        bl          __memcpy_chk_fail
 END(__memcpy_chk)
 
 ENTRY(memcpy)
@@ -386,25 +389,3 @@
         add         sp,  sp, #28
         ldmfd       sp!, {r0, r4, pc}
 END(memcpy)
-
-        // Only reached when the __memcpy_chk check fails.
-ENTRY_PRIVATE(__memcpy_chk_fail)
-        // Preserve lr for backtrace.
-        push    {lr}
-        .cfi_def_cfa_offset 4
-        .cfi_rel_offset lr, 0
-
-        ldr     r0, error_message
-        ldr     r1, error_code
-1:
-        add     r0, pc
-        bl      __fortify_chk_fail
-error_code:
-        .word   BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
-error_message:
-        .word   error_string-(1b+8)
-END(__memcpy_chk_fail)
-
-        .data
-error_string:
-        .string     "memcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/generic/bionic/memset.S b/libc/arch-arm/generic/bionic/memset.S
index b8eabbf..1fd0de1 100644
--- a/libc/arch-arm/generic/bionic/memset.S
+++ b/libc/arch-arm/generic/bionic/memset.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
         /*
          * Optimized memset() for ARM.
@@ -39,28 +38,11 @@
 
 ENTRY(__memset_chk)
         cmp         r2, r3
-        bls         done
+        bls         memset
 
-        ldr         r0, error_message
-        ldr         r1, error_code
-1:
-        add         r0, pc
-        bl          __fortify_chk_fail
-error_code:
-        .word       BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
-error_message:
-        .word       error_string-(1b+8)
-
+        bl          __memset_chk_fail
 END(__memset_chk)
 
-ENTRY(bzero)
-        mov     r2, r1
-        mov     r1, #0
-
-done:
-        // Fall through to memset...
-END(bzero)
-
 ENTRY(memset)
         /* compute the offset to align the destination
          * offset = (4-(src&3))&3 = -src & 3
@@ -127,7 +109,3 @@
         strbcs      r1, [r0]
         ldmfd       sp!, {r0, r4-r7, pc}
 END(memset)
-
-        .data
-error_string:
-        .string     "memset: prevented write past end of buffer"
diff --git a/libc/arch-arm/generic/bionic/strcmp.S b/libc/arch-arm/generic/bionic/strcmp.S
index 6dba942..10b6704 100644
--- a/libc/arch-arm/generic/bionic/strcmp.S
+++ b/libc/arch-arm/generic/bionic/strcmp.S
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
 
 	.text
diff --git a/libc/arch-arm/generic/bionic/strcpy.S b/libc/arch-arm/generic/bionic/strcpy.S
index 89ea098..c0ab9e5 100644
--- a/libc/arch-arm/generic/bionic/strcpy.S
+++ b/libc/arch-arm/generic/bionic/strcpy.S
@@ -29,7 +29,6 @@
  * Android adaptation and tweak by Jim Huang <jserv@0xlab.org>.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
 
 .syntax unified
diff --git a/libc/arch-arm/generic/bionic/strlen.c b/libc/arch-arm/generic/bionic/strlen.c
index 811e1e0..b9f3a2a 100644
--- a/libc/arch-arm/generic/bionic/strlen.c
+++ b/libc/arch-arm/generic/bionic/strlen.c
@@ -25,9 +25,9 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #include <string.h>
 #include <stdint.h>
-#include <machine/cpu-features.h>
 
 size_t strlen(const char *s)
 {
diff --git a/libc/arch-arm/include/machine/elf_machdep.h b/libc/arch-arm/include/machine/elf_machdep.h
index 542f638..3496b28 100644
--- a/libc/arch-arm/include/machine/elf_machdep.h
+++ b/libc/arch-arm/include/machine/elf_machdep.h
@@ -3,11 +3,7 @@
 #ifndef _ARM_ELF_MACHDEP_H_
 #define _ARM_ELF_MACHDEP_H_
 
-#if defined(__ARMEB__)
-#define ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
-#else
 #define ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
-#endif
 
 #define ELF64_MACHDEP_ENDIANNESS	XXX	/* break compilation */
 #define ELF64_MACHDEP_ID_CASES                                          \
@@ -126,15 +122,4 @@
 /* Processor specific symbol types */
 #define STT_ARM_TFUNC		STT_LOPROC
 
-#ifdef _KERNEL
-#ifdef ELFSIZE
-#define	ELF_MD_PROBE_FUNC	ELFNAME2(arm_netbsd,probe)
-#endif
-
-struct exec_package;
-
-int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
-	vaddr_t *);
-#endif
-
 #endif /* _ARM_ELF_MACHDEP_H_ */
diff --git a/libm/include/arm/machine/fenv.h b/libc/arch-arm/include/machine/fenv.h
similarity index 100%
rename from libm/include/arm/machine/fenv.h
rename to libc/arch-arm/include/machine/fenv.h
diff --git a/libc/arch-arm/krait/bionic/__strcat_chk.S b/libc/arch-arm/krait/bionic/__strcat_chk.S
index 1a39c5b..a46ff98 100644
--- a/libc/arch-arm/krait/bionic/__strcat_chk.S
+++ b/libc/arch-arm/krait/bionic/__strcat_chk.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
     .syntax unified
 
@@ -177,7 +176,9 @@
 .L_strlen_done:
     add     r2, r3, r4
     cmp     r2, lr
-    bhi     .L_strcat_chk_failed
+    itt     hi
+    movhi   r0, lr
+    bhi     __strcat_chk_fail
 
     // Set up the registers for the memcpy code.
     mov     r1, r5
@@ -195,18 +196,4 @@
     .cfi_adjust_cfa_offset 8
     .cfi_rel_offset r4, 0
     .cfi_rel_offset r5, 4
-.L_strcat_chk_failed:
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-error_code:
-    .word   BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
 END(__strcat_chk)
-
-    .data
-error_string:
-    .string "strcat: prevented write past end of buffer"
diff --git a/libc/arch-arm/krait/bionic/__strcpy_chk.S b/libc/arch-arm/krait/bionic/__strcpy_chk.S
index 00202f3..9c2f66a 100644
--- a/libc/arch-arm/krait/bionic/__strcpy_chk.S
+++ b/libc/arch-arm/krait/bionic/__strcpy_chk.S
@@ -27,7 +27,6 @@
  */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
     .syntax unified
 
@@ -148,26 +147,15 @@
     pld     [r1, #0]
     pld     [r1, #64]
     ldr     r0, [sp]
-    cmp     r3, lr
-    bhs     .L_strcpy_chk_failed
 
     // Add 1 for copy length to get the string terminator.
     add     r2, r3, #1
 
+    cmp     r2, lr
+    itt     hi
+    movhi   r0, r2
+    bhi     __strcpy_chk_fail
+
 #include "memcpy_base.S"
 
-.L_strcpy_chk_failed:
-    ldr     r0, error_message
-    ldr     r1, error_code
-1:
-    add     r0, pc
-    bl      __fortify_chk_fail
-error_code:
-    .word   BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
-error_message:
-    .word   error_string-(1b+4)
 END(__strcpy_chk)
-
-    .data
-error_string:
-    .string "strcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/krait/bionic/memcpy.S b/libc/arch-arm/krait/bionic/memcpy.S
index 5d27b57..de6f432 100644
--- a/libc/arch-arm/krait/bionic/memcpy.S
+++ b/libc/arch-arm/krait/bionic/memcpy.S
@@ -29,7 +29,6 @@
 /* Assumes neon instructions and a cache line size of 32 bytes. */
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
 /*
  * This code assumes it is running on a processor that supports all arm v7
@@ -45,9 +44,14 @@
 
 ENTRY(__memcpy_chk)
         cmp         r2, r3
-        bhi         .L_memcpy_chk_fail
+        bls         memcpy
 
-        // Fall through to memcpy...
+        // Preserve lr for backtrace.
+        push        {lr}
+        .cfi_def_cfa_offset 4
+        .cfi_rel_offset lr, 0
+
+        bl          __memcpy_chk_fail
 END(__memcpy_chk)
 
 ENTRY(memcpy)
@@ -58,28 +62,4 @@
         .cfi_rel_offset lr, 4
 
 #include "memcpy_base.S"
-
-        // Undo the cfi directives from above.
-        .cfi_adjust_cfa_offset -8
-        .cfi_restore r0
-        .cfi_restore lr
-.L_memcpy_chk_fail:
-        // Preserve lr for backtrace.
-        push    {lr}
-        .cfi_adjust_cfa_offset 4
-        .cfi_rel_offset lr, 0
-
-        ldr     r0, error_message
-        ldr     r1, error_code
-1:
-        add     r0, pc
-        bl      __fortify_chk_fail
-error_code:
-        .word   BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
-error_message:
-        .word   error_string-(1b+4)
 END(memcpy)
-
-        .data
-error_string:
-        .string     "memcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm/krait/bionic/memcpy_base.S b/libc/arch-arm/krait/bionic/memcpy_base.S
index 76c5a84..7368e63 100644
--- a/libc/arch-arm/krait/bionic/memcpy_base.S
+++ b/libc/arch-arm/krait/bionic/memcpy_base.S
@@ -27,7 +27,6 @@
 
 /* Assumes neon instructions and a cache line size of 64 bytes. */
 
-#include <machine/cpu-features.h>
 #include <machine/asm.h>
 
 #define PLDOFFS	(10)
diff --git a/libc/arch-arm/krait/bionic/memset.S b/libc/arch-arm/krait/bionic/memset.S
index ae05965..228942c 100644
--- a/libc/arch-arm/krait/bionic/memset.S
+++ b/libc/arch-arm/krait/bionic/memset.S
@@ -26,9 +26,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
 /*
  * This code assumes it is running on a processor that supports all arm v7
@@ -41,32 +39,16 @@
 
 ENTRY(__memset_chk)
         cmp         r2, r3
-        bls         .L_done
+        bls         memset
 
         // Preserve lr for backtrace.
         push        {lr}
         .cfi_def_cfa_offset 4
         .cfi_rel_offset lr, 0
 
-        ldr         r0, error_message
-        ldr         r1, error_code
-1:
-        add         r0, pc
-        bl          __fortify_chk_fail
-error_code:
-        .word       BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
-error_message:
-        .word       error_string-(1b+8)
+        bl          __memset_chk_fail
 END(__memset_chk)
 
-ENTRY(bzero)
-        mov     r2, r1
-        mov     r1, #0
-
-.L_done:
-        // Fall through to memset...
-END(bzero)
-
 /* memset() returns its first argument.  */
 ENTRY(memset)
         mov         r3, r0
@@ -101,7 +83,3 @@
         strbcs      r1, [r3], #1
         bx          lr
 END(memset)
-
-        .data
-error_string:
-        .string     "memset: prevented write past end of buffer"
diff --git a/libc/arch-arm/krait/bionic/strcmp.S b/libc/arch-arm/krait/bionic/strcmp.S
index 9121c01..b871c76 100644
--- a/libc/arch-arm/krait/bionic/strcmp.S
+++ b/libc/arch-arm/krait/bionic/strcmp.S
@@ -26,7 +26,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <machine/cpu-features.h>
 #include <private/bionic_asm.h>
 
 #ifdef __ARMEB__
diff --git a/libc/arch-arm/krait/krait.mk b/libc/arch-arm/krait/krait.mk
deleted file mode 100644
index f8e3452..0000000
--- a/libc/arch-arm/krait/krait.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-libc_openbsd_src_files_exclude_arm += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-
-libc_bionic_src_files_exclude_arm += \
-    arch-arm/generic/bionic/memcpy.S \
-    arch-arm/generic/bionic/memset.S \
-    arch-arm/generic/bionic/strcmp.S \
-    arch-arm/generic/bionic/strcpy.S \
-    arch-arm/generic/bionic/strlen.c \
-    bionic/__strcat_chk.cpp \
-    bionic/__strcpy_chk.cpp \
-
-libc_bionic_src_files_arm += \
-    arch-arm/krait/bionic/memcpy.S \
-    arch-arm/krait/bionic/memset.S \
-    arch-arm/krait/bionic/strcmp.S \
-    arch-arm/krait/bionic/__strcat_chk.S \
-    arch-arm/krait/bionic/__strcpy_chk.S \
-
-# Use cortex-a15 versions of strcat/strcpy/strlen and standard memmove
-libc_bionic_src_files_arm += \
-    arch-arm/cortex-a15/bionic/stpcpy.S \
-    arch-arm/cortex-a15/bionic/strcat.S \
-    arch-arm/cortex-a15/bionic/strcpy.S \
-    arch-arm/cortex-a15/bionic/strlen.S \
-
-libc_bionic_src_files_arm += \
-    arch-arm/denver/bionic/memmove.S \
diff --git a/libc/arch-arm/syscalls/clock_gettime.S b/libc/arch-arm/syscalls/__clock_gettime.S
similarity index 87%
rename from libc/arch-arm/syscalls/clock_gettime.S
rename to libc/arch-arm/syscalls/__clock_gettime.S
index 61a95dd..30eff03 100644
--- a/libc/arch-arm/syscalls/clock_gettime.S
+++ b/libc/arch-arm/syscalls/__clock_gettime.S
@@ -2,7 +2,7 @@
 
 #include <private/bionic_asm.h>
 
-ENTRY(clock_gettime)
+ENTRY(__clock_gettime)
     mov     ip, r7
     .cfi_register r7, ip
     ldr     r7, =__NR_clock_gettime
@@ -13,4 +13,4 @@
     bxls    lr
     neg     r0, r0
     b       __set_errno_internal
-END(clock_gettime)
+END(__clock_gettime)
diff --git a/libc/arch-arm/syscalls/gettimeofday.S b/libc/arch-arm/syscalls/__gettimeofday.S
similarity index 88%
rename from libc/arch-arm/syscalls/gettimeofday.S
rename to libc/arch-arm/syscalls/__gettimeofday.S
index f5ed674..de0eca5 100644
--- a/libc/arch-arm/syscalls/gettimeofday.S
+++ b/libc/arch-arm/syscalls/__gettimeofday.S
@@ -2,7 +2,7 @@
 
 #include <private/bionic_asm.h>
 
-ENTRY(gettimeofday)
+ENTRY(__gettimeofday)
     mov     ip, r7
     .cfi_register r7, ip
     ldr     r7, =__NR_gettimeofday
@@ -13,4 +13,4 @@
     bxls    lr
     neg     r0, r0
     b       __set_errno_internal
-END(gettimeofday)
+END(__gettimeofday)
diff --git a/libc/arch-arm/syscalls/__sync_file_range2.S b/libc/arch-arm/syscalls/__sync_file_range2.S
new file mode 100644
index 0000000..4346e1b
--- /dev/null
+++ b/libc/arch-arm/syscalls/__sync_file_range2.S
@@ -0,0 +1,22 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range2)
+    mov     ip, sp
+    stmfd   sp!, {r4, r5, r6, r7}
+    .cfi_def_cfa_offset 16
+    .cfi_rel_offset r4, 0
+    .cfi_rel_offset r5, 4
+    .cfi_rel_offset r6, 8
+    .cfi_rel_offset r7, 12
+    ldmfd   ip, {r4, r5, r6}
+    ldr     r7, =__NR_sync_file_range2
+    swi     #0
+    ldmfd   sp!, {r4, r5, r6, r7}
+    .cfi_def_cfa_offset 0
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno_internal
+END(__sync_file_range2)
diff --git a/libc/arch-arm/syscalls/gettimeofday.S b/libc/arch-arm/syscalls/quotactl.S
similarity index 79%
copy from libc/arch-arm/syscalls/gettimeofday.S
copy to libc/arch-arm/syscalls/quotactl.S
index f5ed674..fde17f4 100644
--- a/libc/arch-arm/syscalls/gettimeofday.S
+++ b/libc/arch-arm/syscalls/quotactl.S
@@ -2,10 +2,10 @@
 
 #include <private/bionic_asm.h>
 
-ENTRY(gettimeofday)
+ENTRY(quotactl)
     mov     ip, r7
     .cfi_register r7, ip
-    ldr     r7, =__NR_gettimeofday
+    ldr     r7, =__NR_quotactl
     swi     #0
     mov     r7, ip
     .cfi_restore r7
@@ -13,4 +13,4 @@
     bxls    lr
     neg     r0, r0
     b       __set_errno_internal
-END(gettimeofday)
+END(quotactl)
diff --git a/libc/arch-arm/syscalls/clock_gettime.S b/libc/arch-arm/syscalls/setdomainname.S
similarity index 78%
copy from libc/arch-arm/syscalls/clock_gettime.S
copy to libc/arch-arm/syscalls/setdomainname.S
index 61a95dd..4014a48 100644
--- a/libc/arch-arm/syscalls/clock_gettime.S
+++ b/libc/arch-arm/syscalls/setdomainname.S
@@ -2,10 +2,10 @@
 
 #include <private/bionic_asm.h>
 
-ENTRY(clock_gettime)
+ENTRY(setdomainname)
     mov     ip, r7
     .cfi_register r7, ip
-    ldr     r7, =__NR_clock_gettime
+    ldr     r7, =__NR_setdomainname
     swi     #0
     mov     r7, ip
     .cfi_restore r7
@@ -13,4 +13,4 @@
     bxls    lr
     neg     r0, r0
     b       __set_errno_internal
-END(clock_gettime)
+END(setdomainname)
diff --git a/libc/arch-arm64/arm64.mk b/libc/arch-arm64/arm64.mk
deleted file mode 100644
index 9a76072..0000000
--- a/libc/arch-arm64/arm64.mk
+++ /dev/null
@@ -1,71 +0,0 @@
-# 64-bit arm.
-
-#
-# Generic arm64 optimizations, may be overriden by CPU variants.
-#
-
-libc_bionic_src_files_arm64 += \
-    arch-arm64/generic/bionic/memchr.S \
-    arch-arm64/generic/bionic/memcmp.S \
-    arch-arm64/generic/bionic/memcpy.S \
-    arch-arm64/generic/bionic/memmove.S \
-    arch-arm64/generic/bionic/memset.S \
-    arch-arm64/generic/bionic/stpcpy.S \
-    arch-arm64/generic/bionic/strchr.S \
-    arch-arm64/generic/bionic/strcmp.S \
-    arch-arm64/generic/bionic/strcpy.S \
-    arch-arm64/generic/bionic/strlen.S \
-    arch-arm64/generic/bionic/strncmp.S \
-    arch-arm64/generic/bionic/strnlen.S \
-    arch-arm64/generic/bionic/wmemmove.S \
-
-libc_bionic_src_files_exclude_arm64 += \
-    bionic/__memcpy_chk.cpp \
-    bionic/strchr.cpp \
-    bionic/strnlen.c \
-
-libc_freebsd_src_files_exclude_arm64 += \
-    upstream-freebsd/lib/libc/string/wmemmove.c \
-
-libc_openbsd_src_files_exclude_arm64 += \
-    upstream-openbsd/lib/libc/string/memchr.c \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/strcpy.c \
-    upstream-openbsd/lib/libc/string/strncmp.c \
-
-#
-# Inherently architecture-specific code.
-#
-
-libc_bionic_src_files_arm64 += \
-    arch-arm64/bionic/__bionic_clone.S \
-    arch-arm64/bionic/_exit_with_stack_teardown.S \
-    arch-arm64/bionic/setjmp.S \
-    arch-arm64/bionic/syscall.S \
-    arch-arm64/bionic/vfork.S \
-
-
-libc_crt_target_cflags_arm64 := \
-    -I$(LOCAL_PATH)/arch-arm64/include
-
-libc_crt_target_crtbegin_file_arm64 := \
-    $(LOCAL_PATH)/arch-arm64/bionic/crtbegin.c
-
-libc_crt_target_crtbegin_so_file_arm64 := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c
-
-## CPU variant specific source files
-ifeq ($(strip $(TARGET_CPU_VARIANT)),)
-  $(warning TARGET_ARCH is arm64, but TARGET_CPU_VARIANT is not defined)
-endif
-ifneq ($(TARGET_CPU_VARIANT),generic)
-cpu_variant_mk := $(LOCAL_PATH)/arch-arm64/$(TARGET_CPU_VARIANT)/$(TARGET_CPU_VARIANT).mk
-ifeq ($(wildcard $(cpu_variant_mk)),)
-$(error "TARGET_CPU_VARIANT not set or set to an unknown value. Possible values are generic, denver64. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
-endif
-include $(cpu_variant_mk)
-libc_common_additional_dependencies += $(cpu_variant_mk)
-
-cpu_variant_mk :=
-endif
diff --git a/libc/arch-arm64/bionic/__bionic_clone.S b/libc/arch-arm64/bionic/__bionic_clone.S
index 27e44e7..c3ff0e5 100644
--- a/libc/arch-arm64/bionic/__bionic_clone.S
+++ b/libc/arch-arm64/bionic/__bionic_clone.S
@@ -30,7 +30,7 @@
 
 // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
 
-ENTRY(__bionic_clone)
+ENTRY_PRIVATE(__bionic_clone)
     # Push 'fn' and 'arg' onto the child stack.
     stp     x5, x6, [x1, #-16]!
 
@@ -57,4 +57,3 @@
     ldp     x0, x1, [sp], #16
     b       __start_thread
 END(__bionic_clone)
-.hidden __bionic_clone
diff --git a/libc/arch-arm64/denver64/bionic/memcpy.S b/libc/arch-arm64/denver64/bionic/memcpy.S
index 85129fe..0be2aac 100644
--- a/libc/arch-arm64/denver64/bionic/memcpy.S
+++ b/libc/arch-arm64/denver64/bionic/memcpy.S
@@ -29,35 +29,20 @@
 // Prototype: void *memcpy (void *dst, const void *src, size_t count).
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
 ENTRY(__memcpy_chk)
-  cmp   x2, x3
-  b.hi  __memcpy_chk_fail
+  cmp x2, x3
+  bls memcpy
 
-  // Fall through to memcpy...
+  // Preserve for accurate backtrace.
+  stp x29, x30, [sp, -16]!
+  .cfi_def_cfa_offset 16
+  .cfi_rel_offset x29, 0
+  .cfi_rel_offset x30, 8
+
+  bl __memcpy_chk_fail
 END(__memcpy_chk)
 
 ENTRY(memcpy)
   #include "memcpy_base.S"
 END(memcpy)
-
-ENTRY_PRIVATE(__memcpy_chk_fail)
-  // Preserve for accurate backtrace.
-  stp  x29, x30, [sp, -16]!
-  .cfi_def_cfa_offset 16
-  .cfi_rel_offset x29, 0
-  .cfi_rel_offset x30, 8
-
-  adrp  x0, error_string
-  add   x0, x0, :lo12:error_string
-  ldr   x1, error_code
-  bl    __fortify_chk_fail
-error_code:
-  .word   BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
-END(__memcpy_chk_fail)
-
-  .data
-  .align 2
-error_string:
-  .string "memcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm64/denver64/bionic/memset.S b/libc/arch-arm64/denver64/bionic/memset.S
index 9127d89..bea5b26 100644
--- a/libc/arch-arm64/denver64/bionic/memset.S
+++ b/libc/arch-arm64/denver64/bionic/memset.S
@@ -48,6 +48,7 @@
 #define dstin		x0
 #define val		w1
 #define count		x2
+#define dst_count x3 /* for __memset_chk */
 #define tmp1		x3
 #define tmp1w		w3
 #define tmp2		x4
@@ -63,6 +64,19 @@
 
 #define QA_l		q0
 
+ENTRY(__memset_chk)
+  cmp count, dst_count
+  bls memset
+
+  // Preserve for accurate backtrace.
+  stp x29, x30, [sp, -16]!
+  .cfi_def_cfa_offset 16
+  .cfi_rel_offset x29, 0
+  .cfi_rel_offset x30, 8
+
+  bl __memset_chk_fail
+END(__memset_chk)
+
 ENTRY(memset)
 
 	mov	dst, dstin		/* Preserve return value.  */
diff --git a/libc/arch-arm64/denver64/denver64.mk b/libc/arch-arm64/denver64/denver64.mk
deleted file mode 100644
index 703af45..0000000
--- a/libc/arch-arm64/denver64/denver64.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-libc_bionic_src_files_arm64 += \
-    arch-arm64/denver64/bionic/memcpy.S \
-    arch-arm64/denver64/bionic/memset.S \
-
-libc_bionic_src_files_exclude_arm64 += \
-    arch-arm64/generic/bionic/memcpy.S \
-    arch-arm64/generic/bionic/memset.S \
diff --git a/libc/arch-arm64/generic/bionic/memcpy.S b/libc/arch-arm64/generic/bionic/memcpy.S
index 85129fe..0be2aac 100644
--- a/libc/arch-arm64/generic/bionic/memcpy.S
+++ b/libc/arch-arm64/generic/bionic/memcpy.S
@@ -29,35 +29,20 @@
 // Prototype: void *memcpy (void *dst, const void *src, size_t count).
 
 #include <private/bionic_asm.h>
-#include <private/libc_events.h>
 
 ENTRY(__memcpy_chk)
-  cmp   x2, x3
-  b.hi  __memcpy_chk_fail
+  cmp x2, x3
+  bls memcpy
 
-  // Fall through to memcpy...
+  // Preserve for accurate backtrace.
+  stp x29, x30, [sp, -16]!
+  .cfi_def_cfa_offset 16
+  .cfi_rel_offset x29, 0
+  .cfi_rel_offset x30, 8
+
+  bl __memcpy_chk_fail
 END(__memcpy_chk)
 
 ENTRY(memcpy)
   #include "memcpy_base.S"
 END(memcpy)
-
-ENTRY_PRIVATE(__memcpy_chk_fail)
-  // Preserve for accurate backtrace.
-  stp  x29, x30, [sp, -16]!
-  .cfi_def_cfa_offset 16
-  .cfi_rel_offset x29, 0
-  .cfi_rel_offset x30, 8
-
-  adrp  x0, error_string
-  add   x0, x0, :lo12:error_string
-  ldr   x1, error_code
-  bl    __fortify_chk_fail
-error_code:
-  .word   BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
-END(__memcpy_chk_fail)
-
-  .data
-  .align 2
-error_string:
-  .string "memcpy: prevented write past end of buffer"
diff --git a/libc/arch-arm64/generic/bionic/memset.S b/libc/arch-arm64/generic/bionic/memset.S
index 7c204b4..9626c0b 100644
--- a/libc/arch-arm64/generic/bionic/memset.S
+++ b/libc/arch-arm64/generic/bionic/memset.S
@@ -45,12 +45,9 @@
    values rather than re-reading them each call.  */
 
 #define dstin		x0
-#ifdef BZERO
-#define count		x1
-#else
-#define count		x2
-#endif
 #define val		w1
+#define count		x2
+#define dst_count x3 /* for __memset_chk */
 #define tmp1		x3
 #define tmp1w		w3
 #define tmp2		x4
@@ -64,16 +61,22 @@
 #define dst		x8
 #define tmp3w		w9
 
-#ifdef BZERO
-ENTRY(bzero)
-#else
+ENTRY(__memset_chk)
+  cmp count, dst_count
+  bls memset
+
+  // Preserve for accurate backtrace.
+  stp x29, x30, [sp, -16]!
+  .cfi_def_cfa_offset 16
+  .cfi_rel_offset x29, 0
+  .cfi_rel_offset x30, 8
+
+  bl __memset_chk_fail
+END(__memset_chk)
+
 ENTRY(memset)
-#endif
 
 	mov	dst, dstin		/* Preserve return value.  */
-#ifdef BZERO
-	b	.Lzero_mem
-#endif
 	ands	A_lw, val, #255
 	b.eq	.Lzero_mem
 	orr	A_lw, A_lw, A_lw, lsl #8
@@ -233,11 +236,7 @@
 	ands	count, count, zva_bits_x
 	b.ne	.Ltail_maybe_long
 	ret
-#ifdef BZERO
-END(bzero)
-#else
 END(memset)
-#endif
 
 #ifdef MAYBE_VIRT
 	.bss
diff --git a/libm/include/arm64/machine/fenv.h b/libc/arch-arm64/include/machine/fenv.h
similarity index 100%
rename from libm/include/arm64/machine/fenv.h
rename to libc/arch-arm64/include/machine/fenv.h
diff --git a/libc/arch-arm64/syscalls/__sync_file_range.S b/libc/arch-arm64/syscalls/__sync_file_range.S
new file mode 100644
index 0000000..776e900
--- /dev/null
+++ b/libc/arch-arm64/syscalls/__sync_file_range.S
@@ -0,0 +1,15 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+    mov     x8, __NR_sync_file_range
+    svc     #0
+
+    cmn     x0, #(MAX_ERRNO + 1)
+    cneg    x0, x0, hi
+    b.hi    __set_errno_internal
+
+    ret
+END(__sync_file_range)
+.hidden __sync_file_range
diff --git a/libc/arch-arm64/syscalls/quotactl.S b/libc/arch-arm64/syscalls/quotactl.S
new file mode 100644
index 0000000..b67d47e
--- /dev/null
+++ b/libc/arch-arm64/syscalls/quotactl.S
@@ -0,0 +1,14 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(quotactl)
+    mov     x8, __NR_quotactl
+    svc     #0
+
+    cmn     x0, #(MAX_ERRNO + 1)
+    cneg    x0, x0, hi
+    b.hi    __set_errno_internal
+
+    ret
+END(quotactl)
diff --git a/libc/arch-arm64/syscalls/setdomainname.S b/libc/arch-arm64/syscalls/setdomainname.S
new file mode 100644
index 0000000..18f8d4b
--- /dev/null
+++ b/libc/arch-arm64/syscalls/setdomainname.S
@@ -0,0 +1,14 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(setdomainname)
+    mov     x8, __NR_setdomainname
+    svc     #0
+
+    cmn     x0, #(MAX_ERRNO + 1)
+    cneg    x0, x0, hi
+    b.hi    __set_errno_internal
+
+    ret
+END(setdomainname)
diff --git a/libc/arch-mips/bionic/__bionic_clone.S b/libc/arch-mips/bionic/__bionic_clone.S
index b216efe..a3cacd1 100644
--- a/libc/arch-mips/bionic/__bionic_clone.S
+++ b/libc/arch-mips/bionic/__bionic_clone.S
@@ -31,7 +31,7 @@
 #include <linux/sched.h>
 
 // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
-ENTRY(__bionic_clone)
+ENTRY_PRIVATE(__bionic_clone)
         .set	noreorder
         .cpload t9
         .set	reorder
@@ -69,4 +69,3 @@
 	la	t9,__set_errno_internal
 	j	t9
 END(__bionic_clone)
-.hidden __bionic_clone
diff --git a/libc/arch-mips/bionic/bzero.S b/libc/arch-mips/bionic/bzero.S
deleted file mode 100644
index 6e5d294..0000000
--- a/libc/arch-mips/bionic/bzero.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <private/bionic_asm.h>
-
-// void bzero(void*, size_t);
-ENTRY(bzero)
-	.set	noreorder
-	.cpload	t9
-	move	a2,a1
-	la	t9,memset
-	j	t9
-	 move	a1,zero
-END(bzero)
diff --git a/libstdc++/include/utility b/libc/arch-mips/bionic/libgcc_compat.c
similarity index 81%
copy from libstdc++/include/utility
copy to libc/arch-mips/bionic/libgcc_compat.c
index 12044a7..1a0f566 100644
--- a/libstdc++/include/utility
+++ b/libc/arch-mips/bionic/libgcc_compat.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,14 +25,17 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _CPP_UTILITY
-#define _CPP_UTILITY
 
-#pragma GCC system_header
+extern char __divdi3;
+extern char __moddi3;
+extern char __popcountsi2;
+extern char __udivdi3;
+extern char __umoddi3;
 
-#define  __STL_BEGIN_NAMESPACE  namespace std {
-#define  __STL_END_NAMESPACE    }
-
-#include <stl_pair.h>
-
-#endif /* _CPP_UTILITY */
+void* __bionic_libgcc_compat_symbols[] = {
+    &__divdi3,
+    &__moddi3,
+    &__popcountsi2,
+    &__udivdi3,
+    &__umoddi3,
+};
diff --git a/libc/arch-mips/bionic/setjmp.S b/libc/arch-mips/bionic/setjmp.S
index 73002e8..3b4ff55 100644
--- a/libc/arch-mips/bionic/setjmp.S
+++ b/libc/arch-mips/bionic/setjmp.S
@@ -136,7 +136,7 @@
 /* following fields are 8-byte aligned */
 #define	SC_FLAG_OFFSET	(2*4)		/* 8 bytes, cookie and savesigs flag, first actual field  */
 #define	SC_MASK_OFFSET	(4*4)		/* 16 bytes, mips32/mips64 version of sigset_t */
-#define	SC_SPARE_OFFSET	(8*4)		/* 8 bytes, reserved for future uses */
+#define	SC_CKSUM_OFFSET	(8*4)		/* 8 bytes, used for checksum */
 
 /* Registers that are 4-byte on mips32 o32, and 8-byte on mips64 n64 abi */
 #define	SC_REGS_OFFSET	(10*4)		/* SC_REGS_BYTES */
@@ -165,6 +165,8 @@
 #error _JBLEN is too small
 #endif
 
+#define USE_CHECKSUM 1
+
 .macro m_mangle_reg_and_store reg, cookie, temp, offset
 	xor	\temp, \reg, \cookie
 	REG_S	\temp, \offset
@@ -175,6 +177,20 @@
 	xor	\reg, \temp, \cookie
 .endm
 
+.macro m_calculate_checksum dst, src, scratch
+	REG_L \dst, REGSZ(\src)
+#ifdef __LP64__
+	/* 64 bit: checksum offset is 4 (actual _JBLEN is 25) */
+	.irp i,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
+#else
+	/* 32 bit: checksum offset is 8 (actual _JBLEN is 34) */
+	.irp i,2,3,4,5,6,7,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33
+#endif
+		REG_L \scratch, \i*REGSZ(\src)
+		xor \dst, \dst, \scratch
+	.endr
+.endm
+
 /*
  *
  *  GPOFF and FRAMESIZE must be the same for all setjmp/longjmp routines
@@ -263,6 +279,10 @@
 	s.d	$f30, SC_FPREGS+5*REGSZ_FP(a0)
 #endif
 	sw	v0, SC_FPSR_OFFSET(a0)
+#if USE_CHECKSUM
+	m_calculate_checksum t0, a0, t1
+	REG_S t0, SC_CKSUM_OFFSET(a0)
+#endif
 	move	v0, zero
 	RESTORE_GP64
 	PTR_ADDU sp, FRAMESZ
@@ -311,6 +331,16 @@
 	move	s1, a1				# temp spill
 	move	s0, a0
 
+#if USE_CHECKSUM
+	m_calculate_checksum t0, s0, s2
+	REG_L	s2, SC_CKSUM_OFFSET(s0)
+	beq	t0, s2, 0f
+	nop
+	jal	__bionic_setjmp_checksum_mismatch
+	nop
+0:
+#endif
+
 	# extract savesigs flag
 	REG_L	s2, SC_FLAG_OFFSET(s0)
 	andi	t0, s2, 1
diff --git a/libc/arch-mips/include/machine/asm.h b/libc/arch-mips/include/machine/asm.h
index cdc7914..dc83088 100644
--- a/libc/arch-mips/include/machine/asm.h
+++ b/libc/arch-mips/include/machine/asm.h
@@ -28,7 +28,7 @@
 #ifndef _MIPS64_ASM_H
 #define _MIPS64_ASM_H
 
-#define __bionic_asm_align 4
+#define __bionic_asm_align 16
 
 #undef __bionic_asm_custom_entry
 #undef __bionic_asm_custom_end
@@ -53,13 +53,9 @@
 	ABICALLS
 #endif
 
-#if !defined(__MIPSEL__) && !defined(__MIPSEB__)
-#error "__MIPSEL__ or __MIPSEB__ must be defined"
-#endif
 /*
  * Define how to access unaligned data word
  */
-#if defined(__MIPSEL__)
 #define LWLO    lwl
 #define LWHI    lwr
 #define	SWLO	swl
@@ -68,17 +64,6 @@
 #define LDHI    ldr
 #define	SDLO	sdl
 #define	SDHI	sdr
-#endif
-#if defined(__MIPSEB__)
-#define LWLO    lwr
-#define LWHI    lwl
-#define	SWLO	swr
-#define	SWHI	swl
-#define LDLO    ldr
-#define LDHI    ldl
-#define	SDLO	sdr
-#define	SDHI	sdl
-#endif
 
 /*
  *  Define programming environment for ABI.
diff --git a/libc/arch-mips/include/machine/elf_machdep.h b/libc/arch-mips/include/machine/elf_machdep.h
index 0aacedf..b6117f2 100644
--- a/libc/arch-mips/include/machine/elf_machdep.h
+++ b/libc/arch-mips/include/machine/elf_machdep.h
@@ -121,7 +121,7 @@
 #define	DT_MIPS_GOTSYM		0x70000013	/* first dynamic sym in got */
 #define DT_MIPS_HIPAGENO	0x70000014
 #define	DT_MIPS_RLD_MAP		0x70000016	/* address of loader map */
-#define DT_MIPS_RLD_MAP2	0x70000035	/* offset of loader map, used for PIE */
+#define DT_MIPS_RLD_MAP_REL	0x70000035	/* offset of loader map, used for PIE */
 
 /*
  * ELF Flags
@@ -151,47 +151,7 @@
 #define	EF_MIPS_ABI_EABI32	0x00003000
 #define	EF_MIPS_ABI_EABI64	0x00004000
 
-#if defined(__MIPSEB__)
-#define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
-#define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2MSB
-#elif defined(__MIPSEL__)
 #define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
 #define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2LSB
-#elif !defined(HAVE_NBTOOL_CONFIG_H)
-#error neither __MIPSEL__ nor __MIPSEB__ are defined.
-#endif
-
-#ifdef _KERNEL
-#ifdef _KERNEL_OPT
-#include "opt_compat_netbsd.h"
-#endif
-#ifdef COMPAT_16
-/*
- * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable.
- * Tell the kernel ELF exec code not to try relocating the interpreter
- * for dynamically-linked ELF binaries.
- */
-#define ELF_INTERP_NON_RELOCATABLE
-#endif /* COMPAT_16 */
-
-/*
- * We need to be able to include the ELF header so we can pick out the
- * ABI being used.
- */
-#ifdef ELFSIZE
-#define	ELF_MD_PROBE_FUNC	ELFNAME2(mips_netbsd,probe)
-#define	ELF_MD_COREDUMP_SETUP	ELFNAME2(coredump,setup)
-#endif
-
-struct exec_package;
-
-int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
-	vaddr_t *);
-void coredump_elf32_setup(struct lwp *, void *);
-
-int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
-	vaddr_t *);
-void coredump_elf64_setup(struct lwp *, void *);
-#endif /* _KERNEL */
 
 #endif /* _MIPS_ELF_MACHDEP_H_ */
diff --git a/libm/include/mips/machine/fenv.h b/libc/arch-mips/include/machine/fenv.h
similarity index 100%
rename from libm/include/mips/machine/fenv.h
rename to libc/arch-mips/include/machine/fenv.h
diff --git a/libc/arch-mips/mips.mk b/libc/arch-mips/mips.mk
deleted file mode 100644
index b184abb..0000000
--- a/libc/arch-mips/mips.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-# 32-bit mips.
-
-libc_bionic_src_files_mips += \
-    arch-mips/string/memcmp.c \
-    arch-mips/string/memcpy.S \
-    arch-mips/string/memset.S \
-    arch-mips/string/strcmp.S \
-
-#
-# Inherently architecture-specific code.
-#
-
-libc_bionic_src_files_mips += \
-    arch-mips/bionic/__bionic_clone.S \
-    arch-mips/bionic/bzero.S \
-    arch-mips/bionic/cacheflush.cpp \
-    arch-mips/bionic/_exit_with_stack_teardown.S \
-    arch-mips/bionic/setjmp.S \
-    arch-mips/bionic/syscall.S \
-    arch-mips/bionic/vfork.S \
-
-ifndef ARCH_MIPS_REV6
-libc_bionic_src_files_mips += \
-    arch-mips/string/mips_strlen.c \
-
-else
-libc_bionic_src_files_mips += \
-    arch-mips/string/strlen.c \
-
-endif
-
-libc_crt_target_cflags_mips := \
-    $($(my_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \
-    -I$(LOCAL_PATH)/arch-mips/include
-
-libc_crt_target_crtbegin_file_mips := \
-    $(LOCAL_PATH)/arch-mips/bionic/crtbegin.c
-
-libc_crt_target_crtbegin_so_file_mips := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c
-
-libc_crt_target_so_cflags_mips := \
-    -fPIC
-
-libc_crt_target_ldflags_mips := \
-    -melf32ltsmip
diff --git a/libc/arch-mips/string/memset.S b/libc/arch-mips/string/memset.S
index 65bb5b5..7ea6753 100644
--- a/libc/arch-mips/string/memset.S
+++ b/libc/arch-mips/string/memset.S
@@ -170,11 +170,6 @@
 # define R6_CODE
 #endif
 
-/* Allow the routine to be named something else if desired.  */
-#ifndef MEMSET_NAME
-# define MEMSET_NAME memset
-#endif
-
 /* We load/store 64 bits at a time when USE_DOUBLE is true.
    The C_ prefix stands for CHUNK and is used to avoid macro name
    conflicts with system header files.  */
@@ -209,9 +204,25 @@
 #define UNITM1(unit) (((unit)*NSIZE)-1)
 
 #ifdef __ANDROID__
-LEAF(MEMSET_NAME,0)
+LEAF(__memset_chk,0)
 #else
-LEAF(MEMSET_NAME)
+LEAF(__memset_chk)
+#endif
+	.set	noreorder
+        sltu    t2, a3, a2
+        beq     t2, zero, memset
+        nop
+        .cpsetup t9, t8, __memset_chk
+        LA      t9, __memset_chk_fail
+        jr      t9
+        nop
+        .set	reorder
+END(__memset_chk)
+
+#ifdef __ANDROID__
+LEAF(memset,0)
+#else
+LEAF(memset)
 #endif
 
 	.set	nomips16
@@ -428,9 +439,10 @@
 
 	.set	at
 	.set	reorder
-END(MEMSET_NAME)
+END(memset)
 #ifndef __ANDROID__
 # ifdef _LIBC
-libc_hidden_builtin_def (MEMSET_NAME)
+libc_hidden_builtin_def (memset)
+libc_hidden_builtin_def (__memset_chk)
 # endif
 #endif
diff --git a/libc/arch-mips/syscalls/__sync_file_range.S b/libc/arch-mips/syscalls/__sync_file_range.S
new file mode 100644
index 0000000..79d41e0
--- /dev/null
+++ b/libc/arch-mips/syscalls/__sync_file_range.S
@@ -0,0 +1,19 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+    .set noreorder
+    .cpload t9
+    li v0, __NR_sync_file_range
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    la t9,__set_errno_internal
+    j t9
+    nop
+    .set reorder
+END(__sync_file_range)
diff --git a/libc/arch-mips/syscalls/quotactl.S b/libc/arch-mips/syscalls/quotactl.S
new file mode 100644
index 0000000..fef336a
--- /dev/null
+++ b/libc/arch-mips/syscalls/quotactl.S
@@ -0,0 +1,19 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(quotactl)
+    .set noreorder
+    .cpload t9
+    li v0, __NR_quotactl
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    la t9,__set_errno_internal
+    j t9
+    nop
+    .set reorder
+END(quotactl)
diff --git a/libc/arch-mips/syscalls/setdomainname.S b/libc/arch-mips/syscalls/setdomainname.S
new file mode 100644
index 0000000..ec0504c
--- /dev/null
+++ b/libc/arch-mips/syscalls/setdomainname.S
@@ -0,0 +1,19 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(setdomainname)
+    .set noreorder
+    .cpload t9
+    li v0, __NR_setdomainname
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    la t9,__set_errno_internal
+    j t9
+    nop
+    .set reorder
+END(setdomainname)
diff --git a/libc/arch-mips64/mips64.mk b/libc/arch-mips64/mips64.mk
deleted file mode 100644
index 20ee639..0000000
--- a/libc/arch-mips64/mips64.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# 64-bit mips.
-
-libc_bionic_src_files_mips64 += \
-    arch-mips/string/memcmp.c \
-    arch-mips/string/memcpy.S \
-    arch-mips/string/memset.S \
-    arch-mips/string/strcmp.S \
-    arch-mips/string/strlen.c \
-
-#
-# Inherently architecture-specific code.
-#
-
-libc_bionic_src_files_mips64 += \
-    arch-mips64/bionic/__bionic_clone.S \
-    arch-mips64/bionic/_exit_with_stack_teardown.S \
-    arch-mips64/bionic/setjmp.S \
-    arch-mips64/bionic/syscall.S \
-    arch-mips64/bionic/vfork.S \
-    arch-mips64/bionic/stat.cpp \
-
-libc_crt_target_cflags_mips64 := \
-    $($(my_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \
-    -I$(LOCAL_PATH)/arch-mips64/include \
-
-libc_crt_target_crtbegin_file_mips64 := \
-    $(LOCAL_PATH)/arch-mips64/bionic/crtbegin.c \
-
-libc_crt_target_crtbegin_so_file_mips64 := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c \
-
-libc_crt_target_so_cflags_mips64 := \
-    -fPIC \
-
-libc_crt_target_ldflags_mips64 := \
-    -melf64ltsmip \
diff --git a/libc/arch-mips64/syscalls/__sync_file_range.S b/libc/arch-mips64/syscalls/__sync_file_range.S
new file mode 100644
index 0000000..e22c36e
--- /dev/null
+++ b/libc/arch-mips64/syscalls/__sync_file_range.S
@@ -0,0 +1,26 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+    .set push
+    .set noreorder
+    li v0, __NR_sync_file_range
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    move t0, ra
+    bal     2f
+    nop
+2:
+    .cpsetup ra, t1, 2b
+    LA t9,__set_errno_internal
+    .cpreturn
+    j t9
+    move ra, t0
+    .set pop
+END(__sync_file_range)
+.hidden __sync_file_range
diff --git a/libc/arch-mips64/syscalls/quotactl.S b/libc/arch-mips64/syscalls/quotactl.S
new file mode 100644
index 0000000..861947c
--- /dev/null
+++ b/libc/arch-mips64/syscalls/quotactl.S
@@ -0,0 +1,25 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(quotactl)
+    .set push
+    .set noreorder
+    li v0, __NR_quotactl
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    move t0, ra
+    bal     2f
+    nop
+2:
+    .cpsetup ra, t1, 2b
+    LA t9,__set_errno_internal
+    .cpreturn
+    j t9
+    move ra, t0
+    .set pop
+END(quotactl)
diff --git a/libc/arch-mips64/syscalls/setdomainname.S b/libc/arch-mips64/syscalls/setdomainname.S
new file mode 100644
index 0000000..6cee88e
--- /dev/null
+++ b/libc/arch-mips64/syscalls/setdomainname.S
@@ -0,0 +1,25 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(setdomainname)
+    .set push
+    .set noreorder
+    li v0, __NR_setdomainname
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    move t0, ra
+    bal     2f
+    nop
+2:
+    .cpsetup ra, t1, 2b
+    LA t9,__set_errno_internal
+    .cpreturn
+    j t9
+    move ra, t0
+    .set pop
+END(setdomainname)
diff --git a/libc/arch-x86/atom/atom.mk b/libc/arch-x86/atom/atom.mk
deleted file mode 100644
index 1afabac..0000000
--- a/libc/arch-x86/atom/atom.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-libc_bionic_src_files_x86 += \
-    arch-x86/atom/string/sse2-bzero-atom.S \
-    arch-x86/atom/string/sse2-memset-atom.S \
-    arch-x86/atom/string/sse2-strlen-atom.S \
-    arch-x86/atom/string/ssse3-bcopy-atom.S \
-    arch-x86/atom/string/ssse3-memcmp-atom.S \
-    arch-x86/atom/string/ssse3-memcpy-atom.S \
-    arch-x86/atom/string/ssse3-memmove-atom.S \
-    arch-x86/atom/string/ssse3-strcpy-atom.S \
-    arch-x86/atom/string/ssse3-strncpy-atom.S \
-    arch-x86/atom/string/ssse3-wmemcmp-atom.S
-
-libc_bionic_src_files_exclude_x86 += \
-    arch-x86/generic/string/memcmp.S \
-
-libc_bionic_src_files_exclude_x86 += \
-    arch-x86/silvermont/string/sse2-bcopy-slm.S \
-    arch-x86/silvermont/string/sse2-bzero-slm.S \
-    arch-x86/silvermont/string/sse2-memcpy-slm.S \
-    arch-x86/silvermont/string/sse2-memmove-slm.S \
-    arch-x86/silvermont/string/sse2-memset-slm.S \
-    arch-x86/silvermont/string/sse2-strcpy-slm.S \
-    arch-x86/silvermont/string/sse2-strlen-slm.S \
-    arch-x86/silvermont/string/sse2-strncpy-slm.S \
-
-libc_freebsd_src_files_exclude_x86 += \
-    upstream-freebsd/lib/libc/string/wmemcmp.c \
diff --git a/libc/arch-x86/atom/string/sse2-bzero-atom.S b/libc/arch-x86/atom/string/sse2-bzero-atom.S
deleted file mode 100644
index 0ddc499..0000000
--- a/libc/arch-x86/atom/string/sse2-bzero-atom.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright (c) 2010, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice,
-    * this list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above copyright notice,
-    * this list of conditions and the following disclaimer in the documentation
-    * and/or other materials provided with the distribution.
-
-    * Neither the name of Intel Corporation nor the names of its contributors
-    * may be used to endorse or promote products derived from this software
-    * without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#define USE_AS_BZERO
-#define MEMSET  bzero
-#include "sse2-memset-atom.S"
diff --git a/libc/arch-x86/atom/string/sse2-memset-atom.S b/libc/arch-x86/atom/string/sse2-memset-atom.S
index b0963a1..4e211ca 100644
--- a/libc/arch-x86/atom/string/sse2-memset-atom.S
+++ b/libc/arch-x86/atom/string/sse2-memset-atom.S
@@ -28,6 +28,8 @@
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#include <private/bionic_asm.h>
+
 #include "cache.h"
 
 #ifndef L
@@ -38,69 +40,28 @@
 # define ALIGN(n)	.p2align n
 #endif
 
-#ifndef cfi_startproc
-# define cfi_startproc			.cfi_startproc
-#endif
-
-#ifndef cfi_endproc
-# define cfi_endproc			.cfi_endproc
-#endif
-
-#ifndef cfi_rel_offset
-# define cfi_rel_offset(reg, off)	.cfi_rel_offset reg, off
-#endif
-
-#ifndef cfi_restore
-# define cfi_restore(reg)		.cfi_restore reg
-#endif
-
-#ifndef cfi_adjust_cfa_offset
-# define cfi_adjust_cfa_offset(off)	.cfi_adjust_cfa_offset off
-#endif
-
-#ifndef ENTRY
-# define ENTRY(name)			\
-	.type name,  @function; 	\
-	.globl name;			\
-	.p2align 4;			\
-name:					\
-	cfi_startproc
-#endif
-
-#ifndef END
-# define END(name)			\
-	cfi_endproc;			\
-	.size name, .-name
-#endif
-
 #define CFI_PUSH(REG)						\
-  cfi_adjust_cfa_offset (4);					\
-  cfi_rel_offset (REG, 0)
+  .cfi_adjust_cfa_offset 4;					\
+  .cfi_rel_offset REG, 0
 
 #define CFI_POP(REG)						\
-  cfi_adjust_cfa_offset (-4);					\
-  cfi_restore (REG)
+  .cfi_adjust_cfa_offset -4;					\
+  .cfi_restore REG
 
-#define PUSH(REG)	pushl REG; CFI_PUSH (REG)
-#define POP(REG)	popl REG; CFI_POP (REG)
+#define PUSH(REG)	pushl REG; CFI_PUSH(REG)
+#define POP(REG)	popl REG; CFI_POP(REG)
 
-#ifdef USE_AS_BZERO
-# define DEST		PARMS
-# define LEN		DEST+4
-# define SETRTNVAL
-#else
-# define DEST		PARMS
-# define CHR		DEST+4
-# define LEN		CHR+4
-# define SETRTNVAL	movl DEST(%esp), %eax
-#endif
+#define PARMS 8  /* Preserve EBX. */
+#define DST PARMS
+#define CHR (DST+4)
+#define LEN (CHR+4)
+#define CHK_DST_LEN (LEN+4)
+#define SETRTNVAL	movl DST(%esp), %eax
 
-#if (defined SHARED || defined __PIC__)
-# define ENTRANCE	PUSH (%ebx);
-# define RETURN_END	POP (%ebx); ret
-# define RETURN		RETURN_END; CFI_PUSH (%ebx)
-# define PARMS		8		/* Preserve EBX.  */
-# define JMPTBL(I, B)	I - B
+#define ENTRANCE	PUSH(%ebx);
+#define RETURN_END	POP(%ebx); ret
+#define RETURN		RETURN_END; CFI_PUSH(%ebx)
+#define JMPTBL(I, B)	I - B
 
 /* Load an entry in a jump table into EBX and branch to it.  TABLE is a
    jump table with relative offsets.   */
@@ -113,97 +74,88 @@
        absolute address.  */					\
     add		(%ebx,%ecx,4), %ebx;				\
     add		%ecx, %edx;					\
-    /* We loaded the jump table and adjuested EDX. Go.  */	\
+    /* We loaded the jump table and adjusted EDX. Go.  */	\
     jmp		*%ebx
 
 	.section	.gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits
 	.globl	__x86.get_pc_thunk.bx
 	.hidden	__x86.get_pc_thunk.bx
-	ALIGN (4)
+	ALIGN(4)
 	.type	__x86.get_pc_thunk.bx,@function
 __x86.get_pc_thunk.bx:
 	movl	(%esp), %ebx
 	ret
-#else
-# define ENTRANCE
-# define RETURN_END	ret
-# define RETURN		RETURN_END
-# define PARMS		4
-# define JMPTBL(I, B)	I
 
-/* Branch to an entry in a jump table.  TABLE is a jump table with
-   absolute offsets.  */
-# define BRANCH_TO_JMPTBL_ENTRY(TABLE)				\
-    add		%ecx, %edx;					\
-    jmp		*TABLE(,%ecx,4)
-#endif
+ENTRY(__memset_chk)
+  ENTRANCE
 
-#ifndef MEMSET
-# define MEMSET memset
-#endif
+  movl LEN(%esp), %ecx
+  cmpl CHK_DST_LEN(%esp), %ecx
+  jna L(memset_length_loaded)
+
+  POP(%ebx) // Undo ENTRANCE without returning.
+  jmp __memset_chk_fail
+END(__memset_chk)
 
 	.section .text.sse2,"ax",@progbits
-	ALIGN (4)
-ENTRY (MEMSET)
+	ALIGN(4)
+ENTRY(memset)
 	ENTRANCE
 
 	movl	LEN(%esp), %ecx
-#ifdef USE_AS_BZERO
-	xor	%eax, %eax
-#else
+L(memset_length_loaded):
 	movzbl	CHR(%esp), %eax
 	movb	%al, %ah
 	/* Fill the whole EAX with pattern.  */
 	movl	%eax, %edx
 	shl	$16, %eax
 	or	%edx, %eax
-#endif
-	movl	DEST(%esp), %edx
+	movl	DST(%esp), %edx
 	cmp	$32, %ecx
 	jae	L(32bytesormore)
 
 L(write_less32bytes):
-	BRANCH_TO_JMPTBL_ENTRY (L(table_less_32bytes))
+	BRANCH_TO_JMPTBL_ENTRY(L(table_less_32bytes))
 
 
 	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
+	ALIGN(2)
 L(table_less_32bytes):
-	.int	JMPTBL (L(write_0bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_1bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_2bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_3bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_4bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_5bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_6bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_7bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_8bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_9bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_10bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_11bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_12bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_13bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_14bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_15bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_16bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_17bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_18bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_19bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_20bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_21bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_22bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_23bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_24bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_25bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_26bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_27bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_28bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_29bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_30bytes), L(table_less_32bytes))
-	.int	JMPTBL (L(write_31bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_0bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_1bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_2bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_3bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_4bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_5bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_6bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_7bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_8bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_9bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_10bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_11bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_12bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_13bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_14bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_15bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_16bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_17bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_18bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_19bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_20bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_21bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_22bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_23bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_24bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_25bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_26bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_27bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_28bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_29bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_30bytes), L(table_less_32bytes))
+	.int	JMPTBL(L(write_31bytes), L(table_less_32bytes))
 	.popsection
 
-	ALIGN (4)
+	ALIGN(4)
 L(write_28bytes):
 	movl	%eax, -28(%edx)
 L(write_24bytes):
@@ -222,7 +174,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(write_29bytes):
 	movl	%eax, -29(%edx)
 L(write_25bytes):
@@ -242,7 +194,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(write_30bytes):
 	movl	%eax, -30(%edx)
 L(write_26bytes):
@@ -262,7 +214,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(write_31bytes):
 	movl	%eax, -31(%edx)
 L(write_27bytes):
@@ -283,16 +235,12 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 /* ECX > 32 and EDX is 4 byte aligned.  */
 L(32bytesormore):
 	/* Fill xmm0 with the pattern.  */
-#ifdef USE_AS_BZERO
-	pxor	%xmm0, %xmm0
-#else
 	movd	%eax, %xmm0
 	pshufd	$0, %xmm0, %xmm0
-#endif
 	testl	$0xf, %edx
 	jz	L(aligned_16)
 /* ECX > 32 and EDX is not 16 byte aligned.  */
@@ -305,49 +253,25 @@
 	add	%eax, %ecx
 	movd	%xmm0, %eax
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16):
 	cmp	$128, %ecx
 	jae	L(128bytesormore)
 
 L(aligned_16_less128bytes):
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
-	ALIGN (4)
+	ALIGN(4)
 L(128bytesormore):
-#ifdef SHARED_CACHE_SIZE
-	PUSH (%ebx)
+	PUSH(%ebx)
 	mov	$SHARED_CACHE_SIZE, %ebx
-#else
-# if (defined SHARED || defined __PIC__)
-	call	__x86.get_pc_thunk.bx
-	add	$_GLOBAL_OFFSET_TABLE_, %ebx
-	mov	__x86_shared_cache_size@GOTOFF(%ebx), %ebx
-# else
-	PUSH (%ebx)
-	mov	__x86_shared_cache_size, %ebx
-# endif
-#endif
 	cmp	%ebx, %ecx
 	jae	L(128bytesormore_nt_start)
 
 
-#ifdef DATA_CACHE_SIZE
-	POP (%ebx)
-# define RESTORE_EBX_STATE CFI_PUSH (%ebx)
+	POP(%ebx)
+# define RESTORE_EBX_STATE CFI_PUSH(%ebx)
 	cmp	$DATA_CACHE_SIZE, %ecx
-#else
-# if (defined SHARED || defined __PIC__)
-#  define RESTORE_EBX_STATE
-	call	__x86.get_pc_thunk.bx
-	add	$_GLOBAL_OFFSET_TABLE_, %ebx
-	cmp	__x86_data_cache_size@GOTOFF(%ebx), %ecx
-# else
-	POP (%ebx)
-#  define RESTORE_EBX_STATE CFI_PUSH (%ebx)
-	cmp	__x86_data_cache_size, %ecx
-# endif
-#endif
 
 	jae	L(128bytes_L2_normal)
 	subl	$128, %ecx
@@ -379,9 +303,9 @@
 
 L(128bytesless_normal):
 	add	$128, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
-	ALIGN (4)
+	ALIGN(4)
 L(128bytes_L2_normal):
 	prefetcht0	0x380(%edx)
 	prefetcht0	0x3c0(%edx)
@@ -399,7 +323,7 @@
 	jae	L(128bytes_L2_normal)
 
 L(128bytesless_L2_normal):
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
 	RESTORE_EBX_STATE
 L(128bytesormore_nt_start):
@@ -408,7 +332,7 @@
 	and	$0x7f, %eax
 	add	%eax, %ecx
 	movd	%xmm0, %eax
-	ALIGN (4)
+	ALIGN(4)
 L(128bytesormore_shared_cache_loop):
 	prefetcht0	0x3c0(%edx)
 	prefetcht0	0x380(%edx)
@@ -426,7 +350,7 @@
 	jae	L(128bytesormore_shared_cache_loop)
 	cmp	$0x80, %ecx
 	jb	L(shared_cache_loop_end)
-	ALIGN (4)
+	ALIGN(4)
 L(128bytesormore_nt):
 	sub	$0x80, %ecx
 	movntdq	%xmm0, (%edx)
@@ -442,146 +366,144 @@
 	jae	L(128bytesormore_nt)
 	sfence
 L(shared_cache_loop_end):
-#if defined DATA_CACHE_SIZE || !(defined SHARED || defined __PIC__)
-	POP (%ebx)
-#endif
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	POP(%ebx)
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
 
 	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
+	ALIGN(2)
 L(table_16_128bytes):
-	.int	JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_1bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_2bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_3bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_5bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_6bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_7bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_9bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_10bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_11bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_13bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_14bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_15bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_17bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_18bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_19bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_21bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_22bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_23bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_25bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_26bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_27bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_29bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_30bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_31bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_33bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_34bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_35bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_37bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_38bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_39bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_41bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_42bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_43bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_45bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_46bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_47bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_49bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_50bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_51bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_53bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_54bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_55bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_57bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_58bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_59bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_61bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_62bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_63bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_65bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_66bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_67bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_69bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_70bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_71bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_73bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_74bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_75bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_77bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_78bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_79bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_81bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_82bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_83bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_85bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_86bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_87bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_89bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_90bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_91bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_93bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_94bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_95bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_97bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_98bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_99bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_101bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_102bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_103bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_105bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_106bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_107bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_109bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_110bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_111bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_113bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_114bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_115bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_117bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_118bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_119bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_121bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_122bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_123bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_125bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_126bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_127bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_0bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_1bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_2bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_3bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_4bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_5bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_6bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_7bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_8bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_9bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_10bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_11bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_12bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_13bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_14bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_15bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_16bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_17bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_18bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_19bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_20bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_21bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_22bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_23bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_24bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_25bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_26bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_27bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_28bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_29bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_30bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_31bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_32bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_33bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_34bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_35bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_36bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_37bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_38bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_39bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_40bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_41bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_42bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_43bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_44bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_45bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_46bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_47bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_48bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_49bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_50bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_51bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_52bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_53bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_54bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_55bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_56bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_57bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_58bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_59bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_60bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_61bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_62bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_63bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_64bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_65bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_66bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_67bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_68bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_69bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_70bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_71bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_72bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_73bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_74bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_75bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_76bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_77bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_78bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_79bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_80bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_81bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_82bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_83bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_84bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_85bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_86bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_87bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_88bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_89bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_90bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_91bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_92bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_93bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_94bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_95bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_96bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_97bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_98bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_99bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_100bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_101bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_102bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_103bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_104bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_105bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_106bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_107bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_108bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_109bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_110bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_111bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_112bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_113bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_114bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_115bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_116bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_117bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_118bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_119bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_120bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_121bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_122bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_123bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_124bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_125bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_126bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_127bytes), L(table_16_128bytes))
 	.popsection
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_112bytes):
 	movdqa	%xmm0, -112(%edx)
 L(aligned_16_96bytes):
@@ -600,7 +522,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_113bytes):
 	movdqa	%xmm0, -113(%edx)
 L(aligned_16_97bytes):
@@ -620,7 +542,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_114bytes):
 	movdqa	%xmm0, -114(%edx)
 L(aligned_16_98bytes):
@@ -640,7 +562,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_115bytes):
 	movdqa	%xmm0, -115(%edx)
 L(aligned_16_99bytes):
@@ -661,7 +583,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_116bytes):
 	movdqa	%xmm0, -116(%edx)
 L(aligned_16_100bytes):
@@ -681,7 +603,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_117bytes):
 	movdqa	%xmm0, -117(%edx)
 L(aligned_16_101bytes):
@@ -702,7 +624,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_118bytes):
 	movdqa	%xmm0, -118(%edx)
 L(aligned_16_102bytes):
@@ -723,7 +645,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_119bytes):
 	movdqa	%xmm0, -119(%edx)
 L(aligned_16_103bytes):
@@ -745,7 +667,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_120bytes):
 	movdqa	%xmm0, -120(%edx)
 L(aligned_16_104bytes):
@@ -765,7 +687,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_121bytes):
 	movdqa	%xmm0, -121(%edx)
 L(aligned_16_105bytes):
@@ -786,7 +708,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_122bytes):
 	movdqa	%xmm0, -122(%edx)
 L(aligned_16_106bytes):
@@ -807,7 +729,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_123bytes):
 	movdqa	%xmm0, -123(%edx)
 L(aligned_16_107bytes):
@@ -829,7 +751,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_124bytes):
 	movdqa	%xmm0, -124(%edx)
 L(aligned_16_108bytes):
@@ -850,7 +772,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_125bytes):
 	movdqa	%xmm0, -125(%edx)
 L(aligned_16_109bytes):
@@ -872,7 +794,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_126bytes):
 	movdqa	%xmm0, -126(%edx)
 L(aligned_16_110bytes):
@@ -894,7 +816,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_127bytes):
 	movdqa	%xmm0, -127(%edx)
 L(aligned_16_111bytes):
@@ -917,4 +839,4 @@
 	SETRTNVAL
 	RETURN_END
 
-END (MEMSET)
+END(memset)
diff --git a/libc/arch-x86/atom/string/ssse3-bcopy-atom.S b/libc/arch-x86/atom/string/ssse3-bcopy-atom.S
deleted file mode 100644
index e4b791a..0000000
--- a/libc/arch-x86/atom/string/ssse3-bcopy-atom.S
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-Copyright (c) 2010, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice,
-    * this list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above copyright notice,
-    * this list of conditions and the following disclaimer in the documentation
-    * and/or other materials provided with the distribution.
-
-    * Neither the name of Intel Corporation nor the names of its contributors
-    * may be used to endorse or promote products derived from this software
-    * without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-#define MEMCPY	bcopy
-#define USE_AS_MEMMOVE
-#define USE_AS_BCOPY
-#include "ssse3-memcpy-atom.S"
diff --git a/libc/arch-x86/atom/string/ssse3-memcpy-atom.S b/libc/arch-x86/atom/string/ssse3-memcpy-atom.S
index ac5ec2d..4b2fb8e 100644
--- a/libc/arch-x86/atom/string/ssse3-memcpy-atom.S
+++ b/libc/arch-x86/atom/string/ssse3-memcpy-atom.S
@@ -73,15 +73,9 @@
 	.size name, .-name
 #endif
 
-#ifdef USE_AS_BCOPY
-# define SRC		PARMS
-# define DEST		SRC+4
-# define LEN		DEST+4
-#else
-# define DEST		PARMS
-# define SRC		DEST+4
-# define LEN		SRC+4
-#endif
+#define DEST		PARMS
+#define SRC		DEST+4
+#define LEN		SRC+4
 
 #define CFI_PUSH(REG)		\
   cfi_adjust_cfa_offset (4);		\
@@ -2018,12 +2012,10 @@
 L(fwd_write_4bytes):
 	movl	-4(%eax), %ecx
 	movl	%ecx, -4(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2044,12 +2036,10 @@
 	movq	-8(%eax), %xmm0
 	movq	%xmm0, -8(%edx)
 L(fwd_write_0bytes):
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2059,12 +2049,10 @@
 	movl	-4(%eax), %eax
 	movl	%ecx, -5(%edx)
 	movl	%eax, -4(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2088,12 +2076,10 @@
 	movl	%ecx, -5(%edx)
 	movzbl	-1(%eax), %ecx
 	movb	%cl, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2116,12 +2102,10 @@
 L(fwd_write_1bytes):
 	movzbl	-1(%eax), %ecx
 	movb	%cl, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2146,12 +2130,10 @@
 	movl	%ecx, -6(%edx)
 	movzwl	-2(%eax), %ecx
 	movw	%cx, -2(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2174,12 +2156,10 @@
 L(fwd_write_2bytes):
 	movzwl	-2(%eax), %ecx
 	movw	%cx, -2(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2206,12 +2186,10 @@
 	movzbl	-1(%eax), %eax
 	movw	%cx, -3(%edx)
 	movb	%al, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2236,12 +2214,10 @@
 	movzbl	-1(%eax), %eax
 	movw	%cx, -3(%edx)
 	movb	%al, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2256,12 +2232,10 @@
 	movq	-8(%eax), %xmm0
 	movq	%xmm0, -8(%edx)
 L(fwd_write_0bytes_align):
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2272,12 +2246,10 @@
 L(fwd_write_16bytes_align):
 	movdqa	-16(%eax), %xmm0
 	movdqa	%xmm0, -16(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2287,12 +2259,10 @@
 	movl	-4(%eax), %eax
 	movl	%ecx, -5(%edx)
 	movl	%eax, -4(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2310,12 +2280,10 @@
 	movl	%ecx, -5(%edx)
 	movzbl	-1(%eax), %ecx
 	movb	%cl, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2330,12 +2298,10 @@
 	movl	%ecx, -5(%edx)
 	movzbl	-1(%eax), %ecx
 	movb	%cl, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2352,12 +2318,10 @@
 L(fwd_write_1bytes_align):
 	movzbl	-1(%eax), %ecx
 	movb	%cl, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2370,12 +2334,10 @@
 	movdqa	%xmm0, -17(%edx)
 	movzbl	-1(%eax), %ecx
 	movb	%cl, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2394,12 +2356,10 @@
 	movl	%ecx, -6(%edx)
 	movzwl	-2(%eax), %ecx
 	movw	%cx, -2(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2414,12 +2374,10 @@
 	movl	%ecx, -6(%edx)
 	movzwl	-2(%eax), %ecx
 	movw	%cx, -2(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2436,12 +2394,10 @@
 L(fwd_write_2bytes_align):
 	movzwl	-2(%eax), %ecx
 	movw	%cx, -2(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2454,12 +2410,10 @@
 	movdqa	%xmm0, -18(%edx)
 	movzwl	-2(%eax), %ecx
 	movw	%cx, -2(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2480,12 +2434,10 @@
 	movzbl	-1(%eax), %eax
 	movw	%cx, -3(%edx)
 	movb	%al, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2502,12 +2454,10 @@
 	movzbl	-1(%eax), %eax
 	movw	%cx, -3(%edx)
 	movb	%al, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2526,12 +2476,10 @@
 	movzbl	-1(%eax), %eax
 	movw	%cx, -3(%edx)
 	movb	%al, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2546,12 +2494,10 @@
 	movzbl	-1(%eax), %eax
 	movw	%cx, -3(%edx)
 	movb	%al, -1(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2568,12 +2514,10 @@
 L(fwd_write_4bytes_align):
 	movl	-4(%eax), %ecx
 	movl	%ecx, -4(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN
 
@@ -2586,12 +2530,10 @@
 	movdqa	%xmm0, -20(%edx)
 	movl	-4(%eax), %ecx
 	movl	%ecx, -4(%edx)
-#ifndef USE_AS_BCOPY
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	%edx, %eax
-# else
+#else
 	movl	DEST(%esp), %eax
-# endif
 #endif
 	RETURN_END
 
@@ -2685,12 +2627,10 @@
 	movl	(%eax), %ecx
 	movl	%ecx, (%edx)
 L(bk_write_0bytes):
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN
 
@@ -2710,12 +2650,10 @@
 L(bk_write_8bytes):
 	movq	(%eax), %xmm0
 	movq	%xmm0, (%edx)
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN
 
@@ -2741,12 +2679,10 @@
 L(bk_write_1bytes):
 	movzbl	(%eax), %ecx
 	movb	%cl, (%edx)
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN
 
@@ -2768,12 +2704,10 @@
 	movq	%xmm0, 1(%edx)
 	movzbl	(%eax), %ecx
 	movb	%cl, (%edx)
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN
 
@@ -2798,12 +2732,10 @@
 	movl	%ecx, 2(%edx)
 	movzwl	(%eax), %ecx
 	movw	%cx, (%edx)
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN
 
@@ -2826,12 +2758,10 @@
 L(bk_write_2bytes):
 	movzwl	(%eax), %ecx
 	movw	%cx, (%edx)
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN
 
@@ -2858,12 +2788,10 @@
 	movw	%cx, 1(%edx)
 	movzbl	(%eax), %eax
 	movb	%al, (%edx)
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN
 
@@ -2888,12 +2816,10 @@
 	movw	%cx, 1(%edx)
 	movzbl	(%eax), %eax
 	movb	%al, (%edx)
-#ifndef USE_AS_BCOPY
 	movl	DEST(%esp), %eax
-# ifdef USE_AS_MEMPCPY
+#ifdef USE_AS_MEMPCPY
 	movl	LEN(%esp), %ecx
 	add	%ecx, %eax
-# endif
 #endif
 	RETURN_END
 
diff --git a/libc/arch-x86/bionic/__bionic_clone.S b/libc/arch-x86/bionic/__bionic_clone.S
index 1a6f642..b682b48 100644
--- a/libc/arch-x86/bionic/__bionic_clone.S
+++ b/libc/arch-x86/bionic/__bionic_clone.S
@@ -1,7 +1,7 @@
 #include <private/bionic_asm.h>
 
 // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
-ENTRY(__bionic_clone)
+ENTRY_PRIVATE(__bionic_clone)
         pushl   %ebx
         .cfi_adjust_cfa_offset 4
         .cfi_rel_offset ebx, 0
@@ -62,4 +62,3 @@
         .cfi_restore ebx
         ret
 END(__bionic_clone)
-.hidden __bionic_clone
diff --git a/libc/arch-x86/bionic/__set_tls.c b/libc/arch-x86/bionic/__set_tls.cpp
similarity index 92%
rename from libc/arch-x86/bionic/__set_tls.c
rename to libc/arch-x86/bionic/__set_tls.cpp
index 38ed3c9..b26fd56 100644
--- a/libc/arch-x86/bionic/__set_tls.c
+++ b/libc/arch-x86/bionic/__set_tls.cpp
@@ -32,7 +32,7 @@
 
 #include <asm/ldt.h>
 
-extern int __set_thread_area(struct user_desc*);
+extern "C" int __set_thread_area(struct user_desc*);
 
 __LIBC_HIDDEN__ void __init_user_desc(struct user_desc* result, bool allocate, void* base_addr) {
   if (allocate) {
@@ -45,9 +45,9 @@
     result->entry_number = (gs & 0xffff) >> 3;
   }
 
-  result->base_addr = (uintptr_t) base_addr;
+  result->base_addr = reinterpret_cast<uintptr_t>(base_addr);
 
-  result->limit = PAGE_SIZE;
+  result->limit = 0xfffff;
 
   result->seg_32bit = 1;
   result->contents = MODIFY_LDT_CONTENTS_DATA;
@@ -57,7 +57,7 @@
   result->useable = 1;
 }
 
-__LIBC_HIDDEN__ int __set_tls(void* ptr) {
+extern "C" __LIBC_HIDDEN__ int __set_tls(void* ptr) {
   struct user_desc tls_descriptor;
   __init_user_desc(&tls_descriptor, true, ptr);
 
diff --git a/libc/arch-x86/bionic/libgcc_compat.c b/libc/arch-x86/bionic/libgcc_compat.c
index c723263..1a0f566 100644
--- a/libc/arch-x86/bionic/libgcc_compat.c
+++ b/libc/arch-x86/bionic/libgcc_compat.c
@@ -1,4 +1,30 @@
-/* Generated by genlibgcc_compat.py */
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 extern char __divdi3;
 extern char __moddi3;
diff --git a/libc/arch-x86/generic/string/bcopy.S b/libc/arch-x86/generic/string/bcopy.S
deleted file mode 100644
index f425c58..0000000
--- a/libc/arch-x86/generic/string/bcopy.S
+++ /dev/null
@@ -1,98 +0,0 @@
-/*	$OpenBSD: bcopy.S,v 1.5 2005/08/07 11:30:38 espie Exp $	*/
-
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from locore.s.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <private/bionic_asm.h>
-
-	/*
-	 * (ov)bcopy (src,dst,cnt)
-	 *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
-	 */
-
-#if defined(MEMCOPY)
-ENTRY(memcpy)
-#elif defined(MEMMOVE)
-ENTRY(memmove)
-#else
-ENTRY(bcopy)
-#endif
-	pushl	%esi
-	pushl	%edi
-#if defined(MEMCOPY) || defined(MEMMOVE)
-	movl	12(%esp),%edi
-	movl	16(%esp),%esi
-	movl	%edi, %eax
-#else
-	movl	12(%esp),%esi
-	movl	16(%esp),%edi
-#endif
-	movl	20(%esp),%ecx
-	movl	%ecx,%edx
-	cmpl	%esi,%edi	/* potentially overlapping? */
-	jnb	1f
-	cld			/* nope, copy forwards. */
-	shrl	$2,%ecx		/* copy by words */
-	rep
-	movsl
-	movl	%edx,%ecx
-	andl	$3,%ecx		/* any bytes left? */
-	rep
-	movsb
-	popl	%edi
-	popl	%esi
-	ret
-1:
-	addl	%ecx,%edi	/* copy backwards. */
-	addl	%ecx,%esi
-	std
-	andl	$3,%ecx		/* any fractional bytes? */
-	decl	%edi
-	decl	%esi
-	rep
-	movsb
-	movl	%edx,%ecx
-	shrl	$2,%ecx
-	subl	$3,%esi
-	subl	$3,%edi
-	rep
-	movsl
-	popl	%edi
-	popl	%esi
-	cld
-	ret
-#if defined(MEMCOPY)
-END(memcpy)
-#elif defined(MEMMOVE)
-END(memmove)
-#else
-END(bcopy)
-#endif
diff --git a/libc/arch-x86/generic/string/memcpy.S b/libc/arch-x86/generic/string/memcpy.S
deleted file mode 100644
index 95c8a83..0000000
--- a/libc/arch-x86/generic/string/memcpy.S
+++ /dev/null
@@ -1,3 +0,0 @@
-/*	$OpenBSD: memcpy.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
-#define MEMCOPY
-#include "bcopy.S"
diff --git a/libc/arch-x86/generic/string/memmove.S b/libc/arch-x86/generic/string/memmove.S
deleted file mode 100644
index c5bfd19..0000000
--- a/libc/arch-x86/generic/string/memmove.S
+++ /dev/null
@@ -1,3 +0,0 @@
-/*	$OpenBSD: memmove.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
-#define MEMMOVE
-#include "bcopy.S"
diff --git a/libm/include/i387/machine/fenv.h b/libc/arch-x86/include/machine/fenv.h
similarity index 100%
rename from libm/include/i387/machine/fenv.h
rename to libc/arch-x86/include/machine/fenv.h
diff --git a/libc/arch-x86/silvermont/silvermont.mk b/libc/arch-x86/silvermont/silvermont.mk
deleted file mode 100644
index e69de29..0000000
--- a/libc/arch-x86/silvermont/silvermont.mk
+++ /dev/null
diff --git a/libc/arch-x86/silvermont/string/sse2-bcopy-slm.S b/libc/arch-x86/silvermont/string/sse2-bcopy-slm.S
deleted file mode 100644
index 190d52f..0000000
--- a/libc/arch-x86/silvermont/string/sse2-bcopy-slm.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-Copyright (c) 2014, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice,
-    * this list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above copyright notice,
-    * this list of conditions and the following disclaimer in the documentation
-    * and/or other materials provided with the distribution.
-
-    * Neither the name of Intel Corporation nor the names of its contributors
-    * may be used to endorse or promote products derived from this software
-    * without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-#define MEMMOVE	bcopy
-#define USE_AS_BCOPY
-#include "sse2-memmove-slm.S"
diff --git a/libc/arch-x86/silvermont/string/sse2-bzero-slm.S b/libc/arch-x86/silvermont/string/sse2-bzero-slm.S
deleted file mode 100644
index b682ed6..0000000
--- a/libc/arch-x86/silvermont/string/sse2-bzero-slm.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright (c) 2014, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice,
-    * this list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above copyright notice,
-    * this list of conditions and the following disclaimer in the documentation
-    * and/or other materials provided with the distribution.
-
-    * Neither the name of Intel Corporation nor the names of its contributors
-    * may be used to endorse or promote products derived from this software
-    * without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#define USE_AS_BZERO
-#define MEMSET  bzero
-#include "sse2-memset-slm.S"
diff --git a/libc/arch-x86/silvermont/string/sse2-memmove-slm.S b/libc/arch-x86/silvermont/string/sse2-memmove-slm.S
index 6a8f067..bf9f85d 100644
--- a/libc/arch-x86/silvermont/string/sse2-memmove-slm.S
+++ b/libc/arch-x86/silvermont/string/sse2-memmove-slm.S
@@ -73,15 +73,9 @@
 	.size name, .-name
 #endif
 
-#ifdef USE_AS_BCOPY
-# define SRC		PARMS
-# define DEST		SRC+4
-# define LEN		DEST+4
-#else
-# define DEST		PARMS
-# define SRC		DEST+4
-# define LEN		SRC+4
-#endif
+#define DEST		PARMS
+#define SRC		DEST+4
+#define LEN		SRC+4
 
 #define CFI_PUSH(REG)		\
   cfi_adjust_cfa_offset (4);		\
diff --git a/libc/arch-x86/silvermont/string/sse2-memset-slm.S b/libc/arch-x86/silvermont/string/sse2-memset-slm.S
index c30bf74..03a552d 100644
--- a/libc/arch-x86/silvermont/string/sse2-memset-slm.S
+++ b/libc/arch-x86/silvermont/string/sse2-memset-slm.S
@@ -28,11 +28,9 @@
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "cache.h"
+#include <private/bionic_asm.h>
 
-#ifndef MEMSET
-# define MEMSET memset
-#endif
+#include "cache.h"
 
 #ifndef L
 # define L(label)	.L##label
@@ -42,68 +40,27 @@
 # define ALIGN(n)	.p2align n
 #endif
 
-#ifndef cfi_startproc
-# define cfi_startproc			.cfi_startproc
-#endif
-
-#ifndef cfi_endproc
-# define cfi_endproc			.cfi_endproc
-#endif
-
-#ifndef cfi_rel_offset
-# define cfi_rel_offset(reg, off)	.cfi_rel_offset reg, off
-#endif
-
-#ifndef cfi_restore
-# define cfi_restore(reg)		.cfi_restore reg
-#endif
-
-#ifndef cfi_adjust_cfa_offset
-# define cfi_adjust_cfa_offset(off)	.cfi_adjust_cfa_offset off
-#endif
-
-#ifndef ENTRY
-# define ENTRY(name)			\
-	.type name,  @function;		\
-	.globl name;			\
-	.p2align 4;			\
-name:					\
-	cfi_startproc
-#endif
-
-#ifndef END
-# define END(name)			\
-	cfi_endproc;			\
-	.size name, .-name
-#endif
-
 #define CFI_PUSH(REG)						\
-  cfi_adjust_cfa_offset (4);					\
-  cfi_rel_offset (REG, 0)
+  .cfi_adjust_cfa_offset 4;					\
+  .cfi_rel_offset REG, 0
 
 #define CFI_POP(REG)						\
-  cfi_adjust_cfa_offset (-4);					\
-  cfi_restore (REG)
+  .cfi_adjust_cfa_offset -4;					\
+  .cfi_restore REG
 
-#define PUSH(REG)	pushl REG; CFI_PUSH (REG)
-#define POP(REG)	popl REG; CFI_POP (REG)
+#define PUSH(REG)	pushl REG; CFI_PUSH(REG)
+#define POP(REG)	popl REG; CFI_POP(REG)
 
-#ifdef USE_AS_BZERO
-# define DEST		PARMS
-# define LEN		DEST+4
-# define SETRTNVAL
-#else
-# define DEST		PARMS
-# define CHR		DEST+4
-# define LEN		CHR+4
-# define SETRTNVAL	movl DEST(%esp), %eax
-#endif
+#define PARMS 8 /* Preserve EBX. */
+#define DST PARMS
+#define CHR (DST+4)
+#define LEN (CHR+4)
+#define CHK_DST_LEN (LEN+4)
+#define SETRTNVAL	movl DST(%esp), %eax
 
-#if (defined SHARED || defined __PIC__)
-# define ENTRANCE	PUSH (%ebx);
-# define RETURN_END	POP (%ebx); ret
-# define RETURN		RETURN_END; CFI_PUSH (%ebx)
-# define PARMS		8		/* Preserve EBX.  */
+# define ENTRANCE	PUSH(%ebx);
+# define RETURN_END	POP(%ebx); ret
+# define RETURN		RETURN_END; CFI_PUSH(%ebx)
 # define JMPTBL(I, B)	I - B
 
 /* Load an entry in a jump table into EBX and branch to it.  TABLE is a
@@ -117,54 +74,49 @@
        absolute address.  */					\
     add		(%ebx,%ecx,4), %ebx;				\
     add		%ecx, %edx;					\
-    /* We loaded the jump table and adjuested EDX. Go.  */	\
+    /* We loaded the jump table and adjusted EDX. Go.  */	\
     jmp		*%ebx
 
 	.section	.gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits
 	.globl	__x86.get_pc_thunk.bx
 	.hidden	__x86.get_pc_thunk.bx
-	ALIGN (4)
+	ALIGN(4)
 	.type	__x86.get_pc_thunk.bx,@function
 __x86.get_pc_thunk.bx:
 	movl	(%esp), %ebx
 	ret
-#else
-# define ENTRANCE
-# define RETURN_END	ret
-# define RETURN		RETURN_END
-# define PARMS		4
-# define JMPTBL(I, B)	I
 
-/* Branch to an entry in a jump table.  TABLE is a jump table with
-   absolute offsets.  */
-# define BRANCH_TO_JMPTBL_ENTRY(TABLE)				\
-    add		%ecx, %edx;					\
-    jmp		*TABLE(,%ecx,4)
-#endif
+ENTRY(__memset_chk)
+  ENTRANCE
+
+  movl LEN(%esp), %ecx
+  cmpl CHK_DST_LEN(%esp), %ecx
+  jna L(memset_length_loaded)
+
+  POP(%ebx) // Undo ENTRANCE without returning.
+  jmp __memset_chk_fail
+END(__memset_chk)
 
 	.section .text.sse2,"ax",@progbits
-	ALIGN (4)
-ENTRY (MEMSET)
+	ALIGN(4)
+ENTRY(memset)
 	ENTRANCE
 
 	movl	LEN(%esp), %ecx
+L(memset_length_loaded):
 	cmp	$0, %ecx
 	ja	L(1byteormore)
 	SETRTNVAL
 	RETURN
 
 L(1byteormore):
-#ifdef USE_AS_BZERO
-	xor	%eax, %eax
-#else
 	movzbl	CHR(%esp), %eax
 	movb	%al, %ah
 	/* Fill the whole EAX with pattern.  */
 	movl	%eax, %edx
 	shl	 $16, %eax
 	or	%edx, %eax
-#endif
-	movl	DEST(%esp), %edx
+	movl	DST(%esp), %edx
 	cmp	$1, %ecx
 	je	L(1byte)
 	cmp	$16, %ecx
@@ -193,14 +145,10 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(16bytesormore):
-#ifdef USE_AS_BZERO
-	pxor	%xmm0, %xmm0
-#else
 	movd	%eax, %xmm0
 	pshufd	$0, %xmm0, %xmm0
-#endif
 
 	cmp	$64, %ecx
 	ja	L(64bytesmore)
@@ -226,47 +174,25 @@
 	add	%eax, %ecx
 	movd	%xmm0, %eax
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16):
 	cmp	$128, %ecx
 	jae	L(128bytesormore)
 
 L(aligned_16_less128bytes):
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
-	ALIGN (4)
+	ALIGN(4)
 L(128bytesormore):
-#ifdef SHARED_CACHE_SIZE
-	PUSH (%ebx)
+	PUSH(%ebx)
 	mov	$SHARED_CACHE_SIZE, %ebx
-#else
-# if (defined SHARED || defined __PIC__)
-	call	__x86.get_pc_thunk.bx
-	add	$_GLOBAL_OFFSET_TABLE_, %ebx
-	mov	$__x86_shared_cache_size@GOTOFF(%ebx), %ebx
-# else
-	PUSH (%ebx)
-	mov	$__x86_shared_cache_size, %ebx
-# endif
-#endif
 	cmp	%ebx, %ecx
 	jae	L(128bytesormore_nt_start)
 
-	POP (%ebx)
+	POP(%ebx)
 
-#ifdef DATA_CACHE_SIZE
-	PUSH (%ebx)
+	PUSH(%ebx)
 	mov	$DATA_CACHE_SIZE, %ebx
-#else
-# if (defined SHARED || defined __PIC__)
-	call	__x86.get_pc_thunk.bx
-	add	$_GLOBAL_OFFSET_TABLE_, %ebx
-	mov	$__x86_data_cache_size@GOTOFF(%ebx), %ebx
-# else
-	PUSH (%ebx)
-	mov	$__x86_data_cache_size, %ebx
-# endif
-#endif
 
 	cmp	%ebx, %ecx
 	jae	L(128bytes_L2_normal)
@@ -299,12 +225,10 @@
 
 L(128bytesless_normal):
 	lea	128(%ecx), %ecx
-#if defined DATA_CACHE_SIZE || !(defined SHARED || defined __PIC__)
-	POP (%ebx)
-#endif
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	POP(%ebx)
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
-	ALIGN (4)
+	ALIGN(4)
 L(128bytes_L2_normal):
 	prefetchnta	0x380(%edx)
 	prefetchnta	0x3c0(%edx)
@@ -322,14 +246,12 @@
 	jae	L(128bytes_L2_normal)
 
 L(128bytesless_L2_normal):
-#if defined DATA_CACHE_SIZE || !(defined SHARED || defined __PIC__)
-	POP (%ebx)
-#endif
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	POP(%ebx)
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
 L(128bytesormore_nt_start):
 	sub	%ebx, %ecx
-	ALIGN (4)
+	ALIGN(4)
 L(128bytesormore_shared_cache_loop):
 	prefetchnta	0x3c0(%edx)
 	prefetchnta	0x380(%edx)
@@ -347,7 +269,7 @@
 	jae	L(128bytesormore_shared_cache_loop)
 	cmp	$0x80, %ecx
 	jb	L(shared_cache_loop_end)
-	ALIGN (4)
+	ALIGN(4)
 L(128bytesormore_nt):
 	sub	$0x80, %ecx
 	movntdq	%xmm0, (%edx)
@@ -363,146 +285,144 @@
 	jae	L(128bytesormore_nt)
 	sfence
 L(shared_cache_loop_end):
-#if defined SHARED_CACHE_SIZE || !(defined SHARED || defined __PIC__)
-	POP (%ebx)
-#endif
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
+	POP(%ebx)
+	BRANCH_TO_JMPTBL_ENTRY(L(table_16_128bytes))
 
 
 	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
+	ALIGN(2)
 L(table_16_128bytes):
-	.int	JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_1bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_2bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_3bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_5bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_6bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_7bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_9bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_10bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_11bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_13bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_14bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_15bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_17bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_18bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_19bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_21bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_22bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_23bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_25bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_26bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_27bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_29bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_30bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_31bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_33bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_34bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_35bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_37bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_38bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_39bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_41bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_42bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_43bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_45bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_46bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_47bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_49bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_50bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_51bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_53bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_54bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_55bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_57bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_58bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_59bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_61bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_62bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_63bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_65bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_66bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_67bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_69bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_70bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_71bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_73bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_74bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_75bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_77bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_78bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_79bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_81bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_82bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_83bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_85bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_86bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_87bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_89bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_90bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_91bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_93bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_94bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_95bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_97bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_98bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_99bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_101bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_102bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_103bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_105bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_106bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_107bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_109bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_110bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_111bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_113bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_114bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_115bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_117bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_118bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_119bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_121bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_122bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_123bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_125bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_126bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_127bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_0bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_1bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_2bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_3bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_4bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_5bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_6bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_7bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_8bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_9bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_10bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_11bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_12bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_13bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_14bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_15bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_16bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_17bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_18bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_19bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_20bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_21bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_22bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_23bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_24bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_25bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_26bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_27bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_28bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_29bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_30bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_31bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_32bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_33bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_34bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_35bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_36bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_37bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_38bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_39bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_40bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_41bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_42bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_43bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_44bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_45bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_46bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_47bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_48bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_49bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_50bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_51bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_52bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_53bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_54bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_55bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_56bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_57bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_58bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_59bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_60bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_61bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_62bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_63bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_64bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_65bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_66bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_67bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_68bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_69bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_70bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_71bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_72bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_73bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_74bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_75bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_76bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_77bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_78bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_79bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_80bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_81bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_82bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_83bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_84bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_85bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_86bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_87bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_88bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_89bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_90bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_91bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_92bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_93bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_94bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_95bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_96bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_97bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_98bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_99bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_100bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_101bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_102bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_103bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_104bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_105bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_106bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_107bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_108bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_109bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_110bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_111bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_112bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_113bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_114bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_115bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_116bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_117bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_118bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_119bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_120bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_121bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_122bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_123bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_124bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_125bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_126bytes), L(table_16_128bytes))
+	.int	JMPTBL(L(aligned_16_127bytes), L(table_16_128bytes))
 	.popsection
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_112bytes):
 	movdqa	%xmm0, -112(%edx)
 L(aligned_16_96bytes):
@@ -521,7 +441,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_113bytes):
 	movdqa	%xmm0, -113(%edx)
 L(aligned_16_97bytes):
@@ -541,7 +461,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_114bytes):
 	movdqa	%xmm0, -114(%edx)
 L(aligned_16_98bytes):
@@ -561,7 +481,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_115bytes):
 	movdqa	%xmm0, -115(%edx)
 L(aligned_16_99bytes):
@@ -582,7 +502,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_116bytes):
 	movdqa	%xmm0, -116(%edx)
 L(aligned_16_100bytes):
@@ -602,7 +522,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_117bytes):
 	movdqa	%xmm0, -117(%edx)
 L(aligned_16_101bytes):
@@ -623,7 +543,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_118bytes):
 	movdqa	%xmm0, -118(%edx)
 L(aligned_16_102bytes):
@@ -644,7 +564,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_119bytes):
 	movdqa	%xmm0, -119(%edx)
 L(aligned_16_103bytes):
@@ -666,7 +586,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_120bytes):
 	movdqa	%xmm0, -120(%edx)
 L(aligned_16_104bytes):
@@ -686,7 +606,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_121bytes):
 	movdqa	%xmm0, -121(%edx)
 L(aligned_16_105bytes):
@@ -707,7 +627,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_122bytes):
 	movdqa	%xmm0, -122(%edx)
 L(aligned_16_106bytes):
@@ -728,7 +648,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_123bytes):
 	movdqa	%xmm0, -123(%edx)
 L(aligned_16_107bytes):
@@ -750,7 +670,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_124bytes):
 	movdqa	%xmm0, -124(%edx)
 L(aligned_16_108bytes):
@@ -771,7 +691,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_125bytes):
 	movdqa	%xmm0, -125(%edx)
 L(aligned_16_109bytes):
@@ -793,7 +713,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_126bytes):
 	movdqa	%xmm0, -126(%edx)
 L(aligned_16_110bytes):
@@ -815,7 +735,7 @@
 	SETRTNVAL
 	RETURN
 
-	ALIGN (4)
+	ALIGN(4)
 L(aligned_16_127bytes):
 	movdqa	%xmm0, -127(%edx)
 L(aligned_16_111bytes):
@@ -838,4 +758,4 @@
 	SETRTNVAL
 	RETURN_END
 
-END (MEMSET)
+END(memset)
diff --git a/libc/arch-x86/syscalls/__sync_file_range.S b/libc/arch-x86/syscalls/__sync_file_range.S
new file mode 100644
index 0000000..f5bf3ec
--- /dev/null
+++ b/libc/arch-x86/syscalls/__sync_file_range.S
@@ -0,0 +1,54 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+    pushl   %ebx
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset ebx, 0
+    pushl   %ecx
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset ecx, 0
+    pushl   %edx
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset edx, 0
+    pushl   %esi
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset esi, 0
+    pushl   %edi
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset edi, 0
+    pushl   %ebp
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset ebp, 0
+
+    call    __kernel_syscall
+    pushl   %eax
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset eax, 0
+
+    mov     32(%esp), %ebx
+    mov     36(%esp), %ecx
+    mov     40(%esp), %edx
+    mov     44(%esp), %esi
+    mov     48(%esp), %edi
+    mov     52(%esp), %ebp
+    movl    $__NR_sync_file_range, %eax
+    call    *(%esp)
+    addl    $4, %esp
+
+    cmpl    $-MAX_ERRNO, %eax
+    jb      1f
+    negl    %eax
+    pushl   %eax
+    call    __set_errno_internal
+    addl    $4, %esp
+1:
+    popl    %ebp
+    popl    %edi
+    popl    %esi
+    popl    %edx
+    popl    %ecx
+    popl    %ebx
+    ret
+END(__sync_file_range)
diff --git a/libc/arch-x86/syscalls/quotactl.S b/libc/arch-x86/syscalls/quotactl.S
new file mode 100644
index 0000000..326cf87
--- /dev/null
+++ b/libc/arch-x86/syscalls/quotactl.S
@@ -0,0 +1,44 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(quotactl)
+    pushl   %ebx
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset ebx, 0
+    pushl   %ecx
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset ecx, 0
+    pushl   %edx
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset edx, 0
+    pushl   %esi
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset esi, 0
+
+    call    __kernel_syscall
+    pushl   %eax
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset eax, 0
+
+    mov     24(%esp), %ebx
+    mov     28(%esp), %ecx
+    mov     32(%esp), %edx
+    mov     36(%esp), %esi
+    movl    $__NR_quotactl, %eax
+    call    *(%esp)
+    addl    $4, %esp
+
+    cmpl    $-MAX_ERRNO, %eax
+    jb      1f
+    negl    %eax
+    pushl   %eax
+    call    __set_errno_internal
+    addl    $4, %esp
+1:
+    popl    %esi
+    popl    %edx
+    popl    %ecx
+    popl    %ebx
+    ret
+END(quotactl)
diff --git a/libc/arch-x86/syscalls/setdomainname.S b/libc/arch-x86/syscalls/setdomainname.S
new file mode 100644
index 0000000..8b6afe2
--- /dev/null
+++ b/libc/arch-x86/syscalls/setdomainname.S
@@ -0,0 +1,34 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(setdomainname)
+    pushl   %ebx
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset ebx, 0
+    pushl   %ecx
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset ecx, 0
+
+    call    __kernel_syscall
+    pushl   %eax
+    .cfi_adjust_cfa_offset 4
+    .cfi_rel_offset eax, 0
+
+    mov     16(%esp), %ebx
+    mov     20(%esp), %ecx
+    movl    $__NR_setdomainname, %eax
+    call    *(%esp)
+    addl    $4, %esp
+
+    cmpl    $-MAX_ERRNO, %eax
+    jb      1f
+    negl    %eax
+    pushl   %eax
+    call    __set_errno_internal
+    addl    $4, %esp
+1:
+    popl    %ecx
+    popl    %ebx
+    ret
+END(setdomainname)
diff --git a/libc/arch-x86/x86.mk b/libc/arch-x86/x86.mk
deleted file mode 100644
index 1d717aa..0000000
--- a/libc/arch-x86/x86.mk
+++ /dev/null
@@ -1,140 +0,0 @@
-# 32-bit x86.
-
-#
-# Generic x86 optimizations, may be overriden by CPU variants.
-#
-
-libc_bionic_src_files_x86 += \
-    arch-x86/atom/string/sse2-memchr-atom.S \
-    arch-x86/atom/string/sse2-memrchr-atom.S \
-    arch-x86/atom/string/sse2-strchr-atom.S \
-    arch-x86/atom/string/sse2-strnlen-atom.S \
-    arch-x86/atom/string/sse2-strrchr-atom.S \
-    arch-x86/atom/string/sse2-wcschr-atom.S \
-    arch-x86/atom/string/sse2-wcsrchr-atom.S \
-    arch-x86/atom/string/sse2-wcslen-atom.S \
-    arch-x86/atom/string/sse2-wcscmp-atom.S \
-    arch-x86/silvermont/string/sse2-bcopy-slm.S \
-    arch-x86/silvermont/string/sse2-bzero-slm.S \
-    arch-x86/silvermont/string/sse2-memcpy-slm.S \
-    arch-x86/silvermont/string/sse2-memmove-slm.S \
-    arch-x86/silvermont/string/sse2-memset-slm.S \
-    arch-x86/silvermont/string/sse2-stpcpy-slm.S \
-    arch-x86/silvermont/string/sse2-stpncpy-slm.S \
-    arch-x86/silvermont/string/sse2-strcpy-slm.S \
-    arch-x86/silvermont/string/sse2-strlen-slm.S \
-    arch-x86/silvermont/string/sse2-strncpy-slm.S
-
-libc_bionic_src_files_x86 += \
-    arch-x86/generic/string/memcmp.S \
-    arch-x86/generic/string/strcmp.S \
-    arch-x86/generic/string/strncmp.S \
-    arch-x86/generic/string/strcat.S
-
-ifeq ($(ARCH_X86_HAVE_SSSE3),true)
-libc_bionic_src_files_x86 += \
-    arch-x86/atom/string/ssse3-strncat-atom.S \
-    arch-x86/atom/string/ssse3-strlcat-atom.S \
-    arch-x86/atom/string/ssse3-strlcpy-atom.S \
-    arch-x86/atom/string/ssse3-strcmp-atom.S \
-    arch-x86/atom/string/ssse3-strncmp-atom.S \
-    arch-x86/atom/string/ssse3-strcat-atom.S \
-    arch-x86/atom/string/ssse3-wcscat-atom.S \
-    arch-x86/atom/string/ssse3-wcscpy-atom.S
-libc_bionic_src_files_exclude_x86 += \
-    arch-x86/generic/string/strcmp.S \
-    arch-x86/generic/string/strncmp.S \
-    arch-x86/generic/string/strcat.S
-endif
-
-ifeq ($(ARCH_X86_HAVE_SSE4),true)
-libc_bionic_src_files_x86 += \
-    arch-x86/silvermont/string/sse4-memcmp-slm.S \
-    arch-x86/silvermont/string/sse4-wmemcmp-slm.S
-libc_bionic_src_files_exclude_x86 += \
-    arch-x86/generic/string/memcmp.S
-endif
-
-#
-# Remove default implementations that we have optimized versions of.
-#
-
-libc_freebsd_src_files_exclude_x86 += \
-    upstream-freebsd/lib/libc/string/wcschr.c \
-    upstream-freebsd/lib/libc/string/wcscmp.c \
-    upstream-freebsd/lib/libc/string/wcslen.c \
-    upstream-freebsd/lib/libc/string/wcsrchr.c \
-
-ifeq ($(ARCH_X86_HAVE_SSSE3),true)
-libc_freebsd_src_files_exclude_x86 += \
-    upstream-freebsd/lib/libc/string/wcscat.c \
-    upstream-freebsd/lib/libc/string/wcscpy.c
-endif
-
-ifeq ($(ARCH_X86_HAVE_SSE4),true)
-libc_freebsd_src_files_exclude_x86 += \
-    upstream-freebsd/lib/libc/string/wmemcmp.c
-endif
-
-libc_openbsd_src_files_exclude_x86 += \
-    upstream-openbsd/lib/libc/string/memchr.c \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/memrchr.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/stpncpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-    upstream-openbsd/lib/libc/string/strcpy.c \
-    upstream-openbsd/lib/libc/string/strncmp.c \
-    upstream-openbsd/lib/libc/string/strncpy.c \
-
-ifeq ($(ARCH_X86_HAVE_SSSE3),true)
-libc_openbsd_src_files_exclude_x86 += \
-    upstream-openbsd/lib/libc/string/strlcat.c \
-    upstream-openbsd/lib/libc/string/strlcpy.c \
-    upstream-openbsd/lib/libc/string/strncat.c
-endif
-
-libc_bionic_src_files_exclude_x86 += \
-    bionic/strchr.cpp \
-    bionic/strnlen.c \
-    bionic/strrchr.cpp \
-
-#
-# Inherently architecture-specific functions.
-#
-
-libc_bionic_src_files_x86 += \
-    arch-x86/bionic/__bionic_clone.S \
-    arch-x86/bionic/_exit_with_stack_teardown.S \
-    arch-x86/bionic/libgcc_compat.c \
-    arch-x86/bionic/__restore.S \
-    arch-x86/bionic/setjmp.S \
-    arch-x86/bionic/syscall.S \
-    arch-x86/bionic/vfork.S \
-
-## ARCH variant specific source files
-arch_variant_mk := $(LOCAL_PATH)/arch-x86/$(TARGET_ARCH_VARIANT)/$(TARGET_ARCH_VARIANT).mk
-ifeq ($(wildcard $(arch_variant_mk)),)
-    arch_variant_mk :=
-endif
-ifneq ($(arch_variant_mk),)
-include $(arch_variant_mk)
-libc_common_additional_dependencies += $(arch_variant_mk)
-
-arch_variant_mk :=
-endif
-
-libc_crt_target_cflags_x86 := \
-    -m32 \
-    -I$(LOCAL_PATH)/arch-x86/include
-
-libc_crt_target_ldflags_x86 := -melf_i386
-
-libc_crt_target_crtbegin_file_x86 := \
-     $(LOCAL_PATH)/arch-common/bionic/crtbegin.c
-
-libc_crt_target_crtbegin_so_file_x86 := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c
-
-libc_crt_target_so_cflags_x86 := \
-    -fPIC
diff --git a/libc/arch-x86_64/bionic/__bionic_clone.S b/libc/arch-x86_64/bionic/__bionic_clone.S
index 0c73e5f..a4245b8 100644
--- a/libc/arch-x86_64/bionic/__bionic_clone.S
+++ b/libc/arch-x86_64/bionic/__bionic_clone.S
@@ -29,7 +29,7 @@
 #include <private/bionic_asm.h>
 
 // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
-ENTRY(__bionic_clone)
+ENTRY_PRIVATE(__bionic_clone)
         # Copy 'fn' and 'arg' onto the child stack.
         movq    %r9, -16(%rsi)  # fn
         movq    8(%rsp), %rax   # Read 'arg'.
@@ -74,4 +74,3 @@
         # We're the parent; nothing to do.
         ret
 END(__bionic_clone)
-.hidden __bionic_clone
diff --git a/libm/include/amd64/machine/fenv.h b/libc/arch-x86_64/include/machine/fenv.h
similarity index 100%
rename from libm/include/amd64/machine/fenv.h
rename to libc/arch-x86_64/include/machine/fenv.h
diff --git a/libc/arch-x86_64/string/sse2-memset-slm.S b/libc/arch-x86_64/string/sse2-memset-slm.S
index bfcafae..fc502c0 100644
--- a/libc/arch-x86_64/string/sse2-memset-slm.S
+++ b/libc/arch-x86_64/string/sse2-memset-slm.S
@@ -28,11 +28,9 @@
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "cache.h"
+#include <private/bionic_asm.h>
 
-#ifndef MEMSET
-# define MEMSET		memset
-#endif
+#include "cache.h"
 
 #ifndef L
 # define L(label)	.L##label
@@ -42,39 +40,21 @@
 # define ALIGN(n)	.p2align n
 #endif
 
-#ifndef cfi_startproc
-# define cfi_startproc			.cfi_startproc
-#endif
 
-#ifndef cfi_endproc
-# define cfi_endproc			.cfi_endproc
-#endif
+ENTRY(__memset_chk)
+  # %rdi = dst, %rsi = byte, %rdx = n, %rcx = dst_len
+  cmp %rcx, %rdx
+  ja __memset_chk_fail
+  // Fall through to memset...
+END(__memset_chk)
 
-#ifndef ENTRY
-# define ENTRY(name)			\
-	.type name,  @function;	\
-	.globl name;			\
-name:					\
-	cfi_startproc
-#endif
-
-#ifndef END
-# define END(name)			\
-	cfi_endproc;			\
-	.size name, .-name
-#endif
 
 	.section .text.sse2,"ax",@progbits
-ENTRY (MEMSET)
+ENTRY(memset)
 	movq	%rdi, %rax
-#ifdef USE_AS_BZERO_P
-	mov	%rsi, %rdx
-	xor	%rcx, %rcx
-#else
 	and	$0xff, %rsi
 	mov	$0x0101010101010101, %rcx
 	imul	%rsi, %rcx
-#endif
 	cmpq	$16, %rdx
 	jae	L(16bytesormore)
 	testb	$8, %dl
@@ -106,12 +86,8 @@
 
 	ALIGN (4)
 L(16bytesormore):
-#ifdef USE_AS_BZERO_P
-	pxor	%xmm0, %xmm0
-#else
 	movd	%rcx, %xmm0
 	pshufd	$0, %xmm0, %xmm0
-#endif
 	movdqu	%xmm0, (%rdi)
 	movdqu	%xmm0, -16(%rdi, %rdx)
 	cmpq	$32, %rdx
@@ -170,4 +146,4 @@
 	sfence
 	ret
 
-END (MEMSET)
+END(memset)
diff --git a/libc/arch-x86_64/syscalls/__sync_file_range.S b/libc/arch-x86_64/syscalls/__sync_file_range.S
new file mode 100644
index 0000000..6a2c430
--- /dev/null
+++ b/libc/arch-x86_64/syscalls/__sync_file_range.S
@@ -0,0 +1,17 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__sync_file_range)
+    movq    %rcx, %r10
+    movl    $__NR_sync_file_range, %eax
+    syscall
+    cmpq    $-MAX_ERRNO, %rax
+    jb      1f
+    negl    %eax
+    movl    %eax, %edi
+    call    __set_errno_internal
+1:
+    ret
+END(__sync_file_range)
+.hidden __sync_file_range
diff --git a/libc/arch-x86_64/syscalls/quotactl.S b/libc/arch-x86_64/syscalls/quotactl.S
new file mode 100644
index 0000000..427358a
--- /dev/null
+++ b/libc/arch-x86_64/syscalls/quotactl.S
@@ -0,0 +1,16 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(quotactl)
+    movq    %rcx, %r10
+    movl    $__NR_quotactl, %eax
+    syscall
+    cmpq    $-MAX_ERRNO, %rax
+    jb      1f
+    negl    %eax
+    movl    %eax, %edi
+    call    __set_errno_internal
+1:
+    ret
+END(quotactl)
diff --git a/libc/arch-x86_64/syscalls/setdomainname.S b/libc/arch-x86_64/syscalls/setdomainname.S
new file mode 100644
index 0000000..40d1a33
--- /dev/null
+++ b/libc/arch-x86_64/syscalls/setdomainname.S
@@ -0,0 +1,15 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(setdomainname)
+    movl    $__NR_setdomainname, %eax
+    syscall
+    cmpq    $-MAX_ERRNO, %rax
+    jb      1f
+    negl    %eax
+    movl    %eax, %edi
+    call    __set_errno_internal
+1:
+    ret
+END(setdomainname)
diff --git a/libc/arch-x86_64/x86_64.mk b/libc/arch-x86_64/x86_64.mk
deleted file mode 100644
index ce06217..0000000
--- a/libc/arch-x86_64/x86_64.mk
+++ /dev/null
@@ -1,65 +0,0 @@
-# 64-bit x86.
-
-#
-# Remove default implementations that we have optimized versions of.
-#
-
-libc_openbsd_src_files_exclude_x86_64 += \
-    upstream-openbsd/lib/libc/string/memmove.c \
-    upstream-openbsd/lib/libc/string/stpcpy.c \
-    upstream-openbsd/lib/libc/string/stpncpy.c \
-    upstream-openbsd/lib/libc/string/strcat.c \
-    upstream-openbsd/lib/libc/string/strcpy.c \
-    upstream-openbsd/lib/libc/string/strlcat.c \
-    upstream-openbsd/lib/libc/string/strlcpy.c \
-    upstream-openbsd/lib/libc/string/strncat.c \
-    upstream-openbsd/lib/libc/string/strncmp.c \
-    upstream-openbsd/lib/libc/string/strncpy.c \
-
-#
-# Inherently architecture-specific code.
-#
-
-libc_bionic_src_files_x86_64 += \
-    arch-x86_64/bionic/__bionic_clone.S \
-    arch-x86_64/bionic/_exit_with_stack_teardown.S \
-    arch-x86_64/bionic/__restore_rt.S \
-    arch-x86_64/bionic/setjmp.S \
-    arch-x86_64/bionic/syscall.S \
-    arch-x86_64/bionic/vfork.S \
-
-#
-# Optimized memory/string functions.
-#
-
-libc_bionic_src_files_x86_64 += \
-    arch-x86_64/string/sse2-memcpy-slm.S \
-    arch-x86_64/string/sse2-memmove-slm.S \
-    arch-x86_64/string/sse2-memset-slm.S \
-    arch-x86_64/string/sse2-stpcpy-slm.S \
-    arch-x86_64/string/sse2-stpncpy-slm.S \
-    arch-x86_64/string/sse2-strcat-slm.S \
-    arch-x86_64/string/sse2-strcpy-slm.S \
-    arch-x86_64/string/sse2-strlcat-slm.S \
-    arch-x86_64/string/sse2-strlcpy-slm.S \
-    arch-x86_64/string/sse2-strlen-slm.S \
-    arch-x86_64/string/sse2-strncat-slm.S \
-    arch-x86_64/string/sse2-strncpy-slm.S \
-    arch-x86_64/string/sse4-memcmp-slm.S \
-    arch-x86_64/string/ssse3-strcmp-slm.S \
-    arch-x86_64/string/ssse3-strncmp-slm.S \
-
-libc_crt_target_cflags_x86_64 += \
-    -m64 \
-    -I$(LOCAL_PATH)/arch-x86_64/include \
-
-libc_crt_target_ldflags_x86_64 := -melf_x86_64 \
-
-libc_crt_target_crtbegin_file_x86_64 := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin.c \
-
-libc_crt_target_crtbegin_so_file_x86_64 := \
-    $(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c \
-
-libc_crt_target_so_cflags_x86_64 := \
-    -fPIC \
diff --git a/libc/bionic/__FD_chk.cpp b/libc/bionic/__FD_chk.cpp
deleted file mode 100644
index af8427a..0000000
--- a/libc/bionic/__FD_chk.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <sys/select.h>
-#include "private/libc_logging.h"
-
-extern "C" int __FD_ISSET_chk(int fd, fd_set* set, size_t set_size) {
-  if (__predict_false(fd < 0)) {
-    __fortify_chk_fail("FD_ISSET: file descriptor < 0", 0);
-  }
-  if (__predict_false(fd >= FD_SETSIZE)) {
-    __fortify_chk_fail("FD_ISSET: file descriptor >= FD_SETSIZE", 0);
-  }
-  if (__predict_false(set_size < sizeof(fd_set))) {
-    __fortify_chk_fail("FD_ISSET: set is too small", 0);
-  }
-  return FD_ISSET(fd, set);
-}
-
-extern "C" void __FD_CLR_chk(int fd, fd_set* set, size_t set_size) {
-  if (__predict_false(fd < 0)) {
-    __fortify_chk_fail("FD_CLR: file descriptor < 0", 0);
-  }
-  if (__predict_false(fd >= FD_SETSIZE)) {
-    __fortify_chk_fail("FD_CLR: file descriptor >= FD_SETSIZE", 0);
-  }
-  if (__predict_false(set_size < sizeof(fd_set))) {
-    __fortify_chk_fail("FD_CLR: set is too small", 0);
-  }
-  FD_CLR(fd, set);
-}
-
-extern "C" void __FD_SET_chk(int fd, fd_set* set, size_t set_size) {
-  if (__predict_false(fd < 0)) {
-    __fortify_chk_fail("FD_SET: file descriptor < 0", 0);
-  }
-  if (__predict_false(fd >= FD_SETSIZE)) {
-    __fortify_chk_fail("FD_SET: file descriptor >= FD_SETSIZE", 0);
-  }
-  if (__predict_false(set_size < sizeof(fd_set))) {
-    __fortify_chk_fail("FD_SET: set is too small", 0);
-  }
-  FD_SET(fd, set);
-}
diff --git a/libc/bionic/__fgets_chk.cpp b/libc/bionic/__fgets_chk.cpp
deleted file mode 100644
index 75e4ca0..0000000
--- a/libc/bionic/__fgets_chk.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * __fgets_chk. Called in place of fgets() when we know the
- * size of the buffer we're writing into.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- * for details.
- *
- * This fgets check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-char* __fgets_chk(char* dest, int supplied_size, FILE* stream,
-                  size_t dest_len_from_compiler) {
-  if (supplied_size < 0) {
-    __fortify_chk_fail("fgets: buffer size < 0", 0);
-  }
-
-  if (((size_t) supplied_size) > dest_len_from_compiler) {
-    __fortify_chk_fail("fgets: prevented write past end of buffer", 0);
-  }
-
-  return fgets(dest, supplied_size, stream);
-}
diff --git a/libc/bionic/__fwrite_chk.cpp b/libc/bionic/__fwrite_chk.cpp
deleted file mode 100644
index 2af13d6..0000000
--- a/libc/bionic/__fwrite_chk.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <stdio.h>
-#include <sys/cdefs.h>
-#include "private/libc_logging.h"
-
-extern "C" size_t __fwrite_chk(const void * __restrict buf, size_t size, size_t count,
-                               FILE * __restrict stream, size_t buf_size) {
-  size_t total;
-  if (__predict_false(__size_mul_overflow(size, count, &total))) {
-    // overflow: trigger the error path in fwrite
-    return fwrite(buf, size, count, stream);
-  }
-
-  if (__predict_false(total > buf_size)) {
-    __fortify_chk_fail("fwrite: prevented read past end of buffer", 0);
-  }
-
-  return fwrite(buf, size, count, stream);
-}
diff --git a/libc/bionic/__getcwd_chk.cpp b/libc/bionic/__getcwd_chk.cpp
deleted file mode 100644
index b53ab5c..0000000
--- a/libc/bionic/__getcwd_chk.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern char* __getcwd_chk(char* buf, size_t len, size_t buflen) {
-  if (__predict_false(len > buflen)) {
-    __fortify_chk_fail("getcwd: prevented write past end of buffer", 0);
-  }
-
-  return getcwd(buf, len);
-}
diff --git a/libc/bionic/__libc_init_main_thread.cpp b/libc/bionic/__libc_init_main_thread.cpp
index 01bb9bb..b5a83f4 100644
--- a/libc/bionic/__libc_init_main_thread.cpp
+++ b/libc/bionic/__libc_init_main_thread.cpp
@@ -28,14 +28,24 @@
 
 #include "libc_init_common.h"
 
+#include "private/KernelArgumentBlock.h"
 #include "private/bionic_auxv.h"
 #include "private/bionic_globals.h"
-#include "private/KernelArgumentBlock.h"
+#include "private/bionic_ssp.h"
 #include "pthread_internal.h"
 
 extern "C" int __set_tls(void* ptr);
 extern "C" int __set_tid_address(int* tid_address);
 
+// Declared in "private/bionic_ssp.h".
+uintptr_t __stack_chk_guard = 0;
+
+void __libc_init_global_stack_chk_guard(KernelArgumentBlock& args) {
+  // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
+  // Take the first 4/8 for the -fstack-protector implementation.
+  __stack_chk_guard = *reinterpret_cast<uintptr_t*>(args.getauxval(AT_RANDOM));
+}
+
 // Setup for the main thread. For dynamic executables, this is called by the
 // linker _before_ libc is mapped in memory. This means that all writes to
 // globals from this function will apply to linker-private copies and will not
@@ -59,7 +69,9 @@
 
   // The -fstack-protector implementation uses TLS, so make sure that's
   // set up before we call any function that might get a stack check inserted.
+  // TLS also needs to be set up before errno (and therefore syscalls) can be used.
   __set_tls(main_thread.tls);
+  __init_tls(&main_thread);
 
   // Tell the kernel to clear our tid field when we exit, so we're like any other pthread.
   // As a side-effect, this tells us our pid (which is the same as the main thread's tid).
@@ -78,11 +90,12 @@
   // TODO: the main thread's sched_policy and sched_priority need to be queried.
 
   // The TLS stack guard is set from the global, so ensure that we've initialized the global
-  // before we initialize the TLS.
+  // before we initialize the TLS. Dynamic executables will initialize their copy of the global
+  // stack protector from the one in the main thread's TLS.
   __libc_init_global_stack_chk_guard(args);
+  __init_thread_stack_guard(&main_thread);
 
   __init_thread(&main_thread);
-  __init_tls(&main_thread);
 
   // Store a pointer to the kernel argument block in a TLS slot to be
   // picked up by the libc constructor.
diff --git a/libc/bionic/__memchr_chk.cpp b/libc/bionic/__memchr_chk.cpp
deleted file mode 100644
index d141c04..0000000
--- a/libc/bionic/__memchr_chk.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <string.h>
-#include "private/libc_logging.h"
-
-extern "C" void* __memchr_chk(const void* s, int c, size_t n, size_t buf_size) {
-  if (__predict_false(n > buf_size)) {
-    __fortify_chk_fail("memchr: prevented read past end of buffer", 0);
-  }
-
-  return memchr(s, c, n);
-}
diff --git a/libc/bionic/__memcpy_chk.cpp b/libc/bionic/__memcpy_chk.cpp
index 8a4f207..7b42d99 100644
--- a/libc/bionic/__memcpy_chk.cpp
+++ b/libc/bionic/__memcpy_chk.cpp
@@ -27,27 +27,14 @@
  */
 
 #undef _FORTIFY_SOURCE
+
 #include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
 
-/*
- * Runtime implementation of __memcpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This memcpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" void* __memcpy_chk(void* dest, const void* src,
-                              size_t copy_amount, size_t dest_len) {
-  if (__predict_false(copy_amount > dest_len)) {
-    __fortify_chk_fail("memcpy: prevented write past end of buffer",
-                       BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW);
-  }
+#include "private/bionic_fortify.h"
 
-  return memcpy(dest, src, copy_amount);
+// Runtime implementation of __memcpy_chk (used directly by compiler, not in headers).
+extern "C" void* __memcpy_chk(void* dst, const void* src, size_t count, size_t dst_len) {
+  __check_count("memcpy", "count", count);
+  __check_buffer_access("memcpy", "write into", count, dst_len);
+  return memcpy(dst, src, count);
 }
diff --git a/libc/bionic/__memmove_chk.cpp b/libc/bionic/__memmove_chk.cpp
deleted file mode 100644
index b88a94f..0000000
--- a/libc/bionic/__memmove_chk.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __builtin____memmove_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This memmove check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" void* __memmove_chk (void* dest, const void* src,
-                                size_t len, size_t dest_len) {
-  if (__predict_false(len > dest_len)) {
-    __fortify_chk_fail("memmove: prevented write past end of buffer",
-                       BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW);
-  }
-
-  return memmove(dest, src, len);
-}
diff --git a/libc/bionic/__memrchr_chk.cpp b/libc/bionic/__memrchr_chk.cpp
deleted file mode 100644
index 8529dfc..0000000
--- a/libc/bionic/__memrchr_chk.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <string.h>
-#include "private/libc_logging.h"
-
-extern "C" void* __memrchr_chk(const void* s, int c, size_t n, size_t buf_size) {
-  if (__predict_false(n > buf_size)) {
-    __fortify_chk_fail("memrchr: prevented read past end of buffer", 0);
-  }
-
-  return memrchr(s, c, n);
-}
diff --git a/libc/bionic/__poll_chk.cpp b/libc/bionic/__poll_chk.cpp
deleted file mode 100644
index a24ab8e..0000000
--- a/libc/bionic/__poll_chk.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <poll.h>
-#include "private/libc_logging.h"
-
-extern "C" int __poll_chk(struct pollfd* fds, nfds_t fd_count, int timeout, size_t fds_size) {
-  if (__predict_false(fds_size / sizeof(*fds) < fd_count)) {
-    __fortify_chk_fail("poll: pollfd array smaller than fd count", 0);
-  }
-  return poll(fds, fd_count, timeout);
-}
-
-extern "C" int __ppoll_chk(struct pollfd* fds, nfds_t fd_count, const struct timespec* timeout, const sigset_t* mask, size_t fds_size) {
-  if (__predict_false(fds_size / sizeof(*fds) < fd_count)) {
-    __fortify_chk_fail("ppoll: pollfd array smaller than fd count", 0);
-  }
-  return ppoll(fds, fd_count, timeout, mask);
-}
diff --git a/libc/bionic/__pread64_chk.cpp b/libc/bionic/__pread64_chk.cpp
deleted file mode 100644
index 5d6ad2d..0000000
--- a/libc/bionic/__pread64_chk.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern "C" ssize_t __pread64_chk(int fd, void* buf, size_t count, off64_t offset, size_t buf_size) {
-  if (__predict_false(count > buf_size)) {
-    __fortify_chk_fail("pread64: prevented write past end of buffer", 0);
-  }
-
-  if (__predict_false(count > SSIZE_MAX)) {
-    __fortify_chk_fail("pread64: count > SSIZE_MAX", 0);
-  }
-
-  return pread64(fd, buf, count, offset);
-}
diff --git a/libc/bionic/__pread_chk.cpp b/libc/bionic/__pread_chk.cpp
deleted file mode 100644
index 7109ce6..0000000
--- a/libc/bionic/__pread_chk.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern "C" ssize_t __pread_chk(int fd, void* buf, size_t count, off_t offset, size_t buf_size) {
-  if (__predict_false(count > buf_size)) {
-    __fortify_chk_fail("pread: prevented write past end of buffer", 0);
-  }
-
-  if (__predict_false(count > SSIZE_MAX)) {
-    __fortify_chk_fail("pread: count > SSIZE_MAX", 0);
-  }
-
-  return pread(fd, buf, count, offset);
-}
diff --git a/libc/bionic/__pwrite64_chk.cpp b/libc/bionic/__pwrite64_chk.cpp
deleted file mode 100644
index e488ca1..0000000
--- a/libc/bionic/__pwrite64_chk.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern "C" ssize_t __pwrite64_chk(int fd, const void* buf, size_t count, off64_t offset,
-                                  size_t buf_size) {
-  if (__predict_false(count > buf_size)) {
-    __fortify_chk_fail("pwrite64: prevented read past end of buffer", 0);
-  }
-
-  if (__predict_false(count > SSIZE_MAX)) {
-    __fortify_chk_fail("pwrite64: count > SSIZE_MAX", 0);
-  }
-
-  return pwrite64(fd, buf, count, offset);
-}
diff --git a/libc/bionic/__pwrite_chk.cpp b/libc/bionic/__pwrite_chk.cpp
deleted file mode 100644
index a889ef6..0000000
--- a/libc/bionic/__pwrite_chk.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern "C" ssize_t __pwrite_chk(int fd, const void* buf, size_t count, off_t offset,
-                                size_t buf_size) {
-  if (__predict_false(count > buf_size)) {
-    __fortify_chk_fail("pwrite: prevented read past end of buffer", 0);
-  }
-
-  if (__predict_false(count > SSIZE_MAX)) {
-    __fortify_chk_fail("pwrite: count > SSIZE_MAX", 0);
-  }
-
-  return pwrite(fd, buf, count, offset);
-}
diff --git a/libc/bionic/__read_chk.cpp b/libc/bionic/__read_chk.cpp
deleted file mode 100644
index ff50983..0000000
--- a/libc/bionic/__read_chk.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern "C" ssize_t __read_chk(int fd, void* buf, size_t count, size_t buf_size) {
-  if (__predict_false(count > buf_size)) {
-    __fortify_chk_fail("read: prevented write past end of buffer", 0);
-  }
-
-  if (__predict_false(count > SSIZE_MAX)) {
-    __fortify_chk_fail("read: count > SSIZE_MAX", 0);
-  }
-
-  return read(fd, buf, count);
-}
diff --git a/libc/bionic/__readlink_chk.cpp b/libc/bionic/__readlink_chk.cpp
deleted file mode 100644
index f19f917..0000000
--- a/libc/bionic/__readlink_chk.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern "C" ssize_t __readlink_chk(const char* path, char* buf, size_t size, size_t buf_size) {
-  if (__predict_false(size > buf_size)) {
-    __fortify_chk_fail("readlink: prevented write past end of buffer", 0);
-  }
-
-  if (__predict_false(size > SSIZE_MAX)) {
-    __fortify_chk_fail("readlink: size > SSIZE_MAX", 0);
-  }
-
-  return readlink(path, buf, size);
-}
diff --git a/libc/bionic/__readlinkat_chk.cpp b/libc/bionic/__readlinkat_chk.cpp
deleted file mode 100644
index a11db8e..0000000
--- a/libc/bionic/__readlinkat_chk.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <unistd.h>
-#include "private/libc_logging.h"
-
-extern "C" ssize_t __readlinkat_chk(int dirfd, const char* path, char* buf, size_t size, size_t buf_size) {
-  if (__predict_false(size > buf_size)) {
-    __fortify_chk_fail("readlinkat: prevented write past end of buffer", 0);
-  }
-
-  if (__predict_false(size > SSIZE_MAX)) {
-    __fortify_chk_fail("readlinkat: size > SSIZE_MAX", 0);
-  }
-
-  return readlinkat(dirfd, path, buf, size);
-}
diff --git a/libc/bionic/__recvfrom_chk.cpp b/libc/bionic/__recvfrom_chk.cpp
deleted file mode 100644
index 9c894b0..0000000
--- a/libc/bionic/__recvfrom_chk.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <stddef.h>
-#include <sys/socket.h>
-#include "private/libc_logging.h"
-
-ssize_t __recvfrom_chk(int socket, void* buf, size_t len, size_t buflen,
-                       int flags, const struct sockaddr* src_addr,
-                       socklen_t* addrlen) {
-  if (__predict_false(len > buflen)) {
-    __fortify_chk_fail("recvfrom: prevented write past end of buffer", 0);
-  }
-
-  return recvfrom(socket, buf, len, flags, src_addr, addrlen);
-}
diff --git a/libc/bionic/__stpcpy_chk.cpp b/libc/bionic/__stpcpy_chk.cpp
deleted file mode 100644
index 3ce81ee..0000000
--- a/libc/bionic/__stpcpy_chk.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __builtin____stpcpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This stpcpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" char* __stpcpy_chk(char* dest, const char* src, size_t dest_len) {
-  // TODO: optimize so we don't scan src twice.
-  size_t src_len = strlen(src) + 1;
-  if (__predict_false(src_len > dest_len)) {
-    __fortify_chk_fail("stpcpy: prevented write past end of buffer",
-                       BIONIC_EVENT_STPCPY_BUFFER_OVERFLOW);
-  }
-
-  return stpcpy(dest, src);
-}
diff --git a/libc/bionic/__stpncpy_chk.cpp b/libc/bionic/__stpncpy_chk.cpp
deleted file mode 100644
index 6c9215c..0000000
--- a/libc/bionic/__stpncpy_chk.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __builtin____stpncpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This stpncpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" char* __stpncpy_chk(char* __restrict dest, const char* __restrict src,
-                               size_t len, size_t dest_len) {
-  if (__predict_false(len > dest_len)) {
-    __fortify_chk_fail("stpncpy: prevented write past end of buffer",
-                       BIONIC_EVENT_STPNCPY_BUFFER_OVERFLOW);
-  }
-
-  return stpncpy(dest, src, len);
-}
-
-/*
- * __stpncpy_chk2
- *
- * This is a variant of __stpncpy_chk, but it also checks to make
- * sure we don't read beyond the end of "src". The code for this is
- * based on the original version of stpncpy, but modified to check
- * how much we read from "src" at the end of the copy operation.
- */
-extern "C" char* __stpncpy_chk2(char* __restrict dst, const char* __restrict src,
-              size_t n, size_t dest_len, size_t src_len)
-{
-  if (__predict_false(n > dest_len)) {
-    __fortify_chk_fail("stpncpy: prevented write past end of buffer",
-                       BIONIC_EVENT_STPNCPY_BUFFER_OVERFLOW);
-  }
-  if (n != 0) {
-    char* d = dst;
-    const char* s = src;
-
-    do {
-      if ((*d++ = *s++) == 0) {
-        /* NUL pad the remaining n-1 bytes */
-        while (--n != 0) {
-          *d++ = 0;
-        }
-        break;
-      }
-    } while (--n != 0);
-
-    size_t s_copy_len = static_cast<size_t>(s - src);
-    if (__predict_false(s_copy_len > src_len)) {
-      __fortify_chk_fail("stpncpy: prevented read past end of buffer", 0);
-    }
-  }
-
-  return dst;
-}
diff --git a/libc/bionic/__strcat_chk.cpp b/libc/bionic/__strcat_chk.cpp
index a0ab09e..16b2327 100644
--- a/libc/bionic/__strcat_chk.cpp
+++ b/libc/bionic/__strcat_chk.cpp
@@ -27,33 +27,22 @@
  */
 
 #include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
 
-/*
- * Runtime implementation of __builtin____strcat_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strcat check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" char* __strcat_chk(char* __restrict dest, const char* __restrict src,
-                              size_t dest_buf_size) {
-  char* save = dest;
-  size_t dest_len = __strlen_chk(dest, dest_buf_size);
+#include "private/bionic_fortify.h"
 
-  dest += dest_len;
-  dest_buf_size -= dest_len;
+// Runtime implementation of __builtin____strcat_chk (used directly by compiler, not in headers).
+extern "C" char* __strcat_chk(char* __restrict dst, const char* __restrict src,
+                              size_t dst_buf_size) {
+  char* save = dst;
+  size_t dst_len = __strlen_chk(dst, dst_buf_size);
 
-  while ((*dest++ = *src++) != '\0') {
-    dest_buf_size--;
-    if (__predict_false(dest_buf_size == 0)) {
-      __fortify_chk_fail("strcat: prevented write past end of buffer",
-                         BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW);
+  dst += dst_len;
+  dst_buf_size -= dst_len;
+
+  while ((*dst++ = *src++) != '\0') {
+    dst_buf_size--;
+    if (__predict_false(dst_buf_size == 0)) {
+      __fortify_fatal("strcat: prevented write past end of %zu-byte buffer", dst_buf_size);
     }
   }
 
diff --git a/libc/bionic/__strchr_chk.cpp b/libc/bionic/__strchr_chk.cpp
deleted file mode 100644
index 03b6b30..0000000
--- a/libc/bionic/__strchr_chk.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include "private/libc_logging.h"
-
-extern "C" char* __strchr_chk(const char* p, int ch, size_t s_len) {
-  for (;; ++p, s_len--) {
-    if (__predict_false(s_len == 0)) {
-      __fortify_chk_fail("strchr: prevented read past end of buffer", 0);
-    }
-    if (*p == static_cast<char>(ch)) {
-      return const_cast<char*>(p);
-    }
-    if (*p == '\0') {
-      return NULL;
-    }
-  }
-  /* NOTREACHED */
-}
diff --git a/libc/bionic/__strcpy_chk.cpp b/libc/bionic/__strcpy_chk.cpp
index ad3ef50..116fff4 100644
--- a/libc/bionic/__strcpy_chk.cpp
+++ b/libc/bionic/__strcpy_chk.cpp
@@ -29,27 +29,13 @@
 #undef _FORTIFY_SOURCE
 
 #include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
 
-/*
- * Runtime implementation of __builtin____strcpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strcpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" char* __strcpy_chk(char* dest, const char* src, size_t dest_len) {
+#include "private/bionic_fortify.h"
+
+// Runtime implementation of __builtin____strcpy_chk (used directly by compiler, not in headers).
+extern "C" char* __strcpy_chk(char* dst, const char* src, size_t dst_len) {
   // TODO: optimize so we don't scan src twice.
   size_t src_len = strlen(src) + 1;
-  if (__predict_false(src_len > dest_len)) {
-    __fortify_chk_fail("strcpy: prevented write past end of buffer",
-                       BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW);
-  }
-
-  return strcpy(dest, src);
+  __check_buffer_access("strcpy", "write into", src_len, dst_len);
+  return strcpy(dst, src);
 }
diff --git a/libc/bionic/__strlcat_chk.cpp b/libc/bionic/__strlcat_chk.cpp
deleted file mode 100644
index 2b7373b..0000000
--- a/libc/bionic/__strlcat_chk.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * __strlcat_chk. Called in place of strlcat() when we know the
- * size of the buffer we're writing into.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strlcat check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" size_t __strlcat_chk(char* dest, const char* src,
-                                size_t supplied_size, size_t dest_len_from_compiler) {
-  if (__predict_false(supplied_size > dest_len_from_compiler)) {
-    __fortify_chk_fail("strlcat: prevented write past end of buffer", 0);
-  }
-
-  return strlcat(dest, src, supplied_size);
-}
diff --git a/libc/bionic/__strlcpy_chk.cpp b/libc/bionic/__strlcpy_chk.cpp
deleted file mode 100644
index 6b21879..0000000
--- a/libc/bionic/__strlcpy_chk.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * __strlcpy_chk. Called in place of strlcpy() when we know the
- * size of the buffer we're writing into.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strlcpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" size_t __strlcpy_chk(char* dest, const char* src,
-                                size_t supplied_size, size_t dest_len_from_compiler) {
-  if (__predict_false(supplied_size > dest_len_from_compiler)) {
-    __fortify_chk_fail("strlcpy: prevented write past end of buffer", 0);
-  }
-
-  return strlcpy(dest, src, supplied_size);
-}
diff --git a/libc/bionic/__strlen_chk.cpp b/libc/bionic/__strlen_chk.cpp
deleted file mode 100644
index a67e15e..0000000
--- a/libc/bionic/__strlen_chk.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __strlen_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strlen check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- *
- * This test is designed to detect code such as:
- *
- * int main() {
- *   char buf[10];
- *   memcpy(buf, "1234567890", sizeof(buf));
- *   size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE
- *   printf("%d\n", len);
- *   return 0;
- * }
- *
- * or anytime strlen reads beyond an object boundary.
- */
-extern "C" size_t __strlen_chk(const char* s, size_t s_len) {
-  size_t ret = strlen(s);
-
-  if (__predict_false(ret >= s_len)) {
-    __fortify_chk_fail("strlen: prevented read past end of buffer", 0);
-  }
-
-  return ret;
-}
diff --git a/libc/bionic/__strncat_chk.cpp b/libc/bionic/__strncat_chk.cpp
deleted file mode 100644
index 21e5e39..0000000
--- a/libc/bionic/__strncat_chk.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __builtin____strncat_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strncat check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" char* __strncat_chk(char* __restrict dest, const char* __restrict src,
-                               size_t len, size_t dest_buf_size) {
-  if (len == 0) {
-    return dest;
-  }
-
-  size_t dest_len = __strlen_chk(dest, dest_buf_size);
-  char *d = dest + dest_len;
-  dest_buf_size -= dest_len;
-
-  while (*src != '\0') {
-    *d++ = *src++;
-    len--; dest_buf_size--;
-
-    if (__predict_false(dest_buf_size == 0)) {
-      __fortify_chk_fail("strncat: prevented write past end of buffer",
-                         BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
-    }
-
-    if (len == 0) {
-      break;
-    }
-  }
-
-  *d = '\0';
-  return dest;
-}
diff --git a/libc/bionic/__strncpy_chk.cpp b/libc/bionic/__strncpy_chk.cpp
deleted file mode 100644
index 9625929..0000000
--- a/libc/bionic/__strncpy_chk.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __builtin____strncpy_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This strncpy check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" char* __strncpy_chk(char* __restrict dest, const char* __restrict src,
-                               size_t len, size_t dest_len) {
-  if (__predict_false(len > dest_len)) {
-    __fortify_chk_fail("strncpy: prevented write past end of buffer",
-                       BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
-  }
-
-  return strncpy(dest, src, len);
-}
-
-/*
- * __strncpy_chk2
- *
- * This is a variant of __strncpy_chk, but it also checks to make
- * sure we don't read beyond the end of "src". The code for this is
- * based on the original version of strncpy, but modified to check
- * how much we read from "src" at the end of the copy operation.
- */
-extern "C" char* __strncpy_chk2(char* __restrict dst, const char* __restrict src,
-              size_t n, size_t dest_len, size_t src_len)
-{
-  if (__predict_false(n > dest_len)) {
-    __fortify_chk_fail("strncpy: prevented write past end of buffer",
-                       BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
-  }
-  if (n != 0) {
-    char* d = dst;
-    const char* s = src;
-
-    do {
-      if ((*d++ = *s++) == 0) {
-        /* NUL pad the remaining n-1 bytes */
-        while (--n != 0) {
-          *d++ = 0;
-        }
-        break;
-      }
-    } while (--n != 0);
-
-    size_t s_copy_len = static_cast<size_t>(s - src);
-    if (__predict_false(s_copy_len > src_len)) {
-      __fortify_chk_fail("strncpy: prevented read past end of buffer", 0);
-    }
-  }
-
-  return dst;
-}
diff --git a/libc/bionic/__strrchr_chk.cpp b/libc/bionic/__strrchr_chk.cpp
deleted file mode 100644
index 69198c0..0000000
--- a/libc/bionic/__strrchr_chk.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <string.h>
-#include "private/libc_logging.h"
-
-extern "C" char* __strrchr_chk(const char *p, int ch, size_t s_len) {
-  for (char* save = NULL;; ++p, s_len--) {
-    if (s_len == 0) {
-      __fortify_chk_fail("strrchr: prevented read past end of buffer", 0);
-    }
-    if (*p == (char) ch) {
-      save = (char *)p;
-    }
-    if (!*p) {
-      return(save);
-    }
-  }
-  /* NOTREACHED */
-}
diff --git a/libc/bionic/__umask_chk.cpp b/libc/bionic/__umask_chk.cpp
deleted file mode 100644
index 33b7121..0000000
--- a/libc/bionic/__umask_chk.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __umask_chk.
- *
- * Validate that umask is called with sane mode.
- *
- * This umask check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" mode_t __umask_chk(mode_t mode) {
-  if (__predict_false((mode & 0777) != mode)) {
-    __fortify_chk_fail("umask: called with invalid mask", 0);
-  }
-
-  return umask(mode);
-}
diff --git a/libc/bionic/__vsnprintf_chk.cpp b/libc/bionic/__vsnprintf_chk.cpp
deleted file mode 100644
index 8c09111..0000000
--- a/libc/bionic/__vsnprintf_chk.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __builtin____vsnprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This vsnprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" int __vsnprintf_chk(char* dest, size_t supplied_size, int /*flags*/,
-                               size_t dest_len_from_compiler, const char* format, va_list va) {
-  if (__predict_false(supplied_size > dest_len_from_compiler)) {
-    __fortify_chk_fail("vsnprintf: prevented write past end of buffer", 0);
-  }
-
-  return vsnprintf(dest, supplied_size, format, va);
-}
-
-/*
- * Runtime implementation of __builtin____snprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This snprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" int __snprintf_chk(char* dest, size_t supplied_size, int flags,
-                              size_t dest_len_from_compiler, const char* format, ...) {
-  va_list va;
-  va_start(va, format);
-  int result = __vsnprintf_chk(dest, supplied_size, flags, dest_len_from_compiler, format, va);
-  va_end(va);
-  return result;
-}
diff --git a/libc/bionic/__vsprintf_chk.cpp b/libc/bionic/__vsprintf_chk.cpp
deleted file mode 100644
index 5914026..0000000
--- a/libc/bionic/__vsprintf_chk.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include "private/libc_logging.h"
-
-/*
- * Runtime implementation of __builtin____vsprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This vsprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" int __vsprintf_chk(char* dest, int /*flags*/,
-                              size_t dest_len_from_compiler, const char* format, va_list va) {
-  int result = vsnprintf(dest, dest_len_from_compiler, format, va);
-  if ((size_t) result >= dest_len_from_compiler) {
-    __fortify_chk_fail("vsprintf: prevented write past end of buffer", 0);
-  }
-  return result;
-}
-
-/*
- * Runtime implementation of __builtin____sprintf_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This sprintf check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" int __sprintf_chk(char* dest, int flags,
-                             size_t dest_len_from_compiler, const char* format, ...) {
-  va_list va;
-  va_start(va, format);
-  int result = __vsprintf_chk(dest, flags, dest_len_from_compiler, format, va);
-  va_end(va);
-  return result;
-}
diff --git a/libc/bionic/bionic_netlink.cpp b/libc/bionic/bionic_netlink.cpp
index 19ca88d..f2449dc 100644
--- a/libc/bionic/bionic_netlink.cpp
+++ b/libc/bionic/bionic_netlink.cpp
@@ -61,6 +61,7 @@
   // Did we open a netlink socket yet?
   if (fd_ == -1) {
     fd_ = socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
+    if (fd_ == -1) return false;
   }
 
   // Construct and send the message.
@@ -83,7 +84,11 @@
     nlmsghdr* hdr = reinterpret_cast<nlmsghdr*>(data_);
     for (; NLMSG_OK(hdr, static_cast<size_t>(bytes_read)); hdr = NLMSG_NEXT(hdr, bytes_read)) {
       if (hdr->nlmsg_type == NLMSG_DONE) return true;
-      if (hdr->nlmsg_type == NLMSG_ERROR) return false;
+      if (hdr->nlmsg_type == NLMSG_ERROR) {
+        nlmsgerr* err = reinterpret_cast<nlmsgerr*>(NLMSG_DATA(hdr));
+        errno = (hdr->nlmsg_len >= NLMSG_LENGTH(sizeof(nlmsgerr))) ? -err->error : EIO;
+        return false;
+      }
       callback(context, hdr);
     }
   }
diff --git a/libc/bionic/bionic_netlink.h b/libc/bionic/bionic_netlink.h
index 4b103f3..bc0e3f0 100644
--- a/libc/bionic/bionic_netlink.h
+++ b/libc/bionic/bionic_netlink.h
@@ -50,10 +50,4 @@
   size_t size_;
 };
 
-#if !defined(__clang__)
-// GCC gets confused by NLMSG_DATA and doesn't realize that the old-style
-// cast is from a system header and should be ignored.
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif
-
 #endif
diff --git a/libc/bionic/bionic_time_conversions.cpp b/libc/bionic/bionic_time_conversions.cpp
index f3ca46a..ade3a55 100644
--- a/libc/bionic/bionic_time_conversions.cpp
+++ b/libc/bionic/bionic_time_conversions.cpp
@@ -51,13 +51,3 @@
   tv.tv_sec = ts.tv_sec;
   tv.tv_usec = ts.tv_nsec / 1000;
 }
-
-void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts, clockid_t clock) {
-  clock_gettime(clock, &abs_ts);
-  abs_ts.tv_sec += ts.tv_sec;
-  abs_ts.tv_nsec += ts.tv_nsec;
-  if (abs_ts.tv_nsec >= NS_PER_S) {
-    abs_ts.tv_nsec -= NS_PER_S;
-    abs_ts.tv_sec++;
-  }
-}
diff --git a/libc/bionic/brk.cpp b/libc/bionic/brk.cpp
index 4e46193..e1a4b05 100644
--- a/libc/bionic/brk.cpp
+++ b/libc/bionic/brk.cpp
@@ -29,12 +29,14 @@
 #include <errno.h>
 #include <unistd.h>
 
-#if __LP64__
+#if defined(__LP64__)
 static void* __bionic_brk;
 #else
 void* __bionic_brk; // Accidentally exported by the NDK.
 #endif
 
+extern "C" void* __brk(void* __addr);
+
 int brk(void* end_data) {
   __bionic_brk = __brk(end_data);
   if (__bionic_brk < end_data) {
diff --git a/libc/bionic/clock.cpp b/libc/bionic/clock.cpp
index 053e9e7..fda0708 100644
--- a/libc/bionic/clock.cpp
+++ b/libc/bionic/clock.cpp
@@ -26,9 +26,9 @@
  * SUCH DAMAGE.
  */
 
-#include <time.h>
-#include <sys/sysconf.h>
 #include <sys/times.h>
+#include <time.h>
+#include <unistd.h>
 
 #include "private/bionic_constants.h"
 
diff --git a/libc/bionic/clock_getcpuclockid.cpp b/libc/bionic/clock_getcpuclockid.cpp
index 5511eb4..9ff1845 100644
--- a/libc/bionic/clock_getcpuclockid.cpp
+++ b/libc/bionic/clock_getcpuclockid.cpp
@@ -40,8 +40,7 @@
   result |= 2;
   // Bit 2: thread (set) or process (clear). Bit 2 already 0.
 
-  timespec ts;
-  if (clock_getres(result, &ts) == -1) {
+  if (clock_getres(result, nullptr) == -1) {
     return ESRCH;
   }
 
diff --git a/libc/bionic/clock_nanosleep.cpp b/libc/bionic/clock_nanosleep.cpp
index 8e2146f..eade850 100644
--- a/libc/bionic/clock_nanosleep.cpp
+++ b/libc/bionic/clock_nanosleep.cpp
@@ -33,6 +33,8 @@
 extern "C" int ___clock_nanosleep(clockid_t, int, const timespec*, timespec*);
 
 int clock_nanosleep(clockid_t clock_id, int flags, const timespec* in, timespec* out) {
+  if (clock_id == CLOCK_THREAD_CPUTIME_ID) return EINVAL;
+
   ErrnoRestorer errno_restorer;
   return (___clock_nanosleep(clock_id, flags, in, out) == 0) ? 0 : errno;
 }
diff --git a/libc/bionic/clone.cpp b/libc/bionic/clone.cpp
index 9b5c9e7..3a20aa9 100644
--- a/libc/bionic/clone.cpp
+++ b/libc/bionic/clone.cpp
@@ -38,6 +38,11 @@
 
 // Called from the __bionic_clone assembler to call the thread function then exit.
 extern "C" __LIBC_HIDDEN__ void __start_thread(int (*fn)(void*), void* arg) {
+  pthread_internal_t* self = __get_thread();
+  if (self && self->tid == -1) {
+    self->tid = syscall(__NR_gettid);
+  }
+
   int status = (*fn)(arg);
   __exit(status);
 }
@@ -47,6 +52,11 @@
   void* new_tls = NULL;
   int* child_tid = NULL;
 
+  if (fn != nullptr && child_stack == nullptr) {
+    errno = EINVAL;
+    return -1;
+  }
+
   // Extract any optional parameters required by the flags.
   va_list args;
   va_start(args, arg);
@@ -70,14 +80,40 @@
   pthread_internal_t* self = __get_thread();
   pid_t parent_pid = self->invalidate_cached_pid();
 
-  // Actually do the clone.
-  int clone_result = __bionic_clone(flags, child_stack, parent_tid, new_tls, child_tid, fn, arg);
+  // Remmber the caller's tid so that it can be restored in the parent after clone.
+  pid_t caller_tid = self->tid;
+  // Invalidate the tid before the syscall. The value is lazily cached in gettid(),
+  // and it will be updated by fork() and pthread_create(). We don't do this if
+  // we are sharing address space with the child.
+  if (!(flags & (CLONE_VM|CLONE_VFORK))) {
+    self->tid = -1;
+  }
 
-  // We're the parent, so put our known pid back in place.
-  // We leave the child without a cached pid, but:
-  // 1. pthread_create gives its children their own pthread_internal_t with the correct pid.
-  // 2. fork makes a clone system call directly.
-  // If any other cases become important, we could use a double trampoline like __pthread_start.
-  self->set_cached_pid(parent_pid);
+  // Actually do the clone.
+  int clone_result;
+  if (fn != nullptr) {
+    clone_result = __bionic_clone(flags, child_stack, parent_tid, new_tls, child_tid, fn, arg);
+  } else {
+#if defined(__x86_64__) // sys_clone's last two arguments are flipped on x86-64.
+    clone_result = syscall(__NR_clone, flags, child_stack, parent_tid, child_tid, new_tls);
+#else
+    clone_result = syscall(__NR_clone, flags, child_stack, parent_tid, new_tls, child_tid);
+#endif
+  }
+
+  if (clone_result != 0) {
+    // We're the parent, so put our known pid and tid back in place.
+    // We leave the child without a cached pid and tid, but:
+    // 1. pthread_create gives its children their own pthread_internal_t with the correct pid and tid.
+    // 2. fork uses CLONE_CHILD_SETTID to get the new pid/tid.
+    // 3. The tid is lazily fetched in gettid().
+    // If any other cases become important, we could use a double trampoline like __pthread_start.
+    self->set_cached_pid(parent_pid);
+    self->tid = caller_tid;
+  } else if (self->tid == -1) {
+    self->tid = syscall(__NR_gettid);
+    self->set_cached_pid(self->tid);
+  }
+
   return clone_result;
 }
diff --git a/libc/bionic/epoll_create.cpp b/libc/bionic/epoll_create.cpp
index 1dfafa8..74f664f 100644
--- a/libc/bionic/epoll_create.cpp
+++ b/libc/bionic/epoll_create.cpp
@@ -26,8 +26,13 @@
  * SUCH DAMAGE.
  */
 
+#include <errno.h>
 #include <sys/epoll.h>
 
-int epoll_create(int /*obsolete_size*/) {
+int epoll_create(int size) {
+  if (size <= 0) {
+    errno = EINVAL;
+    return -1;
+  }
   return epoll_create1(0);
 }
diff --git a/libc/bionic/ether_aton.c b/libc/bionic/ether_aton.c
index 6540c07..edd6b11 100644
--- a/libc/bionic/ether_aton.c
+++ b/libc/bionic/ether_aton.c
@@ -26,11 +26,11 @@
  * SUCH DAMAGE.
  */
 
+#include <net/ethernet.h>
+
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/types.h>
-#include <net/if_ether.h>
-#include <ctype.h>
 
 static inline int
 xdigit (char c) {
diff --git a/libc/bionic/ether_ntoa.c b/libc/bionic/ether_ntoa.c
index f56e48b..7c31af3 100644
--- a/libc/bionic/ether_ntoa.c
+++ b/libc/bionic/ether_ntoa.c
@@ -28,7 +28,7 @@
 
 #include <stdio.h>
 #include <sys/types.h>
-#include <net/if_ether.h>
+#include <net/ethernet.h>
 
 /*
  * Convert Ethernet address to standard hex-digits-and-colons printable form.
diff --git a/libc/bionic/exec.cpp b/libc/bionic/exec.cpp
new file mode 100644
index 0000000..c43eb90
--- /dev/null
+++ b/libc/bionic/exec.cpp
@@ -0,0 +1,166 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+extern "C" char** environ;
+
+enum ExecVariant { kIsExecL, kIsExecLE, kIsExecLP };
+
+static int __execl(const char* name, const char* argv0, ExecVariant variant, va_list ap) {
+  // Count the arguments.
+  va_list count_ap;
+  va_copy(count_ap, ap);
+  size_t n = 1;
+  while (va_arg(count_ap, char*) != nullptr) {
+    ++n;
+  }
+  va_end(count_ap);
+
+  // Construct the new argv.
+  char* argv[n + 1];
+  argv[0] = const_cast<char*>(argv0);
+  n = 1;
+  while ((argv[n] = va_arg(ap, char*)) != nullptr) {
+    ++n;
+  }
+
+  // Collect the argp too.
+  char** argp = (variant == kIsExecLE) ? va_arg(ap, char**) : environ;
+
+  va_end(ap);
+
+  return (variant == kIsExecLP) ? execvp(name, argv) : execve(name, argv, argp);
+}
+
+int execl(const char* name, const char* arg, ...) {
+  va_list ap;
+  va_start(ap, arg);
+  return __execl(name, arg, kIsExecL, ap);
+}
+
+int execle(const char* name, const char* arg, ...) {
+  va_list ap;
+  va_start(ap, arg);
+  return __execl(name, arg, kIsExecLE, ap);
+}
+
+int execlp(const char* name, const char* arg, ...) {
+  va_list ap;
+  va_start(ap, arg);
+  return __execl(name, arg, kIsExecLP, ap);
+}
+
+int execv(const char* name, char* const* argv) {
+  return execve(name, argv, environ);
+}
+
+int execvp(const char* name, char* const* argv) {
+  return execvpe(name, argv, environ);
+}
+
+static int __exec_as_script(const char* buf, char* const* argv, char* const* envp) {
+  size_t arg_count = 1;
+  while (argv[arg_count] != nullptr) ++arg_count;
+
+  const char* script_argv[arg_count + 2];
+  script_argv[0] = "sh";
+  script_argv[1] = buf;
+  memcpy(script_argv + 2, argv + 1, arg_count * sizeof(char*));
+  return execve(_PATH_BSHELL, const_cast<char**>(script_argv), envp);
+}
+
+int execvpe(const char* name, char* const* argv, char* const* envp) {
+  // Do not allow null name.
+  if (name == nullptr || *name == '\0') {
+    errno = ENOENT;
+    return -1;
+  }
+
+  // If it's an absolute or relative path name, it's easy.
+  if (strchr(name, '/') && execve(name, argv, envp) == -1) {
+    if (errno == ENOEXEC) return __exec_as_script(name, argv, envp);
+    return -1;
+  }
+
+  // Get the path we're searching.
+  const char* path = getenv("PATH");
+  if (path == nullptr) path = _PATH_DEFPATH;
+
+  // Make a writable copy.
+  size_t len = strlen(path) + 1;
+  char writable_path[len];
+  memcpy(writable_path, path, len);
+
+  bool saw_EACCES = false;
+
+  // Try each element of $PATH in turn...
+  char* strsep_buf = writable_path;
+  const char* dir;
+  while ((dir = strsep(&strsep_buf, ":"))) {
+    // It's a shell path: double, leading and trailing colons
+    // mean the current directory.
+    if (*dir == '\0') dir = const_cast<char*>(".");
+
+    size_t dir_len = strlen(dir);
+    size_t name_len = strlen(name);
+
+    char buf[dir_len + 1 + name_len + 1];
+    mempcpy(mempcpy(mempcpy(buf, dir, dir_len), "/", 1), name, name_len + 1);
+
+    execve(buf, argv, envp);
+    switch (errno) {
+    case EISDIR:
+    case ELOOP:
+    case ENAMETOOLONG:
+    case ENOENT:
+    case ENOTDIR:
+      break;
+    case ENOEXEC:
+      return __exec_as_script(buf, argv, envp);
+    case EACCES:
+      saw_EACCES = true;
+      break;
+    default:
+      return -1;
+    }
+  }
+  if (saw_EACCES) errno = EACCES;
+  return -1;
+}
diff --git a/libc/bionic/fork.cpp b/libc/bionic/fork.cpp
index 6cfc736..32ea255 100644
--- a/libc/bionic/fork.cpp
+++ b/libc/bionic/fork.cpp
@@ -31,26 +31,24 @@
 
 #include "pthread_internal.h"
 
-#define FORK_FLAGS (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD)
-
 int fork() {
   __bionic_atfork_run_prepare();
 
   pthread_internal_t* self = __get_thread();
 
-  // Remember the parent pid and invalidate the cached value while we fork.
-  pid_t parent_pid = self->invalidate_cached_pid();
-
-#if defined(__x86_64__) // sys_clone's last two arguments are flipped on x86-64.
-  int result = syscall(__NR_clone, FORK_FLAGS, NULL, NULL, &(self->tid), NULL);
-#else
-  int result = syscall(__NR_clone, FORK_FLAGS, NULL, NULL, NULL, &(self->tid));
-#endif
+  int result = clone(nullptr,
+                     nullptr,
+                     (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD),
+                     nullptr,
+                     nullptr,
+                     nullptr,
+                     &(self->tid));
   if (result == 0) {
+    // Update the cached pid, since clone() will not set it directly (as
+    // self->tid is updated by the kernel).
     self->set_cached_pid(gettid());
     __bionic_atfork_run_child();
   } else {
-    self->set_cached_pid(parent_pid);
     __bionic_atfork_run_parent();
   }
   return result;
diff --git a/libc/bionic/fortify.cpp b/libc/bionic/fortify.cpp
new file mode 100644
index 0000000..cf50664
--- /dev/null
+++ b/libc/bionic/fortify.cpp
@@ -0,0 +1,450 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#undef _FORTIFY_SOURCE
+
+#include <poll.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/cdefs.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "private/bionic_fortify.h"
+
+//
+// For more details see:
+//   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+//   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+//
+// TODO: add a link to similar clang documentation?
+//
+
+int __FD_ISSET_chk(int fd, fd_set* set, size_t set_size) {
+  __check_fd_set("FD_ISSET", fd, set_size);
+  return FD_ISSET(fd, set);
+}
+
+void __FD_CLR_chk(int fd, fd_set* set, size_t set_size) {
+  __check_fd_set("FD_CLR", fd, set_size);
+  FD_CLR(fd, set);
+}
+
+void __FD_SET_chk(int fd, fd_set* set, size_t set_size) {
+  __check_fd_set("FD_SET", fd, set_size);
+  FD_SET(fd, set);
+}
+
+char* __fgets_chk(char* dst, int supplied_size, FILE* stream, size_t dst_len_from_compiler) {
+  if (supplied_size < 0) {
+    __fortify_fatal("fgets: buffer size %d < 0", supplied_size);
+  }
+  __check_buffer_access("fgets", "write into", supplied_size, dst_len_from_compiler);
+  return fgets(dst, supplied_size, stream);
+}
+
+size_t __fread_chk(void* __restrict buf, size_t size, size_t count,
+                   FILE* __restrict stream, size_t buf_size) {
+  size_t total;
+  if (__predict_false(__size_mul_overflow(size, count, &total))) {
+    // overflow: trigger the error path in fread
+    return fread(buf, size, count, stream);
+  }
+  __check_buffer_access("fread", "write into", total, buf_size);
+  return fread(buf, size, count, stream);
+}
+
+size_t __fwrite_chk(const void* __restrict buf, size_t size, size_t count,
+                    FILE* __restrict stream, size_t buf_size) {
+  size_t total;
+  if (__predict_false(__size_mul_overflow(size, count, &total))) {
+    // overflow: trigger the error path in fwrite
+    return fwrite(buf, size, count, stream);
+  }
+  __check_buffer_access("fwrite", "read from", total, buf_size);
+  return fwrite(buf, size, count, stream);
+}
+
+extern char* __getcwd_chk(char* buf, size_t len, size_t actual_size) {
+  __check_buffer_access("getcwd", "write into", len, actual_size);
+  return getcwd(buf, len);
+}
+
+void* __memchr_chk(const void* s, int c, size_t n, size_t actual_size) {
+  __check_buffer_access("memchr", "read from", n, actual_size);
+  return memchr(s, c, n);
+}
+
+// Runtime implementation of __builtin____memmove_chk (used directly by compiler, not in headers).
+extern "C" void* __memmove_chk(void* dst, const void* src, size_t len, size_t dst_len) {
+  __check_buffer_access("memmove", "write into", len, dst_len);
+  return memmove(dst, src, len);
+}
+
+// memcpy is performance-critical enough that we have assembler __memcpy_chk implementations.
+// This function is used to give better diagnostics than we can easily do from assembler.
+extern "C" void* __memcpy_chk_fail(void* /*dst*/, const void* /*src*/, size_t count, size_t dst_len) {
+  __check_count("memcpy", "count", count);
+  __check_buffer_access("memcpy", "write into", count, dst_len);
+  abort(); // One of the above is supposed to have failed, otherwise we shouldn't have been called.
+}
+
+void* __memrchr_chk(const void* s, int c, size_t n, size_t actual_size) {
+  __check_buffer_access("memrchr", "read from", n, actual_size);
+  return memrchr(s, c, n);
+}
+
+// memset is performance-critical enough that we have assembler __memset_chk implementations.
+// This function is used to give better diagnostics than we can easily do from assembler.
+extern "C" void* __memset_chk_fail(void* /*dst*/, int /*byte*/, size_t count, size_t dst_len) {
+  __check_count("memset", "count", count);
+  __check_buffer_access("memset", "write into", count, dst_len);
+  abort(); // One of the above is supposed to have failed, otherwise we shouldn't have been called.
+}
+
+int __poll_chk(pollfd* fds, nfds_t fd_count, int timeout, size_t fds_size) {
+  __check_pollfd_array("poll", fds_size, fd_count);
+  return poll(fds, fd_count, timeout);
+}
+
+int __ppoll_chk(pollfd* fds, nfds_t fd_count, const timespec* timeout,
+                const sigset_t* mask, size_t fds_size) {
+  __check_pollfd_array("ppoll", fds_size, fd_count);
+  return ppoll(fds, fd_count, timeout, mask);
+}
+
+ssize_t __pread64_chk(int fd, void* buf, size_t count, off64_t offset, size_t buf_size) {
+  __check_count("pread64", "count", count);
+  __check_buffer_access("pread64", "write into", count, buf_size);
+  return pread64(fd, buf, count, offset);
+}
+
+ssize_t __pread_chk(int fd, void* buf, size_t count, off_t offset, size_t buf_size) {
+  __check_count("pread", "count", count);
+  __check_buffer_access("pread", "write into", count, buf_size);
+  return pread(fd, buf, count, offset);
+}
+
+ssize_t __pwrite64_chk(int fd, const void* buf, size_t count, off64_t offset,
+                                  size_t buf_size) {
+  __check_count("pwrite64", "count", count);
+  __check_buffer_access("pwrite64", "read from", count, buf_size);
+  return pwrite64(fd, buf, count, offset);
+}
+
+ssize_t __pwrite_chk(int fd, const void* buf, size_t count, off_t offset,
+                                size_t buf_size) {
+  __check_count("pwrite", "count", count);
+  __check_buffer_access("pwrite", "read from", count, buf_size);
+  return pwrite(fd, buf, count, offset);
+}
+
+ssize_t __read_chk(int fd, void* buf, size_t count, size_t buf_size) {
+  __check_count("read", "count", count);
+  __check_buffer_access("read", "write into", count, buf_size);
+  return read(fd, buf, count);
+}
+
+ssize_t __readlinkat_chk(int dirfd, const char* path, char* buf, size_t size, size_t buf_size) {
+  __check_count("readlinkat", "size", size);
+  __check_buffer_access("readlinkat", "write into", size, buf_size);
+  return readlinkat(dirfd, path, buf, size);
+}
+
+ssize_t __readlink_chk(const char* path, char* buf, size_t size, size_t buf_size) {
+  __check_count("readlink", "size", size);
+  __check_buffer_access("readlink", "write into", size, buf_size);
+  return readlink(path, buf, size);
+}
+
+ssize_t __recvfrom_chk(int socket, void* buf, size_t len, size_t buf_size,
+                       int flags, sockaddr* src_addr, socklen_t* addrlen) {
+  __check_buffer_access("recvfrom", "write into", len, buf_size);
+  return recvfrom(socket, buf, len, flags, src_addr, addrlen);
+}
+
+// Runtime implementation of __builtin____stpcpy_chk (used directly by compiler, not in headers)..
+extern "C" char* __stpcpy_chk(char* dst, const char* src, size_t dst_len) {
+  // TODO: optimize so we don't scan src twice.
+  size_t src_len = strlen(src) + 1;
+  __check_buffer_access("stpcpy", "write into", src_len, dst_len);
+  return stpcpy(dst, src);
+}
+
+// Runtime implementation of __builtin____stpncpy_chk (used directly by compiler, not in headers).
+extern "C" char* __stpncpy_chk(char* __restrict dst, const char* __restrict src,
+                               size_t len, size_t dst_len) {
+  __check_buffer_access("stpncpy", "write into", len, dst_len);
+  return stpncpy(dst, src, len);
+}
+
+// This is a variant of __stpncpy_chk, but it also checks to make
+// sure we don't read beyond the end of "src". The code for this is
+// based on the original version of stpncpy, but modified to check
+// how much we read from "src" at the end of the copy operation.
+char* __stpncpy_chk2(char* __restrict dst, const char* __restrict src,
+                     size_t n, size_t dst_len, size_t src_len) {
+  __check_buffer_access("stpncpy", "write into", n, dst_len);
+  if (n != 0) {
+    char* d = dst;
+    const char* s = src;
+
+    do {
+      if ((*d++ = *s++) == 0) {
+        // NUL pad the remaining n-1 bytes.
+        while (--n != 0) {
+          *d++ = 0;
+        }
+        break;
+      }
+    } while (--n != 0);
+
+    size_t s_copy_len = static_cast<size_t>(s - src);
+    if (__predict_false(s_copy_len > src_len)) {
+      __fortify_fatal("stpncpy: detected read past end of %zu-byte buffer", src_len);
+    }
+  }
+
+  return dst;
+}
+
+// strcat is performance-critical enough that we have assembler __strcat_chk implementations.
+// This function is used to give better diagnostics than we can easily do from assembler.
+extern "C" void __strcat_chk_fail(size_t dst_buf_size) {
+  __fortify_fatal("strcat: prevented write past end of %zu-byte buffer", dst_buf_size);
+}
+
+char* __strchr_chk(const char* p, int ch, size_t s_len) {
+  for (;; ++p, s_len--) {
+    if (__predict_false(s_len == 0)) {
+      __fortify_fatal("strchr: prevented read past end of buffer");
+    }
+    if (*p == static_cast<char>(ch)) {
+      return const_cast<char*>(p);
+    }
+    if (*p == '\0') {
+      return NULL;
+    }
+  }
+}
+
+// strcpy is performance-critical enough that we have assembler __strcpy_chk implementations.
+// This function is used to give better diagnostics than we can easily do from assembler.
+extern "C" void __strcpy_chk_fail(size_t dst_buf_size) {
+  __fortify_fatal("strcpy: prevented write past end of %zu-byte buffer", dst_buf_size);
+}
+
+size_t __strlcat_chk(char* dst, const char* src,
+                     size_t supplied_size, size_t dst_len_from_compiler) {
+  __check_buffer_access("strlcat", "write into", supplied_size, dst_len_from_compiler);
+  return strlcat(dst, src, supplied_size);
+}
+
+size_t __strlcpy_chk(char* dst, const char* src,
+                     size_t supplied_size, size_t dst_len_from_compiler) {
+  __check_buffer_access("strlcpy", "write into", supplied_size, dst_len_from_compiler);
+  return strlcpy(dst, src, supplied_size);
+}
+
+size_t __strlen_chk(const char* s, size_t s_len) {
+  // TODO: "prevented" here would be a lie because this strlen can run off the end.
+  // strlen is too important to be expensive, so we wanted to be able to call the optimized
+  // implementation, but I think we need to implement optimized assembler __strlen_chk routines.
+  size_t ret = strlen(s);
+  if (__predict_false(ret >= s_len)) {
+    __fortify_fatal("strlen: detected read past end of buffer");
+  }
+  return ret;
+}
+
+// Runtime implementation of __builtin____strncat_chk (used directly by compiler, not in headers).
+extern "C" char* __strncat_chk(char* __restrict dst, const char* __restrict src,
+                               size_t len, size_t dst_buf_size) {
+  if (len == 0) {
+    return dst;
+  }
+
+  size_t dst_len = __strlen_chk(dst, dst_buf_size);
+  char* d = dst + dst_len;
+  dst_buf_size -= dst_len;
+
+  while (*src != '\0') {
+    *d++ = *src++;
+    len--; dst_buf_size--;
+
+    if (__predict_false(dst_buf_size == 0)) {
+      __fortify_fatal("strncat: prevented write past end of buffer");
+    }
+
+    if (len == 0) {
+      break;
+    }
+  }
+
+  *d = '\0';
+  return dst;
+}
+
+// Runtime implementation of __builtin____strncpy_chk (used directly by compiler, not in headers).
+extern "C" char* __strncpy_chk(char* __restrict dst, const char* __restrict src,
+                               size_t len, size_t dst_len) {
+  __check_buffer_access("strncpy", "write into", len, dst_len);
+  return strncpy(dst, src, len);
+}
+
+// This is a variant of __strncpy_chk, but it also checks to make
+// sure we don't read beyond the end of "src". The code for this is
+// based on the original version of strncpy, but modified to check
+// how much we read from "src" at the end of the copy operation.
+char* __strncpy_chk2(char* __restrict dst, const char* __restrict src,
+                                size_t n, size_t dst_len, size_t src_len) {
+  __check_buffer_access("strncpy", "write into", n, dst_len);
+  if (n != 0) {
+    char* d = dst;
+    const char* s = src;
+
+    do {
+      if ((*d++ = *s++) == 0) {
+        // NUL pad the remaining n-1 bytes.
+        while (--n != 0) {
+          *d++ = 0;
+        }
+        break;
+      }
+    } while (--n != 0);
+
+    size_t s_copy_len = static_cast<size_t>(s - src);
+    if (__predict_false(s_copy_len > src_len)) {
+      __fortify_fatal("strncpy: detected read past end of %zu-byte buffer", src_len);
+    }
+  }
+
+  return dst;
+}
+
+char* __strrchr_chk(const char* p, int ch, size_t s_len) {
+  for (const char* save = NULL;; ++p, s_len--) {
+    if (s_len == 0) {
+      __fortify_fatal("strrchr: prevented read past end of buffer");
+    }
+    if (*p == static_cast<char>(ch)) {
+      save = p;
+    }
+    if (!*p) {
+      return const_cast<char*>(save);
+    }
+  }
+}
+
+mode_t __umask_chk(mode_t mode) {
+  if (__predict_false((mode & 0777) != mode)) {
+    __fortify_fatal("umask: called with invalid mask %o", mode);
+  }
+
+  return umask(mode);
+}
+
+// Runtime implementation of __builtin____vsnprintf_chk (used directly by compiler, not in headers).
+extern "C" int __vsnprintf_chk(char* dst, size_t supplied_size, int /*flags*/,
+                               size_t dst_len_from_compiler, const char* format, va_list va) {
+  __check_buffer_access("vsnprintf", "write into", supplied_size, dst_len_from_compiler);
+  return vsnprintf(dst, supplied_size, format, va);
+}
+
+// Runtime implementation of __builtin____snprintf_chk (used directly by compiler, not in headers).
+extern "C" int __snprintf_chk(char* dst, size_t supplied_size, int flags,
+                              size_t dst_len_from_compiler, const char* format, ...) {
+  va_list va;
+  va_start(va, format);
+  int result = __vsnprintf_chk(dst, supplied_size, flags, dst_len_from_compiler, format, va);
+  va_end(va);
+  return result;
+}
+
+// Runtime implementation of __builtin____vsprintf_chk (used directly by compiler, not in headers).
+extern "C" int __vsprintf_chk(char* dst, int /*flags*/,
+                              size_t dst_len_from_compiler, const char* format, va_list va) {
+  // The compiler uses SIZE_MAX to mean "no idea", but our vsnprintf rejects sizes that large.
+  int result = vsnprintf(dst,
+                         dst_len_from_compiler == SIZE_MAX ? SSIZE_MAX : dst_len_from_compiler,
+                         format, va);
+
+  // Try to catch failures after the fact...
+  __check_buffer_access("vsprintf", "write into", result + 1, dst_len_from_compiler);
+  return result;
+}
+
+// Runtime implementation of __builtin____sprintf_chk (used directly by compiler, not in headers).
+extern "C" int __sprintf_chk(char* dst, int flags, size_t dst_len_from_compiler,
+                             const char* format, ...) {
+  va_list va;
+  va_start(va, format);
+  int result = __vsprintf_chk(dst, flags, dst_len_from_compiler, format, va);
+  va_end(va);
+  return result;
+}
+
+ssize_t __write_chk(int fd, const void* buf, size_t count, size_t buf_size) {
+  __check_count("write", "count", count);
+  __check_buffer_access("write", "read from", count, buf_size);
+  return write(fd, buf, count);
+}
diff --git a/libc/bionic/fpclassify.cpp b/libc/bionic/fpclassify.cpp
index 21ff946..42ed3ef 100644
--- a/libc/bionic/fpclassify.cpp
+++ b/libc/bionic/fpclassify.cpp
@@ -29,7 +29,8 @@
 #include <sys/types.h>
 
 #include <math.h>
-#include <machine/ieee.h>
+
+#include "private/bionic_ieee.h"
 
 // These aren't declared in our <math.h>.
 extern "C" int __isinf(double);
@@ -112,7 +113,7 @@
 }
 __strong_alias(isnormalf, __isnormalf);
 
-#if __LP64__
+#if defined(__LP64__)
 
 // LP64 uses 128-bit long doubles.
 
diff --git a/libc/bionic/ftw.cpp b/libc/bionic/ftw.cpp
new file mode 100644
index 0000000..2123619
--- /dev/null
+++ b/libc/bionic/ftw.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+
+#include <errno.h>
+#include <fts.h>
+#include <ftw.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+static int do_nftw(const char *path,
+                   int (*ftw_fn)(const char*, const struct stat*, int),
+                   int (*nftw_fn)(const char*, const struct stat*, int, FTW*),
+                   int nfds,
+                   int nftw_flags) {
+  // TODO: nfds is currently unused.
+  if (nfds < 1) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  // Translate to fts_open options.
+  int fts_options = FTS_LOGICAL | FTS_COMFOLLOW | FTS_NOCHDIR;
+  if (nftw_fn) {
+    fts_options = FTS_COMFOLLOW | ((nftw_flags & FTW_PHYS) ? FTS_PHYSICAL : FTS_LOGICAL);
+    if (!(nftw_flags & FTW_CHDIR)) fts_options |= FTS_NOCHDIR;
+    if (nftw_flags & FTW_MOUNT) fts_options |= FTS_XDEV;
+  }
+  bool postorder = (nftw_flags & FTW_DEPTH) != 0;
+
+  // Call fts_open.
+  char* const paths[2] = { const_cast<char*>(path), nullptr };
+  FTS* fts = fts_open(paths, fts_options, nullptr);
+  if (fts == nullptr) {
+    return -1;
+  }
+
+  // Translate fts_read results into ftw/nftw callbacks.
+  int error = 0;
+  FTSENT* cur;
+  while (error == 0 && (cur = fts_read(fts)) != nullptr) {
+    int fn_flag;
+    switch (cur->fts_info) {
+      case FTS_D:
+        // In the postorder case, we'll translate FTS_DP to FTW_DP later.
+        // In the can't-access case, we'll translate FTS_DNR to FTW_DNR later.
+        if (postorder || access(cur->fts_path, R_OK) == -1) continue;
+        fn_flag = FTW_D;
+        break;
+      case FTS_DNR:
+        fn_flag = FTW_DNR;
+        break;
+      case FTS_DP:
+        if (!postorder) continue;
+        fn_flag = FTW_DP;
+        break;
+      case FTS_F:
+      case FTS_DEFAULT:
+        fn_flag = FTW_F;
+        break;
+      case FTS_NS:
+      case FTS_NSOK:
+        fn_flag = FTW_NS;
+        break;
+      case FTS_SL:
+        fn_flag = FTW_SL;
+        break;
+      case FTS_SLNONE:
+        fn_flag = (nftw_fn != nullptr) ? FTW_SLN : FTW_NS;
+        break;
+      case FTS_DC:
+        errno = ELOOP;
+        error = -1;
+        continue;
+      default:
+        error = -1;
+        continue;
+    }
+
+    // Call the appropriate function.
+    if (nftw_fn != nullptr) {
+      FTW ftw;
+      ftw.base = cur->fts_pathlen - cur->fts_namelen;
+      ftw.level = cur->fts_level;
+      error = nftw_fn(cur->fts_path, cur->fts_statp, fn_flag, &ftw);
+    } else {
+      error = ftw_fn(cur->fts_path, cur->fts_statp, fn_flag);
+    }
+  }
+
+  int saved_errno = errno;
+  if (fts_close(fts) != 0 && error == 0) {
+    error = -1;
+  } else {
+    errno = saved_errno;
+  }
+  return error;
+}
+
+int ftw(const char* path, int (*ftw_fn)(const char*, const struct stat*, int), int nfds) {
+  return do_nftw(path, ftw_fn, nullptr, nfds, 0);
+}
+
+int nftw(const char* path, int (*nftw_fn)(const char*, const struct stat*, int, FTW*),
+         int nfds, int nftw_flags) {
+  return do_nftw(path, nullptr, nftw_fn, nfds, nftw_flags);
+}
diff --git a/libc/bionic/utimes.cpp b/libc/bionic/getdomainname.cpp
similarity index 71%
rename from libc/bionic/utimes.cpp
rename to libc/bionic/getdomainname.cpp
index 0b66e6c..761a999 100644
--- a/libc/bionic/utimes.cpp
+++ b/libc/bionic/getdomainname.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,21 +27,23 @@
  */
 
 #include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/time.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/utsname.h>
 
-#include "private/bionic_time_conversions.h"
+int getdomainname(char* name, size_t len) {
+  utsname uts;
+  if (uname(&uts) == -1) return -1;
 
-int utimes(const char* path, const timeval tv[2]) {
-  timespec ts[2];
-  timespec* ts_ptr = NULL;
-  if (tv != NULL) {
-    if (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1])) {
+  // Note: getdomainname()'s behavior varies across implementations when len is
+  // too small.  bionic follows the historical libc policy of returning EINVAL,
+  // instead of glibc's policy of copying the first len bytes without a NULL
+  // terminator.
+  if (strlen(uts.domainname) >= len) {
       errno = EINVAL;
       return -1;
-    }
-    ts_ptr = ts;
   }
-  return utimensat(AT_FDCWD, path, ts_ptr, 0);
+
+  strncpy(name, uts.domainname, len);
+  return 0;
 }
diff --git a/libstdc++/include/utility b/libc/bionic/getpagesize.cpp
similarity index 85%
rename from libstdc++/include/utility
rename to libc/bionic/getpagesize.cpp
index 12044a7..3a59900 100644
--- a/libstdc++/include/utility
+++ b/libc/bionic/getpagesize.cpp
@@ -25,14 +25,11 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _CPP_UTILITY
-#define _CPP_UTILITY
 
-#pragma GCC system_header
+#include <unistd.h>
 
-#define  __STL_BEGIN_NAMESPACE  namespace std {
-#define  __STL_END_NAMESPACE    }
-
-#include <stl_pair.h>
-
-#endif /* _CPP_UTILITY */
+// Portable code should use sysconf(_SC_PAGE_SIZE) directly instead.
+int getpagesize() {
+  // We dont use sysconf(3) here because that drags in stdio, which makes static binaries fat.
+  return PAGE_SIZE;
+}
diff --git a/libc/bionic/getpid.cpp b/libc/bionic/getpid.cpp
index a3d5b35..779b147 100644
--- a/libc/bionic/getpid.cpp
+++ b/libc/bionic/getpid.cpp
@@ -35,10 +35,12 @@
 pid_t getpid() {
   pthread_internal_t* self = __get_thread();
 
-  // Do we have a valid cached pid?
-  pid_t cached_pid;
-  if (__predict_true(self->get_cached_pid(&cached_pid))) {
-    return cached_pid;
+  if (__predict_true(self)) {
+    // Do we have a valid cached pid?
+    pid_t cached_pid;
+    if (__predict_true(self->get_cached_pid(&cached_pid))) {
+      return cached_pid;
+    }
   }
 
   // We're still in the dynamic linker or we're in the middle of forking, so ask the kernel.
diff --git a/libc/bionic/gettid.cpp b/libc/bionic/gettid.cpp
index f42e36a..fe25a4d 100644
--- a/libc/bionic/gettid.cpp
+++ b/libc/bionic/gettid.cpp
@@ -31,5 +31,14 @@
 #include "pthread_internal.h"
 
 pid_t gettid() {
-  return __get_thread()->tid;
+  pthread_internal_t* self = __get_thread();
+  if (__predict_true(self)) {
+    pid_t tid = self->tid;
+    if (__predict_true(tid != -1)) {
+      return tid;
+    }
+    self->tid = syscall(__NR_gettid);
+    return self->tid;
+  }
+  return syscall(__NR_gettid);
 }
diff --git a/libc/bionic/stubs.cpp b/libc/bionic/grp_pwd.cpp
similarity index 82%
rename from libc/bionic/stubs.cpp
rename to libc/bionic/grp_pwd.cpp
index 374d015..332b2b8 100644
--- a/libc/bionic/stubs.cpp
+++ b/libc/bionic/grp_pwd.cpp
@@ -30,7 +30,6 @@
 #include <errno.h>
 #include <grp.h>
 #include <mntent.h>
-#include <netdb.h>
 #include <pthread.h>
 #include <pwd.h>
 #include <stdio.h>
@@ -55,6 +54,8 @@
   group group_;
   char* group_members_[2];
   char group_name_buffer_[32];
+  // Must be last so init_group_state can run a simple memset for the above
+  ssize_t getgrent_idx;
 };
 
 struct passwd_state_t {
@@ -62,13 +63,14 @@
   char name_buffer_[32];
   char dir_buffer_[32];
   char sh_buffer_[32];
+  ssize_t getpwent_idx;
 };
 
 static ThreadLocalBuffer<group_state_t> g_group_tls_buffer;
 static ThreadLocalBuffer<passwd_state_t> g_passwd_tls_buffer;
 
 static void init_group_state(group_state_t* state) {
-  memset(state, 0, sizeof(group_state_t));
+  memset(state, 0, sizeof(group_state_t) - sizeof(state->getgrent_idx));
   state->group_.gr_mem = state->group_members_;
 }
 
@@ -313,27 +315,34 @@
   }
 }
 
+// oem_XXXX -> uid
+//  Supported ranges:
+//   AID_OEM_RESERVED_START to AID_OEM_RESERVED_END (2900-2999)
+//   AID_OEM_RESERVED_2_START to AID_OEM_RESERVED_2_END (5000-5999)
+// Check OEM id is within range.
+static bool is_oem_id(id_t id) {
+  return (((id >= AID_OEM_RESERVED_START) && (id <= AID_OEM_RESERVED_END)) ||
+      ((id >= AID_OEM_RESERVED_2_START) && (id <= AID_OEM_RESERVED_2_END)));
+}
+
 // Translate an OEM name to the corresponding user/group id.
-// oem_XXX -> AID_OEM_RESERVED_2_START + XXX, iff XXX is within range.
 static id_t oem_id_from_name(const char* name) {
   unsigned int id;
   if (sscanf(name, "oem_%u", &id) != 1) {
     return 0;
   }
-  // Check OEM id is within range.
-  if (id > (AID_OEM_RESERVED_2_END - AID_OEM_RESERVED_2_START)) {
+  if (!is_oem_id(id)) {
     return 0;
   }
-  return AID_OEM_RESERVED_2_START + static_cast<id_t>(id);
+  return static_cast<id_t>(id);
 }
 
 static passwd* oem_id_to_passwd(uid_t uid, passwd_state_t* state) {
-  if (uid < AID_OEM_RESERVED_2_START || uid > AID_OEM_RESERVED_2_END) {
+  if (!is_oem_id(uid)) {
     return NULL;
   }
 
-  snprintf(state->name_buffer_, sizeof(state->name_buffer_), "oem_%u",
-           uid - AID_OEM_RESERVED_2_START);
+  snprintf(state->name_buffer_, sizeof(state->name_buffer_), "oem_%u", uid);
   snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/");
   snprintf(state->sh_buffer_, sizeof(state->sh_buffer_), "/system/bin/sh");
 
@@ -347,12 +356,12 @@
 }
 
 static group* oem_id_to_group(gid_t gid, group_state_t* state) {
-  if (gid < AID_OEM_RESERVED_2_START || gid > AID_OEM_RESERVED_2_END) {
+  if (!is_oem_id(gid)) {
     return NULL;
   }
 
   snprintf(state->group_name_buffer_, sizeof(state->group_name_buffer_),
-           "oem_%u", gid - AID_OEM_RESERVED_2_START);
+           "oem_%u", gid);
 
   group* gr = &state->group_;
   gr->gr_name   = state->group_name_buffer_;
@@ -461,6 +470,60 @@
   return (pw != NULL) ? pw->pw_name : NULL;
 }
 
+void setpwent() {
+  passwd_state_t* state = g_passwd_tls_buffer.get();
+  if (state) {
+    state->getpwent_idx = 0;
+  }
+}
+
+void endpwent() {
+  setpwent();
+}
+
+passwd* getpwent() {
+  passwd_state_t* state = g_passwd_tls_buffer.get();
+  if (state == NULL) {
+    return NULL;
+  }
+  if (state->getpwent_idx < 0) {
+    return NULL;
+  }
+
+  size_t start = 0;
+  ssize_t end = android_id_count;
+  if (state->getpwent_idx < end) {
+    return android_iinfo_to_passwd(state, android_ids + state->getpwent_idx++);
+  }
+
+  start = end;
+  end += AID_OEM_RESERVED_END - AID_OEM_RESERVED_START + 1;
+
+  if (state->getpwent_idx < end) {
+    return oem_id_to_passwd(
+        state->getpwent_idx++ - start + AID_OEM_RESERVED_START, state);
+  }
+
+  start = end;
+  end += AID_OEM_RESERVED_2_END - AID_OEM_RESERVED_2_START + 1;
+
+  if (state->getpwent_idx < end) {
+    return oem_id_to_passwd(
+        state->getpwent_idx++ - start + AID_OEM_RESERVED_2_START, state);
+  }
+
+  start = end;
+  end += AID_USER - AID_APP; // Do not expose higher users
+
+  if (state->getpwent_idx < end) {
+    return app_id_to_passwd(state->getpwent_idx++ - start + AID_APP, state);
+  }
+
+  // We are not reporting u1_a* and higher or we will be here forever
+  state->getpwent_idx = -1;
+  return NULL;
+}
+
 static group* getgrgid_internal(gid_t gid, group_state_t* state) {
   group* grp = android_id_to_group(state, gid);
   if (grp != NULL) {
@@ -532,28 +595,60 @@
   return getgroup_r(true, name, 0, grp, buf, buflen, result);
 }
 
-// We don't have an /etc/networks, so all inputs return NULL.
-netent* getnetbyname(const char* /*name*/) {
-  return NULL;
+void setgrent() {
+  group_state_t* state = g_group_tls_buffer.get();
+  if (state) {
+    state->getgrent_idx = 0;
+  }
 }
 
-// We don't have an /etc/networks, so all inputs return NULL.
-netent* getnetbyaddr(uint32_t /*net*/, int /*type*/) {
-  return NULL;
+void endgrent() {
+  setgrent();
 }
 
-// We don't have an /etc/protocols, so all inputs return NULL.
-protoent* getprotobyname(const char* /*name*/) {
-  return NULL;
-}
+group* getgrent() {
+  group_state_t* state = g_group_tls_buffer.get();
+  if (state == NULL) {
+    return NULL;
+  }
+  if (state->getgrent_idx < 0) {
+    return NULL;
+  }
 
-// We don't have an /etc/protocols, so all inputs return NULL.
-protoent* getprotobynumber(int /*proto*/) {
-  return NULL;
-}
+  size_t start = 0;
+  ssize_t end = android_id_count;
+  if (state->getgrent_idx < end) {
+    init_group_state(state);
+    return android_iinfo_to_group(state, android_ids + state->getgrent_idx++);
+  }
 
-// Portable code should use sysconf(_SC_PAGE_SIZE) directly instead.
-int getpagesize() {
-  // We dont use sysconf(3) here because that drags in stdio, which makes static binaries fat.
-  return PAGE_SIZE;
+  start = end;
+  end += AID_OEM_RESERVED_END - AID_OEM_RESERVED_START + 1;
+
+  if (state->getgrent_idx < end) {
+    init_group_state(state);
+    return oem_id_to_group(
+        state->getgrent_idx++ - start + AID_OEM_RESERVED_START, state);
+  }
+
+  start = end;
+  end += AID_OEM_RESERVED_2_END - AID_OEM_RESERVED_2_START + 1;
+
+  if (state->getgrent_idx < end) {
+    init_group_state(state);
+    return oem_id_to_group(
+        state->getgrent_idx++ - start + AID_OEM_RESERVED_2_START, state);
+  }
+
+  start = end;
+  end += AID_USER - AID_APP; // Do not expose higher groups
+
+  if (state->getgrent_idx < end) {
+    init_group_state(state);
+    return app_id_to_group(state->getgrent_idx++ - start + AID_APP, state);
+  }
+
+  // We are not reporting u1_a* and higher or we will be here forever
+  state->getgrent_idx = -1;
+  return NULL;
 }
diff --git a/libc/bionic/ifaddrs.cpp b/libc/bionic/ifaddrs.cpp
index 408949c..f5b080c 100644
--- a/libc/bionic/ifaddrs.cpp
+++ b/libc/bionic/ifaddrs.cpp
@@ -59,7 +59,7 @@
   sockaddr_storage ifa_ifu;
   char name[IFNAMSIZ + 1];
 
-  ifaddrs_storage(ifaddrs** list) {
+  explicit ifaddrs_storage(ifaddrs** list) {
     memset(this, 0, sizeof(*this));
 
     // push_front onto `list`.
diff --git a/libc/bionic/legacy_32_bit_support.cpp b/libc/bionic/legacy_32_bit_support.cpp
index f2bb37d..983fb32 100644
--- a/libc/bionic/legacy_32_bit_support.cpp
+++ b/libc/bionic/legacy_32_bit_support.cpp
@@ -37,7 +37,7 @@
 #include <sys/vfs.h>
 #include <unistd.h>
 
-#if __LP64__
+#if defined(__LP64__)
 #error This code is only needed on 32-bit systems!
 #endif
 
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 4f1226d..e5654c3 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -41,13 +41,13 @@
 #include <sys/time.h>
 #include <unistd.h>
 
+#include "private/KernelArgumentBlock.h"
+#include "private/WriteProtected.h"
 #include "private/bionic_auxv.h"
 #include "private/bionic_globals.h"
-#include "private/bionic_ssp.h"
 #include "private/bionic_tls.h"
-#include "private/KernelArgumentBlock.h"
 #include "private/libc_logging.h"
-#include "private/WriteProtected.h"
+#include "private/thread_private.h"
 #include "pthread_internal.h"
 
 extern "C" abort_msg_t** __abort_message_ptr;
@@ -61,15 +61,6 @@
 // Declared in <unistd.h>.
 char** environ;
 
-// Declared in "private/bionic_ssp.h".
-uintptr_t __stack_chk_guard = 0;
-
-void __libc_init_global_stack_chk_guard(KernelArgumentBlock& args) {
-  // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
-  // Take the first 4/8 for the -fstack-protector implementation.
-  __stack_chk_guard = *reinterpret_cast<uintptr_t*>(args.getauxval(AT_RANDOM));
-}
-
 #if defined(__i386__)
 __LIBC_HIDDEN__ void* __libc_sysinfo = nullptr;
 
@@ -78,7 +69,7 @@
 }
 
 // TODO: lose this function and just access __libc_sysinfo directly.
-extern "C" void* __kernel_syscall() {
+__LIBC_HIDDEN__ extern "C" void* __kernel_syscall() {
   return __libc_sysinfo;
 }
 #endif
@@ -90,7 +81,6 @@
   // Initialize libc globals that are needed in both the linker and in libc.
   // In dynamic binaries, this is run at least twice for different copies of the
   // globals, once for the linker's copy and once for the one in libc.so.
-  __libc_init_global_stack_chk_guard(args);
   __libc_auxv = args.auxv;
   __libc_globals.initialize();
   __libc_globals.mutate([&args](libc_globals* globals) {
@@ -99,6 +89,20 @@
   });
 }
 
+#if !defined(__LP64__)
+static void __check_max_thread_id() {
+  if (gettid() > 65535) {
+    __libc_fatal("Limited by the size of pthread_mutex_t, 32 bit bionic libc only accepts "
+                 "pid <= 65535, but current pid is %d", gettid());
+  }
+}
+#endif
+
+static void arc4random_fork_handler() {
+  _rs_forked = 1;
+  _thread_arc4_lock();
+}
+
 void __libc_init_common(KernelArgumentBlock& args) {
   // Initialize various globals.
   environ = args.envp;
@@ -106,10 +110,17 @@
   __progname = args.argv[0] ? args.argv[0] : "<unknown>";
   __abort_message_ptr = args.abort_message_ptr;
 
+#if !defined(__LP64__)
+  __check_max_thread_id();
+#endif
+
   // Get the main thread from TLS and add it to the thread list.
   pthread_internal_t* main_thread = __get_thread();
   __pthread_internal_add(main_thread);
 
+  // Register atfork handlers to take and release the arc4random lock.
+  pthread_atfork(arc4random_fork_handler, _thread_arc4_unlock, _thread_arc4_unlock);
+
   __system_properties_init(); // Requires 'environ'.
 }
 
@@ -298,6 +309,7 @@
 
 void __libc_init_AT_SECURE(KernelArgumentBlock& args) {
   __libc_auxv = args.auxv;
+  __abort_message_ptr = args.abort_message_ptr;
 
   // Check that the kernel provided a value for AT_SECURE.
   bool found_AT_SECURE = false;
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index ab48fb8..43bca30 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -52,6 +52,7 @@
 #include "libc_init_common.h"
 
 #include "private/bionic_globals.h"
+#include "private/bionic_ssp.h"
 #include "private/bionic_tls.h"
 #include "private/KernelArgumentBlock.h"
 
@@ -74,6 +75,10 @@
   // __libc_init_common() will change the TLS area so the old one won't be accessible anyway.
   *args_slot = NULL;
 
+  // The linker has initialized its copy of the global stack_chk_guard, and filled in the main
+  // thread's TLS slot with that value. Initialize the local global stack guard with its value.
+  __stack_chk_guard = reinterpret_cast<uintptr_t>(tls[TLS_SLOT_STACK_GUARD]);
+
   __libc_init_globals(*args);
   __libc_init_common(*args);
 
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index d1494d7..5e06d39 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -39,6 +39,7 @@
 #include "libc_init_common.h"
 #include "pthread_internal.h"
 
+#include "private/bionic_globals.h"
 #include "private/bionic_page.h"
 #include "private/bionic_tls.h"
 #include "private/KernelArgumentBlock.h"
@@ -85,6 +86,7 @@
   __libc_init_main_thread(args);
 
   // Initializing the globals requires TLS to be available for errno.
+  __init_thread_stack_guard(__get_thread());
   __libc_init_globals(args);
 
   __libc_init_AT_SECURE(args);
diff --git a/libc/bionic/libc_logging.cpp b/libc/bionic/libc_logging.cpp
index fffaea8..d87944e 100644
--- a/libc/bionic/libc_logging.cpp
+++ b/libc/bionic/libc_logging.cpp
@@ -107,7 +107,7 @@
 
 struct FdOutputStream {
  public:
-  FdOutputStream(int fd) : total(0), fd_(fd) {
+  explicit FdOutputStream(int fd) : total(0), fd_(fd) {
   }
 
   void Send(const char* data, int len) {
@@ -432,11 +432,6 @@
 }
 
 static int __libc_write_stderr(const char* tag, const char* msg) {
-  int fd = TEMP_FAILURE_RETRY(open("/dev/stderr", O_CLOEXEC | O_WRONLY | O_APPEND));
-  if (fd == -1) {
-    return -1;
-  }
-
   iovec vec[4];
   vec[0].iov_base = const_cast<char*>(tag);
   vec[0].iov_len = strlen(tag);
@@ -447,8 +442,7 @@
   vec[3].iov_base = const_cast<char*>("\n");
   vec[3].iov_len = 1;
 
-  int result = TEMP_FAILURE_RETRY(writev(fd, vec, 4));
-  close(fd);
+  int result = TEMP_FAILURE_RETRY(writev(STDERR_FILENO, vec, 4));
   return result;
 }
 
@@ -459,13 +453,8 @@
   // found that all logd crashes thus far have had no problem stuffing
   // the UNIX domain socket and moving on so not critical *today*.
 
-  int log_fd = TEMP_FAILURE_RETRY(socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0));
-  if (log_fd < 0) {
-    return -1;
-  }
-
-  if (fcntl(log_fd, F_SETFL, O_NONBLOCK) == -1) {
-    close(log_fd);
+  int log_fd = TEMP_FAILURE_RETRY(socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0));
+  if (log_fd == -1) {
     return -1;
   }
 
@@ -597,57 +586,15 @@
   return result;
 }
 
-static int __libc_android_log_event(int32_t tag, char type, const void* payload, size_t len) {
-  iovec vec[6];
-  char log_id = LOG_ID_EVENTS;
-  vec[0].iov_base = &log_id;
-  vec[0].iov_len = sizeof(log_id);
-  uint16_t tid = gettid();
-  vec[1].iov_base = &tid;
-  vec[1].iov_len = sizeof(tid);
-  timespec ts;
-  clock_gettime(__android_log_clockid(), &ts);
-  log_time realtime_ts;
-  realtime_ts.tv_sec = ts.tv_sec;
-  realtime_ts.tv_nsec = ts.tv_nsec;
-  vec[2].iov_base = &realtime_ts;
-  vec[2].iov_len = sizeof(realtime_ts);
-
-  vec[3].iov_base = &tag;
-  vec[3].iov_len = sizeof(tag);
-  vec[4].iov_base = &type;
-  vec[4].iov_len = sizeof(type);
-  vec[5].iov_base = const_cast<void*>(payload);
-  vec[5].iov_len = len;
-
-  int event_log_fd = __libc_open_log_socket();
-
-  if (event_log_fd == -1) {
-    return -1;
-  }
-  int result = TEMP_FAILURE_RETRY(writev(event_log_fd, vec, sizeof(vec) / sizeof(vec[0])));
-  close(event_log_fd);
-  return result;
-}
-
-void __libc_android_log_event_int(int32_t tag, int value) {
-  __libc_android_log_event(tag, EVENT_TYPE_INT, &value, sizeof(value));
-}
-
-void __libc_android_log_event_uid(int32_t tag) {
-  __libc_android_log_event_int(tag, getuid());
-}
-
-void __fortify_chk_fail(const char* msg, uint32_t tag) {
-  if (tag != 0) {
-    __libc_android_log_event_uid(tag);
-  }
-  __libc_fatal("FORTIFY: %s", msg);
-}
-
-static void __libc_fatal(const char* format, va_list args) {
+static void __libc_fatal_va_list(const char* prefix, const char* format, va_list args) {
   char msg[1024];
   BufferOutputStream os(msg, sizeof(msg));
+
+  if (prefix) {
+    os.Send(prefix, strlen(prefix));
+    os.Send(": ", 2);
+  }
+
   out_vformat(os, format, args);
 
   // Log to stderr for the benefit of "adb shell" users.
@@ -663,17 +610,18 @@
   android_set_abort_message(msg);
 }
 
-void __libc_fatal_no_abort(const char* format, ...) {
+void __libc_fatal(const char* fmt, ...) {
   va_list args;
-  va_start(args, format);
-  __libc_fatal(format, args);
+  va_start(args, fmt);
+  __libc_fatal_va_list(nullptr, fmt, args);
   va_end(args);
+  abort();
 }
 
-void __libc_fatal(const char* format, ...) {
+void __fortify_fatal(const char* fmt, ...) {
   va_list args;
-  va_start(args, format);
-  __libc_fatal(format, args);
+  va_start(args, fmt);
+  __libc_fatal_va_list("FORTIFY", fmt, args);
   va_end(args);
   abort();
 }
diff --git a/libc/bionic/locale.cpp b/libc/bionic/locale.cpp
index b42b440..113118d 100644
--- a/libc/bionic/locale.cpp
+++ b/libc/bionic/locale.cpp
@@ -37,17 +37,18 @@
 
 #include "private/bionic_macros.h"
 
-// We currently support a single locale, the "C" locale (also known as "POSIX").
+// We only support two locales, the "C" locale (also known as "POSIX"),
+// and the "C.UTF-8" locale (also known as "en_US.UTF-8").
 
 static bool __bionic_current_locale_is_utf8 = true;
 
 struct __locale_t {
   size_t mb_cur_max;
 
-  __locale_t(size_t mb_cur_max) : mb_cur_max(mb_cur_max) {
+  explicit __locale_t(size_t mb_cur_max) : mb_cur_max(mb_cur_max) {
   }
 
-  __locale_t(const __locale_t* other) {
+  explicit __locale_t(const __locale_t* other) {
     if (other == LC_GLOBAL_LOCALE) {
       mb_cur_max = __bionic_current_locale_is_utf8 ? 4 : 1;
     } else {
@@ -100,12 +101,16 @@
   g_locale.int_n_sign_posn = CHAR_MAX;
 }
 
-static bool __is_supported_locale(const char* locale) {
-  return (strcmp(locale, "") == 0 ||
-          strcmp(locale, "C") == 0 ||
-          strcmp(locale, "C.UTF-8") == 0 ||
-          strcmp(locale, "en_US.UTF-8") == 0 ||
-          strcmp(locale, "POSIX") == 0);
+static bool __is_supported_locale(const char* locale_name) {
+  return (strcmp(locale_name, "") == 0 ||
+          strcmp(locale_name, "C") == 0 ||
+          strcmp(locale_name, "C.UTF-8") == 0 ||
+          strcmp(locale_name, "en_US.UTF-8") == 0 ||
+          strcmp(locale_name, "POSIX") == 0);
+}
+
+static bool __is_utf8_locale(const char* locale_name) {
+  return (*locale_name == '\0' || strstr(locale_name, "UTF-8"));
 }
 
 lconv* localeconv() {
@@ -133,7 +138,7 @@
     return NULL;
   }
 
-  return new __locale_t(strstr(locale_name, "UTF-8") != NULL ? 4 : 1);
+  return new __locale_t(__is_utf8_locale(locale_name) ? 4 : 1);
 }
 
 char* setlocale(int category, const char* locale_name) {
@@ -150,7 +155,7 @@
       errno = ENOENT;
       return NULL;
     }
-    __bionic_current_locale_is_utf8 = (strstr(locale_name, "UTF-8") != NULL);
+    __bionic_current_locale_is_utf8 = __is_utf8_locale(locale_name);
   }
 
   return const_cast<char*>(__bionic_current_locale_is_utf8 ? "C.UTF-8" : "C");
@@ -192,14 +197,22 @@
   return strerror(error);
 }
 
-size_t strftime_l(char* s, size_t max, const char* format, const struct tm* tm, locale_t) {
-  return strftime(s, max, format, tm);
-}
-
 int strncasecmp_l(const char* s1, const char* s2, size_t n, locale_t) {
   return strncasecmp(s1, s2, n);
 }
 
+double strtod_l(const char* s, char** end_ptr, locale_t) {
+  return strtod(s, end_ptr);
+}
+
+float strtof_l(const char* s, char** end_ptr, locale_t) {
+  return strtof(s, end_ptr);
+}
+
+long strtol_l(const char* s, char** end_ptr, int base, locale_t) {
+  return strtol(s, end_ptr, base);
+}
+
 long double strtold_l(const char* s, char** end_ptr, locale_t) {
   return strtold(s, end_ptr);
 }
@@ -208,6 +221,10 @@
   return strtoll(s, end_ptr, base);
 }
 
+unsigned long strtoul_l(const char* s, char** end_ptr, int base, locale_t) {
+  return strtoul(s, end_ptr, base);
+}
+
 unsigned long long strtoull_l(const char* s, char** end_ptr, int base, locale_t) {
   return strtoull(s, end_ptr, base);
 }
diff --git a/libc/include/sys/utime.h b/libc/bionic/mblen.cpp
similarity index 87%
rename from libc/include/sys/utime.h
rename to libc/bionic/mblen.cpp
index 9f8810e..7def6f1 100644
--- a/libc/include/sys/utime.h
+++ b/libc/bionic/mblen.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,9 +25,11 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _SYS_UTIME_H_
-#define _SYS_UTIME_H_
 
-#include <linux/utime.h>
+#include <stdlib.h>
+#include <wchar.h>
 
-#endif /* _SYS_UTIME_H_ */
+int mblen(const char* s, size_t n) {
+  mbstate_t state = {};
+  return mbrlen(s, n, &state);
+}
diff --git a/libc/bionic/memmem.c b/libc/bionic/memmem.c
deleted file mode 100644
index e72501b..0000000
--- a/libc/bionic/memmem.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * This uses the "Not So Naive" algorithm, a very simple but
- * usually effective algorithm, see:
- * http://www-igm.univ-mlv.fr/~lecroq/string/
- */
-#include <string.h>
-
-void *memmem(const void *haystack, size_t n, const void *needle, size_t m)
-{
-    if (m > n || !m || !n)
-        return NULL;
-
-    if (__builtin_expect((m > 1), 1)) {
-        const unsigned char*  y = (const unsigned char*) haystack;
-        const unsigned char*  x = (const unsigned char*) needle;
-        size_t                j = 0;
-        size_t                k = 1, l = 2;
-
-        if (x[0] == x[1]) {
-            k = 2;
-            l = 1;
-        }
-        while (j <= n-m) {
-            if (x[1] != y[j+1]) {
-                j += k;
-            } else {
-                if (!memcmp(x+2, y+j+2, m-2) && x[0] == y[j])
-                    return (void*) &y[j];
-                j += l;
-            }
-        }
-    } else {
-        /* degenerate case */
-        return memchr(haystack, ((unsigned char*)needle)[0], n);
-    }
-    return NULL;
-}
diff --git a/libc/bionic/memmem.cpp b/libc/bionic/memmem.cpp
new file mode 100644
index 0000000..61d681f
--- /dev/null
+++ b/libc/bionic/memmem.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+void* memmem(const void* void_haystack, size_t n, const void* void_needle, size_t m) {
+  const unsigned char* haystack = reinterpret_cast<const unsigned char*>(void_haystack);
+  const unsigned char* needle = reinterpret_cast<const unsigned char*>(void_needle);
+
+  if (n < m) return nullptr;
+
+  if (m == 0) return const_cast<void*>(void_haystack);
+  if (m == 1) return memchr(haystack, needle[0], n);
+
+  // This uses the "Not So Naive" algorithm, a very simple but usually effective algorithm.
+  // http://www-igm.univ-mlv.fr/~lecroq/string/
+  const unsigned char* y = haystack;
+  const unsigned char* x = needle;
+  size_t j = 0;
+  size_t k = 1, l = 2;
+
+  if (x[0] == x[1]) {
+    k = 2;
+    l = 1;
+  }
+  while (j <= n-m) {
+    if (x[1] != y[j+1]) {
+      j += k;
+    } else {
+      if (!memcmp(x+2, y+j+2, m-2) && x[0] == y[j]) return const_cast<unsigned char*>(&y[j]);
+      j += l;
+    }
+  }
+  return nullptr;
+}
diff --git a/libc/bionic/mntent.cpp b/libc/bionic/mntent.cpp
index d169e29..994b84d 100644
--- a/libc/bionic/mntent.cpp
+++ b/libc/bionic/mntent.cpp
@@ -77,3 +77,24 @@
   }
   return 1;
 }
+
+char* hasmntopt(const struct mntent* mnt, const char* opt) {
+  char* token = mnt->mnt_opts;
+  char* const end = mnt->mnt_opts + strlen(mnt->mnt_opts);
+  const size_t optLen = strlen(opt);
+
+  while (token) {
+    char* const tokenEnd = token + optLen;
+    if (tokenEnd > end) break;
+
+    if (memcmp(token, opt, optLen) == 0 &&
+        (*tokenEnd == '\0' || *tokenEnd == ',' || *tokenEnd == '=')) {
+      return token;
+    }
+
+    token = strchr(token, ',');
+    if (token) token++;
+  }
+
+  return nullptr;
+}
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 3ac88f8..c042f9f 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -45,12 +45,13 @@
 #include <unistd.h>
 #include <wchar.h>
 
+#include "private/bionic_macros.h"
 #include "private/libc_logging.h"
 
 extern "C" {
 
-// Brillo and LP64 don't need to support any legacy cruft.
-#if !defined(__BRILLO__) && !defined(__LP64__)
+// LP64 doesn't need to support any legacy cruft.
+#if !defined(__LP64__)
 
 // These were accidentally declared in <unistd.h> because we stupidly used to inline
 // getpagesize() and __getpageshift(). Needed for backwards compatibility with old NDK apps.
@@ -240,15 +241,17 @@
   return signal(signum, handler);
 }
 
-#if !defined(__i386__)
 // This was removed from POSIX 2008.
 #undef bcopy
 void bcopy(const void* src, void* dst, size_t n) {
   memmove(dst, src, n);
 }
-#else
-// x86 has an assembler implementation.
-#endif
+
+// This was removed from POSIX 2008.
+#undef bzero
+void bzero(void* dst, size_t n) {
+  memset(dst, 0, n);
+}
 
 // sysv_signal() was never in POSIX.
 extern "C++" sighandler_t _signal(int signum, sighandler_t handler, int flags);
@@ -364,10 +367,6 @@
   return __set_errno_internal(n);
 }
 
-// This was never implemented in bionic, only needed for ABI compatibility with the NDK.
-// In the M time frame, over 1000 apps have a reference to this!
-void endpwent() { }
-
 // Since dlmalloc_inspect_all and dlmalloc_trim are exported for systems
 // that use dlmalloc, be consistent and export them everywhere.
 void dlmalloc_inspect_all(void (*)(void*, void*, size_t, void*), void*) {
@@ -376,6 +375,11 @@
     return 0;
 }
 
-#endif // !defined(__BRILLO__) && !defined (__LP64__)
+// LP32's <stdio.h> had putw (but not getw).
+int putw(int value, FILE* fp) {
+    return fwrite(&value, sizeof(value), 1, fp) == 1 ? 0 : EOF;
+}
+
+#endif // !defined (__LP64__)
 
 } // extern "C"
diff --git a/libc/bionic/net_if.cpp b/libc/bionic/net_if.cpp
index f8d73bd..db9c9ea2 100644
--- a/libc/bionic/net_if.cpp
+++ b/libc/bionic/net_if.cpp
@@ -77,7 +77,7 @@
   if_list* next;
   struct if_nameindex data;
 
-  if_list(if_list** list) {
+  explicit if_list(if_list** list) {
     // push_front onto `list`.
     next = *list;
     *list = this;
diff --git a/libstdc++/include/utility b/libc/bionic/netdb.cpp
similarity index 71%
copy from libstdc++/include/utility
copy to libc/bionic/netdb.cpp
index 12044a7..da61f98 100644
--- a/libstdc++/include/utility
+++ b/libc/bionic/netdb.cpp
@@ -25,14 +25,25 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _CPP_UTILITY
-#define _CPP_UTILITY
 
-#pragma GCC system_header
+#include <netdb.h>
 
-#define  __STL_BEGIN_NAMESPACE  namespace std {
-#define  __STL_END_NAMESPACE    }
+// We don't have an /etc/networks, so all inputs return NULL.
+netent* getnetbyname(const char* /*name*/) {
+  return NULL;
+}
 
-#include <stl_pair.h>
+// We don't have an /etc/networks, so all inputs return NULL.
+netent* getnetbyaddr(uint32_t /*net*/, int /*type*/) {
+  return NULL;
+}
 
-#endif /* _CPP_UTILITY */
+// We don't have an /etc/protocols, so all inputs return NULL.
+protoent* getprotobyname(const char* /*name*/) {
+  return NULL;
+}
+
+// We don't have an /etc/protocols, so all inputs return NULL.
+protoent* getprotobynumber(int /*proto*/) {
+  return NULL;
+}
diff --git a/libc/bionic/netinet_in.cpp b/libc/bionic/netinet_in.cpp
index dfa5d8d..2a7090a 100644
--- a/libc/bionic/netinet_in.cpp
+++ b/libc/bionic/netinet_in.cpp
@@ -29,6 +29,7 @@
 #include <netinet/in.h>
 
 #include <errno.h>
+#include <netdb.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <string.h>
diff --git a/libc/bionic/new.cpp b/libc/bionic/new.cpp
index cd84c2e..76c46ee 100644
--- a/libc/bionic/new.cpp
+++ b/libc/bionic/new.cpp
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include <errno.h>
 #include <new>
+
+#include <errno.h>
 #include <stdlib.h>
 
 #include "private/libc_logging.h"
diff --git a/libstdc++/include/cerrno b/libc/bionic/nl_types.cpp
similarity index 77%
rename from libstdc++/include/cerrno
rename to libc/bionic/nl_types.cpp
index e53ca25..2cde591 100644
--- a/libstdc++/include/cerrno
+++ b/libc/bionic/nl_types.cpp
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,14 +26,20 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CERRNO__
-#define BIONIC_LIBSTDCPP_INCLUDE_CERRNO__
+#include <nl_types.h>
 
-/*
- * Standard C++ Library wrapper around the C errno.h header file.
- */
 #include <errno.h>
 
-// errno is a macro, so we can't define std::errno
+nl_catd catopen(const char*, int) {
+  return reinterpret_cast<nl_catd>(-1);
+}
 
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CERRNO__
+char* catgets(nl_catd, int, int, const char* message) {
+  return const_cast<char*>(message);
+}
+
+int catclose(nl_catd) {
+  // Since we didn't hand out a valid nl_catd, you can't be returning one to us.
+  errno = EBADF;
+  return -1;
+}
diff --git a/libc/bionic/open.cpp b/libc/bionic/open.cpp
index a6d8086..2daa21f 100644
--- a/libc/bionic/open.cpp
+++ b/libc/bionic/open.cpp
@@ -36,7 +36,7 @@
 extern "C" int __openat(int, const char*, int, int);
 
 static inline int force_O_LARGEFILE(int flags) {
-#if __LP64__
+#if defined(__LP64__)
   return flags; // No need, and aarch64's strace gets confused.
 #else
   return flags | O_LARGEFILE;
@@ -64,7 +64,7 @@
 
 int __open_2(const char* pathname, int flags) {
   if (__predict_false((flags & O_CREAT) != 0)) {
-    __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
+    __fortify_fatal("open(O_CREAT): called without specifying a mode");
   }
 
   return __openat(AT_FDCWD, pathname, force_O_LARGEFILE(flags), 0);
@@ -86,7 +86,7 @@
 
 int __openat_2(int fd, const char* pathname, int flags) {
   if ((flags & O_CREAT) != 0) {
-    __fortify_chk_fail("openat(O_CREAT): called without specifying a mode", 0);
+    __fortify_fatal("openat(O_CREAT): called without specifying a mode");
   }
 
   return __openat(fd, pathname, force_O_LARGEFILE(flags), 0);
diff --git a/libc/bionic/posix_timers.cpp b/libc/bionic/posix_timers.cpp
index c8f71c8..c46965f 100644
--- a/libc/bionic/posix_timers.cpp
+++ b/libc/bionic/posix_timers.cpp
@@ -37,7 +37,7 @@
 #include <time.h>
 
 // System calls.
-extern "C" int __rt_sigtimedwait(const sigset_t*, siginfo_t*, const struct timespec*, size_t);
+extern "C" int __rt_sigtimedwait(const sigset_t*, siginfo_t*, const timespec*, size_t);
 extern "C" int __timer_create(clockid_t, sigevent*, __kernel_timer_t*);
 extern "C" int __timer_delete(__kernel_timer_t);
 extern "C" int __timer_getoverrun(__kernel_timer_t);
diff --git a/libc/bionic/pthread_atfork.cpp b/libc/bionic/pthread_atfork.cpp
index 2200a6c..84e511c 100644
--- a/libc/bionic/pthread_atfork.cpp
+++ b/libc/bionic/pthread_atfork.cpp
@@ -130,13 +130,15 @@
 }
 
 void __bionic_atfork_run_child() {
+  g_atfork_list_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+  pthread_mutex_lock(&g_atfork_list_mutex);
   g_atfork_list.walk_forward([](atfork_t* it) {
     if (it->child != nullptr) {
       it->child();
     }
   });
-
-  g_atfork_list_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+  pthread_mutex_unlock(&g_atfork_list_mutex);
 }
 
 void __bionic_atfork_run_parent() {
diff --git a/libc/bionic/pthread_barrier.cpp b/libc/bionic/pthread_barrier.cpp
index 1bcd12a..1618222 100644
--- a/libc/bionic/pthread_barrier.cpp
+++ b/libc/bionic/pthread_barrier.cpp
@@ -42,7 +42,7 @@
   return 0;
 }
 
-int pthread_barrierattr_getpshared(pthread_barrierattr_t* attr, int* pshared) {
+int pthread_barrierattr_getpshared(const pthread_barrierattr_t* attr, int* pshared) {
   *pshared = (*attr & 1) ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE;
   return 0;
 }
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 34826db..bfa4e8c 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -44,9 +44,9 @@
 #include "private/ScopedPthreadMutexLocker.h"
 
 // x86 uses segment descriptors rather than a direct pointer to TLS.
-#if __i386__
+#if defined(__i386__)
 #include <asm/ldt.h>
-extern "C" __LIBC_HIDDEN__ void __init_user_desc(struct user_desc*, int, void*);
+void __init_user_desc(struct user_desc*, bool, void*);
 #endif
 
 extern "C" int __isthreaded;
@@ -56,6 +56,9 @@
   // Slot 0 must point to itself. The x86 Linux kernel reads the TLS from %fs:0.
   thread->tls[TLS_SLOT_SELF] = thread->tls;
   thread->tls[TLS_SLOT_THREAD_ID] = thread;
+}
+
+void __init_thread_stack_guard(pthread_internal_t* thread) {
   // GCC looks in the TLS for the stack guard on x86, so copy it there from our global.
   thread->tls[TLS_SLOT_STACK_GUARD] = reinterpret_cast<void*>(__stack_chk_guard);
 }
@@ -98,7 +101,7 @@
     sched_param param;
     param.sched_priority = thread->attr.sched_priority;
     if (sched_setscheduler(thread->tid, thread->attr.sched_policy, &param) == -1) {
-#if __LP64__
+#if defined(__LP64__)
       // For backwards compatibility reasons, we only report failures on 64-bit devices.
       error = errno;
 #endif
@@ -178,6 +181,7 @@
   thread->mmap_size = mmap_size;
   thread->attr = *attr;
   __init_tls(thread);
+  __init_thread_stack_guard(thread);
 
   *threadp = thread;
   *child_stack = stack_top;
diff --git a/libc/bionic/pthread_exit.cpp b/libc/bionic/pthread_exit.cpp
index ceda931..3401ed7 100644
--- a/libc/bionic/pthread_exit.cpp
+++ b/libc/bionic/pthread_exit.cpp
@@ -30,6 +30,7 @@
 
 #include <signal.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/mman.h>
 
 #include "pthread_internal.h"
@@ -82,7 +83,7 @@
   if (thread->alternate_signal_stack != NULL) {
     // Tell the kernel to stop using the alternate signal stack.
     stack_t ss;
-    ss.ss_sp = NULL;
+    memset(&ss, 0, sizeof(ss));
     ss.ss_flags = SS_DISABLE;
     sigaltstack(&ss, NULL);
 
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index e8be4ae..d2abea0 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -114,6 +114,7 @@
 
 __LIBC_HIDDEN__ int __init_thread(pthread_internal_t* thread);
 __LIBC_HIDDEN__ void __init_tls(pthread_internal_t* thread);
+__LIBC_HIDDEN__ void __init_thread_stack_guard(pthread_internal_t* thread);
 __LIBC_HIDDEN__ void __init_alternate_signal_stack(pthread_internal_t*);
 
 __LIBC_HIDDEN__ pthread_t           __pthread_internal_add(pthread_internal_t* thread);
@@ -123,11 +124,25 @@
 
 // Make __get_thread() inlined for performance reason. See http://b/19825434.
 static inline __always_inline pthread_internal_t* __get_thread() {
-  return reinterpret_cast<pthread_internal_t*>(__get_tls()[TLS_SLOT_THREAD_ID]);
+  void** tls = __get_tls();
+  if (__predict_true(tls)) {
+    return reinterpret_cast<pthread_internal_t*>(tls[TLS_SLOT_THREAD_ID]);
+  }
+
+  // This happens when called during libc initialization before TLS has been initialized.
+  return nullptr;
 }
 
 __LIBC_HIDDEN__ void pthread_key_clean_all(void);
 
+#if defined(__LP64__)
+// SIGSTKSZ is not big enough for 64-bit arch.
+// See https://code.google.com/p/android/issues/detail?id=187064.
+#define SIGNAL_STACK_SIZE_WITHOUT_GUARD_PAGE (16 * 1024)
+#else
+#define SIGNAL_STACK_SIZE_WITHOUT_GUARD_PAGE SIGSTKSZ
+#endif
+
 /*
  * Traditionally we gave threads a 1MiB stack. When we started
  * allocating per-thread alternate signal stacks to ease debugging of
@@ -135,15 +150,10 @@
  * from the default thread stack size. This should keep memory usage
  * roughly constant.
  */
-#define PTHREAD_STACK_SIZE_DEFAULT ((1 * 1024 * 1024) - SIGSTKSZ)
+#define PTHREAD_STACK_SIZE_DEFAULT ((1 * 1024 * 1024) - SIGNAL_STACK_SIZE_WITHOUT_GUARD_PAGE)
 
 // Leave room for a guard page in the internally created signal stacks.
-#if defined(__LP64__)
-// SIGSTKSZ is not big enough for 64-bit arch. See http://b/23041777.
-#define SIGNAL_STACK_SIZE (16 * 1024 + PAGE_SIZE)
-#else
-#define SIGNAL_STACK_SIZE (SIGSTKSZ + PAGE_SIZE)
-#endif
+#define SIGNAL_STACK_SIZE (SIGNAL_STACK_SIZE_WITHOUT_GUARD_PAGE + PAGE_SIZE)
 
 /* Needed by fork. */
 __LIBC_HIDDEN__ extern void __bionic_atfork_run_prepare();
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index 7d8e8a8..14e0ab0 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -502,6 +502,9 @@
 
 int pthread_mutex_lock(pthread_mutex_t* mutex_interface) {
 #if !defined(__LP64__)
+    // Some apps depend on being able to pass NULL as a mutex and get EINVAL
+    // back. Don't need to worry about it for LP64 since the ABI is brand new,
+    // but keep compatibility for LP32. http://b/19995172.
     if (mutex_interface == NULL) {
         return EINVAL;
     }
@@ -523,6 +526,9 @@
 
 int pthread_mutex_unlock(pthread_mutex_t* mutex_interface) {
 #if !defined(__LP64__)
+    // Some apps depend on being able to pass NULL as a mutex and get EINVAL
+    // back. Don't need to worry about it for LP64 since the ABI is brand new,
+    // but keep compatibility for LP32. http://b/19995172.
     if (mutex_interface == NULL) {
         return EINVAL;
     }
diff --git a/libc/bionic/pthread_setname_np.cpp b/libc/bionic/pthread_setname_np.cpp
index bb1114e..6d2880e 100644
--- a/libc/bionic/pthread_setname_np.cpp
+++ b/libc/bionic/pthread_setname_np.cpp
@@ -41,41 +41,69 @@
 
 // This value is not exported by kernel headers.
 #define MAX_TASK_COMM_LEN 16
-#define TASK_COMM_FMT "/proc/self/task/%d/comm"
+
+static int __open_task_comm_fd(pthread_t t, int flags) {
+  pthread_internal_t* thread = __pthread_internal_find(t);
+  if (thread == nullptr) {
+    errno = ENOENT;
+    return -1;
+  }
+
+  char comm_name[64];
+  snprintf(comm_name, sizeof(comm_name), "/proc/self/task/%d/comm", thread->tid);
+  return open(comm_name, O_CLOEXEC | flags);
+}
+
+int pthread_getname_np(pthread_t t, char* buf, size_t buf_size) {
+  ErrnoRestorer errno_restorer;
+
+  if (buf_size < MAX_TASK_COMM_LEN) return ERANGE;
+
+  // Getting our own name is an easy special case.
+  if (t == pthread_self()) {
+    return prctl(PR_GET_NAME, buf) ? errno : 0;
+  }
+
+  // We have to get another thread's name.
+  int fd = __open_task_comm_fd(t, O_RDONLY);
+  if (fd == -1) return errno;
+
+  ssize_t n = TEMP_FAILURE_RETRY(read(fd, buf, buf_size));
+  close(fd);
+
+  if (n == -1) return errno;
+
+  // The kernel adds a trailing '\n' to the /proc file,
+  // so this is actually the normal case for short names.
+  if (n > 0 && buf[n - 1] == '\n') {
+    buf[n - 1] = '\0';
+    return 0;
+  }
+
+  if (n == static_cast<ssize_t>(buf_size)) return ERANGE;
+  buf[n] = '\0';
+  return 0;
+}
 
 int pthread_setname_np(pthread_t t, const char* thread_name) {
   ErrnoRestorer errno_restorer;
 
   size_t thread_name_len = strlen(thread_name);
-  if (thread_name_len >= MAX_TASK_COMM_LEN) {
-    return ERANGE;
-  }
+  if (thread_name_len >= MAX_TASK_COMM_LEN) return ERANGE;
 
-  // Changing our own name is an easy special case.
+  // Setting our own name is an easy special case.
   if (t == pthread_self()) {
     return prctl(PR_SET_NAME, thread_name) ? errno : 0;
   }
 
-  // We have to change another thread's name.
-  pthread_internal_t* thread = __pthread_internal_find(t);
-  if (thread == NULL) {
-    return ENOENT;
-  }
-  pid_t tid = thread->tid;
+  // We have to set another thread's name.
+  int fd = __open_task_comm_fd(t, O_WRONLY);
+  if (fd == -1) return errno;
 
-  char comm_name[sizeof(TASK_COMM_FMT) + 8];
-  snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, tid);
-  int fd = open(comm_name, O_CLOEXEC | O_WRONLY);
-  if (fd == -1) {
-    return errno;
-  }
   ssize_t n = TEMP_FAILURE_RETRY(write(fd, thread_name, thread_name_len));
   close(fd);
 
-  if (n < 0) {
-    return errno;
-  } else if (n != static_cast<ssize_t>(thread_name_len)) {
-    return EIO;
-  }
+  if (n == -1) return errno;
+  if (n != static_cast<ssize_t>(thread_name_len)) return EIO;
   return 0;
 }
diff --git a/libstdc++/include/utility b/libc/bionic/sighold.cpp
similarity index 83%
copy from libstdc++/include/utility
copy to libc/bionic/sighold.cpp
index 12044a7..e9c8ca1 100644
--- a/libstdc++/include/utility
+++ b/libc/bionic/sighold.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,14 +25,12 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _CPP_UTILITY
-#define _CPP_UTILITY
 
-#pragma GCC system_header
+#include <signal.h>
 
-#define  __STL_BEGIN_NAMESPACE  namespace std {
-#define  __STL_END_NAMESPACE    }
-
-#include <stl_pair.h>
-
-#endif /* _CPP_UTILITY */
+int sighold(int sig) {
+  sigset_t set;
+  if (sigemptyset(&set) == -1) return -1;
+  if (sigaddset(&set, sig) == -1) return -1;
+  return sigprocmask(SIG_BLOCK, &set, nullptr);
+}
diff --git a/libstdc++/include/climits b/libc/bionic/sigignore.cpp
similarity index 81%
rename from libstdc++/include/climits
rename to libc/bionic/sigignore.cpp
index df85cb9..06f458e 100644
--- a/libstdc++/include/climits
+++ b/libc/bionic/sigignore.cpp
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,13 +26,13 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
-#define BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
+#include <signal.h>
+#include <string.h>
 
-/*
- * Standard C++ Library wrapper around the C limits.h header file.
- */
-
-#include <limits.h>
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
+int sigignore(int sig) {
+  struct sigaction sa;
+  memset(&sa, 0, sizeof(sa));
+  if (sigemptyset(&sa.sa_mask) == -1) return -1;
+  sa.sa_handler = SIG_IGN;
+  return sigaction(sig, &sa, nullptr);
+}
diff --git a/libstdc++/include/utility b/libc/bionic/sigpause.cpp
similarity index 83%
copy from libstdc++/include/utility
copy to libc/bionic/sigpause.cpp
index 12044a7..8ba42d4 100644
--- a/libstdc++/include/utility
+++ b/libc/bionic/sigpause.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,14 +25,12 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _CPP_UTILITY
-#define _CPP_UTILITY
 
-#pragma GCC system_header
+#include <signal.h>
 
-#define  __STL_BEGIN_NAMESPACE  namespace std {
-#define  __STL_END_NAMESPACE    }
-
-#include <stl_pair.h>
-
-#endif /* _CPP_UTILITY */
+int sigpause(int sig) {
+  sigset_t set;
+  if (sigprocmask(SIG_SETMASK, nullptr, &set) == -1) return -1;
+  if (sigdelset(&set, sig) == -1) return -1;
+  return sigsuspend(&set);
+}
diff --git a/libstdc++/include/utility b/libc/bionic/sigrelse.cpp
similarity index 83%
copy from libstdc++/include/utility
copy to libc/bionic/sigrelse.cpp
index 12044a7..ab5554e 100644
--- a/libstdc++/include/utility
+++ b/libc/bionic/sigrelse.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,14 +25,12 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _CPP_UTILITY
-#define _CPP_UTILITY
 
-#pragma GCC system_header
+#include <signal.h>
 
-#define  __STL_BEGIN_NAMESPACE  namespace std {
-#define  __STL_END_NAMESPACE    }
-
-#include <stl_pair.h>
-
-#endif /* _CPP_UTILITY */
+int sigrelse(int sig) {
+  sigset_t set;
+  if (sigemptyset(&set) == -1) return -1;
+  if (sigaddset(&set, sig) == -1) return -1;
+  return sigprocmask(SIG_UNBLOCK, &set, nullptr);
+}
diff --git a/libc/bionic/__memset_chk.cpp b/libc/bionic/sigset.cpp
similarity index 64%
rename from libc/bionic/__memset_chk.cpp
rename to libc/bionic/sigset.cpp
index 5f20452..e3f3e72 100644
--- a/libc/bionic/__memset_chk.cpp
+++ b/libc/bionic/sigset.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,28 +26,31 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
-
+#include <signal.h>
 #include <string.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
 
-/*
- * Runtime implementation of __builtin____memset_chk.
- *
- * See
- *   http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
- *   http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
- * for details.
- *
- * This memset check is called if _FORTIFY_SOURCE is defined and
- * greater than 0.
- */
-extern "C" void* __memset_chk (void* dest, int c, size_t n, size_t dest_len) {
-  if (__predict_false(n > dest_len)) {
-    __fortify_chk_fail("memset: prevented write past end of buffer",
-                       BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW);
+sighandler_t sigset(int sig, sighandler_t disp) {
+  struct sigaction new_sa;
+  if (disp != SIG_HOLD) {
+    memset(&new_sa, 0, sizeof(new_sa));
+    new_sa.sa_handler = disp;
+    sigemptyset(&new_sa.sa_mask);
   }
 
-  return memset(dest, c, n);
+  struct sigaction old_sa;
+  if (sigaction(sig, disp == SIG_HOLD ? nullptr : &new_sa, &old_sa) == -1) {
+    return SIG_ERR;
+  }
+
+  sigset_t new_proc_mask;
+  sigemptyset(&new_proc_mask);
+  sigaddset(&new_proc_mask, sig);
+
+  sigset_t old_proc_mask;
+  if (sigprocmask(disp == SIG_HOLD ? SIG_BLOCK : SIG_UNBLOCK,
+                  &new_proc_mask, &old_proc_mask) == -1) {
+    return SIG_ERR;
+  }
+
+  return sigismember(&old_proc_mask, sig) ? SIG_HOLD : old_sa.sa_handler;
 }
diff --git a/libc/bionic/sigwait.cpp b/libc/bionic/sigwait.cpp
index 873a368..2534b89 100644
--- a/libc/bionic/sigwait.cpp
+++ b/libc/bionic/sigwait.cpp
@@ -33,7 +33,7 @@
 
 #include "private/kernel_sigset_t.h"
 
-extern "C" int __rt_sigtimedwait(const sigset_t* uthese, siginfo_t* uinfo, const struct timespec* uts, size_t sigsetsize);
+extern "C" int __rt_sigtimedwait(const sigset_t*, siginfo_t*, const timespec*, size_t);
 
 int sigwait(const sigset_t* set, int* sig) {
   kernel_sigset_t sigset(set);
diff --git a/libc/bionic/statvfs.cpp b/libc/bionic/statvfs.cpp
index 39ffb64..cd825eb 100644
--- a/libc/bionic/statvfs.cpp
+++ b/libc/bionic/statvfs.cpp
@@ -20,7 +20,7 @@
 
 // Paper over the fact that 32-bit kernels use fstatfs64/statfs64 with an extra argument,
 // but 64-bit kernels don't have the "64" bit suffix or the extra size_t argument.
-#if __LP64__
+#if defined(__LP64__)
 extern "C" int __fstatfs(int, struct statfs*);
 extern "C" int __statfs(const char*, struct statfs*);
 #  define __fstatfs64(fd,size,buf) __fstatfs(fd,buf)
diff --git a/libc/bionic/strerror_r.cpp b/libc/bionic/strerror_r.cpp
index d419fb1..a0a0809 100644
--- a/libc/bionic/strerror_r.cpp
+++ b/libc/bionic/strerror_r.cpp
@@ -31,7 +31,7 @@
 
 static const Pair _sys_error_strings[] = {
 #define  __BIONIC_ERRDEF(x,y,z)  { x, z },
-#include <sys/_errdefs.h>
+#include "private/bionic_errdefs.h"
   { 0, NULL }
 };
 
@@ -41,7 +41,7 @@
 
 static const Pair _sys_signal_strings[] = {
 #define  __BIONIC_SIGDEF(signal_number, signal_description)  { signal_number, signal_description },
-#include <sys/_sigdefs.h>
+#include "private/bionic_sigdefs.h"
   { 0, NULL }
 };
 
diff --git a/libc/bionic/strtold.cpp b/libc/bionic/strtold.cpp
index 5616cf7..c55dd61 100644
--- a/libc/bionic/strtold.cpp
+++ b/libc/bionic/strtold.cpp
@@ -32,7 +32,7 @@
 extern "C" int __strtorQ(const char*, char**, int, void*);
 
 long double strtold(const char* s, char** end_ptr) {
-#if __LP64__
+#if defined(__LP64__)
   long double result;
   __strtorQ(s, end_ptr, FLT_ROUNDS, &result);
   return result;
diff --git a/libstdc++/include/cassert b/libc/bionic/sync_file_range.cpp
similarity index 75%
copy from libstdc++/include/cassert
copy to libc/bionic/sync_file_range.cpp
index 5753e34..7f60882 100644
--- a/libstdc++/include/cassert
+++ b/libc/bionic/sync_file_range.cpp
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,13 +26,15 @@
  * SUCH DAMAGE.
  */
 
-/*
- * Standard C++ Library wrapper around the C assert.h header file.  This file
- * can be included multiple times with different definition of NDEBUG, hence the
- * absence of include guards.
- */
+#include <fcntl.h>
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CASSERT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CASSERT__
+extern "C" int __sync_file_range(int, off64_t, off64_t, unsigned int);
+extern "C" int __sync_file_range2(int, unsigned int, off64_t, off64_t);
+
+int sync_file_range(int fd, off64_t offset, off64_t length, unsigned int flags) {
+#if __arm__
+  return __sync_file_range2(fd, flags, offset, length);
+#else
+  return __sync_file_range(fd, offset, length, flags);
 #endif
-#include <assert.h>
+}
diff --git a/libc/bionic/sys_msg.cpp b/libc/bionic/sys_msg.cpp
new file mode 100644
index 0000000..4880356
--- /dev/null
+++ b/libc/bionic/sys_msg.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/msg.h>
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+int msgctl(int id, int cmd, msqid_ds* buf) {
+#if !defined(__LP64__) || defined(__mips__)
+  // Annoyingly, the kernel requires this for 32-bit but rejects it for 64-bit.
+  // Mips64 is an exception to this, it requires the flag.
+  cmd |= IPC_64;
+#endif
+#if defined(SYS_msgctl)
+  return syscall(SYS_msgctl, id, cmd, buf);
+#else
+  return syscall(SYS_ipc, MSGCTL, id, cmd, 0, buf, 0);
+#endif
+}
+
+int msgget(key_t key, int flags) {
+#if defined(SYS_msgget)
+  return syscall(SYS_msgget, key, flags);
+#else
+  return syscall(SYS_ipc, MSGGET, key, flags, 0, 0, 0);
+#endif
+}
+
+ssize_t msgrcv(int id, void* msg, size_t n, long type, int flags) {
+#if defined(SYS_msgrcv)
+  return syscall(SYS_msgrcv, id, msg, n, type, flags);
+#else
+  return syscall(SYS_ipc, IPCCALL(1, MSGRCV), id, n, flags, msg, type);
+#endif
+}
+
+int msgsnd(int id, const void* msg, size_t n, int flags) {
+#if defined(SYS_msgsnd)
+  return syscall(SYS_msgsnd, id, msg, n, flags);
+#else
+  return syscall(SYS_ipc, MSGSND, id, n, flags, msg, 0);
+#endif
+}
diff --git a/libc/bionic/sys_sem.cpp b/libc/bionic/sys_sem.cpp
new file mode 100644
index 0000000..5e2a05c
--- /dev/null
+++ b/libc/bionic/sys_sem.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/sem.h>
+
+#include <stdarg.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+int semctl(int id, int num, int cmd, ...) {
+#if !defined(__LP64__) || defined(__mips__)
+  // Annoyingly, the kernel requires this for 32-bit but rejects it for 64-bit.
+  // Mips64 is an exception to this, it requires the flag.
+  cmd |= IPC_64;
+#endif
+  va_list ap;
+  va_start(ap, cmd);
+  semun arg = va_arg(ap, semun);
+  va_end(ap);
+#if defined(SYS_semctl)
+  return syscall(SYS_semctl, id, num, cmd, arg);
+#else
+  return syscall(SYS_ipc, SEMCTL, id, num, cmd, &arg, 0);
+#endif
+}
+
+int semget(key_t key, int n, int flags) {
+#if defined(SYS_semget)
+  return syscall(SYS_semget, key, n, flags);
+#else
+  return syscall(SYS_ipc, SEMGET, key, n, flags, 0, 0);
+#endif
+}
+
+int semop(int id, sembuf* ops, size_t op_count) {
+  return semtimedop(id, ops, op_count, nullptr);
+}
+
+int semtimedop(int id, sembuf* ops, size_t op_count, const timespec* ts) {
+#if defined(SYS_semtimedop)
+  return syscall(SYS_semtimedop, id, ops, op_count, ts);
+#else
+  return syscall(SYS_ipc, SEMTIMEDOP, id, op_count, 0, ops, ts);
+#endif
+}
diff --git a/libc/bionic/sys_shm.cpp b/libc/bionic/sys_shm.cpp
new file mode 100644
index 0000000..f3b26e7
--- /dev/null
+++ b/libc/bionic/sys_shm.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/shm.h>
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+void* shmat(int id, const void* address, int flags) {
+#if defined(SYS_shmat)
+  return reinterpret_cast<void*>(syscall(SYS_shmat, id, address, flags));
+#else
+  // See the kernel's ipc/syscall.c for the other side of this dance.
+  void* result = nullptr;
+  if (syscall(SYS_ipc, SHMAT, id, flags, &result, address, 0) == -1) {
+    return reinterpret_cast<void*>(-1);
+  }
+  return result;
+#endif
+}
+
+int shmctl(int id, int cmd, struct shmid_ds* buf) {
+#if !defined(__LP64__) || defined(__mips__)
+  // Annoyingly, the kernel requires this for 32-bit but rejects it for 64-bit.
+  // Mips64 is an exception to this, it requires the flag.
+  cmd |= IPC_64;
+#endif
+#if defined(SYS_shmctl)
+  return syscall(SYS_shmctl, id, cmd, buf);
+#else
+  return syscall(SYS_ipc, SHMCTL, id, cmd, 0, buf, 0);
+#endif
+}
+
+int shmdt(const void* address) {
+#if defined(SYS_shmdt)
+  return syscall(SYS_shmdt, address);
+#else
+  return syscall(SYS_ipc, SHMDT, 0, 0, 0, address, 0);
+#endif
+}
+
+int shmget(key_t key, size_t size, int flags) {
+#if defined(SYS_shmget)
+  return syscall(SYS_shmget, key, size, flags);
+#else
+  return syscall(SYS_ipc, SHMGET, key, size, flags, 0, 0);
+#endif
+}
diff --git a/libc/bionic/sys_siglist.c b/libc/bionic/sys_siglist.c
index 3cfddbf..8e33d64 100644
--- a/libc/bionic/sys_siglist.c
+++ b/libc/bionic/sys_siglist.c
@@ -30,5 +30,5 @@
 
 const char* const sys_siglist[NSIG] = {
 #define __BIONIC_SIGDEF(signal_number, signal_description) [ signal_number ] = signal_description,
-#include <sys/_sigdefs.h>
+#include "private/bionic_sigdefs.h"
 };
diff --git a/libc/bionic/sys_signame.c b/libc/bionic/sys_signame.c
index e1286f2..5158b83 100644
--- a/libc/bionic/sys_signame.c
+++ b/libc/bionic/sys_signame.c
@@ -30,5 +30,5 @@
 
 const char* const sys_signame[NSIG] = {
 #define __BIONIC_SIGDEF(signal_number, unused) [ signal_number ] = #signal_number + 3,
-#include <sys/_sigdefs.h>
+#include "private/bionic_sigdefs.h"
 };
diff --git a/libc/bionic/utimes.cpp b/libc/bionic/sys_time.cpp
similarity index 67%
copy from libc/bionic/utimes.cpp
copy to libc/bionic/sys_time.cpp
index 0b66e6c..3d0cd87 100644
--- a/libc/bionic/utimes.cpp
+++ b/libc/bionic/sys_time.cpp
@@ -26,22 +26,40 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/time.h>
+
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 
 #include "private/bionic_time_conversions.h"
 
-int utimes(const char* path, const timeval tv[2]) {
+static int futimesat(int fd, const char* path, const timeval tv[2], int flags) {
   timespec ts[2];
-  timespec* ts_ptr = NULL;
-  if (tv != NULL) {
-    if (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1])) {
-      errno = EINVAL;
-      return -1;
-    }
-    ts_ptr = ts;
+  if (tv && (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1]))) {
+    errno = EINVAL;
+    return -1;
   }
-  return utimensat(AT_FDCWD, path, ts_ptr, 0);
+  return utimensat(fd, path, tv ? ts : nullptr, flags);
+}
+
+int utimes(const char* path, const timeval tv[2]) {
+  return futimesat(AT_FDCWD, path, tv, 0);
+}
+
+int lutimes(const char* path, const timeval tv[2]) {
+  return futimesat(AT_FDCWD, path, tv, AT_SYMLINK_NOFOLLOW);
+}
+
+int futimesat(int fd, const char* path, const timeval tv[2]) {
+  return futimesat(fd, path, tv, 0);
+}
+
+int futimes(int fd, const timeval tv[2]) {
+  timespec ts[2];
+  if (tv && (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1]))) {
+    errno = EINVAL;
+    return -1;
+  }
+  return futimens(fd, tv ? ts : nullptr);
 }
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index 125b3c9..4a23fec 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -29,12 +29,11 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
-#include <linux/uio.h>  // For UIO_MAXIOV.
 #include <pthread.h>
 #include <stdio.h>  // For FOPEN_MAX.
 #include <sys/auxv.h>
+#include <sys/param.h>
 #include <sys/resource.h>
-#include <sys/sysconf.h>
 #include <sys/sysinfo.h>
 #include <time.h>
 #include <unistd.h>
@@ -49,18 +48,39 @@
 
 long sysconf(int name) {
   switch (name) {
-    case _SC_ARG_MAX:           return ARG_MAX;
+    //
+    // Things we actually have to calculate...
+    //
+    case _SC_ARG_MAX:
+      // Not a constant since Linux 2.6.23; see fs/exec.c for details.
+      // At least 32 pages, otherwise a quarter of the stack limit.
+      return MAX(__sysconf_rlimit(RLIMIT_STACK) / 4, _KERNEL_ARG_MAX);
+
+    case _SC_AVPHYS_PAGES:      return get_avphys_pages();
+    case _SC_CHILD_MAX:         return __sysconf_rlimit(RLIMIT_NPROC);
+    case _SC_CLK_TCK:           return static_cast<long>(getauxval(AT_CLKTCK));
+    case _SC_NPROCESSORS_CONF:  return get_nprocs_conf();
+    case _SC_NPROCESSORS_ONLN:  return get_nprocs();
+    case _SC_OPEN_MAX:          return __sysconf_rlimit(RLIMIT_NOFILE);
+
+    case _SC_PAGESIZE:
+    case _SC_PAGE_SIZE:
+      // _SC_PAGESIZE and _SC_PAGE_SIZE are distinct, but return the same value.
+      return static_cast<long>(getauxval(AT_PAGESZ));
+
+    case _SC_PHYS_PAGES:        return get_phys_pages();
+
+    //
+    // Constants...
+    //
     case _SC_BC_BASE_MAX:       return _POSIX2_BC_BASE_MAX;   // Minimum requirement.
     case _SC_BC_DIM_MAX:        return _POSIX2_BC_DIM_MAX;    // Minimum requirement.
     case _SC_BC_SCALE_MAX:      return _POSIX2_BC_SCALE_MAX;  // Minimum requirement.
     case _SC_BC_STRING_MAX:     return _POSIX2_BC_STRING_MAX; // Minimum requirement.
-    case _SC_CHILD_MAX:         return __sysconf_rlimit(RLIMIT_NPROC);
-    case _SC_CLK_TCK:           return static_cast<long>(getauxval(AT_CLKTCK));
     case _SC_COLL_WEIGHTS_MAX:  return _POSIX2_COLL_WEIGHTS_MAX;  // Minimum requirement.
     case _SC_EXPR_NEST_MAX:     return _POSIX2_EXPR_NEST_MAX;     // Minimum requirement.
     case _SC_LINE_MAX:          return _POSIX2_LINE_MAX;          // Minimum requirement.
     case _SC_NGROUPS_MAX:       return NGROUPS_MAX;
-    case _SC_OPEN_MAX:          return __sysconf_rlimit(RLIMIT_NOFILE);
     case _SC_PASS_MAX:          return PASS_MAX;
     case _SC_2_C_BIND:          return _POSIX2_C_BIND;
     case _SC_2_C_DEV:           return _POSIX2_C_DEV;
@@ -85,12 +105,7 @@
     case _SC_XOPEN_REALTIME_THREADS: return _XOPEN_REALTIME_THREADS;
     case _SC_XOPEN_LEGACY:      return _XOPEN_LEGACY;
     case _SC_ATEXIT_MAX:        return LONG_MAX;    // Unlimited.
-    case _SC_IOV_MAX:           return UIO_MAXIOV;
-
-    // _SC_PAGESIZE and _SC_PAGE_SIZE are distinct, but return the same value.
-    case _SC_PAGESIZE:
-    case _SC_PAGE_SIZE:
-      return static_cast<long>(getauxval(AT_PAGESZ));
+    case _SC_IOV_MAX:           return IOV_MAX;
 
     case _SC_XOPEN_UNIX:        return _XOPEN_UNIX;
     case _SC_AIO_LISTIO_MAX:    return _POSIX_AIO_LISTIO_MAX;     // Minimum requirement.
@@ -124,8 +139,8 @@
     case _SC_THREAD_DESTRUCTOR_ITERATIONS: return PTHREAD_DESTRUCTOR_ITERATIONS;
     case _SC_THREAD_KEYS_MAX:   return PTHREAD_KEYS_MAX;
     case _SC_THREAD_STACK_MIN:    return PTHREAD_STACK_MIN;
-    case _SC_THREAD_THREADS_MAX:  return PTHREAD_THREADS_MAX;
-    case _SC_TTY_NAME_MAX:        return 32;  // Seems default on linux.
+    case _SC_THREAD_THREADS_MAX:  return -1; // No specific limit.
+    case _SC_TTY_NAME_MAX:        return 32; // Seems default on linux.
     case _SC_THREADS:             return _POSIX_THREADS;
     case _SC_THREAD_ATTR_STACKADDR:   return _POSIX_THREAD_ATTR_STACKADDR;
     case _SC_THREAD_ATTR_STACKSIZE:   return _POSIX_THREAD_ATTR_STACKSIZE;
@@ -133,10 +148,6 @@
     case _SC_THREAD_PRIO_INHERIT: return _POSIX_THREAD_PRIO_INHERIT;
     case _SC_THREAD_PRIO_PROTECT: return _POSIX_THREAD_PRIO_PROTECT;
     case _SC_THREAD_SAFE_FUNCTIONS:  return _POSIX_THREAD_SAFE_FUNCTIONS;
-    case _SC_NPROCESSORS_CONF:  return get_nprocs_conf();
-    case _SC_NPROCESSORS_ONLN:  return get_nprocs();
-    case _SC_PHYS_PAGES:        return get_phys_pages();
-    case _SC_AVPHYS_PAGES:      return get_avphys_pages();
     case _SC_MONOTONIC_CLOCK:   return _POSIX_VERSION;
 
     case _SC_2_PBS:             return -1;     // Obsolescent in POSIX.1-2008.
diff --git a/libc/bionic/sysinfo.cpp b/libc/bionic/sysinfo.cpp
index 1cb5c79..304634a 100644
--- a/libc/bionic/sysinfo.cpp
+++ b/libc/bionic/sysinfo.cpp
@@ -76,29 +76,14 @@
   return cpu_count;
 }
 
-static int __get_meminfo_page_count(const char* pattern) {
-  FILE* fp = fopen("/proc/meminfo", "re");
-  if (fp == NULL) {
-    return -1;
-  }
-
-  int page_count = -1;
-  char buf[256];
-  while (fgets(buf, sizeof(buf), fp) != NULL) {
-    long total;
-    if (sscanf(buf, pattern, &total) == 1) {
-      page_count = static_cast<int>(total / (sysconf(_SC_PAGE_SIZE) / 1024));
-      break;
-    }
-  }
-  fclose(fp);
-  return page_count;
-}
-
 long get_phys_pages() {
-  return __get_meminfo_page_count("MemTotal: %ld kB");
+  struct sysinfo si;
+  sysinfo(&si);
+  return (si.totalram * si.mem_unit) / sysconf(_SC_PAGE_SIZE);
 }
 
 long get_avphys_pages() {
-  return __get_meminfo_page_count("MemFree: %ld kB");
+  struct sysinfo si;
+  sysinfo(&si);
+  return ((si.freeram + si.bufferram) * si.mem_unit) / sysconf(_SC_PAGE_SIZE);
 }
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp
index 9c992da..0f68431 100644
--- a/libc/bionic/system_properties.cpp
+++ b/libc/bionic/system_properties.cpp
@@ -192,7 +192,7 @@
     const uint32_t n;
     const prop_info *pi;
 
-    find_nth_cookie(uint32_t n) : count(0), n(n), pi(NULL) {
+    explicit find_nth_cookie(uint32_t n) : count(0), n(n), pi(NULL) {
     }
 };
 
diff --git a/libc/bionic/vdso.cpp b/libc/bionic/vdso.cpp
index 029c148..f3d95ca 100644
--- a/libc/bionic/vdso.cpp
+++ b/libc/bionic/vdso.cpp
@@ -17,7 +17,7 @@
 #include "private/bionic_globals.h"
 #include "private/bionic_vdso.h"
 
-#if defined(__aarch64__) || defined(__x86_64__) || defined (__i386__)
+#if defined(__aarch64__) || defined(__arm__) || defined(__i386__) || defined(__x86_64__)
 
 #include <limits.h>
 #include <link.h>
@@ -28,6 +28,8 @@
 #include <unistd.h>
 #include "private/KernelArgumentBlock.h"
 
+#define AT_SYSINFO_EHDR 33 /* until we have new enough uapi headers... */
+
 int clock_gettime(int clock_id, timespec* tp) {
   auto vdso_clock_gettime = reinterpret_cast<decltype(&clock_gettime)>(
     __libc_globals->vdso[VDSO_CLOCK_GETTIME].fn);
diff --git a/libc/bionic/wchar.cpp b/libc/bionic/wchar.cpp
index e0879b9..7717e10 100644
--- a/libc/bionic/wchar.cpp
+++ b/libc/bionic/wchar.cpp
@@ -61,7 +61,7 @@
   static mbstate_t __private_state;
   mbstate_t* state = (ps == NULL) ? &__private_state : ps;
 
-  // Our wchar_t is UTF-32
+  // Our wchar_t is UTF-32.
   return mbrtoc32(reinterpret_cast<char32_t*>(pwc), s, n, state);
 }
 
@@ -70,21 +70,19 @@
   mbstate_t* state = (ps == NULL) ? &__private_state : ps;
   size_t i, o, r;
 
+  // The fast paths in the loops below are not safe if an ASCII
+  // character appears as anything but the first byte of a
+  // multibyte sequence. Check now to avoid doing it in the loops.
+  if (nmc > 0 && mbstate_bytes_so_far(state) > 0 && static_cast<uint8_t>((*src)[0]) < 0x80) {
+    return reset_and_return_illegal(EILSEQ, state);
+  }
+
+  // Measure only?
   if (dst == NULL) {
-    /*
-     * The fast path in the loop below is not safe if an ASCII
-     * character appears as anything but the first byte of a
-     * multibyte sequence. Check now to avoid doing it in the loop.
-     */
-    if ((nmc > 0) && (mbstate_bytes_so_far(state) > 0)
-        && (static_cast<uint8_t>((*src)[0]) < 0x80)) {
-      return reset_and_return_illegal(EILSEQ, state);
-    }
     for (i = o = 0; i < nmc; i += r, o++) {
       if (static_cast<uint8_t>((*src)[i]) < 0x80) {
         // Fast path for plain ASCII characters.
         if ((*src)[i] == '\0') {
-          *src = nullptr;
           return reset_and_return(o, state);
         }
         r = 1;
@@ -97,7 +95,6 @@
           return reset_and_return_illegal(EILSEQ, state);
         }
         if (r == 0) {
-          *src = nullptr;
           return reset_and_return(o, state);
         }
       }
@@ -105,15 +102,7 @@
     return reset_and_return(o, state);
   }
 
-  /*
-   * The fast path in the loop below is not safe if an ASCII
-   * character appears as anything but the first byte of a
-   * multibyte sequence. Check now to avoid doing it in the loop.
-   */
-  if ((nmc > 0) && (mbstate_bytes_so_far(state) > 0)
-      && (static_cast<uint8_t>((*src)[0]) < 0x80)) {
-    return reset_and_return_illegal(EILSEQ, state);
-  }
+  // Actually convert, updating `dst` and `src`.
   for (i = o = 0; i < nmc && o < len; i += r, o++) {
     if (static_cast<uint8_t>((*src)[i]) < 0x80) {
       // Fast path for plain ASCII characters.
@@ -151,7 +140,7 @@
   static mbstate_t __private_state;
   mbstate_t* state = (ps == NULL) ? &__private_state : ps;
 
-  // Our wchar_t is UTF-32
+  // Our wchar_t is UTF-32.
   return c32rtomb(s, static_cast<char32_t>(wc), state);
 }
 
diff --git a/libc/bionic/wcstod.cpp b/libc/bionic/wcstod.cpp
new file mode 100644
index 0000000..eb66ba0
--- /dev/null
+++ b/libc/bionic/wcstod.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <wchar.h>
+
+#include <stdlib.h>
+
+#include "local.h"
+
+template <typename float_type> float_type wcstod(const wchar_t* str, wchar_t** end,
+                                                 float_type strtod_fn(const char*, char**)) {
+  // What's the longest span of the input that might be part of the float?
+  size_t max_len = wcsspn(str, L"-+0123456789.xXeEpP()nNaAiIfFtTyY");
+
+  // We know the only valid characters are ASCII, so convert them by brute force.
+  char* ascii_str = new char[max_len + 1];
+  if (!ascii_str) return float_type();
+  for (size_t i = 0; i < max_len; ++i) {
+    ascii_str[i] = str[i] & 0xff;
+  }
+  ascii_str[max_len] = 0;
+
+  // Set up a fake FILE that points to those ASCII characters, for `parsefloat`.
+  FILE f;
+  __sfileext fext;
+  _FILEEXT_SETUP(&f, &fext);
+  f._flags = __SRD;
+  f._bf._base = f._p = reinterpret_cast<unsigned char*>(ascii_str);
+  f._bf._size = f._r = max_len;
+  f._read = [](void*, char*, int) { return 0; }; // aka `eofread`, aka "no more data".
+  f._lb._base = NULL;
+
+  // Ask `parsefloat` to look at the same data more carefully.
+
+  // We can't just do this straight away because we can't construct a suitable FILE*
+  // in the absence of any `fwmemopen` analogous to `fmemopen`. And we don't want to
+  // duplicate the `parsefloat` logic. We also don't want to actually have to have wchar_t
+  // implementations of the ASCII `strtod` logic (though if you were designing a libc
+  // from scratch, you'd probably want to just make that more generic and lose all the
+  // cruft on top).
+  size_t actual_len = parsefloat(&f, ascii_str, ascii_str + max_len);
+
+  // Finally let the ASCII conversion function do the work.
+  char* ascii_end;
+  float_type result = strtod_fn(ascii_str, &ascii_end);
+  if (ascii_end != ascii_str + actual_len) abort();
+
+  if (end) *end = const_cast<wchar_t*>(str) + actual_len;
+
+  delete[] ascii_str;
+  return result;
+}
+
+float wcstof(const wchar_t* s, wchar_t** end) {
+  return wcstod<float>(s, end, strtof);
+}
+
+double wcstod(const wchar_t* s, wchar_t** end) {
+  return wcstod<double>(s, end, strtod);
+}
+
+long double wcstold(const wchar_t* s, wchar_t** end) {
+  return wcstod<long double>(s, end, strtold);
+}
diff --git a/libc/bionic/wctype.cpp b/libc/bionic/wctype.cpp
index f2d7861..05e9c90 100644
--- a/libc/bionic/wctype.cpp
+++ b/libc/bionic/wctype.cpp
@@ -26,11 +26,13 @@
  * SUCH DAMAGE.
  */
 
+#include <wctype.h>
+
 #include <ctype.h>
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
-#include <wctype.h>
 
 // TODO: these only work for the ASCII range; rewrite to dlsym icu4c? http://b/14499654
 
@@ -85,8 +87,8 @@
 wint_t towlower(wint_t wc) { return tolower(wc); }
 wint_t towupper(wint_t wc) { return toupper(wc); }
 
-int towupper_l(int c, locale_t) { return towupper(c); }
-int towlower_l(int c, locale_t) { return towlower(c); }
+wint_t towupper_l(int c, locale_t) { return towupper(c); }
+wint_t towlower_l(int c, locale_t) { return towlower(c); }
 
 wctype_t wctype(const char* property) {
   static const char* const  properties[WC_TYPE_MAX] = {
@@ -109,3 +111,27 @@
 int wcwidth(wchar_t wc) {
   return (wc > 0);
 }
+
+static wctrans_t wctrans_tolower = wctrans_t(1);
+static wctrans_t wctrans_toupper = wctrans_t(2);
+
+wctrans_t wctrans(const char* name) {
+  if (strcmp(name, "tolower") == 0) return wctrans_tolower;
+  if (strcmp(name, "toupper") == 0) return wctrans_toupper;
+  return 0;
+}
+
+wctrans_t wctrans_l(const char* name, locale_t) {
+  return wctrans(name);
+}
+
+wint_t towctrans(wint_t c, wctrans_t t) {
+  if (t == wctrans_tolower) return towlower(c);
+  if (t == wctrans_toupper) return towupper(c);
+  errno = EINVAL;
+  return 0;
+}
+
+wint_t towctrans_l(wint_t c, wctrans_t t, locale_t) {
+  return towctrans(c, t);
+}
diff --git a/libc/crt.mk b/libc/crt.mk
deleted file mode 100644
index 7b96bf2..0000000
--- a/libc/crt.mk
+++ /dev/null
@@ -1,146 +0,0 @@
-# Define the libc run-time (crt) support object files that must be built,
-# which are needed to build all other objects (shared/static libs and
-# executables)
-# ==========================================================================
-# AArch64, ARM, MIPS, and x86 all need crtbegin_so/crtend_so.
-#
-# For x86, the .init section must point to a function that calls all
-# entries in the .ctors section. (on ARM this is done through the
-# .init_array section instead).
-#
-# For all the platforms, the .fini_array section must point to a function
-# that will call __cxa_finalize(&__dso_handle) in order to ensure that
-# static C++ destructors are properly called on dlclose().
-#
-# Args:
-#     my_2nd_arch_prefix: set to $(TARGET_2ND_ARCH_VAR_PREFIX) if it's
-#                         for the 2nd arch; otherwise empty.
-
-my_arch := $(TARGET_$(my_2nd_arch_prefix)ARCH)
-
-my_libc_crt_target_crtbegin_file := $(libc_crt_target_crtbegin_file_$(my_arch))
-my_libc_crt_target_crtbegin_so_file := $(libc_crt_target_crtbegin_so_file_$(my_arch))
-
-my_libc_crt_target_cflags := \
-    $(libc_crt_target_cflags) \
-    $(libc_crt_target_cflags_$(my_arch))
-
-my_libc_crt_target_so_cflags := \
-    $(libc_crt_target_so_cflags_$(my_arch)) \
-    $(my_libc_crt_target_cflags)
-
-my_libc_crt_target_ldflags := $(libc_crt_target_ldflags_$(my_arch))
-
-# crtbrand.S -> crtbrand.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o
-$(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC)
-$(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_so_cflags)
-$(GEN): $(LOCAL_PATH)/arch-common/bionic/crtbrand.S
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
-		-MD -MF $(@:%.o=%.d) -o $@ -c $<
-	$(transform-d-to-p)
-$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
-
-# crtbegin_so.c -> crtbegin_so1.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so1.o
-$(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC)
-$(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_so_cflags)
-$(GEN): $(my_libc_crt_target_crtbegin_so_file)
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
-		-MD -MF $(@:%.o=%.d) -o $@ -c $<
-	$(transform-d-to-p)
-$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
-
-# crtbegin_so1.o + crtbrand.o -> crtbegin_so.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-$(GEN): PRIVATE_LD := $($(my_2nd_arch_prefix)TARGET_LD)
-$(GEN): PRIVATE_LDFLAGS := $(my_libc_crt_target_ldflags)
-$(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so1.o \
-    $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_LD) $(PRIVATE_LDFLAGS) -r -o $@ $^
-
-# crtend_so.S -> crtend_so.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-$(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC)
-$(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_so_cflags)
-$(GEN): $(LOCAL_PATH)/arch-common/bionic/crtend_so.S
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
-		-MD -MF $(@:%.o=%.d) -o $@ -c $<
-	$(transform-d-to-p)
-$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
-
-# crtbegin_so.o and crtend_so.o are installed to device
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_SHARED_LIBRARIES)/crtbegin_so.o
-$(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-	$(hide) mkdir -p $(dir $@) && cp -f $< $@
-ALL_GENERATED_SOURCES += $(GEN)
-
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_SHARED_LIBRARIES)/crtend_so.o
-$(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-	$(hide) mkdir -p $(dir $@) && cp -f $< $@
-ALL_GENERATED_SOURCES += $(GEN)
-
-# crtbegin.c -> crtbegin_static1.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o
-$(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC)
-$(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_cflags)
-$(GEN): $(my_libc_crt_target_crtbegin_file)
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
-		-MD -MF $(@:%.o=%.d) -o $@ -c $<
-	$(transform-d-to-p)
-$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
-
-# crtbegin_static1.o + crtbrand.o -> crtbegin_static.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
-$(GEN): PRIVATE_LD := $($(my_2nd_arch_prefix)TARGET_LD)
-$(GEN): PRIVATE_LDFLAGS := $(my_libc_crt_target_ldflags)
-$(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o \
-    $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_LD) $(PRIVATE_LDFLAGS) -r -o $@ $^
-
-# crtbegin.c -> crtbegin_dynamic1.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o
-$(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC)
-$(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_cflags)
-$(GEN): $(my_libc_crt_target_crtbegin_file)
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
-		-MD -MF $(@:%.o=%.d) -o $@ -c $<
-	$(transform-d-to-p)
-$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
-
-# crtbegin_dynamic1.o + crtbrand.o -> crtbegin_dynamic.o
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
-$(GEN): PRIVATE_LD := $($(my_2nd_arch_prefix)TARGET_LD)
-$(GEN): PRIVATE_LDFLAGS := $(my_libc_crt_target_ldflags)
-$(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o \
-    $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_LD) $(PRIVATE_LDFLAGS) -r -o $@ $^
-
-# crtend.S -> crtend_android.o
-# We rename crtend.o to crtend_android.o to avoid a
-# name clash between gcc and bionic.
-GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-$(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC)
-$(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_cflags)
-$(GEN): $(LOCAL_PATH)/arch-common/bionic/crtend.S
-	@mkdir -p $(dir $@)
-	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
-		-MD -MF $(@:%.o=%.d) -o $@ -c $<
-	$(transform-d-to-p)
-$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
-
-# Clear temp vars
-my_libc_crt_target_ldflags :=
-my_libc_crt_target_so_cflags :=
-my_libc_crt_target_cflags :=
-my_libc_crt_target_crtbegin_so_file :=
-my_libc_crt_target_crtbegin_file :=
-my_arch :=
diff --git a/libc/include/nsswitch.h b/libc/dns/include/nsswitch.h
similarity index 92%
rename from libc/include/nsswitch.h
rename to libc/dns/include/nsswitch.h
index af88433..a0ae83b 100644
--- a/libc/include/nsswitch.h
+++ b/libc/dns/include/nsswitch.h
@@ -144,19 +144,6 @@
 
 
 /*
- * Default sourcelists (if nsswitch.conf is missing, corrupt,
- * or the requested database doesn't have an entry)
- */
-extern const ns_src __nsdefaultsrc[];
-extern const ns_src __nsdefaultcompat[];
-extern const ns_src __nsdefaultcompat_forceall[];
-extern const ns_src __nsdefaultfiles[];
-extern const ns_src __nsdefaultfiles_forceall[];
-extern const ns_src __nsdefaultnis[];
-extern const ns_src __nsdefaultnis_forceall[];
-
-
-/*
  * ns_mtab - `nsswitch method table'
  * An nsswitch module provides a mapping from (database name, method name)
  * tuples to the nss_method and associated callback data.  Effectively,
@@ -215,7 +202,7 @@
 
 __BEGIN_DECLS
 int	nsdispatch(void *, const ns_dtab [], const char *,
-			const char *, const ns_src [], ...) __LIBC_ABI_PUBLIC__;
+			const char *, const ns_src [], ...);
 
 #ifdef _NS_PRIVATE
 int		 _nsdbtaddsrc(ns_dbt *, const ns_src *);
diff --git a/libc/dns/include/resolv_netid.h b/libc/dns/include/resolv_netid.h
index 266193a..7182ca6 100644
--- a/libc/dns/include/resolv_netid.h
+++ b/libc/dns/include/resolv_netid.h
@@ -101,9 +101,6 @@
 int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int, unsigned, unsigned) __LIBC_HIDDEN__;
 FILE* android_open_proxy(void) __LIBC_HIDDEN__;
 
-/* delete the cache associated with a certain network */
-extern void _resolv_delete_cache_for_net(unsigned netid);
-
 __END_DECLS
 
 #endif /* _RESOLV_NETID_H */
diff --git a/libc/dns/include/resolv_private.h b/libc/dns/include/resolv_private.h
index 3ab8ea6..54b9626 100644
--- a/libc/dns/include/resolv_private.h
+++ b/libc/dns/include/resolv_private.h
@@ -63,9 +63,6 @@
 #include <net/if.h>
 #include <time.h>
 
-/* Despite this file's name, it's part of libresolv. On Android, that means it's part of libc :-( */
-#pragma GCC visibility push(default)
-
 // Linux defines MAXHOSTNAMELEN as 64, while the domain name limit in
 // RFC 1034 and RFC 1035 is 255 octets.
 #ifdef MAXHOSTNAMELEN
@@ -536,8 +533,15 @@
 
 #undef __socketcall
 
-__END_DECLS
+// Symbols that are supposed to be in resolv.h, but that we aren't exporting.
+int ns_parserr2(ns_msg*, ns_sect, int, ns_rr2*);
+int ns_name_pton2(const char*, u_char*, size_t, size_t*);
+int ns_name_unpack2(const u_char*, const u_char*, const u_char*, u_char*, size_t, size_t*);
+int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
+int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
+int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
+int ns_name_labels(ns_nname_ct, size_t);
 
-#pragma GCC visibility pop
+__END_DECLS
 
 #endif /* !_RESOLV_PRIVATE_H_ */
diff --git a/libc/dns/nameser/ns_parse.c b/libc/dns/nameser/ns_parse.c
index 2d6d530..3a1901a 100644
--- a/libc/dns/nameser/ns_parse.c
+++ b/libc/dns/nameser/ns_parse.c
@@ -52,6 +52,8 @@
 
 /* Public. */
 
+struct _ns_flagdata {  int mask, shift;  };
+
 /* These need to be in the same order as the nres.h:ns_flag enum. */
 const struct _ns_flagdata _ns_flagdata[16] = {
 	{ 0x8000, 15 },		/* qr. */
diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c
index 829b679..13000f7 100644
--- a/libc/dns/net/getaddrinfo.c
+++ b/libc/dns/net/getaddrinfo.c
@@ -108,9 +108,9 @@
 #include <stdarg.h>
 #include "nsswitch.h"
 
-#ifdef ANDROID_CHANGES
+#if defined(__BIONIC__)
 #include <sys/system_properties.h>
-#endif /* ANDROID_CHANGES */
+#endif
 
 typedef union sockaddr_union {
     struct sockaddr     generic;
@@ -325,7 +325,7 @@
 {
 	struct addrinfo *next;
 
-#if __ANDROID__
+#if defined(__BIONIC__)
 	if (ai == NULL) return;
 #else
 	_DIAGASSERT(ai != NULL);
@@ -1791,10 +1791,14 @@
 			return -1;
 		}
 	}
-	if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0)
+	if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0) {
+		close(sock);
 		return 0;
-	if (uid > 0 && uid != NET_CONTEXT_INVALID_UID && fchown(sock, uid, (gid_t)-1) < 0)
+	}
+	if (uid > 0 && uid != NET_CONTEXT_INVALID_UID && fchown(sock, uid, (gid_t)-1) < 0) {
+		close(sock);
 		return 0;
+	}
 	do {
 		ret = __connect(sock, addr, len);
 	} while (ret == -1 && errno == EINTR);
diff --git a/libc/dns/net/getnameinfo.c b/libc/dns/net/getnameinfo.c
index 893e982..63a347e 100644
--- a/libc/dns/net/getnameinfo.c
+++ b/libc/dns/net/getnameinfo.c
@@ -54,8 +54,6 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <net/if.h>
-#include <net/if_ieee1394.h>
-#include <net/if_types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <assert.h>
diff --git a/libc/dns/resolv/res_init.c b/libc/dns/resolv/res_init.c
index 713b6e0..a5413dd 100644
--- a/libc/dns/resolv/res_init.c
+++ b/libc/dns/resolv/res_init.c
@@ -166,23 +166,23 @@
 /* This function has to be reachable by res_data.c but not publicly. */
 int
 __res_vinit(res_state statp, int preinit) {
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
 	register FILE *fp;
 #endif
 	register char *cp, **pp;
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
 	register int n;
 #endif
 	char buf[BUFSIZ];
 	int nserv = 0;    /* number of nameserver records read from file */
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
 	int haveenv = 0;
 #endif
 	int havesearch = 0;
 #ifdef RESOLVSORT
 	int nsort = 0;
 #endif
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
 	char *net;
 #endif
 	int dots;
@@ -243,7 +243,9 @@
 	statp->nsort = 0;
 	res_setservers(statp, u, nserv);
 
-#if !defined(__ANDROID__) /* IGNORE THE ENVIRONMENT */
+#if defined(__BIONIC__)
+	/* Ignore the environment. */
+#else
 	/* Allow user to override the local domain definition */
 	if ((cp = getenv("LOCALDOMAIN")) != NULL) {
 		(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
diff --git a/libc/dns/resolv/res_mkquery.c b/libc/dns/resolv/res_mkquery.c
index 3736aa1..6fb1957 100644
--- a/libc/dns/resolv/res_mkquery.c
+++ b/libc/dns/resolv/res_mkquery.c
@@ -1,7 +1,6 @@
 /*	$NetBSD: res_mkquery.c,v 1.6 2006/01/24 17:40:32 christos Exp $	*/
 
 /*
- * Copyright (c) 2008  Android Open Source Project (query id randomization)
  * Copyright (c) 1985, 1993
  *    The Regents of the University of California.  All rights reserved.
  *
diff --git a/libc/dns/resolv/res_send.c b/libc/dns/resolv/res_send.c
index 1ae675b..f53da5f 100644
--- a/libc/dns/resolv/res_send.c
+++ b/libc/dns/resolv/res_send.c
@@ -1,7 +1,6 @@
 /*	$NetBSD: res_send.c,v 1.9 2006/01/24 17:41:25 christos Exp $	*/
 
 /*
- * Copyright 2008  Android Open Source Project (source port randomization)
  * Copyright (c) 1985, 1989, 1993
  *    The Regents of the University of California.  All rights reserved.
  *
@@ -1219,9 +1218,6 @@
 		 * XXX - potential security hazard could
 		 *	 be detected here.
 		 */
-#ifdef ANDROID_CHANGES
-		__libc_android_log_event_uid(BIONIC_EVENT_RESOLVER_OLD_RESPONSE);
-#endif
 		DprintQ((statp->options & RES_DEBUG) ||
 			(statp->pfcode & RES_PRF_REPLY),
 			(stdout, ";; old answer:\n"),
@@ -1235,9 +1231,6 @@
 		 * XXX - potential security hazard could
 		 *	 be detected here.
 		 */
-#ifdef ANDROID_CHANGES
-		__libc_android_log_event_uid(BIONIC_EVENT_RESOLVER_WRONG_SERVER);
-#endif
 		DprintQ((statp->options & RES_DEBUG) ||
 			(statp->pfcode & RES_PRF_REPLY),
 			(stdout, ";; not our server:\n"),
@@ -1268,9 +1261,6 @@
 		 * XXX - potential security hazard could
 		 *	 be detected here.
 		 */
-#ifdef ANDROID_CHANGES
-		__libc_android_log_event_uid(BIONIC_EVENT_RESOLVER_WRONG_QUERY);
-#endif
 		DprintQ((statp->options & RES_DEBUG) ||
 			(statp->pfcode & RES_PRF_REPLY),
 			(stdout, ";; wrong query name:\n"),
diff --git a/libc/include/alloca.h b/libc/include/alloca.h
index 0c50fc3..0508d31 100644
--- a/libc/include/alloca.h
+++ b/libc/include/alloca.h
@@ -25,9 +25,12 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _ALLOCA_H
 #define _ALLOCA_H
 
+#include <sys/cdefs.h>
+
 #define alloca(size)   __builtin_alloca(size)
 
 #endif /* _ALLOCA_H */
diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h
index 2d2f096..6dd4c18 100644
--- a/libc/include/android/api-level.h
+++ b/libc/include/android/api-level.h
@@ -29,10 +29,18 @@
 #ifndef ANDROID_API_LEVEL_H
 #define ANDROID_API_LEVEL_H
 
+#include <sys/cdefs.h>
+
 /*
  * Magic version number for a current development build, which has
  * not yet turned into an official release.
  */
-#define __ANDROID_API__ 10000
+#ifndef __ANDROID_API_FUTURE__
+#define __ANDROID_API_FUTURE__ 10000
+#endif
+
+#ifndef __ANDROID_API__
+#define __ANDROID_API__ __ANDROID_API_FUTURE__
+#endif
 
 #endif /* ANDROID_API_LEVEL_H */
diff --git a/libc/include/android/dlext.h b/libc/include/android/dlext.h
index aa36f1e..ca3bd25 100644
--- a/libc/include/android/dlext.h
+++ b/libc/include/android/dlext.h
@@ -17,6 +17,7 @@
 #ifndef __ANDROID_DLEXT_H__
 #define __ANDROID_DLEXT_H__
 
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <sys/cdefs.h>
@@ -128,7 +129,8 @@
   struct android_namespace_t* library_namespace;
 } android_dlextinfo;
 
-extern void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo);
+void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo)
+  __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/android/legacy_errno_inlines.h b/libc/include/android/legacy_errno_inlines.h
index 71096fc..93cba1f 100644
--- a/libc/include/android/legacy_errno_inlines.h
+++ b/libc/include/android/legacy_errno_inlines.h
@@ -29,8 +29,11 @@
 #ifndef _ANDROID_LEGACY_ERRNO_INLINES_H
 #define _ANDROID_LEGACY_ERRNO_INLINES_H
 
+#include <errno.h>
 #include <sys/cdefs.h>
 
+#if __ANDROID_API__ < 21
+
 __BEGIN_DECLS
 
 static __inline int __attribute__((deprecated)) __set_errno(int n) {
@@ -40,4 +43,5 @@
 
 __END_DECLS
 
+#endif
 #endif /* _ANDROID_LEGACY_ERRNO_INLINES_H */
diff --git a/libc/include/android/legacy_fenv_inlines_arm.h b/libc/include/android/legacy_fenv_inlines_arm.h
new file mode 100644
index 0000000..a5bb26b
--- /dev/null
+++ b/libc/include/android/legacy_fenv_inlines_arm.h
@@ -0,0 +1,154 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/msun/arm/fenv.c,v 1.1 2004/06/06 10:03:59 das Exp $
+ */
+
+#ifndef ANDROID_LEGACY_FENV_INLINES_ARM_H
+#define ANDROID_LEGACY_FENV_INLINES_ARM_H
+
+#include <fenv.h>
+
+#if __ANDROID_API__ < 21 && defined(__arm__)
+
+__BEGIN_DECLS
+
+#define FPSCR_ENABLE_SHIFT 8
+#define FPSCR_ENABLE_MASK  (FE_ALL_EXCEPT << FPSCR_ENABLE_SHIFT)
+
+#define FPSCR_RMODE_SHIFT 22
+
+static __inline int fegetenv(fenv_t* __envp) {
+  fenv_t _fpscr;
+  __asm__ __volatile__("vmrs %0,fpscr" : "=r" (_fpscr));
+  *__envp = _fpscr;
+  return 0;
+}
+
+static __inline int fesetenv(const fenv_t* __envp) {
+  fenv_t _fpscr = *__envp;
+  __asm__ __volatile__("vmsr fpscr,%0" : :"ri" (_fpscr));
+  return 0;
+}
+
+static __inline int feclearexcept(int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  __fpscr &= ~__excepts;
+  fesetenv(&__fpscr);
+  return 0;
+}
+
+static __inline int fegetexceptflag(fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  *__flagp = __fpscr & __excepts;
+  return 0;
+}
+
+static __inline int fesetexceptflag(const fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  __fpscr &= ~__excepts;
+  __fpscr |= *__flagp & __excepts;
+  fesetenv(&__fpscr);
+  return 0;
+}
+
+static __inline int feraiseexcept(int __excepts) {
+  fexcept_t __ex = __excepts;
+  fesetexceptflag(&__ex, __excepts);
+  return 0;
+}
+
+static __inline int fetestexcept(int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  return (__fpscr & __excepts);
+}
+
+static __inline int fegetround(void) {
+  fenv_t _fpscr;
+  fegetenv(&_fpscr);
+  return ((_fpscr >> FPSCR_RMODE_SHIFT) & 0x3);
+}
+
+static __inline int fesetround(int __round) {
+  fenv_t _fpscr;
+  fegetenv(&_fpscr);
+  _fpscr &= ~(0x3 << FPSCR_RMODE_SHIFT);
+  _fpscr |= (__round << FPSCR_RMODE_SHIFT);
+  fesetenv(&_fpscr);
+  return 0;
+}
+
+static __inline int feholdexcept(fenv_t* __envp) {
+  fenv_t __env;
+  fegetenv(&__env);
+  *__envp = __env;
+  __env &= ~(FE_ALL_EXCEPT | FPSCR_ENABLE_MASK);
+  fesetenv(&__env);
+  return 0;
+}
+
+static __inline int feupdateenv(const fenv_t* __envp) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  fesetenv(__envp);
+  feraiseexcept(__fpscr & FE_ALL_EXCEPT);
+  return 0;
+}
+
+static __inline int feenableexcept(int __mask) {
+  fenv_t __old_fpscr, __new_fpscr;
+  fegetenv(&__old_fpscr);
+  __new_fpscr = __old_fpscr | (__mask & FE_ALL_EXCEPT) << FPSCR_ENABLE_SHIFT;
+  fesetenv(&__new_fpscr);
+  return ((__old_fpscr >> FPSCR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static __inline int fedisableexcept(int __mask) {
+  fenv_t __old_fpscr, __new_fpscr;
+  fegetenv(&__old_fpscr);
+  __new_fpscr = __old_fpscr & ~((__mask & FE_ALL_EXCEPT) << FPSCR_ENABLE_SHIFT);
+  fesetenv(&__new_fpscr);
+  return ((__old_fpscr >> FPSCR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static __inline int fegetexcept(void) {
+  fenv_t __fpscr;
+  fegetenv(&__fpscr);
+  return ((__fpscr & FPSCR_ENABLE_MASK) >> FPSCR_ENABLE_SHIFT);
+}
+
+#undef FPSCR_ENABLE_SHIFT
+#undef FPSCR_ENABLE_MASK
+#undef FPSCR_RMODE_SHIFT
+
+__END_DECLS
+
+#endif /* __ANDROID_API__ < 21 && defined(__arm__) */
+
+#endif /* ANDROID_LEGACY_FENV_INLINES_ARM_H */
diff --git a/libc/include/android/legacy_fenv_inlines_mips.h b/libc/include/android/legacy_fenv_inlines_mips.h
new file mode 100644
index 0000000..ead697c
--- /dev/null
+++ b/libc/include/android/legacy_fenv_inlines_mips.h
@@ -0,0 +1,168 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/msun/mips/fenv.c,v 1.1 2008/04/26 12:20:29 imp Exp $
+ */
+
+#ifndef ANDROID_LEGACY_FENV_INLINES_MIPS_H
+#define ANDROID_LEGACY_FENV_INLINES_MIPS_H
+
+#include <fenv.h>
+
+#if __ANDROID_API__ < 21 && (defined(__mips__) && !defined(__LP64__))
+
+__BEGIN_DECLS
+
+#define FCSR_CAUSE_SHIFT 10
+#define FCSR_ENABLE_SHIFT 5
+#define FCSR_ENABLE_MASK (FE_ALL_EXCEPT << FCSR_ENABLE_SHIFT)
+
+#define FCSR_RMASK       0x3
+
+static __inline int fegetenv(fenv_t* __envp) {
+  fenv_t _fcsr = 0;
+#ifdef  __mips_hard_float
+  __asm__ __volatile__("cfc1 %0,$31" : "=r" (_fcsr));
+#endif
+  *__envp = _fcsr;
+  return 0;
+}
+
+static __inline int fesetenv(const fenv_t* __envp) {
+  fenv_t _fcsr = *__envp;
+#ifdef  __mips_hard_float
+  __asm__ __volatile__("ctc1 %0,$31" : : "r" (_fcsr));
+#endif
+  return 0;
+}
+
+static __inline int feclearexcept(int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~(__excepts | (__excepts << FCSR_CAUSE_SHIFT));
+  fesetenv(&__fcsr);
+  return 0;
+}
+
+static __inline int fegetexceptflag(fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  *__flagp = __fcsr & __excepts & FE_ALL_EXCEPT;
+  return 0;
+}
+
+static __inline int fesetexceptflag(const fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~__excepts;
+  __fcsr |= *__flagp & __excepts;
+  fesetenv(&__fcsr);
+  return 0;
+}
+
+static __inline int feraiseexcept(int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  /* Cause bit needs to be set as well for generating the exception*/
+  __fcsr |= __excepts | (__excepts << FCSR_CAUSE_SHIFT);
+  fesetenv(&__fcsr);
+  return 0;
+}
+
+static __inline int fetestexcept(int __excepts) {
+  fexcept_t __FCSR;
+  fegetenv(&__FCSR);
+  return (__FCSR & __excepts & FE_ALL_EXCEPT);
+}
+
+static __inline int fegetround(void) {
+  fenv_t _fcsr;
+  fegetenv(&_fcsr);
+  return (_fcsr & FCSR_RMASK);
+}
+
+static __inline int fesetround(int __round) {
+  fenv_t _fcsr;
+  fegetenv(&_fcsr);
+  _fcsr &= ~FCSR_RMASK;
+  _fcsr |= (__round & FCSR_RMASK);
+  fesetenv(&_fcsr);
+  return 0;
+}
+
+static __inline int feholdexcept(fenv_t* __envp) {
+  fenv_t __env;
+  fegetenv(&__env);
+  *__envp = __env;
+  __env &= ~(FE_ALL_EXCEPT | FCSR_ENABLE_MASK);
+  fesetenv(&__env);
+  return 0;
+}
+
+static __inline int feupdateenv(const fenv_t* __envp) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  fesetenv(__envp);
+  feraiseexcept(__fcsr & FE_ALL_EXCEPT);
+  return 0;
+}
+
+static __inline int feenableexcept(int __mask) {
+  fenv_t __old_fcsr, __new_fcsr;
+  fegetenv(&__old_fcsr);
+  __new_fcsr = __old_fcsr | (__mask & FE_ALL_EXCEPT) << FCSR_ENABLE_SHIFT;
+  fesetenv(&__new_fcsr);
+  return ((__old_fcsr >> FCSR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static __inline int fedisableexcept(int __mask) {
+  fenv_t __old_fcsr, __new_fcsr;
+  fegetenv(&__old_fcsr);
+  __new_fcsr = __old_fcsr & ~((__mask & FE_ALL_EXCEPT) << FCSR_ENABLE_SHIFT);
+  fesetenv(&__new_fcsr);
+  return ((__old_fcsr >> FCSR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static __inline int fegetexcept(void) {
+  fenv_t __fcsr;
+  fegetenv(&__fcsr);
+  return ((__fcsr & FCSR_ENABLE_MASK) >> FCSR_ENABLE_SHIFT);
+}
+
+#undef FCSR_CAUSE_SHIFT
+#undef FCSR_ENABLE_SHIFT
+#undef FCSR_ENABLE_MASK
+#undef FCSR_RMASK
+
+__END_DECLS
+
+#endif /* __ANDROID_API__ < 21 && (defined(__mips__) && !defined(__LP64__)) */
+
+#endif /* ANDROID_LEGACY_FENV_INLINES_MIPS_H */
diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h
index 1b6e687..8ba7894 100644
--- a/libc/include/android/legacy_signal_inlines.h
+++ b/libc/include/android/legacy_signal_inlines.h
@@ -29,14 +29,19 @@
 #ifndef _ANDROID_LEGACY_SIGNAL_INLINES_H_
 #define _ANDROID_LEGACY_SIGNAL_INLINES_H_
 
+#include <errno.h>
+#include <signal.h>
 #include <string.h>
 #include <sys/cdefs.h>
 
+
 __BEGIN_DECLS
 
-extern sighandler_t bsd_signal(int signum, sighandler_t handler);
+sighandler_t bsd_signal(int signum, sighandler_t handler) __REMOVED_IN(21);
 
-static __inline int sigismember(sigset_t *set, int signum) {
+#if __ANDROID_API__ < 21
+
+static __inline int sigismember(const sigset_t *set, int signum) {
   /* Signal numbers start at 1, but bit positions start at 0. */
   int bit = signum - 1;
   const unsigned long *local_set = (const unsigned long *)set;
@@ -93,6 +98,8 @@
   return bsd_signal(s, f);
 }
 
+#endif /* __ANDROID_API__ < 21 */
+
 __END_DECLS
 
 #endif /* _ANDROID_LEGACY_SIGNAL_INLINES_H_ */
diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h
index 58a2a9e..93554e5 100644
--- a/libc/include/android/legacy_stdlib_inlines.h
+++ b/libc/include/android/legacy_stdlib_inlines.h
@@ -29,8 +29,11 @@
 #ifndef _ANDROID_LEGACY_STDLIB_INLINES_H_
 #define _ANDROID_LEGACY_STDLIB_INLINES_H_
 
+#include <stdlib.h>
 #include <sys/cdefs.h>
 
+#if __ANDROID_API__ < 21
+
 __BEGIN_DECLS
 
 static __inline float strtof(const char *nptr, char **endptr) {
@@ -61,4 +64,5 @@
 
 __END_DECLS
 
+#endif
 #endif /* _ANDROID_LEGACY_STDLIB_INLINES_H_ */
diff --git a/libc/include/android/legacy_sys_atomics_inlines.h b/libc/include/android/legacy_sys_atomics_inlines.h
deleted file mode 100644
index 85cbade..0000000
--- a/libc/include/android/legacy_sys_atomics_inlines.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ANDROID_LEGACY_SYS_ATOMICS_INLINES_H_
-#define _ANDROID_LEGACY_SYS_ATOMICS_INLINES_H_
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/* Note: atomic operations that were exported by the C library didn't
- *       provide any memory barriers, which created potential issues on
- *       multi-core devices. We now define them as inlined calls to
- *       GCC sync builtins, which always provide a full barrier.
- *
- *       NOTE: The C library still exports atomic functions by the same
- *              name to ensure ABI stability for existing NDK machine code.
- *
- *       If you are an NDK developer, we encourage you to rebuild your
- *       unmodified sources against this header as soon as possible.
- */
-#define __ATOMIC_INLINE__ static __inline __attribute__((always_inline))
-
-__ATOMIC_INLINE__ int __atomic_cmpxchg(int old, int _new, volatile int *ptr) {
-  /* We must return 0 on success */
-  return __sync_val_compare_and_swap(ptr, old, _new) != old;
-}
-
-__ATOMIC_INLINE__ int __atomic_swap(int _new, volatile int *ptr) {
-  int prev;
-  do {
-    prev = *ptr;
-  } while (__sync_val_compare_and_swap(ptr, prev, _new) != prev);
-  return prev;
-}
-
-__ATOMIC_INLINE__ int __atomic_dec(volatile int *ptr) {
-  return __sync_fetch_and_sub(ptr, 1);
-}
-
-__ATOMIC_INLINE__ int __atomic_inc(volatile int *ptr) {
-  return __sync_fetch_and_add(ptr, 1);
-}
-
-__END_DECLS
-
-#endif /* _ANDROID_LEGACY_SYS_ATOMICS_INLINES_H_ */
diff --git a/libc/include/android/legacy_sys_stat_inlines.h b/libc/include/android/legacy_sys_stat_inlines.h
index f6d3c0f..c08edfa 100644
--- a/libc/include/android/legacy_sys_stat_inlines.h
+++ b/libc/include/android/legacy_sys_stat_inlines.h
@@ -30,6 +30,9 @@
 #define _ANDROID_LEGACY_SYS_STAT_INLINES_H_
 
 #include <sys/cdefs.h>
+#include <sys/stat.h>
+
+#if __ANDROID_API__ < 21
 
 __BEGIN_DECLS
 
@@ -39,4 +42,5 @@
 
 __END_DECLS
 
+#endif
 #endif /* _ANDROID_LEGACY_SYS_STAT_INLINES_H_ */
diff --git a/libc/bionic/__write_chk.cpp b/libc/include/android/legacy_sys_wait_inlines.h
similarity index 71%
rename from libc/bionic/__write_chk.cpp
rename to libc/include/android/legacy_sys_wait_inlines.h
index cbd247a..63343eb 100644
--- a/libc/bionic/__write_chk.cpp
+++ b/libc/include/android/legacy_sys_wait_inlines.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,18 +26,24 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
+#ifndef _ANDROID_LEGACY_SYS_WAIT_INLINES_H_
+#define _ANDROID_LEGACY_SYS_WAIT_INLINES_H_
+
+#include <sys/cdefs.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
 #include <unistd.h>
-#include "private/libc_logging.h"
 
-extern "C" ssize_t __write_chk(int fd, const void* buf, size_t count, size_t buf_size) {
-  if (__predict_false(count > buf_size)) {
-    __fortify_chk_fail("write: prevented read past end of buffer", 0);
-  }
+#if __ANDROID_API__ < 18
 
-  if (__predict_false(count > SSIZE_MAX)) {
-    __fortify_chk_fail("write: count > SSIZE_MAX", 0);
-  }
+__BEGIN_DECLS
 
-  return write(fd, buf, count);
+static __inline pid_t wait4(pid_t pid, int* status, int options, struct rusage* rusage) {
+  return __BIONIC_CAST(static_cast, pid_t, syscall(__NR_wait4, pid, status, options, rusage));
 }
+
+__END_DECLS
+
+#endif /* __ANDROID_API__ < 18 */
+
+#endif /* _ANDROID_LEGACY_SYS_WAIT_INLINES_H_ */
diff --git a/libc/include/android/legacy_termios_inlines.h b/libc/include/android/legacy_termios_inlines.h
index fb61f27..41ea955 100644
--- a/libc/include/android/legacy_termios_inlines.h
+++ b/libc/include/android/legacy_termios_inlines.h
@@ -34,6 +34,8 @@
 #include <sys/ioctl.h>
 #include <sys/types.h>
 
+#if __ANDROID_API__ < 21
+
 __BEGIN_DECLS
 
 static __inline int tcgetattr(int fd, struct termios *s) {
@@ -90,4 +92,5 @@
 
 __END_DECLS
 
+#endif
 #endif /* _ANDROID_LEGACY_TERMIOS_INLINES_H_ */
diff --git a/libc/include/android/set_abort_message.h b/libc/include/android/set_abort_message.h
index 4b3d82b..18881a3 100644
--- a/libc/include/android/set_abort_message.h
+++ b/libc/include/android/set_abort_message.h
@@ -33,8 +33,8 @@
 
 __BEGIN_DECLS
 
-void android_set_abort_message(const char* msg);
+void android_set_abort_message(const char* msg) __INTRODUCED_IN(21);
 
 __END_DECLS
 
-#endif // _SET_ABORT_MESSAGE_H
+#endif
diff --git a/libc/include/android/versioning.h b/libc/include/android/versioning.h
new file mode 100644
index 0000000..4e1a185
--- /dev/null
+++ b/libc/include/android/versioning.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_VERSIONING_H
+#define ANDROID_VERSIONING_H
+
+#define __INTRODUCED_IN(api_level) __attribute__((annotate("introduced_in=" #api_level)))
+#define __INTRODUCED_IN_FUTURE __attribute__((annotate("introduced_in_future")))
+#define __DEPRECATED_IN(api_level) __attribute__((annotate("deprecated_in=" #api_level)))
+#define __REMOVED_IN(api_level) __attribute__((annotate("obsoleted_in=" #api_level)))
+#define __INTRODUCED_IN_32(api_level) __attribute__((annotate("introduced_in_32=" #api_level)))
+#define __INTRODUCED_IN_64(api_level) __attribute__((annotate("introduced_in_64=" #api_level)))
+#define __INTRODUCED_IN_ARM(api_level) __attribute__((annotate("introduced_in_arm=" #api_level)))
+#define __INTRODUCED_IN_X86(api_level) __attribute__((annotate("introduced_in_x86=" #api_level)))
+#define __INTRODUCED_IN_MIPS(api_level) __attribute__((annotate("introduced_in_mips=" #api_level)))
+
+#define __VERSIONER_NO_GUARD __attribute__((annotate("versioner_no_guard")))
+
+#endif /* ANDROID_VERSIONING_H */
diff --git a/libc/include/ar.h b/libc/include/ar.h
index 835290b..413f767 100644
--- a/libc/include/ar.h
+++ b/libc/include/ar.h
@@ -43,6 +43,8 @@
 #ifndef _AR_H_
 #define	_AR_H_
 
+#include <sys/cdefs.h>
+
 /* Pre-4BSD archives had these magic numbers in them. */
 #define	OARMAG1	0177555
 #define	OARMAG2	0177545
diff --git a/libc/include/arpa/inet.h b/libc/include/arpa/inet.h
index 86265bf..d137130 100644
--- a/libc/include/arpa/inet.h
+++ b/libc/include/arpa/inet.h
@@ -29,18 +29,19 @@
 #ifndef _ARPA_INET_H_
 #define _ARPA_INET_H_
 
-#include <stdint.h>
-#include <sys/types.h>
 #include <netinet/in.h>
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
 
 __BEGIN_DECLS
 
 in_addr_t inet_addr(const char*);
 int inet_aton(const char*, struct in_addr*);
-in_addr_t inet_lnaof(struct in_addr);
-struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
-in_addr_t inet_netof(struct in_addr);
-in_addr_t inet_network(const char*);
+in_addr_t inet_lnaof(struct in_addr) __INTRODUCED_IN(21);
+struct in_addr inet_makeaddr(in_addr_t, in_addr_t) __INTRODUCED_IN(21);
+in_addr_t inet_netof(struct in_addr) __INTRODUCED_IN(21);
+in_addr_t inet_network(const char*) __INTRODUCED_IN(21);
 char* inet_ntoa(struct in_addr);
 const char* inet_ntop(int, const void*, char*, socklen_t);
 unsigned int inet_nsap_addr(const char*, unsigned char*, int);
diff --git a/libc/include/arpa/nameser.h b/libc/include/arpa/nameser.h
index 91561ce..9507f49 100644
--- a/libc/include/arpa/nameser.h
+++ b/libc/include/arpa/nameser.h
@@ -141,10 +141,6 @@
 };
 typedef struct ns_newmsg ns_newmsg;
 
-/* Private data structure - do not use from outside library. */
-struct _ns_flagdata {  int mask, shift;  };
-extern const struct _ns_flagdata _ns_flagdata[];
-
 /* Accessor macros - this is part of the public interface. */
 
 #define ns_msg_id(handle) ((handle)._id + 0)
@@ -518,6 +514,8 @@
 	(cp) += NS_INT32SZ; \
 } while (/*CONSTCOND*/0)
 
+__BEGIN_DECLS
+
 #if !defined(__LP64__)
 /* Annoyingly, LP32 shipped with __ names. */
 #define	ns_msg_getflag		__ns_msg_getflag
@@ -563,73 +561,66 @@
 #define	ns_subdomain		__ns_subdomain
 #define	ns_makecanon		__ns_makecanon
 #define	ns_samename		__ns_samename
-#endif
 
-__BEGIN_DECLS
-int		ns_msg_getflag(ns_msg, int) __LIBC_ABI_PUBLIC__;
-uint16_t	ns_get16(const u_char *) __LIBC_ABI_PUBLIC__;
-uint32_t	ns_get32(const u_char *) __LIBC_ABI_PUBLIC__;
-void		ns_put16(uint16_t, u_char *) __LIBC_ABI_PUBLIC__;
-void		ns_put32(uint32_t, u_char *) __LIBC_ABI_PUBLIC__;
-int		ns_initparse(const u_char *, int, ns_msg *) __LIBC_ABI_PUBLIC__;
-int		ns_skiprr(const u_char *, const u_char *, ns_sect, int) __LIBC_ABI_PUBLIC__;
-int		ns_parserr(ns_msg *, ns_sect, int, ns_rr *) __LIBC_ABI_PUBLIC__;
-int		ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *) __LIBC_HIDDEN__;
-int		ns_sprintrr(const ns_msg *, const ns_rr *,
-				 const char *, const char *, char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_sprintrrf(const u_char *, size_t, const char *,
-				  ns_class, ns_type, u_long, const u_char *,
-				  size_t, const char *, const char *,
-				  char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_format_ttl(u_long, char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_parse_ttl(const char *, u_long *) __LIBC_ABI_PUBLIC__;
-uint32_t	ns_datetosecs(const char *cp, int *errp) __LIBC_ABI_PUBLIC__;
-int		ns_name_ntol(const u_char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_name_ntop(const u_char *, char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_name_pton(const char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_name_pton2(const char *, u_char *, size_t, size_t *) __LIBC_HIDDEN__;
-int		ns_name_unpack(const u_char *, const u_char *,
-				    const u_char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_name_unpack2(const u_char *, const u_char *,
-				     const u_char *, u_char *, size_t,
-				     size_t *) __LIBC_HIDDEN__;
-int		ns_name_pack(const u_char *, u_char *, int,
-				  const u_char **, const u_char **) __LIBC_ABI_PUBLIC__;
-int		ns_name_uncompress(const u_char *, const u_char *,
-					const u_char *, char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_name_compress(const char *, u_char *, size_t,
-				      const u_char **, const u_char **) __LIBC_ABI_PUBLIC__;
-int		ns_name_skip(const u_char **, const u_char *) __LIBC_ABI_PUBLIC__;
-void		ns_name_rollback(const u_char *, const u_char **,
-				      const u_char **) __LIBC_ABI_PUBLIC__;
-int		ns_sign(u_char *, int *, int, int, void *,
-			     const u_char *, int, u_char *, int *, time_t) __LIBC_ABI_PUBLIC__;
-int		ns_sign2(u_char *, int *, int, int, void *,
-			      const u_char *, int, u_char *, int *, time_t,
-			      u_char **, u_char **) __LIBC_ABI_PUBLIC__;
-ssize_t		ns_name_length(ns_nname_ct, size_t) __LIBC_HIDDEN__;
-int		ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t) __LIBC_HIDDEN__;
-int		ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int) __LIBC_HIDDEN__;
-int		ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int) __LIBC_HIDDEN__;
-int		ns_name_labels(ns_nname_ct, size_t) __LIBC_HIDDEN__;
-int		ns_sign_tcp(u_char *, int *, int, int,
-				 ns_tcp_tsig_state *, int) __LIBC_ABI_PUBLIC__;
-int		ns_sign_tcp2(u_char *, int *, int, int,
-				  ns_tcp_tsig_state *, int,
-				  u_char **, u_char **) __LIBC_ABI_PUBLIC__;
-int		ns_sign_tcp_init(void *, const u_char *, int,
-					ns_tcp_tsig_state *) __LIBC_ABI_PUBLIC__;
-u_char		*ns_find_tsig(u_char *, u_char *) __LIBC_ABI_PUBLIC__;
-int		ns_verify(u_char *, int *, void *,
-			       const u_char *, int, u_char *, int *,
-			       time_t *, int) __LIBC_ABI_PUBLIC__;
-int		ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int);
-int		ns_verify_tcp_init(void *, const u_char *, int,
-					ns_tcp_tsig_state *) __LIBC_ABI_PUBLIC__;
-int		ns_samedomain(const char *, const char *) __LIBC_ABI_PUBLIC__;
-int		ns_subdomain(const char *, const char *) __LIBC_ABI_PUBLIC__;
-int		ns_makecanon(const char *, char *, size_t) __LIBC_ABI_PUBLIC__;
-int		ns_samename(const char *, const char *) __LIBC_ABI_PUBLIC__;
+int ns_msg_getflag(ns_msg, int);
+uint16_t ns_get16(const u_char*);
+uint32_t ns_get32(const u_char*);
+void ns_put16(uint16_t, u_char*);
+void ns_put32(uint32_t, u_char*);
+int ns_initparse(const u_char*, int, ns_msg*);
+int ns_skiprr(const u_char*, const u_char*, ns_sect, int);
+int ns_parserr(ns_msg*, ns_sect, int, ns_rr*);
+int ns_sprintrr(const ns_msg*, const ns_rr*, const char*, const char*, char*, size_t);
+int ns_sprintrrf(const u_char*, size_t, const char*, ns_class, ns_type, u_long, const u_char*,
+                 size_t, const char*, const char*, char*, size_t);
+int ns_format_ttl(u_long, char*, size_t);
+int ns_name_ntol(const u_char*, u_char*, size_t);
+int ns_name_ntop(const u_char*, char*, size_t);
+int ns_name_pton(const char*, u_char*, size_t);
+int ns_name_unpack(const u_char*, const u_char*, const u_char*, u_char*, size_t);
+int ns_name_pack(const u_char*, u_char*, int, const u_char**, const u_char**);
+int ns_name_uncompress(const u_char*, const u_char*, const u_char*, char*, size_t);
+int ns_name_compress(const char*, u_char*, size_t, const u_char**, const u_char**);
+int ns_name_skip(const u_char**, const u_char*);
+void ns_name_rollback(const u_char*, const u_char**, const u_char**);
+
+int ns_makecanon(const char*, char*, size_t);
+int ns_samename(const char*, const char*);
+
+#else
+/* The names of these symbols were accidentally prefixed with __ in L. */
+/* The duplication here is intentional to avoid declaring different symbols with the same
+ * declaration. */
+int ns_msg_getflag(ns_msg, int) __INTRODUCED_IN_64(23);
+uint16_t ns_get16(const u_char*) __INTRODUCED_IN_64(23);
+uint32_t ns_get32(const u_char*) __INTRODUCED_IN_64(23);
+void ns_put16(uint16_t, u_char*) __INTRODUCED_IN_64(23);
+void ns_put32(uint32_t, u_char*) __INTRODUCED_IN_64(23);
+int ns_initparse(const u_char*, int, ns_msg*) __INTRODUCED_IN_64(23);
+int ns_skiprr(const u_char*, const u_char*, ns_sect, int) __INTRODUCED_IN_64(23);
+int ns_parserr(ns_msg*, ns_sect, int, ns_rr*) __INTRODUCED_IN_64(23);
+int ns_sprintrr(const ns_msg*, const ns_rr*, const char*, const char*, char*, size_t)
+  __INTRODUCED_IN_64(23);
+int ns_sprintrrf(const u_char*, size_t, const char*, ns_class, ns_type, u_long, const u_char*,
+                 size_t, const char*, const char*, char*, size_t) __INTRODUCED_IN_64(23);
+int ns_format_ttl(u_long, char*, size_t) __INTRODUCED_IN_64(23);
+int ns_name_ntol(const u_char*, u_char*, size_t) __INTRODUCED_IN_64(23);
+int ns_name_ntop(const u_char*, char*, size_t) __INTRODUCED_IN_64(23);
+int ns_name_pton(const char*, u_char*, size_t) __INTRODUCED_IN_64(23);
+int ns_name_unpack(const u_char*, const u_char*, const u_char*, u_char*, size_t)
+  __INTRODUCED_IN_64(23);
+int ns_name_pack(const u_char*, u_char*, int, const u_char**, const u_char**) __INTRODUCED_IN_64(23);
+int ns_name_uncompress(const u_char*, const u_char*, const u_char*, char*, size_t)
+  __INTRODUCED_IN_64(23);
+int ns_name_compress(const char*, u_char*, size_t, const u_char**, const u_char**)
+  __INTRODUCED_IN_64(23);
+int ns_name_skip(const u_char**, const u_char*) __INTRODUCED_IN_64(23);
+void ns_name_rollback(const u_char*, const u_char**, const u_char**) __INTRODUCED_IN_64(23);
+
+int ns_makecanon(const char*, char*, size_t) __INTRODUCED_IN_64(23);
+int ns_samename(const char*, const char*) __INTRODUCED_IN_64(23);
+#endif /* !defined(__LP64__) */
+
 __END_DECLS
 
 #ifdef BIND_4_COMPAT
diff --git a/libc/include/arpa/nameser_compat.h b/libc/include/arpa/nameser_compat.h
index 539864e..e4e9335 100644
--- a/libc/include/arpa/nameser_compat.h
+++ b/libc/include/arpa/nameser_compat.h
@@ -40,9 +40,10 @@
 #ifndef _ARPA_NAMESER_COMPAT_
 #define	_ARPA_NAMESER_COMPAT_
 
-#define	__BIND		19950621	/* (DEAD) interface version stamp. */
-
 #include <endian.h>
+#include <sys/cdefs.h>
+
+#define	__BIND		19950621	/* (DEAD) interface version stamp. */
 
 /*
  * Structure for query header.  The order of the fields is machine- and
@@ -53,21 +54,6 @@
 
 typedef struct {
 	unsigned	id :16;		/* query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
-			/* fields in third byte */
-	unsigned	qr: 1;		/* response flag */
-	unsigned	opcode: 4;	/* purpose of message */
-	unsigned	aa: 1;		/* authoritive answer */
-	unsigned	tc: 1;		/* truncated message */
-	unsigned	rd: 1;		/* recursion desired */
-			/* fields in fourth byte */
-	unsigned	ra: 1;		/* recursion available */
-	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
-	unsigned	ad: 1;		/* authentic data from named */
-	unsigned	cd: 1;		/* checking disabled by resolver */
-	unsigned	rcode :4;	/* response code */
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
 			/* fields in third byte */
 	unsigned	rd :1;		/* recursion desired */
 	unsigned	tc :1;		/* truncated message */
@@ -80,7 +66,6 @@
 	unsigned	ad: 1;		/* authentic data from named */
 	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
 	unsigned	ra :1;		/* recursion available */
-#endif
 			/* remaining bytes */
 	unsigned	qdcount :16;	/* number of question entries */
 	unsigned	ancount :16;	/* number of answer entries */
diff --git a/libc/include/arpa/telnet.h b/libc/include/arpa/telnet.h
index d318e08..594dc7a 100644
--- a/libc/include/arpa/telnet.h
+++ b/libc/include/arpa/telnet.h
@@ -32,6 +32,8 @@
 #ifndef _ARPA_TELNET_H
 #define	_ARPA_TELNET_H 1
 
+#include <sys/cdefs.h>
+
 /*
  * Definitions for the TELNET protocol.
  */
@@ -64,8 +66,6 @@
 	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
 	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
 };
-#else
-extern char *telcmds[];
 #endif
 
 #define	TELCMD_FIRST	xEOF
@@ -206,8 +206,6 @@
 const char *slc_names[] = {
 	SLC_NAMELIST
 };
-#else
-extern char *slc_names[];
 #define	SLC_NAMES SLC_NAMELIST
 #endif
 
@@ -266,8 +264,6 @@
 const char *authtype_names[] = {
 	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
 };
-#else
-extern char *authtype_names[];
 #endif
 
 #define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
@@ -301,9 +297,6 @@
 const char *enctype_names[] = {
 	"ANY", "DES_CFB64",  "DES_OFB64",  0,
 };
-#else
-extern const char *encrypt_names[];
-extern const char *enctype_names[];
 #endif
 
 
diff --git a/libc/include/assert.h b/libc/include/assert.h
index 361a5ff..8c456ef 100644
--- a/libc/include/assert.h
+++ b/libc/include/assert.h
@@ -1,6 +1,3 @@
-/*	$OpenBSD: assert.h,v 1.12 2006/01/31 10:53:51 hshoexer Exp $	*/
-/*	$NetBSD: assert.h,v 1.6 1994/10/26 00:55:44 cgd Exp $	*/
-
 /*-
  * Copyright (c) 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -33,33 +30,36 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- *	@(#)assert.h	8.2 (Berkeley) 1/21/94
  */
 
 /*
- * Unlike other ANSI header files, <assert.h> may usefully be included
- * multiple times, with and without NDEBUG defined.
+ * There's no include guard in this file because <assert.h> may usefully be
+ * included multiple times, with and without NDEBUG defined.
  */
 
 #include <sys/cdefs.h>
 
 #undef assert
-#undef _assert
+#undef __assert_no_op
+
+#define __assert_no_op __BIONIC_CAST(static_cast, void, 0)
 
 #ifdef NDEBUG
-# define	assert(e)	((void)0)
-# define	_assert(e)	((void)0)
+# define assert(e) __assert_no_op
 #else
-# define	_assert(e)	assert(e)
-# if __ISO_C_VISIBLE >= 1999
-#  define	assert(e)	((e) ? (void)0 : __assert2(__FILE__, __LINE__, __func__, #e))
+# if defined(__cplusplus) || __STDC_VERSION__ >= 199901L
+#  define assert(e) ((e) ? __assert_no_op : __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e))
 # else
-#  define	assert(e)	((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
+#  define assert(e) ((e) ? __assert_no_op : __assert(__FILE__, __LINE__, #e))
 # endif
 #endif
 
+#if !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
+# undef static_assert
+# define static_assert _Static_assert
+#endif
+
 __BEGIN_DECLS
-__dead void __assert(const char *, int, const char *) __noreturn;
-__dead void __assert2(const char *, int, const char *, const char *) __noreturn;
+void __assert(const char*, int, const char*) __noreturn;
+void __assert2(const char*, int, const char*, const char*) __noreturn;
 __END_DECLS
diff --git a/libc/include/sys/utime.h b/libc/include/bits/fcntl.h
similarity index 87%
copy from libc/include/sys/utime.h
copy to libc/include/bits/fcntl.h
index 9f8810e..604d35a 100644
--- a/libc/include/sys/utime.h
+++ b/libc/include/bits/fcntl.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,9 +25,16 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _SYS_UTIME_H_
-#define _SYS_UTIME_H_
 
-#include <linux/utime.h>
+#ifndef _BITS_FCNTL_H_
+#define _BITS_FCNTL_H_
 
-#endif /* _SYS_UTIME_H_ */
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+int fcntl(int, int, ...);
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/machine/endian.h b/libc/include/bits/getopt.h
similarity index 81%
rename from libc/include/machine/endian.h
rename to libc/include/bits/getopt.h
index ac89519..7153d48 100644
--- a/libc/include/machine/endian.h
+++ b/libc/include/bits/getopt.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,10 +26,18 @@
  * SUCH DAMAGE.
  */
 
-#ifndef _MACHINE_ENDIAN_H_
-#define _MACHINE_ENDIAN_H_
+#ifndef _BITS_GETOPT_H_
+#define _BITS_GETOPT_H_
 
-/* This file is for BSD source compatibility only. Use <endian.h> or <sys/endian.h> instead. */
-#include <sys/endian.h>
+#include <sys/cdefs.h>
 
-#endif /* _MACHINE_ENDIAN_H_ */
+__BEGIN_DECLS
+
+int	 getopt(int, char * const [], const char *);
+
+extern char *optarg;			/* getopt(3) external variables */
+extern int optind, opterr, optopt;
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/bits/glibc-syscalls.h b/libc/include/bits/glibc-syscalls.h
new file mode 100644
index 0000000..598e310
--- /dev/null
+++ b/libc/include/bits/glibc-syscalls.h
@@ -0,0 +1,1234 @@
+/* Generated by gensyscalls.py. Do not edit. */
+#ifndef _BIONIC_BITS_GLIBC_SYSCALLS_H_
+#define _BIONIC_BITS_GLIBC_SYSCALLS_H_
+#if defined(__NR_accept)
+  #define SYS_accept __NR_accept
+#endif
+#if defined(__NR_accept4)
+  #define SYS_accept4 __NR_accept4
+#endif
+#if defined(__NR_access)
+  #define SYS_access __NR_access
+#endif
+#if defined(__NR_acct)
+  #define SYS_acct __NR_acct
+#endif
+#if defined(__NR_add_key)
+  #define SYS_add_key __NR_add_key
+#endif
+#if defined(__NR_adjtimex)
+  #define SYS_adjtimex __NR_adjtimex
+#endif
+#if defined(__NR_afs_syscall)
+  #define SYS_afs_syscall __NR_afs_syscall
+#endif
+#if defined(__NR_alarm)
+  #define SYS_alarm __NR_alarm
+#endif
+#if defined(__NR_arch_prctl)
+  #define SYS_arch_prctl __NR_arch_prctl
+#endif
+#if defined(__NR_arch_specific_syscall)
+  #define SYS_arch_specific_syscall __NR_arch_specific_syscall
+#endif
+#if defined(__NR_arm_fadvise64_64)
+  #define SYS_arm_fadvise64_64 __NR_arm_fadvise64_64
+#endif
+#if defined(__NR_arm_sync_file_range)
+  #define SYS_arm_sync_file_range __NR_arm_sync_file_range
+#endif
+#if defined(__NR_bdflush)
+  #define SYS_bdflush __NR_bdflush
+#endif
+#if defined(__NR_bind)
+  #define SYS_bind __NR_bind
+#endif
+#if defined(__NR_bpf)
+  #define SYS_bpf __NR_bpf
+#endif
+#if defined(__NR_break)
+  #define SYS_break __NR_break
+#endif
+#if defined(__NR_brk)
+  #define SYS_brk __NR_brk
+#endif
+#if defined(__NR_cachectl)
+  #define SYS_cachectl __NR_cachectl
+#endif
+#if defined(__NR_cacheflush)
+  #define SYS_cacheflush __NR_cacheflush
+#endif
+#if defined(__NR_capget)
+  #define SYS_capget __NR_capget
+#endif
+#if defined(__NR_capset)
+  #define SYS_capset __NR_capset
+#endif
+#if defined(__NR_chdir)
+  #define SYS_chdir __NR_chdir
+#endif
+#if defined(__NR_chmod)
+  #define SYS_chmod __NR_chmod
+#endif
+#if defined(__NR_chown)
+  #define SYS_chown __NR_chown
+#endif
+#if defined(__NR_chown32)
+  #define SYS_chown32 __NR_chown32
+#endif
+#if defined(__NR_chroot)
+  #define SYS_chroot __NR_chroot
+#endif
+#if defined(__NR_clock_adjtime)
+  #define SYS_clock_adjtime __NR_clock_adjtime
+#endif
+#if defined(__NR_clock_getres)
+  #define SYS_clock_getres __NR_clock_getres
+#endif
+#if defined(__NR_clock_gettime)
+  #define SYS_clock_gettime __NR_clock_gettime
+#endif
+#if defined(__NR_clock_nanosleep)
+  #define SYS_clock_nanosleep __NR_clock_nanosleep
+#endif
+#if defined(__NR_clock_settime)
+  #define SYS_clock_settime __NR_clock_settime
+#endif
+#if defined(__NR_clone)
+  #define SYS_clone __NR_clone
+#endif
+#if defined(__NR_close)
+  #define SYS_close __NR_close
+#endif
+#if defined(__NR_connect)
+  #define SYS_connect __NR_connect
+#endif
+#if defined(__NR_copy_file_range)
+  #define SYS_copy_file_range __NR_copy_file_range
+#endif
+#if defined(__NR_creat)
+  #define SYS_creat __NR_creat
+#endif
+#if defined(__NR_create_module)
+  #define SYS_create_module __NR_create_module
+#endif
+#if defined(__NR_delete_module)
+  #define SYS_delete_module __NR_delete_module
+#endif
+#if defined(__NR_dup)
+  #define SYS_dup __NR_dup
+#endif
+#if defined(__NR_dup2)
+  #define SYS_dup2 __NR_dup2
+#endif
+#if defined(__NR_dup3)
+  #define SYS_dup3 __NR_dup3
+#endif
+#if defined(__NR_epoll_create)
+  #define SYS_epoll_create __NR_epoll_create
+#endif
+#if defined(__NR_epoll_create1)
+  #define SYS_epoll_create1 __NR_epoll_create1
+#endif
+#if defined(__NR_epoll_ctl)
+  #define SYS_epoll_ctl __NR_epoll_ctl
+#endif
+#if defined(__NR_epoll_ctl_old)
+  #define SYS_epoll_ctl_old __NR_epoll_ctl_old
+#endif
+#if defined(__NR_epoll_pwait)
+  #define SYS_epoll_pwait __NR_epoll_pwait
+#endif
+#if defined(__NR_epoll_wait)
+  #define SYS_epoll_wait __NR_epoll_wait
+#endif
+#if defined(__NR_epoll_wait_old)
+  #define SYS_epoll_wait_old __NR_epoll_wait_old
+#endif
+#if defined(__NR_eventfd)
+  #define SYS_eventfd __NR_eventfd
+#endif
+#if defined(__NR_eventfd2)
+  #define SYS_eventfd2 __NR_eventfd2
+#endif
+#if defined(__NR_execve)
+  #define SYS_execve __NR_execve
+#endif
+#if defined(__NR_execveat)
+  #define SYS_execveat __NR_execveat
+#endif
+#if defined(__NR_exit)
+  #define SYS_exit __NR_exit
+#endif
+#if defined(__NR_exit_group)
+  #define SYS_exit_group __NR_exit_group
+#endif
+#if defined(__NR_faccessat)
+  #define SYS_faccessat __NR_faccessat
+#endif
+#if defined(__NR_fadvise64)
+  #define SYS_fadvise64 __NR_fadvise64
+#endif
+#if defined(__NR_fadvise64_64)
+  #define SYS_fadvise64_64 __NR_fadvise64_64
+#endif
+#if defined(__NR_fallocate)
+  #define SYS_fallocate __NR_fallocate
+#endif
+#if defined(__NR_fanotify_init)
+  #define SYS_fanotify_init __NR_fanotify_init
+#endif
+#if defined(__NR_fanotify_mark)
+  #define SYS_fanotify_mark __NR_fanotify_mark
+#endif
+#if defined(__NR_fchdir)
+  #define SYS_fchdir __NR_fchdir
+#endif
+#if defined(__NR_fchmod)
+  #define SYS_fchmod __NR_fchmod
+#endif
+#if defined(__NR_fchmodat)
+  #define SYS_fchmodat __NR_fchmodat
+#endif
+#if defined(__NR_fchown)
+  #define SYS_fchown __NR_fchown
+#endif
+#if defined(__NR_fchown32)
+  #define SYS_fchown32 __NR_fchown32
+#endif
+#if defined(__NR_fchownat)
+  #define SYS_fchownat __NR_fchownat
+#endif
+#if defined(__NR_fcntl)
+  #define SYS_fcntl __NR_fcntl
+#endif
+#if defined(__NR_fcntl64)
+  #define SYS_fcntl64 __NR_fcntl64
+#endif
+#if defined(__NR_fdatasync)
+  #define SYS_fdatasync __NR_fdatasync
+#endif
+#if defined(__NR_fgetxattr)
+  #define SYS_fgetxattr __NR_fgetxattr
+#endif
+#if defined(__NR_finit_module)
+  #define SYS_finit_module __NR_finit_module
+#endif
+#if defined(__NR_flistxattr)
+  #define SYS_flistxattr __NR_flistxattr
+#endif
+#if defined(__NR_flock)
+  #define SYS_flock __NR_flock
+#endif
+#if defined(__NR_fork)
+  #define SYS_fork __NR_fork
+#endif
+#if defined(__NR_fremovexattr)
+  #define SYS_fremovexattr __NR_fremovexattr
+#endif
+#if defined(__NR_fsetxattr)
+  #define SYS_fsetxattr __NR_fsetxattr
+#endif
+#if defined(__NR_fstat)
+  #define SYS_fstat __NR_fstat
+#endif
+#if defined(__NR_fstat64)
+  #define SYS_fstat64 __NR_fstat64
+#endif
+#if defined(__NR_fstatat64)
+  #define SYS_fstatat64 __NR_fstatat64
+#endif
+#if defined(__NR_fstatfs)
+  #define SYS_fstatfs __NR_fstatfs
+#endif
+#if defined(__NR_fstatfs64)
+  #define SYS_fstatfs64 __NR_fstatfs64
+#endif
+#if defined(__NR_fsync)
+  #define SYS_fsync __NR_fsync
+#endif
+#if defined(__NR_ftime)
+  #define SYS_ftime __NR_ftime
+#endif
+#if defined(__NR_ftruncate)
+  #define SYS_ftruncate __NR_ftruncate
+#endif
+#if defined(__NR_ftruncate64)
+  #define SYS_ftruncate64 __NR_ftruncate64
+#endif
+#if defined(__NR_futex)
+  #define SYS_futex __NR_futex
+#endif
+#if defined(__NR_futimesat)
+  #define SYS_futimesat __NR_futimesat
+#endif
+#if defined(__NR_get_kernel_syms)
+  #define SYS_get_kernel_syms __NR_get_kernel_syms
+#endif
+#if defined(__NR_get_mempolicy)
+  #define SYS_get_mempolicy __NR_get_mempolicy
+#endif
+#if defined(__NR_get_robust_list)
+  #define SYS_get_robust_list __NR_get_robust_list
+#endif
+#if defined(__NR_get_thread_area)
+  #define SYS_get_thread_area __NR_get_thread_area
+#endif
+#if defined(__NR_getcpu)
+  #define SYS_getcpu __NR_getcpu
+#endif
+#if defined(__NR_getcwd)
+  #define SYS_getcwd __NR_getcwd
+#endif
+#if defined(__NR_getdents)
+  #define SYS_getdents __NR_getdents
+#endif
+#if defined(__NR_getdents64)
+  #define SYS_getdents64 __NR_getdents64
+#endif
+#if defined(__NR_getegid)
+  #define SYS_getegid __NR_getegid
+#endif
+#if defined(__NR_getegid32)
+  #define SYS_getegid32 __NR_getegid32
+#endif
+#if defined(__NR_geteuid)
+  #define SYS_geteuid __NR_geteuid
+#endif
+#if defined(__NR_geteuid32)
+  #define SYS_geteuid32 __NR_geteuid32
+#endif
+#if defined(__NR_getgid)
+  #define SYS_getgid __NR_getgid
+#endif
+#if defined(__NR_getgid32)
+  #define SYS_getgid32 __NR_getgid32
+#endif
+#if defined(__NR_getgroups)
+  #define SYS_getgroups __NR_getgroups
+#endif
+#if defined(__NR_getgroups32)
+  #define SYS_getgroups32 __NR_getgroups32
+#endif
+#if defined(__NR_getitimer)
+  #define SYS_getitimer __NR_getitimer
+#endif
+#if defined(__NR_getpeername)
+  #define SYS_getpeername __NR_getpeername
+#endif
+#if defined(__NR_getpgid)
+  #define SYS_getpgid __NR_getpgid
+#endif
+#if defined(__NR_getpgrp)
+  #define SYS_getpgrp __NR_getpgrp
+#endif
+#if defined(__NR_getpid)
+  #define SYS_getpid __NR_getpid
+#endif
+#if defined(__NR_getpmsg)
+  #define SYS_getpmsg __NR_getpmsg
+#endif
+#if defined(__NR_getppid)
+  #define SYS_getppid __NR_getppid
+#endif
+#if defined(__NR_getpriority)
+  #define SYS_getpriority __NR_getpriority
+#endif
+#if defined(__NR_getrandom)
+  #define SYS_getrandom __NR_getrandom
+#endif
+#if defined(__NR_getresgid)
+  #define SYS_getresgid __NR_getresgid
+#endif
+#if defined(__NR_getresgid32)
+  #define SYS_getresgid32 __NR_getresgid32
+#endif
+#if defined(__NR_getresuid)
+  #define SYS_getresuid __NR_getresuid
+#endif
+#if defined(__NR_getresuid32)
+  #define SYS_getresuid32 __NR_getresuid32
+#endif
+#if defined(__NR_getrlimit)
+  #define SYS_getrlimit __NR_getrlimit
+#endif
+#if defined(__NR_getrusage)
+  #define SYS_getrusage __NR_getrusage
+#endif
+#if defined(__NR_getsid)
+  #define SYS_getsid __NR_getsid
+#endif
+#if defined(__NR_getsockname)
+  #define SYS_getsockname __NR_getsockname
+#endif
+#if defined(__NR_getsockopt)
+  #define SYS_getsockopt __NR_getsockopt
+#endif
+#if defined(__NR_gettid)
+  #define SYS_gettid __NR_gettid
+#endif
+#if defined(__NR_gettimeofday)
+  #define SYS_gettimeofday __NR_gettimeofday
+#endif
+#if defined(__NR_getuid)
+  #define SYS_getuid __NR_getuid
+#endif
+#if defined(__NR_getuid32)
+  #define SYS_getuid32 __NR_getuid32
+#endif
+#if defined(__NR_getxattr)
+  #define SYS_getxattr __NR_getxattr
+#endif
+#if defined(__NR_gtty)
+  #define SYS_gtty __NR_gtty
+#endif
+#if defined(__NR_idle)
+  #define SYS_idle __NR_idle
+#endif
+#if defined(__NR_init_module)
+  #define SYS_init_module __NR_init_module
+#endif
+#if defined(__NR_inotify_add_watch)
+  #define SYS_inotify_add_watch __NR_inotify_add_watch
+#endif
+#if defined(__NR_inotify_init)
+  #define SYS_inotify_init __NR_inotify_init
+#endif
+#if defined(__NR_inotify_init1)
+  #define SYS_inotify_init1 __NR_inotify_init1
+#endif
+#if defined(__NR_inotify_rm_watch)
+  #define SYS_inotify_rm_watch __NR_inotify_rm_watch
+#endif
+#if defined(__NR_io_cancel)
+  #define SYS_io_cancel __NR_io_cancel
+#endif
+#if defined(__NR_io_destroy)
+  #define SYS_io_destroy __NR_io_destroy
+#endif
+#if defined(__NR_io_getevents)
+  #define SYS_io_getevents __NR_io_getevents
+#endif
+#if defined(__NR_io_setup)
+  #define SYS_io_setup __NR_io_setup
+#endif
+#if defined(__NR_io_submit)
+  #define SYS_io_submit __NR_io_submit
+#endif
+#if defined(__NR_ioctl)
+  #define SYS_ioctl __NR_ioctl
+#endif
+#if defined(__NR_ioperm)
+  #define SYS_ioperm __NR_ioperm
+#endif
+#if defined(__NR_iopl)
+  #define SYS_iopl __NR_iopl
+#endif
+#if defined(__NR_ioprio_get)
+  #define SYS_ioprio_get __NR_ioprio_get
+#endif
+#if defined(__NR_ioprio_set)
+  #define SYS_ioprio_set __NR_ioprio_set
+#endif
+#if defined(__NR_ipc)
+  #define SYS_ipc __NR_ipc
+#endif
+#if defined(__NR_kcmp)
+  #define SYS_kcmp __NR_kcmp
+#endif
+#if defined(__NR_kexec_file_load)
+  #define SYS_kexec_file_load __NR_kexec_file_load
+#endif
+#if defined(__NR_kexec_load)
+  #define SYS_kexec_load __NR_kexec_load
+#endif
+#if defined(__NR_keyctl)
+  #define SYS_keyctl __NR_keyctl
+#endif
+#if defined(__NR_kill)
+  #define SYS_kill __NR_kill
+#endif
+#if defined(__NR_lchown)
+  #define SYS_lchown __NR_lchown
+#endif
+#if defined(__NR_lchown32)
+  #define SYS_lchown32 __NR_lchown32
+#endif
+#if defined(__NR_lgetxattr)
+  #define SYS_lgetxattr __NR_lgetxattr
+#endif
+#if defined(__NR_link)
+  #define SYS_link __NR_link
+#endif
+#if defined(__NR_linkat)
+  #define SYS_linkat __NR_linkat
+#endif
+#if defined(__NR_listen)
+  #define SYS_listen __NR_listen
+#endif
+#if defined(__NR_listxattr)
+  #define SYS_listxattr __NR_listxattr
+#endif
+#if defined(__NR_llistxattr)
+  #define SYS_llistxattr __NR_llistxattr
+#endif
+#if defined(__NR_llseek)
+  #define SYS_llseek __NR_llseek
+#endif
+#if defined(__NR_lock)
+  #define SYS_lock __NR_lock
+#endif
+#if defined(__NR_lookup_dcookie)
+  #define SYS_lookup_dcookie __NR_lookup_dcookie
+#endif
+#if defined(__NR_lremovexattr)
+  #define SYS_lremovexattr __NR_lremovexattr
+#endif
+#if defined(__NR_lseek)
+  #define SYS_lseek __NR_lseek
+#endif
+#if defined(__NR_lsetxattr)
+  #define SYS_lsetxattr __NR_lsetxattr
+#endif
+#if defined(__NR_lstat)
+  #define SYS_lstat __NR_lstat
+#endif
+#if defined(__NR_lstat64)
+  #define SYS_lstat64 __NR_lstat64
+#endif
+#if defined(__NR_madvise)
+  #define SYS_madvise __NR_madvise
+#endif
+#if defined(__NR_mbind)
+  #define SYS_mbind __NR_mbind
+#endif
+#if defined(__NR_membarrier)
+  #define SYS_membarrier __NR_membarrier
+#endif
+#if defined(__NR_memfd_create)
+  #define SYS_memfd_create __NR_memfd_create
+#endif
+#if defined(__NR_migrate_pages)
+  #define SYS_migrate_pages __NR_migrate_pages
+#endif
+#if defined(__NR_mincore)
+  #define SYS_mincore __NR_mincore
+#endif
+#if defined(__NR_mkdir)
+  #define SYS_mkdir __NR_mkdir
+#endif
+#if defined(__NR_mkdirat)
+  #define SYS_mkdirat __NR_mkdirat
+#endif
+#if defined(__NR_mknod)
+  #define SYS_mknod __NR_mknod
+#endif
+#if defined(__NR_mknodat)
+  #define SYS_mknodat __NR_mknodat
+#endif
+#if defined(__NR_mlock)
+  #define SYS_mlock __NR_mlock
+#endif
+#if defined(__NR_mlock2)
+  #define SYS_mlock2 __NR_mlock2
+#endif
+#if defined(__NR_mlockall)
+  #define SYS_mlockall __NR_mlockall
+#endif
+#if defined(__NR_mmap)
+  #define SYS_mmap __NR_mmap
+#endif
+#if defined(__NR_mmap2)
+  #define SYS_mmap2 __NR_mmap2
+#endif
+#if defined(__NR_modify_ldt)
+  #define SYS_modify_ldt __NR_modify_ldt
+#endif
+#if defined(__NR_mount)
+  #define SYS_mount __NR_mount
+#endif
+#if defined(__NR_move_pages)
+  #define SYS_move_pages __NR_move_pages
+#endif
+#if defined(__NR_mprotect)
+  #define SYS_mprotect __NR_mprotect
+#endif
+#if defined(__NR_mpx)
+  #define SYS_mpx __NR_mpx
+#endif
+#if defined(__NR_mq_getsetattr)
+  #define SYS_mq_getsetattr __NR_mq_getsetattr
+#endif
+#if defined(__NR_mq_notify)
+  #define SYS_mq_notify __NR_mq_notify
+#endif
+#if defined(__NR_mq_open)
+  #define SYS_mq_open __NR_mq_open
+#endif
+#if defined(__NR_mq_timedreceive)
+  #define SYS_mq_timedreceive __NR_mq_timedreceive
+#endif
+#if defined(__NR_mq_timedsend)
+  #define SYS_mq_timedsend __NR_mq_timedsend
+#endif
+#if defined(__NR_mq_unlink)
+  #define SYS_mq_unlink __NR_mq_unlink
+#endif
+#if defined(__NR_mremap)
+  #define SYS_mremap __NR_mremap
+#endif
+#if defined(__NR_msgctl)
+  #define SYS_msgctl __NR_msgctl
+#endif
+#if defined(__NR_msgget)
+  #define SYS_msgget __NR_msgget
+#endif
+#if defined(__NR_msgrcv)
+  #define SYS_msgrcv __NR_msgrcv
+#endif
+#if defined(__NR_msgsnd)
+  #define SYS_msgsnd __NR_msgsnd
+#endif
+#if defined(__NR_msync)
+  #define SYS_msync __NR_msync
+#endif
+#if defined(__NR_munlock)
+  #define SYS_munlock __NR_munlock
+#endif
+#if defined(__NR_munlockall)
+  #define SYS_munlockall __NR_munlockall
+#endif
+#if defined(__NR_munmap)
+  #define SYS_munmap __NR_munmap
+#endif
+#if defined(__NR_name_to_handle_at)
+  #define SYS_name_to_handle_at __NR_name_to_handle_at
+#endif
+#if defined(__NR_nanosleep)
+  #define SYS_nanosleep __NR_nanosleep
+#endif
+#if defined(__NR_newfstatat)
+  #define SYS_newfstatat __NR_newfstatat
+#endif
+#if defined(__NR_nfsservctl)
+  #define SYS_nfsservctl __NR_nfsservctl
+#endif
+#if defined(__NR_nice)
+  #define SYS_nice __NR_nice
+#endif
+#if defined(__NR_oldfstat)
+  #define SYS_oldfstat __NR_oldfstat
+#endif
+#if defined(__NR_oldlstat)
+  #define SYS_oldlstat __NR_oldlstat
+#endif
+#if defined(__NR_oldolduname)
+  #define SYS_oldolduname __NR_oldolduname
+#endif
+#if defined(__NR_oldstat)
+  #define SYS_oldstat __NR_oldstat
+#endif
+#if defined(__NR_olduname)
+  #define SYS_olduname __NR_olduname
+#endif
+#if defined(__NR_oldwait4)
+  #define SYS_oldwait4 __NR_oldwait4
+#endif
+#if defined(__NR_open)
+  #define SYS_open __NR_open
+#endif
+#if defined(__NR_open_by_handle_at)
+  #define SYS_open_by_handle_at __NR_open_by_handle_at
+#endif
+#if defined(__NR_openat)
+  #define SYS_openat __NR_openat
+#endif
+#if defined(__NR_pause)
+  #define SYS_pause __NR_pause
+#endif
+#if defined(__NR_pciconfig_iobase)
+  #define SYS_pciconfig_iobase __NR_pciconfig_iobase
+#endif
+#if defined(__NR_pciconfig_read)
+  #define SYS_pciconfig_read __NR_pciconfig_read
+#endif
+#if defined(__NR_pciconfig_write)
+  #define SYS_pciconfig_write __NR_pciconfig_write
+#endif
+#if defined(__NR_perf_event_open)
+  #define SYS_perf_event_open __NR_perf_event_open
+#endif
+#if defined(__NR_personality)
+  #define SYS_personality __NR_personality
+#endif
+#if defined(__NR_pipe)
+  #define SYS_pipe __NR_pipe
+#endif
+#if defined(__NR_pipe2)
+  #define SYS_pipe2 __NR_pipe2
+#endif
+#if defined(__NR_pivot_root)
+  #define SYS_pivot_root __NR_pivot_root
+#endif
+#if defined(__NR_poll)
+  #define SYS_poll __NR_poll
+#endif
+#if defined(__NR_ppoll)
+  #define SYS_ppoll __NR_ppoll
+#endif
+#if defined(__NR_prctl)
+  #define SYS_prctl __NR_prctl
+#endif
+#if defined(__NR_pread64)
+  #define SYS_pread64 __NR_pread64
+#endif
+#if defined(__NR_preadv)
+  #define SYS_preadv __NR_preadv
+#endif
+#if defined(__NR_preadv2)
+  #define SYS_preadv2 __NR_preadv2
+#endif
+#if defined(__NR_prlimit64)
+  #define SYS_prlimit64 __NR_prlimit64
+#endif
+#if defined(__NR_process_vm_readv)
+  #define SYS_process_vm_readv __NR_process_vm_readv
+#endif
+#if defined(__NR_process_vm_writev)
+  #define SYS_process_vm_writev __NR_process_vm_writev
+#endif
+#if defined(__NR_prof)
+  #define SYS_prof __NR_prof
+#endif
+#if defined(__NR_profil)
+  #define SYS_profil __NR_profil
+#endif
+#if defined(__NR_pselect6)
+  #define SYS_pselect6 __NR_pselect6
+#endif
+#if defined(__NR_ptrace)
+  #define SYS_ptrace __NR_ptrace
+#endif
+#if defined(__NR_putpmsg)
+  #define SYS_putpmsg __NR_putpmsg
+#endif
+#if defined(__NR_pwrite64)
+  #define SYS_pwrite64 __NR_pwrite64
+#endif
+#if defined(__NR_pwritev)
+  #define SYS_pwritev __NR_pwritev
+#endif
+#if defined(__NR_pwritev2)
+  #define SYS_pwritev2 __NR_pwritev2
+#endif
+#if defined(__NR_query_module)
+  #define SYS_query_module __NR_query_module
+#endif
+#if defined(__NR_quotactl)
+  #define SYS_quotactl __NR_quotactl
+#endif
+#if defined(__NR_read)
+  #define SYS_read __NR_read
+#endif
+#if defined(__NR_readahead)
+  #define SYS_readahead __NR_readahead
+#endif
+#if defined(__NR_readdir)
+  #define SYS_readdir __NR_readdir
+#endif
+#if defined(__NR_readlink)
+  #define SYS_readlink __NR_readlink
+#endif
+#if defined(__NR_readlinkat)
+  #define SYS_readlinkat __NR_readlinkat
+#endif
+#if defined(__NR_readv)
+  #define SYS_readv __NR_readv
+#endif
+#if defined(__NR_reboot)
+  #define SYS_reboot __NR_reboot
+#endif
+#if defined(__NR_recv)
+  #define SYS_recv __NR_recv
+#endif
+#if defined(__NR_recvfrom)
+  #define SYS_recvfrom __NR_recvfrom
+#endif
+#if defined(__NR_recvmmsg)
+  #define SYS_recvmmsg __NR_recvmmsg
+#endif
+#if defined(__NR_recvmsg)
+  #define SYS_recvmsg __NR_recvmsg
+#endif
+#if defined(__NR_remap_file_pages)
+  #define SYS_remap_file_pages __NR_remap_file_pages
+#endif
+#if defined(__NR_removexattr)
+  #define SYS_removexattr __NR_removexattr
+#endif
+#if defined(__NR_rename)
+  #define SYS_rename __NR_rename
+#endif
+#if defined(__NR_renameat)
+  #define SYS_renameat __NR_renameat
+#endif
+#if defined(__NR_renameat2)
+  #define SYS_renameat2 __NR_renameat2
+#endif
+#if defined(__NR_request_key)
+  #define SYS_request_key __NR_request_key
+#endif
+#if defined(__NR_restart_syscall)
+  #define SYS_restart_syscall __NR_restart_syscall
+#endif
+#if defined(__NR_rmdir)
+  #define SYS_rmdir __NR_rmdir
+#endif
+#if defined(__NR_rt_sigaction)
+  #define SYS_rt_sigaction __NR_rt_sigaction
+#endif
+#if defined(__NR_rt_sigpending)
+  #define SYS_rt_sigpending __NR_rt_sigpending
+#endif
+#if defined(__NR_rt_sigprocmask)
+  #define SYS_rt_sigprocmask __NR_rt_sigprocmask
+#endif
+#if defined(__NR_rt_sigqueueinfo)
+  #define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
+#endif
+#if defined(__NR_rt_sigreturn)
+  #define SYS_rt_sigreturn __NR_rt_sigreturn
+#endif
+#if defined(__NR_rt_sigsuspend)
+  #define SYS_rt_sigsuspend __NR_rt_sigsuspend
+#endif
+#if defined(__NR_rt_sigtimedwait)
+  #define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
+#endif
+#if defined(__NR_rt_tgsigqueueinfo)
+  #define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
+#endif
+#if defined(__NR_sched_get_priority_max)
+  #define SYS_sched_get_priority_max __NR_sched_get_priority_max
+#endif
+#if defined(__NR_sched_get_priority_min)
+  #define SYS_sched_get_priority_min __NR_sched_get_priority_min
+#endif
+#if defined(__NR_sched_getaffinity)
+  #define SYS_sched_getaffinity __NR_sched_getaffinity
+#endif
+#if defined(__NR_sched_getattr)
+  #define SYS_sched_getattr __NR_sched_getattr
+#endif
+#if defined(__NR_sched_getparam)
+  #define SYS_sched_getparam __NR_sched_getparam
+#endif
+#if defined(__NR_sched_getscheduler)
+  #define SYS_sched_getscheduler __NR_sched_getscheduler
+#endif
+#if defined(__NR_sched_rr_get_interval)
+  #define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
+#endif
+#if defined(__NR_sched_setaffinity)
+  #define SYS_sched_setaffinity __NR_sched_setaffinity
+#endif
+#if defined(__NR_sched_setattr)
+  #define SYS_sched_setattr __NR_sched_setattr
+#endif
+#if defined(__NR_sched_setparam)
+  #define SYS_sched_setparam __NR_sched_setparam
+#endif
+#if defined(__NR_sched_setscheduler)
+  #define SYS_sched_setscheduler __NR_sched_setscheduler
+#endif
+#if defined(__NR_sched_yield)
+  #define SYS_sched_yield __NR_sched_yield
+#endif
+#if defined(__NR_seccomp)
+  #define SYS_seccomp __NR_seccomp
+#endif
+#if defined(__NR_security)
+  #define SYS_security __NR_security
+#endif
+#if defined(__NR_select)
+  #define SYS_select __NR_select
+#endif
+#if defined(__NR_semctl)
+  #define SYS_semctl __NR_semctl
+#endif
+#if defined(__NR_semget)
+  #define SYS_semget __NR_semget
+#endif
+#if defined(__NR_semop)
+  #define SYS_semop __NR_semop
+#endif
+#if defined(__NR_semtimedop)
+  #define SYS_semtimedop __NR_semtimedop
+#endif
+#if defined(__NR_send)
+  #define SYS_send __NR_send
+#endif
+#if defined(__NR_sendfile)
+  #define SYS_sendfile __NR_sendfile
+#endif
+#if defined(__NR_sendfile64)
+  #define SYS_sendfile64 __NR_sendfile64
+#endif
+#if defined(__NR_sendmmsg)
+  #define SYS_sendmmsg __NR_sendmmsg
+#endif
+#if defined(__NR_sendmsg)
+  #define SYS_sendmsg __NR_sendmsg
+#endif
+#if defined(__NR_sendto)
+  #define SYS_sendto __NR_sendto
+#endif
+#if defined(__NR_set_mempolicy)
+  #define SYS_set_mempolicy __NR_set_mempolicy
+#endif
+#if defined(__NR_set_robust_list)
+  #define SYS_set_robust_list __NR_set_robust_list
+#endif
+#if defined(__NR_set_thread_area)
+  #define SYS_set_thread_area __NR_set_thread_area
+#endif
+#if defined(__NR_set_tid_address)
+  #define SYS_set_tid_address __NR_set_tid_address
+#endif
+#if defined(__NR_setdomainname)
+  #define SYS_setdomainname __NR_setdomainname
+#endif
+#if defined(__NR_setfsgid)
+  #define SYS_setfsgid __NR_setfsgid
+#endif
+#if defined(__NR_setfsgid32)
+  #define SYS_setfsgid32 __NR_setfsgid32
+#endif
+#if defined(__NR_setfsuid)
+  #define SYS_setfsuid __NR_setfsuid
+#endif
+#if defined(__NR_setfsuid32)
+  #define SYS_setfsuid32 __NR_setfsuid32
+#endif
+#if defined(__NR_setgid)
+  #define SYS_setgid __NR_setgid
+#endif
+#if defined(__NR_setgid32)
+  #define SYS_setgid32 __NR_setgid32
+#endif
+#if defined(__NR_setgroups)
+  #define SYS_setgroups __NR_setgroups
+#endif
+#if defined(__NR_setgroups32)
+  #define SYS_setgroups32 __NR_setgroups32
+#endif
+#if defined(__NR_sethostname)
+  #define SYS_sethostname __NR_sethostname
+#endif
+#if defined(__NR_setitimer)
+  #define SYS_setitimer __NR_setitimer
+#endif
+#if defined(__NR_setns)
+  #define SYS_setns __NR_setns
+#endif
+#if defined(__NR_setpgid)
+  #define SYS_setpgid __NR_setpgid
+#endif
+#if defined(__NR_setpriority)
+  #define SYS_setpriority __NR_setpriority
+#endif
+#if defined(__NR_setregid)
+  #define SYS_setregid __NR_setregid
+#endif
+#if defined(__NR_setregid32)
+  #define SYS_setregid32 __NR_setregid32
+#endif
+#if defined(__NR_setresgid)
+  #define SYS_setresgid __NR_setresgid
+#endif
+#if defined(__NR_setresgid32)
+  #define SYS_setresgid32 __NR_setresgid32
+#endif
+#if defined(__NR_setresuid)
+  #define SYS_setresuid __NR_setresuid
+#endif
+#if defined(__NR_setresuid32)
+  #define SYS_setresuid32 __NR_setresuid32
+#endif
+#if defined(__NR_setreuid)
+  #define SYS_setreuid __NR_setreuid
+#endif
+#if defined(__NR_setreuid32)
+  #define SYS_setreuid32 __NR_setreuid32
+#endif
+#if defined(__NR_setrlimit)
+  #define SYS_setrlimit __NR_setrlimit
+#endif
+#if defined(__NR_setsid)
+  #define SYS_setsid __NR_setsid
+#endif
+#if defined(__NR_setsockopt)
+  #define SYS_setsockopt __NR_setsockopt
+#endif
+#if defined(__NR_settimeofday)
+  #define SYS_settimeofday __NR_settimeofday
+#endif
+#if defined(__NR_setuid)
+  #define SYS_setuid __NR_setuid
+#endif
+#if defined(__NR_setuid32)
+  #define SYS_setuid32 __NR_setuid32
+#endif
+#if defined(__NR_setxattr)
+  #define SYS_setxattr __NR_setxattr
+#endif
+#if defined(__NR_sgetmask)
+  #define SYS_sgetmask __NR_sgetmask
+#endif
+#if defined(__NR_shmat)
+  #define SYS_shmat __NR_shmat
+#endif
+#if defined(__NR_shmctl)
+  #define SYS_shmctl __NR_shmctl
+#endif
+#if defined(__NR_shmdt)
+  #define SYS_shmdt __NR_shmdt
+#endif
+#if defined(__NR_shmget)
+  #define SYS_shmget __NR_shmget
+#endif
+#if defined(__NR_shutdown)
+  #define SYS_shutdown __NR_shutdown
+#endif
+#if defined(__NR_sigaction)
+  #define SYS_sigaction __NR_sigaction
+#endif
+#if defined(__NR_sigaltstack)
+  #define SYS_sigaltstack __NR_sigaltstack
+#endif
+#if defined(__NR_signal)
+  #define SYS_signal __NR_signal
+#endif
+#if defined(__NR_signalfd)
+  #define SYS_signalfd __NR_signalfd
+#endif
+#if defined(__NR_signalfd4)
+  #define SYS_signalfd4 __NR_signalfd4
+#endif
+#if defined(__NR_sigpending)
+  #define SYS_sigpending __NR_sigpending
+#endif
+#if defined(__NR_sigprocmask)
+  #define SYS_sigprocmask __NR_sigprocmask
+#endif
+#if defined(__NR_sigreturn)
+  #define SYS_sigreturn __NR_sigreturn
+#endif
+#if defined(__NR_sigsuspend)
+  #define SYS_sigsuspend __NR_sigsuspend
+#endif
+#if defined(__NR_socket)
+  #define SYS_socket __NR_socket
+#endif
+#if defined(__NR_socketcall)
+  #define SYS_socketcall __NR_socketcall
+#endif
+#if defined(__NR_socketpair)
+  #define SYS_socketpair __NR_socketpair
+#endif
+#if defined(__NR_splice)
+  #define SYS_splice __NR_splice
+#endif
+#if defined(__NR_ssetmask)
+  #define SYS_ssetmask __NR_ssetmask
+#endif
+#if defined(__NR_stat)
+  #define SYS_stat __NR_stat
+#endif
+#if defined(__NR_stat64)
+  #define SYS_stat64 __NR_stat64
+#endif
+#if defined(__NR_statfs)
+  #define SYS_statfs __NR_statfs
+#endif
+#if defined(__NR_statfs64)
+  #define SYS_statfs64 __NR_statfs64
+#endif
+#if defined(__NR_stime)
+  #define SYS_stime __NR_stime
+#endif
+#if defined(__NR_stty)
+  #define SYS_stty __NR_stty
+#endif
+#if defined(__NR_swapoff)
+  #define SYS_swapoff __NR_swapoff
+#endif
+#if defined(__NR_swapon)
+  #define SYS_swapon __NR_swapon
+#endif
+#if defined(__NR_symlink)
+  #define SYS_symlink __NR_symlink
+#endif
+#if defined(__NR_symlinkat)
+  #define SYS_symlinkat __NR_symlinkat
+#endif
+#if defined(__NR_sync)
+  #define SYS_sync __NR_sync
+#endif
+#if defined(__NR_sync_file_range)
+  #define SYS_sync_file_range __NR_sync_file_range
+#endif
+#if defined(__NR_sync_file_range2)
+  #define SYS_sync_file_range2 __NR_sync_file_range2
+#endif
+#if defined(__NR_syncfs)
+  #define SYS_syncfs __NR_syncfs
+#endif
+#if defined(__NR_syscall)
+  #define SYS_syscall __NR_syscall
+#endif
+#if defined(__NR_syscalls)
+  #define SYS_syscalls __NR_syscalls
+#endif
+#if defined(__NR_sysfs)
+  #define SYS_sysfs __NR_sysfs
+#endif
+#if defined(__NR_sysinfo)
+  #define SYS_sysinfo __NR_sysinfo
+#endif
+#if defined(__NR_syslog)
+  #define SYS_syslog __NR_syslog
+#endif
+#if defined(__NR_sysmips)
+  #define SYS_sysmips __NR_sysmips
+#endif
+#if defined(__NR_tee)
+  #define SYS_tee __NR_tee
+#endif
+#if defined(__NR_tgkill)
+  #define SYS_tgkill __NR_tgkill
+#endif
+#if defined(__NR_time)
+  #define SYS_time __NR_time
+#endif
+#if defined(__NR_timer_create)
+  #define SYS_timer_create __NR_timer_create
+#endif
+#if defined(__NR_timer_delete)
+  #define SYS_timer_delete __NR_timer_delete
+#endif
+#if defined(__NR_timer_getoverrun)
+  #define SYS_timer_getoverrun __NR_timer_getoverrun
+#endif
+#if defined(__NR_timer_gettime)
+  #define SYS_timer_gettime __NR_timer_gettime
+#endif
+#if defined(__NR_timer_settime)
+  #define SYS_timer_settime __NR_timer_settime
+#endif
+#if defined(__NR_timerfd)
+  #define SYS_timerfd __NR_timerfd
+#endif
+#if defined(__NR_timerfd_create)
+  #define SYS_timerfd_create __NR_timerfd_create
+#endif
+#if defined(__NR_timerfd_gettime)
+  #define SYS_timerfd_gettime __NR_timerfd_gettime
+#endif
+#if defined(__NR_timerfd_settime)
+  #define SYS_timerfd_settime __NR_timerfd_settime
+#endif
+#if defined(__NR_times)
+  #define SYS_times __NR_times
+#endif
+#if defined(__NR_tkill)
+  #define SYS_tkill __NR_tkill
+#endif
+#if defined(__NR_truncate)
+  #define SYS_truncate __NR_truncate
+#endif
+#if defined(__NR_truncate64)
+  #define SYS_truncate64 __NR_truncate64
+#endif
+#if defined(__NR_tuxcall)
+  #define SYS_tuxcall __NR_tuxcall
+#endif
+#if defined(__NR_ugetrlimit)
+  #define SYS_ugetrlimit __NR_ugetrlimit
+#endif
+#if defined(__NR_ulimit)
+  #define SYS_ulimit __NR_ulimit
+#endif
+#if defined(__NR_umask)
+  #define SYS_umask __NR_umask
+#endif
+#if defined(__NR_umount)
+  #define SYS_umount __NR_umount
+#endif
+#if defined(__NR_umount2)
+  #define SYS_umount2 __NR_umount2
+#endif
+#if defined(__NR_uname)
+  #define SYS_uname __NR_uname
+#endif
+#if defined(__NR_unlink)
+  #define SYS_unlink __NR_unlink
+#endif
+#if defined(__NR_unlinkat)
+  #define SYS_unlinkat __NR_unlinkat
+#endif
+#if defined(__NR_unshare)
+  #define SYS_unshare __NR_unshare
+#endif
+#if defined(__NR_uselib)
+  #define SYS_uselib __NR_uselib
+#endif
+#if defined(__NR_userfaultfd)
+  #define SYS_userfaultfd __NR_userfaultfd
+#endif
+#if defined(__NR_ustat)
+  #define SYS_ustat __NR_ustat
+#endif
+#if defined(__NR_utime)
+  #define SYS_utime __NR_utime
+#endif
+#if defined(__NR_utimensat)
+  #define SYS_utimensat __NR_utimensat
+#endif
+#if defined(__NR_utimes)
+  #define SYS_utimes __NR_utimes
+#endif
+#if defined(__NR_vfork)
+  #define SYS_vfork __NR_vfork
+#endif
+#if defined(__NR_vhangup)
+  #define SYS_vhangup __NR_vhangup
+#endif
+#if defined(__NR_vm86)
+  #define SYS_vm86 __NR_vm86
+#endif
+#if defined(__NR_vm86old)
+  #define SYS_vm86old __NR_vm86old
+#endif
+#if defined(__NR_vmsplice)
+  #define SYS_vmsplice __NR_vmsplice
+#endif
+#if defined(__NR_vserver)
+  #define SYS_vserver __NR_vserver
+#endif
+#if defined(__NR_wait4)
+  #define SYS_wait4 __NR_wait4
+#endif
+#if defined(__NR_waitid)
+  #define SYS_waitid __NR_waitid
+#endif
+#if defined(__NR_waitpid)
+  #define SYS_waitpid __NR_waitpid
+#endif
+#if defined(__NR_write)
+  #define SYS_write __NR_write
+#endif
+#if defined(__NR_writev)
+  #define SYS_writev __NR_writev
+#endif
+#endif /* _BIONIC_BITS_GLIBC_SYSCALLS_H_ */
diff --git a/libc/include/sys/utime.h b/libc/include/bits/ioctl.h
similarity index 87%
copy from libc/include/sys/utime.h
copy to libc/include/bits/ioctl.h
index 9f8810e..53116ca 100644
--- a/libc/include/sys/utime.h
+++ b/libc/include/bits/ioctl.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,9 +25,16 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _SYS_UTIME_H_
-#define _SYS_UTIME_H_
 
-#include <linux/utime.h>
+#ifndef _BITS_IOCTL_H_
+#define _BITS_IOCTL_H_
 
-#endif /* _SYS_UTIME_H_ */
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+int ioctl(int, int, ...);
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/bits/lockf.h b/libc/include/bits/lockf.h
index d814807..655514d 100644
--- a/libc/include/bits/lockf.h
+++ b/libc/include/bits/lockf.h
@@ -30,6 +30,7 @@
 #define _BITS_LOCKF_H_
 
 #include <sys/cdefs.h>
+#include <sys/types.h>
 
 #define F_ULOCK 0
 #define F_LOCK 1
@@ -41,9 +42,9 @@
 #if defined(__USE_FILE_OFFSET64)
 int lockf(int, int, off_t) __RENAME(lockf64);
 #else
-int lockf(int, int, off_t);
+int lockf(int, int, off_t) __INTRODUCED_IN(24);
 #endif
-int lockf64(int, int, off64_t);
+int lockf64(int, int, off64_t) __INTRODUCED_IN(24);
 
 __END_DECLS
 
diff --git a/libstdc++/include/utility b/libc/include/bits/mbstate_t.h
similarity index 83%
copy from libstdc++/include/utility
copy to libc/include/bits/mbstate_t.h
index 12044a7..057a2c9 100644
--- a/libstdc++/include/utility
+++ b/libc/include/bits/mbstate_t.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,14 +25,17 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _CPP_UTILITY
-#define _CPP_UTILITY
 
-#pragma GCC system_header
+#ifndef _BITS_MBSTATE_T_H_
+#define _BITS_MBSTATE_T_H_
 
-#define  __STL_BEGIN_NAMESPACE  namespace std {
-#define  __STL_END_NAMESPACE    }
+#include <sys/cdefs.h>
 
-#include <stl_pair.h>
+typedef struct {
+  unsigned char __seq[4];
+#ifdef __LP64__
+  unsigned char __reserved[4];
+#endif
+} mbstate_t;
 
-#endif /* _CPP_UTILITY */
+#endif
diff --git a/libc/include/bits/posix_limits.h b/libc/include/bits/posix_limits.h
index 31016a8..c498c69 100644
--- a/libc/include/bits/posix_limits.h
+++ b/libc/include/bits/posix_limits.h
@@ -29,15 +29,16 @@
 #ifndef _BITS_POSIX_LIMITS_H_
 #define _BITS_POSIX_LIMITS_H_
 
+#include <sys/cdefs.h>
 
 /* Any constant values here other than -1 or 200809L are explicitly specified by POSIX.1-2008. */
-/* Keep it sorted. */
+/* Keep this list sorted by name. */
 #define _POSIX_ADVISORY_INFO        200809L
 #define _POSIX_AIO_LISTIO_MAX       2
 #define _POSIX_AIO_MAX              1
 #define _POSIX_ARG_MAX              4096
 #define _POSIX_ASYNCHRONOUS_IO      -1  /* not implemented */
-#define _POSIX_BARRIERS             -1  /* not implemented */
+#define _POSIX_BARRIERS             200809L
 #define _POSIX_CHILD_MAX            25
 #define _POSIX_CHOWN_RESTRICTED     1  /* yes, chown requires appropriate privileges */
 #define _POSIX_CLOCK_SELECTION      200809L
@@ -80,7 +81,7 @@
 #define _POSIX_SHELL                1   /* system() supported */
 #define _POSIX_SIGQUEUE_MAX         32
 #define _POSIX_SPAWN                -1  /* not implemented */
-#define _POSIX_SPIN_LOCKS           -1  /* not implemented */
+#define _POSIX_SPIN_LOCKS           200809L
 #define _POSIX_SPORADIC_SERVER      -1  /* not implemented */
 #define _POSIX_SSIZE_MAX            32767
 #define _POSIX_STREAM_MAX           8
@@ -94,8 +95,8 @@
 #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
 #define _POSIX_THREAD_KEYS_MAX      128
 #define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
-#define _POSIX_THREAD_PRIO_INHERIT  200809L  /* linux feature */
-#define _POSIX_THREAD_PRIO_PROTECT  200809L  /* linux feature */
+#define _POSIX_THREAD_PRIO_INHERIT -1  /* not implemented */
+#define _POSIX_THREAD_PRIO_PROTECT -1  /* not implemented */
 #define _POSIX_THREAD_PROCESS_SHARED  -1  /* not implemented */
 #define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1  /* not implemented */
 #define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1  /* not implemented */
diff --git a/libc/include/bits/pthread_types.h b/libc/include/bits/pthread_types.h
index 6ac1c68..7fc379b 100644
--- a/libc/include/bits/pthread_types.h
+++ b/libc/include/bits/pthread_types.h
@@ -29,10 +29,9 @@
 #ifndef _BITS_PTHREAD_TYPES_H_
 #define _BITS_PTHREAD_TYPES_H_
 
+#include <sys/cdefs.h>
 #include <sys/types.h>
 
-typedef long pthread_t;
-
 typedef struct {
   uint32_t flags;
   void* stack_base;
@@ -45,4 +44,58 @@
 #endif
 } pthread_attr_t;
 
+typedef struct {
+#if defined(__LP64__)
+  int64_t __private[4];
+#else
+  int32_t __private[8];
+#endif
+} pthread_barrier_t;
+
+typedef int pthread_barrierattr_t;
+
+typedef struct {
+#if defined(__LP64__)
+  int32_t __private[12];
+#else
+  int32_t __private[1];
+#endif
+} pthread_cond_t;
+
+typedef long pthread_condattr_t;
+
+typedef int pthread_key_t;
+
+typedef struct {
+#if defined(__LP64__)
+  int32_t __private[10];
+#else
+  int32_t __private[1];
+#endif
+} pthread_mutex_t;
+
+typedef long pthread_mutexattr_t;
+
+typedef int pthread_once_t;
+
+typedef struct {
+#if defined(__LP64__)
+  int32_t __private[14];
+#else
+  int32_t __private[10];
+#endif
+} pthread_rwlock_t;
+
+typedef long pthread_rwlockattr_t;
+
+typedef struct {
+#if defined(__LP64__)
+  int64_t __private;
+#else
+  int32_t __private[2];
+#endif
+} pthread_spinlock_t;
+
+typedef long pthread_t;
+
 #endif
diff --git a/libstdc++/include/cwchar b/libc/include/bits/sa_family_t.h
similarity index 87%
copy from libstdc++/include/cwchar
copy to libc/include/bits/sa_family_t.h
index a4f9f42..98ca27f 100644
--- a/libstdc++/include/cwchar
+++ b/libc/include/bits/sa_family_t.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,5 +26,11 @@
  * SUCH DAMAGE.
  */
 
-/* IMPORTANT: cwchar and cwctype are not supported. See comment in
- * bionic/libc/include/wchar.h */
+#ifndef _BITS_SA_FAMILY_T_H_
+#define _BITS_SA_FAMILY_T_H_
+
+#include <sys/cdefs.h>
+
+typedef unsigned short sa_family_t;
+
+#endif
diff --git a/libstdc++/include/cwchar b/libc/include/bits/seek_constants.h
similarity index 87%
rename from libstdc++/include/cwchar
rename to libc/include/bits/seek_constants.h
index a4f9f42..34c5866 100644
--- a/libstdc++/include/cwchar
+++ b/libc/include/bits/seek_constants.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,5 +26,11 @@
  * SUCH DAMAGE.
  */
 
-/* IMPORTANT: cwchar and cwctype are not supported. See comment in
- * bionic/libc/include/wchar.h */
+#ifndef _BITS_SEEK_CONSTANTS_H_
+#define _BITS_SEEK_CONSTANTS_H_
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#endif
diff --git a/libstdc++/include/cassert b/libc/include/bits/strcasecmp.h
similarity index 71%
copy from libstdc++/include/cassert
copy to libc/include/bits/strcasecmp.h
index 5753e34..df1a6b8 100644
--- a/libstdc++/include/cassert
+++ b/libc/include/bits/strcasecmp.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,13 +26,20 @@
  * SUCH DAMAGE.
  */
 
-/*
- * Standard C++ Library wrapper around the C assert.h header file.  This file
- * can be included multiple times with different definition of NDEBUG, hence the
- * absence of include guards.
- */
+#ifndef _BITS_STRCASECMP_H_
+#define _BITS_STRCASECMP_H_
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CASSERT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CASSERT__
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <xlocale.h>
+
+__BEGIN_DECLS
+
+int strcasecmp(const char*, const char*) __attribute_pure__;
+int strcasecmp_l(const char*, const char*, locale_t) __attribute_pure__ __INTRODUCED_IN(23);
+int strncasecmp(const char*, const char*, size_t) __attribute_pure__;
+int strncasecmp_l(const char*, const char*, size_t, locale_t) __attribute_pure__ __INTRODUCED_IN(23);
+
+__END_DECLS
+
 #endif
-#include <assert.h>
diff --git a/libstdc++/include/cstdint b/libc/include/bits/struct_file.h
similarity index 80%
rename from libstdc++/include/cstdint
rename to libc/include/bits/struct_file.h
index 3df56df..08e18a1 100644
--- a/libstdc++/include/cstdint
+++ b/libc/include/bits/struct_file.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,14 +26,21 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+#ifndef BITS_FILE_H
+#define BITS_FILE_H
 
-/*
- * Standard C++ Library wrapper around the C stdint.h header file.
- */
+#include <sys/cdefs.h>
 
-#include <stdint.h>
+__BEGIN_DECLS
 
+struct __sFILE {
+#if defined(__LP64__)
+  char __private[152];
+#else
+  char __private[84];
+#endif
+} __attribute__((aligned(sizeof(void*))));
 
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+__END_DECLS
+
+#endif /* BITS_FILE_H */
diff --git a/libc/include/bits/sysconf.h b/libc/include/bits/sysconf.h
new file mode 100644
index 0000000..2cbbb11
--- /dev/null
+++ b/libc/include/bits/sysconf.h
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BITS_SYSCONF_H_
+#define _BITS_SYSCONF_H_
+
+#include <sys/cdefs.h>
+
+/* as listed by Posix sysconf() description */
+/* most of these will return -1 and ENOSYS  */
+
+#define _SC_ARG_MAX             0x0000
+#define _SC_BC_BASE_MAX         0x0001
+#define _SC_BC_DIM_MAX          0x0002
+#define _SC_BC_SCALE_MAX        0x0003
+#define _SC_BC_STRING_MAX       0x0004
+#define _SC_CHILD_MAX           0x0005
+#define _SC_CLK_TCK             0x0006
+#define _SC_COLL_WEIGHTS_MAX    0x0007
+#define _SC_EXPR_NEST_MAX       0x0008
+#define _SC_LINE_MAX            0x0009
+#define _SC_NGROUPS_MAX         0x000a
+#define _SC_OPEN_MAX            0x000b
+#define _SC_PASS_MAX            0x000c
+#define _SC_2_C_BIND            0x000d
+#define _SC_2_C_DEV             0x000e
+#define _SC_2_C_VERSION         0x000f  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_2_CHAR_TERM         0x0010
+#define _SC_2_FORT_DEV          0x0011
+#define _SC_2_FORT_RUN          0x0012
+#define _SC_2_LOCALEDEF         0x0013
+#define _SC_2_SW_DEV            0x0014
+#define _SC_2_UPE               0x0015
+#define _SC_2_VERSION           0x0016
+#define _SC_JOB_CONTROL         0x0017
+#define _SC_SAVED_IDS           0x0018
+#define _SC_VERSION             0x0019
+#define _SC_RE_DUP_MAX          0x001a
+#define _SC_STREAM_MAX          0x001b
+#define _SC_TZNAME_MAX          0x001c
+#define _SC_XOPEN_CRYPT         0x001d
+#define _SC_XOPEN_ENH_I18N      0x001e
+#define _SC_XOPEN_SHM           0x001f
+#define _SC_XOPEN_VERSION       0x0020
+#define _SC_XOPEN_XCU_VERSION   0x0021  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XOPEN_REALTIME      0x0022
+#define _SC_XOPEN_REALTIME_THREADS  0x0023
+#define _SC_XOPEN_LEGACY        0x0024
+#define _SC_ATEXIT_MAX          0x0025
+#define _SC_IOV_MAX             0x0026
+#define _SC_PAGESIZE            0x0027
+#define _SC_PAGE_SIZE           0x0028
+#define _SC_XOPEN_UNIX          0x0029
+#define _SC_XBS5_ILP32_OFF32    0x002a  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XBS5_ILP32_OFFBIG   0x002b  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XBS5_LP64_OFF64     0x002c  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XBS5_LPBIG_OFFBIG   0x002d  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_AIO_LISTIO_MAX      0x002e
+#define _SC_AIO_MAX             0x002f
+#define _SC_AIO_PRIO_DELTA_MAX  0x0030
+#define _SC_DELAYTIMER_MAX      0x0031
+#define _SC_MQ_OPEN_MAX         0x0032
+#define _SC_MQ_PRIO_MAX         0x0033
+#define _SC_RTSIG_MAX           0x0034
+#define _SC_SEM_NSEMS_MAX       0x0035
+#define _SC_SEM_VALUE_MAX       0x0036
+#define _SC_SIGQUEUE_MAX        0x0037
+#define _SC_TIMER_MAX           0x0038
+#define _SC_ASYNCHRONOUS_IO     0x0039
+#define _SC_FSYNC               0x003a
+#define _SC_MAPPED_FILES        0x003b
+#define _SC_MEMLOCK             0x003c
+#define _SC_MEMLOCK_RANGE       0x003d
+#define _SC_MEMORY_PROTECTION   0x003e
+#define _SC_MESSAGE_PASSING     0x003f
+#define _SC_PRIORITIZED_IO      0x0040
+#define _SC_PRIORITY_SCHEDULING 0x0041
+#define _SC_REALTIME_SIGNALS    0x0042
+#define _SC_SEMAPHORES          0x0043
+#define _SC_SHARED_MEMORY_OBJECTS  0x0044
+#define _SC_SYNCHRONIZED_IO     0x0045
+#define _SC_TIMERS              0x0046
+#define _SC_GETGR_R_SIZE_MAX    0x0047
+#define _SC_GETPW_R_SIZE_MAX    0x0048
+#define _SC_LOGIN_NAME_MAX      0x0049
+#define _SC_THREAD_DESTRUCTOR_ITERATIONS  0x004a
+#define _SC_THREAD_KEYS_MAX     0x004b
+#define _SC_THREAD_STACK_MIN    0x004c
+#define _SC_THREAD_THREADS_MAX  0x004d
+#define _SC_TTY_NAME_MAX        0x004e
+
+#define _SC_THREADS                     0x004f
+#define _SC_THREAD_ATTR_STACKADDR       0x0050
+#define _SC_THREAD_ATTR_STACKSIZE       0x0051
+#define _SC_THREAD_PRIORITY_SCHEDULING  0x0052
+#define _SC_THREAD_PRIO_INHERIT         0x0053
+#define _SC_THREAD_PRIO_PROTECT         0x0054
+#define _SC_THREAD_SAFE_FUNCTIONS       0x0055
+
+#define _SC_NPROCESSORS_CONF            0x0060
+#define _SC_NPROCESSORS_ONLN            0x0061
+#define _SC_PHYS_PAGES                  0x0062
+#define _SC_AVPHYS_PAGES                0x0063
+#define _SC_MONOTONIC_CLOCK             0x0064
+
+#define _SC_2_PBS               0x0065
+#define _SC_2_PBS_ACCOUNTING    0x0066
+#define _SC_2_PBS_CHECKPOINT    0x0067
+#define _SC_2_PBS_LOCATE        0x0068
+#define _SC_2_PBS_MESSAGE       0x0069
+#define _SC_2_PBS_TRACK         0x006a
+#define _SC_ADVISORY_INFO       0x006b
+#define _SC_BARRIERS            0x006c
+#define _SC_CLOCK_SELECTION     0x006d
+#define _SC_CPUTIME             0x006e
+#define _SC_HOST_NAME_MAX       0x006f
+#define _SC_IPV6                0x0070
+#define _SC_RAW_SOCKETS         0x0071
+#define _SC_READER_WRITER_LOCKS 0x0072
+#define _SC_REGEXP              0x0073
+#define _SC_SHELL               0x0074
+#define _SC_SPAWN               0x0075
+#define _SC_SPIN_LOCKS          0x0076
+#define _SC_SPORADIC_SERVER     0x0077
+#define _SC_SS_REPL_MAX         0x0078
+#define _SC_SYMLOOP_MAX         0x0079
+#define _SC_THREAD_CPUTIME      0x007a
+#define _SC_THREAD_PROCESS_SHARED       0x007b
+#define _SC_THREAD_ROBUST_PRIO_INHERIT  0x007c
+#define _SC_THREAD_ROBUST_PRIO_PROTECT  0x007d
+#define _SC_THREAD_SPORADIC_SERVER      0x007e
+#define _SC_TIMEOUTS            0x007f
+#define _SC_TRACE               0x0080
+#define _SC_TRACE_EVENT_FILTER  0x0081
+#define _SC_TRACE_EVENT_NAME_MAX  0x0082
+#define _SC_TRACE_INHERIT       0x0083
+#define _SC_TRACE_LOG           0x0084
+#define _SC_TRACE_NAME_MAX      0x0085
+#define _SC_TRACE_SYS_MAX       0x0086
+#define _SC_TRACE_USER_EVENT_MAX  0x0087
+#define _SC_TYPED_MEMORY_OBJECTS  0x0088
+#define _SC_V7_ILP32_OFF32      0x0089
+#define _SC_V7_ILP32_OFFBIG     0x008a
+#define _SC_V7_LP64_OFF64       0x008b
+#define _SC_V7_LPBIG_OFFBIG     0x008c
+#define _SC_XOPEN_STREAMS       0x008d
+#define _SC_XOPEN_UUCP          0x008e
+
+#define _SC_LEVEL1_ICACHE_SIZE      0x008f
+#define _SC_LEVEL1_ICACHE_ASSOC     0x0090
+#define _SC_LEVEL1_ICACHE_LINESIZE  0x0091
+#define _SC_LEVEL1_DCACHE_SIZE      0x0092
+#define _SC_LEVEL1_DCACHE_ASSOC     0x0093
+#define _SC_LEVEL1_DCACHE_LINESIZE  0x0094
+#define _SC_LEVEL2_CACHE_SIZE       0x0095
+#define _SC_LEVEL2_CACHE_ASSOC      0x0096
+#define _SC_LEVEL2_CACHE_LINESIZE   0x0097
+#define _SC_LEVEL3_CACHE_SIZE       0x0098
+#define _SC_LEVEL3_CACHE_ASSOC      0x0099
+#define _SC_LEVEL3_CACHE_LINESIZE   0x009a
+#define _SC_LEVEL4_CACHE_SIZE       0x009b
+#define _SC_LEVEL4_CACHE_ASSOC      0x009c
+#define _SC_LEVEL4_CACHE_LINESIZE   0x009d
+
+__BEGIN_DECLS
+
+long sysconf(int __name);
+
+__END_DECLS
+
+#endif /* _SYS_SYSCONF_H_ */
diff --git a/libc/include/bits/timespec.h b/libc/include/bits/timespec.h
index 046d898..df7a7ce 100644
--- a/libc/include/bits/timespec.h
+++ b/libc/include/bits/timespec.h
@@ -29,6 +29,7 @@
 #ifndef _BITS_TIMESPEC_H_
 #define _BITS_TIMESPEC_H_
 
+#include <sys/cdefs.h>
 #include <sys/types.h>
 
 /*
diff --git a/libc/include/bits/wchar_limits.h b/libc/include/bits/wchar_limits.h
index f779c1a..ffad604 100644
--- a/libc/include/bits/wchar_limits.h
+++ b/libc/include/bits/wchar_limits.h
@@ -29,6 +29,8 @@
 #ifndef _BITS_WCHAR_LIMITS_H_
 #define _BITS_WCHAR_LIMITS_H_
 
+#include <sys/cdefs.h>
+
 /* Both GCC and clang define __WCHAR_MAX__. */
 #define WCHAR_MAX __WCHAR_MAX__
 
diff --git a/libc/bionic/__fread_chk.cpp b/libc/include/bits/wctype.h
similarity index 61%
copy from libc/bionic/__fread_chk.cpp
copy to libc/include/bits/wctype.h
index afc8d90..c968d71 100644
--- a/libc/bionic/__fread_chk.cpp
+++ b/libc/include/bits/wctype.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,22 +26,41 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
-#include <stdio.h>
+#ifndef _BITS_WCTYPE_H_
+#define _BITS_WCTYPE_H_
+
 #include <sys/cdefs.h>
-#include "private/libc_logging.h"
 
-extern "C" size_t __fread_chk(void * __restrict buf, size_t size, size_t count,
-                              FILE * __restrict stream, size_t buf_size) {
-  size_t total;
-  if (__predict_false(__size_mul_overflow(size, count, &total))) {
-    // overflow: trigger the error path in fread
-    return fread(buf, size, count, stream);
-  }
+__BEGIN_DECLS
 
-  if (__predict_false(total > buf_size)) {
-    __fortify_chk_fail("fread: prevented write past end of buffer", 0);
-  }
+typedef __WINT_TYPE__ wint_t;
 
-  return fread(buf, size, count, stream);
-}
+#define WEOF __BIONIC_CAST(static_cast, wint_t, -1)
+
+int iswalnum(wint_t);
+int iswalpha(wint_t);
+int iswblank(wint_t) __INTRODUCED_IN(21);
+int iswcntrl(wint_t);
+int iswdigit(wint_t);
+int iswgraph(wint_t);
+int iswlower(wint_t);
+int iswprint(wint_t);
+int iswpunct(wint_t);
+int iswspace(wint_t);
+int iswupper(wint_t);
+int iswxdigit(wint_t);
+
+wint_t towlower(wint_t);
+wint_t towupper(wint_t);
+
+typedef long wctype_t;
+wctype_t wctype(const char*);
+int iswctype(wint_t, wctype_t);
+
+typedef const void* wctrans_t;
+wint_t towctrans(wint_t, wctrans_t) __INTRODUCED_IN_FUTURE __VERSIONER_NO_GUARD;
+wctrans_t wctrans(const char*) __INTRODUCED_IN_FUTURE __VERSIONER_NO_GUARD;
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/byteswap.h b/libc/include/byteswap.h
index 628fb7f..0838e6c 100644
--- a/libc/include/byteswap.h
+++ b/libc/include/byteswap.h
@@ -25,9 +25,11 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _BYTESWAP_H_
 #define _BYTESWAP_H_
 
+#include <sys/cdefs.h>
 #include <sys/endian.h>
 
 #define bswap_16(x) __swap16(x)
diff --git a/libc/include/complex.h b/libc/include/complex.h
new file mode 100644
index 0000000..f4dc124
--- /dev/null
+++ b/libc/include/complex.h
@@ -0,0 +1,160 @@
+/*-
+ * Copyright (c) 2001-2011 The FreeBSD Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _COMPLEX_H
+#define	_COMPLEX_H
+
+#include <sys/cdefs.h>
+
+#ifdef __GNUC__
+#define	_Complex_I	((float _Complex)1.0i)
+#endif
+
+#ifdef __generic
+_Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
+    "_Complex_I must be of type float _Complex");
+#endif
+
+#define	complex		_Complex
+#define	I		_Complex_I
+
+#if __STDC_VERSION__ >= 201112L
+#ifdef __clang__
+#define	CMPLX(x, y)	((double complex){ x, y })
+#define	CMPLXF(x, y)	((float complex){ x, y })
+#define	CMPLXL(x, y)	((long double complex){ x, y })
+#else
+#define	CMPLX(x, y)	__builtin_complex((double)(x), (double)(y))
+#define	CMPLXF(x, y)	__builtin_complex((float)(x), (float)(y))
+#define	CMPLXL(x, y)	__builtin_complex((long double)(x), (long double)(y))
+#endif
+#endif
+
+__BEGIN_DECLS
+
+/* 7.3.5 Trigonometric functions */
+/* 7.3.5.1 The cacos functions */
+double complex cacos(double complex) __INTRODUCED_IN(23);
+float complex cacosf(float complex) __INTRODUCED_IN(23);
+long double complex cacosl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.5.2 The casin functions */
+double complex casin(double complex) __INTRODUCED_IN(23);
+float complex casinf(float complex) __INTRODUCED_IN(23);
+long double complex casinl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.5.1 The catan functions */
+double complex catan(double complex) __INTRODUCED_IN(23);
+float complex catanf(float complex) __INTRODUCED_IN(23);
+long double complex catanl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.5.1 The ccos functions */
+double complex ccos(double complex) __INTRODUCED_IN(23);
+float complex ccosf(float complex) __INTRODUCED_IN(23);
+long double complex ccosl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.5.1 The csin functions */
+double complex csin(double complex) __INTRODUCED_IN(23);
+float complex csinf(float complex) __INTRODUCED_IN(23);
+long double complex csinl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.5.1 The ctan functions */
+double complex ctan(double complex) __INTRODUCED_IN(23);
+float complex ctanf(float complex) __INTRODUCED_IN(23);
+long double complex ctanl(long double complex) __INTRODUCED_IN_FUTURE;
+
+/* 7.3.6 Hyperbolic functions */
+/* 7.3.6.1 The cacosh functions */
+double complex cacosh(double complex) __INTRODUCED_IN(23);
+float complex cacoshf(float complex) __INTRODUCED_IN(23);
+long double complex cacoshl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.6.2 The casinh functions */
+double complex casinh(double complex) __INTRODUCED_IN(23);
+float complex casinhf(float complex) __INTRODUCED_IN(23);
+long double complex casinhl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.6.3 The catanh functions */
+double complex catanh(double complex) __INTRODUCED_IN(23);
+float complex catanhf(float complex) __INTRODUCED_IN(23);
+long double complex catanhl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.6.4 The ccosh functions */
+double complex ccosh(double complex) __INTRODUCED_IN(23);
+float complex ccoshf(float complex) __INTRODUCED_IN(23);
+long double complex ccoshl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.6.5 The csinh functions */
+double complex csinh(double complex) __INTRODUCED_IN(23);
+float complex csinhf(float complex) __INTRODUCED_IN(23);
+long double complex csinhl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.6.6 The ctanh functions */
+double complex ctanh(double complex) __INTRODUCED_IN(23);
+float complex ctanhf(float complex) __INTRODUCED_IN(23);
+long double complex ctanhl(long double complex) __INTRODUCED_IN_FUTURE;
+
+/* 7.3.7 Exponential and logarithmic functions */
+/* 7.3.7.1 The cexp functions */
+double complex cexp(double complex) __INTRODUCED_IN(23);
+float complex cexpf(float complex) __INTRODUCED_IN(23);
+long double complex cexpl(long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.7.2 The clog functions */
+double complex clog(double complex) __INTRODUCED_IN_FUTURE;
+float complex clogf(float complex) __INTRODUCED_IN_FUTURE;
+long double complex clogl(long double complex) __INTRODUCED_IN_FUTURE;
+
+/* 7.3.8 Power and absolute-value functions */
+/* 7.3.8.1 The cabs functions */
+double cabs(double complex) __INTRODUCED_IN(23);
+float cabsf(float complex) __INTRODUCED_IN(23);
+long double cabsl(long double complex) __INTRODUCED_IN_32(21) __INTRODUCED_IN_64(23);
+/* 7.3.8.2 The cpow functions */
+double complex cpow(double complex, double complex) __INTRODUCED_IN_FUTURE;
+float complex cpowf(float complex, float complex) __INTRODUCED_IN_FUTURE;
+long double complex cpowl(long double complex, long double complex) __INTRODUCED_IN_FUTURE;
+/* 7.3.8.3 The csqrt functions */
+double complex csqrt(double complex) __INTRODUCED_IN(23);
+float complex csqrtf(float complex) __INTRODUCED_IN(23);
+long double complex csqrtl(long double complex) __INTRODUCED_IN_32(21) __INTRODUCED_IN_64(23);
+
+/* 7.3.9 Manipulation functions */
+/* 7.3.9.1 The carg functions */
+double carg(double complex) __INTRODUCED_IN(23);
+float cargf(float complex) __INTRODUCED_IN(23);
+long double cargl(long double complex) __INTRODUCED_IN(23);
+/* 7.3.9.2 The cimag functions */
+double cimag(double complex) __INTRODUCED_IN(23);
+float cimagf(float complex) __INTRODUCED_IN(23);
+long double cimagl(long double complex) __INTRODUCED_IN(23);
+/* 7.3.9.3 The conj functions */
+double complex conj(double complex) __INTRODUCED_IN(23);
+float complex conjf(float complex) __INTRODUCED_IN(23);
+long double complex conjl(long double complex) __INTRODUCED_IN(23);
+/* 7.3.9.4 The cproj functions */
+double complex cproj(double complex) __INTRODUCED_IN(23);
+float complex cprojf(float complex) __INTRODUCED_IN(23);
+long double complex cprojl(long double complex) __INTRODUCED_IN_32(21) __INTRODUCED_IN_64(23);
+/* 7.3.9.5 The creal functions */
+double creal(double complex) __INTRODUCED_IN(23);
+float crealf(float complex) __INTRODUCED_IN(23);
+long double creall(long double complex) __INTRODUCED_IN(23);
+
+__END_DECLS
+
+#endif /* _COMPLEX_H */
diff --git a/libc/bionic/__fread_chk.cpp b/libc/include/cpio.h
similarity index 68%
rename from libc/bionic/__fread_chk.cpp
rename to libc/include/cpio.h
index afc8d90..ceeeb87 100644
--- a/libc/bionic/__fread_chk.cpp
+++ b/libc/include/cpio.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,22 +26,32 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
-#include <stdio.h>
+#ifndef _CPIO_H_
+#define _CPIO_H_
+
 #include <sys/cdefs.h>
-#include "private/libc_logging.h"
 
-extern "C" size_t __fread_chk(void * __restrict buf, size_t size, size_t count,
-                              FILE * __restrict stream, size_t buf_size) {
-  size_t total;
-  if (__predict_false(__size_mul_overflow(size, count, &total))) {
-    // overflow: trigger the error path in fread
-    return fread(buf, size, count, stream);
-  }
+#define C_IRUSR 0000400
+#define C_IWUSR 0000200
+#define C_IXUSR 0000100
+#define C_IRGRP 0000040
+#define C_IWGRP 0000020
+#define C_IXGRP 0000010
+#define C_IROTH 0000004
+#define C_IWOTH 0000002
+#define C_IXOTH 0000001
+#define C_ISUID 0004000
+#define C_ISGID 0002000
+#define C_ISVTX 0001000
+#define C_ISDIR 0040000
+#define C_ISFIFO 0010000
+#define C_ISREG 0100000
+#define C_ISBLK 0060000
+#define C_ISCHR 0020000
+#define C_ISCTG 0110000
+#define C_ISLNK 0120000
+#define C_ISSOCK 0140000
 
-  if (__predict_false(total > buf_size)) {
-    __fortify_chk_fail("fread: prevented write past end of buffer", 0);
-  }
+#define MAGIC "070707"
 
-  return fread(buf, size, count, stream);
-}
+#endif /* _CPIO_H_ */
diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index 83b5ba7..f59b399 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -54,13 +54,16 @@
 #define _CTYPE_R (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_D|_CTYPE_B)
 #define _CTYPE_A (_CTYPE_L|_CTYPE_U)
 
+/* _CTYPE_N was added to NDK r10 and is expected by gnu-libstdc++ */
+#define _CTYPE_N _CTYPE_D
+
 __BEGIN_DECLS
 
-extern const char	*_ctype_;
+extern const char* _ctype_;
 
-#if defined(__GNUC__) || defined(_ANSI_LIBRARY) || defined(lint)
 int isalnum(int);
 int isalpha(int);
+int isblank(int);
 int iscntrl(int);
 int isdigit(int);
 int isgraph(int);
@@ -74,35 +77,28 @@
 int toupper(int);
 
 #if __ANDROID_API__ >= 21
-int isalnum_l(int, locale_t);
-int isalpha_l(int, locale_t);
-int isblank_l(int, locale_t);
-int iscntrl_l(int, locale_t);
-int isdigit_l(int, locale_t);
-int isgraph_l(int, locale_t);
-int islower_l(int, locale_t);
-int isprint_l(int, locale_t);
-int ispunct_l(int, locale_t);
-int isspace_l(int, locale_t);
-int isupper_l(int, locale_t);
-int isxdigit_l(int, locale_t);
-int tolower_l(int, locale_t);
-int toupper_l(int, locale_t);
-#endif /* __ANDROID_API__ >= 21 */
-
-#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE > 200112 \
-    || __XPG_VISIBLE > 600
-int isblank(int);
+int isalnum_l(int, locale_t) __INTRODUCED_IN(21);
+int isalpha_l(int, locale_t) __INTRODUCED_IN(21);
+int isblank_l(int, locale_t) __INTRODUCED_IN(21);
+int iscntrl_l(int, locale_t) __INTRODUCED_IN(21);
+int isdigit_l(int, locale_t) __INTRODUCED_IN(21);
+int isgraph_l(int, locale_t) __INTRODUCED_IN(21);
+int islower_l(int, locale_t) __INTRODUCED_IN(21);
+int isprint_l(int, locale_t) __INTRODUCED_IN(21);
+int ispunct_l(int, locale_t) __INTRODUCED_IN(21);
+int isspace_l(int, locale_t) __INTRODUCED_IN(21);
+int isupper_l(int, locale_t) __INTRODUCED_IN(21);
+int isxdigit_l(int, locale_t) __INTRODUCED_IN(21);
+int tolower_l(int, locale_t) __INTRODUCED_IN(21);
+int toupper_l(int, locale_t) __INTRODUCED_IN(21);
+#else
+// Implemented as static inlines before 21.
 #endif
 
-#if __BSD_VISIBLE || __XPG_VISIBLE
 int isascii(int);
 int toascii(int);
-int _tolower(int);
-int _toupper(int);
-#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
-
-#endif /* __GNUC__ || _ANSI_LIBRARY || lint */
+int _tolower(int) __INTRODUCED_IN(21);
+int _toupper(int) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/dirent.h b/libc/include/dirent.h
index 3cdfa68..3f9ad18 100644
--- a/libc/include/dirent.h
+++ b/libc/include/dirent.h
@@ -68,25 +68,28 @@
 
 typedef struct DIR DIR;
 
-extern DIR* opendir(const char*);
-extern DIR* fdopendir(int);
-extern struct dirent* readdir(DIR*);
-extern struct dirent64* readdir64(DIR*);
-extern int readdir_r(DIR*, struct dirent*, struct dirent**);
-extern int readdir64_r(DIR*, struct dirent64*, struct dirent64**);
-extern int closedir(DIR*);
-extern void rewinddir(DIR*);
-extern void seekdir(DIR*, long);
-extern long telldir(DIR*);
-extern int dirfd(DIR*);
-extern int alphasort(const struct dirent**, const struct dirent**);
-extern int alphasort64(const struct dirent64**, const struct dirent64**);
-extern int scandir64(const char*, struct dirent64***, int (*)(const struct dirent64*), int (*)(const struct dirent64**, const struct dirent64**));
-extern int scandir(const char*, struct dirent***, int (*)(const struct dirent*), int (*)(const struct dirent**, const struct dirent**));
+DIR* opendir(const char*);
+DIR* fdopendir(int);
+struct dirent* readdir(DIR*);
+struct dirent64* readdir64(DIR*) __INTRODUCED_IN(21);
+int readdir_r(DIR*, struct dirent*, struct dirent**);
+int readdir64_r(DIR*, struct dirent64*, struct dirent64**) __INTRODUCED_IN(21);
+int closedir(DIR*);
+void rewinddir(DIR*);
+void seekdir(DIR*, long) __INTRODUCED_IN(23);
+long telldir(DIR*) __INTRODUCED_IN(23);
+int dirfd(DIR*);
+int alphasort(const struct dirent**, const struct dirent**);
+int alphasort64(const struct dirent64**, const struct dirent64**) __INTRODUCED_IN(21);
+int scandir64(const char*, struct dirent64***, int (*)(const struct dirent64*),
+              int (*)(const struct dirent64**, const struct dirent64**)) __INTRODUCED_IN(21);
+int scandir(const char*, struct dirent***, int (*)(const struct dirent*), int (*)(const struct dirent**, const struct dirent**));
 
 #if defined(__USE_GNU)
-int scandirat64(int, const char*, struct dirent64***, int (*)(const struct dirent64*), int (*)(const struct dirent64**, const struct dirent64**));
-int scandirat(int, const char*, struct dirent***, int (*)(const struct dirent*), int (*)(const struct dirent**, const struct dirent**));
+int scandirat64(int, const char*, struct dirent64***, int (*)(const struct dirent64*),
+                int (*)(const struct dirent64**, const struct dirent64**)) __INTRODUCED_IN(24);
+int scandirat(int, const char*, struct dirent***, int (*)(const struct dirent*),
+              int (*)(const struct dirent**, const struct dirent**)) __INTRODUCED_IN(24);
 #endif
 
 __END_DECLS
diff --git a/libc/include/dlfcn.h b/libc/include/dlfcn.h
index c2e8980..9aa4a1f 100644
--- a/libc/include/dlfcn.h
+++ b/libc/include/dlfcn.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef __DLFCN_H__
 #define __DLFCN_H__
 
@@ -32,23 +33,28 @@
 
 __BEGIN_DECLS
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+#endif
+
 typedef struct {
-    const char *dli_fname;  /* Pathname of shared object that
-                               contains address */
-    void       *dli_fbase;  /* Address at which shared object
-                               is loaded */
-    const char *dli_sname;  /* Name of nearest symbol with address
-                               lower than addr */
-    void       *dli_saddr;  /* Exact address of symbol named
-                               in dli_sname */
+  /* Pathname of shared object that contains address. */
+  const char* dli_fname;
+  /* Address at which shared object is loaded. */
+  void* dli_fbase;
+  /* Name of nearest symbol with address lower than addr. */
+  const char* dli_sname;
+  /* Exact address of symbol named in dli_sname. */
+  void* dli_saddr;
 } Dl_info;
 
-extern void* dlopen(const char*  filename, int flag);
-extern int dlclose(void*  handle);
-extern const char* dlerror(void);
-extern void* dlsym(void* handle, const char* symbol) __nonnull((2));
-extern void* dlvsym(void* handle, const char* symbol, const char* version) __nonnull((2, 3));
-extern int dladdr(const void* addr, Dl_info *info);
+void* dlopen(const char* filename, int flag);
+int dlclose(void* _Nonnull handle);
+char* dlerror(void);
+void* dlsym(void* handle, const char* _Nonnull symbol);
+void* dlvsym(void* handle, const char* _Nonnull symbol, const char* _Nonnull version) __INTRODUCED_IN(24);
+int dladdr(const void* addr, Dl_info* _Nonnull info);
 
 enum {
 #if defined(__LP64__)
@@ -69,15 +75,17 @@
 };
 
 #if defined (__LP64__)
-#define RTLD_DEFAULT  ((void*) 0)
-#define RTLD_NEXT     ((void*) -1L)
+#define RTLD_DEFAULT  __BIONIC_CAST(reinterpret_cast, void*, 0)
+#define RTLD_NEXT     __BIONIC_CAST(reinterpret_cast, void*, -1L)
 #else
-#define RTLD_DEFAULT  ((void*) 0xffffffff)
-#define RTLD_NEXT     ((void*) 0xfffffffe)
+#define RTLD_DEFAULT  __BIONIC_CAST(reinterpret_cast, void*, 0xffffffff)
+#define RTLD_NEXT     __BIONIC_CAST(reinterpret_cast, void*, 0xfffffffe)
+#endif
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
 #endif
 
 __END_DECLS
 
 #endif /* __DLFCN_H */
-
-
diff --git a/libc/include/elf.h b/libc/include/elf.h
index eaad1d3..1a99337 100644
--- a/libc/include/elf.h
+++ b/libc/include/elf.h
@@ -25,14 +25,15 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _ELF_H
 #define _ELF_H
 
 #include <linux/auxvec.h>
 #include <linux/elf.h>
 #include <linux/elf-em.h>
-
 #include <machine/elf_machdep.h>
+#include <sys/cdefs.h>
 
 #define ELF32_R_INFO(sym, type) ((((Elf32_Word)sym) << 8) | ((type) & 0xff))
 #define ELF64_R_INFO(sym, type) ((((Elf64_Xword)sym) << 32) | ((type) & 0xffffffff))
diff --git a/libc/include/endian.h b/libc/include/endian.h
index 475b48c..65e2930 100644
--- a/libc/include/endian.h
+++ b/libc/include/endian.h
@@ -1,33 +1 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _ENDIAN_H_
-#define _ENDIAN_H_
-
 #include <sys/endian.h>
-
-#endif /* _ENDIAN_H_ */
diff --git a/libc/include/errno.h b/libc/include/errno.h
index 82f4b42..3f4cff9 100644
--- a/libc/include/errno.h
+++ b/libc/include/errno.h
@@ -41,15 +41,13 @@
 #endif
 
 /* internal function returning the address of the thread-specific errno */
-extern volatile int* __errno(void) __pure2;
+volatile int* __errno(void) __attribute_const__;
 
 /* a macro expanding to the errno l-value */
 #define  errno   (*__errno())
 
-#if __ANDROID_API__ < 21
-#include <android/legacy_errno_inlines.h>
-#endif
-
 __END_DECLS
 
+#include <android/legacy_errno_inlines.h>
+
 #endif /* _ERRNO_H */
diff --git a/libc/include/error.h b/libc/include/error.h
index dd12884..05ce35d 100644
--- a/libc/include/error.h
+++ b/libc/include/error.h
@@ -33,12 +33,13 @@
 
 __BEGIN_DECLS
 
-void error(int, int, const char*, ...) __printflike(3, 4);
-void error_at_line(int, int, const char*, unsigned int, const char*, ...) __printflike(5, 6);
+extern void (* _Nullable error_print_progname)(void) __INTRODUCED_IN(23);
+extern unsigned int error_message_count __INTRODUCED_IN(23);
+extern int error_one_per_line __INTRODUCED_IN(23);
 
-extern void (*error_print_progname)(void);
-extern unsigned int error_message_count;
-extern int error_one_per_line;
+void error(int, int, const char* _Nonnull, ...) __printflike(3, 4) __INTRODUCED_IN(23);
+void error_at_line(int, int, const char* _Nullable, unsigned int, const char* _Nonnull, ...)
+    __printflike(5, 6) __INTRODUCED_IN(23);
 
 __END_DECLS
 
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 6e2ad51..94ea153 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -32,10 +32,14 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <linux/fadvise.h>
+#include <linux/falloc.h>
 #include <linux/fcntl.h>
 #include <linux/stat.h>
 #include <linux/uio.h>
 
+#include <bits/fcntl.h>
+#include <bits/seek_constants.h>
+
 #if defined(__USE_GNU) || defined(__USE_BSD)
 #include <bits/lockf.h>
 #endif
@@ -61,35 +65,38 @@
 #define SYNC_FILE_RANGE_WRITE 2
 #define SYNC_FILE_RANGE_WAIT_AFTER 4
 
-extern int creat(const char*, mode_t);
-extern int creat64(const char*, mode_t);
-extern int fcntl(int, int, ...);
-extern int openat(int, const char*, int, ...);
-extern int openat64(int, const char*, int, ...);
-extern int open(const char*, int, ...);
-extern int open64(const char*, int, ...);
-extern ssize_t splice(int, off64_t*, int, off64_t*, size_t, unsigned int);
-extern ssize_t tee(int, int, size_t, unsigned int);
-extern int unlinkat(int, const char*, int);
-extern ssize_t vmsplice(int, const struct iovec*, size_t, unsigned int);
+int creat(const char*, mode_t);
+int creat64(const char*, mode_t) __INTRODUCED_IN(21);
+int openat(int, const char*, int, ...);
+int openat64(int, const char*, int, ...) __INTRODUCED_IN(21);
+int open(const char*, int, ...);
+int open64(const char*, int, ...) __INTRODUCED_IN(21);
+ssize_t splice(int, off64_t*, int, off64_t*, size_t, unsigned int) __INTRODUCED_IN(21);
+ssize_t tee(int, int, size_t, unsigned int) __INTRODUCED_IN(21);
+ssize_t vmsplice(int, const struct iovec*, size_t, unsigned int) __INTRODUCED_IN(21);
 
 #if defined(__USE_FILE_OFFSET64)
-extern int fallocate(int, int, off_t, off_t) __RENAME(fallocate64);
-extern int posix_fadvise(int, off_t, off_t, int) __RENAME(posix_fadvise64);
-extern int posix_fallocate(int, off_t, off_t) __RENAME(posix_fallocate);
+int fallocate(int, int, off_t, off_t) __RENAME(fallocate64) __INTRODUCED_IN(21);
+int posix_fadvise(int, off_t, off_t, int) __RENAME(posix_fadvise64) __INTRODUCED_IN(21);
+int posix_fallocate(int, off_t, off_t) __RENAME(posix_fallocate64) __INTRODUCED_IN(21);
 #else
-extern int fallocate(int, int, off_t, off_t);
-extern int posix_fadvise(int, off_t, off_t, int);
-extern int posix_fallocate(int, off_t, off_t);
+int fallocate(int, int, off_t, off_t) __INTRODUCED_IN(21);
+int posix_fadvise(int, off_t, off_t, int) __INTRODUCED_IN(21);
+int posix_fallocate(int, off_t, off_t) __INTRODUCED_IN(21);
 #endif
-extern int fallocate64(int, int, off64_t, off64_t);
-extern int posix_fadvise64(int, off64_t, off64_t, int);
-extern int posix_fallocate64(int, off64_t, off64_t);
+int fallocate64(int, int, off64_t, off64_t) __INTRODUCED_IN(21);
+int posix_fadvise64(int, off64_t, off64_t, int) __INTRODUCED_IN(21);
+int posix_fallocate64(int, off64_t, off64_t) __INTRODUCED_IN(21);
 
-extern int __open_2(const char*, int);
-extern int __open_real(const char*, int, ...) __RENAME(open);
-extern int __openat_2(int, const char*, int);
-extern int __openat_real(int, const char*, int, ...) __RENAME(openat);
+#if defined(__USE_GNU)
+ssize_t readahead(int, off64_t, size_t) __INTRODUCED_IN(16);
+int sync_file_range(int, off64_t, off64_t, unsigned int) __INTRODUCED_IN_FUTURE;
+#endif
+
+int __open_2(const char*, int) __INTRODUCED_IN(17);
+int __open_real(const char*, int, ...) __RENAME(open);
+int __openat_2(int, const char*, int) __INTRODUCED_IN(17);
+int __openat_real(int, const char*, int, ...) __RENAME(openat);
 __errordecl(__creat_missing_mode, "called with O_CREAT, but missing mode");
 __errordecl(__creat_too_many_args, "too many arguments");
 
@@ -101,12 +108,12 @@
 int open(const char* pathname, int flags, ...) {
     if (__builtin_constant_p(flags)) {
         if ((flags & O_CREAT) && __builtin_va_arg_pack_len() == 0) {
-            __creat_missing_mode();  // compile time error
+            __creat_missing_mode();  /* Compile time error. */
         }
     }
 
     if (__builtin_va_arg_pack_len() > 1) {
-        __creat_too_many_args();  // compile time error
+        __creat_too_many_args();  /* Compile time error. */
     }
 
     if ((__builtin_va_arg_pack_len() == 0) && !__builtin_constant_p(flags)) {
@@ -120,12 +127,12 @@
 int openat(int dirfd, const char* pathname, int flags, ...) {
     if (__builtin_constant_p(flags)) {
         if ((flags & O_CREAT) && __builtin_va_arg_pack_len() == 0) {
-            __creat_missing_mode();  // compile time error
+            __creat_missing_mode();  /* Compile time error. */
         }
     }
 
     if (__builtin_va_arg_pack_len() > 1) {
-        __creat_too_many_args();  // compile time error
+        __creat_too_many_args();  /* Compile time error. */
     }
 
     if ((__builtin_va_arg_pack_len() == 0) && !__builtin_constant_p(flags)) {
diff --git a/libc/include/fenv.h b/libc/include/fenv.h
new file mode 100644
index 0000000..241e845
--- /dev/null
+++ b/libc/include/fenv.h
@@ -0,0 +1,80 @@
+/*  $OpenBSD: fenv.h,v 1.2 2011/05/25 21:46:49 martynas Exp $ */
+/*  $NetBSD: fenv.h,v 1.2.4.1 2011/02/08 16:18:55 bouyer Exp $  */
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _FENV_H_
+#define _FENV_H_
+
+#include <sys/cdefs.h>
+#include <machine/fenv.h>
+
+__BEGIN_DECLS
+
+// fenv was always available on x86.
+#if __ANDROID_API__ >= 21 || defined(__i386__)
+int feclearexcept(int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int fegetexceptflag(fexcept_t*, int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21)
+    __INTRODUCED_IN_X86(9);
+int feraiseexcept(int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int fesetexceptflag(const fexcept_t*, int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21)
+    __INTRODUCED_IN_X86(9);
+int fetestexcept(int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+
+int fegetround(void) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int fesetround(int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+
+int fegetenv(fenv_t*) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int feholdexcept(fenv_t*) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int fesetenv(const fenv_t*) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int feupdateenv(const fenv_t*) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21)
+    __INTRODUCED_IN_X86(9);
+
+int feenableexcept(int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int fedisableexcept(int) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+int fegetexcept(void) __INTRODUCED_IN_ARM(21) __INTRODUCED_IN_MIPS(21) __INTRODUCED_IN_X86(9);
+#else
+/* Defined as inlines for pre-21 ARM and MIPS. */
+#endif
+
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions that manage the floating-point
+ * environment, namely fesetenv() and feupdateenv().
+ */
+extern const fenv_t __fe_dfl_env;
+#define FE_DFL_ENV  (&__fe_dfl_env)
+
+__END_DECLS
+
+#include <android/legacy_fenv_inlines_arm.h>
+#include <android/legacy_fenv_inlines_mips.h>
+
+#endif  /* ! _FENV_H_ */
diff --git a/libc/include/fnmatch.h b/libc/include/fnmatch.h
index 772b4ef..1a5348b 100644
--- a/libc/include/fnmatch.h
+++ b/libc/include/fnmatch.h
@@ -44,9 +44,8 @@
 #define FNM_IGNORECASE   FNM_CASEFOLD
 #define FNM_FILE_NAME    FNM_PATHNAME
 
-extern int  fnmatch(const char *pattern, const char *string, int flags);
+int fnmatch(const char* pattern, const char* string, int flags);
 
 __END_DECLS
 
 #endif /* _FNMATCH_H */
-
diff --git a/libc/include/fts.h b/libc/include/fts.h
index cde0349..b46c19c 100644
--- a/libc/include/fts.h
+++ b/libc/include/fts.h
@@ -35,6 +35,7 @@
 #ifndef	_FTS_H_
 #define	_FTS_H_
 
+#include <sys/cdefs.h>
 #include <sys/types.h>
 
 typedef struct {
diff --git a/libc/include/ftw.h b/libc/include/ftw.h
index af524d0..cb8ae7d 100644
--- a/libc/include/ftw.h
+++ b/libc/include/ftw.h
@@ -25,8 +25,9 @@
 #ifndef	_FTW_H
 #define	_FTW_H
 
-#include <sys/types.h>
+#include <sys/cdefs.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 
 /*
  * Valid flags for the 3rd argument to the function that is passed as the
@@ -54,12 +55,12 @@
 };
 
 __BEGIN_DECLS
-int	ftw(const char *, int (*)(const char *, const struct stat *, int), int);
-int	nftw(const char *, int (*)(const char *, const struct stat *, int,
-	    struct FTW *), int, int);
-int	ftw64(const char *, int (*)(const char *, const struct stat64 *, int), int);
-int	nftw64(const char *, int (*)(const char *, const struct stat64 *, int,
-	    struct FTW *), int, int);
+int ftw(const char*, int (*)(const char*, const struct stat*, int), int) __INTRODUCED_IN(17);
+int nftw(const char*, int (*)(const char*, const struct stat*, int, struct FTW*), int, int)
+  __INTRODUCED_IN(17);
+int ftw64(const char*, int (*)(const char*, const struct stat64*, int), int) __INTRODUCED_IN(21);
+int nftw64(const char*, int (*)(const char*, const struct stat64*, int, struct FTW*), int, int)
+  __INTRODUCED_IN(21);
 __END_DECLS
 
 #endif	/* !_FTW_H */
diff --git a/libc/include/getopt.h b/libc/include/getopt.h
index 4451941..46d2eb7 100644
--- a/libc/include/getopt.h
+++ b/libc/include/getopt.h
@@ -35,9 +35,10 @@
 
 #include <sys/cdefs.h>
 
+#include <bits/getopt.h>
+
 /*
  * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
- * getopt() is declared here too for GNU programs.
  */
 #define no_argument        0
 #define required_argument  1
@@ -62,13 +63,7 @@
 	const struct option *, int *);
 int	getopt_long_only(int, char * const *, const char *,
 	const struct option *, int *);
-#ifndef _GETOPT_DECLARED
-#define	_GETOPT_DECLARED
-int	 getopt(int, char * const [], const char *);
 
-extern char *optarg;			/* getopt(3) external variables */
-extern int optind, opterr, optopt;
-#endif
 #ifndef _OPTRESET_DECLARED
 #define	_OPTRESET_DECLARED
 extern int optreset;			/* getopt(3) external variable */
diff --git a/libc/include/grp.h b/libc/include/grp.h
index df7a613..1d38265 100644
--- a/libc/include/grp.h
+++ b/libc/include/grp.h
@@ -1,9 +1,6 @@
-/*	$OpenBSD: grp.h,v 1.8 2005/12/13 00:35:22 millert Exp $	*/
-/*	$NetBSD: grp.h,v 1.7 1995/04/29 05:30:40 cgd Exp $	*/
-
 /*-
  * Copyright (c) 1989, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *    The Regents of the University of California.  All rights reserved.
  * (c) UNIX System Laboratories, Inc.
  * All or some portions of this file are derived from material licensed
  * to the University of California by American Telephone and Telegraph
@@ -33,40 +30,35 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- *	@(#)grp.h	8.2 (Berkeley) 1/21/94
  */
 
 #ifndef _GRP_H_
-#define	_GRP_H_
+#define _GRP_H_
 
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
 struct group {
-	char	*gr_name;		/* group name */
-	char	*gr_passwd;		/* group password */
-	gid_t	gr_gid;			/* group id */
-	char	**gr_mem;		/* group members */
+  char* gr_name; /* group name */
+  char* gr_passwd; /* group password */
+  gid_t gr_gid; /* group id */
+  char** gr_mem; /* group members */
 };
 
 __BEGIN_DECLS
-struct group	*getgrgid(gid_t);
-struct group	*getgrnam(const char *);
-#if __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE
-struct group	*getgrent(void)  __attribute__((deprecated("getgrent is meaningless on Android")));
-void setgrent(void) __attribute__((deprecated("setgrent is meaningless on Android")));
-void endgrent(void) __attribute__((deprecated("endgrent is meaningless on Android")));
-int		 getgrgid_r(gid_t, struct group *, char *,
-		    size_t, struct group **);
-int		 getgrnam_r(const char *, struct group *, char *,
-		    size_t, struct group **);
-#endif
 
-int   getgrouplist (const char *user, gid_t group,
-                  gid_t *groups, int *ngroups);
+struct group* getgrgid(gid_t);
+struct group* getgrnam(const char*);
 
-int   initgroups (const char *user, gid_t group);
+/* Note: Android has thousands and thousands of ids to iterate through. */
+struct group* getgrent(void) __INTRODUCED_IN_FUTURE;
+
+void setgrent(void) __INTRODUCED_IN_FUTURE;
+void endgrent(void) __INTRODUCED_IN_FUTURE;
+int getgrgid_r(gid_t, struct group*, char*, size_t, struct group**) __INTRODUCED_IN(24);
+int getgrnam_r(const char*, struct group*, char*, size_t, struct group**) __INTRODUCED_IN(24);
+int getgrouplist (const char*, gid_t, gid_t*, int*);
+int initgroups (const char*, gid_t);
 
 __END_DECLS
 
diff --git a/libc/include/ifaddrs.h b/libc/include/ifaddrs.h
index 54a5a2c..083b27a 100644
--- a/libc/include/ifaddrs.h
+++ b/libc/include/ifaddrs.h
@@ -51,8 +51,8 @@
 #define ifa_broadaddr ifa_ifu.ifu_broadaddr
 #define ifa_dstaddr ifa_ifu.ifu_dstaddr
 
-void freeifaddrs(struct ifaddrs*);
-int getifaddrs(struct ifaddrs**);
+void freeifaddrs(struct ifaddrs*) __INTRODUCED_IN(24);
+int getifaddrs(struct ifaddrs**) __INTRODUCED_IN(24);
 
 __END_DECLS
 
diff --git a/libc/include/inttypes.h b/libc/include/inttypes.h
index 8853c08..f74afa3 100644
--- a/libc/include/inttypes.h
+++ b/libc/include/inttypes.h
@@ -29,6 +29,7 @@
 #define __PRI_64_prefix "ll"
 #define __PRI_PTR_prefix
 #endif
+#define __PRI_FAST_prefix __PRI_PTR_prefix
 
 /*
  * 7.8.1 Macros for format specifiers
@@ -58,8 +59,8 @@
 #define	PRIdLEAST64		__PRI_64_prefix"d"		/* int_least64_t */
 
 #define	PRIdFAST8		"d"		/* int_fast8_t */
-#define	PRIdFAST16		"d"		/* int_fast16_t */
-#define	PRIdFAST32		"d"		/* int_fast32_t */
+#define	PRIdFAST16		__PRI_FAST_prefix"d"	/* int_fast16_t */
+#define	PRIdFAST32		__PRI_FAST_prefix"d"	/* int_fast32_t */
 #define	PRIdFAST64		__PRI_64_prefix"d"		/* int_fast64_t */
 
 #define	PRIdMAX			"jd"		/* intmax_t */
@@ -76,8 +77,8 @@
 #define	PRIiLEAST64		__PRI_64_prefix"i"		/* int_least64_t */
 
 #define	PRIiFAST8		"i"		/* int_fast8_t */
-#define	PRIiFAST16		"i"		/* int_fast16_t */
-#define	PRIiFAST32		"i"		/* int_fast32_t */
+#define	PRIiFAST16		__PRI_FAST_prefix"i"	/* int_fast16_t */
+#define	PRIiFAST32		__PRI_FAST_prefix"i"	/* int_fast32_t */
 #define	PRIiFAST64		__PRI_64_prefix"i"		/* int_fast64_t */
 
 #define	PRIiMAX			"ji"		/* intmax_t */
@@ -95,8 +96,8 @@
 #define	PRIoLEAST64		__PRI_64_prefix"o"		/* int_least64_t */
 
 #define	PRIoFAST8		"o"		/* int_fast8_t */
-#define	PRIoFAST16		"o"		/* int_fast16_t */
-#define	PRIoFAST32		"o"		/* int_fast32_t */
+#define	PRIoFAST16		__PRI_FAST_prefix"o"	/* int_fast16_t */
+#define	PRIoFAST32		__PRI_FAST_prefix"o"	/* int_fast32_t */
 #define	PRIoFAST64		__PRI_64_prefix"o"		/* int_fast64_t */
 
 #define	PRIoMAX			"jo"		/* intmax_t */
@@ -113,8 +114,8 @@
 #define	PRIuLEAST64		__PRI_64_prefix"u"		/* uint_least64_t */
 
 #define	PRIuFAST8		"u"		/* uint_fast8_t */
-#define	PRIuFAST16		"u"		/* uint_fast16_t */
-#define	PRIuFAST32		"u"		/* uint_fast32_t */
+#define	PRIuFAST16		__PRI_FAST_prefix"u"	/* uint_fast16_t */
+#define	PRIuFAST32		__PRI_FAST_prefix"u"	/* uint_fast32_t */
 #define	PRIuFAST64		__PRI_64_prefix"u"		/* uint_fast64_t */
 
 #define	PRIuMAX			"ju"		/* uintmax_t */
@@ -131,8 +132,8 @@
 #define	PRIxLEAST64		__PRI_64_prefix"x"		/* uint_least64_t */
 
 #define	PRIxFAST8		"x"		/* uint_fast8_t */
-#define	PRIxFAST16		"x"		/* uint_fast16_t */
-#define	PRIxFAST32		"x"		/* uint_fast32_t */
+#define	PRIxFAST16		__PRI_FAST_prefix"x"	/* uint_fast16_t */
+#define	PRIxFAST32		__PRI_FAST_prefix"x"	/* uint_fast32_t */
 #define	PRIxFAST64		__PRI_64_prefix"x"		/* uint_fast64_t */
 
 #define	PRIxMAX			"jx"		/* uintmax_t */
@@ -149,8 +150,8 @@
 #define	PRIXLEAST64		__PRI_64_prefix"X"		/* uint_least64_t */
 
 #define	PRIXFAST8		"X"		/* uint_fast8_t */
-#define	PRIXFAST16		"X"		/* uint_fast16_t */
-#define	PRIXFAST32		"X"		/* uint_fast32_t */
+#define	PRIXFAST16		__PRI_FAST_prefix"X"	/* uint_fast16_t */
+#define	PRIXFAST32		__PRI_FAST_prefix"X"	/* uint_fast32_t */
 #define	PRIXFAST64		__PRI_64_prefix"X"		/* uint_fast64_t */
 
 #define	PRIXMAX			"jX"		/* uintmax_t */
@@ -168,8 +169,8 @@
 #define	SCNdLEAST64		__PRI_64_prefix"d"		/* int_least64_t */
 
 #define	SCNdFAST8		"hhd"		/* int_fast8_t */
-#define	SCNdFAST16		"hd"		/* int_fast16_t */
-#define	SCNdFAST32		"d"		/* int_fast32_t */
+#define	SCNdFAST16		__PRI_FAST_prefix"d"	/* int_fast16_t */
+#define	SCNdFAST32		__PRI_FAST_prefix"d"	/* int_fast32_t */
 #define	SCNdFAST64		__PRI_64_prefix"d"		/* int_fast64_t */
 
 #define	SCNdMAX			"jd"		/* intmax_t */
@@ -186,8 +187,8 @@
 #define	SCNiLEAST64		__PRI_64_prefix"i"		/* int_least64_t */
 
 #define	SCNiFAST8		"hhi"		/* int_fast8_t */
-#define	SCNiFAST16		"hi"		/* int_fast16_t */
-#define	SCNiFAST32		"i"		/* int_fast32_t */
+#define	SCNiFAST16		__PRI_FAST_prefix"i"	/* int_fast16_t */
+#define	SCNiFAST32		__PRI_FAST_prefix"i"	/* int_fast32_t */
 #define	SCNiFAST64		__PRI_64_prefix"i"		/* int_fast64_t */
 
 #define	SCNiMAX			"ji"		/* intmax_t */
@@ -205,8 +206,8 @@
 #define	SCNoLEAST64		__PRI_64_prefix"o"		/* uint_least64_t */
 
 #define	SCNoFAST8		"hho"		/* uint_fast8_t */
-#define	SCNoFAST16		"ho"		/* uint_fast16_t */
-#define	SCNoFAST32		"o"		/* uint_fast32_t */
+#define	SCNoFAST16		__PRI_FAST_prefix"o"	/* uint_fast16_t */
+#define	SCNoFAST32		__PRI_FAST_prefix"o"	/* uint_fast32_t */
 #define	SCNoFAST64		__PRI_64_prefix"o"		/* uint_fast64_t */
 
 #define	SCNoMAX			"jo"		/* uintmax_t */
@@ -223,8 +224,8 @@
 #define	SCNuLEAST64		__PRI_64_prefix"u"		/* uint_least64_t */
 
 #define	SCNuFAST8		"hhu"		/* uint_fast8_t */
-#define	SCNuFAST16		"hu"		/* uint_fast16_t */
-#define	SCNuFAST32		"u"		/* uint_fast32_t */
+#define	SCNuFAST16		__PRI_FAST_prefix"u"	/* uint_fast16_t */
+#define	SCNuFAST32		__PRI_FAST_prefix"u"		/* uint_fast32_t */
 #define	SCNuFAST64		__PRI_64_prefix"u"		/* uint_fast64_t */
 
 #define	SCNuMAX			"ju"		/* uintmax_t */
@@ -241,8 +242,8 @@
 #define	SCNxLEAST64		__PRI_64_prefix"x"		/* uint_least64_t */
 
 #define	SCNxFAST8		"hhx"		/* uint_fast8_t */
-#define	SCNxFAST16		"hx"		/* uint_fast16_t */
-#define	SCNxFAST32		"x"		/* uint_fast32_t */
+#define	SCNxFAST16		__PRI_FAST_prefix"x"	/* uint_fast16_t */
+#define	SCNxFAST32		__PRI_FAST_prefix"x"	/* uint_fast32_t */
 #define	SCNxFAST64		__PRI_64_prefix"x"		/* uint_fast64_t */
 
 #define	SCNxMAX			"jx"		/* uintmax_t */
@@ -254,14 +255,12 @@
 } imaxdiv_t;
 
 __BEGIN_DECLS
-intmax_t	imaxabs(intmax_t) __pure2;
-imaxdiv_t	imaxdiv(intmax_t, intmax_t) __pure2;
+intmax_t imaxabs(intmax_t) __attribute_const__ __INTRODUCED_IN(19);
+imaxdiv_t imaxdiv(intmax_t, intmax_t) __attribute_const__ __INTRODUCED_IN(19);
 intmax_t	strtoimax(const char *, char **, int);
 uintmax_t	strtoumax(const char *, char **, int);
-intmax_t	wcstoimax(const wchar_t * __restrict,
-		    wchar_t ** __restrict, int);
-uintmax_t	wcstoumax(const wchar_t * __restrict,
-		    wchar_t ** __restrict, int);
+intmax_t wcstoimax(const wchar_t* __restrict, wchar_t** __restrict, int) __INTRODUCED_IN(21);
+uintmax_t wcstoumax(const wchar_t* __restrict, wchar_t** __restrict, int) __INTRODUCED_IN(21);
 __END_DECLS
 
 #endif /* _INTTYPES_H_ */
diff --git a/libc/include/lastlog.h b/libc/include/lastlog.h
index e69de29..4f46106 100644
--- a/libc/include/lastlog.h
+++ b/libc/include/lastlog.h
@@ -0,0 +1,2 @@
+/* This is a BSD synonym for <utmp.h> that's also provided by glibc. */
+#include <utmp.h>
diff --git a/libc/include/libgen.h b/libc/include/libgen.h
index 4d22d15..f864ee1 100644
--- a/libc/include/libgen.h
+++ b/libc/include/libgen.h
@@ -42,17 +42,17 @@
  * Note that this has the wrong argument cv-qualifiers, but doesn't modify its
  * input and uses thread-local storage for the result if necessary.
  */
-extern char* __posix_basename(const char*) __RENAME(basename);
+char* __posix_basename(const char*) __RENAME(basename);
 
 #define basename __posix_basename
 
 /* This has the wrong argument cv-qualifiers, but doesn't modify its input and uses thread-local storage for the result if necessary. */
-extern char* dirname(const char*);
+char* dirname(const char*);
 
 #if !defined(__LP64__)
 /* These non-standard functions are not needed on Android; basename and dirname use thread-local storage. */
-extern int dirname_r(const char*, char*, size_t);
-extern int basename_r(const char*, char*, size_t);
+int dirname_r(const char*, char*, size_t);
+int basename_r(const char*, char*, size_t);
 #endif
 
 __END_DECLS
diff --git a/libc/include/limits.h b/libc/include/limits.h
index 342217b..a1124b3 100644
--- a/libc/include/limits.h
+++ b/libc/include/limits.h
@@ -37,7 +37,6 @@
 
 #include <sys/cdefs.h>
 
-#if __XPG_VISIBLE
 #define PASS_MAX		128	/* _PASSWORD_LEN from <pwd.h> */
 
 #define NL_ARGMAX		9
@@ -48,14 +47,9 @@
 #define NL_TEXTMAX		255
 
 #define TMP_MAX                 308915776
-#endif /* __XPG_VISIBLE */
 
 #include <sys/limits.h>
 
-#if __POSIX_VISIBLE
-#include <sys/syslimits.h>
-#endif
-
 /* GLibc compatibility definitions.
    Note that these are defined by GCC's <limits.h>
    only when __GNU_LIBRARY__ is defined, i.e. when
@@ -72,15 +66,23 @@
 #define ULONG_LONG_MAX  ULLONG_MAX
 #endif
 
-/* BSD compatibility definitions. */
-#if __BSD_VISIBLE
+#if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
+#if defined(__LP64__)
 #define SIZE_T_MAX ULONG_MAX
-#endif /* __BSD_VISIBLE */
+#else
+#define SIZE_T_MAX UINT_MAX
+#endif
+#endif
 
+#if defined(__LP64__)
 #define SSIZE_MAX LONG_MAX
+#else
+#define SSIZE_MAX INT_MAX
+#endif
 
 #define MB_LEN_MAX 4
 
+#define IOV_MAX 1024
 #define SEM_VALUE_MAX 0x3fffffff
 
 /* POSIX says these belong in <unistd.h> but BSD has some in <limits.h>. */
diff --git a/libc/include/link.h b/libc/include/link.h
index cb8e139..92ecceb 100644
--- a/libc/include/link.h
+++ b/libc/include/link.h
@@ -28,12 +28,13 @@
 #ifndef _LINK_H_
 #define _LINK_H_
 
-#include <sys/types.h>
 #include <elf.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
 
 __BEGIN_DECLS
 
-#if __LP64__
+#if defined(__LP64__)
 #define ElfW(type) Elf64_ ## type
 #else
 #define ElfW(type) Elf32_ ## type
@@ -46,7 +47,11 @@
   ElfW(Half) dlpi_phnum;
 };
 
+#if defined(__arm__)
+int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*) __INTRODUCED_IN(21);
+#else
 int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*);
+#endif
 
 #ifdef __arm__
 typedef long unsigned int* _Unwind_Ptr;
diff --git a/libc/include/locale.h b/libc/include/locale.h
index 7fd8c2c..c1b6299 100644
--- a/libc/include/locale.h
+++ b/libc/include/locale.h
@@ -25,12 +25,16 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _LOCALE_H_
 #define _LOCALE_H_
 
 #include <sys/cdefs.h>
 #include <xlocale.h>
 
+#define __need_NULL
+#include <stddef.h>
+
 __BEGIN_DECLS
 
 #define LC_CTYPE           0
@@ -66,41 +70,41 @@
                      LC_IDENTIFICATION_MASK)
 
 struct lconv {
-    char* decimal_point;
-    char* thousands_sep;
-    char* grouping;
-    char* int_curr_symbol;
-    char* currency_symbol;
-    char* mon_decimal_point;
-    char* mon_thousands_sep;
-    char* mon_grouping;
-    char* positive_sign;
-    char* negative_sign;
-    char  int_frac_digits;
-    char  frac_digits;
-    char  p_cs_precedes;
-    char  p_sep_by_space;
-    char  n_cs_precedes;
-    char  n_sep_by_space;
-    char  p_sign_posn;
-    char  n_sign_posn;
-    char  int_p_cs_precedes;
-    char  int_p_sep_by_space;
-    char  int_n_cs_precedes;
-    char  int_n_sep_by_space;
-    char  int_p_sign_posn;
-    char  int_n_sign_posn;
+  char* decimal_point;
+  char* thousands_sep;
+  char* grouping;
+  char* int_curr_symbol;
+  char* currency_symbol;
+  char* mon_decimal_point;
+  char* mon_thousands_sep;
+  char* mon_grouping;
+  char* positive_sign;
+  char* negative_sign;
+  char int_frac_digits;
+  char frac_digits;
+  char p_cs_precedes;
+  char p_sep_by_space;
+  char n_cs_precedes;
+  char n_sep_by_space;
+  char p_sign_posn;
+  char n_sign_posn;
+  char int_p_cs_precedes;
+  char int_p_sep_by_space;
+  char int_n_cs_precedes;
+  char int_n_sep_by_space;
+  char int_p_sign_posn;
+  char int_n_sign_posn;
 };
 
-struct lconv* localeconv(void);
+struct lconv* localeconv(void) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
 
-locale_t duplocale(locale_t);
-void freelocale(locale_t);
-locale_t newlocale(int, const char*, locale_t);
+locale_t duplocale(locale_t) __INTRODUCED_IN(21);
+void freelocale(locale_t) __INTRODUCED_IN(21);
+locale_t newlocale(int, const char*, locale_t) __INTRODUCED_IN(21);
 char* setlocale(int, const char*);
-locale_t uselocale(locale_t);
+locale_t uselocale(locale_t) __INTRODUCED_IN(21);
 
-#define LC_GLOBAL_LOCALE ((locale_t) -1L)
+#define LC_GLOBAL_LOCALE __BIONIC_CAST(reinterpret_cast, locale_t, -1L)
 
 __END_DECLS
 
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index 87555a9..7452e53 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -23,13 +23,19 @@
 
 __BEGIN_DECLS
 
-extern void* malloc(size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(1)));
-extern void* calloc(size_t item_count, size_t item_size) __mallocfunc __wur __attribute__((alloc_size(1,2)));
-extern void* realloc(void* p, size_t byte_count) __wur __attribute__((alloc_size(2)));
-extern void free(void* p);
+#if defined(__clang__)
+#define __BIONIC_ALLOC_SIZE(...) /* clang doesn't support attribute alloc_size. */
+#else
+#define __BIONIC_ALLOC_SIZE(...) __attribute__((__alloc_size__(__VA_ARGS__)))
+#endif
 
-extern void* memalign(size_t alignment, size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(2)));
-extern size_t malloc_usable_size(const void* p);
+void* malloc(size_t byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(1) __wur;
+void* calloc(size_t item_count, size_t item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2) __wur;
+void* realloc(void* p, size_t byte_count) __BIONIC_ALLOC_SIZE(2) __wur;
+void free(void* p);
+
+void* memalign(size_t alignment, size_t byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2) __wur;
+size_t malloc_usable_size(const void* p) __INTRODUCED_IN(17);
 
 #ifndef STRUCT_MALLINFO_DECLARED
 #define STRUCT_MALLINFO_DECLARED 1
@@ -47,7 +53,7 @@
 };
 #endif  /* STRUCT_MALLINFO_DECLARED */
 
-extern struct mallinfo mallinfo(void);
+struct mallinfo mallinfo(void);
 
 /*
  * XML structure for malloc_info(3) is in the following format:
@@ -68,7 +74,7 @@
  *   <!-- more heaps -->
  * </malloc>
  */
-extern int malloc_info(int, FILE *);
+int malloc_info(int, FILE*) __INTRODUCED_IN(23);
 
 __END_DECLS
 
diff --git a/libc/include/math.h b/libc/include/math.h
new file mode 100644
index 0000000..d9896fc
--- /dev/null
+++ b/libc/include/math.h
@@ -0,0 +1,373 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * from: @(#)fdlibm.h 5.1 93/09/24
+ * $FreeBSD$
+ */
+
+#ifndef _MATH_H_
+#define _MATH_H_
+
+#include <sys/cdefs.h>
+#include <limits.h>
+
+__BEGIN_DECLS
+
+#define HUGE_VAL	__builtin_huge_val()
+
+#define FP_ILOGB0	(-INT_MAX)
+#define FP_ILOGBNAN	INT_MAX
+
+#define HUGE_VALF	__builtin_huge_valf()
+#define HUGE_VALL	__builtin_huge_vall()
+#define INFINITY	__builtin_inff()
+#define NAN		__builtin_nanf("")
+
+#define MATH_ERRNO	1
+#define MATH_ERREXCEPT	2
+#define math_errhandling	MATH_ERREXCEPT
+
+#if defined(__FP_FAST_FMA)
+#define FP_FAST_FMA 1
+#endif
+#if defined(__FP_FAST_FMAF)
+#define FP_FAST_FMAF 1
+#endif
+#if defined(__FP_FAST_FMAL)
+#define FP_FAST_FMAL 1
+#endif
+
+/* Symbolic constants to classify floating point numbers. */
+#define FP_INFINITE	0x01
+#define FP_NAN		0x02
+#define FP_NORMAL	0x04
+#define FP_SUBNORMAL	0x08
+#define FP_ZERO		0x10
+#define fpclassify(x) \
+    __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
+
+#define isfinite(x) __builtin_isfinite(x)
+#define isinf(x) __builtin_isinf(x)
+#define isnan(x) __builtin_isnan(x)
+#define isnormal(x) __builtin_isnormal(x)
+
+#define isgreater(x, y) __builtin_isgreater((x), (y))
+#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
+#define isless(x, y) __builtin_isless((x), (y))
+#define islessequal(x, y) __builtin_islessequal((x), (y))
+#define islessgreater(x, y) __builtin_islessgreater((x), (y))
+#define isunordered(x, y) __builtin_isunordered((x), (y))
+
+#define signbit(x) \
+    ((sizeof(x) == sizeof(float)) ? __builtin_signbitf(x) \
+    : (sizeof(x) == sizeof(double)) ? __builtin_signbit(x) \
+    : __builtin_signbitl(x))
+
+typedef double __double_t;
+typedef __double_t double_t;
+typedef float __float_t;
+typedef __float_t float_t;
+
+#if defined(__USE_BSD)
+#define HUGE MAXFLOAT
+#endif
+
+extern int signgam;
+
+/*
+ * Most of these functions depend on the rounding mode and have the side
+ * effect of raising floating-point exceptions, so they are not declared
+ * as __attribute_const__. In C99, FENV_ACCESS affects the purity of these functions.
+ */
+
+int __fpclassifyd(double) __attribute_const__;
+int __fpclassifyf(float) __attribute_const__;
+int __fpclassifyl(long double) __attribute_const__;
+int __isfinitef(float) __attribute_const__;
+int __isfinite(double) __attribute_const__;
+int __isfinitel(long double) __attribute_const__;
+int __isinff(float) __attribute_const__;
+int __isinfl(long double) __attribute_const__;
+int __isnanf(float) __attribute_const__ __INTRODUCED_IN(21);
+int __isnanl(long double) __attribute_const__;
+int __isnormalf(float) __attribute_const__;
+int __isnormal(double) __attribute_const__;
+int __isnormall(long double) __attribute_const__;
+int __signbit(double) __attribute_const__;
+int __signbitf(float) __attribute_const__;
+int __signbitl(long double) __attribute_const__;
+
+double	acos(double);
+double	asin(double);
+double	atan(double);
+double	atan2(double, double);
+double	cos(double);
+double	sin(double);
+double	tan(double);
+
+double	cosh(double);
+double	sinh(double);
+double	tanh(double);
+
+double	exp(double);
+double	frexp(double, int *);	/* fundamentally !__attribute_const__ */
+double	ldexp(double, int);
+double	log(double);
+double	log10(double);
+double	modf(double, double *);	/* fundamentally !__attribute_const__ */
+
+double	pow(double, double);
+double	sqrt(double);
+
+double	ceil(double);
+double	fabs(double) __attribute_const__;
+double	floor(double);
+double	fmod(double, double);
+
+double	acosh(double);
+double	asinh(double);
+double	atanh(double);
+double	cbrt(double);
+double	erf(double);
+double	erfc(double);
+double	exp2(double);
+double	expm1(double);
+double	fma(double, double, double);
+double	hypot(double, double);
+int	ilogb(double) __attribute_const__;
+int(isinf)(double) __attribute_const__ __INTRODUCED_IN(21);
+int	(isnan)(double) __attribute_const__;
+double	lgamma(double);
+long long llrint(double);
+long long llround(double);
+double	log1p(double);
+double log2(double) __INTRODUCED_IN(18);
+double	logb(double);
+long	lrint(double);
+long	lround(double);
+
+double nan(const char*) __attribute_const__ __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_MIPS(13)
+    __INTRODUCED_IN_X86(9);
+
+double	nextafter(double, double);
+double	remainder(double, double);
+double	remquo(double, double, int*);
+double	rint(double);
+
+double	copysign(double, double) __attribute_const__;
+double	fdim(double, double);
+double	fmax(double, double) __attribute_const__;
+double	fmin(double, double) __attribute_const__;
+double	nearbyint(double);
+double	round(double);
+double scalbln(double, long) __INTRODUCED_IN_X86(18) __VERSIONER_NO_GUARD;
+double scalbn(double, int);
+double	tgamma(double);
+double	trunc(double);
+
+float	acosf(float);
+float	asinf(float);
+float	atanf(float);
+float	atan2f(float, float);
+float	cosf(float);
+float	sinf(float);
+float	tanf(float);
+
+float	coshf(float);
+float	sinhf(float);
+float	tanhf(float);
+
+float	exp2f(float);
+float	expf(float);
+float	expm1f(float);
+float	frexpf(float, int *);	/* fundamentally !__attribute_const__ */
+int	ilogbf(float) __attribute_const__;
+float	ldexpf(float, int);
+float	log10f(float);
+float	log1pf(float);
+float log2f(float) __INTRODUCED_IN(18);
+float	logf(float);
+float	modff(float, float *);	/* fundamentally !__attribute_const__ */
+
+float	powf(float, float);
+float	sqrtf(float);
+
+float	ceilf(float);
+float	fabsf(float) __attribute_const__;
+float	floorf(float);
+float	fmodf(float, float);
+float	roundf(float);
+
+float	erff(float);
+float	erfcf(float);
+float	hypotf(float, float);
+float	lgammaf(float);
+float tgammaf(float) __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_MIPS(13) __INTRODUCED_IN_X86(9);
+
+float	acoshf(float);
+float	asinhf(float);
+float	atanhf(float);
+float	cbrtf(float);
+float	logbf(float);
+float	copysignf(float, float) __attribute_const__;
+long long llrintf(float);
+long long llroundf(float);
+long	lrintf(float);
+long	lroundf(float);
+float nanf(const char*) __attribute_const__ __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_MIPS(13)
+    __INTRODUCED_IN_X86(9);
+float	nearbyintf(float);
+float	nextafterf(float, float);
+float	remainderf(float, float);
+float	remquof(float, float, int *);
+float	rintf(float);
+float	scalblnf(float, long) __INTRODUCED_IN_X86(18) __VERSIONER_NO_GUARD;
+float scalbnf(float, int);
+float	truncf(float);
+
+float	fdimf(float, float);
+float	fmaf(float, float, float);
+float	fmaxf(float, float) __attribute_const__;
+float	fminf(float, float) __attribute_const__;
+
+long double acoshl(long double) __INTRODUCED_IN(21);
+long double acosl(long double) __INTRODUCED_IN(21);
+long double asinhl(long double) __INTRODUCED_IN(21);
+long double asinl(long double) __INTRODUCED_IN(21);
+long double atan2l(long double, long double) __INTRODUCED_IN(21);
+long double atanhl(long double) __INTRODUCED_IN(21);
+long double atanl(long double) __INTRODUCED_IN(21);
+long double cbrtl(long double) __INTRODUCED_IN(21);
+long double ceill(long double);
+long double copysignl(long double, long double) __attribute_const__;
+long double coshl(long double) __INTRODUCED_IN(21);
+long double cosl(long double) __INTRODUCED_IN(21);
+long double erfcl(long double) __INTRODUCED_IN(21);
+long double erfl(long double) __INTRODUCED_IN(21);
+long double exp2l(long double) __INTRODUCED_IN(21);
+long double expl(long double) __INTRODUCED_IN(21);
+long double expm1l(long double) __INTRODUCED_IN(21);
+long double fabsl(long double) __attribute_const__;
+long double fdiml(long double, long double);
+long double floorl(long double);
+long double fmal(long double, long double, long double) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
+long double fmaxl(long double, long double) __attribute_const__;
+long double fminl(long double, long double) __attribute_const__;
+long double fmodl(long double, long double) __INTRODUCED_IN(21);
+long double frexpl(long double value, int*)
+    __INTRODUCED_IN(21) __VERSIONER_NO_GUARD; /* fundamentally !__attribute_const__ */
+long double hypotl(long double, long double) __INTRODUCED_IN(21);
+int ilogbl(long double) __attribute_const__;
+long double ldexpl(long double, int);
+long double lgammal(long double) __INTRODUCED_IN(21);
+long long llrintl(long double) __INTRODUCED_IN(21);
+long long llroundl(long double);
+long double log10l(long double) __INTRODUCED_IN(21);
+long double log1pl(long double) __INTRODUCED_IN(21);
+long double log2l(long double) __INTRODUCED_IN(18);
+long double logbl(long double) __INTRODUCED_IN(18);
+long double logl(long double) __INTRODUCED_IN(21);
+long lrintl(long double) __INTRODUCED_IN(21);
+long lroundl(long double);
+long double modfl(long double, long double*) __INTRODUCED_IN(21); /* fundamentally !__attribute_const__ */
+long double nanl(const char*) __attribute_const__ __INTRODUCED_IN(13);
+long double nearbyintl(long double) __INTRODUCED_IN(21);
+long double nextafterl(long double, long double) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
+double nexttoward(double, long double) __INTRODUCED_IN(18) __VERSIONER_NO_GUARD;
+float nexttowardf(float, long double);
+long double nexttowardl(long double, long double) __INTRODUCED_IN(18) __VERSIONER_NO_GUARD;
+long double powl(long double, long double) __INTRODUCED_IN(21);
+long double remainderl(long double, long double) __INTRODUCED_IN(21);
+long double remquol(long double, long double, int*) __INTRODUCED_IN(21);
+long double rintl(long double) __INTRODUCED_IN(21);
+long double roundl(long double);
+long double scalblnl(long double, long) __INTRODUCED_IN_X86(18) __VERSIONER_NO_GUARD;
+long double scalbnl(long double, int);
+long double sinhl(long double) __INTRODUCED_IN(21);
+long double sinl(long double) __INTRODUCED_IN(21);
+long double sqrtl(long double) __INTRODUCED_IN(21);
+long double tanhl(long double) __INTRODUCED_IN(21);
+long double tanl(long double) __INTRODUCED_IN(21);
+long double tgammal(long double) __INTRODUCED_IN(21);
+long double truncl(long double);
+
+double j0(double);
+double j1(double);
+double jn(int, double);
+double y0(double);
+double y1(double);
+double yn(int, double);
+
+#define M_E		2.7182818284590452354	/* e */
+#define M_LOG2E		1.4426950408889634074	/* log 2e */
+#define M_LOG10E	0.43429448190325182765	/* log 10e */
+#define M_LN2		0.69314718055994530942	/* log e2 */
+#define M_LN10		2.30258509299404568402	/* log e10 */
+#define M_PI		3.14159265358979323846	/* pi */
+#define M_PI_2		1.57079632679489661923	/* pi/2 */
+#define M_PI_4		0.78539816339744830962	/* pi/4 */
+#define M_1_PI		0.31830988618379067154	/* 1/pi */
+#define M_2_PI		0.63661977236758134308	/* 2/pi */
+#define M_2_SQRTPI	1.12837916709551257390	/* 2/sqrt(pi) */
+#define M_SQRT2		1.41421356237309504880	/* sqrt(2) */
+#define M_SQRT1_2	0.70710678118654752440	/* 1/sqrt(2) */
+
+#define MAXFLOAT	((float)3.40282346638528860e+38)
+
+#if defined(__USE_BSD) || defined(__USE_GNU)
+double gamma(double);
+double scalb(double, double);
+double drem(double, double);
+int finite(double) __attribute_const__;
+int isnanf(float) __attribute_const__;
+double gamma_r(double, int*);
+double lgamma_r(double, int*);
+double significand(double);
+long double lgammal_r(long double, int*) __INTRODUCED_IN(23);
+long double significandl(long double) __INTRODUCED_IN(21);
+float dremf(float, float);
+int finitef(float) __attribute_const__;
+float gammaf(float);
+float j0f(float);
+float j1f(float);
+float jnf(int, float);
+float scalbf(float, float);
+float y0f(float);
+float y1f(float);
+float ynf(int, float);
+float gammaf_r(float, int *);
+float lgammaf_r(float, int *);
+float significandf(float);
+#endif
+
+#if defined(__USE_GNU)
+#define M_El            2.718281828459045235360287471352662498L /* e */
+#define M_LOG2El        1.442695040888963407359924681001892137L /* log 2e */
+#define M_LOG10El       0.434294481903251827651128918916605082L /* log 10e */
+#define M_LN2l          0.693147180559945309417232121458176568L /* log e2 */
+#define M_LN10l         2.302585092994045684017991454684364208L /* log e10 */
+#define M_PIl           3.141592653589793238462643383279502884L /* pi */
+#define M_PI_2l         1.570796326794896619231321691639751442L /* pi/2 */
+#define M_PI_4l         0.785398163397448309615660845819875721L /* pi/4 */
+#define M_1_PIl         0.318309886183790671537767526745028724L /* 1/pi */
+#define M_2_PIl         0.636619772367581343075535053490057448L /* 2/pi */
+#define M_2_SQRTPIl     1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
+#define M_SQRT2l        1.414213562373095048801688724209698079L /* sqrt(2) */
+#define M_SQRT1_2l      0.707106781186547524400844362104849039L /* 1/sqrt(2) */
+void sincos(double, double*, double*);
+void sincosf(float, float*, float*);
+void sincosl(long double, long double*, long double*);
+#endif
+
+__END_DECLS
+
+#endif /* !_MATH_H_ */
diff --git a/libc/include/mntent.h b/libc/include/mntent.h
index de285d0..ad9d72f 100644
--- a/libc/include/mntent.h
+++ b/libc/include/mntent.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _MNTENT_H_
 #define _MNTENT_H_
 
@@ -33,7 +34,17 @@
 #include <paths.h>  /* for _PATH_MOUNTED */
 
 #define MOUNTED _PATH_MOUNTED
+
 #define MNTTYPE_IGNORE "ignore"
+#define MNTTYPE_NFS "nfs"
+#define MNTTYPE_SWAP "swap"
+
+#define MNTOPT_DEFAULTS "defaults"
+#define MNTOPT_NOAUTO "noauto"
+#define MNTOPT_NOSUID "nosuid"
+#define MNTOPT_RO "ro"
+#define MNTOPT_RW "rw"
+#define MNTOPT_SUID "suid"
 
 struct mntent {
   char* mnt_fsname;
@@ -46,10 +57,11 @@
 
 __BEGIN_DECLS
 
-int endmntent(FILE*);
+int endmntent(FILE*) __INTRODUCED_IN(21);
 struct mntent* getmntent(FILE*);
-struct mntent* getmntent_r(FILE*, struct mntent*, char*, int);
-FILE* setmntent(const char*, const char*);
+struct mntent* getmntent_r(FILE*, struct mntent*, char*, int) __INTRODUCED_IN(21);
+FILE* setmntent(const char*, const char*) __INTRODUCED_IN(21);
+char* hasmntopt(const struct mntent*, const char*) __INTRODUCED_IN_FUTURE;
 
 __END_DECLS
 
diff --git a/libc/include/net/ethernet.h b/libc/include/net/ethernet.h
index 47858b3..d5ba11f 100644
--- a/libc/include/net/ethernet.h
+++ b/libc/include/net/ethernet.h
@@ -29,7 +29,52 @@
 #ifndef _NET_ETHERNET_H_
 #define _NET_ETHERNET_H_
 
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
 #include <linux/if_ether.h>
-#include <net/if_ether.h>
+
+#define ETHERTYPE_IP 0x0800
+#define ETHERTYPE_ARP 0x0806
+#define ETHERTYPE_REVARP 0x8035
+#define ETHERTYPE_VLAN 0x8100
+#define ETHERTYPE_IPX 0x8137
+#define ETHERTYPE_IPV6 0x86dd
+#define ETHERTYPE_LOOPBACK 0x9000
+
+#define ETHERTYPE_TRAIL 0x1000
+#define ETHERTYPE_NTRAILER 16
+
+/*
+ * Some basic Ethernet constants.
+ */
+#define	ETHER_ADDR_LEN	6	/* length of an Ethernet address */
+#define	ETHER_TYPE_LEN	2	/* length of the Ethernet type field */
+#define	ETHER_CRC_LEN	4	/* length of the Ethernet CRC */
+#define	ETHER_HDR_LEN	((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN)
+#define	ETHER_MIN_LEN	64	/* minimum frame length, including CRC */
+#define	ETHER_MAX_LEN	1518	/* maximum frame length, including CRC */
+#define	ETHER_MAX_LEN_JUMBO 9018 /* maximum jumbo frame len, including CRC */
+
+/*
+ * Ethernet address - 6 octets
+ * this is only used by the ethers(3) functions.
+ */
+struct ether_addr {
+	u_int8_t ether_addr_octet[ETHER_ADDR_LEN];
+} __attribute__((__packed__));
+
+/*
+ * Structure of a 10Mb/s Ethernet header.
+ */
+struct	ether_header {
+	u_int8_t  ether_dhost[ETHER_ADDR_LEN];
+	u_int8_t  ether_shost[ETHER_ADDR_LEN];
+	u_int16_t ether_type;
+} __attribute__((__packed__));
+
+#define	ETHERMTU_JUMBO	(ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN)
+#define	ETHERMTU	(ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
+#define	ETHERMIN	(ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
 
 #endif
diff --git a/libc/include/net/ethertypes.h b/libc/include/net/ethertypes.h
deleted file mode 100644
index 1cfd2cd..0000000
--- a/libc/include/net/ethertypes.h
+++ /dev/null
@@ -1,313 +0,0 @@
-/*	$NetBSD: ethertypes.h,v 1.17 2005/12/10 23:21:38 elad Exp $	*/
-
-/*
- * Copyright (c) 1982, 1986, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)if_ether.h	8.1 (Berkeley) 6/10/93
- */
-
-/*
- * Ethernet protocol types.
- *
- * According to "assigned numbers", the Ethernet protocol numbers are also
- * used as ARP protocol type numbers.
- *
- * I factor them out here to avoid pulling all the Ethernet header file
- * into the hardware independent ARP code. -is
- *
- * Additional sources of information:
- *	http://www.mit.edu/~map/Ethernet/Ethernet.txt
- *	ftp://venera.isi.edu/in-notes/iana/assignments/ethernet-numbers
- *
- */
-
-#ifndef _NET_ETHERTYPES_H_
-#define	_NET_ETHERTYPES_H_
-
-/*
- *  NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields.
- *  However, there are some conflicts.
- */
-
-#define	ETHERTYPE_8023		0x0004	/* IEEE 802.3 packet */
-		   /* 0x0101 .. 0x1FF	   Experimental */
-#define	ETHERTYPE_PUP		0x0200	/* Xerox PUP protocol - see 0A00 */
-#define	ETHERTYPE_PUPAT		0x0200	/* PUP Address Translation - see 0A01 */
-#define	ETHERTYPE_SPRITE	0x0500	/* ??? */
-			     /* 0x0400	   Nixdorf */
-#define	ETHERTYPE_NS		0x0600	/* XNS */
-#define	ETHERTYPE_NSAT		0x0601	/* XNS Address Translation (3Mb only) */
-#define	ETHERTYPE_DLOG1 	0x0660	/* DLOG (?) */
-#define	ETHERTYPE_DLOG2 	0x0661	/* DLOG (?) */
-#define	ETHERTYPE_IP		0x0800	/* IP protocol */
-#define	ETHERTYPE_X75		0x0801	/* X.75 Internet */
-#define	ETHERTYPE_NBS		0x0802	/* NBS Internet */
-#define	ETHERTYPE_ECMA		0x0803	/* ECMA Internet */
-#define	ETHERTYPE_CHAOS 	0x0804	/* CHAOSnet */
-#define	ETHERTYPE_X25		0x0805	/* X.25 Level 3 */
-#define	ETHERTYPE_ARP		0x0806	/* Address resolution protocol */
-#define	ETHERTYPE_NSCOMPAT	0x0807	/* XNS Compatibility */
-#define	ETHERTYPE_FRARP 	0x0808	/* Frame Relay ARP (RFC1701) */
-			     /* 0x081C	   Symbolics Private */
-		    /* 0x0888 - 0x088A	   Xyplex */
-#define	ETHERTYPE_UBDEBUG	0x0900	/* Ungermann-Bass network debugger */
-#define	ETHERTYPE_IEEEPUP	0x0A00	/* Xerox IEEE802.3 PUP */
-#define	ETHERTYPE_IEEEPUPAT	0x0A01	/* Xerox IEEE802.3 PUP Address Translation */
-#define	ETHERTYPE_VINES 	0x0BAD	/* Banyan VINES */
-#define	ETHERTYPE_VINESLOOP	0x0BAE	/* Banyan VINES Loopback */
-#define	ETHERTYPE_VINESECHO	0x0BAF	/* Banyan VINES Echo */
-
-/*		       0x1000 - 0x100F	   Berkeley Trailer */
-/*
- * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
- * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
- * by an ETHER type (as given above) and then the (variable-length) header.
- */
-#define	ETHERTYPE_TRAIL		0x1000	/* Trailer packet */
-#define	ETHERTYPE_NTRAILER	16
-
-#define	ETHERTYPE_DCA		0x1234	/* DCA - Multicast */
-#define	ETHERTYPE_VALID 	0x1600	/* VALID system protocol */
-#define	ETHERTYPE_DOGFIGHT	0x1989	/* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */
-#define	ETHERTYPE_RCL		0x1995	/* Datapoint Corporation (RCL lan protocol) */
-
-					/* The following 3C0x types
-					   are unregistered: */
-#define	ETHERTYPE_NBPVCD	0x3C00	/* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */
-#define	ETHERTYPE_NBPSCD	0x3C01	/* 3Com NBP System control datagram not registered */
-#define	ETHERTYPE_NBPCREQ	0x3C02	/* 3Com NBP Connect request (virtual cct) not registered */
-#define	ETHERTYPE_NBPCRSP	0x3C03	/* 3Com NBP Connect repsonse not registered */
-#define	ETHERTYPE_NBPCC		0x3C04	/* 3Com NBP Connect complete not registered */
-#define	ETHERTYPE_NBPCLREQ	0x3C05	/* 3Com NBP Close request (virtual cct) not registered */
-#define	ETHERTYPE_NBPCLRSP	0x3C06	/* 3Com NBP Close response not registered */
-#define	ETHERTYPE_NBPDG		0x3C07	/* 3Com NBP Datagram (like XNS IDP) not registered */
-#define	ETHERTYPE_NBPDGB	0x3C08	/* 3Com NBP Datagram broadcast not registered */
-#define	ETHERTYPE_NBPCLAIM	0x3C09	/* 3Com NBP Claim NetBIOS name not registered */
-#define	ETHERTYPE_NBPDLTE	0x3C0A	/* 3Com NBP Delete Netbios name not registered */
-#define	ETHERTYPE_NBPRAS	0x3C0B	/* 3Com NBP Remote adaptor status request not registered */
-#define	ETHERTYPE_NBPRAR	0x3C0C	/* 3Com NBP Remote adaptor response not registered */
-#define	ETHERTYPE_NBPRST	0x3C0D	/* 3Com NBP Reset not registered */
-
-#define	ETHERTYPE_PCS		0x4242	/* PCS Basic Block Protocol */
-#define	ETHERTYPE_IMLBLDIAG	0x424C	/* Information Modes Little Big LAN diagnostic */
-#define	ETHERTYPE_DIDDLE	0x4321	/* THD - Diddle */
-#define	ETHERTYPE_IMLBL		0x4C42	/* Information Modes Little Big LAN */
-#define	ETHERTYPE_SIMNET	0x5208	/* BBN Simnet Private */
-#define	ETHERTYPE_DECEXPER	0x6000	/* DEC Unassigned, experimental */
-#define	ETHERTYPE_MOPDL		0x6001	/* DEC MOP dump/load */
-#define	ETHERTYPE_MOPRC		0x6002	/* DEC MOP remote console */
-#define	ETHERTYPE_DECnet	0x6003	/* DEC DECNET Phase IV route */
-#define	ETHERTYPE_DN		ETHERTYPE_DECnet	/* libpcap, tcpdump */
-#define	ETHERTYPE_LAT		0x6004	/* DEC LAT */
-#define	ETHERTYPE_DECDIAG	0x6005	/* DEC diagnostic protocol (at interface initialization?) */
-#define	ETHERTYPE_DECCUST	0x6006	/* DEC customer protocol */
-#define	ETHERTYPE_SCA		0x6007	/* DEC LAVC, SCA */
-#define	ETHERTYPE_AMBER		0x6008	/* DEC AMBER */
-#define	ETHERTYPE_DECMUMPS	0x6009	/* DEC MUMPS */
-		    /* 0x6010 - 0x6014	   3Com Corporation */
-#define	ETHERTYPE_TRANSETHER	0x6558	/* Trans Ether Bridging (RFC1701)*/
-#define	ETHERTYPE_RAWFR		0x6559	/* Raw Frame Relay (RFC1701) */
-#define	ETHERTYPE_UBDL		0x7000	/* Ungermann-Bass download */
-#define	ETHERTYPE_UBNIU		0x7001	/* Ungermann-Bass NIUs */
-#define	ETHERTYPE_UBDIAGLOOP	0x7002	/* Ungermann-Bass diagnostic/loopback */
-#define	ETHERTYPE_UBNMC		0x7003	/* Ungermann-Bass ??? (NMC to/from UB Bridge) */
-#define	ETHERTYPE_UBBST		0x7005	/* Ungermann-Bass Bridge Spanning Tree */
-#define	ETHERTYPE_OS9		0x7007	/* OS/9 Microware */
-#define	ETHERTYPE_OS9NET	0x7009	/* OS/9 Net? */
-		    /* 0x7020 - 0x7029	   LRT (England) (now Sintrom) */
-#define	ETHERTYPE_RACAL		0x7030	/* Racal-Interlan */
-#define	ETHERTYPE_PRIMENTS	0x7031	/* Prime NTS (Network Terminal Service) */
-#define	ETHERTYPE_CABLETRON	0x7034	/* Cabletron */
-#define	ETHERTYPE_CRONUSVLN	0x8003	/* Cronus VLN */
-#define	ETHERTYPE_CRONUS	0x8004	/* Cronus Direct */
-#define	ETHERTYPE_HP		0x8005	/* HP Probe */
-#define	ETHERTYPE_NESTAR	0x8006	/* Nestar */
-#define	ETHERTYPE_ATTSTANFORD	0x8008	/* AT&T/Stanford (local use) */
-#define	ETHERTYPE_EXCELAN	0x8010	/* Excelan */
-#define	ETHERTYPE_SG_DIAG	0x8013	/* SGI diagnostic type */
-#define	ETHERTYPE_SG_NETGAMES	0x8014	/* SGI network games */
-#define	ETHERTYPE_SG_RESV	0x8015	/* SGI reserved type */
-#define	ETHERTYPE_SG_BOUNCE	0x8016	/* SGI bounce server */
-#define	ETHERTYPE_APOLLODOMAIN	0x8019	/* Apollo DOMAIN */
-#define	ETHERTYPE_TYMSHARE	0x802E	/* Tymeshare */
-#define	ETHERTYPE_TIGAN		0x802F	/* Tigan, Inc. */
-#define	ETHERTYPE_REVARP	0x8035	/* Reverse addr resolution protocol */
-#define	ETHERTYPE_AEONIC	0x8036	/* Aeonic Systems */
-#define	ETHERTYPE_IPXNEW	0x8037	/* IPX (Novell Netware?) */
-#define	ETHERTYPE_LANBRIDGE	0x8038	/* DEC LANBridge */
-#define	ETHERTYPE_DSMD	0x8039	/* DEC DSM/DDP */
-#define	ETHERTYPE_ARGONAUT	0x803A	/* DEC Argonaut Console */
-#define	ETHERTYPE_VAXELN	0x803B	/* DEC VAXELN */
-#define	ETHERTYPE_DECDNS	0x803C	/* DEC DNS Naming Service */
-#define	ETHERTYPE_ENCRYPT	0x803D	/* DEC Ethernet Encryption */
-#define	ETHERTYPE_DECDTS	0x803E	/* DEC Distributed Time Service */
-#define	ETHERTYPE_DECLTM	0x803F	/* DEC LAN Traffic Monitor */
-#define	ETHERTYPE_DECNETBIOS	0x8040	/* DEC PATHWORKS DECnet NETBIOS Emulation */
-#define	ETHERTYPE_DECLAST	0x8041	/* DEC Local Area System Transport */
-			     /* 0x8042	   DEC Unassigned */
-#define	ETHERTYPE_PLANNING	0x8044	/* Planning Research Corp. */
-		    /* 0x8046 - 0x8047	   AT&T */
-#define	ETHERTYPE_DECAM		0x8048	/* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */
-#define	ETHERTYPE_EXPERDATA	0x8049	/* ExperData */
-#define	ETHERTYPE_VEXP		0x805B	/* Stanford V Kernel exp. */
-#define	ETHERTYPE_VPROD		0x805C	/* Stanford V Kernel prod. */
-#define	ETHERTYPE_ES		0x805D	/* Evans & Sutherland */
-#define	ETHERTYPE_LITTLE	0x8060	/* Little Machines */
-#define	ETHERTYPE_COUNTERPOINT	0x8062	/* Counterpoint Computers */
-		    /* 0x8065 - 0x8066	   Univ. of Mass @ Amherst */
-#define	ETHERTYPE_VEECO		0x8067	/* Veeco Integrated Auto. */
-#define	ETHERTYPE_GENDYN	0x8068	/* General Dynamics */
-#define	ETHERTYPE_ATT		0x8069	/* AT&T */
-#define	ETHERTYPE_AUTOPHON	0x806A	/* Autophon */
-#define	ETHERTYPE_COMDESIGN	0x806C	/* ComDesign */
-#define	ETHERTYPE_COMPUGRAPHIC	0x806D	/* Compugraphic Corporation */
-		    /* 0x806E - 0x8077	   Landmark Graphics Corp. */
-#define	ETHERTYPE_MATRA		0x807A	/* Matra */
-#define	ETHERTYPE_DDE		0x807B	/* Dansk Data Elektronik */
-#define	ETHERTYPE_MERIT		0x807C	/* Merit Internodal (or Univ of Michigan?) */
-		    /* 0x807D - 0x807F	   Vitalink Communications */
-#define	ETHERTYPE_VLTLMAN	0x8080	/* Vitalink TransLAN III Management */
-		    /* 0x8081 - 0x8083	   Counterpoint Computers */
-		    /* 0x8088 - 0x808A	   Xyplex */
-#define	ETHERTYPE_ATALK		0x809B	/* AppleTalk */
-#define	ETHERTYPE_AT		ETHERTYPE_ATALK		/* old NetBSD */
-#define	ETHERTYPE_APPLETALK	ETHERTYPE_ATALK		/* HP-UX */
-		    /* 0x809C - 0x809E	   Datability */
-#define	ETHERTYPE_SPIDER	0x809F	/* Spider Systems Ltd. */
-			     /* 0x80A3	   Nixdorf */
-		    /* 0x80A4 - 0x80B3	   Siemens Gammasonics Inc. */
-		    /* 0x80C0 - 0x80C3	   DCA (Digital Comm. Assoc.) Data Exchange Cluster */
-		    /* 0x80C4 - 0x80C5	   Banyan Systems */
-#define	ETHERTYPE_PACER		0x80C6	/* Pacer Software */
-#define	ETHERTYPE_APPLITEK	0x80C7	/* Applitek Corporation */
-		    /* 0x80C8 - 0x80CC	   Intergraph Corporation */
-		    /* 0x80CD - 0x80CE	   Harris Corporation */
-		    /* 0x80CF - 0x80D2	   Taylor Instrument */
-		    /* 0x80D3 - 0x80D4	   Rosemount Corporation */
-#define	ETHERTYPE_SNA		0x80D5	/* IBM SNA Services over Ethernet */
-#define	ETHERTYPE_VARIAN	0x80DD	/* Varian Associates */
-		    /* 0x80DE - 0x80DF	   TRFS (Integrated Solutions Transparent Remote File System) */
-		    /* 0x80E0 - 0x80E3	   Allen-Bradley */
-		    /* 0x80E4 - 0x80F0	   Datability */
-#define	ETHERTYPE_RETIX		0x80F2	/* Retix */
-#define	ETHERTYPE_AARP		0x80F3	/* AppleTalk AARP */
-		    /* 0x80F4 - 0x80F5	   Kinetics */
-#define	ETHERTYPE_APOLLO	0x80F7	/* Apollo Computer */
-#define ETHERTYPE_VLAN		0x8100	/* IEEE 802.1Q VLAN tagging (XXX conflicts) */
-		    /* 0x80FF - 0x8101	   Wellfleet Communications (XXX conflicts) */
-#define	ETHERTYPE_BOFL		0x8102	/* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */
-#define	ETHERTYPE_WELLFLEET	0x8103	/* Wellfleet Communications */
-		    /* 0x8107 - 0x8109	   Symbolics Private */
-#define	ETHERTYPE_TALARIS	0x812B	/* Talaris */
-#define	ETHERTYPE_WATERLOO	0x8130	/* Waterloo Microsystems Inc. (XXX which?) */
-#define	ETHERTYPE_HAYES		0x8130	/* Hayes Microcomputers (XXX which?) */
-#define	ETHERTYPE_VGLAB		0x8131	/* VG Laboratory Systems */
-		    /* 0x8132 - 0x8137	   Bridge Communications */
-#define	ETHERTYPE_IPX		0x8137	/* Novell (old) NetWare IPX (ECONFIG E option) */
-#define	ETHERTYPE_NOVELL	0x8138	/* Novell, Inc. */
-		    /* 0x8139 - 0x813D	   KTI */
-#define	ETHERTYPE_MUMPS		0x813F	/* M/MUMPS data sharing */
-#define	ETHERTYPE_AMOEBA	0x8145	/* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */
-#define	ETHERTYPE_FLIP		0x8146	/* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */
-#define	ETHERTYPE_VURESERVED	0x8147	/* Vrije Universiteit (NL) [reserved] */
-#define	ETHERTYPE_LOGICRAFT	0x8148	/* Logicraft */
-#define	ETHERTYPE_NCD		0x8149	/* Network Computing Devices */
-#define	ETHERTYPE_ALPHA		0x814A	/* Alpha Micro */
-#define	ETHERTYPE_SNMP		0x814C	/* SNMP over Ethernet (see RFC1089) */
-		    /* 0x814D - 0x814E	   BIIN */
-#define	ETHERTYPE_TEC	0x814F	/* Technically Elite Concepts */
-#define	ETHERTYPE_RATIONAL	0x8150	/* Rational Corp */
-		    /* 0x8151 - 0x8153	   Qualcomm */
-		    /* 0x815C - 0x815E	   Computer Protocol Pty Ltd */
-		    /* 0x8164 - 0x8166	   Charles River Data Systems */
-#define	ETHERTYPE_XTP		0x817D	/* Protocol Engines XTP */
-#define	ETHERTYPE_SGITW		0x817E	/* SGI/Time Warner prop. */
-#define	ETHERTYPE_HIPPI_FP	0x8180	/* HIPPI-FP encapsulation */
-#define	ETHERTYPE_STP		0x8181	/* Scheduled Transfer STP, HIPPI-ST */
-		    /* 0x8182 - 0x8183	   Reserved for HIPPI-6400 */
-		    /* 0x8184 - 0x818C	   SGI prop. */
-#define	ETHERTYPE_MOTOROLA	0x818D	/* Motorola */
-#define	ETHERTYPE_NETBEUI	0x8191	/* PowerLAN NetBIOS/NetBEUI (PC) */
-		    /* 0x819A - 0x81A3	   RAD Network Devices */
-		    /* 0x81B7 - 0x81B9	   Xyplex */
-		    /* 0x81CC - 0x81D5	   Apricot Computers */
-		    /* 0x81D6 - 0x81DD	   Artisoft Lantastic */
-		    /* 0x81E6 - 0x81EF	   Polygon */
-		    /* 0x81F0 - 0x81F2	   Comsat Labs */
-		    /* 0x81F3 - 0x81F5	   SAIC */
-		    /* 0x81F6 - 0x81F8	   VG Analytical */
-		    /* 0x8203 - 0x8205	   QNX Software Systems Ltd. */
-		    /* 0x8221 - 0x8222	   Ascom Banking Systems */
-		    /* 0x823E - 0x8240	   Advanced Encryption Systems */
-		    /* 0x8263 - 0x826A	   Charles River Data Systems */
-		    /* 0x827F - 0x8282	   Athena Programming */
-		    /* 0x829A - 0x829B	   Inst Ind Info Tech */
-		    /* 0x829C - 0x82AB	   Taurus Controls */
-		    /* 0x82AC - 0x8693	   Walker Richer & Quinn */
-#define	ETHERTYPE_ACCTON	0x8390	/* Accton Technologies (unregistered) */
-#define	ETHERTYPE_TALARISMC	0x852B	/* Talaris multicast */
-#define	ETHERTYPE_KALPANA	0x8582	/* Kalpana */
-		    /* 0x8694 - 0x869D	   Idea Courier */
-		    /* 0x869E - 0x86A1	   Computer Network Tech */
-		    /* 0x86A3 - 0x86AC	   Gateway Communications */
-#define	ETHERTYPE_SECTRA	0x86DB	/* SECTRA */
-#define	ETHERTYPE_IPV6		0x86DD	/* IP protocol version 6 */
-#define	ETHERTYPE_DELTACON	0x86DE	/* Delta Controls */
-#define	ETHERTYPE_ATOMIC	0x86DF	/* ATOMIC */
-		    /* 0x86E0 - 0x86EF	   Landis & Gyr Powers */
-		    /* 0x8700 - 0x8710	   Motorola */
-#define	ETHERTYPE_RDP		0x8739	/* Control Technology Inc. RDP Without IP */
-#define	ETHERTYPE_MICP		0x873A	/* Control Technology Inc. Mcast Industrial Ctrl Proto. */
-		    /* 0x873B - 0x873C	   Control Technology Inc. Proprietary */
-#define	ETHERTYPE_TCPCOMP	0x876B	/* TCP/IP Compression (RFC1701) */
-#define	ETHERTYPE_IPAS		0x876C	/* IP Autonomous Systems (RFC1701) */
-#define	ETHERTYPE_SECUREDATA	0x876D	/* Secure Data (RFC1701) */
-#define	ETHERTYPE_FLOWCONTROL	0x8808	/* 802.3x flow control packet */
-#define	ETHERTYPE_SLOWPROTOCOLS	0x8809	/* Slow protocols */
-#define	ETHERTYPE_PPP		0x880B	/* PPP (obsolete by PPPOE) */
-#define	ETHERTYPE_HITACHI	0x8820	/* Hitachi Cable (Optoelectronic Systems Laboratory) */
-#define	ETHERTYPE_MPLS		0x8847	/* MPLS Unicast */
-#define	ETHERTYPE_MPLS_MCAST	0x8848	/* MPLS Multicast */
-#define	ETHERTYPE_AXIS		0x8856	/* Axis Communications AB proprietary bootstrap/config */
-#define	ETHERTYPE_PPPOEDISC	0x8863	/* PPP Over Ethernet Discovery Stage */
-#define	ETHERTYPE_PPPOE		0x8864	/* PPP Over Ethernet Session Stage */
-#define	ETHERTYPE_LANPROBE	0x8888	/* HP LanProbe test? */
-#define	ETHERTYPE_PAE		0x888e	/* EAPOL PAE/802.1x */
-#define	ETHERTYPE_LOOPBACK	0x9000	/* Loopback */
-#define	ETHERTYPE_LBACK		ETHERTYPE_LOOPBACK	/* DEC MOP loopback */
-#define	ETHERTYPE_XNSSM		0x9001	/* 3Com (Formerly Bridge Communications), XNS Systems Management */
-#define	ETHERTYPE_TCPSM		0x9002	/* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */
-#define	ETHERTYPE_BCLOOP	0x9003	/* 3Com (Formerly Bridge Communications), loopback detection */
-#define	ETHERTYPE_DEBNI		0xAAAA	/* DECNET? Used by VAX 6220 DEBNI */
-#define	ETHERTYPE_SONIX		0xFAF5	/* Sonix Arpeggio */
-#define	ETHERTYPE_VITAL		0xFF00	/* BBN VITAL-LanBridge cache wakeups */
-		    /* 0xFF00 - 0xFFOF	   ISC Bunker Ramo */
-
-#define	ETHERTYPE_MAX		0xFFFF	/* Maximum valid ethernet type, reserved */
-
-#endif /* !_NET_ETHERTYPES_H_ */
diff --git a/libc/include/net/if.h b/libc/include/net/if.h
index aa4c19e..eac7699 100644
--- a/libc/include/net/if.h
+++ b/libc/include/net/if.h
@@ -46,8 +46,8 @@
 
 char* if_indextoname(unsigned, char*);
 unsigned if_nametoindex(const char*);
-struct if_nameindex* if_nameindex(void);
-void if_freenameindex(struct if_nameindex*);
+struct if_nameindex* if_nameindex(void) __INTRODUCED_IN(24);
+void if_freenameindex(struct if_nameindex*) __INTRODUCED_IN(24);
 
 __END_DECLS
 
diff --git a/libc/include/net/if_ether.h b/libc/include/net/if_ether.h
deleted file mode 100644
index 8daa16b..0000000
--- a/libc/include/net/if_ether.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*	$NetBSD: if_ether.h,v 1.43 2006/11/24 01:04:30 rpaulo Exp $	*/
-
-/*
- * Copyright (c) 1982, 1986, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)if_ether.h	8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _NET_IF_ETHER_H_
-#define _NET_IF_ETHER_H_
-
-#include <sys/types.h>
-
-#ifdef _KERNEL
-#ifdef _KERNEL_OPT
-#include "opt_mbuftrace.h"
-#endif
-#include <sys/mbuf.h>
-#endif
-
-/*
- * Some basic Ethernet constants.
- */
-#define	ETHER_ADDR_LEN	6	/* length of an Ethernet address */
-#define	ETHER_TYPE_LEN	2	/* length of the Ethernet type field */
-#define	ETHER_CRC_LEN	4	/* length of the Ethernet CRC */
-#define	ETHER_HDR_LEN	((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN)
-#define	ETHER_MIN_LEN	64	/* minimum frame length, including CRC */
-#define	ETHER_MAX_LEN	1518	/* maximum frame length, including CRC */
-#define	ETHER_MAX_LEN_JUMBO 9018 /* maximum jumbo frame len, including CRC */
-
-/*
- * Some Ethernet extensions.
- */
-#define	ETHER_VLAN_ENCAP_LEN 4	/* length of 802.1Q VLAN encapsulation */
-
-/*
- * Ethernet address - 6 octets
- * this is only used by the ethers(3) functions.
- */
-struct ether_addr {
-	u_int8_t ether_addr_octet[ETHER_ADDR_LEN];
-} __attribute__((__packed__));
-
-/*
- * Structure of a 10Mb/s Ethernet header.
- */
-struct	ether_header {
-	u_int8_t  ether_dhost[ETHER_ADDR_LEN];
-	u_int8_t  ether_shost[ETHER_ADDR_LEN];
-	u_int16_t ether_type;
-} __attribute__((__packed__));
-
-#include <net/ethertypes.h>
-
-#define	ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
-
-#define	ETHERMTU_JUMBO	(ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN)
-#define	ETHERMTU	(ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
-#define	ETHERMIN	(ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
-
-/*
- * Compute the maximum frame size based on ethertype (i.e. possible
- * encapsulation) and whether or not an FCS is present.
- */
-#define	ETHER_MAX_FRAME(ifp, etype, hasfcs)				\
-	((ifp)->if_mtu + ETHER_HDR_LEN +				\
-	 ((hasfcs) ? ETHER_CRC_LEN : 0) +				\
-	 (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0))
-
-/*
- * Ethernet CRC32 polynomials (big- and little-endian verions).
- */
-#define	ETHER_CRC_POLY_LE	0xedb88320
-#define	ETHER_CRC_POLY_BE	0x04c11db6
-
-#ifndef _STANDALONE
-
-/*
- * Ethernet-specific mbuf flags.
- */
-#define	M_HASFCS	M_LINK0	/* FCS included at end of frame */
-#define	M_PROMISC	M_LINK1	/* this packet is not for us */
-
-#ifdef _KERNEL
-/*
- * Macro to map an IP multicast address to an Ethernet multicast address.
- * The high-order 25 bits of the Ethernet address are statically assigned,
- * and the low-order 23 bits are taken from the low end of the IP address.
- */
-#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr)				\
-	/* struct in_addr *ipaddr; */					\
-	/* u_int8_t enaddr[ETHER_ADDR_LEN]; */				\
-{									\
-	(enaddr)[0] = 0x01;						\
-	(enaddr)[1] = 0x00;						\
-	(enaddr)[2] = 0x5e;						\
-	(enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f;			\
-	(enaddr)[4] = ((u_int8_t *)ipaddr)[2];				\
-	(enaddr)[5] = ((u_int8_t *)ipaddr)[3];				\
-}
-/*
- * Macro to map an IP6 multicast address to an Ethernet multicast address.
- * The high-order 16 bits of the Ethernet address are statically assigned,
- * and the low-order 32 bits are taken from the low end of the IP6 address.
- */
-#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr)			\
-	/* struct in6_addr *ip6addr; */					\
-	/* u_int8_t enaddr[ETHER_ADDR_LEN]; */				\
-{                                                                       \
-	(enaddr)[0] = 0x33;						\
-	(enaddr)[1] = 0x33;						\
-	(enaddr)[2] = ((u_int8_t *)ip6addr)[12];			\
-	(enaddr)[3] = ((u_int8_t *)ip6addr)[13];			\
-	(enaddr)[4] = ((u_int8_t *)ip6addr)[14];			\
-	(enaddr)[5] = ((u_int8_t *)ip6addr)[15];			\
-}
-#endif
-
-#define	ETHERCAP_VLAN_MTU	0x00000001	/* VLAN-compatible MTU */
-#define	ETHERCAP_VLAN_HWTAGGING	0x00000002	/* hardware VLAN tag support */
-#define	ETHERCAP_JUMBO_MTU	0x00000004	/* 9000 byte MTU supported */
-
-#ifdef	_KERNEL
-extern const uint8_t etherbroadcastaddr[ETHER_ADDR_LEN];
-extern const uint8_t ethermulticastaddr_slowprotocols[ETHER_ADDR_LEN];
-extern const uint8_t ether_ipmulticast_min[ETHER_ADDR_LEN];
-extern const uint8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
-
-int	ether_ioctl(struct ifnet *, u_long, caddr_t);
-int	ether_addmulti (struct ifreq *, struct ethercom *);
-int	ether_delmulti (struct ifreq *, struct ethercom *);
-int	ether_changeaddr (struct ifreq *, struct ethercom *);
-int	ether_multiaddr(struct sockaddr *, u_int8_t[], u_int8_t[]);
-
-/*
- * Ethernet 802.1Q VLAN structures.
- */
-
-/* add VLAN tag to input/received packet */
-#define	VLAN_INPUT_TAG(ifp, m, vlanid, _errcase)	\
-	do {								\
-                struct m_tag *mtag =					\
-                    m_tag_get(PACKET_TAG_VLAN, sizeof(u_int), M_NOWAIT);\
-                if (mtag == NULL) {					\
-			ifp->if_ierrors++;				\
-                        printf("%s: unable to allocate VLAN tag\n",	\
-                            ifp->if_xname);				\
-                        m_freem(m);					\
-                        _errcase;					\
-                }							\
-                *(u_int *)(mtag + 1) = vlanid;				\
-                m_tag_prepend(m, mtag);					\
-	} while(0)
-
-/* extract VLAN tag from output/trasmit packet */
-#define VLAN_OUTPUT_TAG(ec, m0)			\
-	VLAN_ATTACHED(ec) ? m_tag_find((m0), PACKET_TAG_VLAN, NULL) : NULL
-
-/* extract VLAN ID value from a VLAN tag */
-#define VLAN_TAG_VALUE(mtag)	\
-	((*(u_int *)(mtag + 1)) & 4095)
-
-/* test if any VLAN is configured for this interface */
-#define VLAN_ATTACHED(ec)	((ec)->ec_nvlans > 0)
-
-void	ether_ifattach(struct ifnet *, const u_int8_t *);
-void	ether_ifdetach(struct ifnet *);
-
-char	*ether_sprintf(const u_int8_t *);
-char	*ether_snprintf(char *, size_t, const u_int8_t *);
-
-u_int32_t ether_crc32_le(const u_int8_t *, size_t);
-u_int32_t ether_crc32_be(const u_int8_t *, size_t);
-
-int	ether_nonstatic_aton(u_char *, char *);
-#else
-/*
- * Prototype ethers(3) functions.
- */
-#include <sys/cdefs.h>
-__BEGIN_DECLS
-char *	ether_ntoa __P((const struct ether_addr *));
-struct ether_addr *
-	ether_aton __P((const char *));
-int	ether_ntohost __P((char *, const struct ether_addr *));
-int	ether_hostton __P((const char *, struct ether_addr *));
-int	ether_line __P((const char *, struct ether_addr *, char *));
-__END_DECLS
-#endif
-
-#endif /* _STANDALONE */
-
-#endif /* !_NET_IF_ETHER_H_ */
diff --git a/libc/include/net/if_ieee1394.h b/libc/include/net/if_ieee1394.h
deleted file mode 100644
index 5a61581..0000000
--- a/libc/include/net/if_ieee1394.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*	$NetBSD: if_ieee1394.h,v 1.6 2005/12/10 23:21:38 elad Exp $	*/
-
-/*
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Atsushi Onoe.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the NetBSD
- *	Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _NET_IF_IEEE1394_H_
-#define _NET_IF_IEEE1394_H_
-
-/* hardware address information for arp / nd */
-struct ieee1394_hwaddr {
-	u_int8_t	iha_uid[8];		/* node unique ID */
-	u_int8_t	iha_maxrec;		/* max_rec in the config ROM */
-	u_int8_t	iha_speed;		/* min of link/PHY speed */
-	u_int8_t	iha_offset[6];		/* unicast FIFO address */
-};
-
-/*
- * BPF wants to see one of these.
- */
-struct ieee1394_bpfhdr {
-	uint8_t		ibh_dhost[8];
-	uint8_t		ibh_shost[8];
-	uint16_t	ibh_type;
-};
-
-#ifdef _KERNEL
-
-/* pseudo header */
-struct ieee1394_header {
-	u_int8_t	ih_uid[8];		/* dst/src uid */
-	u_int8_t	ih_maxrec;		/* dst maxrec for tx */
-	u_int8_t	ih_speed;		/* speed */
-	u_int8_t	ih_offset[6];		/* dst offset */
-};
-
-/* unfragment encapsulation header */
-struct ieee1394_unfraghdr {
-	u_int16_t	iuh_ft;			/* fragment type == 0 */
-	u_int16_t	iuh_etype;		/* ether_type */
-};
-
-/* fragmented encapsulation header */
-struct ieee1394_fraghdr {
-	u_int16_t	ifh_ft_size;		/* fragment type, data size-1 */
-	u_int16_t	ifh_etype_off;		/* etype for first fragment */
-						/* offset for subseq frag */
-	u_int16_t	ifh_dgl;		/* datagram label */
-	u_int16_t	ifh_reserved;
-};
-
-#define	IEEE1394_FT_SUBSEQ	0x8000
-#define	IEEE1394_FT_MORE	0x4000
-
-#define	IEEE1394MTU		1500
-
-#define	IEEE1394_GASP_LEN	8		/* GASP header for Stream */
-#define	IEEE1394_ADDR_LEN	8
-#define	IEEE1394_CRC_LEN	4
-
-struct ieee1394_reass_pkt {
-	LIST_ENTRY(ieee1394_reass_pkt) rp_next;
-	struct mbuf	*rp_m;
-	u_int16_t	rp_size;
-	u_int16_t	rp_etype;
-	u_int16_t	rp_off;
-	u_int16_t	rp_dgl;
-	u_int16_t	rp_len;
-	u_int16_t	rp_ttl;
-};
-
-struct ieee1394_reassq {
-	LIST_ENTRY(ieee1394_reassq) rq_node;
-	LIST_HEAD(, ieee1394_reass_pkt) rq_pkt;
-	u_int32_t	fr_id;
-};
-
-struct ieee1394com {
-	struct ifnet	fc_if;
-	struct ieee1394_hwaddr ic_hwaddr;
-	u_int16_t	ic_dgl;
-	LIST_HEAD(, ieee1394_reassq) ic_reassq;
-};
-
-const char *ieee1394_sprintf(const u_int8_t *);
-void ieee1394_input(struct ifnet *, struct mbuf *, u_int16_t);
-void ieee1394_ifattach(struct ifnet *, const struct ieee1394_hwaddr *);
-void ieee1394_ifdetach(struct ifnet *);
-int  ieee1394_ioctl(struct ifnet *, u_long, caddr_t);
-struct mbuf * ieee1394_fragment(struct ifnet *, struct mbuf *, int, u_int16_t);
-void ieee1394_drain(struct ifnet *);
-void ieee1394_watchdog(struct ifnet *);
-#endif /* _KERNEL */
-
-#endif /* !_NET_IF_IEEE1394_H_ */
diff --git a/libc/include/net/if_types.h b/libc/include/net/if_types.h
deleted file mode 100644
index eff6d53..0000000
--- a/libc/include/net/if_types.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*	$NetBSD: if_types.h,v 1.26 2012/08/05 21:21:41 wiz Exp $	*/
-
-/*
- * Copyright (c) 1989, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)if_types.h	8.3 (Berkeley) 4/28/95
- */
-
-#ifndef _NET_IF_TYPES_H_
-#define _NET_IF_TYPES_H_
-
-/*
- * Interface types for benefit of parsing media address headers.
- * This list is derived from the SNMP list of ifTypes, originally
- * documented in RFC1573, now maintained as:
- *
- * <URL:http://www.iana.org/assignments/smi-numbers>
- */
-
-#define	IFT_OTHER	0x1		/* none of the following */
-#define	IFT_1822	0x2		/* old-style arpanet imp */
-#define	IFT_HDH1822	0x3		/* HDH arpanet imp */
-#define	IFT_X25DDN	0x4		/* x25 to imp */
-#define	IFT_X25		0x5		/* PDN X25 interface (RFC877) */
-#define	IFT_ETHER	0x6		/* Ethernet CSMA/CD */
-#define	IFT_ISO88023	0x7		/* CSMA/CD */
-#define	IFT_ISO88024	0x8		/* Token Bus */
-#define	IFT_ISO88025	0x9		/* Token Ring */
-#define	IFT_ISO88026	0xa		/* MAN */
-#define	IFT_STARLAN	0xb
-#define	IFT_P10		0xc		/* Proteon 10MBit ring */
-#define	IFT_P80		0xd		/* Proteon 80MBit ring */
-#define	IFT_HY		0xe		/* Hyperchannel */
-#define	IFT_FDDI	0xf
-#define	IFT_LAPB	0x10
-#define	IFT_SDLC	0x11
-#define	IFT_T1		0x12
-#define	IFT_CEPT	0x13		/* E1 - european T1 */
-#define	IFT_ISDNBASIC	0x14
-#define	IFT_ISDNPRIMARY	0x15
-#define	IFT_PTPSERIAL	0x16		/* Proprietary PTP serial */
-#define	IFT_PPP		0x17		/* RFC 1331 */
-#define	IFT_LOOP	0x18		/* loopback */
-#define	IFT_EON		0x19		/* ISO over IP */
-#define	IFT_XETHER	0x1a		/* obsolete 3MB experimental ethernet */
-#define	IFT_NSIP	0x1b		/* XNS over IP */
-#define	IFT_SLIP	0x1c		/* IP over generic TTY */
-#define	IFT_ULTRA	0x1d		/* Ultra Technologies */
-#define	IFT_DS3		0x1e		/* Generic T3 */
-#define	IFT_SIP		0x1f		/* SMDS */
-#define	IFT_FRELAY	0x20		/* Frame Relay DTE only */
-#define	IFT_RS232	0x21
-#define	IFT_PARA	0x22		/* parallel-port */
-#define	IFT_ARCNET	0x23
-#define	IFT_ARCNETPLUS	0x24
-#define	IFT_ATM		0x25		/* ATM cells */
-#define	IFT_MIOX25	0x26
-#define	IFT_SONET	0x27		/* SONET or SDH */
-#define	IFT_X25PLE	0x28
-#define	IFT_ISO88022LLC	0x29
-#define	IFT_LOCALTALK	0x2a
-#define	IFT_SMDSDXI	0x2b
-#define	IFT_FRELAYDCE	0x2c		/* Frame Relay DCE */
-#define	IFT_V35		0x2d
-#define	IFT_HSSI	0x2e
-#define	IFT_HIPPI	0x2f
-#define	IFT_MODEM	0x30		/* Generic Modem */
-#define	IFT_AAL5	0x31		/* AAL5 over ATM */
-#define	IFT_SONETPATH	0x32
-#define	IFT_SONETVT	0x33
-#define	IFT_SMDSICIP	0x34		/* SMDS InterCarrier Interface */
-#define	IFT_PROPVIRTUAL	0x35		/* Proprietary Virtual/internal */
-#define	IFT_PROPMUX	0x36		/* Proprietary Multiplexing */
-#define IFT_IEEE80212		   0x37 /* 100BaseVG */
-#define IFT_FIBRECHANNEL	   0x38 /* Fibre Channel */
-#define IFT_HIPPIINTERFACE	   0x39 /* HIPPI interfaces	 */
-#define IFT_FRAMERELAYINTERCONNECT 0x3a /* Obsolete, use either 0x20 or 0x2c */
-#define IFT_AFLANE8023		   0x3b /* ATM Emulated LAN for 802.3 */
-#define IFT_AFLANE8025		   0x3c /* ATM Emulated LAN for 802.5 */
-#define IFT_CCTEMUL		   0x3d /* ATM Emulated circuit		  */
-#define IFT_FASTETHER		   0x3e /* Fast Ethernet (100BaseT) */
-#define IFT_ISDN		   0x3f /* ISDN and X.25	    */
-#define IFT_V11			   0x40 /* CCITT V.11/X.21		*/
-#define IFT_V36			   0x41 /* CCITT V.36			*/
-#define IFT_G703AT64K		   0x42 /* CCITT G703 at 64Kbps */
-#define IFT_G703AT2MB		   0x43 /* Obsolete see DS1-MIB */
-#define IFT_QLLC		   0x44 /* SNA QLLC			*/
-#define IFT_FASTETHERFX		   0x45 /* Fast Ethernet (100BaseFX)	*/
-#define IFT_CHANNEL		   0x46 /* channel			*/
-#define IFT_IEEE80211		   0x47 /* radio spread spectrum	*/
-#define IFT_IBM370PARCHAN	   0x48 /* IBM System 360/370 OEMI Channel */
-#define IFT_ESCON		   0x49 /* IBM Enterprise Systems Connection */
-#define IFT_DLSW		   0x4a /* Data Link Switching */
-#define IFT_ISDNS		   0x4b /* ISDN S/T interface */
-#define IFT_ISDNU		   0x4c /* ISDN U interface */
-#define IFT_LAPD		   0x4d /* Link Access Protocol D */
-#define IFT_IPSWITCH		   0x4e /* IP Switching Objects */
-#define IFT_RSRB		   0x4f /* Remote Source Route Bridging */
-#define IFT_ATMLOGICAL		   0x50 /* ATM Logical Port */
-#define IFT_DS0			   0x51 /* Digital Signal Level 0 */
-#define IFT_DS0BUNDLE		   0x52 /* group of ds0s on the same ds1 */
-#define IFT_BSC			   0x53 /* Bisynchronous Protocol */
-#define IFT_ASYNC		   0x54 /* Asynchronous Protocol */
-#define IFT_CNR			   0x55 /* Combat Net Radio */
-#define IFT_ISO88025DTR		   0x56 /* ISO 802.5r DTR */
-#define IFT_EPLRS		   0x57 /* Ext Pos Loc Report Sys */
-#define IFT_ARAP		   0x58 /* Appletalk Remote Access Protocol */
-#define IFT_PROPCNLS		   0x59 /* Proprietary Connectionless Protocol*/
-#define IFT_HOSTPAD		   0x5a /* CCITT-ITU X.29 PAD Protocol */
-#define IFT_TERMPAD		   0x5b /* CCITT-ITU X.3 PAD Facility */
-#define IFT_FRAMERELAYMPI	   0x5c /* Multiproto Interconnect over FR */
-#define IFT_X213		   0x5d /* CCITT-ITU X213 */
-#define IFT_ADSL		   0x5e /* Asymmetric Digital Subscriber Loop */
-#define IFT_RADSL		   0x5f /* Rate-Adapt. Digital Subscriber Loop*/
-#define IFT_SDSL		   0x60 /* Symmetric Digital Subscriber Loop */
-#define IFT_VDSL		   0x61 /* Very H-Speed Digital Subscrib. Loop*/
-#define IFT_ISO88025CRFPINT	   0x62 /* ISO 802.5 CRFP */
-#define IFT_MYRINET		   0x63 /* Myricom Myrinet */
-#define IFT_VOICEEM		   0x64 /* voice recEive and transMit */
-#define IFT_VOICEFXO		   0x65 /* voice Foreign Exchange Office */
-#define IFT_VOICEFXS		   0x66 /* voice Foreign Exchange Station */
-#define IFT_VOICEENCAP		   0x67 /* voice encapsulation */
-#define IFT_VOICEOVERIP		   0x68 /* voice over IP encapsulation */
-#define IFT_ATMDXI		   0x69 /* ATM DXI */
-#define IFT_ATMFUNI		   0x6a /* ATM FUNI */
-#define IFT_ATMIMA		   0x6b /* ATM IMA		      */
-#define IFT_PPPMULTILINKBUNDLE	   0x6c /* PPP Multilink Bundle */
-#define IFT_IPOVERCDLC		   0x6d /* IBM ipOverCdlc */
-#define IFT_IPOVERCLAW		   0x6e /* IBM Common Link Access to Workstn */
-#define IFT_STACKTOSTACK	   0x6f /* IBM stackToStack */
-#define IFT_VIRTUALIPADDRESS	   0x70 /* IBM VIPA */
-#define IFT_MPC			   0x71 /* IBM multi-protocol channel support */
-#define IFT_IPOVERATM		   0x72 /* IBM ipOverAtm */
-#define IFT_ISO88025FIBER	   0x73 /* ISO 802.5j Fiber Token Ring */
-#define IFT_TDLC		   0x74 /* IBM twinaxial data link control */
-#define IFT_GIGABITETHERNET	   0x75 /* Gigabit Ethernet */
-#define IFT_HDLC		   0x76 /* HDLC */
-#define IFT_LAPF		   0x77 /* LAP F */
-#define IFT_V37			   0x78 /* V.37 */
-#define IFT_X25MLP		   0x79 /* Multi-Link Protocol */
-#define IFT_X25HUNTGROUP	   0x7a /* X25 Hunt Group */
-#define IFT_TRANSPHDLC		   0x7b /* Transp HDLC */
-#define IFT_INTERLEAVE		   0x7c /* Interleave channel */
-#define IFT_FAST		   0x7d /* Fast channel */
-#define IFT_IP			   0x7e /* IP (for APPN HPR in IP networks) */
-#define IFT_DOCSCABLEMACLAYER	   0x7f /* CATV Mac Layer */
-#define IFT_DOCSCABLEDOWNSTREAM	   0x80 /* CATV Downstream interface */
-#define IFT_DOCSCABLEUPSTREAM	   0x81 /* CATV Upstream interface */
-#define IFT_A12MPPSWITCH	   0x82	/* Avalon Parallel Processor */
-#define IFT_TUNNEL		   0x83	/* Encapsulation interface */
-#define IFT_COFFEE		   0x84	/* coffee pot */
-#define IFT_CES			   0x85	/* Circiut Emulation Service */
-#define IFT_ATMSUBINTERFACE	   0x86	/* (x)  ATM Sub Interface */
-#define IFT_L2VLAN		   0x87	/* Layer 2 Virtual LAN using 802.1Q */
-#define IFT_L3IPVLAN		   0x88	/* Layer 3 Virtual LAN - IP Protocol */
-#define IFT_L3IPXVLAN		   0x89	/* Layer 3 Virtual LAN - IPX Prot. */
-#define IFT_DIGITALPOWERLINE	   0x8a	/* IP over Power Lines */
-#define IFT_MEDIAMAILOVERIP	   0x8b	/* (xxx)  Multimedia Mail over IP */
-#define IFT_DTM			   0x8c	/* Dynamic synchronous Transfer Mode */
-#define IFT_DCN			   0x8d	/* Data Communications Network */
-#define IFT_IPFORWARD		   0x8e	/* IP Forwarding Interface */
-#define IFT_MSDSL		   0x8f	/* Multi-rate Symmetric DSL */
-#define IFT_IEEE1394		   0x90	/* IEEE1394 High Performance SerialBus*/
-#define IFT_IFGSN		   0x91	/* HIPPI-6400 */
-#define IFT_DVBRCCMACLAYER	   0x92	/* DVB-RCC MAC Layer */
-#define IFT_DVBRCCDOWNSTREAM	   0x93	/* DVB-RCC Downstream Channel */
-#define IFT_DVBRCCUPSTREAM	   0x94	/* DVB-RCC Upstream Channel */
-#define IFT_ATMVIRTUAL		   0x95	/* ATM Virtual Interface */
-#define IFT_MPLSTUNNEL		   0x96	/* MPLS Tunnel Virtual Interface */
-#define IFT_SRP			   0x97	/* Spatial Reuse Protocol */
-#define IFT_VOICEOVERATM	   0x98	/* Voice over ATM */
-#define IFT_VOICEOVERFRAMERELAY	   0x99	/* Voice Over Frame Relay */
-#define IFT_IDSL		   0x9a	/* Digital Subscriber Loop over ISDN */
-#define IFT_COMPOSITELINK	   0x9b	/* Avici Composite Link Interface */
-#define IFT_SS7SIGLINK		   0x9c	/* SS7 Signaling Link */
-#define IFT_PROPWIRELESSP2P	   0x9d	/* Prop. P2P wireless interface */
-#define IFT_FRFORWARD		   0x9e	/* Frame forward Interface */
-#define IFT_RFC1483		   0x9f	/* Multiprotocol over ATM AAL5 */
-#define IFT_USB			   0xa0	/* USB Interface */
-#define IFT_IEEE8023ADLAG	   0xa1	/* IEEE 802.3ad Link Aggregate*/
-#define IFT_BGPPOLICYACCOUNTING	   0xa2	/* BGP Policy Accounting */
-#define IFT_FRF16MFRBUNDLE	   0xa3	/* FRF.16 Multilik Frame Relay*/
-#define IFT_H323GATEKEEPER	   0xa4	/* H323 Gatekeeper */
-#define IFT_H323PROXY		   0xa5	/* H323 Voice and Video Proxy */
-#define IFT_MPLS		   0xa6	/* MPLS */
-#define IFT_MFSIGLINK		   0xa7	/* Multi-frequency signaling link */
-#define IFT_HDSL2		   0xa8	/* High Bit-Rate DSL, 2nd gen. */
-#define IFT_SHDSL		   0xa9	/* Multirate HDSL2 */
-#define IFT_DS1FDL		   0xaa	/* Facility Data Link (4Kbps) on a DS1*/
-#define IFT_POS			   0xab	/* Packet over SONET/SDH Interface */
-#define IFT_DVBASILN		   0xac	/* DVB-ASI Input */
-#define IFT_DVBASIOUT		   0xad	/* DVB-ASI Output */
-#define IFT_PLC			   0xae	/* Power Line Communications */
-#define IFT_NFAS		   0xaf	/* Non-Facility Associated Signaling */
-#define IFT_TR008		   0xb0	/* TROO8 */
-#define IFT_GR303RDT		   0xb1	/* Remote Digital Terminal */
-#define IFT_GR303IDT		   0xb2	/* Integrated Digital Terminal */
-#define IFT_ISUP		   0xb3	/* ISUP */
-#define IFT_PROPDOCSWIRELESSMACLAYER	   0xb4	/* prop/Wireless MAC Layer */
-#define IFT_PROPDOCSWIRELESSDOWNSTREAM	   0xb5	/* prop/Wireless Downstream */
-#define IFT_PROPDOCSWIRELESSUPSTREAM	   0xb6	/* prop/Wireless Upstream */
-#define IFT_HIPERLAN2		   0xb7	/* HIPERLAN Type 2 Radio Interface */
-#define IFT_PROPBWAP2MP		   0xb8	/* PropBroadbandWirelessAccess P2MP*/
-#define IFT_SONETOVERHEADCHANNEL   0xb9	/* SONET Overhead Channel */
-#define IFT_DIGITALWRAPPEROVERHEADCHANNEL  0xba	/* Digital Wrapper Overhead */
-#define IFT_AAL2		   0xbb	/* ATM adaptation layer 2 */
-#define IFT_RADIOMAC		   0xbc	/* MAC layer over radio links */
-#define IFT_ATMRADIO		   0xbd	/* ATM over radio links */
-#define IFT_IMT			   0xbe /* Inter-Machine Trunks */
-#define IFT_MVL			   0xbf /* Multiple Virtual Lines DSL */
-#define IFT_REACHDSL		   0xc0 /* Long Reach DSL */
-#define IFT_FRDLCIENDPT		   0xc1 /* Frame Relay DLCI End Point */
-#define IFT_ATMVCIENDPT		   0xc2 /* ATM VCI End Point */
-#define IFT_OPTICALCHANNEL	   0xc3 /* Optical Channel */
-#define IFT_OPTICALTRANSPORT	   0xc4 /* Optical Transport */
-#define IFT_PROPATM		   0xc5 /* Proprietary ATM */
-#define IFT_VOICEOVERCABLE	   0xc6 /* Voice Over Cable Interface */
-#define IFT_INFINIBAND		   0xc7 /* Infiniband */
-#define IFT_TELINK		   0xc8 /* TE Link */
-#define IFT_Q2931		   0xc9 /* Q.2931 */
-#define IFT_VIRTUALTG		   0xca /* Virtual Trunk Group */
-#define IFT_SIPTG		   0xcb /* SIP Trunk Group */
-#define IFT_SIPSIG		   0xcc /* SIP Signaling */
-#define IFT_DOCSCABLEUPSTREAMCHANNEL 0xcd /* CATV Upstream Channel */
-#define IFT_ECONET		   0xce /* Acorn Econet */
-#define IFT_PON155		   0xcf /* FSAN 155Mb Symetrical PON interface */
-#define IFT_PON622		   0xd0 /* FSAN 622Mb Symetrical PON interface */
-#define IFT_BRIDGE		   0xd1 /* Transparent bridge interface */
-#define IFT_LINEGROUP		   0xd2 /* Interface common to multiple lines */
-#define IFT_VOICEEMFGD		   0xd3 /* voice E&M Feature Group D */
-#define IFT_VOICEFGDEANA	   0xd4 /* voice FGD Exchange Access North American */
-#define IFT_VOICEDID		   0xd5 /* voice Direct Inward Dialing */
-#define IFT_STF			   0xd7	/* 6to4 interface */
-
-/* not based on IANA assignments - how should we treat these? */
-#define IFT_GIF		0xf0
-#define IFT_PVC		0xf1
-#define IFT_FAITH	0xf2
-#define IFT_PFLOG	0xf5		/* Packet filter logging */
-#define IFT_PFSYNC	0xf6		/* Packet filter state syncing */
-#define IFT_CARP	0xf8		/* Common Address Redundancy Protocol */
-
-#endif /* !_NET_IF_TYPES_H_ */
diff --git a/libc/include/net/route.h b/libc/include/net/route.h
index 326fbe7..9c53875 100644
--- a/libc/include/net/route.h
+++ b/libc/include/net/route.h
@@ -29,6 +29,7 @@
 #ifndef _NET_ROUTE_H_
 #define _NET_ROUTE_H_
 
+#include <sys/cdefs.h>
 #include <sys/socket.h>
 #include <linux/route.h>
 #include <linux/in6.h>
diff --git a/libc/include/netdb.h b/libc/include/netdb.h
index 3bb973c..816acc5 100644
--- a/libc/include/netdb.h
+++ b/libc/include/netdb.h
@@ -192,59 +192,41 @@
  */
 #define	SCOPE_DELIMITER	'%'
 
+#define IPPORT_RESERVED 1024
+
 __BEGIN_DECLS
-#pragma GCC visibility push(default)
 
 /* BIONIC-BEGIN */
 #define  h_errno   (*__get_h_errno())
 int*  __get_h_errno(void);
 /* BIONIC-END */
-void endhostent(void);
-void endnetent(void);
-void endnetgrent(void);
-void endprotoent(void);
 void endservent(void);
-void freehostent(struct hostent *);
-struct hostent	*gethostbyaddr(const void *, socklen_t, int);
-int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
-struct hostent	*gethostbyname(const char *);
-int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
-struct hostent	*gethostbyname2(const char *, int);
-int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
-struct hostent	*gethostent(void);
-int gethostent_r(struct hostent *, char *, size_t, struct hostent **, int *);
-struct hostent	*getipnodebyaddr(const void *, size_t, int, int *);
-struct hostent	*getipnodebyname(const char *, int, int, int *);
-struct netent	*getnetbyaddr(uint32_t, int);
-int getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t, struct netent**, int *);
-struct netent	*getnetbyname(const char *);
-int getnetbyname_r(const char *, struct netent *, char *, size_t, struct netent **, int *);
-struct netent	*getnetent(void);
-int getnetent_r(struct netent *, char *, size_t, struct netent **, int *);
-int getnetgrent(char **, char **, char **);
-struct protoent	*getprotobyname(const char *);
-int getprotobyname_r(const char *, struct protoent *, char *, size_t, struct protoent **);
-struct protoent	*getprotobynumber(int);
-int getprotobynumber_r(int, struct protoent *, char *, size_t, struct protoent **);
-struct protoent	*getprotoent(void);
-int getprotoent_r(struct protoent *, char *, size_t, struct protoent **);
-struct servent	*getservbyname(const char *, const char *);
-struct servent	*getservbyport(int, const char *);
-struct servent	*getservent(void);
-void herror(const char *);
-const char	*hstrerror(int);
-int innetgr(const char *, const char *, const char *, const char *);
-void sethostent(int);
-void setnetent(int);
-void setprotoent(int);
-int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
-int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int);
-void freeaddrinfo(struct addrinfo *);
-const char	*gai_strerror(int);
-void setnetgrent(const char *);
+struct hostent* gethostbyaddr(const void*, socklen_t, int);
+int gethostbyaddr_r(const void*, socklen_t, int, struct hostent*, char*, size_t, struct hostent**,
+                    int*) __INTRODUCED_IN(23);
+struct hostent* gethostbyname(const char*);
+int gethostbyname_r(const char*, struct hostent*, char*, size_t, struct hostent**, int*);
+struct hostent* gethostbyname2(const char*, int);
+int gethostbyname2_r(const char*, int, struct hostent*, char*, size_t, struct hostent**, int*)
+  __INTRODUCED_IN(23);
+struct hostent* gethostent(void);
+struct netent* getnetbyaddr(uint32_t, int);
+struct netent* getnetbyname(const char*);
+struct protoent* getprotobyname(const char*);
+struct protoent* getprotobynumber(int);
+struct servent* getservbyname(const char*, const char*);
+struct servent* getservbyport(int, const char*);
+struct servent* getservent(void);
+void herror(const char*);
+const char* hstrerror(int);
+
+int getaddrinfo(const char*, const char*, const struct addrinfo*, struct addrinfo**);
+/* POSIX getnameinfo uses socklen_t, not size_t, but LP64 sizeof(socklen_t) != sizeof(size_t). */
+int getnameinfo(const struct sockaddr*, socklen_t, char*, size_t, char*, size_t, int);
+void freeaddrinfo(struct addrinfo*);
+const char* gai_strerror(int);
 void setservent(int);
 
-#pragma GCC visibility pop
 __END_DECLS
 
 #endif /* !_NETDB_H_ */
diff --git a/libc/include/netinet/ether.h b/libc/include/netinet/ether.h
index a1c9cbb..e69cdaf 100644
--- a/libc/include/netinet/ether.h
+++ b/libc/include/netinet/ether.h
@@ -25,4 +25,20 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include <net/if_ether.h>
+
+#ifndef _NETINET_ETHER_H_
+#define _NETINET_ETHER_H_ 1
+
+#include <sys/cdefs.h>
+#include <netinet/if_ether.h>
+
+__BEGIN_DECLS
+
+char* ether_ntoa(const struct ether_addr*) __INTRODUCED_IN(11);
+char* ether_ntoa_r(const struct ether_addr*, char*) __INTRODUCED_IN(11);
+struct ether_addr* ether_aton(const char*) __INTRODUCED_IN(11);
+struct ether_addr* ether_aton_r(const char*, struct ether_addr*) __INTRODUCED_IN(11);
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/netinet/icmp6.h b/libc/include/netinet/icmp6.h
index 6625712..43ec521 100644
--- a/libc/include/netinet/icmp6.h
+++ b/libc/include/netinet/icmp6.h
@@ -66,6 +66,7 @@
 #define _NETINET_ICMP6_H_
 
 #include <netinet/in.h> /* android-added: glibc source compatibility. */
+#include <sys/cdefs.h>
 
 #define ICMPV6_PLD_MAXLEN	1232	/* IPV6_MMTU - sizeof(struct ip6_hdr)
 					   - sizeof(struct icmp6_hdr) */
@@ -107,13 +108,6 @@
 #define ICMP6_MEMBERSHIP_REPORT		131	/* group membership report */
 #define ICMP6_MEMBERSHIP_REDUCTION	132	/* group membership termination */
 
-#ifndef _KERNEL
-/* the followings are for backward compatibility to old KAME apps. */
-#define MLD6_LISTENER_QUERY	MLD_LISTENER_QUERY
-#define MLD6_LISTENER_REPORT	MLD_LISTENER_REPORT
-#define MLD6_LISTENER_DONE	MLD_LISTENER_DONE
-#endif
-
 #define ND_ROUTER_SOLICIT		133	/* router solicitation */
 #define ND_ROUTER_ADVERT		134	/* router advertisement */
 #define ND_NEIGHBOR_SOLICIT		135	/* neighbor solicitation */
@@ -134,12 +128,6 @@
 #define MLD_MTRACE_RESP			200	/* mtrace response(to sender) */
 #define MLD_MTRACE			201	/* mtrace messages */
 
-#ifndef _KERNEL
-/* the followings are for backward compatibility to old KAME apps. */
-#define MLD6_MTRACE_RESP	MLD_MTRACE_RESP
-#define MLD6_MTRACE		MLD_MTRACE
-#endif
-
 #define ICMP6_MAXTYPE			201
 
 #define ICMP6_DST_UNREACH_NOROUTE	0	/* no route to destination */
@@ -185,17 +173,6 @@
 	struct in6_addr		mld_addr; /* multicast address */
 } __packed;
 
-/* definitions to provide backward compatibility to old KAME applications */
-#ifndef _KERNEL
-#define mld6_hdr	mld_hdr
-#define mld6_type	mld_type
-#define mld6_code	mld_code
-#define mld6_cksum	mld_cksum
-#define mld6_maxdelay	mld_maxdelay
-#define mld6_reserved	mld_reserved
-#define mld6_addr	mld_addr
-#endif
-
 /* shortcut macro definitions */
 #define mld_type	mld_icmp6_hdr.icmp6_type
 #define mld_code	mld_icmp6_hdr.icmp6_code
@@ -268,17 +245,9 @@
 #define nd_na_code		nd_na_hdr.icmp6_code
 #define nd_na_cksum		nd_na_hdr.icmp6_cksum
 #define nd_na_flags_reserved	nd_na_hdr.icmp6_data32[0]
-#if BYTE_ORDER == BIG_ENDIAN
-#define ND_NA_FLAG_ROUTER		0x80000000
-#define ND_NA_FLAG_SOLICITED		0x40000000
-#define ND_NA_FLAG_OVERRIDE		0x20000000
-#else
-#if BYTE_ORDER == LITTLE_ENDIAN
 #define ND_NA_FLAG_ROUTER		0x80
 #define ND_NA_FLAG_SOLICITED		0x40
 #define ND_NA_FLAG_OVERRIDE		0x20
-#endif
-#endif
 
 struct nd_redirect {		/* redirect */
 	struct icmp6_hdr	nd_rd_hdr;
@@ -407,40 +376,17 @@
 #define NI_QTYPE_NODEADDR	3 /* Node Addresses */
 #define NI_QTYPE_IPV4ADDR	4 /* IPv4 Addresses */
 
-#if BYTE_ORDER == BIG_ENDIAN
-#define NI_SUPTYPE_FLAG_COMPRESS	0x1
-#define NI_FQDN_FLAG_VALIDTTL		0x1
-#elif BYTE_ORDER == LITTLE_ENDIAN
 #define NI_SUPTYPE_FLAG_COMPRESS	0x0100
 #define NI_FQDN_FLAG_VALIDTTL		0x0100
-#endif
 
 #ifdef NAME_LOOKUPS_04
-#if BYTE_ORDER == BIG_ENDIAN
-#define NI_NODEADDR_FLAG_LINKLOCAL	0x1
-#define NI_NODEADDR_FLAG_SITELOCAL	0x2
-#define NI_NODEADDR_FLAG_GLOBAL		0x4
-#define NI_NODEADDR_FLAG_ALL		0x8
-#define NI_NODEADDR_FLAG_TRUNCATE	0x10
-#define NI_NODEADDR_FLAG_ANYCAST	0x20 /* just experimental. not in spec */
-#elif BYTE_ORDER == LITTLE_ENDIAN
 #define NI_NODEADDR_FLAG_LINKLOCAL	0x0100
 #define NI_NODEADDR_FLAG_SITELOCAL	0x0200
 #define NI_NODEADDR_FLAG_GLOBAL		0x0400
 #define NI_NODEADDR_FLAG_ALL		0x0800
 #define NI_NODEADDR_FLAG_TRUNCATE	0x1000
 #define NI_NODEADDR_FLAG_ANYCAST	0x2000 /* just experimental. not in spec */
-#endif
 #else  /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
-#if BYTE_ORDER == BIG_ENDIAN
-#define NI_NODEADDR_FLAG_TRUNCATE	0x1
-#define NI_NODEADDR_FLAG_ALL		0x2
-#define NI_NODEADDR_FLAG_COMPAT		0x4
-#define NI_NODEADDR_FLAG_LINKLOCAL	0x8
-#define NI_NODEADDR_FLAG_SITELOCAL	0x10
-#define NI_NODEADDR_FLAG_GLOBAL		0x20
-#define NI_NODEADDR_FLAG_ANYCAST	0x40 /* just experimental. not in spec */
-#elif BYTE_ORDER == LITTLE_ENDIAN
 #define NI_NODEADDR_FLAG_TRUNCATE	0x0100
 #define NI_NODEADDR_FLAG_ALL		0x0200
 #define NI_NODEADDR_FLAG_COMPAT		0x0400
@@ -449,7 +395,6 @@
 #define NI_NODEADDR_FLAG_GLOBAL		0x2000
 #define NI_NODEADDR_FLAG_ANYCAST	0x4000 /* just experimental. not in spec */
 #endif
-#endif
 
 struct ni_reply_fqdn {
 	u_int32_t ni_fqdn_ttl;	/* TTL */
@@ -508,13 +453,8 @@
 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK	0x80
 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO	0x40
 
-#if BYTE_ORDER == BIG_ENDIAN
-#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80000000
-#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40000000
-#elif BYTE_ORDER == LITTLE_ENDIAN
 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80
 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40
-#endif
 
 struct rr_result {		/* router renumbering result message */
 	u_int16_t	rrr_flags;
@@ -523,13 +463,8 @@
 	u_int32_t	rrr_ifid;
 	struct	in6_addr rrr_prefix;
 } __packed;
-#if BYTE_ORDER == BIG_ENDIAN
-#define ICMP6_RR_RESULT_FLAGS_OOB		0x0002
-#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x0001
-#elif BYTE_ORDER == LITTLE_ENDIAN
 #define ICMP6_RR_RESULT_FLAGS_OOB		0x0200
 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x0100
-#endif
 
 /*
  * icmp6 filter structures.
@@ -562,233 +497,4 @@
  * END android-changed
  */
 
-/*
- * Variables related to this implementation
- * of the internet control message protocol version 6.
- */
-
-/*
- * IPv6 ICMP statistics.
- * Each counter is an unsigned 64-bit value.
- */
-#define	ICMP6_STAT_ERROR	0	/* # of calls to icmp6_error */
-#define	ICMP6_STAT_CANTERROR	1	/* no error (old was icmp) */
-#define	ICMP6_STAT_TOOFREQ	2	/* no error (rate limitation) */
-#define	ICMP6_STAT_OUTHIST	3	/* # of output messages */
-		/* space for 256 counters */
-#define	ICMP6_STAT_BADCODE	259	/* icmp6_code out of range */
-#define	ICMP6_STAT_TOOSHORT	260	/* packet < sizeof(struct icmp6_hdr) */
-#define	ICMP6_STAT_CHECKSUM	261	/* bad checksum */
-#define	ICMP6_STAT_BADLEN	262	/* calculated bound mismatch */
-	/*
-	 * number of responses; this member is inherited from the netinet code,
-	 * but for netinet6 code, it is already available in outhist[].
-	 */
-#define	ICMP6_STAT_REFLECT	263
-#define	ICMP6_STAT_INHIST	264	/* # of input messages */
-		/* space for 256 counters */
-#define	ICMP6_STAT_ND_TOOMANYOPT 520	/* too many ND options */
-#define	ICMP6_STAT_OUTERRHIST	521
-		/* space for 13 counters */
-#define	ICMP6_STAT_PMTUCHG	534	/* path MTU changes */
-#define	ICMP6_STAT_ND_BADOPT	535	/* bad ND options */
-#define	ICMP6_STAT_BADNS	536	/* bad neighbor solicititation */
-#define	ICMP6_STAT_BADNA	537	/* bad neighbor advertisement */
-#define	ICMP6_STAT_BADRS	538	/* bad router solicitiation */
-#define	ICMP6_STAT_BADRA	539	/* bad router advertisement */
-#define	ICMP6_STAT_BADREDIRECT	540	/* bad redirect message */
-#define ICMP6_STAT_DROPPED_RAROUTE 541	/* discarded routes from router advertisement */
-
-#define	ICMP6_NSTATS		542
-
-#define	ICMP6_ERRSTAT_DST_UNREACH_NOROUTE	0
-#define	ICMP6_ERRSTAT_DST_UNREACH_ADMIN		1
-#define	ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE	2
-#define	ICMP6_ERRSTAT_DST_UNREACH_ADDR		3
-#define	ICMP6_ERRSTAT_DST_UNREACH_NOPORT	4
-#define	ICMP6_ERRSTAT_PACKET_TOO_BIG		5
-#define	ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT	6
-#define	ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY	7
-#define	ICMP6_ERRSTAT_PARAMPROB_HEADER		8
-#define	ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER	9
-#define	ICMP6_ERRSTAT_PARAMPROB_OPTION		10
-#define	ICMP6_ERRSTAT_REDIRECT			11
-#define	ICMP6_ERRSTAT_UNKNOWN			12
-
-/*
- * Names for ICMP sysctl objects
- */
-#define ICMPV6CTL_STATS		1
-#define ICMPV6CTL_REDIRACCEPT	2	/* accept/process redirects */
-#define ICMPV6CTL_REDIRTIMEOUT	3	/* redirect cache time */
-#if 0	/*obsoleted*/
-#define ICMPV6CTL_ERRRATELIMIT	5	/* ICMPv6 error rate limitation */
-#endif
-#define ICMPV6CTL_ND6_PRUNE	6
-#define ICMPV6CTL_ND6_DELAY	8
-#define ICMPV6CTL_ND6_UMAXTRIES	9
-#define ICMPV6CTL_ND6_MMAXTRIES		10
-#define ICMPV6CTL_ND6_USELOOPBACK	11
-/*#define ICMPV6CTL_ND6_PROXYALL	12	obsoleted, do not reuse here */
-#define ICMPV6CTL_NODEINFO	13
-#define ICMPV6CTL_ERRPPSLIMIT	14	/* ICMPv6 error pps limitation */
-#define ICMPV6CTL_ND6_MAXNUDHINT	15
-#define ICMPV6CTL_MTUDISC_HIWAT	16
-#define ICMPV6CTL_MTUDISC_LOWAT	17
-#define ICMPV6CTL_ND6_DEBUG	18
-#define ICMPV6CTL_ND6_DRLIST	19
-#define ICMPV6CTL_ND6_PRLIST	20
-#define	ICMPV6CTL_ND6_MAXQLEN	24
-#define ICMPV6CTL_MAXID		25
-
-#define ICMPV6CTL_NAMES { \
-	{ 0, 0 }, \
-	{ 0, 0 }, \
-	{ "rediraccept", CTLTYPE_INT }, \
-	{ "redirtimeout", CTLTYPE_INT }, \
-	{ 0, 0 }, \
-	{ 0, 0 }, \
-	{ "nd6_prune", CTLTYPE_INT }, \
-	{ 0, 0 }, \
-	{ "nd6_delay", CTLTYPE_INT }, \
-	{ "nd6_umaxtries", CTLTYPE_INT }, \
-	{ "nd6_mmaxtries", CTLTYPE_INT }, \
-	{ "nd6_useloopback", CTLTYPE_INT }, \
-	{ 0, 0 }, \
-	{ "nodeinfo", CTLTYPE_INT }, \
-	{ "errppslimit", CTLTYPE_INT }, \
-	{ "nd6_maxnudhint", CTLTYPE_INT }, \
-	{ "mtudisc_hiwat", CTLTYPE_INT }, \
-	{ "mtudisc_lowat", CTLTYPE_INT }, \
-	{ "nd6_debug", CTLTYPE_INT }, \
-	{ 0, 0 }, \
-	{ 0, 0 }, \
-	{ 0, 0 }, \
-	{ 0, 0 }, \
-	{ 0, 0 }, \
-	{ "nd6_maxqueuelen", CTLTYPE_INT }, \
-}
-
-#ifdef _KERNEL
-struct	rtentry;
-struct	rttimer;
-struct	in6_multi;
-
-void	icmp6_init(void);
-void	icmp6_paramerror(struct mbuf *, int);
-void	icmp6_error(struct mbuf *, int, int, int);
-void	icmp6_error2(struct mbuf *, int, int, int, struct ifnet *);
-int	icmp6_input(struct mbuf **, int *, int);
-void	icmp6_fasttimo(void);
-void	icmp6_reflect(struct mbuf *, size_t);
-void	icmp6_prepare(struct mbuf *);
-void	icmp6_redirect_input(struct mbuf *, int);
-void	icmp6_redirect_output(struct mbuf *, struct rtentry *);
-int	icmp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-
-void	icmp6_statinc(u_int);
-
-struct	ip6ctlparam;
-void	icmp6_mtudisc_update(struct ip6ctlparam *, int);
-void	icmp6_mtudisc_callback_register(void (*)(struct in6_addr *));
-
-/* XXX: is this the right place for these macros? */
-#define icmp6_ifstat_inc(ifp, tag) \
-do {								\
-	if (ifp)						\
-		((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
-} while (/*CONSTCOND*/ 0)
-
-#define icmp6_ifoutstat_inc(ifp, type, code) \
-do { \
-		icmp6_ifstat_inc(ifp, ifs6_out_msg); \
-		switch(type) { \
-		 case ICMP6_DST_UNREACH: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
-			 if (code == ICMP6_DST_UNREACH_ADMIN) \
-				 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
-			 break; \
-		 case ICMP6_PACKET_TOO_BIG: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
-			 break; \
-		 case ICMP6_TIME_EXCEEDED: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
-			 break; \
-		 case ICMP6_PARAM_PROB: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
-			 break; \
-		 case ICMP6_ECHO_REQUEST: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
-			 break; \
-		 case ICMP6_ECHO_REPLY: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
-			 break; \
-		 case MLD_LISTENER_QUERY: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
-			 break; \
-		 case MLD_LISTENER_REPORT: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
-			 break; \
-		 case MLD_LISTENER_DONE: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
-			 break; \
-		 case ND_ROUTER_SOLICIT: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
-			 break; \
-		 case ND_ROUTER_ADVERT: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
-			 break; \
-		 case ND_NEIGHBOR_SOLICIT: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
-			 break; \
-		 case ND_NEIGHBOR_ADVERT: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
-			 break; \
-		 case ND_REDIRECT: \
-			 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
-			 break; \
-		} \
-} while (/*CONSTCOND*/ 0)
-
-extern int	icmp6_rediraccept;	/* accept/process redirects */
-extern int	icmp6_redirtimeout;	/* cache time for redirect routes */
-#endif /* _KERNEL */
-
-#ifdef ICMP6_STRINGS
-/* Info: http://www.iana.org/assignments/icmpv6-parameters */
-
-static const char * const icmp6_type_err[] = {
-	"reserved0", "unreach", "packet_too_big", "timxceed", "paramprob",
-	NULL
-};
-
-static const char * const icmp6_type_info[] = {
-	"echo", "echoreply",
-	"mcastlistenq", "mcastlistenrep", "mcastlistendone",
-	"rtsol", "rtadv", "neighsol", "neighadv", "redirect",
-	"routerrenum", "nodeinfoq", "nodeinfor", "invneighsol", "invneighrep",
-	"mcastlistenrep2", "haad_req", "haad_rep",
-	"mobile_psol", "mobile_padv", "cga_sol", "cga_adv",
-	"experimental150", "mcast_rtadv", "mcast_rtsol", "mcast_rtterm",
-	"fmipv6_msg", "rpl_control", NULL
-};
-
-static const char * const icmp6_code_none[] = { "none", NULL };
-
-static const char * const icmp6_code_unreach[] = {
-	"noroute", "admin", "beyondscope", "addr", "port",
-	"srcaddr_policy", "reject_route", "source_route_err", NULL
-};
-
-static const char * const icmp6_code_timxceed[] = {
-	"intrans", "reass", NULL
-};
-
-static const char * const icmp6_code_paramprob[] = {
-	"hdr_field", "nxthdr_type", "option", NULL
-};      
-
-/* not all informational icmps that have codes have a names array */
-#endif
-
 #endif /* !_NETINET_ICMP6_H_ */
diff --git a/libc/include/netinet/if_ether.h b/libc/include/netinet/if_ether.h
index e4317fa..b1b9ed0 100644
--- a/libc/include/netinet/if_ether.h
+++ b/libc/include/netinet/if_ether.h
@@ -1,35 +1,110 @@
+/*	$NetBSD: if_ether.h,v 1.34 2007/12/25 18:33:46 perry Exp $	*/
+
 /*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- *  * Redistributions of source code must retain the above copyright
+ * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
+ *
+ *	@(#)if_ether.h	8.3 (Berkeley) 5/2/95
  */
 
-#include <sys/socket.h>
+#ifndef _NETINET_IF_ETHER_H_
+#define _NETINET_IF_ETHER_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#if defined(__USE_BSD)
+
+/* pull in Ethernet-specific definitions and packet structures */
+
 #include <linux/if_ether.h>
-#include <linux/if_arp.h>
-#ifndef ETHER_ADDR_LEN
-#define ETHER_ADDR_LEN ETH_ALEN
-#include <net/ethertypes.h>
-#endif
+
+/* pull in ARP-specific definitions and packet structures */
+
+#include <net/if_arp.h>
+
+#include <net/ethernet.h>
+
+/* ... and define some more which we don't need anymore: */
+
+/*
+ * Ethernet Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description.  Structure below is not
+ * used by our kernel!!! Only for userland programs which are externally
+ * maintained and need it.
+ */
+
+struct	ether_arp {
+	struct	 arphdr ea_hdr;			/* fixed-size header */
+	u_int8_t arp_sha[ETHER_ADDR_LEN];	/* sender hardware address */
+	u_int8_t arp_spa[4];			/* sender protocol address */
+	u_int8_t arp_tha[ETHER_ADDR_LEN];	/* target hardware address */
+	u_int8_t arp_tpa[4];			/* target protocol address */
+} __packed;
+#define	arp_hrd	ea_hdr.ar_hrd
+#define	arp_pro	ea_hdr.ar_pro
+#define	arp_hln	ea_hdr.ar_hln
+#define	arp_pln	ea_hdr.ar_pln
+#define	arp_op	ea_hdr.ar_op
+
+/*
+ * Macro to map an IP multicast address to an Ethernet multicast address.
+ * The high-order 25 bits of the Ethernet address are statically assigned,
+ * and the low-order 23 bits are taken from the low end of the IP address.
+ */
+#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr)				\
+	/* struct in_addr *ipaddr; */					\
+	/* u_int8_t enaddr[ETHER_ADDR_LEN]; */				\
+{									\
+	(enaddr)[0] = 0x01;						\
+	(enaddr)[1] = 0x00;						\
+	(enaddr)[2] = 0x5e;						\
+	(enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f;			\
+	(enaddr)[4] = ((u_int8_t *)ipaddr)[2];				\
+	(enaddr)[5] = ((u_int8_t *)ipaddr)[3];				\
+}
+/*
+ * Macro to map an IP6 multicast address to an Ethernet multicast address.
+ * The high-order 16 bits of the Ethernet address are statically assigned,
+ * and the low-order 32 bits are taken from the low end of the IP6 address.
+ */
+#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr)			\
+	/* struct in6_addr *ip6addr; */					\
+	/* u_int8_t enaddr[ETHER_ADDR_LEN]; */				\
+{                                                                       \
+	(enaddr)[0] = 0x33;						\
+	(enaddr)[1] = 0x33;						\
+	(enaddr)[2] = ((u_int8_t *)ip6addr)[12];			\
+	(enaddr)[3] = ((u_int8_t *)ip6addr)[13];			\
+	(enaddr)[4] = ((u_int8_t *)ip6addr)[14];			\
+	(enaddr)[5] = ((u_int8_t *)ip6addr)[15];			\
+}
+
+#endif /* __USE_BSD */
+
+#endif /* !_NET_IF_ETHER_H_ */
diff --git a/libc/include/netinet/in.h b/libc/include/netinet/in.h
index 5f3d11f..3574976 100644
--- a/libc/include/netinet/in.h
+++ b/libc/include/netinet/in.h
@@ -40,8 +40,6 @@
 
 __BEGIN_DECLS
 
-#define IPPORT_RESERVED  1024
-
 #define INET_ADDRSTRLEN 16
 
 typedef uint16_t in_port_t;
@@ -49,8 +47,13 @@
 
 int bindresvport(int, struct sockaddr_in*);
 
-extern const struct in6_addr in6addr_any;
-extern const struct in6_addr in6addr_loopback;
+#if __ANDROID_API__ >= 24
+extern const struct in6_addr in6addr_any __INTRODUCED_IN(24);
+extern const struct in6_addr in6addr_loopback __INTRODUCED_IN(24);
+#else
+static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+static const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
+#endif /* __ANDROID_API__ >= 24 */
 
 __END_DECLS
 
diff --git a/libc/include/netinet/in6.h b/libc/include/netinet/in6.h
index 879ac75..ae20f83 100644
--- a/libc/include/netinet/in6.h
+++ b/libc/include/netinet/in6.h
@@ -29,33 +29,34 @@
 #ifndef _NETINET_IN6_H
 #define _NETINET_IN6_H
 
+#include <sys/cdefs.h>
+
 #include <linux/in6.h>
 
 #define IN6_IS_ADDR_UNSPECIFIED(a) \
-  ((*(const uint32_t*)(&(a)->s6_addr[0]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[4]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[8]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[12]) == 0))
+  ((((a)->s6_addr32[0]) == 0) && \
+   (((a)->s6_addr32[1]) == 0) && \
+   (((a)->s6_addr32[2]) == 0) && \
+   (((a)->s6_addr32[3]) == 0))
 
 #define IN6_IS_ADDR_LOOPBACK(a) \
-  ((*(const uint32_t*)(&(a)->s6_addr[0]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[4]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[8]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[12]) == ntohl(1)))
+  ((((a)->s6_addr32[0]) == 0) && \
+   (((a)->s6_addr32[1]) == 0) && \
+   (((a)->s6_addr32[2]) == 0) && \
+   (((a)->s6_addr32[3]) == ntohl(1)))
 
 #define IN6_IS_ADDR_V4COMPAT(a) \
-  ((*(const uint32_t*)(&(a)->s6_addr[0]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[4]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[8]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[12]) != 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[12]) != ntohl(1)))
+  ((((a)->s6_addr32[0]) == 0) && \
+   (((a)->s6_addr32[1]) == 0) && \
+   (((a)->s6_addr32[2]) == 0) && \
+   (((a)->s6_addr32[3]) != 0) && (((a)->s6_addr32[3]) != ntohl(1)))
 
 #define IN6_IS_ADDR_V4MAPPED(a) \
-  ((*(const uint32_t*)(&(a)->s6_addr[0]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[4]) == 0) && \
-   (*(const uint32_t*)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
+  ((((a)->s6_addr32[0]) == 0) && \
+   (((a)->s6_addr32[1]) == 0) && \
+   (((a)->s6_addr32[2]) == ntohl(0x0000ffff)))
 
-#define __bionic_s6_addr(a) ((const uint8_t*)(a))
+#define __bionic_s6_addr(a) __BIONIC_CAST(reinterpret_cast, const uint8_t*, a)
 
 #define IN6_IS_ADDR_LINKLOCAL(a) \
   ((__bionic_s6_addr(a)[0] == 0xfe) && ((__bionic_s6_addr(a)[1] & 0xc0) == 0x80))
diff --git a/libc/include/netinet/in_systm.h b/libc/include/netinet/in_systm.h
index ff53fb7..8da19a5 100644
--- a/libc/include/netinet/in_systm.h
+++ b/libc/include/netinet/in_systm.h
@@ -34,6 +34,9 @@
 #ifndef _NETINET_IN_SYSTM_H_
 #define _NETINET_IN_SYSTM_H_
 
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
 /*
  * Miscellaneous internetwork
  * definitions for kernel.
@@ -52,8 +55,4 @@
 
 typedef u_int32_t n_time;		/* ms since 00:00 GMT, byte rev */
 
-#ifdef _KERNEL
-n_time	 iptime (void);
-#endif
-
 #endif /* !_NETINET_IN_SYSTM_H_ */
diff --git a/libc/include/netinet/ip.h b/libc/include/netinet/ip.h
index 629ed77..4821933 100644
--- a/libc/include/netinet/ip.h
+++ b/libc/include/netinet/ip.h
@@ -53,14 +53,8 @@
  * Structure of an internet header, naked of options.
  */
 struct ip {
-#if BYTE_ORDER == LITTLE_ENDIAN
 	u_int32_t ip_hl:4,		/* header length */
 		  ip_v:4;		/* version */
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
-	u_int32_t ip_v:4,		/* version */
-		  ip_hl:4;		/* header length */
-#endif
 	u_int8_t  ip_tos;		/* type of service */
 	u_int16_t ip_len;		/* total length */
 	u_int16_t ip_id;		/* identification */
@@ -149,14 +143,8 @@
 	u_int8_t ipt_code;		/* IPOPT_TS */
 	u_int8_t ipt_len;		/* size of structure (variable) */
 	u_int8_t ipt_ptr;		/* index of current entry */
-#if _BYTE_ORDER == _LITTLE_ENDIAN
 	u_int32_t ipt_flg:4,		/* flags, see below */
 		  ipt_oflw:4;		/* overflow counter */
-#endif
-#if _BYTE_ORDER == _BIG_ENDIAN
-	u_int32_t ipt_oflw:4,		/* overflow counter */
-		  ipt_flg:4;		/* flags, see below */
-#endif
 	union ipt_timestamp {
 	n_time	ipt_time[1];
 	struct	ipt_ta {
diff --git a/libc/include/netinet/ip6.h b/libc/include/netinet/ip6.h
index aa816c2..b4f6ce6 100644
--- a/libc/include/netinet/ip6.h
+++ b/libc/include/netinet/ip6.h
@@ -64,6 +64,12 @@
 #ifndef _NETINET_IP6_H_
 #define _NETINET_IP6_H_
 
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <endian.h>
+
+#include <linux/in6.h>
+
 /*
  * Definition for internet protocol version 6.
  * RFC 2460
@@ -93,35 +99,15 @@
 #define IPV6_VERSION		0x60
 #define IPV6_VERSION_MASK	0xf0
 
-#if BYTE_ORDER == BIG_ENDIAN
-#define IPV6_FLOWINFO_MASK	0x0fffffff	/* flow info (28 bits) */
-#define IPV6_FLOWLABEL_MASK	0x000fffff	/* flow label (20 bits) */
-#else
-#if BYTE_ORDER == LITTLE_ENDIAN
 #define IPV6_FLOWINFO_MASK	0xffffff0f	/* flow info (28 bits) */
 #define IPV6_FLOWLABEL_MASK	0xffff0f00	/* flow label (20 bits) */
-#endif /* LITTLE_ENDIAN */
-#endif
+
 #if 1
 /* ECN bits proposed by Sally Floyd */
 #define IP6TOS_CE		0x01	/* congestion experienced */
 #define IP6TOS_ECT		0x02	/* ECN-capable transport */
 #endif
 
-#ifdef _KERNEL
-/*
- * for IPv6 pseudo header checksum
- * XXX nonstandard
- */
-struct ip6_hdr_pseudo {
-	struct in6_addr ip6ph_src;
-	struct in6_addr ip6ph_dst;
-	u_int32_t	ip6ph_len;
-	u_int8_t	ip6ph_zero[3];
-	u_int8_t	ip6ph_nxt;
-} __packed;
-#endif
-
 /*
  * Extension Headers
  */
@@ -208,17 +194,9 @@
 	u_int8_t ip6or_value[2];
 } __packed;
 /* Router alert values (in network byte order) */
-#if BYTE_ORDER == BIG_ENDIAN
-#define IP6_ALERT_MLD	0x0000
-#define IP6_ALERT_RSVP	0x0001
-#define IP6_ALERT_AN	0x0002
-#else
-#if BYTE_ORDER == LITTLE_ENDIAN
 #define IP6_ALERT_MLD	0x0000
 #define IP6_ALERT_RSVP	0x0100
 #define IP6_ALERT_AN	0x0200
-#endif /* LITTLE_ENDIAN */
-#endif
 
 /* Routing header */
 struct ip6_rthdr {
@@ -246,15 +224,9 @@
 	u_int32_t ip6f_ident;		/* identification */
 } __packed;
 
-#if BYTE_ORDER == BIG_ENDIAN
-#define IP6F_OFF_MASK		0xfff8	/* mask out offset from _offlg */
-#define IP6F_RESERVED_MASK	0x0006	/* reserved bits in ip6f_offlg */
-#define IP6F_MORE_FRAG		0x0001	/* more-fragments flag */
-#else /* BYTE_ORDER == LITTLE_ENDIAN */
 #define IP6F_OFF_MASK		0xf8ff	/* mask out offset from _offlg */
 #define IP6F_RESERVED_MASK	0x0600	/* reserved bits in ip6f_offlg */
 #define IP6F_MORE_FRAG		0x0100	/* more-fragments flag */
-#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /*
  * Internet implementation parameters.
@@ -267,53 +239,4 @@
 #define IPV6_MMTU	1280	/* minimal MTU and reassembly. 1024 + 256 */
 #define IPV6_MAXPACKET	65535	/* ip6 max packet size without Jumbo payload*/
 
-#ifdef _KERNEL
-/*
- * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
- * "len") is located in single mbuf, on contiguous memory region.
- * The pointer to the region will be returned to pointer variable "val",
- * with type "typ".
- * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
- * very top of mbuf.  GET0 is likely to make memory copy than GET.
- *
- * XXX we're now testing this, needs m_pulldown()
- */
-#define IP6_EXTHDR_GET(val, typ, m, off, len) \
-do {									\
-	struct mbuf *_t;						\
-	int _tmp;							\
-	if ((m)->m_len >= (off) + (len))				\
-		(val) = (typ)(mtod((m), char *) + (off));		\
-	else {								\
-		_t = m_pulldown((m), (off), (len), &_tmp);		\
-		if (_t) {						\
-			if (_t->m_len < _tmp + (len))			\
-				panic("m_pulldown malfunction");	\
-			(val) = (typ)(mtod(_t, char *) + _tmp);	\
-		} else {						\
-			(val) = (typ)NULL;				\
-			(m) = NULL;					\
-		}							\
-	}								\
-} while (/*CONSTCOND*/ 0)
-
-#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
-do {									\
-	struct mbuf *_t;						\
-	if ((off) == 0 && (m)->m_len >= len)				\
-		(val) = (typ)mtod((m), void *);			\
-	else {								\
-		_t = m_pulldown((m), (off), (len), NULL);		\
-		if (_t) {						\
-			if (_t->m_len < (len))				\
-				panic("m_pulldown malfunction");	\
-			(val) = (typ)mtod(_t, void *);			\
-		} else {						\
-			(val) = (typ)NULL;				\
-			(m) = NULL;					\
-		}							\
-	}								\
-} while (/*CONSTCOND*/ 0)
-#endif /*_KERNEL*/
-
 #endif /* !_NETINET_IP6_H_ */
diff --git a/libc/include/netinet/tcp.h b/libc/include/netinet/tcp.h
index 5601645..147f6f7 100644
--- a/libc/include/netinet/tcp.h
+++ b/libc/include/netinet/tcp.h
@@ -29,10 +29,57 @@
 #ifndef _NETINET_TCP_H
 #define _NETINET_TCP_H
 
+#include <sys/cdefs.h>
+#include <stdint.h>
+
+#define tcphdr __kernel_tcphdr
 #include <linux/tcp.h>
+#undef tcphdr
 
 __BEGIN_DECLS
 
+struct tcphdr {
+  __extension__ union {
+    struct {
+      uint16_t th_sport;
+      uint16_t th_dport;
+      uint32_t th_seq;
+      uint32_t th_ack;
+      uint8_t th_x2:4;
+      uint8_t th_off:4;
+      uint8_t th_flags;
+      uint16_t th_win;
+      uint16_t th_sum;
+      uint16_t th_urp;
+    };
+    struct {
+      uint16_t source;
+      uint16_t dest;
+      uint32_t seq;
+      uint32_t ack_seq;
+      uint16_t res1:4;
+      uint16_t doff:4;
+      uint16_t fin:1;
+      uint16_t syn:1;
+      uint16_t rst:1;
+      uint16_t psh:1;
+      uint16_t ack:1;
+      uint16_t urg:1;
+      uint16_t res2:2;
+      uint16_t window;
+      uint16_t check;
+      uint16_t urg_ptr;
+    };
+  };
+};
+
+#define TH_FIN 0x01
+#define TH_SYN 0x02
+#define TH_RST 0x04
+#define TH_PUSH 0x08
+#define TH_ACK 0x10
+#define TH_URG 0x20
+
 enum {
   TCP_ESTABLISHED = 1,
   TCP_SYN_SENT,
diff --git a/libc/include/netinet/udp.h b/libc/include/netinet/udp.h
index d4eb368..ef517d6 100644
--- a/libc/include/netinet/udp.h
+++ b/libc/include/netinet/udp.h
@@ -29,6 +29,7 @@
 #ifndef _NETINET_UDP_H
 #define _NETINET_UDP_H
 
+#include <sys/cdefs.h>
 #include <sys/types.h>
 
 #include <linux/udp.h>
diff --git a/libstdc++/include/cassert b/libc/include/nl_types.h
similarity index 76%
rename from libstdc++/include/cassert
rename to libc/include/nl_types.h
index 5753e34..bcaab06 100644
--- a/libstdc++/include/cassert
+++ b/libc/include/nl_types.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,13 +26,23 @@
  * SUCH DAMAGE.
  */
 
-/*
- * Standard C++ Library wrapper around the C assert.h header file.  This file
- * can be included multiple times with different definition of NDEBUG, hence the
- * absence of include guards.
- */
+#ifndef _NL_TYPES_H_
+#define _NL_TYPES_H_
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CASSERT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CASSERT__
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+#define NL_CAT_LOCALE 1
+#define NL_SETD 1
+
+typedef void* nl_catd;
+typedef int nl_item;
+
+nl_catd catopen(const char*, int) __INTRODUCED_IN_FUTURE;
+char* catgets(nl_catd, int, int, const char*) __INTRODUCED_IN_FUTURE;
+int catclose(nl_catd) __INTRODUCED_IN_FUTURE;
+
+__END_DECLS
+
 #endif
-#include <assert.h>
diff --git a/libc/include/paths.h b/libc/include/paths.h
index 82c2804..b76d045 100644
--- a/libc/include/paths.h
+++ b/libc/include/paths.h
@@ -32,9 +32,11 @@
 #ifndef _PATHS_H_
 #define	_PATHS_H_
 
+#include <sys/cdefs.h>
+
 #define	_PATH_BSHELL	"/system/bin/sh"
 #define	_PATH_CONSOLE	"/dev/console"
-#define	_PATH_DEFPATH	"/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin"
+#define	_PATH_DEFPATH	"/sbin:/system/sbin:/system/bin:/system/xbin:/vendor/bin:/vendor/xbin"
 #define	_PATH_DEV	"/dev/"
 #define	_PATH_DEVNULL	"/dev/null"
 #define	_PATH_KLOG	"/proc/kmsg"
diff --git a/libc/include/poll.h b/libc/include/poll.h
index 7c16d81..0fa55d2 100644
--- a/libc/include/poll.h
+++ b/libc/include/poll.h
@@ -39,18 +39,21 @@
 typedef unsigned int nfds_t;
 
 int poll(struct pollfd*, nfds_t, int);
-int ppoll(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*);
+int ppoll(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*) __INTRODUCED_IN(21);
 
-int __poll_chk(struct pollfd*, nfds_t, int, size_t);
+int __poll_chk(struct pollfd*, nfds_t, int, size_t) __INTRODUCED_IN(23);
 int __poll_real(struct pollfd*, nfds_t, int) __RENAME(poll);
 __errordecl(__poll_too_small_error, "poll: pollfd array smaller than fd count");
 
-int __ppoll_chk(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*, size_t);
-int __ppoll_real(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*) __RENAME(ppoll);
+int __ppoll_chk(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*, size_t)
+  __INTRODUCED_IN(23);
+int __ppoll_real(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*) __RENAME(ppoll)
+  __INTRODUCED_IN(21);
 __errordecl(__ppoll_too_small_error, "ppoll: pollfd array smaller than fd count");
 
 #if defined(__BIONIC_FORTIFY)
 
+#if __ANDROID_API__ >= 23
 __BIONIC_FORTIFY_INLINE
 int poll(struct pollfd* fds, nfds_t fd_count, int timeout) {
 #if defined(__clang__)
@@ -82,6 +85,7 @@
   return __ppoll_real(fds, fd_count, timeout, mask);
 #endif
 }
+#endif /* __ANDROID_API__ >= 23 */
 
 #endif
 
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index 50f2024..20fd566 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -36,15 +36,12 @@
 #include <sys/types.h>
 #include <time.h>
 
-typedef struct {
-#if defined(__LP64__)
-  int32_t __private[10];
-#else
-  int32_t __private[1];
-#endif
-} pthread_mutex_t;
+__BEGIN_DECLS
 
-typedef long pthread_mutexattr_t;
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+#endif
 
 enum {
     PTHREAD_MUTEX_NORMAL = 0,
@@ -61,28 +58,8 @@
 #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { { ((PTHREAD_MUTEX_RECURSIVE & 3) << 14) } }
 #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP { { ((PTHREAD_MUTEX_ERRORCHECK & 3) << 14) } }
 
-typedef struct {
-#if defined(__LP64__)
-  int32_t __private[12];
-#else
-  int32_t __private[1];
-#endif
-} pthread_cond_t;
-
-typedef long pthread_condattr_t;
-
 #define PTHREAD_COND_INITIALIZER  { { 0 } }
 
-typedef struct {
-#if defined(__LP64__)
-  int32_t __private[14];
-#else
-  int32_t __private[10];
-#endif
-} pthread_rwlock_t;
-
-typedef long pthread_rwlockattr_t;
-
 #define PTHREAD_RWLOCK_INITIALIZER  { { 0 } }
 
 enum {
@@ -90,32 +67,10 @@
   PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP = 1,
 };
 
-typedef int pthread_key_t;
-
-typedef int pthread_once_t;
-
 #define PTHREAD_ONCE_INIT 0
 
-typedef struct {
-#if defined(__LP64__)
-  int64_t __private[4];
-#else
-  int32_t __private[8];
-#endif
-} pthread_barrier_t;
-
-typedef int pthread_barrierattr_t;
-
 #define PTHREAD_BARRIER_SERIAL_THREAD -1
 
-typedef struct {
-#if defined(__LP64__)
-  int64_t __private;
-#else
-  int32_t __private[2];
-#endif
-} pthread_spinlock_t;
-
 #if defined(__LP64__)
 #define PTHREAD_STACK_MIN (4 * PAGE_SIZE)
 #else
@@ -131,123 +86,125 @@
 #define PTHREAD_SCOPE_SYSTEM     0
 #define PTHREAD_SCOPE_PROCESS    1
 
-__BEGIN_DECLS
+int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)) __INTRODUCED_IN(12);
 
-int pthread_atfork(void (*)(void), void (*)(void), void(*)(void));
+int pthread_attr_destroy(pthread_attr_t* _Nonnull);
+int pthread_attr_getdetachstate(const pthread_attr_t* _Nonnull, int* _Nonnull);
+int pthread_attr_getguardsize(const pthread_attr_t* _Nonnull, size_t* _Nonnull);
+int pthread_attr_getschedparam(const pthread_attr_t* _Nonnull, struct sched_param* _Nonnull);
+int pthread_attr_getschedpolicy(const pthread_attr_t* _Nonnull, int* _Nonnull);
+int pthread_attr_getscope(const pthread_attr_t* _Nonnull, int* _Nonnull);
+int pthread_attr_getstack(const pthread_attr_t* _Nonnull, void** _Nonnull, size_t* _Nonnull);
+int pthread_attr_getstacksize(const pthread_attr_t* _Nonnull, size_t* _Nonnull);
+int pthread_attr_init(pthread_attr_t* _Nonnull);
+int pthread_attr_setdetachstate(pthread_attr_t* _Nonnull, int);
+int pthread_attr_setguardsize(pthread_attr_t* _Nonnull, size_t);
+int pthread_attr_setschedparam(pthread_attr_t* _Nonnull, const struct sched_param* _Nonnull);
+int pthread_attr_setschedpolicy(pthread_attr_t* _Nonnull, int);
+int pthread_attr_setscope(pthread_attr_t* _Nonnull, int);
+int pthread_attr_setstack(pthread_attr_t* _Nonnull, void*, size_t);
+int pthread_attr_setstacksize(pthread_attr_t* _Nonnull, size_t);
 
-int pthread_attr_destroy(pthread_attr_t*) __nonnull((1));
-int pthread_attr_getdetachstate(const pthread_attr_t*, int*) __nonnull((1, 2));
-int pthread_attr_getguardsize(const pthread_attr_t*, size_t*) __nonnull((1, 2));
-int pthread_attr_getschedparam(const pthread_attr_t*, struct sched_param*) __nonnull((1, 2));
-int pthread_attr_getschedpolicy(const pthread_attr_t*, int*) __nonnull((1, 2));
-int pthread_attr_getscope(const pthread_attr_t*, int*) __nonnull((1, 2));
-int pthread_attr_getstack(const pthread_attr_t*, void**, size_t*) __nonnull((1, 2, 3));
-int pthread_attr_getstacksize(const pthread_attr_t*, size_t*) __nonnull((1, 2));
-int pthread_attr_init(pthread_attr_t*) __nonnull((1));
-int pthread_attr_setdetachstate(pthread_attr_t*, int) __nonnull((1));
-int pthread_attr_setguardsize(pthread_attr_t*, size_t) __nonnull((1));
-int pthread_attr_setschedparam(pthread_attr_t*, const struct sched_param*) __nonnull((1, 2));
-int pthread_attr_setschedpolicy(pthread_attr_t*, int) __nonnull((1));
-int pthread_attr_setscope(pthread_attr_t*, int) __nonnull((1));
-int pthread_attr_setstack(pthread_attr_t*, void*, size_t) __nonnull((1));
-int pthread_attr_setstacksize(pthread_attr_t*, size_t) __nonnull((1));
+int pthread_condattr_destroy(pthread_condattr_t* _Nonnull);
+int pthread_condattr_getclock(const pthread_condattr_t* _Nonnull, clockid_t* _Nonnull)
+  __INTRODUCED_IN(21);
+int pthread_condattr_getpshared(const pthread_condattr_t* _Nonnull, int* _Nonnull);
+int pthread_condattr_init(pthread_condattr_t* _Nonnull);
+int pthread_condattr_setclock(pthread_condattr_t* _Nonnull, clockid_t) __INTRODUCED_IN(21);
+int pthread_condattr_setpshared(pthread_condattr_t* _Nonnull, int);
 
-int pthread_condattr_destroy(pthread_condattr_t*) __nonnull((1));
-int pthread_condattr_getclock(const pthread_condattr_t*, clockid_t*) __nonnull((1, 2));
-int pthread_condattr_getpshared(const pthread_condattr_t*, int*) __nonnull((1, 2));
-int pthread_condattr_init(pthread_condattr_t*) __nonnull((1));
-int pthread_condattr_setclock(pthread_condattr_t*, clockid_t) __nonnull((1));
-int pthread_condattr_setpshared(pthread_condattr_t*, int) __nonnull((1));
+int pthread_cond_broadcast(pthread_cond_t* _Nonnull);
+int pthread_cond_destroy(pthread_cond_t* _Nonnull);
+int pthread_cond_init(pthread_cond_t* _Nonnull, const pthread_condattr_t*);
+int pthread_cond_signal(pthread_cond_t* _Nonnull);
+int pthread_cond_timedwait(pthread_cond_t* _Nonnull, pthread_mutex_t* _Nonnull,
+                           const struct timespec* _Nonnull);
+int pthread_cond_wait(pthread_cond_t* _Nonnull, pthread_mutex_t* _Nonnull);
 
-int pthread_cond_broadcast(pthread_cond_t*) __nonnull((1));
-int pthread_cond_destroy(pthread_cond_t*) __nonnull((1));
-int pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*) __nonnull((1));
-int pthread_cond_signal(pthread_cond_t*) __nonnull((1));
-int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const struct timespec*) __nonnull((1, 2, 3));
-int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*) __nonnull((1, 2));
-
-int pthread_create(pthread_t*, pthread_attr_t const*, void *(*)(void*), void*) __nonnull((1, 3));
+int pthread_create(pthread_t* _Nonnull, pthread_attr_t const*,
+                   void* (* _Nonnull start_routine)(void*), void*);
 int pthread_detach(pthread_t);
 void pthread_exit(void*) __noreturn;
 
 int pthread_equal(pthread_t, pthread_t);
 
-int pthread_getattr_np(pthread_t, pthread_attr_t*) __nonnull((2));
+int pthread_getattr_np(pthread_t, pthread_attr_t* _Nonnull);
 
-int pthread_getcpuclockid(pthread_t, clockid_t*) __nonnull((2));
+int pthread_getcpuclockid(pthread_t, clockid_t* _Nonnull);
 
-int pthread_getschedparam(pthread_t, int*, struct sched_param*) __nonnull((2, 3));
+int pthread_getschedparam(pthread_t, int* _Nonnull, struct sched_param* _Nonnull);
 
 void* pthread_getspecific(pthread_key_t);
 
-pid_t pthread_gettid_np(pthread_t);
+pid_t pthread_gettid_np(pthread_t) __INTRODUCED_IN(21);
 
 int pthread_join(pthread_t, void**);
 
-int pthread_key_create(pthread_key_t*, void (*)(void*)) __nonnull((1));
+int pthread_key_create(pthread_key_t* _Nonnull, void (*)(void*));
 int pthread_key_delete(pthread_key_t);
 
-int pthread_mutexattr_destroy(pthread_mutexattr_t*) __nonnull((1));
-int pthread_mutexattr_getpshared(const pthread_mutexattr_t*, int*) __nonnull((1, 2));
-int pthread_mutexattr_gettype(const pthread_mutexattr_t*, int*) __nonnull((1, 2));
-int pthread_mutexattr_init(pthread_mutexattr_t*) __nonnull((1));
-int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int) __nonnull((1));
-int pthread_mutexattr_settype(pthread_mutexattr_t*, int) __nonnull((1));
+int pthread_mutexattr_destroy(pthread_mutexattr_t* _Nonnull);
+int pthread_mutexattr_getpshared(const pthread_mutexattr_t* _Nonnull, int* _Nonnull);
+int pthread_mutexattr_gettype(const pthread_mutexattr_t* _Nonnull, int* _Nonnull);
+int pthread_mutexattr_init(pthread_mutexattr_t* _Nonnull);
+int pthread_mutexattr_setpshared(pthread_mutexattr_t* _Nonnull, int);
+int pthread_mutexattr_settype(pthread_mutexattr_t* _Nonnull, int);
 
-int pthread_mutex_destroy(pthread_mutex_t*) __nonnull((1));
-int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __nonnull((1));
-#if !defined(__LP64__)
-int pthread_mutex_lock(pthread_mutex_t*) /* __nonnull((1)) */;
-#else
-int pthread_mutex_lock(pthread_mutex_t*) __nonnull((1));
+int pthread_mutex_destroy(pthread_mutex_t* _Nonnull);
+int pthread_mutex_init(pthread_mutex_t* _Nonnull, const pthread_mutexattr_t*);
+int pthread_mutex_lock(pthread_mutex_t* _Nonnull);
+int pthread_mutex_timedlock(pthread_mutex_t* _Nonnull, const struct timespec* _Nonnull)
+  __INTRODUCED_IN(21);
+int pthread_mutex_trylock(pthread_mutex_t* _Nonnull);
+int pthread_mutex_unlock(pthread_mutex_t* _Nonnull);
+
+int pthread_once(pthread_once_t* _Nonnull, void (* _Nonnull init_routine)(void));
+
+int pthread_rwlockattr_init(pthread_rwlockattr_t* _Nonnull);
+int pthread_rwlockattr_destroy(pthread_rwlockattr_t* _Nonnull);
+int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* _Nonnull, int* _Nonnull);
+int pthread_rwlockattr_setpshared(pthread_rwlockattr_t* _Nonnull, int);
+int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t* _Nonnull, int* _Nonnull)
+  __INTRODUCED_IN(23);
+int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t* _Nonnull, int) __INTRODUCED_IN(23);
+
+int pthread_rwlock_destroy(pthread_rwlock_t* _Nonnull);
+int pthread_rwlock_init(pthread_rwlock_t* _Nonnull, const pthread_rwlockattr_t*);
+int pthread_rwlock_rdlock(pthread_rwlock_t* _Nonnull);
+int pthread_rwlock_timedrdlock(pthread_rwlock_t* _Nonnull, const struct timespec* _Nonnull);
+int pthread_rwlock_timedwrlock(pthread_rwlock_t* _Nonnull, const struct timespec* _Nonnull);
+int pthread_rwlock_tryrdlock(pthread_rwlock_t* _Nonnull);
+int pthread_rwlock_trywrlock(pthread_rwlock_t* _Nonnull);
+int pthread_rwlock_unlock(pthread_rwlock_t* _Nonnull);
+int pthread_rwlock_wrlock(pthread_rwlock_t* _Nonnull);
+
+int pthread_barrierattr_init(pthread_barrierattr_t* _Nonnull attr) __INTRODUCED_IN(24);
+int pthread_barrierattr_destroy(pthread_barrierattr_t* _Nonnull attr) __INTRODUCED_IN(24);
+int pthread_barrierattr_getpshared(const pthread_barrierattr_t* _Nonnull attr,
+                                   int* _Nonnull pshared) __INTRODUCED_IN(24);
+int pthread_barrierattr_setpshared(pthread_barrierattr_t* _Nonnull attr, int pshared)
+  __INTRODUCED_IN(24);
+
+int pthread_barrier_init(pthread_barrier_t* _Nonnull, const pthread_barrierattr_t*, unsigned)
+  __INTRODUCED_IN(24);
+int pthread_barrier_destroy(pthread_barrier_t* _Nonnull) __INTRODUCED_IN(24);
+int pthread_barrier_wait(pthread_barrier_t* _Nonnull) __INTRODUCED_IN(24);
+
+int pthread_spin_destroy(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
+int pthread_spin_init(pthread_spinlock_t* _Nonnull, int) __INTRODUCED_IN(24);
+int pthread_spin_lock(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
+int pthread_spin_trylock(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
+int pthread_spin_unlock(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
+
+pthread_t pthread_self(void) __attribute_const__;
+
+#if defined(__USE_GNU)
+int pthread_getname_np(pthread_t, char* _Nonnull, size_t) __INTRODUCED_IN_FUTURE;
 #endif
-int pthread_mutex_timedlock(pthread_mutex_t*, const struct timespec*) __nonnull((1, 2));
-int pthread_mutex_trylock(pthread_mutex_t*) __nonnull((1));
-#if !defined(__LP4__)
-int pthread_mutex_unlock(pthread_mutex_t*) /* __nonnull((1)) */;
-#else
-int pthread_mutex_unlock(pthread_mutex_t*) __nonnull((1));
-#endif
+/* TODO: this should be __USE_GNU too. */
+int pthread_setname_np(pthread_t, const char* _Nonnull);
 
-int pthread_once(pthread_once_t*, void (*)(void)) __nonnull((1, 2));
-
-int pthread_rwlockattr_init(pthread_rwlockattr_t*) __nonnull((1));
-int pthread_rwlockattr_destroy(pthread_rwlockattr_t*) __nonnull((1));
-int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t*, int*) __nonnull((1, 2));
-int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int) __nonnull((1));
-int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t*, int*) __nonnull((1, 2));
-int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t*, int) __nonnull((1));
-
-int pthread_rwlock_destroy(pthread_rwlock_t*) __nonnull((1));
-int pthread_rwlock_init(pthread_rwlock_t*, const pthread_rwlockattr_t*) __nonnull((1));
-int pthread_rwlock_rdlock(pthread_rwlock_t*) __nonnull((1));
-int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const struct timespec*) __nonnull((1, 2));
-int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const struct timespec*) __nonnull((1, 2));
-int pthread_rwlock_tryrdlock(pthread_rwlock_t*) __nonnull((1));
-int pthread_rwlock_trywrlock(pthread_rwlock_t*) __nonnull((1));
-int pthread_rwlock_unlock(pthread_rwlock_t *) __nonnull((1));
-int pthread_rwlock_wrlock(pthread_rwlock_t*) __nonnull((1));
-
-int pthread_barrierattr_init(pthread_barrierattr_t* attr) __nonnull((1));
-int pthread_barrierattr_destroy(pthread_barrierattr_t* attr) __nonnull((1));
-int pthread_barrierattr_getpshared(pthread_barrierattr_t* attr, int* pshared) __nonnull((1, 2));
-int pthread_barrierattr_setpshared(pthread_barrierattr_t* attr, int pshared) __nonnull((1));
-
-int pthread_barrier_init(pthread_barrier_t*, const pthread_barrierattr_t*, unsigned) __nonnull((1));
-int pthread_barrier_destroy(pthread_barrier_t*) __nonnull((1));
-int pthread_barrier_wait(pthread_barrier_t*) __nonnull((1));
-
-int pthread_spin_destroy(pthread_spinlock_t*) __nonnull((1));
-int pthread_spin_init(pthread_spinlock_t*, int) __nonnull((1));
-int pthread_spin_lock(pthread_spinlock_t*) __nonnull((1));
-int pthread_spin_trylock(pthread_spinlock_t*) __nonnull((1));
-int pthread_spin_unlock(pthread_spinlock_t*) __nonnull((1));
-
-pthread_t pthread_self(void) __pure2;
-
-int pthread_setname_np(pthread_t, const char*) __nonnull((2));
-
-int pthread_setschedparam(pthread_t, int, const struct sched_param*) __nonnull((3));
+int pthread_setschedparam(pthread_t, int, const struct sched_param* _Nonnull);
 
 int pthread_setspecific(pthread_key_t, const void*);
 
@@ -259,8 +216,8 @@
   void*                         __cleanup_arg;
 } __pthread_cleanup_t;
 
-extern void __pthread_cleanup_push(__pthread_cleanup_t* c, __pthread_cleanup_func_t, void*);
-extern void __pthread_cleanup_pop(__pthread_cleanup_t*, int);
+void __pthread_cleanup_push(__pthread_cleanup_t* c, __pthread_cleanup_func_t, void*);
+void __pthread_cleanup_pop(__pthread_cleanup_t*, int);
 
 /* Believe or not, the definitions of pthread_cleanup_push and
  * pthread_cleanup_pop below are correct. Posix states that these
@@ -277,22 +234,9 @@
         __pthread_cleanup_pop( &__cleanup, (execute)); \
     } while (0);                                       \
 
-
-#if !defined(__LP64__)
-
-// Bionic additions that are deprecated even in the 32-bit ABI.
-//
-// TODO: Remove them once chromium_org / NFC have switched over.
-int pthread_cond_timedwait_monotonic_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);
-int pthread_cond_timedwait_monotonic(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);
-
-int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*) /* TODO: __attribute__((deprecated("use pthread_cond_timedwait instead")))*/;
-#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE 1 /* TODO: stop defining this to push LP32 off this API sooner. */
-int pthread_cond_timeout_np(pthread_cond_t*, pthread_mutex_t*, unsigned) /* TODO: __attribute__((deprecated("use pthread_cond_timedwait instead")))*/;
-
-int pthread_mutex_lock_timeout_np(pthread_mutex_t*, unsigned) __attribute__((deprecated("use pthread_mutex_timedlock instead")));
-
-#endif /* !defined(__LP64__) */
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
 
 __END_DECLS
 
diff --git a/libc/include/pty.h b/libc/include/pty.h
index bca1137..ec257a5 100644
--- a/libc/include/pty.h
+++ b/libc/include/pty.h
@@ -36,8 +36,8 @@
 
 __BEGIN_DECLS
 
-int openpty(int*, int*, char*, const struct termios*, const struct winsize*);
-int forkpty(int*, char*, const struct termios*, const struct winsize*);
+int openpty(int*, int*, char*, const struct termios*, const struct winsize*) __INTRODUCED_IN(23);
+int forkpty(int*, char*, const struct termios*, const struct winsize*) __INTRODUCED_IN(23);
 
 __END_DECLS
 
diff --git a/libc/include/pwd.h b/libc/include/pwd.h
index 905bc75..a686d05 100644
--- a/libc/include/pwd.h
+++ b/libc/include/pwd.h
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 1989, 1993
- *	The Regents of the University of California.  All rights reserved.
+ *    The Regents of the University of California.  All rights reserved.
  * (c) UNIX System Laboratories, Inc.
  * All or some portions of this file are derived from material licensed
  * to the University of California by American Telephone and Telegraph
@@ -30,8 +30,6 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
  */
 
 /*-
@@ -65,6 +63,8 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
+__BEGIN_DECLS
+
 #define _PATH_PASSWD        "/etc/passwd"
 #define _PATH_MASTERPASSWD  "/etc/master.passwd"
 #define _PATH_MASTERPASSWD_LOCK "/etc/ptmp"
@@ -98,8 +98,7 @@
 #define _PASSWORD_WARNDAYS  14  /* days to warn about expiry */
 #define _PASSWORD_CHGNOW    -1  /* special day to force password change at next login */
 
-struct passwd
-{
+struct passwd {
   char* pw_name;
   char* pw_passwd;
   uid_t pw_uid;
@@ -107,20 +106,24 @@
 #ifdef __LP64__
   char* pw_gecos;
 #else
-  // Note: On LP32, we define pw_gecos to pw_passwd since they're both NULL.
+  /* Note: On LP32, we define pw_gecos to pw_passwd since they're both NULL. */
 # define pw_gecos pw_passwd
 #endif
   char* pw_dir;
   char* pw_shell;
 };
 
-__BEGIN_DECLS
-
 struct passwd* getpwnam(const char*);
 struct passwd* getpwuid(uid_t);
 
-int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);
-int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);
+/* Note: Android has thousands and thousands of ids to iterate through */
+struct passwd* getpwent(void) __INTRODUCED_IN_FUTURE;
+
+void setpwent(void) __INTRODUCED_IN_FUTURE;
+void endpwent(void) __INTRODUCED_IN_FUTURE;
+
+int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**) __INTRODUCED_IN(12);
+int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**) __INTRODUCED_IN(12);
 
 __END_DECLS
 
diff --git a/libc/include/resolv.h b/libc/include/resolv.h
index c8899ed..2c12819 100644
--- a/libc/include/resolv.h
+++ b/libc/include/resolv.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _RESOLV_H_
 #define _RESOLV_H_
 
@@ -37,23 +38,27 @@
 #include <netinet/in.h>
 
 __BEGIN_DECLS
-#pragma GCC visibility push(default)
-
-struct res_state;
-
-extern struct __res_state *__res_state(void);
-#define _res (*__res_state())
 
 #define b64_ntop __b64_ntop
+int b64_ntop(u_char const*, size_t, char*, size_t);
 #define b64_pton __b64_pton
-extern int b64_ntop(u_char const*, size_t, char*, size_t);
-extern int b64_pton(char const*, u_char*, size_t);
+int b64_pton(char const*, u_char*, size_t);
 
 #define dn_comp __dn_comp
-extern int dn_comp(const char*, u_char*, int, u_char**, u_char**);
-extern int dn_expand(const u_char*, const u_char*, const u_char*, char*, int);
+int dn_comp(const char*, u_char*, int, u_char**, u_char**);
 
-#pragma GCC visibility pop
+int dn_expand(const u_char*, const u_char*, const u_char*, char*, int);
+
+#define p_class __p_class
+const char* p_class(int);
+#define p_type __p_type
+const char* p_type(int);
+
+int res_init(void);
+int res_mkquery(int, const char*, int, int, const u_char*, int, const u_char*, u_char*, int);
+int res_query(const char*, int, int, u_char*, int);
+int res_search(const char*, int, int, u_char*, int);
+
 __END_DECLS
 
 #endif /* _RESOLV_H_ */
diff --git a/libc/include/sched.h b/libc/include/sched.h
index 0b9235b..d407202 100644
--- a/libc/include/sched.h
+++ b/libc/include/sched.h
@@ -41,21 +41,22 @@
   int sched_priority;
 };
 
-extern int sched_setscheduler(pid_t, int, const struct sched_param*);
-extern int sched_getscheduler(pid_t);
-extern int sched_yield(void);
-extern int sched_get_priority_max(int);
-extern int sched_get_priority_min(int);
-extern int sched_setparam(pid_t, const struct sched_param*);
-extern int sched_getparam(pid_t, struct sched_param*);
-extern int sched_rr_get_interval(pid_t, struct timespec*);
+int sched_setscheduler(pid_t, int, const struct sched_param*);
+int sched_getscheduler(pid_t);
+int sched_yield(void);
+int sched_get_priority_max(int);
+int sched_get_priority_min(int);
+int sched_setparam(pid_t, const struct sched_param*);
+int sched_getparam(pid_t, struct sched_param*);
+int sched_rr_get_interval(pid_t, struct timespec*);
 
 #if defined(__USE_GNU)
 
-extern int clone(int (*)(void*), void*, int, void*, ...);
-extern int unshare(int);
-extern int sched_getcpu(void);
-extern int setns(int, int);
+int clone(int (*)(void*), void*, int, void*, ...) __INTRODUCED_IN_ARM(9)
+    __INTRODUCED_IN_MIPS(12) __INTRODUCED_IN_X86(17);
+int unshare(int) __INTRODUCED_IN(17);
+int sched_getcpu(void) __INTRODUCED_IN(12);
+int setns(int, int) __INTRODUCED_IN(21);
 
 #ifdef __LP64__
 #define CPU_SETSIZE 1024
@@ -72,9 +73,8 @@
   __CPU_BITTYPE  __bits[ CPU_SETSIZE / __CPU_BITS ];
 } cpu_set_t;
 
-extern int sched_setaffinity(pid_t pid, size_t setsize, const cpu_set_t* set);
-
-extern int sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set);
+int sched_setaffinity(pid_t pid, size_t setsize, const cpu_set_t* set) __INTRODUCED_IN(12);
+int sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set) __INTRODUCED_IN(12);
 
 #define CPU_ZERO(set)          CPU_ZERO_S(sizeof(cpu_set_t), set)
 #define CPU_SET(cpu, set)      CPU_SET_S(cpu, sizeof(cpu_set_t), set)
@@ -97,8 +97,8 @@
 #define CPU_ALLOC(count)  __sched_cpualloc((count))
 #define CPU_FREE(set)     __sched_cpufree((set))
 
-extern cpu_set_t* __sched_cpualloc(size_t count);
-extern void       __sched_cpufree(cpu_set_t* set);
+cpu_set_t* __sched_cpualloc(size_t count) __INTRODUCED_IN(12);
+void __sched_cpufree(cpu_set_t* set) __INTRODUCED_IN(12);
 
 #define CPU_ZERO_S(setsize, set)  __builtin_memset(set, 0, setsize)
 
@@ -142,7 +142,7 @@
 
 #define CPU_COUNT_S(setsize, set)  __sched_cpucount((setsize), (set))
 
-extern int __sched_cpucount(size_t setsize, cpu_set_t* set);
+int __sched_cpucount(size_t setsize, cpu_set_t* set) __INTRODUCED_IN(12);
 
 #endif /* __USE_GNU */
 
diff --git a/libc/include/search.h b/libc/include/search.h
index 9b01e12..dc160e9 100644
--- a/libc/include/search.h
+++ b/libc/include/search.h
@@ -29,17 +29,20 @@
 
 __BEGIN_DECLS
 
-void insque(void*, void*);
-void remque(void*);
+void insque(void*, void*) __INTRODUCED_IN(21);
+void remque(void*) __INTRODUCED_IN(21);
 
-void* lfind(const void*, const void*, size_t*, size_t, int (*)(const void*, const void*));
-void* lsearch(const void*, void*, size_t*, size_t, int (*)(const void*, const void*));
+void* lfind(const void*, const void*, size_t*, size_t, int (*)(const void*, const void*))
+  __INTRODUCED_IN(21);
+void* lsearch(const void*, void*, size_t*, size_t, int (*)(const void*, const void*))
+  __INTRODUCED_IN(21);
 
-void* tdelete(const void* __restrict, void** __restrict, int (*)(const void*, const void*));
-void tdestroy(void*, void (*)(void*));
-void* tfind(const void*, void* const*, int (*)(const void*, const void*));
-void* tsearch(const void*, void**, int (*)(const void*, const void*));
-void twalk(const void*, void (*)(const void*, VISIT, int));
+void* tdelete(const void* __restrict, void** __restrict, int (*)(const void*, const void*))
+  __INTRODUCED_IN(16);
+void tdestroy(void*, void (*)(void*)) __INTRODUCED_IN(16);
+void* tfind(const void*, void* const*, int (*)(const void*, const void*)) __INTRODUCED_IN(16);
+void* tsearch(const void*, void**, int (*)(const void*, const void*)) __INTRODUCED_IN(16);
+void twalk(const void*, void (*)(const void*, VISIT, int)) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/semaphore.h b/libc/include/semaphore.h
index 4ef13af..218f22a 100644
--- a/libc/include/semaphore.h
+++ b/libc/include/semaphore.h
@@ -42,7 +42,7 @@
 #endif
 } sem_t;
 
-#define SEM_FAILED NULL
+#define SEM_FAILED __BIONIC_CAST(reinterpret_cast, sem_t*, 0)
 
 int sem_destroy(sem_t*);
 int sem_getvalue(sem_t*, int*);
diff --git a/libc/include/setjmp.h b/libc/include/setjmp.h
index 02b06f5..7adeb35 100644
--- a/libc/include/setjmp.h
+++ b/libc/include/setjmp.h
@@ -54,8 +54,10 @@
 int     setjmp(jmp_buf);
 void    longjmp(jmp_buf, int);
 
-int     sigsetjmp(sigjmp_buf, int);
-void    siglongjmp(sigjmp_buf, int);
+int sigsetjmp(sigjmp_buf, int) __INTRODUCED_IN_ARM(9) __INTRODUCED_IN_MIPS(12)
+    __INTRODUCED_IN_X86(12);
+void siglongjmp(sigjmp_buf, int) __INTRODUCED_IN_ARM(9) __INTRODUCED_IN_MIPS(12)
+    __INTRODUCED_IN_X86(12);
 
 __END_DECLS
 
diff --git a/libc/include/sgtty.h b/libc/include/sgtty.h
deleted file mode 100644
index 1ac3100..0000000
--- a/libc/include/sgtty.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$NetBSD: sgtty.h,v 1.8 2005/02/03 04:39:32 perry Exp $	*/
-
-/*
- * Copyright (c) 1985, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)sgtty.h	8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _SGTTY_H_
-#define _SGTTY_H_
-
-#ifndef USE_OLD_TTY
-#define	USE_OLD_TTY
-#endif
-#include <sys/ioctl.h>
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-int gtty(int, struct sgttyb *);
-int stty(int, struct sgttyb *);
-__END_DECLS
-
-#endif /* _SGTTY_H_ */
diff --git a/libc/include/signal.h b/libc/include/signal.h
index 85c46c0..a9df04b 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -53,6 +53,11 @@
 
 __BEGIN_DECLS
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+#endif
+
 typedef int sig_atomic_t;
 
 /* The arm and x86 kernel header files don't define _NSIG. */
@@ -64,14 +69,19 @@
 #define _NSIG (_KERNEL__NSIG + 1)
 #define NSIG _NSIG
 
+/* The kernel headers define SIG_DFL (0) and SIG_IGN (1) but not SIG_HOLD, since
+ * SIG_HOLD is only used by the deprecated SysV signal API.
+ */
+#define SIG_HOLD __BIONIC_CAST(reinterpret_cast, sighandler_t, 2)
+
 /* We take a few real-time signals for ourselves. May as well use the same names as glibc. */
 #define SIGRTMIN (__libc_current_sigrtmin())
 #define SIGRTMAX (__libc_current_sigrtmax())
-extern int __libc_current_sigrtmin(void);
-extern int __libc_current_sigrtmax(void);
+int __libc_current_sigrtmin(void) __INTRODUCED_IN(21);
+int __libc_current_sigrtmax(void) __INTRODUCED_IN(21);
 
-extern const char* const sys_siglist[];
-extern const char* const sys_signame[]; /* BSD compatibility. */
+extern const char* const sys_siglist[_NSIG];
+extern const char* const sys_signame[_NSIG]; /* BSD compatibility. */
 
 typedef __sighandler_t sig_t; /* BSD compatibility. */
 typedef __sighandler_t sighandler_t; /* glibc compatibility. */
@@ -103,43 +113,61 @@
 
 #endif
 
-extern int sigaction(int, const struct sigaction*, struct sigaction*);
+int sigaction(int, const struct sigaction*, struct sigaction*);
 
-extern sighandler_t signal(int, sighandler_t) __INTRODUCED_IN(21);
+int siginterrupt(int, int);
 
-extern int siginterrupt(int, int);
+#if __ANDROID_API__ >= 21
+sighandler_t signal(int, sighandler_t) __INTRODUCED_IN(21);
+int sigaddset(sigset_t*, int) __INTRODUCED_IN(21);
+int sigdelset(sigset_t*, int) __INTRODUCED_IN(21);
+int sigemptyset(sigset_t*) __INTRODUCED_IN(21);
+int sigfillset(sigset_t*) __INTRODUCED_IN(21);
+int sigismember(const sigset_t*, int) __INTRODUCED_IN(21);
+#else
+// Implemented as static inlines before 21.
+#endif
 
-extern int sigaddset(sigset_t*, int) __INTRODUCED_IN(21);
-extern int sigdelset(sigset_t*, int) __INTRODUCED_IN(21);
-extern int sigemptyset(sigset_t*) __INTRODUCED_IN(21);
-extern int sigfillset(sigset_t*) __INTRODUCED_IN(21);
-extern int sigismember(const sigset_t*, int) __INTRODUCED_IN(21);
+int sigpending(sigset_t* _Nonnull);
+int sigprocmask(int, const sigset_t*, sigset_t*);
+int sigsuspend(const sigset_t* _Nonnull);
+int sigwait(const sigset_t* _Nonnull, int* _Nonnull);
 
-extern int sigpending(sigset_t*) __nonnull((1));
-extern int sigprocmask(int, const sigset_t*, sigset_t*);
-extern int sigsuspend(const sigset_t*) __nonnull((1));
-extern int sigwait(const sigset_t*, int*) __nonnull((1, 2));
+int sighold(int)
+  __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
+  __INTRODUCED_IN_FUTURE;
+int sigignore(int)
+  __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN_FUTURE;
+int sigpause(int)
+  __attribute__((deprecated("use sigsuspend() instead"))) __INTRODUCED_IN_FUTURE;
+int sigrelse(int)
+  __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
+  __INTRODUCED_IN_FUTURE;
+sighandler_t sigset(int, sighandler_t)
+  __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN_FUTURE;
 
-extern int raise(int);
-extern int kill(pid_t, int);
-extern int killpg(int, int);
+int raise(int);
+int kill(pid_t, int);
+int killpg(int, int);
 
-extern int sigaltstack(const stack_t*, stack_t*);
+int sigaltstack(const stack_t*, stack_t*);
 
-extern void psiginfo(const siginfo_t*, const char*);
-extern void psignal(int, const char*);
+void psiginfo(const siginfo_t*, const char*) __INTRODUCED_IN(17);
+void psignal(int, const char*) __INTRODUCED_IN(17);
 
-extern int pthread_kill(pthread_t, int);
-extern int pthread_sigmask(int, const sigset_t*, sigset_t*);
+int pthread_kill(pthread_t, int);
+int pthread_sigmask(int, const sigset_t*, sigset_t*);
 
-extern int sigqueue(pid_t, int, const union sigval);
-extern int sigtimedwait(const sigset_t*, siginfo_t*, const struct timespec*);
-extern int sigwaitinfo(const sigset_t*, siginfo_t*);
+int sigqueue(pid_t, int, const union sigval) __INTRODUCED_IN(23);
+int sigtimedwait(const sigset_t* _Nonnull, siginfo_t*, const struct timespec*) __INTRODUCED_IN(23);
+int sigwaitinfo(const sigset_t* _Nonnull, siginfo_t*) __INTRODUCED_IN(23);
 
-#if __ANDROID_API__ < 21
-#include <android/legacy_signal_inlines.h>
+#if defined(__clang__)
+#pragma clang diagnostic pop
 #endif
 
 __END_DECLS
 
+#include <android/legacy_signal_inlines.h>
+
 #endif /* _SIGNAL_H_ */
diff --git a/libc/include/stdatomic.h b/libc/include/stdatomic.h
index 2c4f1ce..8d573b2 100644
--- a/libc/include/stdatomic.h
+++ b/libc/include/stdatomic.h
@@ -32,22 +32,13 @@
 
 #include <sys/cdefs.h>
 
-#if defined(__GNUC__) && !defined(__GNUC_PREREQ)
-/* Duplicate definition here, since the mingw sys/cdefs.h omits the  */
-/* definition, and this needs to be usable there.                    */
-#define	__GNUC_PREREQ(x, y)    \
-	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || (__GNUC__ > (x)))
-#endif /* __GNUC__ && ... */
-
 #if defined(__cplusplus) && __cplusplus >= 201103L && defined(_USING_LIBCXX)
 # ifdef __clang__
 #  if __has_feature(cxx_atomic)
 #   define _STDATOMIC_HAVE_ATOMIC
 #  endif
 # else /* gcc */
-#  if __GNUC_PREREQ(4, 7)
-#   define _STDATOMIC_HAVE_ATOMIC
-#  endif
+#  define _STDATOMIC_HAVE_ATOMIC
 # endif
 #endif
 
@@ -150,12 +141,16 @@
  * bits as a T.
  */
 
-#include <stddef.h>  /* For ptrdiff_t.                          */
-#include <stdint.h>  /* TODO: Should pollute namespace less.    */
+#include <stddef.h>  /* For ptrdiff_t. */
+#include <stdint.h>  /* TODO: don't drag in all the macros, just the types. */
+// Include uchar.h only when needed.  Bionic's stdatomic.h is also used for the
+// host (via a copy in prebuilts/clang) and uchar.h is not available in the
+// glibc used for the host.
 #if __STDC_VERSION__ >= 201112L
 # include <uchar.h>  /* For char16_t and char32_t.              */
 #endif
 
+
 #ifdef __clang__
 # if __has_extension(c_atomic) || __has_extension(cxx_atomic)
 #  define       __CLANG_ATOMICS
@@ -166,14 +161,7 @@
 #  define __HAS_BUILTIN_SYNC_SWAP
 # endif
 #else
-# if __GNUC_PREREQ(4, 7)
-#  define	__GNUC_ATOMICS
-# else
-#  define	__SYNC_ATOMICS
-#  ifdef __cplusplus
-#   define       __ATOMICS_AVOID_DOT_INIT
-#  endif
-# endif
+# define __GNUC_ATOMICS
 #endif
 
 /*
@@ -182,53 +170,33 @@
 
 #ifdef __GCC_ATOMIC_BOOL_LOCK_FREE
 #define	ATOMIC_BOOL_LOCK_FREE		__GCC_ATOMIC_BOOL_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_BOOL_LOCK_FREE           2 /* For all modern platforms */
 #endif
 #ifdef __GCC_ATOMIC_CHAR_LOCK_FREE
 #define	ATOMIC_CHAR_LOCK_FREE		__GCC_ATOMIC_CHAR_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_CHAR_LOCK_FREE           2
 #endif
 #ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE
 #define	ATOMIC_CHAR16_T_LOCK_FREE	__GCC_ATOMIC_CHAR16_T_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_CHAR16_T_LOCK_FREE       2
 #endif
 #ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE
 #define	ATOMIC_CHAR32_T_LOCK_FREE	__GCC_ATOMIC_CHAR32_T_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_CHAR32_T_LOCK_FREE       2
 #endif
 #ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE
 #define	ATOMIC_WCHAR_T_LOCK_FREE	__GCC_ATOMIC_WCHAR_T_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_WCHAR_T_LOCK_FREE        2
 #endif
 #ifdef __GCC_ATOMIC_SHORT_LOCK_FREE
 #define	ATOMIC_SHORT_LOCK_FREE		__GCC_ATOMIC_SHORT_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_SHORT_LOCK_FREE          2
 #endif
 #ifdef __GCC_ATOMIC_INT_LOCK_FREE
 #define	ATOMIC_INT_LOCK_FREE		__GCC_ATOMIC_INT_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_INT_LOCK_FREE            2
 #endif
 #ifdef __GCC_ATOMIC_LONG_LOCK_FREE
 #define	ATOMIC_LONG_LOCK_FREE		__GCC_ATOMIC_LONG_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_LONG_LOCK_FREE           2
 #endif
 #ifdef __GCC_ATOMIC_LLONG_LOCK_FREE
 #define	ATOMIC_LLONG_LOCK_FREE		__GCC_ATOMIC_LLONG_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_LLONG_LOCK_FREE          1 /* maybe */
 #endif
 #ifdef __GCC_ATOMIC_POINTER_LOCK_FREE
 #define	ATOMIC_POINTER_LOCK_FREE	__GCC_ATOMIC_POINTER_LOCK_FREE
-#elif defined(__SYNC_ATOMICS)
-#define	ATOMIC_POINTER_LOCK_FREE        2
 #endif
 
 /*
@@ -239,11 +207,7 @@
 #define	ATOMIC_VAR_INIT(value)		(value)
 #define	atomic_init(obj, value)		__c11_atomic_init(obj, value)
 #else
-#ifdef __ATOMICS_AVOID_DOT_INIT
-#define	ATOMIC_VAR_INIT(value)		{ value }
-#else
 #define	ATOMIC_VAR_INIT(value)		{ .__val = (value) }
-#endif
 #define	atomic_init(obj, value)		((void)((obj)->__val = (value)))
 #endif
 
diff --git a/libc/include/stdint.h b/libc/include/stdint.h
index a66e21e..322a81c 100644
--- a/libc/include/stdint.h
+++ b/libc/include/stdint.h
@@ -31,14 +31,15 @@
 
 #include <bits/wchar_limits.h>
 #include <stddef.h>
+#include <sys/cdefs.h>
 
-typedef __signed char __int8_t;
+typedef signed char __int8_t;
 typedef unsigned char __uint8_t;
 typedef short __int16_t;
 typedef unsigned short __uint16_t;
 typedef int __int32_t;
 typedef unsigned int __uint32_t;
-#if __LP64__
+#if defined(__LP64__)
 typedef long __int64_t;
 typedef unsigned long __uint64_t;
 #else
@@ -46,7 +47,7 @@
 typedef unsigned long long __uint64_t;
 #endif
 
-#if __LP64__
+#if defined(__LP64__)
 typedef long __intptr_t;
 typedef unsigned long __uintptr_t;
 #else
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 623995b..816bd28 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -47,21 +47,42 @@
 #define __need_NULL
 #include <stddef.h>
 
+#include <bits/seek_constants.h>
+
+#if __ANDROID_API__ <= 23
+#include <bits/struct_file.h>
+#endif
+
 __BEGIN_DECLS
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+#endif
+
 typedef off_t fpos_t;
 typedef off64_t fpos64_t;
 
 struct __sFILE;
 typedef struct __sFILE FILE;
 
-extern FILE* stdin;
-extern FILE* stdout;
-extern FILE* stderr;
+#if __ANDROID_API__ >= 23
+extern FILE* stdin __INTRODUCED_IN(23);
+extern FILE* stdout __INTRODUCED_IN(23);
+extern FILE* stderr __INTRODUCED_IN(23);
+
 /* C99 and earlier plus current C++ standards say these must be macros. */
 #define stdin stdin
 #define stdout stdout
 #define stderr stderr
+#else
+/* Before M the actual symbols for stdin and friends had different names. */
+extern FILE __sF[] __REMOVED_IN(23);
+
+#define stdin (&__sF[0])
+#define stdout (&__sF[1])
+#define stderr (&__sF[2])
+#endif
 
 /*
  * The following three definitions are for ANSI C, which took them
@@ -88,17 +109,9 @@
 #define	FOPEN_MAX	20	/* must be <= OPEN_MAX <sys/syslimits.h> */
 #define	FILENAME_MAX	1024	/* must be <= PATH_MAX <sys/syslimits.h> */
 
-/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
-#if __BSD_VISIBLE || __XPG_VISIBLE
-#define	P_tmpdir	"/tmp/"
-#endif
 #define	L_tmpnam	1024	/* XXX must be == PATH_MAX */
 #define	TMP_MAX		308915776
 
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-
 /*
  * Functions defined in ANSI C standard.
  */
@@ -109,57 +122,45 @@
 int	 fflush(FILE *);
 int	 fgetc(FILE *);
 char	*fgets(char * __restrict, int, FILE * __restrict);
-int	 fprintf(FILE * __restrict , const char * __restrict, ...)
-		__printflike(2, 3);
+int	 fprintf(FILE * __restrict , const char * __restrict _Nonnull, ...) __printflike(2, 3);
 int	 fputc(int, FILE *);
 int	 fputs(const char * __restrict, FILE * __restrict);
 size_t	 fread(void * __restrict, size_t, size_t, FILE * __restrict);
-int	 fscanf(FILE * __restrict, const char * __restrict, ...)
-		__scanflike(2, 3);
+int	 fscanf(FILE * __restrict, const char * __restrict _Nonnull, ...) __scanflike(2, 3);
 size_t	 fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
 int	 getc(FILE *);
 int	 getchar(void);
-ssize_t	 getdelim(char ** __restrict, size_t * __restrict, int,
-	    FILE * __restrict);
-ssize_t	 getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+ssize_t getdelim(char** __restrict, size_t* __restrict, int, FILE* __restrict) __INTRODUCED_IN(18);
+ssize_t getline(char** __restrict, size_t* __restrict, FILE* __restrict) __INTRODUCED_IN(18);
 
 void	 perror(const char *);
-int	 printf(const char * __restrict, ...)
-		__printflike(1, 2);
+int	 printf(const char * __restrict _Nonnull, ...) __printflike(1, 2);
 int	 putc(int, FILE *);
 int	 putchar(int);
 int	 puts(const char *);
 int	 remove(const char *);
 void	 rewind(FILE *);
-int	 scanf(const char * __restrict, ...)
-		__scanflike(1, 2);
+int	 scanf(const char * __restrict _Nonnull, ...) __scanflike(1, 2);
 void	 setbuf(FILE * __restrict, char * __restrict);
 int	 setvbuf(FILE * __restrict, char * __restrict, int, size_t);
-int	 sscanf(const char * __restrict, const char * __restrict, ...)
-		__scanflike(2, 3);
+int	 sscanf(const char * __restrict, const char * __restrict _Nonnull, ...) __scanflike(2, 3);
 int	 ungetc(int, FILE *);
-int	 vfprintf(FILE * __restrict, const char * __restrict, __va_list)
-		__printflike(2, 0);
-int	 vprintf(const char * __restrict, __va_list)
-		__printflike(1, 0);
+int	 vfprintf(FILE * __restrict, const char * __restrict _Nonnull, __va_list) __printflike(2, 0);
+int	 vprintf(const char * __restrict _Nonnull, __va_list) __printflike(1, 0);
 
-int dprintf(int, const char * __restrict, ...) __printflike(2, 3);
-int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0);
+int dprintf(int, const char* __restrict _Nonnull, ...) __printflike(2, 3) __INTRODUCED_IN(21);
+int vdprintf(int, const char* __restrict _Nonnull, __va_list) __printflike(2, 0) __INTRODUCED_IN(21);
 
-#ifndef __AUDIT__
-#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 201112L) || \
+    (defined(__cplusplus) && __cplusplus <= 201103L)
 char* gets(char*) __attribute__((deprecated("gets is unsafe, use fgets instead")));
 #endif
-int sprintf(char* __restrict, const char* __restrict, ...)
-    __printflike(2, 3) __warnattr("sprintf is often misused; please use snprintf");
-int vsprintf(char* __restrict, const char* __restrict, __va_list)
-    __printflike(2, 0) __warnattr("vsprintf is often misused; please use vsnprintf");
+int sprintf(char* __restrict, const char* __restrict _Nonnull, ...) __printflike(2, 3);
+int vsprintf(char* __restrict, const char* __restrict _Nonnull, __va_list) __printflike(2, 0);
 char* tmpnam(char*) __attribute__((deprecated("tmpnam is unsafe, use mkstemp or tmpfile instead")));
-#if __XPG_VISIBLE
+#define P_tmpdir "/tmp/" /* deprecated */
 char* tempnam(const char*, const char*)
     __attribute__((deprecated("tempnam is unsafe, use mkstemp or tmpfile instead")));
-#endif
-#endif
 
 int rename(const char*, const char*);
 int renameat(int, const char*, int, const char*);
@@ -192,125 +193,89 @@
               int (*)(void*));
 #  endif
 #endif
-int fgetpos64(FILE*, fpos64_t*);
-int fsetpos64(FILE*, const fpos64_t*);
-int fseeko64(FILE*, off64_t, int);
-off64_t ftello64(FILE*);
+int fgetpos64(FILE*, fpos64_t*) __INTRODUCED_IN(24);
+int fsetpos64(FILE*, const fpos64_t*) __INTRODUCED_IN(24);
+int fseeko64(FILE*, off64_t, int) __INTRODUCED_IN(24);
+off64_t ftello64(FILE*) __INTRODUCED_IN(24);
 #if defined(__USE_BSD)
-FILE* funopen64(const void*,
-                int (*)(void*, char*, int),
-                int (*)(void*, const char*, int),
-                fpos64_t (*)(void*, fpos64_t, int),
-                int (*)(void*));
+FILE* funopen64(const void*, int (*)(void*, char*, int), int (*)(void*, const char*, int),
+                fpos64_t (*)(void*, fpos64_t, int), int (*)(void*)) __INTRODUCED_IN(24);
 #endif
 
 FILE* fopen(const char* __restrict, const char* __restrict);
-FILE* fopen64(const char* __restrict, const char* __restrict);
+FILE* fopen64(const char* __restrict, const char* __restrict) __INTRODUCED_IN(24);
 FILE* freopen(const char* __restrict, const char* __restrict, FILE* __restrict);
-FILE* freopen64(const char* __restrict, const char* __restrict, FILE* __restrict);
+FILE* freopen64(const char* __restrict, const char* __restrict, FILE* __restrict)
+  __INTRODUCED_IN(24);
 FILE* tmpfile(void);
-FILE* tmpfile64(void);
+FILE* tmpfile64(void) __INTRODUCED_IN(24);
 
-#if __ISO_C_VISIBLE >= 1999 || __BSD_VISIBLE
-int	 snprintf(char * __restrict, size_t, const char * __restrict, ...)
-		__printflike(3, 4);
-int	 vfscanf(FILE * __restrict, const char * __restrict, __va_list)
-		__scanflike(2, 0);
-int	 vscanf(const char *, __va_list)
-		__scanflike(1, 0);
-int	 vsnprintf(char * __restrict, size_t, const char * __restrict, __va_list)
-		__printflike(3, 0);
-int	 vsscanf(const char * __restrict, const char * __restrict, __va_list)
-		__scanflike(2, 0);
-#endif /* __ISO_C_VISIBLE >= 1999 || __BSD_VISIBLE */
+int snprintf(char* __restrict, size_t, const char* __restrict _Nonnull, ...) __printflike(3, 4);
+int vfscanf(FILE* __restrict, const char* __restrict _Nonnull, __va_list) __scanflike(2, 0);
+int vscanf(const char* _Nonnull , __va_list) __scanflike(1, 0);
+int vsnprintf(char* __restrict, size_t, const char* __restrict _Nonnull, __va_list) __printflike(3, 0);
+int vsscanf(const char* __restrict _Nonnull, const char* __restrict _Nonnull, __va_list) __scanflike(2, 0);
 
-/*
- * Functions defined in POSIX 1003.1.
- */
-#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
-#define	L_ctermid	1024	/* size for ctermid(); PATH_MAX */
+#define L_ctermid 1024 /* size for ctermid() */
+char* ctermid(char*) __INTRODUCED_IN_FUTURE;
 
-FILE	*fdopen(int, const char *);
-int	 fileno(FILE *);
+FILE* fdopen(int, const char*);
+int fileno(FILE*);
+int pclose(FILE*);
+FILE* popen(const char*, const char*);
+void flockfile(FILE*);
+int ftrylockfile(FILE*);
+void funlockfile(FILE*);
+int getc_unlocked(FILE*);
+int getchar_unlocked(void);
+int putc_unlocked(int, FILE*);
+int putchar_unlocked(int);
 
-#if (__POSIX_VISIBLE >= 199209)
-int	 pclose(FILE *);
-FILE	*popen(const char *, const char *);
-#endif
+FILE* fmemopen(void*, size_t, const char*) __INTRODUCED_IN(23);
+FILE* open_memstream(char**, size_t*) __INTRODUCED_IN(23);
 
-#if __POSIX_VISIBLE >= 199506
-void	 flockfile(FILE *);
-int	 ftrylockfile(FILE *);
-void	 funlockfile(FILE *);
-
-/*
- * These are normally used through macros as defined below, but POSIX
- * requires functions as well.
- */
-int	 getc_unlocked(FILE *);
-int	 getchar_unlocked(void);
-int	 putc_unlocked(int, FILE *);
-int	 putchar_unlocked(int);
-#endif /* __POSIX_VISIBLE >= 199506 */
-
-#if __POSIX_VISIBLE >= 200809
-FILE* fmemopen(void*, size_t, const char*);
-FILE* open_memstream(char**, size_t*);
-#endif /* __POSIX_VISIBLE >= 200809 */
-
-#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
-
-/*
- * Routines that are purely local.
- */
-#if __BSD_VISIBLE
-int	 asprintf(char ** __restrict, const char * __restrict, ...)
-		__printflike(2, 3);
-char	*fgetln(FILE * __restrict, size_t * __restrict);
-int	 fpurge(FILE *);
-void	 setbuffer(FILE *, char *, int);
-int	 setlinebuf(FILE *);
-int	 vasprintf(char ** __restrict, const char * __restrict,
-    __va_list)
-		__printflike(2, 0);
-
-void clearerr_unlocked(FILE*);
-int feof_unlocked(FILE*);
-int ferror_unlocked(FILE*);
-int fileno_unlocked(FILE*);
-
+#if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
+int  asprintf(char** __restrict, const char* __restrict _Nonnull, ...) __printflike(2, 3);
+char* fgetln(FILE* __restrict, size_t* __restrict);
+int fpurge(FILE*);
+void setbuffer(FILE*, char*, int);
+int setlinebuf(FILE*);
+int vasprintf(char** __restrict, const char* __restrict _Nonnull, __va_list) __printflike(2, 0);
+void clearerr_unlocked(FILE*) __INTRODUCED_IN(23);
+int feof_unlocked(FILE*) __INTRODUCED_IN(23);
+int ferror_unlocked(FILE*) __INTRODUCED_IN(23);
+int fileno_unlocked(FILE*) __INTRODUCED_IN(24);
 #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
 #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
-#endif /* __BSD_VISIBLE */
+#endif /* __USE_BSD */
 
-extern char* __fgets_chk(char*, int, FILE*, size_t);
-extern char* __fgets_real(char*, int, FILE*) __RENAME(fgets);
+char* __fgets_chk(char*, int, FILE*, size_t) __INTRODUCED_IN(17);
+char* __fgets_real(char*, int, FILE*) __RENAME(fgets);
 __errordecl(__fgets_too_big_error, "fgets called with size bigger than buffer");
 __errordecl(__fgets_too_small_error, "fgets called with size less than zero");
 
-extern size_t __fread_chk(void * __restrict, size_t, size_t, FILE * __restrict, size_t);
-extern size_t __fread_real(void * __restrict, size_t, size_t, FILE * __restrict) __RENAME(fread);
+size_t __fread_chk(void* __restrict, size_t, size_t, FILE* __restrict, size_t)
+  __INTRODUCED_IN(24);
+size_t __fread_real(void * __restrict, size_t, size_t, FILE * __restrict) __RENAME(fread);
 __errordecl(__fread_too_big_error, "fread called with size * count bigger than buffer");
 __errordecl(__fread_overflow, "fread called with overflowing size * count");
 
-extern size_t __fwrite_chk(const void * __restrict, size_t, size_t, FILE * __restrict, size_t);
-extern size_t __fwrite_real(const void * __restrict, size_t, size_t, FILE * __restrict) __RENAME(fwrite);
+size_t __fwrite_chk(const void* __restrict, size_t, size_t, FILE* __restrict, size_t)
+  __INTRODUCED_IN(24);
+size_t __fwrite_real(const void * __restrict, size_t, size_t, FILE * __restrict) __RENAME(fwrite);
 __errordecl(__fwrite_too_big_error, "fwrite called with size * count bigger than buffer");
 __errordecl(__fwrite_overflow, "fwrite called with overflowing size * count");
 
-#if defined(__BIONIC_FORTIFY)
+#if defined(__BIONIC_FORTIFY) && !defined(__BIONIC_NO_STDIO_FORTIFY)
 
+#if __ANDROID_API__ >= 17
 __BIONIC_FORTIFY_INLINE
-__printflike(3, 0)
-int vsnprintf(char *dest, size_t size, const char *format, __va_list ap)
-{
+__printflike(3, 0) int vsnprintf(char* dest, size_t size, const char* _Nonnull format, __va_list ap) {
     return __builtin___vsnprintf_chk(dest, size, 0, __bos(dest), format, ap);
 }
 
 __BIONIC_FORTIFY_INLINE
-__printflike(2, 0)
-int vsprintf(char *dest, const char *format, __va_list ap)
-{
+__printflike(2, 0) int vsprintf(char* dest, const char* _Nonnull format, __va_list ap) {
     return __builtin___vsprintf_chk(dest, 0, __bos(dest), format, ap);
 }
 
@@ -321,11 +286,8 @@
   #endif
 #else
 __BIONIC_FORTIFY_INLINE
-__printflike(3, 4)
-int snprintf(char *dest, size_t size, const char *format, ...)
-{
-    return __builtin___snprintf_chk(dest, size, 0,
-        __bos(dest), format, __builtin_va_arg_pack());
+__printflike(3, 4) int snprintf(char* dest, size_t size, const char* _Nonnull format, ...) {
+    return __builtin___snprintf_chk(dest, size, 0, __bos(dest), format, __builtin_va_arg_pack());
 }
 #endif
 
@@ -336,14 +298,13 @@
   #endif
 #else
 __BIONIC_FORTIFY_INLINE
-__printflike(2, 3)
-int sprintf(char *dest, const char *format, ...)
-{
-    return __builtin___sprintf_chk(dest, 0,
-        __bos(dest), format, __builtin_va_arg_pack());
+__printflike(2, 3) int sprintf(char* dest, const char* _Nonnull format, ...) {
+    return __builtin___sprintf_chk(dest, 0, __bos(dest), format, __builtin_va_arg_pack());
 }
 #endif
+#endif /* __ANDROID_API__ >= 17 */
 
+#if __ANDROID_API__ >= 24
 __BIONIC_FORTIFY_INLINE
 size_t fread(void * __restrict buf, size_t size, size_t count, FILE * __restrict stream) {
     size_t bos = __bos0(buf);
@@ -395,6 +356,7 @@
 
     return __fwrite_chk(buf, size, count, stream, bos);
 }
+#endif /* __ANDROID_API__ >= 24 */
 
 #if !defined(__clang__)
 
@@ -432,6 +394,10 @@
 
 #endif /* defined(__BIONIC_FORTIFY) */
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 __END_DECLS
 
 #endif /* _STDIO_H_ */
diff --git a/libc/include/stdio_ext.h b/libc/include/stdio_ext.h
index f299e54..fdf6772 100644
--- a/libc/include/stdio_ext.h
+++ b/libc/include/stdio_ext.h
@@ -38,16 +38,14 @@
 
 __BEGIN_DECLS
 
-size_t __fbufsize(FILE*);
-int __freading(FILE*);
-int __fwriting(FILE*);
-int __freadable(FILE*);
-int __fwritable(FILE*);
-int __flbf(FILE*);
-void __fpurge(FILE*);
-size_t __fpending(FILE*);
-void _flushlbf(void);
-int __fsetlocking(FILE*, int);
+size_t __fbufsize(FILE*) __INTRODUCED_IN(23);
+int __freadable(FILE*) __INTRODUCED_IN(23);
+int __fwritable(FILE*) __INTRODUCED_IN(23);
+int __flbf(FILE*) __INTRODUCED_IN(23);
+void __fpurge(FILE*) __INTRODUCED_IN(23);
+size_t __fpending(FILE*) __INTRODUCED_IN(23);
+void _flushlbf(void) __INTRODUCED_IN(23);
+int __fsetlocking(FILE*, int) __INTRODUCED_IN(23);
 
 __END_DECLS
 
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index d9d277a..c84460b 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -41,67 +41,55 @@
 #define EXIT_FAILURE 1
 #define EXIT_SUCCESS 0
 
-extern __noreturn void abort(void);
-extern __noreturn void exit(int);
-extern __noreturn void _Exit(int);
-extern int atexit(void (*)(void));
+__noreturn void abort(void);
+__noreturn void exit(int);
+__noreturn void _Exit(int) __INTRODUCED_IN(21);
+int atexit(void (*)(void));
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-int at_quick_exit(void (*)(void));
-void quick_exit(int) __noreturn;
-#endif
+int at_quick_exit(void (*)(void)) __INTRODUCED_IN(21);
+void quick_exit(int) __noreturn __INTRODUCED_IN(21);
 
-extern char* getenv(const char*);
-extern int putenv(char*);
-extern int setenv(const char*, const char*, int);
-extern int unsetenv(const char*);
-extern int clearenv(void);
+char* getenv(const char*);
+int putenv(char*);
+int setenv(const char*, const char*, int);
+int unsetenv(const char*);
+int clearenv(void);
 
-extern char* mkdtemp(char*);
-extern char* mktemp(char*) __attribute__((deprecated("mktemp is unsafe, use mkstemp or tmpfile instead")));
+char* mkdtemp(char*);
+char* mktemp(char*) __attribute__((deprecated("mktemp is unsafe, use mkstemp or tmpfile instead")));
 
-extern int mkostemp64(char*, int);
-extern int mkostemp(char*, int);
-extern int mkostemps64(char*, int, int);
-extern int mkostemps(char*, int, int);
-extern int mkstemp64(char*);
-extern int mkstemp(char*);
-extern int mkstemps64(char*, int);
-extern int mkstemps(char*, int);
+int mkostemp64(char*, int) __INTRODUCED_IN(23);
+int mkostemp(char*, int) __INTRODUCED_IN(23);
+int mkostemps64(char*, int, int) __INTRODUCED_IN(23);
+int mkostemps(char*, int, int) __INTRODUCED_IN(23);
+int mkstemp64(char*) __INTRODUCED_IN(21);
+int mkstemp(char*);
+int mkstemps64(char*, int) __INTRODUCED_IN(23);
+int mkstemps(char*, int);
 
-extern long strtol(const char *, char **, int);
-extern long long strtoll(const char *, char **, int);
-extern unsigned long strtoul(const char *, char **, int);
-extern unsigned long long strtoull(const char *, char **, int);
+long strtol(const char *, char **, int);
+long long strtoll(const char *, char **, int);
+unsigned long strtoul(const char *, char **, int);
+unsigned long long strtoull(const char *, char **, int);
 
-extern int posix_memalign(void **memptr, size_t alignment, size_t size);
+int posix_memalign(void** memptr, size_t alignment, size_t size) __INTRODUCED_IN(16);
 
-extern double atof(const char*) __INTRODUCED_IN(21);
+double strtod(const char*, char**);
+long double strtold(const char*, char**) __INTRODUCED_IN(21);
 
-extern double strtod(const char*, char**) __LIBC_ABI_PUBLIC__;
-extern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__ __INTRODUCED_IN(21);
-extern long double strtold(const char*, char**) __LIBC_ABI_PUBLIC__;
+unsigned long strtoul_l(const char*, char**, int, locale_t) __INTRODUCED_IN_FUTURE;
 
-extern long double strtold_l(const char *, char **, locale_t) __LIBC_ABI_PUBLIC__;
-extern long long strtoll_l(const char *, char **, int, locale_t) __LIBC_ABI_PUBLIC__;
-extern unsigned long long strtoull_l(const char *, char **, int, locale_t) __LIBC_ABI_PUBLIC__;
+int atoi(const char*) __attribute_pure__;
+long atol(const char*) __attribute_pure__;
+long long atoll(const char*) __attribute_pure__;
 
-extern int atoi(const char*) __purefunc;
-extern long atol(const char*) __purefunc;
-extern long long atoll(const char*) __purefunc;
+char* realpath(const char* path, char* resolved);
+int system(const char* string);
 
-extern int abs(int) __pure2 __INTRODUCED_IN(21);
-extern long labs(long) __pure2 __INTRODUCED_IN(21);
-extern long long llabs(long long) __pure2 __INTRODUCED_IN(21);
+void* bsearch(const void* key, const void* base0, size_t nmemb, size_t size,
+              int (*compar)(const void*, const void*));
 
-extern char * realpath(const char *path, char *resolved);
-extern int system(const char *string);
-
-extern void * bsearch(const void *key, const void *base0,
-	size_t nmemb, size_t size,
-	int (*compar)(const void *, const void *));
-
-extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+void qsort(void*, size_t, size_t, int (*)(const void*, const void*));
 
 uint32_t arc4random(void);
 uint32_t arc4random_uniform(uint32_t);
@@ -109,76 +97,75 @@
 
 #define RAND_MAX 0x7fffffff
 
-int rand(void) __INTRODUCED_IN(21);
-int rand_r(unsigned int*);
-void srand(unsigned int) __INTRODUCED_IN(21);
+int rand_r(unsigned int*) __INTRODUCED_IN(21);
 
 double drand48(void);
 double erand48(unsigned short[3]);
 long jrand48(unsigned short[3]);
-void lcong48(unsigned short[7]);
+void lcong48(unsigned short[7]) __INTRODUCED_IN(23);
 long lrand48(void);
 long mrand48(void);
 long nrand48(unsigned short[3]);
 unsigned short* seed48(unsigned short[3]);
 void srand48(long);
 
-char* initstate(unsigned int, char*, size_t);
-long random(void) __INTRODUCED_IN(21);
-char* setstate(char*);
-void srandom(unsigned int) __INTRODUCED_IN(21);
+char* initstate(unsigned int, char*, size_t) __INTRODUCED_IN(21);
+char* setstate(char*) __INTRODUCED_IN(21);
 
 int getpt(void);
-int grantpt(int) __INTRODUCED_IN(21);
-int posix_openpt(int);
+int posix_openpt(int) __INTRODUCED_IN(21);
 char* ptsname(int);
 int ptsname_r(int, char*, size_t);
 int unlockpt(int);
 
+int getsubopt(char**, char* const*, char**) __INTRODUCED_IN_FUTURE;
+
 typedef struct {
     int  quot;
     int  rem;
 } div_t;
 
-extern div_t   div(int, int) __pure2;
+div_t div(int, int) __attribute_const__;
 
 typedef struct {
     long int  quot;
     long int  rem;
 } ldiv_t;
 
-extern ldiv_t   ldiv(long, long) __pure2;
+ldiv_t ldiv(long, long) __attribute_const__;
 
 typedef struct {
     long long int  quot;
     long long int  rem;
 } lldiv_t;
 
-extern lldiv_t   lldiv(long long, long long) __pure2;
+lldiv_t lldiv(long long, long long) __attribute_const__;
 
 /* BSD compatibility. */
-extern const char* getprogname(void);
-extern void setprogname(const char*);
+const char* getprogname(void) __INTRODUCED_IN(21);
+void setprogname(const char*) __INTRODUCED_IN(21);
 
-/* make STLPort happy */
-extern int      mblen(const char *, size_t);
-extern size_t   mbstowcs(wchar_t *, const char *, size_t);
-extern int      mbtowc(wchar_t *, const char *, size_t);
+int mblen(const char*, size_t) __INTRODUCED_IN_FUTURE __VERSIONER_NO_GUARD;
+size_t mbstowcs(wchar_t*, const char*, size_t);
+int mbtowc(wchar_t*, const char*, size_t) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
+int wctomb(char*, wchar_t) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
 
-/* Likewise, make libstdc++-v3 happy.  */
-extern int	wctomb(char *, wchar_t);
-extern size_t	wcstombs(char *, const wchar_t *, size_t);
+size_t wcstombs(char*, const wchar_t*, size_t);
 
-extern size_t __ctype_get_mb_cur_max(void);
+#if __ANDROID_API__ >= 21
+size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21);
 #define MB_CUR_MAX __ctype_get_mb_cur_max()
-
-#if __ANDROID_API__ < 21
-#include <android/legacy_stdlib_inlines.h>
+#else
+/*
+ * 4 is only true for UTF-8 locales, but that's what we default to. We'll need
+ * the NDK compatibility library to fix this properly.
+ */
+#define MB_CUR_MAX 4
 #endif
 
 #if defined(__BIONIC_FORTIFY)
 
-extern char* __realpath_real(const char*, char*) __RENAME(realpath);
+char* __realpath_real(const char*, char*) __RENAME(realpath);
 __errordecl(__realpath_size_error, "realpath output parameter must be NULL or a >= PATH_MAX bytes buffer");
 
 #if !defined(__clang__)
@@ -197,6 +184,35 @@
 
 #endif /* defined(__BIONIC_FORTIFY) */
 
+#if __ANDROID_API__ >= 21
+float strtof(const char*, char**) __INTRODUCED_IN(21);
+double atof(const char*) __attribute_pure__ __INTRODUCED_IN(21);
+int abs(int) __attribute_const__ __INTRODUCED_IN(21);
+long labs(long) __attribute_const__ __INTRODUCED_IN(21);
+long long llabs(long long) __attribute_const__ __INTRODUCED_IN(21);
+int rand(void) __INTRODUCED_IN(21);
+void srand(unsigned int) __INTRODUCED_IN(21);
+long random(void) __INTRODUCED_IN(21);
+void srandom(unsigned int) __INTRODUCED_IN(21);
+int grantpt(int) __INTRODUCED_IN(21);
+
+long long strtoll_l(const char*, char**, int, locale_t) __INTRODUCED_IN(21);
+unsigned long long strtoull_l(const char*, char**, int, locale_t) __INTRODUCED_IN(21);
+long double strtold_l(const char*, char**, locale_t) __INTRODUCED_IN(21);
+#else
+// Implemented as static inlines before 21.
+#endif
+
+#if __ANDROID_API__ >= __ANDROID_API_FUTURE__
+double strtod_l(const char*, char**, locale_t) __INTRODUCED_IN_FUTURE;
+float strtof_l(const char*, char**, locale_t) __INTRODUCED_IN_FUTURE;
+long strtol_l(const char*, char**, int, locale_t) __INTRODUCED_IN_FUTURE;
+#else
+// Implemented as static inlines.
+#endif
+
 __END_DECLS
 
+#include <android/legacy_stdlib_inlines.h>
+
 #endif /* _STDLIB_H */
diff --git a/libc/include/string.h b/libc/include/string.h
index 32d4a18..b3b3ed0 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -33,120 +33,128 @@
 #include <stddef.h>
 #include <xlocale.h>
 
+#include <bits/strcasecmp.h>
+
 __BEGIN_DECLS
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+#endif
+
 #if defined(__USE_BSD)
 #include <strings.h>
 #endif
 
-extern void*  memccpy(void* __restrict, const void* __restrict, int, size_t);
-extern void*  memchr(const void *, int, size_t) __purefunc;
-extern void*  memrchr(const void *, int, size_t) __purefunc;
-extern int    memcmp(const void *, const void *, size_t) __purefunc;
-extern void*  memcpy(void* __restrict, const void* __restrict, size_t);
+void* memccpy(void* _Nonnull __restrict, const void* _Nonnull __restrict, int, size_t);
+void* memchr(const void* _Nonnull, int, size_t) __attribute_pure__;
+void* memrchr(const void* _Nonnull, int, size_t) __attribute_pure__;
+int memcmp(const void* _Nonnull, const void* _Nonnull, size_t) __attribute_pure__;
+void* memcpy(void* _Nonnull __restrict, const void* _Nonnull __restrict, size_t);
 #if defined(__USE_GNU)
-extern void*  mempcpy(void* __restrict, const void* __restrict, size_t);
+void* mempcpy(void* _Nonnull __restrict, const void* _Nonnull __restrict, size_t) __INTRODUCED_IN(23);
 #endif
-extern void*  memmove(void *, const void *, size_t);
-extern void*  memset(void *, int, size_t);
-extern void*  memmem(const void *, size_t, const void *, size_t) __purefunc;
+void* memmove(void* _Nonnull, const void* _Nonnull, size_t);
+void* memset(void* _Nonnull, int, size_t);
+void* memmem(const void* _Nonnull, size_t, const void* _Nonnull, size_t) __attribute_pure__;
 
-extern char*  strchr(const char *, int) __purefunc;
-extern char* __strchr_chk(const char *, int, size_t);
+char* strchr(const char* _Nonnull, int) __attribute_pure__;
+char* __strchr_chk(const char* _Nonnull, int, size_t) __INTRODUCED_IN(18);
 #if defined(__USE_GNU)
 #if defined(__cplusplus)
-extern "C++" char* strchrnul(char*, int) __RENAME(strchrnul) __purefunc;
-extern "C++" const char* strchrnul(const char*, int) __RENAME(strchrnul) __purefunc;
+extern "C++" char* strchrnul(char* _Nonnull, int) __RENAME(strchrnul) __attribute_pure__;
+extern "C++" const char* strchrnul(const char* _Nonnull, int) __RENAME(strchrnul) __attribute_pure__;
 #else
-char* strchrnul(const char*, int) __purefunc;
+char* strchrnul(const char* _Nonnull, int) __attribute_pure__ __INTRODUCED_IN(24);
 #endif
 #endif
 
-extern char*  strrchr(const char *, int) __purefunc;
-extern char* __strrchr_chk(const char *, int, size_t);
+char* strrchr(const char* _Nonnull, int) __attribute_pure__;
+char* __strrchr_chk(const char* _Nonnull, int, size_t) __INTRODUCED_IN(18);
 
-extern size_t strlen(const char *) __purefunc;
-extern size_t __strlen_chk(const char *, size_t);
-extern int    strcmp(const char *, const char *) __purefunc;
-extern char*  stpcpy(char* __restrict, const char* __restrict);
-extern char*  strcpy(char* __restrict, const char* __restrict);
-extern char*  strcat(char* __restrict, const char* __restrict);
+size_t strlen(const char* _Nonnull) __attribute_pure__;
+size_t __strlen_chk(const char* _Nonnull, size_t) __INTRODUCED_IN(17);
+int strcmp(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
+char* stpcpy(char* _Nonnull __restrict, const char* _Nonnull__restrict) __INTRODUCED_IN(21);
+char* strcpy(char* _Nonnull __restrict, const char* _Nonnull __restrict);
+char* strcat(char* _Nonnull __restrict, const char* _Nonnull __restrict);
 
-int strcasecmp(const char*, const char*) __purefunc;
-int strcasecmp_l(const char*, const char*, locale_t) __purefunc;
-int strncasecmp(const char*, const char*, size_t) __purefunc;
-int strncasecmp_l(const char*, const char*, size_t, locale_t) __purefunc;
+char* strdup(const char* _Nonnull);
 
-extern char*  strdup(const char *);
+char* strstr(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
+char* strcasestr(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
+char* strtok(char* __restrict, const char* _Nonnull __restrict);
+char* strtok_r(char* __restrict, const char* _Nonnull __restrict, char** _Nonnull __restrict);
 
-extern char*  strstr(const char *, const char *) __purefunc;
-extern char*  strcasestr(const char *haystack, const char *needle) __purefunc;
-extern char*  strtok(char* __restrict, const char* __restrict);
-extern char*  strtok_r(char* __restrict, const char* __restrict, char** __restrict);
-
-extern char* strerror(int);
-extern char* strerror_l(int, locale_t);
+char* strerror(int);
+char* strerror_l(int, locale_t) __INTRODUCED_IN(23);
 #if defined(__USE_GNU)
-extern char* strerror_r(int, char*, size_t) __RENAME(__gnu_strerror_r);
+char* strerror_r(int, char*, size_t) __RENAME(__gnu_strerror_r) __INTRODUCED_IN(23);
 #else /* POSIX */
-extern int strerror_r(int, char*, size_t);
+int strerror_r(int, char*, size_t);
 #endif
 
-extern size_t strnlen(const char *, size_t) __purefunc;
-extern char*  strncat(char* __restrict, const char* __restrict, size_t);
-extern char*  strndup(const char *, size_t);
-extern int    strncmp(const char *, const char *, size_t) __purefunc;
-extern char*  stpncpy(char* __restrict, const char* __restrict, size_t);
-extern char*  strncpy(char* __restrict, const char* __restrict, size_t);
+size_t strnlen(const char* _Nonnull, size_t) __attribute_pure__;
+char* strncat(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t);
+char* strndup(const char* _Nonnull, size_t);
+int strncmp(const char* _Nonnull, const char* _Nonnull, size_t) __attribute_pure__;
+char* stpncpy(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t) __INTRODUCED_IN(21);
+char* strncpy(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t);
 
-extern size_t strlcat(char* __restrict, const char* __restrict, size_t);
-extern size_t strlcpy(char* __restrict, const char* __restrict, size_t);
+size_t strlcat(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t);
+size_t strlcpy(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t);
 
-extern size_t strcspn(const char *, const char *) __purefunc;
-extern char*  strpbrk(const char *, const char *) __purefunc;
-extern char*  strsep(char** __restrict, const char* __restrict);
-extern size_t strspn(const char *, const char *);
+size_t strcspn(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
+char* strpbrk(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
+char* strsep(char** _Nonnull __restrict, const char* _Nonnull __restrict);
+size_t strspn(const char* _Nonnull, const char* _Nonnull);
 
-extern char*  strsignal(int  sig);
+char* strsignal(int);
 
-extern int    strcoll(const char *, const char *) __purefunc;
-extern size_t strxfrm(char* __restrict, const char* __restrict, size_t);
+int strcoll(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
+size_t strxfrm(char* __restrict, const char* _Nonnull __restrict, size_t);
 
-extern int    strcoll_l(const char *, const char *, locale_t) __purefunc;
-extern size_t strxfrm_l(char* __restrict, const char* __restrict, size_t, locale_t);
+#if __ANDROID_API__ >= 21
+int strcoll_l(const char* _Nonnull, const char* _Nonnull, locale_t) __attribute_pure__ __INTRODUCED_IN(21);
+size_t strxfrm_l(char* __restrict, const char* _Nonnull __restrict, size_t, locale_t) __INTRODUCED_IN(21);
+#else
+// Implemented as static inlines before 21.
+#endif
 
 #if defined(__USE_GNU) && !defined(basename)
 /*
  * glibc has a basename in <string.h> that's different to the POSIX one in <libgen.h>.
  * It doesn't modify its argument, and in C++ it's const-correct.
  */
-
 #if defined(__cplusplus)
-extern "C++" char* basename(char*) __RENAME(__gnu_basename) __nonnull((1));
-extern "C++" const char* basename(const char*) __RENAME(__gnu_basename) __nonnull((1));
+extern "C++" char* basename(char* _Nonnull) __RENAME(__gnu_basename);
+extern "C++" const char* basename(const char* _Nonnull) __RENAME(__gnu_basename);
 #else
-extern char* basename(const char*) __RENAME(__gnu_basename) __nonnull((1));
+char* basename(const char* _Nonnull) __RENAME(__gnu_basename) __INTRODUCED_IN(23);
 #endif
 #endif
 
-extern void* __memchr_chk(const void*, int, size_t, size_t);
+void* __memchr_chk(const void* _Nonnull, int, size_t, size_t) __INTRODUCED_IN(23);
 __errordecl(__memchr_buf_size_error, "memchr called with size bigger than buffer");
 
-extern void* __memrchr_chk(const void*, int, size_t, size_t);
+void* __memrchr_chk(const void* _Nonnull, int, size_t, size_t) __INTRODUCED_IN(23);
 __errordecl(__memrchr_buf_size_error, "memrchr called with size bigger than buffer");
-extern void* __memrchr_real(const void*, int, size_t) __RENAME(memrchr);
+void* __memrchr_real(const void* _Nonnull, int, size_t) __RENAME(memrchr);
 
-extern char* __stpncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
-extern char* __strncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
-extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t) __RENAME(strlcpy);
-extern size_t __strlcpy_chk(char *, const char *, size_t, size_t);
-extern size_t __strlcat_real(char* __restrict, const char* __restrict, size_t) __RENAME(strlcat);
-extern size_t __strlcat_chk(char* __restrict, const char* __restrict, size_t, size_t);
+char* __stpncpy_chk2(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t, size_t, size_t)
+  __INTRODUCED_IN(21);
+char* __strncpy_chk2(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t, size_t, size_t)
+  __INTRODUCED_IN(21);
+size_t __strlcpy_real(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t) __RENAME(strlcpy);
+size_t __strlcpy_chk(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t, size_t) __INTRODUCED_IN(17);
+size_t __strlcat_real(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t) __RENAME(strlcat);
+size_t __strlcat_chk(char* _Nonnull __restrict, const char* _Nonnull __restrict, size_t, size_t) __INTRODUCED_IN(17);
 
 #if defined(__BIONIC_FORTIFY)
 
+#if __ANDROID_API__ >= 23
 __BIONIC_FORTIFY_INLINE
-void* memchr(const void *s, int c, size_t n) {
+void* memchr(const void* s, int c, size_t n) {
     size_t bos = __bos(s);
 
 #if !defined(__clang__)
@@ -167,7 +175,7 @@
 }
 
 __BIONIC_FORTIFY_INLINE
-void* memrchr(const void *s, int c, size_t n) {
+void* memrchr(const void* s, int c, size_t n) {
     size_t bos = __bos(s);
 
 #if !defined(__clang__)
@@ -186,127 +194,137 @@
 
     return __memrchr_chk(s, c, n, bos);
 }
+#endif /* __ANDROID_API__ >= 23 */
 
+#if __ANDROID_API__ >= 17
 __BIONIC_FORTIFY_INLINE
-void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amount) {
-    return __builtin___memcpy_chk(dest, src, copy_amount, __bos0(dest));
+void* memcpy(void* _Nonnull __restrict dst, const void* _Nonnull __restrict src, size_t copy_amount) {
+    return __builtin___memcpy_chk(dst, src, copy_amount, __bos0(dst));
 }
 
 __BIONIC_FORTIFY_INLINE
-void* memmove(void *dest, const void *src, size_t len) {
-    return __builtin___memmove_chk(dest, src, len, __bos0(dest));
+void* memmove(void* _Nonnull dst, const void* _Nonnull src, size_t len) {
+    return __builtin___memmove_chk(dst, src, len, __bos0(dst));
 }
+#endif /* __ANDROID_API__ >= 17 */
 
+#if __ANDROID_API__ >= 21
 __BIONIC_FORTIFY_INLINE
-char* stpcpy(char* __restrict dest, const char* __restrict src) {
-    return __builtin___stpcpy_chk(dest, src, __bos(dest));
+char* stpcpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src) {
+    return __builtin___stpcpy_chk(dst, src, __bos(dst));
 }
+#endif /* __ANDROID_API__ >= 21 */
 
+#if __ANDROID_API__ >= 17
 __BIONIC_FORTIFY_INLINE
-char* strcpy(char* __restrict dest, const char* __restrict src) {
-    return __builtin___strcpy_chk(dest, src, __bos(dest));
+char* strcpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src) {
+    return __builtin___strcpy_chk(dst, src, __bos(dst));
 }
+#endif /* __ANDROID_API__ >= 17 */
 
+#if __ANDROID_API__ >= 21
 __BIONIC_FORTIFY_INLINE
-char* stpncpy(char* __restrict dest, const char* __restrict src, size_t n) {
-    size_t bos_dest = __bos(dest);
+char* stpncpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src, size_t n) {
+    size_t bos_dst = __bos(dst);
     size_t bos_src = __bos(src);
 
     if (bos_src == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
-        return __builtin___stpncpy_chk(dest, src, n, bos_dest);
+        return __builtin___stpncpy_chk(dst, src, n, bos_dst);
     }
 
     if (__builtin_constant_p(n) && (n <= bos_src)) {
-        return __builtin___stpncpy_chk(dest, src, n, bos_dest);
+        return __builtin___stpncpy_chk(dst, src, n, bos_dst);
     }
 
     size_t slen = __builtin_strlen(src);
     if (__builtin_constant_p(slen)) {
-        return __builtin___stpncpy_chk(dest, src, n, bos_dest);
+        return __builtin___stpncpy_chk(dst, src, n, bos_dst);
     }
 
-    return __stpncpy_chk2(dest, src, n, bos_dest, bos_src);
+    return __stpncpy_chk2(dst, src, n, bos_dst, bos_src);
 }
 
 __BIONIC_FORTIFY_INLINE
-char* strncpy(char* __restrict dest, const char* __restrict src, size_t n) {
-    size_t bos_dest = __bos(dest);
+char* strncpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src, size_t n) {
+    size_t bos_dst = __bos(dst);
     size_t bos_src = __bos(src);
 
     if (bos_src == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
-        return __builtin___strncpy_chk(dest, src, n, bos_dest);
+        return __builtin___strncpy_chk(dst, src, n, bos_dst);
     }
 
     if (__builtin_constant_p(n) && (n <= bos_src)) {
-        return __builtin___strncpy_chk(dest, src, n, bos_dest);
+        return __builtin___strncpy_chk(dst, src, n, bos_dst);
     }
 
     size_t slen = __builtin_strlen(src);
     if (__builtin_constant_p(slen)) {
-        return __builtin___strncpy_chk(dest, src, n, bos_dest);
+        return __builtin___strncpy_chk(dst, src, n, bos_dst);
     }
 
-    return __strncpy_chk2(dest, src, n, bos_dest, bos_src);
+    return __strncpy_chk2(dst, src, n, bos_dst, bos_src);
+}
+#endif /* __ANDROID_API__ >= 21 */
+
+#if __ANDROID_API__ >= 17
+__BIONIC_FORTIFY_INLINE
+char* strcat(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src) {
+    return __builtin___strcat_chk(dst, src, __bos(dst));
 }
 
 __BIONIC_FORTIFY_INLINE
-char* strcat(char* __restrict dest, const char* __restrict src) {
-    return __builtin___strcat_chk(dest, src, __bos(dest));
+char *strncat(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src, size_t n) {
+    return __builtin___strncat_chk(dst, src, n, __bos(dst));
 }
 
 __BIONIC_FORTIFY_INLINE
-char *strncat(char* __restrict dest, const char* __restrict src, size_t n) {
-    return __builtin___strncat_chk(dest, src, n, __bos(dest));
-}
-
-__BIONIC_FORTIFY_INLINE
-void* memset(void *s, int c, size_t n) {
+void* memset(void* _Nonnull s, int c, size_t n) {
     return __builtin___memset_chk(s, c, n, __bos0(s));
 }
 
 __BIONIC_FORTIFY_INLINE
-size_t strlcpy(char* __restrict dest, const char* __restrict src, size_t size) {
-    size_t bos = __bos(dest);
+size_t strlcpy(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src, size_t size) {
+    size_t bos = __bos(dst);
 
 #if !defined(__clang__)
     // Compiler doesn't know destination size. Don't call __strlcpy_chk
     if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
-        return __strlcpy_real(dest, src, size);
+        return __strlcpy_real(dst, src, size);
     }
 
     // Compiler can prove, at compile time, that the passed in size
     // is always <= the actual object size. Don't call __strlcpy_chk
     if (__builtin_constant_p(size) && (size <= bos)) {
-        return __strlcpy_real(dest, src, size);
+        return __strlcpy_real(dst, src, size);
     }
 #endif /* !defined(__clang__) */
 
-    return __strlcpy_chk(dest, src, size, bos);
+    return __strlcpy_chk(dst, src, size, bos);
 }
 
 
 __BIONIC_FORTIFY_INLINE
-size_t strlcat(char* __restrict dest, const char* __restrict src, size_t size) {
-    size_t bos = __bos(dest);
+size_t strlcat(char* _Nonnull __restrict dst, const char* _Nonnull __restrict src, size_t size) {
+    size_t bos = __bos(dst);
 
 #if !defined(__clang__)
     // Compiler doesn't know destination size. Don't call __strlcat_chk
     if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
-        return __strlcat_real(dest, src, size);
+        return __strlcat_real(dst, src, size);
     }
 
     // Compiler can prove, at compile time, that the passed in size
     // is always <= the actual object size. Don't call __strlcat_chk
     if (__builtin_constant_p(size) && (size <= bos)) {
-        return __strlcat_real(dest, src, size);
+        return __strlcat_real(dst, src, size);
     }
 #endif /* !defined(__clang__) */
 
-    return __strlcat_chk(dest, src, size, bos);
+    return __strlcat_chk(dst, src, size, bos);
 }
 
 __BIONIC_FORTIFY_INLINE
-size_t strlen(const char *s) {
+size_t strlen(const char* _Nonnull s) {
     size_t bos = __bos(s);
 
 #if !defined(__clang__)
@@ -323,9 +341,11 @@
 
     return __strlen_chk(s, bos);
 }
+#endif /* __ANDROID_API__ >= 17 */
 
+#if  __ANDROID_API__ >= 18
 __BIONIC_FORTIFY_INLINE
-char* strchr(const char *s, int c) {
+char* strchr(const char* _Nonnull s, int c) {
     size_t bos = __bos(s);
 
 #if !defined(__clang__)
@@ -344,7 +364,7 @@
 }
 
 __BIONIC_FORTIFY_INLINE
-char* strrchr(const char *s, int c) {
+char* strrchr(const char* _Nonnull s, int c) {
     size_t bos = __bos(s);
 
 #if !defined(__clang__)
@@ -361,10 +381,14 @@
 
     return __strrchr_chk(s, c, bos);
 }
-
+#endif /* __ANDROID_API__ >= 18 */
 
 #endif /* defined(__BIONIC_FORTIFY) */
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 __END_DECLS
 
 #endif /* _STRING_H */
diff --git a/libc/include/strings.h b/libc/include/strings.h
index 1253006..021e2b4 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -43,6 +43,8 @@
 #include <sys/cdefs.h>
 #include <xlocale.h>
 
+#include <bits/strcasecmp.h>
+
 __BEGIN_DECLS
 #if defined(__BIONIC_FORTIFY)
 #define bcopy(b1, b2, len) (void)(__builtin___memmove_chk((b2), (b1), (len), __bos0(b2)))
@@ -52,12 +54,7 @@
 #define bzero(b, len) (void)(__builtin_memset((b), '\0', (len)))
 #endif
 
-int ffs(int);
-
-int strcasecmp(const char*, const char*) __purefunc;
-int strcasecmp_l(const char*, const char*, locale_t) __purefunc;
-int strncasecmp(const char*, const char*, size_t) __purefunc;
-int strncasecmp_l(const char*, const char*, size_t, locale_t) __purefunc;
+int ffs(int) __INTRODUCED_IN_X86(18);
 
 __END_DECLS
 
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index 3b1f7d0..60789d4 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -29,6 +29,8 @@
 #ifndef _INCLUDE_SYS__SYSTEM_PROPERTIES_H
 #define _INCLUDE_SYS__SYSTEM_PROPERTIES_H
 
+#include <sys/cdefs.h>
+
 #ifndef _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
 #error you should #include <sys/system_properties.h> instead
 #else
diff --git a/libc/include/sys/atomics.h b/libc/include/sys/atomics.h
deleted file mode 100644
index 38ab366..0000000
--- a/libc/include/sys/atomics.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _SYS_ATOMICS_H_
-#define _SYS_ATOMICS_H_
-
-/*
- * These got proper out of line definitions in L. Putting the inline definitions
- * back for old targets brings us closer to being able to use one set of headers
- * for all API levels.
- *
- * The other inlines we put back went in to their appropriate headers, but the
- * sys/atomics.h header was removed, so we'll just add these somewhere we can be
- * sure they will be included.
- */
-#if __ANDROID_API__ < 21
-#include <android/legacy_sys_atomics_inlines.h>
-#endif
-
-#endif /* _SYS_ATOMICS_H_ */
diff --git a/libc/include/sys/auxv.h b/libc/include/sys/auxv.h
index 0d753c3..2fa637e 100644
--- a/libc/include/sys/auxv.h
+++ b/libc/include/sys/auxv.h
@@ -33,7 +33,7 @@
 
 __BEGIN_DECLS
 
-unsigned long int getauxval(unsigned long int type);
+unsigned long int getauxval(unsigned long int type) __INTRODUCED_IN(18);
 
 __END_DECLS
 
diff --git a/libc/include/sys/cachectl.h b/libc/include/sys/cachectl.h
index a302ff8..5b20c19 100644
--- a/libc/include/sys/cachectl.h
+++ b/libc/include/sys/cachectl.h
@@ -25,11 +25,13 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_CACHECTL_H
 #define _SYS_CACHECTL_H 1
 
+#include <sys/cdefs.h>
 #ifdef __mips__
 #include <asm/cachectl.h>
-extern int __cachectl (void *addr, __const int nbytes, __const int op);
 #endif
+
 #endif /* sys/cachectl.h */
diff --git a/libc/include/sys/capability.h b/libc/include/sys/capability.h
index 7718a6c..b9a40b3 100644
--- a/libc/include/sys/capability.h
+++ b/libc/include/sys/capability.h
@@ -34,8 +34,8 @@
 
 __BEGIN_DECLS
 
-extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
-extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
+int capget(cap_user_header_t hdrp, cap_user_data_t datap);
+int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
 
 __END_DECLS
 
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index f51942b..63e782e 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -40,7 +40,6 @@
 /*
  * Testing against Clang-specific extensions.
  */
-
 #ifndef __has_extension
 #define __has_extension         __has_feature
 #endif
@@ -57,38 +56,22 @@
 #define __has_attribute(x)      0
 #endif
 
-
-/*
- * Macro to test if we're using a GNU C compiler of a specific vintage
- * or later, for e.g. features that appeared in a particular version
- * of GNU C.  Usage:
- *
- *	#if __GNUC_PREREQ(major, minor)
- *	...cool feature...
- *	#else
- *	...delete feature...
- *	#endif
- */
-#ifdef __GNUC__
-#define	__GNUC_PREREQ(x, y)						\
-	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\
-	 (__GNUC__ > (x)))
-#else
-#define	__GNUC_PREREQ(x, y)	0
-#endif
-
 #define __strong_alias(alias, sym) \
     __asm__(".global " #alias "\n" \
             #alias " = " #sym);
 
 #if defined(__cplusplus)
-#define	__BEGIN_DECLS		extern "C" {
-#define	__END_DECLS		}
-#define	__static_cast(x,y)	static_cast<x>(y)
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
 #else
-#define	__BEGIN_DECLS
-#define	__END_DECLS
-#define	__static_cast(x,y)	(x)y
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
+#if defined(__cplusplus)
+#define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v))
+#else
+#define __BIONIC_CAST(_k,_t,_v) ((_t) (_v))
 #endif
 
 /*
@@ -107,15 +90,8 @@
 #define	__CONCAT(x,y)	x ## y
 #define	__STRING(x)	#x
 
-#define	__const		const		/* define reserved names to standard */
-#define	__signed	signed
-#define	__volatile	volatile
 #if defined(__cplusplus)
 #define	__inline	inline		/* convert to C++ keyword */
-#else
-#if !defined(__GNUC__) && !defined(__lint__)
-#define	__inline			/* delete GCC keyword */
-#endif /* !__GNUC__  && !__lint__ */
 #endif /* !__cplusplus */
 
 #else	/* !(__STDC__ || __cplusplus) */
@@ -123,61 +99,56 @@
 #define	__CONCAT(x,y)	x/**/y
 #define	__STRING(x)	"x"
 
-#ifndef __GNUC__
-#define	__const				/* delete pseudo-ANSI C keywords */
-#define	__inline
-#define	__signed
-#define	__volatile
-#endif	/* !__GNUC__ */
-
 #endif	/* !(__STDC__ || __cplusplus) */
 
-/*
- * The following macro is used to remove const cast-away warnings
- * from gcc -Wcast-qual; it should be used with caution because it
- * can hide valid errors; in particular most valid uses are in
- * situations where the API requires it, not to cast away string
- * constants. We don't use *intptr_t on purpose here and we are
- * explicit about unsigned long so that we don't have additional
- * dependencies.
- */
-#define __UNCONST(a)	((void *)(unsigned long)(const void *)(a))
-
+#define __always_inline __attribute__((__always_inline__))
+#define __attribute_const__ __attribute__((__const__))
+#define __attribute_pure__ __attribute__((__pure__))
 #define __dead __attribute__((__noreturn__))
-#define __pure __attribute__((__const__))
-#define __pure2 __attribute__((__const__)) /* Android-added: used by FreeBSD libm */
-
-#define	__unused	__attribute__((__unused__))
-
-#define	__used		__attribute__((__used__))
-
-#define	__packed	__attribute__((__packed__))
-#define	__aligned(x)	__attribute__((__aligned__(x)))
-#define	__section(x)	__attribute__((__section__(x)))
-
-#define __statement(x)	__extension__(x)
-
-#define __nonnull(args) __attribute__((__nonnull__ args))
-
-#define __printflike(x, y) __attribute__((__format__(printf, x, y))) __nonnull((x))
-#define __scanflike(x, y) __attribute__((__format__(scanf, x, y))) __nonnull((x))
+#define __noreturn __attribute__((__noreturn__))
+#define __mallocfunc  __attribute__((__malloc__))
+#define __packed __attribute__((__packed__))
+#define __unused __attribute__((__unused__))
+#define __used __attribute__((__used__))
 
 /*
- * C99 defines the restrict type qualifier keyword.
+ * _Nonnull is similar to the nonnull attribute in that it will instruct
+ * compilers to warn the user if it can prove that a null argument is being
+ * passed. Unlike the nonnull attribute, this annotation indicated that a value
+ * *should not* be null, not that it *cannot* be null, or even that the behavior
+ * is undefined. The important distinction is that the optimizer will perform
+ * surprising optimizations like the following:
+ *
+ *     void foo(void*) __attribute__(nonnull, 1);
+ *
+ *     int bar(int* p) {
+ *       foo(p);
+ *
+ *       // The following null check will be elided because nonnull attribute
+ *       // means that, since we call foo with p, p can be assumed to not be
+ *       // null. Thus this will crash if we are called with a null pointer.
+ *       if (p != NULL) {
+ *         return *p;
+ *       }
+ *       return 0;
+ *     }
+ *
+ *     int main() {
+ *       return bar(NULL);
+ *     }
+ *
+ * http://clang.llvm.org/docs/AttributeReference.html#nonnull
  */
-#if defined(__STDC__VERSION__) && __STDC_VERSION__ >= 199901L
-#define	__restrict	restrict
+#if !(defined(__clang__) && __has_feature(nullability))
+#define _Nonnull
+#define _Nullable
 #endif
 
-/*
- * C99 defines __func__ predefined identifier.
- */
-#if !defined(__STDC_VERSION__) || !(__STDC_VERSION__ >= 199901L)
-#define	__func__	__PRETTY_FUNCTION__
-#endif /* !(__STDC_VERSION__ >= 199901L) */
+#define __printflike(x, y) __attribute__((__format__(printf, x, y)))
+#define __scanflike(x, y) __attribute__((__format__(scanf, x, y)))
 
 /*
- * GNU C version 2.96 adds explicit branch prediction so that
+ * GNU C version 2.96 added explicit branch prediction so that
  * the CPU back-end can hint the processor and also so that
  * code blocks can be reordered such that the predicted path
  * sees a more linear flow, thus improving cache behavior, etc.
@@ -207,16 +178,13 @@
 #define	__predict_true(exp)	__builtin_expect((exp) != 0, 1)
 #define	__predict_false(exp)	__builtin_expect((exp) != 0, 0)
 
-#define __noreturn    __attribute__((__noreturn__))
-#define __mallocfunc  __attribute__((malloc))
-#define __purefunc    __attribute__((pure))
-
-#define __always_inline __attribute__((__always_inline__))
-
 #define __wur __attribute__((__warn_unused_result__))
 
+#ifdef __clang__
+#define __errorattr(msg) __attribute__((unavailable(msg)))
+#else
 #define __errorattr(msg) __attribute__((__error__(msg)))
-#define __warnattr(msg) __attribute__((__warning__(msg)))
+#endif
 
 #define __errordecl(name, msg) extern void name(void) __errorattr(msg)
 
@@ -232,176 +200,35 @@
 #define __SCCSID(_s) /* nothing */
 
 /*
- * _BSD_SOURCE and _GNU_SOURCE are expected to be defined by callers before
- * any standard header file is included. In those header files we test
- * against __USE_BSD and __USE_GNU. glibc does this in <features.h> but we
- * do it in <sys/cdefs.h> instead because that's where our existing
- * _POSIX_C_SOURCE tests were, and we're already confident that <sys/cdefs.h>
- * is included everywhere it should be.
+ * With bionic, you always get all C and POSIX API.
  *
- * The _GNU_SOURCE test needs to come before any _BSD_SOURCE or _POSIX* tests
- * because _GNU_SOURCE implies everything else.
+ * If you want BSD and/or GNU extensions, _BSD_SOURCE and/or _GNU_SOURCE are
+ * expected to be defined by callers before *any* standard header file is
+ * included.
+ *
+ * In our header files we test against __USE_BSD and __USE_GNU.
  */
 #if defined(_GNU_SOURCE)
+# define __USE_BSD 1
 # define __USE_GNU 1
-# undef _POSIX_SOURCE
-# define _POSIX_SOURCE 1
-# undef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200809L
-# undef _BSD_SOURCE
-# define _BSD_SOURCE 1
 #endif
 
 #if defined(_BSD_SOURCE)
 # define __USE_BSD 1
 #endif
 
-/*
- * _FILE_OFFSET_BITS 64 support.
- */
+/* _FILE_OFFSET_BITS 64 support. */
 #if !defined(__LP64__) && defined(_FILE_OFFSET_BITS)
 #if _FILE_OFFSET_BITS == 64
 #define __USE_FILE_OFFSET64 1
 #endif
 #endif
 
-/*-
- * POSIX.1 requires that the macros we test be defined before any standard
- * header file is included.
- *
- * Here's a quick run-down of the versions:
- *  defined(_POSIX_SOURCE)		1003.1-1988
- *  _POSIX_C_SOURCE == 1		1003.1-1990
- *  _POSIX_C_SOURCE == 2		1003.2-1992 C Language Binding Option
- *  _POSIX_C_SOURCE == 199309		1003.1b-1993
- *  _POSIX_C_SOURCE == 199506		1003.1c-1995, 1003.1i-1995,
- *					and the omnibus ISO/IEC 9945-1: 1996
- *  _POSIX_C_SOURCE == 200112		1003.1-2001
- *  _POSIX_C_SOURCE == 200809		1003.1-2008
- *
- * In addition, the X/Open Portability Guide, which is now the Single UNIX
- * Specification, defines a feature-test macro which indicates the version of
- * that specification, and which subsumes _POSIX_C_SOURCE.
- *
- * Our macros begin with two underscores to avoid namespace screwage.
- */
-
-/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
-#undef _POSIX_C_SOURCE		/* Probably illegal, but beyond caring now. */
-#define	_POSIX_C_SOURCE		199009
-#endif
-
-/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
-#undef _POSIX_C_SOURCE
-#define	_POSIX_C_SOURCE		199209
-#endif
-
-/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
-#ifdef _XOPEN_SOURCE
-#if _XOPEN_SOURCE - 0 >= 700
-#define	__XSI_VISIBLE		700
-#undef _POSIX_C_SOURCE
-#define	_POSIX_C_SOURCE		200809
-#elif _XOPEN_SOURCE - 0 >= 600
-#define	__XSI_VISIBLE		600
-#undef _POSIX_C_SOURCE
-#define	_POSIX_C_SOURCE		200112
-#elif _XOPEN_SOURCE - 0 >= 500
-#define	__XSI_VISIBLE		500
-#undef _POSIX_C_SOURCE
-#define	_POSIX_C_SOURCE		199506
-#endif
-#endif
-
-/*
- * Deal with all versions of POSIX.  The ordering relative to the tests above is
- * important.
- */
-#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
-#define	_POSIX_C_SOURCE		198808
-#endif
-#ifdef _POSIX_C_SOURCE
-#if _POSIX_C_SOURCE >= 200809
-#define	__POSIX_VISIBLE		200809
-#define	__ISO_C_VISIBLE		1999
-#elif _POSIX_C_SOURCE >= 200112
-#define	__POSIX_VISIBLE		200112
-#define	__ISO_C_VISIBLE		1999
-#elif _POSIX_C_SOURCE >= 199506
-#define	__POSIX_VISIBLE		199506
-#define	__ISO_C_VISIBLE		1990
-#elif _POSIX_C_SOURCE >= 199309
-#define	__POSIX_VISIBLE		199309
-#define	__ISO_C_VISIBLE		1990
-#elif _POSIX_C_SOURCE >= 199209
-#define	__POSIX_VISIBLE		199209
-#define	__ISO_C_VISIBLE		1990
-#elif _POSIX_C_SOURCE >= 199009
-#define	__POSIX_VISIBLE		199009
-#define	__ISO_C_VISIBLE		1990
-#else
-#define	__POSIX_VISIBLE		198808
-#define	__ISO_C_VISIBLE		0
-#endif /* _POSIX_C_SOURCE */
-#else
-/*-
- * Deal with _ANSI_SOURCE:
- * If it is defined, and no other compilation environment is explicitly
- * requested, then define our internal feature-test macros to zero.  This
- * makes no difference to the preprocessor (undefined symbols in preprocessing
- * expressions are defined to have value zero), but makes it more convenient for
- * a test program to print out the values.
- *
- * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
- * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
- * environment (and in fact we will never get here).
- */
-#if defined(_ANSI_SOURCE)	/* Hide almost everything. */
-#define	__POSIX_VISIBLE		0
-#define	__XSI_VISIBLE		0
-#define	__BSD_VISIBLE		0
-#define	__ISO_C_VISIBLE		1990
-#elif defined(_C99_SOURCE)	/* Localism to specify strict C99 env. */
-#define	__POSIX_VISIBLE		0
-#define	__XSI_VISIBLE		0
-#define	__BSD_VISIBLE		0
-#define	__ISO_C_VISIBLE		1999
-#else				/* Default environment: show everything. */
-#define	__POSIX_VISIBLE		200809
-#define	__XSI_VISIBLE		700
-#define	__BSD_VISIBLE		1
-#define	__ISO_C_VISIBLE		1999
-#endif
-#endif
-
-/*
- * Default values.
- */
-#ifndef __XPG_VISIBLE
-# define __XPG_VISIBLE          700
-#endif
-#ifndef __POSIX_VISIBLE
-# define __POSIX_VISIBLE        200809
-#endif
-#ifndef __ISO_C_VISIBLE
-# define __ISO_C_VISIBLE        1999
-#endif
-#ifndef __BSD_VISIBLE
-# define __BSD_VISIBLE          1
-#endif
-
 #define  __BIONIC__   1
 #include <android/api-level.h>
 
 /* glibc compatibility. */
-#if __POSIX_VISIBLE >= 200809
-#define __USE_ISOC99 1
-#define __USE_XOPEN2K 1
-#define __USE_XOPEN2K8 1
-#endif
-#if __LP64__
+#if defined(__LP64__)
 #define __WORDSIZE 64
 #else
 #define __WORDSIZE 32
@@ -423,40 +250,34 @@
 #    define __bos(s) __builtin_object_size((s), 0)
 #  endif
 #  define __bos0(s) __builtin_object_size((s), 0)
-#  define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
+#  if defined(__clang__)
+#    define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline))
+#  else
+#    define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
+#  endif
 #endif
-#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
+#define __BIONIC_FORTIFY_UNKNOWN_SIZE __BIONIC_CAST(static_cast, size_t, -1)
 
 /* Used to tag non-static symbols that are private and never exposed by the shared library. */
 #define __LIBC_HIDDEN__ __attribute__((visibility("hidden")))
 
-/* Like __LIBC_HIDDEN__, but preserves binary compatibility for LP32. */
+/*
+ * Used to tag symbols that should be hidden for 64-bit,
+ * but visible to preserve binary compatibility for LP32.
+ */
 #ifdef __LP64__
-#define __LIBC32_LEGACY_PUBLIC__ __LIBC_HIDDEN__
+#define __LIBC32_LEGACY_PUBLIC__ __attribute__((visibility("hidden")))
 #else
-#define __LIBC32_LEGACY_PUBLIC__ __LIBC_ABI_PUBLIC__
+#define __LIBC32_LEGACY_PUBLIC__ __attribute__((visibility("default")))
 #endif
 
-/* Used to tag non-static symbols that are public and exposed by the shared library. */
-#define __LIBC_ABI_PUBLIC__ __attribute__((visibility ("default")))
-
 /* Used to rename functions so that the compiler emits a call to 'x' rather than the function this was applied to. */
 #define __RENAME(x) __asm__(#x)
 
-#ifdef __clang__
-#define __AVAILABILITY(...) __attribute__((availability(android,__VA_ARGS__)))
-#define __INTRODUCED_IN(api_level) __AVAILABILITY(introduced=api_level)
-#define __DEPRECATED_IN(api_level) __AVAILABILITY(deprecated=api_level)
-#define __REMOVED_IN(api_level) __AVAILABILITY(obsoleted=api_level)
-#else
-#define __AVAILABILITY(...)
-#define __INTRODUCED_IN(api_level)
-#define __DEPRECATED_IN(api_level)
-#define __REMOVED_IN(api_level)
-#endif // __clang__
+#include <android/versioning.h>
 
 #if __has_builtin(__builtin_umul_overflow) || __GNUC__ >= 5
-#if __LP64__
+#if defined(__LP64__)
 #define __size_mul_overflow(a, b, result) __builtin_umull_overflow(a, b, result)
 #else
 #define __size_mul_overflow(a, b, result) __builtin_umul_overflow(a, b, result)
@@ -470,4 +291,17 @@
 }
 #endif
 
+/*
+ * TODO(danalbert): Remove this once we've moved entirely off prebuilts/ndk.
+ *
+ * The NDK used to have a __NDK_FPABI__ that was defined to empty for most cases
+ * but `__attribute__((pcs("aapcs")))` for the now defunct armeabi-v7a-hard ABI.
+ *
+ * During the transition from prebuilts/ndk to ndk_headers, we'll have some
+ * headers that still use __NDK_FPABI__ while the libc headers have stopped
+ * defining it. In the interim, just provide an empty definition to keep the
+ * build working.
+ */
+#define __NDK_FPABI__
+
 #endif /* !_SYS_CDEFS_H_ */
diff --git a/libc/include/sys/endian.h b/libc/include/sys/endian.h
index 60cc030..de172fe 100644
--- a/libc/include/sys/endian.h
+++ b/libc/include/sys/endian.h
@@ -49,10 +49,10 @@
 
 /* glibc compatibility. */
 __BEGIN_DECLS
-uint32_t htonl(uint32_t) __pure2;
-uint16_t htons(uint16_t) __pure2;
-uint32_t ntohl(uint32_t) __pure2;
-uint16_t ntohs(uint16_t) __pure2;
+uint32_t htonl(uint32_t) __attribute_const__ __INTRODUCED_IN(21);
+uint16_t htons(uint16_t) __attribute_const__ __INTRODUCED_IN(21);
+uint32_t ntohl(uint32_t) __attribute_const__ __INTRODUCED_IN(21);
+uint16_t ntohs(uint16_t) __attribute_const__ __INTRODUCED_IN(21);
 __END_DECLS
 
 #define htonl(x) __swap32(x)
@@ -64,7 +64,7 @@
 #define htonq(x) __swap64(x)
 #define ntohq(x) __swap64(x)
 
-#if __BSD_VISIBLE
+#if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
 #define LITTLE_ENDIAN _LITTLE_ENDIAN
 #define BIG_ENDIAN _BIG_ENDIAN
 #define PDP_ENDIAN _PDP_ENDIAN
@@ -101,6 +101,6 @@
 #define le16toh(x) htole16(x)
 #define le32toh(x) htole32(x)
 #define le64toh(x) htole64(x)
-#endif /* __BSD_VISIBLE */
+#endif /* __USE_BSD */
 
 #endif /* _SYS_ENDIAN_H_ */
diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h
index 4a5a37c..4ec8969 100644
--- a/libc/include/sys/epoll.h
+++ b/libc/include/sys/epoll.h
@@ -74,10 +74,10 @@
 ;
 
 int epoll_create(int);
-int epoll_create1(int);
+int epoll_create1(int) __INTRODUCED_IN(21);
 int epoll_ctl(int, int, int, struct epoll_event*);
 int epoll_wait(int, struct epoll_event*, int, int);
-int epoll_pwait(int, struct epoll_event*, int, int, const sigset_t*);
+int epoll_pwait(int, struct epoll_event*, int, int, const sigset_t*) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/sys/eventfd.h b/libc/include/sys/eventfd.h
index 4c8da0c..6b9749a 100644
--- a/libc/include/sys/eventfd.h
+++ b/libc/include/sys/eventfd.h
@@ -40,10 +40,10 @@
 /* type of event counter */
 typedef uint64_t eventfd_t;
 
-extern int eventfd(unsigned int initial_value, int flags);
+int eventfd(unsigned int initial_value, int flags);
 
-extern int eventfd_read(int fd, eventfd_t* value);
-extern int eventfd_write(int fd, eventfd_t value);
+int eventfd_read(int fd, eventfd_t* value);
+int eventfd_write(int fd, eventfd_t value);
 
 __END_DECLS
 
diff --git a/libc/include/sys/fsuid.h b/libc/include/sys/fsuid.h
index 03355b7..e4d9ebc 100644
--- a/libc/include/sys/fsuid.h
+++ b/libc/include/sys/fsuid.h
@@ -34,8 +34,8 @@
 
 __BEGIN_DECLS
 
-extern int setfsuid(uid_t);
-extern int setfsgid(gid_t);
+int setfsuid(uid_t) __INTRODUCED_IN(21);
+int setfsgid(gid_t) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/sys/glibc-syscalls.h b/libc/include/sys/glibc-syscalls.h
deleted file mode 100644
index 26887b1..0000000
--- a/libc/include/sys/glibc-syscalls.h
+++ /dev/null
@@ -1,1759 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-#ifndef _BIONIC_GLIBC_SYSCALLS_H_
-#define _BIONIC_GLIBC_SYSCALLS_H_
-#if defined(__aarch64__)
-#define SYS_accept __NR_accept
-#define SYS_accept4 __NR_accept4
-#define SYS_access __NR_access
-#define SYS_acct __NR_acct
-#define SYS_add_key __NR_add_key
-#define SYS_adjtimex __NR_adjtimex
-#define SYS_alarm __NR_alarm
-#define SYS_arch_specific_syscall __NR_arch_specific_syscall
-#define SYS_bdflush __NR_bdflush
-#define SYS_bind __NR_bind
-#define SYS_bpf __NR_bpf
-#define SYS_brk __NR_brk
-#define SYS_capget __NR_capget
-#define SYS_capset __NR_capset
-#define SYS_chdir __NR_chdir
-#define SYS_chmod __NR_chmod
-#define SYS_chown __NR_chown
-#define SYS_chroot __NR_chroot
-#define SYS_clock_adjtime __NR_clock_adjtime
-#define SYS_clock_getres __NR_clock_getres
-#define SYS_clock_gettime __NR_clock_gettime
-#define SYS_clock_nanosleep __NR_clock_nanosleep
-#define SYS_clock_settime __NR_clock_settime
-#define SYS_clone __NR_clone
-#define SYS_close __NR_close
-#define SYS_connect __NR_connect
-#define SYS_creat __NR_creat
-#define SYS_delete_module __NR_delete_module
-#define SYS_dup __NR_dup
-#define SYS_dup2 __NR_dup2
-#define SYS_dup3 __NR_dup3
-#define SYS_epoll_create __NR_epoll_create
-#define SYS_epoll_create1 __NR_epoll_create1
-#define SYS_epoll_ctl __NR_epoll_ctl
-#define SYS_epoll_pwait __NR_epoll_pwait
-#define SYS_epoll_wait __NR_epoll_wait
-#define SYS_eventfd __NR_eventfd
-#define SYS_eventfd2 __NR_eventfd2
-#define SYS_execve __NR_execve
-#define SYS_execveat __NR_execveat
-#define SYS_exit __NR_exit
-#define SYS_exit_group __NR_exit_group
-#define SYS_faccessat __NR_faccessat
-#define SYS_fadvise64 __NR_fadvise64
-#define SYS_fadvise64_64 __NR_fadvise64_64
-#define SYS_fallocate __NR_fallocate
-#define SYS_fanotify_init __NR_fanotify_init
-#define SYS_fanotify_mark __NR_fanotify_mark
-#define SYS_fchdir __NR_fchdir
-#define SYS_fchmod __NR_fchmod
-#define SYS_fchmodat __NR_fchmodat
-#define SYS_fchown __NR_fchown
-#define SYS_fchownat __NR_fchownat
-#define SYS_fcntl __NR_fcntl
-#define SYS_fcntl64 __NR_fcntl64
-#define SYS_fdatasync __NR_fdatasync
-#define SYS_fgetxattr __NR_fgetxattr
-#define SYS_finit_module __NR_finit_module
-#define SYS_flistxattr __NR_flistxattr
-#define SYS_flock __NR_flock
-#define SYS_fork __NR_fork
-#define SYS_fremovexattr __NR_fremovexattr
-#define SYS_fsetxattr __NR_fsetxattr
-#define SYS_fstat __NR_fstat
-#define SYS_fstat64 __NR_fstat64
-#define SYS_fstatat64 __NR_fstatat64
-#define SYS_fstatfs __NR_fstatfs
-#define SYS_fstatfs64 __NR_fstatfs64
-#define SYS_fsync __NR_fsync
-#define SYS_ftruncate __NR_ftruncate
-#define SYS_ftruncate64 __NR_ftruncate64
-#define SYS_futex __NR_futex
-#define SYS_futimesat __NR_futimesat
-#define SYS_get_mempolicy __NR_get_mempolicy
-#define SYS_get_robust_list __NR_get_robust_list
-#define SYS_getcpu __NR_getcpu
-#define SYS_getcwd __NR_getcwd
-#define SYS_getdents __NR_getdents
-#define SYS_getdents64 __NR_getdents64
-#define SYS_getegid __NR_getegid
-#define SYS_geteuid __NR_geteuid
-#define SYS_getgid __NR_getgid
-#define SYS_getgroups __NR_getgroups
-#define SYS_getitimer __NR_getitimer
-#define SYS_getpeername __NR_getpeername
-#define SYS_getpgid __NR_getpgid
-#define SYS_getpgrp __NR_getpgrp
-#define SYS_getpid __NR_getpid
-#define SYS_getppid __NR_getppid
-#define SYS_getpriority __NR_getpriority
-#define SYS_getrandom __NR_getrandom
-#define SYS_getresgid __NR_getresgid
-#define SYS_getresuid __NR_getresuid
-#define SYS_getrlimit __NR_getrlimit
-#define SYS_getrusage __NR_getrusage
-#define SYS_getsid __NR_getsid
-#define SYS_getsockname __NR_getsockname
-#define SYS_getsockopt __NR_getsockopt
-#define SYS_gettid __NR_gettid
-#define SYS_gettimeofday __NR_gettimeofday
-#define SYS_getuid __NR_getuid
-#define SYS_getxattr __NR_getxattr
-#define SYS_init_module __NR_init_module
-#define SYS_inotify_add_watch __NR_inotify_add_watch
-#define SYS_inotify_init __NR_inotify_init
-#define SYS_inotify_init1 __NR_inotify_init1
-#define SYS_inotify_rm_watch __NR_inotify_rm_watch
-#define SYS_io_cancel __NR_io_cancel
-#define SYS_io_destroy __NR_io_destroy
-#define SYS_io_getevents __NR_io_getevents
-#define SYS_io_setup __NR_io_setup
-#define SYS_io_submit __NR_io_submit
-#define SYS_ioctl __NR_ioctl
-#define SYS_ioprio_get __NR_ioprio_get
-#define SYS_ioprio_set __NR_ioprio_set
-#define SYS_kcmp __NR_kcmp
-#define SYS_kexec_load __NR_kexec_load
-#define SYS_keyctl __NR_keyctl
-#define SYS_kill __NR_kill
-#define SYS_lchown __NR_lchown
-#define SYS_lgetxattr __NR_lgetxattr
-#define SYS_link __NR_link
-#define SYS_linkat __NR_linkat
-#define SYS_listen __NR_listen
-#define SYS_listxattr __NR_listxattr
-#define SYS_llistxattr __NR_llistxattr
-#define SYS_llseek __NR_llseek
-#define SYS_lookup_dcookie __NR_lookup_dcookie
-#define SYS_lremovexattr __NR_lremovexattr
-#define SYS_lseek __NR_lseek
-#define SYS_lsetxattr __NR_lsetxattr
-#define SYS_lstat __NR_lstat
-#define SYS_lstat64 __NR_lstat64
-#define SYS_madvise __NR_madvise
-#define SYS_mbind __NR_mbind
-#define SYS_membarrier __NR_membarrier
-#define SYS_memfd_create __NR_memfd_create
-#define SYS_migrate_pages __NR_migrate_pages
-#define SYS_mincore __NR_mincore
-#define SYS_mkdir __NR_mkdir
-#define SYS_mkdirat __NR_mkdirat
-#define SYS_mknod __NR_mknod
-#define SYS_mknodat __NR_mknodat
-#define SYS_mlock __NR_mlock
-#define SYS_mlock2 __NR_mlock2
-#define SYS_mlockall __NR_mlockall
-#define SYS_mmap __NR_mmap
-#define SYS_mmap2 __NR_mmap2
-#define SYS_mount __NR_mount
-#define SYS_move_pages __NR_move_pages
-#define SYS_mprotect __NR_mprotect
-#define SYS_mq_getsetattr __NR_mq_getsetattr
-#define SYS_mq_notify __NR_mq_notify
-#define SYS_mq_open __NR_mq_open
-#define SYS_mq_timedreceive __NR_mq_timedreceive
-#define SYS_mq_timedsend __NR_mq_timedsend
-#define SYS_mq_unlink __NR_mq_unlink
-#define SYS_mremap __NR_mremap
-#define SYS_msgctl __NR_msgctl
-#define SYS_msgget __NR_msgget
-#define SYS_msgrcv __NR_msgrcv
-#define SYS_msgsnd __NR_msgsnd
-#define SYS_msync __NR_msync
-#define SYS_munlock __NR_munlock
-#define SYS_munlockall __NR_munlockall
-#define SYS_munmap __NR_munmap
-#define SYS_name_to_handle_at __NR_name_to_handle_at
-#define SYS_nanosleep __NR_nanosleep
-#define SYS_newfstatat __NR_newfstatat
-#define SYS_nfsservctl __NR_nfsservctl
-#define SYS_oldwait4 __NR_oldwait4
-#define SYS_open __NR_open
-#define SYS_open_by_handle_at __NR_open_by_handle_at
-#define SYS_openat __NR_openat
-#define SYS_pause __NR_pause
-#define SYS_perf_event_open __NR_perf_event_open
-#define SYS_personality __NR_personality
-#define SYS_pipe __NR_pipe
-#define SYS_pipe2 __NR_pipe2
-#define SYS_pivot_root __NR_pivot_root
-#define SYS_poll __NR_poll
-#define SYS_ppoll __NR_ppoll
-#define SYS_prctl __NR_prctl
-#define SYS_pread64 __NR_pread64
-#define SYS_preadv __NR_preadv
-#define SYS_prlimit64 __NR_prlimit64
-#define SYS_process_vm_readv __NR_process_vm_readv
-#define SYS_process_vm_writev __NR_process_vm_writev
-#define SYS_pselect6 __NR_pselect6
-#define SYS_ptrace __NR_ptrace
-#define SYS_pwrite64 __NR_pwrite64
-#define SYS_pwritev __NR_pwritev
-#define SYS_quotactl __NR_quotactl
-#define SYS_read __NR_read
-#define SYS_readahead __NR_readahead
-#define SYS_readlink __NR_readlink
-#define SYS_readlinkat __NR_readlinkat
-#define SYS_readv __NR_readv
-#define SYS_reboot __NR_reboot
-#define SYS_recv __NR_recv
-#define SYS_recvfrom __NR_recvfrom
-#define SYS_recvmmsg __NR_recvmmsg
-#define SYS_recvmsg __NR_recvmsg
-#define SYS_remap_file_pages __NR_remap_file_pages
-#define SYS_removexattr __NR_removexattr
-#define SYS_rename __NR_rename
-#define SYS_renameat __NR_renameat
-#define SYS_renameat2 __NR_renameat2
-#define SYS_request_key __NR_request_key
-#define SYS_restart_syscall __NR_restart_syscall
-#define SYS_rmdir __NR_rmdir
-#define SYS_rt_sigaction __NR_rt_sigaction
-#define SYS_rt_sigpending __NR_rt_sigpending
-#define SYS_rt_sigprocmask __NR_rt_sigprocmask
-#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
-#define SYS_rt_sigreturn __NR_rt_sigreturn
-#define SYS_rt_sigsuspend __NR_rt_sigsuspend
-#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
-#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
-#define SYS_sched_get_priority_max __NR_sched_get_priority_max
-#define SYS_sched_get_priority_min __NR_sched_get_priority_min
-#define SYS_sched_getaffinity __NR_sched_getaffinity
-#define SYS_sched_getattr __NR_sched_getattr
-#define SYS_sched_getparam __NR_sched_getparam
-#define SYS_sched_getscheduler __NR_sched_getscheduler
-#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
-#define SYS_sched_setaffinity __NR_sched_setaffinity
-#define SYS_sched_setattr __NR_sched_setattr
-#define SYS_sched_setparam __NR_sched_setparam
-#define SYS_sched_setscheduler __NR_sched_setscheduler
-#define SYS_sched_yield __NR_sched_yield
-#define SYS_seccomp __NR_seccomp
-#define SYS_select __NR_select
-#define SYS_semctl __NR_semctl
-#define SYS_semget __NR_semget
-#define SYS_semop __NR_semop
-#define SYS_semtimedop __NR_semtimedop
-#define SYS_send __NR_send
-#define SYS_sendfile __NR_sendfile
-#define SYS_sendfile64 __NR_sendfile64
-#define SYS_sendmmsg __NR_sendmmsg
-#define SYS_sendmsg __NR_sendmsg
-#define SYS_sendto __NR_sendto
-#define SYS_set_mempolicy __NR_set_mempolicy
-#define SYS_set_robust_list __NR_set_robust_list
-#define SYS_set_tid_address __NR_set_tid_address
-#define SYS_setdomainname __NR_setdomainname
-#define SYS_setfsgid __NR_setfsgid
-#define SYS_setfsuid __NR_setfsuid
-#define SYS_setgid __NR_setgid
-#define SYS_setgroups __NR_setgroups
-#define SYS_sethostname __NR_sethostname
-#define SYS_setitimer __NR_setitimer
-#define SYS_setns __NR_setns
-#define SYS_setpgid __NR_setpgid
-#define SYS_setpriority __NR_setpriority
-#define SYS_setregid __NR_setregid
-#define SYS_setresgid __NR_setresgid
-#define SYS_setresuid __NR_setresuid
-#define SYS_setreuid __NR_setreuid
-#define SYS_setrlimit __NR_setrlimit
-#define SYS_setsid __NR_setsid
-#define SYS_setsockopt __NR_setsockopt
-#define SYS_settimeofday __NR_settimeofday
-#define SYS_setuid __NR_setuid
-#define SYS_setxattr __NR_setxattr
-#define SYS_shmat __NR_shmat
-#define SYS_shmctl __NR_shmctl
-#define SYS_shmdt __NR_shmdt
-#define SYS_shmget __NR_shmget
-#define SYS_shutdown __NR_shutdown
-#define SYS_sigaltstack __NR_sigaltstack
-#define SYS_signalfd __NR_signalfd
-#define SYS_signalfd4 __NR_signalfd4
-#define SYS_socket __NR_socket
-#define SYS_socketpair __NR_socketpair
-#define SYS_splice __NR_splice
-#define SYS_stat __NR_stat
-#define SYS_stat64 __NR_stat64
-#define SYS_statfs __NR_statfs
-#define SYS_statfs64 __NR_statfs64
-#define SYS_swapoff __NR_swapoff
-#define SYS_swapon __NR_swapon
-#define SYS_symlink __NR_symlink
-#define SYS_symlinkat __NR_symlinkat
-#define SYS_sync __NR_sync
-#define SYS_sync_file_range __NR_sync_file_range
-#define SYS_sync_file_range2 __NR_sync_file_range2
-#define SYS_syncfs __NR_syncfs
-#define SYS_syscalls __NR_syscalls
-#define SYS_sysinfo __NR_sysinfo
-#define SYS_syslog __NR_syslog
-#define SYS_tee __NR_tee
-#define SYS_tgkill __NR_tgkill
-#define SYS_time __NR_time
-#define SYS_timer_create __NR_timer_create
-#define SYS_timer_delete __NR_timer_delete
-#define SYS_timer_getoverrun __NR_timer_getoverrun
-#define SYS_timer_gettime __NR_timer_gettime
-#define SYS_timer_settime __NR_timer_settime
-#define SYS_timerfd_create __NR_timerfd_create
-#define SYS_timerfd_gettime __NR_timerfd_gettime
-#define SYS_timerfd_settime __NR_timerfd_settime
-#define SYS_times __NR_times
-#define SYS_tkill __NR_tkill
-#define SYS_truncate __NR_truncate
-#define SYS_truncate64 __NR_truncate64
-#define SYS_umask __NR_umask
-#define SYS_umount __NR_umount
-#define SYS_umount2 __NR_umount2
-#define SYS_uname __NR_uname
-#define SYS_unlink __NR_unlink
-#define SYS_unlinkat __NR_unlinkat
-#define SYS_unshare __NR_unshare
-#define SYS_uselib __NR_uselib
-#define SYS_userfaultfd __NR_userfaultfd
-#define SYS_ustat __NR_ustat
-#define SYS_utime __NR_utime
-#define SYS_utimensat __NR_utimensat
-#define SYS_utimes __NR_utimes
-#define SYS_vfork __NR_vfork
-#define SYS_vhangup __NR_vhangup
-#define SYS_vmsplice __NR_vmsplice
-#define SYS_wait4 __NR_wait4
-#define SYS_waitid __NR_waitid
-#define SYS_write __NR_write
-#define SYS_writev __NR_writev
-#elif defined(__arm__)
-#define SYS_accept __NR_accept
-#define SYS_accept4 __NR_accept4
-#define SYS_access __NR_access
-#define SYS_acct __NR_acct
-#define SYS_add_key __NR_add_key
-#define SYS_adjtimex __NR_adjtimex
-#define SYS_alarm __NR_alarm
-#define SYS_arm_fadvise64_64 __NR_arm_fadvise64_64
-#define SYS_arm_sync_file_range __NR_arm_sync_file_range
-#define SYS_bdflush __NR_bdflush
-#define SYS_bind __NR_bind
-#define SYS_bpf __NR_bpf
-#define SYS_brk __NR_brk
-#define SYS_capget __NR_capget
-#define SYS_capset __NR_capset
-#define SYS_chdir __NR_chdir
-#define SYS_chmod __NR_chmod
-#define SYS_chown __NR_chown
-#define SYS_chown32 __NR_chown32
-#define SYS_chroot __NR_chroot
-#define SYS_clock_adjtime __NR_clock_adjtime
-#define SYS_clock_getres __NR_clock_getres
-#define SYS_clock_gettime __NR_clock_gettime
-#define SYS_clock_nanosleep __NR_clock_nanosleep
-#define SYS_clock_settime __NR_clock_settime
-#define SYS_clone __NR_clone
-#define SYS_close __NR_close
-#define SYS_connect __NR_connect
-#define SYS_creat __NR_creat
-#define SYS_delete_module __NR_delete_module
-#define SYS_dup __NR_dup
-#define SYS_dup2 __NR_dup2
-#define SYS_dup3 __NR_dup3
-#define SYS_epoll_create __NR_epoll_create
-#define SYS_epoll_create1 __NR_epoll_create1
-#define SYS_epoll_ctl __NR_epoll_ctl
-#define SYS_epoll_pwait __NR_epoll_pwait
-#define SYS_epoll_wait __NR_epoll_wait
-#define SYS_eventfd __NR_eventfd
-#define SYS_eventfd2 __NR_eventfd2
-#define SYS_execve __NR_execve
-#define SYS_execveat __NR_execveat
-#define SYS_exit __NR_exit
-#define SYS_exit_group __NR_exit_group
-#define SYS_faccessat __NR_faccessat
-#define SYS_fallocate __NR_fallocate
-#define SYS_fanotify_init __NR_fanotify_init
-#define SYS_fanotify_mark __NR_fanotify_mark
-#define SYS_fchdir __NR_fchdir
-#define SYS_fchmod __NR_fchmod
-#define SYS_fchmodat __NR_fchmodat
-#define SYS_fchown __NR_fchown
-#define SYS_fchown32 __NR_fchown32
-#define SYS_fchownat __NR_fchownat
-#define SYS_fcntl __NR_fcntl
-#define SYS_fcntl64 __NR_fcntl64
-#define SYS_fdatasync __NR_fdatasync
-#define SYS_fgetxattr __NR_fgetxattr
-#define SYS_finit_module __NR_finit_module
-#define SYS_flistxattr __NR_flistxattr
-#define SYS_flock __NR_flock
-#define SYS_fork __NR_fork
-#define SYS_fremovexattr __NR_fremovexattr
-#define SYS_fsetxattr __NR_fsetxattr
-#define SYS_fstat __NR_fstat
-#define SYS_fstat64 __NR_fstat64
-#define SYS_fstatat64 __NR_fstatat64
-#define SYS_fstatfs __NR_fstatfs
-#define SYS_fstatfs64 __NR_fstatfs64
-#define SYS_fsync __NR_fsync
-#define SYS_ftruncate __NR_ftruncate
-#define SYS_ftruncate64 __NR_ftruncate64
-#define SYS_futex __NR_futex
-#define SYS_futimesat __NR_futimesat
-#define SYS_get_mempolicy __NR_get_mempolicy
-#define SYS_get_robust_list __NR_get_robust_list
-#define SYS_getcpu __NR_getcpu
-#define SYS_getcwd __NR_getcwd
-#define SYS_getdents __NR_getdents
-#define SYS_getdents64 __NR_getdents64
-#define SYS_getegid __NR_getegid
-#define SYS_getegid32 __NR_getegid32
-#define SYS_geteuid __NR_geteuid
-#define SYS_geteuid32 __NR_geteuid32
-#define SYS_getgid __NR_getgid
-#define SYS_getgid32 __NR_getgid32
-#define SYS_getgroups __NR_getgroups
-#define SYS_getgroups32 __NR_getgroups32
-#define SYS_getitimer __NR_getitimer
-#define SYS_getpeername __NR_getpeername
-#define SYS_getpgid __NR_getpgid
-#define SYS_getpgrp __NR_getpgrp
-#define SYS_getpid __NR_getpid
-#define SYS_getppid __NR_getppid
-#define SYS_getpriority __NR_getpriority
-#define SYS_getrandom __NR_getrandom
-#define SYS_getresgid __NR_getresgid
-#define SYS_getresgid32 __NR_getresgid32
-#define SYS_getresuid __NR_getresuid
-#define SYS_getresuid32 __NR_getresuid32
-#define SYS_getrlimit __NR_getrlimit
-#define SYS_getrusage __NR_getrusage
-#define SYS_getsid __NR_getsid
-#define SYS_getsockname __NR_getsockname
-#define SYS_getsockopt __NR_getsockopt
-#define SYS_gettid __NR_gettid
-#define SYS_gettimeofday __NR_gettimeofday
-#define SYS_getuid __NR_getuid
-#define SYS_getuid32 __NR_getuid32
-#define SYS_getxattr __NR_getxattr
-#define SYS_init_module __NR_init_module
-#define SYS_inotify_add_watch __NR_inotify_add_watch
-#define SYS_inotify_init __NR_inotify_init
-#define SYS_inotify_init1 __NR_inotify_init1
-#define SYS_inotify_rm_watch __NR_inotify_rm_watch
-#define SYS_io_cancel __NR_io_cancel
-#define SYS_io_destroy __NR_io_destroy
-#define SYS_io_getevents __NR_io_getevents
-#define SYS_io_setup __NR_io_setup
-#define SYS_io_submit __NR_io_submit
-#define SYS_ioctl __NR_ioctl
-#define SYS_ioprio_get __NR_ioprio_get
-#define SYS_ioprio_set __NR_ioprio_set
-#define SYS_ipc __NR_ipc
-#define SYS_kcmp __NR_kcmp
-#define SYS_kexec_load __NR_kexec_load
-#define SYS_keyctl __NR_keyctl
-#define SYS_kill __NR_kill
-#define SYS_lchown __NR_lchown
-#define SYS_lchown32 __NR_lchown32
-#define SYS_lgetxattr __NR_lgetxattr
-#define SYS_link __NR_link
-#define SYS_linkat __NR_linkat
-#define SYS_listen __NR_listen
-#define SYS_listxattr __NR_listxattr
-#define SYS_llistxattr __NR_llistxattr
-#define SYS_lookup_dcookie __NR_lookup_dcookie
-#define SYS_lremovexattr __NR_lremovexattr
-#define SYS_lseek __NR_lseek
-#define SYS_lsetxattr __NR_lsetxattr
-#define SYS_lstat __NR_lstat
-#define SYS_lstat64 __NR_lstat64
-#define SYS_madvise __NR_madvise
-#define SYS_mbind __NR_mbind
-#define SYS_membarrier __NR_membarrier
-#define SYS_memfd_create __NR_memfd_create
-#define SYS_mincore __NR_mincore
-#define SYS_mkdir __NR_mkdir
-#define SYS_mkdirat __NR_mkdirat
-#define SYS_mknod __NR_mknod
-#define SYS_mknodat __NR_mknodat
-#define SYS_mlock __NR_mlock
-#define SYS_mlock2 __NR_mlock2
-#define SYS_mlockall __NR_mlockall
-#define SYS_mmap __NR_mmap
-#define SYS_mmap2 __NR_mmap2
-#define SYS_mount __NR_mount
-#define SYS_move_pages __NR_move_pages
-#define SYS_mprotect __NR_mprotect
-#define SYS_mq_getsetattr __NR_mq_getsetattr
-#define SYS_mq_notify __NR_mq_notify
-#define SYS_mq_open __NR_mq_open
-#define SYS_mq_timedreceive __NR_mq_timedreceive
-#define SYS_mq_timedsend __NR_mq_timedsend
-#define SYS_mq_unlink __NR_mq_unlink
-#define SYS_mremap __NR_mremap
-#define SYS_msgctl __NR_msgctl
-#define SYS_msgget __NR_msgget
-#define SYS_msgrcv __NR_msgrcv
-#define SYS_msgsnd __NR_msgsnd
-#define SYS_msync __NR_msync
-#define SYS_munlock __NR_munlock
-#define SYS_munlockall __NR_munlockall
-#define SYS_munmap __NR_munmap
-#define SYS_name_to_handle_at __NR_name_to_handle_at
-#define SYS_nanosleep __NR_nanosleep
-#define SYS_nfsservctl __NR_nfsservctl
-#define SYS_nice __NR_nice
-#define SYS_open __NR_open
-#define SYS_open_by_handle_at __NR_open_by_handle_at
-#define SYS_openat __NR_openat
-#define SYS_pause __NR_pause
-#define SYS_pciconfig_iobase __NR_pciconfig_iobase
-#define SYS_pciconfig_read __NR_pciconfig_read
-#define SYS_pciconfig_write __NR_pciconfig_write
-#define SYS_perf_event_open __NR_perf_event_open
-#define SYS_personality __NR_personality
-#define SYS_pipe __NR_pipe
-#define SYS_pipe2 __NR_pipe2
-#define SYS_pivot_root __NR_pivot_root
-#define SYS_poll __NR_poll
-#define SYS_ppoll __NR_ppoll
-#define SYS_prctl __NR_prctl
-#define SYS_pread64 __NR_pread64
-#define SYS_preadv __NR_preadv
-#define SYS_prlimit64 __NR_prlimit64
-#define SYS_process_vm_readv __NR_process_vm_readv
-#define SYS_process_vm_writev __NR_process_vm_writev
-#define SYS_pselect6 __NR_pselect6
-#define SYS_ptrace __NR_ptrace
-#define SYS_pwrite64 __NR_pwrite64
-#define SYS_pwritev __NR_pwritev
-#define SYS_quotactl __NR_quotactl
-#define SYS_read __NR_read
-#define SYS_readahead __NR_readahead
-#define SYS_readdir __NR_readdir
-#define SYS_readlink __NR_readlink
-#define SYS_readlinkat __NR_readlinkat
-#define SYS_readv __NR_readv
-#define SYS_reboot __NR_reboot
-#define SYS_recv __NR_recv
-#define SYS_recvfrom __NR_recvfrom
-#define SYS_recvmmsg __NR_recvmmsg
-#define SYS_recvmsg __NR_recvmsg
-#define SYS_remap_file_pages __NR_remap_file_pages
-#define SYS_removexattr __NR_removexattr
-#define SYS_rename __NR_rename
-#define SYS_renameat __NR_renameat
-#define SYS_renameat2 __NR_renameat2
-#define SYS_request_key __NR_request_key
-#define SYS_restart_syscall __NR_restart_syscall
-#define SYS_rmdir __NR_rmdir
-#define SYS_rt_sigaction __NR_rt_sigaction
-#define SYS_rt_sigpending __NR_rt_sigpending
-#define SYS_rt_sigprocmask __NR_rt_sigprocmask
-#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
-#define SYS_rt_sigreturn __NR_rt_sigreturn
-#define SYS_rt_sigsuspend __NR_rt_sigsuspend
-#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
-#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
-#define SYS_sched_get_priority_max __NR_sched_get_priority_max
-#define SYS_sched_get_priority_min __NR_sched_get_priority_min
-#define SYS_sched_getaffinity __NR_sched_getaffinity
-#define SYS_sched_getattr __NR_sched_getattr
-#define SYS_sched_getparam __NR_sched_getparam
-#define SYS_sched_getscheduler __NR_sched_getscheduler
-#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
-#define SYS_sched_setaffinity __NR_sched_setaffinity
-#define SYS_sched_setattr __NR_sched_setattr
-#define SYS_sched_setparam __NR_sched_setparam
-#define SYS_sched_setscheduler __NR_sched_setscheduler
-#define SYS_sched_yield __NR_sched_yield
-#define SYS_seccomp __NR_seccomp
-#define SYS_select __NR_select
-#define SYS_semctl __NR_semctl
-#define SYS_semget __NR_semget
-#define SYS_semop __NR_semop
-#define SYS_semtimedop __NR_semtimedop
-#define SYS_send __NR_send
-#define SYS_sendfile __NR_sendfile
-#define SYS_sendfile64 __NR_sendfile64
-#define SYS_sendmmsg __NR_sendmmsg
-#define SYS_sendmsg __NR_sendmsg
-#define SYS_sendto __NR_sendto
-#define SYS_set_mempolicy __NR_set_mempolicy
-#define SYS_set_robust_list __NR_set_robust_list
-#define SYS_set_tid_address __NR_set_tid_address
-#define SYS_setdomainname __NR_setdomainname
-#define SYS_setfsgid __NR_setfsgid
-#define SYS_setfsgid32 __NR_setfsgid32
-#define SYS_setfsuid __NR_setfsuid
-#define SYS_setfsuid32 __NR_setfsuid32
-#define SYS_setgid __NR_setgid
-#define SYS_setgid32 __NR_setgid32
-#define SYS_setgroups __NR_setgroups
-#define SYS_setgroups32 __NR_setgroups32
-#define SYS_sethostname __NR_sethostname
-#define SYS_setitimer __NR_setitimer
-#define SYS_setns __NR_setns
-#define SYS_setpgid __NR_setpgid
-#define SYS_setpriority __NR_setpriority
-#define SYS_setregid __NR_setregid
-#define SYS_setregid32 __NR_setregid32
-#define SYS_setresgid __NR_setresgid
-#define SYS_setresgid32 __NR_setresgid32
-#define SYS_setresuid __NR_setresuid
-#define SYS_setresuid32 __NR_setresuid32
-#define SYS_setreuid __NR_setreuid
-#define SYS_setreuid32 __NR_setreuid32
-#define SYS_setrlimit __NR_setrlimit
-#define SYS_setsid __NR_setsid
-#define SYS_setsockopt __NR_setsockopt
-#define SYS_settimeofday __NR_settimeofday
-#define SYS_setuid __NR_setuid
-#define SYS_setuid32 __NR_setuid32
-#define SYS_setxattr __NR_setxattr
-#define SYS_shmat __NR_shmat
-#define SYS_shmctl __NR_shmctl
-#define SYS_shmdt __NR_shmdt
-#define SYS_shmget __NR_shmget
-#define SYS_shutdown __NR_shutdown
-#define SYS_sigaction __NR_sigaction
-#define SYS_sigaltstack __NR_sigaltstack
-#define SYS_signalfd __NR_signalfd
-#define SYS_signalfd4 __NR_signalfd4
-#define SYS_sigpending __NR_sigpending
-#define SYS_sigprocmask __NR_sigprocmask
-#define SYS_sigreturn __NR_sigreturn
-#define SYS_sigsuspend __NR_sigsuspend
-#define SYS_socket __NR_socket
-#define SYS_socketcall __NR_socketcall
-#define SYS_socketpair __NR_socketpair
-#define SYS_splice __NR_splice
-#define SYS_stat __NR_stat
-#define SYS_stat64 __NR_stat64
-#define SYS_statfs __NR_statfs
-#define SYS_statfs64 __NR_statfs64
-#define SYS_stime __NR_stime
-#define SYS_swapoff __NR_swapoff
-#define SYS_swapon __NR_swapon
-#define SYS_symlink __NR_symlink
-#define SYS_symlinkat __NR_symlinkat
-#define SYS_sync __NR_sync
-#define SYS_sync_file_range2 __NR_sync_file_range2
-#define SYS_syncfs __NR_syncfs
-#define SYS_syscall __NR_syscall
-#define SYS_sysfs __NR_sysfs
-#define SYS_sysinfo __NR_sysinfo
-#define SYS_syslog __NR_syslog
-#define SYS_tee __NR_tee
-#define SYS_tgkill __NR_tgkill
-#define SYS_time __NR_time
-#define SYS_timer_create __NR_timer_create
-#define SYS_timer_delete __NR_timer_delete
-#define SYS_timer_getoverrun __NR_timer_getoverrun
-#define SYS_timer_gettime __NR_timer_gettime
-#define SYS_timer_settime __NR_timer_settime
-#define SYS_timerfd_create __NR_timerfd_create
-#define SYS_timerfd_gettime __NR_timerfd_gettime
-#define SYS_timerfd_settime __NR_timerfd_settime
-#define SYS_times __NR_times
-#define SYS_tkill __NR_tkill
-#define SYS_truncate __NR_truncate
-#define SYS_truncate64 __NR_truncate64
-#define SYS_ugetrlimit __NR_ugetrlimit
-#define SYS_umask __NR_umask
-#define SYS_umount __NR_umount
-#define SYS_umount2 __NR_umount2
-#define SYS_uname __NR_uname
-#define SYS_unlink __NR_unlink
-#define SYS_unlinkat __NR_unlinkat
-#define SYS_unshare __NR_unshare
-#define SYS_uselib __NR_uselib
-#define SYS_userfaultfd __NR_userfaultfd
-#define SYS_ustat __NR_ustat
-#define SYS_utime __NR_utime
-#define SYS_utimensat __NR_utimensat
-#define SYS_utimes __NR_utimes
-#define SYS_vfork __NR_vfork
-#define SYS_vhangup __NR_vhangup
-#define SYS_vmsplice __NR_vmsplice
-#define SYS_vserver __NR_vserver
-#define SYS_wait4 __NR_wait4
-#define SYS_waitid __NR_waitid
-#define SYS_write __NR_write
-#define SYS_writev __NR_writev
-#elif defined(__mips__)
-#define SYS_accept __NR_accept
-#define SYS_accept4 __NR_accept4
-#define SYS_access __NR_access
-#define SYS_acct __NR_acct
-#define SYS_add_key __NR_add_key
-#define SYS_adjtimex __NR_adjtimex
-#define SYS_afs_syscall __NR_afs_syscall
-#define SYS_alarm __NR_alarm
-#define SYS_bdflush __NR_bdflush
-#define SYS_bind __NR_bind
-#define SYS_bpf __NR_bpf
-#define SYS_break __NR_break
-#define SYS_brk __NR_brk
-#define SYS_cachectl __NR_cachectl
-#define SYS_cacheflush __NR_cacheflush
-#define SYS_capget __NR_capget
-#define SYS_capset __NR_capset
-#define SYS_chdir __NR_chdir
-#define SYS_chmod __NR_chmod
-#define SYS_chown __NR_chown
-#define SYS_chroot __NR_chroot
-#define SYS_clock_adjtime __NR_clock_adjtime
-#define SYS_clock_getres __NR_clock_getres
-#define SYS_clock_gettime __NR_clock_gettime
-#define SYS_clock_nanosleep __NR_clock_nanosleep
-#define SYS_clock_settime __NR_clock_settime
-#define SYS_clone __NR_clone
-#define SYS_close __NR_close
-#define SYS_connect __NR_connect
-#define SYS_creat __NR_creat
-#define SYS_create_module __NR_create_module
-#define SYS_delete_module __NR_delete_module
-#define SYS_dup __NR_dup
-#define SYS_dup2 __NR_dup2
-#define SYS_dup3 __NR_dup3
-#define SYS_epoll_create __NR_epoll_create
-#define SYS_epoll_create1 __NR_epoll_create1
-#define SYS_epoll_ctl __NR_epoll_ctl
-#define SYS_epoll_pwait __NR_epoll_pwait
-#define SYS_epoll_wait __NR_epoll_wait
-#define SYS_eventfd __NR_eventfd
-#define SYS_eventfd2 __NR_eventfd2
-#define SYS_execve __NR_execve
-#define SYS_execveat __NR_execveat
-#define SYS_exit __NR_exit
-#define SYS_exit_group __NR_exit_group
-#define SYS_faccessat __NR_faccessat
-#define SYS_fadvise64 __NR_fadvise64
-#define SYS_fallocate __NR_fallocate
-#define SYS_fanotify_init __NR_fanotify_init
-#define SYS_fanotify_mark __NR_fanotify_mark
-#define SYS_fchdir __NR_fchdir
-#define SYS_fchmod __NR_fchmod
-#define SYS_fchmodat __NR_fchmodat
-#define SYS_fchown __NR_fchown
-#define SYS_fchownat __NR_fchownat
-#define SYS_fcntl __NR_fcntl
-#define SYS_fcntl64 __NR_fcntl64
-#define SYS_fdatasync __NR_fdatasync
-#define SYS_fgetxattr __NR_fgetxattr
-#define SYS_finit_module __NR_finit_module
-#define SYS_flistxattr __NR_flistxattr
-#define SYS_flock __NR_flock
-#define SYS_fork __NR_fork
-#define SYS_fremovexattr __NR_fremovexattr
-#define SYS_fsetxattr __NR_fsetxattr
-#define SYS_fstat __NR_fstat
-#define SYS_fstat64 __NR_fstat64
-#define SYS_fstatat64 __NR_fstatat64
-#define SYS_fstatfs __NR_fstatfs
-#define SYS_fstatfs64 __NR_fstatfs64
-#define SYS_fsync __NR_fsync
-#define SYS_ftime __NR_ftime
-#define SYS_ftruncate __NR_ftruncate
-#define SYS_ftruncate64 __NR_ftruncate64
-#define SYS_futex __NR_futex
-#define SYS_futimesat __NR_futimesat
-#define SYS_get_kernel_syms __NR_get_kernel_syms
-#define SYS_get_mempolicy __NR_get_mempolicy
-#define SYS_get_robust_list __NR_get_robust_list
-#define SYS_getcpu __NR_getcpu
-#define SYS_getcwd __NR_getcwd
-#define SYS_getdents __NR_getdents
-#define SYS_getdents64 __NR_getdents64
-#define SYS_getegid __NR_getegid
-#define SYS_geteuid __NR_geteuid
-#define SYS_getgid __NR_getgid
-#define SYS_getgroups __NR_getgroups
-#define SYS_getitimer __NR_getitimer
-#define SYS_getpeername __NR_getpeername
-#define SYS_getpgid __NR_getpgid
-#define SYS_getpgrp __NR_getpgrp
-#define SYS_getpid __NR_getpid
-#define SYS_getpmsg __NR_getpmsg
-#define SYS_getppid __NR_getppid
-#define SYS_getpriority __NR_getpriority
-#define SYS_getrandom __NR_getrandom
-#define SYS_getresgid __NR_getresgid
-#define SYS_getresuid __NR_getresuid
-#define SYS_getrlimit __NR_getrlimit
-#define SYS_getrusage __NR_getrusage
-#define SYS_getsid __NR_getsid
-#define SYS_getsockname __NR_getsockname
-#define SYS_getsockopt __NR_getsockopt
-#define SYS_gettid __NR_gettid
-#define SYS_gettimeofday __NR_gettimeofday
-#define SYS_getuid __NR_getuid
-#define SYS_getxattr __NR_getxattr
-#define SYS_gtty __NR_gtty
-#define SYS_idle __NR_idle
-#define SYS_init_module __NR_init_module
-#define SYS_inotify_add_watch __NR_inotify_add_watch
-#define SYS_inotify_init __NR_inotify_init
-#define SYS_inotify_init1 __NR_inotify_init1
-#define SYS_inotify_rm_watch __NR_inotify_rm_watch
-#define SYS_io_cancel __NR_io_cancel
-#define SYS_io_destroy __NR_io_destroy
-#define SYS_io_getevents __NR_io_getevents
-#define SYS_io_setup __NR_io_setup
-#define SYS_io_submit __NR_io_submit
-#define SYS_ioctl __NR_ioctl
-#define SYS_ioperm __NR_ioperm
-#define SYS_iopl __NR_iopl
-#define SYS_ioprio_get __NR_ioprio_get
-#define SYS_ioprio_set __NR_ioprio_set
-#define SYS_ipc __NR_ipc
-#define SYS_kcmp __NR_kcmp
-#define SYS_kexec_load __NR_kexec_load
-#define SYS_keyctl __NR_keyctl
-#define SYS_kill __NR_kill
-#define SYS_lchown __NR_lchown
-#define SYS_lgetxattr __NR_lgetxattr
-#define SYS_link __NR_link
-#define SYS_linkat __NR_linkat
-#define SYS_listen __NR_listen
-#define SYS_listxattr __NR_listxattr
-#define SYS_llistxattr __NR_llistxattr
-#define SYS_lock __NR_lock
-#define SYS_lookup_dcookie __NR_lookup_dcookie
-#define SYS_lremovexattr __NR_lremovexattr
-#define SYS_lseek __NR_lseek
-#define SYS_lsetxattr __NR_lsetxattr
-#define SYS_lstat __NR_lstat
-#define SYS_lstat64 __NR_lstat64
-#define SYS_madvise __NR_madvise
-#define SYS_mbind __NR_mbind
-#define SYS_membarrier __NR_membarrier
-#define SYS_memfd_create __NR_memfd_create
-#define SYS_migrate_pages __NR_migrate_pages
-#define SYS_mincore __NR_mincore
-#define SYS_mkdir __NR_mkdir
-#define SYS_mkdirat __NR_mkdirat
-#define SYS_mknod __NR_mknod
-#define SYS_mknodat __NR_mknodat
-#define SYS_mlock __NR_mlock
-#define SYS_mlock2 __NR_mlock2
-#define SYS_mlockall __NR_mlockall
-#define SYS_mmap __NR_mmap
-#define SYS_mmap2 __NR_mmap2
-#define SYS_modify_ldt __NR_modify_ldt
-#define SYS_mount __NR_mount
-#define SYS_move_pages __NR_move_pages
-#define SYS_mprotect __NR_mprotect
-#define SYS_mpx __NR_mpx
-#define SYS_mq_getsetattr __NR_mq_getsetattr
-#define SYS_mq_notify __NR_mq_notify
-#define SYS_mq_open __NR_mq_open
-#define SYS_mq_timedreceive __NR_mq_timedreceive
-#define SYS_mq_timedsend __NR_mq_timedsend
-#define SYS_mq_unlink __NR_mq_unlink
-#define SYS_mremap __NR_mremap
-#define SYS_msgctl __NR_msgctl
-#define SYS_msgget __NR_msgget
-#define SYS_msgrcv __NR_msgrcv
-#define SYS_msgsnd __NR_msgsnd
-#define SYS_msync __NR_msync
-#define SYS_munlock __NR_munlock
-#define SYS_munlockall __NR_munlockall
-#define SYS_munmap __NR_munmap
-#define SYS_name_to_handle_at __NR_name_to_handle_at
-#define SYS_nanosleep __NR_nanosleep
-#define SYS_newfstatat __NR_newfstatat
-#define SYS_nfsservctl __NR_nfsservctl
-#define SYS_nice __NR_nice
-#define SYS_open __NR_open
-#define SYS_open_by_handle_at __NR_open_by_handle_at
-#define SYS_openat __NR_openat
-#define SYS_pause __NR_pause
-#define SYS_perf_event_open __NR_perf_event_open
-#define SYS_personality __NR_personality
-#define SYS_pipe __NR_pipe
-#define SYS_pipe2 __NR_pipe2
-#define SYS_pivot_root __NR_pivot_root
-#define SYS_poll __NR_poll
-#define SYS_ppoll __NR_ppoll
-#define SYS_prctl __NR_prctl
-#define SYS_pread64 __NR_pread64
-#define SYS_preadv __NR_preadv
-#define SYS_prlimit64 __NR_prlimit64
-#define SYS_process_vm_readv __NR_process_vm_readv
-#define SYS_process_vm_writev __NR_process_vm_writev
-#define SYS_prof __NR_prof
-#define SYS_profil __NR_profil
-#define SYS_pselect6 __NR_pselect6
-#define SYS_ptrace __NR_ptrace
-#define SYS_putpmsg __NR_putpmsg
-#define SYS_pwrite64 __NR_pwrite64
-#define SYS_pwritev __NR_pwritev
-#define SYS_query_module __NR_query_module
-#define SYS_quotactl __NR_quotactl
-#define SYS_read __NR_read
-#define SYS_readahead __NR_readahead
-#define SYS_readdir __NR_readdir
-#define SYS_readlink __NR_readlink
-#define SYS_readlinkat __NR_readlinkat
-#define SYS_readv __NR_readv
-#define SYS_reboot __NR_reboot
-#define SYS_recv __NR_recv
-#define SYS_recvfrom __NR_recvfrom
-#define SYS_recvmmsg __NR_recvmmsg
-#define SYS_recvmsg __NR_recvmsg
-#define SYS_remap_file_pages __NR_remap_file_pages
-#define SYS_removexattr __NR_removexattr
-#define SYS_rename __NR_rename
-#define SYS_renameat __NR_renameat
-#define SYS_renameat2 __NR_renameat2
-#define SYS_request_key __NR_request_key
-#define SYS_reserved177 __NR_reserved177
-#define SYS_reserved193 __NR_reserved193
-#define SYS_reserved221 __NR_reserved221
-#define SYS_reserved82 __NR_reserved82
-#define SYS_restart_syscall __NR_restart_syscall
-#define SYS_rmdir __NR_rmdir
-#define SYS_rt_sigaction __NR_rt_sigaction
-#define SYS_rt_sigpending __NR_rt_sigpending
-#define SYS_rt_sigprocmask __NR_rt_sigprocmask
-#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
-#define SYS_rt_sigreturn __NR_rt_sigreturn
-#define SYS_rt_sigsuspend __NR_rt_sigsuspend
-#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
-#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
-#define SYS_sched_get_priority_max __NR_sched_get_priority_max
-#define SYS_sched_get_priority_min __NR_sched_get_priority_min
-#define SYS_sched_getaffinity __NR_sched_getaffinity
-#define SYS_sched_getattr __NR_sched_getattr
-#define SYS_sched_getparam __NR_sched_getparam
-#define SYS_sched_getscheduler __NR_sched_getscheduler
-#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
-#define SYS_sched_setaffinity __NR_sched_setaffinity
-#define SYS_sched_setattr __NR_sched_setattr
-#define SYS_sched_setparam __NR_sched_setparam
-#define SYS_sched_setscheduler __NR_sched_setscheduler
-#define SYS_sched_yield __NR_sched_yield
-#define SYS_seccomp __NR_seccomp
-#define SYS_semctl __NR_semctl
-#define SYS_semget __NR_semget
-#define SYS_semop __NR_semop
-#define SYS_semtimedop __NR_semtimedop
-#define SYS_send __NR_send
-#define SYS_sendfile __NR_sendfile
-#define SYS_sendfile64 __NR_sendfile64
-#define SYS_sendmmsg __NR_sendmmsg
-#define SYS_sendmsg __NR_sendmsg
-#define SYS_sendto __NR_sendto
-#define SYS_set_mempolicy __NR_set_mempolicy
-#define SYS_set_robust_list __NR_set_robust_list
-#define SYS_set_thread_area __NR_set_thread_area
-#define SYS_set_tid_address __NR_set_tid_address
-#define SYS_setdomainname __NR_setdomainname
-#define SYS_setfsgid __NR_setfsgid
-#define SYS_setfsuid __NR_setfsuid
-#define SYS_setgid __NR_setgid
-#define SYS_setgroups __NR_setgroups
-#define SYS_sethostname __NR_sethostname
-#define SYS_setitimer __NR_setitimer
-#define SYS_setns __NR_setns
-#define SYS_setpgid __NR_setpgid
-#define SYS_setpriority __NR_setpriority
-#define SYS_setregid __NR_setregid
-#define SYS_setresgid __NR_setresgid
-#define SYS_setresuid __NR_setresuid
-#define SYS_setreuid __NR_setreuid
-#define SYS_setrlimit __NR_setrlimit
-#define SYS_setsid __NR_setsid
-#define SYS_setsockopt __NR_setsockopt
-#define SYS_settimeofday __NR_settimeofday
-#define SYS_setuid __NR_setuid
-#define SYS_setxattr __NR_setxattr
-#define SYS_sgetmask __NR_sgetmask
-#define SYS_shmat __NR_shmat
-#define SYS_shmctl __NR_shmctl
-#define SYS_shmdt __NR_shmdt
-#define SYS_shmget __NR_shmget
-#define SYS_shutdown __NR_shutdown
-#define SYS_sigaction __NR_sigaction
-#define SYS_sigaltstack __NR_sigaltstack
-#define SYS_signal __NR_signal
-#define SYS_signalfd __NR_signalfd
-#define SYS_signalfd4 __NR_signalfd4
-#define SYS_sigpending __NR_sigpending
-#define SYS_sigprocmask __NR_sigprocmask
-#define SYS_sigreturn __NR_sigreturn
-#define SYS_sigsuspend __NR_sigsuspend
-#define SYS_socket __NR_socket
-#define SYS_socketcall __NR_socketcall
-#define SYS_socketpair __NR_socketpair
-#define SYS_splice __NR_splice
-#define SYS_ssetmask __NR_ssetmask
-#define SYS_stat __NR_stat
-#define SYS_stat64 __NR_stat64
-#define SYS_statfs __NR_statfs
-#define SYS_statfs64 __NR_statfs64
-#define SYS_stime __NR_stime
-#define SYS_stty __NR_stty
-#define SYS_swapoff __NR_swapoff
-#define SYS_swapon __NR_swapon
-#define SYS_symlink __NR_symlink
-#define SYS_symlinkat __NR_symlinkat
-#define SYS_sync __NR_sync
-#define SYS_sync_file_range __NR_sync_file_range
-#define SYS_syncfs __NR_syncfs
-#define SYS_syscall __NR_syscall
-#define SYS_sysfs __NR_sysfs
-#define SYS_sysinfo __NR_sysinfo
-#define SYS_syslog __NR_syslog
-#define SYS_sysmips __NR_sysmips
-#define SYS_tee __NR_tee
-#define SYS_tgkill __NR_tgkill
-#define SYS_time __NR_time
-#define SYS_timer_create __NR_timer_create
-#define SYS_timer_delete __NR_timer_delete
-#define SYS_timer_getoverrun __NR_timer_getoverrun
-#define SYS_timer_gettime __NR_timer_gettime
-#define SYS_timer_settime __NR_timer_settime
-#define SYS_timerfd __NR_timerfd
-#define SYS_timerfd_create __NR_timerfd_create
-#define SYS_timerfd_gettime __NR_timerfd_gettime
-#define SYS_timerfd_settime __NR_timerfd_settime
-#define SYS_times __NR_times
-#define SYS_tkill __NR_tkill
-#define SYS_truncate __NR_truncate
-#define SYS_truncate64 __NR_truncate64
-#define SYS_ulimit __NR_ulimit
-#define SYS_umask __NR_umask
-#define SYS_umount __NR_umount
-#define SYS_umount2 __NR_umount2
-#define SYS_uname __NR_uname
-#define SYS_unlink __NR_unlink
-#define SYS_unlinkat __NR_unlinkat
-#define SYS_unshare __NR_unshare
-#define SYS_unused109 __NR_unused109
-#define SYS_unused150 __NR_unused150
-#define SYS_unused18 __NR_unused18
-#define SYS_unused28 __NR_unused28
-#define SYS_unused59 __NR_unused59
-#define SYS_unused84 __NR_unused84
-#define SYS_uselib __NR_uselib
-#define SYS_userfaultfd __NR_userfaultfd
-#define SYS_ustat __NR_ustat
-#define SYS_utime __NR_utime
-#define SYS_utimensat __NR_utimensat
-#define SYS_utimes __NR_utimes
-#define SYS_vhangup __NR_vhangup
-#define SYS_vm86 __NR_vm86
-#define SYS_vmsplice __NR_vmsplice
-#define SYS_vserver __NR_vserver
-#define SYS_wait4 __NR_wait4
-#define SYS_waitid __NR_waitid
-#define SYS_waitpid __NR_waitpid
-#define SYS_write __NR_write
-#define SYS_writev __NR_writev
-#elif defined(__i386__)
-#define SYS_accept4 __NR_accept4
-#define SYS_access __NR_access
-#define SYS_acct __NR_acct
-#define SYS_add_key __NR_add_key
-#define SYS_adjtimex __NR_adjtimex
-#define SYS_afs_syscall __NR_afs_syscall
-#define SYS_alarm __NR_alarm
-#define SYS_bdflush __NR_bdflush
-#define SYS_bind __NR_bind
-#define SYS_bpf __NR_bpf
-#define SYS_break __NR_break
-#define SYS_brk __NR_brk
-#define SYS_capget __NR_capget
-#define SYS_capset __NR_capset
-#define SYS_chdir __NR_chdir
-#define SYS_chmod __NR_chmod
-#define SYS_chown __NR_chown
-#define SYS_chown32 __NR_chown32
-#define SYS_chroot __NR_chroot
-#define SYS_clock_adjtime __NR_clock_adjtime
-#define SYS_clock_getres __NR_clock_getres
-#define SYS_clock_gettime __NR_clock_gettime
-#define SYS_clock_nanosleep __NR_clock_nanosleep
-#define SYS_clock_settime __NR_clock_settime
-#define SYS_clone __NR_clone
-#define SYS_close __NR_close
-#define SYS_connect __NR_connect
-#define SYS_creat __NR_creat
-#define SYS_create_module __NR_create_module
-#define SYS_delete_module __NR_delete_module
-#define SYS_dup __NR_dup
-#define SYS_dup2 __NR_dup2
-#define SYS_dup3 __NR_dup3
-#define SYS_epoll_create __NR_epoll_create
-#define SYS_epoll_create1 __NR_epoll_create1
-#define SYS_epoll_ctl __NR_epoll_ctl
-#define SYS_epoll_pwait __NR_epoll_pwait
-#define SYS_epoll_wait __NR_epoll_wait
-#define SYS_eventfd __NR_eventfd
-#define SYS_eventfd2 __NR_eventfd2
-#define SYS_execve __NR_execve
-#define SYS_execveat __NR_execveat
-#define SYS_exit __NR_exit
-#define SYS_exit_group __NR_exit_group
-#define SYS_faccessat __NR_faccessat
-#define SYS_fadvise64 __NR_fadvise64
-#define SYS_fadvise64_64 __NR_fadvise64_64
-#define SYS_fallocate __NR_fallocate
-#define SYS_fanotify_init __NR_fanotify_init
-#define SYS_fanotify_mark __NR_fanotify_mark
-#define SYS_fchdir __NR_fchdir
-#define SYS_fchmod __NR_fchmod
-#define SYS_fchmodat __NR_fchmodat
-#define SYS_fchown __NR_fchown
-#define SYS_fchown32 __NR_fchown32
-#define SYS_fchownat __NR_fchownat
-#define SYS_fcntl __NR_fcntl
-#define SYS_fcntl64 __NR_fcntl64
-#define SYS_fdatasync __NR_fdatasync
-#define SYS_fgetxattr __NR_fgetxattr
-#define SYS_finit_module __NR_finit_module
-#define SYS_flistxattr __NR_flistxattr
-#define SYS_flock __NR_flock
-#define SYS_fork __NR_fork
-#define SYS_fremovexattr __NR_fremovexattr
-#define SYS_fsetxattr __NR_fsetxattr
-#define SYS_fstat __NR_fstat
-#define SYS_fstat64 __NR_fstat64
-#define SYS_fstatat64 __NR_fstatat64
-#define SYS_fstatfs __NR_fstatfs
-#define SYS_fstatfs64 __NR_fstatfs64
-#define SYS_fsync __NR_fsync
-#define SYS_ftime __NR_ftime
-#define SYS_ftruncate __NR_ftruncate
-#define SYS_ftruncate64 __NR_ftruncate64
-#define SYS_futex __NR_futex
-#define SYS_futimesat __NR_futimesat
-#define SYS_get_kernel_syms __NR_get_kernel_syms
-#define SYS_get_mempolicy __NR_get_mempolicy
-#define SYS_get_robust_list __NR_get_robust_list
-#define SYS_get_thread_area __NR_get_thread_area
-#define SYS_getcpu __NR_getcpu
-#define SYS_getcwd __NR_getcwd
-#define SYS_getdents __NR_getdents
-#define SYS_getdents64 __NR_getdents64
-#define SYS_getegid __NR_getegid
-#define SYS_getegid32 __NR_getegid32
-#define SYS_geteuid __NR_geteuid
-#define SYS_geteuid32 __NR_geteuid32
-#define SYS_getgid __NR_getgid
-#define SYS_getgid32 __NR_getgid32
-#define SYS_getgroups __NR_getgroups
-#define SYS_getgroups32 __NR_getgroups32
-#define SYS_getitimer __NR_getitimer
-#define SYS_getpeername __NR_getpeername
-#define SYS_getpgid __NR_getpgid
-#define SYS_getpgrp __NR_getpgrp
-#define SYS_getpid __NR_getpid
-#define SYS_getpmsg __NR_getpmsg
-#define SYS_getppid __NR_getppid
-#define SYS_getpriority __NR_getpriority
-#define SYS_getrandom __NR_getrandom
-#define SYS_getresgid __NR_getresgid
-#define SYS_getresgid32 __NR_getresgid32
-#define SYS_getresuid __NR_getresuid
-#define SYS_getresuid32 __NR_getresuid32
-#define SYS_getrlimit __NR_getrlimit
-#define SYS_getrusage __NR_getrusage
-#define SYS_getsid __NR_getsid
-#define SYS_getsockname __NR_getsockname
-#define SYS_getsockopt __NR_getsockopt
-#define SYS_gettid __NR_gettid
-#define SYS_gettimeofday __NR_gettimeofday
-#define SYS_getuid __NR_getuid
-#define SYS_getuid32 __NR_getuid32
-#define SYS_getxattr __NR_getxattr
-#define SYS_gtty __NR_gtty
-#define SYS_idle __NR_idle
-#define SYS_init_module __NR_init_module
-#define SYS_inotify_add_watch __NR_inotify_add_watch
-#define SYS_inotify_init __NR_inotify_init
-#define SYS_inotify_init1 __NR_inotify_init1
-#define SYS_inotify_rm_watch __NR_inotify_rm_watch
-#define SYS_io_cancel __NR_io_cancel
-#define SYS_io_destroy __NR_io_destroy
-#define SYS_io_getevents __NR_io_getevents
-#define SYS_io_setup __NR_io_setup
-#define SYS_io_submit __NR_io_submit
-#define SYS_ioctl __NR_ioctl
-#define SYS_ioperm __NR_ioperm
-#define SYS_iopl __NR_iopl
-#define SYS_ioprio_get __NR_ioprio_get
-#define SYS_ioprio_set __NR_ioprio_set
-#define SYS_ipc __NR_ipc
-#define SYS_kcmp __NR_kcmp
-#define SYS_kexec_load __NR_kexec_load
-#define SYS_keyctl __NR_keyctl
-#define SYS_kill __NR_kill
-#define SYS_lchown __NR_lchown
-#define SYS_lchown32 __NR_lchown32
-#define SYS_lgetxattr __NR_lgetxattr
-#define SYS_link __NR_link
-#define SYS_linkat __NR_linkat
-#define SYS_listen __NR_listen
-#define SYS_listxattr __NR_listxattr
-#define SYS_llistxattr __NR_llistxattr
-#define SYS_lock __NR_lock
-#define SYS_lookup_dcookie __NR_lookup_dcookie
-#define SYS_lremovexattr __NR_lremovexattr
-#define SYS_lseek __NR_lseek
-#define SYS_lsetxattr __NR_lsetxattr
-#define SYS_lstat __NR_lstat
-#define SYS_lstat64 __NR_lstat64
-#define SYS_madvise __NR_madvise
-#define SYS_mbind __NR_mbind
-#define SYS_membarrier __NR_membarrier
-#define SYS_memfd_create __NR_memfd_create
-#define SYS_migrate_pages __NR_migrate_pages
-#define SYS_mincore __NR_mincore
-#define SYS_mkdir __NR_mkdir
-#define SYS_mkdirat __NR_mkdirat
-#define SYS_mknod __NR_mknod
-#define SYS_mknodat __NR_mknodat
-#define SYS_mlock __NR_mlock
-#define SYS_mlock2 __NR_mlock2
-#define SYS_mlockall __NR_mlockall
-#define SYS_mmap __NR_mmap
-#define SYS_mmap2 __NR_mmap2
-#define SYS_modify_ldt __NR_modify_ldt
-#define SYS_mount __NR_mount
-#define SYS_move_pages __NR_move_pages
-#define SYS_mprotect __NR_mprotect
-#define SYS_mpx __NR_mpx
-#define SYS_mq_getsetattr __NR_mq_getsetattr
-#define SYS_mq_notify __NR_mq_notify
-#define SYS_mq_open __NR_mq_open
-#define SYS_mq_timedreceive __NR_mq_timedreceive
-#define SYS_mq_timedsend __NR_mq_timedsend
-#define SYS_mq_unlink __NR_mq_unlink
-#define SYS_mremap __NR_mremap
-#define SYS_msync __NR_msync
-#define SYS_munlock __NR_munlock
-#define SYS_munlockall __NR_munlockall
-#define SYS_munmap __NR_munmap
-#define SYS_name_to_handle_at __NR_name_to_handle_at
-#define SYS_nanosleep __NR_nanosleep
-#define SYS_nfsservctl __NR_nfsservctl
-#define SYS_nice __NR_nice
-#define SYS_oldfstat __NR_oldfstat
-#define SYS_oldlstat __NR_oldlstat
-#define SYS_oldolduname __NR_oldolduname
-#define SYS_oldstat __NR_oldstat
-#define SYS_olduname __NR_olduname
-#define SYS_open __NR_open
-#define SYS_open_by_handle_at __NR_open_by_handle_at
-#define SYS_openat __NR_openat
-#define SYS_pause __NR_pause
-#define SYS_perf_event_open __NR_perf_event_open
-#define SYS_personality __NR_personality
-#define SYS_pipe __NR_pipe
-#define SYS_pipe2 __NR_pipe2
-#define SYS_pivot_root __NR_pivot_root
-#define SYS_poll __NR_poll
-#define SYS_ppoll __NR_ppoll
-#define SYS_prctl __NR_prctl
-#define SYS_pread64 __NR_pread64
-#define SYS_preadv __NR_preadv
-#define SYS_prlimit64 __NR_prlimit64
-#define SYS_process_vm_readv __NR_process_vm_readv
-#define SYS_process_vm_writev __NR_process_vm_writev
-#define SYS_prof __NR_prof
-#define SYS_profil __NR_profil
-#define SYS_pselect6 __NR_pselect6
-#define SYS_ptrace __NR_ptrace
-#define SYS_putpmsg __NR_putpmsg
-#define SYS_pwrite64 __NR_pwrite64
-#define SYS_pwritev __NR_pwritev
-#define SYS_query_module __NR_query_module
-#define SYS_quotactl __NR_quotactl
-#define SYS_read __NR_read
-#define SYS_readahead __NR_readahead
-#define SYS_readdir __NR_readdir
-#define SYS_readlink __NR_readlink
-#define SYS_readlinkat __NR_readlinkat
-#define SYS_readv __NR_readv
-#define SYS_reboot __NR_reboot
-#define SYS_recvfrom __NR_recvfrom
-#define SYS_recvmmsg __NR_recvmmsg
-#define SYS_recvmsg __NR_recvmsg
-#define SYS_remap_file_pages __NR_remap_file_pages
-#define SYS_removexattr __NR_removexattr
-#define SYS_rename __NR_rename
-#define SYS_renameat __NR_renameat
-#define SYS_renameat2 __NR_renameat2
-#define SYS_request_key __NR_request_key
-#define SYS_restart_syscall __NR_restart_syscall
-#define SYS_rmdir __NR_rmdir
-#define SYS_rt_sigaction __NR_rt_sigaction
-#define SYS_rt_sigpending __NR_rt_sigpending
-#define SYS_rt_sigprocmask __NR_rt_sigprocmask
-#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
-#define SYS_rt_sigreturn __NR_rt_sigreturn
-#define SYS_rt_sigsuspend __NR_rt_sigsuspend
-#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
-#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
-#define SYS_sched_get_priority_max __NR_sched_get_priority_max
-#define SYS_sched_get_priority_min __NR_sched_get_priority_min
-#define SYS_sched_getaffinity __NR_sched_getaffinity
-#define SYS_sched_getattr __NR_sched_getattr
-#define SYS_sched_getparam __NR_sched_getparam
-#define SYS_sched_getscheduler __NR_sched_getscheduler
-#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
-#define SYS_sched_setaffinity __NR_sched_setaffinity
-#define SYS_sched_setattr __NR_sched_setattr
-#define SYS_sched_setparam __NR_sched_setparam
-#define SYS_sched_setscheduler __NR_sched_setscheduler
-#define SYS_sched_yield __NR_sched_yield
-#define SYS_seccomp __NR_seccomp
-#define SYS_select __NR_select
-#define SYS_sendfile __NR_sendfile
-#define SYS_sendfile64 __NR_sendfile64
-#define SYS_sendmmsg __NR_sendmmsg
-#define SYS_sendmsg __NR_sendmsg
-#define SYS_sendto __NR_sendto
-#define SYS_set_mempolicy __NR_set_mempolicy
-#define SYS_set_robust_list __NR_set_robust_list
-#define SYS_set_thread_area __NR_set_thread_area
-#define SYS_set_tid_address __NR_set_tid_address
-#define SYS_setdomainname __NR_setdomainname
-#define SYS_setfsgid __NR_setfsgid
-#define SYS_setfsgid32 __NR_setfsgid32
-#define SYS_setfsuid __NR_setfsuid
-#define SYS_setfsuid32 __NR_setfsuid32
-#define SYS_setgid __NR_setgid
-#define SYS_setgid32 __NR_setgid32
-#define SYS_setgroups __NR_setgroups
-#define SYS_setgroups32 __NR_setgroups32
-#define SYS_sethostname __NR_sethostname
-#define SYS_setitimer __NR_setitimer
-#define SYS_setns __NR_setns
-#define SYS_setpgid __NR_setpgid
-#define SYS_setpriority __NR_setpriority
-#define SYS_setregid __NR_setregid
-#define SYS_setregid32 __NR_setregid32
-#define SYS_setresgid __NR_setresgid
-#define SYS_setresgid32 __NR_setresgid32
-#define SYS_setresuid __NR_setresuid
-#define SYS_setresuid32 __NR_setresuid32
-#define SYS_setreuid __NR_setreuid
-#define SYS_setreuid32 __NR_setreuid32
-#define SYS_setrlimit __NR_setrlimit
-#define SYS_setsid __NR_setsid
-#define SYS_setsockopt __NR_setsockopt
-#define SYS_settimeofday __NR_settimeofday
-#define SYS_setuid __NR_setuid
-#define SYS_setuid32 __NR_setuid32
-#define SYS_setxattr __NR_setxattr
-#define SYS_sgetmask __NR_sgetmask
-#define SYS_shutdown __NR_shutdown
-#define SYS_sigaction __NR_sigaction
-#define SYS_sigaltstack __NR_sigaltstack
-#define SYS_signal __NR_signal
-#define SYS_signalfd __NR_signalfd
-#define SYS_signalfd4 __NR_signalfd4
-#define SYS_sigpending __NR_sigpending
-#define SYS_sigprocmask __NR_sigprocmask
-#define SYS_sigreturn __NR_sigreturn
-#define SYS_sigsuspend __NR_sigsuspend
-#define SYS_socket __NR_socket
-#define SYS_socketcall __NR_socketcall
-#define SYS_socketpair __NR_socketpair
-#define SYS_splice __NR_splice
-#define SYS_ssetmask __NR_ssetmask
-#define SYS_stat __NR_stat
-#define SYS_stat64 __NR_stat64
-#define SYS_statfs __NR_statfs
-#define SYS_statfs64 __NR_statfs64
-#define SYS_stime __NR_stime
-#define SYS_stty __NR_stty
-#define SYS_swapoff __NR_swapoff
-#define SYS_swapon __NR_swapon
-#define SYS_symlink __NR_symlink
-#define SYS_symlinkat __NR_symlinkat
-#define SYS_sync __NR_sync
-#define SYS_sync_file_range __NR_sync_file_range
-#define SYS_syncfs __NR_syncfs
-#define SYS_sysfs __NR_sysfs
-#define SYS_sysinfo __NR_sysinfo
-#define SYS_syslog __NR_syslog
-#define SYS_tee __NR_tee
-#define SYS_tgkill __NR_tgkill
-#define SYS_time __NR_time
-#define SYS_timer_create __NR_timer_create
-#define SYS_timer_delete __NR_timer_delete
-#define SYS_timer_getoverrun __NR_timer_getoverrun
-#define SYS_timer_gettime __NR_timer_gettime
-#define SYS_timer_settime __NR_timer_settime
-#define SYS_timerfd_create __NR_timerfd_create
-#define SYS_timerfd_gettime __NR_timerfd_gettime
-#define SYS_timerfd_settime __NR_timerfd_settime
-#define SYS_times __NR_times
-#define SYS_tkill __NR_tkill
-#define SYS_truncate __NR_truncate
-#define SYS_truncate64 __NR_truncate64
-#define SYS_ugetrlimit __NR_ugetrlimit
-#define SYS_ulimit __NR_ulimit
-#define SYS_umask __NR_umask
-#define SYS_umount __NR_umount
-#define SYS_umount2 __NR_umount2
-#define SYS_uname __NR_uname
-#define SYS_unlink __NR_unlink
-#define SYS_unlinkat __NR_unlinkat
-#define SYS_unshare __NR_unshare
-#define SYS_uselib __NR_uselib
-#define SYS_userfaultfd __NR_userfaultfd
-#define SYS_ustat __NR_ustat
-#define SYS_utime __NR_utime
-#define SYS_utimensat __NR_utimensat
-#define SYS_utimes __NR_utimes
-#define SYS_vfork __NR_vfork
-#define SYS_vhangup __NR_vhangup
-#define SYS_vm86 __NR_vm86
-#define SYS_vm86old __NR_vm86old
-#define SYS_vmsplice __NR_vmsplice
-#define SYS_vserver __NR_vserver
-#define SYS_wait4 __NR_wait4
-#define SYS_waitid __NR_waitid
-#define SYS_waitpid __NR_waitpid
-#define SYS_write __NR_write
-#define SYS_writev __NR_writev
-#elif defined(__x86_64__)
-#define SYS_accept __NR_accept
-#define SYS_accept4 __NR_accept4
-#define SYS_access __NR_access
-#define SYS_acct __NR_acct
-#define SYS_add_key __NR_add_key
-#define SYS_adjtimex __NR_adjtimex
-#define SYS_afs_syscall __NR_afs_syscall
-#define SYS_alarm __NR_alarm
-#define SYS_arch_prctl __NR_arch_prctl
-#define SYS_bind __NR_bind
-#define SYS_bpf __NR_bpf
-#define SYS_brk __NR_brk
-#define SYS_capget __NR_capget
-#define SYS_capset __NR_capset
-#define SYS_chdir __NR_chdir
-#define SYS_chmod __NR_chmod
-#define SYS_chown __NR_chown
-#define SYS_chroot __NR_chroot
-#define SYS_clock_adjtime __NR_clock_adjtime
-#define SYS_clock_getres __NR_clock_getres
-#define SYS_clock_gettime __NR_clock_gettime
-#define SYS_clock_nanosleep __NR_clock_nanosleep
-#define SYS_clock_settime __NR_clock_settime
-#define SYS_clone __NR_clone
-#define SYS_close __NR_close
-#define SYS_connect __NR_connect
-#define SYS_creat __NR_creat
-#define SYS_create_module __NR_create_module
-#define SYS_delete_module __NR_delete_module
-#define SYS_dup __NR_dup
-#define SYS_dup2 __NR_dup2
-#define SYS_dup3 __NR_dup3
-#define SYS_epoll_create __NR_epoll_create
-#define SYS_epoll_create1 __NR_epoll_create1
-#define SYS_epoll_ctl __NR_epoll_ctl
-#define SYS_epoll_ctl_old __NR_epoll_ctl_old
-#define SYS_epoll_pwait __NR_epoll_pwait
-#define SYS_epoll_wait __NR_epoll_wait
-#define SYS_epoll_wait_old __NR_epoll_wait_old
-#define SYS_eventfd __NR_eventfd
-#define SYS_eventfd2 __NR_eventfd2
-#define SYS_execve __NR_execve
-#define SYS_execveat __NR_execveat
-#define SYS_exit __NR_exit
-#define SYS_exit_group __NR_exit_group
-#define SYS_faccessat __NR_faccessat
-#define SYS_fadvise64 __NR_fadvise64
-#define SYS_fallocate __NR_fallocate
-#define SYS_fanotify_init __NR_fanotify_init
-#define SYS_fanotify_mark __NR_fanotify_mark
-#define SYS_fchdir __NR_fchdir
-#define SYS_fchmod __NR_fchmod
-#define SYS_fchmodat __NR_fchmodat
-#define SYS_fchown __NR_fchown
-#define SYS_fchownat __NR_fchownat
-#define SYS_fcntl __NR_fcntl
-#define SYS_fdatasync __NR_fdatasync
-#define SYS_fgetxattr __NR_fgetxattr
-#define SYS_finit_module __NR_finit_module
-#define SYS_flistxattr __NR_flistxattr
-#define SYS_flock __NR_flock
-#define SYS_fork __NR_fork
-#define SYS_fremovexattr __NR_fremovexattr
-#define SYS_fsetxattr __NR_fsetxattr
-#define SYS_fstat __NR_fstat
-#define SYS_fstatfs __NR_fstatfs
-#define SYS_fsync __NR_fsync
-#define SYS_ftruncate __NR_ftruncate
-#define SYS_futex __NR_futex
-#define SYS_futimesat __NR_futimesat
-#define SYS_get_kernel_syms __NR_get_kernel_syms
-#define SYS_get_mempolicy __NR_get_mempolicy
-#define SYS_get_robust_list __NR_get_robust_list
-#define SYS_get_thread_area __NR_get_thread_area
-#define SYS_getcpu __NR_getcpu
-#define SYS_getcwd __NR_getcwd
-#define SYS_getdents __NR_getdents
-#define SYS_getdents64 __NR_getdents64
-#define SYS_getegid __NR_getegid
-#define SYS_geteuid __NR_geteuid
-#define SYS_getgid __NR_getgid
-#define SYS_getgroups __NR_getgroups
-#define SYS_getitimer __NR_getitimer
-#define SYS_getpeername __NR_getpeername
-#define SYS_getpgid __NR_getpgid
-#define SYS_getpgrp __NR_getpgrp
-#define SYS_getpid __NR_getpid
-#define SYS_getpmsg __NR_getpmsg
-#define SYS_getppid __NR_getppid
-#define SYS_getpriority __NR_getpriority
-#define SYS_getrandom __NR_getrandom
-#define SYS_getresgid __NR_getresgid
-#define SYS_getresuid __NR_getresuid
-#define SYS_getrlimit __NR_getrlimit
-#define SYS_getrusage __NR_getrusage
-#define SYS_getsid __NR_getsid
-#define SYS_getsockname __NR_getsockname
-#define SYS_getsockopt __NR_getsockopt
-#define SYS_gettid __NR_gettid
-#define SYS_gettimeofday __NR_gettimeofday
-#define SYS_getuid __NR_getuid
-#define SYS_getxattr __NR_getxattr
-#define SYS_init_module __NR_init_module
-#define SYS_inotify_add_watch __NR_inotify_add_watch
-#define SYS_inotify_init __NR_inotify_init
-#define SYS_inotify_init1 __NR_inotify_init1
-#define SYS_inotify_rm_watch __NR_inotify_rm_watch
-#define SYS_io_cancel __NR_io_cancel
-#define SYS_io_destroy __NR_io_destroy
-#define SYS_io_getevents __NR_io_getevents
-#define SYS_io_setup __NR_io_setup
-#define SYS_io_submit __NR_io_submit
-#define SYS_ioctl __NR_ioctl
-#define SYS_ioperm __NR_ioperm
-#define SYS_iopl __NR_iopl
-#define SYS_ioprio_get __NR_ioprio_get
-#define SYS_ioprio_set __NR_ioprio_set
-#define SYS_kcmp __NR_kcmp
-#define SYS_kexec_file_load __NR_kexec_file_load
-#define SYS_kexec_load __NR_kexec_load
-#define SYS_keyctl __NR_keyctl
-#define SYS_kill __NR_kill
-#define SYS_lchown __NR_lchown
-#define SYS_lgetxattr __NR_lgetxattr
-#define SYS_link __NR_link
-#define SYS_linkat __NR_linkat
-#define SYS_listen __NR_listen
-#define SYS_listxattr __NR_listxattr
-#define SYS_llistxattr __NR_llistxattr
-#define SYS_lookup_dcookie __NR_lookup_dcookie
-#define SYS_lremovexattr __NR_lremovexattr
-#define SYS_lseek __NR_lseek
-#define SYS_lsetxattr __NR_lsetxattr
-#define SYS_lstat __NR_lstat
-#define SYS_madvise __NR_madvise
-#define SYS_mbind __NR_mbind
-#define SYS_membarrier __NR_membarrier
-#define SYS_memfd_create __NR_memfd_create
-#define SYS_migrate_pages __NR_migrate_pages
-#define SYS_mincore __NR_mincore
-#define SYS_mkdir __NR_mkdir
-#define SYS_mkdirat __NR_mkdirat
-#define SYS_mknod __NR_mknod
-#define SYS_mknodat __NR_mknodat
-#define SYS_mlock __NR_mlock
-#define SYS_mlock2 __NR_mlock2
-#define SYS_mlockall __NR_mlockall
-#define SYS_mmap __NR_mmap
-#define SYS_modify_ldt __NR_modify_ldt
-#define SYS_mount __NR_mount
-#define SYS_move_pages __NR_move_pages
-#define SYS_mprotect __NR_mprotect
-#define SYS_mq_getsetattr __NR_mq_getsetattr
-#define SYS_mq_notify __NR_mq_notify
-#define SYS_mq_open __NR_mq_open
-#define SYS_mq_timedreceive __NR_mq_timedreceive
-#define SYS_mq_timedsend __NR_mq_timedsend
-#define SYS_mq_unlink __NR_mq_unlink
-#define SYS_mremap __NR_mremap
-#define SYS_msgctl __NR_msgctl
-#define SYS_msgget __NR_msgget
-#define SYS_msgrcv __NR_msgrcv
-#define SYS_msgsnd __NR_msgsnd
-#define SYS_msync __NR_msync
-#define SYS_munlock __NR_munlock
-#define SYS_munlockall __NR_munlockall
-#define SYS_munmap __NR_munmap
-#define SYS_name_to_handle_at __NR_name_to_handle_at
-#define SYS_nanosleep __NR_nanosleep
-#define SYS_newfstatat __NR_newfstatat
-#define SYS_nfsservctl __NR_nfsservctl
-#define SYS_open __NR_open
-#define SYS_open_by_handle_at __NR_open_by_handle_at
-#define SYS_openat __NR_openat
-#define SYS_pause __NR_pause
-#define SYS_perf_event_open __NR_perf_event_open
-#define SYS_personality __NR_personality
-#define SYS_pipe __NR_pipe
-#define SYS_pipe2 __NR_pipe2
-#define SYS_pivot_root __NR_pivot_root
-#define SYS_poll __NR_poll
-#define SYS_ppoll __NR_ppoll
-#define SYS_prctl __NR_prctl
-#define SYS_pread64 __NR_pread64
-#define SYS_preadv __NR_preadv
-#define SYS_prlimit64 __NR_prlimit64
-#define SYS_process_vm_readv __NR_process_vm_readv
-#define SYS_process_vm_writev __NR_process_vm_writev
-#define SYS_pselect6 __NR_pselect6
-#define SYS_ptrace __NR_ptrace
-#define SYS_putpmsg __NR_putpmsg
-#define SYS_pwrite64 __NR_pwrite64
-#define SYS_pwritev __NR_pwritev
-#define SYS_query_module __NR_query_module
-#define SYS_quotactl __NR_quotactl
-#define SYS_read __NR_read
-#define SYS_readahead __NR_readahead
-#define SYS_readlink __NR_readlink
-#define SYS_readlinkat __NR_readlinkat
-#define SYS_readv __NR_readv
-#define SYS_reboot __NR_reboot
-#define SYS_recvfrom __NR_recvfrom
-#define SYS_recvmmsg __NR_recvmmsg
-#define SYS_recvmsg __NR_recvmsg
-#define SYS_remap_file_pages __NR_remap_file_pages
-#define SYS_removexattr __NR_removexattr
-#define SYS_rename __NR_rename
-#define SYS_renameat __NR_renameat
-#define SYS_renameat2 __NR_renameat2
-#define SYS_request_key __NR_request_key
-#define SYS_restart_syscall __NR_restart_syscall
-#define SYS_rmdir __NR_rmdir
-#define SYS_rt_sigaction __NR_rt_sigaction
-#define SYS_rt_sigpending __NR_rt_sigpending
-#define SYS_rt_sigprocmask __NR_rt_sigprocmask
-#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
-#define SYS_rt_sigreturn __NR_rt_sigreturn
-#define SYS_rt_sigsuspend __NR_rt_sigsuspend
-#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
-#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
-#define SYS_sched_get_priority_max __NR_sched_get_priority_max
-#define SYS_sched_get_priority_min __NR_sched_get_priority_min
-#define SYS_sched_getaffinity __NR_sched_getaffinity
-#define SYS_sched_getattr __NR_sched_getattr
-#define SYS_sched_getparam __NR_sched_getparam
-#define SYS_sched_getscheduler __NR_sched_getscheduler
-#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
-#define SYS_sched_setaffinity __NR_sched_setaffinity
-#define SYS_sched_setattr __NR_sched_setattr
-#define SYS_sched_setparam __NR_sched_setparam
-#define SYS_sched_setscheduler __NR_sched_setscheduler
-#define SYS_sched_yield __NR_sched_yield
-#define SYS_seccomp __NR_seccomp
-#define SYS_security __NR_security
-#define SYS_select __NR_select
-#define SYS_semctl __NR_semctl
-#define SYS_semget __NR_semget
-#define SYS_semop __NR_semop
-#define SYS_semtimedop __NR_semtimedop
-#define SYS_sendfile __NR_sendfile
-#define SYS_sendmmsg __NR_sendmmsg
-#define SYS_sendmsg __NR_sendmsg
-#define SYS_sendto __NR_sendto
-#define SYS_set_mempolicy __NR_set_mempolicy
-#define SYS_set_robust_list __NR_set_robust_list
-#define SYS_set_thread_area __NR_set_thread_area
-#define SYS_set_tid_address __NR_set_tid_address
-#define SYS_setdomainname __NR_setdomainname
-#define SYS_setfsgid __NR_setfsgid
-#define SYS_setfsuid __NR_setfsuid
-#define SYS_setgid __NR_setgid
-#define SYS_setgroups __NR_setgroups
-#define SYS_sethostname __NR_sethostname
-#define SYS_setitimer __NR_setitimer
-#define SYS_setns __NR_setns
-#define SYS_setpgid __NR_setpgid
-#define SYS_setpriority __NR_setpriority
-#define SYS_setregid __NR_setregid
-#define SYS_setresgid __NR_setresgid
-#define SYS_setresuid __NR_setresuid
-#define SYS_setreuid __NR_setreuid
-#define SYS_setrlimit __NR_setrlimit
-#define SYS_setsid __NR_setsid
-#define SYS_setsockopt __NR_setsockopt
-#define SYS_settimeofday __NR_settimeofday
-#define SYS_setuid __NR_setuid
-#define SYS_setxattr __NR_setxattr
-#define SYS_shmat __NR_shmat
-#define SYS_shmctl __NR_shmctl
-#define SYS_shmdt __NR_shmdt
-#define SYS_shmget __NR_shmget
-#define SYS_shutdown __NR_shutdown
-#define SYS_sigaltstack __NR_sigaltstack
-#define SYS_signalfd __NR_signalfd
-#define SYS_signalfd4 __NR_signalfd4
-#define SYS_socket __NR_socket
-#define SYS_socketpair __NR_socketpair
-#define SYS_splice __NR_splice
-#define SYS_stat __NR_stat
-#define SYS_statfs __NR_statfs
-#define SYS_swapoff __NR_swapoff
-#define SYS_swapon __NR_swapon
-#define SYS_symlink __NR_symlink
-#define SYS_symlinkat __NR_symlinkat
-#define SYS_sync __NR_sync
-#define SYS_sync_file_range __NR_sync_file_range
-#define SYS_syncfs __NR_syncfs
-#define SYS_sysfs __NR_sysfs
-#define SYS_sysinfo __NR_sysinfo
-#define SYS_syslog __NR_syslog
-#define SYS_tee __NR_tee
-#define SYS_tgkill __NR_tgkill
-#define SYS_time __NR_time
-#define SYS_timer_create __NR_timer_create
-#define SYS_timer_delete __NR_timer_delete
-#define SYS_timer_getoverrun __NR_timer_getoverrun
-#define SYS_timer_gettime __NR_timer_gettime
-#define SYS_timer_settime __NR_timer_settime
-#define SYS_timerfd_create __NR_timerfd_create
-#define SYS_timerfd_gettime __NR_timerfd_gettime
-#define SYS_timerfd_settime __NR_timerfd_settime
-#define SYS_times __NR_times
-#define SYS_tkill __NR_tkill
-#define SYS_truncate __NR_truncate
-#define SYS_tuxcall __NR_tuxcall
-#define SYS_umask __NR_umask
-#define SYS_umount2 __NR_umount2
-#define SYS_uname __NR_uname
-#define SYS_unlink __NR_unlink
-#define SYS_unlinkat __NR_unlinkat
-#define SYS_unshare __NR_unshare
-#define SYS_uselib __NR_uselib
-#define SYS_userfaultfd __NR_userfaultfd
-#define SYS_ustat __NR_ustat
-#define SYS_utime __NR_utime
-#define SYS_utimensat __NR_utimensat
-#define SYS_utimes __NR_utimes
-#define SYS_vfork __NR_vfork
-#define SYS_vhangup __NR_vhangup
-#define SYS_vmsplice __NR_vmsplice
-#define SYS_vserver __NR_vserver
-#define SYS_wait4 __NR_wait4
-#define SYS_waitid __NR_waitid
-#define SYS_write __NR_write
-#define SYS_writev __NR_writev
-#endif
-#endif /* _BIONIC_GLIBC_SYSCALLS_H_ */
diff --git a/libc/include/sys/inotify.h b/libc/include/sys/inotify.h
index dcdd29a..2e99144 100644
--- a/libc/include/sys/inotify.h
+++ b/libc/include/sys/inotify.h
@@ -40,10 +40,10 @@
 #define IN_CLOEXEC O_CLOEXEC
 #define IN_NONBLOCK O_NONBLOCK
 
-extern int inotify_init(void);
-extern int inotify_init1(int);
-extern int inotify_add_watch(int, const char*, uint32_t);
-extern int inotify_rm_watch(int, uint32_t);
+int inotify_init(void);
+int inotify_init1(int) __INTRODUCED_IN(21);
+int inotify_add_watch(int, const char*, uint32_t);
+int inotify_rm_watch(int, uint32_t);
 
 __END_DECLS
 
diff --git a/libc/include/sys/ioctl.h b/libc/include/sys/ioctl.h
index a1014dc..efbcb0c 100644
--- a/libc/include/sys/ioctl.h
+++ b/libc/include/sys/ioctl.h
@@ -37,13 +37,8 @@
 #include <linux/termios.h>
 #include <asm/ioctls.h>
 #include <asm/termbits.h>
-#include <sys/ioctl_compat.h>
 #include <linux/tty.h>
 
-__BEGIN_DECLS
-
-extern int ioctl(int, int, ...);
-
-__END_DECLS
+#include <bits/ioctl.h>
 
 #endif /* _SYS_IOCTL_H_ */
diff --git a/libc/include/sys/ioctl_compat.h b/libc/include/sys/ioctl_compat.h
deleted file mode 100644
index d9ba4c7..0000000
--- a/libc/include/sys/ioctl_compat.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*	$NetBSD: ioctl_compat.h,v 1.15 2005/12/03 17:10:46 christos Exp $	*/
-
-/*
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)ioctl_compat.h	8.4 (Berkeley) 1/21/94
- */
-
-#ifndef _SYS_IOCTL_COMPAT_H_
-#define	_SYS_IOCTL_COMPAT_H_
-
-/*#include <sys/ttychars.h>*/
-/*#include <sys/ttydev.h>*/
-
-#if !defined(__mips__)
-struct tchars {
-	char	t_intrc;	/* interrupt */
-	char	t_quitc;	/* quit */
-	char	t_startc;	/* start output */
-	char	t_stopc;	/* stop output */
-	char	t_eofc;		/* end-of-file */
-	char	t_brkc;		/* input delimiter (like nl) */
-};
-
-struct ltchars {
-	char	t_suspc;	/* stop process signal */
-	char	t_dsuspc;	/* delayed stop process signal */
-	char	t_rprntc;	/* reprint line */
-	char	t_flushc;	/* flush output (toggles) */
-	char	t_werasc;	/* word erase */
-	char	t_lnextc;	/* literal next character */
-};
-
-/*
- * Structure for TIOCGETP and TIOCSETP ioctls.
- */
-#ifndef _SGTTYB_
-#define	_SGTTYB_
-struct sgttyb {
-	char	sg_ispeed;		/* input speed */
-	char	sg_ospeed;		/* output speed */
-	char	sg_erase;		/* erase character */
-	char	sg_kill;		/* kill character */
-	short	sg_flags;		/* mode flags */
-};
-#endif
-#endif
-
-#ifdef USE_OLD_TTY
-# undef  TIOCGETD
-# define TIOCGETD	_IOR('t', 0, int)	/* get line discipline */
-# undef  TIOCSETD
-# define TIOCSETD	_IOW('t', 1, int)	/* set line discipline */
-#else
-# define OTIOCGETD	_IOR('t', 0, int)	/* get line discipline */
-# define OTIOCSETD	_IOW('t', 1, int)	/* set line discipline */
-#endif
-#define	TIOCHPCL	_IO('t', 2)		/* hang up on last close */
-#if !defined(__mips__)
-#define	TIOCGETP	_IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
-#define	TIOCSETP	_IOW('t', 9,struct sgttyb)/* set parameters -- stty */
-#define	TIOCSETN	_IOW('t',10,struct sgttyb)/* as above, but no flushtty*/
-#endif
-#define	TIOCSETC	_IOW('t',17,struct tchars)/* set special characters */
-#define	TIOCGETC	_IOR('t',18,struct tchars)/* get special characters */
-#if 0
-/* BUG: a bunch of these conflict with #defines in asm/termbits.h */
-#define		TANDEM		0x00000001	/* send stopc on out q full */
-#define		CBREAK		0x00000002	/* half-cooked mode */
-#define		LCASE		0x00000004	/* simulate lower case */
-#define		ECHO		0x00000008	/* enable echoing */
-#define		CRMOD		0x00000010	/* map \r to \r\n on output */
-#define		RAW		0x00000020	/* no i/o processing */
-#define		ODDP		0x00000040	/* get/send odd parity */
-#define		EVENP		0x00000080	/* get/send even parity */
-#define		ANYP		0x000000c0	/* get any parity/send none */
-#define		NLDELAY		0x00000300	/* \n delay */
-#define			NL0	0x00000000
-#define			NL1	0x00000100	/* tty 37 */
-#define			NL2	0x00000200	/* vt05 */
-#define			NL3	0x00000300
-#define		TBDELAY		0x00000c00	/* horizontal tab delay */
-#define			TAB0	0x00000000
-#define			TAB1	0x00000400	/* tty 37 */
-#define			TAB2	0x00000800
-#define		XTABS		0x00000c00	/* expand tabs on output */
-#define		CRDELAY		0x00003000	/* \r delay */
-#define			CR0	0x00000000
-#define			CR1	0x00001000	/* tn 300 */
-#define			CR2	0x00002000	/* tty 37 */
-#define			CR3	0x00003000	/* concept 100 */
-#define		VTDELAY		0x00004000	/* vertical tab delay */
-#define			FF0	0x00000000
-#define			FF1	0x00004000	/* tty 37 */
-#define		BSDELAY		0x00008000	/* \b delay */
-#define			BS0	0x00000000
-#define			BS1	0x00008000
-#define		ALLDELAY	(NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
-#define		CRTBS		0x00010000	/* do backspacing for crt */
-#define		PRTERA		0x00020000	/* \ ... / erase */
-#define		CRTERA		0x00040000	/* " \b " to wipe out char */
-#define		TILDE		0x00080000	/* hazeltine tilde kludge */
-#define		MDMBUF		0x00100000	/* DTR/DCD hardware flow control */
-#define		LITOUT		0x00200000	/* literal output */
-#define		TOSTOP		0x00400000	/* stop background jobs on output */
-#define		FLUSHO		0x00800000	/* output being flushed (state) */
-#define		NOHANG		0x01000000	/* (no-op) was no SIGHUP on carrier drop */
-#define		L001000		0x02000000
-#define		CRTKIL		0x04000000	/* kill line with " \b " */
-#define		PASS8		0x08000000
-#define		CTLECH		0x10000000	/* echo control chars as ^X */
-#define		PENDIN		0x20000000	/* re-echo input buffer at next read */
-#define		DECCTQ		0x40000000	/* only ^Q starts after ^S */
-#define		NOFLSH		0x80000000	/* don't flush output on signal */
-#endif
-#define	TIOCLBIS	_IOW('t', 127, int)	/* bis local mode bits */
-#define	TIOCLBIC	_IOW('t', 126, int)	/* bic local mode bits */
-#define	TIOCLSET	_IOW('t', 125, int)	/* set entire local mode word */
-#define	TIOCLGET	_IOR('t', 124, int)	/* get local modes */
-#define		LCRTBS		(CRTBS>>16)
-#define		LPRTERA		(PRTERA>>16)
-#define		LCRTERA		(CRTERA>>16)
-#define		LTILDE		(TILDE>>16)
-#define		LMDMBUF		(MDMBUF>>16)
-#define		LLITOUT		(LITOUT>>16)
-#define		LTOSTOP		(TOSTOP>>16)
-#define		LFLUSHO		(FLUSHO>>16)
-#define		LNOHANG		(NOHANG>>16)
-#define		LCRTKIL		(CRTKIL>>16)
-#define		LPASS8		(PASS8>>16)
-#define		LCTLECH		(CTLECH>>16)
-#define		LPENDIN		(PENDIN>>16)
-#define		LDECCTQ		(DECCTQ>>16)
-#define		LNOFLSH		(NOFLSH>>16)
-#if !defined(__mips__)
-#define	TIOCSLTC	_IOW('t',117,struct ltchars)/* set local special chars*/
-#define	TIOCGLTC	_IOR('t',116,struct ltchars)/* get local special chars*/
-#endif
-#define OTIOCCONS	_IO('t', 98)	/* for hp300 -- sans int arg */
-#define	OTTYDISC	0
-#define	NETLDISC	1
-#define	NTTYDISC	2
-
-#endif /* !_SYS_IOCTL_COMPAT_H_ */
diff --git a/libc/include/sys/ipc.h b/libc/include/sys/ipc.h
index c0ae0ba..1a5a4a0 100644
--- a/libc/include/sys/ipc.h
+++ b/libc/include/sys/ipc.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_IPC_H
 #define _SYS_IPC_H
 
@@ -32,9 +33,11 @@
 #include <sys/types.h>
 #include <linux/ipc.h>
 
+#define ipc_perm ipc64_perm
+
 __BEGIN_DECLS
 
-extern key_t  ftok(const char*  path, int  id);
+key_t ftok(const char* path, int id);
 
 __END_DECLS
 
diff --git a/libc/include/sys/klog.h b/libc/include/sys/klog.h
index acfaa20..47eb3a4 100644
--- a/libc/include/sys/klog.h
+++ b/libc/include/sys/klog.h
@@ -46,7 +46,7 @@
 #define KLOG_SIZE_UNREAD   9
 #define KLOG_SIZE_BUFFER   10
 
-extern int klogctl(int, char *, int);
+int klogctl(int, char *, int);
 
 __END_DECLS
 
diff --git a/libc/include/sys/limits.h b/libc/include/sys/limits.h
index be79cf3..60cc7f7 100644
--- a/libc/include/sys/limits.h
+++ b/libc/include/sys/limits.h
@@ -66,16 +66,14 @@
 # define LONG_MIN	(-0x7fffffffL-1)/* min value for a long */
 #endif
 
-#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
 # define ULLONG_MAX	0xffffffffffffffffULL
 					/* max value for unsigned long long */
 # define LLONG_MAX	0x7fffffffffffffffLL
 					/* max value for a signed long long */
 # define LLONG_MIN	(-0x7fffffffffffffffLL-1)
 					/* min value for a signed long long */
-#endif
 
-#if __BSD_VISIBLE
+#if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
 # define UID_MAX	UINT_MAX	/* max value for a uid_t */
 # define GID_MAX	UINT_MAX	/* max value for a gid_t */
 #endif
@@ -108,20 +106,17 @@
 #  endif
 # endif
 
-/* Bionic: the following has been optimized out from our processed kernel headers */
-
-#define  CHILD_MAX   999
-#define  OPEN_MAX    256
-
 /* Bionic-specific definitions */
 
 #define  _POSIX_VERSION             200809L   /* Posix C language bindings version */
 #define  _POSIX2_VERSION            -1        /* we don't support Posix command-line tools */
 #define  _XOPEN_VERSION             700       /* by Posix definition */
 
-
-#define PTHREAD_DESTRUCTOR_ITERATIONS 4     // >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-#define PTHREAD_KEYS_MAX              128   // >= _POSIX_THREAD_KEYS_MAX
-#define PTHREAD_THREADS_MAX           2048  // bionic has no specific limit
+/* >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS */
+#define PTHREAD_DESTRUCTOR_ITERATIONS 4
+/* >= _POSIX_THREAD_KEYS_MAX */
+#define PTHREAD_KEYS_MAX 128
+/* bionic has no specific limit */
+#undef PTHREAD_THREADS_MAX
 
 #endif
diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h
index a19ceb5..79f1faf 100644
--- a/libc/include/sys/mman.h
+++ b/libc/include/sys/mman.h
@@ -38,7 +38,7 @@
 #define MAP_ANON  MAP_ANONYMOUS
 #endif
 
-#define MAP_FAILED ((void *)-1)
+#define MAP_FAILED __BIONIC_CAST(reinterpret_cast, void*, -1)
 
 #define MREMAP_MAYMOVE  1
 #define MREMAP_FIXED    2
@@ -50,29 +50,26 @@
 #define POSIX_MADV_DONTNEED   MADV_DONTNEED
 
 #if defined(__USE_FILE_OFFSET64)
-extern void* mmap(void*, size_t, int, int, int, off_t) __RENAME(mmap64);
+void* mmap(void*, size_t, int, int, int, off_t) __RENAME(mmap64) __INTRODUCED_IN(21);
 #else
-extern void* mmap(void*, size_t, int, int, int, off_t);
+void* mmap(void*, size_t, int, int, int, off_t);
 #endif
-extern void* mmap64(void*, size_t, int, int, int, off64_t);
+void* mmap64(void*, size_t, int, int, int, off64_t) __INTRODUCED_IN(21);
 
-extern int munmap(void*, size_t);
-extern int msync(const void*, size_t, int);
-extern int mprotect(const void*, size_t, int);
-extern void* mremap(void*, size_t, size_t, int, ...);
+int munmap(void*, size_t);
+int msync(void*, size_t, int);
+int mprotect(void*, size_t, int);
+void* mremap(void*, size_t, size_t, int, ...);
 
-extern int mlockall(int);
-extern int munlockall(void);
-extern int mlock(const void*, size_t);
-extern int munlock(const void*, size_t);
-extern int madvise(void*, size_t, int);
+int mlockall(int) __INTRODUCED_IN(17);
+int munlockall(void) __INTRODUCED_IN(17);
+int mlock(const void*, size_t);
+int munlock(const void*, size_t);
 
-extern int mlock(const void*, size_t);
-extern int munlock(const void*, size_t);
+int mincore(void*, size_t, unsigned char*);
 
-extern int mincore(void*, size_t, unsigned char*);
-
-extern int posix_madvise(void*, size_t, int);
+int madvise(void*, size_t, int);
+int posix_madvise(void*, size_t, int) __INTRODUCED_IN(23);
 
 __END_DECLS
 
diff --git a/libc/include/sys/mount.h b/libc/include/sys/mount.h
index fd7cf17..26c0e0f 100644
--- a/libc/include/sys/mount.h
+++ b/libc/include/sys/mount.h
@@ -41,9 +41,9 @@
 #define MNT_EXPIRE 4
 #define UMOUNT_NOFOLLOW 8
 
-extern int mount(const char*, const char*, const char*, unsigned long, const void*);
-extern int umount(const char*);
-extern int umount2(const char*, int);
+int mount(const char*, const char*, const char*, unsigned long, const void*);
+int umount(const char*);
+int umount2(const char*, int);
 
 __END_DECLS
 
diff --git a/libc/include/sys/msg.h b/libc/include/sys/msg.h
index 1a6d30d..f746bb5 100644
--- a/libc/include/sys/msg.h
+++ b/libc/include/sys/msg.h
@@ -29,6 +29,23 @@
 #ifndef _SYS_MSG_H_
 #define _SYS_MSG_H_
 
+#include <sys/cdefs.h>
+#include <sys/ipc.h>
+
 #include <linux/msg.h>
 
+#define msqid_ds msqid64_ds
+
+__BEGIN_DECLS
+
+typedef __kernel_ulong_t msgqnum_t;
+typedef __kernel_ulong_t msglen_t;
+
+int msgctl(int, int, struct msqid_ds*) __INTRODUCED_IN_FUTURE;
+int msgget(key_t, int) __INTRODUCED_IN_FUTURE;
+ssize_t msgrcv(int, void*, size_t, long, int) __INTRODUCED_IN_FUTURE;
+int msgsnd(int, const void*, size_t, int) __INTRODUCED_IN_FUTURE;
+
+__END_DECLS
+
 #endif /* _SYS_MSG_H_ */
diff --git a/libc/include/sys/param.h b/libc/include/sys/param.h
index e64d6ce..d3686e0 100644
--- a/libc/include/sys/param.h
+++ b/libc/include/sys/param.h
@@ -25,11 +25,15 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_PARAM_H_
 #define _SYS_PARAM_H_
 
 #include <limits.h>
 #include <linux/param.h>
+#include <sys/cdefs.h>
+
+#define DEV_BSIZE 512
 
 #define MAXPATHLEN  PATH_MAX
 #define MAXSYMLINKS 8
diff --git a/libc/include/sys/personality.h b/libc/include/sys/personality.h
index 7764468..6f3a3c9 100644
--- a/libc/include/sys/personality.h
+++ b/libc/include/sys/personality.h
@@ -34,7 +34,7 @@
 
 __BEGIN_DECLS
 
-extern int personality (unsigned int persona);
+int personality(unsigned int persona) __INTRODUCED_IN(15);
 
 __END_DECLS
 
diff --git a/libc/include/sys/prctl.h b/libc/include/sys/prctl.h
index d96b8b6..742ed57 100644
--- a/libc/include/sys/prctl.h
+++ b/libc/include/sys/prctl.h
@@ -35,7 +35,7 @@
 
 __BEGIN_DECLS
 
-extern int prctl(int option, ...);
+int prctl(int option, ...);
 
 __END_DECLS
 
diff --git a/libc/include/sys/queue.h b/libc/include/sys/queue.h
index b0e6b38..0890838 100644
--- a/libc/include/sys/queue.h
+++ b/libc/include/sys/queue.h
@@ -32,6 +32,8 @@
 #ifndef	_SYS_QUEUE_H_
 #define	_SYS_QUEUE_H_
 
+#include <sys/cdefs.h>
+
 /*
  * This file defines five types of data structures: singly-linked lists,
  * lists, simple queues, tail queues, and circular queues.
diff --git a/libc/include/sys/utime.h b/libc/include/sys/quota.h
similarity index 77%
copy from libc/include/sys/utime.h
copy to libc/include/sys/quota.h
index 9f8810e..08ca982 100644
--- a/libc/include/sys/utime.h
+++ b/libc/include/sys/quota.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,9 +25,23 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _SYS_UTIME_H_
-#define _SYS_UTIME_H_
 
-#include <linux/utime.h>
+#ifndef _SYS_QUOTA_H_
+#define _SYS_QUOTA_H_
 
-#endif /* _SYS_UTIME_H_ */
+#include <sys/cdefs.h>
+
+// The uapi header uses different names from userspace, oddly.
+#define if_dqblk dqblk
+#define if_dqinfo dqinfo
+#include <linux/quota.h>
+#undef if_dqblk
+#undef if_dqinfo
+
+__BEGIN_DECLS
+
+int quotactl(int, const char*, int, char*) __INTRODUCED_IN_FUTURE;
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/sys/reboot.h b/libc/include/sys/reboot.h
index 7d202f7..df4739e 100644
--- a/libc/include/sys/reboot.h
+++ b/libc/include/sys/reboot.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_REBOOT_H_
 #define _SYS_REBOOT_H_
 
@@ -41,7 +42,7 @@
 #define RB_DISABLE_CAD  LINUX_REBOOT_CMD_CAD_OFF
 #define RB_POWER_OFF    LINUX_REBOOT_CMD_POWER_OFF
 
-extern int reboot(int  reboot_type);
+int reboot(int reboot_type);
 
 __END_DECLS
 
diff --git a/libc/include/sys/reg.h b/libc/include/sys/reg.h
index b3d2aac..1066b6d 100644
--- a/libc/include/sys/reg.h
+++ b/libc/include/sys/reg.h
@@ -29,6 +29,8 @@
 #ifndef _SYS_REG_H_
 #define _SYS_REG_H_
 
+#include <sys/cdefs.h>
+
 #if defined(__i386__)
 
 #define EBX 0
diff --git a/libc/include/sys/resource.h b/libc/include/sys/resource.h
index 8209dfb..248310e 100644
--- a/libc/include/sys/resource.h
+++ b/libc/include/sys/resource.h
@@ -42,19 +42,20 @@
 
 typedef unsigned long rlim_t;
 
-extern int getrlimit(int, struct rlimit*);
-extern int setrlimit(int, const struct rlimit*);
+int getrlimit(int, struct rlimit*);
+int setrlimit(int, const struct rlimit*);
 
-extern int getrlimit64(int, struct rlimit64*);
-extern int setrlimit64(int, const struct rlimit64*);
+int getrlimit64(int, struct rlimit64*) __INTRODUCED_IN(21);
+int setrlimit64(int, const struct rlimit64*) __INTRODUCED_IN(21);
 
-extern int getpriority(int, int);
-extern int setpriority(int, int, int);
+int getpriority(int, int);
+int setpriority(int, int, int);
 
-extern int getrusage(int, struct rusage*);
+int getrusage(int, struct rusage*);
 
-extern int prlimit(pid_t, int, const struct rlimit*, struct rlimit*);
-extern int prlimit64(pid_t, int, const struct rlimit64*, struct rlimit64*);
+int prlimit(pid_t, int, const struct rlimit*, struct rlimit*) __INTRODUCED_IN_32(24)
+  __INTRODUCED_IN_64(21);
+int prlimit64(pid_t, int, const struct rlimit64*, struct rlimit64*) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h
index 0c4a823..5a8a81d 100644
--- a/libc/include/sys/select.h
+++ b/libc/include/sys/select.h
@@ -46,7 +46,7 @@
 
 #define __FDELT(fd) ((fd) / NFDBITS)
 #define __FDMASK(fd) (1UL << ((fd) % NFDBITS))
-#define __FDS_BITS(set) (((fd_set*)(set))->fds_bits)
+#define __FDS_BITS(set) (__BIONIC_CAST(static_cast, fd_set*, set)->fds_bits)
 
 /* Inline loop so we don't have to declare memset. */
 #define FD_ZERO(set) \
@@ -57,11 +57,11 @@
     } \
   } while (0)
 
-extern void __FD_CLR_chk(int, fd_set*, size_t);
-extern void __FD_SET_chk(int, fd_set*, size_t);
-extern int  __FD_ISSET_chk(int, fd_set*, size_t);
+void __FD_CLR_chk(int, fd_set*, size_t) __INTRODUCED_IN(21);
+void __FD_SET_chk(int, fd_set*, size_t) __INTRODUCED_IN(21);
+int __FD_ISSET_chk(int, fd_set*, size_t) __INTRODUCED_IN(21);
 
-#if defined(__BIONIC_FORTIFY)
+#if defined(__BIONIC_FORTIFY) && __ANDROID_API__ >= 21
 #define FD_CLR(fd, set) __FD_CLR_chk(fd, set, __bos(set))
 #define FD_SET(fd, set) __FD_SET_chk(fd, set, __bos(set))
 #define FD_ISSET(fd, set) __FD_ISSET_chk(fd, set, __bos(set))
@@ -69,10 +69,10 @@
 #define FD_CLR(fd, set) (__FDS_BITS(set)[__FDELT(fd)] &= ~__FDMASK(fd))
 #define FD_SET(fd, set) (__FDS_BITS(set)[__FDELT(fd)] |= __FDMASK(fd))
 #define FD_ISSET(fd, set) ((__FDS_BITS(set)[__FDELT(fd)] & __FDMASK(fd)) != 0)
-#endif /* defined(__BIONIC_FORTIFY) */
+#endif /* defined(__BIONIC_FORTIFY) && __ANDROID_API >= 21 */
 
-extern int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
-extern int pselect(int, fd_set*, fd_set*, fd_set*, const struct timespec*, const sigset_t*);
+int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
+int pselect(int, fd_set*, fd_set*, fd_set*, const struct timespec*, const sigset_t*);
 
 __END_DECLS
 
diff --git a/libc/include/sys/sem.h b/libc/include/sys/sem.h
index a1ecd1f..99873c1 100644
--- a/libc/include/sys/sem.h
+++ b/libc/include/sys/sem.h
@@ -29,6 +29,28 @@
 #ifndef _SYS_SEM_H_
 #define _SYS_SEM_H_
 
+#include <sys/cdefs.h>
+#include <sys/ipc.h>
+#include <sys/types.h>
+
+#if defined(__USE_GNU)
+#include <bits/timespec.h>
+#endif
+
 #include <linux/sem.h>
 
-#endif /* _SYS_SEM_H_ */
+#define semid_ds semid64_ds
+
+__BEGIN_DECLS
+
+int semctl(int, int, int, ...) __INTRODUCED_IN_FUTURE;
+int semget(key_t, int, int) __INTRODUCED_IN_FUTURE;
+int semop(int, struct sembuf*, size_t) __INTRODUCED_IN_FUTURE;
+
+#if defined(__USE_GNU)
+int semtimedop(int, struct sembuf*, size_t, const struct timespec*) __INTRODUCED_IN_FUTURE;
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/sys/sendfile.h b/libc/include/sys/sendfile.h
index c588e68..3ac8fdf 100644
--- a/libc/include/sys/sendfile.h
+++ b/libc/include/sys/sendfile.h
@@ -35,11 +35,12 @@
 __BEGIN_DECLS
 
 #if defined(__USE_FILE_OFFSET64)
-extern ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) __RENAME(sendfile64);
+ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) __RENAME(sendfile64)
+  __INTRODUCED_IN(21);
 #else
-extern ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count);
+ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count);
 #endif
-extern ssize_t sendfile64(int out_fd, int in_fd, off64_t* offset, size_t count);
+ssize_t sendfile64(int out_fd, int in_fd, off64_t* offset, size_t count) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libstdc++/include/cstdint b/libc/include/sys/shm.h
similarity index 71%
copy from libstdc++/include/cstdint
copy to libc/include/sys/shm.h
index 3df56df..7836460 100644
--- a/libstdc++/include/cstdint
+++ b/libc/include/sys/shm.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,14 +26,27 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+#ifndef _SYS_SHM_H_
+#define _SYS_SHM_H_
 
-/*
- * Standard C++ Library wrapper around the C stdint.h header file.
- */
+#include <sys/cdefs.h>
+#include <sys/ipc.h>
+#include <sys/types.h>
 
-#include <stdint.h>
+#include <linux/shm.h>
 
+#define shmid_ds shmid64_ds
+#define SHMLBA 4096
 
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+__BEGIN_DECLS
+
+typedef unsigned long shmatt_t;
+
+void* shmat(int, const void*, int) __INTRODUCED_IN_FUTURE;
+int shmctl(int, int, struct shmid_ds*) __INTRODUCED_IN_FUTURE;
+int shmdt(const void*) __INTRODUCED_IN_FUTURE;
+int shmget(key_t, size_t, int) __INTRODUCED_IN_FUTURE;
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/sys/signalfd.h b/libc/include/sys/signalfd.h
index 2537ab9..a21c57b 100644
--- a/libc/include/sys/signalfd.h
+++ b/libc/include/sys/signalfd.h
@@ -35,7 +35,7 @@
 
 __BEGIN_DECLS
 
-extern int signalfd(int fd, const sigset_t* mask, int flags) __nonnull((2));
+int signalfd(int fd, const sigset_t* _Nonnull mask, int flags) __INTRODUCED_IN(18);
 
 __END_DECLS
 
diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h
index c7e9acc..03dc849 100644
--- a/libc/include/sys/socket.h
+++ b/libc/include/sys/socket.h
@@ -40,10 +40,11 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 
+#include <bits/sa_family_t.h>
+
 __BEGIN_DECLS
 
 #define sockaddr_storage __kernel_sockaddr_storage
-typedef unsigned short sa_family_t;
 
 struct timespec;
 
@@ -113,7 +114,22 @@
    ? (struct cmsghdr*) (msg)->msg_control : (struct cmsghdr*) NULL)
 #define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) &&   (cmsg)->cmsg_len <= (unsigned long)   ((mhdr)->msg_controllen -   ((char*)(cmsg) - (char*)(mhdr)->msg_control)))
 
-struct cmsghdr* __cmsg_nxthdr(struct msghdr*, struct cmsghdr*);
+#if __ANDROID_API__ >= 21
+struct cmsghdr* __cmsg_nxthdr(struct msghdr*, struct cmsghdr*) __INTRODUCED_IN(21);
+#else
+/* TODO(danalbert): Move this into libandroid_support. */
+static inline struct cmsghdr* __cmsg_nxthdr(struct msghdr* msg, struct cmsghdr* cmsg) {
+  struct cmsghdr* ptr =
+      __BIONIC_CAST(reinterpret_cast, struct cmsghdr*,
+                    (__BIONIC_CAST(reinterpret_cast, char*, cmsg) + CMSG_ALIGN(cmsg->cmsg_len)));
+  size_t len = __BIONIC_CAST(reinterpret_cast, char*, ptr + 1) -
+               __BIONIC_CAST(reinterpret_cast, char*, msg->msg_control);
+  if (len > msg->msg_controllen) {
+    return NULL;
+  }
+  return ptr;
+}
+#endif /* __ANDROID_API__ >= 21 */
 
 #define SCM_RIGHTS 0x01
 #define SCM_CREDENTIALS 0x02
@@ -269,36 +285,39 @@
 #endif
 
 __socketcall int accept(int, struct sockaddr*, socklen_t*);
-__socketcall int accept4(int, struct sockaddr*, socklen_t*, int);
-__socketcall int bind(int, const struct sockaddr*, int);
+__socketcall int accept4(int, struct sockaddr*, socklen_t*, int) __INTRODUCED_IN(21);
+__socketcall int bind(int, const struct sockaddr*, socklen_t);
 __socketcall int connect(int, const struct sockaddr*, socklen_t);
 __socketcall int getpeername(int, struct sockaddr*, socklen_t*);
 __socketcall int getsockname(int, struct sockaddr*, socklen_t*);
 __socketcall int getsockopt(int, int, int, void*, socklen_t*);
 __socketcall int listen(int, int);
-__socketcall int recvmmsg(int, struct mmsghdr*, unsigned int, int, const struct timespec*);
-__socketcall int recvmsg(int, struct msghdr*, int);
-__socketcall int sendmmsg(int, const struct mmsghdr*, unsigned int, int);
-__socketcall int sendmsg(int, const struct msghdr*, int);
+__socketcall int recvmmsg(int, struct mmsghdr*, unsigned int, int, const struct timespec*)
+  __INTRODUCED_IN(21);
+__socketcall ssize_t recvmsg(int, struct msghdr*, int);
+__socketcall int sendmmsg(int, const struct mmsghdr*, unsigned int, int) __INTRODUCED_IN(21);
+__socketcall ssize_t sendmsg(int, const struct msghdr*, int);
 __socketcall int setsockopt(int, int, int, const void*, socklen_t);
 __socketcall int shutdown(int, int);
 __socketcall int socket(int, int, int);
 __socketcall int socketpair(int, int, int, int*);
 
-extern ssize_t send(int, const void*, size_t, int);
-extern ssize_t recv(int, void*, size_t, int);
+ssize_t recv(int, void*, size_t, int);
+ssize_t send(int, const void*, size_t, int);
 
 __socketcall ssize_t sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t);
-__socketcall ssize_t recvfrom(int, void*, size_t, int, const struct sockaddr*, socklen_t*);
+__socketcall ssize_t recvfrom(int, void*, size_t, int, struct sockaddr*, socklen_t*);
 
 __errordecl(__recvfrom_error, "recvfrom called with size bigger than buffer");
-extern ssize_t __recvfrom_chk(int, void*, size_t, size_t, int, const struct sockaddr*, socklen_t*);
-extern ssize_t __recvfrom_real(int, void*, size_t, int, const struct sockaddr*, socklen_t*) __RENAME(recvfrom);
+ssize_t __recvfrom_chk(int, void*, size_t, size_t, int, struct sockaddr*, socklen_t*)
+  __INTRODUCED_IN(21);
+ssize_t __recvfrom_real(int, void*, size_t, int, struct sockaddr*, socklen_t*) __RENAME(recvfrom);
 
 #if defined(__BIONIC_FORTIFY)
 
+#if __ANDROID_API__ >= 24
 __BIONIC_FORTIFY_INLINE
-ssize_t recvfrom(int fd, void* buf, size_t len, int flags, const struct sockaddr* src_addr, socklen_t* addr_len) {
+ssize_t recvfrom(int fd, void* buf, size_t len, int flags, struct sockaddr* src_addr, socklen_t* addr_len) {
   size_t bos = __bos0(buf);
 
 #if !defined(__clang__)
@@ -317,6 +336,7 @@
 
   return __recvfrom_chk(fd, buf, len, bos, flags, src_addr, addr_len);
 }
+#endif /* __ANDROID_API__ >= 24 */
 
 __BIONIC_FORTIFY_INLINE
 ssize_t recv(int socket, void* buf, size_t len, int flags) {
diff --git a/libc/include/sys/socketcalls.h b/libc/include/sys/socketcalls.h
deleted file mode 100644
index 131e0bb..0000000
--- a/libc/include/sys/socketcalls.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _SYS_SOCKETCALLS_H_
-#define _SYS_SOCKETCALLS_H_
-
-/* socketcalls by number */
-
-#define SYS_SOCKET      1               /* sys_socket(2)                */
-#define SYS_BIND        2               /* sys_bind(2)                  */
-#define SYS_CONNECT     3               /* sys_connect(2)               */
-#define SYS_LISTEN      4               /* sys_listen(2)                */
-#define SYS_ACCEPT      5               /* sys_accept(2)                */
-#define SYS_GETSOCKNAME 6               /* sys_getsockname(2)           */
-#define SYS_GETPEERNAME 7               /* sys_getpeername(2)           */
-#define SYS_SOCKETPAIR  8               /* sys_socketpair(2)            */
-#define SYS_SEND        9               /* sys_send(2)                  */
-#define SYS_RECV        10              /* sys_recv(2)                  */
-#define SYS_SENDTO      11              /* sys_sendto(2)                */
-#define SYS_RECVFROM    12              /* sys_recvfrom(2)              */
-#define SYS_SHUTDOWN    13              /* sys_shutdown(2)              */
-#define SYS_SETSOCKOPT  14              /* sys_setsockopt(2)            */
-#define SYS_GETSOCKOPT  15              /* sys_getsockopt(2)            */
-#define SYS_SENDMSG     16              /* sys_sendmsg(2)               */
-#define SYS_RECVMSG     17              /* sys_recvmsg(2)               */
-#define SYS_ACCEPT4     18              /* sys_accept4(2)               */
-#define SYS_RECVMMSG    19              /* sys_recvmmsg(2)              */
-#define SYS_SENDMMSG    20              /* sys_sendmmsg(2)              */
-
-#endif /* _SYS_SOCKETCALLS_H_ */
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 257ded0..cc9dd91 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -128,35 +128,48 @@
 #define st_mtimensec st_mtim.tv_nsec
 #define st_ctimensec st_ctim.tv_nsec
 
-#ifdef __USE_BSD
+#if defined(__USE_BSD)
 /* Permission macros provided by glibc for compatibility with BSDs. */
 #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
 #define ALLPERMS    (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
 #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
 #endif
 
-extern int chmod(const char*, mode_t);
-extern int fchmod(int, mode_t);
-extern int mkdir(const char*, mode_t);
+#if defined(__USE_BSD) || defined(__USE_GNU)
+#define S_IREAD S_IRUSR
+#define S_IWRITE S_IWUSR
+#define S_IEXEC S_IXUSR
+#endif
 
-extern int fstat(int, struct stat*);
-extern int fstat64(int, struct stat64*);
-extern int fstatat(int, const char*, struct stat*, int);
-extern int fstatat64(int, const char*, struct stat64*, int);
-extern int lstat(const char*, struct stat*);
-extern int lstat64(const char*, struct stat64*);
-extern int stat(const char*, struct stat*);
-extern int stat64(const char*, struct stat64*);
+/* POSIX mandates these, but Linux doesn't implement them as distinct file types. */
+#define S_TYPEISMQ(__sb) 0
+#define S_TYPEISSEM(__sb) 0
+#define S_TYPEISSHM(__sb) 0
+#define S_TYPEISTMO(__sb) 0
 
-extern int mknod(const char*, mode_t, dev_t);
-extern mode_t umask(mode_t);
+int chmod(const char*, mode_t);
+int fchmod(int, mode_t);
+int mkdir(const char*, mode_t);
 
-extern mode_t __umask_chk(mode_t);
-extern mode_t __umask_real(mode_t) __RENAME(umask);
+int fstat(int, struct stat*);
+int fstat64(int, struct stat64*) __INTRODUCED_IN(21);
+int fstatat(int, const char*, struct stat*, int);
+int fstatat64(int, const char*, struct stat64*, int) __INTRODUCED_IN(21);
+int lstat(const char*, struct stat*);
+int lstat64(const char*, struct stat64*) __INTRODUCED_IN(21);
+int stat(const char*, struct stat*);
+int stat64(const char*, struct stat64*) __INTRODUCED_IN(21);
+
+int mknod(const char*, mode_t, dev_t);
+mode_t umask(mode_t);
+
+mode_t __umask_chk(mode_t) __INTRODUCED_IN(18);
+mode_t __umask_real(mode_t) __RENAME(umask);
 __errordecl(__umask_invalid_mode, "umask called with invalid mode");
 
 #if defined(__BIONIC_FORTIFY)
 
+#if __ANDROID_API__ >= 18
 __BIONIC_FORTIFY_INLINE
 mode_t umask(mode_t mode) {
 #if !defined(__clang__)
@@ -169,24 +182,30 @@
 #endif
   return __umask_chk(mode);
 }
+#endif /* __ANDROID_API__ >= 18 */
+
 #endif /* defined(__BIONIC_FORTIFY) */
 
-extern int mkfifo(const char*, mode_t) __INTRODUCED_IN(21);
-extern int mkfifoat(int, const char*, mode_t);
+#if __ANDROID_API__ >= 21
+int mkfifo(const char*, mode_t) __INTRODUCED_IN(21);
+#else
+// Implemented as a static inline before 21.
+#endif
 
-extern int fchmodat(int, const char*, mode_t, int);
-extern int mkdirat(int, const char*, mode_t);
-extern int mknodat(int, const char*, mode_t, dev_t);
+int mkfifoat(int, const char*, mode_t) __INTRODUCED_IN(23);
+
+int fchmodat(int, const char*, mode_t, int);
+int mkdirat(int, const char*, mode_t);
+int mknodat(int, const char*, mode_t, dev_t) __INTRODUCED_IN(21);
 
 #define UTIME_NOW  ((1L << 30) - 1L)
 #define UTIME_OMIT ((1L << 30) - 2L)
-extern int utimensat(int fd, const char *path, const struct timespec times[2], int flags);
-extern int futimens(int fd, const struct timespec times[2]);
-
-#if __ANDROID_API__ < 21
-#include <android/legacy_sys_stat_inlines.h>
-#endif
+int utimensat(int fd, const char* path, const struct timespec times[2], int flags)
+  __INTRODUCED_IN(12);
+int futimens(int fd, const struct timespec times[2]) __INTRODUCED_IN(19);
 
 __END_DECLS
 
+#include <android/legacy_sys_stat_inlines.h>
+
 #endif /* _SYS_STAT_H_ */
diff --git a/libc/include/sys/statvfs.h b/libc/include/sys/statvfs.h
index 3495546..af1b9c0 100644
--- a/libc/include/sys/statvfs.h
+++ b/libc/include/sys/statvfs.h
@@ -59,10 +59,12 @@
 #define ST_NODIRATIME  0x0800
 #define ST_RELATIME    0x1000
 
-extern int statvfs(const char* __restrict, struct statvfs* __restrict) __nonnull((1, 2));
-extern int statvfs64(const char* __restrict, struct statvfs64* __restrict) __nonnull((1, 2));
-extern int fstatvfs(int, struct statvfs*) __nonnull((2));
-extern int fstatvfs64(int, struct statvfs64*) __nonnull((2));
+int statvfs(const char* __restrict _Nonnull, struct statvfs* __restrict _Nonnull)
+  __INTRODUCED_IN(19);
+int statvfs64(const char* __restrict _Nonnull, struct statvfs64* __restrict _Nonnull)
+  __INTRODUCED_IN(21);
+int fstatvfs(int, struct statvfs* _Nonnull) __INTRODUCED_IN(19);
+int fstatvfs64(int, struct statvfs64* _Nonnull) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/sys/swap.h b/libc/include/sys/swap.h
index e4c1819..3444736 100644
--- a/libc/include/sys/swap.h
+++ b/libc/include/sys/swap.h
@@ -38,8 +38,8 @@
 #define SWAP_FLAG_PRIO_MASK 0x7fff
 #define SWAP_FLAG_PRIO_SHIFT 0
 
-extern int swapon(const char*, int) __nonnull((1));
-extern int swapoff(const char*) __nonnull((1));
+int swapon(const char* _Nonnull, int) __INTRODUCED_IN(19);
+int swapoff(const char* _Nonnull) __INTRODUCED_IN(19);
 
 __END_DECLS
 
diff --git a/libc/include/sys/syscall.h b/libc/include/sys/syscall.h
index 21eaf33..a49323d 100644
--- a/libc/include/sys/syscall.h
+++ b/libc/include/sys/syscall.h
@@ -30,7 +30,8 @@
 #define _SYS_SYSCALL_H_
 
 #include <asm/unistd.h> /* Linux kernel __NR_* names. */
-#include <sys/glibc-syscalls.h> /* glibc-compatible SYS_* aliases. */
+#include <bits/glibc-syscalls.h> /* glibc-compatible SYS_* aliases. */
+#include <sys/cdefs.h>
 
 /* The syscall function itself is declared in <unistd.h>, not here. */
 
diff --git a/libc/include/sys/sysconf.h b/libc/include/sys/sysconf.h
index ca32132..eb30faf 100644
--- a/libc/include/sys/sysconf.h
+++ b/libc/include/sys/sysconf.h
@@ -1,195 +1,6 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * This file used to contain the declarations of sysconf and its associated constants.
+ * No standard mentions a <sys/sysconf.h>, but there are enough users in vendor (and potential ones
+ * in the NDK) to warrant not breaking source compatibility.
  */
-#ifndef _SYS_SYSCONF_H_
-#define _SYS_SYSCONF_H_
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/* as listed by Posix sysconf() description */
-/* most of these will return -1 and ENOSYS  */
-
-#define _SC_ARG_MAX             0x0000
-#define _SC_BC_BASE_MAX         0x0001
-#define _SC_BC_DIM_MAX          0x0002
-#define _SC_BC_SCALE_MAX        0x0003
-#define _SC_BC_STRING_MAX       0x0004
-#define _SC_CHILD_MAX           0x0005
-#define _SC_CLK_TCK             0x0006
-#define _SC_COLL_WEIGHTS_MAX    0x0007
-#define _SC_EXPR_NEST_MAX       0x0008
-#define _SC_LINE_MAX            0x0009
-#define _SC_NGROUPS_MAX         0x000a
-#define _SC_OPEN_MAX            0x000b
-#define _SC_PASS_MAX            0x000c
-#define _SC_2_C_BIND            0x000d
-#define _SC_2_C_DEV             0x000e
-#define _SC_2_C_VERSION         0x000f  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_2_CHAR_TERM         0x0010
-#define _SC_2_FORT_DEV          0x0011
-#define _SC_2_FORT_RUN          0x0012
-#define _SC_2_LOCALEDEF         0x0013
-#define _SC_2_SW_DEV            0x0014
-#define _SC_2_UPE               0x0015
-#define _SC_2_VERSION           0x0016
-#define _SC_JOB_CONTROL         0x0017
-#define _SC_SAVED_IDS           0x0018
-#define _SC_VERSION             0x0019
-#define _SC_RE_DUP_MAX          0x001a
-#define _SC_STREAM_MAX          0x001b
-#define _SC_TZNAME_MAX          0x001c
-#define _SC_XOPEN_CRYPT         0x001d
-#define _SC_XOPEN_ENH_I18N      0x001e
-#define _SC_XOPEN_SHM           0x001f
-#define _SC_XOPEN_VERSION       0x0020
-#define _SC_XOPEN_XCU_VERSION   0x0021  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XOPEN_REALTIME      0x0022
-#define _SC_XOPEN_REALTIME_THREADS  0x0023
-#define _SC_XOPEN_LEGACY        0x0024
-#define _SC_ATEXIT_MAX          0x0025
-#define _SC_IOV_MAX             0x0026
-#define _SC_PAGESIZE            0x0027
-#define _SC_PAGE_SIZE           0x0028
-#define _SC_XOPEN_UNIX          0x0029
-#define _SC_XBS5_ILP32_OFF32    0x002a  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XBS5_ILP32_OFFBIG   0x002b  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XBS5_LP64_OFF64     0x002c  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XBS5_LPBIG_OFFBIG   0x002d  /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_AIO_LISTIO_MAX      0x002e
-#define _SC_AIO_MAX             0x002f
-#define _SC_AIO_PRIO_DELTA_MAX  0x0030
-#define _SC_DELAYTIMER_MAX      0x0031
-#define _SC_MQ_OPEN_MAX         0x0032
-#define _SC_MQ_PRIO_MAX         0x0033
-#define _SC_RTSIG_MAX           0x0034
-#define _SC_SEM_NSEMS_MAX       0x0035
-#define _SC_SEM_VALUE_MAX       0x0036
-#define _SC_SIGQUEUE_MAX        0x0037
-#define _SC_TIMER_MAX           0x0038
-#define _SC_ASYNCHRONOUS_IO     0x0039
-#define _SC_FSYNC               0x003a
-#define _SC_MAPPED_FILES        0x003b
-#define _SC_MEMLOCK             0x003c
-#define _SC_MEMLOCK_RANGE       0x003d
-#define _SC_MEMORY_PROTECTION   0x003e
-#define _SC_MESSAGE_PASSING     0x003f
-#define _SC_PRIORITIZED_IO      0x0040
-#define _SC_PRIORITY_SCHEDULING 0x0041
-#define _SC_REALTIME_SIGNALS    0x0042
-#define _SC_SEMAPHORES          0x0043
-#define _SC_SHARED_MEMORY_OBJECTS  0x0044
-#define _SC_SYNCHRONIZED_IO     0x0045
-#define _SC_TIMERS              0x0046
-#define _SC_GETGR_R_SIZE_MAX    0x0047
-#define _SC_GETPW_R_SIZE_MAX    0x0048
-#define _SC_LOGIN_NAME_MAX      0x0049
-#define _SC_THREAD_DESTRUCTOR_ITERATIONS  0x004a
-#define _SC_THREAD_KEYS_MAX     0x004b
-#define _SC_THREAD_STACK_MIN    0x004c
-#define _SC_THREAD_THREADS_MAX  0x004d
-#define _SC_TTY_NAME_MAX        0x004e
-
-#define _SC_THREADS                     0x004f
-#define _SC_THREAD_ATTR_STACKADDR       0x0050
-#define _SC_THREAD_ATTR_STACKSIZE       0x0051
-#define _SC_THREAD_PRIORITY_SCHEDULING  0x0052
-#define _SC_THREAD_PRIO_INHERIT         0x0053
-#define _SC_THREAD_PRIO_PROTECT         0x0054
-#define _SC_THREAD_SAFE_FUNCTIONS       0x0055
-
-#define _SC_NPROCESSORS_CONF            0x0060
-#define _SC_NPROCESSORS_ONLN            0x0061
-#define _SC_PHYS_PAGES                  0x0062
-#define _SC_AVPHYS_PAGES                0x0063
-#define _SC_MONOTONIC_CLOCK             0x0064
-
-#define _SC_2_PBS               0x0065
-#define _SC_2_PBS_ACCOUNTING    0x0066
-#define _SC_2_PBS_CHECKPOINT    0x0067
-#define _SC_2_PBS_LOCATE        0x0068
-#define _SC_2_PBS_MESSAGE       0x0069
-#define _SC_2_PBS_TRACK         0x006a
-#define _SC_ADVISORY_INFO       0x006b
-#define _SC_BARRIERS            0x006c
-#define _SC_CLOCK_SELECTION     0x006d
-#define _SC_CPUTIME             0x006e
-#define _SC_HOST_NAME_MAX       0x006f
-#define _SC_IPV6                0x0070
-#define _SC_RAW_SOCKETS         0x0071
-#define _SC_READER_WRITER_LOCKS 0x0072
-#define _SC_REGEXP              0x0073
-#define _SC_SHELL               0x0074
-#define _SC_SPAWN               0x0075
-#define _SC_SPIN_LOCKS          0x0076
-#define _SC_SPORADIC_SERVER     0x0077
-#define _SC_SS_REPL_MAX         0x0078
-#define _SC_SYMLOOP_MAX         0x0079
-#define _SC_THREAD_CPUTIME      0x007a
-#define _SC_THREAD_PROCESS_SHARED       0x007b
-#define _SC_THREAD_ROBUST_PRIO_INHERIT  0x007c
-#define _SC_THREAD_ROBUST_PRIO_PROTECT  0x007d
-#define _SC_THREAD_SPORADIC_SERVER      0x007e
-#define _SC_TIMEOUTS            0x007f
-#define _SC_TRACE               0x0080
-#define _SC_TRACE_EVENT_FILTER  0x0081
-#define _SC_TRACE_EVENT_NAME_MAX  0x0082
-#define _SC_TRACE_INHERIT       0x0083
-#define _SC_TRACE_LOG           0x0084
-#define _SC_TRACE_NAME_MAX      0x0085
-#define _SC_TRACE_SYS_MAX       0x0086
-#define _SC_TRACE_USER_EVENT_MAX  0x0087
-#define _SC_TYPED_MEMORY_OBJECTS  0x0088
-#define _SC_V7_ILP32_OFF32      0x0089
-#define _SC_V7_ILP32_OFFBIG     0x008a
-#define _SC_V7_LP64_OFF64       0x008b
-#define _SC_V7_LPBIG_OFFBIG     0x008c
-#define _SC_XOPEN_STREAMS       0x008d
-#define _SC_XOPEN_UUCP          0x008e
-
-#define _SC_LEVEL1_ICACHE_SIZE      0x008f
-#define _SC_LEVEL1_ICACHE_ASSOC     0x0090
-#define _SC_LEVEL1_ICACHE_LINESIZE  0x0091
-#define _SC_LEVEL1_DCACHE_SIZE      0x0092
-#define _SC_LEVEL1_DCACHE_ASSOC     0x0093
-#define _SC_LEVEL1_DCACHE_LINESIZE  0x0094
-#define _SC_LEVEL2_CACHE_SIZE       0x0095
-#define _SC_LEVEL2_CACHE_ASSOC      0x0096
-#define _SC_LEVEL2_CACHE_LINESIZE   0x0097
-#define _SC_LEVEL3_CACHE_SIZE       0x0098
-#define _SC_LEVEL3_CACHE_ASSOC      0x0099
-#define _SC_LEVEL3_CACHE_LINESIZE   0x009a
-#define _SC_LEVEL4_CACHE_SIZE       0x009b
-#define _SC_LEVEL4_CACHE_ASSOC      0x009c
-#define _SC_LEVEL4_CACHE_LINESIZE   0x009d
-
-long sysconf(int);
-
-__END_DECLS
-
-#endif /* _SYS_SYSCONF_H_ */
+#include <bits/sysconf.h>
diff --git a/libc/include/sys/sysinfo.h b/libc/include/sys/sysinfo.h
index b66bc8e..9a10d64 100644
--- a/libc/include/sys/sysinfo.h
+++ b/libc/include/sys/sysinfo.h
@@ -35,13 +35,13 @@
 
 int sysinfo(struct sysinfo* info);
 
-int get_nprocs_conf(void);
+int get_nprocs_conf(void) __INTRODUCED_IN(23);
 
-int get_nprocs(void);
+int get_nprocs(void) __INTRODUCED_IN(23);
 
-long get_phys_pages(void);
+long get_phys_pages(void) __INTRODUCED_IN(23);
 
-long get_avphys_pages(void);
+long get_avphys_pages(void) __INTRODUCED_IN(23);
 
 __END_DECLS
 
diff --git a/libc/include/sys/sysmacros.h b/libc/include/sys/sysmacros.h
index 54e43dd..592cc5e 100644
--- a/libc/include/sys/sysmacros.h
+++ b/libc/include/sys/sysmacros.h
@@ -29,6 +29,8 @@
 #ifndef _SYS_SYSMACROS_H_
 #define _SYS_SYSMACROS_H_
 
+#include <sys/cdefs.h>
+
 #define makedev(__major, __minor) \
   ( \
     (((__major) & 0xfffff000ULL) << 32) | (((__major) & 0xfffULL) << 8) | \
diff --git a/libc/include/sys/system_properties.h b/libc/include/sys/system_properties.h
index 01c3db3..d3e0d8d 100644
--- a/libc/include/sys/system_properties.h
+++ b/libc/include/sys/system_properties.h
@@ -48,7 +48,7 @@
 
 /* Set a system property by name.
 **/
-int __system_property_set(const char *key, const char *value);
+int __system_property_set(const char* key, const char* value) __INTRODUCED_IN(12);
 
 /* Return a pointer to the system property named name, if it
 ** exists, or NULL if there is no such property.  Use 
@@ -93,9 +93,8 @@
 ** Order of results may change from call to call.  This is
 ** not a bug.
 */
-int __system_property_foreach(
-        void (*propfn)(const prop_info *pi, void *cookie),
-        void *cookie);
+int __system_property_foreach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie)
+  __INTRODUCED_IN(19);
 
 __END_DECLS
 
diff --git a/libc/include/sys/time.h b/libc/include/sys/time.h
index f60c905..ad5844a 100644
--- a/libc/include/sys/time.h
+++ b/libc/include/sys/time.h
@@ -38,13 +38,22 @@
 
 __BEGIN_DECLS
 
-extern int gettimeofday(struct timeval *, struct timezone *);
-extern int settimeofday(const struct timeval *, const struct timezone *);
+int gettimeofday(struct timeval*, struct timezone*);
+int settimeofday(const struct timeval*, const struct timezone*);
 
-extern int getitimer(int, struct itimerval *);
-extern int setitimer(int, const struct itimerval *, struct itimerval *);
+int getitimer(int, struct itimerval*);
+int setitimer(int, const struct itimerval*, struct itimerval*);
 
-extern int utimes(const char *, const struct timeval *);
+int utimes(const char*, const struct timeval*);
+
+#if defined(__USE_BSD)
+int futimes(int, const struct timeval[2]) __INTRODUCED_IN_FUTURE;
+int lutimes(const char*, const struct timeval[2]) __INTRODUCED_IN_FUTURE;
+#endif
+
+#if defined(__USE_GNU)
+int futimesat(int, const char*, const struct timeval[2]) __INTRODUCED_IN_FUTURE;
+#endif
 
 #define timerclear(a)   \
         ((a)->tv_sec = (a)->tv_usec = 0)
diff --git a/libc/include/sys/timerfd.h b/libc/include/sys/timerfd.h
index 1aa97b4..a500060 100644
--- a/libc/include/sys/timerfd.h
+++ b/libc/include/sys/timerfd.h
@@ -31,6 +31,7 @@
 
 #include <fcntl.h> /* For O_CLOEXEC and O_NONBLOCK. */
 #include <time.h>
+#include <sys/cdefs.h>
 #include <sys/types.h>
 
 __BEGIN_DECLS
@@ -41,10 +42,9 @@
 #define TFD_CLOEXEC O_CLOEXEC
 #define TFD_NONBLOCK O_NONBLOCK
 
-extern int timerfd_create(clockid_t, int);
-extern int timerfd_settime(int, int, const struct itimerspec*,
-                           struct itimerspec*);
-extern int timerfd_gettime(int, struct itimerspec*);
+int timerfd_create(clockid_t, int) __INTRODUCED_IN(19);
+int timerfd_settime(int, int, const struct itimerspec*, struct itimerspec*) __INTRODUCED_IN(19);
+int timerfd_gettime(int, struct itimerspec*) __INTRODUCED_IN(19);
 
 __END_DECLS
 
diff --git a/libc/include/sys/times.h b/libc/include/sys/times.h
index 6ce5b55..f52db1f 100644
--- a/libc/include/sys/times.h
+++ b/libc/include/sys/times.h
@@ -35,7 +35,7 @@
 
 __BEGIN_DECLS
 
-extern clock_t times(struct tms*);
+clock_t times(struct tms*);
 
 __END_DECLS
 
diff --git a/libc/include/sys/timex.h b/libc/include/sys/timex.h
index fade5c3..f704ce8 100644
--- a/libc/include/sys/timex.h
+++ b/libc/include/sys/timex.h
@@ -35,8 +35,8 @@
 
 __BEGIN_DECLS
 
-int adjtimex(struct timex*);
-int clock_adjtime(clockid_t, struct timex*);
+int adjtimex(struct timex*) __INTRODUCED_IN(24);
+int clock_adjtime(clockid_t, struct timex*) __INTRODUCED_IN(24);
 
 __END_DECLS
 
diff --git a/libc/include/sys/ttychars.h b/libc/include/sys/ttychars.h
deleted file mode 100644
index e69de29..0000000
--- a/libc/include/sys/ttychars.h
+++ /dev/null
diff --git a/libc/include/sys/ttydefaults.h b/libc/include/sys/ttydefaults.h
index 405e759..62af84b 100644
--- a/libc/include/sys/ttydefaults.h
+++ b/libc/include/sys/ttydefaults.h
@@ -42,6 +42,8 @@
 #ifndef _SYS_TTYDEFAULTS_H_
 #define	_SYS_TTYDEFAULTS_H_
 
+#include <sys/cdefs.h>
+
 /*
  * Defaults on "first" open.
  */
@@ -84,7 +86,6 @@
 /*
  * #define TTYDEFCHARS to include an array of default control characters.
  */
-#ifdef _KERNEL
 #ifdef TTYDEFCHARS
 const cc_t ttydefchars[NCCS] = {
 	[VEOF] = CEOF,
@@ -109,7 +110,4 @@
 	[19] = _POSIX_VDISABLE,	/* spare */
 };
 #undef TTYDEFCHARS
-#else
-extern const cc_t ttydefchars[NCCS];
 #endif
-#endif /* _KERNEL */
diff --git a/libc/include/sys/ttydev.h b/libc/include/sys/ttydev.h
deleted file mode 100644
index e69de29..0000000
--- a/libc/include/sys/ttydev.h
+++ /dev/null
diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h
index 217fd60..8188f89 100644
--- a/libc/include/sys/types.h
+++ b/libc/include/sys/types.h
@@ -35,6 +35,8 @@
 #include <linux/types.h>
 #include <linux/posix_types.h>
 
+#include <bits/pthread_types.h>
+
 /* gids, uids, and pids are all 32-bit. */
 typedef __kernel_gid32_t __gid_t;
 typedef __gid_t gid_t;
@@ -66,6 +68,8 @@
 typedef __kernel_ino_t __ino_t;
 typedef __ino_t ino_t;
 
+typedef uint64_t ino64_t;
+
 typedef uint32_t __nlink_t;
 typedef __nlink_t nlink_t;
 
@@ -139,7 +143,7 @@
 typedef unsigned int        uint_t;
 typedef unsigned int        uint;
 
-#ifdef __BSD_VISIBLE
+#if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
 #include <sys/sysmacros.h>
 
 typedef unsigned char  u_char;
diff --git a/libc/include/sys/ucontext.h b/libc/include/sys/ucontext.h
index 9e3c653..fdb3015 100644
--- a/libc/include/sys/ucontext.h
+++ b/libc/include/sys/ucontext.h
@@ -30,6 +30,7 @@
 #define _SYS_UCONTEXT_H_
 
 #include <signal.h>
+#include <sys/cdefs.h>
 #include <sys/user.h>
 
 __BEGIN_DECLS
@@ -70,9 +71,9 @@
   stack_t uc_stack;
   mcontext_t uc_mcontext;
   sigset_t uc_sigmask;
-  // Android has a wrong (smaller) sigset_t on ARM.
+  /* Android has a wrong (smaller) sigset_t on ARM. */
   uint32_t __padding_rt_sigset;
-  // The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM.
+  /* The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM. */
   char __padding[120];
   unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
 } ucontext_t;
@@ -92,7 +93,7 @@
   struct ucontext *uc_link;
   stack_t uc_stack;
   sigset_t uc_sigmask;
-  // The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM64.
+  /* The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM64. */
   char __padding[128 - sizeof(sigset_t)];
   mcontext_t uc_mcontext;
 } ucontext_t;
@@ -157,7 +158,7 @@
   stack_t uc_stack;
   mcontext_t uc_mcontext;
   sigset_t uc_sigmask;
-  // Android has a wrong (smaller) sigset_t on x86.
+  /* Android has a wrong (smaller) sigset_t on x86. */
   uint32_t __padding_rt_sigset;
   struct _libc_fpstate __fpregs_mem;
 } ucontext_t;
diff --git a/libc/include/sys/uio.h b/libc/include/sys/uio.h
index 72675d1..7a009b4 100644
--- a/libc/include/sys/uio.h
+++ b/libc/include/sys/uio.h
@@ -42,16 +42,18 @@
 ssize_t preadv(int, const struct iovec*, int, off_t) __RENAME(preadv64);
 ssize_t pwritev(int, const struct iovec*, int, off_t) __RENAME(pwritev64);
 #else
-ssize_t preadv(int, const struct iovec*, int, off_t);
-ssize_t pwritev(int, const struct iovec*, int, off_t);
+ssize_t preadv(int, const struct iovec*, int, off_t) __INTRODUCED_IN(24);
+ssize_t pwritev(int, const struct iovec*, int, off_t) __INTRODUCED_IN(24);
 #endif
-ssize_t preadv64(int, const struct iovec*, int, off64_t);
-ssize_t pwritev64(int, const struct iovec*, int, off64_t);
+ssize_t preadv64(int, const struct iovec*, int, off64_t) __INTRODUCED_IN(24);
+ssize_t pwritev64(int, const struct iovec*, int, off64_t) __INTRODUCED_IN(24);
 #endif
 
 #if defined(__USE_GNU)
-ssize_t process_vm_readv(pid_t, const struct iovec*, unsigned long, const struct iovec*, unsigned long, unsigned long);
-ssize_t process_vm_writev(pid_t, const struct iovec*, unsigned long, const struct iovec*, unsigned long, unsigned long);
+ssize_t process_vm_readv(pid_t, const struct iovec*, unsigned long, const struct iovec*,
+                         unsigned long, unsigned long) __INTRODUCED_IN(23);
+ssize_t process_vm_writev(pid_t, const struct iovec*, unsigned long, const struct iovec*,
+                          unsigned long, unsigned long) __INTRODUCED_IN(23);
 #endif
 
 __END_DECLS
diff --git a/libc/include/sys/un.h b/libc/include/sys/un.h
index 65ffbdcf..3e1c429 100644
--- a/libc/include/sys/un.h
+++ b/libc/include/sys/un.h
@@ -25,11 +25,12 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_UN_H_
 #define _SYS_UN_H_
 
-typedef unsigned short sa_family_t;
-
+#include <bits/sa_family_t.h>
 #include <linux/un.h>
+#include <sys/cdefs.h>
 
-#endif /* _SYS_UN_H_ */
+#endif
diff --git a/libc/include/sys/user.h b/libc/include/sys/user.h
index 3312981..f9ad956 100644
--- a/libc/include/sys/user.h
+++ b/libc/include/sys/user.h
@@ -31,13 +31,14 @@
 
 #include <sys/cdefs.h>
 #include <stddef.h> /* For size_t. */
+#include <stdint.h>
 
 __BEGIN_DECLS
 
 #define PAGE_SIZE 4096
 #define PAGE_MASK (~(PAGE_SIZE - 1))
 
-#if __i386__
+#if defined(__i386__)
 
 struct user_fpregs_struct {
   long cwd;
@@ -108,13 +109,13 @@
   unsigned short swd;
   unsigned short ftw;
   unsigned short fop;
-  __u64 rip;
-  __u64 rdp;
-  __u32 mxcsr;
-  __u32 mxcr_mask;
-  __u32 st_space[32];
-  __u32 xmm_space[64];
-  __u32 padding[24];
+  unsigned long rip;
+  unsigned long rdp;
+  unsigned int mxcsr;
+  unsigned int mxcr_mask;
+  unsigned int st_space[32];
+  unsigned int xmm_space[64];
+  unsigned int padding[24];
 };
 struct user_regs_struct {
   unsigned long r15;
diff --git a/libc/include/sys/utsname.h b/libc/include/sys/utsname.h
index d54a994..b3856a7 100644
--- a/libc/include/sys/utsname.h
+++ b/libc/include/sys/utsname.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_UTSNAME_H_
 #define _SYS_UTSNAME_H_
 
@@ -43,7 +44,7 @@
     char  domainname[SYS_NMLN];
 };
 
-extern int uname(struct utsname *);
+int uname(struct utsname*);
 
 __END_DECLS
 
diff --git a/libc/include/sys/vfs.h b/libc/include/sys/vfs.h
index 1fbc8be..1231eb1 100644
--- a/libc/include/sys/vfs.h
+++ b/libc/include/sys/vfs.h
@@ -137,10 +137,10 @@
 #define XENIX_SUPER_MAGIC     0x012FF7B4
 #define XFS_SUPER_MAGIC       0x58465342
 
-extern int statfs(const char*, struct statfs*) __nonnull((1, 2));
-extern int statfs64(const char*, struct statfs64*) __nonnull((1, 2));
-extern int fstatfs(int, struct statfs*) __nonnull((2));
-extern int fstatfs64(int, struct statfs64*) __nonnull((2));
+int statfs(const char* _Nonnull, struct statfs* _Nonnull);
+int statfs64(const char* _Nonnull, struct statfs64* _Nonnull) __INTRODUCED_IN(21);
+int fstatfs(int, struct statfs* _Nonnull);
+int fstatfs64(int, struct statfs64* _Nonnull) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h
index 2317b02..f3972fc 100644
--- a/libc/include/sys/wait.h
+++ b/libc/include/sys/wait.h
@@ -49,9 +49,13 @@
 #define W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
 #define W_STOPCODE(sig)         ((sig) << 8 | 0x7f)
 
-extern pid_t  wait(int *);
-extern pid_t  waitpid(pid_t, int *, int);
-extern pid_t  wait4(pid_t, int *, int, struct rusage *);
+pid_t wait(int*);
+pid_t waitpid(pid_t, int*, int);
+#if __ANDROID_API__ >= 18
+pid_t wait4(pid_t, int*, int, struct rusage*) __INTRODUCED_IN(18);
+#else
+// Implemented as a static inline before 18.
+#endif
 
 /* Posix states that idtype_t should be an enumeration type, but
  * the kernel headers define P_ALL, P_PID and P_PGID as constant macros
@@ -59,8 +63,10 @@
  */
 typedef int idtype_t;
 
-extern int  waitid(idtype_t which, id_t id, siginfo_t *info, int options);
+int waitid(idtype_t which, id_t id, siginfo_t* info, int options);
 
 __END_DECLS
 
+#include <android/legacy_sys_wait_inlines.h>
+
 #endif /* _SYS_WAIT_H_ */
diff --git a/libc/include/sys/xattr.h b/libc/include/sys/xattr.h
index 39b25b1..37e352d 100644
--- a/libc/include/sys/xattr.h
+++ b/libc/include/sys/xattr.h
@@ -25,31 +25,34 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_XATTR_H_
 #define _SYS_XATTR_H_
 
+#include <linux/xattr.h>
+#include <sys/cdefs.h>
 #include <sys/types.h>
 
 __BEGIN_DECLS
 
-#define XATTR_CREATE 1
-#define XATTR_REPLACE 2
+int fsetxattr(int fd, const char* name, const void* value, size_t size, int flags)
+  __INTRODUCED_IN(16);
+int setxattr(const char* path, const char* name, const void* value, size_t size, int flags)
+  __INTRODUCED_IN(16);
+int lsetxattr(const char* path, const char* name, const void* value, size_t size, int flags)
+  __INTRODUCED_IN(16);
 
-extern int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags);
-extern int setxattr(const char *path, const char *name, const void *value, size_t size, int flags);
-extern int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags);
+ssize_t fgetxattr(int fd, const char* name, void* value, size_t size) __INTRODUCED_IN(16);
+ssize_t getxattr(const char* path, const char* name, void* value, size_t size) __INTRODUCED_IN(16);
+ssize_t lgetxattr(const char* path, const char* name, void* value, size_t size) __INTRODUCED_IN(16);
 
-extern ssize_t fgetxattr(int fd, const char *name, void *value, size_t size);
-extern ssize_t getxattr(const char *path, const char *name, void *value, size_t size);
-extern ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size);
+ssize_t listxattr(const char* path, char* list, size_t size) __INTRODUCED_IN(16);
+ssize_t llistxattr(const char* path, char* list, size_t size) __INTRODUCED_IN(16);
+ssize_t flistxattr(int fd, char* list, size_t size) __INTRODUCED_IN(16);
 
-extern ssize_t listxattr(const char *path, char *list, size_t size);
-extern ssize_t llistxattr(const char *path, char *list, size_t size);
-extern ssize_t flistxattr(int fd, char *list, size_t size);
-
-extern int removexattr(const char *path, const char *name);
-extern int lremovexattr(const char *path, const char *name);
-extern int fremovexattr(int fd, const char *name);
+int removexattr(const char* path, const char* name) __INTRODUCED_IN(16);
+int lremovexattr(const char* path, const char* name) __INTRODUCED_IN(16);
+int fremovexattr(int fd, const char* name) __INTRODUCED_IN(16);
 
 __END_DECLS
 
diff --git a/libc/include/sysexits.h b/libc/include/sysexits.h
index e244836..97f5366 100644
--- a/libc/include/sysexits.h
+++ b/libc/include/sysexits.h
@@ -35,6 +35,8 @@
 #ifndef	_SYSEXITS_H_
 #define	_SYSEXITS_H_
 
+#include <sys/cdefs.h>
+
 /*
  *  SYSEXITS.H -- Exit status codes for system programs.
  *
diff --git a/libc/include/syslog.h b/libc/include/syslog.h
index 8000f03..ee288e5 100644
--- a/libc/include/syslog.h
+++ b/libc/include/syslog.h
@@ -86,10 +86,10 @@
 #define LOG_PERROR 0x20
 
 void closelog(void);
-void openlog(const char*, int, int);
+void openlog(const char* _Nullable, int, int);
 int setlogmask(int);
-void syslog(int, const char*, ...) __printflike(2, 3);
-void vsyslog(int, const char*, va_list) __printflike(2, 0);
+void syslog(int, const char* _Nonnull, ...) __printflike(2, 3);
+void vsyslog(int, const char* _Nonnull, va_list) __printflike(2, 0);
 
 __END_DECLS
 
diff --git a/libc/bionic/__fread_chk.cpp b/libc/include/tar.h
similarity index 68%
copy from libc/bionic/__fread_chk.cpp
copy to libc/include/tar.h
index afc8d90..a5d7a36 100644
--- a/libc/bionic/__fread_chk.cpp
+++ b/libc/include/tar.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,22 +26,37 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
-#include <stdio.h>
+#ifndef _TAR_H_
+#define _TAR_H_
+
 #include <sys/cdefs.h>
-#include "private/libc_logging.h"
 
-extern "C" size_t __fread_chk(void * __restrict buf, size_t size, size_t count,
-                              FILE * __restrict stream, size_t buf_size) {
-  size_t total;
-  if (__predict_false(__size_mul_overflow(size, count, &total))) {
-    // overflow: trigger the error path in fread
-    return fread(buf, size, count, stream);
-  }
+#define TMAGIC "ustar"
+#define TMAGLEN 6
+#define TVERSION "00"
+#define TVERSLEN 2
 
-  if (__predict_false(total > buf_size)) {
-    __fortify_chk_fail("fread: prevented write past end of buffer", 0);
-  }
+#define REGTYPE '0'
+#define AREGTYPE '\0'
+#define LNKTYPE '1'
+#define SYMTYPE '2'
+#define CHRTYPE '3'
+#define BLKTYPE '4'
+#define DIRTYPE '5'
+#define FIFOTYPE '6'
+#define CONTTYPE '7'
 
-  return fread(buf, size, count, stream);
-}
+#define TSUID 04000
+#define TSGID 02000
+#define TSVTX 01000
+#define TUREAD 00400
+#define TUWRITE 00200
+#define TUEXEC 00100
+#define TGREAD 00040
+#define TGWRITE 00020
+#define TGEXEC 00010
+#define TOREAD 00004
+#define TOWRITE 00002
+#define TOEXEC 00001
+
+#endif /* _TAR_H_ */
diff --git a/libc/include/termio.h b/libc/include/termio.h
index 99d3630..9e26956 100644
--- a/libc/include/termio.h
+++ b/libc/include/termio.h
@@ -1,32 +1 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* All definitions related to termio are in Linux kernel headers
- * that are already included by <termios.h>
- */
 #include <termios.h>
diff --git a/libc/include/termios.h b/libc/include/termios.h
index 683fde2..c17794c 100644
--- a/libc/include/termios.h
+++ b/libc/include/termios.h
@@ -36,23 +36,25 @@
 __BEGIN_DECLS
 
 #if __ANDROID_API__ >= 21
-speed_t cfgetispeed(const struct termios*);
-speed_t cfgetospeed(const struct termios*);
-void cfmakeraw(struct termios*);
-int cfsetispeed(struct termios*, speed_t);
-int cfsetospeed(struct termios*, speed_t);
-int cfsetspeed(struct termios*, speed_t);
-int tcdrain(int);
-int tcflow(int, int);
-int tcflush(int, int);
-int tcgetattr(int, struct termios*);
-pid_t tcgetsid(int);
-int tcsendbreak(int, int);
-int tcsetattr(int, int, const struct termios*);
-#else
-#include <android/legacy_termios_inlines.h>
+// Implemented as static inlines before 21.
+speed_t cfgetispeed(const struct termios*) __INTRODUCED_IN(21);
+speed_t cfgetospeed(const struct termios*) __INTRODUCED_IN(21);
+void cfmakeraw(struct termios*) __INTRODUCED_IN(21);
+int cfsetispeed(struct termios*, speed_t) __INTRODUCED_IN(21);
+int cfsetospeed(struct termios*, speed_t) __INTRODUCED_IN(21);
+int tcflow(int, int) __INTRODUCED_IN(21);
+int tcflush(int, int) __INTRODUCED_IN(21);
+int tcgetattr(int, struct termios*) __INTRODUCED_IN(21);
+pid_t tcgetsid(int) __INTRODUCED_IN(21);
+int tcsendbreak(int, int) __INTRODUCED_IN(21);
+int tcsetattr(int, int, const struct termios*) __INTRODUCED_IN(21);
 #endif
 
+int cfsetspeed(struct termios*, speed_t) __INTRODUCED_IN(21);
+int tcdrain(int) __INTRODUCED_IN(21);
+
 __END_DECLS
 
+#include <android/legacy_termios_inlines.h>
+
 #endif /* _TERMIOS_H_ */
diff --git a/libc/include/time.h b/libc/include/time.h
index 1b0f6a1..37246b4 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -37,9 +37,9 @@
 
 #define CLOCKS_PER_SEC 1000000
 
-extern char* tzname[] __LIBC_ABI_PUBLIC__;
-extern int daylight __LIBC_ABI_PUBLIC__;
-extern long int timezone __LIBC_ABI_PUBLIC__;
+extern char* tzname[];
+extern int daylight;
+extern long int timezone;
 
 struct sigevent;
 
@@ -59,48 +59,53 @@
 
 #define TM_ZONE tm_zone
 
-extern time_t time(time_t*) __LIBC_ABI_PUBLIC__;
-extern int nanosleep(const struct timespec*, struct timespec*) __LIBC_ABI_PUBLIC__;
+time_t time(time_t*);
+int nanosleep(const struct timespec*, struct timespec*);
 
-extern char* asctime(const struct tm*) __LIBC_ABI_PUBLIC__;
-extern char* asctime_r(const struct tm*, char*) __LIBC_ABI_PUBLIC__;
+char* asctime(const struct tm*);
+char* asctime_r(const struct tm*, char*);
 
-extern double difftime(time_t, time_t) __LIBC_ABI_PUBLIC__;
-extern time_t mktime(struct tm*) __LIBC_ABI_PUBLIC__;
+double difftime(time_t, time_t);
+time_t mktime(struct tm*);
 
-extern struct tm* localtime(const time_t*) __LIBC_ABI_PUBLIC__;
-extern struct tm* localtime_r(const time_t*, struct tm*) __LIBC_ABI_PUBLIC__;
+struct tm* localtime(const time_t*);
+struct tm* localtime_r(const time_t*, struct tm*);
 
-extern struct tm* gmtime(const time_t*) __LIBC_ABI_PUBLIC__;
-extern struct tm* gmtime_r(const time_t*, struct tm*) __LIBC_ABI_PUBLIC__;
+struct tm* gmtime(const time_t*);
+struct tm* gmtime_r(const time_t*, struct tm*);
 
-extern char* strptime(const char*, const char*, struct tm*) __LIBC_ABI_PUBLIC__;
-extern size_t strftime(char*, size_t, const char*, const struct tm*) __LIBC_ABI_PUBLIC__;
-extern size_t strftime_l(char *, size_t, const char *, const struct tm *, locale_t) __LIBC_ABI_PUBLIC__;
+char* strptime(const char*, const char*, struct tm*);
+size_t strftime(char*, size_t, const char*, const struct tm*);
 
-extern char* ctime(const time_t*) __LIBC_ABI_PUBLIC__;
-extern char* ctime_r(const time_t*, char*) __LIBC_ABI_PUBLIC__;
+#if __ANDROID_API__ >= 21
+size_t strftime_l(char*, size_t, const char*, const struct tm*, locale_t) __INTRODUCED_IN(21);
+#else
+// Implemented as static inline before 21.
+#endif
 
-extern void tzset(void) __LIBC_ABI_PUBLIC__;
+char* ctime(const time_t*);
+char* ctime_r(const time_t*, char*);
 
-extern clock_t clock(void) __LIBC_ABI_PUBLIC__;
+void tzset(void);
 
-extern int clock_getcpuclockid(pid_t, clockid_t*) __LIBC_ABI_PUBLIC__;
+clock_t clock(void);
 
-extern int clock_getres(clockid_t, struct timespec*) __LIBC_ABI_PUBLIC__;
-extern int clock_gettime(clockid_t, struct timespec*) __LIBC_ABI_PUBLIC__;
-extern int clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*) __LIBC_ABI_PUBLIC__;
-extern int clock_settime(clockid_t, const struct timespec*) __LIBC_ABI_PUBLIC__;
+int clock_getcpuclockid(pid_t, clockid_t*) __INTRODUCED_IN(23);
 
-extern int timer_create(int, struct sigevent*, timer_t*) __LIBC_ABI_PUBLIC__;
-extern int timer_delete(timer_t) __LIBC_ABI_PUBLIC__;
-extern int timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*) __LIBC_ABI_PUBLIC__;
-extern int timer_gettime(timer_t, struct itimerspec*) __LIBC_ABI_PUBLIC__;
-extern int timer_getoverrun(timer_t) __LIBC_ABI_PUBLIC__;
+int clock_getres(clockid_t, struct timespec*);
+int clock_gettime(clockid_t, struct timespec*);
+int clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*);
+int clock_settime(clockid_t, const struct timespec*);
+
+int timer_create(int, struct sigevent*, timer_t*);
+int timer_delete(timer_t);
+int timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*);
+int timer_gettime(timer_t, struct itimerspec*);
+int timer_getoverrun(timer_t);
 
 /* Non-standard extensions that are in the BSDs and glibc. */
-extern time_t timelocal(struct tm*) __LIBC_ABI_PUBLIC__;
-extern time_t timegm(struct tm*) __LIBC_ABI_PUBLIC__;
+time_t timelocal(struct tm*) __INTRODUCED_IN(12);
+time_t timegm(struct tm*) __INTRODUCED_IN(12);
 
 __END_DECLS
 
diff --git a/libc/include/uchar.h b/libc/include/uchar.h
index a5e72ea..818acb1 100644
--- a/libc/include/uchar.h
+++ b/libc/include/uchar.h
@@ -29,12 +29,13 @@
 #ifndef _UCHAR_H_
 #define _UCHAR_H_
 
+#include <stddef.h>
 #include <sys/cdefs.h>
-#include <wchar.h>
+#include <bits/mbstate_t.h>
 
 __BEGIN_DECLS
 
-#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
+#if !defined(__cplusplus)
 typedef __CHAR16_TYPE__ char16_t;
 typedef __CHAR32_TYPE__ char32_t;
 #endif
@@ -42,16 +43,12 @@
 #define __STD_UTF_16__ 1
 #define __STD_UTF_32__ 1
 
-size_t c16rtomb(char* __restrict, char16_t, mbstate_t* __restrict);
-size_t c32rtomb(char* __restrict, char32_t, mbstate_t* __restrict);
-size_t mbrtoc16(char16_t* __restrict,
-                const char* __restrict,
-                size_t,
-                mbstate_t* __restrict);
-size_t mbrtoc32(char32_t* __restrict,
-                const char* __restrict,
-                size_t,
-                mbstate_t* __restrict);
+size_t c16rtomb(char* __restrict, char16_t, mbstate_t* __restrict) __INTRODUCED_IN(21);
+size_t c32rtomb(char* __restrict, char32_t, mbstate_t* __restrict) __INTRODUCED_IN(21);
+size_t mbrtoc16(char16_t* __restrict, const char* __restrict, size_t, mbstate_t* __restrict)
+  __INTRODUCED_IN(21);
+size_t mbrtoc32(char32_t* __restrict, const char* __restrict, size_t, mbstate_t* __restrict)
+  __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/ucontext.h b/libc/include/ucontext.h
index 5ea2982..73c2166 100644
--- a/libc/include/ucontext.h
+++ b/libc/include/ucontext.h
@@ -1,34 +1 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _UCONTEXT_H_
-#define _UCONTEXT_H_
-
 #include <sys/ucontext.h>
-
-#endif /* _UCONTEXT_H_ */
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 5045267..130ede6 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -33,10 +33,14 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/select.h>
-#include <sys/sysconf.h>
 
+#include <bits/fcntl.h>
+#include <bits/getopt.h>
+#include <bits/ioctl.h>
 #include <bits/lockf.h>
 #include <bits/posix_limits.h>
+#include <bits/seek_constants.h>
+#include <bits/sysconf.h>
 
 __BEGIN_DECLS
 
@@ -49,10 +53,6 @@
 #define W_OK 2
 #define R_OK 4
 
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-
 #define _PC_FILESIZEBITS 0
 #define _PC_LINK_MAX 1
 #define _PC_MAX_CANON 2
@@ -76,168 +76,155 @@
 
 extern char** environ;
 
-extern __noreturn void _exit(int __status);
+__noreturn void _exit(int __status);
 
-extern pid_t  fork(void);
-extern pid_t  vfork(void);
-extern pid_t  getpid(void);
-extern pid_t  gettid(void) __pure2;
-extern pid_t  getpgid(pid_t __pid);
-extern int    setpgid(pid_t __pid, pid_t __pgid);
-extern pid_t  getppid(void);
-extern pid_t  getpgrp(void);
-extern int    setpgrp(void);
-extern pid_t  getsid(pid_t __pid) __INTRODUCED_IN(21);
-extern pid_t  setsid(void);
+pid_t  fork(void);
+pid_t  vfork(void);
+pid_t  getpid(void);
+pid_t  gettid(void) __attribute_const__;
+pid_t  getpgid(pid_t __pid);
+int    setpgid(pid_t __pid, pid_t __pgid);
+pid_t  getppid(void);
+pid_t  getpgrp(void);
+int    setpgrp(void);
+pid_t  getsid(pid_t __pid) __INTRODUCED_IN(17);
+pid_t  setsid(void);
 
-extern int execv(const char* __path, char* const* __argv);
-extern int execvp(const char* __file, char* const* __argv);
-extern int execvpe(const char* __file, char* const* __argv, char* const* __envp)
-  __INTRODUCED_IN(21);
-extern int execve(const char* __file, char* const* __argv, char* const* __envp);
-extern int execl(const char* __path, const char* __arg0, ...);
-extern int execlp(const char* __file, const char* __arg0, ...);
-extern int execle(const char* __path, const char* __arg0, ...);
+int execv(const char* __path, char* const* __argv);
+int execvp(const char* __file, char* const* __argv);
+int execvpe(const char* __file, char* const* __argv, char* const* __envp) __INTRODUCED_IN(21);
+int execve(const char* __file, char* const* __argv, char* const* __envp);
+int execl(const char* __path, const char* __arg0, ...) __attribute__((__sentinel__));
+int execlp(const char* __file, const char* __arg0, ...) __attribute__((__sentinel__));
+int execle(const char* __path, const char* __arg0, ... /*,  char* const* __envp */)
+    __attribute__((__sentinel__(1)));
 
-extern int nice(int __incr);
+int nice(int __incr);
 
-extern int setuid(uid_t __uid);
-extern uid_t getuid(void);
-extern int seteuid(uid_t __uid);
-extern uid_t geteuid(void);
-extern int setgid(gid_t __gid);
-extern gid_t getgid(void);
-extern int setegid(gid_t __gid);
-extern gid_t getegid(void);
-extern int getgroups(int __size, gid_t* __list);
-extern int setgroups(size_t __size, const gid_t* __list);
-extern int setreuid(uid_t __ruid, uid_t __euid);
-extern int setregid(gid_t __rgid, gid_t __egid);
-extern int setresuid(uid_t __ruid, uid_t __euid, uid_t __suid);
-extern int setresgid(gid_t __rgid, gid_t __egid, gid_t __sgid);
-extern int getresuid(uid_t* __ruid, uid_t* __euid, uid_t* __suid);
-extern int getresgid(gid_t* __rgid, gid_t* __egid, gid_t* __sgid);
-extern char* getlogin(void);
+int setuid(uid_t __uid);
+uid_t getuid(void);
+int seteuid(uid_t __uid);
+uid_t geteuid(void);
+int setgid(gid_t __gid);
+gid_t getgid(void);
+int setegid(gid_t __gid);
+gid_t getegid(void);
+int getgroups(int __size, gid_t* __list);
+int setgroups(size_t __size, const gid_t* __list);
+int setreuid(uid_t __ruid, uid_t __euid);
+int setregid(gid_t __rgid, gid_t __egid);
+int setresuid(uid_t __ruid, uid_t __euid, uid_t __suid);
+int setresgid(gid_t __rgid, gid_t __egid, gid_t __sgid);
+int getresuid(uid_t* __ruid, uid_t* __euid, uid_t* __suid);
+int getresgid(gid_t* __rgid, gid_t* __egid, gid_t* __sgid);
+char* getlogin(void);
 
-extern long fpathconf(int __fd, int __name);
-extern long pathconf(const char* __path, int __name);
+long fpathconf(int __fd, int __name);
+long pathconf(const char* __path, int __name);
 
-extern int access(const char* __path, int __mode);
-extern int faccessat(int __dirfd, const char* __path, int __mode, int __flags)
-  __INTRODUCED_IN(21);
-extern int link(const char* __oldpath, const char* __newpath);
-extern int linkat(int __olddirfd, const char* __oldpath, int __newdirfd,
-                  const char* __newpath, int __flags) __INTRODUCED_IN(21);
-extern int unlink(const char* __path);
-extern int unlinkat(int __dirfd, const char* __path, int __flags);
-extern int chdir(const char* __path);
-extern int fchdir(int __fd);
-extern int rmdir(const char* __path);
-extern int pipe(int* __pipefd);
+int access(const char* __path, int __mode);
+int faccessat(int __dirfd, const char* __path, int __mode, int __flags) __INTRODUCED_IN(16);
+int link(const char* __oldpath, const char* __newpath);
+int linkat(int __olddirfd, const char* __oldpath, int __newdirfd,
+           const char* __newpath, int __flags) __INTRODUCED_IN(21);
+int unlink(const char* __path);
+int unlinkat(int __dirfd, const char* __path, int __flags);
+int chdir(const char* __path);
+int fchdir(int __fd);
+int rmdir(const char* __path);
+int pipe(int* __pipefd);
 #if defined(__USE_GNU)
-extern int pipe2(int* __pipefd, int __flags) __INTRODUCED_IN(9);
+int pipe2(int* __pipefd, int __flags) __INTRODUCED_IN(9);
 #endif
-extern int chroot(const char* __path);
-extern int symlink(const char* __oldpath, const char* __newpath);
-extern int symlinkat(const char* __oldpath, int __newdirfd,
-                     const char* __newpath) __INTRODUCED_IN(21);
-extern ssize_t readlink(const char* __path, char* __buf, size_t __bufsiz);
-extern ssize_t readlinkat(int __dirfd, const char* __path, char* __buf,
-                          size_t __bufsiz) __INTRODUCED_IN(21);
-extern int chown(const char* __path, uid_t __owner, gid_t __group);
-extern int fchown(int __fd, uid_t __owner, gid_t __group);
-extern int fchownat(int __dirfd, const char* __path, uid_t __owner,
-                    gid_t __group, int __flags);
-extern int lchown(const char* __path, uid_t __owner, gid_t __group);
-extern char* getcwd(char* __buf, size_t __size);
+int chroot(const char* __path);
+int symlink(const char* __oldpath, const char* __newpath);
+int symlinkat(const char* __oldpath, int __newdirfd, const char* __newpath) __INTRODUCED_IN(21);
+ssize_t readlink(const char* __path, char* __buf, size_t __bufsiz);
+ssize_t readlinkat(int __dirfd, const char* __path, char* __buf,
+                   size_t __bufsiz) __INTRODUCED_IN(21);
+int chown(const char* __path, uid_t __owner, gid_t __group);
+int fchown(int __fd, uid_t __owner, gid_t __group);
+int fchownat(int __dirfd, const char* __path, uid_t __owner, gid_t __group, int __flags);
+int lchown(const char* __path, uid_t __owner, gid_t __group);
+char* getcwd(char* __buf, size_t __size);
 
-extern int sync(void);
+int sync(void);
 
-extern int close(int __fd);
+int close(int __fd);
 
-extern ssize_t read(int __fd, void* __buf, size_t __count);
-extern ssize_t write(int __fd, const void* __buf, size_t __count);
+ssize_t read(int __fd, void* __buf, size_t __count);
+ssize_t write(int __fd, const void* __buf, size_t __count);
 
-extern int dup(int __oldfd);
-extern int dup2(int __oldfd, int __newfd);
-extern int dup3(int __oldfd, int __newfd, int __flags) __INTRODUCED_IN(21);
-extern int fcntl(int __fd, int __cmd, ...);
-extern int ioctl(int __fd, int __request, ...);
-extern int fsync(int __fd);
-extern int fdatasync(int __fd) __INTRODUCED_IN(9);
+int dup(int __oldfd);
+int dup2(int __oldfd, int __newfd);
+int dup3(int __oldfd, int __newfd, int __flags) __INTRODUCED_IN(21);
+int fsync(int __fd);
+int fdatasync(int __fd) __INTRODUCED_IN(9);
 
 #if defined(__USE_FILE_OFFSET64)
-extern off_t lseek(int __fd, off_t __offset, int __whence) __RENAME(lseek64);
+off_t lseek(int __fd, off_t __offset, int __whence) __RENAME(lseek64);
 #else
-extern off_t lseek(int __fd, off_t __offset, int __whence);
+off_t lseek(int __fd, off_t __offset, int __whence);
 #endif
 
-extern off64_t lseek64(int __fd, off64_t __offset, int __whence);
+off64_t lseek64(int __fd, off64_t __offset, int __whence);
 
 #if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= 21
-extern int truncate(const char* __path, off_t __length) __RENAME(truncate64);
-extern ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset)
-  __RENAME(pread64);
-extern ssize_t pwrite(int __fd, const void* __buf, size_t __count,
-                      off_t __offset) __RENAME(pwrite64);
-extern int ftruncate(int __fd, off_t __length) __RENAME(ftruncate64);
+int truncate(const char* __path, off_t __length) __RENAME(truncate64) __INTRODUCED_IN(21);
+ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset) __RENAME(pread64)
+  __INTRODUCED_IN(12);
+ssize_t pwrite(int __fd, const void* __buf, size_t __count, off_t __offset)
+  __RENAME(pwrite64) __INTRODUCED_IN(12);
+int ftruncate(int __fd, off_t __length) __RENAME(ftruncate64) __INTRODUCED_IN(12);
 #else
-extern int truncate(const char* __path, off_t __length);
-extern ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset);
-extern ssize_t pwrite(int __fd, const void* __buf, size_t __count,
-                      off_t __offset);
-extern int ftruncate(int __fd, off_t __length);
+int truncate(const char* __path, off_t __length);
+ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset);
+ssize_t pwrite(int __fd, const void* __buf, size_t __count, off_t __offset);
+int ftruncate(int __fd, off_t __length);
 #endif
 
-extern int truncate64(const char* __path, off64_t __length) __INTRODUCED_IN(21);
-extern ssize_t pread64(int __fd, void* __buf, size_t __count, off64_t __offset) __INTRODUCED_IN(21);
-extern ssize_t pwrite64(int __fd, const void* __buf, size_t __count,
-                        off64_t __offset) __INTRODUCED_IN(21);
-extern int ftruncate64(int __fd, off64_t __length) __INTRODUCED_IN(21);
+int truncate64(const char* __path, off64_t __length) __INTRODUCED_IN(21);
+ssize_t pread64(int __fd, void* __buf, size_t __count, off64_t __offset) __INTRODUCED_IN(12);
+ssize_t pwrite64(int __fd, const void* __buf, size_t __count, off64_t __offset)
+  __INTRODUCED_IN(12);
+int ftruncate64(int __fd, off64_t __length) __INTRODUCED_IN(12);
 
-extern int pause(void);
-extern unsigned int alarm(unsigned int __seconds);
-extern unsigned int sleep(unsigned int __seconds);
-extern int usleep(useconds_t __usec);
+int pause(void);
+unsigned int alarm(unsigned int __seconds);
+unsigned int sleep(unsigned int __seconds);
+int usleep(useconds_t __usec);
 
 int gethostname(char* __name, size_t __len);
-int sethostname(const char* __name, size_t __len);
+int sethostname(const char* __name, size_t __len) __INTRODUCED_IN(23);
 
-extern void* __brk(void* __addr);
-extern int brk(void* __addr);
-extern void* sbrk(ptrdiff_t __increment);
+int brk(void* __addr);
+void* sbrk(ptrdiff_t __increment);
 
-extern int getopt(int __argc, char* const* __argv, const char* __argstring);
-extern char* optarg;
-extern int optind, opterr, optopt;
+int isatty(int __fd);
+char* ttyname(int __fd);
+int ttyname_r(int __fd, char* __buf, size_t __buflen) __INTRODUCED_IN(8);
 
-extern int isatty(int __fd);
-extern char* ttyname(int __fd);
-extern int ttyname_r(int __fd, char* __buf, size_t __buflen) __INTRODUCED_IN(8);
-
-extern int acct(const char* __filepath);
-
-long sysconf(int __name);
+int acct(const char* __filepath);
 
 #if __ANDROID_API__ >= 21
-int getpagesize(void);
+int getpagesize(void) __INTRODUCED_IN(21);
 #else
-__inline__ int getpagesize(void) {
+static __inline__ int getpagesize(void) {
   return sysconf(_SC_PAGESIZE);
 }
 #endif
 
 long syscall(long __number, ...);
 
-extern int daemon(int __nochdir, int __noclose);
+int daemon(int __nochdir, int __noclose);
 
 #if defined(__arm__) || (defined(__mips__) && !defined(__LP64__))
-extern int cacheflush(long __addr, long __nbytes, long __cache);
+int cacheflush(long __addr, long __nbytes, long __cache);
     /* __attribute__((deprecated("use __builtin___clear_cache instead"))); */
 #endif
 
-extern pid_t tcgetpgrp(int __fd);
-extern int tcsetpgrp(int __fd, pid_t __pid);
+pid_t tcgetpgrp(int __fd);
+int tcsetpgrp(int __fd, pid_t __pid);
 
 /* Used to retry syscalls that can return EINTR. */
 #define TEMP_FAILURE_RETRY(exp) ({         \
@@ -248,52 +235,56 @@
     _rc; })
 
 /* TODO(unified-headers): Factor out all the FORTIFY features. */
-extern char* __getcwd_chk(char*, size_t, size_t);
+char* __getcwd_chk(char*, size_t, size_t) __INTRODUCED_IN(24);
 __errordecl(__getcwd_dest_size_error, "getcwd called with size bigger than destination");
-extern char* __getcwd_real(char*, size_t) __RENAME(getcwd);
+char* __getcwd_real(char*, size_t) __RENAME(getcwd);
 
-extern ssize_t __pread_chk(int, void*, size_t, off_t, size_t);
+ssize_t __pread_chk(int, void*, size_t, off_t, size_t) __INTRODUCED_IN(23);
 __errordecl(__pread_dest_size_error, "pread called with size bigger than destination");
 __errordecl(__pread_count_toobig_error, "pread called with count > SSIZE_MAX");
-extern ssize_t __pread_real(int, void*, size_t, off_t) __RENAME(pread);
+ssize_t __pread_real(int, void*, size_t, off_t) __RENAME(pread);
 
-extern ssize_t __pread64_chk(int, void*, size_t, off64_t, size_t);
+ssize_t __pread64_chk(int, void*, size_t, off64_t, size_t) __INTRODUCED_IN(23);
 __errordecl(__pread64_dest_size_error, "pread64 called with size bigger than destination");
 __errordecl(__pread64_count_toobig_error, "pread64 called with count > SSIZE_MAX");
-extern ssize_t __pread64_real(int, void*, size_t, off64_t) __RENAME(pread64);
+ssize_t __pread64_real(int, void*, size_t, off64_t) __RENAME(pread64) __INTRODUCED_IN(12);
 
-extern ssize_t __pwrite_chk(int, const void*, size_t, off_t, size_t);
+ssize_t __pwrite_chk(int, const void*, size_t, off_t, size_t) __INTRODUCED_IN(24);
 __errordecl(__pwrite_dest_size_error, "pwrite called with size bigger than destination");
 __errordecl(__pwrite_count_toobig_error, "pwrite called with count > SSIZE_MAX");
-extern ssize_t __pwrite_real(int, const void*, size_t, off_t) __RENAME(pwrite);
+ssize_t __pwrite_real(int, const void*, size_t, off_t) __RENAME(pwrite);
 
-extern ssize_t __pwrite64_chk(int, const void*, size_t, off64_t, size_t);
+ssize_t __pwrite64_chk(int, const void*, size_t, off64_t, size_t) __INTRODUCED_IN(24);
 __errordecl(__pwrite64_dest_size_error, "pwrite64 called with size bigger than destination");
 __errordecl(__pwrite64_count_toobig_error, "pwrite64 called with count > SSIZE_MAX");
-extern ssize_t __pwrite64_real(int, const void*, size_t, off64_t) __RENAME(pwrite64);
+ssize_t __pwrite64_real(int, const void*, size_t, off64_t) __RENAME(pwrite64) __INTRODUCED_IN(12);
 
-extern ssize_t __read_chk(int, void*, size_t, size_t);
+ssize_t __read_chk(int, void*, size_t, size_t) __INTRODUCED_IN(21);
 __errordecl(__read_dest_size_error, "read called with size bigger than destination");
 __errordecl(__read_count_toobig_error, "read called with count > SSIZE_MAX");
-extern ssize_t __read_real(int, void*, size_t) __RENAME(read);
+ssize_t __read_real(int, void*, size_t) __RENAME(read);
 
-extern ssize_t __write_chk(int, const void*, size_t, size_t);
+ssize_t __write_chk(int, const void*, size_t, size_t) __INTRODUCED_IN(24);
 __errordecl(__write_dest_size_error, "write called with size bigger than destination");
 __errordecl(__write_count_toobig_error, "write called with count > SSIZE_MAX");
-extern ssize_t __write_real(int, const void*, size_t) __RENAME(write);
+ssize_t __write_real(int, const void*, size_t) __RENAME(write);
 
-extern ssize_t __readlink_chk(const char*, char*, size_t, size_t);
+ssize_t __readlink_chk(const char*, char*, size_t, size_t) __INTRODUCED_IN(23);
 __errordecl(__readlink_dest_size_error, "readlink called with size bigger than destination");
 __errordecl(__readlink_size_toobig_error, "readlink called with size > SSIZE_MAX");
-extern ssize_t __readlink_real(const char*, char*, size_t) __RENAME(readlink);
+ssize_t __readlink_real(const char*, char*, size_t) __RENAME(readlink);
 
-extern ssize_t __readlinkat_chk(int dirfd, const char*, char*, size_t, size_t);
+ssize_t __readlinkat_chk(int dirfd, const char*, char*, size_t, size_t) __INTRODUCED_IN(23);
 __errordecl(__readlinkat_dest_size_error, "readlinkat called with size bigger than destination");
 __errordecl(__readlinkat_size_toobig_error, "readlinkat called with size > SSIZE_MAX");
-extern ssize_t __readlinkat_real(int dirfd, const char*, char*, size_t) __RENAME(readlinkat);
+ssize_t __readlinkat_real(int dirfd, const char*, char*, size_t) __RENAME(readlinkat) __INTRODUCED_IN(21);
+
+int getdomainname(char*, size_t) __INTRODUCED_IN_FUTURE;
+int setdomainname(const char*, size_t) __INTRODUCED_IN_FUTURE;
 
 #if defined(__BIONIC_FORTIFY)
 
+#if __ANDROID_API__ >= 24
 __BIONIC_FORTIFY_INLINE
 char* getcwd(char* buf, size_t size) {
     size_t bos = __bos(buf);
@@ -324,6 +315,7 @@
 
     return __getcwd_chk(buf, size, bos);
 }
+#endif /* __ANDROID_API__ >= 24 */
 
 #if defined(__USE_FILE_OFFSET64)
 #define __PREAD_PREFIX(x) __pread64_ ## x
@@ -331,6 +323,7 @@
 #define __PREAD_PREFIX(x) __pread_ ## x
 #endif
 
+#if __ANDROID_API__ >= 23
 __BIONIC_FORTIFY_INLINE
 ssize_t pread(int fd, void* buf, size_t count, off_t offset) {
     size_t bos = __bos0(buf);
@@ -380,6 +373,7 @@
 
     return __pread64_chk(fd, buf, count, offset, bos);
 }
+#endif /* __ANDROID_API__ >= 23 */
 
 #if defined(__USE_FILE_OFFSET64)
 #define __PWRITE_PREFIX(x) __pwrite64_ ## x
@@ -387,6 +381,7 @@
 #define __PWRITE_PREFIX(x) __pwrite_ ## x
 #endif
 
+#if __ANDROID_API__ >= 24
 __BIONIC_FORTIFY_INLINE
 ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) {
     size_t bos = __bos0(buf);
@@ -436,7 +431,9 @@
 
     return __pwrite64_chk(fd, buf, count, offset, bos);
 }
+#endif /* __ANDROID_API__ >= 24 */
 
+#if __ANDROID_API__ >= 21
 __BIONIC_FORTIFY_INLINE
 ssize_t read(int fd, void* buf, size_t count) {
     size_t bos = __bos0(buf);
@@ -461,7 +458,9 @@
 
     return __read_chk(fd, buf, count, bos);
 }
+#endif /* __ANDROID_API__ >= 21 */
 
+#if __ANDROID_API__ >= 24
 __BIONIC_FORTIFY_INLINE
 ssize_t write(int fd, const void* buf, size_t count) {
     size_t bos = __bos0(buf);
@@ -488,7 +487,9 @@
 
     return __write_chk(fd, buf, count, bos);
 }
+#endif /* __ANDROID_API__ >= 24 */
 
+#if __ANDROID_API__ >= 23
 __BIONIC_FORTIFY_INLINE
 ssize_t readlink(const char* path, char* buf, size_t size) {
     size_t bos = __bos(buf);
@@ -538,6 +539,7 @@
 
     return __readlinkat_chk(dirfd, path, buf, size, bos);
 }
+#endif /* __ANDROID_API__ >= 23 */
 
 #endif /* defined(__BIONIC_FORTIFY) */
 
diff --git a/libc/include/util.h b/libc/include/util.h
deleted file mode 100644
index e69de29..0000000
--- a/libc/include/util.h
+++ /dev/null
diff --git a/libc/include/utime.h b/libc/include/utime.h
index 3d72da4..9783859 100644
--- a/libc/include/utime.h
+++ b/libc/include/utime.h
@@ -35,7 +35,7 @@
 
 __BEGIN_DECLS
 
-extern int utime(const char*, const struct utimbuf*);
+int utime(const char*, const struct utimbuf*);
 
 __END_DECLS
 
diff --git a/libc/include/utmp.h b/libc/include/utmp.h
index c6f22a5..62e8d59 100644
--- a/libc/include/utmp.h
+++ b/libc/include/utmp.h
@@ -101,7 +101,7 @@
 struct utmp* getutent(void);
 void endutent(void);
 
-int login_tty(int);
+int login_tty(int) __INTRODUCED_IN(23);
 
 __END_DECLS
 
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index 0a94cee..2ee6c69 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -36,18 +36,12 @@
 #include <time.h>
 #include <xlocale.h>
 
+#include <bits/mbstate_t.h>
 #include <bits/wchar_limits.h>
+#include <bits/wctype.h>
 
 __BEGIN_DECLS
 
-typedef __WINT_TYPE__  wint_t;
-typedef struct {
-  uint8_t __seq[4];
-#ifdef __LP64__
-  char __reserved[4];
-#endif
-} mbstate_t;
-
 enum {
     WC_TYPE_INVALID = 0,
     WC_TYPE_ALNUM,
@@ -65,119 +59,97 @@
     WC_TYPE_MAX
 };
 
-typedef long wctype_t;
-
-#define  WEOF        ((wint_t)(-1))
-
-extern wint_t            btowc(int);
-extern int               fwprintf(FILE *, const wchar_t *, ...);
-extern int               fwscanf(FILE *, const wchar_t *, ...);
-extern int               iswalnum(wint_t);
-extern int               iswalpha(wint_t);
-extern int               iswblank(wint_t);
-extern int               iswcntrl(wint_t);
-extern int               iswdigit(wint_t);
-extern int               iswgraph(wint_t);
-extern int               iswlower(wint_t);
-extern int               iswprint(wint_t);
-extern int               iswpunct(wint_t);
-extern int               iswspace(wint_t);
-extern int               iswupper(wint_t);
-extern int               iswxdigit(wint_t);
-extern int               iswctype(wint_t, wctype_t);
-extern wint_t            fgetwc(FILE *);
-extern wchar_t          *fgetws(wchar_t *, int, FILE *);
-extern wint_t            fputwc(wchar_t, FILE *);
-extern int               fputws(const wchar_t *, FILE *);
-extern int               fwide(FILE *, int);
-extern wint_t            getwc(FILE *);
-extern wint_t            getwchar(void);
-extern int               mbsinit(const mbstate_t *);
-extern size_t            mbrlen(const char *, size_t, mbstate_t *);
-extern size_t            mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
-extern size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*);
-extern size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*);
-extern size_t            mbstowcs(wchar_t *, const char *, size_t);
-extern wint_t            putwc(wchar_t, FILE *);
-extern wint_t            putwchar(wchar_t);
-extern int               swprintf(wchar_t *, size_t, const wchar_t *, ...);
-extern int               swscanf(const wchar_t *, const wchar_t *, ...);
-extern wint_t            towlower(wint_t);
-extern wint_t            towupper(wint_t);
-extern wint_t            ungetwc(wint_t, FILE *);
-extern int vfwprintf(FILE*, const wchar_t*, va_list);
-extern int vfwscanf(FILE*, const wchar_t*, va_list);
-extern int vswprintf(wchar_t*, size_t, const wchar_t*, va_list);
-extern int vswscanf(const wchar_t*, const wchar_t*, va_list);
-extern int vwprintf(const wchar_t*, va_list);
-extern int vwscanf(const wchar_t*, va_list);
-extern wchar_t* wcpcpy (wchar_t*, const wchar_t *);
-extern wchar_t* wcpncpy (wchar_t*, const wchar_t *, size_t);
-extern size_t            wcrtomb(char *, wchar_t, mbstate_t *);
-extern int               wcscasecmp(const wchar_t *, const wchar_t *);
-extern int               wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
-extern wchar_t          *wcscat(wchar_t *, const wchar_t *);
-extern wchar_t          *wcschr(const wchar_t *, wchar_t);
-extern int               wcscmp(const wchar_t *, const wchar_t *);
-extern int               wcscoll(const wchar_t *, const wchar_t *);
-extern wchar_t          *wcscpy(wchar_t *, const wchar_t *);
-extern size_t            wcscspn(const wchar_t *, const wchar_t *);
-extern size_t            wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *) __LIBC_ABI_PUBLIC__;
-extern size_t            wcslen(const wchar_t *);
-extern int               wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
-extern int               wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
-extern wchar_t          *wcsncat(wchar_t *, const wchar_t *, size_t);
-extern int               wcsncmp(const wchar_t *, const wchar_t *, size_t);
-extern wchar_t          *wcsncpy(wchar_t *, const wchar_t *, size_t);
-extern size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*);
-extern wchar_t          *wcspbrk(const wchar_t *, const wchar_t *);
-extern wchar_t          *wcsrchr(const wchar_t *, wchar_t);
-extern size_t wcsrtombs(char*, const wchar_t**, size_t, mbstate_t*);
-extern size_t            wcsspn(const wchar_t *, const wchar_t *);
-extern wchar_t          *wcsstr(const wchar_t *, const wchar_t *);
-extern double wcstod(const wchar_t*, wchar_t**);
-extern float wcstof(const wchar_t*, wchar_t**);
-extern wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**);
-extern long wcstol(const wchar_t*, wchar_t**, int);
-extern long long wcstoll(const wchar_t*, wchar_t**, int);
-extern long double wcstold(const wchar_t*, wchar_t**);
-extern unsigned long wcstoul(const wchar_t*, wchar_t**, int);
-extern unsigned long long wcstoull(const wchar_t*, wchar_t**, int);
-extern int               wcswidth(const wchar_t *, size_t);
-extern size_t            wcsxfrm(wchar_t *, const wchar_t *, size_t);
-extern int               wctob(wint_t);
-extern wctype_t          wctype(const char *);
-extern int               wcwidth(wchar_t);
-extern wchar_t          *wmemchr(const wchar_t *, wchar_t, size_t);
-extern int               wmemcmp(const wchar_t *, const wchar_t *, size_t);
-extern wchar_t          *wmemcpy(wchar_t *, const wchar_t *, size_t);
+wint_t            btowc(int);
+int               fwprintf(FILE *, const wchar_t *, ...);
+int               fwscanf(FILE *, const wchar_t *, ...);
+wint_t            fgetwc(FILE *);
+wchar_t          *fgetws(wchar_t *, int, FILE *);
+wint_t            fputwc(wchar_t, FILE *);
+int               fputws(const wchar_t *, FILE *);
+int               fwide(FILE *, int);
+wint_t            getwc(FILE *);
+wint_t            getwchar(void);
+int               mbsinit(const mbstate_t *);
+size_t            mbrlen(const char *, size_t, mbstate_t *);
+size_t            mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
+size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*);
+size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*) __INTRODUCED_IN(21);
+wint_t            putwc(wchar_t, FILE *);
+wint_t            putwchar(wchar_t);
+int               swprintf(wchar_t *, size_t, const wchar_t *, ...);
+int               swscanf(const wchar_t *, const wchar_t *, ...);
+wint_t            ungetwc(wint_t, FILE *);
+int vfwprintf(FILE*, const wchar_t*, va_list);
+int vfwscanf(FILE*, const wchar_t*, va_list) __INTRODUCED_IN(21);
+int vswprintf(wchar_t*, size_t, const wchar_t*, va_list);
+int vswscanf(const wchar_t*, const wchar_t*, va_list) __INTRODUCED_IN(21);
+int vwprintf(const wchar_t*, va_list);
+int vwscanf(const wchar_t*, va_list) __INTRODUCED_IN(21);
+wchar_t* wcpcpy (wchar_t*, const wchar_t *);
+wchar_t* wcpncpy (wchar_t*, const wchar_t *, size_t);
+size_t            wcrtomb(char *, wchar_t, mbstate_t *);
+int               wcscasecmp(const wchar_t *, const wchar_t *);
+int wcscasecmp_l(const wchar_t*, const wchar_t*, locale_t) __INTRODUCED_IN(23);
+wchar_t          *wcscat(wchar_t *, const wchar_t *);
+wchar_t          *wcschr(const wchar_t *, wchar_t);
+int               wcscmp(const wchar_t *, const wchar_t *);
+int               wcscoll(const wchar_t *, const wchar_t *);
+wchar_t          *wcscpy(wchar_t *, const wchar_t *);
+size_t            wcscspn(const wchar_t *, const wchar_t *);
+size_t            wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
+size_t            wcslen(const wchar_t *);
+int               wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
+int wcsncasecmp_l(const wchar_t*, const wchar_t*, size_t, locale_t) __INTRODUCED_IN(23);
+wchar_t          *wcsncat(wchar_t *, const wchar_t *, size_t);
+int               wcsncmp(const wchar_t *, const wchar_t *, size_t);
+wchar_t          *wcsncpy(wchar_t *, const wchar_t *, size_t);
+size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*) __INTRODUCED_IN(21);
+wchar_t          *wcspbrk(const wchar_t *, const wchar_t *);
+wchar_t          *wcsrchr(const wchar_t *, wchar_t);
+size_t wcsrtombs(char*, const wchar_t**, size_t, mbstate_t*);
+size_t            wcsspn(const wchar_t *, const wchar_t *);
+wchar_t          *wcsstr(const wchar_t *, const wchar_t *);
+double wcstod(const wchar_t*, wchar_t**);
+float wcstof(const wchar_t*, wchar_t**) __INTRODUCED_IN(21);
+wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**);
+long wcstol(const wchar_t*, wchar_t**, int);
+long long wcstoll(const wchar_t*, wchar_t**, int) __INTRODUCED_IN(21);
+long double wcstold(const wchar_t*, wchar_t**) __INTRODUCED_IN(21);
+unsigned long wcstoul(const wchar_t*, wchar_t**, int);
+unsigned long long wcstoull(const wchar_t*, wchar_t**, int) __INTRODUCED_IN(21);
+int               wcswidth(const wchar_t *, size_t);
+size_t            wcsxfrm(wchar_t *, const wchar_t *, size_t);
+int               wctob(wint_t);
+int               wcwidth(wchar_t);
+wchar_t          *wmemchr(const wchar_t *, wchar_t, size_t);
+int               wmemcmp(const wchar_t *, const wchar_t *, size_t);
+wchar_t          *wmemcpy(wchar_t *, const wchar_t *, size_t);
 #if defined(__USE_GNU)
-extern wchar_t          *wmempcpy(wchar_t *, const wchar_t *, size_t);
+wchar_t* wmempcpy(wchar_t*, const wchar_t*, size_t) __INTRODUCED_IN(23);
 #endif
-extern wchar_t          *wmemmove(wchar_t *, const wchar_t *, size_t);
-extern wchar_t          *wmemset(wchar_t *, wchar_t, size_t);
-extern int               wprintf(const wchar_t *, ...);
-extern int               wscanf(const wchar_t *, ...);
+wchar_t          *wmemmove(wchar_t *, const wchar_t *, size_t);
+wchar_t          *wmemset(wchar_t *, wchar_t, size_t);
+int               wprintf(const wchar_t *, ...);
+int               wscanf(const wchar_t *, ...);
 
-extern long long          wcstoll_l(const wchar_t *, wchar_t **, int, locale_t);
-extern unsigned long long wcstoull_l(const wchar_t *, wchar_t **, int, locale_t);
-extern long double        wcstold_l(const wchar_t *, wchar_t **, locale_t );
+#if __ANDROID_API__ >= 21
+long long wcstoll_l(const wchar_t*, wchar_t**, int, locale_t) __INTRODUCED_IN(21);
+unsigned long long wcstoull_l(const wchar_t*, wchar_t**, int, locale_t) __INTRODUCED_IN(21);
+long double wcstold_l(const wchar_t*, wchar_t**, locale_t) __INTRODUCED_IN(21);
 
-extern int    wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
-extern size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
+int wcscoll_l(const wchar_t* _Nonnull, const wchar_t* _Nonnull, locale_t) __attribute_pure__
+    __INTRODUCED_IN(21);
+size_t wcsxfrm_l(wchar_t*, const wchar_t* _Nonnull, size_t, locale_t) __INTRODUCED_IN(21);
+#else
+// Implemented as static inlines before 21.
+#endif
 
-extern size_t wcslcat(wchar_t*, const wchar_t*, size_t);
-extern size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
+size_t wcslcat(wchar_t*, const wchar_t*, size_t);
+size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
 
-typedef void *wctrans_t;
-extern wint_t towctrans(wint_t, wctrans_t);
-extern wctrans_t wctrans(const char*);
-
-#if __POSIX_VISIBLE >= 200809
-FILE* open_wmemstream(wchar_t**, size_t*);
+FILE* open_wmemstream(wchar_t**, size_t*) __INTRODUCED_IN(23);
 wchar_t* wcsdup(const wchar_t*);
 size_t wcsnlen(const wchar_t*, size_t);
-#endif
 
 __END_DECLS
 
diff --git a/libc/include/wctype.h b/libc/include/wctype.h
index 1a4a05e..0613e7e 100644
--- a/libc/include/wctype.h
+++ b/libc/include/wctype.h
@@ -29,27 +29,37 @@
 #ifndef _WCTYPE_H_
 #define _WCTYPE_H_
 
-#include <wchar.h>
+#include <bits/wctype.h>
+#include <sys/cdefs.h>
+#include <xlocale.h>
 
 __BEGIN_DECLS
 
-extern int iswalnum_l(wint_t, locale_t);
-extern int iswalpha_l(wint_t, locale_t);
-extern int iswblank_l(wint_t, locale_t);
-extern int iswcntrl_l(wint_t, locale_t);
-extern int iswdigit_l(wint_t, locale_t);
-extern int iswgraph_l(wint_t, locale_t);
-extern int iswlower_l(wint_t, locale_t);
-extern int iswprint_l(wint_t, locale_t);
-extern int iswpunct_l(wint_t, locale_t);
-extern int iswspace_l(wint_t, locale_t);
-extern int iswupper_l(wint_t, locale_t);
-extern int iswxdigit_l(wint_t, locale_t);
-extern int towlower_l(int, locale_t);
-extern int towupper_l(int, locale_t);
+#if __ANDROID_API__ >= 21
+int iswalnum_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswalpha_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswblank_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswcntrl_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswdigit_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswgraph_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswlower_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswprint_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswpunct_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswspace_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswupper_l(wint_t, locale_t) __INTRODUCED_IN(21);
+int iswxdigit_l(wint_t, locale_t) __INTRODUCED_IN(21);
 
-extern int iswctype_l(wint_t, wctype_t, locale_t);
-extern wctype_t wctype_l(const char*, locale_t);
+wint_t towlower_l(int, locale_t) __INTRODUCED_IN(21);
+wint_t towupper_l(int, locale_t) __INTRODUCED_IN(21);
+#else
+// Implemented as static inlines before 21.
+#endif
+
+wint_t towctrans_l(wint_t, wctrans_t, locale_t) __INTRODUCED_IN_FUTURE;
+wctrans_t wctrans_l(const char*, locale_t) __INTRODUCED_IN_FUTURE;
+
+wctype_t wctype_l(const char*, locale_t) __INTRODUCED_IN(21);
+int iswctype_l(wint_t, wctype_t, locale_t) __INTRODUCED_IN(21);
 
 __END_DECLS
 
diff --git a/libc/include/xlocale.h b/libc/include/xlocale.h
index f7eb8f4..559d24d 100644
--- a/libc/include/xlocale.h
+++ b/libc/include/xlocale.h
@@ -29,6 +29,8 @@
 #ifndef _XLOCALE_H_
 #define _XLOCALE_H_
 
+#include <sys/cdefs.h>
+
 /* If we just use void* here, GCC exposes that in error messages. */
 struct __locale_t;
 typedef struct __locale_t* locale_t;
diff --git a/libc/kernel/README.TXT b/libc/kernel/README.TXT
index e7312ef..313dc0d 100644
--- a/libc/kernel/README.TXT
+++ b/libc/kernel/README.TXT
@@ -1,3 +1,6 @@
+Bionic Kernel Header Files
+==========================
+
 Bionic comes with a processed set of all of the uapi Linux kernel headers that
 can safely be included by userland applications and libraries.
 
@@ -43,19 +46,34 @@
     Automatically update all clean headers from the content of
     'external/kernel-headers/original'.
 
-
-HOW TO UPDATE THE HEADERS WHEN NEEDED:
-======================================
+How To Update The Headers
+=========================
 
 IMPORTANT IMPORTANT:
 
-  WHEN UPDATING THE HEADERS, ALWAYS CHECK THAT THE NEW CLEAN HEADERS DO
-  NOT BREAK THE KERNEL <-> USER ABI, FOR EXAMPLE BY CHANGING THE SIZE
-  OF A GIVEN TYPE. THIS TASK CANNOT BE EASILY AUTOMATED AT THE MOMENT
+WHEN UPDATING THE HEADERS, ALWAYS CHECK THAT THE NEW CLEAN HEADERS DO
+NOT BREAK THE KERNEL <-> USER ABI, FOR EXAMPLE BY CHANGING THE SIZE
+OF A GIVEN TYPE. THIS TASK CANNOT BE EASILY AUTOMATED AT THE MOMENT.
 
-Grab the latest headers from the android kernel by running this command:
+Download the Linux kernel source code:
 
-  bionic/libc/kernel/tools/generate_uapi_headers.sh --download-kernel
+  > mkdir kernel_src
+  > cd kernel_src
+  kernel_src> git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
+
+Then checkout the stable tag for the new kernel headers to import:
+
+  kernel_src> cd linux-stable
+  kernel_src/linux-stable> git checkout tags/vXXX
+
+Before running the command to import the headers, make sure that you have
+done a lunch TARGET. The script uses a variable set by the lunch command
+to determine which directory to use as the destination directory.
+
+After running lunch, run this command to import the headers into the android
+source tree:
+
+  bionic/libc/kernel/tools/generate_uapi_headers.sh --use-kernel-dir kernel_src
 
 Next, run this command to copy the parsed files to bionic/libc/kernel/uapi:
 
diff --git a/libc/kernel/android/README.TXT b/libc/kernel/android/README.TXT
new file mode 100644
index 0000000..bc2efde
--- /dev/null
+++ b/libc/kernel/android/README.TXT
@@ -0,0 +1,17 @@
+The files under the uapi directory are android kernel uapi header files that
+exist in android kernels, but have not been upstreamed into the regular
+kernel.
+
+None of these files will get updated automatically, and are frozen at their
+current value.
+
+The files under the scsi directory are frozen copies of kernel scsi headers.
+Linux's scsi headers are a mix of userspace-facing and kernel-facing
+declarations that can't be directly used by userspace. The glibc
+maintainers manually copy-and-pasted these definitions into their own
+scsi headers and haven't substantially updated them in 15 years. The
+musl libc project has a similar set of definitions in its scsi headers.
+
+These files are actually maintained in external/kernel-headers/modified/scsi.
+Any modification should first be made there then copied into the scsi
+directory.
diff --git a/libc/kernel/android/scsi/scsi.h b/libc/kernel/android/scsi/scsi.h
new file mode 100644
index 0000000..bcbcffe
--- /dev/null
+++ b/libc/kernel/android/scsi/scsi.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _SCSI_SCSI_H
+#define _SCSI_SCSI_H
+#include <linux/types.h>
+#include <scsi/scsi_proto.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ccs_modesel_head {
+  __u8 _r1;
+  __u8 medium;
+  __u8 _r2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 block_desc_length;
+  __u8 density;
+  __u8 number_blocks_hi;
+  __u8 number_blocks_med;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 number_blocks_lo;
+  __u8 _r3;
+  __u8 block_length_hi;
+  __u8 block_length_med;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 block_length_lo;
+};
+#define COMMAND_COMPLETE 0x00
+#define EXTENDED_MESSAGE 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EXTENDED_MODIFY_DATA_POINTER 0x00
+#define EXTENDED_SDTR 0x01
+#define EXTENDED_EXTENDED_IDENTIFY 0x02
+#define EXTENDED_WDTR 0x03
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EXTENDED_PPR 0x04
+#define EXTENDED_MODIFY_BIDI_DATA_PTR 0x05
+#define SAVE_POINTERS 0x02
+#define RESTORE_POINTERS 0x03
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DISCONNECT 0x04
+#define INITIATOR_ERROR 0x05
+#define ABORT_TASK_SET 0x06
+#define MESSAGE_REJECT 0x07
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NOP 0x08
+#define MSG_PARITY_ERROR 0x09
+#define LINKED_CMD_COMPLETE 0x0a
+#define LINKED_FLG_CMD_COMPLETE 0x0b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TARGET_RESET 0x0c
+#define ABORT_TASK 0x0d
+#define CLEAR_TASK_SET 0x0e
+#define INITIATE_RECOVERY 0x0f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RELEASE_RECOVERY 0x10
+#define CLEAR_ACA 0x16
+#define LOGICAL_UNIT_RESET 0x17
+#define SIMPLE_QUEUE_TAG 0x20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HEAD_OF_QUEUE_TAG 0x21
+#define ORDERED_QUEUE_TAG 0x22
+#define IGNORE_WIDE_RESIDUE 0x23
+#define ACA 0x24
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QAS_REQUEST 0x55
+#define BUS_DEVICE_RESET TARGET_RESET
+#define ABORT ABORT_TASK_SET
+#define SCSI_IOCTL_GET_IDLUN 0x5382
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SCSI_IOCTL_PROBE_HOST 0x5385
+#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386
+#define SCSI_IOCTL_GET_PCI 0x5387
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/scsi/scsi_ioctl.h b/libc/kernel/android/scsi/scsi_ioctl.h
similarity index 100%
rename from libc/kernel/common/scsi/scsi_ioctl.h
rename to libc/kernel/android/scsi/scsi_ioctl.h
diff --git a/libc/kernel/common/scsi/scsi.h b/libc/kernel/android/scsi/scsi_proto.h
similarity index 75%
rename from libc/kernel/common/scsi/scsi.h
rename to libc/kernel/android/scsi/scsi_proto.h
index 9e5edd7..acb18e7 100644
--- a/libc/kernel/common/scsi/scsi.h
+++ b/libc/kernel/android/scsi/scsi_proto.h
@@ -16,8 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _SCSI_SCSI_H
-#define _SCSI_SCSI_H
+#ifndef _SCSI_PROTO_H_
+#define _SCSI_PROTO_H_
 #include <linux/types.h>
 #define TEST_UNIT_READY 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -112,36 +112,41 @@
 #define EXCHANGE_MEDIUM 0xa6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define READ_12 0xa8
+#define SERVICE_ACTION_OUT_12 0xa9
 #define WRITE_12 0xaa
 #define READ_MEDIA_SERIAL_NUMBER 0xab
-#define WRITE_VERIFY_12 0xae
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SERVICE_ACTION_IN_12 0xab
+#define WRITE_VERIFY_12 0xae
 #define VERIFY_12 0xaf
 #define SEARCH_HIGH_12 0xb0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEARCH_EQUAL_12 0xb1
 #define SEARCH_LOW_12 0xb2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SECURITY_PROTOCOL_OUT 0xb5
 #define READ_ELEMENT_STATUS 0xb8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEND_VOLUME_TAG 0xb6
 #define WRITE_LONG_2 0xea
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXTENDED_COPY 0x83
 #define RECEIVE_COPY_RESULTS 0x84
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ACCESS_CONTROL_IN 0x86
 #define ACCESS_CONTROL_OUT 0x87
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define READ_16 0x88
 #define COMPARE_AND_WRITE 0x89
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WRITE_16 0x8a
 #define READ_ATTRIBUTE 0x8c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define WRITE_ATTRIBUTE 0x8d
 #define VERIFY_16 0x8f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SYNCHRONIZE_CACHE_16 0x91
 #define WRITE_SAME_16 0x93
+#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
+#define SERVICE_ACTION_IN_16 0x9e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SERVICE_ACTION_IN 0x9e
+#define SERVICE_ACTION_OUT_16 0x9f
 #define GOOD 0x00
 #define CHECK_CONDITION 0x01
 #define CONDITION_GOOD 0x02
@@ -194,68 +199,5 @@
 #define TYPE_ZBC 0x14
 #define TYPE_WLUN 0x1e
 #define TYPE_NO_LUN 0x7f
-struct ccs_modesel_head {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 _r1;
-  __u8 medium;
-  __u8 _r2;
-  __u8 block_desc_length;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 density;
-  __u8 number_blocks_hi;
-  __u8 number_blocks_med;
-  __u8 number_blocks_lo;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 _r3;
-  __u8 block_length_hi;
-  __u8 block_length_med;
-  __u8 block_length_lo;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-#define COMMAND_COMPLETE 0x00
-#define EXTENDED_MESSAGE 0x01
-#define EXTENDED_MODIFY_DATA_POINTER 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXTENDED_SDTR 0x01
-#define EXTENDED_EXTENDED_IDENTIFY 0x02
-#define EXTENDED_WDTR 0x03
-#define EXTENDED_PPR 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EXTENDED_MODIFY_BIDI_DATA_PTR 0x05
-#define SAVE_POINTERS 0x02
-#define RESTORE_POINTERS 0x03
-#define DISCONNECT 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define INITIATOR_ERROR 0x05
-#define ABORT_TASK_SET 0x06
-#define MESSAGE_REJECT 0x07
-#define NOP 0x08
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSG_PARITY_ERROR 0x09
-#define LINKED_CMD_COMPLETE 0x0a
-#define LINKED_FLG_CMD_COMPLETE 0x0b
-#define TARGET_RESET 0x0c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ABORT_TASK 0x0d
-#define CLEAR_TASK_SET 0x0e
-#define INITIATE_RECOVERY 0x0f
-#define RELEASE_RECOVERY 0x10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CLEAR_ACA 0x16
-#define LOGICAL_UNIT_RESET 0x17
-#define SIMPLE_QUEUE_TAG 0x20
-#define HEAD_OF_QUEUE_TAG 0x21
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ORDERED_QUEUE_TAG 0x22
-#define IGNORE_WIDE_RESIDUE 0x23
-#define ACA 0x24
-#define QAS_REQUEST 0x55
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BUS_DEVICE_RESET TARGET_RESET
-#define ABORT ABORT_TASK_SET
-#define SCSI_IOCTL_GET_IDLUN 0x5382
-#define SCSI_IOCTL_PROBE_HOST 0x5385
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386
-#define SCSI_IOCTL_GET_PCI 0x5387
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/common/scsi/sg.h b/libc/kernel/android/scsi/sg.h
similarity index 99%
rename from libc/kernel/common/scsi/sg.h
rename to libc/kernel/android/scsi/sg.h
index a38eccb..4472385 100644
--- a/libc/kernel/common/scsi/sg.h
+++ b/libc/kernel/android/scsi/sg.h
@@ -127,53 +127,54 @@
 #define SG_SCSI_RESET_HOST 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SG_SCSI_RESET_TARGET 4
+#define SG_SCSI_RESET_NO_ESCALATE 0x100
 #define SG_IO 0x2285
 #define SG_GET_REQUEST_TABLE 0x2286
-#define SG_SET_KEEP_ORPHAN 0x2287
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SG_SET_KEEP_ORPHAN 0x2287
 #define SG_GET_KEEP_ORPHAN 0x2288
 #define SG_GET_ACCESS_COUNT 0x2289
 #define SG_SCATTER_SZ (8 * 4096)
-#define SG_DEFAULT_RETRIES 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SG_DEFAULT_RETRIES 0
 #define SG_DEF_FORCE_LOW_DMA 0
 #define SG_DEF_FORCE_PACK_ID 0
 #define SG_DEF_KEEP_ORPHAN 0
-#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ
 #define SG_MAX_QUEUE 16
 #define SG_BIG_BUFF SG_DEF_RESERVED_SIZE
 typedef struct sg_io_hdr Sg_io_hdr;
-typedef struct sg_io_vec Sg_io_vec;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct sg_io_vec Sg_io_vec;
 typedef struct sg_scsi_id Sg_scsi_id;
 typedef struct sg_req_info Sg_req_info;
 #define SG_MAX_SENSE 16
-struct sg_header {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct sg_header {
   int pack_len;
   int reply_len;
   int pack_id;
-  int result;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int result;
   unsigned int twelve_byte : 1;
   unsigned int target_status : 5;
   unsigned int host_status : 8;
-  unsigned int driver_status : 8;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int driver_status : 8;
   unsigned int other_flags : 10;
   unsigned char sense_buffer[SG_MAX_SENSE];
 };
-#define SG_SET_TIMEOUT 0x2201
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SG_SET_TIMEOUT 0x2201
 #define SG_GET_TIMEOUT 0x2202
 #define SG_GET_COMMAND_Q 0x2270
 #define SG_SET_COMMAND_Q 0x2271
-#define SG_SET_DEBUG 0x227e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SG_SET_DEBUG 0x227e
 #define SG_NEXT_CMD_LEN 0x2283
 #define SG_DEFAULT_TIMEOUT (60 * HZ)
 #define SG_DEF_COMMAND_Q 0
-#define SG_DEF_UNDERRUN_FLAG 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SG_DEF_UNDERRUN_FLAG 0
 #endif
diff --git a/libc/kernel/uapi/linux/compiler.h b/libc/kernel/android/uapi/linux/compiler.h
similarity index 100%
rename from libc/kernel/uapi/linux/compiler.h
rename to libc/kernel/android/uapi/linux/compiler.h
diff --git a/libc/kernel/uapi/linux/keychord.h b/libc/kernel/android/uapi/linux/keychord.h
similarity index 100%
rename from libc/kernel/uapi/linux/keychord.h
rename to libc/kernel/android/uapi/linux/keychord.h
diff --git a/libc/kernel/uapi/linux/netfilter_ipv4/ipt_ULOG.h b/libc/kernel/android/uapi/linux/netfilter_ipv4/ipt_ULOG.h
similarity index 100%
rename from libc/kernel/uapi/linux/netfilter_ipv4/ipt_ULOG.h
rename to libc/kernel/android/uapi/linux/netfilter_ipv4/ipt_ULOG.h
diff --git a/libc/kernel/uapi/linux/usb/f_accessory.h b/libc/kernel/android/uapi/linux/usb/f_accessory.h
similarity index 100%
rename from libc/kernel/uapi/linux/usb/f_accessory.h
rename to libc/kernel/android/uapi/linux/usb/f_accessory.h
diff --git a/libc/kernel/uapi/linux/usb/f_mtp.h b/libc/kernel/android/uapi/linux/usb/f_mtp.h
similarity index 100%
rename from libc/kernel/uapi/linux/usb/f_mtp.h
rename to libc/kernel/android/uapi/linux/usb/f_mtp.h
diff --git a/libc/kernel/uapi/video/adf.h b/libc/kernel/android/uapi/video/adf.h
similarity index 100%
rename from libc/kernel/uapi/video/adf.h
rename to libc/kernel/android/uapi/video/adf.h
diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py
index e84bcf9..99f4c7f 100755
--- a/libc/kernel/tools/clean_header.py
+++ b/libc/kernel/tools/clean_header.py
@@ -117,7 +117,7 @@
                 statics = statics.union(kernel_known_statics.get(arch, set()))
         # common headers (ie non-asm and non-uapi)
         else:
-            dst_path = os.path.join("common", rel_path)
+            dst_path = os.path.join("android", rel_path)
 
     dst_path = os.path.join(dst_dir, dst_path)
 
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index 773d22f..d5577da 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -53,11 +53,20 @@
     "x86": {},
     }
 
-# Replace tokens in the output according to this mapping
+# Replace tokens in the output according to this mapping.
 kernel_token_replacements = {
-    "asm": "__asm__",
+    # The kernel's ARG_MAX is actually the "minimum" maximum (see fs/exec.c).
+    "ARG_MAX": "_KERNEL_ARG_MAX",
     # The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>.
     "__unused": "__linux_unused",
+    # The kernel usage of C++ keywords causes problems for C++ code so rename.
+    "private": "__linux_private",
+    "virtual": "__linux_virtual",
+    # 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",
     # 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",
diff --git a/libc/kernel/tools/generate_uapi_headers.sh b/libc/kernel/tools/generate_uapi_headers.sh
index 3c80d9f..4603fbe 100755
--- a/libc/kernel/tools/generate_uapi_headers.sh
+++ b/libc/kernel/tools/generate_uapi_headers.sh
@@ -30,6 +30,9 @@
 ###   --use-kernel-dir <DIR>
 ###     Do not check out the kernel source, use the kernel directory
 ###     pointed to by <DIR>.
+###   --verify-modified-headers-only <DIR>
+###     Do not build anything, simply verify that the set of modified
+###     kernel headers have not changed.
 
 # Terminate the script if any command fails.
 set -eE
@@ -42,6 +45,7 @@
 ARCH_LIST=("arm" "arm64" "mips" "x86")
 ANDROID_KERNEL_DIR="external/kernel-headers/original"
 SKIP_GENERATION=0
+VERIFY_HEADERS_ONLY=0
 
 function cleanup () {
   if [[ "${TMPDIR}" =~ /tmp ]] && [[ -d "${TMPDIR}" ]]; then
@@ -99,7 +103,7 @@
   done
 }
 
-function check_hdrs () {
+function verify_modified_hdrs () {
   local src_dir=$1
   local tgt_dir=$2
   local kernel_dir=$3
@@ -124,7 +128,7 @@
   done
 
   for dir in "${search_dirs[@]}"; do
-    check_hdrs "${dir}" ${tgt_dir}/$(basename ${dir}) "${kernel_dir}"
+    verify_modified_hdrs "${dir}" ${tgt_dir}/$(basename ${dir}) "${kernel_dir}"
   done
 }
 
@@ -149,6 +153,16 @@
       KERNEL_DIR="$1"
       KERNEL_DOWNLOAD=0
       ;;
+    "--verify-modified-headers-only")
+      if [[ $# -lt 2 ]]; then
+        echo "--verify-modified-headers-only requires an argument."
+        exit 1
+      fi
+      shift
+      KERNEL_DIR="$1"
+      KERNEL_DOWNLOAD=0
+      VERIFY_HEADERS_ONLY=1
+      ;;
     "-h" | "--help")
       usage
       exit 1
@@ -183,6 +197,14 @@
   src_dir="common"
 fi
 
+if [[ ${VERIFY_HEADERS_ONLY} -eq 1 ]]; then
+  # Verify if modified headers have changed.
+  verify_modified_hdrs "${KERNEL_DIR}/${src_dir}/include/scsi" \
+                       "${ANDROID_KERNEL_DIR}/scsi" \
+                       "${KERNEL_DIR}/${src_dir}"
+  exit 0
+fi
+
 if [[ ${KERNEL_DOWNLOAD} -eq 1 ]]; then
   TMPDIR=$(mktemp -d /tmp/android_kernelXXXXXXXX)
   cd "${TMPDIR}"
@@ -202,6 +224,9 @@
 fi
 
 if [[ ${SKIP_GENERATION} -eq 0 ]]; then
+  # Clean up any leftover headers.
+  make distclean
+
   # Build all of the generated headers.
   for arch in "${ARCH_LIST[@]}"; do
     echo "Generating headers for arch ${arch}"
@@ -209,6 +234,11 @@
   done
 fi
 
+# Completely delete the old original headers so that any deleted/moved
+# headers are also removed.
+rm -rf "${ANDROID_KERNEL_DIR}/uapi"
+mkdir -p "${ANDROID_KERNEL_DIR}/uapi"
+
 cd ${ANDROID_BUILD_TOP}
 
 # Copy all of the include/uapi files to the kernel headers uapi directory.
@@ -237,7 +267,12 @@
                  "${ANDROID_KERNEL_DIR}/uapi/asm-${arch}/asm"
 done
 
+# The arm types.h uapi header is not properly being generated, so copy it
+# directly.
+cp "${KERNEL_DIR}/${src_dir}/include/uapi/asm-generic/types.h" \
+   "${ANDROID_KERNEL_DIR}/uapi/asm-arm/asm"
+
 # Verify if modified headers have changed.
-check_hdrs "${KERNEL_DIR}/${src_dir}/include/scsi" \
-           "${ANDROID_KERNEL_DIR}/scsi" \
-           "${KERNEL_DIR}/${src_dir}"
+verify_modified_hdrs "${KERNEL_DIR}/${src_dir}/include/scsi" \
+                     "${ANDROID_KERNEL_DIR}/scsi" \
+                     "${KERNEL_DIR}/${src_dir}"
diff --git a/libc/kernel/tools/update_all.py b/libc/kernel/tools/update_all.py
index 7f3657c..5031168 100755
--- a/libc/kernel/tools/update_all.py
+++ b/libc/kernel/tools/update_all.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-import sys, cpp, kernel, glob, os, re, getopt, clean_header, subprocess
+import sys, cpp, kernel, glob, os, re, getopt, clean_header, subprocess, shutil
 from defaults import *
 from utils import *
 
@@ -20,7 +20,7 @@
         android tree
 
       - the clean headers will be placed in 'bionic/libc/kernel/arch-<arch>/asm',
-        'bionic/libc/kernel/common', etc..
+        'bionic/libc/kernel/android', etc..
 """ % { "progname" : os.path.basename(sys.argv[0]) }
     sys.exit(0)
 
@@ -75,7 +75,13 @@
 for arch in kernel_archs:
     b.readDir(os.path.join(kernel_dir, "arch-%s" % arch))
 
-b.readDir(os.path.join(kernel_dir, "common"))
+b.readDir(os.path.join(kernel_dir, "android"))
+
+# Delete the old uapi headers before updating to handle headers that
+# get moved/deleted.
+uapi_dir = os.path.join(get_kernel_dir(), "uapi")
+shutil.rmtree(uapi_dir)
+os.mkdir(uapi_dir, 0755)
 
 oldlen = 120
 android_root_len = len(get_android_root()) + 1
diff --git a/libc/kernel/uapi/asm-arm/asm/auxvec.h b/libc/kernel/uapi/asm-arm/asm/auxvec.h
index 2fa0e6b..3aa54b6 100644
--- a/libc/kernel/uapi/asm-arm/asm/auxvec.h
+++ b/libc/kernel/uapi/asm-arm/asm/auxvec.h
@@ -16,4 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include <asm-generic/auxvec.h>
+#ifndef __ASM_AUXVEC_H
+#define __ASM_AUXVEC_H
+#define AT_SYSINFO_EHDR 33
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-arm/asm/types.h b/libc/kernel/uapi/asm-arm/asm/types.h
index 8250f43..c0d4bea 100644
--- a/libc/kernel/uapi/asm-arm/asm/types.h
+++ b/libc/kernel/uapi/asm-arm/asm/types.h
@@ -16,4 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include <asm-generic/types.h>
+#ifndef _ASM_GENERIC_TYPES_H
+#define _ASM_GENERIC_TYPES_H
+#include <asm-generic/int-ll64.h>
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-arm/asm/unistd.h b/libc/kernel/uapi/asm-arm/asm/unistd.h
index 468f50a..45bae1e 100644
--- a/libc/kernel/uapi/asm-arm/asm/unistd.h
+++ b/libc/kernel/uapi/asm-arm/asm/unistd.h
@@ -469,27 +469,31 @@
 #define __NR_userfaultfd (__NR_SYSCALL_BASE + 388)
 #define __NR_membarrier (__NR_SYSCALL_BASE + 389)
 #define __NR_mlock2 (__NR_SYSCALL_BASE + 390)
-#define __ARM_NR_BASE (__NR_SYSCALL_BASE + 0x0f0000)
+#define __NR_copy_file_range (__NR_SYSCALL_BASE + 391)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_preadv2 (__NR_SYSCALL_BASE + 392)
+#define __NR_pwritev2 (__NR_SYSCALL_BASE + 393)
+#define __ARM_NR_BASE (__NR_SYSCALL_BASE + 0x0f0000)
 #define __ARM_NR_breakpoint (__ARM_NR_BASE + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __ARM_NR_cacheflush (__ARM_NR_BASE + 2)
 #define __ARM_NR_usr26 (__ARM_NR_BASE + 3)
 #define __ARM_NR_usr32 (__ARM_NR_BASE + 4)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __ARM_NR_set_tls (__ARM_NR_BASE + 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_time
 #undef __NR_umount
 #undef __NR_stime
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_alarm
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_utime
 #undef __NR_getrlimit
 #undef __NR_select
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_readdir
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_mmap
 #undef __NR_socketcall
 #undef __NR_syscall
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_ipc
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/asm-arm64/asm/hwcap.h b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
index 5e2b495..6c063be 100644
--- a/libc/kernel/uapi/asm-arm64/asm/hwcap.h
+++ b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
@@ -29,5 +29,7 @@
 #define HWCAP_SHA2 (1 << 6)
 #define HWCAP_CRC32 (1 << 7)
 #define HWCAP_ATOMICS (1 << 8)
-#endif
+#define HWCAP_FPHP (1 << 9)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HWCAP_ASIMDHP (1 << 10)
+#endif
diff --git a/libc/kernel/uapi/asm-arm64/asm/kvm.h b/libc/kernel/uapi/asm-arm64/asm/kvm.h
index 39b961a..63fc337 100644
--- a/libc/kernel/uapi/asm-arm64/asm/kvm.h
+++ b/libc/kernel/uapi/asm-arm64/asm/kvm.h
@@ -74,84 +74,89 @@
 #define KVM_ARM_VCPU_POWER_OFF 0
 #define KVM_ARM_VCPU_EL1_32BIT 1
 #define KVM_ARM_VCPU_PSCI_0_2 2
-struct kvm_vcpu_init {
+#define KVM_ARM_VCPU_PMU_V3 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct kvm_vcpu_init {
   __u32 target;
   __u32 features[7];
 };
-struct kvm_sregs {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct kvm_sregs {
 };
 struct kvm_fpu {
 };
-#define KVM_ARM_MAX_DBG_REGS 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_ARM_MAX_DBG_REGS 16
 struct kvm_guest_debug_arch {
   __u64 dbg_bcr[KVM_ARM_MAX_DBG_REGS];
   __u64 dbg_bvr[KVM_ARM_MAX_DBG_REGS];
-  __u64 dbg_wcr[KVM_ARM_MAX_DBG_REGS];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 dbg_wcr[KVM_ARM_MAX_DBG_REGS];
   __u64 dbg_wvr[KVM_ARM_MAX_DBG_REGS];
 };
 struct kvm_debug_exit_arch {
-  __u32 hsr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 hsr;
   __u64 far;
 };
 #define KVM_GUESTDBG_USE_SW_BP (1 << 16)
-#define KVM_GUESTDBG_USE_HW (1 << 17)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_GUESTDBG_USE_HW (1 << 17)
 struct kvm_sync_regs {
 };
 struct kvm_arch_memory_slot {
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000
 #define KVM_REG_ARM_COPROC_SHIFT 16
 #define KVM_REG_ARM_CORE (0x0010 << KVM_REG_ARM_COPROC_SHIFT)
-#define KVM_REG_ARM_CORE_REG(name) (offsetof(struct kvm_regs, name) / sizeof(__u32))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_REG_ARM_CORE_REG(name) (offsetof(struct kvm_regs, name) / sizeof(__u32))
 #define KVM_REG_ARM_DEMUX (0x0011 << KVM_REG_ARM_COPROC_SHIFT)
 #define KVM_REG_ARM_DEMUX_ID_MASK 0x000000000000FF00
 #define KVM_REG_ARM_DEMUX_ID_SHIFT 8
-#define KVM_REG_ARM_DEMUX_ID_CCSIDR (0x00 << KVM_REG_ARM_DEMUX_ID_SHIFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_REG_ARM_DEMUX_ID_CCSIDR (0x00 << KVM_REG_ARM_DEMUX_ID_SHIFT)
 #define KVM_REG_ARM_DEMUX_VAL_MASK 0x00000000000000FF
 #define KVM_REG_ARM_DEMUX_VAL_SHIFT 0
 #define KVM_REG_ARM64_SYSREG (0x0013 << KVM_REG_ARM_COPROC_SHIFT)
-#define KVM_REG_ARM64_SYSREG_OP0_MASK 0x000000000000c000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_REG_ARM64_SYSREG_OP0_MASK 0x000000000000c000
 #define KVM_REG_ARM64_SYSREG_OP0_SHIFT 14
 #define KVM_REG_ARM64_SYSREG_OP1_MASK 0x0000000000003800
 #define KVM_REG_ARM64_SYSREG_OP1_SHIFT 11
-#define KVM_REG_ARM64_SYSREG_CRN_MASK 0x0000000000000780
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_REG_ARM64_SYSREG_CRN_MASK 0x0000000000000780
 #define KVM_REG_ARM64_SYSREG_CRN_SHIFT 7
 #define KVM_REG_ARM64_SYSREG_CRM_MASK 0x0000000000000078
 #define KVM_REG_ARM64_SYSREG_CRM_SHIFT 3
-#define KVM_REG_ARM64_SYSREG_OP2_MASK 0x0000000000000007
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_REG_ARM64_SYSREG_OP2_MASK 0x0000000000000007
 #define KVM_REG_ARM64_SYSREG_OP2_SHIFT 0
 #define ARM64_SYS_REG_SHIFT_MASK(x,n) (((x) << KVM_REG_ARM64_SYSREG_ ##n ##_SHIFT) & KVM_REG_ARM64_SYSREG_ ##n ##_MASK)
 #define __ARM64_SYS_REG(op0,op1,crn,crm,op2) (KVM_REG_ARM64 | KVM_REG_ARM64_SYSREG | ARM64_SYS_REG_SHIFT_MASK(op0, OP0) | ARM64_SYS_REG_SHIFT_MASK(op1, OP1) | ARM64_SYS_REG_SHIFT_MASK(crn, CRN) | ARM64_SYS_REG_SHIFT_MASK(crm, CRM) | ARM64_SYS_REG_SHIFT_MASK(op2, OP2))
-#define ARM64_SYS_REG(...) (__ARM64_SYS_REG(__VA_ARGS__) | KVM_REG_SIZE_U64)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARM64_SYS_REG(...) (__ARM64_SYS_REG(__VA_ARGS__) | KVM_REG_SIZE_U64)
 #define KVM_REG_ARM_TIMER_CTL ARM64_SYS_REG(3, 3, 14, 3, 1)
 #define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2)
 #define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2)
-#define KVM_DEV_ARM_VGIC_GRP_ADDR 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_DEV_ARM_VGIC_GRP_ADDR 0
 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1
 #define KVM_DEV_ARM_VGIC_GRP_CPU_REGS 2
 #define KVM_DEV_ARM_VGIC_CPUID_SHIFT 32
-#define KVM_DEV_ARM_VGIC_CPUID_MASK (0xffULL << KVM_DEV_ARM_VGIC_CPUID_SHIFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_DEV_ARM_VGIC_CPUID_MASK (0xffULL << KVM_DEV_ARM_VGIC_CPUID_SHIFT)
 #define KVM_DEV_ARM_VGIC_OFFSET_SHIFT 0
 #define KVM_DEV_ARM_VGIC_OFFSET_MASK (0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)
 #define KVM_DEV_ARM_VGIC_GRP_NR_IRQS 3
-#define KVM_DEV_ARM_VGIC_GRP_CTRL 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_DEV_ARM_VGIC_GRP_CTRL 4
 #define KVM_DEV_ARM_VGIC_CTRL_INIT 0
+#define KVM_ARM_VCPU_PMU_V3_CTRL 0
+#define KVM_ARM_VCPU_PMU_V3_IRQ 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_ARM_VCPU_PMU_V3_INIT 1
 #define KVM_ARM_IRQ_TYPE_SHIFT 24
 #define KVM_ARM_IRQ_TYPE_MASK 0xff
 #define KVM_ARM_IRQ_VCPU_SHIFT 16
diff --git a/libc/kernel/uapi/asm-arm64/asm/ptrace.h b/libc/kernel/uapi/asm-arm64/asm/ptrace.h
index 37148f5..465c7bb 100644
--- a/libc/kernel/uapi/asm-arm64/asm/ptrace.h
+++ b/libc/kernel/uapi/asm-arm64/asm/ptrace.h
@@ -38,43 +38,44 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PSR_D_BIT 0x00000200
 #define PSR_PAN_BIT 0x00400000
+#define PSR_UAO_BIT 0x00800000
 #define PSR_Q_BIT 0x08000000
-#define PSR_V_BIT 0x10000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PSR_V_BIT 0x10000000
 #define PSR_C_BIT 0x20000000
 #define PSR_Z_BIT 0x40000000
 #define PSR_N_BIT 0x80000000
-#define PSR_f 0xff000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PSR_f 0xff000000
 #define PSR_s 0x00ff0000
 #define PSR_x 0x0000ff00
 #define PSR_c 0x000000ff
-#ifndef __ASSEMBLY__
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef __ASSEMBLY__
 struct user_pt_regs {
   __u64 regs[31];
   __u64 sp;
-  __u64 pc;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 pc;
   __u64 pstate;
 };
 struct user_fpsimd_state {
-  __uint128_t vregs[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __uint128_t vregs[32];
   __u32 fpsr;
   __u32 fpcr;
 };
-struct user_hwdebug_state {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct user_hwdebug_state {
   __u32 dbg_info;
   __u32 pad;
   struct {
-    __u64 addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u64 addr;
     __u32 ctrl;
     __u32 pad;
   } dbg_regs[16];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
 #endif
diff --git a/libc/kernel/uapi/asm-arm64/asm/unistd.h b/libc/kernel/uapi/asm-arm64/asm/unistd.h
index 697186a..cc151fd 100644
--- a/libc/kernel/uapi/asm-arm64/asm/unistd.h
+++ b/libc/kernel/uapi/asm-arm64/asm/unistd.h
@@ -16,4 +16,5 @@
  ***
  ****************************************************************************
  ****************************************************************************/
+#define __ARCH_WANT_RENAMEAT
 #include <asm-generic/unistd.h>
diff --git a/libc/kernel/uapi/asm-generic/mman-common.h b/libc/kernel/uapi/asm-generic/mman-common.h
index 00075c7..5c28f15 100644
--- a/libc/kernel/uapi/asm-generic/mman-common.h
+++ b/libc/kernel/uapi/asm-generic/mman-common.h
@@ -46,21 +46,23 @@
 #define MADV_WILLNEED 3
 #define MADV_DONTNEED 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_FREE 8
 #define MADV_REMOVE 9
 #define MADV_DONTFORK 10
 #define MADV_DOFORK 11
-#define MADV_HWPOISON 100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_HWPOISON 100
 #define MADV_SOFT_OFFLINE 101
 #define MADV_MERGEABLE 12
 #define MADV_UNMERGEABLE 13
-#define MADV_HUGEPAGE 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_HUGEPAGE 14
 #define MADV_NOHUGEPAGE 15
 #define MADV_DONTDUMP 16
 #define MADV_DODUMP 17
-#define MAP_FILE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_FILE 0
 #define MAP_HUGE_SHIFT 26
 #define MAP_HUGE_MASK 0x3f
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-generic/siginfo.h b/libc/kernel/uapi/asm-generic/siginfo.h
index ad54529..7a16217 100644
--- a/libc/kernel/uapi/asm-generic/siginfo.h
+++ b/libc/kernel/uapi/asm-generic/siginfo.h
@@ -94,51 +94,56 @@
       int _trapno;
 #endif
       short _addr_lsb;
-      struct {
+      union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-        void __user * _lower;
-        void __user * _upper;
-      } _addr_bnd;
+        struct {
+          void __user * _lower;
+          void __user * _upper;
+        } _addr_bnd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+        __u32 _pkey;
+      };
     } _sigfault;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __ARCH_SI_BAND_T _band;
       int _fd;
     } _sigpoll;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       void __user * _call_addr;
       int _syscall;
       unsigned int _arch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } _sigsys;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } _sifields;
 } __ARCH_SI_ATTRIBUTES siginfo_t;
 #define __ARCH_SIGSYS
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_pid _sifields._kill._pid
 #define si_uid _sifields._kill._uid
 #define si_tid _sifields._timer._tid
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_overrun _sifields._timer._overrun
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_sys_private _sifields._timer._sys_private
 #define si_status _sifields._sigchld._status
 #define si_utime _sifields._sigchld._utime
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_stime _sifields._sigchld._stime
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_value _sifields._rt._sigval
 #define si_int _sifields._rt._sigval.sival_int
 #define si_ptr _sifields._rt._sigval.sival_ptr
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_addr _sifields._sigfault._addr
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __ARCH_SI_TRAPNO
 #define si_trapno _sifields._sigfault._trapno
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_addr_lsb _sifields._sigfault._addr_lsb
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_lower _sifields._sigfault._addr_bnd._lower
 #define si_upper _sifields._sigfault._addr_bnd._upper
+#define si_pkey _sifields._sigfault._pkey
 #define si_band _sifields._sigpoll._band
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define si_fd _sifields._sigpoll._fd
@@ -199,71 +204,72 @@
 #define SEGV_MAPERR (__SI_FAULT | 1)
 #define SEGV_ACCERR (__SI_FAULT | 2)
 #define SEGV_BNDERR (__SI_FAULT | 3)
-#define NSIGSEGV 3
+#define SEGV_PKUERR (__SI_FAULT | 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NSIGSEGV 4
 #define BUS_ADRALN (__SI_FAULT | 1)
 #define BUS_ADRERR (__SI_FAULT | 2)
 #define BUS_OBJERR (__SI_FAULT | 3)
-#define BUS_MCEERR_AR (__SI_FAULT | 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BUS_MCEERR_AR (__SI_FAULT | 4)
 #define BUS_MCEERR_AO (__SI_FAULT | 5)
 #define NSIGBUS 5
 #define TRAP_BRKPT (__SI_FAULT | 1)
-#define TRAP_TRACE (__SI_FAULT | 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TRAP_TRACE (__SI_FAULT | 2)
 #define TRAP_BRANCH (__SI_FAULT | 3)
 #define TRAP_HWBKPT (__SI_FAULT | 4)
 #define NSIGTRAP 4
-#define CLD_EXITED (__SI_CHLD | 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CLD_EXITED (__SI_CHLD | 1)
 #define CLD_KILLED (__SI_CHLD | 2)
 #define CLD_DUMPED (__SI_CHLD | 3)
 #define CLD_TRAPPED (__SI_CHLD | 4)
-#define CLD_STOPPED (__SI_CHLD | 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CLD_STOPPED (__SI_CHLD | 5)
 #define CLD_CONTINUED (__SI_CHLD | 6)
 #define NSIGCHLD 6
 #define POLL_IN (__SI_POLL | 1)
-#define POLL_OUT (__SI_POLL | 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define POLL_OUT (__SI_POLL | 2)
 #define POLL_MSG (__SI_POLL | 3)
 #define POLL_ERR (__SI_POLL | 4)
 #define POLL_PRI (__SI_POLL | 5)
-#define POLL_HUP (__SI_POLL | 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define POLL_HUP (__SI_POLL | 6)
 #define NSIGPOLL 6
 #define SYS_SECCOMP (__SI_SYS | 1)
 #define NSIGSYS 1
-#define SIGEV_SIGNAL 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SIGEV_SIGNAL 0
 #define SIGEV_NONE 1
 #define SIGEV_THREAD 2
 #define SIGEV_THREAD_ID 4
-#ifndef __ARCH_SIGEV_PREAMBLE_SIZE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef __ARCH_SIGEV_PREAMBLE_SIZE
 #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t))
 #endif
 #define SIGEV_MAX_SIZE 64
-#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) / sizeof(int))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) / sizeof(int))
 typedef struct sigevent {
   sigval_t sigev_value;
   int sigev_signo;
-  int sigev_notify;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int sigev_notify;
   union {
     int _pad[SIGEV_PAD_SIZE];
     int _tid;
-    struct {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct {
       void(* _function) (sigval_t);
       void * _attribute;
     } _sigev_thread;
-  } _sigev_un;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  } _sigev_un;
 } sigevent_t;
 #define sigev_notify_function _sigev_un._sigev_thread._function
 #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
-#define sigev_notify_thread_id _sigev_un._tid
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define sigev_notify_thread_id _sigev_un._tid
 #endif
diff --git a/libc/kernel/uapi/asm-generic/socket.h b/libc/kernel/uapi/asm-generic/socket.h
index ec38e2c..e0d0817 100644
--- a/libc/kernel/uapi/asm-generic/socket.h
+++ b/libc/kernel/uapi/asm-generic/socket.h
@@ -93,4 +93,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_ATTACH_BPF 50
 #define SO_DETACH_BPF SO_DETACH_FILTER
+#define SO_ATTACH_REUSEPORT_CBPF 51
+#define SO_ATTACH_REUSEPORT_EBPF 52
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_CNX_ADVICE 53
 #endif
diff --git a/libc/kernel/uapi/asm-generic/unistd.h b/libc/kernel/uapi/asm-generic/unistd.h
index 635a123..a77e211 100644
--- a/libc/kernel/uapi/asm-generic/unistd.h
+++ b/libc/kernel/uapi/asm-generic/unistd.h
@@ -83,449 +83,456 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_symlinkat 36
 #define __NR_linkat 37
+#ifdef __ARCH_WANT_RENAMEAT
 #define __NR_renameat 38
-#define __NR_umount2 39
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define __NR_umount2 39
 #define __NR_mount 40
 #define __NR_pivot_root 41
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_nfsservctl 42
 #define __NR3264_statfs 43
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR3264_fstatfs 44
 #define __NR3264_truncate 45
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR3264_ftruncate 46
 #define __NR_fallocate 47
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_faccessat 48
 #define __NR_chdir 49
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchdir 50
 #define __NR_chroot 51
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchmod 52
 #define __NR_fchmodat 53
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchownat 54
 #define __NR_fchown 55
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_openat 56
 #define __NR_close 57
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vhangup 58
 #define __NR_pipe2 59
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_quotactl 60
 #define __NR_getdents64 61
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __ARCH_WANT_COMPAT_SYS_GETDENTS64
 #define __NR3264_lseek 62
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_read 63
 #define __NR_write 64
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readv 65
 #define __NR_writev 66
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pread64 67
 #define __NR_pwrite64 68
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_preadv 69
 #define __NR_pwritev 70
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR3264_sendfile 71
 #define __NR_pselect6 72
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ppoll 73
 #define __NR_signalfd4 74
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vmsplice 75
 #define __NR_splice 76
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_tee 77
 #define __NR_readlinkat 78
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR3264_fstatat 79
 #define __NR3264_fstat 80
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sync 81
 #define __NR_fsync 82
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fdatasync 83
 #ifdef __ARCH_WANT_SYNC_FILE_RANGE2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sync_file_range2 84
 #else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sync_file_range 84
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timerfd_create 85
 #define __NR_timerfd_settime 86
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timerfd_gettime 87
 #define __NR_utimensat 88
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_acct 89
 #define __NR_capget 90
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_capset 91
 #define __NR_personality 92
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_exit 93
 #define __NR_exit_group 94
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_waitid 95
 #define __NR_set_tid_address 96
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_unshare 97
 #define __NR_futex 98
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_set_robust_list 99
 #define __NR_get_robust_list 100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_nanosleep 101
 #define __NR_getitimer 102
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setitimer 103
 #define __NR_kexec_load 104
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_init_module 105
 #define __NR_delete_module 106
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_create 107
 #define __NR_timer_gettime 108
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_getoverrun 109
 #define __NR_timer_settime 110
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_delete 111
 #define __NR_clock_settime 112
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_gettime 113
 #define __NR_clock_getres 114
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_nanosleep 115
 #define __NR_syslog 116
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ptrace 117
 #define __NR_sched_setparam 118
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_setscheduler 119
 #define __NR_sched_getscheduler 120
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getparam 121
 #define __NR_sched_setaffinity 122
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getaffinity 123
 #define __NR_sched_yield 124
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_get_priority_max 125
 #define __NR_sched_get_priority_min 126
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_rr_get_interval 127
 #define __NR_restart_syscall 128
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_kill 129
 #define __NR_tkill 130
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_tgkill 131
 #define __NR_sigaltstack 132
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigsuspend 133
 #define __NR_rt_sigaction 134
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigprocmask 135
 #define __NR_rt_sigpending 136
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigtimedwait 137
 #define __NR_rt_sigqueueinfo 138
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigreturn 139
 #define __NR_setpriority 140
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpriority 141
 #define __NR_reboot 142
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setregid 143
 #define __NR_setgid 144
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setreuid 145
 #define __NR_setuid 146
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setresuid 147
 #define __NR_getresuid 148
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setresgid 149
 #define __NR_getresgid 150
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setfsuid 151
 #define __NR_setfsgid 152
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_times 153
 #define __NR_setpgid 154
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpgid 155
 #define __NR_getsid 156
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setsid 157
 #define __NR_getgroups 158
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setgroups 159
 #define __NR_uname 160
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sethostname 161
 #define __NR_setdomainname 162
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getrlimit 163
 #define __NR_setrlimit 164
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getrusage 165
 #define __NR_umask 166
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_prctl 167
 #define __NR_getcpu 168
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_gettimeofday 169
 #define __NR_settimeofday 170
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_adjtimex 171
 #define __NR_getpid 172
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getppid 173
 #define __NR_getuid 174
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_geteuid 175
 #define __NR_getgid 176
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getegid 177
 #define __NR_gettid 178
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sysinfo 179
 #define __NR_mq_open 180
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_unlink 181
 #define __NR_mq_timedsend 182
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_timedreceive 183
 #define __NR_mq_notify 184
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_getsetattr 185
 #define __NR_msgget 186
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgctl 187
 #define __NR_msgrcv 188
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgsnd 189
 #define __NR_semget 190
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semctl 191
 #define __NR_semtimedop 192
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semop 193
 #define __NR_shmget 194
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmctl 195
 #define __NR_shmat 196
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmdt 197
 #define __NR_socket 198
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_socketpair 199
 #define __NR_bind 200
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_listen 201
 #define __NR_accept 202
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_connect 203
 #define __NR_getsockname 204
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpeername 205
 #define __NR_sendto 206
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_recvfrom 207
 #define __NR_setsockopt 208
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsockopt 209
 #define __NR_shutdown 210
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendmsg 211
 #define __NR_recvmsg 212
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readahead 213
 #define __NR_brk 214
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_munmap 215
 #define __NR_mremap 216
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_add_key 217
 #define __NR_request_key 218
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_keyctl 219
 #define __NR_clone 220
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_execve 221
 #define __NR3264_mmap 222
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR3264_fadvise64 223
 #ifndef __ARCH_NOMMU
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_swapon 224
 #define __NR_swapoff 225
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mprotect 226
 #define __NR_msync 227
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mlock 228
 #define __NR_munlock 229
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mlockall 230
 #define __NR_munlockall 231
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mincore 232
 #define __NR_madvise 233
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_remap_file_pages 234
 #define __NR_mbind 235
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_get_mempolicy 236
 #define __NR_set_mempolicy 237
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_migrate_pages 238
 #define __NR_move_pages 239
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define __NR_rt_tgsigqueueinfo 240
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_perf_event_open 241
 #define __NR_accept4 242
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_recvmmsg 243
 #define __NR_arch_specific_syscall 244
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_wait4 260
 #define __NR_prlimit64 261
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fanotify_init 262
 #define __NR_fanotify_mark 263
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_name_to_handle_at 264
 #define __NR_open_by_handle_at 265
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_adjtime 266
 #define __NR_syncfs 267
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setns 268
 #define __NR_sendmmsg 269
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_process_vm_readv 270
 #define __NR_process_vm_writev 271
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_kcmp 272
 #define __NR_finit_module 273
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_setattr 274
 #define __NR_sched_getattr 275
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_renameat2 276
 #define __NR_seccomp 277
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getrandom 278
 #define __NR_memfd_create 279
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_bpf 280
 #define __NR_execveat 281
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_userfaultfd 282
 #define __NR_membarrier 283
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mlock2 284
-#undef __NR_syscalls
-#define __NR_syscalls 285
-#ifdef __ARCH_WANT_SYSCALL_NO_AT
+#define __NR_copy_file_range 285
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_preadv2 286
+#define __NR_pwritev2 287
+#undef __NR_syscalls
+#define __NR_syscalls 288
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __ARCH_WANT_SYSCALL_NO_AT
 #define __NR_open 1024
 #define __NR_link 1025
 #define __NR_unlink 1026
-#define __NR_mknod 1027
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_mknod 1027
 #define __NR_chmod 1028
 #define __NR_chown 1029
 #define __NR_mkdir 1030
-#define __NR_rmdir 1031
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_rmdir 1031
 #define __NR_lchown 1032
 #define __NR_access 1033
 #define __NR_rename 1034
-#define __NR_readlink 1035
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_readlink 1035
 #define __NR_symlink 1036
 #define __NR_utimes 1037
 #define __NR3264_stat 1038
-#define __NR3264_lstat 1039
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR3264_lstat 1039
 #undef __NR_syscalls
 #define __NR_syscalls (__NR3264_lstat + 1)
 #endif
-#ifdef __ARCH_WANT_SYSCALL_NO_FLAGS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __ARCH_WANT_SYSCALL_NO_FLAGS
 #define __NR_pipe 1040
 #define __NR_dup2 1041
 #define __NR_epoll_create 1042
-#define __NR_inotify_init 1043
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_inotify_init 1043
 #define __NR_eventfd 1044
 #define __NR_signalfd 1045
 #undef __NR_syscalls
-#define __NR_syscalls (__NR_signalfd + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_syscalls (__NR_signalfd + 1)
 #endif
 #if (__BITS_PER_LONG == 32 || defined(__SYSCALL_COMPAT)) && defined(__ARCH_WANT_SYSCALL_OFF_T)
 #define __NR_sendfile 1046
-#define __NR_ftruncate 1047
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_ftruncate 1047
 #define __NR_truncate 1048
 #define __NR_stat 1049
 #define __NR_lstat 1050
-#define __NR_fstat 1051
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fstat 1051
 #define __NR_fcntl 1052
 #define __NR_fadvise64 1053
 #define __ARCH_WANT_SYS_FADVISE64
-#define __NR_newfstatat 1054
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_newfstatat 1054
 #define __ARCH_WANT_SYS_NEWFSTATAT
 #define __NR_fstatfs 1055
 #define __NR_statfs 1056
-#define __NR_lseek 1057
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_lseek 1057
 #define __NR_mmap 1058
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_mmap + 1)
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #ifdef __ARCH_WANT_SYSCALL_DEPRECATED
 #define __NR_alarm 1059
 #define __ARCH_WANT_SYS_ALARM
-#define __NR_getpgrp 1060
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_getpgrp 1060
 #define __ARCH_WANT_SYS_GETPGRP
 #define __NR_pause 1061
 #define __ARCH_WANT_SYS_PAUSE
-#define __NR_time 1062
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_time 1062
 #define __ARCH_WANT_SYS_TIME
 #define __ARCH_WANT_COMPAT_SYS_TIME
 #define __NR_utime 1063
-#define __ARCH_WANT_SYS_UTIME
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __ARCH_WANT_SYS_UTIME
 #define __NR_creat 1064
 #define __NR_getdents 1065
 #define __ARCH_WANT_SYS_GETDENTS
-#define __NR_futimesat 1066
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_futimesat 1066
 #define __NR_select 1067
 #define __ARCH_WANT_SYS_SELECT
 #define __NR_poll 1068
-#define __NR_epoll_wait 1069
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_epoll_wait 1069
 #define __NR_ustat 1070
 #define __NR_vfork 1071
 #define __NR_oldwait4 1072
-#define __NR_recv 1073
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_recv 1073
 #define __NR_send 1074
 #define __NR_bdflush 1075
 #define __NR_umount 1076
-#define __ARCH_WANT_SYS_OLDUMOUNT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __ARCH_WANT_SYS_OLDUMOUNT
 #define __NR_uselib 1077
 #define __NR__sysctl 1078
 #define __NR_fork 1079
-#undef __NR_syscalls
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#undef __NR_syscalls
 #define __NR_syscalls (__NR_fork + 1)
 #endif
 #if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
-#define __NR_fcntl __NR3264_fcntl
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fcntl __NR3264_fcntl
 #define __NR_statfs __NR3264_statfs
 #define __NR_fstatfs __NR3264_fstatfs
 #define __NR_truncate __NR3264_truncate
-#define __NR_ftruncate __NR3264_ftruncate
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_ftruncate __NR3264_ftruncate
 #define __NR_lseek __NR3264_lseek
 #define __NR_sendfile __NR3264_sendfile
 #define __NR_newfstatat __NR3264_fstatat
-#define __NR_fstat __NR3264_fstat
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fstat __NR3264_fstat
 #define __NR_mmap __NR3264_mmap
 #define __NR_fadvise64 __NR3264_fadvise64
 #ifdef __NR3264_stat
-#define __NR_stat __NR3264_stat
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_stat __NR3264_stat
 #define __NR_lstat __NR3264_lstat
 #endif
 #else
-#define __NR_fcntl64 __NR3264_fcntl
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fcntl64 __NR3264_fcntl
 #define __NR_statfs64 __NR3264_statfs
 #define __NR_fstatfs64 __NR3264_fstatfs
 #define __NR_truncate64 __NR3264_truncate
-#define __NR_ftruncate64 __NR3264_ftruncate
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_ftruncate64 __NR3264_ftruncate
 #define __NR_llseek __NR3264_lseek
 #define __NR_sendfile64 __NR3264_sendfile
 #define __NR_fstatat64 __NR3264_fstatat
-#define __NR_fstat64 __NR3264_fstat
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fstat64 __NR3264_fstat
 #define __NR_mmap2 __NR3264_mmap
 #define __NR_fadvise64_64 __NR3264_fadvise64
 #ifdef __NR3264_stat
-#define __NR_stat64 __NR3264_stat
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_stat64 __NR3264_stat
 #define __NR_lstat64 __NR3264_lstat
 #endif
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-mips/asm/auxvec.h b/libc/kernel/uapi/asm-mips/asm/auxvec.h
index 2fa0e6b..3aa54b6 100644
--- a/libc/kernel/uapi/asm-mips/asm/auxvec.h
+++ b/libc/kernel/uapi/asm-mips/asm/auxvec.h
@@ -16,4 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include <asm-generic/auxvec.h>
+#ifndef __ASM_AUXVEC_H
+#define __ASM_AUXVEC_H
+#define AT_SYSINFO_EHDR 33
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-mips/asm/inst.h b/libc/kernel/uapi/asm-mips/asm/inst.h
index 7446223..1f05464 100644
--- a/libc/kernel/uapi/asm-mips/asm/inst.h
+++ b/libc/kernel/uapi/asm-mips/asm/inst.h
@@ -314,790 +314,807 @@
   mthc_op = 0x07,
   bc_op = 0x08,
   bc1eqz_op = 0x09,
-  bc1nez_op = 0x0d,
+  mfmc0_op = 0x0b,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  bc1nez_op = 0x0d,
+  wrpgpr_op = 0x0e,
   cop_op = 0x10,
   copm_op = 0x18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum bcop_op {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   bcf_op,
   bct_op,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   bcfl_op,
   bctl_op
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum cop0_coi_func {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   tlbr_op = 0x01,
   tlbwi_op = 0x02,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   tlbwr_op = 0x06,
   tlbp_op = 0x08,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   rfe_op = 0x10,
   eret_op = 0x18,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   wait_op = 0x20,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum cop0_com_func {
   tlbr1_op = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   tlbw_op = 0x02,
   tlbp1_op = 0x08,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   dctr_op = 0x09,
   dctw_op = 0x0a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum cop1_fmt {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   s_fmt,
   d_fmt,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   e_fmt,
   q_fmt,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   w_fmt,
   l_fmt
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum cop1_sdw_func {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fadd_op = 0x00,
   fsub_op = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fmul_op = 0x02,
   fdiv_op = 0x03,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fsqrt_op = 0x04,
   fabs_op = 0x05,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fmov_op = 0x06,
   fneg_op = 0x07,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   froundl_op = 0x08,
   ftruncl_op = 0x09,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fceill_op = 0x0a,
   ffloorl_op = 0x0b,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fround_op = 0x0c,
   ftrunc_op = 0x0d,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fceil_op = 0x0e,
   ffloor_op = 0x0f,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  fsel_op = 0x10,
   fmovc_op = 0x11,
   fmovz_op = 0x12,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fmovn_op = 0x13,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fseleqz_op = 0x14,
   frecip_op = 0x15,
   frsqrt_op = 0x16,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fselnez_op = 0x17,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fmaddf_op = 0x18,
   fmsubf_op = 0x19,
   frint_op = 0x1a,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fclass_op = 0x1b,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fmin_op = 0x1c,
   fmina_op = 0x1d,
   fmax_op = 0x1e,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fmaxa_op = 0x1f,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fcvts_op = 0x20,
   fcvtd_op = 0x21,
   fcvte_op = 0x22,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fcvtw_op = 0x24,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   fcvtl_op = 0x25,
   fcmp_op = 0x30
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum cop1x_func {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   lwxc1_op = 0x00,
   ldxc1_op = 0x01,
   swxc1_op = 0x08,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   sdxc1_op = 0x09,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   pfetch_op = 0x0f,
   madd_s_op = 0x20,
   madd_d_op = 0x21,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   madd_e_op = 0x22,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   msub_s_op = 0x28,
   msub_d_op = 0x29,
   msub_e_op = 0x2a,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   nmadd_s_op = 0x30,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   nmadd_d_op = 0x31,
   nmadd_e_op = 0x32,
   nmsub_s_op = 0x38,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   nmsub_d_op = 0x39,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   nmsub_e_op = 0x3a
 };
 enum mad_func {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   madd_fp_op = 0x08,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   msub_fp_op = 0x0a,
   nmadd_fp_op = 0x0c,
   nmsub_fp_op = 0x0e
+};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum ptw_func {
+  lwdir_op = 0x00,
+  lwpte_op = 0x01,
+  lddir_op = 0x02,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ldpte_op = 0x03,
 };
 enum lx_func {
   lwx_op = 0x00,
-  lhx_op = 0x04,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  lhx_op = 0x04,
   lbux_op = 0x06,
   ldx_op = 0x08,
   lwux_op = 0x10,
-  lhux_op = 0x14,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  lhux_op = 0x14,
   lbx_op = 0x16,
 };
 enum bshfl_func {
-  wsbh_op = 0x2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  wsbh_op = 0x2,
   dshd_op = 0x5,
   seb_op = 0x10,
   seh_op = 0x18,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum msa_mi10_func {
   msa_ld_op = 8,
   msa_st_op = 9,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum msa_2b_fmt {
   msa_fmt_b = 0,
   msa_fmt_h = 1,
-  msa_fmt_w = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  msa_fmt_w = 2,
   msa_fmt_d = 3,
 };
 enum mm_major_op {
-  mm_pool32a_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_pool32a_op,
   mm_pool16a_op,
   mm_lbu16_op,
   mm_move16_op,
-  mm_addi32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_addi32_op,
   mm_lbu32_op,
   mm_sb32_op,
   mm_lb32_op,
-  mm_pool32b_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_pool32b_op,
   mm_pool16b_op,
   mm_lhu16_op,
   mm_andi16_op,
-  mm_addiu32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_addiu32_op,
   mm_lhu32_op,
   mm_sh32_op,
   mm_lh32_op,
-  mm_pool32i_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_pool32i_op,
   mm_pool16c_op,
   mm_lwsp16_op,
   mm_pool16d_op,
-  mm_ori32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_ori32_op,
   mm_pool32f_op,
   mm_reserved1_op,
   mm_reserved2_op,
-  mm_pool32c_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_pool32c_op,
   mm_lwgp16_op,
   mm_lw16_op,
   mm_pool16e_op,
-  mm_xori32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_xori32_op,
   mm_jals32_op,
   mm_addiupc_op,
   mm_reserved3_op,
-  mm_reserved4_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_reserved4_op,
   mm_pool16f_op,
   mm_sb16_op,
   mm_beqz16_op,
-  mm_slti32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_slti32_op,
   mm_beq32_op,
   mm_swc132_op,
   mm_lwc132_op,
-  mm_reserved5_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_reserved5_op,
   mm_reserved6_op,
   mm_sh16_op,
   mm_bnez16_op,
-  mm_sltiu32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_sltiu32_op,
   mm_bne32_op,
   mm_sdc132_op,
   mm_ldc132_op,
-  mm_reserved7_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_reserved7_op,
   mm_reserved8_op,
   mm_swsp16_op,
   mm_b16_op,
-  mm_andi32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_andi32_op,
   mm_j32_op,
   mm_sd32_op,
   mm_ld32_op,
-  mm_reserved11_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_reserved11_op,
   mm_reserved12_op,
   mm_sw16_op,
   mm_li16_op,
-  mm_jalx32_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_jalx32_op,
   mm_jal32_op,
   mm_sw32_op,
   mm_lw32_op,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum mm_32i_minor_op {
   mm_bltz_op,
   mm_bltzal_op,
-  mm_bgez_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_bgez_op,
   mm_bgezal_op,
   mm_blez_op,
   mm_bnezc_op,
-  mm_bgtz_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_bgtz_op,
   mm_beqzc_op,
   mm_tlti_op,
   mm_tgei_op,
-  mm_tltiu_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_tltiu_op,
   mm_tgeiu_op,
   mm_tnei_op,
   mm_lui_op,
-  mm_teqi_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_teqi_op,
   mm_reserved13_op,
   mm_synci_op,
   mm_bltzals_op,
-  mm_reserved14_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_reserved14_op,
   mm_bgezals_op,
   mm_bc2f_op,
   mm_bc2t_op,
-  mm_reserved15_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_reserved15_op,
   mm_reserved16_op,
   mm_reserved17_op,
   mm_reserved18_op,
-  mm_bposge64_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_bposge64_op,
   mm_bposge32_op,
   mm_bc1f_op,
   mm_bc1t_op,
-  mm_reserved19_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_reserved19_op,
   mm_reserved20_op,
   mm_bc1any2f_op,
   mm_bc1any2t_op,
-  mm_bc1any4f_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_bc1any4f_op,
   mm_bc1any4t_op,
 };
 enum mm_32a_minor_op {
-  mm_sll32_op = 0x000,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_sll32_op = 0x000,
   mm_ins_op = 0x00c,
   mm_sllv32_op = 0x010,
   mm_ext_op = 0x02c,
-  mm_pool32axf_op = 0x03c,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_pool32axf_op = 0x03c,
   mm_srl32_op = 0x040,
   mm_sra_op = 0x080,
   mm_srlv32_op = 0x090,
-  mm_rotr_op = 0x0c0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_rotr_op = 0x0c0,
   mm_lwxs_op = 0x118,
   mm_addu32_op = 0x150,
   mm_subu32_op = 0x1d0,
-  mm_wsbh_op = 0x1ec,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_wsbh_op = 0x1ec,
   mm_mul_op = 0x210,
   mm_and_op = 0x250,
   mm_or32_op = 0x290,
-  mm_xor32_op = 0x310,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_xor32_op = 0x310,
   mm_slt_op = 0x350,
   mm_sltu_op = 0x390,
 };
-enum mm_32b_func {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum mm_32b_func {
   mm_lwc2_func = 0x0,
   mm_lwp_func = 0x1,
   mm_ldc2_func = 0x2,
-  mm_ldp_func = 0x4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_ldp_func = 0x4,
   mm_lwm32_func = 0x5,
   mm_cache_func = 0x6,
   mm_ldm_func = 0x7,
-  mm_swc2_func = 0x8,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_swc2_func = 0x8,
   mm_swp_func = 0x9,
   mm_sdc2_func = 0xa,
   mm_sdp_func = 0xc,
-  mm_swm32_func = 0xd,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_swm32_func = 0xd,
   mm_sdm_func = 0xf,
 };
 enum mm_32c_func {
-  mm_pref_func = 0x2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_pref_func = 0x2,
   mm_ll_func = 0x3,
   mm_swr_func = 0x9,
   mm_sc_func = 0xb,
-  mm_lwu_func = 0xe,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_lwu_func = 0xe,
 };
 enum mm_32axf_minor_op {
   mm_mfc0_op = 0x003,
-  mm_mtc0_op = 0x00b,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_mtc0_op = 0x00b,
   mm_tlbp_op = 0x00d,
   mm_mfhi32_op = 0x035,
   mm_jalr_op = 0x03c,
-  mm_tlbr_op = 0x04d,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_tlbr_op = 0x04d,
   mm_mflo32_op = 0x075,
   mm_jalrhb_op = 0x07c,
   mm_tlbwi_op = 0x08d,
-  mm_tlbwr_op = 0x0cd,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_tlbwr_op = 0x0cd,
   mm_jalrs_op = 0x13c,
   mm_jalrshb_op = 0x17c,
   mm_sync_op = 0x1ad,
-  mm_syscall_op = 0x22d,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_syscall_op = 0x22d,
   mm_wait_op = 0x24d,
   mm_eret_op = 0x3cd,
   mm_divu_op = 0x5dc,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum mm_32f_minor_op {
   mm_32f_00_op = 0x00,
   mm_32f_01_op = 0x01,
-  mm_32f_02_op = 0x02,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_32f_02_op = 0x02,
   mm_32f_10_op = 0x08,
   mm_32f_11_op = 0x09,
   mm_32f_12_op = 0x0a,
-  mm_32f_20_op = 0x10,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_32f_20_op = 0x10,
   mm_32f_30_op = 0x18,
   mm_32f_40_op = 0x20,
   mm_32f_41_op = 0x21,
-  mm_32f_42_op = 0x22,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_32f_42_op = 0x22,
   mm_32f_50_op = 0x28,
   mm_32f_51_op = 0x29,
   mm_32f_52_op = 0x2a,
-  mm_32f_60_op = 0x30,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_32f_60_op = 0x30,
   mm_32f_70_op = 0x38,
   mm_32f_73_op = 0x3b,
   mm_32f_74_op = 0x3c,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum mm_32f_10_minor_op {
   mm_lwxc1_op = 0x1,
   mm_swxc1_op,
-  mm_ldxc1_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_ldxc1_op,
   mm_sdxc1_op,
   mm_luxc1_op,
   mm_suxc1_op,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum mm_32f_func {
   mm_lwxc1_func = 0x048,
   mm_swxc1_func = 0x088,
-  mm_ldxc1_func = 0x0c8,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_ldxc1_func = 0x0c8,
   mm_sdxc1_func = 0x108,
 };
 enum mm_32f_40_minor_op {
-  mm_fmovf_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_fmovf_op,
   mm_fmovt_op,
 };
 enum mm_32f_60_minor_op {
-  mm_fadd_op,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_fadd_op,
   mm_fsub_op,
   mm_fmul_op,
   mm_fdiv_op,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum mm_32f_70_minor_op {
   mm_fmovn_op,
   mm_fmovz_op,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum mm_32f_73_minor_op {
   mm_fmov0_op = 0x01,
   mm_fcvtl_op = 0x04,
-  mm_movf0_op = 0x05,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_movf0_op = 0x05,
   mm_frsqrt_op = 0x08,
   mm_ffloorl_op = 0x0c,
   mm_fabs0_op = 0x0d,
-  mm_fcvtw_op = 0x24,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_fcvtw_op = 0x24,
   mm_movt0_op = 0x25,
   mm_fsqrt_op = 0x28,
   mm_ffloorw_op = 0x2c,
-  mm_fneg0_op = 0x2d,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_fneg0_op = 0x2d,
   mm_cfc1_op = 0x40,
   mm_frecip_op = 0x48,
   mm_fceill_op = 0x4c,
-  mm_fcvtd0_op = 0x4d,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_fcvtd0_op = 0x4d,
   mm_ctc1_op = 0x60,
   mm_fceilw_op = 0x6c,
   mm_fcvts0_op = 0x6d,
-  mm_mfc1_op = 0x80,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_mfc1_op = 0x80,
   mm_fmov1_op = 0x81,
   mm_movf1_op = 0x85,
   mm_ftruncl_op = 0x8c,
-  mm_fabs1_op = 0x8d,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_fabs1_op = 0x8d,
   mm_mtc1_op = 0xa0,
   mm_movt1_op = 0xa5,
   mm_ftruncw_op = 0xac,
-  mm_fneg1_op = 0xad,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_fneg1_op = 0xad,
   mm_mfhc1_op = 0xc0,
   mm_froundl_op = 0xcc,
   mm_fcvtd1_op = 0xcd,
-  mm_mthc1_op = 0xe0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_mthc1_op = 0xe0,
   mm_froundw_op = 0xec,
   mm_fcvts1_op = 0xed,
 };
-enum mm_16c_minor_op {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum mm_16c_minor_op {
   mm_lwm16_op = 0x04,
   mm_swm16_op = 0x05,
   mm_jr16_op = 0x0c,
-  mm_jrc_op = 0x0d,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  mm_jrc_op = 0x0d,
   mm_jalr16_op = 0x0e,
   mm_jalrs16_op = 0x0f,
   mm_jraddiusp_op = 0x18,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum mm_16d_minor_op {
   mm_addius5_func,
   mm_addiusp_func,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum MIPS16e_ops {
   MIPS16e_jal_op = 003,
   MIPS16e_ld_op = 007,
-  MIPS16e_i8_op = 014,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MIPS16e_i8_op = 014,
   MIPS16e_sd_op = 017,
   MIPS16e_lb_op = 020,
   MIPS16e_lh_op = 021,
-  MIPS16e_lwsp_op = 022,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MIPS16e_lwsp_op = 022,
   MIPS16e_lw_op = 023,
   MIPS16e_lbu_op = 024,
   MIPS16e_lhu_op = 025,
-  MIPS16e_lwpc_op = 026,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MIPS16e_lwpc_op = 026,
   MIPS16e_lwu_op = 027,
   MIPS16e_sb_op = 030,
   MIPS16e_sh_op = 031,
-  MIPS16e_swsp_op = 032,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MIPS16e_swsp_op = 032,
   MIPS16e_sw_op = 033,
   MIPS16e_rr_op = 035,
   MIPS16e_extend_op = 036,
-  MIPS16e_i64_op = 037,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MIPS16e_i64_op = 037,
 };
 enum MIPS16e_i64_func {
   MIPS16e_ldsp_func,
-  MIPS16e_sdsp_func,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MIPS16e_sdsp_func,
   MIPS16e_sdrasp_func,
   MIPS16e_dadjsp_func,
   MIPS16e_ldpc_func,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum MIPS16e_rr_func {
   MIPS16e_jr_func,
 };
-enum MIPS6e_i8_func {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum MIPS6e_i8_func {
   MIPS16e_swrasp_func = 02,
 };
 #define MM_NOP16 0x0c00
-struct j_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct j_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int target : 26,;
  ))
 };
-struct i_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct i_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(signed int simmediate : 16,;
  ))))
 };
-struct u_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct u_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int uimmediate : 16,;
  ))))
 };
-struct c_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct c_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int c_op : 3, __BITFIELD_FIELD(unsigned int cache : 2, __BITFIELD_FIELD(unsigned int simmediate : 16,;
  )))))
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct r_format {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int rd : 5, __BITFIELD_FIELD(unsigned int re : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct p_format {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int rd : 5, __BITFIELD_FIELD(unsigned int re : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct f_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct f_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int : 1, __BITFIELD_FIELD(unsigned int fmt : 4, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int rd : 5, __BITFIELD_FIELD(unsigned int re : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  )))))))
 };
-struct ma_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ma_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int fr : 5, __BITFIELD_FIELD(unsigned int ft : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int func : 4, __BITFIELD_FIELD(unsigned int fmt : 2,;
  )))))))
 };
-struct b_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct b_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int code : 20, __BITFIELD_FIELD(unsigned int func : 6,;
  )))
 };
-struct ps_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ps_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int ft : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct v_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int sel : 4, __BITFIELD_FIELD(unsigned int fmt : 1, __BITFIELD_FIELD(unsigned int vt : 5, __BITFIELD_FIELD(unsigned int vs : 5, __BITFIELD_FIELD(unsigned int vd : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  )))))))
 };
-struct msa_mi10_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct msa_mi10_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(signed int s10 : 10, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int wd : 5, __BITFIELD_FIELD(unsigned int func : 4, __BITFIELD_FIELD(unsigned int df : 2,;
  ))))))
 };
-struct spec3_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct spec3_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(signed int simmediate : 9, __BITFIELD_FIELD(unsigned int func : 7,;
  )))))
 };
-struct fb_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct fb_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int bc : 5, __BITFIELD_FIELD(unsigned int cc : 3, __BITFIELD_FIELD(unsigned int flag : 2, __BITFIELD_FIELD(signed int simmediate : 16,;
  )))))
 };
-struct fp0_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct fp0_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int fmt : 5, __BITFIELD_FIELD(unsigned int ft : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct mm_fp0_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_fp0_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int ft : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int fmt : 3, __BITFIELD_FIELD(unsigned int op : 2, __BITFIELD_FIELD(unsigned int func : 6,;
  )))))))
 };
-struct fp1_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct fp1_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int op : 5, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct mm_fp1_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_fp1_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fmt : 2, __BITFIELD_FIELD(unsigned int op : 8, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct mm_fp2_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_fp2_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int cc : 3, __BITFIELD_FIELD(unsigned int zero : 2, __BITFIELD_FIELD(unsigned int fmt : 2, __BITFIELD_FIELD(unsigned int op : 3, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))))
 };
-struct mm_fp3_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_fp3_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fmt : 3, __BITFIELD_FIELD(unsigned int op : 7, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct mm_fp4_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_fp4_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int cc : 3, __BITFIELD_FIELD(unsigned int fmt : 3, __BITFIELD_FIELD(unsigned int cond : 4, __BITFIELD_FIELD(unsigned int func : 6,;
  )))))))
 };
-struct mm_fp5_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_fp5_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int index : 5, __BITFIELD_FIELD(unsigned int base : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int op : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct fp6_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct fp6_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int fr : 5, __BITFIELD_FIELD(unsigned int ft : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct mm_fp6_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_fp6_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int ft : 5, __BITFIELD_FIELD(unsigned int fs : 5, __BITFIELD_FIELD(unsigned int fd : 5, __BITFIELD_FIELD(unsigned int fr : 5, __BITFIELD_FIELD(unsigned int func : 6,;
  ))))))
 };
-struct mm_i_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_i_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(unsigned int rs : 5, __BITFIELD_FIELD(signed int simmediate : 16,;
  ))))
 };
-struct mm_m_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_m_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rd : 5, __BITFIELD_FIELD(unsigned int base : 5, __BITFIELD_FIELD(unsigned int func : 4, __BITFIELD_FIELD(signed int simmediate : 12,;
  )))))
 };
-struct mm_x_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_x_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int index : 5, __BITFIELD_FIELD(unsigned int base : 5, __BITFIELD_FIELD(unsigned int rd : 5, __BITFIELD_FIELD(unsigned int func : 11,;
  )))))
 };
-struct mm_b0_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_a_format {
+  __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 3, __BITFIELD_FIELD(signed int simmediate : 23,;
+ )))
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_b0_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(signed int simmediate : 10, __BITFIELD_FIELD(unsigned int : 16,;
  )))
 };
-struct mm_b1_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_b1_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rs : 3, __BITFIELD_FIELD(signed int simmediate : 7, __BITFIELD_FIELD(unsigned int : 16,;
  ))))
 };
-struct mm16_m_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm16_m_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int func : 4, __BITFIELD_FIELD(unsigned int rlist : 2, __BITFIELD_FIELD(unsigned int imm : 4, __BITFIELD_FIELD(unsigned int : 16,;
  )))))
 };
-struct mm16_rb_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm16_rb_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 3, __BITFIELD_FIELD(unsigned int base : 3, __BITFIELD_FIELD(signed int simmediate : 4, __BITFIELD_FIELD(unsigned int : 16,;
  )))))
 };
-struct mm16_r3_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm16_r3_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 3, __BITFIELD_FIELD(signed int simmediate : 7, __BITFIELD_FIELD(unsigned int : 16,;
  ))))
 };
-struct mm16_r5_format {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm16_r5_format {
   __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 5, __BITFIELD_FIELD(signed int simmediate : 5, __BITFIELD_FIELD(unsigned int : 16,;
  ))))
 };
-struct m16e_rr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct m16e_rr {
   __BITFIELD_FIELD(unsigned int opcode : 5, __BITFIELD_FIELD(unsigned int rx : 3, __BITFIELD_FIELD(unsigned int nd : 1, __BITFIELD_FIELD(unsigned int l : 1, __BITFIELD_FIELD(unsigned int ra : 1, __BITFIELD_FIELD(unsigned int func : 5,;
  ))))))
 };
-struct m16e_jal {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct m16e_jal {
   __BITFIELD_FIELD(unsigned int opcode : 5, __BITFIELD_FIELD(unsigned int x : 1, __BITFIELD_FIELD(unsigned int imm20_16 : 5, __BITFIELD_FIELD(signed int imm25_21 : 5,;
  ))))
 };
-struct m16e_i64 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct m16e_i64 {
   __BITFIELD_FIELD(unsigned int opcode : 5, __BITFIELD_FIELD(unsigned int func : 3, __BITFIELD_FIELD(unsigned int imm : 8,;
  )))
 };
-struct m16e_ri64 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct m16e_ri64 {
   __BITFIELD_FIELD(unsigned int opcode : 5, __BITFIELD_FIELD(unsigned int func : 3, __BITFIELD_FIELD(unsigned int ry : 3, __BITFIELD_FIELD(unsigned int imm : 5,;
  ))))
 };
-struct m16e_ri {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct m16e_ri {
   __BITFIELD_FIELD(unsigned int opcode : 5, __BITFIELD_FIELD(unsigned int rx : 3, __BITFIELD_FIELD(unsigned int imm : 8,;
  )))
 };
-struct m16e_rri {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct m16e_rri {
   __BITFIELD_FIELD(unsigned int opcode : 5, __BITFIELD_FIELD(unsigned int rx : 3, __BITFIELD_FIELD(unsigned int ry : 3, __BITFIELD_FIELD(unsigned int imm : 5,;
  ))))
 };
-struct m16e_i8 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct m16e_i8 {
   __BITFIELD_FIELD(unsigned int opcode : 5, __BITFIELD_FIELD(unsigned int func : 3, __BITFIELD_FIELD(unsigned int imm : 8,;
  )))
 };
-union mips_instruction {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+union mips_instruction {
   unsigned int word;
   unsigned short halfword[2];
   unsigned char byte[4];
-  struct j_format j_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct j_format j_format;
   struct i_format i_format;
   struct u_format u_format;
   struct c_format c_format;
-  struct r_format r_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct r_format r_format;
   struct p_format p_format;
   struct f_format f_format;
   struct ma_format ma_format;
-  struct msa_mi10_format msa_mi10_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct msa_mi10_format msa_mi10_format;
   struct b_format b_format;
   struct ps_format ps_format;
   struct v_format v_format;
-  struct spec3_format spec3_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct spec3_format spec3_format;
   struct fb_format fb_format;
   struct fp0_format fp0_format;
   struct mm_fp0_format mm_fp0_format;
-  struct fp1_format fp1_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct fp1_format fp1_format;
   struct mm_fp1_format mm_fp1_format;
   struct mm_fp2_format mm_fp2_format;
   struct mm_fp3_format mm_fp3_format;
-  struct mm_fp4_format mm_fp4_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct mm_fp4_format mm_fp4_format;
   struct mm_fp5_format mm_fp5_format;
   struct fp6_format fp6_format;
   struct mm_fp6_format mm_fp6_format;
-  struct mm_i_format mm_i_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct mm_i_format mm_i_format;
   struct mm_m_format mm_m_format;
   struct mm_x_format mm_x_format;
+  struct mm_a_format mm_a_format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct mm_b0_format mm_b0_format;
   struct mm_b1_format mm_b1_format;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct mm16_m_format mm16_m_format;
   struct mm16_rb_format mm16_rb_format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct mm16_r3_format mm16_r3_format;
   struct mm16_r5_format mm16_r5_format;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 union mips16e_instruction {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int full : 16;
   struct m16e_rr rr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct m16e_jal jal;
   struct m16e_i64 i64;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct m16e_ri64 ri64;
   struct m16e_ri ri;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct m16e_rri rri;
   struct m16e_i8 i8;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-mips/asm/mman.h b/libc/kernel/uapi/asm-mips/asm/mman.h
index 7d7f68d..d126014 100644
--- a/libc/kernel/uapi/asm-mips/asm/mman.h
+++ b/libc/kernel/uapi/asm-mips/asm/mman.h
@@ -64,21 +64,22 @@
 #define MADV_SEQUENTIAL 2
 #define MADV_WILLNEED 3
 #define MADV_DONTNEED 4
-#define MADV_REMOVE 9
+#define MADV_FREE 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_REMOVE 9
 #define MADV_DONTFORK 10
 #define MADV_DOFORK 11
 #define MADV_MERGEABLE 12
-#define MADV_UNMERGEABLE 13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_UNMERGEABLE 13
 #define MADV_HWPOISON 100
 #define MADV_HUGEPAGE 14
 #define MADV_NOHUGEPAGE 15
-#define MADV_DONTDUMP 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_DONTDUMP 16
 #define MADV_DODUMP 17
 #define MAP_FILE 0
 #define MAP_HUGE_SHIFT 26
-#define MAP_HUGE_MASK 0x3f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_HUGE_MASK 0x3f
 #endif
diff --git a/libc/kernel/uapi/asm-mips/asm/siginfo.h b/libc/kernel/uapi/asm-mips/asm/siginfo.h
index 758327c..98aead4 100644
--- a/libc/kernel/uapi/asm-mips/asm/siginfo.h
+++ b/libc/kernel/uapi/asm-mips/asm/siginfo.h
@@ -43,12 +43,12 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     int _pad[SI_PAD_SIZE];
     struct {
-      pid_t _pid;
+      __kernel_pid_t _pid;
       __ARCH_SI_UID_T _uid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } _kill;
     struct {
-      timer_t _tid;
+      __kernel_timer_t _tid;
       int _overrun;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       char _pad[sizeof(__ARCH_SI_UID_T) - sizeof(int)];
@@ -57,26 +57,26 @@
     } _timer;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
-      pid_t _pid;
+      __kernel_pid_t _pid;
       __ARCH_SI_UID_T _uid;
       sigval_t _sigval;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } _rt;
     struct {
-      pid_t _pid;
+      __kernel_pid_t _pid;
       __ARCH_SI_UID_T _uid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       int _status;
-      clock_t _utime;
-      clock_t _stime;
+      __kernel_clock_t _utime;
+      __kernel_clock_t _stime;
     } _sigchld;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
-      pid_t _pid;
-      clock_t _utime;
+      __kernel_pid_t _pid;
+      __kernel_clock_t _utime;
       int _status;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-      clock_t _stime;
+      __kernel_clock_t _stime;
     } _irix_sigchld;
     struct {
       void __user * _addr;
@@ -86,33 +86,35 @@
 #endif
       short _addr_lsb;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-      struct {
-        void __user * _lower;
-        void __user * _upper;
-      } _addr_bnd;
+      union {
+        struct {
+          void __user * _lower;
+          void __user * _upper;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+        } _addr_bnd;
+        __u32 _pkey;
+      };
     } _sigfault;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __ARCH_SI_BAND_T _band;
       int _fd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } _sigpoll;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       void __user * _call_addr;
       int _syscall;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       unsigned int _arch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } _sigsys;
   } _sifields;
 } siginfo_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef SI_ASYNCIO
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef SI_TIMER
 #undef SI_MESGQ
 #define SI_ASYNCIO - 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TIMER __SI_CODE(__SI_TIMER, - 3)
-#define SI_MESGQ __SI_CODE(__SI_MESGQ, - 4)
-#include <asm-generic/siginfo.h>
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SI_MESGQ __SI_CODE(__SI_MESGQ, - 4)
+#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/socket.h b/libc/kernel/uapi/asm-mips/asm/socket.h
index 4405053..5bbb046 100644
--- a/libc/kernel/uapi/asm-mips/asm/socket.h
+++ b/libc/kernel/uapi/asm-mips/asm/socket.h
@@ -92,4 +92,8 @@
 #define SO_ATTACH_BPF 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_DETACH_BPF SO_DETACH_FILTER
+#define SO_ATTACH_REUSEPORT_CBPF 51
+#define SO_ATTACH_REUSEPORT_EBPF 52
+#define SO_CNX_ADVICE 53
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/asm-mips/asm/ucontext.h b/libc/kernel/uapi/asm-mips/asm/ucontext.h
index aa4d67d..16c9487 100644
--- a/libc/kernel/uapi/asm-mips/asm/ucontext.h
+++ b/libc/kernel/uapi/asm-mips/asm/ucontext.h
@@ -16,4 +16,30 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include <asm-generic/ucontext.h>
+#ifndef __MIPS_UAPI_ASM_UCONTEXT_H
+#define __MIPS_UAPI_ASM_UCONTEXT_H
+struct extcontext {
+  unsigned int magic;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int size;
+};
+struct msa_extcontext {
+  struct extcontext ext;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MSA_EXTCONTEXT_MAGIC 0x784d5341
+  unsigned long long wr[32];
+  unsigned int csr;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define END_EXTCONTEXT_MAGIC 0x78454e44
+struct ucontext {
+  unsigned long uc_flags;
+  struct ucontext * uc_link;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  stack_t uc_stack;
+  struct sigcontext uc_mcontext;
+  sigset_t uc_sigmask;
+  unsigned long long uc_extcontext[0];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#endif
diff --git a/libc/kernel/uapi/asm-mips/asm/unistd.h b/libc/kernel/uapi/asm-mips/asm/unistd.h
index d5c3de3..7a7c507 100644
--- a/libc/kernel/uapi/asm-mips/asm/unistd.h
+++ b/libc/kernel/uapi/asm-mips/asm/unistd.h
@@ -471,826 +471,838 @@
 #define __NR_membarrier (__NR_Linux + 358)
 #define __NR_mlock2 (__NR_Linux + 359)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __NR_Linux_syscalls 359
+#define __NR_copy_file_range (__NR_Linux + 360)
+#define __NR_preadv2 (__NR_Linux + 361)
+#define __NR_pwritev2 (__NR_Linux + 362)
+#define __NR_Linux_syscalls 362
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define __NR_O32_Linux 4000
-#define __NR_O32_Linux_syscalls 359
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_O32_Linux_syscalls 362
 #if _MIPS_SIM == _MIPS_SIM_ABI64
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_Linux 5000
 #define __NR_read (__NR_Linux + 0)
 #define __NR_write (__NR_Linux + 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_open (__NR_Linux + 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_close (__NR_Linux + 3)
 #define __NR_stat (__NR_Linux + 4)
 #define __NR_fstat (__NR_Linux + 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lstat (__NR_Linux + 6)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_poll (__NR_Linux + 7)
 #define __NR_lseek (__NR_Linux + 8)
 #define __NR_mmap (__NR_Linux + 9)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mprotect (__NR_Linux + 10)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_munmap (__NR_Linux + 11)
 #define __NR_brk (__NR_Linux + 12)
 #define __NR_rt_sigaction (__NR_Linux + 13)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigprocmask (__NR_Linux + 14)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ioctl (__NR_Linux + 15)
 #define __NR_pread64 (__NR_Linux + 16)
 #define __NR_pwrite64 (__NR_Linux + 17)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readv (__NR_Linux + 18)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_writev (__NR_Linux + 19)
 #define __NR_access (__NR_Linux + 20)
 #define __NR_pipe (__NR_Linux + 21)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR__newselect (__NR_Linux + 22)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_yield (__NR_Linux + 23)
 #define __NR_mremap (__NR_Linux + 24)
 #define __NR_msync (__NR_Linux + 25)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mincore (__NR_Linux + 26)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_madvise (__NR_Linux + 27)
 #define __NR_shmget (__NR_Linux + 28)
 #define __NR_shmat (__NR_Linux + 29)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmctl (__NR_Linux + 30)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_dup (__NR_Linux + 31)
 #define __NR_dup2 (__NR_Linux + 32)
 #define __NR_pause (__NR_Linux + 33)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_nanosleep (__NR_Linux + 34)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getitimer (__NR_Linux + 35)
 #define __NR_setitimer (__NR_Linux + 36)
 #define __NR_alarm (__NR_Linux + 37)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpid (__NR_Linux + 38)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendfile (__NR_Linux + 39)
 #define __NR_socket (__NR_Linux + 40)
 #define __NR_connect (__NR_Linux + 41)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_accept (__NR_Linux + 42)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendto (__NR_Linux + 43)
 #define __NR_recvfrom (__NR_Linux + 44)
 #define __NR_sendmsg (__NR_Linux + 45)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_recvmsg (__NR_Linux + 46)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shutdown (__NR_Linux + 47)
 #define __NR_bind (__NR_Linux + 48)
 #define __NR_listen (__NR_Linux + 49)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsockname (__NR_Linux + 50)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpeername (__NR_Linux + 51)
 #define __NR_socketpair (__NR_Linux + 52)
 #define __NR_setsockopt (__NR_Linux + 53)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsockopt (__NR_Linux + 54)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clone (__NR_Linux + 55)
 #define __NR_fork (__NR_Linux + 56)
 #define __NR_execve (__NR_Linux + 57)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_exit (__NR_Linux + 58)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_wait4 (__NR_Linux + 59)
 #define __NR_kill (__NR_Linux + 60)
 #define __NR_uname (__NR_Linux + 61)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semget (__NR_Linux + 62)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semop (__NR_Linux + 63)
 #define __NR_semctl (__NR_Linux + 64)
 #define __NR_shmdt (__NR_Linux + 65)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgget (__NR_Linux + 66)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgsnd (__NR_Linux + 67)
 #define __NR_msgrcv (__NR_Linux + 68)
 #define __NR_msgctl (__NR_Linux + 69)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fcntl (__NR_Linux + 70)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_flock (__NR_Linux + 71)
 #define __NR_fsync (__NR_Linux + 72)
 #define __NR_fdatasync (__NR_Linux + 73)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_truncate (__NR_Linux + 74)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ftruncate (__NR_Linux + 75)
 #define __NR_getdents (__NR_Linux + 76)
 #define __NR_getcwd (__NR_Linux + 77)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_chdir (__NR_Linux + 78)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchdir (__NR_Linux + 79)
 #define __NR_rename (__NR_Linux + 80)
 #define __NR_mkdir (__NR_Linux + 81)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rmdir (__NR_Linux + 82)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_creat (__NR_Linux + 83)
 #define __NR_link (__NR_Linux + 84)
 #define __NR_unlink (__NR_Linux + 85)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_symlink (__NR_Linux + 86)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readlink (__NR_Linux + 87)
 #define __NR_chmod (__NR_Linux + 88)
 #define __NR_fchmod (__NR_Linux + 89)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_chown (__NR_Linux + 90)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchown (__NR_Linux + 91)
 #define __NR_lchown (__NR_Linux + 92)
 #define __NR_umask (__NR_Linux + 93)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_gettimeofday (__NR_Linux + 94)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getrlimit (__NR_Linux + 95)
 #define __NR_getrusage (__NR_Linux + 96)
 #define __NR_sysinfo (__NR_Linux + 97)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_times (__NR_Linux + 98)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ptrace (__NR_Linux + 99)
 #define __NR_getuid (__NR_Linux + 100)
 #define __NR_syslog (__NR_Linux + 101)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getgid (__NR_Linux + 102)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setuid (__NR_Linux + 103)
 #define __NR_setgid (__NR_Linux + 104)
 #define __NR_geteuid (__NR_Linux + 105)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getegid (__NR_Linux + 106)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setpgid (__NR_Linux + 107)
 #define __NR_getppid (__NR_Linux + 108)
 #define __NR_getpgrp (__NR_Linux + 109)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setsid (__NR_Linux + 110)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setreuid (__NR_Linux + 111)
 #define __NR_setregid (__NR_Linux + 112)
 #define __NR_getgroups (__NR_Linux + 113)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setgroups (__NR_Linux + 114)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setresuid (__NR_Linux + 115)
 #define __NR_getresuid (__NR_Linux + 116)
 #define __NR_setresgid (__NR_Linux + 117)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getresgid (__NR_Linux + 118)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpgid (__NR_Linux + 119)
 #define __NR_setfsuid (__NR_Linux + 120)
 #define __NR_setfsgid (__NR_Linux + 121)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsid (__NR_Linux + 122)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_capget (__NR_Linux + 123)
 #define __NR_capset (__NR_Linux + 124)
 #define __NR_rt_sigpending (__NR_Linux + 125)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigtimedwait (__NR_Linux + 126)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigqueueinfo (__NR_Linux + 127)
 #define __NR_rt_sigsuspend (__NR_Linux + 128)
 #define __NR_sigaltstack (__NR_Linux + 129)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_utime (__NR_Linux + 130)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mknod (__NR_Linux + 131)
 #define __NR_personality (__NR_Linux + 132)
 #define __NR_ustat (__NR_Linux + 133)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_statfs (__NR_Linux + 134)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fstatfs (__NR_Linux + 135)
 #define __NR_sysfs (__NR_Linux + 136)
 #define __NR_getpriority (__NR_Linux + 137)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setpriority (__NR_Linux + 138)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_setparam (__NR_Linux + 139)
 #define __NR_sched_getparam (__NR_Linux + 140)
 #define __NR_sched_setscheduler (__NR_Linux + 141)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getscheduler (__NR_Linux + 142)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_get_priority_max (__NR_Linux + 143)
 #define __NR_sched_get_priority_min (__NR_Linux + 144)
 #define __NR_sched_rr_get_interval (__NR_Linux + 145)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mlock (__NR_Linux + 146)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_munlock (__NR_Linux + 147)
 #define __NR_mlockall (__NR_Linux + 148)
 #define __NR_munlockall (__NR_Linux + 149)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vhangup (__NR_Linux + 150)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pivot_root (__NR_Linux + 151)
 #define __NR__sysctl (__NR_Linux + 152)
 #define __NR_prctl (__NR_Linux + 153)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_adjtimex (__NR_Linux + 154)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setrlimit (__NR_Linux + 155)
 #define __NR_chroot (__NR_Linux + 156)
 #define __NR_sync (__NR_Linux + 157)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_acct (__NR_Linux + 158)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_settimeofday (__NR_Linux + 159)
 #define __NR_mount (__NR_Linux + 160)
 #define __NR_umount2 (__NR_Linux + 161)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_swapon (__NR_Linux + 162)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_swapoff (__NR_Linux + 163)
 #define __NR_reboot (__NR_Linux + 164)
 #define __NR_sethostname (__NR_Linux + 165)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setdomainname (__NR_Linux + 166)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_create_module (__NR_Linux + 167)
 #define __NR_init_module (__NR_Linux + 168)
 #define __NR_delete_module (__NR_Linux + 169)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_get_kernel_syms (__NR_Linux + 170)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_query_module (__NR_Linux + 171)
 #define __NR_quotactl (__NR_Linux + 172)
 #define __NR_nfsservctl (__NR_Linux + 173)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpmsg (__NR_Linux + 174)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_putpmsg (__NR_Linux + 175)
 #define __NR_afs_syscall (__NR_Linux + 176)
 #define __NR_reserved177 (__NR_Linux + 177)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_gettid (__NR_Linux + 178)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readahead (__NR_Linux + 179)
 #define __NR_setxattr (__NR_Linux + 180)
 #define __NR_lsetxattr (__NR_Linux + 181)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fsetxattr (__NR_Linux + 182)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getxattr (__NR_Linux + 183)
 #define __NR_lgetxattr (__NR_Linux + 184)
 #define __NR_fgetxattr (__NR_Linux + 185)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_listxattr (__NR_Linux + 186)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_llistxattr (__NR_Linux + 187)
 #define __NR_flistxattr (__NR_Linux + 188)
 #define __NR_removexattr (__NR_Linux + 189)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lremovexattr (__NR_Linux + 190)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fremovexattr (__NR_Linux + 191)
 #define __NR_tkill (__NR_Linux + 192)
 #define __NR_reserved193 (__NR_Linux + 193)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_futex (__NR_Linux + 194)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_setaffinity (__NR_Linux + 195)
 #define __NR_sched_getaffinity (__NR_Linux + 196)
 #define __NR_cacheflush (__NR_Linux + 197)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_cachectl (__NR_Linux + 198)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sysmips (__NR_Linux + 199)
 #define __NR_io_setup (__NR_Linux + 200)
 #define __NR_io_destroy (__NR_Linux + 201)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_getevents (__NR_Linux + 202)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_submit (__NR_Linux + 203)
 #define __NR_io_cancel (__NR_Linux + 204)
 #define __NR_exit_group (__NR_Linux + 205)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lookup_dcookie (__NR_Linux + 206)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_create (__NR_Linux + 207)
 #define __NR_epoll_ctl (__NR_Linux + 208)
 #define __NR_epoll_wait (__NR_Linux + 209)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_remap_file_pages (__NR_Linux + 210)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigreturn (__NR_Linux + 211)
 #define __NR_set_tid_address (__NR_Linux + 212)
 #define __NR_restart_syscall (__NR_Linux + 213)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semtimedop (__NR_Linux + 214)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fadvise64 (__NR_Linux + 215)
 #define __NR_timer_create (__NR_Linux + 216)
 #define __NR_timer_settime (__NR_Linux + 217)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_gettime (__NR_Linux + 218)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_getoverrun (__NR_Linux + 219)
 #define __NR_timer_delete (__NR_Linux + 220)
 #define __NR_clock_settime (__NR_Linux + 221)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_gettime (__NR_Linux + 222)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_getres (__NR_Linux + 223)
 #define __NR_clock_nanosleep (__NR_Linux + 224)
 #define __NR_tgkill (__NR_Linux + 225)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_utimes (__NR_Linux + 226)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mbind (__NR_Linux + 227)
 #define __NR_get_mempolicy (__NR_Linux + 228)
 #define __NR_set_mempolicy (__NR_Linux + 229)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_open (__NR_Linux + 230)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_unlink (__NR_Linux + 231)
 #define __NR_mq_timedsend (__NR_Linux + 232)
 #define __NR_mq_timedreceive (__NR_Linux + 233)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_notify (__NR_Linux + 234)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_getsetattr (__NR_Linux + 235)
 #define __NR_vserver (__NR_Linux + 236)
 #define __NR_waitid (__NR_Linux + 237)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_add_key (__NR_Linux + 239)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_request_key (__NR_Linux + 240)
 #define __NR_keyctl (__NR_Linux + 241)
 #define __NR_set_thread_area (__NR_Linux + 242)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_init (__NR_Linux + 243)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_add_watch (__NR_Linux + 244)
 #define __NR_inotify_rm_watch (__NR_Linux + 245)
 #define __NR_migrate_pages (__NR_Linux + 246)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_openat (__NR_Linux + 247)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mkdirat (__NR_Linux + 248)
 #define __NR_mknodat (__NR_Linux + 249)
 #define __NR_fchownat (__NR_Linux + 250)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_futimesat (__NR_Linux + 251)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_newfstatat (__NR_Linux + 252)
 #define __NR_unlinkat (__NR_Linux + 253)
 #define __NR_renameat (__NR_Linux + 254)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_linkat (__NR_Linux + 255)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_symlinkat (__NR_Linux + 256)
 #define __NR_readlinkat (__NR_Linux + 257)
 #define __NR_fchmodat (__NR_Linux + 258)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_faccessat (__NR_Linux + 259)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pselect6 (__NR_Linux + 260)
 #define __NR_ppoll (__NR_Linux + 261)
 #define __NR_unshare (__NR_Linux + 262)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_splice (__NR_Linux + 263)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sync_file_range (__NR_Linux + 264)
 #define __NR_tee (__NR_Linux + 265)
 #define __NR_vmsplice (__NR_Linux + 266)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_move_pages (__NR_Linux + 267)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_set_robust_list (__NR_Linux + 268)
 #define __NR_get_robust_list (__NR_Linux + 269)
 #define __NR_kexec_load (__NR_Linux + 270)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getcpu (__NR_Linux + 271)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_pwait (__NR_Linux + 272)
 #define __NR_ioprio_set (__NR_Linux + 273)
 #define __NR_ioprio_get (__NR_Linux + 274)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_utimensat (__NR_Linux + 275)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_signalfd (__NR_Linux + 276)
 #define __NR_timerfd (__NR_Linux + 277)
 #define __NR_eventfd (__NR_Linux + 278)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fallocate (__NR_Linux + 279)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timerfd_create (__NR_Linux + 280)
 #define __NR_timerfd_gettime (__NR_Linux + 281)
 #define __NR_timerfd_settime (__NR_Linux + 282)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_signalfd4 (__NR_Linux + 283)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_eventfd2 (__NR_Linux + 284)
 #define __NR_epoll_create1 (__NR_Linux + 285)
 #define __NR_dup3 (__NR_Linux + 286)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pipe2 (__NR_Linux + 287)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_init1 (__NR_Linux + 288)
 #define __NR_preadv (__NR_Linux + 289)
 #define __NR_pwritev (__NR_Linux + 290)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_tgsigqueueinfo (__NR_Linux + 291)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_perf_event_open (__NR_Linux + 292)
 #define __NR_accept4 (__NR_Linux + 293)
 #define __NR_recvmmsg (__NR_Linux + 294)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fanotify_init (__NR_Linux + 295)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fanotify_mark (__NR_Linux + 296)
 #define __NR_prlimit64 (__NR_Linux + 297)
 #define __NR_name_to_handle_at (__NR_Linux + 298)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_open_by_handle_at (__NR_Linux + 299)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_adjtime (__NR_Linux + 300)
 #define __NR_syncfs (__NR_Linux + 301)
 #define __NR_sendmmsg (__NR_Linux + 302)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setns (__NR_Linux + 303)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_process_vm_readv (__NR_Linux + 304)
 #define __NR_process_vm_writev (__NR_Linux + 305)
 #define __NR_kcmp (__NR_Linux + 306)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_finit_module (__NR_Linux + 307)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getdents64 (__NR_Linux + 308)
 #define __NR_sched_setattr (__NR_Linux + 309)
 #define __NR_sched_getattr (__NR_Linux + 310)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_renameat2 (__NR_Linux + 311)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_seccomp (__NR_Linux + 312)
 #define __NR_getrandom (__NR_Linux + 313)
 #define __NR_memfd_create (__NR_Linux + 314)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_bpf (__NR_Linux + 315)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_execveat (__NR_Linux + 316)
 #define __NR_userfaultfd (__NR_Linux + 317)
 #define __NR_membarrier (__NR_Linux + 318)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mlock2 (__NR_Linux + 319)
-#define __NR_Linux_syscalls 319
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_copy_file_range (__NR_Linux + 320)
+#define __NR_preadv2 (__NR_Linux + 321)
+#define __NR_pwritev2 (__NR_Linux + 322)
+#define __NR_Linux_syscalls 322
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define __NR_64_Linux 5000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __NR_64_Linux_syscalls 319
+#define __NR_64_Linux_syscalls 322
 #if _MIPS_SIM == _MIPS_SIM_NABI32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_Linux 6000
 #define __NR_read (__NR_Linux + 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_write (__NR_Linux + 1)
 #define __NR_open (__NR_Linux + 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_close (__NR_Linux + 3)
 #define __NR_stat (__NR_Linux + 4)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fstat (__NR_Linux + 5)
 #define __NR_lstat (__NR_Linux + 6)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_poll (__NR_Linux + 7)
 #define __NR_lseek (__NR_Linux + 8)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mmap (__NR_Linux + 9)
 #define __NR_mprotect (__NR_Linux + 10)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_munmap (__NR_Linux + 11)
 #define __NR_brk (__NR_Linux + 12)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigaction (__NR_Linux + 13)
 #define __NR_rt_sigprocmask (__NR_Linux + 14)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ioctl (__NR_Linux + 15)
 #define __NR_pread64 (__NR_Linux + 16)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pwrite64 (__NR_Linux + 17)
 #define __NR_readv (__NR_Linux + 18)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_writev (__NR_Linux + 19)
 #define __NR_access (__NR_Linux + 20)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pipe (__NR_Linux + 21)
 #define __NR__newselect (__NR_Linux + 22)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_yield (__NR_Linux + 23)
 #define __NR_mremap (__NR_Linux + 24)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msync (__NR_Linux + 25)
 #define __NR_mincore (__NR_Linux + 26)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_madvise (__NR_Linux + 27)
 #define __NR_shmget (__NR_Linux + 28)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmat (__NR_Linux + 29)
 #define __NR_shmctl (__NR_Linux + 30)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_dup (__NR_Linux + 31)
 #define __NR_dup2 (__NR_Linux + 32)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pause (__NR_Linux + 33)
 #define __NR_nanosleep (__NR_Linux + 34)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getitimer (__NR_Linux + 35)
 #define __NR_setitimer (__NR_Linux + 36)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_alarm (__NR_Linux + 37)
 #define __NR_getpid (__NR_Linux + 38)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendfile (__NR_Linux + 39)
 #define __NR_socket (__NR_Linux + 40)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_connect (__NR_Linux + 41)
 #define __NR_accept (__NR_Linux + 42)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendto (__NR_Linux + 43)
 #define __NR_recvfrom (__NR_Linux + 44)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendmsg (__NR_Linux + 45)
 #define __NR_recvmsg (__NR_Linux + 46)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shutdown (__NR_Linux + 47)
 #define __NR_bind (__NR_Linux + 48)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_listen (__NR_Linux + 49)
 #define __NR_getsockname (__NR_Linux + 50)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpeername (__NR_Linux + 51)
 #define __NR_socketpair (__NR_Linux + 52)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setsockopt (__NR_Linux + 53)
 #define __NR_getsockopt (__NR_Linux + 54)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clone (__NR_Linux + 55)
 #define __NR_fork (__NR_Linux + 56)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_execve (__NR_Linux + 57)
 #define __NR_exit (__NR_Linux + 58)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_wait4 (__NR_Linux + 59)
 #define __NR_kill (__NR_Linux + 60)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_uname (__NR_Linux + 61)
 #define __NR_semget (__NR_Linux + 62)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semop (__NR_Linux + 63)
 #define __NR_semctl (__NR_Linux + 64)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmdt (__NR_Linux + 65)
 #define __NR_msgget (__NR_Linux + 66)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgsnd (__NR_Linux + 67)
 #define __NR_msgrcv (__NR_Linux + 68)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgctl (__NR_Linux + 69)
 #define __NR_fcntl (__NR_Linux + 70)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_flock (__NR_Linux + 71)
 #define __NR_fsync (__NR_Linux + 72)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fdatasync (__NR_Linux + 73)
 #define __NR_truncate (__NR_Linux + 74)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ftruncate (__NR_Linux + 75)
 #define __NR_getdents (__NR_Linux + 76)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getcwd (__NR_Linux + 77)
 #define __NR_chdir (__NR_Linux + 78)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchdir (__NR_Linux + 79)
 #define __NR_rename (__NR_Linux + 80)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mkdir (__NR_Linux + 81)
 #define __NR_rmdir (__NR_Linux + 82)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_creat (__NR_Linux + 83)
 #define __NR_link (__NR_Linux + 84)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_unlink (__NR_Linux + 85)
 #define __NR_symlink (__NR_Linux + 86)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readlink (__NR_Linux + 87)
 #define __NR_chmod (__NR_Linux + 88)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchmod (__NR_Linux + 89)
 #define __NR_chown (__NR_Linux + 90)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchown (__NR_Linux + 91)
 #define __NR_lchown (__NR_Linux + 92)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_umask (__NR_Linux + 93)
 #define __NR_gettimeofday (__NR_Linux + 94)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getrlimit (__NR_Linux + 95)
 #define __NR_getrusage (__NR_Linux + 96)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sysinfo (__NR_Linux + 97)
 #define __NR_times (__NR_Linux + 98)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ptrace (__NR_Linux + 99)
 #define __NR_getuid (__NR_Linux + 100)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_syslog (__NR_Linux + 101)
 #define __NR_getgid (__NR_Linux + 102)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setuid (__NR_Linux + 103)
 #define __NR_setgid (__NR_Linux + 104)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_geteuid (__NR_Linux + 105)
 #define __NR_getegid (__NR_Linux + 106)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setpgid (__NR_Linux + 107)
 #define __NR_getppid (__NR_Linux + 108)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpgrp (__NR_Linux + 109)
 #define __NR_setsid (__NR_Linux + 110)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setreuid (__NR_Linux + 111)
 #define __NR_setregid (__NR_Linux + 112)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getgroups (__NR_Linux + 113)
 #define __NR_setgroups (__NR_Linux + 114)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setresuid (__NR_Linux + 115)
 #define __NR_getresuid (__NR_Linux + 116)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setresgid (__NR_Linux + 117)
 #define __NR_getresgid (__NR_Linux + 118)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpgid (__NR_Linux + 119)
 #define __NR_setfsuid (__NR_Linux + 120)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setfsgid (__NR_Linux + 121)
 #define __NR_getsid (__NR_Linux + 122)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_capget (__NR_Linux + 123)
 #define __NR_capset (__NR_Linux + 124)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigpending (__NR_Linux + 125)
 #define __NR_rt_sigtimedwait (__NR_Linux + 126)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigqueueinfo (__NR_Linux + 127)
 #define __NR_rt_sigsuspend (__NR_Linux + 128)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sigaltstack (__NR_Linux + 129)
 #define __NR_utime (__NR_Linux + 130)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mknod (__NR_Linux + 131)
 #define __NR_personality (__NR_Linux + 132)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ustat (__NR_Linux + 133)
 #define __NR_statfs (__NR_Linux + 134)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fstatfs (__NR_Linux + 135)
 #define __NR_sysfs (__NR_Linux + 136)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpriority (__NR_Linux + 137)
 #define __NR_setpriority (__NR_Linux + 138)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_setparam (__NR_Linux + 139)
 #define __NR_sched_getparam (__NR_Linux + 140)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_setscheduler (__NR_Linux + 141)
 #define __NR_sched_getscheduler (__NR_Linux + 142)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_get_priority_max (__NR_Linux + 143)
 #define __NR_sched_get_priority_min (__NR_Linux + 144)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_rr_get_interval (__NR_Linux + 145)
 #define __NR_mlock (__NR_Linux + 146)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_munlock (__NR_Linux + 147)
 #define __NR_mlockall (__NR_Linux + 148)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_munlockall (__NR_Linux + 149)
 #define __NR_vhangup (__NR_Linux + 150)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pivot_root (__NR_Linux + 151)
 #define __NR__sysctl (__NR_Linux + 152)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_prctl (__NR_Linux + 153)
 #define __NR_adjtimex (__NR_Linux + 154)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setrlimit (__NR_Linux + 155)
 #define __NR_chroot (__NR_Linux + 156)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sync (__NR_Linux + 157)
 #define __NR_acct (__NR_Linux + 158)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_settimeofday (__NR_Linux + 159)
 #define __NR_mount (__NR_Linux + 160)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_umount2 (__NR_Linux + 161)
 #define __NR_swapon (__NR_Linux + 162)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_swapoff (__NR_Linux + 163)
 #define __NR_reboot (__NR_Linux + 164)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sethostname (__NR_Linux + 165)
 #define __NR_setdomainname (__NR_Linux + 166)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_create_module (__NR_Linux + 167)
 #define __NR_init_module (__NR_Linux + 168)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_delete_module (__NR_Linux + 169)
 #define __NR_get_kernel_syms (__NR_Linux + 170)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_query_module (__NR_Linux + 171)
 #define __NR_quotactl (__NR_Linux + 172)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_nfsservctl (__NR_Linux + 173)
 #define __NR_getpmsg (__NR_Linux + 174)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_putpmsg (__NR_Linux + 175)
 #define __NR_afs_syscall (__NR_Linux + 176)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_reserved177 (__NR_Linux + 177)
 #define __NR_gettid (__NR_Linux + 178)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readahead (__NR_Linux + 179)
 #define __NR_setxattr (__NR_Linux + 180)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lsetxattr (__NR_Linux + 181)
 #define __NR_fsetxattr (__NR_Linux + 182)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getxattr (__NR_Linux + 183)
 #define __NR_lgetxattr (__NR_Linux + 184)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fgetxattr (__NR_Linux + 185)
 #define __NR_listxattr (__NR_Linux + 186)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_llistxattr (__NR_Linux + 187)
 #define __NR_flistxattr (__NR_Linux + 188)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_removexattr (__NR_Linux + 189)
 #define __NR_lremovexattr (__NR_Linux + 190)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fremovexattr (__NR_Linux + 191)
 #define __NR_tkill (__NR_Linux + 192)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_reserved193 (__NR_Linux + 193)
 #define __NR_futex (__NR_Linux + 194)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_setaffinity (__NR_Linux + 195)
 #define __NR_sched_getaffinity (__NR_Linux + 196)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_cacheflush (__NR_Linux + 197)
 #define __NR_cachectl (__NR_Linux + 198)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sysmips (__NR_Linux + 199)
 #define __NR_io_setup (__NR_Linux + 200)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_destroy (__NR_Linux + 201)
 #define __NR_io_getevents (__NR_Linux + 202)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_submit (__NR_Linux + 203)
 #define __NR_io_cancel (__NR_Linux + 204)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_exit_group (__NR_Linux + 205)
 #define __NR_lookup_dcookie (__NR_Linux + 206)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_create (__NR_Linux + 207)
 #define __NR_epoll_ctl (__NR_Linux + 208)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_wait (__NR_Linux + 209)
 #define __NR_remap_file_pages (__NR_Linux + 210)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigreturn (__NR_Linux + 211)
 #define __NR_fcntl64 (__NR_Linux + 212)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_set_tid_address (__NR_Linux + 213)
 #define __NR_restart_syscall (__NR_Linux + 214)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semtimedop (__NR_Linux + 215)
 #define __NR_fadvise64 (__NR_Linux + 216)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_statfs64 (__NR_Linux + 217)
 #define __NR_fstatfs64 (__NR_Linux + 218)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendfile64 (__NR_Linux + 219)
 #define __NR_timer_create (__NR_Linux + 220)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_settime (__NR_Linux + 221)
 #define __NR_timer_gettime (__NR_Linux + 222)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_getoverrun (__NR_Linux + 223)
 #define __NR_timer_delete (__NR_Linux + 224)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_settime (__NR_Linux + 225)
 #define __NR_clock_gettime (__NR_Linux + 226)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_getres (__NR_Linux + 227)
 #define __NR_clock_nanosleep (__NR_Linux + 228)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_tgkill (__NR_Linux + 229)
 #define __NR_utimes (__NR_Linux + 230)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mbind (__NR_Linux + 231)
 #define __NR_get_mempolicy (__NR_Linux + 232)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_set_mempolicy (__NR_Linux + 233)
 #define __NR_mq_open (__NR_Linux + 234)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_unlink (__NR_Linux + 235)
 #define __NR_mq_timedsend (__NR_Linux + 236)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_timedreceive (__NR_Linux + 237)
 #define __NR_mq_notify (__NR_Linux + 238)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_getsetattr (__NR_Linux + 239)
 #define __NR_vserver (__NR_Linux + 240)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_waitid (__NR_Linux + 241)
 #define __NR_add_key (__NR_Linux + 243)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_request_key (__NR_Linux + 244)
 #define __NR_keyctl (__NR_Linux + 245)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_set_thread_area (__NR_Linux + 246)
 #define __NR_inotify_init (__NR_Linux + 247)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_add_watch (__NR_Linux + 248)
 #define __NR_inotify_rm_watch (__NR_Linux + 249)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_migrate_pages (__NR_Linux + 250)
 #define __NR_openat (__NR_Linux + 251)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mkdirat (__NR_Linux + 252)
 #define __NR_mknodat (__NR_Linux + 253)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchownat (__NR_Linux + 254)
 #define __NR_futimesat (__NR_Linux + 255)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_newfstatat (__NR_Linux + 256)
 #define __NR_unlinkat (__NR_Linux + 257)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_renameat (__NR_Linux + 258)
 #define __NR_linkat (__NR_Linux + 259)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_symlinkat (__NR_Linux + 260)
 #define __NR_readlinkat (__NR_Linux + 261)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fchmodat (__NR_Linux + 262)
 #define __NR_faccessat (__NR_Linux + 263)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pselect6 (__NR_Linux + 264)
 #define __NR_ppoll (__NR_Linux + 265)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_unshare (__NR_Linux + 266)
 #define __NR_splice (__NR_Linux + 267)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sync_file_range (__NR_Linux + 268)
 #define __NR_tee (__NR_Linux + 269)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vmsplice (__NR_Linux + 270)
 #define __NR_move_pages (__NR_Linux + 271)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_set_robust_list (__NR_Linux + 272)
 #define __NR_get_robust_list (__NR_Linux + 273)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_kexec_load (__NR_Linux + 274)
 #define __NR_getcpu (__NR_Linux + 275)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_pwait (__NR_Linux + 276)
 #define __NR_ioprio_set (__NR_Linux + 277)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ioprio_get (__NR_Linux + 278)
 #define __NR_utimensat (__NR_Linux + 279)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_signalfd (__NR_Linux + 280)
 #define __NR_timerfd (__NR_Linux + 281)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_eventfd (__NR_Linux + 282)
 #define __NR_fallocate (__NR_Linux + 283)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timerfd_create (__NR_Linux + 284)
 #define __NR_timerfd_gettime (__NR_Linux + 285)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timerfd_settime (__NR_Linux + 286)
 #define __NR_signalfd4 (__NR_Linux + 287)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_eventfd2 (__NR_Linux + 288)
 #define __NR_epoll_create1 (__NR_Linux + 289)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_dup3 (__NR_Linux + 290)
 #define __NR_pipe2 (__NR_Linux + 291)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_init1 (__NR_Linux + 292)
 #define __NR_preadv (__NR_Linux + 293)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pwritev (__NR_Linux + 294)
 #define __NR_rt_tgsigqueueinfo (__NR_Linux + 295)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_perf_event_open (__NR_Linux + 296)
 #define __NR_accept4 (__NR_Linux + 297)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_recvmmsg (__NR_Linux + 298)
 #define __NR_getdents64 (__NR_Linux + 299)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fanotify_init (__NR_Linux + 300)
 #define __NR_fanotify_mark (__NR_Linux + 301)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_prlimit64 (__NR_Linux + 302)
 #define __NR_name_to_handle_at (__NR_Linux + 303)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_open_by_handle_at (__NR_Linux + 304)
 #define __NR_clock_adjtime (__NR_Linux + 305)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_syncfs (__NR_Linux + 306)
 #define __NR_sendmmsg (__NR_Linux + 307)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setns (__NR_Linux + 308)
 #define __NR_process_vm_readv (__NR_Linux + 309)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_process_vm_writev (__NR_Linux + 310)
 #define __NR_kcmp (__NR_Linux + 311)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_finit_module (__NR_Linux + 312)
 #define __NR_sched_setattr (__NR_Linux + 313)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getattr (__NR_Linux + 314)
 #define __NR_renameat2 (__NR_Linux + 315)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_seccomp (__NR_Linux + 316)
 #define __NR_getrandom (__NR_Linux + 317)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_memfd_create (__NR_Linux + 318)
 #define __NR_bpf (__NR_Linux + 319)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_execveat (__NR_Linux + 320)
 #define __NR_userfaultfd (__NR_Linux + 321)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_membarrier (__NR_Linux + 322)
 #define __NR_mlock2 (__NR_Linux + 323)
-#define __NR_Linux_syscalls 323
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_copy_file_range (__NR_Linux + 324)
+#define __NR_preadv2 (__NR_Linux + 325)
+#define __NR_pwritev2 (__NR_Linux + 326)
+#define __NR_Linux_syscalls 326
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define __NR_N32_Linux 6000
+#define __NR_N32_Linux_syscalls 326
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __NR_N32_Linux 6000
-#define __NR_N32_Linux_syscalls 323
-#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/bootparam.h b/libc/kernel/uapi/asm-x86/asm/bootparam.h
index 1394829..a055bf6 100644
--- a/libc/kernel/uapi/asm-x86/asm/bootparam.h
+++ b/libc/kernel/uapi/asm-x86/asm/bootparam.h
@@ -176,7 +176,7 @@
   __u8 _pad9[276];
 } __attribute__((packed));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum {
+enum x86_hardware_subarch {
   X86_SUBARCH_PC = 0,
   X86_SUBARCH_LGUEST,
   X86_SUBARCH_XEN,
diff --git a/libc/kernel/uapi/asm-x86/asm/hyperv.h b/libc/kernel/uapi/asm-x86/asm/hyperv.h
index 312726f..6520d95 100644
--- a/libc/kernel/uapi/asm-x86/asm/hyperv.h
+++ b/libc/kernel/uapi/asm-x86/asm/hyperv.h
@@ -143,43 +143,126 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT 12
 #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK (~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
-#define HV_X64_HV_NOTIFY_LONG_SPIN_WAIT 0x0008
-#define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE 0x00000001
+#define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008
+#define HVCALL_POST_MESSAGE 0x005c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HVCALL_SIGNAL_EVENT 0x005d
+#define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE 0x00000001
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT 12
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_MASK (~((1ull << HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001
 #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_PROCESSOR_POWER_STATE_C0 0
 #define HV_PROCESSOR_POWER_STATE_C1 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_PROCESSOR_POWER_STATE_C2 2
 #define HV_PROCESSOR_POWER_STATE_C3 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_STATUS_SUCCESS 0
 #define HV_STATUS_INVALID_HYPERCALL_CODE 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_STATUS_INVALID_HYPERCALL_INPUT 3
 #define HV_STATUS_INVALID_ALIGNMENT 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_STATUS_INSUFFICIENT_MEMORY 11
 #define HV_STATUS_INVALID_CONNECTION_ID 18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_STATUS_INSUFFICIENT_BUFFERS 19
 typedef struct _HV_REFERENCE_TSC_PAGE {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tsc_sequence;
   __u32 res1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 tsc_scale;
   __s64 tsc_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } HV_REFERENCE_TSC_PAGE, * PHV_REFERENCE_TSC_PAGE;
 #define HV_SYNIC_SINT_COUNT (16)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_SYNIC_VERSION_1 (0x1)
 #define HV_SYNIC_CONTROL_ENABLE (1ULL << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_SYNIC_SIMP_ENABLE (1ULL << 0)
 #define HV_SYNIC_SIEFP_ENABLE (1ULL << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_SYNIC_SINT_MASKED (1ULL << 16)
 #define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HV_SYNIC_SINT_VECTOR_MASK (0xFF)
+#define HV_SYNIC_STIMER_COUNT (4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HV_MESSAGE_SIZE (256)
+#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240)
+#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
+enum hv_message_type {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HVMSG_NONE = 0x00000000,
+  HVMSG_UNMAPPED_GPA = 0x80000000,
+  HVMSG_GPA_INTERCEPT = 0x80000001,
+  HVMSG_TIMER_EXPIRED = 0x80000010,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020,
+  HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021,
+  HVMSG_UNSUPPORTED_FEATURE = 0x80000022,
+  HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HVMSG_X64_IOPORT_INTERCEPT = 0x80010000,
+  HVMSG_X64_MSR_INTERCEPT = 0x80010001,
+  HVMSG_X64_CPUID_INTERCEPT = 0x80010002,
+  HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HVMSG_X64_APIC_EOI = 0x80010004,
+  HVMSG_X64_LEGACY_FP_ERROR = 0x80010005
+};
+union hv_message_flags {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 asu8;
+  struct {
+    __u8 msg_pending : 1;
+    __u8 reserved : 7;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
+};
+union hv_port_id {
+  __u32 asu32;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct {
+    __u32 id : 24;
+    __u32 reserved : 8;
+  } u;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct hv_message_header {
+  __u32 message_type;
+  __u8 payload_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union hv_message_flags message_flags;
+  __u8 reserved[2];
+  union {
+    __u64 sender;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    union hv_port_id port;
+  };
+};
+struct hv_message {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct hv_message_header header;
+  union {
+    __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
+  } u;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct hv_message_page {
+  struct hv_message sint_message[HV_SYNIC_SINT_COUNT];
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct hv_timer_message_payload {
+  __u32 timer_index;
+  __u32 reserved;
+  __u64 expiration_time;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 delivery_time;
+};
+#define HV_STIMER_ENABLE (1ULL << 0)
+#define HV_STIMER_PERIODIC (1ULL << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HV_STIMER_LAZY (1ULL << 2)
+#define HV_STIMER_AUTOENABLE (1ULL << 3)
+#define HV_STIMER_SINT(config) (__u8) (((config) >> 16) & 0x0F)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-x86/asm/kvm.h b/libc/kernel/uapi/asm-x86/asm/kvm.h
index 45c8d12..d944c5e 100644
--- a/libc/kernel/uapi/asm-x86/asm/kvm.h
+++ b/libc/kernel/uapi/asm-x86/asm/kvm.h
@@ -236,9 +236,9 @@
   __u32 padding[3];
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
-#define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1)
-#define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2)
+#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX (1 << 0)
+#define KVM_CPUID_FLAG_STATEFUL_FUNC (1 << 1)
+#define KVM_CPUID_FLAG_STATE_READ_NEXT (1 << 2)
 struct kvm_cpuid2 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 nent;
diff --git a/libc/kernel/uapi/asm-x86/asm/mce.h b/libc/kernel/uapi/asm-x86/asm/mce.h
index ca24c44..5132daa 100644
--- a/libc/kernel/uapi/asm-x86/asm/mce.h
+++ b/libc/kernel/uapi/asm-x86/asm/mce.h
@@ -34,7 +34,7 @@
   __u8 cpuvendor;
   __u8 inject_flags;
   __u8 severity;
-  __u8 usable_addr;
+  __u8 pad;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cpuid;
   __u8 cs;
diff --git a/libc/kernel/uapi/asm-x86/asm/msr-index.h b/libc/kernel/uapi/asm-x86/asm/msr-index.h
deleted file mode 100644
index 221cec2..0000000
--- a/libc/kernel/uapi/asm-x86/asm/msr-index.h
+++ /dev/null
@@ -1,601 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _ASM_X86_MSR_INDEX_H
-#define _ASM_X86_MSR_INDEX_H
-#define MSR_EFER 0xc0000080
-#define MSR_STAR 0xc0000081
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_LSTAR 0xc0000082
-#define MSR_CSTAR 0xc0000083
-#define MSR_SYSCALL_MASK 0xc0000084
-#define MSR_FS_BASE 0xc0000100
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_GS_BASE 0xc0000101
-#define MSR_KERNEL_GS_BASE 0xc0000102
-#define MSR_TSC_AUX 0xc0000103
-#define _EFER_SCE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _EFER_LME 8
-#define _EFER_LMA 10
-#define _EFER_NX 11
-#define _EFER_SVME 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define _EFER_LMSLE 13
-#define _EFER_FFXSR 14
-#define EFER_SCE (1 << _EFER_SCE)
-#define EFER_LME (1 << _EFER_LME)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EFER_LMA (1 << _EFER_LMA)
-#define EFER_NX (1 << _EFER_NX)
-#define EFER_SVME (1 << _EFER_SVME)
-#define EFER_LMSLE (1 << _EFER_LMSLE)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EFER_FFXSR (1 << _EFER_FFXSR)
-#define MSR_IA32_PERFCTR0 0x000000c1
-#define MSR_IA32_PERFCTR1 0x000000c2
-#define MSR_FSB_FREQ 0x000000cd
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_NHM_PLATFORM_INFO 0x000000ce
-#define MSR_NHM_SNB_PKG_CST_CFG_CTL 0x000000e2
-#define NHM_C3_AUTO_DEMOTE (1UL << 25)
-#define NHM_C1_AUTO_DEMOTE (1UL << 26)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ATM_LNC_C6_AUTO_DEMOTE (1UL << 25)
-#define SNB_C1_AUTO_UNDEMOTE (1UL << 27)
-#define SNB_C3_AUTO_UNDEMOTE (1UL << 28)
-#define MSR_PLATFORM_INFO 0x000000ce
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_MTRRcap 0x000000fe
-#define MSR_IA32_BBL_CR_CTL 0x00000119
-#define MSR_IA32_BBL_CR_CTL3 0x0000011e
-#define MSR_IA32_SYSENTER_CS 0x00000174
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_SYSENTER_ESP 0x00000175
-#define MSR_IA32_SYSENTER_EIP 0x00000176
-#define MSR_IA32_MCG_CAP 0x00000179
-#define MSR_IA32_MCG_STATUS 0x0000017a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MCG_CTL 0x0000017b
-#define MSR_OFFCORE_RSP_0 0x000001a6
-#define MSR_OFFCORE_RSP_1 0x000001a7
-#define MSR_NHM_TURBO_RATIO_LIMIT 0x000001ad
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IVT_TURBO_RATIO_LIMIT 0x000001ae
-#define MSR_LBR_SELECT 0x000001c8
-#define MSR_LBR_TOS 0x000001c9
-#define MSR_LBR_NHM_FROM 0x00000680
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_LBR_NHM_TO 0x000006c0
-#define MSR_LBR_CORE_FROM 0x00000040
-#define MSR_LBR_CORE_TO 0x00000060
-#define MSR_IA32_PEBS_ENABLE 0x000003f1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_DS_AREA 0x00000600
-#define MSR_IA32_PERF_CAPABILITIES 0x00000345
-#define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6
-#define MSR_MTRRfix64K_00000 0x00000250
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_MTRRfix16K_80000 0x00000258
-#define MSR_MTRRfix16K_A0000 0x00000259
-#define MSR_MTRRfix4K_C0000 0x00000268
-#define MSR_MTRRfix4K_C8000 0x00000269
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_MTRRfix4K_D0000 0x0000026a
-#define MSR_MTRRfix4K_D8000 0x0000026b
-#define MSR_MTRRfix4K_E0000 0x0000026c
-#define MSR_MTRRfix4K_E8000 0x0000026d
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_MTRRfix4K_F0000 0x0000026e
-#define MSR_MTRRfix4K_F8000 0x0000026f
-#define MSR_MTRRdefType 0x000002ff
-#define MSR_IA32_CR_PAT 0x00000277
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_DEBUGCTLMSR 0x000001d9
-#define MSR_IA32_LASTBRANCHFROMIP 0x000001db
-#define MSR_IA32_LASTBRANCHTOIP 0x000001dc
-#define MSR_IA32_LASTINTFROMIP 0x000001dd
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_LASTINTTOIP 0x000001de
-#define DEBUGCTLMSR_LBR (1UL << 0)
-#define DEBUGCTLMSR_BTF (1UL << 1)
-#define DEBUGCTLMSR_TR (1UL << 6)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DEBUGCTLMSR_BTS (1UL << 7)
-#define DEBUGCTLMSR_BTINT (1UL << 8)
-#define DEBUGCTLMSR_BTS_OFF_OS (1UL << 9)
-#define DEBUGCTLMSR_BTS_OFF_USR (1UL << 10)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DEBUGCTLMSR_FREEZE_LBRS_ON_PMI (1UL << 11)
-#define MSR_IA32_POWER_CTL 0x000001fc
-#define MSR_IA32_MC0_CTL 0x00000400
-#define MSR_IA32_MC0_STATUS 0x00000401
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MC0_ADDR 0x00000402
-#define MSR_IA32_MC0_MISC 0x00000403
-#define MSR_PKG_C3_RESIDENCY 0x000003f8
-#define MSR_PKG_C6_RESIDENCY 0x000003f9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_PKG_C7_RESIDENCY 0x000003fa
-#define MSR_CORE_C3_RESIDENCY 0x000003fc
-#define MSR_CORE_C6_RESIDENCY 0x000003fd
-#define MSR_CORE_C7_RESIDENCY 0x000003fe
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_PKG_C2_RESIDENCY 0x0000060d
-#define MSR_PKG_C8_RESIDENCY 0x00000630
-#define MSR_PKG_C9_RESIDENCY 0x00000631
-#define MSR_PKG_C10_RESIDENCY 0x00000632
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_RAPL_POWER_UNIT 0x00000606
-#define MSR_PKG_POWER_LIMIT 0x00000610
-#define MSR_PKG_ENERGY_STATUS 0x00000611
-#define MSR_PKG_PERF_STATUS 0x00000613
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_PKG_POWER_INFO 0x00000614
-#define MSR_DRAM_POWER_LIMIT 0x00000618
-#define MSR_DRAM_ENERGY_STATUS 0x00000619
-#define MSR_DRAM_PERF_STATUS 0x0000061b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_DRAM_POWER_INFO 0x0000061c
-#define MSR_PP0_POWER_LIMIT 0x00000638
-#define MSR_PP0_ENERGY_STATUS 0x00000639
-#define MSR_PP0_POLICY 0x0000063a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_PP0_PERF_STATUS 0x0000063b
-#define MSR_PP1_POWER_LIMIT 0x00000640
-#define MSR_PP1_ENERGY_STATUS 0x00000641
-#define MSR_PP1_POLICY 0x00000642
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_CORE_C1_RES 0x00000660
-#define MSR_CC6_DEMOTION_POLICY_CONFIG 0x00000668
-#define MSR_MC6_DEMOTION_POLICY_CONFIG 0x00000669
-#define MSR_AMD64_MC0_MASK 0xc0010044
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MCx_CTL(x) (MSR_IA32_MC0_CTL + 4 * (x))
-#define MSR_IA32_MCx_STATUS(x) (MSR_IA32_MC0_STATUS + 4 * (x))
-#define MSR_IA32_MCx_ADDR(x) (MSR_IA32_MC0_ADDR + 4 * (x))
-#define MSR_IA32_MCx_MISC(x) (MSR_IA32_MC0_MISC + 4 * (x))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_MCx_MASK(x) (MSR_AMD64_MC0_MASK + (x))
-#define MSR_IA32_MC0_CTL2 0x00000280
-#define MSR_IA32_MCx_CTL2(x) (MSR_IA32_MC0_CTL2 + (x))
-#define MSR_P6_PERFCTR0 0x000000c1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P6_PERFCTR1 0x000000c2
-#define MSR_P6_EVNTSEL0 0x00000186
-#define MSR_P6_EVNTSEL1 0x00000187
-#define MSR_KNC_PERFCTR0 0x00000020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_KNC_PERFCTR1 0x00000021
-#define MSR_KNC_EVNTSEL0 0x00000028
-#define MSR_KNC_EVNTSEL1 0x00000029
-#define MSR_IA32_PMC0 0x000004c1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_PATCH_LEVEL 0x0000008b
-#define MSR_AMD64_TSC_RATIO 0xc0000104
-#define MSR_AMD64_NB_CFG 0xc001001f
-#define MSR_AMD64_PATCH_LOADER 0xc0010020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_OSVW_ID_LENGTH 0xc0010140
-#define MSR_AMD64_OSVW_STATUS 0xc0010141
-#define MSR_AMD64_LS_CFG 0xc0011020
-#define MSR_AMD64_DC_CFG 0xc0011022
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_BU_CFG2 0xc001102a
-#define MSR_AMD64_IBSFETCHCTL 0xc0011030
-#define MSR_AMD64_IBSFETCHLINAD 0xc0011031
-#define MSR_AMD64_IBSFETCHPHYSAD 0xc0011032
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_IBSFETCH_REG_COUNT 3
-#define MSR_AMD64_IBSFETCH_REG_MASK ((1UL << MSR_AMD64_IBSFETCH_REG_COUNT) - 1)
-#define MSR_AMD64_IBSOPCTL 0xc0011033
-#define MSR_AMD64_IBSOPRIP 0xc0011034
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_IBSOPDATA 0xc0011035
-#define MSR_AMD64_IBSOPDATA2 0xc0011036
-#define MSR_AMD64_IBSOPDATA3 0xc0011037
-#define MSR_AMD64_IBSDCLINAD 0xc0011038
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_IBSDCPHYSAD 0xc0011039
-#define MSR_AMD64_IBSOP_REG_COUNT 7
-#define MSR_AMD64_IBSOP_REG_MASK ((1UL << MSR_AMD64_IBSOP_REG_COUNT) - 1)
-#define MSR_AMD64_IBSCTL 0xc001103a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_AMD64_IBSBRTARGET 0xc001103b
-#define MSR_AMD64_IBS_REG_COUNT_MAX 8
-#define MSR_F16H_L2I_PERF_CTL 0xc0010230
-#define MSR_F16H_L2I_PERF_CTR 0xc0010231
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_F15H_PERF_CTL 0xc0010200
-#define MSR_F15H_PERF_CTR 0xc0010201
-#define MSR_F15H_NB_PERF_CTL 0xc0010240
-#define MSR_F15H_NB_PERF_CTR 0xc0010241
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_FAM10H_MMIO_CONF_BASE 0xc0010058
-#define FAM10H_MMIO_CONF_ENABLE (1 << 0)
-#define FAM10H_MMIO_CONF_BUSRANGE_MASK 0xf
-#define FAM10H_MMIO_CONF_BUSRANGE_SHIFT 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffffULL
-#define FAM10H_MMIO_CONF_BASE_SHIFT 20
-#define MSR_FAM10H_NODE_ID 0xc001100c
-#define MSR_K8_TOP_MEM1 0xc001001a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_K8_TOP_MEM2 0xc001001d
-#define MSR_K8_SYSCFG 0xc0010010
-#define MSR_K8_INT_PENDING_MSG 0xc0010055
-#define K8_INTP_C1E_ACTIVE_MASK 0x18000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_K8_TSEG_ADDR 0xc0010112
-#define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000
-#define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000
-#define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_K7_EVNTSEL0 0xc0010000
-#define MSR_K7_PERFCTR0 0xc0010004
-#define MSR_K7_EVNTSEL1 0xc0010001
-#define MSR_K7_PERFCTR1 0xc0010005
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_K7_EVNTSEL2 0xc0010002
-#define MSR_K7_PERFCTR2 0xc0010006
-#define MSR_K7_EVNTSEL3 0xc0010003
-#define MSR_K7_PERFCTR3 0xc0010007
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_K7_CLK_CTL 0xc001001b
-#define MSR_K7_HWCR 0xc0010015
-#define MSR_K7_FID_VID_CTL 0xc0010041
-#define MSR_K7_FID_VID_STATUS 0xc0010042
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_K6_WHCR 0xc0000082
-#define MSR_K6_UWCCR 0xc0000085
-#define MSR_K6_EPMR 0xc0000086
-#define MSR_K6_PSOR 0xc0000087
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_K6_PFIR 0xc0000088
-#define MSR_IDT_FCR1 0x00000107
-#define MSR_IDT_FCR2 0x00000108
-#define MSR_IDT_FCR3 0x00000109
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IDT_FCR4 0x0000010a
-#define MSR_IDT_MCR0 0x00000110
-#define MSR_IDT_MCR1 0x00000111
-#define MSR_IDT_MCR2 0x00000112
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IDT_MCR3 0x00000113
-#define MSR_IDT_MCR4 0x00000114
-#define MSR_IDT_MCR5 0x00000115
-#define MSR_IDT_MCR6 0x00000116
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IDT_MCR7 0x00000117
-#define MSR_IDT_MCR_CTRL 0x00000120
-#define MSR_VIA_FCR 0x00001107
-#define MSR_VIA_LONGHAUL 0x0000110a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_VIA_RNG 0x0000110b
-#define MSR_VIA_BCR2 0x00001147
-#define MSR_TMTA_LONGRUN_CTRL 0x80868010
-#define MSR_TMTA_LONGRUN_FLAGS 0x80868011
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_TMTA_LRTI_READOUT 0x80868018
-#define MSR_TMTA_LRTI_VOLT_MHZ 0x8086801a
-#define MSR_IA32_P5_MC_ADDR 0x00000000
-#define MSR_IA32_P5_MC_TYPE 0x00000001
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_TSC 0x00000010
-#define MSR_IA32_PLATFORM_ID 0x00000017
-#define MSR_IA32_EBL_CR_POWERON 0x0000002a
-#define MSR_EBC_FREQUENCY_ID 0x0000002c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_SMI_COUNT 0x00000034
-#define MSR_IA32_FEATURE_CONTROL 0x0000003a
-#define MSR_IA32_TSC_ADJUST 0x0000003b
-#define MSR_IA32_BNDCFGS 0x00000d90
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_XSS 0x00000da0
-#define FEATURE_CONTROL_LOCKED (1 << 0)
-#define FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX (1 << 1)
-#define FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_APICBASE 0x0000001b
-#define MSR_IA32_APICBASE_BSP (1 << 8)
-#define MSR_IA32_APICBASE_ENABLE (1 << 11)
-#define MSR_IA32_APICBASE_BASE (0xfffff << 12)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_TSCDEADLINE 0x000006e0
-#define MSR_IA32_UCODE_WRITE 0x00000079
-#define MSR_IA32_UCODE_REV 0x0000008b
-#define MSR_IA32_PERF_STATUS 0x00000198
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_PERF_CTL 0x00000199
-#define MSR_AMD_PSTATE_DEF_BASE 0xc0010064
-#define MSR_AMD_PERF_STATUS 0xc0010063
-#define MSR_AMD_PERF_CTL 0xc0010062
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MPERF 0x000000e7
-#define MSR_IA32_APERF 0x000000e8
-#define MSR_IA32_THERM_CONTROL 0x0000019a
-#define MSR_IA32_THERM_INTERRUPT 0x0000019b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define THERM_INT_HIGH_ENABLE (1 << 0)
-#define THERM_INT_LOW_ENABLE (1 << 1)
-#define THERM_INT_PLN_ENABLE (1 << 24)
-#define MSR_IA32_THERM_STATUS 0x0000019c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define THERM_STATUS_PROCHOT (1 << 0)
-#define THERM_STATUS_POWER_LIMIT (1 << 10)
-#define MSR_THERM2_CTL 0x0000019d
-#define MSR_THERM2_CTL_TM_SELECT (1ULL << 16)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE 0x000001a0
-#define MSR_IA32_TEMPERATURE_TARGET 0x000001a2
-#define MSR_IA32_ENERGY_PERF_BIAS 0x000001b0
-#define ENERGY_PERF_BIAS_PERFORMANCE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ENERGY_PERF_BIAS_NORMAL 6
-#define ENERGY_PERF_BIAS_POWERSAVE 15
-#define MSR_IA32_PACKAGE_THERM_STATUS 0x000001b1
-#define PACKAGE_THERM_STATUS_PROCHOT (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PACKAGE_THERM_STATUS_POWER_LIMIT (1 << 10)
-#define MSR_IA32_PACKAGE_THERM_INTERRUPT 0x000001b2
-#define PACKAGE_THERM_INT_HIGH_ENABLE (1 << 0)
-#define PACKAGE_THERM_INT_LOW_ENABLE (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PACKAGE_THERM_INT_PLN_ENABLE (1 << 24)
-#define THERM_INT_THRESHOLD0_ENABLE (1 << 15)
-#define THERM_SHIFT_THRESHOLD0 8
-#define THERM_MASK_THRESHOLD0 (0x7f << THERM_SHIFT_THRESHOLD0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define THERM_INT_THRESHOLD1_ENABLE (1 << 23)
-#define THERM_SHIFT_THRESHOLD1 16
-#define THERM_MASK_THRESHOLD1 (0x7f << THERM_SHIFT_THRESHOLD1)
-#define THERM_STATUS_THRESHOLD0 (1 << 6)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define THERM_LOG_THRESHOLD0 (1 << 7)
-#define THERM_STATUS_THRESHOLD1 (1 << 8)
-#define THERM_LOG_THRESHOLD1 (1 << 9)
-#define MSR_IA32_MISC_ENABLE_FAST_STRING_BIT 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_FAST_STRING (1ULL << MSR_IA32_MISC_ENABLE_FAST_STRING_BIT)
-#define MSR_IA32_MISC_ENABLE_TCC_BIT 1
-#define MSR_IA32_MISC_ENABLE_TCC (1ULL << MSR_IA32_MISC_ENABLE_TCC_BIT)
-#define MSR_IA32_MISC_ENABLE_EMON_BIT 7
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_EMON (1ULL << MSR_IA32_MISC_ENABLE_EMON_BIT)
-#define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL_BIT 11
-#define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL (1ULL << MSR_IA32_MISC_ENABLE_BTS_UNAVAIL_BIT)
-#define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL_BIT 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL (1ULL << MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL_BIT)
-#define MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP_BIT 16
-#define MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP (1ULL << MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP_BIT)
-#define MSR_IA32_MISC_ENABLE_MWAIT_BIT 18
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << MSR_IA32_MISC_ENABLE_MWAIT_BIT)
-#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT 22
-#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT)
-#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT 23
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_XD_DISABLE_BIT 34
-#define MSR_IA32_MISC_ENABLE_XD_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_XD_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_X87_COMPAT_BIT 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_X87_COMPAT (1ULL << MSR_IA32_MISC_ENABLE_X87_COMPAT_BIT)
-#define MSR_IA32_MISC_ENABLE_TM1_BIT 3
-#define MSR_IA32_MISC_ENABLE_TM1 (1ULL << MSR_IA32_MISC_ENABLE_TM1_BIT)
-#define MSR_IA32_MISC_ENABLE_SPLIT_LOCK_DISABLE_BIT 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_SPLIT_LOCK_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_SPLIT_LOCK_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_L3CACHE_DISABLE_BIT 6
-#define MSR_IA32_MISC_ENABLE_L3CACHE_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_L3CACHE_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_SUPPRESS_LOCK_BIT 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_SUPPRESS_LOCK (1ULL << MSR_IA32_MISC_ENABLE_SUPPRESS_LOCK_BIT)
-#define MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT 9
-#define MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_FERR_BIT 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_FERR (1ULL << MSR_IA32_MISC_ENABLE_FERR_BIT)
-#define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX_BIT 10
-#define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX (1ULL << MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX_BIT)
-#define MSR_IA32_MISC_ENABLE_TM2_BIT 13
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_TM2 (1ULL << MSR_IA32_MISC_ENABLE_TM2_BIT)
-#define MSR_IA32_MISC_ENABLE_ADJ_PREF_DISABLE_BIT 19
-#define MSR_IA32_MISC_ENABLE_ADJ_PREF_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_ADJ_PREF_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_SPEEDSTEP_LOCK_BIT 20
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_SPEEDSTEP_LOCK (1ULL << MSR_IA32_MISC_ENABLE_SPEEDSTEP_LOCK_BIT)
-#define MSR_IA32_MISC_ENABLE_L1D_CONTEXT_BIT 24
-#define MSR_IA32_MISC_ENABLE_L1D_CONTEXT (1ULL << MSR_IA32_MISC_ENABLE_L1D_CONTEXT_BIT)
-#define MSR_IA32_MISC_ENABLE_DCU_PREF_DISABLE_BIT 37
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_DCU_PREF_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_DCU_PREF_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_TURBO_DISABLE_BIT 38
-#define MSR_IA32_MISC_ENABLE_TURBO_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_TURBO_DISABLE_BIT)
-#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT 39
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT)
-#define MSR_IA32_TSC_DEADLINE 0x000006E0
-#define MSR_IA32_MCG_EAX 0x00000180
-#define MSR_IA32_MCG_EBX 0x00000181
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MCG_ECX 0x00000182
-#define MSR_IA32_MCG_EDX 0x00000183
-#define MSR_IA32_MCG_ESI 0x00000184
-#define MSR_IA32_MCG_EDI 0x00000185
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MCG_EBP 0x00000186
-#define MSR_IA32_MCG_ESP 0x00000187
-#define MSR_IA32_MCG_EFLAGS 0x00000188
-#define MSR_IA32_MCG_EIP 0x00000189
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_MCG_RESERVED 0x0000018a
-#define MSR_P4_BPU_PERFCTR0 0x00000300
-#define MSR_P4_BPU_PERFCTR1 0x00000301
-#define MSR_P4_BPU_PERFCTR2 0x00000302
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_BPU_PERFCTR3 0x00000303
-#define MSR_P4_MS_PERFCTR0 0x00000304
-#define MSR_P4_MS_PERFCTR1 0x00000305
-#define MSR_P4_MS_PERFCTR2 0x00000306
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_MS_PERFCTR3 0x00000307
-#define MSR_P4_FLAME_PERFCTR0 0x00000308
-#define MSR_P4_FLAME_PERFCTR1 0x00000309
-#define MSR_P4_FLAME_PERFCTR2 0x0000030a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_FLAME_PERFCTR3 0x0000030b
-#define MSR_P4_IQ_PERFCTR0 0x0000030c
-#define MSR_P4_IQ_PERFCTR1 0x0000030d
-#define MSR_P4_IQ_PERFCTR2 0x0000030e
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_IQ_PERFCTR3 0x0000030f
-#define MSR_P4_IQ_PERFCTR4 0x00000310
-#define MSR_P4_IQ_PERFCTR5 0x00000311
-#define MSR_P4_BPU_CCCR0 0x00000360
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_BPU_CCCR1 0x00000361
-#define MSR_P4_BPU_CCCR2 0x00000362
-#define MSR_P4_BPU_CCCR3 0x00000363
-#define MSR_P4_MS_CCCR0 0x00000364
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_MS_CCCR1 0x00000365
-#define MSR_P4_MS_CCCR2 0x00000366
-#define MSR_P4_MS_CCCR3 0x00000367
-#define MSR_P4_FLAME_CCCR0 0x00000368
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_FLAME_CCCR1 0x00000369
-#define MSR_P4_FLAME_CCCR2 0x0000036a
-#define MSR_P4_FLAME_CCCR3 0x0000036b
-#define MSR_P4_IQ_CCCR0 0x0000036c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_IQ_CCCR1 0x0000036d
-#define MSR_P4_IQ_CCCR2 0x0000036e
-#define MSR_P4_IQ_CCCR3 0x0000036f
-#define MSR_P4_IQ_CCCR4 0x00000370
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_IQ_CCCR5 0x00000371
-#define MSR_P4_ALF_ESCR0 0x000003ca
-#define MSR_P4_ALF_ESCR1 0x000003cb
-#define MSR_P4_BPU_ESCR0 0x000003b2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_BPU_ESCR1 0x000003b3
-#define MSR_P4_BSU_ESCR0 0x000003a0
-#define MSR_P4_BSU_ESCR1 0x000003a1
-#define MSR_P4_CRU_ESCR0 0x000003b8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_CRU_ESCR1 0x000003b9
-#define MSR_P4_CRU_ESCR2 0x000003cc
-#define MSR_P4_CRU_ESCR3 0x000003cd
-#define MSR_P4_CRU_ESCR4 0x000003e0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_CRU_ESCR5 0x000003e1
-#define MSR_P4_DAC_ESCR0 0x000003a8
-#define MSR_P4_DAC_ESCR1 0x000003a9
-#define MSR_P4_FIRM_ESCR0 0x000003a4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_FIRM_ESCR1 0x000003a5
-#define MSR_P4_FLAME_ESCR0 0x000003a6
-#define MSR_P4_FLAME_ESCR1 0x000003a7
-#define MSR_P4_FSB_ESCR0 0x000003a2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_FSB_ESCR1 0x000003a3
-#define MSR_P4_IQ_ESCR0 0x000003ba
-#define MSR_P4_IQ_ESCR1 0x000003bb
-#define MSR_P4_IS_ESCR0 0x000003b4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_IS_ESCR1 0x000003b5
-#define MSR_P4_ITLB_ESCR0 0x000003b6
-#define MSR_P4_ITLB_ESCR1 0x000003b7
-#define MSR_P4_IX_ESCR0 0x000003c8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_IX_ESCR1 0x000003c9
-#define MSR_P4_MOB_ESCR0 0x000003aa
-#define MSR_P4_MOB_ESCR1 0x000003ab
-#define MSR_P4_MS_ESCR0 0x000003c0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_MS_ESCR1 0x000003c1
-#define MSR_P4_PMH_ESCR0 0x000003ac
-#define MSR_P4_PMH_ESCR1 0x000003ad
-#define MSR_P4_RAT_ESCR0 0x000003bc
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_RAT_ESCR1 0x000003bd
-#define MSR_P4_SAAT_ESCR0 0x000003ae
-#define MSR_P4_SAAT_ESCR1 0x000003af
-#define MSR_P4_SSU_ESCR0 0x000003be
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_SSU_ESCR1 0x000003bf
-#define MSR_P4_TBPU_ESCR0 0x000003c2
-#define MSR_P4_TBPU_ESCR1 0x000003c3
-#define MSR_P4_TC_ESCR0 0x000003c4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_P4_TC_ESCR1 0x000003c5
-#define MSR_P4_U2L_ESCR0 0x000003b0
-#define MSR_P4_U2L_ESCR1 0x000003b1
-#define MSR_P4_PEBS_MATRIX_VERT 0x000003f2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_CORE_PERF_FIXED_CTR0 0x00000309
-#define MSR_CORE_PERF_FIXED_CTR1 0x0000030a
-#define MSR_CORE_PERF_FIXED_CTR2 0x0000030b
-#define MSR_CORE_PERF_FIXED_CTR_CTRL 0x0000038d
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_CORE_PERF_GLOBAL_STATUS 0x0000038e
-#define MSR_CORE_PERF_GLOBAL_CTRL 0x0000038f
-#define MSR_CORE_PERF_GLOBAL_OVF_CTRL 0x00000390
-#define MSR_GEODE_BUSCONT_CONF0 0x00001900
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_VMX_BASIC 0x00000480
-#define MSR_IA32_VMX_PINBASED_CTLS 0x00000481
-#define MSR_IA32_VMX_PROCBASED_CTLS 0x00000482
-#define MSR_IA32_VMX_EXIT_CTLS 0x00000483
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_VMX_ENTRY_CTLS 0x00000484
-#define MSR_IA32_VMX_MISC 0x00000485
-#define MSR_IA32_VMX_CR0_FIXED0 0x00000486
-#define MSR_IA32_VMX_CR0_FIXED1 0x00000487
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_VMX_CR4_FIXED0 0x00000488
-#define MSR_IA32_VMX_CR4_FIXED1 0x00000489
-#define MSR_IA32_VMX_VMCS_ENUM 0x0000048a
-#define MSR_IA32_VMX_PROCBASED_CTLS2 0x0000048b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_VMX_EPT_VPID_CAP 0x0000048c
-#define MSR_IA32_VMX_TRUE_PINBASED_CTLS 0x0000048d
-#define MSR_IA32_VMX_TRUE_PROCBASED_CTLS 0x0000048e
-#define MSR_IA32_VMX_TRUE_EXIT_CTLS 0x0000048f
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490
-#define MSR_IA32_VMX_VMFUNC 0x00000491
-#define VMX_BASIC_VMCS_SIZE_SHIFT 32
-#define VMX_BASIC_TRUE_CTLS (1ULL << 55)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VMX_BASIC_64 0x0001000000000000LLU
-#define VMX_BASIC_MEM_TYPE_SHIFT 50
-#define VMX_BASIC_MEM_TYPE_MASK 0x003c000000000000LLU
-#define VMX_BASIC_MEM_TYPE_WB 6LLU
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VMX_BASIC_INOUT 0x0040000000000000LLU
-#define MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS (1ULL << 29)
-#define MSR_IA32_VMX_MISC_PREEMPTION_TIMER_SCALE 0x1F
-#define MSR_VM_CR 0xc0010114
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MSR_VM_IGNNE 0xc0010115
-#define MSR_VM_HSAVE_PA 0xc0010117
-#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/processor-flags.h b/libc/kernel/uapi/asm-x86/asm/processor-flags.h
index 74fbff2..b9a8943 100644
--- a/libc/kernel/uapi/asm-x86/asm/processor-flags.h
+++ b/libc/kernel/uapi/asm-x86/asm/processor-flags.h
@@ -143,24 +143,27 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define X86_CR4_SMAP_BIT 21
 #define X86_CR4_SMAP _BITUL(X86_CR4_SMAP_BIT)
+#define X86_CR4_PKE_BIT 22
+#define X86_CR4_PKE _BITUL(X86_CR4_PKE_BIT)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define X86_CR8_TPR _AC(0x0000000f, UL)
 #define CX86_PCR0 0x20
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CX86_GCR 0xb8
 #define CX86_CCR0 0xc0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CX86_CCR1 0xc1
 #define CX86_CCR2 0xc2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CX86_CCR3 0xc3
 #define CX86_CCR4 0xe8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CX86_CCR5 0xe9
 #define CX86_CCR6 0xea
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CX86_CCR7 0xeb
 #define CX86_PCR1 0xf0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CX86_DIR0 0xfe
 #define CX86_DIR1 0xff
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CX86_ARR_BASE 0xc4
 #define CX86_RCR_BASE 0xdc
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/sigcontext.h b/libc/kernel/uapi/asm-x86/asm/sigcontext.h
index c9dbc50..da14068 100644
--- a/libc/kernel/uapi/asm-x86/asm/sigcontext.h
+++ b/libc/kernel/uapi/asm-x86/asm/sigcontext.h
@@ -182,7 +182,7 @@
   __u16 gs;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 fs;
-  __u16 __pad0;
+  __u16 ss;
   __u64 err;
   __u64 trapno;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -254,20 +254,23 @@
   __u16 cs;
   __u16 gs;
   __u16 fs;
-  __u16 __pad0;
+  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u16 ss;
+    __u16 __pad0;
+  };
   __u64 err;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 trapno;
   __u64 oldmask;
   __u64 cr2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct _fpstate __user * fpstate;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __ILP32__
   __u32 __fpstate_pad;
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 reserved1[8];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-x86/asm/svm.h b/libc/kernel/uapi/asm-x86/asm/svm.h
index 29ead9b..e598d5f 100644
--- a/libc/kernel/uapi/asm-x86/asm/svm.h
+++ b/libc/kernel/uapi/asm-x86/asm/svm.h
@@ -19,96 +19,101 @@
 #ifndef _UAPI__SVM_H
 #define _UAPI__SVM_H
 #define SVM_EXIT_READ_CR0 0x000
-#define SVM_EXIT_READ_CR3 0x003
+#define SVM_EXIT_READ_CR2 0x002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SVM_EXIT_READ_CR3 0x003
 #define SVM_EXIT_READ_CR4 0x004
 #define SVM_EXIT_READ_CR8 0x008
 #define SVM_EXIT_WRITE_CR0 0x010
-#define SVM_EXIT_WRITE_CR3 0x013
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SVM_EXIT_WRITE_CR2 0x012
+#define SVM_EXIT_WRITE_CR3 0x013
 #define SVM_EXIT_WRITE_CR4 0x014
 #define SVM_EXIT_WRITE_CR8 0x018
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_READ_DR0 0x020
 #define SVM_EXIT_READ_DR1 0x021
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_READ_DR2 0x022
 #define SVM_EXIT_READ_DR3 0x023
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_READ_DR4 0x024
 #define SVM_EXIT_READ_DR5 0x025
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_READ_DR6 0x026
 #define SVM_EXIT_READ_DR7 0x027
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_WRITE_DR0 0x030
 #define SVM_EXIT_WRITE_DR1 0x031
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_WRITE_DR2 0x032
 #define SVM_EXIT_WRITE_DR3 0x033
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_WRITE_DR4 0x034
 #define SVM_EXIT_WRITE_DR5 0x035
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_WRITE_DR6 0x036
 #define SVM_EXIT_WRITE_DR7 0x037
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_EXCP_BASE 0x040
 #define SVM_EXIT_INTR 0x060
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_NMI 0x061
 #define SVM_EXIT_SMI 0x062
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_INIT 0x063
 #define SVM_EXIT_VINTR 0x064
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_CR0_SEL_WRITE 0x065
 #define SVM_EXIT_IDTR_READ 0x066
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_GDTR_READ 0x067
 #define SVM_EXIT_LDTR_READ 0x068
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_TR_READ 0x069
 #define SVM_EXIT_IDTR_WRITE 0x06a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_GDTR_WRITE 0x06b
 #define SVM_EXIT_LDTR_WRITE 0x06c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_TR_WRITE 0x06d
 #define SVM_EXIT_RDTSC 0x06e
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_RDPMC 0x06f
 #define SVM_EXIT_PUSHF 0x070
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_POPF 0x071
 #define SVM_EXIT_CPUID 0x072
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_RSM 0x073
 #define SVM_EXIT_IRET 0x074
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_SWINT 0x075
 #define SVM_EXIT_INVD 0x076
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_PAUSE 0x077
 #define SVM_EXIT_HLT 0x078
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_INVLPG 0x079
 #define SVM_EXIT_INVLPGA 0x07a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_IOIO 0x07b
 #define SVM_EXIT_MSR 0x07c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_TASK_SWITCH 0x07d
 #define SVM_EXIT_FERR_FREEZE 0x07e
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_SHUTDOWN 0x07f
 #define SVM_EXIT_VMRUN 0x080
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_VMMCALL 0x081
 #define SVM_EXIT_VMLOAD 0x082
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_VMSAVE 0x083
 #define SVM_EXIT_STGI 0x084
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_CLGI 0x085
 #define SVM_EXIT_SKINIT 0x086
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_RDTSCP 0x087
 #define SVM_EXIT_ICEBP 0x088
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_WBINVD 0x089
 #define SVM_EXIT_MONITOR 0x08a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_MWAIT 0x08b
 #define SVM_EXIT_MWAIT_COND 0x08c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SVM_EXIT_XSETBV 0x08d
 #define SVM_EXIT_NPF 0x400
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
+#define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402
 #define SVM_EXIT_ERR - 1
-#define SVM_EXIT_REASONS { SVM_EXIT_READ_CR0, "read_cr0" }, { SVM_EXIT_READ_CR3, "read_cr3" }, { SVM_EXIT_READ_CR4, "read_cr4" }, { SVM_EXIT_READ_CR8, "read_cr8" }, { SVM_EXIT_WRITE_CR0, "write_cr0" }, { SVM_EXIT_WRITE_CR3, "write_cr3" }, { SVM_EXIT_WRITE_CR4, "write_cr4" }, { SVM_EXIT_WRITE_CR8, "write_cr8" }, { SVM_EXIT_READ_DR0, "read_dr0" }, { SVM_EXIT_READ_DR1, "read_dr1" }, { SVM_EXIT_READ_DR2, "read_dr2" }, { SVM_EXIT_READ_DR3, "read_dr3" }, { SVM_EXIT_WRITE_DR0, "write_dr0" }, { SVM_EXIT_WRITE_DR1, "write_dr1" }, { SVM_EXIT_WRITE_DR2, "write_dr2" }, { SVM_EXIT_WRITE_DR3, "write_dr3" }, { SVM_EXIT_WRITE_DR5, "write_dr5" }, { SVM_EXIT_WRITE_DR7, "write_dr7" }, { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, { SVM_EXIT_EXCP_BASE + AC_VECTOR, "AC excp" }, { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, { SVM_EXIT_INTR, "interrupt" }, { SVM_EXIT_NMI, "nmi" }, { SVM_EXIT_SMI, "smi" }, { SVM_EXIT_INIT, "init" }, { SVM_EXIT_VINTR, "vintr" }, { SVM_EXIT_CPUID, "cpuid" }, { SVM_EXIT_INVD, "invd" }, { SVM_EXIT_HLT, "hlt" }, { SVM_EXIT_INVLPG, "invlpg" }, { SVM_EXIT_INVLPGA, "invlpga" }, { SVM_EXIT_IOIO, "io" }, { SVM_EXIT_MSR, "msr" }, { SVM_EXIT_TASK_SWITCH, "task_switch" }, { SVM_EXIT_SHUTDOWN, "shutdown" }, { SVM_EXIT_VMRUN, "vmrun" }, { SVM_EXIT_VMMCALL, "hypercall" }, { SVM_EXIT_VMLOAD, "vmload" }, { SVM_EXIT_VMSAVE, "vmsave" }, { SVM_EXIT_STGI, "stgi" }, { SVM_EXIT_CLGI, "clgi" }, { SVM_EXIT_SKINIT, "skinit" }, { SVM_EXIT_WBINVD, "wbinvd" }, { SVM_EXIT_MONITOR, "monitor" }, { SVM_EXIT_MWAIT, "mwait" }, { SVM_EXIT_XSETBV, "xsetbv" }, { SVM_EXIT_NPF, "npf" }
+#define SVM_EXIT_REASONS { SVM_EXIT_READ_CR0, "read_cr0" }, { SVM_EXIT_READ_CR2, "read_cr2" }, { SVM_EXIT_READ_CR3, "read_cr3" }, { SVM_EXIT_READ_CR4, "read_cr4" }, { SVM_EXIT_READ_CR8, "read_cr8" }, { SVM_EXIT_WRITE_CR0, "write_cr0" }, { SVM_EXIT_WRITE_CR2, "write_cr2" }, { SVM_EXIT_WRITE_CR3, "write_cr3" }, { SVM_EXIT_WRITE_CR4, "write_cr4" }, { SVM_EXIT_WRITE_CR8, "write_cr8" }, { SVM_EXIT_READ_DR0, "read_dr0" }, { SVM_EXIT_READ_DR1, "read_dr1" }, { SVM_EXIT_READ_DR2, "read_dr2" }, { SVM_EXIT_READ_DR3, "read_dr3" }, { SVM_EXIT_READ_DR4, "read_dr4" }, { SVM_EXIT_READ_DR5, "read_dr5" }, { SVM_EXIT_READ_DR6, "read_dr6" }, { SVM_EXIT_READ_DR7, "read_dr7" }, { SVM_EXIT_WRITE_DR0, "write_dr0" }, { SVM_EXIT_WRITE_DR1, "write_dr1" }, { SVM_EXIT_WRITE_DR2, "write_dr2" }, { SVM_EXIT_WRITE_DR3, "write_dr3" }, { SVM_EXIT_WRITE_DR4, "write_dr4" }, { SVM_EXIT_WRITE_DR5, "write_dr5" }, { SVM_EXIT_WRITE_DR6, "write_dr6" }, { SVM_EXIT_WRITE_DR7, "write_dr7" }, { SVM_EXIT_EXCP_BASE + DE_VECTOR, "DE excp" }, { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, { SVM_EXIT_EXCP_BASE + OF_VECTOR, "OF excp" }, { SVM_EXIT_EXCP_BASE + BR_VECTOR, "BR excp" }, { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, { SVM_EXIT_EXCP_BASE + DF_VECTOR, "DF excp" }, { SVM_EXIT_EXCP_BASE + TS_VECTOR, "TS excp" }, { SVM_EXIT_EXCP_BASE + NP_VECTOR, "NP excp" }, { SVM_EXIT_EXCP_BASE + SS_VECTOR, "SS excp" }, { SVM_EXIT_EXCP_BASE + GP_VECTOR, "GP excp" }, { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, { SVM_EXIT_EXCP_BASE + MF_VECTOR, "MF excp" }, { SVM_EXIT_EXCP_BASE + AC_VECTOR, "AC excp" }, { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, { SVM_EXIT_EXCP_BASE + XM_VECTOR, "XF excp" }, { SVM_EXIT_INTR, "interrupt" }, { SVM_EXIT_NMI, "nmi" }, { SVM_EXIT_SMI, "smi" }, { SVM_EXIT_INIT, "init" }, { SVM_EXIT_VINTR, "vintr" }, { SVM_EXIT_CR0_SEL_WRITE, "cr0_sel_write" }, { SVM_EXIT_IDTR_READ, "read_idtr" }, { SVM_EXIT_GDTR_READ, "read_gdtr" }, { SVM_EXIT_LDTR_READ, "read_ldtr" }, { SVM_EXIT_TR_READ, "read_rt" }, { SVM_EXIT_IDTR_WRITE, "write_idtr" }, { SVM_EXIT_GDTR_WRITE, "write_gdtr" }, { SVM_EXIT_LDTR_WRITE, "write_ldtr" }, { SVM_EXIT_TR_WRITE, "write_rt" }, { SVM_EXIT_RDTSC, "rdtsc" }, { SVM_EXIT_RDPMC, "rdpmc" }, { SVM_EXIT_PUSHF, "pushf" }, { SVM_EXIT_POPF, "popf" }, { SVM_EXIT_CPUID, "cpuid" }, { SVM_EXIT_RSM, "rsm" }, { SVM_EXIT_IRET, "iret" }, { SVM_EXIT_SWINT, "swint" }, { SVM_EXIT_INVD, "invd" }, { SVM_EXIT_PAUSE, "pause" }, { SVM_EXIT_HLT, "hlt" }, { SVM_EXIT_INVLPG, "invlpg" }, { SVM_EXIT_INVLPGA, "invlpga" }, { SVM_EXIT_IOIO, "io" }, { SVM_EXIT_MSR, "msr" }, { SVM_EXIT_TASK_SWITCH, "task_switch" }, { SVM_EXIT_FERR_FREEZE, "ferr_freeze" }, { SVM_EXIT_SHUTDOWN, "shutdown" }, { SVM_EXIT_VMRUN, "vmrun" }, { SVM_EXIT_VMMCALL, "hypercall" }, { SVM_EXIT_VMLOAD, "vmload" }, { SVM_EXIT_VMSAVE, "vmsave" }, { SVM_EXIT_STGI, "stgi" }, { SVM_EXIT_CLGI, "clgi" }, { SVM_EXIT_SKINIT, "skinit" }, { SVM_EXIT_RDTSCP, "rdtscp" }, { SVM_EXIT_ICEBP, "icebp" }, { SVM_EXIT_WBINVD, "wbinvd" }, { SVM_EXIT_MONITOR, "monitor" }, { SVM_EXIT_MWAIT, "mwait" }, { SVM_EXIT_XSETBV, "xsetbv" }, { SVM_EXIT_NPF, "npf" }, { SVM_EXIT_AVIC_INCOMPLETE_IPI, "avic_incomplete_ipi" }, { SVM_EXIT_AVIC_UNACCELERATED_ACCESS, "avic_unaccelerated_access" }, { SVM_EXIT_ERR, "invalid_guest_state" }
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/ucontext.h b/libc/kernel/uapi/asm-x86/asm/ucontext.h
index 9ceffac..88f8160 100644
--- a/libc/kernel/uapi/asm-x86/asm/ucontext.h
+++ b/libc/kernel/uapi/asm-x86/asm/ucontext.h
@@ -19,6 +19,11 @@
 #ifndef _ASM_X86_UCONTEXT_H
 #define _ASM_X86_UCONTEXT_H
 #define UC_FP_XSTATE 0x1
+#ifdef __x86_64__
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UC_SIGCONTEXT_SS 0x2
+#define UC_STRICT_RESTORE_SS 0x4
+#endif
 #include <asm-generic/ucontext.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_32.h b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
index 6a5a8d4..f520ca9 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
@@ -484,5 +484,8 @@
 #define __NR_userfaultfd 374
 #define __NR_membarrier 375
 #define __NR_mlock2 376
-#endif
+#define __NR_copy_file_range 377
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_preadv2 378
+#define __NR_pwritev2 379
+#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_64.h b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
index 2d02d21..c43d336 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_64.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
@@ -426,4 +426,8 @@
 #define __NR_membarrier 324
 #define __NR_mlock2 325
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_copy_file_range 326
+#define __NR_preadv2 327
+#define __NR_pwritev2 328
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
index 894615c..42dd8a3 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
@@ -369,47 +369,51 @@
 #define __NR_userfaultfd (__X32_SYSCALL_BIT + 323)
 #define __NR_membarrier (__X32_SYSCALL_BIT + 324)
 #define __NR_mlock2 (__X32_SYSCALL_BIT + 325)
-#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
+#define __NR_copy_file_range (__X32_SYSCALL_BIT + 326)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
 #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
 #define __NR_ioctl (__X32_SYSCALL_BIT + 514)
 #define __NR_readv (__X32_SYSCALL_BIT + 515)
-#define __NR_writev (__X32_SYSCALL_BIT + 516)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_writev (__X32_SYSCALL_BIT + 516)
 #define __NR_recvfrom (__X32_SYSCALL_BIT + 517)
 #define __NR_sendmsg (__X32_SYSCALL_BIT + 518)
 #define __NR_recvmsg (__X32_SYSCALL_BIT + 519)
-#define __NR_execve (__X32_SYSCALL_BIT + 520)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_execve (__X32_SYSCALL_BIT + 520)
 #define __NR_ptrace (__X32_SYSCALL_BIT + 521)
 #define __NR_rt_sigpending (__X32_SYSCALL_BIT + 522)
 #define __NR_rt_sigtimedwait (__X32_SYSCALL_BIT + 523)
-#define __NR_rt_sigqueueinfo (__X32_SYSCALL_BIT + 524)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_rt_sigqueueinfo (__X32_SYSCALL_BIT + 524)
 #define __NR_sigaltstack (__X32_SYSCALL_BIT + 525)
 #define __NR_timer_create (__X32_SYSCALL_BIT + 526)
 #define __NR_mq_notify (__X32_SYSCALL_BIT + 527)
-#define __NR_kexec_load (__X32_SYSCALL_BIT + 528)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_kexec_load (__X32_SYSCALL_BIT + 528)
 #define __NR_waitid (__X32_SYSCALL_BIT + 529)
 #define __NR_set_robust_list (__X32_SYSCALL_BIT + 530)
 #define __NR_get_robust_list (__X32_SYSCALL_BIT + 531)
-#define __NR_vmsplice (__X32_SYSCALL_BIT + 532)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_vmsplice (__X32_SYSCALL_BIT + 532)
 #define __NR_move_pages (__X32_SYSCALL_BIT + 533)
 #define __NR_preadv (__X32_SYSCALL_BIT + 534)
-#define __NR_pwritev (__X32_SYSCALL_BIT + 535)
-#define __NR_rt_tgsigqueueinfo (__X32_SYSCALL_BIT + 536)
+#define __NR_preadv2 (__X32_SYSCALL_BIT + 534)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_pwritev (__X32_SYSCALL_BIT + 535)
+#define __NR_pwritev2 (__X32_SYSCALL_BIT + 535)
+#define __NR_rt_tgsigqueueinfo (__X32_SYSCALL_BIT + 536)
 #define __NR_recvmmsg (__X32_SYSCALL_BIT + 537)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendmmsg (__X32_SYSCALL_BIT + 538)
 #define __NR_process_vm_readv (__X32_SYSCALL_BIT + 539)
 #define __NR_process_vm_writev (__X32_SYSCALL_BIT + 540)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setsockopt (__X32_SYSCALL_BIT + 541)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsockopt (__X32_SYSCALL_BIT + 542)
 #define __NR_io_setup (__X32_SYSCALL_BIT + 543)
 #define __NR_io_submit (__X32_SYSCALL_BIT + 544)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_execveat (__X32_SYSCALL_BIT + 545)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/drm/amdgpu_drm.h b/libc/kernel/uapi/drm/amdgpu_drm.h
index 16c127c..059fed5 100644
--- a/libc/kernel/uapi/drm/amdgpu_drm.h
+++ b/libc/kernel/uapi/drm/amdgpu_drm.h
@@ -19,481 +19,486 @@
 #ifndef __AMDGPU_DRM_H__
 #define __AMDGPU_DRM_H__
 #include "drm.h"
-#define DRM_AMDGPU_GEM_CREATE 0x00
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define DRM_AMDGPU_GEM_CREATE 0x00
 #define DRM_AMDGPU_GEM_MMAP 0x01
 #define DRM_AMDGPU_CTX 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_AMDGPU_BO_LIST 0x03
 #define DRM_AMDGPU_CS 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_AMDGPU_INFO 0x05
 #define DRM_AMDGPU_GEM_METADATA 0x06
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_AMDGPU_GEM_WAIT_IDLE 0x07
 #define DRM_AMDGPU_GEM_VA 0x08
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_AMDGPU_WAIT_CS 0x09
 #define DRM_AMDGPU_GEM_OP 0x10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_AMDGPU_GEM_USERPTR 0x11
 #define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
 #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
 #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
 #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
 #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
 #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
 #define AMDGPU_GEM_DOMAIN_CPU 0x1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_DOMAIN_GTT 0x2
 #define AMDGPU_GEM_DOMAIN_VRAM 0x4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_DOMAIN_GDS 0x8
 #define AMDGPU_GEM_DOMAIN_GWS 0x10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_DOMAIN_OA 0x20
 #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
 #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_gem_create_in {
-  uint64_t bo_size;
-  uint64_t alignment;
-  uint64_t domains;
+  __u64 bo_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t domain_flags;
+  __u64 alignment;
+  __u64 domains;
+  __u64 domain_flags;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_gem_create_out {
-  uint32_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t _pad;
+  __u32 handle;
+  __u32 _pad;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_amdgpu_gem_create {
   struct drm_amdgpu_gem_create_in in;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_amdgpu_gem_create_out out;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_BO_LIST_OP_CREATE 0
 #define AMDGPU_BO_LIST_OP_DESTROY 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_BO_LIST_OP_UPDATE 2
 struct drm_amdgpu_bo_list_in {
-  uint32_t operation;
-  uint32_t list_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t bo_number;
-  uint32_t bo_info_size;
-  uint64_t bo_info_ptr;
+  __u32 operation;
+  __u32 list_handle;
+  __u32 bo_number;
+  __u32 bo_info_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 bo_info_ptr;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_bo_list_entry {
-  uint32_t bo_handle;
-  uint32_t bo_priority;
-};
+  __u32 bo_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bo_priority;
+};
 struct drm_amdgpu_bo_list_out {
-  uint32_t list_handle;
-  uint32_t _pad;
-};
+  __u32 list_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 _pad;
+};
 union drm_amdgpu_bo_list {
   struct drm_amdgpu_bo_list_in in;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_amdgpu_bo_list_out out;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_CTX_OP_ALLOC_CTX 1
 #define AMDGPU_CTX_OP_FREE_CTX 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_CTX_OP_QUERY_STATE 3
 #define AMDGPU_CTX_NO_RESET 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_CTX_GUILTY_RESET 1
 #define AMDGPU_CTX_INNOCENT_RESET 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_CTX_UNKNOWN_RESET 3
 struct drm_amdgpu_ctx_in {
+  __u32 op;
+  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t op;
-  uint32_t flags;
-  uint32_t ctx_id;
-  uint32_t _pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ctx_id;
+  __u32 _pad;
 };
 union drm_amdgpu_ctx_out {
-  struct {
-    uint32_t ctx_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    uint32_t _pad;
+  struct {
+    __u32 ctx_id;
+    __u32 _pad;
   } alloc;
-  struct {
-    uint64_t flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    uint32_t hangs;
-    uint32_t reset_status;
+  struct {
+    __u64 flags;
+    __u32 hangs;
+    __u32 reset_status;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } state;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_amdgpu_ctx {
   struct drm_amdgpu_ctx_in in;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union drm_amdgpu_ctx_out out;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
 #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
 #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_gem_userptr {
-  uint64_t addr;
-  uint64_t size;
-  uint32_t flags;
+  __u64 addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t handle;
+  __u64 size;
+  __u32 flags;
+  __u32 handle;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
 #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
 #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
 #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
 #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
 #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
 #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
 #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
 #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_TILING_SET(field,value) (((value) & AMDGPU_TILING_ ##field ##_MASK) << AMDGPU_TILING_ ##field ##_SHIFT)
 #define AMDGPU_TILING_GET(value,field) (((value) >> AMDGPU_TILING_ ##field ##_SHIFT) & AMDGPU_TILING_ ##field ##_MASK)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
 #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_gem_metadata {
-  uint32_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t op;
+  __u32 handle;
+  __u32 op;
   struct {
-    uint64_t flags;
-    uint64_t tiling_info;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    uint32_t data_size_bytes;
-    uint32_t data[64];
+    __u64 flags;
+    __u64 tiling_info;
+    __u32 data_size_bytes;
+    __u32 data[64];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } data;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_gem_mmap_in {
-  uint32_t handle;
-  uint32_t _pad;
-};
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 _pad;
+};
 struct drm_amdgpu_gem_mmap_out {
-  uint64_t addr_ptr;
+  __u64 addr_ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 union drm_amdgpu_gem_mmap {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_amdgpu_gem_mmap_in in;
   struct drm_amdgpu_gem_mmap_out out;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_amdgpu_gem_wait_idle_in {
+  __u32 handle;
+  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t handle;
-  uint32_t flags;
-  uint64_t timeout;
+  __u64 timeout;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_gem_wait_idle_out {
-  uint32_t status;
-  uint32_t domain;
-};
+  __u32 status;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 domain;
+};
 union drm_amdgpu_gem_wait_idle {
   struct drm_amdgpu_gem_wait_idle_in in;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_amdgpu_gem_wait_idle_out out;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_wait_cs_in {
-  uint64_t handle;
-  uint64_t timeout;
-  uint32_t ip_type;
+  __u64 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t ip_instance;
-  uint32_t ring;
-  uint32_t ctx_id;
+  __u64 timeout;
+  __u32 ip_type;
+  __u32 ip_instance;
+  __u32 ring;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ctx_id;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_wait_cs_out {
-  uint64_t status;
+  __u64 status;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 union drm_amdgpu_wait_cs {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_amdgpu_wait_cs_in in;
   struct drm_amdgpu_wait_cs_out out;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_GEM_OP_SET_PLACEMENT 1
 struct drm_amdgpu_gem_op {
-  uint32_t handle;
-  uint32_t op;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t value;
+  __u32 handle;
+  __u32 op;
+  __u64 value;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_VA_OP_MAP 1
 #define AMDGPU_VA_OP_UNMAP 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
 #define AMDGPU_VM_PAGE_READABLE (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
 #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_gem_va {
-  uint32_t handle;
-  uint32_t _pad;
-  uint32_t operation;
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t flags;
-  uint64_t va_address;
-  uint64_t offset_in_bo;
-  uint64_t map_size;
+  __u32 _pad;
+  __u32 operation;
+  __u32 flags;
+  __u64 va_address;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 offset_in_bo;
+  __u64 map_size;
 };
 #define AMDGPU_HW_IP_GFX 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_HW_IP_COMPUTE 1
 #define AMDGPU_HW_IP_DMA 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_HW_IP_UVD 3
 #define AMDGPU_HW_IP_VCE 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_HW_IP_NUM 5
 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_CHUNK_ID_IB 0x01
 #define AMDGPU_CHUNK_ID_FENCE 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
 struct drm_amdgpu_cs_chunk {
+  __u32 chunk_id;
+  __u32 length_dw;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t chunk_id;
-  uint32_t length_dw;
-  uint64_t chunk_data;
+  __u64 chunk_data;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_cs_in {
-  uint32_t ctx_id;
-  uint32_t bo_list_handle;
-  uint32_t num_chunks;
+  __u32 ctx_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t _pad;
-  uint64_t chunks;
+  __u32 bo_list_handle;
+  __u32 num_chunks;
+  __u32 _pad;
+  __u64 chunks;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_amdgpu_cs_out {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t handle;
+  __u64 handle;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_amdgpu_cs {
   struct drm_amdgpu_cs_in in;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_amdgpu_cs_out out;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_IB_FLAG_CE (1 << 0)
 #define AMDGPU_IB_FLAG_PREAMBLE (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_cs_chunk_ib {
-  uint32_t _pad;
-  uint32_t flags;
-  uint64_t va_start;
+  __u32 _pad;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t ib_bytes;
-  uint32_t ip_type;
-  uint32_t ip_instance;
-  uint32_t ring;
+  __u32 flags;
+  __u64 va_start;
+  __u32 ib_bytes;
+  __u32 ip_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ip_instance;
+  __u32 ring;
 };
 struct drm_amdgpu_cs_chunk_dep {
-  uint32_t ip_type;
-  uint32_t ip_instance;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t ring;
-  uint32_t ctx_id;
-  uint64_t handle;
+  __u32 ip_type;
+  __u32 ip_instance;
+  __u32 ring;
+  __u32 ctx_id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 handle;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_cs_chunk_fence {
-  uint32_t handle;
-  uint32_t offset;
-};
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offset;
+};
 struct drm_amdgpu_cs_chunk_data {
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct drm_amdgpu_cs_chunk_ib ib_data;
     struct drm_amdgpu_cs_chunk_fence fence_data;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_IDS_FLAGS_FUSION 0x1
 #define AMDGPU_INFO_ACCEL_WORKING 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_CRTC_FROM_ID 0x01
 #define AMDGPU_INFO_HW_IP_INFO 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_HW_IP_COUNT 0x03
 #define AMDGPU_INFO_TIMESTAMP 0x05
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_FW_VERSION 0x0e
 #define AMDGPU_INFO_FW_VCE 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_FW_UVD 0x2
 #define AMDGPU_INFO_FW_GMC 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_FW_GFX_ME 0x04
 #define AMDGPU_INFO_FW_GFX_PFP 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_FW_GFX_CE 0x06
 #define AMDGPU_INFO_FW_GFX_RLC 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_FW_GFX_MEC 0x08
 #define AMDGPU_INFO_FW_SMC 0x0a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_FW_SDMA 0x0b
 #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_VRAM_USAGE 0x10
 #define AMDGPU_INFO_GTT_USAGE 0x11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_GDS_CONFIG 0x13
 #define AMDGPU_INFO_VRAM_GTT 0x14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_READ_MMR_REG 0x15
 #define AMDGPU_INFO_DEV_INFO 0x16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
 #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
 struct drm_amdgpu_info {
+  __u64 return_pointer;
+  __u32 return_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t return_pointer;
-  uint32_t return_size;
-  uint32_t query;
+  __u32 query;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
-      uint32_t id;
-      uint32_t _pad;
+      __u32 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 _pad;
     } mode_crtc;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
-      uint32_t type;
-      uint32_t ip_instance;
+      __u32 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 ip_instance;
     } query_hw_ip;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
-      uint32_t dword_offset;
-      uint32_t count;
-      uint32_t instance;
+      __u32 dword_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-      uint32_t flags;
+      __u32 count;
+      __u32 instance;
+      __u32 flags;
     } read_mmr_reg;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
-      uint32_t fw_type;
+      __u32 fw_type;
+      __u32 ip_instance;
+      __u32 index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-      uint32_t ip_instance;
-      uint32_t index;
-      uint32_t _pad;
+      __u32 _pad;
     } query_fw;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_info_gds {
-  uint32_t gds_gfx_partition_size;
+  __u32 gds_gfx_partition_size;
+  __u32 compute_partition_size;
+  __u32 gds_total_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t compute_partition_size;
-  uint32_t gds_total_size;
-  uint32_t gws_per_gfx_partition;
-  uint32_t gws_per_compute_partition;
+  __u32 gws_per_gfx_partition;
+  __u32 gws_per_compute_partition;
+  __u32 oa_per_gfx_partition;
+  __u32 oa_per_compute_partition;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t oa_per_gfx_partition;
-  uint32_t oa_per_compute_partition;
-  uint32_t _pad;
+  __u32 _pad;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_info_vram_gtt {
-  uint64_t vram_size;
-  uint64_t vram_cpu_accessible_size;
-  uint64_t gtt_size;
+  __u64 vram_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 vram_cpu_accessible_size;
+  __u64 gtt_size;
 };
 struct drm_amdgpu_info_firmware {
-  uint32_t ver;
-  uint32_t feature;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ver;
+  __u32 feature;
 };
 #define AMDGPU_VRAM_TYPE_UNKNOWN 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_VRAM_TYPE_GDDR1 1
 #define AMDGPU_VRAM_TYPE_DDR2 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_VRAM_TYPE_GDDR3 3
 #define AMDGPU_VRAM_TYPE_GDDR4 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_VRAM_TYPE_GDDR5 5
 #define AMDGPU_VRAM_TYPE_HBM 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_VRAM_TYPE_DDR3 7
 struct drm_amdgpu_info_device {
-  uint32_t device_id;
-  uint32_t chip_rev;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t external_rev;
-  uint32_t pci_rev;
-  uint32_t family;
-  uint32_t num_shader_engines;
+  __u32 device_id;
+  __u32 chip_rev;
+  __u32 external_rev;
+  __u32 pci_rev;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t num_shader_arrays_per_engine;
-  uint32_t gpu_counter_freq;
-  uint64_t max_engine_clock;
-  uint64_t max_memory_clock;
+  __u32 family;
+  __u32 num_shader_engines;
+  __u32 num_shader_arrays_per_engine;
+  __u32 gpu_counter_freq;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t cu_active_number;
-  uint32_t cu_ao_mask;
-  uint32_t cu_bitmap[4][4];
-  uint32_t enabled_rb_pipes_mask;
+  __u64 max_engine_clock;
+  __u64 max_memory_clock;
+  __u32 cu_active_number;
+  __u32 cu_ao_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t num_rb_pipes;
-  uint32_t num_hw_gfx_contexts;
-  uint32_t _pad;
-  uint64_t ids_flags;
+  __u32 cu_bitmap[4][4];
+  __u32 enabled_rb_pipes_mask;
+  __u32 num_rb_pipes;
+  __u32 num_hw_gfx_contexts;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t virtual_address_offset;
-  uint64_t virtual_address_max;
-  uint32_t virtual_address_alignment;
-  uint32_t pte_fragment_size;
+  __u32 _pad;
+  __u64 ids_flags;
+  __u64 virtual_address_offset;
+  __u64 virtual_address_max;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t gart_page_size;
-  uint32_t ce_ram_size;
-  uint32_t vram_type;
-  uint32_t vram_bit_width;
+  __u32 virtual_address_alignment;
+  __u32 pte_fragment_size;
+  __u32 gart_page_size;
+  __u32 ce_ram_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t vce_harvest_config;
+  __u32 vram_type;
+  __u32 vram_bit_width;
+  __u32 vce_harvest_config;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_amdgpu_info_hw_ip {
-  uint32_t hw_ip_version_major;
+  __u32 hw_ip_version_major;
+  __u32 hw_ip_version_minor;
+  __u64 capabilities_flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t hw_ip_version_minor;
-  uint64_t capabilities_flags;
-  uint32_t ib_start_alignment;
-  uint32_t ib_size_alignment;
+  __u32 ib_start_alignment;
+  __u32 ib_size_alignment;
+  __u32 available_rings;
+  __u32 _pad;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t available_rings;
-  uint32_t _pad;
 };
 #define AMDGPU_FAMILY_UNKNOWN 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_FAMILY_CI 120
 #define AMDGPU_FAMILY_KV 125
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define AMDGPU_FAMILY_VI 130
 #define AMDGPU_FAMILY_CZ 135
+#ifdef __cplusplus
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/drm/armada_drm.h b/libc/kernel/uapi/drm/armada_drm.h
index 160c4f8..ca9d46b 100644
--- a/libc/kernel/uapi/drm/armada_drm.h
+++ b/libc/kernel/uapi/drm/armada_drm.h
@@ -18,34 +18,41 @@
  ****************************************************************************/
 #ifndef DRM_ARMADA_IOCTL_H
 #define DRM_ARMADA_IOCTL_H
+#include "drm.h"
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define DRM_ARMADA_GEM_CREATE 0x00
 #define DRM_ARMADA_GEM_MMAP 0x02
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_ARMADA_GEM_PWRITE 0x03
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ARMADA_IOCTL(dir,name,str) DRM_ ##dir(DRM_COMMAND_BASE + DRM_ARMADA_ ##name, struct drm_armada_ ##str)
 struct drm_armada_gem_create {
   uint32_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define DRM_IOCTL_ARMADA_GEM_CREATE ARMADA_IOCTL(IOWR, GEM_CREATE, gem_create)
 struct drm_armada_gem_mmap {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t pad;
   uint64_t offset;
   uint64_t size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define DRM_IOCTL_ARMADA_GEM_MMAP ARMADA_IOCTL(IOWR, GEM_MMAP, gem_mmap)
 struct drm_armada_gem_pwrite {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t handle;
   uint32_t offset;
   uint32_t size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_ARMADA_GEM_PWRITE ARMADA_IOCTL(IOW, GEM_PWRITE, gem_pwrite)
+#ifdef __cplusplus
 #endif
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/drm/drm.h b/libc/kernel/uapi/drm/drm.h
index 1f32797..713e7fe 100644
--- a/libc/kernel/uapi/drm/drm.h
+++ b/libc/kernel/uapi/drm/drm.h
@@ -37,418 +37,428 @@
 typedef int64_t __s64;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef uint64_t __u64;
+typedef size_t __kernel_size_t;
 typedef unsigned long drm_handle_t;
 #endif
-#define DRM_NAME "drm"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
+#define DRM_NAME "drm"
 #define DRM_MIN_ORDER 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MAX_ORDER 22
 #define DRM_RAM_PERCENT 10
 #define _DRM_LOCK_HELD 0x80000000U
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _DRM_LOCK_CONT 0x40000000U
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
 #define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
 #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD | _DRM_LOCK_CONT))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef unsigned int drm_context_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef unsigned int drm_drawable_t;
 typedef unsigned int drm_magic_t;
 struct drm_clip_rect {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short x1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short y1;
   unsigned short x2;
   unsigned short y2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_drawable_info {
   unsigned int num_rects;
   struct drm_clip_rect * rects;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tex_region {
   unsigned char next;
   unsigned char prev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char in_use;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char padding;
   unsigned int age;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_hw_lock {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __volatile__ unsigned int lock;
   char padding[60];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_version {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int version_major;
   int version_minor;
   int version_patchlevel;
+  __kernel_size_t name_len;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  size_t name_len;
   char __user * name;
-  size_t date_len;
+  __kernel_size_t date_len;
   char __user * date;
+  __kernel_size_t desc_len;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  size_t desc_len;
   char __user * desc;
 };
 struct drm_unique {
+  __kernel_size_t unique_len;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  size_t unique_len;
   char __user * unique;
 };
 struct drm_list {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_version __user * version;
 };
 struct drm_block {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int unused;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_control {
   enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     DRM_ADD_COMMAND,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     DRM_RM_COMMAND,
     DRM_INST_HANDLER,
     DRM_UNINST_HANDLER
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } func;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int irq;
 };
 enum drm_map_type {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_FRAME_BUFFER = 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_REGISTERS = 1,
   _DRM_SHM = 2,
   _DRM_AGP = 3,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_SCATTER_GATHER = 4,
-  _DRM_CONSISTENT = 5,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  _DRM_CONSISTENT = 5
 };
 enum drm_map_flags {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_RESTRICTED = 0x01,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_READ_ONLY = 0x02,
   _DRM_LOCKED = 0x04,
   _DRM_KERNEL = 0x08,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_WRITE_COMBINING = 0x10,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_CONTAINS_LOCK = 0x20,
   _DRM_REMOVABLE = 0x40,
   _DRM_DRIVER = 0x80
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_ctx_priv_map {
   unsigned int ctx_id;
   void * handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_map {
   unsigned long offset;
   unsigned long size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum drm_map_type type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum drm_map_flags flags;
   void * handle;
   int mtrr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_client {
   int idx;
   int auth;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long pid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long uid;
   unsigned long magic;
   unsigned long iocs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_stat_type {
   _DRM_STAT_LOCK,
   _DRM_STAT_OPENS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_STAT_CLOSES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_STAT_IOCTLS,
   _DRM_STAT_LOCKS,
   _DRM_STAT_UNLOCKS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_STAT_VALUE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_STAT_BYTE,
   _DRM_STAT_COUNT,
   _DRM_STAT_IRQ,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_STAT_PRIMARY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_STAT_SECONDARY,
   _DRM_STAT_DMA,
   _DRM_STAT_SPECIAL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_STAT_MISSED
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_stats {
   unsigned long count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned long value;
     enum drm_stat_type type;
   } data[15];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_lock_flags {
   _DRM_LOCK_READY = 0x01,
   _DRM_LOCK_QUIESCENT = 0x02,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_LOCK_FLUSH = 0x04,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_LOCK_FLUSH_ALL = 0x08,
   _DRM_HALT_ALL_QUEUES = 0x10,
   _DRM_HALT_CUR_QUEUES = 0x20
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_lock {
   int context;
   enum drm_lock_flags flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_dma_flags {
   _DRM_DMA_BLOCK = 0x01,
   _DRM_DMA_WHILE_LOCKED = 0x02,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_DMA_PRIORITY = 0x04,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_DMA_WAIT = 0x10,
   _DRM_DMA_SMALLER_OK = 0x20,
   _DRM_DMA_LARGER_OK = 0x40
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_buf_desc {
   int count;
   int size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int low_mark;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int high_mark;
   enum {
     _DRM_PAGE_ALIGN = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     _DRM_AGP_BUFFER = 0x02,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     _DRM_SG_BUFFER = 0x04,
     _DRM_FB_BUFFER = 0x08,
     _DRM_PCI_BUFFER_RO = 0x10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long agp_start;
 };
 struct drm_buf_info {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_buf_desc __user * list;
 };
 struct drm_buf_free {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int __user * list;
 };
 struct drm_buf_pub {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int total;
   int used;
   void __user * address;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_buf_map {
   int count;
-  void __user * virtual;
+#ifdef __cplusplus
+  void __user * virt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
+  void __user * __linux_virtual;
+#endif
   struct drm_buf_pub __user * list;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_dma {
   int context;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int send_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int __user * send_indices;
   int __user * send_sizes;
   enum drm_dma_flags flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int request_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int request_size;
   int __user * request_indices;
   int __user * request_sizes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int granted_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum drm_ctx_flags {
   _DRM_CONTEXT_PRESERVED = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_CONTEXT_2DONLY = 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_ctx {
   drm_context_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum drm_ctx_flags flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_ctx_res {
   int count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_ctx __user * contexts;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_draw {
   drm_drawable_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-typedef enum {
-  DRM_DRAWABLE_CLIPRECTS,
-} drm_drawable_info_type_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef enum {
+  DRM_DRAWABLE_CLIPRECTS
+} drm_drawable_info_type_t;
 struct drm_update_draw {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_drawable_t handle;
   unsigned int type;
   unsigned int num;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long long data;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_auth {
   drm_magic_t magic;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_irq_busid {
   int irq;
   int busnum;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int devnum;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int funcnum;
 };
 enum drm_vblank_seq_type {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_VBLANK_ABSOLUTE = 0x0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_VBLANK_RELATIVE = 0x1,
   _DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
   _DRM_VBLANK_EVENT = 0x4000000,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_VBLANK_FLIP = 0x8000000,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   _DRM_VBLANK_NEXTONMISS = 0x10000000,
   _DRM_VBLANK_SECONDARY = 0x20000000,
   _DRM_VBLANK_SIGNAL = 0x40000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _DRM_VBLANK_HIGH_CRTC_SHIFT 1
 #define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
 #define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_wait_vblank_request {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum drm_vblank_seq_type type;
   unsigned int sequence;
   unsigned long signal;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_wait_vblank_reply {
   enum drm_vblank_seq_type type;
   unsigned int sequence;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   long tval_sec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   long tval_usec;
 };
 union drm_wait_vblank {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_wait_vblank_request request;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_wait_vblank_reply reply;
 };
 #define _DRM_PRE_MODESET 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _DRM_POST_MODESET 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_modeset_ctl {
   __u32 crtc;
   __u32 cmd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_agp_mode {
   unsigned long mode;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_agp_buffer {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long size;
   unsigned long handle;
   unsigned long type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long physical;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_agp_binding {
   unsigned long handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_agp_info {
   int agp_version_major;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int agp_version_minor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long mode;
   unsigned long aperture_base;
   unsigned long aperture_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long memory_allowed;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long memory_used;
   unsigned short id_vendor;
   unsigned short id_device;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_scatter_gather {
   unsigned long size;
   unsigned long handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_set_version {
   int drm_di_major;
   int drm_di_minor;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int drm_dd_major;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int drm_dd_minor;
 };
 struct drm_gem_close {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
 };
 struct drm_gem_flink {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 name;
 };
 struct drm_gem_open {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 name;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
   __u64 size;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_CAP_DUMB_BUFFER 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_CAP_VBLANK_HIGH_CRTC 0x2
 #define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
 #define DRM_CAP_DUMB_PREFER_SHADOW 0x4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_CAP_PRIME 0x5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_PRIME_CAP_IMPORT 0x1
 #define DRM_PRIME_CAP_EXPORT 0x2
 #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_CAP_ASYNC_PAGE_FLIP 0x7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_CAP_CURSOR_WIDTH 0x8
 #define DRM_CAP_CURSOR_HEIGHT 0x9
 #define DRM_CAP_ADDFB2_MODIFIERS 0x10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_get_cap {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 capability;
   __u64 value;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_CLIENT_CAP_STEREO_3D 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
 #define DRM_CLIENT_CAP_ATOMIC 3
 struct drm_set_client_cap {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 capability;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 value;
 };
+#define DRM_RDWR O_RDWR
 #define DRM_CLOEXEC O_CLOEXEC
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_prime_handle {
@@ -457,7 +467,12 @@
   __s32 fd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#include <drm/drm_mode.h>
+#ifdef __cplusplus
+#endif
+#include "drm_mode.h"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
 #define DRM_IOCTL_BASE 'd'
 #define DRM_IO(nr) _IO(DRM_IOCTL_BASE, nr)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -644,5 +659,7 @@
 typedef struct drm_agp_info drm_agp_info_t;
 typedef struct drm_scatter_gather drm_scatter_gather_t;
 typedef struct drm_set_version drm_set_version_t;
-#endif
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#endif
diff --git a/libc/kernel/uapi/drm/drm_fourcc.h b/libc/kernel/uapi/drm/drm_fourcc.h
index ec8a91a..99e84ae 100644
--- a/libc/kernel/uapi/drm/drm_fourcc.h
+++ b/libc/kernel/uapi/drm/drm_fourcc.h
@@ -18,101 +18,106 @@
  ****************************************************************************/
 #ifndef DRM_FOURCC_H
 #define DRM_FOURCC_H
-#include <linux/types.h>
-#define fourcc_code(a,b,c,d) ((__u32) (a) | ((__u32) (b) << 8) | ((__u32) (c) << 16) | ((__u32) (d) << 24))
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define fourcc_code(a,b,c,d) ((__u32) (a) | ((__u32) (b) << 8) | ((__u32) (c) << 16) | ((__u32) (d) << 24))
 #define DRM_FORMAT_BIG_ENDIAN (1 << 31)
 #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ')
 #define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8')
 #define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8')
 #define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2')
 #define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2')
 #define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2')
 #define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2')
 #define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5')
 #define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5')
 #define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5')
 #define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5')
 #define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6')
 #define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4')
 #define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4')
 #define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4')
 #define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4')
 #define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4')
 #define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0')
 #define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0')
 #define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0')
 #define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0')
 #define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U')
 #define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y')
 #define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2')
 #define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6')
 #define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4')
 #define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9')
 #define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1')
 #define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2')
 #define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6')
 #define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4')
 #define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_MOD_NONE 0
 #define DRM_FORMAT_MOD_VENDOR_INTEL 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_MOD_VENDOR_AMD 0x02
 #define DRM_FORMAT_MOD_VENDOR_NV 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04
 #define DRM_FORMAT_MOD_VENDOR_QCOM 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define fourcc_mod_code(vendor,val) ((((__u64) DRM_FORMAT_MOD_VENDOR_ ##vendor) << 56) | (val & 0x00ffffffffffffffULL))
 #define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2)
 #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1)
+#ifdef __cplusplus
+#endif
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/drm/drm_mode.h b/libc/kernel/uapi/drm/drm_mode.h
index 240a8ae..8fda8d8 100644
--- a/libc/kernel/uapi/drm/drm_mode.h
+++ b/libc/kernel/uapi/drm/drm_mode.h
@@ -18,211 +18,216 @@
  ****************************************************************************/
 #ifndef _DRM_MODE_H
 #define _DRM_MODE_H
-#include <linux/types.h>
-#define DRM_DISPLAY_INFO_LEN 32
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define DRM_DISPLAY_INFO_LEN 32
 #define DRM_CONNECTOR_NAME_LEN 32
 #define DRM_DISPLAY_MODE_LEN 32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_PROP_NAME_LEN 32
 #define DRM_MODE_TYPE_BUILTIN (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_TYPE_CLOCK_C ((1 << 1) | DRM_MODE_TYPE_BUILTIN)
 #define DRM_MODE_TYPE_CRTC_C ((1 << 2) | DRM_MODE_TYPE_BUILTIN)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_TYPE_PREFERRED (1 << 3)
 #define DRM_MODE_TYPE_DEFAULT (1 << 4)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_TYPE_USERDEF (1 << 5)
 #define DRM_MODE_TYPE_DRIVER (1 << 6)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_PHSYNC (1 << 0)
 #define DRM_MODE_FLAG_NHSYNC (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_PVSYNC (1 << 2)
 #define DRM_MODE_FLAG_NVSYNC (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_INTERLACE (1 << 4)
 #define DRM_MODE_FLAG_DBLSCAN (1 << 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_CSYNC (1 << 6)
 #define DRM_MODE_FLAG_PCSYNC (1 << 7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_NCSYNC (1 << 8)
 #define DRM_MODE_FLAG_HSKEW (1 << 9)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_BCAST (1 << 10)
 #define DRM_MODE_FLAG_PIXMUX (1 << 11)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_DBLCLK (1 << 12)
 #define DRM_MODE_FLAG_CLKDIV2 (1 << 13)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_3D_MASK (0x1f << 14)
 #define DRM_MODE_FLAG_3D_NONE (0 << 14)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_3D_FRAME_PACKING (1 << 14)
 #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2 << 14)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3 << 14)
 #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4 << 14)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_3D_L_DEPTH (5 << 14)
 #define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6 << 14)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7 << 14)
 #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8 << 14)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_DPMS_ON 0
 #define DRM_MODE_DPMS_STANDBY 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_DPMS_SUSPEND 2
 #define DRM_MODE_DPMS_OFF 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_SCALE_NONE 0
 #define DRM_MODE_SCALE_FULLSCREEN 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_SCALE_CENTER 2
 #define DRM_MODE_SCALE_ASPECT 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_PICTURE_ASPECT_NONE 0
 #define DRM_MODE_PICTURE_ASPECT_4_3 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_PICTURE_ASPECT_16_9 2
 #define DRM_MODE_DITHERING_OFF 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_DITHERING_ON 1
 #define DRM_MODE_DITHERING_AUTO 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_DIRTY_OFF 0
 #define DRM_MODE_DIRTY_ON 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_DIRTY_ANNOTATE 2
 struct drm_mode_modeinfo {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 clock;
   __u16 hdisplay;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 hsync_start;
   __u16 hsync_end;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 htotal;
   __u16 hskew;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 vdisplay;
   __u16 vsync_start;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 vsync_end;
   __u16 vtotal;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 vscan;
   __u32 vrefresh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   __u32 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char name[DRM_DISPLAY_MODE_LEN];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_mode_card_res {
   __u64 fb_id_ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 crtc_id_ptr;
   __u64 connector_id_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 encoder_id_ptr;
   __u32 count_fbs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 count_crtcs;
   __u32 count_connectors;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 count_encoders;
   __u32 min_width;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 max_width;
   __u32 min_height;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 max_height;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_mode_crtc {
   __u64 set_connectors_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 count_connectors;
   __u32 crtc_id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 fb_id;
   __u32 x;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 y;
   __u32 gamma_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 mode_valid;
   struct drm_mode_modeinfo mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define DRM_MODE_PRESENT_TOP_FIELD (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_PRESENT_BOTTOM_FIELD (1 << 1)
 struct drm_mode_set_plane {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 plane_id;
   __u32 crtc_id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 fb_id;
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 crtc_x;
   __s32 crtc_y;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 crtc_w;
   __u32 crtc_h;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 src_x;
   __u32 src_y;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 src_h;
   __u32 src_w;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_mode_get_plane {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 plane_id;
   __u32 crtc_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 fb_id;
   __u32 possible_crtcs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 gamma_size;
   __u32 count_format_types;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 format_type_ptr;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_mode_get_plane_res {
   __u64 plane_id_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 count_planes;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_ENCODER_NONE 0
 #define DRM_MODE_ENCODER_DAC 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_ENCODER_TMDS 2
 #define DRM_MODE_ENCODER_LVDS 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_ENCODER_TVDAC 4
 #define DRM_MODE_ENCODER_VIRTUAL 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_ENCODER_DSI 6
 #define DRM_MODE_ENCODER_DPMST 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_MODE_ENCODER_DPI 8
 struct drm_mode_get_encoder {
   __u32 encoder_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 encoder_type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 crtc_id;
   __u32 possible_crtcs;
   __u32 possible_clones;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_SUBCONNECTOR_Automatic 0
 #define DRM_MODE_SUBCONNECTOR_Unknown 0
 #define DRM_MODE_SUBCONNECTOR_DVID 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_SUBCONNECTOR_DVIA 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_SUBCONNECTOR_Composite 5
 #define DRM_MODE_SUBCONNECTOR_SVIDEO 6
 #define DRM_MODE_SUBCONNECTOR_Component 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_SUBCONNECTOR_SCART 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_Unknown 0
 #define DRM_MODE_CONNECTOR_VGA 1
 #define DRM_MODE_CONNECTOR_DVII 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_DVID 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_DVIA 4
 #define DRM_MODE_CONNECTOR_Composite 5
 #define DRM_MODE_CONNECTOR_SVIDEO 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_LVDS 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_Component 8
 #define DRM_MODE_CONNECTOR_9PinDIN 9
 #define DRM_MODE_CONNECTOR_DisplayPort 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_HDMIA 11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_HDMIB 12
 #define DRM_MODE_CONNECTOR_TV 13
 #define DRM_MODE_CONNECTOR_eDP 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_VIRTUAL 15
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MODE_CONNECTOR_DSI 16
+#define DRM_MODE_CONNECTOR_DPI 17
 struct drm_mode_get_connector {
   __u64 encoders_ptr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -283,172 +288,197 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 connector_id;
 };
-struct drm_mode_obj_get_properties {
-  __u64 props_ptr;
+#define DRM_MODE_OBJECT_CRTC 0xcccccccc
+#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
+#define DRM_MODE_OBJECT_MODE 0xdededede
+#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
+#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
+#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
+#define DRM_MODE_OBJECT_ANY 0
+struct drm_mode_obj_get_properties {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 props_ptr;
   __u64 prop_values_ptr;
   __u32 count_props;
   __u32 obj_id;
-  __u32 obj_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 obj_type;
 };
 struct drm_mode_obj_set_property {
   __u64 value;
-  __u32 prop_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 prop_id;
   __u32 obj_id;
   __u32 obj_type;
 };
-struct drm_mode_get_blob {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_mode_get_blob {
   __u32 blob_id;
   __u32 length;
   __u64 data;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_mode_fb_cmd {
   __u32 fb_id;
   __u32 width;
-  __u32 height;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 height;
   __u32 pitch;
   __u32 bpp;
   __u32 depth;
-  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
 };
 #define DRM_MODE_FB_INTERLACED (1 << 0)
 #define DRM_MODE_FB_MODIFIERS (1 << 1)
-struct drm_mode_fb_cmd2 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_mode_fb_cmd2 {
   __u32 fb_id;
   __u32 width;
   __u32 height;
-  __u32 pixel_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pixel_format;
   __u32 flags;
   __u32 handles[4];
   __u32 pitches[4];
-  __u32 offsets[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offsets[4];
   __u64 modifier[4];
 };
 #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
-#define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
 #define DRM_MODE_FB_DIRTY_FLAGS 0x03
 #define DRM_MODE_FB_DIRTY_MAX_CLIPS 256
 struct drm_mode_fb_dirty_cmd {
-  __u32 fb_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 fb_id;
   __u32 flags;
   __u32 color;
   __u32 num_clips;
-  __u64 clips_ptr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 clips_ptr;
 };
 struct drm_mode_mode_cmd {
   __u32 connector_id;
-  struct drm_mode_modeinfo mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct drm_mode_modeinfo mode;
 };
 #define DRM_MODE_CURSOR_BO 0x01
 #define DRM_MODE_CURSOR_MOVE 0x02
-#define DRM_MODE_CURSOR_FLAGS 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_MODE_CURSOR_FLAGS 0x03
 struct drm_mode_cursor {
   __u32 flags;
   __u32 crtc_id;
-  __s32 x;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 x;
   __s32 y;
   __u32 width;
   __u32 height;
-  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
 };
 struct drm_mode_cursor2 {
   __u32 flags;
-  __u32 crtc_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 crtc_id;
   __s32 x;
   __s32 y;
   __u32 width;
-  __u32 height;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 height;
   __u32 handle;
   __s32 hot_x;
   __s32 hot_y;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_mode_crtc_lut {
   __u32 crtc_id;
   __u32 gamma_size;
-  __u64 red;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 red;
   __u64 green;
   __u64 blue;
 };
-#define DRM_MODE_PAGE_FLIP_EVENT 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_color_ctm {
+  __s64 matrix[9];
+};
+struct drm_color_lut {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 red;
+  __u16 green;
+  __u16 blue;
+  __u16 reserved;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define DRM_MODE_PAGE_FLIP_EVENT 0x01
 #define DRM_MODE_PAGE_FLIP_ASYNC 0x02
 #define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_PAGE_FLIP_ASYNC)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_mode_crtc_page_flip {
   __u32 crtc_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 fb_id;
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved;
   __u64 user_data;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_mode_create_dumb {
-  uint32_t height;
-  uint32_t width;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t bpp;
-  uint32_t flags;
-  uint32_t handle;
-  uint32_t pitch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t size;
-};
-struct drm_mode_map_dumb {
-  __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 pad;
-  __u64 offset;
-};
-struct drm_mode_destroy_dumb {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t handle;
-};
-#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
-#define DRM_MODE_ATOMIC_NONBLOCK 0x0200
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
-#define DRM_MODE_ATOMIC_FLAGS (DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_PAGE_FLIP_ASYNC | DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_ATOMIC_ALLOW_MODESET)
-struct drm_mode_atomic {
+  __u32 height;
+  __u32 width;
+  __u32 bpp;
   __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 pitch;
+  __u64 size;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_mode_map_dumb {
+  __u32 handle;
+  __u32 pad;
+  __u64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct drm_mode_destroy_dumb {
+  __u32 handle;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
+#define DRM_MODE_ATOMIC_NONBLOCK 0x0200
+#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
+#define DRM_MODE_ATOMIC_FLAGS (DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_PAGE_FLIP_ASYNC | DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_ATOMIC_ALLOW_MODESET)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_mode_atomic {
+  __u32 flags;
   __u32 count_objs;
   __u64 objs_ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 count_props_ptr;
   __u64 props_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 prop_values_ptr;
   __u64 reserved;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 user_data;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_mode_create_blob {
   __u64 data;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 length;
   __u32 blob_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_mode_destroy_blob {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 blob_id;
 };
+#ifdef __cplusplus
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/drm/drm_sarea.h b/libc/kernel/uapi/drm/drm_sarea.h
index ca19c2b..a4a74af 100644
--- a/libc/kernel/uapi/drm/drm_sarea.h
+++ b/libc/kernel/uapi/drm/drm_sarea.h
@@ -18,46 +18,51 @@
  ****************************************************************************/
 #ifndef _DRM_SAREA_H_
 #define _DRM_SAREA_H_
-#include <drm/drm.h>
-#ifdef __alpha__
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifdef __alpha__
 #define SAREA_MAX 0x2000U
 #elif defined(__mips__)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAREA_MAX 0x4000U
 #elif defined(__ia64__)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAREA_MAX 0x10000U
 #else
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAREA_MAX 0x2000U
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAREA_MAX_DRAWABLES 256
 #define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_sarea_drawable {
   unsigned int stamp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int flags;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_sarea_frame {
   unsigned int x;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int y;
   unsigned int width;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int height;
   unsigned int fullscreen;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_sarea {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_hw_lock lock;
   struct drm_hw_lock drawable_lock;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_sarea_drawable drawableTable[SAREA_MAX_DRAWABLES];
   struct drm_sarea_frame frame;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_context_t dummy_context;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_sarea_drawable drm_sarea_drawable_t;
 typedef struct drm_sarea_frame drm_sarea_frame_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_sarea drm_sarea_t;
+#ifdef __cplusplus
+#endif
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/drm/etnaviv_drm.h b/libc/kernel/uapi/drm/etnaviv_drm.h
new file mode 100644
index 0000000..1a5ffb5
--- /dev/null
+++ b/libc/kernel/uapi/drm/etnaviv_drm.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ETNAVIV_DRM_H__
+#define __ETNAVIV_DRM_H__
+#include "drm.h"
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+struct drm_etnaviv_timespec {
+  __s64 tv_sec;
+  __s64 tv_nsec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define ETNAVIV_PARAM_GPU_MODEL 0x01
+#define ETNAVIV_PARAM_GPU_REVISION 0x02
+#define ETNAVIV_PARAM_GPU_FEATURES_0 0x03
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNAVIV_PARAM_GPU_FEATURES_1 0x04
+#define ETNAVIV_PARAM_GPU_FEATURES_2 0x05
+#define ETNAVIV_PARAM_GPU_FEATURES_3 0x06
+#define ETNAVIV_PARAM_GPU_FEATURES_4 0x07
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNAVIV_PARAM_GPU_FEATURES_5 0x08
+#define ETNAVIV_PARAM_GPU_FEATURES_6 0x09
+#define ETNAVIV_PARAM_GPU_STREAM_COUNT 0x10
+#define ETNAVIV_PARAM_GPU_REGISTER_MAX 0x11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNAVIV_PARAM_GPU_THREAD_COUNT 0x12
+#define ETNAVIV_PARAM_GPU_VERTEX_CACHE_SIZE 0x13
+#define ETNAVIV_PARAM_GPU_SHADER_CORE_COUNT 0x14
+#define ETNAVIV_PARAM_GPU_PIXEL_PIPES 0x15
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNAVIV_PARAM_GPU_VERTEX_OUTPUT_BUFFER_SIZE 0x16
+#define ETNAVIV_PARAM_GPU_BUFFER_SIZE 0x17
+#define ETNAVIV_PARAM_GPU_INSTRUCTION_COUNT 0x18
+#define ETNAVIV_PARAM_GPU_NUM_CONSTANTS 0x19
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNAVIV_PARAM_GPU_NUM_VARYINGS 0x1a
+#define ETNA_MAX_PIPES 4
+struct drm_etnaviv_param {
+  __u32 pipe;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 param;
+  __u64 value;
+};
+#define ETNA_BO_CACHE_MASK 0x000f0000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNA_BO_CACHED 0x00010000
+#define ETNA_BO_WC 0x00020000
+#define ETNA_BO_UNCACHED 0x00040000
+#define ETNA_BO_FORCE_MMU 0x00100000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_etnaviv_gem_new {
+  __u64 size;
+  __u32 flags;
+  __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct drm_etnaviv_gem_info {
+  __u32 handle;
+  __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 offset;
+};
+#define ETNA_PREP_READ 0x01
+#define ETNA_PREP_WRITE 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNA_PREP_NOSYNC 0x04
+struct drm_etnaviv_gem_cpu_prep {
+  __u32 handle;
+  __u32 op;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct drm_etnaviv_timespec timeout;
+};
+struct drm_etnaviv_gem_cpu_fini {
+  __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
+};
+struct drm_etnaviv_gem_submit_reloc {
+  __u32 submit_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reloc_idx;
+  __u64 reloc_offset;
+  __u32 flags;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNA_SUBMIT_BO_READ 0x0001
+#define ETNA_SUBMIT_BO_WRITE 0x0002
+struct drm_etnaviv_gem_submit_bo {
+  __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u64 presumed;
+};
+#define ETNA_PIPE_3D 0x00
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETNA_PIPE_2D 0x01
+#define ETNA_PIPE_VG 0x02
+struct drm_etnaviv_gem_submit {
+  __u32 fence;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pipe;
+  __u32 exec_state;
+  __u32 nr_bos;
+  __u32 nr_relocs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 stream_size;
+  __u64 bos;
+  __u64 relocs;
+  __u64 stream;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define ETNA_WAIT_NONBLOCK 0x01
+struct drm_etnaviv_wait_fence {
+  __u32 pipe;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 fence;
+  __u32 flags;
+  __u32 pad;
+  struct drm_etnaviv_timespec timeout;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define ETNA_USERPTR_READ 0x01
+#define ETNA_USERPTR_WRITE 0x02
+struct drm_etnaviv_gem_userptr {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 user_ptr;
+  __u64 user_size;
+  __u32 flags;
+  __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct drm_etnaviv_gem_wait {
+  __u32 pipe;
+  __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
+  __u32 pad;
+  struct drm_etnaviv_timespec timeout;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_ETNAVIV_GET_PARAM 0x00
+#define DRM_ETNAVIV_GEM_NEW 0x02
+#define DRM_ETNAVIV_GEM_INFO 0x03
+#define DRM_ETNAVIV_GEM_CPU_PREP 0x04
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_ETNAVIV_GEM_CPU_FINI 0x05
+#define DRM_ETNAVIV_GEM_SUBMIT 0x06
+#define DRM_ETNAVIV_WAIT_FENCE 0x07
+#define DRM_ETNAVIV_GEM_USERPTR 0x08
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_ETNAVIV_GEM_WAIT 0x09
+#define DRM_ETNAVIV_NUM_IOCTLS 0x0a
+#define DRM_IOCTL_ETNAVIV_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_ETNAVIV_GET_PARAM, struct drm_etnaviv_param)
+#define DRM_IOCTL_ETNAVIV_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_ETNAVIV_GEM_NEW, struct drm_etnaviv_gem_new)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_ETNAVIV_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_ETNAVIV_GEM_INFO, struct drm_etnaviv_gem_info)
+#define DRM_IOCTL_ETNAVIV_GEM_CPU_PREP DRM_IOW(DRM_COMMAND_BASE + DRM_ETNAVIV_GEM_CPU_PREP, struct drm_etnaviv_gem_cpu_prep)
+#define DRM_IOCTL_ETNAVIV_GEM_CPU_FINI DRM_IOW(DRM_COMMAND_BASE + DRM_ETNAVIV_GEM_CPU_FINI, struct drm_etnaviv_gem_cpu_fini)
+#define DRM_IOCTL_ETNAVIV_GEM_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_ETNAVIV_GEM_SUBMIT, struct drm_etnaviv_gem_submit)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_ETNAVIV_WAIT_FENCE DRM_IOW(DRM_COMMAND_BASE + DRM_ETNAVIV_WAIT_FENCE, struct drm_etnaviv_wait_fence)
+#define DRM_IOCTL_ETNAVIV_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_ETNAVIV_GEM_USERPTR, struct drm_etnaviv_gem_userptr)
+#define DRM_IOCTL_ETNAVIV_GEM_WAIT DRM_IOW(DRM_COMMAND_BASE + DRM_ETNAVIV_GEM_WAIT, struct drm_etnaviv_gem_wait)
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#endif
diff --git a/libc/kernel/uapi/drm/exynos_drm.h b/libc/kernel/uapi/drm/exynos_drm.h
index 47294b7..a03069b 100644
--- a/libc/kernel/uapi/drm/exynos_drm.h
+++ b/libc/kernel/uapi/drm/exynos_drm.h
@@ -18,197 +18,207 @@
  ****************************************************************************/
 #ifndef _UAPI_EXYNOS_DRM_H_
 #define _UAPI_EXYNOS_DRM_H_
-#include <drm/drm.h>
+#include "drm.h"
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 struct drm_exynos_gem_create {
+  __u64 size;
+  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t size;
-  unsigned int flags;
-  unsigned int handle;
+  __u32 handle;
 };
+struct drm_exynos_gem_map {
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved;
+  __u64 offset;
+};
 struct drm_exynos_gem_info {
-  unsigned int handle;
-  unsigned int flags;
-  uint64_t size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 flags;
+  __u64 size;
 };
-struct drm_exynos_vidi_connection {
-  unsigned int connection;
-  unsigned int extensions;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t edid;
+struct drm_exynos_vidi_connection {
+  __u32 connection;
+  __u32 extensions;
+  __u64 edid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum e_drm_exynos_gem_mem_type {
   EXYNOS_BO_CONTIG = 0 << 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_BO_NONCONTIG = 1 << 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_BO_NONCACHABLE = 0 << 1,
   EXYNOS_BO_CACHABLE = 1 << 1,
   EXYNOS_BO_WC = 1 << 2,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_BO_MASK = EXYNOS_BO_NONCONTIG | EXYNOS_BO_CACHABLE | EXYNOS_BO_WC
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_g2d_get_ver {
   __u32 major;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 minor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_g2d_cmd {
   __u32 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 data;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum drm_exynos_g2d_buf_type {
   G2D_BUF_USERPTR = 1 << 31,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_exynos_g2d_event_type {
   G2D_EVENT_NOT,
   G2D_EVENT_NONSTOP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   G2D_EVENT_STOP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_g2d_userptr {
   unsigned long userptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_g2d_set_cmdlist {
   __u64 cmd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 cmd_buf;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd_nr;
   __u32 cmd_buf_nr;
   __u64 event_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 user_data;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_g2d_exec {
   __u64 async;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_exynos_ops_id {
   EXYNOS_DRM_OPS_SRC,
   EXYNOS_DRM_OPS_DST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_DRM_OPS_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_sz {
   __u32 hsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vsize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_pos {
   __u32 x;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 y;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 w;
   __u32 h;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_exynos_flip {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_DRM_FLIP_NONE = (0 << 0),
   EXYNOS_DRM_FLIP_VERTICAL = (1 << 0),
   EXYNOS_DRM_FLIP_HORIZONTAL = (1 << 1),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_DRM_FLIP_BOTH = EXYNOS_DRM_FLIP_VERTICAL | EXYNOS_DRM_FLIP_HORIZONTAL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum drm_exynos_degree {
   EXYNOS_DRM_DEGREE_0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_DRM_DEGREE_90,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_DRM_DEGREE_180,
   EXYNOS_DRM_DEGREE_270,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_exynos_planer {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_DRM_PLANAR_Y,
   EXYNOS_DRM_PLANAR_CB,
   EXYNOS_DRM_PLANAR_CR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXYNOS_DRM_PLANAR_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_ipp_prop_list {
   __u32 version;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 ipp_id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 count;
   __u32 writeback;
   __u32 flip;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 degree;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 csc;
   __u32 crop;
   __u32 scale;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 refresh_min;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 refresh_max;
   __u32 reserved;
   struct drm_exynos_sz crop_min;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_exynos_sz crop_max;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_exynos_sz scale_min;
   struct drm_exynos_sz scale_max;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_exynos_ipp_config {
-  enum drm_exynos_ops_id ops_id;
-  enum drm_exynos_flip flip;
-  enum drm_exynos_degree degree;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ops_id;
+  __u32 flip;
+  __u32 degree;
   __u32 fmt;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_exynos_sz sz;
   struct drm_exynos_pos pos;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_exynos_ipp_cmd {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IPP_CMD_NONE,
   IPP_CMD_M2M,
   IPP_CMD_WB,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IPP_CMD_OUTPUT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IPP_CMD_MAX,
 };
 struct drm_exynos_ipp_property {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX];
-  enum drm_exynos_ipp_cmd cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 cmd;
   __u32 ipp_id;
   __u32 prop_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 refresh_rate;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum drm_exynos_ipp_buf_type {
   IPP_BUF_ENQUEUE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IPP_BUF_DEQUEUE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_ipp_queue_buf {
-  enum drm_exynos_ops_id ops_id;
+  __u32 ops_id;
+  __u32 buf_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  enum drm_exynos_ipp_buf_type buf_type;
   __u32 prop_id;
   __u32 buf_id;
   __u32 handle[EXYNOS_DRM_PLANAR_MAX];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 user_data;
 };
 enum drm_exynos_ipp_ctrl {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IPP_CTRL_PLAY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IPP_CTRL_STOP,
   IPP_CTRL_PAUSE,
   IPP_CTRL_RESUME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IPP_CTRL_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_exynos_ipp_cmd_ctrl {
   __u32 prop_id;
+  __u32 ctrl;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  enum drm_exynos_ipp_ctrl ctrl;
 };
 #define DRM_EXYNOS_GEM_CREATE 0x00
+#define DRM_EXYNOS_GEM_MAP 0x01
 #define DRM_EXYNOS_GEM_GET 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_EXYNOS_VIDI_CONNECTION 0x07
@@ -222,39 +232,43 @@
 #define DRM_EXYNOS_IPP_CMD_CTRL 0x33
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
+#define DRM_IOCTL_EXYNOS_GEM_MAP DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
 #define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info)
 #define DRM_IOCTL_EXYNOS_VIDI_CONNECTION DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection)
-#define DRM_IOCTL_EXYNOS_G2D_GET_VER DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_G2D_GET_VER, struct drm_exynos_g2d_get_ver)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_EXYNOS_G2D_GET_VER DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_G2D_GET_VER, struct drm_exynos_g2d_get_ver)
 #define DRM_IOCTL_EXYNOS_G2D_SET_CMDLIST DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_G2D_SET_CMDLIST, struct drm_exynos_g2d_set_cmdlist)
 #define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
 #define DRM_IOCTL_EXYNOS_IPP_GET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_IPP_GET_PROPERTY, struct drm_exynos_ipp_prop_list)
-#define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property)
 #define DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_IPP_QUEUE_BUF, struct drm_exynos_ipp_queue_buf)
 #define DRM_IOCTL_EXYNOS_IPP_CMD_CTRL DRM_IOWR(DRM_COMMAND_BASE + DRM_EXYNOS_IPP_CMD_CTRL, struct drm_exynos_ipp_cmd_ctrl)
 #define DRM_EXYNOS_G2D_EVENT 0x80000000
-#define DRM_EXYNOS_IPP_EVENT 0x80000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_EXYNOS_IPP_EVENT 0x80000001
 struct drm_exynos_g2d_event {
   struct drm_event base;
   __u64 user_data;
-  __u32 tv_sec;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 tv_sec;
   __u32 tv_usec;
   __u32 cmdlist_no;
   __u32 reserved;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_exynos_ipp_event {
   struct drm_event base;
   __u64 user_data;
-  __u32 tv_sec;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 tv_sec;
   __u32 tv_usec;
   __u32 prop_id;
   __u32 reserved;
-  __u32 buf_id[EXYNOS_DRM_OPS_MAX];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 buf_id[EXYNOS_DRM_OPS_MAX];
 };
+#ifdef __cplusplus
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/drm/i810_drm.h b/libc/kernel/uapi/drm/i810_drm.h
index 9292a80..ad2fdcf 100644
--- a/libc/kernel/uapi/drm/i810_drm.h
+++ b/libc/kernel/uapi/drm/i810_drm.h
@@ -18,246 +18,251 @@
  ****************************************************************************/
 #ifndef _I810_DRM_H_
 #define _I810_DRM_H_
-#include <drm/drm.h>
-#ifndef _I810_DEFINES_
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifndef _I810_DEFINES_
 #define _I810_DEFINES_
 #define I810_DMA_BUF_ORDER 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_DMA_BUF_SZ (1 << I810_DMA_BUF_ORDER)
 #define I810_DMA_BUF_NR 256
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_NR_SAREA_CLIPRECTS 8
 #define I810_NR_TEX_REGIONS 64
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_LOG_MIN_TEX_REGION_SIZE 16
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_UPLOAD_TEX0IMAGE 0x1
 #define I810_UPLOAD_TEX1IMAGE 0x2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_UPLOAD_CTX 0x4
 #define I810_UPLOAD_BUFFERS 0x8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_UPLOAD_TEX0 0x10
 #define I810_UPLOAD_TEX1 0x20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_UPLOAD_CLIPRECTS 0x40
 #define I810_DESTREG_DI0 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_DESTREG_DI1 1
 #define I810_DESTREG_DV0 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_DESTREG_DV1 3
 #define I810_DESTREG_DR0 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_DESTREG_DR1 5
 #define I810_DESTREG_DR2 6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_DESTREG_DR3 7
 #define I810_DESTREG_DR4 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_DEST_SETUP_SIZE 10
 #define I810_CTXREG_CF0 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_CF1 1
 #define I810_CTXREG_ST0 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_ST1 3
 #define I810_CTXREG_VF 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_MT 5
 #define I810_CTXREG_MC0 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_MC1 7
 #define I810_CTXREG_MC2 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_MA0 9
 #define I810_CTXREG_MA1 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_MA2 11
 #define I810_CTXREG_SDM 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_FOG 13
 #define I810_CTXREG_B1 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_B2 15
 #define I810_CTXREG_LCS 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_PV 17
 #define I810_CTXREG_ZA 18
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_CTXREG_AA 19
 #define I810_CTX_SETUP_SIZE 20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_TEXREG_MI0 0
 #define I810_TEXREG_MI1 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_TEXREG_MI2 2
 #define I810_TEXREG_MI3 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_TEXREG_MF 4
 #define I810_TEXREG_MLC 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_TEXREG_MLL 6
 #define I810_TEXREG_MCS 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_TEX_SETUP_SIZE 8
 #define I810_FRONT 0x1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I810_BACK 0x2
 #define I810_DEPTH 0x4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef enum _drm_i810_init_func {
   I810_INIT_DMA = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   I810_CLEANUP_DMA = 0x02,
   I810_INIT_DMA_1_4 = 0x03
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i810_init_func_t;
 typedef struct _drm_i810_init {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_i810_init_func_t func;
   unsigned int mmio_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int buffers_offset;
   int sarea_priv_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int ring_start;
   unsigned int ring_end;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int ring_size;
   unsigned int front_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int back_offset;
   unsigned int depth_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int overlay_offset;
   unsigned int overlay_physical;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int w;
   unsigned int h;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pitch;
   unsigned int pitch_bits;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i810_init_t;
 typedef struct _drm_i810_pre12_init {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_i810_init_func_t func;
   unsigned int mmio_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int buffers_offset;
   int sarea_priv_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int ring_start;
   unsigned int ring_end;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int ring_size;
   unsigned int front_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int back_offset;
   unsigned int depth_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int w;
   unsigned int h;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pitch;
   unsigned int pitch_bits;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i810_pre12_init_t;
 typedef struct _drm_i810_tex_region {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char next, prev;
   unsigned char in_use;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int age;
 } drm_i810_tex_region_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct _drm_i810_sarea {
   unsigned int ContextState[I810_CTX_SETUP_SIZE];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int BufferState[I810_DEST_SETUP_SIZE];
   unsigned int TexState[2][I810_TEX_SETUP_SIZE];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dirty;
   unsigned int nbox;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_clip_rect boxes[I810_NR_SAREA_CLIPRECTS];
   drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS + 1];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int texAge;
   int last_enqueue;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int last_dispatch;
   int last_quiescent;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int ctxOwner;
   int vertex_prim;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pf_enabled;
   int pf_active;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pf_current_page;
 } drm_i810_sarea_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_INIT 0x00
 #define DRM_I810_VERTEX 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_CLEAR 0x02
 #define DRM_I810_FLUSH 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_GETAGE 0x04
 #define DRM_I810_GETBUF 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_SWAP 0x06
 #define DRM_I810_COPY 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_DOCOPY 0x08
 #define DRM_I810_OV0INFO 0x09
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_FSTATUS 0x0a
 #define DRM_I810_OV0FLIP 0x0b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_MC 0x0c
 #define DRM_I810_RSTATUS 0x0d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I810_FLIP 0x0e
 #define DRM_IOCTL_I810_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I810_INIT, drm_i810_init_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I810_VERTEX DRM_IOW(DRM_COMMAND_BASE + DRM_I810_VERTEX, drm_i810_vertex_t)
 #define DRM_IOCTL_I810_CLEAR DRM_IOW(DRM_COMMAND_BASE + DRM_I810_CLEAR, drm_i810_clear_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I810_FLUSH DRM_IO(DRM_COMMAND_BASE + DRM_I810_FLUSH)
 #define DRM_IOCTL_I810_GETAGE DRM_IO(DRM_COMMAND_BASE + DRM_I810_GETAGE)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I810_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_I810_GETBUF, drm_i810_dma_t)
 #define DRM_IOCTL_I810_SWAP DRM_IO(DRM_COMMAND_BASE + DRM_I810_SWAP)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I810_COPY DRM_IOW(DRM_COMMAND_BASE + DRM_I810_COPY, drm_i810_copy_t)
 #define DRM_IOCTL_I810_DOCOPY DRM_IO(DRM_COMMAND_BASE + DRM_I810_DOCOPY)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I810_OV0INFO DRM_IOR(DRM_COMMAND_BASE + DRM_I810_OV0INFO, drm_i810_overlay_t)
 #define DRM_IOCTL_I810_FSTATUS DRM_IO(DRM_COMMAND_BASE + DRM_I810_FSTATUS)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I810_OV0FLIP DRM_IO(DRM_COMMAND_BASE + DRM_I810_OV0FLIP)
 #define DRM_IOCTL_I810_MC DRM_IOW(DRM_COMMAND_BASE + DRM_I810_MC, drm_i810_mc_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I810_RSTATUS DRM_IO(DRM_COMMAND_BASE + DRM_I810_RSTATUS)
 #define DRM_IOCTL_I810_FLIP DRM_IO(DRM_COMMAND_BASE + DRM_I810_FLIP)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct _drm_i810_clear {
   int clear_color;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int clear_depth;
   int flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i810_clear_t;
 typedef struct _drm_i810_vertex {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int used;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int discard;
 } drm_i810_vertex_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct _drm_i810_copy_t {
   int idx;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int used;
   void * address;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i810_copy_t;
 #define PR_TRIANGLES (0x0 << 18)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_TRISTRIP_0 (0x1 << 18)
 #define PR_TRISTRIP_1 (0x2 << 18)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_TRIFAN (0x3 << 18)
 #define PR_POLYGON (0x4 << 18)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_LINES (0x5 << 18)
 #define PR_LINESTRIP (0x6 << 18)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PR_RECTS (0x7 << 18)
 #define PR_MASK (0x7 << 18)
-typedef struct drm_i810_dma {
-  void * virtual;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct drm_i810_dma {
+  void * __linux_virtual;
   int request_idx;
   int request_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int granted;
 } drm_i810_dma_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct _drm_i810_overlay_t {
   unsigned int offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int physical;
 } drm_i810_overlay_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct _drm_i810_mc {
   int idx;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int used;
   int num_blocks;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int * length;
   unsigned int last_render;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i810_mc_t;
+#ifdef __cplusplus
+#endif
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/drm/i915_drm.h b/libc/kernel/uapi/drm/i915_drm.h
index da68576..3fb8c56 100644
--- a/libc/kernel/uapi/drm/i915_drm.h
+++ b/libc/kernel/uapi/drm/i915_drm.h
@@ -18,490 +18,495 @@
  ****************************************************************************/
 #ifndef _UAPI_I915_DRM_H_
 #define _UAPI_I915_DRM_H_
-#include <drm/drm.h>
-#define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR"
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR"
 #define I915_ERROR_UEVENT "ERROR"
 #define I915_RESET_UEVENT "RESET"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_NR_TEX_REGIONS 255
 #define I915_LOG_MIN_TEX_REGION_SIZE 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct _drm_i915_init {
   enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     I915_INIT_DMA = 0x01,
     I915_CLEANUP_DMA = 0x02,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     I915_RESUME_DMA = 0x03
   } func;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int mmio_offset;
   int sarea_priv_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int ring_start;
   unsigned int ring_end;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int ring_size;
   unsigned int front_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int back_offset;
   unsigned int depth_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int w;
   unsigned int h;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pitch;
   unsigned int pitch_bits;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int back_pitch;
   unsigned int depth_pitch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int cpp;
   unsigned int chipset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_init_t;
 typedef struct _drm_i915_sarea {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_tex_region texList[I915_NR_TEX_REGIONS + 1];
   int last_upload;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int last_enqueue;
   int last_dispatch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int ctxOwner;
   int texAge;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pf_enabled;
   int pf_active;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pf_current_page;
   int perf_boxes;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int width, height;
   drm_handle_t front_handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int front_offset;
   int front_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_handle_t back_handle;
   int back_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int back_size;
   drm_handle_t depth_handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int depth_offset;
   int depth_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_handle_t tex_handle;
   int tex_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int tex_size;
   int log_tex_granularity;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pitch;
   int rotation;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int rotated_offset;
   int rotated_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int rotated_pitch;
   int virtualX, virtualY;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int front_tiled;
   unsigned int back_tiled;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int depth_tiled;
   unsigned int rotated_tiled;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int rotated2_tiled;
   int pipeA_x;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pipeA_y;
   int pipeA_w;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pipeA_h;
   int pipeB_x;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pipeB_y;
   int pipeB_w;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pipeB_h;
   drm_handle_t unused_handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 unused1, unused2, unused3;
   __u32 front_bo_handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 back_bo_handle;
   __u32 unused_bo_handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 depth_bo_handle;
 } drm_i915_sarea_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define planeA_x pipeA_x
 #define planeA_y pipeA_y
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define planeA_w pipeA_w
 #define planeA_h pipeA_h
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define planeB_x pipeB_x
 #define planeB_y pipeB_y
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define planeB_w pipeB_w
 #define planeB_h pipeB_h
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_BOX_RING_EMPTY 0x1
 #define I915_BOX_FLIP 0x2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_BOX_WAIT 0x4
 #define I915_BOX_TEXTURE_LOAD 0x8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_BOX_LOST_CONTEXT 0x10
 #define DRM_I915_INIT 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_FLUSH 0x01
 #define DRM_I915_FLIP 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_BATCHBUFFER 0x03
 #define DRM_I915_IRQ_EMIT 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_IRQ_WAIT 0x05
 #define DRM_I915_GETPARAM 0x06
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_SETPARAM 0x07
 #define DRM_I915_ALLOC 0x08
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_FREE 0x09
 #define DRM_I915_INIT_HEAP 0x0a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_CMDBUFFER 0x0b
 #define DRM_I915_DESTROY_HEAP 0x0c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_SET_VBLANK_PIPE 0x0d
 #define DRM_I915_GET_VBLANK_PIPE 0x0e
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_VBLANK_SWAP 0x0f
 #define DRM_I915_HWS_ADDR 0x11
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_INIT 0x13
 #define DRM_I915_GEM_EXECBUFFER 0x14
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_PIN 0x15
 #define DRM_I915_GEM_UNPIN 0x16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_BUSY 0x17
 #define DRM_I915_GEM_THROTTLE 0x18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_ENTERVT 0x19
 #define DRM_I915_GEM_LEAVEVT 0x1a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_CREATE 0x1b
 #define DRM_I915_GEM_PREAD 0x1c
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_PWRITE 0x1d
 #define DRM_I915_GEM_MMAP 0x1e
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_SET_DOMAIN 0x1f
 #define DRM_I915_GEM_SW_FINISH 0x20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_SET_TILING 0x21
 #define DRM_I915_GEM_GET_TILING 0x22
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_GET_APERTURE 0x23
 #define DRM_I915_GEM_MMAP_GTT 0x24
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GET_PIPE_FROM_CRTC_ID 0x25
 #define DRM_I915_GEM_MADVISE 0x26
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_OVERLAY_PUT_IMAGE 0x27
 #define DRM_I915_OVERLAY_ATTRS 0x28
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_EXECBUFFER2 0x29
 #define DRM_I915_GET_SPRITE_COLORKEY 0x2a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_SET_SPRITE_COLORKEY 0x2b
 #define DRM_I915_GEM_WAIT 0x2c
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_CONTEXT_CREATE 0x2d
 #define DRM_I915_GEM_CONTEXT_DESTROY 0x2e
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_SET_CACHING 0x2f
 #define DRM_I915_GEM_GET_CACHING 0x30
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_REG_READ 0x31
 #define DRM_I915_GET_RESET_STATS 0x32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_USERPTR 0x33
 #define DRM_I915_GEM_CONTEXT_GETPARAM 0x34
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_GEM_CONTEXT_SETPARAM 0x35
 #define DRM_IOCTL_I915_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_FLUSH DRM_IO(DRM_COMMAND_BASE + DRM_I915_FLUSH)
 #define DRM_IOCTL_I915_FLIP DRM_IO(DRM_COMMAND_BASE + DRM_I915_FLIP)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
 #define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
 #define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_SETPARAM DRM_IOW(DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
 #define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_FREE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
 #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW(DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
 #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW(DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
 #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR(DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
 #define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
 #define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
 #define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
 #define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching)
 #define DRM_IOCTL_I915_GEM_GET_CACHING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_THROTTLE DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE)
 #define DRM_IOCTL_I915_GEM_ENTERVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_LEAVEVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT)
 #define DRM_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_PREAD DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)
 #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)
 #define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)
 #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
 #define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
 #define DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_PIPE_FROM_CRTC_ID, struct drm_i915_get_pipe_from_crtc_id)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
 #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
 #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
 #define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
 #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_REG_READ DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
 #define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
 #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
 typedef struct drm_i915_batchbuffer {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int start;
   int used;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int DR1;
   int DR4;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int num_cliprects;
   struct drm_clip_rect __user * cliprects;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_batchbuffer_t;
 typedef struct _drm_i915_cmdbuffer {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char __user * buf;
   int sz;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int DR1;
   int DR4;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int num_cliprects;
   struct drm_clip_rect __user * cliprects;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_cmdbuffer_t;
 typedef struct drm_i915_irq_emit {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int __user * irq_seq;
 } drm_i915_irq_emit_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_i915_irq_wait {
   int irq_seq;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_irq_wait_t;
 #define I915_PARAM_IRQ_ACTIVE 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_ALLOW_BATCHBUFFER 2
 #define I915_PARAM_LAST_DISPATCH 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_CHIPSET_ID 4
 #define I915_PARAM_HAS_GEM 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_NUM_FENCES_AVAIL 6
 #define I915_PARAM_HAS_OVERLAY 7
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_PAGEFLIPPING 8
 #define I915_PARAM_HAS_EXECBUF2 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_BSD 10
 #define I915_PARAM_HAS_BLT 11
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_RELAXED_FENCING 12
 #define I915_PARAM_HAS_COHERENT_RINGS 13
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_EXEC_CONSTANTS 14
 #define I915_PARAM_HAS_RELAXED_DELTA 15
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_GEN7_SOL_RESET 16
 #define I915_PARAM_HAS_LLC 17
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_ALIASING_PPGTT 18
 #define I915_PARAM_HAS_WAIT_TIMEOUT 19
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_SEMAPHORES 20
 #define I915_PARAM_HAS_PRIME_VMAP_FLUSH 21
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_VEBOX 22
 #define I915_PARAM_HAS_SECURE_BATCHES 23
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_PINNED_BATCHES 24
 #define I915_PARAM_HAS_EXEC_NO_RELOC 25
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
 #define I915_PARAM_HAS_WT 27
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_CMD_PARSER_VERSION 28
 #define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_MMAP_VERSION 30
 #define I915_PARAM_HAS_BSD2 31
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_REVISION 32
 #define I915_PARAM_SUBSLICE_TOTAL 33
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_EU_TOTAL 34
 #define I915_PARAM_HAS_GPU_RESET 35
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_PARAM_HAS_RESOURCE_STREAMER 36
+#define I915_PARAM_HAS_EXEC_SOFTPIN 37
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_i915_getparam {
   __s32 param;
   int __user * value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_getparam_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
 #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
 #define I915_SETPARAM_ALLOW_BATCHBUFFER 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_SETPARAM_NUM_USED_FENCES 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_i915_setparam {
   int param;
   int value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_setparam_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_MEM_REGION_AGP 1
 typedef struct drm_i915_mem_alloc {
   int region;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int alignment;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int size;
   int __user * region_offset;
 } drm_i915_mem_alloc_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_i915_mem_free {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int region;
   int region_offset;
 } drm_i915_mem_free_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_i915_mem_init_heap {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int region;
   int size;
   int start;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_mem_init_heap_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_i915_mem_destroy_heap {
   int region;
 } drm_i915_mem_destroy_heap_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_VBLANK_PIPE_A 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_I915_VBLANK_PIPE_B 2
 typedef struct drm_i915_vblank_pipe {
   int pipe;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_vblank_pipe_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_i915_vblank_swap {
   drm_drawable_t drawable;
   enum drm_vblank_seq_type seqtype;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int sequence;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_vblank_swap_t;
 typedef struct drm_i915_hws_addr {
   __u64 addr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_i915_hws_addr_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_i915_gem_init {
   __u64 gtt_start;
   __u64 gtt_end;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_i915_gem_create {
   __u64 size;
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_i915_gem_pread {
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 offset;
   __u64 size;
   __u64 data_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_i915_gem_pwrite {
   __u32 handle;
   __u32 pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 size;
   __u64 data_ptr;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_i915_gem_mmap {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
   __u32 pad;
   __u64 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 addr_ptr;
   __u64 flags;
 #define I915_MMAP_WC 0x1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_i915_gem_mmap_gtt {
   __u32 handle;
   __u32 pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_i915_gem_set_domain {
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 read_domains;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 write_domain;
 };
 struct drm_i915_gem_sw_finish {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_i915_gem_relocation_entry {
   __u32 target_handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 delta;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 offset;
   __u64 presumed_offset;
   __u32 read_domains;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 write_domain;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define I915_GEM_DOMAIN_CPU 0x00000001
 #define I915_GEM_DOMAIN_RENDER 0x00000002
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_GEM_DOMAIN_SAMPLER 0x00000004
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_GEM_DOMAIN_COMMAND 0x00000008
 #define I915_GEM_DOMAIN_INSTRUCTION 0x00000010
 #define I915_GEM_DOMAIN_VERTEX 0x00000020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_GEM_DOMAIN_GTT 0x00000040
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_i915_gem_exec_object {
   __u32 handle;
   __u32 relocation_count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 relocs_ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 alignment;
   __u64 offset;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_i915_gem_execbuffer {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 buffers_ptr;
   __u32 buffer_count;
   __u32 batch_start_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 batch_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 DR1;
   __u32 DR4;
   __u32 num_cliprects;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 cliprects_ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_i915_gem_exec_object2 {
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 relocation_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 relocs_ptr;
   __u64 alignment;
   __u64 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXEC_OBJECT_NEEDS_FENCE (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EXEC_OBJECT_NEEDS_GTT (1 << 1)
 #define EXEC_OBJECT_WRITE (1 << 2)
 #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1 << 3)
+#define EXEC_OBJECT_PINNED (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __EXEC_OBJECT_UNKNOWN_FLAGS - (EXEC_OBJECT_SUPPORTS_48B_ADDRESS << 1)
+#define __EXEC_OBJECT_UNKNOWN_FLAGS - (EXEC_OBJECT_PINNED << 1)
   __u64 flags;
   __u64 rsvd1;
   __u64 rsvd2;
@@ -542,220 +547,225 @@
 #define I915_EXEC_NO_RELOC (1 << 11)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define I915_EXEC_HANDLE_LUT (1 << 12)
-#define I915_EXEC_BSD_MASK (3 << 13)
-#define I915_EXEC_BSD_DEFAULT (0 << 13)
-#define I915_EXEC_BSD_RING1 (1 << 13)
+#define I915_EXEC_BSD_SHIFT (13)
+#define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)
+#define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I915_EXEC_BSD_RING2 (2 << 13)
+#define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)
+#define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)
 #define I915_EXEC_RESOURCE_STREAMER (1 << 15)
 #define __I915_EXEC_UNKNOWN_FLAGS - (I915_EXEC_RESOURCE_STREAMER << 1)
-#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
 #define i915_execbuffer2_set_context_id(eb2,context) (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
 #define i915_execbuffer2_get_context_id(eb2) ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
 struct drm_i915_gem_pin {
-  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
   __u32 pad;
   __u64 alignment;
   __u64 offset;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_i915_gem_unpin {
   __u32 handle;
   __u32 pad;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_i915_gem_busy {
   __u32 handle;
   __u32 busy;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define I915_CACHING_NONE 0
 #define I915_CACHING_CACHED 1
 #define I915_CACHING_DISPLAY 2
-struct drm_i915_gem_caching {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_i915_gem_caching {
   __u32 handle;
   __u32 caching;
 };
-#define I915_TILING_NONE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_TILING_NONE 0
 #define I915_TILING_X 1
 #define I915_TILING_Y 2
 #define I915_BIT_6_SWIZZLE_NONE 0
-#define I915_BIT_6_SWIZZLE_9 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_BIT_6_SWIZZLE_9 1
 #define I915_BIT_6_SWIZZLE_9_10 2
 #define I915_BIT_6_SWIZZLE_9_11 3
 #define I915_BIT_6_SWIZZLE_9_10_11 4
-#define I915_BIT_6_SWIZZLE_UNKNOWN 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_BIT_6_SWIZZLE_UNKNOWN 5
 #define I915_BIT_6_SWIZZLE_9_17 6
 #define I915_BIT_6_SWIZZLE_9_10_17 7
 struct drm_i915_gem_set_tiling {
-  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
   __u32 tiling_mode;
   __u32 stride;
   __u32 swizzle_mode;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_i915_gem_get_tiling {
   __u32 handle;
   __u32 tiling_mode;
-  __u32 swizzle_mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 swizzle_mode;
   __u32 phys_swizzle_mode;
 };
 struct drm_i915_gem_get_aperture {
-  __u64 aper_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 aper_size;
   __u64 aper_available_size;
 };
 struct drm_i915_get_pipe_from_crtc_id {
-  __u32 crtc_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 crtc_id;
   __u32 pipe;
 };
 #define I915_MADV_WILLNEED 0
-#define I915_MADV_DONTNEED 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_MADV_DONTNEED 1
 #define __I915_MADV_PURGED 2
 struct drm_i915_gem_madvise {
   __u32 handle;
-  __u32 madv;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 madv;
   __u32 retained;
 };
 #define I915_OVERLAY_TYPE_MASK 0xff
-#define I915_OVERLAY_YUV_PLANAR 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_OVERLAY_YUV_PLANAR 0x01
 #define I915_OVERLAY_YUV_PACKED 0x02
 #define I915_OVERLAY_RGB 0x03
 #define I915_OVERLAY_DEPTH_MASK 0xff00
-#define I915_OVERLAY_RGB24 0x1000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_OVERLAY_RGB24 0x1000
 #define I915_OVERLAY_RGB16 0x2000
 #define I915_OVERLAY_RGB15 0x3000
 #define I915_OVERLAY_YUV422 0x0100
-#define I915_OVERLAY_YUV411 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_OVERLAY_YUV411 0x0200
 #define I915_OVERLAY_YUV420 0x0300
 #define I915_OVERLAY_YUV410 0x0400
 #define I915_OVERLAY_SWAP_MASK 0xff0000
-#define I915_OVERLAY_NO_SWAP 0x000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_OVERLAY_NO_SWAP 0x000000
 #define I915_OVERLAY_UV_SWAP 0x010000
 #define I915_OVERLAY_Y_SWAP 0x020000
 #define I915_OVERLAY_Y_AND_UV_SWAP 0x030000
-#define I915_OVERLAY_FLAGS_MASK 0xff000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_OVERLAY_FLAGS_MASK 0xff000000
 #define I915_OVERLAY_ENABLE 0x01000000
 struct drm_intel_overlay_put_image {
   __u32 flags;
-  __u32 bo_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bo_handle;
   __u16 stride_Y;
   __u16 stride_UV;
   __u32 offset_Y;
-  __u32 offset_U;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offset_U;
   __u32 offset_V;
   __u16 src_width;
   __u16 src_height;
-  __u16 src_scan_width;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 src_scan_width;
   __u16 src_scan_height;
   __u32 crtc_id;
   __u16 dst_x;
-  __u16 dst_y;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 dst_y;
   __u16 dst_width;
   __u16 dst_height;
 };
-#define I915_OVERLAY_UPDATE_ATTRS (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_OVERLAY_UPDATE_ATTRS (1 << 0)
 #define I915_OVERLAY_UPDATE_GAMMA (1 << 1)
 #define I915_OVERLAY_DISABLE_DEST_COLORKEY (1 << 2)
 struct drm_intel_overlay_attrs {
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 color_key;
   __s32 brightness;
   __u32 contrast;
-  __u32 saturation;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 saturation;
   __u32 gamma0;
   __u32 gamma1;
   __u32 gamma2;
-  __u32 gamma3;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 gamma3;
   __u32 gamma4;
   __u32 gamma5;
 };
-#define I915_SET_COLORKEY_NONE (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_SET_COLORKEY_NONE (1 << 0)
 #define I915_SET_COLORKEY_DESTINATION (1 << 1)
 #define I915_SET_COLORKEY_SOURCE (1 << 2)
 struct drm_intel_sprite_colorkey {
-  __u32 plane_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 plane_id;
   __u32 min_value;
   __u32 channel_mask;
   __u32 max_value;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
 };
 struct drm_i915_gem_wait {
   __u32 bo_handle;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __s64 timeout_ns;
 };
 struct drm_i915_gem_context_create {
-  __u32 ctx_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ctx_id;
   __u32 pad;
 };
 struct drm_i915_gem_context_destroy {
-  __u32 ctx_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ctx_id;
   __u32 pad;
 };
 struct drm_i915_reg_read {
-  __u64 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 offset;
   __u64 val;
 };
 struct drm_i915_reset_stats {
-  __u32 ctx_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ctx_id;
   __u32 flags;
   __u32 reset_count;
   __u32 batch_active;
-  __u32 batch_pending;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 batch_pending;
   __u32 pad;
 };
 struct drm_i915_gem_userptr {
-  __u64 user_ptr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 user_ptr;
   __u64 user_size;
   __u32 flags;
 #define I915_USERPTR_READ_ONLY 0x1
-#define I915_USERPTR_UNSYNCHRONIZED 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_USERPTR_UNSYNCHRONIZED 0x80000000
   __u32 handle;
 };
 struct drm_i915_gem_context_param {
-  __u32 ctx_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ctx_id;
   __u32 size;
   __u64 param;
 #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
-#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
+#define I915_CONTEXT_PARAM_GTT_SIZE 0x3
   __u64 value;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
 #endif
diff --git a/libc/kernel/uapi/drm/mga_drm.h b/libc/kernel/uapi/drm/mga_drm.h
index ded4d89..38608ec 100644
--- a/libc/kernel/uapi/drm/mga_drm.h
+++ b/libc/kernel/uapi/drm/mga_drm.h
@@ -18,278 +18,283 @@
  ****************************************************************************/
 #ifndef __MGA_DRM_H__
 #define __MGA_DRM_H__
-#include <drm/drm.h>
-#ifndef __MGA_SAREA_DEFINES__
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifndef __MGA_SAREA_DEFINES__
 #define __MGA_SAREA_DEFINES__
 #define MGA_F 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_A 0x2
 #define MGA_S 0x4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_T2 0x8
 #define MGA_WARP_TGZ 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_TGZF (MGA_F)
 #define MGA_WARP_TGZA (MGA_A)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_TGZAF (MGA_F | MGA_A)
 #define MGA_WARP_TGZS (MGA_S)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_TGZSF (MGA_S | MGA_F)
 #define MGA_WARP_TGZSA (MGA_S | MGA_A)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_TGZSAF (MGA_S | MGA_F | MGA_A)
 #define MGA_WARP_T2GZ (MGA_T2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_T2GZF (MGA_T2 | MGA_F)
 #define MGA_WARP_T2GZA (MGA_T2 | MGA_A)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_T2GZAF (MGA_T2 | MGA_A | MGA_F)
 #define MGA_WARP_T2GZS (MGA_T2 | MGA_S)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_T2GZSF (MGA_T2 | MGA_S | MGA_F)
 #define MGA_WARP_T2GZSA (MGA_T2 | MGA_S | MGA_A)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_T2GZSAF (MGA_T2 | MGA_S | MGA_F | MGA_A)
 #define MGA_MAX_G200_PIPES 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_MAX_G400_PIPES 16
 #define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_WARP_UCODE_SIZE 32768
 #define MGA_CARD_TYPE_G200 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_CARD_TYPE_G400 2
 #define MGA_CARD_TYPE_G450 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_CARD_TYPE_G550 4
 #define MGA_FRONT 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_BACK 0x2
 #define MGA_DEPTH 0x4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_UPLOAD_CONTEXT 0x1
 #define MGA_UPLOAD_TEX0 0x2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_UPLOAD_TEX1 0x4
 #define MGA_UPLOAD_PIPE 0x8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_UPLOAD_TEX0IMAGE 0x10
 #define MGA_UPLOAD_TEX1IMAGE 0x20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_UPLOAD_2D 0x40
 #define MGA_WAIT_AGE 0x80
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_UPLOAD_CLIPRECTS 0x100
 #define MGA_BUFFER_SIZE (1 << 16)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_NUM_BUFFERS 128
 #define MGA_NR_SAREA_CLIPRECTS 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_CARD_HEAP 0
 #define MGA_AGP_HEAP 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_NR_TEX_HEAPS 2
 #define MGA_NR_TEX_REGIONS 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_LOG_MIN_TEX_REGION_SIZE 16
 #define DRM_MGA_IDLE_RETRY 2048
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 typedef struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dstorg;
   unsigned int maccess;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int plnwt;
   unsigned int dwgctl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int alphactrl;
   unsigned int fogcolor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int wflag;
   unsigned int tdualstage0;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int tdualstage1;
   unsigned int fcol;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int stencil;
   unsigned int stencilctl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_context_regs_t;
 typedef struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pitch;
 } drm_mga_server_regs_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   unsigned int texctl;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texctl2;
   unsigned int texfilter;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texbordercol;
   unsigned int texorg;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texwidth;
   unsigned int texheight;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texorg1;
   unsigned int texorg2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texorg3;
   unsigned int texorg4;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_texture_regs_t;
 typedef struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int head;
   unsigned int wrap;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_age_t;
 typedef struct _drm_mga_sarea {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_mga_context_regs_t context_state;
   drm_mga_server_regs_t server_state;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_mga_texture_regs_t tex_state[2];
   unsigned int warp_pipe;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dirty;
   unsigned int vertsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_clip_rect boxes[MGA_NR_SAREA_CLIPRECTS];
   unsigned int nbox;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int req_drawable;
   unsigned int req_draw_buffer;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int exported_drawable;
   unsigned int exported_index;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int exported_stamp;
   unsigned int exported_buffers;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int exported_nfront;
   unsigned int exported_nback;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int exported_back_x, exported_front_x, exported_w;
   int exported_back_y, exported_front_y, exported_h;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_clip_rect exported_boxes[MGA_NR_SAREA_CLIPRECTS];
   unsigned int status[4];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int last_wrap;
   drm_mga_age_t last_frame;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int last_enqueue;
   unsigned int last_dispatch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int last_quiescent;
   struct drm_tex_region texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS + 1];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texAge[MGA_NR_TEX_HEAPS];
   int ctxOwner;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_sarea_t;
 #define DRM_MGA_INIT 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MGA_FLUSH 0x01
 #define DRM_MGA_RESET 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MGA_SWAP 0x03
 #define DRM_MGA_CLEAR 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MGA_VERTEX 0x05
 #define DRM_MGA_INDICES 0x06
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MGA_ILOAD 0x07
 #define DRM_MGA_BLIT 0x08
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MGA_GETPARAM 0x09
 #define DRM_MGA_SET_FENCE 0x0a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MGA_WAIT_FENCE 0x0b
 #define DRM_MGA_DMA_BOOTSTRAP 0x0c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MGA_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_INIT, drm_mga_init_t)
 #define DRM_IOCTL_MGA_FLUSH DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_FLUSH, struct drm_lock)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MGA_RESET DRM_IO(DRM_COMMAND_BASE + DRM_MGA_RESET)
 #define DRM_IOCTL_MGA_SWAP DRM_IO(DRM_COMMAND_BASE + DRM_MGA_SWAP)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MGA_CLEAR DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_CLEAR, drm_mga_clear_t)
 #define DRM_IOCTL_MGA_VERTEX DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_VERTEX, drm_mga_vertex_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MGA_INDICES DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_INDICES, drm_mga_indices_t)
 #define DRM_IOCTL_MGA_ILOAD DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_ILOAD, drm_mga_iload_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MGA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_BLIT, drm_mga_blit_t)
 #define DRM_IOCTL_MGA_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MGA_GETPARAM, drm_mga_getparam_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MGA_SET_FENCE DRM_IOW(DRM_COMMAND_BASE + DRM_MGA_SET_FENCE, __u32)
 #define DRM_IOCTL_MGA_WAIT_FENCE DRM_IOWR(DRM_COMMAND_BASE + DRM_MGA_WAIT_FENCE, __u32)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MGA_DMA_BOOTSTRAP DRM_IOWR(DRM_COMMAND_BASE + DRM_MGA_DMA_BOOTSTRAP, drm_mga_dma_bootstrap_t)
 typedef struct _drm_mga_warp_index {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int installed;
   unsigned long phys_addr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int size;
 } drm_mga_warp_index_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_mga_init {
   enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     MGA_INIT_DMA = 0x01,
     MGA_CLEANUP_DMA = 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } func;
   unsigned long sarea_priv_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int chipset;
   int sgram;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int maccess;
   unsigned int fb_cpp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int front_offset, front_pitch;
   unsigned int back_offset, back_pitch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int depth_cpp;
   unsigned int depth_offset, depth_pitch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texture_offset[MGA_NR_TEX_HEAPS];
   unsigned int texture_size[MGA_NR_TEX_HEAPS];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long fb_offset;
   unsigned long mmio_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long status_offset;
   unsigned long warp_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long primary_offset;
   unsigned long buffers_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_init_t;
 typedef struct drm_mga_dma_bootstrap {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long texture_handle;
   __u32 texture_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 primary_size;
   __u32 secondary_bin_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 secondary_bin_size;
   __u32 agp_mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 agp_size;
 } drm_mga_dma_bootstrap_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_mga_clear {
   unsigned int flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int clear_color;
   unsigned int clear_depth;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int color_mask;
   unsigned int depth_mask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_clear_t;
 typedef struct drm_mga_vertex {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int used;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int discard;
 } drm_mga_vertex_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_mga_indices {
   int idx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int start;
   unsigned int end;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int discard;
 } drm_mga_indices_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_mga_iload {
   int idx;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dstorg;
   unsigned int length;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_iload_t;
 typedef struct _drm_mga_blit {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int planemask;
   unsigned int srcorg;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dstorg;
   int src_pitch, dst_pitch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int delta_sx, delta_sy;
   int delta_dx, delta_dy;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int height, ydir;
   int source_pitch, dest_pitch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_blit_t;
 #define MGA_PARAM_IRQ_NR 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MGA_PARAM_CARD_TYPE 2
 typedef struct drm_mga_getparam {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int param;
   void __user * value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_mga_getparam_t;
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #endif
diff --git a/libc/kernel/uapi/drm/msm_drm.h b/libc/kernel/uapi/drm/msm_drm.h
index 069fd01..fc441fb 100644
--- a/libc/kernel/uapi/drm/msm_drm.h
+++ b/libc/kernel/uapi/drm/msm_drm.h
@@ -18,132 +18,138 @@
  ****************************************************************************/
 #ifndef __MSM_DRM_H__
 #define __MSM_DRM_H__
-#include <stddef.h>
-#include <drm/drm.h>
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define MSM_PIPE_NONE 0x00
 #define MSM_PIPE_2D0 0x01
 #define MSM_PIPE_2D1 0x02
-#define MSM_PIPE_3D0 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MSM_PIPE_3D0 0x10
 struct drm_msm_timespec {
   __s64 tv_sec;
   __s64 tv_nsec;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define MSM_PARAM_GPU_ID 0x01
 #define MSM_PARAM_GMEM_SIZE 0x02
 #define MSM_PARAM_CHIP_ID 0x03
-struct drm_msm_param {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MSM_PARAM_MAX_FREQ 0x04
+#define MSM_PARAM_TIMESTAMP 0x05
+struct drm_msm_param {
   __u32 pipe;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 param;
   __u64 value;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_BO_SCANOUT 0x00000001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_BO_GPU_READONLY 0x00000002
 #define MSM_BO_CACHE_MASK 0x000f0000
 #define MSM_BO_CACHED 0x00010000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_BO_WC 0x00020000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_BO_UNCACHED 0x00040000
 #define MSM_BO_FLAGS (MSM_BO_SCANOUT | MSM_BO_GPU_READONLY | MSM_BO_CACHED | MSM_BO_WC | MSM_BO_UNCACHED)
 struct drm_msm_gem_new {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   __u32 handle;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_msm_gem_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
   __u32 pad;
   __u64 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_PREP_READ 0x01
 #define MSM_PREP_WRITE 0x02
 #define MSM_PREP_NOSYNC 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_PREP_FLAGS (MSM_PREP_READ | MSM_PREP_WRITE | MSM_PREP_NOSYNC)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_msm_gem_cpu_prep {
   __u32 handle;
   __u32 op;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_msm_timespec timeout;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_msm_gem_cpu_fini {
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_msm_gem_submit_reloc {
   __u32 submit_offset;
   __u32 or;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 shift;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reloc_idx;
   __u64 reloc_offset;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_SUBMIT_CMD_BUF 0x0001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_SUBMIT_CMD_IB_TARGET_BUF 0x0002
 #define MSM_SUBMIT_CMD_CTX_RESTORE_BUF 0x0003
 struct drm_msm_gem_submit_cmd {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 submit_idx;
   __u32 submit_offset;
   __u32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 nr_relocs;
   __u64 __user relocs;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_SUBMIT_BO_READ 0x0001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSM_SUBMIT_BO_WRITE 0x0002
 #define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE)
 struct drm_msm_gem_submit_bo {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
   __u64 presumed;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_msm_gem_submit {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pipe;
   __u32 fence;
   __u32 nr_bos;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 nr_cmds;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 __user bos;
   __u64 __user cmds;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_msm_wait_fence {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 fence;
   __u32 pad;
   struct drm_msm_timespec timeout;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MSM_GET_PARAM 0x00
 #define DRM_MSM_GEM_NEW 0x02
 #define DRM_MSM_GEM_INFO 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MSM_GEM_CPU_PREP 0x04
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MSM_GEM_CPU_FINI 0x05
 #define DRM_MSM_GEM_SUBMIT 0x06
 #define DRM_MSM_WAIT_FENCE 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_MSM_NUM_IOCTLS 0x08
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
 #define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
 #define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW(DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_MSM_GEM_CPU_FINI DRM_IOW(DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_FINI, struct drm_msm_gem_cpu_fini)
 #define DRM_IOCTL_MSM_GEM_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_SUBMIT, struct drm_msm_gem_submit)
 #define DRM_IOCTL_MSM_WAIT_FENCE DRM_IOW(DRM_COMMAND_BASE + DRM_MSM_WAIT_FENCE, struct drm_msm_wait_fence)
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+#endif
diff --git a/libc/kernel/uapi/drm/nouveau_drm.h b/libc/kernel/uapi/drm/nouveau_drm.h
index 38ee589..06cc6c1 100644
--- a/libc/kernel/uapi/drm/nouveau_drm.h
+++ b/libc/kernel/uapi/drm/nouveau_drm.h
@@ -19,128 +19,135 @@
 #ifndef __NOUVEAU_DRM_H__
 #define __NOUVEAU_DRM_H__
 #define DRM_NOUVEAU_EVENT_NVIF 0x80000000
-#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
+#include "drm.h"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
+#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
 #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
 #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
 #define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_TILE_COMP 0x00030000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
 #define NOUVEAU_GEM_TILE_16BPP 0x00000001
 #define NOUVEAU_GEM_TILE_32BPP 0x00000002
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_TILE_ZETA 0x00000004
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
 struct drm_nouveau_gem_info {
-  uint32_t handle;
+  __u32 handle;
+  __u32 domain;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t domain;
-  uint64_t size;
-  uint64_t offset;
-  uint64_t map_handle;
+  __u64 size;
+  __u64 offset;
+  __u64 map_handle;
+  __u32 tile_mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t tile_mode;
-  uint32_t tile_flags;
+  __u32 tile_flags;
 };
 struct drm_nouveau_gem_new {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_nouveau_gem_info info;
-  uint32_t channel_hint;
-  uint32_t align;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 channel_hint;
+  __u32 align;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_MAX_BUFFERS 1024
-struct drm_nouveau_gem_pushbuf_bo_presumed {
-  uint32_t valid;
-  uint32_t domain;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t offset;
+struct drm_nouveau_gem_pushbuf_bo_presumed {
+  __u32 valid;
+  __u32 domain;
+  __u64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_nouveau_gem_pushbuf_bo {
-  uint64_t user_priv;
+  __u64 user_priv;
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t handle;
-  uint32_t read_domains;
-  uint32_t write_domains;
-  uint32_t valid_domains;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 read_domains;
+  __u32 write_domains;
+  __u32 valid_domains;
   struct drm_nouveau_gem_pushbuf_bo_presumed presumed;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NOUVEAU_GEM_RELOC_LOW (1 << 0)
 #define NOUVEAU_GEM_RELOC_HIGH (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_RELOC_OR (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_MAX_RELOCS 1024
 struct drm_nouveau_gem_pushbuf_reloc {
-  uint32_t reloc_bo_index;
+  __u32 reloc_bo_index;
+  __u32 reloc_bo_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t reloc_bo_offset;
-  uint32_t bo_index;
-  uint32_t flags;
-  uint32_t data;
+  __u32 bo_index;
+  __u32 flags;
+  __u32 data;
+  __u32 vor;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t vor;
-  uint32_t tor;
+  __u32 tor;
 };
 #define NOUVEAU_GEM_MAX_PUSH 512
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_nouveau_gem_pushbuf_push {
-  uint32_t bo_index;
-  uint32_t pad;
-  uint64_t offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t length;
+  __u32 bo_index;
+  __u32 pad;
+  __u64 offset;
+  __u64 length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_nouveau_gem_pushbuf {
-  uint32_t channel;
+  __u32 channel;
+  __u32 nr_buffers;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t nr_buffers;
-  uint64_t buffers;
-  uint32_t nr_relocs;
-  uint32_t nr_push;
+  __u64 buffers;
+  __u32 nr_relocs;
+  __u32 nr_push;
+  __u64 relocs;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t relocs;
-  uint64_t push;
-  uint32_t suffix0;
-  uint32_t suffix1;
+  __u64 push;
+  __u32 suffix0;
+  __u32 suffix1;
+  __u64 vram_available;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t vram_available;
-  uint64_t gart_available;
+  __u64 gart_available;
 };
 #define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_nouveau_gem_cpu_prep {
-  uint32_t handle;
-  uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 flags;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_nouveau_gem_cpu_fini {
-  uint32_t handle;
+  __u32 handle;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_NOUVEAU_GETPARAM 0x00
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_NOUVEAU_SETPARAM 0x01
 #define DRM_NOUVEAU_CHANNEL_ALLOC 0x02
 #define DRM_NOUVEAU_CHANNEL_FREE 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_NOUVEAU_GROBJ_ALLOC 0x04
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05
 #define DRM_NOUVEAU_GPUOBJ_FREE 0x06
 #define DRM_NOUVEAU_NVIF 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_NOUVEAU_GEM_NEW 0x40
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_NOUVEAU_GEM_PUSHBUF 0x41
 #define DRM_NOUVEAU_GEM_CPU_PREP 0x42
 #define DRM_NOUVEAU_GEM_CPU_FINI 0x43
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_NOUVEAU_GEM_INFO 0x44
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_NOUVEAU_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new)
 #define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF, struct drm_nouveau_gem_pushbuf)
 #define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP DRM_IOW(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, struct drm_nouveau_gem_cpu_prep)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI DRM_IOW(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, struct drm_nouveau_gem_cpu_fini)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_NOUVEAU_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info)
+#ifdef __cplusplus
 #endif
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/drm/omap_drm.h b/libc/kernel/uapi/drm/omap_drm.h
index efca002..52351b1 100644
--- a/libc/kernel/uapi/drm/omap_drm.h
+++ b/libc/kernel/uapi/drm/omap_drm.h
@@ -18,83 +18,88 @@
  ****************************************************************************/
 #ifndef __OMAP_DRM_H__
 #define __OMAP_DRM_H__
-#include <drm/drm.h>
-#define OMAP_PARAM_CHIPSET_ID 1
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define OMAP_PARAM_CHIPSET_ID 1
 struct drm_omap_param {
   uint64_t param;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t value;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OMAP_BO_SCANOUT 0x00000001
 #define OMAP_BO_CACHE_MASK 0x00000006
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OMAP_BO_TILED_MASK 0x00000f00
 #define OMAP_BO_CACHED 0x00000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OMAP_BO_WC 0x00000002
 #define OMAP_BO_UNCACHED 0x00000004
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OMAP_BO_TILED_8 0x00000100
 #define OMAP_BO_TILED_16 0x00000200
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OMAP_BO_TILED_32 0x00000300
 #define OMAP_BO_TILED (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | OMAP_BO_TILED_32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union omap_gem_size {
   uint32_t bytes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     uint16_t width;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     uint16_t height;
   } tiled;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_omap_gem_new {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union omap_gem_size size;
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t handle;
   uint32_t __pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum omap_gem_op {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OMAP_GEM_READ = 0x01,
   OMAP_GEM_WRITE = 0x02,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_omap_gem_cpu_prep {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t handle;
   uint32_t op;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_omap_gem_cpu_fini {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t handle;
   uint32_t op;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t nregions;
   uint32_t __pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_omap_gem_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t handle;
   uint32_t pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t offset;
   uint32_t size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t __pad;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_OMAP_GET_PARAM 0x00
 #define DRM_OMAP_SET_PARAM 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_OMAP_GEM_NEW 0x03
 #define DRM_OMAP_GEM_CPU_PREP 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_OMAP_GEM_CPU_FINI 0x05
 #define DRM_OMAP_GEM_INFO 0x06
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_OMAP_NUM_IOCTLS 0x07
 #define DRM_IOCTL_OMAP_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GET_PARAM, struct drm_omap_param)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_OMAP_SET_PARAM DRM_IOW(DRM_COMMAND_BASE + DRM_OMAP_SET_PARAM, struct drm_omap_param)
 #define DRM_IOCTL_OMAP_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GEM_NEW, struct drm_omap_gem_new)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_OMAP_GEM_CPU_PREP DRM_IOW(DRM_COMMAND_BASE + DRM_OMAP_GEM_CPU_PREP, struct drm_omap_gem_cpu_prep)
 #define DRM_IOCTL_OMAP_GEM_CPU_FINI DRM_IOW(DRM_COMMAND_BASE + DRM_OMAP_GEM_CPU_FINI, struct drm_omap_gem_cpu_fini)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_OMAP_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_OMAP_GEM_INFO, struct drm_omap_gem_info)
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #endif
diff --git a/libc/kernel/uapi/drm/qxl_drm.h b/libc/kernel/uapi/drm/qxl_drm.h
index 3878b75..6636454 100644
--- a/libc/kernel/uapi/drm/qxl_drm.h
+++ b/libc/kernel/uapi/drm/qxl_drm.h
@@ -18,101 +18,104 @@
  ****************************************************************************/
 #ifndef QXL_DRM_H
 #define QXL_DRM_H
-#include <stddef.h>
-#include "drm/drm.h"
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define QXL_GEM_DOMAIN_CPU 0
 #define QXL_GEM_DOMAIN_VRAM 1
 #define QXL_GEM_DOMAIN_SURFACE 2
-#define DRM_QXL_ALLOC 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_QXL_ALLOC 0x00
 #define DRM_QXL_MAP 0x01
 #define DRM_QXL_EXECBUFFER 0x02
 #define DRM_QXL_UPDATE_AREA 0x03
-#define DRM_QXL_GETPARAM 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_QXL_GETPARAM 0x04
 #define DRM_QXL_CLIENTCAP 0x05
 #define DRM_QXL_ALLOC_SURF 0x06
 struct drm_qxl_alloc {
-  uint32_t size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t handle;
+  __u32 size;
+  __u32 handle;
 };
 struct drm_qxl_map {
-  uint64_t offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t handle;
-  uint32_t pad;
+  __u64 offset;
+  __u32 handle;
+  __u32 pad;
 };
-#define QXL_RELOC_TYPE_BO 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QXL_RELOC_TYPE_BO 1
 #define QXL_RELOC_TYPE_SURF 2
 struct drm_qxl_reloc {
-  uint64_t src_offset;
-  uint64_t dst_offset;
+  __u64 src_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t src_handle;
-  uint32_t dst_handle;
-  uint32_t reloc_type;
-  uint32_t pad;
+  __u64 dst_offset;
+  __u32 src_handle;
+  __u32 dst_handle;
+  __u32 reloc_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pad;
 };
 struct drm_qxl_command {
-  uint64_t __user command;
-  uint64_t __user relocs;
+  __u64 __user command;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t type;
-  uint32_t command_size;
-  uint32_t relocs_num;
-  uint32_t pad;
+  __u64 __user relocs;
+  __u32 type;
+  __u32 command_size;
+  __u32 relocs_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pad;
 };
 struct drm_qxl_execbuffer {
-  uint32_t flags;
-  uint32_t commands_num;
+  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t __user commands;
+  __u32 commands_num;
+  __u64 __user commands;
 };
 struct drm_qxl_update_area {
-  uint32_t handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t top;
-  uint32_t left;
-  uint32_t bottom;
-  uint32_t right;
+  __u32 handle;
+  __u32 top;
+  __u32 left;
+  __u32 bottom;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad;
+  __u32 right;
+  __u32 pad;
 };
 #define QXL_PARAM_NUM_SURFACES 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define QXL_PARAM_MAX_RELOCS 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_qxl_getparam {
-  uint64_t param;
-  uint64_t value;
-};
+  __u64 param;
+  __u64 value;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_qxl_clientcap {
-  uint32_t index;
-  uint32_t pad;
-};
+  __u32 index;
+  __u32 pad;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct drm_qxl_alloc_surf {
-  uint32_t format;
-  uint32_t width;
-  uint32_t height;
+  __u32 format;
+  __u32 width;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int32_t stride;
-  uint32_t handle;
-  uint32_t pad;
+  __u32 height;
+  __s32 stride;
+  __u32 handle;
+  __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_QXL_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc)
 #define DRM_IOCTL_QXL_MAP DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map)
 #define DRM_IOCTL_QXL_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER, struct drm_qxl_execbuffer)
-#define DRM_IOCTL_QXL_UPDATE_AREA DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA, struct drm_qxl_update_area)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_QXL_UPDATE_AREA DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA, struct drm_qxl_update_area)
 #define DRM_IOCTL_QXL_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM, struct drm_qxl_getparam)
 #define DRM_IOCTL_QXL_CLIENTCAP DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP, struct drm_qxl_clientcap)
 #define DRM_IOCTL_QXL_ALLOC_SURF DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF, struct drm_qxl_alloc_surf)
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
+#endif
diff --git a/libc/kernel/uapi/drm/r128_drm.h b/libc/kernel/uapi/drm/r128_drm.h
index de30d62..35c94f6 100644
--- a/libc/kernel/uapi/drm/r128_drm.h
+++ b/libc/kernel/uapi/drm/r128_drm.h
@@ -18,264 +18,269 @@
  ****************************************************************************/
 #ifndef __R128_DRM_H__
 #define __R128_DRM_H__
-#include <drm/drm.h>
-#ifndef __R128_SAREA_DEFINES__
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifndef __R128_SAREA_DEFINES__
 #define __R128_SAREA_DEFINES__
 #define R128_UPLOAD_CONTEXT 0x001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_UPLOAD_SETUP 0x002
 #define R128_UPLOAD_TEX0 0x004
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_UPLOAD_TEX1 0x008
 #define R128_UPLOAD_TEX0IMAGES 0x010
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_UPLOAD_TEX1IMAGES 0x020
 #define R128_UPLOAD_CORE 0x040
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_UPLOAD_MASKS 0x080
 #define R128_UPLOAD_WINDOW 0x100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_UPLOAD_CLIPRECTS 0x200
 #define R128_REQUIRE_QUIESCENCE 0x400
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_UPLOAD_ALL 0x7ff
 #define R128_FRONT 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_BACK 0x2
 #define R128_DEPTH 0x4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_POINTS 0x1
 #define R128_LINES 0x2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_LINE_STRIP 0x3
 #define R128_TRIANGLES 0x4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_TRIANGLE_FAN 0x5
 #define R128_TRIANGLE_STRIP 0x6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_BUFFER_SIZE 16384
 #define R128_INDEX_PRIM_OFFSET 20
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_HOSTDATA_BLIT_OFFSET 32
 #define R128_NR_SAREA_CLIPRECTS 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_LOCAL_TEX_HEAP 0
 #define R128_AGP_TEX_HEAP 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_NR_TEX_HEAPS 2
 #define R128_NR_TEX_REGIONS 64
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_LOG_TEX_GRANULARITY 16
 #define R128_NR_CONTEXT_REGS 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R128_MAX_TEXTURE_LEVELS 11
 #define R128_MAX_TEXTURE_UNITS 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 typedef struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dst_pitch_offset_c;
   unsigned int dp_gui_master_cntl_c;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int sc_top_left_c;
   unsigned int sc_bottom_right_c;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int z_offset_c;
   unsigned int z_pitch_c;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int z_sten_cntl_c;
   unsigned int tex_cntl_c;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int misc_3d_state_cntl_reg;
   unsigned int texture_clr_cmp_clr_c;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texture_clr_cmp_msk_c;
   unsigned int fog_color_c;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int tex_size_pitch_c;
   unsigned int constant_color_c;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pm4_vc_fpu_setup;
   unsigned int setup_cntl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dp_write_mask;
   unsigned int sten_ref_mask_c;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int plane_3d_mask_c;
   unsigned int window_xy_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int scale_3d_cntl;
 } drm_r128_context_regs_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   unsigned int tex_cntl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int tex_combine_cntl;
   unsigned int tex_size_pitch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
   unsigned int tex_border_color;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_texture_regs_t;
 typedef struct drm_r128_sarea {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_r128_context_regs_t context_state;
   drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dirty;
   unsigned int vertsize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int vc_format;
   struct drm_clip_rect boxes[R128_NR_SAREA_CLIPRECTS];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int nbox;
   unsigned int last_frame;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int last_dispatch;
   struct drm_tex_region tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS + 1];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int tex_age[R128_NR_TEX_HEAPS];
   int ctx_owner;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pfAllowPageFlip;
   int pfCurrentPage;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_sarea_t;
 #define DRM_R128_INIT 0x00
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_CCE_START 0x01
 #define DRM_R128_CCE_STOP 0x02
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_CCE_RESET 0x03
 #define DRM_R128_CCE_IDLE 0x04
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_RESET 0x06
 #define DRM_R128_SWAP 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_CLEAR 0x08
 #define DRM_R128_VERTEX 0x09
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_INDICES 0x0a
 #define DRM_R128_BLIT 0x0b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_DEPTH 0x0c
 #define DRM_R128_STIPPLE 0x0d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_INDIRECT 0x0f
 #define DRM_R128_FULLSCREEN 0x10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_CLEAR2 0x11
 #define DRM_R128_GETPARAM 0x12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_R128_FLIP 0x13
 #define DRM_IOCTL_R128_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_R128_INIT, drm_r128_init_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_CCE_START DRM_IO(DRM_COMMAND_BASE + DRM_R128_CCE_START)
 #define DRM_IOCTL_R128_CCE_STOP DRM_IOW(DRM_COMMAND_BASE + DRM_R128_CCE_STOP, drm_r128_cce_stop_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_CCE_RESET DRM_IO(DRM_COMMAND_BASE + DRM_R128_CCE_RESET)
 #define DRM_IOCTL_R128_CCE_IDLE DRM_IO(DRM_COMMAND_BASE + DRM_R128_CCE_IDLE)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_RESET DRM_IO(DRM_COMMAND_BASE + DRM_R128_RESET)
 #define DRM_IOCTL_R128_SWAP DRM_IO(DRM_COMMAND_BASE + DRM_R128_SWAP)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_CLEAR DRM_IOW(DRM_COMMAND_BASE + DRM_R128_CLEAR, drm_r128_clear_t)
 #define DRM_IOCTL_R128_VERTEX DRM_IOW(DRM_COMMAND_BASE + DRM_R128_VERTEX, drm_r128_vertex_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_INDICES DRM_IOW(DRM_COMMAND_BASE + DRM_R128_INDICES, drm_r128_indices_t)
 #define DRM_IOCTL_R128_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_R128_BLIT, drm_r128_blit_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_DEPTH DRM_IOW(DRM_COMMAND_BASE + DRM_R128_DEPTH, drm_r128_depth_t)
 #define DRM_IOCTL_R128_STIPPLE DRM_IOW(DRM_COMMAND_BASE + DRM_R128_STIPPLE, drm_r128_stipple_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_R128_INDIRECT, drm_r128_indirect_t)
 #define DRM_IOCTL_R128_FULLSCREEN DRM_IOW(DRM_COMMAND_BASE + DRM_R128_FULLSCREEN, drm_r128_fullscreen_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_CLEAR2 DRM_IOW(DRM_COMMAND_BASE + DRM_R128_CLEAR2, drm_r128_clear2_t)
 #define DRM_IOCTL_R128_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_R128_GETPARAM, drm_r128_getparam_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_R128_FLIP DRM_IO(DRM_COMMAND_BASE + DRM_R128_FLIP)
 typedef struct drm_r128_init {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum {
     R128_INIT_CCE = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     R128_CLEANUP_CCE = 0x02
   } func;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long sarea_priv_offset;
   int is_pci;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int cce_mode;
   int cce_secure;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int ring_size;
   int usec_timeout;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int fb_bpp;
   unsigned int front_offset, front_pitch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int back_offset, back_pitch;
   unsigned int depth_bpp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int depth_offset, depth_pitch;
   unsigned int span_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long fb_offset;
   unsigned long mmio_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long ring_offset;
   unsigned long ring_rptr_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long buffers_offset;
   unsigned long agp_textures_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_init_t;
 typedef struct drm_r128_cce_stop {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int flush;
   int idle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_cce_stop_t;
 typedef struct drm_r128_clear {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int flags;
   unsigned int clear_color;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int clear_depth;
   unsigned int color_mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int depth_mask;
 } drm_r128_clear_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_r128_vertex {
   int prim;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int discard;
 } drm_r128_vertex_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_r128_indices {
   int prim;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int start;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int end;
   int discard;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_indices_t;
 typedef struct drm_r128_blit {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int pitch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int offset;
   int format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short x, y;
   unsigned short width, height;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_blit_t;
 typedef struct drm_r128_depth {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum {
     R128_WRITE_SPAN = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     R128_WRITE_PIXELS = 0x02,
     R128_READ_SPAN = 0x03,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     R128_READ_PIXELS = 0x04
   } func;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int n;
   int __user * x;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int __user * y;
   unsigned int __user * buffer;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char __user * mask;
 } drm_r128_depth_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_r128_stipple {
   unsigned int __user * mask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_stipple_t;
 typedef struct drm_r128_indirect {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int start;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int end;
   int discard;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_indirect_t;
 typedef struct drm_r128_fullscreen {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum {
     R128_INIT_FULLSCREEN = 0x01,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     R128_CLEANUP_FULLSCREEN = 0x02
   } func;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_r128_fullscreen_t;
 #define R128_PARAM_IRQ_NR 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_r128_getparam {
   int param;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   void __user * value;
 } drm_r128_getparam_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
 #endif
diff --git a/libc/kernel/uapi/drm/radeon_drm.h b/libc/kernel/uapi/drm/radeon_drm.h
index d85309f..5e4c773 100644
--- a/libc/kernel/uapi/drm/radeon_drm.h
+++ b/libc/kernel/uapi/drm/radeon_drm.h
@@ -19,978 +19,983 @@
 #ifndef __RADEON_DRM_H__
 #define __RADEON_DRM_H__
 #include "drm.h"
-#ifndef __RADEON_SAREA_DEFINES__
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifndef __RADEON_SAREA_DEFINES__
 #define __RADEON_SAREA_DEFINES__
 #define RADEON_UPLOAD_CONTEXT 0x00000001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_VERTFMT 0x00000002
 #define RADEON_UPLOAD_LINE 0x00000004
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_BUMPMAP 0x00000008
 #define RADEON_UPLOAD_MASKS 0x00000010
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_VIEWPORT 0x00000020
 #define RADEON_UPLOAD_SETUP 0x00000040
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_TCL 0x00000080
 #define RADEON_UPLOAD_MISC 0x00000100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_TEX0 0x00000200
 #define RADEON_UPLOAD_TEX1 0x00000400
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_TEX2 0x00000800
 #define RADEON_UPLOAD_TEX0IMAGES 0x00001000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_TEX1IMAGES 0x00002000
 #define RADEON_UPLOAD_TEX2IMAGES 0x00004000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_CLIPRECTS 0x00008000
 #define RADEON_REQUIRE_QUIESCENCE 0x00010000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_ZBIAS 0x00020000
 #define RADEON_UPLOAD_ALL 0x003effff
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_UPLOAD_CONTEXT_ALL 0x003e01ff
 #define RADEON_EMIT_PP_MISC 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_CNTL 1
 #define RADEON_EMIT_RB3D_COLORPITCH 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_RE_LINE_PATTERN 3
 #define RADEON_EMIT_SE_LINE_WIDTH 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_LUM_MATRIX 5
 #define RADEON_EMIT_PP_ROT_MATRIX_0 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_RB3D_STENCILREFMASK 7
 #define RADEON_EMIT_SE_VPORT_XSCALE 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_SE_CNTL 9
 #define RADEON_EMIT_SE_CNTL_STATUS 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_RE_MISC 11
 #define RADEON_EMIT_PP_TXFILTER_0 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_BORDER_COLOR_0 13
 #define RADEON_EMIT_PP_TXFILTER_1 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_BORDER_COLOR_1 15
 #define RADEON_EMIT_PP_TXFILTER_2 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_BORDER_COLOR_2 17
 #define RADEON_EMIT_SE_ZBIAS_FACTOR 18
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT 19
 #define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED 20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXCBLEND_0 21
 #define R200_EMIT_PP_TXCBLEND_1 22
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXCBLEND_2 23
 #define R200_EMIT_PP_TXCBLEND_3 24
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXCBLEND_4 25
 #define R200_EMIT_PP_TXCBLEND_5 26
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXCBLEND_6 27
 #define R200_EMIT_PP_TXCBLEND_7 28
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_TCL_LIGHT_MODEL_CTL_0 29
 #define R200_EMIT_TFACTOR_0 30
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_VTX_FMT_0 31
 #define R200_EMIT_VAP_CTL 32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_MATRIX_SELECT_0 33
 #define R200_EMIT_TEX_PROC_CTL_2 34
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_TCL_UCP_VERT_BLEND_CTL 35
 #define R200_EMIT_PP_TXFILTER_0 36
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXFILTER_1 37
 #define R200_EMIT_PP_TXFILTER_2 38
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXFILTER_3 39
 #define R200_EMIT_PP_TXFILTER_4 40
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXFILTER_5 41
 #define R200_EMIT_PP_TXOFFSET_0 42
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXOFFSET_1 43
 #define R200_EMIT_PP_TXOFFSET_2 44
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXOFFSET_3 45
 #define R200_EMIT_PP_TXOFFSET_4 46
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXOFFSET_5 47
 #define R200_EMIT_VTE_CNTL 48
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_OUTPUT_VTX_COMP_SEL 49
 #define R200_EMIT_PP_TAM_DEBUG3 50
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_CNTL_X 51
 #define R200_EMIT_RB3D_DEPTHXY_OFFSET 52
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_RE_AUX_SCISSOR_CNTL 53
 #define R200_EMIT_RE_SCISSOR_TL_0 54
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_RE_SCISSOR_TL_1 55
 #define R200_EMIT_RE_SCISSOR_TL_2 56
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_SE_VAP_CNTL_STATUS 57
 #define R200_EMIT_SE_VTX_STATE_CNTL 58
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_RE_POINTSIZE 59
 #define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0 60
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_CUBIC_FACES_0 61
 #define R200_EMIT_PP_CUBIC_OFFSETS_0 62
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_CUBIC_FACES_1 63
 #define R200_EMIT_PP_CUBIC_OFFSETS_1 64
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_CUBIC_FACES_2 65
 #define R200_EMIT_PP_CUBIC_OFFSETS_2 66
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_CUBIC_FACES_3 67
 #define R200_EMIT_PP_CUBIC_OFFSETS_3 68
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_CUBIC_FACES_4 69
 #define R200_EMIT_PP_CUBIC_OFFSETS_4 70
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_CUBIC_FACES_5 71
 #define R200_EMIT_PP_CUBIC_OFFSETS_5 72
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_TEX_SIZE_0 73
 #define RADEON_EMIT_PP_TEX_SIZE_1 74
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_TEX_SIZE_2 75
 #define R200_EMIT_RB3D_BLENDCOLOR 76
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_TCL_POINT_SPRITE_CNTL 77
 #define RADEON_EMIT_PP_CUBIC_FACES_0 78
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_CUBIC_OFFSETS_T0 79
 #define RADEON_EMIT_PP_CUBIC_FACES_1 80
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_CUBIC_OFFSETS_T1 81
 #define RADEON_EMIT_PP_CUBIC_FACES_2 82
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_EMIT_PP_CUBIC_OFFSETS_T2 83
 #define R200_EMIT_PP_TRI_PERF_CNTL 84
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_AFS_0 85
 #define R200_EMIT_PP_AFS_1 86
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_ATF_TFACTOR 87
 #define R200_EMIT_PP_TXCTLALL_0 88
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXCTLALL_1 89
 #define R200_EMIT_PP_TXCTLALL_2 90
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXCTLALL_3 91
 #define R200_EMIT_PP_TXCTLALL_4 92
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R200_EMIT_PP_TXCTLALL_5 93
 #define R200_EMIT_VAP_PVS_CNTL 94
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_MAX_STATE_PACKETS 95
 #define RADEON_CMD_PACKET 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CMD_SCALARS 2
 #define RADEON_CMD_VECTORS 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CMD_DMA_DISCARD 4
 #define RADEON_CMD_PACKET3 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CMD_PACKET3_CLIP 6
 #define RADEON_CMD_SCALARS2 7
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CMD_WAIT 8
 #define RADEON_CMD_VECLINEAR 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef union {
   int i;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, pad0, pad1, pad2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } header;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, packet_id, pad0, pad1;
   } packet;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, offset, stride, count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } scalars;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, offset, stride, count;
   } vectors;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, addr_lo, addr_hi, count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } veclinear;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, buf_idx, pad0, pad1;
   } dma;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, flags, pad0, pad1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } wait;
 } drm_radeon_cmd_header_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_WAIT_2D 0x1
 #define RADEON_WAIT_3D 0x2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_CMD_PACKET3_CLEAR 0
 #define R300_CMD_PACKET3_RAW 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_CMD_PACKET0 1
 #define R300_CMD_VPU 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_CMD_PACKET3 3
 #define R300_CMD_END3D 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_CMD_CP_DELAY 5
 #define R300_CMD_DMA_DISCARD 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_CMD_WAIT 7
 #define R300_WAIT_2D 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_WAIT_3D 0x2
 #define R300_WAIT_2D_CLEAN 0x3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_WAIT_3D_CLEAN 0x4
 #define R300_NEW_WAIT_2D_3D 0x3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_NEW_WAIT_2D_2D_CLEAN 0x4
 #define R300_NEW_WAIT_3D_3D_CLEAN 0x6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN 0x8
 #define R300_CMD_SCRATCH 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R300_CMD_R500FP 9
 typedef union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int u;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, pad0, pad1, pad2;
   } header;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, count, reglo, reghi;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } packet0;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, count, adrlo, adrhi;
   } vpu;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, packet, pad0, pad1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } packet3;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, packet;
     unsigned short count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } delay;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, buf_idx, pad0, pad1;
   } dma;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, flags, pad0, pad1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } wait;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd_type, reg, n_bufs, flags;
   } scratch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd_type, count, adrlo, adrhi_flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } r500fp;
 } drm_r300_cmd_header_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_FRONT 0x1
 #define RADEON_BACK 0x2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_DEPTH 0x4
 #define RADEON_STENCIL 0x8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CLEAR_FASTZ 0x80000000
 #define RADEON_USE_HIERZ 0x40000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_USE_COMP_ZBUF 0x20000000
 #define R500FP_CONSTANT_TYPE (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R500FP_CONSTANT_CLAMP (1 << 2)
 #define RADEON_POINTS 0x1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_LINES 0x2
 #define RADEON_LINE_STRIP 0x3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TRIANGLES 0x4
 #define RADEON_TRIANGLE_FAN 0x5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TRIANGLE_STRIP 0x6
 #define RADEON_BUFFER_SIZE 65536
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INDEX_PRIM_OFFSET 20
 #define RADEON_SCRATCH_REG_OFFSET 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R600_SCRATCH_REG_OFFSET 256
 #define RADEON_NR_SAREA_CLIPRECTS 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_LOCAL_TEX_HEAP 0
 #define RADEON_GART_TEX_HEAP 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_NR_TEX_HEAPS 2
 #define RADEON_NR_TEX_REGIONS 64
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_LOG_TEX_GRANULARITY 16
 #define RADEON_MAX_TEXTURE_LEVELS 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_MAX_TEXTURE_UNITS 3
 #define RADEON_MAX_SURFACES 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_OFFSET_SHIFT 10
 #define RADEON_OFFSET_ALIGN (1 << RADEON_OFFSET_SHIFT)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_OFFSET_MASK (RADEON_OFFSET_ALIGN - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   unsigned int red;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int green;
   unsigned int blue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int alpha;
 } radeon_color_regs_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   unsigned int pp_misc;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pp_fog_color;
   unsigned int re_solid_color;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int rb3d_blendcntl;
   unsigned int rb3d_depthoffset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int rb3d_depthpitch;
   unsigned int rb3d_zstencilcntl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pp_cntl;
   unsigned int rb3d_cntl;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int rb3d_coloroffset;
   unsigned int re_width_height;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int rb3d_colorpitch;
   unsigned int se_cntl;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int se_coord_fmt;
   unsigned int re_line_pattern;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int re_line_state;
   unsigned int se_line_width;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pp_lum_matrix;
   unsigned int pp_rot_matrix_0;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pp_rot_matrix_1;
   unsigned int rb3d_stencilrefmask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int rb3d_ropcntl;
   unsigned int rb3d_planemask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int se_vport_xscale;
   unsigned int se_vport_xoffset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int se_vport_yscale;
   unsigned int se_vport_yoffset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int se_vport_zscale;
   unsigned int se_vport_zoffset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int se_cntl_status;
   unsigned int re_top_left;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int re_misc;
 } drm_radeon_context_regs_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   unsigned int se_zbias_factor;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int se_zbias_constant;
 } drm_radeon_context2_regs_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   unsigned int pp_txfilter;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pp_txformat;
   unsigned int pp_txoffset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pp_txcblend;
   unsigned int pp_txablend;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pp_tfactor;
   unsigned int pp_border_color;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_texture_regs_t;
 typedef struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int start;
   unsigned int finish;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int prim : 8;
   unsigned int stateidx : 8;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int numverts : 16;
   unsigned int vc_format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_prim_t;
 typedef struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_radeon_context_regs_t context;
   drm_radeon_texture_regs_t tex[RADEON_MAX_TEXTURE_UNITS];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_radeon_context2_regs_t context2;
   unsigned int dirty;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_state_t;
 typedef struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_radeon_context_regs_t context_state;
   drm_radeon_texture_regs_t tex_state[RADEON_MAX_TEXTURE_UNITS];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dirty;
   unsigned int vertsize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int vc_format;
   struct drm_clip_rect boxes[RADEON_NR_SAREA_CLIPRECTS];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int nbox;
   unsigned int last_frame;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int last_dispatch;
   unsigned int last_clear;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_tex_region tex_list[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS + 1];
   unsigned int tex_age[RADEON_NR_TEX_HEAPS];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int ctx_owner;
   int pfState;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pfCurrentPage;
   int crtc2_base;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int tiling_enabled;
 } drm_radeon_sarea_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_CP_INIT 0x00
 #define DRM_RADEON_CP_START 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_CP_STOP 0x02
 #define DRM_RADEON_CP_RESET 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_CP_IDLE 0x04
 #define DRM_RADEON_RESET 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_FULLSCREEN 0x06
 #define DRM_RADEON_SWAP 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_CLEAR 0x08
 #define DRM_RADEON_VERTEX 0x09
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_INDICES 0x0A
 #define DRM_RADEON_NOT_USED
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_STIPPLE 0x0C
 #define DRM_RADEON_INDIRECT 0x0D
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_TEXTURE 0x0E
 #define DRM_RADEON_VERTEX2 0x0F
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_CMDBUF 0x10
 #define DRM_RADEON_GETPARAM 0x11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_FLIP 0x12
 #define DRM_RADEON_ALLOC 0x13
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_FREE 0x14
 #define DRM_RADEON_INIT_HEAP 0x15
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_IRQ_EMIT 0x16
 #define DRM_RADEON_IRQ_WAIT 0x17
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_CP_RESUME 0x18
 #define DRM_RADEON_SETPARAM 0x19
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_SURF_ALLOC 0x1a
 #define DRM_RADEON_SURF_FREE 0x1b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_GEM_INFO 0x1c
 #define DRM_RADEON_GEM_CREATE 0x1d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_GEM_MMAP 0x1e
 #define DRM_RADEON_GEM_PREAD 0x21
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_GEM_PWRITE 0x22
 #define DRM_RADEON_GEM_SET_DOMAIN 0x23
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_GEM_WAIT_IDLE 0x24
 #define DRM_RADEON_CS 0x26
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_INFO 0x27
 #define DRM_RADEON_GEM_SET_TILING 0x28
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_GEM_GET_TILING 0x29
 #define DRM_RADEON_GEM_BUSY 0x2a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_GEM_VA 0x2b
 #define DRM_RADEON_GEM_OP 0x2c
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_GEM_USERPTR 0x2d
 #define DRM_IOCTL_RADEON_CP_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_CP_START DRM_IO(DRM_COMMAND_BASE + DRM_RADEON_CP_START)
 #define DRM_IOCTL_RADEON_CP_STOP DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_CP_STOP, drm_radeon_cp_stop_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_CP_RESET DRM_IO(DRM_COMMAND_BASE + DRM_RADEON_CP_RESET)
 #define DRM_IOCTL_RADEON_CP_IDLE DRM_IO(DRM_COMMAND_BASE + DRM_RADEON_CP_IDLE)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_RESET DRM_IO(DRM_COMMAND_BASE + DRM_RADEON_RESET)
 #define DRM_IOCTL_RADEON_FULLSCREEN DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_FULLSCREEN, drm_radeon_fullscreen_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_SWAP DRM_IO(DRM_COMMAND_BASE + DRM_RADEON_SWAP)
 #define DRM_IOCTL_RADEON_CLEAR DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_CLEAR, drm_radeon_clear_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_VERTEX DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_VERTEX, drm_radeon_vertex_t)
 #define DRM_IOCTL_RADEON_INDICES DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_INDICES, drm_radeon_indices_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_STIPPLE DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_STIPPLE, drm_radeon_stipple_t)
 #define DRM_IOCTL_RADEON_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INDIRECT, drm_radeon_indirect_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_TEXTURE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_TEXTURE, drm_radeon_texture_t)
 #define DRM_IOCTL_RADEON_VERTEX2 DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_VERTEX2, drm_radeon_vertex2_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_CMDBUF DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_CMDBUF, drm_radeon_cmd_buffer_t)
 #define DRM_IOCTL_RADEON_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GETPARAM, drm_radeon_getparam_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_FLIP DRM_IO(DRM_COMMAND_BASE + DRM_RADEON_FLIP)
 #define DRM_IOCTL_RADEON_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_ALLOC, drm_radeon_mem_alloc_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_FREE DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_FREE, drm_radeon_mem_free_t)
 #define DRM_IOCTL_RADEON_INIT_HEAP DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_INIT_HEAP, drm_radeon_mem_init_heap_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_IRQ_EMIT, drm_radeon_irq_emit_t)
 #define DRM_IOCTL_RADEON_IRQ_WAIT DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_IRQ_WAIT, drm_radeon_irq_wait_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_CP_RESUME DRM_IO(DRM_COMMAND_BASE + DRM_RADEON_CP_RESUME)
 #define DRM_IOCTL_RADEON_SETPARAM DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_SETPARAM, drm_radeon_setparam_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_SURF_ALLOC DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_SURF_ALLOC, drm_radeon_surface_alloc_t)
 #define DRM_IOCTL_RADEON_SURF_FREE DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_SURF_FREE, drm_radeon_surface_free_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_INFO, struct drm_radeon_gem_info)
 #define DRM_IOCTL_RADEON_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_CREATE, struct drm_radeon_gem_create)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_MMAP, struct drm_radeon_gem_mmap)
 #define DRM_IOCTL_RADEON_GEM_PREAD DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PREAD, struct drm_radeon_gem_pread)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_GEM_PWRITE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PWRITE, struct drm_radeon_gem_pwrite)
 #define DRM_IOCTL_RADEON_GEM_SET_DOMAIN DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_DOMAIN, struct drm_radeon_gem_set_domain)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_GEM_WAIT_IDLE DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_GEM_WAIT_IDLE, struct drm_radeon_gem_wait_idle)
 #define DRM_IOCTL_RADEON_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_CS, struct drm_radeon_cs)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INFO, struct drm_radeon_info)
 #define DRM_IOCTL_RADEON_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling)
 #define DRM_IOCTL_RADEON_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_GEM_VA DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_VA, struct drm_radeon_gem_va)
 #define DRM_IOCTL_RADEON_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_OP, struct drm_radeon_gem_op)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_RADEON_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_USERPTR, struct drm_radeon_gem_userptr)
 typedef struct drm_radeon_init {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum {
     RADEON_INIT_CP = 0x01,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     RADEON_CLEANUP_CP = 0x02,
     RADEON_INIT_R200_CP = 0x03,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     RADEON_INIT_R300_CP = 0x04,
     RADEON_INIT_R600_CP = 0x05
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } func;
   unsigned long sarea_priv_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int is_pci;
   int cp_mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int gart_size;
   int ring_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int usec_timeout;
   unsigned int fb_bpp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int front_offset, front_pitch;
   unsigned int back_offset, back_pitch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int depth_bpp;
   unsigned int depth_offset, depth_pitch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long fb_offset;
   unsigned long mmio_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long ring_offset;
   unsigned long ring_rptr_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long buffers_offset;
   unsigned long gart_textures_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_init_t;
 typedef struct drm_radeon_cp_stop {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int flush;
   int idle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_cp_stop_t;
 typedef struct drm_radeon_fullscreen {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum {
     RADEON_INIT_FULLSCREEN = 0x01,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     RADEON_CLEANUP_FULLSCREEN = 0x02
   } func;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_fullscreen_t;
 #define CLEAR_X1 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CLEAR_Y1 1
 #define CLEAR_X2 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CLEAR_Y2 3
 #define CLEAR_DEPTH 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef union drm_radeon_clear_rect {
   float f[5];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int ui[5];
 } drm_radeon_clear_rect_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_clear {
   unsigned int flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int clear_color;
   unsigned int clear_depth;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int color_mask;
   unsigned int depth_mask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_radeon_clear_rect_t __user * depth_boxes;
 } drm_radeon_clear_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_vertex {
   int prim;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int discard;
 } drm_radeon_vertex_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_indices {
   int prim;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int start;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int end;
   int discard;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_indices_t;
 typedef struct drm_radeon_vertex2 {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int discard;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int nr_states;
   drm_radeon_state_t __user * state;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int nr_prims;
   drm_radeon_prim_t __user * prim;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_vertex2_t;
 typedef struct drm_radeon_cmd_buffer {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int bufsz;
   char __user * buf;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int nbox;
   struct drm_clip_rect __user * boxes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_cmd_buffer_t;
 typedef struct drm_radeon_tex_image {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int x, y;
   unsigned int width, height;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   const void __user * data;
 } drm_radeon_tex_image_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_texture {
   unsigned int offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int pitch;
   int format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int width;
   int height;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_radeon_tex_image_t __user * image;
 } drm_radeon_texture_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_stipple {
   unsigned int __user * mask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_stipple_t;
 typedef struct drm_radeon_indirect {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int idx;
   int start;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int end;
   int discard;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_indirect_t;
 #define RADEON_CARD_PCI 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CARD_AGP 1
 #define RADEON_CARD_PCIE 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_GART_BUFFER_OFFSET 1
 #define RADEON_PARAM_LAST_FRAME 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_LAST_DISPATCH 3
 #define RADEON_PARAM_LAST_CLEAR 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_IRQ_NR 5
 #define RADEON_PARAM_GART_BASE 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_REGISTER_HANDLE 7
 #define RADEON_PARAM_STATUS_HANDLE 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_SAREA_HANDLE 9
 #define RADEON_PARAM_GART_TEX_HANDLE 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_SCRATCH_OFFSET 11
 #define RADEON_PARAM_CARD_TYPE 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_VBLANK_CRTC 13
 #define RADEON_PARAM_FB_LOCATION 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_NUM_GB_PIPES 15
 #define RADEON_PARAM_DEVICE_ID 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_PARAM_NUM_Z_PIPES 17
 typedef struct drm_radeon_getparam {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int param;
   void __user * value;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_getparam_t;
 #define RADEON_MEM_REGION_GART 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_MEM_REGION_FB 2
 typedef struct drm_radeon_mem_alloc {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int region;
   int alignment;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int size;
   int __user * region_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_mem_alloc_t;
 typedef struct drm_radeon_mem_free {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int region;
   int region_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_mem_free_t;
 typedef struct drm_radeon_mem_init_heap {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int region;
   int size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int start;
 } drm_radeon_mem_init_heap_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_irq_emit {
   int __user * irq_seq;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_irq_emit_t;
 typedef struct drm_radeon_irq_wait {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int irq_seq;
 } drm_radeon_irq_wait_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_setparam {
   unsigned int param;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s64 value;
 } drm_radeon_setparam_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_SETPARAM_FB_LOCATION 1
 #define RADEON_SETPARAM_SWITCH_TILING 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_SETPARAM_PCIGART_LOCATION 3
 #define RADEON_SETPARAM_NEW_MEMMAP 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_SETPARAM_PCIGART_TABLE_SIZE 5
 #define RADEON_SETPARAM_VBLANK_CRTC 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_radeon_surface_alloc {
   unsigned int address;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int size;
   unsigned int flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_radeon_surface_alloc_t;
 typedef struct drm_radeon_surface_free {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int address;
 } drm_radeon_surface_free_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_RADEON_VBLANK_CRTC1 1
 #define DRM_RADEON_VBLANK_CRTC2 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_DOMAIN_CPU 0x1
 #define RADEON_GEM_DOMAIN_GTT 0x2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_DOMAIN_VRAM 0x4
 struct drm_radeon_gem_info {
-  uint64_t gart_size;
-  uint64_t vram_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t vram_visible;
+  __u64 gart_size;
+  __u64 vram_size;
+  __u64 vram_visible;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_NO_BACKING_STORE (1 << 0)
 #define RADEON_GEM_GTT_UC (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_GTT_WC (1 << 2)
 #define RADEON_GEM_CPU_ACCESS (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_NO_CPU_ACCESS (1 << 4)
 struct drm_radeon_gem_create {
+  __u64 size;
+  __u64 alignment;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t size;
-  uint64_t alignment;
-  uint32_t handle;
-  uint32_t initial_domain;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t flags;
+  __u32 handle;
+  __u32 initial_domain;
+  __u32 flags;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_USERPTR_READONLY (1 << 0)
 #define RADEON_GEM_USERPTR_ANONONLY (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_USERPTR_VALIDATE (1 << 2)
 #define RADEON_GEM_USERPTR_REGISTER (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_gem_userptr {
-  uint64_t addr;
+  __u64 addr;
+  __u64 size;
+  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t size;
-  uint32_t flags;
-  uint32_t handle;
+  __u32 handle;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_MACRO 0x1
 #define RADEON_TILING_MICRO 0x2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_SWAP_16BIT 0x4
 #define RADEON_TILING_SWAP_32BIT 0x8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_SURFACE 0x10
 #define RADEON_TILING_MICRO_SQUARE 0x20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_EG_BANKW_SHIFT 8
 #define RADEON_TILING_EG_BANKW_MASK 0xf
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_EG_BANKH_SHIFT 12
 #define RADEON_TILING_EG_BANKH_MASK 0xf
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT 16
 #define RADEON_TILING_EG_MACRO_TILE_ASPECT_MASK 0xf
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_EG_TILE_SPLIT_SHIFT 24
 #define RADEON_TILING_EG_TILE_SPLIT_MASK 0xf
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_TILING_EG_STENCIL_TILE_SPLIT_SHIFT 28
 #define RADEON_TILING_EG_STENCIL_TILE_SPLIT_MASK 0xf
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_gem_set_tiling {
-  uint32_t handle;
-  uint32_t tiling_flags;
-  uint32_t pitch;
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 tiling_flags;
+  __u32 pitch;
 };
 struct drm_radeon_gem_get_tiling {
-  uint32_t handle;
-  uint32_t tiling_flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pitch;
+  __u32 handle;
+  __u32 tiling_flags;
+  __u32 pitch;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_gem_mmap {
-  uint32_t handle;
+  __u32 handle;
+  __u32 pad;
+  __u64 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad;
-  uint64_t offset;
-  uint64_t size;
-  uint64_t addr_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 size;
+  __u64 addr_ptr;
 };
 struct drm_radeon_gem_set_domain {
-  uint32_t handle;
-  uint32_t read_domains;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t write_domain;
+  __u32 handle;
+  __u32 read_domains;
+  __u32 write_domain;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_gem_wait_idle {
-  uint32_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad;
+  __u32 handle;
+  __u32 pad;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_gem_busy {
-  uint32_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t domain;
+  __u32 handle;
+  __u32 domain;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_gem_pread {
-  uint32_t handle;
+  __u32 handle;
+  __u32 pad;
+  __u64 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad;
-  uint64_t offset;
-  uint64_t size;
-  uint64_t data_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 size;
+  __u64 data_ptr;
 };
 struct drm_radeon_gem_pwrite {
-  uint32_t handle;
-  uint32_t pad;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t offset;
-  uint64_t size;
-  uint64_t data_ptr;
+  __u32 handle;
+  __u32 pad;
+  __u64 offset;
+  __u64 size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 data_ptr;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_gem_op {
-  uint32_t handle;
-  uint32_t op;
-  uint64_t value;
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 op;
+  __u64 value;
 };
 #define RADEON_GEM_OP_GET_INITIAL_DOMAIN 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_GEM_OP_SET_INITIAL_DOMAIN 1
 #define RADEON_VA_MAP 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_VA_UNMAP 2
 #define RADEON_VA_RESULT_OK 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_VA_RESULT_ERROR 1
 #define RADEON_VA_RESULT_VA_EXIST 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_VM_PAGE_VALID (1 << 0)
 #define RADEON_VM_PAGE_READABLE (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_VM_PAGE_WRITEABLE (1 << 2)
 #define RADEON_VM_PAGE_SYSTEM (1 << 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_VM_PAGE_SNOOPED (1 << 4)
 struct drm_radeon_gem_va {
-  uint32_t handle;
-  uint32_t operation;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t vm_id;
-  uint32_t flags;
-  uint64_t offset;
+  __u32 handle;
+  __u32 operation;
+  __u32 vm_id;
+  __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 offset;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CHUNK_ID_RELOCS 0x01
 #define RADEON_CHUNK_ID_IB 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CHUNK_ID_FLAGS 0x03
 #define RADEON_CHUNK_ID_CONST_IB 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CS_KEEP_TILING_FLAGS 0x01
 #define RADEON_CS_USE_VM 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CS_END_OF_FRAME 0x04
 #define RADEON_CS_RING_GFX 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CS_RING_COMPUTE 1
 #define RADEON_CS_RING_DMA 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_CS_RING_UVD 3
 #define RADEON_CS_RING_VCE 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_cs_chunk {
-  uint32_t chunk_id;
-  uint32_t length_dw;
-  uint64_t chunk_data;
+  __u32 chunk_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 length_dw;
+  __u64 chunk_data;
 };
 #define RADEON_RELOC_PRIO_MASK (0xf << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_cs_reloc {
-  uint32_t handle;
+  __u32 handle;
+  __u32 read_domains;
+  __u32 write_domain;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t read_domains;
-  uint32_t write_domain;
-  uint32_t flags;
+  __u32 flags;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_radeon_cs {
-  uint32_t num_chunks;
-  uint32_t cs_id;
-  uint64_t chunks;
+  __u32 num_chunks;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t gart_limit;
-  uint64_t vram_limit;
+  __u32 cs_id;
+  __u64 chunks;
+  __u64 gart_limit;
+  __u64 vram_limit;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define RADEON_INFO_DEVICE_ID 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_NUM_GB_PIPES 0x01
 #define RADEON_INFO_NUM_Z_PIPES 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_ACCEL_WORKING 0x03
 #define RADEON_INFO_CRTC_FROM_ID 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_ACCEL_WORKING2 0x05
 #define RADEON_INFO_TILING_CONFIG 0x06
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_WANT_HYPERZ 0x07
 #define RADEON_INFO_WANT_CMASK 0x08
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_CLOCK_CRYSTAL_FREQ 0x09
 #define RADEON_INFO_NUM_BACKENDS 0x0a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_NUM_TILE_PIPES 0x0b
 #define RADEON_INFO_FUSION_GART_WORKING 0x0c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_BACKEND_MAP 0x0d
 #define RADEON_INFO_VA_START 0x0e
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_IB_VM_MAX_SIZE 0x0f
 #define RADEON_INFO_MAX_PIPES 0x10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_TIMESTAMP 0x11
 #define RADEON_INFO_MAX_SE 0x12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_MAX_SH_PER_SE 0x13
 #define RADEON_INFO_FASTFB_WORKING 0x14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_RING_WORKING 0x15
 #define RADEON_INFO_SI_TILE_MODE_ARRAY 0x16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_SI_CP_DMA_COMPUTE 0x17
 #define RADEON_INFO_CIK_MACROTILE_MODE_ARRAY 0x18
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_SI_BACKEND_ENABLED_MASK 0x19
 #define RADEON_INFO_MAX_SCLK 0x1a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_VCE_FW_VERSION 0x1b
 #define RADEON_INFO_VCE_FB_VERSION 0x1c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_NUM_BYTES_MOVED 0x1d
 #define RADEON_INFO_VRAM_USAGE 0x1e
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_GTT_USAGE 0x1f
 #define RADEON_INFO_ACTIVE_CU_COUNT 0x20
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_CURRENT_GPU_TEMP 0x21
 #define RADEON_INFO_CURRENT_GPU_SCLK 0x22
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_CURRENT_GPU_MCLK 0x23
 #define RADEON_INFO_READ_REG 0x24
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RADEON_INFO_VA_UNMAP_WORKING 0x25
 #define RADEON_INFO_GPU_RESET_COUNTER 0x26
-struct drm_radeon_info {
-  uint32_t request;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad;
-  uint64_t value;
+struct drm_radeon_info {
+  __u32 request;
+  __u32 pad;
+  __u64 value;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SI_TILE_MODE_COLOR_LINEAR_ALIGNED 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TILE_MODE_COLOR_1D 13
 #define SI_TILE_MODE_COLOR_1D_SCANOUT 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TILE_MODE_COLOR_2D_8BPP 14
 #define SI_TILE_MODE_COLOR_2D_16BPP 15
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TILE_MODE_COLOR_2D_32BPP 16
 #define SI_TILE_MODE_COLOR_2D_64BPP 17
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TILE_MODE_COLOR_2D_SCANOUT_16BPP 11
 #define SI_TILE_MODE_COLOR_2D_SCANOUT_32BPP 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TILE_MODE_DEPTH_STENCIL_1D 4
 #define SI_TILE_MODE_DEPTH_STENCIL_2D 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TILE_MODE_DEPTH_STENCIL_2D_2AA 3
 #define SI_TILE_MODE_DEPTH_STENCIL_2D_4AA 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SI_TILE_MODE_DEPTH_STENCIL_2D_8AA 2
 #define CIK_TILE_MODE_DEPTH_STENCIL_1D 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
 #endif
diff --git a/libc/kernel/uapi/drm/savage_drm.h b/libc/kernel/uapi/drm/savage_drm.h
index eba99a3..a5dd097 100644
--- a/libc/kernel/uapi/drm/savage_drm.h
+++ b/libc/kernel/uapi/drm/savage_drm.h
@@ -18,167 +18,172 @@
  ****************************************************************************/
 #ifndef __SAVAGE_DRM_H__
 #define __SAVAGE_DRM_H__
-#include <drm/drm.h>
-#ifndef __SAVAGE_SAREA_DEFINES__
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifndef __SAVAGE_SAREA_DEFINES__
 #define __SAVAGE_SAREA_DEFINES__
 #define SAVAGE_CARD_HEAP 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_AGP_HEAP 1
 #define SAVAGE_NR_TEX_HEAPS 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_NR_TEX_REGIONS 16
 #define SAVAGE_LOG_MIN_TEX_REGION_SIZE 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 typedef struct _drm_savage_sarea {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_tex_region texList[SAVAGE_NR_TEX_HEAPS][SAVAGE_NR_TEX_REGIONS + 1];
   unsigned int texAge[SAVAGE_NR_TEX_HEAPS];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int ctxOwner;
 } drm_savage_sarea_t, * drm_savage_sarea_ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_SAVAGE_BCI_INIT 0x00
 #define DRM_SAVAGE_BCI_CMDBUF 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_SAVAGE_BCI_EVENT_EMIT 0x02
 #define DRM_SAVAGE_BCI_EVENT_WAIT 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_INIT, drm_savage_init_t)
 #define DRM_IOCTL_SAVAGE_BCI_CMDBUF DRM_IOW(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_CMDBUF, drm_savage_cmdbuf_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_SAVAGE_BCI_EVENT_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_EMIT, drm_savage_event_emit_t)
 #define DRM_IOCTL_SAVAGE_BCI_EVENT_WAIT DRM_IOW(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_WAIT, drm_savage_event_wait_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_DMA_PCI 1
 #define SAVAGE_DMA_AGP 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_savage_init {
   enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     SAVAGE_INIT_BCI = 1,
     SAVAGE_CLEANUP_BCI = 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } func;
   unsigned int sarea_priv_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int cob_size;
   unsigned int bci_threshold_lo, bci_threshold_hi;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int dma_type;
   unsigned int fb_bpp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int front_offset, front_pitch;
   unsigned int back_offset, back_pitch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int depth_bpp;
   unsigned int depth_offset, depth_pitch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int texture_offset;
   unsigned int texture_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long status_offset;
   unsigned long buffers_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long agp_textures_offset;
   unsigned long cmd_dma_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_savage_init_t;
 typedef union drm_savage_cmd_header drm_savage_cmd_header_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_savage_cmdbuf {
   drm_savage_cmd_header_t __user * cmd_addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int size;
   unsigned int dma_idx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int discard;
   unsigned int __user * vb_addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int vb_size;
   unsigned int vb_stride;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_clip_rect __user * box_addr;
   unsigned int nbox;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_savage_cmdbuf_t;
 #define SAVAGE_WAIT_2D 0x1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_WAIT_3D 0x2
 #define SAVAGE_WAIT_IRQ 0x4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct drm_savage_event {
   unsigned int count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int flags;
 } drm_savage_event_emit_t, drm_savage_event_wait_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_CMD_STATE 0
 #define SAVAGE_CMD_DMA_PRIM 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_CMD_VB_PRIM 2
 #define SAVAGE_CMD_DMA_IDX 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_CMD_VB_IDX 4
 #define SAVAGE_CMD_CLEAR 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_CMD_SWAP 6
 #define SAVAGE_PRIM_TRILIST 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_PRIM_TRISTRIP 1
 #define SAVAGE_PRIM_TRIFAN 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_PRIM_TRILIST_201 3
 #define SAVAGE_SKIP_Z 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_SKIP_W 0x02
 #define SAVAGE_SKIP_C0 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_SKIP_C1 0x08
 #define SAVAGE_SKIP_S0 0x10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_SKIP_T0 0x20
 #define SAVAGE_SKIP_ST0 0x30
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_SKIP_S1 0x40
 #define SAVAGE_SKIP_T1 0x80
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_SKIP_ST1 0xc0
 #define SAVAGE_SKIP_ALL_S3D 0x3f
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_SKIP_ALL_S4 0xff
 #define SAVAGE_FRONT 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SAVAGE_BACK 0x2
 #define SAVAGE_DEPTH 0x4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_savage_cmd_header {
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd;
     unsigned char pad0;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned short pad1;
     unsigned short pad2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned short pad3;
   } cmd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char global;
     unsigned short count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned short start;
     unsigned short pad3;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } state;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd;
     unsigned char prim;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned short skip;
     unsigned short count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned short start;
   } prim;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     unsigned char cmd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char prim;
     unsigned short skip;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned short count;
     unsigned short pad3;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } idx;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned char cmd;
     unsigned char pad0;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned short pad1;
     unsigned int flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } clear0;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned int mask;
     unsigned int value;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } clear1;
 };
+#ifdef __cplusplus
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/drm/sis_drm.h b/libc/kernel/uapi/drm/sis_drm.h
index 52054c4..039b589 100644
--- a/libc/kernel/uapi/drm/sis_drm.h
+++ b/libc/kernel/uapi/drm/sis_drm.h
@@ -18,37 +18,43 @@
  ****************************************************************************/
 #ifndef __SIS_DRM_H__
 #define __SIS_DRM_H__
+#include "drm.h"
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define NOT_USED_0_3
 #define DRM_SIS_FB_ALLOC 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_SIS_FB_FREE 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NOT_USED_6_12
 #define DRM_SIS_AGP_INIT 0x13
 #define DRM_SIS_AGP_ALLOC 0x14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_SIS_AGP_FREE 0x15
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_SIS_FB_INIT 0x16
 #define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t)
 #define DRM_IOCTL_SIS_FB_FREE DRM_IOW(DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t)
 #define DRM_IOCTL_SIS_AGP_FREE DRM_IOW(DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t)
 #define DRM_IOCTL_SIS_FB_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int context;
   unsigned long offset;
   unsigned long size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long free;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_sis_mem_t;
 typedef struct {
   unsigned long offset, size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } drm_sis_agp_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   unsigned long offset, size;
 } drm_sis_fb_t;
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+#endif
diff --git a/libc/kernel/uapi/drm/tegra_drm.h b/libc/kernel/uapi/drm/tegra_drm.h
index e5d8b67..2d85a14 100644
--- a/libc/kernel/uapi/drm/tegra_drm.h
+++ b/libc/kernel/uapi/drm/tegra_drm.h
@@ -18,182 +18,187 @@
  ****************************************************************************/
 #ifndef _UAPI_TEGRA_DRM_H_
 #define _UAPI_TEGRA_DRM_H_
-#include <drm/drm.h>
-#define DRM_TEGRA_GEM_CREATE_TILED (1 << 0)
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define DRM_TEGRA_GEM_CREATE_TILED (1 << 0)
 #define DRM_TEGRA_GEM_CREATE_BOTTOM_UP (1 << 1)
 struct drm_tegra_gem_create {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 size;
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 handle;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_gem_mmap {
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
   __u64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_tegra_syncpt_read {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 id;
   __u32 value;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_tegra_syncpt_incr {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 id;
   __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_tegra_syncpt_wait {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 id;
   __u32 thresh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 timeout;
   __u32 value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define DRM_TEGRA_NO_TIMEOUT (0xffffffff)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_open_channel {
   __u32 client;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
   __u64 context;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_tegra_close_channel {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 context;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_get_syncpt {
   __u64 context;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 index;
   __u32 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_tegra_get_syncpt_base {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 context;
   __u32 syncpt;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 id;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_syncpt {
   __u32 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 incrs;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_cmdbuf {
   __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 offset;
   __u32 words;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_reloc {
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 handle;
     __u32 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } cmdbuf;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 handle;
     __u32 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } target;
   __u32 shift;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_waitchk {
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 offset;
   __u32 syncpt;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 thresh;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_submit {
   __u64 context;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 num_syncpts;
   __u32 num_cmdbufs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 num_relocs;
   __u32 num_waitchks;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 waitchk_mask;
   __u32 timeout;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 syncpts;
   __u64 cmdbufs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 relocs;
   __u64 waitchks;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 fence;
   __u32 reserved[5];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define DRM_TEGRA_GEM_TILING_MODE_PITCH 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_GEM_TILING_MODE_TILED 1
 #define DRM_TEGRA_GEM_TILING_MODE_BLOCK 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_gem_set_tiling {
   __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 mode;
   __u32 value;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_gem_get_tiling {
   __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 mode;
   __u32 value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_GEM_BOTTOM_UP (1 << 0)
 #define DRM_TEGRA_GEM_FLAGS (DRM_TEGRA_GEM_BOTTOM_UP)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_gem_set_flags {
   __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_tegra_gem_get_flags {
   __u32 handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_GEM_CREATE 0x00
 #define DRM_TEGRA_GEM_MMAP 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_SYNCPT_READ 0x02
 #define DRM_TEGRA_SYNCPT_INCR 0x03
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_SYNCPT_WAIT 0x04
 #define DRM_TEGRA_OPEN_CHANNEL 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_CLOSE_CHANNEL 0x06
 #define DRM_TEGRA_GET_SYNCPT 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_SUBMIT 0x08
 #define DRM_TEGRA_GET_SYNCPT_BASE 0x09
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_GEM_SET_TILING 0x0a
 #define DRM_TEGRA_GEM_GET_TILING 0x0b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_TEGRA_GEM_SET_FLAGS 0x0c
 #define DRM_TEGRA_GEM_GET_FLAGS 0x0d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
 #define DRM_IOCTL_TEGRA_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_MMAP, struct drm_tegra_gem_mmap)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_TEGRA_SYNCPT_READ DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_READ, struct drm_tegra_syncpt_read)
 #define DRM_IOCTL_TEGRA_SYNCPT_INCR DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_INCR, struct drm_tegra_syncpt_incr)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_TEGRA_SYNCPT_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_WAIT, struct drm_tegra_syncpt_wait)
 #define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
 #define DRM_IOCTL_TEGRA_GET_SYNCPT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT, struct drm_tegra_get_syncpt)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
 #define DRM_IOCTL_TEGRA_GET_SYNCPT_BASE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT_BASE, struct drm_tegra_get_syncpt_base)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_TEGRA_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_TILING, struct drm_tegra_gem_set_tiling)
 #define DRM_IOCTL_TEGRA_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_TILING, struct drm_tegra_gem_get_tiling)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_IOCTL_TEGRA_GEM_SET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_FLAGS, struct drm_tegra_gem_set_flags)
 #define DRM_IOCTL_TEGRA_GEM_GET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_FLAGS, struct drm_tegra_gem_get_flags)
+#ifdef __cplusplus
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/drm/vc4_drm.h b/libc/kernel/uapi/drm/vc4_drm.h
new file mode 100644
index 0000000..6d05b37
--- /dev/null
+++ b/libc/kernel/uapi/drm/vc4_drm.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_VC4_DRM_H_
+#define _UAPI_VC4_DRM_H_
+#include "drm.h"
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define DRM_VC4_SUBMIT_CL 0x00
+#define DRM_VC4_WAIT_SEQNO 0x01
+#define DRM_VC4_WAIT_BO 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_VC4_CREATE_BO 0x03
+#define DRM_VC4_MMAP_BO 0x04
+#define DRM_VC4_CREATE_SHADER_BO 0x05
+#define DRM_VC4_GET_HANG_STATE 0x06
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VC4_SUBMIT_CL DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl)
+#define DRM_IOCTL_VC4_WAIT_SEQNO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno)
+#define DRM_IOCTL_VC4_WAIT_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_BO, struct drm_vc4_wait_bo)
+#define DRM_IOCTL_VC4_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VC4_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo)
+#define DRM_IOCTL_VC4_CREATE_SHADER_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_SHADER_BO, struct drm_vc4_create_shader_bo)
+#define DRM_IOCTL_VC4_GET_HANG_STATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_HANG_STATE, struct drm_vc4_get_hang_state)
+struct drm_vc4_submit_rcl_surface {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 hindex;
+  __u32 offset;
+  __u16 bits;
+#define VC4_SUBMIT_RCL_SURFACE_READ_IS_FULL_RES (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 flags;
+};
+struct drm_vc4_submit_cl {
+  __u64 bin_cl;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 shader_rec;
+  __u64 uniforms;
+  __u64 bo_handles;
+  __u32 bin_cl_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 shader_rec_size;
+  __u32 shader_rec_count;
+  __u32 uniforms_size;
+  __u32 bo_handle_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 width;
+  __u16 height;
+  __u8 min_x_tile;
+  __u8 min_y_tile;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 max_x_tile;
+  __u8 max_y_tile;
+  struct drm_vc4_submit_rcl_surface color_read;
+  struct drm_vc4_submit_rcl_surface color_write;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct drm_vc4_submit_rcl_surface zs_read;
+  struct drm_vc4_submit_rcl_surface zs_write;
+  struct drm_vc4_submit_rcl_surface msaa_color_write;
+  struct drm_vc4_submit_rcl_surface msaa_zs_write;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 clear_color[2];
+  __u32 clear_z;
+  __u8 clear_s;
+  __u32 pad : 24;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VC4_SUBMIT_CL_USE_CLEAR_COLOR (1 << 0)
+  __u32 flags;
+  __u64 seqno;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_vc4_wait_seqno {
+  __u64 seqno;
+  __u64 timeout_ns;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_vc4_wait_bo {
+  __u32 handle;
+  __u32 pad;
+  __u64 timeout_ns;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct drm_vc4_create_bo {
+  __u32 size;
+  __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 pad;
+};
+struct drm_vc4_mmap_bo {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 flags;
+  __u64 offset;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_vc4_create_shader_bo {
+  __u32 size;
+  __u32 flags;
+  __u64 data;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 pad;
+};
+struct drm_vc4_get_hang_state_bo {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 paddr;
+  __u32 size;
+  __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct drm_vc4_get_hang_state {
+  __u64 bo;
+  __u32 bo_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 start_bin, start_render;
+  __u32 ct0ca, ct0ea;
+  __u32 ct1ca, ct1ea;
+  __u32 ct0cs, ct1cs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ct0ra0, ct1ra0;
+  __u32 bpca, bpcs;
+  __u32 bpoa, bpos;
+  __u32 vpmbase;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dbge;
+  __u32 fdbgo;
+  __u32 fdbgb;
+  __u32 fdbgr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 fdbgs;
+  __u32 errstat;
+  __u32 pad[16];
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __cplusplus
+#endif
+#endif
diff --git a/libc/kernel/uapi/drm/via_drm.h b/libc/kernel/uapi/drm/via_drm.h
index 18ac0b6..1eb334e 100644
--- a/libc/kernel/uapi/drm/via_drm.h
+++ b/libc/kernel/uapi/drm/via_drm.h
@@ -18,224 +18,228 @@
  ****************************************************************************/
 #ifndef _VIA_DRM_H_
 #define _VIA_DRM_H_
-#include <drm/drm.h>
+#include "drm.h"
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #ifndef _VIA_DEFINES_
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _VIA_DEFINES_
-#include "via_drmclient.h"
 #define VIA_NR_SAREA_CLIPRECTS 8
-#define VIA_NR_XVMC_PORTS 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIA_NR_XVMC_PORTS 10
 #define VIA_NR_XVMC_LOCKS 5
 #define VIA_MAX_CACHELINE_SIZE 64
 #define XVMCLOCKPTR(saPriv,lockNo) ((volatile struct drm_hw_lock *) (((((unsigned long) (saPriv)->XvMCLockArea) + (VIA_MAX_CACHELINE_SIZE - 1)) & ~(VIA_MAX_CACHELINE_SIZE - 1)) + VIA_MAX_CACHELINE_SIZE * (lockNo)))
-#define VIA_NR_TEX_REGIONS 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIA_NR_TEX_REGIONS 64
 #define VIA_LOG_MIN_TEX_REGION_SIZE 16
 #endif
 #define VIA_UPLOAD_TEX0IMAGE 0x1
-#define VIA_UPLOAD_TEX1IMAGE 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIA_UPLOAD_TEX1IMAGE 0x2
 #define VIA_UPLOAD_CTX 0x4
 #define VIA_UPLOAD_BUFFERS 0x8
 #define VIA_UPLOAD_TEX0 0x10
-#define VIA_UPLOAD_TEX1 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIA_UPLOAD_TEX1 0x20
 #define VIA_UPLOAD_CLIPRECTS 0x40
 #define VIA_UPLOAD_ALL 0xff
 #define DRM_VIA_ALLOCMEM 0x00
-#define DRM_VIA_FREEMEM 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_VIA_FREEMEM 0x01
 #define DRM_VIA_AGP_INIT 0x02
 #define DRM_VIA_FB_INIT 0x03
 #define DRM_VIA_MAP_INIT 0x04
-#define DRM_VIA_DEC_FUTEX 0x05
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_VIA_DEC_FUTEX 0x05
 #define NOT_USED
 #define DRM_VIA_DMA_INIT 0x07
 #define DRM_VIA_CMDBUFFER 0x08
-#define DRM_VIA_FLUSH 0x09
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_VIA_FLUSH 0x09
 #define DRM_VIA_PCICMD 0x0a
 #define DRM_VIA_CMDBUF_SIZE 0x0b
 #define NOT_USED
-#define DRM_VIA_WAIT_IRQ 0x0d
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_VIA_WAIT_IRQ 0x0d
 #define DRM_VIA_DMA_BLIT 0x0e
 #define DRM_VIA_BLIT_SYNC 0x0f
 #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
-#define DRM_IOCTL_VIA_FREEMEM DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VIA_FREEMEM DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
 #define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
 #define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
 #define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
-#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
 #define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
 #define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
 #define DRM_IOCTL_VIA_FLUSH DRM_IO(DRM_COMMAND_BASE + DRM_VIA_FLUSH)
-#define DRM_IOCTL_VIA_PCICMD DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VIA_PCICMD DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
 #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, drm_via_cmdbuf_size_t)
 #define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
 #define DRM_IOCTL_VIA_DMA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
-#define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
 #define VIA_TEX_SETUP_SIZE 8
 #define VIA_FRONT 0x1
 #define VIA_BACK 0x2
-#define VIA_DEPTH 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIA_DEPTH 0x4
 #define VIA_STENCIL 0x8
 #define VIA_MEM_VIDEO 0
 #define VIA_MEM_AGP 1
-#define VIA_MEM_SYSTEM 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIA_MEM_SYSTEM 2
 #define VIA_MEM_MIXED 3
 #define VIA_MEM_UNKNOWN 4
 typedef struct {
-  __u32 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offset;
   __u32 size;
 } drm_via_agp_t;
 typedef struct {
-  __u32 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offset;
   __u32 size;
 } drm_via_fb_t;
 typedef struct {
-  __u32 context;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 context;
   __u32 type;
   __u32 size;
   unsigned long index;
-  unsigned long offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned long offset;
 } drm_via_mem_t;
 typedef struct _drm_via_init {
   enum {
-    VIA_INIT_MAP = 0x01,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    VIA_INIT_MAP = 0x01,
     VIA_CLEANUP_MAP = 0x02
   } func;
   unsigned long sarea_priv_offset;
-  unsigned long fb_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned long fb_offset;
   unsigned long mmio_offset;
   unsigned long agpAddr;
 } drm_via_init_t;
-typedef struct _drm_via_futex {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct _drm_via_futex {
   enum {
     VIA_FUTEX_WAIT = 0x00,
     VIA_FUTEX_WAKE = 0X01
-  } func;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  } func;
   __u32 ms;
   __u32 lock;
   __u32 val;
-} drm_via_futex_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} drm_via_futex_t;
 typedef struct _drm_via_dma_init {
   enum {
     VIA_INIT_DMA = 0x01,
-    VIA_CLEANUP_DMA = 0x02,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    VIA_CLEANUP_DMA = 0x02,
     VIA_DMA_INITIALIZED = 0x03
   } func;
   unsigned long offset;
-  unsigned long size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned long size;
   unsigned long reg_pause_addr;
 } drm_via_dma_init_t;
 typedef struct _drm_via_cmdbuffer {
-  char __user * buf;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char __user * buf;
   unsigned long size;
 } drm_via_cmdbuffer_t;
 typedef struct _drm_via_tex_region {
-  unsigned char next, prev;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char next, prev;
   unsigned char inUse;
   int age;
 } drm_via_tex_region_t;
-typedef struct _drm_via_sarea {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct _drm_via_sarea {
   unsigned int dirty;
   unsigned int nbox;
   struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
-  drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
   int texAge;
   int ctxOwner;
   int vertexPrim;
-  char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
   unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
   unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
   unsigned int XvMCCtxNoGrabbed;
-  unsigned int pfCurrentOffset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int pfCurrentOffset;
 } drm_via_sarea_t;
 typedef struct _drm_via_cmdbuf_size {
   enum {
-    VIA_CMDBUF_SPACE = 0x01,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    VIA_CMDBUF_SPACE = 0x01,
     VIA_CMDBUF_LAG = 0x02
   } func;
   int wait;
-  __u32 size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 size;
 } drm_via_cmdbuf_size_t;
 typedef enum {
   VIA_IRQ_ABSOLUTE = 0x0,
-  VIA_IRQ_RELATIVE = 0x1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  VIA_IRQ_RELATIVE = 0x1,
   VIA_IRQ_SIGNAL = 0x10000000,
   VIA_IRQ_FORCE_SEQUENCE = 0x20000000
 } via_irq_seq_type_t;
-#define VIA_IRQ_FLAGS_MASK 0xF0000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIA_IRQ_FLAGS_MASK 0xF0000000
 enum drm_via_irqs {
   drm_via_irq_hqv0 = 0,
   drm_via_irq_hqv1,
-  drm_via_irq_dma0_dd,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  drm_via_irq_dma0_dd,
   drm_via_irq_dma0_td,
   drm_via_irq_dma1_dd,
   drm_via_irq_dma1_td,
-  drm_via_irq_num
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  drm_via_irq_num
 };
 struct drm_via_wait_irq_request {
   unsigned irq;
-  via_irq_seq_type_t type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  via_irq_seq_type_t type;
   __u32 sequence;
   __u32 signal;
 };
-typedef union drm_via_irqwait {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef union drm_via_irqwait {
   struct drm_via_wait_irq_request request;
   struct drm_wait_vblank_reply reply;
 } drm_via_irqwait_t;
-typedef struct drm_via_blitsync {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct drm_via_blitsync {
   __u32 sync_handle;
   unsigned engine;
 } drm_via_blitsync_t;
-typedef struct drm_via_dmablit {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct drm_via_dmablit {
   __u32 num_lines;
   __u32 line_length;
   __u32 fb_addr;
-  __u32 fb_stride;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 fb_stride;
   unsigned char * mem_addr;
   __u32 mem_stride;
   __u32 flags;
-  int to_fb;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int to_fb;
   drm_via_blitsync_t sync;
 } drm_via_dmablit_t;
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #endif
diff --git a/libc/kernel/uapi/drm/virtgpu_drm.h b/libc/kernel/uapi/drm/virtgpu_drm.h
index 94a82d1..b465662 100644
--- a/libc/kernel/uapi/drm/virtgpu_drm.h
+++ b/libc/kernel/uapi/drm/virtgpu_drm.h
@@ -18,119 +18,123 @@
  ****************************************************************************/
 #ifndef VIRTGPU_DRM_H
 #define VIRTGPU_DRM_H
-#include <stddef.h>
-#include "drm/drm.h"
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define DRM_VIRTGPU_MAP 0x01
 #define DRM_VIRTGPU_EXECBUFFER 0x02
 #define DRM_VIRTGPU_GETPARAM 0x03
-#define DRM_VIRTGPU_RESOURCE_CREATE 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_VIRTGPU_RESOURCE_CREATE 0x04
 #define DRM_VIRTGPU_RESOURCE_INFO 0x05
 #define DRM_VIRTGPU_TRANSFER_FROM_HOST 0x06
 #define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07
-#define DRM_VIRTGPU_WAIT 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_VIRTGPU_WAIT 0x08
 #define DRM_VIRTGPU_GET_CAPS 0x09
 struct drm_virtgpu_map {
-  uint64_t offset;
-  uint32_t handle;
+  __u64 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad;
+  __u32 handle;
+  __u32 pad;
 };
 struct drm_virtgpu_execbuffer {
-  uint32_t flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t size;
-  uint64_t command;
-  uint64_t bo_handles;
-  uint32_t num_bo_handles;
+  __u32 flags;
+  __u32 size;
+  __u64 command;
+  __u64 bo_handles;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad;
+  __u32 num_bo_handles;
+  __u32 pad;
 };
 #define VIRTGPU_PARAM_3D_FEATURES 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_virtgpu_getparam {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t param;
-  uint64_t value;
+  __u64 param;
+  __u64 value;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_virtgpu_resource_create {
+  __u32 target;
+  __u32 format;
+  __u32 bind;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t target;
-  uint32_t format;
-  uint32_t bind;
-  uint32_t width;
+  __u32 width;
+  __u32 height;
+  __u32 depth;
+  __u32 array_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t height;
-  uint32_t depth;
-  uint32_t array_size;
-  uint32_t last_level;
+  __u32 last_level;
+  __u32 nr_samples;
+  __u32 flags;
+  __u32 bo_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t nr_samples;
-  uint32_t flags;
-  uint32_t bo_handle;
-  uint32_t res_handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t size;
-  uint32_t stride;
+  __u32 res_handle;
+  __u32 size;
+  __u32 stride;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_virtgpu_resource_info {
+  __u32 bo_handle;
+  __u32 res_handle;
+  __u32 size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t bo_handle;
-  uint32_t res_handle;
-  uint32_t size;
-  uint32_t stride;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 stride;
 };
 struct drm_virtgpu_3d_box {
-  uint32_t x;
-  uint32_t y;
+  __u32 x;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t z;
-  uint32_t w;
-  uint32_t h;
-  uint32_t d;
+  __u32 y;
+  __u32 z;
+  __u32 w;
+  __u32 h;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 d;
 };
 struct drm_virtgpu_3d_transfer_to_host {
-  uint32_t bo_handle;
-  struct drm_virtgpu_3d_box box;
+  __u32 bo_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t level;
-  uint32_t offset;
+  struct drm_virtgpu_3d_box box;
+  __u32 level;
+  __u32 offset;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_virtgpu_3d_transfer_from_host {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t bo_handle;
+  __u32 bo_handle;
   struct drm_virtgpu_3d_box box;
-  uint32_t level;
-  uint32_t offset;
+  __u32 level;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offset;
 };
 #define VIRTGPU_WAIT_NOWAIT 1
 struct drm_virtgpu_3d_wait {
-  uint32_t handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t flags;
+  __u32 handle;
+  __u32 flags;
 };
 struct drm_virtgpu_get_caps {
-  uint32_t cap_set_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t cap_set_ver;
-  uint64_t addr;
-  uint32_t size;
-  uint32_t pad;
+  __u32 cap_set_id;
+  __u32 cap_set_ver;
+  __u64 addr;
+  __u32 size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pad;
 };
 #define DRM_IOCTL_VIRTGPU_MAP DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
 #define DRM_IOCTL_VIRTGPU_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER, struct drm_virtgpu_execbuffer)
-#define DRM_IOCTL_VIRTGPU_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM, struct drm_virtgpu_getparam)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VIRTGPU_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM, struct drm_virtgpu_getparam)
 #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE, struct drm_virtgpu_resource_create)
 #define DRM_IOCTL_VIRTGPU_RESOURCE_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, struct drm_virtgpu_resource_info)
 #define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST, struct drm_virtgpu_3d_transfer_from_host)
-#define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, struct drm_virtgpu_3d_transfer_to_host)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, struct drm_virtgpu_3d_transfer_to_host)
 #define DRM_IOCTL_VIRTGPU_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT, struct drm_virtgpu_3d_wait)
 #define DRM_IOCTL_VIRTGPU_GET_CAPS DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, struct drm_virtgpu_get_caps)
+#ifdef __cplusplus
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #endif
diff --git a/libc/kernel/uapi/drm/vmwgfx_drm.h b/libc/kernel/uapi/drm/vmwgfx_drm.h
index 26762ab..ead6034 100644
--- a/libc/kernel/uapi/drm/vmwgfx_drm.h
+++ b/libc/kernel/uapi/drm/vmwgfx_drm.h
@@ -18,372 +18,377 @@
  ****************************************************************************/
 #ifndef __VMWGFX_DRM_H__
 #define __VMWGFX_DRM_H__
-#include <drm/drm.h>
-#define DRM_VMW_MAX_SURFACE_FACES 6
+#include "drm.h"
+#ifdef __cplusplus
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#define DRM_VMW_MAX_SURFACE_FACES 6
 #define DRM_VMW_MAX_MIP_LEVELS 24
 #define DRM_VMW_GET_PARAM 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_ALLOC_DMABUF 1
 #define DRM_VMW_UNREF_DMABUF 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_CURSOR_BYPASS 3
 #define DRM_VMW_CONTROL_STREAM 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_CLAIM_STREAM 5
 #define DRM_VMW_UNREF_STREAM 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_CREATE_CONTEXT 7
 #define DRM_VMW_UNREF_CONTEXT 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_CREATE_SURFACE 9
 #define DRM_VMW_UNREF_SURFACE 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_REF_SURFACE 11
 #define DRM_VMW_EXECBUF 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_GET_3D_CAP 13
 #define DRM_VMW_FENCE_WAIT 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_FENCE_SIGNALED 15
 #define DRM_VMW_FENCE_UNREF 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_FENCE_EVENT 17
 #define DRM_VMW_PRESENT 18
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PRESENT_READBACK 19
 #define DRM_VMW_UPDATE_LAYOUT 20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_CREATE_SHADER 21
 #define DRM_VMW_UNREF_SHADER 22
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_GB_SURFACE_CREATE 23
 #define DRM_VMW_GB_SURFACE_REF 24
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_SYNCCPU 25
 #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PARAM_NUM_STREAMS 0
 #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PARAM_3D 2
 #define DRM_VMW_PARAM_HW_CAPS 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PARAM_FIFO_CAPS 4
 #define DRM_VMW_PARAM_MAX_FB_SIZE 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PARAM_FIFO_HW_VERSION 6
 #define DRM_VMW_PARAM_MAX_SURF_MEMORY 7
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PARAM_3D_CAPS_SIZE 8
 #define DRM_VMW_PARAM_MAX_MOB_MEMORY 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PARAM_MAX_MOB_SIZE 10
 #define DRM_VMW_PARAM_SCREEN_TARGET 11
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_PARAM_DX 12
 enum drm_vmw_handle_type {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   DRM_VMW_HANDLE_LEGACY = 0,
   DRM_VMW_HANDLE_PRIME = 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_vmw_getparam_arg {
-  uint64_t value;
-  uint32_t param;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad64;
+  __u64 value;
+  __u32 param;
+  __u32 pad64;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_context_arg {
-  int32_t cid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad64;
+  __s32 cid;
+  __u32 pad64;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_surface_create_req {
-  uint32_t flags;
+  __u32 flags;
+  __u32 format;
+  __u32 mip_levels[DRM_VMW_MAX_SURFACE_FACES];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t format;
-  uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
-  uint64_t size_addr;
-  int32_t shareable;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int32_t scanout;
+  __u64 size_addr;
+  __s32 shareable;
+  __s32 scanout;
 };
-struct drm_vmw_surface_arg {
-  int32_t sid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct drm_vmw_surface_arg {
+  __s32 sid;
   enum drm_vmw_handle_type handle_type;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_size {
-  uint32_t width;
+  __u32 width;
+  __u32 height;
+  __u32 depth;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t height;
-  uint32_t depth;
-  uint32_t pad64;
+  __u32 pad64;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_vmw_surface_create_arg {
   struct drm_vmw_surface_arg rep;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_surface_create_req req;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_vmw_surface_reference_arg {
   struct drm_vmw_surface_create_req rep;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_surface_arg req;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_EXECBUF_VERSION 2
 struct drm_vmw_execbuf_arg {
-  uint64_t commands;
-  uint32_t command_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t throttle_us;
-  uint64_t fence_rep;
-  uint32_t version;
-  uint32_t flags;
+  __u64 commands;
+  __u32 command_size;
+  __u32 throttle_us;
+  __u64 fence_rep;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t context_handle;
-  uint32_t pad64;
+  __u32 version;
+  __u32 flags;
+  __u32 context_handle;
+  __u32 pad64;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_vmw_fence_rep {
+  __u32 handle;
+  __u32 mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t handle;
-  uint32_t mask;
-  uint32_t seqno;
-  uint32_t passed_seqno;
+  __u32 seqno;
+  __u32 passed_seqno;
+  __u32 pad64;
+  __s32 error;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad64;
-  int32_t error;
 };
 struct drm_vmw_alloc_dmabuf_req {
+  __u32 size;
+  __u32 pad64;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t size;
-  uint32_t pad64;
 };
 struct drm_vmw_dmabuf_rep {
+  __u64 map_handle;
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t map_handle;
-  uint32_t handle;
-  uint32_t cur_gmr_id;
-  uint32_t cur_gmr_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad64;
+  __u32 cur_gmr_id;
+  __u32 cur_gmr_offset;
+  __u32 pad64;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_vmw_alloc_dmabuf_arg {
   struct drm_vmw_alloc_dmabuf_req req;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_dmabuf_rep rep;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_unref_dmabuf_arg {
-  uint32_t handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad64;
+  __u32 handle;
+  __u32 pad64;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_rect {
-  int32_t x;
+  __s32 x;
+  __s32 y;
+  __u32 w;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int32_t y;
-  uint32_t w;
-  uint32_t h;
+  __u32 h;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_control_stream_arg {
-  uint32_t stream_id;
-  uint32_t enabled;
-  uint32_t flags;
+  __u32 stream_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t color_key;
-  uint32_t handle;
-  uint32_t offset;
-  int32_t format;
+  __u32 enabled;
+  __u32 flags;
+  __u32 color_key;
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t size;
-  uint32_t width;
-  uint32_t height;
-  uint32_t pitch[3];
+  __u32 offset;
+  __s32 format;
+  __u32 size;
+  __u32 width;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad64;
+  __u32 height;
+  __u32 pitch[3];
+  __u32 pad64;
   struct drm_vmw_rect src;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_rect dst;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_CURSOR_BYPASS_ALL (1 << 0)
 #define DRM_VMW_CURSOR_BYPASS_FLAGS (1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_cursor_bypass_arg {
-  uint32_t flags;
+  __u32 flags;
+  __u32 crtc_id;
+  __s32 xpos;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t crtc_id;
-  int32_t xpos;
-  int32_t ypos;
-  int32_t xhot;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int32_t yhot;
+  __s32 ypos;
+  __s32 xhot;
+  __s32 yhot;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_stream_arg {
-  uint32_t stream_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t pad64;
+  __u32 stream_id;
+  __u32 pad64;
 };
-struct drm_vmw_get_3d_cap_arg {
-  uint64_t buffer;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t max_size;
-  uint32_t pad64;
+struct drm_vmw_get_3d_cap_arg {
+  __u64 buffer;
+  __u32 max_size;
+  __u32 pad64;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define DRM_VMW_FENCE_FLAG_EXEC (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DRM_VMW_FENCE_FLAG_QUERY (1 << 1)
 #define DRM_VMW_WAIT_OPTION_UNREF (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_fence_wait_arg {
-  uint32_t handle;
+  __u32 handle;
+  __s32 cookie_valid;
+  __u64 kernel_cookie;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int32_t cookie_valid;
-  uint64_t kernel_cookie;
-  uint64_t timeout_us;
-  int32_t lazy;
+  __u64 timeout_us;
+  __s32 lazy;
+  __s32 flags;
+  __s32 wait_options;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int32_t flags;
-  int32_t wait_options;
-  int32_t pad64;
+  __s32 pad64;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_fence_signaled_arg {
-  uint32_t handle;
-  uint32_t flags;
-  int32_t signaled;
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t passed_seqno;
-  uint32_t signaled_flags;
-  uint32_t pad64;
+  __u32 flags;
+  __s32 signaled;
+  __u32 passed_seqno;
+  __u32 signaled_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pad64;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_fence_arg {
-  uint32_t handle;
-  uint32_t pad64;
-};
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pad64;
+};
 #define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
 struct drm_vmw_event_fence {
-  struct drm_event base;
-  uint64_t user_data;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t tv_sec;
-  uint32_t tv_usec;
+  struct drm_event base;
+  __u64 user_data;
+  __u32 tv_sec;
+  __u32 tv_usec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define DRM_VMW_FE_FLAG_REQ_TIME (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_fence_event_arg {
-  uint64_t fence_rep;
-  uint64_t user_data;
-  uint32_t handle;
+  __u64 fence_rep;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t flags;
+  __u64 user_data;
+  __u32 handle;
+  __u32 flags;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_present_arg {
-  uint32_t fb_id;
+  __u32 fb_id;
+  __u32 sid;
+  __s32 dest_x;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t sid;
-  int32_t dest_x;
-  int32_t dest_y;
-  uint64_t clips_ptr;
+  __s32 dest_y;
+  __u64 clips_ptr;
+  __u32 num_clips;
+  __u32 pad64;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t num_clips;
-  uint32_t pad64;
 };
 struct drm_vmw_present_readback_arg {
+  __u32 fb_id;
+  __u32 num_clips;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t fb_id;
-  uint32_t num_clips;
-  uint64_t clips_ptr;
-  uint64_t fence_rep;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 clips_ptr;
+  __u64 fence_rep;
 };
 struct drm_vmw_update_layout_arg {
-  uint32_t num_outputs;
-  uint32_t pad64;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t rects;
+  __u32 num_outputs;
+  __u32 pad64;
+  __u64 rects;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_vmw_shader_type {
   drm_vmw_shader_type_vs = 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_vmw_shader_type_ps,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_shader_create_arg {
   enum drm_vmw_shader_type shader_type;
+  __u32 size;
+  __u32 buffer_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t size;
-  uint32_t buffer_handle;
-  uint32_t shader_handle;
-  uint64_t offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 shader_handle;
+  __u64 offset;
 };
 struct drm_vmw_shader_arg {
-  uint32_t handle;
-  uint32_t pad64;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 handle;
+  __u32 pad64;
 };
 enum drm_vmw_surface_flags {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_vmw_surface_flag_shareable = (1 << 0),
   drm_vmw_surface_flag_scanout = (1 << 1),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_vmw_surface_flag_create_buffer = (1 << 2)
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_gb_surface_create_req {
-  uint32_t svga3d_flags;
+  __u32 svga3d_flags;
+  __u32 format;
+  __u32 mip_levels;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t format;
-  uint32_t mip_levels;
   enum drm_vmw_surface_flags drm_surface_flags;
-  uint32_t multisample_count;
+  __u32 multisample_count;
+  __u32 autogen_filter;
+  __u32 buffer_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t autogen_filter;
-  uint32_t buffer_handle;
-  uint32_t array_size;
+  __u32 array_size;
   struct drm_vmw_size base_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct drm_vmw_gb_surface_create_rep {
-  uint32_t handle;
-  uint32_t backup_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint32_t buffer_handle;
-  uint32_t buffer_size;
-  uint64_t buffer_map_handle;
+  __u32 handle;
+  __u32 backup_size;
+  __u32 buffer_handle;
+  __u32 buffer_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 buffer_map_handle;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_vmw_gb_surface_create_arg {
   struct drm_vmw_gb_surface_create_rep rep;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_gb_surface_create_req req;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_gb_surface_ref_rep {
   struct drm_vmw_gb_surface_create_req creq;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_gb_surface_create_rep crep;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_vmw_gb_surface_reference_arg {
   struct drm_vmw_gb_surface_ref_rep rep;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_surface_arg req;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_vmw_synccpu_flags {
   drm_vmw_synccpu_read = (1 << 0),
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_vmw_synccpu_write = (1 << 1),
   drm_vmw_synccpu_dontblock = (1 << 2),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_vmw_synccpu_allow_cs = (1 << 3)
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum drm_vmw_synccpu_op {
   drm_vmw_synccpu_grab,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_vmw_synccpu_release
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct drm_vmw_synccpu_arg {
   enum drm_vmw_synccpu_op op;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   enum drm_vmw_synccpu_flags flags;
-  uint32_t handle;
-  uint32_t pad64;
-};
+  __u32 handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pad64;
+};
 enum drm_vmw_extended_context {
   drm_vmw_context_legacy,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   drm_vmw_context_dx
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union drm_vmw_extended_context_arg {
   enum drm_vmw_extended_context req;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct drm_vmw_context_arg rep;
 };
+#ifdef __cplusplus
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/agpgart.h b/libc/kernel/uapi/linux/agpgart.h
index 0b103cc..586e212 100644
--- a/libc/kernel/uapi/linux/agpgart.h
+++ b/libc/kernel/uapi/linux/agpgart.h
@@ -43,56 +43,57 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #include <linux/types.h>
+#include <stdlib.h>
 struct agp_version {
-  __u16 major;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 major;
   __u16 minor;
 };
 typedef struct _agp_info {
-  struct agp_version version;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct agp_version version;
   __u32 bridge_id;
   __u32 agp_mode;
   unsigned long aper_base;
-  size_t aper_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  size_t aper_size;
   size_t pg_total;
   size_t pg_system;
   size_t pg_used;
-} agp_info;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} agp_info;
 typedef struct _agp_setup {
   __u32 agp_mode;
 } agp_setup;
-typedef struct _agp_segment {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct _agp_segment {
   __kernel_off_t pg_start;
   __kernel_size_t pg_count;
   int prot;
-} agp_segment;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} agp_segment;
 typedef struct _agp_region {
   __kernel_pid_t pid;
   __kernel_size_t seg_count;
-  struct _agp_segment * seg_list;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct _agp_segment * seg_list;
 } agp_region;
 typedef struct _agp_allocate {
   int key;
-  __kernel_size_t pg_count;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __kernel_size_t pg_count;
   __u32 type;
   __u32 physical;
 } agp_allocate;
-typedef struct _agp_bind {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct _agp_bind {
   int key;
   __kernel_off_t pg_start;
 } agp_bind;
-typedef struct _agp_unbind {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct _agp_unbind {
   int key;
   __u32 priority;
 } agp_unbind;
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/android_alarm.h b/libc/kernel/uapi/linux/android_alarm.h
deleted file mode 100644
index 801a01e..0000000
--- a/libc/kernel/uapi/linux/android_alarm.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _UAPI_LINUX_ANDROID_ALARM_H
-#define _UAPI_LINUX_ANDROID_ALARM_H
-#include <linux/ioctl.h>
-#include <linux/time.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum android_alarm_type {
-  ANDROID_ALARM_RTC_WAKEUP,
-  ANDROID_ALARM_RTC,
-  ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  ANDROID_ALARM_ELAPSED_REALTIME,
-  ANDROID_ALARM_SYSTEMTIME,
-  ANDROID_ALARM_TYPE_COUNT,
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum android_alarm_return_flags {
-  ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP,
-  ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC,
-  ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  ANDROID_ALARM_ELAPSED_REALTIME_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME,
-  ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME,
-  ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4))
-#define ANDROID_ALARM_WAIT _IO('a', 1)
-#define ALARM_IOW(c,type,size) _IOW('a', (c) | ((type) << 4), size)
-#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec)
-#define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec)
-#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec)
-#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0)))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4)
-#endif
diff --git a/libc/kernel/uapi/linux/ashmem.h b/libc/kernel/uapi/linux/ashmem.h
index 4711ef3..62ed37e 100644
--- a/libc/kernel/uapi/linux/ashmem.h
+++ b/libc/kernel/uapi/linux/ashmem.h
@@ -19,31 +19,32 @@
 #ifndef _UAPI_LINUX_ASHMEM_H
 #define _UAPI_LINUX_ASHMEM_H
 #include <linux/ioctl.h>
-#define ASHMEM_NAME_LEN 256
+#include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ASHMEM_NAME_LEN 256
 #define ASHMEM_NAME_DEF "dev/ashmem"
 #define ASHMEM_NOT_PURGED 0
 #define ASHMEM_WAS_PURGED 1
-#define ASHMEM_IS_UNPINNED 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ASHMEM_IS_UNPINNED 0
 #define ASHMEM_IS_PINNED 1
 struct ashmem_pin {
   __u32 offset;
-  __u32 len;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 len;
 };
 #define __ASHMEMIOC 0x77
 #define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN])
-#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN])
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN])
 #define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t)
 #define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4)
 #define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long)
-#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6)
 #define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin)
 #define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
 #define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
-#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
 #endif
diff --git a/libc/kernel/uapi/linux/audit.h b/libc/kernel/uapi/linux/audit.h
index 5c4389d..37a31b2 100644
--- a/libc/kernel/uapi/linux/audit.h
+++ b/libc/kernel/uapi/linux/audit.h
@@ -91,325 +91,326 @@
 #define AUDIT_PROCTITLE 1327
 #define AUDIT_FEATURE_CHANGE 1328
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_REPLACE 1329
 #define AUDIT_AVC 1400
 #define AUDIT_SELINUX_ERR 1401
 #define AUDIT_AVC_PATH 1402
-#define AUDIT_MAC_POLICY_LOAD 1403
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_POLICY_LOAD 1403
 #define AUDIT_MAC_STATUS 1404
 #define AUDIT_MAC_CONFIG_CHANGE 1405
 #define AUDIT_MAC_UNLBL_ALLOW 1406
-#define AUDIT_MAC_CIPSOV4_ADD 1407
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_CIPSOV4_ADD 1407
 #define AUDIT_MAC_CIPSOV4_DEL 1408
 #define AUDIT_MAC_MAP_ADD 1409
 #define AUDIT_MAC_MAP_DEL 1410
-#define AUDIT_MAC_IPSEC_ADDSA 1411
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_IPSEC_ADDSA 1411
 #define AUDIT_MAC_IPSEC_DELSA 1412
 #define AUDIT_MAC_IPSEC_ADDSPD 1413
 #define AUDIT_MAC_IPSEC_DELSPD 1414
-#define AUDIT_MAC_IPSEC_EVENT 1415
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAC_IPSEC_EVENT 1415
 #define AUDIT_MAC_UNLBL_STCADD 1416
 #define AUDIT_MAC_UNLBL_STCDEL 1417
 #define AUDIT_FIRST_KERN_ANOM_MSG 1700
-#define AUDIT_LAST_KERN_ANOM_MSG 1799
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_LAST_KERN_ANOM_MSG 1799
 #define AUDIT_ANOM_PROMISCUOUS 1700
 #define AUDIT_ANOM_ABEND 1701
 #define AUDIT_ANOM_LINK 1702
-#define AUDIT_INTEGRITY_DATA 1800
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_INTEGRITY_DATA 1800
 #define AUDIT_INTEGRITY_METADATA 1801
 #define AUDIT_INTEGRITY_STATUS 1802
 #define AUDIT_INTEGRITY_HASH 1803
-#define AUDIT_INTEGRITY_PCR 1804
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_INTEGRITY_PCR 1804
 #define AUDIT_INTEGRITY_RULE 1805
 #define AUDIT_KERNEL 2000
 #define AUDIT_FILTER_USER 0x00
-#define AUDIT_FILTER_TASK 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_FILTER_TASK 0x01
 #define AUDIT_FILTER_ENTRY 0x02
 #define AUDIT_FILTER_WATCH 0x03
 #define AUDIT_FILTER_EXIT 0x04
-#define AUDIT_FILTER_TYPE 0x05
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_FILTER_TYPE 0x05
 #define AUDIT_NR_FILTERS 6
 #define AUDIT_FILTER_PREPEND 0x10
 #define AUDIT_NEVER 0
-#define AUDIT_POSSIBLE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_POSSIBLE 1
 #define AUDIT_ALWAYS 2
 #define AUDIT_MAX_FIELDS 64
 #define AUDIT_MAX_KEY_LEN 256
-#define AUDIT_BITMASK_SIZE 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_BITMASK_SIZE 64
 #define AUDIT_WORD(nr) ((__u32) ((nr) / 32))
 #define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr) * 32))
 #define AUDIT_SYSCALL_CLASSES 16
-#define AUDIT_CLASS_DIR_WRITE 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_CLASS_DIR_WRITE 0
 #define AUDIT_CLASS_DIR_WRITE_32 1
 #define AUDIT_CLASS_CHATTR 2
 #define AUDIT_CLASS_CHATTR_32 3
-#define AUDIT_CLASS_READ 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_CLASS_READ 4
 #define AUDIT_CLASS_READ_32 5
 #define AUDIT_CLASS_WRITE 6
 #define AUDIT_CLASS_WRITE_32 7
-#define AUDIT_CLASS_SIGNAL 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_CLASS_SIGNAL 8
 #define AUDIT_CLASS_SIGNAL_32 9
 #define AUDIT_UNUSED_BITS 0x07FFFC00
 #define AUDIT_COMPARE_UID_TO_OBJ_UID 1
-#define AUDIT_COMPARE_GID_TO_OBJ_GID 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_GID_TO_OBJ_GID 2
 #define AUDIT_COMPARE_EUID_TO_OBJ_UID 3
 #define AUDIT_COMPARE_EGID_TO_OBJ_GID 4
 #define AUDIT_COMPARE_AUID_TO_OBJ_UID 5
-#define AUDIT_COMPARE_SUID_TO_OBJ_UID 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_SUID_TO_OBJ_UID 6
 #define AUDIT_COMPARE_SGID_TO_OBJ_GID 7
 #define AUDIT_COMPARE_FSUID_TO_OBJ_UID 8
 #define AUDIT_COMPARE_FSGID_TO_OBJ_GID 9
-#define AUDIT_COMPARE_UID_TO_AUID 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_UID_TO_AUID 10
 #define AUDIT_COMPARE_UID_TO_EUID 11
 #define AUDIT_COMPARE_UID_TO_FSUID 12
 #define AUDIT_COMPARE_UID_TO_SUID 13
-#define AUDIT_COMPARE_AUID_TO_FSUID 14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_AUID_TO_FSUID 14
 #define AUDIT_COMPARE_AUID_TO_SUID 15
 #define AUDIT_COMPARE_AUID_TO_EUID 16
 #define AUDIT_COMPARE_EUID_TO_SUID 17
-#define AUDIT_COMPARE_EUID_TO_FSUID 18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_EUID_TO_FSUID 18
 #define AUDIT_COMPARE_SUID_TO_FSUID 19
 #define AUDIT_COMPARE_GID_TO_EGID 20
 #define AUDIT_COMPARE_GID_TO_FSGID 21
-#define AUDIT_COMPARE_GID_TO_SGID 22
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_COMPARE_GID_TO_SGID 22
 #define AUDIT_COMPARE_EGID_TO_FSGID 23
 #define AUDIT_COMPARE_EGID_TO_SGID 24
 #define AUDIT_COMPARE_SGID_TO_FSGID 25
-#define AUDIT_MAX_FIELD_COMPARE AUDIT_COMPARE_SGID_TO_FSGID
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MAX_FIELD_COMPARE AUDIT_COMPARE_SGID_TO_FSGID
 #define AUDIT_PID 0
 #define AUDIT_UID 1
 #define AUDIT_EUID 2
-#define AUDIT_SUID 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_SUID 3
 #define AUDIT_FSUID 4
 #define AUDIT_GID 5
 #define AUDIT_EGID 6
-#define AUDIT_SGID 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_SGID 7
 #define AUDIT_FSGID 8
 #define AUDIT_LOGINUID 9
 #define AUDIT_PERS 10
-#define AUDIT_ARCH 11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH 11
 #define AUDIT_MSGTYPE 12
 #define AUDIT_SUBJ_USER 13
 #define AUDIT_SUBJ_ROLE 14
-#define AUDIT_SUBJ_TYPE 15
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_SUBJ_TYPE 15
 #define AUDIT_SUBJ_SEN 16
 #define AUDIT_SUBJ_CLR 17
 #define AUDIT_PPID 18
-#define AUDIT_OBJ_USER 19
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_OBJ_USER 19
 #define AUDIT_OBJ_ROLE 20
 #define AUDIT_OBJ_TYPE 21
 #define AUDIT_OBJ_LEV_LOW 22
-#define AUDIT_OBJ_LEV_HIGH 23
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_OBJ_LEV_HIGH 23
 #define AUDIT_LOGINUID_SET 24
 #define AUDIT_DEVMAJOR 100
 #define AUDIT_DEVMINOR 101
-#define AUDIT_INODE 102
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_INODE 102
 #define AUDIT_EXIT 103
 #define AUDIT_SUCCESS 104
 #define AUDIT_WATCH 105
-#define AUDIT_PERM 106
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_PERM 106
 #define AUDIT_DIR 107
 #define AUDIT_FILETYPE 108
 #define AUDIT_OBJ_UID 109
-#define AUDIT_OBJ_GID 110
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_OBJ_GID 110
 #define AUDIT_FIELD_COMPARE 111
 #define AUDIT_EXE 112
 #define AUDIT_ARG0 200
-#define AUDIT_ARG1 (AUDIT_ARG0 + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARG1 (AUDIT_ARG0 + 1)
 #define AUDIT_ARG2 (AUDIT_ARG0 + 2)
 #define AUDIT_ARG3 (AUDIT_ARG0 + 3)
 #define AUDIT_FILTERKEY 210
-#define AUDIT_NEGATE 0x80000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_NEGATE 0x80000000
 #define AUDIT_BIT_MASK 0x08000000
 #define AUDIT_LESS_THAN 0x10000000
 #define AUDIT_GREATER_THAN 0x20000000
-#define AUDIT_NOT_EQUAL 0x30000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_NOT_EQUAL 0x30000000
 #define AUDIT_EQUAL 0x40000000
 #define AUDIT_BIT_TEST (AUDIT_BIT_MASK | AUDIT_EQUAL)
 #define AUDIT_LESS_THAN_OR_EQUAL (AUDIT_LESS_THAN | AUDIT_EQUAL)
-#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN | AUDIT_EQUAL)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN | AUDIT_EQUAL)
 #define AUDIT_OPERATORS (AUDIT_EQUAL | AUDIT_NOT_EQUAL | AUDIT_BIT_MASK)
 enum {
   Audit_equal,
-  Audit_not_equal,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  Audit_not_equal,
   Audit_bitmask,
   Audit_bittest,
   Audit_lt,
-  Audit_gt,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  Audit_gt,
   Audit_le,
   Audit_ge,
   Audit_bad
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define AUDIT_STATUS_ENABLED 0x0001
 #define AUDIT_STATUS_FAILURE 0x0002
 #define AUDIT_STATUS_PID 0x0004
-#define AUDIT_STATUS_RATE_LIMIT 0x0008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_STATUS_RATE_LIMIT 0x0008
 #define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
 #define AUDIT_STATUS_BACKLOG_WAIT_TIME 0x0020
 #define AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT 0x00000001
-#define AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME 0x00000002
 #define AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH 0x00000004
 #define AUDIT_FEATURE_BITMAP_ALL (AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT | AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME | AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH)
 #define AUDIT_VERSION_LATEST AUDIT_FEATURE_BITMAP_ALL
-#define AUDIT_VERSION_BACKLOG_LIMIT AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_VERSION_BACKLOG_LIMIT AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT
 #define AUDIT_VERSION_BACKLOG_WAIT_TIME AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME
 #define AUDIT_FAIL_SILENT 0
 #define AUDIT_FAIL_PRINTK 1
-#define AUDIT_FAIL_PANIC 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_FAIL_PANIC 2
 #define __AUDIT_ARCH_CONVENTION_MASK 0x30000000
 #define __AUDIT_ARCH_CONVENTION_MIPS64_N32 0x20000000
 #define __AUDIT_ARCH_64BIT 0x80000000
-#define __AUDIT_ARCH_LE 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __AUDIT_ARCH_LE 0x40000000
 #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ALPHA (EM_ALPHA | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARM (EM_ARM | __AUDIT_ARCH_LE)
-#define AUDIT_ARCH_ARMEB (EM_ARM)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_ARMEB (EM_ARM)
 #define AUDIT_ARCH_CRIS (EM_CRIS | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV (EM_FRV)
 #define AUDIT_ARCH_I386 (EM_386 | __AUDIT_ARCH_LE)
-#define AUDIT_ARCH_IA64 (EM_IA_64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_IA64 (EM_IA_64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_M32R (EM_M32R)
 #define AUDIT_ARCH_M68K (EM_68K)
 #define AUDIT_ARCH_MICROBLAZE (EM_MICROBLAZE)
-#define AUDIT_ARCH_MIPS (EM_MIPS)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_MIPS (EM_MIPS)
 #define AUDIT_ARCH_MIPSEL (EM_MIPS | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_MIPS64 (EM_MIPS | __AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_MIPS64N32 (EM_MIPS | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_CONVENTION_MIPS64_N32)
-#define AUDIT_ARCH_MIPSEL64 (EM_MIPS | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_MIPSEL64 (EM_MIPS | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_MIPSEL64N32 (EM_MIPS | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE | __AUDIT_ARCH_CONVENTION_MIPS64_N32)
 #define AUDIT_ARCH_OPENRISC (EM_OPENRISC)
 #define AUDIT_ARCH_PARISC (EM_PARISC)
-#define AUDIT_ARCH_PARISC64 (EM_PARISC | __AUDIT_ARCH_64BIT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_PARISC64 (EM_PARISC | __AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_PPC (EM_PPC)
 #define AUDIT_ARCH_PPC64 (EM_PPC64 | __AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_PPC64LE (EM_PPC64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
-#define AUDIT_ARCH_S390 (EM_S390)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_S390 (EM_S390)
 #define AUDIT_ARCH_S390X (EM_S390 | __AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_SH (EM_SH)
 #define AUDIT_ARCH_SHEL (EM_SH | __AUDIT_ARCH_LE)
-#define AUDIT_ARCH_SH64 (EM_SH | __AUDIT_ARCH_64BIT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_SH64 (EM_SH | __AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_SHEL64 (EM_SH | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_SPARC (EM_SPARC)
 #define AUDIT_ARCH_SPARC64 (EM_SPARCV9 | __AUDIT_ARCH_64BIT)
-#define AUDIT_ARCH_TILEGX (EM_TILEGX | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_ARCH_TILEGX (EM_TILEGX | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEGX32 (EM_TILEGX | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEPRO (EM_TILEPRO | __AUDIT_ARCH_LE)
 #define AUDIT_ARCH_X86_64 (EM_X86_64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
-#define AUDIT_PERM_EXEC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_PERM_EXEC 1
 #define AUDIT_PERM_WRITE 2
 #define AUDIT_PERM_READ 4
 #define AUDIT_PERM_ATTR 8
-#define AUDIT_MESSAGE_TEXT_MAX 8560
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define AUDIT_MESSAGE_TEXT_MAX 8560
 enum audit_nlgrps {
   AUDIT_NLGRP_NONE,
   AUDIT_NLGRP_READLOG,
-  __AUDIT_NLGRP_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __AUDIT_NLGRP_MAX
 };
 #define AUDIT_NLGRP_MAX (__AUDIT_NLGRP_MAX - 1)
 struct audit_status {
-  __u32 mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 mask;
   __u32 enabled;
   __u32 failure;
   __u32 pid;
-  __u32 rate_limit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rate_limit;
   __u32 backlog_limit;
   __u32 lost;
   __u32 backlog;
-  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union {
     __u32 version;
     __u32 feature_bitmap;
   };
-  __u32 backlog_wait_time;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 backlog_wait_time;
 };
 struct audit_features {
 #define AUDIT_FEATURE_VERSION 1
-  __u32 vers;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 vers;
   __u32 mask;
   __u32 features;
   __u32 lock;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define AUDIT_FEATURE_ONLY_UNSET_LOGINUID 0
 #define AUDIT_FEATURE_LOGINUID_IMMUTABLE 1
 #define AUDIT_LAST_FEATURE AUDIT_FEATURE_LOGINUID_IMMUTABLE
-#define audit_feature_valid(x) ((x) >= 0 && (x) <= AUDIT_LAST_FEATURE)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define audit_feature_valid(x) ((x) >= 0 && (x) <= AUDIT_LAST_FEATURE)
 #define AUDIT_FEATURE_TO_MASK(x) (1 << ((x) & 31))
 struct audit_tty_status {
   __u32 enabled;
-  __u32 log_passwd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 log_passwd;
 };
 #define AUDIT_UID_UNSET (unsigned int) - 1
 struct audit_rule_data {
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 action;
   __u32 field_count;
   __u32 mask[AUDIT_BITMASK_SIZE];
-  __u32 fields[AUDIT_MAX_FIELDS];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 fields[AUDIT_MAX_FIELDS];
   __u32 values[AUDIT_MAX_FIELDS];
   __u32 fieldflags[AUDIT_MAX_FIELDS];
   __u32 buflen;
-  char buf[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char buf[0];
 };
 #endif
diff --git a/libc/kernel/uapi/linux/binder.h b/libc/kernel/uapi/linux/binder.h
deleted file mode 100644
index af3cea9..0000000
--- a/libc/kernel/uapi/linux/binder.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _UAPI_LINUX_BINDER_H
-#define _UAPI_LINUX_BINDER_H
-#include <linux/ioctl.h>
-#define B_PACK_CHARS(c1,c2,c3,c4) ((((c1) << 24)) | (((c2) << 16)) | (((c3) << 8)) | (c4))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define B_TYPE_LARGE 0x85
-enum {
-  BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE),
-  BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
-  BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
-  BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum {
-  FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
-  FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifdef BINDER_IPC_32BIT
-typedef __u32 binder_size_t;
-typedef __u32 binder_uintptr_t;
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef __u64 binder_size_t;
-typedef __u64 binder_uintptr_t;
-#endif
-struct flat_binder_object {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 type;
-  __u32 flags;
-  union {
-    binder_uintptr_t binder;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    __u32 handle;
-  };
-  binder_uintptr_t cookie;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct binder_write_read {
-  binder_size_t write_size;
-  binder_size_t write_consumed;
-  binder_uintptr_t write_buffer;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  binder_size_t read_size;
-  binder_size_t read_consumed;
-  binder_uintptr_t read_buffer;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct binder_version {
-  __s32 protocol_version;
-};
-#ifdef BINDER_IPC_32BIT
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BINDER_CURRENT_PROTOCOL_VERSION 7
-#else
-#define BINDER_CURRENT_PROTOCOL_VERSION 8
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
-#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
-#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
-#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32)
-#define BINDER_THREAD_EXIT _IOW('b', 8, __s32)
-#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
-enum transaction_flags {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  TF_ONE_WAY = 0x01,
-  TF_ROOT_OBJECT = 0x04,
-  TF_STATUS_CODE = 0x08,
-  TF_ACCEPT_FDS = 0x10,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct binder_transaction_data {
-  union {
-    __u32 handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    binder_uintptr_t ptr;
-  } target;
-  binder_uintptr_t cookie;
-  __u32 code;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 flags;
-  pid_t sender_pid;
-  uid_t sender_euid;
-  binder_size_t data_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  binder_size_t offsets_size;
-  union {
-    struct {
-      binder_uintptr_t buffer;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-      binder_uintptr_t offsets;
-    } ptr;
-    __u8 buf[8];
-  } data;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct binder_ptr_cookie {
-  binder_uintptr_t ptr;
-  binder_uintptr_t cookie;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct binder_handle_cookie {
-  __u32 handle;
-  binder_uintptr_t cookie;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} __packed;
-struct binder_pri_desc {
-  __s32 priority;
-  __u32 desc;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct binder_pri_ptr_cookie {
-  __s32 priority;
-  binder_uintptr_t ptr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  binder_uintptr_t cookie;
-};
-enum binder_driver_return_protocol {
-  BR_ERROR = _IOR('r', 0, __s32),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BR_OK = _IO('r', 1),
-  BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
-  BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
-  BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BR_DEAD_REPLY = _IO('r', 5),
-  BR_TRANSACTION_COMPLETE = _IO('r', 6),
-  BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
-  BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
-  BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
-  BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
-  BR_NOOP = _IO('r', 12),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BR_SPAWN_LOOPER = _IO('r', 13),
-  BR_FINISHED = _IO('r', 14),
-  BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
-  BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BR_FAILED_REPLY = _IO('r', 17),
-};
-enum binder_driver_command_protocol {
-  BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
-  BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
-  BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
-  BC_INCREFS = _IOW('c', 4, __u32),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BC_ACQUIRE = _IOW('c', 5, __u32),
-  BC_RELEASE = _IOW('c', 6, __u32),
-  BC_DECREFS = _IOW('c', 7, __u32),
-  BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
-  BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
-  BC_REGISTER_LOOPER = _IO('c', 11),
-  BC_ENTER_LOOPER = _IO('c', 12),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  BC_EXIT_LOOPER = _IO('c', 13),
-  BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie),
-  BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie),
-  BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-#endif
diff --git a/libc/kernel/uapi/linux/bpf.h b/libc/kernel/uapi/linux/bpf.h
index 8a21996..44b6b3b 100644
--- a/libc/kernel/uapi/linux/bpf.h
+++ b/libc/kernel/uapi/linux/bpf.h
@@ -87,14 +87,19 @@
   BPF_MAP_TYPE_PROG_ARRAY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_MAP_TYPE_PERF_EVENT_ARRAY,
+  BPF_MAP_TYPE_PERCPU_HASH,
+  BPF_MAP_TYPE_PERCPU_ARRAY,
+  BPF_MAP_TYPE_STACK_TRACE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum bpf_prog_type {
   BPF_PROG_TYPE_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_PROG_TYPE_SOCKET_FILTER,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_PROG_TYPE_KPROBE,
   BPF_PROG_TYPE_SCHED_CLS,
   BPF_PROG_TYPE_SCHED_ACT,
+  BPF_PROG_TYPE_TRACEPOINT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define BPF_PSEUDO_MAP_FD 1
@@ -102,105 +107,144 @@
 #define BPF_NOEXIST 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BPF_EXIST 2
+#define BPF_F_NO_PREALLOC (1U << 0)
 union bpf_attr {
   struct {
-    __u32 map_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u32 map_type;
     __u32 key_size;
     __u32 value_size;
     __u32 max_entries;
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u32 map_flags;
+  };
   struct {
     __u32 map_fd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __aligned_u64 key;
     union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __aligned_u64 value;
       __aligned_u64 next_key;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     };
     __u64 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 prog_type;
     __u32 insn_cnt;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __aligned_u64 insns;
     __aligned_u64 license;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 log_level;
     __u32 log_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __aligned_u64 log_buf;
     __u32 kern_version;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __aligned_u64 pathname;
     __u32 bpf_fd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 } __attribute__((aligned(8)));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum bpf_func_id {
   BPF_FUNC_unspec,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_map_lookup_elem,
   BPF_FUNC_map_update_elem,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_map_delete_elem,
   BPF_FUNC_probe_read,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_ktime_get_ns,
   BPF_FUNC_trace_printk,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_get_prandom_u32,
   BPF_FUNC_get_smp_processor_id,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_skb_store_bytes,
   BPF_FUNC_l3_csum_replace,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_l4_csum_replace,
   BPF_FUNC_tail_call,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_clone_redirect,
   BPF_FUNC_get_current_pid_tgid,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_get_current_uid_gid,
   BPF_FUNC_get_current_comm,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_get_cgroup_classid,
   BPF_FUNC_skb_vlan_push,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_skb_vlan_pop,
   BPF_FUNC_skb_get_tunnel_key,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_skb_set_tunnel_key,
   BPF_FUNC_perf_event_read,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   BPF_FUNC_redirect,
   BPF_FUNC_get_route_realm,
-  BPF_FUNC_perf_event_output,
-  __BPF_FUNC_MAX_ID,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  BPF_FUNC_perf_event_output,
+  BPF_FUNC_skb_load_bytes,
+  BPF_FUNC_get_stackid,
+  BPF_FUNC_csum_diff,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  BPF_FUNC_skb_get_tunnel_opt,
+  BPF_FUNC_skb_set_tunnel_opt,
+  __BPF_FUNC_MAX_ID,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BPF_F_RECOMPUTE_CSUM (1ULL << 0)
+#define BPF_F_INVALIDATE_HASH (1ULL << 1)
+#define BPF_F_HDR_FIELD_MASK 0xfULL
+#define BPF_F_PSEUDO_HDR (1ULL << 4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BPF_F_MARK_MANGLED_0 (1ULL << 5)
+#define BPF_F_INGRESS (1ULL << 0)
+#define BPF_F_TUNINFO_IPV6 (1ULL << 0)
+#define BPF_F_SKIP_FIELD_MASK 0xffULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BPF_F_USER_STACK (1ULL << 8)
+#define BPF_F_FAST_STACK_CMP (1ULL << 9)
+#define BPF_F_REUSE_STACKID (1ULL << 10)
+#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BPF_F_DONT_FRAGMENT (1ULL << 2)
+#define BPF_F_INDEX_MASK 0xffffffffULL
+#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
 struct __sk_buff {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 len;
   __u32 pkt_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 mark;
   __u32 queue_mapping;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 protocol;
   __u32 vlan_present;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vlan_tci;
   __u32 vlan_proto;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 priority;
   __u32 ingress_ifindex;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 ifindex;
   __u32 tc_index;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cb[5];
   __u32 hash;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tc_classid;
+  __u32 data;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 data_end;
 };
 struct bpf_tunnel_key {
   __u32 tunnel_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 remote_ipv4;
+  union {
+    __u32 remote_ipv4;
+    __u32 remote_ipv6[4];
+  };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 tunnel_tos;
+  __u8 tunnel_ttl;
+  __u16 tunnel_ext;
+  __u32 tunnel_label;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
diff --git a/libc/kernel/uapi/linux/btrfs.h b/libc/kernel/uapi/linux/btrfs.h
index 98dacee..1522b92 100644
--- a/libc/kernel/uapi/linux/btrfs.h
+++ b/libc/kernel/uapi/linux/btrfs.h
@@ -23,62 +23,77 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTRFS_IOCTL_MAGIC 0x94
 #define BTRFS_VOL_NAME_MAX 255
+#define BTRFS_LABEL_SIZE 256
 #define BTRFS_PATH_NAME_MAX 4087
-struct btrfs_ioctl_vol_args {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_vol_args {
   __s64 fd;
   char name[BTRFS_PATH_NAME_MAX + 1];
 };
-#define BTRFS_DEVICE_PATH_NAME_MAX 1024
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
-#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
-#define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
+#define BTRFS_DEVICE_PATH_NAME_MAX 1024
+#define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)
+#define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED (BTRFS_SUBVOL_CREATE_ASYNC | BTRFS_SUBVOL_RDONLY | BTRFS_SUBVOL_QGROUP_INHERIT | BTRFS_DEVICE_SPEC_BY_ID)
 #define BTRFS_FSID_SIZE 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTRFS_UUID_SIZE 16
 #define BTRFS_UUID_UNPARSED_SIZE 37
-#define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
-struct btrfs_qgroup_limit {
+#define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
+#define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
+#define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
+#define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4)
+#define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_qgroup_limit {
   __u64 flags;
   __u64 max_rfer;
   __u64 max_excl;
-  __u64 rsv_rfer;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 rsv_rfer;
   __u64 rsv_excl;
 };
+#define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct btrfs_qgroup_inherit {
   __u64 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 num_qgroups;
   __u64 num_ref_copies;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 num_excl_copies;
   struct btrfs_qgroup_limit lim;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 qgroups[0];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct btrfs_ioctl_qgroup_limit_args {
   __u64 qgroupid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct btrfs_qgroup_limit lim;
 };
-#define BTRFS_SUBVOL_NAME_MAX 4039
-struct btrfs_ioctl_vol_args_v2 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
+#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
+#define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
+#define BTRFS_SUBVOL_NAME_MAX 4039
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_vol_args_v2 {
   __s64 fd;
   __u64 transid;
   __u64 flags;
-  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union {
     struct {
       __u64 size;
       struct btrfs_qgroup_inherit __user * qgroup_inherit;
-    };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    };
     __u64 unused[4];
   };
-  char name[BTRFS_SUBVOL_NAME_MAX + 1];
+  union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    char name[BTRFS_SUBVOL_NAME_MAX + 1];
+    __u64 devid;
+  };
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct btrfs_scrub_progress {
@@ -182,340 +197,388 @@
   __u64 reserved[122];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
+#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
+#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
+#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
+#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZOv2 (1ULL << 4)
+#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
+#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
+#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
+#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct btrfs_ioctl_feature_flags {
   __u64 compat_flags;
   __u64 compat_ro_flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 incompat_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define BTRFS_BALANCE_CTL_PAUSE 1
 #define BTRFS_BALANCE_CTL_CANCEL 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct btrfs_balance_args {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 profiles;
   union {
     __le64 usage;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __le32 usage_min;
       __le32 usage_max;
     };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 devid;
   __u64 pstart;
   __u64 pend;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 vstart;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 vend;
   __u64 target;
   __u64 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u64 limit;
     struct {
       __u32 limit_min;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 limit_max;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     };
   };
   __le32 stripes_min;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 stripes_max;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 unused[6];
 } __attribute__((__packed__));
 struct btrfs_balance_progress {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 expected;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 considered;
   __u64 completed;
 };
+#define BTRFS_BALANCE_DATA (1ULL << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BALANCE_SYSTEM (1ULL << 1)
+#define BTRFS_BALANCE_METADATA (1ULL << 2)
+#define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | BTRFS_BALANCE_SYSTEM | BTRFS_BALANCE_METADATA)
+#define BTRFS_BALANCE_FORCE (1ULL << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BALANCE_RESUME (1ULL << 4)
+#define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)
+#define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1)
+#define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3)
+#define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4)
+#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
+#define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
+#define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10)
+#define BTRFS_BALANCE_ARGS_MASK (BTRFS_BALANCE_ARGS_PROFILES | BTRFS_BALANCE_ARGS_USAGE | BTRFS_BALANCE_ARGS_DEVID | BTRFS_BALANCE_ARGS_DRANGE | BTRFS_BALANCE_ARGS_VRANGE | BTRFS_BALANCE_ARGS_LIMIT | BTRFS_BALANCE_ARGS_LIMIT_RANGE | BTRFS_BALANCE_ARGS_STRIPES_RANGE | BTRFS_BALANCE_ARGS_USAGE_RANGE)
+#define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9)
 #define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0)
 #define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1)
 #define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2)
-struct btrfs_ioctl_balance_args {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_balance_args {
   __u64 flags;
   __u64 state;
   struct btrfs_balance_args data;
-  struct btrfs_balance_args meta;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct btrfs_balance_args meta;
   struct btrfs_balance_args sys;
   struct btrfs_balance_progress stat;
   __u64 unused[72];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
 struct btrfs_ioctl_ino_lookup_args {
   __u64 treeid;
-  __u64 objectid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 objectid;
   char name[BTRFS_INO_LOOKUP_PATH_MAX];
 };
 struct btrfs_ioctl_search_key {
-  __u64 tree_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 tree_id;
   __u64 min_objectid;
   __u64 max_objectid;
   __u64 min_offset;
-  __u64 max_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 max_offset;
   __u64 min_transid;
   __u64 max_transid;
   __u32 min_type;
-  __u32 max_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_type;
   __u32 nr_items;
   __u32 unused;
   __u64 unused1;
-  __u64 unused2;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 unused2;
   __u64 unused3;
   __u64 unused4;
 };
-struct btrfs_ioctl_search_header {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_search_header {
   __u64 transid;
   __u64 objectid;
   __u64 offset;
-  __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 type;
   __u32 len;
 };
 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
-struct btrfs_ioctl_search_args {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_search_args {
   struct btrfs_ioctl_search_key key;
   char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
 };
-struct btrfs_ioctl_search_args_v2 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_search_args_v2 {
   struct btrfs_ioctl_search_key key;
   __u64 buf_size;
   __u64 buf[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct btrfs_ioctl_clone_range_args {
   __s64 src_fd;
   __u64 src_offset, src_length;
-  __u64 dest_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 dest_offset;
 };
 #define BTRFS_DEFRAG_RANGE_COMPRESS 1
 #define BTRFS_DEFRAG_RANGE_START_IO 2
-#define BTRFS_SAME_DATA_DIFFERS 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_defrag_range_args {
+  __u64 start;
+  __u64 len;
+  __u64 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 extent_thresh;
+  __u32 compress_type;
+  __u32 unused[4];
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_SAME_DATA_DIFFERS 1
 struct btrfs_ioctl_same_extent_info {
   __s64 fd;
   __u64 logical_offset;
-  __u64 bytes_deduped;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 bytes_deduped;
   __s32 status;
   __u32 reserved;
 };
-struct btrfs_ioctl_same_args {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_same_args {
   __u64 logical_offset;
   __u64 length;
   __u16 dest_count;
-  __u16 reserved1;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 reserved1;
   __u32 reserved2;
   struct btrfs_ioctl_same_extent_info info[0];
 };
-struct btrfs_ioctl_space_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_space_info {
   __u64 flags;
   __u64 total_bytes;
   __u64 used_bytes;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct btrfs_ioctl_space_args {
   __u64 space_slots;
   __u64 total_spaces;
-  struct btrfs_ioctl_space_info spaces[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct btrfs_ioctl_space_info spaces[0];
 };
 struct btrfs_data_container {
   __u32 bytes_left;
-  __u32 bytes_missing;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bytes_missing;
   __u32 elem_cnt;
   __u32 elem_missed;
   __u64 val[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct btrfs_ioctl_ino_path_args {
   __u64 inum;
   __u64 size;
-  __u64 reserved[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 reserved[4];
   __u64 fspath;
 };
 struct btrfs_ioctl_logical_ino_args {
-  __u64 logical;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 logical;
   __u64 size;
   __u64 reserved[4];
   __u64 inodes;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum btrfs_dev_stat_values {
   BTRFS_DEV_STAT_WRITE_ERRS,
   BTRFS_DEV_STAT_READ_ERRS,
-  BTRFS_DEV_STAT_FLUSH_ERRS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  BTRFS_DEV_STAT_FLUSH_ERRS,
   BTRFS_DEV_STAT_CORRUPTION_ERRS,
   BTRFS_DEV_STAT_GENERATION_ERRS,
   BTRFS_DEV_STAT_VALUES_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define BTRFS_DEV_STATS_RESET (1ULL << 0)
 struct btrfs_ioctl_get_dev_stats {
   __u64 devid;
-  __u64 nr_items;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 nr_items;
   __u64 flags;
   __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
   __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define BTRFS_QUOTA_CTL_ENABLE 1
 #define BTRFS_QUOTA_CTL_DISABLE 2
 #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
-struct btrfs_ioctl_quota_ctl_args {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_quota_ctl_args {
   __u64 cmd;
   __u64 status;
 };
-struct btrfs_ioctl_quota_rescan_args {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_ioctl_quota_rescan_args {
   __u64 flags;
   __u64 progress;
   __u64 reserved[6];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct btrfs_ioctl_qgroup_assign_args {
   __u64 assign;
   __u64 src;
-  __u64 dst;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 dst;
 };
 struct btrfs_ioctl_qgroup_create_args {
   __u64 create;
-  __u64 qgroupid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 qgroupid;
 };
 struct btrfs_ioctl_timespec {
   __u64 sec;
-  __u32 nsec;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 nsec;
 };
 struct btrfs_ioctl_received_subvol_args {
   char uuid[BTRFS_UUID_SIZE];
-  __u64 stransid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 stransid;
   __u64 rtransid;
   struct btrfs_ioctl_timespec stime;
   struct btrfs_ioctl_timespec rtime;
-  __u64 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 flags;
   __u64 reserved[16];
 };
 #define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1
-#define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2
 #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4
 #define BTRFS_SEND_FLAG_MASK (BTRFS_SEND_FLAG_NO_FILE_DATA | BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | BTRFS_SEND_FLAG_OMIT_END_CMD)
 struct btrfs_ioctl_send_args {
-  __s64 send_fd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s64 send_fd;
   __u64 clone_sources_count;
   __u64 __user * clone_sources;
   __u64 parent_root;
-  __u64 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 flags;
   __u64 reserved[4];
 };
 enum btrfs_err_code {
-  BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
   BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
   BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
   BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
-  BTRFS_ERROR_DEV_TGT_REPLACE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  BTRFS_ERROR_DEV_TGT_REPLACE,
   BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
   BTRFS_ERROR_DEV_ONLY_WRITABLE,
   BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, struct btrfs_ioctl_vol_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
 #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
 #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
-#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
 #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, struct btrfs_ioctl_clone_range_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, struct btrfs_ioctl_clone_range_args)
 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, struct btrfs_ioctl_vol_args)
 #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, struct btrfs_ioctl_defrag_range_args)
-#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, struct btrfs_ioctl_search_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, struct btrfs_ioctl_search_args)
 #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, struct btrfs_ioctl_search_args_v2)
 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, struct btrfs_ioctl_ino_lookup_args)
 #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
-#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, struct btrfs_ioctl_space_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, struct btrfs_ioctl_space_args)
 #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
 #define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
-#define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
 #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
 #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
 #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, struct btrfs_ioctl_scrub_args)
-#define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
 #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, struct btrfs_ioctl_scrub_args)
 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, struct btrfs_ioctl_dev_info_args)
 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, struct btrfs_ioctl_fs_info_args)
-#define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, struct btrfs_ioctl_balance_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, struct btrfs_ioctl_balance_args)
 #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
 #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, struct btrfs_ioctl_balance_args)
 #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, struct btrfs_ioctl_ino_path_args)
-#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, struct btrfs_ioctl_ino_path_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, struct btrfs_ioctl_ino_path_args)
 #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, struct btrfs_ioctl_received_subvol_args)
 #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
 #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, struct btrfs_ioctl_quota_ctl_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, struct btrfs_ioctl_quota_ctl_args)
 #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, struct btrfs_ioctl_qgroup_assign_args)
 #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, struct btrfs_ioctl_qgroup_create_args)
 #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, struct btrfs_ioctl_qgroup_limit_args)
-#define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, struct btrfs_ioctl_quota_rescan_args)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, struct btrfs_ioctl_quota_rescan_args)
 #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, struct btrfs_ioctl_quota_rescan_args)
 #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
 #define BTRFS_IOC_GET_FSLABEL _IOR(BTRFS_IOCTL_MAGIC, 49, char[BTRFS_LABEL_SIZE])
-#define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, char[BTRFS_LABEL_SIZE])
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, char[BTRFS_LABEL_SIZE])
 #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, struct btrfs_ioctl_get_dev_stats)
 #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, struct btrfs_ioctl_dev_replace_args)
 #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, struct btrfs_ioctl_same_args)
-#define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, struct btrfs_ioctl_feature_flags)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, struct btrfs_ioctl_feature_flags)
 #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, struct btrfs_ioctl_feature_flags[2])
 #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, struct btrfs_ioctl_feature_flags[3])
+#define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, struct btrfs_ioctl_vol_args_v2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/btrfs_tree.h b/libc/kernel/uapi/linux/btrfs_tree.h
new file mode 100644
index 0000000..557574d
--- /dev/null
+++ b/libc/kernel/uapi/linux/btrfs_tree.h
@@ -0,0 +1,518 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _BTRFS_CTREE_H_
+#define _BTRFS_CTREE_H_
+#define BTRFS_ROOT_TREE_OBJECTID 1ULL
+#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_CHUNK_TREE_OBJECTID 3ULL
+#define BTRFS_DEV_TREE_OBJECTID 4ULL
+#define BTRFS_FS_TREE_OBJECTID 5ULL
+#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_CSUM_TREE_OBJECTID 7ULL
+#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
+#define BTRFS_UUID_TREE_OBJECTID 9ULL
+#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_DEV_STATS_OBJECTID 0ULL
+#define BTRFS_BALANCE_OBJECTID - 4ULL
+#define BTRFS_ORPHAN_OBJECTID - 5ULL
+#define BTRFS_TREE_LOG_OBJECTID - 6ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_TREE_LOG_FIXUP_OBJECTID - 7ULL
+#define BTRFS_TREE_RELOC_OBJECTID - 8ULL
+#define BTRFS_DATA_RELOC_TREE_OBJECTID - 9ULL
+#define BTRFS_EXTENT_CSUM_OBJECTID - 10ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FREE_SPACE_OBJECTID - 11ULL
+#define BTRFS_FREE_INO_OBJECTID - 12ULL
+#define BTRFS_MULTIPLE_OBJECTIDS - 255ULL
+#define BTRFS_FIRST_FREE_OBJECTID 256ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_LAST_FREE_OBJECTID - 256ULL
+#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
+#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
+#define BTRFS_BTREE_INODE_OBJECTID 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
+#define BTRFS_DEV_REPLACE_DEVID 0ULL
+#define BTRFS_INODE_ITEM_KEY 1
+#define BTRFS_INODE_REF_KEY 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_INODE_EXTREF_KEY 13
+#define BTRFS_XATTR_ITEM_KEY 24
+#define BTRFS_ORPHAN_ITEM_KEY 48
+#define BTRFS_DIR_LOG_ITEM_KEY 60
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_DIR_LOG_INDEX_KEY 72
+#define BTRFS_DIR_ITEM_KEY 84
+#define BTRFS_DIR_INDEX_KEY 96
+#define BTRFS_EXTENT_DATA_KEY 108
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_EXTENT_CSUM_KEY 128
+#define BTRFS_ROOT_ITEM_KEY 132
+#define BTRFS_ROOT_BACKREF_KEY 144
+#define BTRFS_ROOT_REF_KEY 156
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_EXTENT_ITEM_KEY 168
+#define BTRFS_METADATA_ITEM_KEY 169
+#define BTRFS_TREE_BLOCK_REF_KEY 176
+#define BTRFS_EXTENT_DATA_REF_KEY 178
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_EXTENT_REF_V0_KEY 180
+#define BTRFS_SHARED_BLOCK_REF_KEY 182
+#define BTRFS_SHARED_DATA_REF_KEY 184
+#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FREE_SPACE_INFO_KEY 198
+#define BTRFS_FREE_SPACE_EXTENT_KEY 199
+#define BTRFS_FREE_SPACE_BITMAP_KEY 200
+#define BTRFS_DEV_EXTENT_KEY 204
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_DEV_ITEM_KEY 216
+#define BTRFS_CHUNK_ITEM_KEY 228
+#define BTRFS_QGROUP_STATUS_KEY 240
+#define BTRFS_QGROUP_INFO_KEY 242
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_QGROUP_LIMIT_KEY 244
+#define BTRFS_QGROUP_RELATION_KEY 246
+#define BTRFS_BALANCE_ITEM_KEY 248
+#define BTRFS_TEMPORARY_ITEM_KEY 248
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_DEV_STATS_KEY 249
+#define BTRFS_PERSISTENT_ITEM_KEY 249
+#define BTRFS_DEV_REPLACE_KEY 250
+#if BTRFS_UUID_SIZE != 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#error "UUID items require BTRFS_UUID_SIZE == 16!"
+#endif
+#define BTRFS_UUID_KEY_SUBVOL 251
+#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_STRING_ITEM_KEY 253
+#define BTRFS_CSUM_SIZE 32
+#define BTRFS_CSUM_TYPE_CRC32 0
+#define BTRFS_FT_UNKNOWN 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FT_REG_FILE 1
+#define BTRFS_FT_DIR 2
+#define BTRFS_FT_CHRDEV 3
+#define BTRFS_FT_BLKDEV 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FT_FIFO 5
+#define BTRFS_FT_SOCK 6
+#define BTRFS_FT_SYMLINK 7
+#define BTRFS_FT_XATTR 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FT_MAX 9
+struct btrfs_disk_key {
+  __le64 objectid;
+  __u8 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 offset;
+} __attribute__((__packed__));
+struct btrfs_key {
+  __u64 objectid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 type;
+  __u64 offset;
+} __attribute__((__packed__));
+struct btrfs_dev_item {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 devid;
+  __le64 total_bytes;
+  __le64 bytes_used;
+  __le32 io_align;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 io_width;
+  __le32 sector_size;
+  __le64 type;
+  __le64 generation;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 start_offset;
+  __le32 dev_group;
+  __u8 seek_speed;
+  __u8 bandwidth;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 uuid[BTRFS_UUID_SIZE];
+  __u8 fsid[BTRFS_UUID_SIZE];
+} __attribute__((__packed__));
+struct btrfs_stripe {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 devid;
+  __le64 offset;
+  __u8 dev_uuid[BTRFS_UUID_SIZE];
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_chunk {
+  __le64 length;
+  __le64 owner;
+  __le64 stripe_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 type;
+  __le32 io_align;
+  __le32 io_width;
+  __le32 sector_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le16 num_stripes;
+  __le16 sub_stripes;
+  struct btrfs_stripe stripe;
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FREE_SPACE_EXTENT 1
+#define BTRFS_FREE_SPACE_BITMAP 2
+struct btrfs_free_space_entry {
+  __le64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 bytes;
+  __u8 type;
+} __attribute__((__packed__));
+struct btrfs_free_space_header {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct btrfs_disk_key location;
+  __le64 generation;
+  __le64 num_entries;
+  __le64 num_bitmaps;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
+#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
+#define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
+#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
+struct btrfs_extent_item {
+  __le64 refs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 generation;
+  __le64 flags;
+} __attribute__((__packed__));
+struct btrfs_extent_item_v0 {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 refs;
+} __attribute__((__packed__));
+#define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
+#define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
+#define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
+struct btrfs_tree_block_info {
+  struct btrfs_disk_key key;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 level;
+} __attribute__((__packed__));
+struct btrfs_extent_data_ref {
+  __le64 root;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 objectid;
+  __le64 offset;
+  __le32 count;
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_shared_data_ref {
+  __le32 count;
+} __attribute__((__packed__));
+struct btrfs_extent_inline_ref {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 type;
+  __le64 offset;
+} __attribute__((__packed__));
+struct btrfs_extent_ref_v0 {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 root;
+  __le64 generation;
+  __le64 objectid;
+  __le32 count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+struct btrfs_dev_extent {
+  __le64 chunk_tree;
+  __le64 chunk_objectid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 chunk_offset;
+  __le64 length;
+  __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_inode_ref {
+  __le64 index;
+  __le16 name_len;
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_inode_extref {
+  __le64 parent_objectid;
+  __le64 index;
+  __le16 name_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 name[0];
+} __attribute__((__packed__));
+struct btrfs_timespec {
+  __le64 sec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 nsec;
+} __attribute__((__packed__));
+struct btrfs_inode_item {
+  __le64 generation;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 transid;
+  __le64 size;
+  __le64 nbytes;
+  __le64 block_group;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 nlink;
+  __le32 uid;
+  __le32 gid;
+  __le32 mode;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 rdev;
+  __le64 flags;
+  __le64 sequence;
+  __le64 reserved[4];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct btrfs_timespec atime;
+  struct btrfs_timespec ctime;
+  struct btrfs_timespec mtime;
+  struct btrfs_timespec otime;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+struct btrfs_dir_log_item {
+  __le64 end;
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_dir_item {
+  struct btrfs_disk_key location;
+  __le64 transid;
+  __le16 data_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le16 name_len;
+  __u8 type;
+} __attribute__((__packed__));
+#define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
+struct btrfs_root_item {
+  struct btrfs_inode_item inode;
+  __le64 generation;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 root_dirid;
+  __le64 bytenr;
+  __le64 byte_limit;
+  __le64 bytes_used;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 last_snapshot;
+  __le64 flags;
+  __le32 refs;
+  struct btrfs_disk_key drop_progress;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 drop_level;
+  __u8 level;
+  __le64 generation_v2;
+  __u8 uuid[BTRFS_UUID_SIZE];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 parent_uuid[BTRFS_UUID_SIZE];
+  __u8 received_uuid[BTRFS_UUID_SIZE];
+  __le64 ctransid;
+  __le64 otransid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 stransid;
+  __le64 rtransid;
+  struct btrfs_timespec ctime;
+  struct btrfs_timespec otime;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct btrfs_timespec stime;
+  struct btrfs_timespec rtime;
+  __le64 reserved[8];
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_root_ref {
+  __le64 dirid;
+  __le64 sequence;
+  __le16 name_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+struct btrfs_disk_balance_args {
+  __le64 profiles;
+  union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __le64 usage;
+    struct {
+      __le32 usage_min;
+      __le32 usage_max;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    };
+  };
+  __le64 devid;
+  __le64 pstart;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 pend;
+  __le64 vstart;
+  __le64 vend;
+  __le64 target;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 flags;
+  union {
+    __le64 limit;
+    struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __le32 limit_min;
+      __le32 limit_max;
+    };
+  };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 stripes_min;
+  __le32 stripes_max;
+  __le64 unused[6];
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_balance_item {
+  __le64 flags;
+  struct btrfs_disk_balance_args data;
+  struct btrfs_disk_balance_args meta;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct btrfs_disk_balance_args sys;
+  __le64 unused[4];
+} __attribute__((__packed__));
+#define BTRFS_FILE_EXTENT_INLINE 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_FILE_EXTENT_REG 1
+#define BTRFS_FILE_EXTENT_PREALLOC 2
+struct btrfs_file_extent_item {
+  __le64 generation;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 ram_bytes;
+  __u8 compression;
+  __u8 encryption;
+  __le16 other_encoding;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 type;
+  __le64 disk_bytenr;
+  __le64 disk_num_bytes;
+  __le64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 num_bytes;
+} __attribute__((__packed__));
+struct btrfs_csum_item {
+  __u8 csum;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+struct btrfs_dev_stats_item {
+  __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
+#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
+#define BTRFS_DEV_REPLACE_ITEM_STATE_NEVER_STARTED 0
+#define BTRFS_DEV_REPLACE_ITEM_STATE_STARTED 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_DEV_REPLACE_ITEM_STATE_SUSPENDED 2
+#define BTRFS_DEV_REPLACE_ITEM_STATE_FINISHED 3
+#define BTRFS_DEV_REPLACE_ITEM_STATE_CANCELED 4
+struct btrfs_dev_replace_item {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 src_devid;
+  __le64 cursor_left;
+  __le64 cursor_right;
+  __le64 cont_reading_from_srcdev_mode;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 replace_state;
+  __le64 time_started;
+  __le64 time_stopped;
+  __le64 num_write_errors;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 num_uncorrectable_read_errors;
+} __attribute__((__packed__));
+#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
+#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
+#define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
+#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
+#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
+#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
+#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
+#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_SPACE_INFO_GLOBAL_RSV)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum btrfs_raid_types {
+  BTRFS_RAID_RAID10,
+  BTRFS_RAID_RAID1,
+  BTRFS_RAID_DUP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  BTRFS_RAID_RAID0,
+  BTRFS_RAID_SINGLE,
+  BTRFS_RAID_RAID5,
+  BTRFS_RAID_RAID6,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  BTRFS_NR_RAID_TYPES
+};
+#define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_SYSTEM | BTRFS_BLOCK_GROUP_METADATA)
+#define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 | BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID10)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)
+#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
+#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
+#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | BTRFS_AVAIL_ALLOC_BIT_SINGLE)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_block_group_item {
+  __le64 used;
+  __le64 chunk_objectid;
+  __le64 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+struct btrfs_free_space_info {
+  __le32 extent_count;
+  __le32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+#define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
+#define BTRFS_QGROUP_LEVEL_SHIFT 48
+#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
+#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
+#define BTRFS_QGROUP_STATUS_VERSION 1
+struct btrfs_qgroup_status_item {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 version;
+  __le64 generation;
+  __le64 flags;
+  __le64 rescan;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
+struct btrfs_qgroup_info_item {
+  __le64 generation;
+  __le64 rfer;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 rfer_cmpr;
+  __le64 excl;
+  __le64 excl_cmpr;
+} __attribute__((__packed__));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct btrfs_qgroup_limit_item {
+  __le64 flags;
+  __le64 max_rfer;
+  __le64 max_excl;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le64 rsv_rfer;
+  __le64 rsv_excl;
+} __attribute__((__packed__));
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/if_pppopns.h b/libc/kernel/uapi/linux/coresight-stm.h
similarity index 76%
copy from libc/kernel/uapi/linux/if_pppopns.h
copy to libc/kernel/uapi/linux/coresight-stm.h
index bd96e94..9b5a9e4 100644
--- a/libc/kernel/uapi/linux/if_pppopns.h
+++ b/libc/kernel/uapi/linux/coresight-stm.h
@@ -16,18 +16,14 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _UAPI_LINUX_IF_PPPOPNS_H
-#define _UAPI_LINUX_IF_PPPOPNS_H
-#include <linux/socket.h>
-#include <linux/types.h>
+#ifndef __UAPI_CORESIGHT_STM_H_
+#define __UAPI_CORESIGHT_STM_H_
+#define STM_FLAG_TIMESTAMPED BIT(3)
+#define STM_FLAG_GUARANTEED BIT(7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sockaddr_pppopns {
-  sa_family_t sa_family;
-  unsigned int sa_protocol;
-  int tcp_socket;
+enum {
+  STM_OPTION_GUARANTEED = 0,
+  STM_OPTION_INVARIANT,
+};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 local;
-  __u16 remote;
-} __attribute__((packed));
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/devlink.h b/libc/kernel/uapi/linux/devlink.h
new file mode 100644
index 0000000..4e11eda
--- /dev/null
+++ b/libc/kernel/uapi/linux/devlink.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_LINUX_DEVLINK_H_
+#define _UAPI_LINUX_DEVLINK_H_
+#define DEVLINK_GENL_NAME "devlink"
+#define DEVLINK_GENL_VERSION 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
+enum devlink_command {
+  DEVLINK_CMD_UNSPEC,
+  DEVLINK_CMD_GET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_SET,
+  DEVLINK_CMD_NEW,
+  DEVLINK_CMD_DEL,
+  DEVLINK_CMD_PORT_GET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_PORT_SET,
+  DEVLINK_CMD_PORT_NEW,
+  DEVLINK_CMD_PORT_DEL,
+  DEVLINK_CMD_PORT_SPLIT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_PORT_UNSPLIT,
+  DEVLINK_CMD_SB_GET,
+  DEVLINK_CMD_SB_SET,
+  DEVLINK_CMD_SB_NEW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_SB_DEL,
+  DEVLINK_CMD_SB_POOL_GET,
+  DEVLINK_CMD_SB_POOL_SET,
+  DEVLINK_CMD_SB_POOL_NEW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_SB_POOL_DEL,
+  DEVLINK_CMD_SB_PORT_POOL_GET,
+  DEVLINK_CMD_SB_PORT_POOL_SET,
+  DEVLINK_CMD_SB_PORT_POOL_NEW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_SB_PORT_POOL_DEL,
+  DEVLINK_CMD_SB_TC_POOL_BIND_GET,
+  DEVLINK_CMD_SB_TC_POOL_BIND_SET,
+  DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_SB_TC_POOL_BIND_DEL,
+  DEVLINK_CMD_SB_OCC_SNAPSHOT,
+  DEVLINK_CMD_SB_OCC_MAX_CLEAR,
+  __DEVLINK_CMD_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
+};
+enum devlink_port_type {
+  DEVLINK_PORT_TYPE_NOTSET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_PORT_TYPE_AUTO,
+  DEVLINK_PORT_TYPE_ETH,
+  DEVLINK_PORT_TYPE_IB,
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum devlink_sb_pool_type {
+  DEVLINK_SB_POOL_TYPE_INGRESS,
+  DEVLINK_SB_POOL_TYPE_EGRESS,
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum devlink_sb_threshold_type {
+  DEVLINK_SB_THRESHOLD_TYPE_STATIC,
+  DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC,
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
+enum devlink_attr {
+  DEVLINK_ATTR_UNSPEC,
+  DEVLINK_ATTR_BUS_NAME,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_ATTR_DEV_NAME,
+  DEVLINK_ATTR_PORT_INDEX,
+  DEVLINK_ATTR_PORT_TYPE,
+  DEVLINK_ATTR_PORT_DESIRED_TYPE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_ATTR_PORT_NETDEV_IFINDEX,
+  DEVLINK_ATTR_PORT_NETDEV_NAME,
+  DEVLINK_ATTR_PORT_IBDEV_NAME,
+  DEVLINK_ATTR_PORT_SPLIT_COUNT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_ATTR_PORT_SPLIT_GROUP,
+  DEVLINK_ATTR_SB_INDEX,
+  DEVLINK_ATTR_SB_SIZE,
+  DEVLINK_ATTR_SB_INGRESS_POOL_COUNT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_ATTR_SB_EGRESS_POOL_COUNT,
+  DEVLINK_ATTR_SB_INGRESS_TC_COUNT,
+  DEVLINK_ATTR_SB_EGRESS_TC_COUNT,
+  DEVLINK_ATTR_SB_POOL_INDEX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_ATTR_SB_POOL_TYPE,
+  DEVLINK_ATTR_SB_POOL_SIZE,
+  DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,
+  DEVLINK_ATTR_SB_THRESHOLD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_ATTR_SB_TC_INDEX,
+  DEVLINK_ATTR_SB_OCC_CUR,
+  DEVLINK_ATTR_SB_OCC_MAX,
+  __DEVLINK_ATTR_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
+};
+#endif
diff --git a/libc/kernel/uapi/linux/if_pppopns.h b/libc/kernel/uapi/linux/dma-buf.h
similarity index 72%
copy from libc/kernel/uapi/linux/if_pppopns.h
copy to libc/kernel/uapi/linux/dma-buf.h
index bd96e94..370d65f 100644
--- a/libc/kernel/uapi/linux/if_pppopns.h
+++ b/libc/kernel/uapi/linux/dma-buf.h
@@ -16,18 +16,21 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _UAPI_LINUX_IF_PPPOPNS_H
-#define _UAPI_LINUX_IF_PPPOPNS_H
-#include <linux/socket.h>
+#ifndef _DMA_BUF_UAPI_H_
+#define _DMA_BUF_UAPI_H_
 #include <linux/types.h>
+struct dma_buf_sync {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sockaddr_pppopns {
-  sa_family_t sa_family;
-  unsigned int sa_protocol;
-  int tcp_socket;
+  __u64 flags;
+};
+#define DMA_BUF_SYNC_READ (1 << 0)
+#define DMA_BUF_SYNC_WRITE (2 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 local;
-  __u16 remote;
-} __attribute__((packed));
+#define DMA_BUF_SYNC_RW (DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE)
+#define DMA_BUF_SYNC_START (0 << 2)
+#define DMA_BUF_SYNC_END (1 << 2)
+#define DMA_BUF_SYNC_VALID_FLAGS_MASK (DMA_BUF_SYNC_RW | DMA_BUF_SYNC_END)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DMA_BUF_BASE 'b'
+#define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/dqblk_xfs.h b/libc/kernel/uapi/linux/dqblk_xfs.h
index 396e697..6720db6 100644
--- a/libc/kernel/uapi/linux/dqblk_xfs.h
+++ b/libc/kernel/uapi/linux/dqblk_xfs.h
@@ -37,122 +37,123 @@
 #define Q_XQUOTASYNC XQM_CMD(7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define Q_XGETQSTATV XQM_CMD(8)
+#define Q_XGETNEXTQUOTA XQM_CMD(9)
 #define FS_DQUOT_VERSION 1
 typedef struct fs_disk_quota {
-  __s8 d_version;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s8 d_version;
   __s8 d_flags;
   __u16 d_fieldmask;
   __u32 d_id;
-  __u64 d_blk_hardlimit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 d_blk_hardlimit;
   __u64 d_blk_softlimit;
   __u64 d_ino_hardlimit;
   __u64 d_ino_softlimit;
-  __u64 d_bcount;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 d_bcount;
   __u64 d_icount;
   __s32 d_itimer;
   __s32 d_btimer;
-  __u16 d_iwarns;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 d_iwarns;
   __u16 d_bwarns;
   __s32 d_padding2;
   __u64 d_rtb_hardlimit;
-  __u64 d_rtb_softlimit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 d_rtb_softlimit;
   __u64 d_rtbcount;
   __s32 d_rtbtimer;
   __u16 d_rtbwarns;
-  __s16 d_padding3;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s16 d_padding3;
   char d_padding4[8];
 } fs_disk_quota_t;
 #define FS_DQ_ISOFT (1 << 0)
-#define FS_DQ_IHARD (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_DQ_IHARD (1 << 1)
 #define FS_DQ_BSOFT (1 << 2)
 #define FS_DQ_BHARD (1 << 3)
 #define FS_DQ_RTBSOFT (1 << 4)
-#define FS_DQ_RTBHARD (1 << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_DQ_RTBHARD (1 << 5)
 #define FS_DQ_LIMIT_MASK (FS_DQ_ISOFT | FS_DQ_IHARD | FS_DQ_BSOFT | FS_DQ_BHARD | FS_DQ_RTBSOFT | FS_DQ_RTBHARD)
 #define FS_DQ_BTIMER (1 << 6)
 #define FS_DQ_ITIMER (1 << 7)
-#define FS_DQ_RTBTIMER (1 << 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_DQ_RTBTIMER (1 << 8)
 #define FS_DQ_TIMER_MASK (FS_DQ_BTIMER | FS_DQ_ITIMER | FS_DQ_RTBTIMER)
 #define FS_DQ_BWARNS (1 << 9)
 #define FS_DQ_IWARNS (1 << 10)
-#define FS_DQ_RTBWARNS (1 << 11)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_DQ_RTBWARNS (1 << 11)
 #define FS_DQ_WARNS_MASK (FS_DQ_BWARNS | FS_DQ_IWARNS | FS_DQ_RTBWARNS)
 #define FS_DQ_BCOUNT (1 << 12)
 #define FS_DQ_ICOUNT (1 << 13)
-#define FS_DQ_RTBCOUNT (1 << 14)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_DQ_RTBCOUNT (1 << 14)
 #define FS_DQ_ACCT_MASK (FS_DQ_BCOUNT | FS_DQ_ICOUNT | FS_DQ_RTBCOUNT)
 #define FS_QUOTA_UDQ_ACCT (1 << 0)
 #define FS_QUOTA_UDQ_ENFD (1 << 1)
-#define FS_QUOTA_GDQ_ACCT (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_QUOTA_GDQ_ACCT (1 << 2)
 #define FS_QUOTA_GDQ_ENFD (1 << 3)
 #define FS_QUOTA_PDQ_ACCT (1 << 4)
 #define FS_QUOTA_PDQ_ENFD (1 << 5)
-#define FS_USER_QUOTA (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_USER_QUOTA (1 << 0)
 #define FS_PROJ_QUOTA (1 << 1)
 #define FS_GROUP_QUOTA (1 << 2)
 #define FS_QSTAT_VERSION 1
-typedef struct fs_qfilestat {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef struct fs_qfilestat {
   __u64 qfs_ino;
   __u64 qfs_nblks;
   __u32 qfs_nextents;
-} fs_qfilestat_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} fs_qfilestat_t;
 typedef struct fs_quota_stat {
   __s8 qs_version;
   __u16 qs_flags;
-  __s8 qs_pad;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s8 qs_pad;
   fs_qfilestat_t qs_uquota;
   fs_qfilestat_t qs_gquota;
   __u32 qs_incoredqs;
-  __s32 qs_btimelimit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 qs_btimelimit;
   __s32 qs_itimelimit;
   __s32 qs_rtbtimelimit;
   __u16 qs_bwarnlimit;
-  __u16 qs_iwarnlimit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 qs_iwarnlimit;
 } fs_quota_stat_t;
 #define FS_QSTATV_VERSION1 1
 struct fs_qfilestatv {
-  __u64 qfs_ino;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 qfs_ino;
   __u64 qfs_nblks;
   __u32 qfs_nextents;
   __u32 qfs_pad;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct fs_quota_statv {
   __s8 qs_version;
   __u8 qs_pad1;
-  __u16 qs_flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 qs_flags;
   __u32 qs_incoredqs;
   struct fs_qfilestatv qs_uquota;
   struct fs_qfilestatv qs_gquota;
-  struct fs_qfilestatv qs_pquota;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct fs_qfilestatv qs_pquota;
   __s32 qs_btimelimit;
   __s32 qs_itimelimit;
   __s32 qs_rtbtimelimit;
-  __u16 qs_bwarnlimit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 qs_bwarnlimit;
   __u16 qs_iwarnlimit;
   __u64 qs_pad2[8];
 };
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/dvb/video.h b/libc/kernel/uapi/linux/dvb/video.h
index c8910bd..5e22050 100644
--- a/libc/kernel/uapi/linux/dvb/video.h
+++ b/libc/kernel/uapi/linux/dvb/video.h
@@ -19,188 +19,187 @@
 #ifndef _UAPI_DVBVIDEO_H_
 #define _UAPI_DVBVIDEO_H_
 #include <linux/types.h>
-#include <stdint.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <time.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef enum {
   VIDEO_FORMAT_4_3,
   VIDEO_FORMAT_16_9,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_FORMAT_221_1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_format_t;
 typedef enum {
   VIDEO_SYSTEM_PAL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_SYSTEM_NTSC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_SYSTEM_PALN,
   VIDEO_SYSTEM_PALNc,
   VIDEO_SYSTEM_PALM,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_SYSTEM_NTSC60,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_SYSTEM_PAL60,
   VIDEO_SYSTEM_PALM60
 } video_system_t;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_PAN_SCAN,
   VIDEO_LETTER_BOX,
   VIDEO_CENTER_CUT_OUT
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_displayformat_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
   int w;
   int h;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   video_format_t aspect_ratio;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_size_t;
 typedef enum {
   VIDEO_SOURCE_DEMUX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_SOURCE_MEMORY
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_stream_source_t;
 typedef enum {
   VIDEO_STOPPED,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_PLAYING,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VIDEO_FREEZED
 } video_play_state_t;
 #define VIDEO_CMD_PLAY (0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CMD_STOP (1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CMD_FREEZE (2)
 #define VIDEO_CMD_CONTINUE (3)
 #define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CMD_STOP_TO_BLACK (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1)
 #define VIDEO_PLAY_FMT_NONE (0)
 #define VIDEO_PLAY_FMT_GOP (1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct video_command {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 flags;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 pts;
     } stop;
     struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __s32 speed;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 format;
     } play;
     struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 data[16];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } raw;
   };
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_VSYNC_FIELD_UNKNOWN (0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_VSYNC_FIELD_ODD (1)
 #define VIDEO_VSYNC_FIELD_EVEN (2)
 #define VIDEO_VSYNC_FIELD_PROGRESSIVE (3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct video_event {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 type;
 #define VIDEO_EVENT_SIZE_CHANGED 1
 #define VIDEO_EVENT_FRAME_RATE_CHANGED 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_EVENT_DECODER_STOPPED 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_EVENT_VSYNC 4
   __kernel_time_t timestamp;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     video_size_t size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned int frame_rate;
     unsigned char vsync_field;
   } u;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct video_status {
   int video_blank;
   video_play_state_t play_state;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   video_stream_source_t stream_source;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   video_format_t video_format;
   video_displayformat_t display_format;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct video_still_picture {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char __user * iFrame;
   __s32 size;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct video_highlight {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int active;
   __u8 contrast1;
   __u8 contrast2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 color1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 color2;
   __u32 ypos;
   __u32 xpos;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_highlight_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct video_spu {
   int active;
   int stream_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_spu_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct video_spu_palette {
   int length;
   __u8 __user * palette;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_spu_palette_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct video_navi_pack {
   int length;
   __u8 data[1024];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } video_navi_pack_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef __u16 video_attributes_t;
 #define VIDEO_CAP_MPEG1 1
 #define VIDEO_CAP_MPEG2 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CAP_SYS 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CAP_PROG 8
 #define VIDEO_CAP_SPU 16
 #define VIDEO_CAP_NAVI 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CAP_CSS 64
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_STOP _IO('o', 21)
 #define VIDEO_PLAY _IO('o', 22)
 #define VIDEO_FREEZE _IO('o', 23)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_CONTINUE _IO('o', 24)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_SELECT_SOURCE _IO('o', 25)
 #define VIDEO_SET_BLANK _IO('o', 26)
 #define VIDEO_GET_STATUS _IOR('o', 27, struct video_status)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_GET_EVENT _IOR('o', 28, struct video_event)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29)
 #define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture)
 #define VIDEO_FAST_FORWARD _IO('o', 31)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_SLOWMOTION _IO('o', 32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int)
 #define VIDEO_CLEAR_BUFFER _IO('o', 34)
 #define VIDEO_SET_ID _IO('o', 35)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_SET_STREAMTYPE _IO('o', 36)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_SET_FORMAT _IO('o', 37)
 #define VIDEO_SET_SYSTEM _IO('o', 38)
 #define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_SET_SPU _IOW('o', 50, video_spu_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t)
 #define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t)
 #define VIDEO_SET_ATTRIBUTES _IO('o', 53)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int)
 #define VIDEO_GET_PTS _IOR('o', 57, __u64)
 #define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_COMMAND _IOWR('o', 59, struct video_command)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command)
 #endif
diff --git a/libc/kernel/uapi/linux/elf-em.h b/libc/kernel/uapi/linux/elf-em.h
index 1e372fa..df446d5 100644
--- a/libc/kernel/uapi/linux/elf-em.h
+++ b/libc/kernel/uapi/linux/elf-em.h
@@ -48,27 +48,24 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_S390 22
 #define EM_CRIS 76
-#define EM_V850 87
 #define EM_M32R 88
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_MN10300 89
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_OPENRISC 92
 #define EM_BLACKFIN 106
 #define EM_ALTERA_NIOS2 113
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_TI_C6000 140
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_AARCH64 183
 #define EM_TILEPRO 188
 #define EM_MICROBLAZE 189
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_TILEGX 191
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_FRV 0x5441
 #define EM_AVR32 0x18ad
 #define EM_ALPHA 0x9026
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EM_CYGNUS_V850 0x9080
 #define EM_CYGNUS_M32R 0x9041
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EM_S390_OLD 0xA390
 #define EM_CYGNUS_MN10300 0xbeef
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/elf.h b/libc/kernel/uapi/linux/elf.h
index 27a2f84..fe50a67 100644
--- a/libc/kernel/uapi/linux/elf.h
+++ b/libc/kernel/uapi/linux/elf.h
@@ -298,136 +298,138 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SHF_ALLOC 0x2
 #define SHF_EXECINSTR 0x4
+#define SHF_RELA_LIVEPATCH 0x00100000
 #define SHF_MASKPROC 0xf0000000
-#define SHN_UNDEF 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SHN_UNDEF 0
 #define SHN_LORESERVE 0xff00
 #define SHN_LOPROC 0xff00
 #define SHN_HIPROC 0xff1f
-#define SHN_ABS 0xfff1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SHN_LIVEPATCH 0xff20
+#define SHN_ABS 0xfff1
 #define SHN_COMMON 0xfff2
 #define SHN_HIRESERVE 0xffff
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct elf32_shdr {
   Elf32_Word sh_name;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf32_Word sh_type;
   Elf32_Word sh_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf32_Addr sh_addr;
   Elf32_Off sh_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf32_Word sh_size;
   Elf32_Word sh_link;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf32_Word sh_info;
   Elf32_Word sh_addralign;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf32_Word sh_entsize;
 } Elf32_Shdr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct elf64_shdr {
   Elf64_Word sh_name;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf64_Word sh_type;
   Elf64_Xword sh_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf64_Addr sh_addr;
   Elf64_Off sh_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf64_Xword sh_size;
   Elf64_Word sh_link;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf64_Word sh_info;
   Elf64_Xword sh_addralign;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf64_Xword sh_entsize;
 } Elf64_Shdr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EI_MAG0 0
 #define EI_MAG1 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EI_MAG2 2
 #define EI_MAG3 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EI_CLASS 4
 #define EI_DATA 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EI_VERSION 6
 #define EI_OSABI 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EI_PAD 8
 #define ELFMAG0 0x7f
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELFMAG1 'E'
 #define ELFMAG2 'L'
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELFMAG3 'F'
 #define ELFMAG "\177ELF"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SELFMAG 4
 #define ELFCLASSNONE 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELFCLASS32 1
 #define ELFCLASS64 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELFCLASSNUM 3
 #define ELFDATANONE 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELFDATA2LSB 1
 #define ELFDATA2MSB 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EV_NONE 0
 #define EV_CURRENT 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EV_NUM 2
 #define ELFOSABI_NONE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELFOSABI_LINUX 3
 #ifndef ELF_OSABI
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELF_OSABI ELFOSABI_NONE
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_PRSTATUS 1
 #define NT_PRFPREG 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_PRPSINFO 3
 #define NT_TASKSTRUCT 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_AUXV 6
 #define NT_SIGINFO 0x53494749
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_FILE 0x46494c45
 #define NT_PRXFPREG 0x46e62b7f
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_PPC_VMX 0x100
 #define NT_PPC_SPE 0x101
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_PPC_VSX 0x102
 #define NT_386_TLS 0x200
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_386_IOPERM 0x201
 #define NT_X86_XSTATE 0x202
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_S390_HIGH_GPRS 0x300
 #define NT_S390_TIMER 0x301
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_S390_TODCMP 0x302
 #define NT_S390_TODPREG 0x303
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_S390_CTRS 0x304
 #define NT_S390_PREFIX 0x305
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_S390_LAST_BREAK 0x306
 #define NT_S390_SYSTEM_CALL 0x307
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_S390_TDB 0x308
 #define NT_S390_VXRS_LOW 0x309
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_S390_VXRS_HIGH 0x30a
 #define NT_ARM_VFP 0x400
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_ARM_TLS 0x401
 #define NT_ARM_HW_BREAK 0x402
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_ARM_HW_WATCH 0x403
 #define NT_ARM_SYSTEM_CALL 0x404
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_METAG_CBUF 0x500
 #define NT_METAG_RPIPE 0x501
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NT_METAG_TLS 0x502
 typedef struct elf32_note {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf32_Word n_namesz;
   Elf32_Word n_descsz;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf32_Word n_type;
 } Elf32_Nhdr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct elf64_note {
   Elf64_Word n_namesz;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   Elf64_Word n_descsz;
   Elf64_Word n_type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } Elf64_Nhdr;
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/ethtool.h b/libc/kernel/uapi/linux/ethtool.h
index a2a2da7..30f76da 100644
--- a/libc/kernel/uapi/linux/ethtool.h
+++ b/libc/kernel/uapi/linux/ethtool.h
@@ -18,451 +18,496 @@
  ****************************************************************************/
 #ifndef _UAPI_LINUX_ETHTOOL_H
 #define _UAPI_LINUX_ETHTOOL_H
+#include <linux/kernel.h>
 #include <linux/types.h>
-#include <linux/if_ether.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/if_ether.h>
+#include <limits.h>
 struct ethtool_cmd {
   __u32 cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 supported;
   __u32 advertising;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 speed;
   __u8 duplex;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 port;
   __u8 phy_address;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 transceiver;
   __u8 autoneg;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 mdio_support;
   __u32 maxtxpkt;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 maxrxpkt;
   __u16 speed_hi;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 eth_tp_mdix;
   __u8 eth_tp_mdix_ctrl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 lp_advertising;
   __u32 reserved[2];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define ETH_MDIO_SUPPORTS_C22 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_MDIO_SUPPORTS_C45 2
 #define ETHTOOL_FWVERS_LEN 32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETHTOOL_BUSINFO_LEN 32
 #define ETHTOOL_EROMVERS_LEN 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_drvinfo {
   __u32 cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char driver[32];
   char version[32];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char fw_version[ETHTOOL_FWVERS_LEN];
   char bus_info[ETHTOOL_BUSINFO_LEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char erom_version[ETHTOOL_EROMVERS_LEN];
   char reserved2[12];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 n_priv_flags;
   __u32 n_stats;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 testinfo_len;
   __u32 eedump_len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 regdump_len;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SOPASS_MAX 6
 struct ethtool_wolinfo {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 supported;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 wolopts;
   __u8 sopass[SOPASS_MAX];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ethtool_value {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 data;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum tunable_id {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETHTOOL_ID_UNSPEC,
   ETHTOOL_RX_COPYBREAK,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETHTOOL_TX_COPYBREAK,
   __ETHTOOL_TUNABLE_COUNT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum tunable_type_id {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETHTOOL_TUNABLE_UNSPEC,
   ETHTOOL_TUNABLE_U8,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETHTOOL_TUNABLE_U16,
   ETHTOOL_TUNABLE_U32,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETHTOOL_TUNABLE_U64,
   ETHTOOL_TUNABLE_STRING,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETHTOOL_TUNABLE_S8,
   ETHTOOL_TUNABLE_S16,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETHTOOL_TUNABLE_S32,
   ETHTOOL_TUNABLE_S64,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ethtool_tunable {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type_id;
   __u32 len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   void * data[0];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_regs {
   __u32 cmd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 version;
   __u32 len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 data[0];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_eeprom {
   __u32 cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 magic;
   __u32 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 len;
   __u8 data[0];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ethtool_eee {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 supported;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 advertised;
   __u32 lp_advertised;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 eee_active;
   __u32 eee_enabled;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tx_lpi_enabled;
   __u32 tx_lpi_timer;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[2];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_modinfo {
   __u32 cmd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   __u32 eeprom_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[8];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_coalesce {
   __u32 cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_coalesce_usecs;
   __u32 rx_max_coalesced_frames;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_coalesce_usecs_irq;
   __u32 rx_max_coalesced_frames_irq;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tx_coalesce_usecs;
   __u32 tx_max_coalesced_frames;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tx_coalesce_usecs_irq;
   __u32 tx_max_coalesced_frames_irq;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 stats_block_coalesce_usecs;
   __u32 use_adaptive_rx_coalesce;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 use_adaptive_tx_coalesce;
   __u32 pkt_rate_low;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_coalesce_usecs_low;
   __u32 rx_max_coalesced_frames_low;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tx_coalesce_usecs_low;
   __u32 tx_max_coalesced_frames_low;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pkt_rate_high;
   __u32 rx_coalesce_usecs_high;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_max_coalesced_frames_high;
   __u32 tx_coalesce_usecs_high;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tx_max_coalesced_frames_high;
   __u32 rate_sample_interval;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ethtool_ringparam {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 rx_max_pending;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_mini_max_pending;
   __u32 rx_jumbo_max_pending;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tx_max_pending;
   __u32 rx_pending;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_mini_pending;
   __u32 rx_jumbo_pending;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tx_pending;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_channels {
   __u32 cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 max_rx;
   __u32 max_tx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 max_other;
   __u32 max_combined;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_count;
   __u32 tx_count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 other_count;
   __u32 combined_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ethtool_pauseparam {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 autoneg;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rx_pause;
   __u32 tx_pause;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define ETH_GSTRING_LEN 32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ethtool_stringset {
   ETH_SS_TEST = 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_SS_STATS,
   ETH_SS_PRIV_FLAGS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_SS_NTUPLE_FILTERS,
   ETH_SS_FEATURES,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_SS_RSS_HASH_FUNCS,
   ETH_SS_TUNABLES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ETH_SS_PHY_STATS,
 };
 struct ethtool_gstrings {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 string_set;
   __u32 len;
   __u8 data[0];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_sset_info {
   __u32 cmd;
   __u32 reserved;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 sset_mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 data[0];
 };
 enum ethtool_test_flags {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_TEST_FL_OFFLINE = (1 << 0),
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_TEST_FL_FAILED = (1 << 1),
   ETH_TEST_FL_EXTERNAL_LB = (1 << 2),
   ETH_TEST_FL_EXTERNAL_LB_DONE = (1 << 3),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_test {
   __u32 cmd;
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 len;
   __u64 data[0];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_stats {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cmd;
   __u32 n_stats;
   __u64 data[0];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_perm_addr {
   __u32 cmd;
   __u32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 data[0];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum ethtool_flags {
   ETH_FLAG_TXVLAN = (1 << 7),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_FLAG_RXVLAN = (1 << 8),
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_FLAG_LRO = (1 << 15),
   ETH_FLAG_NTUPLE = (1 << 27),
   ETH_FLAG_RXHASH = (1 << 28),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_tcpip4_spec {
   __be32 ip4src;
   __be32 ip4dst;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be16 psrc;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be16 pdst;
   __u8 tos;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethtool_ah_espip4_spec {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ip4src;
   __be32 ip4dst;
   __be32 spi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 tos;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define ETH_RX_NFC_IP4 1
 struct ethtool_usrip4_spec {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ip4src;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ip4dst;
   __be32 l4_4_bytes;
   __u8 tos;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ip_ver;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 proto;
 };
-union ethtool_flow_union {
+struct ethtool_tcpip6_spec {
+  __be32 ip6src[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be32 ip6dst[4];
+  __be16 psrc;
+  __be16 pdst;
+  __u8 tclass;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct ethtool_ah_espip6_spec {
+  __be32 ip6src[4];
+  __be32 ip6dst[4];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be32 spi;
+  __u8 tclass;
+};
+struct ethtool_usrip6_spec {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be32 ip6src[4];
+  __be32 ip6dst[4];
+  __be32 l4_4_bytes;
+  __u8 tclass;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 l4_proto;
+};
+union ethtool_flow_union {
   struct ethtool_tcpip4_spec tcp_ip4_spec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct ethtool_tcpip4_spec udp_ip4_spec;
   struct ethtool_tcpip4_spec sctp_ip4_spec;
   struct ethtool_ah_espip4_spec ah_ip4_spec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct ethtool_ah_espip4_spec esp_ip4_spec;
-  struct ethtool_usrip4_spec usr_ip4_spec;
-  struct ethhdr ether_spec;
-  __u8 hdata[52];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ethtool_usrip4_spec usr_ip4_spec;
+  struct ethtool_tcpip6_spec tcp_ip6_spec;
+  struct ethtool_tcpip6_spec udp_ip6_spec;
+  struct ethtool_tcpip6_spec sctp_ip6_spec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ethtool_ah_espip6_spec ah_ip6_spec;
+  struct ethtool_ah_espip6_spec esp_ip6_spec;
+  struct ethtool_usrip6_spec usr_ip6_spec;
+  struct ethhdr ether_spec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 hdata[52];
 };
 struct ethtool_flow_ext {
   __u8 padding[2];
-  unsigned char h_dest[ETH_ALEN];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char h_dest[ETH_ALEN];
   __be16 vlan_etype;
   __be16 vlan_tci;
   __be32 data[2];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ethtool_rx_flow_spec {
   __u32 flow_type;
   union ethtool_flow_union h_u;
-  struct ethtool_flow_ext h_ext;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ethtool_flow_ext h_ext;
   union ethtool_flow_union m_u;
   struct ethtool_flow_ext m_ext;
   __u64 ring_cookie;
-  __u32 location;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 location;
 };
 #define ETHTOOL_RX_FLOW_SPEC_RING 0x00000000FFFFFFFFLL
 #define ETHTOOL_RX_FLOW_SPEC_RING_VF 0x000000FF00000000LL
-#define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32
 struct ethtool_rxfh_indir {
   __u32 cmd;
   __u32 size;
-  __u32 ring_index[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ring_index[0];
 };
 struct ethtool_rxfh {
   __u32 cmd;
-  __u32 rss_context;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rss_context;
   __u32 indir_size;
   __u32 key_size;
   __u8 hfunc;
-  __u8 rsvd8[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 rsvd8[3];
   __u32 rsvd32;
   __u32 rss_config[0];
 };
-#define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff
 struct ethtool_rx_ntuple_flow_spec {
   __u32 flow_type;
   union {
-    struct ethtool_tcpip4_spec tcp_ip4_spec;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct ethtool_tcpip4_spec tcp_ip4_spec;
     struct ethtool_tcpip4_spec udp_ip4_spec;
     struct ethtool_tcpip4_spec sctp_ip4_spec;
     struct ethtool_ah_espip4_spec ah_ip4_spec;
-    struct ethtool_ah_espip4_spec esp_ip4_spec;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct ethtool_ah_espip4_spec esp_ip4_spec;
     struct ethtool_usrip4_spec usr_ip4_spec;
     struct ethhdr ether_spec;
     __u8 hdata[72];
-  } h_u, m_u;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  } h_u, m_u;
   __u16 vlan_tag;
   __u16 vlan_tag_mask;
   __u64 data;
-  __u64 data_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 data_mask;
   __s32 action;
 #define ETHTOOL_RXNTUPLE_ACTION_DROP (- 1)
 #define ETHTOOL_RXNTUPLE_ACTION_CLEAR (- 2)
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ethtool_rx_ntuple {
   __u32 cmd;
   struct ethtool_rx_ntuple_flow_spec fs;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define ETHTOOL_FLASH_MAX_FILENAME 128
 enum ethtool_flash_op_type {
   ETHTOOL_FLASH_ALL_REGIONS = 0,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ethtool_flash {
   __u32 cmd;
   __u32 region;
-  char data[ETHTOOL_FLASH_MAX_FILENAME];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char data[ETHTOOL_FLASH_MAX_FILENAME];
 };
 struct ethtool_dump {
   __u32 cmd;
-  __u32 version;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 version;
   __u32 flag;
   __u32 len;
   __u8 data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define ETH_FW_DUMP_DISABLE 0
 struct ethtool_get_features_block {
   __u32 available;
-  __u32 requested;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 requested;
   __u32 active;
   __u32 never_changed;
 };
-struct ethtool_gfeatures {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ethtool_gfeatures {
   __u32 cmd;
   __u32 size;
   struct ethtool_get_features_block features[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ethtool_set_features_block {
   __u32 valid;
   __u32 requested;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ethtool_sfeatures {
   __u32 cmd;
   __u32 size;
-  struct ethtool_set_features_block features[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ethtool_set_features_block features[0];
 };
 struct ethtool_ts_info {
   __u32 cmd;
-  __u32 so_timestamping;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 so_timestamping;
   __s32 phc_index;
   __u32 tx_types;
   __u32 tx_reserved[3];
-  __u32 rx_filters;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rx_filters;
   __u32 rx_reserved[3];
 };
 enum ethtool_sfeatures_retval_bits {
-  ETHTOOL_F_UNSUPPORTED__BIT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ETHTOOL_F_UNSUPPORTED__BIT,
   ETHTOOL_F_WISH__BIT,
   ETHTOOL_F_COMPAT__BIT,
 };
-#define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT)
 #define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT)
 #define ETHTOOL_F_COMPAT (1 << ETHTOOL_F_COMPAT__BIT)
+#define MAX_NUM_QUEUE 4096
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ethtool_per_queue_op {
+  __u32 cmd;
+  __u32 sub_command;
+  __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char data[];
+};
 #define ETHTOOL_GSET 0x00000001
 #define ETHTOOL_SSET 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -553,86 +598,146 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETHTOOL_GTUNABLE 0x00000048
 #define ETHTOOL_STUNABLE 0x00000049
+#define ETHTOOL_GPHYSTATS 0x0000004a
+#define ETHTOOL_PERQUEUE 0x0000004b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETHTOOL_GLINKSETTINGS 0x0000004c
+#define ETHTOOL_SLINKSETTINGS 0x0000004d
 #define SPARC_ETH_GSET ETHTOOL_GSET
 #define SPARC_ETH_SSET ETHTOOL_SSET
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_10baseT_Half (1 << 0)
-#define SUPPORTED_10baseT_Full (1 << 1)
-#define SUPPORTED_100baseT_Half (1 << 2)
-#define SUPPORTED_100baseT_Full (1 << 3)
+enum ethtool_link_mode_bit_indices {
+  ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0,
+  ETHTOOL_LINK_MODE_10baseT_Full_BIT = 1,
+  ETHTOOL_LINK_MODE_100baseT_Half_BIT = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_1000baseT_Half (1 << 4)
-#define SUPPORTED_1000baseT_Full (1 << 5)
-#define SUPPORTED_Autoneg (1 << 6)
-#define SUPPORTED_TP (1 << 7)
+  ETHTOOL_LINK_MODE_100baseT_Full_BIT = 3,
+  ETHTOOL_LINK_MODE_1000baseT_Half_BIT = 4,
+  ETHTOOL_LINK_MODE_1000baseT_Full_BIT = 5,
+  ETHTOOL_LINK_MODE_Autoneg_BIT = 6,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_AUI (1 << 8)
-#define SUPPORTED_MII (1 << 9)
-#define SUPPORTED_FIBRE (1 << 10)
-#define SUPPORTED_BNC (1 << 11)
+  ETHTOOL_LINK_MODE_TP_BIT = 7,
+  ETHTOOL_LINK_MODE_AUI_BIT = 8,
+  ETHTOOL_LINK_MODE_MII_BIT = 9,
+  ETHTOOL_LINK_MODE_FIBRE_BIT = 10,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_10000baseT_Full (1 << 12)
-#define SUPPORTED_Pause (1 << 13)
-#define SUPPORTED_Asym_Pause (1 << 14)
-#define SUPPORTED_2500baseX_Full (1 << 15)
+  ETHTOOL_LINK_MODE_BNC_BIT = 11,
+  ETHTOOL_LINK_MODE_10000baseT_Full_BIT = 12,
+  ETHTOOL_LINK_MODE_Pause_BIT = 13,
+  ETHTOOL_LINK_MODE_Asym_Pause_BIT = 14,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_Backplane (1 << 16)
-#define SUPPORTED_1000baseKX_Full (1 << 17)
-#define SUPPORTED_10000baseKX4_Full (1 << 18)
-#define SUPPORTED_10000baseKR_Full (1 << 19)
+  ETHTOOL_LINK_MODE_2500baseX_Full_BIT = 15,
+  ETHTOOL_LINK_MODE_Backplane_BIT = 16,
+  ETHTOOL_LINK_MODE_1000baseKX_Full_BIT = 17,
+  ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT = 18,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_10000baseR_FEC (1 << 20)
-#define SUPPORTED_20000baseMLD2_Full (1 << 21)
-#define SUPPORTED_20000baseKR2_Full (1 << 22)
-#define SUPPORTED_40000baseKR4_Full (1 << 23)
+  ETHTOOL_LINK_MODE_10000baseKR_Full_BIT = 19,
+  ETHTOOL_LINK_MODE_10000baseR_FEC_BIT = 20,
+  ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 21,
+  ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT = 22,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_40000baseCR4_Full (1 << 24)
-#define SUPPORTED_40000baseSR4_Full (1 << 25)
-#define SUPPORTED_40000baseLR4_Full (1 << 26)
-#define SUPPORTED_56000baseKR4_Full (1 << 27)
+  ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT = 23,
+  ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT = 24,
+  ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT = 25,
+  ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT = 26,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SUPPORTED_56000baseCR4_Full (1 << 28)
-#define SUPPORTED_56000baseSR4_Full (1 << 29)
-#define SUPPORTED_56000baseLR4_Full (1 << 30)
-#define ADVERTISED_10baseT_Half (1 << 0)
+  ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT = 27,
+  ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT = 28,
+  ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT = 29,
+  ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT = 30,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_10baseT_Full (1 << 1)
-#define ADVERTISED_100baseT_Half (1 << 2)
-#define ADVERTISED_100baseT_Full (1 << 3)
-#define ADVERTISED_1000baseT_Half (1 << 4)
+  ETHTOOL_LINK_MODE_25000baseCR_Full_BIT = 31,
+  ETHTOOL_LINK_MODE_25000baseKR_Full_BIT = 32,
+  ETHTOOL_LINK_MODE_25000baseSR_Full_BIT = 33,
+  ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT = 34,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_1000baseT_Full (1 << 5)
-#define ADVERTISED_Autoneg (1 << 6)
-#define ADVERTISED_TP (1 << 7)
-#define ADVERTISED_AUI (1 << 8)
+  ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT = 35,
+  ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT = 36,
+  ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT = 37,
+  ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT = 38,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_MII (1 << 9)
-#define ADVERTISED_FIBRE (1 << 10)
-#define ADVERTISED_BNC (1 << 11)
-#define ADVERTISED_10000baseT_Full (1 << 12)
+  ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT = 39,
+  __ETHTOOL_LINK_MODE_LAST = ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT,
+};
+#define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name) (1UL << (ETHTOOL_LINK_MODE_ ##base_name ##_BIT))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_Pause (1 << 13)
-#define ADVERTISED_Asym_Pause (1 << 14)
-#define ADVERTISED_2500baseX_Full (1 << 15)
-#define ADVERTISED_Backplane (1 << 16)
+#define SUPPORTED_10baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
+#define SUPPORTED_10baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
+#define SUPPORTED_100baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
+#define SUPPORTED_100baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_1000baseKX_Full (1 << 17)
-#define ADVERTISED_10000baseKX4_Full (1 << 18)
-#define ADVERTISED_10000baseKR_Full (1 << 19)
-#define ADVERTISED_10000baseR_FEC (1 << 20)
+#define SUPPORTED_1000baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
+#define SUPPORTED_1000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
+#define SUPPORTED_Autoneg __ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
+#define SUPPORTED_TP __ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_20000baseMLD2_Full (1 << 21)
-#define ADVERTISED_20000baseKR2_Full (1 << 22)
-#define ADVERTISED_40000baseKR4_Full (1 << 23)
-#define ADVERTISED_40000baseCR4_Full (1 << 24)
+#define SUPPORTED_AUI __ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
+#define SUPPORTED_MII __ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
+#define SUPPORTED_FIBRE __ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
+#define SUPPORTED_BNC __ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_40000baseSR4_Full (1 << 25)
-#define ADVERTISED_40000baseLR4_Full (1 << 26)
-#define ADVERTISED_56000baseKR4_Full (1 << 27)
-#define ADVERTISED_56000baseCR4_Full (1 << 28)
+#define SUPPORTED_10000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
+#define SUPPORTED_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
+#define SUPPORTED_Asym_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
+#define SUPPORTED_2500baseX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ADVERTISED_56000baseSR4_Full (1 << 29)
-#define ADVERTISED_56000baseLR4_Full (1 << 30)
+#define SUPPORTED_Backplane __ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
+#define SUPPORTED_1000baseKX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
+#define SUPPORTED_10000baseKX4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
+#define SUPPORTED_10000baseKR_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SUPPORTED_10000baseR_FEC __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
+#define SUPPORTED_20000baseMLD2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
+#define SUPPORTED_20000baseKR2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
+#define SUPPORTED_40000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SUPPORTED_40000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
+#define SUPPORTED_40000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
+#define SUPPORTED_40000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
+#define SUPPORTED_56000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SUPPORTED_56000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
+#define SUPPORTED_56000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
+#define SUPPORTED_56000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
+#define ADVERTISED_10baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_10baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
+#define ADVERTISED_100baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
+#define ADVERTISED_100baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
+#define ADVERTISED_1000baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_1000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
+#define ADVERTISED_Autoneg __ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
+#define ADVERTISED_TP __ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
+#define ADVERTISED_AUI __ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_MII __ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
+#define ADVERTISED_FIBRE __ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
+#define ADVERTISED_BNC __ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
+#define ADVERTISED_10000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
+#define ADVERTISED_Asym_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
+#define ADVERTISED_2500baseX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
+#define ADVERTISED_Backplane __ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_1000baseKX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
+#define ADVERTISED_10000baseKX4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
+#define ADVERTISED_10000baseKR_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
+#define ADVERTISED_10000baseR_FEC __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_20000baseMLD2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
+#define ADVERTISED_20000baseKR2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
+#define ADVERTISED_40000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
+#define ADVERTISED_40000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_40000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
+#define ADVERTISED_40000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
+#define ADVERTISED_56000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
+#define ADVERTISED_56000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADVERTISED_56000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
+#define ADVERTISED_56000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
 #define SPEED_10 10
 #define SPEED_100 100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -701,54 +806,74 @@
 #define AH_V6_FLOW 0x0b
 #define ESP_V6_FLOW 0x0c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IP_USER_FLOW 0x0d
+#define IPV4_USER_FLOW 0x0d
+#define IP_USER_FLOW IPV4_USER_FLOW
+#define IPV6_USER_FLOW 0x0e
 #define IPV4_FLOW 0x10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPV6_FLOW 0x11
 #define ETHER_FLOW 0x12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FLOW_EXT 0x80000000
 #define FLOW_MAC_EXT 0x40000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RXH_L2DA (1 << 1)
 #define RXH_VLAN (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RXH_L3_PROTO (1 << 3)
 #define RXH_IP_SRC (1 << 4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RXH_IP_DST (1 << 5)
 #define RXH_L4_B_0_1 (1 << 6)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RXH_L4_B_2_3 (1 << 7)
 #define RXH_DISCARD (1 << 31)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RX_CLS_FLOW_DISC 0xffffffffffffffffULL
 #define RX_CLS_LOC_SPECIAL 0x80000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RX_CLS_LOC_ANY 0xffffffff
 #define RX_CLS_LOC_FIRST 0xfffffffe
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RX_CLS_LOC_LAST 0xfffffffd
 #define ETH_MODULE_SFF_8079 0x1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_MODULE_SFF_8079_LEN 256
 #define ETH_MODULE_SFF_8472 0x2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_MODULE_SFF_8472_LEN 512
 #define ETH_MODULE_SFF_8636 0x3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_MODULE_SFF_8636_LEN 256
 #define ETH_MODULE_SFF_8436 0x4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_MODULE_SFF_8436_LEN 256
 enum ethtool_reset_flags {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_RESET_MGMT = 1 << 0,
   ETH_RESET_IRQ = 1 << 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_RESET_DMA = 1 << 2,
   ETH_RESET_FILTER = 1 << 3,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_RESET_OFFLOAD = 1 << 4,
   ETH_RESET_MAC = 1 << 5,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_RESET_PHY = 1 << 6,
   ETH_RESET_RAM = 1 << 7,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ETH_RESET_DEDICATED = 0x0000ffff,
   ETH_RESET_ALL = 0xffffffff,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define ETH_RESET_SHARED_SHIFT 16
+struct ethtool_link_settings {
+  __u32 cmd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 speed;
+  __u8 duplex;
+  __u8 port;
+  __u8 phy_address;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 autoneg;
+  __u8 mdio_support;
+  __u8 eth_tp_mdix;
+  __u8 eth_tp_mdix_ctrl;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s8 link_mode_masks_nwords;
+  __u32 reserved[8];
+  __u32 link_mode_masks[0];
+};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/eventpoll.h b/libc/kernel/uapi/linux/eventpoll.h
index 9f329f7..ec51b9f 100644
--- a/libc/kernel/uapi/linux/eventpoll.h
+++ b/libc/kernel/uapi/linux/eventpoll.h
@@ -26,19 +26,20 @@
 #define EPOLL_CTL_DEL 2
 #define EPOLL_CTL_MOD 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EPOLLEXCLUSIVE (1 << 28)
 #define EPOLLWAKEUP (1 << 29)
 #define EPOLLONESHOT (1 << 30)
 #define EPOLLET (1 << 31)
-#ifdef __x86_64__
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __x86_64__
 #define EPOLL_PACKED __attribute__((packed))
 #else
 #define EPOLL_PACKED
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 struct epoll_event {
   __u32 events;
   __u64 data;
-} EPOLL_PACKED;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} EPOLL_PACKED;
 #endif
diff --git a/libc/kernel/uapi/linux/fib_rules.h b/libc/kernel/uapi/linux/fib_rules.h
index fdc3577..0268826 100644
--- a/libc/kernel/uapi/linux/fib_rules.h
+++ b/libc/kernel/uapi/linux/fib_rules.h
@@ -68,24 +68,30 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FRA_FWMASK,
   FRA_OIFNAME,
+  /* MANUAL CHANGE:
+   * Temporarily remove this define since it conflicts with the android
+   * kernel value FRA_UID_START that has not been upstreamed yet.
+  FRA_PAD,
+   */
   __FRA_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define FRA_MAX (__FRA_MAX - 1)
 enum {
   FR_ACT_UNSPEC,
-  FR_ACT_TO_TBL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FR_ACT_TO_TBL,
   FR_ACT_GOTO,
   FR_ACT_NOP,
   FR_ACT_RES3,
-  FR_ACT_RES4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FR_ACT_RES4,
   FR_ACT_BLACKHOLE,
   FR_ACT_UNREACHABLE,
   FR_ACT_PROHIBIT,
-  __FR_ACT_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __FR_ACT_MAX,
 };
 #define FR_ACT_MAX (__FR_ACT_MAX - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/fs.h b/libc/kernel/uapi/linux/fs.h
index 7a63bd8..6407f71 100644
--- a/libc/kernel/uapi/linux/fs.h
+++ b/libc/kernel/uapi/linux/fs.h
@@ -39,155 +39,240 @@
 #define RENAME_NOREPLACE (1 << 0)
 #define RENAME_EXCHANGE (1 << 1)
 #define RENAME_WHITEOUT (1 << 2)
-struct fstrim_range {
+struct file_clone_range {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s64 src_fd;
+  __u64 src_offset;
+  __u64 src_length;
+  __u64 dest_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct fstrim_range {
   __u64 start;
   __u64 len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 minlen;
 };
+#define FILE_DEDUPE_RANGE_SAME 0
+#define FILE_DEDUPE_RANGE_DIFFERS 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct file_dedupe_range_info {
+  __s64 dest_fd;
+  __u64 dest_offset;
+  __u64 bytes_deduped;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 status;
+  __u32 reserved;
+};
+struct file_dedupe_range {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 src_offset;
+  __u64 src_length;
+  __u16 dest_count;
+  __u16 reserved1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved2;
+  struct file_dedupe_range_info info[0];
+};
 struct files_stat_struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long nr_files;
   unsigned long nr_free_files;
   unsigned long max_files;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct inodes_stat_t {
   long nr_inodes;
   long nr_unused;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   long dummy[5];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NR_FILE 8192
 #define MS_RDONLY 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_NOSUID 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_NODEV 4
 #define MS_NOEXEC 8
 #define MS_SYNCHRONOUS 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_REMOUNT 32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_MANDLOCK 64
 #define MS_DIRSYNC 128
 #define MS_NOATIME 1024
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_NODIRATIME 2048
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_BIND 4096
 #define MS_MOVE 8192
 #define MS_REC 16384
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_VERBOSE 32768
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_SILENT 32768
 #define MS_POSIXACL (1 << 16)
 #define MS_UNBINDABLE (1 << 17)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_PRIVATE (1 << 18)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_SLAVE (1 << 19)
 #define MS_SHARED (1 << 20)
 #define MS_RELATIME (1 << 21)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_KERNMOUNT (1 << 22)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_I_VERSION (1 << 23)
 #define MS_STRICTATIME (1 << 24)
 #define MS_LAZYTIME (1 << 25)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_NOSEC (1 << 28)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_BORN (1 << 29)
 #define MS_ACTIVE (1 << 30)
 #define MS_NOUSER (1 << 31)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_RMT_MASK (MS_RDONLY | MS_SYNCHRONOUS | MS_MANDLOCK | MS_I_VERSION | MS_LAZYTIME)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_MGC_VAL 0xC0ED0000
 #define MS_MGC_MSK 0xffff0000
-#define BLKROSET _IO(0x12, 93)
+struct fsxattr {
+  __u32 fsx_xflags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 fsx_extsize;
+  __u32 fsx_nextents;
+  __u32 fsx_projid;
+  unsigned char fsx_pad[12];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define FS_XFLAG_REALTIME 0x00000001
+#define FS_XFLAG_PREALLOC 0x00000002
+#define FS_XFLAG_IMMUTABLE 0x00000008
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_XFLAG_APPEND 0x00000010
+#define FS_XFLAG_SYNC 0x00000020
+#define FS_XFLAG_NOATIME 0x00000040
+#define FS_XFLAG_NODUMP 0x00000080
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_XFLAG_RTINHERIT 0x00000100
+#define FS_XFLAG_PROJINHERIT 0x00000200
+#define FS_XFLAG_NOSYMLINKS 0x00000400
+#define FS_XFLAG_EXTSIZE 0x00000800
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_XFLAG_EXTSZINHERIT 0x00001000
+#define FS_XFLAG_NODEFRAG 0x00002000
+#define FS_XFLAG_FILESTREAM 0x00004000
+#define FS_XFLAG_DAX 0x00008000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_XFLAG_HASATTR 0x80000000
+#define BLKROSET _IO(0x12, 93)
 #define BLKROGET _IO(0x12, 94)
 #define BLKRRPART _IO(0x12, 95)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKGETSIZE _IO(0x12, 96)
 #define BLKFLSBUF _IO(0x12, 97)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKRASET _IO(0x12, 98)
 #define BLKRAGET _IO(0x12, 99)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKFRASET _IO(0x12, 100)
 #define BLKFRAGET _IO(0x12, 101)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKSECTSET _IO(0x12, 102)
 #define BLKSECTGET _IO(0x12, 103)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKSSZGET _IO(0x12, 104)
 #define BLKBSZGET _IOR(0x12, 112, size_t)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKBSZSET _IOW(0x12, 113, size_t)
 #define BLKGETSIZE64 _IOR(0x12, 114, size_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKTRACESETUP _IOWR(0x12, 115, struct blk_user_trace_setup)
 #define BLKTRACESTART _IO(0x12, 116)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKTRACESTOP _IO(0x12, 117)
 #define BLKTRACETEARDOWN _IO(0x12, 118)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKDISCARD _IO(0x12, 119)
 #define BLKIOMIN _IO(0x12, 120)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKIOOPT _IO(0x12, 121)
 #define BLKALIGNOFF _IO(0x12, 122)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKPBSZGET _IO(0x12, 123)
 #define BLKDISCARDZEROES _IO(0x12, 124)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKSECDISCARD _IO(0x12, 125)
 #define BLKROTATIONAL _IO(0x12, 126)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BLKZEROOUT _IO(0x12, 127)
 #define BMAP_IOCTL 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FIBMAP _IO(0x00, 1)
 #define FIGETBSZ _IO(0x00, 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FIFREEZE _IOWR('X', 119, int)
 #define FITHAW _IOWR('X', 120, int)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FITRIM _IOWR('X', 121, struct fstrim_range)
+#define FICLONE _IOW(0x94, 9, int)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range)
+#define FIDEDUPERANGE _IOWR(0x94, 54, struct file_dedupe_range)
 #define FS_IOC_GETFLAGS _IOR('f', 1, long)
 #define FS_IOC_SETFLAGS _IOW('f', 2, long)
-#define FS_IOC_GETVERSION _IOR('v', 1, long)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_IOC_GETVERSION _IOR('v', 1, long)
 #define FS_IOC_SETVERSION _IOW('v', 2, long)
 #define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
 #define FS_IOC32_GETFLAGS _IOR('f', 1, int)
-#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
 #define FS_IOC32_GETVERSION _IOR('v', 1, int)
 #define FS_IOC32_SETVERSION _IOW('v', 2, int)
+#define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
+#define FS_KEY_DESCRIPTOR_SIZE 8
+struct fscrypt_policy {
+  __u8 version;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 contents_encryption_mode;
+  __u8 filenames_encryption_mode;
+  __u8 flags;
+  __u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __packed;
+#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
+#define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16])
+#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_SECRM_FL 0x00000001
 #define FS_UNRM_FL 0x00000002
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_COMPR_FL 0x00000004
 #define FS_SYNC_FL 0x00000008
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_IMMUTABLE_FL 0x00000010
 #define FS_APPEND_FL 0x00000020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_NODUMP_FL 0x00000040
 #define FS_NOATIME_FL 0x00000080
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_DIRTY_FL 0x00000100
 #define FS_COMPRBLK_FL 0x00000200
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_NOCOMP_FL 0x00000400
-#define FS_ECOMPR_FL 0x00000800
+#define FS_ENCRYPT_FL 0x00000800
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_BTREE_FL 0x00001000
 #define FS_INDEX_FL 0x00001000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_IMAGIC_FL 0x00002000
 #define FS_JOURNAL_DATA_FL 0x00004000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_NOTAIL_FL 0x00008000
 #define FS_DIRSYNC_FL 0x00010000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_TOPDIR_FL 0x00020000
+#define FS_HUGE_FILE_FL 0x00040000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS_EXTENT_FL 0x00080000
-#define FS_DIRECTIO_FL 0x00100000
+#define FS_EA_INODE_FL 0x00200000
+#define FS_EOFBLOCKS_FL 0x00400000
 #define FS_NOCOW_FL 0x00800000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_INLINE_DATA_FL 0x10000000
 #define FS_PROJINHERIT_FL 0x20000000
 #define FS_RESERVED_FL 0x80000000
 #define FS_FL_USER_VISIBLE 0x0003DFFF
-#define FS_FL_USER_MODIFIABLE 0x000380FF
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FS_FL_USER_MODIFIABLE 0x000380FF
 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
 #define SYNC_FILE_RANGE_WRITE 2
 #define SYNC_FILE_RANGE_WAIT_AFTER 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RWF_HIPRI 0x00000001
+#define RWF_DSYNC 0x00000002
+#define RWF_SYNC 0x00000004
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/fuse.h b/libc/kernel/uapi/linux/fuse.h
index f98296c..07a7a0a 100644
--- a/libc/kernel/uapi/linux/fuse.h
+++ b/libc/kernel/uapi/linux/fuse.h
@@ -21,7 +21,7 @@
 #include <stdint.h>
 #define FUSE_KERNEL_VERSION 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define FUSE_KERNEL_MINOR_VERSION 23
+#define FUSE_KERNEL_MINOR_VERSION 25
 #define FUSE_ROOT_ID 1
 struct fuse_attr {
   uint64_t ino;
@@ -108,484 +108,498 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_WRITEBACK_CACHE (1 << 16)
 #define FUSE_NO_OPEN_SUPPORT (1 << 17)
+#define FUSE_PARALLEL_DIROPS (1 << 18)
 #define CUSE_UNRESTRICTED_IOCTL (1 << 0)
-#define FUSE_RELEASE_FLUSH (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FUSE_RELEASE_FLUSH (1 << 0)
 #define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
 #define FUSE_GETATTR_FH (1 << 0)
 #define FUSE_LK_FLOCK (1 << 0)
-#define FUSE_WRITE_CACHE (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FUSE_WRITE_CACHE (1 << 0)
 #define FUSE_WRITE_LOCKOWNER (1 << 1)
 #define FUSE_READ_LOCKOWNER (1 << 1)
 #define FUSE_IOCTL_COMPAT (1 << 0)
-#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
 #define FUSE_IOCTL_RETRY (1 << 2)
 #define FUSE_IOCTL_32BIT (1 << 3)
 #define FUSE_IOCTL_DIR (1 << 4)
-#define FUSE_IOCTL_MAX_IOV 256
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define FUSE_IOCTL_MAX_IOV 256
 #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
 enum fuse_opcode {
   FUSE_LOOKUP = 1,
-  FUSE_FORGET = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_FORGET = 2,
   FUSE_GETATTR = 3,
   FUSE_SETATTR = 4,
   FUSE_READLINK = 5,
-  FUSE_SYMLINK = 6,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_SYMLINK = 6,
   FUSE_MKNOD = 8,
   FUSE_MKDIR = 9,
   FUSE_UNLINK = 10,
-  FUSE_RMDIR = 11,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_RMDIR = 11,
   FUSE_RENAME = 12,
   FUSE_LINK = 13,
   FUSE_OPEN = 14,
-  FUSE_READ = 15,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_READ = 15,
   FUSE_WRITE = 16,
   FUSE_STATFS = 17,
   FUSE_RELEASE = 18,
-  FUSE_FSYNC = 20,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_FSYNC = 20,
   FUSE_SETXATTR = 21,
   FUSE_GETXATTR = 22,
   FUSE_LISTXATTR = 23,
-  FUSE_REMOVEXATTR = 24,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_REMOVEXATTR = 24,
   FUSE_FLUSH = 25,
   FUSE_INIT = 26,
   FUSE_OPENDIR = 27,
-  FUSE_READDIR = 28,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_READDIR = 28,
   FUSE_RELEASEDIR = 29,
   FUSE_FSYNCDIR = 30,
   FUSE_GETLK = 31,
-  FUSE_SETLK = 32,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_SETLK = 32,
   FUSE_SETLKW = 33,
   FUSE_ACCESS = 34,
   FUSE_CREATE = 35,
-  FUSE_INTERRUPT = 36,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_INTERRUPT = 36,
   FUSE_BMAP = 37,
   FUSE_DESTROY = 38,
   FUSE_IOCTL = 39,
-  FUSE_POLL = 40,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_POLL = 40,
   FUSE_NOTIFY_REPLY = 41,
   FUSE_BATCH_FORGET = 42,
   FUSE_FALLOCATE = 43,
-  FUSE_READDIRPLUS = 44,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  FUSE_READDIRPLUS = 44,
   FUSE_RENAME2 = 45,
+  FUSE_LSEEK = 46,
   CUSE_INIT = 4096,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum fuse_notify_code {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FUSE_NOTIFY_POLL = 1,
   FUSE_NOTIFY_INVAL_INODE = 2,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FUSE_NOTIFY_INVAL_ENTRY = 3,
   FUSE_NOTIFY_STORE = 4,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FUSE_NOTIFY_RETRIEVE = 5,
   FUSE_NOTIFY_DELETE = 6,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FUSE_NOTIFY_CODE_MAX,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_MIN_READ_BUFFER 8192
 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_entry_out {
   uint64_t nodeid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t generation;
   uint64_t entry_valid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t attr_valid;
   uint32_t entry_valid_nsec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t attr_valid_nsec;
   struct fuse_attr attr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_forget_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t nlookup;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_forget_one {
   uint64_t nodeid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t nlookup;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_batch_forget_in {
   uint32_t count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t dummy;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_getattr_in {
   uint32_t getattr_flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t dummy;
   uint64_t fh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define FUSE_COMPAT_ATTR_OUT_SIZE 96
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_attr_out {
   uint64_t attr_valid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t attr_valid_nsec;
   uint32_t dummy;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct fuse_attr attr;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
 struct fuse_mknod_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t mode;
   uint32_t rdev;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t umask;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_mkdir_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t mode;
   uint32_t umask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_rename_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t newdir;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_rename2_in {
   uint64_t newdir;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t flags;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_link_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t oldnodeid;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_setattr_in {
   uint32_t valid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
   uint64_t fh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t size;
   uint64_t lock_owner;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t atime;
   uint64_t mtime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t ctime;
   uint32_t atimensec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t mtimensec;
   uint32_t ctimensec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t mode;
   uint32_t unused4;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t uid;
   uint32_t gid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t unused5;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_open_in {
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t unused;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_create_in {
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t mode;
   uint32_t umask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_open_out {
   uint64_t fh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t open_flags;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_release_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t fh;
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t release_flags;
   uint64_t lock_owner;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_flush_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t fh;
   uint32_t unused;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
   uint64_t lock_owner;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_read_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t fh;
   uint64_t offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
   uint32_t read_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t lock_owner;
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_COMPAT_WRITE_IN_SIZE 24
 struct fuse_write_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t fh;
   uint64_t offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
   uint32_t write_flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t lock_owner;
   uint32_t flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_write_out {
   uint32_t size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_COMPAT_STATFS_SIZE 48
 struct fuse_statfs_out {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct fuse_kstatfs st;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_fsync_in {
   uint64_t fh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t fsync_flags;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_setxattr_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_getxattr_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_getxattr_out {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_lk_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t fh;
   uint64_t owner;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct fuse_file_lock lk;
   uint32_t lk_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_lk_out {
   struct fuse_file_lock lk;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_access_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t mask;
   uint32_t padding;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_init_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t major;
   uint32_t minor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t max_readahead;
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define FUSE_COMPAT_INIT_OUT_SIZE 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_COMPAT_22_INIT_OUT_SIZE 24
 struct fuse_init_out {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t major;
   uint32_t minor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t max_readahead;
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint16_t max_background;
   uint16_t congestion_threshold;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t max_write;
   uint32_t time_gran;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t unused[9];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CUSE_INIT_INFO_MAX 4096
 struct cuse_init_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t major;
   uint32_t minor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t unused;
   uint32_t flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct cuse_init_out {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t major;
   uint32_t minor;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t unused;
   uint32_t flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t max_read;
   uint32_t max_write;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t dev_major;
   uint32_t dev_minor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t spare[10];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_interrupt_in {
   uint64_t unique;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_bmap_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t block;
   uint32_t blocksize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_bmap_out {
   uint64_t block;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_ioctl_in {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t fh;
   uint32_t flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t cmd;
   uint64_t arg;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t in_size;
   uint32_t out_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_ioctl_iovec {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t base;
   uint64_t len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_ioctl_out {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int32_t result;
   uint32_t flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t in_iovs;
   uint32_t out_iovs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_poll_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t fh;
   uint64_t kh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t flags;
   uint32_t events;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_poll_out {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t revents;
   uint32_t padding;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_notify_poll_wakeup_out {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t kh;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_fallocate_in {
   uint64_t fh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t offset;
   uint64_t length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t mode;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_in_header {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t len;
   uint32_t opcode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t unique;
   uint64_t nodeid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t uid;
   uint32_t gid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t pid;
   uint32_t padding;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_out_header {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t len;
   int32_t error;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t unique;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_dirent {
   uint64_t ino;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t off;
   uint32_t namelen;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t type;
   char name[];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
 #define FUSE_DIRENT_SIZE(d) FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_direntplus {
   struct fuse_entry_out entry_out;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct fuse_dirent dirent;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FUSE_NAME_OFFSET_DIRENTPLUS offsetof(struct fuse_direntplus, dirent.name)
 #define FUSE_DIRENTPLUS_SIZE(d) FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_notify_inval_inode_out {
   uint64_t ino;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int64_t off;
   int64_t len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_notify_inval_entry_out {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t parent;
   uint32_t namelen;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_notify_delete_out {
   uint64_t parent;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t child;
   uint32_t namelen;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_notify_store_out {
   uint64_t nodeid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t offset;
   uint32_t size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t padding;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct fuse_notify_retrieve_out {
   uint64_t notify_unique;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t nodeid;
   uint64_t offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
   uint32_t padding;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct fuse_notify_retrieve_in {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t dummy1;
   uint64_t offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t size;
   uint32_t dummy2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint64_t dummy3;
   uint64_t dummy4;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define FUSE_DEV_IOC_CLONE _IOR(229, 0, uint32_t)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct fuse_lseek_in {
+  uint64_t fh;
+  uint64_t offset;
+  uint32_t whence;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  uint32_t padding;
+};
+struct fuse_lseek_out {
+  uint64_t offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/gen_stats.h b/libc/kernel/uapi/linux/gen_stats.h
index 9dc9b32..aa7ac28 100644
--- a/libc/kernel/uapi/linux/gen_stats.h
+++ b/libc/kernel/uapi/linux/gen_stats.h
@@ -28,42 +28,43 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_STATS_APP,
   TCA_STATS_RATE_EST64,
+  TCA_STATS_PAD,
   __TCA_STATS_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
 struct gnet_stats_basic {
   __u64 bytes;
-  __u32 packets;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 packets;
 };
 struct gnet_stats_basic_packed {
   __u64 bytes;
-  __u32 packets;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 packets;
 } __attribute__((packed));
 struct gnet_stats_rate_est {
   __u32 bps;
-  __u32 pps;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pps;
 };
 struct gnet_stats_rate_est64 {
   __u64 bps;
-  __u64 pps;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 pps;
 };
 struct gnet_stats_queue {
   __u32 qlen;
-  __u32 backlog;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 backlog;
   __u32 drops;
   __u32 requeues;
   __u32 overlimits;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct gnet_estimator {
   signed char interval;
   unsigned char ewma_log;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/genetlink.h b/libc/kernel/uapi/linux/genetlink.h
index 5daa4a6..2b75bb7 100644
--- a/libc/kernel/uapi/linux/genetlink.h
+++ b/libc/kernel/uapi/linux/genetlink.h
@@ -37,59 +37,60 @@
 #define GENL_CMD_CAP_DUMP 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GENL_CMD_CAP_HASPOL 0x08
+#define GENL_UNS_ADMIN_PERM 0x10
 #define GENL_ID_GENERATE 0
 #define GENL_ID_CTRL NLMSG_MIN_TYPE
-#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
 #define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
 enum {
   CTRL_CMD_UNSPEC,
-  CTRL_CMD_NEWFAMILY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTRL_CMD_NEWFAMILY,
   CTRL_CMD_DELFAMILY,
   CTRL_CMD_GETFAMILY,
   CTRL_CMD_NEWOPS,
-  CTRL_CMD_DELOPS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTRL_CMD_DELOPS,
   CTRL_CMD_GETOPS,
   CTRL_CMD_NEWMCAST_GRP,
   CTRL_CMD_DELMCAST_GRP,
-  CTRL_CMD_GETMCAST_GRP,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTRL_CMD_GETMCAST_GRP,
   __CTRL_CMD_MAX,
 };
 #define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   CTRL_ATTR_UNSPEC,
   CTRL_ATTR_FAMILY_ID,
   CTRL_ATTR_FAMILY_NAME,
-  CTRL_ATTR_VERSION,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTRL_ATTR_VERSION,
   CTRL_ATTR_HDRSIZE,
   CTRL_ATTR_MAXATTR,
   CTRL_ATTR_OPS,
-  CTRL_ATTR_MCAST_GROUPS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTRL_ATTR_MCAST_GROUPS,
   __CTRL_ATTR_MAX,
 };
 #define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   CTRL_ATTR_OP_UNSPEC,
   CTRL_ATTR_OP_ID,
   CTRL_ATTR_OP_FLAGS,
-  __CTRL_ATTR_OP_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __CTRL_ATTR_OP_MAX,
 };
 #define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
 enum {
-  CTRL_ATTR_MCAST_GRP_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTRL_ATTR_MCAST_GRP_UNSPEC,
   CTRL_ATTR_MCAST_GRP_NAME,
   CTRL_ATTR_MCAST_GRP_ID,
   __CTRL_ATTR_MCAST_GRP_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/gfs2_ondisk.h b/libc/kernel/uapi/linux/gfs2_ondisk.h
index fcb5993..3fc4dee 100644
--- a/libc/kernel/uapi/linux/gfs2_ondisk.h
+++ b/libc/kernel/uapi/linux/gfs2_ondisk.h
@@ -257,119 +257,122 @@
 #define GFS2_FNAMESIZE 255
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_DIRENT_SIZE(name_len) ((sizeof(struct gfs2_dirent) + (name_len) + 7) & ~7)
+#define GFS2_MIN_DIRENT_SIZE (GFS2_DIRENT_SIZE(1))
 struct gfs2_dirent {
   struct gfs2_inum de_inum;
-  __be32 de_hash;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be32 de_hash;
   __be16 de_rec_len;
   __be16 de_name_len;
   __be16 de_type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be16 de_rahead;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    __u8 __pad[14];
+    __u8 __pad[12];
     struct {
-      __be16 de_rahead;
-      __u8 pad2[12];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 de_cookie;
+      __u8 pad3[8];
     };
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct gfs2_leaf {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct gfs2_meta_header lf_header;
   __be16 lf_depth;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be16 lf_entries;
   __be32 lf_dirent_format;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be64 lf_next;
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u8 lf_reserved[64];
     struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __be64 lf_inode;
       __be32 lf_dist;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __be32 lf_nsec;
       __be64 lf_sec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u8 lf_reserved2[40];
     };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_EA_MAX_NAME_LEN 255
 #define GFS2_EA_MAX_DATA_LEN 65536
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_EATYPE_UNUSED 0
 #define GFS2_EATYPE_USR 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_EATYPE_SYS 2
 #define GFS2_EATYPE_SECURITY 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_EATYPE_LAST 3
 #define GFS2_EATYPE_VALID(x) ((x) <= GFS2_EATYPE_LAST)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_EAFLAG_LAST 0x01
 struct gfs2_ea_header {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ea_rec_len;
   __be32 ea_data_len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ea_name_len;
   __u8 ea_type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ea_flags;
   __u8 ea_num_ptrs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 __pad;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_LOG_HEAD_UNMOUNT 0x00000001
 struct gfs2_log_header {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct gfs2_meta_header lh_header;
   __be64 lh_sequence;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 lh_flags;
   __be32 lh_tail;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 lh_blkno;
   __be32 lh_hash;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define GFS2_LOG_DESC_METADATA 300
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_LOG_DESC_REVOKE 301
 #define GFS2_LOG_DESC_JDATA 302
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct gfs2_log_descriptor {
   struct gfs2_meta_header ld_header;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ld_type;
   __be32 ld_length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ld_data1;
   __be32 ld_data2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ld_reserved[32];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_INUM_QUANTUM 1048576
 struct gfs2_inum_range {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be64 ir_start;
   __be64 ir_length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct gfs2_statfs_change {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be64 sc_total;
   __be64 sc_free;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be64 sc_dinodes;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GFS2_QCF_USER 0x00000001
 struct gfs2_quota_change {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be64 qc_change;
   __be32 qc_flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 qc_id;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct gfs2_quota_lvb {
   __be32 qb_magic;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 __pad;
   __be64 qb_limit;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be64 qb_warn;
   __be64 qb_value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/asm-arm/asm/a.out.h b/libc/kernel/uapi/linux/gpio.h
similarity index 69%
rename from libc/kernel/uapi/asm-arm/asm/a.out.h
rename to libc/kernel/uapi/linux/gpio.h
index 3d51506..0a4a31b 100644
--- a/libc/kernel/uapi/asm-arm/asm/a.out.h
+++ b/libc/kernel/uapi/linux/gpio.h
@@ -16,31 +16,31 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef __ARM_A_OUT_H__
-#define __ARM_A_OUT_H__
-#include <linux/personality.h>
+#ifndef _UAPI_GPIO_H_
+#define _UAPI_GPIO_H_
+#include <linux/ioctl.h>
 #include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct exec {
-  __u32 a_info;
-  __u32 a_text;
-  __u32 a_data;
+struct gpiochip_info {
+  char name[32];
+  char label[32];
+  __u32 lines;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 a_bss;
-  __u32 a_syms;
-  __u32 a_entry;
-  __u32 a_trsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 a_drsize;
 };
-#define N_TXTADDR(a) (0x00008000)
-#define N_TRSIZE(a) ((a).a_trsize)
+#define GPIOLINE_FLAG_KERNEL (1UL << 0)
+#define GPIOLINE_FLAG_IS_OUT (1UL << 1)
+#define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define N_DRSIZE(a) ((a).a_drsize)
-#define N_SYMSIZE(a) ((a).a_syms)
-#define M_ARM 103
-#ifndef LIBRARY_START_TEXT
+#define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3)
+#define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4)
+struct gpioline_info {
+  __u32 line_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define LIBRARY_START_TEXT (0x00c00000)
-#endif
+  __u32 flags;
+  char name[32];
+  char consumer[32];
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info)
+#define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info)
 #endif
diff --git a/libc/kernel/uapi/linux/sync.h b/libc/kernel/uapi/linux/gtp.h
similarity index 70%
copy from libc/kernel/uapi/linux/sync.h
copy to libc/kernel/uapi/linux/gtp.h
index bbf6641..1e99298 100644
--- a/libc/kernel/uapi/linux/sync.h
+++ b/libc/kernel/uapi/linux/gtp.h
@@ -16,38 +16,38 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _UAPI_LINUX_SYNC_H
-#define _UAPI_LINUX_SYNC_H
-#include <linux/ioctl.h>
-#include <linux/types.h>
+#ifndef _UAPI_LINUX_GTP_H_
+#define _UAPI_LINUX_GTP_H_
+enum gtp_genl_cmds {
+  GTP_CMD_NEWPDP,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sync_merge_data {
-  __s32 fd2;
-  char name[32];
-  __s32 fence;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  GTP_CMD_DELPDP,
+  GTP_CMD_GETPDP,
+  GTP_CMD_MAX,
 };
-struct sync_pt_info {
-  __u32 len;
-  char obj_name[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  char driver_name[32];
-  __s32 status;
-  __u64 timestamp_ns;
-  __u8 driver_data[0];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum gtp_version {
+  GTP_V0 = 0,
+  GTP_V1,
 };
-struct sync_fence_info_data {
-  __u32 len;
-  char name[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __s32 status;
-  __u8 pt_info[0];
+enum gtp_attrs {
+  GTPA_UNSPEC = 0,
+  GTPA_LINK,
+  GTPA_VERSION,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  GTPA_TID,
+  GTPA_SGSN_ADDRESS,
+  GTPA_MS_ADDRESS,
+  GTPA_FLOW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  GTPA_NET_NS_FD,
+  GTPA_I_TEI,
+  GTPA_O_TEI,
+  GTPA_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __GTPA_MAX,
 };
-#define SYNC_IOC_MAGIC '>'
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32)
-#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data)
-#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_fence_info_data)
+#define GTPA_MAX (__GTPA_MAX + 1)
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/hash_info.h b/libc/kernel/uapi/linux/hash_info.h
index 552e048..c52e3aa 100644
--- a/libc/kernel/uapi/linux/hash_info.h
+++ b/libc/kernel/uapi/linux/hash_info.h
@@ -41,6 +41,8 @@
   HASH_ALGO_TGR_160,
   HASH_ALGO_TGR_192,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HASH_ALGO_SM3_256,
   HASH_ALGO__LAST
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/hyperv.h b/libc/kernel/uapi/linux/hyperv.h
index 51e60e6..7993306 100644
--- a/libc/kernel/uapi/linux/hyperv.h
+++ b/libc/kernel/uapi/linux/hyperv.h
@@ -149,88 +149,90 @@
 #define HV_INVALIDARG 0x80070057
 #define HV_GUID_NOTFOUND 0x80041002
 #define HV_ERROR_ALREADY_EXISTS 0x80070050
-#define ADDR_FAMILY_NONE 0x00
+#define HV_ERROR_DISK_FULL 0x80070070
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ADDR_FAMILY_NONE 0x00
 #define ADDR_FAMILY_IPV4 0x01
 #define ADDR_FAMILY_IPV6 0x02
 #define MAX_ADAPTER_ID_SIZE 128
-#define MAX_IP_ADDR_SIZE 1024
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAX_IP_ADDR_SIZE 1024
 #define MAX_GATEWAY_SIZE 512
 struct hv_kvp_ipaddr_value {
   __u16 adapter_id[MAX_ADAPTER_ID_SIZE];
-  __u8 addr_family;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 addr_family;
   __u8 dhcp_enabled;
   __u16 ip_addr[MAX_IP_ADDR_SIZE];
   __u16 sub_net[MAX_IP_ADDR_SIZE];
-  __u16 gate_way[MAX_GATEWAY_SIZE];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 gate_way[MAX_GATEWAY_SIZE];
   __u16 dns_addr[MAX_IP_ADDR_SIZE];
 } __attribute__((packed));
 struct hv_kvp_hdr {
-  __u8 operation;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 operation;
   __u8 pool;
   __u16 pad;
 } __attribute__((packed));
-struct hv_kvp_exchg_msg_value {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct hv_kvp_exchg_msg_value {
   __u32 value_type;
   __u32 key_size;
   __u32 value_size;
-  __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
   union {
     __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
     __u32 value_u32;
-    __u64 value_u64;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u64 value_u64;
   };
 } __attribute__((packed));
 struct hv_kvp_msg_enumerate {
-  __u32 index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 index;
   struct hv_kvp_exchg_msg_value data;
 } __attribute__((packed));
 struct hv_kvp_msg_get {
-  struct hv_kvp_exchg_msg_value data;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct hv_kvp_exchg_msg_value data;
 };
 struct hv_kvp_msg_set {
   struct hv_kvp_exchg_msg_value data;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct hv_kvp_msg_delete {
   __u32 key_size;
   __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct hv_kvp_register {
   __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
 };
-struct hv_kvp_msg {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct hv_kvp_msg {
   union {
     struct hv_kvp_hdr kvp_hdr;
     int error;
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
   union {
     struct hv_kvp_msg_get kvp_get;
     struct hv_kvp_msg_set kvp_set;
-    struct hv_kvp_msg_delete kvp_delete;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct hv_kvp_msg_delete kvp_delete;
     struct hv_kvp_msg_enumerate kvp_enum_data;
     struct hv_kvp_ipaddr_value kvp_ip_val;
     struct hv_kvp_register kvp_register;
-  } body;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  } body;
 } __attribute__((packed));
 struct hv_kvp_ip_msg {
   __u8 operation;
-  __u8 pool;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 pool;
   struct hv_kvp_ipaddr_value kvp_ip_val;
 } __attribute__((packed));
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/i2c.h b/libc/kernel/uapi/linux/i2c.h
index 3e4d89c..a812a7a 100644
--- a/libc/kernel/uapi/linux/i2c.h
+++ b/libc/kernel/uapi/linux/i2c.h
@@ -23,16 +23,16 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 addr;
   __u16 flags;
-#define I2C_M_TEN 0x0010
 #define I2C_M_RD 0x0001
+#define I2C_M_TEN 0x0010
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_M_STOP 0x8000
-#define I2C_M_NOSTART 0x4000
-#define I2C_M_REV_DIR_ADDR 0x2000
-#define I2C_M_IGNORE_NAK 0x1000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define I2C_M_NO_RD_ACK 0x0800
 #define I2C_M_RECV_LEN 0x0400
+#define I2C_M_NO_RD_ACK 0x0800
+#define I2C_M_IGNORE_NAK 0x1000
+#define I2C_M_REV_DIR_ADDR 0x2000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define I2C_M_NOSTART 0x4000
+#define I2C_M_STOP 0x8000
   __u16 len;
   __u8 * buf;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/if.h b/libc/kernel/uapi/linux/if.h
index f7b4e22..fb93c48 100644
--- a/libc/kernel/uapi/linux/if.h
+++ b/libc/kernel/uapi/linux/if.h
@@ -18,63 +18,58 @@
  ****************************************************************************/
 #ifndef _LINUX_IF_H
 #define _LINUX_IF_H
+#include <linux/libc-compat.h>
 #include <linux/types.h>
-#include <linux/socket.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/socket.h>
 #include <linux/compiler.h>
+#if __UAPI_DEF_IF_IFNAMSIZ
 #define IFNAMSIZ 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define IFALIASZ 256
 #include <linux/hdlc/ioctl.h>
+#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum net_device_flags {
-  IFF_UP = 1 << 0,
-  IFF_BROADCAST = 1 << 1,
-  IFF_DEBUG = 1 << 2,
+#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
+  IFF_UP = 1 << 0, IFF_BROADCAST = 1 << 1, IFF_DEBUG = 1 << 2, IFF_LOOPBACK = 1 << 3, IFF_POINTOPOINT = 1 << 4, IFF_NOTRAILERS = 1 << 5, IFF_RUNNING = 1 << 6, IFF_NOARP = 1 << 7, IFF_PROMISC = 1 << 8, IFF_ALLMULTI = 1 << 9, IFF_MASTER = 1 << 10, IFF_SLAVE = 1 << 11, IFF_MULTICAST = 1 << 12, IFF_PORTSEL = 1 << 13, IFF_AUTOMEDIA = 1 << 14, IFF_DYNAMIC = 1 << 15,
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  IFF_LOOPBACK = 1 << 3,
-  IFF_POINTOPOINT = 1 << 4,
-  IFF_NOTRAILERS = 1 << 5,
-  IFF_RUNNING = 1 << 6,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  IFF_NOARP = 1 << 7,
-  IFF_PROMISC = 1 << 8,
-  IFF_ALLMULTI = 1 << 9,
-  IFF_MASTER = 1 << 10,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  IFF_SLAVE = 1 << 11,
-  IFF_MULTICAST = 1 << 12,
-  IFF_PORTSEL = 1 << 13,
-  IFF_AUTOMEDIA = 1 << 14,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  IFF_DYNAMIC = 1 << 15,
-  IFF_LOWER_UP = 1 << 16,
-  IFF_DORMANT = 1 << 17,
-  IFF_ECHO = 1 << 18,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
+  IFF_LOWER_UP = 1 << 16, IFF_DORMANT = 1 << 17, IFF_ECHO = 1 << 18,
+#endif
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
 #define IFF_UP IFF_UP
 #define IFF_BROADCAST IFF_BROADCAST
-#define IFF_DEBUG IFF_DEBUG
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFF_DEBUG IFF_DEBUG
 #define IFF_LOOPBACK IFF_LOOPBACK
 #define IFF_POINTOPOINT IFF_POINTOPOINT
 #define IFF_NOTRAILERS IFF_NOTRAILERS
-#define IFF_RUNNING IFF_RUNNING
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFF_RUNNING IFF_RUNNING
 #define IFF_NOARP IFF_NOARP
 #define IFF_PROMISC IFF_PROMISC
 #define IFF_ALLMULTI IFF_ALLMULTI
-#define IFF_MASTER IFF_MASTER
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFF_MASTER IFF_MASTER
 #define IFF_SLAVE IFF_SLAVE
 #define IFF_MULTICAST IFF_MULTICAST
 #define IFF_PORTSEL IFF_PORTSEL
-#define IFF_AUTOMEDIA IFF_AUTOMEDIA
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFF_AUTOMEDIA IFF_AUTOMEDIA
 #define IFF_DYNAMIC IFF_DYNAMIC
+#endif
+#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFF_LOWER_UP IFF_LOWER_UP
 #define IFF_DORMANT IFF_DORMANT
 #define IFF_ECHO IFF_ECHO
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFF_VOLATILE (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST | IFF_ECHO | IFF_MASTER | IFF_SLAVE | IFF_RUNNING | IFF_LOWER_UP | IFF_DORMANT)
 #define IF_GET_IFACE 0x0001
@@ -121,58 +116,63 @@
   IF_LINK_MODE_DORMANT,
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#if __UAPI_DEF_IF_IFMAP
 struct ifmap {
   unsigned long mem_start;
   unsigned long mem_end;
-  unsigned short base_addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned short base_addr;
   unsigned char irq;
   unsigned char dma;
   unsigned char port;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#endif
 struct if_settings {
   unsigned int type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int size;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     raw_hdlc_proto __user * raw_hdlc;
     cisco_proto __user * cisco;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     fr_proto __user * fr;
     fr_proto_pvc __user * fr_pvc;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     fr_proto_pvc_info __user * fr_pvc_info;
     sync_serial_settings __user * sync;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     te1_settings __user * te1;
   } ifs_ifsu;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+#if __UAPI_DEF_IF_IFREQ
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ifreq {
 #define IFHWADDRLEN 6
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     char ifrn_name[IFNAMSIZ];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } ifr_ifrn;
   union {
     struct sockaddr ifru_addr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct sockaddr ifru_dstaddr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct sockaddr ifru_broadaddr;
     struct sockaddr ifru_netmask;
     struct sockaddr ifru_hwaddr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     short ifru_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     int ifru_ivalue;
     int ifru_mtu;
     struct ifmap ifru_map;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     char ifru_slave[IFNAMSIZ];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     char ifru_newname[IFNAMSIZ];
     void __user * ifru_data;
     struct if_settings ifru_settings;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } ifr_ifru;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+#endif
 #define ifr_name ifr_ifrn.ifrn_name
 #define ifr_hwaddr ifr_ifru.ifru_hwaddr
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -194,16 +194,18 @@
 #define ifr_qlen ifr_ifru.ifru_ivalue
 #define ifr_newname ifr_ifru.ifru_newname
 #define ifr_settings ifr_ifru.ifru_settings
-struct ifconf {
+#if __UAPI_DEF_IF_IFCONF
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ifconf {
   int ifc_len;
   union {
     char __user * ifcu_buf;
-    struct ifreq __user * ifcu_req;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct ifreq __user * ifcu_req;
   } ifc_ifcu;
 };
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ifc_buf ifc_ifcu.ifcu_buf
 #define ifc_req ifc_ifcu.ifcu_req
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/if_bridge.h b/libc/kernel/uapi/linux/if_bridge.h
index 1c8477f..8f4d436 100644
--- a/libc/kernel/uapi/linux/if_bridge.h
+++ b/libc/kernel/uapi/linux/if_bridge.h
@@ -143,37 +143,72 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 vid;
 };
-enum {
-  MDBA_UNSPEC,
+struct bridge_vlan_xstats {
+  __u64 rx_bytes;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 rx_packets;
+  __u64 tx_bytes;
+  __u64 tx_packets;
+  __u16 vid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 pad1;
+  __u32 pad2;
+};
+enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MDBA_UNSPEC,
   MDBA_MDB,
   MDBA_ROUTER,
   __MDBA_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define MDBA_MAX (__MDBA_MAX - 1)
 enum {
   MDBA_MDB_UNSPEC,
-  MDBA_MDB_ENTRY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MDBA_MDB_ENTRY,
   __MDBA_MDB_MAX,
 };
 #define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   MDBA_MDB_ENTRY_UNSPEC,
   MDBA_MDB_ENTRY_INFO,
   __MDBA_MDB_ENTRY_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1)
 enum {
-  MDBA_ROUTER_UNSPEC,
-  MDBA_ROUTER_PORT,
+  MDBA_MDB_EATTR_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MDBA_MDB_EATTR_TIMER,
+  __MDBA_MDB_EATTR_MAX
+};
+#define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
+  MDB_RTR_TYPE_DISABLED,
+  MDB_RTR_TYPE_TEMP_QUERY,
+  MDB_RTR_TYPE_PERM,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MDB_RTR_TYPE_TEMP
+};
+enum {
+  MDBA_ROUTER_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MDBA_ROUTER_PORT,
   __MDBA_ROUTER_MAX,
 };
 #define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
+  MDBA_ROUTER_PATTR_UNSPEC,
+  MDBA_ROUTER_PATTR_TIMER,
+  MDBA_ROUTER_PATTR_TYPE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __MDBA_ROUTER_PATTR_MAX
+};
+#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
 struct br_port_msg {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 family;
@@ -186,23 +221,33 @@
 #define MDB_PERMANENT 1
   __u8 state;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MDB_FLAGS_OFFLOAD (1 << 0)
+  __u8 flags;
   __u16 vid;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     union {
       __be32 ip4;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       struct in6_addr ip6;
     } u;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __be16 proto;
   } addr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   MDBA_SET_ENTRY_UNSPEC,
   MDBA_SET_ENTRY,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __MDBA_SET_ENTRY_MAX,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
+enum {
+  BRIDGE_XSTATS_UNSPEC,
+  BRIDGE_XSTATS_VLAN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __BRIDGE_XSTATS_MAX
+};
+#define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/if_ether.h b/libc/kernel/uapi/linux/if_ether.h
index 3f36781..2aeb381 100644
--- a/libc/kernel/uapi/linux/if_ether.h
+++ b/libc/kernel/uapi/linux/if_ether.h
@@ -78,61 +78,63 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_802_EX1 0x88B5
 #define ETH_P_TIPC 0x88CA
+#define ETH_P_MACSEC 0x88E5
 #define ETH_P_8021AH 0x88E7
-#define ETH_P_MVRP 0x88F5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETH_P_MVRP 0x88F5
 #define ETH_P_1588 0x88F7
 #define ETH_P_PRP 0x88FB
 #define ETH_P_FCOE 0x8906
-#define ETH_P_TDLS 0x890D
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ETH_P_TDLS 0x890D
 #define ETH_P_FIP 0x8914
 #define ETH_P_80221 0x8917
+#define ETH_P_HSR 0x892F
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_LOOPBACK 0x9000
 #define ETH_P_QINQ1 0x9100
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_QINQ2 0x9200
 #define ETH_P_QINQ3 0x9300
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_EDSA 0xDADA
 #define ETH_P_AF_IUCV 0xFBFB
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_802_3_MIN 0x0600
 #define ETH_P_802_3 0x0001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_AX25 0x0002
 #define ETH_P_ALL 0x0003
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_802_2 0x0004
 #define ETH_P_SNAP 0x0005
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_DDCMP 0x0006
 #define ETH_P_WAN_PPP 0x0007
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_PPP_MP 0x0008
 #define ETH_P_LOCALTALK 0x0009
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_CAN 0x000C
 #define ETH_P_CANFD 0x000D
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_PPPTALK 0x0010
 #define ETH_P_TR_802_2 0x0011
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_MOBITEX 0x0015
 #define ETH_P_CONTROL 0x0016
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_IRDA 0x0017
 #define ETH_P_ECONET 0x0018
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_HDLC 0x0019
 #define ETH_P_ARCNET 0x001A
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_DSA 0x001B
 #define ETH_P_TRAILER 0x001C
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_PHONET 0x00F5
 #define ETH_P_IEEE802154 0x00F6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ETH_P_CAIF 0x00F7
 #define ETH_P_XDSA 0x00F8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ethhdr {
   unsigned char h_dest[ETH_ALEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char h_source[ETH_ALEN];
   __be16 h_proto;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/if_link.h b/libc/kernel/uapi/linux/if_link.h
index 226968d..ce990c7 100644
--- a/libc/kernel/uapi/linux/if_link.h
+++ b/libc/kernel/uapi/linux/if_link.h
@@ -51,199 +51,209 @@
   __u32 rx_compressed;
   __u32 tx_compressed;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rx_nohandler;
 };
 struct rtnl_link_stats64 {
   __u64 rx_packets;
-  __u64 tx_packets;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 tx_packets;
   __u64 rx_bytes;
   __u64 tx_bytes;
   __u64 rx_errors;
-  __u64 tx_errors;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 tx_errors;
   __u64 rx_dropped;
   __u64 tx_dropped;
   __u64 multicast;
-  __u64 collisions;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 collisions;
   __u64 rx_length_errors;
   __u64 rx_over_errors;
   __u64 rx_crc_errors;
-  __u64 rx_frame_errors;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 rx_frame_errors;
   __u64 rx_fifo_errors;
   __u64 rx_missed_errors;
   __u64 tx_aborted_errors;
-  __u64 tx_carrier_errors;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 tx_carrier_errors;
   __u64 tx_fifo_errors;
   __u64 tx_heartbeat_errors;
   __u64 tx_window_errors;
-  __u64 rx_compressed;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 rx_compressed;
   __u64 tx_compressed;
+  __u64 rx_nohandler;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct rtnl_link_ifmap {
   __u64 mem_start;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 mem_end;
   __u64 base_addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 irq;
   __u8 dma;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 port;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   IFLA_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_ADDRESS,
   IFLA_BROADCAST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_IFNAME,
   IFLA_MTU,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_LINK,
   IFLA_QDISC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_STATS,
   IFLA_COST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_COST IFLA_COST
   IFLA_PRIORITY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_PRIORITY IFLA_PRIORITY
   IFLA_MASTER,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_MASTER IFLA_MASTER
   IFLA_WIRELESS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_WIRELESS IFLA_WIRELESS
   IFLA_PROTINFO,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_PROTINFO IFLA_PROTINFO
   IFLA_TXQLEN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_TXQLEN IFLA_TXQLEN
   IFLA_MAP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_MAP IFLA_MAP
   IFLA_WEIGHT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_WEIGHT IFLA_WEIGHT
   IFLA_OPERSTATE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_LINKMODE,
   IFLA_LINKINFO,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IFLA_LINKINFO IFLA_LINKINFO
   IFLA_NET_NS_PID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_IFALIAS,
   IFLA_NUM_VF,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_VFINFO_LIST,
   IFLA_STATS64,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_VF_PORTS,
   IFLA_PORT_SELF,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_AF_SPEC,
   IFLA_GROUP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_NET_NS_FD,
   IFLA_EXT_MASK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_PROMISCUITY,
 #define IFLA_PROMISCUITY IFLA_PROMISCUITY
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_NUM_TX_QUEUES,
   IFLA_NUM_RX_QUEUES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_CARRIER,
   IFLA_PHYS_PORT_ID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_CARRIER_CHANGES,
   IFLA_PHYS_SWITCH_ID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_LINK_NETNSID,
   IFLA_PHYS_PORT_NAME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_PROTO_DOWN,
+  IFLA_GSO_MAX_SEGS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_GSO_MAX_SIZE,
+  IFLA_PAD,
   __IFLA_MAX
 };
-#define IFLA_MAX (__IFLA_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_MAX (__IFLA_MAX - 1)
 #define IFLA_RTA(r) ((struct rtattr *) (((char *) (r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct ifinfomsg))
 enum {
-  IFLA_INET_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_INET_UNSPEC,
   IFLA_INET_CONF,
   __IFLA_INET_MAX,
 };
-#define IFLA_INET_MAX (__IFLA_INET_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_INET_MAX (__IFLA_INET_MAX - 1)
 enum {
   IFLA_INET6_UNSPEC,
   IFLA_INET6_FLAGS,
-  IFLA_INET6_CONF,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_INET6_CONF,
   IFLA_INET6_STATS,
   IFLA_INET6_MCAST,
   IFLA_INET6_CACHEINFO,
-  IFLA_INET6_ICMP6STATS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_INET6_ICMP6STATS,
   IFLA_INET6_TOKEN,
   IFLA_INET6_ADDR_GEN_MODE,
   __IFLA_INET6_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
 enum in6_addr_gen_mode {
   IN6_ADDR_GEN_MODE_EUI64,
-  IN6_ADDR_GEN_MODE_NONE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IN6_ADDR_GEN_MODE_NONE,
   IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
+  IN6_ADDR_GEN_MODE_RANDOM,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   IFLA_BR_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_FORWARD_DELAY,
   IFLA_BR_HELLO_TIME,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MAX_AGE,
   IFLA_BR_AGEING_TIME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_STP_STATE,
   IFLA_BR_PRIORITY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_VLAN_FILTERING,
   IFLA_BR_VLAN_PROTOCOL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_GROUP_FWD_MASK,
   IFLA_BR_ROOT_ID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_BRIDGE_ID,
   IFLA_BR_ROOT_PORT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_ROOT_PATH_COST,
   IFLA_BR_TOPOLOGY_CHANGE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_TOPOLOGY_CHANGE_DETECTED,
   IFLA_BR_HELLO_TIMER,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_TCN_TIMER,
   IFLA_BR_TOPOLOGY_CHANGE_TIMER,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_GC_TIMER,
   IFLA_BR_GROUP_ADDR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_FDB_FLUSH,
   IFLA_BR_MCAST_ROUTER,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MCAST_SNOOPING,
   IFLA_BR_MCAST_QUERY_USE_IFADDR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MCAST_QUERIER,
   IFLA_BR_MCAST_HASH_ELASTICITY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MCAST_HASH_MAX,
   IFLA_BR_MCAST_LAST_MEMBER_CNT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MCAST_STARTUP_QUERY_CNT,
   IFLA_BR_MCAST_LAST_MEMBER_INTVL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MCAST_MEMBERSHIP_INTVL,
   IFLA_BR_MCAST_QUERIER_INTVL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MCAST_QUERY_INTVL,
   IFLA_BR_MCAST_QUERY_RESPONSE_INTVL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_MCAST_STARTUP_QUERY_INTVL,
   IFLA_BR_NF_CALL_IPTABLES,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_NF_CALL_IP6TABLES,
   IFLA_BR_NF_CALL_ARPTABLES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BR_VLAN_DEFAULT_PVID,
+  IFLA_BR_PAD,
+  IFLA_BR_VLAN_STATS_ENABLED,
   __IFLA_BR_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
@@ -292,317 +302,392 @@
   IFLA_BRPORT_FLUSH,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_BRPORT_MULTICAST_ROUTER,
+  IFLA_BRPORT_PAD,
   __IFLA_BRPORT_MAX
 };
-#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
 struct ifla_cacheinfo {
   __u32 max_reasm_len;
   __u32 tstamp;
-  __u32 reachable_time;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reachable_time;
   __u32 retrans_time;
 };
 enum {
-  IFLA_INFO_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_INFO_UNSPEC,
   IFLA_INFO_KIND,
   IFLA_INFO_DATA,
   IFLA_INFO_XSTATS,
-  IFLA_INFO_SLAVE_KIND,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_INFO_SLAVE_KIND,
   IFLA_INFO_SLAVE_DATA,
   __IFLA_INFO_MAX,
 };
-#define IFLA_INFO_MAX (__IFLA_INFO_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_INFO_MAX (__IFLA_INFO_MAX - 1)
 enum {
   IFLA_VLAN_UNSPEC,
   IFLA_VLAN_ID,
-  IFLA_VLAN_FLAGS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VLAN_FLAGS,
   IFLA_VLAN_EGRESS_QOS,
   IFLA_VLAN_INGRESS_QOS,
   IFLA_VLAN_PROTOCOL,
-  __IFLA_VLAN_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __IFLA_VLAN_MAX,
 };
 #define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1)
 struct ifla_vlan_flags {
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 mask;
 };
 enum {
-  IFLA_VLAN_QOS_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VLAN_QOS_UNSPEC,
   IFLA_VLAN_QOS_MAPPING,
   __IFLA_VLAN_QOS_MAX
 };
-#define IFLA_VLAN_QOS_MAX (__IFLA_VLAN_QOS_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_VLAN_QOS_MAX (__IFLA_VLAN_QOS_MAX - 1)
 struct ifla_vlan_qos_mapping {
   __u32 from;
   __u32 to;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum {
   IFLA_MACVLAN_UNSPEC,
   IFLA_MACVLAN_MODE,
-  IFLA_MACVLAN_FLAGS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_MACVLAN_FLAGS,
   IFLA_MACVLAN_MACADDR_MODE,
   IFLA_MACVLAN_MACADDR,
   IFLA_MACVLAN_MACADDR_DATA,
-  IFLA_MACVLAN_MACADDR_COUNT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_MACVLAN_MACADDR_COUNT,
   __IFLA_MACVLAN_MAX,
 };
 #define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1)
-enum macvlan_mode {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum macvlan_mode {
   MACVLAN_MODE_PRIVATE = 1,
   MACVLAN_MODE_VEPA = 2,
   MACVLAN_MODE_BRIDGE = 4,
-  MACVLAN_MODE_PASSTHRU = 8,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACVLAN_MODE_PASSTHRU = 8,
   MACVLAN_MODE_SOURCE = 16,
 };
 enum macvlan_macaddr_mode {
-  MACVLAN_MACADDR_ADD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACVLAN_MACADDR_ADD,
   MACVLAN_MACADDR_DEL,
   MACVLAN_MACADDR_FLUSH,
   MACVLAN_MACADDR_SET,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define MACVLAN_FLAG_NOPROMISC 1
 enum {
   IFLA_VRF_UNSPEC,
-  IFLA_VRF_TABLE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VRF_TABLE,
   __IFLA_VRF_MAX
 };
 #define IFLA_VRF_MAX (__IFLA_VRF_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
+  IFLA_VRF_PORT_UNSPEC,
+  IFLA_VRF_PORT_TABLE,
+  __IFLA_VRF_PORT_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define IFLA_VRF_PORT_MAX (__IFLA_VRF_PORT_MAX - 1)
+enum {
+  IFLA_MACSEC_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_MACSEC_SCI,
+  IFLA_MACSEC_PORT,
+  IFLA_MACSEC_ICV_LEN,
+  IFLA_MACSEC_CIPHER_SUITE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_MACSEC_WINDOW,
+  IFLA_MACSEC_ENCODING_SA,
+  IFLA_MACSEC_ENCRYPT,
+  IFLA_MACSEC_PROTECT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_MACSEC_INC_SCI,
+  IFLA_MACSEC_ES,
+  IFLA_MACSEC_SCB,
+  IFLA_MACSEC_REPLAY_PROTECT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_MACSEC_VALIDATION,
+  IFLA_MACSEC_PAD,
+  __IFLA_MACSEC_MAX,
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_MACSEC_MAX (__IFLA_MACSEC_MAX - 1)
+enum macsec_validation_type {
+  MACSEC_VALIDATE_DISABLED = 0,
+  MACSEC_VALIDATE_CHECK = 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_VALIDATE_STRICT = 2,
+  __MACSEC_VALIDATE_END,
+  MACSEC_VALIDATE_MAX = __MACSEC_VALIDATE_END - 1,
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   IFLA_IPVLAN_UNSPEC,
   IFLA_IPVLAN_MODE,
   __IFLA_IPVLAN_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1)
 enum ipvlan_mode {
   IPVLAN_MODE_L2 = 0,
-  IPVLAN_MODE_L3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPVLAN_MODE_L3,
   IPVLAN_MODE_MAX
 };
 enum {
-  IFLA_VXLAN_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VXLAN_UNSPEC,
   IFLA_VXLAN_ID,
   IFLA_VXLAN_GROUP,
   IFLA_VXLAN_LINK,
-  IFLA_VXLAN_LOCAL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VXLAN_LOCAL,
   IFLA_VXLAN_TTL,
   IFLA_VXLAN_TOS,
   IFLA_VXLAN_LEARNING,
-  IFLA_VXLAN_AGEING,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VXLAN_AGEING,
   IFLA_VXLAN_LIMIT,
   IFLA_VXLAN_PORT_RANGE,
   IFLA_VXLAN_PROXY,
-  IFLA_VXLAN_RSC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VXLAN_RSC,
   IFLA_VXLAN_L2MISS,
   IFLA_VXLAN_L3MISS,
   IFLA_VXLAN_PORT,
-  IFLA_VXLAN_GROUP6,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VXLAN_GROUP6,
   IFLA_VXLAN_LOCAL6,
   IFLA_VXLAN_UDP_CSUM,
   IFLA_VXLAN_UDP_ZERO_CSUM6_TX,
-  IFLA_VXLAN_UDP_ZERO_CSUM6_RX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VXLAN_UDP_ZERO_CSUM6_RX,
   IFLA_VXLAN_REMCSUM_TX,
   IFLA_VXLAN_REMCSUM_RX,
   IFLA_VXLAN_GBP,
-  IFLA_VXLAN_REMCSUM_NOPARTIAL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VXLAN_REMCSUM_NOPARTIAL,
   IFLA_VXLAN_COLLECT_METADATA,
+  IFLA_VXLAN_LABEL,
+  IFLA_VXLAN_GPE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __IFLA_VXLAN_MAX
 };
 #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ifla_vxlan_port_range {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be16 low;
   __be16 high;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_GENEVE_UNSPEC,
   IFLA_GENEVE_ID,
   IFLA_GENEVE_REMOTE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_GENEVE_TTL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_GENEVE_TOS,
   IFLA_GENEVE_PORT,
   IFLA_GENEVE_COLLECT_METADATA,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_GENEVE_REMOTE6,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_GENEVE_UDP_CSUM,
+  IFLA_GENEVE_UDP_ZERO_CSUM6_TX,
+  IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
+  IFLA_GENEVE_LABEL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __IFLA_GENEVE_MAX
 };
 #define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
+enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_PPP_UNSPEC,
+  IFLA_PPP_DEV_FD,
+  __IFLA_PPP_MAX
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_PPP_MAX (__IFLA_PPP_MAX - 1)
+enum {
+  IFLA_GTP_UNSPEC,
+  IFLA_GTP_FD0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_GTP_FD1,
+  IFLA_GTP_PDP_HASHSIZE,
+  __IFLA_GTP_MAX,
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)
 enum {
   IFLA_BOND_UNSPEC,
   IFLA_BOND_MODE,
-  IFLA_BOND_ACTIVE_SLAVE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_ACTIVE_SLAVE,
   IFLA_BOND_MIIMON,
   IFLA_BOND_UPDELAY,
   IFLA_BOND_DOWNDELAY,
-  IFLA_BOND_USE_CARRIER,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_USE_CARRIER,
   IFLA_BOND_ARP_INTERVAL,
   IFLA_BOND_ARP_IP_TARGET,
   IFLA_BOND_ARP_VALIDATE,
-  IFLA_BOND_ARP_ALL_TARGETS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_ARP_ALL_TARGETS,
   IFLA_BOND_PRIMARY,
   IFLA_BOND_PRIMARY_RESELECT,
   IFLA_BOND_FAIL_OVER_MAC,
-  IFLA_BOND_XMIT_HASH_POLICY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_XMIT_HASH_POLICY,
   IFLA_BOND_RESEND_IGMP,
   IFLA_BOND_NUM_PEER_NOTIF,
   IFLA_BOND_ALL_SLAVES_ACTIVE,
-  IFLA_BOND_MIN_LINKS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_MIN_LINKS,
   IFLA_BOND_LP_INTERVAL,
   IFLA_BOND_PACKETS_PER_SLAVE,
   IFLA_BOND_AD_LACP_RATE,
-  IFLA_BOND_AD_SELECT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_AD_SELECT,
   IFLA_BOND_AD_INFO,
   IFLA_BOND_AD_ACTOR_SYS_PRIO,
   IFLA_BOND_AD_USER_PORT_KEY,
-  IFLA_BOND_AD_ACTOR_SYSTEM,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_AD_ACTOR_SYSTEM,
   IFLA_BOND_TLB_DYNAMIC_LB,
   __IFLA_BOND_MAX,
 };
-#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1)
 enum {
   IFLA_BOND_AD_INFO_UNSPEC,
   IFLA_BOND_AD_INFO_AGGREGATOR,
-  IFLA_BOND_AD_INFO_NUM_PORTS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_AD_INFO_NUM_PORTS,
   IFLA_BOND_AD_INFO_ACTOR_KEY,
   IFLA_BOND_AD_INFO_PARTNER_KEY,
   IFLA_BOND_AD_INFO_PARTNER_MAC,
-  __IFLA_BOND_AD_INFO_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __IFLA_BOND_AD_INFO_MAX,
 };
 #define IFLA_BOND_AD_INFO_MAX (__IFLA_BOND_AD_INFO_MAX - 1)
 enum {
-  IFLA_BOND_SLAVE_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_SLAVE_UNSPEC,
   IFLA_BOND_SLAVE_STATE,
   IFLA_BOND_SLAVE_MII_STATUS,
   IFLA_BOND_SLAVE_LINK_FAILURE_COUNT,
-  IFLA_BOND_SLAVE_PERM_HWADDR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_SLAVE_PERM_HWADDR,
   IFLA_BOND_SLAVE_QUEUE_ID,
   IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
   IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
-  IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
   __IFLA_BOND_SLAVE_MAX,
 };
 #define IFLA_BOND_SLAVE_MAX (__IFLA_BOND_SLAVE_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   IFLA_VF_INFO_UNSPEC,
   IFLA_VF_INFO,
   __IFLA_VF_INFO_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IFLA_VF_INFO_MAX (__IFLA_VF_INFO_MAX - 1)
 enum {
   IFLA_VF_UNSPEC,
-  IFLA_VF_MAC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VF_MAC,
   IFLA_VF_VLAN,
   IFLA_VF_TX_RATE,
   IFLA_VF_SPOOFCHK,
-  IFLA_VF_LINK_STATE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VF_LINK_STATE,
   IFLA_VF_RATE,
   IFLA_VF_RSS_QUERY_EN,
   IFLA_VF_STATS,
-  IFLA_VF_TRUST,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_VF_TRUST,
+  IFLA_VF_IB_NODE_GUID,
+  IFLA_VF_IB_PORT_GUID,
   __IFLA_VF_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define IFLA_VF_MAX (__IFLA_VF_MAX - 1)
 struct ifla_vf_mac {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vf;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 mac[32];
 };
 struct ifla_vf_vlan {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vf;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vlan;
   __u32 qos;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ifla_vf_tx_rate {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vf;
   __u32 rate;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ifla_vf_rate {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vf;
   __u32 min_tx_rate;
   __u32 max_tx_rate;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ifla_vf_spoofchk {
   __u32 vf;
   __u32 setting;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ifla_vf_guid {
+  __u32 vf;
+  __u64 guid;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   IFLA_VF_LINK_STATE_AUTO,
   IFLA_VF_LINK_STATE_ENABLE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_VF_LINK_STATE_DISABLE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __IFLA_VF_LINK_STATE_MAX,
 };
 struct ifla_vf_link_state {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vf;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 link_state;
 };
 struct ifla_vf_rss_query_en {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vf;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 setting;
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_VF_STATS_RX_PACKETS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_VF_STATS_TX_PACKETS,
   IFLA_VF_STATS_RX_BYTES,
   IFLA_VF_STATS_TX_BYTES,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_VF_STATS_BROADCAST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IFLA_VF_STATS_MULTICAST,
+  IFLA_VF_STATS_PAD,
   __IFLA_VF_STATS_MAX,
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -696,8 +781,35 @@
   IFLA_HSR_SUPERVISION_ADDR,
   IFLA_HSR_SEQ_NR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_HSR_VERSION,
   __IFLA_HSR_MAX,
 };
 #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct if_stats_msg {
+  __u8 family;
+  __u8 pad1;
+  __u16 pad2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ifindex;
+  __u32 filter_mask;
+};
+enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IFLA_STATS_UNSPEC,
+  IFLA_STATS_LINK_64,
+  IFLA_STATS_LINK_XSTATS,
+  __IFLA_STATS_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define IFLA_STATS_MAX (__IFLA_STATS_MAX - 1)
+#define IFLA_STATS_FILTER_BIT(ATTR) (1 << (ATTR - 1))
+enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  LINK_XSTATS_TYPE_UNSPEC,
+  LINK_XSTATS_TYPE_BRIDGE,
+  __LINK_XSTATS_TYPE_MAX
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1)
+#endif
diff --git a/libc/kernel/uapi/linux/if_macsec.h b/libc/kernel/uapi/linux/if_macsec.h
new file mode 100644
index 0000000..68e039e
--- /dev/null
+++ b/libc/kernel/uapi/linux/if_macsec.h
@@ -0,0 +1,190 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_MACSEC_H
+#define _UAPI_MACSEC_H
+#include <linux/types.h>
+#define MACSEC_GENL_NAME "macsec"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MACSEC_GENL_VERSION 1
+#define MACSEC_MAX_KEY_LEN 128
+#define MACSEC_KEYID_LEN 16
+#define MACSEC_DEFAULT_CIPHER_ID 0x0080020001000001ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MACSEC_DEFAULT_CIPHER_ALT 0x0080C20001000001ULL
+#define MACSEC_MIN_ICV_LEN 8
+#define MACSEC_MAX_ICV_LEN 32
+enum macsec_attrs {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_ATTR_UNSPEC,
+  MACSEC_ATTR_IFINDEX,
+  MACSEC_ATTR_RXSC_CONFIG,
+  MACSEC_ATTR_SA_CONFIG,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_ATTR_SECY,
+  MACSEC_ATTR_TXSA_LIST,
+  MACSEC_ATTR_RXSC_LIST,
+  MACSEC_ATTR_TXSC_STATS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_ATTR_SECY_STATS,
+  __MACSEC_ATTR_END,
+  NUM_MACSEC_ATTR = __MACSEC_ATTR_END,
+  MACSEC_ATTR_MAX = __MACSEC_ATTR_END - 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+enum macsec_secy_attrs {
+  MACSEC_SECY_ATTR_UNSPEC,
+  MACSEC_SECY_ATTR_SCI,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SECY_ATTR_ENCODING_SA,
+  MACSEC_SECY_ATTR_WINDOW,
+  MACSEC_SECY_ATTR_CIPHER_SUITE,
+  MACSEC_SECY_ATTR_ICV_LEN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SECY_ATTR_PROTECT,
+  MACSEC_SECY_ATTR_REPLAY,
+  MACSEC_SECY_ATTR_OPER,
+  MACSEC_SECY_ATTR_VALIDATE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SECY_ATTR_ENCRYPT,
+  MACSEC_SECY_ATTR_INC_SCI,
+  MACSEC_SECY_ATTR_ES,
+  MACSEC_SECY_ATTR_SCB,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SECY_ATTR_PAD,
+  __MACSEC_SECY_ATTR_END,
+  NUM_MACSEC_SECY_ATTR = __MACSEC_SECY_ATTR_END,
+  MACSEC_SECY_ATTR_MAX = __MACSEC_SECY_ATTR_END - 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+enum macsec_rxsc_attrs {
+  MACSEC_RXSC_ATTR_UNSPEC,
+  MACSEC_RXSC_ATTR_SCI,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_RXSC_ATTR_ACTIVE,
+  MACSEC_RXSC_ATTR_SA_LIST,
+  MACSEC_RXSC_ATTR_STATS,
+  MACSEC_RXSC_ATTR_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __MACSEC_RXSC_ATTR_END,
+  NUM_MACSEC_RXSC_ATTR = __MACSEC_RXSC_ATTR_END,
+  MACSEC_RXSC_ATTR_MAX = __MACSEC_RXSC_ATTR_END - 1,
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum macsec_sa_attrs {
+  MACSEC_SA_ATTR_UNSPEC,
+  MACSEC_SA_ATTR_AN,
+  MACSEC_SA_ATTR_ACTIVE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SA_ATTR_PN,
+  MACSEC_SA_ATTR_KEY,
+  MACSEC_SA_ATTR_KEYID,
+  MACSEC_SA_ATTR_STATS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SA_ATTR_PAD,
+  __MACSEC_SA_ATTR_END,
+  NUM_MACSEC_SA_ATTR = __MACSEC_SA_ATTR_END,
+  MACSEC_SA_ATTR_MAX = __MACSEC_SA_ATTR_END - 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+enum macsec_nl_commands {
+  MACSEC_CMD_GET_TXSC,
+  MACSEC_CMD_ADD_RXSC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_CMD_DEL_RXSC,
+  MACSEC_CMD_UPD_RXSC,
+  MACSEC_CMD_ADD_TXSA,
+  MACSEC_CMD_DEL_TXSA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_CMD_UPD_TXSA,
+  MACSEC_CMD_ADD_RXSA,
+  MACSEC_CMD_DEL_RXSA,
+  MACSEC_CMD_UPD_RXSA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+enum macsec_rxsc_stats_attr {
+  MACSEC_RXSC_STATS_ATTR_UNSPEC,
+  MACSEC_RXSC_STATS_ATTR_IN_OCTETS_VALIDATED,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_RXSC_STATS_ATTR_IN_OCTETS_DECRYPTED,
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_UNCHECKED,
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_DELAYED,
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_OK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_INVALID,
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_LATE,
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_NOT_VALID,
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_NOT_USING_SA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_RXSC_STATS_ATTR_IN_PKTS_UNUSED_SA,
+  MACSEC_RXSC_STATS_ATTR_PAD,
+  __MACSEC_RXSC_STATS_ATTR_END,
+  NUM_MACSEC_RXSC_STATS_ATTR = __MACSEC_RXSC_STATS_ATTR_END,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_RXSC_STATS_ATTR_MAX = __MACSEC_RXSC_STATS_ATTR_END - 1,
+};
+enum macsec_sa_stats_attr {
+  MACSEC_SA_STATS_ATTR_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SA_STATS_ATTR_IN_PKTS_OK,
+  MACSEC_SA_STATS_ATTR_IN_PKTS_INVALID,
+  MACSEC_SA_STATS_ATTR_IN_PKTS_NOT_VALID,
+  MACSEC_SA_STATS_ATTR_IN_PKTS_NOT_USING_SA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SA_STATS_ATTR_IN_PKTS_UNUSED_SA,
+  MACSEC_SA_STATS_ATTR_OUT_PKTS_PROTECTED,
+  MACSEC_SA_STATS_ATTR_OUT_PKTS_ENCRYPTED,
+  __MACSEC_SA_STATS_ATTR_END,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NUM_MACSEC_SA_STATS_ATTR = __MACSEC_SA_STATS_ATTR_END,
+  MACSEC_SA_STATS_ATTR_MAX = __MACSEC_SA_STATS_ATTR_END - 1,
+};
+enum macsec_txsc_stats_attr {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_TXSC_STATS_ATTR_UNSPEC,
+  MACSEC_TXSC_STATS_ATTR_OUT_PKTS_PROTECTED,
+  MACSEC_TXSC_STATS_ATTR_OUT_PKTS_ENCRYPTED,
+  MACSEC_TXSC_STATS_ATTR_OUT_OCTETS_PROTECTED,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_TXSC_STATS_ATTR_OUT_OCTETS_ENCRYPTED,
+  MACSEC_TXSC_STATS_ATTR_PAD,
+  __MACSEC_TXSC_STATS_ATTR_END,
+  NUM_MACSEC_TXSC_STATS_ATTR = __MACSEC_TXSC_STATS_ATTR_END,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_TXSC_STATS_ATTR_MAX = __MACSEC_TXSC_STATS_ATTR_END - 1,
+};
+enum macsec_secy_stats_attr {
+  MACSEC_SECY_STATS_ATTR_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SECY_STATS_ATTR_OUT_PKTS_UNTAGGED,
+  MACSEC_SECY_STATS_ATTR_IN_PKTS_UNTAGGED,
+  MACSEC_SECY_STATS_ATTR_OUT_PKTS_TOO_LONG,
+  MACSEC_SECY_STATS_ATTR_IN_PKTS_NO_TAG,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SECY_STATS_ATTR_IN_PKTS_BAD_TAG,
+  MACSEC_SECY_STATS_ATTR_IN_PKTS_UNKNOWN_SCI,
+  MACSEC_SECY_STATS_ATTR_IN_PKTS_NO_SCI,
+  MACSEC_SECY_STATS_ATTR_IN_PKTS_OVERRUN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  MACSEC_SECY_STATS_ATTR_PAD,
+  __MACSEC_SECY_STATS_ATTR_END,
+  NUM_MACSEC_SECY_STATS_ATTR = __MACSEC_SECY_STATS_ATTR_END,
+  MACSEC_SECY_STATS_ATTR_MAX = __MACSEC_SECY_STATS_ATTR_END - 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#endif
diff --git a/libc/kernel/uapi/linux/if_pppolac.h b/libc/kernel/uapi/linux/if_pppolac.h
deleted file mode 100644
index 303a899..0000000
--- a/libc/kernel/uapi/linux/if_pppolac.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _UAPI_LINUX_IF_PPPOLAC_H
-#define _UAPI_LINUX_IF_PPPOLAC_H
-#include <linux/socket.h>
-#include <linux/types.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sockaddr_pppolac {
-  sa_family_t sa_family;
-  unsigned int sa_protocol;
-  int udp_socket;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  struct __attribute__((packed)) {
-    __u16 tunnel, session;
-  } local, remote;
-} __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/uapi/linux/iio/types.h b/libc/kernel/uapi/linux/iio/types.h
index 7520dbf..e17783c 100644
--- a/libc/kernel/uapi/linux/iio/types.h
+++ b/libc/kernel/uapi/linux/iio/types.h
@@ -52,70 +52,74 @@
   IIO_CONCENTRATION,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_RESISTANCE,
+  IIO_PH,
+  IIO_UVINDEX,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum iio_modifier {
   IIO_NO_MOD,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_X,
   IIO_MOD_Y,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_Z,
   IIO_MOD_X_AND_Y,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_X_AND_Z,
   IIO_MOD_Y_AND_Z,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_X_AND_Y_AND_Z,
   IIO_MOD_X_OR_Y,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_X_OR_Z,
   IIO_MOD_Y_OR_Z,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_X_OR_Y_OR_Z,
   IIO_MOD_LIGHT_BOTH,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_LIGHT_IR,
   IIO_MOD_ROOT_SUM_SQUARED_X_Y,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_SUM_SQUARED_X_Y_Z,
   IIO_MOD_LIGHT_CLEAR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_LIGHT_RED,
   IIO_MOD_LIGHT_GREEN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_LIGHT_BLUE,
   IIO_MOD_QUATERNION,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_TEMP_AMBIENT,
   IIO_MOD_TEMP_OBJECT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_NORTH_MAGN,
   IIO_MOD_NORTH_TRUE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_NORTH_MAGN_TILT_COMP,
   IIO_MOD_NORTH_TRUE_TILT_COMP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_RUNNING,
   IIO_MOD_JOGGING,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_WALKING,
   IIO_MOD_STILL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
   IIO_MOD_I,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_MOD_Q,
   IIO_MOD_CO2,
-  IIO_MOD_VOC,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IIO_MOD_VOC,
+  IIO_MOD_LIGHT_UV,
+};
 enum iio_event_type {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_EV_TYPE_THRESH,
   IIO_EV_TYPE_MAG,
   IIO_EV_TYPE_ROC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_EV_TYPE_THRESH_ADAPTIVE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_EV_TYPE_MAG_ADAPTIVE,
   IIO_EV_TYPE_CHANGE,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum iio_event_direction {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_EV_DIR_EITHER,
   IIO_EV_DIR_RISING,
   IIO_EV_DIR_FALLING,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IIO_EV_DIR_NONE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
diff --git a/libc/kernel/uapi/linux/ila.h b/libc/kernel/uapi/linux/ila.h
index dc036d7..187b4b9 100644
--- a/libc/kernel/uapi/linux/ila.h
+++ b/libc/kernel/uapi/linux/ila.h
@@ -18,12 +18,41 @@
  ****************************************************************************/
 #ifndef _UAPI_LINUX_ILA_H
 #define _UAPI_LINUX_ILA_H
+#define ILA_GENL_NAME "ila"
+#define ILA_GENL_VERSION 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   ILA_ATTR_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ILA_ATTR_LOCATOR,
+  ILA_ATTR_IDENTIFIER,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ILA_ATTR_LOCATOR_MATCH,
+  ILA_ATTR_IFINDEX,
+  ILA_ATTR_DIR,
+  ILA_ATTR_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ILA_ATTR_CSUM_MODE,
   __ILA_ATTR_MAX,
 };
 #define ILA_ATTR_MAX (__ILA_ATTR_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
+  ILA_CMD_UNSPEC,
+  ILA_CMD_ADD,
+  ILA_CMD_DEL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ILA_CMD_GET,
+  __ILA_CMD_MAX,
+};
+#define ILA_CMD_MAX (__ILA_CMD_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ILA_DIR_IN (1 << 0)
+#define ILA_DIR_OUT (1 << 1)
+enum {
+  ILA_CSUM_ADJUST_TRANSPORT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ILA_CSUM_NEUTRAL_MAP,
+  ILA_CSUM_NO_ACTION,
+};
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/in6.h b/libc/kernel/uapi/linux/in6.h
index e54bc33..6533f8d 100644
--- a/libc/kernel/uapi/linux/in6.h
+++ b/libc/kernel/uapi/linux/in6.h
@@ -172,43 +172,44 @@
 #define IPV6_IPSEC_POLICY 34
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IPV6_XFRM_POLICY 35
+#define IPV6_HDRINCL 36
 #endif
 #define IPV6_RECVPKTINFO 49
-#define IPV6_PKTINFO 50
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_PKTINFO 50
 #define IPV6_RECVHOPLIMIT 51
 #define IPV6_HOPLIMIT 52
 #define IPV6_RECVHOPOPTS 53
-#define IPV6_HOPOPTS 54
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_HOPOPTS 54
 #define IPV6_RTHDRDSTOPTS 55
 #define IPV6_RECVRTHDR 56
 #define IPV6_RTHDR 57
-#define IPV6_RECVDSTOPTS 58
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_RECVDSTOPTS 58
 #define IPV6_DSTOPTS 59
 #define IPV6_RECVPATHMTU 60
 #define IPV6_PATHMTU 61
-#define IPV6_DONTFRAG 62
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_DONTFRAG 62
 #define IPV6_RECVTCLASS 66
 #define IPV6_TCLASS 67
 #define IPV6_AUTOFLOWLABEL 70
-#define IPV6_ADDR_PREFERENCES 72
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_ADDR_PREFERENCES 72
 #define IPV6_PREFER_SRC_TMP 0x0001
 #define IPV6_PREFER_SRC_PUBLIC 0x0002
 #define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
-#define IPV6_PREFER_SRC_COA 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_PREFER_SRC_COA 0x0004
 #define IPV6_PREFER_SRC_HOME 0x0400
 #define IPV6_PREFER_SRC_CGA 0x0008
 #define IPV6_PREFER_SRC_NONCGA 0x0800
-#define IPV6_MINHOPCOUNT 73
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_MINHOPCOUNT 73
 #define IPV6_ORIGDSTADDR 74
 #define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
 #define IPV6_TRANSPARENT 75
-#define IPV6_UNICAST_IF 76
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPV6_UNICAST_IF 76
 #endif
diff --git a/libc/kernel/uapi/linux/inet_diag.h b/libc/kernel/uapi/linux/inet_diag.h
index d904418..9ebba1c 100644
--- a/libc/kernel/uapi/linux/inet_diag.h
+++ b/libc/kernel/uapi/linux/inet_diag.h
@@ -121,8 +121,13 @@
   INET_DIAG_PROTOCOL,
   INET_DIAG_SKV6ONLY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  INET_DIAG_LOCALS,
+  INET_DIAG_PEERS,
+  INET_DIAG_PAD,
+  __INET_DIAG_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define INET_DIAG_MAX INET_DIAG_SKV6ONLY
+#define INET_DIAG_MAX (__INET_DIAG_MAX - 1)
 struct inet_diag_meminfo {
   __u32 idiag_rmem;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/input-event-codes.h b/libc/kernel/uapi/linux/input-event-codes.h
index 3bf47e9..e905b7e 100644
--- a/libc/kernel/uapi/linux/input-event-codes.h
+++ b/libc/kernel/uapi/linux/input-event-codes.h
@@ -678,188 +678,212 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_KBDINPUTASSIST_ACCEPT 0x264
 #define KEY_KBDINPUTASSIST_CANCEL 0x265
+#define KEY_RIGHT_UP 0x266
+#define KEY_RIGHT_DOWN 0x267
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_LEFT_UP 0x268
+#define KEY_LEFT_DOWN 0x269
+#define KEY_ROOT_MENU 0x26a
+#define KEY_MEDIA_TOP_MENU 0x26b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_NUMERIC_11 0x26c
+#define KEY_NUMERIC_12 0x26d
+#define KEY_AUDIO_DESC 0x26e
+#define KEY_3D_MODE 0x26f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_NEXT_FAVORITE 0x270
+#define KEY_STOP_RECORD 0x271
+#define KEY_PAUSE_RECORD 0x272
+#define KEY_VOD 0x273
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_UNMUTE 0x274
+#define KEY_FASTREVERSE 0x275
+#define KEY_SLOWREVERSE 0x276
+#define KEY_DATA 0x275
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY 0x2c0
 #define BTN_TRIGGER_HAPPY1 0x2c0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY2 0x2c1
 #define BTN_TRIGGER_HAPPY3 0x2c2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY4 0x2c3
 #define BTN_TRIGGER_HAPPY5 0x2c4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY6 0x2c5
 #define BTN_TRIGGER_HAPPY7 0x2c6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY8 0x2c7
 #define BTN_TRIGGER_HAPPY9 0x2c8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY10 0x2c9
 #define BTN_TRIGGER_HAPPY11 0x2ca
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY12 0x2cb
 #define BTN_TRIGGER_HAPPY13 0x2cc
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY14 0x2cd
 #define BTN_TRIGGER_HAPPY15 0x2ce
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY16 0x2cf
 #define BTN_TRIGGER_HAPPY17 0x2d0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY18 0x2d1
 #define BTN_TRIGGER_HAPPY19 0x2d2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY20 0x2d3
 #define BTN_TRIGGER_HAPPY21 0x2d4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY22 0x2d5
 #define BTN_TRIGGER_HAPPY23 0x2d6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY24 0x2d7
 #define BTN_TRIGGER_HAPPY25 0x2d8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY26 0x2d9
 #define BTN_TRIGGER_HAPPY27 0x2da
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY28 0x2db
 #define BTN_TRIGGER_HAPPY29 0x2dc
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY30 0x2dd
 #define BTN_TRIGGER_HAPPY31 0x2de
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY32 0x2df
 #define BTN_TRIGGER_HAPPY33 0x2e0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY34 0x2e1
 #define BTN_TRIGGER_HAPPY35 0x2e2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY36 0x2e3
 #define BTN_TRIGGER_HAPPY37 0x2e4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY38 0x2e5
 #define BTN_TRIGGER_HAPPY39 0x2e6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY40 0x2e7
 #define KEY_MIN_INTERESTING KEY_MUTE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_MAX 0x2ff
 #define KEY_CNT (KEY_MAX + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REL_X 0x00
 #define REL_Y 0x01
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REL_Z 0x02
 #define REL_RX 0x03
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REL_RY 0x04
 #define REL_RZ 0x05
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REL_HWHEEL 0x06
 #define REL_DIAL 0x07
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REL_WHEEL 0x08
 #define REL_MISC 0x09
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REL_MAX 0x0f
 #define REL_CNT (REL_MAX + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_X 0x00
 #define ABS_Y 0x01
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_Z 0x02
 #define ABS_RX 0x03
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_RY 0x04
 #define ABS_RZ 0x05
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_THROTTLE 0x06
 #define ABS_RUDDER 0x07
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_WHEEL 0x08
 #define ABS_GAS 0x09
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_BRAKE 0x0a
 #define ABS_HAT0X 0x10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_HAT0Y 0x11
 #define ABS_HAT1X 0x12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_HAT1Y 0x13
 #define ABS_HAT2X 0x14
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_HAT2Y 0x15
 #define ABS_HAT3X 0x16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_HAT3Y 0x17
 #define ABS_PRESSURE 0x18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_DISTANCE 0x19
 #define ABS_TILT_X 0x1a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_TILT_Y 0x1b
 #define ABS_TOOL_WIDTH 0x1c
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_VOLUME 0x20
 #define ABS_MISC 0x28
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_SLOT 0x2f
 #define ABS_MT_TOUCH_MAJOR 0x30
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_TOUCH_MINOR 0x31
 #define ABS_MT_WIDTH_MAJOR 0x32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_WIDTH_MINOR 0x33
 #define ABS_MT_ORIENTATION 0x34
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_POSITION_X 0x35
 #define ABS_MT_POSITION_Y 0x36
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_TOOL_TYPE 0x37
 #define ABS_MT_BLOB_ID 0x38
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_TRACKING_ID 0x39
 #define ABS_MT_PRESSURE 0x3a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_DISTANCE 0x3b
 #define ABS_MT_TOOL_X 0x3c
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_MT_TOOL_Y 0x3d
 #define ABS_MAX 0x3f
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ABS_CNT (ABS_MAX + 1)
 #define SW_LID 0x00
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_TABLET_MODE 0x01
 #define SW_HEADPHONE_INSERT 0x02
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_RFKILL_ALL 0x03
 #define SW_RADIO SW_RFKILL_ALL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_MICROPHONE_INSERT 0x04
 #define SW_DOCK 0x05
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_LINEOUT_INSERT 0x06
 #define SW_JACK_PHYSICAL_INSERT 0x07
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_VIDEOOUT_INSERT 0x08
 #define SW_CAMERA_LENS_COVER 0x09
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_KEYPAD_SLIDE 0x0a
 #define SW_FRONT_PROXIMITY 0x0b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_ROTATE_LOCK 0x0c
 #define SW_LINEIN_INSERT 0x0d
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_MUTE_DEVICE 0x0e
+#define SW_PEN_INSERTED 0x0f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SW_MAX 0x0f
 #define SW_CNT (SW_MAX + 1)
 #define MSC_SERIAL 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSC_PULSELED 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSC_GESTURE 0x02
 #define MSC_RAW 0x03
 #define MSC_SCAN 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSC_TIMESTAMP 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MSC_MAX 0x07
 #define MSC_CNT (MSC_MAX + 1)
 #define LED_NUML 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LED_CAPSL 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LED_SCROLLL 0x02
 #define LED_COMPOSE 0x03
 #define LED_KANA 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LED_SLEEP 0x05
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LED_SUSPEND 0x06
 #define LED_MUTE 0x07
 #define LED_MISC 0x08
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LED_MAIL 0x09
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LED_CHARGING 0x0a
 #define LED_MAX 0x0f
 #define LED_CNT (LED_MAX + 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REP_DELAY 0x00
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define REP_PERIOD 0x01
 #define REP_MAX 0x01
 #define REP_CNT (REP_MAX + 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SND_CLICK 0x00
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SND_BELL 0x01
 #define SND_TONE 0x02
 #define SND_MAX 0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SND_CNT (SND_MAX + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/input.h b/libc/kernel/uapi/linux/input.h
index 9fbebb6..641b141 100644
--- a/libc/kernel/uapi/linux/input.h
+++ b/libc/kernel/uapi/linux/input.h
@@ -131,115 +131,118 @@
 #define BUS_ATARI 0x1B
 #define BUS_SPI 0x1C
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BUS_RMI 0x1D
+#define BUS_CEC 0x1E
 #define MT_TOOL_FINGER 0
 #define MT_TOOL_PEN 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MT_TOOL_PALM 2
 #define MT_TOOL_MAX 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_STATUS_STOPPED 0x00
 #define FF_STATUS_PLAYING 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_STATUS_MAX 0x01
 struct ff_replay {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 length;
   __u16 delay;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ff_trigger {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 button;
   __u16 interval;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ff_envelope {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 attack_length;
   __u16 attack_level;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 fade_length;
   __u16 fade_level;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ff_constant_effect {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s16 level;
   struct ff_envelope envelope;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ff_ramp_effect {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s16 start_level;
   __s16 end_level;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct ff_envelope envelope;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ff_condition_effect {
   __u16 right_saturation;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 left_saturation;
   __s16 right_coeff;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s16 left_coeff;
   __u16 deadband;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s16 center;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ff_periodic_effect {
   __u16 waveform;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 period;
   __s16 magnitude;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s16 offset;
   __u16 phase;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct ff_envelope envelope;
   __u32 custom_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s16 __user * custom_data;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ff_rumble_effect {
   __u16 strong_magnitude;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 weak_magnitude;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ff_effect {
   __u16 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s16 id;
   __u16 direction;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct ff_trigger trigger;
   struct ff_replay replay;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
     struct ff_constant_effect constant;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct ff_ramp_effect ramp;
     struct ff_periodic_effect periodic;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct ff_condition_effect condition[2];
     struct ff_rumble_effect rumble;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } u;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_RUMBLE 0x50
 #define FF_PERIODIC 0x51
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_CONSTANT 0x52
 #define FF_SPRING 0x53
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_FRICTION 0x54
 #define FF_DAMPER 0x55
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_INERTIA 0x56
 #define FF_RAMP 0x57
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_EFFECT_MIN FF_RUMBLE
 #define FF_EFFECT_MAX FF_RAMP
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_SQUARE 0x58
 #define FF_TRIANGLE 0x59
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_SINE 0x5a
 #define FF_SAW_UP 0x5b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_SAW_DOWN 0x5c
 #define FF_CUSTOM 0x5d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_WAVEFORM_MIN FF_SQUARE
 #define FF_WAVEFORM_MAX FF_CUSTOM
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_GAIN 0x60
 #define FF_AUTOCENTER 0x61
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_MAX_EFFECTS FF_GAIN
 #define FF_MAX 0x7f
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FF_CNT (FF_MAX + 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/ioprio.h b/libc/kernel/uapi/linux/ioprio.h
deleted file mode 100644
index 5886e77..0000000
--- a/libc/kernel/uapi/linux/ioprio.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _UAPI_LINUX_IOPRIO_H
-#define _UAPI_LINUX_IOPRIO_H
-#define IOPRIO_BITS (16)
-#define IOPRIO_CLASS_SHIFT (13)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
-#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
-#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK)
-#define IOPRIO_PRIO_VALUE(class,data) (((class) << IOPRIO_CLASS_SHIFT) | data)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
-enum {
-  IOPRIO_CLASS_NONE,
-  IOPRIO_CLASS_RT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  IOPRIO_CLASS_BE,
-  IOPRIO_CLASS_IDLE,
-};
-#define IOPRIO_BE_NR (8)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum {
-  IOPRIO_WHO_PROCESS = 1,
-  IOPRIO_WHO_PGRP,
-  IOPRIO_WHO_USER,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-#define IOPRIO_NORM (4)
-#endif
diff --git a/libc/kernel/uapi/linux/ip.h b/libc/kernel/uapi/linux/ip.h
index a56f1d6..d8dac9c 100644
--- a/libc/kernel/uapi/linux/ip.h
+++ b/libc/kernel/uapi/linux/ip.h
@@ -174,8 +174,11 @@
   IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL,
   IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL,
   IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
-  __IPV4_DEVCONF_MAX
+  IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPV4_DEVCONF_DROP_GRATUITOUS_ARP,
+  __IPV4_DEVCONF_MAX
 };
 #define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/ip_vs.h b/libc/kernel/uapi/linux/ip_vs.h
index 2971861..97a9c21 100644
--- a/libc/kernel/uapi/linux/ip_vs.h
+++ b/libc/kernel/uapi/linux/ip_vs.h
@@ -326,16 +326,18 @@
   IPVS_STATS_ATTR_INBPS,
   IPVS_STATS_ATTR_OUTBPS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPVS_STATS_ATTR_PAD,
   __IPVS_STATS_ATTR_MAX,
 };
 #define IPVS_STATS_ATTR_MAX (__IPVS_STATS_ATTR_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   IPVS_INFO_ATTR_UNSPEC = 0,
   IPVS_INFO_ATTR_VERSION,
   IPVS_INFO_ATTR_CONN_TAB_SIZE,
-  __IPVS_INFO_ATTR_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __IPVS_INFO_ATTR_MAX,
 };
 #define IPVS_INFO_ATTR_MAX (__IPVS_INFO_ATTR_MAX - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/ipc.h b/libc/kernel/uapi/linux/ipc.h
index 67345ce..5a2ea4d 100644
--- a/libc/kernel/uapi/linux/ipc.h
+++ b/libc/kernel/uapi/linux/ipc.h
@@ -21,7 +21,7 @@
 #include <linux/types.h>
 #define IPC_PRIVATE ((__kernel_key_t) 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct ipc_perm {
+struct __kernel_legacy_ipc_perm {
   __kernel_key_t key;
   __kernel_uid_t uid;
   __kernel_gid_t gid;
diff --git a/libc/kernel/uapi/linux/ipv6.h b/libc/kernel/uapi/linux/ipv6.h
index 24d5743..5a1d4fd 100644
--- a/libc/kernel/uapi/linux/ipv6.h
+++ b/libc/kernel/uapi/linux/ipv6.h
@@ -157,7 +157,10 @@
   DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
+  DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
+  DEVCONF_DROP_UNSOLICITED_NA,
+  DEVCONF_KEEP_ADDR_ON_DOWN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   DEVCONF_MAX
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/if_pppopns.h b/libc/kernel/uapi/linux/kcm.h
similarity index 73%
copy from libc/kernel/uapi/linux/if_pppopns.h
copy to libc/kernel/uapi/linux/kcm.h
index bd96e94..bbd0791 100644
--- a/libc/kernel/uapi/linux/if_pppopns.h
+++ b/libc/kernel/uapi/linux/kcm.h
@@ -16,18 +16,25 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _UAPI_LINUX_IF_PPPOPNS_H
-#define _UAPI_LINUX_IF_PPPOPNS_H
-#include <linux/socket.h>
-#include <linux/types.h>
+#ifndef KCM_KERNEL_H
+#define KCM_KERNEL_H
+struct kcm_attach {
+  int fd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sockaddr_pppopns {
-  sa_family_t sa_family;
-  unsigned int sa_protocol;
-  int tcp_socket;
+  int bpf_fd;
+};
+struct kcm_unattach {
+  int fd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 local;
-  __u16 remote;
-} __attribute__((packed));
+};
+struct kcm_clone {
+  int fd;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SIOCKCMATTACH (SIOCPROTOPRIVATE + 0)
+#define SIOCKCMUNATTACH (SIOCPROTOPRIVATE + 1)
+#define SIOCKCMCLONE (SIOCPROTOPRIVATE + 2)
+#define KCMPROTO_CONNECTED 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KCM_RECV_DISABLE 1
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/if_pppopns.h b/libc/kernel/uapi/linux/kcov.h
similarity index 72%
copy from libc/kernel/uapi/linux/if_pppopns.h
copy to libc/kernel/uapi/linux/kcov.h
index bd96e94..74b121d 100644
--- a/libc/kernel/uapi/linux/if_pppopns.h
+++ b/libc/kernel/uapi/linux/kcov.h
@@ -16,18 +16,11 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _UAPI_LINUX_IF_PPPOPNS_H
-#define _UAPI_LINUX_IF_PPPOPNS_H
-#include <linux/socket.h>
+#ifndef _LINUX_KCOV_IOCTLS_H
+#define _LINUX_KCOV_IOCTLS_H
 #include <linux/types.h>
+#define KCOV_INIT_TRACE _IOR('c', 1, unsigned long)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sockaddr_pppopns {
-  sa_family_t sa_family;
-  unsigned int sa_protocol;
-  int tcp_socket;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 local;
-  __u16 remote;
-} __attribute__((packed));
+#define KCOV_ENABLE _IO('c', 100)
+#define KCOV_DISABLE _IO('c', 101)
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/kernel.h b/libc/kernel/uapi/linux/kernel.h
index eb9490f..1a79728 100644
--- a/libc/kernel/uapi/linux/kernel.h
+++ b/libc/kernel/uapi/linux/kernel.h
@@ -22,4 +22,5 @@
 #define __ALIGN_KERNEL(x,a) __ALIGN_KERNEL_MASK(x, (typeof(x)) (a) - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __ALIGN_KERNEL_MASK(x,mask) (((x) + (mask)) & ~(mask))
+#define __KERNEL_DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 #endif
diff --git a/libc/kernel/uapi/linux/keyctl.h b/libc/kernel/uapi/linux/keyctl.h
index 152ca59..4ba1e68 100644
--- a/libc/kernel/uapi/linux/keyctl.h
+++ b/libc/kernel/uapi/linux/keyctl.h
@@ -18,54 +18,63 @@
  ****************************************************************************/
 #ifndef _LINUX_KEYCTL_H
 #define _LINUX_KEYCTL_H
+#include <linux/types.h>
 #define KEY_SPEC_THREAD_KEYRING - 1
-#define KEY_SPEC_PROCESS_KEYRING - 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_SPEC_PROCESS_KEYRING - 2
 #define KEY_SPEC_SESSION_KEYRING - 3
 #define KEY_SPEC_USER_KEYRING - 4
 #define KEY_SPEC_USER_SESSION_KEYRING - 5
-#define KEY_SPEC_GROUP_KEYRING - 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_SPEC_GROUP_KEYRING - 6
 #define KEY_SPEC_REQKEY_AUTH_KEY - 7
 #define KEY_SPEC_REQUESTOR_KEYRING - 8
 #define KEY_REQKEY_DEFL_NO_CHANGE - 1
-#define KEY_REQKEY_DEFL_DEFAULT 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_REQKEY_DEFL_DEFAULT 0
 #define KEY_REQKEY_DEFL_THREAD_KEYRING 1
 #define KEY_REQKEY_DEFL_PROCESS_KEYRING 2
 #define KEY_REQKEY_DEFL_SESSION_KEYRING 3
-#define KEY_REQKEY_DEFL_USER_KEYRING 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_REQKEY_DEFL_USER_KEYRING 4
 #define KEY_REQKEY_DEFL_USER_SESSION_KEYRING 5
 #define KEY_REQKEY_DEFL_GROUP_KEYRING 6
 #define KEY_REQKEY_DEFL_REQUESTOR_KEYRING 7
-#define KEYCTL_GET_KEYRING_ID 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEYCTL_GET_KEYRING_ID 0
 #define KEYCTL_JOIN_SESSION_KEYRING 1
 #define KEYCTL_UPDATE 2
 #define KEYCTL_REVOKE 3
-#define KEYCTL_CHOWN 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEYCTL_CHOWN 4
 #define KEYCTL_SETPERM 5
 #define KEYCTL_DESCRIBE 6
 #define KEYCTL_CLEAR 7
-#define KEYCTL_LINK 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEYCTL_LINK 8
 #define KEYCTL_UNLINK 9
 #define KEYCTL_SEARCH 10
 #define KEYCTL_READ 11
-#define KEYCTL_INSTANTIATE 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEYCTL_INSTANTIATE 12
 #define KEYCTL_NEGATE 13
 #define KEYCTL_SET_REQKEY_KEYRING 14
 #define KEYCTL_SET_TIMEOUT 15
-#define KEYCTL_ASSUME_AUTHORITY 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEYCTL_ASSUME_AUTHORITY 16
 #define KEYCTL_GET_SECURITY 17
 #define KEYCTL_SESSION_TO_PARENT 18
 #define KEYCTL_REJECT 19
-#define KEYCTL_INSTANTIATE_IOV 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEYCTL_INSTANTIATE_IOV 20
 #define KEYCTL_INVALIDATE 21
 #define KEYCTL_GET_PERSISTENT 22
+#define KEYCTL_DH_COMPUTE 23
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct keyctl_dh_params {
+  __s32 __linux_private;
+  __s32 prime;
+  __s32 base;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/kvm.h b/libc/kernel/uapi/linux/kvm.h
index c227904..db9f765 100644
--- a/libc/kernel/uapi/linux/kvm.h
+++ b/libc/kernel/uapi/linux/kvm.h
@@ -149,191 +149,216 @@
   __u32 flags;
   __u32 reserved[9];
 };
-#define KVM_S390_GET_SKEYS_NONE 1
+struct kvm_hyperv_exit {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_EXIT_HYPERV_SYNIC 1
+#define KVM_EXIT_HYPERV_HCALL 2
+  __u32 type;
+  union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct {
+      __u32 msr;
+      __u64 control;
+      __u64 evt_page;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u64 msg_page;
+    } synic;
+    struct {
+      __u64 input;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u64 result;
+      __u64 params[2];
+    } hcall;
+  } u;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define KVM_S390_GET_SKEYS_NONE 1
 #define KVM_S390_SKEYS_MAX 1048576
 #define KVM_EXIT_UNKNOWN 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_EXCEPTION 1
 #define KVM_EXIT_IO 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_HYPERCALL 3
 #define KVM_EXIT_DEBUG 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_HLT 5
 #define KVM_EXIT_MMIO 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_IRQ_WINDOW_OPEN 7
 #define KVM_EXIT_SHUTDOWN 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_FAIL_ENTRY 9
 #define KVM_EXIT_INTR 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_SET_TPR 11
 #define KVM_EXIT_TPR_ACCESS 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_S390_SIEIC 13
 #define KVM_EXIT_S390_RESET 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_DCR 15
 #define KVM_EXIT_NMI 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_INTERNAL_ERROR 17
 #define KVM_EXIT_OSI 18
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_PAPR_HCALL 19
 #define KVM_EXIT_S390_UCONTROL 20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_WATCHDOG 21
 #define KVM_EXIT_S390_TSCH 22
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_EPR 23
 #define KVM_EXIT_SYSTEM_EVENT 24
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_S390_STSI 25
 #define KVM_EXIT_IOAPIC_EOI 26
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_EXIT_HYPERV 27
 #define KVM_INTERNAL_ERROR_EMULATION 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_INTERNAL_ERROR_SIMUL_EX 2
 #define KVM_INTERNAL_ERROR_DELIVERY_EV 3
 struct kvm_run {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 request_interrupt_window;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 padding1[7];
   __u32 exit_reason;
   __u8 ready_for_interrupt_injection;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 if_flag;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 flags;
   __u64 cr8;
   __u64 apic_base;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __KVM_S390
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 psw_mask;
   __u64 psw_addr;
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __u64 hardware_exit_reason;
     } hw;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 hardware_entry_failure_reason;
     } fail_entry;
     struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 exception;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 error_code;
     } ex;
     struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_IO_IN 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_EXIT_IO_OUT 1
       __u8 direction;
       __u8 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u16 port;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 count;
       __u64 data_offset;
     } io;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       struct kvm_debug_exit_arch arch;
     } debug;
     struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 phys_addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u8 data[8];
       __u32 len;
       __u8 is_write;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } mmio;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __u64 nr;
       __u64 args[6];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 ret;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 longmode;
       __u32 pad;
     } hypercall;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 rip;
       __u32 is_write;
       __u32 pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } tpr_access;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __u8 icptcode;
       __u16 ipa;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 ipb;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } s390_sieic;
 #define KVM_S390_RESET_POR 1
 #define KVM_S390_RESET_CLEAR 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_RESET_SUBSYSTEM 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_RESET_CPU_INIT 8
 #define KVM_S390_RESET_IPL 16
     __u64 s390_reset_flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 trans_exc_code;
       __u32 pgm_code;
     } s390_ucontrol;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 dcrn;
       __u32 data;
       __u8 is_write;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } dcr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __u32 suberror;
       __u32 ndata;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 data[16];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } internal;
     struct {
       __u64 gprs[32];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } osi;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __u64 nr;
       __u64 ret;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 args[9];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } papr_hcall;
     struct {
       __u16 subchannel_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u16 subchannel_nr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 io_int_parm;
       __u32 io_int_word;
       __u32 ipb;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u8 dequeued;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } s390_tsch;
     struct {
       __u32 epr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } epr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
 #define KVM_SYSTEM_EVENT_SHUTDOWN 1
 #define KVM_SYSTEM_EVENT_RESET 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SYSTEM_EVENT_CRASH 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 type;
       __u64 flags;
     } system_event;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u64 addr;
       __u8 ar;
       __u8 reserved;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u8 fc;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u8 sel1;
       __u16 sel2;
     } s390_stsi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u8 vector;
     } eoi;
+    struct kvm_hyperv_exit hyperv;
     char padding[256];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
@@ -497,323 +522,338 @@
   __u8 per_access_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 op_access_id;
-  __u8 pad[3];
+#define KVM_S390_PGM_FLAGS_ILC_VALID 0x01
+#define KVM_S390_PGM_FLAGS_ILC_0 0x02
+#define KVM_S390_PGM_FLAGS_ILC_1 0x04
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_S390_PGM_FLAGS_ILC_MASK 0x06
+#define KVM_S390_PGM_FLAGS_NO_REWIND 0x08
+  __u8 flags;
+  __u8 pad[2];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct kvm_s390_prefix_info {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 address;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_s390_extcall_info {
   __u16 code;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct kvm_s390_emerg_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 code;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01
 struct kvm_s390_stop_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_s390_mchk_info {
   __u64 cr14;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 mcic;
   __u64 failing_storage_address;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 ext_damage_code;
   __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 fixed_logout[16];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_s390_irq {
   __u64 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
     struct kvm_s390_io_info io;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct kvm_s390_ext_info ext;
     struct kvm_s390_pgm_info pgm;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct kvm_s390_emerg_info emerg;
     struct kvm_s390_extcall_info extcall;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct kvm_s390_prefix_info prefix;
     struct kvm_s390_stop_info stop;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct kvm_s390_mchk_info mchk;
     char reserved[64];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } u;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_s390_irq_state {
   __u64 buf;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   __u32 len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[4];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GUESTDBG_ENABLE 0x00000001
 #define KVM_GUESTDBG_SINGLESTEP 0x00000002
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_guest_debug {
   __u32 control;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
   struct kvm_guest_debug_arch arch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   kvm_ioeventfd_flag_nr_datamatch,
   kvm_ioeventfd_flag_nr_pio,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   kvm_ioeventfd_flag_nr_deassign,
   kvm_ioeventfd_flag_nr_virtio_ccw_notify,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   kvm_ioeventfd_flag_nr_fast_mmio,
   kvm_ioeventfd_flag_nr_max,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
 #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
 #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_ioeventfd {
   __u64 datamatch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 addr;
   __u32 len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 fd;
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 pad[36];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_enable_cap {
   __u32 cap;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   __u64 args[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 pad[64];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_ppc_pvinfo {
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 hcall[4];
   __u8 pad[108];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define KVM_PPC_PAGE_SIZES_MAX_SZ 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_ppc_one_page_size {
   __u32 page_shift;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pte_enc;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_ppc_one_seg_page_size {
   __u32 page_shift;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 slb_enc;
   struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define KVM_PPC_PAGE_SIZES_REAL 0x00000001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_PPC_1T_SEGMENTS 0x00000002
 struct kvm_ppc_smmu_info {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 flags;
   __u32 slb_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad;
   struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVMIO 0xAE
 #define KVM_VM_S390_UCONTROL 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_VM_PPC_HV 1
 #define KVM_VM_PPC_PR 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_SIE_PAGE_OFFSET 1
 #define KVM_GET_API_VERSION _IO(KVMIO, 0x00)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CREATE_VM _IO(KVMIO, 0x01)
 #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06)
 #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04)
 #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06
 #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08
 #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IRQCHIP 0
 #define KVM_CAP_HLT 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
 #define KVM_CAP_USER_MEMORY 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_SET_TSS_ADDR 4
 #define KVM_CAP_VAPIC 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_EXT_CPUID 7
 #define KVM_CAP_CLOCKSOURCE 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_NR_VCPUS 9
 #define KVM_CAP_NR_MEMSLOTS 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PIT 11
 #define KVM_CAP_NOP_IO_DELAY 12
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PV_MMU 13
 #define KVM_CAP_MP_STATE 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_COALESCED_MMIO 15
 #define KVM_CAP_SYNC_MMU 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IOMMU 18
 #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_USER_NMI 22
 #ifdef __KVM_HAVE_GUEST_DEBUG
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_SET_GUEST_DEBUG 23
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __KVM_HAVE_PIT
 #define KVM_CAP_REINJECT_CONTROL 24
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define KVM_CAP_IRQ_ROUTING 25
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IRQ_INJECT_STATUS 26
 #define KVM_CAP_ASSIGN_DEV_IRQ 29
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30
 #ifdef __KVM_HAVE_MCE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_MCE 31
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IRQFD 32
 #ifdef __KVM_HAVE_PIT
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PIT2 33
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_SET_BOOT_CPU_ID 34
 #ifdef __KVM_HAVE_PIT_STATE2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PIT_STATE2 35
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IOEVENTFD 36
 #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __KVM_HAVE_XEN_HVM
 #define KVM_CAP_XEN_HVM 38
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define KVM_CAP_ADJUST_CLOCK 39
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_INTERNAL_ERROR_DATA 40
 #ifdef __KVM_HAVE_VCPU_EVENTS
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_VCPU_EVENTS 41
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_S390_PSW 42
 #define KVM_CAP_PPC_SEGSTATE 43
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_HYPERV 44
 #define KVM_CAP_HYPERV_VAPIC 45
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_HYPERV_SPIN 46
 #define KVM_CAP_PCI_SEGMENT 47
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_PAIRED_SINGLES 48
 #define KVM_CAP_INTR_SHADOW 49
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __KVM_HAVE_DEBUGREGS
 #define KVM_CAP_DEBUGREGS 50
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define KVM_CAP_X86_ROBUST_SINGLESTEP 51
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_OSI 52
 #define KVM_CAP_PPC_UNSET_IRQ 53
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_ENABLE_CAP 54
 #ifdef __KVM_HAVE_XSAVE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_XSAVE 55
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __KVM_HAVE_XCRS
 #define KVM_CAP_XCRS 56
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define KVM_CAP_PPC_GET_PVINFO 57
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_IRQ_LEVEL 58
 #define KVM_CAP_ASYNC_PF 59
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_TSC_CONTROL 60
 #define KVM_CAP_GET_TSC_KHZ 61
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_BOOKE_SREGS 62
 #define KVM_CAP_SPAPR_TCE 63
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_SMT 64
 #define KVM_CAP_PPC_RMA 65
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_MAX_VCPUS 66
 #define KVM_CAP_PPC_HIOR 67
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_SW_TLB 69
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_ONE_REG 70
 #define KVM_CAP_S390_GMAP 71
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_TSC_DEADLINE_TIMER 72
 #define KVM_CAP_S390_UCONTROL 73
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_SYNC_REGS 74
 #define KVM_CAP_PCI_2_3 75
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_KVMCLOCK_CTRL 76
 #define KVM_CAP_SIGNAL_MSI 77
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_GET_SMMU_INFO 78
 #define KVM_CAP_S390_COW 79
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_ALLOC_HTAB 80
 #define KVM_CAP_READONLY_MEM 81
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IRQFD_RESAMPLE 82
 #define KVM_CAP_PPC_BOOKE_WATCHDOG 83
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_HTAB_FD 84
 #define KVM_CAP_S390_CSS_SUPPORT 85
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_EPR 86
 #define KVM_CAP_ARM_PSCI 87
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_ARM_SET_DEVICE_ADDR 88
 #define KVM_CAP_DEVICE_CTRL 89
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IRQ_MPIC 90
 #define KVM_CAP_PPC_RTAS 91
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IRQ_XICS 92
 #define KVM_CAP_ARM_EL1_32BIT 93
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_SPAPR_MULTITCE 94
 #define KVM_CAP_EXT_EMUL_CPUID 95
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_HYPERV_TIME 96
 #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_ENABLE_CAP_VM 98
 #define KVM_CAP_S390_IRQCHIP 99
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IOEVENTFD_NO_LENGTH 100
 #define KVM_CAP_VM_ATTRIBUTES 101
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_ARM_PSCI_0_2 102
 #define KVM_CAP_PPC_FIXUP_HCALL 103
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_PPC_ENABLE_HCALL 104
 #define KVM_CAP_CHECK_EXTENSION_VM 105
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_S390_USER_SIGP 106
 #define KVM_CAP_S390_VECTOR_REGISTERS 107
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_S390_MEM_OP 108
 #define KVM_CAP_S390_USER_STSI 109
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_S390_SKEYS 110
 #define KVM_CAP_MIPS_FPU 111
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_MIPS_MSA 112
 #define KVM_CAP_S390_INJECT_IRQ 113
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_S390_IRQ_STATE 114
 #define KVM_CAP_PPC_HWRNG 115
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_DISABLE_QUIRKS 116
 #define KVM_CAP_X86_SMM 117
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_MULTI_ADDRESS_SPACE 118
 #define KVM_CAP_GUEST_DEBUG_HW_BPS 119
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_GUEST_DEBUG_HW_WPS 120
 #define KVM_CAP_SPLIT_IRQCHIP 121
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
+#define KVM_CAP_HYPERV_SYNIC 123
+#define KVM_CAP_S390_RI 124
+#define KVM_CAP_SPAPR_TCE_64 125
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_CAP_ARM_PMU_V3 126
+#define KVM_CAP_VCPU_ATTRIBUTES 127
+#define KVM_CAP_MAX_VCPU_ID 128
 #ifdef KVM_CAP_IRQ_ROUTING
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_irq_routing_irqchip {
@@ -837,377 +877,385 @@
   __u32 adapter_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+struct kvm_irq_routing_hv_sint {
+  __u32 vcpu;
+  __u32 sint;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define KVM_IRQ_ROUTING_IRQCHIP 1
 #define KVM_IRQ_ROUTING_MSI 2
 #define KVM_IRQ_ROUTING_S390_ADAPTER 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KVM_IRQ_ROUTING_HV_SINT 4
 struct kvm_irq_routing_entry {
   __u32 gsi;
   __u32 type;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 pad;
   union {
     struct kvm_irq_routing_irqchip irqchip;
-    struct kvm_irq_routing_msi msi;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct kvm_irq_routing_msi msi;
     struct kvm_irq_routing_s390_adapter adapter;
+    struct kvm_irq_routing_hv_sint hv_sint;
     __u32 pad[8];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } u;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_irq_routing {
   __u32 nr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   struct kvm_irq_routing_entry entries[0];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef KVM_CAP_MCE
 struct kvm_x86_mce {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 status;
   __u64 addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 misc;
   __u64 mcg_status;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bank;
   __u8 pad1[7];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 pad2[3];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifdef KVM_CAP_XEN_HVM
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_xen_hvm_config {
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 msr;
   __u64 blob_addr_32;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 blob_addr_64;
   __u8 blob_size_32;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 blob_size_64;
   __u8 pad2[30];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
 #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_irqfd {
   __u32 fd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 gsi;
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 resamplefd;
   __u8 pad[16];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct kvm_clock_data {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 clock;
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pad[9];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_MMU_FSL_BOOKE_NOHV 0
 #define KVM_MMU_FSL_BOOKE_HV 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_config_tlb {
   __u64 params;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 array;
   __u32 mmu_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 array_len;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_dirty_tlb {
   __u64 bitmap;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 num_dirty;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_ARCH_MASK 0xff00000000000000ULL
 #define KVM_REG_GENERIC 0x0000000000000000ULL
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_PPC 0x1000000000000000ULL
 #define KVM_REG_X86 0x2000000000000000ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_IA64 0x3000000000000000ULL
 #define KVM_REG_ARM 0x4000000000000000ULL
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_S390 0x5000000000000000ULL
 #define KVM_REG_ARM64 0x6000000000000000ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_MIPS 0x7000000000000000ULL
 #define KVM_REG_SIZE_SHIFT 52
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
 #define KVM_REG_SIZE_U8 0x0000000000000000ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_SIZE_U16 0x0010000000000000ULL
 #define KVM_REG_SIZE_U32 0x0020000000000000ULL
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_SIZE_U64 0x0030000000000000ULL
 #define KVM_REG_SIZE_U128 0x0040000000000000ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_SIZE_U256 0x0050000000000000ULL
 #define KVM_REG_SIZE_U512 0x0060000000000000ULL
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_REG_SIZE_U1024 0x0070000000000000ULL
 struct kvm_reg_list {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 n;
   __u64 reg[0];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct kvm_one_reg {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 id;
   __u64 addr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct kvm_msi {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 address_lo;
   __u32 address_hi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 data;
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 pad[16];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_arm_device_addr {
   __u64 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 addr;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CREATE_DEVICE_TEST 1
 struct kvm_create_device {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   __u32 fd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_device_attr {
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 group;
   __u64 attr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 addr;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEV_VFIO_GROUP 1
 #define KVM_DEV_VFIO_GROUP_ADD 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEV_VFIO_GROUP_DEL 2
 enum kvm_device_type {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_FSL_MPIC_20 = 1,
 #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_FSL_MPIC_42,
 #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_XICS,
 #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_VFIO,
 #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_ARM_VGIC_V2,
 #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_FLIC,
 #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_ARM_VGIC_V3,
 #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   KVM_DEV_TYPE_MAX,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region)
 #define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
 #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
 #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, struct kvm_userspace_memory_region)
 #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64)
 struct kvm_s390_ucas_mapping {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 user_addr;
   __u64 vcpu_addr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 length;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
 #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long)
 #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
 #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip)
 #define KVM_CREATE_PIT _IO(KVMIO, 0x64)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state)
 #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level)
 #define KVM_REGISTER_COALESCED_MMIO _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_UNREGISTER_COALESCED_MMIO _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone)
 #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, struct kvm_assigned_pci_dev)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing)
 #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq)
 #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, struct kvm_assigned_pci_dev)
 #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, struct kvm_assigned_msix_nr)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry)
 #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd)
 #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78)
 #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config)
 #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data)
 #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
 #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
 #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, struct kvm_assigned_pci_dev)
 #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info)
 #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce)
+#define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce_64)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma)
 #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd)
 #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)
 #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr)
 #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_RUN _IO(KVMIO, 0x80)
 #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs)
 #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs)
 #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation)
 #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs)
 #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs)
 #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu)
 #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu)
 #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2)
 #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
 #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt)
 #define KVM_S390_STORE_STATUS_NOADDR (- 1ul)
 #define KVM_S390_STORE_STATUS_PREFIXED (- 2ul)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)
 #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97)
 #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_NMI _IO(KVMIO, 0x9a)
 #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug)
 #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce)
 #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events)
 #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs)
 #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)
 #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs)
 #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs)
 #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg)
 #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad)
 #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
 #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op)
 #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq)
 #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state)
 #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_SMI _IO(KVMIO, 0xb7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
 #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
 #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_assigned_pci_dev {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 assigned_dev_id;
   __u32 busnr;
   __u32 devfn;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 segnr;
   union {
     __u32 reserved[11];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define KVM_DEV_IRQ_HOST_INTX (1 << 0)
 #define KVM_DEV_IRQ_HOST_MSI (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEV_IRQ_HOST_MSIX (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEV_IRQ_GUEST_INTX (1 << 8)
 #define KVM_DEV_IRQ_GUEST_MSI (1 << 9)
 #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEV_IRQ_HOST_MASK 0x00ff
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_DEV_IRQ_GUEST_MASK 0xff00
 struct kvm_assigned_irq {
   __u32 assigned_dev_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 host_irq;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 guest_irq;
   __u32 flags;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 reserved[12];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 };
 struct kvm_assigned_msix_nr {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 assigned_dev_id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 entry_nr;
   __u16 padding;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KVM_MAX_MSIX_PER_DEV 256
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct kvm_assigned_msix_entry {
   __u32 assigned_dev_id;
   __u32 gsi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 entry;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 padding[3];
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/l2tp.h b/libc/kernel/uapi/linux/l2tp.h
index cb1504b..b51e953 100644
--- a/libc/kernel/uapi/linux/l2tp.h
+++ b/libc/kernel/uapi/linux/l2tp.h
@@ -104,56 +104,58 @@
   L2TP_ATTR_IP6_DADDR,
   L2TP_ATTR_UDP_ZERO_CSUM6_TX,
   L2TP_ATTR_UDP_ZERO_CSUM6_RX,
-  __L2TP_ATTR_MAX,
+  L2TP_ATTR_PAD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __L2TP_ATTR_MAX,
 };
 #define L2TP_ATTR_MAX (__L2TP_ATTR_MAX - 1)
 enum {
-  L2TP_ATTR_STATS_NONE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  L2TP_ATTR_STATS_NONE,
   L2TP_ATTR_TX_PACKETS,
   L2TP_ATTR_TX_BYTES,
   L2TP_ATTR_TX_ERRORS,
-  L2TP_ATTR_RX_PACKETS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  L2TP_ATTR_RX_PACKETS,
   L2TP_ATTR_RX_BYTES,
   L2TP_ATTR_RX_SEQ_DISCARDS,
   L2TP_ATTR_RX_OOS_PACKETS,
-  L2TP_ATTR_RX_ERRORS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  L2TP_ATTR_RX_ERRORS,
+  L2TP_ATTR_STATS_PAD,
   __L2TP_ATTR_STATS_MAX,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define L2TP_ATTR_STATS_MAX (__L2TP_ATTR_STATS_MAX - 1)
 enum l2tp_pwtype {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   L2TP_PWTYPE_NONE = 0x0000,
   L2TP_PWTYPE_ETH_VLAN = 0x0004,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   L2TP_PWTYPE_ETH = 0x0005,
   L2TP_PWTYPE_PPP = 0x0007,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   L2TP_PWTYPE_PPP_AC = 0x0008,
   L2TP_PWTYPE_IP = 0x000b,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __L2TP_PWTYPE_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum l2tp_l2spec_type {
   L2TP_L2SPECTYPE_NONE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   L2TP_L2SPECTYPE_DEFAULT,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum l2tp_encap_type {
   L2TP_ENCAPTYPE_UDP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   L2TP_ENCAPTYPE_IP,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum l2tp_seqmode {
   L2TP_SEQ_NONE = 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   L2TP_SEQ_IP = 1,
   L2TP_SEQ_ALL = 2,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define L2TP_GENL_NAME "l2tp"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define L2TP_GENL_VERSION 0x1
 #define L2TP_GENL_MCGROUP "l2tp"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/libc-compat.h b/libc/kernel/uapi/linux/libc-compat.h
index c91df87..8a65a28 100644
--- a/libc/kernel/uapi/linux/libc-compat.h
+++ b/libc/kernel/uapi/linux/libc-compat.h
@@ -19,76 +19,105 @@
 #ifndef _UAPI_LIBC_COMPAT_H
 #define _UAPI_LIBC_COMPAT_H
 #ifdef __GLIBC__
-#ifdef _NETINET_IN_H
+#if defined(_NET_IF_H) && defined(__USE_MISC)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IF_IFCONF 0
+#define __UAPI_DEF_IF_IFMAP 0
+#define __UAPI_DEF_IF_IFNAMSIZ 0
+#define __UAPI_DEF_IF_IFREQ 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
+#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
+#define __UAPI_DEF_IF_IFCONF 1
+#define __UAPI_DEF_IF_IFMAP 1
+#define __UAPI_DEF_IF_IFNAMSIZ 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IF_IFREQ 1
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef _NETINET_IN_H
 #define __UAPI_DEF_IN_ADDR 0
 #define __UAPI_DEF_IN_IPPROTO 0
 #define __UAPI_DEF_IN_PKTINFO 0
-#define __UAPI_DEF_IP_MREQ 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IP_MREQ 0
 #define __UAPI_DEF_SOCKADDR_IN 0
 #define __UAPI_DEF_IN_CLASS 0
 #define __UAPI_DEF_IN6_ADDR 0
-#if defined(__USE_MISC) || defined(__USE_GNU)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#if defined(__USE_MISC) || defined(__USE_GNU)
 #define __UAPI_DEF_IN6_ADDR_ALT 0
 #else
 #define __UAPI_DEF_IN6_ADDR_ALT 1
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define __UAPI_DEF_SOCKADDR_IN6 0
 #define __UAPI_DEF_IPV6_MREQ 0
 #define __UAPI_DEF_IPPROTO_V6 0
-#define __UAPI_DEF_IPV6_OPTIONS 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IPV6_OPTIONS 0
 #define __UAPI_DEF_IN6_PKTINFO 0
 #define __UAPI_DEF_IP6_MTUINFO 0
 #else
-#define __UAPI_DEF_IN_ADDR 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IN_ADDR 1
 #define __UAPI_DEF_IN_IPPROTO 1
 #define __UAPI_DEF_IN_PKTINFO 1
 #define __UAPI_DEF_IP_MREQ 1
-#define __UAPI_DEF_SOCKADDR_IN 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_SOCKADDR_IN 1
 #define __UAPI_DEF_IN_CLASS 1
 #define __UAPI_DEF_IN6_ADDR 1
 #define __UAPI_DEF_IN6_ADDR_ALT 1
-#define __UAPI_DEF_SOCKADDR_IN6 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_SOCKADDR_IN6 1
 #define __UAPI_DEF_IPV6_MREQ 1
 #define __UAPI_DEF_IPPROTO_V6 1
 #define __UAPI_DEF_IPV6_OPTIONS 1
-#define __UAPI_DEF_IN6_PKTINFO 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IN6_PKTINFO 1
 #define __UAPI_DEF_IP6_MTUINFO 1
 #endif
 #ifdef _SYS_XATTR_H
-#define __UAPI_DEF_XATTR 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_XATTR 0
 #else
 #define __UAPI_DEF_XATTR 1
 #endif
-#else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
+#define __UAPI_DEF_IF_IFCONF 1
+#define __UAPI_DEF_IF_IFMAP 1
+#define __UAPI_DEF_IF_IFNAMSIZ 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UAPI_DEF_IF_IFREQ 1
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
 #define __UAPI_DEF_IN_ADDR 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __UAPI_DEF_IN_IPPROTO 1
 #define __UAPI_DEF_IN_PKTINFO 1
 #define __UAPI_DEF_IP_MREQ 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __UAPI_DEF_SOCKADDR_IN 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __UAPI_DEF_IN_CLASS 1
 #define __UAPI_DEF_IN6_ADDR 1
 #define __UAPI_DEF_IN6_ADDR_ALT 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __UAPI_DEF_SOCKADDR_IN6 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __UAPI_DEF_IPV6_MREQ 1
 #define __UAPI_DEF_IPPROTO_V6 1
 #define __UAPI_DEF_IPV6_OPTIONS 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __UAPI_DEF_IN6_PKTINFO 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __UAPI_DEF_IP6_MTUINFO 1
 #define __UAPI_DEF_XATTR 1
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/lightnvm.h b/libc/kernel/uapi/linux/lightnvm.h
index a3430f3..9238113 100644
--- a/libc/kernel/uapi/linux/lightnvm.h
+++ b/libc/kernel/uapi/linux/lightnvm.h
@@ -27,68 +27,88 @@
 #define NVM_TTYPE_NAME_MAX 48
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NVM_TTYPE_MAX 63
+#define NVM_MMTYPE_LEN 8
 #define NVM_CTRL_FILE "/dev/lightnvm/control"
 struct nvm_ioctl_info_tgt {
-  __u32 version[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 version[3];
   __u32 reserved;
   char tgtname[NVM_TTYPE_NAME_MAX];
 };
-struct nvm_ioctl_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct nvm_ioctl_info {
   __u32 version[3];
   __u16 tgtsize;
   __u16 reserved16;
-  __u32 reserved[12];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[12];
   struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX];
 };
 enum {
-  NVM_DEVICE_ACTIVE = 1 << 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NVM_DEVICE_ACTIVE = 1 << 0,
 };
 struct nvm_ioctl_device_info {
   char devname[DISK_NAME_LEN];
-  char bmname[NVM_TTYPE_NAME_MAX];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char bmname[NVM_TTYPE_NAME_MAX];
   __u32 bmversion[3];
   __u32 flags;
   __u32 reserved[8];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct nvm_ioctl_get_devices {
   __u32 nr_devices;
   __u32 reserved[31];
-  struct nvm_ioctl_device_info info[31];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct nvm_ioctl_device_info info[31];
 };
 struct nvm_ioctl_create_simple {
   __u32 lun_begin;
-  __u32 lun_end;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 lun_end;
 };
 enum {
   NVM_CONFIG_TYPE_SIMPLE = 0,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct nvm_ioctl_create_conf {
   __u32 type;
   union {
-    struct nvm_ioctl_create_simple s;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct nvm_ioctl_create_simple s;
   };
 };
 struct nvm_ioctl_create {
-  char dev[DISK_NAME_LEN];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char dev[DISK_NAME_LEN];
   char tgttype[NVM_TTYPE_NAME_MAX];
   char tgtname[DISK_NAME_LEN];
   __u32 flags;
-  struct nvm_ioctl_create_conf conf;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct nvm_ioctl_create_conf conf;
 };
 struct nvm_ioctl_remove {
   char tgtname[DISK_NAME_LEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
+};
+struct nvm_ioctl_dev_init {
+  char dev[DISK_NAME_LEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char mmtype[NVM_MMTYPE_LEN];
+  __u32 flags;
+};
+enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NVM_FACTORY_ERASE_ONLY_USER = 1 << 0,
+  NVM_FACTORY_RESET_HOST_BLKS = 1 << 1,
+  NVM_FACTORY_RESET_GRWN_BBLKS = 1 << 2,
+  NVM_FACTORY_NR_BITS = 1 << 3,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct nvm_ioctl_dev_factory {
+  char dev[DISK_NAME_LEN];
   __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
@@ -98,13 +118,18 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NVM_DEV_CREATE_CMD,
   NVM_DEV_REMOVE_CMD,
+  NVM_DEV_INIT_CMD,
+  NVM_DEV_FACTORY_CMD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NVM_IOCTL 'L'
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NVM_INFO _IOWR(NVM_IOCTL, NVM_INFO_CMD, struct nvm_ioctl_info)
 #define NVM_GET_DEVICES _IOR(NVM_IOCTL, NVM_GET_DEVICES_CMD, struct nvm_ioctl_get_devices)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NVM_DEV_CREATE _IOW(NVM_IOCTL, NVM_DEV_CREATE_CMD, struct nvm_ioctl_create)
 #define NVM_DEV_REMOVE _IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, struct nvm_ioctl_remove)
+#define NVM_DEV_INIT _IOW(NVM_IOCTL, NVM_DEV_INIT_CMD, struct nvm_ioctl_dev_init)
+#define NVM_DEV_FACTORY _IOW(NVM_IOCTL, NVM_DEV_FACTORY_CMD, struct nvm_ioctl_dev_factory)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NVM_VERSION_MAJOR 1
 #define NVM_VERSION_MINOR 0
diff --git a/libc/kernel/uapi/linux/limits.h b/libc/kernel/uapi/linux/limits.h
index 406d175..4441592 100644
--- a/libc/kernel/uapi/linux/limits.h
+++ b/libc/kernel/uapi/linux/limits.h
@@ -21,7 +21,7 @@
 #define NR_OPEN 1024
 #define NGROUPS_MAX 65536
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARG_MAX 131072
+#define _KERNEL_ARG_MAX 131072
 #define LINK_MAX 127
 #define MAX_CANON 255
 #define MAX_INPUT 255
diff --git a/libc/kernel/uapi/linux/lirc.h b/libc/kernel/uapi/linux/lirc.h
new file mode 100644
index 0000000..1505fe8
--- /dev/null
+++ b/libc/kernel/uapi/linux/lirc.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_LIRC_H
+#define _LINUX_LIRC_H
+#include <linux/types.h>
+#include <linux/ioctl.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PULSE_BIT 0x01000000
+#define PULSE_MASK 0x00FFFFFF
+#define LIRC_MODE2_SPACE 0x00000000
+#define LIRC_MODE2_PULSE 0x01000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_MODE2_FREQUENCY 0x02000000
+#define LIRC_MODE2_TIMEOUT 0x03000000
+#define LIRC_VALUE_MASK 0x00FFFFFF
+#define LIRC_MODE2_MASK 0xFF000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_SPACE(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_SPACE)
+#define LIRC_PULSE(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_PULSE)
+#define LIRC_FREQUENCY(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY)
+#define LIRC_TIMEOUT(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_VALUE(val) ((val) & LIRC_VALUE_MASK)
+#define LIRC_MODE2(val) ((val) & LIRC_MODE2_MASK)
+#define LIRC_IS_SPACE(val) (LIRC_MODE2(val) == LIRC_MODE2_SPACE)
+#define LIRC_IS_PULSE(val) (LIRC_MODE2(val) == LIRC_MODE2_PULSE)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_IS_FREQUENCY(val) (LIRC_MODE2(val) == LIRC_MODE2_FREQUENCY)
+#define LIRC_IS_TIMEOUT(val) (LIRC_MODE2(val) == LIRC_MODE2_TIMEOUT)
+#define lirc_t int
+#define LIRC_MODE2SEND(x) (x)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_SEND2MODE(x) (x)
+#define LIRC_MODE2REC(x) ((x) << 16)
+#define LIRC_REC2MODE(x) ((x) >> 16)
+#define LIRC_MODE_RAW 0x00000001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_MODE_PULSE 0x00000002
+#define LIRC_MODE_MODE2 0x00000004
+#define LIRC_MODE_LIRCCODE 0x00000010
+#define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE)
+#define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2)
+#define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE)
+#define LIRC_CAN_SEND_MASK 0x0000003f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_CAN_SET_SEND_CARRIER 0x00000100
+#define LIRC_CAN_SET_SEND_DUTY_CYCLE 0x00000200
+#define LIRC_CAN_SET_TRANSMITTER_MASK 0x00000400
+#define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE)
+#define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2)
+#define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE)
+#define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_CAN_SET_REC_CARRIER (LIRC_CAN_SET_SEND_CARRIER << 16)
+#define LIRC_CAN_SET_REC_DUTY_CYCLE (LIRC_CAN_SET_SEND_DUTY_CYCLE << 16)
+#define LIRC_CAN_SET_REC_DUTY_CYCLE_RANGE 0x40000000
+#define LIRC_CAN_SET_REC_CARRIER_RANGE 0x80000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_CAN_GET_REC_RESOLUTION 0x20000000
+#define LIRC_CAN_SET_REC_TIMEOUT 0x10000000
+#define LIRC_CAN_SET_REC_FILTER 0x08000000
+#define LIRC_CAN_MEASURE_CARRIER 0x02000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_CAN_USE_WIDEBAND_RECEIVER 0x04000000
+#define LIRC_CAN_SEND(x) ((x) & LIRC_CAN_SEND_MASK)
+#define LIRC_CAN_REC(x) ((x) & LIRC_CAN_REC_MASK)
+#define LIRC_CAN_NOTIFY_DECODE 0x01000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_GET_FEATURES _IOR('i', 0x00000000, __u32)
+#define LIRC_GET_SEND_MODE _IOR('i', 0x00000001, __u32)
+#define LIRC_GET_REC_MODE _IOR('i', 0x00000002, __u32)
+#define LIRC_GET_SEND_CARRIER _IOR('i', 0x00000003, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_GET_REC_CARRIER _IOR('i', 0x00000004, __u32)
+#define LIRC_GET_SEND_DUTY_CYCLE _IOR('i', 0x00000005, __u32)
+#define LIRC_GET_REC_DUTY_CYCLE _IOR('i', 0x00000006, __u32)
+#define LIRC_GET_REC_RESOLUTION _IOR('i', 0x00000007, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_GET_MIN_TIMEOUT _IOR('i', 0x00000008, __u32)
+#define LIRC_GET_MAX_TIMEOUT _IOR('i', 0x00000009, __u32)
+#define LIRC_GET_MIN_FILTER_PULSE _IOR('i', 0x0000000a, __u32)
+#define LIRC_GET_MAX_FILTER_PULSE _IOR('i', 0x0000000b, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_GET_MIN_FILTER_SPACE _IOR('i', 0x0000000c, __u32)
+#define LIRC_GET_MAX_FILTER_SPACE _IOR('i', 0x0000000d, __u32)
+#define LIRC_GET_LENGTH _IOR('i', 0x0000000f, __u32)
+#define LIRC_SET_SEND_MODE _IOW('i', 0x00000011, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_SET_REC_MODE _IOW('i', 0x00000012, __u32)
+#define LIRC_SET_SEND_CARRIER _IOW('i', 0x00000013, __u32)
+#define LIRC_SET_REC_CARRIER _IOW('i', 0x00000014, __u32)
+#define LIRC_SET_SEND_DUTY_CYCLE _IOW('i', 0x00000015, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_SET_REC_DUTY_CYCLE _IOW('i', 0x00000016, __u32)
+#define LIRC_SET_TRANSMITTER_MASK _IOW('i', 0x00000017, __u32)
+#define LIRC_SET_REC_TIMEOUT _IOW('i', 0x00000018, __u32)
+#define LIRC_SET_REC_TIMEOUT_REPORTS _IOW('i', 0x00000019, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_SET_REC_FILTER_PULSE _IOW('i', 0x0000001a, __u32)
+#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, __u32)
+#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, __u32)
+#define LIRC_SET_MEASURE_CARRIER_MODE _IOW('i', 0x0000001d, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_SET_REC_DUTY_CYCLE_RANGE _IOW('i', 0x0000001e, __u32)
+#define LIRC_SET_REC_CARRIER_RANGE _IOW('i', 0x0000001f, __u32)
+#define LIRC_NOTIFY_DECODE _IO('i', 0x00000020)
+#define LIRC_SETUP_START _IO('i', 0x00000021)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define LIRC_SETUP_END _IO('i', 0x00000022)
+#define LIRC_SET_WIDEBAND_RECEIVER _IOW('i', 0x00000023, __u32)
+#endif
diff --git a/libc/kernel/uapi/linux/lwtunnel.h b/libc/kernel/uapi/linux/lwtunnel.h
index 9bd438f..bf9b4d2 100644
--- a/libc/kernel/uapi/linux/lwtunnel.h
+++ b/libc/kernel/uapi/linux/lwtunnel.h
@@ -41,21 +41,24 @@
   LWTUNNEL_IP_TOS,
   LWTUNNEL_IP_FLAGS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  LWTUNNEL_IP_PAD,
   __LWTUNNEL_IP_MAX,
 };
 #define LWTUNNEL_IP_MAX (__LWTUNNEL_IP_MAX - 1)
-enum lwtunnel_ip6_t {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum lwtunnel_ip6_t {
   LWTUNNEL_IP6_UNSPEC,
   LWTUNNEL_IP6_ID,
   LWTUNNEL_IP6_DST,
-  LWTUNNEL_IP6_SRC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  LWTUNNEL_IP6_SRC,
   LWTUNNEL_IP6_HOPLIMIT,
   LWTUNNEL_IP6_TC,
   LWTUNNEL_IP6_FLAGS,
-  __LWTUNNEL_IP6_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  LWTUNNEL_IP6_PAD,
+  __LWTUNNEL_IP6_MAX,
 };
 #define LWTUNNEL_IP6_MAX (__LWTUNNEL_IP6_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/magic.h b/libc/kernel/uapi/linux/magic.h
index 16b9752..f9121a7 100644
--- a/libc/kernel/uapi/linux/magic.h
+++ b/libc/kernel/uapi/linux/magic.h
@@ -56,46 +56,50 @@
 #define EFIVARFS_MAGIC 0xde5e81e4
 #define HOSTFS_SUPER_MAGIC 0x00c0ffee
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OVERLAYFS_SUPER_MAGIC 0x794c7630
 #define MINIX_SUPER_MAGIC 0x137F
 #define MINIX_SUPER_MAGIC2 0x138F
 #define MINIX2_SUPER_MAGIC 0x2468
-#define MINIX2_SUPER_MAGIC2 0x2478
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MINIX2_SUPER_MAGIC2 0x2478
 #define MINIX3_SUPER_MAGIC 0x4d5a
 #define MSDOS_SUPER_MAGIC 0x4d44
 #define NCP_SUPER_MAGIC 0x564c
-#define NFS_SUPER_MAGIC 0x6969
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFS_SUPER_MAGIC 0x6969
 #define OPENPROM_SUPER_MAGIC 0x9fa1
 #define QNX4_SUPER_MAGIC 0x002f
 #define QNX6_SUPER_MAGIC 0x68191122
-#define REISERFS_SUPER_MAGIC 0x52654973
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define REISERFS_SUPER_MAGIC 0x52654973
 #define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
 #define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
 #define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
-#define SMB_SUPER_MAGIC 0x517B
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SMB_SUPER_MAGIC 0x517B
 #define CGROUP_SUPER_MAGIC 0x27e0eb
+#define CGROUP2_SUPER_MAGIC 0x63677270
 #define STACK_END_MAGIC 0x57AC6E9D
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TRACEFS_MAGIC 0x74726163
 #define V9FS_MAGIC 0x01021997
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BDEVFS_MAGIC 0x62646576
 #define BINFMTFS_MAGIC 0x42494e4d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DEVPTS_SUPER_MAGIC 0x1cd1
 #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PIPEFS_MAGIC 0x50495045
 #define PROC_SUPER_MAGIC 0x9fa0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SOCKFS_MAGIC 0x534F434B
 #define SYSFS_MAGIC 0x62656572
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVICE_SUPER_MAGIC 0x9fa2
 #define MTD_INODE_FS_MAGIC 0x11307854
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ANON_INODE_FS_MAGIC 0x09041934
 #define BTRFS_TEST_MAGIC 0x73727279
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NSFS_MAGIC 0x6e736673
 #define BPF_FS_MAGIC 0xcafe4a11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UDF_SUPER_MAGIC 0x15013346
 #endif
diff --git a/libc/kernel/uapi/linux/media.h b/libc/kernel/uapi/linux/media.h
index 9b9f465..cd2cb0d 100644
--- a/libc/kernel/uapi/linux/media.h
+++ b/libc/kernel/uapi/linux/media.h
@@ -18,123 +18,243 @@
  ****************************************************************************/
 #ifndef __LINUX_MEDIA_H
 #define __LINUX_MEDIA_H
+#include <stdint.h>
 #include <linux/ioctl.h>
-#include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/types.h>
 #include <linux/version.h>
 #define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
 struct media_device_info {
-  char driver[16];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char driver[16];
   char model[32];
   char serial[40];
   char bus_info[32];
-  __u32 media_version;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 media_version;
   __u32 hw_revision;
   __u32 driver_version;
   __u32 reserved[31];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
+#define MEDIA_ENT_F_UNKNOWN 0x00000000
+#define MEDIA_ENT_F_BASE 0x00000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_ENT_F_OLD_BASE 0x00010000
+#define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000
+#define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 0x00001)
+#define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 0x00002)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 0x00003)
+#define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 0x00004)
+#define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 0x01001)
+#define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 0x01002)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 0x01003)
+#define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 0x02001)
+#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 0x02002)
+#define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 0x03001)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 0x03002)
+#define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003)
+#define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
+#define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
+#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
+#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
+#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
 #define MEDIA_ENT_TYPE_SHIFT 16
 #define MEDIA_ENT_TYPE_MASK 0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT)
-#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1)
+#define MEDIA_ENT_T_DEVNODE_UNKNOWN (MEDIA_ENT_T_DEVNODE | MEDIA_ENT_SUBTYPE_MASK)
+#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
+#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
+#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
+#define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
+#define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MEDIA_ENT_T_DEVNODE_DVB_FE (MEDIA_ENT_T_DEVNODE + 4)
-#define MEDIA_ENT_T_DEVNODE_DVB_DEMUX (MEDIA_ENT_T_DEVNODE + 5)
-#define MEDIA_ENT_T_DEVNODE_DVB_DVR (MEDIA_ENT_T_DEVNODE + 6)
-#define MEDIA_ENT_T_DEVNODE_DVB_CA (MEDIA_ENT_T_DEVNODE + 7)
+#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
+#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
+#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
+#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MEDIA_ENT_T_DEVNODE_DVB_NET (MEDIA_ENT_T_DEVNODE + 8)
-#define MEDIA_ENT_T_DEVNODE_DVB MEDIA_ENT_T_DEVNODE_DVB_FE
-#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT)
-#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2)
-#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3)
-#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV + 4)
-#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV + 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
 #define MEDIA_ENT_FL_DEFAULT (1 << 0)
+#define MEDIA_ENT_FL_CONNECTOR (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct media_entity_desc {
   __u32 id;
   char name[32];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 revision;
   __u32 flags;
   __u32 group_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 pads;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 links;
   __u32 reserved[4];
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 major;
       __u32 minor;
     } dev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u32 card;
       __u32 device;
       __u32 subdevice;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } alsa;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __u32 major;
       __u32 minor;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } v4l;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       __u32 major;
       __u32 minor;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } fb;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     int dvb;
     __u8 raw[184];
   };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MEDIA_PAD_FL_SINK (1 << 0)
 #define MEDIA_PAD_FL_SOURCE (1 << 1)
 #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct media_pad_desc {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 entity;
   __u16 index;
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[2];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define MEDIA_LNK_FL_ENABLED (1 << 0)
 #define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MEDIA_LNK_FL_DYNAMIC (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
+#define MEDIA_LNK_FL_DATA_LINK (0 << 28)
+#define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
 struct media_link_desc {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct media_pad_desc source;
   struct media_pad_desc sink;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   __u32 reserved[2];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct media_links_enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 entity;
   struct media_pad_desc __user * pads;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct media_link_desc __user * links;
   __u32 reserved[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+#define MEDIA_INTF_T_DVB_BASE 0x00000100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_INTF_T_V4L_BASE 0x00000200
+#define MEDIA_INTF_T_ALSA_BASE 0x00000300
+#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
+#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
+#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
+#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
+#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
+#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
+#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
+#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE)
+#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
+#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2)
+#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)
+#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
+#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6)
+#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct media_v2_entity {
+  __u32 id;
+  char name[64];
+  __u32 function;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[6];
+} __attribute__((packed));
+struct media_v2_intf_devnode {
+  __u32 major;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 minor;
+} __attribute__((packed));
+struct media_v2_interface {
+  __u32 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 intf_type;
+  __u32 flags;
+  __u32 reserved[9];
+  union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct media_v2_intf_devnode devnode;
+    __u32 raw[16];
+  };
+} __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct media_v2_pad {
+  __u32 id;
+  __u32 entity_id;
+  __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[5];
+} __attribute__((packed));
+struct media_v2_link {
+  __u32 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 source_id;
+  __u32 sink_id;
+  __u32 flags;
+  __u32 reserved[6];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((packed));
+struct media_v2_topology {
+  __u64 topology_version;
+  __u32 num_entities;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved1;
+  __u64 ptr_entities;
+  __u32 num_interfaces;
+  __u32 reserved2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 ptr_interfaces;
+  __u32 num_pads;
+  __u32 reserved3;
+  __u64 ptr_pads;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 num_links;
+  __u32 reserved4;
+  __u64 ptr_links;
+} __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
 #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
 #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
 #endif
diff --git a/libc/kernel/uapi/linux/mroute6.h b/libc/kernel/uapi/linux/mroute6.h
index 8a3c363..d4da98c 100644
--- a/libc/kernel/uapi/linux/mroute6.h
+++ b/libc/kernel/uapi/linux/mroute6.h
@@ -18,101 +18,98 @@
  ****************************************************************************/
 #ifndef _UAPI__LINUX_MROUTE6_H
 #define _UAPI__LINUX_MROUTE6_H
+#include <linux/kernel.h>
 #include <linux/types.h>
-#include <linux/sockios.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/sockios.h>
 #define MRT6_BASE 200
 #define MRT6_INIT (MRT6_BASE)
 #define MRT6_DONE (MRT6_BASE + 1)
-#define MRT6_ADD_MIF (MRT6_BASE + 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MRT6_ADD_MIF (MRT6_BASE + 2)
 #define MRT6_DEL_MIF (MRT6_BASE + 3)
 #define MRT6_ADD_MFC (MRT6_BASE + 4)
 #define MRT6_DEL_MFC (MRT6_BASE + 5)
-#define MRT6_VERSION (MRT6_BASE + 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MRT6_VERSION (MRT6_BASE + 6)
 #define MRT6_ASSERT (MRT6_BASE + 7)
 #define MRT6_PIM (MRT6_BASE + 8)
 #define MRT6_TABLE (MRT6_BASE + 9)
-#define MRT6_ADD_MFC_PROXY (MRT6_BASE + 10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MRT6_ADD_MFC_PROXY (MRT6_BASE + 10)
 #define MRT6_DEL_MFC_PROXY (MRT6_BASE + 11)
 #define MRT6_MAX (MRT6_BASE + 11)
 #define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE
-#define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE + 1)
 #define SIOCGETRPF (SIOCPROTOPRIVATE + 2)
 #define MAXMIFS 32
 typedef unsigned long mifbitmap_t;
-typedef unsigned short mifi_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef unsigned short mifi_t;
 #define ALL_MIFS ((mifi_t) (- 1))
 #ifndef IF_SETSIZE
 #define IF_SETSIZE 256
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 typedef __u32 if_mask;
 #define NIFBITS (sizeof(if_mask) * 8)
-#ifndef DIV_ROUND_UP
-#define DIV_ROUND_UP(x,y) (((x) + ((y) - 1)) / (y))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
 typedef struct if_set {
-  if_mask ifs_bits[DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
-} if_set;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  if_mask ifs_bits[__KERNEL_DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
+} if_set;
 #define IF_SET(n,p) ((p)->ifs_bits[(n) / NIFBITS] |= (1 << ((n) % NIFBITS)))
 #define IF_CLR(n,p) ((p)->ifs_bits[(n) / NIFBITS] &= ~(1 << ((n) % NIFBITS)))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IF_ISSET(n,p) ((p)->ifs_bits[(n) / NIFBITS] & (1 << ((n) % NIFBITS)))
 #define IF_COPY(f,t) bcopy(f, t, sizeof(* (f)))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IF_ZERO(p) bzero(p, sizeof(* (p)))
 struct mif6ctl {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   mifi_t mif6c_mifi;
   unsigned char mif6c_flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char vifc_threshold;
   __u16 mif6c_pifi;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int vifc_rate_limit;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MIFF_REGISTER 0x1
 struct mf6cctl {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct sockaddr_in6 mf6cc_origin;
   struct sockaddr_in6 mf6cc_mcastgrp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   mifi_t mf6cc_parent;
   struct if_set mf6cc_ifset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct sioc_sg_req6 {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct sockaddr_in6 src;
   struct sockaddr_in6 grp;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long pktcnt;
   unsigned long bytecnt;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long wrong_if;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct sioc_mif_req6 {
   mifi_t mifi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long icount;
   unsigned long ocount;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned long ibytes;
   unsigned long obytes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct mrt6msg {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MRT6MSG_NOCACHE 1
 #define MRT6MSG_WRONGMIF 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MRT6MSG_WHOLEPKT 3
   __u8 im6_mbz;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 im6_msgtype;
   __u16 im6_mif;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 im6_pad;
   struct in6_addr im6_src, im6_dst;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/msg.h b/libc/kernel/uapi/linux/msg.h
index b455f0c..a15b499 100644
--- a/libc/kernel/uapi/linux/msg.h
+++ b/libc/kernel/uapi/linux/msg.h
@@ -26,8 +26,8 @@
 #define MSG_EXCEPT 020000
 #define MSG_COPY 040000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct msqid_ds {
-  struct ipc_perm msg_perm;
+struct __kernel_legacy_msqid_ds {
+  struct __kernel_legacy_ipc_perm msg_perm;
   struct msg * msg_first;
   struct msg * msg_last;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/ndctl.h b/libc/kernel/uapi/linux/ndctl.h
index 6626e24..4a25ab8 100644
--- a/libc/kernel/uapi/linux/ndctl.h
+++ b/libc/kernel/uapi/linux/ndctl.h
@@ -24,120 +24,180 @@
   __u32 status;
   __u8 data[128];
 } __packed;
-struct nd_cmd_smart_threshold {
+#define ND_SMART_HEALTH_VALID (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ND_SMART_TEMP_VALID (1 << 1)
+#define ND_SMART_SPARES_VALID (1 << 2)
+#define ND_SMART_ALARM_VALID (1 << 3)
+#define ND_SMART_USED_VALID (1 << 4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ND_SMART_SHUTDOWN_VALID (1 << 5)
+#define ND_SMART_VENDOR_VALID (1 << 6)
+#define ND_SMART_TEMP_TRIP (1 << 0)
+#define ND_SMART_SPARE_TRIP (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
+#define ND_SMART_CRITICAL_HEALTH (1 << 1)
+#define ND_SMART_FATAL_HEALTH (1 << 2)
+struct nd_smart_payload {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
+  __u8 reserved0[4];
+  __u8 health;
+  __u16 temperature;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 spares;
+  __u8 alarm_flags;
+  __u8 life_used;
+  __u8 shutdown_state;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 reserved1;
+  __u32 vendor_size;
+  __u8 vendor_data[108];
+} __packed;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct nd_cmd_smart_threshold {
   __u32 status;
   __u8 data[8];
 } __packed;
-struct nd_cmd_dimm_flags {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct nd_smart_threshold_payload {
+  __u16 alarm_control;
+  __u16 temperature;
+  __u8 spares;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 reserved[3];
+} __packed;
+struct nd_cmd_dimm_flags {
   __u32 status;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
 } __packed;
 struct nd_cmd_get_config_size {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 status;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 config_size;
   __u32 max_xfer;
 } __packed;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nd_cmd_get_config_data_hdr {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 in_offset;
   __u32 in_length;
   __u32 status;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 out_buf[0];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __packed;
 struct nd_cmd_set_config_hdr {
   __u32 in_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 in_length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 in_buf[0];
 } __packed;
 struct nd_cmd_vendor_hdr {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 opcode;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 in_length;
   __u8 in_buf[0];
 } __packed;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nd_cmd_vendor_tail {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 status;
   __u32 out_length;
   __u8 out_buf[0];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __packed;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nd_cmd_ars_cap {
   __u64 address;
   __u64 length;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 status;
-  __u32 max_ars_out;
-} __packed;
-struct nd_cmd_ars_start {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_ars_out;
+  __u32 clear_err_unit;
+  __u32 reserved;
+} __packed;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct nd_cmd_ars_start {
   __u64 address;
   __u64 length;
   __u16 type;
-  __u8 reserved[6];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 flags;
+  __u8 reserved[5];
   __u32 status;
+  __u32 scrub_time;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __packed;
 struct nd_cmd_ars_status {
   __u32 status;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 out_length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 address;
   __u64 length;
-  __u16 type;
+  __u64 restart_address;
+  __u64 restart_length;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 type;
+  __u16 flags;
   __u32 num_records;
   struct nd_ars_record {
-    __u32 handle;
-    __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u32 handle;
+    __u32 reserved;
     __u64 err_address;
     __u64 length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } __packed records[0];
 } __packed;
+struct nd_cmd_clear_error {
+  __u64 address;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 length;
+  __u32 status;
+  __u8 reserved[4];
+  __u64 cleared;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __packed;
 enum {
   ND_CMD_IMPLEMENTED = 0,
   ND_CMD_ARS_CAP = 1,
-  ND_CMD_ARS_START = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ND_CMD_ARS_START = 2,
   ND_CMD_ARS_STATUS = 3,
+  ND_CMD_CLEAR_ERROR = 4,
   ND_CMD_SMART = 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ND_CMD_SMART_THRESHOLD = 2,
   ND_CMD_DIMM_FLAGS = 3,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ND_CMD_GET_CONFIG_SIZE = 4,
   ND_CMD_GET_CONFIG_DATA = 5,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ND_CMD_SET_CONFIG_DATA = 6,
   ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ND_CMD_VENDOR_EFFECT_LOG = 8,
   ND_CMD_VENDOR = 9,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ND_CMD_CALL = 10,
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ND_ARS_VOLATILE = 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ND_ARS_PERSISTENT = 2,
 };
 #define ND_IOCTL 'N'
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART, struct nd_cmd_smart)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD, struct nd_cmd_smart_threshold)
 #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS, struct nd_cmd_dimm_flags)
 #define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE, struct nd_cmd_get_config_size)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA, struct nd_cmd_get_config_data_hdr)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA, struct nd_cmd_set_config_hdr)
 #define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR, struct nd_cmd_vendor_hdr)
 #define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP, struct nd_cmd_ars_cap)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START, struct nd_cmd_ars_start)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS, struct nd_cmd_ars_status)
+#define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR, struct nd_cmd_clear_error)
 #define ND_DEVICE_DIMM 1
 #define ND_DEVICE_REGION_PMEM 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -146,23 +206,41 @@
 #define ND_DEVICE_NAMESPACE_PMEM 5
 #define ND_DEVICE_NAMESPACE_BLK 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ND_DEVICE_DAX_PMEM 7
 enum nd_driver_flags {
   ND_DRIVER_DIMM = 1 << ND_DEVICE_DIMM,
   ND_DRIVER_REGION_PMEM = 1 << ND_DEVICE_REGION_PMEM,
-  ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
   ND_DRIVER_NAMESPACE_IO = 1 << ND_DEVICE_NAMESPACE_IO,
   ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM,
   ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ND_DRIVER_DAX_PMEM = 1 << ND_DEVICE_DAX_PMEM,
+};
 enum {
   ND_MIN_NAMESPACE_SIZE = 0x00400000,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum ars_masks {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ARS_STATUS_MASK = 0x0000FFFF,
   ARS_EXT_STATUS_SHIFT = 16,
-};
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct nd_cmd_pkg {
+  __u64 nd_family;
+  __u64 nd_command;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 nd_size_in;
+  __u32 nd_size_out;
+  __u32 nd_reserved2[9];
+  __u32 nd_fw_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char nd_payload[];
+};
+#define NVDIMM_FAMILY_INTEL 0
+#define NVDIMM_FAMILY_HPE1 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NVDIMM_FAMILY_HPE2 2
+#define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL, struct nd_cmd_pkg)
+#endif
diff --git a/libc/kernel/uapi/linux/neighbour.h b/libc/kernel/uapi/linux/neighbour.h
index 7af454a..8a28979 100644
--- a/libc/kernel/uapi/linux/neighbour.h
+++ b/libc/kernel/uapi/linux/neighbour.h
@@ -117,44 +117,47 @@
   NDTPA_QUEUE_LENBYTES,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NDTPA_MCAST_REPROBES,
+  NDTPA_PAD,
   __NDTPA_MAX
 };
-#define NDTPA_MAX (__NDTPA_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NDTPA_MAX (__NDTPA_MAX - 1)
 struct ndtmsg {
   __u8 ndtm_family;
   __u8 ndtm_pad1;
-  __u16 ndtm_pad2;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 ndtm_pad2;
 };
 struct ndt_config {
   __u16 ndtc_key_len;
-  __u16 ndtc_entry_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 ndtc_entry_size;
   __u32 ndtc_entries;
   __u32 ndtc_last_flush;
   __u32 ndtc_last_rand;
-  __u32 ndtc_hash_rnd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ndtc_hash_rnd;
   __u32 ndtc_hash_mask;
   __u32 ndtc_hash_chain_gc;
   __u32 ndtc_proxy_qlen;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum {
   NDTA_UNSPEC,
   NDTA_NAME,
-  NDTA_THRESH1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NDTA_THRESH1,
   NDTA_THRESH2,
   NDTA_THRESH3,
   NDTA_CONFIG,
-  NDTA_PARMS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NDTA_PARMS,
   NDTA_STATS,
   NDTA_GC_INTERVAL,
+  NDTA_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NDTA_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NDTA_MAX (__NDTA_MAX - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/net_tstamp.h b/libc/kernel/uapi/linux/net_tstamp.h
index 045201c..96e82eb 100644
--- a/libc/kernel/uapi/linux/net_tstamp.h
+++ b/libc/kernel/uapi/linux/net_tstamp.h
@@ -39,38 +39,40 @@
   SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_TSONLY,
   SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) | SOF_TIMESTAMPING_LAST
 };
-struct hwtstamp_config {
+#define SOF_TIMESTAMPING_TX_RECORD_MASK (SOF_TIMESTAMPING_TX_HARDWARE | SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_TX_SCHED | SOF_TIMESTAMPING_TX_ACK)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct hwtstamp_config {
   int flags;
   int tx_type;
   int rx_filter;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum hwtstamp_tx_types {
   HWTSTAMP_TX_OFF,
   HWTSTAMP_TX_ON,
-  HWTSTAMP_TX_ONESTEP_SYNC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HWTSTAMP_TX_ONESTEP_SYNC,
 };
 enum hwtstamp_rx_filters {
   HWTSTAMP_FILTER_NONE,
-  HWTSTAMP_FILTER_ALL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HWTSTAMP_FILTER_ALL,
   HWTSTAMP_FILTER_SOME,
   HWTSTAMP_FILTER_PTP_V1_L4_EVENT,
   HWTSTAMP_FILTER_PTP_V1_L4_SYNC,
-  HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ,
   HWTSTAMP_FILTER_PTP_V2_L4_EVENT,
   HWTSTAMP_FILTER_PTP_V2_L4_SYNC,
   HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ,
-  HWTSTAMP_FILTER_PTP_V2_L2_EVENT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HWTSTAMP_FILTER_PTP_V2_L2_EVENT,
   HWTSTAMP_FILTER_PTP_V2_L2_SYNC,
   HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ,
   HWTSTAMP_FILTER_PTP_V2_EVENT,
-  HWTSTAMP_FILTER_PTP_V2_SYNC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  HWTSTAMP_FILTER_PTP_V2_SYNC,
   HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netconf.h b/libc/kernel/uapi/linux/netconf.h
index 556ecaf..ec10ea5 100644
--- a/libc/kernel/uapi/linux/netconf.h
+++ b/libc/kernel/uapi/linux/netconf.h
@@ -38,7 +38,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NETCONFA_MAX (__NETCONFA_MAX - 1)
+#define NETCONFA_ALL - 1
 #define NETCONFA_IFINDEX_ALL - 1
-#define NETCONFA_IFINDEX_DEFAULT - 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NETCONFA_IFINDEX_DEFAULT - 2
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/ipset/ip_set.h b/libc/kernel/uapi/linux/netfilter/ipset/ip_set.h
index 7459cb4..d3df8d6 100644
--- a/libc/kernel/uapi/linux/netfilter/ipset/ip_set.h
+++ b/libc/kernel/uapi/linux/netfilter/ipset/ip_set.h
@@ -126,179 +126,180 @@
   IPSET_ATTR_SKBPRIO,
   IPSET_ATTR_SKBQUEUE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ATTR_PAD,
   __IPSET_ATTR_ADT_MAX,
 };
 #define IPSET_ATTR_ADT_MAX (__IPSET_ATTR_ADT_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   IPSET_ATTR_IPADDR_IPV4 = IPSET_ATTR_UNSPEC + 1,
   IPSET_ATTR_IPADDR_IPV6,
   __IPSET_ATTR_IPADDR_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IPSET_ATTR_IPADDR_MAX (__IPSET_ATTR_IPADDR_MAX - 1)
 enum ipset_errno {
   IPSET_ERR_PRIVATE = 4096,
-  IPSET_ERR_PROTOCOL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_PROTOCOL,
   IPSET_ERR_FIND_TYPE,
   IPSET_ERR_MAX_SETS,
   IPSET_ERR_BUSY,
-  IPSET_ERR_EXIST_SETNAME2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_EXIST_SETNAME2,
   IPSET_ERR_TYPE_MISMATCH,
   IPSET_ERR_EXIST,
   IPSET_ERR_INVALID_CIDR,
-  IPSET_ERR_INVALID_NETMASK,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_INVALID_NETMASK,
   IPSET_ERR_INVALID_FAMILY,
   IPSET_ERR_TIMEOUT,
   IPSET_ERR_REFERENCED,
-  IPSET_ERR_IPADDR_IPV4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_IPADDR_IPV4,
   IPSET_ERR_IPADDR_IPV6,
   IPSET_ERR_COUNTER,
   IPSET_ERR_COMMENT,
-  IPSET_ERR_INVALID_MARKMASK,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_INVALID_MARKMASK,
   IPSET_ERR_SKBINFO,
   IPSET_ERR_TYPE_SPECIFIC = 4352,
 };
-enum ipset_cmd_flags {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum ipset_cmd_flags {
   IPSET_FLAG_BIT_EXIST = 0,
   IPSET_FLAG_EXIST = (1 << IPSET_FLAG_BIT_EXIST),
   IPSET_FLAG_BIT_LIST_SETNAME = 1,
-  IPSET_FLAG_LIST_SETNAME = (1 << IPSET_FLAG_BIT_LIST_SETNAME),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_LIST_SETNAME = (1 << IPSET_FLAG_BIT_LIST_SETNAME),
   IPSET_FLAG_BIT_LIST_HEADER = 2,
   IPSET_FLAG_LIST_HEADER = (1 << IPSET_FLAG_BIT_LIST_HEADER),
   IPSET_FLAG_BIT_SKIP_COUNTER_UPDATE = 3,
-  IPSET_FLAG_SKIP_COUNTER_UPDATE = (1 << IPSET_FLAG_BIT_SKIP_COUNTER_UPDATE),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_SKIP_COUNTER_UPDATE = (1 << IPSET_FLAG_BIT_SKIP_COUNTER_UPDATE),
   IPSET_FLAG_BIT_SKIP_SUBCOUNTER_UPDATE = 4,
   IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE = (1 << IPSET_FLAG_BIT_SKIP_SUBCOUNTER_UPDATE),
   IPSET_FLAG_BIT_MATCH_COUNTERS = 5,
-  IPSET_FLAG_MATCH_COUNTERS = (1 << IPSET_FLAG_BIT_MATCH_COUNTERS),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_MATCH_COUNTERS = (1 << IPSET_FLAG_BIT_MATCH_COUNTERS),
   IPSET_FLAG_BIT_RETURN_NOMATCH = 7,
   IPSET_FLAG_RETURN_NOMATCH = (1 << IPSET_FLAG_BIT_RETURN_NOMATCH),
   IPSET_FLAG_BIT_MAP_SKBMARK = 8,
-  IPSET_FLAG_MAP_SKBMARK = (1 << IPSET_FLAG_BIT_MAP_SKBMARK),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_MAP_SKBMARK = (1 << IPSET_FLAG_BIT_MAP_SKBMARK),
   IPSET_FLAG_BIT_MAP_SKBPRIO = 9,
   IPSET_FLAG_MAP_SKBPRIO = (1 << IPSET_FLAG_BIT_MAP_SKBPRIO),
   IPSET_FLAG_BIT_MAP_SKBQUEUE = 10,
-  IPSET_FLAG_MAP_SKBQUEUE = (1 << IPSET_FLAG_BIT_MAP_SKBQUEUE),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_MAP_SKBQUEUE = (1 << IPSET_FLAG_BIT_MAP_SKBQUEUE),
   IPSET_FLAG_CMD_MAX = 15,
 };
 enum ipset_cadt_flags {
-  IPSET_FLAG_BIT_BEFORE = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_BIT_BEFORE = 0,
   IPSET_FLAG_BEFORE = (1 << IPSET_FLAG_BIT_BEFORE),
   IPSET_FLAG_BIT_PHYSDEV = 1,
   IPSET_FLAG_PHYSDEV = (1 << IPSET_FLAG_BIT_PHYSDEV),
-  IPSET_FLAG_BIT_NOMATCH = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_BIT_NOMATCH = 2,
   IPSET_FLAG_NOMATCH = (1 << IPSET_FLAG_BIT_NOMATCH),
   IPSET_FLAG_BIT_WITH_COUNTERS = 3,
   IPSET_FLAG_WITH_COUNTERS = (1 << IPSET_FLAG_BIT_WITH_COUNTERS),
-  IPSET_FLAG_BIT_WITH_COMMENT = 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_BIT_WITH_COMMENT = 4,
   IPSET_FLAG_WITH_COMMENT = (1 << IPSET_FLAG_BIT_WITH_COMMENT),
   IPSET_FLAG_BIT_WITH_FORCEADD = 5,
   IPSET_FLAG_WITH_FORCEADD = (1 << IPSET_FLAG_BIT_WITH_FORCEADD),
-  IPSET_FLAG_BIT_WITH_SKBINFO = 6,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_FLAG_BIT_WITH_SKBINFO = 6,
   IPSET_FLAG_WITH_SKBINFO = (1 << IPSET_FLAG_BIT_WITH_SKBINFO),
   IPSET_FLAG_CADT_MAX = 15,
 };
-enum ipset_create_flags {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum ipset_create_flags {
   IPSET_CREATE_FLAG_BIT_FORCEADD = 0,
   IPSET_CREATE_FLAG_FORCEADD = (1 << IPSET_CREATE_FLAG_BIT_FORCEADD),
   IPSET_CREATE_FLAG_BIT_MAX = 7,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum ipset_adt {
   IPSET_ADD,
   IPSET_DEL,
-  IPSET_TEST,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_TEST,
   IPSET_ADT_MAX,
   IPSET_CREATE = IPSET_ADT_MAX,
   IPSET_CADT_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 typedef __u16 ip_set_id_t;
 #define IPSET_INVALID_ID 65535
 enum ip_set_dim {
-  IPSET_DIM_ZERO = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_DIM_ZERO = 0,
   IPSET_DIM_ONE,
   IPSET_DIM_TWO,
   IPSET_DIM_THREE,
-  IPSET_DIM_MAX = 6,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_DIM_MAX = 6,
   IPSET_BIT_RETURN_NOMATCH = 7,
 };
 enum ip_set_kopt {
-  IPSET_INV_MATCH = (1 << IPSET_DIM_ZERO),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_INV_MATCH = (1 << IPSET_DIM_ZERO),
   IPSET_DIM_ONE_SRC = (1 << IPSET_DIM_ONE),
   IPSET_DIM_TWO_SRC = (1 << IPSET_DIM_TWO),
   IPSET_DIM_THREE_SRC = (1 << IPSET_DIM_THREE),
-  IPSET_RETURN_NOMATCH = (1 << IPSET_BIT_RETURN_NOMATCH),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_RETURN_NOMATCH = (1 << IPSET_BIT_RETURN_NOMATCH),
 };
 enum {
   IPSET_COUNTER_NONE = 0,
-  IPSET_COUNTER_EQ,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_COUNTER_EQ,
   IPSET_COUNTER_NE,
   IPSET_COUNTER_LT,
   IPSET_COUNTER_GT,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ip_set_counter_match0 {
   __u8 op;
   __u64 value;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ip_set_counter_match {
   __aligned_u64 value;
   __u8 op;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define SO_IP_SET 83
 union ip_set_name_index {
   char name[IPSET_MAXNAMELEN];
-  ip_set_id_t index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  ip_set_id_t index;
 };
 #define IP_SET_OP_GET_BYNAME 0x00000006
 struct ip_set_req_get_set {
-  unsigned int op;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int op;
   unsigned int version;
   union ip_set_name_index set;
 };
-#define IP_SET_OP_GET_BYINDEX 0x00000007
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP_SET_OP_GET_BYINDEX 0x00000007
 #define IP_SET_OP_GET_FNAME 0x00000008
 struct ip_set_req_get_set_family {
   unsigned int op;
-  unsigned int version;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int version;
   unsigned int family;
   union ip_set_name_index set;
 };
-#define IP_SET_OP_VERSION 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP_SET_OP_VERSION 0x00000100
 struct ip_set_req_version {
   unsigned int op;
   unsigned int version;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/ipset/ip_set_bitmap.h b/libc/kernel/uapi/linux/netfilter/ipset/ip_set_bitmap.h
index edcae4c..78ff715 100644
--- a/libc/kernel/uapi/linux/netfilter/ipset/ip_set_bitmap.h
+++ b/libc/kernel/uapi/linux/netfilter/ipset/ip_set_bitmap.h
@@ -18,9 +18,11 @@
  ****************************************************************************/
 #ifndef _UAPI__IP_SET_BITMAP_H
 #define _UAPI__IP_SET_BITMAP_H
+#include <linux/netfilter/ipset/ip_set.h>
 enum {
-  IPSET_ERR_BITMAP_RANGE = IPSET_ERR_TYPE_SPECIFIC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_BITMAP_RANGE = IPSET_ERR_TYPE_SPECIFIC,
   IPSET_ERR_BITMAP_RANGE_SIZE,
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/ipset/ip_set_hash.h b/libc/kernel/uapi/linux/netfilter/ipset/ip_set_hash.h
index dd765fc..eec8067 100644
--- a/libc/kernel/uapi/linux/netfilter/ipset/ip_set_hash.h
+++ b/libc/kernel/uapi/linux/netfilter/ipset/ip_set_hash.h
@@ -18,14 +18,16 @@
  ****************************************************************************/
 #ifndef _UAPI__IP_SET_HASH_H
 #define _UAPI__IP_SET_HASH_H
+#include <linux/netfilter/ipset/ip_set.h>
 enum {
-  IPSET_ERR_HASH_FULL = IPSET_ERR_TYPE_SPECIFIC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_HASH_FULL = IPSET_ERR_TYPE_SPECIFIC,
   IPSET_ERR_HASH_ELEM,
   IPSET_ERR_INVALID_PROTO,
   IPSET_ERR_MISSING_PROTO,
-  IPSET_ERR_HASH_RANGE_UNSUPPORTED,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_HASH_RANGE_UNSUPPORTED,
   IPSET_ERR_HASH_RANGE,
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/ipset/ip_set_list.h b/libc/kernel/uapi/linux/netfilter/ipset/ip_set_list.h
index 623574c..7ebae67 100644
--- a/libc/kernel/uapi/linux/netfilter/ipset/ip_set_list.h
+++ b/libc/kernel/uapi/linux/netfilter/ipset/ip_set_list.h
@@ -18,14 +18,16 @@
  ****************************************************************************/
 #ifndef _UAPI__IP_SET_LIST_H
 #define _UAPI__IP_SET_LIST_H
+#include <linux/netfilter/ipset/ip_set.h>
 enum {
-  IPSET_ERR_NAME = IPSET_ERR_TYPE_SPECIFIC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_NAME = IPSET_ERR_TYPE_SPECIFIC,
   IPSET_ERR_LOOP,
   IPSET_ERR_BEFORE,
   IPSET_ERR_NAMEREF,
-  IPSET_ERR_LIST_FULL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IPSET_ERR_LIST_FULL,
   IPSET_ERR_REF_EXIST,
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h b/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h
index 57cbb90..25bf6ea 100644
--- a/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h
+++ b/libc/kernel/uapi/linux/netfilter/nf_conntrack_common.h
@@ -27,8 +27,8 @@
   IP_CT_ESTABLISHED_REPLY = IP_CT_ESTABLISHED + IP_CT_IS_REPLY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IP_CT_RELATED_REPLY = IP_CT_RELATED + IP_CT_IS_REPLY,
-  IP_CT_NEW_REPLY = IP_CT_NEW + IP_CT_IS_REPLY,
-  IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1
+  IP_CT_NUMBER,
+  IP_CT_NEW_REPLY = IP_CT_NUMBER,
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NF_CT_STATE_INVALID_BIT (1 << 0)
diff --git a/libc/kernel/uapi/linux/netfilter/nf_conntrack_sctp.h b/libc/kernel/uapi/linux/netfilter/nf_conntrack_sctp.h
index dd7525a..d4f6b58 100644
--- a/libc/kernel/uapi/linux/netfilter/nf_conntrack_sctp.h
+++ b/libc/kernel/uapi/linux/netfilter/nf_conntrack_sctp.h
@@ -16,8 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _NF_CONNTRACK_SCTP_H
-#define _NF_CONNTRACK_SCTP_H
+#ifndef _UAPI_NF_CONNTRACK_SCTP_H
+#define _UAPI_NF_CONNTRACK_SCTP_H
 #include <linux/netfilter/nf_conntrack_tuple_common.h>
 enum sctp_conntrack {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -36,9 +36,4 @@
   SCTP_CONNTRACK_MAX
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct ip_ct_sctp {
-  enum sctp_conntrack state;
-  __be32 vtag[IP_CT_DIR_MAX];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/nf_conntrack_tuple_common.h b/libc/kernel/uapi/linux/netfilter/nf_conntrack_tuple_common.h
index 8566e86..2ff1dd8 100644
--- a/libc/kernel/uapi/linux/netfilter/nf_conntrack_tuple_common.h
+++ b/libc/kernel/uapi/linux/netfilter/nf_conntrack_tuple_common.h
@@ -18,38 +18,41 @@
  ****************************************************************************/
 #ifndef _NF_CONNTRACK_TUPLE_COMMON_H
 #define _NF_CONNTRACK_TUPLE_COMMON_H
+#include <linux/types.h>
+#include <linux/netfilter.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ip_conntrack_dir {
   IP_CT_DIR_ORIGINAL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   IP_CT_DIR_REPLY,
   IP_CT_DIR_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 union nf_conntrack_man_proto {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be16 all;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __be16 port;
   } tcp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     __be16 port;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } udp;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __be16 id;
   } icmp;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     __be16 port;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } dccp;
   struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __be16 port;
   } sctp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct {
     __be16 key;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } gre;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTINFO2DIR(ctinfo) ((ctinfo) >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/nf_tables.h b/libc/kernel/uapi/linux/netfilter/nf_tables.h
index 7284549..bfe5e01 100644
--- a/libc/kernel/uapi/linux/netfilter/nf_tables.h
+++ b/libc/kernel/uapi/linux/netfilter/nf_tables.h
@@ -21,133 +21,138 @@
 #define NFT_TABLE_MAXNAMELEN 32
 #define NFT_CHAIN_MAXNAMELEN 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFT_SET_MAXNAMELEN 32
 #define NFT_USERDATA_MAXLEN 256
 enum nft_registers {
   NFT_REG_VERDICT,
-  NFT_REG_1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_REG_1,
   NFT_REG_2,
   NFT_REG_3,
   NFT_REG_4,
-  __NFT_REG_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NFT_REG_MAX,
   NFT_REG32_00 = 8,
   MFT_REG32_01,
   NFT_REG32_02,
-  NFT_REG32_03,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_REG32_03,
   NFT_REG32_04,
   NFT_REG32_05,
   NFT_REG32_06,
-  NFT_REG32_07,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_REG32_07,
   NFT_REG32_08,
   NFT_REG32_09,
   NFT_REG32_10,
-  NFT_REG32_11,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_REG32_11,
   NFT_REG32_12,
   NFT_REG32_13,
   NFT_REG32_14,
-  NFT_REG32_15,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_REG32_15,
 };
 #define NFT_REG_MAX (__NFT_REG_MAX - 1)
 #define NFT_REG_SIZE 16
-#define NFT_REG32_SIZE 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFT_REG32_SIZE 4
 enum nft_verdicts {
   NFT_CONTINUE = - 1,
   NFT_BREAK = - 2,
-  NFT_JUMP = - 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_JUMP = - 3,
   NFT_GOTO = - 4,
   NFT_RETURN = - 5,
 };
-enum nf_tables_msg_types {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum nf_tables_msg_types {
   NFT_MSG_NEWTABLE,
   NFT_MSG_GETTABLE,
   NFT_MSG_DELTABLE,
-  NFT_MSG_NEWCHAIN,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_MSG_NEWCHAIN,
   NFT_MSG_GETCHAIN,
   NFT_MSG_DELCHAIN,
   NFT_MSG_NEWRULE,
-  NFT_MSG_GETRULE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_MSG_GETRULE,
   NFT_MSG_DELRULE,
   NFT_MSG_NEWSET,
   NFT_MSG_GETSET,
-  NFT_MSG_DELSET,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_MSG_DELSET,
   NFT_MSG_NEWSETELEM,
   NFT_MSG_GETSETELEM,
   NFT_MSG_DELSETELEM,
-  NFT_MSG_NEWGEN,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_MSG_NEWGEN,
   NFT_MSG_GETGEN,
+  NFT_MSG_TRACE,
   NFT_MSG_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nft_list_attributes {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_LIST_UNPEC,
   NFTA_LIST_ELEM,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_LIST_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_LIST_MAX (__NFTA_LIST_MAX - 1)
 enum nft_hook_attributes {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_HOOK_UNSPEC,
   NFTA_HOOK_HOOKNUM,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_HOOK_PRIORITY,
   NFTA_HOOK_DEV,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_HOOK_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_HOOK_MAX (__NFTA_HOOK_MAX - 1)
 enum nft_table_flags {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_TABLE_F_DORMANT = 0x1,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_table_attributes {
   NFTA_TABLE_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_TABLE_NAME,
   NFTA_TABLE_FLAGS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_TABLE_USE,
   __NFTA_TABLE_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_chain_attributes {
   NFTA_CHAIN_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CHAIN_TABLE,
   NFTA_CHAIN_HANDLE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CHAIN_NAME,
   NFTA_CHAIN_HOOK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CHAIN_POLICY,
   NFTA_CHAIN_USE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CHAIN_TYPE,
   NFTA_CHAIN_COUNTERS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_CHAIN_PAD,
   __NFTA_CHAIN_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_rule_attributes {
   NFTA_RULE_UNSPEC,
   NFTA_RULE_TABLE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_RULE_CHAIN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_RULE_HANDLE,
   NFTA_RULE_EXPRESSIONS,
   NFTA_RULE_COMPAT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_RULE_POSITION,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_RULE_USERDATA,
+  NFTA_RULE_PAD,
   __NFTA_RULE_MAX
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -206,159 +211,164 @@
   NFTA_SET_TIMEOUT,
   NFTA_SET_GC_INTERVAL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_SET_USERDATA,
+  NFTA_SET_PAD,
   __NFTA_SET_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_SET_MAX (__NFTA_SET_MAX - 1)
 enum nft_set_elem_flags {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_SET_ELEM_INTERVAL_END = 0x1,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_set_elem_attributes {
   NFTA_SET_ELEM_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_SET_ELEM_KEY,
   NFTA_SET_ELEM_DATA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_SET_ELEM_FLAGS,
   NFTA_SET_ELEM_TIMEOUT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_SET_ELEM_EXPIRATION,
   NFTA_SET_ELEM_USERDATA,
-  NFTA_SET_ELEM_EXPR,
-  __NFTA_SET_ELEM_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_SET_ELEM_EXPR,
+  NFTA_SET_ELEM_PAD,
+  __NFTA_SET_ELEM_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1)
 enum nft_set_elem_list_attributes {
   NFTA_SET_ELEM_LIST_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_SET_ELEM_LIST_TABLE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_SET_ELEM_LIST_SET,
   NFTA_SET_ELEM_LIST_ELEMENTS,
   NFTA_SET_ELEM_LIST_SET_ID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_SET_ELEM_LIST_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_SET_ELEM_LIST_MAX (__NFTA_SET_ELEM_LIST_MAX - 1)
 enum nft_data_types {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_DATA_VALUE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_DATA_VERDICT = 0xffffff00U,
 };
 #define NFT_DATA_RESERVED_MASK 0xffffff00U
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_data_attributes {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_DATA_UNSPEC,
   NFTA_DATA_VALUE,
   NFTA_DATA_VERDICT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_DATA_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1)
 #define NFT_DATA_VALUE_MAXLEN 64
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_verdict_attributes {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_VERDICT_UNSPEC,
   NFTA_VERDICT_CODE,
   NFTA_VERDICT_CHAIN,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_VERDICT_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_VERDICT_MAX (__NFTA_VERDICT_MAX - 1)
 enum nft_expr_attributes {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_EXPR_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_EXPR_NAME,
   NFTA_EXPR_DATA,
   __NFTA_EXPR_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_EXPR_MAX (__NFTA_EXPR_MAX - 1)
 enum nft_immediate_attributes {
   NFTA_IMMEDIATE_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_IMMEDIATE_DREG,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_IMMEDIATE_DATA,
   __NFTA_IMMEDIATE_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_IMMEDIATE_MAX (__NFTA_IMMEDIATE_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_bitwise_attributes {
   NFTA_BITWISE_UNSPEC,
   NFTA_BITWISE_SREG,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_BITWISE_DREG,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_BITWISE_LEN,
   NFTA_BITWISE_MASK,
   NFTA_BITWISE_XOR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_BITWISE_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_BITWISE_MAX (__NFTA_BITWISE_MAX - 1)
 enum nft_byteorder_ops {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_BYTEORDER_NTOH,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_BYTEORDER_HTON,
 };
 enum nft_byteorder_attributes {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_BYTEORDER_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_BYTEORDER_SREG,
   NFTA_BYTEORDER_DREG,
   NFTA_BYTEORDER_OP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_BYTEORDER_LEN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_BYTEORDER_SIZE,
   __NFTA_BYTEORDER_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_BYTEORDER_MAX (__NFTA_BYTEORDER_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_cmp_ops {
   NFT_CMP_EQ,
   NFT_CMP_NEQ,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_CMP_LT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_CMP_LTE,
   NFT_CMP_GT,
   NFT_CMP_GTE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_cmp_attributes {
   NFTA_CMP_UNSPEC,
   NFTA_CMP_SREG,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CMP_OP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CMP_DATA,
   __NFTA_CMP_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_CMP_MAX (__NFTA_CMP_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_lookup_attributes {
   NFTA_LOOKUP_UNSPEC,
   NFTA_LOOKUP_SET,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_LOOKUP_SREG,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_LOOKUP_DREG,
   NFTA_LOOKUP_SET_ID,
   __NFTA_LOOKUP_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_LOOKUP_MAX (__NFTA_LOOKUP_MAX - 1)
 enum nft_dynset_ops {
   NFT_DYNSET_OP_ADD,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_DYNSET_OP_UPDATE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nft_dynset_attributes {
   NFTA_DYNSET_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_DYNSET_SET_NAME,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_DYNSET_SET_ID,
   NFTA_DYNSET_OP,
   NFTA_DYNSET_SREG_KEY,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_DYNSET_SREG_DATA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_DYNSET_TIMEOUT,
   NFTA_DYNSET_EXPR,
+  NFTA_DYNSET_PAD,
   __NFTA_DYNSET_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
@@ -369,6 +379,11 @@
   NFT_PAYLOAD_NETWORK_HEADER,
   NFT_PAYLOAD_TRANSPORT_HEADER,
 };
+enum nft_payload_csum_types {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_PAYLOAD_CSUM_NONE,
+  NFT_PAYLOAD_CSUM_INET,
+};
 enum nft_payload_attributes {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_PAYLOAD_UNSPEC,
@@ -377,52 +392,57 @@
   NFTA_PAYLOAD_OFFSET,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_PAYLOAD_LEN,
+  NFTA_PAYLOAD_SREG,
+  NFTA_PAYLOAD_CSUM_TYPE,
+  NFTA_PAYLOAD_CSUM_OFFSET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_PAYLOAD_MAX
 };
 #define NFTA_PAYLOAD_MAX (__NFTA_PAYLOAD_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_exthdr_attributes {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_EXTHDR_UNSPEC,
   NFTA_EXTHDR_DREG,
   NFTA_EXTHDR_TYPE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_EXTHDR_OFFSET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_EXTHDR_LEN,
   __NFTA_EXTHDR_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_EXTHDR_MAX (__NFTA_EXTHDR_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_meta_keys {
   NFT_META_LEN,
   NFT_META_PROTOCOL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_PRIORITY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_MARK,
   NFT_META_IIF,
   NFT_META_OIF,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_IIFNAME,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_OIFNAME,
   NFT_META_IIFTYPE,
   NFT_META_OIFTYPE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_SKUID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_SKGID,
   NFT_META_NFTRACE,
   NFT_META_RTCLASSID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_SECMARK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_NFPROTO,
   NFT_META_L4PROTO,
   NFT_META_BRI_IIFNAME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_BRI_OIFNAME,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_PKTTYPE,
   NFT_META_CPU,
   NFT_META_IIFGROUP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_OIFGROUP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_META_CGROUP,
+  NFT_META_PRANDOM,
 };
 enum nft_meta_attributes {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -453,40 +473,50 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_CT_PROTO_DST,
   NFT_CT_LABELS,
+  NFT_CT_PKTS,
+  NFT_CT_BYTES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nft_ct_attributes {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CT_UNSPEC,
   NFTA_CT_DREG,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CT_KEY,
   NFTA_CT_DIRECTION,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_CT_SREG,
   __NFTA_CT_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_CT_MAX (__NFTA_CT_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_limit_type {
   NFT_LIMIT_PKTS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFT_LIMIT_PKT_BYTES
 };
+enum nft_limit_flags {
+  NFT_LIMIT_F_INV = (1 << 0),
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum nft_limit_attributes {
   NFTA_LIMIT_UNSPEC,
   NFTA_LIMIT_RATE,
-  NFTA_LIMIT_UNIT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_LIMIT_UNIT,
   NFTA_LIMIT_BURST,
   NFTA_LIMIT_TYPE,
+  NFTA_LIMIT_FLAGS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_LIMIT_PAD,
   __NFTA_LIMIT_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_LIMIT_MAX (__NFTA_LIMIT_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_counter_attributes {
   NFTA_COUNTER_UNSPEC,
   NFTA_COUNTER_BYTES,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_COUNTER_PACKETS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_COUNTER_PAD,
   __NFTA_COUNTER_MAX
 };
 #define NFTA_COUNTER_MAX (__NFTA_COUNTER_MAX - 1)
@@ -567,28 +597,38 @@
   NFTA_MASQ_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_MASQ_FLAGS,
+  NFTA_MASQ_REG_PROTO_MIN,
+  NFTA_MASQ_REG_PROTO_MAX,
   __NFTA_MASQ_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_redir_attributes {
   NFTA_REDIR_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_REDIR_REG_PROTO_MIN,
   NFTA_REDIR_REG_PROTO_MAX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_REDIR_FLAGS,
   __NFTA_REDIR_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFTA_REDIR_MAX (__NFTA_REDIR_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nft_dup_attributes {
   NFTA_DUP_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_DUP_SREG_ADDR,
   NFTA_DUP_SREG_DEV,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NFTA_DUP_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_DUP_MAX (__NFTA_DUP_MAX - 1)
+enum nft_fwd_attributes {
+  NFTA_FWD_UNSPEC,
+  NFTA_FWD_SREG_DEV,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NFTA_FWD_MAX
+};
+#define NFTA_FWD_MAX (__NFTA_FWD_MAX - 1)
 enum nft_gen_attributes {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFTA_GEN_UNSPEC,
@@ -597,4 +637,42 @@
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1)
+enum nft_trace_attibutes {
+  NFTA_TRACE_UNSPEC,
+  NFTA_TRACE_TABLE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_TRACE_CHAIN,
+  NFTA_TRACE_RULE_HANDLE,
+  NFTA_TRACE_TYPE,
+  NFTA_TRACE_VERDICT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_TRACE_ID,
+  NFTA_TRACE_LL_HEADER,
+  NFTA_TRACE_NETWORK_HEADER,
+  NFTA_TRACE_TRANSPORT_HEADER,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_TRACE_IIF,
+  NFTA_TRACE_IIFTYPE,
+  NFTA_TRACE_OIF,
+  NFTA_TRACE_OIFTYPE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFTA_TRACE_MARK,
+  NFTA_TRACE_NFPROTO,
+  NFTA_TRACE_POLICY,
+  NFTA_TRACE_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NFTA_TRACE_MAX
+};
+#define NFTA_TRACE_MAX (__NFTA_TRACE_MAX - 1)
+enum nft_trace_types {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFT_TRACETYPE_UNSPEC,
+  NFT_TRACETYPE_POLICY,
+  NFT_TRACETYPE_RETURN,
+  NFT_TRACETYPE_RULE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NFT_TRACETYPE_MAX
+};
+#define NFT_TRACETYPE_MAX (__NFT_TRACETYPE_MAX - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/nfnetlink.h b/libc/kernel/uapi/linux/netfilter/nfnetlink.h
index ea06f08..7d7e527 100644
--- a/libc/kernel/uapi/linux/netfilter/nfnetlink.h
+++ b/libc/kernel/uapi/linux/netfilter/nfnetlink.h
@@ -44,37 +44,40 @@
 #define NFNLGRP_NFTABLES NFNLGRP_NFTABLES
   NFNLGRP_ACCT_QUOTA,
 #define NFNLGRP_ACCT_QUOTA NFNLGRP_ACCT_QUOTA
-  __NFNLGRP_MAX,
+  NFNLGRP_NFTRACE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFNLGRP_NFTRACE NFNLGRP_NFTRACE
+  __NFNLGRP_MAX,
 };
 #define NFNLGRP_MAX (__NFNLGRP_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nfgenmsg {
   __u8 nfgen_family;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 version;
   __be16 res_id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NFNETLINK_V0 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_ID(x) ((x & 0xff00) >> 8)
 #define NFNL_MSG_TYPE(x) (x & 0x00ff)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_NONE 0
 #define NFNL_SUBSYS_CTNETLINK 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_CTNETLINK_EXP 2
 #define NFNL_SUBSYS_QUEUE 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_ULOG 4
 #define NFNL_SUBSYS_OSF 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_IPSET 6
 #define NFNL_SUBSYS_ACCT 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_CTNETLINK_TIMEOUT 8
 #define NFNL_SUBSYS_CTHELPER 9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_NFTABLES 10
 #define NFNL_SUBSYS_NFT_COMPAT 11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_SUBSYS_COUNT 12
 #define NFNL_MSG_BATCH_BEGIN NLMSG_MIN_TYPE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NFNL_MSG_BATCH_END NLMSG_MIN_TYPE + 1
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/nfnetlink_acct.h b/libc/kernel/uapi/linux/netfilter/nfnetlink_acct.h
index 2b71112..588405e 100644
--- a/libc/kernel/uapi/linux/netfilter/nfnetlink_acct.h
+++ b/libc/kernel/uapi/linux/netfilter/nfnetlink_acct.h
@@ -49,17 +49,18 @@
   NFACCT_FLAGS,
   NFACCT_QUOTA,
   NFACCT_FILTER,
-  __NFACCT_MAX
+  NFACCT_PAD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NFACCT_MAX
 };
 #define NFACCT_MAX (__NFACCT_MAX - 1)
 enum nfnl_attr_filter_type {
-  NFACCT_FILTER_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFACCT_FILTER_UNSPEC,
   NFACCT_FILTER_MASK,
   NFACCT_FILTER_VALUE,
   __NFACCT_FILTER_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define NFACCT_FILTER_MAX (__NFACCT_FILTER_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/nfnetlink_conntrack.h b/libc/kernel/uapi/linux/netfilter/nfnetlink_conntrack.h
index cde3340..62dd299 100644
--- a/libc/kernel/uapi/linux/netfilter/nfnetlink_conntrack.h
+++ b/libc/kernel/uapi/linux/netfilter/nfnetlink_conntrack.h
@@ -148,167 +148,171 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_PROTOINFO_DCCP_ROLE,
   CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ,
+  CTA_PROTOINFO_DCCP_PAD,
   __CTA_PROTOINFO_DCCP_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define CTA_PROTOINFO_DCCP_MAX (__CTA_PROTOINFO_DCCP_MAX - 1)
 enum ctattr_protoinfo_sctp {
   CTA_PROTOINFO_SCTP_UNSPEC,
-  CTA_PROTOINFO_SCTP_STATE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTA_PROTOINFO_SCTP_STATE,
   CTA_PROTOINFO_SCTP_VTAG_ORIGINAL,
   CTA_PROTOINFO_SCTP_VTAG_REPLY,
   __CTA_PROTOINFO_SCTP_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define CTA_PROTOINFO_SCTP_MAX (__CTA_PROTOINFO_SCTP_MAX - 1)
 enum ctattr_counters {
   CTA_COUNTERS_UNSPEC,
-  CTA_COUNTERS_PACKETS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTA_COUNTERS_PACKETS,
   CTA_COUNTERS_BYTES,
   CTA_COUNTERS32_PACKETS,
   CTA_COUNTERS32_BYTES,
-  __CTA_COUNTERS_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTA_COUNTERS_PAD,
+  __CTA_COUNTERS_MAX
 };
 #define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_tstamp {
   CTA_TIMESTAMP_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_TIMESTAMP_START,
   CTA_TIMESTAMP_STOP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  CTA_TIMESTAMP_PAD,
   __CTA_TIMESTAMP_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTA_TIMESTAMP_MAX (__CTA_TIMESTAMP_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_nat {
   CTA_NAT_UNSPEC,
   CTA_NAT_V4_MINIP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTA_NAT_MINIP CTA_NAT_V4_MINIP
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_NAT_V4_MAXIP,
 #define CTA_NAT_MAXIP CTA_NAT_V4_MAXIP
   CTA_NAT_PROTO,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_NAT_V6_MINIP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_NAT_V6_MAXIP,
   __CTA_NAT_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTA_NAT_MAX (__CTA_NAT_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_protonat {
   CTA_PROTONAT_UNSPEC,
   CTA_PROTONAT_PORT_MIN,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_PROTONAT_PORT_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_PROTONAT_MAX
 };
 #define CTA_PROTONAT_MAX (__CTA_PROTONAT_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_seqadj {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_SEQADJ_UNSPEC,
   CTA_SEQADJ_CORRECTION_POS,
   CTA_SEQADJ_OFFSET_BEFORE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_SEQADJ_OFFSET_AFTER,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_SEQADJ_MAX
 };
 #define CTA_SEQADJ_MAX (__CTA_SEQADJ_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_natseq {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_NAT_SEQ_UNSPEC,
   CTA_NAT_SEQ_CORRECTION_POS,
   CTA_NAT_SEQ_OFFSET_BEFORE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_NAT_SEQ_OFFSET_AFTER,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_NAT_SEQ_MAX
 };
 #define CTA_NAT_SEQ_MAX (__CTA_NAT_SEQ_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_expect {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_EXPECT_UNSPEC,
   CTA_EXPECT_MASTER,
   CTA_EXPECT_TUPLE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_EXPECT_MASK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_EXPECT_TIMEOUT,
   CTA_EXPECT_ID,
   CTA_EXPECT_HELP_NAME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_EXPECT_ZONE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_EXPECT_FLAGS,
   CTA_EXPECT_CLASS,
   CTA_EXPECT_NAT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_EXPECT_FN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_EXPECT_MAX
 };
 #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_expect_nat {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_EXPECT_NAT_UNSPEC,
   CTA_EXPECT_NAT_DIR,
   CTA_EXPECT_NAT_TUPLE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_EXPECT_NAT_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define CTA_EXPECT_NAT_MAX (__CTA_EXPECT_NAT_MAX - 1)
 enum ctattr_help {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_HELP_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_HELP_NAME,
   CTA_HELP_INFO,
   __CTA_HELP_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTA_HELP_MAX (__CTA_HELP_MAX - 1)
 enum ctattr_secctx {
   CTA_SECCTX_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_SECCTX_NAME,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_SECCTX_MAX
 };
 #define CTA_SECCTX_MAX (__CTA_SECCTX_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_stats_cpu {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_UNSPEC,
   CTA_STATS_SEARCHED,
   CTA_STATS_FOUND,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_NEW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_INVALID,
   CTA_STATS_IGNORE,
   CTA_STATS_DELETE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_DELETE_LIST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_INSERT,
   CTA_STATS_INSERT_FAILED,
   CTA_STATS_DROP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_EARLY_DROP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_ERROR,
   CTA_STATS_SEARCH_RESTART,
   __CTA_STATS_MAX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CTA_STATS_MAX (__CTA_STATS_MAX - 1)
 enum ctattr_stats_global {
   CTA_STATS_GLOBAL_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_GLOBAL_ENTRIES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_STATS_GLOBAL_MAX,
 };
 #define CTA_STATS_GLOBAL_MAX (__CTA_STATS_GLOBAL_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ctattr_expect_stats {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_EXP_UNSPEC,
   CTA_STATS_EXP_NEW,
   CTA_STATS_EXP_CREATE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CTA_STATS_EXP_DELETE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __CTA_STATS_EXP_MAX,
 };
 #define CTA_STATS_EXP_MAX (__CTA_STATS_EXP_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/nfnetlink_queue.h b/libc/kernel/uapi/linux/netfilter/nfnetlink_queue.h
index 8a09ef2..81c4681 100644
--- a/libc/kernel/uapi/linux/netfilter/nfnetlink_queue.h
+++ b/libc/kernel/uapi/linux/netfilter/nfnetlink_queue.h
@@ -47,88 +47,99 @@
   __aligned_be64 usec;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+enum nfqnl_vlan_attr {
+  NFQA_VLAN_UNSPEC,
+  NFQA_VLAN_PROTO,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFQA_VLAN_TCI,
+  __NFQA_VLAN_MAX,
+};
+#define NFQA_VLAN_MAX (__NFQA_VLAN_MAX + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nfqnl_attr_type {
   NFQA_UNSPEC,
   NFQA_PACKET_HDR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_VERDICT_HDR,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_MARK,
   NFQA_TIMESTAMP,
   NFQA_IFINDEX_INDEV,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_IFINDEX_OUTDEV,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_IFINDEX_PHYSINDEV,
   NFQA_IFINDEX_PHYSOUTDEV,
   NFQA_HWADDR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_PAYLOAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_CT,
   NFQA_CT_INFO,
   NFQA_CAP_LEN,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_SKB_INFO,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_EXP,
   NFQA_UID,
   NFQA_GID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NFQA_SECCTX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFQA_VLAN,
+  NFQA_L2HDR,
   __NFQA_MAX
 };
-#define NFQA_MAX (__NFQA_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFQA_MAX (__NFQA_MAX - 1)
 struct nfqnl_msg_verdict_hdr {
   __be32 verdict;
   __be32 id;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum nfqnl_msg_config_cmds {
   NFQNL_CFG_CMD_NONE,
   NFQNL_CFG_CMD_BIND,
-  NFQNL_CFG_CMD_UNBIND,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFQNL_CFG_CMD_UNBIND,
   NFQNL_CFG_CMD_PF_BIND,
   NFQNL_CFG_CMD_PF_UNBIND,
 };
-struct nfqnl_msg_config_cmd {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct nfqnl_msg_config_cmd {
   __u8 command;
   __u8 _pad;
   __be16 pf;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum nfqnl_config_mode {
   NFQNL_COPY_NONE,
   NFQNL_COPY_META,
-  NFQNL_COPY_PACKET,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFQNL_COPY_PACKET,
 };
 struct nfqnl_msg_config_params {
   __be32 copy_range;
-  __u8 copy_mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 copy_mode;
 } __attribute__((packed));
 enum nfqnl_attr_config {
   NFQA_CFG_UNSPEC,
-  NFQA_CFG_CMD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFQA_CFG_CMD,
   NFQA_CFG_PARAMS,
   NFQA_CFG_QUEUE_MAXLEN,
   NFQA_CFG_MASK,
-  NFQA_CFG_FLAGS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NFQA_CFG_FLAGS,
   __NFQA_CFG_MAX
 };
 #define NFQA_CFG_MAX (__NFQA_CFG_MAX - 1)
-#define NFQA_CFG_F_FAIL_OPEN (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFQA_CFG_F_FAIL_OPEN (1 << 0)
 #define NFQA_CFG_F_CONNTRACK (1 << 1)
 #define NFQA_CFG_F_GSO (1 << 2)
 #define NFQA_CFG_F_UID_GID (1 << 3)
-#define NFQA_CFG_F_SECCTX (1 << 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFQA_CFG_F_SECCTX (1 << 4)
 #define NFQA_CFG_F_MAX (1 << 5)
 #define NFQA_SKB_CSUMNOTREADY (1 << 0)
 #define NFQA_SKB_GSO (1 << 1)
-#define NFQA_SKB_CSUM_NOTVERIFIED (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NFQA_SKB_CSUM_NOTVERIFIED (1 << 2)
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_HMARK.h b/libc/kernel/uapi/linux/netfilter/xt_HMARK.h
index d3b2ab4..b60935c 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_HMARK.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_HMARK.h
@@ -19,56 +19,57 @@
 #ifndef XT_HMARK_H_
 #define XT_HMARK_H_
 #include <linux/types.h>
-enum {
+#include <linux/netfilter.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   XT_HMARK_SADDR_MASK,
   XT_HMARK_DADDR_MASK,
   XT_HMARK_SPI,
-  XT_HMARK_SPI_MASK,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_HMARK_SPI_MASK,
   XT_HMARK_SPORT,
   XT_HMARK_DPORT,
   XT_HMARK_SPORT_MASK,
-  XT_HMARK_DPORT_MASK,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_HMARK_DPORT_MASK,
   XT_HMARK_PROTO_MASK,
   XT_HMARK_RND,
   XT_HMARK_MODULUS,
-  XT_HMARK_OFFSET,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_HMARK_OFFSET,
   XT_HMARK_CT,
   XT_HMARK_METHOD_L3,
   XT_HMARK_METHOD_L3_4,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define XT_HMARK_FLAG(flag) (1 << flag)
 union hmark_ports {
   struct {
-    __u16 src;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u16 src;
     __u16 dst;
   } p16;
   struct {
-    __be16 src;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __be16 src;
     __be16 dst;
   } b16;
   __u32 v32;
-  __be32 b32;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be32 b32;
 };
 struct xt_hmark_info {
   union nf_inet_addr src_mask;
-  union nf_inet_addr dst_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union nf_inet_addr dst_mask;
   union hmark_ports port_mask;
   union hmark_ports port_set;
   __u32 flags;
-  __u16 proto_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 proto_mask;
   __u32 hashrnd;
   __u32 hmodulus;
   __u32 hoffset;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_RATEEST.h b/libc/kernel/uapi/linux/netfilter/xt_RATEEST.h
index 63dd2b6..211c734 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_RATEEST.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_RATEEST.h
@@ -19,12 +19,13 @@
 #ifndef _XT_RATEEST_TARGET_H
 #define _XT_RATEEST_TARGET_H
 #include <linux/types.h>
-struct xt_rateest_target_info {
+#include <linux/if.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xt_rateest_target_info {
   char name[IFNAMSIZ];
   __s8 interval;
   __u8 ewma_log;
-  struct xt_rateest * est __attribute__((aligned(8)));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xt_rateest * est __attribute__((aligned(8)));
 };
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_SYNPROXY.h b/libc/kernel/uapi/linux/netfilter/xt_SYNPROXY.h
index dbdb74a..a94fb54 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_SYNPROXY.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_SYNPROXY.h
@@ -18,17 +18,18 @@
  ****************************************************************************/
 #ifndef _XT_SYNPROXY_H
 #define _XT_SYNPROXY_H
+#include <linux/types.h>
 #define XT_SYNPROXY_OPT_MSS 0x01
-#define XT_SYNPROXY_OPT_WSCALE 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XT_SYNPROXY_OPT_WSCALE 0x02
 #define XT_SYNPROXY_OPT_SACK_PERM 0x04
 #define XT_SYNPROXY_OPT_TIMESTAMP 0x08
 #define XT_SYNPROXY_OPT_ECN 0x10
-struct xt_synproxy_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xt_synproxy_info {
   __u8 options;
   __u8 wscale;
   __u16 mss;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_TEE.h b/libc/kernel/uapi/linux/netfilter/xt_TEE.h
index ddf6a18..ff564d6 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_TEE.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_TEE.h
@@ -18,11 +18,12 @@
  ****************************************************************************/
 #ifndef _XT_TEE_TARGET_H
 #define _XT_TEE_TARGET_H
+#include <linux/netfilter.h>
 struct xt_tee_tginfo {
-  union nf_inet_addr gw;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union nf_inet_addr gw;
   char oif[16];
   struct xt_tee_priv * priv __attribute__((aligned(8)));
 };
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_TPROXY.h b/libc/kernel/uapi/linux/netfilter/xt_TPROXY.h
index 3807085..226885d 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_TPROXY.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_TPROXY.h
@@ -19,20 +19,21 @@
 #ifndef _XT_TPROXY_H
 #define _XT_TPROXY_H
 #include <linux/types.h>
-struct xt_tproxy_target_info {
+#include <linux/netfilter.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xt_tproxy_target_info {
   __u32 mark_mask;
   __u32 mark_value;
   __be32 laddr;
-  __be16 lport;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be16 lport;
 };
 struct xt_tproxy_target_info_v1 {
   __u32 mark_mask;
-  __u32 mark_value;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 mark_value;
   union nf_inet_addr laddr;
   __be16 lport;
 };
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_cgroup.h b/libc/kernel/uapi/linux/netfilter/xt_cgroup.h
index ce42e9e..3b4309b 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_cgroup.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_cgroup.h
@@ -19,10 +19,22 @@
 #ifndef _UAPI_XT_CGROUP_H
 #define _UAPI_XT_CGROUP_H
 #include <linux/types.h>
-struct xt_cgroup_info {
+#include <linux/limits.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xt_cgroup_info_v0 {
   __u32 id;
   __u32 invert;
 };
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xt_cgroup_info_v1 {
+  __u8 has_path;
+  __u8 has_classid;
+  __u8 invert_path;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 invert_classid;
+  char path[PATH_MAX];
+  __u32 classid;
+  void * priv __attribute__((aligned(8)));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_hashlimit.h b/libc/kernel/uapi/linux/netfilter/xt_hashlimit.h
index 49e1c34..afd8d37 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_hashlimit.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_hashlimit.h
@@ -19,60 +19,61 @@
 #ifndef _UAPI_XT_HASHLIMIT_H
 #define _UAPI_XT_HASHLIMIT_H
 #include <linux/types.h>
-#define XT_HASHLIMIT_SCALE 10000
+#include <linux/if.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XT_HASHLIMIT_SCALE 10000
 #define XT_HASHLIMIT_BYTE_SHIFT 4
 struct xt_hashlimit_htable;
 enum {
-  XT_HASHLIMIT_HASH_DIP = 1 << 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_HASHLIMIT_HASH_DIP = 1 << 0,
   XT_HASHLIMIT_HASH_DPT = 1 << 1,
   XT_HASHLIMIT_HASH_SIP = 1 << 2,
   XT_HASHLIMIT_HASH_SPT = 1 << 3,
-  XT_HASHLIMIT_INVERT = 1 << 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_HASHLIMIT_INVERT = 1 << 4,
   XT_HASHLIMIT_BYTES = 1 << 5,
 };
 struct hashlimit_cfg {
-  __u32 mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 mode;
   __u32 avg;
   __u32 burst;
   __u32 size;
-  __u32 max;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max;
   __u32 gc_interval;
   __u32 expire;
 };
-struct xt_hashlimit_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xt_hashlimit_info {
   char name[IFNAMSIZ];
   struct hashlimit_cfg cfg;
   struct xt_hashlimit_htable * hinfo;
-  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union {
     void * ptr;
     struct xt_hashlimit_info * master;
   } u;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct hashlimit_cfg1 {
   __u32 mode;
   __u32 avg;
-  __u32 burst;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 burst;
   __u32 size;
   __u32 max;
   __u32 gc_interval;
-  __u32 expire;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 expire;
   __u8 srcmask, dstmask;
 };
 struct xt_hashlimit_mtinfo1 {
-  char name[IFNAMSIZ];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char name[IFNAMSIZ];
   struct hashlimit_cfg1 cfg;
   struct xt_hashlimit_htable * hinfo __attribute__((aligned(8)));
 };
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_ipvs.h b/libc/kernel/uapi/linux/netfilter/xt_ipvs.h
index 8a702e0..443b8fc 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_ipvs.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_ipvs.h
@@ -19,30 +19,31 @@
 #ifndef _XT_IPVS_H
 #define _XT_IPVS_H
 #include <linux/types.h>
-enum {
+#include <linux/netfilter.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   XT_IPVS_IPVS_PROPERTY = 1 << 0,
   XT_IPVS_PROTO = 1 << 1,
   XT_IPVS_VADDR = 1 << 2,
-  XT_IPVS_VPORT = 1 << 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_IPVS_VPORT = 1 << 3,
   XT_IPVS_DIR = 1 << 4,
   XT_IPVS_METHOD = 1 << 5,
   XT_IPVS_VPORTCTL = 1 << 6,
-  XT_IPVS_MASK = (1 << 7) - 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_IPVS_MASK = (1 << 7) - 1,
   XT_IPVS_ONCE_MASK = XT_IPVS_MASK & ~XT_IPVS_IPVS_PROPERTY
 };
 struct xt_ipvs_mtinfo {
-  union nf_inet_addr vaddr, vmask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union nf_inet_addr vaddr, vmask;
   __be16 vport;
   __u8 l4proto;
   __u8 fwd_method;
-  __be16 vportctl;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be16 vportctl;
   __u8 invert;
   __u8 bitmask;
 };
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_mac.h b/libc/kernel/uapi/linux/netfilter/xt_mac.h
index 5796906..5d9036e 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_mac.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_mac.h
@@ -18,9 +18,11 @@
  ****************************************************************************/
 #ifndef _XT_MAC_H
 #define _XT_MAC_H
+#include <linux/if_ether.h>
 struct xt_mac_info {
-  unsigned char srcaddr[ETH_ALEN];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char srcaddr[ETH_ALEN];
   int invert;
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/xt_osf.h b/libc/kernel/uapi/linux/netfilter/xt_osf.h
index 9859797..46efa1b 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_osf.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_osf.h
@@ -19,95 +19,97 @@
 #ifndef _XT_OSF_H
 #define _XT_OSF_H
 #include <linux/types.h>
-#define MAXGENRELEN 32
+#include <linux/ip.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/tcp.h>
+#define MAXGENRELEN 32
 #define XT_OSF_GENRE (1 << 0)
 #define XT_OSF_TTL (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XT_OSF_LOG (1 << 2)
 #define XT_OSF_INVERT (1 << 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XT_OSF_LOGLEVEL_ALL 0
 #define XT_OSF_LOGLEVEL_FIRST 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XT_OSF_LOGLEVEL_ALL_KNOWN 2
 #define XT_OSF_TTL_TRUE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define XT_OSF_TTL_LESS 1
 #define XT_OSF_TTL_NOCHECK 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct xt_osf_info {
   char genre[MAXGENRELEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 len;
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 loglevel;
   __u32 ttl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct xt_osf_wc {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 wc;
   __u32 val;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct xt_osf_opt {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 kind, length;
   struct xt_osf_wc wc;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct xt_osf_user_finger {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct xt_osf_wc wss;
   __u8 ttl, df;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 ss, mss;
   __u16 opt_num;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char genre[MAXGENRELEN];
   char version[MAXGENRELEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char subtype[MAXGENRELEN];
   struct xt_osf_opt opt[MAX_IPOPTLEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct xt_osf_nlmsg {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct xt_osf_user_finger f;
   struct iphdr ip;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct tcphdr tcp;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum iana_options {
   OSFOPT_EOL = 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSFOPT_NOP,
   OSFOPT_MSS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSFOPT_WSO,
   OSFOPT_SACKP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSFOPT_SACK,
   OSFOPT_ECHO,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSFOPT_ECHOREPLY,
   OSFOPT_TS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSFOPT_POCP,
   OSFOPT_POSP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSFOPT_EMPTY = 255,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum xt_osf_window_size_options {
   OSF_WSS_PLAIN = 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSF_WSS_MSS,
   OSF_WSS_MTU,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSF_WSS_MODULO,
   OSF_WSS_MAX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum xt_osf_msg_types {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSF_MSG_ADD,
   OSF_MSG_REMOVE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSF_MSG_MAX,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum xt_osf_attr_type {
   OSF_ATTR_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OSF_ATTR_FINGER,
   OSF_ATTR_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter/xt_physdev.h b/libc/kernel/uapi/linux/netfilter/xt_physdev.h
index ccfd67b..2055eea 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_physdev.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_physdev.h
@@ -19,22 +19,23 @@
 #ifndef _UAPI_XT_PHYSDEV_H
 #define _UAPI_XT_PHYSDEV_H
 #include <linux/types.h>
-#define XT_PHYSDEV_OP_IN 0x01
+#include <linux/if.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XT_PHYSDEV_OP_IN 0x01
 #define XT_PHYSDEV_OP_OUT 0x02
 #define XT_PHYSDEV_OP_BRIDGED 0x04
 #define XT_PHYSDEV_OP_ISIN 0x08
-#define XT_PHYSDEV_OP_ISOUT 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XT_PHYSDEV_OP_ISOUT 0x10
 #define XT_PHYSDEV_OP_MASK (0x20 - 1)
 struct xt_physdev_info {
   char physindev[IFNAMSIZ];
-  char in_mask[IFNAMSIZ];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char in_mask[IFNAMSIZ];
   char physoutdev[IFNAMSIZ];
   char out_mask[IFNAMSIZ];
   __u8 invert;
-  __u8 bitmask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bitmask;
 };
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_policy.h b/libc/kernel/uapi/linux/netfilter/xt_policy.h
index 5babfde..5f8b46f 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_policy.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_policy.h
@@ -19,53 +19,56 @@
 #ifndef _XT_POLICY_H
 #define _XT_POLICY_H
 #include <linux/types.h>
-#define XT_POLICY_MAX_ELEM 4
+#include <linux/in.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/in6.h>
+#define XT_POLICY_MAX_ELEM 4
 enum xt_policy_flags {
   XT_POLICY_MATCH_IN = 0x1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   XT_POLICY_MATCH_OUT = 0x2,
   XT_POLICY_MATCH_NONE = 0x4,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   XT_POLICY_MATCH_STRICT = 0x8,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum xt_policy_modes {
   XT_POLICY_MODE_TRANSPORT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   XT_POLICY_MODE_TUNNEL
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct xt_policy_spec {
   __u8 saddr : 1, daddr : 1, proto : 1, mode : 1, spi : 1, reqid : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 union xt_policy_addr {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct in_addr a4;
   struct in6_addr a6;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct xt_policy_elem {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
     struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       union xt_policy_addr saddr;
       union xt_policy_addr smask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       union xt_policy_addr daddr;
       union xt_policy_addr dmask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     };
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 spi;
   __u32 reqid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 proto;
   __u8 mode;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct xt_policy_spec match;
   struct xt_policy_spec invert;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct xt_policy_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct xt_policy_elem pol[XT_POLICY_MAX_ELEM];
   __u16 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 len;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_rateest.h b/libc/kernel/uapi/linux/netfilter/xt_rateest.h
index 0db074d..8ae4e82 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_rateest.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_rateest.h
@@ -19,37 +19,38 @@
 #ifndef _XT_RATEEST_MATCH_H
 #define _XT_RATEEST_MATCH_H
 #include <linux/types.h>
-enum xt_rateest_match_flags {
+#include <linux/if.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum xt_rateest_match_flags {
   XT_RATEEST_MATCH_INVERT = 1 << 0,
   XT_RATEEST_MATCH_ABS = 1 << 1,
   XT_RATEEST_MATCH_REL = 1 << 2,
-  XT_RATEEST_MATCH_DELTA = 1 << 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_RATEEST_MATCH_DELTA = 1 << 3,
   XT_RATEEST_MATCH_BPS = 1 << 4,
   XT_RATEEST_MATCH_PPS = 1 << 5,
 };
-enum xt_rateest_match_mode {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum xt_rateest_match_mode {
   XT_RATEEST_MATCH_NONE,
   XT_RATEEST_MATCH_EQ,
   XT_RATEEST_MATCH_LT,
-  XT_RATEEST_MATCH_GT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_RATEEST_MATCH_GT,
 };
 struct xt_rateest_match_info {
   char name1[IFNAMSIZ];
-  char name2[IFNAMSIZ];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char name2[IFNAMSIZ];
   __u16 flags;
   __u16 mode;
   __u32 bps1;
-  __u32 pps1;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pps1;
   __u32 bps2;
   __u32 pps2;
   struct xt_rateest * est1 __attribute__((aligned(8)));
-  struct xt_rateest * est2 __attribute__((aligned(8)));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xt_rateest * est2 __attribute__((aligned(8)));
 };
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter/xt_recent.h b/libc/kernel/uapi/linux/netfilter/xt_recent.h
index 8294c5b..ae38823 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_recent.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_recent.h
@@ -19,42 +19,43 @@
 #ifndef _LINUX_NETFILTER_XT_RECENT_H
 #define _LINUX_NETFILTER_XT_RECENT_H 1
 #include <linux/types.h>
-enum {
+#include <linux/netfilter.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   XT_RECENT_CHECK = 1 << 0,
   XT_RECENT_SET = 1 << 1,
   XT_RECENT_UPDATE = 1 << 2,
-  XT_RECENT_REMOVE = 1 << 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_RECENT_REMOVE = 1 << 3,
   XT_RECENT_TTL = 1 << 4,
   XT_RECENT_REAP = 1 << 5,
   XT_RECENT_SOURCE = 0,
-  XT_RECENT_DEST = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XT_RECENT_DEST = 1,
   XT_RECENT_NAME_LEN = 200,
 };
 #define XT_RECENT_MODIFIERS (XT_RECENT_TTL | XT_RECENT_REAP)
-#define XT_RECENT_VALID_FLAGS (XT_RECENT_CHECK | XT_RECENT_SET | XT_RECENT_UPDATE | XT_RECENT_REMOVE | XT_RECENT_TTL | XT_RECENT_REAP)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XT_RECENT_VALID_FLAGS (XT_RECENT_CHECK | XT_RECENT_SET | XT_RECENT_UPDATE | XT_RECENT_REMOVE | XT_RECENT_TTL | XT_RECENT_REAP)
 struct xt_recent_mtinfo {
   __u32 seconds;
   __u32 hit_count;
-  __u8 check_set;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 check_set;
   __u8 invert;
   char name[XT_RECENT_NAME_LEN];
   __u8 side;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct xt_recent_mtinfo_v1 {
   __u32 seconds;
   __u32 hit_count;
-  __u8 check_set;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 check_set;
   __u8 invert;
   char name[XT_RECENT_NAME_LEN];
   __u8 side;
-  union nf_inet_addr mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union nf_inet_addr mask;
 };
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter_arp/arp_tables.h b/libc/kernel/uapi/linux/netfilter_arp/arp_tables.h
index 123683d..1a92eeb 100644
--- a/libc/kernel/uapi/linux/netfilter_arp/arp_tables.h
+++ b/libc/kernel/uapi/linux/netfilter_arp/arp_tables.h
@@ -21,110 +21,111 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/if.h>
 #include <linux/netfilter_arp.h>
 #include <linux/netfilter/x_tables.h>
 #define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
-#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
 #define arpt_entry_target xt_entry_target
 #define arpt_standard_target xt_standard_target
 #define arpt_error_target xt_error_target
-#define ARPT_CONTINUE XT_CONTINUE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_CONTINUE XT_CONTINUE
 #define ARPT_RETURN XT_RETURN
 #define arpt_counters_info xt_counters_info
 #define arpt_counters xt_counters
-#define ARPT_STANDARD_TARGET XT_STANDARD_TARGET
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_STANDARD_TARGET XT_STANDARD_TARGET
 #define ARPT_ERROR_TARGET XT_ERROR_TARGET
 #define ARPT_ENTRY_ITERATE(entries,size,fn,args...) XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ##args)
 #define ARPT_DEV_ADDR_LEN_MAX 16
-struct arpt_devaddr_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct arpt_devaddr_info {
   char addr[ARPT_DEV_ADDR_LEN_MAX];
   char mask[ARPT_DEV_ADDR_LEN_MAX];
 };
-struct arpt_arp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct arpt_arp {
   struct in_addr src, tgt;
   struct in_addr smsk, tmsk;
   __u8 arhln, arhln_mask;
-  struct arpt_devaddr_info src_devaddr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct arpt_devaddr_info src_devaddr;
   struct arpt_devaddr_info tgt_devaddr;
   __be16 arpop, arpop_mask;
   __be16 arhrd, arhrd_mask;
-  __be16 arpro, arpro_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be16 arpro, arpro_mask;
   char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
   unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
   __u8 flags;
-  __u16 invflags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 invflags;
 };
 #define ARPT_F_MASK 0x00
 #define ARPT_INV_VIA_IN 0x0001
-#define ARPT_INV_VIA_OUT 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_INV_VIA_OUT 0x0002
 #define ARPT_INV_SRCIP 0x0004
 #define ARPT_INV_TGTIP 0x0008
 #define ARPT_INV_SRCDEVADDR 0x0010
-#define ARPT_INV_TGTDEVADDR 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_INV_TGTDEVADDR 0x0020
 #define ARPT_INV_ARPOP 0x0040
 #define ARPT_INV_ARPHRD 0x0080
 #define ARPT_INV_ARPPRO 0x0100
-#define ARPT_INV_ARPHLN 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_INV_ARPHLN 0x0200
 #define ARPT_INV_MASK 0x03FF
 struct arpt_entry {
   struct arpt_arp arp;
-  __u16 target_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 target_offset;
   __u16 next_offset;
   unsigned int comefrom;
   struct xt_counters counters;
-  unsigned char elems[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char elems[0];
 };
 #define ARPT_BASE_CTL 96
 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL)
-#define ARPT_SO_SET_ADD_COUNTERS (ARPT_BASE_CTL + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_SO_SET_ADD_COUNTERS (ARPT_BASE_CTL + 1)
 #define ARPT_SO_SET_MAX ARPT_SO_SET_ADD_COUNTERS
 #define ARPT_SO_GET_INFO (ARPT_BASE_CTL)
 #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1)
-#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)
 #define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET)
 struct arpt_getinfo {
   char name[XT_TABLE_MAXNAMELEN];
-  unsigned int valid_hooks;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int valid_hooks;
   unsigned int hook_entry[NF_ARP_NUMHOOKS];
   unsigned int underflow[NF_ARP_NUMHOOKS];
   unsigned int num_entries;
-  unsigned int size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int size;
 };
 struct arpt_replace {
   char name[XT_TABLE_MAXNAMELEN];
-  unsigned int valid_hooks;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int valid_hooks;
   unsigned int num_entries;
   unsigned int size;
   unsigned int hook_entry[NF_ARP_NUMHOOKS];
-  unsigned int underflow[NF_ARP_NUMHOOKS];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int underflow[NF_ARP_NUMHOOKS];
   unsigned int num_counters;
   struct xt_counters __user * counters;
   struct arpt_entry entries[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct arpt_get_entries {
   char name[XT_TABLE_MAXNAMELEN];
   unsigned int size;
-  struct arpt_entry entrytable[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct arpt_entry entrytable[0];
 };
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter_bridge.h b/libc/kernel/uapi/linux/netfilter_bridge.h
index d1b9444..f1ae6ef 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge.h
@@ -18,18 +18,19 @@
  ****************************************************************************/
 #ifndef _UAPI__LINUX_BRIDGE_NETFILTER_H
 #define _UAPI__LINUX_BRIDGE_NETFILTER_H
+#include <linux/in.h>
 #include <linux/netfilter.h>
-#include <linux/if_ether.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/if_ether.h>
 #include <linux/if_vlan.h>
 #include <linux/if_pppox.h>
 #define NF_BR_PRE_ROUTING 0
-#define NF_BR_LOCAL_IN 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NF_BR_LOCAL_IN 1
 #define NF_BR_FORWARD 2
 #define NF_BR_LOCAL_OUT 3
 #define NF_BR_POST_ROUTING 4
-#define NF_BR_BROUTING 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NF_BR_BROUTING 5
 #define NF_BR_NUMHOOKS 6
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebt_arp.h b/libc/kernel/uapi/linux/netfilter_bridge/ebt_arp.h
index fb676b6..b997244 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebt_arp.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge/ebt_arp.h
@@ -19,36 +19,37 @@
 #ifndef __LINUX_BRIDGE_EBT_ARP_H
 #define __LINUX_BRIDGE_EBT_ARP_H
 #include <linux/types.h>
-#define EBT_ARP_OPCODE 0x01
+#include <linux/if_ether.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EBT_ARP_OPCODE 0x01
 #define EBT_ARP_HTYPE 0x02
 #define EBT_ARP_PTYPE 0x04
 #define EBT_ARP_SRC_IP 0x08
-#define EBT_ARP_DST_IP 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EBT_ARP_DST_IP 0x10
 #define EBT_ARP_SRC_MAC 0x20
 #define EBT_ARP_DST_MAC 0x40
 #define EBT_ARP_GRAT 0x80
-#define EBT_ARP_MASK (EBT_ARP_OPCODE | EBT_ARP_HTYPE | EBT_ARP_PTYPE | EBT_ARP_SRC_IP | EBT_ARP_DST_IP | EBT_ARP_SRC_MAC | EBT_ARP_DST_MAC | EBT_ARP_GRAT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EBT_ARP_MASK (EBT_ARP_OPCODE | EBT_ARP_HTYPE | EBT_ARP_PTYPE | EBT_ARP_SRC_IP | EBT_ARP_DST_IP | EBT_ARP_SRC_MAC | EBT_ARP_DST_MAC | EBT_ARP_GRAT)
 #define EBT_ARP_MATCH "arp"
 struct ebt_arp_info {
   __be16 htype;
-  __be16 ptype;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be16 ptype;
   __be16 opcode;
   __be32 saddr;
   __be32 smsk;
-  __be32 daddr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be32 daddr;
   __be32 dmsk;
   unsigned char smaddr[ETH_ALEN];
   unsigned char smmsk[ETH_ALEN];
-  unsigned char dmaddr[ETH_ALEN];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char dmaddr[ETH_ALEN];
   unsigned char dmmsk[ETH_ALEN];
   __u8 bitmask;
   __u8 invflags;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebt_arpreply.h b/libc/kernel/uapi/linux/netfilter_bridge/ebt_arpreply.h
index e0cd503..4d37842 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebt_arpreply.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge/ebt_arpreply.h
@@ -18,11 +18,12 @@
  ****************************************************************************/
 #ifndef __LINUX_BRIDGE_EBT_ARPREPLY_H
 #define __LINUX_BRIDGE_EBT_ARPREPLY_H
+#include <linux/if_ether.h>
 struct ebt_arpreply_info {
-  unsigned char mac[ETH_ALEN];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char mac[ETH_ALEN];
   int target;
 };
 #define EBT_ARPREPLY_TARGET "arpreply"
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebt_ip6.h b/libc/kernel/uapi/linux/netfilter_bridge/ebt_ip6.h
index ac06046..d16f048 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebt_ip6.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge/ebt_ip6.h
@@ -19,38 +19,40 @@
 #ifndef __LINUX_BRIDGE_EBT_IP6_H
 #define __LINUX_BRIDGE_EBT_IP6_H
 #include <linux/types.h>
-#define EBT_IP6_SOURCE 0x01
+#include <linux/in6.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EBT_IP6_SOURCE 0x01
 #define EBT_IP6_DEST 0x02
 #define EBT_IP6_TCLASS 0x04
 #define EBT_IP6_PROTO 0x08
-#define EBT_IP6_SPORT 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EBT_IP6_SPORT 0x10
 #define EBT_IP6_DPORT 0x20
 #define EBT_IP6_ICMP6 0x40
 #define EBT_IP6_MASK (EBT_IP6_SOURCE | EBT_IP6_DEST | EBT_IP6_TCLASS | EBT_IP6_PROTO | EBT_IP6_SPORT | EBT_IP6_DPORT | EBT_IP6_ICMP6)
-#define EBT_IP6_MATCH "ip6"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EBT_IP6_MATCH "ip6"
 struct ebt_ip6_info {
   struct in6_addr saddr;
   struct in6_addr daddr;
-  struct in6_addr smsk;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct in6_addr smsk;
   struct in6_addr dmsk;
   __u8 tclass;
   __u8 protocol;
-  __u8 bitmask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bitmask;
   __u8 invflags;
   union {
     __u16 sport[2];
-    __u8 icmpv6_type[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u8 icmpv6_type[2];
   };
   union {
     __u16 dport[2];
-    __u8 icmpv6_code[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u8 icmpv6_code[2];
   };
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebt_nat.h b/libc/kernel/uapi/linux/netfilter_bridge/ebt_nat.h
index eb341c2..bd7d501 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebt_nat.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge/ebt_nat.h
@@ -18,13 +18,14 @@
  ****************************************************************************/
 #ifndef __LINUX_BRIDGE_EBT_NAT_H
 #define __LINUX_BRIDGE_EBT_NAT_H
+#include <linux/if_ether.h>
 #define NAT_ARP_BIT (0x00000010)
-struct ebt_nat_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ebt_nat_info {
   unsigned char mac[ETH_ALEN];
   int target;
 };
-#define EBT_SNAT_TARGET "snat"
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EBT_SNAT_TARGET "snat"
 #define EBT_DNAT_TARGET "dnat"
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebt_ulog.h b/libc/kernel/uapi/linux/netfilter_bridge/ebt_ulog.h
deleted file mode 100644
index 029d6b1..0000000
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebt_ulog.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _EBT_ULOG_H
-#define _EBT_ULOG_H
-#include <linux/types.h>
-#define EBT_ULOG_DEFAULT_NLGROUP 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EBT_ULOG_DEFAULT_QTHRESHOLD 1
-#define EBT_ULOG_MAXNLGROUPS 32
-#define EBT_ULOG_PREFIX_LEN 32
-#define EBT_ULOG_MAX_QLEN 50
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define EBT_ULOG_WATCHER "ulog"
-#define EBT_ULOG_VERSION 1
-struct ebt_ulog_info {
-  __u32 nlgroup;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int cprange;
-  unsigned int qthreshold;
-  char prefix[EBT_ULOG_PREFIX_LEN];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef struct ebt_ulog_packet_msg {
-  int version;
-  char indev[IFNAMSIZ];
-  char outdev[IFNAMSIZ];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  char physindev[IFNAMSIZ];
-  char physoutdev[IFNAMSIZ];
-  char prefix[EBT_ULOG_PREFIX_LEN];
-  struct timeval stamp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned long mark;
-  unsigned int hook;
-  size_t data_len;
-  unsigned char data[0] __attribute__((aligned(__alignof__(struct ebt_ulog_info))));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-} ebt_ulog_packet_msg_t;
-#endif
diff --git a/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h b/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
index aab8490..60d5e0f 100644
--- a/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
+++ b/libc/kernel/uapi/linux/netfilter_bridge/ebtables.h
@@ -18,155 +18,158 @@
  ****************************************************************************/
 #ifndef _UAPI__LINUX_BRIDGE_EFF_H
 #define _UAPI__LINUX_BRIDGE_EFF_H
+#include <linux/types.h>
+#include <linux/if.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/netfilter_bridge.h>
 #define EBT_TABLE_MAXNAMELEN 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN
 #define EBT_FUNCTION_MAXNAMELEN EBT_TABLE_MAXNAMELEN
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_ACCEPT - 1
 #define EBT_DROP - 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_CONTINUE - 3
 #define EBT_RETURN - 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NUM_STANDARD_TARGETS 4
 #define EBT_VERDICT_BITS 0x0000000F
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct xt_match;
 struct xt_target;
-struct ebt_counter {
-  uint64_t pcnt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint64_t bcnt;
+struct ebt_counter {
+  __u64 pcnt;
+  __u64 bcnt;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ebt_replace {
   char name[EBT_TABLE_MAXNAMELEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int valid_hooks;
   unsigned int nentries;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int entries_size;
   struct ebt_entries __user * hook_entry[NF_BR_NUMHOOKS];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int num_counters;
   struct ebt_counter __user * counters;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char __user * entries;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ebt_replace_kernel {
   char name[EBT_TABLE_MAXNAMELEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int valid_hooks;
   unsigned int nentries;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int entries_size;
   struct ebt_entries * hook_entry[NF_BR_NUMHOOKS];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int num_counters;
   struct ebt_counter * counters;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char * entries;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ebt_entries {
   unsigned int distinguisher;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char name[EBT_CHAIN_MAXNAMELEN];
   unsigned int counter_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int policy;
   unsigned int nentries;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char data[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_ENTRY_OR_ENTRIES 0x01
 #define EBT_NOPROTO 0x02
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_802_3 0x04
 #define EBT_SOURCEMAC 0x08
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_DESTMAC 0x10
 #define EBT_F_MASK (EBT_NOPROTO | EBT_802_3 | EBT_SOURCEMAC | EBT_DESTMAC | EBT_ENTRY_OR_ENTRIES)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_IPROTO 0x01
 #define EBT_IIN 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_IOUT 0x04
 #define EBT_ISOURCE 0x8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_IDEST 0x10
 #define EBT_ILOGICALIN 0x20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_ILOGICALOUT 0x40
 #define EBT_INV_MASK (EBT_IPROTO | EBT_IIN | EBT_IOUT | EBT_ILOGICALIN | EBT_ILOGICALOUT | EBT_ISOURCE | EBT_IDEST)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ebt_entry_match {
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     char name[EBT_FUNCTION_MAXNAMELEN];
     struct xt_match * match;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } u;
   unsigned int match_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char data[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ebt_entry_watcher {
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     char name[EBT_FUNCTION_MAXNAMELEN];
     struct xt_target * watcher;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } u;
   unsigned int watcher_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char data[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ebt_entry_target {
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     char name[EBT_FUNCTION_MAXNAMELEN];
     struct xt_target * target;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } u;
   unsigned int target_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char data[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_STANDARD_TARGET "standard"
 struct ebt_standard_target {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct ebt_entry_target target;
   int verdict;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ebt_entry {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int bitmask;
   unsigned int invflags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be16 ethproto;
   char in[IFNAMSIZ];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char logical_in[IFNAMSIZ];
   char out[IFNAMSIZ];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char logical_out[IFNAMSIZ];
   unsigned char sourcemac[ETH_ALEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char sourcemsk[ETH_ALEN];
   unsigned char destmac[ETH_ALEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char destmsk[ETH_ALEN];
   unsigned int watchers_offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int target_offset;
   unsigned int next_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char elems[0] __attribute__((aligned(__alignof__(struct ebt_replace))));
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_BASE_CTL 128
 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_SO_SET_COUNTERS (EBT_SO_SET_ENTRIES + 1)
 #define EBT_SO_SET_MAX (EBT_SO_SET_COUNTERS + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_SO_GET_INFO (EBT_BASE_CTL)
 #define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO + 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES + 1)
 #define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_SO_GET_MAX (EBT_SO_GET_INIT_ENTRIES + 1)
 #define EBT_MATCH_ITERATE(e,fn,args...) \
 ({ unsigned int __i; int __ret = 0; struct ebt_entry_match * __match; for(__i = sizeof(struct ebt_entry); __i < (e)->watchers_offset; __i += __match->match_size + sizeof(struct ebt_entry_match)) { __match = (void *) (e) + __i; __ret = fn(__match, ##args); if(__ret != 0) break; } if(__ret == 0) { if(__i != (e)->watchers_offset) __ret = - EINVAL; } __ret; \
 })
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBT_WATCHER_ITERATE(e,fn,args...) \
 ({ unsigned int __i; int __ret = 0; struct ebt_entry_watcher * __watcher; for(__i = e->watchers_offset; __i < (e)->target_offset; __i += __watcher->watcher_size + sizeof(struct ebt_entry_watcher)) { __watcher = (void *) (e) + __i; __ret = fn(__watcher, ##args); if(__ret != 0) break; } if(__ret == 0) { if(__i != (e)->target_offset) __ret = - EINVAL; } __ret; \
 })
 #define EBT_ENTRY_ITERATE(entries,size,fn,args...) \
 ({ unsigned int __i; int __ret = 0; struct ebt_entry * __entry; for(__i = 0; __i < (size);) { __entry = (void *) (entries) + __i; __ret = fn(__entry, ##args); if(__ret != 0) break; if(__entry->bitmask != 0) __i += __entry->next_offset; else __i += sizeof(struct ebt_entries); } if(__ret == 0) { if(__i != (size)) __ret = - EINVAL; } __ret; \
 })
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter_ipv4/ip_tables.h b/libc/kernel/uapi/linux/netfilter_ipv4/ip_tables.h
index 04896c6..2b867f7 100644
--- a/libc/kernel/uapi/linux/netfilter_ipv4/ip_tables.h
+++ b/libc/kernel/uapi/linux/netfilter_ipv4/ip_tables.h
@@ -21,131 +21,133 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/if.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter/x_tables.h>
 #define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
-#define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
 #define ipt_match xt_match
 #define ipt_target xt_target
 #define ipt_table xt_table
-#define ipt_get_revision xt_get_revision
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ipt_get_revision xt_get_revision
 #define ipt_entry_match xt_entry_match
 #define ipt_entry_target xt_entry_target
 #define ipt_standard_target xt_standard_target
-#define ipt_error_target xt_error_target
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ipt_error_target xt_error_target
 #define ipt_counters xt_counters
 #define IPT_CONTINUE XT_CONTINUE
 #define IPT_RETURN XT_RETURN
-#include <linux/netfilter/xt_tcpudp.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/netfilter/xt_tcpudp.h>
 #define ipt_udp xt_udp
 #define ipt_tcp xt_tcp
 #define IPT_TCP_INV_SRCPT XT_TCP_INV_SRCPT
-#define IPT_TCP_INV_DSTPT XT_TCP_INV_DSTPT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_TCP_INV_DSTPT XT_TCP_INV_DSTPT
 #define IPT_TCP_INV_FLAGS XT_TCP_INV_FLAGS
 #define IPT_TCP_INV_OPTION XT_TCP_INV_OPTION
 #define IPT_TCP_INV_MASK XT_TCP_INV_MASK
-#define IPT_UDP_INV_SRCPT XT_UDP_INV_SRCPT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_UDP_INV_SRCPT XT_UDP_INV_SRCPT
 #define IPT_UDP_INV_DSTPT XT_UDP_INV_DSTPT
 #define IPT_UDP_INV_MASK XT_UDP_INV_MASK
 #define ipt_counters_info xt_counters_info
-#define IPT_STANDARD_TARGET XT_STANDARD_TARGET
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_STANDARD_TARGET XT_STANDARD_TARGET
 #define IPT_ERROR_TARGET XT_ERROR_TARGET
 #define IPT_MATCH_ITERATE(e,fn,args...) XT_MATCH_ITERATE(struct ipt_entry, e, fn, ##args)
 #define IPT_ENTRY_ITERATE(entries,size,fn,args...) XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ##args)
-struct ipt_ip {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ipt_ip {
   struct in_addr src, dst;
   struct in_addr smsk, dmsk;
   char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
-  unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
   __u16 proto;
   __u8 flags;
   __u8 invflags;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IPT_F_FRAG 0x01
 #define IPT_F_GOTO 0x02
 #define IPT_F_MASK 0x03
-#define IPT_INV_VIA_IN 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_INV_VIA_IN 0x01
 #define IPT_INV_VIA_OUT 0x02
 #define IPT_INV_TOS 0x04
 #define IPT_INV_SRCIP 0x08
-#define IPT_INV_DSTIP 0x10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_INV_DSTIP 0x10
 #define IPT_INV_FRAG 0x20
 #define IPT_INV_PROTO XT_INV_PROTO
 #define IPT_INV_MASK 0x7F
-struct ipt_entry {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ipt_entry {
   struct ipt_ip ip;
   unsigned int nfcache;
   __u16 target_offset;
-  __u16 next_offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 next_offset;
   unsigned int comefrom;
   struct xt_counters counters;
   unsigned char elems[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IPT_BASE_CTL 64
 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL)
 #define IPT_SO_SET_ADD_COUNTERS (IPT_BASE_CTL + 1)
-#define IPT_SO_SET_MAX IPT_SO_SET_ADD_COUNTERS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_SO_SET_MAX IPT_SO_SET_ADD_COUNTERS
 #define IPT_SO_GET_INFO (IPT_BASE_CTL)
 #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1)
 #define IPT_SO_GET_REVISION_MATCH (IPT_BASE_CTL + 2)
-#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
 #define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET
 struct ipt_icmp {
   __u8 type;
-  __u8 code[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 code[2];
   __u8 invflags;
 };
 #define IPT_ICMP_INV 0x01
-struct ipt_getinfo {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ipt_getinfo {
   char name[XT_TABLE_MAXNAMELEN];
   unsigned int valid_hooks;
   unsigned int hook_entry[NF_INET_NUMHOOKS];
-  unsigned int underflow[NF_INET_NUMHOOKS];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int underflow[NF_INET_NUMHOOKS];
   unsigned int num_entries;
   unsigned int size;
 };
-struct ipt_replace {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ipt_replace {
   char name[XT_TABLE_MAXNAMELEN];
   unsigned int valid_hooks;
   unsigned int num_entries;
-  unsigned int size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int size;
   unsigned int hook_entry[NF_INET_NUMHOOKS];
   unsigned int underflow[NF_INET_NUMHOOKS];
   unsigned int num_counters;
-  struct xt_counters __user * counters;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xt_counters __user * counters;
   struct ipt_entry entries[0];
 };
 struct ipt_get_entries {
-  char name[XT_TABLE_MAXNAMELEN];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char name[XT_TABLE_MAXNAMELEN];
   unsigned int size;
   struct ipt_entry entrytable[0];
 };
-static __inline__ struct xt_entry_target * ipt_get_target(struct ipt_entry * e) {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+static __inline__ struct xt_entry_target * ipt_get_target(struct ipt_entry * e) {
   return(void *) e + e->target_offset;
 }
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/netfilter_ipv6/ip6_tables.h b/libc/kernel/uapi/linux/netfilter_ipv6/ip6_tables.h
index 37884b0..66269cf 100644
--- a/libc/kernel/uapi/linux/netfilter_ipv6/ip6_tables.h
+++ b/libc/kernel/uapi/linux/netfilter_ipv6/ip6_tables.h
@@ -21,155 +21,156 @@
 #include <linux/types.h>
 #include <linux/compiler.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/if.h>
 #include <linux/netfilter_ipv6.h>
 #include <linux/netfilter/x_tables.h>
 #define IP6T_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
-#define IP6T_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
 #define ip6t_match xt_match
 #define ip6t_target xt_target
 #define ip6t_table xt_table
-#define ip6t_get_revision xt_get_revision
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ip6t_get_revision xt_get_revision
 #define ip6t_entry_match xt_entry_match
 #define ip6t_entry_target xt_entry_target
 #define ip6t_standard_target xt_standard_target
-#define ip6t_error_target xt_error_target
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ip6t_error_target xt_error_target
 #define ip6t_counters xt_counters
 #define IP6T_CONTINUE XT_CONTINUE
 #define IP6T_RETURN XT_RETURN
-#include <linux/netfilter/xt_tcpudp.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/netfilter/xt_tcpudp.h>
 #define ip6t_tcp xt_tcp
 #define ip6t_udp xt_udp
 #define IP6T_TCP_INV_SRCPT XT_TCP_INV_SRCPT
-#define IP6T_TCP_INV_DSTPT XT_TCP_INV_DSTPT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_TCP_INV_DSTPT XT_TCP_INV_DSTPT
 #define IP6T_TCP_INV_FLAGS XT_TCP_INV_FLAGS
 #define IP6T_TCP_INV_OPTION XT_TCP_INV_OPTION
 #define IP6T_TCP_INV_MASK XT_TCP_INV_MASK
-#define IP6T_UDP_INV_SRCPT XT_UDP_INV_SRCPT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_UDP_INV_SRCPT XT_UDP_INV_SRCPT
 #define IP6T_UDP_INV_DSTPT XT_UDP_INV_DSTPT
 #define IP6T_UDP_INV_MASK XT_UDP_INV_MASK
 #define ip6t_counters_info xt_counters_info
-#define IP6T_STANDARD_TARGET XT_STANDARD_TARGET
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_STANDARD_TARGET XT_STANDARD_TARGET
 #define IP6T_ERROR_TARGET XT_ERROR_TARGET
 #define IP6T_MATCH_ITERATE(e,fn,args...) XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ##args)
 #define IP6T_ENTRY_ITERATE(entries,size,fn,args...) XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ##args)
-struct ip6t_ip6 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ip6t_ip6 {
   struct in6_addr src, dst;
   struct in6_addr smsk, dmsk;
   char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
-  unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
   __u16 proto;
   __u8 tos;
   __u8 flags;
-  __u8 invflags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 invflags;
 };
 #define IP6T_F_PROTO 0x01
 #define IP6T_F_TOS 0x02
-#define IP6T_F_GOTO 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_F_GOTO 0x04
 #define IP6T_F_MASK 0x07
 #define IP6T_INV_VIA_IN 0x01
 #define IP6T_INV_VIA_OUT 0x02
-#define IP6T_INV_TOS 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_INV_TOS 0x04
 #define IP6T_INV_SRCIP 0x08
 #define IP6T_INV_DSTIP 0x10
 #define IP6T_INV_FRAG 0x20
-#define IP6T_INV_PROTO XT_INV_PROTO
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_INV_PROTO XT_INV_PROTO
 #define IP6T_INV_MASK 0x7F
 struct ip6t_entry {
   struct ip6t_ip6 ipv6;
-  unsigned int nfcache;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int nfcache;
   __u16 target_offset;
   __u16 next_offset;
   unsigned int comefrom;
-  struct xt_counters counters;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xt_counters counters;
   unsigned char elems[0];
 };
 struct ip6t_standard {
-  struct ip6t_entry entry;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ip6t_entry entry;
   struct xt_standard_target target;
 };
 struct ip6t_error {
-  struct ip6t_entry entry;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ip6t_entry entry;
   struct xt_error_target target;
 };
 #define IP6T_ENTRY_INIT(__size) \
 {.target_offset = sizeof(struct ip6t_entry),.next_offset = (__size), \
 }
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IP6T_STANDARD_INIT(__verdict) \
 {.entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)),.target = XT_TARGET_INIT(XT_STANDARD_TARGET, sizeof(struct xt_standard_target)),.target.verdict = - (__verdict) - 1, \
 }
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define IP6T_ERROR_INIT \
 {.entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)),.target = XT_TARGET_INIT(XT_ERROR_TARGET, sizeof(struct xt_error_target)),.target.errorname = "ERROR", \
 }
 #define IP6T_BASE_CTL 64
 #define IP6T_SO_SET_REPLACE (IP6T_BASE_CTL)
-#define IP6T_SO_SET_ADD_COUNTERS (IP6T_BASE_CTL + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_SO_SET_ADD_COUNTERS (IP6T_BASE_CTL + 1)
 #define IP6T_SO_SET_MAX IP6T_SO_SET_ADD_COUNTERS
 #define IP6T_SO_GET_INFO (IP6T_BASE_CTL)
 #define IP6T_SO_GET_ENTRIES (IP6T_BASE_CTL + 1)
-#define IP6T_SO_GET_REVISION_MATCH (IP6T_BASE_CTL + 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_SO_GET_REVISION_MATCH (IP6T_BASE_CTL + 4)
 #define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5)
 #define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET
 #define IP6T_SO_ORIGINAL_DST 80
-struct ip6t_icmp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ip6t_icmp {
   __u8 type;
   __u8 code[2];
   __u8 invflags;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IP6T_ICMP_INV 0x01
 struct ip6t_getinfo {
   char name[XT_TABLE_MAXNAMELEN];
-  unsigned int valid_hooks;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int valid_hooks;
   unsigned int hook_entry[NF_INET_NUMHOOKS];
   unsigned int underflow[NF_INET_NUMHOOKS];
   unsigned int num_entries;
-  unsigned int size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int size;
 };
 struct ip6t_replace {
   char name[XT_TABLE_MAXNAMELEN];
-  unsigned int valid_hooks;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int valid_hooks;
   unsigned int num_entries;
   unsigned int size;
   unsigned int hook_entry[NF_INET_NUMHOOKS];
-  unsigned int underflow[NF_INET_NUMHOOKS];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int underflow[NF_INET_NUMHOOKS];
   unsigned int num_counters;
   struct xt_counters __user * counters;
   struct ip6t_entry entries[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ip6t_get_entries {
   char name[XT_TABLE_MAXNAMELEN];
   unsigned int size;
-  struct ip6t_entry entrytable[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ip6t_entry entrytable[0];
 };
 static __inline__ struct xt_entry_target * ip6t_get_target(struct ip6t_entry * e) {
   return(void *) e + e->target_offset;
-}
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+}
 #endif
diff --git a/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_rt.h b/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_rt.h
index 036b26a..08f14aa 100644
--- a/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_rt.h
+++ b/libc/kernel/uapi/linux/netfilter_ipv6/ip6t_rt.h
@@ -19,31 +19,32 @@
 #ifndef _IP6T_RT_H
 #define _IP6T_RT_H
 #include <linux/types.h>
-#define IP6T_RT_HOPS 16
+#include <linux/in6.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_RT_HOPS 16
 struct ip6t_rt {
   __u32 rt_type;
   __u32 segsleft[2];
-  __u32 hdrlen;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 hdrlen;
   __u8 flags;
   __u8 invflags;
   struct in6_addr addrs[IP6T_RT_HOPS];
-  __u8 addrnr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 addrnr;
 };
 #define IP6T_RT_TYP 0x01
 #define IP6T_RT_SGS 0x02
-#define IP6T_RT_LEN 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_RT_LEN 0x04
 #define IP6T_RT_RES 0x08
 #define IP6T_RT_FST_MASK 0x30
 #define IP6T_RT_FST 0x10
-#define IP6T_RT_FST_NSTRICT 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_RT_FST_NSTRICT 0x20
 #define IP6T_RT_INV_TYP 0x01
 #define IP6T_RT_INV_SGS 0x02
 #define IP6T_RT_INV_LEN 0x04
-#define IP6T_RT_INV_MASK 0x07
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IP6T_RT_INV_MASK 0x07
 #endif
diff --git a/libc/kernel/uapi/linux/nl80211.h b/libc/kernel/uapi/linux/nl80211.h
index 5453971..92abde1 100644
--- a/libc/kernel/uapi/linux/nl80211.h
+++ b/libc/kernel/uapi/linux/nl80211.h
@@ -178,476 +178,491 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH,
   NL80211_CMD_WIPHY_REG_CHANGE,
+  NL80211_CMD_ABORT_SCAN,
   __NL80211_CMD_AFTER_LAST,
-  NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
 };
 #define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
 #define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE
-#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE
 #define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE
 #define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE
 #define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE
-#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
 #define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
 #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
 #define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG
-#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
 #define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE
 enum nl80211_attrs {
   NL80211_ATTR_UNSPEC,
-  NL80211_ATTR_WIPHY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY,
   NL80211_ATTR_WIPHY_NAME,
   NL80211_ATTR_IFINDEX,
   NL80211_ATTR_IFNAME,
-  NL80211_ATTR_IFTYPE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_IFTYPE,
   NL80211_ATTR_MAC,
   NL80211_ATTR_KEY_DATA,
   NL80211_ATTR_KEY_IDX,
-  NL80211_ATTR_KEY_CIPHER,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_KEY_CIPHER,
   NL80211_ATTR_KEY_SEQ,
   NL80211_ATTR_KEY_DEFAULT,
   NL80211_ATTR_BEACON_INTERVAL,
-  NL80211_ATTR_DTIM_PERIOD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_DTIM_PERIOD,
   NL80211_ATTR_BEACON_HEAD,
   NL80211_ATTR_BEACON_TAIL,
   NL80211_ATTR_STA_AID,
-  NL80211_ATTR_STA_FLAGS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_STA_FLAGS,
   NL80211_ATTR_STA_LISTEN_INTERVAL,
   NL80211_ATTR_STA_SUPPORTED_RATES,
   NL80211_ATTR_STA_VLAN,
-  NL80211_ATTR_STA_INFO,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_STA_INFO,
   NL80211_ATTR_WIPHY_BANDS,
   NL80211_ATTR_MNTR_FLAGS,
   NL80211_ATTR_MESH_ID,
-  NL80211_ATTR_STA_PLINK_ACTION,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_STA_PLINK_ACTION,
   NL80211_ATTR_MPATH_NEXT_HOP,
   NL80211_ATTR_MPATH_INFO,
   NL80211_ATTR_BSS_CTS_PROT,
-  NL80211_ATTR_BSS_SHORT_PREAMBLE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_BSS_SHORT_PREAMBLE,
   NL80211_ATTR_BSS_SHORT_SLOT_TIME,
   NL80211_ATTR_HT_CAPABILITY,
   NL80211_ATTR_SUPPORTED_IFTYPES,
-  NL80211_ATTR_REG_ALPHA2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_REG_ALPHA2,
   NL80211_ATTR_REG_RULES,
   NL80211_ATTR_MESH_CONFIG,
   NL80211_ATTR_BSS_BASIC_RATES,
-  NL80211_ATTR_WIPHY_TXQ_PARAMS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_TXQ_PARAMS,
   NL80211_ATTR_WIPHY_FREQ,
   NL80211_ATTR_WIPHY_CHANNEL_TYPE,
   NL80211_ATTR_KEY_DEFAULT_MGMT,
-  NL80211_ATTR_MGMT_SUBTYPE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_MGMT_SUBTYPE,
   NL80211_ATTR_IE,
   NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
   NL80211_ATTR_SCAN_FREQUENCIES,
-  NL80211_ATTR_SCAN_SSIDS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_SCAN_SSIDS,
   NL80211_ATTR_GENERATION,
   NL80211_ATTR_BSS,
   NL80211_ATTR_REG_INITIATOR,
-  NL80211_ATTR_REG_TYPE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_REG_TYPE,
   NL80211_ATTR_SUPPORTED_COMMANDS,
   NL80211_ATTR_FRAME,
   NL80211_ATTR_SSID,
-  NL80211_ATTR_AUTH_TYPE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_AUTH_TYPE,
   NL80211_ATTR_REASON_CODE,
   NL80211_ATTR_KEY_TYPE,
   NL80211_ATTR_MAX_SCAN_IE_LEN,
-  NL80211_ATTR_CIPHER_SUITES,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_CIPHER_SUITES,
   NL80211_ATTR_FREQ_BEFORE,
   NL80211_ATTR_FREQ_AFTER,
   NL80211_ATTR_FREQ_FIXED,
-  NL80211_ATTR_WIPHY_RETRY_SHORT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_RETRY_SHORT,
   NL80211_ATTR_WIPHY_RETRY_LONG,
   NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
   NL80211_ATTR_WIPHY_RTS_THRESHOLD,
-  NL80211_ATTR_TIMED_OUT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_TIMED_OUT,
   NL80211_ATTR_USE_MFP,
   NL80211_ATTR_STA_FLAGS2,
   NL80211_ATTR_CONTROL_PORT,
-  NL80211_ATTR_TESTDATA,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_TESTDATA,
   NL80211_ATTR_PRIVACY,
   NL80211_ATTR_DISCONNECTED_BY_AP,
   NL80211_ATTR_STATUS_CODE,
-  NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
   NL80211_ATTR_CIPHER_SUITE_GROUP,
   NL80211_ATTR_WPA_VERSIONS,
   NL80211_ATTR_AKM_SUITES,
-  NL80211_ATTR_REQ_IE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_REQ_IE,
   NL80211_ATTR_RESP_IE,
   NL80211_ATTR_PREV_BSSID,
   NL80211_ATTR_KEY,
-  NL80211_ATTR_KEYS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_KEYS,
   NL80211_ATTR_PID,
   NL80211_ATTR_4ADDR,
   NL80211_ATTR_SURVEY_INFO,
-  NL80211_ATTR_PMKID,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_PMKID,
   NL80211_ATTR_MAX_NUM_PMKIDS,
   NL80211_ATTR_DURATION,
   NL80211_ATTR_COOKIE,
-  NL80211_ATTR_WIPHY_COVERAGE_CLASS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_COVERAGE_CLASS,
   NL80211_ATTR_TX_RATES,
   NL80211_ATTR_FRAME_MATCH,
   NL80211_ATTR_ACK,
-  NL80211_ATTR_PS_STATE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_PS_STATE,
   NL80211_ATTR_CQM,
   NL80211_ATTR_LOCAL_STATE_CHANGE,
   NL80211_ATTR_AP_ISOLATE,
-  NL80211_ATTR_WIPHY_TX_POWER_SETTING,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_TX_POWER_SETTING,
   NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
   NL80211_ATTR_TX_FRAME_TYPES,
   NL80211_ATTR_RX_FRAME_TYPES,
-  NL80211_ATTR_FRAME_TYPE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_FRAME_TYPE,
   NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
   NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
   NL80211_ATTR_SUPPORT_IBSS_RSN,
-  NL80211_ATTR_WIPHY_ANTENNA_TX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_ANTENNA_TX,
   NL80211_ATTR_WIPHY_ANTENNA_RX,
   NL80211_ATTR_MCAST_RATE,
   NL80211_ATTR_OFFCHANNEL_TX_OK,
-  NL80211_ATTR_BSS_HT_OPMODE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_BSS_HT_OPMODE,
   NL80211_ATTR_KEY_DEFAULT_TYPES,
   NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
   NL80211_ATTR_MESH_SETUP,
-  NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
   NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
   NL80211_ATTR_SUPPORT_MESH_AUTH,
   NL80211_ATTR_STA_PLINK_STATE,
-  NL80211_ATTR_WOWLAN_TRIGGERS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WOWLAN_TRIGGERS,
   NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
   NL80211_ATTR_SCHED_SCAN_INTERVAL,
   NL80211_ATTR_INTERFACE_COMBINATIONS,
-  NL80211_ATTR_SOFTWARE_IFTYPES,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_SOFTWARE_IFTYPES,
   NL80211_ATTR_REKEY_DATA,
   NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
   NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
-  NL80211_ATTR_SCAN_SUPP_RATES,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_SCAN_SUPP_RATES,
   NL80211_ATTR_HIDDEN_SSID,
   NL80211_ATTR_IE_PROBE_RESP,
   NL80211_ATTR_IE_ASSOC_RESP,
-  NL80211_ATTR_STA_WME,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_STA_WME,
   NL80211_ATTR_SUPPORT_AP_UAPSD,
   NL80211_ATTR_ROAM_SUPPORT,
   NL80211_ATTR_SCHED_SCAN_MATCH,
-  NL80211_ATTR_MAX_MATCH_SETS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_MAX_MATCH_SETS,
   NL80211_ATTR_PMKSA_CANDIDATE,
   NL80211_ATTR_TX_NO_CCK_RATE,
   NL80211_ATTR_TDLS_ACTION,
-  NL80211_ATTR_TDLS_DIALOG_TOKEN,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_TDLS_DIALOG_TOKEN,
   NL80211_ATTR_TDLS_OPERATION,
   NL80211_ATTR_TDLS_SUPPORT,
   NL80211_ATTR_TDLS_EXTERNAL_SETUP,
-  NL80211_ATTR_DEVICE_AP_SME,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_DEVICE_AP_SME,
   NL80211_ATTR_DONT_WAIT_FOR_ACK,
   NL80211_ATTR_FEATURE_FLAGS,
   NL80211_ATTR_PROBE_RESP_OFFLOAD,
-  NL80211_ATTR_PROBE_RESP,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_PROBE_RESP,
   NL80211_ATTR_DFS_REGION,
   NL80211_ATTR_DISABLE_HT,
   NL80211_ATTR_HT_CAPABILITY_MASK,
-  NL80211_ATTR_NOACK_MAP,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_NOACK_MAP,
   NL80211_ATTR_INACTIVITY_TIMEOUT,
   NL80211_ATTR_RX_SIGNAL_DBM,
   NL80211_ATTR_BG_SCAN_PERIOD,
-  NL80211_ATTR_WDEV,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WDEV,
   NL80211_ATTR_USER_REG_HINT_TYPE,
   NL80211_ATTR_CONN_FAILED_REASON,
   NL80211_ATTR_SAE_DATA,
-  NL80211_ATTR_VHT_CAPABILITY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_VHT_CAPABILITY,
   NL80211_ATTR_SCAN_FLAGS,
   NL80211_ATTR_CHANNEL_WIDTH,
   NL80211_ATTR_CENTER_FREQ1,
-  NL80211_ATTR_CENTER_FREQ2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_CENTER_FREQ2,
   NL80211_ATTR_P2P_CTWINDOW,
   NL80211_ATTR_P2P_OPPPS,
   NL80211_ATTR_LOCAL_MESH_POWER_MODE,
-  NL80211_ATTR_ACL_POLICY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_ACL_POLICY,
   NL80211_ATTR_MAC_ADDRS,
   NL80211_ATTR_MAC_ACL_MAX,
   NL80211_ATTR_RADAR_EVENT,
-  NL80211_ATTR_EXT_CAPA,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_EXT_CAPA,
   NL80211_ATTR_EXT_CAPA_MASK,
   NL80211_ATTR_STA_CAPABILITY,
   NL80211_ATTR_STA_EXT_CAPABILITY,
-  NL80211_ATTR_PROTOCOL_FEATURES,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_PROTOCOL_FEATURES,
   NL80211_ATTR_SPLIT_WIPHY_DUMP,
   NL80211_ATTR_DISABLE_VHT,
   NL80211_ATTR_VHT_CAPABILITY_MASK,
-  NL80211_ATTR_MDID,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_MDID,
   NL80211_ATTR_IE_RIC,
   NL80211_ATTR_CRIT_PROT_ID,
   NL80211_ATTR_MAX_CRIT_PROT_DURATION,
-  NL80211_ATTR_PEER_AID,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_PEER_AID,
   NL80211_ATTR_COALESCE_RULE,
   NL80211_ATTR_CH_SWITCH_COUNT,
   NL80211_ATTR_CH_SWITCH_BLOCK_TX,
-  NL80211_ATTR_CSA_IES,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_CSA_IES,
   NL80211_ATTR_CSA_C_OFF_BEACON,
   NL80211_ATTR_CSA_C_OFF_PRESP,
   NL80211_ATTR_RXMGMT_FLAGS,
-  NL80211_ATTR_STA_SUPPORTED_CHANNELS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_STA_SUPPORTED_CHANNELS,
   NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES,
   NL80211_ATTR_HANDLE_DFS,
   NL80211_ATTR_SUPPORT_5_MHZ,
-  NL80211_ATTR_SUPPORT_10_MHZ,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_SUPPORT_10_MHZ,
   NL80211_ATTR_OPMODE_NOTIF,
   NL80211_ATTR_VENDOR_ID,
   NL80211_ATTR_VENDOR_SUBCMD,
-  NL80211_ATTR_VENDOR_DATA,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_VENDOR_DATA,
   NL80211_ATTR_VENDOR_EVENTS,
   NL80211_ATTR_QOS_MAP,
   NL80211_ATTR_MAC_HINT,
-  NL80211_ATTR_WIPHY_FREQ_HINT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_FREQ_HINT,
   NL80211_ATTR_MAX_AP_ASSOC_STA,
   NL80211_ATTR_TDLS_PEER_CAPABILITY,
   NL80211_ATTR_SOCKET_OWNER,
-  NL80211_ATTR_CSA_C_OFFSETS_TX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_CSA_C_OFFSETS_TX,
   NL80211_ATTR_MAX_CSA_COUNTERS,
   NL80211_ATTR_TDLS_INITIATOR,
   NL80211_ATTR_USE_RRM,
-  NL80211_ATTR_WIPHY_DYN_ACK,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_WIPHY_DYN_ACK,
   NL80211_ATTR_TSID,
   NL80211_ATTR_USER_PRIO,
   NL80211_ATTR_ADMITTED_TIME,
-  NL80211_ATTR_SMPS_MODE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_SMPS_MODE,
   NL80211_ATTR_OPER_CLASS,
   NL80211_ATTR_MAC_MASK,
   NL80211_ATTR_WIPHY_SELF_MANAGED_REG,
-  NL80211_ATTR_EXT_FEATURES,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_EXT_FEATURES,
   NL80211_ATTR_SURVEY_RADIO_STATS,
   NL80211_ATTR_NETNS_FD,
   NL80211_ATTR_SCHED_SCAN_DELAY,
-  NL80211_ATTR_REG_INDOOR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_REG_INDOOR,
   NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS,
   NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL,
   NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS,
-  NL80211_ATTR_SCHED_SCAN_PLANS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_SCHED_SCAN_PLANS,
+  NL80211_ATTR_PBSS,
+  NL80211_ATTR_BSS_SELECT,
+  NL80211_ATTR_STA_SUPPORT_P2P_PS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_PAD,
   __NL80211_ATTR_AFTER_LAST,
   NUM_NL80211_ATTR = __NL80211_ATTR_AFTER_LAST,
   NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
 #define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
 #define NL80211_ATTR_IFACE_SOCKET_OWNER NL80211_ATTR_SOCKET_OWNER
-#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
 #define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
 #define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
 #define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
-#define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_ATTR_WIPHY_FREQ NL80211_ATTR_WIPHY_FREQ
 #define NL80211_ATTR_WIPHY_CHANNEL_TYPE NL80211_ATTR_WIPHY_CHANNEL_TYPE
 #define NL80211_ATTR_MGMT_SUBTYPE NL80211_ATTR_MGMT_SUBTYPE
 #define NL80211_ATTR_IE NL80211_ATTR_IE
-#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
 #define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE
 #define NL80211_ATTR_FRAME NL80211_ATTR_FRAME
 #define NL80211_ATTR_SSID NL80211_ATTR_SSID
-#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
 #define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE
 #define NL80211_ATTR_CIPHER_SUITES_PAIRWISE NL80211_ATTR_CIPHER_SUITES_PAIRWISE
 #define NL80211_ATTR_CIPHER_SUITE_GROUP NL80211_ATTR_CIPHER_SUITE_GROUP
-#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
 #define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
 #define NL80211_ATTR_KEY NL80211_ATTR_KEY
 #define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
-#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
 #define NL80211_MAX_SUPP_RATES 32
 #define NL80211_MAX_SUPP_HT_RATES 77
 #define NL80211_MAX_SUPP_REG_RULES 64
-#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
 #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
 #define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
 #define NL80211_HT_CAPABILITY_LEN 26
-#define NL80211_VHT_CAPABILITY_LEN 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_VHT_CAPABILITY_LEN 12
 #define NL80211_MAX_NR_CIPHER_SUITES 5
 #define NL80211_MAX_NR_AKM_SUITES 2
 #define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10
-#define NL80211_SCAN_RSSI_THOLD_OFF - 300
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_SCAN_RSSI_THOLD_OFF - 300
 #define NL80211_CQM_TXE_MAX_INTVL 1800
 enum nl80211_iftype {
   NL80211_IFTYPE_UNSPECIFIED,
-  NL80211_IFTYPE_ADHOC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_IFTYPE_ADHOC,
   NL80211_IFTYPE_STATION,
   NL80211_IFTYPE_AP,
   NL80211_IFTYPE_AP_VLAN,
-  NL80211_IFTYPE_WDS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_IFTYPE_WDS,
   NL80211_IFTYPE_MONITOR,
   NL80211_IFTYPE_MESH_POINT,
   NL80211_IFTYPE_P2P_CLIENT,
-  NL80211_IFTYPE_P2P_GO,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_IFTYPE_P2P_GO,
   NL80211_IFTYPE_P2P_DEVICE,
   NL80211_IFTYPE_OCB,
   NUM_NL80211_IFTYPES,
-  NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
 };
 enum nl80211_sta_flags {
   __NL80211_STA_FLAG_INVALID,
-  NL80211_STA_FLAG_AUTHORIZED,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_STA_FLAG_AUTHORIZED,
   NL80211_STA_FLAG_SHORT_PREAMBLE,
   NL80211_STA_FLAG_WME,
   NL80211_STA_FLAG_MFP,
-  NL80211_STA_FLAG_AUTHENTICATED,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_STA_FLAG_AUTHENTICATED,
   NL80211_STA_FLAG_TDLS_PEER,
   NL80211_STA_FLAG_ASSOCIATED,
   __NL80211_STA_FLAG_AFTER_LAST,
-  NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
+};
+enum nl80211_sta_p2p_ps_status {
+  NL80211_P2P_PS_UNSUPPORTED = 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_P2P_PS_SUPPORTED,
+  NUM_NL80211_P2P_PS_STATUS,
 };
 #define NL80211_STA_FLAG_MAX_OLD_API NL80211_STA_FLAG_TDLS_PEER
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nl80211_sta_flag_update {
   __u32 mask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 set;
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_rate_info {
   __NL80211_RATE_INFO_INVALID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_RATE_INFO_BITRATE,
   NL80211_RATE_INFO_MCS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_RATE_INFO_40_MHZ_WIDTH,
   NL80211_RATE_INFO_SHORT_GI,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_RATE_INFO_BITRATE32,
   NL80211_RATE_INFO_VHT_MCS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_RATE_INFO_VHT_NSS,
   NL80211_RATE_INFO_80_MHZ_WIDTH,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_RATE_INFO_80P80_MHZ_WIDTH,
   NL80211_RATE_INFO_160_MHZ_WIDTH,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_RATE_INFO_10_MHZ_WIDTH,
   NL80211_RATE_INFO_5_MHZ_WIDTH,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_RATE_INFO_AFTER_LAST,
   NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_sta_bss_param {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_STA_BSS_PARAM_INVALID,
   NL80211_STA_BSS_PARAM_CTS_PROT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_BSS_PARAM_SHORT_PREAMBLE,
   NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_BSS_PARAM_DTIM_PERIOD,
   NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_STA_BSS_PARAM_AFTER_LAST,
   NL80211_STA_BSS_PARAM_MAX = __NL80211_STA_BSS_PARAM_AFTER_LAST - 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_sta_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_STA_INFO_INVALID,
   NL80211_STA_INFO_INACTIVE_TIME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_RX_BYTES,
   NL80211_STA_INFO_TX_BYTES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_LLID,
   NL80211_STA_INFO_PLID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_PLINK_STATE,
   NL80211_STA_INFO_SIGNAL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_TX_BITRATE,
   NL80211_STA_INFO_RX_PACKETS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_TX_PACKETS,
   NL80211_STA_INFO_TX_RETRIES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_TX_FAILED,
   NL80211_STA_INFO_SIGNAL_AVG,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_RX_BITRATE,
   NL80211_STA_INFO_BSS_PARAM,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_CONNECTED_TIME,
   NL80211_STA_INFO_STA_FLAGS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_BEACON_LOSS,
   NL80211_STA_INFO_T_OFFSET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_LOCAL_PM,
   NL80211_STA_INFO_PEER_PM,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_NONPEER_PM,
   NL80211_STA_INFO_RX_BYTES64,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_TX_BYTES64,
   NL80211_STA_INFO_CHAIN_SIGNAL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
   NL80211_STA_INFO_EXPECTED_THROUGHPUT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_RX_DROP_MISC,
   NL80211_STA_INFO_BEACON_RX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_STA_INFO_BEACON_SIGNAL_AVG,
   NL80211_STA_INFO_TID_STATS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_STA_INFO_RX_DURATION,
+  NL80211_STA_INFO_PAD,
   __NL80211_STA_INFO_AFTER_LAST,
   NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -659,449 +674,454 @@
   NL80211_TID_STATS_TX_MSDU,
   NL80211_TID_STATS_TX_MSDU_RETRIES,
   NL80211_TID_STATS_TX_MSDU_FAILED,
-  NUM_NL80211_TID_STATS,
+  NL80211_TID_STATS_PAD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NUM_NL80211_TID_STATS,
   NL80211_TID_STATS_MAX = NUM_NL80211_TID_STATS - 1
 };
 enum nl80211_mpath_flags {
-  NL80211_MPATH_FLAG_ACTIVE = 1 << 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_MPATH_FLAG_ACTIVE = 1 << 0,
   NL80211_MPATH_FLAG_RESOLVING = 1 << 1,
   NL80211_MPATH_FLAG_SN_VALID = 1 << 2,
   NL80211_MPATH_FLAG_FIXED = 1 << 3,
-  NL80211_MPATH_FLAG_RESOLVED = 1 << 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_MPATH_FLAG_RESOLVED = 1 << 4,
 };
 enum nl80211_mpath_info {
   __NL80211_MPATH_INFO_INVALID,
-  NL80211_MPATH_INFO_FRAME_QLEN,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_MPATH_INFO_FRAME_QLEN,
   NL80211_MPATH_INFO_SN,
   NL80211_MPATH_INFO_METRIC,
   NL80211_MPATH_INFO_EXPTIME,
-  NL80211_MPATH_INFO_FLAGS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_MPATH_INFO_FLAGS,
   NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
   NL80211_MPATH_INFO_DISCOVERY_RETRIES,
   __NL80211_MPATH_INFO_AFTER_LAST,
-  NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
 };
 enum nl80211_band_attr {
   __NL80211_BAND_ATTR_INVALID,
-  NL80211_BAND_ATTR_FREQS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_BAND_ATTR_FREQS,
   NL80211_BAND_ATTR_RATES,
   NL80211_BAND_ATTR_HT_MCS_SET,
   NL80211_BAND_ATTR_HT_CAPA,
-  NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
   NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
   NL80211_BAND_ATTR_VHT_MCS_SET,
   NL80211_BAND_ATTR_VHT_CAPA,
-  __NL80211_BAND_ATTR_AFTER_LAST,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NL80211_BAND_ATTR_AFTER_LAST,
   NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
 };
 #define NL80211_BAND_ATTR_HT_CAPA NL80211_BAND_ATTR_HT_CAPA
-enum nl80211_frequency_attr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum nl80211_frequency_attr {
   __NL80211_FREQUENCY_ATTR_INVALID,
   NL80211_FREQUENCY_ATTR_FREQ,
   NL80211_FREQUENCY_ATTR_DISABLED,
-  NL80211_FREQUENCY_ATTR_NO_IR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_FREQUENCY_ATTR_NO_IR,
   __NL80211_FREQUENCY_ATTR_NO_IBSS,
   NL80211_FREQUENCY_ATTR_RADAR,
   NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
-  NL80211_FREQUENCY_ATTR_DFS_STATE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_FREQUENCY_ATTR_DFS_STATE,
   NL80211_FREQUENCY_ATTR_DFS_TIME,
   NL80211_FREQUENCY_ATTR_NO_HT40_MINUS,
   NL80211_FREQUENCY_ATTR_NO_HT40_PLUS,
-  NL80211_FREQUENCY_ATTR_NO_80MHZ,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_FREQUENCY_ATTR_NO_80MHZ,
   NL80211_FREQUENCY_ATTR_NO_160MHZ,
   NL80211_FREQUENCY_ATTR_DFS_CAC_TIME,
   NL80211_FREQUENCY_ATTR_INDOOR_ONLY,
-  NL80211_FREQUENCY_ATTR_IR_CONCURRENT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_FREQUENCY_ATTR_IR_CONCURRENT,
   NL80211_FREQUENCY_ATTR_NO_20MHZ,
   NL80211_FREQUENCY_ATTR_NO_10MHZ,
   __NL80211_FREQUENCY_ATTR_AFTER_LAST,
-  NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
 };
 #define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
 #define NL80211_FREQUENCY_ATTR_PASSIVE_SCAN NL80211_FREQUENCY_ATTR_NO_IR
-#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
 #define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR
 #define NL80211_FREQUENCY_ATTR_GO_CONCURRENT NL80211_FREQUENCY_ATTR_IR_CONCURRENT
 enum nl80211_bitrate_attr {
-  __NL80211_BITRATE_ATTR_INVALID,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NL80211_BITRATE_ATTR_INVALID,
   NL80211_BITRATE_ATTR_RATE,
   NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
   __NL80211_BITRATE_ATTR_AFTER_LAST,
-  NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
 };
 enum nl80211_reg_initiator {
   NL80211_REGDOM_SET_BY_CORE,
-  NL80211_REGDOM_SET_BY_USER,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_REGDOM_SET_BY_USER,
   NL80211_REGDOM_SET_BY_DRIVER,
   NL80211_REGDOM_SET_BY_COUNTRY_IE,
 };
-enum nl80211_reg_type {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum nl80211_reg_type {
   NL80211_REGDOM_TYPE_COUNTRY,
   NL80211_REGDOM_TYPE_WORLD,
   NL80211_REGDOM_TYPE_CUSTOM_WORLD,
-  NL80211_REGDOM_TYPE_INTERSECTION,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_REGDOM_TYPE_INTERSECTION,
 };
 enum nl80211_reg_rule_attr {
   __NL80211_REG_RULE_ATTR_INVALID,
-  NL80211_ATTR_REG_RULE_FLAGS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_REG_RULE_FLAGS,
   NL80211_ATTR_FREQ_RANGE_START,
   NL80211_ATTR_FREQ_RANGE_END,
   NL80211_ATTR_FREQ_RANGE_MAX_BW,
-  NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
   NL80211_ATTR_POWER_RULE_MAX_EIRP,
   NL80211_ATTR_DFS_CAC_TIME,
   __NL80211_REG_RULE_ATTR_AFTER_LAST,
-  NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
 };
 enum nl80211_sched_scan_match_attr {
   __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID,
-  NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
   NL80211_SCHED_SCAN_MATCH_ATTR_RSSI,
   __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
   NL80211_SCHED_SCAN_MATCH_ATTR_MAX = __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST - 1
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define NL80211_ATTR_SCHED_SCAN_MATCH_SSID NL80211_SCHED_SCAN_MATCH_ATTR_SSID
 enum nl80211_reg_rule_flags {
   NL80211_RRF_NO_OFDM = 1 << 0,
-  NL80211_RRF_NO_CCK = 1 << 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_RRF_NO_CCK = 1 << 1,
   NL80211_RRF_NO_INDOOR = 1 << 2,
   NL80211_RRF_NO_OUTDOOR = 1 << 3,
   NL80211_RRF_DFS = 1 << 4,
-  NL80211_RRF_PTP_ONLY = 1 << 5,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_RRF_PTP_ONLY = 1 << 5,
   NL80211_RRF_PTMP_ONLY = 1 << 6,
   NL80211_RRF_NO_IR = 1 << 7,
   __NL80211_RRF_NO_IBSS = 1 << 8,
-  NL80211_RRF_AUTO_BW = 1 << 11,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_RRF_AUTO_BW = 1 << 11,
   NL80211_RRF_IR_CONCURRENT = 1 << 12,
   NL80211_RRF_NO_HT40MINUS = 1 << 13,
   NL80211_RRF_NO_HT40PLUS = 1 << 14,
-  NL80211_RRF_NO_80MHZ = 1 << 15,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_RRF_NO_80MHZ = 1 << 15,
   NL80211_RRF_NO_160MHZ = 1 << 16,
 };
 #define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
-#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
 #define NL80211_RRF_NO_IR NL80211_RRF_NO_IR
 #define NL80211_RRF_NO_HT40 (NL80211_RRF_NO_HT40MINUS | NL80211_RRF_NO_HT40PLUS)
 #define NL80211_RRF_GO_CONCURRENT NL80211_RRF_IR_CONCURRENT
-#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
 enum nl80211_dfs_regions {
   NL80211_DFS_UNSET = 0,
   NL80211_DFS_FCC = 1,
-  NL80211_DFS_ETSI = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_DFS_ETSI = 2,
   NL80211_DFS_JP = 3,
 };
 enum nl80211_user_reg_hint_type {
-  NL80211_USER_REG_HINT_USER = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_USER_REG_HINT_USER = 0,
   NL80211_USER_REG_HINT_CELL_BASE = 1,
   NL80211_USER_REG_HINT_INDOOR = 2,
 };
-enum nl80211_survey_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum nl80211_survey_info {
   __NL80211_SURVEY_INFO_INVALID,
   NL80211_SURVEY_INFO_FREQUENCY,
   NL80211_SURVEY_INFO_NOISE,
-  NL80211_SURVEY_INFO_IN_USE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_SURVEY_INFO_IN_USE,
   NL80211_SURVEY_INFO_TIME,
   NL80211_SURVEY_INFO_TIME_BUSY,
   NL80211_SURVEY_INFO_TIME_EXT_BUSY,
-  NL80211_SURVEY_INFO_TIME_RX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_SURVEY_INFO_TIME_RX,
   NL80211_SURVEY_INFO_TIME_TX,
   NL80211_SURVEY_INFO_TIME_SCAN,
+  NL80211_SURVEY_INFO_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_SURVEY_INFO_AFTER_LAST,
   NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NL80211_SURVEY_INFO_CHANNEL_TIME NL80211_SURVEY_INFO_TIME
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY NL80211_SURVEY_INFO_TIME_BUSY
 #define NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY NL80211_SURVEY_INFO_TIME_EXT_BUSY
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NL80211_SURVEY_INFO_CHANNEL_TIME_RX NL80211_SURVEY_INFO_TIME_RX
 #define NL80211_SURVEY_INFO_CHANNEL_TIME_TX NL80211_SURVEY_INFO_TIME_TX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_mntr_flags {
   __NL80211_MNTR_FLAG_INVALID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MNTR_FLAG_FCSFAIL,
   NL80211_MNTR_FLAG_PLCPFAIL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MNTR_FLAG_CONTROL,
   NL80211_MNTR_FLAG_OTHER_BSS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MNTR_FLAG_COOK_FRAMES,
   NL80211_MNTR_FLAG_ACTIVE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_MNTR_FLAG_AFTER_LAST,
   NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_mesh_power_mode {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESH_POWER_UNKNOWN,
   NL80211_MESH_POWER_ACTIVE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESH_POWER_LIGHT_SLEEP,
   NL80211_MESH_POWER_DEEP_SLEEP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_MESH_POWER_AFTER_LAST,
   NL80211_MESH_POWER_MAX = __NL80211_MESH_POWER_AFTER_LAST - 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_meshconf_params {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_MESHCONF_INVALID,
   NL80211_MESHCONF_RETRY_TIMEOUT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_CONFIRM_TIMEOUT,
   NL80211_MESHCONF_HOLDING_TIMEOUT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_MAX_PEER_LINKS,
   NL80211_MESHCONF_MAX_RETRIES,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_TTL,
   NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
   NL80211_MESHCONF_PATH_REFRESH_TIME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
   NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
   NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_HWMP_ROOTMODE,
   NL80211_MESHCONF_ELEMENT_TTL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_HWMP_RANN_INTERVAL,
   NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
   NL80211_MESHCONF_FORWARDING,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_RSSI_THRESHOLD,
   NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_HT_OPMODE,
   NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
   NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_POWER_MODE,
   NL80211_MESHCONF_AWAKE_WINDOW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_PLINK_TIMEOUT,
   __NL80211_MESHCONF_ATTR_AFTER_LAST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST - 1
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_mesh_setup_params {
   __NL80211_MESH_SETUP_INVALID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
   NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESH_SETUP_IE,
   NL80211_MESH_SETUP_USERSPACE_AUTH,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESH_SETUP_USERSPACE_AMPE,
   NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MESH_SETUP_USERSPACE_MPM,
   NL80211_MESH_SETUP_AUTH_PROTOCOL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
   NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_txq_attr {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_TXQ_ATTR_INVALID,
   NL80211_TXQ_ATTR_AC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_TXQ_ATTR_TXOP,
   NL80211_TXQ_ATTR_CWMIN,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_TXQ_ATTR_CWMAX,
   NL80211_TXQ_ATTR_AIFS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_TXQ_ATTR_AFTER_LAST,
   NL80211_TXQ_ATTR_MAX = __NL80211_TXQ_ATTR_AFTER_LAST - 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_ac {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_AC_VO,
   NL80211_AC_VI,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_AC_BE,
   NL80211_AC_BK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_NUM_ACS
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NL80211_TXQ_ATTR_QUEUE NL80211_TXQ_ATTR_AC
 #define NL80211_TXQ_Q_VO NL80211_AC_VO
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NL80211_TXQ_Q_VI NL80211_AC_VI
 #define NL80211_TXQ_Q_BE NL80211_AC_BE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NL80211_TXQ_Q_BK NL80211_AC_BK
 enum nl80211_channel_type {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_CHAN_NO_HT,
   NL80211_CHAN_HT20,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_CHAN_HT40MINUS,
   NL80211_CHAN_HT40PLUS
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_chan_width {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_CHAN_WIDTH_20_NOHT,
   NL80211_CHAN_WIDTH_20,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_CHAN_WIDTH_40,
   NL80211_CHAN_WIDTH_80,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_CHAN_WIDTH_80P80,
   NL80211_CHAN_WIDTH_160,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_CHAN_WIDTH_5,
   NL80211_CHAN_WIDTH_10,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_bss_scan_width {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_CHAN_WIDTH_20,
   NL80211_BSS_CHAN_WIDTH_10,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_CHAN_WIDTH_5,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_bss {
   __NL80211_BSS_INVALID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_BSSID,
   NL80211_BSS_FREQUENCY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_TSF,
   NL80211_BSS_BEACON_INTERVAL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_CAPABILITY,
   NL80211_BSS_INFORMATION_ELEMENTS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_SIGNAL_MBM,
   NL80211_BSS_SIGNAL_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_STATUS,
   NL80211_BSS_SEEN_MS_AGO,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_BEACON_IES,
   NL80211_BSS_CHAN_WIDTH,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_BEACON_TSF,
   NL80211_BSS_PRESP_DATA,
-  NL80211_BSS_LAST_SEEN_BOOTTIME,
-  __NL80211_BSS_AFTER_LAST,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_BSS_LAST_SEEN_BOOTTIME,
+  NL80211_BSS_PAD,
+  __NL80211_BSS_AFTER_LAST,
   NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_bss_status {
   NL80211_BSS_STATUS_AUTHENTICATED,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_STATUS_ASSOCIATED,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BSS_STATUS_IBSS_JOINED,
 };
 enum nl80211_auth_type {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_AUTHTYPE_OPEN_SYSTEM,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_AUTHTYPE_SHARED_KEY,
   NL80211_AUTHTYPE_FT,
   NL80211_AUTHTYPE_NETWORK_EAP,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_AUTHTYPE_SAE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_AUTHTYPE_NUM,
   NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
   NL80211_AUTHTYPE_AUTOMATIC
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_key_type {
   NL80211_KEYTYPE_GROUP,
   NL80211_KEYTYPE_PAIRWISE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_KEYTYPE_PEERKEY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NUM_NL80211_KEYTYPES
 };
 enum nl80211_mfp {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MFP_NO,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_MFP_REQUIRED,
 };
 enum nl80211_wpa_versions {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_WPA_VERSION_1 = 1 << 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_WPA_VERSION_2 = 1 << 1,
 };
 enum nl80211_key_default_types {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_KEY_DEFAULT_TYPE_INVALID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_KEY_DEFAULT_TYPE_UNICAST,
   NL80211_KEY_DEFAULT_TYPE_MULTICAST,
   NUM_NL80211_KEY_DEFAULT_TYPES
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_key_attributes {
   __NL80211_KEY_INVALID,
   NL80211_KEY_DATA,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_KEY_IDX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_KEY_CIPHER,
   NL80211_KEY_SEQ,
   NL80211_KEY_DEFAULT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_KEY_DEFAULT_MGMT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_KEY_TYPE,
   NL80211_KEY_DEFAULT_TYPES,
   __NL80211_KEY_AFTER_LAST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum nl80211_tx_rate_attributes {
   __NL80211_TXRATE_INVALID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_TXRATE_LEGACY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_TXRATE_HT,
   NL80211_TXRATE_VHT,
   NL80211_TXRATE_GI,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __NL80211_TXRATE_AFTER_LAST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1
 };
 #define NL80211_TXRATE_MCS NL80211_TXRATE_HT
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NL80211_VHT_NSS_MAX 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nl80211_txrate_vht {
   __u16 mcs[NL80211_VHT_NSS_MAX];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_txrate_gi {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_TXRATE_DEFAULT_GI,
   NL80211_TXRATE_FORCE_SGI,
   NL80211_TXRATE_FORCE_LGI,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum nl80211_band {
   NL80211_BAND_2GHZ,
   NL80211_BAND_5GHZ,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_BAND_60GHZ,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NUM_NL80211_BANDS,
 };
 enum nl80211_ps_state {
   NL80211_PS_DISABLED,
@@ -1382,94 +1402,110 @@
 enum nl80211_ext_feature_index {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NL80211_EXT_FEATURE_VHT_IBSS,
+  NL80211_EXT_FEATURE_RRM,
   NUM_NL80211_EXT_FEATURES,
   MAX_NL80211_EXT_FEATURES = NUM_NL80211_EXT_FEATURES - 1
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum nl80211_probe_resp_offload_support_attr {
   NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1 << 0,
   NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1 << 1,
-  NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1 << 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1 << 2,
   NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1 << 3,
 };
 enum nl80211_connect_failed_reason {
-  NL80211_CONN_FAIL_MAX_CLIENTS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_CONN_FAIL_MAX_CLIENTS,
   NL80211_CONN_FAIL_BLOCKED_CLIENT,
 };
 enum nl80211_scan_flags {
-  NL80211_SCAN_FLAG_LOW_PRIORITY = 1 << 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_SCAN_FLAG_LOW_PRIORITY = 1 << 0,
   NL80211_SCAN_FLAG_FLUSH = 1 << 1,
   NL80211_SCAN_FLAG_AP = 1 << 2,
   NL80211_SCAN_FLAG_RANDOM_ADDR = 1 << 3,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum nl80211_acl_policy {
   NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED,
   NL80211_ACL_POLICY_DENY_UNLESS_LISTED,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum nl80211_smps_mode {
   NL80211_SMPS_OFF,
   NL80211_SMPS_STATIC,
-  NL80211_SMPS_DYNAMIC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_SMPS_DYNAMIC,
   __NL80211_SMPS_AFTER_LAST,
   NL80211_SMPS_MAX = __NL80211_SMPS_AFTER_LAST - 1
 };
-enum nl80211_radar_event {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum nl80211_radar_event {
   NL80211_RADAR_DETECTED,
   NL80211_RADAR_CAC_FINISHED,
   NL80211_RADAR_CAC_ABORTED,
-  NL80211_RADAR_NOP_FINISHED,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_RADAR_NOP_FINISHED,
 };
 enum nl80211_dfs_state {
   NL80211_DFS_USABLE,
-  NL80211_DFS_UNAVAILABLE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_DFS_UNAVAILABLE,
   NL80211_DFS_AVAILABLE,
 };
 enum nl80211_protocol_features {
-  NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1 << 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1 << 0,
 };
 enum nl80211_crit_proto_id {
   NL80211_CRIT_PROTO_UNSPEC,
-  NL80211_CRIT_PROTO_DHCP,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_CRIT_PROTO_DHCP,
   NL80211_CRIT_PROTO_EAPOL,
   NL80211_CRIT_PROTO_APIPA,
   NUM_NL80211_CRIT_PROTO
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define NL80211_CRIT_PROTO_MAX_DURATION 5000
 enum nl80211_rxmgmt_flags {
   NL80211_RXMGMT_FLAG_ANSWERED = 1 << 0,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define NL80211_VENDOR_ID_IS_LINUX 0x80000000
 struct nl80211_vendor_cmd_info {
   __u32 vendor_id;
-  __u32 subcmd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 subcmd;
 };
 enum nl80211_tdls_peer_capability {
   NL80211_TDLS_PEER_HT = 1 << 0,
-  NL80211_TDLS_PEER_VHT = 1 << 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_TDLS_PEER_VHT = 1 << 1,
   NL80211_TDLS_PEER_WMM = 1 << 2,
 };
 enum nl80211_sched_scan_plan {
-  __NL80211_SCHED_SCAN_PLAN_INVALID,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __NL80211_SCHED_SCAN_PLAN_INVALID,
   NL80211_SCHED_SCAN_PLAN_INTERVAL,
   NL80211_SCHED_SCAN_PLAN_ITERATIONS,
   __NL80211_SCHED_SCAN_PLAN_AFTER_LAST,
-  NL80211_SCHED_SCAN_PLAN_MAX = __NL80211_SCHED_SCAN_PLAN_AFTER_LAST - 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_SCHED_SCAN_PLAN_MAX = __NL80211_SCHED_SCAN_PLAN_AFTER_LAST - 1
+};
+struct nl80211_bss_select_rssi_adjust {
+  __u8 band;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s8 delta;
+} __attribute__((packed));
+enum nl80211_bss_select_attr {
+  __NL80211_BSS_SELECT_ATTR_INVALID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_BSS_SELECT_ATTR_RSSI,
+  NL80211_BSS_SELECT_ATTR_BAND_PREF,
+  NL80211_BSS_SELECT_ATTR_RSSI_ADJUST,
+  __NL80211_BSS_SELECT_ATTR_AFTER_LAST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  NL80211_BSS_SELECT_ATTR_MAX = __NL80211_BSS_SELECT_ATTR_AFTER_LAST - 1
 };
 #endif
diff --git a/libc/kernel/uapi/linux/nvme.h b/libc/kernel/uapi/linux/nvme.h
deleted file mode 100644
index 030f01c..0000000
--- a/libc/kernel/uapi/linux/nvme.h
+++ /dev/null
@@ -1,595 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _UAPI_LINUX_NVME_H
-#define _UAPI_LINUX_NVME_H
-#include <linux/types.h>
-struct nvme_id_power_state {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 max_power;
-  __u8 rsvd2;
-  __u8 flags;
-  __le32 entry_lat;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 exit_lat;
-  __u8 read_tput;
-  __u8 read_lat;
-  __u8 write_tput;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 write_lat;
-  __le16 idle_power;
-  __u8 idle_scale;
-  __u8 rsvd19;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 active_power;
-  __u8 active_work_scale;
-  __u8 rsvd23[9];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum {
-  NVME_PS_FLAGS_MAX_POWER_SCALE = 1 << 0,
-  NVME_PS_FLAGS_NON_OP_STATE = 1 << 1,
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct nvme_id_ctrl {
-  __le16 vid;
-  __le16 ssvid;
-  char sn[20];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  char mn[40];
-  char fr[8];
-  __u8 rab;
-  __u8 ieee[3];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 mic;
-  __u8 mdts;
-  __u16 cntlid;
-  __u32 ver;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 rsvd84[172];
-  __le16 oacs;
-  __u8 acl;
-  __u8 aerl;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 frmw;
-  __u8 lpa;
-  __u8 elpe;
-  __u8 npss;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 avscc;
-  __u8 apsta;
-  __le16 wctemp;
-  __le16 cctemp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 rsvd270[242];
-  __u8 sqes;
-  __u8 cqes;
-  __u8 rsvd514[2];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 nn;
-  __le16 oncs;
-  __le16 fuses;
-  __u8 fna;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 vwc;
-  __le16 awun;
-  __le16 awupf;
-  __u8 nvscc;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 rsvd531;
-  __le16 acwu;
-  __u8 rsvd534[2];
-  __le32 sgls;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 rsvd540[1508];
-  struct nvme_id_power_state psd[32];
-  __u8 vs[1024];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum {
-  NVME_CTRL_ONCS_COMPARE = 1 << 0,
-  NVME_CTRL_ONCS_WRITE_UNCORRECTABLE = 1 << 1,
-  NVME_CTRL_ONCS_DSM = 1 << 2,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_CTRL_VWC_PRESENT = 1 << 0,
-};
-struct nvme_lbaf {
-  __le16 ms;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 ds;
-  __u8 rp;
-};
-struct nvme_id_ns {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le64 nsze;
-  __le64 ncap;
-  __le64 nuse;
-  __u8 nsfeat;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 nlbaf;
-  __u8 flbas;
-  __u8 mc;
-  __u8 dpc;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 dps;
-  __u8 nmic;
-  __u8 rescap;
-  __u8 fpi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 rsvd33;
-  __le16 nawun;
-  __le16 nawupf;
-  __le16 nacwu;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 rsvd40[80];
-  __u8 eui64[8];
-  struct nvme_lbaf lbaf[16];
-  __u8 rsvd192[192];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 vs[3712];
-};
-enum {
-  NVME_NS_FEAT_THIN = 1 << 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_LBAF_RP_BEST = 0,
-  NVME_LBAF_RP_BETTER = 1,
-  NVME_LBAF_RP_GOOD = 2,
-  NVME_LBAF_RP_DEGRADED = 3,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct nvme_smart_log {
-  __u8 critical_warning;
-  __u8 temperature[2];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 avail_spare;
-  __u8 spare_thresh;
-  __u8 percent_used;
-  __u8 rsvd6[26];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 data_units_read[16];
-  __u8 data_units_written[16];
-  __u8 host_reads[16];
-  __u8 host_writes[16];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 ctrl_busy_time[16];
-  __u8 power_cycles[16];
-  __u8 power_on_hours[16];
-  __u8 unsafe_shutdowns[16];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 media_errors[16];
-  __u8 num_err_log_entries[16];
-  __le32 warning_temp_time;
-  __le32 critical_comp_time;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 temp_sensor[8];
-  __u8 rsvd216[296];
-};
-enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SMART_CRIT_SPARE = 1 << 0,
-  NVME_SMART_CRIT_TEMPERATURE = 1 << 1,
-  NVME_SMART_CRIT_RELIABILITY = 1 << 2,
-  NVME_SMART_CRIT_MEDIA = 1 << 3,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SMART_CRIT_VOLATILE_MEMORY = 1 << 4,
-};
-struct nvme_lba_range_type {
-  __u8 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 attributes;
-  __u8 rsvd2[14];
-  __u64 slba;
-  __u64 nlb;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 guid[16];
-  __u8 rsvd48[16];
-};
-enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_LBART_TYPE_FS = 0x01,
-  NVME_LBART_TYPE_RAID = 0x02,
-  NVME_LBART_TYPE_CACHE = 0x03,
-  NVME_LBART_TYPE_SWAP = 0x04,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_LBART_ATTRIB_TEMP = 1 << 0,
-  NVME_LBART_ATTRIB_HIDE = 1 << 1,
-};
-enum nvme_opcode {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  nvme_cmd_flush = 0x00,
-  nvme_cmd_write = 0x01,
-  nvme_cmd_read = 0x02,
-  nvme_cmd_write_uncor = 0x04,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  nvme_cmd_compare = 0x05,
-  nvme_cmd_dsm = 0x09,
-};
-struct nvme_common_command {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 opcode;
-  __u8 flags;
-  __u16 command_id;
-  __le32 nsid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 cdw2[2];
-  __le64 metadata;
-  __le64 prp1;
-  __le64 prp2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 cdw10[6];
-};
-struct nvme_rw_command {
-  __u8 opcode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 flags;
-  __u16 command_id;
-  __le32 nsid;
-  __u64 rsvd2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le64 metadata;
-  __le64 prp1;
-  __le64 prp2;
-  __le64 slba;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 length;
-  __le16 control;
-  __le32 dsmgmt;
-  __le32 reftag;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 apptag;
-  __le16 appmask;
-};
-enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_RW_LR = 1 << 15,
-  NVME_RW_FUA = 1 << 14,
-  NVME_RW_DSM_FREQ_UNSPEC = 0,
-  NVME_RW_DSM_FREQ_TYPICAL = 1,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_RW_DSM_FREQ_RARE = 2,
-  NVME_RW_DSM_FREQ_READS = 3,
-  NVME_RW_DSM_FREQ_WRITES = 4,
-  NVME_RW_DSM_FREQ_RW = 5,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_RW_DSM_FREQ_ONCE = 6,
-  NVME_RW_DSM_FREQ_PREFETCH = 7,
-  NVME_RW_DSM_FREQ_TEMP = 8,
-  NVME_RW_DSM_LATENCY_NONE = 0 << 4,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_RW_DSM_LATENCY_IDLE = 1 << 4,
-  NVME_RW_DSM_LATENCY_NORM = 2 << 4,
-  NVME_RW_DSM_LATENCY_LOW = 3 << 4,
-  NVME_RW_DSM_SEQ_REQ = 1 << 6,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_RW_DSM_COMPRESSED = 1 << 7,
-};
-struct nvme_dsm_cmd {
-  __u8 opcode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 flags;
-  __u16 command_id;
-  __le32 nsid;
-  __u64 rsvd2[2];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le64 prp1;
-  __le64 prp2;
-  __le32 nr;
-  __le32 attributes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 rsvd12[4];
-};
-enum {
-  NVME_DSMGMT_IDR = 1 << 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_DSMGMT_IDW = 1 << 1,
-  NVME_DSMGMT_AD = 1 << 2,
-};
-struct nvme_dsm_range {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 cattr;
-  __le32 nlb;
-  __le64 slba;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-enum nvme_admin_opcode {
-  nvme_admin_delete_sq = 0x00,
-  nvme_admin_create_sq = 0x01,
-  nvme_admin_get_log_page = 0x02,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  nvme_admin_delete_cq = 0x04,
-  nvme_admin_create_cq = 0x05,
-  nvme_admin_identify = 0x06,
-  nvme_admin_abort_cmd = 0x08,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  nvme_admin_set_features = 0x09,
-  nvme_admin_get_features = 0x0a,
-  nvme_admin_async_event = 0x0c,
-  nvme_admin_activate_fw = 0x10,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  nvme_admin_download_fw = 0x11,
-  nvme_admin_format_nvm = 0x80,
-  nvme_admin_security_send = 0x81,
-  nvme_admin_security_recv = 0x82,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-enum {
-  NVME_QUEUE_PHYS_CONTIG = (1 << 0),
-  NVME_CQ_IRQ_ENABLED = (1 << 1),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SQ_PRIO_URGENT = (0 << 1),
-  NVME_SQ_PRIO_HIGH = (1 << 1),
-  NVME_SQ_PRIO_MEDIUM = (2 << 1),
-  NVME_SQ_PRIO_LOW = (3 << 1),
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_FEAT_ARBITRATION = 0x01,
-  NVME_FEAT_POWER_MGMT = 0x02,
-  NVME_FEAT_LBA_RANGE = 0x03,
-  NVME_FEAT_TEMP_THRESH = 0x04,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_FEAT_ERR_RECOVERY = 0x05,
-  NVME_FEAT_VOLATILE_WC = 0x06,
-  NVME_FEAT_NUM_QUEUES = 0x07,
-  NVME_FEAT_IRQ_COALESCE = 0x08,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_FEAT_IRQ_CONFIG = 0x09,
-  NVME_FEAT_WRITE_ATOMIC = 0x0a,
-  NVME_FEAT_ASYNC_EVENT = 0x0b,
-  NVME_FEAT_SW_PROGRESS = 0x0c,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_LOG_ERROR = 0x01,
-  NVME_LOG_SMART = 0x02,
-  NVME_LOG_FW_SLOT = 0x03,
-  NVME_LOG_RESERVATION = 0x80,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_FWACT_REPL = (0 << 3),
-  NVME_FWACT_REPL_ACTV = (1 << 3),
-  NVME_FWACT_ACTV = (2 << 3),
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct nvme_identify {
-  __u8 opcode;
-  __u8 flags;
-  __u16 command_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 nsid;
-  __u64 rsvd2[2];
-  __le64 prp1;
-  __le64 prp2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 cns;
-  __u32 rsvd11[5];
-};
-struct nvme_features {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 opcode;
-  __u8 flags;
-  __u16 command_id;
-  __le32 nsid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u64 rsvd2[2];
-  __le64 prp1;
-  __le64 prp2;
-  __le32 fid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 dword11;
-  __u32 rsvd12[4];
-};
-struct nvme_create_cq {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 opcode;
-  __u8 flags;
-  __u16 command_id;
-  __u32 rsvd1[5];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le64 prp1;
-  __u64 rsvd8;
-  __le16 cqid;
-  __le16 qsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 cq_flags;
-  __le16 irq_vector;
-  __u32 rsvd12[4];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct nvme_create_sq {
-  __u8 opcode;
-  __u8 flags;
-  __u16 command_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 rsvd1[5];
-  __le64 prp1;
-  __u64 rsvd8;
-  __le16 sqid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 qsize;
-  __le16 sq_flags;
-  __le16 cqid;
-  __u32 rsvd12[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct nvme_delete_queue {
-  __u8 opcode;
-  __u8 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 command_id;
-  __u32 rsvd1[9];
-  __le16 qid;
-  __u16 rsvd10;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 rsvd11[5];
-};
-struct nvme_abort_cmd {
-  __u8 opcode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 flags;
-  __u16 command_id;
-  __u32 rsvd1[9];
-  __le16 sqid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 cid;
-  __u32 rsvd11[5];
-};
-struct nvme_download_firmware {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 opcode;
-  __u8 flags;
-  __u16 command_id;
-  __u32 rsvd1[5];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le64 prp1;
-  __le64 prp2;
-  __le32 numd;
-  __le32 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 rsvd12[4];
-};
-struct nvme_format_cmd {
-  __u8 opcode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 flags;
-  __u16 command_id;
-  __le32 nsid;
-  __u64 rsvd2[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le32 cdw10;
-  __u32 rsvd11[5];
-};
-struct nvme_command {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  union {
-    struct nvme_common_command common;
-    struct nvme_rw_command rw;
-    struct nvme_identify identify;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    struct nvme_features features;
-    struct nvme_create_cq create_cq;
-    struct nvme_create_sq create_sq;
-    struct nvme_delete_queue delete_queue;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-    struct nvme_download_firmware dlfw;
-    struct nvme_format_cmd format;
-    struct nvme_dsm_cmd dsm;
-    struct nvme_abort_cmd abort;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  };
-};
-enum {
-  NVME_SC_SUCCESS = 0x0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_INVALID_OPCODE = 0x1,
-  NVME_SC_INVALID_FIELD = 0x2,
-  NVME_SC_CMDID_CONFLICT = 0x3,
-  NVME_SC_DATA_XFER_ERROR = 0x4,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_POWER_LOSS = 0x5,
-  NVME_SC_INTERNAL = 0x6,
-  NVME_SC_ABORT_REQ = 0x7,
-  NVME_SC_ABORT_QUEUE = 0x8,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_FUSED_FAIL = 0x9,
-  NVME_SC_FUSED_MISSING = 0xa,
-  NVME_SC_INVALID_NS = 0xb,
-  NVME_SC_CMD_SEQ_ERROR = 0xc,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_LBA_RANGE = 0x80,
-  NVME_SC_CAP_EXCEEDED = 0x81,
-  NVME_SC_NS_NOT_READY = 0x82,
-  NVME_SC_CQ_INVALID = 0x100,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_QID_INVALID = 0x101,
-  NVME_SC_QUEUE_SIZE = 0x102,
-  NVME_SC_ABORT_LIMIT = 0x103,
-  NVME_SC_ABORT_MISSING = 0x104,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_ASYNC_LIMIT = 0x105,
-  NVME_SC_FIRMWARE_SLOT = 0x106,
-  NVME_SC_FIRMWARE_IMAGE = 0x107,
-  NVME_SC_INVALID_VECTOR = 0x108,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_INVALID_LOG_PAGE = 0x109,
-  NVME_SC_INVALID_FORMAT = 0x10a,
-  NVME_SC_BAD_ATTRIBUTES = 0x180,
-  NVME_SC_WRITE_FAULT = 0x280,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_READ_ERROR = 0x281,
-  NVME_SC_GUARD_CHECK = 0x282,
-  NVME_SC_APPTAG_CHECK = 0x283,
-  NVME_SC_REFTAG_CHECK = 0x284,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  NVME_SC_COMPARE_FAILED = 0x285,
-  NVME_SC_ACCESS_DENIED = 0x286,
-  NVME_SC_DNR = 0x4000,
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct nvme_completion {
-  __le32 result;
-  __u32 rsvd;
-  __le16 sq_head;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 sq_id;
-  __u16 command_id;
-  __le16 status;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct nvme_user_io {
-  __u8 opcode;
-  __u8 flags;
-  __u16 control;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 nblocks;
-  __u16 rsvd;
-  __u64 metadata;
-  __u64 addr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u64 slba;
-  __u32 dsmgmt;
-  __u32 reftag;
-  __u16 apptag;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 appmask;
-};
-struct nvme_admin_cmd {
-  __u8 opcode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 flags;
-  __u16 rsvd1;
-  __u32 nsid;
-  __u32 cdw2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 cdw3;
-  __u64 metadata;
-  __u64 addr;
-  __u32 metadata_len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 data_len;
-  __u32 cdw10;
-  __u32 cdw11;
-  __u32 cdw12;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 cdw13;
-  __u32 cdw14;
-  __u32 cdw15;
-  __u32 timeout_ms;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 result;
-};
-#define NVME_IOCTL_ID _IO('N', 0x40)
-#define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_admin_cmd)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io)
-#endif
diff --git a/libc/kernel/uapi/linux/nvme_ioctl.h b/libc/kernel/uapi/linux/nvme_ioctl.h
index d643767..a332ef2 100644
--- a/libc/kernel/uapi/linux/nvme_ioctl.h
+++ b/libc/kernel/uapi/linux/nvme_ioctl.h
@@ -71,4 +71,5 @@
 #define NVME_IOCTL_RESET _IO('N', 0x44)
 #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define NVME_IOCTL_RESCAN _IO('N', 0x46)
 #endif
diff --git a/libc/kernel/uapi/linux/openvswitch.h b/libc/kernel/uapi/linux/openvswitch.h
index 61923cc..377bc34 100644
--- a/libc/kernel/uapi/linux/openvswitch.h
+++ b/libc/kernel/uapi/linux/openvswitch.h
@@ -47,387 +47,414 @@
   OVS_DP_ATTR_MEGAFLOW_STATS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_DP_ATTR_USER_FEATURES,
+  OVS_DP_ATTR_PAD,
   __OVS_DP_ATTR_MAX
 };
-#define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1)
 struct ovs_dp_stats {
   __u64 n_hit;
   __u64 n_missed;
-  __u64 n_lost;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 n_lost;
   __u64 n_flows;
 };
 struct ovs_dp_megaflow_stats {
-  __u64 n_mask_hit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 n_mask_hit;
   __u32 n_masks;
   __u32 pad0;
   __u64 pad1;
-  __u64 pad2;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 pad2;
 };
 struct ovs_vport_stats {
   __u64 rx_packets;
-  __u64 tx_packets;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 tx_packets;
   __u64 rx_bytes;
   __u64 tx_bytes;
   __u64 rx_errors;
-  __u64 tx_errors;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 tx_errors;
   __u64 rx_dropped;
   __u64 tx_dropped;
 };
-#define OVS_DP_F_UNALIGNED (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OVS_DP_F_UNALIGNED (1 << 0)
 #define OVS_DP_F_VPORT_PIDS (1 << 1)
 #define OVSP_LOCAL ((__u32) 0)
 #define OVS_PACKET_FAMILY "ovs_packet"
-#define OVS_PACKET_VERSION 0x1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OVS_PACKET_VERSION 0x1
 enum ovs_packet_cmd {
   OVS_PACKET_CMD_UNSPEC,
   OVS_PACKET_CMD_MISS,
-  OVS_PACKET_CMD_ACTION,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_PACKET_CMD_ACTION,
   OVS_PACKET_CMD_EXECUTE
 };
 enum ovs_packet_attr {
-  OVS_PACKET_ATTR_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_PACKET_ATTR_UNSPEC,
   OVS_PACKET_ATTR_PACKET,
   OVS_PACKET_ATTR_KEY,
   OVS_PACKET_ATTR_ACTIONS,
-  OVS_PACKET_ATTR_USERDATA,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_PACKET_ATTR_USERDATA,
   OVS_PACKET_ATTR_EGRESS_TUN_KEY,
   OVS_PACKET_ATTR_UNUSED1,
   OVS_PACKET_ATTR_UNUSED2,
-  OVS_PACKET_ATTR_PROBE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_PACKET_ATTR_PROBE,
   OVS_PACKET_ATTR_MRU,
   __OVS_PACKET_ATTR_MAX
 };
-#define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1)
 #define OVS_VPORT_FAMILY "ovs_vport"
 #define OVS_VPORT_MCGROUP "ovs_vport"
 #define OVS_VPORT_VERSION 0x1
-enum ovs_vport_cmd {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum ovs_vport_cmd {
   OVS_VPORT_CMD_UNSPEC,
   OVS_VPORT_CMD_NEW,
   OVS_VPORT_CMD_DEL,
-  OVS_VPORT_CMD_GET,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_VPORT_CMD_GET,
   OVS_VPORT_CMD_SET
 };
 enum ovs_vport_type {
-  OVS_VPORT_TYPE_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_VPORT_TYPE_UNSPEC,
   OVS_VPORT_TYPE_NETDEV,
   OVS_VPORT_TYPE_INTERNAL,
   OVS_VPORT_TYPE_GRE,
-  OVS_VPORT_TYPE_VXLAN,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_VPORT_TYPE_VXLAN,
   OVS_VPORT_TYPE_GENEVE,
   __OVS_VPORT_TYPE_MAX
 };
-#define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1)
 enum ovs_vport_attr {
   OVS_VPORT_ATTR_UNSPEC,
   OVS_VPORT_ATTR_PORT_NO,
-  OVS_VPORT_ATTR_TYPE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_VPORT_ATTR_TYPE,
   OVS_VPORT_ATTR_NAME,
   OVS_VPORT_ATTR_OPTIONS,
   OVS_VPORT_ATTR_UPCALL_PID,
-  OVS_VPORT_ATTR_STATS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_VPORT_ATTR_STATS,
+  OVS_VPORT_ATTR_PAD,
   __OVS_VPORT_ATTR_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1)
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_VXLAN_EXT_UNSPEC,
   OVS_VXLAN_EXT_GBP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __OVS_VXLAN_EXT_MAX,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_VXLAN_EXT_MAX (__OVS_VXLAN_EXT_MAX - 1)
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_ATTR_UNSPEC,
   OVS_TUNNEL_ATTR_DST_PORT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_ATTR_EXTENSION,
   __OVS_TUNNEL_ATTR_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define OVS_TUNNEL_ATTR_MAX (__OVS_TUNNEL_ATTR_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_FLOW_FAMILY "ovs_flow"
 #define OVS_FLOW_MCGROUP "ovs_flow"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_FLOW_VERSION 0x1
 enum ovs_flow_cmd {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FLOW_CMD_UNSPEC,
   OVS_FLOW_CMD_NEW,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FLOW_CMD_DEL,
   OVS_FLOW_CMD_GET,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FLOW_CMD_SET
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_flow_stats {
   __u64 n_packets;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 n_bytes;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ovs_key_attr {
   OVS_KEY_ATTR_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_ENCAP,
   OVS_KEY_ATTR_PRIORITY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_IN_PORT,
   OVS_KEY_ATTR_ETHERNET,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_VLAN,
   OVS_KEY_ATTR_ETHERTYPE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_IPV4,
   OVS_KEY_ATTR_IPV6,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_TCP,
   OVS_KEY_ATTR_UDP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_ICMP,
   OVS_KEY_ATTR_ICMPV6,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_ARP,
   OVS_KEY_ATTR_ND,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_SKB_MARK,
   OVS_KEY_ATTR_TUNNEL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_SCTP,
   OVS_KEY_ATTR_TCP_FLAGS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_DP_HASH,
   OVS_KEY_ATTR_RECIRC_ID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_MPLS,
   OVS_KEY_ATTR_CT_STATE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_CT_ZONE,
   OVS_KEY_ATTR_CT_MARK,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_KEY_ATTR_CT_LABELS,
   __OVS_KEY_ATTR_MAX
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ovs_tunnel_key_attr {
   OVS_TUNNEL_KEY_ATTR_ID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_KEY_ATTR_IPV4_SRC,
   OVS_TUNNEL_KEY_ATTR_IPV4_DST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_KEY_ATTR_TOS,
   OVS_TUNNEL_KEY_ATTR_TTL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT,
   OVS_TUNNEL_KEY_ATTR_CSUM,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_KEY_ATTR_OAM,
   OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_KEY_ATTR_TP_SRC,
   OVS_TUNNEL_KEY_ATTR_TP_DST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS,
   OVS_TUNNEL_KEY_ATTR_IPV6_SRC,
-  OVS_TUNNEL_KEY_ATTR_IPV6_DST,
-  __OVS_TUNNEL_KEY_ATTR_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_TUNNEL_KEY_ATTR_IPV6_DST,
+  OVS_TUNNEL_KEY_ATTR_PAD,
+  __OVS_TUNNEL_KEY_ATTR_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_TUNNEL_KEY_ATTR_MAX (__OVS_TUNNEL_KEY_ATTR_MAX - 1)
 enum ovs_frag_type {
   OVS_FRAG_TYPE_NONE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FRAG_TYPE_FIRST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FRAG_TYPE_LATER,
   __OVS_FRAG_TYPE_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_ethernet {
   __u8 eth_src[ETH_ALEN];
   __u8 eth_dst[ETH_ALEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_mpls {
   __be32 mpls_lse;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_ipv4 {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ipv4_src;
   __be32 ipv4_dst;
   __u8 ipv4_proto;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ipv4_tos;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ipv4_ttl;
   __u8 ipv4_frag;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_ipv6 {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 ipv6_src[4];
   __be32 ipv6_dst[4];
   __be32 ipv6_label;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ipv6_proto;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 ipv6_tclass;
   __u8 ipv6_hlimit;
   __u8 ipv6_frag;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_tcp {
   __be16 tcp_src;
   __be16 tcp_dst;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_udp {
   __be16 udp_src;
   __be16 udp_dst;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_sctp {
   __be16 sctp_src;
   __be16 sctp_dst;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_icmp {
   __u8 icmp_type;
   __u8 icmp_code;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_icmpv6 {
   __u8 icmpv6_type;
   __u8 icmpv6_code;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_arp {
   __be32 arp_sip;
   __be32 arp_tip;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be16 arp_op;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 arp_sha[ETH_ALEN];
   __u8 arp_tha[ETH_ALEN];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_key_nd {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 nd_target[4];
   __u8 nd_sll[ETH_ALEN];
   __u8 nd_tll[ETH_ALEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_CT_LABELS_LEN 16
 struct ovs_key_ct_labels {
   __u8 ct_labels[OVS_CT_LABELS_LEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_CS_F_NEW 0x01
 #define OVS_CS_F_ESTABLISHED 0x02
 #define OVS_CS_F_RELATED 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_CS_F_REPLY_DIR 0x08
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_CS_F_INVALID 0x10
 #define OVS_CS_F_TRACKED 0x20
-enum ovs_flow_attr {
+#define OVS_CS_F_SRC_NAT 0x40
+#define OVS_CS_F_DST_NAT 0x80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
+enum ovs_flow_attr {
   OVS_FLOW_ATTR_UNSPEC,
   OVS_FLOW_ATTR_KEY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FLOW_ATTR_ACTIONS,
   OVS_FLOW_ATTR_STATS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FLOW_ATTR_TCP_FLAGS,
   OVS_FLOW_ATTR_USED,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FLOW_ATTR_CLEAR,
   OVS_FLOW_ATTR_MASK,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_FLOW_ATTR_PROBE,
   OVS_FLOW_ATTR_UFID,
-  OVS_FLOW_ATTR_UFID_FLAGS,
-  __OVS_FLOW_ATTR_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_FLOW_ATTR_UFID_FLAGS,
+  OVS_FLOW_ATTR_PAD,
+  __OVS_FLOW_ATTR_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_FLOW_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1)
 #define OVS_UFID_F_OMIT_KEY (1 << 0)
 #define OVS_UFID_F_OMIT_MASK (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_UFID_F_OMIT_ACTIONS (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ovs_sample_attr {
   OVS_SAMPLE_ATTR_UNSPEC,
   OVS_SAMPLE_ATTR_PROBABILITY,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_SAMPLE_ATTR_ACTIONS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __OVS_SAMPLE_ATTR_MAX,
 };
 #define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ovs_userspace_attr {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_USERSPACE_ATTR_UNSPEC,
   OVS_USERSPACE_ATTR_PID,
   OVS_USERSPACE_ATTR_USERDATA,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_USERSPACE_ATTR_EGRESS_TUN_PORT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_USERSPACE_ATTR_ACTIONS,
   __OVS_USERSPACE_ATTR_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_action_push_mpls {
   __be32 mpls_lse;
   __be16 mpls_ethertype;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_action_push_vlan {
   __be16 vlan_tpid;
   __be16 vlan_tci;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ovs_hash_alg {
   OVS_HASH_ALG_L4,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ovs_action_hash {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   uint32_t hash_alg;
   uint32_t hash_basis;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ovs_ct_attr {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_CT_ATTR_UNSPEC,
   OVS_CT_ATTR_COMMIT,
   OVS_CT_ATTR_ZONE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_CT_ATTR_MARK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_CT_ATTR_LABELS,
   OVS_CT_ATTR_HELPER,
+  OVS_CT_ATTR_NAT,
   __OVS_CT_ATTR_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1)
+enum ovs_nat_attr {
+  OVS_NAT_ATTR_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_NAT_ATTR_SRC,
+  OVS_NAT_ATTR_DST,
+  OVS_NAT_ATTR_IP_MIN,
+  OVS_NAT_ATTR_IP_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_NAT_ATTR_PROTO_MIN,
+  OVS_NAT_ATTR_PROTO_MAX,
+  OVS_NAT_ATTR_PERSISTENT,
+  OVS_NAT_ATTR_PROTO_HASH,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  OVS_NAT_ATTR_PROTO_RANDOM,
+  __OVS_NAT_ATTR_MAX,
+};
+#define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum ovs_action_attr {
   OVS_ACTION_ATTR_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_ACTION_ATTR_OUTPUT,
   OVS_ACTION_ATTR_USERSPACE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_ACTION_ATTR_SET,
   OVS_ACTION_ATTR_PUSH_VLAN,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_ACTION_ATTR_POP_VLAN,
   OVS_ACTION_ATTR_SAMPLE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_ACTION_ATTR_RECIRC,
   OVS_ACTION_ATTR_HASH,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_ACTION_ATTR_PUSH_MPLS,
   OVS_ACTION_ATTR_POP_MPLS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   OVS_ACTION_ATTR_SET_MASKED,
   OVS_ACTION_ATTR_CT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __OVS_ACTION_ATTR_MAX,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/pci_regs.h b/libc/kernel/uapi/linux/pci_regs.h
index 9e5bfac..1f58a3b 100644
--- a/libc/kernel/uapi/linux/pci_regs.h
+++ b/libc/kernel/uapi/linux/pci_regs.h
@@ -716,285 +716,301 @@
 #define PCI_EXT_CAP_ID_PMUX 0x1A
 #define PCI_EXT_CAP_ID_PASID 0x1B
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PASID
+#define PCI_EXT_CAP_ID_DPC 0x1D
+#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_DPC
 #define PCI_EXT_CAP_DSN_SIZEOF 12
 #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40
-#define PCI_ERR_UNCOR_STATUS 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_UNCOR_STATUS 4
 #define PCI_ERR_UNC_UND 0x00000001
 #define PCI_ERR_UNC_DLP 0x00000010
 #define PCI_ERR_UNC_SURPDN 0x00000020
-#define PCI_ERR_UNC_POISON_TLP 0x00001000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_UNC_POISON_TLP 0x00001000
 #define PCI_ERR_UNC_FCP 0x00002000
 #define PCI_ERR_UNC_COMP_TIME 0x00004000
 #define PCI_ERR_UNC_COMP_ABORT 0x00008000
-#define PCI_ERR_UNC_UNX_COMP 0x00010000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_UNC_UNX_COMP 0x00010000
 #define PCI_ERR_UNC_RX_OVER 0x00020000
 #define PCI_ERR_UNC_MALF_TLP 0x00040000
 #define PCI_ERR_UNC_ECRC 0x00080000
-#define PCI_ERR_UNC_UNSUP 0x00100000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_UNC_UNSUP 0x00100000
 #define PCI_ERR_UNC_ACSV 0x00200000
 #define PCI_ERR_UNC_INTN 0x00400000
 #define PCI_ERR_UNC_MCBTLP 0x00800000
-#define PCI_ERR_UNC_ATOMEG 0x01000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_UNC_ATOMEG 0x01000000
 #define PCI_ERR_UNC_TLPPRE 0x02000000
 #define PCI_ERR_UNCOR_MASK 8
 #define PCI_ERR_UNCOR_SEVER 12
-#define PCI_ERR_COR_STATUS 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_COR_STATUS 16
 #define PCI_ERR_COR_RCVR 0x00000001
 #define PCI_ERR_COR_BAD_TLP 0x00000040
 #define PCI_ERR_COR_BAD_DLLP 0x00000080
-#define PCI_ERR_COR_REP_ROLL 0x00000100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_COR_REP_ROLL 0x00000100
 #define PCI_ERR_COR_REP_TIMER 0x00001000
 #define PCI_ERR_COR_ADV_NFAT 0x00002000
 #define PCI_ERR_COR_INTERNAL 0x00004000
-#define PCI_ERR_COR_LOG_OVER 0x00008000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_COR_LOG_OVER 0x00008000
 #define PCI_ERR_COR_MASK 20
 #define PCI_ERR_CAP 24
 #define PCI_ERR_CAP_FEP(x) ((x) & 31)
-#define PCI_ERR_CAP_ECRC_GENC 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_CAP_ECRC_GENC 0x00000020
 #define PCI_ERR_CAP_ECRC_GENE 0x00000040
 #define PCI_ERR_CAP_ECRC_CHKC 0x00000080
 #define PCI_ERR_CAP_ECRC_CHKE 0x00000100
-#define PCI_ERR_HEADER_LOG 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_HEADER_LOG 28
 #define PCI_ERR_ROOT_COMMAND 44
 #define PCI_ERR_ROOT_CMD_COR_EN 0x00000001
 #define PCI_ERR_ROOT_CMD_NONFATAL_EN 0x00000002
-#define PCI_ERR_ROOT_CMD_FATAL_EN 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_ROOT_CMD_FATAL_EN 0x00000004
 #define PCI_ERR_ROOT_STATUS 48
 #define PCI_ERR_ROOT_COR_RCV 0x00000001
 #define PCI_ERR_ROOT_MULTI_COR_RCV 0x00000002
-#define PCI_ERR_ROOT_UNCOR_RCV 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_ROOT_UNCOR_RCV 0x00000004
 #define PCI_ERR_ROOT_MULTI_UNCOR_RCV 0x00000008
 #define PCI_ERR_ROOT_FIRST_FATAL 0x00000010
 #define PCI_ERR_ROOT_NONFATAL_RCV 0x00000020
-#define PCI_ERR_ROOT_FATAL_RCV 0x00000040
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ERR_ROOT_FATAL_RCV 0x00000040
 #define PCI_ERR_ROOT_ERR_SRC 52
 #define PCI_VC_PORT_CAP1 4
 #define PCI_VC_CAP1_EVCC 0x00000007
-#define PCI_VC_CAP1_LPEVCC 0x00000070
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VC_CAP1_LPEVCC 0x00000070
 #define PCI_VC_CAP1_ARB_SIZE 0x00000c00
 #define PCI_VC_PORT_CAP2 8
 #define PCI_VC_CAP2_32_PHASE 0x00000002
-#define PCI_VC_CAP2_64_PHASE 0x00000004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VC_CAP2_64_PHASE 0x00000004
 #define PCI_VC_CAP2_128_PHASE 0x00000008
 #define PCI_VC_CAP2_ARB_OFF 0xff000000
 #define PCI_VC_PORT_CTRL 12
-#define PCI_VC_PORT_CTRL_LOAD_TABLE 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VC_PORT_CTRL_LOAD_TABLE 0x00000001
 #define PCI_VC_PORT_STATUS 14
 #define PCI_VC_PORT_STATUS_TABLE 0x00000001
 #define PCI_VC_RES_CAP 16
-#define PCI_VC_RES_CAP_32_PHASE 0x00000002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VC_RES_CAP_32_PHASE 0x00000002
 #define PCI_VC_RES_CAP_64_PHASE 0x00000004
 #define PCI_VC_RES_CAP_128_PHASE 0x00000008
 #define PCI_VC_RES_CAP_128_PHASE_TB 0x00000010
-#define PCI_VC_RES_CAP_256_PHASE 0x00000020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VC_RES_CAP_256_PHASE 0x00000020
 #define PCI_VC_RES_CAP_ARB_OFF 0xff000000
 #define PCI_VC_RES_CTRL 20
 #define PCI_VC_RES_CTRL_LOAD_TABLE 0x00010000
-#define PCI_VC_RES_CTRL_ARB_SELECT 0x000e0000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VC_RES_CTRL_ARB_SELECT 0x000e0000
 #define PCI_VC_RES_CTRL_ID 0x07000000
 #define PCI_VC_RES_CTRL_ENABLE 0x80000000
 #define PCI_VC_RES_STATUS 26
-#define PCI_VC_RES_STATUS_TABLE 0x00000001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VC_RES_STATUS_TABLE 0x00000001
 #define PCI_VC_RES_STATUS_NEGO 0x00000002
 #define PCI_CAP_VC_BASE_SIZEOF 0x10
 #define PCI_CAP_VC_PER_VC_SIZEOF 0x0C
-#define PCI_PWR_DSR 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PWR_DSR 4
 #define PCI_PWR_DATA 8
 #define PCI_PWR_DATA_BASE(x) ((x) & 0xff)
 #define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3)
-#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7)
 #define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3)
 #define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7)
 #define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7)
-#define PCI_PWR_CAP 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PWR_CAP 12
 #define PCI_PWR_CAP_BUDGET(x) ((x) & 1)
 #define PCI_EXT_CAP_PWR_SIZEOF 16
 #define PCI_VNDR_HEADER 4
-#define PCI_VNDR_HEADER_ID(x) ((x) & 0xffff)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_VNDR_HEADER_ID(x) ((x) & 0xffff)
 #define PCI_VNDR_HEADER_REV(x) (((x) >> 16) & 0xf)
 #define PCI_VNDR_HEADER_LEN(x) (((x) >> 20) & 0xfff)
 #define HT_3BIT_CAP_MASK 0xE0
-#define HT_CAPTYPE_SLAVE 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HT_CAPTYPE_SLAVE 0x00
 #define HT_CAPTYPE_HOST 0x20
 #define HT_5BIT_CAP_MASK 0xF8
 #define HT_CAPTYPE_IRQ 0x80
-#define HT_CAPTYPE_REMAPPING_40 0xA0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HT_CAPTYPE_REMAPPING_40 0xA0
 #define HT_CAPTYPE_REMAPPING_64 0xA2
 #define HT_CAPTYPE_UNITID_CLUMP 0x90
 #define HT_CAPTYPE_EXTCONF 0x98
-#define HT_CAPTYPE_MSI_MAPPING 0xA8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HT_CAPTYPE_MSI_MAPPING 0xA8
 #define HT_MSI_FLAGS 0x02
 #define HT_MSI_FLAGS_ENABLE 0x1
 #define HT_MSI_FLAGS_FIXED 0x2
-#define HT_MSI_FIXED_ADDR 0x00000000FEE00000ULL
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HT_MSI_FIXED_ADDR 0x00000000FEE00000ULL
 #define HT_MSI_ADDR_LO 0x04
 #define HT_MSI_ADDR_LO_MASK 0xFFF00000
 #define HT_MSI_ADDR_HI 0x08
-#define HT_CAPTYPE_DIRECT_ROUTE 0xB0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HT_CAPTYPE_DIRECT_ROUTE 0xB0
 #define HT_CAPTYPE_VCSET 0xB8
 #define HT_CAPTYPE_ERROR_RETRY 0xC0
 #define HT_CAPTYPE_GEN3 0xD0
-#define HT_CAPTYPE_PM 0xE0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HT_CAPTYPE_PM 0xE0
 #define HT_CAP_SIZEOF_LONG 28
 #define HT_CAP_SIZEOF_SHORT 24
 #define PCI_ARI_CAP 0x04
-#define PCI_ARI_CAP_MFVC 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ARI_CAP_MFVC 0x0001
 #define PCI_ARI_CAP_ACS 0x0002
 #define PCI_ARI_CAP_NFN(x) (((x) >> 8) & 0xff)
 #define PCI_ARI_CTRL 0x06
-#define PCI_ARI_CTRL_MFVC 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ARI_CTRL_MFVC 0x0001
 #define PCI_ARI_CTRL_ACS 0x0002
 #define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7)
 #define PCI_EXT_CAP_ARI_SIZEOF 8
-#define PCI_ATS_CAP 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ATS_CAP 0x04
 #define PCI_ATS_CAP_QDEP(x) ((x) & 0x1f)
 #define PCI_ATS_MAX_QDEP 32
 #define PCI_ATS_CTRL 0x06
-#define PCI_ATS_CTRL_ENABLE 0x8000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ATS_CTRL_ENABLE 0x8000
 #define PCI_ATS_CTRL_STU(x) ((x) & 0x1f)
 #define PCI_ATS_MIN_STU 12
 #define PCI_EXT_CAP_ATS_SIZEOF 8
-#define PCI_PRI_CTRL 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PRI_CTRL 0x04
 #define PCI_PRI_CTRL_ENABLE 0x01
 #define PCI_PRI_CTRL_RESET 0x02
 #define PCI_PRI_STATUS 0x06
-#define PCI_PRI_STATUS_RF 0x001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PRI_STATUS_RF 0x001
 #define PCI_PRI_STATUS_UPRGI 0x002
 #define PCI_PRI_STATUS_STOPPED 0x100
 #define PCI_PRI_MAX_REQ 0x08
-#define PCI_PRI_ALLOC_REQ 0x0c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PRI_ALLOC_REQ 0x0c
 #define PCI_EXT_CAP_PRI_SIZEOF 16
 #define PCI_PASID_CAP 0x04
 #define PCI_PASID_CAP_EXEC 0x02
-#define PCI_PASID_CAP_PRIV 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PASID_CAP_PRIV 0x04
 #define PCI_PASID_CTRL 0x06
 #define PCI_PASID_CTRL_ENABLE 0x01
 #define PCI_PASID_CTRL_EXEC 0x02
-#define PCI_PASID_CTRL_PRIV 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_PASID_CTRL_PRIV 0x04
 #define PCI_EXT_CAP_PASID_SIZEOF 8
 #define PCI_SRIOV_CAP 0x04
 #define PCI_SRIOV_CAP_VFM 0x01
-#define PCI_SRIOV_CAP_INTR(x) ((x) >> 21)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SRIOV_CAP_INTR(x) ((x) >> 21)
 #define PCI_SRIOV_CTRL 0x08
 #define PCI_SRIOV_CTRL_VFE 0x01
 #define PCI_SRIOV_CTRL_VFM 0x02
-#define PCI_SRIOV_CTRL_INTR 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SRIOV_CTRL_INTR 0x04
 #define PCI_SRIOV_CTRL_MSE 0x08
 #define PCI_SRIOV_CTRL_ARI 0x10
 #define PCI_SRIOV_STATUS 0x0a
-#define PCI_SRIOV_STATUS_VFM 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SRIOV_STATUS_VFM 0x01
 #define PCI_SRIOV_INITIAL_VF 0x0c
 #define PCI_SRIOV_TOTAL_VF 0x0e
 #define PCI_SRIOV_NUM_VF 0x10
-#define PCI_SRIOV_FUNC_LINK 0x12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SRIOV_FUNC_LINK 0x12
 #define PCI_SRIOV_VF_OFFSET 0x14
 #define PCI_SRIOV_VF_STRIDE 0x16
 #define PCI_SRIOV_VF_DID 0x1a
-#define PCI_SRIOV_SUP_PGSIZE 0x1c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SRIOV_SUP_PGSIZE 0x1c
 #define PCI_SRIOV_SYS_PGSIZE 0x20
 #define PCI_SRIOV_BAR 0x24
 #define PCI_SRIOV_NUM_BARS 6
-#define PCI_SRIOV_VFM 0x3c
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SRIOV_VFM 0x3c
 #define PCI_SRIOV_VFM_BIR(x) ((x) & 7)
 #define PCI_SRIOV_VFM_OFFSET(x) ((x) & ~7)
 #define PCI_SRIOV_VFM_UA 0x0
-#define PCI_SRIOV_VFM_MI 0x1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SRIOV_VFM_MI 0x1
 #define PCI_SRIOV_VFM_MO 0x2
 #define PCI_SRIOV_VFM_AV 0x3
 #define PCI_EXT_CAP_SRIOV_SIZEOF 64
-#define PCI_LTR_MAX_SNOOP_LAT 0x4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_LTR_MAX_SNOOP_LAT 0x4
 #define PCI_LTR_MAX_NOSNOOP_LAT 0x6
 #define PCI_LTR_VALUE_MASK 0x000003ff
 #define PCI_LTR_SCALE_MASK 0x00001c00
-#define PCI_LTR_SCALE_SHIFT 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_LTR_SCALE_SHIFT 10
 #define PCI_EXT_CAP_LTR_SIZEOF 8
 #define PCI_ACS_CAP 0x04
 #define PCI_ACS_SV 0x01
-#define PCI_ACS_TB 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ACS_TB 0x02
 #define PCI_ACS_RR 0x04
 #define PCI_ACS_CR 0x08
 #define PCI_ACS_UF 0x10
-#define PCI_ACS_EC 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ACS_EC 0x20
 #define PCI_ACS_DT 0x40
 #define PCI_ACS_EGRESS_BITS 0x05
 #define PCI_ACS_CTRL 0x06
-#define PCI_ACS_EGRESS_CTL_V 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_ACS_EGRESS_CTL_V 0x08
 #define PCI_VSEC_HDR 4
 #define PCI_VSEC_HDR_LEN_SHIFT 20
 #define PCI_SATA_REGS 4
-#define PCI_SATA_REGS_MASK 0xF
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_SATA_REGS_MASK 0xF
 #define PCI_SATA_REGS_INLINE 0xF
 #define PCI_SATA_SIZEOF_SHORT 8
 #define PCI_SATA_SIZEOF_LONG 16
-#define PCI_REBAR_CTRL 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_REBAR_CTRL 8
 #define PCI_REBAR_CTRL_NBAR_MASK (7 << 5)
 #define PCI_REBAR_CTRL_NBAR_SHIFT 5
 #define PCI_DPA_CAP 4
-#define PCI_DPA_CAP_SUBSTATE_MASK 0x1F
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_DPA_CAP_SUBSTATE_MASK 0x1F
 #define PCI_DPA_BASE_SIZEOF 16
 #define PCI_TPH_CAP 4
 #define PCI_TPH_CAP_LOC_MASK 0x600
-#define PCI_TPH_LOC_NONE 0x000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_TPH_LOC_NONE 0x000
 #define PCI_TPH_LOC_CAP 0x200
 #define PCI_TPH_LOC_MSIX 0x400
 #define PCI_TPH_CAP_ST_MASK 0x07FF0000
-#define PCI_TPH_CAP_ST_SHIFT 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_TPH_CAP_ST_SHIFT 16
 #define PCI_TPH_BASE_SIZEOF 12
+#define PCI_EXP_DPC_CAP 4
+#define PCI_EXP_DPC_CAP_RP_EXT 0x20
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_EXP_DPC_CAP_POISONED_TLP 0x40
+#define PCI_EXP_DPC_CAP_SW_TRIGGER 0x80
+#define PCI_EXP_DPC_CAP_DL_ACTIVE 0x1000
+#define PCI_EXP_DPC_CTL 6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_EXP_DPC_CTL_EN_NONFATAL 0x02
+#define PCI_EXP_DPC_CTL_INT_EN 0x08
+#define PCI_EXP_DPC_STATUS 8
+#define PCI_EXP_DPC_STATUS_TRIGGER 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PCI_EXP_DPC_STATUS_INTERRUPT 0x08
+#define PCI_EXP_DPC_SOURCE_ID 10
 #endif
diff --git a/libc/kernel/uapi/linux/perf_event.h b/libc/kernel/uapi/linux/perf_event.h
index 0478470..22bf3f8 100644
--- a/libc/kernel/uapi/linux/perf_event.h
+++ b/libc/kernel/uapi/linux/perf_event.h
@@ -139,27 +139,32 @@
   PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 11,
   PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 12,
   PERF_SAMPLE_BRANCH_CALL_SHIFT = 13,
-  PERF_SAMPLE_BRANCH_MAX_SHIFT
+  PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 14,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 15,
+  PERF_SAMPLE_BRANCH_MAX_SHIFT
 };
 enum perf_branch_sample_type {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_USER = 1U << PERF_SAMPLE_BRANCH_USER_SHIFT,
   PERF_SAMPLE_BRANCH_KERNEL = 1U << PERF_SAMPLE_BRANCH_KERNEL_SHIFT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_HV = 1U << PERF_SAMPLE_BRANCH_HV_SHIFT,
   PERF_SAMPLE_BRANCH_ANY = 1U << PERF_SAMPLE_BRANCH_ANY_SHIFT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_ANY_CALL = 1U << PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT,
   PERF_SAMPLE_BRANCH_ANY_RETURN = 1U << PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_IND_CALL = 1U << PERF_SAMPLE_BRANCH_IND_CALL_SHIFT,
   PERF_SAMPLE_BRANCH_ABORT_TX = 1U << PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_IN_TX = 1U << PERF_SAMPLE_BRANCH_IN_TX_SHIFT,
   PERF_SAMPLE_BRANCH_NO_TX = 1U << PERF_SAMPLE_BRANCH_NO_TX_SHIFT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_COND = 1U << PERF_SAMPLE_BRANCH_COND_SHIFT,
   PERF_SAMPLE_BRANCH_CALL_STACK = 1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_IND_JUMP = 1U << PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT,
   PERF_SAMPLE_BRANCH_CALL = 1U << PERF_SAMPLE_BRANCH_CALL_SHIFT,
+  PERF_SAMPLE_BRANCH_NO_FLAGS = 1U << PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT,
+  PERF_SAMPLE_BRANCH_NO_CYCLES = 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
 };
@@ -216,7 +221,7 @@
   __u64 sample_type;
   __u64 read_format;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u64 disabled : 1, inherit : 1, pinned : 1, exclusive : 1, exclude_user : 1, exclude_kernel : 1, exclude_hv : 1, exclude_idle : 1, mmap : 1, comm : 1, freq : 1, inherit_stat : 1, enable_on_exec : 1, task : 1, watermark : 1, precise_ip : 2, mmap_data : 1, sample_id_all : 1, exclude_host : 1, exclude_guest : 1, exclude_callchain_kernel : 1, exclude_callchain_user : 1, mmap2 : 1, comm_exec : 1, use_clockid : 1, context_switch : 1, __reserved_1 : 37;
+  __u64 disabled : 1, inherit : 1, pinned : 1, exclusive : 1, exclude_user : 1, exclude_kernel : 1, exclude_hv : 1, exclude_idle : 1, mmap : 1, comm : 1, freq : 1, inherit_stat : 1, enable_on_exec : 1, task : 1, watermark : 1, precise_ip : 2, mmap_data : 1, sample_id_all : 1, exclude_host : 1, exclude_guest : 1, exclude_callchain_kernel : 1, exclude_callchain_user : 1, mmap2 : 1, comm_exec : 1, use_clockid : 1, context_switch : 1, write_backward : 1, __reserved_1 : 36;
   union {
     __u32 wakeup_events;
     __u32 wakeup_watermark;
@@ -256,173 +261,175 @@
 #define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *)
 #define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32)
 enum perf_event_ioc_flags {
   PERF_IOC_FLAG_GROUP = 1U << 0,
 };
-struct perf_event_mmap_page {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct perf_event_mmap_page {
   __u32 version;
   __u32 compat_version;
   __u32 lock;
-  __u32 index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 index;
   __s64 offset;
   __u64 time_enabled;
   __u64 time_running;
-  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union {
     __u64 capabilities;
     struct {
       __u64 cap_bit0 : 1, cap_bit0_is_deprecated : 1, cap_user_rdpmc : 1, cap_user_time : 1, cap_user_time_zero : 1, cap_____res : 59;
-    };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    };
   };
   __u16 pmc_width;
   __u16 time_shift;
-  __u32 time_mult;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 time_mult;
   __u64 time_offset;
   __u64 time_zero;
   __u32 size;
-  __u8 __reserved[118 * 8 + 4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 __reserved[118 * 8 + 4];
   __u64 data_head;
   __u64 data_tail;
   __u64 data_offset;
-  __u64 data_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 data_size;
   __u64 aux_head;
   __u64 aux_tail;
   __u64 aux_offset;
-  __u64 aux_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 aux_size;
 };
 #define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0)
 #define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0)
-#define PERF_RECORD_MISC_KERNEL (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PERF_RECORD_MISC_KERNEL (1 << 0)
 #define PERF_RECORD_MISC_USER (2 << 0)
 #define PERF_RECORD_MISC_HYPERVISOR (3 << 0)
 #define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0)
-#define PERF_RECORD_MISC_GUEST_USER (5 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PERF_RECORD_MISC_GUEST_USER (5 << 0)
 #define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12)
 #define PERF_RECORD_MISC_MMAP_DATA (1 << 13)
 #define PERF_RECORD_MISC_COMM_EXEC (1 << 13)
-#define PERF_RECORD_MISC_SWITCH_OUT (1 << 13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PERF_RECORD_MISC_SWITCH_OUT (1 << 13)
 #define PERF_RECORD_MISC_EXACT_IP (1 << 14)
 #define PERF_RECORD_MISC_EXT_RESERVED (1 << 15)
 struct perf_event_header {
-  __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 type;
   __u16 misc;
   __u16 size;
 };
-enum perf_event_type {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum perf_event_type {
   PERF_RECORD_MMAP = 1,
   PERF_RECORD_LOST = 2,
   PERF_RECORD_COMM = 3,
-  PERF_RECORD_EXIT = 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  PERF_RECORD_EXIT = 4,
   PERF_RECORD_THROTTLE = 5,
   PERF_RECORD_UNTHROTTLE = 6,
   PERF_RECORD_FORK = 7,
-  PERF_RECORD_READ = 8,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  PERF_RECORD_READ = 8,
   PERF_RECORD_SAMPLE = 9,
   PERF_RECORD_MMAP2 = 10,
   PERF_RECORD_AUX = 11,
-  PERF_RECORD_ITRACE_START = 12,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  PERF_RECORD_ITRACE_START = 12,
   PERF_RECORD_LOST_SAMPLES = 13,
   PERF_RECORD_SWITCH = 14,
   PERF_RECORD_SWITCH_CPU_WIDE = 15,
-  PERF_RECORD_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  PERF_RECORD_MAX,
 };
 #define PERF_MAX_STACK_DEPTH 127
+#define PERF_MAX_CONTEXTS_PER_STACK 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum perf_callchain_context {
   PERF_CONTEXT_HV = (__u64) - 32,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_CONTEXT_KERNEL = (__u64) - 128,
   PERF_CONTEXT_USER = (__u64) - 512,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_CONTEXT_GUEST = (__u64) - 2048,
   PERF_CONTEXT_GUEST_KERNEL = (__u64) - 2176,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PERF_CONTEXT_GUEST_USER = (__u64) - 2560,
   PERF_CONTEXT_MAX = (__u64) - 4095,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define PERF_AUX_FLAG_TRUNCATED 0x01
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_AUX_FLAG_OVERWRITE 0x02
 #define PERF_FLAG_FD_NO_GROUP (1UL << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_FLAG_FD_OUTPUT (1UL << 1)
 #define PERF_FLAG_PID_CGROUP (1UL << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_FLAG_FD_CLOEXEC (1UL << 3)
 union perf_mem_data_src {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 val;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u64 mem_op : 5, mem_lvl : 14, mem_snoop : 5, mem_lock : 2, mem_dtlb : 7, mem_rsvd : 31;
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define PERF_MEM_OP_NA 0x01
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_OP_LOAD 0x02
 #define PERF_MEM_OP_STORE 0x04
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_OP_PFETCH 0x08
 #define PERF_MEM_OP_EXEC 0x10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_OP_SHIFT 0
 #define PERF_MEM_LVL_NA 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LVL_HIT 0x02
 #define PERF_MEM_LVL_MISS 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LVL_L1 0x08
 #define PERF_MEM_LVL_LFB 0x10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LVL_L2 0x20
 #define PERF_MEM_LVL_L3 0x40
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LVL_LOC_RAM 0x80
 #define PERF_MEM_LVL_REM_RAM1 0x100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LVL_REM_RAM2 0x200
 #define PERF_MEM_LVL_REM_CCE1 0x400
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LVL_REM_CCE2 0x800
 #define PERF_MEM_LVL_IO 0x1000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LVL_UNC 0x2000
 #define PERF_MEM_LVL_SHIFT 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_SNOOP_NA 0x01
 #define PERF_MEM_SNOOP_NONE 0x02
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_SNOOP_HIT 0x04
 #define PERF_MEM_SNOOP_MISS 0x08
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_SNOOP_HITM 0x10
 #define PERF_MEM_SNOOP_SHIFT 19
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LOCK_NA 0x01
 #define PERF_MEM_LOCK_LOCKED 0x02
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_LOCK_SHIFT 24
 #define PERF_MEM_TLB_NA 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_TLB_HIT 0x02
 #define PERF_MEM_TLB_MISS 0x04
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_TLB_L1 0x08
 #define PERF_MEM_TLB_L2 0x10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_TLB_WK 0x20
 #define PERF_MEM_TLB_OS 0x40
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PERF_MEM_TLB_SHIFT 26
 #define PERF_MEM_S(a,s) (((__u64) PERF_MEM_ ##a ##_ ##s) << PERF_MEM_ ##a ##_SHIFT)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct perf_branch_entry {
   __u64 from;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 to;
   __u64 mispred : 1, predicted : 1, in_tx : 1, abort : 1, cycles : 16, reserved : 44;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/pkt_cls.h b/libc/kernel/uapi/linux/pkt_cls.h
index 99d9873..55431b0 100644
--- a/libc/kernel/uapi/linux/pkt_cls.h
+++ b/libc/kernel/uapi/linux/pkt_cls.h
@@ -28,347 +28,357 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_ACT_INDEX,
   TCA_ACT_STATS,
+  TCA_ACT_PAD,
   __TCA_ACT_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCA_ACT_MAX __TCA_ACT_MAX
 #define TCA_OLD_COMPAT (TCA_ACT_MAX + 1)
 #define TCA_ACT_MAX_PRIO 32
-#define TCA_ACT_BIND 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_ACT_BIND 1
 #define TCA_ACT_NOBIND 0
 #define TCA_ACT_UNBIND 1
 #define TCA_ACT_NOUNBIND 0
-#define TCA_ACT_REPLACE 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_ACT_REPLACE 1
 #define TCA_ACT_NOREPLACE 0
 #define TC_ACT_UNSPEC (- 1)
 #define TC_ACT_OK 0
-#define TC_ACT_RECLASSIFY 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_ACT_RECLASSIFY 1
 #define TC_ACT_SHOT 2
 #define TC_ACT_PIPE 3
 #define TC_ACT_STOLEN 4
-#define TC_ACT_QUEUED 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_ACT_QUEUED 5
 #define TC_ACT_REPEAT 6
 #define TC_ACT_REDIRECT 7
 #define TC_ACT_JUMP 0x10000000
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   TCA_ID_UNSPEC = 0,
   TCA_ID_POLICE = 1,
   __TCA_ID_MAX = 255
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCA_ID_MAX __TCA_ID_MAX
 struct tc_police {
   __u32 index;
-  int action;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int action;
 #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
 #define TC_POLICE_OK TC_ACT_OK
 #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
-#define TC_POLICE_SHOT TC_ACT_SHOT
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_POLICE_SHOT TC_ACT_SHOT
 #define TC_POLICE_PIPE TC_ACT_PIPE
   __u32 limit;
   __u32 burst;
-  __u32 mtu;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 mtu;
   struct tc_ratespec rate;
   struct tc_ratespec peakrate;
   int refcnt;
-  int bindcnt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int bindcnt;
   __u32 capab;
 };
 struct tcf_t {
-  __u64 install;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 install;
   __u64 lastuse;
   __u64 expires;
 };
-struct tc_cnt {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct tc_cnt {
   int refcnt;
   int bindcnt;
 };
-#define tc_gen __u32 index; __u32 capab; int action; int refcnt; int bindcnt
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define tc_gen __u32 index; __u32 capab; int action; int refcnt; int bindcnt
 enum {
   TCA_POLICE_UNSPEC,
   TCA_POLICE_TBF,
-  TCA_POLICE_RATE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_POLICE_RATE,
   TCA_POLICE_PEAKRATE,
   TCA_POLICE_AVRATE,
   TCA_POLICE_RESULT,
-  __TCA_POLICE_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_POLICE_TM,
+  TCA_POLICE_PAD,
+  __TCA_POLICE_MAX
 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
-#define TC_U32_HTID(h) ((h) & 0xFFF00000)
+#define TCA_CLS_FLAGS_SKIP_HW (1 << 0)
+#define TCA_CLS_FLAGS_SKIP_SW (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_U32_HTID(h) ((h) & 0xFFF00000)
 #define TC_U32_USERHTID(h) (TC_U32_HTID(h) >> 20)
 #define TC_U32_HASH(h) (((h) >> 12) & 0xFF)
 #define TC_U32_NODE(h) ((h) & 0xFFF)
-#define TC_U32_KEY(h) ((h) & 0xFFFFF)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_U32_KEY(h) ((h) & 0xFFFFF)
 #define TC_U32_UNSPEC 0
 #define TC_U32_ROOT (0xFFF00000)
 enum {
-  TCA_U32_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_U32_UNSPEC,
   TCA_U32_CLASSID,
   TCA_U32_HASH,
   TCA_U32_LINK,
-  TCA_U32_DIVISOR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_U32_DIVISOR,
   TCA_U32_SEL,
   TCA_U32_POLICE,
   TCA_U32_ACT,
-  TCA_U32_INDEV,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_U32_INDEV,
   TCA_U32_PCNT,
   TCA_U32_MARK,
+  TCA_U32_FLAGS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_U32_PAD,
   __TCA_U32_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_U32_MAX (__TCA_U32_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_u32_key {
   __be32 mask;
   __be32 val;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int off;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int offmask;
 };
 struct tc_u32_sel {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char offshift;
   unsigned char nkeys;
   __be16 offmask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 off;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   short offoff;
   short hoff;
   __be32 hmask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct tc_u32_key keys[0];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct tc_u32_mark {
   __u32 val;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 success;
 };
 struct tc_u32_pcnt {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 rcnt;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 rhit;
   __u64 kcnts[0];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TC_U32_TERMINAL 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TC_U32_OFFSET 2
 #define TC_U32_VAROFFSET 4
 #define TC_U32_EAT 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TC_U32_MAXDEPTH 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   TCA_RSVP_UNSPEC,
   TCA_RSVP_CLASSID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_RSVP_DST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_RSVP_SRC,
   TCA_RSVP_PINFO,
   TCA_RSVP_POLICE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_RSVP_ACT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_RSVP_MAX
 };
 #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_rsvp_gpi {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 key;
   __u32 mask;
   int offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_rsvp_pinfo {
   struct tc_rsvp_gpi dpi;
   struct tc_rsvp_gpi spi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 protocol;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 tunnelid;
   __u8 tunnelhdr;
   __u8 pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   TCA_ROUTE4_UNSPEC,
   TCA_ROUTE4_CLASSID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_ROUTE4_TO,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_ROUTE4_FROM,
   TCA_ROUTE4_IIF,
   TCA_ROUTE4_POLICE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_ROUTE4_ACT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_ROUTE4_MAX
 };
 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FW_UNSPEC,
   TCA_FW_CLASSID,
   TCA_FW_POLICE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FW_INDEV,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FW_ACT,
   TCA_FW_MASK,
   __TCA_FW_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_FW_MAX (__TCA_FW_MAX - 1)
 enum {
   TCA_TCINDEX_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TCINDEX_HASH,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TCINDEX_MASK,
   TCA_TCINDEX_SHIFT,
   TCA_TCINDEX_FALL_THROUGH,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TCINDEX_CLASSID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TCINDEX_POLICE,
   TCA_TCINDEX_ACT,
   __TCA_TCINDEX_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
 enum {
   FLOW_KEY_SRC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_DST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_PROTO,
   FLOW_KEY_PROTO_SRC,
   FLOW_KEY_PROTO_DST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_IIF,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_PRIORITY,
   FLOW_KEY_MARK,
   FLOW_KEY_NFCT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_NFCT_SRC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_NFCT_DST,
   FLOW_KEY_NFCT_PROTO_SRC,
   FLOW_KEY_NFCT_PROTO_DST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_RTCLASSID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_SKUID,
   FLOW_KEY_SKGID,
   FLOW_KEY_VLAN_TAG,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_KEY_RXHASH,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __FLOW_KEY_MAX,
 };
 #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   FLOW_MODE_MAP,
   FLOW_MODE_HASH,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOW_UNSPEC,
   TCA_FLOW_KEYS,
   TCA_FLOW_MODE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOW_BASECLASS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOW_RSHIFT,
   TCA_FLOW_ADDEND,
   TCA_FLOW_MASK,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOW_XOR,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOW_DIVISOR,
   TCA_FLOW_ACT,
   TCA_FLOW_POLICE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOW_EMATCHES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOW_PERTURB,
   __TCA_FLOW_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   TCA_BASIC_UNSPEC,
   TCA_BASIC_CLASSID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_BASIC_EMATCHES,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_BASIC_ACT,
   TCA_BASIC_POLICE,
   __TCA_BASIC_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
 enum {
   TCA_CGROUP_UNSPEC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_CGROUP_ACT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_CGROUP_POLICE,
   TCA_CGROUP_EMATCHES,
   __TCA_CGROUP_MAX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
 #define TCA_BPF_FLAG_ACT_DIRECT (1 << 0)
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_BPF_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_BPF_ACT,
   TCA_BPF_POLICE,
   TCA_BPF_CLASSID,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_BPF_OPS_LEN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_BPF_OPS,
   TCA_BPF_FD,
   TCA_BPF_NAME,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_BPF_FLAGS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_BPF_MAX,
 };
 #define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_UNSPEC,
   TCA_FLOWER_CLASSID,
   TCA_FLOWER_INDEV,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_ACT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_ETH_DST,
   TCA_FLOWER_KEY_ETH_DST_MASK,
   TCA_FLOWER_KEY_ETH_SRC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_ETH_SRC_MASK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_ETH_TYPE,
   TCA_FLOWER_KEY_IP_PROTO,
   TCA_FLOWER_KEY_IPV4_SRC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_IPV4_SRC_MASK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_IPV4_DST,
   TCA_FLOWER_KEY_IPV4_DST_MASK,
   TCA_FLOWER_KEY_IPV6_SRC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_IPV6_SRC_MASK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_IPV6_DST,
   TCA_FLOWER_KEY_IPV6_DST_MASK,
   TCA_FLOWER_KEY_TCP_SRC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_TCP_DST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FLOWER_KEY_UDP_SRC,
   TCA_FLOWER_KEY_UDP_DST,
+  TCA_FLOWER_FLAGS,
   __TCA_FLOWER_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
diff --git a/libc/kernel/uapi/linux/pkt_sched.h b/libc/kernel/uapi/linux/pkt_sched.h
index 14ffcd4..1d111dd 100644
--- a/libc/kernel/uapi/linux/pkt_sched.h
+++ b/libc/kernel/uapi/linux/pkt_sched.h
@@ -56,92 +56,97 @@
 #define TC_H_ROOT (0xFFFFFFFFU)
 #define TC_H_INGRESS (0xFFFFFFF1U)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_H_CLSACT TC_H_INGRESS
+#define TC_H_MIN_INGRESS 0xFFF2U
+#define TC_H_MIN_EGRESS 0xFFF3U
 enum tc_link_layer {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TC_LINKLAYER_UNAWARE,
   TC_LINKLAYER_ETHERNET,
   TC_LINKLAYER_ATM,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TC_LINKLAYER_MASK 0x0F
 struct tc_ratespec {
   unsigned char cell_log;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 linklayer;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short overhead;
   short cell_align;
   unsigned short mpu;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rate;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define TC_RTAB_SIZE 1024
 struct tc_sizespec {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char cell_log;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char size_log;
   short cell_align;
   int overhead;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int linklayer;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int mpu;
   unsigned int mtu;
   unsigned int tsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   TCA_STAB_UNSPEC,
   TCA_STAB_BASE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_STAB_DATA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_STAB_MAX
 };
 #define TCA_STAB_MAX (__TCA_STAB_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_fifo_qopt {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 limit;
 };
 #define TCQ_PRIO_BANDS 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCQ_MIN_PRIO_BANDS 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_prio_qopt {
   int bands;
   __u8 priomap[TC_PRIO_MAX + 1];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_multiq_qopt {
   __u16 bands;
   __u16 max_bands;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCQ_PLUG_BUFFER 0
 #define TCQ_PLUG_RELEASE_ONE 1
 #define TCQ_PLUG_RELEASE_INDEFINITE 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCQ_PLUG_LIMIT 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_plug_qopt {
   int action;
   __u32 limit;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_tbf_qopt {
   struct tc_ratespec rate;
   struct tc_ratespec peakrate;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 limit;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 buffer;
   __u32 mtu;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TBF_UNSPEC,
   TCA_TBF_PARMS,
   TCA_TBF_RTAB,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TBF_PTAB,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TBF_RATE64,
   TCA_TBF_PRATE64,
   TCA_TBF_BURST,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_TBF_PBURST,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_TBF_PAD,
   __TCA_TBF_MAX,
 };
 #define TCA_TBF_MAX (__TCA_TBF_MAX - 1)
@@ -328,345 +333,350 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_HTB_RATE64,
   TCA_HTB_CEIL64,
+  TCA_HTB_PAD,
   __TCA_HTB_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCA_HTB_MAX (__TCA_HTB_MAX - 1)
 struct tc_htb_xstats {
   __u32 lends;
-  __u32 borrows;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 borrows;
   __u32 giants;
   __u32 tokens;
   __u32 ctokens;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct tc_hfsc_qopt {
   __u16 defcls;
 };
-struct tc_service_curve {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct tc_service_curve {
   __u32 m1;
   __u32 d;
   __u32 m2;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct tc_hfsc_stats {
   __u64 work;
   __u64 rtwork;
-  __u32 period;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 period;
   __u32 level;
 };
 enum {
-  TCA_HFSC_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_HFSC_UNSPEC,
   TCA_HFSC_RSC,
   TCA_HFSC_FSC,
   TCA_HFSC_USC,
-  __TCA_HFSC_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __TCA_HFSC_MAX,
 };
 #define TCA_HFSC_MAX (__TCA_HFSC_MAX - 1)
 #define TC_CBQ_MAXPRIO 8
-#define TC_CBQ_MAXLEVEL 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_CBQ_MAXLEVEL 8
 #define TC_CBQ_DEF_EWMA 5
 struct tc_cbq_lssopt {
   unsigned char change;
-  unsigned char flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char flags;
 #define TCF_CBQ_LSS_BOUNDED 1
 #define TCF_CBQ_LSS_ISOLATED 2
   unsigned char ewma_log;
-  unsigned char level;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char level;
 #define TCF_CBQ_LSS_FLAGS 1
 #define TCF_CBQ_LSS_EWMA 2
 #define TCF_CBQ_LSS_MAXIDLE 4
-#define TCF_CBQ_LSS_MINIDLE 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCF_CBQ_LSS_MINIDLE 8
 #define TCF_CBQ_LSS_OFFTIME 0x10
 #define TCF_CBQ_LSS_AVPKT 0x20
   __u32 maxidle;
-  __u32 minidle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 minidle;
   __u32 offtime;
   __u32 avpkt;
 };
-struct tc_cbq_wrropt {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct tc_cbq_wrropt {
   unsigned char flags;
   unsigned char priority;
   unsigned char cpriority;
-  unsigned char __reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char __reserved;
   __u32 allot;
   __u32 weight;
 };
-struct tc_cbq_ovl {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct tc_cbq_ovl {
   unsigned char strategy;
 #define TC_CBQ_OVL_CLASSIC 0
 #define TC_CBQ_OVL_DELAY 1
-#define TC_CBQ_OVL_LOWPRIO 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TC_CBQ_OVL_LOWPRIO 2
 #define TC_CBQ_OVL_DROP 3
 #define TC_CBQ_OVL_RCLASSIC 4
   unsigned char priority2;
-  __u16 pad;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 pad;
   __u32 penalty;
 };
 struct tc_cbq_police {
-  unsigned char police;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char police;
   unsigned char __res1;
   unsigned short __res2;
 };
-struct tc_cbq_fopt {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct tc_cbq_fopt {
   __u32 split;
   __u32 defmap;
   __u32 defchange;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct tc_cbq_xstats {
   __u32 borrows;
   __u32 overactions;
-  __s32 avgidle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 avgidle;
   __s32 undertime;
 };
 enum {
-  TCA_CBQ_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_CBQ_UNSPEC,
   TCA_CBQ_LSSOPT,
   TCA_CBQ_WRROPT,
   TCA_CBQ_FOPT,
-  TCA_CBQ_OVL_STRATEGY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_CBQ_OVL_STRATEGY,
   TCA_CBQ_RATE,
   TCA_CBQ_RTAB,
   TCA_CBQ_POLICE,
-  __TCA_CBQ_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __TCA_CBQ_MAX,
 };
 #define TCA_CBQ_MAX (__TCA_CBQ_MAX - 1)
 enum {
-  TCA_DSMARK_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_DSMARK_UNSPEC,
   TCA_DSMARK_INDICES,
   TCA_DSMARK_DEFAULT_INDEX,
   TCA_DSMARK_SET_TC_INDEX,
-  TCA_DSMARK_MASK,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_DSMARK_MASK,
   TCA_DSMARK_VALUE,
   __TCA_DSMARK_MAX,
 };
-#define TCA_DSMARK_MAX (__TCA_DSMARK_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_DSMARK_MAX (__TCA_DSMARK_MAX - 1)
 enum {
   TCA_ATM_UNSPEC,
   TCA_ATM_FD,
-  TCA_ATM_PTR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_ATM_PTR,
   TCA_ATM_HDR,
   TCA_ATM_EXCESS,
   TCA_ATM_ADDR,
-  TCA_ATM_STATE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_ATM_STATE,
   __TCA_ATM_MAX,
 };
 #define TCA_ATM_MAX (__TCA_ATM_MAX - 1)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   TCA_NETEM_UNSPEC,
   TCA_NETEM_CORR,
   TCA_NETEM_DELAY_DIST,
-  TCA_NETEM_REORDER,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_NETEM_REORDER,
   TCA_NETEM_CORRUPT,
   TCA_NETEM_LOSS,
   TCA_NETEM_RATE,
-  TCA_NETEM_ECN,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_NETEM_ECN,
   TCA_NETEM_RATE64,
+  TCA_NETEM_PAD,
   __TCA_NETEM_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define TCA_NETEM_MAX (__TCA_NETEM_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_netem_qopt {
   __u32 latency;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 limit;
   __u32 loss;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 gap;
   __u32 duplicate;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 jitter;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_netem_corr {
   __u32 delay_corr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 loss_corr;
   __u32 dup_corr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct tc_netem_reorder {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 probability;
   __u32 correlation;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct tc_netem_corrupt {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 probability;
   __u32 correlation;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct tc_netem_rate {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rate;
   __s32 packet_overhead;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 cell_size;
   __s32 cell_overhead;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NETEM_LOSS_UNSPEC,
   NETEM_LOSS_GI,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NETEM_LOSS_GE,
   __NETEM_LOSS_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NETEM_LOSS_MAX (__NETEM_LOSS_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_netem_gimodel {
   __u32 p13;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 p31;
   __u32 p32;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 p14;
   __u32 p23;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct tc_netem_gemodel {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 p;
   __u32 r;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 h;
   __u32 k1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define NETEM_DIST_SCALE 8192
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NETEM_DIST_MAX 16384
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_DRR_UNSPEC,
   TCA_DRR_QUANTUM,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_DRR_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_DRR_MAX (__TCA_DRR_MAX - 1)
 struct tc_drr_stats {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 deficit;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TC_QOPT_BITMASK 15
 #define TC_QOPT_MAX_QUEUE 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_mqprio_qopt {
   __u8 num_tc;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 prio_tc_map[TC_QOPT_BITMASK + 1];
   __u8 hw;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 count[TC_QOPT_MAX_QUEUE];
   __u16 offset[TC_QOPT_MAX_QUEUE];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_SFB_UNSPEC,
   TCA_SFB_PARMS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_SFB_MAX,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_SFB_MAX (__TCA_SFB_MAX - 1)
 struct tc_sfb_qopt {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rehash_interval;
   __u32 warmup_time;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 max;
   __u32 bin_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 increment;
   __u32 decrement;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 limit;
   __u32 penalty_rate;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 penalty_burst;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tc_sfb_xstats {
   __u32 earlydrop;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 penaltydrop;
   __u32 bucketdrop;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 queuedrop;
   __u32 childdrop;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 marked;
   __u32 maxqlen;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 maxprob;
   __u32 avgprob;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SFB_MAX_PROB 0xFFFF
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   TCA_QFQ_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_QFQ_WEIGHT,
   TCA_QFQ_LMAX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_QFQ_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_QFQ_MAX (__TCA_QFQ_MAX - 1)
 struct tc_qfq_stats {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 weight;
   __u32 lmax;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_CODEL_UNSPEC,
   TCA_CODEL_TARGET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_CODEL_LIMIT,
   TCA_CODEL_INTERVAL,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_CODEL_ECN,
   TCA_CODEL_CE_THRESHOLD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_CODEL_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_CODEL_MAX (__TCA_CODEL_MAX - 1)
 struct tc_codel_xstats {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 maxpacket;
   __u32 count;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 lastcount;
   __u32 ldelay;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 drop_next;
   __u32 drop_overlimit;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 ecn_mark;
   __u32 dropping;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 ce_mark;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   TCA_FQ_CODEL_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_CODEL_TARGET,
   TCA_FQ_CODEL_LIMIT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_CODEL_INTERVAL,
   TCA_FQ_CODEL_ECN,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_CODEL_FLOWS,
   TCA_FQ_CODEL_QUANTUM,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_CODEL_CE_THRESHOLD,
+  TCA_FQ_CODEL_DROP_BATCH_SIZE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_FQ_CODEL_MEMORY_LIMIT,
   __TCA_FQ_CODEL_MAX
 };
 #define TCA_FQ_CODEL_MAX (__TCA_FQ_CODEL_MAX - 1)
@@ -686,110 +696,113 @@
   __u32 old_flows_len;
   __u32 ce_mark;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 memory_usage;
+  __u32 drop_overmemory;
 };
 struct tc_fq_codel_cl_stats {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 deficit;
   __u32 ldelay;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 count;
   __u32 lastcount;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 dropping;
   __s32 drop_next;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct tc_fq_codel_xstats {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct tc_fq_codel_qd_stats qdisc_stats;
     struct tc_fq_codel_cl_stats class_stats;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   TCA_FQ_UNSPEC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_PLIMIT,
   TCA_FQ_FLOW_PLIMIT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_QUANTUM,
   TCA_FQ_INITIAL_QUANTUM,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_RATE_ENABLE,
   TCA_FQ_FLOW_DEFAULT_RATE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_FLOW_MAX_RATE,
   TCA_FQ_BUCKETS_LOG,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FQ_FLOW_REFILL_DELAY,
   TCA_FQ_ORPHAN_MASK,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_FQ_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_FQ_MAX (__TCA_FQ_MAX - 1)
 struct tc_fq_qd_stats {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 gc_flows;
   __u64 highprio_packets;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 tcp_retrans;
   __u64 throttled;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 flows_plimit;
   __u64 pkts_too_long;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 allocation_errors;
   __s64 time_next_delayed_flow;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flows;
   __u32 inactive_flows;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 throttled_flows;
   __u32 pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_HHF_UNSPEC,
   TCA_HHF_BACKLOG_LIMIT,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_HHF_QUANTUM,
   TCA_HHF_HH_FLOWS_LIMIT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_HHF_RESET_TIMEOUT,
   TCA_HHF_ADMIT_BYTES,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_HHF_EVICT_TIMEOUT,
   TCA_HHF_NON_HH_WEIGHT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_HHF_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_HHF_MAX (__TCA_HHF_MAX - 1)
 struct tc_hhf_xstats {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 drop_overlimit;
   __u32 hh_overlimit;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 hh_tot_count;
   __u32 hh_cur_count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_PIE_UNSPEC,
   TCA_PIE_TARGET,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_PIE_LIMIT,
   TCA_PIE_TUPDATE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_PIE_ALPHA,
   TCA_PIE_BETA,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_PIE_ECN,
   TCA_PIE_BYTEMODE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_PIE_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_PIE_MAX (__TCA_PIE_MAX - 1)
 struct tc_pie_xstats {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 prob;
   __u32 delay;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 avg_dq_rate;
   __u32 packets_in;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 dropped;
   __u32 overlimit;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 maxq;
   __u32 ecn_mark;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/ptp_clock.h b/libc/kernel/uapi/linux/ptp_clock.h
index bb9d6d9..fb656bb 100644
--- a/libc/kernel/uapi/linux/ptp_clock.h
+++ b/libc/kernel/uapi/linux/ptp_clock.h
@@ -39,57 +39,67 @@
   int n_per_out;
   int pps;
   int n_pins;
-  int rsv[14];
+  int cross_timestamping;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int rsv[13];
 };
 struct ptp_extts_request {
   unsigned int index;
-  unsigned int flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int flags;
   unsigned int rsv[2];
 };
 struct ptp_perout_request {
-  struct ptp_clock_time start;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ptp_clock_time start;
   struct ptp_clock_time period;
   unsigned int index;
   unsigned int flags;
-  unsigned int rsv[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int rsv[4];
 };
 #define PTP_MAX_SAMPLES 25
 struct ptp_sys_offset {
-  unsigned int n_samples;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int n_samples;
   unsigned int rsv[3];
   struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
 };
-enum ptp_pin_function {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ptp_sys_offset_precise {
+  struct ptp_clock_time device;
+  struct ptp_clock_time sys_realtime;
+  struct ptp_clock_time sys_monoraw;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int rsv[4];
+};
+enum ptp_pin_function {
   PTP_PF_NONE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PTP_PF_EXTTS,
   PTP_PF_PEROUT,
   PTP_PF_PHYSYNC,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ptp_pin_desc {
   char name[64];
   unsigned int index;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int func;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int chan;
   unsigned int rsv[5];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTP_CLK_MAGIC '='
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
 #define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
 #define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTP_SYS_OFFSET _IOW(PTP_CLK_MAGIC, 5, struct ptp_sys_offset)
 #define PTP_PIN_GETFUNC _IOWR(PTP_CLK_MAGIC, 6, struct ptp_pin_desc)
 #define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
+#define PTP_SYS_OFFSET_PRECISE _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ptp_extts_event {
   struct ptp_clock_time t;
diff --git a/libc/kernel/uapi/linux/if_pppopns.h b/libc/kernel/uapi/linux/qrtr.h
similarity index 78%
rename from libc/kernel/uapi/linux/if_pppopns.h
rename to libc/kernel/uapi/linux/qrtr.h
index bd96e94..6a5cd6d 100644
--- a/libc/kernel/uapi/linux/if_pppopns.h
+++ b/libc/kernel/uapi/linux/qrtr.h
@@ -16,18 +16,14 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _UAPI_LINUX_IF_PPPOPNS_H
-#define _UAPI_LINUX_IF_PPPOPNS_H
+#ifndef _LINUX_QRTR_H
+#define _LINUX_QRTR_H
 #include <linux/socket.h>
-#include <linux/types.h>
+struct sockaddr_qrtr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sockaddr_pppopns {
-  sa_family_t sa_family;
-  unsigned int sa_protocol;
-  int tcp_socket;
+  __kernel_sa_family_t sq_family;
+  __u32 sq_node;
+  __u32 sq_port;
+};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 local;
-  __u16 remote;
-} __attribute__((packed));
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/quota.h b/libc/kernel/uapi/linux/quota.h
index 2c5485f..1d59adb 100644
--- a/libc/kernel/uapi/linux/quota.h
+++ b/libc/kernel/uapi/linux/quota.h
@@ -43,38 +43,53 @@
 #define Q_GETQUOTA 0x800007
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define Q_SETQUOTA 0x800008
+#define Q_GETNEXTQUOTA 0x800009
 #define QFMT_VFS_OLD 1
 #define QFMT_VFS_V0 2
-#define QFMT_OCFS2 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QFMT_OCFS2 3
 #define QFMT_VFS_V1 4
 #define QIF_DQBLKSIZE_BITS 10
 #define QIF_DQBLKSIZE (1 << QIF_DQBLKSIZE_BITS)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   QIF_BLIMITS_B = 0,
   QIF_SPACE_B,
   QIF_ILIMITS_B,
-  QIF_INODES_B,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  QIF_INODES_B,
   QIF_BTIME_B,
   QIF_ITIME_B,
 };
-#define QIF_BLIMITS (1 << QIF_BLIMITS_B)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QIF_BLIMITS (1 << QIF_BLIMITS_B)
 #define QIF_SPACE (1 << QIF_SPACE_B)
 #define QIF_ILIMITS (1 << QIF_ILIMITS_B)
 #define QIF_INODES (1 << QIF_INODES_B)
-#define QIF_BTIME (1 << QIF_BTIME_B)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QIF_BTIME (1 << QIF_BTIME_B)
 #define QIF_ITIME (1 << QIF_ITIME_B)
 #define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
 #define QIF_USAGE (QIF_SPACE | QIF_INODES)
-#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
 #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
 struct if_dqblk {
   __u64 dqb_bhardlimit;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 dqb_bsoftlimit;
+  __u64 dqb_curspace;
+  __u64 dqb_ihardlimit;
+  __u64 dqb_isoftlimit;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 dqb_curinodes;
+  __u64 dqb_btime;
+  __u64 dqb_itime;
+  __u32 dqb_valid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct if_nextdqblk {
+  __u64 dqb_bhardlimit;
   __u64 dqb_bsoftlimit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 dqb_curspace;
@@ -85,62 +100,65 @@
   __u64 dqb_btime;
   __u64 dqb_itime;
   __u32 dqb_valid;
-};
+  __u32 dqb_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define IIF_BGRACE 1
 #define IIF_IGRACE 2
 #define IIF_FLAGS 4
-#define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
 enum {
   DQF_ROOT_SQUASH_B = 0,
   DQF_SYS_FILE_B = 16,
-  DQF_PRIVATE
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  DQF_PRIVATE
 };
 #define DQF_ROOT_SQUASH (1 << DQF_ROOT_SQUASH_B)
 #define DQF_SYS_FILE (1 << DQF_SYS_FILE_B)
-struct if_dqinfo {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct if_dqinfo {
   __u64 dqi_bgrace;
   __u64 dqi_igrace;
   __u32 dqi_flags;
-  __u32 dqi_valid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dqi_valid;
 };
 #define QUOTA_NL_NOWARN 0
 #define QUOTA_NL_IHARDWARN 1
-#define QUOTA_NL_ISOFTLONGWARN 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QUOTA_NL_ISOFTLONGWARN 2
 #define QUOTA_NL_ISOFTWARN 3
 #define QUOTA_NL_BHARDWARN 4
 #define QUOTA_NL_BSOFTLONGWARN 5
-#define QUOTA_NL_BSOFTWARN 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QUOTA_NL_BSOFTWARN 6
 #define QUOTA_NL_IHARDBELOW 7
 #define QUOTA_NL_ISOFTBELOW 8
 #define QUOTA_NL_BHARDBELOW 9
-#define QUOTA_NL_BSOFTBELOW 10
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define QUOTA_NL_BSOFTBELOW 10
 enum {
   QUOTA_NL_C_UNSPEC,
   QUOTA_NL_C_WARNING,
-  __QUOTA_NL_C_MAX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __QUOTA_NL_C_MAX,
 };
 #define QUOTA_NL_C_MAX (__QUOTA_NL_C_MAX - 1)
 enum {
-  QUOTA_NL_A_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  QUOTA_NL_A_UNSPEC,
   QUOTA_NL_A_QTYPE,
   QUOTA_NL_A_EXCESS_ID,
   QUOTA_NL_A_WARNING,
-  QUOTA_NL_A_DEV_MAJOR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  QUOTA_NL_A_DEV_MAJOR,
   QUOTA_NL_A_DEV_MINOR,
   QUOTA_NL_A_CAUSED_ID,
+  QUOTA_NL_A_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __QUOTA_NL_A_MAX,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define QUOTA_NL_A_MAX (__QUOTA_NL_A_MAX - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/raid/md_u.h b/libc/kernel/uapi/linux/raid/md_u.h
index 66ab2ba..7556eee 100644
--- a/libc/kernel/uapi/linux/raid/md_u.h
+++ b/libc/kernel/uapi/linux/raid/md_u.h
@@ -62,7 +62,7 @@
   int minor_version;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int patch_version;
-  int ctime;
+  unsigned int ctime;
   int level;
   int size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -71,7 +71,7 @@
   int md_minor;
   int not_persistent;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int utime;
+  unsigned int utime;
   int state;
   int active_disks;
   int working_disks;
diff --git a/libc/kernel/uapi/linux/rio_mport_cdev.h b/libc/kernel/uapi/linux/rio_mport_cdev.h
new file mode 100644
index 0000000..0f66bb2
--- /dev/null
+++ b/libc/kernel/uapi/linux/rio_mport_cdev.h
@@ -0,0 +1,211 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   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.
+ ***
+ ***   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!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _RIO_MPORT_CDEV_H_
+#define _RIO_MPORT_CDEV_H_
+#include <linux/ioctl.h>
+#include <linux/types.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct rio_mport_maint_io {
+  __u16 rioid;
+  __u8 hopcount;
+  __u8 pad0[5];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offset;
+  __u32 length;
+  __u64 buffer;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_TRANSFER_MODE_MAPPED (1 << 0)
+#define RIO_TRANSFER_MODE_TRANSFER (1 << 1)
+#define RIO_CAP_DBL_SEND (1 << 2)
+#define RIO_CAP_DBL_RECV (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_CAP_PW_SEND (1 << 4)
+#define RIO_CAP_PW_RECV (1 << 5)
+#define RIO_CAP_MAP_OUTB (1 << 6)
+#define RIO_CAP_MAP_INB (1 << 7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct rio_mport_properties {
+  __u16 hdid;
+  __u8 id;
+  __u8 index;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
+  __u32 sys_size;
+  __u8 port_ok;
+  __u8 link_speed;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 link_width;
+  __u8 pad0;
+  __u32 dma_max_sge;
+  __u32 dma_max_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dma_align;
+  __u32 transfer_mode;
+  __u32 cap_sys_size;
+  __u32 cap_addr_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 cap_transfer_mode;
+  __u32 cap_mport;
+};
+#define RIO_DOORBELL (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_PORTWRITE (1 << 1)
+struct rio_doorbell {
+  __u16 rioid;
+  __u16 payload;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct rio_doorbell_filter {
+  __u16 rioid;
+  __u16 low;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 high;
+  __u16 pad0;
+};
+struct rio_portwrite {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 payload[16];
+};
+struct rio_pw_filter {
+  __u32 mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 low;
+  __u32 high;
+  __u32 pad0;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_MAP_ANY_ADDR (__u64) (~((__u64) 0))
+struct rio_mmap {
+  __u16 rioid;
+  __u16 pad0[3];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 rio_addr;
+  __u64 length;
+  __u64 handle;
+  __u64 address;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct rio_dma_mem {
+  __u64 length;
+  __u64 dma_handle;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 address;
+};
+struct rio_event {
+  __u32 header;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union {
+    struct rio_doorbell doorbell;
+    struct rio_portwrite portwrite;
+  } u;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pad0;
+};
+enum rio_transfer_sync {
+  RIO_TRANSFER_SYNC,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RIO_TRANSFER_ASYNC,
+  RIO_TRANSFER_FAF,
+};
+enum rio_transfer_dir {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RIO_TRANSFER_DIR_READ,
+  RIO_TRANSFER_DIR_WRITE,
+};
+enum rio_exchange {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RIO_EXCHANGE_DEFAULT,
+  RIO_EXCHANGE_NWRITE,
+  RIO_EXCHANGE_SWRITE,
+  RIO_EXCHANGE_NWRITE_R,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RIO_EXCHANGE_SWRITE_R,
+  RIO_EXCHANGE_NWRITE_R_ALL,
+};
+struct rio_transfer_io {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 rio_addr;
+  __u64 loc_addr;
+  __u64 handle;
+  __u64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 length;
+  __u16 rioid;
+  __u16 method;
+  __u32 completion_code;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct rio_transaction {
+  __u64 block;
+  __u32 count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 transfer_mode;
+  __u16 sync;
+  __u16 dir;
+  __u32 pad0;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+struct rio_async_tx_wait {
+  __u32 token;
+  __u32 timeout;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define RIO_MAX_DEVNAME_SZ 20
+struct rio_rdev_info {
+  __u16 destid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 hopcount;
+  __u8 pad0;
+  __u32 comptag;
+  char name[RIO_MAX_DEVNAME_SZ + 1];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define RIO_MPORT_DRV_MAGIC 'm'
+#define RIO_MPORT_MAINT_HDID_SET _IOW(RIO_MPORT_DRV_MAGIC, 1, __u16)
+#define RIO_MPORT_MAINT_COMPTAG_SET _IOW(RIO_MPORT_DRV_MAGIC, 2, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_MPORT_MAINT_PORT_IDX_GET _IOR(RIO_MPORT_DRV_MAGIC, 3, __u32)
+#define RIO_MPORT_GET_PROPERTIES _IOR(RIO_MPORT_DRV_MAGIC, 4, struct rio_mport_properties)
+#define RIO_MPORT_MAINT_READ_LOCAL _IOR(RIO_MPORT_DRV_MAGIC, 5, struct rio_mport_maint_io)
+#define RIO_MPORT_MAINT_WRITE_LOCAL _IOW(RIO_MPORT_DRV_MAGIC, 6, struct rio_mport_maint_io)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_MPORT_MAINT_READ_REMOTE _IOR(RIO_MPORT_DRV_MAGIC, 7, struct rio_mport_maint_io)
+#define RIO_MPORT_MAINT_WRITE_REMOTE _IOW(RIO_MPORT_DRV_MAGIC, 8, struct rio_mport_maint_io)
+#define RIO_ENABLE_DOORBELL_RANGE _IOW(RIO_MPORT_DRV_MAGIC, 9, struct rio_doorbell_filter)
+#define RIO_DISABLE_DOORBELL_RANGE _IOW(RIO_MPORT_DRV_MAGIC, 10, struct rio_doorbell_filter)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_ENABLE_PORTWRITE_RANGE _IOW(RIO_MPORT_DRV_MAGIC, 11, struct rio_pw_filter)
+#define RIO_DISABLE_PORTWRITE_RANGE _IOW(RIO_MPORT_DRV_MAGIC, 12, struct rio_pw_filter)
+#define RIO_SET_EVENT_MASK _IOW(RIO_MPORT_DRV_MAGIC, 13, __u32)
+#define RIO_GET_EVENT_MASK _IOR(RIO_MPORT_DRV_MAGIC, 14, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_MAP_OUTBOUND _IOWR(RIO_MPORT_DRV_MAGIC, 15, struct rio_mmap)
+#define RIO_UNMAP_OUTBOUND _IOW(RIO_MPORT_DRV_MAGIC, 16, struct rio_mmap)
+#define RIO_MAP_INBOUND _IOWR(RIO_MPORT_DRV_MAGIC, 17, struct rio_mmap)
+#define RIO_UNMAP_INBOUND _IOW(RIO_MPORT_DRV_MAGIC, 18, __u64)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_ALLOC_DMA _IOWR(RIO_MPORT_DRV_MAGIC, 19, struct rio_dma_mem)
+#define RIO_FREE_DMA _IOW(RIO_MPORT_DRV_MAGIC, 20, __u64)
+#define RIO_TRANSFER _IOWR(RIO_MPORT_DRV_MAGIC, 21, struct rio_transaction)
+#define RIO_WAIT_FOR_ASYNC _IOW(RIO_MPORT_DRV_MAGIC, 22, struct rio_async_tx_wait)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RIO_DEV_ADD _IOW(RIO_MPORT_DRV_MAGIC, 23, struct rio_rdev_info)
+#define RIO_DEV_DEL _IOW(RIO_MPORT_DRV_MAGIC, 24, struct rio_rdev_info)
+#endif
diff --git a/libc/kernel/uapi/linux/rtnetlink.h b/libc/kernel/uapi/linux/rtnetlink.h
index 81b709b..d4a9d83 100644
--- a/libc/kernel/uapi/linux/rtnetlink.h
+++ b/libc/kernel/uapi/linux/rtnetlink.h
@@ -152,6 +152,11 @@
   RTM_GETNSID = 90,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTM_GETNSID RTM_GETNSID
+  RTM_NEWSTATS = 92,
+#define RTM_NEWSTATS RTM_NEWSTATS
+  RTM_GETSTATS = 94,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RTM_GETSTATS RTM_GETSTATS
   __RTM_MAX,
 #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
 };
@@ -283,334 +288,338 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTA_ENCAP_TYPE,
   RTA_ENCAP,
+  RTA_EXPIRES,
+  RTA_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __RTA_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTA_MAX (__RTA_MAX - 1)
 #define RTM_RTA(r) ((struct rtattr *) (((char *) (r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct rtmsg))
 struct rtnexthop {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short rtnh_len;
   unsigned char rtnh_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char rtnh_hops;
   int rtnh_ifindex;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define RTNH_F_DEAD 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNH_F_PERVASIVE 2
 #define RTNH_F_ONLINK 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNH_F_OFFLOAD 8
 #define RTNH_F_LINKDOWN 16
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN)
 #define RTNH_ALIGNTO 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNH_ALIGN(len) (((len) + RTNH_ALIGNTO - 1) & ~(RTNH_ALIGNTO - 1))
 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && ((int) (rtnh)->rtnh_len) <= (len))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNH_NEXT(rtnh) ((struct rtnexthop *) (((char *) (rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
 #define RTNH_DATA(rtnh) ((struct rtattr *) (((char *) (rtnh)) + RTNH_LENGTH(0)))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct rtvia {
   __kernel_sa_family_t rtvia_family;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 rtvia_addr[0];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct rta_cacheinfo {
   __u32 rta_clntref;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rta_lastuse;
   __s32 rta_expires;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rta_error;
   __u32 rta_used;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNETLINK_HAVE_PEERINFO 1
   __u32 rta_id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 rta_ts;
   __u32 rta_tsage;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_UNSPEC,
 #define RTAX_UNSPEC RTAX_UNSPEC
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_LOCK,
 #define RTAX_LOCK RTAX_LOCK
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_MTU,
 #define RTAX_MTU RTAX_MTU
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_WINDOW,
 #define RTAX_WINDOW RTAX_WINDOW
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_RTT,
 #define RTAX_RTT RTAX_RTT
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_RTTVAR,
 #define RTAX_RTTVAR RTAX_RTTVAR
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_SSTHRESH,
 #define RTAX_SSTHRESH RTAX_SSTHRESH
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_CWND,
 #define RTAX_CWND RTAX_CWND
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_ADVMSS,
 #define RTAX_ADVMSS RTAX_ADVMSS
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_REORDERING,
 #define RTAX_REORDERING RTAX_REORDERING
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_HOPLIMIT,
 #define RTAX_HOPLIMIT RTAX_HOPLIMIT
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_INITCWND,
 #define RTAX_INITCWND RTAX_INITCWND
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_FEATURES,
 #define RTAX_FEATURES RTAX_FEATURES
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_RTO_MIN,
 #define RTAX_RTO_MIN RTAX_RTO_MIN
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_INITRWND,
 #define RTAX_INITRWND RTAX_INITRWND
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_QUICKACK,
 #define RTAX_QUICKACK RTAX_QUICKACK
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTAX_CC_ALGO,
 #define RTAX_CC_ALGO RTAX_CC_ALGO
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __RTAX_MAX
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTAX_MAX (__RTAX_MAX - 1)
 #define RTAX_FEATURE_ECN (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTAX_FEATURE_SACK (1 << 1)
 #define RTAX_FEATURE_TIMESTAMP (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTAX_FEATURE_ALLFRAG (1 << 3)
 #define RTAX_FEATURE_MASK (RTAX_FEATURE_ECN | RTAX_FEATURE_SACK | RTAX_FEATURE_TIMESTAMP | RTAX_FEATURE_ALLFRAG)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct rta_session {
   __u8 proto;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 pad1;
   __u16 pad2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u16 sport;
       __u16 dport;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     } ports;
     struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u8 type;
       __u8 code;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       __u16 ident;
     } icmpt;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 spi;
   } u;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct rta_mfc_stats {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 mfcs_packets;
   __u64 mfcs_bytes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 mfcs_wrong_if;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct rtgenmsg {
   unsigned char rtgen_family;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ifinfomsg {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char ifi_family;
   unsigned char __ifi_pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short ifi_type;
   int ifi_index;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned ifi_flags;
   unsigned ifi_change;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct prefixmsg {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char prefix_family;
   unsigned char prefix_pad1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short prefix_pad2;
   int prefix_ifindex;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char prefix_type;
   unsigned char prefix_len;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char prefix_flags;
   unsigned char prefix_pad3;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PREFIX_UNSPEC,
   PREFIX_ADDRESS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   PREFIX_CACHEINFO,
   __PREFIX_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define PREFIX_MAX (__PREFIX_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct prefix_cacheinfo {
   __u32 preferred_time;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 valid_time;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tcmsg {
   unsigned char tcm_family;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char tcm__pad1;
   unsigned short tcm__pad2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int tcm_ifindex;
   __u32 tcm_handle;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tcm_parent;
   __u32 tcm_info;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_UNSPEC,
   TCA_KIND,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_OPTIONS,
   TCA_STATS,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_XSTATS,
   TCA_RATE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_FCNT,
   TCA_STATS2,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_STAB,
+  TCA_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __TCA_MAX
 };
 #define TCA_MAX (__TCA_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_RTA(r) ((struct rtattr *) (((char *) (r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct tcmsg))
 struct nduseroptmsg {
   unsigned char nduseropt_family;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char nduseropt_pad1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short nduseropt_opts_len;
   int nduseropt_ifindex;
   __u8 nduseropt_icmp_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 nduseropt_icmp_code;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short nduseropt_pad2;
   unsigned int nduseropt_pad3;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   NDUSEROPT_UNSPEC,
   NDUSEROPT_SRCADDR,
   __NDUSEROPT_MAX
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NDUSEROPT_MAX (__NDUSEROPT_MAX - 1)
 #define RTMGRP_LINK 1
 #define RTMGRP_NOTIFY 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTMGRP_NEIGH 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTMGRP_TC 8
 #define RTMGRP_IPV4_IFADDR 0x10
 #define RTMGRP_IPV4_MROUTE 0x20
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTMGRP_IPV4_ROUTE 0x40
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTMGRP_IPV4_RULE 0x80
 #define RTMGRP_IPV6_IFADDR 0x100
 #define RTMGRP_IPV6_MROUTE 0x200
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTMGRP_IPV6_ROUTE 0x400
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTMGRP_IPV6_IFINFO 0x800
 #define RTMGRP_DECnet_IFADDR 0x1000
 #define RTMGRP_DECnet_ROUTE 0x4000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTMGRP_IPV6_PREFIX 0x20000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum rtnetlink_groups {
   RTNLGRP_NONE,
 #define RTNLGRP_NONE RTNLGRP_NONE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_LINK,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_LINK RTNLGRP_LINK
   RTNLGRP_NOTIFY,
 #define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_NEIGH,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_NEIGH RTNLGRP_NEIGH
   RTNLGRP_TC,
 #define RTNLGRP_TC RTNLGRP_TC
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_IPV4_IFADDR,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
   RTNLGRP_IPV4_MROUTE,
 #define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_IPV4_ROUTE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
   RTNLGRP_IPV4_RULE,
 #define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_IPV6_IFADDR,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
   RTNLGRP_IPV6_MROUTE,
 #define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_IPV6_ROUTE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
   RTNLGRP_IPV6_IFINFO,
 #define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_DECnet_IFADDR,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
   RTNLGRP_NOP2,
   RTNLGRP_DECnet_ROUTE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_DECnet_RULE,
 #define RTNLGRP_DECnet_RULE RTNLGRP_DECnet_RULE
   RTNLGRP_NOP4,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_IPV6_PREFIX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
   RTNLGRP_IPV6_RULE,
 #define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_ND_USEROPT,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT
   RTNLGRP_PHONET_IFADDR,
 #define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_PHONET_ROUTE,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
   RTNLGRP_DCB,
 #define RTNLGRP_DCB RTNLGRP_DCB
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_IPV4_NETCONF,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_IPV4_NETCONF RTNLGRP_IPV4_NETCONF
   RTNLGRP_IPV6_NETCONF,
 #define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_MDB,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_MDB RTNLGRP_MDB
   RTNLGRP_MPLS_ROUTE,
 #define RTNLGRP_MPLS_ROUTE RTNLGRP_MPLS_ROUTE
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RTNLGRP_NSID,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_NSID RTNLGRP_NSID
   __RTNLGRP_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct tcamsg {
   unsigned char tca_family;
   unsigned char tca__pad1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short tca__pad2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define TA_RTA(r) ((struct rtattr *) (((char *) (r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct tcamsg))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCA_ACT_TAB 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define TCAA_MAX 1
 #define RTEXT_FILTER_VF (1 << 0)
 #define RTEXT_FILTER_BRVLAN (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTEXT_FILTER_BRVLAN_COMPRESSED (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define RTEXT_FILTER_SKIP_STATS (1 << 3)
 #endif
diff --git a/libc/kernel/uapi/linux/sched.h b/libc/kernel/uapi/linux/sched.h
index d87bc2a..2d11898 100644
--- a/libc/kernel/uapi/linux/sched.h
+++ b/libc/kernel/uapi/linux/sched.h
@@ -39,22 +39,23 @@
 #define CLONE_DETACHED 0x00400000
 #define CLONE_UNTRACED 0x00800000
 #define CLONE_CHILD_SETTID 0x01000000
-#define CLONE_NEWUTS 0x04000000
+#define CLONE_NEWCGROUP 0x02000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CLONE_NEWUTS 0x04000000
 #define CLONE_NEWIPC 0x08000000
 #define CLONE_NEWUSER 0x10000000
 #define CLONE_NEWPID 0x20000000
-#define CLONE_NEWNET 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CLONE_NEWNET 0x40000000
 #define CLONE_IO 0x80000000
 #define SCHED_NORMAL 0
 #define SCHED_FIFO 1
-#define SCHED_RR 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SCHED_RR 2
 #define SCHED_BATCH 3
 #define SCHED_IDLE 5
 #define SCHED_DEADLINE 6
-#define SCHED_RESET_ON_FORK 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SCHED_RESET_ON_FORK 0x40000000
 #define SCHED_FLAG_RESET_ON_FORK 0x01
 #endif
diff --git a/libc/kernel/uapi/linux/sem.h b/libc/kernel/uapi/linux/sem.h
index 4f3632b..6916556 100644
--- a/libc/kernel/uapi/linux/sem.h
+++ b/libc/kernel/uapi/linux/sem.h
@@ -32,8 +32,8 @@
 #define SEM_STAT 18
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SEM_INFO 19
-struct semid_ds {
-  struct ipc_perm sem_perm;
+struct __kernel_legacy_semid_ds {
+  struct __kernel_legacy_ipc_perm sem_perm;
   __kernel_time_t sem_otime;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __kernel_time_t sem_ctime;
@@ -54,7 +54,7 @@
 };
 union semun {
   int val;
-  struct semid_ds __user * buf;
+  struct __kernel_legacy_semid_ds __user * buf;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short __user * array;
   struct seminfo __user * __buf;
diff --git a/libc/kernel/uapi/linux/serial.h b/libc/kernel/uapi/linux/serial.h
index 494dc9a..ebeef18 100644
--- a/libc/kernel/uapi/linux/serial.h
+++ b/libc/kernel/uapi/linux/serial.h
@@ -76,46 +76,48 @@
 #define SERIAL_IO_TSI 5
 #define SERIAL_IO_MEM32BE 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SERIAL_IO_MEM16 7
 #define UART_CLEAR_FIFO 0x01
 #define UART_USE_FIFO 0x02
 #define UART_STARTECH 0x04
-#define UART_NATSEMI 0x08
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UART_NATSEMI 0x08
 struct serial_multiport_struct {
   int irq;
   int port1;
-  unsigned char mask1, match1;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char mask1, match1;
   int port2;
   unsigned char mask2, match2;
   int port3;
-  unsigned char mask3, match3;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char mask3, match3;
   int port4;
   unsigned char mask4, match4;
   int port_monitor;
-  int reserved[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int reserved[32];
 };
 struct serial_icounter_struct {
   int cts, dsr, rng, dcd;
-  int rx, tx;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  int rx, tx;
   int frame, overrun, parity, brk;
   int buf_overrun;
   int reserved[9];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct serial_rs485 {
   __u32 flags;
 #define SER_RS485_ENABLED (1 << 0)
-#define SER_RS485_RTS_ON_SEND (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SER_RS485_RTS_ON_SEND (1 << 1)
 #define SER_RS485_RTS_AFTER_SEND (1 << 2)
 #define SER_RS485_RX_DURING_TX (1 << 4)
   __u32 delay_rts_before_send;
-  __u32 delay_rts_after_send;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 delay_rts_after_send;
   __u32 padding[5];
 };
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/serial_core.h b/libc/kernel/uapi/linux/serial_core.h
index dcda903..e7e28f4 100644
--- a/libc/kernel/uapi/linux/serial_core.h
+++ b/libc/kernel/uapi/linux/serial_core.h
@@ -154,5 +154,8 @@
 #define PORT_SPRD 111
 #define PORT_CRIS 112
 #define PORT_STM32 113
-#endif
+#define PORT_MVEBU 114
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PORT_PIC32 115
+#define PORT_MPS2UART 116
+#endif
diff --git a/libc/kernel/uapi/linux/serio.h b/libc/kernel/uapi/linux/serio.h
index a8fcfd9..a956d96 100644
--- a/libc/kernel/uapi/linux/serio.h
+++ b/libc/kernel/uapi/linux/serio.h
@@ -86,4 +86,5 @@
 #define SERIO_TSC40 0x3d
 #define SERIO_WACOM_IV 0x3e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SERIO_EGALAX 0x3f
 #endif
diff --git a/libc/kernel/uapi/linux/shm.h b/libc/kernel/uapi/linux/shm.h
index bb7f907..c7e1e53 100644
--- a/libc/kernel/uapi/linux/shm.h
+++ b/libc/kernel/uapi/linux/shm.h
@@ -28,8 +28,8 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SHMALL (ULONG_MAX - (1UL << 24))
 #define SHMSEG SHMMNI
-struct shmid_ds {
-  struct ipc_perm shm_perm;
+struct __kernel_legacy_shmid_ds {
+  struct __kernel_legacy_ipc_perm shm_perm;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int shm_segsz;
   __kernel_time_t shm_atime;
diff --git a/libc/kernel/uapi/linux/signal.h b/libc/kernel/uapi/linux/signal.h
index b8d7428..e9663ec 100644
--- a/libc/kernel/uapi/linux/signal.h
+++ b/libc/kernel/uapi/linux/signal.h
@@ -23,4 +23,7 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SS_ONSTACK 1
 #define SS_DISABLE 2
+#define SS_AUTODISARM (1U << 31)
+#define SS_FLAG_BITS SS_AUTODISARM
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/sock_diag.h b/libc/kernel/uapi/linux/sock_diag.h
index 4d9e440..39fa6c1 100644
--- a/libc/kernel/uapi/linux/sock_diag.h
+++ b/libc/kernel/uapi/linux/sock_diag.h
@@ -21,34 +21,36 @@
 #include <linux/types.h>
 #define SOCK_DIAG_BY_FAMILY 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SOCK_DESTROY 21
 struct sock_diag_req {
   __u8 sdiag_family;
   __u8 sdiag_protocol;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum {
   SK_MEMINFO_RMEM_ALLOC,
   SK_MEMINFO_RCVBUF,
-  SK_MEMINFO_WMEM_ALLOC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  SK_MEMINFO_WMEM_ALLOC,
   SK_MEMINFO_SNDBUF,
   SK_MEMINFO_FWD_ALLOC,
   SK_MEMINFO_WMEM_QUEUED,
-  SK_MEMINFO_OPTMEM,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  SK_MEMINFO_OPTMEM,
   SK_MEMINFO_BACKLOG,
+  SK_MEMINFO_DROPS,
   SK_MEMINFO_VARS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum sknetlink_groups {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   SKNLGRP_NONE,
   SKNLGRP_INET_TCP_DESTROY,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   SKNLGRP_INET_UDP_DESTROY,
   SKNLGRP_INET6_TCP_DESTROY,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   SKNLGRP_INET6_UDP_DESTROY,
   __SKNLGRP_MAX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SKNLGRP_MAX (__SKNLGRP_MAX - 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/som.h b/libc/kernel/uapi/linux/som.h
deleted file mode 100644
index cb76e70..0000000
--- a/libc/kernel/uapi/linux/som.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
- ****************************************************************************
- ***
- ***   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.
- ***
- ***   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!
- ***
- ****************************************************************************
- ****************************************************************************/
-#ifndef _LINUX_SOM_H
-#define _LINUX_SOM_H
-#include <linux/time.h>
-#define SOM_PAGESIZE 4096
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct som_hdr {
-  short system_id;
-  short a_magic;
-  unsigned int version_id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  struct timespec file_time;
-  unsigned int entry_space;
-  unsigned int entry_subspace;
-  unsigned int entry_offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int aux_header_location;
-  unsigned int aux_header_size;
-  unsigned int som_length;
-  unsigned int presumed_dp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int space_location;
-  unsigned int space_total;
-  unsigned int subspace_location;
-  unsigned int subspace_total;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int loader_fixup_location;
-  unsigned int loader_fixup_total;
-  unsigned int space_strings_location;
-  unsigned int space_strings_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int init_array_location;
-  unsigned int init_array_total;
-  unsigned int compiler_location;
-  unsigned int compiler_total;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int symbol_location;
-  unsigned int symbol_total;
-  unsigned int fixup_request_location;
-  unsigned int fixup_request_total;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int symbol_strings_location;
-  unsigned int symbol_strings_size;
-  unsigned int unloadable_sp_location;
-  unsigned int unloadable_sp_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int checksum;
-};
-#define SOM_SID_PARISC_1_0 0x020b
-#define SOM_SID_PARISC_1_1 0x0210
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOM_SID_PARISC_2_0 0x0214
-#define SOM_LIB_EXEC 0x0104
-#define SOM_RELOCATABLE 0x0106
-#define SOM_EXEC_NONSHARE 0x0107
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOM_EXEC_SHARE 0x0108
-#define SOM_EXEC_DEMAND 0x010B
-#define SOM_LIB_DYN 0x010D
-#define SOM_LIB_SHARE 0x010E
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SOM_LIB_RELOC 0x0619
-#define SOM_ID_OLD 85082112
-#define SOM_ID_NEW 87102412
-struct aux_id {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int mandatory : 1;
-  unsigned int copy : 1;
-  unsigned int append : 1;
-  unsigned int ignore : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int reserved : 12;
-  unsigned int type : 16;
-  unsigned int length;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct som_exec_auxhdr {
-  struct aux_id som_auxhdr;
-  int exec_tsize;
-  int exec_tmem;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int exec_tfile;
-  int exec_dsize;
-  int exec_dmem;
-  int exec_dfile;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int exec_bsize;
-  int exec_entry;
-  int exec_flags;
-  int exec_bfill;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-union name_pt {
-  char * n_name;
-  unsigned int n_strx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct space_dictionary_record {
-  union name_pt name;
-  unsigned int is_loadable : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int is_defined : 1;
-  unsigned int is_private : 1;
-  unsigned int has_intermediate_code : 1;
-  unsigned int is_tspecific : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int reserved : 11;
-  unsigned int sort_key : 8;
-  unsigned int reserved2 : 8;
-  int space_number;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int subspace_index;
-  unsigned int subspace_quantity;
-  int loader_fix_index;
-  unsigned int loader_fix_quantity;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int init_pointer_index;
-  unsigned int init_pointer_quantity;
-};
-struct subspace_dictionary_record {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  int space_index;
-  unsigned int access_control_bits : 7;
-  unsigned int memory_resident : 1;
-  unsigned int dup_common : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int is_common : 1;
-  unsigned int quadrant : 2;
-  unsigned int initially_frozen : 1;
-  unsigned int is_first : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int code_only : 1;
-  unsigned int sort_key : 8;
-  unsigned int replicate_init : 1;
-  unsigned int continuation : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int is_tspecific : 1;
-  unsigned int is_comdat : 1;
-  unsigned int reserved : 4;
-  int file_loc_init_value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int initialization_length;
-  unsigned int subspace_start;
-  unsigned int subspace_length;
-  unsigned int reserved2 : 5;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  unsigned int alignment : 27;
-  union name_pt name;
-  int fixup_request_index;
-  unsigned int fixup_request_quantity;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-#endif
diff --git a/libc/kernel/uapi/linux/stddef.h b/libc/kernel/uapi/linux/stddef.h
index 8f2ed27..0f817a4 100644
--- a/libc/kernel/uapi/linux/stddef.h
+++ b/libc/kernel/uapi/linux/stddef.h
@@ -17,3 +17,7 @@
  ****************************************************************************
  ****************************************************************************/
 #include <linux/compiler.h>
+#ifndef __always_inline
+#define __always_inline inline
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/swab.h b/libc/kernel/uapi/linux/swab.h
index d7d6fa6..a3387de 100644
--- a/libc/kernel/uapi/linux/swab.h
+++ b/libc/kernel/uapi/linux/swab.h
@@ -28,72 +28,83 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ___constant_swahw32(x) ((__u32) ((((__u32) (x) & (__u32) 0x0000ffffUL) << 16) | (((__u32) (x) & (__u32) 0xffff0000UL) >> 16)))
 #define ___constant_swahb32(x) ((__u32) ((((__u32) (x) & (__u32) 0x00ff00ffUL) << 8) | (((__u32) (x) & (__u32) 0xff00ff00UL) >> 8)))
-#ifdef __HAVE_BUILTIN_BSWAP16__
-#elif defined(__arch_swab16)
+#ifdef __arch_swab16
+#else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifdef __arch_swab32
 #else
 #endif
-#ifdef __HAVE_BUILTIN_BSWAP32__
-#elif defined(__arch_swab32)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#else
-#endif
-#ifdef __HAVE_BUILTIN_BSWAP64__
-#elif defined(__arch_swab64)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __arch_swab64
 #elif defined(__SWAB_64_THRU_32__)
 #else
 #endif
-#ifdef __arch_swahw32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __arch_swahw32
 #else
 #endif
 #ifdef __arch_swahb32
-#else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
 #endif
+#ifdef __HAVE_BUILTIN_BSWAP16__
+#define __swab16(x) (__u16) __builtin_bswap16((__u16) (x))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
 #define __swab16(x) (__builtin_constant_p((__u16) (x)) ? ___constant_swab16(x) : __fswab16(x))
+#endif
+#ifdef __HAVE_BUILTIN_BSWAP32__
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __swab32(x) (__u32) __builtin_bswap32((__u32) (x))
+#else
 #define __swab32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swab32(x) : __fswab32(x))
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __HAVE_BUILTIN_BSWAP64__
+#define __swab64(x) (__u64) __builtin_bswap64((__u64) (x))
+#else
 #define __swab64(x) (__builtin_constant_p((__u64) (x)) ? ___constant_swab64(x) : __fswab64(x))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #define __swahw32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahw32(x) : __fswahw32(x))
 #define __swahb32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahb32(x) : __fswahb32(x))
 #ifdef __arch_swab16p
-#else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
 #endif
 #ifdef __arch_swab32p
 #else
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #ifdef __arch_swab64p
 #else
 #endif
-#ifdef __arch_swahw32p
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __arch_swahw32p
 #else
 #endif
 #ifdef __arch_swahb32p
-#else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
 #endif
 #ifdef __arch_swab16s
 #else
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
 #ifdef __arch_swab32s
 #else
 #endif
-#ifdef __arch_swab64s
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __arch_swab64s
 #else
 #endif
 #ifdef __arch_swahw32s
-#else
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
 #endif
 #ifdef __arch_swahb32s
 #else
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+#endif
diff --git a/libc/kernel/uapi/linux/sync.h b/libc/kernel/uapi/linux/sync_file.h
similarity index 84%
rename from libc/kernel/uapi/linux/sync.h
rename to libc/kernel/uapi/linux/sync_file.h
index bbf6641..5c3d6da 100644
--- a/libc/kernel/uapi/linux/sync.h
+++ b/libc/kernel/uapi/linux/sync_file.h
@@ -22,32 +22,34 @@
 #include <linux/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct sync_merge_data {
-  __s32 fd2;
   char name[32];
+  __s32 fd2;
   __s32 fence;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
+  __u32 pad;
 };
-struct sync_pt_info {
-  __u32 len;
-  char obj_name[32];
+struct sync_fence_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char obj_name[32];
   char driver_name[32];
   __s32 status;
-  __u64 timestamp_ns;
-  __u8 driver_data[0];
+  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 timestamp_ns;
 };
-struct sync_fence_info_data {
-  __u32 len;
+struct sync_file_info {
   char name[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 status;
-  __u8 pt_info[0];
+  __u32 flags;
+  __u32 num_fences;
+  __u32 pad;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 sync_fence_info;
 };
 #define SYNC_IOC_MAGIC '>'
+#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32)
-#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data)
-#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_fence_info_data)
+#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/target_core_user.h b/libc/kernel/uapi/linux/target_core_user.h
index 343414c..a76b19b 100644
--- a/libc/kernel/uapi/linux/target_core_user.h
+++ b/libc/kernel/uapi/linux/target_core_user.h
@@ -24,76 +24,77 @@
 #define TCMU_VERSION "2.0"
 #define TCMU_MAILBOX_VERSION 2
 #define ALIGN_SIZE 64
-struct tcmu_mailbox {
+#define TCMU_MAILBOX_FLAG_CAP_OOOC (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct tcmu_mailbox {
   __u16 version;
   __u16 flags;
   __u32 cmdr_off;
-  __u32 cmdr_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 cmdr_size;
   __u32 cmd_head;
   __u32 cmd_tail __attribute__((__aligned__(ALIGN_SIZE)));
 } __packed;
-enum tcmu_opcode {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum tcmu_opcode {
   TCMU_OP_PAD = 0,
   TCMU_OP_CMD,
 };
-struct tcmu_cmd_entry_hdr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct tcmu_cmd_entry_hdr {
   __u32 len_op;
   __u16 cmd_id;
   __u8 kflags;
-#define TCMU_UFLAG_UNKNOWN_OP 0x1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCMU_UFLAG_UNKNOWN_OP 0x1
   __u8 uflags;
 } __packed;
 #define TCMU_OP_MASK 0x7
-#define TCMU_SENSE_BUFFERSIZE 96
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCMU_SENSE_BUFFERSIZE 96
 struct tcmu_cmd_entry {
   struct tcmu_cmd_entry_hdr hdr;
   union {
-    struct {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct {
       uint32_t iov_cnt;
       uint32_t iov_bidi_cnt;
       uint32_t iov_dif_cnt;
-      uint64_t cdb_off;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      uint64_t cdb_off;
       uint64_t __pad1;
       uint64_t __pad2;
       struct iovec iov[0];
-    } req;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    } req;
     struct {
       uint8_t scsi_status;
       uint8_t __pad1;
-      uint16_t __pad2;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      uint16_t __pad2;
       uint32_t __pad3;
       char sense_buffer[TCMU_SENSE_BUFFERSIZE];
     } rsp;
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
 } __packed;
 #define TCMU_OP_ALIGN_SIZE sizeof(uint64_t)
 enum tcmu_genl_cmd {
-  TCMU_CMD_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCMU_CMD_UNSPEC,
   TCMU_CMD_ADDED_DEVICE,
   TCMU_CMD_REMOVED_DEVICE,
   __TCMU_CMD_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCMU_CMD_MAX (__TCMU_CMD_MAX - 1)
 enum tcmu_genl_attr {
   TCMU_ATTR_UNSPEC,
-  TCMU_ATTR_DEVICE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCMU_ATTR_DEVICE,
   TCMU_ATTR_MINOR,
   __TCMU_ATTR_MAX,
 };
-#define TCMU_ATTR_MAX (__TCMU_ATTR_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCMU_ATTR_MAX (__TCMU_ATTR_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_bpf.h b/libc/kernel/uapi/linux/tc_act/tc_bpf.h
index 6b59128..8953f96 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_bpf.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_bpf.h
@@ -34,8 +34,10 @@
   TCA_ACT_BPF_OPS,
   TCA_ACT_BPF_FD,
   TCA_ACT_BPF_NAME,
-  __TCA_ACT_BPF_MAX,
+  TCA_ACT_BPF_PAD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __TCA_ACT_BPF_MAX,
 };
 #define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/tc_act/tc_connmark.h b/libc/kernel/uapi/linux/tc_act/tc_connmark.h
index 6dd64f0..6a0d60d 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_connmark.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_connmark.h
@@ -32,8 +32,9 @@
   TCA_CONNMARK_PARMS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_CONNMARK_TM,
+  TCA_CONNMARK_PAD,
   __TCA_CONNMARK_MAX
 };
-#define TCA_CONNMARK_MAX (__TCA_CONNMARK_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_CONNMARK_MAX (__TCA_CONNMARK_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_csum.h b/libc/kernel/uapi/linux/tc_act/tc_csum.h
index 83c00b6..02a82f7 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_csum.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_csum.h
@@ -27,23 +27,24 @@
   TCA_CSUM_PARMS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_CSUM_TM,
+  TCA_CSUM_PAD,
   __TCA_CSUM_MAX
 };
-#define TCA_CSUM_MAX (__TCA_CSUM_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_CSUM_MAX (__TCA_CSUM_MAX - 1)
 enum {
   TCA_CSUM_UPDATE_FLAG_IPV4HDR = 1,
   TCA_CSUM_UPDATE_FLAG_ICMP = 2,
-  TCA_CSUM_UPDATE_FLAG_IGMP = 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_CSUM_UPDATE_FLAG_IGMP = 4,
   TCA_CSUM_UPDATE_FLAG_TCP = 8,
   TCA_CSUM_UPDATE_FLAG_UDP = 16,
   TCA_CSUM_UPDATE_FLAG_UDPLITE = 32
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct tc_csum {
   tc_gen;
   __u32 update_flags;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_defact.h b/libc/kernel/uapi/linux/tc_act/tc_defact.h
index b96bcd5..400955d 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_defact.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_defact.h
@@ -29,8 +29,10 @@
   TCA_DEF_TM,
   TCA_DEF_PARMS,
   TCA_DEF_DATA,
-  __TCA_DEF_MAX
+  TCA_DEF_PAD,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __TCA_DEF_MAX
 };
 #define TCA_DEF_MAX (__TCA_DEF_MAX - 1)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/tc_act/tc_gact.h b/libc/kernel/uapi/linux/tc_act/tc_gact.h
index 18152e2..3d1d912 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_gact.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_gact.h
@@ -43,8 +43,9 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_GACT_PARMS,
   TCA_GACT_PROB,
+  TCA_GACT_PAD,
   __TCA_GACT_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCA_GACT_MAX (__TCA_GACT_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/sync.h b/libc/kernel/uapi/linux/tc_act/tc_ife.h
similarity index 70%
copy from libc/kernel/uapi/linux/sync.h
copy to libc/kernel/uapi/linux/tc_act/tc_ife.h
index bbf6641..b2adbac 100644
--- a/libc/kernel/uapi/linux/sync.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_ife.h
@@ -16,38 +16,40 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _UAPI_LINUX_SYNC_H
-#define _UAPI_LINUX_SYNC_H
-#include <linux/ioctl.h>
+#ifndef __UAPI_TC_IFE_H
+#define __UAPI_TC_IFE_H
 #include <linux/types.h>
+#include <linux/pkt_cls.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct sync_merge_data {
-  __s32 fd2;
-  char name[32];
-  __s32 fence;
+#define TCA_ACT_IFE 25
+#define IFE_ENCODE 1
+#define IFE_DECODE 0
+struct tc_ife {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  tc_gen;
+  __u16 flags;
 };
-struct sync_pt_info {
-  __u32 len;
-  char obj_name[32];
+enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  char driver_name[32];
-  __s32 status;
-  __u64 timestamp_ns;
-  __u8 driver_data[0];
+  TCA_IFE_UNSPEC,
+  TCA_IFE_PARMS,
+  TCA_IFE_TM,
+  TCA_IFE_DMAC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_IFE_SMAC,
+  TCA_IFE_TYPE,
+  TCA_IFE_METALST,
+  TCA_IFE_PAD,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __TCA_IFE_MAX
 };
-struct sync_fence_info_data {
-  __u32 len;
-  char name[32];
+#define TCA_IFE_MAX (__TCA_IFE_MAX - 1)
+#define IFE_META_SKBMARK 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __s32 status;
-  __u8 pt_info[0];
-};
-#define SYNC_IOC_MAGIC '>'
+#define IFE_META_HASHID 2
+#define IFE_META_PRIO 3
+#define IFE_META_QMAP 4
+#define __IFE_META_MAX 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32)
-#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data)
-#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_fence_info_data)
+#define IFE_META_MAX (__IFE_META_MAX - 1)
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/tc_act/tc_ipt.h b/libc/kernel/uapi/linux/tc_act/tc_ipt.h
index 10b8805..75a725f 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_ipt.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_ipt.h
@@ -32,8 +32,9 @@
   TCA_IPT_TM,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_IPT_TARG,
+  TCA_IPT_PAD,
   __TCA_IPT_MAX
 };
-#define TCA_IPT_MAX (__TCA_IPT_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_IPT_MAX (__TCA_IPT_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_mirred.h b/libc/kernel/uapi/linux/tc_act/tc_mirred.h
index 983ce92..3c05a93 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_mirred.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_mirred.h
@@ -38,8 +38,9 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_MIRRED_TM,
   TCA_MIRRED_PARMS,
+  TCA_MIRRED_PAD,
   __TCA_MIRRED_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_nat.h b/libc/kernel/uapi/linux/tc_act/tc_nat.h
index e812d59..c0d778c 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_nat.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_nat.h
@@ -27,18 +27,19 @@
   TCA_NAT_PARMS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_NAT_TM,
+  TCA_NAT_PAD,
   __TCA_NAT_MAX
 };
-#define TCA_NAT_MAX (__TCA_NAT_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_NAT_MAX (__TCA_NAT_MAX - 1)
 #define TCA_NAT_FLAG_EGRESS 1
 struct tc_nat {
   tc_gen;
-  __be32 old_addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be32 old_addr;
   __be32 new_addr;
   __be32 mask;
   __u32 flags;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_pedit.h b/libc/kernel/uapi/linux/tc_act/tc_pedit.h
index 4a1721a..a87a5a8 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_pedit.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_pedit.h
@@ -27,27 +27,28 @@
   TCA_PEDIT_TM,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_PEDIT_PARMS,
+  TCA_PEDIT_PAD,
   __TCA_PEDIT_MAX
 };
-#define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1)
 struct tc_pedit_key {
   __u32 mask;
   __u32 val;
-  __u32 off;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 off;
   __u32 at;
   __u32 offmask;
   __u32 shift;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct tc_pedit_sel {
   tc_gen;
   unsigned char nkeys;
-  unsigned char flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned char flags;
   struct tc_pedit_key keys[0];
 };
 #define tc_pedit tc_pedit_sel
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_skbedit.h b/libc/kernel/uapi/linux/tc_act/tc_skbedit.h
index 73fd3a9..d57d7b5 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_skbedit.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_skbedit.h
@@ -37,8 +37,9 @@
   TCA_SKBEDIT_QUEUE_MAPPING,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCA_SKBEDIT_MARK,
+  TCA_SKBEDIT_PAD,
   __TCA_SKBEDIT_MAX
 };
-#define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_vlan.h b/libc/kernel/uapi/linux/tc_act/tc_vlan.h
index f9b4d29..a760752 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_vlan.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_vlan.h
@@ -36,8 +36,9 @@
   TCA_VLAN_PUSH_VLAN_ID,
   TCA_VLAN_PUSH_VLAN_PROTOCOL,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCA_VLAN_PAD,
   __TCA_VLAN_MAX,
 };
 #define TCA_VLAN_MAX (__TCA_VLAN_MAX - 1)
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/tcp.h b/libc/kernel/uapi/linux/tcp.h
index ce36178..72619bc 100644
--- a/libc/kernel/uapi/linux/tcp.h
+++ b/libc/kernel/uapi/linux/tcp.h
@@ -182,6 +182,11 @@
   __u32 tcpi_segs_out;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 tcpi_segs_in;
+  __u32 tcpi_notsent_bytes;
+  __u32 tcpi_min_rtt;
+  __u32 tcpi_data_segs_in;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 tcpi_data_segs_out;
 };
 #define TCP_MD5SIG_MAXKEYLEN 80
 struct tcp_md5sig {
diff --git a/libc/kernel/uapi/linux/tcp_metrics.h b/libc/kernel/uapi/linux/tcp_metrics.h
index 4bc3e48..6eed74e 100644
--- a/libc/kernel/uapi/linux/tcp_metrics.h
+++ b/libc/kernel/uapi/linux/tcp_metrics.h
@@ -53,17 +53,18 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   TCP_METRICS_ATTR_SADDR_IPV4,
   TCP_METRICS_ATTR_SADDR_IPV6,
+  TCP_METRICS_ATTR_PAD,
   __TCP_METRICS_ATTR_MAX,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define TCP_METRICS_ATTR_MAX (__TCP_METRICS_ATTR_MAX - 1)
 enum {
   TCP_METRICS_CMD_UNSPEC,
-  TCP_METRICS_CMD_GET,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  TCP_METRICS_CMD_GET,
   TCP_METRICS_CMD_DEL,
   __TCP_METRICS_CMD_MAX,
 };
-#define TCP_METRICS_CMD_MAX (__TCP_METRICS_CMD_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TCP_METRICS_CMD_MAX (__TCP_METRICS_CMD_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/linux/tty_flags.h b/libc/kernel/uapi/linux/tty_flags.h
index 12fae79..77026d5 100644
--- a/libc/kernel/uapi/linux/tty_flags.h
+++ b/libc/kernel/uapi/linux/tty_flags.h
@@ -41,58 +41,63 @@
 #define ASYNCB_MAGIC_MULTIPLIER 16
 #define ASYNCB_LAST_USER 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef _KERNEL_
 #define ASYNCB_INITIALIZED 31
 #define ASYNCB_SUSPENDED 30
 #define ASYNCB_NORMAL_ACTIVE 29
-#define ASYNCB_BOOT_AUTOCONF 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ASYNCB_BOOT_AUTOCONF 28
 #define ASYNCB_CLOSING 27
 #define ASYNCB_CTS_FLOW 26
 #define ASYNCB_CHECK_CD 25
-#define ASYNCB_SHARE_IRQ 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ASYNCB_SHARE_IRQ 24
 #define ASYNCB_CONS_FLOW 23
 #define ASYNCB_FIRST_KERNEL 22
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_HUP_NOTIFY (1U << ASYNCB_HUP_NOTIFY)
 #define ASYNC_SUSPENDED (1U << ASYNCB_SUSPENDED)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_FOURPORT (1U << ASYNCB_FOURPORT)
 #define ASYNC_SAK (1U << ASYNCB_SAK)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_SPLIT_TERMIOS (1U << ASYNCB_SPLIT_TERMIOS)
 #define ASYNC_SPD_HI (1U << ASYNCB_SPD_HI)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_SPD_VHI (1U << ASYNCB_SPD_VHI)
 #define ASYNC_SKIP_TEST (1U << ASYNCB_SKIP_TEST)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_AUTO_IRQ (1U << ASYNCB_AUTO_IRQ)
 #define ASYNC_SESSION_LOCKOUT (1U << ASYNCB_SESSION_LOCKOUT)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_PGRP_LOCKOUT (1U << ASYNCB_PGRP_LOCKOUT)
 #define ASYNC_CALLOUT_NOHUP (1U << ASYNCB_CALLOUT_NOHUP)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_HARDPPS_CD (1U << ASYNCB_HARDPPS_CD)
 #define ASYNC_SPD_SHI (1U << ASYNCB_SPD_SHI)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_LOW_LATENCY (1U << ASYNCB_LOW_LATENCY)
 #define ASYNC_BUGGY_UART (1U << ASYNCB_BUGGY_UART)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_AUTOPROBE (1U << ASYNCB_AUTOPROBE)
 #define ASYNC_MAGIC_MULTIPLIER (1U << ASYNCB_MAGIC_MULTIPLIER)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_FLAGS ((1U << (ASYNCB_LAST_USER + 1)) - 1)
 #define ASYNC_DEPRECATED (ASYNC_SESSION_LOCKOUT | ASYNC_PGRP_LOCKOUT | ASYNC_CALLOUT_NOHUP | ASYNC_AUTOPROBE)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_USR_MASK (ASYNC_SPD_MASK | ASYNC_CALLOUT_NOHUP | ASYNC_LOW_LATENCY)
 #define ASYNC_SPD_CUST (ASYNC_SPD_HI | ASYNC_SPD_VHI)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_SPD_WARP (ASYNC_SPD_HI | ASYNC_SPD_SHI)
 #define ASYNC_SPD_MASK (ASYNC_SPD_HI | ASYNC_SPD_VHI | ASYNC_SPD_SHI)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef _KERNEL_
 #define ASYNC_INITIALIZED (1U << ASYNCB_INITIALIZED)
 #define ASYNC_NORMAL_ACTIVE (1U << ASYNCB_NORMAL_ACTIVE)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_BOOT_AUTOCONF (1U << ASYNCB_BOOT_AUTOCONF)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_CLOSING (1U << ASYNCB_CLOSING)
 #define ASYNC_CTS_FLOW (1U << ASYNCB_CTS_FLOW)
 #define ASYNC_CHECK_CD (1U << ASYNCB_CHECK_CD)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_SHARE_IRQ (1U << ASYNCB_SHARE_IRQ)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ASYNC_CONS_FLOW (1U << ASYNCB_CONS_FLOW)
 #define ASYNC_INTERNAL_FLAGS (~((1U << ASYNCB_FIRST_KERNEL) - 1))
 #endif
+#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/udp.h b/libc/kernel/uapi/linux/udp.h
index a3e9e97..aa5287a 100644
--- a/libc/kernel/uapi/linux/udp.h
+++ b/libc/kernel/uapi/linux/udp.h
@@ -36,4 +36,6 @@
 #define UDP_ENCAP_ESPINUDP 2
 #define UDP_ENCAP_L2TPINUDP 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UDP_ENCAP_GTP0 4
+#define UDP_ENCAP_GTP1U 5
 #endif
diff --git a/libc/kernel/uapi/linux/uinput.h b/libc/kernel/uapi/linux/uinput.h
index 018d8a8..7a80f85 100644
--- a/libc/kernel/uapi/linux/uinput.h
+++ b/libc/kernel/uapi/linux/uinput.h
@@ -21,24 +21,39 @@
 #include <linux/types.h>
 #include <linux/input.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UINPUT_VERSION 4
+#define UINPUT_VERSION 5
+#define UINPUT_MAX_NAME_SIZE 80
 struct uinput_ff_upload {
   __u32 request_id;
-  __s32 retval;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 retval;
   struct ff_effect effect;
   struct ff_effect old;
 };
-struct uinput_ff_erase {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct uinput_ff_erase {
   __u32 request_id;
   __s32 retval;
   __u32 effect_id;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define UINPUT_IOCTL_BASE 'U'
 #define UI_DEV_CREATE _IO(UINPUT_IOCTL_BASE, 1)
 #define UI_DEV_DESTROY _IO(UINPUT_IOCTL_BASE, 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct uinput_setup {
+  struct input_id id;
+  char name[UINPUT_MAX_NAME_SIZE];
+  __u32 ff_effects_max;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
+#define UI_DEV_SETUP _IOW(UINPUT_IOCTL_BASE, 3, struct uinput_setup)
+struct uinput_abs_setup {
+  __u16 code;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct input_absinfo absinfo;
+};
+#define UI_ABS_SETUP _IOW(UINPUT_IOCTL_BASE, 4, struct uinput_abs_setup)
 #define UI_SET_EVBIT _IOW(UINPUT_IOCTL_BASE, 100, int)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define UI_SET_KEYBIT _IOW(UINPUT_IOCTL_BASE, 101, int)
@@ -64,17 +79,16 @@
 #define EV_UINPUT 0x0101
 #define UI_FF_UPLOAD 1
 #define UI_FF_ERASE 2
-#define UINPUT_MAX_NAME_SIZE 80
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct uinput_user_dev {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char name[UINPUT_MAX_NAME_SIZE];
   struct input_id id;
   __u32 ff_effects_max;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 absmax[ABS_CNT];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 absmin[ABS_CNT];
   __s32 absfuzz[ABS_CNT];
   __s32 absflat[ABS_CNT];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/usb/ch11.h b/libc/kernel/uapi/linux/usb/ch11.h
index f8585df..1335bb9 100644
--- a/libc/kernel/uapi/linux/usb/ch11.h
+++ b/libc/kernel/uapi/linux/usb/ch11.h
@@ -23,56 +23,61 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
+#define HUB_PORT_STATUS 0
+#define HUB_PORT_PD_STATUS 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HUB_EXT_PORT_STATUS 2
 #define HUB_CLEAR_TT_BUFFER 8
 #define HUB_RESET_TT 9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HUB_GET_TT_STATE 10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HUB_STOP_TT 11
 #define HUB_SET_DEPTH 12
 #define HUB_GET_PORT_ERR_COUNT 13
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define C_HUB_LOCAL_POWER 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define C_HUB_OVER_CURRENT 1
 #define USB_PORT_FEAT_CONNECTION 0
 #define USB_PORT_FEAT_ENABLE 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_SUSPEND 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_OVER_CURRENT 3
 #define USB_PORT_FEAT_RESET 4
 #define USB_PORT_FEAT_L1 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_POWER 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_LOWSPEED 9
 #define USB_PORT_FEAT_C_CONNECTION 16
 #define USB_PORT_FEAT_C_ENABLE 17
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_C_SUSPEND 18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_C_OVER_CURRENT 19
 #define USB_PORT_FEAT_C_RESET 20
 #define USB_PORT_FEAT_TEST 21
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_INDICATOR 22
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_C_PORT_L1 23
 #define USB_PORT_FEAT_LINK_STATE 5
 #define USB_PORT_FEAT_U1_TIMEOUT 23
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_U2_TIMEOUT 24
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_C_PORT_LINK_STATE 25
 #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
 #define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_BH_PORT_RESET 28
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_C_BH_PORT_RESET 29
 #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
 #define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9)
 #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10)
 struct usb_port_status {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 wPortStatus;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 wPortChange;
+  __le32 dwExtPortStatus;
 } __attribute__((packed));
 #define USB_PORT_STAT_CONNECTION 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -121,6 +126,11 @@
 #define USB_PORT_STAT_C_LINK_STATE 0x0040
 #define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_EXT_PORT_STAT_RX_SPEED_ID 0x0000000f
+#define USB_EXT_PORT_STAT_TX_SPEED_ID 0x000000f0
+#define USB_EXT_PORT_STAT_RX_LANES 0x00000f00
+#define USB_EXT_PORT_STAT_TX_LANES 0x0000f000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HUB_CHAR_LPSM 0x0003
 #define HUB_CHAR_COMMON_LPSM 0x0000
 #define HUB_CHAR_INDV_PORT_LPSM 0x0001
diff --git a/libc/kernel/uapi/linux/usb/ch9.h b/libc/kernel/uapi/linux/usb/ch9.h
index 8b96af9..f20b0f2 100644
--- a/libc/kernel/uapi/linux/usb/ch9.h
+++ b/libc/kernel/uapi/linux/usb/ch9.h
@@ -71,470 +71,600 @@
 #define USB_REQ_LOOPBACK_DATA_READ 0x16
 #define USB_REQ_SET_INTERFACE_DS 0x17
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_REQ_GET_PARTNER_PDO 20
+#define USB_REQ_GET_BATTERY_STATUS 21
+#define USB_REQ_SET_PDO 22
+#define USB_REQ_GET_VDM 23
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_REQ_SEND_VDM 24
 #define USB_DEVICE_SELF_POWERED 0
 #define USB_DEVICE_REMOTE_WAKEUP 1
 #define USB_DEVICE_TEST_MODE 2
-#define USB_DEVICE_BATTERY 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DEVICE_BATTERY 2
 #define USB_DEVICE_B_HNP_ENABLE 3
 #define USB_DEVICE_WUSB_DEVICE 3
 #define USB_DEVICE_A_HNP_SUPPORT 4
-#define USB_DEVICE_A_ALT_HNP_SUPPORT 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DEVICE_A_ALT_HNP_SUPPORT 5
 #define USB_DEVICE_DEBUG_MODE 6
 #define TEST_J 1
 #define TEST_K 2
-#define TEST_SE0_NAK 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEST_SE0_NAK 3
 #define TEST_PACKET 4
 #define TEST_FORCE_EN 5
 #define USB_DEVICE_U1_ENABLE 48
-#define USB_DEVICE_U2_ENABLE 49
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DEVICE_U2_ENABLE 49
 #define USB_DEVICE_LTM_ENABLE 50
 #define USB_INTRF_FUNC_SUSPEND 0
 #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
-#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
 #define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
 #define USB_INTRF_STAT_FUNC_RW_CAP 1
 #define USB_INTRF_STAT_FUNC_RW 2
-#define USB_ENDPOINT_HALT 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_ENDPOINT_HALT 0
 #define USB_DEV_STAT_U1_ENABLED 2
 #define USB_DEV_STAT_U2_ENABLED 3
 #define USB_DEV_STAT_LTM_ENABLED 4
-struct usb_ctrlrequest {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DEVICE_BATTERY_WAKE_MASK 40
+#define USB_DEVICE_OS_IS_PD_AWARE 41
+#define USB_DEVICE_POLICY_MODE 42
+#define USB_PORT_PR_SWAP 43
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_PORT_GOTO_MIN 44
+#define USB_PORT_RETURN_POWER 45
+#define USB_PORT_ACCEPT_PD_REQUEST 46
+#define USB_PORT_REJECT_PD_REQUEST 47
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_PORT_PORT_PD_RESET 48
+#define USB_PORT_C_PORT_PD_CHANGE 49
+#define USB_PORT_CABLE_PD_RESET 50
+#define USB_DEVICE_CHARGING_POLICY 54
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct usb_ctrlrequest {
   __u8 bRequestType;
   __u8 bRequest;
   __le16 wValue;
-  __le16 wIndex;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le16 wIndex;
   __le16 wLength;
 } __attribute__((packed));
 #define USB_DT_DEVICE 0x01
-#define USB_DT_CONFIG 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_CONFIG 0x02
 #define USB_DT_STRING 0x03
 #define USB_DT_INTERFACE 0x04
 #define USB_DT_ENDPOINT 0x05
-#define USB_DT_DEVICE_QUALIFIER 0x06
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_DEVICE_QUALIFIER 0x06
 #define USB_DT_OTHER_SPEED_CONFIG 0x07
 #define USB_DT_INTERFACE_POWER 0x08
 #define USB_DT_OTG 0x09
-#define USB_DT_DEBUG 0x0a
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_DEBUG 0x0a
 #define USB_DT_INTERFACE_ASSOCIATION 0x0b
 #define USB_DT_SECURITY 0x0c
 #define USB_DT_KEY 0x0d
-#define USB_DT_ENCRYPTION_TYPE 0x0e
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_ENCRYPTION_TYPE 0x0e
 #define USB_DT_BOS 0x0f
 #define USB_DT_DEVICE_CAPABILITY 0x10
 #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
-#define USB_DT_WIRE_ADAPTER 0x21
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_WIRE_ADAPTER 0x21
 #define USB_DT_RPIPE 0x22
 #define USB_DT_CS_RADIO_CONTROL 0x23
 #define USB_DT_PIPE_USAGE 0x24
-#define USB_DT_SS_ENDPOINT_COMP 0x30
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_SS_ENDPOINT_COMP 0x30
+#define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31
 #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
 #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
 #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
 struct usb_descriptor_header {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct usb_device_descriptor {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 bcdUSB;
   __u8 bDeviceClass;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDeviceSubClass;
   __u8 bDeviceProtocol;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bMaxPacketSize0;
   __le16 idVendor;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 idProduct;
   __le16 bcdDevice;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 iManufacturer;
   __u8 iProduct;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 iSerialNumber;
   __u8 bNumConfigurations;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 #define USB_DT_DEVICE_SIZE 18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_PER_INTERFACE 0
 #define USB_CLASS_AUDIO 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_COMM 2
 #define USB_CLASS_HID 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_PHYSICAL 5
 #define USB_CLASS_STILL_IMAGE 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_PRINTER 7
 #define USB_CLASS_MASS_STORAGE 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_HUB 9
 #define USB_CLASS_CDC_DATA 0x0a
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_CSCID 0x0b
 #define USB_CLASS_CONTENT_SEC 0x0d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_VIDEO 0x0e
 #define USB_CLASS_WIRELESS_CONTROLLER 0xe0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_MISC 0xef
 #define USB_CLASS_APP_SPEC 0xfe
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CLASS_VENDOR_SPEC 0xff
 #define USB_SUBCLASS_VENDOR_SPEC 0xff
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_config_descriptor {
   __u8 bLength;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
   __le16 wTotalLength;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bNumInterfaces;
   __u8 bConfigurationValue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 iConfiguration;
   __u8 bmAttributes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bMaxPower;
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_DT_CONFIG_SIZE 9
 #define USB_CONFIG_ATT_ONE (1 << 7)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CONFIG_ATT_SELFPOWER (1 << 6)
 #define USB_CONFIG_ATT_WAKEUP (1 << 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_CONFIG_ATT_BATTERY (1 << 4)
 struct usb_string_descriptor {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 wData[1];
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_interface_descriptor {
   __u8 bLength;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
   __u8 bInterfaceNumber;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bAlternateSetting;
   __u8 bNumEndpoints;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bInterfaceClass;
   __u8 bInterfaceSubClass;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bInterfaceProtocol;
   __u8 iInterface;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 #define USB_DT_INTERFACE_SIZE 9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_endpoint_descriptor {
   __u8 bLength;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
   __u8 bEndpointAddress;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bmAttributes;
   __le16 wMaxPacketSize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bInterval;
   __u8 bRefresh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bSynchAddress;
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_DT_ENDPOINT_SIZE 7
 #define USB_DT_ENDPOINT_AUDIO_SIZE 9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_NUMBER_MASK 0x0f
 #define USB_ENDPOINT_DIR_MASK 0x80
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_XFERTYPE_MASK 0x03
 #define USB_ENDPOINT_XFER_CONTROL 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_XFER_ISOC 1
 #define USB_ENDPOINT_XFER_BULK 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_XFER_INT 3
 #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_INTRTYPE 0x30
 #define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
 #define USB_ENDPOINT_SYNCTYPE 0x0c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_SYNC_NONE (0 << 2)
 #define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
 #define USB_ENDPOINT_SYNC_SYNC (3 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_USAGE_MASK 0x30
 #define USB_ENDPOINT_USAGE_DATA 0x00
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10
 #define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20
+struct usb_ssp_isoc_ep_comp_descriptor {
+  __u8 bLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorType;
+  __le16 wReseved;
+  __le32 dwBytesPerInterval;
+} __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_SSP_ISOC_EP_COMP_SIZE 8
 struct usb_ss_ep_comp_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
-  __u8 bMaxBurst;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bMaxBurst;
   __u8 bmAttributes;
   __le16 wBytesPerInterval;
 } __attribute__((packed));
-#define USB_DT_SS_EP_COMP_SIZE 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_SS_EP_COMP_SIZE 6
 #define USB_SS_MULT(p) (1 + ((p) & 0x3))
+#define USB_SS_SSP_ISOC_COMP(p) ((p) & (1 << 7))
 struct usb_qualifier_descriptor {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 bcdUSB;
   __u8 bDeviceClass;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDeviceSubClass;
   __u8 bDeviceProtocol;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bMaxPacketSize0;
   __u8 bNumConfigurations;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bRESERVED;
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_otg_descriptor {
   __u8 bLength;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
   __u8 bmAttributes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct usb_otg20_descriptor {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bmAttributes;
   __le16 bcdOTG;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 #define USB_OTG_SRP (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_OTG_HNP (1 << 1)
 #define USB_OTG_ADP (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define OTG_STS_SELECTOR 0xF000
 struct usb_debug_descriptor {
   __u8 bLength;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDebugInEndpoint;
   __u8 bDebugOutEndpoint;
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_interface_assoc_descriptor {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bFirstInterface;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bInterfaceCount;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bFunctionClass;
   __u8 bFunctionSubClass;
   __u8 bFunctionProtocol;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 iFunction;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct usb_security_descriptor {
   __u8 bLength;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 wTotalLength;
   __u8 bNumEncryptionTypes;
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_key_descriptor {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 tTKID[3];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bReserved;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bKeyData[0];
 } __attribute__((packed));
 struct usb_encryption_descriptor {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
   __u8 bEncryptionType;
 #define USB_ENC_TYPE_UNSECURE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENC_TYPE_WIRED 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENC_TYPE_CCM_1 2
 #define USB_ENC_TYPE_RSA_1 3
   __u8 bEncryptionValue;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bAuthKeyIndex;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct usb_bos_descriptor {
   __u8 bLength;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 wTotalLength;
   __u8 bNumDeviceCaps;
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_DT_BOS_SIZE 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_dev_cap_header {
   __u8 bLength;
   __u8 bDescriptorType;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDevCapabilityType;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 #define USB_CAP_TYPE_WIRELESS_USB 1
 struct usb_wireless_cap_descriptor {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
   __u8 bDevCapabilityType;
   __u8 bmAttributes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_P2P_DRD (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_BEACON_MASK (3 << 2)
 #define USB_WIRELESS_BEACON_SELF (1 << 2)
 #define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_BEACON_NONE (3 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 wPHYRates;
 #define USB_WIRELESS_PHY_53 (1 << 0)
 #define USB_WIRELESS_PHY_80 (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_PHY_107 (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_PHY_160 (1 << 3)
 #define USB_WIRELESS_PHY_200 (1 << 4)
 #define USB_WIRELESS_PHY_320 (1 << 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_PHY_400 (1 << 6)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_WIRELESS_PHY_480 (1 << 7)
   __u8 bmTFITXPowerInfo;
   __u8 bmFFITXPowerInfo;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 bmBandGroup;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bReserved;
 } __attribute__((packed));
 #define USB_CAP_TYPE_EXT 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_ext_cap_descriptor {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDevCapabilityType;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 bmAttributes;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_LPM_SUPPORT (1 << 1)
 #define USB_BESL_SUPPORT (1 << 2)
 #define USB_BESL_BASELINE_VALID (1 << 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_BESL_DEEP_VALID (1 << 4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
 #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_DT_USB_EXT_CAP_SIZE 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_SS_CAP_TYPE 3
 struct usb_ss_cap_descriptor {
   __u8 bLength;
+  __u8 bDescriptorType;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDevCapabilityType;
+  __u8 bmAttributes;
+#define USB_LTM_SUPPORT (1 << 1)
+  __le16 wSpeedSupported;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_LOW_SPEED_OPERATION (1)
+#define USB_FULL_SPEED_OPERATION (1 << 1)
+#define USB_HIGH_SPEED_OPERATION (1 << 2)
+#define USB_5GBPS_OPERATION (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bFunctionalitySupport;
+  __u8 bU1devExitLat;
+  __le16 bU2DevExitLat;
+} __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_DT_USB_SS_CAP_SIZE 10
+#define CONTAINER_ID_TYPE 4
+struct usb_ss_container_id_descriptor {
+  __u8 bLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bDescriptorType;
   __u8 bDevCapabilityType;
-  __u8 bmAttributes;
-#define USB_LTM_SUPPORT (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 wSpeedSupported;
-#define USB_LOW_SPEED_OPERATION (1)
-#define USB_FULL_SPEED_OPERATION (1 << 1)
-#define USB_HIGH_SPEED_OPERATION (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_5GBPS_OPERATION (1 << 3)
-  __u8 bFunctionalitySupport;
-  __u8 bU1devExitLat;
-  __le16 bU2DevExitLat;
+  __u8 bReserved;
+  __u8 ContainerID[16];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
-#define USB_DT_USB_SS_CAP_SIZE 10
-#define CONTAINER_ID_TYPE 4
-struct usb_ss_container_id_descriptor {
+#define USB_DT_USB_SS_CONTN_ID_SIZE 20
+#define USB_SSP_CAP_TYPE 0xa
+struct usb_ssp_cap_descriptor {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDevCapabilityType;
   __u8 bReserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u8 ContainerID[16];
-} __attribute__((packed));
-#define USB_DT_USB_SS_CONTN_ID_SIZE 20
-#define USB_SSP_CAP_TYPE 0xa
+  __le32 bmAttributes;
+#define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0)
+#define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5)
+  __le16 wFunctionalitySupport;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-struct usb_ssp_cap_descriptor {
+#define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf)
+#define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
+#define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
+  __le16 wReserved;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 bmSublinkSpeedAttr[1];
+#define USB_SSP_SUBLINK_SPEED_SSID (0xf)
+#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4)
+#define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8)
+#define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14)
+#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16)
+} __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_PD_POWER_DELIVERY_CAPABILITY 0x06
+#define USB_PD_BATTERY_INFO_CAPABILITY 0x07
+#define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08
+#define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct usb_pd_cap_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDevCapabilityType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bReserved;
   __le32 bmAttributes;
-#define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0)
-#define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5)
+#define USB_PD_CAP_BATTERY_CHARGING (1 << 1)
+#define USB_PD_CAP_USB_PD (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u16 wFunctionalitySupport;
-#define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf)
-#define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
-#define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
+#define USB_PD_CAP_PROVIDER (1 << 3)
+#define USB_PD_CAP_CONSUMER (1 << 4)
+#define USB_PD_CAP_CHARGING_POLICY (1 << 5)
+#define USB_PD_CAP_TYPE_C_CURRENT (1 << 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __le16 wReserved;
-  __le32 bmSublinkSpeedAttr[1];
-#define USB_SSP_SUBLINK_SPEED_SSID (0xf)
-#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4)
+#define USB_PD_CAP_PWR_AC (1 << 8)
+#define USB_PD_CAP_PWR_BAT (1 << 9)
+#define USB_PD_CAP_PWR_USE_V_BUS (1 << 14)
+  __le16 bmProviderPorts;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6)
-#define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8)
-#define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14)
-#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16)
+  __le16 bmConsumerPorts;
+  __le16 bcdBCVersion;
+  __le16 bcdPDVersion;
+  __le16 bcdUSBTypeCVersion;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
-struct usb_wireless_ep_comp_descriptor {
+struct usb_pd_cap_battery_info_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDevCapabilityType;
+  __u8 iBattery;
+  __u8 iSerial;
+  __u8 iManufacturer;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bBatteryId;
+  __u8 bReserved;
+  __le32 dwChargedThreshold;
+  __le32 dwWeakThreshold;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 dwBatteryDesignCapacity;
+  __le32 dwBatteryLastFullchargeCapacity;
+} __attribute__((packed));
+struct usb_pd_cap_consumer_port_descriptor {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bLength;
+  __u8 bDescriptorType;
+  __u8 bDevCapabilityType;
+  __u8 bReserved;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bmCapabilities;
+#define USB_PD_CAP_CONSUMER_BC (1 << 0)
+#define USB_PD_CAP_CONSUMER_PD (1 << 1)
+#define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le16 wMinVoltage;
+  __le16 wMaxVoltage;
+  __u16 wReserved;
+  __le32 dwMaxOperatingPower;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 dwMaxPeakPower;
+  __le32 dwMaxPeakPowerTime;
+#define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff
+} __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct usb_pd_cap_provider_port_descriptor {
+  __u8 bLength;
+  __u8 bDescriptorType;
+  __u8 bDevCapabilityType;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bReserved1;
+  __u8 bmCapabilities;
+#define USB_PD_CAP_PROVIDER_BC (1 << 0)
+#define USB_PD_CAP_PROVIDER_PD (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2)
+  __u8 bNumOfPDObjects;
+  __u8 bReserved2;
+  __le32 wPowerDataObject[];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((packed));
+#define USB_PTM_CAP_TYPE 0xb
+struct usb_ptm_cap_descriptor {
+  __u8 bLength;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorType;
+  __u8 bDevCapabilityType;
+} __attribute__((packed));
+#define USB_DT_USB_SSP_CAP_SIZE(ssac) (16 + ssac * 4)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct usb_wireless_ep_comp_descriptor {
+  __u8 bLength;
+  __u8 bDescriptorType;
   __u8 bMaxBurst;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bMaxSequence;
   __le16 wMaxStreamDelay;
   __le16 wOverTheAirPacketSize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bOverTheAirInterval;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bmCompAttributes;
 #define USB_ENDPOINT_SWITCH_MASK 0x03
 #define USB_ENDPOINT_SWITCH_NO 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_SWITCH_SWITCH 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USB_ENDPOINT_SWITCH_SCALE 2
 } __attribute__((packed));
 struct usb_handshake {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bMessageNumber;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 bStatus;
   __u8 tTKID[3];
   __u8 bReserved;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 CDID[16];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 nonce[16];
   __u8 MIC[8];
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usb_connection_context {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 CHID[16];
   __u8 CDID[16];
   __u8 CK[16];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum usb_device_speed {
   USB_SPEED_UNKNOWN = 0,
   USB_SPEED_LOW,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   USB_SPEED_FULL,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   USB_SPEED_HIGH,
   USB_SPEED_WIRELESS,
   USB_SPEED_SUPER,
+  USB_SPEED_SUPER_PLUS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum usb_device_state {
diff --git a/libc/kernel/uapi/linux/usb/tmc.h b/libc/kernel/uapi/linux/usb/tmc.h
index 98f9296..2cf0559 100644
--- a/libc/kernel/uapi/linux/usb/tmc.h
+++ b/libc/kernel/uapi/linux/usb/tmc.h
@@ -36,6 +36,11 @@
 #define USBTMC_REQUEST_GET_CAPABILITIES 7
 #define USBTMC_REQUEST_INDICATOR_PULSE 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USBTMC488_REQUEST_READ_STATUS_BYTE 128
+#define USBTMC488_REQUEST_REN_CONTROL 160
+#define USBTMC488_REQUEST_GOTO_LOCAL 161
+#define USBTMC488_REQUEST_LOCAL_LOCKOUT 162
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBTMC_IOC_NR 91
 #define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1)
 #define USBTMC_IOCTL_CLEAR _IO(USBTMC_IOC_NR, 2)
@@ -44,5 +49,23 @@
 #define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4)
 #define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6)
 #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
-#endif
+#define USBTMC488_IOCTL_GET_CAPS _IOR(USBTMC_IOC_NR, 17, unsigned char)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USBTMC488_IOCTL_READ_STB _IOR(USBTMC_IOC_NR, 18, unsigned char)
+#define USBTMC488_IOCTL_REN_CONTROL _IOW(USBTMC_IOC_NR, 19, unsigned char)
+#define USBTMC488_IOCTL_GOTO_LOCAL _IO(USBTMC_IOC_NR, 20)
+#define USBTMC488_IOCTL_LOCAL_LOCKOUT _IO(USBTMC_IOC_NR, 21)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USBTMC488_CAPABILITY_TRIGGER 1
+#define USBTMC488_CAPABILITY_SIMPLE 2
+#define USBTMC488_CAPABILITY_REN_CONTROL 2
+#define USBTMC488_CAPABILITY_GOTO_LOCAL 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USBTMC488_CAPABILITY_LOCAL_LOCKOUT 2
+#define USBTMC488_CAPABILITY_488_DOT_2 4
+#define USBTMC488_CAPABILITY_DT1 16
+#define USBTMC488_CAPABILITY_RL1 32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USBTMC488_CAPABILITY_SR1 64
+#define USBTMC488_CAPABILITY_FULL_SCPI 128
+#endif
diff --git a/libc/kernel/uapi/linux/usb/video.h b/libc/kernel/uapi/linux/usb/video.h
index ab10ed8..9b2ce65 100644
--- a/libc/kernel/uapi/linux/usb/video.h
+++ b/libc/kernel/uapi/linux/usb/video.h
@@ -26,435 +26,436 @@
 #define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
 #define UVC_PC_PROTOCOL_UNDEFINED 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_PC_PROTOCOL_15 0x01
 #define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
 #define UVC_VC_HEADER 0x01
 #define UVC_VC_INPUT_TERMINAL 0x02
-#define UVC_VC_OUTPUT_TERMINAL 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VC_OUTPUT_TERMINAL 0x03
 #define UVC_VC_SELECTOR_UNIT 0x04
 #define UVC_VC_PROCESSING_UNIT 0x05
 #define UVC_VC_EXTENSION_UNIT 0x06
-#define UVC_VS_UNDEFINED 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VS_UNDEFINED 0x00
 #define UVC_VS_INPUT_HEADER 0x01
 #define UVC_VS_OUTPUT_HEADER 0x02
 #define UVC_VS_STILL_IMAGE_FRAME 0x03
-#define UVC_VS_FORMAT_UNCOMPRESSED 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VS_FORMAT_UNCOMPRESSED 0x04
 #define UVC_VS_FRAME_UNCOMPRESSED 0x05
 #define UVC_VS_FORMAT_MJPEG 0x06
 #define UVC_VS_FRAME_MJPEG 0x07
-#define UVC_VS_FORMAT_MPEG2TS 0x0a
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VS_FORMAT_MPEG2TS 0x0a
 #define UVC_VS_FORMAT_DV 0x0c
 #define UVC_VS_COLORFORMAT 0x0d
 #define UVC_VS_FORMAT_FRAME_BASED 0x10
-#define UVC_VS_FRAME_FRAME_BASED 0x11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VS_FRAME_FRAME_BASED 0x11
 #define UVC_VS_FORMAT_STREAM_BASED 0x12
 #define UVC_EP_UNDEFINED 0x00
 #define UVC_EP_GENERAL 0x01
-#define UVC_EP_ENDPOINT 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_EP_ENDPOINT 0x02
 #define UVC_EP_INTERRUPT 0x03
 #define UVC_RC_UNDEFINED 0x00
 #define UVC_SET_CUR 0x01
-#define UVC_GET_CUR 0x81
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_GET_CUR 0x81
 #define UVC_GET_MIN 0x82
 #define UVC_GET_MAX 0x83
 #define UVC_GET_RES 0x84
-#define UVC_GET_LEN 0x85
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_GET_LEN 0x85
 #define UVC_GET_INFO 0x86
 #define UVC_GET_DEF 0x87
 #define UVC_VC_CONTROL_UNDEFINED 0x00
-#define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
 #define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
 #define UVC_TE_CONTROL_UNDEFINED 0x00
 #define UVC_SU_CONTROL_UNDEFINED 0x00
-#define UVC_SU_INPUT_SELECT_CONTROL 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_SU_INPUT_SELECT_CONTROL 0x01
 #define UVC_CT_CONTROL_UNDEFINED 0x00
 #define UVC_CT_SCANNING_MODE_CONTROL 0x01
 #define UVC_CT_AE_MODE_CONTROL 0x02
-#define UVC_CT_AE_PRIORITY_CONTROL 0x03
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_CT_AE_PRIORITY_CONTROL 0x03
 #define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
 #define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
 #define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
-#define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
 #define UVC_CT_FOCUS_AUTO_CONTROL 0x08
 #define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
 #define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
-#define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
 #define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
 #define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
 #define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
-#define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
 #define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
 #define UVC_CT_PRIVACY_CONTROL 0x11
 #define UVC_PU_CONTROL_UNDEFINED 0x00
-#define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
 #define UVC_PU_BRIGHTNESS_CONTROL 0x02
 #define UVC_PU_CONTRAST_CONTROL 0x03
 #define UVC_PU_GAIN_CONTROL 0x04
-#define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
 #define UVC_PU_HUE_CONTROL 0x06
 #define UVC_PU_SATURATION_CONTROL 0x07
 #define UVC_PU_SHARPNESS_CONTROL 0x08
-#define UVC_PU_GAMMA_CONTROL 0x09
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_PU_GAMMA_CONTROL 0x09
 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
 #define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
 #define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
-#define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
 #define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
 #define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
 #define UVC_PU_HUE_AUTO_CONTROL 0x10
-#define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
 #define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
 #define UVC_VS_CONTROL_UNDEFINED 0x00
 #define UVC_VS_PROBE_CONTROL 0x01
-#define UVC_VS_COMMIT_CONTROL 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VS_COMMIT_CONTROL 0x02
 #define UVC_VS_STILL_PROBE_CONTROL 0x03
 #define UVC_VS_STILL_COMMIT_CONTROL 0x04
 #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
-#define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
 #define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
 #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
 #define UVC_VS_SYNC_DELAY_CONTROL 0x09
-#define UVC_TT_VENDOR_SPECIFIC 0x0100
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_TT_VENDOR_SPECIFIC 0x0100
 #define UVC_TT_STREAMING 0x0101
 #define UVC_ITT_VENDOR_SPECIFIC 0x0200
 #define UVC_ITT_CAMERA 0x0201
-#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
 #define UVC_OTT_VENDOR_SPECIFIC 0x0300
 #define UVC_OTT_DISPLAY 0x0301
 #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
-#define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
 #define UVC_COMPOSITE_CONNECTOR 0x0401
 #define UVC_SVIDEO_CONNECTOR 0x0402
 #define UVC_COMPONENT_CONNECTOR 0x0403
-#define UVC_STATUS_TYPE_CONTROL 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_STATUS_TYPE_CONTROL 1
 #define UVC_STATUS_TYPE_STREAMING 2
 #define UVC_STREAM_EOH (1 << 7)
 #define UVC_STREAM_ERR (1 << 6)
-#define UVC_STREAM_STI (1 << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_STREAM_STI (1 << 5)
 #define UVC_STREAM_RES (1 << 4)
 #define UVC_STREAM_SCR (1 << 3)
 #define UVC_STREAM_PTS (1 << 2)
-#define UVC_STREAM_EOF (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_STREAM_EOF (1 << 1)
 #define UVC_STREAM_FID (1 << 0)
 #define UVC_CONTROL_CAP_GET (1 << 0)
 #define UVC_CONTROL_CAP_SET (1 << 1)
-#define UVC_CONTROL_CAP_DISABLED (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_CONTROL_CAP_DISABLED (1 << 2)
 #define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
 #define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
 struct uvc_descriptor_header {
-  __u8 bLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDescriptorSubType;
 } __attribute__((packed));
-struct uvc_header_descriptor {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct uvc_header_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDescriptorSubType;
-  __u16 bcdUVC;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 bcdUVC;
   __u16 wTotalLength;
   __u32 dwClockFrequency;
   __u8 bInCollection;
-  __u8 baInterfaceNr[];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 baInterfaceNr[];
 } __attribute__((__packed__));
 #define UVC_DT_HEADER_SIZE(n) (12 + (n))
 #define UVC_HEADER_DESCRIPTOR(n) uvc_header_descriptor_ ##n
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DECLARE_UVC_HEADER_DESCRIPTOR(n) struct UVC_HEADER_DESCRIPTOR(n) { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u16 bcdUVC; __u16 wTotalLength; __u32 dwClockFrequency; __u8 bInCollection; __u8 baInterfaceNr[n]; \
 } __attribute__((packed))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct uvc_input_terminal_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
-  __u8 bDescriptorSubType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorSubType;
   __u8 bTerminalID;
   __u16 wTerminalType;
   __u8 bAssocTerminal;
-  __u8 iTerminal;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 iTerminal;
 } __attribute__((__packed__));
 #define UVC_DT_INPUT_TERMINAL_SIZE 8
 struct uvc_output_terminal_descriptor {
-  __u8 bLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDescriptorSubType;
   __u8 bTerminalID;
-  __u16 wTerminalType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 wTerminalType;
   __u8 bAssocTerminal;
   __u8 bSourceID;
   __u8 iTerminal;
-} __attribute__((__packed__));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
 #define UVC_DT_OUTPUT_TERMINAL_SIZE 9
 struct uvc_camera_terminal_descriptor {
   __u8 bLength;
-  __u8 bDescriptorType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorType;
   __u8 bDescriptorSubType;
   __u8 bTerminalID;
   __u16 wTerminalType;
-  __u8 bAssocTerminal;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bAssocTerminal;
   __u8 iTerminal;
   __u16 wObjectiveFocalLengthMin;
   __u16 wObjectiveFocalLengthMax;
-  __u16 wOcularFocalLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 wOcularFocalLength;
   __u8 bControlSize;
   __u8 bmControls[3];
 } __attribute__((__packed__));
-#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15 + (n))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15 + (n))
 struct uvc_selector_unit_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
-  __u8 bDescriptorSubType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorSubType;
   __u8 bUnitID;
   __u8 bNrInPins;
   __u8 baSourceID[0];
-  __u8 iSelector;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 iSelector;
 } __attribute__((__packed__));
 #define UVC_DT_SELECTOR_UNIT_SIZE(n) (6 + (n))
 #define UVC_SELECTOR_UNIT_DESCRIPTOR(n) uvc_selector_unit_descriptor_ ##n
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u8 bUnitID; __u8 bNrInPins; __u8 baSourceID[n]; __u8 iSelector; \
 } __attribute__((packed))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct uvc_processing_unit_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
-  __u8 bDescriptorSubType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorSubType;
   __u8 bUnitID;
   __u8 bSourceID;
   __u16 wMaxMultiplier;
-  __u8 bControlSize;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bControlSize;
   __u8 bmControls[2];
   __u8 iProcessing;
 } __attribute__((__packed__));
-#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9 + (n))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9 + (n))
 struct uvc_extension_unit_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
-  __u8 bDescriptorSubType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorSubType;
   __u8 bUnitID;
   __u8 guidExtensionCode[16];
   __u8 bNumControls;
-  __u8 bNrInPins;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bNrInPins;
   __u8 baSourceID[0];
   __u8 bControlSize;
   __u8 bmControls[0];
-  __u8 iExtension;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 iExtension;
 } __attribute__((__packed__));
 #define UVC_DT_EXTENSION_UNIT_SIZE(p,n) (24 + (p) + (n))
 #define UVC_EXTENSION_UNIT_DESCRIPTOR(p,n) uvc_extension_unit_descriptor_ ##p_ ##n
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p,n) struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u8 bUnitID; __u8 guidExtensionCode[16]; __u8 bNumControls; __u8 bNrInPins; __u8 baSourceID[p]; __u8 bControlSize; __u8 bmControls[n]; __u8 iExtension; \
 } __attribute__((packed))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct uvc_control_endpoint_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
-  __u8 bDescriptorSubType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorSubType;
   __u16 wMaxTransferSize;
 } __attribute__((__packed__));
 #define UVC_DT_CONTROL_ENDPOINT_SIZE 5
-struct uvc_input_header_descriptor {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct uvc_input_header_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDescriptorSubType;
-  __u8 bNumFormats;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bNumFormats;
   __u16 wTotalLength;
   __u8 bEndpointAddress;
   __u8 bmInfo;
-  __u8 bTerminalLink;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bTerminalLink;
   __u8 bStillCaptureMethod;
   __u8 bTriggerSupport;
   __u8 bTriggerUsage;
-  __u8 bControlSize;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bControlSize;
   __u8 bmaControls[];
 } __attribute__((__packed__));
 #define UVC_DT_INPUT_HEADER_SIZE(n,p) (13 + (n * p))
-#define UVC_INPUT_HEADER_DESCRIPTOR(n,p) uvc_input_header_descriptor_ ##n_ ##p
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_INPUT_HEADER_DESCRIPTOR(n,p) uvc_input_header_descriptor_ ##n_ ##p
 #define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n,p) struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u8 bNumFormats; __u16 wTotalLength; __u8 bEndpointAddress; __u8 bmInfo; __u8 bTerminalLink; __u8 bStillCaptureMethod; __u8 bTriggerSupport; __u8 bTriggerUsage; __u8 bControlSize; __u8 bmaControls[p][n]; \
 } __attribute__((packed))
 struct uvc_output_header_descriptor {
   __u8 bLength;
-  __u8 bDescriptorType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorType;
   __u8 bDescriptorSubType;
   __u8 bNumFormats;
   __u16 wTotalLength;
-  __u8 bEndpointAddress;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bEndpointAddress;
   __u8 bTerminalLink;
   __u8 bControlSize;
   __u8 bmaControls[];
-} __attribute__((__packed__));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
 #define UVC_DT_OUTPUT_HEADER_SIZE(n,p) (9 + (n * p))
 #define UVC_OUTPUT_HEADER_DESCRIPTOR(n,p) uvc_output_header_descriptor_ ##n_ ##p
 #define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n,p) struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u8 bNumFormats; __u16 wTotalLength; __u8 bEndpointAddress; __u8 bTerminalLink; __u8 bControlSize; __u8 bmaControls[p][n]; \
 } __attribute__((packed))
-struct uvc_color_matching_descriptor {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct uvc_color_matching_descriptor {
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDescriptorSubType;
-  __u8 bColorPrimaries;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bColorPrimaries;
   __u8 bTransferCharacteristics;
   __u8 bMatrixCoefficients;
 } __attribute__((__packed__));
-#define UVC_DT_COLOR_MATCHING_SIZE 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UVC_DT_COLOR_MATCHING_SIZE 6
 struct uvc_streaming_control {
   __u16 bmHint;
   __u8 bFormatIndex;
-  __u8 bFrameIndex;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bFrameIndex;
   __u32 dwFrameInterval;
   __u16 wKeyFrameRate;
   __u16 wPFrameRate;
-  __u16 wCompQuality;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 wCompQuality;
   __u16 wCompWindowSize;
   __u16 wDelay;
   __u32 dwMaxVideoFrameSize;
-  __u32 dwMaxPayloadTransferSize;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dwMaxPayloadTransferSize;
   __u32 dwClockFrequency;
   __u8 bmFramingInfo;
   __u8 bPreferedVersion;
-  __u8 bMinVersion;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bMinVersion;
   __u8 bMaxVersion;
 } __attribute__((__packed__));
 struct uvc_format_uncompressed {
-  __u8 bLength;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDescriptorSubType;
   __u8 bFormatIndex;
-  __u8 bNumFrameDescriptors;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bNumFrameDescriptors;
   __u8 guidFormat[16];
   __u8 bBitsPerPixel;
   __u8 bDefaultFrameIndex;
-  __u8 bAspectRatioX;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bAspectRatioX;
   __u8 bAspectRatioY;
   __u8 bmInterfaceFlags;
   __u8 bCopyProtect;
-} __attribute__((__packed__));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
 #define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
 struct uvc_frame_uncompressed {
   __u8 bLength;
-  __u8 bDescriptorType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorType;
   __u8 bDescriptorSubType;
   __u8 bFrameIndex;
   __u8 bmCapabilities;
-  __u16 wWidth;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 wWidth;
   __u16 wHeight;
   __u32 dwMinBitRate;
   __u32 dwMaxBitRate;
-  __u32 dwMaxVideoFrameBufferSize;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dwMaxVideoFrameBufferSize;
   __u32 dwDefaultFrameInterval;
   __u8 bFrameIntervalType;
   __u32 dwFrameInterval[];
-} __attribute__((__packed__));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
 #define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26 + 4 * (n))
 #define UVC_FRAME_UNCOMPRESSED(n) uvc_frame_uncompressed_ ##n
 #define DECLARE_UVC_FRAME_UNCOMPRESSED(n) struct UVC_FRAME_UNCOMPRESSED(n) { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u8 bFrameIndex; __u8 bmCapabilities; __u16 wWidth; __u16 wHeight; __u32 dwMinBitRate; __u32 dwMaxBitRate; __u32 dwMaxVideoFrameBufferSize; __u32 dwDefaultFrameInterval; __u8 bFrameIntervalType; __u32 dwFrameInterval[n]; \
 } __attribute__((packed))
-struct uvc_format_mjpeg {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct uvc_format_mjpeg {
   __u8 bLength;
   __u8 bDescriptorType;
   __u8 bDescriptorSubType;
-  __u8 bFormatIndex;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bFormatIndex;
   __u8 bNumFrameDescriptors;
   __u8 bmFlags;
   __u8 bDefaultFrameIndex;
-  __u8 bAspectRatioX;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bAspectRatioX;
   __u8 bAspectRatioY;
   __u8 bmInterfaceFlags;
   __u8 bCopyProtect;
-} __attribute__((__packed__));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
 #define UVC_DT_FORMAT_MJPEG_SIZE 11
 struct uvc_frame_mjpeg {
   __u8 bLength;
-  __u8 bDescriptorType;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 bDescriptorType;
   __u8 bDescriptorSubType;
   __u8 bFrameIndex;
   __u8 bmCapabilities;
-  __u16 wWidth;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 wWidth;
   __u16 wHeight;
   __u32 dwMinBitRate;
   __u32 dwMaxBitRate;
-  __u32 dwMaxVideoFrameBufferSize;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dwMaxVideoFrameBufferSize;
   __u32 dwDefaultFrameInterval;
   __u8 bFrameIntervalType;
   __u32 dwFrameInterval[];
-} __attribute__((__packed__));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((__packed__));
 #define UVC_DT_FRAME_MJPEG_SIZE(n) (26 + 4 * (n))
 #define UVC_FRAME_MJPEG(n) uvc_frame_mjpeg_ ##n
 #define DECLARE_UVC_FRAME_MJPEG(n) struct UVC_FRAME_MJPEG(n) { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u8 bFrameIndex; __u8 bmCapabilities; __u16 wWidth; __u16 wHeight; __u32 dwMinBitRate; __u32 dwMaxBitRate; __u32 dwMaxVideoFrameBufferSize; __u32 dwDefaultFrameInterval; __u8 bFrameIntervalType; __u32 dwFrameInterval[n]; \
 } __attribute__((packed))
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/usbdevice_fs.h b/libc/kernel/uapi/linux/usbdevice_fs.h
index 285b003..9f2bf73 100644
--- a/libc/kernel/uapi/linux/usbdevice_fs.h
+++ b/libc/kernel/uapi/linux/usbdevice_fs.h
@@ -119,61 +119,65 @@
 #define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
 #define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
 #define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10
-#define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
+#define USBDEVFS_CAP_MMAP 0x20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USBDEVFS_CAP_DROP_PRIVILEGES 0x40
+#define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
 #define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02
 struct usbdevfs_disconnect_claim {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int interface;
   unsigned int flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char driver[USBDEVFS_MAXDRIVERNAME + 1];
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct usbdevfs_streams {
   unsigned int num_streams;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int num_eps;
   unsigned char eps[0];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
 #define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
 #define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)
 #define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver)
 #define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
 #define USBDEVFS_DISCARDURB _IO('U', 11)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_REAPURB _IOW('U', 12, void *)
 #define USBDEVFS_REAPURB32 _IOW('U', 12, __u32)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)
 #define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal)
 #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
 #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
 #define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32)
 #define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_RESET _IO('U', 20)
 #define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_DISCONNECT _IO('U', 22)
 #define USBDEVFS_CONNECT _IO('U', 23)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int)
 #define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32)
 #define USBDEVFS_DISCONNECT_CLAIM _IOR('U', 27, struct usbdevfs_disconnect_claim)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USBDEVFS_ALLOC_STREAMS _IOR('U', 28, struct usbdevfs_streams)
 #define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/v4l2-controls.h b/libc/kernel/uapi/linux/v4l2-controls.h
index 8267d37..99e03e1 100644
--- a/libc/kernel/uapi/linux/v4l2-controls.h
+++ b/libc/kernel/uapi/linux/v4l2-controls.h
@@ -378,621 +378,633 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_MPEG_BASE + 227)
 #define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE + 228)
+#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_MPEG_BASE + 229)
 #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE + 300)
-#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE + 301)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE + 301)
 #define V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP (V4L2_CID_MPEG_BASE + 302)
 #define V4L2_CID_MPEG_VIDEO_H263_MIN_QP (V4L2_CID_MPEG_BASE + 303)
 #define V4L2_CID_MPEG_VIDEO_H263_MAX_QP (V4L2_CID_MPEG_BASE + 304)
-#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP (V4L2_CID_MPEG_BASE + 350)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP (V4L2_CID_MPEG_BASE + 350)
 #define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP (V4L2_CID_MPEG_BASE + 351)
 #define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP (V4L2_CID_MPEG_BASE + 352)
 #define V4L2_CID_MPEG_VIDEO_H264_MIN_QP (V4L2_CID_MPEG_BASE + 353)
-#define V4L2_CID_MPEG_VIDEO_H264_MAX_QP (V4L2_CID_MPEG_BASE + 354)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_MAX_QP (V4L2_CID_MPEG_BASE + 354)
 #define V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM (V4L2_CID_MPEG_BASE + 355)
 #define V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE (V4L2_CID_MPEG_BASE + 356)
 #define V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE (V4L2_CID_MPEG_BASE + 357)
-enum v4l2_mpeg_video_h264_entropy_mode {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum v4l2_mpeg_video_h264_entropy_mode {
   V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC = 0,
   V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC = 1,
 };
-#define V4L2_CID_MPEG_VIDEO_H264_I_PERIOD (V4L2_CID_MPEG_BASE + 358)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_I_PERIOD (V4L2_CID_MPEG_BASE + 358)
 #define V4L2_CID_MPEG_VIDEO_H264_LEVEL (V4L2_CID_MPEG_BASE + 359)
 enum v4l2_mpeg_video_h264_level {
   V4L2_MPEG_VIDEO_H264_LEVEL_1_0 = 0,
-  V4L2_MPEG_VIDEO_H264_LEVEL_1B = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_LEVEL_1B = 1,
   V4L2_MPEG_VIDEO_H264_LEVEL_1_1 = 2,
   V4L2_MPEG_VIDEO_H264_LEVEL_1_2 = 3,
   V4L2_MPEG_VIDEO_H264_LEVEL_1_3 = 4,
-  V4L2_MPEG_VIDEO_H264_LEVEL_2_0 = 5,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_LEVEL_2_0 = 5,
   V4L2_MPEG_VIDEO_H264_LEVEL_2_1 = 6,
   V4L2_MPEG_VIDEO_H264_LEVEL_2_2 = 7,
   V4L2_MPEG_VIDEO_H264_LEVEL_3_0 = 8,
-  V4L2_MPEG_VIDEO_H264_LEVEL_3_1 = 9,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_LEVEL_3_1 = 9,
   V4L2_MPEG_VIDEO_H264_LEVEL_3_2 = 10,
   V4L2_MPEG_VIDEO_H264_LEVEL_4_0 = 11,
   V4L2_MPEG_VIDEO_H264_LEVEL_4_1 = 12,
-  V4L2_MPEG_VIDEO_H264_LEVEL_4_2 = 13,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_LEVEL_4_2 = 13,
   V4L2_MPEG_VIDEO_H264_LEVEL_5_0 = 14,
   V4L2_MPEG_VIDEO_H264_LEVEL_5_1 = 15,
 };
-#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA (V4L2_CID_MPEG_BASE + 360)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA (V4L2_CID_MPEG_BASE + 360)
 #define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA (V4L2_CID_MPEG_BASE + 361)
 #define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE (V4L2_CID_MPEG_BASE + 362)
 enum v4l2_mpeg_video_h264_loop_filter_mode {
-  V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED = 0,
   V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED = 1,
   V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY = 2,
 };
-#define V4L2_CID_MPEG_VIDEO_H264_PROFILE (V4L2_CID_MPEG_BASE + 363)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_PROFILE (V4L2_CID_MPEG_BASE + 363)
 enum v4l2_mpeg_video_h264_profile {
   V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE = 0,
   V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE = 1,
-  V4L2_MPEG_VIDEO_H264_PROFILE_MAIN = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_PROFILE_MAIN = 2,
   V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED = 3,
   V4L2_MPEG_VIDEO_H264_PROFILE_HIGH = 4,
   V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10 = 5,
-  V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422 = 6,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422 = 6,
   V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_PREDICTIVE = 7,
   V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10_INTRA = 8,
   V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422_INTRA = 9,
-  V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_INTRA = 10,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_INTRA = 10,
   V4L2_MPEG_VIDEO_H264_PROFILE_CAVLC_444_INTRA = 11,
   V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_BASELINE = 12,
   V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_HIGH = 13,
-  V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_HIGH_INTRA = 14,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_HIGH_INTRA = 14,
   V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH = 15,
   V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH = 16,
 };
-#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT (V4L2_CID_MPEG_BASE + 364)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT (V4L2_CID_MPEG_BASE + 364)
 #define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH (V4L2_CID_MPEG_BASE + 365)
 #define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE (V4L2_CID_MPEG_BASE + 366)
 #define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC (V4L2_CID_MPEG_BASE + 367)
-enum v4l2_mpeg_video_h264_vui_sar_idc {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum v4l2_mpeg_video_h264_vui_sar_idc {
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_UNSPECIFIED = 0,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_1x1 = 1,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_12x11 = 2,
-  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_10x11 = 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_10x11 = 3,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_16x11 = 4,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_40x33 = 5,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_24x11 = 6,
-  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_20x11 = 7,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_20x11 = 7,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_32x11 = 8,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_80x33 = 9,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_18x11 = 10,
-  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_15x11 = 11,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_15x11 = 11,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_64x33 = 12,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_160x99 = 13,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_4x3 = 14,
-  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_3x2 = 15,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_3x2 = 15,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_2x1 = 16,
   V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_EXTENDED = 17,
 };
-#define V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING (V4L2_CID_MPEG_BASE + 368)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING (V4L2_CID_MPEG_BASE + 368)
 #define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0 (V4L2_CID_MPEG_BASE + 369)
 #define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE (V4L2_CID_MPEG_BASE + 370)
 enum v4l2_mpeg_video_h264_sei_fp_arrangement_type {
-  V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_CHECKERBOARD = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_CHECKERBOARD = 0,
   V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_COLUMN = 1,
   V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_ROW = 2,
   V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_SIDE_BY_SIDE = 3,
-  V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_TOP_BOTTOM = 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_TOP_BOTTOM = 4,
   V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_TEMPORAL = 5,
 };
 #define V4L2_CID_MPEG_VIDEO_H264_FMO (V4L2_CID_MPEG_BASE + 371)
-#define V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE (V4L2_CID_MPEG_BASE + 372)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE (V4L2_CID_MPEG_BASE + 372)
 enum v4l2_mpeg_video_h264_fmo_map_type {
   V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_INTERLEAVED_SLICES = 0,
   V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_SCATTERED_SLICES = 1,
-  V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_FOREGROUND_WITH_LEFT_OVER = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_FOREGROUND_WITH_LEFT_OVER = 2,
   V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_BOX_OUT = 3,
   V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_RASTER_SCAN = 4,
   V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_WIPE_SCAN = 5,
-  V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_EXPLICIT = 6,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_EXPLICIT = 6,
 };
 #define V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP (V4L2_CID_MPEG_BASE + 373)
 #define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION (V4L2_CID_MPEG_BASE + 374)
-enum v4l2_mpeg_video_h264_fmo_change_dir {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum v4l2_mpeg_video_h264_fmo_change_dir {
   V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_RIGHT = 0,
   V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_LEFT = 1,
 };
-#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE (V4L2_CID_MPEG_BASE + 375)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE (V4L2_CID_MPEG_BASE + 375)
 #define V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH (V4L2_CID_MPEG_BASE + 376)
 #define V4L2_CID_MPEG_VIDEO_H264_ASO (V4L2_CID_MPEG_BASE + 377)
 #define V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER (V4L2_CID_MPEG_BASE + 378)
-#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING (V4L2_CID_MPEG_BASE + 379)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING (V4L2_CID_MPEG_BASE + 379)
 #define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE (V4L2_CID_MPEG_BASE + 380)
 enum v4l2_mpeg_video_h264_hierarchical_coding_type {
   V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_B = 0,
-  V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P = 1,
 };
 #define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER (V4L2_CID_MPEG_BASE + 381)
 #define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP (V4L2_CID_MPEG_BASE + 382)
-#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_MPEG_BASE + 400)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_MPEG_BASE + 400)
 #define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (V4L2_CID_MPEG_BASE + 401)
 #define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (V4L2_CID_MPEG_BASE + 402)
 #define V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP (V4L2_CID_MPEG_BASE + 403)
-#define V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP (V4L2_CID_MPEG_BASE + 404)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP (V4L2_CID_MPEG_BASE + 404)
 #define V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL (V4L2_CID_MPEG_BASE + 405)
 enum v4l2_mpeg_video_mpeg4_level {
   V4L2_MPEG_VIDEO_MPEG4_LEVEL_0 = 0,
-  V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B = 1,
   V4L2_MPEG_VIDEO_MPEG4_LEVEL_1 = 2,
   V4L2_MPEG_VIDEO_MPEG4_LEVEL_2 = 3,
   V4L2_MPEG_VIDEO_MPEG4_LEVEL_3 = 4,
-  V4L2_MPEG_VIDEO_MPEG4_LEVEL_3B = 5,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_MPEG4_LEVEL_3B = 5,
   V4L2_MPEG_VIDEO_MPEG4_LEVEL_4 = 6,
   V4L2_MPEG_VIDEO_MPEG4_LEVEL_5 = 7,
 };
-#define V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE (V4L2_CID_MPEG_BASE + 406)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE (V4L2_CID_MPEG_BASE + 406)
 enum v4l2_mpeg_video_mpeg4_profile {
   V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE = 0,
   V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE = 1,
-  V4L2_MPEG_VIDEO_MPEG4_PROFILE_CORE = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_VIDEO_MPEG4_PROFILE_CORE = 2,
   V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE_SCALABLE = 3,
   V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY = 4,
 };
-#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE + 407)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE + 407)
 #define V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS (V4L2_CID_MPEG_BASE + 500)
 enum v4l2_vp8_num_partitions {
   V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION = 0,
-  V4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS = 1,
   V4L2_CID_MPEG_VIDEO_VPX_4_PARTITIONS = 2,
   V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS = 3,
 };
-#define V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4 (V4L2_CID_MPEG_BASE + 501)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4 (V4L2_CID_MPEG_BASE + 501)
 #define V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES (V4L2_CID_MPEG_BASE + 502)
 enum v4l2_vp8_num_ref_frames {
   V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME = 0,
-  V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME = 1,
   V4L2_CID_MPEG_VIDEO_VPX_3_REF_FRAME = 2,
 };
 #define V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL (V4L2_CID_MPEG_BASE + 503)
-#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS (V4L2_CID_MPEG_BASE + 504)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS (V4L2_CID_MPEG_BASE + 504)
 #define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD (V4L2_CID_MPEG_BASE + 505)
 #define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL (V4L2_CID_MPEG_BASE + 506)
 enum v4l2_vp8_golden_frame_sel {
-  V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV = 0,
   V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_REF_PERIOD = 1,
 };
 #define V4L2_CID_MPEG_VIDEO_VPX_MIN_QP (V4L2_CID_MPEG_BASE + 507)
-#define V4L2_CID_MPEG_VIDEO_VPX_MAX_QP (V4L2_CID_MPEG_BASE + 508)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_VIDEO_VPX_MAX_QP (V4L2_CID_MPEG_BASE + 508)
 #define V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP (V4L2_CID_MPEG_BASE + 509)
 #define V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP (V4L2_CID_MPEG_BASE + 510)
 #define V4L2_CID_MPEG_VIDEO_VPX_PROFILE (V4L2_CID_MPEG_BASE + 511)
-#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
 #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE + 0)
 enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
   V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0,
-  V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1,
 };
 #define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE + 1)
 #define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE + 2)
-enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {
   V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0,
   V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
   V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2,
-  V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3,
   V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4,
 };
 #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE + 3)
-enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type {
   V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0,
   V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
 };
-#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE + 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE + 4)
 enum v4l2_mpeg_cx2341x_video_temporal_filter_mode {
   V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0,
   V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE + 5)
 #define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE + 6)
 enum v4l2_mpeg_cx2341x_video_median_filter_type {
-  V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0,
   V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1,
   V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2,
   V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3,
-  V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4,
 };
 #define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE + 7)
 #define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE + 8)
-#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE + 9)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE + 9)
 #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE + 10)
 #define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE + 11)
 #define V4L2_CID_MPEG_MFC51_BASE (V4L2_CTRL_CLASS_MPEG | 0x1100)
-#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY (V4L2_CID_MPEG_MFC51_BASE + 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY (V4L2_CID_MPEG_MFC51_BASE + 0)
 #define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY_ENABLE (V4L2_CID_MPEG_MFC51_BASE + 1)
 #define V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE (V4L2_CID_MPEG_MFC51_BASE + 2)
 enum v4l2_mpeg_mfc51_video_frame_skip_mode {
-  V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_DISABLED = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_DISABLED = 0,
   V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT = 1,
   V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT = 2,
 };
-#define V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE (V4L2_CID_MPEG_MFC51_BASE + 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE (V4L2_CID_MPEG_MFC51_BASE + 3)
 enum v4l2_mpeg_mfc51_video_force_frame_type {
   V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_DISABLED = 0,
   V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_I_FRAME = 1,
-  V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_NOT_CODED = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_NOT_CODED = 2,
 };
 #define V4L2_CID_MPEG_MFC51_VIDEO_PADDING (V4L2_CID_MPEG_MFC51_BASE + 4)
 #define V4L2_CID_MPEG_MFC51_VIDEO_PADDING_YUV (V4L2_CID_MPEG_MFC51_BASE + 5)
-#define V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT (V4L2_CID_MPEG_MFC51_BASE + 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT (V4L2_CID_MPEG_MFC51_BASE + 6)
 #define V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF (V4L2_CID_MPEG_MFC51_BASE + 7)
 #define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_ACTIVITY (V4L2_CID_MPEG_MFC51_BASE + 50)
 #define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_DARK (V4L2_CID_MPEG_MFC51_BASE + 51)
-#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH (V4L2_CID_MPEG_MFC51_BASE + 52)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH (V4L2_CID_MPEG_MFC51_BASE + 52)
 #define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC (V4L2_CID_MPEG_MFC51_BASE + 53)
 #define V4L2_CID_MPEG_MFC51_VIDEO_H264_NUM_REF_PIC_FOR_P (V4L2_CID_MPEG_MFC51_BASE + 54)
 #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
-#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
 #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE + 1)
 enum v4l2_exposure_auto_type {
   V4L2_EXPOSURE_AUTO = 0,
-  V4L2_EXPOSURE_MANUAL = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_EXPOSURE_MANUAL = 1,
   V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
   V4L2_EXPOSURE_APERTURE_PRIORITY = 3
 };
-#define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 2)
 #define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE + 3)
 #define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 4)
 #define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 5)
-#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE + 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE + 6)
 #define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE + 7)
 #define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 8)
 #define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 9)
-#define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 10)
 #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 11)
 #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE + 12)
 #define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 13)
-#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 14)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 14)
 #define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE + 15)
 #define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE + 16)
 #define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 17)
-#define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 18)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 18)
 #define V4L2_CID_AUTO_EXPOSURE_BIAS (V4L2_CID_CAMERA_CLASS_BASE + 19)
 #define V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE (V4L2_CID_CAMERA_CLASS_BASE + 20)
 enum v4l2_auto_n_preset_white_balance {
-  V4L2_WHITE_BALANCE_MANUAL = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_WHITE_BALANCE_MANUAL = 0,
   V4L2_WHITE_BALANCE_AUTO = 1,
   V4L2_WHITE_BALANCE_INCANDESCENT = 2,
   V4L2_WHITE_BALANCE_FLUORESCENT = 3,
-  V4L2_WHITE_BALANCE_FLUORESCENT_H = 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_WHITE_BALANCE_FLUORESCENT_H = 4,
   V4L2_WHITE_BALANCE_HORIZON = 5,
   V4L2_WHITE_BALANCE_DAYLIGHT = 6,
   V4L2_WHITE_BALANCE_FLASH = 7,
-  V4L2_WHITE_BALANCE_CLOUDY = 8,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_WHITE_BALANCE_CLOUDY = 8,
   V4L2_WHITE_BALANCE_SHADE = 9,
 };
 #define V4L2_CID_WIDE_DYNAMIC_RANGE (V4L2_CID_CAMERA_CLASS_BASE + 21)
-#define V4L2_CID_IMAGE_STABILIZATION (V4L2_CID_CAMERA_CLASS_BASE + 22)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_IMAGE_STABILIZATION (V4L2_CID_CAMERA_CLASS_BASE + 22)
 #define V4L2_CID_ISO_SENSITIVITY (V4L2_CID_CAMERA_CLASS_BASE + 23)
 #define V4L2_CID_ISO_SENSITIVITY_AUTO (V4L2_CID_CAMERA_CLASS_BASE + 24)
 enum v4l2_iso_sensitivity_auto_type {
-  V4L2_ISO_SENSITIVITY_MANUAL = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_ISO_SENSITIVITY_MANUAL = 0,
   V4L2_ISO_SENSITIVITY_AUTO = 1,
 };
 #define V4L2_CID_EXPOSURE_METERING (V4L2_CID_CAMERA_CLASS_BASE + 25)
-enum v4l2_exposure_metering {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum v4l2_exposure_metering {
   V4L2_EXPOSURE_METERING_AVERAGE = 0,
   V4L2_EXPOSURE_METERING_CENTER_WEIGHTED = 1,
   V4L2_EXPOSURE_METERING_SPOT = 2,
-  V4L2_EXPOSURE_METERING_MATRIX = 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_EXPOSURE_METERING_MATRIX = 3,
 };
 #define V4L2_CID_SCENE_MODE (V4L2_CID_CAMERA_CLASS_BASE + 26)
 enum v4l2_scene_mode {
-  V4L2_SCENE_MODE_NONE = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_SCENE_MODE_NONE = 0,
   V4L2_SCENE_MODE_BACKLIGHT = 1,
   V4L2_SCENE_MODE_BEACH_SNOW = 2,
   V4L2_SCENE_MODE_CANDLE_LIGHT = 3,
-  V4L2_SCENE_MODE_DAWN_DUSK = 4,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_SCENE_MODE_DAWN_DUSK = 4,
   V4L2_SCENE_MODE_FALL_COLORS = 5,
   V4L2_SCENE_MODE_FIREWORKS = 6,
   V4L2_SCENE_MODE_LANDSCAPE = 7,
-  V4L2_SCENE_MODE_NIGHT = 8,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_SCENE_MODE_NIGHT = 8,
   V4L2_SCENE_MODE_PARTY_INDOOR = 9,
   V4L2_SCENE_MODE_PORTRAIT = 10,
   V4L2_SCENE_MODE_SPORTS = 11,
-  V4L2_SCENE_MODE_SUNSET = 12,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_SCENE_MODE_SUNSET = 12,
   V4L2_SCENE_MODE_TEXT = 13,
 };
 #define V4L2_CID_3A_LOCK (V4L2_CID_CAMERA_CLASS_BASE + 27)
-#define V4L2_LOCK_EXPOSURE (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_LOCK_EXPOSURE (1 << 0)
 #define V4L2_LOCK_WHITE_BALANCE (1 << 1)
 #define V4L2_LOCK_FOCUS (1 << 2)
 #define V4L2_CID_AUTO_FOCUS_START (V4L2_CID_CAMERA_CLASS_BASE + 28)
-#define V4L2_CID_AUTO_FOCUS_STOP (V4L2_CID_CAMERA_CLASS_BASE + 29)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_AUTO_FOCUS_STOP (V4L2_CID_CAMERA_CLASS_BASE + 29)
 #define V4L2_CID_AUTO_FOCUS_STATUS (V4L2_CID_CAMERA_CLASS_BASE + 30)
 #define V4L2_AUTO_FOCUS_STATUS_IDLE (0 << 0)
 #define V4L2_AUTO_FOCUS_STATUS_BUSY (1 << 0)
-#define V4L2_AUTO_FOCUS_STATUS_REACHED (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_AUTO_FOCUS_STATUS_REACHED (1 << 1)
 #define V4L2_AUTO_FOCUS_STATUS_FAILED (1 << 2)
 #define V4L2_CID_AUTO_FOCUS_RANGE (V4L2_CID_CAMERA_CLASS_BASE + 31)
 enum v4l2_auto_focus_range {
-  V4L2_AUTO_FOCUS_RANGE_AUTO = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_AUTO_FOCUS_RANGE_AUTO = 0,
   V4L2_AUTO_FOCUS_RANGE_NORMAL = 1,
   V4L2_AUTO_FOCUS_RANGE_MACRO = 2,
   V4L2_AUTO_FOCUS_RANGE_INFINITY = 3,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 32)
 #define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE + 33)
 #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
-#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1)
 #define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1)
 #define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2)
 #define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3)
-#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5)
 #define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
 #define V4L2_CID_RDS_TX_MONO_STEREO (V4L2_CID_FM_TX_CLASS_BASE + 7)
 #define V4L2_CID_RDS_TX_ARTIFICIAL_HEAD (V4L2_CID_FM_TX_CLASS_BASE + 8)
-#define V4L2_CID_RDS_TX_COMPRESSED (V4L2_CID_FM_TX_CLASS_BASE + 9)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_RDS_TX_COMPRESSED (V4L2_CID_FM_TX_CLASS_BASE + 9)
 #define V4L2_CID_RDS_TX_DYNAMIC_PTY (V4L2_CID_FM_TX_CLASS_BASE + 10)
 #define V4L2_CID_RDS_TX_TRAFFIC_ANNOUNCEMENT (V4L2_CID_FM_TX_CLASS_BASE + 11)
 #define V4L2_CID_RDS_TX_TRAFFIC_PROGRAM (V4L2_CID_FM_TX_CLASS_BASE + 12)
-#define V4L2_CID_RDS_TX_MUSIC_SPEECH (V4L2_CID_FM_TX_CLASS_BASE + 13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_RDS_TX_MUSIC_SPEECH (V4L2_CID_FM_TX_CLASS_BASE + 13)
 #define V4L2_CID_RDS_TX_ALT_FREQS_ENABLE (V4L2_CID_FM_TX_CLASS_BASE + 14)
 #define V4L2_CID_RDS_TX_ALT_FREQS (V4L2_CID_FM_TX_CLASS_BASE + 15)
 #define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
-#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 65)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 65)
 #define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 66)
 #define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 80)
 #define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FM_TX_CLASS_BASE + 81)
-#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 82)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 82)
 #define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FM_TX_CLASS_BASE + 83)
 #define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 84)
 #define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 96)
-#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 97)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 97)
 #define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FM_TX_CLASS_BASE + 98)
 #define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112)
 enum v4l2_preemphasis {
-  V4L2_PREEMPHASIS_DISABLED = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_PREEMPHASIS_DISABLED = 0,
   V4L2_PREEMPHASIS_50_uS = 1,
   V4L2_PREEMPHASIS_75_uS = 2,
 };
-#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113)
 #define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114)
 #define V4L2_CID_FLASH_CLASS_BASE (V4L2_CTRL_CLASS_FLASH | 0x900)
 #define V4L2_CID_FLASH_CLASS (V4L2_CTRL_CLASS_FLASH | 1)
-#define V4L2_CID_FLASH_LED_MODE (V4L2_CID_FLASH_CLASS_BASE + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_FLASH_LED_MODE (V4L2_CID_FLASH_CLASS_BASE + 1)
 enum v4l2_flash_led_mode {
   V4L2_FLASH_LED_MODE_NONE,
   V4L2_FLASH_LED_MODE_FLASH,
-  V4L2_FLASH_LED_MODE_TORCH,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_FLASH_LED_MODE_TORCH,
 };
 #define V4L2_CID_FLASH_STROBE_SOURCE (V4L2_CID_FLASH_CLASS_BASE + 2)
 enum v4l2_flash_strobe_source {
-  V4L2_FLASH_STROBE_SOURCE_SOFTWARE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_FLASH_STROBE_SOURCE_SOFTWARE,
   V4L2_FLASH_STROBE_SOURCE_EXTERNAL,
 };
 #define V4L2_CID_FLASH_STROBE (V4L2_CID_FLASH_CLASS_BASE + 3)
-#define V4L2_CID_FLASH_STROBE_STOP (V4L2_CID_FLASH_CLASS_BASE + 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_FLASH_STROBE_STOP (V4L2_CID_FLASH_CLASS_BASE + 4)
 #define V4L2_CID_FLASH_STROBE_STATUS (V4L2_CID_FLASH_CLASS_BASE + 5)
 #define V4L2_CID_FLASH_TIMEOUT (V4L2_CID_FLASH_CLASS_BASE + 6)
 #define V4L2_CID_FLASH_INTENSITY (V4L2_CID_FLASH_CLASS_BASE + 7)
-#define V4L2_CID_FLASH_TORCH_INTENSITY (V4L2_CID_FLASH_CLASS_BASE + 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_FLASH_TORCH_INTENSITY (V4L2_CID_FLASH_CLASS_BASE + 8)
 #define V4L2_CID_FLASH_INDICATOR_INTENSITY (V4L2_CID_FLASH_CLASS_BASE + 9)
 #define V4L2_CID_FLASH_FAULT (V4L2_CID_FLASH_CLASS_BASE + 10)
 #define V4L2_FLASH_FAULT_OVER_VOLTAGE (1 << 0)
-#define V4L2_FLASH_FAULT_TIMEOUT (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_FLASH_FAULT_TIMEOUT (1 << 1)
 #define V4L2_FLASH_FAULT_OVER_TEMPERATURE (1 << 2)
 #define V4L2_FLASH_FAULT_SHORT_CIRCUIT (1 << 3)
 #define V4L2_FLASH_FAULT_OVER_CURRENT (1 << 4)
-#define V4L2_FLASH_FAULT_INDICATOR (1 << 5)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_FLASH_FAULT_INDICATOR (1 << 5)
 #define V4L2_FLASH_FAULT_UNDER_VOLTAGE (1 << 6)
 #define V4L2_FLASH_FAULT_INPUT_VOLTAGE (1 << 7)
 #define V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE (1 << 8)
-#define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11)
 #define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12)
 #define V4L2_CID_JPEG_CLASS_BASE (V4L2_CTRL_CLASS_JPEG | 0x900)
 #define V4L2_CID_JPEG_CLASS (V4L2_CTRL_CLASS_JPEG | 1)
-#define V4L2_CID_JPEG_CHROMA_SUBSAMPLING (V4L2_CID_JPEG_CLASS_BASE + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_JPEG_CHROMA_SUBSAMPLING (V4L2_CID_JPEG_CLASS_BASE + 1)
 enum v4l2_jpeg_chroma_subsampling {
   V4L2_JPEG_CHROMA_SUBSAMPLING_444 = 0,
   V4L2_JPEG_CHROMA_SUBSAMPLING_422 = 1,
-  V4L2_JPEG_CHROMA_SUBSAMPLING_420 = 2,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_JPEG_CHROMA_SUBSAMPLING_420 = 2,
   V4L2_JPEG_CHROMA_SUBSAMPLING_411 = 3,
   V4L2_JPEG_CHROMA_SUBSAMPLING_410 = 4,
   V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY = 5,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define V4L2_CID_JPEG_RESTART_INTERVAL (V4L2_CID_JPEG_CLASS_BASE + 2)
 #define V4L2_CID_JPEG_COMPRESSION_QUALITY (V4L2_CID_JPEG_CLASS_BASE + 3)
 #define V4L2_CID_JPEG_ACTIVE_MARKER (V4L2_CID_JPEG_CLASS_BASE + 4)
-#define V4L2_JPEG_ACTIVE_MARKER_APP0 (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_JPEG_ACTIVE_MARKER_APP0 (1 << 0)
 #define V4L2_JPEG_ACTIVE_MARKER_APP1 (1 << 1)
 #define V4L2_JPEG_ACTIVE_MARKER_COM (1 << 16)
 #define V4L2_JPEG_ACTIVE_MARKER_DQT (1 << 17)
-#define V4L2_JPEG_ACTIVE_MARKER_DHT (1 << 18)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_JPEG_ACTIVE_MARKER_DHT (1 << 18)
 #define V4L2_CID_IMAGE_SOURCE_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_SOURCE | 0x900)
 #define V4L2_CID_IMAGE_SOURCE_CLASS (V4L2_CTRL_CLASS_IMAGE_SOURCE | 1)
 #define V4L2_CID_VBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 1)
-#define V4L2_CID_HBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_HBLANK (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 2)
 #define V4L2_CID_ANALOGUE_GAIN (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 3)
 #define V4L2_CID_TEST_PATTERN_RED (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 4)
 #define V4L2_CID_TEST_PATTERN_GREENR (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 5)
-#define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6)
 #define V4L2_CID_TEST_PATTERN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7)
 #define V4L2_CID_IMAGE_PROC_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_PROC | 0x900)
 #define V4L2_CID_IMAGE_PROC_CLASS (V4L2_CTRL_CLASS_IMAGE_PROC | 1)
-#define V4L2_CID_LINK_FREQ (V4L2_CID_IMAGE_PROC_CLASS_BASE + 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_LINK_FREQ (V4L2_CID_IMAGE_PROC_CLASS_BASE + 1)
 #define V4L2_CID_PIXEL_RATE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 2)
 #define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3)
 #define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
-#define V4L2_CID_DV_CLASS (V4L2_CTRL_CLASS_DV | 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_DV_CLASS (V4L2_CTRL_CLASS_DV | 1)
 #define V4L2_CID_DV_TX_HOTPLUG (V4L2_CID_DV_CLASS_BASE + 1)
 #define V4L2_CID_DV_TX_RXSENSE (V4L2_CID_DV_CLASS_BASE + 2)
 #define V4L2_CID_DV_TX_EDID_PRESENT (V4L2_CID_DV_CLASS_BASE + 3)
-#define V4L2_CID_DV_TX_MODE (V4L2_CID_DV_CLASS_BASE + 4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_DV_TX_MODE (V4L2_CID_DV_CLASS_BASE + 4)
 enum v4l2_dv_tx_mode {
   V4L2_DV_TX_MODE_DVI_D = 0,
   V4L2_DV_TX_MODE_HDMI = 1,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define V4L2_CID_DV_TX_RGB_RANGE (V4L2_CID_DV_CLASS_BASE + 5)
 enum v4l2_dv_rgb_range {
   V4L2_DV_RGB_RANGE_AUTO = 0,
-  V4L2_DV_RGB_RANGE_LIMITED = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_DV_RGB_RANGE_LIMITED = 1,
   V4L2_DV_RGB_RANGE_FULL = 2,
 };
-#define V4L2_CID_DV_RX_POWER_PRESENT (V4L2_CID_DV_CLASS_BASE + 100)
-#define V4L2_CID_DV_RX_RGB_RANGE (V4L2_CID_DV_CLASS_BASE + 101)
+#define V4L2_CID_DV_TX_IT_CONTENT_TYPE (V4L2_CID_DV_CLASS_BASE + 6)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum v4l2_dv_it_content_type {
+  V4L2_DV_IT_CONTENT_TYPE_GRAPHICS = 0,
+  V4L2_DV_IT_CONTENT_TYPE_PHOTO = 1,
+  V4L2_DV_IT_CONTENT_TYPE_CINEMA = 2,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_DV_IT_CONTENT_TYPE_GAME = 3,
+  V4L2_DV_IT_CONTENT_TYPE_NO_ITC = 4,
+};
+#define V4L2_CID_DV_RX_POWER_PRESENT (V4L2_CID_DV_CLASS_BASE + 100)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CID_DV_RX_RGB_RANGE (V4L2_CID_DV_CLASS_BASE + 101)
+#define V4L2_CID_DV_RX_IT_CONTENT_TYPE (V4L2_CID_DV_CLASS_BASE + 102)
 #define V4L2_CID_FM_RX_CLASS_BASE (V4L2_CTRL_CLASS_FM_RX | 0x900)
 #define V4L2_CID_FM_RX_CLASS (V4L2_CTRL_CLASS_FM_RX | 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_TUNE_DEEMPHASIS (V4L2_CID_FM_RX_CLASS_BASE + 1)
 enum v4l2_deemphasis {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   V4L2_DEEMPHASIS_DISABLED = V4L2_PREEMPHASIS_DISABLED,
   V4L2_DEEMPHASIS_50_uS = V4L2_PREEMPHASIS_50_uS,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   V4L2_DEEMPHASIS_75_uS = V4L2_PREEMPHASIS_75_uS,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RDS_RECEPTION (V4L2_CID_FM_RX_CLASS_BASE + 2)
 #define V4L2_CID_RDS_RX_PTY (V4L2_CID_FM_RX_CLASS_BASE + 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RDS_RX_PS_NAME (V4L2_CID_FM_RX_CLASS_BASE + 4)
 #define V4L2_CID_RDS_RX_RADIO_TEXT (V4L2_CID_FM_RX_CLASS_BASE + 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RDS_RX_TRAFFIC_ANNOUNCEMENT (V4L2_CID_FM_RX_CLASS_BASE + 6)
 #define V4L2_CID_RDS_RX_TRAFFIC_PROGRAM (V4L2_CID_FM_RX_CLASS_BASE + 7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RDS_RX_MUSIC_SPEECH (V4L2_CID_FM_RX_CLASS_BASE + 8)
 #define V4L2_CID_RF_TUNER_CLASS_BASE (V4L2_CTRL_CLASS_RF_TUNER | 0x900)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RF_TUNER_CLASS (V4L2_CTRL_CLASS_RF_TUNER | 1)
 #define V4L2_CID_RF_TUNER_BANDWIDTH_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 11)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RF_TUNER_BANDWIDTH (V4L2_CID_RF_TUNER_CLASS_BASE + 12)
 #define V4L2_CID_RF_TUNER_RF_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 32)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RF_TUNER_LNA_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 41)
 #define V4L2_CID_RF_TUNER_LNA_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 42)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 51)
 #define V4L2_CID_RF_TUNER_MIXER_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 52)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RF_TUNER_IF_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 61)
 #define V4L2_CID_RF_TUNER_IF_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 62)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_RF_TUNER_PLL_LOCK (V4L2_CID_RF_TUNER_CLASS_BASE + 91)
 #define V4L2_CID_DETECT_CLASS_BASE (V4L2_CTRL_CLASS_DETECT | 0x900)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_DETECT_CLASS (V4L2_CTRL_CLASS_DETECT | 1)
 #define V4L2_CID_DETECT_MD_MODE (V4L2_CID_DETECT_CLASS_BASE + 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum v4l2_detect_md_mode {
   V4L2_DETECT_MD_MODE_DISABLED = 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   V4L2_DETECT_MD_MODE_GLOBAL = 1,
   V4L2_DETECT_MD_MODE_THRESHOLD_GRID = 2,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   V4L2_DETECT_MD_MODE_REGION_GRID = 3,
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_DETECT_MD_GLOBAL_THRESHOLD (V4L2_CID_DETECT_CLASS_BASE + 2)
 #define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4)
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/v4l2-dv-timings.h b/libc/kernel/uapi/linux/v4l2-dv-timings.h
index ac5fb64..2485e28 100644
--- a/libc/kernel/uapi/linux/v4l2-dv-timings.h
+++ b/libc/kernel/uapi/linux/v4l2-dv-timings.h
@@ -63,27 +63,27 @@
 #define V4L2_DV_BT_CEA_1920X1080P60 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(1920, 1080, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 148500000, 88, 44, 148, 4, 5, 36, 0, 0, 0, V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
 }
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_BT_CEA_3840X2160P24 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, 297000000, 1276, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_3840X2160P24 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 297000000, 1276, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
 }
-#define V4L2_DV_BT_CEA_3840X2160P25 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, 297000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_3840X2160P25 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 297000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
-#define V4L2_DV_BT_CEA_3840X2160P30 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, 297000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_3840X2160P30 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 297000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
 }
-#define V4L2_DV_BT_CEA_3840X2160P50 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, 594000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_3840X2160P50 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 594000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_BT_CEA_3840X2160P60 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, 594000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_3840X2160P60 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 594000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
 }
-#define V4L2_DV_BT_CEA_4096X2160P24 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, 297000000, 1020, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_4096X2160P24 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 297000000, 1020, 88, 296, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
 }
-#define V4L2_DV_BT_CEA_4096X2160P25 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, 297000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_4096X2160P25 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 297000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
-#define V4L2_DV_BT_CEA_4096X2160P30 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, 297000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_4096X2160P30 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 297000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
 }
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define V4L2_DV_BT_CEA_4096X2160P50 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, 594000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_4096X2160P50 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 594000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_IS_CE_VIDEO) \
 }
-#define V4L2_DV_BT_CEA_4096X2160P60 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, 594000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
+#define V4L2_DV_BT_CEA_4096X2160P60 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL | V4L2_DV_VSYNC_POS_POL, 594000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS | V4L2_DV_FL_IS_CE_VIDEO) \
 }
 #define V4L2_DV_BT_DMT_640X350P85 {.type = V4L2_DV_BT_656_1120, V4L2_INIT_BT_TIMINGS(640, 350, 0, V4L2_DV_HSYNC_POS_POL, 31500000, 32, 64, 96, 32, 3, 60, 0, 0, 0, V4L2_DV_BT_STD_DMT, 0) \
 }
diff --git a/libc/kernel/uapi/linux/version.h b/libc/kernel/uapi/linux/version.h
index 7bd7753..db01469 100644
--- a/libc/kernel/uapi/linux/version.h
+++ b/libc/kernel/uapi/linux/version.h
@@ -16,5 +16,5 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#define LINUX_VERSION_CODE 263169
+#define LINUX_VERSION_CODE 263938
 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
diff --git a/libc/kernel/uapi/linux/vfio.h b/libc/kernel/uapi/linux/vfio.h
index 1ca071f..01b8956 100644
--- a/libc/kernel/uapi/linux/vfio.h
+++ b/libc/kernel/uapi/linux/vfio.h
@@ -31,254 +31,293 @@
 #define VFIO_TYPE1_NESTING_IOMMU 6
 #define VFIO_SPAPR_TCE_v2_IOMMU 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_NOIOMMU_IOMMU 8
 #define VFIO_TYPE (';')
 #define VFIO_BASE 100
+struct vfio_info_cap_header {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 id;
+  __u16 version;
+  __u32 next;
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_GET_API_VERSION _IO(VFIO_TYPE, VFIO_BASE + 0)
 #define VFIO_CHECK_EXTENSION _IO(VFIO_TYPE, VFIO_BASE + 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_SET_IOMMU _IO(VFIO_TYPE, VFIO_BASE + 2)
 struct vfio_group_status {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 argsz;
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_GROUP_FLAGS_VIABLE (1 << 0)
 #define VFIO_GROUP_FLAGS_CONTAINER_SET (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define VFIO_GROUP_GET_STATUS _IO(VFIO_TYPE, VFIO_BASE + 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_GROUP_SET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 4)
 #define VFIO_GROUP_UNSET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_GROUP_GET_DEVICE_FD _IO(VFIO_TYPE, VFIO_BASE + 6)
 struct vfio_device_info {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 argsz;
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_DEVICE_FLAGS_RESET (1 << 0)
 #define VFIO_DEVICE_FLAGS_PCI (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)
 #define VFIO_DEVICE_FLAGS_AMBA (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 num_regions;
   __u32 num_irqs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct vfio_region_info {
   __u32 argsz;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
 #define VFIO_REGION_INFO_FLAG_READ (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_REGION_INFO_FLAG_WRITE (1 << 1)
 #define VFIO_REGION_INFO_FLAG_MMAP (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_REGION_INFO_FLAG_CAPS (1 << 3)
   __u32 index;
-  __u32 resv;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 cap_offset;
   __u64 size;
   __u64 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
-struct vfio_irq_info {
-  __u32 argsz;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
+#define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1
+struct vfio_region_sparse_mmap_area {
+  __u64 offset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 size;
+};
+struct vfio_region_info_cap_sparse_mmap {
+  struct vfio_info_cap_header header;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 nr_areas;
+  __u32 reserved;
+  struct vfio_region_sparse_mmap_area areas[];
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_REGION_INFO_CAP_TYPE 2
+struct vfio_region_info_cap_type {
+  struct vfio_info_cap_header header;
+  __u32 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 subtype;
+};
+#define VFIO_REGION_TYPE_PCI_VENDOR_TYPE (1 << 31)
+#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1)
+#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)
+#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3)
+struct vfio_irq_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 argsz;
   __u32 flags;
 #define VFIO_IRQ_INFO_EVENTFD (1 << 0)
 #define VFIO_IRQ_INFO_MASKABLE (1 << 1)
-#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)
 #define VFIO_IRQ_INFO_NORESIZE (1 << 3)
   __u32 index;
   __u32 count;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9)
 struct vfio_irq_set {
   __u32 argsz;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
 #define VFIO_IRQ_SET_DATA_NONE (1 << 0)
 #define VFIO_IRQ_SET_DATA_BOOL (1 << 1)
 #define VFIO_IRQ_SET_DATA_EVENTFD (1 << 2)
-#define VFIO_IRQ_SET_ACTION_MASK (1 << 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_IRQ_SET_ACTION_MASK (1 << 3)
 #define VFIO_IRQ_SET_ACTION_UNMASK (1 << 4)
 #define VFIO_IRQ_SET_ACTION_TRIGGER (1 << 5)
   __u32 index;
-  __u32 start;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 start;
   __u32 count;
   __u8 data[];
 };
-#define VFIO_DEVICE_SET_IRQS _IO(VFIO_TYPE, VFIO_BASE + 10)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_DEVICE_SET_IRQS _IO(VFIO_TYPE, VFIO_BASE + 10)
 #define VFIO_IRQ_SET_DATA_TYPE_MASK (VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_DATA_BOOL | VFIO_IRQ_SET_DATA_EVENTFD)
 #define VFIO_IRQ_SET_ACTION_TYPE_MASK (VFIO_IRQ_SET_ACTION_MASK | VFIO_IRQ_SET_ACTION_UNMASK | VFIO_IRQ_SET_ACTION_TRIGGER)
 #define VFIO_DEVICE_RESET _IO(VFIO_TYPE, VFIO_BASE + 11)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   VFIO_PCI_BAR0_REGION_INDEX,
   VFIO_PCI_BAR1_REGION_INDEX,
   VFIO_PCI_BAR2_REGION_INDEX,
-  VFIO_PCI_BAR3_REGION_INDEX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  VFIO_PCI_BAR3_REGION_INDEX,
   VFIO_PCI_BAR4_REGION_INDEX,
   VFIO_PCI_BAR5_REGION_INDEX,
   VFIO_PCI_ROM_REGION_INDEX,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VFIO_PCI_CONFIG_REGION_INDEX,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   VFIO_PCI_VGA_REGION_INDEX,
-  VFIO_PCI_NUM_REGIONS
+  VFIO_PCI_NUM_REGIONS = 9
 };
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   VFIO_PCI_INTX_IRQ_INDEX,
   VFIO_PCI_MSI_IRQ_INDEX,
   VFIO_PCI_MSIX_IRQ_INDEX,
-  VFIO_PCI_ERR_IRQ_INDEX,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  VFIO_PCI_ERR_IRQ_INDEX,
   VFIO_PCI_REQ_IRQ_INDEX,
   VFIO_PCI_NUM_IRQS
 };
-struct vfio_pci_dependent_device {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct vfio_pci_dependent_device {
   __u32 group_id;
   __u16 segment;
   __u8 bus;
-  __u8 devfn;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 devfn;
 };
 struct vfio_pci_hot_reset_info {
   __u32 argsz;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 count;
   struct vfio_pci_dependent_device devices[];
 };
-#define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
 struct vfio_pci_hot_reset {
   __u32 argsz;
   __u32 flags;
-  __u32 count;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 count;
   __s32 group_fds[];
 };
 #define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13)
-struct vfio_iommu_type1_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct vfio_iommu_type1_info {
   __u32 argsz;
   __u32 flags;
 #define VFIO_IOMMU_INFO_PGSIZES (1 << 0)
-  __u64 iova_pgsizes;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 iova_pgsizes;
 };
 #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
 struct vfio_iommu_type1_dma_map {
-  __u32 argsz;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 argsz;
   __u32 flags;
 #define VFIO_DMA_MAP_FLAG_READ (1 << 0)
 #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1)
-  __u64 vaddr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 vaddr;
   __u64 iova;
   __u64 size;
 };
-#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)
 struct vfio_iommu_type1_dma_unmap {
   __u32 argsz;
   __u32 flags;
-  __u64 iova;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 iova;
   __u64 size;
 };
 #define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14)
-#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15)
 #define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16)
 struct vfio_iommu_spapr_tce_ddw_info {
   __u64 pgsizes;
-  __u32 max_dynamic_windows_supported;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_dynamic_windows_supported;
   __u32 levels;
 };
 struct vfio_iommu_spapr_tce_info {
-  __u32 argsz;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 argsz;
   __u32 flags;
 #define VFIO_IOMMU_SPAPR_INFO_DDW (1 << 0)
   __u32 dma32_window_start;
-  __u32 dma32_window_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dma32_window_size;
   struct vfio_iommu_spapr_tce_ddw_info ddw;
 };
 #define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
-struct vfio_eeh_pe_err {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct vfio_eeh_pe_err {
   __u32 type;
   __u32 func;
   __u64 addr;
-  __u64 mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 mask;
 };
 struct vfio_eeh_pe_op {
   __u32 argsz;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 op;
   union {
     struct vfio_eeh_pe_err err;
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
 };
 #define VFIO_EEH_PE_DISABLE 0
 #define VFIO_EEH_PE_ENABLE 1
-#define VFIO_EEH_PE_UNFREEZE_IO 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_EEH_PE_UNFREEZE_IO 2
 #define VFIO_EEH_PE_UNFREEZE_DMA 3
 #define VFIO_EEH_PE_GET_STATE 4
 #define VFIO_EEH_PE_STATE_NORMAL 0
-#define VFIO_EEH_PE_STATE_RESET 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_EEH_PE_STATE_RESET 1
 #define VFIO_EEH_PE_STATE_STOPPED 2
 #define VFIO_EEH_PE_STATE_STOPPED_DMA 4
 #define VFIO_EEH_PE_STATE_UNAVAIL 5
-#define VFIO_EEH_PE_RESET_DEACTIVATE 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_EEH_PE_RESET_DEACTIVATE 5
 #define VFIO_EEH_PE_RESET_HOT 6
 #define VFIO_EEH_PE_RESET_FUNDAMENTAL 7
 #define VFIO_EEH_PE_CONFIGURE 8
-#define VFIO_EEH_PE_INJECT_ERR 9
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_EEH_PE_INJECT_ERR 9
 #define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21)
 struct vfio_iommu_spapr_register_memory {
   __u32 argsz;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u64 vaddr;
   __u64 size;
 };
-#define VFIO_IOMMU_SPAPR_REGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 17)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VFIO_IOMMU_SPAPR_REGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 17)
 #define VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 18)
 struct vfio_iommu_spapr_tce_create {
   __u32 argsz;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 page_shift;
+  __u32 __resv1;
   __u64 window_size;
-  __u32 levels;
-  __u64 start_addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 levels;
+  __u32 __resv2;
+  __u64 start_addr;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VFIO_IOMMU_SPAPR_TCE_CREATE _IO(VFIO_TYPE, VFIO_BASE + 19)
 struct vfio_iommu_spapr_tce_remove {
   __u32 argsz;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 start_addr;
 };
 #define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 20)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/vhost.h b/libc/kernel/uapi/linux/vhost.h
index f5e8f4f..5cf52d2 100644
--- a/libc/kernel/uapi/linux/vhost.h
+++ b/libc/kernel/uapi/linux/vhost.h
@@ -84,23 +84,26 @@
 #define VHOST_SET_VRING_KICK _IOW(VHOST_VIRTIO, 0x20, struct vhost_vring_file)
 #define VHOST_SET_VRING_CALL _IOW(VHOST_VIRTIO, 0x21, struct vhost_vring_file)
 #define VHOST_SET_VRING_ERR _IOW(VHOST_VIRTIO, 0x22, struct vhost_vring_file)
-#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
+#define VHOST_SET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x23, struct vhost_vring_state)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VHOST_GET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x24, struct vhost_vring_state)
+#define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
 #define VHOST_F_LOG_ALL 26
 #define VHOST_NET_F_VIRTIO_NET_HDR 27
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VHOST_SCSI_ABI_VERSION 1
 struct vhost_scsi_target {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int abi_version;
   char vhost_wwpn[224];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short vhost_tpgt;
   unsigned short reserved;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
 #define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
 #define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/linux/videodev2.h b/libc/kernel/uapi/linux/videodev2.h
index ab6a3cf..3c8340a 100644
--- a/libc/kernel/uapi/linux/videodev2.h
+++ b/libc/kernel/uapi/linux/videodev2.h
@@ -308,6 +308,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2')
 #define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'M', '2', '1')
+#define V4L2_PIX_FMT_YUV422M v4l2_fourcc('Y', 'M', '1', '6')
+#define V4L2_PIX_FMT_YVU422M v4l2_fourcc('Y', 'M', '6', '1')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_PIX_FMT_YUV444M v4l2_fourcc('Y', 'M', '2', '4')
+#define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2')
 #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')
 #define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -391,1214 +396,1225 @@
 #define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1')
 #define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I')
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ')
+#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I')
+#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ')
 #define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6')
 #define V4L2_SDR_FMT_CS8 v4l2_fourcc('C', 'S', '0', '8')
 #define V4L2_SDR_FMT_CS14LE v4l2_fourcc('C', 'S', '1', '4')
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_SDR_FMT_RU12LE v4l2_fourcc('R', 'U', '1', '2')
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
 #define V4L2_PIX_FMT_FLAG_PREMUL_ALPHA 0x00000001
 struct v4l2_fmtdesc {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 index;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   __u32 flags;
   __u8 description[32];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pixelformat;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[4];
 };
 #define V4L2_FMT_FLAG_COMPRESSED 0x0001
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FMT_FLAG_EMULATED 0x0002
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum v4l2_frmsizetypes {
   V4L2_FRMSIZE_TYPE_DISCRETE = 1,
   V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   V4L2_FRMSIZE_TYPE_STEPWISE = 3,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_frmsize_discrete {
   __u32 width;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 height;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_frmsize_stepwise {
   __u32 min_width;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 max_width;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 step_width;
   __u32 min_height;
   __u32 max_height;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 step_height;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_frmsizeenum {
   __u32 index;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pixel_format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   union {
     struct v4l2_frmsize_discrete discrete;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct v4l2_frmsize_stepwise stepwise;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
   __u32 reserved[2];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum v4l2_frmivaltypes {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   V4L2_FRMIVAL_TYPE_DISCRETE = 1,
   V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
   V4L2_FRMIVAL_TYPE_STEPWISE = 3,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_frmival_stepwise {
   struct v4l2_fract min;
   struct v4l2_fract max;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_fract step;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_frmivalenum {
   __u32 index;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 pixel_format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 width;
   __u32 height;
   __u32 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct v4l2_fract discrete;
     struct v4l2_frmival_stepwise stepwise;
   };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[2];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_timecode {
   __u32 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 frames;
   __u8 seconds;
   __u8 minutes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 hours;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 userbits[4];
 };
 #define V4L2_TC_TYPE_24FPS 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_TC_TYPE_25FPS 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_TC_TYPE_30FPS 3
 #define V4L2_TC_TYPE_50FPS 4
 #define V4L2_TC_TYPE_60FPS 5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_TC_FLAG_DROPFRAME 0x0001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_TC_FLAG_COLORFRAME 0x0002
 #define V4L2_TC_USERBITS_field 0x000C
 #define V4L2_TC_USERBITS_USERDEFINED 0x0000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_TC_USERBITS_8BITCHARS 0x0008
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_jpegcompression {
   int quality;
   int APPn;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int APP_len;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char APP_data[60];
   int COM_len;
   char COM_data[60];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 jpeg_markers;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_JPEG_MARKER_DHT (1 << 3)
 #define V4L2_JPEG_MARKER_DQT (1 << 4)
 #define V4L2_JPEG_MARKER_DRI (1 << 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_JPEG_MARKER_COM (1 << 6)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_JPEG_MARKER_APP (1 << 7)
 };
 struct v4l2_requestbuffers {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   __u32 memory;
   __u32 reserved[2];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_plane {
   __u32 bytesused;
   __u32 length;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 mem_offset;
     unsigned long userptr;
     __s32 fd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } m;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 data_offset;
   __u32 reserved[11];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_buffer {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 index;
   __u32 type;
   __u32 bytesused;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 field;
   struct timeval timestamp;
   struct v4l2_timecode timecode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 sequence;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 memory;
   union {
     __u32 offset;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     unsigned long userptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct v4l2_plane * planes;
     __s32 fd;
   } m;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 length;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved2;
   __u32 reserved;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_MAPPED 0x00000001
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_QUEUED 0x00000002
 #define V4L2_BUF_FLAG_DONE 0x00000004
 #define V4L2_BUF_FLAG_KEYFRAME 0x00000008
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_PFRAME 0x00000010
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_BFRAME 0x00000020
 #define V4L2_BUF_FLAG_ERROR 0x00000040
 #define V4L2_BUF_FLAG_TIMECODE 0x00000100
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_PREPARED 0x00000400
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x00000800
 #define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x00001000
 #define V4L2_BUF_FLAG_TIMESTAMP_MASK 0x0000e000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x00000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x00002000
 #define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x00004000
 #define V4L2_BUF_FLAG_TSTAMP_SRC_MASK 0x00070000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 0x00000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000
 #define V4L2_BUF_FLAG_LAST 0x00100000
 struct v4l2_exportbuffer {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 index;
   __u32 plane;
   __u32 flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __s32 fd;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[11];
 };
 struct v4l2_framebuffer {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 capability;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   void * base;
   struct {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 width;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 height;
     __u32 pixelformat;
     __u32 field;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 bytesperline;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 sizeimage;
     __u32 colorspace;
     __u32 priv;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } fmt;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
 #define V4L2_FBUF_CAP_CHROMAKEY 0x0002
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
 #define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010
 #define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FBUF_CAP_SRC_CHROMAKEY 0x0080
 #define V4L2_FBUF_FLAG_PRIMARY 0x0001
 #define V4L2_FBUF_FLAG_OVERLAY 0x0002
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008
 #define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010
 #define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_FBUF_FLAG_SRC_CHROMAKEY 0x0040
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_clip {
   struct v4l2_rect c;
   struct v4l2_clip __user * next;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_window {
   struct v4l2_rect w;
   __u32 field;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 chromakey;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_clip __user * clips;
   __u32 clipcount;
   void __user * bitmap;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 global_alpha;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_captureparm {
   __u32 capability;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 capturemode;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_fract timeperframe;
   __u32 extendedmode;
   __u32 readbuffers;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[4];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define V4L2_MODE_HIGHQUALITY 0x0001
 #define V4L2_CAP_TIMEPERFRAME 0x1000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_outputparm {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 capability;
   __u32 outputmode;
   struct v4l2_fract timeperframe;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 extendedmode;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 writebuffers;
   __u32 reserved[4];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_cropcap {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   struct v4l2_rect bounds;
   struct v4l2_rect defrect;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_fract pixelaspect;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_crop {
   __u32 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_rect c;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_selection {
   __u32 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 target;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
   struct v4l2_rect r;
   __u32 reserved[9];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef __u64 v4l2_std_id;
 #define V4L2_STD_PAL_B ((v4l2_std_id) 0x00000001)
 #define V4L2_STD_PAL_B1 ((v4l2_std_id) 0x00000002)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_G ((v4l2_std_id) 0x00000004)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_H ((v4l2_std_id) 0x00000008)
 #define V4L2_STD_PAL_I ((v4l2_std_id) 0x00000010)
 #define V4L2_STD_PAL_D ((v4l2_std_id) 0x00000020)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_D1 ((v4l2_std_id) 0x00000040)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_K ((v4l2_std_id) 0x00000080)
 #define V4L2_STD_PAL_M ((v4l2_std_id) 0x00000100)
 #define V4L2_STD_PAL_N ((v4l2_std_id) 0x00000200)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_Nc ((v4l2_std_id) 0x00000400)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_60 ((v4l2_std_id) 0x00000800)
 #define V4L2_STD_NTSC_M ((v4l2_std_id) 0x00001000)
 #define V4L2_STD_NTSC_M_JP ((v4l2_std_id) 0x00002000)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_NTSC_443 ((v4l2_std_id) 0x00004000)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_NTSC_M_KR ((v4l2_std_id) 0x00008000)
 #define V4L2_STD_SECAM_B ((v4l2_std_id) 0x00010000)
 #define V4L2_STD_SECAM_D ((v4l2_std_id) 0x00020000)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_SECAM_G ((v4l2_std_id) 0x00040000)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_SECAM_H ((v4l2_std_id) 0x00080000)
 #define V4L2_STD_SECAM_K ((v4l2_std_id) 0x00100000)
 #define V4L2_STD_SECAM_K1 ((v4l2_std_id) 0x00200000)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_SECAM_L ((v4l2_std_id) 0x00400000)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_SECAM_LC ((v4l2_std_id) 0x00800000)
 #define V4L2_STD_ATSC_8_VSB ((v4l2_std_id) 0x01000000)
 #define V4L2_STD_ATSC_16_VSB ((v4l2_std_id) 0x02000000)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_NTSC (V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D | V4L2_STD_SECAM_K | V4L2_STD_SECAM_K1)
 #define V4L2_STD_SECAM (V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H | V4L2_STD_SECAM_DK | V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)
 #define V4L2_STD_PAL_BG (V4L2_STD_PAL_B | V4L2_STD_PAL_B1 | V4L2_STD_PAL_G)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL_DK (V4L2_STD_PAL_D | V4L2_STD_PAL_D1 | V4L2_STD_PAL_K)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_PAL (V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_H | V4L2_STD_PAL_I)
 #define V4L2_STD_B (V4L2_STD_PAL_B | V4L2_STD_PAL_B1 | V4L2_STD_SECAM_B)
 #define V4L2_STD_G (V4L2_STD_PAL_G | V4L2_STD_SECAM_G)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_H (V4L2_STD_PAL_H | V4L2_STD_SECAM_H)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_L (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)
 #define V4L2_STD_GH (V4L2_STD_G | V4L2_STD_H)
 #define V4L2_STD_DK (V4L2_STD_PAL_DK | V4L2_STD_SECAM_DK)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_BG (V4L2_STD_B | V4L2_STD_G)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_MN (V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | V4L2_STD_NTSC)
 #define V4L2_STD_MTS (V4L2_STD_NTSC_M | V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)
 #define V4L2_STD_525_60 (V4L2_STD_PAL_M | V4L2_STD_PAL_60 | V4L2_STD_NTSC | V4L2_STD_NTSC_443)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_625_50 (V4L2_STD_PAL | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | V4L2_STD_SECAM)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB | V4L2_STD_ATSC_16_VSB)
 #define V4L2_STD_UNKNOWN 0
 #define V4L2_STD_ALL (V4L2_STD_525_60 | V4L2_STD_625_50)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_standard {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 index;
   v4l2_std_id id;
   __u8 name[24];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_fract frameperiod;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 framelines;
   __u32 reserved[4];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_bt_timings {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 width;
   __u32 height;
   __u32 interlaced;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 polarities;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 pixelclock;
   __u32 hfrontporch;
   __u32 hsync;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 hbackporch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 vfrontporch;
   __u32 vsync;
   __u32 vbackporch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 il_vfrontporch;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 il_vsync;
   __u32 il_vbackporch;
   __u32 standards;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[14];
 } __attribute__((packed));
 #define V4L2_DV_PROGRESSIVE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_INTERLACED 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_VSYNC_POS_POL 0x00000001
 #define V4L2_DV_HSYNC_POS_POL 0x00000002
 #define V4L2_DV_BT_STD_CEA861 (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_BT_STD_DMT (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_BT_STD_CVT (1 << 2)
 #define V4L2_DV_BT_STD_GTF (1 << 3)
 #define V4L2_DV_FL_REDUCED_BLANKING (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_FL_CAN_REDUCE_FPS (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_FL_REDUCED_FPS (1 << 2)
 #define V4L2_DV_FL_HALF_LINE (1 << 3)
 #define V4L2_DV_FL_IS_CE_VIDEO (1 << 4)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_BT_BLANKING_WIDTH(bt) ((bt)->hfrontporch + (bt)->hsync + (bt)->hbackporch)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_BT_FRAME_WIDTH(bt) ((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt))
 #define V4L2_DV_BT_BLANKING_HEIGHT(bt) ((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch)
 #define V4L2_DV_BT_FRAME_HEIGHT(bt) ((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_dv_timings {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   union {
     struct v4l2_bt_timings bt;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u32 reserved[32];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 } __attribute__((packed));
 #define V4L2_DV_BT_656_1120 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_enum_dv_timings {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 index;
   __u32 pad;
   __u32 reserved[2];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_dv_timings timings;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_bt_timings_cap {
   __u32 min_width;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 max_width;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 min_height;
   __u32 max_height;
   __u64 min_pixelclock;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 max_pixelclock;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 standards;
   __u32 capabilities;
   __u32 reserved[16];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_BT_CAP_INTERLACED (1 << 0)
 #define V4L2_DV_BT_CAP_PROGRESSIVE (1 << 1)
 #define V4L2_DV_BT_CAP_REDUCED_BLANKING (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_DV_BT_CAP_CUSTOM (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_dv_timings_cap {
   __u32 type;
   __u32 pad;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[2];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
     struct v4l2_bt_timings_cap bt;
     __u32 raw_data[32];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct v4l2_input {
   __u32 index;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 name[32];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 type;
   __u32 audioset;
   __u32 tuner;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   v4l2_std_id std;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 status;
   __u32 capabilities;
   __u32 reserved[3];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_INPUT_TYPE_TUNER 1
 #define V4L2_INPUT_TYPE_CAMERA 2
 #define V4L2_IN_ST_NO_POWER 0x00000001
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_ST_NO_SIGNAL 0x00000002
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_ST_NO_COLOR 0x00000004
 #define V4L2_IN_ST_HFLIP 0x00000010
 #define V4L2_IN_ST_VFLIP 0x00000020
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_ST_NO_H_LOCK 0x00000100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_ST_COLOR_KILL 0x00000200
 #define V4L2_IN_ST_NO_SYNC 0x00010000
 #define V4L2_IN_ST_NO_EQU 0x00020000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_ST_NO_CARRIER 0x00040000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_ST_MACROVISION 0x01000000
 #define V4L2_IN_ST_NO_ACCESS 0x02000000
 #define V4L2_IN_ST_VTR 0x04000000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_CAP_DV_TIMINGS 0x00000002
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_IN_CAP_CUSTOM_TIMINGS V4L2_IN_CAP_DV_TIMINGS
 #define V4L2_IN_CAP_STD 0x00000004
 #define V4L2_IN_CAP_NATIVE_SIZE 0x00000008
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_output {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 index;
   __u8 name[32];
   __u32 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 audioset;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 modulator;
   v4l2_std_id std;
   __u32 capabilities;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved[3];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define V4L2_OUTPUT_TYPE_MODULATOR 1
 #define V4L2_OUTPUT_TYPE_ANALOG 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_OUT_CAP_DV_TIMINGS 0x00000002
 #define V4L2_OUT_CAP_CUSTOM_TIMINGS V4L2_OUT_CAP_DV_TIMINGS
 #define V4L2_OUT_CAP_STD 0x00000004
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_OUT_CAP_NATIVE_SIZE 0x00000008
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_control {
   __u32 id;
   __s32 value;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct v4l2_ext_control {
   __u32 id;
   __u32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved2[1];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
     __s32 value;
     __s64 value64;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     char __user * string;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     __u8 __user * p_u8;
     __u16 __user * p_u16;
     __u32 __user * p_u32;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     void __user * ptr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
 } __attribute__((packed));
 struct v4l2_ext_controls {
+  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 ctrl_class;
+    __u32 ctrl_class;
+    __u32 which;
+  };
   __u32 count;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 error_idx;
   __u32 reserved[2];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct v4l2_ext_control * controls;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define V4L2_CTRL_ID_MASK (0x0fffffff)
 #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CTRL_ID2WHICH(id) ((id) & 0x0fff0000UL)
 #define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
-#define V4L2_CTRL_MAX_DIMS (4)
-enum v4l2_ctrl_type {
-  V4L2_CTRL_TYPE_INTEGER = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CTRL_MAX_DIMS (4)
+#define V4L2_CTRL_WHICH_CUR_VAL 0
+#define V4L2_CTRL_WHICH_DEF_VAL 0x0f000000
+enum v4l2_ctrl_type {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_CTRL_TYPE_INTEGER = 1,
   V4L2_CTRL_TYPE_BOOLEAN = 2,
   V4L2_CTRL_TYPE_MENU = 3,
   V4L2_CTRL_TYPE_BUTTON = 4,
-  V4L2_CTRL_TYPE_INTEGER64 = 5,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_CTRL_TYPE_INTEGER64 = 5,
   V4L2_CTRL_TYPE_CTRL_CLASS = 6,
   V4L2_CTRL_TYPE_STRING = 7,
   V4L2_CTRL_TYPE_BITMASK = 8,
-  V4L2_CTRL_TYPE_INTEGER_MENU = 9,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_CTRL_TYPE_INTEGER_MENU = 9,
   V4L2_CTRL_COMPOUND_TYPES = 0x0100,
   V4L2_CTRL_TYPE_U8 = 0x0100,
   V4L2_CTRL_TYPE_U16 = 0x0101,
-  V4L2_CTRL_TYPE_U32 = 0x0102,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  V4L2_CTRL_TYPE_U32 = 0x0102,
 };
 struct v4l2_queryctrl {
   __u32 id;
-  __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 type;
   __u8 name[32];
   __s32 minimum;
   __s32 maximum;
-  __s32 step;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 step;
   __s32 default_value;
   __u32 flags;
   __u32 reserved[2];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct v4l2_query_ext_ctrl {
   __u32 id;
   __u32 type;
-  char name[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  char name[32];
   __s64 minimum;
   __s64 maximum;
   __u64 step;
-  __s64 default_value;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s64 default_value;
   __u32 flags;
   __u32 elem_size;
   __u32 elems;
-  __u32 nr_of_dims;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 nr_of_dims;
   __u32 dims[V4L2_CTRL_MAX_DIMS];
   __u32 reserved[32];
 };
-struct v4l2_querymenu {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_querymenu {
   __u32 id;
   __u32 index;
   union {
-    __u8 name[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u8 name[32];
     __s64 value;
   };
   __u32 reserved;
-} __attribute__((packed));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} __attribute__((packed));
 #define V4L2_CTRL_FLAG_DISABLED 0x0001
 #define V4L2_CTRL_FLAG_GRABBED 0x0002
 #define V4L2_CTRL_FLAG_READ_ONLY 0x0004
-#define V4L2_CTRL_FLAG_UPDATE 0x0008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CTRL_FLAG_UPDATE 0x0008
 #define V4L2_CTRL_FLAG_INACTIVE 0x0010
 #define V4L2_CTRL_FLAG_SLIDER 0x0020
 #define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040
-#define V4L2_CTRL_FLAG_VOLATILE 0x0080
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CTRL_FLAG_VOLATILE 0x0080
 #define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100
 #define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200
 #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
-#define V4L2_CTRL_FLAG_NEXT_COMPOUND 0x40000000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CTRL_FLAG_NEXT_COMPOUND 0x40000000
 #define V4L2_CID_MAX_CTRLS 1024
 #define V4L2_CID_PRIVATE_BASE 0x08000000
 struct v4l2_tuner {
-  __u32 index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 index;
   __u8 name[32];
   __u32 type;
   __u32 capability;
-  __u32 rangelow;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rangelow;
   __u32 rangehigh;
   __u32 rxsubchans;
   __u32 audmode;
-  __s32 signal;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 signal;
   __s32 afc;
   __u32 reserved[4];
 };
-struct v4l2_modulator {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_modulator {
   __u32 index;
   __u8 name[32];
   __u32 capability;
-  __u32 rangelow;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rangelow;
   __u32 rangehigh;
   __u32 txsubchans;
   __u32 type;
-  __u32 reserved[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[3];
 };
 #define V4L2_TUNER_CAP_LOW 0x0001
 #define V4L2_TUNER_CAP_NORM 0x0002
-#define V4L2_TUNER_CAP_HWSEEK_BOUNDED 0x0004
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_TUNER_CAP_HWSEEK_BOUNDED 0x0004
 #define V4L2_TUNER_CAP_HWSEEK_WRAP 0x0008
 #define V4L2_TUNER_CAP_STEREO 0x0010
 #define V4L2_TUNER_CAP_LANG2 0x0020
-#define V4L2_TUNER_CAP_SAP 0x0020
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_TUNER_CAP_SAP 0x0020
 #define V4L2_TUNER_CAP_LANG1 0x0040
 #define V4L2_TUNER_CAP_RDS 0x0080
 #define V4L2_TUNER_CAP_RDS_BLOCK_IO 0x0100
-#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200
 #define V4L2_TUNER_CAP_FREQ_BANDS 0x0400
 #define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800
 #define V4L2_TUNER_CAP_1HZ 0x1000
-#define V4L2_TUNER_SUB_MONO 0x0001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_TUNER_SUB_MONO 0x0001
 #define V4L2_TUNER_SUB_STEREO 0x0002
 #define V4L2_TUNER_SUB_LANG2 0x0004
 #define V4L2_TUNER_SUB_SAP 0x0004
-#define V4L2_TUNER_SUB_LANG1 0x0008
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_TUNER_SUB_LANG1 0x0008
 #define V4L2_TUNER_SUB_RDS 0x0010
 #define V4L2_TUNER_MODE_MONO 0x0000
 #define V4L2_TUNER_MODE_STEREO 0x0001
-#define V4L2_TUNER_MODE_LANG2 0x0002
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_TUNER_MODE_LANG2 0x0002
 #define V4L2_TUNER_MODE_SAP 0x0002
 #define V4L2_TUNER_MODE_LANG1 0x0003
 #define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
-struct v4l2_frequency {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_frequency {
   __u32 tuner;
   __u32 type;
   __u32 frequency;
-  __u32 reserved[8];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[8];
 };
 #define V4L2_BAND_MODULATION_VSB (1 << 1)
 #define V4L2_BAND_MODULATION_FM (1 << 2)
-#define V4L2_BAND_MODULATION_AM (1 << 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_BAND_MODULATION_AM (1 << 3)
 struct v4l2_frequency_band {
   __u32 tuner;
   __u32 type;
-  __u32 index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 index;
   __u32 capability;
   __u32 rangelow;
   __u32 rangehigh;
-  __u32 modulation;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 modulation;
   __u32 reserved[9];
 };
 struct v4l2_hw_freq_seek {
-  __u32 tuner;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 tuner;
   __u32 type;
   __u32 seek_upward;
   __u32 wrap_around;
-  __u32 spacing;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 spacing;
   __u32 rangelow;
   __u32 rangehigh;
   __u32 reserved[5];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct v4l2_rds_data {
   __u8 lsb;
   __u8 msb;
-  __u8 block;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 block;
 } __attribute__((packed));
 #define V4L2_RDS_BLOCK_MSK 0x7
 #define V4L2_RDS_BLOCK_A 0
-#define V4L2_RDS_BLOCK_B 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_RDS_BLOCK_B 1
 #define V4L2_RDS_BLOCK_C 2
 #define V4L2_RDS_BLOCK_D 3
 #define V4L2_RDS_BLOCK_C_ALT 4
-#define V4L2_RDS_BLOCK_INVALID 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_RDS_BLOCK_INVALID 7
 #define V4L2_RDS_BLOCK_CORRECTED 0x40
 #define V4L2_RDS_BLOCK_ERROR 0x80
 struct v4l2_audio {
-  __u32 index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 index;
   __u8 name[32];
   __u32 capability;
   __u32 mode;
-  __u32 reserved[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[2];
 };
 #define V4L2_AUDCAP_STEREO 0x00001
 #define V4L2_AUDCAP_AVL 0x00002
-#define V4L2_AUDMODE_AVL 0x00001
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_AUDMODE_AVL 0x00001
 struct v4l2_audioout {
   __u32 index;
   __u8 name[32];
-  __u32 capability;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 capability;
   __u32 mode;
   __u32 reserved[2];
 };
-#define V4L2_ENC_IDX_FRAME_I (0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_ENC_IDX_FRAME_I (0)
 #define V4L2_ENC_IDX_FRAME_P (1)
 #define V4L2_ENC_IDX_FRAME_B (2)
 #define V4L2_ENC_IDX_FRAME_MASK (0xf)
-struct v4l2_enc_idx_entry {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_enc_idx_entry {
   __u64 offset;
   __u64 pts;
   __u32 length;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 reserved[2];
 };
 #define V4L2_ENC_IDX_ENTRIES (64)
-struct v4l2_enc_idx {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_enc_idx {
   __u32 entries;
   __u32 entries_cap;
   __u32 reserved[4];
-  struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES];
 };
 #define V4L2_ENC_CMD_START (0)
 #define V4L2_ENC_CMD_STOP (1)
-#define V4L2_ENC_CMD_PAUSE (2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_ENC_CMD_PAUSE (2)
 #define V4L2_ENC_CMD_RESUME (3)
 #define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0)
 struct v4l2_encoder_cmd {
-  __u32 cmd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 cmd;
   __u32 flags;
   union {
     struct {
-      __u32 data[8];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 data[8];
     } raw;
   };
 };
-#define V4L2_DEC_CMD_START (0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_DEC_CMD_START (0)
 #define V4L2_DEC_CMD_STOP (1)
 #define V4L2_DEC_CMD_PAUSE (2)
 #define V4L2_DEC_CMD_RESUME (3)
-#define V4L2_DEC_CMD_START_MUTE_AUDIO (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_DEC_CMD_START_MUTE_AUDIO (1 << 0)
 #define V4L2_DEC_CMD_PAUSE_TO_BLACK (1 << 0)
 #define V4L2_DEC_CMD_STOP_TO_BLACK (1 << 0)
 #define V4L2_DEC_CMD_STOP_IMMEDIATELY (1 << 1)
-#define V4L2_DEC_START_FMT_NONE (0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_DEC_START_FMT_NONE (0)
 #define V4L2_DEC_START_FMT_GOP (1)
 struct v4l2_decoder_cmd {
   __u32 cmd;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   union {
     struct {
       __u64 pts;
-    } stop;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    } stop;
     struct {
       __s32 speed;
       __u32 format;
-    } start;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    } start;
     struct {
       __u32 data[16];
     } raw;
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
 };
 struct v4l2_vbi_format {
   __u32 sampling_rate;
-  __u32 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 offset;
   __u32 samples_per_line;
   __u32 sample_format;
   __s32 start[2];
-  __u32 count[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 count[2];
   __u32 flags;
   __u32 reserved[2];
 };
-#define V4L2_VBI_UNSYNC (1 << 0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_VBI_UNSYNC (1 << 0)
 #define V4L2_VBI_INTERLACED (1 << 1)
 #define V4L2_VBI_ITU_525_F1_START (1)
 #define V4L2_VBI_ITU_525_F2_START (264)
-#define V4L2_VBI_ITU_625_F1_START (1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_VBI_ITU_625_F1_START (1)
 #define V4L2_VBI_ITU_625_F2_START (314)
 struct v4l2_sliced_vbi_format {
   __u16 service_set;
-  __u16 service_lines[2][24];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 service_lines[2][24];
   __u32 io_size;
   __u32 reserved[2];
 };
-#define V4L2_SLICED_TELETEXT_B (0x0001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_SLICED_TELETEXT_B (0x0001)
 #define V4L2_SLICED_VPS (0x0400)
 #define V4L2_SLICED_CAPTION_525 (0x1000)
 #define V4L2_SLICED_WSS_625 (0x4000)
-#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
 #define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
 struct v4l2_sliced_vbi_cap {
   __u16 service_set;
-  __u16 service_lines[2][24];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 service_lines[2][24];
   __u32 type;
   __u32 reserved[3];
 };
-struct v4l2_sliced_vbi_data {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_sliced_vbi_data {
   __u32 id;
   __u32 field;
   __u32 line;
-  __u32 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved;
   __u8 data[48];
 };
 #define V4L2_MPEG_VBI_IVTV_TELETEXT_B (1)
-#define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4)
 #define V4L2_MPEG_VBI_IVTV_WSS_625 (5)
 #define V4L2_MPEG_VBI_IVTV_VPS (7)
 struct v4l2_mpeg_vbi_itv0_line {
-  __u8 id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 id;
   __u8 data[42];
 } __attribute__((packed));
 struct v4l2_mpeg_vbi_itv0 {
-  __le32 linemask[2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 linemask[2];
   struct v4l2_mpeg_vbi_itv0_line line[35];
 } __attribute__((packed));
 struct v4l2_mpeg_vbi_ITV0 {
-  struct v4l2_mpeg_vbi_itv0_line line[36];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct v4l2_mpeg_vbi_itv0_line line[36];
 } __attribute__((packed));
 #define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0"
 #define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0"
-struct v4l2_mpeg_vbi_fmt_ivtv {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_mpeg_vbi_fmt_ivtv {
   __u8 magic[4];
   union {
     struct v4l2_mpeg_vbi_itv0 itv0;
-    struct v4l2_mpeg_vbi_ITV0 ITV0;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct v4l2_mpeg_vbi_ITV0 ITV0;
   };
 } __attribute__((packed));
 struct v4l2_plane_pix_format {
-  __u32 sizeimage;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 sizeimage;
   __u32 bytesperline;
   __u16 reserved[6];
 } __attribute__((packed));
-struct v4l2_pix_format_mplane {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_pix_format_mplane {
   __u32 width;
   __u32 height;
   __u32 pixelformat;
-  __u32 field;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 field;
   __u32 colorspace;
   struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
   __u8 num_planes;
-  __u8 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 flags;
   __u8 ycbcr_enc;
   __u8 quantization;
   __u8 xfer_func;
-  __u8 reserved[7];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 reserved[7];
 } __attribute__((packed));
 struct v4l2_sdr_format {
   __u32 pixelformat;
-  __u32 buffersize;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 buffersize;
   __u8 reserved[24];
 } __attribute__((packed));
 struct v4l2_format {
-  __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 type;
   union {
     struct v4l2_pix_format pix;
     struct v4l2_pix_format_mplane pix_mp;
-    struct v4l2_window win;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct v4l2_window win;
     struct v4l2_vbi_format vbi;
     struct v4l2_sliced_vbi_format sliced;
     struct v4l2_sdr_format sdr;
-    __u8 raw_data[200];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u8 raw_data[200];
   } fmt;
 };
 struct v4l2_streamparm {
-  __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 type;
   union {
     struct v4l2_captureparm capture;
     struct v4l2_outputparm output;
-    __u8 raw_data[200];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u8 raw_data[200];
   } parm;
 };
 #define V4L2_EVENT_ALL 0
-#define V4L2_EVENT_VSYNC 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_EVENT_VSYNC 1
 #define V4L2_EVENT_EOS 2
 #define V4L2_EVENT_CTRL 3
 #define V4L2_EVENT_FRAME_SYNC 4
-#define V4L2_EVENT_SOURCE_CHANGE 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_EVENT_SOURCE_CHANGE 5
 #define V4L2_EVENT_MOTION_DET 6
 #define V4L2_EVENT_PRIVATE_START 0x08000000
 struct v4l2_event_vsync {
-  __u8 field;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 field;
 } __attribute__((packed));
 #define V4L2_EVENT_CTRL_CH_VALUE (1 << 0)
 #define V4L2_EVENT_CTRL_CH_FLAGS (1 << 1)
-#define V4L2_EVENT_CTRL_CH_RANGE (1 << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_EVENT_CTRL_CH_RANGE (1 << 2)
 struct v4l2_event_ctrl {
   __u32 changes;
   __u32 type;
-  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  union {
     __s32 value;
     __s64 value64;
   };
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __s32 minimum;
   __s32 maximum;
   __s32 step;
-  __s32 default_value;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 default_value;
 };
 struct v4l2_event_frame_sync {
   __u32 frame_sequence;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define V4L2_EVENT_SRC_CH_RESOLUTION (1 << 0)
 struct v4l2_event_src_change {
   __u32 changes;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ (1 << 0)
 struct v4l2_event_motion_det {
   __u32 flags;
-  __u32 frame_sequence;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 frame_sequence;
   __u32 region_mask;
 };
 struct v4l2_event {
-  __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 type;
   union {
     struct v4l2_event_vsync vsync;
     struct v4l2_event_ctrl ctrl;
-    struct v4l2_event_frame_sync frame_sync;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct v4l2_event_frame_sync frame_sync;
     struct v4l2_event_src_change src_change;
     struct v4l2_event_motion_det motion_det;
     __u8 data[64];
-  } u;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  } u;
   __u32 pending;
   __u32 sequence;
   struct timespec timestamp;
-  __u32 id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 id;
   __u32 reserved[8];
 };
 #define V4L2_EVENT_SUB_FL_SEND_INITIAL (1 << 0)
-#define V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK (1 << 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK (1 << 1)
 struct v4l2_event_subscription {
   __u32 type;
   __u32 id;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 reserved[5];
 };
 #define V4L2_CHIP_MATCH_BRIDGE 0
-#define V4L2_CHIP_MATCH_SUBDEV 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CHIP_MATCH_SUBDEV 4
 #define V4L2_CHIP_MATCH_HOST V4L2_CHIP_MATCH_BRIDGE
 #define V4L2_CHIP_MATCH_I2C_DRIVER 1
 #define V4L2_CHIP_MATCH_I2C_ADDR 2
-#define V4L2_CHIP_MATCH_AC97 3
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define V4L2_CHIP_MATCH_AC97 3
 struct v4l2_dbg_match {
   __u32 type;
   union {
-    __u32 addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u32 addr;
     char name[32];
   };
 } __attribute__((packed));
-struct v4l2_dbg_register {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_dbg_register {
   struct v4l2_dbg_match match;
   __u32 size;
   __u64 reg;
-  __u64 val;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 val;
 } __attribute__((packed));
 #define V4L2_CHIP_FL_READABLE (1 << 0)
 #define V4L2_CHIP_FL_WRITABLE (1 << 1)
-struct v4l2_dbg_chip_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct v4l2_dbg_chip_info {
   struct v4l2_dbg_match match;
   char name[32];
   __u32 flags;
-  __u32 reserved[32];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[32];
 } __attribute__((packed));
 struct v4l2_create_buffers {
   __u32 index;
-  __u32 count;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 count;
   __u32 memory;
   struct v4l2_format format;
   __u32 reserved[8];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
 #define VIDIOC_RESERVED _IO('V', 1)
 #define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
-#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
 #define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format)
 #define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers)
 #define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer)
-#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
 #define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
 #define VIDIOC_OVERLAY _IOW('V', 14, int)
 #define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
-#define VIDIOC_EXPBUF _IOWR('V', 16, struct v4l2_exportbuffer)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_EXPBUF _IOWR('V', 16, struct v4l2_exportbuffer)
 #define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
 #define VIDIOC_STREAMON _IOW('V', 18, int)
 #define VIDIOC_STREAMOFF _IOW('V', 19, int)
-#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
 #define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
 #define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id)
 #define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id)
-#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
 #define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input)
 #define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control)
 #define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
-#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
 #define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner)
 #define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
 #define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio)
-#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
 #define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
 #define VIDIOC_G_INPUT _IOR('V', 38, int)
 #define VIDIOC_S_INPUT _IOWR('V', 39, int)
-#define VIDIOC_G_EDID _IOWR('V', 40, struct v4l2_edid)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_EDID _IOWR('V', 40, struct v4l2_edid)
 #define VIDIOC_S_EDID _IOWR('V', 41, struct v4l2_edid)
 #define VIDIOC_G_OUTPUT _IOR('V', 46, int)
 #define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
-#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
 #define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
 #define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout)
 #define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator)
-#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
 #define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency)
 #define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency)
 #define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
-#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
 #define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
 #define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
 #define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
-#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
 #define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
 #define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
 #define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
-#define VIDIOC_G_PRIORITY _IOR('V', 67, __u32)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_PRIORITY _IOR('V', 67, __u32)
 #define VIDIOC_S_PRIORITY _IOW('V', 68, __u32)
 #define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap)
 #define VIDIOC_LOG_STATUS _IO('V', 70)
-#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
 #define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
 #define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
 #define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
-#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
 #define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx)
 #define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd)
 #define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd)
-#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
 #define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register)
 #define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
 #define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings)
-#define VIDIOC_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings)
 #define VIDIOC_DQEVENT _IOR('V', 89, struct v4l2_event)
 #define VIDIOC_SUBSCRIBE_EVENT _IOW('V', 90, struct v4l2_event_subscription)
 #define VIDIOC_UNSUBSCRIBE_EVENT _IOW('V', 91, struct v4l2_event_subscription)
-#define VIDIOC_CREATE_BUFS _IOWR('V', 92, struct v4l2_create_buffers)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_CREATE_BUFS _IOWR('V', 92, struct v4l2_create_buffers)
 #define VIDIOC_PREPARE_BUF _IOWR('V', 93, struct v4l2_buffer)
 #define VIDIOC_G_SELECTION _IOWR('V', 94, struct v4l2_selection)
 #define VIDIOC_S_SELECTION _IOWR('V', 95, struct v4l2_selection)
-#define VIDIOC_DECODER_CMD _IOWR('V', 96, struct v4l2_decoder_cmd)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_DECODER_CMD _IOWR('V', 96, struct v4l2_decoder_cmd)
 #define VIDIOC_TRY_DECODER_CMD _IOWR('V', 97, struct v4l2_decoder_cmd)
 #define VIDIOC_ENUM_DV_TIMINGS _IOWR('V', 98, struct v4l2_enum_dv_timings)
 #define VIDIOC_QUERY_DV_TIMINGS _IOR('V', 99, struct v4l2_dv_timings)
-#define VIDIOC_DV_TIMINGS_CAP _IOWR('V', 100, struct v4l2_dv_timings_cap)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIDIOC_DV_TIMINGS_CAP _IOWR('V', 100, struct v4l2_dv_timings_cap)
 #define VIDIOC_ENUM_FREQ_BANDS _IOWR('V', 101, struct v4l2_frequency_band)
 #define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info)
 #define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl)
-#define BASE_VIDIOC_PRIVATE 192
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define BASE_VIDIOC_PRIVATE 192
 #endif
diff --git a/libc/kernel/uapi/linux/virtio_balloon.h b/libc/kernel/uapi/linux/virtio_balloon.h
index 7f02dc5..c5c3c45 100644
--- a/libc/kernel/uapi/linux/virtio_balloon.h
+++ b/libc/kernel/uapi/linux/virtio_balloon.h
@@ -41,10 +41,11 @@
 #define VIRTIO_BALLOON_S_MEMFREE 4
 #define VIRTIO_BALLOON_S_MEMTOT 5
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIRTIO_BALLOON_S_NR 6
+#define VIRTIO_BALLOON_S_AVAIL 6
+#define VIRTIO_BALLOON_S_NR 7
 struct virtio_balloon_stat {
   __virtio16 tag;
-  __virtio64 val;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __virtio64 val;
 } __attribute__((packed));
 #endif
diff --git a/libc/kernel/uapi/linux/virtio_blk.h b/libc/kernel/uapi/linux/virtio_blk.h
index 9dc7aa7..48abcff 100644
--- a/libc/kernel/uapi/linux/virtio_blk.h
+++ b/libc/kernel/uapi/linux/virtio_blk.h
@@ -36,9 +36,9 @@
 #define VIRTIO_BLK_F_BARRIER 0
 #define VIRTIO_BLK_F_SCSI 7
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define VIRTIO_BLK_F_WCE 9
+#define VIRTIO_BLK_F_FLUSH 9
 #define VIRTIO_BLK_F_CONFIG_WCE 11
-#define VIRTIO_BLK_F_FLUSH VIRTIO_BLK_F_WCE
+#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VIRTIO_BLK_ID_BYTES 20
diff --git a/libc/kernel/uapi/linux/virtio_config.h b/libc/kernel/uapi/linux/virtio_config.h
index 1f41faf..0199978 100644
--- a/libc/kernel/uapi/linux/virtio_config.h
+++ b/libc/kernel/uapi/linux/virtio_config.h
@@ -24,15 +24,16 @@
 #define VIRTIO_CONFIG_S_DRIVER 2
 #define VIRTIO_CONFIG_S_DRIVER_OK 4
 #define VIRTIO_CONFIG_S_FEATURES_OK 8
-#define VIRTIO_CONFIG_S_FAILED 0x80
+#define VIRTIO_CONFIG_S_NEEDS_RESET 0x40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIRTIO_CONFIG_S_FAILED 0x80
 #define VIRTIO_TRANSPORT_F_START 28
 #define VIRTIO_TRANSPORT_F_END 33
 #ifndef VIRTIO_CONFIG_NO_LEGACY
-#define VIRTIO_F_NOTIFY_ON_EMPTY 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VIRTIO_F_NOTIFY_ON_EMPTY 24
 #define VIRTIO_F_ANY_LAYOUT 27
 #endif
 #define VIRTIO_F_VERSION_1 32
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/linux/virtio_gpu.h b/libc/kernel/uapi/linux/virtio_gpu.h
index f7887d9..8d5dd89 100644
--- a/libc/kernel/uapi/linux/virtio_gpu.h
+++ b/libc/kernel/uapi/linux/virtio_gpu.h
@@ -251,7 +251,7 @@
 struct virtio_gpu_resp_capset {
   struct virtio_gpu_ctrl_hdr hdr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  uint8_t capset_data[];
+  __u8 capset_data[];
 };
 #define VIRTIO_GPU_EVENT_DISPLAY (1 << 0)
 struct virtio_gpu_config {
diff --git a/libc/kernel/uapi/linux/vt.h b/libc/kernel/uapi/linux/vt.h
index 5bea24e..74039c7 100644
--- a/libc/kernel/uapi/linux/vt.h
+++ b/libc/kernel/uapi/linux/vt.h
@@ -21,79 +21,78 @@
 #define MIN_NR_CONSOLES 1
 #define MAX_NR_CONSOLES 63
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAX_NR_USER_CONSOLES 63
 #define VT_OPENQRY 0x5600
 struct vt_mode {
   char mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char waitv;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   short relsig;
   short acqsig;
   short frsig;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_GETMODE 0x5601
 #define VT_SETMODE 0x5602
 #define VT_AUTO 0x00
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_PROCESS 0x01
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_ACKACQ 0x02
 struct vt_stat {
   unsigned short v_active;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short v_signal;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short v_state;
 };
 #define VT_GETSTATE 0x5603
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_SENDSIG 0x5604
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_RELDISP 0x5605
 #define VT_ACTIVATE 0x5606
 #define VT_WAITACTIVE 0x5607
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_DISALLOCATE 0x5608
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct vt_sizes {
   unsigned short v_rows;
   unsigned short v_cols;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short v_scrollsize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define VT_RESIZE 0x5609
 struct vt_consize {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short v_rows;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short v_cols;
   unsigned short v_vlin;
   unsigned short v_clin;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short v_vcol;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned short v_ccol;
 };
 #define VT_RESIZEX 0x560A
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_LOCKSWITCH 0x560B
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_UNLOCKSWITCH 0x560C
 #define VT_GETHIFONTMASK 0x560D
 struct vt_event {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int event;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_EVENT_SWITCH 0x0001
 #define VT_EVENT_BLANK 0x0002
 #define VT_EVENT_UNBLANK 0x0004
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_EVENT_RESIZE 0x0008
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VT_MAX_EVENT 0x000F
   unsigned int oldev;
   unsigned int newev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int pad[4];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define VT_WAITEVENT 0x560E
 struct vt_setactivate {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int console;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct vt_mode mode;
 };
 #define VT_SETACTIVATE 0x560F
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/linux/xfrm.h b/libc/kernel/uapi/linux/xfrm.h
index 27f9436..67a8515 100644
--- a/libc/kernel/uapi/linux/xfrm.h
+++ b/libc/kernel/uapi/linux/xfrm.h
@@ -316,239 +316,240 @@
   XFRMA_PROTO,
   XFRMA_ADDRESS_FILTER,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMA_PAD,
   __XFRMA_MAX
 #define XFRMA_MAX (__XFRMA_MAX - 1)
 };
-struct xfrm_mark {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xfrm_mark {
   __u32 v;
   __u32 m;
 };
-enum xfrm_sadattr_type_t {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum xfrm_sadattr_type_t {
   XFRMA_SAD_UNSPEC,
   XFRMA_SAD_CNT,
   XFRMA_SAD_HINFO,
-  __XFRMA_SAD_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __XFRMA_SAD_MAX
 #define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1)
 };
 struct xfrmu_sadhinfo {
-  __u32 sadhcnt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 sadhcnt;
   __u32 sadhmcnt;
 };
 enum xfrm_spdattr_type_t {
-  XFRMA_SPD_UNSPEC,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMA_SPD_UNSPEC,
   XFRMA_SPD_INFO,
   XFRMA_SPD_HINFO,
   XFRMA_SPD_IPV4_HTHRESH,
-  XFRMA_SPD_IPV6_HTHRESH,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMA_SPD_IPV6_HTHRESH,
   __XFRMA_SPD_MAX
 #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1)
 };
-struct xfrmu_spdinfo {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xfrmu_spdinfo {
   __u32 incnt;
   __u32 outcnt;
   __u32 fwdcnt;
-  __u32 inscnt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 inscnt;
   __u32 outscnt;
   __u32 fwdscnt;
 };
-struct xfrmu_spdhinfo {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xfrmu_spdhinfo {
   __u32 spdhcnt;
   __u32 spdhmcnt;
 };
-struct xfrmu_spdhthresh {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xfrmu_spdhthresh {
   __u8 lbits;
   __u8 rbits;
 };
-struct xfrm_usersa_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xfrm_usersa_info {
   struct xfrm_selector sel;
   struct xfrm_id id;
   xfrm_address_t saddr;
-  struct xfrm_lifetime_cfg lft;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xfrm_lifetime_cfg lft;
   struct xfrm_lifetime_cur curlft;
   struct xfrm_stats stats;
   __u32 seq;
-  __u32 reqid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reqid;
   __u16 family;
   __u8 mode;
   __u8 replay_window;
-  __u8 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 flags;
 #define XFRM_STATE_NOECN 1
 #define XFRM_STATE_DECAP_DSCP 2
 #define XFRM_STATE_NOPMTUDISC 4
-#define XFRM_STATE_WILDRECV 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XFRM_STATE_WILDRECV 8
 #define XFRM_STATE_ICMP 16
 #define XFRM_STATE_AF_UNSPEC 32
 #define XFRM_STATE_ALIGN4 64
-#define XFRM_STATE_ESN 128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XFRM_STATE_ESN 128
 };
 #define XFRM_SA_XFLAG_DONT_ENCAP_DSCP 1
 struct xfrm_usersa_id {
-  xfrm_address_t daddr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  xfrm_address_t daddr;
   __be32 spi;
   __u16 family;
   __u8 proto;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct xfrm_aevent_id {
   struct xfrm_usersa_id sa_id;
   xfrm_address_t saddr;
-  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 flags;
   __u32 reqid;
 };
 struct xfrm_userspi_info {
-  struct xfrm_usersa_info info;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xfrm_usersa_info info;
   __u32 min;
   __u32 max;
 };
-struct xfrm_userpolicy_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xfrm_userpolicy_info {
   struct xfrm_selector sel;
   struct xfrm_lifetime_cfg lft;
   struct xfrm_lifetime_cur curlft;
-  __u32 priority;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 priority;
   __u32 index;
   __u8 dir;
   __u8 action;
-#define XFRM_POLICY_ALLOW 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XFRM_POLICY_ALLOW 0
 #define XFRM_POLICY_BLOCK 1
   __u8 flags;
 #define XFRM_POLICY_LOCALOK 1
-#define XFRM_POLICY_ICMP 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XFRM_POLICY_ICMP 2
   __u8 share;
 };
 struct xfrm_userpolicy_id {
-  struct xfrm_selector sel;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xfrm_selector sel;
   __u32 index;
   __u8 dir;
 };
-struct xfrm_user_acquire {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct xfrm_user_acquire {
   struct xfrm_id id;
   xfrm_address_t saddr;
   struct xfrm_selector sel;
-  struct xfrm_userpolicy_info policy;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xfrm_userpolicy_info policy;
   __u32 aalgos;
   __u32 ealgos;
   __u32 calgos;
-  __u32 seq;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 seq;
 };
 struct xfrm_user_expire {
   struct xfrm_usersa_info state;
-  __u8 hard;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 hard;
 };
 struct xfrm_user_polexpire {
   struct xfrm_userpolicy_info pol;
-  __u8 hard;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 hard;
 };
 struct xfrm_usersa_flush {
   __u8 proto;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct xfrm_user_report {
   __u8 proto;
   struct xfrm_selector sel;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct xfrm_user_kmaddress {
   xfrm_address_t local;
   xfrm_address_t remote;
-  __u32 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved;
   __u16 family;
 };
 struct xfrm_user_migrate {
-  xfrm_address_t old_daddr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  xfrm_address_t old_daddr;
   xfrm_address_t old_saddr;
   xfrm_address_t new_daddr;
   xfrm_address_t new_saddr;
-  __u8 proto;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 proto;
   __u8 mode;
   __u16 reserved;
   __u32 reqid;
-  __u16 old_family;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 old_family;
   __u16 new_family;
 };
 struct xfrm_user_mapping {
-  struct xfrm_usersa_id id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct xfrm_usersa_id id;
   __u32 reqid;
   xfrm_address_t old_saddr;
   xfrm_address_t new_saddr;
-  __be16 old_sport;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __be16 old_sport;
   __be16 new_sport;
 };
 struct xfrm_address_filter {
-  xfrm_address_t saddr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  xfrm_address_t saddr;
   xfrm_address_t daddr;
   __u16 family;
   __u8 splen;
-  __u8 dplen;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 dplen;
 };
 #define XFRMGRP_ACQUIRE 1
 #define XFRMGRP_EXPIRE 2
-#define XFRMGRP_SA 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XFRMGRP_SA 4
 #define XFRMGRP_POLICY 8
 #define XFRMGRP_REPORT 0x20
 enum xfrm_nlgroups {
-  XFRMNLGRP_NONE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMNLGRP_NONE,
 #define XFRMNLGRP_NONE XFRMNLGRP_NONE
   XFRMNLGRP_ACQUIRE,
 #define XFRMNLGRP_ACQUIRE XFRMNLGRP_ACQUIRE
-  XFRMNLGRP_EXPIRE,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMNLGRP_EXPIRE,
 #define XFRMNLGRP_EXPIRE XFRMNLGRP_EXPIRE
   XFRMNLGRP_SA,
 #define XFRMNLGRP_SA XFRMNLGRP_SA
-  XFRMNLGRP_POLICY,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMNLGRP_POLICY,
 #define XFRMNLGRP_POLICY XFRMNLGRP_POLICY
   XFRMNLGRP_AEVENTS,
 #define XFRMNLGRP_AEVENTS XFRMNLGRP_AEVENTS
-  XFRMNLGRP_REPORT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMNLGRP_REPORT,
 #define XFRMNLGRP_REPORT XFRMNLGRP_REPORT
   XFRMNLGRP_MIGRATE,
 #define XFRMNLGRP_MIGRATE XFRMNLGRP_MIGRATE
-  XFRMNLGRP_MAPPING,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  XFRMNLGRP_MAPPING,
 #define XFRMNLGRP_MAPPING XFRMNLGRP_MAPPING
   __XFRMNLGRP_MAX
 };
-#define XFRMNLGRP_MAX (__XFRMNLGRP_MAX - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define XFRMNLGRP_MAX (__XFRMNLGRP_MAX - 1)
 #endif
diff --git a/libc/kernel/uapi/misc/cxl.h b/libc/kernel/uapi/misc/cxl.h
index e13a55b..08329da 100644
--- a/libc/kernel/uapi/misc/cxl.h
+++ b/libc/kernel/uapi/misc/cxl.h
@@ -59,60 +59,82 @@
   __u64 reserved5;
   __u64 reserved6;
 };
+#define CXL_AI_NEED_HEADER 0x0000000000000001ULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CXL_AI_ALL CXL_AI_NEED_HEADER
+#define CXL_AI_HEADER_SIZE 128
+#define CXL_AI_BUFFER_SIZE 4096
+#define CXL_AI_MAX_ENTRIES 256
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES)
+struct cxl_adapter_image {
+  __u64 flags;
+  __u64 data;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 len_data;
+  __u64 len_image;
+  __u64 reserved1;
+  __u64 reserved2;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 reserved3;
+  __u64 reserved4;
+};
 #define CXL_MAGIC 0xCA
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
 #define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32)
 #define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
-#define CXL_READ_MIN_SIZE 0x1000
+#define CXL_IOCTL_DOWNLOAD_IMAGE _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CXL_IOCTL_VALIDATE_IMAGE _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image)
+#define CXL_READ_MIN_SIZE 0x1000
 enum cxl_event_type {
   CXL_EVENT_RESERVED = 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CXL_EVENT_AFU_INTERRUPT = 1,
   CXL_EVENT_DATA_STORAGE = 2,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   CXL_EVENT_AFU_ERROR = 3,
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct cxl_event_header {
   __u16 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 size;
   __u16 process_element;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 reserved1;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct cxl_event_afu_interrupt {
   __u16 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 irq;
   __u32 reserved1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct cxl_event_data_storage {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 flags;
   __u16 reserved1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved2;
   __u64 addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 dsisr;
   __u64 reserved3;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct cxl_event_afu_error {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 flags;
   __u16 reserved1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 reserved2;
   __u64 error;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct cxl_event {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct cxl_event_header header;
   union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct cxl_event_afu_interrupt irq;
     struct cxl_event_data_storage fault;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct cxl_event_afu_error afu_error;
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/rdma/hfi/hfi1_user.h b/libc/kernel/uapi/rdma/hfi/hfi1_user.h
index a0079b5..63157ae 100644
--- a/libc/kernel/uapi/rdma/hfi/hfi1_user.h
+++ b/libc/kernel/uapi/rdma/hfi/hfi1_user.h
@@ -19,91 +19,101 @@
 #ifndef _LINUX__HFI1_USER_H
 #define _LINUX__HFI1_USER_H
 #include <linux/types.h>
-#define HFI1_USER_SWMAJOR 4
+#define HFI1_USER_SWMAJOR 6
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HFI1_USER_SWMINOR 0
+#define HFI1_USER_SWMINOR 1
+#define HFI1_SWMAJOR_SHIFT 16
 #define HFI1_CAP_DMA_RTAIL (1UL << 0)
 #define HFI1_CAP_SDMA (1UL << 1)
-#define HFI1_CAP_SDMA_AHG (1UL << 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_CAP_SDMA_AHG (1UL << 2)
 #define HFI1_CAP_EXTENDED_PSN (1UL << 3)
 #define HFI1_CAP_HDRSUPP (1UL << 4)
 #define HFI1_CAP_USE_SDMA_HEAD (1UL << 6)
-#define HFI1_CAP_MULTI_PKT_EGR (1UL << 7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_CAP_MULTI_PKT_EGR (1UL << 7)
 #define HFI1_CAP_NODROP_RHQ_FULL (1UL << 8)
 #define HFI1_CAP_NODROP_EGR_FULL (1UL << 9)
 #define HFI1_CAP_TID_UNMAP (1UL << 10)
-#define HFI1_CAP_PRINT_UNIMPL (1UL << 11)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_CAP_PRINT_UNIMPL (1UL << 11)
 #define HFI1_CAP_ALLOW_PERM_JKEY (1UL << 12)
 #define HFI1_CAP_NO_INTEGRITY (1UL << 13)
 #define HFI1_CAP_PKEY_CHECK (1UL << 14)
-#define HFI1_CAP_STATIC_RATE_CTRL (1UL << 15)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_CAP_STATIC_RATE_CTRL (1UL << 15)
 #define HFI1_CAP_SDMA_HEAD_CHECK (1UL << 17)
 #define HFI1_CAP_EARLY_CREDIT_RETURN (1UL << 18)
 #define HFI1_RCVHDR_ENTSIZE_2 (1UL << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_RCVHDR_ENTSIZE_16 (1UL << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_RCVDHR_ENTSIZE_32 (1UL << 2)
-#define HFI1_ALG_ACROSS 0
-#define HFI1_ALG_WITHIN 1
-#define HFI1_ALG_COUNT 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_CMD_ASSIGN_CTXT 1
 #define HFI1_CMD_CTXT_INFO 2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_CMD_USER_INFO 3
 #define HFI1_CMD_TID_UPDATE 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_CMD_TID_FREE 5
 #define HFI1_CMD_CREDIT_UPD 6
-#define HFI1_CMD_SDMA_STATUS_UPD 7
-#define HFI1_CMD_RECV_CTRL 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_CMD_RECV_CTRL 8
 #define HFI1_CMD_POLL_TYPE 9
 #define HFI1_CMD_ACK_EVENT 10
 #define HFI1_CMD_SET_PKEY 11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_CMD_CTXT_RESET 12
+#define HFI1_CMD_TID_INVAL_READ 13
+#define HFI1_CMD_GET_VERS 14
+#define IB_IOCTL_MAGIC 0x1b
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HFI1_CMD_EP_INFO 64
-#define HFI1_CMD_EP_ERASE_CHIP 65
-#define HFI1_CMD_EP_ERASE_P0 66
-#define HFI1_CMD_EP_ERASE_P1 67
+#define __NUM(cmd) (HFI1_CMD_ ##cmd + 0xe0)
+struct hfi1_cmd;
+#define HFI1_IOCTL_ASSIGN_CTXT _IOWR(IB_IOCTL_MAGIC, __NUM(ASSIGN_CTXT), struct hfi1_user_info)
+#define HFI1_IOCTL_CTXT_INFO _IOW(IB_IOCTL_MAGIC, __NUM(CTXT_INFO), struct hfi1_ctxt_info)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HFI1_CMD_EP_READ_P0 68
-#define HFI1_CMD_EP_READ_P1 69
-#define HFI1_CMD_EP_WRITE_P0 70
-#define HFI1_CMD_EP_WRITE_P1 71
+#define HFI1_IOCTL_USER_INFO _IOW(IB_IOCTL_MAGIC, __NUM(USER_INFO), struct hfi1_base_info)
+#define HFI1_IOCTL_TID_UPDATE _IOWR(IB_IOCTL_MAGIC, __NUM(TID_UPDATE), struct hfi1_tid_info)
+#define HFI1_IOCTL_TID_FREE _IOWR(IB_IOCTL_MAGIC, __NUM(TID_FREE), struct hfi1_tid_info)
+#define HFI1_IOCTL_CREDIT_UPD _IO(IB_IOCTL_MAGIC, __NUM(CREDIT_UPD))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_IOCTL_RECV_CTRL _IOW(IB_IOCTL_MAGIC, __NUM(RECV_CTRL), int)
+#define HFI1_IOCTL_POLL_TYPE _IOW(IB_IOCTL_MAGIC, __NUM(POLL_TYPE), int)
+#define HFI1_IOCTL_ACK_EVENT _IOW(IB_IOCTL_MAGIC, __NUM(ACK_EVENT), unsigned long)
+#define HFI1_IOCTL_SET_PKEY _IOW(IB_IOCTL_MAGIC, __NUM(SET_PKEY), __u16)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_IOCTL_CTXT_RESET _IO(IB_IOCTL_MAGIC, __NUM(CTXT_RESET))
+#define HFI1_IOCTL_TID_INVAL_READ _IOWR(IB_IOCTL_MAGIC, __NUM(TID_INVAL_READ), struct hfi1_tid_info)
+#define HFI1_IOCTL_GET_VERS _IOR(IB_IOCTL_MAGIC, __NUM(GET_VERS), int)
 #define _HFI1_EVENT_FROZEN_BIT 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _HFI1_EVENT_LINKDOWN_BIT 1
 #define _HFI1_EVENT_LID_CHANGE_BIT 2
 #define _HFI1_EVENT_LMC_CHANGE_BIT 3
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define _HFI1_EVENT_SL2VL_CHANGE_BIT 4
-#define _HFI1_MAX_EVENT_BIT _HFI1_EVENT_SL2VL_CHANGE_BIT
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define _HFI1_EVENT_TID_MMU_NOTIFY_BIT 5
+#define _HFI1_MAX_EVENT_BIT _HFI1_EVENT_TID_MMU_NOTIFY_BIT
 #define HFI1_EVENT_FROZEN (1UL << _HFI1_EVENT_FROZEN_BIT)
-#define HFI1_EVENT_LINKDOWN_BIT (1UL << _HFI1_EVENT_LINKDOWN_BIT)
+#define HFI1_EVENT_LINKDOWN (1UL << _HFI1_EVENT_LINKDOWN_BIT)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define HFI1_EVENT_LID_CHANGE_BIT (1UL << _HFI1_EVENT_LID_CHANGE_BIT)
-#define HFI1_EVENT_LMC_CHANGE_BIT (1UL << _HFI1_EVENT_LMC_CHANGE_BIT)
-#define HFI1_EVENT_SL2VL_CHANGE_BIT (1UL << _HFI1_EVENT_SL2VL_CHANGE_BIT)
+#define HFI1_EVENT_LID_CHANGE (1UL << _HFI1_EVENT_LID_CHANGE_BIT)
+#define HFI1_EVENT_LMC_CHANGE (1UL << _HFI1_EVENT_LMC_CHANGE_BIT)
+#define HFI1_EVENT_SL2VL_CHANGE (1UL << _HFI1_EVENT_SL2VL_CHANGE_BIT)
+#define HFI1_EVENT_TID_MMU_NOTIFY (1UL << _HFI1_EVENT_TID_MMU_NOTIFY_BIT)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_STATUS_INITTED 0x1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_STATUS_CHIP_PRESENT 0x20
 #define HFI1_STATUS_IB_READY 0x40
 #define HFI1_STATUS_IB_CONF 0x80
-#define HFI1_STATUS_HWERROR 0x200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define HFI1_STATUS_HWERROR 0x200
 #define HFI1_MAX_SHARED_CTXTS 8
 #define HFI1_POLL_TYPE_ANYRCV 0x0
 #define HFI1_POLL_TYPE_URGENT 0x1
-struct hfi1_user_info {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct hfi1_user_info {
   __u32 userversion;
-  __u16 pad;
-  __u16 hfi1_alg;
+  __u32 pad;
   __u16 subctxt_cnt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 subctxt_id;
@@ -137,103 +147,95 @@
   __u32 tidcnt;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 length;
-  __u64 tidmap;
 };
-struct hfi1_cmd {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-  __u32 type;
-  __u32 len;
-  __u64 addr;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum hfi1_sdma_comp_state {
   FREE = 0,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   QUEUED,
   COMPLETE,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ERROR
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct hfi1_sdma_comp_entry {
   __u32 status;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 errcode;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct hfi1_status {
   __u64 dev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 port;
   char freezemsg[0];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct hfi1_base_info {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 hw_version;
   __u32 sw_version;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 jkey;
   __u16 padding1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u32 bthqp;
   __u64 sc_credits_addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 pio_bufbase_sop;
   __u64 pio_bufbase;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 rcvhdr_bufbase;
   __u64 rcvegr_bufbase;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 sdma_comp_bufbase;
   __u64 user_regbase;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 events_bufbase;
   __u64 status_bufbase;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 rcvhdrtail_base;
   __u64 subctxt_uregbase;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 subctxt_rcvegrbuf;
   __u64 subctxt_rcvhdrbuf;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 enum sdma_req_opcode {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   EXPECTED = 0,
   EAGER
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define HFI1_SDMA_REQ_VERSION_MASK 0xF
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_SDMA_REQ_VERSION_SHIFT 0x0
 #define HFI1_SDMA_REQ_OPCODE_MASK 0xF
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_SDMA_REQ_OPCODE_SHIFT 0x4
 #define HFI1_SDMA_REQ_IOVCNT_MASK 0xFF
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define HFI1_SDMA_REQ_IOVCNT_SHIFT 0x8
 struct sdma_req_info {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 ctrl;
   __u16 npkts;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u16 fragsize;
   __u16 comp_idx;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __packed;
 struct hfi1_kdeth_header {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 ver_tid_offset;
   __le16 jkey;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 hcrc;
   __le32 swdata[7];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __packed;
 struct hfi1_pkt_header {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 pbc[4];
   __be16 lrh[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __be32 bth[3];
   struct hfi1_kdeth_header kdeth;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __packed;
 enum hfi1_ureg {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ur_rcvhdrtail = 0,
   ur_rcvhdrhead = 1,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ur_rcvegrindextail = 2,
   ur_rcvegrindexhead = 3,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ur_rcvegroffsettail = 4,
   ur_maxreg,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   ur_rcvtidflowtable = 256
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/uapi/rdma/ib_user_verbs.h b/libc/kernel/uapi/rdma/ib_user_verbs.h
index a3ed5db..4ae158c 100644
--- a/libc/kernel/uapi/rdma/ib_user_verbs.h
+++ b/libc/kernel/uapi/rdma/ib_user_verbs.h
@@ -207,779 +207,780 @@
   __u64 timestamp_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 hca_core_clock;
+  __u64 device_cap_flags_ex;
 };
 struct ib_uverbs_query_port {
-  __u64 response;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 response;
   __u8 port_num;
   __u8 reserved[7];
   __u64 driver_data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_query_port_resp {
   __u32 port_cap_flags;
   __u32 max_msg_sz;
-  __u32 bad_pkey_cntr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bad_pkey_cntr;
   __u32 qkey_viol_cntr;
   __u32 gid_tbl_len;
   __u16 pkey_tbl_len;
-  __u16 lid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 lid;
   __u16 sm_lid;
   __u8 state;
   __u8 max_mtu;
-  __u8 active_mtu;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 active_mtu;
   __u8 lmc;
   __u8 max_vl_num;
   __u8 sm_sl;
-  __u8 subnet_timeout;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 subnet_timeout;
   __u8 init_type_reply;
   __u8 active_width;
   __u8 active_speed;
-  __u8 phys_state;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 phys_state;
   __u8 link_layer;
   __u8 reserved[2];
 };
-struct ib_uverbs_alloc_pd {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_alloc_pd {
   __u64 response;
   __u64 driver_data[0];
 };
-struct ib_uverbs_alloc_pd_resp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_alloc_pd_resp {
   __u32 pd_handle;
 };
 struct ib_uverbs_dealloc_pd {
-  __u32 pd_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pd_handle;
 };
 struct ib_uverbs_open_xrcd {
   __u64 response;
-  __u32 fd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 fd;
   __u32 oflags;
   __u64 driver_data[0];
 };
-struct ib_uverbs_open_xrcd_resp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_open_xrcd_resp {
   __u32 xrcd_handle;
 };
 struct ib_uverbs_close_xrcd {
-  __u32 xrcd_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 xrcd_handle;
 };
 struct ib_uverbs_reg_mr {
   __u64 response;
-  __u64 start;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 start;
   __u64 length;
   __u64 hca_va;
   __u32 pd_handle;
-  __u32 access_flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 access_flags;
   __u64 driver_data[0];
 };
 struct ib_uverbs_reg_mr_resp {
-  __u32 mr_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 mr_handle;
   __u32 lkey;
   __u32 rkey;
 };
-struct ib_uverbs_rereg_mr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_rereg_mr {
   __u64 response;
   __u32 mr_handle;
   __u32 flags;
-  __u64 start;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 start;
   __u64 length;
   __u64 hca_va;
   __u32 pd_handle;
-  __u32 access_flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 access_flags;
 };
 struct ib_uverbs_rereg_mr_resp {
   __u32 lkey;
-  __u32 rkey;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rkey;
 };
 struct ib_uverbs_dereg_mr {
   __u32 mr_handle;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_alloc_mw {
   __u64 response;
   __u32 pd_handle;
-  __u8 mw_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 mw_type;
   __u8 reserved[3];
 };
 struct ib_uverbs_alloc_mw_resp {
-  __u32 mw_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 mw_handle;
   __u32 rkey;
 };
 struct ib_uverbs_dealloc_mw {
-  __u32 mw_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 mw_handle;
 };
 struct ib_uverbs_create_comp_channel {
   __u64 response;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_create_comp_channel_resp {
   __u32 fd;
 };
-struct ib_uverbs_create_cq {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_create_cq {
   __u64 response;
   __u64 user_handle;
   __u32 cqe;
-  __u32 comp_vector;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 comp_vector;
   __s32 comp_channel;
   __u32 reserved;
   __u64 driver_data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_ex_create_cq {
   __u64 user_handle;
   __u32 cqe;
-  __u32 comp_vector;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 comp_vector;
   __s32 comp_channel;
   __u32 comp_mask;
   __u32 flags;
-  __u32 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved;
 };
 struct ib_uverbs_create_cq_resp {
   __u32 cq_handle;
-  __u32 cqe;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 cqe;
 };
 struct ib_uverbs_ex_create_cq_resp {
   struct ib_uverbs_create_cq_resp base;
-  __u32 comp_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 comp_mask;
   __u32 response_length;
 };
 struct ib_uverbs_resize_cq {
-  __u64 response;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 response;
   __u32 cq_handle;
   __u32 cqe;
   __u64 driver_data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_resize_cq_resp {
   __u32 cqe;
   __u32 reserved;
-  __u64 driver_data[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 driver_data[0];
 };
 struct ib_uverbs_poll_cq {
   __u64 response;
-  __u32 cq_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 cq_handle;
   __u32 ne;
 };
 struct ib_uverbs_wc {
-  __u64 wr_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 wr_id;
   __u32 status;
   __u32 opcode;
   __u32 vendor_err;
-  __u32 byte_len;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 byte_len;
   union {
     __u32 imm_data;
     __u32 invalidate_rkey;
-  } ex;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  } ex;
   __u32 qp_num;
   __u32 src_qp;
   __u32 wc_flags;
-  __u16 pkey_index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 pkey_index;
   __u16 slid;
   __u8 sl;
   __u8 dlid_path_bits;
-  __u8 port_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 port_num;
   __u8 reserved;
 };
 struct ib_uverbs_poll_cq_resp {
-  __u32 count;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 count;
   __u32 reserved;
   struct ib_uverbs_wc wc[0];
 };
-struct ib_uverbs_req_notify_cq {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_req_notify_cq {
   __u32 cq_handle;
   __u32 solicited_only;
 };
-struct ib_uverbs_destroy_cq {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_destroy_cq {
   __u64 response;
   __u32 cq_handle;
   __u32 reserved;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_destroy_cq_resp {
   __u32 comp_events_reported;
   __u32 async_events_reported;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_global_route {
   __u8 dgid[16];
   __u32 flow_label;
-  __u8 sgid_index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 sgid_index;
   __u8 hop_limit;
   __u8 traffic_class;
   __u8 reserved;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_ah_attr {
   struct ib_uverbs_global_route grh;
   __u16 dlid;
-  __u8 sl;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 sl;
   __u8 src_path_bits;
   __u8 static_rate;
   __u8 is_global;
-  __u8 port_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 port_num;
   __u8 reserved;
 };
 struct ib_uverbs_qp_attr {
-  __u32 qp_attr_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qp_attr_mask;
   __u32 qp_state;
   __u32 cur_qp_state;
   __u32 path_mtu;
-  __u32 path_mig_state;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 path_mig_state;
   __u32 qkey;
   __u32 rq_psn;
   __u32 sq_psn;
-  __u32 dest_qp_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 dest_qp_num;
   __u32 qp_access_flags;
   struct ib_uverbs_ah_attr ah_attr;
   struct ib_uverbs_ah_attr alt_ah_attr;
-  __u32 max_send_wr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_send_wr;
   __u32 max_recv_wr;
   __u32 max_send_sge;
   __u32 max_recv_sge;
-  __u32 max_inline_data;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_inline_data;
   __u16 pkey_index;
   __u16 alt_pkey_index;
   __u8 en_sqd_async_notify;
-  __u8 sq_draining;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 sq_draining;
   __u8 max_rd_atomic;
   __u8 max_dest_rd_atomic;
   __u8 min_rnr_timer;
-  __u8 port_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 port_num;
   __u8 timeout;
   __u8 retry_cnt;
   __u8 rnr_retry;
-  __u8 alt_port_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 alt_port_num;
   __u8 alt_timeout;
   __u8 reserved[5];
 };
-struct ib_uverbs_create_qp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_create_qp {
   __u64 response;
   __u64 user_handle;
   __u32 pd_handle;
-  __u32 send_cq_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 send_cq_handle;
   __u32 recv_cq_handle;
   __u32 srq_handle;
   __u32 max_send_wr;
-  __u32 max_recv_wr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_recv_wr;
   __u32 max_send_sge;
   __u32 max_recv_sge;
   __u32 max_inline_data;
-  __u8 sq_sig_all;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 sq_sig_all;
   __u8 qp_type;
   __u8 is_srq;
   __u8 reserved;
-  __u64 driver_data[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 driver_data[0];
 };
 struct ib_uverbs_ex_create_qp {
   __u64 user_handle;
-  __u32 pd_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pd_handle;
   __u32 send_cq_handle;
   __u32 recv_cq_handle;
   __u32 srq_handle;
-  __u32 max_send_wr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_send_wr;
   __u32 max_recv_wr;
   __u32 max_send_sge;
   __u32 max_recv_sge;
-  __u32 max_inline_data;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_inline_data;
   __u8 sq_sig_all;
   __u8 qp_type;
   __u8 is_srq;
-  __u8 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 reserved;
   __u32 comp_mask;
   __u32 create_flags;
 };
-struct ib_uverbs_open_qp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_open_qp {
   __u64 response;
   __u64 user_handle;
   __u32 pd_handle;
-  __u32 qpn;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qpn;
   __u8 qp_type;
   __u8 reserved[7];
   __u64 driver_data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_create_qp_resp {
   __u32 qp_handle;
   __u32 qpn;
-  __u32 max_send_wr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_send_wr;
   __u32 max_recv_wr;
   __u32 max_send_sge;
   __u32 max_recv_sge;
-  __u32 max_inline_data;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_inline_data;
   __u32 reserved;
 };
 struct ib_uverbs_ex_create_qp_resp {
-  struct ib_uverbs_create_qp_resp base;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ib_uverbs_create_qp_resp base;
   __u32 comp_mask;
   __u32 response_length;
 };
-struct ib_uverbs_qp_dest {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_qp_dest {
   __u8 dgid[16];
   __u32 flow_label;
   __u16 dlid;
-  __u16 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 reserved;
   __u8 sgid_index;
   __u8 hop_limit;
   __u8 traffic_class;
-  __u8 sl;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 sl;
   __u8 src_path_bits;
   __u8 static_rate;
   __u8 is_global;
-  __u8 port_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 port_num;
 };
 struct ib_uverbs_query_qp {
   __u64 response;
-  __u32 qp_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qp_handle;
   __u32 attr_mask;
   __u64 driver_data[0];
 };
-struct ib_uverbs_query_qp_resp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_query_qp_resp {
   struct ib_uverbs_qp_dest dest;
   struct ib_uverbs_qp_dest alt_dest;
   __u32 max_send_wr;
-  __u32 max_recv_wr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_recv_wr;
   __u32 max_send_sge;
   __u32 max_recv_sge;
   __u32 max_inline_data;
-  __u32 qkey;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qkey;
   __u32 rq_psn;
   __u32 sq_psn;
   __u32 dest_qp_num;
-  __u32 qp_access_flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qp_access_flags;
   __u16 pkey_index;
   __u16 alt_pkey_index;
   __u8 qp_state;
-  __u8 cur_qp_state;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 cur_qp_state;
   __u8 path_mtu;
   __u8 path_mig_state;
   __u8 sq_draining;
-  __u8 max_rd_atomic;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 max_rd_atomic;
   __u8 max_dest_rd_atomic;
   __u8 min_rnr_timer;
   __u8 port_num;
-  __u8 timeout;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 timeout;
   __u8 retry_cnt;
   __u8 rnr_retry;
   __u8 alt_port_num;
-  __u8 alt_timeout;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 alt_timeout;
   __u8 sq_sig_all;
   __u8 reserved[5];
   __u64 driver_data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_modify_qp {
   struct ib_uverbs_qp_dest dest;
   struct ib_uverbs_qp_dest alt_dest;
-  __u32 qp_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qp_handle;
   __u32 attr_mask;
   __u32 qkey;
   __u32 rq_psn;
-  __u32 sq_psn;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 sq_psn;
   __u32 dest_qp_num;
   __u32 qp_access_flags;
   __u16 pkey_index;
-  __u16 alt_pkey_index;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 alt_pkey_index;
   __u8 qp_state;
   __u8 cur_qp_state;
   __u8 path_mtu;
-  __u8 path_mig_state;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 path_mig_state;
   __u8 en_sqd_async_notify;
   __u8 max_rd_atomic;
   __u8 max_dest_rd_atomic;
-  __u8 min_rnr_timer;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 min_rnr_timer;
   __u8 port_num;
   __u8 timeout;
   __u8 retry_cnt;
-  __u8 rnr_retry;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 rnr_retry;
   __u8 alt_port_num;
   __u8 alt_timeout;
   __u8 reserved[2];
-  __u64 driver_data[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 driver_data[0];
 };
 struct ib_uverbs_modify_qp_resp {
 };
-struct ib_uverbs_destroy_qp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_destroy_qp {
   __u64 response;
   __u32 qp_handle;
   __u32 reserved;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_destroy_qp_resp {
   __u32 events_reported;
 };
-struct ib_uverbs_sge {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_sge {
   __u64 addr;
   __u32 length;
   __u32 lkey;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_send_wr {
   __u64 wr_id;
   __u32 num_sge;
-  __u32 opcode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 opcode;
   __u32 send_flags;
   union {
     __u32 imm_data;
-    __u32 invalidate_rkey;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    __u32 invalidate_rkey;
   } ex;
   union {
     struct {
-      __u64 remote_addr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u64 remote_addr;
       __u32 rkey;
       __u32 reserved;
     } rdma;
-    struct {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct {
       __u64 remote_addr;
       __u64 compare_add;
       __u64 swap;
-      __u32 rkey;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 rkey;
       __u32 reserved;
     } atomic;
     struct {
-      __u32 ah;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 ah;
       __u32 remote_qpn;
       __u32 remote_qkey;
       __u32 reserved;
-    } ud;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    } ud;
   } wr;
 };
 struct ib_uverbs_post_send {
-  __u64 response;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 response;
   __u32 qp_handle;
   __u32 wr_count;
   __u32 sge_count;
-  __u32 wqe_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 wqe_size;
   struct ib_uverbs_send_wr send_wr[0];
 };
 struct ib_uverbs_post_send_resp {
-  __u32 bad_wr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bad_wr;
 };
 struct ib_uverbs_recv_wr {
   __u64 wr_id;
-  __u32 num_sge;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 num_sge;
   __u32 reserved;
 };
 struct ib_uverbs_post_recv {
-  __u64 response;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 response;
   __u32 qp_handle;
   __u32 wr_count;
   __u32 sge_count;
-  __u32 wqe_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 wqe_size;
   struct ib_uverbs_recv_wr recv_wr[0];
 };
 struct ib_uverbs_post_recv_resp {
-  __u32 bad_wr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bad_wr;
 };
 struct ib_uverbs_post_srq_recv {
   __u64 response;
-  __u32 srq_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 srq_handle;
   __u32 wr_count;
   __u32 sge_count;
   __u32 wqe_size;
-  struct ib_uverbs_recv_wr recv[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ib_uverbs_recv_wr recv[0];
 };
 struct ib_uverbs_post_srq_recv_resp {
   __u32 bad_wr;
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_create_ah {
   __u64 response;
   __u64 user_handle;
-  __u32 pd_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pd_handle;
   __u32 reserved;
   struct ib_uverbs_ah_attr attr;
 };
-struct ib_uverbs_create_ah_resp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_create_ah_resp {
   __u32 ah_handle;
 };
 struct ib_uverbs_destroy_ah {
-  __u32 ah_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ah_handle;
 };
 struct ib_uverbs_attach_mcast {
   __u8 gid[16];
-  __u32 qp_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qp_handle;
   __u16 mlid;
   __u16 reserved;
   __u64 driver_data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_detach_mcast {
   __u8 gid[16];
   __u32 qp_handle;
-  __u16 mlid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u16 mlid;
   __u16 reserved;
   __u64 driver_data[0];
 };
-struct ib_uverbs_flow_spec_hdr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_flow_spec_hdr {
   __u32 type;
   __u16 size;
   __u16 reserved;
-  __u64 flow_spec_data[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 flow_spec_data[0];
 };
 struct ib_uverbs_flow_eth_filter {
   __u8 dst_mac[6];
-  __u8 src_mac[6];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 src_mac[6];
   __be16 ether_type;
   __be16 vlan_tag;
 };
-struct ib_uverbs_flow_spec_eth {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_flow_spec_eth {
   union {
     struct ib_uverbs_flow_spec_hdr hdr;
     struct {
-      __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 type;
       __u16 size;
       __u16 reserved;
     };
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
   struct ib_uverbs_flow_eth_filter val;
   struct ib_uverbs_flow_eth_filter mask;
 };
-struct ib_uverbs_flow_ipv4_filter {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_flow_ipv4_filter {
   __be32 src_ip;
   __be32 dst_ip;
 };
-struct ib_uverbs_flow_spec_ipv4 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_flow_spec_ipv4 {
   union {
     struct ib_uverbs_flow_spec_hdr hdr;
     struct {
-      __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 type;
       __u16 size;
       __u16 reserved;
     };
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
   struct ib_uverbs_flow_ipv4_filter val;
   struct ib_uverbs_flow_ipv4_filter mask;
 };
-struct ib_uverbs_flow_tcp_udp_filter {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_flow_tcp_udp_filter {
   __be16 dst_port;
   __be16 src_port;
 };
-struct ib_uverbs_flow_spec_tcp_udp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_flow_spec_tcp_udp {
   union {
     struct ib_uverbs_flow_spec_hdr hdr;
     struct {
-      __u32 type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+      __u32 type;
       __u16 size;
       __u16 reserved;
     };
-  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  };
   struct ib_uverbs_flow_tcp_udp_filter val;
   struct ib_uverbs_flow_tcp_udp_filter mask;
 };
-struct ib_uverbs_flow_attr {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_flow_attr {
   __u32 type;
   __u16 size;
   __u16 priority;
-  __u8 num_of_specs;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 num_of_specs;
   __u8 reserved[2];
   __u8 port;
   __u32 flags;
-  struct ib_uverbs_flow_spec_hdr flow_specs[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct ib_uverbs_flow_spec_hdr flow_specs[0];
 };
 struct ib_uverbs_create_flow {
   __u32 comp_mask;
-  __u32 qp_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 qp_handle;
   struct ib_uverbs_flow_attr flow_attr;
 };
 struct ib_uverbs_create_flow_resp {
-  __u32 comp_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 comp_mask;
   __u32 flow_handle;
 };
 struct ib_uverbs_destroy_flow {
-  __u32 comp_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 comp_mask;
   __u32 flow_handle;
 };
 struct ib_uverbs_create_srq {
-  __u64 response;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 response;
   __u64 user_handle;
   __u32 pd_handle;
   __u32 max_wr;
-  __u32 max_sge;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_sge;
   __u32 srq_limit;
   __u64 driver_data[0];
 };
-struct ib_uverbs_create_xsrq {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_create_xsrq {
   __u64 response;
   __u64 user_handle;
   __u32 srq_type;
-  __u32 pd_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 pd_handle;
   __u32 max_wr;
   __u32 max_sge;
   __u32 srq_limit;
-  __u32 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved;
   __u32 xrcd_handle;
   __u32 cq_handle;
   __u64 driver_data[0];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 struct ib_uverbs_create_srq_resp {
   __u32 srq_handle;
   __u32 max_wr;
-  __u32 max_sge;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 max_sge;
   __u32 srqn;
 };
 struct ib_uverbs_modify_srq {
-  __u32 srq_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 srq_handle;
   __u32 attr_mask;
   __u32 max_wr;
   __u32 srq_limit;
-  __u64 driver_data[0];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 driver_data[0];
 };
 struct ib_uverbs_query_srq {
   __u64 response;
-  __u32 srq_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 srq_handle;
   __u32 reserved;
   __u64 driver_data[0];
 };
-struct ib_uverbs_query_srq_resp {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct ib_uverbs_query_srq_resp {
   __u32 max_wr;
   __u32 max_sge;
   __u32 srq_limit;
-  __u32 reserved;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved;
 };
 struct ib_uverbs_destroy_srq {
   __u64 response;
-  __u32 srq_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 srq_handle;
   __u32 reserved;
 };
 struct ib_uverbs_destroy_srq_resp {
-  __u32 events_reported;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 events_reported;
 };
 #endif
diff --git a/libc/kernel/uapi/rdma/rdma_netlink.h b/libc/kernel/uapi/rdma/rdma_netlink.h
index b35703a..b6f0831 100644
--- a/libc/kernel/uapi/rdma/rdma_netlink.h
+++ b/libc/kernel/uapi/rdma/rdma_netlink.h
@@ -22,182 +22,190 @@
 enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   RDMA_NL_RDMA_CM = 1,
-  RDMA_NL_NES,
-  RDMA_NL_C4IW,
+  RDMA_NL_IWCM,
+  RDMA_NL_RSVD,
   RDMA_NL_LS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RDMA_NL_I40IW,
   RDMA_NL_NUM_CLIENTS
 };
 enum {
-  RDMA_NL_GROUP_CM = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RDMA_NL_GROUP_CM = 1,
   RDMA_NL_GROUP_IWPM,
   RDMA_NL_GROUP_LS,
   RDMA_NL_NUM_GROUPS
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10)
 #define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1))
 #define RDMA_NL_GET_TYPE(client,op) ((client << 10) + op)
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   RDMA_NL_RDMA_CM_ID_STATS = 0,
   RDMA_NL_RDMA_CM_NUM_OPS
 };
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   RDMA_NL_RDMA_CM_ATTR_SRC_ADDR = 1,
   RDMA_NL_RDMA_CM_ATTR_DST_ADDR,
   RDMA_NL_RDMA_CM_NUM_ATTR,
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum {
   RDMA_NL_IWPM_REG_PID = 0,
   RDMA_NL_IWPM_ADD_MAPPING,
-  RDMA_NL_IWPM_QUERY_MAPPING,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RDMA_NL_IWPM_QUERY_MAPPING,
   RDMA_NL_IWPM_REMOVE_MAPPING,
   RDMA_NL_IWPM_REMOTE_INFO,
   RDMA_NL_IWPM_HANDLE_ERR,
-  RDMA_NL_IWPM_MAPINFO,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RDMA_NL_IWPM_MAPINFO,
   RDMA_NL_IWPM_MAPINFO_NUM,
   RDMA_NL_IWPM_NUM_OPS
 };
-struct rdma_cm_id_stats {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct rdma_cm_id_stats {
   __u32 qp_num;
   __u32 bound_dev_if;
   __u32 port_space;
-  __s32 pid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 pid;
   __u8 cm_state;
   __u8 node_type;
   __u8 port_num;
-  __u8 qp_type;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 qp_type;
 };
 enum {
   IWPM_NLA_REG_PID_UNSPEC = 0,
-  IWPM_NLA_REG_PID_SEQ,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_REG_PID_SEQ,
   IWPM_NLA_REG_IF_NAME,
   IWPM_NLA_REG_IBDEV_NAME,
   IWPM_NLA_REG_ULIB_NAME,
-  IWPM_NLA_REG_PID_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_REG_PID_MAX
 };
 enum {
   IWPM_NLA_RREG_PID_UNSPEC = 0,
-  IWPM_NLA_RREG_PID_SEQ,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_RREG_PID_SEQ,
   IWPM_NLA_RREG_IBDEV_NAME,
   IWPM_NLA_RREG_ULIB_NAME,
   IWPM_NLA_RREG_ULIB_VER,
-  IWPM_NLA_RREG_PID_ERR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_RREG_PID_ERR,
   IWPM_NLA_RREG_PID_MAX
 };
 enum {
-  IWPM_NLA_MANAGE_MAPPING_UNSPEC = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_MANAGE_MAPPING_UNSPEC = 0,
   IWPM_NLA_MANAGE_MAPPING_SEQ,
   IWPM_NLA_MANAGE_ADDR,
   IWPM_NLA_MANAGE_MAPPED_LOC_ADDR,
-  IWPM_NLA_RMANAGE_MAPPING_ERR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_RMANAGE_MAPPING_ERR,
   IWPM_NLA_RMANAGE_MAPPING_MAX
 };
 #define IWPM_NLA_MANAGE_MAPPING_MAX 3
-#define IWPM_NLA_QUERY_MAPPING_MAX 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define IWPM_NLA_QUERY_MAPPING_MAX 4
 #define IWPM_NLA_MAPINFO_SEND_MAX 3
 enum {
   IWPM_NLA_QUERY_MAPPING_UNSPEC = 0,
-  IWPM_NLA_QUERY_MAPPING_SEQ,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_QUERY_MAPPING_SEQ,
   IWPM_NLA_QUERY_LOCAL_ADDR,
   IWPM_NLA_QUERY_REMOTE_ADDR,
   IWPM_NLA_RQUERY_MAPPED_LOC_ADDR,
-  IWPM_NLA_RQUERY_MAPPED_REM_ADDR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_RQUERY_MAPPED_REM_ADDR,
   IWPM_NLA_RQUERY_MAPPING_ERR,
   IWPM_NLA_RQUERY_MAPPING_MAX
 };
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   IWPM_NLA_MAPINFO_REQ_UNSPEC = 0,
   IWPM_NLA_MAPINFO_ULIB_NAME,
   IWPM_NLA_MAPINFO_ULIB_VER,
-  IWPM_NLA_MAPINFO_REQ_MAX
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_MAPINFO_REQ_MAX
 };
 enum {
   IWPM_NLA_MAPINFO_UNSPEC = 0,
-  IWPM_NLA_MAPINFO_LOCAL_ADDR,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_MAPINFO_LOCAL_ADDR,
   IWPM_NLA_MAPINFO_MAPPED_ADDR,
   IWPM_NLA_MAPINFO_MAX
 };
-enum {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+enum {
   IWPM_NLA_MAPINFO_NUM_UNSPEC = 0,
   IWPM_NLA_MAPINFO_SEQ,
   IWPM_NLA_MAPINFO_SEND_NUM,
-  IWPM_NLA_MAPINFO_ACK_NUM,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_MAPINFO_ACK_NUM,
   IWPM_NLA_MAPINFO_NUM_MAX
 };
 enum {
-  IWPM_NLA_ERR_UNSPEC = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  IWPM_NLA_ERR_UNSPEC = 0,
   IWPM_NLA_ERR_SEQ,
   IWPM_NLA_ERR_CODE,
   IWPM_NLA_ERR_MAX
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 enum {
   RDMA_NL_LS_OP_RESOLVE = 0,
   RDMA_NL_LS_OP_SET_TIMEOUT,
-  RDMA_NL_LS_NUM_OPS
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  RDMA_NL_LS_OP_IP_RESOLVE,
+  RDMA_NL_LS_NUM_OPS
 };
 #define RDMA_NL_LS_F_ERR 0x0100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum {
   LS_RESOLVE_PATH_USE_ALL = 0,
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   LS_RESOLVE_PATH_USE_UNIDIRECTIONAL,
   LS_RESOLVE_PATH_USE_GMP,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   LS_RESOLVE_PATH_USE_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define LS_DEVICE_NAME_MAX 64
 struct rdma_ls_resolve_header {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 device_name[LS_DEVICE_NAME_MAX];
   __u8 port_num;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 path_use;
 };
-#define RDMA_NLA_F_MANDATORY (1 << 13)
-#define RDMA_NLA_TYPE_MASK (~(NLA_F_NESTED | NLA_F_NET_BYTEORDER | RDMA_NLA_F_MANDATORY))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct rdma_ls_ip_resolve_header {
+  __u32 ifindex;
+};
+#define RDMA_NLA_F_MANDATORY (1 << 13)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define RDMA_NLA_TYPE_MASK (~(NLA_F_NESTED | NLA_F_NET_BYTEORDER | RDMA_NLA_F_MANDATORY))
 enum {
   LS_NLA_TYPE_UNSPEC = 0,
   LS_NLA_TYPE_PATH_RECORD,
-  LS_NLA_TYPE_TIMEOUT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  LS_NLA_TYPE_TIMEOUT,
   LS_NLA_TYPE_SERVICE_ID,
   LS_NLA_TYPE_DGID,
   LS_NLA_TYPE_SGID,
-  LS_NLA_TYPE_TCLASS,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  LS_NLA_TYPE_TCLASS,
   LS_NLA_TYPE_PKEY,
   LS_NLA_TYPE_QOS_CLASS,
+  LS_NLA_TYPE_IPV4,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  LS_NLA_TYPE_IPV6,
   LS_NLA_TYPE_MAX
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct rdma_nla_ls_gid {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u8 gid[16];
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/scsi/cxlflash_ioctl.h b/libc/kernel/uapi/scsi/cxlflash_ioctl.h
index fe7c822..cc14710 100644
--- a/libc/kernel/uapi/scsi/cxlflash_ioctl.h
+++ b/libc/kernel/uapi/scsi/cxlflash_ioctl.h
@@ -28,141 +28,142 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __u64 return_flags;
 };
+#define DK_CXLFLASH_ALL_PORTS_ACTIVE 0x0000000000000001ULL
 #define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
-struct dk_cxlflash_attach {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct dk_cxlflash_attach {
   struct dk_cxlflash_hdr hdr;
   __u64 num_interrupts;
   __u64 context_id;
-  __u64 mmio_size;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 mmio_size;
   __u64 block_size;
   __u64 adap_fd;
   __u64 last_lba;
-  __u64 max_xfer;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 max_xfer;
   __u64 reserved[8];
 };
 struct dk_cxlflash_detach {
-  struct dk_cxlflash_hdr hdr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct dk_cxlflash_hdr hdr;
   __u64 context_id;
   __u64 reserved[8];
 };
-struct dk_cxlflash_udirect {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct dk_cxlflash_udirect {
   struct dk_cxlflash_hdr hdr;
   __u64 context_id;
   __u64 rsrc_handle;
-  __u64 last_lba;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 last_lba;
   __u64 reserved[8];
 };
 #define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME 0x8000000000000000ULL
-struct dk_cxlflash_uvirtual {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct dk_cxlflash_uvirtual {
   struct dk_cxlflash_hdr hdr;
   __u64 context_id;
   __u64 lun_size;
-  __u64 rsrc_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 rsrc_handle;
   __u64 last_lba;
   __u64 reserved[8];
 };
-struct dk_cxlflash_release {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct dk_cxlflash_release {
   struct dk_cxlflash_hdr hdr;
   __u64 context_id;
   __u64 rsrc_handle;
-  __u64 reserved[8];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 reserved[8];
 };
 struct dk_cxlflash_resize {
   struct dk_cxlflash_hdr hdr;
-  __u64 context_id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 context_id;
   __u64 rsrc_handle;
   __u64 req_size;
   __u64 last_lba;
-  __u64 reserved[8];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 reserved[8];
 };
 struct dk_cxlflash_clone {
   struct dk_cxlflash_hdr hdr;
-  __u64 context_id_src;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 context_id_src;
   __u64 context_id_dst;
   __u64 adap_fd_src;
   __u64 reserved[8];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define DK_CXLFLASH_VERIFY_SENSE_LEN 18
 #define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
 struct dk_cxlflash_verify {
-  struct dk_cxlflash_hdr hdr;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct dk_cxlflash_hdr hdr;
   __u64 context_id;
   __u64 rsrc_handle;
   __u64 hint;
-  __u64 last_lba;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 last_lba;
   __u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN];
   __u8 pad[6];
   __u64 reserved[8];
-};
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+};
 #define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
 struct dk_cxlflash_recover_afu {
   struct dk_cxlflash_hdr hdr;
-  __u64 reason;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 reason;
   __u64 context_id;
   __u64 mmio_size;
   __u64 adap_fd;
-  __u64 reserved[8];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u64 reserved[8];
 };
 #define DK_CXLFLASH_MANAGE_LUN_WWID_LEN 16
 #define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
-#define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
 #define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
 struct dk_cxlflash_manage_lun {
   struct dk_cxlflash_hdr hdr;
-  __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN];
   __u64 reserved[8];
 };
 union cxlflash_ioctls {
-  struct dk_cxlflash_attach attach;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct dk_cxlflash_attach attach;
   struct dk_cxlflash_detach detach;
   struct dk_cxlflash_udirect udirect;
   struct dk_cxlflash_uvirtual uvirtual;
-  struct dk_cxlflash_release release;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct dk_cxlflash_release release;
   struct dk_cxlflash_resize resize;
   struct dk_cxlflash_clone clone;
   struct dk_cxlflash_verify verify;
-  struct dk_cxlflash_recover_afu recover_afu;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct dk_cxlflash_recover_afu recover_afu;
   struct dk_cxlflash_manage_lun manage_lun;
 };
 #define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
-#define CXL_MAGIC 0xCA
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define CXL_MAGIC 0xCA
 #define CXL_IOWR(_n,_s) _IOWR(CXL_MAGIC, _n, struct _s)
 #define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
 #define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
-#define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
 #define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
 #define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
 #define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
-#define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
 #define DK_CXLFLASH_USER_VIRTUAL CXL_IOWR(0x87, dk_cxlflash_uvirtual)
 #define DK_CXLFLASH_VLUN_RESIZE CXL_IOWR(0x88, dk_cxlflash_resize)
 #define DK_CXLFLASH_VLUN_CLONE CXL_IOWR(0x89, dk_cxlflash_clone)
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/uapi/sound/asequencer.h b/libc/kernel/uapi/sound/asequencer.h
index 3596012..556da58 100644
--- a/libc/kernel/uapi/sound/asequencer.h
+++ b/libc/kernel/uapi/sound/asequencer.h
@@ -19,7 +19,7 @@
 #ifndef _UAPI__SOUND_ASEQUENCER_H
 #define _UAPI__SOUND_ASEQUENCER_H
 #include <sound/asound.h>
-#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1)
+#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 2)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_EVENT_SYSTEM 0
 #define SNDRV_SEQ_EVENT_RESULT 1
@@ -277,213 +277,213 @@
   int num_ports;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int event_lost;
-  char reserved[64];
+  int card;
+  int pid;
+  char reserved[56];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct snd_seq_client_pool {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int client;
   int output_pool;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int input_pool;
   int output_room;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int output_free;
   int input_free;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char reserved[64];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_REMOVE_INPUT (1 << 0)
 #define SNDRV_SEQ_REMOVE_OUTPUT (1 << 1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_REMOVE_DEST (1 << 2)
 #define SNDRV_SEQ_REMOVE_DEST_CHANNEL (1 << 3)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_REMOVE_TIME_BEFORE (1 << 4)
 #define SNDRV_SEQ_REMOVE_TIME_AFTER (1 << 5)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_REMOVE_TIME_TICK (1 << 6)
 #define SNDRV_SEQ_REMOVE_EVENT_TYPE (1 << 7)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_REMOVE_IGNORE_OFF (1 << 8)
 #define SNDRV_SEQ_REMOVE_TAG_MATCH (1 << 9)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_seq_remove_events {
   unsigned int remove_mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union snd_seq_timestamp time;
   unsigned char queue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_seq_addr dest;
   unsigned char channel;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int type;
   char tag;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int reserved[10];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_SYSTEM_TIMER 0
 #define SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_CAP_READ (1 << 0)
 #define SNDRV_SEQ_PORT_CAP_WRITE (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_CAP_SYNC_READ (1 << 2)
 #define SNDRV_SEQ_PORT_CAP_SYNC_WRITE (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_CAP_DUPLEX (1 << 4)
 #define SNDRV_SEQ_PORT_CAP_SUBS_READ (1 << 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_CAP_SUBS_WRITE (1 << 6)
 #define SNDRV_SEQ_PORT_CAP_NO_EXPORT (1 << 7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_SPECIFIC (1 << 0)
 #define SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC (1 << 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_MIDI_GM (1 << 2)
 #define SNDRV_SEQ_PORT_TYPE_MIDI_GS (1 << 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_MIDI_XG (1 << 4)
 #define SNDRV_SEQ_PORT_TYPE_MIDI_MT32 (1 << 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_MIDI_GM2 (1 << 6)
 #define SNDRV_SEQ_PORT_TYPE_SYNTH (1 << 10)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE (1 << 11)
 #define SNDRV_SEQ_PORT_TYPE_SAMPLE (1 << 12)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_HARDWARE (1 << 16)
 #define SNDRV_SEQ_PORT_TYPE_SOFTWARE (1 << 17)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_SYNTHESIZER (1 << 18)
 #define SNDRV_SEQ_PORT_TYPE_PORT (1 << 19)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_TYPE_APPLICATION (1 << 20)
 #define SNDRV_SEQ_PORT_FLG_GIVEN_PORT (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_FLG_TIMESTAMP (1 << 1)
 #define SNDRV_SEQ_PORT_FLG_TIME_REAL (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_seq_port_info {
   struct snd_seq_addr addr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char name[64];
   unsigned int capability;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int type;
   int midi_channels;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int midi_voices;
   int synth_voices;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int read_use;
   int write_use;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   void * kernel;
   unsigned int flags;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char time_queue;
   char reserved[59];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SNDRV_SEQ_QUEUE_FLG_SYNC (1 << 0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_seq_queue_info {
   int queue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int owner;
   unsigned locked : 1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char name[64];
   unsigned int flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char reserved[60];
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_seq_queue_status {
   int queue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int events;
   snd_seq_tick_time_t tick;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_seq_real_time time;
   int running;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int flags;
   char reserved[64];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct snd_seq_queue_tempo {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int queue;
   unsigned int tempo;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int ppq;
   unsigned int skew_value;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int skew_base;
   char reserved[24];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SNDRV_SEQ_TIMER_ALSA 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_TIMER_MIDI_CLOCK 1
 #define SNDRV_SEQ_TIMER_MIDI_TICK 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_seq_queue_timer {
   int queue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int type;
   union {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
     struct {
       struct snd_timer_id id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
       unsigned int resolution;
     } alsa;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   } u;
   char reserved[64];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct snd_seq_queue_client {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int queue;
   int client;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int used;
   char reserved[64];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SNDRV_SEQ_PORT_SUBS_EXCLUSIVE (1 << 0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_PORT_SUBS_TIMESTAMP (1 << 1)
 #define SNDRV_SEQ_PORT_SUBS_TIME_REAL (1 << 2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_seq_port_subscribe {
   struct snd_seq_addr sender;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_seq_addr dest;
   unsigned int voices;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int flags;
   unsigned char queue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned char pad[3];
   char reserved[64];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SNDRV_SEQ_QUERY_SUBS_READ 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_QUERY_SUBS_WRITE 1
 struct snd_seq_query_subs {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_seq_addr root;
   int type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   int index;
   int num_subs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_seq_addr addr;
   unsigned char queue;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   unsigned int flags;
   char reserved[64];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define SNDRV_SEQ_IOCTL_PVERSION _IOR('S', 0x00, int)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_CLIENT_ID _IOR('S', 0x01, int)
 #define SNDRV_SEQ_IOCTL_SYSTEM_INFO _IOWR('S', 0x02, struct snd_seq_system_info)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_RUNNING_MODE _IOWR('S', 0x03, struct snd_seq_running_info)
 #define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO _IOWR('S', 0x10, struct snd_seq_client_info)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO _IOW('S', 0x11, struct snd_seq_client_info)
 #define SNDRV_SEQ_IOCTL_CREATE_PORT _IOWR('S', 0x20, struct snd_seq_port_info)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_DELETE_PORT _IOW('S', 0x21, struct snd_seq_port_info)
 #define SNDRV_SEQ_IOCTL_GET_PORT_INFO _IOWR('S', 0x22, struct snd_seq_port_info)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_SET_PORT_INFO _IOW('S', 0x23, struct snd_seq_port_info)
 #define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT _IOW('S', 0x30, struct snd_seq_port_subscribe)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW('S', 0x31, struct snd_seq_port_subscribe)
 #define SNDRV_SEQ_IOCTL_CREATE_QUEUE _IOWR('S', 0x32, struct snd_seq_queue_info)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_DELETE_QUEUE _IOW('S', 0x33, struct snd_seq_queue_info)
 #define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO _IOWR('S', 0x34, struct snd_seq_queue_info)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO _IOWR('S', 0x35, struct snd_seq_queue_info)
 #define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE _IOWR('S', 0x36, struct snd_seq_queue_info)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct snd_seq_queue_status)
 #define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO _IOWR('S', 0x41, struct snd_seq_queue_tempo)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO _IOW('S', 0x42, struct snd_seq_queue_tempo)
-#define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER _IOWR('S', 0x43, struct snd_seq_queue_owner)
-#define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER _IOW('S', 0x44, struct snd_seq_queue_owner)
 #define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER _IOWR('S', 0x45, struct snd_seq_queue_timer)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER _IOW('S', 0x46, struct snd_seq_queue_timer)
diff --git a/libc/kernel/uapi/sound/asoc.h b/libc/kernel/uapi/sound/asoc.h
index a4fac22..4905200 100644
--- a/libc/kernel/uapi/sound/asoc.h
+++ b/libc/kernel/uapi/sound/asoc.h
@@ -93,197 +93,236 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SND_SOC_TPLG_STREAM_PLAYBACK 0
 #define SND_SOC_TPLG_STREAM_CAPTURE 1
+#define SND_SOC_TPLG_TUPLE_TYPE_UUID 0
+#define SND_SOC_TPLG_TUPLE_TYPE_STRING 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2
+#define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3
+#define SND_SOC_TPLG_TUPLE_TYPE_WORD 4
+#define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_hdr {
   __le32 magic;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 abi;
   __le32 version;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 type;
   __le32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 vendor_type;
   __le32 payload_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 index;
   __le32 count;
+} __attribute__((packed));
+struct snd_soc_tplg_vendor_uuid_elem {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 token;
+  char uuid[16];
+} __attribute__((packed));
+struct snd_soc_tplg_vendor_value_elem {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 token;
+  __le32 value;
+} __attribute__((packed));
+struct snd_soc_tplg_vendor_string_elem {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 token;
+  char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
+} __attribute__((packed));
+struct snd_soc_tplg_vendor_array {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 size;
+  __le32 type;
+  __le32 num_elems;
+  union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct snd_soc_tplg_vendor_uuid_elem uuid[0];
+    struct snd_soc_tplg_vendor_value_elem value[0];
+    struct snd_soc_tplg_vendor_string_elem string[0];
+  };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct snd_soc_tplg_private {
   __le32 size;
-  char data[0];
+  union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    char data[0];
+    struct snd_soc_tplg_vendor_array array[0];
+  };
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_tlv_dbscale {
   __le32 min;
   __le32 step;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 mute;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct snd_soc_tplg_ctl_tlv {
   __le32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   union {
     __le32 data[SND_SOC_TPLG_TLV_SIZE];
     struct snd_soc_tplg_tlv_dbscale scale;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct snd_soc_tplg_channel {
   __le32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 reg;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 shift;
   __le32 id;
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_io_ops {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 get;
   __le32 put;
   __le32 info;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_ctl_hdr {
   __le32 size;
   __le32 type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 access;
   struct snd_soc_tplg_io_ops ops;
   struct snd_soc_tplg_ctl_tlv tlv;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_stream_caps {
   __le32 size;
   char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le64 formats;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 rates;
   __le32 rate_min;
   __le32 rate_max;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 channels_min;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 channels_max;
   __le32 periods_min;
   __le32 periods_max;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 period_size_min;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 period_size_max;
   __le32 buffer_size_min;
   __le32 buffer_size_max;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_stream {
   __le32 size;
   char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le64 format;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 rate;
   __le32 period_bytes;
   __le32 buffer_bytes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 channels;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct snd_soc_tplg_manifest {
   __le32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 control_elems;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 widget_elems;
   __le32 graph_elems;
-  __le32 dai_elems;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __le32 pcm_elems;
   __le32 dai_link_elems;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_soc_tplg_private priv;
 } __attribute__((packed));
 struct snd_soc_tplg_mixer_control {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_soc_tplg_ctl_hdr hdr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 size;
   __le32 min;
   __le32 max;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 platform_max;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 invert;
   __le32 num_channels;
   struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_soc_tplg_private priv;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct snd_soc_tplg_enum_control {
   struct snd_soc_tplg_ctl_hdr hdr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 num_channels;
   struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
   __le32 items;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 count;
   char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
   __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_soc_tplg_private priv;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct snd_soc_tplg_bytes_control {
   struct snd_soc_tplg_ctl_hdr hdr;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 max;
   __le32 mask;
   __le32 base;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 num_regs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_soc_tplg_io_ops ext_ops;
   struct snd_soc_tplg_private priv;
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_dapm_graph_elem {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
   char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
   char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_dapm_widget {
   __le32 size;
   __le32 id;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
   __le32 reg;
   __le32 shift;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 subseq;
   __le32 invert;
   __le32 ignore_suspend;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 event_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le16 event_type;
   __le32 num_kcontrols;
   struct snd_soc_tplg_private priv;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct snd_soc_tplg_pcm {
   __le32 size;
   char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 pcm_id;
   __le32 dai_id;
   __le32 playback;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 capture;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 compress;
   struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
   __le32 num_streams;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_soc_tplg_stream_caps caps[2];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 struct snd_soc_tplg_link_config {
   __le32 size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   __le32 id;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
   struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
   __le32 num_streams;
 } __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/uapi/sound/asound.h b/libc/kernel/uapi/sound/asound.h
index 0dfff8b..7e5dd3f 100644
--- a/libc/kernel/uapi/sound/asound.h
+++ b/libc/kernel/uapi/sound/asound.h
@@ -18,7 +18,12 @@
  ****************************************************************************/
 #ifndef _UAPI__SOUND_ASOUND_H
 #define _UAPI__SOUND_ASOUND_H
+#ifdef __linux__
 #include <linux/types.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#else
+#include <sys/ioctl.h>
+#endif
 #include <stdlib.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SNDRV_PROTOCOL_VERSION(major,minor,subminor) (((major) << 16) | ((minor) << 8) | (subminor))
diff --git a/libc/kernel/uapi/sound/compress_params.h b/libc/kernel/uapi/sound/compress_params.h
index b1703dc..f3d8a85 100644
--- a/libc/kernel/uapi/sound/compress_params.h
+++ b/libc/kernel/uapi/sound/compress_params.h
@@ -41,205 +41,206 @@
 #define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
 #define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_G729
+#define SND_AUDIOCODEC_BESPOKE ((__u32) 0x0000000E)
+#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_BESPOKE
 #define SND_AUDIOPROFILE_PCM ((__u32) 0x00000001)
 #define SND_AUDIOCHANMODE_MP3_MONO ((__u32) 0x00000001)
-#define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
 #define SND_AUDIOCHANMODE_MP3_JOINTSTEREO ((__u32) 0x00000004)
 #define SND_AUDIOCHANMODE_MP3_DUAL ((__u32) 0x00000008)
 #define SND_AUDIOPROFILE_AMR ((__u32) 0x00000001)
-#define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
 #define SND_AUDIOMODE_AMR_VAD1 ((__u32) 0x00000002)
 #define SND_AUDIOMODE_AMR_VAD2 ((__u32) 0x00000004)
 #define SND_AUDIOSTREAMFORMAT_UNDEFINED ((__u32) 0x00000000)
-#define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
 #define SND_AUDIOSTREAMFORMAT_IF1 ((__u32) 0x00000002)
 #define SND_AUDIOSTREAMFORMAT_IF2 ((__u32) 0x00000004)
 #define SND_AUDIOSTREAMFORMAT_FSF ((__u32) 0x00000008)
-#define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
 #define SND_AUDIOSTREAMFORMAT_ITU ((__u32) 0x00000020)
 #define SND_AUDIOPROFILE_AMRWB ((__u32) 0x00000001)
 #define SND_AUDIOMODE_AMRWB_DTX_OFF ((__u32) 0x00000001)
-#define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
 #define SND_AUDIOMODE_AMRWB_VAD2 ((__u32) 0x00000004)
 #define SND_AUDIOPROFILE_AMRWBPLUS ((__u32) 0x00000001)
 #define SND_AUDIOPROFILE_AAC ((__u32) 0x00000001)
-#define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
 #define SND_AUDIOMODE_AAC_LC ((__u32) 0x00000002)
 #define SND_AUDIOMODE_AAC_SSR ((__u32) 0x00000004)
 #define SND_AUDIOMODE_AAC_LTP ((__u32) 0x00000008)
-#define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
 #define SND_AUDIOMODE_AAC_SCALABLE ((__u32) 0x00000020)
 #define SND_AUDIOMODE_AAC_ERLC ((__u32) 0x00000040)
 #define SND_AUDIOMODE_AAC_LD ((__u32) 0x00000080)
-#define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
 #define SND_AUDIOMODE_AAC_HE_MPS ((__u32) 0x00000200)
 #define SND_AUDIOSTREAMFORMAT_MP2ADTS ((__u32) 0x00000001)
 #define SND_AUDIOSTREAMFORMAT_MP4ADTS ((__u32) 0x00000002)
-#define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
 #define SND_AUDIOSTREAMFORMAT_MP4LATM ((__u32) 0x00000008)
 #define SND_AUDIOSTREAMFORMAT_ADIF ((__u32) 0x00000010)
 #define SND_AUDIOSTREAMFORMAT_MP4FF ((__u32) 0x00000020)
-#define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
 #define SND_AUDIOPROFILE_WMA7 ((__u32) 0x00000001)
 #define SND_AUDIOPROFILE_WMA8 ((__u32) 0x00000002)
 #define SND_AUDIOPROFILE_WMA9 ((__u32) 0x00000004)
-#define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
 #define SND_AUDIOMODE_WMA_LEVEL1 ((__u32) 0x00000001)
 #define SND_AUDIOMODE_WMA_LEVEL2 ((__u32) 0x00000002)
 #define SND_AUDIOMODE_WMA_LEVEL3 ((__u32) 0x00000004)
-#define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
 #define SND_AUDIOMODE_WMAPRO_LEVELM0 ((__u32) 0x00000010)
 #define SND_AUDIOMODE_WMAPRO_LEVELM1 ((__u32) 0x00000020)
 #define SND_AUDIOMODE_WMAPRO_LEVELM2 ((__u32) 0x00000040)
-#define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
 #define SND_AUDIOSTREAMFORMAT_WMA_ASF ((__u32) 0x00000001)
 #define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR ((__u32) 0x00000002)
 #define SND_AUDIOPROFILE_REALAUDIO ((__u32) 0x00000001)
-#define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
 #define SND_AUDIOMODE_REALAUDIO_8 ((__u32) 0x00000002)
 #define SND_AUDIOMODE_REALAUDIO_10 ((__u32) 0x00000004)
 #define SND_AUDIOMODE_REALAUDIO_SURROUND ((__u32) 0x00000008)
-#define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
 #define SND_AUDIOMODE_VORBIS ((__u32) 0x00000001)
 #define SND_AUDIOPROFILE_FLAC ((__u32) 0x00000001)
 #define SND_AUDIOMODE_FLAC_LEVEL0 ((__u32) 0x00000001)
-#define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
 #define SND_AUDIOMODE_FLAC_LEVEL2 ((__u32) 0x00000004)
 #define SND_AUDIOMODE_FLAC_LEVEL3 ((__u32) 0x00000008)
 #define SND_AUDIOMODE_FLAC_LEVEL4 ((__u32) 0x00000010)
-#define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
 #define SND_AUDIOMODE_FLAC_LEVEL6 ((__u32) 0x00000040)
 #define SND_AUDIOMODE_FLAC_LEVEL7 ((__u32) 0x00000080)
 #define SND_AUDIOMODE_FLAC_LEVEL8 ((__u32) 0x00000100)
-#define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
 #define SND_AUDIOSTREAMFORMAT_FLAC_OGG ((__u32) 0x00000002)
 #define SND_AUDIOPROFILE_IEC61937 ((__u32) 0x00000001)
 #define SND_AUDIOPROFILE_IEC61937_SPDIF ((__u32) 0x00000002)
-#define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
 #define SND_AUDIOMODE_IEC_LPCM ((__u32) 0x00000001)
 #define SND_AUDIOMODE_IEC_AC3 ((__u32) 0x00000002)
 #define SND_AUDIOMODE_IEC_MPEG1 ((__u32) 0x00000004)
-#define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
 #define SND_AUDIOMODE_IEC_MPEG2 ((__u32) 0x00000010)
 #define SND_AUDIOMODE_IEC_AACLC ((__u32) 0x00000020)
 #define SND_AUDIOMODE_IEC_DTS ((__u32) 0x00000040)
-#define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
 #define SND_AUDIOMODE_IEC_SACD ((__u32) 0x00000100)
 #define SND_AUDIOMODE_IEC_EAC3 ((__u32) 0x00000200)
 #define SND_AUDIOMODE_IEC_DTS_HD ((__u32) 0x00000400)
-#define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
 #define SND_AUDIOMODE_IEC_DST ((__u32) 0x00001000)
 #define SND_AUDIOMODE_IEC_WMAPRO ((__u32) 0x00002000)
 #define SND_AUDIOMODE_IEC_REF_CXT ((__u32) 0x00004000)
-#define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
 #define SND_AUDIOMODE_IEC_HE_AAC2 ((__u32) 0x00010000)
 #define SND_AUDIOMODE_IEC_MPEG_SURROUND ((__u32) 0x00020000)
 #define SND_AUDIOPROFILE_G723_1 ((__u32) 0x00000001)
-#define SND_AUDIOMODE_G723_1_ANNEX_A ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_G723_1_ANNEX_A ((__u32) 0x00000001)
 #define SND_AUDIOMODE_G723_1_ANNEX_B ((__u32) 0x00000002)
 #define SND_AUDIOMODE_G723_1_ANNEX_C ((__u32) 0x00000004)
 #define SND_AUDIOPROFILE_G729 ((__u32) 0x00000001)
-#define SND_AUDIOMODE_G729_ANNEX_A ((__u32) 0x00000001)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SND_AUDIOMODE_G729_ANNEX_A ((__u32) 0x00000001)
 #define SND_AUDIOMODE_G729_ANNEX_B ((__u32) 0x00000002)
 #define SND_RATECONTROLMODE_CONSTANTBITRATE ((__u32) 0x00000001)
 #define SND_RATECONTROLMODE_VARIABLEBITRATE ((__u32) 0x00000002)
-struct snd_enc_wma {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct snd_enc_wma {
   __u32 super_block_align;
 };
 struct snd_enc_vorbis {
-  __s32 quality;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s32 quality;
   __u32 managed;
   __u32 max_bit_rate;
   __u32 min_bit_rate;
-  __u32 downmix;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 downmix;
 } __attribute__((packed, aligned(4)));
 struct snd_enc_real {
   __u32 quant_bits;
-  __u32 start_region;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 start_region;
   __u32 num_regions;
 } __attribute__((packed, aligned(4)));
 struct snd_enc_flac {
-  __u32 num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 num;
   __u32 gain;
 } __attribute__((packed, aligned(4)));
 struct snd_enc_generic {
-  __u32 bw;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bw;
   __s32 reserved[15];
 } __attribute__((packed, aligned(4)));
 union snd_codec_options {
-  struct snd_enc_wma wma;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct snd_enc_wma wma;
   struct snd_enc_vorbis vorbis;
   struct snd_enc_real real;
   struct snd_enc_flac flac;
-  struct snd_enc_generic generic;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  struct snd_enc_generic generic;
 } __attribute__((packed, aligned(4)));
 struct snd_codec_desc {
   __u32 max_ch;
-  __u32 sample_rates[MAX_NUM_SAMPLE_RATES];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 sample_rates[MAX_NUM_SAMPLE_RATES];
   __u32 num_sample_rates;
   __u32 bit_rate[MAX_NUM_BITRATES];
   __u32 num_bitrates;
-  __u32 rate_control;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 rate_control;
   __u32 profiles;
   __u32 modes;
   __u32 formats;
-  __u32 min_buffer;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 min_buffer;
   __u32 reserved[15];
 } __attribute__((packed, aligned(4)));
 struct snd_codec {
-  __u32 id;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 id;
   __u32 ch_in;
   __u32 ch_out;
   __u32 sample_rate;
-  __u32 bit_rate;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 bit_rate;
   __u32 rate_control;
   __u32 profile;
   __u32 level;
-  __u32 ch_mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 ch_mode;
   __u32 format;
   __u32 align;
   union snd_codec_options options;
-  __u32 reserved[3];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __u32 reserved[3];
 } __attribute__((packed, aligned(4)));
 #endif
diff --git a/libc/kernel/uapi/xen/gntdev.h b/libc/kernel/uapi/xen/gntdev.h
index 89e5eb0..08ac9c7 100644
--- a/libc/kernel/uapi/xen/gntdev.h
+++ b/libc/kernel/uapi/xen/gntdev.h
@@ -62,7 +62,29 @@
   __u32 event_channel_port;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+struct gntdev_grant_copy_segment {
+  union {
+    void __user * virt;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    struct {
+      grant_ref_t ref;
+      __u16 offset;
+      domid_t domid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+    } foreign;
+  } source, dest;
+  __u16 len;
+  __u16 flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  __s16 status;
+};
+#define IOCTL_GNTDEV_GRANT_COPY _IOC(_IOC_NONE, 'G', 8, sizeof(struct ioctl_gntdev_grant_copy))
+struct ioctl_gntdev_grant_copy {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+  unsigned int count;
+  struct gntdev_grant_copy_segment __user * segments;
+};
 #define UNMAP_NOTIFY_CLEAR_BYTE 0x1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define UNMAP_NOTIFY_SEND_EVENT 0x2
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/libc.arm.brillo.map b/libc/libc.arm.brillo.map
deleted file mode 100644
index 4e5b5c8..0000000
--- a/libc/libc.arm.brillo.map
+++ /dev/null
@@ -1,1458 +0,0 @@
-# Generated by genversionscripts.py. Do not edit.
-LIBC {
-  global:
-    __assert;
-    __assert2;
-    __atomic_cmpxchg; # arm
-    __atomic_dec; # arm
-    __atomic_inc; # arm
-    __atomic_swap; # arm
-    __b64_ntop;
-    __b64_pton;
-    __brk; # arm x86 mips
-    __cmsg_nxthdr;
-    __connect; # arm x86 mips
-    __ctype_get_mb_cur_max;
-    __cxa_atexit;
-    __cxa_finalize;
-    __cxa_thread_atexit_impl;
-    __dn_comp;
-    __dn_count_labels;
-    __dn_skipname;
-    __epoll_pwait; # arm x86 mips
-    __errno;
-    __exit; # arm x86 mips
-    __fbufsize;
-    __fcntl64; # arm x86 mips
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
-    __fp_nquery;
-    __fp_query;
-    __fpclassify;
-    __fpclassifyd;
-    __fpclassifyf;
-    __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
-    __fstatfs64; # arm x86 mips
-    __fwritable;
-    __get_h_errno;
-    __getcpu; # arm x86 mips
-    __getcwd; # arm x86 mips
-    __getpid; # arm x86 mips
-    __getpriority; # arm x86 mips
-    __gnu_basename;
-    __gnu_strerror_r;
-    __hostalias;
-    __ioctl; # arm x86 mips
-    __isfinite;
-    __isfinitef;
-    __isfinitel;
-    __isinf;
-    __isinff;
-    __isinfl;
-    __isnan;
-    __isnanf;
-    __isnanl;
-    __isnormal;
-    __isnormalf;
-    __isnormall;
-    __isthreaded; # arm x86 mips
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
-    __libc_init;
-    __llseek; # arm x86 mips
-    __loc_aton;
-    __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
-    __mmap2; # arm x86 mips
-    __ns_format_ttl; # arm x86 mips
-    __ns_get16; # arm x86 mips
-    __ns_get32; # arm x86 mips
-    __ns_initparse; # arm x86 mips
-    __ns_makecanon; # arm x86 mips
-    __ns_msg_getflag; # arm x86 mips
-    __ns_name_compress; # arm x86 mips
-    __ns_name_ntol; # arm x86 mips
-    __ns_name_ntop; # arm x86 mips
-    __ns_name_pack; # arm x86 mips
-    __ns_name_pton; # arm x86 mips
-    __ns_name_rollback; # arm x86 mips
-    __ns_name_skip; # arm x86 mips
-    __ns_name_uncompress; # arm x86 mips
-    __ns_name_unpack; # arm x86 mips
-    __ns_parserr; # arm x86 mips
-    __ns_put16; # arm x86 mips
-    __ns_put32; # arm x86 mips
-    __ns_samename; # arm x86 mips
-    __ns_skiprr; # arm x86 mips
-    __ns_sprintrr; # arm x86 mips
-    __ns_sprintrrf; # arm x86 mips
-    __open_2;
-    __openat; # arm x86 mips
-    __openat_2;
-    __p_cdname;
-    __p_cdnname;
-    __p_class;
-    __p_class_syms;
-    __p_fqname;
-    __p_fqnname;
-    __p_option;
-    __p_query;
-    __p_rcode;
-    __p_secstodate;
-    __p_time;
-    __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll; # arm x86 mips
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
-    __pselect6; # arm x86 mips
-    __pthread_cleanup_pop;
-    __pthread_cleanup_push;
-    __ptrace; # arm x86 mips
-    __putlong;
-    __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
-    __reboot; # arm x86 mips
-    __recvfrom_chk;
-    __register_atfork;
-    __res_close;
-    __res_dnok;
-    __res_hnok;
-    __res_hostalias;
-    __res_isourserver;
-    __res_mailok;
-    __res_nameinquery;
-    __res_nclose;
-    __res_ninit;
-    __res_nmkquery;
-    __res_nquery;
-    __res_nquerydomain;
-    __res_nsearch;
-    __res_nsend;
-    __res_ownok;
-    __res_queriesmatch;
-    __res_querydomain;
-    __res_send;
-    __res_send_setqhook;
-    __res_send_setrhook;
-    __rt_sigaction; # arm x86 mips
-    __rt_sigpending; # arm x86 mips
-    __rt_sigprocmask; # arm x86 mips
-    __rt_sigsuspend; # arm x86 mips
-    __rt_sigtimedwait; # arm x86 mips
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sched_getaffinity; # arm x86 mips
-    __set_tid_address; # arm x86 mips
-    __set_tls; # arm mips
-    __sF;
-    __sigaction; # arm x86 mips
-    __snprintf_chk;
-    __socket; # arm x86 mips
-    __sprintf_chk;
-    __stack_chk_fail;
-    __stack_chk_guard;
-    __statfs64; # arm x86 mips
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
-    __sym_ntop;
-    __sym_ntos;
-    __sym_ston;
-    __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
-    __system_property_find;
-    __system_property_find_nth;
-    __system_property_foreach;
-    __system_property_get;
-    __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
-    __timer_create; # arm x86 mips
-    __timer_delete; # arm x86 mips
-    __timer_getoverrun; # arm x86 mips
-    __timer_gettime; # arm x86 mips
-    __timer_settime; # arm x86 mips
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
-    __waitid; # arm x86 mips
-    _ctype_;
-    _Exit;
-    _exit;
-    _flushlbf;
-    _getlong;
-    _getshort;
-    _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
-    _setjmp;
-    _tolower;
-    _tolower_tab_; # arm x86 mips
-    _toupper;
-    _toupper_tab_; # arm x86 mips
-    abort;
-    abs;
-    accept;
-    accept4;
-    access;
-    acct;
-    alarm;
-    alphasort;
-    alphasort64;
-    android_set_abort_message;
-    arc4random;
-    arc4random_buf;
-    arc4random_uniform;
-    asctime;
-    asctime64; # arm x86 mips
-    asctime64_r; # arm x86 mips
-    asctime_r;
-    asprintf;
-    at_quick_exit;
-    atof;
-    atoi;
-    atol;
-    atoll;
-    basename;
-    basename_r; # arm x86 mips
-    bind;
-    bindresvport;
-    brk;
-    bsearch;
-    btowc;
-    c16rtomb;
-    c32rtomb;
-    cacheflush; # arm mips
-    calloc;
-    capget;
-    capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
-    chdir;
-    chmod;
-    chown;
-    chroot;
-    clearenv;
-    clearerr;
-    clearerr_unlocked;
-    clock;
-    clock_getcpuclockid;
-    clock_getres;
-    clock_gettime;
-    clock_nanosleep;
-    clock_settime;
-    clone;
-    close;
-    closedir;
-    closelog;
-    connect;
-    creat;
-    creat64;
-    ctime;
-    ctime64; # arm x86 mips
-    ctime64_r; # arm x86 mips
-    ctime_r;
-    daemon;
-    daylight;
-    delete_module;
-    difftime;
-    dirfd;
-    dirname;
-    dirname_r; # arm x86 mips
-    div;
-    dn_expand;
-    dprintf;
-    drand48;
-    dup;
-    dup2;
-    dup3;
-    duplocale;
-    endmntent;
-    endservent;
-    endutent;
-    environ;
-    epoll_create;
-    epoll_create1;
-    epoll_ctl;
-    epoll_pwait;
-    epoll_wait;
-    erand48;
-    err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
-    errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
-    eventfd;
-    eventfd_read;
-    eventfd_write;
-    execl;
-    execle;
-    execlp;
-    execv;
-    execve;
-    execvp;
-    execvpe;
-    exit;
-    faccessat;
-    fallocate;
-    fallocate64;
-    fchdir;
-    fchmod;
-    fchmodat;
-    fchown;
-    fchownat;
-    fclose;
-    fcntl;
-    fdatasync;
-    fdopen;
-    fdopendir;
-    feof;
-    feof_unlocked;
-    ferror;
-    ferror_unlocked;
-    fflush;
-    ffs;
-    fgetc;
-    fgetln;
-    fgetpos;
-    fgets;
-    fgetwc;
-    fgetws;
-    fgetxattr;
-    fileno;
-    flistxattr;
-    flock;
-    flockfile;
-    fmemopen;
-    fnmatch;
-    fopen;
-    fork;
-    forkpty;
-    fpathconf;
-    fprintf;
-    fpurge;
-    fputc;
-    fputs;
-    fputwc;
-    fputws;
-    fread;
-    free;
-    freeaddrinfo;
-    freelocale;
-    fremovexattr;
-    freopen;
-    fscanf;
-    fseek;
-    fseeko;
-    fsetpos;
-    fsetxattr;
-    fstat;
-    fstat64;
-    fstatat;
-    fstatat64;
-    fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
-    fsync;
-    ftell;
-    ftello;
-    ftok;
-    ftruncate;
-    ftruncate64;
-    ftrylockfile;
-    fts_children;
-    fts_close;
-    fts_open;
-    fts_read;
-    fts_set;
-    ftw;
-    ftw64;
-    funlockfile;
-    funopen;
-    futimens;
-    fwide;
-    fwprintf;
-    fwrite;
-    fwscanf;
-    gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
-    getaddrinfo;
-    getauxval;
-    getc;
-    getc_unlocked;
-    getchar;
-    getchar_unlocked;
-    getcwd;
-    getdelim;
-    getegid;
-    getenv;
-    geteuid;
-    getgid;
-    getgrgid;
-    getgrnam;
-    getgrouplist;
-    getgroups;
-    gethostbyaddr;
-    gethostbyaddr_r;
-    gethostbyname;
-    gethostbyname2;
-    gethostbyname2_r;
-    gethostbyname_r;
-    gethostent;
-    gethostname;
-    getitimer;
-    getline;
-    getlogin;
-    getmntent;
-    getmntent_r;
-    getnameinfo;
-    getnetbyaddr;
-    getnetbyname;
-    getopt;
-    getopt_long;
-    getopt_long_only;
-    getpagesize;
-    getpeername;
-    getpgid;
-    getpgrp;
-    getpid;
-    getppid;
-    getpriority;
-    getprogname;
-    getprotobyname;
-    getprotobynumber;
-    getpt;
-    getpwnam;
-    getpwnam_r;
-    getpwuid;
-    getpwuid_r;
-    getresgid;
-    getresuid;
-    getrlimit;
-    getrlimit64;
-    getrusage;
-    gets;
-    getservbyname;
-    getservbyport;
-    getservent;
-    getsid;
-    getsockname;
-    getsockopt;
-    gettid;
-    gettimeofday;
-    getuid;
-    getutent;
-    getwc;
-    getwchar;
-    getxattr;
-    gmtime;
-    gmtime64; # arm x86 mips
-    gmtime64_r; # arm x86 mips
-    gmtime_r;
-    grantpt;
-    herror;
-    hstrerror;
-    htonl;
-    htons;
-    if_indextoname;
-    if_nametoindex;
-    imaxabs;
-    imaxdiv;
-    inet_addr;
-    inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
-    inet_nsap_addr;
-    inet_nsap_ntoa;
-    inet_ntoa;
-    inet_ntop;
-    inet_pton;
-    init_module;
-    initgroups;
-    initstate;
-    inotify_add_watch;
-    inotify_init;
-    inotify_init1;
-    inotify_rm_watch;
-    insque;
-    ioctl;
-    isalnum;
-    isalnum_l;
-    isalpha;
-    isalpha_l;
-    isascii;
-    isatty;
-    isblank;
-    isblank_l;
-    iscntrl;
-    iscntrl_l;
-    isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
-    isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
-    islower;
-    islower_l;
-    isnan;
-    isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
-    isprint;
-    isprint_l;
-    ispunct;
-    ispunct_l;
-    isspace;
-    isspace_l;
-    isupper;
-    isupper_l;
-    iswalnum;
-    iswalnum_l;
-    iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
-    iswcntrl;
-    iswcntrl_l;
-    iswctype;
-    iswctype_l;
-    iswdigit;
-    iswdigit_l;
-    iswgraph;
-    iswgraph_l;
-    iswlower;
-    iswlower_l;
-    iswprint;
-    iswprint_l;
-    iswpunct;
-    iswpunct_l;
-    iswspace;
-    iswspace_l;
-    iswupper;
-    iswupper_l;
-    iswxdigit;
-    iswxdigit_l;
-    isxdigit;
-    isxdigit_l;
-    jrand48;
-    kill;
-    killpg;
-    klogctl;
-    labs;
-    lchown;
-    lcong48;
-    ldexp;
-    ldiv;
-    lfind;
-    lgetxattr;
-    link;
-    linkat;
-    listen;
-    listxattr;
-    llabs;
-    lldiv;
-    llistxattr;
-    localeconv;
-    localtime;
-    localtime64; # arm x86 mips
-    localtime64_r; # arm x86 mips
-    localtime_r;
-    login_tty;
-    longjmp;
-    lrand48;
-    lremovexattr;
-    lsearch;
-    lseek;
-    lseek64;
-    lsetxattr;
-    lstat;
-    lstat64;
-    madvise;
-    mallinfo;
-    malloc;
-    malloc_info;
-    malloc_usable_size;
-    mbrlen;
-    mbrtoc16;
-    mbrtoc32;
-    mbrtowc;
-    mbsinit;
-    mbsnrtowcs;
-    mbsrtowcs;
-    mbstowcs;
-    mbtowc;
-    memalign;
-    memccpy;
-    memchr;
-    memcmp;
-    memcpy;
-    memmem;
-    memmove;
-    mempcpy;
-    memrchr;
-    memset;
-    mincore;
-    mkdir;
-    mkdirat;
-    mkdtemp;
-    mkfifo;
-    mkfifoat;
-    mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
-    mkstemp;
-    mkstemp64;
-    mkstemps;
-    mkstemps64;
-    mktemp;
-    mktime;
-    mktime64; # arm x86 mips
-    mlock;
-    mlockall;
-    mmap;
-    mmap64;
-    mount;
-    mprotect;
-    mrand48;
-    mremap;
-    msync;
-    munlock;
-    munlockall;
-    munmap;
-    nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
-    nice;
-    nrand48;
-    nsdispatch;
-    ntohl;
-    ntohs;
-    open;
-    open64;
-    open_memstream;
-    open_wmemstream;
-    openat;
-    openat64;
-    opendir;
-    openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
-    pathconf;
-    pause;
-    pclose;
-    perror;
-    personality;
-    pipe;
-    pipe2;
-    poll;
-    popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
-    prctl;
-    pread;
-    pread64;
-    printf;
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
-    pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
-    pthread_attr_destroy;
-    pthread_attr_getdetachstate;
-    pthread_attr_getguardsize;
-    pthread_attr_getschedparam;
-    pthread_attr_getschedpolicy;
-    pthread_attr_getscope;
-    pthread_attr_getstack;
-    pthread_attr_getstacksize;
-    pthread_attr_init;
-    pthread_attr_setdetachstate;
-    pthread_attr_setguardsize;
-    pthread_attr_setschedparam;
-    pthread_attr_setschedpolicy;
-    pthread_attr_setscope;
-    pthread_attr_setstack;
-    pthread_attr_setstacksize;
-    pthread_cond_broadcast;
-    pthread_cond_destroy;
-    pthread_cond_init;
-    pthread_cond_signal;
-    pthread_cond_timedwait;
-    pthread_cond_timedwait_monotonic; # arm x86 mips
-    pthread_cond_timedwait_monotonic_np; # arm x86 mips
-    pthread_cond_timedwait_relative_np; # arm x86 mips
-    pthread_cond_timeout_np; # arm x86 mips
-    pthread_cond_wait;
-    pthread_condattr_destroy;
-    pthread_condattr_getclock;
-    pthread_condattr_getpshared;
-    pthread_condattr_init;
-    pthread_condattr_setclock;
-    pthread_condattr_setpshared;
-    pthread_create;
-    pthread_detach;
-    pthread_equal;
-    pthread_exit;
-    pthread_getattr_np;
-    pthread_getcpuclockid;
-    pthread_getschedparam;
-    pthread_getspecific;
-    pthread_gettid_np;
-    pthread_join;
-    pthread_key_create;
-    pthread_key_delete;
-    pthread_kill;
-    pthread_mutex_destroy;
-    pthread_mutex_init;
-    pthread_mutex_lock;
-    pthread_mutex_lock_timeout_np; # arm x86 mips
-    pthread_mutex_timedlock;
-    pthread_mutex_trylock;
-    pthread_mutex_unlock;
-    pthread_mutexattr_destroy;
-    pthread_mutexattr_getpshared;
-    pthread_mutexattr_gettype;
-    pthread_mutexattr_init;
-    pthread_mutexattr_setpshared;
-    pthread_mutexattr_settype;
-    pthread_once;
-    pthread_rwlock_destroy;
-    pthread_rwlock_init;
-    pthread_rwlock_rdlock;
-    pthread_rwlock_timedrdlock;
-    pthread_rwlock_timedwrlock;
-    pthread_rwlock_tryrdlock;
-    pthread_rwlock_trywrlock;
-    pthread_rwlock_unlock;
-    pthread_rwlock_wrlock;
-    pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
-    pthread_rwlockattr_getpshared;
-    pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
-    pthread_rwlockattr_setpshared;
-    pthread_self;
-    pthread_setname_np;
-    pthread_setschedparam;
-    pthread_setspecific;
-    pthread_sigmask;
-    ptrace;
-    ptsname;
-    ptsname_r;
-    putc;
-    putc_unlocked;
-    putchar;
-    putchar_unlocked;
-    putenv;
-    puts;
-    pututline;
-    putw; # arm x86 mips
-    putwc;
-    putwchar;
-    pvalloc; # arm x86 mips
-    pwrite;
-    pwrite64;
-    qsort;
-    quick_exit;
-    raise;
-    rand;
-    rand_r;
-    random;
-    read;
-    readahead;
-    readdir;
-    readdir64;
-    readdir64_r;
-    readdir_r;
-    readlink;
-    readlinkat;
-    readv;
-    realloc;
-    realpath;
-    reboot;
-    recv;
-    recvfrom;
-    recvmmsg;
-    recvmsg;
-    regcomp;
-    regerror;
-    regexec;
-    regfree;
-    remove;
-    removexattr;
-    remque;
-    rename;
-    renameat;
-    res_init;
-    res_mkquery;
-    res_query;
-    res_search;
-    rewind;
-    rewinddir;
-    rmdir;
-    sbrk;
-    scandir;
-    scandir64;
-    scanf;
-    sched_get_priority_max;
-    sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
-    sched_getparam;
-    sched_getscheduler;
-    sched_rr_get_interval;
-    sched_setaffinity;
-    sched_setparam;
-    sched_setscheduler;
-    sched_yield;
-    seed48;
-    seekdir;
-    select;
-    sem_close;
-    sem_destroy;
-    sem_getvalue;
-    sem_init;
-    sem_open;
-    sem_post;
-    sem_timedwait;
-    sem_trywait;
-    sem_unlink;
-    sem_wait;
-    send;
-    sendfile;
-    sendfile64;
-    sendmmsg;
-    sendmsg;
-    sendto;
-    setbuf;
-    setbuffer;
-    setegid;
-    setenv;
-    seteuid;
-    setfsgid;
-    setfsuid;
-    setgid;
-    setgroups;
-    sethostname;
-    setitimer;
-    setjmp;
-    setlinebuf;
-    setlocale;
-    setlogmask;
-    setmntent;
-    setns;
-    setpgid;
-    setpgrp;
-    setpriority;
-    setprogname;
-    setregid;
-    setresgid;
-    setresuid;
-    setreuid;
-    setrlimit;
-    setrlimit64;
-    setservent;
-    setsid;
-    setsockopt;
-    setstate;
-    settimeofday;
-    setuid;
-    setutent;
-    setvbuf;
-    setxattr;
-    shutdown;
-    sigaction;
-    sigaddset;
-    sigaltstack;
-    sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
-    siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
-    sigpending;
-    sigprocmask;
-    sigqueue;
-    sigsetjmp;
-    sigsetmask;
-    sigsuspend;
-    sigtimedwait;
-    sigwait;
-    sigwaitinfo;
-    sleep;
-    snprintf;
-    socket;
-    socketpair;
-    splice;
-    sprintf;
-    srand;
-    srand48;
-    srandom;
-    sscanf;
-    stat;
-    stat64;
-    statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
-    strcasecmp;
-    strcasecmp_l;
-    strcasestr;
-    strcat;
-    strchr;
-    strcmp;
-    strcoll;
-    strcoll_l;
-    strcpy;
-    strcspn;
-    strdup;
-    strerror;
-    strerror_l;
-    strerror_r;
-    strftime;
-    strftime_l;
-    strlcat;
-    strlcpy;
-    strlen;
-    strncasecmp;
-    strncasecmp_l;
-    strncat;
-    strncmp;
-    strncpy;
-    strndup;
-    strnlen;
-    strpbrk;
-    strptime;
-    strrchr;
-    strsep;
-    strsignal;
-    strspn;
-    strstr;
-    strtod;
-    strtof;
-    strtoimax;
-    strtok;
-    strtok_r;
-    strtol;
-    strtold;
-    strtold_l;
-    strtoll;
-    strtoll_l;
-    strtoq;
-    strtoul;
-    strtoull;
-    strtoull_l;
-    strtoumax;
-    strtouq;
-    strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
-    swprintf;
-    swscanf;
-    symlink;
-    symlinkat;
-    sync;
-    sys_siglist;
-    sys_signame;
-    syscall;
-    sysconf;
-    sysinfo;
-    syslog;
-    system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
-    tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
-    tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
-    tempnam;
-    tfind;
-    tgkill;
-    time;
-    timegm;
-    timegm64; # arm x86 mips
-    timelocal;
-    timelocal64; # arm x86 mips
-    timer_create;
-    timer_delete;
-    timer_getoverrun;
-    timer_gettime;
-    timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
-    times;
-    timezone;
-    tmpfile;
-    tmpnam;
-    toascii;
-    tolower;
-    tolower_l;
-    toupper;
-    toupper_l;
-    towlower;
-    towlower_l;
-    towupper;
-    towupper_l;
-    truncate;
-    truncate64;
-    tsearch;
-    ttyname;
-    ttyname_r;
-    twalk;
-    tzname;
-    tzset;
-    umask;
-    umount;
-    umount2;
-    uname;
-    ungetc;
-    ungetwc;
-    unlink;
-    unlinkat;
-    unlockpt;
-    unsetenv;
-    unshare;
-    uselocale;
-    usleep;
-    utime;
-    utimensat;
-    utimes;
-    utmpname;
-    valloc; # arm x86 mips
-    vasprintf;
-    vdprintf;
-    verr;
-    verrx;
-    vfork;
-    vfprintf;
-    vfscanf;
-    vfwprintf;
-    vfwscanf;
-    vmsplice;
-    vprintf;
-    vscanf;
-    vsnprintf;
-    vsprintf;
-    vsscanf;
-    vswprintf;
-    vswscanf;
-    vsyslog;
-    vwarn;
-    vwarnx;
-    vwprintf;
-    vwscanf;
-    wait;
-    wait4;
-    waitid;
-    waitpid;
-    warn;
-    warnx;
-    wcpcpy;
-    wcpncpy;
-    wcrtomb;
-    wcscasecmp;
-    wcscasecmp_l;
-    wcscat;
-    wcschr;
-    wcscmp;
-    wcscoll;
-    wcscoll_l;
-    wcscpy;
-    wcscspn;
-    wcsdup;
-    wcsftime;
-    wcslcat;
-    wcslcpy;
-    wcslen;
-    wcsncasecmp;
-    wcsncasecmp_l;
-    wcsncat;
-    wcsncmp;
-    wcsncpy;
-    wcsnlen;
-    wcsnrtombs;
-    wcspbrk;
-    wcsrchr;
-    wcsrtombs;
-    wcsspn;
-    wcsstr;
-    wcstod;
-    wcstof;
-    wcstoimax;
-    wcstok;
-    wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
-    wcstombs;
-    wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
-    wcswidth;
-    wcsxfrm;
-    wcsxfrm_l;
-    wctob;
-    wctomb;
-    wctype;
-    wctype_l;
-    wcwidth;
-    wmemchr;
-    wmemcmp;
-    wmemcpy;
-    wmemmove;
-    wmempcpy;
-    wmemset;
-    wprintf;
-    write;
-    writev;
-    wscanf;
-  local:
-    *;
-};
-
-LIBC_N {
-  global:
-    __aeabi_atexit; # arm
-    __aeabi_memclr; # arm
-    __aeabi_memclr4; # arm
-    __aeabi_memclr8; # arm
-    __aeabi_memcpy; # arm
-    __aeabi_memcpy4; # arm
-    __aeabi_memcpy8; # arm
-    __aeabi_memmove; # arm
-    __aeabi_memmove4; # arm
-    __aeabi_memmove8; # arm
-    __aeabi_memset; # arm
-    __aeabi_memset4; # arm
-    __aeabi_memset8; # arm
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __gnu_Unwind_Find_exidx; # arm
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    prlimit; # arm mips x86
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
-} LIBC;
-
-LIBC_PRIVATE {
-  global:
-    ___Unwind_Backtrace; # arm
-    ___Unwind_ForcedUnwind; # arm
-    ___Unwind_RaiseException; # arm
-    ___Unwind_Resume; # arm
-    ___Unwind_Resume_or_Rethrow; # arm
-    __accept4; # arm x86 mips
-    __adddf3; # arm
-    __addsf3; # arm
-    __aeabi_atexit; # arm
-    __aeabi_cdcmpeq; # arm
-    __aeabi_cdcmple; # arm
-    __aeabi_cdrcmple; # arm
-    __aeabi_d2f; # arm
-    __aeabi_d2iz; # arm
-    __aeabi_dadd; # arm
-    __aeabi_dcmpeq; # arm
-    __aeabi_dcmpge; # arm
-    __aeabi_dcmpgt; # arm
-    __aeabi_dcmple; # arm
-    __aeabi_dcmplt; # arm
-    __aeabi_dcmpun; # arm
-    __aeabi_ddiv; # arm
-    __aeabi_dmul; # arm
-    __aeabi_drsub; # arm
-    __aeabi_dsub; # arm
-    __aeabi_f2d; # arm
-    __aeabi_f2iz; # arm
-    __aeabi_f2uiz; # arm
-    __aeabi_fadd; # arm
-    __aeabi_fcmpun; # arm
-    __aeabi_fdiv; # arm
-    __aeabi_fmul; # arm
-    __aeabi_frsub; # arm
-    __aeabi_fsub; # arm
-    __aeabi_i2d; # arm
-    __aeabi_i2f; # arm
-    __aeabi_idiv; # arm
-    __aeabi_idiv0; # arm
-    __aeabi_idivmod; # arm
-    __aeabi_l2d; # arm
-    __aeabi_l2f; # arm
-    __aeabi_lasr; # arm
-    __aeabi_ldiv0; # arm
-    __aeabi_ldivmod; # arm
-    __aeabi_llsl; # arm
-    __aeabi_llsr; # arm
-    __aeabi_lmul; # arm
-    __aeabi_memclr; # arm
-    __aeabi_memclr4; # arm
-    __aeabi_memclr8; # arm
-    __aeabi_memcpy; # arm
-    __aeabi_memcpy4; # arm
-    __aeabi_memcpy8; # arm
-    __aeabi_memmove; # arm
-    __aeabi_memmove4; # arm
-    __aeabi_memmove8; # arm
-    __aeabi_memset; # arm
-    __aeabi_memset4; # arm
-    __aeabi_memset8; # arm
-    __aeabi_ui2d; # arm
-    __aeabi_ui2f; # arm
-    __aeabi_uidiv; # arm
-    __aeabi_uidivmod; # arm
-    __aeabi_ul2d; # arm
-    __aeabi_ul2f; # arm
-    __aeabi_uldivmod; # arm
-    __aeabi_unwind_cpp_pr0; # arm
-    __aeabi_unwind_cpp_pr1; # arm
-    __aeabi_unwind_cpp_pr2; # arm
-    __arm_fadvise64_64; # arm
-    __ashldi3; # arm
-    __ashrdi3; # arm
-    __bionic_brk; # arm x86 mips
-    __bionic_libgcc_compat_symbols; # arm x86
-    __cmpdf2; # arm
-    __divdf3; # arm
-    __divdi3; # arm x86 mips
-    __divsf3; # arm
-    __divsi3; # arm
-    __dso_handle; # arm
-    __eqdf2; # arm
-    __extendsfdf2; # arm
-    __fixdfsi; # arm
-    __fixsfsi; # arm
-    __fixunssfsi; # arm
-    __floatdidf; # arm
-    __floatdisf; # arm
-    __floatsidf; # arm
-    __floatsisf; # arm
-    __floatundidf; # arm
-    __floatundisf; # arm
-    __floatunsidf; # arm
-    __floatunsisf; # arm
-    __gedf2; # arm
-    __getdents64; # arm x86 mips
-    __gnu_ldivmod_helper; # arm
-    __gnu_uldivmod_helper; # arm
-    __gnu_Unwind_Backtrace; # arm
-    __gnu_unwind_execute; # arm
-    __gnu_Unwind_Find_exidx; # arm
-    __gnu_Unwind_ForcedUnwind; # arm
-    __gnu_unwind_frame; # arm
-    __gnu_Unwind_RaiseException; # arm
-    __gnu_Unwind_Restore_VFP; # arm
-    __gnu_Unwind_Restore_VFP_D; # arm
-    __gnu_Unwind_Restore_VFP_D_16_to_31; # arm
-    __gnu_Unwind_Restore_WMMXC; # arm
-    __gnu_Unwind_Restore_WMMXD; # arm
-    __gnu_Unwind_Resume; # arm
-    __gnu_Unwind_Resume_or_Rethrow; # arm
-    __gnu_Unwind_Save_VFP; # arm
-    __gnu_Unwind_Save_VFP_D; # arm
-    __gnu_Unwind_Save_VFP_D_16_to_31; # arm
-    __gnu_Unwind_Save_WMMXC; # arm
-    __gnu_Unwind_Save_WMMXD; # arm
-    __gtdf2; # arm
-    __ledf2; # arm
-    __lshrdi3; # arm
-    __ltdf2; # arm
-    __muldf3; # arm
-    __muldi3; # arm
-    __mulsf3; # arm
-    __nedf2; # arm
-    __popcount_tab; # arm
-    __popcountsi2; # arm x86 mips
-    __restore_core_regs; # arm
-    __sclose; # arm x86 mips
-    __sflags; # arm x86 mips
-    __sflush; # arm x86 mips
-    __sfp; # arm x86 mips
-    __sglue; # arm x86 mips
-    __smakebuf; # arm x86 mips
-    __sread; # arm x86 mips
-    __srefill; # arm x86 mips
-    __srget; # arm x86 mips
-    __sseek; # arm x86 mips
-    __subdf3; # arm
-    __subsf3; # arm
-    __swbuf; # arm x86 mips
-    __swrite; # arm x86 mips
-    __swsetup; # arm x86 mips
-    __truncdfsf2; # arm
-    __udivdi3; # arm x86 mips
-    __udivsi3; # arm
-    __unorddf2; # arm
-    __unordsf2; # arm
-    _fwalk; # arm x86 mips
-    _Unwind_Backtrace; # arm
-    _Unwind_Complete; # arm
-    _Unwind_DeleteException; # arm
-    _Unwind_ForcedUnwind; # arm
-    _Unwind_GetCFA; # arm
-    _Unwind_GetDataRelBase; # arm
-    _Unwind_GetLanguageSpecificData; # arm
-    _Unwind_GetRegionStart; # arm
-    _Unwind_GetTextRelBase; # arm
-    _Unwind_RaiseException; # arm
-    _Unwind_Resume; # arm
-    _Unwind_Resume_or_Rethrow; # arm
-    _Unwind_VRS_Get; # arm
-    _Unwind_VRS_Pop; # arm
-    _Unwind_VRS_Set; # arm
-    android_getaddrinfofornet;
-    android_getaddrinfofornetcontext;
-    android_gethostbyaddrfornet;
-    android_gethostbynamefornet;
-    atexit; # arm
-    free_malloc_leak_info;
-    get_malloc_leak_info;
-    gMallocLeakZygoteChild;
-    restore_core_regs; # arm
-    SHA1Final; # arm x86 mips
-    SHA1Init; # arm x86 mips
-    SHA1Transform; # arm x86 mips
-    SHA1Update; # arm x86 mips
-} LIBC_N;
-
-LIBC_PLATFORM {
-  global:
-    android_net_res_stats_get_info_for_net;
-    android_net_res_stats_aggregate;
-    android_net_res_stats_get_usable_servers;
-    malloc_backtrace;
-    malloc_disable;
-    malloc_enable;
-    malloc_iterate;
-} LIBC_N;
diff --git a/libc/libc.arm.map b/libc/libc.arm.map
index 38f8437..eb75e8f 100644
--- a/libc/libc.arm.map
+++ b/libc/libc.arm.map
@@ -1,4 +1,4 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
     __assert;
@@ -9,45 +9,44 @@
     __atomic_swap; # arm
     __b64_ntop;
     __b64_pton;
-    __brk; # arm x86 mips
-    __cmsg_nxthdr;
-    __connect; # arm x86 mips
-    __ctype_get_mb_cur_max;
+    __cmsg_nxthdr; # introduced=21
+    __connect; # arm x86 mips introduced=21
+    __ctype_get_mb_cur_max; # introduced=21
     __cxa_atexit;
     __cxa_finalize;
-    __cxa_thread_atexit_impl;
+    __cxa_thread_atexit_impl; # introduced=23
     __dn_comp;
     __dn_count_labels;
     __dn_skipname;
-    __epoll_pwait; # arm x86 mips
+    __epoll_pwait; # arm x86 mips introduced=21
     __errno;
-    __exit; # arm x86 mips
-    __fbufsize;
+    __exit; # arm x86 mips introduced=21
+    __fbufsize; # introduced=23
     __fcntl64; # arm x86 mips
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
+    __FD_CLR_chk; # introduced=21
+    __FD_ISSET_chk; # introduced=21
+    __FD_SET_chk; # introduced=21
+    __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __flbf; # introduced=23
     __fp_nquery;
     __fp_query;
-    __fpclassify;
+    __fpclassify; # introduced=21
     __fpclassifyd;
     __fpclassifyf;
     __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
+    __fpending; # introduced=23
+    __fpurge; # introduced=23
+    __freadable; # introduced=23
+    __fsetlocking; # introduced=23
     __fstatfs64; # arm x86 mips
-    __fwritable;
+    __fwritable; # introduced=23
     __get_h_errno;
-    __getcpu; # arm x86 mips
+    __getcpu; # arm x86 mips introduced-arm=12 introduced-mips=16 introduced-x86=12
     __getcwd; # arm x86 mips
-    __getpid; # arm x86 mips
+    __getpid; # arm x86 mips introduced=21
     __getpriority; # arm x86 mips
-    __gnu_basename;
-    __gnu_strerror_r;
+    __gnu_basename; # introduced=23
+    __gnu_strerror_r; # introduced=23
     __hostalias;
     __ioctl; # arm x86 mips
     __isfinite;
@@ -56,24 +55,24 @@
     __isinf;
     __isinff;
     __isinfl;
-    __isnan;
-    __isnanf;
+    __isnan; # introduced=21
+    __isnanf; # introduced=21
     __isnanl;
     __isnormal;
     __isnormalf;
     __isnormall;
-    __isthreaded; # arm x86 mips
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
+    __isthreaded; # arm x86 mips var
+    __libc_current_sigrtmax; # introduced=21
+    __libc_current_sigrtmin; # introduced=21
     __libc_init;
     __llseek; # arm x86 mips
     __loc_aton;
     __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
+    __memchr_chk; # introduced=23
+    __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memrchr_chk; # introduced=23
+    __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __mmap2; # arm x86 mips
     __ns_format_ttl; # arm x86 mips
     __ns_get16; # arm x86 mips
@@ -97,13 +96,13 @@
     __ns_skiprr; # arm x86 mips
     __ns_sprintrr; # arm x86 mips
     __ns_sprintrrf; # arm x86 mips
-    __open_2;
+    __open_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __openat; # arm x86 mips
-    __openat_2;
+    __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __p_cdname;
     __p_cdnname;
     __p_class;
-    __p_class_syms;
+    __p_class_syms; # var
     __p_fqname;
     __p_fqnname;
     __p_option;
@@ -112,25 +111,25 @@
     __p_secstodate;
     __p_time;
     __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll; # arm x86 mips
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
-    __pselect6; # arm x86 mips
+    __p_type_syms; # var
+    __poll_chk; # introduced=23
+    __ppoll; # arm x86 mips introduced=21
+    __ppoll_chk; # introduced=23
+    __pread64_chk; # introduced=23
+    __pread_chk; # introduced=23
+    __progname; # var
+    __pselect6; # arm x86 mips introduced=21
     __pthread_cleanup_pop;
     __pthread_cleanup_push;
     __ptrace; # arm x86 mips
     __putlong;
     __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
+    __read_chk; # introduced=21
+    __readlink_chk; # introduced=23
+    __readlinkat_chk; # introduced=23
     __reboot; # arm x86 mips
-    __recvfrom_chk;
-    __register_atfork;
+    __recvfrom_chk; # introduced=21
+    __register_atfork; # introduced=23
     __res_close;
     __res_dnok;
     __res_hnok;
@@ -152,89 +151,89 @@
     __res_send_setqhook;
     __res_send_setrhook;
     __rt_sigaction; # arm x86 mips
-    __rt_sigpending; # arm x86 mips
+    __rt_sigpending; # arm x86 mips introduced=21
     __rt_sigprocmask; # arm x86 mips
-    __rt_sigsuspend; # arm x86 mips
+    __rt_sigsuspend; # arm x86 mips introduced=21
     __rt_sigtimedwait; # arm x86 mips
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sched_getaffinity; # arm x86 mips
-    __set_tid_address; # arm x86 mips
+    __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_getaffinity; # arm x86 mips introduced=12
+    __set_tid_address; # arm x86 mips introduced=21
     __set_tls; # arm mips
-    __sF;
-    __sigaction; # arm x86 mips
-    __snprintf_chk;
-    __socket; # arm x86 mips
-    __sprintf_chk;
+    __sF; # var
+    __sigaction; # arm x86 mips introduced=21
+    __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __socket; # arm x86 mips introduced=21
+    __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __stack_chk_fail;
-    __stack_chk_guard;
+    __stack_chk_guard; # var
     __statfs64; # arm x86 mips
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
+    __stpcpy_chk; # introduced=21
+    __stpncpy_chk; # introduced=21
+    __stpncpy_chk2; # introduced=21
+    __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk2; # introduced=21
+    __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     __sym_ntop;
     __sym_ntos;
     __sym_ston;
     __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
+    __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area__; # var
+    __system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area_serial; # introduced=23
     __system_property_find;
     __system_property_find_nth;
-    __system_property_foreach;
+    __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __system_property_get;
     __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
+    __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __timer_create; # arm x86 mips
     __timer_delete; # arm x86 mips
     __timer_getoverrun; # arm x86 mips
     __timer_gettime; # arm x86 mips
     __timer_settime; # arm x86 mips
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
+    __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __waitid; # arm x86 mips
-    _ctype_;
-    _Exit;
+    _ctype_; # var
+    _Exit; # introduced=21
     _exit;
-    _flushlbf;
+    _flushlbf; # introduced=23
     _getlong;
     _getshort;
     _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
+    _resolv_delete_cache_for_net; # introduced=21
+    _resolv_flush_cache_for_net; # introduced=21
+    _resolv_set_nameservers_for_net; # introduced=21
     _setjmp;
-    _tolower;
-    _tolower_tab_; # arm x86 mips
-    _toupper;
-    _toupper_tab_; # arm x86 mips
+    _tolower; # introduced=21
+    _tolower_tab_; # arm x86 mips var
+    _toupper; # introduced=21
+    _toupper_tab_; # arm x86 mips var
     abort;
-    abs;
+    abs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     accept;
-    accept4;
+    accept4; # introduced=21
     access;
     acct;
     alarm;
     alphasort;
-    alphasort64;
-    android_set_abort_message;
+    alphasort64; # introduced=21
+    android_set_abort_message; # introduced=21
     arc4random;
     arc4random_buf;
     arc4random_uniform;
@@ -243,8 +242,8 @@
     asctime64_r; # arm x86 mips
     asctime_r;
     asprintf;
-    at_quick_exit;
-    atof;
+    at_quick_exit; # introduced=21
+    atof; # introduced=21
     atoi;
     atol;
     atoll;
@@ -255,44 +254,44 @@
     brk;
     bsearch;
     btowc;
-    c16rtomb;
-    c32rtomb;
+    c16rtomb; # introduced=21
+    c32rtomb; # introduced=21
     cacheflush; # arm mips
     calloc;
     capget;
     capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
+    cfgetispeed; # introduced=21
+    cfgetospeed; # introduced=21
+    cfmakeraw; # introduced=21
+    cfsetispeed; # introduced=21
+    cfsetospeed; # introduced=21
+    cfsetspeed; # introduced=21
     chdir;
     chmod;
     chown;
     chroot;
     clearenv;
     clearerr;
-    clearerr_unlocked;
+    clearerr_unlocked; # introduced=23
     clock;
-    clock_getcpuclockid;
+    clock_getcpuclockid; # introduced=23
     clock_getres;
     clock_gettime;
     clock_nanosleep;
     clock_settime;
-    clone;
+    clone; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     close;
     closedir;
     closelog;
     connect;
     creat;
-    creat64;
+    creat64; # introduced=21
     ctime;
     ctime64; # arm x86 mips
     ctime64_r; # arm x86 mips
     ctime_r;
     daemon;
-    daylight;
+    daylight; # var
     delete_module;
     difftime;
     dirfd;
@@ -300,33 +299,33 @@
     dirname_r; # arm x86 mips
     div;
     dn_expand;
-    dprintf;
+    dprintf; # introduced=21
     drand48;
     dup;
     dup2;
-    dup3;
-    duplocale;
-    endmntent;
+    dup3; # introduced=21
+    duplocale; # introduced=21
+    endmntent; # introduced=21
     endservent;
     endutent;
-    environ;
+    environ; # var
     epoll_create;
-    epoll_create1;
+    epoll_create1; # introduced=21
     epoll_ctl;
-    epoll_pwait;
+    epoll_pwait; # introduced=21
     epoll_wait;
     erand48;
     err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
+    error; # introduced=23
+    error_at_line; # introduced=23
+    error_message_count; # var introduced=23
+    error_one_per_line; # var introduced=23
+    error_print_progname; # var introduced=23
     errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
+    ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     eventfd;
     eventfd_read;
     eventfd_write;
@@ -336,11 +335,11 @@
     execv;
     execve;
     execvp;
-    execvpe;
+    execvpe; # introduced=21
     exit;
-    faccessat;
-    fallocate;
-    fallocate64;
+    faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    fallocate; # introduced=21
+    fallocate64; # introduced=21
     fchdir;
     fchmod;
     fchmodat;
@@ -352,27 +351,27 @@
     fdopen;
     fdopendir;
     feof;
-    feof_unlocked;
+    feof_unlocked; # introduced=23
     ferror;
-    ferror_unlocked;
+    ferror_unlocked; # introduced=23
     fflush;
-    ffs;
+    ffs; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     fgetc;
     fgetln;
     fgetpos;
     fgets;
     fgetwc;
     fgetws;
-    fgetxattr;
+    fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fileno;
-    flistxattr;
+    flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     flock;
     flockfile;
-    fmemopen;
+    fmemopen; # introduced=23
     fnmatch;
     fopen;
     fork;
-    forkpty;
+    forkpty; # introduced=23
     fpathconf;
     fprintf;
     fpurge;
@@ -383,56 +382,56 @@
     fread;
     free;
     freeaddrinfo;
-    freelocale;
-    fremovexattr;
+    freelocale; # introduced=21
+    fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     freopen;
     fscanf;
     fseek;
     fseeko;
     fsetpos;
-    fsetxattr;
+    fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fstat;
-    fstat64;
+    fstat64; # introduced=21
     fstatat;
-    fstatat64;
+    fstatat64; # introduced=21
     fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
+    fstatfs64; # introduced=21
+    fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    fstatvfs64; # introduced=21
     fsync;
     ftell;
     ftello;
     ftok;
     ftruncate;
-    ftruncate64;
+    ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     ftrylockfile;
     fts_children;
     fts_close;
     fts_open;
     fts_read;
     fts_set;
-    ftw;
-    ftw64;
+    ftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    ftw64; # introduced=21
     funlockfile;
     funopen;
-    futimens;
+    futimens; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     fwide;
     fwprintf;
     fwrite;
     fwscanf;
     gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
+    get_avphys_pages; # introduced=23
+    get_nprocs; # introduced=23
+    get_nprocs_conf; # introduced=23
+    get_phys_pages; # introduced=23
     getaddrinfo;
-    getauxval;
+    getauxval; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getc;
     getc_unlocked;
     getchar;
     getchar_unlocked;
     getcwd;
-    getdelim;
+    getdelim; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getegid;
     getenv;
     geteuid;
@@ -442,49 +441,49 @@
     getgrouplist;
     getgroups;
     gethostbyaddr;
-    gethostbyaddr_r;
+    gethostbyaddr_r; # introduced=23
     gethostbyname;
     gethostbyname2;
-    gethostbyname2_r;
+    gethostbyname2_r; # introduced=23
     gethostbyname_r;
     gethostent;
     gethostname;
     getitimer;
-    getline;
+    getline; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getlogin;
     getmntent;
-    getmntent_r;
+    getmntent_r; # introduced=21
     getnameinfo;
     getnetbyaddr;
     getnetbyname;
     getopt;
     getopt_long;
     getopt_long_only;
-    getpagesize;
+    getpagesize; # introduced=21
     getpeername;
     getpgid;
     getpgrp;
     getpid;
     getppid;
     getpriority;
-    getprogname;
+    getprogname; # introduced=21
     getprotobyname;
     getprotobynumber;
     getpt;
     getpwnam;
-    getpwnam_r;
+    getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getpwuid;
-    getpwuid_r;
+    getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getresgid;
     getresuid;
     getrlimit;
-    getrlimit64;
+    getrlimit64; # introduced=21
     getrusage;
     gets;
     getservbyname;
     getservbyport;
     getservent;
-    getsid;
+    getsid; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     getsockname;
     getsockopt;
     gettid;
@@ -493,26 +492,26 @@
     getutent;
     getwc;
     getwchar;
-    getxattr;
+    getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     gmtime;
     gmtime64; # arm x86 mips
     gmtime64_r; # arm x86 mips
     gmtime_r;
-    grantpt;
+    grantpt; # introduced=21
     herror;
     hstrerror;
-    htonl;
-    htons;
+    htonl; # introduced=21
+    htons; # introduced=21
     if_indextoname;
     if_nametoindex;
-    imaxabs;
-    imaxdiv;
+    imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     inet_addr;
     inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
+    inet_lnaof; # introduced=21
+    inet_makeaddr; # introduced=21
+    inet_netof; # introduced=21
+    inet_network; # introduced=21
     inet_nsap_addr;
     inet_nsap_ntoa;
     inet_ntoa;
@@ -520,124 +519,124 @@
     inet_pton;
     init_module;
     initgroups;
-    initstate;
+    initstate; # introduced=21
     inotify_add_watch;
     inotify_init;
-    inotify_init1;
+    inotify_init1; # introduced=21
     inotify_rm_watch;
-    insque;
+    insque; # introduced=21
     ioctl;
     isalnum;
-    isalnum_l;
+    isalnum_l; # introduced=21
     isalpha;
-    isalpha_l;
+    isalpha_l; # introduced=21
     isascii;
     isatty;
     isblank;
-    isblank_l;
+    isblank_l; # introduced=21
     iscntrl;
-    iscntrl_l;
+    iscntrl_l; # introduced=21
     isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
+    isdigit_l; # introduced=21
+    isfinite; # introduced=21
+    isfinitef; # introduced=21
+    isfinitel; # introduced=21
     isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
+    isgraph_l; # introduced=21
+    isinf; # introduced=21
+    isinff; # introduced=21
+    isinfl; # introduced=21
     islower;
-    islower_l;
+    islower_l; # introduced=21
     isnan;
     isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
+    isnanl; # introduced=21
+    isnormal; # introduced=21
+    isnormalf; # introduced=21
+    isnormall; # introduced=21
     isprint;
-    isprint_l;
+    isprint_l; # introduced=21
     ispunct;
-    ispunct_l;
+    ispunct_l; # introduced=21
     isspace;
-    isspace_l;
+    isspace_l; # introduced=21
     isupper;
-    isupper_l;
+    isupper_l; # introduced=21
     iswalnum;
-    iswalnum_l;
+    iswalnum_l; # introduced=21
     iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
+    iswalpha_l; # introduced=21
+    iswblank; # introduced=21
+    iswblank_l; # introduced=21
     iswcntrl;
-    iswcntrl_l;
+    iswcntrl_l; # introduced=21
     iswctype;
-    iswctype_l;
+    iswctype_l; # introduced=21
     iswdigit;
-    iswdigit_l;
+    iswdigit_l; # introduced=21
     iswgraph;
-    iswgraph_l;
+    iswgraph_l; # introduced=21
     iswlower;
-    iswlower_l;
+    iswlower_l; # introduced=21
     iswprint;
-    iswprint_l;
+    iswprint_l; # introduced=21
     iswpunct;
-    iswpunct_l;
+    iswpunct_l; # introduced=21
     iswspace;
-    iswspace_l;
+    iswspace_l; # introduced=21
     iswupper;
-    iswupper_l;
+    iswupper_l; # introduced=21
     iswxdigit;
-    iswxdigit_l;
+    iswxdigit_l; # introduced=21
     isxdigit;
-    isxdigit_l;
+    isxdigit_l; # introduced=21
     jrand48;
     kill;
     killpg;
     klogctl;
-    labs;
+    labs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lchown;
-    lcong48;
+    lcong48; # introduced=23
     ldexp;
     ldiv;
-    lfind;
-    lgetxattr;
+    lfind; # introduced=21
+    lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     link;
-    linkat;
+    linkat; # introduced=21
     listen;
-    listxattr;
-    llabs;
+    listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lldiv;
-    llistxattr;
-    localeconv;
+    llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    localeconv; # introduced=21
     localtime;
     localtime64; # arm x86 mips
     localtime64_r; # arm x86 mips
     localtime_r;
-    login_tty;
+    login_tty; # introduced=23
     longjmp;
     lrand48;
-    lremovexattr;
-    lsearch;
+    lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    lsearch; # introduced=21
     lseek;
     lseek64;
-    lsetxattr;
+    lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     lstat;
-    lstat64;
+    lstat64; # introduced=21
     madvise;
     mallinfo;
     malloc;
-    malloc_info;
-    malloc_usable_size;
+    malloc_info; # introduced=23
+    malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mbrlen;
-    mbrtoc16;
-    mbrtoc32;
+    mbrtoc16; # introduced=21
+    mbrtoc32; # introduced=21
     mbrtowc;
     mbsinit;
-    mbsnrtowcs;
+    mbsnrtowcs; # introduced=21
     mbsrtowcs;
     mbstowcs;
-    mbtowc;
+    mbtowc; # introduced=21
     memalign;
     memccpy;
     memchr;
@@ -645,91 +644,91 @@
     memcpy;
     memmem;
     memmove;
-    mempcpy;
+    mempcpy; # introduced=23
     memrchr;
     memset;
     mincore;
     mkdir;
     mkdirat;
     mkdtemp;
-    mkfifo;
-    mkfifoat;
+    mkfifo; # introduced=21
+    mkfifoat; # introduced=23
     mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
+    mknodat; # introduced=21
+    mkostemp; # introduced=23
+    mkostemp64; # introduced=23
+    mkostemps; # introduced=23
+    mkostemps64; # introduced=23
     mkstemp;
-    mkstemp64;
+    mkstemp64; # introduced=21
     mkstemps;
-    mkstemps64;
+    mkstemps64; # introduced=23
     mktemp;
     mktime;
     mktime64; # arm x86 mips
     mlock;
-    mlockall;
+    mlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mmap;
-    mmap64;
+    mmap64; # introduced=21
     mount;
     mprotect;
     mrand48;
     mremap;
     msync;
     munlock;
-    munlockall;
+    munlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     munmap;
     nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
+    newlocale; # introduced=21
+    nftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    nftw64; # introduced=21
     nice;
     nrand48;
     nsdispatch;
-    ntohl;
-    ntohs;
+    ntohl; # introduced=21
+    ntohs; # introduced=21
     open;
-    open64;
-    open_memstream;
-    open_wmemstream;
+    open64; # introduced=21
+    open_memstream; # introduced=23
+    open_wmemstream; # introduced=23
     openat;
-    openat64;
+    openat64; # introduced=21
     opendir;
     openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
+    openpty; # introduced=23
+    optarg; # var
+    opterr; # var
+    optind; # var
+    optopt; # var
+    optreset; # var
     pathconf;
     pause;
     pclose;
     perror;
-    personality;
+    personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
     pipe;
     pipe2;
     poll;
     popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
+    posix_fadvise; # introduced=21
+    posix_fadvise64; # introduced=21
+    posix_fallocate; # introduced=21
+    posix_fallocate64; # introduced=21
+    posix_madvise; # introduced=23
+    posix_memalign; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    posix_openpt; # introduced=21
+    ppoll; # introduced=21
     prctl;
     pread;
-    pread64;
+    pread64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     printf;
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
+    prlimit64; # introduced=21
+    process_vm_readv; # introduced=23
+    process_vm_writev; # introduced=23
     pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
+    psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    psignal; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     pthread_attr_destroy;
     pthread_attr_getdetachstate;
     pthread_attr_getguardsize;
@@ -757,10 +756,10 @@
     pthread_cond_timeout_np; # arm x86 mips
     pthread_cond_wait;
     pthread_condattr_destroy;
-    pthread_condattr_getclock;
+    pthread_condattr_getclock; # introduced=21
     pthread_condattr_getpshared;
     pthread_condattr_init;
-    pthread_condattr_setclock;
+    pthread_condattr_setclock; # introduced=21
     pthread_condattr_setpshared;
     pthread_create;
     pthread_detach;
@@ -770,7 +769,7 @@
     pthread_getcpuclockid;
     pthread_getschedparam;
     pthread_getspecific;
-    pthread_gettid_np;
+    pthread_gettid_np; # introduced=21
     pthread_join;
     pthread_key_create;
     pthread_key_delete;
@@ -779,7 +778,7 @@
     pthread_mutex_init;
     pthread_mutex_lock;
     pthread_mutex_lock_timeout_np; # arm x86 mips
-    pthread_mutex_timedlock;
+    pthread_mutex_timedlock; # introduced=21
     pthread_mutex_trylock;
     pthread_mutex_unlock;
     pthread_mutexattr_destroy;
@@ -799,10 +798,10 @@
     pthread_rwlock_unlock;
     pthread_rwlock_wrlock;
     pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getkind_np; # introduced=23
     pthread_rwlockattr_getpshared;
     pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setkind_np; # introduced=23
     pthread_rwlockattr_setpshared;
     pthread_self;
     pthread_setname_np;
@@ -822,38 +821,38 @@
     putw; # arm x86 mips
     putwc;
     putwchar;
-    pvalloc; # arm x86 mips
+    pvalloc; # arm x86 mips introduced=17
     pwrite;
-    pwrite64;
+    pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     qsort;
-    quick_exit;
+    quick_exit; # introduced=21
     raise;
-    rand;
-    rand_r;
-    random;
+    rand; # introduced=21
+    rand_r; # introduced=21
+    random; # introduced=21
     read;
-    readahead;
+    readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     readdir;
-    readdir64;
-    readdir64_r;
+    readdir64; # introduced=21
+    readdir64_r; # introduced=21
     readdir_r;
     readlink;
-    readlinkat;
+    readlinkat; # introduced=21
     readv;
     realloc;
     realpath;
     reboot;
     recv;
     recvfrom;
-    recvmmsg;
+    recvmmsg; # introduced=21
     recvmsg;
     regcomp;
     regerror;
     regexec;
     regfree;
     remove;
-    removexattr;
-    remque;
+    removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    remque; # introduced=21
     rename;
     renameat;
     res_init;
@@ -865,21 +864,21 @@
     rmdir;
     sbrk;
     scandir;
-    scandir64;
+    scandir64; # introduced=21
     scanf;
     sched_get_priority_max;
     sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
+    sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_getparam;
     sched_getscheduler;
     sched_rr_get_interval;
-    sched_setaffinity;
+    sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_setparam;
     sched_setscheduler;
     sched_yield;
     seed48;
-    seekdir;
+    seekdir; # introduced=23
     select;
     sem_close;
     sem_destroy;
@@ -893,8 +892,8 @@
     sem_wait;
     send;
     sendfile;
-    sendfile64;
-    sendmmsg;
+    sendfile64; # introduced=21
+    sendmmsg; # introduced=21
     sendmsg;
     sendto;
     setbuf;
@@ -902,101 +901,101 @@
     setegid;
     setenv;
     seteuid;
-    setfsgid;
-    setfsuid;
+    setfsgid; # introduced=21
+    setfsuid; # introduced=21
     setgid;
     setgroups;
-    sethostname;
+    sethostname; # introduced=23
     setitimer;
     setjmp;
     setlinebuf;
     setlocale;
     setlogmask;
-    setmntent;
-    setns;
+    setmntent; # introduced=21
+    setns; # introduced=21
     setpgid;
     setpgrp;
     setpriority;
-    setprogname;
+    setprogname; # introduced=21
     setregid;
     setresgid;
     setresuid;
     setreuid;
     setrlimit;
-    setrlimit64;
+    setrlimit64; # introduced=21
     setservent;
     setsid;
     setsockopt;
-    setstate;
+    setstate; # introduced=21
     settimeofday;
     setuid;
     setutent;
     setvbuf;
-    setxattr;
+    setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     shutdown;
     sigaction;
-    sigaddset;
+    sigaddset; # introduced=21
     sigaltstack;
     sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
+    sigdelset; # introduced=21
+    sigemptyset; # introduced=21
+    sigfillset; # introduced=21
     siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
+    sigismember; # introduced=21
+    siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    signal; # introduced=21
+    signalfd; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     sigpending;
     sigprocmask;
-    sigqueue;
-    sigsetjmp;
+    sigqueue; # introduced=23
+    sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sigsetmask;
     sigsuspend;
-    sigtimedwait;
+    sigtimedwait; # introduced=23
     sigwait;
-    sigwaitinfo;
+    sigwaitinfo; # introduced=23
     sleep;
     snprintf;
     socket;
     socketpair;
-    splice;
+    splice; # introduced=21
     sprintf;
-    srand;
+    srand; # introduced=21
     srand48;
-    srandom;
+    srandom; # introduced=21
     sscanf;
     stat;
-    stat64;
+    stat64; # introduced=21
     statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
+    statfs64; # introduced=21
+    statvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    statvfs64; # introduced=21
+    stderr; # var introduced=23
+    stdin; # var introduced=23
+    stdout; # var introduced=23
+    stpcpy; # introduced=21
+    stpncpy; # introduced=21
     strcasecmp;
-    strcasecmp_l;
+    strcasecmp_l; # introduced=23
     strcasestr;
     strcat;
     strchr;
     strcmp;
     strcoll;
-    strcoll_l;
+    strcoll_l; # introduced=21
     strcpy;
     strcspn;
     strdup;
     strerror;
-    strerror_l;
+    strerror_l; # introduced=23
     strerror_r;
     strftime;
-    strftime_l;
+    strftime_l; # introduced=21
     strlcat;
     strlcpy;
     strlen;
     strncasecmp;
-    strncasecmp_l;
+    strncasecmp_l; # introduced=23
     strncat;
     strncmp;
     strncpy;
@@ -1010,86 +1009,86 @@
     strspn;
     strstr;
     strtod;
-    strtof;
+    strtof; # introduced=21
     strtoimax;
     strtok;
     strtok_r;
     strtol;
-    strtold;
-    strtold_l;
+    strtold; # introduced=21
+    strtold_l; # introduced=21
     strtoll;
-    strtoll_l;
-    strtoq;
+    strtoll_l; # introduced=21
+    strtoq; # introduced=21
     strtoul;
     strtoull;
-    strtoull_l;
+    strtoull_l; # introduced=21
     strtoumax;
-    strtouq;
+    strtouq; # introduced=21
     strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
+    strxfrm_l; # introduced=21
+    swapoff; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    swapon; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     swprintf;
     swscanf;
     symlink;
-    symlinkat;
+    symlinkat; # introduced=21
     sync;
-    sys_siglist;
-    sys_signame;
+    sys_siglist; # var
+    sys_signame; # var
     syscall;
     sysconf;
     sysinfo;
     syslog;
     system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
+    tcdrain; # introduced=21
+    tcflow; # introduced=21
+    tcflush; # introduced=21
+    tcgetattr; # introduced=21
     tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
+    tcgetsid; # introduced=21
+    tcsendbreak; # introduced=21
+    tcsetattr; # introduced=21
     tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
+    tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tee; # introduced=21
+    telldir; # introduced=23
     tempnam;
-    tfind;
-    tgkill;
+    tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     time;
-    timegm;
+    timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timegm64; # arm x86 mips
-    timelocal;
+    timelocal; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timelocal64; # arm x86 mips
     timer_create;
     timer_delete;
     timer_getoverrun;
     timer_gettime;
     timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
+    timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     times;
-    timezone;
+    timezone; # var
     tmpfile;
     tmpnam;
     toascii;
     tolower;
-    tolower_l;
+    tolower_l; # introduced=21
     toupper;
-    toupper_l;
+    toupper_l; # introduced=21
     towlower;
-    towlower_l;
+    towlower_l; # introduced=21
     towupper;
-    towupper_l;
+    towupper_l; # introduced=21
     truncate;
-    truncate64;
-    tsearch;
+    truncate64; # introduced=21
+    tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     ttyname;
     ttyname_r;
-    twalk;
-    tzname;
+    twalk; # introduced=21
+    tzname; # var
     tzset;
     umask;
     umount;
@@ -1101,38 +1100,38 @@
     unlinkat;
     unlockpt;
     unsetenv;
-    unshare;
-    uselocale;
+    unshare; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    uselocale; # introduced=21
     usleep;
     utime;
-    utimensat;
+    utimensat; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     utimes;
     utmpname;
     valloc; # arm x86 mips
     vasprintf;
-    vdprintf;
+    vdprintf; # introduced=21
     verr;
     verrx;
     vfork;
     vfprintf;
     vfscanf;
     vfwprintf;
-    vfwscanf;
-    vmsplice;
+    vfwscanf; # introduced=21
+    vmsplice; # introduced=21
     vprintf;
     vscanf;
     vsnprintf;
     vsprintf;
     vsscanf;
     vswprintf;
-    vswscanf;
+    vswscanf; # introduced=21
     vsyslog;
     vwarn;
     vwarnx;
     vwprintf;
-    vwscanf;
+    vwscanf; # introduced=21
     wait;
-    wait4;
+    wait4; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     waitid;
     waitpid;
     warn;
@@ -1141,12 +1140,12 @@
     wcpncpy;
     wcrtomb;
     wcscasecmp;
-    wcscasecmp_l;
+    wcscasecmp_l; # introduced=23
     wcscat;
     wcschr;
     wcscmp;
     wcscoll;
-    wcscoll_l;
+    wcscoll_l; # introduced=21
     wcscpy;
     wcscspn;
     wcsdup;
@@ -1155,44 +1154,44 @@
     wcslcpy;
     wcslen;
     wcsncasecmp;
-    wcsncasecmp_l;
+    wcsncasecmp_l; # introduced=23
     wcsncat;
     wcsncmp;
     wcsncpy;
     wcsnlen;
-    wcsnrtombs;
+    wcsnrtombs; # introduced=21
     wcspbrk;
     wcsrchr;
     wcsrtombs;
     wcsspn;
     wcsstr;
     wcstod;
-    wcstof;
-    wcstoimax;
+    wcstof; # introduced=21
+    wcstoimax; # introduced=21
     wcstok;
     wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
+    wcstold; # introduced=21
+    wcstold_l; # introduced=21
+    wcstoll; # introduced=21
+    wcstoll_l; # introduced=21
     wcstombs;
     wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
+    wcstoull; # introduced=21
+    wcstoull_l; # introduced=21
+    wcstoumax; # introduced=21
     wcswidth;
     wcsxfrm;
-    wcsxfrm_l;
+    wcsxfrm_l; # introduced=21
     wctob;
-    wctomb;
+    wctomb; # introduced=21
     wctype;
-    wctype_l;
+    wctype_l; # introduced=21
     wcwidth;
     wmemchr;
     wmemcmp;
     wmemcpy;
     wmemmove;
-    wmempcpy;
+    wmempcpy; # introduced=23
     wmemset;
     wprintf;
     write;
@@ -1202,71 +1201,122 @@
     *;
 };
 
-LIBC_N {
+LIBC_N { # introduced-arm64=24 introduced-mips=24 introduced-mips64=24 introduced-x86=24 introduced-x86_64=24
   global:
-    __aeabi_atexit; # arm
-    __aeabi_memclr; # arm
-    __aeabi_memclr4; # arm
-    __aeabi_memclr8; # arm
-    __aeabi_memcpy; # arm
-    __aeabi_memcpy4; # arm
-    __aeabi_memcpy8; # arm
-    __aeabi_memmove; # arm
-    __aeabi_memmove4; # arm
-    __aeabi_memmove8; # arm
-    __aeabi_memset; # arm
-    __aeabi_memset4; # arm
-    __aeabi_memset8; # arm
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __gnu_Unwind_Find_exidx; # arm
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    prlimit; # arm mips x86
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
+    __aeabi_atexit; # arm versioned=24
+    __aeabi_memclr; # arm versioned=24
+    __aeabi_memclr4; # arm versioned=24
+    __aeabi_memclr8; # arm versioned=24
+    __aeabi_memcpy; # arm versioned=24
+    __aeabi_memcpy4; # arm versioned=24
+    __aeabi_memcpy8; # arm versioned=24
+    __aeabi_memmove; # arm versioned=24
+    __aeabi_memmove4; # arm versioned=24
+    __aeabi_memmove8; # arm versioned=24
+    __aeabi_memset; # arm versioned=24
+    __aeabi_memset4; # arm versioned=24
+    __aeabi_memset8; # arm versioned=24
+    __fread_chk; # introduced=24
+    __fwrite_chk; # introduced=24
+    __getcwd_chk; # introduced=24
+    __gnu_Unwind_Find_exidx; # arm versioned=24
+    __pwrite_chk; # introduced=24
+    __pwrite64_chk; # introduced=24
+    __write_chk; # introduced=24
+    adjtimex; # introduced=24
+    clock_adjtime; # introduced=24
+    fgetpos64; # introduced=24
+    fileno_unlocked; # introduced=24
+    fopen64; # introduced=24
+    freeifaddrs; # introduced=24
+    freopen64; # introduced=24
+    fseeko64; # introduced=24
+    fsetpos64; # introduced=24
+    ftello64; # introduced=24
+    funopen64; # introduced=24
+    getgrgid_r; # introduced=24
+    getgrnam_r; # introduced=24
+    getifaddrs; # introduced=24
+    if_freenameindex; # introduced=24
+    if_nameindex; # introduced=24
+    in6addr_any; # var introduced=24
+    in6addr_loopback; # var introduced=24
+    lockf; # introduced=24
+    lockf64; # introduced=24
+    preadv; # introduced=24
+    preadv64; # introduced=24
+    prlimit; # arm mips x86 introduced=24
+    pthread_barrierattr_destroy; # introduced=24
+    pthread_barrierattr_getpshared; # introduced=24
+    pthread_barrierattr_init; # introduced=24
+    pthread_barrierattr_setpshared; # introduced=24
+    pthread_barrier_destroy; # introduced=24
+    pthread_barrier_init; # introduced=24
+    pthread_barrier_wait; # introduced=24
+    pthread_spin_destroy; # introduced=24
+    pthread_spin_init; # introduced=24
+    pthread_spin_lock; # introduced=24
+    pthread_spin_trylock; # introduced=24
+    pthread_spin_unlock; # introduced=24
+    pwritev; # introduced=24
+    pwritev64; # introduced=24
+    scandirat; # introduced=24
+    scandirat64; # introduced=24
+    strchrnul; # introduced=24
+    tmpfile64; # introduced=24
 } LIBC;
 
+LIBC_O {
+  global:
+    bsd_signal; # arm x86 mips versioned=26
+    catclose; # future
+    catgets; # future
+    catopen; # future
+    ctermid; # future
+    endgrent; # future
+    endpwent; # future
+    futimes; # future
+    futimesat; # future
+    getdomainname; # future
+    getgrent; # future
+    getpwent; # future
+    getsubopt; # future
+    hasmntopt; # future
+    lutimes; # future
+    mblen; # future
+    msgctl; # future
+    msgget; # future
+    msgrcv; # future
+    msgsnd; # future
+    pthread_getname_np; # future
+    quotactl; # future
+    semctl; # future
+    semget; # future
+    semop; # future
+    semtimedop; # future
+    setdomainname; # future
+    setgrent; # future
+    setpwent; # future
+    shmat; # future
+    shmctl; # future
+    shmdt; # future
+    shmget; # future
+    sighold; # future
+    sigignore; # future
+    sigpause; # future
+    sigrelse; # future
+    sigset; # future
+    strtod_l; # future
+    strtof_l; # future
+    strtol_l; # future
+    strtoul_l; # future
+    sync_file_range; # future
+    towctrans; # future
+    towctrans_l; # future
+    wctrans; # future
+    wctrans_l; # future
+} LIBC_N;
+
 LIBC_PRIVATE {
   global:
     ___Unwind_Backtrace; # arm
@@ -1362,11 +1412,11 @@
     __floatundisf; # arm
     __floatunsidf; # arm
     __floatunsisf; # arm
-    __futex_wait; # arm x86 mips nobrillo
-    __futex_wake; # arm x86 mips nobrillo
+    __futex_wait; # arm x86 mips
+    __futex_wake; # arm x86 mips
     __gedf2; # arm
-    __get_thread; # arm x86 mips nobrillo
-    __get_tls; # arm x86 mips nobrillo
+    __get_thread; # arm x86 mips
+    __get_tls; # arm x86 mips
     __getdents64; # arm x86 mips
     __gnu_ldivmod_helper; # arm
     __gnu_uldivmod_helper; # arm
@@ -1396,21 +1446,21 @@
     __muldi3; # arm
     __mulsf3; # arm
     __nedf2; # arm
-    __open; # arm x86 mips nobrillo
-    __page_shift; # arm x86 mips nobrillo
-    __page_size; # arm x86 mips nobrillo
+    __open; # arm x86 mips
+    __page_shift; # arm x86 mips
+    __page_size; # arm x86 mips
     __popcount_tab; # arm
     __popcountsi2; # arm x86 mips
-    __pthread_gettid; # arm x86 mips nobrillo
+    __pthread_gettid; # arm x86 mips
     __restore_core_regs; # arm
     __sclose; # arm x86 mips
-    __sdidinit; # arm x86 mips nobrillo
-    __set_errno; # arm x86 mips nobrillo
+    __sdidinit; # arm x86 mips
+    __set_errno; # arm x86 mips
     __sflags; # arm x86 mips
     __sflush; # arm x86 mips
     __sfp; # arm x86 mips
     __sglue; # arm x86 mips
-    __sinit; # arm x86 mips nobrillo
+    __sinit; # arm x86 mips
     __smakebuf; # arm x86 mips
     __sread; # arm x86 mips
     __srefill; # arm x86 mips
@@ -1426,7 +1476,7 @@
     __udivsi3; # arm
     __unorddf2; # arm
     __unordsf2; # arm
-    __wait4; # arm x86 mips nobrillo
+    __wait4; # arm x86 mips
     _fwalk; # arm x86 mips
     _Unwind_Backtrace; # arm
     _Unwind_Complete; # arm
@@ -1447,43 +1497,41 @@
     android_getaddrinfofornetcontext;
     android_gethostbyaddrfornet;
     android_gethostbynamefornet;
-    arc4random_addrandom; # arm x86 mips nobrillo
-    arc4random_stir; # arm x86 mips nobrillo
+    arc4random_addrandom; # arm x86 mips
+    arc4random_stir; # arm x86 mips
     atexit; # arm
-    bcopy; # arm x86 mips nobrillo
-    bzero; # arm x86 mips nobrillo
-    bsd_signal; # arm x86 mips nobrillo
-    dlmalloc; # arm x86 mips nobrillo
-    dlmalloc_inspect_all; # arm x86 mips nobrillo
-    dlmalloc_trim; # arm x86 mips nobrillo
-    dlmalloc_usable_size; # arm x86 mips nobrillo
-    endpwent; # arm x86 mips nobrillo
-    fdprintf; # arm x86 mips nobrillo
+    bcopy; # arm x86 mips
+    bzero; # arm x86 mips
+    dlmalloc; # arm x86 mips
+    dlmalloc_inspect_all; # arm x86 mips
+    dlmalloc_trim; # arm x86 mips
+    dlmalloc_usable_size; # arm x86 mips
+    fdprintf; # arm x86 mips
     free_malloc_leak_info;
-    ftime; # arm x86 mips nobrillo
+    ftime; # arm x86 mips
     get_malloc_leak_info;
-    getdents; # arm x86 mips nobrillo
-    getdtablesize; # arm x86 mips nobrillo
+    getdents; # arm x86 mips
+    getdtablesize; # arm x86 mips
     gMallocLeakZygoteChild;
-    index; # arm x86 mips nobrillo
-    issetugid; # arm x86 mips nobrillo
-    memswap; # arm x86 mips nobrillo
-    pthread_attr_getstackaddr; # arm x86 mips nobrillo
-    pthread_attr_setstackaddr; # arm x86 mips nobrillo
+    index; # arm x86 mips
+    issetugid; # arm x86 mips
+    memswap; # arm x86 mips
+    pthread_attr_getstackaddr; # arm x86 mips
+    pthread_attr_setstackaddr; # arm x86 mips
     restore_core_regs; # arm
     SHA1Final; # arm x86 mips
     SHA1Init; # arm x86 mips
     SHA1Transform; # arm x86 mips
     SHA1Update; # arm x86 mips
-    strntoimax; # arm x86 mips nobrillo
-    strntoumax; # arm x86 mips nobrillo
-    strtotimeval; # arm x86 mips nobrillo
-    sysv_signal; # arm x86 mips nobrillo
-    tkill; # arm x86 mips nobrillo
-    vfdprintf; # arm x86 mips nobrillo
-    wait3; # arm x86 mips nobrillo
-    wcswcs; # arm x86 mips nobrillo
-} LIBC_N;
+    strntoimax; # arm x86 mips
+    strntoumax; # arm x86 mips
+    strtotimeval; # arm x86 mips
+    sysv_signal; # arm x86 mips
+    tkill; # arm x86 mips
+    vfdprintf; # arm x86 mips
+    wait3; # arm x86 mips
+    wcswcs; # arm x86 mips
+} LIBC_O;
 
 LIBC_PLATFORM {
   global:
@@ -1494,4 +1542,4 @@
     malloc_disable;
     malloc_enable;
     malloc_iterate;
-} LIBC_N;
+} LIBC_O;
diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map
index afbd0ee..28755d4 100644
--- a/libc/libc.arm64.map
+++ b/libc/libc.arm64.map
@@ -1,39 +1,39 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
     __assert;
     __assert2;
     __b64_ntop;
     __b64_pton;
-    __cmsg_nxthdr;
-    __ctype_get_mb_cur_max;
+    __cmsg_nxthdr; # introduced=21
+    __ctype_get_mb_cur_max; # introduced=21
     __cxa_atexit;
     __cxa_finalize;
-    __cxa_thread_atexit_impl;
+    __cxa_thread_atexit_impl; # introduced=23
     __dn_comp;
     __dn_count_labels;
     __dn_skipname;
     __errno;
-    __fbufsize;
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
+    __fbufsize; # introduced=23
+    __FD_CLR_chk; # introduced=21
+    __FD_ISSET_chk; # introduced=21
+    __FD_SET_chk; # introduced=21
+    __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __flbf; # introduced=23
     __fp_nquery;
     __fp_query;
-    __fpclassify;
+    __fpclassify; # introduced=21
     __fpclassifyd;
     __fpclassifyf;
     __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
-    __fwritable;
+    __fpending; # introduced=23
+    __fpurge; # introduced=23
+    __freadable; # introduced=23
+    __fsetlocking; # introduced=23
+    __fwritable; # introduced=23
     __get_h_errno;
-    __gnu_basename;
-    __gnu_strerror_r;
+    __gnu_basename; # introduced=23
+    __gnu_strerror_r; # introduced=23
     __hostalias;
     __isfinite;
     __isfinitef;
@@ -41,28 +41,28 @@
     __isinf;
     __isinff;
     __isinfl;
-    __isnan;
-    __isnanf;
+    __isnan; # introduced=21
+    __isnanf; # introduced=21
     __isnanl;
     __isnormal;
     __isnormalf;
     __isnormall;
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
+    __libc_current_sigrtmax; # introduced=21
+    __libc_current_sigrtmin; # introduced=21
     __libc_init;
     __loc_aton;
     __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
-    __open_2;
-    __openat_2;
+    __memchr_chk; # introduced=23
+    __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memrchr_chk; # introduced=23
+    __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __open_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __p_cdname;
     __p_cdnname;
     __p_class;
-    __p_class_syms;
+    __p_class_syms; # var
     __p_fqname;
     __p_fqnname;
     __p_option;
@@ -71,21 +71,21 @@
     __p_secstodate;
     __p_time;
     __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
+    __p_type_syms; # var
+    __poll_chk; # introduced=23
+    __ppoll_chk; # introduced=23
+    __pread64_chk; # introduced=23
+    __pread_chk; # introduced=23
+    __progname; # var
     __pthread_cleanup_pop;
     __pthread_cleanup_push;
     __putlong;
     __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
-    __recvfrom_chk;
-    __register_atfork;
+    __read_chk; # introduced=21
+    __readlink_chk; # introduced=23
+    __readlinkat_chk; # introduced=23
+    __recvfrom_chk; # introduced=21
+    __register_atfork; # introduced=23
     __res_close;
     __res_dnok;
     __res_hnok;
@@ -106,79 +106,79 @@
     __res_send;
     __res_send_setqhook;
     __res_send_setrhook;
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sF;
-    __snprintf_chk;
-    __sprintf_chk;
+    __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sF; # var
+    __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __stack_chk_fail;
-    __stack_chk_guard;
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
+    __stack_chk_guard; # var
+    __stpcpy_chk; # introduced=21
+    __stpncpy_chk; # introduced=21
+    __stpncpy_chk2; # introduced=21
+    __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk2; # introduced=21
+    __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     __sym_ntop;
     __sym_ntos;
     __sym_ston;
     __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
+    __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area__; # var
+    __system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area_serial; # introduced=23
     __system_property_find;
     __system_property_find_nth;
-    __system_property_foreach;
+    __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __system_property_get;
     __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
-    _ctype_;
-    _Exit;
+    __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    _ctype_; # var
+    _Exit; # introduced=21
     _exit;
-    _flushlbf;
+    _flushlbf; # introduced=23
     _getlong;
     _getshort;
     _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
+    _resolv_delete_cache_for_net; # introduced=21
+    _resolv_flush_cache_for_net; # introduced=21
+    _resolv_set_nameservers_for_net; # introduced=21
     _setjmp;
-    _tolower;
-    _toupper;
+    _tolower; # introduced=21
+    _toupper; # introduced=21
     abort;
-    abs;
+    abs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     accept;
-    accept4;
+    accept4; # introduced=21
     access;
     acct;
     alarm;
     alphasort;
-    alphasort64;
-    android_set_abort_message;
+    alphasort64; # introduced=21
+    android_set_abort_message; # introduced=21
     arc4random;
     arc4random_buf;
     arc4random_uniform;
     asctime;
     asctime_r;
     asprintf;
-    at_quick_exit;
-    atof;
+    at_quick_exit; # introduced=21
+    atof; # introduced=21
     atoi;
     atol;
     atoll;
@@ -188,74 +188,74 @@
     brk;
     bsearch;
     btowc;
-    c16rtomb;
-    c32rtomb;
+    c16rtomb; # introduced=21
+    c32rtomb; # introduced=21
     calloc;
     capget;
     capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
+    cfgetispeed; # introduced=21
+    cfgetospeed; # introduced=21
+    cfmakeraw; # introduced=21
+    cfsetispeed; # introduced=21
+    cfsetospeed; # introduced=21
+    cfsetspeed; # introduced=21
     chdir;
     chmod;
     chown;
     chroot;
     clearenv;
     clearerr;
-    clearerr_unlocked;
+    clearerr_unlocked; # introduced=23
     clock;
-    clock_getcpuclockid;
+    clock_getcpuclockid; # introduced=23
     clock_getres;
     clock_gettime;
     clock_nanosleep;
     clock_settime;
-    clone;
+    clone; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     close;
     closedir;
     closelog;
     connect;
     creat;
-    creat64;
+    creat64; # introduced=21
     ctime;
     ctime_r;
     daemon;
-    daylight;
+    daylight; # var
     delete_module;
     difftime;
     dirfd;
     dirname;
     div;
     dn_expand;
-    dprintf;
+    dprintf; # introduced=21
     drand48;
     dup;
     dup2;
-    dup3;
-    duplocale;
-    endmntent;
+    dup3; # introduced=21
+    duplocale; # introduced=21
+    endmntent; # introduced=21
     endservent;
     endutent;
-    environ;
+    environ; # var
     epoll_create;
-    epoll_create1;
+    epoll_create1; # introduced=21
     epoll_ctl;
-    epoll_pwait;
+    epoll_pwait; # introduced=21
     epoll_wait;
     erand48;
     err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
+    error; # introduced=23
+    error_at_line; # introduced=23
+    error_message_count; # var introduced=23
+    error_one_per_line; # var introduced=23
+    error_print_progname; # var introduced=23
     errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
+    ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     eventfd;
     eventfd_read;
     eventfd_write;
@@ -265,11 +265,11 @@
     execv;
     execve;
     execvp;
-    execvpe;
+    execvpe; # introduced=21
     exit;
-    faccessat;
-    fallocate;
-    fallocate64;
+    faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    fallocate; # introduced=21
+    fallocate64; # introduced=21
     fchdir;
     fchmod;
     fchmodat;
@@ -281,27 +281,27 @@
     fdopen;
     fdopendir;
     feof;
-    feof_unlocked;
+    feof_unlocked; # introduced=23
     ferror;
-    ferror_unlocked;
+    ferror_unlocked; # introduced=23
     fflush;
-    ffs;
+    ffs; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     fgetc;
     fgetln;
     fgetpos;
     fgets;
     fgetwc;
     fgetws;
-    fgetxattr;
+    fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fileno;
-    flistxattr;
+    flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     flock;
     flockfile;
-    fmemopen;
+    fmemopen; # introduced=23
     fnmatch;
     fopen;
     fork;
-    forkpty;
+    forkpty; # introduced=23
     fpathconf;
     fprintf;
     fpurge;
@@ -312,56 +312,56 @@
     fread;
     free;
     freeaddrinfo;
-    freelocale;
-    fremovexattr;
+    freelocale; # introduced=21
+    fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     freopen;
     fscanf;
     fseek;
     fseeko;
     fsetpos;
-    fsetxattr;
+    fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fstat;
-    fstat64;
+    fstat64; # introduced=21
     fstatat;
-    fstatat64;
+    fstatat64; # introduced=21
     fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
+    fstatfs64; # introduced=21
+    fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    fstatvfs64; # introduced=21
     fsync;
     ftell;
     ftello;
     ftok;
     ftruncate;
-    ftruncate64;
+    ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     ftrylockfile;
     fts_children;
     fts_close;
     fts_open;
     fts_read;
     fts_set;
-    ftw;
-    ftw64;
+    ftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    ftw64; # introduced=21
     funlockfile;
     funopen;
-    futimens;
+    futimens; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     fwide;
     fwprintf;
     fwrite;
     fwscanf;
     gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
+    get_avphys_pages; # introduced=23
+    get_nprocs; # introduced=23
+    get_nprocs_conf; # introduced=23
+    get_phys_pages; # introduced=23
     getaddrinfo;
-    getauxval;
+    getauxval; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getc;
     getc_unlocked;
     getchar;
     getchar_unlocked;
     getcwd;
-    getdelim;
+    getdelim; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getegid;
     getenv;
     geteuid;
@@ -371,49 +371,49 @@
     getgrouplist;
     getgroups;
     gethostbyaddr;
-    gethostbyaddr_r;
+    gethostbyaddr_r; # introduced=23
     gethostbyname;
     gethostbyname2;
-    gethostbyname2_r;
+    gethostbyname2_r; # introduced=23
     gethostbyname_r;
     gethostent;
     gethostname;
     getitimer;
-    getline;
+    getline; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getlogin;
     getmntent;
-    getmntent_r;
+    getmntent_r; # introduced=21
     getnameinfo;
     getnetbyaddr;
     getnetbyname;
     getopt;
     getopt_long;
     getopt_long_only;
-    getpagesize;
+    getpagesize; # introduced=21
     getpeername;
     getpgid;
     getpgrp;
     getpid;
     getppid;
     getpriority;
-    getprogname;
+    getprogname; # introduced=21
     getprotobyname;
     getprotobynumber;
     getpt;
     getpwnam;
-    getpwnam_r;
+    getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getpwuid;
-    getpwuid_r;
+    getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getresgid;
     getresuid;
     getrlimit;
-    getrlimit64;
+    getrlimit64; # introduced=21
     getrusage;
     gets;
     getservbyname;
     getservbyport;
     getservent;
-    getsid;
+    getsid; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     getsockname;
     getsockopt;
     gettid;
@@ -422,24 +422,24 @@
     getutent;
     getwc;
     getwchar;
-    getxattr;
+    getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     gmtime;
     gmtime_r;
-    grantpt;
+    grantpt; # introduced=21
     herror;
     hstrerror;
-    htonl;
-    htons;
+    htonl; # introduced=21
+    htons; # introduced=21
     if_indextoname;
     if_nametoindex;
-    imaxabs;
-    imaxdiv;
+    imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     inet_addr;
     inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
+    inet_lnaof; # introduced=21
+    inet_makeaddr; # introduced=21
+    inet_netof; # introduced=21
+    inet_network; # introduced=21
     inet_nsap_addr;
     inet_nsap_ntoa;
     inet_ntoa;
@@ -447,122 +447,122 @@
     inet_pton;
     init_module;
     initgroups;
-    initstate;
+    initstate; # introduced=21
     inotify_add_watch;
     inotify_init;
-    inotify_init1;
+    inotify_init1; # introduced=21
     inotify_rm_watch;
-    insque;
+    insque; # introduced=21
     ioctl;
     isalnum;
-    isalnum_l;
+    isalnum_l; # introduced=21
     isalpha;
-    isalpha_l;
+    isalpha_l; # introduced=21
     isascii;
     isatty;
     isblank;
-    isblank_l;
+    isblank_l; # introduced=21
     iscntrl;
-    iscntrl_l;
+    iscntrl_l; # introduced=21
     isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
+    isdigit_l; # introduced=21
+    isfinite; # introduced=21
+    isfinitef; # introduced=21
+    isfinitel; # introduced=21
     isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
+    isgraph_l; # introduced=21
+    isinf; # introduced=21
+    isinff; # introduced=21
+    isinfl; # introduced=21
     islower;
-    islower_l;
+    islower_l; # introduced=21
     isnan;
     isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
+    isnanl; # introduced=21
+    isnormal; # introduced=21
+    isnormalf; # introduced=21
+    isnormall; # introduced=21
     isprint;
-    isprint_l;
+    isprint_l; # introduced=21
     ispunct;
-    ispunct_l;
+    ispunct_l; # introduced=21
     isspace;
-    isspace_l;
+    isspace_l; # introduced=21
     isupper;
-    isupper_l;
+    isupper_l; # introduced=21
     iswalnum;
-    iswalnum_l;
+    iswalnum_l; # introduced=21
     iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
+    iswalpha_l; # introduced=21
+    iswblank; # introduced=21
+    iswblank_l; # introduced=21
     iswcntrl;
-    iswcntrl_l;
+    iswcntrl_l; # introduced=21
     iswctype;
-    iswctype_l;
+    iswctype_l; # introduced=21
     iswdigit;
-    iswdigit_l;
+    iswdigit_l; # introduced=21
     iswgraph;
-    iswgraph_l;
+    iswgraph_l; # introduced=21
     iswlower;
-    iswlower_l;
+    iswlower_l; # introduced=21
     iswprint;
-    iswprint_l;
+    iswprint_l; # introduced=21
     iswpunct;
-    iswpunct_l;
+    iswpunct_l; # introduced=21
     iswspace;
-    iswspace_l;
+    iswspace_l; # introduced=21
     iswupper;
-    iswupper_l;
+    iswupper_l; # introduced=21
     iswxdigit;
-    iswxdigit_l;
+    iswxdigit_l; # introduced=21
     isxdigit;
-    isxdigit_l;
+    isxdigit_l; # introduced=21
     jrand48;
     kill;
     killpg;
     klogctl;
-    labs;
+    labs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lchown;
-    lcong48;
+    lcong48; # introduced=23
     ldexp;
     ldiv;
-    lfind;
-    lgetxattr;
+    lfind; # introduced=21
+    lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     link;
-    linkat;
+    linkat; # introduced=21
     listen;
-    listxattr;
-    llabs;
+    listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lldiv;
-    llistxattr;
-    localeconv;
+    llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    localeconv; # introduced=21
     localtime;
     localtime_r;
-    login_tty;
+    login_tty; # introduced=23
     longjmp;
     lrand48;
-    lremovexattr;
-    lsearch;
+    lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    lsearch; # introduced=21
     lseek;
     lseek64;
-    lsetxattr;
+    lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     lstat;
-    lstat64;
+    lstat64; # introduced=21
     madvise;
     mallinfo;
     malloc;
-    malloc_info;
-    malloc_usable_size;
+    malloc_info; # introduced=23
+    malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mbrlen;
-    mbrtoc16;
-    mbrtoc32;
+    mbrtoc16; # introduced=21
+    mbrtoc32; # introduced=21
     mbrtowc;
     mbsinit;
-    mbsnrtowcs;
+    mbsnrtowcs; # introduced=21
     mbsrtowcs;
     mbstowcs;
-    mbtowc;
+    mbtowc; # introduced=21
     memalign;
     memccpy;
     memchr;
@@ -570,113 +570,113 @@
     memcpy;
     memmem;
     memmove;
-    mempcpy;
+    mempcpy; # introduced=23
     memrchr;
     memset;
     mincore;
     mkdir;
     mkdirat;
     mkdtemp;
-    mkfifo;
-    mkfifoat;
+    mkfifo; # introduced=21
+    mkfifoat; # introduced=23
     mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
+    mknodat; # introduced=21
+    mkostemp; # introduced=23
+    mkostemp64; # introduced=23
+    mkostemps; # introduced=23
+    mkostemps64; # introduced=23
     mkstemp;
-    mkstemp64;
+    mkstemp64; # introduced=21
     mkstemps;
-    mkstemps64;
+    mkstemps64; # introduced=23
     mktemp;
     mktime;
     mlock;
-    mlockall;
+    mlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mmap;
-    mmap64;
+    mmap64; # introduced=21
     mount;
     mprotect;
     mrand48;
     mremap;
     msync;
     munlock;
-    munlockall;
+    munlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     munmap;
     nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
+    newlocale; # introduced=21
+    nftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    nftw64; # introduced=21
     nice;
     nrand48;
-    ns_format_ttl; # arm64 x86_64 mips64
-    ns_get16; # arm64 x86_64 mips64
-    ns_get32; # arm64 x86_64 mips64
-    ns_initparse; # arm64 x86_64 mips64
-    ns_makecanon; # arm64 x86_64 mips64
-    ns_msg_getflag; # arm64 x86_64 mips64
-    ns_name_compress; # arm64 x86_64 mips64
-    ns_name_ntol; # arm64 x86_64 mips64
-    ns_name_ntop; # arm64 x86_64 mips64
-    ns_name_pack; # arm64 x86_64 mips64
-    ns_name_pton; # arm64 x86_64 mips64
-    ns_name_rollback; # arm64 x86_64 mips64
-    ns_name_skip; # arm64 x86_64 mips64
-    ns_name_uncompress; # arm64 x86_64 mips64
-    ns_name_unpack; # arm64 x86_64 mips64
-    ns_parserr; # arm64 x86_64 mips64
-    ns_put16; # arm64 x86_64 mips64
-    ns_put32; # arm64 x86_64 mips64
-    ns_samename; # arm64 x86_64 mips64
-    ns_skiprr; # arm64 x86_64 mips64
-    ns_sprintrr; # arm64 x86_64 mips64
-    ns_sprintrrf; # arm64 x86_64 mips64
+    ns_format_ttl; # arm64 x86_64 mips64 introduced=22
+    ns_get16; # arm64 x86_64 mips64 introduced=22
+    ns_get32; # arm64 x86_64 mips64 introduced=22
+    ns_initparse; # arm64 x86_64 mips64 introduced=22
+    ns_makecanon; # arm64 x86_64 mips64 introduced=22
+    ns_msg_getflag; # arm64 x86_64 mips64 introduced=22
+    ns_name_compress; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntol; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntop; # arm64 x86_64 mips64 introduced=22
+    ns_name_pack; # arm64 x86_64 mips64 introduced=22
+    ns_name_pton; # arm64 x86_64 mips64 introduced=23
+    ns_name_rollback; # arm64 x86_64 mips64 introduced=22
+    ns_name_skip; # arm64 x86_64 mips64 introduced=22
+    ns_name_uncompress; # arm64 x86_64 mips64 introduced=22
+    ns_name_unpack; # arm64 x86_64 mips64 introduced=22
+    ns_parserr; # arm64 x86_64 mips64 introduced=22
+    ns_put16; # arm64 x86_64 mips64 introduced=22
+    ns_put32; # arm64 x86_64 mips64 introduced=22
+    ns_samename; # arm64 x86_64 mips64 introduced=22
+    ns_skiprr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrrf; # arm64 x86_64 mips64 introduced=22
     nsdispatch;
-    ntohl;
-    ntohs;
+    ntohl; # introduced=21
+    ntohs; # introduced=21
     open;
-    open64;
-    open_memstream;
-    open_wmemstream;
+    open64; # introduced=21
+    open_memstream; # introduced=23
+    open_wmemstream; # introduced=23
     openat;
-    openat64;
+    openat64; # introduced=21
     opendir;
     openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
+    openpty; # introduced=23
+    optarg; # var
+    opterr; # var
+    optind; # var
+    optopt; # var
+    optreset; # var
     pathconf;
     pause;
     pclose;
     perror;
-    personality;
+    personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
     pipe;
     pipe2;
     poll;
     popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
+    posix_fadvise; # introduced=21
+    posix_fadvise64; # introduced=21
+    posix_fallocate; # introduced=21
+    posix_fallocate64; # introduced=21
+    posix_madvise; # introduced=23
+    posix_memalign; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    posix_openpt; # introduced=21
+    ppoll; # introduced=21
     prctl;
     pread;
-    pread64;
+    pread64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     printf;
     prlimit; # arm64 x86_64 mips64
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
+    prlimit64; # introduced=21
+    process_vm_readv; # introduced=23
+    process_vm_writev; # introduced=23
     pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
+    psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    psignal; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     pthread_attr_destroy;
     pthread_attr_getdetachstate;
     pthread_attr_getguardsize;
@@ -700,10 +700,10 @@
     pthread_cond_timedwait;
     pthread_cond_wait;
     pthread_condattr_destroy;
-    pthread_condattr_getclock;
+    pthread_condattr_getclock; # introduced=21
     pthread_condattr_getpshared;
     pthread_condattr_init;
-    pthread_condattr_setclock;
+    pthread_condattr_setclock; # introduced=21
     pthread_condattr_setpshared;
     pthread_create;
     pthread_detach;
@@ -713,7 +713,7 @@
     pthread_getcpuclockid;
     pthread_getschedparam;
     pthread_getspecific;
-    pthread_gettid_np;
+    pthread_gettid_np; # introduced=21
     pthread_join;
     pthread_key_create;
     pthread_key_delete;
@@ -721,7 +721,7 @@
     pthread_mutex_destroy;
     pthread_mutex_init;
     pthread_mutex_lock;
-    pthread_mutex_timedlock;
+    pthread_mutex_timedlock; # introduced=21
     pthread_mutex_trylock;
     pthread_mutex_unlock;
     pthread_mutexattr_destroy;
@@ -741,10 +741,10 @@
     pthread_rwlock_unlock;
     pthread_rwlock_wrlock;
     pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getkind_np; # introduced=23
     pthread_rwlockattr_getpshared;
     pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setkind_np; # introduced=23
     pthread_rwlockattr_setpshared;
     pthread_self;
     pthread_setname_np;
@@ -764,36 +764,36 @@
     putwc;
     putwchar;
     pwrite;
-    pwrite64;
+    pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     qsort;
-    quick_exit;
+    quick_exit; # introduced=21
     raise;
-    rand;
-    rand_r;
-    random;
+    rand; # introduced=21
+    rand_r; # introduced=21
+    random; # introduced=21
     read;
-    readahead;
+    readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     readdir;
-    readdir64;
-    readdir64_r;
+    readdir64; # introduced=21
+    readdir64_r; # introduced=21
     readdir_r;
     readlink;
-    readlinkat;
+    readlinkat; # introduced=21
     readv;
     realloc;
     realpath;
     reboot;
     recv;
     recvfrom;
-    recvmmsg;
+    recvmmsg; # introduced=21
     recvmsg;
     regcomp;
     regerror;
     regexec;
     regfree;
     remove;
-    removexattr;
-    remque;
+    removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    remque; # introduced=21
     rename;
     renameat;
     res_init;
@@ -805,21 +805,21 @@
     rmdir;
     sbrk;
     scandir;
-    scandir64;
+    scandir64; # introduced=21
     scanf;
     sched_get_priority_max;
     sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
+    sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_getparam;
     sched_getscheduler;
     sched_rr_get_interval;
-    sched_setaffinity;
+    sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_setparam;
     sched_setscheduler;
     sched_yield;
     seed48;
-    seekdir;
+    seekdir; # introduced=23
     select;
     sem_close;
     sem_destroy;
@@ -833,8 +833,8 @@
     sem_wait;
     send;
     sendfile;
-    sendfile64;
-    sendmmsg;
+    sendfile64; # introduced=21
+    sendmmsg; # introduced=21
     sendmsg;
     sendto;
     setbuf;
@@ -842,101 +842,101 @@
     setegid;
     setenv;
     seteuid;
-    setfsgid;
-    setfsuid;
+    setfsgid; # introduced=21
+    setfsuid; # introduced=21
     setgid;
     setgroups;
-    sethostname;
+    sethostname; # introduced=23
     setitimer;
     setjmp;
     setlinebuf;
     setlocale;
     setlogmask;
-    setmntent;
-    setns;
+    setmntent; # introduced=21
+    setns; # introduced=21
     setpgid;
     setpgrp;
     setpriority;
-    setprogname;
+    setprogname; # introduced=21
     setregid;
     setresgid;
     setresuid;
     setreuid;
     setrlimit;
-    setrlimit64;
+    setrlimit64; # introduced=21
     setservent;
     setsid;
     setsockopt;
-    setstate;
+    setstate; # introduced=21
     settimeofday;
     setuid;
     setutent;
     setvbuf;
-    setxattr;
+    setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     shutdown;
     sigaction;
-    sigaddset;
+    sigaddset; # introduced=21
     sigaltstack;
     sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
+    sigdelset; # introduced=21
+    sigemptyset; # introduced=21
+    sigfillset; # introduced=21
     siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
+    sigismember; # introduced=21
+    siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    signal; # introduced=21
+    signalfd; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     sigpending;
     sigprocmask;
-    sigqueue;
-    sigsetjmp;
+    sigqueue; # introduced=23
+    sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sigsetmask;
     sigsuspend;
-    sigtimedwait;
+    sigtimedwait; # introduced=23
     sigwait;
-    sigwaitinfo;
+    sigwaitinfo; # introduced=23
     sleep;
     snprintf;
     socket;
     socketpair;
-    splice;
+    splice; # introduced=21
     sprintf;
-    srand;
+    srand; # introduced=21
     srand48;
-    srandom;
+    srandom; # introduced=21
     sscanf;
     stat;
-    stat64;
+    stat64; # introduced=21
     statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
+    statfs64; # introduced=21
+    statvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    statvfs64; # introduced=21
+    stderr; # var introduced=23
+    stdin; # var introduced=23
+    stdout; # var introduced=23
+    stpcpy; # introduced=21
+    stpncpy; # introduced=21
     strcasecmp;
-    strcasecmp_l;
+    strcasecmp_l; # introduced=23
     strcasestr;
     strcat;
     strchr;
     strcmp;
     strcoll;
-    strcoll_l;
+    strcoll_l; # introduced=21
     strcpy;
     strcspn;
     strdup;
     strerror;
-    strerror_l;
+    strerror_l; # introduced=23
     strerror_r;
     strftime;
-    strftime_l;
+    strftime_l; # introduced=21
     strlcat;
     strlcpy;
     strlen;
     strncasecmp;
-    strncasecmp_l;
+    strncasecmp_l; # introduced=23
     strncat;
     strncmp;
     strncpy;
@@ -950,84 +950,84 @@
     strspn;
     strstr;
     strtod;
-    strtof;
+    strtof; # introduced=21
     strtoimax;
     strtok;
     strtok_r;
     strtol;
-    strtold;
-    strtold_l;
+    strtold; # introduced=21
+    strtold_l; # introduced=21
     strtoll;
-    strtoll_l;
-    strtoq;
+    strtoll_l; # introduced=21
+    strtoq; # introduced=21
     strtoul;
     strtoull;
-    strtoull_l;
+    strtoull_l; # introduced=21
     strtoumax;
-    strtouq;
+    strtouq; # introduced=21
     strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
+    strxfrm_l; # introduced=21
+    swapoff; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    swapon; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     swprintf;
     swscanf;
     symlink;
-    symlinkat;
+    symlinkat; # introduced=21
     sync;
-    sys_siglist;
-    sys_signame;
+    sys_siglist; # var
+    sys_signame; # var
     syscall;
     sysconf;
     sysinfo;
     syslog;
     system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
+    tcdrain; # introduced=21
+    tcflow; # introduced=21
+    tcflush; # introduced=21
+    tcgetattr; # introduced=21
     tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
+    tcgetsid; # introduced=21
+    tcsendbreak; # introduced=21
+    tcsetattr; # introduced=21
     tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
+    tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tee; # introduced=21
+    telldir; # introduced=23
     tempnam;
-    tfind;
-    tgkill;
+    tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     time;
-    timegm;
-    timelocal;
+    timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    timelocal; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timer_create;
     timer_delete;
     timer_getoverrun;
     timer_gettime;
     timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
+    timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     times;
-    timezone;
+    timezone; # var
     tmpfile;
     tmpnam;
     toascii;
     tolower;
-    tolower_l;
+    tolower_l; # introduced=21
     toupper;
-    toupper_l;
+    toupper_l; # introduced=21
     towlower;
-    towlower_l;
+    towlower_l; # introduced=21
     towupper;
-    towupper_l;
+    towupper_l; # introduced=21
     truncate;
-    truncate64;
-    tsearch;
+    truncate64; # introduced=21
+    tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     ttyname;
     ttyname_r;
-    twalk;
-    tzname;
+    twalk; # introduced=21
+    tzname; # var
     tzset;
     umask;
     umount;
@@ -1039,37 +1039,37 @@
     unlinkat;
     unlockpt;
     unsetenv;
-    unshare;
-    uselocale;
+    unshare; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    uselocale; # introduced=21
     usleep;
     utime;
-    utimensat;
+    utimensat; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     utimes;
     utmpname;
     vasprintf;
-    vdprintf;
+    vdprintf; # introduced=21
     verr;
     verrx;
     vfork;
     vfprintf;
     vfscanf;
     vfwprintf;
-    vfwscanf;
-    vmsplice;
+    vfwscanf; # introduced=21
+    vmsplice; # introduced=21
     vprintf;
     vscanf;
     vsnprintf;
     vsprintf;
     vsscanf;
     vswprintf;
-    vswscanf;
+    vswscanf; # introduced=21
     vsyslog;
     vwarn;
     vwarnx;
     vwprintf;
-    vwscanf;
+    vwscanf; # introduced=21
     wait;
-    wait4;
+    wait4; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     waitid;
     waitpid;
     warn;
@@ -1078,12 +1078,12 @@
     wcpncpy;
     wcrtomb;
     wcscasecmp;
-    wcscasecmp_l;
+    wcscasecmp_l; # introduced=23
     wcscat;
     wcschr;
     wcscmp;
     wcscoll;
-    wcscoll_l;
+    wcscoll_l; # introduced=21
     wcscpy;
     wcscspn;
     wcsdup;
@@ -1092,44 +1092,44 @@
     wcslcpy;
     wcslen;
     wcsncasecmp;
-    wcsncasecmp_l;
+    wcsncasecmp_l; # introduced=23
     wcsncat;
     wcsncmp;
     wcsncpy;
     wcsnlen;
-    wcsnrtombs;
+    wcsnrtombs; # introduced=21
     wcspbrk;
     wcsrchr;
     wcsrtombs;
     wcsspn;
     wcsstr;
     wcstod;
-    wcstof;
-    wcstoimax;
+    wcstof; # introduced=21
+    wcstoimax; # introduced=21
     wcstok;
     wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
+    wcstold; # introduced=21
+    wcstold_l; # introduced=21
+    wcstoll; # introduced=21
+    wcstoll_l; # introduced=21
     wcstombs;
     wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
+    wcstoull; # introduced=21
+    wcstoull_l; # introduced=21
+    wcstoumax; # introduced=21
     wcswidth;
     wcsxfrm;
-    wcsxfrm_l;
+    wcsxfrm_l; # introduced=21
     wctob;
-    wctomb;
+    wctomb; # introduced=21
     wctype;
-    wctype_l;
+    wctype_l; # introduced=21
     wcwidth;
     wmemchr;
     wmemcmp;
     wmemcpy;
     wmemmove;
-    wmempcpy;
+    wmempcpy; # introduced=23
     wmemset;
     wprintf;
     write;
@@ -1139,56 +1139,106 @@
     *;
 };
 
-LIBC_N {
+LIBC_N { # introduced-arm64=24 introduced-mips=24 introduced-mips64=24 introduced-x86=24 introduced-x86_64=24
   global:
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
+    __fread_chk; # introduced=24
+    __fwrite_chk; # introduced=24
+    __getcwd_chk; # introduced=24
+    __pwrite_chk; # introduced=24
+    __pwrite64_chk; # introduced=24
+    __write_chk; # introduced=24
+    adjtimex; # introduced=24
+    clock_adjtime; # introduced=24
+    fgetpos64; # introduced=24
+    fileno_unlocked; # introduced=24
+    fopen64; # introduced=24
+    freeifaddrs; # introduced=24
+    freopen64; # introduced=24
+    fseeko64; # introduced=24
+    fsetpos64; # introduced=24
+    ftello64; # introduced=24
+    funopen64; # introduced=24
+    getgrgid_r; # introduced=24
+    getgrnam_r; # introduced=24
+    getifaddrs; # introduced=24
+    if_freenameindex; # introduced=24
+    if_nameindex; # introduced=24
+    in6addr_any; # var introduced=24
+    in6addr_loopback; # var introduced=24
+    lockf; # introduced=24
+    lockf64; # introduced=24
+    preadv; # introduced=24
+    preadv64; # introduced=24
+    pthread_barrierattr_destroy; # introduced=24
+    pthread_barrierattr_getpshared; # introduced=24
+    pthread_barrierattr_init; # introduced=24
+    pthread_barrierattr_setpshared; # introduced=24
+    pthread_barrier_destroy; # introduced=24
+    pthread_barrier_init; # introduced=24
+    pthread_barrier_wait; # introduced=24
+    pthread_spin_destroy; # introduced=24
+    pthread_spin_init; # introduced=24
+    pthread_spin_lock; # introduced=24
+    pthread_spin_trylock; # introduced=24
+    pthread_spin_unlock; # introduced=24
+    pwritev; # introduced=24
+    pwritev64; # introduced=24
+    scandirat; # introduced=24
+    scandirat64; # introduced=24
+    strchrnul; # introduced=24
+    tmpfile64; # introduced=24
 } LIBC;
 
+LIBC_O {
+  global:
+    catclose; # future
+    catgets; # future
+    catopen; # future
+    ctermid; # future
+    endgrent; # future
+    endpwent; # future
+    futimes; # future
+    futimesat; # future
+    getdomainname; # future
+    getgrent; # future
+    getpwent; # future
+    getsubopt; # future
+    hasmntopt; # future
+    lutimes; # future
+    mblen; # future
+    msgctl; # future
+    msgget; # future
+    msgrcv; # future
+    msgsnd; # future
+    pthread_getname_np; # future
+    quotactl; # future
+    semctl; # future
+    semget; # future
+    semop; # future
+    semtimedop; # future
+    setdomainname; # future
+    setgrent; # future
+    setpwent; # future
+    shmat; # future
+    shmctl; # future
+    shmdt; # future
+    shmget; # future
+    sighold; # future
+    sigignore; # future
+    sigpause; # future
+    sigrelse; # future
+    sigset; # future
+    strtod_l; # future
+    strtof_l; # future
+    strtol_l; # future
+    strtoul_l; # future
+    sync_file_range; # future
+    towctrans; # future
+    towctrans_l; # future
+    wctrans; # future
+    wctrans_l; # future
+} LIBC_N;
+
 LIBC_PRIVATE {
   global:
     android_getaddrinfofornet;
@@ -1198,7 +1248,7 @@
     free_malloc_leak_info;
     get_malloc_leak_info;
     gMallocLeakZygoteChild;
-} LIBC_N;
+} LIBC_O;
 
 LIBC_PLATFORM {
   global:
@@ -1209,4 +1259,4 @@
     malloc_disable;
     malloc_enable;
     malloc_iterate;
-} LIBC_N;
+} LIBC_O;
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 0e41f6c..1fba8ee 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -8,46 +8,45 @@
     __atomic_swap; # arm
     __b64_ntop;
     __b64_pton;
-    __brk; # arm x86 mips
-    __cmsg_nxthdr;
-    __connect; # arm x86 mips
-    __ctype_get_mb_cur_max;
+    __cmsg_nxthdr; # introduced=21
+    __connect; # arm x86 mips introduced=21
+    __ctype_get_mb_cur_max; # introduced=21
     __cxa_atexit;
     __cxa_finalize;
-    __cxa_thread_atexit_impl;
+    __cxa_thread_atexit_impl; # introduced=23
     __dn_comp;
     __dn_count_labels;
     __dn_skipname;
-    __epoll_pwait; # arm x86 mips
+    __epoll_pwait; # arm x86 mips introduced=21
     __errno;
-    __exit; # arm x86 mips
-    __fadvise64; # x86 mips
-    __fbufsize;
+    __exit; # arm x86 mips introduced=21
+    __fadvise64; # x86 mips introduced=21
+    __fbufsize; # introduced=23
     __fcntl64; # arm x86 mips
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
+    __FD_CLR_chk; # introduced=21
+    __FD_ISSET_chk; # introduced=21
+    __FD_SET_chk; # introduced=21
+    __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __flbf; # introduced=23
     __fp_nquery;
     __fp_query;
-    __fpclassify;
+    __fpclassify; # introduced=21
     __fpclassifyd;
     __fpclassifyf;
     __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
+    __fpending; # introduced=23
+    __fpurge; # introduced=23
+    __freadable; # introduced=23
+    __fsetlocking; # introduced=23
     __fstatfs64; # arm x86 mips
-    __fwritable;
+    __fwritable; # introduced=23
     __get_h_errno;
-    __getcpu; # arm x86 mips
+    __getcpu; # arm x86 mips introduced-arm=12 introduced-mips=16 introduced-x86=12
     __getcwd; # arm x86 mips
-    __getpid; # arm x86 mips
+    __getpid; # arm x86 mips introduced=21
     __getpriority; # arm x86 mips
-    __gnu_basename;
-    __gnu_strerror_r;
+    __gnu_basename; # introduced=23
+    __gnu_strerror_r; # introduced=23
     __hostalias;
     __ioctl; # arm x86 mips
     __isfinite;
@@ -56,24 +55,24 @@
     __isinf;
     __isinff;
     __isinfl;
-    __isnan;
-    __isnanf;
+    __isnan; # introduced=21
+    __isnanf; # introduced=21
     __isnanl;
     __isnormal;
     __isnormalf;
     __isnormall;
-    __isthreaded; # arm x86 mips
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
+    __isthreaded; # arm x86 mips var
+    __libc_current_sigrtmax; # introduced=21
+    __libc_current_sigrtmin; # introduced=21
     __libc_init;
     __llseek; # arm x86 mips
     __loc_aton;
     __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
+    __memchr_chk; # introduced=23
+    __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memrchr_chk; # introduced=23
+    __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __mmap2; # arm x86 mips
     __ns_format_ttl; # arm x86 mips
     __ns_get16; # arm x86 mips
@@ -97,13 +96,13 @@
     __ns_skiprr; # arm x86 mips
     __ns_sprintrr; # arm x86 mips
     __ns_sprintrrf; # arm x86 mips
-    __open_2;
+    __open_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __openat; # arm x86 mips
-    __openat_2;
+    __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __p_cdname;
     __p_cdnname;
     __p_class;
-    __p_class_syms;
+    __p_class_syms; # var
     __p_fqname;
     __p_fqnname;
     __p_option;
@@ -112,25 +111,25 @@
     __p_secstodate;
     __p_time;
     __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll; # arm x86 mips
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
-    __pselect6; # arm x86 mips
+    __p_type_syms; # var
+    __poll_chk; # introduced=23
+    __ppoll; # arm x86 mips introduced=21
+    __ppoll_chk; # introduced=23
+    __pread64_chk; # introduced=23
+    __pread_chk; # introduced=23
+    __progname; # var
+    __pselect6; # arm x86 mips introduced=21
     __pthread_cleanup_pop;
     __pthread_cleanup_push;
     __ptrace; # arm x86 mips
     __putlong;
     __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
+    __read_chk; # introduced=21
+    __readlink_chk; # introduced=23
+    __readlinkat_chk; # introduced=23
     __reboot; # arm x86 mips
-    __recvfrom_chk;
-    __register_atfork;
+    __recvfrom_chk; # introduced=21
+    __register_atfork; # introduced=23
     __res_close;
     __res_dnok;
     __res_hnok;
@@ -152,91 +151,91 @@
     __res_send_setqhook;
     __res_send_setrhook;
     __rt_sigaction; # arm x86 mips
-    __rt_sigpending; # arm x86 mips
+    __rt_sigpending; # arm x86 mips introduced=21
     __rt_sigprocmask; # arm x86 mips
-    __rt_sigsuspend; # arm x86 mips
+    __rt_sigsuspend; # arm x86 mips introduced=21
     __rt_sigtimedwait; # arm x86 mips
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sched_getaffinity; # arm x86 mips
+    __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_getaffinity; # arm x86 mips introduced=12
     __set_thread_area; # x86
-    __set_tid_address; # arm x86 mips
+    __set_tid_address; # arm x86 mips introduced=21
     __set_tls; # arm mips
-    __sF;
-    __sigaction; # arm x86 mips
-    __snprintf_chk;
-    __socket; # arm x86 mips
-    __sprintf_chk;
+    __sF; # var
+    __sigaction; # arm x86 mips introduced=21
+    __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __socket; # arm x86 mips introduced=21
+    __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __stack_chk_fail;
-    __stack_chk_guard;
+    __stack_chk_guard; # var
     __statfs64; # arm x86 mips
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
+    __stpcpy_chk; # introduced=21
+    __stpncpy_chk; # introduced=21
+    __stpncpy_chk2; # introduced=21
+    __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk2; # introduced=21
+    __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     __sym_ntop;
     __sym_ntos;
     __sym_ston;
     __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
+    __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area__; # var
+    __system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area_serial; # introduced=23
     __system_property_find;
     __system_property_find_nth;
-    __system_property_foreach;
+    __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __system_property_get;
     __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
+    __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __timer_create; # arm x86 mips
     __timer_delete; # arm x86 mips
     __timer_getoverrun; # arm x86 mips
     __timer_gettime; # arm x86 mips
     __timer_settime; # arm x86 mips
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
+    __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __waitid; # arm x86 mips
-    _ctype_;
-    _Exit;
+    _ctype_; # var
+    _Exit; # introduced=21
     _exit;
     _flush_cache; # mips
-    _flushlbf;
+    _flushlbf; # introduced=23
     _getlong;
     _getshort;
     _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
+    _resolv_delete_cache_for_net; # introduced=21
+    _resolv_flush_cache_for_net; # introduced=21
+    _resolv_set_nameservers_for_net; # introduced=21
     _setjmp;
-    _tolower;
-    _tolower_tab_; # arm x86 mips
-    _toupper;
-    _toupper_tab_; # arm x86 mips
+    _tolower; # introduced=21
+    _tolower_tab_; # arm x86 mips var
+    _toupper; # introduced=21
+    _toupper_tab_; # arm x86 mips var
     abort;
-    abs;
+    abs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     accept;
-    accept4;
+    accept4; # introduced=21
     access;
     acct;
     alarm;
     alphasort;
-    alphasort64;
-    android_set_abort_message;
+    alphasort64; # introduced=21
+    android_set_abort_message; # introduced=21
     arc4random;
     arc4random_buf;
     arc4random_uniform;
@@ -245,8 +244,8 @@
     asctime64_r; # arm x86 mips
     asctime_r;
     asprintf;
-    at_quick_exit;
-    atof;
+    at_quick_exit; # introduced=21
+    atof; # introduced=21
     atoi;
     atol;
     atoll;
@@ -257,44 +256,44 @@
     brk;
     bsearch;
     btowc;
-    c16rtomb;
-    c32rtomb;
+    c16rtomb; # introduced=21
+    c32rtomb; # introduced=21
     cacheflush; # arm mips
     calloc;
     capget;
     capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
+    cfgetispeed; # introduced=21
+    cfgetospeed; # introduced=21
+    cfmakeraw; # introduced=21
+    cfsetispeed; # introduced=21
+    cfsetospeed; # introduced=21
+    cfsetspeed; # introduced=21
     chdir;
     chmod;
     chown;
     chroot;
     clearenv;
     clearerr;
-    clearerr_unlocked;
+    clearerr_unlocked; # introduced=23
     clock;
-    clock_getcpuclockid;
+    clock_getcpuclockid; # introduced=23
     clock_getres;
     clock_gettime;
     clock_nanosleep;
     clock_settime;
-    clone;
+    clone; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     close;
     closedir;
     closelog;
     connect;
     creat;
-    creat64;
+    creat64; # introduced=21
     ctime;
     ctime64; # arm x86 mips
     ctime64_r; # arm x86 mips
     ctime_r;
     daemon;
-    daylight;
+    daylight; # var
     delete_module;
     difftime;
     dirfd;
@@ -302,33 +301,33 @@
     dirname_r; # arm x86 mips
     div;
     dn_expand;
-    dprintf;
+    dprintf; # introduced=21
     drand48;
     dup;
     dup2;
-    dup3;
-    duplocale;
-    endmntent;
+    dup3; # introduced=21
+    duplocale; # introduced=21
+    endmntent; # introduced=21
     endservent;
     endutent;
-    environ;
+    environ; # var
     epoll_create;
-    epoll_create1;
+    epoll_create1; # introduced=21
     epoll_ctl;
-    epoll_pwait;
+    epoll_pwait; # introduced=21
     epoll_wait;
     erand48;
     err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
+    error; # introduced=23
+    error_at_line; # introduced=23
+    error_message_count; # var introduced=23
+    error_one_per_line; # var introduced=23
+    error_print_progname; # var introduced=23
     errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
+    ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     eventfd;
     eventfd_read;
     eventfd_write;
@@ -338,11 +337,11 @@
     execv;
     execve;
     execvp;
-    execvpe;
+    execvpe; # introduced=21
     exit;
-    faccessat;
-    fallocate;
-    fallocate64;
+    faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    fallocate; # introduced=21
+    fallocate64; # introduced=21
     fchdir;
     fchmod;
     fchmodat;
@@ -354,27 +353,27 @@
     fdopen;
     fdopendir;
     feof;
-    feof_unlocked;
+    feof_unlocked; # introduced=23
     ferror;
-    ferror_unlocked;
+    ferror_unlocked; # introduced=23
     fflush;
-    ffs;
+    ffs; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     fgetc;
     fgetln;
     fgetpos;
     fgets;
     fgetwc;
     fgetws;
-    fgetxattr;
+    fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fileno;
-    flistxattr;
+    flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     flock;
     flockfile;
-    fmemopen;
+    fmemopen; # introduced=23
     fnmatch;
     fopen;
     fork;
-    forkpty;
+    forkpty; # introduced=23
     fpathconf;
     fprintf;
     fpurge;
@@ -385,56 +384,56 @@
     fread;
     free;
     freeaddrinfo;
-    freelocale;
-    fremovexattr;
+    freelocale; # introduced=21
+    fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     freopen;
     fscanf;
     fseek;
     fseeko;
     fsetpos;
-    fsetxattr;
+    fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fstat;
-    fstat64;
+    fstat64; # introduced=21
     fstatat;
-    fstatat64;
+    fstatat64; # introduced=21
     fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
+    fstatfs64; # introduced=21
+    fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    fstatvfs64; # introduced=21
     fsync;
     ftell;
     ftello;
     ftok;
     ftruncate;
-    ftruncate64;
+    ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     ftrylockfile;
     fts_children;
     fts_close;
     fts_open;
     fts_read;
     fts_set;
-    ftw;
-    ftw64;
+    ftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    ftw64; # introduced=21
     funlockfile;
     funopen;
-    futimens;
+    futimens; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     fwide;
     fwprintf;
     fwrite;
     fwscanf;
     gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
+    get_avphys_pages; # introduced=23
+    get_nprocs; # introduced=23
+    get_nprocs_conf; # introduced=23
+    get_phys_pages; # introduced=23
     getaddrinfo;
-    getauxval;
+    getauxval; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getc;
     getc_unlocked;
     getchar;
     getchar_unlocked;
     getcwd;
-    getdelim;
+    getdelim; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getegid;
     getenv;
     geteuid;
@@ -444,49 +443,49 @@
     getgrouplist;
     getgroups;
     gethostbyaddr;
-    gethostbyaddr_r;
+    gethostbyaddr_r; # introduced=23
     gethostbyname;
     gethostbyname2;
-    gethostbyname2_r;
+    gethostbyname2_r; # introduced=23
     gethostbyname_r;
     gethostent;
     gethostname;
     getitimer;
-    getline;
+    getline; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getlogin;
     getmntent;
-    getmntent_r;
+    getmntent_r; # introduced=21
     getnameinfo;
     getnetbyaddr;
     getnetbyname;
     getopt;
     getopt_long;
     getopt_long_only;
-    getpagesize;
+    getpagesize; # introduced=21
     getpeername;
     getpgid;
     getpgrp;
     getpid;
     getppid;
     getpriority;
-    getprogname;
+    getprogname; # introduced=21
     getprotobyname;
     getprotobynumber;
     getpt;
     getpwnam;
-    getpwnam_r;
+    getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getpwuid;
-    getpwuid_r;
+    getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getresgid;
     getresuid;
     getrlimit;
-    getrlimit64;
+    getrlimit64; # introduced=21
     getrusage;
     gets;
     getservbyname;
     getservbyport;
     getservent;
-    getsid;
+    getsid; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     getsockname;
     getsockopt;
     gettid;
@@ -495,26 +494,26 @@
     getutent;
     getwc;
     getwchar;
-    getxattr;
+    getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     gmtime;
     gmtime64; # arm x86 mips
     gmtime64_r; # arm x86 mips
     gmtime_r;
-    grantpt;
+    grantpt; # introduced=21
     herror;
     hstrerror;
-    htonl;
-    htons;
+    htonl; # introduced=21
+    htons; # introduced=21
     if_indextoname;
     if_nametoindex;
-    imaxabs;
-    imaxdiv;
+    imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     inet_addr;
     inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
+    inet_lnaof; # introduced=21
+    inet_makeaddr; # introduced=21
+    inet_netof; # introduced=21
+    inet_network; # introduced=21
     inet_nsap_addr;
     inet_nsap_ntoa;
     inet_ntoa;
@@ -522,124 +521,124 @@
     inet_pton;
     init_module;
     initgroups;
-    initstate;
+    initstate; # introduced=21
     inotify_add_watch;
     inotify_init;
-    inotify_init1;
+    inotify_init1; # introduced=21
     inotify_rm_watch;
-    insque;
+    insque; # introduced=21
     ioctl;
     isalnum;
-    isalnum_l;
+    isalnum_l; # introduced=21
     isalpha;
-    isalpha_l;
+    isalpha_l; # introduced=21
     isascii;
     isatty;
     isblank;
-    isblank_l;
+    isblank_l; # introduced=21
     iscntrl;
-    iscntrl_l;
+    iscntrl_l; # introduced=21
     isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
+    isdigit_l; # introduced=21
+    isfinite; # introduced=21
+    isfinitef; # introduced=21
+    isfinitel; # introduced=21
     isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
+    isgraph_l; # introduced=21
+    isinf; # introduced=21
+    isinff; # introduced=21
+    isinfl; # introduced=21
     islower;
-    islower_l;
+    islower_l; # introduced=21
     isnan;
     isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
+    isnanl; # introduced=21
+    isnormal; # introduced=21
+    isnormalf; # introduced=21
+    isnormall; # introduced=21
     isprint;
-    isprint_l;
+    isprint_l; # introduced=21
     ispunct;
-    ispunct_l;
+    ispunct_l; # introduced=21
     isspace;
-    isspace_l;
+    isspace_l; # introduced=21
     isupper;
-    isupper_l;
+    isupper_l; # introduced=21
     iswalnum;
-    iswalnum_l;
+    iswalnum_l; # introduced=21
     iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
+    iswalpha_l; # introduced=21
+    iswblank; # introduced=21
+    iswblank_l; # introduced=21
     iswcntrl;
-    iswcntrl_l;
+    iswcntrl_l; # introduced=21
     iswctype;
-    iswctype_l;
+    iswctype_l; # introduced=21
     iswdigit;
-    iswdigit_l;
+    iswdigit_l; # introduced=21
     iswgraph;
-    iswgraph_l;
+    iswgraph_l; # introduced=21
     iswlower;
-    iswlower_l;
+    iswlower_l; # introduced=21
     iswprint;
-    iswprint_l;
+    iswprint_l; # introduced=21
     iswpunct;
-    iswpunct_l;
+    iswpunct_l; # introduced=21
     iswspace;
-    iswspace_l;
+    iswspace_l; # introduced=21
     iswupper;
-    iswupper_l;
+    iswupper_l; # introduced=21
     iswxdigit;
-    iswxdigit_l;
+    iswxdigit_l; # introduced=21
     isxdigit;
-    isxdigit_l;
+    isxdigit_l; # introduced=21
     jrand48;
     kill;
     killpg;
     klogctl;
-    labs;
+    labs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lchown;
-    lcong48;
+    lcong48; # introduced=23
     ldexp;
     ldiv;
-    lfind;
-    lgetxattr;
+    lfind; # introduced=21
+    lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     link;
-    linkat;
+    linkat; # introduced=21
     listen;
-    listxattr;
-    llabs;
+    listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lldiv;
-    llistxattr;
-    localeconv;
+    llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    localeconv; # introduced=21
     localtime;
     localtime64; # arm x86 mips
     localtime64_r; # arm x86 mips
     localtime_r;
-    login_tty;
+    login_tty; # introduced=23
     longjmp;
     lrand48;
-    lremovexattr;
-    lsearch;
+    lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    lsearch; # introduced=21
     lseek;
     lseek64;
-    lsetxattr;
+    lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     lstat;
-    lstat64;
+    lstat64; # introduced=21
     madvise;
     mallinfo;
     malloc;
-    malloc_info;
-    malloc_usable_size;
+    malloc_info; # introduced=23
+    malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mbrlen;
-    mbrtoc16;
-    mbrtoc32;
+    mbrtoc16; # introduced=21
+    mbrtoc32; # introduced=21
     mbrtowc;
     mbsinit;
-    mbsnrtowcs;
+    mbsnrtowcs; # introduced=21
     mbsrtowcs;
     mbstowcs;
-    mbtowc;
+    mbtowc; # introduced=21
     memalign;
     memccpy;
     memchr;
@@ -647,114 +646,114 @@
     memcpy;
     memmem;
     memmove;
-    mempcpy;
+    mempcpy; # introduced=23
     memrchr;
     memset;
     mincore;
     mkdir;
     mkdirat;
     mkdtemp;
-    mkfifo;
-    mkfifoat;
+    mkfifo; # introduced=21
+    mkfifoat; # introduced=23
     mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
+    mknodat; # introduced=21
+    mkostemp; # introduced=23
+    mkostemp64; # introduced=23
+    mkostemps; # introduced=23
+    mkostemps64; # introduced=23
     mkstemp;
-    mkstemp64;
+    mkstemp64; # introduced=21
     mkstemps;
-    mkstemps64;
+    mkstemps64; # introduced=23
     mktemp;
     mktime;
     mktime64; # arm x86 mips
     mlock;
-    mlockall;
+    mlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mmap;
-    mmap64;
+    mmap64; # introduced=21
     mount;
     mprotect;
     mrand48;
     mremap;
     msync;
     munlock;
-    munlockall;
+    munlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     munmap;
     nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
+    newlocale; # introduced=21
+    nftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    nftw64; # introduced=21
     nice;
     nrand48;
-    ns_format_ttl; # arm64 x86_64 mips64
-    ns_get16; # arm64 x86_64 mips64
-    ns_get32; # arm64 x86_64 mips64
-    ns_initparse; # arm64 x86_64 mips64
-    ns_makecanon; # arm64 x86_64 mips64
-    ns_msg_getflag; # arm64 x86_64 mips64
-    ns_name_compress; # arm64 x86_64 mips64
-    ns_name_ntol; # arm64 x86_64 mips64
-    ns_name_ntop; # arm64 x86_64 mips64
-    ns_name_pack; # arm64 x86_64 mips64
-    ns_name_pton; # arm64 x86_64 mips64
-    ns_name_rollback; # arm64 x86_64 mips64
-    ns_name_skip; # arm64 x86_64 mips64
-    ns_name_uncompress; # arm64 x86_64 mips64
-    ns_name_unpack; # arm64 x86_64 mips64
-    ns_parserr; # arm64 x86_64 mips64
-    ns_put16; # arm64 x86_64 mips64
-    ns_put32; # arm64 x86_64 mips64
-    ns_samename; # arm64 x86_64 mips64
-    ns_skiprr; # arm64 x86_64 mips64
-    ns_sprintrr; # arm64 x86_64 mips64
-    ns_sprintrrf; # arm64 x86_64 mips64
+    ns_format_ttl; # arm64 x86_64 mips64 introduced=22
+    ns_get16; # arm64 x86_64 mips64 introduced=22
+    ns_get32; # arm64 x86_64 mips64 introduced=22
+    ns_initparse; # arm64 x86_64 mips64 introduced=22
+    ns_makecanon; # arm64 x86_64 mips64 introduced=22
+    ns_msg_getflag; # arm64 x86_64 mips64 introduced=22
+    ns_name_compress; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntol; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntop; # arm64 x86_64 mips64 introduced=22
+    ns_name_pack; # arm64 x86_64 mips64 introduced=22
+    ns_name_pton; # arm64 x86_64 mips64 introduced=23
+    ns_name_rollback; # arm64 x86_64 mips64 introduced=22
+    ns_name_skip; # arm64 x86_64 mips64 introduced=22
+    ns_name_uncompress; # arm64 x86_64 mips64 introduced=22
+    ns_name_unpack; # arm64 x86_64 mips64 introduced=22
+    ns_parserr; # arm64 x86_64 mips64 introduced=22
+    ns_put16; # arm64 x86_64 mips64 introduced=22
+    ns_put32; # arm64 x86_64 mips64 introduced=22
+    ns_samename; # arm64 x86_64 mips64 introduced=22
+    ns_skiprr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrrf; # arm64 x86_64 mips64 introduced=22
     nsdispatch;
-    ntohl;
-    ntohs;
+    ntohl; # introduced=21
+    ntohs; # introduced=21
     open;
-    open64;
-    open_memstream;
-    open_wmemstream;
+    open64; # introduced=21
+    open_memstream; # introduced=23
+    open_wmemstream; # introduced=23
     openat;
-    openat64;
+    openat64; # introduced=21
     opendir;
     openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
+    openpty; # introduced=23
+    optarg; # var
+    opterr; # var
+    optind; # var
+    optopt; # var
+    optreset; # var
     pathconf;
     pause;
     pclose;
     perror;
-    personality;
+    personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
     pipe;
     pipe2;
     poll;
     popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
+    posix_fadvise; # introduced=21
+    posix_fadvise64; # introduced=21
+    posix_fallocate; # introduced=21
+    posix_fallocate64; # introduced=21
+    posix_madvise; # introduced=23
+    posix_memalign; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    posix_openpt; # introduced=21
+    ppoll; # introduced=21
     prctl;
     pread;
-    pread64;
+    pread64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     printf;
     prlimit; # arm64 x86_64 mips64
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
+    prlimit64; # introduced=21
+    process_vm_readv; # introduced=23
+    process_vm_writev; # introduced=23
     pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
+    psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    psignal; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     pthread_attr_destroy;
     pthread_attr_getdetachstate;
     pthread_attr_getguardsize;
@@ -782,10 +781,10 @@
     pthread_cond_timeout_np; # arm x86 mips
     pthread_cond_wait;
     pthread_condattr_destroy;
-    pthread_condattr_getclock;
+    pthread_condattr_getclock; # introduced=21
     pthread_condattr_getpshared;
     pthread_condattr_init;
-    pthread_condattr_setclock;
+    pthread_condattr_setclock; # introduced=21
     pthread_condattr_setpshared;
     pthread_create;
     pthread_detach;
@@ -795,7 +794,7 @@
     pthread_getcpuclockid;
     pthread_getschedparam;
     pthread_getspecific;
-    pthread_gettid_np;
+    pthread_gettid_np; # introduced=21
     pthread_join;
     pthread_key_create;
     pthread_key_delete;
@@ -804,7 +803,7 @@
     pthread_mutex_init;
     pthread_mutex_lock;
     pthread_mutex_lock_timeout_np; # arm x86 mips
-    pthread_mutex_timedlock;
+    pthread_mutex_timedlock; # introduced=21
     pthread_mutex_trylock;
     pthread_mutex_unlock;
     pthread_mutexattr_destroy;
@@ -824,10 +823,10 @@
     pthread_rwlock_unlock;
     pthread_rwlock_wrlock;
     pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getkind_np; # introduced=23
     pthread_rwlockattr_getpshared;
     pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setkind_np; # introduced=23
     pthread_rwlockattr_setpshared;
     pthread_self;
     pthread_setname_np;
@@ -847,38 +846,38 @@
     putw; # arm x86 mips
     putwc;
     putwchar;
-    pvalloc; # arm x86 mips
+    pvalloc; # arm x86 mips introduced=17
     pwrite;
-    pwrite64;
+    pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     qsort;
-    quick_exit;
+    quick_exit; # introduced=21
     raise;
-    rand;
-    rand_r;
-    random;
+    rand; # introduced=21
+    rand_r; # introduced=21
+    random; # introduced=21
     read;
-    readahead;
+    readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     readdir;
-    readdir64;
-    readdir64_r;
+    readdir64; # introduced=21
+    readdir64_r; # introduced=21
     readdir_r;
     readlink;
-    readlinkat;
+    readlinkat; # introduced=21
     readv;
     realloc;
     realpath;
     reboot;
     recv;
     recvfrom;
-    recvmmsg;
+    recvmmsg; # introduced=21
     recvmsg;
     regcomp;
     regerror;
     regexec;
     regfree;
     remove;
-    removexattr;
-    remque;
+    removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    remque; # introduced=21
     rename;
     renameat;
     res_init;
@@ -890,21 +889,21 @@
     rmdir;
     sbrk;
     scandir;
-    scandir64;
+    scandir64; # introduced=21
     scanf;
     sched_get_priority_max;
     sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
+    sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_getparam;
     sched_getscheduler;
     sched_rr_get_interval;
-    sched_setaffinity;
+    sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_setparam;
     sched_setscheduler;
     sched_yield;
     seed48;
-    seekdir;
+    seekdir; # introduced=23
     select;
     sem_close;
     sem_destroy;
@@ -918,8 +917,8 @@
     sem_wait;
     send;
     sendfile;
-    sendfile64;
-    sendmmsg;
+    sendfile64; # introduced=21
+    sendmmsg; # introduced=21
     sendmsg;
     sendto;
     setbuf;
@@ -927,101 +926,101 @@
     setegid;
     setenv;
     seteuid;
-    setfsgid;
-    setfsuid;
+    setfsgid; # introduced=21
+    setfsuid; # introduced=21
     setgid;
     setgroups;
-    sethostname;
+    sethostname; # introduced=23
     setitimer;
     setjmp;
     setlinebuf;
     setlocale;
     setlogmask;
-    setmntent;
-    setns;
+    setmntent; # introduced=21
+    setns; # introduced=21
     setpgid;
     setpgrp;
     setpriority;
-    setprogname;
+    setprogname; # introduced=21
     setregid;
     setresgid;
     setresuid;
     setreuid;
     setrlimit;
-    setrlimit64;
+    setrlimit64; # introduced=21
     setservent;
     setsid;
     setsockopt;
-    setstate;
+    setstate; # introduced=21
     settimeofday;
     setuid;
     setutent;
     setvbuf;
-    setxattr;
+    setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     shutdown;
     sigaction;
-    sigaddset;
+    sigaddset; # introduced=21
     sigaltstack;
     sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
+    sigdelset; # introduced=21
+    sigemptyset; # introduced=21
+    sigfillset; # introduced=21
     siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
+    sigismember; # introduced=21
+    siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    signal; # introduced=21
+    signalfd; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     sigpending;
     sigprocmask;
-    sigqueue;
-    sigsetjmp;
+    sigqueue; # introduced=23
+    sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sigsetmask;
     sigsuspend;
-    sigtimedwait;
+    sigtimedwait; # introduced=23
     sigwait;
-    sigwaitinfo;
+    sigwaitinfo; # introduced=23
     sleep;
     snprintf;
     socket;
     socketpair;
-    splice;
+    splice; # introduced=21
     sprintf;
-    srand;
+    srand; # introduced=21
     srand48;
-    srandom;
+    srandom; # introduced=21
     sscanf;
     stat;
-    stat64;
+    stat64; # introduced=21
     statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
+    statfs64; # introduced=21
+    statvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    statvfs64; # introduced=21
+    stderr; # var introduced=23
+    stdin; # var introduced=23
+    stdout; # var introduced=23
+    stpcpy; # introduced=21
+    stpncpy; # introduced=21
     strcasecmp;
-    strcasecmp_l;
+    strcasecmp_l; # introduced=23
     strcasestr;
     strcat;
     strchr;
     strcmp;
     strcoll;
-    strcoll_l;
+    strcoll_l; # introduced=21
     strcpy;
     strcspn;
     strdup;
     strerror;
-    strerror_l;
+    strerror_l; # introduced=23
     strerror_r;
     strftime;
-    strftime_l;
+    strftime_l; # introduced=21
     strlcat;
     strlcpy;
     strlen;
     strncasecmp;
-    strncasecmp_l;
+    strncasecmp_l; # introduced=23
     strncat;
     strncmp;
     strncpy;
@@ -1035,86 +1034,86 @@
     strspn;
     strstr;
     strtod;
-    strtof;
+    strtof; # introduced=21
     strtoimax;
     strtok;
     strtok_r;
     strtol;
-    strtold;
-    strtold_l;
+    strtold; # introduced=21
+    strtold_l; # introduced=21
     strtoll;
-    strtoll_l;
-    strtoq;
+    strtoll_l; # introduced=21
+    strtoq; # introduced=21
     strtoul;
     strtoull;
-    strtoull_l;
+    strtoull_l; # introduced=21
     strtoumax;
-    strtouq;
+    strtouq; # introduced=21
     strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
+    strxfrm_l; # introduced=21
+    swapoff; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    swapon; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     swprintf;
     swscanf;
     symlink;
-    symlinkat;
+    symlinkat; # introduced=21
     sync;
-    sys_siglist;
-    sys_signame;
+    sys_siglist; # var
+    sys_signame; # var
     syscall;
     sysconf;
     sysinfo;
     syslog;
     system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
+    tcdrain; # introduced=21
+    tcflow; # introduced=21
+    tcflush; # introduced=21
+    tcgetattr; # introduced=21
     tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
+    tcgetsid; # introduced=21
+    tcsendbreak; # introduced=21
+    tcsetattr; # introduced=21
     tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
+    tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tee; # introduced=21
+    telldir; # introduced=23
     tempnam;
-    tfind;
-    tgkill;
+    tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     time;
-    timegm;
+    timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timegm64; # arm x86 mips
-    timelocal;
+    timelocal; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timelocal64; # arm x86 mips
     timer_create;
     timer_delete;
     timer_getoverrun;
     timer_gettime;
     timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
+    timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     times;
-    timezone;
+    timezone; # var
     tmpfile;
     tmpnam;
     toascii;
     tolower;
-    tolower_l;
+    tolower_l; # introduced=21
     toupper;
-    toupper_l;
+    toupper_l; # introduced=21
     towlower;
-    towlower_l;
+    towlower_l; # introduced=21
     towupper;
-    towupper_l;
+    towupper_l; # introduced=21
     truncate;
-    truncate64;
-    tsearch;
+    truncate64; # introduced=21
+    tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     ttyname;
     ttyname_r;
-    twalk;
-    tzname;
+    twalk; # introduced=21
+    tzname; # var
     tzset;
     umask;
     umount;
@@ -1126,38 +1125,38 @@
     unlinkat;
     unlockpt;
     unsetenv;
-    unshare;
-    uselocale;
+    unshare; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    uselocale; # introduced=21
     usleep;
     utime;
-    utimensat;
+    utimensat; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     utimes;
     utmpname;
     valloc; # arm x86 mips
     vasprintf;
-    vdprintf;
+    vdprintf; # introduced=21
     verr;
     verrx;
     vfork;
     vfprintf;
     vfscanf;
     vfwprintf;
-    vfwscanf;
-    vmsplice;
+    vfwscanf; # introduced=21
+    vmsplice; # introduced=21
     vprintf;
     vscanf;
     vsnprintf;
     vsprintf;
     vsscanf;
     vswprintf;
-    vswscanf;
+    vswscanf; # introduced=21
     vsyslog;
     vwarn;
     vwarnx;
     vwprintf;
-    vwscanf;
+    vwscanf; # introduced=21
     wait;
-    wait4;
+    wait4; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     waitid;
     waitpid;
     warn;
@@ -1166,12 +1165,12 @@
     wcpncpy;
     wcrtomb;
     wcscasecmp;
-    wcscasecmp_l;
+    wcscasecmp_l; # introduced=23
     wcscat;
     wcschr;
     wcscmp;
     wcscoll;
-    wcscoll_l;
+    wcscoll_l; # introduced=21
     wcscpy;
     wcscspn;
     wcsdup;
@@ -1180,44 +1179,44 @@
     wcslcpy;
     wcslen;
     wcsncasecmp;
-    wcsncasecmp_l;
+    wcsncasecmp_l; # introduced=23
     wcsncat;
     wcsncmp;
     wcsncpy;
     wcsnlen;
-    wcsnrtombs;
+    wcsnrtombs; # introduced=21
     wcspbrk;
     wcsrchr;
     wcsrtombs;
     wcsspn;
     wcsstr;
     wcstod;
-    wcstof;
-    wcstoimax;
+    wcstof; # introduced=21
+    wcstoimax; # introduced=21
     wcstok;
     wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
+    wcstold; # introduced=21
+    wcstold_l; # introduced=21
+    wcstoll; # introduced=21
+    wcstoll_l; # introduced=21
     wcstombs;
     wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
+    wcstoull; # introduced=21
+    wcstoull_l; # introduced=21
+    wcstoumax; # introduced=21
     wcswidth;
     wcsxfrm;
-    wcsxfrm_l;
+    wcsxfrm_l; # introduced=21
     wctob;
-    wctomb;
+    wctomb; # introduced=21
     wctype;
-    wctype_l;
+    wctype_l; # introduced=21
     wcwidth;
     wmemchr;
     wmemcmp;
     wmemcpy;
     wmemmove;
-    wmempcpy;
+    wmempcpy; # introduced=23
     wmemset;
     wprintf;
     write;
@@ -1227,71 +1226,122 @@
     *;
 };
 
-LIBC_N {
+LIBC_N { # introduced-arm64=24 introduced-mips=24 introduced-mips64=24 introduced-x86=24 introduced-x86_64=24
   global:
-    __aeabi_atexit; # arm
-    __aeabi_memclr; # arm
-    __aeabi_memclr4; # arm
-    __aeabi_memclr8; # arm
-    __aeabi_memcpy; # arm
-    __aeabi_memcpy4; # arm
-    __aeabi_memcpy8; # arm
-    __aeabi_memmove; # arm
-    __aeabi_memmove4; # arm
-    __aeabi_memmove8; # arm
-    __aeabi_memset; # arm
-    __aeabi_memset4; # arm
-    __aeabi_memset8; # arm
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __gnu_Unwind_Find_exidx; # arm
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    prlimit; # arm mips x86
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
+    __aeabi_atexit; # arm versioned=24
+    __aeabi_memclr; # arm versioned=24
+    __aeabi_memclr4; # arm versioned=24
+    __aeabi_memclr8; # arm versioned=24
+    __aeabi_memcpy; # arm versioned=24
+    __aeabi_memcpy4; # arm versioned=24
+    __aeabi_memcpy8; # arm versioned=24
+    __aeabi_memmove; # arm versioned=24
+    __aeabi_memmove4; # arm versioned=24
+    __aeabi_memmove8; # arm versioned=24
+    __aeabi_memset; # arm versioned=24
+    __aeabi_memset4; # arm versioned=24
+    __aeabi_memset8; # arm versioned=24
+    __fread_chk; # introduced=24
+    __fwrite_chk; # introduced=24
+    __getcwd_chk; # introduced=24
+    __gnu_Unwind_Find_exidx; # arm versioned=24
+    __pwrite_chk; # introduced=24
+    __pwrite64_chk; # introduced=24
+    __write_chk; # introduced=24
+    adjtimex; # introduced=24
+    clock_adjtime; # introduced=24
+    fgetpos64; # introduced=24
+    fileno_unlocked; # introduced=24
+    fopen64; # introduced=24
+    freeifaddrs; # introduced=24
+    freopen64; # introduced=24
+    fseeko64; # introduced=24
+    fsetpos64; # introduced=24
+    ftello64; # introduced=24
+    funopen64; # introduced=24
+    getgrgid_r; # introduced=24
+    getgrnam_r; # introduced=24
+    getifaddrs; # introduced=24
+    if_freenameindex; # introduced=24
+    if_nameindex; # introduced=24
+    in6addr_any; # var introduced=24
+    in6addr_loopback; # var introduced=24
+    lockf; # introduced=24
+    lockf64; # introduced=24
+    preadv; # introduced=24
+    preadv64; # introduced=24
+    prlimit; # arm mips x86 introduced=24
+    pthread_barrierattr_destroy; # introduced=24
+    pthread_barrierattr_getpshared; # introduced=24
+    pthread_barrierattr_init; # introduced=24
+    pthread_barrierattr_setpshared; # introduced=24
+    pthread_barrier_destroy; # introduced=24
+    pthread_barrier_init; # introduced=24
+    pthread_barrier_wait; # introduced=24
+    pthread_spin_destroy; # introduced=24
+    pthread_spin_init; # introduced=24
+    pthread_spin_lock; # introduced=24
+    pthread_spin_trylock; # introduced=24
+    pthread_spin_unlock; # introduced=24
+    pwritev; # introduced=24
+    pwritev64; # introduced=24
+    scandirat; # introduced=24
+    scandirat64; # introduced=24
+    strchrnul; # introduced=24
+    tmpfile64; # introduced=24
 } LIBC;
 
+LIBC_O {
+  global:
+    bsd_signal; # arm x86 mips versioned=26
+    catclose; # future
+    catgets; # future
+    catopen; # future
+    ctermid; # future
+    endgrent; # future
+    endpwent; # future
+    futimes; # future
+    futimesat; # future
+    getdomainname; # future
+    getgrent; # future
+    getpwent; # future
+    getsubopt; # future
+    hasmntopt; # future
+    lutimes; # future
+    mblen; # future
+    msgctl; # future
+    msgget; # future
+    msgrcv; # future
+    msgsnd; # future
+    pthread_getname_np; # future
+    quotactl; # future
+    semctl; # future
+    semget; # future
+    semop; # future
+    semtimedop; # future
+    setdomainname; # future
+    setgrent; # future
+    setpwent; # future
+    shmat; # future
+    shmctl; # future
+    shmdt; # future
+    shmget; # future
+    sighold; # future
+    sigignore; # future
+    sigpause; # future
+    sigrelse; # future
+    sigset; # future
+    strtod_l; # future
+    strtof_l; # future
+    strtol_l; # future
+    strtoul_l; # future
+    sync_file_range; # future
+    towctrans; # future
+    towctrans_l; # future
+    wctrans; # future
+    wctrans_l; # future
+} LIBC_N;
+
 LIBC_PRIVATE {
   global:
     ___Unwind_Backtrace; # arm
@@ -1387,11 +1437,11 @@
     __floatundisf; # arm
     __floatunsidf; # arm
     __floatunsisf; # arm
-    __futex_wait; # arm x86 mips nobrillo
-    __futex_wake; # arm x86 mips nobrillo
+    __futex_wait; # arm x86 mips
+    __futex_wake; # arm x86 mips
     __gedf2; # arm
-    __get_thread; # arm x86 mips nobrillo
-    __get_tls; # arm x86 mips nobrillo
+    __get_thread; # arm x86 mips
+    __get_tls; # arm x86 mips
     __getdents64; # arm x86 mips
     __gnu_ldivmod_helper; # arm
     __gnu_uldivmod_helper; # arm
@@ -1421,21 +1471,21 @@
     __muldi3; # arm
     __mulsf3; # arm
     __nedf2; # arm
-    __open; # arm x86 mips nobrillo
-    __page_shift; # arm x86 mips nobrillo
-    __page_size; # arm x86 mips nobrillo
+    __open; # arm x86 mips
+    __page_shift; # arm x86 mips
+    __page_size; # arm x86 mips
     __popcount_tab; # arm
     __popcountsi2; # arm x86 mips
-    __pthread_gettid; # arm x86 mips nobrillo
+    __pthread_gettid; # arm x86 mips
     __restore_core_regs; # arm
     __sclose; # arm x86 mips
-    __sdidinit; # arm x86 mips nobrillo
-    __set_errno; # arm x86 mips nobrillo
+    __sdidinit; # arm x86 mips
+    __set_errno; # arm x86 mips
     __sflags; # arm x86 mips
     __sflush; # arm x86 mips
     __sfp; # arm x86 mips
     __sglue; # arm x86 mips
-    __sinit; # arm x86 mips nobrillo
+    __sinit; # arm x86 mips
     __smakebuf; # arm x86 mips
     __sread; # arm x86 mips
     __srefill; # arm x86 mips
@@ -1452,7 +1502,7 @@
     __umoddi3; # x86 mips
     __unorddf2; # arm
     __unordsf2; # arm
-    __wait4; # arm x86 mips nobrillo
+    __wait4; # arm x86 mips
     _fwalk; # arm x86 mips
     _Unwind_Backtrace; # arm
     _Unwind_Complete; # arm
@@ -1473,43 +1523,41 @@
     android_getaddrinfofornetcontext;
     android_gethostbyaddrfornet;
     android_gethostbynamefornet;
-    arc4random_addrandom; # arm x86 mips nobrillo
-    arc4random_stir; # arm x86 mips nobrillo
+    arc4random_addrandom; # arm x86 mips
+    arc4random_stir; # arm x86 mips
     atexit; # arm
-    bcopy; # arm x86 mips nobrillo
-    bzero; # arm x86 mips nobrillo
-    bsd_signal; # arm x86 mips nobrillo
-    dlmalloc; # arm x86 mips nobrillo
-    dlmalloc_inspect_all; # arm x86 mips nobrillo
-    dlmalloc_trim; # arm x86 mips nobrillo
-    dlmalloc_usable_size; # arm x86 mips nobrillo
-    endpwent; # arm x86 mips nobrillo
-    fdprintf; # arm x86 mips nobrillo
+    bcopy; # arm x86 mips
+    bzero; # arm x86 mips
+    dlmalloc; # arm x86 mips
+    dlmalloc_inspect_all; # arm x86 mips
+    dlmalloc_trim; # arm x86 mips
+    dlmalloc_usable_size; # arm x86 mips
+    fdprintf; # arm x86 mips
     free_malloc_leak_info;
-    ftime; # arm x86 mips nobrillo
+    ftime; # arm x86 mips
     get_malloc_leak_info;
-    getdents; # arm x86 mips nobrillo
-    getdtablesize; # arm x86 mips nobrillo
+    getdents; # arm x86 mips
+    getdtablesize; # arm x86 mips
     gMallocLeakZygoteChild;
-    index; # arm x86 mips nobrillo
-    issetugid; # arm x86 mips nobrillo
-    memswap; # arm x86 mips nobrillo
-    pthread_attr_getstackaddr; # arm x86 mips nobrillo
-    pthread_attr_setstackaddr; # arm x86 mips nobrillo
+    index; # arm x86 mips
+    issetugid; # arm x86 mips
+    memswap; # arm x86 mips
+    pthread_attr_getstackaddr; # arm x86 mips
+    pthread_attr_setstackaddr; # arm x86 mips
     restore_core_regs; # arm
     SHA1Final; # arm x86 mips
     SHA1Init; # arm x86 mips
     SHA1Transform; # arm x86 mips
     SHA1Update; # arm x86 mips
-    strntoimax; # arm x86 mips nobrillo
-    strntoumax; # arm x86 mips nobrillo
-    strtotimeval; # arm x86 mips nobrillo
-    sysv_signal; # arm x86 mips nobrillo
-    tkill; # arm x86 mips nobrillo
-    vfdprintf; # arm x86 mips nobrillo
-    wait3; # arm x86 mips nobrillo
-    wcswcs; # arm x86 mips nobrillo
-} LIBC_N;
+    strntoimax; # arm x86 mips
+    strntoumax; # arm x86 mips
+    strtotimeval; # arm x86 mips
+    sysv_signal; # arm x86 mips
+    tkill; # arm x86 mips
+    vfdprintf; # arm x86 mips
+    wait3; # arm x86 mips
+    wcswcs; # arm x86 mips
+} LIBC_O;
 
 LIBC_PLATFORM {
   global:
@@ -1520,4 +1568,4 @@
     malloc_disable;
     malloc_enable;
     malloc_iterate;
-} LIBC_N;
+} LIBC_O;
diff --git a/libc/libc.mips.brillo.map b/libc/libc.mips.brillo.map
deleted file mode 100644
index d11a5ab..0000000
--- a/libc/libc.mips.brillo.map
+++ /dev/null
@@ -1,1299 +0,0 @@
-# Generated by genversionscripts.py. Do not edit.
-LIBC {
-  global:
-    __assert;
-    __assert2;
-    __b64_ntop;
-    __b64_pton;
-    __brk; # arm x86 mips
-    __cmsg_nxthdr;
-    __connect; # arm x86 mips
-    __ctype_get_mb_cur_max;
-    __cxa_atexit;
-    __cxa_finalize;
-    __cxa_thread_atexit_impl;
-    __dn_comp;
-    __dn_count_labels;
-    __dn_skipname;
-    __epoll_pwait; # arm x86 mips
-    __errno;
-    __exit; # arm x86 mips
-    __fadvise64; # x86 mips
-    __fbufsize;
-    __fcntl64; # arm x86 mips
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
-    __fp_nquery;
-    __fp_query;
-    __fpclassify;
-    __fpclassifyd;
-    __fpclassifyf;
-    __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
-    __fstatfs64; # arm x86 mips
-    __fwritable;
-    __get_h_errno;
-    __getcpu; # arm x86 mips
-    __getcwd; # arm x86 mips
-    __getpid; # arm x86 mips
-    __getpriority; # arm x86 mips
-    __gnu_basename;
-    __gnu_strerror_r;
-    __hostalias;
-    __ioctl; # arm x86 mips
-    __isfinite;
-    __isfinitef;
-    __isfinitel;
-    __isinf;
-    __isinff;
-    __isinfl;
-    __isnan;
-    __isnanf;
-    __isnanl;
-    __isnormal;
-    __isnormalf;
-    __isnormall;
-    __isthreaded; # arm x86 mips
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
-    __libc_init;
-    __llseek; # arm x86 mips
-    __loc_aton;
-    __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
-    __mmap2; # arm x86 mips
-    __ns_format_ttl; # arm x86 mips
-    __ns_get16; # arm x86 mips
-    __ns_get32; # arm x86 mips
-    __ns_initparse; # arm x86 mips
-    __ns_makecanon; # arm x86 mips
-    __ns_msg_getflag; # arm x86 mips
-    __ns_name_compress; # arm x86 mips
-    __ns_name_ntol; # arm x86 mips
-    __ns_name_ntop; # arm x86 mips
-    __ns_name_pack; # arm x86 mips
-    __ns_name_pton; # arm x86 mips
-    __ns_name_rollback; # arm x86 mips
-    __ns_name_skip; # arm x86 mips
-    __ns_name_uncompress; # arm x86 mips
-    __ns_name_unpack; # arm x86 mips
-    __ns_parserr; # arm x86 mips
-    __ns_put16; # arm x86 mips
-    __ns_put32; # arm x86 mips
-    __ns_samename; # arm x86 mips
-    __ns_skiprr; # arm x86 mips
-    __ns_sprintrr; # arm x86 mips
-    __ns_sprintrrf; # arm x86 mips
-    __open_2;
-    __openat; # arm x86 mips
-    __openat_2;
-    __p_cdname;
-    __p_cdnname;
-    __p_class;
-    __p_class_syms;
-    __p_fqname;
-    __p_fqnname;
-    __p_option;
-    __p_query;
-    __p_rcode;
-    __p_secstodate;
-    __p_time;
-    __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll; # arm x86 mips
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
-    __pselect6; # arm x86 mips
-    __pthread_cleanup_pop;
-    __pthread_cleanup_push;
-    __ptrace; # arm x86 mips
-    __putlong;
-    __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
-    __reboot; # arm x86 mips
-    __recvfrom_chk;
-    __register_atfork;
-    __res_close;
-    __res_dnok;
-    __res_hnok;
-    __res_hostalias;
-    __res_isourserver;
-    __res_mailok;
-    __res_nameinquery;
-    __res_nclose;
-    __res_ninit;
-    __res_nmkquery;
-    __res_nquery;
-    __res_nquerydomain;
-    __res_nsearch;
-    __res_nsend;
-    __res_ownok;
-    __res_queriesmatch;
-    __res_querydomain;
-    __res_send;
-    __res_send_setqhook;
-    __res_send_setrhook;
-    __rt_sigaction; # arm x86 mips
-    __rt_sigpending; # arm x86 mips
-    __rt_sigprocmask; # arm x86 mips
-    __rt_sigsuspend; # arm x86 mips
-    __rt_sigtimedwait; # arm x86 mips
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sched_getaffinity; # arm x86 mips
-    __set_tid_address; # arm x86 mips
-    __set_tls; # arm mips
-    __sF;
-    __sigaction; # arm x86 mips
-    __snprintf_chk;
-    __socket; # arm x86 mips
-    __sprintf_chk;
-    __stack_chk_fail;
-    __stack_chk_guard;
-    __statfs64; # arm x86 mips
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
-    __sym_ntop;
-    __sym_ntos;
-    __sym_ston;
-    __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
-    __system_property_find;
-    __system_property_find_nth;
-    __system_property_foreach;
-    __system_property_get;
-    __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
-    __timer_create; # arm x86 mips
-    __timer_delete; # arm x86 mips
-    __timer_getoverrun; # arm x86 mips
-    __timer_gettime; # arm x86 mips
-    __timer_settime; # arm x86 mips
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
-    __waitid; # arm x86 mips
-    _ctype_;
-    _Exit;
-    _exit;
-    _flush_cache; # mips
-    _flushlbf;
-    _getlong;
-    _getshort;
-    _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
-    _setjmp;
-    _tolower;
-    _tolower_tab_; # arm x86 mips
-    _toupper;
-    _toupper_tab_; # arm x86 mips
-    abort;
-    abs;
-    accept;
-    accept4;
-    access;
-    acct;
-    alarm;
-    alphasort;
-    alphasort64;
-    android_set_abort_message;
-    arc4random;
-    arc4random_buf;
-    arc4random_uniform;
-    asctime;
-    asctime64; # arm x86 mips
-    asctime64_r; # arm x86 mips
-    asctime_r;
-    asprintf;
-    at_quick_exit;
-    atof;
-    atoi;
-    atol;
-    atoll;
-    basename;
-    basename_r; # arm x86 mips
-    bind;
-    bindresvport;
-    brk;
-    bsearch;
-    btowc;
-    c16rtomb;
-    c32rtomb;
-    cacheflush; # arm mips
-    calloc;
-    capget;
-    capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
-    chdir;
-    chmod;
-    chown;
-    chroot;
-    clearenv;
-    clearerr;
-    clearerr_unlocked;
-    clock;
-    clock_getcpuclockid;
-    clock_getres;
-    clock_gettime;
-    clock_nanosleep;
-    clock_settime;
-    clone;
-    close;
-    closedir;
-    closelog;
-    connect;
-    creat;
-    creat64;
-    ctime;
-    ctime64; # arm x86 mips
-    ctime64_r; # arm x86 mips
-    ctime_r;
-    daemon;
-    daylight;
-    delete_module;
-    difftime;
-    dirfd;
-    dirname;
-    dirname_r; # arm x86 mips
-    div;
-    dn_expand;
-    dprintf;
-    drand48;
-    dup;
-    dup2;
-    dup3;
-    duplocale;
-    endmntent;
-    endservent;
-    endutent;
-    environ;
-    epoll_create;
-    epoll_create1;
-    epoll_ctl;
-    epoll_pwait;
-    epoll_wait;
-    erand48;
-    err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
-    errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
-    eventfd;
-    eventfd_read;
-    eventfd_write;
-    execl;
-    execle;
-    execlp;
-    execv;
-    execve;
-    execvp;
-    execvpe;
-    exit;
-    faccessat;
-    fallocate;
-    fallocate64;
-    fchdir;
-    fchmod;
-    fchmodat;
-    fchown;
-    fchownat;
-    fclose;
-    fcntl;
-    fdatasync;
-    fdopen;
-    fdopendir;
-    feof;
-    feof_unlocked;
-    ferror;
-    ferror_unlocked;
-    fflush;
-    ffs;
-    fgetc;
-    fgetln;
-    fgetpos;
-    fgets;
-    fgetwc;
-    fgetws;
-    fgetxattr;
-    fileno;
-    flistxattr;
-    flock;
-    flockfile;
-    fmemopen;
-    fnmatch;
-    fopen;
-    fork;
-    forkpty;
-    fpathconf;
-    fprintf;
-    fpurge;
-    fputc;
-    fputs;
-    fputwc;
-    fputws;
-    fread;
-    free;
-    freeaddrinfo;
-    freelocale;
-    fremovexattr;
-    freopen;
-    fscanf;
-    fseek;
-    fseeko;
-    fsetpos;
-    fsetxattr;
-    fstat;
-    fstat64;
-    fstatat;
-    fstatat64;
-    fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
-    fsync;
-    ftell;
-    ftello;
-    ftok;
-    ftruncate;
-    ftruncate64;
-    ftrylockfile;
-    fts_children;
-    fts_close;
-    fts_open;
-    fts_read;
-    fts_set;
-    ftw;
-    ftw64;
-    funlockfile;
-    funopen;
-    futimens;
-    fwide;
-    fwprintf;
-    fwrite;
-    fwscanf;
-    gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
-    getaddrinfo;
-    getauxval;
-    getc;
-    getc_unlocked;
-    getchar;
-    getchar_unlocked;
-    getcwd;
-    getdelim;
-    getegid;
-    getenv;
-    geteuid;
-    getgid;
-    getgrgid;
-    getgrnam;
-    getgrouplist;
-    getgroups;
-    gethostbyaddr;
-    gethostbyaddr_r;
-    gethostbyname;
-    gethostbyname2;
-    gethostbyname2_r;
-    gethostbyname_r;
-    gethostent;
-    gethostname;
-    getitimer;
-    getline;
-    getlogin;
-    getmntent;
-    getmntent_r;
-    getnameinfo;
-    getnetbyaddr;
-    getnetbyname;
-    getopt;
-    getopt_long;
-    getopt_long_only;
-    getpagesize;
-    getpeername;
-    getpgid;
-    getpgrp;
-    getpid;
-    getppid;
-    getpriority;
-    getprogname;
-    getprotobyname;
-    getprotobynumber;
-    getpt;
-    getpwnam;
-    getpwnam_r;
-    getpwuid;
-    getpwuid_r;
-    getresgid;
-    getresuid;
-    getrlimit;
-    getrlimit64;
-    getrusage;
-    gets;
-    getservbyname;
-    getservbyport;
-    getservent;
-    getsid;
-    getsockname;
-    getsockopt;
-    gettid;
-    gettimeofday;
-    getuid;
-    getutent;
-    getwc;
-    getwchar;
-    getxattr;
-    gmtime;
-    gmtime64; # arm x86 mips
-    gmtime64_r; # arm x86 mips
-    gmtime_r;
-    grantpt;
-    herror;
-    hstrerror;
-    htonl;
-    htons;
-    if_indextoname;
-    if_nametoindex;
-    imaxabs;
-    imaxdiv;
-    inet_addr;
-    inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
-    inet_nsap_addr;
-    inet_nsap_ntoa;
-    inet_ntoa;
-    inet_ntop;
-    inet_pton;
-    init_module;
-    initgroups;
-    initstate;
-    inotify_add_watch;
-    inotify_init;
-    inotify_init1;
-    inotify_rm_watch;
-    insque;
-    ioctl;
-    isalnum;
-    isalnum_l;
-    isalpha;
-    isalpha_l;
-    isascii;
-    isatty;
-    isblank;
-    isblank_l;
-    iscntrl;
-    iscntrl_l;
-    isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
-    isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
-    islower;
-    islower_l;
-    isnan;
-    isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
-    isprint;
-    isprint_l;
-    ispunct;
-    ispunct_l;
-    isspace;
-    isspace_l;
-    isupper;
-    isupper_l;
-    iswalnum;
-    iswalnum_l;
-    iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
-    iswcntrl;
-    iswcntrl_l;
-    iswctype;
-    iswctype_l;
-    iswdigit;
-    iswdigit_l;
-    iswgraph;
-    iswgraph_l;
-    iswlower;
-    iswlower_l;
-    iswprint;
-    iswprint_l;
-    iswpunct;
-    iswpunct_l;
-    iswspace;
-    iswspace_l;
-    iswupper;
-    iswupper_l;
-    iswxdigit;
-    iswxdigit_l;
-    isxdigit;
-    isxdigit_l;
-    jrand48;
-    kill;
-    killpg;
-    klogctl;
-    labs;
-    lchown;
-    lcong48;
-    ldexp;
-    ldiv;
-    lfind;
-    lgetxattr;
-    link;
-    linkat;
-    listen;
-    listxattr;
-    llabs;
-    lldiv;
-    llistxattr;
-    localeconv;
-    localtime;
-    localtime64; # arm x86 mips
-    localtime64_r; # arm x86 mips
-    localtime_r;
-    login_tty;
-    longjmp;
-    lrand48;
-    lremovexattr;
-    lsearch;
-    lseek;
-    lseek64;
-    lsetxattr;
-    lstat;
-    lstat64;
-    madvise;
-    mallinfo;
-    malloc;
-    malloc_info;
-    malloc_usable_size;
-    mbrlen;
-    mbrtoc16;
-    mbrtoc32;
-    mbrtowc;
-    mbsinit;
-    mbsnrtowcs;
-    mbsrtowcs;
-    mbstowcs;
-    mbtowc;
-    memalign;
-    memccpy;
-    memchr;
-    memcmp;
-    memcpy;
-    memmem;
-    memmove;
-    mempcpy;
-    memrchr;
-    memset;
-    mincore;
-    mkdir;
-    mkdirat;
-    mkdtemp;
-    mkfifo;
-    mkfifoat;
-    mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
-    mkstemp;
-    mkstemp64;
-    mkstemps;
-    mkstemps64;
-    mktemp;
-    mktime;
-    mktime64; # arm x86 mips
-    mlock;
-    mlockall;
-    mmap;
-    mmap64;
-    mount;
-    mprotect;
-    mrand48;
-    mremap;
-    msync;
-    munlock;
-    munlockall;
-    munmap;
-    nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
-    nice;
-    nrand48;
-    nsdispatch;
-    ntohl;
-    ntohs;
-    open;
-    open64;
-    open_memstream;
-    open_wmemstream;
-    openat;
-    openat64;
-    opendir;
-    openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
-    pathconf;
-    pause;
-    pclose;
-    perror;
-    personality;
-    pipe;
-    pipe2;
-    poll;
-    popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
-    prctl;
-    pread;
-    pread64;
-    printf;
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
-    pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
-    pthread_attr_destroy;
-    pthread_attr_getdetachstate;
-    pthread_attr_getguardsize;
-    pthread_attr_getschedparam;
-    pthread_attr_getschedpolicy;
-    pthread_attr_getscope;
-    pthread_attr_getstack;
-    pthread_attr_getstacksize;
-    pthread_attr_init;
-    pthread_attr_setdetachstate;
-    pthread_attr_setguardsize;
-    pthread_attr_setschedparam;
-    pthread_attr_setschedpolicy;
-    pthread_attr_setscope;
-    pthread_attr_setstack;
-    pthread_attr_setstacksize;
-    pthread_cond_broadcast;
-    pthread_cond_destroy;
-    pthread_cond_init;
-    pthread_cond_signal;
-    pthread_cond_timedwait;
-    pthread_cond_timedwait_monotonic; # arm x86 mips
-    pthread_cond_timedwait_monotonic_np; # arm x86 mips
-    pthread_cond_timedwait_relative_np; # arm x86 mips
-    pthread_cond_timeout_np; # arm x86 mips
-    pthread_cond_wait;
-    pthread_condattr_destroy;
-    pthread_condattr_getclock;
-    pthread_condattr_getpshared;
-    pthread_condattr_init;
-    pthread_condattr_setclock;
-    pthread_condattr_setpshared;
-    pthread_create;
-    pthread_detach;
-    pthread_equal;
-    pthread_exit;
-    pthread_getattr_np;
-    pthread_getcpuclockid;
-    pthread_getschedparam;
-    pthread_getspecific;
-    pthread_gettid_np;
-    pthread_join;
-    pthread_key_create;
-    pthread_key_delete;
-    pthread_kill;
-    pthread_mutex_destroy;
-    pthread_mutex_init;
-    pthread_mutex_lock;
-    pthread_mutex_lock_timeout_np; # arm x86 mips
-    pthread_mutex_timedlock;
-    pthread_mutex_trylock;
-    pthread_mutex_unlock;
-    pthread_mutexattr_destroy;
-    pthread_mutexattr_getpshared;
-    pthread_mutexattr_gettype;
-    pthread_mutexattr_init;
-    pthread_mutexattr_setpshared;
-    pthread_mutexattr_settype;
-    pthread_once;
-    pthread_rwlock_destroy;
-    pthread_rwlock_init;
-    pthread_rwlock_rdlock;
-    pthread_rwlock_timedrdlock;
-    pthread_rwlock_timedwrlock;
-    pthread_rwlock_tryrdlock;
-    pthread_rwlock_trywrlock;
-    pthread_rwlock_unlock;
-    pthread_rwlock_wrlock;
-    pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
-    pthread_rwlockattr_getpshared;
-    pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
-    pthread_rwlockattr_setpshared;
-    pthread_self;
-    pthread_setname_np;
-    pthread_setschedparam;
-    pthread_setspecific;
-    pthread_sigmask;
-    ptrace;
-    ptsname;
-    ptsname_r;
-    putc;
-    putc_unlocked;
-    putchar;
-    putchar_unlocked;
-    putenv;
-    puts;
-    pututline;
-    putw; # arm x86 mips
-    putwc;
-    putwchar;
-    pvalloc; # arm x86 mips
-    pwrite;
-    pwrite64;
-    qsort;
-    quick_exit;
-    raise;
-    rand;
-    rand_r;
-    random;
-    read;
-    readahead;
-    readdir;
-    readdir64;
-    readdir64_r;
-    readdir_r;
-    readlink;
-    readlinkat;
-    readv;
-    realloc;
-    realpath;
-    reboot;
-    recv;
-    recvfrom;
-    recvmmsg;
-    recvmsg;
-    regcomp;
-    regerror;
-    regexec;
-    regfree;
-    remove;
-    removexattr;
-    remque;
-    rename;
-    renameat;
-    res_init;
-    res_mkquery;
-    res_query;
-    res_search;
-    rewind;
-    rewinddir;
-    rmdir;
-    sbrk;
-    scandir;
-    scandir64;
-    scanf;
-    sched_get_priority_max;
-    sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
-    sched_getparam;
-    sched_getscheduler;
-    sched_rr_get_interval;
-    sched_setaffinity;
-    sched_setparam;
-    sched_setscheduler;
-    sched_yield;
-    seed48;
-    seekdir;
-    select;
-    sem_close;
-    sem_destroy;
-    sem_getvalue;
-    sem_init;
-    sem_open;
-    sem_post;
-    sem_timedwait;
-    sem_trywait;
-    sem_unlink;
-    sem_wait;
-    send;
-    sendfile;
-    sendfile64;
-    sendmmsg;
-    sendmsg;
-    sendto;
-    setbuf;
-    setbuffer;
-    setegid;
-    setenv;
-    seteuid;
-    setfsgid;
-    setfsuid;
-    setgid;
-    setgroups;
-    sethostname;
-    setitimer;
-    setjmp;
-    setlinebuf;
-    setlocale;
-    setlogmask;
-    setmntent;
-    setns;
-    setpgid;
-    setpgrp;
-    setpriority;
-    setprogname;
-    setregid;
-    setresgid;
-    setresuid;
-    setreuid;
-    setrlimit;
-    setrlimit64;
-    setservent;
-    setsid;
-    setsockopt;
-    setstate;
-    settimeofday;
-    setuid;
-    setutent;
-    setvbuf;
-    setxattr;
-    shutdown;
-    sigaction;
-    sigaddset;
-    sigaltstack;
-    sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
-    siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
-    sigpending;
-    sigprocmask;
-    sigqueue;
-    sigsetjmp;
-    sigsetmask;
-    sigsuspend;
-    sigtimedwait;
-    sigwait;
-    sigwaitinfo;
-    sleep;
-    snprintf;
-    socket;
-    socketpair;
-    splice;
-    sprintf;
-    srand;
-    srand48;
-    srandom;
-    sscanf;
-    stat;
-    stat64;
-    statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
-    strcasecmp;
-    strcasecmp_l;
-    strcasestr;
-    strcat;
-    strchr;
-    strcmp;
-    strcoll;
-    strcoll_l;
-    strcpy;
-    strcspn;
-    strdup;
-    strerror;
-    strerror_l;
-    strerror_r;
-    strftime;
-    strftime_l;
-    strlcat;
-    strlcpy;
-    strlen;
-    strncasecmp;
-    strncasecmp_l;
-    strncat;
-    strncmp;
-    strncpy;
-    strndup;
-    strnlen;
-    strpbrk;
-    strptime;
-    strrchr;
-    strsep;
-    strsignal;
-    strspn;
-    strstr;
-    strtod;
-    strtof;
-    strtoimax;
-    strtok;
-    strtok_r;
-    strtol;
-    strtold;
-    strtold_l;
-    strtoll;
-    strtoll_l;
-    strtoq;
-    strtoul;
-    strtoull;
-    strtoull_l;
-    strtoumax;
-    strtouq;
-    strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
-    swprintf;
-    swscanf;
-    symlink;
-    symlinkat;
-    sync;
-    sys_siglist;
-    sys_signame;
-    syscall;
-    sysconf;
-    sysinfo;
-    syslog;
-    system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
-    tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
-    tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
-    tempnam;
-    tfind;
-    tgkill;
-    time;
-    timegm;
-    timegm64; # arm x86 mips
-    timelocal;
-    timelocal64; # arm x86 mips
-    timer_create;
-    timer_delete;
-    timer_getoverrun;
-    timer_gettime;
-    timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
-    times;
-    timezone;
-    tmpfile;
-    tmpnam;
-    toascii;
-    tolower;
-    tolower_l;
-    toupper;
-    toupper_l;
-    towlower;
-    towlower_l;
-    towupper;
-    towupper_l;
-    truncate;
-    truncate64;
-    tsearch;
-    ttyname;
-    ttyname_r;
-    twalk;
-    tzname;
-    tzset;
-    umask;
-    umount;
-    umount2;
-    uname;
-    ungetc;
-    ungetwc;
-    unlink;
-    unlinkat;
-    unlockpt;
-    unsetenv;
-    unshare;
-    uselocale;
-    usleep;
-    utime;
-    utimensat;
-    utimes;
-    utmpname;
-    valloc; # arm x86 mips
-    vasprintf;
-    vdprintf;
-    verr;
-    verrx;
-    vfork;
-    vfprintf;
-    vfscanf;
-    vfwprintf;
-    vfwscanf;
-    vmsplice;
-    vprintf;
-    vscanf;
-    vsnprintf;
-    vsprintf;
-    vsscanf;
-    vswprintf;
-    vswscanf;
-    vsyslog;
-    vwarn;
-    vwarnx;
-    vwprintf;
-    vwscanf;
-    wait;
-    wait4;
-    waitid;
-    waitpid;
-    warn;
-    warnx;
-    wcpcpy;
-    wcpncpy;
-    wcrtomb;
-    wcscasecmp;
-    wcscasecmp_l;
-    wcscat;
-    wcschr;
-    wcscmp;
-    wcscoll;
-    wcscoll_l;
-    wcscpy;
-    wcscspn;
-    wcsdup;
-    wcsftime;
-    wcslcat;
-    wcslcpy;
-    wcslen;
-    wcsncasecmp;
-    wcsncasecmp_l;
-    wcsncat;
-    wcsncmp;
-    wcsncpy;
-    wcsnlen;
-    wcsnrtombs;
-    wcspbrk;
-    wcsrchr;
-    wcsrtombs;
-    wcsspn;
-    wcsstr;
-    wcstod;
-    wcstof;
-    wcstoimax;
-    wcstok;
-    wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
-    wcstombs;
-    wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
-    wcswidth;
-    wcsxfrm;
-    wcsxfrm_l;
-    wctob;
-    wctomb;
-    wctype;
-    wctype_l;
-    wcwidth;
-    wmemchr;
-    wmemcmp;
-    wmemcpy;
-    wmemmove;
-    wmempcpy;
-    wmemset;
-    wprintf;
-    write;
-    writev;
-    wscanf;
-  local:
-    *;
-};
-
-LIBC_N {
-  global:
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    prlimit; # arm mips x86
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
-} LIBC;
-
-LIBC_PRIVATE {
-  global:
-    __accept4; # arm x86 mips
-    __bionic_brk; # arm x86 mips
-    __divdi3; # arm x86 mips
-    __getdents64; # arm x86 mips
-    __popcountsi2; # arm x86 mips
-    __sclose; # arm x86 mips
-    __sflags; # arm x86 mips
-    __sflush; # arm x86 mips
-    __sfp; # arm x86 mips
-    __sglue; # arm x86 mips
-    __smakebuf; # arm x86 mips
-    __sread; # arm x86 mips
-    __srefill; # arm x86 mips
-    __srget; # arm x86 mips
-    __sseek; # arm x86 mips
-    __swbuf; # arm x86 mips
-    __swrite; # arm x86 mips
-    __swsetup; # arm x86 mips
-    __udivdi3; # arm x86 mips
-    __umoddi3; # x86 mips
-    _fwalk; # arm x86 mips
-    android_getaddrinfofornet;
-    android_getaddrinfofornetcontext;
-    android_gethostbyaddrfornet;
-    android_gethostbynamefornet;
-    free_malloc_leak_info;
-    get_malloc_leak_info;
-    gMallocLeakZygoteChild;
-    SHA1Final; # arm x86 mips
-    SHA1Init; # arm x86 mips
-    SHA1Transform; # arm x86 mips
-    SHA1Update; # arm x86 mips
-} LIBC_N;
-
-LIBC_PLATFORM {
-  global:
-    android_net_res_stats_get_info_for_net;
-    android_net_res_stats_aggregate;
-    android_net_res_stats_get_usable_servers;
-    malloc_backtrace;
-    malloc_disable;
-    malloc_enable;
-    malloc_iterate;
-} LIBC_N;
diff --git a/libc/libc.mips.map b/libc/libc.mips.map
index 46c835b..f61f615 100644
--- a/libc/libc.mips.map
+++ b/libc/libc.mips.map
@@ -1,50 +1,49 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
     __assert;
     __assert2;
     __b64_ntop;
     __b64_pton;
-    __brk; # arm x86 mips
-    __cmsg_nxthdr;
-    __connect; # arm x86 mips
-    __ctype_get_mb_cur_max;
+    __cmsg_nxthdr; # introduced=21
+    __connect; # arm x86 mips introduced=21
+    __ctype_get_mb_cur_max; # introduced=21
     __cxa_atexit;
     __cxa_finalize;
-    __cxa_thread_atexit_impl;
+    __cxa_thread_atexit_impl; # introduced=23
     __dn_comp;
     __dn_count_labels;
     __dn_skipname;
-    __epoll_pwait; # arm x86 mips
+    __epoll_pwait; # arm x86 mips introduced=21
     __errno;
-    __exit; # arm x86 mips
-    __fadvise64; # x86 mips
-    __fbufsize;
+    __exit; # arm x86 mips introduced=21
+    __fadvise64; # x86 mips introduced=21
+    __fbufsize; # introduced=23
     __fcntl64; # arm x86 mips
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
+    __FD_CLR_chk; # introduced=21
+    __FD_ISSET_chk; # introduced=21
+    __FD_SET_chk; # introduced=21
+    __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __flbf; # introduced=23
     __fp_nquery;
     __fp_query;
-    __fpclassify;
+    __fpclassify; # introduced=21
     __fpclassifyd;
     __fpclassifyf;
     __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
+    __fpending; # introduced=23
+    __fpurge; # introduced=23
+    __freadable; # introduced=23
+    __fsetlocking; # introduced=23
     __fstatfs64; # arm x86 mips
-    __fwritable;
+    __fwritable; # introduced=23
     __get_h_errno;
-    __getcpu; # arm x86 mips
+    __getcpu; # arm x86 mips introduced-arm=12 introduced-mips=16 introduced-x86=12
     __getcwd; # arm x86 mips
-    __getpid; # arm x86 mips
+    __getpid; # arm x86 mips introduced=21
     __getpriority; # arm x86 mips
-    __gnu_basename;
-    __gnu_strerror_r;
+    __gnu_basename; # introduced=23
+    __gnu_strerror_r; # introduced=23
     __hostalias;
     __ioctl; # arm x86 mips
     __isfinite;
@@ -53,24 +52,24 @@
     __isinf;
     __isinff;
     __isinfl;
-    __isnan;
-    __isnanf;
+    __isnan; # introduced=21
+    __isnanf; # introduced=21
     __isnanl;
     __isnormal;
     __isnormalf;
     __isnormall;
-    __isthreaded; # arm x86 mips
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
+    __isthreaded; # arm x86 mips var
+    __libc_current_sigrtmax; # introduced=21
+    __libc_current_sigrtmin; # introduced=21
     __libc_init;
     __llseek; # arm x86 mips
     __loc_aton;
     __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
+    __memchr_chk; # introduced=23
+    __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memrchr_chk; # introduced=23
+    __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __mmap2; # arm x86 mips
     __ns_format_ttl; # arm x86 mips
     __ns_get16; # arm x86 mips
@@ -94,13 +93,13 @@
     __ns_skiprr; # arm x86 mips
     __ns_sprintrr; # arm x86 mips
     __ns_sprintrrf; # arm x86 mips
-    __open_2;
+    __open_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __openat; # arm x86 mips
-    __openat_2;
+    __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __p_cdname;
     __p_cdnname;
     __p_class;
-    __p_class_syms;
+    __p_class_syms; # var
     __p_fqname;
     __p_fqnname;
     __p_option;
@@ -109,25 +108,25 @@
     __p_secstodate;
     __p_time;
     __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll; # arm x86 mips
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
-    __pselect6; # arm x86 mips
+    __p_type_syms; # var
+    __poll_chk; # introduced=23
+    __ppoll; # arm x86 mips introduced=21
+    __ppoll_chk; # introduced=23
+    __pread64_chk; # introduced=23
+    __pread_chk; # introduced=23
+    __progname; # var
+    __pselect6; # arm x86 mips introduced=21
     __pthread_cleanup_pop;
     __pthread_cleanup_push;
     __ptrace; # arm x86 mips
     __putlong;
     __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
+    __read_chk; # introduced=21
+    __readlink_chk; # introduced=23
+    __readlinkat_chk; # introduced=23
     __reboot; # arm x86 mips
-    __recvfrom_chk;
-    __register_atfork;
+    __recvfrom_chk; # introduced=21
+    __register_atfork; # introduced=23
     __res_close;
     __res_dnok;
     __res_hnok;
@@ -149,90 +148,90 @@
     __res_send_setqhook;
     __res_send_setrhook;
     __rt_sigaction; # arm x86 mips
-    __rt_sigpending; # arm x86 mips
+    __rt_sigpending; # arm x86 mips introduced=21
     __rt_sigprocmask; # arm x86 mips
-    __rt_sigsuspend; # arm x86 mips
+    __rt_sigsuspend; # arm x86 mips introduced=21
     __rt_sigtimedwait; # arm x86 mips
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sched_getaffinity; # arm x86 mips
-    __set_tid_address; # arm x86 mips
+    __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_getaffinity; # arm x86 mips introduced=12
+    __set_tid_address; # arm x86 mips introduced=21
     __set_tls; # arm mips
-    __sF;
-    __sigaction; # arm x86 mips
-    __snprintf_chk;
-    __socket; # arm x86 mips
-    __sprintf_chk;
+    __sF; # var
+    __sigaction; # arm x86 mips introduced=21
+    __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __socket; # arm x86 mips introduced=21
+    __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __stack_chk_fail;
-    __stack_chk_guard;
+    __stack_chk_guard; # var
     __statfs64; # arm x86 mips
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
+    __stpcpy_chk; # introduced=21
+    __stpncpy_chk; # introduced=21
+    __stpncpy_chk2; # introduced=21
+    __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk2; # introduced=21
+    __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     __sym_ntop;
     __sym_ntos;
     __sym_ston;
     __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
+    __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area__; # var
+    __system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area_serial; # introduced=23
     __system_property_find;
     __system_property_find_nth;
-    __system_property_foreach;
+    __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __system_property_get;
     __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
+    __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __timer_create; # arm x86 mips
     __timer_delete; # arm x86 mips
     __timer_getoverrun; # arm x86 mips
     __timer_gettime; # arm x86 mips
     __timer_settime; # arm x86 mips
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
+    __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __waitid; # arm x86 mips
-    _ctype_;
-    _Exit;
+    _ctype_; # var
+    _Exit; # introduced=21
     _exit;
     _flush_cache; # mips
-    _flushlbf;
+    _flushlbf; # introduced=23
     _getlong;
     _getshort;
     _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
+    _resolv_delete_cache_for_net; # introduced=21
+    _resolv_flush_cache_for_net; # introduced=21
+    _resolv_set_nameservers_for_net; # introduced=21
     _setjmp;
-    _tolower;
-    _tolower_tab_; # arm x86 mips
-    _toupper;
-    _toupper_tab_; # arm x86 mips
+    _tolower; # introduced=21
+    _tolower_tab_; # arm x86 mips var
+    _toupper; # introduced=21
+    _toupper_tab_; # arm x86 mips var
     abort;
-    abs;
+    abs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     accept;
-    accept4;
+    accept4; # introduced=21
     access;
     acct;
     alarm;
     alphasort;
-    alphasort64;
-    android_set_abort_message;
+    alphasort64; # introduced=21
+    android_set_abort_message; # introduced=21
     arc4random;
     arc4random_buf;
     arc4random_uniform;
@@ -241,8 +240,8 @@
     asctime64_r; # arm x86 mips
     asctime_r;
     asprintf;
-    at_quick_exit;
-    atof;
+    at_quick_exit; # introduced=21
+    atof; # introduced=21
     atoi;
     atol;
     atoll;
@@ -253,44 +252,44 @@
     brk;
     bsearch;
     btowc;
-    c16rtomb;
-    c32rtomb;
+    c16rtomb; # introduced=21
+    c32rtomb; # introduced=21
     cacheflush; # arm mips
     calloc;
     capget;
     capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
+    cfgetispeed; # introduced=21
+    cfgetospeed; # introduced=21
+    cfmakeraw; # introduced=21
+    cfsetispeed; # introduced=21
+    cfsetospeed; # introduced=21
+    cfsetspeed; # introduced=21
     chdir;
     chmod;
     chown;
     chroot;
     clearenv;
     clearerr;
-    clearerr_unlocked;
+    clearerr_unlocked; # introduced=23
     clock;
-    clock_getcpuclockid;
+    clock_getcpuclockid; # introduced=23
     clock_getres;
     clock_gettime;
     clock_nanosleep;
     clock_settime;
-    clone;
+    clone; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     close;
     closedir;
     closelog;
     connect;
     creat;
-    creat64;
+    creat64; # introduced=21
     ctime;
     ctime64; # arm x86 mips
     ctime64_r; # arm x86 mips
     ctime_r;
     daemon;
-    daylight;
+    daylight; # var
     delete_module;
     difftime;
     dirfd;
@@ -298,33 +297,33 @@
     dirname_r; # arm x86 mips
     div;
     dn_expand;
-    dprintf;
+    dprintf; # introduced=21
     drand48;
     dup;
     dup2;
-    dup3;
-    duplocale;
-    endmntent;
+    dup3; # introduced=21
+    duplocale; # introduced=21
+    endmntent; # introduced=21
     endservent;
     endutent;
-    environ;
+    environ; # var
     epoll_create;
-    epoll_create1;
+    epoll_create1; # introduced=21
     epoll_ctl;
-    epoll_pwait;
+    epoll_pwait; # introduced=21
     epoll_wait;
     erand48;
     err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
+    error; # introduced=23
+    error_at_line; # introduced=23
+    error_message_count; # var introduced=23
+    error_one_per_line; # var introduced=23
+    error_print_progname; # var introduced=23
     errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
+    ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     eventfd;
     eventfd_read;
     eventfd_write;
@@ -334,11 +333,11 @@
     execv;
     execve;
     execvp;
-    execvpe;
+    execvpe; # introduced=21
     exit;
-    faccessat;
-    fallocate;
-    fallocate64;
+    faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    fallocate; # introduced=21
+    fallocate64; # introduced=21
     fchdir;
     fchmod;
     fchmodat;
@@ -350,27 +349,27 @@
     fdopen;
     fdopendir;
     feof;
-    feof_unlocked;
+    feof_unlocked; # introduced=23
     ferror;
-    ferror_unlocked;
+    ferror_unlocked; # introduced=23
     fflush;
-    ffs;
+    ffs; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     fgetc;
     fgetln;
     fgetpos;
     fgets;
     fgetwc;
     fgetws;
-    fgetxattr;
+    fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fileno;
-    flistxattr;
+    flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     flock;
     flockfile;
-    fmemopen;
+    fmemopen; # introduced=23
     fnmatch;
     fopen;
     fork;
-    forkpty;
+    forkpty; # introduced=23
     fpathconf;
     fprintf;
     fpurge;
@@ -381,56 +380,56 @@
     fread;
     free;
     freeaddrinfo;
-    freelocale;
-    fremovexattr;
+    freelocale; # introduced=21
+    fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     freopen;
     fscanf;
     fseek;
     fseeko;
     fsetpos;
-    fsetxattr;
+    fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fstat;
-    fstat64;
+    fstat64; # introduced=21
     fstatat;
-    fstatat64;
+    fstatat64; # introduced=21
     fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
+    fstatfs64; # introduced=21
+    fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    fstatvfs64; # introduced=21
     fsync;
     ftell;
     ftello;
     ftok;
     ftruncate;
-    ftruncate64;
+    ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     ftrylockfile;
     fts_children;
     fts_close;
     fts_open;
     fts_read;
     fts_set;
-    ftw;
-    ftw64;
+    ftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    ftw64; # introduced=21
     funlockfile;
     funopen;
-    futimens;
+    futimens; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     fwide;
     fwprintf;
     fwrite;
     fwscanf;
     gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
+    get_avphys_pages; # introduced=23
+    get_nprocs; # introduced=23
+    get_nprocs_conf; # introduced=23
+    get_phys_pages; # introduced=23
     getaddrinfo;
-    getauxval;
+    getauxval; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getc;
     getc_unlocked;
     getchar;
     getchar_unlocked;
     getcwd;
-    getdelim;
+    getdelim; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getegid;
     getenv;
     geteuid;
@@ -440,49 +439,49 @@
     getgrouplist;
     getgroups;
     gethostbyaddr;
-    gethostbyaddr_r;
+    gethostbyaddr_r; # introduced=23
     gethostbyname;
     gethostbyname2;
-    gethostbyname2_r;
+    gethostbyname2_r; # introduced=23
     gethostbyname_r;
     gethostent;
     gethostname;
     getitimer;
-    getline;
+    getline; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getlogin;
     getmntent;
-    getmntent_r;
+    getmntent_r; # introduced=21
     getnameinfo;
     getnetbyaddr;
     getnetbyname;
     getopt;
     getopt_long;
     getopt_long_only;
-    getpagesize;
+    getpagesize; # introduced=21
     getpeername;
     getpgid;
     getpgrp;
     getpid;
     getppid;
     getpriority;
-    getprogname;
+    getprogname; # introduced=21
     getprotobyname;
     getprotobynumber;
     getpt;
     getpwnam;
-    getpwnam_r;
+    getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getpwuid;
-    getpwuid_r;
+    getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getresgid;
     getresuid;
     getrlimit;
-    getrlimit64;
+    getrlimit64; # introduced=21
     getrusage;
     gets;
     getservbyname;
     getservbyport;
     getservent;
-    getsid;
+    getsid; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     getsockname;
     getsockopt;
     gettid;
@@ -491,26 +490,26 @@
     getutent;
     getwc;
     getwchar;
-    getxattr;
+    getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     gmtime;
     gmtime64; # arm x86 mips
     gmtime64_r; # arm x86 mips
     gmtime_r;
-    grantpt;
+    grantpt; # introduced=21
     herror;
     hstrerror;
-    htonl;
-    htons;
+    htonl; # introduced=21
+    htons; # introduced=21
     if_indextoname;
     if_nametoindex;
-    imaxabs;
-    imaxdiv;
+    imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     inet_addr;
     inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
+    inet_lnaof; # introduced=21
+    inet_makeaddr; # introduced=21
+    inet_netof; # introduced=21
+    inet_network; # introduced=21
     inet_nsap_addr;
     inet_nsap_ntoa;
     inet_ntoa;
@@ -518,124 +517,124 @@
     inet_pton;
     init_module;
     initgroups;
-    initstate;
+    initstate; # introduced=21
     inotify_add_watch;
     inotify_init;
-    inotify_init1;
+    inotify_init1; # introduced=21
     inotify_rm_watch;
-    insque;
+    insque; # introduced=21
     ioctl;
     isalnum;
-    isalnum_l;
+    isalnum_l; # introduced=21
     isalpha;
-    isalpha_l;
+    isalpha_l; # introduced=21
     isascii;
     isatty;
     isblank;
-    isblank_l;
+    isblank_l; # introduced=21
     iscntrl;
-    iscntrl_l;
+    iscntrl_l; # introduced=21
     isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
+    isdigit_l; # introduced=21
+    isfinite; # introduced=21
+    isfinitef; # introduced=21
+    isfinitel; # introduced=21
     isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
+    isgraph_l; # introduced=21
+    isinf; # introduced=21
+    isinff; # introduced=21
+    isinfl; # introduced=21
     islower;
-    islower_l;
+    islower_l; # introduced=21
     isnan;
     isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
+    isnanl; # introduced=21
+    isnormal; # introduced=21
+    isnormalf; # introduced=21
+    isnormall; # introduced=21
     isprint;
-    isprint_l;
+    isprint_l; # introduced=21
     ispunct;
-    ispunct_l;
+    ispunct_l; # introduced=21
     isspace;
-    isspace_l;
+    isspace_l; # introduced=21
     isupper;
-    isupper_l;
+    isupper_l; # introduced=21
     iswalnum;
-    iswalnum_l;
+    iswalnum_l; # introduced=21
     iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
+    iswalpha_l; # introduced=21
+    iswblank; # introduced=21
+    iswblank_l; # introduced=21
     iswcntrl;
-    iswcntrl_l;
+    iswcntrl_l; # introduced=21
     iswctype;
-    iswctype_l;
+    iswctype_l; # introduced=21
     iswdigit;
-    iswdigit_l;
+    iswdigit_l; # introduced=21
     iswgraph;
-    iswgraph_l;
+    iswgraph_l; # introduced=21
     iswlower;
-    iswlower_l;
+    iswlower_l; # introduced=21
     iswprint;
-    iswprint_l;
+    iswprint_l; # introduced=21
     iswpunct;
-    iswpunct_l;
+    iswpunct_l; # introduced=21
     iswspace;
-    iswspace_l;
+    iswspace_l; # introduced=21
     iswupper;
-    iswupper_l;
+    iswupper_l; # introduced=21
     iswxdigit;
-    iswxdigit_l;
+    iswxdigit_l; # introduced=21
     isxdigit;
-    isxdigit_l;
+    isxdigit_l; # introduced=21
     jrand48;
     kill;
     killpg;
     klogctl;
-    labs;
+    labs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lchown;
-    lcong48;
+    lcong48; # introduced=23
     ldexp;
     ldiv;
-    lfind;
-    lgetxattr;
+    lfind; # introduced=21
+    lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     link;
-    linkat;
+    linkat; # introduced=21
     listen;
-    listxattr;
-    llabs;
+    listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lldiv;
-    llistxattr;
-    localeconv;
+    llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    localeconv; # introduced=21
     localtime;
     localtime64; # arm x86 mips
     localtime64_r; # arm x86 mips
     localtime_r;
-    login_tty;
+    login_tty; # introduced=23
     longjmp;
     lrand48;
-    lremovexattr;
-    lsearch;
+    lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    lsearch; # introduced=21
     lseek;
     lseek64;
-    lsetxattr;
+    lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     lstat;
-    lstat64;
+    lstat64; # introduced=21
     madvise;
     mallinfo;
     malloc;
-    malloc_info;
-    malloc_usable_size;
+    malloc_info; # introduced=23
+    malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mbrlen;
-    mbrtoc16;
-    mbrtoc32;
+    mbrtoc16; # introduced=21
+    mbrtoc32; # introduced=21
     mbrtowc;
     mbsinit;
-    mbsnrtowcs;
+    mbsnrtowcs; # introduced=21
     mbsrtowcs;
     mbstowcs;
-    mbtowc;
+    mbtowc; # introduced=21
     memalign;
     memccpy;
     memchr;
@@ -643,91 +642,91 @@
     memcpy;
     memmem;
     memmove;
-    mempcpy;
+    mempcpy; # introduced=23
     memrchr;
     memset;
     mincore;
     mkdir;
     mkdirat;
     mkdtemp;
-    mkfifo;
-    mkfifoat;
+    mkfifo; # introduced=21
+    mkfifoat; # introduced=23
     mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
+    mknodat; # introduced=21
+    mkostemp; # introduced=23
+    mkostemp64; # introduced=23
+    mkostemps; # introduced=23
+    mkostemps64; # introduced=23
     mkstemp;
-    mkstemp64;
+    mkstemp64; # introduced=21
     mkstemps;
-    mkstemps64;
+    mkstemps64; # introduced=23
     mktemp;
     mktime;
     mktime64; # arm x86 mips
     mlock;
-    mlockall;
+    mlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mmap;
-    mmap64;
+    mmap64; # introduced=21
     mount;
     mprotect;
     mrand48;
     mremap;
     msync;
     munlock;
-    munlockall;
+    munlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     munmap;
     nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
+    newlocale; # introduced=21
+    nftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    nftw64; # introduced=21
     nice;
     nrand48;
     nsdispatch;
-    ntohl;
-    ntohs;
+    ntohl; # introduced=21
+    ntohs; # introduced=21
     open;
-    open64;
-    open_memstream;
-    open_wmemstream;
+    open64; # introduced=21
+    open_memstream; # introduced=23
+    open_wmemstream; # introduced=23
     openat;
-    openat64;
+    openat64; # introduced=21
     opendir;
     openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
+    openpty; # introduced=23
+    optarg; # var
+    opterr; # var
+    optind; # var
+    optopt; # var
+    optreset; # var
     pathconf;
     pause;
     pclose;
     perror;
-    personality;
+    personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
     pipe;
     pipe2;
     poll;
     popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
+    posix_fadvise; # introduced=21
+    posix_fadvise64; # introduced=21
+    posix_fallocate; # introduced=21
+    posix_fallocate64; # introduced=21
+    posix_madvise; # introduced=23
+    posix_memalign; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    posix_openpt; # introduced=21
+    ppoll; # introduced=21
     prctl;
     pread;
-    pread64;
+    pread64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     printf;
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
+    prlimit64; # introduced=21
+    process_vm_readv; # introduced=23
+    process_vm_writev; # introduced=23
     pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
+    psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    psignal; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     pthread_attr_destroy;
     pthread_attr_getdetachstate;
     pthread_attr_getguardsize;
@@ -755,10 +754,10 @@
     pthread_cond_timeout_np; # arm x86 mips
     pthread_cond_wait;
     pthread_condattr_destroy;
-    pthread_condattr_getclock;
+    pthread_condattr_getclock; # introduced=21
     pthread_condattr_getpshared;
     pthread_condattr_init;
-    pthread_condattr_setclock;
+    pthread_condattr_setclock; # introduced=21
     pthread_condattr_setpshared;
     pthread_create;
     pthread_detach;
@@ -768,7 +767,7 @@
     pthread_getcpuclockid;
     pthread_getschedparam;
     pthread_getspecific;
-    pthread_gettid_np;
+    pthread_gettid_np; # introduced=21
     pthread_join;
     pthread_key_create;
     pthread_key_delete;
@@ -777,7 +776,7 @@
     pthread_mutex_init;
     pthread_mutex_lock;
     pthread_mutex_lock_timeout_np; # arm x86 mips
-    pthread_mutex_timedlock;
+    pthread_mutex_timedlock; # introduced=21
     pthread_mutex_trylock;
     pthread_mutex_unlock;
     pthread_mutexattr_destroy;
@@ -797,10 +796,10 @@
     pthread_rwlock_unlock;
     pthread_rwlock_wrlock;
     pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getkind_np; # introduced=23
     pthread_rwlockattr_getpshared;
     pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setkind_np; # introduced=23
     pthread_rwlockattr_setpshared;
     pthread_self;
     pthread_setname_np;
@@ -820,38 +819,38 @@
     putw; # arm x86 mips
     putwc;
     putwchar;
-    pvalloc; # arm x86 mips
+    pvalloc; # arm x86 mips introduced=17
     pwrite;
-    pwrite64;
+    pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     qsort;
-    quick_exit;
+    quick_exit; # introduced=21
     raise;
-    rand;
-    rand_r;
-    random;
+    rand; # introduced=21
+    rand_r; # introduced=21
+    random; # introduced=21
     read;
-    readahead;
+    readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     readdir;
-    readdir64;
-    readdir64_r;
+    readdir64; # introduced=21
+    readdir64_r; # introduced=21
     readdir_r;
     readlink;
-    readlinkat;
+    readlinkat; # introduced=21
     readv;
     realloc;
     realpath;
     reboot;
     recv;
     recvfrom;
-    recvmmsg;
+    recvmmsg; # introduced=21
     recvmsg;
     regcomp;
     regerror;
     regexec;
     regfree;
     remove;
-    removexattr;
-    remque;
+    removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    remque; # introduced=21
     rename;
     renameat;
     res_init;
@@ -863,21 +862,21 @@
     rmdir;
     sbrk;
     scandir;
-    scandir64;
+    scandir64; # introduced=21
     scanf;
     sched_get_priority_max;
     sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
+    sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_getparam;
     sched_getscheduler;
     sched_rr_get_interval;
-    sched_setaffinity;
+    sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_setparam;
     sched_setscheduler;
     sched_yield;
     seed48;
-    seekdir;
+    seekdir; # introduced=23
     select;
     sem_close;
     sem_destroy;
@@ -891,8 +890,8 @@
     sem_wait;
     send;
     sendfile;
-    sendfile64;
-    sendmmsg;
+    sendfile64; # introduced=21
+    sendmmsg; # introduced=21
     sendmsg;
     sendto;
     setbuf;
@@ -900,101 +899,101 @@
     setegid;
     setenv;
     seteuid;
-    setfsgid;
-    setfsuid;
+    setfsgid; # introduced=21
+    setfsuid; # introduced=21
     setgid;
     setgroups;
-    sethostname;
+    sethostname; # introduced=23
     setitimer;
     setjmp;
     setlinebuf;
     setlocale;
     setlogmask;
-    setmntent;
-    setns;
+    setmntent; # introduced=21
+    setns; # introduced=21
     setpgid;
     setpgrp;
     setpriority;
-    setprogname;
+    setprogname; # introduced=21
     setregid;
     setresgid;
     setresuid;
     setreuid;
     setrlimit;
-    setrlimit64;
+    setrlimit64; # introduced=21
     setservent;
     setsid;
     setsockopt;
-    setstate;
+    setstate; # introduced=21
     settimeofday;
     setuid;
     setutent;
     setvbuf;
-    setxattr;
+    setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     shutdown;
     sigaction;
-    sigaddset;
+    sigaddset; # introduced=21
     sigaltstack;
     sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
+    sigdelset; # introduced=21
+    sigemptyset; # introduced=21
+    sigfillset; # introduced=21
     siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
+    sigismember; # introduced=21
+    siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    signal; # introduced=21
+    signalfd; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     sigpending;
     sigprocmask;
-    sigqueue;
-    sigsetjmp;
+    sigqueue; # introduced=23
+    sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sigsetmask;
     sigsuspend;
-    sigtimedwait;
+    sigtimedwait; # introduced=23
     sigwait;
-    sigwaitinfo;
+    sigwaitinfo; # introduced=23
     sleep;
     snprintf;
     socket;
     socketpair;
-    splice;
+    splice; # introduced=21
     sprintf;
-    srand;
+    srand; # introduced=21
     srand48;
-    srandom;
+    srandom; # introduced=21
     sscanf;
     stat;
-    stat64;
+    stat64; # introduced=21
     statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
+    statfs64; # introduced=21
+    statvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    statvfs64; # introduced=21
+    stderr; # var introduced=23
+    stdin; # var introduced=23
+    stdout; # var introduced=23
+    stpcpy; # introduced=21
+    stpncpy; # introduced=21
     strcasecmp;
-    strcasecmp_l;
+    strcasecmp_l; # introduced=23
     strcasestr;
     strcat;
     strchr;
     strcmp;
     strcoll;
-    strcoll_l;
+    strcoll_l; # introduced=21
     strcpy;
     strcspn;
     strdup;
     strerror;
-    strerror_l;
+    strerror_l; # introduced=23
     strerror_r;
     strftime;
-    strftime_l;
+    strftime_l; # introduced=21
     strlcat;
     strlcpy;
     strlen;
     strncasecmp;
-    strncasecmp_l;
+    strncasecmp_l; # introduced=23
     strncat;
     strncmp;
     strncpy;
@@ -1008,86 +1007,86 @@
     strspn;
     strstr;
     strtod;
-    strtof;
+    strtof; # introduced=21
     strtoimax;
     strtok;
     strtok_r;
     strtol;
-    strtold;
-    strtold_l;
+    strtold; # introduced=21
+    strtold_l; # introduced=21
     strtoll;
-    strtoll_l;
-    strtoq;
+    strtoll_l; # introduced=21
+    strtoq; # introduced=21
     strtoul;
     strtoull;
-    strtoull_l;
+    strtoull_l; # introduced=21
     strtoumax;
-    strtouq;
+    strtouq; # introduced=21
     strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
+    strxfrm_l; # introduced=21
+    swapoff; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    swapon; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     swprintf;
     swscanf;
     symlink;
-    symlinkat;
+    symlinkat; # introduced=21
     sync;
-    sys_siglist;
-    sys_signame;
+    sys_siglist; # var
+    sys_signame; # var
     syscall;
     sysconf;
     sysinfo;
     syslog;
     system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
+    tcdrain; # introduced=21
+    tcflow; # introduced=21
+    tcflush; # introduced=21
+    tcgetattr; # introduced=21
     tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
+    tcgetsid; # introduced=21
+    tcsendbreak; # introduced=21
+    tcsetattr; # introduced=21
     tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
+    tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tee; # introduced=21
+    telldir; # introduced=23
     tempnam;
-    tfind;
-    tgkill;
+    tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     time;
-    timegm;
+    timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timegm64; # arm x86 mips
-    timelocal;
+    timelocal; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timelocal64; # arm x86 mips
     timer_create;
     timer_delete;
     timer_getoverrun;
     timer_gettime;
     timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
+    timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     times;
-    timezone;
+    timezone; # var
     tmpfile;
     tmpnam;
     toascii;
     tolower;
-    tolower_l;
+    tolower_l; # introduced=21
     toupper;
-    toupper_l;
+    toupper_l; # introduced=21
     towlower;
-    towlower_l;
+    towlower_l; # introduced=21
     towupper;
-    towupper_l;
+    towupper_l; # introduced=21
     truncate;
-    truncate64;
-    tsearch;
+    truncate64; # introduced=21
+    tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     ttyname;
     ttyname_r;
-    twalk;
-    tzname;
+    twalk; # introduced=21
+    tzname; # var
     tzset;
     umask;
     umount;
@@ -1099,38 +1098,38 @@
     unlinkat;
     unlockpt;
     unsetenv;
-    unshare;
-    uselocale;
+    unshare; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    uselocale; # introduced=21
     usleep;
     utime;
-    utimensat;
+    utimensat; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     utimes;
     utmpname;
     valloc; # arm x86 mips
     vasprintf;
-    vdprintf;
+    vdprintf; # introduced=21
     verr;
     verrx;
     vfork;
     vfprintf;
     vfscanf;
     vfwprintf;
-    vfwscanf;
-    vmsplice;
+    vfwscanf; # introduced=21
+    vmsplice; # introduced=21
     vprintf;
     vscanf;
     vsnprintf;
     vsprintf;
     vsscanf;
     vswprintf;
-    vswscanf;
+    vswscanf; # introduced=21
     vsyslog;
     vwarn;
     vwarnx;
     vwprintf;
-    vwscanf;
+    vwscanf; # introduced=21
     wait;
-    wait4;
+    wait4; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     waitid;
     waitpid;
     warn;
@@ -1139,12 +1138,12 @@
     wcpncpy;
     wcrtomb;
     wcscasecmp;
-    wcscasecmp_l;
+    wcscasecmp_l; # introduced=23
     wcscat;
     wcschr;
     wcscmp;
     wcscoll;
-    wcscoll_l;
+    wcscoll_l; # introduced=21
     wcscpy;
     wcscspn;
     wcsdup;
@@ -1153,44 +1152,44 @@
     wcslcpy;
     wcslen;
     wcsncasecmp;
-    wcsncasecmp_l;
+    wcsncasecmp_l; # introduced=23
     wcsncat;
     wcsncmp;
     wcsncpy;
     wcsnlen;
-    wcsnrtombs;
+    wcsnrtombs; # introduced=21
     wcspbrk;
     wcsrchr;
     wcsrtombs;
     wcsspn;
     wcsstr;
     wcstod;
-    wcstof;
-    wcstoimax;
+    wcstof; # introduced=21
+    wcstoimax; # introduced=21
     wcstok;
     wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
+    wcstold; # introduced=21
+    wcstold_l; # introduced=21
+    wcstoll; # introduced=21
+    wcstoll_l; # introduced=21
     wcstombs;
     wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
+    wcstoull; # introduced=21
+    wcstoull_l; # introduced=21
+    wcstoumax; # introduced=21
     wcswidth;
     wcsxfrm;
-    wcsxfrm_l;
+    wcsxfrm_l; # introduced=21
     wctob;
-    wctomb;
+    wctomb; # introduced=21
     wctype;
-    wctype_l;
+    wctype_l; # introduced=21
     wcwidth;
     wmemchr;
     wmemcmp;
     wmemcpy;
     wmemmove;
-    wmempcpy;
+    wmempcpy; # introduced=23
     wmemset;
     wprintf;
     write;
@@ -1200,80 +1199,131 @@
     *;
 };
 
-LIBC_N {
+LIBC_N { # introduced-arm64=24 introduced-mips=24 introduced-mips64=24 introduced-x86=24 introduced-x86_64=24
   global:
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    prlimit; # arm mips x86
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
+    __fread_chk; # introduced=24
+    __fwrite_chk; # introduced=24
+    __getcwd_chk; # introduced=24
+    __pwrite_chk; # introduced=24
+    __pwrite64_chk; # introduced=24
+    __write_chk; # introduced=24
+    adjtimex; # introduced=24
+    clock_adjtime; # introduced=24
+    fgetpos64; # introduced=24
+    fileno_unlocked; # introduced=24
+    fopen64; # introduced=24
+    freeifaddrs; # introduced=24
+    freopen64; # introduced=24
+    fseeko64; # introduced=24
+    fsetpos64; # introduced=24
+    ftello64; # introduced=24
+    funopen64; # introduced=24
+    getgrgid_r; # introduced=24
+    getgrnam_r; # introduced=24
+    getifaddrs; # introduced=24
+    if_freenameindex; # introduced=24
+    if_nameindex; # introduced=24
+    in6addr_any; # var introduced=24
+    in6addr_loopback; # var introduced=24
+    lockf; # introduced=24
+    lockf64; # introduced=24
+    preadv; # introduced=24
+    preadv64; # introduced=24
+    prlimit; # arm mips x86 introduced=24
+    pthread_barrierattr_destroy; # introduced=24
+    pthread_barrierattr_getpshared; # introduced=24
+    pthread_barrierattr_init; # introduced=24
+    pthread_barrierattr_setpshared; # introduced=24
+    pthread_barrier_destroy; # introduced=24
+    pthread_barrier_init; # introduced=24
+    pthread_barrier_wait; # introduced=24
+    pthread_spin_destroy; # introduced=24
+    pthread_spin_init; # introduced=24
+    pthread_spin_lock; # introduced=24
+    pthread_spin_trylock; # introduced=24
+    pthread_spin_unlock; # introduced=24
+    pwritev; # introduced=24
+    pwritev64; # introduced=24
+    scandirat; # introduced=24
+    scandirat64; # introduced=24
+    strchrnul; # introduced=24
+    tmpfile64; # introduced=24
 } LIBC;
 
+LIBC_O {
+  global:
+    bsd_signal; # arm x86 mips versioned=26
+    catclose; # future
+    catgets; # future
+    catopen; # future
+    ctermid; # future
+    endgrent; # future
+    endpwent; # future
+    futimes; # future
+    futimesat; # future
+    getdomainname; # future
+    getgrent; # future
+    getpwent; # future
+    getsubopt; # future
+    hasmntopt; # future
+    lutimes; # future
+    mblen; # future
+    msgctl; # future
+    msgget; # future
+    msgrcv; # future
+    msgsnd; # future
+    pthread_getname_np; # future
+    quotactl; # future
+    semctl; # future
+    semget; # future
+    semop; # future
+    semtimedop; # future
+    setdomainname; # future
+    setgrent; # future
+    setpwent; # future
+    shmat; # future
+    shmctl; # future
+    shmdt; # future
+    shmget; # future
+    sighold; # future
+    sigignore; # future
+    sigpause; # future
+    sigrelse; # future
+    sigset; # future
+    strtod_l; # future
+    strtof_l; # future
+    strtol_l; # future
+    strtoul_l; # future
+    sync_file_range; # future
+    towctrans; # future
+    towctrans_l; # future
+    wctrans; # future
+    wctrans_l; # future
+} LIBC_N;
+
 LIBC_PRIVATE {
   global:
     __accept4; # arm x86 mips
     __bionic_brk; # arm x86 mips
     __divdi3; # arm x86 mips
-    __futex_wait; # arm x86 mips nobrillo
-    __futex_wake; # arm x86 mips nobrillo
-    __get_thread; # arm x86 mips nobrillo
-    __get_tls; # arm x86 mips nobrillo
+    __futex_wait; # arm x86 mips
+    __futex_wake; # arm x86 mips
+    __get_thread; # arm x86 mips
+    __get_tls; # arm x86 mips
     __getdents64; # arm x86 mips
-    __open; # arm x86 mips nobrillo
-    __page_shift; # arm x86 mips nobrillo
-    __page_size; # arm x86 mips nobrillo
+    __open; # arm x86 mips
+    __page_shift; # arm x86 mips
+    __page_size; # arm x86 mips
     __popcountsi2; # arm x86 mips
-    __pthread_gettid; # arm x86 mips nobrillo
+    __pthread_gettid; # arm x86 mips
     __sclose; # arm x86 mips
-    __sdidinit; # arm x86 mips nobrillo
-    __set_errno; # arm x86 mips nobrillo
+    __sdidinit; # arm x86 mips
+    __set_errno; # arm x86 mips
     __sflags; # arm x86 mips
     __sflush; # arm x86 mips
     __sfp; # arm x86 mips
     __sglue; # arm x86 mips
-    __sinit; # arm x86 mips nobrillo
+    __sinit; # arm x86 mips
     __smakebuf; # arm x86 mips
     __sread; # arm x86 mips
     __srefill; # arm x86 mips
@@ -1284,47 +1334,45 @@
     __swsetup; # arm x86 mips
     __udivdi3; # arm x86 mips
     __umoddi3; # x86 mips
-    __wait4; # arm x86 mips nobrillo
+    __wait4; # arm x86 mips
     _fwalk; # arm x86 mips
     android_getaddrinfofornet;
     android_getaddrinfofornetcontext;
     android_gethostbyaddrfornet;
     android_gethostbynamefornet;
-    arc4random_addrandom; # arm x86 mips nobrillo
-    arc4random_stir; # arm x86 mips nobrillo
-    bcopy; # arm x86 mips nobrillo
-    bzero; # arm x86 mips nobrillo
-    bsd_signal; # arm x86 mips nobrillo
-    dlmalloc; # arm x86 mips nobrillo
-    dlmalloc_inspect_all; # arm x86 mips nobrillo
-    dlmalloc_trim; # arm x86 mips nobrillo
-    dlmalloc_usable_size; # arm x86 mips nobrillo
-    endpwent; # arm x86 mips nobrillo
-    fdprintf; # arm x86 mips nobrillo
+    arc4random_addrandom; # arm x86 mips
+    arc4random_stir; # arm x86 mips
+    bcopy; # arm x86 mips
+    bzero; # arm x86 mips
+    dlmalloc; # arm x86 mips
+    dlmalloc_inspect_all; # arm x86 mips
+    dlmalloc_trim; # arm x86 mips
+    dlmalloc_usable_size; # arm x86 mips
+    fdprintf; # arm x86 mips
     free_malloc_leak_info;
-    ftime; # arm x86 mips nobrillo
+    ftime; # arm x86 mips
     get_malloc_leak_info;
-    getdents; # arm x86 mips nobrillo
-    getdtablesize; # arm x86 mips nobrillo
+    getdents; # arm x86 mips
+    getdtablesize; # arm x86 mips
     gMallocLeakZygoteChild;
-    index; # arm x86 mips nobrillo
-    issetugid; # arm x86 mips nobrillo
-    memswap; # arm x86 mips nobrillo
-    pthread_attr_getstackaddr; # arm x86 mips nobrillo
-    pthread_attr_setstackaddr; # arm x86 mips nobrillo
+    index; # arm x86 mips
+    issetugid; # arm x86 mips
+    memswap; # arm x86 mips
+    pthread_attr_getstackaddr; # arm x86 mips
+    pthread_attr_setstackaddr; # arm x86 mips
     SHA1Final; # arm x86 mips
     SHA1Init; # arm x86 mips
     SHA1Transform; # arm x86 mips
     SHA1Update; # arm x86 mips
-    strntoimax; # arm x86 mips nobrillo
-    strntoumax; # arm x86 mips nobrillo
-    strtotimeval; # arm x86 mips nobrillo
-    sysv_signal; # arm x86 mips nobrillo
-    tkill; # arm x86 mips nobrillo
-    vfdprintf; # arm x86 mips nobrillo
-    wait3; # arm x86 mips nobrillo
-    wcswcs; # arm x86 mips nobrillo
-} LIBC_N;
+    strntoimax; # arm x86 mips
+    strntoumax; # arm x86 mips
+    strtotimeval; # arm x86 mips
+    sysv_signal; # arm x86 mips
+    tkill; # arm x86 mips
+    vfdprintf; # arm x86 mips
+    wait3; # arm x86 mips
+    wcswcs; # arm x86 mips
+} LIBC_O;
 
 LIBC_PLATFORM {
   global:
@@ -1335,4 +1383,4 @@
     malloc_disable;
     malloc_enable;
     malloc_iterate;
-} LIBC_N;
+} LIBC_O;
diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map
index afbd0ee..28755d4 100644
--- a/libc/libc.mips64.map
+++ b/libc/libc.mips64.map
@@ -1,39 +1,39 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
     __assert;
     __assert2;
     __b64_ntop;
     __b64_pton;
-    __cmsg_nxthdr;
-    __ctype_get_mb_cur_max;
+    __cmsg_nxthdr; # introduced=21
+    __ctype_get_mb_cur_max; # introduced=21
     __cxa_atexit;
     __cxa_finalize;
-    __cxa_thread_atexit_impl;
+    __cxa_thread_atexit_impl; # introduced=23
     __dn_comp;
     __dn_count_labels;
     __dn_skipname;
     __errno;
-    __fbufsize;
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
+    __fbufsize; # introduced=23
+    __FD_CLR_chk; # introduced=21
+    __FD_ISSET_chk; # introduced=21
+    __FD_SET_chk; # introduced=21
+    __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __flbf; # introduced=23
     __fp_nquery;
     __fp_query;
-    __fpclassify;
+    __fpclassify; # introduced=21
     __fpclassifyd;
     __fpclassifyf;
     __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
-    __fwritable;
+    __fpending; # introduced=23
+    __fpurge; # introduced=23
+    __freadable; # introduced=23
+    __fsetlocking; # introduced=23
+    __fwritable; # introduced=23
     __get_h_errno;
-    __gnu_basename;
-    __gnu_strerror_r;
+    __gnu_basename; # introduced=23
+    __gnu_strerror_r; # introduced=23
     __hostalias;
     __isfinite;
     __isfinitef;
@@ -41,28 +41,28 @@
     __isinf;
     __isinff;
     __isinfl;
-    __isnan;
-    __isnanf;
+    __isnan; # introduced=21
+    __isnanf; # introduced=21
     __isnanl;
     __isnormal;
     __isnormalf;
     __isnormall;
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
+    __libc_current_sigrtmax; # introduced=21
+    __libc_current_sigrtmin; # introduced=21
     __libc_init;
     __loc_aton;
     __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
-    __open_2;
-    __openat_2;
+    __memchr_chk; # introduced=23
+    __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memrchr_chk; # introduced=23
+    __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __open_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __p_cdname;
     __p_cdnname;
     __p_class;
-    __p_class_syms;
+    __p_class_syms; # var
     __p_fqname;
     __p_fqnname;
     __p_option;
@@ -71,21 +71,21 @@
     __p_secstodate;
     __p_time;
     __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
+    __p_type_syms; # var
+    __poll_chk; # introduced=23
+    __ppoll_chk; # introduced=23
+    __pread64_chk; # introduced=23
+    __pread_chk; # introduced=23
+    __progname; # var
     __pthread_cleanup_pop;
     __pthread_cleanup_push;
     __putlong;
     __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
-    __recvfrom_chk;
-    __register_atfork;
+    __read_chk; # introduced=21
+    __readlink_chk; # introduced=23
+    __readlinkat_chk; # introduced=23
+    __recvfrom_chk; # introduced=21
+    __register_atfork; # introduced=23
     __res_close;
     __res_dnok;
     __res_hnok;
@@ -106,79 +106,79 @@
     __res_send;
     __res_send_setqhook;
     __res_send_setrhook;
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sF;
-    __snprintf_chk;
-    __sprintf_chk;
+    __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sF; # var
+    __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __stack_chk_fail;
-    __stack_chk_guard;
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
+    __stack_chk_guard; # var
+    __stpcpy_chk; # introduced=21
+    __stpncpy_chk; # introduced=21
+    __stpncpy_chk2; # introduced=21
+    __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk2; # introduced=21
+    __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     __sym_ntop;
     __sym_ntos;
     __sym_ston;
     __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
+    __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area__; # var
+    __system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area_serial; # introduced=23
     __system_property_find;
     __system_property_find_nth;
-    __system_property_foreach;
+    __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __system_property_get;
     __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
-    _ctype_;
-    _Exit;
+    __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    _ctype_; # var
+    _Exit; # introduced=21
     _exit;
-    _flushlbf;
+    _flushlbf; # introduced=23
     _getlong;
     _getshort;
     _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
+    _resolv_delete_cache_for_net; # introduced=21
+    _resolv_flush_cache_for_net; # introduced=21
+    _resolv_set_nameservers_for_net; # introduced=21
     _setjmp;
-    _tolower;
-    _toupper;
+    _tolower; # introduced=21
+    _toupper; # introduced=21
     abort;
-    abs;
+    abs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     accept;
-    accept4;
+    accept4; # introduced=21
     access;
     acct;
     alarm;
     alphasort;
-    alphasort64;
-    android_set_abort_message;
+    alphasort64; # introduced=21
+    android_set_abort_message; # introduced=21
     arc4random;
     arc4random_buf;
     arc4random_uniform;
     asctime;
     asctime_r;
     asprintf;
-    at_quick_exit;
-    atof;
+    at_quick_exit; # introduced=21
+    atof; # introduced=21
     atoi;
     atol;
     atoll;
@@ -188,74 +188,74 @@
     brk;
     bsearch;
     btowc;
-    c16rtomb;
-    c32rtomb;
+    c16rtomb; # introduced=21
+    c32rtomb; # introduced=21
     calloc;
     capget;
     capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
+    cfgetispeed; # introduced=21
+    cfgetospeed; # introduced=21
+    cfmakeraw; # introduced=21
+    cfsetispeed; # introduced=21
+    cfsetospeed; # introduced=21
+    cfsetspeed; # introduced=21
     chdir;
     chmod;
     chown;
     chroot;
     clearenv;
     clearerr;
-    clearerr_unlocked;
+    clearerr_unlocked; # introduced=23
     clock;
-    clock_getcpuclockid;
+    clock_getcpuclockid; # introduced=23
     clock_getres;
     clock_gettime;
     clock_nanosleep;
     clock_settime;
-    clone;
+    clone; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     close;
     closedir;
     closelog;
     connect;
     creat;
-    creat64;
+    creat64; # introduced=21
     ctime;
     ctime_r;
     daemon;
-    daylight;
+    daylight; # var
     delete_module;
     difftime;
     dirfd;
     dirname;
     div;
     dn_expand;
-    dprintf;
+    dprintf; # introduced=21
     drand48;
     dup;
     dup2;
-    dup3;
-    duplocale;
-    endmntent;
+    dup3; # introduced=21
+    duplocale; # introduced=21
+    endmntent; # introduced=21
     endservent;
     endutent;
-    environ;
+    environ; # var
     epoll_create;
-    epoll_create1;
+    epoll_create1; # introduced=21
     epoll_ctl;
-    epoll_pwait;
+    epoll_pwait; # introduced=21
     epoll_wait;
     erand48;
     err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
+    error; # introduced=23
+    error_at_line; # introduced=23
+    error_message_count; # var introduced=23
+    error_one_per_line; # var introduced=23
+    error_print_progname; # var introduced=23
     errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
+    ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     eventfd;
     eventfd_read;
     eventfd_write;
@@ -265,11 +265,11 @@
     execv;
     execve;
     execvp;
-    execvpe;
+    execvpe; # introduced=21
     exit;
-    faccessat;
-    fallocate;
-    fallocate64;
+    faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    fallocate; # introduced=21
+    fallocate64; # introduced=21
     fchdir;
     fchmod;
     fchmodat;
@@ -281,27 +281,27 @@
     fdopen;
     fdopendir;
     feof;
-    feof_unlocked;
+    feof_unlocked; # introduced=23
     ferror;
-    ferror_unlocked;
+    ferror_unlocked; # introduced=23
     fflush;
-    ffs;
+    ffs; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     fgetc;
     fgetln;
     fgetpos;
     fgets;
     fgetwc;
     fgetws;
-    fgetxattr;
+    fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fileno;
-    flistxattr;
+    flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     flock;
     flockfile;
-    fmemopen;
+    fmemopen; # introduced=23
     fnmatch;
     fopen;
     fork;
-    forkpty;
+    forkpty; # introduced=23
     fpathconf;
     fprintf;
     fpurge;
@@ -312,56 +312,56 @@
     fread;
     free;
     freeaddrinfo;
-    freelocale;
-    fremovexattr;
+    freelocale; # introduced=21
+    fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     freopen;
     fscanf;
     fseek;
     fseeko;
     fsetpos;
-    fsetxattr;
+    fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fstat;
-    fstat64;
+    fstat64; # introduced=21
     fstatat;
-    fstatat64;
+    fstatat64; # introduced=21
     fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
+    fstatfs64; # introduced=21
+    fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    fstatvfs64; # introduced=21
     fsync;
     ftell;
     ftello;
     ftok;
     ftruncate;
-    ftruncate64;
+    ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     ftrylockfile;
     fts_children;
     fts_close;
     fts_open;
     fts_read;
     fts_set;
-    ftw;
-    ftw64;
+    ftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    ftw64; # introduced=21
     funlockfile;
     funopen;
-    futimens;
+    futimens; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     fwide;
     fwprintf;
     fwrite;
     fwscanf;
     gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
+    get_avphys_pages; # introduced=23
+    get_nprocs; # introduced=23
+    get_nprocs_conf; # introduced=23
+    get_phys_pages; # introduced=23
     getaddrinfo;
-    getauxval;
+    getauxval; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getc;
     getc_unlocked;
     getchar;
     getchar_unlocked;
     getcwd;
-    getdelim;
+    getdelim; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getegid;
     getenv;
     geteuid;
@@ -371,49 +371,49 @@
     getgrouplist;
     getgroups;
     gethostbyaddr;
-    gethostbyaddr_r;
+    gethostbyaddr_r; # introduced=23
     gethostbyname;
     gethostbyname2;
-    gethostbyname2_r;
+    gethostbyname2_r; # introduced=23
     gethostbyname_r;
     gethostent;
     gethostname;
     getitimer;
-    getline;
+    getline; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getlogin;
     getmntent;
-    getmntent_r;
+    getmntent_r; # introduced=21
     getnameinfo;
     getnetbyaddr;
     getnetbyname;
     getopt;
     getopt_long;
     getopt_long_only;
-    getpagesize;
+    getpagesize; # introduced=21
     getpeername;
     getpgid;
     getpgrp;
     getpid;
     getppid;
     getpriority;
-    getprogname;
+    getprogname; # introduced=21
     getprotobyname;
     getprotobynumber;
     getpt;
     getpwnam;
-    getpwnam_r;
+    getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getpwuid;
-    getpwuid_r;
+    getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getresgid;
     getresuid;
     getrlimit;
-    getrlimit64;
+    getrlimit64; # introduced=21
     getrusage;
     gets;
     getservbyname;
     getservbyport;
     getservent;
-    getsid;
+    getsid; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     getsockname;
     getsockopt;
     gettid;
@@ -422,24 +422,24 @@
     getutent;
     getwc;
     getwchar;
-    getxattr;
+    getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     gmtime;
     gmtime_r;
-    grantpt;
+    grantpt; # introduced=21
     herror;
     hstrerror;
-    htonl;
-    htons;
+    htonl; # introduced=21
+    htons; # introduced=21
     if_indextoname;
     if_nametoindex;
-    imaxabs;
-    imaxdiv;
+    imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     inet_addr;
     inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
+    inet_lnaof; # introduced=21
+    inet_makeaddr; # introduced=21
+    inet_netof; # introduced=21
+    inet_network; # introduced=21
     inet_nsap_addr;
     inet_nsap_ntoa;
     inet_ntoa;
@@ -447,122 +447,122 @@
     inet_pton;
     init_module;
     initgroups;
-    initstate;
+    initstate; # introduced=21
     inotify_add_watch;
     inotify_init;
-    inotify_init1;
+    inotify_init1; # introduced=21
     inotify_rm_watch;
-    insque;
+    insque; # introduced=21
     ioctl;
     isalnum;
-    isalnum_l;
+    isalnum_l; # introduced=21
     isalpha;
-    isalpha_l;
+    isalpha_l; # introduced=21
     isascii;
     isatty;
     isblank;
-    isblank_l;
+    isblank_l; # introduced=21
     iscntrl;
-    iscntrl_l;
+    iscntrl_l; # introduced=21
     isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
+    isdigit_l; # introduced=21
+    isfinite; # introduced=21
+    isfinitef; # introduced=21
+    isfinitel; # introduced=21
     isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
+    isgraph_l; # introduced=21
+    isinf; # introduced=21
+    isinff; # introduced=21
+    isinfl; # introduced=21
     islower;
-    islower_l;
+    islower_l; # introduced=21
     isnan;
     isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
+    isnanl; # introduced=21
+    isnormal; # introduced=21
+    isnormalf; # introduced=21
+    isnormall; # introduced=21
     isprint;
-    isprint_l;
+    isprint_l; # introduced=21
     ispunct;
-    ispunct_l;
+    ispunct_l; # introduced=21
     isspace;
-    isspace_l;
+    isspace_l; # introduced=21
     isupper;
-    isupper_l;
+    isupper_l; # introduced=21
     iswalnum;
-    iswalnum_l;
+    iswalnum_l; # introduced=21
     iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
+    iswalpha_l; # introduced=21
+    iswblank; # introduced=21
+    iswblank_l; # introduced=21
     iswcntrl;
-    iswcntrl_l;
+    iswcntrl_l; # introduced=21
     iswctype;
-    iswctype_l;
+    iswctype_l; # introduced=21
     iswdigit;
-    iswdigit_l;
+    iswdigit_l; # introduced=21
     iswgraph;
-    iswgraph_l;
+    iswgraph_l; # introduced=21
     iswlower;
-    iswlower_l;
+    iswlower_l; # introduced=21
     iswprint;
-    iswprint_l;
+    iswprint_l; # introduced=21
     iswpunct;
-    iswpunct_l;
+    iswpunct_l; # introduced=21
     iswspace;
-    iswspace_l;
+    iswspace_l; # introduced=21
     iswupper;
-    iswupper_l;
+    iswupper_l; # introduced=21
     iswxdigit;
-    iswxdigit_l;
+    iswxdigit_l; # introduced=21
     isxdigit;
-    isxdigit_l;
+    isxdigit_l; # introduced=21
     jrand48;
     kill;
     killpg;
     klogctl;
-    labs;
+    labs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lchown;
-    lcong48;
+    lcong48; # introduced=23
     ldexp;
     ldiv;
-    lfind;
-    lgetxattr;
+    lfind; # introduced=21
+    lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     link;
-    linkat;
+    linkat; # introduced=21
     listen;
-    listxattr;
-    llabs;
+    listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lldiv;
-    llistxattr;
-    localeconv;
+    llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    localeconv; # introduced=21
     localtime;
     localtime_r;
-    login_tty;
+    login_tty; # introduced=23
     longjmp;
     lrand48;
-    lremovexattr;
-    lsearch;
+    lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    lsearch; # introduced=21
     lseek;
     lseek64;
-    lsetxattr;
+    lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     lstat;
-    lstat64;
+    lstat64; # introduced=21
     madvise;
     mallinfo;
     malloc;
-    malloc_info;
-    malloc_usable_size;
+    malloc_info; # introduced=23
+    malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mbrlen;
-    mbrtoc16;
-    mbrtoc32;
+    mbrtoc16; # introduced=21
+    mbrtoc32; # introduced=21
     mbrtowc;
     mbsinit;
-    mbsnrtowcs;
+    mbsnrtowcs; # introduced=21
     mbsrtowcs;
     mbstowcs;
-    mbtowc;
+    mbtowc; # introduced=21
     memalign;
     memccpy;
     memchr;
@@ -570,113 +570,113 @@
     memcpy;
     memmem;
     memmove;
-    mempcpy;
+    mempcpy; # introduced=23
     memrchr;
     memset;
     mincore;
     mkdir;
     mkdirat;
     mkdtemp;
-    mkfifo;
-    mkfifoat;
+    mkfifo; # introduced=21
+    mkfifoat; # introduced=23
     mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
+    mknodat; # introduced=21
+    mkostemp; # introduced=23
+    mkostemp64; # introduced=23
+    mkostemps; # introduced=23
+    mkostemps64; # introduced=23
     mkstemp;
-    mkstemp64;
+    mkstemp64; # introduced=21
     mkstemps;
-    mkstemps64;
+    mkstemps64; # introduced=23
     mktemp;
     mktime;
     mlock;
-    mlockall;
+    mlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mmap;
-    mmap64;
+    mmap64; # introduced=21
     mount;
     mprotect;
     mrand48;
     mremap;
     msync;
     munlock;
-    munlockall;
+    munlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     munmap;
     nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
+    newlocale; # introduced=21
+    nftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    nftw64; # introduced=21
     nice;
     nrand48;
-    ns_format_ttl; # arm64 x86_64 mips64
-    ns_get16; # arm64 x86_64 mips64
-    ns_get32; # arm64 x86_64 mips64
-    ns_initparse; # arm64 x86_64 mips64
-    ns_makecanon; # arm64 x86_64 mips64
-    ns_msg_getflag; # arm64 x86_64 mips64
-    ns_name_compress; # arm64 x86_64 mips64
-    ns_name_ntol; # arm64 x86_64 mips64
-    ns_name_ntop; # arm64 x86_64 mips64
-    ns_name_pack; # arm64 x86_64 mips64
-    ns_name_pton; # arm64 x86_64 mips64
-    ns_name_rollback; # arm64 x86_64 mips64
-    ns_name_skip; # arm64 x86_64 mips64
-    ns_name_uncompress; # arm64 x86_64 mips64
-    ns_name_unpack; # arm64 x86_64 mips64
-    ns_parserr; # arm64 x86_64 mips64
-    ns_put16; # arm64 x86_64 mips64
-    ns_put32; # arm64 x86_64 mips64
-    ns_samename; # arm64 x86_64 mips64
-    ns_skiprr; # arm64 x86_64 mips64
-    ns_sprintrr; # arm64 x86_64 mips64
-    ns_sprintrrf; # arm64 x86_64 mips64
+    ns_format_ttl; # arm64 x86_64 mips64 introduced=22
+    ns_get16; # arm64 x86_64 mips64 introduced=22
+    ns_get32; # arm64 x86_64 mips64 introduced=22
+    ns_initparse; # arm64 x86_64 mips64 introduced=22
+    ns_makecanon; # arm64 x86_64 mips64 introduced=22
+    ns_msg_getflag; # arm64 x86_64 mips64 introduced=22
+    ns_name_compress; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntol; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntop; # arm64 x86_64 mips64 introduced=22
+    ns_name_pack; # arm64 x86_64 mips64 introduced=22
+    ns_name_pton; # arm64 x86_64 mips64 introduced=23
+    ns_name_rollback; # arm64 x86_64 mips64 introduced=22
+    ns_name_skip; # arm64 x86_64 mips64 introduced=22
+    ns_name_uncompress; # arm64 x86_64 mips64 introduced=22
+    ns_name_unpack; # arm64 x86_64 mips64 introduced=22
+    ns_parserr; # arm64 x86_64 mips64 introduced=22
+    ns_put16; # arm64 x86_64 mips64 introduced=22
+    ns_put32; # arm64 x86_64 mips64 introduced=22
+    ns_samename; # arm64 x86_64 mips64 introduced=22
+    ns_skiprr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrrf; # arm64 x86_64 mips64 introduced=22
     nsdispatch;
-    ntohl;
-    ntohs;
+    ntohl; # introduced=21
+    ntohs; # introduced=21
     open;
-    open64;
-    open_memstream;
-    open_wmemstream;
+    open64; # introduced=21
+    open_memstream; # introduced=23
+    open_wmemstream; # introduced=23
     openat;
-    openat64;
+    openat64; # introduced=21
     opendir;
     openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
+    openpty; # introduced=23
+    optarg; # var
+    opterr; # var
+    optind; # var
+    optopt; # var
+    optreset; # var
     pathconf;
     pause;
     pclose;
     perror;
-    personality;
+    personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
     pipe;
     pipe2;
     poll;
     popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
+    posix_fadvise; # introduced=21
+    posix_fadvise64; # introduced=21
+    posix_fallocate; # introduced=21
+    posix_fallocate64; # introduced=21
+    posix_madvise; # introduced=23
+    posix_memalign; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    posix_openpt; # introduced=21
+    ppoll; # introduced=21
     prctl;
     pread;
-    pread64;
+    pread64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     printf;
     prlimit; # arm64 x86_64 mips64
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
+    prlimit64; # introduced=21
+    process_vm_readv; # introduced=23
+    process_vm_writev; # introduced=23
     pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
+    psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    psignal; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     pthread_attr_destroy;
     pthread_attr_getdetachstate;
     pthread_attr_getguardsize;
@@ -700,10 +700,10 @@
     pthread_cond_timedwait;
     pthread_cond_wait;
     pthread_condattr_destroy;
-    pthread_condattr_getclock;
+    pthread_condattr_getclock; # introduced=21
     pthread_condattr_getpshared;
     pthread_condattr_init;
-    pthread_condattr_setclock;
+    pthread_condattr_setclock; # introduced=21
     pthread_condattr_setpshared;
     pthread_create;
     pthread_detach;
@@ -713,7 +713,7 @@
     pthread_getcpuclockid;
     pthread_getschedparam;
     pthread_getspecific;
-    pthread_gettid_np;
+    pthread_gettid_np; # introduced=21
     pthread_join;
     pthread_key_create;
     pthread_key_delete;
@@ -721,7 +721,7 @@
     pthread_mutex_destroy;
     pthread_mutex_init;
     pthread_mutex_lock;
-    pthread_mutex_timedlock;
+    pthread_mutex_timedlock; # introduced=21
     pthread_mutex_trylock;
     pthread_mutex_unlock;
     pthread_mutexattr_destroy;
@@ -741,10 +741,10 @@
     pthread_rwlock_unlock;
     pthread_rwlock_wrlock;
     pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getkind_np; # introduced=23
     pthread_rwlockattr_getpshared;
     pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setkind_np; # introduced=23
     pthread_rwlockattr_setpshared;
     pthread_self;
     pthread_setname_np;
@@ -764,36 +764,36 @@
     putwc;
     putwchar;
     pwrite;
-    pwrite64;
+    pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     qsort;
-    quick_exit;
+    quick_exit; # introduced=21
     raise;
-    rand;
-    rand_r;
-    random;
+    rand; # introduced=21
+    rand_r; # introduced=21
+    random; # introduced=21
     read;
-    readahead;
+    readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     readdir;
-    readdir64;
-    readdir64_r;
+    readdir64; # introduced=21
+    readdir64_r; # introduced=21
     readdir_r;
     readlink;
-    readlinkat;
+    readlinkat; # introduced=21
     readv;
     realloc;
     realpath;
     reboot;
     recv;
     recvfrom;
-    recvmmsg;
+    recvmmsg; # introduced=21
     recvmsg;
     regcomp;
     regerror;
     regexec;
     regfree;
     remove;
-    removexattr;
-    remque;
+    removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    remque; # introduced=21
     rename;
     renameat;
     res_init;
@@ -805,21 +805,21 @@
     rmdir;
     sbrk;
     scandir;
-    scandir64;
+    scandir64; # introduced=21
     scanf;
     sched_get_priority_max;
     sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
+    sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_getparam;
     sched_getscheduler;
     sched_rr_get_interval;
-    sched_setaffinity;
+    sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_setparam;
     sched_setscheduler;
     sched_yield;
     seed48;
-    seekdir;
+    seekdir; # introduced=23
     select;
     sem_close;
     sem_destroy;
@@ -833,8 +833,8 @@
     sem_wait;
     send;
     sendfile;
-    sendfile64;
-    sendmmsg;
+    sendfile64; # introduced=21
+    sendmmsg; # introduced=21
     sendmsg;
     sendto;
     setbuf;
@@ -842,101 +842,101 @@
     setegid;
     setenv;
     seteuid;
-    setfsgid;
-    setfsuid;
+    setfsgid; # introduced=21
+    setfsuid; # introduced=21
     setgid;
     setgroups;
-    sethostname;
+    sethostname; # introduced=23
     setitimer;
     setjmp;
     setlinebuf;
     setlocale;
     setlogmask;
-    setmntent;
-    setns;
+    setmntent; # introduced=21
+    setns; # introduced=21
     setpgid;
     setpgrp;
     setpriority;
-    setprogname;
+    setprogname; # introduced=21
     setregid;
     setresgid;
     setresuid;
     setreuid;
     setrlimit;
-    setrlimit64;
+    setrlimit64; # introduced=21
     setservent;
     setsid;
     setsockopt;
-    setstate;
+    setstate; # introduced=21
     settimeofday;
     setuid;
     setutent;
     setvbuf;
-    setxattr;
+    setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     shutdown;
     sigaction;
-    sigaddset;
+    sigaddset; # introduced=21
     sigaltstack;
     sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
+    sigdelset; # introduced=21
+    sigemptyset; # introduced=21
+    sigfillset; # introduced=21
     siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
+    sigismember; # introduced=21
+    siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    signal; # introduced=21
+    signalfd; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     sigpending;
     sigprocmask;
-    sigqueue;
-    sigsetjmp;
+    sigqueue; # introduced=23
+    sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sigsetmask;
     sigsuspend;
-    sigtimedwait;
+    sigtimedwait; # introduced=23
     sigwait;
-    sigwaitinfo;
+    sigwaitinfo; # introduced=23
     sleep;
     snprintf;
     socket;
     socketpair;
-    splice;
+    splice; # introduced=21
     sprintf;
-    srand;
+    srand; # introduced=21
     srand48;
-    srandom;
+    srandom; # introduced=21
     sscanf;
     stat;
-    stat64;
+    stat64; # introduced=21
     statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
+    statfs64; # introduced=21
+    statvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    statvfs64; # introduced=21
+    stderr; # var introduced=23
+    stdin; # var introduced=23
+    stdout; # var introduced=23
+    stpcpy; # introduced=21
+    stpncpy; # introduced=21
     strcasecmp;
-    strcasecmp_l;
+    strcasecmp_l; # introduced=23
     strcasestr;
     strcat;
     strchr;
     strcmp;
     strcoll;
-    strcoll_l;
+    strcoll_l; # introduced=21
     strcpy;
     strcspn;
     strdup;
     strerror;
-    strerror_l;
+    strerror_l; # introduced=23
     strerror_r;
     strftime;
-    strftime_l;
+    strftime_l; # introduced=21
     strlcat;
     strlcpy;
     strlen;
     strncasecmp;
-    strncasecmp_l;
+    strncasecmp_l; # introduced=23
     strncat;
     strncmp;
     strncpy;
@@ -950,84 +950,84 @@
     strspn;
     strstr;
     strtod;
-    strtof;
+    strtof; # introduced=21
     strtoimax;
     strtok;
     strtok_r;
     strtol;
-    strtold;
-    strtold_l;
+    strtold; # introduced=21
+    strtold_l; # introduced=21
     strtoll;
-    strtoll_l;
-    strtoq;
+    strtoll_l; # introduced=21
+    strtoq; # introduced=21
     strtoul;
     strtoull;
-    strtoull_l;
+    strtoull_l; # introduced=21
     strtoumax;
-    strtouq;
+    strtouq; # introduced=21
     strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
+    strxfrm_l; # introduced=21
+    swapoff; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    swapon; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     swprintf;
     swscanf;
     symlink;
-    symlinkat;
+    symlinkat; # introduced=21
     sync;
-    sys_siglist;
-    sys_signame;
+    sys_siglist; # var
+    sys_signame; # var
     syscall;
     sysconf;
     sysinfo;
     syslog;
     system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
+    tcdrain; # introduced=21
+    tcflow; # introduced=21
+    tcflush; # introduced=21
+    tcgetattr; # introduced=21
     tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
+    tcgetsid; # introduced=21
+    tcsendbreak; # introduced=21
+    tcsetattr; # introduced=21
     tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
+    tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tee; # introduced=21
+    telldir; # introduced=23
     tempnam;
-    tfind;
-    tgkill;
+    tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     time;
-    timegm;
-    timelocal;
+    timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    timelocal; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timer_create;
     timer_delete;
     timer_getoverrun;
     timer_gettime;
     timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
+    timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     times;
-    timezone;
+    timezone; # var
     tmpfile;
     tmpnam;
     toascii;
     tolower;
-    tolower_l;
+    tolower_l; # introduced=21
     toupper;
-    toupper_l;
+    toupper_l; # introduced=21
     towlower;
-    towlower_l;
+    towlower_l; # introduced=21
     towupper;
-    towupper_l;
+    towupper_l; # introduced=21
     truncate;
-    truncate64;
-    tsearch;
+    truncate64; # introduced=21
+    tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     ttyname;
     ttyname_r;
-    twalk;
-    tzname;
+    twalk; # introduced=21
+    tzname; # var
     tzset;
     umask;
     umount;
@@ -1039,37 +1039,37 @@
     unlinkat;
     unlockpt;
     unsetenv;
-    unshare;
-    uselocale;
+    unshare; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    uselocale; # introduced=21
     usleep;
     utime;
-    utimensat;
+    utimensat; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     utimes;
     utmpname;
     vasprintf;
-    vdprintf;
+    vdprintf; # introduced=21
     verr;
     verrx;
     vfork;
     vfprintf;
     vfscanf;
     vfwprintf;
-    vfwscanf;
-    vmsplice;
+    vfwscanf; # introduced=21
+    vmsplice; # introduced=21
     vprintf;
     vscanf;
     vsnprintf;
     vsprintf;
     vsscanf;
     vswprintf;
-    vswscanf;
+    vswscanf; # introduced=21
     vsyslog;
     vwarn;
     vwarnx;
     vwprintf;
-    vwscanf;
+    vwscanf; # introduced=21
     wait;
-    wait4;
+    wait4; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     waitid;
     waitpid;
     warn;
@@ -1078,12 +1078,12 @@
     wcpncpy;
     wcrtomb;
     wcscasecmp;
-    wcscasecmp_l;
+    wcscasecmp_l; # introduced=23
     wcscat;
     wcschr;
     wcscmp;
     wcscoll;
-    wcscoll_l;
+    wcscoll_l; # introduced=21
     wcscpy;
     wcscspn;
     wcsdup;
@@ -1092,44 +1092,44 @@
     wcslcpy;
     wcslen;
     wcsncasecmp;
-    wcsncasecmp_l;
+    wcsncasecmp_l; # introduced=23
     wcsncat;
     wcsncmp;
     wcsncpy;
     wcsnlen;
-    wcsnrtombs;
+    wcsnrtombs; # introduced=21
     wcspbrk;
     wcsrchr;
     wcsrtombs;
     wcsspn;
     wcsstr;
     wcstod;
-    wcstof;
-    wcstoimax;
+    wcstof; # introduced=21
+    wcstoimax; # introduced=21
     wcstok;
     wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
+    wcstold; # introduced=21
+    wcstold_l; # introduced=21
+    wcstoll; # introduced=21
+    wcstoll_l; # introduced=21
     wcstombs;
     wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
+    wcstoull; # introduced=21
+    wcstoull_l; # introduced=21
+    wcstoumax; # introduced=21
     wcswidth;
     wcsxfrm;
-    wcsxfrm_l;
+    wcsxfrm_l; # introduced=21
     wctob;
-    wctomb;
+    wctomb; # introduced=21
     wctype;
-    wctype_l;
+    wctype_l; # introduced=21
     wcwidth;
     wmemchr;
     wmemcmp;
     wmemcpy;
     wmemmove;
-    wmempcpy;
+    wmempcpy; # introduced=23
     wmemset;
     wprintf;
     write;
@@ -1139,56 +1139,106 @@
     *;
 };
 
-LIBC_N {
+LIBC_N { # introduced-arm64=24 introduced-mips=24 introduced-mips64=24 introduced-x86=24 introduced-x86_64=24
   global:
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
+    __fread_chk; # introduced=24
+    __fwrite_chk; # introduced=24
+    __getcwd_chk; # introduced=24
+    __pwrite_chk; # introduced=24
+    __pwrite64_chk; # introduced=24
+    __write_chk; # introduced=24
+    adjtimex; # introduced=24
+    clock_adjtime; # introduced=24
+    fgetpos64; # introduced=24
+    fileno_unlocked; # introduced=24
+    fopen64; # introduced=24
+    freeifaddrs; # introduced=24
+    freopen64; # introduced=24
+    fseeko64; # introduced=24
+    fsetpos64; # introduced=24
+    ftello64; # introduced=24
+    funopen64; # introduced=24
+    getgrgid_r; # introduced=24
+    getgrnam_r; # introduced=24
+    getifaddrs; # introduced=24
+    if_freenameindex; # introduced=24
+    if_nameindex; # introduced=24
+    in6addr_any; # var introduced=24
+    in6addr_loopback; # var introduced=24
+    lockf; # introduced=24
+    lockf64; # introduced=24
+    preadv; # introduced=24
+    preadv64; # introduced=24
+    pthread_barrierattr_destroy; # introduced=24
+    pthread_barrierattr_getpshared; # introduced=24
+    pthread_barrierattr_init; # introduced=24
+    pthread_barrierattr_setpshared; # introduced=24
+    pthread_barrier_destroy; # introduced=24
+    pthread_barrier_init; # introduced=24
+    pthread_barrier_wait; # introduced=24
+    pthread_spin_destroy; # introduced=24
+    pthread_spin_init; # introduced=24
+    pthread_spin_lock; # introduced=24
+    pthread_spin_trylock; # introduced=24
+    pthread_spin_unlock; # introduced=24
+    pwritev; # introduced=24
+    pwritev64; # introduced=24
+    scandirat; # introduced=24
+    scandirat64; # introduced=24
+    strchrnul; # introduced=24
+    tmpfile64; # introduced=24
 } LIBC;
 
+LIBC_O {
+  global:
+    catclose; # future
+    catgets; # future
+    catopen; # future
+    ctermid; # future
+    endgrent; # future
+    endpwent; # future
+    futimes; # future
+    futimesat; # future
+    getdomainname; # future
+    getgrent; # future
+    getpwent; # future
+    getsubopt; # future
+    hasmntopt; # future
+    lutimes; # future
+    mblen; # future
+    msgctl; # future
+    msgget; # future
+    msgrcv; # future
+    msgsnd; # future
+    pthread_getname_np; # future
+    quotactl; # future
+    semctl; # future
+    semget; # future
+    semop; # future
+    semtimedop; # future
+    setdomainname; # future
+    setgrent; # future
+    setpwent; # future
+    shmat; # future
+    shmctl; # future
+    shmdt; # future
+    shmget; # future
+    sighold; # future
+    sigignore; # future
+    sigpause; # future
+    sigrelse; # future
+    sigset; # future
+    strtod_l; # future
+    strtof_l; # future
+    strtol_l; # future
+    strtoul_l; # future
+    sync_file_range; # future
+    towctrans; # future
+    towctrans_l; # future
+    wctrans; # future
+    wctrans_l; # future
+} LIBC_N;
+
 LIBC_PRIVATE {
   global:
     android_getaddrinfofornet;
@@ -1198,7 +1248,7 @@
     free_malloc_leak_info;
     get_malloc_leak_info;
     gMallocLeakZygoteChild;
-} LIBC_N;
+} LIBC_O;
 
 LIBC_PLATFORM {
   global:
@@ -1209,4 +1259,4 @@
     malloc_disable;
     malloc_enable;
     malloc_iterate;
-} LIBC_N;
+} LIBC_O;
diff --git a/libc/libc.x86.brillo.map b/libc/libc.x86.brillo.map
deleted file mode 100644
index 34f5e0e..0000000
--- a/libc/libc.x86.brillo.map
+++ /dev/null
@@ -1,1298 +0,0 @@
-# Generated by genversionscripts.py. Do not edit.
-LIBC {
-  global:
-    __assert;
-    __assert2;
-    __b64_ntop;
-    __b64_pton;
-    __brk; # arm x86 mips
-    __cmsg_nxthdr;
-    __connect; # arm x86 mips
-    __ctype_get_mb_cur_max;
-    __cxa_atexit;
-    __cxa_finalize;
-    __cxa_thread_atexit_impl;
-    __dn_comp;
-    __dn_count_labels;
-    __dn_skipname;
-    __epoll_pwait; # arm x86 mips
-    __errno;
-    __exit; # arm x86 mips
-    __fadvise64; # x86 mips
-    __fbufsize;
-    __fcntl64; # arm x86 mips
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
-    __fp_nquery;
-    __fp_query;
-    __fpclassify;
-    __fpclassifyd;
-    __fpclassifyf;
-    __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
-    __fstatfs64; # arm x86 mips
-    __fwritable;
-    __get_h_errno;
-    __getcpu; # arm x86 mips
-    __getcwd; # arm x86 mips
-    __getpid; # arm x86 mips
-    __getpriority; # arm x86 mips
-    __gnu_basename;
-    __gnu_strerror_r;
-    __hostalias;
-    __ioctl; # arm x86 mips
-    __isfinite;
-    __isfinitef;
-    __isfinitel;
-    __isinf;
-    __isinff;
-    __isinfl;
-    __isnan;
-    __isnanf;
-    __isnanl;
-    __isnormal;
-    __isnormalf;
-    __isnormall;
-    __isthreaded; # arm x86 mips
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
-    __libc_init;
-    __llseek; # arm x86 mips
-    __loc_aton;
-    __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
-    __mmap2; # arm x86 mips
-    __ns_format_ttl; # arm x86 mips
-    __ns_get16; # arm x86 mips
-    __ns_get32; # arm x86 mips
-    __ns_initparse; # arm x86 mips
-    __ns_makecanon; # arm x86 mips
-    __ns_msg_getflag; # arm x86 mips
-    __ns_name_compress; # arm x86 mips
-    __ns_name_ntol; # arm x86 mips
-    __ns_name_ntop; # arm x86 mips
-    __ns_name_pack; # arm x86 mips
-    __ns_name_pton; # arm x86 mips
-    __ns_name_rollback; # arm x86 mips
-    __ns_name_skip; # arm x86 mips
-    __ns_name_uncompress; # arm x86 mips
-    __ns_name_unpack; # arm x86 mips
-    __ns_parserr; # arm x86 mips
-    __ns_put16; # arm x86 mips
-    __ns_put32; # arm x86 mips
-    __ns_samename; # arm x86 mips
-    __ns_skiprr; # arm x86 mips
-    __ns_sprintrr; # arm x86 mips
-    __ns_sprintrrf; # arm x86 mips
-    __open_2;
-    __openat; # arm x86 mips
-    __openat_2;
-    __p_cdname;
-    __p_cdnname;
-    __p_class;
-    __p_class_syms;
-    __p_fqname;
-    __p_fqnname;
-    __p_option;
-    __p_query;
-    __p_rcode;
-    __p_secstodate;
-    __p_time;
-    __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll; # arm x86 mips
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
-    __pselect6; # arm x86 mips
-    __pthread_cleanup_pop;
-    __pthread_cleanup_push;
-    __ptrace; # arm x86 mips
-    __putlong;
-    __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
-    __reboot; # arm x86 mips
-    __recvfrom_chk;
-    __register_atfork;
-    __res_close;
-    __res_dnok;
-    __res_hnok;
-    __res_hostalias;
-    __res_isourserver;
-    __res_mailok;
-    __res_nameinquery;
-    __res_nclose;
-    __res_ninit;
-    __res_nmkquery;
-    __res_nquery;
-    __res_nquerydomain;
-    __res_nsearch;
-    __res_nsend;
-    __res_ownok;
-    __res_queriesmatch;
-    __res_querydomain;
-    __res_send;
-    __res_send_setqhook;
-    __res_send_setrhook;
-    __rt_sigaction; # arm x86 mips
-    __rt_sigpending; # arm x86 mips
-    __rt_sigprocmask; # arm x86 mips
-    __rt_sigsuspend; # arm x86 mips
-    __rt_sigtimedwait; # arm x86 mips
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sched_getaffinity; # arm x86 mips
-    __set_thread_area; # x86
-    __set_tid_address; # arm x86 mips
-    __sF;
-    __sigaction; # arm x86 mips
-    __snprintf_chk;
-    __socket; # arm x86 mips
-    __sprintf_chk;
-    __stack_chk_fail;
-    __stack_chk_guard;
-    __statfs64; # arm x86 mips
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
-    __sym_ntop;
-    __sym_ntos;
-    __sym_ston;
-    __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
-    __system_property_find;
-    __system_property_find_nth;
-    __system_property_foreach;
-    __system_property_get;
-    __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
-    __timer_create; # arm x86 mips
-    __timer_delete; # arm x86 mips
-    __timer_getoverrun; # arm x86 mips
-    __timer_gettime; # arm x86 mips
-    __timer_settime; # arm x86 mips
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
-    __waitid; # arm x86 mips
-    _ctype_;
-    _Exit;
-    _exit;
-    _flushlbf;
-    _getlong;
-    _getshort;
-    _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
-    _setjmp;
-    _tolower;
-    _tolower_tab_; # arm x86 mips
-    _toupper;
-    _toupper_tab_; # arm x86 mips
-    abort;
-    abs;
-    accept;
-    accept4;
-    access;
-    acct;
-    alarm;
-    alphasort;
-    alphasort64;
-    android_set_abort_message;
-    arc4random;
-    arc4random_buf;
-    arc4random_uniform;
-    asctime;
-    asctime64; # arm x86 mips
-    asctime64_r; # arm x86 mips
-    asctime_r;
-    asprintf;
-    at_quick_exit;
-    atof;
-    atoi;
-    atol;
-    atoll;
-    basename;
-    basename_r; # arm x86 mips
-    bind;
-    bindresvport;
-    brk;
-    bsearch;
-    btowc;
-    c16rtomb;
-    c32rtomb;
-    calloc;
-    capget;
-    capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
-    chdir;
-    chmod;
-    chown;
-    chroot;
-    clearenv;
-    clearerr;
-    clearerr_unlocked;
-    clock;
-    clock_getcpuclockid;
-    clock_getres;
-    clock_gettime;
-    clock_nanosleep;
-    clock_settime;
-    clone;
-    close;
-    closedir;
-    closelog;
-    connect;
-    creat;
-    creat64;
-    ctime;
-    ctime64; # arm x86 mips
-    ctime64_r; # arm x86 mips
-    ctime_r;
-    daemon;
-    daylight;
-    delete_module;
-    difftime;
-    dirfd;
-    dirname;
-    dirname_r; # arm x86 mips
-    div;
-    dn_expand;
-    dprintf;
-    drand48;
-    dup;
-    dup2;
-    dup3;
-    duplocale;
-    endmntent;
-    endservent;
-    endutent;
-    environ;
-    epoll_create;
-    epoll_create1;
-    epoll_ctl;
-    epoll_pwait;
-    epoll_wait;
-    erand48;
-    err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
-    errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
-    eventfd;
-    eventfd_read;
-    eventfd_write;
-    execl;
-    execle;
-    execlp;
-    execv;
-    execve;
-    execvp;
-    execvpe;
-    exit;
-    faccessat;
-    fallocate;
-    fallocate64;
-    fchdir;
-    fchmod;
-    fchmodat;
-    fchown;
-    fchownat;
-    fclose;
-    fcntl;
-    fdatasync;
-    fdopen;
-    fdopendir;
-    feof;
-    feof_unlocked;
-    ferror;
-    ferror_unlocked;
-    fflush;
-    ffs;
-    fgetc;
-    fgetln;
-    fgetpos;
-    fgets;
-    fgetwc;
-    fgetws;
-    fgetxattr;
-    fileno;
-    flistxattr;
-    flock;
-    flockfile;
-    fmemopen;
-    fnmatch;
-    fopen;
-    fork;
-    forkpty;
-    fpathconf;
-    fprintf;
-    fpurge;
-    fputc;
-    fputs;
-    fputwc;
-    fputws;
-    fread;
-    free;
-    freeaddrinfo;
-    freelocale;
-    fremovexattr;
-    freopen;
-    fscanf;
-    fseek;
-    fseeko;
-    fsetpos;
-    fsetxattr;
-    fstat;
-    fstat64;
-    fstatat;
-    fstatat64;
-    fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
-    fsync;
-    ftell;
-    ftello;
-    ftok;
-    ftruncate;
-    ftruncate64;
-    ftrylockfile;
-    fts_children;
-    fts_close;
-    fts_open;
-    fts_read;
-    fts_set;
-    ftw;
-    ftw64;
-    funlockfile;
-    funopen;
-    futimens;
-    fwide;
-    fwprintf;
-    fwrite;
-    fwscanf;
-    gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
-    getaddrinfo;
-    getauxval;
-    getc;
-    getc_unlocked;
-    getchar;
-    getchar_unlocked;
-    getcwd;
-    getdelim;
-    getegid;
-    getenv;
-    geteuid;
-    getgid;
-    getgrgid;
-    getgrnam;
-    getgrouplist;
-    getgroups;
-    gethostbyaddr;
-    gethostbyaddr_r;
-    gethostbyname;
-    gethostbyname2;
-    gethostbyname2_r;
-    gethostbyname_r;
-    gethostent;
-    gethostname;
-    getitimer;
-    getline;
-    getlogin;
-    getmntent;
-    getmntent_r;
-    getnameinfo;
-    getnetbyaddr;
-    getnetbyname;
-    getopt;
-    getopt_long;
-    getopt_long_only;
-    getpagesize;
-    getpeername;
-    getpgid;
-    getpgrp;
-    getpid;
-    getppid;
-    getpriority;
-    getprogname;
-    getprotobyname;
-    getprotobynumber;
-    getpt;
-    getpwnam;
-    getpwnam_r;
-    getpwuid;
-    getpwuid_r;
-    getresgid;
-    getresuid;
-    getrlimit;
-    getrlimit64;
-    getrusage;
-    gets;
-    getservbyname;
-    getservbyport;
-    getservent;
-    getsid;
-    getsockname;
-    getsockopt;
-    gettid;
-    gettimeofday;
-    getuid;
-    getutent;
-    getwc;
-    getwchar;
-    getxattr;
-    gmtime;
-    gmtime64; # arm x86 mips
-    gmtime64_r; # arm x86 mips
-    gmtime_r;
-    grantpt;
-    herror;
-    hstrerror;
-    htonl;
-    htons;
-    if_indextoname;
-    if_nametoindex;
-    imaxabs;
-    imaxdiv;
-    inet_addr;
-    inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
-    inet_nsap_addr;
-    inet_nsap_ntoa;
-    inet_ntoa;
-    inet_ntop;
-    inet_pton;
-    init_module;
-    initgroups;
-    initstate;
-    inotify_add_watch;
-    inotify_init;
-    inotify_init1;
-    inotify_rm_watch;
-    insque;
-    ioctl;
-    isalnum;
-    isalnum_l;
-    isalpha;
-    isalpha_l;
-    isascii;
-    isatty;
-    isblank;
-    isblank_l;
-    iscntrl;
-    iscntrl_l;
-    isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
-    isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
-    islower;
-    islower_l;
-    isnan;
-    isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
-    isprint;
-    isprint_l;
-    ispunct;
-    ispunct_l;
-    isspace;
-    isspace_l;
-    isupper;
-    isupper_l;
-    iswalnum;
-    iswalnum_l;
-    iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
-    iswcntrl;
-    iswcntrl_l;
-    iswctype;
-    iswctype_l;
-    iswdigit;
-    iswdigit_l;
-    iswgraph;
-    iswgraph_l;
-    iswlower;
-    iswlower_l;
-    iswprint;
-    iswprint_l;
-    iswpunct;
-    iswpunct_l;
-    iswspace;
-    iswspace_l;
-    iswupper;
-    iswupper_l;
-    iswxdigit;
-    iswxdigit_l;
-    isxdigit;
-    isxdigit_l;
-    jrand48;
-    kill;
-    killpg;
-    klogctl;
-    labs;
-    lchown;
-    lcong48;
-    ldexp;
-    ldiv;
-    lfind;
-    lgetxattr;
-    link;
-    linkat;
-    listen;
-    listxattr;
-    llabs;
-    lldiv;
-    llistxattr;
-    localeconv;
-    localtime;
-    localtime64; # arm x86 mips
-    localtime64_r; # arm x86 mips
-    localtime_r;
-    login_tty;
-    longjmp;
-    lrand48;
-    lremovexattr;
-    lsearch;
-    lseek;
-    lseek64;
-    lsetxattr;
-    lstat;
-    lstat64;
-    madvise;
-    mallinfo;
-    malloc;
-    malloc_info;
-    malloc_usable_size;
-    mbrlen;
-    mbrtoc16;
-    mbrtoc32;
-    mbrtowc;
-    mbsinit;
-    mbsnrtowcs;
-    mbsrtowcs;
-    mbstowcs;
-    mbtowc;
-    memalign;
-    memccpy;
-    memchr;
-    memcmp;
-    memcpy;
-    memmem;
-    memmove;
-    mempcpy;
-    memrchr;
-    memset;
-    mincore;
-    mkdir;
-    mkdirat;
-    mkdtemp;
-    mkfifo;
-    mkfifoat;
-    mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
-    mkstemp;
-    mkstemp64;
-    mkstemps;
-    mkstemps64;
-    mktemp;
-    mktime;
-    mktime64; # arm x86 mips
-    mlock;
-    mlockall;
-    mmap;
-    mmap64;
-    mount;
-    mprotect;
-    mrand48;
-    mremap;
-    msync;
-    munlock;
-    munlockall;
-    munmap;
-    nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
-    nice;
-    nrand48;
-    nsdispatch;
-    ntohl;
-    ntohs;
-    open;
-    open64;
-    open_memstream;
-    open_wmemstream;
-    openat;
-    openat64;
-    opendir;
-    openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
-    pathconf;
-    pause;
-    pclose;
-    perror;
-    personality;
-    pipe;
-    pipe2;
-    poll;
-    popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
-    prctl;
-    pread;
-    pread64;
-    printf;
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
-    pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
-    pthread_attr_destroy;
-    pthread_attr_getdetachstate;
-    pthread_attr_getguardsize;
-    pthread_attr_getschedparam;
-    pthread_attr_getschedpolicy;
-    pthread_attr_getscope;
-    pthread_attr_getstack;
-    pthread_attr_getstacksize;
-    pthread_attr_init;
-    pthread_attr_setdetachstate;
-    pthread_attr_setguardsize;
-    pthread_attr_setschedparam;
-    pthread_attr_setschedpolicy;
-    pthread_attr_setscope;
-    pthread_attr_setstack;
-    pthread_attr_setstacksize;
-    pthread_cond_broadcast;
-    pthread_cond_destroy;
-    pthread_cond_init;
-    pthread_cond_signal;
-    pthread_cond_timedwait;
-    pthread_cond_timedwait_monotonic; # arm x86 mips
-    pthread_cond_timedwait_monotonic_np; # arm x86 mips
-    pthread_cond_timedwait_relative_np; # arm x86 mips
-    pthread_cond_timeout_np; # arm x86 mips
-    pthread_cond_wait;
-    pthread_condattr_destroy;
-    pthread_condattr_getclock;
-    pthread_condattr_getpshared;
-    pthread_condattr_init;
-    pthread_condattr_setclock;
-    pthread_condattr_setpshared;
-    pthread_create;
-    pthread_detach;
-    pthread_equal;
-    pthread_exit;
-    pthread_getattr_np;
-    pthread_getcpuclockid;
-    pthread_getschedparam;
-    pthread_getspecific;
-    pthread_gettid_np;
-    pthread_join;
-    pthread_key_create;
-    pthread_key_delete;
-    pthread_kill;
-    pthread_mutex_destroy;
-    pthread_mutex_init;
-    pthread_mutex_lock;
-    pthread_mutex_lock_timeout_np; # arm x86 mips
-    pthread_mutex_timedlock;
-    pthread_mutex_trylock;
-    pthread_mutex_unlock;
-    pthread_mutexattr_destroy;
-    pthread_mutexattr_getpshared;
-    pthread_mutexattr_gettype;
-    pthread_mutexattr_init;
-    pthread_mutexattr_setpshared;
-    pthread_mutexattr_settype;
-    pthread_once;
-    pthread_rwlock_destroy;
-    pthread_rwlock_init;
-    pthread_rwlock_rdlock;
-    pthread_rwlock_timedrdlock;
-    pthread_rwlock_timedwrlock;
-    pthread_rwlock_tryrdlock;
-    pthread_rwlock_trywrlock;
-    pthread_rwlock_unlock;
-    pthread_rwlock_wrlock;
-    pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
-    pthread_rwlockattr_getpshared;
-    pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
-    pthread_rwlockattr_setpshared;
-    pthread_self;
-    pthread_setname_np;
-    pthread_setschedparam;
-    pthread_setspecific;
-    pthread_sigmask;
-    ptrace;
-    ptsname;
-    ptsname_r;
-    putc;
-    putc_unlocked;
-    putchar;
-    putchar_unlocked;
-    putenv;
-    puts;
-    pututline;
-    putw; # arm x86 mips
-    putwc;
-    putwchar;
-    pvalloc; # arm x86 mips
-    pwrite;
-    pwrite64;
-    qsort;
-    quick_exit;
-    raise;
-    rand;
-    rand_r;
-    random;
-    read;
-    readahead;
-    readdir;
-    readdir64;
-    readdir64_r;
-    readdir_r;
-    readlink;
-    readlinkat;
-    readv;
-    realloc;
-    realpath;
-    reboot;
-    recv;
-    recvfrom;
-    recvmmsg;
-    recvmsg;
-    regcomp;
-    regerror;
-    regexec;
-    regfree;
-    remove;
-    removexattr;
-    remque;
-    rename;
-    renameat;
-    res_init;
-    res_mkquery;
-    res_query;
-    res_search;
-    rewind;
-    rewinddir;
-    rmdir;
-    sbrk;
-    scandir;
-    scandir64;
-    scanf;
-    sched_get_priority_max;
-    sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
-    sched_getparam;
-    sched_getscheduler;
-    sched_rr_get_interval;
-    sched_setaffinity;
-    sched_setparam;
-    sched_setscheduler;
-    sched_yield;
-    seed48;
-    seekdir;
-    select;
-    sem_close;
-    sem_destroy;
-    sem_getvalue;
-    sem_init;
-    sem_open;
-    sem_post;
-    sem_timedwait;
-    sem_trywait;
-    sem_unlink;
-    sem_wait;
-    send;
-    sendfile;
-    sendfile64;
-    sendmmsg;
-    sendmsg;
-    sendto;
-    setbuf;
-    setbuffer;
-    setegid;
-    setenv;
-    seteuid;
-    setfsgid;
-    setfsuid;
-    setgid;
-    setgroups;
-    sethostname;
-    setitimer;
-    setjmp;
-    setlinebuf;
-    setlocale;
-    setlogmask;
-    setmntent;
-    setns;
-    setpgid;
-    setpgrp;
-    setpriority;
-    setprogname;
-    setregid;
-    setresgid;
-    setresuid;
-    setreuid;
-    setrlimit;
-    setrlimit64;
-    setservent;
-    setsid;
-    setsockopt;
-    setstate;
-    settimeofday;
-    setuid;
-    setutent;
-    setvbuf;
-    setxattr;
-    shutdown;
-    sigaction;
-    sigaddset;
-    sigaltstack;
-    sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
-    siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
-    sigpending;
-    sigprocmask;
-    sigqueue;
-    sigsetjmp;
-    sigsetmask;
-    sigsuspend;
-    sigtimedwait;
-    sigwait;
-    sigwaitinfo;
-    sleep;
-    snprintf;
-    socket;
-    socketpair;
-    splice;
-    sprintf;
-    srand;
-    srand48;
-    srandom;
-    sscanf;
-    stat;
-    stat64;
-    statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
-    strcasecmp;
-    strcasecmp_l;
-    strcasestr;
-    strcat;
-    strchr;
-    strcmp;
-    strcoll;
-    strcoll_l;
-    strcpy;
-    strcspn;
-    strdup;
-    strerror;
-    strerror_l;
-    strerror_r;
-    strftime;
-    strftime_l;
-    strlcat;
-    strlcpy;
-    strlen;
-    strncasecmp;
-    strncasecmp_l;
-    strncat;
-    strncmp;
-    strncpy;
-    strndup;
-    strnlen;
-    strpbrk;
-    strptime;
-    strrchr;
-    strsep;
-    strsignal;
-    strspn;
-    strstr;
-    strtod;
-    strtof;
-    strtoimax;
-    strtok;
-    strtok_r;
-    strtol;
-    strtold;
-    strtold_l;
-    strtoll;
-    strtoll_l;
-    strtoq;
-    strtoul;
-    strtoull;
-    strtoull_l;
-    strtoumax;
-    strtouq;
-    strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
-    swprintf;
-    swscanf;
-    symlink;
-    symlinkat;
-    sync;
-    sys_siglist;
-    sys_signame;
-    syscall;
-    sysconf;
-    sysinfo;
-    syslog;
-    system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
-    tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
-    tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
-    tempnam;
-    tfind;
-    tgkill;
-    time;
-    timegm;
-    timegm64; # arm x86 mips
-    timelocal;
-    timelocal64; # arm x86 mips
-    timer_create;
-    timer_delete;
-    timer_getoverrun;
-    timer_gettime;
-    timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
-    times;
-    timezone;
-    tmpfile;
-    tmpnam;
-    toascii;
-    tolower;
-    tolower_l;
-    toupper;
-    toupper_l;
-    towlower;
-    towlower_l;
-    towupper;
-    towupper_l;
-    truncate;
-    truncate64;
-    tsearch;
-    ttyname;
-    ttyname_r;
-    twalk;
-    tzname;
-    tzset;
-    umask;
-    umount;
-    umount2;
-    uname;
-    ungetc;
-    ungetwc;
-    unlink;
-    unlinkat;
-    unlockpt;
-    unsetenv;
-    unshare;
-    uselocale;
-    usleep;
-    utime;
-    utimensat;
-    utimes;
-    utmpname;
-    valloc; # arm x86 mips
-    vasprintf;
-    vdprintf;
-    verr;
-    verrx;
-    vfork;
-    vfprintf;
-    vfscanf;
-    vfwprintf;
-    vfwscanf;
-    vmsplice;
-    vprintf;
-    vscanf;
-    vsnprintf;
-    vsprintf;
-    vsscanf;
-    vswprintf;
-    vswscanf;
-    vsyslog;
-    vwarn;
-    vwarnx;
-    vwprintf;
-    vwscanf;
-    wait;
-    wait4;
-    waitid;
-    waitpid;
-    warn;
-    warnx;
-    wcpcpy;
-    wcpncpy;
-    wcrtomb;
-    wcscasecmp;
-    wcscasecmp_l;
-    wcscat;
-    wcschr;
-    wcscmp;
-    wcscoll;
-    wcscoll_l;
-    wcscpy;
-    wcscspn;
-    wcsdup;
-    wcsftime;
-    wcslcat;
-    wcslcpy;
-    wcslen;
-    wcsncasecmp;
-    wcsncasecmp_l;
-    wcsncat;
-    wcsncmp;
-    wcsncpy;
-    wcsnlen;
-    wcsnrtombs;
-    wcspbrk;
-    wcsrchr;
-    wcsrtombs;
-    wcsspn;
-    wcsstr;
-    wcstod;
-    wcstof;
-    wcstoimax;
-    wcstok;
-    wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
-    wcstombs;
-    wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
-    wcswidth;
-    wcsxfrm;
-    wcsxfrm_l;
-    wctob;
-    wctomb;
-    wctype;
-    wctype_l;
-    wcwidth;
-    wmemchr;
-    wmemcmp;
-    wmemcpy;
-    wmemmove;
-    wmempcpy;
-    wmemset;
-    wprintf;
-    write;
-    writev;
-    wscanf;
-  local:
-    *;
-};
-
-LIBC_N {
-  global:
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    prlimit; # arm mips x86
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
-} LIBC;
-
-LIBC_PRIVATE {
-  global:
-    __accept4; # arm x86 mips
-    __bionic_brk; # arm x86 mips
-    __bionic_libgcc_compat_symbols; # arm x86
-    __divdi3; # arm x86 mips
-    __getdents64; # arm x86 mips
-    __popcountsi2; # arm x86 mips
-    __sclose; # arm x86 mips
-    __sflags; # arm x86 mips
-    __sflush; # arm x86 mips
-    __sfp; # arm x86 mips
-    __sglue; # arm x86 mips
-    __smakebuf; # arm x86 mips
-    __sread; # arm x86 mips
-    __srefill; # arm x86 mips
-    __srget; # arm x86 mips
-    __sseek; # arm x86 mips
-    __swbuf; # arm x86 mips
-    __swrite; # arm x86 mips
-    __swsetup; # arm x86 mips
-    __udivdi3; # arm x86 mips
-    __umoddi3; # x86 mips
-    _fwalk; # arm x86 mips
-    android_getaddrinfofornet;
-    android_getaddrinfofornetcontext;
-    android_gethostbyaddrfornet;
-    android_gethostbynamefornet;
-    free_malloc_leak_info;
-    get_malloc_leak_info;
-    gMallocLeakZygoteChild;
-    SHA1Final; # arm x86 mips
-    SHA1Init; # arm x86 mips
-    SHA1Transform; # arm x86 mips
-    SHA1Update; # arm x86 mips
-} LIBC_N;
-
-LIBC_PLATFORM {
-  global:
-    android_net_res_stats_get_info_for_net;
-    android_net_res_stats_aggregate;
-    android_net_res_stats_get_usable_servers;
-    malloc_backtrace;
-    malloc_disable;
-    malloc_enable;
-    malloc_iterate;
-} LIBC_N;
diff --git a/libc/libc.x86.map b/libc/libc.x86.map
index 9417d56..a166361 100644
--- a/libc/libc.x86.map
+++ b/libc/libc.x86.map
@@ -1,50 +1,49 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
     __assert;
     __assert2;
     __b64_ntop;
     __b64_pton;
-    __brk; # arm x86 mips
-    __cmsg_nxthdr;
-    __connect; # arm x86 mips
-    __ctype_get_mb_cur_max;
+    __cmsg_nxthdr; # introduced=21
+    __connect; # arm x86 mips introduced=21
+    __ctype_get_mb_cur_max; # introduced=21
     __cxa_atexit;
     __cxa_finalize;
-    __cxa_thread_atexit_impl;
+    __cxa_thread_atexit_impl; # introduced=23
     __dn_comp;
     __dn_count_labels;
     __dn_skipname;
-    __epoll_pwait; # arm x86 mips
+    __epoll_pwait; # arm x86 mips introduced=21
     __errno;
-    __exit; # arm x86 mips
-    __fadvise64; # x86 mips
-    __fbufsize;
+    __exit; # arm x86 mips introduced=21
+    __fadvise64; # x86 mips introduced=21
+    __fbufsize; # introduced=23
     __fcntl64; # arm x86 mips
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
+    __FD_CLR_chk; # introduced=21
+    __FD_ISSET_chk; # introduced=21
+    __FD_SET_chk; # introduced=21
+    __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __flbf; # introduced=23
     __fp_nquery;
     __fp_query;
-    __fpclassify;
+    __fpclassify; # introduced=21
     __fpclassifyd;
     __fpclassifyf;
     __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
+    __fpending; # introduced=23
+    __fpurge; # introduced=23
+    __freadable; # introduced=23
+    __fsetlocking; # introduced=23
     __fstatfs64; # arm x86 mips
-    __fwritable;
+    __fwritable; # introduced=23
     __get_h_errno;
-    __getcpu; # arm x86 mips
+    __getcpu; # arm x86 mips introduced-arm=12 introduced-mips=16 introduced-x86=12
     __getcwd; # arm x86 mips
-    __getpid; # arm x86 mips
+    __getpid; # arm x86 mips introduced=21
     __getpriority; # arm x86 mips
-    __gnu_basename;
-    __gnu_strerror_r;
+    __gnu_basename; # introduced=23
+    __gnu_strerror_r; # introduced=23
     __hostalias;
     __ioctl; # arm x86 mips
     __isfinite;
@@ -53,24 +52,24 @@
     __isinf;
     __isinff;
     __isinfl;
-    __isnan;
-    __isnanf;
+    __isnan; # introduced=21
+    __isnanf; # introduced=21
     __isnanl;
     __isnormal;
     __isnormalf;
     __isnormall;
-    __isthreaded; # arm x86 mips
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
+    __isthreaded; # arm x86 mips var
+    __libc_current_sigrtmax; # introduced=21
+    __libc_current_sigrtmin; # introduced=21
     __libc_init;
     __llseek; # arm x86 mips
     __loc_aton;
     __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
+    __memchr_chk; # introduced=23
+    __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memrchr_chk; # introduced=23
+    __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __mmap2; # arm x86 mips
     __ns_format_ttl; # arm x86 mips
     __ns_get16; # arm x86 mips
@@ -94,13 +93,13 @@
     __ns_skiprr; # arm x86 mips
     __ns_sprintrr; # arm x86 mips
     __ns_sprintrrf; # arm x86 mips
-    __open_2;
+    __open_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __openat; # arm x86 mips
-    __openat_2;
+    __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __p_cdname;
     __p_cdnname;
     __p_class;
-    __p_class_syms;
+    __p_class_syms; # var
     __p_fqname;
     __p_fqnname;
     __p_option;
@@ -109,25 +108,25 @@
     __p_secstodate;
     __p_time;
     __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll; # arm x86 mips
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
-    __pselect6; # arm x86 mips
+    __p_type_syms; # var
+    __poll_chk; # introduced=23
+    __ppoll; # arm x86 mips introduced=21
+    __ppoll_chk; # introduced=23
+    __pread64_chk; # introduced=23
+    __pread_chk; # introduced=23
+    __progname; # var
+    __pselect6; # arm x86 mips introduced=21
     __pthread_cleanup_pop;
     __pthread_cleanup_push;
     __ptrace; # arm x86 mips
     __putlong;
     __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
+    __read_chk; # introduced=21
+    __readlink_chk; # introduced=23
+    __readlinkat_chk; # introduced=23
     __reboot; # arm x86 mips
-    __recvfrom_chk;
-    __register_atfork;
+    __recvfrom_chk; # introduced=21
+    __register_atfork; # introduced=23
     __res_close;
     __res_dnok;
     __res_hnok;
@@ -149,89 +148,89 @@
     __res_send_setqhook;
     __res_send_setrhook;
     __rt_sigaction; # arm x86 mips
-    __rt_sigpending; # arm x86 mips
+    __rt_sigpending; # arm x86 mips introduced=21
     __rt_sigprocmask; # arm x86 mips
-    __rt_sigsuspend; # arm x86 mips
+    __rt_sigsuspend; # arm x86 mips introduced=21
     __rt_sigtimedwait; # arm x86 mips
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sched_getaffinity; # arm x86 mips
+    __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_getaffinity; # arm x86 mips introduced=12
     __set_thread_area; # x86
-    __set_tid_address; # arm x86 mips
-    __sF;
-    __sigaction; # arm x86 mips
-    __snprintf_chk;
-    __socket; # arm x86 mips
-    __sprintf_chk;
+    __set_tid_address; # arm x86 mips introduced=21
+    __sF; # var
+    __sigaction; # arm x86 mips introduced=21
+    __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __socket; # arm x86 mips introduced=21
+    __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __stack_chk_fail;
-    __stack_chk_guard;
+    __stack_chk_guard; # var
     __statfs64; # arm x86 mips
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
+    __stpcpy_chk; # introduced=21
+    __stpncpy_chk; # introduced=21
+    __stpncpy_chk2; # introduced=21
+    __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk2; # introduced=21
+    __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     __sym_ntop;
     __sym_ntos;
     __sym_ston;
     __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
+    __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area__; # var
+    __system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area_serial; # introduced=23
     __system_property_find;
     __system_property_find_nth;
-    __system_property_foreach;
+    __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __system_property_get;
     __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
+    __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __timer_create; # arm x86 mips
     __timer_delete; # arm x86 mips
     __timer_getoverrun; # arm x86 mips
     __timer_gettime; # arm x86 mips
     __timer_settime; # arm x86 mips
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
+    __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __waitid; # arm x86 mips
-    _ctype_;
-    _Exit;
+    _ctype_; # var
+    _Exit; # introduced=21
     _exit;
-    _flushlbf;
+    _flushlbf; # introduced=23
     _getlong;
     _getshort;
     _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
+    _resolv_delete_cache_for_net; # introduced=21
+    _resolv_flush_cache_for_net; # introduced=21
+    _resolv_set_nameservers_for_net; # introduced=21
     _setjmp;
-    _tolower;
-    _tolower_tab_; # arm x86 mips
-    _toupper;
-    _toupper_tab_; # arm x86 mips
+    _tolower; # introduced=21
+    _tolower_tab_; # arm x86 mips var
+    _toupper; # introduced=21
+    _toupper_tab_; # arm x86 mips var
     abort;
-    abs;
+    abs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     accept;
-    accept4;
+    accept4; # introduced=21
     access;
     acct;
     alarm;
     alphasort;
-    alphasort64;
-    android_set_abort_message;
+    alphasort64; # introduced=21
+    android_set_abort_message; # introduced=21
     arc4random;
     arc4random_buf;
     arc4random_uniform;
@@ -240,8 +239,8 @@
     asctime64_r; # arm x86 mips
     asctime_r;
     asprintf;
-    at_quick_exit;
-    atof;
+    at_quick_exit; # introduced=21
+    atof; # introduced=21
     atoi;
     atol;
     atoll;
@@ -252,43 +251,43 @@
     brk;
     bsearch;
     btowc;
-    c16rtomb;
-    c32rtomb;
+    c16rtomb; # introduced=21
+    c32rtomb; # introduced=21
     calloc;
     capget;
     capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
+    cfgetispeed; # introduced=21
+    cfgetospeed; # introduced=21
+    cfmakeraw; # introduced=21
+    cfsetispeed; # introduced=21
+    cfsetospeed; # introduced=21
+    cfsetspeed; # introduced=21
     chdir;
     chmod;
     chown;
     chroot;
     clearenv;
     clearerr;
-    clearerr_unlocked;
+    clearerr_unlocked; # introduced=23
     clock;
-    clock_getcpuclockid;
+    clock_getcpuclockid; # introduced=23
     clock_getres;
     clock_gettime;
     clock_nanosleep;
     clock_settime;
-    clone;
+    clone; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     close;
     closedir;
     closelog;
     connect;
     creat;
-    creat64;
+    creat64; # introduced=21
     ctime;
     ctime64; # arm x86 mips
     ctime64_r; # arm x86 mips
     ctime_r;
     daemon;
-    daylight;
+    daylight; # var
     delete_module;
     difftime;
     dirfd;
@@ -296,33 +295,33 @@
     dirname_r; # arm x86 mips
     div;
     dn_expand;
-    dprintf;
+    dprintf; # introduced=21
     drand48;
     dup;
     dup2;
-    dup3;
-    duplocale;
-    endmntent;
+    dup3; # introduced=21
+    duplocale; # introduced=21
+    endmntent; # introduced=21
     endservent;
     endutent;
-    environ;
+    environ; # var
     epoll_create;
-    epoll_create1;
+    epoll_create1; # introduced=21
     epoll_ctl;
-    epoll_pwait;
+    epoll_pwait; # introduced=21
     epoll_wait;
     erand48;
     err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
+    error; # introduced=23
+    error_at_line; # introduced=23
+    error_message_count; # var introduced=23
+    error_one_per_line; # var introduced=23
+    error_print_progname; # var introduced=23
     errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
+    ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     eventfd;
     eventfd_read;
     eventfd_write;
@@ -332,11 +331,11 @@
     execv;
     execve;
     execvp;
-    execvpe;
+    execvpe; # introduced=21
     exit;
-    faccessat;
-    fallocate;
-    fallocate64;
+    faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    fallocate; # introduced=21
+    fallocate64; # introduced=21
     fchdir;
     fchmod;
     fchmodat;
@@ -348,27 +347,27 @@
     fdopen;
     fdopendir;
     feof;
-    feof_unlocked;
+    feof_unlocked; # introduced=23
     ferror;
-    ferror_unlocked;
+    ferror_unlocked; # introduced=23
     fflush;
-    ffs;
+    ffs; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     fgetc;
     fgetln;
     fgetpos;
     fgets;
     fgetwc;
     fgetws;
-    fgetxattr;
+    fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fileno;
-    flistxattr;
+    flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     flock;
     flockfile;
-    fmemopen;
+    fmemopen; # introduced=23
     fnmatch;
     fopen;
     fork;
-    forkpty;
+    forkpty; # introduced=23
     fpathconf;
     fprintf;
     fpurge;
@@ -379,56 +378,56 @@
     fread;
     free;
     freeaddrinfo;
-    freelocale;
-    fremovexattr;
+    freelocale; # introduced=21
+    fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     freopen;
     fscanf;
     fseek;
     fseeko;
     fsetpos;
-    fsetxattr;
+    fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fstat;
-    fstat64;
+    fstat64; # introduced=21
     fstatat;
-    fstatat64;
+    fstatat64; # introduced=21
     fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
+    fstatfs64; # introduced=21
+    fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    fstatvfs64; # introduced=21
     fsync;
     ftell;
     ftello;
     ftok;
     ftruncate;
-    ftruncate64;
+    ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     ftrylockfile;
     fts_children;
     fts_close;
     fts_open;
     fts_read;
     fts_set;
-    ftw;
-    ftw64;
+    ftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    ftw64; # introduced=21
     funlockfile;
     funopen;
-    futimens;
+    futimens; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     fwide;
     fwprintf;
     fwrite;
     fwscanf;
     gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
+    get_avphys_pages; # introduced=23
+    get_nprocs; # introduced=23
+    get_nprocs_conf; # introduced=23
+    get_phys_pages; # introduced=23
     getaddrinfo;
-    getauxval;
+    getauxval; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getc;
     getc_unlocked;
     getchar;
     getchar_unlocked;
     getcwd;
-    getdelim;
+    getdelim; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getegid;
     getenv;
     geteuid;
@@ -438,49 +437,49 @@
     getgrouplist;
     getgroups;
     gethostbyaddr;
-    gethostbyaddr_r;
+    gethostbyaddr_r; # introduced=23
     gethostbyname;
     gethostbyname2;
-    gethostbyname2_r;
+    gethostbyname2_r; # introduced=23
     gethostbyname_r;
     gethostent;
     gethostname;
     getitimer;
-    getline;
+    getline; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getlogin;
     getmntent;
-    getmntent_r;
+    getmntent_r; # introduced=21
     getnameinfo;
     getnetbyaddr;
     getnetbyname;
     getopt;
     getopt_long;
     getopt_long_only;
-    getpagesize;
+    getpagesize; # introduced=21
     getpeername;
     getpgid;
     getpgrp;
     getpid;
     getppid;
     getpriority;
-    getprogname;
+    getprogname; # introduced=21
     getprotobyname;
     getprotobynumber;
     getpt;
     getpwnam;
-    getpwnam_r;
+    getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getpwuid;
-    getpwuid_r;
+    getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getresgid;
     getresuid;
     getrlimit;
-    getrlimit64;
+    getrlimit64; # introduced=21
     getrusage;
     gets;
     getservbyname;
     getservbyport;
     getservent;
-    getsid;
+    getsid; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     getsockname;
     getsockopt;
     gettid;
@@ -489,26 +488,26 @@
     getutent;
     getwc;
     getwchar;
-    getxattr;
+    getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     gmtime;
     gmtime64; # arm x86 mips
     gmtime64_r; # arm x86 mips
     gmtime_r;
-    grantpt;
+    grantpt; # introduced=21
     herror;
     hstrerror;
-    htonl;
-    htons;
+    htonl; # introduced=21
+    htons; # introduced=21
     if_indextoname;
     if_nametoindex;
-    imaxabs;
-    imaxdiv;
+    imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     inet_addr;
     inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
+    inet_lnaof; # introduced=21
+    inet_makeaddr; # introduced=21
+    inet_netof; # introduced=21
+    inet_network; # introduced=21
     inet_nsap_addr;
     inet_nsap_ntoa;
     inet_ntoa;
@@ -516,124 +515,124 @@
     inet_pton;
     init_module;
     initgroups;
-    initstate;
+    initstate; # introduced=21
     inotify_add_watch;
     inotify_init;
-    inotify_init1;
+    inotify_init1; # introduced=21
     inotify_rm_watch;
-    insque;
+    insque; # introduced=21
     ioctl;
     isalnum;
-    isalnum_l;
+    isalnum_l; # introduced=21
     isalpha;
-    isalpha_l;
+    isalpha_l; # introduced=21
     isascii;
     isatty;
     isblank;
-    isblank_l;
+    isblank_l; # introduced=21
     iscntrl;
-    iscntrl_l;
+    iscntrl_l; # introduced=21
     isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
+    isdigit_l; # introduced=21
+    isfinite; # introduced=21
+    isfinitef; # introduced=21
+    isfinitel; # introduced=21
     isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
+    isgraph_l; # introduced=21
+    isinf; # introduced=21
+    isinff; # introduced=21
+    isinfl; # introduced=21
     islower;
-    islower_l;
+    islower_l; # introduced=21
     isnan;
     isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
+    isnanl; # introduced=21
+    isnormal; # introduced=21
+    isnormalf; # introduced=21
+    isnormall; # introduced=21
     isprint;
-    isprint_l;
+    isprint_l; # introduced=21
     ispunct;
-    ispunct_l;
+    ispunct_l; # introduced=21
     isspace;
-    isspace_l;
+    isspace_l; # introduced=21
     isupper;
-    isupper_l;
+    isupper_l; # introduced=21
     iswalnum;
-    iswalnum_l;
+    iswalnum_l; # introduced=21
     iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
+    iswalpha_l; # introduced=21
+    iswblank; # introduced=21
+    iswblank_l; # introduced=21
     iswcntrl;
-    iswcntrl_l;
+    iswcntrl_l; # introduced=21
     iswctype;
-    iswctype_l;
+    iswctype_l; # introduced=21
     iswdigit;
-    iswdigit_l;
+    iswdigit_l; # introduced=21
     iswgraph;
-    iswgraph_l;
+    iswgraph_l; # introduced=21
     iswlower;
-    iswlower_l;
+    iswlower_l; # introduced=21
     iswprint;
-    iswprint_l;
+    iswprint_l; # introduced=21
     iswpunct;
-    iswpunct_l;
+    iswpunct_l; # introduced=21
     iswspace;
-    iswspace_l;
+    iswspace_l; # introduced=21
     iswupper;
-    iswupper_l;
+    iswupper_l; # introduced=21
     iswxdigit;
-    iswxdigit_l;
+    iswxdigit_l; # introduced=21
     isxdigit;
-    isxdigit_l;
+    isxdigit_l; # introduced=21
     jrand48;
     kill;
     killpg;
     klogctl;
-    labs;
+    labs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lchown;
-    lcong48;
+    lcong48; # introduced=23
     ldexp;
     ldiv;
-    lfind;
-    lgetxattr;
+    lfind; # introduced=21
+    lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     link;
-    linkat;
+    linkat; # introduced=21
     listen;
-    listxattr;
-    llabs;
+    listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lldiv;
-    llistxattr;
-    localeconv;
+    llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    localeconv; # introduced=21
     localtime;
     localtime64; # arm x86 mips
     localtime64_r; # arm x86 mips
     localtime_r;
-    login_tty;
+    login_tty; # introduced=23
     longjmp;
     lrand48;
-    lremovexattr;
-    lsearch;
+    lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    lsearch; # introduced=21
     lseek;
     lseek64;
-    lsetxattr;
+    lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     lstat;
-    lstat64;
+    lstat64; # introduced=21
     madvise;
     mallinfo;
     malloc;
-    malloc_info;
-    malloc_usable_size;
+    malloc_info; # introduced=23
+    malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mbrlen;
-    mbrtoc16;
-    mbrtoc32;
+    mbrtoc16; # introduced=21
+    mbrtoc32; # introduced=21
     mbrtowc;
     mbsinit;
-    mbsnrtowcs;
+    mbsnrtowcs; # introduced=21
     mbsrtowcs;
     mbstowcs;
-    mbtowc;
+    mbtowc; # introduced=21
     memalign;
     memccpy;
     memchr;
@@ -641,91 +640,91 @@
     memcpy;
     memmem;
     memmove;
-    mempcpy;
+    mempcpy; # introduced=23
     memrchr;
     memset;
     mincore;
     mkdir;
     mkdirat;
     mkdtemp;
-    mkfifo;
-    mkfifoat;
+    mkfifo; # introduced=21
+    mkfifoat; # introduced=23
     mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
+    mknodat; # introduced=21
+    mkostemp; # introduced=23
+    mkostemp64; # introduced=23
+    mkostemps; # introduced=23
+    mkostemps64; # introduced=23
     mkstemp;
-    mkstemp64;
+    mkstemp64; # introduced=21
     mkstemps;
-    mkstemps64;
+    mkstemps64; # introduced=23
     mktemp;
     mktime;
     mktime64; # arm x86 mips
     mlock;
-    mlockall;
+    mlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mmap;
-    mmap64;
+    mmap64; # introduced=21
     mount;
     mprotect;
     mrand48;
     mremap;
     msync;
     munlock;
-    munlockall;
+    munlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     munmap;
     nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
+    newlocale; # introduced=21
+    nftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    nftw64; # introduced=21
     nice;
     nrand48;
     nsdispatch;
-    ntohl;
-    ntohs;
+    ntohl; # introduced=21
+    ntohs; # introduced=21
     open;
-    open64;
-    open_memstream;
-    open_wmemstream;
+    open64; # introduced=21
+    open_memstream; # introduced=23
+    open_wmemstream; # introduced=23
     openat;
-    openat64;
+    openat64; # introduced=21
     opendir;
     openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
+    openpty; # introduced=23
+    optarg; # var
+    opterr; # var
+    optind; # var
+    optopt; # var
+    optreset; # var
     pathconf;
     pause;
     pclose;
     perror;
-    personality;
+    personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
     pipe;
     pipe2;
     poll;
     popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
+    posix_fadvise; # introduced=21
+    posix_fadvise64; # introduced=21
+    posix_fallocate; # introduced=21
+    posix_fallocate64; # introduced=21
+    posix_madvise; # introduced=23
+    posix_memalign; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    posix_openpt; # introduced=21
+    ppoll; # introduced=21
     prctl;
     pread;
-    pread64;
+    pread64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     printf;
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
+    prlimit64; # introduced=21
+    process_vm_readv; # introduced=23
+    process_vm_writev; # introduced=23
     pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
+    psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    psignal; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     pthread_attr_destroy;
     pthread_attr_getdetachstate;
     pthread_attr_getguardsize;
@@ -753,10 +752,10 @@
     pthread_cond_timeout_np; # arm x86 mips
     pthread_cond_wait;
     pthread_condattr_destroy;
-    pthread_condattr_getclock;
+    pthread_condattr_getclock; # introduced=21
     pthread_condattr_getpshared;
     pthread_condattr_init;
-    pthread_condattr_setclock;
+    pthread_condattr_setclock; # introduced=21
     pthread_condattr_setpshared;
     pthread_create;
     pthread_detach;
@@ -766,7 +765,7 @@
     pthread_getcpuclockid;
     pthread_getschedparam;
     pthread_getspecific;
-    pthread_gettid_np;
+    pthread_gettid_np; # introduced=21
     pthread_join;
     pthread_key_create;
     pthread_key_delete;
@@ -775,7 +774,7 @@
     pthread_mutex_init;
     pthread_mutex_lock;
     pthread_mutex_lock_timeout_np; # arm x86 mips
-    pthread_mutex_timedlock;
+    pthread_mutex_timedlock; # introduced=21
     pthread_mutex_trylock;
     pthread_mutex_unlock;
     pthread_mutexattr_destroy;
@@ -795,10 +794,10 @@
     pthread_rwlock_unlock;
     pthread_rwlock_wrlock;
     pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getkind_np; # introduced=23
     pthread_rwlockattr_getpshared;
     pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setkind_np; # introduced=23
     pthread_rwlockattr_setpshared;
     pthread_self;
     pthread_setname_np;
@@ -818,38 +817,38 @@
     putw; # arm x86 mips
     putwc;
     putwchar;
-    pvalloc; # arm x86 mips
+    pvalloc; # arm x86 mips introduced=17
     pwrite;
-    pwrite64;
+    pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     qsort;
-    quick_exit;
+    quick_exit; # introduced=21
     raise;
-    rand;
-    rand_r;
-    random;
+    rand; # introduced=21
+    rand_r; # introduced=21
+    random; # introduced=21
     read;
-    readahead;
+    readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     readdir;
-    readdir64;
-    readdir64_r;
+    readdir64; # introduced=21
+    readdir64_r; # introduced=21
     readdir_r;
     readlink;
-    readlinkat;
+    readlinkat; # introduced=21
     readv;
     realloc;
     realpath;
     reboot;
     recv;
     recvfrom;
-    recvmmsg;
+    recvmmsg; # introduced=21
     recvmsg;
     regcomp;
     regerror;
     regexec;
     regfree;
     remove;
-    removexattr;
-    remque;
+    removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    remque; # introduced=21
     rename;
     renameat;
     res_init;
@@ -861,21 +860,21 @@
     rmdir;
     sbrk;
     scandir;
-    scandir64;
+    scandir64; # introduced=21
     scanf;
     sched_get_priority_max;
     sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
+    sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_getparam;
     sched_getscheduler;
     sched_rr_get_interval;
-    sched_setaffinity;
+    sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_setparam;
     sched_setscheduler;
     sched_yield;
     seed48;
-    seekdir;
+    seekdir; # introduced=23
     select;
     sem_close;
     sem_destroy;
@@ -889,8 +888,8 @@
     sem_wait;
     send;
     sendfile;
-    sendfile64;
-    sendmmsg;
+    sendfile64; # introduced=21
+    sendmmsg; # introduced=21
     sendmsg;
     sendto;
     setbuf;
@@ -898,101 +897,101 @@
     setegid;
     setenv;
     seteuid;
-    setfsgid;
-    setfsuid;
+    setfsgid; # introduced=21
+    setfsuid; # introduced=21
     setgid;
     setgroups;
-    sethostname;
+    sethostname; # introduced=23
     setitimer;
     setjmp;
     setlinebuf;
     setlocale;
     setlogmask;
-    setmntent;
-    setns;
+    setmntent; # introduced=21
+    setns; # introduced=21
     setpgid;
     setpgrp;
     setpriority;
-    setprogname;
+    setprogname; # introduced=21
     setregid;
     setresgid;
     setresuid;
     setreuid;
     setrlimit;
-    setrlimit64;
+    setrlimit64; # introduced=21
     setservent;
     setsid;
     setsockopt;
-    setstate;
+    setstate; # introduced=21
     settimeofday;
     setuid;
     setutent;
     setvbuf;
-    setxattr;
+    setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     shutdown;
     sigaction;
-    sigaddset;
+    sigaddset; # introduced=21
     sigaltstack;
     sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
+    sigdelset; # introduced=21
+    sigemptyset; # introduced=21
+    sigfillset; # introduced=21
     siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
+    sigismember; # introduced=21
+    siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    signal; # introduced=21
+    signalfd; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     sigpending;
     sigprocmask;
-    sigqueue;
-    sigsetjmp;
+    sigqueue; # introduced=23
+    sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sigsetmask;
     sigsuspend;
-    sigtimedwait;
+    sigtimedwait; # introduced=23
     sigwait;
-    sigwaitinfo;
+    sigwaitinfo; # introduced=23
     sleep;
     snprintf;
     socket;
     socketpair;
-    splice;
+    splice; # introduced=21
     sprintf;
-    srand;
+    srand; # introduced=21
     srand48;
-    srandom;
+    srandom; # introduced=21
     sscanf;
     stat;
-    stat64;
+    stat64; # introduced=21
     statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
+    statfs64; # introduced=21
+    statvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    statvfs64; # introduced=21
+    stderr; # var introduced=23
+    stdin; # var introduced=23
+    stdout; # var introduced=23
+    stpcpy; # introduced=21
+    stpncpy; # introduced=21
     strcasecmp;
-    strcasecmp_l;
+    strcasecmp_l; # introduced=23
     strcasestr;
     strcat;
     strchr;
     strcmp;
     strcoll;
-    strcoll_l;
+    strcoll_l; # introduced=21
     strcpy;
     strcspn;
     strdup;
     strerror;
-    strerror_l;
+    strerror_l; # introduced=23
     strerror_r;
     strftime;
-    strftime_l;
+    strftime_l; # introduced=21
     strlcat;
     strlcpy;
     strlen;
     strncasecmp;
-    strncasecmp_l;
+    strncasecmp_l; # introduced=23
     strncat;
     strncmp;
     strncpy;
@@ -1006,86 +1005,86 @@
     strspn;
     strstr;
     strtod;
-    strtof;
+    strtof; # introduced=21
     strtoimax;
     strtok;
     strtok_r;
     strtol;
-    strtold;
-    strtold_l;
+    strtold; # introduced=21
+    strtold_l; # introduced=21
     strtoll;
-    strtoll_l;
-    strtoq;
+    strtoll_l; # introduced=21
+    strtoq; # introduced=21
     strtoul;
     strtoull;
-    strtoull_l;
+    strtoull_l; # introduced=21
     strtoumax;
-    strtouq;
+    strtouq; # introduced=21
     strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
+    strxfrm_l; # introduced=21
+    swapoff; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    swapon; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     swprintf;
     swscanf;
     symlink;
-    symlinkat;
+    symlinkat; # introduced=21
     sync;
-    sys_siglist;
-    sys_signame;
+    sys_siglist; # var
+    sys_signame; # var
     syscall;
     sysconf;
     sysinfo;
     syslog;
     system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
+    tcdrain; # introduced=21
+    tcflow; # introduced=21
+    tcflush; # introduced=21
+    tcgetattr; # introduced=21
     tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
+    tcgetsid; # introduced=21
+    tcsendbreak; # introduced=21
+    tcsetattr; # introduced=21
     tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
+    tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tee; # introduced=21
+    telldir; # introduced=23
     tempnam;
-    tfind;
-    tgkill;
+    tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     time;
-    timegm;
+    timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timegm64; # arm x86 mips
-    timelocal;
+    timelocal; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timelocal64; # arm x86 mips
     timer_create;
     timer_delete;
     timer_getoverrun;
     timer_gettime;
     timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
+    timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     times;
-    timezone;
+    timezone; # var
     tmpfile;
     tmpnam;
     toascii;
     tolower;
-    tolower_l;
+    tolower_l; # introduced=21
     toupper;
-    toupper_l;
+    toupper_l; # introduced=21
     towlower;
-    towlower_l;
+    towlower_l; # introduced=21
     towupper;
-    towupper_l;
+    towupper_l; # introduced=21
     truncate;
-    truncate64;
-    tsearch;
+    truncate64; # introduced=21
+    tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     ttyname;
     ttyname_r;
-    twalk;
-    tzname;
+    twalk; # introduced=21
+    tzname; # var
     tzset;
     umask;
     umount;
@@ -1097,38 +1096,38 @@
     unlinkat;
     unlockpt;
     unsetenv;
-    unshare;
-    uselocale;
+    unshare; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    uselocale; # introduced=21
     usleep;
     utime;
-    utimensat;
+    utimensat; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     utimes;
     utmpname;
     valloc; # arm x86 mips
     vasprintf;
-    vdprintf;
+    vdprintf; # introduced=21
     verr;
     verrx;
     vfork;
     vfprintf;
     vfscanf;
     vfwprintf;
-    vfwscanf;
-    vmsplice;
+    vfwscanf; # introduced=21
+    vmsplice; # introduced=21
     vprintf;
     vscanf;
     vsnprintf;
     vsprintf;
     vsscanf;
     vswprintf;
-    vswscanf;
+    vswscanf; # introduced=21
     vsyslog;
     vwarn;
     vwarnx;
     vwprintf;
-    vwscanf;
+    vwscanf; # introduced=21
     wait;
-    wait4;
+    wait4; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     waitid;
     waitpid;
     warn;
@@ -1137,12 +1136,12 @@
     wcpncpy;
     wcrtomb;
     wcscasecmp;
-    wcscasecmp_l;
+    wcscasecmp_l; # introduced=23
     wcscat;
     wcschr;
     wcscmp;
     wcscoll;
-    wcscoll_l;
+    wcscoll_l; # introduced=21
     wcscpy;
     wcscspn;
     wcsdup;
@@ -1151,44 +1150,44 @@
     wcslcpy;
     wcslen;
     wcsncasecmp;
-    wcsncasecmp_l;
+    wcsncasecmp_l; # introduced=23
     wcsncat;
     wcsncmp;
     wcsncpy;
     wcsnlen;
-    wcsnrtombs;
+    wcsnrtombs; # introduced=21
     wcspbrk;
     wcsrchr;
     wcsrtombs;
     wcsspn;
     wcsstr;
     wcstod;
-    wcstof;
-    wcstoimax;
+    wcstof; # introduced=21
+    wcstoimax; # introduced=21
     wcstok;
     wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
+    wcstold; # introduced=21
+    wcstold_l; # introduced=21
+    wcstoll; # introduced=21
+    wcstoll_l; # introduced=21
     wcstombs;
     wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
+    wcstoull; # introduced=21
+    wcstoull_l; # introduced=21
+    wcstoumax; # introduced=21
     wcswidth;
     wcsxfrm;
-    wcsxfrm_l;
+    wcsxfrm_l; # introduced=21
     wctob;
-    wctomb;
+    wctomb; # introduced=21
     wctype;
-    wctype_l;
+    wctype_l; # introduced=21
     wcwidth;
     wmemchr;
     wmemcmp;
     wmemcpy;
     wmemmove;
-    wmempcpy;
+    wmempcpy; # introduced=23
     wmemset;
     wprintf;
     write;
@@ -1198,81 +1197,132 @@
     *;
 };
 
-LIBC_N {
+LIBC_N { # introduced-arm64=24 introduced-mips=24 introduced-mips64=24 introduced-x86=24 introduced-x86_64=24
   global:
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    prlimit; # arm mips x86
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
+    __fread_chk; # introduced=24
+    __fwrite_chk; # introduced=24
+    __getcwd_chk; # introduced=24
+    __pwrite_chk; # introduced=24
+    __pwrite64_chk; # introduced=24
+    __write_chk; # introduced=24
+    adjtimex; # introduced=24
+    clock_adjtime; # introduced=24
+    fgetpos64; # introduced=24
+    fileno_unlocked; # introduced=24
+    fopen64; # introduced=24
+    freeifaddrs; # introduced=24
+    freopen64; # introduced=24
+    fseeko64; # introduced=24
+    fsetpos64; # introduced=24
+    ftello64; # introduced=24
+    funopen64; # introduced=24
+    getgrgid_r; # introduced=24
+    getgrnam_r; # introduced=24
+    getifaddrs; # introduced=24
+    if_freenameindex; # introduced=24
+    if_nameindex; # introduced=24
+    in6addr_any; # var introduced=24
+    in6addr_loopback; # var introduced=24
+    lockf; # introduced=24
+    lockf64; # introduced=24
+    preadv; # introduced=24
+    preadv64; # introduced=24
+    prlimit; # arm mips x86 introduced=24
+    pthread_barrierattr_destroy; # introduced=24
+    pthread_barrierattr_getpshared; # introduced=24
+    pthread_barrierattr_init; # introduced=24
+    pthread_barrierattr_setpshared; # introduced=24
+    pthread_barrier_destroy; # introduced=24
+    pthread_barrier_init; # introduced=24
+    pthread_barrier_wait; # introduced=24
+    pthread_spin_destroy; # introduced=24
+    pthread_spin_init; # introduced=24
+    pthread_spin_lock; # introduced=24
+    pthread_spin_trylock; # introduced=24
+    pthread_spin_unlock; # introduced=24
+    pwritev; # introduced=24
+    pwritev64; # introduced=24
+    scandirat; # introduced=24
+    scandirat64; # introduced=24
+    strchrnul; # introduced=24
+    tmpfile64; # introduced=24
 } LIBC;
 
+LIBC_O {
+  global:
+    bsd_signal; # arm x86 mips versioned=26
+    catclose; # future
+    catgets; # future
+    catopen; # future
+    ctermid; # future
+    endgrent; # future
+    endpwent; # future
+    futimes; # future
+    futimesat; # future
+    getdomainname; # future
+    getgrent; # future
+    getpwent; # future
+    getsubopt; # future
+    hasmntopt; # future
+    lutimes; # future
+    mblen; # future
+    msgctl; # future
+    msgget; # future
+    msgrcv; # future
+    msgsnd; # future
+    pthread_getname_np; # future
+    quotactl; # future
+    semctl; # future
+    semget; # future
+    semop; # future
+    semtimedop; # future
+    setdomainname; # future
+    setgrent; # future
+    setpwent; # future
+    shmat; # future
+    shmctl; # future
+    shmdt; # future
+    shmget; # future
+    sighold; # future
+    sigignore; # future
+    sigpause; # future
+    sigrelse; # future
+    sigset; # future
+    strtod_l; # future
+    strtof_l; # future
+    strtol_l; # future
+    strtoul_l; # future
+    sync_file_range; # future
+    towctrans; # future
+    towctrans_l; # future
+    wctrans; # future
+    wctrans_l; # future
+} LIBC_N;
+
 LIBC_PRIVATE {
   global:
     __accept4; # arm x86 mips
     __bionic_brk; # arm x86 mips
     __bionic_libgcc_compat_symbols; # arm x86
     __divdi3; # arm x86 mips
-    __futex_wait; # arm x86 mips nobrillo
-    __futex_wake; # arm x86 mips nobrillo
-    __get_thread; # arm x86 mips nobrillo
-    __get_tls; # arm x86 mips nobrillo
+    __futex_wait; # arm x86 mips
+    __futex_wake; # arm x86 mips
+    __get_thread; # arm x86 mips
+    __get_tls; # arm x86 mips
     __getdents64; # arm x86 mips
-    __open; # arm x86 mips nobrillo
-    __page_shift; # arm x86 mips nobrillo
-    __page_size; # arm x86 mips nobrillo
+    __open; # arm x86 mips
+    __page_shift; # arm x86 mips
+    __page_size; # arm x86 mips
     __popcountsi2; # arm x86 mips
-    __pthread_gettid; # arm x86 mips nobrillo
+    __pthread_gettid; # arm x86 mips
     __sclose; # arm x86 mips
-    __sdidinit; # arm x86 mips nobrillo
-    __set_errno; # arm x86 mips nobrillo
+    __sdidinit; # arm x86 mips
+    __set_errno; # arm x86 mips
     __sflags; # arm x86 mips
     __sflush; # arm x86 mips
     __sfp; # arm x86 mips
     __sglue; # arm x86 mips
-    __sinit; # arm x86 mips nobrillo
+    __sinit; # arm x86 mips
     __smakebuf; # arm x86 mips
     __sread; # arm x86 mips
     __srefill; # arm x86 mips
@@ -1283,47 +1333,45 @@
     __swsetup; # arm x86 mips
     __udivdi3; # arm x86 mips
     __umoddi3; # x86 mips
-    __wait4; # arm x86 mips nobrillo
+    __wait4; # arm x86 mips
     _fwalk; # arm x86 mips
     android_getaddrinfofornet;
     android_getaddrinfofornetcontext;
     android_gethostbyaddrfornet;
     android_gethostbynamefornet;
-    arc4random_addrandom; # arm x86 mips nobrillo
-    arc4random_stir; # arm x86 mips nobrillo
-    bcopy; # arm x86 mips nobrillo
-    bzero; # arm x86 mips nobrillo
-    bsd_signal; # arm x86 mips nobrillo
-    dlmalloc; # arm x86 mips nobrillo
-    dlmalloc_inspect_all; # arm x86 mips nobrillo
-    dlmalloc_trim; # arm x86 mips nobrillo
-    dlmalloc_usable_size; # arm x86 mips nobrillo
-    endpwent; # arm x86 mips nobrillo
-    fdprintf; # arm x86 mips nobrillo
+    arc4random_addrandom; # arm x86 mips
+    arc4random_stir; # arm x86 mips
+    bcopy; # arm x86 mips
+    bzero; # arm x86 mips
+    dlmalloc; # arm x86 mips
+    dlmalloc_inspect_all; # arm x86 mips
+    dlmalloc_trim; # arm x86 mips
+    dlmalloc_usable_size; # arm x86 mips
+    fdprintf; # arm x86 mips
     free_malloc_leak_info;
-    ftime; # arm x86 mips nobrillo
+    ftime; # arm x86 mips
     get_malloc_leak_info;
-    getdents; # arm x86 mips nobrillo
-    getdtablesize; # arm x86 mips nobrillo
+    getdents; # arm x86 mips
+    getdtablesize; # arm x86 mips
     gMallocLeakZygoteChild;
-    index; # arm x86 mips nobrillo
-    issetugid; # arm x86 mips nobrillo
-    memswap; # arm x86 mips nobrillo
-    pthread_attr_getstackaddr; # arm x86 mips nobrillo
-    pthread_attr_setstackaddr; # arm x86 mips nobrillo
+    index; # arm x86 mips
+    issetugid; # arm x86 mips
+    memswap; # arm x86 mips
+    pthread_attr_getstackaddr; # arm x86 mips
+    pthread_attr_setstackaddr; # arm x86 mips
     SHA1Final; # arm x86 mips
     SHA1Init; # arm x86 mips
     SHA1Transform; # arm x86 mips
     SHA1Update; # arm x86 mips
-    strntoimax; # arm x86 mips nobrillo
-    strntoumax; # arm x86 mips nobrillo
-    strtotimeval; # arm x86 mips nobrillo
-    sysv_signal; # arm x86 mips nobrillo
-    tkill; # arm x86 mips nobrillo
-    vfdprintf; # arm x86 mips nobrillo
-    wait3; # arm x86 mips nobrillo
-    wcswcs; # arm x86 mips nobrillo
-} LIBC_N;
+    strntoimax; # arm x86 mips
+    strntoumax; # arm x86 mips
+    strtotimeval; # arm x86 mips
+    sysv_signal; # arm x86 mips
+    tkill; # arm x86 mips
+    vfdprintf; # arm x86 mips
+    wait3; # arm x86 mips
+    wcswcs; # arm x86 mips
+} LIBC_O;
 
 LIBC_PLATFORM {
   global:
@@ -1334,4 +1382,4 @@
     malloc_disable;
     malloc_enable;
     malloc_iterate;
-} LIBC_N;
+} LIBC_O;
diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map
index afbd0ee..28755d4 100644
--- a/libc/libc.x86_64.map
+++ b/libc/libc.x86_64.map
@@ -1,39 +1,39 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
     __assert;
     __assert2;
     __b64_ntop;
     __b64_pton;
-    __cmsg_nxthdr;
-    __ctype_get_mb_cur_max;
+    __cmsg_nxthdr; # introduced=21
+    __ctype_get_mb_cur_max; # introduced=21
     __cxa_atexit;
     __cxa_finalize;
-    __cxa_thread_atexit_impl;
+    __cxa_thread_atexit_impl; # introduced=23
     __dn_comp;
     __dn_count_labels;
     __dn_skipname;
     __errno;
-    __fbufsize;
-    __FD_CLR_chk;
-    __FD_ISSET_chk;
-    __FD_SET_chk;
-    __fgets_chk;
-    __flbf;
+    __fbufsize; # introduced=23
+    __FD_CLR_chk; # introduced=21
+    __FD_ISSET_chk; # introduced=21
+    __FD_SET_chk; # introduced=21
+    __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __flbf; # introduced=23
     __fp_nquery;
     __fp_query;
-    __fpclassify;
+    __fpclassify; # introduced=21
     __fpclassifyd;
     __fpclassifyf;
     __fpclassifyl;
-    __fpending;
-    __fpurge;
-    __freadable;
-    __fsetlocking;
-    __fwritable;
+    __fpending; # introduced=23
+    __fpurge; # introduced=23
+    __freadable; # introduced=23
+    __fsetlocking; # introduced=23
+    __fwritable; # introduced=23
     __get_h_errno;
-    __gnu_basename;
-    __gnu_strerror_r;
+    __gnu_basename; # introduced=23
+    __gnu_strerror_r; # introduced=23
     __hostalias;
     __isfinite;
     __isfinitef;
@@ -41,28 +41,28 @@
     __isinf;
     __isinff;
     __isinfl;
-    __isnan;
-    __isnanf;
+    __isnan; # introduced=21
+    __isnanf; # introduced=21
     __isnanl;
     __isnormal;
     __isnormalf;
     __isnormall;
-    __libc_current_sigrtmax;
-    __libc_current_sigrtmin;
+    __libc_current_sigrtmax; # introduced=21
+    __libc_current_sigrtmin; # introduced=21
     __libc_init;
     __loc_aton;
     __loc_ntoa;
-    __memchr_chk;
-    __memcpy_chk;
-    __memmove_chk;
-    __memrchr_chk;
-    __memset_chk;
-    __open_2;
-    __openat_2;
+    __memchr_chk; # introduced=23
+    __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __memrchr_chk; # introduced=23
+    __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __open_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __p_cdname;
     __p_cdnname;
     __p_class;
-    __p_class_syms;
+    __p_class_syms; # var
     __p_fqname;
     __p_fqnname;
     __p_option;
@@ -71,21 +71,21 @@
     __p_secstodate;
     __p_time;
     __p_type;
-    __p_type_syms;
-    __poll_chk;
-    __ppoll_chk;
-    __pread64_chk;
-    __pread_chk;
-    __progname;
+    __p_type_syms; # var
+    __poll_chk; # introduced=23
+    __ppoll_chk; # introduced=23
+    __pread64_chk; # introduced=23
+    __pread_chk; # introduced=23
+    __progname; # var
     __pthread_cleanup_pop;
     __pthread_cleanup_push;
     __putlong;
     __putshort;
-    __read_chk;
-    __readlink_chk;
-    __readlinkat_chk;
-    __recvfrom_chk;
-    __register_atfork;
+    __read_chk; # introduced=21
+    __readlink_chk; # introduced=23
+    __readlinkat_chk; # introduced=23
+    __recvfrom_chk; # introduced=21
+    __register_atfork; # introduced=23
     __res_close;
     __res_dnok;
     __res_hnok;
@@ -106,79 +106,79 @@
     __res_send;
     __res_send_setqhook;
     __res_send_setrhook;
-    __sched_cpualloc;
-    __sched_cpucount;
-    __sched_cpufree;
-    __sF;
-    __snprintf_chk;
-    __sprintf_chk;
+    __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __sF; # var
+    __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     __stack_chk_fail;
-    __stack_chk_guard;
-    __stpcpy_chk;
-    __stpncpy_chk;
-    __stpncpy_chk2;
-    __strcat_chk;
-    __strchr_chk;
-    __strcpy_chk;
-    __strlcat_chk;
-    __strlcpy_chk;
-    __strlen_chk;
-    __strncat_chk;
-    __strncpy_chk;
-    __strncpy_chk2;
-    __strrchr_chk;
+    __stack_chk_guard; # var
+    __stpcpy_chk; # introduced=21
+    __stpncpy_chk; # introduced=21
+    __stpncpy_chk2; # introduced=21
+    __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __strncpy_chk2; # introduced=21
+    __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     __sym_ntop;
     __sym_ntos;
     __sym_ston;
     __system_properties_init;
-    __system_property_add;
-    __system_property_area__;
-    __system_property_area_init;
-    __system_property_area_serial;
+    __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area__; # var
+    __system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_area_serial; # introduced=23
     __system_property_find;
     __system_property_find_nth;
-    __system_property_foreach;
+    __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     __system_property_get;
     __system_property_read;
-    __system_property_serial;
-    __system_property_set;
-    __system_property_set_filename;
-    __system_property_update;
-    __system_property_wait_any;
-    __umask_chk;
-    __vsnprintf_chk;
-    __vsprintf_chk;
-    _ctype_;
-    _Exit;
+    __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    __system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    _ctype_; # var
+    _Exit; # introduced=21
     _exit;
-    _flushlbf;
+    _flushlbf; # introduced=23
     _getlong;
     _getshort;
     _longjmp;
-    _resolv_delete_cache_for_net;
-    _resolv_flush_cache_for_net;
-    _resolv_set_nameservers_for_net;
+    _resolv_delete_cache_for_net; # introduced=21
+    _resolv_flush_cache_for_net; # introduced=21
+    _resolv_set_nameservers_for_net; # introduced=21
     _setjmp;
-    _tolower;
-    _toupper;
+    _tolower; # introduced=21
+    _toupper; # introduced=21
     abort;
-    abs;
+    abs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     accept;
-    accept4;
+    accept4; # introduced=21
     access;
     acct;
     alarm;
     alphasort;
-    alphasort64;
-    android_set_abort_message;
+    alphasort64; # introduced=21
+    android_set_abort_message; # introduced=21
     arc4random;
     arc4random_buf;
     arc4random_uniform;
     asctime;
     asctime_r;
     asprintf;
-    at_quick_exit;
-    atof;
+    at_quick_exit; # introduced=21
+    atof; # introduced=21
     atoi;
     atol;
     atoll;
@@ -188,74 +188,74 @@
     brk;
     bsearch;
     btowc;
-    c16rtomb;
-    c32rtomb;
+    c16rtomb; # introduced=21
+    c32rtomb; # introduced=21
     calloc;
     capget;
     capset;
-    cfgetispeed;
-    cfgetospeed;
-    cfmakeraw;
-    cfsetispeed;
-    cfsetospeed;
-    cfsetspeed;
+    cfgetispeed; # introduced=21
+    cfgetospeed; # introduced=21
+    cfmakeraw; # introduced=21
+    cfsetispeed; # introduced=21
+    cfsetospeed; # introduced=21
+    cfsetspeed; # introduced=21
     chdir;
     chmod;
     chown;
     chroot;
     clearenv;
     clearerr;
-    clearerr_unlocked;
+    clearerr_unlocked; # introduced=23
     clock;
-    clock_getcpuclockid;
+    clock_getcpuclockid; # introduced=23
     clock_getres;
     clock_gettime;
     clock_nanosleep;
     clock_settime;
-    clone;
+    clone; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     close;
     closedir;
     closelog;
     connect;
     creat;
-    creat64;
+    creat64; # introduced=21
     ctime;
     ctime_r;
     daemon;
-    daylight;
+    daylight; # var
     delete_module;
     difftime;
     dirfd;
     dirname;
     div;
     dn_expand;
-    dprintf;
+    dprintf; # introduced=21
     drand48;
     dup;
     dup2;
-    dup3;
-    duplocale;
-    endmntent;
+    dup3; # introduced=21
+    duplocale; # introduced=21
+    endmntent; # introduced=21
     endservent;
     endutent;
-    environ;
+    environ; # var
     epoll_create;
-    epoll_create1;
+    epoll_create1; # introduced=21
     epoll_ctl;
-    epoll_pwait;
+    epoll_pwait; # introduced=21
     epoll_wait;
     erand48;
     err;
-    error;
-    error_at_line;
-    error_message_count;
-    error_one_per_line;
-    error_print_progname;
+    error; # introduced=23
+    error_at_line; # introduced=23
+    error_message_count; # var introduced=23
+    error_one_per_line; # var introduced=23
+    error_print_progname; # var introduced=23
     errx;
-    ether_aton;
-    ether_aton_r;
-    ether_ntoa;
-    ether_ntoa_r;
+    ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     eventfd;
     eventfd_read;
     eventfd_write;
@@ -265,11 +265,11 @@
     execv;
     execve;
     execvp;
-    execvpe;
+    execvpe; # introduced=21
     exit;
-    faccessat;
-    fallocate;
-    fallocate64;
+    faccessat; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    fallocate; # introduced=21
+    fallocate64; # introduced=21
     fchdir;
     fchmod;
     fchmodat;
@@ -281,27 +281,27 @@
     fdopen;
     fdopendir;
     feof;
-    feof_unlocked;
+    feof_unlocked; # introduced=23
     ferror;
-    ferror_unlocked;
+    ferror_unlocked; # introduced=23
     fflush;
-    ffs;
+    ffs; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     fgetc;
     fgetln;
     fgetpos;
     fgets;
     fgetwc;
     fgetws;
-    fgetxattr;
+    fgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fileno;
-    flistxattr;
+    flistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     flock;
     flockfile;
-    fmemopen;
+    fmemopen; # introduced=23
     fnmatch;
     fopen;
     fork;
-    forkpty;
+    forkpty; # introduced=23
     fpathconf;
     fprintf;
     fpurge;
@@ -312,56 +312,56 @@
     fread;
     free;
     freeaddrinfo;
-    freelocale;
-    fremovexattr;
+    freelocale; # introduced=21
+    fremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     freopen;
     fscanf;
     fseek;
     fseeko;
     fsetpos;
-    fsetxattr;
+    fsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     fstat;
-    fstat64;
+    fstat64; # introduced=21
     fstatat;
-    fstatat64;
+    fstatat64; # introduced=21
     fstatfs;
-    fstatfs64;
-    fstatvfs;
-    fstatvfs64;
+    fstatfs64; # introduced=21
+    fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    fstatvfs64; # introduced=21
     fsync;
     ftell;
     ftello;
     ftok;
     ftruncate;
-    ftruncate64;
+    ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     ftrylockfile;
     fts_children;
     fts_close;
     fts_open;
     fts_read;
     fts_set;
-    ftw;
-    ftw64;
+    ftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    ftw64; # introduced=21
     funlockfile;
     funopen;
-    futimens;
+    futimens; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     fwide;
     fwprintf;
     fwrite;
     fwscanf;
     gai_strerror;
-    get_avphys_pages;
-    get_nprocs;
-    get_nprocs_conf;
-    get_phys_pages;
+    get_avphys_pages; # introduced=23
+    get_nprocs; # introduced=23
+    get_nprocs_conf; # introduced=23
+    get_phys_pages; # introduced=23
     getaddrinfo;
-    getauxval;
+    getauxval; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getc;
     getc_unlocked;
     getchar;
     getchar_unlocked;
     getcwd;
-    getdelim;
+    getdelim; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getegid;
     getenv;
     geteuid;
@@ -371,49 +371,49 @@
     getgrouplist;
     getgroups;
     gethostbyaddr;
-    gethostbyaddr_r;
+    gethostbyaddr_r; # introduced=23
     gethostbyname;
     gethostbyname2;
-    gethostbyname2_r;
+    gethostbyname2_r; # introduced=23
     gethostbyname_r;
     gethostent;
     gethostname;
     getitimer;
-    getline;
+    getline; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     getlogin;
     getmntent;
-    getmntent_r;
+    getmntent_r; # introduced=21
     getnameinfo;
     getnetbyaddr;
     getnetbyname;
     getopt;
     getopt_long;
     getopt_long_only;
-    getpagesize;
+    getpagesize; # introduced=21
     getpeername;
     getpgid;
     getpgrp;
     getpid;
     getppid;
     getpriority;
-    getprogname;
+    getprogname; # introduced=21
     getprotobyname;
     getprotobynumber;
     getpt;
     getpwnam;
-    getpwnam_r;
+    getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getpwuid;
-    getpwuid_r;
+    getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     getresgid;
     getresuid;
     getrlimit;
-    getrlimit64;
+    getrlimit64; # introduced=21
     getrusage;
     gets;
     getservbyname;
     getservbyport;
     getservent;
-    getsid;
+    getsid; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     getsockname;
     getsockopt;
     gettid;
@@ -422,24 +422,24 @@
     getutent;
     getwc;
     getwchar;
-    getxattr;
+    getxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     gmtime;
     gmtime_r;
-    grantpt;
+    grantpt; # introduced=21
     herror;
     hstrerror;
-    htonl;
-    htons;
+    htonl; # introduced=21
+    htons; # introduced=21
     if_indextoname;
     if_nametoindex;
-    imaxabs;
-    imaxdiv;
+    imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     inet_addr;
     inet_aton;
-    inet_lnaof;
-    inet_makeaddr;
-    inet_netof;
-    inet_network;
+    inet_lnaof; # introduced=21
+    inet_makeaddr; # introduced=21
+    inet_netof; # introduced=21
+    inet_network; # introduced=21
     inet_nsap_addr;
     inet_nsap_ntoa;
     inet_ntoa;
@@ -447,122 +447,122 @@
     inet_pton;
     init_module;
     initgroups;
-    initstate;
+    initstate; # introduced=21
     inotify_add_watch;
     inotify_init;
-    inotify_init1;
+    inotify_init1; # introduced=21
     inotify_rm_watch;
-    insque;
+    insque; # introduced=21
     ioctl;
     isalnum;
-    isalnum_l;
+    isalnum_l; # introduced=21
     isalpha;
-    isalpha_l;
+    isalpha_l; # introduced=21
     isascii;
     isatty;
     isblank;
-    isblank_l;
+    isblank_l; # introduced=21
     iscntrl;
-    iscntrl_l;
+    iscntrl_l; # introduced=21
     isdigit;
-    isdigit_l;
-    isfinite;
-    isfinitef;
-    isfinitel;
+    isdigit_l; # introduced=21
+    isfinite; # introduced=21
+    isfinitef; # introduced=21
+    isfinitel; # introduced=21
     isgraph;
-    isgraph_l;
-    isinf;
-    isinff;
-    isinfl;
+    isgraph_l; # introduced=21
+    isinf; # introduced=21
+    isinff; # introduced=21
+    isinfl; # introduced=21
     islower;
-    islower_l;
+    islower_l; # introduced=21
     isnan;
     isnanf;
-    isnanl;
-    isnormal;
-    isnormalf;
-    isnormall;
+    isnanl; # introduced=21
+    isnormal; # introduced=21
+    isnormalf; # introduced=21
+    isnormall; # introduced=21
     isprint;
-    isprint_l;
+    isprint_l; # introduced=21
     ispunct;
-    ispunct_l;
+    ispunct_l; # introduced=21
     isspace;
-    isspace_l;
+    isspace_l; # introduced=21
     isupper;
-    isupper_l;
+    isupper_l; # introduced=21
     iswalnum;
-    iswalnum_l;
+    iswalnum_l; # introduced=21
     iswalpha;
-    iswalpha_l;
-    iswblank;
-    iswblank_l;
+    iswalpha_l; # introduced=21
+    iswblank; # introduced=21
+    iswblank_l; # introduced=21
     iswcntrl;
-    iswcntrl_l;
+    iswcntrl_l; # introduced=21
     iswctype;
-    iswctype_l;
+    iswctype_l; # introduced=21
     iswdigit;
-    iswdigit_l;
+    iswdigit_l; # introduced=21
     iswgraph;
-    iswgraph_l;
+    iswgraph_l; # introduced=21
     iswlower;
-    iswlower_l;
+    iswlower_l; # introduced=21
     iswprint;
-    iswprint_l;
+    iswprint_l; # introduced=21
     iswpunct;
-    iswpunct_l;
+    iswpunct_l; # introduced=21
     iswspace;
-    iswspace_l;
+    iswspace_l; # introduced=21
     iswupper;
-    iswupper_l;
+    iswupper_l; # introduced=21
     iswxdigit;
-    iswxdigit_l;
+    iswxdigit_l; # introduced=21
     isxdigit;
-    isxdigit_l;
+    isxdigit_l; # introduced=21
     jrand48;
     kill;
     killpg;
     klogctl;
-    labs;
+    labs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lchown;
-    lcong48;
+    lcong48; # introduced=23
     ldexp;
     ldiv;
-    lfind;
-    lgetxattr;
+    lfind; # introduced=21
+    lgetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     link;
-    linkat;
+    linkat; # introduced=21
     listen;
-    listxattr;
-    llabs;
+    listxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    llabs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     lldiv;
-    llistxattr;
-    localeconv;
+    llistxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    localeconv; # introduced=21
     localtime;
     localtime_r;
-    login_tty;
+    login_tty; # introduced=23
     longjmp;
     lrand48;
-    lremovexattr;
-    lsearch;
+    lremovexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    lsearch; # introduced=21
     lseek;
     lseek64;
-    lsetxattr;
+    lsetxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     lstat;
-    lstat64;
+    lstat64; # introduced=21
     madvise;
     mallinfo;
     malloc;
-    malloc_info;
-    malloc_usable_size;
+    malloc_info; # introduced=23
+    malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mbrlen;
-    mbrtoc16;
-    mbrtoc32;
+    mbrtoc16; # introduced=21
+    mbrtoc32; # introduced=21
     mbrtowc;
     mbsinit;
-    mbsnrtowcs;
+    mbsnrtowcs; # introduced=21
     mbsrtowcs;
     mbstowcs;
-    mbtowc;
+    mbtowc; # introduced=21
     memalign;
     memccpy;
     memchr;
@@ -570,113 +570,113 @@
     memcpy;
     memmem;
     memmove;
-    mempcpy;
+    mempcpy; # introduced=23
     memrchr;
     memset;
     mincore;
     mkdir;
     mkdirat;
     mkdtemp;
-    mkfifo;
-    mkfifoat;
+    mkfifo; # introduced=21
+    mkfifoat; # introduced=23
     mknod;
-    mknodat;
-    mkostemp;
-    mkostemp64;
-    mkostemps;
-    mkostemps64;
+    mknodat; # introduced=21
+    mkostemp; # introduced=23
+    mkostemp64; # introduced=23
+    mkostemps; # introduced=23
+    mkostemps64; # introduced=23
     mkstemp;
-    mkstemp64;
+    mkstemp64; # introduced=21
     mkstemps;
-    mkstemps64;
+    mkstemps64; # introduced=23
     mktemp;
     mktime;
     mlock;
-    mlockall;
+    mlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     mmap;
-    mmap64;
+    mmap64; # introduced=21
     mount;
     mprotect;
     mrand48;
     mremap;
     msync;
     munlock;
-    munlockall;
+    munlockall; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
     munmap;
     nanosleep;
-    newlocale;
-    nftw;
-    nftw64;
+    newlocale; # introduced=21
+    nftw; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    nftw64; # introduced=21
     nice;
     nrand48;
-    ns_format_ttl; # arm64 x86_64 mips64
-    ns_get16; # arm64 x86_64 mips64
-    ns_get32; # arm64 x86_64 mips64
-    ns_initparse; # arm64 x86_64 mips64
-    ns_makecanon; # arm64 x86_64 mips64
-    ns_msg_getflag; # arm64 x86_64 mips64
-    ns_name_compress; # arm64 x86_64 mips64
-    ns_name_ntol; # arm64 x86_64 mips64
-    ns_name_ntop; # arm64 x86_64 mips64
-    ns_name_pack; # arm64 x86_64 mips64
-    ns_name_pton; # arm64 x86_64 mips64
-    ns_name_rollback; # arm64 x86_64 mips64
-    ns_name_skip; # arm64 x86_64 mips64
-    ns_name_uncompress; # arm64 x86_64 mips64
-    ns_name_unpack; # arm64 x86_64 mips64
-    ns_parserr; # arm64 x86_64 mips64
-    ns_put16; # arm64 x86_64 mips64
-    ns_put32; # arm64 x86_64 mips64
-    ns_samename; # arm64 x86_64 mips64
-    ns_skiprr; # arm64 x86_64 mips64
-    ns_sprintrr; # arm64 x86_64 mips64
-    ns_sprintrrf; # arm64 x86_64 mips64
+    ns_format_ttl; # arm64 x86_64 mips64 introduced=22
+    ns_get16; # arm64 x86_64 mips64 introduced=22
+    ns_get32; # arm64 x86_64 mips64 introduced=22
+    ns_initparse; # arm64 x86_64 mips64 introduced=22
+    ns_makecanon; # arm64 x86_64 mips64 introduced=22
+    ns_msg_getflag; # arm64 x86_64 mips64 introduced=22
+    ns_name_compress; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntol; # arm64 x86_64 mips64 introduced=22
+    ns_name_ntop; # arm64 x86_64 mips64 introduced=22
+    ns_name_pack; # arm64 x86_64 mips64 introduced=22
+    ns_name_pton; # arm64 x86_64 mips64 introduced=23
+    ns_name_rollback; # arm64 x86_64 mips64 introduced=22
+    ns_name_skip; # arm64 x86_64 mips64 introduced=22
+    ns_name_uncompress; # arm64 x86_64 mips64 introduced=22
+    ns_name_unpack; # arm64 x86_64 mips64 introduced=22
+    ns_parserr; # arm64 x86_64 mips64 introduced=22
+    ns_put16; # arm64 x86_64 mips64 introduced=22
+    ns_put32; # arm64 x86_64 mips64 introduced=22
+    ns_samename; # arm64 x86_64 mips64 introduced=22
+    ns_skiprr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrr; # arm64 x86_64 mips64 introduced=22
+    ns_sprintrrf; # arm64 x86_64 mips64 introduced=22
     nsdispatch;
-    ntohl;
-    ntohs;
+    ntohl; # introduced=21
+    ntohs; # introduced=21
     open;
-    open64;
-    open_memstream;
-    open_wmemstream;
+    open64; # introduced=21
+    open_memstream; # introduced=23
+    open_wmemstream; # introduced=23
     openat;
-    openat64;
+    openat64; # introduced=21
     opendir;
     openlog;
-    openpty;
-    optarg;
-    opterr;
-    optind;
-    optopt;
-    optreset;
+    openpty; # introduced=23
+    optarg; # var
+    opterr; # var
+    optind; # var
+    optopt; # var
+    optreset; # var
     pathconf;
     pause;
     pclose;
     perror;
-    personality;
+    personality; # introduced-arm=15 introduced-arm64=21 introduced-mips=15 introduced-mips64=21 introduced-x86=15 introduced-x86_64=21
     pipe;
     pipe2;
     poll;
     popen;
-    posix_fadvise;
-    posix_fadvise64;
-    posix_fallocate;
-    posix_fallocate64;
-    posix_madvise;
-    posix_memalign;
-    posix_openpt;
-    ppoll;
+    posix_fadvise; # introduced=21
+    posix_fadvise64; # introduced=21
+    posix_fallocate; # introduced=21
+    posix_fallocate64; # introduced=21
+    posix_madvise; # introduced=23
+    posix_memalign; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    posix_openpt; # introduced=21
+    ppoll; # introduced=21
     prctl;
     pread;
-    pread64;
+    pread64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     printf;
     prlimit; # arm64 x86_64 mips64
-    prlimit64;
-    process_vm_readv;
-    process_vm_writev;
+    prlimit64; # introduced=21
+    process_vm_readv; # introduced=23
+    process_vm_writev; # introduced=23
     pselect;
-    psiginfo;
-    psignal;
-    pthread_atfork;
+    psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    psignal; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     pthread_attr_destroy;
     pthread_attr_getdetachstate;
     pthread_attr_getguardsize;
@@ -700,10 +700,10 @@
     pthread_cond_timedwait;
     pthread_cond_wait;
     pthread_condattr_destroy;
-    pthread_condattr_getclock;
+    pthread_condattr_getclock; # introduced=21
     pthread_condattr_getpshared;
     pthread_condattr_init;
-    pthread_condattr_setclock;
+    pthread_condattr_setclock; # introduced=21
     pthread_condattr_setpshared;
     pthread_create;
     pthread_detach;
@@ -713,7 +713,7 @@
     pthread_getcpuclockid;
     pthread_getschedparam;
     pthread_getspecific;
-    pthread_gettid_np;
+    pthread_gettid_np; # introduced=21
     pthread_join;
     pthread_key_create;
     pthread_key_delete;
@@ -721,7 +721,7 @@
     pthread_mutex_destroy;
     pthread_mutex_init;
     pthread_mutex_lock;
-    pthread_mutex_timedlock;
+    pthread_mutex_timedlock; # introduced=21
     pthread_mutex_trylock;
     pthread_mutex_unlock;
     pthread_mutexattr_destroy;
@@ -741,10 +741,10 @@
     pthread_rwlock_unlock;
     pthread_rwlock_wrlock;
     pthread_rwlockattr_destroy;
-    pthread_rwlockattr_getkind_np;
+    pthread_rwlockattr_getkind_np; # introduced=23
     pthread_rwlockattr_getpshared;
     pthread_rwlockattr_init;
-    pthread_rwlockattr_setkind_np;
+    pthread_rwlockattr_setkind_np; # introduced=23
     pthread_rwlockattr_setpshared;
     pthread_self;
     pthread_setname_np;
@@ -764,36 +764,36 @@
     putwc;
     putwchar;
     pwrite;
-    pwrite64;
+    pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     qsort;
-    quick_exit;
+    quick_exit; # introduced=21
     raise;
-    rand;
-    rand_r;
-    random;
+    rand; # introduced=21
+    rand_r; # introduced=21
+    random; # introduced=21
     read;
-    readahead;
+    readahead; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     readdir;
-    readdir64;
-    readdir64_r;
+    readdir64; # introduced=21
+    readdir64_r; # introduced=21
     readdir_r;
     readlink;
-    readlinkat;
+    readlinkat; # introduced=21
     readv;
     realloc;
     realpath;
     reboot;
     recv;
     recvfrom;
-    recvmmsg;
+    recvmmsg; # introduced=21
     recvmsg;
     regcomp;
     regerror;
     regexec;
     regfree;
     remove;
-    removexattr;
-    remque;
+    removexattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    remque; # introduced=21
     rename;
     renameat;
     res_init;
@@ -805,21 +805,21 @@
     rmdir;
     sbrk;
     scandir;
-    scandir64;
+    scandir64; # introduced=21
     scanf;
     sched_get_priority_max;
     sched_get_priority_min;
-    sched_getaffinity;
-    sched_getcpu;
+    sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_getparam;
     sched_getscheduler;
     sched_rr_get_interval;
-    sched_setaffinity;
+    sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sched_setparam;
     sched_setscheduler;
     sched_yield;
     seed48;
-    seekdir;
+    seekdir; # introduced=23
     select;
     sem_close;
     sem_destroy;
@@ -833,8 +833,8 @@
     sem_wait;
     send;
     sendfile;
-    sendfile64;
-    sendmmsg;
+    sendfile64; # introduced=21
+    sendmmsg; # introduced=21
     sendmsg;
     sendto;
     setbuf;
@@ -842,101 +842,101 @@
     setegid;
     setenv;
     seteuid;
-    setfsgid;
-    setfsuid;
+    setfsgid; # introduced=21
+    setfsuid; # introduced=21
     setgid;
     setgroups;
-    sethostname;
+    sethostname; # introduced=23
     setitimer;
     setjmp;
     setlinebuf;
     setlocale;
     setlogmask;
-    setmntent;
-    setns;
+    setmntent; # introduced=21
+    setns; # introduced=21
     setpgid;
     setpgrp;
     setpriority;
-    setprogname;
+    setprogname; # introduced=21
     setregid;
     setresgid;
     setresuid;
     setreuid;
     setrlimit;
-    setrlimit64;
+    setrlimit64; # introduced=21
     setservent;
     setsid;
     setsockopt;
-    setstate;
+    setstate; # introduced=21
     settimeofday;
     setuid;
     setutent;
     setvbuf;
-    setxattr;
+    setxattr; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     shutdown;
     sigaction;
-    sigaddset;
+    sigaddset; # introduced=21
     sigaltstack;
     sigblock;
-    sigdelset;
-    sigemptyset;
-    sigfillset;
+    sigdelset; # introduced=21
+    sigemptyset; # introduced=21
+    sigfillset; # introduced=21
     siginterrupt;
-    sigismember;
-    siglongjmp;
-    signal;
-    signalfd;
+    sigismember; # introduced=21
+    siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    signal; # introduced=21
+    signalfd; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     sigpending;
     sigprocmask;
-    sigqueue;
-    sigsetjmp;
+    sigqueue; # introduced=23
+    sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     sigsetmask;
     sigsuspend;
-    sigtimedwait;
+    sigtimedwait; # introduced=23
     sigwait;
-    sigwaitinfo;
+    sigwaitinfo; # introduced=23
     sleep;
     snprintf;
     socket;
     socketpair;
-    splice;
+    splice; # introduced=21
     sprintf;
-    srand;
+    srand; # introduced=21
     srand48;
-    srandom;
+    srandom; # introduced=21
     sscanf;
     stat;
-    stat64;
+    stat64; # introduced=21
     statfs;
-    statfs64;
-    statvfs;
-    statvfs64;
-    stderr;
-    stdin;
-    stdout;
-    stpcpy;
-    stpncpy;
+    statfs64; # introduced=21
+    statvfs; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    statvfs64; # introduced=21
+    stderr; # var introduced=23
+    stdin; # var introduced=23
+    stdout; # var introduced=23
+    stpcpy; # introduced=21
+    stpncpy; # introduced=21
     strcasecmp;
-    strcasecmp_l;
+    strcasecmp_l; # introduced=23
     strcasestr;
     strcat;
     strchr;
     strcmp;
     strcoll;
-    strcoll_l;
+    strcoll_l; # introduced=21
     strcpy;
     strcspn;
     strdup;
     strerror;
-    strerror_l;
+    strerror_l; # introduced=23
     strerror_r;
     strftime;
-    strftime_l;
+    strftime_l; # introduced=21
     strlcat;
     strlcpy;
     strlen;
     strncasecmp;
-    strncasecmp_l;
+    strncasecmp_l; # introduced=23
     strncat;
     strncmp;
     strncpy;
@@ -950,84 +950,84 @@
     strspn;
     strstr;
     strtod;
-    strtof;
+    strtof; # introduced=21
     strtoimax;
     strtok;
     strtok_r;
     strtol;
-    strtold;
-    strtold_l;
+    strtold; # introduced=21
+    strtold_l; # introduced=21
     strtoll;
-    strtoll_l;
-    strtoq;
+    strtoll_l; # introduced=21
+    strtoq; # introduced=21
     strtoul;
     strtoull;
-    strtoull_l;
+    strtoull_l; # introduced=21
     strtoumax;
-    strtouq;
+    strtouq; # introduced=21
     strxfrm;
-    strxfrm_l;
-    swapoff;
-    swapon;
+    strxfrm_l; # introduced=21
+    swapoff; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    swapon; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     swprintf;
     swscanf;
     symlink;
-    symlinkat;
+    symlinkat; # introduced=21
     sync;
-    sys_siglist;
-    sys_signame;
+    sys_siglist; # var
+    sys_signame; # var
     syscall;
     sysconf;
     sysinfo;
     syslog;
     system;
-    tcdrain;
-    tcflow;
-    tcflush;
-    tcgetattr;
+    tcdrain; # introduced=21
+    tcflow; # introduced=21
+    tcflush; # introduced=21
+    tcgetattr; # introduced=21
     tcgetpgrp;
-    tcgetsid;
-    tcsendbreak;
-    tcsetattr;
+    tcgetsid; # introduced=21
+    tcsendbreak; # introduced=21
+    tcsetattr; # introduced=21
     tcsetpgrp;
-    tdelete;
-    tdestroy;
-    tee;
-    telldir;
+    tdelete; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tdestroy; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tee; # introduced=21
+    telldir; # introduced=23
     tempnam;
-    tfind;
-    tgkill;
+    tfind; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
+    tgkill; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     time;
-    timegm;
-    timelocal;
+    timegm; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
+    timelocal; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     timer_create;
     timer_delete;
     timer_getoverrun;
     timer_gettime;
     timer_settime;
-    timerfd_create;
-    timerfd_gettime;
-    timerfd_settime;
+    timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
+    timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
     times;
-    timezone;
+    timezone; # var
     tmpfile;
     tmpnam;
     toascii;
     tolower;
-    tolower_l;
+    tolower_l; # introduced=21
     toupper;
-    toupper_l;
+    toupper_l; # introduced=21
     towlower;
-    towlower_l;
+    towlower_l; # introduced=21
     towupper;
-    towupper_l;
+    towupper_l; # introduced=21
     truncate;
-    truncate64;
-    tsearch;
+    truncate64; # introduced=21
+    tsearch; # introduced-arm=16 introduced-arm64=21 introduced-mips=16 introduced-mips64=21 introduced-x86=16 introduced-x86_64=21
     ttyname;
     ttyname_r;
-    twalk;
-    tzname;
+    twalk; # introduced=21
+    tzname; # var
     tzset;
     umask;
     umount;
@@ -1039,37 +1039,37 @@
     unlinkat;
     unlockpt;
     unsetenv;
-    unshare;
-    uselocale;
+    unshare; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
+    uselocale; # introduced=21
     usleep;
     utime;
-    utimensat;
+    utimensat; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
     utimes;
     utmpname;
     vasprintf;
-    vdprintf;
+    vdprintf; # introduced=21
     verr;
     verrx;
     vfork;
     vfprintf;
     vfscanf;
     vfwprintf;
-    vfwscanf;
-    vmsplice;
+    vfwscanf; # introduced=21
+    vmsplice; # introduced=21
     vprintf;
     vscanf;
     vsnprintf;
     vsprintf;
     vsscanf;
     vswprintf;
-    vswscanf;
+    vswscanf; # introduced=21
     vsyslog;
     vwarn;
     vwarnx;
     vwprintf;
-    vwscanf;
+    vwscanf; # introduced=21
     wait;
-    wait4;
+    wait4; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     waitid;
     waitpid;
     warn;
@@ -1078,12 +1078,12 @@
     wcpncpy;
     wcrtomb;
     wcscasecmp;
-    wcscasecmp_l;
+    wcscasecmp_l; # introduced=23
     wcscat;
     wcschr;
     wcscmp;
     wcscoll;
-    wcscoll_l;
+    wcscoll_l; # introduced=21
     wcscpy;
     wcscspn;
     wcsdup;
@@ -1092,44 +1092,44 @@
     wcslcpy;
     wcslen;
     wcsncasecmp;
-    wcsncasecmp_l;
+    wcsncasecmp_l; # introduced=23
     wcsncat;
     wcsncmp;
     wcsncpy;
     wcsnlen;
-    wcsnrtombs;
+    wcsnrtombs; # introduced=21
     wcspbrk;
     wcsrchr;
     wcsrtombs;
     wcsspn;
     wcsstr;
     wcstod;
-    wcstof;
-    wcstoimax;
+    wcstof; # introduced=21
+    wcstoimax; # introduced=21
     wcstok;
     wcstol;
-    wcstold;
-    wcstold_l;
-    wcstoll;
-    wcstoll_l;
+    wcstold; # introduced=21
+    wcstold_l; # introduced=21
+    wcstoll; # introduced=21
+    wcstoll_l; # introduced=21
     wcstombs;
     wcstoul;
-    wcstoull;
-    wcstoull_l;
-    wcstoumax;
+    wcstoull; # introduced=21
+    wcstoull_l; # introduced=21
+    wcstoumax; # introduced=21
     wcswidth;
     wcsxfrm;
-    wcsxfrm_l;
+    wcsxfrm_l; # introduced=21
     wctob;
-    wctomb;
+    wctomb; # introduced=21
     wctype;
-    wctype_l;
+    wctype_l; # introduced=21
     wcwidth;
     wmemchr;
     wmemcmp;
     wmemcpy;
     wmemmove;
-    wmempcpy;
+    wmempcpy; # introduced=23
     wmemset;
     wprintf;
     write;
@@ -1139,56 +1139,106 @@
     *;
 };
 
-LIBC_N {
+LIBC_N { # introduced-arm64=24 introduced-mips=24 introduced-mips64=24 introduced-x86=24 introduced-x86_64=24
   global:
-    __fread_chk;
-    __fwrite_chk;
-    __getcwd_chk;
-    __pwrite_chk;
-    __pwrite64_chk;
-    __write_chk;
-    adjtimex;
-    clock_adjtime;
-    fgetpos64;
-    fileno_unlocked;
-    fopen64;
-    freeifaddrs;
-    freopen64;
-    fseeko64;
-    fsetpos64;
-    ftello64;
-    funopen64;
-    getgrgid_r;
-    getgrnam_r;
-    getifaddrs;
-    if_freenameindex;
-    if_nameindex;
-    in6addr_any;
-    in6addr_loopback;
-    lockf;
-    lockf64;
-    preadv;
-    preadv64;
-    pthread_barrierattr_destroy;
-    pthread_barrierattr_getpshared;
-    pthread_barrierattr_init;
-    pthread_barrierattr_setpshared;
-    pthread_barrier_destroy;
-    pthread_barrier_init;
-    pthread_barrier_wait;
-    pthread_spin_destroy;
-    pthread_spin_init;
-    pthread_spin_lock;
-    pthread_spin_trylock;
-    pthread_spin_unlock;
-    pwritev;
-    pwritev64;
-    scandirat;
-    scandirat64;
-    strchrnul;
-    tmpfile64;
+    __fread_chk; # introduced=24
+    __fwrite_chk; # introduced=24
+    __getcwd_chk; # introduced=24
+    __pwrite_chk; # introduced=24
+    __pwrite64_chk; # introduced=24
+    __write_chk; # introduced=24
+    adjtimex; # introduced=24
+    clock_adjtime; # introduced=24
+    fgetpos64; # introduced=24
+    fileno_unlocked; # introduced=24
+    fopen64; # introduced=24
+    freeifaddrs; # introduced=24
+    freopen64; # introduced=24
+    fseeko64; # introduced=24
+    fsetpos64; # introduced=24
+    ftello64; # introduced=24
+    funopen64; # introduced=24
+    getgrgid_r; # introduced=24
+    getgrnam_r; # introduced=24
+    getifaddrs; # introduced=24
+    if_freenameindex; # introduced=24
+    if_nameindex; # introduced=24
+    in6addr_any; # var introduced=24
+    in6addr_loopback; # var introduced=24
+    lockf; # introduced=24
+    lockf64; # introduced=24
+    preadv; # introduced=24
+    preadv64; # introduced=24
+    pthread_barrierattr_destroy; # introduced=24
+    pthread_barrierattr_getpshared; # introduced=24
+    pthread_barrierattr_init; # introduced=24
+    pthread_barrierattr_setpshared; # introduced=24
+    pthread_barrier_destroy; # introduced=24
+    pthread_barrier_init; # introduced=24
+    pthread_barrier_wait; # introduced=24
+    pthread_spin_destroy; # introduced=24
+    pthread_spin_init; # introduced=24
+    pthread_spin_lock; # introduced=24
+    pthread_spin_trylock; # introduced=24
+    pthread_spin_unlock; # introduced=24
+    pwritev; # introduced=24
+    pwritev64; # introduced=24
+    scandirat; # introduced=24
+    scandirat64; # introduced=24
+    strchrnul; # introduced=24
+    tmpfile64; # introduced=24
 } LIBC;
 
+LIBC_O {
+  global:
+    catclose; # future
+    catgets; # future
+    catopen; # future
+    ctermid; # future
+    endgrent; # future
+    endpwent; # future
+    futimes; # future
+    futimesat; # future
+    getdomainname; # future
+    getgrent; # future
+    getpwent; # future
+    getsubopt; # future
+    hasmntopt; # future
+    lutimes; # future
+    mblen; # future
+    msgctl; # future
+    msgget; # future
+    msgrcv; # future
+    msgsnd; # future
+    pthread_getname_np; # future
+    quotactl; # future
+    semctl; # future
+    semget; # future
+    semop; # future
+    semtimedop; # future
+    setdomainname; # future
+    setgrent; # future
+    setpwent; # future
+    shmat; # future
+    shmctl; # future
+    shmdt; # future
+    shmget; # future
+    sighold; # future
+    sigignore; # future
+    sigpause; # future
+    sigrelse; # future
+    sigset; # future
+    strtod_l; # future
+    strtof_l; # future
+    strtol_l; # future
+    strtoul_l; # future
+    sync_file_range; # future
+    towctrans; # future
+    towctrans_l; # future
+    wctrans; # future
+    wctrans_l; # future
+} LIBC_N;
+
 LIBC_PRIVATE {
   global:
     android_getaddrinfofornet;
@@ -1198,7 +1248,7 @@
     free_malloc_leak_info;
     get_malloc_leak_info;
     gMallocLeakZygoteChild;
-} LIBC_N;
+} LIBC_O;
 
 LIBC_PLATFORM {
   global:
@@ -1209,4 +1259,4 @@
     malloc_disable;
     malloc_enable;
     malloc_iterate;
-} LIBC_N;
+} LIBC_O;
diff --git a/libc/libstdc++.arm.map b/libc/libstdc++.arm.map
new file mode 100644
index 0000000..b6b269d
--- /dev/null
+++ b/libc/libstdc++.arm.map
@@ -0,0 +1,19 @@
+# Generated by genversion-scripts.py. Do not edit.
+LIBC_O {
+  global:
+    _ZSt7nothrow; # var
+    _ZdaPv;
+    _ZdaPvRKSt9nothrow_t;
+    _ZdlPv;
+    _ZdlPvRKSt9nothrow_t;
+    _Znaj; # arm x86 mips
+    _ZnajRKSt9nothrow_t; # arm x86 mips
+    _Znwj; # arm x86 mips
+    _ZnwjRKSt9nothrow_t; # arm x86 mips
+    __cxa_guard_abort;
+    __cxa_guard_acquire;
+    __cxa_guard_release;
+    __cxa_pure_virtual;
+  local:
+    *;
+};
diff --git a/libc/libstdc++.arm64.map b/libc/libstdc++.arm64.map
new file mode 100644
index 0000000..d0433c9
--- /dev/null
+++ b/libc/libstdc++.arm64.map
@@ -0,0 +1,19 @@
+# Generated by genversion-scripts.py. Do not edit.
+LIBC_O {
+  global:
+    _ZSt7nothrow; # var
+    _ZdaPv;
+    _ZdaPvRKSt9nothrow_t;
+    _ZdlPv;
+    _ZdlPvRKSt9nothrow_t;
+    _Znam; # arm64 x86_64 mips64
+    _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
+    _Znwm; # arm64 x86_64 mips64
+    _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+    __cxa_guard_abort;
+    __cxa_guard_acquire;
+    __cxa_guard_release;
+    __cxa_pure_virtual;
+  local:
+    *;
+};
diff --git a/libc/libstdc++.map.txt b/libc/libstdc++.map.txt
new file mode 100644
index 0000000..32d5d49
--- /dev/null
+++ b/libc/libstdc++.map.txt
@@ -0,0 +1,22 @@
+LIBC_O {
+  global:
+    _ZSt7nothrow; # var
+    _ZdaPv;
+    _ZdaPvRKSt9nothrow_t;
+    _ZdlPv;
+    _ZdlPvRKSt9nothrow_t;
+    _Znaj; # arm x86 mips
+    _ZnajRKSt9nothrow_t; # arm x86 mips
+    _Znam; # arm64 x86_64 mips64
+    _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
+    _Znwj; # arm x86 mips
+    _ZnwjRKSt9nothrow_t; # arm x86 mips
+    _Znwm; # arm64 x86_64 mips64
+    _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+    __cxa_guard_abort;
+    __cxa_guard_acquire;
+    __cxa_guard_release;
+    __cxa_pure_virtual;
+  local:
+    *;
+};
diff --git a/libc/libstdc++.mips.map b/libc/libstdc++.mips.map
new file mode 100644
index 0000000..b6b269d
--- /dev/null
+++ b/libc/libstdc++.mips.map
@@ -0,0 +1,19 @@
+# Generated by genversion-scripts.py. Do not edit.
+LIBC_O {
+  global:
+    _ZSt7nothrow; # var
+    _ZdaPv;
+    _ZdaPvRKSt9nothrow_t;
+    _ZdlPv;
+    _ZdlPvRKSt9nothrow_t;
+    _Znaj; # arm x86 mips
+    _ZnajRKSt9nothrow_t; # arm x86 mips
+    _Znwj; # arm x86 mips
+    _ZnwjRKSt9nothrow_t; # arm x86 mips
+    __cxa_guard_abort;
+    __cxa_guard_acquire;
+    __cxa_guard_release;
+    __cxa_pure_virtual;
+  local:
+    *;
+};
diff --git a/libc/libstdc++.mips64.map b/libc/libstdc++.mips64.map
new file mode 100644
index 0000000..d0433c9
--- /dev/null
+++ b/libc/libstdc++.mips64.map
@@ -0,0 +1,19 @@
+# Generated by genversion-scripts.py. Do not edit.
+LIBC_O {
+  global:
+    _ZSt7nothrow; # var
+    _ZdaPv;
+    _ZdaPvRKSt9nothrow_t;
+    _ZdlPv;
+    _ZdlPvRKSt9nothrow_t;
+    _Znam; # arm64 x86_64 mips64
+    _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
+    _Znwm; # arm64 x86_64 mips64
+    _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+    __cxa_guard_abort;
+    __cxa_guard_acquire;
+    __cxa_guard_release;
+    __cxa_pure_virtual;
+  local:
+    *;
+};
diff --git a/libc/libstdc++.x86.map b/libc/libstdc++.x86.map
new file mode 100644
index 0000000..b6b269d
--- /dev/null
+++ b/libc/libstdc++.x86.map
@@ -0,0 +1,19 @@
+# Generated by genversion-scripts.py. Do not edit.
+LIBC_O {
+  global:
+    _ZSt7nothrow; # var
+    _ZdaPv;
+    _ZdaPvRKSt9nothrow_t;
+    _ZdlPv;
+    _ZdlPvRKSt9nothrow_t;
+    _Znaj; # arm x86 mips
+    _ZnajRKSt9nothrow_t; # arm x86 mips
+    _Znwj; # arm x86 mips
+    _ZnwjRKSt9nothrow_t; # arm x86 mips
+    __cxa_guard_abort;
+    __cxa_guard_acquire;
+    __cxa_guard_release;
+    __cxa_pure_virtual;
+  local:
+    *;
+};
diff --git a/libc/libstdc++.x86_64.map b/libc/libstdc++.x86_64.map
new file mode 100644
index 0000000..d0433c9
--- /dev/null
+++ b/libc/libstdc++.x86_64.map
@@ -0,0 +1,19 @@
+# Generated by genversion-scripts.py. Do not edit.
+LIBC_O {
+  global:
+    _ZSt7nothrow; # var
+    _ZdaPv;
+    _ZdaPvRKSt9nothrow_t;
+    _ZdlPv;
+    _ZdlPvRKSt9nothrow_t;
+    _Znam; # arm64 x86_64 mips64
+    _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
+    _Znwm; # arm64 x86_64 mips64
+    _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+    __cxa_guard_abort;
+    __cxa_guard_acquire;
+    __cxa_guard_release;
+    __cxa_pure_virtual;
+  local:
+    *;
+};
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
new file mode 100644
index 0000000..8ce3ff3
--- /dev/null
+++ b/libc/malloc_debug/Android.bp
@@ -0,0 +1,132 @@
+// ==============================================================
+// libc_malloc_debug_backtrace.a
+// ==============================================================
+// Used by libmemunreachable
+cc_library_static {
+
+    name: "libc_malloc_debug_backtrace",
+
+    srcs: [
+        "backtrace.cpp",
+        "MapData.cpp",
+    ],
+
+    stl: "libc++_static",
+
+    static_libs: ["libc_logging"],
+
+    include_dirs: ["bionic/libc"],
+    export_include_dirs: ["."],
+
+    sanitize: {
+        never: true,
+    },
+    native_coverage: false,
+
+    // -Wno-error=format-zero-length needed for gcc to compile.
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-Wno-error=format-zero-length",
+    ],
+
+}
+
+// ==============================================================
+// libc_malloc_debug.so
+// ==============================================================
+cc_library {
+    name: "libc_malloc_debug",
+
+    srcs: [
+        "BacktraceData.cpp",
+        "Config.cpp",
+        "DebugData.cpp",
+        "debug_disable.cpp",
+        "FreeTrackData.cpp",
+        "GuardData.cpp",
+        "malloc_debug.cpp",
+        "RecordData.cpp",
+        "TrackData.cpp",
+    ],
+
+    stl: "libc++_static",
+
+    // Only need this for arm since libc++ uses its own unwind code that
+    // doesn't mix with the other default unwind code.
+    arch: {
+        arm: {
+            static_libs: ["libunwind_llvm"],
+        },
+    },
+
+    static_libs: [
+        "libbase",
+        "libc_malloc_debug_backtrace",
+        "libc_logging",
+    ],
+
+    multilib: {
+        lib32: {
+            version_script: "exported32.map",
+        },
+        lib64: {
+            version_script: "exported64.map",
+        },
+    },
+    allow_undefined_symbols: true,
+    include_dirs: ["bionic/libc"],
+
+    sanitize: {
+        never: true,
+    },
+    native_coverage: false,
+
+    // -Wno-error=format-zero-length needed for gcc to compile.
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-fno-stack-protector",
+        "-Wno-error=format-zero-length",
+    ],
+
+}
+
+// ==============================================================
+// Unit Tests
+// ==============================================================
+cc_test {
+
+    name: "malloc_debug_unit_tests",
+    multilib: {
+        lib32: {
+            suffix: "32",
+        },
+        lib64: {
+            suffix: "64",
+        },
+    },
+
+    srcs: [
+        "tests/backtrace_fake.cpp",
+        "tests/log_fake.cpp",
+        "tests/libc_fake.cpp",
+        "tests/property_fake.cpp",
+        "tests/malloc_debug_config_tests.cpp",
+        "tests/malloc_debug_unit_tests.cpp",
+    ],
+
+    whole_static_libs: ["libc_malloc_debug"],
+
+    local_include_dirs: ["tests"],
+    include_dirs: ["bionic/libc"],
+
+    shared_libs: ["libbase"],
+
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-Wno-error=format-zero-length",
+    ],
+
+}
diff --git a/libc/malloc_debug/Android.mk b/libc/malloc_debug/Android.mk
deleted file mode 100644
index 3576611..0000000
--- a/libc/malloc_debug/Android.mk
+++ /dev/null
@@ -1,109 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-libc_malloc_debug_src_files := \
-    BacktraceData.cpp \
-    Config.cpp \
-    DebugData.cpp \
-    debug_disable.cpp \
-    FreeTrackData.cpp \
-    GuardData.cpp \
-    malloc_debug.cpp \
-    TrackData.cpp \
-
-# ==============================================================
-# libc_malloc_debug_backtrace.a
-# ==============================================================
-# Used by libmemunreachable
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libc_malloc_debug_backtrace
-
-LOCAL_SRC_FILES := \
-    backtrace.cpp \
-    MapData.cpp \
-
-LOCAL_CXX_STL := libc++_static
-
-LOCAL_STATIC_LIBRARIES += \
-    libc_logging \
-
-LOCAL_C_INCLUDES += bionic/libc
-LOCAL_EXPORT_C_INCLUDE_DIRS += $(LOCAL_PATH)
-
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := false
-
-# -Wno-error=format-zero-length needed for gcc to compile.
-LOCAL_CFLAGS := \
-    -Wall \
-    -Werror \
-    -Wno-error=format-zero-length \
-
-include $(BUILD_STATIC_LIBRARY)
-
-# ==============================================================
-# libc_malloc_debug.so
-# ==============================================================
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libc_malloc_debug
-
-LOCAL_SRC_FILES := \
-    $(libc_malloc_debug_src_files) \
-
-LOCAL_CXX_STL := libc++_static
-
-# Only need this for arm since libc++ uses its own unwind code that
-# doesn't mix with the other default unwind code.
-LOCAL_STATIC_LIBRARIES_arm := libunwind_llvm
-
-LOCAL_STATIC_LIBRARIES += \
-    libc_malloc_debug_backtrace \
-    libc_logging \
-
-LOCAL_LDFLAGS_32 := -Wl,--version-script,$(LOCAL_PATH)/exported32.map
-LOCAL_LDFLAGS_64 := -Wl,--version-script,$(LOCAL_PATH)/exported64.map
-LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
-LOCAL_C_INCLUDES += bionic/libc
-
-LOCAL_SANITIZE := never
-LOCAL_NATIVE_COVERAGE := false
-
-# -Wno-error=format-zero-length needed for gcc to compile.
-LOCAL_CFLAGS := \
-    -Wall \
-    -Werror \
-    -fno-stack-protector \
-    -Wno-error=format-zero-length \
-
-include $(BUILD_SHARED_LIBRARY)
-
-# ==============================================================
-# Unit Tests
-# ==============================================================
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := malloc_debug_unit_tests
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SRC_FILES := \
-    tests/backtrace_fake.cpp \
-    tests/log_fake.cpp \
-    tests/libc_fake.cpp \
-    tests/property_fake.cpp \
-    tests/malloc_debug_config_tests.cpp \
-    tests/malloc_debug_unit_tests.cpp \
-    $(libc_malloc_debug_src_files) \
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/tests
-LOCAL_C_INCLUDES += bionic/libc
-
-LOCAL_SHARED_LIBRARIES := libbase
-
-LOCAL_CFLAGS := \
-    -Wall \
-    -Werror \
-    -Wno-error=format-zero-length \
-
-include $(BUILD_NATIVE_TEST)
diff --git a/libc/malloc_debug/BacktraceData.cpp b/libc/malloc_debug/BacktraceData.cpp
index 400e282..3d46bf0 100644
--- a/libc/malloc_debug/BacktraceData.cpp
+++ b/libc/malloc_debug/BacktraceData.cpp
@@ -41,27 +41,24 @@
 #include "debug_log.h"
 #include "malloc_debug.h"
 
-BacktraceData::BacktraceData(const Config& config, size_t* offset) {
+static void EnableToggle(int, siginfo_t*, void*) {
+  if (g_debug->backtrace->enabled()) {
+    g_debug->backtrace->set_enabled(false);
+  } else {
+    g_debug->backtrace->set_enabled(true);
+  }
+}
+
+BacktraceData::BacktraceData(DebugData* debug_data, const Config& config, size_t* offset)
+    : OptionData(debug_data) {
   size_t hdr_len = sizeof(BacktraceHeader) + sizeof(uintptr_t) * config.backtrace_frames;
   alloc_offset_ = *offset;
   *offset += BIONIC_ALIGN(hdr_len, MINIMUM_ALIGNMENT_BYTES);
 }
 
-static BacktraceData* g_backtrace_data = nullptr;
-
-static void EnableToggle(int, siginfo_t*, void*) {
-  if (g_backtrace_data->enabled()) {
-    g_backtrace_data->set_enabled(false);
-  } else {
-    g_backtrace_data->set_enabled(true);
-  }
-}
-
 bool BacktraceData::Initialize(const Config& config) {
   enabled_ = config.backtrace_enabled;
   if (config.backtrace_enable_on_signal) {
-    g_backtrace_data = this;
-
     struct sigaction enable_act;
     memset(&enable_act, 0, sizeof(enable_act));
 
diff --git a/libc/malloc_debug/BacktraceData.h b/libc/malloc_debug/BacktraceData.h
index 842e372..dbc3989 100644
--- a/libc/malloc_debug/BacktraceData.h
+++ b/libc/malloc_debug/BacktraceData.h
@@ -33,12 +33,14 @@
 
 #include <private/bionic_macros.h>
 
+#include "OptionData.h"
+
 // Forward declarations.
 struct Config;
 
-class BacktraceData {
+class BacktraceData : public OptionData {
  public:
-  BacktraceData(const Config& config, size_t* offset);
+  BacktraceData(DebugData* debug_data, const Config& config, size_t* offset);
   virtual ~BacktraceData() = default;
 
   bool Initialize(const Config& config);
diff --git a/libc/malloc_debug/Config.cpp b/libc/malloc_debug/Config.cpp
index cc60086..c9fb850 100644
--- a/libc/malloc_debug/Config.cpp
+++ b/libc/malloc_debug/Config.cpp
@@ -64,29 +64,126 @@
 static constexpr size_t DEFAULT_FREE_TRACK_ALLOCATIONS = 100;
 static constexpr size_t MAX_FREE_TRACK_ALLOCATIONS = 16384;
 
-struct Feature {
-  Feature(std::string name, size_t default_value, size_t min_value, size_t max_value,
-          uint64_t option, size_t* value, bool* config, bool combo_option)
-      : name(name), default_value(default_value), min_value(min_value), max_value(max_value),
-        option(option), value(value), config(config), combo_option(combo_option) {}
-  std::string name;
-  size_t default_value = 0;
-  size_t min_value = 0;
-  size_t max_value = 0;
+static constexpr size_t DEFAULT_RECORD_ALLOCS = 8000000;
+static constexpr size_t MAX_RECORD_ALLOCS = 50000000;
+static constexpr const char DEFAULT_RECORD_ALLOCS_FILE[] = "/data/local/tmp/record_allocs.txt";
 
-  uint64_t option = 0;
-  size_t* value = nullptr;
-  bool* config = nullptr;
+struct Option {
+  Option(std::string name, uint64_t option, bool combo_option = false, bool* config = nullptr)
+      : name(name), option(option), combo_option(combo_option), config(config) {}
+  virtual ~Option() = default;
+
+  std::string name;
+
+  uint64_t option;
   // If set to true, then all of the options following are set on until
-  // for which the combo_option value is set.
+  // the combo_option value is set to false.
   bool combo_option = false;
+  bool* config;
+
+  virtual bool ParseValue(const std::string& option_name, const std::string& value) const;
+
+  virtual void SetDefault() const { }
 };
 
+bool Option::ParseValue(const std::string& option_name, const std::string& raw_value) const {
+  if (!raw_value.empty()) {
+    error_log("%s: value set for option '%s' which does not take a value",
+              getprogname(), option_name.c_str());
+    return false;
+  }
+  return true;
+}
+
+struct OptionString : public Option {
+  OptionString(std::string name, uint64_t option, std::string default_value,
+                std::string* value, bool combo_option = false,
+                bool* config = nullptr)
+      : Option(name, option, combo_option, config), default_value(default_value), value(value) {}
+  virtual ~OptionString() = default;
+
+  std::string default_value;
+  std::string* value;
+
+  bool ParseValue(const std::string& option_name, const std::string& value) const override;
+
+  void SetDefault() const override { if (value) *value = default_value; }
+};
+
+bool OptionString::ParseValue(const std::string&, const std::string& raw_value) const {
+  if (!raw_value.empty()) {
+    *value = raw_value;
+  }
+  return true;
+}
+
+struct OptionSizeT : public Option {
+  OptionSizeT(std::string name, size_t default_value, size_t min_value, size_t max_value,
+          uint64_t option, size_t* value, bool combo_option = false, bool* config = nullptr)
+      : Option(name, option, combo_option, config), default_value(default_value),
+        min_value(min_value), max_value(max_value), value(value) {}
+  virtual ~OptionSizeT() = default;
+
+  size_t default_value;
+  size_t min_value;
+  size_t max_value;
+
+  size_t* value;
+
+  bool ParseValue(const std::string& option_name, const std::string& value) const override;
+
+  void SetDefault() const override { if (value) *value = default_value; }
+};
+
+bool OptionSizeT::ParseValue(const std::string& option_name, const std::string& raw_value) const {
+  if (raw_value.empty()) {
+    // Value should have been set by the SetDefault() pass.
+    return true;
+  }
+
+  // Parse the value into a size_t value.
+  errno = 0;
+  char* end;
+  long parsed_value = strtol(raw_value.c_str(), &end, 10);
+  if (errno != 0) {
+    error_log("%s: bad value for option '%s': %s", getprogname(), option_name.c_str(),
+              strerror(errno));
+    return false;
+  }
+  if (end == raw_value.c_str()) {
+    error_log("%s: bad value for option '%s'", getprogname(), option_name.c_str());
+    return false;
+  }
+  if (static_cast<size_t>(end - raw_value.c_str()) != raw_value.size()) {
+    error_log("%s: bad value for option '%s', non space found after option: %s",
+              getprogname(), option_name.c_str(), end);
+    return false;
+  }
+  if (parsed_value < 0) {
+    error_log("%s: bad value for option '%s', value cannot be negative: %ld",
+              getprogname(), option_name.c_str(), parsed_value);
+    return false;
+  }
+
+  if (static_cast<size_t>(parsed_value) < min_value) {
+    error_log("%s: bad value for option '%s', value must be >= %zu: %ld",
+              getprogname(), option_name.c_str(), min_value, parsed_value);
+    return false;
+  }
+  if (static_cast<size_t>(parsed_value) > max_value) {
+    error_log("%s: bad value for option '%s', value must be <= %zu: %ld",
+              getprogname(), option_name.c_str(), max_value, parsed_value);
+    return false;
+  }
+  *value = static_cast<size_t>(parsed_value);
+  return true;
+}
+
 class PropertyParser {
  public:
-  PropertyParser(const char* property) : cur_(property) {}
+  explicit PropertyParser(const char* property) : cur_(property) {}
 
-  bool Get(std::string* property, size_t* value, bool* value_set);
+  bool Get(std::string* property, std::string* value);
 
   bool Done() { return done_; }
 
@@ -100,7 +197,7 @@
   DISALLOW_COPY_AND_ASSIGN(PropertyParser);
 };
 
-bool PropertyParser::Get(std::string* property, size_t* value, bool* value_set) {
+bool PropertyParser::Get(std::string* property, std::string* value) {
   // Process each property name we can find.
   while (isspace(*cur_))
     ++cur_;
@@ -110,44 +207,30 @@
     return false;
   }
 
-  const char* property_start = cur_;
+  const char* start = cur_;
   while (!isspace(*cur_) && *cur_ != '=' && *cur_ != '\0')
     ++cur_;
 
-  *property = std::string(property_start, cur_ - property_start);
+  *property = std::string(start, cur_ - start);
 
   // Skip any spaces after the name.
-  while (isspace(*cur_) && *cur_ != '=' && *cur_ != '\0')
+  while (isspace(*cur_))
     ++cur_;
 
+  value->clear();
   if (*cur_ == '=') {
     ++cur_;
-    errno = 0;
-    *value_set = true;
-    char* end;
-    long read_value = strtol(cur_, const_cast<char**>(&end), 10);
-    if (errno != 0) {
-      error_log("%s: bad value for option '%s': %s", getprogname(), property->c_str(),
-                strerror(errno));
-      return false;
+    // Skip the space after the equal.
+    while (isspace(*cur_))
+      ++cur_;
+
+    start = cur_;
+    while (!isspace(*cur_) && *cur_ != '\0')
+      ++cur_;
+
+    if (cur_ != start) {
+      *value = std::string(start, cur_ - start);
     }
-    if (cur_ == end || (!isspace(*end) && *end != '\0')) {
-      if (cur_ == end) {
-        error_log("%s: bad value for option '%s'", getprogname(), property->c_str());
-      } else {
-        error_log("%s: bad value for option '%s', non space found after option: %s",
-                  getprogname(), property->c_str(), end);
-      }
-      return false;
-    } else if (read_value < 0) {
-      error_log("%s: bad value for option '%s', value cannot be negative: %ld",
-                getprogname(), property->c_str(), read_value);
-      return false;
-    }
-    *value = static_cast<size_t>(read_value);
-    cur_ = end;
-  } else {
-    *value_set = false;
   }
   return true;
 }
@@ -229,34 +312,19 @@
   error_log("");
   error_log("  leak_track");
   error_log("    Enable the leak tracking of memory allocations.");
-}
-
-static bool SetFeature(
-    const std::string name, const Feature& feature, size_t value, bool value_set) {
-  if (feature.config) {
-    *feature.config = true;
-  }
-  if (feature.value != nullptr) {
-    if (value_set) {
-      if (value < feature.min_value) {
-        error_log("%s: bad value for option '%s', value must be >= %zu: %zu",
-                  getprogname(), name.c_str(), feature.min_value, value);
-        return false;
-      } else if (value > feature.max_value) {
-        error_log("%s: bad value for option '%s', value must be <= %zu: %zu",
-                  getprogname(), name.c_str(), feature.max_value, value);
-        return false;
-      }
-      *feature.value = value;
-    } else {
-      *feature.value = feature.default_value;
-    }
-  } else if (value_set) {
-     error_log("%s: value set for option '%s' which does not take a value",
-               getprogname(), name.c_str());
-     return false;
-  }
-  return true;
+  error_log("");
+  error_log("  record_allocs[=XX]");
+  error_log("    Record every single allocation/free call. When a specific signal");
+  error_log("    is sent to the process, the contents of recording are written to");
+  error_log("    a file (%s) and the recording is cleared.", DEFAULT_RECORD_ALLOCS_FILE);
+  error_log("    If XX is set, that is the total number of allocations/frees that can");
+  error_log("    recorded. of frames to capture. The default value is %zu.", DEFAULT_RECORD_ALLOCS);
+  error_log("    If the allocation list fills up, all further allocations are not recorded.");
+  error_log("");
+  error_log("  record_allocs_file[=FILE]");
+  error_log("    This option only has meaning if the record_allocs options has been specified.");
+  error_log("    This is the name of the file to which recording information will be dumped.");
+  error_log("    The default is %s.", DEFAULT_RECORD_ALLOCS_FILE);
 }
 
 // This function is designed to be called once. A second call will not
@@ -274,88 +342,123 @@
   front_guard_value = DEFAULT_FRONT_GUARD_VALUE;
   rear_guard_value = DEFAULT_REAR_GUARD_VALUE;
   backtrace_signal = SIGRTMAX - 19;
-  free_track_backtrace_num_frames = 16;
+  record_allocs_signal = SIGRTMAX - 18;
+  free_track_backtrace_num_frames = 0;
+  record_allocs_file.clear();
 
   // Parse the options are of the format:
   //   option_name or option_name=XX
 
-  // Supported features:
-  const Feature features[] = {
-    Feature("guard", DEFAULT_GUARD_BYTES, 1, MAX_GUARD_BYTES, 0, nullptr, nullptr, true),
-    // Enable front guard. Value is the size of the guard.
-    Feature("front_guard", DEFAULT_GUARD_BYTES, 1, MAX_GUARD_BYTES, FRONT_GUARD,
-            &this->front_guard_bytes, nullptr, true),
-    // Enable end guard. Value is the size of the guard.
-    Feature("rear_guard", DEFAULT_GUARD_BYTES, 1, MAX_GUARD_BYTES, REAR_GUARD,
-            &this->rear_guard_bytes, nullptr, true),
+  // Supported options:
+  const OptionSizeT option_guard(
+      "guard", DEFAULT_GUARD_BYTES, 1, MAX_GUARD_BYTES, 0, nullptr, true);
+  // Enable front guard. Value is the size of the guard.
+  const OptionSizeT option_front_guard(
+      "front_guard", DEFAULT_GUARD_BYTES, 1, MAX_GUARD_BYTES, FRONT_GUARD,
+      &this->front_guard_bytes, true);
+  // Enable end guard. Value is the size of the guard.
+  const OptionSizeT option_rear_guard(
+      "rear_guard", DEFAULT_GUARD_BYTES, 1, MAX_GUARD_BYTES, REAR_GUARD, &this->rear_guard_bytes,
+      true);
 
-    // Enable logging the backtrace on allocation. Value is the total
-    // number of frames to log.
-    Feature("backtrace", DEFAULT_BACKTRACE_FRAMES, 1, MAX_BACKTRACE_FRAMES,
-            BACKTRACE | TRACK_ALLOCS, &this->backtrace_frames, &this->backtrace_enabled, false),
-    // Enable gathering backtrace values on a signal.
-    Feature("backtrace_enable_on_signal", DEFAULT_BACKTRACE_FRAMES, 1, MAX_BACKTRACE_FRAMES,
-            BACKTRACE | TRACK_ALLOCS, &this->backtrace_frames, &this->backtrace_enable_on_signal,
-            false),
+  // Enable logging the backtrace on allocation. Value is the total
+  // number of frames to log.
+  const OptionSizeT option_backtrace(
+      "backtrace", DEFAULT_BACKTRACE_FRAMES, 1, MAX_BACKTRACE_FRAMES, BACKTRACE | TRACK_ALLOCS,
+      &this->backtrace_frames, false, &this->backtrace_enabled);
+  // Enable gathering backtrace values on a signal.
+  const OptionSizeT option_backtrace_enable_on_signal(
+      "backtrace_enable_on_signal", DEFAULT_BACKTRACE_FRAMES, 1, MAX_BACKTRACE_FRAMES,
+      BACKTRACE | TRACK_ALLOCS, &this->backtrace_frames, false, &this->backtrace_enable_on_signal);
 
-    Feature("fill", SIZE_MAX, 1, SIZE_MAX, 0, nullptr, nullptr, true),
-    // Fill the allocation with an arbitrary pattern on allocation.
-    // Value is the number of bytes of the allocation to fill
-    // (default entire allocation).
-    Feature("fill_on_alloc", SIZE_MAX, 1, SIZE_MAX, FILL_ON_ALLOC, &this->fill_on_alloc_bytes,
-            nullptr, true),
-    // Fill the allocation with an arbitrary pattern on free.
-    // Value is the number of bytes of the allocation to fill
-    // (default entire allocation).
-    Feature("fill_on_free", SIZE_MAX, 1, SIZE_MAX, FILL_ON_FREE, &this->fill_on_free_bytes, nullptr, true),
+  const OptionSizeT option_fill("fill", SIZE_MAX, 1, SIZE_MAX, 0, nullptr, true);
+  // Fill the allocation with an arbitrary pattern on allocation.
+  // Value is the number of bytes of the allocation to fill
+  // (default entire allocation).
+  const OptionSizeT option_fill_on_alloc(
+      "fill_on_alloc", SIZE_MAX, 1, SIZE_MAX, FILL_ON_ALLOC, &this->fill_on_alloc_bytes, true);
+  // Fill the allocation with an arbitrary pattern on free.
+  // Value is the number of bytes of the allocation to fill
+  // (default entire allocation).
+  const OptionSizeT option_fill_on_free(
+      "fill_on_free", SIZE_MAX, 1, SIZE_MAX, FILL_ON_FREE, &this->fill_on_free_bytes, true);
 
-    // Expand the size of every alloc by this number bytes. Value is
-    // the total number of bytes to expand every allocation by.
-    Feature ("expand_alloc", DEFAULT_EXPAND_BYTES, 1, MAX_EXPAND_BYTES, EXPAND_ALLOC,
-             &this->expand_alloc_bytes, nullptr, false),
+  // Expand the size of every alloc by this number bytes. Value is
+  // the total number of bytes to expand every allocation by.
+  const OptionSizeT option_expand_alloc(
+      "expand_alloc", DEFAULT_EXPAND_BYTES, 1, MAX_EXPAND_BYTES, EXPAND_ALLOC,
+      &this->expand_alloc_bytes);
 
-    // Keep track of the freed allocations and verify at a later date
-    // that they have not been used. Turning this on, also turns on
-    // fill on free.
-    Feature("free_track", DEFAULT_FREE_TRACK_ALLOCATIONS, 1, MAX_FREE_TRACK_ALLOCATIONS,
-            FREE_TRACK | FILL_ON_FREE, &this->free_track_allocations, nullptr, false),
-    // Number of backtrace frames to keep when free_track is enabled. If this
-    // value is set to zero, no backtrace will be kept.
-    Feature("free_track_backtrace_num_frames", DEFAULT_BACKTRACE_FRAMES,
-            0, MAX_BACKTRACE_FRAMES, 0, &this->free_track_backtrace_num_frames, nullptr, false),
+  // Keep track of the freed allocations and verify at a later date
+  // that they have not been used. Turning this on, also turns on
+  // fill on free.
+  const OptionSizeT option_free_track(
+      "free_track", DEFAULT_FREE_TRACK_ALLOCATIONS, 1, MAX_FREE_TRACK_ALLOCATIONS,
+      FREE_TRACK | FILL_ON_FREE, &this->free_track_allocations);
+  // Number of backtrace frames to keep when free_track is enabled. If this
+  // value is set to zero, no backtrace will be kept.
+  const OptionSizeT option_free_track_backtrace_num_frames(
+      "free_track_backtrace_num_frames", DEFAULT_BACKTRACE_FRAMES, 0, MAX_BACKTRACE_FRAMES, 0,
+      &this->free_track_backtrace_num_frames);
 
-    // Enable printing leaked allocations.
-    Feature("leak_track", 0, 0, 0, LEAK_TRACK | TRACK_ALLOCS, nullptr, nullptr, false),
+  // Enable printing leaked allocations.
+  const Option option_leak_track("leak_track", LEAK_TRACK | TRACK_ALLOCS);
+
+  const OptionSizeT option_record_allocs(
+      "record_allocs", DEFAULT_RECORD_ALLOCS, 1, MAX_RECORD_ALLOCS, RECORD_ALLOCS,
+      &this->record_allocs_num_entries);
+  const OptionString option_record_allocs_file(
+      "record_allocs_file", 0, DEFAULT_RECORD_ALLOCS_FILE, &this->record_allocs_file);
+
+  const Option* option_list[] = {
+    &option_guard, &option_front_guard, &option_rear_guard,
+    &option_backtrace, &option_backtrace_enable_on_signal,
+    &option_fill, &option_fill_on_alloc, &option_fill_on_free,
+    &option_expand_alloc,
+    &option_free_track, &option_free_track_backtrace_num_frames,
+    &option_leak_track,
+    &option_record_allocs, &option_record_allocs_file,
   };
 
+  // Set defaults for all of the options.
+  for (size_t i = 0; i < sizeof(option_list)/sizeof(Option*); i++) {
+    option_list[i]->SetDefault();
+  }
+
   // Process each property name we can find.
-  std::string property;
-  size_t value;
-  bool value_set;
   PropertyParser parser(property_str);
   bool valid = true;
-  while (valid && parser.Get(&property, &value, &value_set)) {
+  std::string property;
+  std::string value;
+  while (valid && parser.Get(&property, &value)) {
     bool found = false;
-    for (size_t i = 0; i < sizeof(features)/sizeof(Feature); i++) {
-      if (property == features[i].name) {
-        if (features[i].option == 0 && features[i].combo_option) {
+    for (size_t i = 0; i < sizeof(option_list)/sizeof(Option*); i++) {
+      if (property == option_list[i]->name) {
+        if (option_list[i]->option == 0 && option_list[i]->combo_option) {
+          const std::string* option_name = &option_list[i]->name;
           i++;
-          for (; i < sizeof(features)/sizeof(Feature) && features[i].combo_option; i++) {
-            if (!SetFeature(property, features[i], value, value_set)) {
+          for (; i < sizeof(option_list)/sizeof(Option*) && option_list[i]->combo_option; i++) {
+            if (!option_list[i]->ParseValue(*option_name, value)) {
               valid = false;
               break;
             }
-            options |= features[i].option;
+            if (option_list[i]->config) {
+              *option_list[i]->config = true;
+            }
+            options |= option_list[i]->option;
           }
           if (!valid) {
             break;
           }
         } else {
-          if (!SetFeature(property, features[i], value, value_set)) {
+          if (!option_list[i]->ParseValue(option_list[i]->name, value)) {
             valid = false;
             break;
           }
-          options |= features[i].option;
+          if (option_list[i]->config) {
+            *option_list[i]->config = true;
+          }
+          options |= option_list[i]->option;
         }
         found = true;
         break;
@@ -376,13 +479,6 @@
     if (options & FRONT_GUARD) {
       front_guard_bytes = BIONIC_ALIGN(front_guard_bytes, MINIMUM_ALIGNMENT_BYTES);
     }
-
-    // This situation can occur if the free_track option is specified and
-    // the fill_on_free option is not. In this case, indicate the whole
-    // allocation should be filled.
-    if ((options & FILL_ON_FREE) && fill_on_free_bytes == 0) {
-      fill_on_free_bytes = SIZE_MAX;
-    }
   } else {
     parser.LogUsage();
   }
diff --git a/libc/malloc_debug/Config.h b/libc/malloc_debug/Config.h
index cb1de5a..ac620ad 100644
--- a/libc/malloc_debug/Config.h
+++ b/libc/malloc_debug/Config.h
@@ -31,6 +31,8 @@
 
 #include <stdint.h>
 
+#include <string>
+
 constexpr uint64_t FRONT_GUARD = 0x1;
 constexpr uint64_t REAR_GUARD = 0x2;
 constexpr uint64_t BACKTRACE = 0x4;
@@ -40,6 +42,7 @@
 constexpr uint64_t FREE_TRACK = 0x40;
 constexpr uint64_t TRACK_ALLOCS = 0x80;
 constexpr uint64_t LEAK_TRACK = 0x100;
+constexpr uint64_t RECORD_ALLOCS = 0x200;
 
 // In order to guarantee posix compliance, set the minimum alignment
 // to 8 bytes for 32 bit systems and 16 bytes for 64 bit systems.
@@ -49,8 +52,8 @@
 constexpr size_t MINIMUM_ALIGNMENT_BYTES = 8;
 #endif
 
-// If only one or more of these options is set, then no special header is needed.
-constexpr uint64_t NO_HEADER_OPTIONS = FILL_ON_ALLOC | FILL_ON_FREE | EXPAND_ALLOC;
+// If one or more of these options is set, then a special header is needed.
+constexpr uint64_t HEADER_OPTIONS = FRONT_GUARD | REAR_GUARD | BACKTRACE | FREE_TRACK | LEAK_TRACK;
 
 struct Config {
   bool SetFromProperties();
@@ -71,6 +74,10 @@
   size_t free_track_allocations = 0;
   size_t free_track_backtrace_num_frames = 0;
 
+  int record_allocs_signal = 0;
+  size_t record_allocs_num_entries = 0;
+  std::string record_allocs_file;
+
   uint64_t options = 0;
   uint8_t fill_alloc_value;
   uint8_t fill_free_value;
diff --git a/libc/malloc_debug/DebugData.cpp b/libc/malloc_debug/DebugData.cpp
index 0447566..fdc2810 100644
--- a/libc/malloc_debug/DebugData.cpp
+++ b/libc/malloc_debug/DebugData.cpp
@@ -43,37 +43,44 @@
   }
 
   // Check to see if the options that require a header are enabled.
-  if ((config_.options & ~(NO_HEADER_OPTIONS)) != 0) {
+  if (config_.options & HEADER_OPTIONS) {
     need_header_ = true;
 
     // Initialize all of the static header offsets.
     pointer_offset_ = BIONIC_ALIGN(sizeof(Header), MINIMUM_ALIGNMENT_BYTES);
 
     if (config_.options & BACKTRACE) {
-      backtrace.reset(new BacktraceData(config_, &pointer_offset_));
+      backtrace.reset(new BacktraceData(this, config_, &pointer_offset_));
       if (!backtrace->Initialize(config_)) {
         return false;
       }
     }
 
     if (config_.options & FRONT_GUARD) {
-      front_guard.reset(new FrontGuardData(config_, &pointer_offset_));
+      front_guard.reset(new FrontGuardData(this, config_, &pointer_offset_));
     }
 
     extra_bytes_ = pointer_offset_;
 
     // Initialize all of the non-header data.
     if (config_.options & REAR_GUARD) {
-      rear_guard.reset(new RearGuardData(config_));
+      rear_guard.reset(new RearGuardData(this, config_));
       extra_bytes_ += config_.rear_guard_bytes;
     }
 
     if (config_.options & FREE_TRACK) {
-      free_track.reset(new FreeTrackData(config_));
+      free_track.reset(new FreeTrackData(this, config_));
     }
 
     if (config_.options & TRACK_ALLOCS) {
-      track.reset(new TrackData());
+      track.reset(new TrackData(this));
+    }
+  }
+
+  if (config_.options & RECORD_ALLOCS) {
+    record.reset(new RecordData());
+    if (!record->Initialize(config_)) {
+      return false;
     }
   }
 
diff --git a/libc/malloc_debug/DebugData.h b/libc/malloc_debug/DebugData.h
index 4600b33..7e2df0c 100644
--- a/libc/malloc_debug/DebugData.h
+++ b/libc/malloc_debug/DebugData.h
@@ -41,6 +41,7 @@
 #include "FreeTrackData.h"
 #include "GuardData.h"
 #include "malloc_debug.h"
+#include "RecordData.h"
 #include "TrackData.h"
 
 class DebugData {
@@ -91,6 +92,7 @@
   std::unique_ptr<FrontGuardData> front_guard;
   std::unique_ptr<RearGuardData> rear_guard;
   std::unique_ptr<FreeTrackData> free_track;
+  std::unique_ptr<RecordData> record;
 
  private:
   size_t extra_bytes_ = 0;
@@ -103,4 +105,6 @@
   DISALLOW_COPY_AND_ASSIGN(DebugData);
 };
 
+extern DebugData* g_debug;
+
 #endif // MALLOC_DEBUG_DEBUGDATA_H
diff --git a/libc/malloc_debug/FreeTrackData.cpp b/libc/malloc_debug/FreeTrackData.cpp
index 470f40b..8e6502e 100644
--- a/libc/malloc_debug/FreeTrackData.cpp
+++ b/libc/malloc_debug/FreeTrackData.cpp
@@ -36,19 +36,16 @@
 #include "FreeTrackData.h"
 #include "malloc_debug.h"
 
-FreeTrackData::FreeTrackData(const Config& config)
-    : backtrace_num_frames_(config.free_track_backtrace_num_frames) {
+FreeTrackData::FreeTrackData(DebugData* debug, const Config& config)
+    : OptionData(debug), backtrace_num_frames_(config.free_track_backtrace_num_frames) {
   cmp_mem_.resize(4096);
   memset(cmp_mem_.data(), config.fill_free_value, cmp_mem_.size());
 }
 
-void FreeTrackData::LogFreeError(DebugData& debug, const Header* header,
-                                 const uint8_t* pointer) {
-  ScopedDisableDebugCalls disable;
-
+void FreeTrackData::LogFreeError(const Header* header, const uint8_t* pointer) {
   error_log(LOG_DIVIDER);
   error_log("+++ ALLOCATION %p USED AFTER FREE", pointer);
-  uint8_t fill_free_value = debug.config().fill_free_value;
+  uint8_t fill_free_value = debug_->config().fill_free_value;
   for (size_t i = 0; i < header->usable_size; i++) {
     if (pointer[i] != fill_free_value) {
       error_log("  allocation[%zu] = 0x%02x (expected 0x%02x)", i, pointer[i], fill_free_value);
@@ -63,10 +60,8 @@
   error_log(LOG_DIVIDER);
 }
 
-void FreeTrackData::VerifyAndFree(DebugData& debug, const Header* header,
-                                  const void* pointer) {
-  ScopedDisableDebugCalls disable;
-
+void FreeTrackData::VerifyAndFree(const Header* header) {
+  const void* pointer = debug_->GetPointer(header);
   if (header->tag != DEBUG_FREE_TAG) {
     error_log(LOG_DIVIDER);
     error_log("+++ ALLOCATION %p HAS CORRUPTED HEADER TAG 0x%x AFTER FREE", pointer, header->tag);
@@ -74,11 +69,12 @@
   } else {
     const uint8_t* memory = reinterpret_cast<const uint8_t*>(pointer);
     size_t bytes = header->usable_size;
-    bytes = (bytes < debug.config().fill_on_free_bytes) ? bytes : debug.config().fill_on_free_bytes;
+    bytes = (bytes < debug_->config().fill_on_free_bytes) ? bytes
+        : debug_->config().fill_on_free_bytes;
     while (bytes > 0) {
       size_t bytes_to_cmp = (bytes < cmp_mem_.size()) ? bytes : cmp_mem_.size();
       if (memcmp(memory, cmp_mem_.data(), bytes_to_cmp) != 0) {
-        LogFreeError(debug, header, reinterpret_cast<const uint8_t*>(pointer));
+        LogFreeError(header, reinterpret_cast<const uint8_t*>(pointer));
         break;
       }
       bytes -= bytes_to_cmp;
@@ -94,14 +90,11 @@
   g_dispatch->free(header->orig_pointer);
 }
 
-void FreeTrackData::Add(DebugData& debug, const Header* header) {
-  // Make sure the stl calls below don't call the debug_XXX functions.
-  ScopedDisableDebugCalls disable;
-
+void FreeTrackData::Add(const Header* header) {
   pthread_mutex_lock(&mutex_);
-  if (list_.size() == debug.config().free_track_allocations) {
+  if (list_.size() == debug_->config().free_track_allocations) {
     const Header* old_header = list_.back();
-    VerifyAndFree(debug, old_header, debug.GetPointer(old_header));
+    VerifyAndFree(old_header);
     list_.pop_back();
   }
 
@@ -118,19 +111,14 @@
   pthread_mutex_unlock(&mutex_);
 }
 
-void FreeTrackData::VerifyAll(DebugData& debug) {
-  // Make sure the stl calls below don't call the debug_XXX functions.
-  ScopedDisableDebugCalls disable;
-
+void FreeTrackData::VerifyAll() {
   for (const auto& header : list_) {
-    VerifyAndFree(debug, header, debug.GetPointer(header));
+    VerifyAndFree(header);
   }
   list_.clear();
 }
 
 void FreeTrackData::LogBacktrace(const Header* header) {
-  ScopedDisableDebugCalls disable;
-
   auto back_iter = backtraces_.find(header);
   if (back_iter == backtraces_.end()) {
     return;
diff --git a/libc/malloc_debug/FreeTrackData.h b/libc/malloc_debug/FreeTrackData.h
index 804b5a6..21f845f 100644
--- a/libc/malloc_debug/FreeTrackData.h
+++ b/libc/malloc_debug/FreeTrackData.h
@@ -38,26 +38,28 @@
 
 #include <private/bionic_macros.h>
 
-// Forward declarations.
-struct Header;
-class DebugData;
-struct Config;
-struct BacktraceHeader;
+#include "OptionData.h"
 
-class FreeTrackData {
+// Forward declarations.
+struct BacktraceHeader;
+struct Config;
+class DebugData;
+struct Header;
+
+class FreeTrackData : public OptionData {
  public:
-  FreeTrackData(const Config& config);
+  FreeTrackData(DebugData* debug_data, const Config& config);
   virtual ~FreeTrackData() = default;
 
-  void Add(DebugData& debug, const Header* header);
+  void Add(const Header* header);
 
-  void VerifyAll(DebugData& debug);
+  void VerifyAll();
 
   void LogBacktrace(const Header* header);
 
  private:
-  void LogFreeError(DebugData& debug, const Header* header, const uint8_t* pointer);
-  void VerifyAndFree(DebugData& debug, const Header* header, const void* pointer);
+  void LogFreeError(const Header* header, const uint8_t* pointer);
+  void VerifyAndFree(const Header* header);
 
   pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER;
   std::deque<const Header*> list_;
diff --git a/libc/malloc_debug/GuardData.cpp b/libc/malloc_debug/GuardData.cpp
index 97b16ff..e207b86 100644
--- a/libc/malloc_debug/GuardData.cpp
+++ b/libc/malloc_debug/GuardData.cpp
@@ -39,15 +39,14 @@
 #include "malloc_debug.h"
 #include "GuardData.h"
 
-GuardData::GuardData(int init_value, size_t num_bytes) {
+GuardData::GuardData(DebugData* debug_data, int init_value, size_t num_bytes)
+    : OptionData(debug_data) {
   // Create a buffer for fast comparisons of the front guard.
   cmp_mem_.resize(num_bytes);
   memset(cmp_mem_.data(), init_value, cmp_mem_.size());
 }
 
 void GuardData::LogFailure(const Header* header, const void* pointer, const void* data) {
-  ScopedDisableDebugCalls disable;
-
   error_log(LOG_DIVIDER);
   error_log("+++ ALLOCATION %p SIZE %zu HAS A CORRUPTED %s GUARD", pointer,
             header->real_size(), GetTypeName());
@@ -70,8 +69,8 @@
   error_log(LOG_DIVIDER);
 }
 
-FrontGuardData::FrontGuardData(const Config& config, size_t* offset)
-   : GuardData(config.front_guard_value, config.front_guard_bytes) {
+FrontGuardData::FrontGuardData(DebugData* debug_data, const Config& config, size_t* offset)
+   : GuardData(debug_data, config.front_guard_value, config.front_guard_bytes) {
   // Create a buffer for fast comparisons of the front guard.
   cmp_mem_.resize(config.front_guard_bytes);
   memset(cmp_mem_.data(), config.front_guard_value, cmp_mem_.size());
@@ -80,22 +79,22 @@
   *offset += config.front_guard_bytes;
 }
 
-bool FrontGuardData::Valid(DebugData& debug, const Header* header) {
-  return GuardData::Valid(debug.GetFrontGuard(header));
+bool FrontGuardData::Valid(const Header* header) {
+  return GuardData::Valid(debug_->GetFrontGuard(header));
 }
 
-void FrontGuardData::LogFailure(DebugData& debug, const Header* header) {
-  GuardData::LogFailure(header, debug.GetPointer(header), debug.GetFrontGuard(header));
+void FrontGuardData::LogFailure(const Header* header) {
+  GuardData::LogFailure(header, debug_->GetPointer(header), debug_->GetFrontGuard(header));
 }
 
-RearGuardData::RearGuardData(const Config& config)
-    : GuardData(config.rear_guard_value, config.rear_guard_bytes) {
+RearGuardData::RearGuardData(DebugData* debug_data, const Config& config)
+    : GuardData(debug_data, config.rear_guard_value, config.rear_guard_bytes) {
 }
 
-bool RearGuardData::Valid(DebugData& debug, const Header* header) {
-  return GuardData::Valid(debug.GetRearGuard(header));
+bool RearGuardData::Valid(const Header* header) {
+  return GuardData::Valid(debug_->GetRearGuard(header));
 }
 
-void RearGuardData::LogFailure(DebugData& debug, const Header* header) {
-  GuardData::LogFailure(header, debug.GetPointer(header), debug.GetRearGuard(header));
+void RearGuardData::LogFailure(const Header* header) {
+  GuardData::LogFailure(header, debug_->GetPointer(header), debug_->GetRearGuard(header));
 }
diff --git a/libc/malloc_debug/GuardData.h b/libc/malloc_debug/GuardData.h
index 4de2702..bfb3949 100644
--- a/libc/malloc_debug/GuardData.h
+++ b/libc/malloc_debug/GuardData.h
@@ -36,14 +36,16 @@
 
 #include <private/bionic_macros.h>
 
+#include "OptionData.h"
+
 // Forward declarations.
 class DebugData;
 struct Header;
 struct Config;
 
-class GuardData {
+class GuardData : public OptionData {
  public:
-  GuardData(int init_value, size_t num_bytes);
+  GuardData(DebugData* debug_data, int init_value, size_t num_bytes);
   virtual ~GuardData() = default;
 
   bool Valid(void* data) { return memcmp(data, cmp_mem_.data(), cmp_mem_.size()) == 0; }
@@ -60,12 +62,12 @@
 
 class FrontGuardData : public GuardData {
  public:
-  FrontGuardData(const Config& config, size_t* offset);
+  FrontGuardData(DebugData* debug_data, const Config& config, size_t* offset);
   virtual ~FrontGuardData() = default;
 
-  bool Valid(DebugData& debug, const Header* header);
+  bool Valid(const Header* header);
 
-  void LogFailure(DebugData& debug, const Header* header);
+  void LogFailure(const Header* header);
 
   size_t offset() { return offset_; }
 
@@ -79,12 +81,12 @@
 
 class RearGuardData : public GuardData {
  public:
-  RearGuardData(const Config& config);
+  RearGuardData(DebugData* debug_data, const Config& config);
   virtual ~RearGuardData() = default;
 
-  bool Valid(DebugData& debug, const Header* header);
+  bool Valid(const Header* header);
 
-  void LogFailure(DebugData& debug, const Header* header);
+  void LogFailure(const Header* header);
 
  private:
   const char* GetTypeName() override { return "REAR"; }
diff --git a/libstdc++/include/cstdint b/libc/malloc_debug/OptionData.h
similarity index 77%
copy from libstdc++/include/cstdint
copy to libc/malloc_debug/OptionData.h
index 3df56df..80190f5 100644
--- a/libstdc++/include/cstdint
+++ b/libc/malloc_debug/OptionData.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,14 +26,21 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+#ifndef DEBUG_MALLOC_OPTIONDATA_H
+#define DEBUG_MALLOC_OPTIONDATA_H
 
-/*
- * Standard C++ Library wrapper around the C stdint.h header file.
- */
+// Forward Declarations
+class DebugData;
 
-#include <stdint.h>
+class OptionData {
+ public:
+  OptionData(DebugData* debug) : debug_(debug) {}
+  ~OptionData() = default;
 
+ protected:
+  DebugData* debug_;
 
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+  DISALLOW_COPY_AND_ASSIGN(OptionData);
+};
+
+#endif // MALLOC_DEBUG_OPTIONDATA_H
diff --git a/libc/malloc_debug/README.md b/libc/malloc_debug/README.md
index 3fc2305..59bd525 100644
--- a/libc/malloc_debug/README.md
+++ b/libc/malloc_debug/README.md
@@ -4,26 +4,31 @@
 Malloc debug is a method of debugging native memory problems. It can help
 detect memory corruption, memory leaks, and use after free issues.
 
-Currently, malloc debug requires root to enable. When it is enabled, it works
-by adding a shim layer that replaces the normal allocation calls. The replaced
-calls are:
+This documentation describes how to enable this feature on Android N or later
+versions of the Android OS.
 
-<pre>
-malloc
-free
-calloc
-realloc
-posix_memalign
-memalign
-malloc_usable_size
-</pre>
+The documentation for malloc debug on older versions of Android is
+[here](README_marshmallow_and_earlier.md).
+
+In order to enable malloc debug, you must be able to set special system
+properties using the setprop command from the shell. This requires the
+ability to run as root on the device.
+
+When malloc debug is enabled, it works by adding a shim layer that replaces
+the normal allocation calls. The replaced calls are:
+
+* `malloc`
+* `free`
+* `calloc`
+* `realloc`
+* `posix_memalign`
+* `memalign`
+* `malloc_usable_size`
 
 On 32 bit systems, these two deprecated functions are also replaced:
 
-<pre>
-pvalloc
-valloc
-</pre>
+* `pvalloc`
+* `valloc`
 
 Any errors detected by the library are reported in the log.
 
@@ -57,11 +62,9 @@
 
 Example error:
 
-<pre>
-04-10 12:00:45.621  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 SIZE 100 HAS A CORRUPTED FRONT GUARD
-04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[-32] = 0x00 (expected 0xaa)
-04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[-15] = 0x02 (expected 0xaa)
-</pre>
+    04-10 12:00:45.621  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 SIZE 100 HAS A CORRUPTED FRONT GUARD
+    04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[-32] = 0x00 (expected 0xaa)
+    04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[-15] = 0x02 (expected 0xaa)
 
 ### rear\_guard[=SIZE\_BYTES]
 Enables a small buffer placed after the allocated data. This is an attempt
@@ -79,11 +82,9 @@
 
 Example error:
 
-<pre>
-04-10 12:00:45.621  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 SIZE 100 HAS A CORRUPTED REAR GUARD
-04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[130] = 0xbf (expected 0xbb)
-04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[131] = 0x00 (expected 0xbb)
-</pre>
+    04-10 12:00:45.621  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 SIZE 100 HAS A CORRUPTED REAR GUARD
+    04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[130] = 0xbf (expected 0xbb)
+    04-10 12:00:45.622  7412  7412 E malloc_debug:   allocation[131] = 0x00 (expected 0xbb)
 
 ### guard[=SIZE\_BYTES]
 Enables both a front guard and a rear guard on all allocations.
@@ -173,25 +174,21 @@
 
 Example error:
 
-<pre>
-04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 USED AFTER FREE
-04-15 12:00:31.305  7412  7412 E malloc_debug:   allocation[20] = 0xaf (expected 0xef)
-04-15 12:00:31.305  7412  7412 E malloc_debug:   allocation[99] = 0x12 (expected 0xef)
-04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace at time of free:
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
-</pre>
+    04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 USED AFTER FREE
+    04-15 12:00:31.305  7412  7412 E malloc_debug:   allocation[20] = 0xaf (expected 0xef)
+    04-15 12:00:31.305  7412  7412 E malloc_debug:   allocation[99] = 0x12 (expected 0xef)
+    04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace at time of free:
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
 
 In addition, there is another type of error message that can occur if
 an allocation has a special header applied, and the header is corrupted
 before the verification occurs. This is the error message that will be found
 in the log:
 
-<pre>
-+++ ALLOCATION 0x12345678 HAS CORRUPTED HEADER TAG 0x1cc7dc00 AFTER FREE
-</pre>
+    04-15 12:00:31.604  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 HAS CORRUPTED HEADER TAG 0x1cc7dc00 AFTER FREE
 
 ### free\_track\_backtrace\_num\_frames[=MAX\_FRAMES]
 This option only has meaning if free\_track is set. It indicates how many
@@ -214,62 +211,156 @@
 
 Example leak error found in the log:
 
-<pre>
-04-15 12:35:33.304  7412  7412 E malloc_debug: +++ APP leaked block of size 100 at 0x2be3b0b0 (leak 1 of 2)
-04-15 12:35:33.304  7412  7412 E malloc_debug: Backtrace at time of allocation:
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
-04-15 12:35:33.305  7412  7412 E malloc_debug: +++ APP leaked block of size 24 at 0x7be32380 (leak 2 of 2)
-04-15 12:35:33.305  7412  7412 E malloc_debug: Backtrace at time of allocation:
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
-04-15 12:35:33.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
-</pre>
+    04-15 12:35:33.304  7412  7412 E malloc_debug: +++ APP leaked block of size 100 at 0x2be3b0b0 (leak 1 of 2)
+    04-15 12:35:33.304  7412  7412 E malloc_debug: Backtrace at time of allocation:
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
+    04-15 12:35:33.305  7412  7412 E malloc_debug: +++ APP leaked block of size 24 at 0x7be32380 (leak 2 of 2)
+    04-15 12:35:33.305  7412  7412 E malloc_debug: Backtrace at time of allocation:
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
+    04-15 12:35:33.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
+
+### record\_allocs[=TOTAL\_ENTRIES]
+Keep track of every allocation/free made on every thread and dump them
+to a file when the signal SIGRTMAX - 18 (which is 46 on most Android devices)
+is received.
+
+If TOTAL\_ENTRIES is set, then it indicates the total number of
+allocation/free records that can be retained. If the number of records
+reaches the TOTAL\_ENTRIES value, then any further allocations/frees are
+not recorded. The default value is 8,000,000 and the maximum value this
+can be set to is 50,000,000.
+
+Once the signal is received, and the current records are written to the
+file, all current records are deleted. Any allocations/frees occuring while
+the data is being dumped to the file are ignored.
+
+**NOTE**: This option is not available until the O release of Android.
+
+The allocation data is written in a human readable format. Every line begins
+with the THREAD\_ID returned by gettid(), which is the thread that is making
+the allocation/free. If a new thread is created, no special line is added
+to the file. However, when a thread completes, a special entry is added to
+the file indicating this.
+
+The thread complete line is:
+
+**THREAD\_ID**: thread\_done 0x0
+
+Example:
+
+    187: thread_done 0x0
+
+Below is how each type of allocation/free call ends up in the file dump.
+
+pointer = malloc(size)
+
+**THREAD\_ID**: malloc pointer size
+
+Example:
+
+    186: malloc 0xb6038060 20
+
+free(pointer)
+
+**THREAD\_ID**: free pointer
+
+Example:
+
+    186: free 0xb6038060
+
+pointer = calloc(nmemb, size)
+
+**THREAD\_ID**: calloc pointer nmemb size
+
+Example:
+
+    186: calloc 0xb609f080 32 4
+
+new\_pointer = realloc(old\_pointer, size)
+
+**THREAD\_ID**: realloc new\_pointer old\_pointer size
+
+Example:
+
+    186: realloc 0xb609f080 0xb603e9a0 12
+
+pointer = memalign(alignment, size)
+
+**THREAD\_ID**: memalign pointer alignment size
+
+posix\_memalign(&pointer, alignment, size)
+
+**THREAD\_ID**: memalign pointer alignment size
+
+Example:
+
+    186: memalign 0x85423660 16 104
+
+pointer = valloc(size)
+
+**THREAD\_ID**: memalign pointer 4096 size
+
+Example:
+
+    186: memalign 0x85423660 4096 112
+
+pointer = pvalloc(size)
+
+**THREAD\_ID**: memalign pointer 4096 <b>SIZE\_ROUNDED\_UP\_TO\_4096</b>
+
+Example:
+
+    186: memalign 0x85423660 4096 8192
+
+### record\_allocs\_file[=FILE\_NAME]
+This option only has meaning if record\_allocs is set. It indicates the
+file where the recorded allocations will be found.
+
+If FILE\_NAME is set, then it indicates where the record allocation data
+will be placed.
+
+**NOTE**: This option is not available until the O release of Android.
 
 Additional Errors
 -----------------
 There are a few other error messages that might appear in the log.
 
 ### Use After Free
-<pre>
-04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 USED AFTER FREE (free)
-04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace of original free:
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
-04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace at time of failure:
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
-</pre>
+    04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 USED AFTER FREE (free)
+    04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace of original free:
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace at time of failure:
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
 
 This indicates that code is attempting to free an already freed pointer. The
 name in parenthesis indicates that the application called the function
-<i>free</i> with the bad pointer.
+*free* with the bad pointer.
 
 For example, this message:
 
-<pre>
-04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 USED AFTER FREE (realloc)
-</pre>
+    04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 USED AFTER FREE (realloc)
 
-Would indicate that the application called the <i>realloc</i> function
+Would indicate that the application called the *realloc* function
 with an already freed pointer.
 
 ### Invalid Tag
-<pre>
-04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 HAS INVALID TAG 1ee7d000 (malloc_usable_size)
-04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace at time of failure:
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
-04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
-</pre>
+    04-15 12:00:31.304  7412  7412 E malloc_debug: +++ ALLOCATION 0x12345678 HAS INVALID TAG 1ee7d000 (malloc_usable_size)
+    04-15 12:00:31.305  7412  7412 E malloc_debug: Backtrace at time of failure:
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #00  pc 00029310  /system/lib/libc.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #01  pc 00021438  /system/lib/libc.so (newlocale+160)
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #02  pc 000a9e38  /system/lib/libc++.so
+    04-15 12:00:31.305  7412  7412 E malloc_debug:           #03  pc 000a28a8  /system/lib/libc++.so
 
 This indicates that a function (malloc\_usable\_size) was called with
 a pointer that is either not allocated memory, or that the memory of
@@ -282,36 +373,28 @@
 ========
 Enable backtrace tracking of all allocation for all processes:
 
-<pre>
-  adb shell stop
-  adb shell setprop libc.debug.malloc.options backtrace
-  adb shell start
-</pre>
+    adb shell stop
+    adb shell setprop libc.debug.malloc.options backtrace
+    adb shell start
 
 Enable backtrace tracking for a specific process (ls):
 
-<pre>
-  adb shell setprop libc.debug.malloc.options backtrace
-  adb shell setprop libc.debug.malloc.program ls
-  adb shell ls
-</pre>
+    adb shell setprop libc.debug.malloc.options backtrace
+    adb shell setprop libc.debug.malloc.program ls
+    adb shell ls
 
 Enable backtrace tracking for the zygote and zygote based processes:
 
-<pre>
-  adb shell stop
-  adb shell setprop libc.debug.malloc.program app_process
-  adb shell setprop libc.debug.malloc.options backtrace
-  adb shell start
-</pre>
+    adb shell stop
+    adb shell setprop libc.debug.malloc.program app_process
+    adb shell setprop libc.debug.malloc.options backtrace
+    adb shell start
 
 Enable multiple options (backtrace and guards):
 
-<pre>
-  adb shell stop
-  adb shell setprop libc.debug.malloc.options "\"backtrace guards\""
-  adb shell start
-</pre>
+    adb shell stop
+    adb shell setprop libc.debug.malloc.options "\"backtrace guards\""
+    adb shell start
 
 Enable malloc debug when multiple processes have the same name. This method
 can be used to enable malloc debug for only a very specific process if
@@ -321,10 +404,20 @@
 the setprop command will fail since the backtrace guards options will look
 like two arguments instead of one.
 
-<pre>
-  adb shell
-  # setprop libc.debug.malloc.env_enabled
-  # setprop libc.debug.malloc.options backtrace
-  # export LIBC_DEBUG_MALLOC_ENABLE 1
-  # ls
-</pre>
+    adb shell
+    # setprop libc.debug.malloc.env_enabled
+    # setprop libc.debug.malloc.options backtrace
+    # export LIBC_DEBUG_MALLOC_ENABLE 1
+    # ls
+
+Enable malloc debug and dump the native allocation with backtraces to
+a file. This only works for zygote based java processes.
+
+    adb shell stop
+    adb shell setprop libc.debug.malloc.options backtrace
+    adb shell start
+    adb shell am dumpheap -n <PID_TO_DUMP> /data/local/tmp/heap.txt
+
+It is possible to use the backtrace\_enable\_on\_signal option as well,
+but it must be enabled through the signal before the file will contain
+any data.
diff --git a/libc/malloc_debug/README_api.md b/libc/malloc_debug/README_api.md
index cd04c32..9d07cb3 100644
--- a/libc/malloc_debug/README_api.md
+++ b/libc/malloc_debug/README_api.md
@@ -7,58 +7,48 @@
 
 The function to gather the data:
 
-<pre>
-<b>
-extern "C" void get_malloc_leak_info(uint8_t** info, size_t* overall_size, size_t* info_size, size_t* total_memory, size_t* backtrace_size);
-</b>
-</pre>
+`extern "C" void get_malloc_leak_info(uint8_t** info, size_t* overall_size, size_t* info_size, size_t* total_memory, size_t* backtrace_size);`
 
-<i>info</i> is set to a buffer allocated by the call that contains all of
+*info* is set to a buffer allocated by the call that contains all of
 the allocation information.
-<i>overall\_size</i> is set to the total size of the buffer returned. If this
-<i>info\_size</i>
+*overall\_size* is set to the total size of the buffer returned. If this
+*info\_size*
 value is zero, then there are no allocation being tracked.
-<i>total\_memory</i> is set to the sum of all allocation sizes that are live at
+*total\_memory* is set to the sum of all allocation sizes that are live at
 the point of the function call. This does not include the memory allocated
 by the malloc debug library itself.
-<i>backtrace\_size</i> is set to the maximum number of backtrace entries
+*backtrace\_size* is set to the maximum number of backtrace entries
 that are present for each allocation.
 
 In order to free the buffer allocated by the function, call:
 
-<pre>
-<b>
-extern "C" void free_malloc_leak_info(uint8_t* info);
-</b>
-</pre>
+`extern "C" void free_malloc_leak_info(uint8_t* info);`
 
 ### Format of info Buffer
-<pre>
-size_t size_of_original_allocation
-size_t num_backtrace_frames
-uintptr_t pc1
-uintptr_t pc2
-uintptr_t pc3
-.
-.
-.
-</pre>
+    size_t size_of_original_allocation
+    size_t num_backtrace_frames
+    uintptr_t pc1
+    uintptr_t pc2
+    uintptr_t pc3
+    .
+    .
+    .
 
-The number of <i>uintptr\_t</i> values is determined by the value
-<i>backtrace\_size</i> as returned by the original call to
-<i>get\_malloc\_leak\_info</i>. This value is not variable, it is the same
+The number of *uintptr\_t* values is determined by the value
+*backtrace\_size* as returned by the original call to
+*get\_malloc\_leak\_info*. This value is not variable, it is the same
 for all the returned data. The value
-<i>num\_backtrace\_frames</i> contains the real number of frames found. The
-extra frames are set to zero. Each <i>uintptr\_t</i> is a pc of the callstack.
+*num\_backtrace\_frames* contains the real number of frames found. The
+extra frames are set to zero. Each *uintptr\_t* is a pc of the callstack.
 The calls from within the malloc debug library are automatically removed.
 
-For 32 bit systems, <i>size\_t</i> and <i>uintptr\_t</i> are both 4 byte values.
+For 32 bit systems, *size\_t* and *uintptr\_t* are both 4 byte values.
 
-For 64 bit systems, <i>size\_t</i> and <i>uintptr\_t</i> are both 8 byte values.
+For 64 bit systems, *size\_t* and *uintptr\_t* are both 8 byte values.
 
-The total number of these structures returned in <i>info</i> is
-<i>overall\_size</i> divided by <i>info\_size</i>.
+The total number of these structures returned in *info* is
+*overall\_size* divided by *info\_size*.
 
 Note, the size value in each allocation data structure will have bit 31 set
-if this allocation was created by the Zygote process. This helps to distinguish
-between native allocations created by the application.
+if this allocation was created in a process forked from the Zygote process.
+This helps to distinguish between native allocations created by the application.
diff --git a/libc/malloc_debug/README_marshmallow_and_earlier.md b/libc/malloc_debug/README_marshmallow_and_earlier.md
new file mode 100644
index 0000000..3513711
--- /dev/null
+++ b/libc/malloc_debug/README_marshmallow_and_earlier.md
@@ -0,0 +1,128 @@
+Malloc Debug
+============
+
+Malloc debug is a method of debugging native memory problems. It can help
+detect memory corruption, memory leaks, and use after free issues.
+
+This documentation describes how to enable this feature on versions of
+the Android OS, Marshmallow or older. Note: malloc debug was full of bugs
+and was not fully functional until KitKat, so using it on a version older
+than that is not guaranteed to work at all.
+
+The documentation for malloc debug on newer versions of Android is
+[here](README.md).
+
+On these old versions of the OS, you must be able to set system properties
+using the setprop command from the shell. This requires the ability to
+run as root on the device.
+
+When malloc debug is enabled, it works by adding a shim layer that replaces
+the normal allocation calls. The replaced calls are:
+
+* `malloc`
+* `free`
+* `calloc`
+* `realloc`
+* `posix_memalign`
+* `memalign`
+* `malloc_usable_size`
+
+On 32 bit systems, these two deprecated functions are also replaced:
+
+* `pvalloc`
+* `valloc`
+
+Any errors detected by the library are reported in the log.
+
+Controlling Malloc Debug Behavior
+---------------------------------
+Malloc debug is controlled by a system property that takes a numeric value
+named libc.debug.malloc. It has only a few distinct modes that enables a
+set of different malloc debug checks at once.
+
+Value 1
+--------
+When enabled, this value creates a special header to all allocations
+that contains information about the allocation.
+
+### Backtrace at Allocation Creation
+Enable capturing the backtrace of each allocation site. Only the
+first 16 frames of the backtrace will be captured.
+This option will slow down allocations by an order of magnitude, and
+might cause timeouts when trying to start a device.
+
+### Track Live Allocations
+All of the currently live allocations will be tracked and can be retrieved
+by a call to get\_malloc\_leak\_info (see README\_api.md for details).
+
+Note: If multiple allocations have the same exact backtrace, then only one
+entry is returned in the list.
+
+Value 5
+-------
+When enabled, this value does not create a special header. It only modifies
+the content of allocations.
+
+Whenever an allocation is created, initialize the data with a known
+pattern (0xeb). This does not happen for the calloc calls.
+Whenever an allocation is freed, write a known pattern over the data (0xef).
+
+Value 10
+--------
+When enabled, this value creates a special header to all allocations
+that contains information about the allocation.
+
+This value enables everything enabled with value 1 plus these other options.
+
+### Allocation Guards
+A 32 byte buffer is placed before the returned allocation (known as
+a front guard). This buffer is filled with the pattern (0xaa). In addition,
+a 32 byte buffer is placed after the data for the returned allocation (known
+as a rear guard). This buffer is filled with the pattern (0xbb).
+
+When the allocation is freed, both of these guards are verified to contain
+the expected patterns. If not, then an error message is printed to the log.
+
+### Free Memory Tracking
+When a pointer is freed, do not free the memory right away, but add it to
+a list of freed allocations. In addition to being added to the list, the
+entire allocation is filled with the value 0xef, and the backtrace at
+the time of the free is recorded. As with the backtrace on allocation,
+only up to 16 frames will be recorded.
+
+When the list of freed allocations reaches 100, the oldest allocation
+on the list is removed and verified that it still contains the pattern 0xef.
+If the entire allocation is not filled with this value, an error is printed
+to the log.
+
+### Log Leaks
+When the program completes, all of the allocations that are still live
+are printed to the log as leaks. This isn't very useful since it tends
+to display a lot of false positive because many programs do not free
+everything before terminating.
+
+Option 20
+---------
+Do not use this option value, it only works on the emulator. It has not
+been verified, so it may or may not work.
+
+Enable on Certain Processes
+---------------------------
+Using the special system property, libc.debug.malloc.program, will
+cause malloc debug to only be used on processes with that name. For example,
+if the property is set to ls, then only the program named ls will have malloc
+debug enabled.
+
+Examples
+========
+Enable malloc debug for all allocations for all processes:
+
+    adb shell stop
+    adb shell setprop libc.debug.malloc 1
+    adb shell start
+
+Enable malloc debug for a particular process:
+
+    adb shell setprop libc.debug.malloc.program ls
+    adb shell setprop libc.debug.malloc 10
+    adb shell ls /data/local/tmp
diff --git a/libc/malloc_debug/RecordData.cpp b/libc/malloc_debug/RecordData.cpp
new file mode 100644
index 0000000..c0f3486
--- /dev/null
+++ b/libc/malloc_debug/RecordData.cpp
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdatomic.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include <mutex>
+
+#include <android-base/stringprintf.h>
+
+#include "Config.h"
+#include "debug_disable.h"
+#include "debug_log.h"
+#include "DebugData.h"
+#include "RecordData.h"
+
+RecordEntry::RecordEntry() : tid_(gettid()) {
+}
+
+std::string ThreadCompleteEntry::GetString() const {
+  return android::base::StringPrintf("%d: thread_done 0x0\n", tid_);
+}
+
+AllocEntry::AllocEntry(void* pointer) : pointer_(pointer) {
+}
+
+MallocEntry::MallocEntry(void* pointer, size_t size) : AllocEntry(pointer), size_(size) {
+}
+
+std::string MallocEntry::GetString() const {
+  return android::base::StringPrintf("%d: malloc %p %zu\n", tid_, pointer_, size_);
+}
+
+FreeEntry::FreeEntry(void* pointer) : AllocEntry(pointer) {
+}
+
+std::string FreeEntry::GetString() const {
+  return android::base::StringPrintf("%d: free %p\n", tid_, pointer_);
+}
+
+CallocEntry::CallocEntry(void* pointer, size_t nmemb, size_t size)
+    : MallocEntry(pointer, size), nmemb_(nmemb) {
+}
+
+std::string CallocEntry::GetString() const {
+  return android::base::StringPrintf("%d: calloc %p %zu %zu\n", tid_, pointer_, nmemb_, size_);
+}
+
+ReallocEntry::ReallocEntry(void* pointer, size_t size, void* old_pointer)
+    : MallocEntry(pointer, size), old_pointer_(old_pointer) {
+}
+
+std::string ReallocEntry::GetString() const {
+  return android::base::StringPrintf("%d: realloc %p %p %zu\n", tid_, pointer_,
+                                     old_pointer_, size_);
+}
+
+// posix_memalign, memalgin, pvalloc, valloc all recorded with this class.
+MemalignEntry::MemalignEntry(void* pointer, size_t size, size_t alignment)
+    : MallocEntry(pointer, size), alignment_(alignment) {
+}
+
+std::string MemalignEntry::GetString() const {
+  return android::base::StringPrintf("%d: memalign %p %zu %zu\n", tid_, pointer_,
+                                     alignment_, size_);
+}
+
+struct ThreadData {
+  ThreadData(RecordData* record_data, ThreadCompleteEntry* entry) : record_data(record_data), entry(entry) {}
+  RecordData* record_data;
+  ThreadCompleteEntry* entry;
+  size_t count = 0;
+};
+
+static void ThreadKeyDelete(void* data) {
+  ThreadData* thread_data = reinterpret_cast<ThreadData*>(data);
+
+  thread_data->count++;
+
+  // This should be the last time we are called.
+  if (thread_data->count == 4) {
+    ScopedDisableDebugCalls disable;
+
+    thread_data->record_data->AddEntryOnly(thread_data->entry);
+    delete thread_data;
+  } else {
+    pthread_setspecific(thread_data->record_data->key(), data);
+  }
+}
+
+static void RecordDump(int, siginfo_t*, void*) {
+  // It's not necessarily safe to do the dump here, instead wait for the
+  // next allocation call to do the dump.
+  g_debug->record->SetToDump();
+}
+
+void RecordData::Dump() {
+  std::lock_guard<std::mutex> lock(dump_lock_);
+
+  // Make it so that no more entries can be added while dumping.
+  unsigned int last_entry_index = cur_index_.exchange(static_cast<unsigned int>(num_entries_));
+  if (dump_ == false) {
+    // Multiple Dump() calls from different threads, and we lost. Do nothing.
+    return;
+  }
+
+  // cur_index_ keeps getting incremented even if we hit the num_entries_.
+  // If that happens, cap the entries to dump by num_entries_.
+  if (last_entry_index > num_entries_) {
+    last_entry_index = num_entries_;
+  }
+
+  int dump_fd = open(dump_file_.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW,
+                     0755);
+  if (dump_fd != -1) {
+    for (size_t i = 0; i < last_entry_index; i++) {
+      std::string line = entries_[i]->GetString();
+      ssize_t bytes = write(dump_fd, line.c_str(), line.length());
+      if (bytes == -1 || static_cast<size_t>(bytes) != line.length()) {
+        error_log("Failed to write record alloc information: %s", strerror(errno));
+        // Free all of the rest of the errors, we don't have any way
+        // to dump a partial list of the entries.
+        for (i++; i < last_entry_index; i++) {
+          delete entries_[i];
+          entries_[i] = nullptr;
+        }
+        break;
+      }
+      delete entries_[i];
+      entries_[i] = nullptr;
+    }
+    close(dump_fd);
+
+    // Mark the entries dumped.
+    cur_index_ = 0U;
+  } else {
+    error_log("Cannot create record alloc file %s: %s", dump_file_.c_str(), strerror(errno));
+    // Since we couldn't create the file, reset the entries dumped back
+    // to the original value.
+    cur_index_ = last_entry_index;
+  }
+
+  dump_ = false;
+}
+
+RecordData::RecordData() {
+  pthread_key_create(&key_, ThreadKeyDelete);
+}
+
+bool RecordData::Initialize(const Config& config) {
+  struct sigaction dump_act;
+  memset(&dump_act, 0, sizeof(dump_act));
+
+  dump_act.sa_sigaction = RecordDump;
+  dump_act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
+  sigemptyset(&dump_act.sa_mask);
+  if (sigaction(config.record_allocs_signal, &dump_act, nullptr) != 0) {
+    error_log("Unable to set up record dump signal function: %s", strerror(errno));
+    return false;
+  }
+  pthread_setspecific(key_, nullptr);
+
+  info_log("%s: Run: 'kill -%d %d' to dump the allocation records.", getprogname(),
+           config.record_allocs_signal, getpid());
+
+  num_entries_ = config.record_allocs_num_entries;
+  entries_ = new const RecordEntry*[num_entries_];
+  cur_index_ = 0;
+  dump_ = false;
+  dump_file_ = config.record_allocs_file;
+
+  return true;
+}
+
+RecordData::~RecordData() {
+  delete [] entries_;
+  pthread_key_delete(key_);
+}
+
+void RecordData::AddEntryOnly(const RecordEntry* entry) {
+  unsigned int entry_index = cur_index_.fetch_add(1);
+  if (entry_index < num_entries_) {
+    entries_[entry_index] = entry;
+  }
+}
+
+void RecordData::AddEntry(const RecordEntry* entry) {
+  void* data = pthread_getspecific(key_);
+  if (data == nullptr) {
+    ThreadData* thread_data = new ThreadData(this, new ThreadCompleteEntry());
+    pthread_setspecific(key_, thread_data);
+  }
+
+  AddEntryOnly(entry);
+
+  // Check to see if it's time to dump the entries.
+  if (dump_) {
+    Dump();
+  }
+}
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
new file mode 100644
index 0000000..741afd5
--- /dev/null
+++ b/libc/malloc_debug/RecordData.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef DEBUG_MALLOC_RECORDDATA_H
+#define DEBUG_MALLOC_RECORDDATA_H
+
+#include <stdint.h>
+#include <pthread.h>
+#include <unistd.h>
+
+#include <atomic>
+#include <mutex>
+#include <string>
+
+#include <private/bionic_macros.h>
+
+class RecordEntry {
+ public:
+  RecordEntry();
+  virtual ~RecordEntry() = default;
+
+  virtual std::string GetString() const = 0;
+
+ protected:
+  pid_t tid_;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(RecordEntry);
+};
+
+class ThreadCompleteEntry : public RecordEntry {
+ public:
+  ThreadCompleteEntry() = default;
+  virtual ~ThreadCompleteEntry() = default;
+
+  std::string GetString() const override;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(ThreadCompleteEntry);
+};
+
+class AllocEntry : public RecordEntry {
+ public:
+  AllocEntry(void* pointer);
+  virtual ~AllocEntry() = default;
+
+ protected:
+  void* pointer_;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(AllocEntry);
+};
+
+class MallocEntry : public AllocEntry {
+ public:
+  MallocEntry(void* pointer, size_t size);
+  virtual ~MallocEntry() = default;
+
+  std::string GetString() const override;
+
+ protected:
+  size_t size_;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(MallocEntry);
+};
+
+class FreeEntry : public AllocEntry {
+ public:
+  FreeEntry(void* pointer);
+  virtual ~FreeEntry() = default;
+
+  std::string GetString() const override;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(FreeEntry);
+};
+
+class CallocEntry : public MallocEntry {
+ public:
+  CallocEntry(void* pointer, size_t size, size_t nmemb);
+  virtual ~CallocEntry() = default;
+
+  std::string GetString() const override;
+
+ protected:
+  size_t nmemb_;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(CallocEntry);
+};
+
+class ReallocEntry : public MallocEntry {
+ public:
+  ReallocEntry(void* pointer, size_t size, void* old_pointer);
+  virtual ~ReallocEntry() = default;
+
+  std::string GetString() const override;
+
+ protected:
+  void* old_pointer_;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(ReallocEntry);
+};
+
+// posix_memalign, memalign, pvalloc, valloc all recorded with this class.
+class MemalignEntry : public MallocEntry {
+ public:
+  MemalignEntry(void* pointer, size_t size, size_t alignment);
+  virtual ~MemalignEntry() = default;
+
+  std::string GetString() const override;
+
+ protected:
+  size_t alignment_;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(MemalignEntry);
+};
+
+struct Config;
+
+class RecordData {
+ public:
+  RecordData();
+  virtual ~RecordData();
+
+  bool Initialize(const Config& config);
+
+  void AddEntry(const RecordEntry* entry);
+  void AddEntryOnly(const RecordEntry* entry);
+
+  void SetToDump() { dump_ = true; }
+
+  pthread_key_t key() { return key_; }
+
+ private:
+  void Dump();
+
+  std::mutex dump_lock_;
+  pthread_key_t key_;
+  const RecordEntry** entries_ = nullptr;
+  size_t num_entries_ = 0;
+  std::atomic_uint cur_index_;
+  std::atomic_bool dump_;
+  std::string dump_file_;
+
+  DISALLOW_COPY_AND_ASSIGN(RecordData);
+};
+
+#endif // DEBUG_MALLOC_RECORDDATA_H
diff --git a/libc/malloc_debug/TrackData.cpp b/libc/malloc_debug/TrackData.cpp
index c9828d0..18f428b 100644
--- a/libc/malloc_debug/TrackData.cpp
+++ b/libc/malloc_debug/TrackData.cpp
@@ -44,9 +44,10 @@
 #include "malloc_debug.h"
 #include "TrackData.h"
 
-void TrackData::GetList(std::vector<const Header*>* list) {
-  ScopedDisableDebugCalls disable;
+TrackData::TrackData(DebugData* debug_data) : OptionData(debug_data) {
+}
 
+void TrackData::GetList(std::vector<const Header*>* list) {
   for (const auto& header : headers_) {
     list->push_back(header);
   }
@@ -59,8 +60,6 @@
 }
 
 void TrackData::Add(const Header* header, bool backtrace_found) {
-  ScopedDisableDebugCalls disable;
-
   pthread_mutex_lock(&mutex_);
   if (backtrace_found) {
     total_backtrace_allocs_++;
@@ -70,8 +69,6 @@
 }
 
 void TrackData::Remove(const Header* header, bool backtrace_found) {
-  ScopedDisableDebugCalls disable;
-
   pthread_mutex_lock(&mutex_);
   headers_.erase(header);
   if (backtrace_found) {
@@ -81,26 +78,22 @@
 }
 
 bool TrackData::Contains(const Header* header) {
-  ScopedDisableDebugCalls disable;
-
   pthread_mutex_lock(&mutex_);
   bool found = headers_.count(header);
   pthread_mutex_unlock(&mutex_);
   return found;
 }
 
-void TrackData::DisplayLeaks(DebugData& debug) {
-  ScopedDisableDebugCalls disable;
-
+void TrackData::DisplayLeaks() {
   std::vector<const Header*> list;
   GetList(&list);
 
   size_t track_count = 0;
   for (const auto& header : list) {
     error_log("+++ %s leaked block of size %zu at %p (leak %zu of %zu)", getprogname(),
-              header->real_size(), debug.GetPointer(header), ++track_count, list.size());
-    if (debug.config().options & BACKTRACE) {
-      BacktraceHeader* back_header = debug.GetAllocBacktrace(header);
+              header->real_size(), debug_->GetPointer(header), ++track_count, list.size());
+    if (debug_->config().options & BACKTRACE) {
+      BacktraceHeader* back_header = debug_->GetAllocBacktrace(header);
       if (back_header->num_frames > 0) {
         error_log("Backtrace at time of allocation:");
         backtrace_log(&back_header->frames[0], back_header->num_frames);
@@ -110,15 +103,15 @@
   }
 }
 
-void TrackData::GetInfo(DebugData& debug, uint8_t** info, size_t* overall_size,
-                        size_t* info_size, size_t* total_memory, size_t* backtrace_size) {
+void TrackData::GetInfo(uint8_t** info, size_t* overall_size, size_t* info_size,
+                        size_t* total_memory, size_t* backtrace_size) {
   ScopedPthreadMutexLocker scoped(&mutex_);
 
   if (headers_.size() == 0 || total_backtrace_allocs_ == 0) {
     return;
   }
 
-  *backtrace_size = debug.config().backtrace_frames;
+  *backtrace_size = debug_->config().backtrace_frames;
   *info_size = sizeof(size_t) * 2 + sizeof(uintptr_t) * *backtrace_size;
   *info = reinterpret_cast<uint8_t*>(g_dispatch->calloc(*info_size, total_backtrace_allocs_));
   if (*info == nullptr) {
@@ -131,7 +124,7 @@
 
   uint8_t* data = *info;
   for (const auto& header : list) {
-    BacktraceHeader* back_header = debug.GetAllocBacktrace(header);
+    BacktraceHeader* back_header = debug_->GetAllocBacktrace(header);
     if (back_header->num_frames > 0) {
       memcpy(data, &header->size, sizeof(size_t));
       memcpy(&data[sizeof(size_t)], &back_header->num_frames, sizeof(size_t));
diff --git a/libc/malloc_debug/TrackData.h b/libc/malloc_debug/TrackData.h
index 1234316..fcd8f2a 100644
--- a/libc/malloc_debug/TrackData.h
+++ b/libc/malloc_debug/TrackData.h
@@ -37,14 +37,16 @@
 
 #include <private/bionic_macros.h>
 
+#include "OptionData.h"
+
 // Forward declarations.
 struct Header;
 struct Config;
 class DebugData;
 
-class TrackData {
+class TrackData : public OptionData {
  public:
-  TrackData() = default;
+  TrackData(DebugData* debug_data);
   virtual ~TrackData() = default;
 
   void GetList(std::vector<const Header*>* list);
@@ -55,10 +57,10 @@
 
   bool Contains(const Header *header);
 
-  void GetInfo(DebugData& debug, uint8_t** info, size_t* overall_size,
-               size_t* info_size, size_t* total_memory, size_t* backtrace_size);
+  void GetInfo(uint8_t** info, size_t* overall_size, size_t* info_size,
+               size_t* total_memory, size_t* backtrace_size);
 
-  void DisplayLeaks(DebugData& debug);
+  void DisplayLeaks();
 
   void PrepareFork() { pthread_mutex_lock(&mutex_); }
   void PostForkParent() { pthread_mutex_unlock(&mutex_); }
diff --git a/libc/malloc_debug/debug_disable.cpp b/libc/malloc_debug/debug_disable.cpp
index af0264b..b80ba8c 100644
--- a/libc/malloc_debug/debug_disable.cpp
+++ b/libc/malloc_debug/debug_disable.cpp
@@ -32,7 +32,6 @@
 #include "debug_disable.h"
 #include "debug_log.h"
 
-extern DebugData* g_debug;
 pthread_key_t g_disable_key;
 
 bool DebugCallsDisabled() {
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 1ee7689..d2bcf99 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -114,8 +114,6 @@
 }
 
 static void LogTagError(const Header* header, const void* pointer, const char* name) {
-  ScopedDisableDebugCalls disable;
-
   error_log(LOG_DIVIDER);
   if (header->tag == DEBUG_FREE_TAG) {
     error_log("+++ ALLOCATION %p USED AFTER FREE (%s)", pointer, name);
@@ -165,7 +163,6 @@
   if (g_debug->config().options & BACKTRACE) {
     BacktraceHeader* back_header = g_debug->GetAllocBacktrace(header);
     if (g_debug->backtrace->enabled()) {
-      ScopedDisableDebugCalls disable;
       back_header->num_frames = backtrace_get(
           &back_header->frames[0], g_debug->config().backtrace_frames);
       backtrace_found = back_header->num_frames > 0;
@@ -217,11 +214,11 @@
   }
 
   if (g_debug->config().options & FREE_TRACK) {
-    g_debug->free_track->VerifyAll(*g_debug);
+    g_debug->free_track->VerifyAll();
   }
 
   if (g_debug->config().options & LEAK_TRACK) {
-    g_debug->track->DisplayLeaks(*g_debug);
+    g_debug->track->DisplayLeaks();
   }
 
   DebugDisableSet(true);
@@ -257,32 +254,37 @@
     return;
   }
 
-  g_debug->track->GetInfo(*g_debug, info, overall_size, info_size, total_memory, backtrace_size);
+  g_debug->track->GetInfo(info, overall_size, info_size, total_memory, backtrace_size);
 }
 
 void debug_free_malloc_leak_info(uint8_t* info) {
   g_dispatch->free(info);
 }
 
-size_t debug_malloc_usable_size(void* pointer) {
-  if (DebugCallsDisabled() || !g_debug->need_header() || pointer == nullptr) {
+static size_t internal_malloc_usable_size(void* pointer) {
+  if (g_debug->need_header()) {
+    Header* header = g_debug->GetHeader(pointer);
+    if (header->tag != DEBUG_TAG) {
+      LogTagError(header, pointer, "malloc_usable_size");
+      return 0;
+    }
+
+    return header->usable_size;
+  } else {
     return g_dispatch->malloc_usable_size(pointer);
   }
-
-  Header* header = g_debug->GetHeader(pointer);
-  if (header->tag != DEBUG_TAG) {
-    LogTagError(header, pointer, "malloc_usable_size");
-    return 0;
-  }
-
-  return header->usable_size;
 }
 
-void* debug_malloc(size_t size) {
-  if (DebugCallsDisabled()) {
-    return g_dispatch->malloc(size);
+size_t debug_malloc_usable_size(void* pointer) {
+  if (DebugCallsDisabled() || pointer == nullptr) {
+    return g_dispatch->malloc_usable_size(pointer);
   }
+  ScopedDisableDebugCalls disable;
 
+  return internal_malloc_usable_size(pointer);
+}
+
+static void *internal_malloc(size_t size) {
   if (size == 0) {
     size = 1;
   }
@@ -312,7 +314,7 @@
   }
 
   if (pointer != nullptr && g_debug->config().options & FILL_ON_ALLOC) {
-    size_t bytes = debug_malloc_usable_size(pointer);
+    size_t bytes = internal_malloc_usable_size(pointer);
     size_t fill_bytes = g_debug->config().fill_on_alloc_bytes;
     bytes = (bytes < fill_bytes) ? bytes : fill_bytes;
     memset(pointer, g_debug->config().fill_alloc_value, bytes);
@@ -320,11 +322,22 @@
   return pointer;
 }
 
-void debug_free(void* pointer) {
-  if (DebugCallsDisabled() || pointer == nullptr) {
-    return g_dispatch->free(pointer);
+void* debug_malloc(size_t size) {
+  if (DebugCallsDisabled()) {
+    return g_dispatch->malloc(size);
+  }
+  ScopedDisableDebugCalls disable;
+
+  void* pointer = internal_malloc(size);
+
+  if (g_debug->config().options & RECORD_ALLOCS) {
+    g_debug->record->AddEntry(new MallocEntry(pointer, size));
   }
 
+  return pointer;
+}
+
+static void internal_free(void* pointer) {
   void* free_pointer = pointer;
   size_t bytes;
   Header* header;
@@ -337,13 +350,13 @@
     free_pointer = header->orig_pointer;
 
     if (g_debug->config().options & FRONT_GUARD) {
-      if (!g_debug->front_guard->Valid(*g_debug, header)) {
-        g_debug->front_guard->LogFailure(*g_debug, header);
+      if (!g_debug->front_guard->Valid(header)) {
+        g_debug->front_guard->LogFailure(header);
       }
     }
     if (g_debug->config().options & REAR_GUARD) {
-      if (!g_debug->rear_guard->Valid(*g_debug, header)) {
-        g_debug->rear_guard->LogFailure(*g_debug, header);
+      if (!g_debug->rear_guard->Valid(header)) {
+        g_debug->rear_guard->LogFailure(header);
       }
     }
 
@@ -374,16 +387,30 @@
     // frees at the same time and we wind up trying to really free this
     // pointer from another thread, while still trying to free it in
     // this function.
-    g_debug->free_track->Add(*g_debug, header);
+    g_debug->free_track->Add(header);
   } else {
     g_dispatch->free(free_pointer);
   }
 }
 
+void debug_free(void* pointer) {
+  if (DebugCallsDisabled() || pointer == nullptr) {
+    return g_dispatch->free(pointer);
+  }
+  ScopedDisableDebugCalls disable;
+
+  if (g_debug->config().options & RECORD_ALLOCS) {
+    g_debug->record->AddEntry(new FreeEntry(pointer));
+  }
+
+  internal_free(pointer);
+}
+
 void* debug_memalign(size_t alignment, size_t bytes) {
   if (DebugCallsDisabled()) {
     return g_dispatch->memalign(alignment, bytes);
   }
+  ScopedDisableDebugCalls disable;
 
   if (bytes == 0) {
     bytes = 1;
@@ -438,11 +465,16 @@
   }
 
   if (pointer != nullptr && g_debug->config().options & FILL_ON_ALLOC) {
-    size_t bytes = debug_malloc_usable_size(pointer);
+    size_t bytes = internal_malloc_usable_size(pointer);
     size_t fill_bytes = g_debug->config().fill_on_alloc_bytes;
     bytes = (bytes < fill_bytes) ? bytes : fill_bytes;
     memset(pointer, g_debug->config().fill_alloc_value, bytes);
   }
+
+  if (g_debug->config().options & RECORD_ALLOCS) {
+    g_debug->record->AddEntry(new MemalignEntry(pointer, bytes, alignment));
+  }
+
   return pointer;
 }
 
@@ -450,13 +482,22 @@
   if (DebugCallsDisabled()) {
     return g_dispatch->realloc(pointer, bytes);
   }
+  ScopedDisableDebugCalls disable;
 
   if (pointer == nullptr) {
-    return debug_malloc(bytes);
+    pointer = internal_malloc(bytes);
+    if (g_debug->config().options & RECORD_ALLOCS) {
+      g_debug->record->AddEntry(new ReallocEntry(pointer, bytes, nullptr));
+    }
+    return pointer;
   }
 
   if (bytes == 0) {
-    debug_free(pointer);
+    if (g_debug->config().options & RECORD_ALLOCS) {
+      g_debug->record->AddEntry(new ReallocEntry(nullptr, bytes, pointer));
+    }
+
+    internal_free(pointer);
     return nullptr;
   }
 
@@ -486,6 +527,7 @@
 
     // Same size, do nothing.
     if (real_size == header->real_size()) {
+      // Do not bother recording, this is essentially a nop.
       return pointer;
     }
 
@@ -502,11 +544,12 @@
         memset(g_debug->GetRearGuard(header), g_debug->config().rear_guard_value,
                g_debug->config().rear_guard_bytes);
       }
+      // Do not bother recording, this is essentially a nop.
       return pointer;
     }
 
     // Allocate the new size.
-    new_pointer = debug_malloc(bytes);
+    new_pointer = internal_malloc(bytes);
     if (new_pointer == nullptr) {
       errno = ENOMEM;
       return nullptr;
@@ -514,7 +557,7 @@
 
     prev_size = header->usable_size;
     memcpy(new_pointer, pointer, prev_size);
-    debug_free(pointer);
+    internal_free(pointer);
   } else {
     prev_size = g_dispatch->malloc_usable_size(pointer);
     new_pointer = g_dispatch->realloc(pointer, real_size);
@@ -524,7 +567,7 @@
   }
 
   if (g_debug->config().options & FILL_ON_ALLOC) {
-    size_t bytes = debug_malloc_usable_size(new_pointer);
+    size_t bytes = internal_malloc_usable_size(new_pointer);
     if (bytes > g_debug->config().fill_on_alloc_bytes) {
       bytes = g_debug->config().fill_on_alloc_bytes;
     }
@@ -534,6 +577,10 @@
     }
   }
 
+  if (g_debug->config().options & RECORD_ALLOCS) {
+    g_debug->record->AddEntry(new ReallocEntry(new_pointer, bytes, pointer));
+  }
+
   return new_pointer;
 }
 
@@ -541,6 +588,7 @@
   if (DebugCallsDisabled()) {
     return g_dispatch->calloc(nmemb, bytes);
   }
+  ScopedDisableDebugCalls disable;
 
   size_t size;
   if (__builtin_mul_overflow(nmemb, bytes, &size)) {
@@ -560,6 +608,7 @@
     return nullptr;
   }
 
+  void* pointer;
   if (g_debug->need_header()) {
     // The above check will guarantee the multiply will not overflow.
     if (size > Header::max_size()) {
@@ -574,10 +623,14 @@
       return nullptr;
     }
     memset(header, 0, g_dispatch->malloc_usable_size(header));
-    return InitHeader(header, header, size);
+    pointer = InitHeader(header, header, size);
   } else {
-    return g_dispatch->calloc(1, real_size);
+    pointer = g_dispatch->calloc(1, real_size);
   }
+  if (g_debug->config().options & RECORD_ALLOCS) {
+    g_debug->record->AddEntry(new CallocEntry(pointer, bytes, nmemb));
+  }
+  return pointer;
 }
 
 struct mallinfo debug_mallinfo() {
@@ -645,6 +698,7 @@
   if (DebugCallsDisabled() || pointer == nullptr) {
     return 0;
   }
+  ScopedDisableDebugCalls disable;
 
   if (g_debug->need_header()) {
     Header* header;
diff --git a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
index 85d5cb5..49edaba 100644
--- a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
@@ -113,6 +113,19 @@
   "6 malloc_debug \n"
   "6 malloc_debug   leak_track\n"
   "6 malloc_debug     Enable the leak tracking of memory allocations.\n"
+  "6 malloc_debug \n"
+  "6 malloc_debug   record_allocs[=XX]\n"
+  "6 malloc_debug     Record every single allocation/free call. When a specific signal\n"
+  "6 malloc_debug     is sent to the process, the contents of recording are written to\n"
+  "6 malloc_debug     a file (/data/local/tmp/record_allocs.txt) and the recording is cleared.\n"
+  "6 malloc_debug     If XX is set, that is the total number of allocations/frees that can\n"
+  "6 malloc_debug     recorded. of frames to capture. The default value is 8000000.\n"
+  "6 malloc_debug     If the allocation list fills up, all further allocations are not recorded.\n"
+  "6 malloc_debug \n"
+  "6 malloc_debug   record_allocs_file[=FILE]\n"
+  "6 malloc_debug     This option only has meaning if the record_allocs options has been specified.\n"
+  "6 malloc_debug     This is the name of the file to which recording information will be dumped.\n"
+  "6 malloc_debug     The default is /data/local/tmp/record_allocs.txt.\n"
 );
 
 TEST_F(MallocDebugConfigTest, unknown_option) {
@@ -190,7 +203,7 @@
 }
 
 TEST_F(MallocDebugConfigTest, space_before_equal) {
-  ASSERT_TRUE(InitConfig("backtrace  =10"));
+  ASSERT_TRUE(InitConfig("backtrace  =10")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options);
   ASSERT_EQ(10U, config->backtrace_frames);
 
@@ -199,7 +212,7 @@
 }
 
 TEST_F(MallocDebugConfigTest, space_after_equal) {
-  ASSERT_TRUE(InitConfig("backtrace=  10"));
+  ASSERT_TRUE(InitConfig("backtrace=  10")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options);
   ASSERT_EQ(10U, config->backtrace_frames);
 
@@ -208,7 +221,7 @@
 }
 
 TEST_F(MallocDebugConfigTest, extra_space) {
-  ASSERT_TRUE(InitConfig("   backtrace=64   "));
+  ASSERT_TRUE(InitConfig("   backtrace=64   ")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options);
   ASSERT_EQ(64U, config->backtrace_frames);
 
@@ -217,7 +230,7 @@
 }
 
 TEST_F(MallocDebugConfigTest, multiple_options) {
-  ASSERT_TRUE(InitConfig("  backtrace=64   front_guard=48"));
+  ASSERT_TRUE(InitConfig("  backtrace=64   front_guard=48")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS | FRONT_GUARD, config->options);
   ASSERT_EQ(64U, config->backtrace_frames);
   ASSERT_EQ(48U, config->front_guard_bytes);
@@ -227,15 +240,15 @@
 }
 
 TEST_F(MallocDebugConfigTest, front_guard) {
-  ASSERT_TRUE(InitConfig("front_guard=48"));
+  ASSERT_TRUE(InitConfig("front_guard=48")) << getFakeLogPrint();
   ASSERT_EQ(FRONT_GUARD, config->options);
   ASSERT_EQ(48U, config->front_guard_bytes);
 
-  ASSERT_TRUE(InitConfig("front_guard"));
+  ASSERT_TRUE(InitConfig("front_guard")) << getFakeLogPrint();
   ASSERT_EQ(FRONT_GUARD, config->options);
   ASSERT_EQ(32U, config->front_guard_bytes);
 
-  ASSERT_TRUE(InitConfig("front_guard=39"));
+  ASSERT_TRUE(InitConfig("front_guard=39")) << getFakeLogPrint();
   ASSERT_EQ(FRONT_GUARD, config->options);
 #if defined(__LP64__)
   ASSERT_EQ(48U, config->front_guard_bytes);
@@ -243,7 +256,7 @@
   ASSERT_EQ(40U, config->front_guard_bytes);
 #endif
 
-  ASSERT_TRUE(InitConfig("front_guard=41"));
+  ASSERT_TRUE(InitConfig("front_guard=41")) << getFakeLogPrint();
   ASSERT_EQ(FRONT_GUARD, config->options);
   ASSERT_EQ(48U, config->front_guard_bytes);
 
@@ -252,11 +265,11 @@
 }
 
 TEST_F(MallocDebugConfigTest, rear_guard) {
-  ASSERT_TRUE(InitConfig("rear_guard=50"));
+  ASSERT_TRUE(InitConfig("rear_guard=50")) << getFakeLogPrint();
   ASSERT_EQ(REAR_GUARD, config->options);
   ASSERT_EQ(50U, config->rear_guard_bytes);
 
-  ASSERT_TRUE(InitConfig("rear_guard"));
+  ASSERT_TRUE(InitConfig("rear_guard")) << getFakeLogPrint();
   ASSERT_EQ(REAR_GUARD, config->options);
   ASSERT_EQ(32U, config->rear_guard_bytes);
 
@@ -265,12 +278,12 @@
 }
 
 TEST_F(MallocDebugConfigTest, guard) {
-  ASSERT_TRUE(InitConfig("guard=32"));
+  ASSERT_TRUE(InitConfig("guard=32")) << getFakeLogPrint();
   ASSERT_EQ(FRONT_GUARD | REAR_GUARD, config->options);
   ASSERT_EQ(32U, config->front_guard_bytes);
   ASSERT_EQ(32U, config->rear_guard_bytes);
 
-  ASSERT_TRUE(InitConfig("guard"));
+  ASSERT_TRUE(InitConfig("guard")) << getFakeLogPrint();
   ASSERT_EQ(FRONT_GUARD | REAR_GUARD, config->options);
   ASSERT_EQ(32U, config->front_guard_bytes);
   ASSERT_EQ(32U, config->rear_guard_bytes);
@@ -280,11 +293,11 @@
 }
 
 TEST_F(MallocDebugConfigTest, backtrace) {
-  ASSERT_TRUE(InitConfig("backtrace=64"));
+  ASSERT_TRUE(InitConfig("backtrace=64")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options);
   ASSERT_EQ(64U, config->backtrace_frames);
 
-  ASSERT_TRUE(InitConfig("backtrace"));
+  ASSERT_TRUE(InitConfig("backtrace")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options);
   ASSERT_EQ(16U, config->backtrace_frames);
 
@@ -293,11 +306,11 @@
 }
 
 TEST_F(MallocDebugConfigTest, backtrace_enable_on_signal) {
-  ASSERT_TRUE(InitConfig("backtrace_enable_on_signal=64"));
+  ASSERT_TRUE(InitConfig("backtrace_enable_on_signal=64")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options);
   ASSERT_EQ(64U, config->backtrace_frames);
 
-  ASSERT_TRUE(InitConfig("backtrace_enable_on_signal"));
+  ASSERT_TRUE(InitConfig("backtrace_enable_on_signal")) << getFakeLogPrint();
   ASSERT_EQ(BACKTRACE | TRACK_ALLOCS, config->options);
   ASSERT_EQ(16U, config->backtrace_frames);
 
@@ -306,11 +319,11 @@
 }
 
 TEST_F(MallocDebugConfigTest, fill_on_alloc) {
-  ASSERT_TRUE(InitConfig("fill_on_alloc=64"));
+  ASSERT_TRUE(InitConfig("fill_on_alloc=64")) << getFakeLogPrint();
   ASSERT_EQ(FILL_ON_ALLOC, config->options);
   ASSERT_EQ(64U, config->fill_on_alloc_bytes);
 
-  ASSERT_TRUE(InitConfig("fill_on_alloc"));
+  ASSERT_TRUE(InitConfig("fill_on_alloc")) << getFakeLogPrint();
   ASSERT_EQ(FILL_ON_ALLOC, config->options);
   ASSERT_EQ(SIZE_MAX, config->fill_on_alloc_bytes);
 
@@ -319,11 +332,11 @@
 }
 
 TEST_F(MallocDebugConfigTest, fill_on_free) {
-  ASSERT_TRUE(InitConfig("fill_on_free=64"));
+  ASSERT_TRUE(InitConfig("fill_on_free=64")) << getFakeLogPrint();
   ASSERT_EQ(FILL_ON_FREE, config->options);
   ASSERT_EQ(64U, config->fill_on_free_bytes);
 
-  ASSERT_TRUE(InitConfig("fill_on_free"));
+  ASSERT_TRUE(InitConfig("fill_on_free")) << getFakeLogPrint();
   ASSERT_EQ(FILL_ON_FREE, config->options);
   ASSERT_EQ(SIZE_MAX, config->fill_on_free_bytes);
 
@@ -332,12 +345,12 @@
 }
 
 TEST_F(MallocDebugConfigTest, fill) {
-  ASSERT_TRUE(InitConfig("fill=64"));
+  ASSERT_TRUE(InitConfig("fill=64")) << getFakeLogPrint();
   ASSERT_EQ(FILL_ON_ALLOC | FILL_ON_FREE, config->options);
   ASSERT_EQ(64U, config->fill_on_alloc_bytes);
   ASSERT_EQ(64U, config->fill_on_free_bytes);
 
-  ASSERT_TRUE(InitConfig("fill"));
+  ASSERT_TRUE(InitConfig("fill")) << getFakeLogPrint();
   ASSERT_EQ(FILL_ON_ALLOC | FILL_ON_FREE, config->options);
   ASSERT_EQ(SIZE_MAX, config->fill_on_alloc_bytes);
   ASSERT_EQ(SIZE_MAX, config->fill_on_free_bytes);
@@ -347,11 +360,11 @@
 }
 
 TEST_F(MallocDebugConfigTest, expand_alloc) {
-  ASSERT_TRUE(InitConfig("expand_alloc=1234"));
+  ASSERT_TRUE(InitConfig("expand_alloc=1234")) << getFakeLogPrint();
   ASSERT_EQ(EXPAND_ALLOC, config->options);
   ASSERT_EQ(1234U, config->expand_alloc_bytes);
 
-  ASSERT_TRUE(InitConfig("expand_alloc"));
+  ASSERT_TRUE(InitConfig("expand_alloc")) << getFakeLogPrint();
   ASSERT_EQ(EXPAND_ALLOC, config->options);
   ASSERT_EQ(16U, config->expand_alloc_bytes);
 
@@ -360,13 +373,13 @@
 }
 
 TEST_F(MallocDebugConfigTest, free_track) {
-  ASSERT_TRUE(InitConfig("free_track=1234"));
+  ASSERT_TRUE(InitConfig("free_track=1234")) << getFakeLogPrint();
   ASSERT_EQ(FREE_TRACK | FILL_ON_FREE, config->options);
   ASSERT_EQ(1234U, config->free_track_allocations);
   ASSERT_EQ(SIZE_MAX, config->fill_on_free_bytes);
   ASSERT_EQ(16U, config->free_track_backtrace_num_frames);
 
-  ASSERT_TRUE(InitConfig("free_track"));
+  ASSERT_TRUE(InitConfig("free_track")) << getFakeLogPrint();
   ASSERT_EQ(FREE_TRACK | FILL_ON_FREE, config->options);
   ASSERT_EQ(100U, config->free_track_allocations);
   ASSERT_EQ(SIZE_MAX, config->fill_on_free_bytes);
@@ -377,13 +390,13 @@
 }
 
 TEST_F(MallocDebugConfigTest, free_track_and_fill_on_free) {
-  ASSERT_TRUE(InitConfig("free_track=1234 fill_on_free=32"));
+  ASSERT_TRUE(InitConfig("free_track=1234 fill_on_free=32")) << getFakeLogPrint();
   ASSERT_EQ(FREE_TRACK | FILL_ON_FREE, config->options);
   ASSERT_EQ(1234U, config->free_track_allocations);
   ASSERT_EQ(32U, config->fill_on_free_bytes);
   ASSERT_EQ(16U, config->free_track_backtrace_num_frames);
 
-  ASSERT_TRUE(InitConfig("free_track fill_on_free=60"));
+  ASSERT_TRUE(InitConfig("free_track fill_on_free=60")) << getFakeLogPrint();
   ASSERT_EQ(FREE_TRACK | FILL_ON_FREE, config->options);
   ASSERT_EQ(100U, config->free_track_allocations);
   ASSERT_EQ(60U, config->fill_on_free_bytes);
@@ -394,12 +407,12 @@
 }
 
 TEST_F(MallocDebugConfigTest, free_track_backtrace_num_frames) {
-  ASSERT_TRUE(InitConfig("free_track_backtrace_num_frames=123"));
+  ASSERT_TRUE(InitConfig("free_track_backtrace_num_frames=123")) << getFakeLogPrint();
 
   ASSERT_EQ(0U, config->options);
   ASSERT_EQ(123U, config->free_track_backtrace_num_frames);
 
-  ASSERT_TRUE(InitConfig("free_track_backtrace_num_frames"));
+  ASSERT_TRUE(InitConfig("free_track_backtrace_num_frames")) << getFakeLogPrint();
   ASSERT_EQ(0U, config->options);
   ASSERT_EQ(16U, config->free_track_backtrace_num_frames);
 
@@ -408,7 +421,7 @@
 }
 
 TEST_F(MallocDebugConfigTest, free_track_backtrace_num_frames_zero) {
-  ASSERT_TRUE(InitConfig("free_track_backtrace_num_frames=0"));
+  ASSERT_TRUE(InitConfig("free_track_backtrace_num_frames=0")) << getFakeLogPrint();
 
   ASSERT_EQ(0U, config->options);
   ASSERT_EQ(0U, config->free_track_backtrace_num_frames);
@@ -418,11 +431,11 @@
 }
 
 TEST_F(MallocDebugConfigTest, free_track_backtrace_num_frames_and_free_track) {
-  ASSERT_TRUE(InitConfig("free_track free_track_backtrace_num_frames=123"));
+  ASSERT_TRUE(InitConfig("free_track free_track_backtrace_num_frames=123")) << getFakeLogPrint();
   ASSERT_EQ(FREE_TRACK | FILL_ON_FREE, config->options);
   ASSERT_EQ(123U, config->free_track_backtrace_num_frames);
 
-  ASSERT_TRUE(InitConfig("free_track free_track_backtrace_num_frames"));
+  ASSERT_TRUE(InitConfig("free_track free_track_backtrace_num_frames")) << getFakeLogPrint();
   ASSERT_EQ(FREE_TRACK | FILL_ON_FREE, config->options);
   ASSERT_EQ(16U, config->free_track_backtrace_num_frames);
 
@@ -431,7 +444,7 @@
 }
 
 TEST_F(MallocDebugConfigTest, leak_track) {
-  ASSERT_TRUE(InitConfig("leak_track"));
+  ASSERT_TRUE(InitConfig("leak_track")) << getFakeLogPrint();
   ASSERT_EQ(LEAK_TRACK | TRACK_ALLOCS, config->options);
 
   ASSERT_STREQ("", getFakeLogBuf().c_str());
@@ -439,7 +452,7 @@
 }
 
 TEST_F(MallocDebugConfigTest, leak_track_fail) {
-  ASSERT_FALSE(InitConfig("leak_track=100"));
+  ASSERT_FALSE(InitConfig("leak_track=100")) << getFakeLogPrint();
 
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   std::string log_msg(
@@ -448,6 +461,32 @@
   ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
 }
 
+TEST_F(MallocDebugConfigTest, record_allocs) {
+  ASSERT_TRUE(InitConfig("record_allocs=1234")) << getFakeLogPrint();
+  ASSERT_EQ(RECORD_ALLOCS, config->options);
+  ASSERT_EQ(1234U, config->record_allocs_num_entries);
+  ASSERT_STREQ("/data/local/tmp/record_allocs.txt", config->record_allocs_file.c_str());
+
+  ASSERT_TRUE(InitConfig("record_allocs")) << getFakeLogPrint();
+  ASSERT_EQ(RECORD_ALLOCS, config->options);
+  ASSERT_EQ(8000000U, config->record_allocs_num_entries);
+  ASSERT_STREQ("/data/local/tmp/record_allocs.txt", config->record_allocs_file.c_str());
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  ASSERT_STREQ("", getFakeLogPrint().c_str());
+}
+
+TEST_F(MallocDebugConfigTest, record_allocs_file) {
+  ASSERT_TRUE(InitConfig("record_allocs=1234 record_allocs_file=/fake/file")) << getFakeLogPrint();
+  ASSERT_STREQ("/fake/file", config->record_allocs_file.c_str());
+
+  ASSERT_TRUE(InitConfig("record_allocs_file")) << getFakeLogPrint();
+  ASSERT_STREQ("/data/local/tmp/record_allocs.txt", config->record_allocs_file.c_str());
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  ASSERT_STREQ("", getFakeLogPrint().c_str());
+}
+
 TEST_F(MallocDebugConfigTest, guard_min_error) {
   ASSERT_FALSE(InitConfig("guard=0"));
 
@@ -626,3 +665,23 @@
       "value must be <= 256: 400\n");
   ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
 }
+
+TEST_F(MallocDebugConfigTest, record_alloc_min_error) {
+  ASSERT_FALSE(InitConfig("record_allocs=0"));
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  std::string log_msg(
+      "6 malloc_debug malloc_testing: bad value for option 'record_allocs', "
+      "value must be >= 1: 0\n");
+  ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
+}
+
+TEST_F(MallocDebugConfigTest, record_allocs_max_error) {
+  ASSERT_FALSE(InitConfig("record_allocs=100000000"));
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  std::string log_msg(
+      "6 malloc_debug malloc_testing: bad value for option 'record_allocs', "
+      "value must be <= 50000000: 100000000\n");
+  ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
+}
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index 014b913..edb03f6 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -30,6 +30,7 @@
 
 #include <gtest/gtest.h>
 
+#include <android-base/file.h>
 #include <android-base/stringprintf.h>
 
 #include <private/bionic_macros.h>
@@ -79,12 +80,16 @@
   return offset;
 }
 
+static constexpr const char RECORD_ALLOCS_FILE[] = "/data/local/tmp/record_allocs.txt";
+
 class MallocDebugTest : public ::testing::Test {
  protected:
   void SetUp() override {
     initialized = false;
     resetLogs();
     backtrace_fake_clear_all();
+    // Delete the record data file if it exists.
+    unlink(RECORD_ALLOCS_FILE);
   }
 
   void TearDown() override {
@@ -1266,7 +1271,7 @@
   debug_free_malloc_leak_info(info);
 
   // Send the signal to enable.
-  ASSERT_TRUE(kill(getpid(), SIGRTMIN + 10) == 0);
+  ASSERT_TRUE(kill(getpid(), SIGRTMAX - 19) == 0);
   sleep(1);
 
   pointer = debug_malloc(100);
@@ -1291,7 +1296,7 @@
   debug_free_malloc_leak_info(info);
 
   // Send the signal to disable.
-  ASSERT_TRUE(kill(getpid(), SIGRTMIN + 10) == 0);
+  ASSERT_TRUE(kill(getpid(), SIGRTMAX - 19) == 0);
   sleep(1);
 
   pointer = debug_malloc(200);
@@ -1311,7 +1316,7 @@
   ASSERT_STREQ("", getFakeLogBuf().c_str());
   std::string expected_log = android::base::StringPrintf(
       "4 malloc_debug malloc_testing: Run: 'kill -%d %d' to enable backtracing.\n",
-      SIGRTMIN + 10, getpid());
+      SIGRTMAX - 19, getpid());
   ASSERT_STREQ(expected_log.c_str(), getFakeLogPrint().c_str());
 }
 
@@ -1512,3 +1517,231 @@
   debug_free(pointer);
 }
 #endif
+
+void VerifyRecordAllocs() {
+  std::string expected;
+
+  void* pointer = debug_malloc(10);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 10\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  pointer = debug_calloc(1, 20);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: calloc %p 20 1\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  pointer = debug_realloc(nullptr, 30);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: realloc %p 0x0 30\n", getpid(), pointer);
+  void* old_pointer = pointer;
+  pointer = debug_realloc(pointer, 2048);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: realloc %p %p 2048\n", getpid(),
+                                          pointer, old_pointer);
+  debug_realloc(pointer, 0);
+  expected += android::base::StringPrintf("%d: realloc 0x0 %p 0\n", getpid(), pointer);
+
+  pointer = debug_memalign(16, 40);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: memalign %p 16 40\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  ASSERT_EQ(0, debug_posix_memalign(&pointer, 32, 50));
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: memalign %p 32 50\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+  pointer = debug_pvalloc(60);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: memalign %p 4096 4096\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  pointer = debug_valloc(70);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: memalign %p 4096 70\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+#endif
+
+  // Dump all of the data accumulated so far.
+  ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
+  sleep(1);
+
+  // This triggers the dumping.
+  pointer = debug_malloc(110);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 110\n", getpid(), pointer);
+
+  // Read all of the contents.
+  std::string actual;
+  ASSERT_TRUE(android::base::ReadFileToString(RECORD_ALLOCS_FILE, &actual));
+
+  ASSERT_STREQ(expected.c_str(), actual.c_str());
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  std::string expected_log = android::base::StringPrintf(
+      "4 malloc_debug malloc_testing: Run: 'kill -%d %d' to dump the allocation records.\n",
+      SIGRTMAX - 18, getpid());
+  ASSERT_STREQ(expected_log.c_str(), getFakeLogPrint().c_str());
+
+  debug_free(pointer);
+}
+
+TEST_F(MallocDebugTest, record_allocs_no_header) {
+  Init("record_allocs");
+
+  VerifyRecordAllocs();
+}
+
+TEST_F(MallocDebugTest, record_allocs_with_header) {
+  Init("record_allocs front_guard");
+
+  VerifyRecordAllocs();
+}
+
+TEST_F(MallocDebugTest, record_allocs_max) {
+  Init("record_allocs=5");
+
+  std::string expected;
+
+  void* pointer = debug_malloc(10);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 10\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  pointer = debug_malloc(20);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 20\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  pointer = debug_malloc(1024);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 1024\n", getpid(), pointer);
+  debug_free(pointer);
+
+  // Dump all of the data accumulated so far.
+  ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
+  sleep(1);
+
+  // This triggers the dumping.
+  pointer = debug_malloc(110);
+  ASSERT_TRUE(pointer != nullptr);
+
+  // Read all of the contents.
+  std::string actual;
+  ASSERT_TRUE(android::base::ReadFileToString(RECORD_ALLOCS_FILE, &actual));
+
+  ASSERT_STREQ(expected.c_str(), actual.c_str());
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  std::string expected_log = android::base::StringPrintf(
+      "4 malloc_debug malloc_testing: Run: 'kill -%d %d' to dump the allocation records.\n",
+      SIGRTMAX - 18, getpid());
+  ASSERT_STREQ(expected_log.c_str(), getFakeLogPrint().c_str());
+
+  debug_free(pointer);
+}
+
+TEST_F(MallocDebugTest, record_allocs_thread_done) {
+  Init("record_allocs=5");
+
+  static pid_t tid = 0;
+  static void* pointer = nullptr;
+  std::thread thread([](){
+    tid = gettid();
+    pointer = debug_malloc(100);
+    write(0, pointer, 0);
+    debug_free(pointer);
+  });
+  thread.join();
+
+  std::string expected = android::base::StringPrintf("%d: malloc %p 100\n", tid, pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", tid, pointer);
+  expected += android::base::StringPrintf("%d: thread_done 0x0\n", tid);
+
+  // Dump all of the data accumulated so far.
+  ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
+  sleep(1);
+
+  // This triggers the dumping.
+  pointer = debug_malloc(23);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 23\n", getpid(), pointer);
+
+  // Read all of the contents.
+  std::string actual;
+  ASSERT_TRUE(android::base::ReadFileToString(RECORD_ALLOCS_FILE, &actual));
+
+  ASSERT_STREQ(expected.c_str(), actual.c_str());
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  std::string expected_log = android::base::StringPrintf(
+      "4 malloc_debug malloc_testing: Run: 'kill -%d %d' to dump the allocation records.\n",
+      SIGRTMAX - 18, getpid());
+  ASSERT_STREQ(expected_log.c_str(), getFakeLogPrint().c_str());
+
+  debug_free(pointer);
+}
+
+TEST_F(MallocDebugTest, record_allocs_file_name_fail) {
+  Init("record_allocs=5");
+
+  // Delete the special.txt file and create a symbolic link there to
+  // make sure the create file will fail.
+  unlink(RECORD_ALLOCS_FILE);
+
+  ASSERT_EQ(0, symlink("/data/local/tmp/does_not_exist", RECORD_ALLOCS_FILE));
+
+  std::string expected;
+
+  void* pointer = debug_malloc(10);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 10\n", getpid(), pointer);
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  // Dump all of the data accumulated so far.
+  ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
+  sleep(1);
+
+  // This triggers the dumping.
+  pointer = debug_malloc(110);
+  ASSERT_TRUE(pointer != nullptr);
+  expected += android::base::StringPrintf("%d: malloc %p 110\n", getpid(), pointer);
+
+  // Read all of the contents.
+  std::string actual;
+  ASSERT_FALSE(android::base::ReadFileToString(RECORD_ALLOCS_FILE, &actual));
+
+  // Unlink the file so the next dump passes.
+  ASSERT_EQ(0, unlink(RECORD_ALLOCS_FILE));
+
+  // Dump all of the data accumulated so far.
+  ASSERT_TRUE(kill(getpid(), SIGRTMAX - 18) == 0);
+  sleep(1);
+
+  // This triggers the dumping.
+  debug_free(pointer);
+  expected += android::base::StringPrintf("%d: free %p\n", getpid(), pointer);
+
+  ASSERT_TRUE(android::base::ReadFileToString(RECORD_ALLOCS_FILE, &actual));
+  ASSERT_STREQ(expected.c_str(), actual.c_str());
+
+  ASSERT_STREQ("", getFakeLogBuf().c_str());
+  std::string expected_log = android::base::StringPrintf(
+      "4 malloc_debug malloc_testing: Run: 'kill -%d %d' to dump the allocation records.\n",
+      SIGRTMAX - 18, getpid());
+  expected_log += android::base::StringPrintf(
+      "6 malloc_debug Cannot create record alloc file %s: Too many symbolic links encountered\n",
+      RECORD_ALLOCS_FILE);
+  ASSERT_STREQ(expected_log.c_str(), getFakeLogPrint().c_str());
+}
diff --git a/libc/private/UniquePtr.h b/libc/private/UniquePtr.h
deleted file mode 100644
index 5ac7599..0000000
--- a/libc/private/UniquePtr.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIQUE_PTR_H_included
-#define UNIQUE_PTR_H_included
-
-// Default deleter for pointer types.
-template <typename T>
-struct DefaultDelete {
-    enum { type_must_be_complete = sizeof(T) };
-    DefaultDelete() {}
-    void operator()(T* p) const {
-        delete p;
-    }
-};
-
-// Default deleter for array types.
-template <typename T>
-struct DefaultDelete<T[]> {
-    enum { type_must_be_complete = sizeof(T) };
-    void operator()(T* p) const {
-        delete[] p;
-    }
-};
-
-// A smart pointer that deletes the given pointer on destruction.
-// Equivalent to C++0x's std::unique_ptr (a combination of boost::scoped_ptr
-// and boost::scoped_array).
-// Named to be in keeping with Android style but also to avoid
-// collision with any other implementation, until we can switch over
-// to unique_ptr.
-// Use thus:
-//   UniquePtr<C> c(new C);
-template <typename T, typename D = DefaultDelete<T> >
-class UniquePtr {
-public:
-    // Construct a new UniquePtr, taking ownership of the given raw pointer.
-    explicit UniquePtr(T* ptr = nullptr) : mPtr(ptr) { }
-
-    UniquePtr(UniquePtr<T, D>&& that) {
-      mPtr = that.mPtr;
-      that.mPtr = nullptr;
-    }
-
-    ~UniquePtr() {
-        reset();
-    }
-
-    // Accessors.
-    T& operator*() const { return *mPtr; }
-    T* operator->() const { return mPtr; }
-    T* get() const { return mPtr; }
-
-    // Returns the raw pointer and hands over ownership to the caller.
-    // The pointer will not be deleted by UniquePtr.
-    T* release() __attribute__((warn_unused_result)) {
-        T* result = mPtr;
-        mPtr = nullptr;
-        return result;
-    }
-
-    // Takes ownership of the given raw pointer.
-    // If this smart pointer previously owned a different raw pointer, that
-    // raw pointer will be freed.
-    void reset(T* ptr = nullptr) {
-        if (ptr != mPtr) {
-            D()(mPtr);
-            mPtr = ptr;
-        }
-    }
-
-private:
-    // The raw pointer.
-    T* mPtr;
-
-    // Comparing unique pointers is probably a mistake, since they're unique.
-    template <typename T2> bool operator==(const UniquePtr<T2>& p) const = delete;
-    template <typename T2> bool operator!=(const UniquePtr<T2>& p) const = delete;
-
-    // Disallow copy and assignment.
-    UniquePtr(const UniquePtr&) = delete;
-    void operator=(const UniquePtr&) = delete;
-};
-
-// Partial specialization for array types. Like std::unique_ptr, this removes
-// operator* and operator-> but adds operator[].
-template <typename T, typename D>
-class UniquePtr<T[], D> {
-public:
-    explicit UniquePtr(T* ptr = NULL) : mPtr(ptr) {
-    }
-    UniquePtr(UniquePtr<T, D>&& that) {
-      mPtr = that.mPtr;
-      that.mPtr = nullptr;
-    }
-
-    ~UniquePtr() {
-        reset();
-    }
-
-    T& operator[](size_t i) const {
-        return mPtr[i];
-    }
-    T* get() const { return mPtr; }
-
-    T* release() __attribute__((warn_unused_result)) {
-        T* result = mPtr;
-        mPtr = NULL;
-        return result;
-    }
-
-    void reset(T* ptr = NULL) {
-        if (ptr != mPtr) {
-            D()(mPtr);
-            mPtr = ptr;
-        }
-    }
-
-private:
-    T* mPtr;
-
-    // Disallow copy and assignment.
-    UniquePtr(const UniquePtr&) = delete;
-    void operator=(const UniquePtr&) = delete;
-};
-
-#endif  // UNIQUE_PTR_H_included
diff --git a/libc/private/bionic_asm.h b/libc/private/bionic_asm.h
index e2084d4..c1fab1f 100644
--- a/libc/private/bionic_asm.h
+++ b/libc/private/bionic_asm.h
@@ -41,7 +41,7 @@
 #define ENTRY_NO_DWARF(f) \
     .text; \
     .globl f; \
-    .align __bionic_asm_align; \
+    .balign __bionic_asm_align; \
     .type f, __bionic_asm_function_type; \
     f: \
     __bionic_asm_custom_entry(f); \
diff --git a/libc/include/sys/_errdefs.h b/libc/private/bionic_errdefs.h
similarity index 100%
rename from libc/include/sys/_errdefs.h
rename to libc/private/bionic_errdefs.h
diff --git a/libc/private/bionic_fortify.h b/libc/private/bionic_fortify.h
new file mode 100644
index 0000000..df810ca
--- /dev/null
+++ b/libc/private/bionic_fortify.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "private/libc_logging.h"
+
+#include <poll.h> // For struct pollfd.
+#include <sys/select.h> // For struct fd_set.
+
+//
+// Common helpers.
+//
+
+static inline void __check_fd_set(const char* fn, int fd, size_t set_size) {
+  if (__predict_false(fd < 0)) {
+    __fortify_fatal("%s: file descriptor %d < 0", fn, fd);
+  }
+  if (__predict_false(fd >= FD_SETSIZE)) {
+    __fortify_fatal("%s: file descriptor %d >= FD_SETSIZE %zu", fn, fd, set_size);
+  }
+  if (__predict_false(set_size < sizeof(fd_set))) {
+    __fortify_fatal("%s: set size %zu is too small to be an fd_set", fn, set_size);
+  }
+}
+
+static inline void __check_pollfd_array(const char* fn, size_t fds_size, nfds_t fd_count) {
+  size_t pollfd_array_length = fds_size / sizeof(pollfd);
+  if (__predict_false(pollfd_array_length < fd_count)) {
+    __fortify_fatal("%s: %zu-element pollfd array too small for %u fds",
+                    fn, pollfd_array_length, fd_count);
+  }
+}
+
+static inline void __check_count(const char* fn, const char* identifier, size_t value) {
+  if (__predict_false(value > SSIZE_MAX)) {
+    __fortify_fatal("%s: %s %zu > SSIZE_MAX", fn, identifier, value);
+  }
+}
+
+static inline void __check_buffer_access(const char* fn, const char* action,
+                                         size_t claim, size_t actual) {
+  if (__predict_false(claim > actual)) {
+    __fortify_fatal("%s: prevented %zu-byte %s %zu-byte buffer", fn, claim, action, actual);
+  }
+}
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index b45c0c3..94dd7e8 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -44,7 +44,6 @@
 __LIBC_HIDDEN__ extern WriteProtected<libc_globals> __libc_globals;
 
 class KernelArgumentBlock;
-__LIBC_HIDDEN__ void __libc_init_global_stack_chk_guard(KernelArgumentBlock& args);
 __LIBC_HIDDEN__ void __libc_init_malloc(libc_globals* globals);
 __LIBC_HIDDEN__ void __libc_init_setjmp_cookie(libc_globals* globals, KernelArgumentBlock& args);
 __LIBC_HIDDEN__ void __libc_init_vdso(libc_globals* globals, KernelArgumentBlock& args);
diff --git a/libc/include/machine/ieee.h b/libc/private/bionic_ieee.h
similarity index 98%
rename from libc/include/machine/ieee.h
rename to libc/private/bionic_ieee.h
index c579969..69095f0 100644
--- a/libc/include/machine/ieee.h
+++ b/libc/private/bionic_ieee.h
@@ -79,7 +79,7 @@
   unsigned dbl_sign:1;
 };
 
-#if __LP64__
+#if defined(__LP64__)
 
 /* 64-bit Android uses ld128 long doubles. */
 
diff --git a/libc/private/bionic_macros.h b/libc/private/bionic_macros.h
index 4969bd9..d5c5b9c 100644
--- a/libc/private/bionic_macros.h
+++ b/libc/private/bionic_macros.h
@@ -17,6 +17,8 @@
 #ifndef _BIONIC_MACROS_H_
 #define _BIONIC_MACROS_H_
 
+#include <stdint.h>
+
 // Frameworks OpenGL code currently leaks this header and allows
 // collisions with other declarations, e.g., from libnativehelper.
 // TODO: Remove once cleaned up. b/18334516
@@ -46,4 +48,22 @@
     ? (1UL << (64 - __builtin_clzl(static_cast<unsigned long>(value)))) \
     : (1UL << (32 - __builtin_clz(static_cast<unsigned int>(value)))))
 
+static inline uintptr_t align_down(uintptr_t p, size_t align) {
+  return p & ~(align - 1);
+}
+
+static inline uintptr_t align_up(uintptr_t p, size_t align) {
+  return (p + align - 1) & ~(align - 1);
+}
+
+template <typename T>
+static inline T* align_down(T* p, size_t align) {
+  return reinterpret_cast<T*>(align_down(reinterpret_cast<uintptr_t>(p), align));
+}
+
+template <typename T>
+static inline T* align_up(T* p, size_t align) {
+  return reinterpret_cast<T*>(align_up(reinterpret_cast<uintptr_t>(p), align));
+}
+
 #endif // _BIONIC_MACROS_H_
diff --git a/libc/include/sys/_sigdefs.h b/libc/private/bionic_sigdefs.h
similarity index 100%
rename from libc/include/sys/_sigdefs.h
rename to libc/private/bionic_sigdefs.h
diff --git a/libc/private/bionic_time_conversions.h b/libc/private/bionic_time_conversions.h
index a834843..b9eaad2 100644
--- a/libc/private/bionic_time_conversions.h
+++ b/libc/private/bionic_time_conversions.h
@@ -42,9 +42,6 @@
 
 __LIBC_HIDDEN__ void timeval_from_timespec(timeval& tv, const timespec& ts);
 
-__LIBC_HIDDEN__ void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts,
-                                                     clockid_t clock);
-
 __END_DECLS
 
 static inline int check_timespec(const timespec* ts, bool null_allowed) {
@@ -62,4 +59,16 @@
   return 0;
 }
 
+#if !defined(__LP64__)
+static inline void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts, clockid_t clock) {
+  clock_gettime(clock, &abs_ts);
+  abs_ts.tv_sec += ts.tv_sec;
+  abs_ts.tv_nsec += ts.tv_nsec;
+  if (abs_ts.tv_nsec >= NS_PER_S) {
+    abs_ts.tv_nsec -= NS_PER_S;
+    abs_ts.tv_sec++;
+  }
+}
+#endif
+
 #endif
diff --git a/libc/private/bionic_vdso.h b/libc/private/bionic_vdso.h
index 5400de5..8fd0743 100644
--- a/libc/private/bionic_vdso.h
+++ b/libc/private/bionic_vdso.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _PRIVATE_BIONIC_VDSO_H
 #define _PRIVATE_BIONIC_VDSO_H
 
@@ -33,7 +34,7 @@
 #if defined(__aarch64__)
 #define VDSO_CLOCK_GETTIME_SYMBOL "__kernel_clock_gettime"
 #define VDSO_GETTIMEOFDAY_SYMBOL  "__kernel_gettimeofday"
-#elif defined(__x86_64__) || defined(__i386__)
+#elif defined(__arm__) || defined(__i386__) || defined(__x86_64__)
 #define VDSO_CLOCK_GETTIME_SYMBOL "__vdso_clock_gettime"
 #define VDSO_GETTIMEOFDAY_SYMBOL  "__vdso_gettimeofday"
 #endif
diff --git a/libc/private/libc_events.h b/libc/private/libc_events.h
deleted file mode 100644
index f2b973d..0000000
--- a/libc/private/libc_events.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _LIBC_EVENTS_H
-#define _LIBC_EVENTS_H
-
-
-// This is going to be included in assembler code so only allow #define
-// values instead of defining an enum.
-
-#define BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW   80100
-#define BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW   80105
-#define BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW  80110
-#define BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW  80115
-#define BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW  80120
-#define BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW   80125
-#define BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW   80130
-#define BIONIC_EVENT_STPCPY_BUFFER_OVERFLOW   80135
-#define BIONIC_EVENT_STPNCPY_BUFFER_OVERFLOW  80140
-
-#define BIONIC_EVENT_RESOLVER_OLD_RESPONSE    80300
-#define BIONIC_EVENT_RESOLVER_WRONG_SERVER    80305
-#define BIONIC_EVENT_RESOLVER_WRONG_QUERY     80310
-
-#endif // _LIBC_EVENTS_H
diff --git a/libc/private/libc_logging.h b/libc/private/libc_logging.h
index e389565..9fa5982 100644
--- a/libc/private/libc_logging.h
+++ b/libc/private/libc_logging.h
@@ -36,8 +36,6 @@
 
 __BEGIN_DECLS
 
-#include "libc_events.h"
-
 enum {
   ANDROID_LOG_UNKNOWN = 0,
   ANDROID_LOG_DEFAULT,    /* only for SetMinPriority() */
@@ -69,48 +67,26 @@
   char msg[0];
 };
 
-//
 // Formats a message to the log (priority 'fatal'), then aborts.
-//
+__noreturn void __libc_fatal(const char* _Nonnull, ...) __printflike(1, 2);
 
-__LIBC_HIDDEN__ __noreturn void __libc_fatal(const char* format, ...) __printflike(1, 2);
-
-//
-// Formats a message to the log (priority 'fatal'), but doesn't abort.
-// Used by the malloc implementation to ensure that debuggerd dumps memory
-// around the bad address.
-//
-
-__LIBC_HIDDEN__ void __libc_fatal_no_abort(const char* format, ...)
-    __printflike(1, 2);
+// Formats a message to the log (priority 'fatal'), prefixed by "FORTIFY: ", then aborts.
+__noreturn void __fortify_fatal(const char* _Nonnull, ...) __printflike(1, 2);
 
 //
 // Formatting routines for the C library's internal debugging.
 // Unlike the usual alternatives, these don't allocate, and they don't drag in all of stdio.
 //
 
-__LIBC_HIDDEN__ int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...)
-    __printflike(3, 4);
-
-__LIBC_HIDDEN__ int __libc_format_fd(int fd, const char* format, ...)
-    __printflike(2, 3);
-
-__LIBC_HIDDEN__ int __libc_format_log(int priority, const char* tag, const char* format, ...)
-    __printflike(3, 4);
-
-__LIBC_HIDDEN__ int __libc_format_log_va_list(int priority, const char* tag, const char* format,
-                                              va_list ap);
-
-__LIBC_HIDDEN__ int __libc_write_log(int priority, const char* tag, const char* msg);
-
-//
-// Event logging.
-//
-
-__LIBC_HIDDEN__ void __libc_android_log_event_int(int32_t tag, int value);
-__LIBC_HIDDEN__ void __libc_android_log_event_uid(int32_t tag);
-
-__LIBC_HIDDEN__ __noreturn void __fortify_chk_fail(const char* msg, uint32_t event_tag);
+int __libc_format_buffer(char* _Nonnull buf, size_t size, const char* _Nonnull fmt, ...) __printflike(3, 4);
+int __libc_format_fd(int fd, const char* _Nonnull format , ...) __printflike(2, 3);
+int __libc_format_log(int pri, const char* _Nonnull tag, const char* _Nonnull fmt, ...) __printflike(3, 4);
+#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
+int __libc_format_log_va_list(int pri, const char* _Nonnull tag, const char* _Nonnull fmt, va_list ap);
+#else // defined(__mips__) || defined(__i386__)
+int __libc_format_log_va_list(int pri, const char* _Nonnull tag, const char* _Nonnull fmt, va_list _Nonnull ap);
+#endif
+int __libc_write_log(int pri, const char* _Nonnull tag, const char* _Nonnull msg);
 
 __END_DECLS
 
diff --git a/libc/private/thread_private.h b/libc/private/thread_private.h
index 2e3ac3d..0081ad0 100644
--- a/libc/private/thread_private.h
+++ b/libc/private/thread_private.h
@@ -50,6 +50,8 @@
 #define _ARC4_UNLOCK() _thread_arc4_unlock()
 #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f))
 
+extern volatile sig_atomic_t _rs_forked;
+
 __END_DECLS
 
 #endif /* _THREAD_PRIVATE_H_ */
diff --git a/libc/upstream-openbsd/lib/libc/stdio/floatio.h b/libc/stdio/floatio.h
similarity index 100%
rename from libc/upstream-openbsd/lib/libc/stdio/floatio.h
rename to libc/stdio/floatio.h
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 7fe339a..575a428 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -147,11 +147,7 @@
 #define __SNPT 0
 #define __SOPT 0
 
-#if defined(__cplusplus)
-#define _EXT(fp) reinterpret_cast<__sfileext*>((fp)->_ext._base)
-#else
-#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base))
-#endif
+#define _EXT(fp) __BIONIC_CAST(reinterpret_cast, struct __sfileext*, (fp)->_ext._base)
 
 #define _UB(fp) _EXT(fp)->_ub
 #define _FLOCK(fp)  _EXT(fp)->_lock
@@ -171,7 +167,7 @@
 
 #define _FILEEXT_SETUP(f, fext) \
 do { \
-	(f)->_ext._base = (unsigned char *)(fext); \
+	(f)->_ext._base = __BIONIC_CAST(reinterpret_cast, unsigned char*, fext); \
 	_FILEEXT_INIT(f); \
 } while (0)
 
@@ -200,8 +196,6 @@
 __LIBC32_LEGACY_PUBLIC__ int __sclose(void *);
 __LIBC32_LEGACY_PUBLIC__ int _fwalk(int (*)(FILE *));
 
-#pragma GCC visibility push(hidden)
-
 off64_t __sseek64(void*, off64_t, int);
 int	__sflush_locked(FILE *);
 int	__swhatbuf(FILE *, size_t *, int *);
@@ -248,19 +242,9 @@
 #define NO_PRINTF_PERCENT_N
 
 /* OpenBSD exposes these in <stdio.h>, but we only want them exposed to the implementation. */
-#define __sfeof(p)     (((p)->_flags & __SEOF) != 0)
 #define __sferror(p)   (((p)->_flags & __SERR) != 0)
 #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
-#if !defined(__cplusplus)
 #define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
-static __inline int __sputc(int _c, FILE* _p) {
-  if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) {
-    return (*_p->_p++ = _c);
-  } else {
-    return (__swbuf(_c, _p));
-  }
-}
-#endif
 
 /* OpenBSD declares these in fvwrite.h but we want to ensure they're hidden. */
 struct __suio;
@@ -271,7 +255,8 @@
 extern void __sinit(void); // Not actually implemented.
 #define __sdidinit 1
 
-#pragma GCC visibility pop
+size_t parsefloat(FILE*, char*, char*);
+size_t wparsefloat(FILE*, wchar_t*, wchar_t*);
 
 __END_DECLS
 
diff --git a/libc/stdio/parsefloat.c b/libc/stdio/parsefloat.c
new file mode 100644
index 0000000..e911da4
--- /dev/null
+++ b/libc/stdio/parsefloat.c
@@ -0,0 +1,336 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+
+#include "local.h"
+#include "floatio.h"
+
+#define	BUF		513	/* Maximum length of numeric string. */
+
+size_t parsefloat(FILE *fp, char *buf, char *end) {
+	char *commit, *p;
+	int infnanpos = 0;
+	enum {
+		S_START, S_GOTSIGN, S_INF, S_NAN, S_MAYBEHEX,
+		S_DIGITS, S_FRAC, S_EXP, S_EXPDIGITS
+	} state = S_START;
+	unsigned char c;
+	int gotmantdig = 0, ishex = 0;
+
+	/*
+	 * We set commit = p whenever the string we have read so far
+	 * constitutes a valid representation of a floating point
+	 * number by itself.  At some point, the parse will complete
+	 * or fail, and we will ungetc() back to the last commit point.
+	 * To ensure that the file offset gets updated properly, it is
+	 * always necessary to read at least one character that doesn't
+	 * match; thus, we can't short-circuit "infinity" or "nan(...)".
+	 */
+	commit = buf - 1;
+	for (p = buf; p < end; ) {
+		c = *fp->_p;
+reswitch:
+		switch (state) {
+		case S_START:
+			state = S_GOTSIGN;
+			if (c == '-' || c == '+')
+				break;
+			else
+				goto reswitch;
+		case S_GOTSIGN:
+			switch (c) {
+			case '0':
+				state = S_MAYBEHEX;
+				commit = p;
+				break;
+			case 'I':
+			case 'i':
+				state = S_INF;
+				break;
+			case 'N':
+			case 'n':
+				state = S_NAN;
+				break;
+			default:
+				state = S_DIGITS;
+				goto reswitch;
+			}
+			break;
+		case S_INF:
+			if (infnanpos > 6 ||
+			    (c != "nfinity"[infnanpos] &&
+			     c != "NFINITY"[infnanpos]))
+				goto parsedone;
+			if (infnanpos == 1 || infnanpos == 6)
+				commit = p;	/* inf or infinity */
+			infnanpos++;
+			break;
+		case S_NAN:
+			switch (infnanpos) {
+			case -1:	/* XXX kludge to deal with nan(...) */
+				goto parsedone;
+			case 0:
+				if (c != 'A' && c != 'a')
+					goto parsedone;
+				break;
+			case 1:
+				if (c != 'N' && c != 'n')
+					goto parsedone;
+				else
+					commit = p;
+				break;
+			case 2:
+				if (c != '(')
+					goto parsedone;
+				break;
+			default:
+				if (c == ')') {
+					commit = p;
+					infnanpos = -2;
+				} else if (!isalnum(c) && c != '_')
+					goto parsedone;
+				break;
+			}
+			infnanpos++;
+			break;
+		case S_MAYBEHEX:
+			state = S_DIGITS;
+			if (c == 'X' || c == 'x') {
+				ishex = 1;
+				break;
+			} else {	/* we saw a '0', but no 'x' */
+				gotmantdig = 1;
+				goto reswitch;
+			}
+		case S_DIGITS:
+			if ((ishex && isxdigit(c)) || isdigit(c))
+				gotmantdig = 1;
+			else {
+				state = S_FRAC;
+				if (c != '.')
+					goto reswitch;
+			}
+			if (gotmantdig)
+				commit = p;
+			break;
+		case S_FRAC:
+			if (((c == 'E' || c == 'e') && !ishex) ||
+			    ((c == 'P' || c == 'p') && ishex)) {
+				if (!gotmantdig)
+					goto parsedone;
+				else
+					state = S_EXP;
+			} else if ((ishex && isxdigit(c)) || isdigit(c)) {
+				commit = p;
+				gotmantdig = 1;
+			} else
+				goto parsedone;
+			break;
+		case S_EXP:
+			state = S_EXPDIGITS;
+			if (c == '-' || c == '+')
+				break;
+			else
+				goto reswitch;
+		case S_EXPDIGITS:
+			if (isdigit(c))
+				commit = p;
+			else
+				goto parsedone;
+			break;
+		default:
+			abort();
+		}
+		*p++ = c;
+		if (--fp->_r > 0)
+			fp->_p++;
+		else if (__srefill(fp))
+			break;	/* EOF */
+	}
+
+parsedone:
+	while (commit < --p)
+		(void)ungetc(*(unsigned char *)p, fp);
+	*++commit = '\0';
+	return commit - buf;
+}
+
+size_t wparsefloat(FILE *fp, wchar_t *buf, wchar_t *end) {
+	wchar_t *commit, *p;
+	int infnanpos = 0;
+	enum {
+		S_START, S_GOTSIGN, S_INF, S_NAN, S_MAYBEHEX,
+		S_DIGITS, S_FRAC, S_EXP, S_EXPDIGITS
+	} state = S_START;
+	wint_t c;
+	int gotmantdig = 0, ishex = 0;
+
+	/*
+	 * We set commit = p whenever the string we have read so far
+	 * constitutes a valid representation of a floating point
+	 * number by itself.  At some point, the parse will complete
+	 * or fail, and we will ungetc() back to the last commit point.
+	 * To ensure that the file offset gets updated properly, it is
+	 * always necessary to read at least one character that doesn't
+	 * match; thus, we can't short-circuit "infinity" or "nan(...)".
+	 */
+	commit = buf - 1;
+	c = WEOF;
+	for (p = buf; p < end; ) {
+		if ((c = __fgetwc_unlock(fp)) == WEOF)
+			break;
+reswitch:
+		switch (state) {
+		case S_START:
+			state = S_GOTSIGN;
+			if (c == '-' || c == '+')
+				break;
+			else
+				goto reswitch;
+		case S_GOTSIGN:
+			switch (c) {
+			case '0':
+				state = S_MAYBEHEX;
+				commit = p;
+				break;
+			case 'I':
+			case 'i':
+				state = S_INF;
+				break;
+			case 'N':
+			case 'n':
+				state = S_NAN;
+				break;
+			default:
+				state = S_DIGITS;
+				goto reswitch;
+			}
+			break;
+		case S_INF:
+			if (infnanpos > 6 ||
+			    (c != (wint_t)"nfinity"[infnanpos] &&
+			     c != (wint_t)"NFINITY"[infnanpos]))
+				goto parsedone;
+			if (infnanpos == 1 || infnanpos == 6)
+				commit = p;	/* inf or infinity */
+			infnanpos++;
+			break;
+		case S_NAN:
+			switch (infnanpos) {
+			case -1:	/* XXX kludge to deal with nan(...) */
+				goto parsedone;
+			case 0:
+				if (c != 'A' && c != 'a')
+					goto parsedone;
+				break;
+			case 1:
+				if (c != 'N' && c != 'n')
+					goto parsedone;
+				else
+					commit = p;
+				break;
+			case 2:
+				if (c != '(')
+					goto parsedone;
+				break;
+			default:
+				if (c == ')') {
+					commit = p;
+					infnanpos = -2;
+				} else if (!iswalnum(c) && c != '_')
+					goto parsedone;
+				break;
+			}
+			infnanpos++;
+			break;
+		case S_MAYBEHEX:
+			state = S_DIGITS;
+			if (c == 'X' || c == 'x') {
+				ishex = 1;
+				break;
+			} else {	/* we saw a '0', but no 'x' */
+				gotmantdig = 1;
+				goto reswitch;
+			}
+		case S_DIGITS:
+			if ((ishex && iswxdigit(c)) || iswdigit(c))
+				gotmantdig = 1;
+			else {
+				state = S_FRAC;
+				if (c != L'.')
+					goto reswitch;
+			}
+			if (gotmantdig)
+				commit = p;
+			break;
+		case S_FRAC:
+			if (((c == 'E' || c == 'e') && !ishex) ||
+			    ((c == 'P' || c == 'p') && ishex)) {
+				if (!gotmantdig)
+					goto parsedone;
+				else
+					state = S_EXP;
+			} else if ((ishex && iswxdigit(c)) || iswdigit(c)) {
+				commit = p;
+				gotmantdig = 1;
+			} else
+				goto parsedone;
+			break;
+		case S_EXP:
+			state = S_EXPDIGITS;
+			if (c == '-' || c == '+')
+				break;
+			else
+				goto reswitch;
+		case S_EXPDIGITS:
+			if (iswdigit(c))
+				commit = p;
+			else
+				goto parsedone;
+			break;
+		default:
+			abort();
+		}
+		*p++ = c;
+		c = WEOF;
+	}
+
+parsedone:
+	if (c != WEOF)
+		ungetwc(c, fp);
+	while (commit < --p)
+		ungetwc(*p, fp);
+	*++commit = '\0';
+	return (int)(commit - buf);
+}
diff --git a/libc/stdio/refill.c b/libc/stdio/refill.c
index 5b0811f..a7c4bff 100644
--- a/libc/stdio/refill.c
+++ b/libc/stdio/refill.c
@@ -53,7 +53,7 @@
 {
 	fp->_r = 0;		/* largely a convenience for callers */
 
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
 	/* SysV does not make this test; take it out for compatibility */
 	if (fp->_flags & __SEOF)
 		return (EOF);
diff --git a/libc/stdio/snprintf.c b/libc/stdio/snprintf.c
deleted file mode 100644
index 9a25ef2..0000000
--- a/libc/stdio/snprintf.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*	$OpenBSD: snprintf.c,v 1.14 2005/10/10 12:00:52 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include "local.h"
-
-int
-snprintf(char *str, size_t n, const char *fmt, ...)
-{
-	va_list ap;
-	int ret;
-	char dummy;
-	FILE f;
-	struct __sfileext fext;
-
-	/* While snprintf(3) specifies size_t stdio uses an int internally */
-	if (n > INT_MAX)
-		n = INT_MAX;
-	/* Stdio internals do not deal correctly with zero length buffer */
-	if (n == 0) {
-		str = &dummy;
-		n = 1;
-	}
-	_FILEEXT_SETUP(&f, &fext);
-	f._file = -1;
-	f._flags = __SWR | __SSTR;
-	f._bf._base = f._p = (unsigned char *)str;
-	f._bf._size = f._w = n - 1;
-	va_start(ap, fmt);
-	ret = __vfprintf(&f, fmt, ap);
-	va_end(ap);
-	*f._p = '\0';
-	return (ret);
-}
diff --git a/libc/stdio/sprintf.c b/libc/stdio/sprintf.c
deleted file mode 100644
index 1245552..0000000
--- a/libc/stdio/sprintf.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*	$OpenBSD: sprintf.c,v 1.13 2005/10/10 12:00:52 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <limits.h>
-#include "local.h"
-
-#if defined(APIWARN)
-__warn_references(sprintf,
-    "warning: sprintf() is often misused, please use snprintf()");
-#endif
-
-int
-sprintf(char *str, const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-	FILE f;
-	struct __sfileext fext;
-
-	_FILEEXT_SETUP(&f, &fext);
-	f._file = -1;
-	f._flags = __SWR | __SSTR;
-	f._bf._base = f._p = (unsigned char *)str;
-	f._bf._size = f._w = INT_MAX;
-	va_start(ap, fmt);
-	ret = __vfprintf(&f, fmt, ap);
-	va_end(ap);
-	*f._p = '\0';
-	return (ret);
-}
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 1c31a27..b0f5c60 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -31,11 +31,13 @@
  * SUCH DAMAGE.
  */
 
+#define __BIONIC_NO_STDIO_FORTIFY
 #include <stdio.h>
 
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
+#include <paths.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/param.h>
@@ -44,6 +46,7 @@
 
 #include "local.h"
 #include "glue.h"
+#include "private/bionic_fortify.h"
 #include "private/ErrnoRestorer.h"
 #include "private/thread_private.h"
 
@@ -52,6 +55,13 @@
 
 #define	NDYNAMIC 10		/* add ten more whenever necessary */
 
+#define PRINTF_IMPL(expr) \
+    va_list ap; \
+    va_start(ap, fmt); \
+    int result = (expr); \
+    va_end(ap); \
+    return result;
+
 #define std(flags, file) \
     {0,0,0,flags,file,{0,0},0,__sF+file,__sclose,__sread,nullptr,__swrite, \
     {(unsigned char *)(__sFext+file), 0},nullptr,0,{0},{0},{0,0},0,0}
@@ -90,7 +100,7 @@
 
 class ScopedFileLock {
  public:
-  ScopedFileLock(FILE* fp) : fp_(fp) {
+  explicit ScopedFileLock(FILE* fp) : fp_(fp) {
     FLOCKFILE(fp_);
   }
   ~ScopedFileLock() {
@@ -387,11 +397,47 @@
   return r;
 }
 
+int fileno_unlocked(FILE* fp) {
+  int fd = fp->_file;
+  if (fd == -1) {
+    errno = EBADF;
+    return -1;
+  }
+  return fd;
+}
+
 int fileno(FILE* fp) {
   ScopedFileLock sfl(fp);
   return fileno_unlocked(fp);
 }
 
+void clearerr_unlocked(FILE* fp) {
+  return __sclearerr(fp);
+}
+
+void clearerr(FILE* fp) {
+  ScopedFileLock sfl(fp);
+  clearerr_unlocked(fp);
+}
+
+int feof_unlocked(FILE* fp) {
+  return ((fp->_flags & __SEOF) != 0);
+}
+
+int feof(FILE* fp) {
+  ScopedFileLock sfl(fp);
+  return feof_unlocked(fp);
+}
+
+int ferror_unlocked(FILE* fp) {
+  return __sferror(fp);
+}
+
+int ferror(FILE* fp) {
+  ScopedFileLock sfl(fp);
+  return ferror_unlocked(fp);
+}
+
 int __sread(void* cookie, char* buf, int n) {
   FILE* fp = reinterpret_cast<FILE*>(cookie);
   return TEMP_FAILURE_RETRY(read(fp->_file, buf, n));
@@ -598,3 +644,220 @@
   }
   return fp;
 }
+
+int asprintf(char** s, const char* fmt, ...) {
+  PRINTF_IMPL(vasprintf(s, fmt, ap));
+}
+
+char* ctermid(char* s) {
+  return s ? strcpy(s, _PATH_TTY) : const_cast<char*>(_PATH_TTY);
+}
+
+int dprintf(int fd, const char* fmt, ...) {
+  PRINTF_IMPL(vdprintf(fd, fmt, ap));
+}
+
+int fprintf(FILE* fp, const char* fmt, ...) {
+  PRINTF_IMPL(vfprintf(fp, fmt, ap));
+}
+
+int fgetc(FILE* fp) {
+  return getc(fp);
+}
+
+int fputc(int c, FILE* fp) {
+  return putc(c, fp);
+}
+
+int fscanf(FILE* fp, const char* fmt, ...) {
+  PRINTF_IMPL(vfscanf(fp, fmt, ap));
+}
+
+int fwprintf(FILE* fp, const wchar_t* fmt, ...) {
+  PRINTF_IMPL(vfwprintf(fp, fmt, ap));
+}
+
+int fwscanf(FILE* fp, const wchar_t* fmt, ...) {
+  PRINTF_IMPL(vfwscanf(fp, fmt, ap));
+}
+
+int getc(FILE* fp) {
+  ScopedFileLock sfl(fp);
+  return getc_unlocked(fp);
+}
+
+int getc_unlocked(FILE* fp) {
+  return __sgetc(fp);
+}
+
+int getchar_unlocked() {
+  return getc_unlocked(stdin);
+}
+
+int getchar() {
+  return getc(stdin);
+}
+
+ssize_t getline(char** buf, size_t* len, FILE* fp) {
+  return getdelim(buf, len, '\n', fp);
+}
+
+wint_t getwc(FILE* fp) {
+  return fgetwc(fp);
+}
+
+wint_t getwchar() {
+  return fgetwc(stdin);
+}
+
+int printf(const char* fmt, ...) {
+  PRINTF_IMPL(vfprintf(stdout, fmt, ap));
+}
+
+int putc(int c, FILE* fp) {
+  ScopedFileLock sfl(fp);
+  return putc_unlocked(c, fp);
+}
+
+int putc_unlocked(int c, FILE* fp) {
+  if (cantwrite(fp)) {
+    errno = EBADF;
+    return EOF;
+  }
+  _SET_ORIENTATION(fp, -1);
+  if (--fp->_w >= 0 || (fp->_w >= fp->_lbfsize && c != '\n')) {
+    return (*fp->_p++ = c);
+  }
+  return (__swbuf(c, fp));
+}
+
+int putchar(int c) {
+  return putc(c, stdout);
+}
+
+int putchar_unlocked(int c) {
+  return putc_unlocked(c, stdout);
+}
+
+wint_t putwc(wchar_t wc, FILE* fp) {
+  return fputwc(wc, fp);
+}
+
+wint_t putwchar(wchar_t wc) {
+  return fputwc(wc, stdout);
+}
+
+int remove(const char* path) {
+  if (unlink(path) != -1) return 0;
+  if (errno != EISDIR) return -1;
+  return rmdir(path);
+}
+
+void rewind(FILE* fp) {
+  ScopedFileLock sfl(fp);
+  fseek(fp, 0, SEEK_SET);
+  clearerr_unlocked(fp);
+}
+
+int scanf(const char* fmt, ...) {
+  PRINTF_IMPL(vfscanf(stdin, fmt, ap));
+}
+
+void setbuf(FILE* fp, char* buf) {
+  setbuffer(fp, buf, BUFSIZ);
+}
+
+void setbuffer(FILE* fp, char* buf, int size) {
+  setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size);
+}
+
+int setlinebuf(FILE* fp) {
+  return setvbuf(fp, nullptr, _IOLBF, 0);
+}
+
+int snprintf(char* s, size_t n, const char* fmt, ...) {
+  PRINTF_IMPL(vsnprintf(s, n, fmt, ap));
+}
+
+int sprintf(char* s, const char* fmt, ...) {
+  PRINTF_IMPL(vsprintf(s, fmt, ap));
+}
+
+int sscanf(const char* s, const char* fmt, ...) {
+  PRINTF_IMPL(vsscanf(s, fmt, ap));
+}
+
+int swprintf(wchar_t* s, size_t n, const wchar_t* fmt, ...) {
+  PRINTF_IMPL(vswprintf(s, n, fmt, ap));
+}
+
+int swscanf(const wchar_t* s, const wchar_t* fmt, ...) {
+  PRINTF_IMPL(vswscanf(s, fmt, ap));
+}
+
+int vprintf(const char* fmt, va_list ap) {
+  return vfprintf(stdout, fmt, ap);
+}
+
+int vscanf(const char* fmt, va_list ap) {
+  return vfscanf(stdin, fmt, ap);
+}
+
+int vsnprintf(char* s, size_t n, const char* fmt, va_list ap) {
+  // stdio internals use int rather than size_t.
+  static_assert(INT_MAX <= SSIZE_MAX, "SSIZE_MAX too large to fit in int");
+
+  __check_count("vsnprintf", "size", n);
+
+  // Stdio internals do not deal correctly with zero length buffer.
+  char dummy;
+  if (n == 0) {
+    s = &dummy;
+    n = 1;
+  }
+
+  FILE f;
+  __sfileext fext;
+  _FILEEXT_SETUP(&f, &fext);
+  f._file = -1;
+  f._flags = __SWR | __SSTR;
+  f._bf._base = f._p = reinterpret_cast<unsigned char*>(s);
+  f._bf._size = f._w = n - 1;
+
+  int result = __vfprintf(&f, fmt, ap);
+  *f._p = '\0';
+  return result;
+}
+
+int vsprintf(char* s, const char* fmt, va_list ap) {
+  return vsnprintf(s, SSIZE_MAX, fmt, ap);
+}
+
+int vwprintf(const wchar_t* fmt, va_list ap) {
+  return vfwprintf(stdout, fmt, ap);
+}
+
+int vwscanf(const wchar_t* fmt, va_list ap) {
+  return vfwscanf(stdin, fmt, ap);
+}
+
+int wprintf(const wchar_t* fmt, ...) {
+  PRINTF_IMPL(vfwprintf(stdout, fmt, ap));
+}
+
+int wscanf(const wchar_t* fmt, ...) {
+  PRINTF_IMPL(vfwscanf(stdin, fmt, ap));
+}
+
+namespace {
+
+namespace phony {
+#include <bits/struct_file.h>
+}
+
+static_assert(sizeof(::__sFILE) == sizeof(phony::__sFILE),
+              "size mismatch between `struct __sFILE` implementation and public stub");
+static_assert(alignof(::__sFILE) == alignof(phony::__sFILE),
+              "alignment mismatch between `struct __sFILE` implementation and public stub");
+
+}
diff --git a/libc/stdio/stdio_ext.cpp b/libc/stdio/stdio_ext.cpp
index 88e5951..f2f58c6 100644
--- a/libc/stdio/stdio_ext.cpp
+++ b/libc/stdio/stdio_ext.cpp
@@ -89,24 +89,3 @@
   _EXT(fp)->_caller_handles_locking = (type == FSETLOCKING_BYCALLER);
   return old_state;
 }
-
-void clearerr_unlocked(FILE* fp) {
-  return __sclearerr(fp);
-}
-
-int feof_unlocked(FILE* fp) {
-  return __sfeof(fp);
-}
-
-int ferror_unlocked(FILE* fp) {
-  return __sferror(fp);
-}
-
-int fileno_unlocked(FILE* fp) {
-  int fd = fp->_file;
-  if (fd == -1) {
-    errno = EBADF;
-    return -1;
-  }
-  return fd;
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vfscanf.c b/libc/stdio/vfscanf.c
similarity index 90%
rename from libc/upstream-openbsd/lib/libc/stdio/vfscanf.c
rename to libc/stdio/vfscanf.c
index abefe32..e47d0df 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/vfscanf.c
+++ b/libc/stdio/vfscanf.c
@@ -346,14 +346,14 @@
 					wcp = NULL;
 				n = 0;
 				while (width != 0) {
-					if (n == MB_CUR_MAX) {
+					if (n == (int)MB_CUR_MAX) {
 						fp->_flags |= __SERR;
 						goto input_failure;
 					}
 					buf[n++] = *fp->_p;
 					fp->_p++;
 					fp->_r--;
-					bzero(&mbs, sizeof(mbs));
+					memset(&mbs, 0, sizeof(mbs));
 					nconv = mbrtowc(wcp, buf, n, &mbs);
 					if (nconv == (size_t)-1) {
 						fp->_flags |= __SERR;
@@ -383,7 +383,7 @@
 			if (flags & SUPPRESS) {
 				size_t sum = 0;
 				for (;;) {
-					if ((n = fp->_r) < width) {
+					if ((n = fp->_r) < (int)width) {
 						sum += n;
 						width -= n;
 						fp->_p += n;
@@ -428,14 +428,14 @@
 				n = 0;
 				nchars = 0;
 				while (width != 0) {
-					if (n == MB_CUR_MAX) {
+					if (n == (int)MB_CUR_MAX) {
 						fp->_flags |= __SERR;
 						goto input_failure;
 					}
 					buf[n++] = *fp->_p;
 					fp->_p++;
 					fp->_r--;
-					bzero(&mbs, sizeof(mbs));
+					memset(&mbs, 0, sizeof(mbs));
 					nconv = mbrtowc(wcp, buf, n, &mbs);
 					if (nconv == (size_t)-1) {
 						fp->_flags |= __SERR;
@@ -532,14 +532,14 @@
 					wcp = &twc;
 				n = 0;
 				while (!isspace(*fp->_p) && width != 0) {
-					if (n == MB_CUR_MAX) {
+					if (n == (int)MB_CUR_MAX) {
 						fp->_flags |= __SERR;
 						goto input_failure;
 					}
 					buf[n++] = *fp->_p;
 					fp->_p++;
 					fp->_r--;
-					bzero(&mbs, sizeof(mbs));
+					memset(&mbs, 0, sizeof(mbs));
 					nconv = mbrtowc(wcp, buf, n, &mbs);
 					if (nconv == (size_t)-1) {
 						fp->_flags |= __SERR;
@@ -760,96 +760,25 @@
 #ifdef FLOATING_POINT
 		case CT_FLOAT:
 			/* scan a floating point number as if by strtod */
-#ifdef hardway
 			if (width == 0 || width > sizeof(buf) - 1)
 				width = sizeof(buf) - 1;
-#else
-			/* size_t is unsigned, hence this optimisation */
-			if (--width > sizeof(buf) - 2)
-				width = sizeof(buf) - 2;
-			width++;
-#endif
-			flags |= SIGNOK | NDIGITS | DPTOK | EXPOK;
-			for (p = buf; width; width--) {
-				c = *fp->_p;
-				/*
-				 * This code mimicks the integer conversion
-				 * code, but is much simpler.
-				 */
-				switch (c) {
-
-				case '0': case '1': case '2': case '3':
-				case '4': case '5': case '6': case '7':
-				case '8': case '9':
-					flags &= ~(SIGNOK | NDIGITS);
-					goto fok;
-
-				case '+': case '-':
-					if (flags & SIGNOK) {
-						flags &= ~SIGNOK;
-						goto fok;
-					}
-					break;
-				case '.':
-					if (flags & DPTOK) {
-						flags &= ~(SIGNOK | DPTOK);
-						goto fok;
-					}
-					break;
-				case 'e': case 'E':
-					/* no exponent without some digits */
-					if ((flags&(NDIGITS|EXPOK)) == EXPOK) {
-						flags =
-						    (flags & ~(EXPOK|DPTOK)) |
-						    SIGNOK | NDIGITS;
-						goto fok;
-					}
-					break;
-				}
-				break;
-		fok:
-				*p++ = c;
-				if (--fp->_r > 0)
-					fp->_p++;
-				else if (__srefill(fp))
-					break;	/* EOF */
-			}
-			/*
-			 * If no digits, might be missing exponent digits
-			 * (just give back the exponent) or might be missing
-			 * regular digits, but had sign and/or decimal point.
-			 */
-			if (flags & NDIGITS) {
-				if (flags & EXPOK) {
-					/* no digits at all */
-					while (p > buf)
-						ungetc(*(u_char *)--p, fp);
-					goto match_failure;
-				}
-				/* just a bad exponent (e and maybe sign) */
-				c = *(u_char *)--p;
-				if (c != 'e' && c != 'E') {
-					(void) ungetc(c, fp);/* sign */
-					c = *(u_char *)--p;
-				}
-				(void) ungetc(c, fp);
-			}
+			if ((width = parsefloat(fp, buf, buf + width)) == 0)
+				goto match_failure;
 			if ((flags & SUPPRESS) == 0) {
-				*p = '\0';
 				if (flags & LONGDBL) {
-					long double res = strtold(buf,
-					    (char **)NULL);
+					long double res = strtold(buf, &p);
 					*va_arg(ap, long double *) = res;
 				} else if (flags & LONG) {
-					double res = strtod(buf, (char **)NULL);
+					double res = strtod(buf, &p);
 					*va_arg(ap, double *) = res;
 				} else {
-					float res = strtof(buf, (char **)NULL);
+					float res = strtof(buf, &p);
 					*va_arg(ap, float *) = res;
 				}
+				if ((size_t)(p - buf) != width) abort();
 				nassigned++;
 			}
-			nread += p - buf;
+			nread += width;
 			break;
 #endif /* FLOATING_POINT */
 		}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vfwscanf.c b/libc/stdio/vfwscanf.c
similarity index 89%
rename from libc/upstream-openbsd/lib/libc/stdio/vfwscanf.c
rename to libc/stdio/vfwscanf.c
index cbb36be..0a7bfa9 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/vfwscanf.c
+++ b/libc/stdio/vfwscanf.c
@@ -95,6 +95,9 @@
 	(cclcompl ? (wmemchr(ccls, (_c), ccle - ccls) == NULL) : \
 	(wmemchr(ccls, (_c), ccle - ccls) != NULL))
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wframe-larger-than="
+
 /*
  * vfwscanf
  */
@@ -120,9 +123,6 @@
 	size_t nconv;		/* number of bytes in mb. conversion */
 	char mbbuf[MB_LEN_MAX];	/* temporary mb. character buffer */
  	mbstate_t mbs;
-#ifdef FLOATING_POINT
-	wchar_t decimal_point = 0;
-#endif
 
 	/* `basefix' is used to avoid `if' tests in the integer scanner */
 	static short basefix[17] =
@@ -371,7 +371,7 @@
 				if (!(flags & SUPPRESS))
 					mbp = va_arg(ap, char *);
 				n = 0;
-				bzero(&mbs, sizeof(mbs));
+				memset(&mbs, 0, sizeof(mbs));
 				while (width != 0 &&
 				    (wi = __fgetwc_unlock(fp)) != WEOF) {
 					if (width >= MB_CUR_MAX &&
@@ -436,7 +436,7 @@
 				if (!(flags & SUPPRESS))
 					mbp = va_arg(ap, char *);
 				n = 0;
-				bzero(&mbs, sizeof(mbs));
+				memset(&mbs, 0, sizeof(mbs));
 				while ((wi = __fgetwc_unlock(fp)) != WEOF &&
 				    width != 0 && INCCL(wi)) {
 					if (width >= MB_CUR_MAX &&
@@ -497,7 +497,7 @@
 			} else {
 				if (!(flags & SUPPRESS))
 					mbp = va_arg(ap, char *);
-				bzero(&mbs, sizeof(mbs));
+				memset(&mbs, 0, sizeof(mbs));
 				while ((wi = __fgetwc_unlock(fp)) != WEOF &&
 				    width != 0 &&
 				    !iswspace(wi)) {
@@ -686,95 +686,23 @@
 			if (width == 0 || width > sizeof(buf) /
 			    sizeof(*buf) - 1)
 				width = sizeof(buf) / sizeof(*buf) - 1;
-			flags |= SIGNOK | NDIGITS | DPTOK | EXPOK;
-			for (p = buf; width; width--) {
-				c = __fgetwc_unlock(fp);
-				/*
-				 * This code mimicks the integer conversion
-				 * code, but is much simpler.
-				 */
-				switch (c) {
-
-				case '0': case '1': case '2': case '3':
-				case '4': case '5': case '6': case '7':
-				case '8': case '9':
-					flags &= ~(SIGNOK | NDIGITS);
-					goto fok;
-
-				case '+': case '-':
-					if (flags & SIGNOK) {
-						flags &= ~SIGNOK;
-						goto fok;
-					}
-					break;
-				case 'e': case 'E':
-					/* no exponent without some digits */
-					if ((flags&(NDIGITS|EXPOK)) == EXPOK) {
-						flags =
-						    (flags & ~(EXPOK|DPTOK)) |
-						    SIGNOK | NDIGITS;
-						goto fok;
-					}
-					break;
-				default:
-					if (decimal_point == 0) {
-						bzero(&mbs, sizeof(mbs));
-						nconv = mbrtowc(&decimal_point,
-						    localeconv()->decimal_point,
-					    	    MB_CUR_MAX, &mbs);
-						if (nconv == 0 ||
-						    nconv == (size_t)-1 ||
-						    nconv == (size_t)-2)
-							decimal_point = '.';
-					}
-					if (c == decimal_point &&
-					    (flags & DPTOK)) {
-						flags &= ~(SIGNOK | DPTOK);
-						goto fok;
-					}
-					break;
-				}
-				if (c != WEOF)
-					__ungetwc(c, fp);
-				break;
-		fok:
-				*p++ = c;
-			}
-			/*
-			 * If no digits, might be missing exponent digits
-			 * (just give back the exponent) or might be missing
-			 * regular digits, but had sign and/or decimal point.
-			 */
-			if (flags & NDIGITS) {
-				if (flags & EXPOK) {
-					/* no digits at all */
-					while (p > buf)
-						__ungetwc(*--p, fp);
-					goto match_failure;
-				}
-				/* just a bad exponent (e and maybe sign) */
-				c = *--p;
-				if (c != 'e' && c != 'E') {
-					__ungetwc(c, fp);/* sign */
-					c = *--p;
-				}
-				__ungetwc(c, fp);
-			}
+			if ((width = wparsefloat(fp, buf, buf + width)) == 0)
+				goto match_failure;
 			if ((flags & SUPPRESS) == 0) {
-				*p = 0;
 				if (flags & LONGDBL) {
-					long double res = wcstold(buf, NULL);
+					long double res = wcstold(buf, &p);
 					*va_arg(ap, long double *) = res;
 				} else if (flags & LONG) {
-					double res = wcstod(buf, NULL);
+					double res = wcstod(buf, &p);
 					*va_arg(ap, double *) = res;
 				} else {
-					float res = wcstof(buf, NULL);
+					float res = wcstof(buf, &p);
 					*va_arg(ap, float *) = res;
 				}
+				if (p - buf != (ptrdiff_t)width) abort();
 				nassigned++;
 			}
-			nread += p - buf;
+			nread += width;
 			nconversions++;
 			break;
 #endif /* FLOATING_POINT */
@@ -785,6 +713,7 @@
 match_failure:
 	return (nassigned);
 }
+#pragma GCC diagnostic pop
 
 int
 vfwscanf(FILE * __restrict fp, const wchar_t * __restrict fmt, __va_list ap)
diff --git a/libc/tools/check-symbols-glibc.py b/libc/tools/check-symbols-glibc.py
index c5dbdcf..631fd93 100755
--- a/libc/tools/check-symbols-glibc.py
+++ b/libc/tools/check-symbols-glibc.py
@@ -88,7 +88,7 @@
   'strlcpy',
   'sys_signame',
   'wcslcat',
-  'wcslcpy'
+  'wcslcpy',
 ])
 # Some symbols are part of the FORTIFY implementation.
 FORTIFY_stuff = set([
@@ -108,15 +108,16 @@
   '__strlen_chk',
   '__strncpy_chk2',
   '__strrchr_chk',
-  '__umask_chk'
+  '__umask_chk',
   '__write_chk',
 ])
-# Some symbols are used to implement public macros.
+# Some symbols are used to implement public functions/macros.
 macro_stuff = set([
   '__assert2',
   '__errno',
   '__fe_dfl_env',
   '__get_h_errno',
+  '__gnu_strerror_r',
   '__fpclassifyd',
   '__isfinite',
   '__isfinitef',
@@ -132,7 +133,8 @@
 linux_stuff = set([
   'getauxval',
   'gettid',
-  'tgkill'
+  'pthread_gettid_np',
+  'tgkill',
 ])
 # Some standard stuff isn't yet in the versions of glibc we're using.
 std_stuff = set([
@@ -168,6 +170,7 @@
 libresolv_stuff = set([
   '__res_send_setqhook',
   '__res_send_setrhook',
+  '_resolv_delete_cache_for_net',
   '_resolv_flush_cache_for_net',
   '_resolv_set_nameservers_for_net',
   'dn_expand',
@@ -178,6 +181,23 @@
   '_ctype_',
   '__libc_init',
 ])
+# POSIX has some stuff that's too stupid for words (a64l) or not actually
+# implemented in glibc unless you count always failing with ENOSYS as
+# being implemented (fattach).
+in_posix_and_glibc_but_actually_dead = set([
+  'a64l',
+  'fattach',
+  'fdetach',
+  'getmsg',
+  'getpmsg',
+  'isastream',
+  'l64a',
+  'putmsg',
+  'putpmsg',
+])
+
+posix = posix - in_posix_and_glibc_but_actually_dead
+glibc = glibc - in_posix_and_glibc_but_actually_dead
 
 if not only_unwanted:
   #print 'glibc:'
diff --git a/libc/tools/generate-NOTICE.py b/libc/tools/generate-NOTICE.py
index 79b4ea9..6573644 100755
--- a/libc/tools/generate-NOTICE.py
+++ b/libc/tools/generate-NOTICE.py
@@ -16,7 +16,7 @@
 
 def IsUninteresting(path):
     path = path.lower()
-    if path.endswith(".mk") or path.endswith(".py") or path.endswith(".pyc") or path.endswith(".txt") or path.endswith(".3"):
+    if path.endswith(".mk") or path.endswith(".py") or path.endswith(".pyc") or path.endswith(".txt") or path.endswith(".3") or path.endswith(".swp"):
         return True
     if path.endswith("/notice") or path.endswith("/readme") or path.endswith("/caveats"):
         return True
diff --git a/libc/tools/genlibgcc_compat.py b/libc/tools/genlibgcc_compat.py
deleted file mode 100755
index 628bf92..0000000
--- a/libc/tools/genlibgcc_compat.py
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/python
-
-'''
-/* This file generates libgcc_compat.c file that contains dummy
- * references to libgcc.a functions to force the dynamic linker
- * to copy their definition into the final libc.so binary.
- *
- * They are required to ensure backwards binary compatibility with
- * libc.so provided by the platform and binaries built with the NDK or
- * different versions/configurations of toolchains.
- *
- * Now, for a more elaborate description of the issue:
- *
- * libgcc.a is a compiler-specific library containing various helper
- * functions used to implement certain operations that are not necessarily
- * supported by the target CPU. For example, integer division doesn't have a
- * corresponding CPU instruction on ARMv5, and is instead implemented in the
- * compiler-generated machine code as a call to an __idiv helper function.
- *
- * Normally, one has to place libgcc.a in the link command used to generate
- * target binaries (shared libraries and executables) after all objects and
- * static libraries, but before dependent shared libraries, i.e. something
- * like:
- *         gcc <options> -o libfoo.so  foo.a libgcc.a -lc -lm
- *
- * This ensures that any helper function needed by the code in foo.a is copied
- * into the final libfoo.so. However, doing so will link a bunch of other __cxa
- * functions from libgcc.a into each .so and executable, causing 4k+ increase
- * in every binary. Therefore the Android platform build system has been
- * using this instead:
- *
- *         gcc <options> -o libfoo.so foo.a -lc -lm libgcc.a
- *
- * The problem with this is that if one helper function needed by foo.a has
- * already been copied into libc.so or libm.so, then nothing will be copied
- * into libfoo.so. Instead, a symbol import definition will be added to it
- * so libfoo.so can directly call the one in libc.so at runtime.
- *
- * When refreshing toolchains for new versions or using different architecture
- * flags, the set of helper functions copied to libc.so may change, which
- * resulted in some native shared libraries generated with the NDK or prebuilts
- * from vendors to fail to load properly.
- *
- * The NDK has been fixed after 1.6_r1 to use the correct link command, so
- * any native shared library generated with it should now be safe from that
- * problem. On the other hand, existing shared libraries distributed with
- * applications that were generated with a previous version of the NDK
- * still need all 1.5/1.6 helper functions in libc.so and libm.so
- *
- * After 3.2, the toolchain was updated again, adding __aeabi_f2uiz to the
- * list of requirements. Technically, this is due to mis-linked NDK libraries
- * but it is easier to add a single function here than asking several app
- * developers to fix their build.
- *
- * The __aeabi_idiv function is added to the list since cortex-a15 supports
- * HW idiv instructions so the system libc.so doesn't pull in the reference to
- * __aeabi_idiv but legacy libraries built against cortex-a9 targets still need
- * it.
- *
- * Final note: some of the functions below should really be in libm.so to
- *             completely reflect the state of 1.5/1.6 system images. However,
- *             since libm.so depends on libc.so, it's easier to put all of
- *             these in libc.so instead, since the dynamic linker will always
- *             search in libc.so before libm.so for dependencies.
- */
-'''
-
-import os
-import sys
-import subprocess
-import tempfile
-import re
-
-libgcc_compat_header = "/* Generated by genlibgcc_compat.py */\n\n"
-
-class Generator:
-    def process(self):
-        android_build_top_path = os.environ["ANDROID_BUILD_TOP"]
-
-        print "* ANDROID_BUILD_TOP=" + android_build_top_path
-
-        # Check TARGET_ARCH
-        arch = subprocess.check_output(["CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core make --no-print-directory -f build/core/config.mk dumpvar-TARGET_ARCH"],
-                    cwd=android_build_top_path, shell=True).strip()
-
-        if arch != 'arm' and arch != 'x86':
-            sys.exit("Error: Invalid TARGET_ARCH='" + arch + "' expecting 'arm' or 'x86'")
-
-        build_path =  android_build_top_path + "/bionic/libc"
-        file_name = "libgcc_compat.c"
-        file_path = build_path + "/arch-" + arch + "/bionic/" + file_name
-
-        build_output_file_path = tempfile.mkstemp()[1]
-
-        p = subprocess.Popen(["ONE_SHOT_MAKEFILE=bionic/libc/Android.mk make -C " + android_build_top_path
-                    + " -f build/core/main.mk all_modules TARGET_LIBGCC= -j20 -B 2>&1 | tee " + build_output_file_path],
-                    cwd=build_path, shell=True)
-        p.wait()
-
-        print "* Build complete, logfile: " + build_output_file_path
-
-        symbol_set = set()
-        prog=re.compile("(?<=undefined reference to ')\w+")
-        fd = open(build_output_file_path, 'r')
-        for line in fd:
-            m = prog.search(line)
-            if m:
-                symbol_set.add(m.group(0))
-
-        fd.close()
-
-        symbol_list = sorted(symbol_set)
-
-        print "* Found " + repr(len(symbol_list)) + " referenced symbols: " + repr(symbol_list)
-
-        if 0 == len(symbol_list):
-            sys.exit("Error: symbol list is empty, please check the build log: " + build_output_file_path)
-
-        print "* Generating " + file_path
-        fres = open(file_path, 'w')
-        fres.write(libgcc_compat_header)
-
-        for sym_name in symbol_list:
-            fres.write("extern char "+sym_name+";\n")
-        fres.write("\n");
-
-        fres.write("void* __bionic_libgcc_compat_symbols[] = {\n");
-        for sym_name in symbol_list:
-            fres.write("    &"+sym_name+",\n")
-        fres.write("};\n");
-
-        fres.close()
-
-generator = Generator()
-generator.process()
-
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 04ccf39..b4aa06c 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -555,41 +555,43 @@
             if syscall.has_key("x86_64"):
                 syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
 
-    # Scan a Linux kernel asm/unistd.h file containing __NR_* constants
+
+    # Scan Linux kernel asm/unistd.h files containing __NR_* constants
     # and write out equivalent SYS_* constants for glibc source compatibility.
-    def scan_linux_unistd_h(self, fp, path):
-        pattern = re.compile(r'^#define __NR_([a-z]\S+) .*')
-        syscalls = set() # MIPS defines everything three times; work around that.
-        for line in open(path):
-            m = re.search(pattern, line)
-            if m:
-                syscalls.add(m.group(1))
-        for syscall in sorted(syscalls):
-            fp.write("#define SYS_%s %s\n" % (syscall, make__NR_name(syscall)))
-
-
     def gen_glibc_syscalls_h(self):
-        # TODO: generate a separate file for each architecture, like glibc's bits/syscall.h.
-        glibc_syscalls_h_path = "include/sys/glibc-syscalls.h"
+        glibc_syscalls_h_path = "include/bits/glibc-syscalls.h"
         logging.info("generating " + glibc_syscalls_h_path)
         glibc_fp = create_file(glibc_syscalls_h_path)
         glibc_fp.write("/* %s */\n" % warning)
-        glibc_fp.write("#ifndef _BIONIC_GLIBC_SYSCALLS_H_\n")
-        glibc_fp.write("#define _BIONIC_GLIBC_SYSCALLS_H_\n")
+        glibc_fp.write("#ifndef _BIONIC_BITS_GLIBC_SYSCALLS_H_\n")
+        glibc_fp.write("#define _BIONIC_BITS_GLIBC_SYSCALLS_H_\n")
 
-        glibc_fp.write("#if defined(__aarch64__)\n")
-        self.scan_linux_unistd_h(glibc_fp, os.path.join(bionic_libc_root, "kernel/uapi/asm-generic/unistd.h"))
-        glibc_fp.write("#elif defined(__arm__)\n")
-        self.scan_linux_unistd_h(glibc_fp, os.path.join(bionic_libc_root, "kernel/uapi/asm-arm/asm/unistd.h"))
-        glibc_fp.write("#elif defined(__mips__)\n")
-        self.scan_linux_unistd_h(glibc_fp, os.path.join(bionic_libc_root, "kernel/uapi/asm-mips/asm/unistd.h"))
-        glibc_fp.write("#elif defined(__i386__)\n")
-        self.scan_linux_unistd_h(glibc_fp, os.path.join(bionic_libc_root, "kernel/uapi/asm-x86/asm/unistd_32.h"))
-        glibc_fp.write("#elif defined(__x86_64__)\n")
-        self.scan_linux_unistd_h(glibc_fp, os.path.join(bionic_libc_root, "kernel/uapi/asm-x86/asm/unistd_64.h"))
-        glibc_fp.write("#endif\n")
+        # Collect the set of all syscalls for all architectures.
+        syscalls = set()
+        pattern = re.compile(r'^\s*#\s*define\s*__NR_([a-z]\S+)')
+        for unistd_h in ["kernel/uapi/asm-generic/unistd.h",
+                         "kernel/uapi/asm-arm/asm/unistd.h",
+                         "kernel/uapi/asm-mips/asm/unistd.h",
+                         "kernel/uapi/asm-x86/asm/unistd_32.h",
+                         "kernel/uapi/asm-x86/asm/unistd_64.h"]:
+          for line in open(os.path.join(bionic_libc_root, unistd_h)):
+            m = re.search(pattern, line)
+            if m:
+              nr_name = m.group(1)
+              if 'reserved' not in nr_name and 'unused' not in nr_name:
+                syscalls.add(nr_name)
 
-        glibc_fp.write("#endif /* _BIONIC_GLIBC_SYSCALLS_H_ */\n")
+        # Write out a single file listing them all. Note that the input
+        # files include #if trickery, so even for a single architecture
+        # we don't know exactly which ones are available.
+        # https://code.google.com/p/android/issues/detail?id=215853
+        for syscall in sorted(syscalls):
+          nr_name = make__NR_name(syscall)
+          glibc_fp.write("#if defined(%s)\n" % nr_name)
+          glibc_fp.write("  #define SYS_%s %s\n" % (syscall, nr_name))
+          glibc_fp.write("#endif\n")
+
+        glibc_fp.write("#endif /* _BIONIC_BITS_GLIBC_SYSCALLS_H_ */\n")
         glibc_fp.close()
         self.other_files.append(glibc_syscalls_h_path)
 
diff --git a/libc/tools/genversion-scripts.py b/libc/tools/genversion-scripts.py
index e15c04e..0a98994 100755
--- a/libc/tools/genversion-scripts.py
+++ b/libc/tools/genversion-scripts.py
@@ -7,6 +7,7 @@
 import os.path
 import shutil
 import tempfile
+import sys
 
 
 all_arches = ["arm", "arm64", "mips", "mips64", "x86", "x86_64"]
@@ -16,6 +17,9 @@
 libc_script = os.path.join(bionic_libc_root, "libc.map.txt")
 libm_script = os.path.join(bionic_libm_root, "libm.map.txt")
 libdl_script = os.path.join(bionic_libdl_root, "libdl.map.txt")
+libstdcxx_script = os.path.join(bionic_libc_root, "libstdc++.map.txt")
+
+script_name = os.path.basename(sys.argv[0])
 
 # TODO (dimity): generate architecture-specific version scripts as part of build
 
@@ -26,38 +30,38 @@
 
 bionic_libc_root = os.path.join(os.environ["ANDROID_BUILD_TOP"], "bionic/libc")
 
-warning = "Generated by genversionscripts.py. Do not edit."
+warning = "Generated by %s. Do not edit." % script_name
+
+
+def has_arch_tags(tags):
+  for arch in all_arches:
+    if arch in tags:
+      return True
+  return False
 
 
 class VersionScriptGenerator(object):
 
   def run(self):
-    for script in [libc_script, libm_script, libdl_script]:
+    for script in [libc_script, libstdcxx_script, libm_script, libdl_script]:
       basename = os.path.basename(script)
       dirname = os.path.dirname(script)
       for arch in all_arches:
-        for brillo in [False, True]:
-          has_nobrillo = False
-          name = basename.split(".")[0] + "." + arch + (".brillo" if brillo else "") + ".map"
-          tmp_path = os.path.join(bionic_temp, name)
-          dest_path = os.path.join(dirname, name)
-          with open(tmp_path, "w") as fout:
-            with open(script, "r") as fin:
-              fout.write("# %s\n" % warning)
-              for line in fin:
-                index = line.find("#")
-                if index != -1:
-                  tags = line[index+1:].split()
-                  if arch not in tags:
-                    continue
-                  if brillo and "nobrillo" in tags:
-                    has_nobrillo = True
-                    continue
-                fout.write(line)
-          if not brillo or has_nobrillo:
-            shutil.copyfile(tmp_path, dest_path)
+        name = basename.split(".")[0] + "." + arch + ".map"
+        tmp_path = os.path.join(bionic_temp, name)
+        dest_path = os.path.join(dirname, name)
+        with open(tmp_path, "w") as fout:
+          with open(script, "r") as fin:
+            fout.write("# %s\n" % warning)
+            for line in fin:
+              index = line.find("#")
+              if index != -1:
+                tags = line[index+1:].split()
+                if arch not in tags and has_arch_tags(tags):
+                  continue
+              fout.write(line)
+        shutil.copyfile(tmp_path, dest_path)
 
 
 generator = VersionScriptGenerator()
 generator.run()
-
diff --git a/libc/tools/pylintrc b/libc/tools/pylintrc
new file mode 100644
index 0000000..2481b12
--- /dev/null
+++ b/libc/tools/pylintrc
@@ -0,0 +1,280 @@
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+profile=no
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+
+[MESSAGES CONTROL]
+
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time. See also the "--disable" option for examples.
+#enable=
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+disable=missing-docstring,invalid-name,no-self-use,fixme,design
+
+
+[REPORTS]
+
+# Set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html. You can also give a reporter class, eg
+# mypackage.mymodule.MyReporterClass.
+output-format=text
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells whether to display a full report or only the messages
+reports=yes
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note). You have access to the variables errors warning, statement which
+# respectively contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (RP0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (RP0004).
+comment=no
+
+# Template used to display messages. This is a python new-style format string
+# used to format the message information. See doc for all details
+#msg-template=
+
+
+[BASIC]
+
+# Required attributes for module, separated by a comma
+required-attributes=
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=map,filter,apply,input
+
+# Regular expression which should only match correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression which should only match correct module level names
+const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
+
+# Regular expression which should only match correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression which should only match correct function names
+function-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct method names
+method-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct instance attribute names
+attr-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct argument names
+argument-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct variable names
+variable-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct attribute names in class
+# bodies
+class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
+
+# Regular expression which should only match correct list comprehension /
+# generator expression variable names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# Regular expression which should only match function or class names that do
+# not require a docstring.
+no-docstring-rgx=__.*__
+
+# Minimum line length for functions/classes that require docstrings, shorter
+# ones are exempt.
+docstring-min-length=-1
+
+
+[TYPECHECK]
+
+# Tells whether missing members accessed in mixin class should be ignored. A
+# mixin class is detected if its name ends with "mixin" (case insensitive).
+ignore-mixin-members=yes
+
+# List of classes names for which member attributes should not be checked
+# (useful for classes with attributes dynamically set).
+ignored-classes=SQLObject
+
+# When zope mode is activated, add a predefined set of Zope acquired attributes
+# to generated-members.
+zope=no
+
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E0201 when accessed. Python regular
+# expressions are accepted.
+generated-members=REQUEST,acl_users,aq_parent
+
+
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME,XXX,TODO
+
+
+[SIMILARITIES]
+
+# Minimum lines number of a similarity.
+min-similarity-lines=4
+
+# Ignore comments when computing similarities.
+ignore-comments=yes
+
+# Ignore docstrings when computing similarities.
+ignore-docstrings=yes
+
+# Ignore imports when computing similarities.
+ignore-imports=no
+
+
+[VARIABLES]
+
+# Tells whether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching the beginning of the name of dummy variables
+# (i.e. not used).
+dummy-variables-rgx=_$|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
+
+
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=100
+
+# Regexp for a line that is allowed to be longer than the limit.
+ignore-long-lines=^\s*(# )?<?https?://\S+>?$
+
+# Allow the body of an if to be on the same line as the test if there is no
+# else.
+single-line-if-stmt=no
+
+# List of optional constructs for which whitespace checking is disabled
+no-space-check=trailing-comma,dict-separator
+
+# Maximum number of lines in a module
+max-module-lines=1000
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string='  '
+
+
+[IMPORTS]
+
+# Deprecated modules which should not be used, separated by a comma
+deprecated-modules=regsub,TERMIOS,Bastion,rexec
+
+# Create a graph of every (i.e. internal and external) dependencies in the
+# given file (report RP0402 must not be disabled)
+import-graph=
+
+# Create a graph of external dependencies in the given file (report RP0402 must
+# not be disabled)
+ext-import-graph=
+
+# Create a graph of internal dependencies in the given file (report RP0402 must
+# not be disabled)
+int-import-graph=
+
+
+[DESIGN]
+
+# Maximum number of arguments for function / method
+max-args=5
+
+# Argument names that match this expression will be ignored. Default to name
+# with leading underscore
+ignored-argument-names=_.*
+
+# Maximum number of locals for function / method body
+max-locals=15
+
+# Maximum number of return / yield for function / method body
+max-returns=6
+
+# Maximum number of branch for function / method body
+max-branches=12
+
+# Maximum number of statements in function / method body
+max-statements=50
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=7
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+
+[CLASSES]
+
+# List of interface methods to ignore, separated by a comma. This is used for
+# instance to not check methods defines in Zope's Interface base class.
+ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,__new__,setUp
+
+# List of valid names for the first argument in a class method.
+valid-classmethod-first-arg=cls
+
+# List of valid names for the first argument in a metaclass class method.
+valid-metaclass-classmethod-first-arg=mcs
+
+
+[EXCEPTIONS]
+
+# Exceptions that will emit a warning when being caught. Defaults to
+# "Exception"
+overgeneral-exceptions=Exception
diff --git a/libc/tzcode/localtime.c b/libc/tzcode/localtime.c
index 3f87743..74411f7 100644
--- a/libc/tzcode/localtime.c
+++ b/libc/tzcode/localtime.c
@@ -178,11 +178,6 @@
 static char lcl_TZname[TZ_STRLEN_MAX + 1];
 static int  lcl_is_set;
 
-char * tzname[2] = {
-    (char *) wildabbr,
-    (char *) wildabbr
-};
-
 /*
 ** Section 4.12.3 of X3.159-1989 requires that
 **  Except for the strftime function, these functions [asctime,
@@ -193,10 +188,16 @@
 
 static struct tm	tm;
 
+#if !HAVE_POSIX_DECLS
+char *			tzname[2] = {
+	(char *) wildabbr,
+	(char *) wildabbr
+};
 #ifdef USG_COMPAT
 long			timezone;
 int			daylight;
-#endif /* defined USG_COMPAT */
+# endif
+#endif
 
 #ifdef ALTZONE
 long			altzone;
@@ -381,7 +382,7 @@
 	register int			fid;
 	register int			stored;
 	register ssize_t		nread;
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
 	register bool doaccess;
 	register char *fullname = lsp->fullname;
 #endif
@@ -425,7 +426,7 @@
 	  return errno;
 
 #if defined(__BIONIC__)
-	nread = read(fid, up->buf, entry_length);
+	nread = TEMP_FAILURE_RETRY(read(fid, up->buf, entry_length));
 #else
 	nread = read(fid, up->buf, sizeof up->buf);
 #endif
@@ -1312,7 +1313,7 @@
 }
 #endif
 
-#if defined(__ANDROID__)
+#if defined(__BIONIC__)
 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
 #include <sys/_system_properties.h> // For __system_property_serial.
 #endif
@@ -1320,13 +1321,13 @@
 static void
 tzset_unlocked(void)
 {
-#if defined(__ANDROID__)
+#if defined(__BIONIC__)
   // The TZ environment variable is meant to override the system-wide setting.
-  const char * name = getenv("TZ");
+  const char* name = getenv("TZ");
 
   // If that's not set, look at the "persist.sys.timezone" system property.
   if (name == NULL) {
-    static const prop_info *pi;
+    static const prop_info* pi;
 
     if (!pi) {
       pi = __system_property_find("persist.sys.timezone");
@@ -1341,12 +1342,21 @@
         s = serial;
       }
       if (ok) {
+        // POSIX and Java disagree about the sign in a timezone string. For POSIX, "GMT+3" means
+        // "3 hours west/behind", but for Java it means "3 hours east/ahead". Since (a) Java is
+        // the one that matches human expectations and (b) this system property is used directly
+        // by Java, we flip the sign here to translate from Java to POSIX. http://b/25463955.
+        if (buf[3] == '-') {
+          buf[3] = '+';
+        } else if (buf[3] == '+') {
+          buf[3] = '-';
+        }
         name = buf;
       }
     }
   }
 
-  // If that's not available (because you're running AOSP on a WiFi-only
+  // If the system property is also not available (because you're running AOSP on a WiFi-only
   // device, say), fall back to GMT.
   if (name == NULL) name = gmt;
 
@@ -2169,6 +2179,10 @@
 time_t
 mktime(struct tm *tmp)
 {
+#if defined(__BIONIC__)
+  int saved_errno = errno;
+#endif
+
   time_t t;
   int err = lock();
   if (err) {
@@ -2178,6 +2192,10 @@
   tzset_unlocked();
   t = mktime_tzname(lclptr, tmp, true);
   unlock();
+
+#if defined(__BIONIC__)
+  errno = (t == -1) ? EOVERFLOW : saved_errno;
+#endif
   return t;
 }
 
@@ -2343,7 +2361,7 @@
     return -1;
   }
   snprintf(path, path_length, "%s/%s", path_prefix, path_suffix);
-  int fd = TEMP_FAILURE_RETRY(open(path, OPEN_MODE));
+  int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC));
   if (fd == -1) {
     free(path);
     return -2; // Distinguish failure to find any data from failure to find a specific id.
diff --git a/libc/tzcode/private.h b/libc/tzcode/private.h
index 1c176e6..941e91b 100644
--- a/libc/tzcode/private.h
+++ b/libc/tzcode/private.h
@@ -22,6 +22,10 @@
 ** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'.
 */
 
+#ifndef HAVE_DECL_ASCTIME_R
+#define HAVE_DECL_ASCTIME_R 1
+#endif
+
 #ifndef HAVE_GETTEXT
 #define HAVE_GETTEXT		0
 #endif /* !defined HAVE_GETTEXT */
@@ -34,6 +38,10 @@
 #define HAVE_LINK		1
 #endif /* !defined HAVE_LINK */
 
+#ifndef HAVE_POSIX_DECLS
+#define HAVE_POSIX_DECLS 1
+#endif
+
 #ifndef HAVE_STRDUP
 #define HAVE_STRDUP 1
 #endif
@@ -106,6 +114,9 @@
 #ifndef ENAMETOOLONG
 # define ENAMETOOLONG EINVAL
 #endif
+#ifndef ENOTSUP
+# define ENOTSUP EINVAL
+#endif
 #ifndef EOVERFLOW
 # define EOVERFLOW EINVAL
 #endif
@@ -379,25 +390,21 @@
 void tzset(void);
 #endif
 
-/*
-** Some time.h implementations don't declare asctime_r.
-** Others might define it as a macro.
-** Fix the former without affecting the latter.
-** Similarly for timezone, daylight, and altzone.
-*/
-
-#ifndef asctime_r
-extern char *	asctime_r(struct tm const *restrict, char *restrict);
+#if !HAVE_DECL_ASCTIME_R && !defined asctime_r
+extern char *asctime_r(struct tm const *restrict, char *restrict);
 #endif
 
-#ifdef USG_COMPAT
-# ifndef timezone
+#if !HAVE_POSIX_DECLS
+# ifdef USG_COMPAT
+#  ifndef timezone
 extern long timezone;
-# endif
-# ifndef daylight
+#  endif
+#  ifndef daylight
 extern int daylight;
+#  endif
 # endif
 #endif
+
 #if defined ALTZONE && !defined altzone
 extern long altzone;
 #endif
diff --git a/libc/tzcode/strftime.c b/libc/tzcode/strftime.c
index 4349cf6..c05f6b5 100644
--- a/libc/tzcode/strftime.c
+++ b/libc/tzcode/strftime.c
@@ -1,34 +1,45 @@
+/* Convert a broken-down time stamp to a string.  */
+
+/* Copyright 1989 The Regents of the University of California.
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+   3. Neither the name of the University nor the names of its contributors
+      may be used to endorse or promote products derived from this software
+      without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+   SUCH DAMAGE.  */
+
 /*
-** Based on the UCB version with the copyright notice and sccsid
-** appearing below.
+** Based on the UCB version with the copyright notice appearing above.
 **
 ** This is ANSIish only when "multibyte character == plain character".
 */
 
 #include "private.h"
 
-/*
-** Copyright (c) 1989 The Regents of the University of California.
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms are permitted
-** provided that the above copyright notice and this paragraph are
-** duplicated in all such forms and that any documentation,
-** advertising materials, and other materials related to such
-** distribution and use acknowledge that the software was developed
-** by the University of California, Berkeley. The name of the
-** University may not be used to endorse or promote products derived
-** from this software without specific prior written permission.
-** THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-** IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-*/
-
 #include "tzfile.h"
 #include "fcntl.h"
 #include "locale.h"
 
-#if __ANDROID__
+#if defined(__BIONIC__)
 
 /* LP32 had a 32-bit time_t, so we need to work around that here. */
 #if defined(__LP64__)
@@ -108,9 +119,10 @@
 static char *   _fmt(const char *, const struct tm *, char *, const char *,
             int *);
 static char *   _yconv(int, int, bool, bool, char *, const char *, int);
-static char *   getformat(int, char *, char *, char *, char *);
 
+#if !HAVE_POSIX_DECLS
 extern char *   tzname[];
+#endif
 
 #ifndef YEAR_2000_NAME
 #define YEAR_2000_NAME  "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS"
@@ -121,7 +133,17 @@
 #define IN_THIS 2
 #define IN_ALL  3
 
-#define FORCE_LOWER_CASE 0x100
+#if HAVE_STRFTIME_L
+size_t
+strftime_l(char *s, size_t maxsize, char const *format, struct tm const *t,
+	   locale_t locale)
+{
+  /* Just call strftime, as only the C locale is supported.  */
+  return strftime(s, maxsize, format, t);
+}
+#endif
+
+#define FORCE_LOWER_CASE 0x100 /* Android extension. */
 
 size_t
 strftime(char *s, size_t maxsize, const char *format, const struct tm *t)
diff --git a/libc/upstream-freebsd/android/include/machine/endian.h b/libc/upstream-freebsd/android/include/machine/endian.h
new file mode 100644
index 0000000..2dc4d83
--- /dev/null
+++ b/libc/upstream-freebsd/android/include/machine/endian.h
@@ -0,0 +1 @@
+#include <endian.h>
diff --git a/libc/upstream-netbsd/android/include/netbsd-compat.h b/libc/upstream-netbsd/android/include/netbsd-compat.h
index bfd0401..45b974a 100644
--- a/libc/upstream-netbsd/android/include/netbsd-compat.h
+++ b/libc/upstream-netbsd/android/include/netbsd-compat.h
@@ -25,6 +25,17 @@
 // that they don't actually test or ship with this.
 #define _DIAGASSERT(e) /* nothing */
 
+/*
+ * The following macro is used to remove const cast-away warnings
+ * from gcc -Wcast-qual; it should be used with caution because it
+ * can hide valid errors; in particular most valid uses are in
+ * situations where the API requires it, not to cast away string
+ * constants. We don't use *intptr_t on purpose here and we are
+ * explicit about unsigned long so that we don't have additional
+ * dependencies.
+ */
+#define __UNCONST(a)    ((void *)(unsigned long)(const void *)(a))
+
 // TODO: we don't yet have thread-safe environment variables.
 #define __readlockenv() 0
 #define __unlockenv() 0
diff --git a/libc/upstream-netbsd/lib/libc/gen/ftw.c b/libc/upstream-netbsd/lib/libc/gen/ftw.c
deleted file mode 100644
index a7f6bbd..0000000
--- a/libc/upstream-netbsd/lib/libc/gen/ftw.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* $NetBSD: ftw.c,v 1.1 2005/12/30 23:07:32 agc Exp $ */
-
-/*	From OpenBSD: ftw.c,v 1.2 2003/07/21 21:15:32 millert Exp 	*/
-
-/*
- * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Sponsored in part by the Defense Advanced Research Projects
- * Agency (DARPA) and Air Force Research Laboratory, Air Force
- * Materiel Command, USAF, under agreement number F39502-99-1-0512.
- */
-#include <sys/cdefs.h>
-
-#ifndef lint
-__RCSID("$NetBSD: ftw.c,v 1.1 2005/12/30 23:07:32 agc Exp $");
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fts.h>
-#include <ftw.h>
-#include <limits.h>
-
-int
-ftw(const char *path, int (*fn)(const char *, const struct stat *, int),
-    int nfds)
-{
-	/* LINTED */
-	char * const paths[2] = { __UNCONST(path), NULL };
-	FTSENT *cur;
-	FTS *ftsp;
-	int fnflag, error, sverrno;
-
-	/* XXX - nfds is currently unused */
-	if (nfds < 1 || nfds > OPEN_MAX) {
-		errno = EINVAL;
-		return (-1);
-	}
-
-	ftsp = fts_open(paths, FTS_COMFOLLOW | FTS_NOCHDIR, NULL);
-	if (ftsp == NULL)
-		return (-1);
-	error = 0;
-	while ((cur = fts_read(ftsp)) != NULL) {
-		switch (cur->fts_info) {
-		case FTS_D:
-			fnflag = FTW_D;
-			break;
-		case FTS_DNR:
-			fnflag = FTW_DNR;
-			break;
-		case FTS_DP:
-			/* we only visit in preorder */
-			continue;
-		case FTS_F:
-		case FTS_DEFAULT:
-			fnflag = FTW_F;
-			break;
-		case FTS_NS:
-		case FTS_NSOK:
-		case FTS_SLNONE:
-			fnflag = FTW_NS;
-			break;
-		case FTS_SL:
-			fnflag = FTW_SL;
-			break;
-		case FTS_DC:
-			errno = ELOOP;
-			/* FALLTHROUGH */
-		default:
-			error = -1;
-			goto done;
-		}
-		error = fn(cur->fts_path, cur->fts_statp, fnflag);
-		if (error != 0)
-			break;
-	}
-done:
-	sverrno = errno;
-	if (fts_close(ftsp) != 0 && error == 0)
-		error = -1;
-	else
-		errno = sverrno;
-	return (error);
-}
diff --git a/libc/upstream-netbsd/lib/libc/gen/nftw.c b/libc/upstream-netbsd/lib/libc/gen/nftw.c
deleted file mode 100644
index 0e51342..0000000
--- a/libc/upstream-netbsd/lib/libc/gen/nftw.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/* $NetBSD */
-
-/*	From OpenBSD: nftw.c,v 1.2 2003/07/21 21:15:32 millert Exp 	*/
-
-/*
- * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Sponsored in part by the Defense Advanced Research Projects
- * Agency (DARPA) and Air Force Research Laboratory, Air Force
- * Materiel Command, USAF, under agreement number F39502-99-1-0512.
- */
-
-#include <sys/cdefs.h>
-
-#ifndef lint
-__RCSID("$NetBSD: nftw.c,v 1.1 2005/12/30 23:07:32 agc Exp $");
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fts.h>
-#include <ftw.h>
-#include <limits.h>
-
-int
-nftw(const char *path, int (*fn)(const char *, const struct stat *, int,
-     struct FTW *), int nfds, int ftwflags)
-{
-	/* LINTED */
-	char * const paths[2] = { __UNCONST(path), NULL };
-	struct FTW f;
-	FTSENT *cur;
-	FTS *ftsp;
-	int ftsflags, fnflag, error, postorder, sverrno;
-
-	/* XXX - nfds is currently unused */
-	if (nfds < 1 || nfds > OPEN_MAX) {
-		errno = EINVAL;
-		return (-1);
-	}
-
-	ftsflags = FTS_COMFOLLOW;
-	if (!(ftwflags & FTW_CHDIR))
-		ftsflags |= FTS_NOCHDIR;
-	if (ftwflags & FTW_MOUNT)
-		ftsflags |= FTS_XDEV;
-	if (ftwflags & FTW_PHYS)
-		ftsflags |= FTS_PHYSICAL;
-	postorder = (ftwflags & FTW_DEPTH) != 0;
-	ftsp = fts_open(paths, ftsflags, NULL);
-	if (ftsp == NULL)
-		return (-1);
-	error = 0;
-	while ((cur = fts_read(ftsp)) != NULL) {
-		switch (cur->fts_info) {
-		case FTS_D:
-			if (postorder)
-				continue;
-			fnflag = FTW_D;
-			break;
-		case FTS_DNR:
-			fnflag = FTW_DNR;
-			break;
-		case FTS_DP:
-			if (!postorder)
-				continue;
-			fnflag = FTW_DP;
-			break;
-		case FTS_F:
-		case FTS_DEFAULT:
-			fnflag = FTW_F;
-			break;
-		case FTS_NS:
-		case FTS_NSOK:
-			fnflag = FTW_NS;
-			break;
-		case FTS_SL:
-			fnflag = FTW_SL;
-			break;
-		case FTS_SLNONE:
-			fnflag = FTW_SLN;
-			break;
-		case FTS_DC:
-			errno = ELOOP;
-			/* FALLTHROUGH */
-		default:
-			error = -1;
-			goto done;
-		}
-		f.base = cur->fts_pathlen - cur->fts_namelen;
-		f.level = cur->fts_level;
-		error = fn(cur->fts_path, cur->fts_statp, fnflag, &f);
-		if (error != 0)
-			break;
-	}
-done:
-	sverrno = errno;
-	(void) fts_close(ftsp);
-	errno = sverrno;
-	return (error);
-}
diff --git a/libc/upstream-openbsd/android/include/arc4random.h b/libc/upstream-openbsd/android/include/arc4random.h
index 96d9c9a..0d70c81 100644
--- a/libc/upstream-openbsd/android/include/arc4random.h
+++ b/libc/upstream-openbsd/android/include/arc4random.h
@@ -28,6 +28,7 @@
 #include <signal.h>
 
 #include "private/bionic_prctl.h"
+#include "private/libc_logging.h"
 
 // Android gets these from "thread_private.h".
 #include "thread_private.h"
@@ -46,16 +47,10 @@
 static inline void
 _getentropy_fail(void)
 {
-	raise(SIGKILL);
+	__libc_fatal("getentropy failed");
 }
 
-static volatile sig_atomic_t _rs_forked;
-
-static inline void
-_rs_forkhandler(void)
-{
-	_rs_forked = 1;
-}
+volatile sig_atomic_t _rs_forked;
 
 static inline void
 _rs_forkdetect(void)
@@ -74,22 +69,21 @@
 static inline int
 _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
 {
-	if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
+	// OpenBSD's arc4random_linux.h allocates two separate mappings, but for
+	// themselves they just allocate both structs into one mapping like this.
+	struct {
+		struct _rs rs;
+		struct _rsx rsx;
+	} *p;
+
+	if ((p = mmap(NULL, sizeof(*p), PROT_READ|PROT_WRITE,
 	    MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
 		return (-1);
 
-	prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, *rsp, sizeof(**rsp),
-	    "arc4random _rs structure");
+	prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, p, sizeof(*p), "arc4random data");
 
-	if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
-	    MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
-		munmap(*rsxp, sizeof(**rsxp));
-		return (-1);
-	}
+	*rsp = &p->rs;
+	*rsxp = &p->rsx;
 
-	prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, *rsxp, sizeof(**rsxp),
-	    "arc4random _rsx structure");
-
-	_ARC4_ATFORK(_rs_forkhandler);
 	return (0);
 }
diff --git a/libc/upstream-openbsd/android/include/arith.h b/libc/upstream-openbsd/android/include/arith.h
index b262e4f..cb116d4 100644
--- a/libc/upstream-openbsd/android/include/arith.h
+++ b/libc/upstream-openbsd/android/include/arith.h
@@ -16,7 +16,7 @@
 
 #define IEEE_8087
 
-#if __LP64__
+#if defined(__LP64__)
 #define Long int
 #endif
 
diff --git a/libc/upstream-openbsd/android/include/gd_qnan.h b/libc/upstream-openbsd/android/include/gd_qnan.h
index e8e907b..bcdff28 100644
--- a/libc/upstream-openbsd/android/include/gd_qnan.h
+++ b/libc/upstream-openbsd/android/include/gd_qnan.h
@@ -14,35 +14,20 @@
  * limitations under the License.
  */
 
-#if __arm__
+//
+// The values in this file came from reading the bits of <math.h>'s NAN back from a union.
+//
 
-#define f_QNAN  0xffffffff
-
-#define d_QNAN0 0xffffffff
-#define d_QNAN1 0xffffffff
-
-#elif __mips__
-
-#define f_QNAN  0x7fbfffff
-
-#define d_QNAN0 0x7ff7ffff
-#define d_QNAN1 0xffffffff
-
-#else
-
-#define f_QNAN  0xffc00000
+#define f_QNAN 0x7fc00000
 
 #define d_QNAN0 0x00000000
-#define d_QNAN1 0xfff80000
+#define d_QNAN1 0x7ff80000
 
-#endif
-
-/* long double. */
-#if __LP64__
-#define ld_QNAN0 0x7fff8000
+#if defined(__LP64__)
+#define ld_QNAN0 0x00000000
 #define ld_QNAN1 0x00000000
 #define ld_QNAN2 0x00000000
-#define ld_QNAN3 0x00000000
+#define ld_QNAN3 0x7fff8000
 #else
-/* sizeof(long double) == sizeof(double), so we shouldn't be trying to use these constants. */
+// LP32 sizeof(long double) == sizeof(double), so LP32 shouldn't try to use these constants.
 #endif
diff --git a/libc/upstream-openbsd/android/include/machine/ieee.h b/libc/upstream-openbsd/android/include/machine/ieee.h
new file mode 100644
index 0000000..dac332a
--- /dev/null
+++ b/libc/upstream-openbsd/android/include/machine/ieee.h
@@ -0,0 +1 @@
+#include "private/bionic_ieee.h"
diff --git a/libc/upstream-openbsd/lib/libc/gen/exec.c b/libc/upstream-openbsd/lib/libc/gen/exec.c
deleted file mode 100644
index 1e2f7d9..0000000
--- a/libc/upstream-openbsd/lib/libc/gen/exec.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*	$OpenBSD: exec.c,v 1.21 2013/09/30 12:02:33 millert Exp $ */
-/*-
- * Copyright (c) 1991, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#include <errno.h>
-#include <limits.h>
-#include <paths.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-extern char **environ;
-
-int
-execl(const char *name, const char *arg, ...)
-{
-	va_list ap;
-	char **argv;
-	int n;
-
-	va_start(ap, arg);
-	n = 1;
-	while (va_arg(ap, char *) != NULL)
-		n++;
-	va_end(ap);
-	argv = alloca((n + 1) * sizeof(*argv));
-	if (argv == NULL) {
-		errno = ENOMEM;
-		return (-1);
-	}
-	va_start(ap, arg);
-	n = 1;
-	argv[0] = (char *)arg;
-	while ((argv[n] = va_arg(ap, char *)) != NULL)
-		n++;
-	va_end(ap);
-	return (execve(name, argv, environ));
-}
-
-int
-execle(const char *name, const char *arg, ...)
-{
-	va_list ap;
-	char **argv, **envp;
-	int n;
-
-	va_start(ap, arg);
-	n = 1;
-	while (va_arg(ap, char *) != NULL)
-		n++;
-	va_end(ap);
-	argv = alloca((n + 1) * sizeof(*argv));
-	if (argv == NULL) {
-		errno = ENOMEM;
-		return (-1);
-	}
-	va_start(ap, arg);
-	n = 1;
-	argv[0] = (char *)arg;
-	while ((argv[n] = va_arg(ap, char *)) != NULL)
-		n++;
-	envp = va_arg(ap, char **);
-	va_end(ap);
-	return (execve(name, argv, envp));
-}
-
-int
-execlp(const char *name, const char *arg, ...)
-{
-	va_list ap;
-	char **argv;
-	int n;
-
-	va_start(ap, arg);
-	n = 1;
-	while (va_arg(ap, char *) != NULL)
-		n++;
-	va_end(ap);
-	argv = alloca((n + 1) * sizeof(*argv));
-	if (argv == NULL) {
-		errno = ENOMEM;
-		return (-1);
-	}
-	va_start(ap, arg);
-	n = 1;
-	argv[0] = (char *)arg;
-	while ((argv[n] = va_arg(ap, char *)) != NULL)
-		n++;
-	va_end(ap);
-	return (execvp(name, argv));
-}
-
-int
-execv(const char *name, char *const *argv)
-{
-	(void)execve(name, argv, environ);
-	return (-1);
-}
-
-int
-execvpe(const char *name, char *const *argv, char *const *envp)
-{
-	char **memp;
-	int cnt;
-	size_t lp, ln, len;
-	char *p;
-	int eacces = 0;
-	char *bp, *cur, *path, buf[PATH_MAX];
-
-	/*
-	 * Do not allow null name
-	 */
-	if (name == NULL || *name == '\0') {
-		errno = ENOENT;
-		return (-1);
- 	}
-
-	/* If it's an absolute or relative path name, it's easy. */
-	if (strchr(name, '/')) {
-		bp = (char *)name;
-		cur = path = NULL;
-		goto retry;
-	}
-	bp = buf;
-
-	/* Get the path we're searching. */
-	if (!(path = getenv("PATH")))
-		path = _PATH_DEFPATH;
-	len = strlen(path) + 1;
-	cur = alloca(len);
-	if (cur == NULL) {
-		errno = ENOMEM;
-		return (-1);
-	}
-	strlcpy(cur, path, len);
-	path = cur;
-	while ((p = strsep(&cur, ":"))) {
-		/*
-		 * It's a SHELL path -- double, leading and trailing colons
-		 * mean the current directory.
-		 */
-		if (!*p) {
-			p = ".";
-			lp = 1;
-		} else
-			lp = strlen(p);
-		ln = strlen(name);
-
-		/*
-		 * If the path is too long complain.  This is a possible
-		 * security issue; given a way to make the path too long
-		 * the user may execute the wrong program.
-		 */
-		if (lp + ln + 2 > sizeof(buf)) {
-			struct iovec iov[3];
-
-			iov[0].iov_base = "execvp: ";
-			iov[0].iov_len = 8;
-			iov[1].iov_base = p;
-			iov[1].iov_len = lp;
-			iov[2].iov_base = ": path too long\n";
-			iov[2].iov_len = 16;
-			(void)writev(STDERR_FILENO, iov, 3);
-			continue;
-		}
-		bcopy(p, buf, lp);
-		buf[lp] = '/';
-		bcopy(name, buf + lp + 1, ln);
-		buf[lp + ln + 1] = '\0';
-
-retry:		(void)execve(bp, argv, envp);
-		switch(errno) {
-		case E2BIG:
-			goto done;
-		case EISDIR:
-		case ELOOP:
-		case ENAMETOOLONG:
-		case ENOENT:
-			break;
-		case ENOEXEC:
-			for (cnt = 0; argv[cnt]; ++cnt)
-				;
-			memp = alloca((cnt + 2) * sizeof(char *));
-			if (memp == NULL)
-				goto done;
-			memp[0] = "sh";
-			memp[1] = bp;
-			bcopy(argv + 1, memp + 2, cnt * sizeof(char *));
-			(void)execve(_PATH_BSHELL, memp, envp);
-			goto done;
-		case ENOMEM:
-			goto done;
-		case ENOTDIR:
-			break;
-		case ETXTBSY:
-			/*
-			 * We used to retry here, but sh(1) doesn't.
-			 */
-			goto done;
-		case EACCES:
-			eacces = 1;
-			break;
-		default:
-			goto done;
-		}
-	}
-	if (eacces)
-		errno = EACCES;
-	else if (!errno)
-		errno = ENOENT;
-done:
-	return (-1);
-}
-
-int
-execvp(const char *name, char *const *argv)
-{
-    return execvpe(name, argv, environ);
-}
-
diff --git a/libc/upstream-openbsd/lib/libc/locale/_wcstod.h b/libc/upstream-openbsd/lib/libc/locale/_wcstod.h
deleted file mode 100644
index ae993ad..0000000
--- a/libc/upstream-openbsd/lib/libc/locale/_wcstod.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*	$OpenBSD: _wcstod.h,v 1.2 2013/06/02 15:22:20 matthew Exp $	*/
-/* $NetBSD: wcstod.c,v 1.4 2001/10/28 12:08:43 yamt Exp $ */
-
-/*-
- * Copyright (c)1999, 2000, 2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	$Citrus: xpg4dl/FreeBSD/lib/libc/locale/wcstod.c,v 1.2 2001/09/27 16:23:57 yamt Exp $
- */
-
-/*
- * function template for wcstof, wcstod and wcstold.
- *
- * parameters:
- *	FUNCNAME : function name
- *      float_type : return type
- *      STRTOD_FUNC : conversion function
- */
-
-float_type
-FUNCNAME(const wchar_t *nptr, wchar_t **endptr)
-{
-	const wchar_t *src;
-	size_t size;
-	const wchar_t *start;
-	const wchar_t *aftersign;
-
-	/*
-	 * check length of string and call strtod
-	 */
-	src = nptr;
-
-	/* skip space first */
-	while (iswspace(*src)) {
-		src++;
-	}
-
-	/* get length of string */
-	start = src;
-	if (*src && wcschr(L"+-", *src))
-		src++;
-	aftersign = src;
-	if (wcsncasecmp(src, L"inf", 3) == 0) {
-		src += 3;
-		if (wcsncasecmp(src, L"inity", 5) == 0)
-			src += 5;
-		goto match;
-	}
-	if (wcsncasecmp(src, L"nan", 3) == 0) {
-		src += 3;
-		if (*src == L'(') {
-			size = 1;
-			while (src[size] != L'\0' && src[size] != L')')
-				size++;
-			if (src[size] == L')')
-				src += size + 1;
-		}
-		goto match;
-	}
-	size = wcsspn(src, L"0123456789");
-	src += size;
-	if (*src == L'.') {/* XXX use localeconv */
-		src++;
-		size = wcsspn(src, L"0123456789");
-		src += size;
-	}
-	if (*src && wcschr(L"Ee", *src)) {
-		src++;
-		if (*src && wcschr(L"+-", *src))
-			src++;
-		size = wcsspn(src, L"0123456789");
-		src += size;
-	}
-match:
-	size = src - start;
-
-	/*
-	 * convert to a char-string and pass it to strtod.
-	 */
-	if (src > aftersign) {
-		mbstate_t st;
-		char *buf;
-		char *end;
-		const wchar_t *s;
-		size_t size_converted;
-		float_type result;
-		size_t bufsize;
-
-		s = start;
-		memset(&st, 0, sizeof(st));
-		bufsize = wcsnrtombs(NULL, &s, size, 0, &st);
-
-		buf = malloc(bufsize + 1);
-		if (!buf) {
-			errno = ENOMEM; /* XXX */
-			goto fail;
-		}
-
-		s = start;
-		memset(&st, 0, sizeof(st));
-		size_converted = wcsnrtombs(buf, &s, size, bufsize, &st);
-		if (size_converted != bufsize) {
-			/* XXX should not happen */
-			free(buf);
-			errno = EILSEQ;
-			goto fail;
-		}
-
-		buf[bufsize] = 0;
-		result = STRTOD_FUNC(buf, &end);
-
-		if (endptr) {
-			const char *s = buf;
-			memset(&st, 0, sizeof(st));
-			size = mbsnrtowcs(NULL, &s, end - buf, 0, &st);
-
-			/* LINTED bad interface */
-			*endptr = (wchar_t*)start + size;
-		}
-
-		free(buf);
-
-		return result;
-	}
-
-fail:
-	if (endptr)
-		/* LINTED bad interface */
-		*endptr = (wchar_t*)nptr;
-
-	return 0;
-}
diff --git a/libc/upstream-openbsd/lib/libc/locale/wcstod.c b/libc/upstream-openbsd/lib/libc/locale/wcstod.c
deleted file mode 100644
index 957d0a1..0000000
--- a/libc/upstream-openbsd/lib/libc/locale/wcstod.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*	$OpenBSD: wcstod.c,v 1.3 2009/01/13 18:18:31 kettenis Exp $	*/
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-#include <wctype.h>
-
-#define FUNCNAME	wcstod
-typedef double		float_type;
-#define STRTOD_FUNC	strtod
-
-#include "_wcstod.h"
diff --git a/libc/upstream-openbsd/lib/libc/locale/wcstof.c b/libc/upstream-openbsd/lib/libc/locale/wcstof.c
deleted file mode 100644
index 40d76c7..0000000
--- a/libc/upstream-openbsd/lib/libc/locale/wcstof.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*	$OpenBSD: wcstof.c,v 1.1 2009/01/13 18:18:31 kettenis Exp $	*/
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-#include <wctype.h>
-
-#define FUNCNAME	wcstof
-typedef float		float_type;
-#define STRTOD_FUNC	strtof
-
-#include "_wcstod.h"
diff --git a/libc/upstream-openbsd/lib/libc/locale/wcstold.c b/libc/upstream-openbsd/lib/libc/locale/wcstold.c
deleted file mode 100644
index a642542..0000000
--- a/libc/upstream-openbsd/lib/libc/locale/wcstold.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*	$OpenBSD: wcstold.c,v 1.1 2009/01/13 18:18:31 kettenis Exp $	*/
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-#include <wctype.h>
-
-#define FUNCNAME	wcstold
-typedef long double	float_type;
-#define STRTOD_FUNC	strtold
-
-#include "_wcstod.h"
diff --git a/libc/dns/net/base64.c b/libc/upstream-openbsd/lib/libc/net/base64.c
similarity index 82%
rename from libc/dns/net/base64.c
rename to libc/upstream-openbsd/lib/libc/net/base64.c
index 1886986..e90696d 100644
--- a/libc/dns/net/base64.c
+++ b/libc/upstream-openbsd/lib/libc/net/base64.c
@@ -1,4 +1,4 @@
-/*	$NetBSD: base64.c,v 1.8 2002/11/11 01:15:17 thorpej Exp $	*/
+/*	$OpenBSD: base64.c,v 1.8 2015/01/16 16:48:51 deraadt Exp $	*/
 
 /*
  * Copyright (c) 1996 by Internet Software Consortium.
@@ -42,25 +42,14 @@
  * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
  */
 
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: base64.c,v 1.8 2002/11/11 01:15:17 thorpej Exp $");
-#endif /* LIBC_SCCS and not lint */
-
 #include <sys/types.h>
-#include <sys/param.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
 
-#include <assert.h>
 #include <ctype.h>
-#ifdef ANDROID_CHANGES
-#include "resolv_private.h"
-#else
 #include <resolv.h>
-#endif
 #include <stdio.h>
 
 #include <stdlib.h>
@@ -118,9 +107,9 @@
    end of the data is performed using the '=' character.
 
    Since all base64 input is an integral number of octets, only the
-         -------------------------------------------------
+         -------------------------------------------------                       
    following cases can arise:
-
+   
        (1) the final quantum of encoding input is an integral
            multiple of 24 bits; here, the final unit of encoded
 	   output will be an integral multiple of 4 characters
@@ -141,12 +130,9 @@
 	size_t targsize;
 {
 	size_t datalength = 0;
-	u_char input[3] = { 0, 0, 0 };  /* make compiler happy */
+	u_char input[3];
 	u_char output[4];
-	size_t i;
-
-	assert(src != NULL);
-	assert(target != NULL);
+	int i;
 
 	while (2 < srclength) {
 		input[0] = *src++;
@@ -154,16 +140,10 @@
 		input[2] = *src++;
 		srclength -= 3;
 
-		output[0] = (u_int32_t)input[0] >> 2;
-		output[1] = ((u_int32_t)(input[0] & 0x03) << 4) +
-		    ((u_int32_t)input[1] >> 4);
-		output[2] = ((u_int32_t)(input[1] & 0x0f) << 2) +
-		    ((u_int32_t)input[2] >> 6);
+		output[0] = input[0] >> 2;
+		output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+		output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
 		output[3] = input[2] & 0x3f;
-		assert(output[0] < 64);
-		assert(output[1] < 64);
-		assert(output[2] < 64);
-		assert(output[3] < 64);
 
 		if (datalength + 4 > targsize)
 			return (-1);
@@ -172,22 +152,17 @@
 		target[datalength++] = Base64[output[2]];
 		target[datalength++] = Base64[output[3]];
 	}
-
+    
 	/* Now we worry about padding. */
 	if (0 != srclength) {
 		/* Get what's left. */
 		input[0] = input[1] = input[2] = '\0';
 		for (i = 0; i < srclength; i++)
 			input[i] = *src++;
-
-		output[0] = (u_int32_t)input[0] >> 2;
-		output[1] = ((u_int32_t)(input[0] & 0x03) << 4) +
-		    ((u_int32_t)input[1] >> 4);
-		output[2] = ((u_int32_t)(input[1] & 0x0f) << 2) +
-		    ((u_int32_t)input[2] >> 6);
-		assert(output[0] < 64);
-		assert(output[1] < 64);
-		assert(output[2] < 64);
+	
+		output[0] = input[0] >> 2;
+		output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+		output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
 
 		if (datalength + 4 > targsize)
 			return (-1);
@@ -217,17 +192,14 @@
 	u_char *target;
 	size_t targsize;
 {
-	size_t tarindex;
-	int state, ch;
+	int tarindex, state, ch;
+	u_char nextbyte;
 	char *pos;
 
-	assert(src != NULL);
-	assert(target != NULL);
-
 	state = 0;
 	tarindex = 0;
 
-	while ((ch = (u_char) *src++) != '\0') {
+	while ((ch = (unsigned char)*src++) != '\0') {
 		if (isspace(ch))	/* Skip whitespace anywhere. */
 			continue;
 
@@ -249,24 +221,28 @@
 			break;
 		case 1:
 			if (target) {
-				if (tarindex + 1 >= targsize)
+				if (tarindex >= targsize)
 					return (-1);
-				target[tarindex] |=
-				    (u_int32_t)(pos - Base64) >> 4;
-				target[tarindex+1]  = ((pos - Base64) & 0x0f)
-							<< 4 ;
+				target[tarindex]   |=  (pos - Base64) >> 4;
+				nextbyte = ((pos - Base64) & 0x0f) << 4;
+				if (tarindex + 1 < targsize)
+					target[tarindex+1] = nextbyte;
+				else if (nextbyte)
+					return (-1);
 			}
 			tarindex++;
 			state = 2;
 			break;
 		case 2:
 			if (target) {
-				if (tarindex + 1 >= targsize)
+				if (tarindex >= targsize)
 					return (-1);
-				target[tarindex] |=
-					(u_int32_t)(pos - Base64) >> 2;
-				target[tarindex+1] = ((pos - Base64) & 0x03)
-							<< 6;
+				target[tarindex]   |=  (pos - Base64) >> 2;
+				nextbyte = ((pos - Base64) & 0x03) << 6;
+				if (tarindex + 1 < targsize)
+					target[tarindex+1] = nextbyte;
+				else if (nextbyte)
+					return (-1);
 			}
 			tarindex++;
 			state = 3;
@@ -280,8 +256,6 @@
 			tarindex++;
 			state = 0;
 			break;
-		default:
-			abort();
 		}
 	}
 
@@ -290,8 +264,8 @@
 	 * on a byte boundary, and/or with erroneous trailing characters.
 	 */
 
-	if (ch == Pad64) {		/* We got a pad char. */
-		ch = *src++;		/* Skip it, get next. */
+	if (ch == Pad64) {			/* We got a pad char. */
+		ch = (unsigned char)*src++;	/* Skip it, get next. */
 		switch (state) {
 		case 0:		/* Invalid = in first position */
 		case 1:		/* Invalid = in second position */
@@ -299,13 +273,13 @@
 
 		case 2:		/* Valid, means one byte of info */
 			/* Skip any number of spaces. */
-			for (; ch != '\0'; ch = (u_char) *src++)
+			for (; ch != '\0'; ch = (unsigned char)*src++)
 				if (!isspace(ch))
 					break;
 			/* Make sure there is another trailing = sign. */
 			if (ch != Pad64)
 				return (-1);
-			ch = *src++;		/* Skip the = */
+			ch = (unsigned char)*src++;		/* Skip the = */
 			/* Fall through to "single trailing =" case. */
 			/* FALLTHROUGH */
 
@@ -314,7 +288,7 @@
 			 * We know this char is an =.  Is there anything but
 			 * whitespace after it?
 			 */
-			for (; ch != '\0'; ch = (u_char) *src++)
+			for (; ch != '\0'; ch = (unsigned char)*src++)
 				if (!isspace(ch))
 					return (-1);
 
@@ -324,7 +298,8 @@
 			 * zeros.  If we don't check them, they become a
 			 * subliminal channel.
 			 */
-			if (target && target[tarindex] != 0)
+			if (target && tarindex < targsize &&
+			    target[tarindex] != 0)
 				return (-1);
 		}
 	} else {
diff --git a/libc/upstream-openbsd/lib/libc/stdio/asprintf.c b/libc/upstream-openbsd/lib/libc/stdio/asprintf.c
deleted file mode 100644
index 4823677..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/asprintf.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*	$OpenBSD: asprintf.c,v 1.22 2015/12/28 22:08:18 mmcc Exp $	*/
-
-/*
- * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-#include "local.h"
-
-int
-asprintf(char **str, const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-	FILE f;
-	struct __sfileext fext;
-	unsigned char *_base;
-
-	_FILEEXT_SETUP(&f, &fext);
-	f._file = -1;
-	f._flags = __SWR | __SSTR | __SALC;
-	f._bf._base = f._p = malloc(128);
-	if (f._bf._base == NULL)
-		goto err;
-	f._bf._size = f._w = 127;		/* Leave room for the NUL */
-	va_start(ap, fmt);
-	ret = __vfprintf(&f, fmt, ap);
-	va_end(ap);
-	if (ret == -1)
-		goto err;
-	*f._p = '\0';
-	_base = realloc(f._bf._base, ret + 1);
-	if (_base == NULL)
-		goto err;
-	*str = (char *)_base;
-	return (ret);
-
-err:
-	free(f._bf._base);
-	f._bf._base = NULL;
-	*str = NULL;
-	errno = ENOMEM;
-	return (-1);
-}
-DEF_WEAK(asprintf);
diff --git a/libc/upstream-openbsd/lib/libc/stdio/clrerr.c b/libc/upstream-openbsd/lib/libc/stdio/clrerr.c
deleted file mode 100644
index ac08c72..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/clrerr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*	$OpenBSD: clrerr.c,v 1.9 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-#undef	clearerr
-
-void
-clearerr(FILE *fp)
-{
-	FLOCKFILE(fp);
-	__sclearerr(fp);
-	FUNLOCKFILE(fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/dprintf.c b/libc/upstream-openbsd/lib/libc/stdio/dprintf.c
deleted file mode 100644
index dbf7d34..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/dprintf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$OpenBSD: dprintf.c,v 1.1 2013/01/30 00:08:13 brad Exp $	*/
-/*	$FreeBSD: src/lib/libc/stdio/dprintf.c,v 1.2 2012/11/17 01:49:39 svnexp Exp $	*/
-
-/*-
- * Copyright (c) 2009 David Schultz <das@FreeBSD.org>
- * All rights reserved.
- *
- * Copyright (c) 2011 The FreeBSD Foundation
- * All rights reserved.
- * Portions of this software were developed by David Chisnall
- * under sponsorship from the FreeBSD Foundation.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-int
-dprintf(int fd, const char * __restrict fmt, ...)
-{
-	va_list ap;
-	int ret;
-
-	va_start(ap, fmt);
-	ret = vdprintf(fd, fmt, ap);
-	va_end(ap);
-	return ret;
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/feof.c b/libc/upstream-openbsd/lib/libc/stdio/feof.c
deleted file mode 100644
index 0036bab..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/feof.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*	$OpenBSD: feof.c,v 1.8 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-
-/*
- * A subroutine version of the macro feof.
- */
-#undef feof
-
-int
-feof(FILE *fp)
-{
-	int	ret;
-
-	FLOCKFILE(fp);
-	ret = __sfeof(fp);
-	FUNLOCKFILE(fp);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/ferror.c b/libc/upstream-openbsd/lib/libc/stdio/ferror.c
deleted file mode 100644
index 00b9c8b..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/ferror.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*	$OpenBSD: ferror.c,v 1.8 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-
-/*
- * A subroutine version of the macro ferror.
- */
-#undef ferror
-
-int
-ferror(FILE *fp)
-{
-	int     ret;
-
-	FLOCKFILE(fp);
-	ret = __sferror(fp);
-	FUNLOCKFILE(fp);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fgetc.c b/libc/upstream-openbsd/lib/libc/stdio/fgetc.c
deleted file mode 100644
index c5d7dde..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fgetc.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*	$OpenBSD: fgetc.c,v 1.8 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-int
-fgetc(FILE *fp)
-{
-	return (getc(fp));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fprintf.c b/libc/upstream-openbsd/lib/libc/stdio/fprintf.c
deleted file mode 100644
index a391142..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fprintf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$OpenBSD: fprintf.c,v 1.7 2011/05/30 18:48:33 martynas Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-/* PRINTFLIKE2 */
-int
-fprintf(FILE *fp, const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	va_start(ap, fmt);
-	ret = vfprintf(fp, fmt, ap);
-	va_end(ap);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fputc.c b/libc/upstream-openbsd/lib/libc/stdio/fputc.c
deleted file mode 100644
index 98e3960..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fputc.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*	$OpenBSD: fputc.c,v 1.10 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <errno.h>
-
-int
-fputc(int c, FILE *fp)
-{
-	return (putc(c, fp));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fscanf.c b/libc/upstream-openbsd/lib/libc/stdio/fscanf.c
deleted file mode 100644
index 5fd10d4..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fscanf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$OpenBSD: fscanf.c,v 1.10 2011/05/30 18:48:33 martynas Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-/* SCANFLIKE2 */
-int
-fscanf(FILE *fp, const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	va_start(ap, fmt);
-	ret = vfscanf(fp, fmt, ap);
-	va_end(ap);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fwprintf.c b/libc/upstream-openbsd/lib/libc/stdio/fwprintf.c
deleted file mode 100644
index 4474e8b..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fwprintf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$OpenBSD: fwprintf.c,v 1.3 2011/04/28 17:38:46 stsp Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <wchar.h>
-
-int
-fwprintf(FILE * __restrict fp, const wchar_t * __restrict fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	va_start(ap, fmt);
-	ret = vfwprintf(fp, fmt, ap);
-	va_end(ap);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fwscanf.c b/libc/upstream-openbsd/lib/libc/stdio/fwscanf.c
deleted file mode 100644
index b716cbf..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fwscanf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $OpenBSD: fwscanf.c,v 1.2 2012/12/05 23:20:01 deraadt Exp $ */
-
-/*-
- * Copyright (c) 2002 Tim J. Robbins
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-fwscanf(FILE * __restrict fp, const wchar_t * __restrict fmt, ...)
-{
-	va_list ap;
-	int r;
-
-	va_start(ap, fmt);
-	r = vfwscanf(fp, fmt, ap);
-	va_end(ap);
-
-	return (r);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getc.c b/libc/upstream-openbsd/lib/libc/stdio/getc.c
deleted file mode 100644
index 6879cbb..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getc.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*	$OpenBSD: getc.c,v 1.9 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-
-/*
- * A subroutine version of the macro getc_unlocked.
- */
-#undef getc_unlocked
-
-int
-getc_unlocked(FILE *fp)
-{
-	return (__sgetc(fp));
-}
-
-/*
- * A subroutine version of the macro getc.
- */
-#undef getc
-
-int
-getc(FILE *fp)
-{
-	int c;
-
-	FLOCKFILE(fp);
-	c = __sgetc(fp);
-	FUNLOCKFILE(fp);
-	return (c);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getchar.c b/libc/upstream-openbsd/lib/libc/stdio/getchar.c
deleted file mode 100644
index 550817d..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getchar.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*	$OpenBSD: getchar.c,v 1.7 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-/*
- * A subroutine version of the macro getchar_unlocked.
- */
-#undef getchar_unlocked
-
-int
-getchar_unlocked(void)
-{
-	return (getc_unlocked(stdin));
-}
-
-
-/*
- * A subroutine version of the macro getchar.
- */
-
-#undef getchar
-
-int
-getchar(void)
-{
-	return (getc(stdin));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getline.c b/libc/upstream-openbsd/lib/libc/stdio/getline.c
deleted file mode 100644
index 55ad396..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getline.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*	$OpenBSD: getline.c,v 1.1 2012/03/21 23:44:35 fgsch Exp $	*/
-/* $NetBSD: getline.c,v 1.3 2009/12/02 08:46:33 roy Exp $ */
-
-/*
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Roy Marples.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-ssize_t
-getline(char **__restrict buf, size_t *__restrict buflen, FILE *__restrict fp)
-{
-	return getdelim(buf, buflen, '\n', fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getwc.c b/libc/upstream-openbsd/lib/libc/stdio/getwc.c
deleted file mode 100644
index e9bbb7c..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getwc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*	$OpenBSD: getwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $	*/
-/* $NetBSD: getwc.c,v 1.2 2003/01/18 11:29:55 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro getwc.
- */
-#undef getwc
-
-wint_t
-getwc(FILE *fp)
-{
-
-	return fgetwc(fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getwchar.c b/libc/upstream-openbsd/lib/libc/stdio/getwchar.c
deleted file mode 100644
index 2a112ed..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getwchar.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*	$OpenBSD: getwchar.c,v 1.1 2005/06/17 20:40:32 espie Exp $	*/
-/* $NetBSD: getwchar.c,v 1.2 2003/01/18 11:29:55 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro getwchar.
- */
-#undef getwchar
-
-wint_t
-getwchar()
-{
-
-	return fgetwc(stdin);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/printf.c b/libc/upstream-openbsd/lib/libc/stdio/printf.c
deleted file mode 100644
index 09bb3d7..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/printf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$OpenBSD: printf.c,v 1.8 2011/05/30 18:48:33 martynas Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-/* PRINTFLIKE1 */
-int
-printf(const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	va_start(ap, fmt);
-	ret = vfprintf(stdout, fmt, ap);
-	va_end(ap);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putc.c b/libc/upstream-openbsd/lib/libc/stdio/putc.c
deleted file mode 100644
index 762fecb..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putc.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*	$OpenBSD: putc.c,v 1.12 2009/11/21 10:11:54 guenther Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include "local.h"
-
-/*
- * A subroutine version of the macro putc_unlocked.
- */
-#undef putc_unlocked
-
-int
-putc_unlocked(int c, FILE *fp)
-{
-	if (cantwrite(fp)) {
-		errno = EBADF;
-		return (EOF);
-	}
-	_SET_ORIENTATION(fp, -1);
-	return (__sputc(c, fp));
-}
-
-/*
- * A subroutine version of the macro putc.
- */
-#undef putc
-
-int
-putc(int c, FILE *fp)
-{
-	int ret;
-
-	FLOCKFILE(fp);
-	ret = putc_unlocked(c, fp);
-	FUNLOCKFILE(fp);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putchar.c b/libc/upstream-openbsd/lib/libc/stdio/putchar.c
deleted file mode 100644
index 233cdfd..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putchar.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*	$OpenBSD: putchar.c,v 1.7 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-#undef putchar_unlocked
-/*
- * A subrouting version of the macro putchar_unlocked
- */
-int
-putchar_unlocked(int c)
-{
-	FILE *so = stdout;
-
-	return (putc_unlocked(c,so));
-}
-
-#undef putchar
-
-/*
- * A subroutine version of the macro putchar
- */
-int
-putchar(int c)
-{
-	FILE *so = stdout;
-
-	return (putc(c, so));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putw.c b/libc/upstream-openbsd/lib/libc/stdio/putw.c
deleted file mode 100644
index 47941a4..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putw.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*	$OpenBSD: putw.c,v 1.10 2009/11/21 09:53:44 guenther Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-#include "fvwrite.h"
-
-int
-putw(int w, FILE *fp)
-{
-	struct __suio uio;
-	struct __siov iov;
-	int ret;
-
-	iov.iov_base = &w;
-	iov.iov_len = uio.uio_resid = sizeof(w);
-	uio.uio_iov = &iov;
-	uio.uio_iovcnt = 1;
-	FLOCKFILE(fp);
-	_SET_ORIENTATION(fp, -1);
-	ret = __sfvwrite(fp, &uio);
-	FUNLOCKFILE(fp);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putwc.c b/libc/upstream-openbsd/lib/libc/stdio/putwc.c
deleted file mode 100644
index 8e2ff2d..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putwc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*	$OpenBSD: putwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $	*/
-/* $NetBSD: putwc.c,v 1.3 2003/01/18 11:29:56 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro putwc.
- */
-#undef putwc
-
-wint_t
-putwc(wchar_t wc, FILE *fp)
-{
-
-	return fputwc(wc, fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putwchar.c b/libc/upstream-openbsd/lib/libc/stdio/putwchar.c
deleted file mode 100644
index 940ec05..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putwchar.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*	$OpenBSD: putwchar.c,v 1.1 2005/06/17 20:40:32 espie Exp $	*/
-/* $NetBSD: putwchar.c,v 1.3 2003/01/18 11:29:56 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro putwchar.
- */
-#undef putwchar
-
-wint_t
-putwchar(wchar_t wc)
-{
-
-	return fputwc(wc, stdout);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/remove.c b/libc/upstream-openbsd/lib/libc/stdio/remove.c
deleted file mode 100644
index d09d76f..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/remove.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*	$OpenBSD: remove.c,v 1.7 2005/08/08 08:05:36 espie Exp $	*/
-
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-int
-remove(const char *file)
-{
-	struct stat st;
-
-	if (lstat(file, &st) < 0)
-		return (-1);
-	if (S_ISDIR(st.st_mode))
-		return (rmdir(file));
-	return (unlink(file));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/rewind.c b/libc/upstream-openbsd/lib/libc/stdio/rewind.c
deleted file mode 100644
index 28119b6..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/rewind.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*	$OpenBSD: rewind.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <errno.h>
-#include <stdio.h>
-
-void
-rewind(FILE *fp)
-{
-	(void) fseek(fp, 0L, SEEK_SET);
-	clearerr(fp);
-	errno = 0;      /* not required, but seems reasonable */
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/scanf.c b/libc/upstream-openbsd/lib/libc/stdio/scanf.c
deleted file mode 100644
index 90cf12a..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/scanf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$OpenBSD: scanf.c,v 1.10 2011/05/30 18:48:33 martynas Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-/* SCANFLIKE1 */
-int
-scanf(const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	va_start(ap, fmt);
-	ret = vfscanf(stdin, fmt, ap);
-	va_end(ap);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/setbuf.c b/libc/upstream-openbsd/lib/libc/stdio/setbuf.c
deleted file mode 100644
index 883b895..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/setbuf.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*	$OpenBSD: setbuf.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-
-void
-setbuf(FILE *fp, char *buf)
-{
-	(void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/setbuffer.c b/libc/upstream-openbsd/lib/libc/stdio/setbuffer.c
deleted file mode 100644
index 8725ff7..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/setbuffer.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*	$OpenBSD: setbuffer.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-void
-setbuffer(FILE *fp, char *buf, int size)
-{
-
-	(void)setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size);
-}
-
-/*
- * set line buffering
- */
-int
-setlinebuf(FILE *fp)
-{
-
-	return (setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/sscanf.c b/libc/upstream-openbsd/lib/libc/stdio/sscanf.c
deleted file mode 100644
index e371ca6..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/sscanf.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*	$OpenBSD: sscanf.c,v 1.14 2011/11/08 18:30:42 guenther Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include "local.h"
-
-/* ARGSUSED */
-static int
-eofread(void *cookie, char *buf, int len)
-{
-
-	return (0);
-}
-
-/* SCANFLIKE2 */
-int
-sscanf(const char *str, const char *fmt, ...)
-{
-	int ret;
-	va_list ap;
-	FILE f;
-	struct __sfileext fext;
-
-	_FILEEXT_SETUP(&f, &fext);
-	f._flags = __SRD;
-	f._bf._base = f._p = (unsigned char *)str;
-	f._bf._size = f._r = strlen(str);
-	f._read = eofread;
-	f._lb._base = NULL;
-	va_start(ap, fmt);
-	ret = __svfscanf(&f, fmt, ap);
-	va_end(ap);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/swprintf.c b/libc/upstream-openbsd/lib/libc/stdio/swprintf.c
deleted file mode 100644
index 8928aea..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/swprintf.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*	$OpenBSD: swprintf.c,v 1.5 2012/12/05 23:20:01 deraadt Exp $ */
-/*	$NetBSD: swprintf.c,v 1.1 2005/05/14 23:51:02 christos Exp $	*/
-
-/*-
- * Copyright (c) 2002 Tim J. Robbins
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-swprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	va_start(ap, fmt);
-	ret = vswprintf(s, n, fmt, ap);
-	va_end(ap);
-
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/swscanf.c b/libc/upstream-openbsd/lib/libc/stdio/swscanf.c
deleted file mode 100644
index a85e9ee..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/swscanf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $OpenBSD: swscanf.c,v 1.2 2012/12/05 23:20:01 deraadt Exp $ */
-
-/*-
- * Copyright (c) 2002 Tim J. Robbins
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-swscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt, ...)
-{
-	va_list ap;
-	int r;
-
-	va_start(ap, fmt);
-	r = vswscanf(str, fmt, ap);
-	va_end(ap);
-
-	return (r);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vprintf.c
deleted file mode 100644
index fcc622c..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vprintf.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*	$OpenBSD: vprintf.c,v 1.8 2006/01/06 18:53:04 millert Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-int
-vprintf(const char *fmt, __va_list ap)
-{
-	return (vfprintf(stdout, fmt, ap));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vscanf.c b/libc/upstream-openbsd/lib/libc/stdio/vscanf.c
deleted file mode 100644
index 228498e..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vscanf.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*	$OpenBSD: vscanf.c,v 1.8 2006/01/06 18:53:04 millert Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Donn Seeley at UUNET Technologies, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-int
-vscanf(const char *fmt, __va_list ap)
-{
-
-	return (vfscanf(stdin, fmt, ap));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vsnprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vsnprintf.c
deleted file mode 100644
index 8b1a088..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vsnprintf.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*	$OpenBSD: vsnprintf.c,v 1.15 2009/11/09 00:18:28 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include "local.h"
-
-int
-vsnprintf(char *str, size_t n, const char *fmt, __va_list ap)
-{
-	int ret;
-	char dummy;
-	FILE f;
-	struct __sfileext fext;
-
-	_FILEEXT_SETUP(&f, &fext);
-
-	/* While snprintf(3) specifies size_t stdio uses an int internally */
-	if (n > INT_MAX)
-		n = INT_MAX;
-	/* Stdio internals do not deal correctly with zero length buffer */
-	if (n == 0) {
-		str = &dummy;
-		n = 1;
-	}
-	f._file = -1;
-	f._flags = __SWR | __SSTR;
-	f._bf._base = f._p = (unsigned char *)str;
-	f._bf._size = f._w = n - 1;
-	ret = __vfprintf(&f, fmt, ap);
-	*f._p = '\0';
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vsprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vsprintf.c
deleted file mode 100644
index 308ff37..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vsprintf.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*	$OpenBSD: vsprintf.c,v 1.16 2009/11/09 00:18:28 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include "local.h"
-
-#if defined(APIWARN)
-__warn_references(vsprintf,
-    "warning: vsprintf() is often misused, please use vsnprintf()");
-#endif
-
-int
-vsprintf(char *str, const char *fmt, __va_list ap)
-{
-	int ret;
-	FILE f;
-	struct __sfileext fext;
-
-	_FILEEXT_SETUP(&f, &fext);
-	f._file = -1;
-	f._flags = __SWR | __SSTR;
-	f._bf._base = f._p = (unsigned char *)str;
-	f._bf._size = f._w = INT_MAX;
-	ret = __vfprintf(&f, fmt, ap);
-	*f._p = '\0';
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vwprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vwprintf.c
deleted file mode 100644
index 49569c1..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vwprintf.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*	$OpenBSD: vwprintf.c,v 1.3 2011/04/28 17:38:46 stsp Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-vwprintf(const wchar_t * __restrict fmt, __va_list ap)
-{
-	return (vfwprintf(stdout, fmt, ap));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vwscanf.c b/libc/upstream-openbsd/lib/libc/stdio/vwscanf.c
deleted file mode 100644
index 7039f02..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vwscanf.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* $OpenBSD: vwscanf.c,v 1.2 2012/12/05 23:20:01 deraadt Exp $ */
-
-/*-
- * Copyright (c) 2002 Tim J. Robbins
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-vwscanf(const wchar_t * __restrict fmt, __va_list ap)
-{
-
-	return (vfwscanf(stdin, fmt, ap));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/wprintf.c b/libc/upstream-openbsd/lib/libc/stdio/wprintf.c
deleted file mode 100644
index 9f7abb6..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/wprintf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*	$OpenBSD: wprintf.c,v 1.3 2011/04/28 17:38:46 stsp Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <wchar.h>
-
-int
-wprintf(const wchar_t * __restrict fmt, ...)
-{
-	int ret;
-	va_list ap;
-
-	va_start(ap, fmt);
-	ret = vfwprintf(stdout, fmt, ap);
-	va_end(ap);
-	return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/wscanf.c b/libc/upstream-openbsd/lib/libc/stdio/wscanf.c
deleted file mode 100644
index 06c0829..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/wscanf.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $OpenBSD: wscanf.c,v 1.2 2012/12/05 23:20:01 deraadt Exp $ */
-
-/*-
- * Copyright (c) 2002 Tim J. Robbins
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-wscanf(const wchar_t * __restrict fmt, ...)
-{
-	va_list ap;
-	int r;
-
-	va_start(ap, fmt);
-	r = vfwscanf(stdin, fmt, ap);
-	va_end(ap);
-
-	return (r);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdlib/getsubopt.c b/libc/upstream-openbsd/lib/libc/stdlib/getsubopt.c
new file mode 100644
index 0000000..735c85b
--- /dev/null
+++ b/libc/upstream-openbsd/lib/libc/stdlib/getsubopt.c
@@ -0,0 +1,92 @@
+/*	$OpenBSD: getsubopt.c,v 1.4 2005/08/08 08:05:36 espie Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * The SVID interface to getsubopt provides no way of figuring out which
+ * part of the suboptions list wasn't matched.  This makes error messages
+ * tricky...  The extern variable suboptarg is a pointer to the token
+ * which didn't match.
+ */
+char *suboptarg;
+
+int
+getsubopt(char **optionp, char * const *tokens, char **valuep)
+{
+	int cnt;
+	char *p;
+
+	suboptarg = *valuep = NULL;
+
+	if (!optionp || !*optionp)
+		return(-1);
+
+	/* skip leading white-space, commas */
+	for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+
+	if (!*p) {
+		*optionp = p;
+		return(-1);
+	}
+
+	/* save the start of the token, and skip the rest of the token. */
+	for (suboptarg = p;
+	    *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
+
+	if (*p) {
+		/*
+		 * If there's an equals sign, set the value pointer, and
+		 * skip over the value part of the token.  Terminate the
+		 * token.
+		 */
+		if (*p == '=') {
+			*p = '\0';
+			for (*valuep = ++p;
+			    *p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
+			if (*p) 
+				*p++ = '\0';
+		} else
+			*p++ = '\0';
+		/* Skip any whitespace or commas after this token. */
+		for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+	}
+
+	/* set optionp for next round. */
+	*optionp = p;
+
+	for (cnt = 0; *tokens; ++tokens, ++cnt)
+		if (!strcmp(suboptarg, *tokens))
+			return(cnt);
+	return(-1);
+}
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 2aa9b68..273a887 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -56,5 +56,13 @@
     allow_undefined_symbols: true,
     system_shared_libs: [],
 
-    sanitize: ["never"],
+    sanitize: {
+        never: true,
+    },
+}
+
+ndk_library {
+    name: "libdl.ndk",
+    symbol_file: "libdl.map.txt",
+    first_version: "9",
 }
diff --git a/libdl/Android.mk b/libdl/Android.mk
deleted file mode 100644
index 1ea5dc7..0000000
--- a/libdl/Android.mk
+++ /dev/null
@@ -1,66 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-# libdl
-#
-
-include $(CLEAR_VARS)
-
-# NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
-# libgcc.a are made static to libdl.so.  This in turn ensures that libraries that
-# a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
-# to provide those symbols, but will instead pull them from libgcc.a.  Specifically,
-# we use this property to make sure libc.so has its own copy of the code from
-# libgcc.a it uses.
-#
-# DO NOT REMOVE --exclude-libs!
-
-LOCAL_LDFLAGS := -Wl,--exclude-libs=libgcc.a
-
-# for x86, exclude libgcc_eh.a for the same reasons as above
-LOCAL_LDFLAGS_x86 := -Wl,--exclude-libs=libgcc_eh.a
-LOCAL_LDFLAGS_x86_64 := $(LOCAL_LDFLAGS_x86)
-
-LOCAL_LDFLAGS_arm    += -Wl,--version-script=$(LOCAL_PATH)/libdl.arm.map
-LOCAL_LDFLAGS_arm64  += -Wl,--version-script=$(LOCAL_PATH)/libdl.arm64.map
-LOCAL_LDFLAGS_mips   += -Wl,--version-script=$(LOCAL_PATH)/libdl.mips.map
-LOCAL_LDFLAGS_mips64 += -Wl,--version-script=$(LOCAL_PATH)/libdl.mips64.map
-LOCAL_LDFLAGS_x86    += -Wl,--version-script=$(LOCAL_PATH)/libdl.x86.map
-LOCAL_LDFLAGS_x86_64 += -Wl,--version-script=$(LOCAL_PATH)/libdl.x86_64.map
-
-LOCAL_SRC_FILES:= libdl.c
-LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror
-LOCAL_CXX_STL := none
-
-LOCAL_MODULE := libdl
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk \
-                                 $(LOCAL_PATH)/libdl.arm.map \
-                                 $(LOCAL_PATH)/libdl.arm64.map \
-                                 $(LOCAL_PATH)/libdl.mips.map \
-                                 $(LOCAL_PATH)/libdl.mips64.map \
-                                 $(LOCAL_PATH)/libdl.x86.map \
-                                 $(LOCAL_PATH)/libdl.x86_64.map \
-
-# NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a
-# few symbols from libc. Using --no-undefined here results in having to link
-# against libc creating a circular dependency which is removed and we end up
-# with missing symbols. Since this library is just a bunch of stubs, we set
-# LOCAL_ALLOW_UNDEFINED_SYMBOLS to remove --no-undefined from the linker flags.
-LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-
-LOCAL_SANITIZE := never
-include $(BUILD_SHARED_LIBRARY)
-
-# A dummy libdl.a. Need for static executables using the LLVM unwinder. Most
-# functions default to failure, others use a sensible default (dl_iterate_phdr()
-# returns 0, as would happen if the user iterated over every phdr).
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES:= libdl.c
-LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror
-LOCAL_CXX_STL := none
-
-LOCAL_MODULE := libdl
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SANITIZE := never
-include $(BUILD_STATIC_LIBRARY)
diff --git a/libdl/NOTICE b/libdl/NOTICE
deleted file mode 100644
index 77b5743..0000000
--- a/libdl/NOTICE
+++ /dev/null
@@ -1,16 +0,0 @@
-Copyright (C) 2007 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
diff --git a/libdl/libdl.arm.map b/libdl/libdl.arm.map
index 2821509..1fdc1a7 100644
--- a/libdl/libdl.arm.map
+++ b/libdl/libdl.arm.map
@@ -1,9 +1,24 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
 
 LIBC {
   global:
-    android_dlopen_ext;
-    dl_iterate_phdr;
+    android_dlopen_ext; # introduced=21
+    dl_iterate_phdr; # introduced-arm=21
     dl_unwind_find_exidx; # arm
     dladdr;
     dlclose;
@@ -16,7 +31,7 @@
 
 LIBC_N {
   global:
-    dlvsym;
+    dlvsym; # introduced=24
 } LIBC;
 
 LIBC_PLATFORM {
diff --git a/libdl/libdl.arm64.map b/libdl/libdl.arm64.map
index f21859c..28d2613 100644
--- a/libdl/libdl.arm64.map
+++ b/libdl/libdl.arm64.map
@@ -1,9 +1,24 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
 
 LIBC {
   global:
-    android_dlopen_ext;
-    dl_iterate_phdr;
+    android_dlopen_ext; # introduced=21
+    dl_iterate_phdr; # introduced-arm=21
     dladdr;
     dlclose;
     dlerror;
@@ -15,7 +30,7 @@
 
 LIBC_N {
   global:
-    dlvsym;
+    dlvsym; # introduced=24
 } LIBC;
 
 LIBC_PLATFORM {
diff --git a/libdl/libdl.c b/libdl/libdl.c
index b62ee5c..4cc4dea 100644
--- a/libdl/libdl.c
+++ b/libdl/libdl.c
@@ -25,7 +25,7 @@
 
 void* dlopen(const char* filename __unused, int flag __unused) { return 0; }
 
-const char* dlerror(void) { return 0; }
+char* dlerror(void) { return 0; }
 
 void* dlsym(void* handle __unused, const char* symbol __unused) { return 0; }
 
diff --git a/libdl/libdl.map.txt b/libdl/libdl.map.txt
index 962692e..0a82a2e 100644
--- a/libdl/libdl.map.txt
+++ b/libdl/libdl.map.txt
@@ -16,8 +16,8 @@
 
 LIBC {
   global:
-    android_dlopen_ext;
-    dl_iterate_phdr;
+    android_dlopen_ext; # introduced=21
+    dl_iterate_phdr; # introduced-arm=21
     dl_unwind_find_exidx; # arm
     dladdr;
     dlclose;
@@ -30,7 +30,7 @@
 
 LIBC_N {
   global:
-    dlvsym;
+    dlvsym; # introduced=24
 } LIBC;
 
 LIBC_PLATFORM {
diff --git a/libdl/libdl.mips.map b/libdl/libdl.mips.map
index f21859c..28d2613 100644
--- a/libdl/libdl.mips.map
+++ b/libdl/libdl.mips.map
@@ -1,9 +1,24 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
 
 LIBC {
   global:
-    android_dlopen_ext;
-    dl_iterate_phdr;
+    android_dlopen_ext; # introduced=21
+    dl_iterate_phdr; # introduced-arm=21
     dladdr;
     dlclose;
     dlerror;
@@ -15,7 +30,7 @@
 
 LIBC_N {
   global:
-    dlvsym;
+    dlvsym; # introduced=24
 } LIBC;
 
 LIBC_PLATFORM {
diff --git a/libdl/libdl.mips64.map b/libdl/libdl.mips64.map
index f21859c..28d2613 100644
--- a/libdl/libdl.mips64.map
+++ b/libdl/libdl.mips64.map
@@ -1,9 +1,24 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
 
 LIBC {
   global:
-    android_dlopen_ext;
-    dl_iterate_phdr;
+    android_dlopen_ext; # introduced=21
+    dl_iterate_phdr; # introduced-arm=21
     dladdr;
     dlclose;
     dlerror;
@@ -15,7 +30,7 @@
 
 LIBC_N {
   global:
-    dlvsym;
+    dlvsym; # introduced=24
 } LIBC;
 
 LIBC_PLATFORM {
diff --git a/libdl/libdl.x86.map b/libdl/libdl.x86.map
index f21859c..28d2613 100644
--- a/libdl/libdl.x86.map
+++ b/libdl/libdl.x86.map
@@ -1,9 +1,24 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
 
 LIBC {
   global:
-    android_dlopen_ext;
-    dl_iterate_phdr;
+    android_dlopen_ext; # introduced=21
+    dl_iterate_phdr; # introduced-arm=21
     dladdr;
     dlclose;
     dlerror;
@@ -15,7 +30,7 @@
 
 LIBC_N {
   global:
-    dlvsym;
+    dlvsym; # introduced=24
 } LIBC;
 
 LIBC_PLATFORM {
diff --git a/libdl/libdl.x86_64.map b/libdl/libdl.x86_64.map
index f21859c..28d2613 100644
--- a/libdl/libdl.x86_64.map
+++ b/libdl/libdl.x86_64.map
@@ -1,9 +1,24 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
 
 LIBC {
   global:
-    android_dlopen_ext;
-    dl_iterate_phdr;
+    android_dlopen_ext; # introduced=21
+    dl_iterate_phdr; # introduced-arm=21
     dladdr;
     dlclose;
     dlerror;
@@ -15,7 +30,7 @@
 
 LIBC_N {
   global:
-    dlvsym;
+    dlvsym; # introduced=24
 } LIBC;
 
 LIBC_PLATFORM {
diff --git a/libm/Android.bp b/libm/Android.bp
index 081a139..11017f6 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -1,307 +1,282 @@
-// ANDROIDMK TRANSLATION ERROR: unsupported directive
-// ifneq ($(TARGET_USE_PRIVATE_LIBM),true)
-
 bionic_coverage = false
 
-libm_common_src_files = [
-    "upstream-freebsd/lib/msun/bsdsrc/b_exp.c",
-    "upstream-freebsd/lib/msun/bsdsrc/b_log.c",
-    "upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c",
-    "upstream-freebsd/lib/msun/src/catrig.c",
-    "upstream-freebsd/lib/msun/src/catrigf.c",
-    "upstream-freebsd/lib/msun/src/e_acos.c",
-    "upstream-freebsd/lib/msun/src/e_acosf.c",
-    "upstream-freebsd/lib/msun/src/e_acosh.c",
-    "upstream-freebsd/lib/msun/src/e_acoshf.c",
-    "upstream-freebsd/lib/msun/src/e_asin.c",
-    "upstream-freebsd/lib/msun/src/e_asinf.c",
-    "upstream-freebsd/lib/msun/src/e_atan2.c",
-    "upstream-freebsd/lib/msun/src/e_atan2f.c",
-    "upstream-freebsd/lib/msun/src/e_atanh.c",
-    "upstream-freebsd/lib/msun/src/e_atanhf.c",
-    "upstream-freebsd/lib/msun/src/e_cosh.c",
-    "upstream-freebsd/lib/msun/src/e_coshf.c",
-    "upstream-freebsd/lib/msun/src/e_exp.c",
-    "upstream-freebsd/lib/msun/src/e_expf.c",
-    "upstream-freebsd/lib/msun/src/e_fmod.c",
-    "upstream-freebsd/lib/msun/src/e_fmodf.c",
-    "upstream-freebsd/lib/msun/src/e_gamma.c",
-    "upstream-freebsd/lib/msun/src/e_gammaf.c",
-    "upstream-freebsd/lib/msun/src/e_gammaf_r.c",
-    "upstream-freebsd/lib/msun/src/e_gamma_r.c",
-    "upstream-freebsd/lib/msun/src/e_hypot.c",
-    "upstream-freebsd/lib/msun/src/e_hypotf.c",
-    "upstream-freebsd/lib/msun/src/e_j0.c",
-    "upstream-freebsd/lib/msun/src/e_j0f.c",
-    "upstream-freebsd/lib/msun/src/e_j1.c",
-    "upstream-freebsd/lib/msun/src/e_j1f.c",
-    "upstream-freebsd/lib/msun/src/e_jn.c",
-    "upstream-freebsd/lib/msun/src/e_jnf.c",
-    "upstream-freebsd/lib/msun/src/e_lgamma.c",
-    "upstream-freebsd/lib/msun/src/e_lgammaf.c",
-    "upstream-freebsd/lib/msun/src/e_lgammaf_r.c",
-    "upstream-freebsd/lib/msun/src/e_lgamma_r.c",
-    "upstream-freebsd/lib/msun/src/e_log10.c",
-    "upstream-freebsd/lib/msun/src/e_log10f.c",
-    "upstream-freebsd/lib/msun/src/e_log2.c",
-    "upstream-freebsd/lib/msun/src/e_log2f.c",
-    "upstream-freebsd/lib/msun/src/e_log.c",
-    "upstream-freebsd/lib/msun/src/e_logf.c",
-    "upstream-freebsd/lib/msun/src/e_pow.c",
-    "upstream-freebsd/lib/msun/src/e_powf.c",
-    "upstream-freebsd/lib/msun/src/e_remainder.c",
-    "upstream-freebsd/lib/msun/src/e_remainderf.c",
-    "upstream-freebsd/lib/msun/src/e_rem_pio2.c",
-    "upstream-freebsd/lib/msun/src/e_rem_pio2f.c",
-    "upstream-freebsd/lib/msun/src/e_scalb.c",
-    "upstream-freebsd/lib/msun/src/e_scalbf.c",
-    "upstream-freebsd/lib/msun/src/e_sinh.c",
-    "upstream-freebsd/lib/msun/src/e_sinhf.c",
-    "upstream-freebsd/lib/msun/src/e_sqrt.c",
-    "upstream-freebsd/lib/msun/src/e_sqrtf.c",
-    "upstream-freebsd/lib/msun/src/imprecise.c",
-    "upstream-freebsd/lib/msun/src/k_cos.c",
-    "upstream-freebsd/lib/msun/src/k_cosf.c",
-    "upstream-freebsd/lib/msun/src/k_exp.c",
-    "upstream-freebsd/lib/msun/src/k_expf.c",
-    "upstream-freebsd/lib/msun/src/k_rem_pio2.c",
-    "upstream-freebsd/lib/msun/src/k_sin.c",
-    "upstream-freebsd/lib/msun/src/k_sinf.c",
-    "upstream-freebsd/lib/msun/src/k_tan.c",
-    "upstream-freebsd/lib/msun/src/k_tanf.c",
-    "upstream-freebsd/lib/msun/src/s_asinh.c",
-    "upstream-freebsd/lib/msun/src/s_asinhf.c",
-    "upstream-freebsd/lib/msun/src/s_atan.c",
-    "upstream-freebsd/lib/msun/src/s_atanf.c",
-    "upstream-freebsd/lib/msun/src/s_carg.c",
-    "upstream-freebsd/lib/msun/src/s_cargf.c",
-    "upstream-freebsd/lib/msun/src/s_cargl.c",
-    "upstream-freebsd/lib/msun/src/s_cbrt.c",
-    "upstream-freebsd/lib/msun/src/s_cbrtf.c",
-    "upstream-freebsd/lib/msun/src/s_ccosh.c",
-    "upstream-freebsd/lib/msun/src/s_ccoshf.c",
-    "upstream-freebsd/lib/msun/src/s_ceil.c",
-    "upstream-freebsd/lib/msun/src/s_ceilf.c",
-    "upstream-freebsd/lib/msun/src/s_cexp.c",
-    "upstream-freebsd/lib/msun/src/s_cexpf.c",
-    "upstream-freebsd/lib/msun/src/s_cimag.c",
-    "upstream-freebsd/lib/msun/src/s_cimagf.c",
-    "upstream-freebsd/lib/msun/src/s_cimagl.c",
-    "upstream-freebsd/lib/msun/src/s_conj.c",
-    "upstream-freebsd/lib/msun/src/s_conjf.c",
-    "upstream-freebsd/lib/msun/src/s_conjl.c",
-    "upstream-freebsd/lib/msun/src/s_copysign.c",
-    "upstream-freebsd/lib/msun/src/s_copysignf.c",
-    "upstream-freebsd/lib/msun/src/s_cos.c",
-    "upstream-freebsd/lib/msun/src/s_cosf.c",
-    "upstream-freebsd/lib/msun/src/s_cproj.c",
-    "upstream-freebsd/lib/msun/src/s_cprojf.c",
-    "upstream-freebsd/lib/msun/src/s_cprojl.c",
-    "upstream-freebsd/lib/msun/src/s_creal.c",
-    "upstream-freebsd/lib/msun/src/s_crealf.c",
-    "upstream-freebsd/lib/msun/src/s_creall.c",
-    "upstream-freebsd/lib/msun/src/s_csinh.c",
-    "upstream-freebsd/lib/msun/src/s_csinhf.c",
-    "upstream-freebsd/lib/msun/src/s_csqrt.c",
-    "upstream-freebsd/lib/msun/src/s_csqrtf.c",
-    "upstream-freebsd/lib/msun/src/s_csqrtl.c",
-    "upstream-freebsd/lib/msun/src/s_ctanh.c",
-    "upstream-freebsd/lib/msun/src/s_ctanhf.c",
-    "upstream-freebsd/lib/msun/src/s_erf.c",
-    "upstream-freebsd/lib/msun/src/s_erff.c",
-    "upstream-freebsd/lib/msun/src/s_exp2.c",
-    "upstream-freebsd/lib/msun/src/s_exp2f.c",
-    "upstream-freebsd/lib/msun/src/s_expm1.c",
-    "upstream-freebsd/lib/msun/src/s_expm1f.c",
-    "upstream-freebsd/lib/msun/src/s_fdim.c",
-    "upstream-freebsd/lib/msun/src/s_finite.c",
-    "upstream-freebsd/lib/msun/src/s_finitef.c",
-    "upstream-freebsd/lib/msun/src/s_floor.c",
-    "upstream-freebsd/lib/msun/src/s_floorf.c",
-    "upstream-freebsd/lib/msun/src/s_fma.c",
-    "upstream-freebsd/lib/msun/src/s_fmaf.c",
-    "upstream-freebsd/lib/msun/src/s_fmax.c",
-    "upstream-freebsd/lib/msun/src/s_fmaxf.c",
-    "upstream-freebsd/lib/msun/src/s_fmin.c",
-    "upstream-freebsd/lib/msun/src/s_fminf.c",
-    "upstream-freebsd/lib/msun/src/s_frexp.c",
-    "upstream-freebsd/lib/msun/src/s_frexpf.c",
-    "upstream-freebsd/lib/msun/src/s_ilogb.c",
-    "upstream-freebsd/lib/msun/src/s_ilogbf.c",
-    "upstream-freebsd/lib/msun/src/s_llrint.c",
-    "upstream-freebsd/lib/msun/src/s_llrintf.c",
-    "upstream-freebsd/lib/msun/src/s_llround.c",
-    "upstream-freebsd/lib/msun/src/s_llroundf.c",
-    "upstream-freebsd/lib/msun/src/s_log1p.c",
-    "upstream-freebsd/lib/msun/src/s_log1pf.c",
-    "upstream-freebsd/lib/msun/src/s_logb.c",
-    "upstream-freebsd/lib/msun/src/s_logbf.c",
-    "upstream-freebsd/lib/msun/src/s_lrint.c",
-    "upstream-freebsd/lib/msun/src/s_lrintf.c",
-    "upstream-freebsd/lib/msun/src/s_lround.c",
-    "upstream-freebsd/lib/msun/src/s_lroundf.c",
-    "upstream-freebsd/lib/msun/src/s_modf.c",
-    "upstream-freebsd/lib/msun/src/s_modff.c",
-    "upstream-freebsd/lib/msun/src/s_nan.c",
-    "upstream-freebsd/lib/msun/src/s_nearbyint.c",
-    "upstream-freebsd/lib/msun/src/s_nextafter.c",
-    "upstream-freebsd/lib/msun/src/s_nextafterf.c",
-    "upstream-freebsd/lib/msun/src/s_remquo.c",
-    "upstream-freebsd/lib/msun/src/s_remquof.c",
-    "upstream-freebsd/lib/msun/src/s_rint.c",
-    "upstream-freebsd/lib/msun/src/s_rintf.c",
-    "upstream-freebsd/lib/msun/src/s_round.c",
-    "upstream-freebsd/lib/msun/src/s_roundf.c",
-    "upstream-freebsd/lib/msun/src/s_scalbln.c",
-    "upstream-freebsd/lib/msun/src/s_scalbn.c",
-    "upstream-freebsd/lib/msun/src/s_scalbnf.c",
-    "upstream-freebsd/lib/msun/src/s_signgam.c",
-    "upstream-freebsd/lib/msun/src/s_significand.c",
-    "upstream-freebsd/lib/msun/src/s_significandf.c",
-    "upstream-freebsd/lib/msun/src/s_sin.c",
-    "upstream-freebsd/lib/msun/src/s_sinf.c",
-    "upstream-freebsd/lib/msun/src/s_tan.c",
-    "upstream-freebsd/lib/msun/src/s_tanf.c",
-    "upstream-freebsd/lib/msun/src/s_tanh.c",
-    "upstream-freebsd/lib/msun/src/s_tanhf.c",
-    "upstream-freebsd/lib/msun/src/s_tgammaf.c",
-    "upstream-freebsd/lib/msun/src/s_trunc.c",
-    "upstream-freebsd/lib/msun/src/s_truncf.c",
-    "upstream-freebsd/lib/msun/src/w_cabs.c",
-    "upstream-freebsd/lib/msun/src/w_cabsf.c",
-    "upstream-freebsd/lib/msun/src/w_cabsl.c",
-    "upstream-freebsd/lib/msun/src/w_drem.c",
-    "upstream-freebsd/lib/msun/src/w_dremf.c",
-]
-
-libm_common_src_files += [
-    // TODO: this comes from from upstream's libc, not libm, but it's an
-    // implementation detail that should have hidden visibility, so it needs
-    // to be in whatever library the math code is in.
-    "digittoint.c",
-
-    // Functionality not in the BSDs.
-    "significandl.c",
-    "sincos.c",
-
-    // Modified versions of BSD code.
-    "signbit.c",
-
-    // Home-grown stuff.
-    "fabs.cpp",
-]
-
-libm_ld128_src_files = [
-    "upstream-freebsd/lib/msun/src/e_acosl.c",
-    "upstream-freebsd/lib/msun/src/e_acoshl.c",
-    "upstream-freebsd/lib/msun/src/e_asinl.c",
-    "upstream-freebsd/lib/msun/src/e_atan2l.c",
-    "upstream-freebsd/lib/msun/src/e_atanhl.c",
-    "upstream-freebsd/lib/msun/src/e_fmodl.c",
-    "upstream-freebsd/lib/msun/src/e_hypotl.c",
-    "upstream-freebsd/lib/msun/src/e_lgammal.c",
-    "upstream-freebsd/lib/msun/src/e_remainderl.c",
-    "upstream-freebsd/lib/msun/src/e_sqrtl.c",
-    "upstream-freebsd/lib/msun/src/s_asinhl.c",
-    "upstream-freebsd/lib/msun/src/s_atanl.c",
-    "upstream-freebsd/lib/msun/src/s_cbrtl.c",
-    "upstream-freebsd/lib/msun/src/s_ceill.c",
-    "upstream-freebsd/lib/msun/src/s_copysignl.c",
-    "upstream-freebsd/lib/msun/src/e_coshl.c",
-    "upstream-freebsd/lib/msun/src/s_cosl.c",
-    "upstream-freebsd/lib/msun/src/s_floorl.c",
-    "upstream-freebsd/lib/msun/src/s_fmal.c",
-    "upstream-freebsd/lib/msun/src/s_fmaxl.c",
-    "upstream-freebsd/lib/msun/src/s_fminl.c",
-    "upstream-freebsd/lib/msun/src/s_modfl.c",
-    "upstream-freebsd/lib/msun/src/s_frexpl.c",
-    "upstream-freebsd/lib/msun/src/s_ilogbl.c",
-    "upstream-freebsd/lib/msun/src/s_llrintl.c",
-    "upstream-freebsd/lib/msun/src/s_llroundl.c",
-    "upstream-freebsd/lib/msun/src/s_logbl.c",
-    "upstream-freebsd/lib/msun/src/s_lrintl.c",
-    "upstream-freebsd/lib/msun/src/s_lroundl.c",
-    "upstream-freebsd/lib/msun/src/s_nextafterl.c",
-    "upstream-freebsd/lib/msun/src/s_nexttoward.c",
-    "upstream-freebsd/lib/msun/src/s_nexttowardf.c",
-    "upstream-freebsd/lib/msun/src/s_remquol.c",
-    "upstream-freebsd/lib/msun/src/s_rintl.c",
-    "upstream-freebsd/lib/msun/src/s_roundl.c",
-    "upstream-freebsd/lib/msun/src/s_scalbnl.c",
-    "upstream-freebsd/lib/msun/src/e_sinhl.c",
-    "upstream-freebsd/lib/msun/src/s_sinl.c",
-    "upstream-freebsd/lib/msun/src/s_tanhl.c",
-    "upstream-freebsd/lib/msun/src/s_tanl.c",
-    "upstream-freebsd/lib/msun/src/s_truncl.c",
-]
-
-libm_ld128_src_files += [
-    "upstream-freebsd/lib/msun/ld128/invtrig.c",
-    "upstream-freebsd/lib/msun/ld128/e_lgammal_r.c",
-    "upstream-freebsd/lib/msun/ld128/k_cosl.c",
-    "upstream-freebsd/lib/msun/ld128/k_sinl.c",
-    "upstream-freebsd/lib/msun/ld128/k_tanl.c",
-    "upstream-freebsd/lib/msun/ld128/s_erfl.c",
-    "upstream-freebsd/lib/msun/ld128/s_exp2l.c",
-    "upstream-freebsd/lib/msun/ld128/s_expl.c",
-    "upstream-freebsd/lib/msun/ld128/s_logl.c",
-    "upstream-freebsd/lib/msun/ld128/s_nanl.c",
-]
-
-// TODO: re-enable i387/e_sqrtf.S for x86, and maybe others.
-
-libm_common_cflags = [
-    "-D__BIONIC_NO_MATH_INLINES",
-    "-DFLT_EVAL_METHOD=0",
-    "-include freebsd-compat.h",
-    "-Werror",
-    "-Wno-missing-braces",
-    "-Wno-parentheses",
-    "-Wno-sign-compare",
-    "-Wno-uninitialized",
-    "-Wno-unknown-pragmas",
-    "-fvisibility=hidden",
-]
-
-// Workaround the GCC "(long)fn -> lfn" optimization bug which will result in
-// self recursions for lrint, lrintf, and lrintl.
-// BUG: 14225968
-libm_common_cflags += [
-    "-fno-builtin-rint",
-    "-fno-builtin-rintf",
-    "-fno-builtin-rintl",
-]
-
-libm_common_local_includes = ["upstream-freebsd/lib/msun/src/"]
-
-libm_ld_local_includes = ["upstream-freebsd/lib/msun/ld128/"]
-
 //
 // libm.so and libm.a for target.
 //
 cc_library {
     name: "libm",
 
-    cflags: libm_common_cflags,
-    include_dirs: ["bionic/libc"],
-    local_include_dirs: libm_common_local_includes,
-    srcs: libm_common_src_files,
-    system_shared_libs: ["libc"],
+    srcs: [
+        "upstream-freebsd/lib/msun/bsdsrc/b_exp.c",
+        "upstream-freebsd/lib/msun/bsdsrc/b_log.c",
+        "upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c",
+        "upstream-freebsd/lib/msun/src/catrig.c",
+        "upstream-freebsd/lib/msun/src/catrigf.c",
+        "upstream-freebsd/lib/msun/src/e_acos.c",
+        "upstream-freebsd/lib/msun/src/e_acosf.c",
+        "upstream-freebsd/lib/msun/src/e_acosh.c",
+        "upstream-freebsd/lib/msun/src/e_acoshf.c",
+        "upstream-freebsd/lib/msun/src/e_asin.c",
+        "upstream-freebsd/lib/msun/src/e_asinf.c",
+        "upstream-freebsd/lib/msun/src/e_atan2.c",
+        "upstream-freebsd/lib/msun/src/e_atan2f.c",
+        "upstream-freebsd/lib/msun/src/e_atanh.c",
+        "upstream-freebsd/lib/msun/src/e_atanhf.c",
+        "upstream-freebsd/lib/msun/src/e_cosh.c",
+        "upstream-freebsd/lib/msun/src/e_coshf.c",
+        "upstream-freebsd/lib/msun/src/e_exp.c",
+        "upstream-freebsd/lib/msun/src/e_expf.c",
+        "upstream-freebsd/lib/msun/src/e_fmod.c",
+        "upstream-freebsd/lib/msun/src/e_fmodf.c",
+        "upstream-freebsd/lib/msun/src/e_gamma.c",
+        "upstream-freebsd/lib/msun/src/e_gammaf.c",
+        "upstream-freebsd/lib/msun/src/e_gammaf_r.c",
+        "upstream-freebsd/lib/msun/src/e_gamma_r.c",
+        "upstream-freebsd/lib/msun/src/e_hypot.c",
+        "upstream-freebsd/lib/msun/src/e_hypotf.c",
+        "upstream-freebsd/lib/msun/src/e_j0.c",
+        "upstream-freebsd/lib/msun/src/e_j0f.c",
+        "upstream-freebsd/lib/msun/src/e_j1.c",
+        "upstream-freebsd/lib/msun/src/e_j1f.c",
+        "upstream-freebsd/lib/msun/src/e_jn.c",
+        "upstream-freebsd/lib/msun/src/e_jnf.c",
+        "upstream-freebsd/lib/msun/src/e_lgamma.c",
+        "upstream-freebsd/lib/msun/src/e_lgammaf.c",
+        "upstream-freebsd/lib/msun/src/e_lgammaf_r.c",
+        "upstream-freebsd/lib/msun/src/e_lgamma_r.c",
+        "upstream-freebsd/lib/msun/src/e_log10.c",
+        "upstream-freebsd/lib/msun/src/e_log10f.c",
+        "upstream-freebsd/lib/msun/src/e_log2.c",
+        "upstream-freebsd/lib/msun/src/e_log2f.c",
+        "upstream-freebsd/lib/msun/src/e_log.c",
+        "upstream-freebsd/lib/msun/src/e_logf.c",
+        "upstream-freebsd/lib/msun/src/e_pow.c",
+        "upstream-freebsd/lib/msun/src/e_powf.c",
+        "upstream-freebsd/lib/msun/src/e_remainder.c",
+        "upstream-freebsd/lib/msun/src/e_remainderf.c",
+        "upstream-freebsd/lib/msun/src/e_rem_pio2.c",
+        "upstream-freebsd/lib/msun/src/e_rem_pio2f.c",
+        "upstream-freebsd/lib/msun/src/e_scalb.c",
+        "upstream-freebsd/lib/msun/src/e_scalbf.c",
+        "upstream-freebsd/lib/msun/src/e_sinh.c",
+        "upstream-freebsd/lib/msun/src/e_sinhf.c",
+        "upstream-freebsd/lib/msun/src/e_sqrt.c",
+        "upstream-freebsd/lib/msun/src/e_sqrtf.c",
+        "upstream-freebsd/lib/msun/src/imprecise.c",
+        "upstream-freebsd/lib/msun/src/k_cos.c",
+        "upstream-freebsd/lib/msun/src/k_cosf.c",
+        "upstream-freebsd/lib/msun/src/k_exp.c",
+        "upstream-freebsd/lib/msun/src/k_expf.c",
+        "upstream-freebsd/lib/msun/src/k_rem_pio2.c",
+        "upstream-freebsd/lib/msun/src/k_sin.c",
+        "upstream-freebsd/lib/msun/src/k_sinf.c",
+        "upstream-freebsd/lib/msun/src/k_tan.c",
+        "upstream-freebsd/lib/msun/src/k_tanf.c",
+        "upstream-freebsd/lib/msun/src/s_asinh.c",
+        "upstream-freebsd/lib/msun/src/s_asinhf.c",
+        "upstream-freebsd/lib/msun/src/s_atan.c",
+        "upstream-freebsd/lib/msun/src/s_atanf.c",
+        "upstream-freebsd/lib/msun/src/s_carg.c",
+        "upstream-freebsd/lib/msun/src/s_cargf.c",
+        "upstream-freebsd/lib/msun/src/s_cargl.c",
+        "upstream-freebsd/lib/msun/src/s_cbrt.c",
+        "upstream-freebsd/lib/msun/src/s_cbrtf.c",
+        "upstream-freebsd/lib/msun/src/s_ccosh.c",
+        "upstream-freebsd/lib/msun/src/s_ccoshf.c",
+        "upstream-freebsd/lib/msun/src/s_ceil.c",
+        "upstream-freebsd/lib/msun/src/s_ceilf.c",
+        "upstream-freebsd/lib/msun/src/s_cexp.c",
+        "upstream-freebsd/lib/msun/src/s_cexpf.c",
+        "upstream-freebsd/lib/msun/src/s_cimag.c",
+        "upstream-freebsd/lib/msun/src/s_cimagf.c",
+        "upstream-freebsd/lib/msun/src/s_cimagl.c",
+        "upstream-freebsd/lib/msun/src/s_conj.c",
+        "upstream-freebsd/lib/msun/src/s_conjf.c",
+        "upstream-freebsd/lib/msun/src/s_conjl.c",
+        "upstream-freebsd/lib/msun/src/s_copysign.c",
+        "upstream-freebsd/lib/msun/src/s_copysignf.c",
+        "upstream-freebsd/lib/msun/src/s_cos.c",
+        "upstream-freebsd/lib/msun/src/s_cosf.c",
+        "upstream-freebsd/lib/msun/src/s_cproj.c",
+        "upstream-freebsd/lib/msun/src/s_cprojf.c",
+        "upstream-freebsd/lib/msun/src/s_cprojl.c",
+        "upstream-freebsd/lib/msun/src/s_creal.c",
+        "upstream-freebsd/lib/msun/src/s_crealf.c",
+        "upstream-freebsd/lib/msun/src/s_creall.c",
+        "upstream-freebsd/lib/msun/src/s_csinh.c",
+        "upstream-freebsd/lib/msun/src/s_csinhf.c",
+        "upstream-freebsd/lib/msun/src/s_csqrt.c",
+        "upstream-freebsd/lib/msun/src/s_csqrtf.c",
+        "upstream-freebsd/lib/msun/src/s_csqrtl.c",
+        "upstream-freebsd/lib/msun/src/s_ctanh.c",
+        "upstream-freebsd/lib/msun/src/s_ctanhf.c",
+        "upstream-freebsd/lib/msun/src/s_erf.c",
+        "upstream-freebsd/lib/msun/src/s_erff.c",
+        "upstream-freebsd/lib/msun/src/s_exp2.c",
+        "upstream-freebsd/lib/msun/src/s_exp2f.c",
+        "upstream-freebsd/lib/msun/src/s_expm1.c",
+        "upstream-freebsd/lib/msun/src/s_expm1f.c",
+        "upstream-freebsd/lib/msun/src/s_fdim.c",
+        "upstream-freebsd/lib/msun/src/s_finite.c",
+        "upstream-freebsd/lib/msun/src/s_finitef.c",
+        "upstream-freebsd/lib/msun/src/s_floor.c",
+        "upstream-freebsd/lib/msun/src/s_floorf.c",
+        "upstream-freebsd/lib/msun/src/s_fma.c",
+        "upstream-freebsd/lib/msun/src/s_fmaf.c",
+        "upstream-freebsd/lib/msun/src/s_fmax.c",
+        "upstream-freebsd/lib/msun/src/s_fmaxf.c",
+        "upstream-freebsd/lib/msun/src/s_fmin.c",
+        "upstream-freebsd/lib/msun/src/s_fminf.c",
+        "upstream-freebsd/lib/msun/src/s_frexp.c",
+        "upstream-freebsd/lib/msun/src/s_frexpf.c",
+        "upstream-freebsd/lib/msun/src/s_ilogb.c",
+        "upstream-freebsd/lib/msun/src/s_ilogbf.c",
+        "upstream-freebsd/lib/msun/src/s_llrint.c",
+        "upstream-freebsd/lib/msun/src/s_llrintf.c",
+        "upstream-freebsd/lib/msun/src/s_llround.c",
+        "upstream-freebsd/lib/msun/src/s_llroundf.c",
+        "upstream-freebsd/lib/msun/src/s_log1p.c",
+        "upstream-freebsd/lib/msun/src/s_log1pf.c",
+        "upstream-freebsd/lib/msun/src/s_logb.c",
+        "upstream-freebsd/lib/msun/src/s_logbf.c",
+        "upstream-freebsd/lib/msun/src/s_lrint.c",
+        "upstream-freebsd/lib/msun/src/s_lrintf.c",
+        "upstream-freebsd/lib/msun/src/s_lround.c",
+        "upstream-freebsd/lib/msun/src/s_lroundf.c",
+        "upstream-freebsd/lib/msun/src/s_modf.c",
+        "upstream-freebsd/lib/msun/src/s_modff.c",
+        "upstream-freebsd/lib/msun/src/s_nan.c",
+        "upstream-freebsd/lib/msun/src/s_nearbyint.c",
+        "upstream-freebsd/lib/msun/src/s_nextafter.c",
+        "upstream-freebsd/lib/msun/src/s_nextafterf.c",
+        "upstream-freebsd/lib/msun/src/s_remquo.c",
+        "upstream-freebsd/lib/msun/src/s_remquof.c",
+        "upstream-freebsd/lib/msun/src/s_rint.c",
+        "upstream-freebsd/lib/msun/src/s_rintf.c",
+        "upstream-freebsd/lib/msun/src/s_round.c",
+        "upstream-freebsd/lib/msun/src/s_roundf.c",
+        "upstream-freebsd/lib/msun/src/s_scalbln.c",
+        "upstream-freebsd/lib/msun/src/s_scalbn.c",
+        "upstream-freebsd/lib/msun/src/s_scalbnf.c",
+        "upstream-freebsd/lib/msun/src/s_signgam.c",
+        "upstream-freebsd/lib/msun/src/s_significand.c",
+        "upstream-freebsd/lib/msun/src/s_significandf.c",
+        "upstream-freebsd/lib/msun/src/s_sin.c",
+        "upstream-freebsd/lib/msun/src/s_sinf.c",
+        "upstream-freebsd/lib/msun/src/s_tan.c",
+        "upstream-freebsd/lib/msun/src/s_tanf.c",
+        "upstream-freebsd/lib/msun/src/s_tanh.c",
+        "upstream-freebsd/lib/msun/src/s_tanhf.c",
+        "upstream-freebsd/lib/msun/src/s_tgammaf.c",
+        "upstream-freebsd/lib/msun/src/s_trunc.c",
+        "upstream-freebsd/lib/msun/src/s_truncf.c",
+        "upstream-freebsd/lib/msun/src/w_cabs.c",
+        "upstream-freebsd/lib/msun/src/w_cabsf.c",
+        "upstream-freebsd/lib/msun/src/w_cabsl.c",
+        "upstream-freebsd/lib/msun/src/w_drem.c",
+        "upstream-freebsd/lib/msun/src/w_dremf.c",
 
-    native_coverage: bionic_coverage,
-    sanitize: ["never"],
+        // The FreeBSD complex functions appear to be better, but they're incomplete.
+        // We take the FreeBSD implementations when they exist, but fill out the rest
+        // of <complex.h> from NetBSD...
+        "upstream-netbsd/lib/libm/complex/cacoshl.c",
+        "upstream-netbsd/lib/libm/complex/cacosl.c",
+        "upstream-netbsd/lib/libm/complex/casinhl.c",
+        "upstream-netbsd/lib/libm/complex/casinl.c",
+        "upstream-netbsd/lib/libm/complex/catanhl.c",
+        "upstream-netbsd/lib/libm/complex/catanl.c",
+        "upstream-netbsd/lib/libm/complex/ccoshl.c",
+        "upstream-netbsd/lib/libm/complex/ccosl.c",
+        "upstream-netbsd/lib/libm/complex/cephes_subrl.c",
+        "upstream-netbsd/lib/libm/complex/cexpl.c",
+        "upstream-netbsd/lib/libm/complex/clog.c",
+        "upstream-netbsd/lib/libm/complex/clogf.c",
+        "upstream-netbsd/lib/libm/complex/clogl.c",
+        "upstream-netbsd/lib/libm/complex/cpow.c",
+        "upstream-netbsd/lib/libm/complex/cpowf.c",
+        "upstream-netbsd/lib/libm/complex/cpowl.c",
+        "upstream-netbsd/lib/libm/complex/csinhl.c",
+        "upstream-netbsd/lib/libm/complex/csinl.c",
+        "upstream-netbsd/lib/libm/complex/ctanhl.c",
+        "upstream-netbsd/lib/libm/complex/ctanl.c",
+
+        // TODO: this comes from from upstream's libc, not libm, but it's an
+        // implementation detail that should have hidden visibility, so it needs
+        // to be in whatever library the math code is in.
+        "digittoint.c",
+
+        // Functionality not in the BSDs.
+        "significandl.c",
+        "sincos.c",
+
+        // Modified versions of BSD code.
+        "signbit.c",
+
+        // Home-grown stuff.
+        "fabs.cpp",
+    ],
 
     multilib: {
         lib32: {
             srcs: ["fake_long_double.c"],
         },
+
         lib64: {
-            srcs: libm_ld128_src_files,
-            local_include_dirs: libm_ld_local_includes,
-            // We'd really like to do this for all architectures, but since this wasn't done
-            // before, these symbols must continue to be exported on LP32 for binary
-            // compatibility.
-            ldflags: ["-Wl,--exclude-libs,libgcc.a"],
+            srcs: [
+                "upstream-freebsd/lib/msun/src/e_acosl.c",
+                "upstream-freebsd/lib/msun/src/e_acoshl.c",
+                "upstream-freebsd/lib/msun/src/e_asinl.c",
+                "upstream-freebsd/lib/msun/src/e_atan2l.c",
+                "upstream-freebsd/lib/msun/src/e_atanhl.c",
+                "upstream-freebsd/lib/msun/src/e_fmodl.c",
+                "upstream-freebsd/lib/msun/src/e_hypotl.c",
+                "upstream-freebsd/lib/msun/src/e_lgammal.c",
+                "upstream-freebsd/lib/msun/src/e_remainderl.c",
+                "upstream-freebsd/lib/msun/src/e_sqrtl.c",
+                "upstream-freebsd/lib/msun/src/s_asinhl.c",
+                "upstream-freebsd/lib/msun/src/s_atanl.c",
+                "upstream-freebsd/lib/msun/src/s_cbrtl.c",
+                "upstream-freebsd/lib/msun/src/s_ceill.c",
+                "upstream-freebsd/lib/msun/src/s_copysignl.c",
+                "upstream-freebsd/lib/msun/src/e_coshl.c",
+                "upstream-freebsd/lib/msun/src/s_cosl.c",
+                "upstream-freebsd/lib/msun/src/s_floorl.c",
+                "upstream-freebsd/lib/msun/src/s_fmal.c",
+                "upstream-freebsd/lib/msun/src/s_fmaxl.c",
+                "upstream-freebsd/lib/msun/src/s_fminl.c",
+                "upstream-freebsd/lib/msun/src/s_modfl.c",
+                "upstream-freebsd/lib/msun/src/s_frexpl.c",
+                "upstream-freebsd/lib/msun/src/s_ilogbl.c",
+                "upstream-freebsd/lib/msun/src/s_llrintl.c",
+                "upstream-freebsd/lib/msun/src/s_llroundl.c",
+                "upstream-freebsd/lib/msun/src/s_logbl.c",
+                "upstream-freebsd/lib/msun/src/s_lrintl.c",
+                "upstream-freebsd/lib/msun/src/s_lroundl.c",
+                "upstream-freebsd/lib/msun/src/s_nextafterl.c",
+                "upstream-freebsd/lib/msun/src/s_nexttoward.c",
+                "upstream-freebsd/lib/msun/src/s_nexttowardf.c",
+                "upstream-freebsd/lib/msun/src/s_remquol.c",
+                "upstream-freebsd/lib/msun/src/s_rintl.c",
+                "upstream-freebsd/lib/msun/src/s_roundl.c",
+                "upstream-freebsd/lib/msun/src/s_scalbnl.c",
+                "upstream-freebsd/lib/msun/src/e_sinhl.c",
+                "upstream-freebsd/lib/msun/src/s_sinl.c",
+                "upstream-freebsd/lib/msun/src/s_tanhl.c",
+                "upstream-freebsd/lib/msun/src/s_tanl.c",
+                "upstream-freebsd/lib/msun/src/s_truncl.c",
+
+                "upstream-freebsd/lib/msun/ld128/invtrig.c",
+                "upstream-freebsd/lib/msun/ld128/e_lgammal_r.c",
+                "upstream-freebsd/lib/msun/ld128/k_cosl.c",
+                "upstream-freebsd/lib/msun/ld128/k_sinl.c",
+                "upstream-freebsd/lib/msun/ld128/k_tanl.c",
+                "upstream-freebsd/lib/msun/ld128/s_erfl.c",
+                "upstream-freebsd/lib/msun/ld128/s_exp2l.c",
+                "upstream-freebsd/lib/msun/ld128/s_expl.c",
+                "upstream-freebsd/lib/msun/ld128/s_logl.c",
+                "upstream-freebsd/lib/msun/ld128/s_nanl.c",
+            ],
+            local_include_dirs: ["upstream-freebsd/lib/msun/ld128/"],
         },
     },
 
@@ -316,6 +291,7 @@
                     "arm/sqrt.S",
                     "arm/floor.S",
                 ],
+
                 exclude_srcs: [
                     "upstream-freebsd/lib/msun/src/e_sqrt.c",
                     "upstream-freebsd/lib/msun/src/e_sqrtf.c",
@@ -387,6 +363,8 @@
                 "x86/libm_reduce_pi04l.S",
                 "x86/libm_sincos_huge.S",
                 "x86/libm_tancot_huge.S",
+                "x86/lrint.S",
+                "x86/lrintf.S",
                 "x86/s_atan.S",
                 "x86/s_cbrt.S",
                 "x86/s_cos.S",
@@ -414,6 +392,8 @@
                 "upstream-freebsd/lib/msun/src/s_cos.c",
                 "upstream-freebsd/lib/msun/src/s_expm1.c",
                 "upstream-freebsd/lib/msun/src/s_log1p.c",
+                "upstream-freebsd/lib/msun/src/s_lrint.c",
+                "upstream-freebsd/lib/msun/src/s_lrintf.c",
                 "upstream-freebsd/lib/msun/src/s_sin.c",
                 "upstream-freebsd/lib/msun/src/s_tan.c",
                 "upstream-freebsd/lib/msun/src/s_tanh.c",
@@ -424,6 +404,8 @@
                     "x86/ceilf.S",
                     "x86/floor.S",
                     "x86/floorf.S",
+                    "x86/rint.S",
+                    "x86/rintf.S",
                     "x86/trunc.S",
                     "x86/truncf.S",
                 ],
@@ -432,13 +414,13 @@
                     "upstream-freebsd/lib/msun/src/s_ceilf.c",
                     "upstream-freebsd/lib/msun/src/s_floor.c",
                     "upstream-freebsd/lib/msun/src/s_floorf.c",
+                    "upstream-freebsd/lib/msun/src/s_rint.c",
+                    "upstream-freebsd/lib/msun/src/s_rintf.c",
                     "upstream-freebsd/lib/msun/src/s_trunc.c",
                     "upstream-freebsd/lib/msun/src/s_truncf.c",
                 ],
             },
             local_include_dirs: ["i387"],
-            // Clang has wrong long double sizes for x86.
-            clang: false,
             ldflags: ["-Wl,--hash-style=both"],
             version_script: "libm.x86.map",
         },
@@ -458,6 +440,8 @@
                 "x86_64/e_log.S",
                 "x86_64/e_pow.S",
                 "x86_64/e_sinh.S",
+                "x86_64/lrint.S",
+                "x86_64/lrintf.S",
                 "x86_64/s_atan.S",
                 "x86_64/s_cbrt.S",
                 "x86_64/s_cos.S",
@@ -485,6 +469,10 @@
                 "upstream-freebsd/lib/msun/src/s_cos.c",
                 "upstream-freebsd/lib/msun/src/s_expm1.c",
                 "upstream-freebsd/lib/msun/src/s_log1p.c",
+                "upstream-freebsd/lib/msun/src/s_llrint.c",
+                "upstream-freebsd/lib/msun/src/s_llrintf.c",
+                "upstream-freebsd/lib/msun/src/s_lrint.c",
+                "upstream-freebsd/lib/msun/src/s_lrintf.c",
                 "upstream-freebsd/lib/msun/src/s_sin.c",
                 "upstream-freebsd/lib/msun/src/s_tan.c",
                 "upstream-freebsd/lib/msun/src/s_tanh.c",
@@ -495,6 +483,8 @@
                     "x86_64/ceilf.S",
                     "x86_64/floor.S",
                     "x86_64/floorf.S",
+                    "x86_64/rint.S",
+                    "x86_64/rintf.S",
                     "x86_64/trunc.S",
                     "x86_64/truncf.S",
                 ],
@@ -503,18 +493,46 @@
                     "upstream-freebsd/lib/msun/src/s_ceilf.c",
                     "upstream-freebsd/lib/msun/src/s_floor.c",
                     "upstream-freebsd/lib/msun/src/s_floorf.c",
+                    "upstream-freebsd/lib/msun/src/s_rint.c",
+                    "upstream-freebsd/lib/msun/src/s_rintf.c",
                     "upstream-freebsd/lib/msun/src/s_trunc.c",
                     "upstream-freebsd/lib/msun/src/s_truncf.c",
                 ],
             },
-            // Clang has wrong long double sizes for x86.
-            clang: false,
             version_script: "libm.x86_64.map",
         },
     },
 
+    local_include_dirs: [
+        "upstream-freebsd/android/include/",
+        "upstream-freebsd/lib/msun/src/",
+    ],
+
+    cflags: [
+        "-D__BIONIC_NO_MATH_INLINES",
+        "-D_BSD_SOURCE",
+        "-DFLT_EVAL_METHOD=0",
+        "-include freebsd-compat.h",
+        "-Werror",
+        "-Wno-missing-braces",
+        "-Wno-parentheses",
+        "-Wno-sign-compare",
+        "-Wno-uninitialized",
+        "-Wno-unknown-pragmas",
+    ],
+
+    include_dirs: ["bionic/libc"],
+    system_shared_libs: ["libc"],
+
+    native_coverage: bionic_coverage,
+    sanitize: {
+        never: true,
+    },
     stl: "none",
 }
 
-// ANDROIDMK TRANSLATION ERROR: unsupported directive
-// endif
+ndk_library {
+    name: "libm.ndk",
+    symbol_file: "libm.map.txt",
+    first_version: "9",
+}
diff --git a/libm/Android.mk b/libm/Android.mk
deleted file mode 100644
index 6575e1e..0000000
--- a/libm/Android.mk
+++ /dev/null
@@ -1,564 +0,0 @@
-ifneq ($(TARGET_USE_PRIVATE_LIBM),true)
-LOCAL_PATH:= $(call my-dir)
-
-bionic_coverage := false
-
-# Clang/llvm has incompatible long double (fp128) for x86_64.
-# https://llvm.org/bugs/show_bug.cgi?id=23897
-ifeq ($(TARGET_ARCH),x86_64)
-libm_clang := false
-endif
-
-# -----------------------------------------------------------------------------
-# libm.a
-# -----------------------------------------------------------------------------
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libm
-
-LOCAL_SRC_FILES := \
-    upstream-freebsd/lib/msun/bsdsrc/b_exp.c \
-    upstream-freebsd/lib/msun/bsdsrc/b_log.c \
-    upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c \
-    upstream-freebsd/lib/msun/src/catrig.c \
-    upstream-freebsd/lib/msun/src/catrigf.c \
-    upstream-freebsd/lib/msun/src/e_acos.c \
-    upstream-freebsd/lib/msun/src/e_acosf.c \
-    upstream-freebsd/lib/msun/src/e_acosh.c \
-    upstream-freebsd/lib/msun/src/e_acoshf.c \
-    upstream-freebsd/lib/msun/src/e_asin.c \
-    upstream-freebsd/lib/msun/src/e_asinf.c \
-    upstream-freebsd/lib/msun/src/e_atan2.c \
-    upstream-freebsd/lib/msun/src/e_atan2f.c \
-    upstream-freebsd/lib/msun/src/e_atanh.c \
-    upstream-freebsd/lib/msun/src/e_atanhf.c \
-    upstream-freebsd/lib/msun/src/e_cosh.c \
-    upstream-freebsd/lib/msun/src/e_coshf.c \
-    upstream-freebsd/lib/msun/src/e_exp.c \
-    upstream-freebsd/lib/msun/src/e_expf.c \
-    upstream-freebsd/lib/msun/src/e_fmod.c \
-    upstream-freebsd/lib/msun/src/e_fmodf.c \
-    upstream-freebsd/lib/msun/src/e_gamma.c \
-    upstream-freebsd/lib/msun/src/e_gammaf.c \
-    upstream-freebsd/lib/msun/src/e_gammaf_r.c \
-    upstream-freebsd/lib/msun/src/e_gamma_r.c \
-    upstream-freebsd/lib/msun/src/e_hypot.c \
-    upstream-freebsd/lib/msun/src/e_hypotf.c \
-    upstream-freebsd/lib/msun/src/e_j0.c \
-    upstream-freebsd/lib/msun/src/e_j0f.c \
-    upstream-freebsd/lib/msun/src/e_j1.c \
-    upstream-freebsd/lib/msun/src/e_j1f.c \
-    upstream-freebsd/lib/msun/src/e_jn.c \
-    upstream-freebsd/lib/msun/src/e_jnf.c \
-    upstream-freebsd/lib/msun/src/e_lgamma.c \
-    upstream-freebsd/lib/msun/src/e_lgammaf.c \
-    upstream-freebsd/lib/msun/src/e_lgammaf_r.c \
-    upstream-freebsd/lib/msun/src/e_lgamma_r.c \
-    upstream-freebsd/lib/msun/src/e_log10.c \
-    upstream-freebsd/lib/msun/src/e_log10f.c \
-    upstream-freebsd/lib/msun/src/e_log2.c \
-    upstream-freebsd/lib/msun/src/e_log2f.c \
-    upstream-freebsd/lib/msun/src/e_log.c \
-    upstream-freebsd/lib/msun/src/e_logf.c \
-    upstream-freebsd/lib/msun/src/e_pow.c \
-    upstream-freebsd/lib/msun/src/e_powf.c \
-    upstream-freebsd/lib/msun/src/e_remainder.c \
-    upstream-freebsd/lib/msun/src/e_remainderf.c \
-    upstream-freebsd/lib/msun/src/e_rem_pio2.c \
-    upstream-freebsd/lib/msun/src/e_rem_pio2f.c \
-    upstream-freebsd/lib/msun/src/e_scalb.c \
-    upstream-freebsd/lib/msun/src/e_scalbf.c \
-    upstream-freebsd/lib/msun/src/e_sinh.c \
-    upstream-freebsd/lib/msun/src/e_sinhf.c \
-    upstream-freebsd/lib/msun/src/e_sqrt.c \
-    upstream-freebsd/lib/msun/src/e_sqrtf.c \
-    upstream-freebsd/lib/msun/src/imprecise.c \
-    upstream-freebsd/lib/msun/src/k_cos.c \
-    upstream-freebsd/lib/msun/src/k_cosf.c \
-    upstream-freebsd/lib/msun/src/k_exp.c \
-    upstream-freebsd/lib/msun/src/k_expf.c \
-    upstream-freebsd/lib/msun/src/k_rem_pio2.c \
-    upstream-freebsd/lib/msun/src/k_sin.c \
-    upstream-freebsd/lib/msun/src/k_sinf.c \
-    upstream-freebsd/lib/msun/src/k_tan.c \
-    upstream-freebsd/lib/msun/src/k_tanf.c \
-    upstream-freebsd/lib/msun/src/s_asinh.c \
-    upstream-freebsd/lib/msun/src/s_asinhf.c \
-    upstream-freebsd/lib/msun/src/s_atan.c \
-    upstream-freebsd/lib/msun/src/s_atanf.c \
-    upstream-freebsd/lib/msun/src/s_carg.c \
-    upstream-freebsd/lib/msun/src/s_cargf.c \
-    upstream-freebsd/lib/msun/src/s_cargl.c \
-    upstream-freebsd/lib/msun/src/s_cbrt.c \
-    upstream-freebsd/lib/msun/src/s_cbrtf.c \
-    upstream-freebsd/lib/msun/src/s_ccosh.c \
-    upstream-freebsd/lib/msun/src/s_ccoshf.c \
-    upstream-freebsd/lib/msun/src/s_ceil.c \
-    upstream-freebsd/lib/msun/src/s_ceilf.c \
-    upstream-freebsd/lib/msun/src/s_cexp.c \
-    upstream-freebsd/lib/msun/src/s_cexpf.c \
-    upstream-freebsd/lib/msun/src/s_cimag.c \
-    upstream-freebsd/lib/msun/src/s_cimagf.c \
-    upstream-freebsd/lib/msun/src/s_cimagl.c \
-    upstream-freebsd/lib/msun/src/s_conj.c \
-    upstream-freebsd/lib/msun/src/s_conjf.c \
-    upstream-freebsd/lib/msun/src/s_conjl.c \
-    upstream-freebsd/lib/msun/src/s_copysign.c \
-    upstream-freebsd/lib/msun/src/s_copysignf.c \
-    upstream-freebsd/lib/msun/src/s_cos.c \
-    upstream-freebsd/lib/msun/src/s_cosf.c \
-    upstream-freebsd/lib/msun/src/s_cproj.c \
-    upstream-freebsd/lib/msun/src/s_cprojf.c \
-    upstream-freebsd/lib/msun/src/s_cprojl.c \
-    upstream-freebsd/lib/msun/src/s_creal.c \
-    upstream-freebsd/lib/msun/src/s_crealf.c \
-    upstream-freebsd/lib/msun/src/s_creall.c \
-    upstream-freebsd/lib/msun/src/s_csinh.c \
-    upstream-freebsd/lib/msun/src/s_csinhf.c \
-    upstream-freebsd/lib/msun/src/s_csqrt.c \
-    upstream-freebsd/lib/msun/src/s_csqrtf.c \
-    upstream-freebsd/lib/msun/src/s_csqrtl.c \
-    upstream-freebsd/lib/msun/src/s_ctanh.c \
-    upstream-freebsd/lib/msun/src/s_ctanhf.c \
-    upstream-freebsd/lib/msun/src/s_erf.c \
-    upstream-freebsd/lib/msun/src/s_erff.c \
-    upstream-freebsd/lib/msun/src/s_exp2.c \
-    upstream-freebsd/lib/msun/src/s_exp2f.c \
-    upstream-freebsd/lib/msun/src/s_expm1.c \
-    upstream-freebsd/lib/msun/src/s_expm1f.c \
-    upstream-freebsd/lib/msun/src/s_fdim.c \
-    upstream-freebsd/lib/msun/src/s_finite.c \
-    upstream-freebsd/lib/msun/src/s_finitef.c \
-    upstream-freebsd/lib/msun/src/s_floor.c \
-    upstream-freebsd/lib/msun/src/s_floorf.c \
-    upstream-freebsd/lib/msun/src/s_fma.c \
-    upstream-freebsd/lib/msun/src/s_fmaf.c \
-    upstream-freebsd/lib/msun/src/s_fmax.c \
-    upstream-freebsd/lib/msun/src/s_fmaxf.c \
-    upstream-freebsd/lib/msun/src/s_fmin.c \
-    upstream-freebsd/lib/msun/src/s_fminf.c \
-    upstream-freebsd/lib/msun/src/s_frexp.c \
-    upstream-freebsd/lib/msun/src/s_frexpf.c \
-    upstream-freebsd/lib/msun/src/s_ilogb.c \
-    upstream-freebsd/lib/msun/src/s_ilogbf.c \
-    upstream-freebsd/lib/msun/src/s_llrint.c \
-    upstream-freebsd/lib/msun/src/s_llrintf.c \
-    upstream-freebsd/lib/msun/src/s_llround.c \
-    upstream-freebsd/lib/msun/src/s_llroundf.c \
-    upstream-freebsd/lib/msun/src/s_log1p.c \
-    upstream-freebsd/lib/msun/src/s_log1pf.c \
-    upstream-freebsd/lib/msun/src/s_logb.c \
-    upstream-freebsd/lib/msun/src/s_logbf.c \
-    upstream-freebsd/lib/msun/src/s_lrint.c \
-    upstream-freebsd/lib/msun/src/s_lrintf.c \
-    upstream-freebsd/lib/msun/src/s_lround.c \
-    upstream-freebsd/lib/msun/src/s_lroundf.c \
-    upstream-freebsd/lib/msun/src/s_modf.c \
-    upstream-freebsd/lib/msun/src/s_modff.c \
-    upstream-freebsd/lib/msun/src/s_nan.c \
-    upstream-freebsd/lib/msun/src/s_nearbyint.c \
-    upstream-freebsd/lib/msun/src/s_nextafter.c \
-    upstream-freebsd/lib/msun/src/s_nextafterf.c \
-    upstream-freebsd/lib/msun/src/s_remquo.c \
-    upstream-freebsd/lib/msun/src/s_remquof.c \
-    upstream-freebsd/lib/msun/src/s_rint.c \
-    upstream-freebsd/lib/msun/src/s_rintf.c \
-    upstream-freebsd/lib/msun/src/s_round.c \
-    upstream-freebsd/lib/msun/src/s_roundf.c \
-    upstream-freebsd/lib/msun/src/s_scalbln.c \
-    upstream-freebsd/lib/msun/src/s_scalbn.c \
-    upstream-freebsd/lib/msun/src/s_scalbnf.c \
-    upstream-freebsd/lib/msun/src/s_signgam.c \
-    upstream-freebsd/lib/msun/src/s_significand.c \
-    upstream-freebsd/lib/msun/src/s_significandf.c \
-    upstream-freebsd/lib/msun/src/s_sin.c \
-    upstream-freebsd/lib/msun/src/s_sinf.c \
-    upstream-freebsd/lib/msun/src/s_tan.c \
-    upstream-freebsd/lib/msun/src/s_tanf.c \
-    upstream-freebsd/lib/msun/src/s_tanh.c \
-    upstream-freebsd/lib/msun/src/s_tanhf.c \
-    upstream-freebsd/lib/msun/src/s_tgammaf.c \
-    upstream-freebsd/lib/msun/src/s_trunc.c \
-    upstream-freebsd/lib/msun/src/s_truncf.c \
-    upstream-freebsd/lib/msun/src/w_cabs.c \
-    upstream-freebsd/lib/msun/src/w_cabsf.c \
-    upstream-freebsd/lib/msun/src/w_cabsl.c \
-    upstream-freebsd/lib/msun/src/w_drem.c \
-    upstream-freebsd/lib/msun/src/w_dremf.c \
-
-LOCAL_SRC_FILES_32 += \
-    fake_long_double.c \
-
-LOCAL_SRC_FILES_64 := \
-    upstream-freebsd/lib/msun/src/e_acosl.c \
-    upstream-freebsd/lib/msun/src/e_acoshl.c \
-    upstream-freebsd/lib/msun/src/e_asinl.c \
-    upstream-freebsd/lib/msun/src/e_atan2l.c \
-    upstream-freebsd/lib/msun/src/e_atanhl.c \
-    upstream-freebsd/lib/msun/src/e_fmodl.c \
-    upstream-freebsd/lib/msun/src/e_hypotl.c \
-    upstream-freebsd/lib/msun/src/e_lgammal.c \
-    upstream-freebsd/lib/msun/src/e_remainderl.c \
-    upstream-freebsd/lib/msun/src/e_sqrtl.c \
-    upstream-freebsd/lib/msun/src/s_asinhl.c \
-    upstream-freebsd/lib/msun/src/s_atanl.c \
-    upstream-freebsd/lib/msun/src/s_cbrtl.c \
-    upstream-freebsd/lib/msun/src/s_ceill.c \
-    upstream-freebsd/lib/msun/src/s_copysignl.c \
-    upstream-freebsd/lib/msun/src/e_coshl.c \
-    upstream-freebsd/lib/msun/src/s_cosl.c \
-    upstream-freebsd/lib/msun/src/s_floorl.c \
-    upstream-freebsd/lib/msun/src/s_fmal.c \
-    upstream-freebsd/lib/msun/src/s_fmaxl.c \
-    upstream-freebsd/lib/msun/src/s_fminl.c \
-    upstream-freebsd/lib/msun/src/s_modfl.c \
-    upstream-freebsd/lib/msun/src/s_frexpl.c \
-    upstream-freebsd/lib/msun/src/s_ilogbl.c \
-    upstream-freebsd/lib/msun/src/s_llrintl.c \
-    upstream-freebsd/lib/msun/src/s_llroundl.c \
-    upstream-freebsd/lib/msun/src/s_logbl.c \
-    upstream-freebsd/lib/msun/src/s_lrintl.c \
-    upstream-freebsd/lib/msun/src/s_lroundl.c \
-    upstream-freebsd/lib/msun/src/s_nextafterl.c \
-    upstream-freebsd/lib/msun/src/s_nexttoward.c \
-    upstream-freebsd/lib/msun/src/s_nexttowardf.c \
-    upstream-freebsd/lib/msun/src/s_remquol.c \
-    upstream-freebsd/lib/msun/src/s_rintl.c \
-    upstream-freebsd/lib/msun/src/s_roundl.c \
-    upstream-freebsd/lib/msun/src/s_scalbnl.c \
-    upstream-freebsd/lib/msun/src/e_sinhl.c \
-    upstream-freebsd/lib/msun/src/s_sinl.c \
-    upstream-freebsd/lib/msun/src/s_tanhl.c \
-    upstream-freebsd/lib/msun/src/s_tanl.c \
-    upstream-freebsd/lib/msun/src/s_truncl.c \
-
-LOCAL_SRC_FILES_64 += \
-    upstream-freebsd/lib/msun/ld128/invtrig.c \
-    upstream-freebsd/lib/msun/ld128/e_lgammal_r.c \
-    upstream-freebsd/lib/msun/ld128/k_cosl.c \
-    upstream-freebsd/lib/msun/ld128/k_sinl.c \
-    upstream-freebsd/lib/msun/ld128/k_tanl.c \
-    upstream-freebsd/lib/msun/ld128/s_erfl.c \
-    upstream-freebsd/lib/msun/ld128/s_exp2l.c \
-    upstream-freebsd/lib/msun/ld128/s_expl.c \
-    upstream-freebsd/lib/msun/ld128/s_logl.c \
-    upstream-freebsd/lib/msun/ld128/s_nanl.c \
-
-# TODO: this comes from from upstream's libc, not libm, but it's an
-# implementation detail that should have hidden visibility, so it needs
-# to be in whatever library the math code is in.
-LOCAL_SRC_FILES += \
-    digittoint.c  \
-
-# Functionality not in the BSDs.
-LOCAL_SRC_FILES += \
-    significandl.c \
-    sincos.c \
-
-# Modified versions of BSD code.
-LOCAL_SRC_FILES += \
-    signbit.c \
-
-# Home-grown stuff.
-LOCAL_SRC_FILES += \
-    fabs.cpp \
-
-# Arch specific optimizations.
-
-# -----------------------------------------------------------------------------
-# arm
-# -----------------------------------------------------------------------------
-LOCAL_SRC_FILES_arm += \
-    arm/fenv.c \
-
-# s_floor.S requires neon instructions.
-ifdef TARGET_2ND_ARCH
-arch_variant := $(TARGET_2ND_ARCH_VARIANT)
-else
-arch_variant := $(TARGET_ARCH_VARIANT)
-endif
-
-# Use the C version on armv7-a since it doesn't support neon instructions.
-ifneq ($(arch_variant),armv7-a)
-LOCAL_SRC_FILES_arm += \
-    arm/sqrt.S \
-    arm/floor.S \
-
-LOCAL_SRC_FILES_EXCLUDE_arm += \
-    upstream-freebsd/lib/msun/src/e_sqrt.c \
-    upstream-freebsd/lib/msun/src/e_sqrtf.c \
-    upstream-freebsd/lib/msun/src/s_floor.c \
-
-endif
-
-# -----------------------------------------------------------------------------
-# arm64
-# -----------------------------------------------------------------------------
-LOCAL_SRC_FILES_arm64 += \
-    arm64/ceil.S \
-    arm64/fenv.c \
-    arm64/fma.S \
-    arm64/floor.S \
-    arm64/lrint.S \
-    arm64/rint.S \
-    arm64/sqrt.S \
-    arm64/trunc.S \
-
-LOCAL_SRC_FILES_EXCLUDE_arm64 += \
-    upstream-freebsd/lib/msun/src/e_sqrt.c \
-    upstream-freebsd/lib/msun/src/e_sqrtf.c \
-    upstream-freebsd/lib/msun/src/s_ceil.c \
-    upstream-freebsd/lib/msun/src/s_ceilf.c \
-    upstream-freebsd/lib/msun/src/s_fma.c \
-    upstream-freebsd/lib/msun/src/s_fmaf.c \
-    upstream-freebsd/lib/msun/src/s_floor.c \
-    upstream-freebsd/lib/msun/src/s_floorf.c \
-    upstream-freebsd/lib/msun/src/s_llrint.c \
-    upstream-freebsd/lib/msun/src/s_llrintf.c \
-    upstream-freebsd/lib/msun/src/s_lrint.c \
-    upstream-freebsd/lib/msun/src/s_lrintf.c \
-    upstream-freebsd/lib/msun/src/s_rint.c \
-    upstream-freebsd/lib/msun/src/s_rintf.c \
-    upstream-freebsd/lib/msun/src/s_trunc.c \
-    upstream-freebsd/lib/msun/src/s_truncf.c \
-
-# -----------------------------------------------------------------------------
-# mips
-# -----------------------------------------------------------------------------
-libm_mips_arch_files := \
-    mips/fenv.c \
-
-LOCAL_SRC_FILES_mips += $(libm_mips_arch_files)
-LOCAL_SRC_FILES_mips64 += $(libm_mips_arch_files)
-
-# -----------------------------------------------------------------------------
-# x86
-# -----------------------------------------------------------------------------
-LOCAL_SRC_FILES_x86 += \
-    i387/fenv.c \
-    x86/sqrt.S \
-    x86/sqrtf.S \
-    x86/e_acos.S \
-    x86/e_asin.S \
-    x86/e_atan2.S \
-    x86/e_cosh.S \
-    x86/e_exp.S \
-    x86/e_hypot.S \
-    x86/e_log10.S \
-    x86/e_log.S \
-    x86/e_pow.S \
-    x86/e_sinh.S \
-    x86/libm_reduce_pi04l.S \
-    x86/libm_sincos_huge.S \
-    x86/libm_tancot_huge.S \
-    x86/lrint.S \
-    x86/lrintf.S \
-    x86/s_atan.S \
-    x86/s_cbrt.S \
-    x86/s_cos.S \
-    x86/s_expm1.S \
-    x86/s_log1p.S \
-    x86/s_sin.S \
-    x86/s_tanh.S \
-    x86/s_tan.S \
-
-LOCAL_SRC_FILES_EXCLUDE_x86 += \
-    upstream-freebsd/lib/msun/src/e_acos.c \
-    upstream-freebsd/lib/msun/src/e_asin.c \
-    upstream-freebsd/lib/msun/src/e_atan2.c \
-    upstream-freebsd/lib/msun/src/e_cosh.c \
-    upstream-freebsd/lib/msun/src/e_exp.c \
-    upstream-freebsd/lib/msun/src/e_hypot.c \
-    upstream-freebsd/lib/msun/src/e_log.c \
-    upstream-freebsd/lib/msun/src/e_log10.c \
-    upstream-freebsd/lib/msun/src/e_pow.c \
-    upstream-freebsd/lib/msun/src/e_sinh.c \
-    upstream-freebsd/lib/msun/src/e_sqrt.c \
-    upstream-freebsd/lib/msun/src/e_sqrtf.c \
-    upstream-freebsd/lib/msun/src/s_atan.c \
-    upstream-freebsd/lib/msun/src/s_cbrt.c \
-    upstream-freebsd/lib/msun/src/s_cos.c \
-    upstream-freebsd/lib/msun/src/s_expm1.c \
-    upstream-freebsd/lib/msun/src/s_log1p.c \
-    upstream-freebsd/lib/msun/src/s_lrint.c \
-    upstream-freebsd/lib/msun/src/s_lrintf.c \
-    upstream-freebsd/lib/msun/src/s_sin.c \
-    upstream-freebsd/lib/msun/src/s_tan.c \
-    upstream-freebsd/lib/msun/src/s_tanh.c \
-
-ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
-LOCAL_SRC_FILES_x86 += \
-    x86/ceil.S \
-    x86/ceilf.S \
-    x86/floor.S \
-    x86/floorf.S \
-    x86/rint.S \
-    x86/rintf.S \
-    x86/trunc.S \
-    x86/truncf.S \
-
-LOCAL_SRC_FILES_EXCLUDE_x86 += \
-    upstream-freebsd/lib/msun/src/s_ceil.c \
-    upstream-freebsd/lib/msun/src/s_ceilf.c \
-    upstream-freebsd/lib/msun/src/s_floor.c \
-    upstream-freebsd/lib/msun/src/s_floorf.c \
-    upstream-freebsd/lib/msun/src/s_rint.c \
-    upstream-freebsd/lib/msun/src/s_rintf.c \
-    upstream-freebsd/lib/msun/src/s_trunc.c \
-    upstream-freebsd/lib/msun/src/s_truncf.c \
-
-endif
-
-# -----------------------------------------------------------------------------
-# x86_64
-# -----------------------------------------------------------------------------
-LOCAL_SRC_FILES_x86_64 += \
-    amd64/fenv.c \
-    x86_64/sqrt.S \
-    x86_64/sqrtf.S \
-    x86_64/e_acos.S \
-    x86_64/e_asin.S \
-    x86_64/e_atan2.S \
-    x86_64/e_cosh.S \
-    x86_64/e_exp.S \
-    x86_64/e_hypot.S \
-    x86_64/e_log10.S \
-    x86_64/e_log.S \
-    x86_64/e_pow.S \
-    x86_64/e_sinh.S \
-    x86_64/lrint.S \
-    x86_64/lrintf.S \
-    x86_64/s_atan.S \
-    x86_64/s_cbrt.S \
-    x86_64/s_cos.S \
-    x86_64/s_expm1.S \
-    x86_64/s_log1p.S \
-    x86_64/s_sin.S \
-    x86_64/s_tanh.S \
-    x86_64/s_tan.S \
-
-LOCAL_SRC_FILES_EXCLUDE_x86_64 += \
-    upstream-freebsd/lib/msun/src/e_acos.c \
-    upstream-freebsd/lib/msun/src/e_asin.c \
-    upstream-freebsd/lib/msun/src/e_atan2.c \
-    upstream-freebsd/lib/msun/src/e_cosh.c \
-    upstream-freebsd/lib/msun/src/e_exp.c \
-    upstream-freebsd/lib/msun/src/e_hypot.c \
-    upstream-freebsd/lib/msun/src/e_log.c \
-    upstream-freebsd/lib/msun/src/e_log10.c \
-    upstream-freebsd/lib/msun/src/e_pow.c \
-    upstream-freebsd/lib/msun/src/e_sinh.c \
-    upstream-freebsd/lib/msun/src/e_sqrt.c \
-    upstream-freebsd/lib/msun/src/e_sqrtf.c \
-    upstream-freebsd/lib/msun/src/s_atan.c \
-    upstream-freebsd/lib/msun/src/s_cbrt.c \
-    upstream-freebsd/lib/msun/src/s_cos.c \
-    upstream-freebsd/lib/msun/src/s_expm1.c \
-    upstream-freebsd/lib/msun/src/s_log1p.c \
-    upstream-freebsd/lib/msun/src/s_llrint.c \
-    upstream-freebsd/lib/msun/src/s_llrintf.c \
-    upstream-freebsd/lib/msun/src/s_lrint.c \
-    upstream-freebsd/lib/msun/src/s_lrintf.c \
-    upstream-freebsd/lib/msun/src/s_sin.c \
-    upstream-freebsd/lib/msun/src/s_tan.c \
-    upstream-freebsd/lib/msun/src/s_tanh.c \
-
-ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
-LOCAL_SRC_FILES_x86_64 += \
-    x86_64/ceil.S \
-    x86_64/ceilf.S \
-    x86_64/floor.S \
-    x86_64/floorf.S \
-    x86_64/rint.S \
-    x86_64/rintf.S \
-    x86_64/trunc.S \
-    x86_64/truncf.S \
-
-LOCAL_SRC_FILES_EXCLUDE_x86_64 += \
-    upstream-freebsd/lib/msun/src/s_ceil.c \
-    upstream-freebsd/lib/msun/src/s_ceilf.c \
-    upstream-freebsd/lib/msun/src/s_floor.c \
-    upstream-freebsd/lib/msun/src/s_floorf.c \
-    upstream-freebsd/lib/msun/src/s_rint.c \
-    upstream-freebsd/lib/msun/src/s_rintf.c \
-    upstream-freebsd/lib/msun/src/s_trunc.c \
-    upstream-freebsd/lib/msun/src/s_truncf.c \
-
-endif
-
-LOCAL_C_INCLUDES_x86 += $(LOCAL_PATH)/i387
-
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/upstream-freebsd/lib/msun/src/
-LOCAL_C_INCLUDES_64 += $(LOCAL_PATH)/upstream-freebsd/lib/msun/ld128/
-
-LOCAL_CLANG := $(libm_clang)
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := \
-    -D__BIONIC_NO_MATH_INLINES \
-    -DFLT_EVAL_METHOD=0 \
-    -include $(LOCAL_PATH)/freebsd-compat.h \
-    -Werror \
-    -Wno-missing-braces \
-    -Wno-parentheses \
-    -Wno-sign-compare \
-    -Wno-uninitialized \
-    -Wno-unknown-pragmas \
-    -fvisibility=hidden \
-
-LOCAL_ASFLAGS := \
-    -Ibionic/libc \
-
-# Workaround the GCC "(long)fn -> lfn" optimization bug which will result in
-# self recursions for lrint, lrintf, and lrintl.
-# BUG: 14225968
-LOCAL_CFLAGS += \
-    -fno-builtin-rint \
-    -fno-builtin-rintf \
-    -fno-builtin-rintl \
-
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-LOCAL_SANITIZE := never
-include $(BUILD_STATIC_LIBRARY)
-
-# -----------------------------------------------------------------------------
-# libm.so
-# -----------------------------------------------------------------------------
-include $(CLEAR_VARS)
-
-LOCAL_ADDITIONAL_DEPENDENCIES := \
-    $(LOCAL_PATH)/libm.arm.map \
-    $(LOCAL_PATH)/libm.arm64.map \
-    $(LOCAL_PATH)/libm.mips.map \
-    $(LOCAL_PATH)/libm.mips64.map \
-    $(LOCAL_PATH)/libm.x86.map \
-    $(LOCAL_PATH)/libm.x86_64.map \
-
-# TODO: This is to work around b/24465209. Remove after root cause is fixed
-LOCAL_LDFLAGS_arm := -Wl,--hash-style=both
-LOCAL_LDFLAGS_x86 := -Wl,--hash-style=both
-
-LOCAL_LDFLAGS_arm    += -Wl,--version-script,$(LOCAL_PATH)/libm.arm.map
-LOCAL_LDFLAGS_arm64  += -Wl,--version-script,$(LOCAL_PATH)/libm.arm64.map
-LOCAL_LDFLAGS_mips   += -Wl,--version-script,$(LOCAL_PATH)/libm.mips.map
-LOCAL_LDFLAGS_mips64 += -Wl,--version-script,$(LOCAL_PATH)/libm.mips64.map
-LOCAL_LDFLAGS_x86    += -Wl,--version-script,$(LOCAL_PATH)/libm.x86.map
-LOCAL_LDFLAGS_x86_64 += -Wl,--version-script,$(LOCAL_PATH)/libm.x86_64.map
-
-
-LOCAL_MODULE := libm
-LOCAL_CLANG := $(libm_clang)
-LOCAL_SYSTEM_SHARED_LIBRARIES := libc
-LOCAL_WHOLE_STATIC_LIBRARIES := libm
-
-LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
-LOCAL_SANITIZE := never
-
-LOCAL_CXX_STL := none
-
-# We'd really like to do this for all architectures, but since this wasn't done
-# before, these symbols must continue to be exported on LP32 for binary
-# compatibility.
-LOCAL_LDFLAGS_64 := -Wl,--exclude-libs,libgcc.a
-
-include $(BUILD_SHARED_LIBRARY)
-endif
diff --git a/libm/NOTICE b/libm/NOTICE
deleted file mode 100644
index c254c08..0000000
--- a/libm/NOTICE
+++ /dev/null
@@ -1,1108 +0,0 @@
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
-Developed at SunPro, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
-Developed at SunPro, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-====================================================
-
-Optimized by Bruce D. Evans.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
-Developed at SunSoft, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
-Developed at SunSoft, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-====================================================
-
-Optimized by Bruce D. Evans.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
-
-Developed at SunSoft, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
-
-Developed at SunSoft, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-====================================================
-
-Optimized by Bruce D. Evans.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-Copyright (c) 2009-2011, Bruce D. Evans, Steven G. Kargl, David Schultz.
-
-Developed at SunPro, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-====================================================
-
-The argument reduction and testing for exceptional cases was
-written by Steven G. Kargl with input from Bruce D. Evans
-and David A. Schultz.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
-
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
-
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-====================================================
-Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
-Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
-
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-Copyright (C) 2010 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (C) 2013 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
-Copyright (C) 2014 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (C) 2015 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
-Copyright (c) 1985, 1993
-   The Regents of the University of California.  All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-   This product includes software developed by the University of
-   California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1988, 1993
-   The Regents of the University of California.  All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-   This product includes software developed by the University of
-   California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1990 The Regents of the University of California.
-All rights reserved.
-
-This code is derived from software contributed to Berkeley by
-William Jolitz.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1992, 1993
-   The Regents of the University of California.  All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-   This product includes software developed by the University of
-   California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2001-2011 The FreeBSD Project.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2003 Dag-Erling Smørgrav
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer
-   in this position and unchanged.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
-Copyright (c) 2002 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2003, Steven G. Kargl
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice unmodified, this list of conditions, and the following
-   disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2004 Stefan Farfeleder
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice unmodified, this list of conditions, and the following
-   disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2005-2008 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2007 David Schultz
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
-Derived from s_modf.c, which has the following Copyright:
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
-Developed at SunPro, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-Copyright (c) 2007 Steven G. Kargl
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice unmodified, this list of conditions, and the following
-   disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2007-2008 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2007-2013 Bruce D. Evans
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice unmodified, this list of conditions, and the following
-   disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2009-2013 Steven G. Kargl
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice unmodified, this list of conditions, and the following
-   disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Optimized by Bruce D. Evans.
-
--------------------------------------------------------------------
-
-Copyright (c) 2010 The NetBSD Foundation, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2011 David Schultz
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice unmodified, this list of conditions, and the following
-   disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2011 David Schultz <das@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2013 David Chisnall
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2013-2014, NVIDIA Corporation.  All rights reserved.
-Johnny Qiu <joqiu@nvidia.com>
-Shu Zhang <chazhang@nvidia.com>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials provided
-      with the distribution.
-    * Neither the name of The Linux Foundation nor the names of its
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 2014, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice,
-    * this list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above copyright notice,
-    * this list of conditions and the following disclaimer in the documentation
-    * and/or other materials provided with the distribution.
-
-    * Neither the name of Intel Corporation nor the names of its contributors
-    * may be used to endorse or promote products derived from this software
-    * without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright 2015, The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
-From: @(#)s_ilogb.c 5.1 93/09/24
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
-Developed at SunPro, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
diff --git a/libm/amd64/fenv.c b/libm/amd64/fenv.c
index 4b24ff9..9edaf88 100755
--- a/libm/amd64/fenv.c
+++ b/libm/amd64/fenv.c
@@ -28,7 +28,14 @@
  */
 
 #include <fenv.h>
-#include <machine/fpu.h>
+
+/*
+ * The i387 defaults to Intel extended precision mode and round to nearest,
+ * with all exceptions masked.
+ */
+#define	__INITIAL_NPXCW__	0x037f
+#define __INITIAL_MXCSR__ 	0x1f80
+#define __INITIAL_MXCSR_MASK__	0xffbf
 
 #define SSE_MASK_SHIFT 7
 
diff --git a/libm/arm64/ceil.S b/libm/arm64/ceil.S
index 006c988..7217d57 100644
--- a/libm/arm64/ceil.S
+++ b/libm/arm64/ceil.S
@@ -1,11 +1,11 @@
 /*
- * Copyright 2015, The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libm/arm64/floor.S b/libm/arm64/floor.S
index 2d792e5..ca106bd 100644
--- a/libm/arm64/floor.S
+++ b/libm/arm64/floor.S
@@ -1,11 +1,11 @@
 /*
- * Copyright 2015, The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libm/arm64/fma.S b/libm/arm64/fma.S
index e64e807..1a8a158 100644
--- a/libm/arm64/fma.S
+++ b/libm/arm64/fma.S
@@ -1,11 +1,11 @@
 /*
- * Copyright 2015, The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libm/arm64/lrint.S b/libm/arm64/lrint.S
index d642759..5f95ae8 100644
--- a/libm/arm64/lrint.S
+++ b/libm/arm64/lrint.S
@@ -1,11 +1,11 @@
 /*
- * Copyright 2015, The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libm/arm64/rint.S b/libm/arm64/rint.S
index 0820c22..bf49f5b 100644
--- a/libm/arm64/rint.S
+++ b/libm/arm64/rint.S
@@ -1,11 +1,11 @@
 /*
- * Copyright 2015, The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libm/arm64/sqrt.S b/libm/arm64/sqrt.S
index fe0020b..3a58ef3 100644
--- a/libm/arm64/sqrt.S
+++ b/libm/arm64/sqrt.S
@@ -1,11 +1,11 @@
 /*
- * Copyright 2015, The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libm/arm64/trunc.S b/libm/arm64/trunc.S
index 329c08d..aa0d4bd 100644
--- a/libm/arm64/trunc.S
+++ b/libm/arm64/trunc.S
@@ -1,11 +1,11 @@
 /*
- * Copyright 2015, The Android Open Source Project
+ * Copyright (C) 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/libm/i387/fenv.c b/libm/i387/fenv.c
index f64f8dc..09b4386 100644
--- a/libm/i387/fenv.c
+++ b/libm/i387/fenv.c
@@ -28,12 +28,31 @@
 
 #include <sys/cdefs.h>
 #include <sys/types.h>
-#include "npx.h"
 #include "fenv.h"
 
 #define ROUND_MASK   (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)
 
 /*
+ * The hardware default control word for i387's and later coprocessors is
+ * 0x37F, giving:
+ *
+ *	round to nearest
+ *	64-bit precision
+ *	all exceptions masked.
+ *
+ * We modify the affine mode bit and precision bits in this to give:
+ *
+ *	affine mode for 287's (if they work at all) (1 in bitfield 1<<12)
+ *	53-bit precision (2 in bitfield 3<<8)
+ *
+ * 64-bit precision often gives bad results with high level languages
+ * because it makes the results of calculations depend on whether
+ * intermediate values are stored in memory or in FPU registers.
+ */
+#define	__INITIAL_NPXCW__	0x127F
+#define	__INITIAL_MXCSR__	0x1F80
+
+/*
  * As compared to the x87 control word, the SSE unit's control word
  * has the rounding control bits offset by 3 and the exception mask
  * bits offset by 7.
@@ -51,18 +70,18 @@
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff } /*__other*/
 };
 
-#define __fldcw(__cw)           __asm __volatile("fldcw %0" : : "m" (__cw))
-#define __fldenv(__env)         __asm __volatile("fldenv %0" : : "m" (__env))
-#define __fldenvx(__env)        __asm __volatile("fldenv %0" : : "m" (__env)  \
+#define __fldcw(__cw)           __asm volatile("fldcw %0" : : "m" (__cw))
+#define __fldenv(__env)         __asm volatile("fldenv %0" : : "m" (__env))
+#define __fldenvx(__env)        __asm volatile("fldenv %0" : : "m" (__env)  \
                                 : "st", "st(1)", "st(2)", "st(3)", "st(4)",   \
                                 "st(5)", "st(6)", "st(7)")
-#define __fnclex()              __asm __volatile("fnclex")
-#define __fnstenv(__env)        __asm __volatile("fnstenv %0" : "=m" (*(__env)))
-#define __fnstcw(__cw)          __asm __volatile("fnstcw %0" : "=m" (*(__cw)))
-#define __fnstsw(__sw)          __asm __volatile("fnstsw %0" : "=am" (*(__sw)))
-#define __fwait()               __asm __volatile("fwait")
-#define __ldmxcsr(__csr)        __asm __volatile("ldmxcsr %0" : : "m" (__csr))
-#define __stmxcsr(__csr)        __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
+#define __fnclex()              __asm volatile("fnclex")
+#define __fnstenv(__env)        __asm volatile("fnstenv %0" : "=m" (*(__env)))
+#define __fnstcw(__cw)          __asm volatile("fnstcw %0" : "=m" (*(__cw)))
+#define __fnstsw(__sw)          __asm volatile("fnstsw %0" : "=am" (*(__sw)))
+#define __fwait()               __asm volatile("fwait")
+#define __ldmxcsr(__csr)        __asm volatile("ldmxcsr %0" : : "m" (__csr))
+#define __stmxcsr(__csr)        __asm volatile("stmxcsr %0" : "=m" (*(__csr)))
 
 /* After testing for SSE support once, we cache the result in __has_sse. */
 enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
@@ -81,9 +100,9 @@
 #endif
 
 #ifndef __SSE__
-#define getfl(x)    __asm __volatile("pushfl\n\tpopl %0" : "=mr" (*(x)))
-#define setfl(x)    __asm __volatile("pushl %0\n\tpopfl" : : "g" (x))
-#define cpuid_dx(x) __asm __volatile("pushl %%ebx\n\tmovl $1, %%eax\n\t"  \
+#define getfl(x)    __asm volatile("pushfl\n\tpopl %0" : "=mr" (*(x)))
+#define setfl(x)    __asm volatile("pushl %0\n\tpopfl" : : "g" (x))
+#define cpuid_dx(x) __asm volatile("pushl %%ebx\n\tmovl $1, %%eax\n\t"  \
                     "cpuid\n\tpopl %%ebx"          \
                     : "=d" (*(x)) : : "eax", "ecx")
 
diff --git a/libm/i387/npx.h b/libm/i387/npx.h
deleted file mode 100644
index 38c2add..0000000
--- a/libm/i387/npx.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	from: @(#)npx.h	5.3 (Berkeley) 1/18/91
- * $FreeBSD: src/sys/i386/include/npx.h,v 1.29.2.1 2006/07/01 00:57:55 davidxu Exp $
- */
-
-/*
- * 287/387 NPX Coprocessor Data Structures and Constants
- * W. Jolitz 1/90
- */
-
-#ifndef _MACHINE_NPX_H_
-#define	_MACHINE_NPX_H_
-
-/* Environment information of floating point unit */
-struct env87 {
-	long	en_cw;		/* control word (16bits) */
-	long	en_sw;		/* status word (16bits) */
-	long	en_tw;		/* tag word (16bits) */
-	long	en_fip;		/* floating point instruction pointer */
-	u_short	en_fcs;		/* floating code segment selector */
-	u_short	en_opcode;	/* opcode last executed (11 bits ) */
-	long	en_foo;		/* floating operand offset */
-	long	en_fos;		/* floating operand segment selector */
-};
-
-/* Contents of each floating point accumulator */
-struct fpacc87 {
-#ifdef dontdef /* too unportable */
-	u_long	fp_mantlo;	/* mantissa low (31:0) */
-	u_long	fp_manthi;	/* mantissa high (63:32) */
-	int	fp_exp:15;	/* exponent */
-	int	fp_sgn:1;	/* mantissa sign */
-#else
-	u_char	fp_bytes[10];
-#endif
-};
-
-/* Floating point context */
-struct save87 {
-	struct	env87 sv_env;	/* floating point control/status */
-	struct	fpacc87	sv_ac[8];	/* accumulator contents, 0-7 */
-	u_char	sv_pad0[4];	/* padding for (now unused) saved status word */
-	/*
-	 * Bogus padding for emulators.  Emulators should use their own
-	 * struct and arrange to store into this struct (ending here)
-	 * before it is inspected for ptracing or for core dumps.  Some
-	 * emulators overwrite the whole struct.  We have no good way of
-	 * knowing how much padding to leave.  Leave just enough for the
-	 * GPL emulator's i387_union (176 bytes total).
-	 */
-	u_char	sv_pad[64];	/* padding; used by emulators */
-};
-
-struct  envxmm {
-	u_int16_t	en_cw;		/* control word (16bits) */
-	u_int16_t	en_sw;		/* status word (16bits) */
-	u_int16_t	en_tw;		/* tag word (16bits) */
-	u_int16_t	en_opcode;	/* opcode last executed (11 bits ) */
-	u_int32_t	en_fip;		/* floating point instruction pointer */
-	u_int16_t	en_fcs;		/* floating code segment selector */
-	u_int16_t	en_pad0;	/* padding */
-	u_int32_t	en_foo;		/* floating operand offset */
-	u_int16_t	en_fos;		/* floating operand segment selector */
-	u_int16_t	en_pad1;	/* padding */
-	u_int32_t	en_mxcsr;	/* SSE sontorol/status register */
-	u_int32_t	en_mxcsr_mask;	/* valid bits in mxcsr */
-};
-
-/* Contents of each SSE extended accumulator */
-struct  xmmacc {
-	u_char	xmm_bytes[16];
-};
-
-struct  savexmm {
-	struct	envxmm	sv_env;
-	struct {
-		struct fpacc87	fp_acc;
-		u_char		fp_pad[6];      /* padding */
-	} sv_fp[8];
-	struct xmmacc	sv_xmm[8];
-	u_char sv_pad[224];
-} __aligned(16);
-
-union	savefpu {
-	struct	save87	sv_87;
-	struct	savexmm	sv_xmm;
-};
-
-/*
- * The hardware default control word for i387's and later coprocessors is
- * 0x37F, giving:
- *
- *	round to nearest
- *	64-bit precision
- *	all exceptions masked.
- *
- * We modify the affine mode bit and precision bits in this to give:
- *
- *	affine mode for 287's (if they work at all) (1 in bitfield 1<<12)
- *	53-bit precision (2 in bitfield 3<<8)
- *
- * 64-bit precision often gives bad results with high level languages
- * because it makes the results of calculations depend on whether
- * intermediate values are stored in memory or in FPU registers.
- */
-#define	__INITIAL_NPXCW__	0x127F
-#define	__INITIAL_MXCSR__	0x1F80
-
-#ifdef _KERNEL
-
-#define	IO_NPX		0x0F0		/* Numeric Coprocessor */
-#define	IO_NPXSIZE	16		/* 80387/80487 NPX registers */
-
-#define	IRQ_NPX		13
-
-/* full reset on some systems, NOP on others */
-#define npx_full_reset() outb(IO_NPX + 1, 0)
-
-int	npxdna(void);
-void	npxdrop(void);
-void	npxexit(struct thread *td);
-int	npxformat(void);
-int	npxgetregs(struct thread *td, union savefpu *addr);
-void	npxinit(u_short control);
-void	npxsave(union savefpu *addr);
-void	npxsetregs(struct thread *td, union savefpu *addr);
-int	npxtrap(void);
-#endif
-
-#endif /* !_MACHINE_NPX_H_ */
diff --git a/libm/include/amd64/machine/fpu.h b/libm/include/amd64/machine/fpu.h
deleted file mode 100644
index bda8f05..0000000
--- a/libm/include/amd64/machine/fpu.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*	$OpenBSD: fpu.h,v 1.9 2011/03/23 16:54:34 pirofti Exp $	*/
-/*	$NetBSD: fpu.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $	*/
-
-#ifndef	_MACHINE_FPU_H_
-#define	_MACHINE_FPU_H_
-
-#include <sys/types.h>
-
-/*
- * amd64 only uses the extended save/restore format used
- * by fxsave/fsrestore, to always deal with the SSE registers,
- * which are part of the ABI to pass floating point values.
- * Must be stored in memory on a 16-byte boundary.
- */
-
-struct fxsave64 {
-	u_int16_t  fx_fcw;
-	u_int16_t  fx_fsw;
-	u_int8_t   fx_ftw;
-	u_int8_t   fx_unused1;
-	u_int16_t  fx_fop;
-	u_int64_t  fx_rip;
-	u_int64_t  fx_rdp;
-	u_int32_t  fx_mxcsr;
-	u_int32_t  fx_mxcsr_mask;
-	u_int64_t  fx_st[8][2];   /* 8 normal FP regs */
-	u_int64_t  fx_xmm[16][2]; /* 16 SSE2 registers */
-	u_int8_t   fx_unused3[96];
-} __packed;
-
-struct savefpu {
-	struct fxsave64 fp_fxsave;	/* see above */
-	u_int16_t fp_ex_sw;		/* saved status from last exception */
-	u_int16_t fp_ex_tw;		/* saved tag from last exception */
-};
-
-/*
- * The i387 defaults to Intel extended precision mode and round to nearest,
- * with all exceptions masked.
- */
-#define	__INITIAL_NPXCW__	0x037f
-#define __INITIAL_MXCSR__ 	0x1f80
-#define __INITIAL_MXCSR_MASK__	0xffbf
-
-#ifdef _KERNEL
-/*
- * XXX
- */
-struct trapframe;
-struct cpu_info;
-
-extern uint32_t	fpu_mxcsr_mask;
-
-void fpuinit(struct cpu_info *);
-void fpudrop(void);
-void fpudiscard(struct proc *);
-void fputrap(struct trapframe *);
-void fpusave_proc(struct proc *, int);
-void fpusave_cpu(struct cpu_info *, int);
-void fpu_kernel_enter(void);
-void fpu_kernel_exit(void);
-
-#endif
-
-#endif /* _MACHINE_FPU_H_ */
diff --git a/libm/include/complex.h b/libm/include/complex.h
deleted file mode 100644
index ff6b166..0000000
--- a/libm/include/complex.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*-
- * Copyright (c) 2001-2011 The FreeBSD Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _COMPLEX_H
-#define	_COMPLEX_H
-
-#include <sys/cdefs.h>
-
-#ifdef __GNUC__
-#if __STDC_VERSION__ < 199901
-#define	_Complex	__complex__
-#endif
-#define	_Complex_I	((float _Complex)1.0i)
-#endif
-
-#ifdef __generic
-_Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
-    "_Complex_I must be of type float _Complex");
-#endif
-
-#define	complex		_Complex
-#define	I		_Complex_I
-
-#if __ISO_C_VISIBLE >= 2011
-#ifdef __clang__
-#define	CMPLX(x, y)	((double complex){ x, y })
-#define	CMPLXF(x, y)	((float complex){ x, y })
-#define	CMPLXL(x, y)	((long double complex){ x, y })
-#elif __GNUC_PREREQ__(4, 7)
-#define	CMPLX(x, y)	__builtin_complex((double)(x), (double)(y))
-#define	CMPLXF(x, y)	__builtin_complex((float)(x), (float)(y))
-#define	CMPLXL(x, y)	__builtin_complex((long double)(x), (long double)(y))
-#endif
-#endif /* __ISO_C_VISIBLE >= 2011 */
-
-__BEGIN_DECLS
-#pragma GCC visibility push(default)
-
-double		cabs(double complex);
-float		cabsf(float complex);
-long double	cabsl(long double complex);
-double complex	cacos(double complex);
-float complex	cacosf(float complex);
-double complex	cacosh(double complex);
-float complex	cacoshf(float complex);
-double		carg(double complex);
-float		cargf(float complex);
-long double	cargl(long double complex);
-double complex	casin(double complex);
-float complex	casinf(float complex);
-double complex	casinh(double complex);
-float complex	casinhf(float complex);
-double complex	catan(double complex);
-float complex	catanf(float complex);
-double complex	catanh(double complex);
-float complex	catanhf(float complex);
-double complex	ccos(double complex);
-float complex	ccosf(float complex);
-double complex	ccosh(double complex);
-float complex	ccoshf(float complex);
-double complex	cexp(double complex);
-float complex	cexpf(float complex);
-double		cimag(double complex) __pure2;
-float		cimagf(float complex) __pure2;
-long double	cimagl(long double complex) __pure2;
-double complex	conj(double complex) __pure2;
-float complex	conjf(float complex) __pure2;
-long double complex
-		conjl(long double complex) __pure2;
-float complex	cprojf(float complex) __pure2;
-double complex	cproj(double complex) __pure2;
-long double complex
-		cprojl(long double complex) __pure2;
-double		creal(double complex) __pure2;
-float		crealf(float complex) __pure2;
-long double	creall(long double complex) __pure2;
-double complex	csin(double complex);
-float complex	csinf(float complex);
-double complex	csinh(double complex);
-float complex	csinhf(float complex);
-double complex	csqrt(double complex);
-float complex	csqrtf(float complex);
-long double complex
-		csqrtl(long double complex);
-double complex	ctan(double complex);
-float complex	ctanf(float complex);
-double complex	ctanh(double complex);
-float complex	ctanhf(float complex);
-
-#pragma GCC visibility pop
-__END_DECLS
-
-#endif /* _COMPLEX_H */
diff --git a/libm/include/fenv.h b/libm/include/fenv.h
deleted file mode 100644
index 73ecc80..0000000
--- a/libm/include/fenv.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*  $OpenBSD: fenv.h,v 1.2 2011/05/25 21:46:49 martynas Exp $ */
-/*  $NetBSD: fenv.h,v 1.2.4.1 2011/02/08 16:18:55 bouyer Exp $  */
-
-/*
- * Copyright (c) 2010 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _FENV_H_
-#define _FENV_H_
-
-#include <sys/cdefs.h>
-#include <machine/fenv.h>
-
-__BEGIN_DECLS
-#pragma GCC visibility push(default)
-
-int feclearexcept(int);
-int fegetexceptflag(fexcept_t *, int);
-int feraiseexcept(int);
-int fesetexceptflag(const fexcept_t *, int);
-int fetestexcept(int);
-
-int fegetround(void);
-int fesetround(int);
-
-int fegetenv(fenv_t *);
-int feholdexcept(fenv_t *);
-int fesetenv(const fenv_t *);
-int feupdateenv(const fenv_t *);
-
-int feenableexcept(int);
-int fedisableexcept(int);
-int fegetexcept(void);
-
-/*
- * The following constant represents the default floating-point environment
- * (that is, the one installed at program startup) and has type pointer to
- * const-qualified fenv_t.
- *
- * It can be used as an argument to the functions that manage the floating-point
- * environment, namely fesetenv() and feupdateenv().
- */
-extern const fenv_t __fe_dfl_env;
-#define FE_DFL_ENV  (&__fe_dfl_env)
-
-#pragma GCC visibility pop
-__END_DECLS
-
-#endif  /* ! _FENV_H_ */
diff --git a/libm/include/math.h b/libm/include/math.h
deleted file mode 100644
index ce8e3b2..0000000
--- a/libm/include/math.h
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * from: @(#)fdlibm.h 5.1 93/09/24
- * $FreeBSD$
- */
-
-#ifndef _MATH_H_
-#define _MATH_H_
-
-#include <sys/cdefs.h>
-#include <limits.h>
-
-#if !defined(__BIONIC_NO_MATH_INLINES)
-#define __BIONIC_MATH_INLINE(__def) extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__)) __def
-#else
-#define __BIONIC_MATH_INLINE(__def)
-#endif
-
-__BEGIN_DECLS
-#pragma GCC visibility push(default)
-
-#define HUGE_VAL	__builtin_huge_val()
-
-#if __ISO_C_VISIBLE >= 1999
-#define FP_ILOGB0	(-INT_MAX)
-#define FP_ILOGBNAN	INT_MAX
-
-#define HUGE_VALF	__builtin_huge_valf()
-#define HUGE_VALL	__builtin_huge_vall()
-#define INFINITY	__builtin_inff()
-#define NAN		__builtin_nanf("")
-
-#define MATH_ERRNO	1
-#define MATH_ERREXCEPT	2
-#define math_errhandling	MATH_ERREXCEPT
-
-#if defined(__FP_FAST_FMA)
-#define FP_FAST_FMA 1
-#endif
-#if defined(__FP_FAST_FMAF)
-#define FP_FAST_FMAF 1
-#endif
-#if defined(__FP_FAST_FMAL)
-#define FP_FAST_FMAL 1
-#endif
-
-/* Symbolic constants to classify floating point numbers. */
-#define FP_INFINITE	0x01
-#define FP_NAN		0x02
-#define FP_NORMAL	0x04
-#define FP_SUBNORMAL	0x08
-#define FP_ZERO		0x10
-#define fpclassify(x) \
-    __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
-
-#define isfinite(x) __builtin_isfinite(x)
-#define isinf(x) __builtin_isinf(x)
-#define isnan(x) __builtin_isnan(x)
-#define isnormal(x) __builtin_isnormal(x)
-
-#define isgreater(x, y) __builtin_isgreater((x), (y))
-#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
-#define isless(x, y) __builtin_isless((x), (y))
-#define islessequal(x, y) __builtin_islessequal((x), (y))
-#define islessgreater(x, y) __builtin_islessgreater((x), (y))
-#define isunordered(x, y) __builtin_isunordered((x), (y))
-
-#define signbit(x) \
-    ((sizeof(x) == sizeof(float)) ? __builtin_signbitf(x) \
-    : (sizeof(x) == sizeof(double)) ? __builtin_signbit(x) \
-    : __builtin_signbitl(x))
-
-typedef double __double_t;
-typedef __double_t double_t;
-typedef float __float_t;
-typedef __float_t float_t;
-#endif /* __ISO_C_VISIBLE >= 1999 */
-
-/*
- * XOPEN/SVID
- */
-#if __BSD_VISIBLE || __XSI_VISIBLE
-#define	M_E		2.7182818284590452354	/* e */
-#define	M_LOG2E		1.4426950408889634074	/* log 2e */
-#define	M_LOG10E	0.43429448190325182765	/* log 10e */
-#define	M_LN2		0.69314718055994530942	/* log e2 */
-#define	M_LN10		2.30258509299404568402	/* log e10 */
-#define	M_PI		3.14159265358979323846	/* pi */
-#define	M_PI_2		1.57079632679489661923	/* pi/2 */
-#define	M_PI_4		0.78539816339744830962	/* pi/4 */
-#define	M_1_PI		0.31830988618379067154	/* 1/pi */
-#define	M_2_PI		0.63661977236758134308	/* 2/pi */
-#define	M_2_SQRTPI	1.12837916709551257390	/* 2/sqrt(pi) */
-#define	M_SQRT2		1.41421356237309504880	/* sqrt(2) */
-#define	M_SQRT1_2	0.70710678118654752440	/* 1/sqrt(2) */
-
-#define	MAXFLOAT	((float)3.40282346638528860e+38)
-extern int signgam;
-#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
-
-#if __BSD_VISIBLE
-#if 0
-/* Old value from 4.4BSD-Lite math.h; this is probably better. */
-#define	HUGE		HUGE_VAL
-#else
-#define	HUGE		MAXFLOAT
-#endif
-#endif /* __BSD_VISIBLE */
-
-/*
- * Most of these functions depend on the rounding mode and have the side
- * effect of raising floating-point exceptions, so they are not declared
- * as __pure2.  In C99, FENV_ACCESS affects the purity of these functions.
- */
-
-/*
- * ANSI/POSIX
- */
-int	__fpclassifyd(double) __pure2;
-int	__fpclassifyf(float) __pure2;
-int	__fpclassifyl(long double) __pure2;
-int	__isfinitef(float) __pure2;
-int	__isfinite(double) __pure2;
-int	__isfinitel(long double) __pure2;
-int	__isinff(float) __pure2;
-int	__isinfl(long double) __pure2;
-int	__isnanf(float) __pure2;
-int	__isnanl(long double) __pure2;
-int	__isnormalf(float) __pure2;
-int	__isnormal(double) __pure2;
-int	__isnormall(long double) __pure2;
-int	__signbit(double) __pure2;
-int	__signbitf(float) __pure2;
-int	__signbitl(long double) __pure2;
-
-double	acos(double);
-double	asin(double);
-double	atan(double);
-double	atan2(double, double);
-double	cos(double);
-double	sin(double);
-double	tan(double);
-
-double	cosh(double);
-double	sinh(double);
-double	tanh(double);
-
-double	exp(double);
-double	frexp(double, int *);	/* fundamentally !__pure2 */
-double	ldexp(double, int);
-double	log(double);
-double	log10(double);
-double	modf(double, double *);	/* fundamentally !__pure2 */
-
-double	pow(double, double);
-double	sqrt(double);
-
-double	ceil(double);
-double	fabs(double) __pure2;
-__BIONIC_MATH_INLINE(double fabs(double x) { return __builtin_fabs(x); })
-double	floor(double);
-double	fmod(double, double);
-
-/*
- * These functions are not in C90.
- */
-#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
-double	acosh(double);
-double	asinh(double);
-double	atanh(double);
-double	cbrt(double);
-double	erf(double);
-double	erfc(double);
-double	exp2(double);
-double	expm1(double);
-double	fma(double, double, double);
-double	hypot(double, double);
-int	ilogb(double) __pure2;
-int	(isinf)(double) __pure2;
-int	(isnan)(double) __pure2;
-double	lgamma(double);
-long long llrint(double);
-long long llround(double);
-double	log1p(double);
-double	log2(double);
-double	logb(double);
-long	lrint(double);
-long	lround(double);
-double	nan(const char *) __pure2;
-double	nextafter(double, double);
-double	remainder(double, double);
-double	remquo(double, double, int *);
-double	rint(double);
-#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
-
-#if __BSD_VISIBLE || __XSI_VISIBLE
-double	j0(double);
-double	j1(double);
-double	jn(int, double);
-double	y0(double);
-double	y1(double);
-double	yn(int, double);
-
-#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
-double	gamma(double);
-#endif
-
-#if __XSI_VISIBLE <= 600 || __BSD_VISIBLE
-double	scalb(double, double);
-#endif
-#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
-
-#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
-double	copysign(double, double) __pure2;
-double	fdim(double, double);
-double	fmax(double, double) __pure2;
-double	fmin(double, double) __pure2;
-double	nearbyint(double);
-double	round(double);
-double	scalbln(double, long);
-double	scalbn(double, int);
-double	tgamma(double);
-double	trunc(double);
-#endif
-
-/*
- * BSD math library entry points
- */
-#if __BSD_VISIBLE
-double	drem(double, double);
-int	finite(double) __pure2;
-int	isnanf(float) __pure2;
-long double significandl(long double);
-
-/*
- * Reentrant version of gamma & lgamma; passes signgam back by reference
- * as the second argument; user must allocate space for signgam.
- */
-double	gamma_r(double, int *);
-double	lgamma_r(double, int *);
-
-/*
- * IEEE Test Vector
- */
-double	significand(double);
-#endif /* __BSD_VISIBLE */
-
-/* float versions of ANSI/POSIX functions */
-#if __ISO_C_VISIBLE >= 1999
-float	acosf(float);
-float	asinf(float);
-float	atanf(float);
-float	atan2f(float, float);
-float	cosf(float);
-float	sinf(float);
-float	tanf(float);
-
-float	coshf(float);
-float	sinhf(float);
-float	tanhf(float);
-
-float	exp2f(float);
-float	expf(float);
-float	expm1f(float);
-float	frexpf(float, int *);	/* fundamentally !__pure2 */
-int	ilogbf(float) __pure2;
-float	ldexpf(float, int);
-float	log10f(float);
-float	log1pf(float);
-float	log2f(float);
-float	logf(float);
-float	modff(float, float *);	/* fundamentally !__pure2 */
-
-float	powf(float, float);
-float	sqrtf(float);
-
-float	ceilf(float);
-float	fabsf(float) __pure2;
-__BIONIC_MATH_INLINE(float fabsf(float x) { return __builtin_fabsf(x); })
-float	floorf(float);
-float	fmodf(float, float);
-float	roundf(float);
-
-float	erff(float);
-float	erfcf(float);
-float	hypotf(float, float);
-float	lgammaf(float);
-float	tgammaf(float);
-
-float	acoshf(float);
-float	asinhf(float);
-float	atanhf(float);
-float	cbrtf(float);
-float	logbf(float);
-float	copysignf(float, float) __pure2;
-long long llrintf(float);
-long long llroundf(float);
-long	lrintf(float);
-long	lroundf(float);
-float	nanf(const char *) __pure2;
-float	nearbyintf(float);
-float	nextafterf(float, float);
-float	remainderf(float, float);
-float	remquof(float, float, int *);
-float	rintf(float);
-float	scalblnf(float, long);
-float	scalbnf(float, int);
-float	truncf(float);
-
-float	fdimf(float, float);
-float	fmaf(float, float, float);
-float	fmaxf(float, float) __pure2;
-float	fminf(float, float) __pure2;
-#endif
-
-/*
- * float versions of BSD math library entry points
- */
-#if __BSD_VISIBLE
-float	dremf(float, float);
-int	finitef(float) __pure2;
-float	gammaf(float);
-float	j0f(float);
-float	j1f(float);
-float	jnf(int, float);
-float	scalbf(float, float);
-float	y0f(float);
-float	y1f(float);
-float	ynf(int, float);
-
-/*
- * Float versions of reentrant version of gamma & lgamma; passes
- * signgam back by reference as the second argument; user must
- * allocate space for signgam.
- */
-float	gammaf_r(float, int *);
-float	lgammaf_r(float, int *);
-
-/*
- * float version of IEEE Test Vector
- */
-float	significandf(float);
-#endif	/* __BSD_VISIBLE */
-
-/*
- * long double versions of ISO/POSIX math functions
- */
-#if __ISO_C_VISIBLE >= 1999
-long double	acoshl(long double);
-long double	acosl(long double);
-long double	asinhl(long double);
-long double	asinl(long double);
-long double	atan2l(long double, long double);
-long double	atanhl(long double);
-long double	atanl(long double);
-long double	cbrtl(long double);
-long double	ceill(long double);
-long double	copysignl(long double, long double) __pure2;
-long double	coshl(long double);
-long double	cosl(long double);
-long double	erfcl(long double);
-long double	erfl(long double);
-long double	exp2l(long double);
-long double	expl(long double);
-long double	expm1l(long double);
-long double	fabsl(long double) __pure2;
-__BIONIC_MATH_INLINE(long double fabsl(long double x) { return __builtin_fabsl(x); })
-long double	fdiml(long double, long double);
-long double	floorl(long double);
-long double	fmal(long double, long double, long double);
-long double	fmaxl(long double, long double) __pure2;
-long double	fminl(long double, long double) __pure2;
-long double	fmodl(long double, long double);
-long double	frexpl(long double value, int *); /* fundamentally !__pure2 */
-long double	hypotl(long double, long double);
-int		ilogbl(long double) __pure2;
-long double	ldexpl(long double, int);
-long double	lgammal(long double);
-long long	llrintl(long double);
-long long	llroundl(long double);
-long double	log10l(long double);
-long double	log1pl(long double);
-long double	log2l(long double);
-long double	logbl(long double);
-long double	logl(long double);
-long		lrintl(long double);
-long		lroundl(long double);
-long double	modfl(long double, long double *); /* fundamentally !__pure2 */
-long double	nanl(const char *) __pure2;
-long double	nearbyintl(long double);
-long double	nextafterl(long double, long double);
-double		nexttoward(double, long double);
-float		nexttowardf(float, long double);
-long double	nexttowardl(long double, long double);
-long double	powl(long double, long double);
-long double	remainderl(long double, long double);
-long double	remquol(long double, long double, int *);
-long double	rintl(long double);
-long double	roundl(long double);
-long double	scalblnl(long double, long);
-long double	scalbnl(long double, int);
-long double	sinhl(long double);
-long double	sinl(long double);
-long double	sqrtl(long double);
-long double	tanhl(long double);
-long double	tanl(long double);
-long double	tgammal(long double);
-long double	truncl(long double);
-#endif /* __ISO_C_VISIBLE >= 1999 */
-
-#if __BSD_VISIBLE
-long double	lgammal_r(long double, int *);
-#endif
-
-#if defined(__USE_GNU)
-void sincos(double, double*, double*);
-void sincosf(float, float*, float*);
-void sincosl(long double, long double*, long double*);
-#endif /* __USE_GNU */
-
-#pragma GCC visibility pop
-__END_DECLS
-
-#endif /* !_MATH_H_ */
diff --git a/libm/libm.arm.map b/libm/libm.arm.map
index e781f2d..7e3175d 100644
--- a/libm/libm.arm.map
+++ b/libm/libm.arm.map
@@ -1,7 +1,7 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
-    __fe_dfl_env;
+    __fe_dfl_env; # var
     __signbit;
     __signbitf;
     __signbitl;
@@ -9,59 +9,59 @@
     acosf;
     acosh;
     acoshf;
-    acoshl;
-    acosl;
+    acoshl; # introduced=21
+    acosl; # introduced=21
     asin;
     asinf;
     asinh;
     asinhf;
-    asinhl;
-    asinl;
+    asinhl; # introduced=21
+    asinl; # introduced=21
     atan;
     atan2;
     atan2f;
-    atan2l;
+    atan2l; # introduced=21
     atanf;
     atanh;
     atanhf;
-    atanhl;
-    atanl;
-    cabs;
-    cabsf;
-    cabsl;
-    cacos;
-    cacosf;
-    cacosh;
-    cacoshf;
-    carg;
-    cargf;
-    cargl;
-    casin;
-    casinf;
-    casinh;
-    casinhf;
-    catan;
-    catanf;
-    catanh;
-    catanhf;
+    atanhl; # introduced=21
+    atanl; # introduced=21
+    cabs; # introduced=23
+    cabsf; # introduced=23
+    cabsl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    cacos; # introduced=23
+    cacosf; # introduced=23
+    cacosh; # introduced=23
+    cacoshf; # introduced=23
+    carg; # introduced=23
+    cargf; # introduced=23
+    cargl; # introduced=23
+    casin; # introduced=23
+    casinf; # introduced=23
+    casinh; # introduced=23
+    casinhf; # introduced=23
+    catan; # introduced=23
+    catanf; # introduced=23
+    catanh; # introduced=23
+    catanhf; # introduced=23
     cbrt;
     cbrtf;
-    cbrtl;
-    ccos;
-    ccosf;
-    ccosh;
-    ccoshf;
+    cbrtl; # introduced=21
+    ccos; # introduced=23
+    ccosf; # introduced=23
+    ccosh; # introduced=23
+    ccoshf; # introduced=23
     ceil;
     ceilf;
     ceill;
-    cexp;
-    cexpf;
-    cimag;
-    cimagf;
-    cimagl;
-    conj;
-    conjf;
-    conjl;
+    cexp; # introduced=23
+    cexpf; # introduced=23
+    cimag; # introduced=23
+    cimagf; # introduced=23
+    cimagl; # introduced=23
+    conj; # introduced=23
+    conjf; # introduced=23
+    conjl; # introduced=23
     copysign;
     copysignf;
     copysignl;
@@ -69,62 +69,62 @@
     cosf;
     cosh;
     coshf;
-    coshl;
-    cosl;
-    cproj;
-    cprojf;
-    cprojl;
-    creal;
-    crealf;
-    creall;
-    csin;
-    csinf;
-    csinh;
-    csinhf;
-    csqrt;
-    csqrtf;
-    csqrtl;
-    ctan;
-    ctanf;
-    ctanh;
-    ctanhf;
+    coshl; # introduced=21
+    cosl; # introduced=21
+    cproj; # introduced=23
+    cprojf; # introduced=23
+    cprojl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    creal; # introduced=23
+    crealf; # introduced=23
+    creall; # introduced=23
+    csin; # introduced=23
+    csinf; # introduced=23
+    csinh; # introduced=23
+    csinhf; # introduced=23
+    csqrt; # introduced=23
+    csqrtf; # introduced=23
+    csqrtl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    ctan; # introduced=23
+    ctanf; # introduced=23
+    ctanh; # introduced=23
+    ctanhf; # introduced=23
     drem;
     dremf;
     erf;
     erfc;
     erfcf;
-    erfcl;
+    erfcl; # introduced=21
     erff;
-    erfl;
+    erfl; # introduced=21
     exp;
     exp2;
     exp2f;
-    exp2l;
+    exp2l; # introduced=21
     expf;
-    expl;
+    expl; # introduced=21
     expm1;
     expm1f;
-    expm1l;
+    expm1l; # introduced=21
     fabs;
     fabsf;
     fabsl;
     fdim;
     fdimf;
     fdiml;
-    feclearexcept;
-    fedisableexcept;
-    feenableexcept;
-    fegetenv;
-    fegetexcept;
-    fegetexceptflag;
-    fegetround;
-    feholdexcept;
-    feraiseexcept;
-    fesetenv;
-    fesetexceptflag;
-    fesetround;
-    fetestexcept;
-    feupdateenv;
+    feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
     finite;
     finitef;
     floor;
@@ -132,7 +132,7 @@
     floorl;
     fma;
     fmaf;
-    fmal;
+    fmal; # introduced=21
     fmax;
     fmaxf;
     fmaxl;
@@ -141,17 +141,17 @@
     fminl;
     fmod;
     fmodf;
-    fmodl;
+    fmodl; # introduced=21
     frexp;
     frexpf;
-    frexpl;
+    frexpl; # introduced=21
     gamma;
     gamma_r;
     gammaf;
     gammaf_r;
     hypot;
     hypotf;
-    hypotl;
+    hypotl; # introduced=21
     ilogb;
     ilogbf;
     ilogbl;
@@ -167,77 +167,77 @@
     lgamma_r;
     lgammaf;
     lgammaf_r;
-    lgammal;
-    lgammal_r;
+    lgammal; # introduced=21
+    lgammal_r; # introduced=23
     llrint;
     llrintf;
-    llrintl;
+    llrintl; # introduced=21
     llround;
     llroundf;
     llroundl;
     log;
     log10;
     log10f;
-    log10l;
+    log10l; # introduced=21
     log1p;
     log1pf;
-    log1pl;
-    log2;
-    log2f;
-    log2l;
+    log1pl; # introduced=21
+    log2; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2f; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2l; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logb;
     logbf;
-    logbl;
+    logbl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logf;
-    logl;
+    logl; # introduced=21
     lrint;
     lrintf;
-    lrintl;
+    lrintl; # introduced=21
     lround;
     lroundf;
     lroundl;
     modf;
     modff;
-    modfl;
-    nan;
-    nanf;
-    nanl;
+    modfl; # introduced=21
+    nan; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanl; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
     nearbyint;
     nearbyintf;
-    nearbyintl;
+    nearbyintl; # introduced=21
     nextafter;
     nextafterf;
-    nextafterl;
-    nexttoward;
+    nextafterl; # introduced=21
+    nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     nexttowardf;
-    nexttowardl;
+    nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     pow;
     powf;
-    powl;
+    powl; # introduced=21
     remainder;
     remainderf;
-    remainderl;
+    remainderl; # introduced=21
     remquo;
     remquof;
-    remquol;
+    remquol; # introduced=21
     rint;
     rintf;
-    rintl;
+    rintl; # introduced=21
     round;
     roundf;
     roundl;
     scalb;
     scalbf;
-    scalbln;
-    scalblnf;
-    scalblnl;
+    scalbln; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     scalbn;
     scalbnf;
     scalbnl;
-    signgam;
+    signgam; # var
     significand;
     significandf;
-    significandl;
+    significandl; # introduced=21
     sin;
     sincos;
     sincosf;
@@ -245,20 +245,20 @@
     sinf;
     sinh;
     sinhf;
-    sinhl;
-    sinl;
+    sinhl; # introduced=21
+    sinl; # introduced=21
     sqrt;
     sqrtf;
-    sqrtl;
+    sqrtl; # introduced=21
     tan;
     tanf;
     tanh;
     tanhf;
-    tanhl;
-    tanl;
+    tanhl; # introduced=21
+    tanl; # introduced=21
     tgamma;
-    tgammaf;
-    tgammal;
+    tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    tgammal; # introduced=21
     trunc;
     truncf;
     truncl;
@@ -272,7 +272,30 @@
     *;
 };
 
-LIBC_PRIVATE { # arm mips
+LIBC_O {
+  global:
+    cacoshl;
+    cacosl;
+    casinhl;
+    casinl;
+    catanhl;
+    catanl;
+    ccoshl;
+    ccosl;
+    cexpl;
+    clog;
+    clogf;
+    clogl;
+    cpow;
+    cpowf;
+    cpowl;
+    csinhl;
+    csinl;
+    ctanhl;
+    ctanl;
+} LIBC;
+
+LIBC_DEPRECATED { # arm mips platform-only
   global: # arm mips
     ___Unwind_Backtrace; # arm
     ___Unwind_ForcedUnwind; # arm
@@ -375,4 +398,4 @@
     _Unwind_VRS_Pop; # arm
     _Unwind_VRS_Set; # arm
     restore_core_regs; # arm
-} LIBC; # arm mips
+} LIBC_O; # arm mips
diff --git a/libm/libm.arm64.map b/libm/libm.arm64.map
index 1623ea0..3e259dd 100644
--- a/libm/libm.arm64.map
+++ b/libm/libm.arm64.map
@@ -1,7 +1,7 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
-    __fe_dfl_env;
+    __fe_dfl_env; # var
     __signbit;
     __signbitf;
     __signbitl;
@@ -9,59 +9,59 @@
     acosf;
     acosh;
     acoshf;
-    acoshl;
-    acosl;
+    acoshl; # introduced=21
+    acosl; # introduced=21
     asin;
     asinf;
     asinh;
     asinhf;
-    asinhl;
-    asinl;
+    asinhl; # introduced=21
+    asinl; # introduced=21
     atan;
     atan2;
     atan2f;
-    atan2l;
+    atan2l; # introduced=21
     atanf;
     atanh;
     atanhf;
-    atanhl;
-    atanl;
-    cabs;
-    cabsf;
-    cabsl;
-    cacos;
-    cacosf;
-    cacosh;
-    cacoshf;
-    carg;
-    cargf;
-    cargl;
-    casin;
-    casinf;
-    casinh;
-    casinhf;
-    catan;
-    catanf;
-    catanh;
-    catanhf;
+    atanhl; # introduced=21
+    atanl; # introduced=21
+    cabs; # introduced=23
+    cabsf; # introduced=23
+    cabsl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    cacos; # introduced=23
+    cacosf; # introduced=23
+    cacosh; # introduced=23
+    cacoshf; # introduced=23
+    carg; # introduced=23
+    cargf; # introduced=23
+    cargl; # introduced=23
+    casin; # introduced=23
+    casinf; # introduced=23
+    casinh; # introduced=23
+    casinhf; # introduced=23
+    catan; # introduced=23
+    catanf; # introduced=23
+    catanh; # introduced=23
+    catanhf; # introduced=23
     cbrt;
     cbrtf;
-    cbrtl;
-    ccos;
-    ccosf;
-    ccosh;
-    ccoshf;
+    cbrtl; # introduced=21
+    ccos; # introduced=23
+    ccosf; # introduced=23
+    ccosh; # introduced=23
+    ccoshf; # introduced=23
     ceil;
     ceilf;
     ceill;
-    cexp;
-    cexpf;
-    cimag;
-    cimagf;
-    cimagl;
-    conj;
-    conjf;
-    conjl;
+    cexp; # introduced=23
+    cexpf; # introduced=23
+    cimag; # introduced=23
+    cimagf; # introduced=23
+    cimagl; # introduced=23
+    conj; # introduced=23
+    conjf; # introduced=23
+    conjl; # introduced=23
     copysign;
     copysignf;
     copysignl;
@@ -69,62 +69,62 @@
     cosf;
     cosh;
     coshf;
-    coshl;
-    cosl;
-    cproj;
-    cprojf;
-    cprojl;
-    creal;
-    crealf;
-    creall;
-    csin;
-    csinf;
-    csinh;
-    csinhf;
-    csqrt;
-    csqrtf;
-    csqrtl;
-    ctan;
-    ctanf;
-    ctanh;
-    ctanhf;
+    coshl; # introduced=21
+    cosl; # introduced=21
+    cproj; # introduced=23
+    cprojf; # introduced=23
+    cprojl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    creal; # introduced=23
+    crealf; # introduced=23
+    creall; # introduced=23
+    csin; # introduced=23
+    csinf; # introduced=23
+    csinh; # introduced=23
+    csinhf; # introduced=23
+    csqrt; # introduced=23
+    csqrtf; # introduced=23
+    csqrtl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    ctan; # introduced=23
+    ctanf; # introduced=23
+    ctanh; # introduced=23
+    ctanhf; # introduced=23
     drem;
     dremf;
     erf;
     erfc;
     erfcf;
-    erfcl;
+    erfcl; # introduced=21
     erff;
-    erfl;
+    erfl; # introduced=21
     exp;
     exp2;
     exp2f;
-    exp2l;
+    exp2l; # introduced=21
     expf;
-    expl;
+    expl; # introduced=21
     expm1;
     expm1f;
-    expm1l;
+    expm1l; # introduced=21
     fabs;
     fabsf;
     fabsl;
     fdim;
     fdimf;
     fdiml;
-    feclearexcept;
-    fedisableexcept;
-    feenableexcept;
-    fegetenv;
-    fegetexcept;
-    fegetexceptflag;
-    fegetround;
-    feholdexcept;
-    feraiseexcept;
-    fesetenv;
-    fesetexceptflag;
-    fesetround;
-    fetestexcept;
-    feupdateenv;
+    feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
     finite;
     finitef;
     floor;
@@ -132,7 +132,7 @@
     floorl;
     fma;
     fmaf;
-    fmal;
+    fmal; # introduced=21
     fmax;
     fmaxf;
     fmaxl;
@@ -141,17 +141,17 @@
     fminl;
     fmod;
     fmodf;
-    fmodl;
+    fmodl; # introduced=21
     frexp;
     frexpf;
-    frexpl;
+    frexpl; # introduced=21
     gamma;
     gamma_r;
     gammaf;
     gammaf_r;
     hypot;
     hypotf;
-    hypotl;
+    hypotl; # introduced=21
     ilogb;
     ilogbf;
     ilogbl;
@@ -167,77 +167,77 @@
     lgamma_r;
     lgammaf;
     lgammaf_r;
-    lgammal;
-    lgammal_r;
+    lgammal; # introduced=21
+    lgammal_r; # introduced=23
     llrint;
     llrintf;
-    llrintl;
+    llrintl; # introduced=21
     llround;
     llroundf;
     llroundl;
     log;
     log10;
     log10f;
-    log10l;
+    log10l; # introduced=21
     log1p;
     log1pf;
-    log1pl;
-    log2;
-    log2f;
-    log2l;
+    log1pl; # introduced=21
+    log2; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2f; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2l; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logb;
     logbf;
-    logbl;
+    logbl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logf;
-    logl;
+    logl; # introduced=21
     lrint;
     lrintf;
-    lrintl;
+    lrintl; # introduced=21
     lround;
     lroundf;
     lroundl;
     modf;
     modff;
-    modfl;
-    nan;
-    nanf;
-    nanl;
+    modfl; # introduced=21
+    nan; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanl; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
     nearbyint;
     nearbyintf;
-    nearbyintl;
+    nearbyintl; # introduced=21
     nextafter;
     nextafterf;
-    nextafterl;
-    nexttoward;
+    nextafterl; # introduced=21
+    nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     nexttowardf;
-    nexttowardl;
+    nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     pow;
     powf;
-    powl;
+    powl; # introduced=21
     remainder;
     remainderf;
-    remainderl;
+    remainderl; # introduced=21
     remquo;
     remquof;
-    remquol;
+    remquol; # introduced=21
     rint;
     rintf;
-    rintl;
+    rintl; # introduced=21
     round;
     roundf;
     roundl;
     scalb;
     scalbf;
-    scalbln;
-    scalblnf;
-    scalblnl;
+    scalbln; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     scalbn;
     scalbnf;
     scalbnl;
-    signgam;
+    signgam; # var
     significand;
     significandf;
-    significandl;
+    significandl; # introduced=21
     sin;
     sincos;
     sincosf;
@@ -245,20 +245,20 @@
     sinf;
     sinh;
     sinhf;
-    sinhl;
-    sinl;
+    sinhl; # introduced=21
+    sinl; # introduced=21
     sqrt;
     sqrtf;
-    sqrtl;
+    sqrtl; # introduced=21
     tan;
     tanf;
     tanh;
     tanhf;
-    tanhl;
-    tanl;
+    tanhl; # introduced=21
+    tanl; # introduced=21
     tgamma;
-    tgammaf;
-    tgammal;
+    tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    tgammal; # introduced=21
     trunc;
     truncf;
     truncl;
@@ -272,3 +272,26 @@
     *;
 };
 
+LIBC_O {
+  global:
+    cacoshl;
+    cacosl;
+    casinhl;
+    casinl;
+    catanhl;
+    catanl;
+    ccoshl;
+    ccosl;
+    cexpl;
+    clog;
+    clogf;
+    clogl;
+    cpow;
+    cpowf;
+    cpowl;
+    csinhl;
+    csinl;
+    ctanhl;
+    ctanl;
+} LIBC;
+
diff --git a/libm/libm.map.txt b/libm/libm.map.txt
index 075ebd5..1fb16b7 100644
--- a/libm/libm.map.txt
+++ b/libm/libm.map.txt
@@ -1,6 +1,6 @@
 LIBC {
   global:
-    __fe_dfl_env;
+    __fe_dfl_env; # var
     __signbit;
     __signbitf;
     __signbitl;
@@ -8,59 +8,59 @@
     acosf;
     acosh;
     acoshf;
-    acoshl;
-    acosl;
+    acoshl; # introduced=21
+    acosl; # introduced=21
     asin;
     asinf;
     asinh;
     asinhf;
-    asinhl;
-    asinl;
+    asinhl; # introduced=21
+    asinl; # introduced=21
     atan;
     atan2;
     atan2f;
-    atan2l;
+    atan2l; # introduced=21
     atanf;
     atanh;
     atanhf;
-    atanhl;
-    atanl;
-    cabs;
-    cabsf;
-    cabsl;
-    cacos;
-    cacosf;
-    cacosh;
-    cacoshf;
-    carg;
-    cargf;
-    cargl;
-    casin;
-    casinf;
-    casinh;
-    casinhf;
-    catan;
-    catanf;
-    catanh;
-    catanhf;
+    atanhl; # introduced=21
+    atanl; # introduced=21
+    cabs; # introduced=23
+    cabsf; # introduced=23
+    cabsl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    cacos; # introduced=23
+    cacosf; # introduced=23
+    cacosh; # introduced=23
+    cacoshf; # introduced=23
+    carg; # introduced=23
+    cargf; # introduced=23
+    cargl; # introduced=23
+    casin; # introduced=23
+    casinf; # introduced=23
+    casinh; # introduced=23
+    casinhf; # introduced=23
+    catan; # introduced=23
+    catanf; # introduced=23
+    catanh; # introduced=23
+    catanhf; # introduced=23
     cbrt;
     cbrtf;
-    cbrtl;
-    ccos;
-    ccosf;
-    ccosh;
-    ccoshf;
+    cbrtl; # introduced=21
+    ccos; # introduced=23
+    ccosf; # introduced=23
+    ccosh; # introduced=23
+    ccoshf; # introduced=23
     ceil;
     ceilf;
     ceill;
-    cexp;
-    cexpf;
-    cimag;
-    cimagf;
-    cimagl;
-    conj;
-    conjf;
-    conjl;
+    cexp; # introduced=23
+    cexpf; # introduced=23
+    cimag; # introduced=23
+    cimagf; # introduced=23
+    cimagl; # introduced=23
+    conj; # introduced=23
+    conjf; # introduced=23
+    conjl; # introduced=23
     copysign;
     copysignf;
     copysignl;
@@ -68,62 +68,62 @@
     cosf;
     cosh;
     coshf;
-    coshl;
-    cosl;
-    cproj;
-    cprojf;
-    cprojl;
-    creal;
-    crealf;
-    creall;
-    csin;
-    csinf;
-    csinh;
-    csinhf;
-    csqrt;
-    csqrtf;
-    csqrtl;
-    ctan;
-    ctanf;
-    ctanh;
-    ctanhf;
+    coshl; # introduced=21
+    cosl; # introduced=21
+    cproj; # introduced=23
+    cprojf; # introduced=23
+    cprojl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    creal; # introduced=23
+    crealf; # introduced=23
+    creall; # introduced=23
+    csin; # introduced=23
+    csinf; # introduced=23
+    csinh; # introduced=23
+    csinhf; # introduced=23
+    csqrt; # introduced=23
+    csqrtf; # introduced=23
+    csqrtl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    ctan; # introduced=23
+    ctanf; # introduced=23
+    ctanh; # introduced=23
+    ctanhf; # introduced=23
     drem;
     dremf;
     erf;
     erfc;
     erfcf;
-    erfcl;
+    erfcl; # introduced=21
     erff;
-    erfl;
+    erfl; # introduced=21
     exp;
     exp2;
     exp2f;
-    exp2l;
+    exp2l; # introduced=21
     expf;
-    expl;
+    expl; # introduced=21
     expm1;
     expm1f;
-    expm1l;
+    expm1l; # introduced=21
     fabs;
     fabsf;
     fabsl;
     fdim;
     fdimf;
     fdiml;
-    feclearexcept;
-    fedisableexcept;
-    feenableexcept;
-    fegetenv;
-    fegetexcept;
-    fegetexceptflag;
-    fegetround;
-    feholdexcept;
-    feraiseexcept;
-    fesetenv;
-    fesetexceptflag;
-    fesetround;
-    fetestexcept;
-    feupdateenv;
+    feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
     finite;
     finitef;
     floor;
@@ -131,7 +131,7 @@
     floorl;
     fma;
     fmaf;
-    fmal;
+    fmal; # introduced=21
     fmax;
     fmaxf;
     fmaxl;
@@ -140,17 +140,17 @@
     fminl;
     fmod;
     fmodf;
-    fmodl;
+    fmodl; # introduced=21
     frexp;
     frexpf;
-    frexpl;
+    frexpl; # introduced=21
     gamma;
     gamma_r;
     gammaf;
     gammaf_r;
     hypot;
     hypotf;
-    hypotl;
+    hypotl; # introduced=21
     ilogb;
     ilogbf;
     ilogbl;
@@ -166,77 +166,77 @@
     lgamma_r;
     lgammaf;
     lgammaf_r;
-    lgammal;
-    lgammal_r;
+    lgammal; # introduced=21
+    lgammal_r; # introduced=23
     llrint;
     llrintf;
-    llrintl;
+    llrintl; # introduced=21
     llround;
     llroundf;
     llroundl;
     log;
     log10;
     log10f;
-    log10l;
+    log10l; # introduced=21
     log1p;
     log1pf;
-    log1pl;
-    log2;
-    log2f;
-    log2l;
+    log1pl; # introduced=21
+    log2; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2f; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2l; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logb;
     logbf;
-    logbl;
+    logbl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logf;
-    logl;
+    logl; # introduced=21
     lrint;
     lrintf;
-    lrintl;
+    lrintl; # introduced=21
     lround;
     lroundf;
     lroundl;
     modf;
     modff;
-    modfl;
-    nan;
-    nanf;
-    nanl;
+    modfl; # introduced=21
+    nan; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanl; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
     nearbyint;
     nearbyintf;
-    nearbyintl;
+    nearbyintl; # introduced=21
     nextafter;
     nextafterf;
-    nextafterl;
-    nexttoward;
+    nextafterl; # introduced=21
+    nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     nexttowardf;
-    nexttowardl;
+    nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     pow;
     powf;
-    powl;
+    powl; # introduced=21
     remainder;
     remainderf;
-    remainderl;
+    remainderl; # introduced=21
     remquo;
     remquof;
-    remquol;
+    remquol; # introduced=21
     rint;
     rintf;
-    rintl;
+    rintl; # introduced=21
     round;
     roundf;
     roundl;
     scalb;
     scalbf;
-    scalbln;
-    scalblnf;
-    scalblnl;
+    scalbln; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     scalbn;
     scalbnf;
     scalbnl;
-    signgam;
+    signgam; # var
     significand;
     significandf;
-    significandl;
+    significandl; # introduced=21
     sin;
     sincos;
     sincosf;
@@ -244,20 +244,20 @@
     sinf;
     sinh;
     sinhf;
-    sinhl;
-    sinl;
+    sinhl; # introduced=21
+    sinl; # introduced=21
     sqrt;
     sqrtf;
-    sqrtl;
+    sqrtl; # introduced=21
     tan;
     tanf;
     tanh;
     tanhf;
-    tanhl;
-    tanl;
+    tanhl; # introduced=21
+    tanl; # introduced=21
     tgamma;
-    tgammaf;
-    tgammal;
+    tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    tgammal; # introduced=21
     trunc;
     truncf;
     truncl;
@@ -271,7 +271,30 @@
     *;
 };
 
-LIBC_PRIVATE { # arm mips
+LIBC_O {
+  global:
+    cacoshl;
+    cacosl;
+    casinhl;
+    casinl;
+    catanhl;
+    catanl;
+    ccoshl;
+    ccosl;
+    cexpl;
+    clog;
+    clogf;
+    clogl;
+    cpow;
+    cpowf;
+    cpowl;
+    csinhl;
+    csinl;
+    ctanhl;
+    ctanl;
+} LIBC;
+
+LIBC_DEPRECATED { # arm mips platform-only
   global: # arm mips
     ___Unwind_Backtrace; # arm
     ___Unwind_ForcedUnwind; # arm
@@ -374,4 +397,4 @@
     _Unwind_VRS_Pop; # arm
     _Unwind_VRS_Set; # arm
     restore_core_regs; # arm
-} LIBC; # arm mips
+} LIBC_O; # arm mips
diff --git a/libm/libm.mips.map b/libm/libm.mips.map
index 476c6ad..b368d41 100644
--- a/libm/libm.mips.map
+++ b/libm/libm.mips.map
@@ -1,7 +1,7 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
-    __fe_dfl_env;
+    __fe_dfl_env; # var
     __signbit;
     __signbitf;
     __signbitl;
@@ -9,59 +9,59 @@
     acosf;
     acosh;
     acoshf;
-    acoshl;
-    acosl;
+    acoshl; # introduced=21
+    acosl; # introduced=21
     asin;
     asinf;
     asinh;
     asinhf;
-    asinhl;
-    asinl;
+    asinhl; # introduced=21
+    asinl; # introduced=21
     atan;
     atan2;
     atan2f;
-    atan2l;
+    atan2l; # introduced=21
     atanf;
     atanh;
     atanhf;
-    atanhl;
-    atanl;
-    cabs;
-    cabsf;
-    cabsl;
-    cacos;
-    cacosf;
-    cacosh;
-    cacoshf;
-    carg;
-    cargf;
-    cargl;
-    casin;
-    casinf;
-    casinh;
-    casinhf;
-    catan;
-    catanf;
-    catanh;
-    catanhf;
+    atanhl; # introduced=21
+    atanl; # introduced=21
+    cabs; # introduced=23
+    cabsf; # introduced=23
+    cabsl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    cacos; # introduced=23
+    cacosf; # introduced=23
+    cacosh; # introduced=23
+    cacoshf; # introduced=23
+    carg; # introduced=23
+    cargf; # introduced=23
+    cargl; # introduced=23
+    casin; # introduced=23
+    casinf; # introduced=23
+    casinh; # introduced=23
+    casinhf; # introduced=23
+    catan; # introduced=23
+    catanf; # introduced=23
+    catanh; # introduced=23
+    catanhf; # introduced=23
     cbrt;
     cbrtf;
-    cbrtl;
-    ccos;
-    ccosf;
-    ccosh;
-    ccoshf;
+    cbrtl; # introduced=21
+    ccos; # introduced=23
+    ccosf; # introduced=23
+    ccosh; # introduced=23
+    ccoshf; # introduced=23
     ceil;
     ceilf;
     ceill;
-    cexp;
-    cexpf;
-    cimag;
-    cimagf;
-    cimagl;
-    conj;
-    conjf;
-    conjl;
+    cexp; # introduced=23
+    cexpf; # introduced=23
+    cimag; # introduced=23
+    cimagf; # introduced=23
+    cimagl; # introduced=23
+    conj; # introduced=23
+    conjf; # introduced=23
+    conjl; # introduced=23
     copysign;
     copysignf;
     copysignl;
@@ -69,62 +69,62 @@
     cosf;
     cosh;
     coshf;
-    coshl;
-    cosl;
-    cproj;
-    cprojf;
-    cprojl;
-    creal;
-    crealf;
-    creall;
-    csin;
-    csinf;
-    csinh;
-    csinhf;
-    csqrt;
-    csqrtf;
-    csqrtl;
-    ctan;
-    ctanf;
-    ctanh;
-    ctanhf;
+    coshl; # introduced=21
+    cosl; # introduced=21
+    cproj; # introduced=23
+    cprojf; # introduced=23
+    cprojl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    creal; # introduced=23
+    crealf; # introduced=23
+    creall; # introduced=23
+    csin; # introduced=23
+    csinf; # introduced=23
+    csinh; # introduced=23
+    csinhf; # introduced=23
+    csqrt; # introduced=23
+    csqrtf; # introduced=23
+    csqrtl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    ctan; # introduced=23
+    ctanf; # introduced=23
+    ctanh; # introduced=23
+    ctanhf; # introduced=23
     drem;
     dremf;
     erf;
     erfc;
     erfcf;
-    erfcl;
+    erfcl; # introduced=21
     erff;
-    erfl;
+    erfl; # introduced=21
     exp;
     exp2;
     exp2f;
-    exp2l;
+    exp2l; # introduced=21
     expf;
-    expl;
+    expl; # introduced=21
     expm1;
     expm1f;
-    expm1l;
+    expm1l; # introduced=21
     fabs;
     fabsf;
     fabsl;
     fdim;
     fdimf;
     fdiml;
-    feclearexcept;
-    fedisableexcept;
-    feenableexcept;
-    fegetenv;
-    fegetexcept;
-    fegetexceptflag;
-    fegetround;
-    feholdexcept;
-    feraiseexcept;
-    fesetenv;
-    fesetexceptflag;
-    fesetround;
-    fetestexcept;
-    feupdateenv;
+    feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
     finite;
     finitef;
     floor;
@@ -132,7 +132,7 @@
     floorl;
     fma;
     fmaf;
-    fmal;
+    fmal; # introduced=21
     fmax;
     fmaxf;
     fmaxl;
@@ -141,17 +141,17 @@
     fminl;
     fmod;
     fmodf;
-    fmodl;
+    fmodl; # introduced=21
     frexp;
     frexpf;
-    frexpl;
+    frexpl; # introduced=21
     gamma;
     gamma_r;
     gammaf;
     gammaf_r;
     hypot;
     hypotf;
-    hypotl;
+    hypotl; # introduced=21
     ilogb;
     ilogbf;
     ilogbl;
@@ -167,77 +167,77 @@
     lgamma_r;
     lgammaf;
     lgammaf_r;
-    lgammal;
-    lgammal_r;
+    lgammal; # introduced=21
+    lgammal_r; # introduced=23
     llrint;
     llrintf;
-    llrintl;
+    llrintl; # introduced=21
     llround;
     llroundf;
     llroundl;
     log;
     log10;
     log10f;
-    log10l;
+    log10l; # introduced=21
     log1p;
     log1pf;
-    log1pl;
-    log2;
-    log2f;
-    log2l;
+    log1pl; # introduced=21
+    log2; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2f; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2l; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logb;
     logbf;
-    logbl;
+    logbl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logf;
-    logl;
+    logl; # introduced=21
     lrint;
     lrintf;
-    lrintl;
+    lrintl; # introduced=21
     lround;
     lroundf;
     lroundl;
     modf;
     modff;
-    modfl;
-    nan;
-    nanf;
-    nanl;
+    modfl; # introduced=21
+    nan; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanl; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
     nearbyint;
     nearbyintf;
-    nearbyintl;
+    nearbyintl; # introduced=21
     nextafter;
     nextafterf;
-    nextafterl;
-    nexttoward;
+    nextafterl; # introduced=21
+    nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     nexttowardf;
-    nexttowardl;
+    nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     pow;
     powf;
-    powl;
+    powl; # introduced=21
     remainder;
     remainderf;
-    remainderl;
+    remainderl; # introduced=21
     remquo;
     remquof;
-    remquol;
+    remquol; # introduced=21
     rint;
     rintf;
-    rintl;
+    rintl; # introduced=21
     round;
     roundf;
     roundl;
     scalb;
     scalbf;
-    scalbln;
-    scalblnf;
-    scalblnl;
+    scalbln; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     scalbn;
     scalbnf;
     scalbnl;
-    signgam;
+    signgam; # var
     significand;
     significandf;
-    significandl;
+    significandl; # introduced=21
     sin;
     sincos;
     sincosf;
@@ -245,20 +245,20 @@
     sinf;
     sinh;
     sinhf;
-    sinhl;
-    sinl;
+    sinhl; # introduced=21
+    sinl; # introduced=21
     sqrt;
     sqrtf;
-    sqrtl;
+    sqrtl; # introduced=21
     tan;
     tanf;
     tanh;
     tanhf;
-    tanhl;
-    tanl;
+    tanhl; # introduced=21
+    tanl; # introduced=21
     tgamma;
-    tgammaf;
-    tgammal;
+    tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    tgammal; # introduced=21
     trunc;
     truncf;
     truncl;
@@ -272,10 +272,33 @@
     *;
 };
 
-LIBC_PRIVATE { # arm mips
+LIBC_O {
+  global:
+    cacoshl;
+    cacosl;
+    casinhl;
+    casinl;
+    catanhl;
+    catanl;
+    ccoshl;
+    ccosl;
+    cexpl;
+    clog;
+    clogf;
+    clogl;
+    cpow;
+    cpowf;
+    cpowl;
+    csinhl;
+    csinl;
+    ctanhl;
+    ctanl;
+} LIBC;
+
+LIBC_DEPRECATED { # arm mips platform-only
   global: # arm mips
     __fixdfdi; # arm mips
     __fixsfdi; # arm mips
     __fixunsdfdi; # arm mips
     __fixunssfdi; # arm mips
-} LIBC; # arm mips
+} LIBC_O; # arm mips
diff --git a/libm/libm.mips64.map b/libm/libm.mips64.map
index 1623ea0..3e259dd 100644
--- a/libm/libm.mips64.map
+++ b/libm/libm.mips64.map
@@ -1,7 +1,7 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
-    __fe_dfl_env;
+    __fe_dfl_env; # var
     __signbit;
     __signbitf;
     __signbitl;
@@ -9,59 +9,59 @@
     acosf;
     acosh;
     acoshf;
-    acoshl;
-    acosl;
+    acoshl; # introduced=21
+    acosl; # introduced=21
     asin;
     asinf;
     asinh;
     asinhf;
-    asinhl;
-    asinl;
+    asinhl; # introduced=21
+    asinl; # introduced=21
     atan;
     atan2;
     atan2f;
-    atan2l;
+    atan2l; # introduced=21
     atanf;
     atanh;
     atanhf;
-    atanhl;
-    atanl;
-    cabs;
-    cabsf;
-    cabsl;
-    cacos;
-    cacosf;
-    cacosh;
-    cacoshf;
-    carg;
-    cargf;
-    cargl;
-    casin;
-    casinf;
-    casinh;
-    casinhf;
-    catan;
-    catanf;
-    catanh;
-    catanhf;
+    atanhl; # introduced=21
+    atanl; # introduced=21
+    cabs; # introduced=23
+    cabsf; # introduced=23
+    cabsl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    cacos; # introduced=23
+    cacosf; # introduced=23
+    cacosh; # introduced=23
+    cacoshf; # introduced=23
+    carg; # introduced=23
+    cargf; # introduced=23
+    cargl; # introduced=23
+    casin; # introduced=23
+    casinf; # introduced=23
+    casinh; # introduced=23
+    casinhf; # introduced=23
+    catan; # introduced=23
+    catanf; # introduced=23
+    catanh; # introduced=23
+    catanhf; # introduced=23
     cbrt;
     cbrtf;
-    cbrtl;
-    ccos;
-    ccosf;
-    ccosh;
-    ccoshf;
+    cbrtl; # introduced=21
+    ccos; # introduced=23
+    ccosf; # introduced=23
+    ccosh; # introduced=23
+    ccoshf; # introduced=23
     ceil;
     ceilf;
     ceill;
-    cexp;
-    cexpf;
-    cimag;
-    cimagf;
-    cimagl;
-    conj;
-    conjf;
-    conjl;
+    cexp; # introduced=23
+    cexpf; # introduced=23
+    cimag; # introduced=23
+    cimagf; # introduced=23
+    cimagl; # introduced=23
+    conj; # introduced=23
+    conjf; # introduced=23
+    conjl; # introduced=23
     copysign;
     copysignf;
     copysignl;
@@ -69,62 +69,62 @@
     cosf;
     cosh;
     coshf;
-    coshl;
-    cosl;
-    cproj;
-    cprojf;
-    cprojl;
-    creal;
-    crealf;
-    creall;
-    csin;
-    csinf;
-    csinh;
-    csinhf;
-    csqrt;
-    csqrtf;
-    csqrtl;
-    ctan;
-    ctanf;
-    ctanh;
-    ctanhf;
+    coshl; # introduced=21
+    cosl; # introduced=21
+    cproj; # introduced=23
+    cprojf; # introduced=23
+    cprojl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    creal; # introduced=23
+    crealf; # introduced=23
+    creall; # introduced=23
+    csin; # introduced=23
+    csinf; # introduced=23
+    csinh; # introduced=23
+    csinhf; # introduced=23
+    csqrt; # introduced=23
+    csqrtf; # introduced=23
+    csqrtl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    ctan; # introduced=23
+    ctanf; # introduced=23
+    ctanh; # introduced=23
+    ctanhf; # introduced=23
     drem;
     dremf;
     erf;
     erfc;
     erfcf;
-    erfcl;
+    erfcl; # introduced=21
     erff;
-    erfl;
+    erfl; # introduced=21
     exp;
     exp2;
     exp2f;
-    exp2l;
+    exp2l; # introduced=21
     expf;
-    expl;
+    expl; # introduced=21
     expm1;
     expm1f;
-    expm1l;
+    expm1l; # introduced=21
     fabs;
     fabsf;
     fabsl;
     fdim;
     fdimf;
     fdiml;
-    feclearexcept;
-    fedisableexcept;
-    feenableexcept;
-    fegetenv;
-    fegetexcept;
-    fegetexceptflag;
-    fegetround;
-    feholdexcept;
-    feraiseexcept;
-    fesetenv;
-    fesetexceptflag;
-    fesetround;
-    fetestexcept;
-    feupdateenv;
+    feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
     finite;
     finitef;
     floor;
@@ -132,7 +132,7 @@
     floorl;
     fma;
     fmaf;
-    fmal;
+    fmal; # introduced=21
     fmax;
     fmaxf;
     fmaxl;
@@ -141,17 +141,17 @@
     fminl;
     fmod;
     fmodf;
-    fmodl;
+    fmodl; # introduced=21
     frexp;
     frexpf;
-    frexpl;
+    frexpl; # introduced=21
     gamma;
     gamma_r;
     gammaf;
     gammaf_r;
     hypot;
     hypotf;
-    hypotl;
+    hypotl; # introduced=21
     ilogb;
     ilogbf;
     ilogbl;
@@ -167,77 +167,77 @@
     lgamma_r;
     lgammaf;
     lgammaf_r;
-    lgammal;
-    lgammal_r;
+    lgammal; # introduced=21
+    lgammal_r; # introduced=23
     llrint;
     llrintf;
-    llrintl;
+    llrintl; # introduced=21
     llround;
     llroundf;
     llroundl;
     log;
     log10;
     log10f;
-    log10l;
+    log10l; # introduced=21
     log1p;
     log1pf;
-    log1pl;
-    log2;
-    log2f;
-    log2l;
+    log1pl; # introduced=21
+    log2; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2f; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2l; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logb;
     logbf;
-    logbl;
+    logbl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logf;
-    logl;
+    logl; # introduced=21
     lrint;
     lrintf;
-    lrintl;
+    lrintl; # introduced=21
     lround;
     lroundf;
     lroundl;
     modf;
     modff;
-    modfl;
-    nan;
-    nanf;
-    nanl;
+    modfl; # introduced=21
+    nan; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanl; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
     nearbyint;
     nearbyintf;
-    nearbyintl;
+    nearbyintl; # introduced=21
     nextafter;
     nextafterf;
-    nextafterl;
-    nexttoward;
+    nextafterl; # introduced=21
+    nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     nexttowardf;
-    nexttowardl;
+    nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     pow;
     powf;
-    powl;
+    powl; # introduced=21
     remainder;
     remainderf;
-    remainderl;
+    remainderl; # introduced=21
     remquo;
     remquof;
-    remquol;
+    remquol; # introduced=21
     rint;
     rintf;
-    rintl;
+    rintl; # introduced=21
     round;
     roundf;
     roundl;
     scalb;
     scalbf;
-    scalbln;
-    scalblnf;
-    scalblnl;
+    scalbln; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     scalbn;
     scalbnf;
     scalbnl;
-    signgam;
+    signgam; # var
     significand;
     significandf;
-    significandl;
+    significandl; # introduced=21
     sin;
     sincos;
     sincosf;
@@ -245,20 +245,20 @@
     sinf;
     sinh;
     sinhf;
-    sinhl;
-    sinl;
+    sinhl; # introduced=21
+    sinl; # introduced=21
     sqrt;
     sqrtf;
-    sqrtl;
+    sqrtl; # introduced=21
     tan;
     tanf;
     tanh;
     tanhf;
-    tanhl;
-    tanl;
+    tanhl; # introduced=21
+    tanl; # introduced=21
     tgamma;
-    tgammaf;
-    tgammal;
+    tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    tgammal; # introduced=21
     trunc;
     truncf;
     truncl;
@@ -272,3 +272,26 @@
     *;
 };
 
+LIBC_O {
+  global:
+    cacoshl;
+    cacosl;
+    casinhl;
+    casinl;
+    catanhl;
+    catanl;
+    ccoshl;
+    ccosl;
+    cexpl;
+    clog;
+    clogf;
+    clogl;
+    cpow;
+    cpowf;
+    cpowl;
+    csinhl;
+    csinl;
+    ctanhl;
+    ctanl;
+} LIBC;
+
diff --git a/libm/libm.x86.map b/libm/libm.x86.map
index 1623ea0..3e259dd 100644
--- a/libm/libm.x86.map
+++ b/libm/libm.x86.map
@@ -1,7 +1,7 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
-    __fe_dfl_env;
+    __fe_dfl_env; # var
     __signbit;
     __signbitf;
     __signbitl;
@@ -9,59 +9,59 @@
     acosf;
     acosh;
     acoshf;
-    acoshl;
-    acosl;
+    acoshl; # introduced=21
+    acosl; # introduced=21
     asin;
     asinf;
     asinh;
     asinhf;
-    asinhl;
-    asinl;
+    asinhl; # introduced=21
+    asinl; # introduced=21
     atan;
     atan2;
     atan2f;
-    atan2l;
+    atan2l; # introduced=21
     atanf;
     atanh;
     atanhf;
-    atanhl;
-    atanl;
-    cabs;
-    cabsf;
-    cabsl;
-    cacos;
-    cacosf;
-    cacosh;
-    cacoshf;
-    carg;
-    cargf;
-    cargl;
-    casin;
-    casinf;
-    casinh;
-    casinhf;
-    catan;
-    catanf;
-    catanh;
-    catanhf;
+    atanhl; # introduced=21
+    atanl; # introduced=21
+    cabs; # introduced=23
+    cabsf; # introduced=23
+    cabsl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    cacos; # introduced=23
+    cacosf; # introduced=23
+    cacosh; # introduced=23
+    cacoshf; # introduced=23
+    carg; # introduced=23
+    cargf; # introduced=23
+    cargl; # introduced=23
+    casin; # introduced=23
+    casinf; # introduced=23
+    casinh; # introduced=23
+    casinhf; # introduced=23
+    catan; # introduced=23
+    catanf; # introduced=23
+    catanh; # introduced=23
+    catanhf; # introduced=23
     cbrt;
     cbrtf;
-    cbrtl;
-    ccos;
-    ccosf;
-    ccosh;
-    ccoshf;
+    cbrtl; # introduced=21
+    ccos; # introduced=23
+    ccosf; # introduced=23
+    ccosh; # introduced=23
+    ccoshf; # introduced=23
     ceil;
     ceilf;
     ceill;
-    cexp;
-    cexpf;
-    cimag;
-    cimagf;
-    cimagl;
-    conj;
-    conjf;
-    conjl;
+    cexp; # introduced=23
+    cexpf; # introduced=23
+    cimag; # introduced=23
+    cimagf; # introduced=23
+    cimagl; # introduced=23
+    conj; # introduced=23
+    conjf; # introduced=23
+    conjl; # introduced=23
     copysign;
     copysignf;
     copysignl;
@@ -69,62 +69,62 @@
     cosf;
     cosh;
     coshf;
-    coshl;
-    cosl;
-    cproj;
-    cprojf;
-    cprojl;
-    creal;
-    crealf;
-    creall;
-    csin;
-    csinf;
-    csinh;
-    csinhf;
-    csqrt;
-    csqrtf;
-    csqrtl;
-    ctan;
-    ctanf;
-    ctanh;
-    ctanhf;
+    coshl; # introduced=21
+    cosl; # introduced=21
+    cproj; # introduced=23
+    cprojf; # introduced=23
+    cprojl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    creal; # introduced=23
+    crealf; # introduced=23
+    creall; # introduced=23
+    csin; # introduced=23
+    csinf; # introduced=23
+    csinh; # introduced=23
+    csinhf; # introduced=23
+    csqrt; # introduced=23
+    csqrtf; # introduced=23
+    csqrtl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    ctan; # introduced=23
+    ctanf; # introduced=23
+    ctanh; # introduced=23
+    ctanhf; # introduced=23
     drem;
     dremf;
     erf;
     erfc;
     erfcf;
-    erfcl;
+    erfcl; # introduced=21
     erff;
-    erfl;
+    erfl; # introduced=21
     exp;
     exp2;
     exp2f;
-    exp2l;
+    exp2l; # introduced=21
     expf;
-    expl;
+    expl; # introduced=21
     expm1;
     expm1f;
-    expm1l;
+    expm1l; # introduced=21
     fabs;
     fabsf;
     fabsl;
     fdim;
     fdimf;
     fdiml;
-    feclearexcept;
-    fedisableexcept;
-    feenableexcept;
-    fegetenv;
-    fegetexcept;
-    fegetexceptflag;
-    fegetround;
-    feholdexcept;
-    feraiseexcept;
-    fesetenv;
-    fesetexceptflag;
-    fesetround;
-    fetestexcept;
-    feupdateenv;
+    feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
     finite;
     finitef;
     floor;
@@ -132,7 +132,7 @@
     floorl;
     fma;
     fmaf;
-    fmal;
+    fmal; # introduced=21
     fmax;
     fmaxf;
     fmaxl;
@@ -141,17 +141,17 @@
     fminl;
     fmod;
     fmodf;
-    fmodl;
+    fmodl; # introduced=21
     frexp;
     frexpf;
-    frexpl;
+    frexpl; # introduced=21
     gamma;
     gamma_r;
     gammaf;
     gammaf_r;
     hypot;
     hypotf;
-    hypotl;
+    hypotl; # introduced=21
     ilogb;
     ilogbf;
     ilogbl;
@@ -167,77 +167,77 @@
     lgamma_r;
     lgammaf;
     lgammaf_r;
-    lgammal;
-    lgammal_r;
+    lgammal; # introduced=21
+    lgammal_r; # introduced=23
     llrint;
     llrintf;
-    llrintl;
+    llrintl; # introduced=21
     llround;
     llroundf;
     llroundl;
     log;
     log10;
     log10f;
-    log10l;
+    log10l; # introduced=21
     log1p;
     log1pf;
-    log1pl;
-    log2;
-    log2f;
-    log2l;
+    log1pl; # introduced=21
+    log2; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2f; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2l; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logb;
     logbf;
-    logbl;
+    logbl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logf;
-    logl;
+    logl; # introduced=21
     lrint;
     lrintf;
-    lrintl;
+    lrintl; # introduced=21
     lround;
     lroundf;
     lroundl;
     modf;
     modff;
-    modfl;
-    nan;
-    nanf;
-    nanl;
+    modfl; # introduced=21
+    nan; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanl; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
     nearbyint;
     nearbyintf;
-    nearbyintl;
+    nearbyintl; # introduced=21
     nextafter;
     nextafterf;
-    nextafterl;
-    nexttoward;
+    nextafterl; # introduced=21
+    nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     nexttowardf;
-    nexttowardl;
+    nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     pow;
     powf;
-    powl;
+    powl; # introduced=21
     remainder;
     remainderf;
-    remainderl;
+    remainderl; # introduced=21
     remquo;
     remquof;
-    remquol;
+    remquol; # introduced=21
     rint;
     rintf;
-    rintl;
+    rintl; # introduced=21
     round;
     roundf;
     roundl;
     scalb;
     scalbf;
-    scalbln;
-    scalblnf;
-    scalblnl;
+    scalbln; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     scalbn;
     scalbnf;
     scalbnl;
-    signgam;
+    signgam; # var
     significand;
     significandf;
-    significandl;
+    significandl; # introduced=21
     sin;
     sincos;
     sincosf;
@@ -245,20 +245,20 @@
     sinf;
     sinh;
     sinhf;
-    sinhl;
-    sinl;
+    sinhl; # introduced=21
+    sinl; # introduced=21
     sqrt;
     sqrtf;
-    sqrtl;
+    sqrtl; # introduced=21
     tan;
     tanf;
     tanh;
     tanhf;
-    tanhl;
-    tanl;
+    tanhl; # introduced=21
+    tanl; # introduced=21
     tgamma;
-    tgammaf;
-    tgammal;
+    tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    tgammal; # introduced=21
     trunc;
     truncf;
     truncl;
@@ -272,3 +272,26 @@
     *;
 };
 
+LIBC_O {
+  global:
+    cacoshl;
+    cacosl;
+    casinhl;
+    casinl;
+    catanhl;
+    catanl;
+    ccoshl;
+    ccosl;
+    cexpl;
+    clog;
+    clogf;
+    clogl;
+    cpow;
+    cpowf;
+    cpowl;
+    csinhl;
+    csinl;
+    ctanhl;
+    ctanl;
+} LIBC;
+
diff --git a/libm/libm.x86_64.map b/libm/libm.x86_64.map
index 1623ea0..3e259dd 100644
--- a/libm/libm.x86_64.map
+++ b/libm/libm.x86_64.map
@@ -1,7 +1,7 @@
-# Generated by genversionscripts.py. Do not edit.
+# Generated by genversion-scripts.py. Do not edit.
 LIBC {
   global:
-    __fe_dfl_env;
+    __fe_dfl_env; # var
     __signbit;
     __signbitf;
     __signbitl;
@@ -9,59 +9,59 @@
     acosf;
     acosh;
     acoshf;
-    acoshl;
-    acosl;
+    acoshl; # introduced=21
+    acosl; # introduced=21
     asin;
     asinf;
     asinh;
     asinhf;
-    asinhl;
-    asinl;
+    asinhl; # introduced=21
+    asinl; # introduced=21
     atan;
     atan2;
     atan2f;
-    atan2l;
+    atan2l; # introduced=21
     atanf;
     atanh;
     atanhf;
-    atanhl;
-    atanl;
-    cabs;
-    cabsf;
-    cabsl;
-    cacos;
-    cacosf;
-    cacosh;
-    cacoshf;
-    carg;
-    cargf;
-    cargl;
-    casin;
-    casinf;
-    casinh;
-    casinhf;
-    catan;
-    catanf;
-    catanh;
-    catanhf;
+    atanhl; # introduced=21
+    atanl; # introduced=21
+    cabs; # introduced=23
+    cabsf; # introduced=23
+    cabsl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    cacos; # introduced=23
+    cacosf; # introduced=23
+    cacosh; # introduced=23
+    cacoshf; # introduced=23
+    carg; # introduced=23
+    cargf; # introduced=23
+    cargl; # introduced=23
+    casin; # introduced=23
+    casinf; # introduced=23
+    casinh; # introduced=23
+    casinhf; # introduced=23
+    catan; # introduced=23
+    catanf; # introduced=23
+    catanh; # introduced=23
+    catanhf; # introduced=23
     cbrt;
     cbrtf;
-    cbrtl;
-    ccos;
-    ccosf;
-    ccosh;
-    ccoshf;
+    cbrtl; # introduced=21
+    ccos; # introduced=23
+    ccosf; # introduced=23
+    ccosh; # introduced=23
+    ccoshf; # introduced=23
     ceil;
     ceilf;
     ceill;
-    cexp;
-    cexpf;
-    cimag;
-    cimagf;
-    cimagl;
-    conj;
-    conjf;
-    conjl;
+    cexp; # introduced=23
+    cexpf; # introduced=23
+    cimag; # introduced=23
+    cimagf; # introduced=23
+    cimagl; # introduced=23
+    conj; # introduced=23
+    conjf; # introduced=23
+    conjl; # introduced=23
     copysign;
     copysignf;
     copysignl;
@@ -69,62 +69,62 @@
     cosf;
     cosh;
     coshf;
-    coshl;
-    cosl;
-    cproj;
-    cprojf;
-    cprojl;
-    creal;
-    crealf;
-    creall;
-    csin;
-    csinf;
-    csinh;
-    csinhf;
-    csqrt;
-    csqrtf;
-    csqrtl;
-    ctan;
-    ctanf;
-    ctanh;
-    ctanhf;
+    coshl; # introduced=21
+    cosl; # introduced=21
+    cproj; # introduced=23
+    cprojf; # introduced=23
+    cprojl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    creal; # introduced=23
+    crealf; # introduced=23
+    creall; # introduced=23
+    csin; # introduced=23
+    csinf; # introduced=23
+    csinh; # introduced=23
+    csinhf; # introduced=23
+    csqrt; # introduced=23
+    csqrtf; # introduced=23
+    csqrtl; # introduced-arm=21 introduced-arm64=23 introduced-mips=21 introduced-mips64=23 introduced-x86=21 introduced-x86_64=23
+    ctan; # introduced=23
+    ctanf; # introduced=23
+    ctanh; # introduced=23
+    ctanhf; # introduced=23
     drem;
     dremf;
     erf;
     erfc;
     erfcf;
-    erfcl;
+    erfcl; # introduced=21
     erff;
-    erfl;
+    erfl; # introduced=21
     exp;
     exp2;
     exp2f;
-    exp2l;
+    exp2l; # introduced=21
     expf;
-    expl;
+    expl; # introduced=21
     expm1;
     expm1f;
-    expm1l;
+    expm1l; # introduced=21
     fabs;
     fabsf;
     fabsl;
     fdim;
     fdimf;
     fdiml;
-    feclearexcept;
-    fedisableexcept;
-    feenableexcept;
-    fegetenv;
-    fegetexcept;
-    fegetexceptflag;
-    fegetround;
-    feholdexcept;
-    feraiseexcept;
-    fesetenv;
-    fesetexceptflag;
-    fesetround;
-    fetestexcept;
-    feupdateenv;
+    feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fegetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fesetround; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-mips=21 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
     finite;
     finitef;
     floor;
@@ -132,7 +132,7 @@
     floorl;
     fma;
     fmaf;
-    fmal;
+    fmal; # introduced=21
     fmax;
     fmaxf;
     fmaxl;
@@ -141,17 +141,17 @@
     fminl;
     fmod;
     fmodf;
-    fmodl;
+    fmodl; # introduced=21
     frexp;
     frexpf;
-    frexpl;
+    frexpl; # introduced=21
     gamma;
     gamma_r;
     gammaf;
     gammaf_r;
     hypot;
     hypotf;
-    hypotl;
+    hypotl; # introduced=21
     ilogb;
     ilogbf;
     ilogbl;
@@ -167,77 +167,77 @@
     lgamma_r;
     lgammaf;
     lgammaf_r;
-    lgammal;
-    lgammal_r;
+    lgammal; # introduced=21
+    lgammal_r; # introduced=23
     llrint;
     llrintf;
-    llrintl;
+    llrintl; # introduced=21
     llround;
     llroundf;
     llroundl;
     log;
     log10;
     log10f;
-    log10l;
+    log10l; # introduced=21
     log1p;
     log1pf;
-    log1pl;
-    log2;
-    log2f;
-    log2l;
+    log1pl; # introduced=21
+    log2; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2f; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    log2l; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logb;
     logbf;
-    logbl;
+    logbl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     logf;
-    logl;
+    logl; # introduced=21
     lrint;
     lrintf;
-    lrintl;
+    lrintl; # introduced=21
     lround;
     lroundf;
     lroundl;
     modf;
     modff;
-    modfl;
-    nan;
-    nanf;
-    nanl;
+    modfl; # introduced=21
+    nan; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    nanl; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
     nearbyint;
     nearbyintf;
-    nearbyintl;
+    nearbyintl; # introduced=21
     nextafter;
     nextafterf;
-    nextafterl;
-    nexttoward;
+    nextafterl; # introduced=21
+    nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     nexttowardf;
-    nexttowardl;
+    nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     pow;
     powf;
-    powl;
+    powl; # introduced=21
     remainder;
     remainderf;
-    remainderl;
+    remainderl; # introduced=21
     remquo;
     remquof;
-    remquol;
+    remquol; # introduced=21
     rint;
     rintf;
-    rintl;
+    rintl; # introduced=21
     round;
     roundf;
     roundl;
     scalb;
     scalbf;
-    scalbln;
-    scalblnf;
-    scalblnl;
+    scalbln; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+    scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-mips=9 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
     scalbn;
     scalbnf;
     scalbnl;
-    signgam;
+    signgam; # var
     significand;
     significandf;
-    significandl;
+    significandl; # introduced=21
     sin;
     sincos;
     sincosf;
@@ -245,20 +245,20 @@
     sinf;
     sinh;
     sinhf;
-    sinhl;
-    sinl;
+    sinhl; # introduced=21
+    sinl; # introduced=21
     sqrt;
     sqrtf;
-    sqrtl;
+    sqrtl; # introduced=21
     tan;
     tanf;
     tanh;
     tanhf;
-    tanhl;
-    tanl;
+    tanhl; # introduced=21
+    tanl; # introduced=21
     tgamma;
-    tgammaf;
-    tgammal;
+    tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=9 introduced-x86_64=21
+    tgammal; # introduced=21
     trunc;
     truncf;
     truncl;
@@ -272,3 +272,26 @@
     *;
 };
 
+LIBC_O {
+  global:
+    cacoshl;
+    cacosl;
+    casinhl;
+    casinl;
+    catanhl;
+    catanl;
+    ccoshl;
+    ccosl;
+    cexpl;
+    clog;
+    clogf;
+    clogl;
+    cpow;
+    cpowf;
+    cpowl;
+    csinhl;
+    csinl;
+    ctanhl;
+    ctanl;
+} LIBC;
+
diff --git a/libm/upstream-freebsd/android/include/machine/endian.h b/libm/upstream-freebsd/android/include/machine/endian.h
new file mode 100644
index 0000000..2dc4d83
--- /dev/null
+++ b/libm/upstream-freebsd/android/include/machine/endian.h
@@ -0,0 +1 @@
+#include <endian.h>
diff --git a/libm/upstream-netbsd/lib/libm/complex/cacoshl.c b/libm/upstream-netbsd/lib/libm/complex/cacoshl.c
new file mode 100644
index 0000000..4e4e006
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cacoshl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: cacoshl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+
+long double complex
+cacoshl(long double complex z)
+{
+	long double complex w;
+
+#if 0 /* does not give the principal value */
+	w = I * cacosl(z);
+#else
+	w = clogl(z + csqrtl(z + 1) * csqrtl(z - 1));
+#endif
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cacosl.c b/libm/upstream-netbsd/lib/libm/complex/cacosl.c
new file mode 100644
index 0000000..e481158
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cacosl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: cacosl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+cacosl(long double complex z)
+{
+	long double complex w;
+
+	w = casinl(z);
+	w = (M_PI_2L - creall(w)) - cimagl(w) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/casinhl.c b/libm/upstream-netbsd/lib/libm/complex/casinhl.c
new file mode 100644
index 0000000..9f74ee9
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/casinhl.c
@@ -0,0 +1,42 @@
+/* $NetBSD: casinhl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+
+long double complex
+casinhl(long double complex z)
+{
+	long double complex w;
+
+	w = -1.0L * I * casinl(z * I);
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/casinl.c b/libm/upstream-netbsd/lib/libm/complex/casinl.c
new file mode 100644
index 0000000..986a8c0
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/casinl.c
@@ -0,0 +1,120 @@
+/* $NetBSD: casinl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+#ifdef __weak_alias
+__weak_alias(casinl, _casinl)
+#endif
+
+long double complex
+casinl(long double complex z)
+{
+	long double complex w;
+	long double complex ca, ct, zz, z2;
+	long double x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+
+#if 0 /* MD: test is incorrect, casin(>1) is defined */
+	if (y == 0.0L) {
+		if (fabsl(x) > 1.0L) {
+			w = M_PI_2L + 0.0L * I;
+#if 0
+			mtherr ("casinl", DOMAIN);
+#endif
+		} else {
+			w = asinl(x) + 0.0L * I;
+		}
+		return w;
+	}
+#endif
+
+/* Power series expansion */
+/*
+b = cabsl(z);
+if( b < 0.125L )
+{
+z2.r = (x - y) * (x + y);
+z2.i = 2.0L * x * y;
+
+cn = 1.0L;
+n = 1.0L;
+ca.r = x;
+ca.i = y;
+sum.r = x;
+sum.i = y;
+do
+	{
+	ct.r = z2.r * ca.r  -  z2.i * ca.i;
+	ct.i = z2.r * ca.i  +  z2.i * ca.r;
+	ca.r = ct.r;
+	ca.i = ct.i;
+
+	cn *= n;
+	n += 1.0;
+	cn /= n;
+	n += 1.0;
+	b = cn/n;
+
+	ct.r *= b;
+	ct.i *= b;
+	sum.r += ct.r;
+	sum.i += ct.i;
+	b = fabsl(ct.r) + fabsl(ct.i);
+	}
+while( b > MACHEPL );
+w->r = sum.r;
+w->i = sum.i;
+return;
+}
+*/
+
+
+	ca = x + y * I;
+	ct = ca * I;
+	/* sqrtl( 1 - z*z) */
+	/* cmull( &ca, &ca, &zz ) */
+	/*x * x  -  y * y */
+	zz = (x - y) * (x + y) + (2.0L * x * y) * I;
+
+	zz = 1.0L - creall(zz) - cimagl(zz) * I;
+	z2 = csqrtl(zz);
+
+	zz = ct + z2;
+	zz = clogl(zz);
+	/* multiply by 1/i = -i */
+	w = zz * (-1.0L * I);
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/catanhl.c b/libm/upstream-netbsd/lib/libm/complex/catanhl.c
new file mode 100644
index 0000000..4969b70
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/catanhl.c
@@ -0,0 +1,42 @@
+/* $NetBSD: catanhl.c,v 1.3 2014/10/10 12:43:15 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+
+long double complex
+catanhl(long double complex z)
+{
+	long double complex w;
+
+	w = -1.0L * I * catanl(z * I);
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/catanl.c b/libm/upstream-netbsd/lib/libm/complex/catanl.c
new file mode 100644
index 0000000..bdff23f
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/catanl.c
@@ -0,0 +1,80 @@
+/* $NetBSD: catanl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include <float.h>
+#include "cephes_subrl.h"
+
+#ifdef __weak_alias
+__weak_alias(catanl, _catanl)
+#endif
+
+#define MAXNUM LDBL_MAX
+
+long double complex
+catanl(long double complex z)
+{
+	long double complex w;
+	long double a, t, x, x2, y;
+
+	x = creall(z);
+	y = cimagl(z);
+
+	if ((x == 0.0L) && (y > 1.0L))
+		goto ovrf;
+
+	x2 = x * x;
+	a = 1.0L - x2 - (y * y);
+	if (a == 0.0)
+		goto ovrf;
+
+	t = 0.5L * atan2l(2.0L * x, a);
+	w = _redupil(t);
+
+	t = y - 1.0L;
+	a = x2 + (t * t);
+	if (a == 0.0L)
+		goto ovrf;
+
+	t = y + 1.0L;
+	a = (x2 + (t * t))/a;
+	w = w + (0.25L * logl(a)) * I;
+	return w;
+
+ovrf:
+#if 0
+	mtherr ("catanl", OVERFLOW);
+#endif
+	w = MAXNUM + MAXNUM * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ccoshl.c b/libm/upstream-netbsd/lib/libm/complex/ccoshl.c
new file mode 100644
index 0000000..4c33f9d
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ccoshl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: ccoshl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double complex
+ccoshl(long double complex z)
+{
+	long double complex w;
+	long double x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+	w = coshl(x) * cosl(y) + (sinhl(x) * sinl(y)) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ccosl.c b/libm/upstream-netbsd/lib/libm/complex/ccosl.c
new file mode 100644
index 0000000..6ce5661
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ccosl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: ccosl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+ccosl(long double complex z)
+{
+	long double complex w;
+	long double ch, sh;
+
+	_cchshl(cimagl(z), &ch, &sh);
+	w = cosl(creall(z)) * ch - (sinl(creall(z)) * sh) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.c b/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.c
new file mode 100644
index 0000000..90dbd86
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.c
@@ -0,0 +1,129 @@
+/* $NetBSD: cephes_subrl.c,v 1.2 2014/10/10 14:06:40 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+/* calculate cosh and sinh */
+
+void
+_cchshl(long double x, long double *c, long double *s)
+{
+	long double e, ei;
+
+	if (fabsl(x) <= 0.5L) {
+		*c = coshl(x);
+		*s = sinhl(x);
+	} else {
+		e = expl(x);
+		ei = 0.5L / e;
+		e = 0.5L * e;
+		*s = e - ei;
+		*c = e + ei;
+	}
+}
+
+/* Program to subtract nearest integer multiple of PI */
+
+/* extended precision value of PI: */
+static const long double DP1 = 3.14159265358979323829596852490908531763125L;
+static const long double DP2 = 1.6667485837041756656403424829301998703007e-19L;
+#ifndef __vax__
+static const long double DP3 = 1.8830410776607851167459095484560349402753e-39L;
+#define MACHEPL 1.1e-38L
+#else
+static const long double DP3 = 0L;
+#define MACHEPL 1.1e-19L
+#endif
+
+long double
+_redupil(long double x)
+{
+	long double t;
+	long long i;
+
+	t = x / M_PIL;
+	if (t >= 0.0L)
+		t += 0.5L;
+	else
+		t -= 0.5L;
+
+	i = t;	/* the multiple */
+	t = i;
+	t = ((x - t * DP1) - t * DP2) - t * DP3;
+	return t;
+}
+
+/* Taylor series expansion for cosh(2y) - cos(2x) */
+
+long double
+_ctansl(long double complex z)
+{
+	long double f, x, x2, y, y2, rn, t;
+	long double d;
+
+	x = fabsl(2.0L * creall(z));
+	y = fabsl(2.0L * cimagl(z));
+
+	x = _redupil(x);
+
+	x = x * x;
+	y = y * y;
+	x2 = 1.0;
+	y2 = 1.0;
+	f = 1.0;
+	rn = 0.0;
+	d = 0.0;
+	do {
+		rn += 1.0L;
+		f *= rn;
+		rn += 1.0L;
+		f *= rn;
+		x2 *= x;
+		y2 *= y;
+		t = y2 + x2;
+		t /= f;
+		d += t;
+
+		rn += 1.0L;
+		f *= rn;
+		rn += 1.0L;
+		f *= rn;
+		x2 *= x;
+		y2 *= y;
+		t = y2 - x2;
+		t /= f;
+		d += t;
+	} while (fabsl(t/d) > MACHEPL);
+	return d;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.h b/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.h
new file mode 100644
index 0000000..6354b23
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.h
@@ -0,0 +1,9 @@
+/* $NetBSD: cephes_subrl.h,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+void _cchshl(long double, long double *, long double *);
+long double _redupil(long double);
+long double _ctansl(long double complex);
+
+#define	M_PIL	3.14159265358979323846264338327950280e+00L
+#define	M_PI_2L	1.57079632679489661923132169163975140e+00L
+
diff --git a/libm/upstream-netbsd/lib/libm/complex/cexpl.c b/libm/upstream-netbsd/lib/libm/complex/cexpl.c
new file mode 100644
index 0000000..a1e2235
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cexpl.c
@@ -0,0 +1,47 @@
+/* $NetBSD: cexpl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double complex
+cexpl(long double complex z)
+{
+	long double complex w;
+	long double r, x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+	r = expl(x);
+	w = r * cosl(y) + r * sinl(y) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/clog.c b/libm/upstream-netbsd/lib/libm/complex/clog.c
new file mode 100644
index 0000000..6362c44
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/clog.c
@@ -0,0 +1,47 @@
+/* $NetBSD: clog.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+double complex
+clog(double complex z)
+{
+	double complex w;
+	double p, rr;
+
+	rr = cabs(z);
+	p = log(rr);
+	rr = atan2(cimag(z), creal(z));
+	w = p + rr * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/clogf.c b/libm/upstream-netbsd/lib/libm/complex/clogf.c
new file mode 100644
index 0000000..c3cdad0
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/clogf.c
@@ -0,0 +1,47 @@
+/* $NetBSD: clogf.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+float complex
+clogf(float complex z)
+{
+	float complex w;
+	float p, rr;
+
+	rr = cabsf(z);
+	p = logf(rr);
+	rr = atan2f(cimagf(z), crealf(z));
+	w = p + rr * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/clogl.c b/libm/upstream-netbsd/lib/libm/complex/clogl.c
new file mode 100644
index 0000000..11e7a15
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/clogl.c
@@ -0,0 +1,47 @@
+/* $NetBSD: clogl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double complex
+clogl(long double complex z)
+{
+	long double complex w;
+	long double p, rr;
+
+	rr = cabsl(z);
+	p = logl(rr);
+	rr = atan2l(cimagl(z), creall(z));
+	w = p + rr * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cpow.c b/libm/upstream-netbsd/lib/libm/complex/cpow.c
new file mode 100644
index 0000000..5bc8d3f
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cpow.c
@@ -0,0 +1,57 @@
+/* $NetBSD: cpow.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+double complex
+cpow(double complex a, double complex z)
+{
+	double complex w;
+	double x, y, r, theta, absa, arga;
+
+	x = creal(z);
+	y = cimag(z);
+	absa = cabs(a);
+	if (absa == 0.0) {
+		return (0.0 + 0.0 * I);
+	}
+	arga = carg(a);
+	r = pow(absa, x);
+	theta = x * arga;
+	if (y != 0.0) {
+		r = r * exp(-y * arga);
+		theta = theta + y * log(absa);
+	}
+	w = r * cos(theta) + (r * sin(theta)) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cpowf.c b/libm/upstream-netbsd/lib/libm/complex/cpowf.c
new file mode 100644
index 0000000..f7af10a
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cpowf.c
@@ -0,0 +1,57 @@
+/* $NetBSD: cpowf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+float complex
+cpowf(float complex a, float complex z)
+{
+	float complex w;
+	float x, y, r, theta, absa, arga;
+
+	x = crealf(z);
+	y = cimagf(z);
+	absa = cabsf(a);
+	if (absa == 0.0f) {
+		return (0.0f + 0.0f * I);
+	}
+	arga = cargf(a);
+	r = powf(absa, x);
+	theta = x * arga;
+	if (y != 0.0f) {
+		r = r * expf(-y * arga);
+		theta = theta + y * logf(absa);
+	}
+	w = r * cosf(theta) + (r * sinf(theta)) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cpowl.c b/libm/upstream-netbsd/lib/libm/complex/cpowl.c
new file mode 100644
index 0000000..39336ea
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cpowl.c
@@ -0,0 +1,57 @@
+/* $NetBSD: cpowl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double complex
+cpowl(long double complex a, long double complex z)
+{
+	long double complex w;
+	long double x, y, r, theta, absa, arga;
+
+	x = creall(z);
+	y = cimagl(z);
+	absa = cabsl(a);
+	if (absa == 0.0L) {
+		return (0.0L + 0.0L * I);
+	}
+	arga = cargl(a);
+	r = powl(absa, x);
+	theta = x * arga;
+	if (y != 0.0L) {
+		r = r * expl(-y * arga);
+		theta = theta + y * logl(absa);
+	}
+	w = r * cosl(theta) + (r * sinl(theta)) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/csinhl.c b/libm/upstream-netbsd/lib/libm/complex/csinhl.c
new file mode 100644
index 0000000..b78f7f1
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/csinhl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: csinhl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double complex
+csinhl(long double complex z)
+{
+	long double complex w;
+	long double x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+	w = sinhl(x) * cosl(y) + (coshl(x) * sinl(y)) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/csinl.c b/libm/upstream-netbsd/lib/libm/complex/csinl.c
new file mode 100644
index 0000000..c86847b
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/csinl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: csinl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+csinl(long double complex z)
+{
+	long double complex w;
+	long double ch, sh;
+
+	_cchshl(cimagl(z), &ch, &sh);
+	w = sinl(creall(z)) * ch + (cosl(creall(z)) * sh) * I;
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ctanhl.c b/libm/upstream-netbsd/lib/libm/complex/ctanhl.c
new file mode 100644
index 0000000..0894dd0
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ctanhl.c
@@ -0,0 +1,48 @@
+/* $NetBSD: ctanhl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double complex
+ctanhl(long double complex z)
+{
+	long double complex w;
+	long double x, y, d;
+
+	x = creall(z);
+	y = cimagl(z);
+	d = coshl(2.0L * x) + cosl(2.0L * y);
+	w = sinhl(2.0L * x) / d  +  (sinl(2.0L * y) / d) * I;
+
+	return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ctanl.c b/libm/upstream-netbsd/lib/libm/complex/ctanl.c
new file mode 100644
index 0000000..7932aef
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ctanl.c
@@ -0,0 +1,59 @@
+/* $NetBSD: ctanl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include <float.h>
+#include "cephes_subrl.h"
+
+#define MAXNUM LDBL_MAX
+
+long double complex
+ctanl(long double complex z)
+{
+	long double complex w;
+	long double d;
+
+	d = cosl(2.0L * creall(z)) + coshl(2.0L * cimagl(z));
+
+	if (fabsl(d) < 0.25L)
+		d = _ctansl(z);
+
+	if (d == 0.0L) {
+		/* mtherr ("ctan", OVERFLOW); */
+		w = MAXNUM + MAXNUM * I;
+		return w;
+	}
+
+	w = sinl(2.0L * creall(z)) / d + (sinhl(2.0L * cimagl(z)) / d) * I;
+	return w;
+}
diff --git a/libc/include/sys/syslimits.h b/libm/upstream-netbsd/lib/libm/src/namespace.h
similarity index 100%
rename from libc/include/sys/syslimits.h
rename to libm/upstream-netbsd/lib/libm/src/namespace.h
diff --git a/libm/x86/lrint.S b/libm/x86/lrint.S
index 48d71dd..df26b30 100644
--- a/libm/x86/lrint.S
+++ b/libm/x86/lrint.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libm/x86/lrintf.S b/libm/x86/lrintf.S
index bc8fcb3..d2dae03 100644
--- a/libm/x86/lrintf.S
+++ b/libm/x86/lrintf.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libm/x86/rint.S b/libm/x86/rint.S
index 85635f2..282d3ed 100644
--- a/libm/x86/rint.S
+++ b/libm/x86/rint.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libm/x86/rintf.S b/libm/x86/rintf.S
index 9f82400..d5cbe78 100644
--- a/libm/x86/rintf.S
+++ b/libm/x86/rintf.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libm/x86_64/lrint.S b/libm/x86_64/lrint.S
index f809a1f..d678761 100644
--- a/libm/x86_64/lrint.S
+++ b/libm/x86_64/lrint.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libm/x86_64/lrintf.S b/libm/x86_64/lrintf.S
index a661cbc..3d3acfb 100644
--- a/libm/x86_64/lrintf.S
+++ b/libm/x86_64/lrintf.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libm/x86_64/rint.S b/libm/x86_64/rint.S
index 098fdc5..9731daa 100644
--- a/libm/x86_64/rint.S
+++ b/libm/x86_64/rint.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libm/x86_64/rintf.S b/libm/x86_64/rintf.S
index 09f5e9c..c3e98bf 100644
--- a/libm/x86_64/rintf.S
+++ b/libm/x86_64/rintf.S
@@ -1,16 +1,21 @@
 /*
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
+
     * Redistributions of source code must retain the above copyright notice,
     * this list of conditions and the following disclaimer.
+
     * Redistributions in binary form must reproduce the above copyright notice,
     * this list of conditions and the following disclaimer in the documentation
     * and/or other materials provided with the distribution.
+
     * Neither the name of Intel Corporation nor the names of its contributors
     * may be used to endorse or promote products derived from this software
     * without specific prior written permission.
+
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/libstdc++/NOTICE b/libstdc++/NOTICE
deleted file mode 100644
index 492770d..0000000
--- a/libstdc++/NOTICE
+++ /dev/null
@@ -1,81 +0,0 @@
-Copyright (C) 2008 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
- * Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in
-   the documentation and/or other materials provided with the
-   distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (C) 2009 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
- * Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in
-   the documentation and/or other materials provided with the
-   distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1994
-Hewlett-Packard Company
-
-Permission to use, copy, modify, distribute and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear
-in supporting documentation.  Hewlett-Packard Company makes no
-representations about the suitability of this software for any
-purpose.  It is provided "as is" without express or implied warranty.
-
-
-Copyright (c) 1996,1997
-Silicon Graphics Computer Systems, Inc.
-
-Permission to use, copy, modify, distribute and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear
-in supporting documentation.  Silicon Graphics makes no
-representations about the suitability of this software for any
-purpose.  It is provided "as is" without express or implied warranty.
-
--------------------------------------------------------------------
-
diff --git a/libstdc++/include/cctype b/libstdc++/include/cctype
deleted file mode 100644
index e0eb981..0000000
--- a/libstdc++/include/cctype
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CCTYPE__
-#define BIONIC_LIBSTDCPP_INCLUDE_CCTYPE__
-
-/*
- * Standard C++ Library wrapper around the C ctype.h header file.
- */
-
-#include <ctype.h>
-
-extern "C++" {
-
-namespace std 
-{
-using ::isalnum;
-using ::isalpha;
-using ::iscntrl;
-using ::isdigit;
-using ::isgraph;
-using ::islower;
-using ::isprint;
-using ::ispunct;
-using ::isspace;
-using ::isupper;
-using ::isxdigit;
-using ::tolower;
-using ::toupper;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CCTYPE__
diff --git a/libstdc++/include/cfloat b/libstdc++/include/cfloat
deleted file mode 100644
index 21c01d9..0000000
--- a/libstdc++/include/cfloat
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CFLOAT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CFLOAT__
-
-/*
- * Standard C++ Library wrapper around the C float.h header file.
- */
-#include <sys/limits.h>
-#include <float.h>
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CFLOAT__
diff --git a/libstdc++/include/cmath b/libstdc++/include/cmath
deleted file mode 100644
index a15b2ac..0000000
--- a/libstdc++/include/cmath
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CMATH__
-#define BIONIC_LIBSTDCPP_INCLUDE_CMATH__
-
-/*
- * Standard C++ Library wrapper around the C math.h header file.
- */
-
-#include <cstddef>
-#include <math.h>
-
-extern "C++" {
-
-namespace std
-{
-// Functions.
-using ::cos;
-using ::sin;
-using ::tan;
-using ::acos;
-using ::asin;
-using ::atan;
-using ::atan2;
-
-using ::cosh;
-using ::sinh;
-using ::tanh;
-
-using ::exp;
-using ::frexp;
-using ::ldexp;
-using ::log;
-using ::log10;
-using ::modf;
-
-using ::pow;
-using ::sqrt;
-
-using ::ceil;
-using ::fabs;
-using ::floor;
-using ::fmod;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CMATH__
diff --git a/libstdc++/include/csetjmp b/libstdc++/include/csetjmp
deleted file mode 100644
index ba82144..0000000
--- a/libstdc++/include/csetjmp
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSETJMP__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSETJMP__
-
-/*
- * Standard C++ Library wrapper around the C setjmp.h header file.
- */
-
-#include <setjmp.h>
-
-extern "C++" {
-
-#ifndef setjmp
-#define setjmp(env) setjmp (env)
-#endif
-
-namespace std
-{
-using ::jmp_buf;
-using ::longjmp;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSETJMP__
diff --git a/libstdc++/include/csignal b/libstdc++/include/csignal
deleted file mode 100644
index 84f0e1d..0000000
--- a/libstdc++/include/csignal
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSIGNAL__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSIGNAL__
-
-/*
- * Standard C++ Library wrapper around the C signal.h header file.
- */
-
-#include <signal.h>
-
-extern "C++" {
-
-namespace std
-{
-using ::sig_atomic_t;
-using ::signal;
-using ::raise;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSIGNAL__
diff --git a/libstdc++/include/cstddef b/libstdc++/include/cstddef
deleted file mode 100644
index cb06b49..0000000
--- a/libstdc++/include/cstddef
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDDEF__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDDEF__
-
-/*
- * Standard C++ Library wrapper around the C stddef.h header file.
- * The following 2 types are also declared in the 'std' namespace:
- *   . ptrdiff_t
- *   . size_t
- */
-#include <stddef.h>
-
-extern "C++" {
-
-namespace std {
-using ::ptrdiff_t;
-using ::size_t;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDDEF__
diff --git a/libstdc++/include/cstdio b/libstdc++/include/cstdio
deleted file mode 100644
index 2948d85..0000000
--- a/libstdc++/include/cstdio
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDIO__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDIO__
-
-/*
- * Standard C++ Library wrapper around the C stdio.h header file.
- */
-#include <cstddef>
-#include <stdio.h>
-
-extern "C++" {
-
-namespace std {
-using ::FILE;
-using ::fpos_t;
-
-using ::clearerr;
-using ::fclose;
-using ::feof;
-using ::ferror;
-using ::fflush;
-using ::fgetc;
-using ::fgetpos;
-using ::fgets;
-using ::fopen;
-using ::fprintf;
-using ::fputc;
-using ::fputs;
-using ::fread;
-using ::freopen;
-using ::fscanf;
-using ::fseek;
-using ::fsetpos;
-using ::ftell;
-using ::fwrite;
-using ::getc;
-using ::getchar;
-#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
-using ::gets;
-#endif
-using ::perror;
-using ::printf;
-using ::putc;
-using ::putchar;
-using ::puts;
-using ::remove;
-using ::rename;
-using ::rewind;
-using ::scanf;
-using ::setbuf;
-using ::setvbuf;
-using ::sprintf;
-using ::sscanf;
-using ::tmpfile;
-using ::tmpnam;
-using ::ungetc;
-using ::vfprintf;
-using ::vprintf;
-using ::vsprintf;
-
-using ::snprintf;
-using ::vfscanf;
-using ::vscanf;
-using ::vsnprintf;
-using ::vsscanf;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDIO__
diff --git a/libstdc++/include/cstdlib b/libstdc++/include/cstdlib
deleted file mode 100644
index bd1deae..0000000
--- a/libstdc++/include/cstdlib
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDLIB__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDLIB__
-
-/*
- * Standard C++ Library wrapper around the C stdlib.h header file.
- */
-#include <stdlib.h>
-
-extern "C++" {
-
-namespace std {
-
-using ::exit;
-using ::abort;
-using ::atexit;
-
-using ::getenv;
-using ::putenv;
-using ::setenv;
-using ::unsetenv;
-using ::clearenv;
-
-using ::mktemp;
-using ::mkstemp;
-
-using ::strtol;
-using ::strtoll;
-using ::strtoul;
-using ::strtoull;
-using ::strtod;
-using ::strtof;
-
-using ::atoi;
-using ::atol;
-using ::atoll;
-using ::atof;
-
-using ::abs;
-using ::labs;
-using ::llabs;
-
-using ::realpath;
-using ::system;
-
-using ::bsearch;
-using ::qsort;
-
-using ::jrand48;
-using ::mrand48;
-using ::nrand48;
-using ::lrand48;
-using ::seed48;
-using ::srand48;
-
-using ::rand;
-using ::srand;
-using ::random;
-using ::srandom;
-
-using ::malloc;
-using ::free;
-using ::calloc;
-using ::realloc;
-
-using ::unlockpt;
-using ::ptsname;
-using ::ptsname_r;
-using ::getpt;
-using ::grantpt;
-
-using ::div_t;
-using ::div;
-using ::ldiv_t;
-using ::ldiv;
-using ::lldiv_t;
-using ::lldiv;
-
-using ::mblen;
-using ::mbstowcs;
-using ::mbtowc;
-using ::wctomb;
-using ::wcstombs;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDLIB__
diff --git a/libstdc++/include/cstring b/libstdc++/include/cstring
deleted file mode 100644
index d3d9387..0000000
--- a/libstdc++/include/cstring
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTRING__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTRING__
-
-/*
- * Standard C++ Library wrapper around the C string.h header file.
- */
-
-#include <cstddef>
-#include <string.h>
-
-extern "C++" {
-
-namespace std
-{
-using ::memchr;
-using ::memcmp;
-using ::memcpy;
-using ::memmove;
-using ::memset;
-using ::strcat;
-using ::strchr;
-using ::strcmp;
-using ::strcoll;
-using ::strcpy;
-using ::strcspn;
-using ::strerror;
-using ::strlen;
-using ::strncat;
-using ::strncmp;
-using ::strncpy;
-using ::strpbrk;
-using ::strrchr;
-using ::strspn;
-using ::strstr;
-using ::strtok;
-using ::strxfrm;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTRING__
diff --git a/libstdc++/include/ctime b/libstdc++/include/ctime
deleted file mode 100644
index 9e6744f..0000000
--- a/libstdc++/include/ctime
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CTIME__
-#define BIONIC_LIBSTDCPP_INCLUDE_CTIME__
-
-/*
- * Standard C++ Library wrapper around the C time.h header file.
- */
-
-#include <cstddef>
-#include <time.h>
-
-extern "C++" {
-
-namespace std 
-{
-// Types.
-using ::clock_t;
-using ::time_t;
-using ::tm;
-
-// Functions.
-using ::clock;
-using ::difftime;
-using ::mktime;
-using ::time;
-using ::asctime;
-using ::ctime;
-using ::gmtime;
-using ::localtime;
-using ::strftime;
-}  // namespace std
-
-}  // extern C++
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CTIME__
diff --git a/libstdc++/include/cwctype_is_not_supported b/libstdc++/include/cwctype_is_not_supported
deleted file mode 100644
index a4f9f42..0000000
--- a/libstdc++/include/cwctype_is_not_supported
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* IMPORTANT: cwchar and cwctype are not supported. See comment in
- * bionic/libc/include/wchar.h */
diff --git a/libstdc++/include/new b/libstdc++/include/new
index c5a43de..cffab6e 100644
--- a/libstdc++/include/new
+++ b/libstdc++/include/new
@@ -2,30 +2,33 @@
 #ifndef __NEW__
 #define __NEW__
 
-#include <cstddef>
+#include <stddef.h>
 
 extern "C++" {
 
 namespace std {
-    struct nothrow_t {};
-    extern const nothrow_t nothrow;
+  using ::size_t;
+  struct nothrow_t {};
+  extern const nothrow_t nothrow;
 }
 
 void* operator new(std::size_t);
-void* operator new[](std::size_t);
-void  operator delete(void*) throw();
-void  operator delete[](void*) throw();
 void* operator new(std::size_t, const std::nothrow_t&);
-void* operator new[](std::size_t, const std::nothrow_t&);
-void  operator delete(void*, const std::nothrow_t&) throw();
-void  operator delete[](void*, const std::nothrow_t&) throw();
+void operator delete(void*) throw();
+// TODO: void operator delete(void*, std::size_t) throw();
+void operator delete(void*, const std::nothrow_t&) throw();
 
+void* operator new[](std::size_t);
+void* operator new[](std::size_t, const std::nothrow_t&);
+void operator delete[](void*) throw();
+// TODO: void operator delete[](void*, std::size_t) throw();
+void operator delete[](void*, const std::nothrow_t&) throw();
+
+// These four are not replaceable, so should be inlined.
 inline void* operator new(std::size_t, void* p) { return p; }
 inline void* operator new[](std::size_t, void* p) { return p; }
-
-// these next two are not really required, since exceptions are off
-inline void  operator delete(void*, void*) throw() { }
-inline void  operator delete[](void*, void*) throw() { }
+inline void operator delete(void*, void*) throw() { }
+inline void operator delete[](void*, void*) throw() { }
 
 }  // extern C++
 
diff --git a/libstdc++/include/stl_pair.h b/libstdc++/include/stl_pair.h
deleted file mode 100644
index 37f757b..0000000
--- a/libstdc++/include/stl_pair.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- *
- * Copyright (c) 1994
- * Hewlett-Packard Company
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation.  Hewlett-Packard Company makes no
- * representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- *
- * Copyright (c) 1996,1997
- * Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation.  Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- */
-
-/* NOTE: This is an internal header file, included by other STL headers.
- *   You should not attempt to use it directly.
- */
-
-#ifndef __SGI_STL_INTERNAL_PAIR_H
-#define __SGI_STL_INTERNAL_PAIR_H
-
-__STL_BEGIN_NAMESPACE
-
-template <class _T1, class _T2>
-struct pair {
-  typedef _T1 first_type;
-  typedef _T2 second_type;
-
-  _T1 first;
-  _T2 second;
-  pair() : first(), second() {}
-  pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
-
-  template <class _U1, class _U2>
-  pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
-};
-
-template <class _T1, class _T2>
-inline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
-{
-  return __x.first == __y.first && __x.second == __y.second;
-}
-
-template <class _T1, class _T2>
-inline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
-{
-  return __x.first < __y.first ||
-         (!(__y.first < __x.first) && __x.second < __y.second);
-}
-
-template <class _T1, class _T2>
-inline bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
-  return !(__x == __y);
-}
-
-template <class _T1, class _T2>
-inline bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
-  return __y < __x;
-}
-
-template <class _T1, class _T2>
-inline bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
-  return !(__y < __x);
-}
-
-template <class _T1, class _T2>
-inline bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
-  return !(__x < __y);
-}
-
-template <class _T1, class _T2>
-inline pair<_T1, _T2> make_pair(_T1 __x, _T2 __y)
-{
-  return pair<_T1, _T2>(__x, __y);
-}
-
-__STL_END_NAMESPACE
-
-#endif /* __SGI_STL_INTERNAL_PAIR_H */
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/libstdc++/include/typeinfo b/libstdc++/include/typeinfo
deleted file mode 100644
index 4b48a79..0000000
--- a/libstdc++/include/typeinfo
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _TYPEINFO_HEADER_GAURD
-#define _TYPEINFO_HEADER_GAURD
-
-extern "C++" {
-
-namespace std {
-    class type_info;
-    class bad_cast;
-    class bad_typeid;
-};
-
-
-class type_info {
-public:
-    type_info();
-    virtual ~type_info();
-
-    char const * name() const;
-
-    bool operator==(type_info const & right) const;
-    bool operator!=(type_info const & right) const;
-    bool before(type_info const & right) const;
-
-private:
-    type_info(type_info const & right);
-    type_info & operator=(type_info const & right);
-};
-
-}  // C++
-
-#endif
diff --git a/linker/Android.bp b/linker/Android.bp
new file mode 100644
index 0000000..4d770ac
--- /dev/null
+++ b/linker/Android.bp
@@ -0,0 +1,149 @@
+cc_library_static {
+    name: "liblinker_malloc",
+    clang: true,
+
+    srcs: [
+        "linker_allocator.cpp",
+        "linker_memory.cpp",
+    ],
+
+    // We need to access Bionic private headers in the linker.
+    include_dirs: ["bionic/libc"],
+}
+
+cc_binary {
+    clang: true,
+
+    srcs: [
+        "dlfcn.cpp",
+        "linker.cpp",
+        "linker_block_allocator.cpp",
+        "linker_dlwarning.cpp",
+        "linker_gdb_support.cpp",
+        "linker_globals.cpp",
+        "linker_libc_support.c",
+        "linker_main.cpp",
+        "linker_namespaces.cpp",
+        "linker_logger.cpp",
+        "linker_mapped_file_fragment.cpp",
+        "linker_phdr.cpp",
+        "linker_sdk_versions.cpp",
+        "linker_soinfo.cpp",
+        "linker_utils.cpp",
+        "rt.cpp",
+    ],
+
+    arch: {
+        arm: {
+            srcs: ["arch/arm/begin.S"],
+
+            cflags: ["-D__work_around_b_24465209__"],
+        },
+        arm64: {
+            srcs: ["arch/arm64/begin.S"],
+        },
+        x86: {
+            srcs: ["arch/x86/begin.c"],
+
+            cflags: ["-D__work_around_b_24465209__"],
+        },
+        x86_64: {
+            srcs: ["arch/x86_64/begin.S"],
+        },
+        mips: {
+            srcs: [
+                "arch/mips/begin.S",
+                "linker_mips.cpp",
+            ],
+        },
+        mips64: {
+            srcs: [
+                "arch/mips64/begin.S",
+                "linker_mips.cpp",
+            ],
+        },
+    },
+
+    // We need to access Bionic private headers in the linker.
+    include_dirs: ["bionic/libc"],
+
+    // -shared is used to overwrite the -Bstatic and -static
+    // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
+    // This dynamic linker is actually a shared object linked with static libraries.
+    ldflags: [
+        "-shared",
+        "-Wl,-Bsymbolic",
+        "-Wl,--exclude-libs,ALL",
+    ],
+
+    cflags: [
+        "-fno-stack-protector",
+        "-Wstrict-overflow=5",
+        "-fvisibility=hidden",
+        "-Wall",
+        "-Wextra",
+        "-Wunused",
+        "-Werror",
+    ],
+
+    // TODO: split out the asflags.
+    asflags: [
+        "-fno-stack-protector",
+        "-Wstrict-overflow=5",
+        "-fvisibility=hidden",
+        "-Wall",
+        "-Wextra",
+        "-Wunused",
+        "-Werror",
+    ],
+
+    conlyflags: ["-std=gnu99"],
+
+    cppflags: ["-Wold-style-cast"],
+
+    // we don't want crtbegin.o (because we have begin.o), so unset it
+    // just for this module
+    nocrt: true,
+
+    static_libs: [
+        "libc_nomalloc",
+        "libziparchive",
+        "libutils",
+        "libbase",
+        "libz",
+        "liblog",
+        "libdebuggerd_client",
+
+        // Important: The liblinker_malloc should be the last library in the list
+        // to overwrite any other malloc implementations by other static libraries.
+        "liblinker_malloc"
+    ],
+    static_executable: true,
+
+    name: "linker",
+    multilib: {
+        lib32: {
+            symlinks: ["linker_asan"],
+        },
+        lib64: {
+            suffix: "64",
+            symlinks: ["linker_asan64"],
+       },
+    },
+    target: {
+        android64: {
+            cflags: ["-DTARGET_IS_64_BIT"],
+        },
+    },
+    compile_multilib: "both",
+
+    // Leave the symbols in the shared library so that stack unwinders can produce
+    // meaningful name resolution.
+    strip: {
+        keep_symbols: true,
+    },
+
+    // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
+    // looking up symbols in the linker by mistake.
+    prefix_symbols: "__dl_",
+}
diff --git a/linker/Android.mk b/linker/Android.mk
index 4a4ca5c..ea7451c 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -1,107 +1,3 @@
 LOCAL_PATH := $(call my-dir)
 
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-
-LOCAL_SRC_FILES := \
-    debugger.cpp \
-    dlfcn.cpp \
-    linker.cpp \
-    linker_allocator.cpp \
-    linker_block_allocator.cpp \
-    linker_dlwarning.cpp \
-    linker_gdb_support.cpp \
-    linker_libc_support.c \
-    linker_mapped_file_fragment.cpp \
-    linker_memory.cpp \
-    linker_phdr.cpp \
-    linker_sdk_versions.cpp \
-    linker_utils.cpp \
-    rt.cpp \
-
-LOCAL_SRC_FILES_arm     := arch/arm/begin.S
-LOCAL_SRC_FILES_arm64   := arch/arm64/begin.S
-LOCAL_SRC_FILES_x86     := arch/x86/begin.c
-LOCAL_SRC_FILES_x86_64  := arch/x86_64/begin.S
-LOCAL_SRC_FILES_mips    := arch/mips/begin.S linker_mips.cpp
-LOCAL_SRC_FILES_mips64  := arch/mips64/begin.S linker_mips.cpp
-
-# -shared is used to overwrite the -Bstatic and -static
-# flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
-# This dynamic linker is actually a shared object linked with static libraries.
-LOCAL_LDFLAGS := \
-    -shared \
-    -Wl,-Bsymbolic \
-    -Wl,--exclude-libs,ALL \
-
-LOCAL_CFLAGS += \
-    -fno-stack-protector \
-    -Wstrict-overflow=5 \
-    -fvisibility=hidden \
-    -Wall -Wextra -Wunused -Werror \
-
-LOCAL_CFLAGS_arm += -D__work_around_b_24465209__
-LOCAL_CFLAGS_x86 += -D__work_around_b_24465209__
-
-LOCAL_CONLYFLAGS += \
-    -std=gnu99 \
-
-LOCAL_CPPFLAGS += \
-    -Wold-style-cast \
-
-ifeq ($(TARGET_IS_64_BIT),true)
-LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
-endif
-
-# We need to access Bionic private headers in the linker.
-LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
-
-# we don't want crtbegin.o (because we have begin.o), so unset it
-# just for this module
-LOCAL_NO_CRT := true
-# TODO: split out the asflags.
-LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libbase libz liblog
-
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-
-LOCAL_MODULE := linker
-LOCAL_MODULE_STEM_32 := linker
-LOCAL_MODULE_STEM_64 := linker64
-LOCAL_MULTILIB := both
-
-# Leave the symbols in the shared library so that stack unwinders can produce
-# meaningful name resolution.
-LOCAL_STRIP_MODULE := keep_symbols
-
-# Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
-# looking up symbols in the linker by mistake.
-#
-# Note we are using "=" instead of ":=" to defer the evaluation,
-# because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point.
-LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \
-  --prefix-symbols=__dl_ $(linked_module)
-
-include $(BUILD_EXECUTABLE)
-
-
-define add-linker-symlink
-$(eval _from := $(TARGET_OUT)/bin/$(1))
-$(eval _to:=$(2))
-$(_from): $(LOCAL_MODULE_MAKEFILE)
-	@echo "Symlink: $$@ -> $(_to)"
-	@mkdir -p $$(dir $$@)
-	@rm -rf $$@
-	$(hide) ln -sf $(_to) $$@
-endef
-
-$(eval $(call add-linker-symlink,linker_asan,linker))
-ifeq ($(TARGET_IS_64_BIT),true)
-$(eval $(call add-linker-symlink,linker_asan64,linker64))
-endif
-
 include $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/linker/NOTICE b/linker/NOTICE
deleted file mode 100644
index 2c70ab8..0000000
--- a/linker/NOTICE
+++ /dev/null
@@ -1,176 +0,0 @@
-Copyright (C) 2007 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
-Copyright (C) 2008 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
- * Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in
-   the documentation and/or other materials provided with the
-   distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (C) 2012 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
- * Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in
-   the documentation and/or other materials provided with the
-   distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (C) 2013 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
-Copyright (C) 2013 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
- * Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in
-   the documentation and/or other materials provided with the
-   distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (C) 2014 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
-Copyright (C) 2015 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--------------------------------------------------------------------
-
-Copyright (C) 2015 The Android Open Source Project
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
- * Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in
-   the documentation and/or other materials provided with the
-   distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
diff --git a/linker/arch/mips/begin.S b/linker/arch/mips/begin.S
index cbe1e37..1bdd358 100644
--- a/linker/arch/mips/begin.S
+++ b/linker/arch/mips/begin.S
@@ -27,7 +27,7 @@
  */
 
     .text
-    .align    4
+    .balign   16
     .type    __start,@function
 
     .ent    __start
diff --git a/linker/arch/mips64/begin.S b/linker/arch/mips64/begin.S
index 8f6b94a..b9637e7 100644
--- a/linker/arch/mips64/begin.S
+++ b/linker/arch/mips64/begin.S
@@ -41,7 +41,7 @@
 #endif
 
     .text
-    .align	4
+    .balign	16
     .type	__start,@function
 
     .ent	__start
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
deleted file mode 100644
index d4c7928..0000000
--- a/linker/debugger.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "linker.h"
-#include "linker_gdb_support.h"
-
-#include <errno.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <sys/socket.h>
-#include <sys/syscall.h>
-#include <sys/un.h>
-#include <unistd.h>
-
-extern "C" int tgkill(int tgid, int tid, int sig);
-
-// Crash actions have to be sent to the proper debuggerd.
-// On 64 bit systems, the 32 bit debuggerd is named differently.
-#if defined(TARGET_IS_64_BIT) && !defined(__LP64__)
-#define DEBUGGER_SOCKET_NAME "android:debuggerd32"
-#else
-#define DEBUGGER_SOCKET_NAME "android:debuggerd"
-#endif
-
-enum debugger_action_t {
-  // dump a crash
-  DEBUGGER_ACTION_CRASH,
-  // dump a tombstone file
-  DEBUGGER_ACTION_DUMP_TOMBSTONE,
-  // dump a backtrace only back to the socket
-  DEBUGGER_ACTION_DUMP_BACKTRACE,
-};
-
-// Message sent over the socket.
-// NOTE: Any changes to this structure must also be reflected in
-//       system/core/include/cutils/debugger.h.
-struct __attribute__((packed)) debugger_msg_t {
-  int32_t action;
-  pid_t tid;
-  uint64_t abort_msg_address;
-  int32_t original_si_code;
-};
-
-// see man(2) prctl, specifically the section about PR_GET_NAME
-#define MAX_TASK_NAME_LEN (16)
-
-static int socket_abstract_client(const char* name, int type) {
-  sockaddr_un addr;
-
-  // Test with length +1 for the *initial* '\0'.
-  size_t namelen = strlen(name);
-  if ((namelen + 1) > sizeof(addr.sun_path)) {
-    errno = EINVAL;
-    return -1;
-  }
-
-  // This is used for abstract socket namespace, we need
-  // an initial '\0' at the start of the Unix socket path.
-  //
-  // Note: The path in this case is *not* supposed to be
-  // '\0'-terminated. ("man 7 unix" for the gory details.)
-  memset(&addr, 0, sizeof(addr));
-  addr.sun_family = AF_LOCAL;
-  addr.sun_path[0] = 0;
-  memcpy(addr.sun_path + 1, name, namelen);
-
-  socklen_t alen = namelen + offsetof(sockaddr_un, sun_path) + 1;
-
-  int s = socket(AF_LOCAL, type, 0);
-  if (s == -1) {
-    return -1;
-  }
-
-  int rc = TEMP_FAILURE_RETRY(connect(s, reinterpret_cast<sockaddr*>(&addr), alen));
-  if (rc == -1) {
-    close(s);
-    return -1;
-  }
-
-  return s;
-}
-
-/*
- * Writes a summary of the signal to the log file.  We do this so that, if
- * for some reason we're not able to contact debuggerd, there is still some
- * indication of the failure in the log.
- *
- * We could be here as a result of native heap corruption, or while a
- * mutex is being held, so we don't want to use any libc functions that
- * could allocate memory or hold a lock.
- */
-static void log_signal_summary(int signum, const siginfo_t* info) {
-  const char* signal_name = "???";
-  bool has_address = false;
-  switch (signum) {
-    case SIGABRT:
-      signal_name = "SIGABRT";
-      break;
-    case SIGBUS:
-      signal_name = "SIGBUS";
-      has_address = true;
-      break;
-    case SIGFPE:
-      signal_name = "SIGFPE";
-      has_address = true;
-      break;
-    case SIGILL:
-      signal_name = "SIGILL";
-      has_address = true;
-      break;
-    case SIGSEGV:
-      signal_name = "SIGSEGV";
-      has_address = true;
-      break;
-#if defined(SIGSTKFLT)
-    case SIGSTKFLT:
-      signal_name = "SIGSTKFLT";
-      break;
-#endif
-    case SIGTRAP:
-      signal_name = "SIGTRAP";
-      break;
-  }
-
-  char thread_name[MAX_TASK_NAME_LEN + 1]; // one more for termination
-  if (prctl(PR_GET_NAME, reinterpret_cast<unsigned long>(thread_name), 0, 0, 0) != 0) {
-    strcpy(thread_name, "<name unknown>");
-  } else {
-    // short names are null terminated by prctl, but the man page
-    // implies that 16 byte names are not.
-    thread_name[MAX_TASK_NAME_LEN] = 0;
-  }
-
-  // "info" will be null if the siginfo_t information was not available.
-  // Many signals don't have an address or a code.
-  char code_desc[32]; // ", code -6"
-  char addr_desc[32]; // ", fault addr 0x1234"
-  addr_desc[0] = code_desc[0] = 0;
-  if (info != nullptr) {
-    // For a rethrown signal, this si_code will be right and the one debuggerd shows will
-    // always be SI_TKILL.
-    __libc_format_buffer(code_desc, sizeof(code_desc), ", code %d", info->si_code);
-    if (has_address) {
-      __libc_format_buffer(addr_desc, sizeof(addr_desc), ", fault addr %p", info->si_addr);
-    }
-  }
-  __libc_format_log(ANDROID_LOG_FATAL, "libc",
-                    "Fatal signal %d (%s)%s%s in tid %d (%s)",
-                    signum, signal_name, code_desc, addr_desc, gettid(), thread_name);
-}
-
-/*
- * Returns true if the handler for signal "signum" has SA_SIGINFO set.
- */
-static bool have_siginfo(int signum) {
-  struct sigaction old_action, new_action;
-
-  memset(&new_action, 0, sizeof(new_action));
-  new_action.sa_handler = SIG_DFL;
-  new_action.sa_flags = SA_RESTART;
-  sigemptyset(&new_action.sa_mask);
-
-  if (sigaction(signum, &new_action, &old_action) < 0) {
-    __libc_format_log(ANDROID_LOG_WARN, "libc", "Failed testing for SA_SIGINFO: %s",
-                      strerror(errno));
-    return false;
-  }
-  bool result = (old_action.sa_flags & SA_SIGINFO) != 0;
-
-  if (sigaction(signum, &old_action, nullptr) == -1) {
-    __libc_format_log(ANDROID_LOG_WARN, "libc", "Restore failed in test for SA_SIGINFO: %s",
-                      strerror(errno));
-  }
-  return result;
-}
-
-static void send_debuggerd_packet(siginfo_t* info) {
-  // Mutex to prevent multiple crashing threads from trying to talk
-  // to debuggerd at the same time.
-  static pthread_mutex_t crash_mutex = PTHREAD_MUTEX_INITIALIZER;
-  int ret = pthread_mutex_trylock(&crash_mutex);
-  if (ret != 0) {
-    if (ret == EBUSY) {
-      __libc_format_log(ANDROID_LOG_INFO, "libc",
-          "Another thread contacted debuggerd first; not contacting debuggerd.");
-      // This will never complete since the lock is never released.
-      pthread_mutex_lock(&crash_mutex);
-    } else {
-      __libc_format_log(ANDROID_LOG_INFO, "libc",
-                        "pthread_mutex_trylock failed: %s", strerror(ret));
-    }
-    return;
-  }
-
-  int s = socket_abstract_client(DEBUGGER_SOCKET_NAME, SOCK_STREAM | SOCK_CLOEXEC);
-  if (s == -1) {
-    __libc_format_log(ANDROID_LOG_FATAL, "libc", "Unable to open connection to debuggerd: %s",
-                      strerror(errno));
-    return;
-  }
-
-  // debuggerd knows our pid from the credentials on the
-  // local socket but we need to tell it the tid of the crashing thread.
-  // debuggerd will be paranoid and verify that we sent a tid
-  // that's actually in our process.
-  debugger_msg_t msg;
-  msg.action = DEBUGGER_ACTION_CRASH;
-  msg.tid = gettid();
-  msg.abort_msg_address = reinterpret_cast<uintptr_t>(g_abort_message);
-  msg.original_si_code = (info != nullptr) ? info->si_code : 0;
-  ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg)));
-  if (ret == sizeof(msg)) {
-    char debuggerd_ack;
-    ret = TEMP_FAILURE_RETRY(read(s, &debuggerd_ack, 1));
-    int saved_errno = errno;
-    notify_gdb_of_libraries();
-    errno = saved_errno;
-  } else {
-    // read or write failed -- broken connection?
-    __libc_format_log(ANDROID_LOG_FATAL, "libc", "Failed while talking to debuggerd: %s",
-                      strerror(errno));
-  }
-
-  close(s);
-}
-
-/*
- * Catches fatal signals so we can ask debuggerd to ptrace us before
- * we crash.
- */
-static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void*) {
-  // It's possible somebody cleared the SA_SIGINFO flag, which would mean
-  // our "info" arg holds an undefined value.
-  if (!have_siginfo(signal_number)) {
-    info = nullptr;
-  }
-
-  log_signal_summary(signal_number, info);
-
-  send_debuggerd_packet(info);
-
-  // We need to return from the signal handler so that debuggerd can dump the
-  // thread that crashed, but returning here does not guarantee that the signal
-  // will be thrown again, even for SIGSEGV and friends, since the signal could
-  // have been sent manually. Resend the signal with rt_tgsigqueueinfo(2) to
-  // preserve the SA_SIGINFO contents.
-  signal(signal_number, SIG_DFL);
-
-  struct siginfo si;
-  if (!info) {
-    memset(&si, 0, sizeof(si));
-    si.si_code = SI_USER;
-    si.si_pid = getpid();
-    si.si_uid = getuid();
-    info = &si;
-  } else if (info->si_code >= 0 || info->si_code == SI_TKILL) {
-    // rt_tgsigqueueinfo(2)'s documentation appears to be incorrect on kernels
-    // that contain commit 66dd34a (3.9+). The manpage claims to only allow
-    // negative si_code values that are not SI_TKILL, but 66dd34a changed the
-    // check to allow all si_code values in calls coming from inside the house.
-  }
-
-  int rc = syscall(SYS_rt_tgsigqueueinfo, getpid(), gettid(), signal_number, info);
-  if (rc != 0) {
-    __libc_format_log(ANDROID_LOG_FATAL, "libc", "failed to resend signal during crash: %s",
-                      strerror(errno));
-    _exit(0);
-  }
-}
-
-__LIBC_HIDDEN__ void debuggerd_init() {
-  struct sigaction action;
-  memset(&action, 0, sizeof(action));
-  sigemptyset(&action.sa_mask);
-  action.sa_sigaction = debuggerd_signal_handler;
-  action.sa_flags = SA_RESTART | SA_SIGINFO;
-
-  // Use the alternate signal stack if available so we can catch stack overflows.
-  action.sa_flags |= SA_ONSTACK;
-
-  sigaction(SIGABRT, &action, nullptr);
-  sigaction(SIGBUS, &action, nullptr);
-  sigaction(SIGFPE, &action, nullptr);
-  sigaction(SIGILL, &action, nullptr);
-  sigaction(SIGSEGV, &action, nullptr);
-#if defined(SIGSTKFLT)
-  sigaction(SIGSTKFLT, &action, nullptr);
-#endif
-  sigaction(SIGTRAP, &action, nullptr);
-}
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 12dd039..3ac61d7 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "linker.h"
+#include "linker_globals.h"
 #include "linker_dlwarning.h"
 
 #include <pthread.h>
@@ -32,10 +33,10 @@
 
 static pthread_mutex_t g_dl_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 
-static const char* __bionic_set_dlerror(char* new_value) {
+static char* __bionic_set_dlerror(char* new_value) {
   char** dlerror_slot = &reinterpret_cast<char**>(__get_tls())[TLS_SLOT_DLERROR];
 
-  const char* old_value = *dlerror_slot;
+  char* old_value = *dlerror_slot;
   *dlerror_slot = new_value;
   return old_value;
 }
@@ -51,8 +52,8 @@
   __bionic_set_dlerror(buffer);
 }
 
-const char* dlerror() {
-  const char* old_value = __bionic_set_dlerror(nullptr);
+char* dlerror() {
+  char* old_value = __bionic_set_dlerror(nullptr);
   return old_value;
 }
 
@@ -69,6 +70,7 @@
 static void* dlopen_ext(const char* filename, int flags,
                         const android_dlextinfo* extinfo, void* caller_addr) {
   ScopedPthreadMutexLocker locker(&g_dl_mutex);
+  g_linker_logger.ResetState();
   void* result = do_dlopen(filename, flags, extinfo, caller_addr);
   if (result == nullptr) {
     __bionic_format_dlerror("dlopen failed", linker_get_error_buffer());
@@ -89,6 +91,7 @@
 
 void* dlsym_impl(void* handle, const char* symbol, const char* version, void* caller_addr) {
   ScopedPthreadMutexLocker locker(&g_dl_mutex);
+  g_linker_logger.ResetState();
   void* result;
   if (!do_dlsym(handle, symbol, version, caller_addr, &result)) {
     __bionic_format_dlerror(linker_get_error_buffer(), nullptr);
@@ -182,14 +185,14 @@
     { name_offset, \
       reinterpret_cast<Elf32_Addr>(value), \
       /* st_size */ 0, \
-      (shndx == 0) ? 0 : (STB_GLOBAL << 4), \
+      ((shndx) == 0) ? 0 : (STB_GLOBAL << 4), \
       /* st_other */ 0, \
       shndx, \
     }
 
 #define ELF64_SYM_INITIALIZER(name_offset, value, shndx) \
     { name_offset, \
-      (shndx == 0) ? 0 : (STB_GLOBAL << 4), \
+      ((shndx) == 0) ? 0 : (STB_GLOBAL << 4), \
       /* st_other */ 0, \
       shndx, \
       reinterpret_cast<Elf64_Addr>(value), \
@@ -259,8 +262,6 @@
 static uint8_t __libdl_info_buf[sizeof(soinfo)] __attribute__((aligned(8)));
 static soinfo* __libdl_info = nullptr;
 
-extern android_namespace_t g_default_namespace;
-
 // This is used by the dynamic linker. Every process gets these symbols for free.
 soinfo* get_libdl_info() {
   if (__libdl_info == nullptr) {
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 9dc928e..f8531b6 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -44,8 +44,6 @@
 #include <vector>
 
 // Private C library headers.
-#include "private/bionic_globals.h"
-#include "private/bionic_tls.h"
 #include "private/KernelArgumentBlock.h"
 #include "private/ScopedPthreadMutexLocker.h"
 #include "private/ScopeGuard.h"
@@ -53,8 +51,11 @@
 #include "linker.h"
 #include "linker_block_allocator.h"
 #include "linker_gdb_support.h"
+#include "linker_globals.h"
 #include "linker_debug.h"
 #include "linker_dlwarning.h"
+#include "linker_main.h"
+#include "linker_namespaces.h"
 #include "linker_sleb128.h"
 #include "linker_phdr.h"
 #include "linker_relocs.h"
@@ -62,6 +63,7 @@
 #include "linker_utils.h"
 
 #include "android-base/strings.h"
+#include "android-base/stringprintf.h"
 #include "ziparchive/zip_archive.h"
 
 extern void __libc_init_globals(KernelArgumentBlock&);
@@ -73,88 +75,14 @@
 #undef ELF_ST_TYPE
 #define ELF_ST_TYPE(x) (static_cast<uint32_t>(x) & 0xf)
 
-struct android_namespace_t {
- public:
-  android_namespace_t() : name_(nullptr), is_isolated_(false) {}
-
-  const char* get_name() const { return name_; }
-  void set_name(const char* name) { name_ = name; }
-
-  bool is_isolated() const { return is_isolated_; }
-  void set_isolated(bool isolated) { is_isolated_ = isolated; }
-
-  const std::vector<std::string>& get_ld_library_paths() const {
-    return ld_library_paths_;
-  }
-  void set_ld_library_paths(std::vector<std::string>&& library_paths) {
-    ld_library_paths_ = library_paths;
-  }
-
-  const std::vector<std::string>& get_default_library_paths() const {
-    return default_library_paths_;
-  }
-  void set_default_library_paths(std::vector<std::string>&& library_paths) {
-    default_library_paths_ = library_paths;
-  }
-
-  const std::vector<std::string>& get_permitted_paths() const {
-    return permitted_paths_;
-  }
-  void set_permitted_paths(std::vector<std::string>&& permitted_paths) {
-    permitted_paths_ = permitted_paths;
-  }
-
-  void add_soinfo(soinfo* si) {
-    soinfo_list_.push_back(si);
-  }
-
-  void add_soinfos(const soinfo::soinfo_list_t& soinfos) {
-    for (auto si : soinfos) {
-      add_soinfo(si);
-      si->add_secondary_namespace(this);
-    }
-  }
-
-  void remove_soinfo(soinfo* si) {
-    soinfo_list_.remove_if([&](soinfo* candidate) {
-      return si == candidate;
-    });
-  }
-
-  const soinfo::soinfo_list_t& soinfo_list() const { return soinfo_list_; }
-
-  // For isolated namespaces - checks if the file is on the search path;
-  // always returns true for not isolated namespace.
-  bool is_accessible(const std::string& path);
-
- private:
-  const char* name_;
-  bool is_isolated_;
-  std::vector<std::string> ld_library_paths_;
-  std::vector<std::string> default_library_paths_;
-  std::vector<std::string> permitted_paths_;
-  soinfo::soinfo_list_t soinfo_list_;
-
-  DISALLOW_COPY_AND_ASSIGN(android_namespace_t);
-};
-
-android_namespace_t g_default_namespace;
-
-static std::unordered_map<uintptr_t, soinfo*> g_soinfo_handles_map;
 static android_namespace_t* g_anonymous_namespace = &g_default_namespace;
 
-static ElfW(Addr) get_elf_exec_load_bias(const ElfW(Ehdr)* elf);
-
 static LinkerTypeAllocator<soinfo> g_soinfo_allocator;
 static LinkerTypeAllocator<LinkedListEntry<soinfo>> g_soinfo_links_allocator;
 
 static LinkerTypeAllocator<android_namespace_t> g_namespace_allocator;
 static LinkerTypeAllocator<LinkedListEntry<android_namespace_t>> g_namespace_list_allocator;
 
-static soinfo* solist;
-static soinfo* sonext;
-static soinfo* somain; // main process, always the one after libdl_info
-
 #if defined(__LP64__)
 static const char* const kSystemLibDir     = "/system/lib64";
 static const char* const kVendorLibDir     = "/vendor/lib64";
@@ -195,15 +123,14 @@
 
 // Checks if the file exists and not a directory.
 static bool file_exists(const char* path) {
-  int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC));
-  if (fd == -1) {
+  struct stat s;
+
+  if (stat(path, &s) != 0) {
     return false;
-  } else {
-    close(fd);
-    return true;
   }
+
+  return S_ISREG(s.st_mode);
 }
-static std::string dirname(const char *path);
 
 // TODO(dimitry): The grey-list is a workaround for http://b/26394120 ---
 // gradually remove libraries from this list until it is gone.
@@ -255,28 +182,11 @@
 }
 // END OF WORKAROUND
 
-static const ElfW(Versym) kVersymNotNeeded = 0;
-static const ElfW(Versym) kVersymGlobal = 1;
-
 static const char* const* g_default_ld_paths;
 static std::vector<std::string> g_ld_preload_names;
 
-static std::vector<soinfo*> g_ld_preloads;
-
 static bool g_public_namespace_initialized;
-static soinfo::soinfo_list_t g_public_namespace;
-
-__LIBC_HIDDEN__ int g_ld_debug_verbosity;
-
-__LIBC_HIDDEN__ abort_msg_t* g_abort_message = nullptr; // For debuggerd.
-
-static std::string dirname(const char *path) {
-  const char* last_slash = strrchr(path, '/');
-  if (last_slash == path) return "/";
-  else if (last_slash == nullptr) return ".";
-  else
-    return std::string(path, last_slash - path);
-}
+static soinfo_list_t g_public_namespace;
 
 #if STATS
 struct linker_stats_t {
@@ -297,16 +207,6 @@
 uint32_t bitmask[4096];
 #endif
 
-static char __linker_dl_err_buf[768];
-
-char* linker_get_error_buffer() {
-  return &__linker_dl_err_buf[0];
-}
-
-size_t linker_get_error_buffer_size() {
-  return sizeof(__linker_dl_err_buf);
-}
-
 static void notify_gdb_of_load(soinfo* info) {
   if (info->is_linker() || info->is_main_executable()) {
     // gdb already knows about the linker and the main executable.
@@ -330,32 +230,6 @@
   notify_gdb_of_unload(&(info->link_map_head));
 }
 
-bool android_namespace_t::is_accessible(const std::string& file) {
-  if (!is_isolated_) {
-    return true;
-  }
-
-  for (const auto& dir : ld_library_paths_) {
-    if (file_is_in_dir(file, dir)) {
-      return true;
-    }
-  }
-
-  for (const auto& dir : default_library_paths_) {
-    if (file_is_in_dir(file, dir)) {
-      return true;
-    }
-  }
-
-  for (const auto& dir : permitted_paths_) {
-    if (file_is_under_dir(file, dir)) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
 LinkedListEntry<soinfo>* SoinfoListAllocator::alloc() {
   return g_soinfo_links_allocator.alloc();
 }
@@ -372,19 +246,20 @@
   g_namespace_list_allocator.free(entry);
 }
 
-static soinfo* soinfo_alloc(android_namespace_t* ns, const char* name,
-                            struct stat* file_stat, off64_t file_offset,
-                            uint32_t rtld_flags) {
+soinfo* soinfo_alloc(android_namespace_t* ns, const char* name,
+                     struct stat* file_stat, off64_t file_offset,
+                     uint32_t rtld_flags) {
   if (strlen(name) >= PATH_MAX) {
     DL_ERR("library name \"%s\" too long", name);
     return nullptr;
   }
 
+  TRACE("name %s: allocating soinfo for ns=%p", name, ns);
+
   soinfo* si = new (g_soinfo_allocator.alloc()) soinfo(ns, name, file_stat,
                                                        file_offset, rtld_flags);
 
-  sonext->next = si;
-  sonext = si;
+  solist_add_soinfo(si);
 
   si->generate_handle();
   ns->add_soinfo(si);
@@ -408,91 +283,21 @@
     }
   }
 
-  soinfo *prev = nullptr, *trav;
-
   TRACE("name %s: freeing soinfo @ %p", si->get_realpath(), si);
 
-  for (trav = solist; trav != nullptr; trav = trav->next) {
-    if (trav == si) {
-      break;
-    }
-    prev = trav;
-  }
-
-  if (trav == nullptr) {
-    // si was not in solist
-    DL_ERR("name \"%s\"@%p is not in solist!", si->get_realpath(), si);
+  if (!solist_remove_soinfo(si)) {
+    // TODO (dimitry): revisit this - for now preserving the logic
+    // but it does not look right, abort if soinfo is not in the list instead?
     return;
   }
 
   // clear links to/from si
   si->remove_all_links();
 
-  // prev will never be null, because the first entry in solist is
-  // always the static libdl_info.
-  prev->next = si->next;
-  if (si == sonext) {
-    sonext = prev;
-  }
-
   si->~soinfo();
   g_soinfo_allocator.free(si);
 }
 
-// For every path element this function checks of it exists, and is a directory,
-// and normalizes it:
-// 1. For regular path it converts it to realpath()
-// 2. For path in a zip file it uses realpath on the zipfile
-//    normalizes entry name by calling normalize_path function.
-static void resolve_paths(std::vector<std::string>& paths,
-                          std::vector<std::string>* resolved_paths) {
-  resolved_paths->clear();
-  for (const auto& path : paths) {
-    char resolved_path[PATH_MAX];
-    const char* original_path = path.c_str();
-    if (realpath(original_path, resolved_path) != nullptr) {
-      struct stat s;
-      if (stat(resolved_path, &s) == 0) {
-        if (S_ISDIR(s.st_mode)) {
-          resolved_paths->push_back(resolved_path);
-        } else {
-          DL_WARN("Warning: \"%s\" is not a directory (excluding from path)", resolved_path);
-          continue;
-        }
-      } else {
-        DL_WARN("Warning: cannot stat file \"%s\": %s", resolved_path, strerror(errno));
-        continue;
-      }
-    } else {
-      std::string zip_path;
-      std::string entry_path;
-
-      std::string normalized_path;
-
-      if (!normalize_path(original_path, &normalized_path)) {
-        DL_WARN("Warning: unable to normalize \"%s\"", original_path);
-        continue;
-      }
-
-      if (parse_zip_path(normalized_path.c_str(), &zip_path, &entry_path)) {
-        if (realpath(zip_path.c_str(), resolved_path) == nullptr) {
-          DL_WARN("Warning: unable to resolve \"%s\": %s", zip_path.c_str(), strerror(errno));
-          continue;
-        }
-
-        resolved_paths->push_back(std::string(resolved_path) + kZipFileSeparator + entry_path);
-      }
-    }
-  }
-}
-
-static void split_path(const char* path, const char* delimiters,
-                       std::vector<std::string>* paths) {
-  if (path != nullptr && path[0] != 0) {
-    *paths = android::base::Split(path, delimiters);
-  }
-}
-
 static void parse_path(const char* path, const char* delimiters,
                        std::vector<std::string>* resolved_paths) {
   std::vector<std::string> paths;
@@ -506,56 +311,6 @@
   g_default_namespace.set_ld_library_paths(std::move(ld_libary_paths));
 }
 
-void soinfo::set_dt_runpath(const char* path) {
-  if (!has_min_version(3)) {
-    return;
-  }
-
-  std::vector<std::string> runpaths;
-
-  split_path(path, ":", &runpaths);
-
-  std::string origin = dirname(get_realpath());
-  // FIXME: add $LIB and $PLATFORM.
-  std::pair<std::string, std::string> substs[] = {{"ORIGIN", origin}};
-  for (auto&& s : runpaths) {
-    size_t pos = 0;
-    while (pos < s.size()) {
-      pos = s.find("$", pos);
-      if (pos == std::string::npos) break;
-      for (const auto& subst : substs) {
-        const std::string& token = subst.first;
-        const std::string& replacement = subst.second;
-        if (s.substr(pos + 1, token.size()) == token) {
-          s.replace(pos, token.size() + 1, replacement);
-          // -1 to compensate for the ++pos below.
-          pos += replacement.size() - 1;
-          break;
-        } else if (s.substr(pos + 1, token.size() + 2) == "{" + token + "}") {
-          s.replace(pos, token.size() + 3, replacement);
-          pos += replacement.size() - 1;
-          break;
-        }
-      }
-      // Skip $ in case it did not match any of the known substitutions.
-      ++pos;
-    }
-  }
-
-  resolve_paths(runpaths, &dt_runpath_);
-}
-
-static void parse_LD_PRELOAD(const char* path) {
-  g_ld_preload_names.clear();
-  if (path != nullptr) {
-    // We have historically supported ':' as well as ' ' in LD_PRELOAD.
-    g_ld_preload_names = android::base::Split(path, " :");
-    std::remove_if(g_ld_preload_names.begin(),
-                   g_ld_preload_names.end(),
-                   [] (const std::string& s) { return s.empty(); });
-  }
-}
-
 static bool realpath_fd(int fd, std::string* realpath) {
   std::vector<char> buf(PATH_MAX), proc_self_fd(PATH_MAX);
   __libc_format_buffer(&proc_self_fd[0], proc_self_fd.size(), "/proc/self/fd/%d", fd);
@@ -581,7 +336,7 @@
 _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
   uintptr_t addr = reinterpret_cast<uintptr_t>(pc);
 
-  for (soinfo* si = solist; si != 0; si = si->next) {
+  for (soinfo* si = solist_get_head(); si != 0; si = si->next) {
     if ((addr >= si->base) && (addr < (si->base + si->size))) {
         *pcount = si->ARM_exidx_count;
         return reinterpret_cast<_Unwind_Ptr>(si->ARM_exidx);
@@ -597,7 +352,7 @@
 // loaded libraries. gcc_eh does the rest.
 int do_dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data) {
   int rv = 0;
-  for (soinfo* si = solist; si != nullptr; si = si->next) {
+  for (soinfo* si = solist_get_head(); si != nullptr; si = si->next) {
     dl_phdr_info dl_info;
     dl_info.dlpi_addr = si->link_map_head.l_addr;
     dl_info.dlpi_name = si->link_map_head.l_name;
@@ -611,336 +366,10 @@
   return rv;
 }
 
-const ElfW(Versym)* soinfo::get_versym(size_t n) const {
-  if (has_min_version(2) && versym_ != nullptr) {
-    return versym_ + n;
-  }
-
-  return nullptr;
-}
-
-ElfW(Addr) soinfo::get_verneed_ptr() const {
-  if (has_min_version(2)) {
-    return verneed_ptr_;
-  }
-
-  return 0;
-}
-
-size_t soinfo::get_verneed_cnt() const {
-  if (has_min_version(2)) {
-    return verneed_cnt_;
-  }
-
-  return 0;
-}
-
-ElfW(Addr) soinfo::get_verdef_ptr() const {
-  if (has_min_version(2)) {
-    return verdef_ptr_;
-  }
-
-  return 0;
-}
-
-size_t soinfo::get_verdef_cnt() const {
-  if (has_min_version(2)) {
-    return verdef_cnt_;
-  }
-
-  return 0;
-}
-
-template<typename F>
-static bool for_each_verdef(const soinfo* si, F functor) {
-  if (!si->has_min_version(2)) {
-    return true;
-  }
-
-  uintptr_t verdef_ptr = si->get_verdef_ptr();
-  if (verdef_ptr == 0) {
-    return true;
-  }
-
-  size_t offset = 0;
-
-  size_t verdef_cnt = si->get_verdef_cnt();
-  for (size_t i = 0; i<verdef_cnt; ++i) {
-    const ElfW(Verdef)* verdef = reinterpret_cast<ElfW(Verdef)*>(verdef_ptr + offset);
-    size_t verdaux_offset = offset + verdef->vd_aux;
-    offset += verdef->vd_next;
-
-    if (verdef->vd_version != 1) {
-      DL_ERR("unsupported verdef[%zd] vd_version: %d (expected 1) library: %s",
-          i, verdef->vd_version, si->get_realpath());
-      return false;
-    }
-
-    if ((verdef->vd_flags & VER_FLG_BASE) != 0) {
-      // "this is the version of the file itself.  It must not be used for
-      //  matching a symbol. It can be used to match references."
-      //
-      // http://www.akkadia.org/drepper/symbol-versioning
-      continue;
-    }
-
-    if (verdef->vd_cnt == 0) {
-      DL_ERR("invalid verdef[%zd] vd_cnt == 0 (version without a name)", i);
-      return false;
-    }
-
-    const ElfW(Verdaux)* verdaux = reinterpret_cast<ElfW(Verdaux)*>(verdef_ptr + verdaux_offset);
-
-    if (functor(i, verdef, verdaux) == true) {
-      break;
-    }
-  }
-
-  return true;
-}
-
-bool soinfo::find_verdef_version_index(const version_info* vi, ElfW(Versym)* versym) const {
-  if (vi == nullptr) {
-    *versym = kVersymNotNeeded;
-    return true;
-  }
-
-  *versym = kVersymGlobal;
-
-  return for_each_verdef(this,
-    [&](size_t, const ElfW(Verdef)* verdef, const ElfW(Verdaux)* verdaux) {
-      if (verdef->vd_hash == vi->elf_hash &&
-          strcmp(vi->name, get_string(verdaux->vda_name)) == 0) {
-        *versym = verdef->vd_ndx;
-        return true;
-      }
-
-      return false;
-    }
-  );
-}
-
-bool soinfo::find_symbol_by_name(SymbolName& symbol_name,
-                                 const version_info* vi,
-                                 const ElfW(Sym)** symbol) const {
-  uint32_t symbol_index;
-  bool success =
-      is_gnu_hash() ?
-      gnu_lookup(symbol_name, vi, &symbol_index) :
-      elf_lookup(symbol_name, vi, &symbol_index);
-
-  if (success) {
-    *symbol = symbol_index == 0 ? nullptr : symtab_ + symbol_index;
-  }
-
-  return success;
-}
-
-static bool is_symbol_global_and_defined(const soinfo* si, const ElfW(Sym)* s) {
-  if (ELF_ST_BIND(s->st_info) == STB_GLOBAL ||
-      ELF_ST_BIND(s->st_info) == STB_WEAK) {
-    return s->st_shndx != SHN_UNDEF;
-  } else if (ELF_ST_BIND(s->st_info) != STB_LOCAL) {
-    DL_WARN("unexpected ST_BIND value: %d for \"%s\" in \"%s\"",
-            ELF_ST_BIND(s->st_info), si->get_string(s->st_name), si->get_realpath());
-  }
-
-  return false;
-}
-
-static const ElfW(Versym) kVersymHiddenBit = 0x8000;
-
-static inline bool is_versym_hidden(const ElfW(Versym)* versym) {
-  // the symbol is hidden if bit 15 of versym is set.
-  return versym != nullptr && (*versym & kVersymHiddenBit) != 0;
-}
-
-static inline bool check_symbol_version(const ElfW(Versym) verneed,
-                                        const ElfW(Versym)* verdef) {
-  return verneed == kVersymNotNeeded ||
-      verdef == nullptr ||
-      verneed == (*verdef & ~kVersymHiddenBit);
-}
-
-bool soinfo::gnu_lookup(SymbolName& symbol_name,
-                        const version_info* vi,
-                        uint32_t* symbol_index) const {
-  uint32_t hash = symbol_name.gnu_hash();
-  uint32_t h2 = hash >> gnu_shift2_;
-
-  uint32_t bloom_mask_bits = sizeof(ElfW(Addr))*8;
-  uint32_t word_num = (hash / bloom_mask_bits) & gnu_maskwords_;
-  ElfW(Addr) bloom_word = gnu_bloom_filter_[word_num];
-
-  *symbol_index = 0;
-
-  TRACE_TYPE(LOOKUP, "SEARCH %s in %s@%p (gnu)",
-      symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
-  // test against bloom filter
-  if ((1 & (bloom_word >> (hash % bloom_mask_bits)) & (bloom_word >> (h2 % bloom_mask_bits))) == 0) {
-    TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
-        symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
-    return true;
-  }
-
-  // bloom test says "probably yes"...
-  uint32_t n = gnu_bucket_[hash % gnu_nbucket_];
-
-  if (n == 0) {
-    TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
-        symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
-    return true;
-  }
-
-  // lookup versym for the version definition in this library
-  // note the difference between "version is not requested" (vi == nullptr)
-  // and "version not found". In the first case verneed is kVersymNotNeeded
-  // which implies that the default version can be accepted; the second case results in
-  // verneed = 1 (kVersymGlobal) and implies that we should ignore versioned symbols
-  // for this library and consider only *global* ones.
-  ElfW(Versym) verneed = 0;
-  if (!find_verdef_version_index(vi, &verneed)) {
-    return false;
-  }
-
-  do {
-    ElfW(Sym)* s = symtab_ + n;
-    const ElfW(Versym)* verdef = get_versym(n);
-    // skip hidden versions when verneed == kVersymNotNeeded (0)
-    if (verneed == kVersymNotNeeded && is_versym_hidden(verdef)) {
-        continue;
-    }
-    if (((gnu_chain_[n] ^ hash) >> 1) == 0 &&
-        check_symbol_version(verneed, verdef) &&
-        strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
-        is_symbol_global_and_defined(this, s)) {
-      TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
-          symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(s->st_value),
-          static_cast<size_t>(s->st_size));
-      *symbol_index = n;
-      return true;
-    }
-  } while ((gnu_chain_[n++] & 1) == 0);
-
-  TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
-             symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
-  return true;
-}
-
-bool soinfo::elf_lookup(SymbolName& symbol_name,
-                        const version_info* vi,
-                        uint32_t* symbol_index) const {
-  uint32_t hash = symbol_name.elf_hash();
-
-  TRACE_TYPE(LOOKUP, "SEARCH %s in %s@%p h=%x(elf) %zd",
-             symbol_name.get_name(), get_realpath(),
-             reinterpret_cast<void*>(base), hash, hash % nbucket_);
-
-  ElfW(Versym) verneed = 0;
-  if (!find_verdef_version_index(vi, &verneed)) {
-    return false;
-  }
-
-  for (uint32_t n = bucket_[hash % nbucket_]; n != 0; n = chain_[n]) {
-    ElfW(Sym)* s = symtab_ + n;
-    const ElfW(Versym)* verdef = get_versym(n);
-
-    // skip hidden versions when verneed == 0
-    if (verneed == kVersymNotNeeded && is_versym_hidden(verdef)) {
-        continue;
-    }
-
-    if (check_symbol_version(verneed, verdef) &&
-        strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
-        is_symbol_global_and_defined(this, s)) {
-      TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
-                 symbol_name.get_name(), get_realpath(),
-                 reinterpret_cast<void*>(s->st_value),
-                 static_cast<size_t>(s->st_size));
-      *symbol_index = n;
-      return true;
-    }
-  }
-
-  TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p %x %zd",
-             symbol_name.get_name(), get_realpath(),
-             reinterpret_cast<void*>(base), hash, hash % nbucket_);
-
-  *symbol_index = 0;
-  return true;
-}
-
-soinfo::soinfo(android_namespace_t* ns, const char* realpath,
-               const struct stat* file_stat, off64_t file_offset,
-               int rtld_flags) {
-  memset(this, 0, sizeof(*this));
-
-  if (realpath != nullptr) {
-    realpath_ = realpath;
-  }
-
-  flags_ = FLAG_NEW_SOINFO;
-  version_ = SOINFO_VERSION;
-
-  if (file_stat != nullptr) {
-    this->st_dev_ = file_stat->st_dev;
-    this->st_ino_ = file_stat->st_ino;
-    this->file_offset_ = file_offset;
-  }
-
-  this->rtld_flags_ = rtld_flags;
-  this->primary_namespace_ = ns;
-}
-
-soinfo::~soinfo() {
-  g_soinfo_handles_map.erase(handle_);
-}
-
-static uint32_t calculate_elf_hash(const char* name) {
-  const uint8_t* name_bytes = reinterpret_cast<const uint8_t*>(name);
-  uint32_t h = 0, g;
-
-  while (*name_bytes) {
-    h = (h << 4) + *name_bytes++;
-    g = h & 0xf0000000;
-    h ^= g;
-    h ^= g >> 24;
-  }
-
-  return h;
-}
-
-uint32_t SymbolName::elf_hash() {
-  if (!has_elf_hash_) {
-    elf_hash_ = calculate_elf_hash(name_);
-    has_elf_hash_ = true;
-  }
-
-  return elf_hash_;
-}
-
-uint32_t SymbolName::gnu_hash() {
-  if (!has_gnu_hash_) {
-    uint32_t h = 5381;
-    const uint8_t* name = reinterpret_cast<const uint8_t*>(name_);
-    while (*name != 0) {
-      h += (h << 5) + *name++; // h*33 + c = h + h * 32 + c = h + h << 5 + c
-    }
-
-    gnu_hash_ =  h;
-    has_gnu_hash_ = true;
-  }
-
-  return gnu_hash_;
-}
 
 bool soinfo_do_lookup(soinfo* si_from, const char* name, const version_info* vi,
-                      soinfo** si_found_in, const soinfo::soinfo_list_t& global_group,
-                      const soinfo::soinfo_list_t& local_group, const ElfW(Sym)** symbol) {
+                      soinfo** si_found_in, const soinfo_list_t& global_group,
+                      const soinfo_list_t& local_group, const ElfW(Sym)** symbol) {
   SymbolName symbol_name(name);
   const ElfW(Sym)* s = nullptr;
 
@@ -1031,33 +460,28 @@
   return true;
 }
 
-class ProtectedDataGuard {
- public:
-  ProtectedDataGuard() {
-    if (ref_count_++ == 0) {
-      protect_data(PROT_READ | PROT_WRITE);
-    }
+ProtectedDataGuard::ProtectedDataGuard() {
+  if (ref_count_++ == 0) {
+    protect_data(PROT_READ | PROT_WRITE);
+  }
+}
+
+ProtectedDataGuard::~ProtectedDataGuard() {
+  if (ref_count_ == 0) { // overflow
+    __libc_fatal("Too many nested calls to dlopen()");
   }
 
-  ~ProtectedDataGuard() {
-    if (ref_count_ == 0) { // overflow
-      __libc_fatal("Too many nested calls to dlopen()");
-    }
-
-    if (--ref_count_ == 0) {
-      protect_data(PROT_READ);
-    }
+  if (--ref_count_ == 0) {
+    protect_data(PROT_READ);
   }
- private:
-  void protect_data(int protection) {
-    g_soinfo_allocator.protect_all(protection);
-    g_soinfo_links_allocator.protect_all(protection);
-    g_namespace_allocator.protect_all(protection);
-    g_namespace_list_allocator.protect_all(protection);
-  }
+}
 
-  static size_t ref_count_;
-};
+void ProtectedDataGuard::protect_data(int protection) {
+  g_soinfo_allocator.protect_all(protection);
+  g_soinfo_links_allocator.protect_all(protection);
+  g_namespace_allocator.protect_all(protection);
+  g_namespace_list_allocator.protect_all(protection);
+}
 
 size_t ProtectedDataGuard::ref_count_ = 0;
 
@@ -1314,7 +738,7 @@
   // Since RTLD_GLOBAL is always set for the main executable and all dt_needed shared
   // libraries and they are loaded in breath-first (correct) order we can just execute
   // dlsym(RTLD_DEFAULT, ...); instead of doing two stage lookup.
-  if (si == somain) {
+  if (si == solist_get_somain()) {
     return dlsym_linear_lookup(&g_default_namespace, name, vi, found, nullptr, RTLD_DEFAULT);
   }
 
@@ -1387,7 +811,7 @@
 
 soinfo* find_containing_library(const void* p) {
   ElfW(Addr) address = reinterpret_cast<ElfW(Addr)>(p);
-  for (soinfo* si = solist; si != nullptr; si = si->next) {
+  for (soinfo* si = solist_get_head(); si != nullptr; si = si->next) {
     if (address >= si->base && address - si->base < si->size) {
       return si;
     }
@@ -1395,52 +819,6 @@
   return nullptr;
 }
 
-ElfW(Sym)* soinfo::find_symbol_by_address(const void* addr) {
-  return is_gnu_hash() ? gnu_addr_lookup(addr) : elf_addr_lookup(addr);
-}
-
-static bool symbol_matches_soaddr(const ElfW(Sym)* sym, ElfW(Addr) soaddr) {
-  return sym->st_shndx != SHN_UNDEF &&
-      soaddr >= sym->st_value &&
-      soaddr < sym->st_value + sym->st_size;
-}
-
-ElfW(Sym)* soinfo::gnu_addr_lookup(const void* addr) {
-  ElfW(Addr) soaddr = reinterpret_cast<ElfW(Addr)>(addr) - load_bias;
-
-  for (size_t i = 0; i < gnu_nbucket_; ++i) {
-    uint32_t n = gnu_bucket_[i];
-
-    if (n == 0) {
-      continue;
-    }
-
-    do {
-      ElfW(Sym)* sym = symtab_ + n;
-      if (symbol_matches_soaddr(sym, soaddr)) {
-        return sym;
-      }
-    } while ((gnu_chain_[n++] & 1) == 0);
-  }
-
-  return nullptr;
-}
-
-ElfW(Sym)* soinfo::elf_addr_lookup(const void* addr) {
-  ElfW(Addr) soaddr = reinterpret_cast<ElfW(Addr)>(addr) - load_bias;
-
-  // Search the library's symbol table for any defined symbol which
-  // contains this address.
-  for (size_t i = 0; i < nchain_; ++i) {
-    ElfW(Sym)* sym = symtab_ + i;
-    if (symbol_matches_soaddr(sym, soaddr)) {
-      return sym;
-    }
-  }
-
-  return nullptr;
-}
-
 class ZipArchiveCache {
  public:
   ZipArchiveCache() {}
@@ -1650,7 +1028,7 @@
   return fd;
 }
 
-static const char* fix_dt_needed(const char* dt_needed, const char* sopath __unused) {
+const char* fix_dt_needed(const char* dt_needed, const char* sopath __unused) {
 #if !defined(__LP64__)
   // Work around incorrect DT_NEEDED entries for old apps: http://b/21364029
   if (get_application_target_sdk_version() <= 22) {
@@ -1667,15 +1045,6 @@
 }
 
 template<typename F>
-static void for_each_dt_needed(const soinfo* si, F action) {
-  for (const ElfW(Dyn)* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
-    if (d->d_tag == DT_NEEDED) {
-      action(fix_dt_needed(si->get_string(d->d_un.d_val), si->get_realpath()));
-    }
-  }
-}
-
-template<typename F>
 static void for_each_dt_needed(const ElfReader& elf_reader, F action) {
   for (const ElfW(Dyn)* d = elf_reader.dynamic(); d->d_tag != DT_NULL; ++d) {
     if (d->d_tag == DT_NEEDED) {
@@ -1883,7 +1252,10 @@
       // "libdl.so" and global group. There is no point in skipping
       // them because relocation process is going to use them
       // in any case.
-      bool is_libdl = si == solist;
+
+      // TODO (dimitry): remove this once linker stops imposing as libdl.so
+      bool is_libdl = (si == solist_get_head());
+
       if (is_libdl || (si->get_dt_flags_1() & DF_1_GLOBAL) != 0 ||
           !si->is_linked() || si->get_target_sdk_version() == target_sdk_version ||
           ns != &g_default_namespace) {
@@ -1955,8 +1327,8 @@
 //
 // This group consists of the main executable, LD_PRELOADs
 // and libraries with the DF_1_GLOBAL flag set.
-static soinfo::soinfo_list_t make_global_group(android_namespace_t* ns) {
-  soinfo::soinfo_list_t global_group;
+static soinfo_list_t make_global_group(android_namespace_t* ns) {
+  soinfo_list_t global_group;
   ns->soinfo_list().for_each([&](soinfo* si) {
     if ((si->get_dt_flags_1() & DF_1_GLOBAL) != 0) {
       global_group.push_back(si);
@@ -1971,12 +1343,12 @@
 // group (see make_global_group). For all others this is a group
 // of RTLD_GLOBAL libraries (which includes the global group from
 // the default namespace).
-static soinfo::soinfo_list_t get_shared_group(android_namespace_t* ns) {
+static soinfo_list_t get_shared_group(android_namespace_t* ns) {
   if (ns == &g_default_namespace) {
     return make_global_group(ns);
   }
 
-  soinfo::soinfo_list_t shared_group;
+  soinfo_list_t shared_group;
   ns->soinfo_list().for_each([&](soinfo* si) {
     if ((si->get_rtld_flags() & RTLD_GLOBAL) != 0) {
       shared_group.push_back(si);
@@ -1998,14 +1370,16 @@
 // not their transitive dependencies) as children of the start_with library.
 // This is false when find_libraries is called for dlopen(), when newly loaded
 // libraries must form a disjoint tree.
-static bool find_libraries(android_namespace_t* ns,
-                           soinfo* start_with,
-                           const char* const library_names[],
-                           size_t library_names_count, soinfo* soinfos[],
-                           std::vector<soinfo*>* ld_preloads,
-                           size_t ld_preloads_count, int rtld_flags,
-                           const android_dlextinfo* extinfo,
-                           bool add_as_children) {
+bool find_libraries(android_namespace_t* ns,
+                    soinfo* start_with,
+                    const char* const library_names[],
+                    size_t library_names_count,
+                    soinfo* soinfos[],
+                    std::vector<soinfo*>* ld_preloads,
+                    size_t ld_preloads_count,
+                    int rtld_flags,
+                    const android_dlextinfo* extinfo,
+                    bool add_as_children) {
   // Step 0: prepare.
   LoadTaskList load_tasks;
   std::unordered_map<const soinfo*, ElfReader> readers_map;
@@ -2016,7 +1390,7 @@
   }
 
   // Construct global_group.
-  soinfo::soinfo_list_t global_group = make_global_group(ns);
+  soinfo_list_t global_group = make_global_group(ns);
 
   // If soinfos array is null allocate one on stack.
   // The array is needed in case of failure; for example
@@ -2123,7 +1497,7 @@
 
 
   // Step 5: link libraries.
-  soinfo::soinfo_list_t local_group;
+  soinfo_list_t local_group;
   walk_dependencies_tree(
       (start_with != nullptr && add_as_children) ? &start_with : soinfos,
       (start_with != nullptr && add_as_children) ? 1 : soinfos_count,
@@ -2170,7 +1544,7 @@
   soinfo* si;
 
   if (name == nullptr) {
-    si = somain;
+    si = solist_get_somain();
   } else if (!find_libraries(ns, needed_by, &name, 1, &si, nullptr, 0, rtld_flags,
                              extinfo, /* add_as_children */ false)) {
     return nullptr;
@@ -2203,7 +1577,7 @@
     return;
   }
 
-  soinfo::soinfo_list_t unload_list;
+  soinfo_list_t unload_list;
   for (size_t i = 0; i < count; ++i) {
     soinfo* si = soinfos[i];
 
@@ -2226,8 +1600,8 @@
   // linked. This is why we can safely use the first one.
   soinfo* root = soinfos[0];
 
-  soinfo::soinfo_list_t local_unload_list;
-  soinfo::soinfo_list_t external_unload_list;
+  soinfo_list_t local_unload_list;
+  soinfo_list_t external_unload_list;
   soinfo* si = nullptr;
 
   while ((si = unload_list.pop_front()) != nullptr) {
@@ -2337,17 +1711,54 @@
   parse_LD_LIBRARY_PATH(ld_library_path);
 }
 
+static std::string android_dlextinfo_to_string(const android_dlextinfo* info) {
+  if (info == nullptr) {
+    return "(null)";
+  }
+
+  return android::base::StringPrintf("[flags=0x%" PRIx64 ","
+                                     " reserved_addr=%p,"
+                                     " reserved_size=0x%zx,"
+                                     " relro_fd=%d,"
+                                     " library_fd=%d,"
+                                     " library_fd_offset=0x%" PRIx64 ","
+                                     " library_namespace=%s@%p]",
+                                     info->flags,
+                                     info->reserved_addr,
+                                     info->reserved_size,
+                                     info->relro_fd,
+                                     info->library_fd,
+                                     info->library_fd_offset,
+                                     (info->flags & ANDROID_DLEXT_USE_NAMESPACE) != 0 ?
+                                        (info->library_namespace != nullptr ?
+                                          info->library_namespace->get_name() : "(null)") : "(n/a)",
+                                     (info->flags & ANDROID_DLEXT_USE_NAMESPACE) != 0 ?
+                                        info->library_namespace : nullptr);
+}
+
 void* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo,
                   void* caller_addr) {
   soinfo* const caller = find_containing_library(caller_addr);
+  android_namespace_t* ns = get_caller_namespace(caller);
+
+  LD_LOG(kLogDlopen,
+         "dlopen(name=\"%s\", flags=0x%x, extinfo=%s, caller=\"%s\", caller_ns=%s@%p) ...",
+         name,
+         flags,
+         android_dlextinfo_to_string(extinfo).c_str(),
+         caller == nullptr ? "(null)" : caller->get_realpath(),
+         ns == nullptr ? "(null)" : ns->get_name(),
+         ns);
+
+  auto failure_guard = make_scope_guard([&]() {
+    LD_LOG(kLogDlopen, "... dlopen failed: %s", linker_get_error_buffer());
+  });
 
   if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL|RTLD_NODELETE|RTLD_NOLOAD)) != 0) {
     DL_ERR("invalid flags to dlopen: %x", flags);
     return nullptr;
   }
 
-  android_namespace_t* ns = get_caller_namespace(caller);
-
   if (extinfo != nullptr) {
     if ((extinfo->flags & ~(ANDROID_DLEXT_VALID_FLAG_BITS)) != 0) {
       DL_ERR("invalid extended flags to android_dlopen_ext: 0x%" PRIx64, extinfo->flags);
@@ -2399,8 +1810,13 @@
   ProtectedDataGuard guard;
   soinfo* si = find_library(ns, translated_name, flags, extinfo, caller);
   if (si != nullptr) {
+    failure_guard.disable();
     si->call_constructors();
-    return si->to_handle();
+    void* handle = si->to_handle();
+    LD_LOG(kLogDlopen,
+           "... dlopen successful: realpath=\"%s\", soname=\"%s\", handle=%p",
+           si->get_realpath(), si->get_soname(), handle);
+    return handle;
   }
 
   return nullptr;
@@ -2510,12 +1926,16 @@
 }
 
 bool init_namespaces(const char* public_ns_sonames, const char* anon_ns_library_path) {
-  CHECK(public_ns_sonames != nullptr);
   if (g_public_namespace_initialized) {
     DL_ERR("public namespace has already been initialized.");
     return false;
   }
 
+  if (public_ns_sonames == nullptr || public_ns_sonames[0] == '\0') {
+    DL_ERR("error initializing public namespace: the list of public libraries is empty.");
+    return false;
+  }
+
   std::vector<std::string> sonames = android::base::Split(public_ns_sonames, ":");
 
   ProtectedDataGuard guard;
@@ -2558,6 +1978,13 @@
   return true;
 }
 
+static void add_soinfos_to_namespace(const soinfo_list_t& soinfos, android_namespace_t* ns) {
+  ns->add_soinfos(soinfos);
+  for (auto si : soinfos) {
+    si->add_secondary_namespace(ns);
+  }
+}
+
 android_namespace_t* create_namespace(const void* caller_addr,
                                       const char* name,
                                       const char* ld_library_path,
@@ -2597,16 +2024,16 @@
 
   if ((type & ANDROID_NAMESPACE_TYPE_SHARED) != 0) {
     // If shared - clone the parent namespace
-    ns->add_soinfos(parent_namespace->soinfo_list());
+    add_soinfos_to_namespace(parent_namespace->soinfo_list(), ns);
   } else {
     // If not shared - copy only the shared group
-    ns->add_soinfos(get_shared_group(parent_namespace));
+    add_soinfos_to_namespace(get_shared_group(parent_namespace), ns);
   }
 
   return ns;
 }
 
-static ElfW(Addr) call_ifunc_resolver(ElfW(Addr) resolver_addr) {
+ElfW(Addr) call_ifunc_resolver(ElfW(Addr) resolver_addr) {
   typedef ElfW(Addr) (*ifunc_resolver_t)(void);
   ifunc_resolver_t ifunc_resolver = reinterpret_cast<ifunc_resolver_t>(resolver_addr);
   ElfW(Addr) ifunc_addr = ifunc_resolver();
@@ -2685,6 +2112,75 @@
   return true;
 }
 
+template <typename F>
+static bool for_each_verdef(const soinfo* si, F functor) {
+  if (!si->has_min_version(2)) {
+    return true;
+  }
+
+  uintptr_t verdef_ptr = si->get_verdef_ptr();
+  if (verdef_ptr == 0) {
+    return true;
+  }
+
+  size_t offset = 0;
+
+  size_t verdef_cnt = si->get_verdef_cnt();
+  for (size_t i = 0; i<verdef_cnt; ++i) {
+    const ElfW(Verdef)* verdef = reinterpret_cast<ElfW(Verdef)*>(verdef_ptr + offset);
+    size_t verdaux_offset = offset + verdef->vd_aux;
+    offset += verdef->vd_next;
+
+    if (verdef->vd_version != 1) {
+      DL_ERR("unsupported verdef[%zd] vd_version: %d (expected 1) library: %s",
+          i, verdef->vd_version, si->get_realpath());
+      return false;
+    }
+
+    if ((verdef->vd_flags & VER_FLG_BASE) != 0) {
+      // "this is the version of the file itself.  It must not be used for
+      //  matching a symbol. It can be used to match references."
+      //
+      // http://www.akkadia.org/drepper/symbol-versioning
+      continue;
+    }
+
+    if (verdef->vd_cnt == 0) {
+      DL_ERR("invalid verdef[%zd] vd_cnt == 0 (version without a name)", i);
+      return false;
+    }
+
+    const ElfW(Verdaux)* verdaux = reinterpret_cast<ElfW(Verdaux)*>(verdef_ptr + verdaux_offset);
+
+    if (functor(i, verdef, verdaux) == true) {
+      break;
+    }
+  }
+
+  return true;
+}
+
+bool find_verdef_version_index(const soinfo* si, const version_info* vi, ElfW(Versym)* versym) {
+  if (vi == nullptr) {
+    *versym = kVersymNotNeeded;
+    return true;
+  }
+
+  *versym = kVersymGlobal;
+
+  return for_each_verdef(si,
+    [&](size_t, const ElfW(Verdef)* verdef, const ElfW(Verdaux)* verdaux) {
+      if (verdef->vd_hash == vi->elf_hash &&
+          strcmp(vi->name, si->get_string(verdaux->vda_name)) == 0) {
+        *versym = verdef->vd_ndx;
+        return true;
+      }
+
+      return false;
+    }
+  );
+}
+
 bool VersionTracker::init_verdef(const soinfo* si_from) {
   return for_each_verdef(si_from,
     [&](size_t, const ElfW(Verdef)* verdef, const ElfW(Verdaux)* verdaux) {
@@ -2703,6 +2199,10 @@
   return init_verneed(si_from) && init_verdef(si_from);
 }
 
+// TODO (dimitry): Methods below need to be moved out of soinfo
+// and in more isolated file in order minimize dependencies on
+// unnecessary object in the linker binary. Consider making them
+// independent from soinfo (?).
 bool soinfo::lookup_version_info(const VersionTracker& version_tracker, ElfW(Word) sym,
                                  const char* sym_name, const version_info** vi) {
   const ElfW(Versym)* sym_ver_ptr = get_versym(sym);
@@ -3103,394 +2603,8 @@
 }
 #endif  // !defined(__mips__)
 
-void soinfo::call_array(const char* array_name __unused, linker_function_t* functions,
-                        size_t count, bool reverse) {
-  if (functions == nullptr) {
-    return;
-  }
-
-  TRACE("[ Calling %s (size %zd) @ %p for \"%s\" ]", array_name, count, functions, get_realpath());
-
-  int begin = reverse ? (count - 1) : 0;
-  int end = reverse ? -1 : count;
-  int step = reverse ? -1 : 1;
-
-  for (int i = begin; i != end; i += step) {
-    TRACE("[ %s[%d] == %p ]", array_name, i, functions[i]);
-    call_function("function", functions[i]);
-  }
-
-  TRACE("[ Done calling %s for \"%s\" ]", array_name, get_realpath());
-}
-
-void soinfo::call_function(const char* function_name __unused, linker_function_t function) {
-  if (function == nullptr || reinterpret_cast<uintptr_t>(function) == static_cast<uintptr_t>(-1)) {
-    return;
-  }
-
-  TRACE("[ Calling %s @ %p for \"%s\" ]", function_name, function, get_realpath());
-  function();
-  TRACE("[ Done calling %s @ %p for \"%s\" ]", function_name, function, get_realpath());
-}
-
-void soinfo::call_pre_init_constructors() {
-  // DT_PREINIT_ARRAY functions are called before any other constructors for executables,
-  // but ignored in a shared library.
-  call_array("DT_PREINIT_ARRAY", preinit_array_, preinit_array_count_, false);
-}
-
-void soinfo::call_constructors() {
-  if (constructors_called) {
-    return;
-  }
-
-  // We set constructors_called before actually calling the constructors, otherwise it doesn't
-  // protect against recursive constructor calls. One simple example of constructor recursion
-  // is the libc debug malloc, which is implemented in libc_malloc_debug_leak.so:
-  // 1. The program depends on libc, so libc's constructor is called here.
-  // 2. The libc constructor calls dlopen() to load libc_malloc_debug_leak.so.
-  // 3. dlopen() calls the constructors on the newly created
-  //    soinfo for libc_malloc_debug_leak.so.
-  // 4. The debug .so depends on libc, so CallConstructors is
-  //    called again with the libc soinfo. If it doesn't trigger the early-
-  //    out above, the libc constructor will be called again (recursively!).
-  constructors_called = true;
-
-  if (!is_main_executable() && preinit_array_ != nullptr) {
-    // The GNU dynamic linker silently ignores these, but we warn the developer.
-    PRINT("\"%s\": ignoring DT_PREINIT_ARRAY in shared library!", get_realpath());
-  }
-
-  get_children().for_each([] (soinfo* si) {
-    si->call_constructors();
-  });
-
-  TRACE("\"%s\": calling constructors", get_realpath());
-
-  // DT_INIT should be called before DT_INIT_ARRAY if both are present.
-  call_function("DT_INIT", init_func_);
-  call_array("DT_INIT_ARRAY", init_array_, init_array_count_, false);
-}
-
-void soinfo::call_destructors() {
-  if (!constructors_called) {
-    return;
-  }
-  TRACE("\"%s\": calling destructors", get_realpath());
-
-  // DT_FINI_ARRAY must be parsed in reverse order.
-  call_array("DT_FINI_ARRAY", fini_array_, fini_array_count_, true);
-
-  // DT_FINI should be called after DT_FINI_ARRAY if both are present.
-  call_function("DT_FINI", fini_func_);
-
-  // This is needed on second call to dlopen
-  // after library has been unloaded with RTLD_NODELETE
-  constructors_called = false;
-}
-
-void soinfo::add_child(soinfo* child) {
-  if (has_min_version(0)) {
-    child->parents_.push_back(this);
-    this->children_.push_back(child);
-  }
-}
-
-void soinfo::remove_all_links() {
-  if (!has_min_version(0)) {
-    return;
-  }
-
-  // 1. Untie connected soinfos from 'this'.
-  children_.for_each([&] (soinfo* child) {
-    child->parents_.remove_if([&] (const soinfo* parent) {
-      return parent == this;
-    });
-  });
-
-  parents_.for_each([&] (soinfo* parent) {
-    parent->children_.remove_if([&] (const soinfo* child) {
-      return child == this;
-    });
-  });
-
-  // 2. Remove from the primary namespace
-  primary_namespace_->remove_soinfo(this);
-  primary_namespace_ = nullptr;
-
-  // 3. Remove from secondary namespaces
-  secondary_namespaces_.for_each([&](android_namespace_t* ns) {
-    ns->remove_soinfo(this);
-  });
-
-
-  // 4. Once everything untied - clear local lists.
-  parents_.clear();
-  children_.clear();
-  secondary_namespaces_.clear();
-}
-
-dev_t soinfo::get_st_dev() const {
-  if (has_min_version(0)) {
-    return st_dev_;
-  }
-
-  return 0;
-};
-
-ino_t soinfo::get_st_ino() const {
-  if (has_min_version(0)) {
-    return st_ino_;
-  }
-
-  return 0;
-}
-
-off64_t soinfo::get_file_offset() const {
-  if (has_min_version(1)) {
-    return file_offset_;
-  }
-
-  return 0;
-}
-
-uint32_t soinfo::get_rtld_flags() const {
-  if (has_min_version(1)) {
-    return rtld_flags_;
-  }
-
-  return 0;
-}
-
-uint32_t soinfo::get_dt_flags_1() const {
-  if (has_min_version(1)) {
-    return dt_flags_1_;
-  }
-
-  return 0;
-}
-
-void soinfo::set_dt_flags_1(uint32_t dt_flags_1) {
-  if (has_min_version(1)) {
-    if ((dt_flags_1 & DF_1_GLOBAL) != 0) {
-      rtld_flags_ |= RTLD_GLOBAL;
-    }
-
-    if ((dt_flags_1 & DF_1_NODELETE) != 0) {
-      rtld_flags_ |= RTLD_NODELETE;
-    }
-
-    dt_flags_1_ = dt_flags_1;
-  }
-}
-
-void soinfo::set_nodelete() {
-  rtld_flags_ |= RTLD_NODELETE;
-}
-
-const char* soinfo::get_realpath() const {
-#if defined(__work_around_b_24465209__)
-  if (has_min_version(2)) {
-    return realpath_.c_str();
-  } else {
-    return old_name_;
-  }
-#else
-  return realpath_.c_str();
-#endif
-}
-
-void soinfo::set_soname(const char* soname) {
-#if defined(__work_around_b_24465209__)
-  if (has_min_version(2)) {
-    soname_ = soname;
-  }
-  strlcpy(old_name_, soname_, sizeof(old_name_));
-#else
-  soname_ = soname;
-#endif
-}
-
-const char* soinfo::get_soname() const {
-#if defined(__work_around_b_24465209__)
-  if (has_min_version(2)) {
-    return soname_;
-  } else {
-    return old_name_;
-  }
-#else
-  return soname_;
-#endif
-}
-
-// This is a return on get_children()/get_parents() if
-// 'this->flags' does not have FLAG_NEW_SOINFO set.
-static soinfo::soinfo_list_t g_empty_list;
-
-soinfo::soinfo_list_t& soinfo::get_children() {
-  if (has_min_version(0)) {
-    return children_;
-  }
-
-  return g_empty_list;
-}
-
-const soinfo::soinfo_list_t& soinfo::get_children() const {
-  if (has_min_version(0)) {
-    return children_;
-  }
-
-  return g_empty_list;
-}
-
-soinfo::soinfo_list_t& soinfo::get_parents() {
-  if (has_min_version(0)) {
-    return parents_;
-  }
-
-  return g_empty_list;
-}
-
-static std::vector<std::string> g_empty_runpath;
-
-const std::vector<std::string>& soinfo::get_dt_runpath() const {
-  if (has_min_version(3)) {
-    return dt_runpath_;
-  }
-
-  return g_empty_runpath;
-}
-
-android_namespace_t* soinfo::get_primary_namespace() {
-  if (has_min_version(3)) {
-    return primary_namespace_;
-  }
-
-  return &g_default_namespace;
-}
-
-void soinfo::add_secondary_namespace(android_namespace_t* secondary_ns) {
-  CHECK(has_min_version(3));
-  secondary_namespaces_.push_back(secondary_ns);
-}
-
-ElfW(Addr) soinfo::resolve_symbol_address(const ElfW(Sym)* s) const {
-  if (ELF_ST_TYPE(s->st_info) == STT_GNU_IFUNC) {
-    return call_ifunc_resolver(s->st_value + load_bias);
-  }
-
-  return static_cast<ElfW(Addr)>(s->st_value + load_bias);
-}
-
-const char* soinfo::get_string(ElfW(Word) index) const {
-  if (has_min_version(1) && (index >= strtab_size_)) {
-    __libc_fatal("%s: strtab out of bounds error; STRSZ=%zd, name=%d",
-        get_realpath(), strtab_size_, index);
-  }
-
-  return strtab_ + index;
-}
-
-bool soinfo::is_gnu_hash() const {
-  return (flags_ & FLAG_GNU_HASH) != 0;
-}
-
-bool soinfo::can_unload() const {
-  return !is_linked() || ((get_rtld_flags() & (RTLD_NODELETE | RTLD_GLOBAL)) == 0);
-}
-
-bool soinfo::is_linked() const {
-  return (flags_ & FLAG_LINKED) != 0;
-}
-
-bool soinfo::is_main_executable() const {
-  return (flags_ & FLAG_EXE) != 0;
-}
-
-bool soinfo::is_linker() const {
-  return (flags_ & FLAG_LINKER) != 0;
-}
-
-void soinfo::set_linked() {
-  flags_ |= FLAG_LINKED;
-}
-
-void soinfo::set_linker_flag() {
-  flags_ |= FLAG_LINKER;
-}
-
-void soinfo::set_main_executable() {
-  flags_ |= FLAG_EXE;
-}
-
-void soinfo::increment_ref_count() {
-  local_group_root_->ref_count_++;
-}
-
-size_t soinfo::decrement_ref_count() {
-  return --local_group_root_->ref_count_;
-}
-
-soinfo* soinfo::get_local_group_root() const {
-  return local_group_root_;
-}
-
-
-void soinfo::set_mapped_by_caller(bool mapped_by_caller) {
-  if (mapped_by_caller) {
-    flags_ |= FLAG_MAPPED_BY_CALLER;
-  } else {
-    flags_ &= ~FLAG_MAPPED_BY_CALLER;
-  }
-}
-
-bool soinfo::is_mapped_by_caller() const {
-  return (flags_ & FLAG_MAPPED_BY_CALLER) != 0;
-}
-
-// This function returns api-level at the time of
-// dlopen/load. Note that libraries opened by system
-// will always have 'current' api level.
-uint32_t soinfo::get_target_sdk_version() const {
-  if (!has_min_version(2)) {
-    return __ANDROID_API__;
-  }
-
-  return local_group_root_->target_sdk_version_;
-}
-
-uintptr_t soinfo::get_handle() const {
-  CHECK(has_min_version(3));
-  CHECK(handle_ != 0);
-  return handle_;
-}
-
-void* soinfo::to_handle() {
-  if (get_application_target_sdk_version() <= 23 || !has_min_version(3)) {
-    return this;
-  }
-
-  return reinterpret_cast<void*>(get_handle());
-}
-
-void soinfo::generate_handle() {
-  CHECK(has_min_version(3));
-  CHECK(handle_ == 0); // Make sure this is the first call
-
-  // Make sure the handle is unique and does not collide
-  // with special values which are RTLD_DEFAULT and RTLD_NEXT.
-  do {
-    arc4random_buf(&handle_, sizeof(handle_));
-    // the least significant bit for the handle is always 1
-    // making it easy to test the type of handle passed to
-    // dl* functions.
-    handle_ = handle_ | 1;
-  } while (handle_ == reinterpret_cast<uintptr_t>(RTLD_DEFAULT) ||
-           handle_ == reinterpret_cast<uintptr_t>(RTLD_NEXT) ||
-           g_soinfo_handles_map.find(handle_) != g_soinfo_handles_map.end());
-
-  g_soinfo_handles_map[handle_] = this;
-}
+// An empty list of soinfos
+static soinfo_list_t g_empty_list;
 
 bool soinfo::prelink_image() {
   /* Extract dynamic section */
@@ -3728,17 +2842,17 @@
 
 #endif
       case DT_INIT:
-        init_func_ = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr);
+        init_func_ = reinterpret_cast<linker_ctor_function_t>(load_bias + d->d_un.d_ptr);
         DEBUG("%s constructors (DT_INIT) found at %p", get_realpath(), init_func_);
         break;
 
       case DT_FINI:
-        fini_func_ = reinterpret_cast<linker_function_t>(load_bias + d->d_un.d_ptr);
+        fini_func_ = reinterpret_cast<linker_dtor_function_t>(load_bias + d->d_un.d_ptr);
         DEBUG("%s destructors (DT_FINI) found at %p", get_realpath(), fini_func_);
         break;
 
       case DT_INIT_ARRAY:
-        init_array_ = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr);
+        init_array_ = reinterpret_cast<linker_ctor_function_t*>(load_bias + d->d_un.d_ptr);
         DEBUG("%s constructors (DT_INIT_ARRAY) found at %p", get_realpath(), init_array_);
         break;
 
@@ -3747,7 +2861,7 @@
         break;
 
       case DT_FINI_ARRAY:
-        fini_array_ = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr);
+        fini_array_ = reinterpret_cast<linker_dtor_function_t*>(load_bias + d->d_un.d_ptr);
         DEBUG("%s destructors (DT_FINI_ARRAY) found at %p", get_realpath(), fini_array_);
         break;
 
@@ -3756,7 +2870,7 @@
         break;
 
       case DT_PREINIT_ARRAY:
-        preinit_array_ = reinterpret_cast<linker_function_t*>(load_bias + d->d_un.d_ptr);
+        preinit_array_ = reinterpret_cast<linker_ctor_function_t*>(load_bias + d->d_un.d_ptr);
         DEBUG("%s constructors (DT_PREINIT_ARRAY) found at %p", get_realpath(), preinit_array_);
         break;
 
@@ -3766,7 +2880,7 @@
 
       case DT_TEXTREL:
 #if defined(__LP64__)
-        DL_ERR("text relocations (DT_TEXTREL) found in 64-bit ELF file \"%s\"", get_realpath());
+        DL_ERR("\"%s\" has text relocations", get_realpath());
         return false;
 #else
         has_text_relocations = true;
@@ -3784,7 +2898,7 @@
       case DT_FLAGS:
         if (d->d_un.d_val & DF_TEXTREL) {
 #if defined(__LP64__)
-          DL_ERR("text relocations (DF_TEXTREL) found in 64-bit ELF file \"%s\"", get_realpath());
+          DL_ERR("\"%s\" has text relocations", get_realpath());
           return false;
 #else
           has_text_relocations = true;
@@ -3799,7 +2913,7 @@
         set_dt_flags_1(d->d_un.d_val);
 
         if ((d->d_un.d_val & ~SUPPORTED_DT_FLAGS_1) != 0) {
-          DL_WARN("%s: unsupported flags DT_FLAGS_1=%p", get_realpath(), reinterpret_cast<void*>(d->d_un.d_val));
+          DL_WARN("\"%s\" has unsupported flags DT_FLAGS_1=%p", get_realpath(), reinterpret_cast<void*>(d->d_un.d_val));
         }
         break;
 #if defined(__mips__)
@@ -3810,8 +2924,8 @@
           *dp = &_r_debug;
         }
         break;
-      case DT_MIPS_RLD_MAP2:
-        // Set the DT_MIPS_RLD_MAP2 entry to the address of _r_debug for GDB.
+      case DT_MIPS_RLD_MAP_REL:
+        // Set the DT_MIPS_RLD_MAP_REL entry to the address of _r_debug for GDB.
         {
           r_debug** dp = reinterpret_cast<r_debug**>(
               reinterpret_cast<ElfW(Addr)>(d) + d->d_un.d_val);
@@ -3866,7 +2980,7 @@
 
       default:
         if (!relocating_linker) {
-          DL_WARN("%s: unused DT entry: type %p arg %p", get_realpath(),
+          DL_WARN("\"%s\" unused DT entry: type %p arg %p", get_realpath(),
               reinterpret_cast<void*>(d->d_tag), reinterpret_cast<void*>(d->d_un.d_val));
         }
         break;
@@ -3919,7 +3033,9 @@
   // This workaround should keep them working. (applies only
   // for apps targeting sdk version <=22). Make an exception for
   // the main executable and linker; they do not need to have dt_soname
-  if (soname_ == nullptr && this != somain && (flags_ & FLAG_LINKER) == 0 &&
+  if (soname_ == nullptr &&
+      this != solist_get_somain() &&
+      (flags_ & FLAG_LINKER) == 0 &&
       get_application_target_sdk_version() <= 22) {
     soname_ = basename(realpath_.c_str());
     DL_WARN("%s: is missing DT_SONAME will use basename as a replacement: \"%s\"",
@@ -3951,13 +3067,12 @@
   if (has_text_relocations) {
     // Fail if app is targeting sdk version > 22
     if (get_application_target_sdk_version() > 22) {
-      PRINT("%s: has text relocations", get_realpath());
-      DL_ERR("%s: has text relocations", get_realpath());
+      DL_ERR_AND_LOG("\"%s\" has text relocations", get_realpath());
       return false;
     }
     // Make segments writable to allow text relocations to work properly. We will later call
     // phdr_table_protect_segments() after all of them are applied.
-    DL_WARN("%s has text relocations. This is wasting memory and prevents "
+    DL_WARN("\"%s\" has text relocations. This is wasting memory and prevents "
             "security hardening. Please fix.", get_realpath());
     add_dlwarning(get_realpath(), "text relocations");
     if (phdr_table_unprotect_segments(phdr, phnum, load_bias) < 0) {
@@ -4083,66 +3198,12 @@
   return true;
 }
 
-/*
- * This function add vdso to internal dso list.
- * It helps to stack unwinding through signal handlers.
- * Also, it makes bionic more like glibc.
- */
-static void add_vdso(KernelArgumentBlock& args __unused) {
-#if defined(AT_SYSINFO_EHDR)
-  ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(args.getauxval(AT_SYSINFO_EHDR));
-  if (ehdr_vdso == nullptr) {
-    return;
-  }
-
-  soinfo* si = soinfo_alloc(&g_default_namespace, "[vdso]", nullptr, 0, 0);
-
-  si->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
-  si->phnum = ehdr_vdso->e_phnum;
-  si->base = reinterpret_cast<ElfW(Addr)>(ehdr_vdso);
-  si->size = phdr_table_get_load_size(si->phdr, si->phnum);
-  si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
-
-  si->prelink_image();
-  si->link_image(g_empty_list, soinfo::soinfo_list_t::make_list(si), nullptr);
-#endif
-}
-
-/* gdb expects the linker to be in the debug shared object list.
- * Without this, gdb has trouble locating the linker's ".text"
- * and ".plt" sections. Gdb could also potentially use this to
- * relocate the offset of our exported 'rtld_db_dlactivity' symbol.
- * Note that the linker shouldn't be on the soinfo list.
- */
-static void init_linker_info_for_gdb(ElfW(Addr) linker_base) {
-  static link_map linker_link_map_for_gdb;
-#if defined(__LP64__)
-  static char kLinkerPath[] = "/system/bin/linker64";
-#else
-  static char kLinkerPath[] = "/system/bin/linker";
-#endif
-
-  linker_link_map_for_gdb.l_addr = linker_base;
-  linker_link_map_for_gdb.l_name = kLinkerPath;
-
-  /*
-   * Set the dynamic field in the link map otherwise gdb will complain with
-   * the following:
-   *   warning: .dynamic section for "/system/bin/linker" is not at the
-   *   expected address (wrong library or version mismatch?)
-   */
-  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_base);
-  ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(linker_base + elf_hdr->e_phoff);
-  phdr_table_get_dynamic_section(phdr, elf_hdr->e_phnum, linker_base,
-                                 &linker_link_map_for_gdb.l_ld, nullptr);
-
-  insert_link_map_into_debug_map(&linker_link_map_for_gdb);
-}
-
-static void init_default_namespace() {
+void init_default_namespace() {
   g_default_namespace.set_name("(default)");
   g_default_namespace.set_isolated(false);
 
+  soinfo* somain = solist_get_somain();
+
   const char *interp = phdr_table_get_interpreter_name(somain->phdr, somain->phnum,
                                                        somain->load_bias);
   const char* bname = basename(interp);
@@ -4166,345 +3227,3 @@
   g_default_namespace.set_default_library_paths(std::move(ld_default_paths));
 };
 
-extern "C" int __system_properties_init(void);
-
-static const char* get_executable_path() {
-  static std::string executable_path;
-  if (executable_path.empty()) {
-    char path[PATH_MAX];
-    ssize_t path_len = readlink("/proc/self/exe", path, sizeof(path));
-    if (path_len == -1 || path_len >= static_cast<ssize_t>(sizeof(path))) {
-      __libc_fatal("readlink('/proc/self/exe') failed: %s", strerror(errno));
-    }
-    executable_path = std::string(path, path_len);
-  }
-
-  return executable_path.c_str();
-}
-
-/*
- * This code is called after the linker has linked itself and
- * fixed it's own GOT. It is safe to make references to externs
- * and other non-local data at this point.
- */
-static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(Addr) linker_base) {
-#if TIMING
-  struct timeval t0, t1;
-  gettimeofday(&t0, 0);
-#endif
-
-  // Sanitize the environment.
-  __libc_init_AT_SECURE(args);
-
-  // Initialize system properties
-  __system_properties_init(); // may use 'environ'
-
-  debuggerd_init();
-
-  // Get a few environment variables.
-  const char* LD_DEBUG = getenv("LD_DEBUG");
-  if (LD_DEBUG != nullptr) {
-    g_ld_debug_verbosity = atoi(LD_DEBUG);
-  }
-
-#if defined(__LP64__)
-  INFO("[ Android dynamic linker (64-bit) ]");
-#else
-  INFO("[ Android dynamic linker (32-bit) ]");
-#endif
-
-  // These should have been sanitized by __libc_init_AT_SECURE, but the test
-  // doesn't cost us anything.
-  const char* ldpath_env = nullptr;
-  const char* ldpreload_env = nullptr;
-  if (!getauxval(AT_SECURE)) {
-    ldpath_env = getenv("LD_LIBRARY_PATH");
-    if (ldpath_env != nullptr) {
-      INFO("[ LD_LIBRARY_PATH set to \"%s\" ]", ldpath_env);
-    }
-    ldpreload_env = getenv("LD_PRELOAD");
-    if (ldpreload_env != nullptr) {
-      INFO("[ LD_PRELOAD set to \"%s\" ]", ldpreload_env);
-    }
-  }
-
-  struct stat file_stat;
-  // Stat "/proc/self/exe" instead of executable_path because
-  // the executable could be unlinked by this point and it should
-  // not cause a crash (see http://b/31084669)
-  if (TEMP_FAILURE_RETRY(stat("/proc/self/exe", &file_stat)) != 0) {
-    __libc_fatal("unable to stat \"/proc/self/exe\": %s", strerror(errno));
-  }
-
-  const char* executable_path = get_executable_path();
-  soinfo* si = soinfo_alloc(&g_default_namespace, executable_path, &file_stat, 0, RTLD_GLOBAL);
-  if (si == nullptr) {
-    __libc_fatal("Couldn't allocate soinfo: out of memory?");
-  }
-
-  /* bootstrap the link map, the main exe always needs to be first */
-  si->set_main_executable();
-  link_map* map = &(si->link_map_head);
-
-  // Register the main executable and the linker upfront to have
-  // gdb aware of them before loading the rest of the dependency
-  // tree.
-  map->l_addr = 0;
-  map->l_name = const_cast<char*>(executable_path);
-  insert_link_map_into_debug_map(map);
-  init_linker_info_for_gdb(linker_base);
-
-  // Extract information passed from the kernel.
-  si->phdr = reinterpret_cast<ElfW(Phdr)*>(args.getauxval(AT_PHDR));
-  si->phnum = args.getauxval(AT_PHNUM);
-  si->entry = args.getauxval(AT_ENTRY);
-
-  /* Compute the value of si->base. We can't rely on the fact that
-   * the first entry is the PHDR because this will not be true
-   * for certain executables (e.g. some in the NDK unit test suite)
-   */
-  si->base = 0;
-  si->size = phdr_table_get_load_size(si->phdr, si->phnum);
-  si->load_bias = 0;
-  for (size_t i = 0; i < si->phnum; ++i) {
-    if (si->phdr[i].p_type == PT_PHDR) {
-      si->load_bias = reinterpret_cast<ElfW(Addr)>(si->phdr) - si->phdr[i].p_vaddr;
-      si->base = reinterpret_cast<ElfW(Addr)>(si->phdr) - si->phdr[i].p_offset;
-      break;
-    }
-  }
-  si->dynamic = nullptr;
-
-  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
-  if (elf_hdr->e_type != ET_DYN) {
-    __libc_fatal("\"%s\": error: only position independent executables (PIE) are supported.",
-                 args.argv[0]);
-  }
-
-  // Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
-  parse_LD_LIBRARY_PATH(ldpath_env);
-  parse_LD_PRELOAD(ldpreload_env);
-
-  somain = si;
-
-  init_default_namespace();
-
-  if (!si->prelink_image()) {
-    __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", args.argv[0], linker_get_error_buffer());
-  }
-
-  // add somain to global group
-  si->set_dt_flags_1(si->get_dt_flags_1() | DF_1_GLOBAL);
-
-  // Load ld_preloads and dependencies.
-  StringLinkedList needed_library_name_list;
-  size_t needed_libraries_count = 0;
-  size_t ld_preloads_count = 0;
-
-  for (const auto& ld_preload_name : g_ld_preload_names) {
-    needed_library_name_list.push_back(ld_preload_name.c_str());
-    ++needed_libraries_count;
-    ++ld_preloads_count;
-  }
-
-  for_each_dt_needed(si, [&](const char* name) {
-    needed_library_name_list.push_back(name);
-    ++needed_libraries_count;
-  });
-
-  const char* needed_library_names[needed_libraries_count];
-
-  memset(needed_library_names, 0, sizeof(needed_library_names));
-  needed_library_name_list.copy_to_array(needed_library_names, needed_libraries_count);
-
-  if (needed_libraries_count > 0 &&
-      !find_libraries(&g_default_namespace, si, needed_library_names, needed_libraries_count,
-                      nullptr, &g_ld_preloads, ld_preloads_count, RTLD_GLOBAL, nullptr,
-                      /* add_as_children */ true)) {
-    __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", args.argv[0], linker_get_error_buffer());
-  } else if (needed_libraries_count == 0) {
-    if (!si->link_image(g_empty_list, soinfo::soinfo_list_t::make_list(si), nullptr)) {
-      __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", args.argv[0], linker_get_error_buffer());
-    }
-    si->increment_ref_count();
-  }
-
-  add_vdso(args);
-
-  {
-    ProtectedDataGuard guard;
-
-    si->call_pre_init_constructors();
-
-    /* After the prelink_image, the si->load_bias is initialized.
-     * For so lib, the map->l_addr will be updated in notify_gdb_of_load.
-     * We need to update this value for so exe here. So Unwind_Backtrace
-     * for some arch like x86 could work correctly within so exe.
-     */
-    map->l_addr = si->load_bias;
-    si->call_constructors();
-  }
-
-#if TIMING
-  gettimeofday(&t1, nullptr);
-  PRINT("LINKER TIME: %s: %d microseconds", args.argv[0], (int) (
-           (((long long)t1.tv_sec * 1000000LL) + (long long)t1.tv_usec) -
-           (((long long)t0.tv_sec * 1000000LL) + (long long)t0.tv_usec)));
-#endif
-#if STATS
-  PRINT("RELO STATS: %s: %d abs, %d rel, %d copy, %d symbol", args.argv[0],
-         linker_stats.count[kRelocAbsolute],
-         linker_stats.count[kRelocRelative],
-         linker_stats.count[kRelocCopy],
-         linker_stats.count[kRelocSymbol]);
-#endif
-#if COUNT_PAGES
-  {
-    unsigned n;
-    unsigned i;
-    unsigned count = 0;
-    for (n = 0; n < 4096; n++) {
-      if (bitmask[n]) {
-        unsigned x = bitmask[n];
-#if defined(__LP64__)
-        for (i = 0; i < 32; i++) {
-#else
-        for (i = 0; i < 8; i++) {
-#endif
-          if (x & 1) {
-            count++;
-          }
-          x >>= 1;
-        }
-      }
-    }
-    PRINT("PAGES MODIFIED: %s: %d (%dKB)", args.argv[0], count, count * 4);
-  }
-#endif
-
-#if TIMING || STATS || COUNT_PAGES
-  fflush(stdout);
-#endif
-
-  TRACE("[ Ready to execute \"%s\" @ %p ]", si->get_realpath(), reinterpret_cast<void*>(si->entry));
-  return si->entry;
-}
-
-/* Compute the load-bias of an existing executable. This shall only
- * be used to compute the load bias of an executable or shared library
- * that was loaded by the kernel itself.
- *
- * Input:
- *    elf    -> address of ELF header, assumed to be at the start of the file.
- * Return:
- *    load bias, i.e. add the value of any p_vaddr in the file to get
- *    the corresponding address in memory.
- */
-static ElfW(Addr) get_elf_exec_load_bias(const ElfW(Ehdr)* elf) {
-  ElfW(Addr) offset = elf->e_phoff;
-  const ElfW(Phdr)* phdr_table =
-      reinterpret_cast<const ElfW(Phdr)*>(reinterpret_cast<uintptr_t>(elf) + offset);
-  const ElfW(Phdr)* phdr_end = phdr_table + elf->e_phnum;
-
-  for (const ElfW(Phdr)* phdr = phdr_table; phdr < phdr_end; phdr++) {
-    if (phdr->p_type == PT_LOAD) {
-      return reinterpret_cast<ElfW(Addr)>(elf) + phdr->p_offset - phdr->p_vaddr;
-    }
-  }
-  return 0;
-}
-
-static void __linker_cannot_link(KernelArgumentBlock& args) {
-  __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", args.argv[0], linker_get_error_buffer());
-}
-
-/*
- * This is the entry point for the linker, called from begin.S. This
- * method is responsible for fixing the linker's own relocations, and
- * then calling __linker_init_post_relocation().
- *
- * Because this method is called before the linker has fixed it's own
- * relocations, any attempt to reference an extern variable, extern
- * function, or other GOT reference will generate a segfault.
- */
-extern "C" ElfW(Addr) __linker_init(void* raw_args) {
-  KernelArgumentBlock args(raw_args);
-
-  ElfW(Addr) linker_addr = args.getauxval(AT_BASE);
-  ElfW(Addr) entry_point = args.getauxval(AT_ENTRY);
-  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_addr);
-  ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(linker_addr + elf_hdr->e_phoff);
-
-  soinfo linker_so(nullptr, nullptr, nullptr, 0, 0);
-
-  // If the linker is not acting as PT_INTERP entry_point is equal to
-  // _start. Which means that the linker is running as an executable and
-  // already linked by PT_INTERP.
-  //
-  // This happens when user tries to run 'adb shell /system/bin/linker'
-  // see also https://code.google.com/p/android/issues/detail?id=63174
-  if (reinterpret_cast<ElfW(Addr)>(&_start) == entry_point) {
-    __libc_format_fd(STDOUT_FILENO,
-                     "This is %s, the helper program for shared library executables.\n",
-                     args.argv[0]);
-    exit(0);
-  }
-
-  linker_so.base = linker_addr;
-  linker_so.size = phdr_table_get_load_size(phdr, elf_hdr->e_phnum);
-  linker_so.load_bias = get_elf_exec_load_bias(elf_hdr);
-  linker_so.dynamic = nullptr;
-  linker_so.phdr = phdr;
-  linker_so.phnum = elf_hdr->e_phnum;
-  linker_so.set_linker_flag();
-
-  // Prelink the linker so we can access linker globals.
-  if (!linker_so.prelink_image()) __linker_cannot_link(args);
-
-  // This might not be obvious... The reasons why we pass g_empty_list
-  // in place of local_group here are (1) we do not really need it, because
-  // linker is built with DT_SYMBOLIC and therefore relocates its symbols against
-  // itself without having to look into local_group and (2) allocators
-  // are not yet initialized, and therefore we cannot use linked_list.push_*
-  // functions at this point.
-  if (!linker_so.link_image(g_empty_list, g_empty_list, nullptr)) __linker_cannot_link(args);
-
-#if defined(__i386__)
-  // On x86, we can't make system calls before this point.
-  // We can't move this up because this needs to assign to a global.
-  // Note that until we call __libc_init_main_thread below we have
-  // no TLS, so you shouldn't make a system call that can fail, because
-  // it will SEGV when it tries to set errno.
-  __libc_init_sysinfo(args);
-#endif
-
-  // Initialize the main thread (including TLS, so system calls really work).
-  __libc_init_main_thread(args);
-
-  // We didn't protect the linker's RELRO pages in link_image because we
-  // couldn't make system calls on x86 at that point, but we can now...
-  if (!linker_so.protect_relro()) __linker_cannot_link(args);
-
-  // Initialize the linker's static libc's globals
-  __libc_init_globals(args);
-
-  // Initialize the linker's own global variables
-  linker_so.call_constructors();
-
-  // Initialize static variables. Note that in order to
-  // get correct libdl_info we need to call constructors
-  // before get_libdl_info().
-  solist = get_libdl_info();
-  sonext = get_libdl_info();
-  g_default_namespace.add_soinfo(get_libdl_info());
-
-  // We have successfully fixed our own relocations. It's safe to run
-  // the main part of the linker now.
-  args.abort_message_ptr = &g_abort_message;
-  ElfW(Addr) start_address = __linker_init_post_relocation(args, linker_addr);
-
-  INFO("[ Jumping to _start (%p)... ]", reinterpret_cast<void*>(start_address));
-
-  // Return the address that the calling assembly stub should jump to.
-  return start_address;
-}
diff --git a/linker/linker.h b/linker/linker.h
index 49eee78..4787471 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -40,31 +40,13 @@
 #include "private/bionic_page.h"
 #include "private/libc_logging.h"
 #include "linked_list.h"
+#include "linker_common_types.h"
+#include "linker_logger.h"
+#include "linker_soinfo.h"
 
 #include <string>
 #include <vector>
 
-#define DL_ERR(fmt, x...) \
-    do { \
-      __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
-      /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
-      DEBUG("%s\n", linker_get_error_buffer()); \
-    } while (false)
-
-#define DL_WARN(fmt, x...) \
-    do { \
-      __libc_format_log(ANDROID_LOG_WARN, "linker", fmt, ##x); \
-      __libc_format_fd(2, "WARNING: linker: "); \
-      __libc_format_fd(2, fmt, ##x); \
-      __libc_format_fd(2, "\n"); \
-    } while (false)
-
-#define DL_ERR_AND_LOG(fmt, x...) \
-  do { \
-    DL_ERR(fmt, x); \
-    PRINT(fmt, x); \
-  } while (false)
-
 #if defined(__LP64__)
 #define ELFW(what) ELF64_ ## what
 #else
@@ -85,81 +67,7 @@
 #define ELF64_R_TYPE(info)  (((info) >> 56) & 0xff)
 #endif
 
-#define FLAG_LINKED           0x00000001
-#define FLAG_EXE              0x00000004 // The main executable
-#define FLAG_LINKER           0x00000010 // The linker itself
-#define FLAG_GNU_HASH         0x00000040 // uses gnu hash
-#define FLAG_MAPPED_BY_CALLER 0x00000080 // the map is reserved by the caller
-                                         // and should not be unmapped
-#define FLAG_NEW_SOINFO       0x40000000 // new soinfo format
-
-#define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE)
-
-#define SOINFO_VERSION 3
-
-#if defined(__work_around_b_24465209__)
-#define SOINFO_NAME_LEN 128
-#endif
-
-typedef void (*linker_function_t)();
-
-// Android uses RELA for aarch64 and x86_64. mips64 still uses REL.
-#if defined(__aarch64__) || defined(__x86_64__)
-#define USE_RELA 1
-#endif
-
-struct soinfo;
-
-class SoinfoListAllocator {
- public:
-  static LinkedListEntry<soinfo>* alloc();
-  static void free(LinkedListEntry<soinfo>* entry);
-
- private:
-  // unconstructable
-  DISALLOW_IMPLICIT_CONSTRUCTORS(SoinfoListAllocator);
-};
-
-class NamespaceListAllocator {
- public:
-  static LinkedListEntry<android_namespace_t>* alloc();
-  static void free(LinkedListEntry<android_namespace_t>* entry);
-
- private:
-  // unconstructable
-  DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceListAllocator);
-};
-
-class SymbolName {
- public:
-  explicit SymbolName(const char* name)
-      : name_(name), has_elf_hash_(false), has_gnu_hash_(false),
-        elf_hash_(0), gnu_hash_(0) { }
-
-  const char* get_name() {
-    return name_;
-  }
-
-  uint32_t elf_hash();
-  uint32_t gnu_hash();
-
- private:
-  const char* name_;
-  bool has_elf_hash_;
-  bool has_gnu_hash_;
-  uint32_t elf_hash_;
-  uint32_t gnu_hash_;
-
-  DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolName);
-};
-
-struct version_info {
-  constexpr version_info() : elf_hash(0), name(nullptr), target_si(nullptr) {}
-
-  uint32_t elf_hash;
-  const char* name;
-  const soinfo* target_si;
-};
+#define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE | DF_1_PIE)
 
 // Class used construct version dependency graph.
 class VersionTracker {
@@ -179,267 +87,9 @@
   DISALLOW_COPY_AND_ASSIGN(VersionTracker);
 };
 
-struct soinfo {
- public:
-  typedef LinkedList<soinfo, SoinfoListAllocator> soinfo_list_t;
-  typedef LinkedList<android_namespace_t, NamespaceListAllocator> android_namespace_list_t;
-#if defined(__work_around_b_24465209__)
- private:
-  char old_name_[SOINFO_NAME_LEN];
-#endif
- public:
-  const ElfW(Phdr)* phdr;
-  size_t phnum;
-  ElfW(Addr) entry;
-  ElfW(Addr) base;
-  size_t size;
-
-#if defined(__work_around_b_24465209__)
-  uint32_t unused1;  // DO NOT USE, maintained for compatibility.
-#endif
-
-  ElfW(Dyn)* dynamic;
-
-#if defined(__work_around_b_24465209__)
-  uint32_t unused2; // DO NOT USE, maintained for compatibility
-  uint32_t unused3; // DO NOT USE, maintained for compatibility
-#endif
-
-  soinfo* next;
- private:
-  uint32_t flags_;
-
-  const char* strtab_;
-  ElfW(Sym)* symtab_;
-
-  size_t nbucket_;
-  size_t nchain_;
-  uint32_t* bucket_;
-  uint32_t* chain_;
-
-#if defined(__mips__) || !defined(__LP64__)
-  // This is only used by mips and mips64, but needs to be here for
-  // all 32-bit architectures to preserve binary compatibility.
-  ElfW(Addr)** plt_got_;
-#endif
-
-#if defined(USE_RELA)
-  ElfW(Rela)* plt_rela_;
-  size_t plt_rela_count_;
-
-  ElfW(Rela)* rela_;
-  size_t rela_count_;
-#else
-  ElfW(Rel)* plt_rel_;
-  size_t plt_rel_count_;
-
-  ElfW(Rel)* rel_;
-  size_t rel_count_;
-#endif
-
-  linker_function_t* preinit_array_;
-  size_t preinit_array_count_;
-
-  linker_function_t* init_array_;
-  size_t init_array_count_;
-  linker_function_t* fini_array_;
-  size_t fini_array_count_;
-
-  linker_function_t init_func_;
-  linker_function_t fini_func_;
-
-#if defined(__arm__)
- public:
-  // ARM EABI section used for stack unwinding.
-  uint32_t* ARM_exidx;
-  size_t ARM_exidx_count;
- private:
-#elif defined(__mips__)
-  uint32_t mips_symtabno_;
-  uint32_t mips_local_gotno_;
-  uint32_t mips_gotsym_;
-  bool mips_relocate_got(const VersionTracker& version_tracker,
-                         const soinfo_list_t& global_group,
-                         const soinfo_list_t& local_group);
-#if !defined(__LP64__)
-  bool mips_check_and_adjust_fp_modes();
-#endif
-#endif
-  size_t ref_count_;
- public:
-  link_map link_map_head;
-
-  bool constructors_called;
-
-  // When you read a virtual address from the ELF file, add this
-  // value to get the corresponding address in the process' address space.
-  ElfW(Addr) load_bias;
-
-#if !defined(__LP64__)
-  bool has_text_relocations;
-#endif
-  bool has_DT_SYMBOLIC;
-
- public:
-  soinfo(android_namespace_t* ns, const char* name, const struct stat* file_stat,
-         off64_t file_offset, int rtld_flags);
-  ~soinfo();
-
-  void call_constructors();
-  void call_destructors();
-  void call_pre_init_constructors();
-  bool prelink_image();
-  bool link_image(const soinfo_list_t& global_group, const soinfo_list_t& local_group,
-                  const android_dlextinfo* extinfo);
-  bool protect_relro();
-
-  void add_child(soinfo* child);
-  void remove_all_links();
-
-  ino_t get_st_ino() const;
-  dev_t get_st_dev() const;
-  off64_t get_file_offset() const;
-
-  uint32_t get_rtld_flags() const;
-  uint32_t get_dt_flags_1() const;
-  void set_dt_flags_1(uint32_t dt_flags_1);
-
-  soinfo_list_t& get_children();
-  const soinfo_list_t& get_children() const;
-
-  soinfo_list_t& get_parents();
-
-  bool find_symbol_by_name(SymbolName& symbol_name,
-                           const version_info* vi,
-                           const ElfW(Sym)** symbol) const;
-
-  ElfW(Sym)* find_symbol_by_address(const void* addr);
-  ElfW(Addr) resolve_symbol_address(const ElfW(Sym)* s) const;
-
-  const char* get_string(ElfW(Word) index) const;
-  bool can_unload() const;
-  bool is_gnu_hash() const;
-
-  bool inline has_min_version(uint32_t min_version __unused) const {
-#if defined(__work_around_b_24465209__)
-    return (flags_ & FLAG_NEW_SOINFO) != 0 && version_ >= min_version;
-#else
-    return true;
-#endif
-  }
-
-  bool is_linked() const;
-  bool is_linker() const;
-  bool is_main_executable() const;
-
-  void set_linked();
-  void set_linker_flag();
-  void set_main_executable();
-  void set_nodelete();
-
-  void increment_ref_count();
-  size_t decrement_ref_count();
-
-  soinfo* get_local_group_root() const;
-
-  void set_soname(const char* soname);
-  const char* get_soname() const;
-  const char* get_realpath() const;
-  const ElfW(Versym)* get_versym(size_t n) const;
-  ElfW(Addr) get_verneed_ptr() const;
-  size_t get_verneed_cnt() const;
-  ElfW(Addr) get_verdef_ptr() const;
-  size_t get_verdef_cnt() const;
-
-  bool find_verdef_version_index(const version_info* vi, ElfW(Versym)* versym) const;
-
-  uint32_t get_target_sdk_version() const;
-
-  void set_dt_runpath(const char *);
-  const std::vector<std::string>& get_dt_runpath() const;
-  android_namespace_t* get_primary_namespace();
-  void add_secondary_namespace(android_namespace_t* secondary_ns);
-
-  void set_mapped_by_caller(bool reserved_map);
-  bool is_mapped_by_caller() const;
-
-  uintptr_t get_handle() const;
-  void generate_handle();
-  void* to_handle();
-
- private:
-  bool elf_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
-  ElfW(Sym)* elf_addr_lookup(const void* addr);
-  bool gnu_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
-  ElfW(Sym)* gnu_addr_lookup(const void* addr);
-
-  bool lookup_version_info(const VersionTracker& version_tracker, ElfW(Word) sym,
-                           const char* sym_name, const version_info** vi);
-
-  void call_array(const char* array_name, linker_function_t* functions, size_t count, bool reverse);
-  void call_function(const char* function_name, linker_function_t function);
-  template<typename ElfRelIteratorT>
-  bool relocate(const VersionTracker& version_tracker, ElfRelIteratorT&& rel_iterator,
-                const soinfo_list_t& global_group, const soinfo_list_t& local_group);
-
- private:
-  // This part of the structure is only available
-  // when FLAG_NEW_SOINFO is set in this->flags.
-  uint32_t version_;
-
-  // version >= 0
-  dev_t st_dev_;
-  ino_t st_ino_;
-
-  // dependency graph
-  soinfo_list_t children_;
-  soinfo_list_t parents_;
-
-  // version >= 1
-  off64_t file_offset_;
-  uint32_t rtld_flags_;
-  uint32_t dt_flags_1_;
-  size_t strtab_size_;
-
-  // version >= 2
-
-  size_t gnu_nbucket_;
-  uint32_t* gnu_bucket_;
-  uint32_t* gnu_chain_;
-  uint32_t gnu_maskwords_;
-  uint32_t gnu_shift2_;
-  ElfW(Addr)* gnu_bloom_filter_;
-
-  soinfo* local_group_root_;
-
-  uint8_t* android_relocs_;
-  size_t android_relocs_size_;
-
-  const char* soname_;
-  std::string realpath_;
-
-  const ElfW(Versym)* versym_;
-
-  ElfW(Addr) verdef_ptr_;
-  size_t verdef_cnt_;
-
-  ElfW(Addr) verneed_ptr_;
-  size_t verneed_cnt_;
-
-  uint32_t target_sdk_version_;
-
-  // version >= 3
-  std::vector<std::string> dt_runpath_;
-  android_namespace_t* primary_namespace_;
-  android_namespace_list_t secondary_namespaces_;
-  uintptr_t handle_;
-
-  friend soinfo* get_libdl_info();
-};
-
 bool soinfo_do_lookup(soinfo* si_from, const char* name, const version_info* vi,
-                      soinfo** si_found_in, const soinfo::soinfo_list_t& global_group,
-                      const soinfo::soinfo_list_t& local_group, const ElfW(Sym)** symbol);
+                      soinfo** si_found_in, const soinfo_list_t& global_group,
+                      const soinfo_list_t& local_group, const ElfW(Sym)** symbol);
 
 enum RelocationKind {
   kRelocAbsolute = 0,
@@ -465,12 +115,6 @@
 
 int do_dladdr(const void* addr, Dl_info* info);
 
-void debuggerd_init();
-extern "C" abort_msg_t* g_abort_message;
-
-char* linker_get_error_buffer();
-size_t linker_get_error_buffer_size();
-
 void set_application_target_sdk_version(uint32_t target);
 uint32_t get_application_target_sdk_version();
 
@@ -509,4 +153,7 @@
                                       const char* permitted_when_isolated_path,
                                       android_namespace_t* parent_namespace);
 
+constexpr unsigned kLibraryAlignmentBits = 18;
+constexpr size_t kLibraryAlignment = 1UL << kLibraryAlignmentBits;
+
 #endif
diff --git a/linker/linker_allocator.cpp b/linker/linker_allocator.cpp
index 57811d8..dc6dfc1 100644
--- a/linker/linker_allocator.cpp
+++ b/linker/linker_allocator.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "linker_allocator.h"
+#include "linker_debug.h"
 #include "linker.h"
 
 #include <algorithm>
@@ -69,10 +70,12 @@
   return result;
 }
 
-LinkerSmallObjectAllocator::LinkerSmallObjectAllocator()
-    : type_(0), block_size_(0), free_pages_cnt_(0), free_blocks_list_(nullptr) {}
+LinkerSmallObjectAllocator::LinkerSmallObjectAllocator(uint32_t type, size_t block_size)
+    : type_(type), block_size_(block_size), free_pages_cnt_(0), free_blocks_list_(nullptr) {}
 
 void* LinkerSmallObjectAllocator::alloc() {
+  CHECK(block_size_ != 0);
+
   if (free_blocks_list_ == nullptr) {
     alloc_page();
   }
@@ -156,11 +159,6 @@
   }
 }
 
-void LinkerSmallObjectAllocator::init(uint32_t type, size_t block_size) {
-  type_ = type;
-  block_size_ = block_size;
-}
-
 linker_vector_t::iterator LinkerSmallObjectAllocator::find_page_record(void* ptr) {
   void* addr = reinterpret_cast<void*>(PAGE_START(reinterpret_cast<uintptr_t>(ptr)));
   small_object_page_record boundary;
@@ -218,11 +216,20 @@
 }
 
 
-LinkerMemoryAllocator::LinkerMemoryAllocator() {
+void LinkerMemoryAllocator::initialize_allocators() {
+  if (allocators_ != nullptr) {
+    return;
+  }
+
+  LinkerSmallObjectAllocator* allocators =
+      reinterpret_cast<LinkerSmallObjectAllocator*>(allocators_buf_);
+
   for (size_t i = 0; i < kSmallObjectAllocatorsCount; ++i) {
     uint32_t type = i + kSmallObjectMinSizeLog2;
-    allocators_[i].init(type, 1 << type);
+    new (allocators + i) LinkerSmallObjectAllocator(type, 1 << type);
   }
+
+  allocators_ = allocators;
 }
 
 void* LinkerMemoryAllocator::alloc_mmap(size_t size) {
@@ -333,5 +340,6 @@
     __libc_fatal("invalid type: %u", type);
   }
 
+  initialize_allocators();
   return &allocators_[type - kSmallObjectMinSizeLog2];
 }
diff --git a/linker/linker_allocator.h b/linker/linker_allocator.h
index 22a337a..8f90dbf 100644
--- a/linker/linker_allocator.h
+++ b/linker/linker_allocator.h
@@ -100,8 +100,7 @@
 
 class LinkerSmallObjectAllocator {
  public:
-  LinkerSmallObjectAllocator();
-  void init(uint32_t type, size_t block_size);
+  LinkerSmallObjectAllocator(uint32_t type, size_t block_size);
   void* alloc();
   void free(void* ptr);
 
@@ -124,7 +123,7 @@
 
 class LinkerMemoryAllocator {
  public:
-  LinkerMemoryAllocator();
+  constexpr LinkerMemoryAllocator() : allocators_(nullptr), allocators_buf_() {}
   void* alloc(size_t size);
 
   // Note that this implementation of realloc never shrinks allocation
@@ -134,8 +133,10 @@
   void* alloc_mmap(size_t size);
   page_info* get_page_info(void* ptr);
   LinkerSmallObjectAllocator* get_small_object_allocator(uint32_t type);
+  void initialize_allocators();
 
-  LinkerSmallObjectAllocator allocators_[kSmallObjectAllocatorsCount];
+  LinkerSmallObjectAllocator* allocators_;
+  uint8_t allocators_buf_[sizeof(LinkerSmallObjectAllocator)*kSmallObjectAllocatorsCount];
 };
 
 
diff --git a/linker/linker_common_types.h b/linker/linker_common_types.h
new file mode 100644
index 0000000..6afd950
--- /dev/null
+++ b/linker/linker_common_types.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_COMMON_TYPES_H
+#define __LINKER_COMMON_TYPES_H
+
+#include <android/dlext.h>
+#include "linked_list.h"
+
+// TODO(dimitry): move this to linker_defines.h? Unless it is removed by
+// consequent refactoring steps.
+
+// Android uses RELA for aarch64 and x86_64. mips64 still uses REL.
+#if defined(__aarch64__) || defined(__x86_64__)
+#define USE_RELA 1
+#endif
+
+
+struct soinfo;
+
+class SoinfoListAllocator {
+ public:
+  static LinkedListEntry<soinfo>* alloc();
+  static void free(LinkedListEntry<soinfo>* entry);
+
+ private:
+  // unconstructable
+  DISALLOW_IMPLICIT_CONSTRUCTORS(SoinfoListAllocator);
+};
+
+class NamespaceListAllocator {
+ public:
+  static LinkedListEntry<android_namespace_t>* alloc();
+  static void free(LinkedListEntry<android_namespace_t>* entry);
+
+ private:
+  // unconstructable
+  DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceListAllocator);
+};
+
+typedef LinkedList<soinfo, SoinfoListAllocator> soinfo_list_t;
+typedef LinkedList<android_namespace_t, NamespaceListAllocator> android_namespace_list_t;
+
+#endif  /* __LINKER_COMMON_TYPES_H */
diff --git a/libstdc++/include/cstdint b/linker/linker_globals.cpp
similarity index 73%
copy from libstdc++/include/cstdint
copy to linker/linker_globals.cpp
index 3df56df..155ebf4 100644
--- a/libstdc++/include/cstdint
+++ b/linker/linker_globals.cpp
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,14 +26,25 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
 
-/*
- * Standard C++ Library wrapper around the C stdint.h header file.
- */
+#include "linker_globals.h"
+#include "linker_namespaces.h"
 
-#include <stdint.h>
+int g_argc = 0;
+char** g_argv = nullptr;
+char** g_envp = nullptr;
 
+android_namespace_t g_default_namespace;
 
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+std::unordered_map<uintptr_t, soinfo*> g_soinfo_handles_map;
+
+static char __linker_dl_err_buf[768];
+
+char* linker_get_error_buffer() {
+  return &__linker_dl_err_buf[0];
+}
+
+size_t linker_get_error_buffer_size() {
+  return sizeof(__linker_dl_err_buf);
+}
+
diff --git a/linker/linker_globals.h b/linker/linker_globals.h
new file mode 100644
index 0000000..b6f8a04
--- /dev/null
+++ b/linker/linker_globals.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_GLOBALS_H
+#define __LINKER_GLOBALS_H
+
+#include <link.h>
+#include <stddef.h>
+
+#include <unordered_map>
+
+#define DL_ERR(fmt, x...) \
+    do { \
+      __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
+      /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
+      LD_LOG(kLogErrors, "%s\n", linker_get_error_buffer()); \
+    } while (false)
+
+#define DL_WARN(fmt, x...) \
+    do { \
+      __libc_format_log(ANDROID_LOG_WARN, "linker", fmt, ##x); \
+      __libc_format_fd(2, "WARNING: linker: "); \
+      __libc_format_fd(2, fmt, ##x); \
+      __libc_format_fd(2, "\n"); \
+    } while (false)
+
+#define DL_ERR_AND_LOG(fmt, x...) \
+  do { \
+    DL_ERR(fmt, x); \
+    PRINT(fmt, x); \
+  } while (false)
+
+constexpr ElfW(Versym) kVersymNotNeeded = 0;
+constexpr ElfW(Versym) kVersymGlobal = 1;
+
+// These values are used to call constructors for .init_array && .preinit_array
+extern int g_argc;
+extern char** g_argv;
+extern char** g_envp;
+
+struct soinfo;
+struct android_namespace_t;
+
+extern android_namespace_t g_default_namespace;
+
+extern std::unordered_map<uintptr_t, soinfo*> g_soinfo_handles_map;
+
+// Error buffer "variable"
+char* linker_get_error_buffer();
+size_t linker_get_error_buffer_size();
+
+#endif  /* __LINKER_GLOBALS_H */
diff --git a/linker/linker_logger.cpp b/linker/linker_logger.cpp
new file mode 100644
index 0000000..a9d358a
--- /dev/null
+++ b/linker/linker_logger.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <sys/prctl.h>
+#include <sys/system_properties.h>
+#include <unistd.h>
+
+#include <string>
+#include <vector>
+
+#include "android-base/strings.h"
+#include "linker_logger.h"
+#include "private/libc_logging.h"
+
+LinkerLogger g_linker_logger;
+
+static const char* kSystemLdDebugProperty = "debug.ld.all";
+static const char* kLdDebugPropertyPrefix = "debug.ld.app.";
+
+static const char* kOptionErrors = "dlerror";
+static const char* kOptionDlopen = "dlopen";
+
+static std::string property_get(const char* name) {
+  char value[PROP_VALUE_MAX] = {};
+  __system_property_get(name, value);
+  return value;
+}
+
+static uint32_t ParseProperty(const std::string& value) {
+  if (value.empty()) {
+    return 0;
+  }
+
+  std::vector<std::string> options = android::base::Split(value, ",");
+
+  uint32_t flags = 0;
+
+  for (const auto& o : options) {
+    if (o == kOptionErrors) {
+      flags |= kLogErrors;
+    } else if (o == kOptionDlopen){
+      flags |= kLogDlopen;
+    } else {
+      __libc_format_log(ANDROID_LOG_WARN, "linker", "Unknown debug.ld option \"%s\", will ignore.", o.c_str());
+    }
+  }
+
+  return flags;
+}
+
+void LinkerLogger::ResetState() {
+  // the most likely scenario app is not debuggable and
+  // is running on user build - the logging is disabled.
+  if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0) {
+    return;
+  }
+
+  flags_ = 0;
+  // check flag applied to all processes first
+  std::string value = property_get(kSystemLdDebugProperty);
+  flags_ |= ParseProperty(value);
+
+  // get process basename
+  std::string process_name = basename(g_argv[0]);
+
+  std::string property_name = std::string(kLdDebugPropertyPrefix) + process_name;
+
+  // Property names are limited to PROP_NAME_MAX.
+
+  if (property_name.size() >= PROP_NAME_MAX) {
+    size_t count = PROP_NAME_MAX - 1;
+    // remove trailing dots...
+    while (property_name[count-1] == '.') {
+      --count;
+    }
+
+    property_name = property_name.substr(0, count);
+  }
+  value = property_get(property_name.c_str());
+  flags_ |= ParseProperty(value);
+}
+
+void LinkerLogger::Log(uint32_t type, const char* format, ...) {
+  if ((flags_ & type) == 0) {
+    return;
+  }
+
+  va_list ap;
+  va_start(ap, format);
+  __libc_format_log_va_list(ANDROID_LOG_DEBUG, "linker", format, ap);
+  va_end(ap);
+}
+
diff --git a/libstdc++/include/climits b/linker/linker_logger.h
similarity index 67%
copy from libstdc++/include/climits
copy to linker/linker_logger.h
index df85cb9..0932471 100644
--- a/libstdc++/include/climits
+++ b/linker/linker_logger.h
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,13 +26,34 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
-#define BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
+#ifndef _LINKER_LOGGER_H_
+#define _LINKER_LOGGER_H_
 
-/*
- * Standard C++ Library wrapper around the C limits.h header file.
- */
-
+#include <stdlib.h>
 #include <limits.h>
+#include "private/bionic_macros.h"
 
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
+#define LD_LOG(type, x...) \
+  { \
+    g_linker_logger.Log(type, x); \
+  }
+
+constexpr const uint32_t kLogErrors = 1 << 0;
+constexpr const uint32_t kLogDlopen = 1 << 1;
+
+class LinkerLogger {
+ public:
+  LinkerLogger() : flags_(0) { }
+
+  void ResetState();
+  void Log(uint32_t type, const char* format, ...);
+ private:
+  uint32_t flags_;
+
+  DISALLOW_COPY_AND_ASSIGN(LinkerLogger);
+};
+
+extern LinkerLogger g_linker_logger;
+extern char** g_argv;
+
+#endif /* _LINKER_LOGGER_H_ */
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
new file mode 100644
index 0000000..2e98bf0
--- /dev/null
+++ b/linker/linker_main.cpp
@@ -0,0 +1,536 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_main.h"
+
+#include "linker_debug.h"
+#include "linker_gdb_support.h"
+#include "linker_globals.h"
+#include "linker_phdr.h"
+#include "linker_utils.h"
+
+#include "private/bionic_globals.h"
+#include "private/bionic_tls.h"
+#include "private/KernelArgumentBlock.h"
+
+#include "android-base/strings.h"
+#include "android-base/stringprintf.h"
+#include "debuggerd/client.h"
+
+#include <vector>
+
+extern void __libc_init_globals(KernelArgumentBlock&);
+extern void __libc_init_AT_SECURE(KernelArgumentBlock&);
+
+extern "C" void _start();
+
+static ElfW(Addr) get_elf_exec_load_bias(const ElfW(Ehdr)* elf);
+
+// These should be preserved static to avoid emitting
+// RELATIVE relocations for the part of the code running
+// before linker links itself.
+
+// TODO (dimtiry): remove somain, rename solist to solist_head
+static soinfo* solist;
+static soinfo* sonext;
+static soinfo* somain; // main process, always the one after libdl_info
+
+void solist_add_soinfo(soinfo* si) {
+  sonext->next = si;
+  sonext = si;
+}
+
+bool solist_remove_soinfo(soinfo* si) {
+  soinfo *prev = nullptr, *trav;
+  for (trav = solist; trav != nullptr; trav = trav->next) {
+    if (trav == si) {
+      break;
+    }
+    prev = trav;
+  }
+
+  if (trav == nullptr) {
+    // si was not in solist
+    PRINT("name \"%s\"@%p is not in solist!", si->get_realpath(), si);
+    return false;
+  }
+
+  // prev will never be null, because the first entry in solist is
+  // always the static libdl_info.
+  prev->next = si->next;
+  if (si == sonext) {
+    sonext = prev;
+  }
+
+  return true;
+}
+
+soinfo* solist_get_head() {
+  return solist;
+}
+
+soinfo* solist_get_somain() {
+  return somain;
+}
+
+int g_ld_debug_verbosity;
+abort_msg_t* g_abort_message = nullptr; // For debuggerd.
+
+static std::vector<std::string> g_ld_preload_names;
+
+static std::vector<soinfo*> g_ld_preloads;
+
+static void parse_path(const char* path, const char* delimiters,
+                       std::vector<std::string>* resolved_paths) {
+  std::vector<std::string> paths;
+  split_path(path, delimiters, &paths);
+  resolve_paths(paths, resolved_paths);
+}
+
+static void parse_LD_LIBRARY_PATH(const char* path) {
+  std::vector<std::string> ld_libary_paths;
+  parse_path(path, ":", &ld_libary_paths);
+  g_default_namespace.set_ld_library_paths(std::move(ld_libary_paths));
+}
+
+static void parse_LD_PRELOAD(const char* path) {
+  g_ld_preload_names.clear();
+  if (path != nullptr) {
+    // We have historically supported ':' as well as ' ' in LD_PRELOAD.
+    g_ld_preload_names = android::base::Split(path, " :");
+    std::remove_if(g_ld_preload_names.begin(),
+                   g_ld_preload_names.end(),
+                   [] (const std::string& s) { return s.empty(); });
+  }
+}
+
+// An empty list of soinfos
+static soinfo_list_t g_empty_list;
+
+static void add_vdso(KernelArgumentBlock& args __unused) {
+#if defined(AT_SYSINFO_EHDR)
+  ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(args.getauxval(AT_SYSINFO_EHDR));
+  if (ehdr_vdso == nullptr) {
+    return;
+  }
+
+  soinfo* si = soinfo_alloc(&g_default_namespace, "[vdso]", nullptr, 0, 0);
+
+  si->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
+  si->phnum = ehdr_vdso->e_phnum;
+  si->base = reinterpret_cast<ElfW(Addr)>(ehdr_vdso);
+  si->size = phdr_table_get_load_size(si->phdr, si->phnum);
+  si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
+
+  si->prelink_image();
+  si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr);
+#endif
+}
+
+/* gdb expects the linker to be in the debug shared object list.
+ * Without this, gdb has trouble locating the linker's ".text"
+ * and ".plt" sections. Gdb could also potentially use this to
+ * relocate the offset of our exported 'rtld_db_dlactivity' symbol.
+ * Note that the linker shouldn't be on the soinfo list.
+ */
+static void init_linker_info_for_gdb(ElfW(Addr) linker_base) {
+  static link_map linker_link_map_for_gdb;
+#if defined(__LP64__)
+  static char kLinkerPath[] = "/system/bin/linker64";
+#else
+  static char kLinkerPath[] = "/system/bin/linker";
+#endif
+
+  linker_link_map_for_gdb.l_addr = linker_base;
+  linker_link_map_for_gdb.l_name = kLinkerPath;
+
+  /*
+   * Set the dynamic field in the link map otherwise gdb will complain with
+   * the following:
+   *   warning: .dynamic section for "/system/bin/linker" is not at the
+   *   expected address (wrong library or version mismatch?)
+   */
+  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_base);
+  ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(linker_base + elf_hdr->e_phoff);
+  phdr_table_get_dynamic_section(phdr, elf_hdr->e_phnum, linker_base,
+                                 &linker_link_map_for_gdb.l_ld, nullptr);
+
+  insert_link_map_into_debug_map(&linker_link_map_for_gdb);
+}
+
+extern "C" int __system_properties_init(void);
+
+static const char* get_executable_path() {
+  static std::string executable_path;
+  if (executable_path.empty()) {
+    char path[PATH_MAX];
+    ssize_t path_len = readlink("/proc/self/exe", path, sizeof(path));
+    if (path_len == -1 || path_len >= static_cast<ssize_t>(sizeof(path))) {
+      __libc_fatal("readlink('/proc/self/exe') failed: %s", strerror(errno));
+    }
+    executable_path = std::string(path, path_len);
+  }
+
+  return executable_path.c_str();
+}
+
+/*
+ * This code is called after the linker has linked itself and
+ * fixed it's own GOT. It is safe to make references to externs
+ * and other non-local data at this point.
+ */
+static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(Addr) linker_base) {
+#if TIMING
+  struct timeval t0, t1;
+  gettimeofday(&t0, 0);
+#endif
+
+  // Sanitize the environment.
+  __libc_init_AT_SECURE(args);
+
+  // Initialize system properties
+  __system_properties_init(); // may use 'environ'
+
+  // Register the debuggerd signal handler.
+  debuggerd_callbacks_t callbacks = {
+    .get_abort_message = []() {
+      return g_abort_message;
+    },
+    .post_dump = &notify_gdb_of_libraries,
+  };
+  debuggerd_init(&callbacks);
+
+  g_linker_logger.ResetState();
+
+  // Get a few environment variables.
+  const char* LD_DEBUG = getenv("LD_DEBUG");
+  if (LD_DEBUG != nullptr) {
+    g_ld_debug_verbosity = atoi(LD_DEBUG);
+  }
+
+#if defined(__LP64__)
+  INFO("[ Android dynamic linker (64-bit) ]");
+#else
+  INFO("[ Android dynamic linker (32-bit) ]");
+#endif
+
+  // These should have been sanitized by __libc_init_AT_SECURE, but the test
+  // doesn't cost us anything.
+  const char* ldpath_env = nullptr;
+  const char* ldpreload_env = nullptr;
+  if (!getauxval(AT_SECURE)) {
+    ldpath_env = getenv("LD_LIBRARY_PATH");
+    if (ldpath_env != nullptr) {
+      INFO("[ LD_LIBRARY_PATH set to \"%s\" ]", ldpath_env);
+    }
+    ldpreload_env = getenv("LD_PRELOAD");
+    if (ldpreload_env != nullptr) {
+      INFO("[ LD_PRELOAD set to \"%s\" ]", ldpreload_env);
+    }
+  }
+
+  struct stat file_stat;
+  // Stat "/proc/self/exe" instead of executable_path because
+  // the executable could be unlinked by this point and it should
+  // not cause a crash (see http://b/31084669)
+  if (TEMP_FAILURE_RETRY(stat("/proc/self/exe", &file_stat)) != 0) {
+    __libc_fatal("unable to stat \"/proc/self/exe\": %s", strerror(errno));
+  }
+
+  const char* executable_path = get_executable_path();
+  soinfo* si = soinfo_alloc(&g_default_namespace, executable_path, &file_stat, 0, RTLD_GLOBAL);
+  if (si == nullptr) {
+    __libc_fatal("Couldn't allocate soinfo: out of memory?");
+  }
+
+  /* bootstrap the link map, the main exe always needs to be first */
+  si->set_main_executable();
+  link_map* map = &(si->link_map_head);
+
+  // Register the main executable and the linker upfront to have
+  // gdb aware of them before loading the rest of the dependency
+  // tree.
+  map->l_addr = 0;
+  map->l_name = const_cast<char*>(executable_path);
+  insert_link_map_into_debug_map(map);
+  init_linker_info_for_gdb(linker_base);
+
+  // Extract information passed from the kernel.
+  si->phdr = reinterpret_cast<ElfW(Phdr)*>(args.getauxval(AT_PHDR));
+  si->phnum = args.getauxval(AT_PHNUM);
+
+  /* Compute the value of si->base. We can't rely on the fact that
+   * the first entry is the PHDR because this will not be true
+   * for certain executables (e.g. some in the NDK unit test suite)
+   */
+  si->base = 0;
+  si->size = phdr_table_get_load_size(si->phdr, si->phnum);
+  si->load_bias = 0;
+  for (size_t i = 0; i < si->phnum; ++i) {
+    if (si->phdr[i].p_type == PT_PHDR) {
+      si->load_bias = reinterpret_cast<ElfW(Addr)>(si->phdr) - si->phdr[i].p_vaddr;
+      si->base = reinterpret_cast<ElfW(Addr)>(si->phdr) - si->phdr[i].p_offset;
+      break;
+    }
+  }
+  si->dynamic = nullptr;
+
+  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
+  if (elf_hdr->e_type != ET_DYN) {
+    __libc_fatal("\"%s\": error: only position independent executables (PIE) are supported.",
+                 g_argv[0]);
+  }
+
+  // Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
+  parse_LD_LIBRARY_PATH(ldpath_env);
+  parse_LD_PRELOAD(ldpreload_env);
+
+  somain = si;
+
+  init_default_namespace();
+
+  if (!si->prelink_image()) {
+    __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", g_argv[0], linker_get_error_buffer());
+  }
+
+  // add somain to global group
+  si->set_dt_flags_1(si->get_dt_flags_1() | DF_1_GLOBAL);
+
+  // Load ld_preloads and dependencies.
+  std::vector<const char*> needed_library_name_list;
+  size_t ld_preloads_count = 0;
+
+  for (const auto& ld_preload_name : g_ld_preload_names) {
+    needed_library_name_list.push_back(ld_preload_name.c_str());
+    ++ld_preloads_count;
+  }
+
+  for_each_dt_needed(si, [&](const char* name) {
+    needed_library_name_list.push_back(name);
+  });
+
+  const char** needed_library_names = &needed_library_name_list[0];
+  size_t needed_libraries_count = needed_library_name_list.size();
+
+  if (needed_libraries_count > 0 &&
+      !find_libraries(&g_default_namespace, si, needed_library_names, needed_libraries_count,
+                      nullptr, &g_ld_preloads, ld_preloads_count, RTLD_GLOBAL, nullptr,
+                      /* add_as_children */ true)) {
+    __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", g_argv[0], linker_get_error_buffer());
+  } else if (needed_libraries_count == 0) {
+    if (!si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr)) {
+      __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", g_argv[0], linker_get_error_buffer());
+    }
+    si->increment_ref_count();
+  }
+
+  add_vdso(args);
+
+  {
+    ProtectedDataGuard guard;
+
+    si->call_pre_init_constructors();
+
+    /* After the prelink_image, the si->load_bias is initialized.
+     * For so lib, the map->l_addr will be updated in notify_gdb_of_load.
+     * We need to update this value for so exe here. So Unwind_Backtrace
+     * for some arch like x86 could work correctly within so exe.
+     */
+    map->l_addr = si->load_bias;
+    si->call_constructors();
+  }
+
+#if TIMING
+  gettimeofday(&t1, nullptr);
+  PRINT("LINKER TIME: %s: %d microseconds", g_argv[0], (int) (
+           (((long long)t1.tv_sec * 1000000LL) + (long long)t1.tv_usec) -
+           (((long long)t0.tv_sec * 1000000LL) + (long long)t0.tv_usec)));
+#endif
+#if STATS
+  PRINT("RELO STATS: %s: %d abs, %d rel, %d copy, %d symbol", g_argv[0],
+         linker_stats.count[kRelocAbsolute],
+         linker_stats.count[kRelocRelative],
+         linker_stats.count[kRelocCopy],
+         linker_stats.count[kRelocSymbol]);
+#endif
+#if COUNT_PAGES
+  {
+    unsigned n;
+    unsigned i;
+    unsigned count = 0;
+    for (n = 0; n < 4096; n++) {
+      if (bitmask[n]) {
+        unsigned x = bitmask[n];
+#if defined(__LP64__)
+        for (i = 0; i < 32; i++) {
+#else
+        for (i = 0; i < 8; i++) {
+#endif
+          if (x & 1) {
+            count++;
+          }
+          x >>= 1;
+        }
+      }
+    }
+    PRINT("PAGES MODIFIED: %s: %d (%dKB)", g_argv[0], count, count * 4);
+  }
+#endif
+
+#if TIMING || STATS || COUNT_PAGES
+  fflush(stdout);
+#endif
+
+  ElfW(Addr) entry = args.getauxval(AT_ENTRY);
+  TRACE("[ Ready to execute \"%s\" @ %p ]", si->get_realpath(), reinterpret_cast<void*>(entry));
+  return entry;
+}
+
+/* Compute the load-bias of an existing executable. This shall only
+ * be used to compute the load bias of an executable or shared library
+ * that was loaded by the kernel itself.
+ *
+ * Input:
+ *    elf    -> address of ELF header, assumed to be at the start of the file.
+ * Return:
+ *    load bias, i.e. add the value of any p_vaddr in the file to get
+ *    the corresponding address in memory.
+ */
+static ElfW(Addr) get_elf_exec_load_bias(const ElfW(Ehdr)* elf) {
+  ElfW(Addr) offset = elf->e_phoff;
+  const ElfW(Phdr)* phdr_table =
+      reinterpret_cast<const ElfW(Phdr)*>(reinterpret_cast<uintptr_t>(elf) + offset);
+  const ElfW(Phdr)* phdr_end = phdr_table + elf->e_phnum;
+
+  for (const ElfW(Phdr)* phdr = phdr_table; phdr < phdr_end; phdr++) {
+    if (phdr->p_type == PT_LOAD) {
+      return reinterpret_cast<ElfW(Addr)>(elf) + phdr->p_offset - phdr->p_vaddr;
+    }
+  }
+  return 0;
+}
+
+static void __linker_cannot_link(const char* argv0) {
+  __libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", argv0, linker_get_error_buffer());
+}
+
+/*
+ * This is the entry point for the linker, called from begin.S. This
+ * method is responsible for fixing the linker's own relocations, and
+ * then calling __linker_init_post_relocation().
+ *
+ * Because this method is called before the linker has fixed it's own
+ * relocations, any attempt to reference an extern variable, extern
+ * function, or other GOT reference will generate a segfault.
+ */
+extern "C" ElfW(Addr) __linker_init(void* raw_args) {
+  KernelArgumentBlock args(raw_args);
+
+  ElfW(Addr) linker_addr = args.getauxval(AT_BASE);
+  ElfW(Addr) entry_point = args.getauxval(AT_ENTRY);
+  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_addr);
+  ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(linker_addr + elf_hdr->e_phoff);
+
+  soinfo linker_so(nullptr, nullptr, nullptr, 0, 0);
+
+  // If the linker is not acting as PT_INTERP entry_point is equal to
+  // _start. Which means that the linker is running as an executable and
+  // already linked by PT_INTERP.
+  //
+  // This happens when user tries to run 'adb shell /system/bin/linker'
+  // see also https://code.google.com/p/android/issues/detail?id=63174
+  if (reinterpret_cast<ElfW(Addr)>(&_start) == entry_point) {
+    __libc_format_fd(STDOUT_FILENO,
+                     "This is %s, the helper program for shared library executables.\n",
+                     args.argv[0]);
+    exit(0);
+  }
+
+  linker_so.base = linker_addr;
+  linker_so.size = phdr_table_get_load_size(phdr, elf_hdr->e_phnum);
+  linker_so.load_bias = get_elf_exec_load_bias(elf_hdr);
+  linker_so.dynamic = nullptr;
+  linker_so.phdr = phdr;
+  linker_so.phnum = elf_hdr->e_phnum;
+  linker_so.set_linker_flag();
+
+  // Prelink the linker so we can access linker globals.
+  if (!linker_so.prelink_image()) __linker_cannot_link(args.argv[0]);
+
+  // This might not be obvious... The reasons why we pass g_empty_list
+  // in place of local_group here are (1) we do not really need it, because
+  // linker is built with DT_SYMBOLIC and therefore relocates its symbols against
+  // itself without having to look into local_group and (2) allocators
+  // are not yet initialized, and therefore we cannot use linked_list.push_*
+  // functions at this point.
+  if (!linker_so.link_image(g_empty_list, g_empty_list, nullptr)) __linker_cannot_link(args.argv[0]);
+
+#if defined(__i386__)
+  // On x86, we can't make system calls before this point.
+  // We can't move this up because this needs to assign to a global.
+  // Note that until we call __libc_init_main_thread below we have
+  // no TLS, so you shouldn't make a system call that can fail, because
+  // it will SEGV when it tries to set errno.
+  __libc_init_sysinfo(args);
+#endif
+
+  // Initialize the main thread (including TLS, so system calls really work).
+  __libc_init_main_thread(args);
+
+  // We didn't protect the linker's RELRO pages in link_image because we
+  // couldn't make system calls on x86 at that point, but we can now...
+  if (!linker_so.protect_relro()) __linker_cannot_link(args.argv[0]);
+
+  // Initialize the linker's static libc's globals
+  __libc_init_globals(args);
+
+  // store argc/argv/envp to use them for calling constructors
+  g_argc = args.argc;
+  g_argv = args.argv;
+  g_envp = args.envp;
+
+  // Initialize the linker's own global variables
+  linker_so.call_constructors();
+
+  // Initialize static variables. Note that in order to
+  // get correct libdl_info we need to call constructors
+  // before get_libdl_info().
+  solist = get_libdl_info();
+  sonext = get_libdl_info();
+  g_default_namespace.add_soinfo(get_libdl_info());
+
+  // We have successfully fixed our own relocations. It's safe to run
+  // the main part of the linker now.
+  args.abort_message_ptr = &g_abort_message;
+  ElfW(Addr) start_address = __linker_init_post_relocation(args, linker_addr);
+
+  INFO("[ Jumping to _start (%p)... ]", reinterpret_cast<void*>(start_address));
+
+  // Return the address that the calling assembly stub should jump to.
+  return start_address;
+}
diff --git a/linker/linker_main.h b/linker/linker_main.h
new file mode 100644
index 0000000..0030f49
--- /dev/null
+++ b/linker/linker_main.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_MAIN_H
+#define __LINKER_MAIN_H
+
+#include <android/dlext.h>
+
+#include "linker_namespaces.h"
+#include "linker_soinfo.h"
+
+class ProtectedDataGuard {
+ public:
+  ProtectedDataGuard();
+  ~ProtectedDataGuard();
+
+ private:
+  void protect_data(int protection);
+  static size_t ref_count_;
+};
+
+void init_default_namespace();
+soinfo* soinfo_alloc(android_namespace_t* ns, const char* name,
+                     struct stat* file_stat, off64_t file_offset,
+                     uint32_t rtld_flags);
+
+bool find_libraries(android_namespace_t* ns,
+                    soinfo* start_with,
+                    const char* const library_names[],
+                    size_t library_names_count,
+                    soinfo* soinfos[],
+                    std::vector<soinfo*>* ld_preloads,
+                    size_t ld_preloads_count,
+                    int rtld_flags,
+                    const android_dlextinfo* extinfo,
+                    bool add_as_children);
+
+void solist_add_soinfo(soinfo* si);
+bool solist_remove_soinfo(soinfo* si);
+soinfo* solist_get_head();
+soinfo* solist_get_somain();
+
+#endif
diff --git a/linker/linker_mips.cpp b/linker/linker_mips.cpp
index 2d565d7..cd392dc 100644
--- a/linker/linker_mips.cpp
+++ b/linker/linker_mips.cpp
@@ -32,10 +32,12 @@
 
 #include "linker.h"
 #include "linker_debug.h"
+#include "linker_globals.h"
 #include "linker_phdr.h"
 #include "linker_relocs.h"
 #include "linker_reloc_iterators.h"
 #include "linker_sleb128.h"
+#include "linker_soinfo.h"
 
 template bool soinfo::relocate<plain_reloc_iterator>(const VersionTracker& version_tracker,
                                                      plain_reloc_iterator&& rel_iterator,
@@ -256,18 +258,10 @@
 
   // FP ABI-variant compatibility checks for MIPS o32 ABI
   if (abiflags == nullptr) {
-    // Old compilers and some translators don't emit the new abiflags section.
-    const char* filename = get_realpath();
-    size_t len = strlen(filename);
-    if (len > 4 && (strcmp(filename+len-4, ".dex") == 0 ||
-                    strcmp(filename+len-4, ".oat") == 0   )) {
-      // Assume dex2oat is compatible with target
-      mips_fpabi = MIPS_ABI_FP_XX;
-    } else {
-      // Old Android compilers used -mfp32 -mdouble-float -modd-spreg defaults,
-      //   ie FP32 aka DOUBLE, using FR=0 mode fpregs & odd single-prec fpregs
-      mips_fpabi = MIPS_ABI_FP_DOUBLE;
-    }
+    // Old compilers lack the new abiflags section.
+    // These compilers used -mfp32 -mdouble-float -modd-spreg defaults,
+    //   ie FP32 aka DOUBLE, using odd-numbered single-prec regs
+    mips_fpabi = MIPS_ABI_FP_DOUBLE;
   } else {
     mips_fpabi = abiflags->fp_abi;
     if ( (abiflags->flags1 & MIPS_AFL_FLAGS1_ODDSPREG)
diff --git a/libc/bionic/utimes.cpp b/linker/linker_namespaces.cpp
similarity index 69%
copy from libc/bionic/utimes.cpp
copy to linker/linker_namespaces.cpp
index 0b66e6c..675f324 100644
--- a/libc/bionic/utimes.cpp
+++ b/linker/linker_namespaces.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,22 +26,34 @@
  * SUCH DAMAGE.
  */
 
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/time.h>
+#include "linker_namespaces.h"
+#include "linker_utils.h"
 
-#include "private/bionic_time_conversions.h"
+#include <vector>
 
-int utimes(const char* path, const timeval tv[2]) {
-  timespec ts[2];
-  timespec* ts_ptr = NULL;
-  if (tv != NULL) {
-    if (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1])) {
-      errno = EINVAL;
-      return -1;
-    }
-    ts_ptr = ts;
+bool android_namespace_t::is_accessible(const std::string& file) {
+  if (!is_isolated_) {
+    return true;
   }
-  return utimensat(AT_FDCWD, path, ts_ptr, 0);
+
+  for (const auto& dir : ld_library_paths_) {
+    if (file_is_in_dir(file, dir)) {
+      return true;
+    }
+  }
+
+  for (const auto& dir : default_library_paths_) {
+    if (file_is_in_dir(file, dir)) {
+      return true;
+    }
+  }
+
+  for (const auto& dir : permitted_paths_) {
+    if (file_is_under_dir(file, dir)) {
+      return true;
+    }
+  }
+
+  return false;
 }
+
diff --git a/linker/linker_namespaces.h b/linker/linker_namespaces.h
new file mode 100644
index 0000000..c1cee8e
--- /dev/null
+++ b/linker/linker_namespaces.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_NAMESPACES_H
+#define __LINKER_NAMESPACES_H
+
+#include "linker_common_types.h"
+
+#include <string>
+#include <vector>
+
+struct android_namespace_t {
+ public:
+  android_namespace_t() : name_(nullptr), is_isolated_(false) {}
+
+  const char* get_name() const { return name_; }
+  void set_name(const char* name) { name_ = name; }
+
+  bool is_isolated() const { return is_isolated_; }
+  void set_isolated(bool isolated) { is_isolated_ = isolated; }
+
+  const std::vector<std::string>& get_ld_library_paths() const {
+    return ld_library_paths_;
+  }
+  void set_ld_library_paths(std::vector<std::string>&& library_paths) {
+    ld_library_paths_ = library_paths;
+  }
+
+  const std::vector<std::string>& get_default_library_paths() const {
+    return default_library_paths_;
+  }
+  void set_default_library_paths(std::vector<std::string>&& library_paths) {
+    default_library_paths_ = library_paths;
+  }
+
+  const std::vector<std::string>& get_permitted_paths() const {
+    return permitted_paths_;
+  }
+  void set_permitted_paths(std::vector<std::string>&& permitted_paths) {
+    permitted_paths_ = permitted_paths;
+  }
+
+  void add_soinfo(soinfo* si) {
+    soinfo_list_.push_back(si);
+  }
+
+  void add_soinfos(const soinfo_list_t& soinfos) {
+    for (auto si : soinfos) {
+      add_soinfo(si);
+    }
+  }
+
+  void remove_soinfo(soinfo* si) {
+    soinfo_list_.remove_if([&](soinfo* candidate) {
+      return si == candidate;
+    });
+  }
+
+  const soinfo_list_t& soinfo_list() const { return soinfo_list_; }
+
+  // For isolated namespaces - checks if the file is on the search path;
+  // always returns true for not isolated namespace.
+  bool is_accessible(const std::string& path);
+
+ private:
+  const char* name_;
+  bool is_isolated_;
+  std::vector<std::string> ld_library_paths_;
+  std::vector<std::string> default_library_paths_;
+  std::vector<std::string> permitted_paths_;
+  soinfo_list_t soinfo_list_;
+
+  DISALLOW_COPY_AND_ASSIGN(android_namespace_t);
+};
+
+#endif  /* __LINKER_NAMESPACES_H */
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 9ed612f..bced722 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -36,6 +36,7 @@
 #include <unistd.h>
 
 #include "linker.h"
+#include "linker_globals.h"
 #include "linker_debug.h"
 #include "linker_utils.h"
 
@@ -245,6 +246,17 @@
     return false;
   }
 
+  if (header_.e_shentsize != sizeof(ElfW(Shdr))) {
+    DL_ERR("\"%s\" has unsupported e_shentsize: 0x%x (expected 0x%zx)",
+           name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr)));
+    return false;
+  }
+
+  if (header_.e_shstrndx == 0) {
+    DL_ERR("\"%s\" has invalid e_shstrndx", name_.c_str());
+    return false;
+  }
+
   return true;
 }
 
@@ -252,7 +264,12 @@
   off64_t range_start;
   off64_t range_end;
 
-  return safe_add(&range_start, file_offset_, offset) &&
+  // Only header can be located at the 0 offset... This function called to
+  // check DYNSYM and DYNAMIC sections and phdr/shdr - none of them can be
+  // at offset 0.
+
+  return offset > 0 &&
+         safe_add(&range_start, file_offset_, offset) &&
          safe_add(&range_end, range_start, size) &&
          (range_start < file_size_) &&
          (range_end <= file_size_) &&
@@ -331,6 +348,35 @@
     return false;
   }
 
+  // Make sure dynamic_shdr offset and size matches PT_DYNAMIC phdr
+  size_t pt_dynamic_offset = 0;
+  size_t pt_dynamic_filesz = 0;
+  for (size_t i = 0; i < phdr_num_; ++i) {
+    const ElfW(Phdr)* phdr = &phdr_table_[i];
+    if (phdr->p_type == PT_DYNAMIC) {
+      pt_dynamic_offset = phdr->p_offset;
+      pt_dynamic_filesz = phdr->p_filesz;
+    }
+  }
+
+  if (pt_dynamic_offset != dynamic_shdr->sh_offset) {
+    DL_ERR("\"%s\" .dynamic section has invalid offset: 0x%zx, "
+           "expected to match PT_DYNAMIC offset: 0x%zx",
+           name_.c_str(),
+           static_cast<size_t>(dynamic_shdr->sh_offset),
+           pt_dynamic_offset);
+    return false;
+  }
+
+  if (pt_dynamic_filesz != dynamic_shdr->sh_size) {
+    DL_ERR("\"%s\" .dynamic section has invalid size: 0x%zx, "
+           "expected to match PT_DYNAMIC filesz: 0x%zx",
+           name_.c_str(),
+           static_cast<size_t>(dynamic_shdr->sh_size),
+           pt_dynamic_filesz);
+    return false;
+  }
+
   if (dynamic_shdr->sh_link >= shdr_num_) {
     DL_ERR_AND_LOG("\"%s\" .dynamic section has invalid sh_link: %d",
                    name_.c_str(),
@@ -423,6 +469,40 @@
   return max_vaddr - min_vaddr;
 }
 
+// Reserve a virtual address range such that if it's limits were extended to the next 2**align
+// boundary, it would not overlap with any existing mappings.
+static void* ReserveAligned(void* hint, size_t size, size_t align) {
+  int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
+  // Address hint is only used in Art for the image mapping, and it is pretty important. Don't mess
+  // with it.
+  // FIXME: try an aligned allocation and fall back to plain mmap() if the former does not provide a
+  // mapping at the requested address?
+  if (align == PAGE_SIZE || hint != nullptr) {
+    void* mmap_ptr = mmap(hint, size, PROT_NONE, mmap_flags, -1, 0);
+    if (mmap_ptr == MAP_FAILED) {
+      return nullptr;
+    }
+    return mmap_ptr;
+  }
+
+  // Allocate enough space so that the end of the desired region aligned up is still inside the
+  // mapping.
+  size_t mmap_size = align_up(size, align) + align - PAGE_SIZE;
+  uint8_t* mmap_ptr =
+      reinterpret_cast<uint8_t*>(mmap(nullptr, mmap_size, PROT_NONE, mmap_flags, -1, 0));
+  if (mmap_ptr == MAP_FAILED) {
+    return nullptr;
+  }
+
+  uint8_t* first = align_up(mmap_ptr, align);
+  uint8_t* last = align_down(mmap_ptr + mmap_size, align) - size;
+  size_t n = arc4random_uniform((last - first) / PAGE_SIZE + 1);
+  uint8_t* start = first + n * PAGE_SIZE;
+  munmap(mmap_ptr, start - mmap_ptr);
+  munmap(start + size, mmap_ptr + mmap_size - (start + size));
+  return start;
+}
+
 // Reserve a virtual address range big enough to hold all loadable
 // segments of a program header table. This is done by creating a
 // private anonymous mmap() with PROT_NONE.
@@ -464,9 +544,8 @@
              reserved_size - load_size_, load_size_, name_.c_str());
       return false;
     }
-    int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
-    start = mmap(mmap_hint, load_size_, PROT_NONE, mmap_flags, -1, 0);
-    if (start == MAP_FAILED) {
+    start = ReserveAligned(mmap_hint, load_size_, kLibraryAlignment);
+    if (start == nullptr) {
       DL_ERR("couldn't reserve %zd bytes of address space for \"%s\"", load_size_, name_.c_str());
       return false;
     }
@@ -528,10 +607,8 @@
       int prot = PFLAGS_TO_PROT(phdr->p_flags);
       // W + E PT_LOAD segments are not allowed.
       if ((prot & (PROT_EXEC | PROT_WRITE)) == (PROT_EXEC | PROT_WRITE)) {
-        DL_WARN("\"%s\": has W+E (writable and executable) load segments. "
-                "This is a security risk shared libraries with W+E load segments "
-                "will not be supported in a future Android release. "
-                "Please fix the library.", name_.c_str());
+        DL_ERR_AND_LOG("\"%s\": W + E load segments are not allowed", name_.c_str());
+        return false;
       }
 
       void* seg_addr = mmap64(reinterpret_cast<void*>(seg_page_start),
diff --git a/linker/linker_sleb128.h b/linker/linker_sleb128.h
index a34916f..c4df259 100644
--- a/linker/linker_sleb128.h
+++ b/linker/linker_sleb128.h
@@ -19,6 +19,8 @@
 
 #include <stdint.h>
 
+#include "linker_debug.h"
+
 // Helper classes for decoding LEB128, used in packed relocation data.
 // http://en.wikipedia.org/wiki/LEB128
 
diff --git a/linker/linker_soinfo.cpp b/linker/linker_soinfo.cpp
new file mode 100644
index 0000000..59bdc4d
--- /dev/null
+++ b/linker/linker_soinfo.cpp
@@ -0,0 +1,795 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_soinfo.h"
+
+#include <dlfcn.h>
+#include <elf.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "linker_debug.h"
+#include "linker_globals.h"
+#include "linker_logger.h"
+#include "linker_utils.h"
+
+// TODO(dimitry): These functions are currently located in linker.cpp - find a better place for it
+bool find_verdef_version_index(const soinfo* si, const version_info* vi, ElfW(Versym)* versym);
+ElfW(Addr) call_ifunc_resolver(ElfW(Addr) resolver_addr);
+uint32_t get_application_target_sdk_version();
+
+soinfo::soinfo(android_namespace_t* ns, const char* realpath,
+               const struct stat* file_stat, off64_t file_offset,
+               int rtld_flags) {
+  memset(this, 0, sizeof(*this));
+
+  if (realpath != nullptr) {
+    realpath_ = realpath;
+  }
+
+  flags_ = FLAG_NEW_SOINFO;
+  version_ = SOINFO_VERSION;
+
+  if (file_stat != nullptr) {
+    this->st_dev_ = file_stat->st_dev;
+    this->st_ino_ = file_stat->st_ino;
+    this->file_offset_ = file_offset;
+  }
+
+  this->rtld_flags_ = rtld_flags;
+  this->primary_namespace_ = ns;
+}
+
+soinfo::~soinfo() {
+  g_soinfo_handles_map.erase(handle_);
+}
+
+void soinfo::set_dt_runpath(const char* path) {
+  if (!has_min_version(3)) {
+    return;
+  }
+
+  std::vector<std::string> runpaths;
+
+  split_path(path, ":", &runpaths);
+
+  std::string origin = dirname(get_realpath());
+  // FIXME: add $LIB and $PLATFORM.
+  std::pair<std::string, std::string> substs[] = {{"ORIGIN", origin}};
+  for (auto&& s : runpaths) {
+    size_t pos = 0;
+    while (pos < s.size()) {
+      pos = s.find("$", pos);
+      if (pos == std::string::npos) break;
+      for (const auto& subst : substs) {
+        const std::string& token = subst.first;
+        const std::string& replacement = subst.second;
+        if (s.substr(pos + 1, token.size()) == token) {
+          s.replace(pos, token.size() + 1, replacement);
+          // -1 to compensate for the ++pos below.
+          pos += replacement.size() - 1;
+          break;
+        } else if (s.substr(pos + 1, token.size() + 2) == "{" + token + "}") {
+          s.replace(pos, token.size() + 3, replacement);
+          pos += replacement.size() - 1;
+          break;
+        }
+      }
+      // Skip $ in case it did not match any of the known substitutions.
+      ++pos;
+    }
+  }
+
+  resolve_paths(runpaths, &dt_runpath_);
+}
+
+const ElfW(Versym)* soinfo::get_versym(size_t n) const {
+  if (has_min_version(2) && versym_ != nullptr) {
+    return versym_ + n;
+  }
+
+  return nullptr;
+}
+
+ElfW(Addr) soinfo::get_verneed_ptr() const {
+  if (has_min_version(2)) {
+    return verneed_ptr_;
+  }
+
+  return 0;
+}
+
+size_t soinfo::get_verneed_cnt() const {
+  if (has_min_version(2)) {
+    return verneed_cnt_;
+  }
+
+  return 0;
+}
+
+ElfW(Addr) soinfo::get_verdef_ptr() const {
+  if (has_min_version(2)) {
+    return verdef_ptr_;
+  }
+
+  return 0;
+}
+
+size_t soinfo::get_verdef_cnt() const {
+  if (has_min_version(2)) {
+    return verdef_cnt_;
+  }
+
+  return 0;
+}
+
+bool soinfo::find_symbol_by_name(SymbolName& symbol_name,
+                                 const version_info* vi,
+                                 const ElfW(Sym)** symbol) const {
+  uint32_t symbol_index;
+  bool success =
+      is_gnu_hash() ?
+      gnu_lookup(symbol_name, vi, &symbol_index) :
+      elf_lookup(symbol_name, vi, &symbol_index);
+
+  if (success) {
+    *symbol = symbol_index == 0 ? nullptr : symtab_ + symbol_index;
+  }
+
+  return success;
+}
+
+static bool is_symbol_global_and_defined(const soinfo* si, const ElfW(Sym)* s) {
+  if (ELF_ST_BIND(s->st_info) == STB_GLOBAL ||
+      ELF_ST_BIND(s->st_info) == STB_WEAK) {
+    return s->st_shndx != SHN_UNDEF;
+  } else if (ELF_ST_BIND(s->st_info) != STB_LOCAL) {
+    DL_WARN("unexpected ST_BIND value: %d for \"%s\" in \"%s\"",
+            ELF_ST_BIND(s->st_info), si->get_string(s->st_name), si->get_realpath());
+  }
+
+  return false;
+}
+
+static const ElfW(Versym) kVersymHiddenBit = 0x8000;
+
+static inline bool is_versym_hidden(const ElfW(Versym)* versym) {
+  // the symbol is hidden if bit 15 of versym is set.
+  return versym != nullptr && (*versym & kVersymHiddenBit) != 0;
+}
+
+static inline bool check_symbol_version(const ElfW(Versym) verneed,
+                                        const ElfW(Versym)* verdef) {
+  return verneed == kVersymNotNeeded ||
+      verdef == nullptr ||
+      verneed == (*verdef & ~kVersymHiddenBit);
+}
+
+bool soinfo::gnu_lookup(SymbolName& symbol_name,
+                        const version_info* vi,
+                        uint32_t* symbol_index) const {
+  uint32_t hash = symbol_name.gnu_hash();
+  uint32_t h2 = hash >> gnu_shift2_;
+
+  uint32_t bloom_mask_bits = sizeof(ElfW(Addr))*8;
+  uint32_t word_num = (hash / bloom_mask_bits) & gnu_maskwords_;
+  ElfW(Addr) bloom_word = gnu_bloom_filter_[word_num];
+
+  *symbol_index = 0;
+
+  TRACE_TYPE(LOOKUP, "SEARCH %s in %s@%p (gnu)",
+      symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
+
+  // test against bloom filter
+  if ((1 & (bloom_word >> (hash % bloom_mask_bits)) & (bloom_word >> (h2 % bloom_mask_bits))) == 0) {
+    TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
+        symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
+
+    return true;
+  }
+
+  // bloom test says "probably yes"...
+  uint32_t n = gnu_bucket_[hash % gnu_nbucket_];
+
+  if (n == 0) {
+    TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
+        symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
+
+    return true;
+  }
+
+  // lookup versym for the version definition in this library
+  // note the difference between "version is not requested" (vi == nullptr)
+  // and "version not found". In the first case verneed is kVersymNotNeeded
+  // which implies that the default version can be accepted; the second case results in
+  // verneed = 1 (kVersymGlobal) and implies that we should ignore versioned symbols
+  // for this library and consider only *global* ones.
+  ElfW(Versym) verneed = 0;
+  if (!find_verdef_version_index(this, vi, &verneed)) {
+    return false;
+  }
+
+  do {
+    ElfW(Sym)* s = symtab_ + n;
+    const ElfW(Versym)* verdef = get_versym(n);
+    // skip hidden versions when verneed == kVersymNotNeeded (0)
+    if (verneed == kVersymNotNeeded && is_versym_hidden(verdef)) {
+        continue;
+    }
+    if (((gnu_chain_[n] ^ hash) >> 1) == 0 &&
+        check_symbol_version(verneed, verdef) &&
+        strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
+        is_symbol_global_and_defined(this, s)) {
+      TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
+          symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(s->st_value),
+          static_cast<size_t>(s->st_size));
+      *symbol_index = n;
+      return true;
+    }
+  } while ((gnu_chain_[n++] & 1) == 0);
+
+  TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
+             symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
+
+  return true;
+}
+
+bool soinfo::elf_lookup(SymbolName& symbol_name,
+                        const version_info* vi,
+                        uint32_t* symbol_index) const {
+  uint32_t hash = symbol_name.elf_hash();
+
+  TRACE_TYPE(LOOKUP, "SEARCH %s in %s@%p h=%x(elf) %zd",
+             symbol_name.get_name(), get_realpath(),
+             reinterpret_cast<void*>(base), hash, hash % nbucket_);
+
+  ElfW(Versym) verneed = 0;
+  if (!find_verdef_version_index(this, vi, &verneed)) {
+    return false;
+  }
+
+  for (uint32_t n = bucket_[hash % nbucket_]; n != 0; n = chain_[n]) {
+    ElfW(Sym)* s = symtab_ + n;
+    const ElfW(Versym)* verdef = get_versym(n);
+
+    // skip hidden versions when verneed == 0
+    if (verneed == kVersymNotNeeded && is_versym_hidden(verdef)) {
+        continue;
+    }
+
+    if (check_symbol_version(verneed, verdef) &&
+        strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
+        is_symbol_global_and_defined(this, s)) {
+      TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
+                 symbol_name.get_name(), get_realpath(),
+                 reinterpret_cast<void*>(s->st_value),
+                 static_cast<size_t>(s->st_size));
+      *symbol_index = n;
+      return true;
+    }
+  }
+
+  TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p %x %zd",
+             symbol_name.get_name(), get_realpath(),
+             reinterpret_cast<void*>(base), hash, hash % nbucket_);
+
+  *symbol_index = 0;
+  return true;
+}
+
+ElfW(Sym)* soinfo::find_symbol_by_address(const void* addr) {
+  return is_gnu_hash() ? gnu_addr_lookup(addr) : elf_addr_lookup(addr);
+}
+
+static bool symbol_matches_soaddr(const ElfW(Sym)* sym, ElfW(Addr) soaddr) {
+  return sym->st_shndx != SHN_UNDEF &&
+      soaddr >= sym->st_value &&
+      soaddr < sym->st_value + sym->st_size;
+}
+
+ElfW(Sym)* soinfo::gnu_addr_lookup(const void* addr) {
+  ElfW(Addr) soaddr = reinterpret_cast<ElfW(Addr)>(addr) - load_bias;
+
+  for (size_t i = 0; i < gnu_nbucket_; ++i) {
+    uint32_t n = gnu_bucket_[i];
+
+    if (n == 0) {
+      continue;
+    }
+
+    do {
+      ElfW(Sym)* sym = symtab_ + n;
+      if (symbol_matches_soaddr(sym, soaddr)) {
+        return sym;
+      }
+    } while ((gnu_chain_[n++] & 1) == 0);
+  }
+
+  return nullptr;
+}
+
+ElfW(Sym)* soinfo::elf_addr_lookup(const void* addr) {
+  ElfW(Addr) soaddr = reinterpret_cast<ElfW(Addr)>(addr) - load_bias;
+
+  // Search the library's symbol table for any defined symbol which
+  // contains this address.
+  for (size_t i = 0; i < nchain_; ++i) {
+    ElfW(Sym)* sym = symtab_ + i;
+    if (symbol_matches_soaddr(sym, soaddr)) {
+      return sym;
+    }
+  }
+
+  return nullptr;
+}
+
+static void call_function(const char* function_name __unused,
+                          linker_ctor_function_t function,
+                          const char* realpath __unused) {
+  if (function == nullptr || reinterpret_cast<uintptr_t>(function) == static_cast<uintptr_t>(-1)) {
+    return;
+  }
+
+  TRACE("[ Calling c-tor %s @ %p for '%s' ]", function_name, function, realpath);
+  function(g_argc, g_argv, g_envp);
+  TRACE("[ Done calling c-tor %s @ %p for '%s' ]", function_name, function, realpath);
+}
+
+static void call_function(const char* function_name __unused,
+                          linker_dtor_function_t function,
+                          const char* realpath __unused) {
+  if (function == nullptr || reinterpret_cast<uintptr_t>(function) == static_cast<uintptr_t>(-1)) {
+    return;
+  }
+
+  TRACE("[ Calling d-tor %s @ %p for '%s' ]", function_name, function, realpath);
+  function();
+  TRACE("[ Done calling d-tor %s @ %p for '%s' ]", function_name, function, realpath);
+}
+
+template <typename F>
+static void call_array(const char* array_name __unused,
+                       F* functions,
+                       size_t count,
+                       bool reverse,
+                       const char* realpath) {
+  if (functions == nullptr) {
+    return;
+  }
+
+  TRACE("[ Calling %s (size %zd) @ %p for '%s' ]", array_name, count, functions, realpath);
+
+  int begin = reverse ? (count - 1) : 0;
+  int end = reverse ? -1 : count;
+  int step = reverse ? -1 : 1;
+
+  for (int i = begin; i != end; i += step) {
+    TRACE("[ %s[%d] == %p ]", array_name, i, functions[i]);
+    call_function("function", functions[i], realpath);
+  }
+
+  TRACE("[ Done calling %s for '%s' ]", array_name, realpath);
+}
+
+void soinfo::call_pre_init_constructors() {
+  // DT_PREINIT_ARRAY functions are called before any other constructors for executables,
+  // but ignored in a shared library.
+  call_array("DT_PREINIT_ARRAY", preinit_array_, preinit_array_count_, false, get_realpath());
+}
+
+void soinfo::call_constructors() {
+  if (constructors_called) {
+    return;
+  }
+
+  // We set constructors_called before actually calling the constructors, otherwise it doesn't
+  // protect against recursive constructor calls. One simple example of constructor recursion
+  // is the libc debug malloc, which is implemented in libc_malloc_debug_leak.so:
+  // 1. The program depends on libc, so libc's constructor is called here.
+  // 2. The libc constructor calls dlopen() to load libc_malloc_debug_leak.so.
+  // 3. dlopen() calls the constructors on the newly created
+  //    soinfo for libc_malloc_debug_leak.so.
+  // 4. The debug .so depends on libc, so CallConstructors is
+  //    called again with the libc soinfo. If it doesn't trigger the early-
+  //    out above, the libc constructor will be called again (recursively!).
+  constructors_called = true;
+
+  if (!is_main_executable() && preinit_array_ != nullptr) {
+    // The GNU dynamic linker silently ignores these, but we warn the developer.
+    PRINT("\"%s\": ignoring DT_PREINIT_ARRAY in shared library!", get_realpath());
+  }
+
+  get_children().for_each([] (soinfo* si) {
+    si->call_constructors();
+  });
+
+  TRACE("\"%s\": calling constructors", get_realpath());
+
+  // DT_INIT should be called before DT_INIT_ARRAY if both are present.
+  call_function("DT_INIT", init_func_, get_realpath());
+  call_array("DT_INIT_ARRAY", init_array_, init_array_count_, false, get_realpath());
+}
+
+void soinfo::call_destructors() {
+  if (!constructors_called) {
+    return;
+  }
+  TRACE("\"%s\": calling destructors", get_realpath());
+
+  // DT_FINI_ARRAY must be parsed in reverse order.
+  call_array("DT_FINI_ARRAY", fini_array_, fini_array_count_, true, get_realpath());
+
+  // DT_FINI should be called after DT_FINI_ARRAY if both are present.
+  call_function("DT_FINI", fini_func_, get_realpath());
+}
+
+void soinfo::add_child(soinfo* child) {
+  if (has_min_version(0)) {
+    child->parents_.push_back(this);
+    this->children_.push_back(child);
+  }
+}
+
+void soinfo::remove_all_links() {
+  if (!has_min_version(0)) {
+    return;
+  }
+
+  // 1. Untie connected soinfos from 'this'.
+  children_.for_each([&] (soinfo* child) {
+    child->parents_.remove_if([&] (const soinfo* parent) {
+      return parent == this;
+    });
+  });
+
+  parents_.for_each([&] (soinfo* parent) {
+    parent->children_.remove_if([&] (const soinfo* child) {
+      return child == this;
+    });
+  });
+
+  // 2. Remove from the primary namespace
+  primary_namespace_->remove_soinfo(this);
+  primary_namespace_ = nullptr;
+
+  // 3. Remove from secondary namespaces
+  secondary_namespaces_.for_each([&](android_namespace_t* ns) {
+    ns->remove_soinfo(this);
+  });
+
+
+  // 4. Once everything untied - clear local lists.
+  parents_.clear();
+  children_.clear();
+  secondary_namespaces_.clear();
+}
+
+dev_t soinfo::get_st_dev() const {
+  if (has_min_version(0)) {
+    return st_dev_;
+  }
+
+  return 0;
+};
+
+ino_t soinfo::get_st_ino() const {
+  if (has_min_version(0)) {
+    return st_ino_;
+  }
+
+  return 0;
+}
+
+off64_t soinfo::get_file_offset() const {
+  if (has_min_version(1)) {
+    return file_offset_;
+  }
+
+  return 0;
+}
+
+uint32_t soinfo::get_rtld_flags() const {
+  if (has_min_version(1)) {
+    return rtld_flags_;
+  }
+
+  return 0;
+}
+
+uint32_t soinfo::get_dt_flags_1() const {
+  if (has_min_version(1)) {
+    return dt_flags_1_;
+  }
+
+  return 0;
+}
+
+void soinfo::set_dt_flags_1(uint32_t dt_flags_1) {
+  if (has_min_version(1)) {
+    if ((dt_flags_1 & DF_1_GLOBAL) != 0) {
+      rtld_flags_ |= RTLD_GLOBAL;
+    }
+
+    if ((dt_flags_1 & DF_1_NODELETE) != 0) {
+      rtld_flags_ |= RTLD_NODELETE;
+    }
+
+    dt_flags_1_ = dt_flags_1;
+  }
+}
+
+void soinfo::set_nodelete() {
+  rtld_flags_ |= RTLD_NODELETE;
+}
+
+const char* soinfo::get_realpath() const {
+#if defined(__work_around_b_24465209__)
+  if (has_min_version(2)) {
+    return realpath_.c_str();
+  } else {
+    return old_name_;
+  }
+#else
+  return realpath_.c_str();
+#endif
+}
+
+void soinfo::set_soname(const char* soname) {
+#if defined(__work_around_b_24465209__)
+  if (has_min_version(2)) {
+    soname_ = soname;
+  }
+  strlcpy(old_name_, soname_, sizeof(old_name_));
+#else
+  soname_ = soname;
+#endif
+}
+
+const char* soinfo::get_soname() const {
+#if defined(__work_around_b_24465209__)
+  if (has_min_version(2)) {
+    return soname_;
+  } else {
+    return old_name_;
+  }
+#else
+  return soname_;
+#endif
+}
+
+// This is a return on get_children()/get_parents() if
+// 'this->flags' does not have FLAG_NEW_SOINFO set.
+static soinfo_list_t g_empty_list;
+
+soinfo_list_t& soinfo::get_children() {
+  if (has_min_version(0)) {
+    return children_;
+  }
+
+  return g_empty_list;
+}
+
+const soinfo_list_t& soinfo::get_children() const {
+  if (has_min_version(0)) {
+    return children_;
+  }
+
+  return g_empty_list;
+}
+
+soinfo_list_t& soinfo::get_parents() {
+  if (has_min_version(0)) {
+    return parents_;
+  }
+
+  return g_empty_list;
+}
+
+static std::vector<std::string> g_empty_runpath;
+
+const std::vector<std::string>& soinfo::get_dt_runpath() const {
+  if (has_min_version(3)) {
+    return dt_runpath_;
+  }
+
+  return g_empty_runpath;
+}
+
+android_namespace_t* soinfo::get_primary_namespace() {
+  if (has_min_version(3)) {
+    return primary_namespace_;
+  }
+
+  return &g_default_namespace;
+}
+
+void soinfo::add_secondary_namespace(android_namespace_t* secondary_ns) {
+  CHECK(has_min_version(3));
+  secondary_namespaces_.push_back(secondary_ns);
+}
+
+ElfW(Addr) soinfo::resolve_symbol_address(const ElfW(Sym)* s) const {
+  if (ELF_ST_TYPE(s->st_info) == STT_GNU_IFUNC) {
+    return call_ifunc_resolver(s->st_value + load_bias);
+  }
+
+  return static_cast<ElfW(Addr)>(s->st_value + load_bias);
+}
+
+const char* soinfo::get_string(ElfW(Word) index) const {
+  if (has_min_version(1) && (index >= strtab_size_)) {
+    __libc_fatal("%s: strtab out of bounds error; STRSZ=%zd, name=%d",
+        get_realpath(), strtab_size_, index);
+  }
+
+  return strtab_ + index;
+}
+
+bool soinfo::is_gnu_hash() const {
+  return (flags_ & FLAG_GNU_HASH) != 0;
+}
+
+bool soinfo::can_unload() const {
+  return !is_linked() || ((get_rtld_flags() & (RTLD_NODELETE | RTLD_GLOBAL)) == 0);
+}
+
+bool soinfo::is_linked() const {
+  return (flags_ & FLAG_LINKED) != 0;
+}
+
+bool soinfo::is_main_executable() const {
+  return (flags_ & FLAG_EXE) != 0;
+}
+
+bool soinfo::is_linker() const {
+  return (flags_ & FLAG_LINKER) != 0;
+}
+
+void soinfo::set_linked() {
+  flags_ |= FLAG_LINKED;
+}
+
+void soinfo::set_linker_flag() {
+  flags_ |= FLAG_LINKER;
+}
+
+void soinfo::set_main_executable() {
+  flags_ |= FLAG_EXE;
+}
+
+void soinfo::increment_ref_count() {
+  local_group_root_->ref_count_++;
+}
+
+size_t soinfo::decrement_ref_count() {
+  return --local_group_root_->ref_count_;
+}
+
+soinfo* soinfo::get_local_group_root() const {
+  return local_group_root_;
+}
+
+
+void soinfo::set_mapped_by_caller(bool mapped_by_caller) {
+  if (mapped_by_caller) {
+    flags_ |= FLAG_MAPPED_BY_CALLER;
+  } else {
+    flags_ &= ~FLAG_MAPPED_BY_CALLER;
+  }
+}
+
+bool soinfo::is_mapped_by_caller() const {
+  return (flags_ & FLAG_MAPPED_BY_CALLER) != 0;
+}
+
+// This function returns api-level at the time of
+// dlopen/load. Note that libraries opened by system
+// will always have 'current' api level.
+uint32_t soinfo::get_target_sdk_version() const {
+  if (!has_min_version(2)) {
+    return __ANDROID_API__;
+  }
+
+  return local_group_root_->target_sdk_version_;
+}
+
+uintptr_t soinfo::get_handle() const {
+  CHECK(has_min_version(3));
+  CHECK(handle_ != 0);
+  return handle_;
+}
+
+void* soinfo::to_handle() {
+  if (get_application_target_sdk_version() <= 23 || !has_min_version(3)) {
+    return this;
+  }
+
+  return reinterpret_cast<void*>(get_handle());
+}
+
+void soinfo::generate_handle() {
+  CHECK(has_min_version(3));
+  CHECK(handle_ == 0); // Make sure this is the first call
+
+  // Make sure the handle is unique and does not collide
+  // with special values which are RTLD_DEFAULT and RTLD_NEXT.
+  do {
+    arc4random_buf(&handle_, sizeof(handle_));
+    // the least significant bit for the handle is always 1
+    // making it easy to test the type of handle passed to
+    // dl* functions.
+    handle_ = handle_ | 1;
+  } while (handle_ == reinterpret_cast<uintptr_t>(RTLD_DEFAULT) ||
+           handle_ == reinterpret_cast<uintptr_t>(RTLD_NEXT) ||
+           g_soinfo_handles_map.find(handle_) != g_soinfo_handles_map.end());
+
+  g_soinfo_handles_map[handle_] = this;
+}
+
+// TODO(dimitry): Move SymbolName methods to a separate file.
+
+uint32_t calculate_elf_hash(const char* name) {
+  const uint8_t* name_bytes = reinterpret_cast<const uint8_t*>(name);
+  uint32_t h = 0, g;
+
+  while (*name_bytes) {
+    h = (h << 4) + *name_bytes++;
+    g = h & 0xf0000000;
+    h ^= g;
+    h ^= g >> 24;
+  }
+
+  return h;
+}
+
+uint32_t SymbolName::elf_hash() {
+  if (!has_elf_hash_) {
+    elf_hash_ = calculate_elf_hash(name_);
+    has_elf_hash_ = true;
+  }
+
+  return elf_hash_;
+}
+
+uint32_t SymbolName::gnu_hash() {
+  if (!has_gnu_hash_) {
+    uint32_t h = 5381;
+    const uint8_t* name = reinterpret_cast<const uint8_t*>(name_);
+    while (*name != 0) {
+      h += (h << 5) + *name++; // h*33 + c = h + h * 32 + c = h + h << 5 + c
+    }
+
+    gnu_hash_ =  h;
+    has_gnu_hash_ = true;
+  }
+
+  return gnu_hash_;
+}
+
+
diff --git a/linker/linker_soinfo.h b/linker/linker_soinfo.h
new file mode 100644
index 0000000..a0fe9e2
--- /dev/null
+++ b/linker/linker_soinfo.h
@@ -0,0 +1,356 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_SOINFO_H
+#define __LINKER_SOINFO_H
+
+#include <link.h>
+
+#include <string>
+
+#include "linker_namespaces.h"
+
+#define FLAG_LINKED           0x00000001
+#define FLAG_EXE              0x00000004 // The main executable
+#define FLAG_LINKER           0x00000010 // The linker itself
+#define FLAG_GNU_HASH         0x00000040 // uses gnu hash
+#define FLAG_MAPPED_BY_CALLER 0x00000080 // the map is reserved by the caller
+                                         // and should not be unmapped
+#define FLAG_NEW_SOINFO       0x40000000 // new soinfo format
+
+#define SOINFO_VERSION 3
+
+typedef void (*linker_dtor_function_t)();
+typedef void (*linker_ctor_function_t)(int, char**, char**);
+
+class SymbolName {
+ public:
+  explicit SymbolName(const char* name)
+      : name_(name), has_elf_hash_(false), has_gnu_hash_(false),
+        elf_hash_(0), gnu_hash_(0) { }
+
+  const char* get_name() {
+    return name_;
+  }
+
+  uint32_t elf_hash();
+  uint32_t gnu_hash();
+
+ private:
+  const char* name_;
+  bool has_elf_hash_;
+  bool has_gnu_hash_;
+  uint32_t elf_hash_;
+  uint32_t gnu_hash_;
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolName);
+};
+
+struct version_info {
+  constexpr version_info() : elf_hash(0), name(nullptr), target_si(nullptr) {}
+
+  uint32_t elf_hash;
+  const char* name;
+  const soinfo* target_si;
+};
+
+// TODO(dimitry): remove reference from soinfo member functions to this class.
+class VersionTracker;
+
+#if defined(__work_around_b_24465209__)
+#define SOINFO_NAME_LEN 128
+#endif
+
+struct soinfo {
+#if defined(__work_around_b_24465209__)
+ private:
+  char old_name_[SOINFO_NAME_LEN];
+#endif
+ public:
+  const ElfW(Phdr)* phdr;
+  size_t phnum;
+#if defined(__work_around_b_24465209__)
+  ElfW(Addr) unused0; // DO NOT USE, maintained for compatibility.
+#endif
+  ElfW(Addr) base;
+  size_t size;
+
+#if defined(__work_around_b_24465209__)
+  uint32_t unused1;  // DO NOT USE, maintained for compatibility.
+#endif
+
+  ElfW(Dyn)* dynamic;
+
+#if defined(__work_around_b_24465209__)
+  uint32_t unused2; // DO NOT USE, maintained for compatibility
+  uint32_t unused3; // DO NOT USE, maintained for compatibility
+#endif
+
+  soinfo* next;
+ private:
+  uint32_t flags_;
+
+  const char* strtab_;
+  ElfW(Sym)* symtab_;
+
+  size_t nbucket_;
+  size_t nchain_;
+  uint32_t* bucket_;
+  uint32_t* chain_;
+
+#if defined(__mips__) || !defined(__LP64__)
+  // This is only used by mips and mips64, but needs to be here for
+  // all 32-bit architectures to preserve binary compatibility.
+  ElfW(Addr)** plt_got_;
+#endif
+
+#if defined(USE_RELA)
+  ElfW(Rela)* plt_rela_;
+  size_t plt_rela_count_;
+
+  ElfW(Rela)* rela_;
+  size_t rela_count_;
+#else
+  ElfW(Rel)* plt_rel_;
+  size_t plt_rel_count_;
+
+  ElfW(Rel)* rel_;
+  size_t rel_count_;
+#endif
+
+  linker_ctor_function_t* preinit_array_;
+  size_t preinit_array_count_;
+
+  linker_ctor_function_t* init_array_;
+  size_t init_array_count_;
+  linker_dtor_function_t* fini_array_;
+  size_t fini_array_count_;
+
+  linker_ctor_function_t init_func_;
+  linker_dtor_function_t fini_func_;
+
+#if defined(__arm__)
+ public:
+  // ARM EABI section used for stack unwinding.
+  uint32_t* ARM_exidx;
+  size_t ARM_exidx_count;
+ private:
+#elif defined(__mips__)
+  uint32_t mips_symtabno_;
+  uint32_t mips_local_gotno_;
+  uint32_t mips_gotsym_;
+  bool mips_relocate_got(const VersionTracker& version_tracker,
+                         const soinfo_list_t& global_group,
+                         const soinfo_list_t& local_group);
+#if !defined(__LP64__)
+  bool mips_check_and_adjust_fp_modes();
+#endif
+#endif
+  size_t ref_count_;
+ public:
+  link_map link_map_head;
+
+  bool constructors_called;
+
+  // When you read a virtual address from the ELF file, add this
+  // value to get the corresponding address in the process' address space.
+  ElfW(Addr) load_bias;
+
+#if !defined(__LP64__)
+  bool has_text_relocations;
+#endif
+  bool has_DT_SYMBOLIC;
+
+ public:
+  soinfo(android_namespace_t* ns, const char* name, const struct stat* file_stat,
+         off64_t file_offset, int rtld_flags);
+  ~soinfo();
+
+  void call_constructors();
+  void call_destructors();
+  void call_pre_init_constructors();
+  bool prelink_image();
+  bool link_image(const soinfo_list_t& global_group, const soinfo_list_t& local_group,
+                  const android_dlextinfo* extinfo);
+  bool protect_relro();
+
+  void add_child(soinfo* child);
+  void remove_all_links();
+
+  ino_t get_st_ino() const;
+  dev_t get_st_dev() const;
+  off64_t get_file_offset() const;
+
+  uint32_t get_rtld_flags() const;
+  uint32_t get_dt_flags_1() const;
+  void set_dt_flags_1(uint32_t dt_flags_1);
+
+  soinfo_list_t& get_children();
+  const soinfo_list_t& get_children() const;
+
+  soinfo_list_t& get_parents();
+
+  bool find_symbol_by_name(SymbolName& symbol_name,
+                           const version_info* vi,
+                           const ElfW(Sym)** symbol) const;
+
+  ElfW(Sym)* find_symbol_by_address(const void* addr);
+  ElfW(Addr) resolve_symbol_address(const ElfW(Sym)* s) const;
+
+  const char* get_string(ElfW(Word) index) const;
+  bool can_unload() const;
+  bool is_gnu_hash() const;
+
+  bool inline has_min_version(uint32_t min_version __unused) const {
+#if defined(__work_around_b_24465209__)
+    return (flags_ & FLAG_NEW_SOINFO) != 0 && version_ >= min_version;
+#else
+    return true;
+#endif
+  }
+
+  bool is_linked() const;
+  bool is_linker() const;
+  bool is_main_executable() const;
+
+  void set_linked();
+  void set_linker_flag();
+  void set_main_executable();
+  void set_nodelete();
+
+  void increment_ref_count();
+  size_t decrement_ref_count();
+
+  soinfo* get_local_group_root() const;
+
+  void set_soname(const char* soname);
+  const char* get_soname() const;
+  const char* get_realpath() const;
+  const ElfW(Versym)* get_versym(size_t n) const;
+  ElfW(Addr) get_verneed_ptr() const;
+  size_t get_verneed_cnt() const;
+  ElfW(Addr) get_verdef_ptr() const;
+  size_t get_verdef_cnt() const;
+
+  uint32_t get_target_sdk_version() const;
+
+  void set_dt_runpath(const char *);
+  const std::vector<std::string>& get_dt_runpath() const;
+  android_namespace_t* get_primary_namespace();
+  void add_secondary_namespace(android_namespace_t* secondary_ns);
+
+  void set_mapped_by_caller(bool reserved_map);
+  bool is_mapped_by_caller() const;
+
+  uintptr_t get_handle() const;
+  void generate_handle();
+  void* to_handle();
+
+ private:
+  bool elf_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
+  ElfW(Sym)* elf_addr_lookup(const void* addr);
+  bool gnu_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
+  ElfW(Sym)* gnu_addr_lookup(const void* addr);
+
+  bool lookup_version_info(const VersionTracker& version_tracker, ElfW(Word) sym,
+                           const char* sym_name, const version_info** vi);
+
+  template<typename ElfRelIteratorT>
+  bool relocate(const VersionTracker& version_tracker, ElfRelIteratorT&& rel_iterator,
+                const soinfo_list_t& global_group, const soinfo_list_t& local_group);
+
+ private:
+  // This part of the structure is only available
+  // when FLAG_NEW_SOINFO is set in this->flags.
+  uint32_t version_;
+
+  // version >= 0
+  dev_t st_dev_;
+  ino_t st_ino_;
+
+  // dependency graph
+  soinfo_list_t children_;
+  soinfo_list_t parents_;
+
+  // version >= 1
+  off64_t file_offset_;
+  uint32_t rtld_flags_;
+  uint32_t dt_flags_1_;
+  size_t strtab_size_;
+
+  // version >= 2
+
+  size_t gnu_nbucket_;
+  uint32_t* gnu_bucket_;
+  uint32_t* gnu_chain_;
+  uint32_t gnu_maskwords_;
+  uint32_t gnu_shift2_;
+  ElfW(Addr)* gnu_bloom_filter_;
+
+  soinfo* local_group_root_;
+
+  uint8_t* android_relocs_;
+  size_t android_relocs_size_;
+
+  const char* soname_;
+  std::string realpath_;
+
+  const ElfW(Versym)* versym_;
+
+  ElfW(Addr) verdef_ptr_;
+  size_t verdef_cnt_;
+
+  ElfW(Addr) verneed_ptr_;
+  size_t verneed_cnt_;
+
+  uint32_t target_sdk_version_;
+
+  // version >= 3
+  std::vector<std::string> dt_runpath_;
+  android_namespace_t* primary_namespace_;
+  android_namespace_list_t secondary_namespaces_;
+  uintptr_t handle_;
+
+  friend soinfo* get_libdl_info();
+};
+
+// This function is used by dlvsym() to calculate hash of sym_ver
+uint32_t calculate_elf_hash(const char* name);
+
+const char* fix_dt_needed(const char* dt_needed, const char* sopath);
+
+template<typename F>
+void for_each_dt_needed(const soinfo* si, F action) {
+  for (const ElfW(Dyn)* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
+    if (d->d_tag == DT_NEEDED) {
+      action(fix_dt_needed(si->get_string(d->d_un.d_val), si->get_realpath()));
+    }
+  }
+}
+
+#endif  /* __LINKER_SOINFO_H */
diff --git a/linker/linker_utils.cpp b/linker/linker_utils.cpp
index fb070ee..05ac687 100644
--- a/linker/linker_utils.cpp
+++ b/linker/linker_utils.cpp
@@ -15,7 +15,26 @@
  */
 
 #include "linker_utils.h"
+
 #include "linker_debug.h"
+#include "linker_globals.h"
+
+#include "android-base/strings.h"
+
+#include <sys/stat.h>
+#include <unistd.h>
+
+std::string dirname(const char* path) {
+  const char* last_slash = strrchr(path, '/');
+
+  if (last_slash == path) {
+    return "/";
+  } else if (last_slash == nullptr) {
+    return ".";
+  } else {
+    return std::string(path, last_slash - path);
+  }
+}
 
 bool normalize_path(const char* path, std::string* normalized_path) {
   // Input should be an absolute path
@@ -134,3 +153,57 @@
   return static_cast<size_t>(offset & (PAGE_SIZE-1));
 }
 
+void split_path(const char* path, const char* delimiters,
+                std::vector<std::string>* paths) {
+  if (path != nullptr && path[0] != 0) {
+    *paths = android::base::Split(path, delimiters);
+  }
+}
+
+void resolve_paths(std::vector<std::string>& paths,
+                   std::vector<std::string>* resolved_paths) {
+  resolved_paths->clear();
+  for (const auto& path : paths) {
+    // skip empty paths
+    if (path.empty()) {
+      continue;
+    }
+
+    char resolved_path[PATH_MAX];
+    const char* original_path = path.c_str();
+    if (realpath(original_path, resolved_path) != nullptr) {
+      struct stat s;
+      if (stat(resolved_path, &s) == 0) {
+        if (S_ISDIR(s.st_mode)) {
+          resolved_paths->push_back(resolved_path);
+        } else {
+          DL_WARN("Warning: \"%s\" is not a directory (excluding from path)", resolved_path);
+          continue;
+        }
+      } else {
+        DL_WARN("Warning: cannot stat file \"%s\": %s", resolved_path, strerror(errno));
+        continue;
+      }
+    } else {
+      std::string zip_path;
+      std::string entry_path;
+
+      std::string normalized_path;
+
+      if (!normalize_path(original_path, &normalized_path)) {
+        DL_WARN("Warning: unable to normalize \"%s\"", original_path);
+        continue;
+      }
+
+      if (parse_zip_path(normalized_path.c_str(), &zip_path, &entry_path)) {
+        if (realpath(zip_path.c_str(), resolved_path) == nullptr) {
+          DL_WARN("Warning: unable to resolve \"%s\": %s", zip_path.c_str(), strerror(errno));
+          continue;
+        }
+
+        resolved_paths->push_back(std::string(resolved_path) + kZipFileSeparator + entry_path);
+      }
+    }
+  }
+}
+
diff --git a/linker/linker_utils.h b/linker/linker_utils.h
index 987eabd..2e015a5 100644
--- a/linker/linker_utils.h
+++ b/linker/linker_utils.h
@@ -17,14 +17,25 @@
 #define __LINKER_UTILS_H
 
 #include <string>
+#include <vector>
 
 extern const char* const kZipFileSeparator;
 
-bool normalize_path(const char* path, std::string* normalized_path);
 bool file_is_in_dir(const std::string& file, const std::string& dir);
 bool file_is_under_dir(const std::string& file, const std::string& dir);
+bool normalize_path(const char* path, std::string* normalized_path);
 bool parse_zip_path(const char* input_path, std::string* zip_path, std::string* entry_path);
 
+// For every path element this function checks of it exists, and is a directory,
+// and normalizes it:
+// 1. For regular path it converts it to realpath()
+// 2. For path in a zip file it uses realpath on the zipfile
+//    normalizes entry name by calling normalize_path function.
+void resolve_paths(std::vector<std::string>& paths, std::vector<std::string>* resolved_paths);
+void split_path(const char* path, const char* delimiters, std::vector<std::string>* paths);
+
+std::string dirname(const char* path);
+
 off64_t page_start(off64_t offset);
 size_t page_offset(off64_t offset);
 bool safe_add(off64_t* out, off64_t a, size_t b);
diff --git a/linker/tests/Android.mk b/linker/tests/Android.mk
index a061877..d5b57f1 100644
--- a/linker/tests/Android.mk
+++ b/linker/tests/Android.mk
@@ -27,16 +27,19 @@
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../libc/
 
 LOCAL_SRC_FILES := \
+  linker_block_allocator_test.cpp \
   linker_globals.cpp \
   linked_list_test.cpp \
-  linker_block_allocator_test.cpp \
-  ../linker_block_allocator.cpp \
   linker_memory_allocator_test.cpp \
-  ../linker_allocator.cpp \
+  linker_sleb128_test.cpp \
   linker_utils_test.cpp \
+  ../linker_allocator.cpp \
+  ../linker_block_allocator.cpp \
   ../linker_utils.cpp
 
 # for __libc_fatal
 LOCAL_SRC_FILES += ../../libc/bionic/libc_logging.cpp
 
+LOCAL_STATIC_LIBRARIES += libbase
+
 include $(BUILD_NATIVE_TEST)
diff --git a/linker/tests/linker_sleb128_test.cpp b/linker/tests/linker_sleb128_test.cpp
new file mode 100644
index 0000000..4e29bca
--- /dev/null
+++ b/linker/tests/linker_sleb128_test.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#include <gtest/gtest.h>
+
+#include "../linker_sleb128.h"
+
+TEST(linker_sleb128, smoke) {
+  std::vector<uint8_t> encoding;
+  // 624485
+  encoding.push_back(0xe5);
+  encoding.push_back(0x8e);
+  encoding.push_back(0x26);
+  // 0
+  encoding.push_back(0x00);
+  // 1
+  encoding.push_back(0x01);
+  // 63
+  encoding.push_back(0x3f);
+  // 64
+  encoding.push_back(0xc0);
+  encoding.push_back(0x00);
+  // -1
+  encoding.push_back(0x7f);
+  // -624485
+  encoding.push_back(0x9b);
+  encoding.push_back(0xf1);
+  encoding.push_back(0x59);
+  // 2147483647
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0x07);
+  // -2147483648
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x78);
+#if defined(__LP64__)
+  // 9223372036854775807
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0xff);
+  encoding.push_back(0x00);
+  // -9223372036854775808
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x80);
+  encoding.push_back(0x7f);
+#endif
+  sleb128_decoder decoder(&encoding[0], encoding.size());
+
+  EXPECT_EQ(624485U, decoder.pop_front());
+
+  EXPECT_EQ(0U, decoder.pop_front());
+  EXPECT_EQ(1U, decoder.pop_front());
+  EXPECT_EQ(63U, decoder.pop_front());
+  EXPECT_EQ(64U, decoder.pop_front());
+  EXPECT_EQ(static_cast<size_t>(-1), decoder.pop_front());
+  EXPECT_EQ(static_cast<size_t>(-624485), decoder.pop_front());
+  EXPECT_EQ(2147483647U, decoder.pop_front());
+  EXPECT_EQ(static_cast<size_t>(-2147483648), decoder.pop_front());
+#if defined(__LP64__)
+  EXPECT_EQ(9223372036854775807ULL, decoder.pop_front());
+  EXPECT_EQ(static_cast<uint64_t>(-9223372036854775807LL - 1), decoder.pop_front());
+#endif
+}
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..3e1e13b
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,486 @@
+//
+// Copyright (C) 2012 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_defaults {
+    name: "bionic_tests_defaults",
+    host_supported: true,
+    target: {
+        darwin: {
+            enabled: false,
+        },
+    },
+    cflags: [
+        "-fstack-protector-all",
+        "-g",
+        "-Wall",
+        "-Wextra",
+        "-Wunused",
+        "-Werror",
+        "-fno-builtin",
+
+        // We want to test deprecated API too.
+        "-Wno-deprecated-declarations",
+
+        // For glibc.
+        "-D__STDC_LIMIT_MACROS",
+    ],
+    stl: "libc++",
+    sanitize: {
+        never: true,
+    },
+}
+
+// -----------------------------------------------------------------------------
+// All standard tests.
+// -----------------------------------------------------------------------------
+
+cc_test_library {
+    name: "libBionicStandardTests",
+    defaults: ["bionic_tests_defaults"],
+    srcs: [
+        "arpa_inet_test.cpp",
+        "assert_test.cpp",
+        "buffer_tests.cpp",
+        "bug_26110743_test.cpp",
+        "complex_test.cpp",
+        "ctype_test.cpp",
+        "dirent_test.cpp",
+        "error_test.cpp",
+        "eventfd_test.cpp",
+        "fcntl_test.cpp",
+        "fenv_test.cpp",
+        "ftw_test.cpp",
+        "getauxval_test.cpp",
+        "getcwd_test.cpp",
+        "grp_pwd_test.cpp",
+        "ifaddrs_test.cpp",
+        "inttypes_test.cpp",
+        "libc_logging_test.cpp",
+        "libgen_basename_test.cpp",
+        "libgen_test.cpp",
+        "locale_test.cpp",
+        "malloc_test.cpp",
+        "math_test.cpp",
+        "mntent_test.cpp",
+        "netdb_test.cpp",
+        "net_if_test.cpp",
+        "netinet_ether_test.cpp",
+        "netinet_in_test.cpp",
+        "netinet_udp_test.cpp",
+        "nl_types_test.cpp",
+        "pthread_test.cpp",
+        "pty_test.cpp",
+        "regex_test.cpp",
+        "resolv_test.cpp",
+        "sched_test.cpp",
+        "search_test.cpp",
+        "semaphore_test.cpp",
+        "setjmp_test.cpp",
+        "signal_test.cpp",
+        "stack_protector_test.cpp",
+        "stack_protector_test_helper.cpp",
+        "stack_unwinding_test.cpp",
+        "stdatomic_test.cpp",
+        "stdint_test.cpp",
+        "stdio_nofortify_test.cpp",
+        "stdio_test.cpp",
+        "stdio_ext_test.cpp",
+        "stdlib_test.cpp",
+        "string_nofortify_test.cpp",
+        "string_test.cpp",
+        "string_posix_strerror_r_test.cpp",
+        "strings_nofortify_test.cpp",
+        "strings_test.cpp",
+        "sstream_test.cpp",
+        "sys_epoll_test.cpp",
+        "sys_mman_test.cpp",
+        "sys_msg_test.cpp",
+        "sys_personality_test.cpp",
+        "sys_prctl_test.cpp",
+        "sys_procfs_test.cpp",
+        "sys_ptrace_test.cpp",
+        "sys_quota_test.cpp",
+        "sys_resource_test.cpp",
+        "sys_select_test.cpp",
+        "sys_sem_test.cpp",
+        "sys_sendfile_test.cpp",
+        "sys_shm_test.cpp",
+        "sys_socket_test.cpp",
+        "sys_stat_test.cpp",
+        "sys_statvfs_test.cpp",
+        "sys_syscall_test.cpp",
+        "sys_sysinfo_test.cpp",
+        "sys_sysmacros_test.cpp",
+        "sys_time_test.cpp",
+        "sys_timex_test.cpp",
+        "sys_types_test.cpp",
+        "sys_uio_test.cpp",
+        "sys_vfs_test.cpp",
+        "sys_xattr_test.cpp",
+        "system_properties_test.cpp",
+        "time_test.cpp",
+        "uchar_test.cpp",
+        "unistd_nofortify_test.cpp",
+        "unistd_test.cpp",
+        "utmp_test.cpp",
+        "wchar_test.cpp",
+        "wctype_test.cpp",
+    ],
+
+    include_dirs: [
+        "bionic/libc",
+        "external/tinyxml2",
+    ],
+
+    static_libs: [
+        "libtinyxml2",
+        "liblog",
+        "libbase",
+    ],
+    host_ldlibs: ["-lrt"],
+    shared: {
+        enabled: false,
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Fortify tests.
+// -----------------------------------------------------------------------------
+
+cc_defaults {
+    name: "bionic_fortify_tests_defaults",
+    cflags: [
+        "-Wno-error",
+        "-U_FORTIFY_SOURCE",
+    ],
+    srcs: ["fortify_test_main.cpp"],
+    target: {
+        host: {
+            clang_cflags: ["-D__clang__"],
+        },
+    },
+}
+
+cc_test_library {
+    name: "libfortify1-tests-gcc",
+    defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
+    clang: false,
+    cflags: [
+        "-D_FORTIFY_SOURCE=1",
+        "-DTEST_NAME=Fortify1_gcc"
+    ],
+    shared: {
+        enabled: false,
+    },
+}
+
+cc_test_library {
+    name: "libfortify2-tests-gcc",
+    defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
+    clang: false,
+    cflags: [
+        "-D_FORTIFY_SOURCE=2",
+        "-DTEST_NAME=Fortify2_gcc"
+    ],
+    shared: {
+        enabled: false,
+    },
+}
+
+cc_test_library {
+    name: "libfortify1-tests-clang",
+    defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
+    clang: true,
+    cflags: [
+        "-D_FORTIFY_SOURCE=1",
+        "-DTEST_NAME=Fortify1_clang"
+    ],
+    shared: {
+        enabled: false,
+    },
+}
+
+cc_test_library {
+    name: "libfortify2-tests-clang",
+    defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
+    clang: true,
+    cflags: [
+        "-D_FORTIFY_SOURCE=2",
+        "-DTEST_NAME=Fortify2_clang"
+    ],
+    shared: {
+        enabled: false,
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Library of all tests (excluding the dynamic linker tests).
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libBionicTests",
+    defaults: ["bionic_tests_defaults"],
+    whole_static_libs: [
+        "libBionicStandardTests",
+        "libfortify1-tests-gcc",
+        "libfortify2-tests-gcc",
+        "libfortify1-tests-clang",
+        "libfortify2-tests-clang",
+    ],
+    shared: {
+        enabled: false,
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Library of bionic customized gtest main function, with simplified output format.
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libBionicGtestMain",
+    defaults: ["bionic_tests_defaults"],
+    srcs: [
+        "gtest_main.cpp",
+        "gtest_globals.cpp",
+    ],
+    static_libs: [
+        "libbase",
+    ],
+    include_dirs: [
+        "bionic/libc",
+    ],
+    target: {
+        darwin: {
+            enabled: true,
+        },
+    },
+    shared: {
+        enabled: false,
+    },
+}
+
+cc_test_library {
+    name: "libBionicLoaderTests",
+    defaults: ["bionic_tests_defaults"],
+    srcs: [
+        "atexit_test.cpp",
+        "dl_test.cpp",
+        "dlfcn_symlink_support.cpp",
+        "dlfcn_test.cpp",
+        "pthread_dlfcn_test.cpp",
+    ],
+    static_libs: [
+        "libbase",
+    ],
+    include_dirs: [
+        "bionic/libc",
+    ],
+    shared: {
+        enabled: false,
+    },
+    target: {
+        android: {
+            srcs: [
+                "dlext_test.cpp",
+                "libdl_test.cpp",
+            ],
+            static_libs: [
+                "libpagemap",
+            ],
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+// Library of bionic customized gtest main function, with normal gtest output format,
+// which is needed by bionic cts test.
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libBionicCtsGtestMain",
+    defaults: ["bionic_tests_defaults"],
+    srcs: [
+        "gtest_main.cpp",
+        "gtest_globals_cts.cpp",
+    ],
+    cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
+    shared: {
+        enabled: false,
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Tests for the device using bionic's .so. Run with:
+//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
+//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
+//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
+//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
+// -----------------------------------------------------------------------------
+cc_defaults {
+    name: "bionic_unit_tests_defaults",
+    host_supported: false,
+
+    whole_static_libs: [
+        "libBionicTests",
+        "libBionicLoaderTests",
+        "libBionicGtestMain",
+    ],
+
+    static_libs: [
+        "libtinyxml2",
+        "liblog",
+        "libbase",
+    ],
+
+    srcs: [
+        // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
+        "__cxa_thread_atexit_test.cpp",
+        "thread_local_test.cpp",
+    ],
+
+    conlyflags: [
+        "-fexceptions",
+        "-fnon-call-exceptions",
+    ],
+
+    ldflags: ["-Wl,--export-dynamic"],
+
+    include_dirs: ["bionic/libc"],
+
+    target: {
+        android: {
+            shared_libs: [
+                "libdl",
+                "libdl_preempt_test_1",
+                "libdl_preempt_test_2",
+                "libdl_test_df_1_global",
+            ],
+            static_libs: [
+                // The order of these libraries matters, do not shuffle them.
+                "libbase",
+                "libpagemap",
+                "libziparchive",
+                "libz",
+                "libutils",
+            ],
+            ldflags: [
+                "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
+                "-Wl,--enable-new-dtags",
+            ],
+        },
+    }
+}
+
+cc_test {
+    name: "bionic-unit-tests",
+    defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
+    clang: true,
+}
+
+cc_test {
+    name: "bionic-unit-tests-gcc",
+    defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
+    clang: false,
+}
+
+// -----------------------------------------------------------------------------
+// Tests for the device linked against bionic's static library. Run with:
+//   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
+//   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
+// -----------------------------------------------------------------------------
+cc_test {
+    name: "bionic-unit-tests-static",
+    defaults: ["bionic_tests_defaults"],
+    host_supported: false,
+
+    whole_static_libs: [
+        "libBionicTests",
+        "libBionicGtestMain",
+    ],
+
+    static_libs: [
+        "libm",
+        "libc",
+        "libc++_static",
+        "libdl",
+        "libtinyxml2",
+        "liblog",
+        "libbase",
+    ],
+
+    static_executable: true,
+    stl: "libc++_static",
+
+    // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
+    // still causes issues when linking libc.a and libc++.a, since private isn't
+    // effective until it has been linked. To fix this, just allow multiple symbol
+    // definitions for the static tests.
+    ldflags: ["-Wl,--allow-multiple-definition"],
+}
+
+// -----------------------------------------------------------------------------
+// Tests to run on the host and linked against glibc. Run with:
+//   cd bionic/tests; mm bionic-unit-tests-glibc-run
+// -----------------------------------------------------------------------------
+
+cc_test_host {
+    name: "bionic-unit-tests-glibc",
+    defaults: ["bionic_tests_defaults"],
+
+    srcs: [
+        "atexit_test.cpp",
+        "dlfcn_symlink_support.cpp",
+        "dlfcn_test.cpp",
+        "dl_test.cpp",
+        "pthread_dlfcn_test.cpp",
+    ],
+
+    shared_libs: [
+        "libdl_preempt_test_1",
+        "libdl_preempt_test_2",
+
+        "libdl_test_df_1_global",
+    ],
+
+    whole_static_libs: [
+        "libBionicStandardTests",
+        "libBionicGtestMain",
+        "libfortify1-tests-gcc",
+        "libfortify2-tests-gcc",
+        "libfortify1-tests-clang",
+        "libfortify2-tests-clang",
+    ],
+
+    static_libs: [
+        "libbase",
+        "liblog",
+        "libcutils",
+    ],
+
+    host_ldlibs: [
+        "-lresolv",
+        "-lrt",
+        "-ldl",
+        "-lutil",
+    ],
+
+    include_dirs: ["bionic/libc"],
+
+    ldflags: ["-Wl,--export-dynamic"],
+
+    sanitize: {
+        never: false,
+    },
+}
+
+subdirs = ["libs"]
diff --git a/tests/Android.build.mk b/tests/Android.build.mk
index 740c2f4..cce4344 100644
--- a/tests/Android.build.mk
+++ b/tests/Android.build.mk
@@ -28,15 +28,7 @@
     LOCAL_MODULE_STEM_32 := $(module)32
     LOCAL_MODULE_STEM_64 := $(module)64
 else
-
 ifneq ($($(module)_install_to_out_data_dir),)
-  $(module)_install_to_out_data := true
-endif
-
-ifeq ($($(module)_install_to_out_data),true)
-    ifeq ($($(module)_install_to_out_data_dir),)
-      $(module)_install_to_out_data_dir := $(module)
-    endif
     LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$($(module)_install_to_out_data_dir)
     LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$($(module)_install_to_out_data_dir)
 endif
diff --git a/tests/Android.build.prebuilt.mk b/tests/Android.build.prebuilt.mk
new file mode 100644
index 0000000..c98aee2
--- /dev/null
+++ b/tests/Android.build.prebuilt.mk
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include $(CLEAR_VARS)
+LOCAL_MULTILIB := both
+LOCAL_MODULE := $(bionic_tests_module)
+LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/prebuilt-elf-files
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/prebuilt-elf-files
+LOCAL_MODULE_CLASS := EXECUTABLES
+
+LOCAL_SRC_FILES_arm := prebuilt-elf-files/arm/$(bionic_tests_module)
+LOCAL_SRC_FILES_arm64 := prebuilt-elf-files/arm64/$(bionic_tests_module)
+LOCAL_SRC_FILES_x86 := prebuilt-elf-files/x86/$(bionic_tests_module)
+LOCAL_SRC_FILES_x86_64 := prebuilt-elf-files/x86_64/$(bionic_tests_module)
+LOCAL_SRC_FILES_mips := prebuilt-elf-files/mips/$(bionic_tests_module)
+LOCAL_SRC_FILES_mips64 := prebuilt-elf-files/mips64/$(bionic_tests_module)
+include $(BUILD_PREBUILT)
+bionic-loader-test-libs-target: $(LOCAL_MODULE)
diff --git a/tests/Android.mk b/tests/Android.mk
index d39f4d7..b65b456 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -16,9 +16,36 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# -----------------------------------------------------------------------------
-# Unit tests.
-# -----------------------------------------------------------------------------
+# TODO(dimitry): replace with define once https://android-review.googlesource.com/247466 is reverted
+# https://github.com/google/kati/issues/83 is currently blocking it.
+
+# Move prebuilt test elf-files to $(TARGET_OUT_NATIVE_TESTS)
+bionic_tests_module := libtest_invalid-rw_load_segment.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-unaligned_shdr_offset.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-zero_shentsize.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-zero_shstrndx.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-empty_shdr_table.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-zero_shdr_table_offset.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-zero_shdr_table_content.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-textrels.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
+
+bionic_tests_module := libtest_invalid-textrels2.so
+include $(LOCAL_PATH)/Android.build.prebuilt.mk
 
 ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
 build_host := true
@@ -26,414 +53,8 @@
 build_host := false
 endif
 
-common_additional_dependencies := $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
-# All standard tests.
-# -----------------------------------------------------------------------------
-test_cflags = \
-    -fstack-protector-all \
-    -g \
-    -Wall -Wextra -Wunused \
-    -Werror \
-    -fno-builtin \
-
-test_cflags += -D__STDC_LIMIT_MACROS  # For glibc.
-
-test_cppflags := \
-
-libBionicStandardTests_src_files := \
-    arpa_inet_test.cpp \
-    buffer_tests.cpp \
-    bug_26110743_test.cpp \
-    complex_test.cpp \
-    ctype_test.cpp \
-    dirent_test.cpp \
-    error_test.cpp \
-    eventfd_test.cpp \
-    fcntl_test.cpp \
-    fenv_test.cpp \
-    ftw_test.cpp \
-    getauxval_test.cpp \
-    getcwd_test.cpp \
-    ifaddrs_test.cpp \
-    inttypes_test.cpp \
-    libc_logging_test.cpp \
-    libgen_basename_test.cpp \
-    libgen_test.cpp \
-    locale_test.cpp \
-    malloc_test.cpp \
-    math_test.cpp \
-    mntent_test.cpp \
-    netdb_test.cpp \
-    net_if_test.cpp \
-    netinet_in_test.cpp \
-    netinet_udp_test.cpp \
-    pthread_test.cpp \
-    pty_test.cpp \
-    regex_test.cpp \
-    sched_test.cpp \
-    search_test.cpp \
-    semaphore_test.cpp \
-    setjmp_test.cpp \
-    signal_test.cpp \
-    stack_protector_test.cpp \
-    stack_protector_test_helper.cpp \
-    stack_unwinding_test.cpp \
-    stdatomic_test.cpp \
-    stdint_test.cpp \
-    stdio_nofortify_test.cpp \
-    stdio_test.cpp \
-    stdio_ext_test.cpp \
-    stdlib_test.cpp \
-    string_nofortify_test.cpp \
-    string_test.cpp \
-    string_posix_strerror_r_test.cpp \
-    strings_nofortify_test.cpp \
-    strings_test.cpp \
-    stubs_test.cpp \
-    sstream_test.cpp \
-    sys_epoll_test.cpp \
-    sys_mman_test.cpp \
-    sys_personality_test.cpp \
-    sys_prctl_test.cpp \
-    sys_procfs_test.cpp \
-    sys_resource_test.cpp \
-    sys_select_test.cpp \
-    sys_sendfile_test.cpp \
-    sys_socket_test.cpp \
-    sys_stat_test.cpp \
-    sys_statvfs_test.cpp \
-    sys_syscall_test.cpp \
-    sys_sysinfo_test.cpp \
-    sys_sysmacros_test.cpp \
-    sys_time_test.cpp \
-    sys_timex_test.cpp \
-    sys_types_test.cpp \
-    sys_uio_test.cpp \
-    sys_vfs_test.cpp \
-    sys_xattr_test.cpp \
-    system_properties_test.cpp \
-    time_test.cpp \
-    uchar_test.cpp \
-    uniqueptr_test.cpp \
-    unistd_nofortify_test.cpp \
-    unistd_test.cpp \
-    utmp_test.cpp \
-    wchar_test.cpp \
-
-libBionicStandardTests_cflags := \
-    $(test_cflags) \
-
-libBionicStandardTests_cppflags := \
-    $(test_cppflags) \
-
-libBionicStandardTests_c_includes := \
-    bionic/libc \
-    external/tinyxml2 \
-
-libBionicStandardTests_static_libraries := \
-    libbase \
-
-libBionicStandardTests_ldlibs_host := \
-    -lrt \
-
-# Clang/llvm has incompatible long double (fp128) for x86_64.
-# https://llvm.org/bugs/show_bug.cgi?id=23897
-# This affects most of math_test.cpp.
-ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86_64))
-libBionicStandardTests_clang_target := false
-endif
-
-module := libBionicStandardTests
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-include $(LOCAL_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
-# Fortify tests.
-# -----------------------------------------------------------------------------
-$(foreach compiler,gcc clang, \
-  $(foreach test,1 2, \
-    $(eval fortify$(test)-tests-$(compiler)_cflags := \
-      $(test_cflags) \
-      -Wno-error \
-      -U_FORTIFY_SOURCE \
-      -D_FORTIFY_SOURCE=$(test) \
-      -DTEST_NAME=Fortify$(test)_$(compiler)); \
-    $(eval fortify$(test)-tests-$(compiler)_src_files := \
-      fortify_test_main.cpp); \
-    $(eval fortify_libs += fortify$(test)-tests-$(compiler)); \
-  ) \
-)
-
-fortify1-tests-gcc_clang_target := false
-module := fortify1-tests-gcc
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-include $(LOCAL_PATH)/Android.build.mk
-
-fortify2-tests-gcc_clang_target := false
-module := fortify2-tests-gcc
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-include $(LOCAL_PATH)/Android.build.mk
-
-fortify1-tests-clang_clang_target := true
-fortify1-tests-clang_cflags_host := -D__clang__
-
-module := fortify1-tests-clang
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-include $(LOCAL_PATH)/Android.build.mk
-
-fortify2-tests-clang_clang_target := true
-
-fortify2-tests-clang_cflags_host := -D__clang__
-
-module := fortify2-tests-clang
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-include $(LOCAL_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
-# Library of all tests (excluding the dynamic linker tests).
-# -----------------------------------------------------------------------------
-libBionicTests_whole_static_libraries := \
-    libBionicStandardTests \
-    $(fortify_libs) \
-
-module := libBionicTests
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-include $(LOCAL_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
-# Library of bionic customized gtest main function, with simplified output format.
-# -----------------------------------------------------------------------------
-libBionicGtestMain_src_files := gtest_main.cpp
-
-libBionicGtestMain_cflags := $(test_cflags)
-
-libBionicGtestMain_cppflags := $(test_cppflags)
-
-module := libBionicGtestMain
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-
-ifeq ($(HOST_OS),$(filter $(HOST_OS),linux darwin))
-saved_build_host := $(build_host)
-build_host := true
-include $(LOCAL_PATH)/Android.build.mk
-build_host := $(saved_build_host)
-endif
-
-# -----------------------------------------------------------------------------
-# Library of bionic customized gtest main function, with normal gtest output format,
-# which is needed by bionic cts test.
-# -----------------------------------------------------------------------------
-libBionicCtsGtestMain_src_files := gtest_main.cpp
-
-libBionicCtsGtestMain_cflags := $(test_cflags)
-
-libBionicCtsGtestMain_cppflags := $(test_cppflags) -DUSING_GTEST_OUTPUT_FORMAT \
-
-module := libBionicCtsGtestMain
-module_tag := optional
-build_type := target
-build_target := STATIC_TEST_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-include $(LOCAL_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
-# Tests for the device using bionic's .so. Run with:
-#   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
-#   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
-#   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
-#   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
-# -----------------------------------------------------------------------------
-common_bionic-unit-tests_whole_static_libraries := \
-    libBionicTests \
-    libBionicGtestMain \
-
-common_bionic-unit-tests_static_libraries := \
-    libtinyxml2 \
-    liblog \
-    libbase \
-
-# TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
-common_bionic-unit-tests_src_files := \
-    atexit_test.cpp \
-    dl_test.cpp \
-    dlext_test.cpp \
-    __cxa_thread_atexit_test.cpp \
-    dlfcn_test.cpp \
-    libdl_test.cpp \
-    pthread_dlfcn_test.cpp \
-    thread_local_test.cpp \
-
-common_bionic-unit-tests_cflags := $(test_cflags)
-
-common_bionic-unit-tests_conlyflags := \
-    -fexceptions \
-    -fnon-call-exceptions \
-
-common_bionic-unit-tests_cppflags := $(test_cppflags)
-
-common_bionic-unit-tests_ldflags := \
-    -Wl,--export-dynamic
-
-common_bionic-unit-tests_c_includes := \
-    bionic/libc \
-
-common_bionic-unit-tests_shared_libraries_target := \
-    libdl \
-    libpagemap \
-    libdl_preempt_test_1 \
-    libdl_preempt_test_2 \
-    libdl_test_df_1_global \
-
-# The order of these libraries matters, do not shuffle them.
-common_bionic-unit-tests_static_libraries_target := \
-    libbase \
-    libziparchive \
-    liblog \
-    libz \
-    libutils \
-
-module_tag := optional
-build_type := target
-build_target := NATIVE_TEST
-
-module := bionic-unit-tests
-bionic-unit-tests_clang_target := true
-bionic-unit-tests_whole_static_libraries := $(common_bionic-unit-tests_whole_static_libraries)
-bionic-unit-tests_static_libraries := $(common_bionic-unit-tests_static_libraries)
-bionic-unit-tests_src_files := $(common_bionic-unit-tests_src_files)
-bionic-unit-tests_cflags := $(common_bionic-unit-tests_cflags)
-bionic-unit-tests_conlyflags := $(common_bionic-unit-tests_conlyflags)
-bionic-unit-tests_cppflags := $(common_bionic-unit-tests_cppflags)
-bionic-unit-tests_ldflags := $(common_bionic-unit-tests_ldflags)
-bionic-unit-tests_c_includes := $(common_bionic-unit-tests_c_includes)
-bionic-unit-tests_shared_libraries_target := $(common_bionic-unit-tests_shared_libraries_target)
-bionic-unit-tests_static_libraries_target := $(common_bionic-unit-tests_static_libraries_target)
-include $(LOCAL_PATH)/Android.build.mk
-
-module := bionic-unit-tests-gcc
-bionic-unit-tests-gcc_clang_target := false
-bionic-unit-tests-gcc_whole_static_libraries := $(common_bionic-unit-tests_whole_static_libraries)
-bionic-unit-tests-gcc_static_libraries := $(common_bionic-unit-tests_static_libraries)
-bionic-unit-tests-gcc_src_files := $(common_bionic-unit-tests_src_files)
-bionic-unit-tests-gcc_cflags := $(common_bionic-unit-tests_cflags)
-bionic-unit-tests-gcc_conlyflags := $(common_bionic-unit-tests_conlyflags)
-bionic-unit-tests-gcc_cppflags := $(common_bionic-unit-tests_cppflags)
-bionic-unit-tests-gcc_ldflags := $(common_bionic-unit-tests_ldflags)
-bionic-unit-tests-gcc_c_includes := $(common_bionic-unit-tests_c_includes)
-bionic-unit-tests-gcc_shared_libraries_target := $(common_bionic-unit-tests_shared_libraries_target)
-bionic-unit-tests-gcc_static_libraries_target := $(common_bionic-unit-tests_static_libraries_target)
-include $(LOCAL_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
-# Tests for the device linked against bionic's static library. Run with:
-#   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
-#   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
-# -----------------------------------------------------------------------------
-bionic-unit-tests-static_whole_static_libraries := \
-    libBionicTests \
-    libBionicGtestMain \
-
-bionic-unit-tests-static_static_libraries := \
-    libm \
-    libc \
-    libc++_static \
-    libdl \
-    libtinyxml2 \
-    liblog \
-    libbase \
-
-bionic-unit-tests-static_force_static_executable := true
-
-# libc and libc++ both define std::nothrow. libc's is a private symbol, but this
-# still causes issues when linking libc.a and libc++.a, since private isn't
-# effective until it has been linked. To fix this, just allow multiple symbol
-# definitions for the static tests.
-bionic-unit-tests-static_ldflags := -Wl,--allow-multiple-definition
-
-module := bionic-unit-tests-static
-module_tag := optional
-build_type := target
-build_target := NATIVE_TEST
-include $(LOCAL_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
-# Tests to run on the host and linked against glibc. Run with:
-#   cd bionic/tests; mm bionic-unit-tests-glibc-run
-# -----------------------------------------------------------------------------
-
 ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
 
-bionic-unit-tests-glibc_src_files := \
-    atexit_test.cpp \
-    dlfcn_test.cpp \
-    dl_test.cpp \
-    pthread_dlfcn_test.cpp \
-
-bionic-unit-tests-glibc_shared_libraries := \
-    libdl_preempt_test_1 \
-    libdl_preempt_test_2
-
-bionic-unit-tests-glibc_shared_libraries += libdl_test_df_1_global
-
-bionic-unit-tests-glibc_whole_static_libraries := \
-    libBionicStandardTests \
-    libBionicGtestMain \
-    $(fortify_libs) \
-
-bionic-unit-tests-glibc_static_libraries := \
-    libbase \
-    liblog \
-    libcutils \
-
-bionic-unit-tests-glibc_ldlibs := \
-    -lrt -ldl -lutil \
-
-bionic-unit-tests-glibc_c_includes := \
-    bionic/libc \
-
-bionic-unit-tests-glibc_cflags := $(test_cflags)
-bionic-unit-tests-glibc_cppflags := $(test_cppflags)
-bionic-unit-tests-glibc_ldflags := -Wl,--export-dynamic
-
-bionic-unit-tests-glibc_allow_asan := true
-
-module := bionic-unit-tests-glibc
-module_tag := optional
-build_type := host
-build_target := NATIVE_TEST
-include $(LOCAL_PATH)/Android.build.mk
-
 # -----------------------------------------------------------------------------
 # Compile time tests.
 # -----------------------------------------------------------------------------
@@ -481,52 +102,6 @@
 LOCAL_SRC_FILES :=
 include $(BUILD_STATIC_LIBRARY)
 
-# -----------------------------------------------------------------------------
-# Host glibc tests.
-# -----------------------------------------------------------------------------
-
-# gtest needs ANDROID_DATA/local/tmp for death test output.
-# Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
-# Use the current target out directory as ANDROID_DATA.
-# BIONIC_TEST_FLAGS is either empty or it comes from the user.
-.PHONY: bionic-unit-tests-glibc-run
-bionic-unit-tests-glibc-run: bionic-unit-tests-glibc
-	mkdir -p $(TARGET_OUT_DATA)/local/tmp
-	ANDROID_DATA=$(TARGET_OUT_DATA) \
-	ANDROID_ROOT=$(TARGET_OUT) \
-		$(HOST_OUT_EXECUTABLES)/bionic-unit-tests-glibc64 $(BIONIC_TEST_FLAGS)
-
-# -----------------------------------------------------------------------------
-# Run the unit tests built against x86 bionic on an x86 host.
-# -----------------------------------------------------------------------------
-
-include $(LOCAL_PATH)/../build/run-on-host.mk
-
-ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
-
-TEST_TIMEOUT := 0
-
-# BIONIC_TEST_FLAGS is either empty or it comes from the user.
-.PHONY: bionic-unit-tests-run-on-host32
-bionic-unit-tests-run-on-host32: bionic-unit-tests bionic-prepare-run-on-host
-	ANDROID_DATA=$(TARGET_OUT_DATA) \
-	ANDROID_DNS_MODE=local \
-	ANDROID_ROOT=$(TARGET_OUT) \
-		timeout $(TEST_TIMEOUT) \
-		$(TARGET_OUT_DATA)/nativetest/bionic-unit-tests/bionic-unit-tests32 $(BIONIC_TEST_FLAGS)
-
-ifeq ($(TARGET_IS_64_BIT),true)
-# add target to run lp64 tests
-.PHONY: bionic-unit-tests-run-on-host64
-bionic-unit-tests-run-on-host64: bionic-unit-tests bionic-prepare-run-on-host
-	ANDROID_DATA=$(TARGET_OUT_DATA) \
-	ANDROID_DNS_MODE=local \
-	ANDROID_ROOT=$(TARGET_OUT) \
-		timeout $(TEST_TIMEOUT) \
-		$(TARGET_OUT_DATA)/nativetest64/bionic-unit-tests/bionic-unit-tests64 $(BIONIC_TEST_FLAGS)
-endif
-
-endif # x86 x86_64
 endif # linux-x86
 
 include $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/ScopedSignalHandler.h b/tests/ScopedSignalHandler.h
index 3fb60a1..8998d0d 100644
--- a/tests/ScopedSignalHandler.h
+++ b/tests/ScopedSignalHandler.h
@@ -39,6 +39,10 @@
     sigaction(signal_number_, &action_, &old_action_);
   }
 
+  ScopedSignalHandler(int signal_number) : signal_number_(signal_number) {
+    sigaction(signal_number, nullptr, &old_action_);
+  }
+
   ~ScopedSignalHandler() {
     sigaction(signal_number_, &old_action_, NULL);
   }
@@ -49,4 +53,18 @@
   const int signal_number_;
 };
 
+class ScopedSignalMask {
+ public:
+  ScopedSignalMask() {
+    sigprocmask(SIG_SETMASK, nullptr, &old_mask_);
+  }
+
+  ~ScopedSignalMask() {
+    sigprocmask(SIG_SETMASK, &old_mask_, nullptr);
+  }
+
+ private:
+  sigset_t old_mask_;
+};
+
 #endif // _BIONIC_TESTS_SCOPED_SIGNAL_HANDLER_H
diff --git a/tests/__cxa_thread_atexit_test.cpp b/tests/__cxa_thread_atexit_test.cpp
index 1432968..e388f3b 100644
--- a/tests/__cxa_thread_atexit_test.cpp
+++ b/tests/__cxa_thread_atexit_test.cpp
@@ -35,12 +35,7 @@
   std::string message;
 };
 
-#if defined(__clang__) && defined(__aarch64__)
-// b/25642296, aarch64 clang compiled "thread_local" does not link.
-static ClassWithDtor class_with_dtor;
-#else
 static thread_local ClassWithDtor class_with_dtor;
-#endif
 
 static void* thread_nop(void* arg) {
   class_with_dtor.set_message(*static_cast<std::string*>(arg));
@@ -52,12 +47,7 @@
   pthread_t t;
   ASSERT_EQ(0, pthread_create(&t, nullptr, thread_nop, &msg));
   ASSERT_EQ(0, pthread_join(t, nullptr));
-#if defined(__clang__) && defined(__aarch64__)
-  GTEST_LOG_(INFO) << "Skipping test, b/25642296, "
-                   << "thread_local does not work with aarch64 clang/llvm.\n";
-#else
   ASSERT_EQ("dtor called.", class_with_dtor_output);
-#endif
 }
 
 class ClassWithDtorForMainThread {
@@ -74,13 +64,7 @@
 };
 
 static void thread_atexit_main() {
-#if defined(__clang__) && defined(__aarch64__)
-  static ClassWithDtorForMainThread class_with_dtor_for_main_thread;
-  GTEST_LOG_(INFO) << "Skipping test, b/25642296, "
-                   << "thread_local does not work with aarch64 clang/llvm.\n";
-#else
   static thread_local ClassWithDtorForMainThread class_with_dtor_for_main_thread;
-#endif
   class_with_dtor_for_main_thread.set_message("d-tor for main thread called.");
   exit(0);
 }
diff --git a/tests/assert_test.cpp b/tests/assert_test.cpp
new file mode 100644
index 0000000..9436151
--- /dev/null
+++ b/tests/assert_test.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#undef NDEBUG
+#include <assert.h>
+
+TEST(assert, assert_true) {
+  assert(true);
+}
+
+TEST(assert, assert_false) {
+  EXPECT_DEATH(assert(false),
+               "bionic/tests/assert_test.cpp:.*: "
+               "virtual void assert_assert_false_Test::TestBody\\(\\): "
+               "assertion \"false\" failed");
+}
+
+// Re-include <assert.h> with assertions disabled.
+#define NDEBUG
+#include <assert.h>
+
+TEST(assert, assert_true_NDEBUG) {
+  assert(true);
+}
+
+TEST(assert, assert_false_NDEBUG) {
+  assert(false);
+}
diff --git a/tests/complex_test.cpp b/tests/complex_test.cpp
index 47964f6..f18fac5 100644
--- a/tests/complex_test.cpp
+++ b/tests/complex_test.cpp
@@ -16,245 +16,305 @@
 
 #include <gtest/gtest.h>
 
+// This file is compiled against both glibc and bionic, and our complex.h
+// depends on bionic-specific macros, so hack around that.
+#include <sys/cdefs.h>
+#if !defined(__INTRODUCED_IN)
+#define __INTRODUCED_IN(x)
+#define __INTRODUCED_IN_32(x)
+#define __INTRODUCED_IN_64(x)
+#define __INTRODUCED_IN_FUTURE
+#endif
+
 // libc++ actively gets in the way of including <complex.h> from C++, so we
-// have to declare the complex math functions ourselves.
+// have to be naughty.
+#include <../libc/include/complex.h>
+
 // (libc++ also seems to have really bad implementations of its own that ignore
 // the intricacies of floating point math.)
 // http://llvm.org/bugs/show_bug.cgi?id=21504
 
-#include <math.h> // For M_PI.
+#include <math.h> // For M_PI_2/M_PI_2l.
 
-extern "C" double cabs(double _Complex);
+// Note that gtest doesn't support complex numbers, so the output from
+// assertion failures is misleading/useless (at best you'll only see the real
+// part).
+// TODO: find out why gtest doesn't use these; until then they're only useful
+// for manual printf^Woperator<< debugging.
+#include <iostream>
+std::ostream& operator<<(std::ostream& os, const double _Complex c) {
+  os << "(" << creal(c) << "," << cimag(c) << "i)";
+ return os;
+}
+std::ostream& operator<<(std::ostream& os, const float _Complex c) {
+  os << "(" << crealf(c) << "," << cimagf(c) << "i)";
+  return os;
+}
+std::ostream& operator<<(std::ostream& os, const long double _Complex c) {
+  os << "(" << creall(c) << "," << cimagl(c) << "i)";
+  return os;
+}
+
 TEST(complex, cabs) {
   ASSERT_EQ(0.0, cabs(0));
 }
 
-extern "C" float cabsf(float _Complex);
 TEST(complex, cabsf) {
   ASSERT_EQ(0.0, cabsf(0));
 }
 
-extern "C" long double cabsl(long double _Complex);
 TEST(complex, cabsl) {
   ASSERT_EQ(0.0, cabsl(0));
 }
 
-extern "C" double _Complex cacos(double _Complex);
 TEST(complex, cacos) {
-  ASSERT_EQ(M_PI/2.0, cacos(0.0));
+  ASSERT_EQ(M_PI_2, cacos(0.0));
 }
 
-extern "C" float _Complex cacosf(float _Complex);
 TEST(complex, cacosf) {
-  ASSERT_EQ(static_cast<float>(M_PI)/2.0f, cacosf(0.0));
+  ASSERT_EQ(static_cast<float>(M_PI_2), cacosf(0.0));
 }
 
-extern "C" double _Complex cacosh(double _Complex);
+TEST(complex, cacosl) {
+  ASSERT_EQ(M_PI_2l, cacosl(0.0));
+}
+
 TEST(complex, cacosh) {
   ASSERT_EQ(0.0, cacosh(1.0));
 }
 
-extern "C" float _Complex cacoshf(float _Complex);
+TEST(complex, cacoshl) {
+  ASSERT_EQ(0.0, cacoshl(1.0));
+}
+
 TEST(complex, cacoshf) {
   ASSERT_EQ(0.0, cacoshf(1.0));
 }
 
-extern "C" double carg(double _Complex);
 TEST(complex, carg) {
   ASSERT_EQ(0.0, carg(0));
 }
 
-extern "C" float cargf(float _Complex);
 TEST(complex, cargf) {
   ASSERT_EQ(0.0, cargf(0));
 }
 
-extern "C" long double cargl(long double _Complex);
 TEST(complex, cargl) {
   ASSERT_EQ(0.0, cargl(0));
 }
 
-extern "C" double _Complex casin(double _Complex);
 TEST(complex, casin) {
   ASSERT_EQ(0.0, casin(0));
 }
 
-extern "C" float _Complex casinf(float _Complex);
 TEST(complex, casinf) {
   ASSERT_EQ(0.0, casinf(0));
 }
 
-extern "C" double _Complex casinh(double _Complex);
+TEST(complex, casinl) {
+  ASSERT_EQ(0.0, casinl(0));
+}
+
 TEST(complex, casinh) {
   ASSERT_EQ(0.0, casinh(0));
 }
 
-extern "C" float _Complex casinhf(float _Complex);
 TEST(complex, casinhf) {
   ASSERT_EQ(0.0, casinhf(0));
 }
 
-extern "C" double _Complex catan(double _Complex);
+TEST(complex, casinhl) {
+  ASSERT_EQ(0.0, casinhl(0));
+}
+
 TEST(complex, catan) {
   ASSERT_EQ(0.0, catan(0));
 }
 
-extern "C" float _Complex catanf(float _Complex);
 TEST(complex, catanf) {
   ASSERT_EQ(0.0, catanf(0));
 }
 
-extern "C" double _Complex catanh(double _Complex);
+TEST(complex, catanl) {
+  ASSERT_EQ(0.0, catanl(0));
+}
+
 TEST(complex, catanh) {
   ASSERT_EQ(0.0, catanh(0));
 }
 
-extern "C" float _Complex catanhf(float _Complex);
 TEST(complex, catanhf) {
   ASSERT_EQ(0.0, catanhf(0));
 }
 
-extern "C" double _Complex ccos(double _Complex);
+TEST(complex, catanhl) {
+  ASSERT_EQ(0.0, catanhl(0));
+}
+
 TEST(complex, ccos) {
   ASSERT_EQ(1.0, ccos(0));
 }
 
-extern "C" float _Complex ccosf(float _Complex);
 TEST(complex, ccosf) {
   ASSERT_EQ(1.0, ccosf(0));
 }
 
-extern "C" double _Complex ccosh(double _Complex);
+TEST(complex, ccosl) {
+  ASSERT_EQ(1.0, ccosl(0));
+}
+
 TEST(complex, ccosh) {
   ASSERT_EQ(1.0, ccosh(0));
 }
 
-extern "C" float _Complex ccoshf(float _Complex);
 TEST(complex, ccoshf) {
   ASSERT_EQ(1.0, ccoshf(0));
 }
 
-extern "C" double _Complex cexp(double _Complex);
+TEST(complex, ccoshl) {
+  ASSERT_EQ(1.0, ccoshl(0));
+}
+
 TEST(complex, cexp) {
   ASSERT_EQ(1.0, cexp(0));
 }
 
-extern "C" float _Complex cexpf(float _Complex);
 TEST(complex, cexpf) {
   ASSERT_EQ(1.0, cexpf(0));
 }
 
-extern "C" double cimag(double _Complex);
+TEST(complex, cexpl) {
+  ASSERT_EQ(1.0, cexpl(0));
+}
+
 TEST(complex, cimag) {
   ASSERT_EQ(0.0, cimag(0));
 }
 
-extern "C" float cimagf(float _Complex);
 TEST(complex, cimagf) {
   ASSERT_EQ(0.0f, cimagf(0));
 }
 
-extern "C" long double cimagl(long double _Complex);
 TEST(complex, cimagl) {
   ASSERT_EQ(0.0, cimagl(0));
 }
 
-extern "C" double _Complex conj(double _Complex);
+TEST(complex, clog) {
+  ASSERT_EQ(0.0, clog(1.0));
+}
+
+TEST(complex, clogf) {
+  ASSERT_EQ(0.0f, clogf(1.0f));
+}
+
+TEST(complex, clogl) {
+  ASSERT_EQ(0.0L, clogl(1.0L));
+}
+
 TEST(complex, conj) {
   ASSERT_EQ(0.0, conj(0));
 }
 
-extern "C" float _Complex conjf(float _Complex);
 TEST(complex, conjf) {
   ASSERT_EQ(0.0f, conjf(0));
 }
 
-extern "C" long double _Complex conjl(long double _Complex);
 TEST(complex, conjl) {
   ASSERT_EQ(0.0, conjl(0));
 }
 
-extern "C" double _Complex cproj(double _Complex);
+TEST(complex, cpow) {
+  ASSERT_EQ(8.0, cpow(2.0, 3.0));
+}
+
+TEST(complex, cpowf) {
+  ASSERT_EQ(8.0f, cpowf(2.0f, 3.0f));
+}
+
+TEST(complex, cpowl) {
+  ASSERT_EQ(8.0L, cpowl(2.0L, 3.0L));
+}
+
 TEST(complex, cproj) {
   ASSERT_EQ(0.0, cproj(0));
 }
 
-extern "C" float _Complex cprojf(float _Complex);
 TEST(complex, cprojf) {
   ASSERT_EQ(0.0f, cprojf(0));
 }
 
-extern "C" long double _Complex cprojl(long double _Complex);
 TEST(complex, cprojl) {
   ASSERT_EQ(0.0, cprojl(0));
 }
 
-extern "C" double creal(double _Complex);
 TEST(complex, creal) {
-  ASSERT_EQ(0.0, creal(0));
+  ASSERT_EQ(2.0, creal(2.0 + 3.0I));
 }
 
-extern "C" float crealf(float _Complex);
 TEST(complex, crealf) {
-  ASSERT_EQ(0.0f, crealf(0));
+  ASSERT_EQ(2.0f, crealf(2.0f + 3.0fI));
 }
 
-extern "C" long double creall(long double _Complex);
 TEST(complex, creall) {
-  ASSERT_EQ(0.0, creall(0));
+  ASSERT_EQ(2.0, creall(2.0L + 3.0LI));
 }
 
-extern "C" double _Complex csin(double _Complex);
 TEST(complex, csin) {
   ASSERT_EQ(0.0, csin(0));
 }
 
-extern "C" float _Complex csinf(float _Complex);
 TEST(complex, csinf) {
   ASSERT_EQ(0.0, csinf(0));
 }
 
-extern "C" double _Complex csinh(double _Complex);
+TEST(complex, csinl) {
+  ASSERT_EQ(0.0, csinl(0));
+}
+
 TEST(complex, csinh) {
   ASSERT_EQ(0.0, csinh(0));
 }
 
-extern "C" float _Complex csinhf(float _Complex);
 TEST(complex, csinhf) {
   ASSERT_EQ(0.0, csinhf(0));
 }
 
-extern "C" double _Complex csqrt(double _Complex);
+TEST(complex, csinhl) {
+  ASSERT_EQ(0.0, csinhl(0));
+}
+
 TEST(complex, csqrt) {
   ASSERT_EQ(0.0, csqrt(0));
 }
 
-extern "C" float _Complex csqrtf(float _Complex);
 TEST(complex, csqrtf) {
-  ASSERT_EQ(0.0f, csqrt(0));
+  ASSERT_EQ(0.0f, csqrtf(0));
 }
 
-extern "C" long double _Complex csqrtl(long double _Complex);
 TEST(complex, csqrtl) {
   ASSERT_EQ(0.0, csqrtl(0));
 }
 
-extern "C" double _Complex ctan(double _Complex);
 TEST(complex, ctan) {
   ASSERT_EQ(0.0, ctan(0));
 }
 
-extern "C" float _Complex ctanf(float _Complex);
 TEST(complex, ctanf) {
   ASSERT_EQ(0.0, ctanf(0));
 }
 
-extern "C" double _Complex ctanh(double _Complex);
+TEST(complex, ctanl) {
+  ASSERT_EQ(0.0, ctanl(0));
+}
+
 TEST(complex, ctanh) {
   ASSERT_EQ(0.0, ctanh(0));
 }
 
-extern "C" float _Complex ctanhf(float _Complex);
 TEST(complex, ctanhf) {
   ASSERT_EQ(0.0, ctanhf(0));
 }
+
+TEST(complex, ctanhl) {
+  ASSERT_EQ(0.0, ctanhl(0));
+}
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index 5501c8e..8527b00 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -32,12 +32,14 @@
 #include <pagemap/pagemap.h>
 #include <ziparchive/zip_archive.h>
 
+#include "gtest_globals.h"
 #include "TemporaryFile.h"
 #include "utils.h"
 #include "dlext_private.h"
+#include "dlfcn_symlink_support.h"
 
 #define ASSERT_DL_NOTNULL(ptr) \
-    ASSERT_TRUE(ptr != nullptr) << "dlerror: " << dlerror()
+    ASSERT_TRUE((ptr) != nullptr) << "dlerror: " << dlerror()
 
 #define ASSERT_DL_ZERO(i) \
     ASSERT_EQ(0, i) << "dlerror: " << dlerror()
@@ -50,32 +52,22 @@
 
 
 typedef int (*fn)(void);
-#define LIBNAME "libdlext_test.so"
-#define LIBNAME_NORELRO "libdlext_test_norelro.so"
-#define LIBSIZE 1024*1024 // how much address space to reserve for it
-
-#if defined(__LP64__)
-#define NATIVE_TESTS_PATH "/nativetest64"
-#else
-#define NATIVE_TESTS_PATH "/nativetest"
-#endif
-
-#define LIBPATH NATIVE_TESTS_PATH "/libdlext_test_fd/libdlext_test_fd.so"
-#define LIBZIPPATH NATIVE_TESTS_PATH "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"
-#define LIBZIPPATH_WITH_RUNPATH NATIVE_TESTS_PATH "/libdlext_test_runpath_zip/libdlext_test_runpath_zip_zipaligned.zip"
-#define LIBZIP_SIMPLE_ZIP "libdir/libatest_simple_zip.so"
+constexpr const char* kLibName = "libdlext_test.so";
+constexpr const char* kLibNameNoRelro = "libdlext_test_norelro.so";
+constexpr const char* kLibZipSimpleZip = "libdir/libatest_simple_zip.so";
+constexpr auto kLibSize = 1024 * 1024; // how much address space to reserve for it
 
 class DlExtTest : public ::testing::Test {
 protected:
   virtual void SetUp() {
     handle_ = nullptr;
     // verify that we don't have the library loaded already
-    void* h = dlopen(LIBNAME, RTLD_NOW | RTLD_NOLOAD);
+    void* h = dlopen(kLibName, RTLD_NOW | RTLD_NOLOAD);
     ASSERT_TRUE(h == nullptr);
-    h = dlopen(LIBNAME_NORELRO, RTLD_NOW | RTLD_NOLOAD);
+    h = dlopen(kLibNameNoRelro, RTLD_NOW | RTLD_NOLOAD);
     ASSERT_TRUE(h == nullptr);
     // call dlerror() to swallow the error, and check it was the one we wanted
-    ASSERT_STREQ("dlopen failed: library \"" LIBNAME_NORELRO "\" wasn't loaded and RTLD_NOLOAD prevented it", dlerror());
+    ASSERT_EQ(std::string("dlopen failed: library \"") + kLibNameNoRelro + "\" wasn't loaded and RTLD_NOLOAD prevented it", dlerror());
   }
 
   virtual void TearDown() {
@@ -88,7 +80,7 @@
 };
 
 TEST_F(DlExtTest, ExtInfoNull) {
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, nullptr);
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, nullptr);
   ASSERT_DL_NOTNULL(handle_);
   fn f = reinterpret_cast<fn>(dlsym(handle_, "getRandomNumber"));
   ASSERT_DL_NOTNULL(f);
@@ -98,7 +90,7 @@
 TEST_F(DlExtTest, ExtInfoNoFlags) {
   android_dlextinfo extinfo;
   extinfo.flags = 0;
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, &extinfo);
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
   ASSERT_DL_NOTNULL(handle_);
   fn f = reinterpret_cast<fn>(dlsym(handle_, "getRandomNumber"));
   ASSERT_DL_NOTNULL(f);
@@ -106,7 +98,7 @@
 }
 
 TEST_F(DlExtTest, ExtInfoUseFd) {
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBPATH;
+  const std::string lib_path = g_testlib_root + "/libdlext_test_fd/libdlext_test_fd.so";
 
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD;
@@ -124,7 +116,7 @@
 }
 
 TEST_F(DlExtTest, ExtInfoUseFdWithOffset) {
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH;
+  const std::string lib_path = g_testlib_root + "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip";
 
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
@@ -135,8 +127,8 @@
   ASSERT_EQ(0, OpenArchive(lib_path.c_str(), &handle));
   ZipEntry zip_entry;
   ZipString zip_name;
-  zip_name.name = reinterpret_cast<const uint8_t*>(LIBZIP_SIMPLE_ZIP);
-  zip_name.name_length = sizeof(LIBZIP_SIMPLE_ZIP) - 1;
+  zip_name.name = reinterpret_cast<const uint8_t*>(kLibZipSimpleZip);
+  zip_name.name_length = strlen(kLibZipSimpleZip);
   ASSERT_EQ(0, FindEntry(handle, zip_name, &zip_entry));
   extinfo.library_fd_offset = zip_entry.offset;
   CloseArchive(handle);
@@ -150,11 +142,7 @@
 }
 
 TEST_F(DlExtTest, ExtInfoUseFdWithInvalidOffset) {
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH;
-  // lib_path is relative when $ANDROID_DATA is relative
-  char lib_realpath_buf[PATH_MAX];
-  ASSERT_TRUE(realpath(lib_path.c_str(), lib_realpath_buf) == lib_realpath_buf);
-  const std::string lib_realpath = std::string(lib_realpath_buf);
+  const std::string lib_path = g_testlib_root + "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip";
 
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
@@ -179,7 +167,7 @@
   extinfo.library_fd_offset = 0;
   handle_ = android_dlopen_ext("libname_ignored", RTLD_NOW, &extinfo);
   ASSERT_TRUE(handle_ == nullptr);
-  ASSERT_EQ("dlopen failed: \"" + lib_realpath + "\" has bad ELF magic", dlerror());
+  ASSERT_EQ("dlopen failed: \"" + lib_path + "\" has bad ELF magic", dlerror());
 
   // Check if dlsym works after unsuccessful dlopen().
   // Supply non-exiting one to make linker visit every soinfo.
@@ -201,13 +189,15 @@
 }
 
 TEST(dlext, android_dlopen_ext_force_load_smoke) {
+  DlfcnSymlink symlink("android_dlopen_ext_force_load_smoke");
+  const std::string symlink_name = basename(symlink.get_symlink_path().c_str());
   // 1. Open actual file
   void* handle = dlopen("libdlext_test.so", RTLD_NOW);
   ASSERT_DL_NOTNULL(handle);
   // 2. Open link with force_load flag set
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_FORCE_LOAD;
-  void* handle2 = android_dlopen_ext("libdlext_test_v2.so", RTLD_NOW, &extinfo);
+  void* handle2 = android_dlopen_ext(symlink_name.c_str(), RTLD_NOW, &extinfo);
   ASSERT_DL_NOTNULL(handle2);
   ASSERT_TRUE(handle != handle2);
 
@@ -216,15 +206,17 @@
 }
 
 TEST(dlext, android_dlopen_ext_force_load_soname_exception) {
+  DlfcnSymlink symlink("android_dlopen_ext_force_load_soname_exception");
+  const std::string symlink_name = basename(symlink.get_symlink_path().c_str());
   // Check if soname lookup still returns already loaded library
   // when ANDROID_DLEXT_FORCE_LOAD flag is specified.
-  void* handle = dlopen("libdlext_test_v2.so", RTLD_NOW);
+  void* handle = dlopen(symlink_name.c_str(), RTLD_NOW);
   ASSERT_DL_NOTNULL(handle);
 
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_FORCE_LOAD;
 
-  // Note that 'libdlext_test.so' is dt_soname for libdlext_test_v2.so
+  // Note that 'libdlext_test.so' is dt_soname for the symlink_name
   void* handle2 = android_dlopen_ext("libdlext_test.so", RTLD_NOW, &extinfo);
 
   ASSERT_DL_NOTNULL(handle2);
@@ -235,7 +227,8 @@
 }
 
 TEST(dlfcn, dlopen_from_zip_absolute_path) {
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH;
+  const std::string lib_zip_path = "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip";
+  const std::string lib_path = g_testlib_root + lib_zip_path;
 
   void* handle = dlopen((lib_path + "!/libdir/libatest_simple_zip.so").c_str(), RTLD_NOW);
   ASSERT_TRUE(handle != nullptr) << dlerror();
@@ -248,7 +241,8 @@
 }
 
 TEST(dlfcn, dlopen_from_zip_with_dt_runpath) {
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH_WITH_RUNPATH;
+  const std::string lib_zip_path = "/libdlext_test_runpath_zip/libdlext_test_runpath_zip_zipaligned.zip";
+  const std::string lib_path = g_testlib_root + lib_zip_path;
 
   void* handle = dlopen((lib_path + "!/libdir/libtest_dt_runpath_d_zip.so").c_str(), RTLD_NOW);
 
@@ -266,7 +260,8 @@
 }
 
 TEST(dlfcn, dlopen_from_zip_ld_library_path) {
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH + "!/libdir";
+  const std::string lib_zip_path = "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip";
+  const std::string lib_path = g_testlib_root + lib_zip_path + "!/libdir";
 
   typedef void (*fn_t)(const char*);
   fn_t android_update_LD_LIBRARY_PATH =
@@ -297,19 +292,19 @@
 
 
 TEST_F(DlExtTest, Reserved) {
-  void* start = mmap(nullptr, LIBSIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+  void* start = mmap(nullptr, kLibSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   ASSERT_TRUE(start != MAP_FAILED);
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS;
   extinfo.reserved_addr = start;
-  extinfo.reserved_size = LIBSIZE;
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, &extinfo);
+  extinfo.reserved_size = kLibSize;
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
   ASSERT_DL_NOTNULL(handle_);
   fn f = reinterpret_cast<fn>(dlsym(handle_, "getRandomNumber"));
   ASSERT_DL_NOTNULL(f);
   EXPECT_GE(reinterpret_cast<void*>(f), start);
   EXPECT_LT(reinterpret_cast<void*>(f),
-            reinterpret_cast<char*>(start) + LIBSIZE);
+            reinterpret_cast<char*>(start) + kLibSize);
   EXPECT_EQ(4, f());
 
   // Check that after dlclose reserved address space is unmapped (and can be reused)
@@ -327,24 +322,24 @@
   extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS;
   extinfo.reserved_addr = start;
   extinfo.reserved_size = PAGE_SIZE;
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, &extinfo);
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
   EXPECT_EQ(nullptr, handle_);
 }
 
 TEST_F(DlExtTest, ReservedHint) {
-  void* start = mmap(nullptr, LIBSIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+  void* start = mmap(nullptr, kLibSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   ASSERT_TRUE(start != MAP_FAILED);
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS_HINT;
   extinfo.reserved_addr = start;
-  extinfo.reserved_size = LIBSIZE;
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, &extinfo);
+  extinfo.reserved_size = kLibSize;
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
   ASSERT_DL_NOTNULL(handle_);
   fn f = reinterpret_cast<fn>(dlsym(handle_, "getRandomNumber"));
   ASSERT_DL_NOTNULL(f);
   EXPECT_GE(reinterpret_cast<void*>(f), start);
   EXPECT_LT(reinterpret_cast<void*>(f),
-            reinterpret_cast<char*>(start) + LIBSIZE);
+            reinterpret_cast<char*>(start) + kLibSize);
   EXPECT_EQ(4, f());
 }
 
@@ -355,7 +350,7 @@
   extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS_HINT;
   extinfo.reserved_addr = start;
   extinfo.reserved_size = PAGE_SIZE;
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, &extinfo);
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
   ASSERT_DL_NOTNULL(handle_);
   fn f = reinterpret_cast<fn>(dlsym(handle_, "getRandomNumber"));
   ASSERT_DL_NOTNULL(f);
@@ -366,36 +361,36 @@
 }
 
 TEST_F(DlExtTest, LoadAtFixedAddress) {
-  void* start = mmap(nullptr, LIBSIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+  void* start = mmap(nullptr, kLibSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   ASSERT_TRUE(start != MAP_FAILED);
-  munmap(start, LIBSIZE);
+  munmap(start, kLibSize);
 
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS;
   extinfo.reserved_addr = start;
 
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, &extinfo);
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
   ASSERT_DL_NOTNULL(handle_);
   fn f = reinterpret_cast<fn>(dlsym(handle_, "getRandomNumber"));
   ASSERT_DL_NOTNULL(f);
   EXPECT_GE(reinterpret_cast<void*>(f), start);
-  EXPECT_LT(reinterpret_cast<void*>(f), reinterpret_cast<char*>(start) + LIBSIZE);
+  EXPECT_LT(reinterpret_cast<void*>(f), reinterpret_cast<char*>(start) + kLibSize);
 
   EXPECT_EQ(4, f());
   dlclose(handle_);
   handle_ = nullptr;
 
   // Check that dlclose unmapped the file
-  void* addr = mmap(start, LIBSIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+  void* addr = mmap(start, kLibSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   ASSERT_EQ(start, addr) << "dlclose did not unmap the memory";
 }
 
 TEST_F(DlExtTest, LoadAtFixedAddressTooSmall) {
-  void* start = mmap(nullptr, LIBSIZE + PAGE_SIZE, PROT_NONE,
+  void* start = mmap(nullptr, kLibSize + PAGE_SIZE, PROT_NONE,
                          MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   ASSERT_TRUE(start != MAP_FAILED);
-  munmap(start, LIBSIZE + PAGE_SIZE);
-  void* new_addr = mmap(reinterpret_cast<uint8_t*>(start) + PAGE_SIZE, LIBSIZE, PROT_NONE,
+  munmap(start, kLibSize + PAGE_SIZE);
+  void* new_addr = mmap(reinterpret_cast<uint8_t*>(start) + PAGE_SIZE, kLibSize, PROT_NONE,
                         MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   ASSERT_TRUE(new_addr != MAP_FAILED);
 
@@ -403,7 +398,7 @@
   extinfo.flags = ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS;
   extinfo.reserved_addr = start;
 
-  handle_ = android_dlopen_ext(LIBNAME, RTLD_NOW, &extinfo);
+  handle_ = android_dlopen_ext(kLibName, RTLD_NOW, &extinfo);
   ASSERT_TRUE(handle_ == nullptr);
 }
 
@@ -411,11 +406,11 @@
 protected:
   virtual void SetUp() {
     DlExtTest::SetUp();
-    void* start = mmap(nullptr, LIBSIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+    void* start = mmap(nullptr, kLibSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
     ASSERT_TRUE(start != MAP_FAILED);
     extinfo_.flags = ANDROID_DLEXT_RESERVED_ADDRESS;
     extinfo_.reserved_addr = start;
-    extinfo_.reserved_size = LIBSIZE;
+    extinfo_.reserved_size = kLibSize;
     extinfo_.relro_fd = -1;
   }
 
@@ -474,8 +469,8 @@
   TemporaryFile tf; // Use tf to get an unique filename.
   ASSERT_NOERROR(close(tf.fd));
 
-  ASSERT_NO_FATAL_FAILURE(CreateRelroFile(LIBNAME, tf.filename));
-  ASSERT_NO_FATAL_FAILURE(TryUsingRelro(LIBNAME));
+  ASSERT_NO_FATAL_FAILURE(CreateRelroFile(kLibName, tf.filename));
+  ASSERT_NO_FATAL_FAILURE(TryUsingRelro(kLibName));
 
   // Use destructor of tf to close and unlink the file.
   tf.fd = extinfo_.relro_fd;
@@ -485,15 +480,15 @@
   TemporaryFile tf; // // Use tf to get an unique filename.
   ASSERT_NOERROR(close(tf.fd));
 
-  ASSERT_NO_FATAL_FAILURE(CreateRelroFile(LIBNAME_NORELRO, tf.filename));
-  ASSERT_NO_FATAL_FAILURE(TryUsingRelro(LIBNAME_NORELRO));
+  ASSERT_NO_FATAL_FAILURE(CreateRelroFile(kLibNameNoRelro, tf.filename));
+  ASSERT_NO_FATAL_FAILURE(TryUsingRelro(kLibNameNoRelro));
 
   // Use destructor of tf to close and unlink the file.
   tf.fd = extinfo_.relro_fd;
 }
 
 TEST_F(DlExtRelroSharingTest, RelroFileEmpty) {
-  ASSERT_NO_FATAL_FAILURE(TryUsingRelro(LIBNAME));
+  ASSERT_NO_FATAL_FAILURE(TryUsingRelro(kLibName));
 }
 
 TEST_F(DlExtRelroSharingTest, VerifyMemorySaving) {
@@ -505,14 +500,14 @@
   TemporaryFile tf; // Use tf to get an unique filename.
   ASSERT_NOERROR(close(tf.fd));
 
-  ASSERT_NO_FATAL_FAILURE(CreateRelroFile(LIBNAME, tf.filename));
+  ASSERT_NO_FATAL_FAILURE(CreateRelroFile(kLibName, tf.filename));
 
   int pipefd[2];
   ASSERT_NOERROR(pipe(pipefd));
 
   size_t without_sharing, with_sharing;
-  ASSERT_NO_FATAL_FAILURE(SpawnChildrenAndMeasurePss(LIBNAME, false, &without_sharing));
-  ASSERT_NO_FATAL_FAILURE(SpawnChildrenAndMeasurePss(LIBNAME, true, &with_sharing));
+  ASSERT_NO_FATAL_FAILURE(SpawnChildrenAndMeasurePss(kLibName, false, &without_sharing));
+  ASSERT_NO_FATAL_FAILURE(SpawnChildrenAndMeasurePss(kLibName, true, &with_sharing));
 
   // We expect the sharing to save at least 10% of the total PSS. In practice
   // it saves 40%+ for this test.
@@ -632,9 +627,11 @@
                "default namespace",
                dlerror());
 
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + NATIVE_TESTS_PATH;
+  ASSERT_FALSE(android_init_namespaces("", nullptr));
+  ASSERT_STREQ("android_init_namespaces failed: error initializing public namespace: "
+               "the list of public libraries is empty.", dlerror());
 
-  const std::string lib_public_path = lib_path + "/public_namespace_libs/" + g_public_lib;
+  const std::string lib_public_path = g_testlib_root + "/public_namespace_libs/" + g_public_lib;
   void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW);
   ASSERT_TRUE(handle_public != nullptr) << dlerror();
 
@@ -642,20 +639,20 @@
 
   // Check that libraries added to public namespace are NODELETE
   dlclose(handle_public);
-  handle_public = dlopen((lib_path + "/public_namespace_libs/" + g_public_lib).c_str(),
+  handle_public = dlopen((g_testlib_root + "/public_namespace_libs/" + g_public_lib).c_str(),
                          RTLD_NOW | RTLD_NOLOAD);
 
   ASSERT_TRUE(handle_public != nullptr) << dlerror();
 
   android_namespace_t* ns1 =
           android_create_namespace("private", nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr);
   ASSERT_TRUE(ns1 != nullptr) << dlerror();
 
   android_namespace_t* ns2 =
           android_create_namespace("private_isolated", nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr);
   ASSERT_TRUE(ns2 != nullptr) << dlerror();
 
@@ -746,8 +743,7 @@
   static const char* root_lib = "libnstest_root_not_isolated.so";
   std::string path = std::string("libc.so:libc++.so:libdl.so:libm.so:") + g_public_lib;
 
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + NATIVE_TESTS_PATH;
-  const std::string lib_public_path = lib_path + "/public_namespace_libs/" + g_public_lib;
+  const std::string lib_public_path = g_testlib_root + "/public_namespace_libs/" + g_public_lib;
   void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW);
   ASSERT_TRUE(handle_public != nullptr) << dlerror();
 
@@ -757,14 +753,14 @@
 
   android_namespace_t* ns_not_isolated =
           android_create_namespace("private", nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr);
   ASSERT_TRUE(ns_not_isolated != nullptr) << dlerror();
 
   android_namespace_t* ns_isolated =
           android_create_namespace("private_isolated1",
                                    nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_ISOLATED,
                                    nullptr,
                                    nullptr);
@@ -772,10 +768,10 @@
 
   android_namespace_t* ns_isolated2 =
           android_create_namespace("private_isolated2",
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    nullptr,
                                    ANDROID_NAMESPACE_TYPE_ISOLATED,
-                                   lib_path.c_str(),
+                                   g_testlib_root.c_str(),
                                    nullptr);
   ASSERT_TRUE(ns_isolated2 != nullptr) << dlerror();
 
@@ -783,7 +779,7 @@
   ASSERT_STREQ("dlopen failed: library \"libnstest_root_not_isolated.so\" not found", dlerror());
 
   std::string lib_private_external_path =
-      lib_path + "/private_namespace_libs_external/libnstest_private_external.so";
+      g_testlib_root + "/private_namespace_libs_external/libnstest_private_external.so";
 
   // Load lib_private_external_path to default namespace
   // (it should remain invisible for the isolated namespaces after this)
@@ -812,7 +808,7 @@
 
   extinfo.library_namespace = ns_isolated2;
 
-  // this should work because isolation_path for private_isolated2 includes lib_path
+  // this should work because isolation_path for private_isolated2 includes g_testlib_root
   handle2 = android_dlopen_ext(root_lib, RTLD_NOW, &extinfo);
   ASSERT_TRUE(handle2 != nullptr) << dlerror();
   dlclose(handle2);
@@ -853,8 +849,7 @@
   static const char* root_lib_isolated = "libnstest_root.so";
   std::string path = std::string("libc.so:libc++.so:libdl.so:libm.so:") + g_public_lib;
 
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + NATIVE_TESTS_PATH;
-  const std::string lib_public_path = lib_path + "/public_namespace_libs/" + g_public_lib;
+  const std::string lib_public_path = g_testlib_root + "/public_namespace_libs/" + g_public_lib;
   void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW);
   ASSERT_TRUE(handle_public != nullptr) << dlerror();
 
@@ -865,18 +860,18 @@
   // preload this library to the default namespace to check if it
   // is shared later on.
   void* handle_dlopened =
-          dlopen((lib_path + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW);
+          dlopen((g_testlib_root + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW);
   ASSERT_TRUE(handle_dlopened != nullptr) << dlerror();
 
   android_namespace_t* ns_not_isolated =
           android_create_namespace("private", nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr);
   ASSERT_TRUE(ns_not_isolated != nullptr) << dlerror();
 
   android_namespace_t* ns_isolated_shared =
           android_create_namespace("private_isolated_shared", nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_ISOLATED | ANDROID_NAMESPACE_TYPE_SHARED,
                                    nullptr, nullptr);
   ASSERT_TRUE(ns_isolated_shared != nullptr) << dlerror();
@@ -885,7 +880,7 @@
   ASSERT_STREQ("dlopen failed: library \"libnstest_root_not_isolated.so\" not found", dlerror());
 
   std::string lib_private_external_path =
-      lib_path + "/private_namespace_libs_external/libnstest_private_external.so";
+      g_testlib_root + "/private_namespace_libs_external/libnstest_private_external.so";
 
   // Load lib_private_external_path to default namespace
   // (it should remain invisible for the isolated namespaces after this)
@@ -969,8 +964,6 @@
 TEST(dlext, ns_shared_dlclose) {
   std::string path = "libc.so:libc++.so:libdl.so:libm.so";
 
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + NATIVE_TESTS_PATH;
-
   android_set_application_target_sdk_version(42U); // something > 23
 
   ASSERT_TRUE(android_init_namespaces(path.c_str(), nullptr)) << dlerror();
@@ -978,12 +971,12 @@
   // preload this library to the default namespace to check if it
   // is shared later on.
   void* handle_dlopened =
-          dlopen((lib_path + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW);
+          dlopen((g_testlib_root + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW);
   ASSERT_TRUE(handle_dlopened != nullptr) << dlerror();
 
   android_namespace_t* ns_isolated_shared =
           android_create_namespace("private_isolated_shared", nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_ISOLATED | ANDROID_NAMESPACE_TYPE_SHARED,
                                    nullptr, nullptr);
   ASSERT_TRUE(ns_isolated_shared != nullptr) << dlerror();
@@ -1004,7 +997,7 @@
   ASSERT_TRUE(handle == nullptr)
       << "Error: libnstest_dlopened.so is still accessible in shared namespace";
 
-  handle = android_dlopen_ext((lib_path + "/private_namespace_libs/libnstest_dlopened.so").c_str(),
+  handle = android_dlopen_ext((g_testlib_root + "/private_namespace_libs/libnstest_dlopened.so").c_str(),
                               RTLD_NOW | RTLD_NOLOAD, &extinfo);
   ASSERT_TRUE(handle == nullptr)
       << "Error: libnstest_dlopened.so is still accessible in shared namespace";
@@ -1013,14 +1006,14 @@
   ASSERT_TRUE(handle == nullptr)
       << "Error: libnstest_dlopened.so is still accessible in default namespace";
 
-  handle = dlopen((lib_path + "/private_namespace_libs/libnstest_dlopened.so").c_str(),
+  handle = dlopen((g_testlib_root + "/private_namespace_libs/libnstest_dlopened.so").c_str(),
                   RTLD_NOW | RTLD_NOLOAD);
   ASSERT_TRUE(handle == nullptr)
       << "Error: libnstest_dlopened.so is still accessible in default namespace";
 
   // Now lets see if the soinfo area gets reused in the wrong way:
   // load a library to default namespace.
-  const std::string lib_public_path = lib_path + "/public_namespace_libs/" + g_public_lib;
+  const std::string lib_public_path = g_testlib_root + "/public_namespace_libs/" + g_public_lib;
   void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW);
   ASSERT_TRUE(handle_public != nullptr) << dlerror();
 
@@ -1036,14 +1029,12 @@
 
   ASSERT_TRUE(android_init_namespaces(path.c_str(), nullptr));
 
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + NATIVE_TESTS_PATH;
-
-  const std::string lib_public_path = lib_path + "/public_namespace_libs";
+  const std::string lib_public_path = g_testlib_root + "/public_namespace_libs";
 
   android_namespace_t* ns1 =
           android_create_namespace("isolated1",
                                    nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_ISOLATED,
                                    lib_public_path.c_str(),
                                    nullptr);
@@ -1052,7 +1043,7 @@
   android_namespace_t* ns2 =
           android_create_namespace("isolated2",
                                    nullptr,
-                                   (lib_path + "/private_namespace_libs").c_str(),
+                                   (g_testlib_root + "/private_namespace_libs").c_str(),
                                    ANDROID_NAMESPACE_TYPE_ISOLATED,
                                    lib_public_path.c_str(),
                                    nullptr);
@@ -1071,7 +1062,7 @@
   android_namespace_t* ns1_child =
         android_create_namespace("isolated1_child",
                                  nullptr,
-                                 (lib_path + "/private_namespace_libs").c_str(),
+                                 (g_testlib_root + "/private_namespace_libs").c_str(),
                                  ANDROID_NAMESPACE_TYPE_ISOLATED,
                                  nullptr,
                                  ns1);
@@ -1106,24 +1097,22 @@
   static const char* root_lib = "libnstest_root.so";
   std::string path = std::string("libc.so:libc++.so:libdl.so:libm.so:") + g_public_lib;
 
-  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + NATIVE_TESTS_PATH;
-
-  const std::string lib_public_path = lib_path + "/public_namespace_libs/" + g_public_lib;
+  const std::string lib_public_path = g_testlib_root + "/public_namespace_libs/" + g_public_lib;
   void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW);
 
   ASSERT_TRUE(handle_public != nullptr) << dlerror();
 
-  ASSERT_TRUE(android_init_namespaces(path.c_str(), (lib_path + "/private_namespace_libs").c_str()))
+  ASSERT_TRUE(android_init_namespaces(path.c_str(), (g_testlib_root + "/private_namespace_libs").c_str()))
       << dlerror();
 
   android_namespace_t* ns = android_create_namespace(
                                 "private", nullptr,
-                                (lib_path + "/private_namespace_libs").c_str(),
+                                (g_testlib_root + "/private_namespace_libs").c_str(),
                                 ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr);
 
   ASSERT_TRUE(ns != nullptr) << dlerror();
 
-  std::string private_library_absolute_path = lib_path + "/private_namespace_libs/" + root_lib;
+  std::string private_library_absolute_path = g_testlib_root + "/private_namespace_libs/" + root_lib;
 
   android_dlextinfo extinfo;
   extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE;
diff --git a/tests/dlfcn_symlink_support.cpp b/tests/dlfcn_symlink_support.cpp
new file mode 100644
index 0000000..be1839e
--- /dev/null
+++ b/tests/dlfcn_symlink_support.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dlfcn_symlink_support.h"
+
+#include <gtest/gtest.h>
+
+#include <dlfcn.h>
+#include <libgen.h>
+#include <link.h>
+#include <unistd.h>
+
+#include <android-base/strings.h>
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+static const constexpr char* source_file_name = "libdlext_test.so";
+static const constexpr char* symlink_name_prefix = "libdlext_test_";
+
+static int dl_callback(struct dl_phdr_info *info, size_t /* size */, void *data) {
+  // The case when path is not absolute and is equal to source_file_name
+  // is disregarded intentionally since in bionic dlpi_name should always
+  // be realpath to a shared object.
+  const std::string suffix = std::string("/") + source_file_name;
+
+  // TODO (dimitry): remove this check once fake libdl.so is gone
+  if (info->dlpi_name == nullptr) {
+    // This is linker imposing as libdl.so - skip it
+    return 0;
+  }
+
+  if (android::base::EndsWith(info->dlpi_name, suffix.c_str())) {
+    std::string* path = reinterpret_cast<std::string*>(data);
+    *path = info->dlpi_name;
+    return 1; // found
+  }
+
+  return 0;
+}
+
+void create_dlfcn_test_symlink(const char* suffix, std::string* result) {
+  void* handle = dlopen(source_file_name, RTLD_NOW);
+  std::string source_file_path;
+
+  ASSERT_TRUE(handle != nullptr) << dlerror();
+  ASSERT_TRUE(dl_iterate_phdr(dl_callback, &source_file_path) == 1)
+      << "dl_phdr_info for \"" << source_file_name << "\" was not found.";
+
+  dlclose(handle);
+  std::vector<char> buf;
+  std::copy(source_file_path.begin(), source_file_path.end(), std::back_inserter(buf));
+  buf.push_back('\0');
+
+  std::string path_dir = dirname(&buf[0]);
+  std::string link_path = path_dir + "/" + symlink_name_prefix + suffix + ".so";
+
+  ASSERT_TRUE(symlink(source_file_path.c_str(), link_path.c_str()) == 0) << strerror(errno);
+  *result = link_path;
+}
+
+void remove_dlfcn_test_symlink(const std::string& path) {
+  ASSERT_TRUE(unlink(path.c_str()) == 0) << strerror(errno);
+}
diff --git a/tests/dlfcn_symlink_support.h b/tests/dlfcn_symlink_support.h
new file mode 100644
index 0000000..8a8d3a2
--- /dev/null
+++ b/tests/dlfcn_symlink_support.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DLFCN_SYMLINK_SUPPORT_H__
+#define __DLFCN_SYMLINK_SUPPORT_H__
+
+#include <string>
+
+void create_dlfcn_test_symlink(const char* suffix, std::string* result);
+void remove_dlfcn_test_symlink(const std::string& path);
+
+class DlfcnSymlink {
+ public:
+  explicit DlfcnSymlink(const char* test_name) {
+    create_dlfcn_test_symlink(test_name, &symlink_path_);
+  }
+
+  ~DlfcnSymlink() {
+    remove_dlfcn_test_symlink(symlink_path_);
+  }
+
+  const std::string& get_symlink_path() const {
+    return symlink_path_;
+  }
+
+ private:
+  std::string symlink_path_;
+};
+
+#endif /* __DLFCN_SYMLINK_SUPPORT_H__ */
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index f842c66..5908fc3 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -17,15 +17,17 @@
 #include <gtest/gtest.h>
 
 #include <dlfcn.h>
-#include <libgen.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <string.h>
 
 #include "private/ScopeGuard.h"
 
 #include <string>
 
+#include "gtest_globals.h"
+#include "dlfcn_symlink_support.h"
 #include "utils.h"
 
 #define ASSERT_SUBSTR(needle, haystack) \
@@ -38,15 +40,24 @@
 }
 
 static int g_ctor_function_called = 0;
+static int g_ctor_argc = 0;
+static char** g_ctor_argv = reinterpret_cast<char**>(0xDEADBEEF);
+static char** g_ctor_envp = g_ctor_envp;
 
-extern "C" void ctor_function() __attribute__ ((constructor));
+extern "C" void ctor_function(int argc, char** argv, char** envp) __attribute__ ((constructor));
 
-extern "C" void ctor_function() {
+extern "C" void ctor_function(int argc, char** argv, char** envp) {
   g_ctor_function_called = 17;
+  g_ctor_argc = argc;
+  g_ctor_argv = argv;
+  g_ctor_envp = envp;
 }
 
 TEST(dlfcn, ctor_function_call) {
   ASSERT_EQ(17, g_ctor_function_called);
+  ASSERT_TRUE(g_ctor_argc = get_argc());
+  ASSERT_TRUE(g_ctor_argv = get_argv());
+  ASSERT_TRUE(g_ctor_envp = get_envp());
 }
 
 TEST(dlfcn, dlsym_in_executable) {
@@ -211,8 +222,8 @@
   dlclose(handle);
 }
 
-// ifuncs are only supported on intel and arm64 for now
-#if defined (__aarch64__) || defined(__i386__) || defined(__x86_64__)
+// mips doesn't support ifuncs
+#if !defined(__mips__)
 TEST(dlfcn, ifunc) {
   typedef const char* (*fn_ptr)();
 
@@ -256,6 +267,21 @@
   ASSERT_STREQ("true", is_ctor_called());
   dlclose(handle);
 }
+
+TEST(dlfcn, ifunc_ctor_call_rtld_lazy) {
+  typedef const char* (*fn_ptr)();
+
+  void* handle = dlopen("libtest_ifunc.so", RTLD_LAZY);
+  ASSERT_TRUE(handle != nullptr) << dlerror();
+  fn_ptr is_ctor_called =  reinterpret_cast<fn_ptr>(dlsym(handle, "is_ctor_called_irelative"));
+  ASSERT_TRUE(is_ctor_called != nullptr) << dlerror();
+  ASSERT_STREQ("false", is_ctor_called());
+
+  is_ctor_called =  reinterpret_cast<fn_ptr>(dlsym(handle, "is_ctor_called_jump_slot"));
+  ASSERT_TRUE(is_ctor_called != nullptr) << dlerror();
+  ASSERT_STREQ("true", is_ctor_called());
+  dlclose(handle);
+}
 #endif
 
 TEST(dlfcn, dlopen_check_relocation_dt_needed_order) {
@@ -988,8 +1014,10 @@
 }
 
 TEST(dlfcn, dlopen_symlink) {
+  DlfcnSymlink symlink("dlopen_symlink");
+  const std::string symlink_name = basename(symlink.get_symlink_path().c_str());
   void* handle1 = dlopen("libdlext_test.so", RTLD_NOW);
-  void* handle2 = dlopen("libdlext_test_v2.so", RTLD_NOW);
+  void* handle2 = dlopen(symlink_name.c_str(), RTLD_NOW);
   ASSERT_TRUE(handle1 != nullptr);
   ASSERT_TRUE(handle2 != nullptr);
   ASSERT_EQ(handle1, handle2);
@@ -1105,8 +1133,12 @@
   dlclose(handle);
 }
 
+// Bionic specific tests
+#if defined(__BIONIC__)
+
 TEST(dlfcn, dt_runpath_absolute_path) {
-  void* handle = dlopen(PATH_TO_SYSTEM_LIB "libtest_dt_runpath_d.so", RTLD_NOW);
+  std::string libpath = g_testlib_root + "/libtest_dt_runpath_d.so";
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
   ASSERT_TRUE(handle != nullptr) << dlerror();
 
   typedef void *(* dlopen_b_fn)();
@@ -1118,3 +1150,103 @@
 
   dlclose(handle);
 }
+
+TEST(dlfcn, dlopen_invalid_rw_load_segment) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-rw_load_segment.so";
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\": W + E load segments are not allowed";
+  ASSERT_STREQ(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_unaligned_shdr_offset) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-unaligned_shdr_offset.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has invalid shdr offset/size: ";
+  ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_zero_shentsize) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-zero_shentsize.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has unsupported e_shentsize: 0x0 (expected 0x";
+  ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_zero_shstrndx) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-zero_shstrndx.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has invalid e_shstrndx";
+  ASSERT_STREQ(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_empty_shdr_table) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-empty_shdr_table.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has no section headers";
+  ASSERT_STREQ(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_zero_shdr_table_offset) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-zero_shdr_table_offset.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has invalid shdr offset/size: 0/";
+  ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_zero_shdr_table_content) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-zero_shdr_table_content.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" .dynamic section header was not found";
+  ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_textrels) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-textrels.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has text relocations";
+  ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
+TEST(dlfcn, dlopen_invalid_textrels2) {
+  const std::string libpath = g_testlib_root +
+                              "/" + kPrebuiltElfDir +
+                              "/libtest_invalid-textrels2.so";
+
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has text relocations";
+  ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
+#endif
diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp
index 3fd0a8c..275a5da 100644
--- a/tests/fcntl_test.cpp
+++ b/tests/fcntl_test.cpp
@@ -18,9 +18,16 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <string.h>
+#include <sys/utsname.h>
 
 #include "TemporaryFile.h"
 
+// Glibc v2.19 doesn't include these in fcntl.h so host builds will fail without.
+#if !defined(FALLOC_FL_PUNCH_HOLE) || !defined(FALLOC_FL_KEEP_SIZE)
+#include <linux/falloc.h>
+#endif
+
 TEST(fcntl, fcntl_smoke) {
   int fd = open("/proc/version", O_RDONLY);
   ASSERT_TRUE(fd != -1);
@@ -237,3 +244,50 @@
   ASSERT_STREQ(expected, buf1);
   ASSERT_STREQ(expected, buf2);
 }
+
+TEST(fcntl, readahead) {
+  // Just check that the function is available.
+  errno = 0;
+  ASSERT_EQ(-1, readahead(-1, 0, 123));
+  ASSERT_EQ(EBADF, errno);
+}
+
+TEST(fcntl, sync_file_range) {
+  // Just check that the function is available.
+  errno = 0;
+  ASSERT_EQ(-1, sync_file_range(-1, 0, 0, 0));
+  ASSERT_EQ(EBADF, errno);
+
+  TemporaryFile tf;
+  ASSERT_EQ(0, sync_file_range(tf.fd, 0, 0, 0));
+
+  // The arguments to the underlying system call are in a different order on 32-bit ARM.
+  // Check that the `flags` argument gets passed to the kernel correctly.
+  errno = 0;
+  ASSERT_EQ(-1, sync_file_range(tf.fd, 0, 0, ~0));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+static bool parse_kernel_release(long* const major, long* const minor) {
+  struct utsname buf;
+  if (uname(&buf) == -1) {
+    return false;
+  }
+  return sscanf(buf.release, "%ld.%ld", major, minor) == 2;
+}
+
+/*
+ * Kernels less than 4.1 are affected.
+ * Devices that fail this test should include change id from Nexus:
+ * Commit: 9b431291a1fadbdbcca1485711b5bab145112293
+ */
+TEST(fcntl, falloc_punch) {
+  long major = 0, minor = 0;
+  ASSERT_TRUE(parse_kernel_release(&major, &minor));
+
+  if (major < 4 || (major == 4 && minor < 1)) {
+    TemporaryFile tf;
+    ASSERT_EQ(-1, fallocate(tf.fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1));
+    ASSERT_EQ(errno, EOPNOTSUPP);
+  }
+}
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 4ffd5f9..e1ff769 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -560,6 +560,12 @@
   ASSERT_FORTIFY(memcpy(bufb, bufa, n));
 }
 
+TEST_F(DEATHTEST, memset_fortified) {
+  char buf[10];
+  size_t n = atoi("11");
+  ASSERT_FORTIFY(memset(buf, 0, n));
+}
+
 TEST_F(DEATHTEST, stpncpy_fortified) {
   char bufa[15];
   char bufb[10];
diff --git a/tests/ftw_test.cpp b/tests/ftw_test.cpp
index b7e5bd5..ea494ba 100644
--- a/tests/ftw_test.cpp
+++ b/tests/ftw_test.cpp
@@ -16,6 +16,7 @@
 
 #include <ftw.h>
 
+#include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
@@ -24,6 +25,7 @@
 
 #include "TemporaryFile.h"
 
+#include <android-base/stringprintf.h>
 #include <gtest/gtest.h>
 
 static void MakeTree(const char* root) {
@@ -39,7 +41,7 @@
   snprintf(path, sizeof(path), "%s/dangler", root);
   ASSERT_EQ(0, symlink("/does-not-exist", path));
   snprintf(path, sizeof(path), "%s/symlink", root);
-  ASSERT_EQ(0, symlink("sub2", path));
+  ASSERT_EQ(0, symlink("dir/sub", path));
 
   int fd;
   snprintf(path, sizeof(path), "%s/regular", root);
@@ -51,8 +53,21 @@
   ASSERT_TRUE(fpath != NULL);
   ASSERT_TRUE(sb != NULL);
 
+  // Was it a case where the struct stat we're given is meaningless?
+  if (tflag == FTW_NS || tflag == FTW_SLN) {
+    // If so, double-check that we really can't stat.
+    struct stat sb;
+    EXPECT_EQ(-1, stat(fpath, &sb));
+    return;
+  }
+
+  // Otherwise check that the struct stat matches the type flag.
   if (S_ISDIR(sb->st_mode)) {
-    EXPECT_TRUE(tflag == FTW_D || tflag == FTW_DNR || tflag == FTW_DP) << fpath;
+    if (access(fpath, R_OK) == 0) {
+      EXPECT_TRUE(tflag == FTW_D || tflag == FTW_DP) << fpath << ' ' << tflag;
+    } else {
+      EXPECT_EQ(FTW_DNR, tflag) << fpath;
+    }
   } else if (S_ISLNK(sb->st_mode)) {
     EXPECT_EQ(FTW_SL, tflag) << fpath;
   } else {
@@ -60,7 +75,7 @@
   }
 }
 
-void sanity_check_nftw(const char* fpath, const struct stat* sb, int tflag, struct FTW* ftwbuf) {
+void sanity_check_nftw(const char* fpath, const struct stat* sb, int tflag, FTW* ftwbuf) {
   sanity_check_ftw(fpath, sb, tflag);
   ASSERT_EQ('/', fpath[ftwbuf->base - 1]) << fpath;
 }
@@ -75,12 +90,12 @@
   return 0;
 }
 
-int check_nftw(const char* fpath, const struct stat* sb, int tflag, struct FTW* ftwbuf) {
+int check_nftw(const char* fpath, const struct stat* sb, int tflag, FTW* ftwbuf) {
   sanity_check_nftw(fpath, sb, tflag, ftwbuf);
   return 0;
 }
 
-int check_nftw64(const char* fpath, const struct stat64* sb, int tflag, struct FTW* ftwbuf) {
+int check_nftw64(const char* fpath, const struct stat64* sb, int tflag, FTW* ftwbuf) {
   sanity_check_nftw(fpath, reinterpret_cast<const struct stat*>(sb), tflag, ftwbuf);
   return 0;
 }
@@ -108,3 +123,33 @@
   MakeTree(root.dirname);
   ASSERT_EQ(0, nftw64(root.dirname, check_nftw64, 128, 0));
 }
+
+template <typename StatT>
+static int bug_28197840_ftw(const char* path, const StatT*, int flag) {
+  EXPECT_EQ(strstr(path, "unreadable") != nullptr ? FTW_DNR : FTW_D, flag) << path;
+  return 0;
+}
+
+template <typename StatT>
+static int bug_28197840_nftw(const char* path, const StatT* sb, int flag, FTW*) {
+  return bug_28197840_ftw(path, sb, flag);
+}
+
+TEST(ftw, bug_28197840) {
+  // Drop root for this test, because root can still read directories even if
+  // permissions would imply otherwise.
+  if (getuid() == 0) {
+    passwd* pwd = getpwnam("shell");
+    ASSERT_EQ(0, setuid(pwd->pw_uid));
+  }
+
+  TemporaryDir root;
+
+  std::string path = android::base::StringPrintf("%s/unreadable-directory", root.dirname);
+  ASSERT_EQ(0, mkdir(path.c_str(), 0000)) << path;
+
+  ASSERT_EQ(0, ftw(root.dirname, bug_28197840_ftw<struct stat>, 128));
+  ASSERT_EQ(0, ftw64(root.dirname, bug_28197840_ftw<struct stat64>, 128));
+  ASSERT_EQ(0, nftw(root.dirname, bug_28197840_nftw<struct stat>, 128, FTW_PHYS));
+  ASSERT_EQ(0, nftw64(root.dirname, bug_28197840_nftw<struct stat64>, 128, FTW_PHYS));
+}
diff --git a/tests/stubs_test.cpp b/tests/grp_pwd_test.cpp
similarity index 78%
rename from tests/stubs_test.cpp
rename to tests/grp_pwd_test.cpp
index c81ca58..a684780 100644
--- a/tests/stubs_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -26,6 +26,10 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <bitset>
+
+#include <private/android_filesystem_config.h>
+
 enum uid_type_t {
   TYPE_SYSTEM,
   TYPE_APP
@@ -122,12 +126,20 @@
   check_get_passwd("radio", 1001, TYPE_SYSTEM);
 }
 
-TEST(getpwnam, oem_id_0) {
-  check_get_passwd("oem_0", 5000, TYPE_SYSTEM);
+TEST(getpwnam, oem_id_5000) {
+  check_get_passwd("oem_5000", 5000, TYPE_SYSTEM);
 }
 
-TEST(getpwnam, oem_id_999) {
-  check_get_passwd("oem_999", 5999, TYPE_SYSTEM);
+TEST(getpwnam, oem_id_5999) {
+  check_get_passwd("oem_5999", 5999, TYPE_SYSTEM);
+}
+
+TEST(getpwnam, oem_id_2900) {
+  check_get_passwd("oem_2900", 2900, TYPE_SYSTEM);
+}
+
+TEST(getpwnam, oem_id_2999) {
+  check_get_passwd("oem_2999", 2999, TYPE_SYSTEM);
 }
 
 TEST(getpwnam, app_id_nobody) {
@@ -171,6 +183,46 @@
   check_get_passwd("u1_i0", 199000, TYPE_APP);
 }
 
+TEST(getpwent, iterate) {
+  passwd* pwd;
+  std::bitset<10000> exist;
+  bool application = false;
+
+  exist.reset();
+
+  setpwent();
+  while ((pwd = getpwent()) != NULL) {
+    ASSERT_TRUE(NULL != pwd->pw_name);
+    ASSERT_EQ(pwd->pw_gid, pwd->pw_uid);
+    ASSERT_EQ(NULL, pwd->pw_passwd);
+#ifdef __LP64__
+    ASSERT_TRUE(NULL == pwd->pw_gecos);
+#endif
+    ASSERT_TRUE(NULL != pwd->pw_shell);
+    if (pwd->pw_uid >= exist.size()) {
+      ASSERT_STREQ("/data", pwd->pw_dir);
+      application = true;
+    } else {
+      ASSERT_STREQ("/", pwd->pw_dir);
+      ASSERT_FALSE(exist[pwd->pw_uid]);
+      exist[pwd->pw_uid] = true;
+    }
+  }
+  endpwent();
+
+  // Required content
+  for (size_t n = 0; n < android_id_count; ++n) {
+    ASSERT_TRUE(exist[android_ids[n].aid]);
+  }
+  for (size_t n = 2900; n < 2999; ++n) {
+    ASSERT_TRUE(exist[n]);
+  }
+  for (size_t n = 5000; n < 5999; ++n) {
+    ASSERT_TRUE(exist[n]);
+  }
+  ASSERT_TRUE(application);
+}
+
 static void check_group(const group* grp, const char* group_name, gid_t gid) {
   ASSERT_TRUE(grp != NULL);
   ASSERT_STREQ(group_name, grp->gr_name);
@@ -255,12 +307,20 @@
   check_get_group("radio", 1001);
 }
 
-TEST(getgrnam, oem_id_0) {
-  check_get_group("oem_0", 5000);
+TEST(getgrnam, oem_id_5000) {
+  check_get_group("oem_5000", 5000);
 }
 
-TEST(getgrnam, oem_id_999) {
-  check_get_group("oem_999", 5999);
+TEST(getgrnam, oem_id_5999) {
+  check_get_group("oem_5999", 5999);
+}
+
+TEST(getgrnam, oem_id_2900) {
+  check_get_group("oem_2900", 2900);
+}
+
+TEST(getgrnam, oem_id_2999) {
+  check_get_group("oem_2999", 2999);
 }
 
 TEST(getgrnam, app_id_nobody) {
@@ -357,3 +417,38 @@
   ASSERT_EQ(0, getgrnam_r("root", &grp_storage, buf, size, &grp));
   check_group(grp, "root", 0);
 }
+
+TEST(getgrent, iterate) {
+  group* grp;
+  std::bitset<10000> exist;
+  bool application = false;
+
+  exist.reset();
+
+  setgrent();
+  while ((grp = getgrent()) != NULL) {
+    ASSERT_TRUE(grp->gr_name != NULL);
+    ASSERT_TRUE(grp->gr_mem != NULL);
+    ASSERT_STREQ(grp->gr_name, grp->gr_mem[0]);
+    ASSERT_TRUE(grp->gr_mem[1] == NULL);
+    if (grp->gr_gid >= exist.size()) {
+      application = true;
+    } else {
+      ASSERT_FALSE(exist[grp->gr_gid]);
+      exist[grp->gr_gid] = true;
+    }
+  }
+  endgrent();
+
+  // Required content
+  for (size_t n = 0; n < android_id_count; ++n) {
+    ASSERT_TRUE(exist[android_ids[n].aid]);
+  }
+  for (size_t n = 2900; n < 2999; ++n) {
+    ASSERT_TRUE(exist[n]);
+  }
+  for (size_t n = 5000; n < 5999; ++n) {
+    ASSERT_TRUE(exist[n]);
+  }
+  ASSERT_TRUE(application);
+}
diff --git a/tests/gtest_globals.cpp b/tests/gtest_globals.cpp
new file mode 100644
index 0000000..4f2c82e
--- /dev/null
+++ b/tests/gtest_globals.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "gtest_globals.h"
+
+#include <gtest/gtest.h>
+#include "utils.h"
+
+#include <string>
+
+static std::string get_testlib_root() {
+  std::string out_path;
+  const char* data_dir = getenv("ANDROID_DATA");
+  if (data_dir == nullptr) {
+    out_path = "/data";
+  } else {
+    out_path = data_dir;
+  }
+
+  out_path = out_path + "/nativetest";
+#if defined(__LP64__)
+  out_path += "64";
+#endif
+  out_path += "/bionic-loader-test-libs";
+  std::string real_path;
+  if (!get_realpath(out_path, &real_path)) {
+    abort();
+  }
+
+  return real_path;
+}
+
+const std::string g_testlib_root = get_testlib_root();
diff --git a/tests/gtest_globals.h b/tests/gtest_globals.h
new file mode 100644
index 0000000..fab2a39
--- /dev/null
+++ b/tests/gtest_globals.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_TESTS_GTEST_GLOBALS_H
+#define _BIONIC_TESTS_GTEST_GLOBALS_H
+
+#include <string>
+
+constexpr const char* kPrebuiltElfDir = "prebuilt-elf-files";
+
+extern const std::string g_testlib_root;
+
+#endif  // _BIONIC_TESTS_GTEST_GLOBALS_H
diff --git a/tests/gtest_globals_cts.cpp b/tests/gtest_globals_cts.cpp
new file mode 100644
index 0000000..bf891a1
--- /dev/null
+++ b/tests/gtest_globals_cts.cpp
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "gtest_globals.h"
+
+#include <string>
+
+const std::string g_testlib_root = "/data/local/tmp/lib/bionic-loader-test-libs";
diff --git a/tests/gtest_main.cpp b/tests/gtest_main.cpp
index 2b58646..aacf9ae 100644
--- a/tests/gtest_main.cpp
+++ b/tests/gtest_main.cpp
@@ -47,11 +47,36 @@
 #endif
 
 static std::string g_executable_path;
+static int g_argc;
+static char** g_argv;
+static char** g_envp;
 
 const std::string& get_executable_path() {
   return g_executable_path;
 }
 
+bool get_realpath(const std::string& path, std::string* real_path) {
+  char realpath_buf[PATH_MAX];
+  if (realpath(path.c_str(), realpath_buf) != realpath_buf) {
+    return false;
+  }
+
+  *real_path = realpath_buf;
+  return true;
+}
+
+int get_argc() {
+  return g_argc;
+}
+
+char** get_argv() {
+  return g_argv;
+}
+
+char** get_envp() {
+  return g_envp;
+}
+
 namespace testing {
 namespace internal {
 
@@ -76,7 +101,7 @@
 using testing::internal::ColoredPrintf;
 
 constexpr int DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS = 90000;
-constexpr int DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS = 2000;
+constexpr int DEFAULT_GLOBAL_TEST_RUN_SLOW_THRESHOLD_MS = 2000;
 
 // The time each test can run before killed for the reason of timeout.
 // It takes effect only with --isolate option.
@@ -84,16 +109,16 @@
 
 // The time each test can run before be warned for too much running time.
 // It takes effect only with --isolate option.
-static int global_test_run_warnline_ms = DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS;
+static int global_test_run_slow_threshold_ms = DEFAULT_GLOBAL_TEST_RUN_SLOW_THRESHOLD_MS;
 
-// Return deadline duration for a test, in ms.
-static int GetDeadlineInfo(const std::string& /*test_name*/) {
+// Return timeout duration for a test, in ms.
+static int GetTimeoutMs(const std::string& /*test_name*/) {
   return global_test_run_deadline_ms;
 }
 
-// Return warnline duration for a test, in ms.
-static int GetWarnlineInfo(const std::string& /*test_name*/) {
-  return global_test_run_warnline_ms;
+// Return threshold for calling a test slow, in ms.
+static int GetSlowThresholdMs(const std::string& /*test_name*/) {
+  return global_test_run_slow_threshold_ms;
 }
 
 static void PrintHelpInfo() {
@@ -106,10 +131,10 @@
          "      Don't use isolation mode, run all tests in a single process.\n"
          "  --deadline=[TIME_IN_MS]\n"
          "      Run each test in no longer than [TIME_IN_MS] time.\n"
-         "      It takes effect only in isolation mode. Deafult deadline is 90000 ms.\n"
-         "  --warnline=[TIME_IN_MS]\n"
-         "      Test running longer than [TIME_IN_MS] will be warned.\n"
-         "      It takes effect only in isolation mode. Default warnline is 2000 ms.\n"
+         "      Only valid in isolation mode. Default deadline is 90000 ms.\n"
+         "  --slow-threshold=[TIME_IN_MS]\n"
+         "      Test running longer than [TIME_IN_MS] will be called slow.\n"
+         "      Only valid in isolation mode. Default slow threshold is 2000 ms.\n"
          "  --gtest-filter=POSITIVE_PATTERNS[-NEGATIVE_PATTERNS]\n"
          "      Used as a synonym for --gtest_filter option in gtest.\n"
          "Default bionic unit test option is -j.\n"
@@ -291,7 +316,7 @@
 // PrettyUnitTestResultPrinter. The reason for copy is that PrettyUnitTestResultPrinter
 // is defined and used in gtest.cc, which is hard to reuse.
 static void OnTestIterationStartPrint(const std::vector<TestCase>& testcase_list, size_t iteration,
-                                      int iteration_count) {
+                                      int iteration_count, size_t job_count) {
   if (iteration_count != 1) {
     printf("\nRepeating all tests (iteration %zu) . . .\n\n", iteration);
   }
@@ -303,9 +328,10 @@
     test_count += testcase.TestCount();
   }
 
-  printf("Running %zu %s from %zu %s.\n",
+  printf("Running %zu %s from %zu %s (%zu %s).\n",
          test_count, (test_count == 1) ? "test" : "tests",
-         testcase_count, (testcase_count == 1) ? "test case" : "test cases");
+         testcase_count, (testcase_count == 1) ? "test case" : "test cases",
+         job_count, (job_count == 1) ? "job" : "jobs");
   fflush(stdout);
 }
 
@@ -364,7 +390,7 @@
   std::vector<std::string> fail_test_name_list;
   std::vector<std::pair<std::string, int64_t>> timeout_test_list;
 
-  // For tests run exceed warnline but not timeout.
+  // For tests that were slow but didn't time out.
   std::vector<std::tuple<std::string, int64_t, int>> slow_test_list;
   size_t testcase_count = testcase_list.size();
   size_t test_count = 0;
@@ -383,10 +409,10 @@
                                                    testcase.GetTestTime(i)));
       }
       if (result != TEST_TIMEOUT &&
-          testcase.GetTestTime(i) / 1000000 >= GetWarnlineInfo(testcase.GetTestName(i))) {
+          testcase.GetTestTime(i) / 1000000 >= GetSlowThresholdMs(testcase.GetTestName(i))) {
         slow_test_list.push_back(std::make_tuple(testcase.GetTestName(i),
                                                  testcase.GetTestTime(i),
-                                                 GetWarnlineInfo(testcase.GetTestName(i))));
+                                                 GetSlowThresholdMs(testcase.GetTestName(i))));
       }
     }
   }
@@ -401,18 +427,7 @@
   ColoredPrintf(COLOR_GREEN,  "[   PASS   ] ");
   printf("%zu %s.\n", success_test_count, (success_test_count == 1) ? "test" : "tests");
 
-  // Print tests failed.
-  size_t fail_test_count = fail_test_name_list.size();
-  if (fail_test_count > 0) {
-    ColoredPrintf(COLOR_RED,  "[   FAIL   ] ");
-    printf("%zu %s, listed below:\n", fail_test_count, (fail_test_count == 1) ? "test" : "tests");
-    for (const auto& name : fail_test_name_list) {
-      ColoredPrintf(COLOR_RED, "[   FAIL   ] ");
-      printf("%s\n", name.c_str());
-    }
-  }
-
-  // Print tests run timeout.
+  // Print tests that timed out.
   size_t timeout_test_count = timeout_test_list.size();
   if (timeout_test_count > 0) {
     ColoredPrintf(COLOR_RED, "[ TIMEOUT  ] ");
@@ -424,27 +439,42 @@
     }
   }
 
-  // Print tests run exceed warnline.
+  // Print tests that were slow.
   size_t slow_test_count = slow_test_list.size();
   if (slow_test_count > 0) {
     ColoredPrintf(COLOR_YELLOW, "[   SLOW   ] ");
     printf("%zu %s, listed below:\n", slow_test_count, (slow_test_count == 1) ? "test" : "tests");
     for (const auto& slow_tuple : slow_test_list) {
       ColoredPrintf(COLOR_YELLOW, "[   SLOW   ] ");
-      printf("%s (%" PRId64 " ms, exceed warnline %d ms)\n", std::get<0>(slow_tuple).c_str(),
+      printf("%s (%" PRId64 " ms, exceeded %d ms)\n", std::get<0>(slow_tuple).c_str(),
              std::get<1>(slow_tuple) / 1000000, std::get<2>(slow_tuple));
     }
   }
 
+  // Print tests that failed.
+  size_t fail_test_count = fail_test_name_list.size();
   if (fail_test_count > 0) {
-    printf("\n%2zu FAILED %s\n", fail_test_count, (fail_test_count == 1) ? "TEST" : "TESTS");
+    ColoredPrintf(COLOR_RED,  "[   FAIL   ] ");
+    printf("%zu %s, listed below:\n", fail_test_count, (fail_test_count == 1) ? "test" : "tests");
+    for (const auto& name : fail_test_name_list) {
+      ColoredPrintf(COLOR_RED, "[   FAIL   ] ");
+      printf("%s\n", name.c_str());
+    }
   }
+
+  if (timeout_test_count > 0 || slow_test_count > 0 || fail_test_count > 0) {
+    printf("\n");
+  }
+
   if (timeout_test_count > 0) {
     printf("%2zu TIMEOUT %s\n", timeout_test_count, (timeout_test_count == 1) ? "TEST" : "TESTS");
   }
   if (slow_test_count > 0) {
     printf("%2zu SLOW %s\n", slow_test_count, (slow_test_count == 1) ? "TEST" : "TESTS");
   }
+  if (fail_test_count > 0) {
+    printf("%2zu FAILED %s\n", fail_test_count, (fail_test_count == 1) ? "TEST" : "TESTS");
+  }
   fflush(stdout);
 }
 
@@ -647,7 +677,7 @@
   child_proc.child_read_fd = pipefd[0];
   child_proc.pid = pid;
   child_proc.start_time_ns = NanoTime();
-  child_proc.deadline_end_time_ns = child_proc.start_time_ns + GetDeadlineInfo(test_name) * 1000000LL;
+  child_proc.deadline_end_time_ns = child_proc.start_time_ns + GetTimeoutMs(test_name) * 1000000LL;
   child_proc.testcase_id = testcase_id;
   child_proc.test_id = test_id;
   child_proc.finished = false;
@@ -841,7 +871,7 @@
   for (size_t iteration = 1;
        iteration_count < 0 || iteration <= static_cast<size_t>(iteration_count);
        ++iteration) {
-    OnTestIterationStartPrint(testcase_list, iteration, iteration_count);
+    OnTestIterationStartPrint(testcase_list, iteration, iteration_count, job_count);
     int64_t iteration_start_time_ns = NanoTime();
     time_t epoch_iteration_start_time = time(NULL);
 
@@ -941,7 +971,7 @@
   bool isolate;
   size_t job_count;
   int test_deadline_ms;
-  int test_warnline_ms;
+  int test_slow_threshold_ms;
   std::string gtest_color;
   bool gtest_print_time;
   int gtest_repeat;
@@ -1019,7 +1049,7 @@
   // Init default isolation test options.
   options.job_count = GetDefaultJobCount();
   options.test_deadline_ms = DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS;
-  options.test_warnline_ms = DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS;
+  options.test_slow_threshold_ms = DEFAULT_GLOBAL_TEST_RUN_SLOW_THRESHOLD_MS;
   options.gtest_color = testing::GTEST_FLAG(color);
   options.gtest_print_time = testing::GTEST_FLAG(print_time);
   options.gtest_repeat = testing::GTEST_FLAG(repeat);
@@ -1050,13 +1080,13 @@
         return false;
       }
       options.test_deadline_ms = time_ms;
-    } else if (strncmp(args[i], "--warnline=", strlen("--warnline=")) == 0) {
-      int time_ms = atoi(args[i] + strlen("--warnline="));
+    } else if (strncmp(args[i], "--slow-threshold=", strlen("--slow-threshold=")) == 0) {
+      int time_ms = atoi(args[i] + strlen("--slow-threshold="));
       if (time_ms <= 0) {
-        fprintf(stderr, "invalid warnline: %d\n", time_ms);
+        fprintf(stderr, "invalid slow test threshold: %d\n", time_ms);
         return false;
       }
-      options.test_warnline_ms = time_ms;
+      options.test_slow_threshold_ms = time_ms;
     } else if (strncmp(args[i], "--gtest_color=", strlen("--gtest_color=")) == 0) {
       options.gtest_color = args[i] + strlen("--gtest_color=");
     } else if (strcmp(args[i], "--gtest_print_time=0") == 0) {
@@ -1122,8 +1152,11 @@
   return std::string(path, path_len);
 }
 
-int main(int argc, char** argv) {
+int main(int argc, char** argv, char** envp) {
   g_executable_path = get_proc_self_exe();
+  g_argc = argc;
+  g_argv = argv;
+  g_envp = envp;
   std::vector<char*> arg_list;
   for (int i = 0; i < argc; ++i) {
     arg_list.push_back(argv[i]);
@@ -1137,7 +1170,7 @@
   if (options.isolate == true) {
     // Set global variables.
     global_test_run_deadline_ms = options.test_deadline_ms;
-    global_test_run_warnline_ms = options.test_warnline_ms;
+    global_test_run_slow_threshold_ms = options.test_slow_threshold_ms;
     testing::GTEST_FLAG(color) = options.gtest_color.c_str();
     testing::GTEST_FLAG(print_time) = options.gtest_print_time;
     std::vector<TestCase> testcase_list;
diff --git a/tests/ifaddrs_test.cpp b/tests/ifaddrs_test.cpp
index 9f01619..4b9d4d8 100644
--- a/tests/ifaddrs_test.cpp
+++ b/tests/ifaddrs_test.cpp
@@ -19,6 +19,7 @@
 #include <ifaddrs.h>
 
 #include <dirent.h>
+#include <fcntl.h>
 #include <linux/if_packet.h>
 #include <net/ethernet.h>
 #include <net/if.h>
@@ -28,6 +29,7 @@
 
 #include <algorithm>
 #include <map>
+#include <thread>
 #include <vector>
 
 TEST(ifaddrs, freeifaddrs_null) {
@@ -267,3 +269,40 @@
 
   freeifaddrs(addrs);
 }
+
+TEST(ifaddrs, kernel_bug_31038971) {
+  // Some kernels had a bug that would lead to an NLMSG_ERROR response,
+  // but bionic wasn't setting errno based on the value in the message.
+  // This is the test for the kernel bug, but on a device with a bad
+  // kernel this test was also useful for testing the bionic errno fix.
+  std::vector<std::thread*> threads;
+  for (size_t i = 0; i < 128; ++i) {
+    threads.push_back(new std::thread([]() {
+      ifaddrs* addrs = nullptr;
+      ASSERT_EQ(0, getifaddrs(&addrs)) << strerror(errno);
+      freeifaddrs(addrs);
+    }));
+  }
+  for (auto& t : threads) {
+    t->join();
+    delete t;
+  }
+}
+
+TEST(ifaddrs, errno_EMFILE) {
+  std::vector<int> fds;
+  while (true) {
+    int fd = open("/dev/null", O_RDONLY|O_CLOEXEC);
+    if (fd == -1) {
+      ASSERT_EQ(EMFILE, errno);
+      break;
+    }
+    fds.push_back(fd);
+  }
+
+  ifaddrs* addrs;
+  EXPECT_EQ(-1, getifaddrs(&addrs));
+  EXPECT_EQ(EMFILE, errno);
+
+  for (int fd : fds) close(fd);
+}
diff --git a/tests/inttypes_test.cpp b/tests/inttypes_test.cpp
index dbbb6d4..80580a4 100644
--- a/tests/inttypes_test.cpp
+++ b/tests/inttypes_test.cpp
@@ -20,24 +20,81 @@
 #include <gtest/gtest.h>
 #include <stdio.h>
 
-TEST(inttypes, misc) {
-  char buf[512];
+#define PRINTF_TYPED(FMT_SUFFIX, TYPE_SUFFIX) \
+  do { \
+    char buf[512]; \
+    memset(buf, 0, sizeof(buf)); \
+    snprintf(buf, sizeof(buf), "%" PRId##FMT_SUFFIX, int##TYPE_SUFFIX(123)); \
+    EXPECT_STREQ("123", buf); \
+    memset(buf, 0, sizeof(buf)); \
+    snprintf(buf, sizeof(buf), "%" PRIi##FMT_SUFFIX, int##TYPE_SUFFIX(123)); \
+    EXPECT_STREQ("123", buf); \
+    memset(buf, 0, sizeof(buf)); \
+    snprintf(buf, sizeof(buf), "%" PRIo##FMT_SUFFIX, int##TYPE_SUFFIX(123)); \
+    EXPECT_STREQ("173", buf); \
+    memset(buf, 0, sizeof(buf)); \
+    snprintf(buf, sizeof(buf), "%" PRIu##FMT_SUFFIX, uint##TYPE_SUFFIX(123)); \
+    EXPECT_STREQ("123", buf); \
+    memset(buf, 0, sizeof(buf)); \
+    snprintf(buf, sizeof(buf), "%" PRIx##FMT_SUFFIX, uint##TYPE_SUFFIX(123)); \
+    EXPECT_STREQ("7b", buf); \
+    memset(buf, 0, sizeof(buf)); \
+    snprintf(buf, sizeof(buf), "%" PRIX##FMT_SUFFIX, uint##TYPE_SUFFIX(123)); \
+    EXPECT_STREQ("7B", buf); \
+  } while (false) \
 
-  intptr_t i = 0;
-  uintptr_t u = 0;
+#define PRINTF_SIZED(WIDTH) \
+  PRINTF_TYPED(WIDTH, WIDTH##_t); \
+  PRINTF_TYPED(FAST##WIDTH, _fast##WIDTH##_t); \
+  PRINTF_TYPED(LEAST##WIDTH, _least##WIDTH##_t) \
 
-  snprintf(buf, sizeof(buf), "%08" PRIdPTR, i);
-  snprintf(buf, sizeof(buf), "%08" PRIiPTR, i);
-  snprintf(buf, sizeof(buf), "%08" PRIoPTR, i);
-  snprintf(buf, sizeof(buf), "%08" PRIuPTR, u);
-  snprintf(buf, sizeof(buf), "%08" PRIxPTR, u);
-  snprintf(buf, sizeof(buf), "%08" PRIXPTR, u);
 
-  sscanf(buf, "%08" SCNdPTR, &i);
-  sscanf(buf, "%08" SCNiPTR, &i);
-  sscanf(buf, "%08" SCNoPTR, &u);
-  sscanf(buf, "%08" SCNuPTR, &u);
-  sscanf(buf, "%08" SCNxPTR, &u);
+#define SCANF_TYPED(FMT_SUFFIX, TYPE_SUFFIX) \
+  do { \
+    int##TYPE_SUFFIX dst_int##TYPE_SUFFIX = 0; \
+    uint##TYPE_SUFFIX dst_uint##TYPE_SUFFIX = 0u; \
+    \
+    sscanf("123", "%" SCNd##FMT_SUFFIX, &dst_int##TYPE_SUFFIX); \
+    EXPECT_EQ(123, dst_int##TYPE_SUFFIX); \
+    dst_int##TYPE_SUFFIX = 0; \
+    sscanf("123", "%" SCNi##FMT_SUFFIX, &dst_int##TYPE_SUFFIX); \
+    EXPECT_EQ(123, dst_int##TYPE_SUFFIX); \
+    dst_int##TYPE_SUFFIX = 0; \
+    sscanf("173", "%" SCNo##FMT_SUFFIX, &dst_int##TYPE_SUFFIX); \
+    EXPECT_EQ(123, dst_int##TYPE_SUFFIX); \
+    dst_int##TYPE_SUFFIX = 0; \
+    sscanf("123", "%" SCNu##FMT_SUFFIX, &dst_uint##TYPE_SUFFIX); \
+    EXPECT_EQ(123u, dst_uint##TYPE_SUFFIX); \
+    dst_uint##TYPE_SUFFIX = 0; \
+    sscanf("7B", "%" SCNx##FMT_SUFFIX, &dst_uint##TYPE_SUFFIX); \
+    EXPECT_EQ(123u, dst_uint##TYPE_SUFFIX); \
+    dst_uint##TYPE_SUFFIX = 0; \
+  } while (false) \
+
+#define SCANF_SIZED(SIZE) \
+  SCANF_TYPED(SIZE, SIZE##_t); \
+  SCANF_TYPED(FAST##SIZE, _fast##SIZE##_t); \
+  SCANF_TYPED(LEAST##SIZE, _least##SIZE##_t) \
+
+
+TEST(inttypes, printf_macros) {
+  PRINTF_SIZED(8);
+  PRINTF_SIZED(16);
+  PRINTF_SIZED(32);
+  PRINTF_SIZED(64);
+
+  PRINTF_TYPED(MAX, max_t);
+  PRINTF_TYPED(PTR, ptr_t);
+}
+
+TEST(inttypes, scanf_macros) {
+  SCANF_SIZED(8);
+  SCANF_SIZED(16);
+  SCANF_SIZED(32);
+  SCANF_SIZED(64);
+
+  SCANF_TYPED(MAX, max_t);
+  SCANF_TYPED(PTR, ptr_t);
 }
 
 TEST(inttypes, wcstoimax) {
diff --git a/tests/libc_logging_test.cpp b/tests/libc_logging_test.cpp
index d4ceded..4150483 100644
--- a/tests/libc_logging_test.cpp
+++ b/tests/libc_logging_test.cpp
@@ -133,7 +133,7 @@
 #if defined(__BIONIC__)
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
-#if __LP64__
+#if defined(__LP64__)
   EXPECT_STREQ("9223372036854775807", buf);
 #else
   EXPECT_STREQ("2147483647", buf);
@@ -147,7 +147,7 @@
 #if defined(__BIONIC__)
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
-#if __LP64__
+#if defined(__LP64__)
   EXPECT_STREQ("-9223372036854775808", buf);
 #else
   EXPECT_STREQ("-2147483648", buf);
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
new file mode 100644
index 0000000..fe0d6ab
--- /dev/null
+++ b/tests/libs/Android.bp
@@ -0,0 +1,458 @@
+//
+// Copyright (C) 2012 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_defaults {
+    name: "bionic_testlib_defaults",
+    host_supported: true,
+    ldflags: [
+        "-Wl,--rpath,${ORIGIN}",
+        "-Wl,--enable-new-dtags",
+    ],
+    relative_install_path: "bionic-loader-test-libs",
+    gtest: false,
+    sanitize: {
+        never: true,
+    },
+    target: {
+        darwin: {
+            enabled: false,
+        },
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Library to test gnu-styled hash
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libgnu-hash-table-library",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlext_test_library.cpp"],
+    ldflags: ["-Wl,--hash-style=gnu"],
+    arch: {
+        mips: {
+            enabled: false,
+        },
+        mips64: {
+            enabled: false,
+        },
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Library to test sysv-styled hash
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libsysv-hash-table-library",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlext_test_library.cpp"],
+    ldflags: ["-Wl,--hash-style=sysv"],
+}
+
+// -----------------------------------------------------------------------------
+// Library used by dlext tests - with GNU RELRO program header
+// -----------------------------------------------------------------------------
+// In Android.mk to support creating symlinks
+
+// -----------------------------------------------------------------------------
+// Library used by dlext tests - without GNU RELRO program header
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libdlext_test_norelro",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlext_test_library.cpp"],
+    ldflags: ["-Wl,-z,norelro"],
+    shared_libs = ["libtest_simple"],
+}
+
+// -----------------------------------------------------------------------------
+// Library used by dlext tests - different name non-default location
+// -----------------------------------------------------------------------------
+// In Android.mk to support installing to /data
+
+// -----------------------------------------------------------------------------
+// Libraries used by dlext tests for open from a zip-file
+// -----------------------------------------------------------------------------
+// In Android.mk to support installing to /data
+
+// ----------------------------------------------------------------------------
+// Library with soname which does not match filename
+// ----------------------------------------------------------------------------
+// In Android.mk to support zipped and aligned tests
+
+// -----------------------------------------------------------------------------
+// Library used by dlext tests - zipped and aligned
+// -----------------------------------------------------------------------------
+// In Android.mk to support zipped and aligned tests
+
+// -----------------------------------------------------------------------------
+// Library used by dlfcn tests
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_simple",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_simple.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library used by dlfcn nodelete tests
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_nodelete_1",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_nodelete_1.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library used by dlfcn nodelete tests
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_nodelete_2",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_nodelete_2.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library used by dlfcn nodelete tests
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_nodelete_dt_flags_1",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_nodelete_dt_flags_1.cpp"],
+    ldflags: ["-Wl,-z,nodelete"],
+}
+
+// -----------------------------------------------------------------------------
+// Build test helper libraries for linker namespaces
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.linker_namespaces.mk
+
+// -----------------------------------------------------------------------------
+// Build DT_RUNPATH test helper libraries
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.dt_runpath.mk
+
+// -----------------------------------------------------------------------------
+// Build library with two parents
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.dlopen_2_parents_reloc.mk
+
+// -----------------------------------------------------------------------------
+// Build libtest_check_order_dlsym.so with its dependencies.
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.dlopen_check_order_dlsym.mk
+
+// -----------------------------------------------------------------------------
+// Build libtest_check_order_siblings.so with its dependencies.
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_siblings.mk
+
+// -----------------------------------------------------------------------------
+// Build libtest_check_order_root.so with its dependencies.
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_main_executable.mk
+
+// -----------------------------------------------------------------------------
+// Build libtest_versioned_lib.so with its dependencies.
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.versioned_lib.mk
+
+// -----------------------------------------------------------------------------
+// Build libraries needed by pthread_atfork tests
+// -----------------------------------------------------------------------------
+// include $(LOCAL_PATH)/Android.build.pthread_atfork.mk
+
+// -----------------------------------------------------------------------------
+// Library with dependency loop used by dlfcn tests
+//
+// libtest_with_dependency_loop -> a -> b -> c -> a
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_with_dependency_loop",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_loopy_root.cpp"],
+    shared_libs: ["libtest_with_dependency_loop_a"],
+}
+
+// -----------------------------------------------------------------------------
+// libtest_with_dependency_loop_a.so
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_with_dependency_loop_a",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_loopy_a.cpp"],
+    shared_libs: ["libtest_with_dependency_loop_b_tmp"],
+}
+
+// -----------------------------------------------------------------------------
+// libtest_with_dependency_loop_b.so
+//
+// this is temporary placeholder - will be removed
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_with_dependency_loop_b_tmp",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_loopy_invalid.cpp"],
+    ldflags: ["-Wl,-soname=libtest_with_dependency_loop_b.so"],
+}
+
+// -----------------------------------------------------------------------------
+// libtest_with_dependency_loop_b.so
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_with_dependency_loop_b",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_loopy_b.cpp"],
+    shared_libs: ["libtest_with_dependency_loop_c"],
+}
+
+// -----------------------------------------------------------------------------
+// libtest_with_dependency_loop_c.so
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_with_dependency_loop_c",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_loopy_c.cpp"],
+    shared_libs: ["libtest_with_dependency_loop_a"],
+}
+
+// -----------------------------------------------------------------------------
+// libtest_relo_check_dt_needed_order.so
+// |
+// +-> libtest_relo_check_dt_needed_order_1.so
+// |
+// +-> libtest_relo_check_dt_needed_order_2.so
+// -----------------------------------------------------------------------------
+
+
+cc_test_library {
+    name: "libtest_relo_check_dt_needed_order",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_relo_check_dt_needed_order.cpp"],
+    shared_libs: [
+        "libtest_relo_check_dt_needed_order_1",
+        "libtest_relo_check_dt_needed_order_2",
+    ],
+}
+
+cc_test_library {
+    name: "libtest_relo_check_dt_needed_order_1",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_relo_check_dt_needed_order_1.cpp"],
+}
+
+cc_test_library {
+    name: "libtest_relo_check_dt_needed_order_2",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_relo_check_dt_needed_order_2.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library with dependency used by dlfcn tests
+// -----------------------------------------------------------------------------
+// In Android.mk to support dependency on libdlext_test
+
+// -----------------------------------------------------------------------------
+// Library used by ifunc tests
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_ifunc",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_ifunc.c"],
+
+    // TODO(dimitry): clang does not support ifunc attribute
+    clang: false,
+    arch: {
+        mips: {
+            enabled: false,
+        },
+        mips64: {
+            enabled: false,
+        },
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Library used by atexit tests
+// -----------------------------------------------------------------------------
+
+cc_test_library {
+    name: "libtest_atexit",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["atexit_testlib.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// This library is used by dl_load test to check symbol preempting
+// by main executable
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libdl_preempt_test_1",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dl_preempt_library_1.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// This library is used by dl_load test to check symbol preempting
+// by libdl_preempt_test_1.so
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libdl_preempt_test_2",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dl_preempt_library_2.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library with DF_1_GLOBAL
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libdl_test_df_1_global",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dl_df_1_global.cpp"],
+    ldflags: ["-Wl,-z,global"],
+
+    target: {
+        host: {
+            // TODO (dimitry): host ld.gold does not yet support -z global
+            // remove this line once it is updated.
+            ldflags: ["-fuse-ld=bfd"],
+        },
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Library using symbol from libdl_test_df_1_global
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlsym_df_1_global",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dl_df_1_use_global.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library with weak function
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlsym_weak_func",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlsym_weak_function.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library to check RTLD_LOCAL with dlsym in 'this'
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlsym_from_this",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlsym_from_this_symbol.cpp"],
+    shared_libs: ["libtest_dlsym_from_this_child"],
+
+    target: {
+        android: {
+            shared_libs: ["libdl"],
+        },
+        host: {
+            host_ldlibs: ["-ldl"],
+        },
+    },
+}
+
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlsym_from_this_child",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlsym_from_this_functions.cpp"],
+    shared_libs: ["libtest_dlsym_from_this_grandchild"],
+    target: {
+        android: {
+            shared_libs: ["libdl"],
+        },
+        host: {
+            host_ldlibs: ["-ldl"],
+        },
+    },
+}
+
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlsym_from_this_grandchild",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlsym_from_this_symbol2.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Empty library
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_empty",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["empty.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library with weak undefined function
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlopen_weak_undefined_func",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_weak_undefined.cpp"],
+}
+
+// -----------------------------------------------------------------------------
+// Library with constructor that calls dlopen() b/7941716
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlopen_from_ctor",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["dlopen_testlib_dlopen_from_ctor.cpp"],
+    target: {
+        android: {
+            shared_libs: ["libdl"],
+        },
+        host: {
+            host_ldlibs: ["-ldl"],
+        },
+    },
+}
+
+// -----------------------------------------------------------------------------
+// Library that depends on the library with constructor that calls dlopen() b/7941716
+// -----------------------------------------------------------------------------
+cc_test_library {
+    name: "libtest_dlopen_from_ctor_main",
+    defaults: ["bionic_testlib_defaults"],
+    srcs: ["empty.cpp"],
+    shared_libs: ["libtest_dlopen_from_ctor"],
+}
+
+// -----------------------------------------------------------------------------
+// Tool to use to align the shared libraries in a zip file.
+// -----------------------------------------------------------------------------
+cc_binary_host {
+    name: "bionic_tests_zipalign",
+    srcs: ["bionic_tests_zipalign.cpp"],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+
+    static_libs: [
+        "libziparchive",
+        "liblog",
+        "libbase",
+        "libz",
+        "libutils",
+    ],
+}
diff --git a/tests/libs/Android.build.dlext_testzip.mk b/tests/libs/Android.build.dlext_testzip.mk
index 56be1e2..37499ba 100644
--- a/tests/libs/Android.build.dlext_testzip.mk
+++ b/tests/libs/Android.build.dlext_testzip.mk
@@ -26,7 +26,7 @@
 LOCAL_MODULE := libdlext_test_zip_zipaligned
 LOCAL_MODULE_SUFFIX := .zip
 LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/libdlext_test_zip
+LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_zip
 LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
 
 include $(BUILD_SYSTEM)/base_rules.mk
@@ -48,7 +48,7 @@
 LOCAL_MODULE := libdlext_test_runpath_zip_zipaligned
 LOCAL_MODULE_SUFFIX := .zip
 LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/libdlext_test_runpath_zip
+LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_runpath_zip
 LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
 
 include $(BUILD_SYSTEM)/base_rules.mk
diff --git a/tests/libs/Android.build.dt_runpath.mk b/tests/libs/Android.build.dt_runpath.mk
index 4544bb1..60844e5 100644
--- a/tests/libs/Android.build.dt_runpath.mk
+++ b/tests/libs/Android.build.dt_runpath.mk
@@ -67,17 +67,21 @@
 
 libtest_dt_runpath_d_shared_libraries := libtest_dt_runpath_b libtest_dt_runpath_c
 libtest_dt_runpath_d_ldflags := -Wl,--rpath,\$${ORIGIN}/dt_runpath_b_c_x -Wl,--enable-new-dtags
+libtest_dt_runpath_d_ldlibs := -ldl
 module := libtest_dt_runpath_d
 include $(LOCAL_PATH)/Android.build.testlib.mk
 
 # D version for open-from-zip test with runpath
+module := libtest_dt_runpath_d_zip
+
 libtest_dt_runpath_d_zip_src_files := \
     dlopen_b.cpp
 
 libtest_dt_runpath_d_zip_shared_libraries := libtest_dt_runpath_b libtest_dt_runpath_c
 libtest_dt_runpath_d_zip_ldflags := -Wl,--rpath,\$${ORIGIN}/dt_runpath_b_c_x -Wl,--enable-new-dtags
-libtest_dt_runpath_d_zip_install_to_out_data := true
-module := libtest_dt_runpath_d_zip
+libtest_dt_runpath_d_zip_ldlibs := -ldl
+libtest_dt_runpath_d_zip_install_to_out_data_dir := $(module)
+
 module_tag := optional
 build_type := target
 build_target := SHARED_LIBRARY
diff --git a/tests/libs/Android.build.linker_namespaces.mk b/tests/libs/Android.build.linker_namespaces.mk
index f913780..df6428c 100644
--- a/tests/libs/Android.build.linker_namespaces.mk
+++ b/tests/libs/Android.build.linker_namespaces.mk
@@ -35,24 +35,24 @@
 # -----------------------------------------------------------------------------
 libnstest_root_src_files := namespaces_root.cpp
 libnstest_root_shared_libraries := libnstest_public libnstest_private
-libnstest_root_install_to_out_data_dir := private_namespace_libs
+libnstest_root_relative_install_path := private_namespace_libs
 module := libnstest_root
-include $(LOCAL_PATH)/Android.build.target.testlib.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
 libnstest_public_src_files := namespaces_public.cpp
 module := libnstest_public
-libnstest_public_install_to_out_data_dir := public_namespace_libs
-include $(LOCAL_PATH)/Android.build.target.testlib.mk
+libnstest_public_relative_install_path := public_namespace_libs
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
 libnstest_private_src_files := namespaces_private.cpp
-libnstest_private_install_to_out_data_dir := private_namespace_libs
+libnstest_private_relative_install_path := private_namespace_libs
 module := libnstest_private
-include $(LOCAL_PATH)/Android.build.target.testlib.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
 libnstest_dlopened_src_files := namespaces_dlopened.cpp
-libnstest_dlopened_install_to_out_data_dir := private_namespace_libs
+libnstest_dlopened_relative_install_path := private_namespace_libs
 module := libnstest_dlopened
-include $(LOCAL_PATH)/Android.build.target.testlib.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
 # -----------------------------------------------------------------------------
 # This set of libraries is to test isolated namespaces
@@ -71,14 +71,14 @@
 # -----------------------------------------------------------------------------
 libnstest_root_not_isolated_src_files := namespaces_root.cpp
 libnstest_root_not_isolated_shared_libraries := libnstest_public libnstest_private_external
-libnstest_root_not_isolated_install_to_out_data_dir := private_namespace_libs
+libnstest_root_not_isolated_relative_install_path := private_namespace_libs
 libnstest_root_not_isolated_ldflags := -Wl,--rpath,\$$ORIGIN/../private_namespace_libs_external \
                                        -Wl,--enable-new-dtags
 
 module := libnstest_root_not_isolated
-include $(LOCAL_PATH)/Android.build.target.testlib.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
 libnstest_private_external_src_files := namespaces_private.cpp
-libnstest_private_external_install_to_out_data_dir := private_namespace_libs_external
+libnstest_private_external_relative_install_path := private_namespace_libs_external
 module := libnstest_private_external
-include $(LOCAL_PATH)/Android.build.target.testlib.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
diff --git a/tests/libs/Android.build.testlib.mk b/tests/libs/Android.build.testlib.mk
index 5b688e4..833caf6 100644
--- a/tests/libs/Android.build.testlib.mk
+++ b/tests/libs/Android.build.testlib.mk
@@ -17,6 +17,6 @@
 build_target := SHARED_LIBRARY
 build_type := host
 include $(TEST_PATH)/Android.build.mk
-build_type := target
-include $(TEST_PATH)/Android.build.mk
+
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
diff --git a/tests/libs/Android.build.testlib.target.mk b/tests/libs/Android.build.testlib.target.mk
new file mode 100644
index 0000000..b79dbfc
--- /dev/null
+++ b/tests/libs/Android.build.testlib.target.mk
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+build_type := target
+# 1. Install test libraries to /data/nativetests../bionic-loader-test-libs/
+#    by default.
+ifeq ($($(module)_relative_install_path),)
+  $(module)_install_to_out_data_dir := bionic-loader-test-libs
+else
+  $(module)_install_to_out_data_dir := bionic-loader-test-libs/$($(module)_relative_install_path)
+endif
+# 2. Set dt_runpath to origin to resolve dependencies
+$(module)_ldflags += -Wl,--rpath,\$${ORIGIN} -Wl,--enable-new-dtags
+include $(TEST_PATH)/Android.build.mk
diff --git a/tests/libs/Android.mk b/tests/libs/Android.mk
index 506d6f2..a54318d 100644
--- a/tests/libs/Android.mk
+++ b/tests/libs/Android.mk
@@ -29,38 +29,11 @@
     $(LOCAL_PATH)/Android.build.linker_namespaces.mk \
     $(LOCAL_PATH)/Android.build.pthread_atfork.mk \
     $(LOCAL_PATH)/Android.build.testlib.mk \
+    $(LOCAL_PATH)/Android.build.testlib.target.mk \
     $(LOCAL_PATH)/Android.build.versioned_lib.mk \
     $(TEST_PATH)/Android.build.mk
 
 # -----------------------------------------------------------------------------
-# Library to test gnu-styled hash
-# -----------------------------------------------------------------------------
-ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
-libgnu-hash-table-library_src_files := \
-    dlext_test_library.cpp \
-
-libgnu-hash-table-library_ldflags := \
-    -Wl,--hash-style=gnu \
-
-module := libgnu-hash-table-library
-module_tag := optional
-include $(LOCAL_PATH)/Android.build.testlib.mk
-endif
-
-# -----------------------------------------------------------------------------
-# Library to test sysv-styled hash
-# -----------------------------------------------------------------------------
-libsysv-hash-table-library_src_files := \
-    dlext_test_library.cpp \
-
-libsysv-hash-table-library_ldflags := \
-    -Wl,--hash-style=sysv \
-
-module := libsysv-hash-table-library
-module_tag := optional
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
 # Library used by dlext tests - with GNU RELRO program header
 # -----------------------------------------------------------------------------
 libdlext_test_src_files := \
@@ -76,82 +49,45 @@
 include $(LOCAL_PATH)/Android.build.testlib.mk
 
 # -----------------------------------------------------------------------------
-# create symlink to libdlext_test.so for symlink test
-# -----------------------------------------------------------------------------
-# Use = instead of := to defer the evaluation of $@
-$(TARGET_OUT)/lib/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \
-    $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so
-
-ifneq ($(TARGET_2ND_ARCH),)
-# link 64 bit .so
-$(TARGET_OUT)/lib64/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \
-    $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so
-endif
-
-# host symlinks
-$(HOST_OUT)/lib64/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \
-    $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so
-
-$(HOST_OUT)/lib/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \
-    $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so
-
-# -----------------------------------------------------------------------------
-# Library used by dlext tests - without GNU RELRO program header
-# -----------------------------------------------------------------------------
-libdlext_test_norelro_src_files := \
-    dlext_test_library.cpp \
-
-libdlext_test_norelro_ldflags := \
-    -Wl,-z,norelro \
-
-libdlext_test_norelro_shared_libraries := libtest_simple
-
-module := libdlext_test_norelro
-module_tag := optional
-build_type := target
-build_target := SHARED_LIBRARY
-include $(TEST_PATH)/Android.build.mk
-
-# -----------------------------------------------------------------------------
 # Library used by dlext tests - different name non-default location
 # -----------------------------------------------------------------------------
+module := libdlext_test_fd
+
 libdlext_test_fd_src_files := \
     dlext_test_library.cpp \
 
 libdlext_test_fd_shared_libraries := libtest_simple
 
-libdlext_test_fd_install_to_out_data := true
-module := libdlext_test_fd
+libdlext_test_fd_relative_install_path := $(module)
+
+libdlext_test_fd_ldflags := -Wl,--rpath,\$${ORIGIN}/.. -Wl,--enable-new-dtags
+
 module_tag := optional
-build_type := target
-build_target := SHARED_LIBRARY
-include $(TEST_PATH)/Android.build.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
 
 # -----------------------------------------------------------------------------
 # Libraries used by dlext tests for open from a zip-file
 # -----------------------------------------------------------------------------
+module := libdlext_test_zip
+
 libdlext_test_zip_src_files := \
     dlext_test_library.cpp \
 
 libdlext_test_zip_shared_libraries := libatest_simple_zip
 
-libdlext_test_zip_install_to_out_data := true
-module := libdlext_test_zip
+libdlext_test_zip_relative_install_path := $(module)
 module_tag := optional
-build_type := target
-build_target := SHARED_LIBRARY
-include $(TEST_PATH)/Android.build.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
+
+module := libatest_simple_zip
 
 libatest_simple_zip_src_files := \
     dlopen_testlib_simple.cpp
 
-libatest_simple_zip_install_to_out_data := true
-module := libatest_simple_zip
+libatest_simple_zip_relative_install_path := $(module)
 module_tag := optional
-build_type := target
-build_target := SHARED_LIBRARY
-include $(TEST_PATH)/Android.build.mk
+include $(LOCAL_PATH)/Android.build.testlib.target.mk
 
 # ----------------------------------------------------------------------------
 # Library with soname which does not match filename
@@ -176,44 +112,6 @@
 endif
 
 # -----------------------------------------------------------------------------
-# Library used by dlfcn tests
-# -----------------------------------------------------------------------------
-libtest_simple_src_files := \
-    dlopen_testlib_simple.cpp
-
-module := libtest_simple
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library used by dlfcn nodelete tests
-# -----------------------------------------------------------------------------
-libtest_nodelete_1_src_files := \
-    dlopen_nodelete_1.cpp
-
-module := libtest_nodelete_1
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library used by dlfcn nodelete tests
-# -----------------------------------------------------------------------------
-libtest_nodelete_2_src_files := \
-    dlopen_nodelete_2.cpp
-
-module := libtest_nodelete_2
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library used by dlfcn nodelete tests
-# -----------------------------------------------------------------------------
-libtest_nodelete_dt_flags_1_src_files := \
-    dlopen_nodelete_dt_flags_1.cpp
-
-libtest_nodelete_dt_flags_1_ldflags := -Wl,-z,nodelete
-
-module := libtest_nodelete_dt_flags_1
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
 # Build test helper libraries for linker namespaces
 # -----------------------------------------------------------------------------
 include $(LOCAL_PATH)/Android.build.linker_namespaces.mk
@@ -254,82 +152,6 @@
 include $(LOCAL_PATH)/Android.build.pthread_atfork.mk
 
 # -----------------------------------------------------------------------------
-# Library with dependency loop used by dlfcn tests
-#
-# libtest_with_dependency_loop -> a -> b -> c -> a
-# -----------------------------------------------------------------------------
-libtest_with_dependency_loop_src_files := dlopen_testlib_loopy_root.cpp
-
-libtest_with_dependency_loop_shared_libraries := \
-    libtest_with_dependency_loop_a
-
-module := libtest_with_dependency_loop
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# libtest_with_dependency_loop_a.so
-# -----------------------------------------------------------------------------
-libtest_with_dependency_loop_a_src_files := dlopen_testlib_loopy_a.cpp
-
-libtest_with_dependency_loop_a_shared_libraries := \
-    libtest_with_dependency_loop_b_tmp
-
-module := libtest_with_dependency_loop_a
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# libtest_with_dependency_loop_b.so
-#
-# this is temporary placeholder - will be removed
-# -----------------------------------------------------------------------------
-libtest_with_dependency_loop_b_tmp_src_files := dlopen_testlib_loopy_invalid.cpp
-libtest_with_dependency_loop_b_tmp_ldflags := -Wl,-soname=libtest_with_dependency_loop_b.so
-
-module := libtest_with_dependency_loop_b_tmp
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# libtest_with_dependency_loop_b.so
-# -----------------------------------------------------------------------------
-libtest_with_dependency_loop_b_src_files := dlopen_testlib_loopy_b.cpp
-libtest_with_dependency_loop_b_shared_libraries := libtest_with_dependency_loop_c
-
-module := libtest_with_dependency_loop_b
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# libtest_with_dependency_loop_c.so
-# -----------------------------------------------------------------------------
-libtest_with_dependency_loop_c_src_files := dlopen_testlib_loopy_c.cpp
-
-libtest_with_dependency_loop_c_shared_libraries := \
-    libtest_with_dependency_loop_a
-
-module := libtest_with_dependency_loop_c
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# libtest_relo_check_dt_needed_order.so
-# |
-# +-> libtest_relo_check_dt_needed_order_1.so
-# |
-# +-> libtest_relo_check_dt_needed_order_2.so
-# -----------------------------------------------------------------------------
-libtest_relo_check_dt_needed_order_shared_libraries := \
-    libtest_relo_check_dt_needed_order_1 libtest_relo_check_dt_needed_order_2
-
-libtest_relo_check_dt_needed_order_src_files := dlopen_testlib_relo_check_dt_needed_order.cpp
-libtest_relo_check_dt_needed_order_1_src_files := dlopen_testlib_relo_check_dt_needed_order_1.cpp
-libtest_relo_check_dt_needed_order_2_src_files := dlopen_testlib_relo_check_dt_needed_order_2.cpp
-
-module := libtest_relo_check_dt_needed_order
-include $(LOCAL_PATH)/Android.build.testlib.mk
-module := libtest_relo_check_dt_needed_order_1
-include $(LOCAL_PATH)/Android.build.testlib.mk
-module := libtest_relo_check_dt_needed_order_2
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
 # Library with dependency used by dlfcn tests
 # -----------------------------------------------------------------------------
 libtest_with_dependency_src_files := \
@@ -339,165 +161,3 @@
 
 module := libtest_with_dependency
 include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library used by ifunc tests
-# -----------------------------------------------------------------------------
-libtest_ifunc_src_files := \
-    dlopen_testlib_ifunc.c
-
-libtest_ifunc_clang_host := false
-module := libtest_ifunc
-build_target := SHARED_LIBRARY
-
-build_type := host
-include $(TEST_PATH)/Android.build.mk
-
-ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm64 x86 x86_64))
-    ifeq ($(TARGET_ARCH),arm64)
-      libtest_ifunc_multilib := 64
-      # TODO: This is a workaround - remove it once gcc
-      # removes its Android ifunc checks
-      libtest_ifunc_cflags := -mglibc
-    endif
-
-    build_type := target
-    libtest_ifunc_clang_target := false
-    include $(TEST_PATH)/Android.build.mk
-endif
-
-# -----------------------------------------------------------------------------
-# Library used by atexit tests
-# -----------------------------------------------------------------------------
-
-libtest_atexit_src_files := \
-    atexit_testlib.cpp
-
-module := libtest_atexit
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# This library is used by dl_load test to check symbol preempting
-# by main executable
-# -----------------------------------------------------------------------------
-libdl_preempt_test_1_src_files := dl_preempt_library_1.cpp
-
-module := libdl_preempt_test_1
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# This library is used by dl_load test to check symbol preempting
-# by libdl_preempt_test_1.so
-# -----------------------------------------------------------------------------
-libdl_preempt_test_2_src_files := dl_preempt_library_2.cpp
-
-module := libdl_preempt_test_2
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library with DF_1_GLOBAL
-# -----------------------------------------------------------------------------
-libdl_test_df_1_global_src_files := dl_df_1_global.cpp
-libdl_test_df_1_global_ldflags := -Wl,-z,global
-
-# TODO (dimitry): host ld.gold does not yet support -z global
-# remove this line once it is updated.
-libdl_test_df_1_global_ldflags_host := -fuse-ld=bfd
-
-module := libdl_test_df_1_global
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library using symbol from libdl_test_df_1_global
-# -----------------------------------------------------------------------------
-libtest_dlsym_df_1_global_src_files := dl_df_1_use_global.cpp
-module := libtest_dlsym_df_1_global
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library with weak function
-# -----------------------------------------------------------------------------
-libtest_dlsym_weak_func_src_files := \
-    dlsym_weak_function.cpp
-
-module := libtest_dlsym_weak_func
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library to check RTLD_LOCAL with dlsym in 'this'
-# -----------------------------------------------------------------------------
-libtest_dlsym_from_this_src_files := dlsym_from_this_symbol.cpp
-
-libtest_dlsym_from_this_shared_libraries_target := libdl
-libtest_dlsym_from_this_shared_libraries := libtest_dlsym_from_this_child
-
-module := libtest_dlsym_from_this
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-libtest_dlsym_from_this_child_src_files := dlsym_from_this_functions.cpp
-
-libtest_dlsym_from_this_child_shared_libraries := libtest_dlsym_from_this_grandchild
-
-module := libtest_dlsym_from_this_child
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-libtest_dlsym_from_this_grandchild_src_files := dlsym_from_this_symbol2.cpp
-
-module := libtest_dlsym_from_this_grandchild
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Empty library
-# -----------------------------------------------------------------------------
-libtest_empty_src_files := empty.cpp
-
-module := libtest_empty
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library with weak undefined function
-# -----------------------------------------------------------------------------
-libtest_dlopen_weak_undefined_func_src_files := \
-    dlopen_weak_undefined.cpp
-
-module := libtest_dlopen_weak_undefined_func
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library with constructor that calls dlopen() b/7941716
-# -----------------------------------------------------------------------------
-libtest_dlopen_from_ctor_src_files := \
-   dlopen_testlib_dlopen_from_ctor.cpp
-
-module := libtest_dlopen_from_ctor
-
-libtest_dlopen_from_ctor_shared_libraries_target := libdl
-
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Library that depends on the library with constructor that calls dlopen() b/7941716
-# -----------------------------------------------------------------------------
-
-libtest_dlopen_from_ctor_main_src_files := empty.cpp
-libtest_dlopen_from_ctor_main_shared_libraries := libtest_dlopen_from_ctor
-
-module := libtest_dlopen_from_ctor_main
-include $(LOCAL_PATH)/Android.build.testlib.mk
-
-# -----------------------------------------------------------------------------
-# Tool to use to align the shared libraries in a zip file.
-# -----------------------------------------------------------------------------
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := bionic_tests_zipalign.cpp
-LOCAL_MODULE := bionic_tests_zipalign
-LOCAL_CFLAGS := -Wall -Werror
-
-LOCAL_STATIC_LIBRARIES := libziparchive-host liblog libbase libz libutils
-
-LOCAL_MODULE_HOST_OS := darwin linux windows
-
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/tests/libs/bionic_tests_zipalign.cpp b/tests/libs/bionic_tests_zipalign.cpp
index a72820f..8e31474 100644
--- a/tests/libs/bionic_tests_zipalign.cpp
+++ b/tests/libs/bionic_tests_zipalign.cpp
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 
 #include <algorithm>
+#include <memory>
 #include <string>
 #include <vector>
 
@@ -36,7 +37,7 @@
   fprintf(stderr, "    The output zip file that will be created from the input file.\n");
 }
 
-typedef std::pair<ZipEntry*, ZipString*> ZipData;
+using ZipData = std::pair<std::unique_ptr<ZipEntry>, std::unique_ptr<ZipString>>;
 
 static bool GetEntries(ZipArchiveHandle handle, std::vector<ZipData>* entries) {
   void* cookie;
@@ -49,14 +50,15 @@
   ZipEntry entry;
   ZipString name;
   while ((return_value = Next(cookie, &entry, &name)) == 0) {
-    entries->push_back(std::make_pair(new ZipEntry(entry), new ZipString(name)));
+    entries->emplace_back(std::make_pair(std::make_unique<ZipEntry>(entry),
+                                         std::make_unique<ZipString>(name)));
   }
   if (return_value != -1) {
     fprintf(stderr, "Error while iterating over zip entries: %s\n", ErrorCodeString(return_value));
   } else {
     // Sort by offset.
     std::sort(entries->begin(), entries->end(),
-              [](ZipData a, ZipData b) { return a.first->offset < b.first->offset; });
+              [](ZipData& a, ZipData& b) { return a.first->offset < b.first->offset; });
   }
 
   EndIteration(cookie);
@@ -75,8 +77,8 @@
 
   int32_t error;
   for (auto& entry : entries) {
-    ZipEntry* zip_entry = entry.first;
-    ZipString* zip_str = entry.second;
+    ZipEntry* zip_entry = entry.first.get();
+    ZipString* zip_str = entry.second.get();
 
     size_t flags = 0;
     if ((zip_entry->method & kCompressDeflated) != 0) {
diff --git a/tests/locale_test.cpp b/tests/locale_test.cpp
index f308af5..8b38c40 100644
--- a/tests/locale_test.cpp
+++ b/tests/locale_test.cpp
@@ -59,9 +59,10 @@
   EXPECT_EQ(EINVAL, errno);
 
 #if defined(__BIONIC__)
-  // The "" locale is implementation-defined. For bionic, it's the C locale.
+  // The "" locale is implementation-defined. For bionic, it's the C.UTF-8 locale, which is
+  // pretty much all we support anyway.
   // glibc will give us something like "en_US.UTF-8", depending on the user's configuration.
-  EXPECT_STREQ("C", setlocale(LC_ALL, ""));
+  EXPECT_STREQ("C.UTF-8", setlocale(LC_ALL, ""));
 #endif
   EXPECT_STREQ("C", setlocale(LC_ALL, "C"));
   EXPECT_STREQ("C", setlocale(LC_ALL, "POSIX"));
diff --git a/tests/math_data_test.h b/tests/math_data_test.h
index 0aba701..42dc42c 100644
--- a/tests/math_data_test.h
+++ b/tests/math_data_test.h
@@ -16,6 +16,7 @@
 
 #include <gtest/gtest.h>
 
+#include <math.h>
 #include <fenv.h>
 
 template <typename RT, typename T1>
@@ -102,7 +103,28 @@
   uint64_t sign_magnitude;
 };
 
-// TODO: long double.
+template <> union fp_u<long double> {
+  long double value;
+#if defined(__LP64__)
+  struct {
+    unsigned fracl;
+    unsigned fraclm;
+    unsigned frachm;
+    unsigned frach:16;
+    unsigned exp:15;
+    unsigned sign:1;
+  } bits;
+  __int128_t sign_magnitude;
+#else
+  struct {
+      unsigned fracl;
+      unsigned frach:20;
+      unsigned exp:11;
+      unsigned sign:1;
+  } bits;
+  uint64_t sign_magnitude;
+#endif
+};
 
 template <typename T>
 static inline auto SignAndMagnitudeToBiased(const T& value) -> decltype(fp_u<T>::sign_magnitude) {
@@ -134,14 +156,8 @@
       return ::testing::AssertionSuccess();
     }
 
-    // Output the actual and expected values as hex floating point.
-    char expected_str[64];
-    char actual_str[64];
-    snprintf(expected_str, sizeof(expected_str), "%a", expected);
-    snprintf(actual_str, sizeof(actual_str), "%a", actual);
-
     return ::testing::AssertionFailure()
-        << "expected (" << expected_str << ") != actual (" << actual_str << ")";
+        << "expected (" << std::hexfloat << expected << ") != actual (" << actual << ")";
   }
 };
 
@@ -282,4 +298,3 @@
                         data[i].expected, f(data[i].input1, data[i].input2, data[i].input3)) << "Failed on element " << i;
   }
 }
-
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
index c805cc2..6c7dffb 100644
--- a/tests/math_test.cpp
+++ b/tests/math_test.cpp
@@ -385,6 +385,27 @@
   ASSERT_DOUBLE_EQ(0.0L, sinl(0.0L));
 }
 
+TEST(math, sincos) {
+  double s, c;
+  sincos(0.0, &s, &c);
+  ASSERT_DOUBLE_EQ(0.0, s);
+  ASSERT_DOUBLE_EQ(1.0, c);
+}
+
+TEST(math, sincosf) {
+  float s, c;
+  sincosf(0.0f, &s, &c);
+  ASSERT_FLOAT_EQ(0.0f, s);
+  ASSERT_FLOAT_EQ(1.0f, c);
+}
+
+TEST(math, sincosl) {
+  long double s, c;
+  sincosl(0.0L, &s, &c);
+  ASSERT_DOUBLE_EQ(0.0L, s);
+  ASSERT_DOUBLE_EQ(1.0L, c);
+}
+
 TEST(math, tan) {
   ASSERT_DOUBLE_EQ(0.0, tan(0.0));
 }
diff --git a/tests/mntent_test.cpp b/tests/mntent_test.cpp
index a102849..3fb2f86 100644
--- a/tests/mntent_test.cpp
+++ b/tests/mntent_test.cpp
@@ -38,3 +38,20 @@
 
   ASSERT_EQ(1, endmntent(fp));
 }
+
+TEST(mntent, hasmntopt) {
+  // indices                  1  1
+  // of keys:      0    5   9 1  4
+  char mnt_opts[]{"aa=b,a=b,b,bb,c=d"};
+  struct mntent ent;
+  memset(&ent, 0, sizeof(ent));
+  ent.mnt_opts = mnt_opts;
+
+  EXPECT_EQ(mnt_opts, hasmntopt(&ent, "aa"));
+  EXPECT_EQ(mnt_opts + 5, hasmntopt(&ent, "a"));
+  EXPECT_EQ(mnt_opts + 9, hasmntopt(&ent, "b"));
+  EXPECT_EQ(mnt_opts + 11, hasmntopt(&ent, "bb"));
+  EXPECT_EQ(mnt_opts + 14, hasmntopt(&ent, "c"));
+  EXPECT_EQ(nullptr, hasmntopt(&ent, "d"));
+  EXPECT_EQ(nullptr, hasmntopt(&ent, "e"));
+}
diff --git a/tests/netinet_ether_test.cpp b/tests/netinet_ether_test.cpp
new file mode 100644
index 0000000..faa3db4
--- /dev/null
+++ b/tests/netinet_ether_test.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <netinet/ether.h>
+
+TEST(netinet_ether, ether_aton__ether_ntoa) {
+  ether_addr* a = ether_aton("12:34:56:78:9a:bc");
+  ASSERT_NE(nullptr, a);
+  ASSERT_EQ(0x12, a->ether_addr_octet[0]);
+  ASSERT_EQ(0x34, a->ether_addr_octet[1]);
+  ASSERT_EQ(0x56, a->ether_addr_octet[2]);
+  ASSERT_EQ(0x78, a->ether_addr_octet[3]);
+  ASSERT_EQ(0x9a, a->ether_addr_octet[4]);
+  ASSERT_EQ(0xbc, a->ether_addr_octet[5]);
+
+  ASSERT_STREQ("12:34:56:78:9a:bc", ether_ntoa(a));
+}
+
+TEST(netinet_ether, ether_aton_r__ether_ntoa_r) {
+  ether_addr addr;
+  memset(&addr, 0, sizeof(addr));
+  ether_addr* a = ether_aton_r("12:34:56:78:9a:bc", &addr);
+  ASSERT_EQ(&addr, a);
+  ASSERT_EQ(0x12, addr.ether_addr_octet[0]);
+  ASSERT_EQ(0x34, addr.ether_addr_octet[1]);
+  ASSERT_EQ(0x56, addr.ether_addr_octet[2]);
+  ASSERT_EQ(0x78, addr.ether_addr_octet[3]);
+  ASSERT_EQ(0x9a, addr.ether_addr_octet[4]);
+  ASSERT_EQ(0xbc, addr.ether_addr_octet[5]);
+
+  char buf[32];
+  memset(buf, 0, sizeof(buf));
+  char* p = ether_ntoa_r(&addr, buf);
+  ASSERT_EQ(buf, p);
+  ASSERT_STREQ("12:34:56:78:9a:bc", buf);
+}
diff --git a/tests/nl_types_test.cpp b/tests/nl_types_test.cpp
new file mode 100644
index 0000000..2e3995b
--- /dev/null
+++ b/tests/nl_types_test.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <nl_types.h>
+
+#include <errno.h>
+#include <gtest/gtest.h>
+
+TEST(nl_types, smoke) {
+  nl_catd cat = catopen("/does/not/exist", NL_CAT_LOCALE);
+  ASSERT_EQ(reinterpret_cast<nl_catd>(-1), cat);
+
+  ASSERT_STREQ("hello, world!", catgets(cat, NL_SETD, 0, "hello, world!"));
+
+  errno = 0;
+  ASSERT_EQ(-1, catclose(cat));
+  ASSERT_EQ(EBADF, errno);
+}
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-empty_shdr_table.so b/tests/prebuilt-elf-files/arm/libtest_invalid-empty_shdr_table.so
new file mode 100755
index 0000000..ebeaa19
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-empty_shdr_table.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/arm/libtest_invalid-rw_load_segment.so
new file mode 100755
index 0000000..00d91ff
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-textrels.so b/tests/prebuilt-elf-files/arm/libtest_invalid-textrels.so
new file mode 100755
index 0000000..7e852c0
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-textrels.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-textrels2.so b/tests/prebuilt-elf-files/arm/libtest_invalid-textrels2.so
new file mode 100755
index 0000000..26ebdb9
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-textrels2.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-unaligned_shdr_offset.so b/tests/prebuilt-elf-files/arm/libtest_invalid-unaligned_shdr_offset.so
new file mode 100755
index 0000000..24bd96e
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-unaligned_shdr_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_content.so b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_content.so
new file mode 100755
index 0000000..829c7c2
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_content.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_offset.so b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_offset.so
new file mode 100755
index 0000000..347cf8b
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shentsize.so b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shentsize.so
new file mode 100755
index 0000000..36085d5
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shentsize.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shstrndx.so b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shstrndx.so
new file mode 100755
index 0000000..25355d0
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm/libtest_invalid-zero_shstrndx.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-empty_shdr_table.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-empty_shdr_table.so
new file mode 100755
index 0000000..12ce90f
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-empty_shdr_table.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so
new file mode 100755
index 0000000..f61d2ed
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-textrels.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-textrels.so
new file mode 100755
index 0000000..7d925cb
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-textrels.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-textrels2.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-textrels2.so
new file mode 100755
index 0000000..7eb62f5
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-textrels2.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-unaligned_shdr_offset.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-unaligned_shdr_offset.so
new file mode 100755
index 0000000..7389d9c
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-unaligned_shdr_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_content.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_content.so
new file mode 100755
index 0000000..819a032
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_content.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_offset.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_offset.so
new file mode 100755
index 0000000..0a07e1c
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shentsize.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shentsize.so
new file mode 100755
index 0000000..b8d49e3
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shentsize.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shstrndx.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shstrndx.so
new file mode 100755
index 0000000..625a0e6
--- /dev/null
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-zero_shstrndx.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-empty_shdr_table.so b/tests/prebuilt-elf-files/mips/libtest_invalid-empty_shdr_table.so
new file mode 100755
index 0000000..7973498
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-empty_shdr_table.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/mips/libtest_invalid-rw_load_segment.so
new file mode 100755
index 0000000..f938d13
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-textrels.so b/tests/prebuilt-elf-files/mips/libtest_invalid-textrels.so
new file mode 100755
index 0000000..9405863
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-textrels.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-textrels2.so b/tests/prebuilt-elf-files/mips/libtest_invalid-textrels2.so
new file mode 100755
index 0000000..eb9d61c
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-textrels2.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-unaligned_shdr_offset.so b/tests/prebuilt-elf-files/mips/libtest_invalid-unaligned_shdr_offset.so
new file mode 100755
index 0000000..1e8ea7d
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-unaligned_shdr_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shdr_table_content.so b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shdr_table_content.so
new file mode 100755
index 0000000..8fe1f63
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shdr_table_content.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shdr_table_offset.so b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shdr_table_offset.so
new file mode 100755
index 0000000..64f3a88
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shdr_table_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shentsize.so b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shentsize.so
new file mode 100755
index 0000000..285db43
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shentsize.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shstrndx.so b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shstrndx.so
new file mode 100755
index 0000000..fb1a421
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips/libtest_invalid-zero_shstrndx.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-empty_shdr_table.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-empty_shdr_table.so
new file mode 100755
index 0000000..5984a85
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-empty_shdr_table.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-rw_load_segment.so
new file mode 100755
index 0000000..d8bab60
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-textrels.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-textrels.so
new file mode 100755
index 0000000..d387691
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-textrels.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-textrels2.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-textrels2.so
new file mode 100755
index 0000000..eb5868a
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-textrels2.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-unaligned_shdr_offset.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-unaligned_shdr_offset.so
new file mode 100755
index 0000000..a2aff50
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-unaligned_shdr_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shdr_table_content.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shdr_table_content.so
new file mode 100755
index 0000000..ac4a69c
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shdr_table_content.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shdr_table_offset.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shdr_table_offset.so
new file mode 100755
index 0000000..01c229b
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shdr_table_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shentsize.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shentsize.so
new file mode 100755
index 0000000..abcd27b
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shentsize.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shstrndx.so b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shstrndx.so
new file mode 100755
index 0000000..d3aa35f
--- /dev/null
+++ b/tests/prebuilt-elf-files/mips64/libtest_invalid-zero_shstrndx.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-empty_shdr_table.so b/tests/prebuilt-elf-files/x86/libtest_invalid-empty_shdr_table.so
new file mode 100755
index 0000000..97cf006
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-empty_shdr_table.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/x86/libtest_invalid-rw_load_segment.so
new file mode 100755
index 0000000..7a343c9
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-textrels.so b/tests/prebuilt-elf-files/x86/libtest_invalid-textrels.so
new file mode 100755
index 0000000..ad78ed4
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-textrels.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-textrels2.so b/tests/prebuilt-elf-files/x86/libtest_invalid-textrels2.so
new file mode 100755
index 0000000..f70b1fa
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-textrels2.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-unaligned_shdr_offset.so b/tests/prebuilt-elf-files/x86/libtest_invalid-unaligned_shdr_offset.so
new file mode 100755
index 0000000..5c9501c
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-unaligned_shdr_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_content.so b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_content.so
new file mode 100755
index 0000000..9bb21ed
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_content.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_offset.so b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_offset.so
new file mode 100755
index 0000000..ca814ea
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shentsize.so b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shentsize.so
new file mode 100755
index 0000000..afdfb74
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shentsize.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shstrndx.so b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shstrndx.so
new file mode 100755
index 0000000..f5ff987
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86/libtest_invalid-zero_shstrndx.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-empty_shdr_table.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-empty_shdr_table.so
new file mode 100755
index 0000000..2052442
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-empty_shdr_table.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so
new file mode 100755
index 0000000..b39d0ca
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-textrels.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-textrels.so
new file mode 100755
index 0000000..425eb8b
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-textrels.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-textrels2.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-textrels2.so
new file mode 100755
index 0000000..ede0148
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-textrels2.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-unaligned_shdr_offset.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-unaligned_shdr_offset.so
new file mode 100755
index 0000000..0d42283
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-unaligned_shdr_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_content.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_content.so
new file mode 100755
index 0000000..5ad764c
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_content.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_offset.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_offset.so
new file mode 100755
index 0000000..1fae589
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_offset.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shentsize.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shentsize.so
new file mode 100755
index 0000000..079f7ec
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shentsize.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shstrndx.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shstrndx.so
new file mode 100755
index 0000000..d4f6502
--- /dev/null
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-zero_shstrndx.so
Binary files differ
diff --git a/tests/pthread_dlfcn_test.cpp b/tests/pthread_dlfcn_test.cpp
index 64423da..1c733fe 100644
--- a/tests/pthread_dlfcn_test.cpp
+++ b/tests/pthread_dlfcn_test.cpp
@@ -37,6 +37,11 @@
 static void AtForkChild3() { g_atfork_child_calls = (g_atfork_child_calls * 10) + 3; }
 static void AtForkChild4() { g_atfork_child_calls = (g_atfork_child_calls * 10) + 4; }
 
+static void* g_atfork_test_handle = nullptr;
+static void AtForkPrepare() {}
+static void AtForkParent() {}
+static void AtForkChild() { dlclose(g_atfork_test_handle); g_atfork_test_handle = dlopen("libtest_pthread_atfork.so", RTLD_NOW | RTLD_LOCAL); }
+
 TEST(pthread, pthread_atfork_with_dlclose) {
   ASSERT_EQ(0, pthread_atfork(AtForkPrepare1, AtForkParent1, AtForkChild1));
 
@@ -82,3 +87,28 @@
 
   AssertChildExited(pid, 0);
 }
+
+TEST(pthread, pthread_atfork_child_with_dlclose) {
+
+  g_atfork_test_handle = dlopen("libtest_pthread_atfork.so", RTLD_NOW | RTLD_LOCAL);
+  ASSERT_TRUE(g_atfork_test_handle != nullptr) << dlerror();
+  typedef int (*fn_t)(void (*)(void), void (*)(void), void (*)(void));
+  fn_t fn = reinterpret_cast<fn_t>(dlsym(g_atfork_test_handle, "proxy_pthread_atfork"));
+  ASSERT_TRUE(fn != nullptr) << dlerror();
+  // the library registers 2 additional atfork handlers in a constructor
+
+  ASSERT_EQ(0, pthread_atfork(AtForkPrepare, AtForkParent, AtForkChild));
+
+  pid_t pid = fork();
+
+  ASSERT_NE(-1, pid) << strerror(errno);
+
+  if (pid == 0) {
+    _exit(0);
+  }
+
+  AssertChildExited(pid, 0);
+
+  EXPECT_EQ(0, dlclose(g_atfork_test_handle));
+  g_atfork_test_handle = nullptr;
+}
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 0313171..b0c95fe 100755
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -24,6 +24,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <sys/mman.h>
+#include <sys/prctl.h>
 #include <sys/syscall.h>
 #include <time.h>
 #include <unistd.h>
@@ -260,10 +261,10 @@
 }
 
 TEST(pthread, pthread_no_join_after_detach) {
-  SpinFunctionHelper spinhelper;
+  SpinFunctionHelper spin_helper;
 
   pthread_t t1;
-  ASSERT_EQ(0, pthread_create(&t1, NULL, spinhelper.GetFunction(), NULL));
+  ASSERT_EQ(0, pthread_create(&t1, NULL, spin_helper.GetFunction(), NULL));
 
   // After a pthread_detach...
   ASSERT_EQ(0, pthread_detach(t1));
@@ -274,10 +275,10 @@
 }
 
 TEST(pthread, pthread_no_op_detach_after_join) {
-  SpinFunctionHelper spinhelper;
+  SpinFunctionHelper spin_helper;
 
   pthread_t t1;
-  ASSERT_EQ(0, pthread_create(&t1, NULL, spinhelper.GetFunction(), NULL));
+  ASSERT_EQ(0, pthread_create(&t1, NULL, spin_helper.GetFunction(), NULL));
 
   // If thread 2 is already waiting to join thread 1...
   pthread_t t2;
@@ -292,7 +293,7 @@
 #endif
   AssertDetached(t1, false);
 
-  spinhelper.UnSpin();
+  spin_helper.UnSpin();
 
   // ...but t2's join on t1 still goes ahead (which we can tell because our join on t2 finishes).
   void* join_result;
@@ -396,32 +397,60 @@
   ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, NULL));
 }
 
-TEST(pthread, pthread_setname_np__too_long) {
+static void test_pthread_setname_np__pthread_getname_np(pthread_t t) {
+  ASSERT_EQ(0, pthread_setname_np(t, "short"));
+  char name[32];
+  ASSERT_EQ(0, pthread_getname_np(t, name, sizeof(name)));
+  ASSERT_STREQ("short", name);
+
   // The limit is 15 characters --- the kernel's buffer is 16, but includes a NUL.
-  ASSERT_EQ(0, pthread_setname_np(pthread_self(), "123456789012345"));
-  ASSERT_EQ(ERANGE, pthread_setname_np(pthread_self(), "1234567890123456"));
+  ASSERT_EQ(0, pthread_setname_np(t, "123456789012345"));
+  ASSERT_EQ(0, pthread_getname_np(t, name, sizeof(name)));
+  ASSERT_STREQ("123456789012345", name);
+
+  ASSERT_EQ(ERANGE, pthread_setname_np(t, "1234567890123456"));
+
+  // The passed-in buffer should be at least 16 bytes.
+  ASSERT_EQ(0, pthread_getname_np(t, name, 16));
+  ASSERT_EQ(ERANGE, pthread_getname_np(t, name, 15));
 }
 
-TEST(pthread, pthread_setname_np__self) {
-  ASSERT_EQ(0, pthread_setname_np(pthread_self(), "short 1"));
+TEST(pthread, pthread_setname_np__pthread_getname_np__self) {
+  test_pthread_setname_np__pthread_getname_np(pthread_self());
 }
 
-TEST(pthread, pthread_setname_np__other) {
-  SpinFunctionHelper spinhelper;
+TEST(pthread, pthread_setname_np__pthread_getname_np__other) {
+  SpinFunctionHelper spin_helper;
 
-  pthread_t t1;
-  ASSERT_EQ(0, pthread_create(&t1, NULL, spinhelper.GetFunction(), NULL));
-  ASSERT_EQ(0, pthread_setname_np(t1, "short 2"));
-  spinhelper.UnSpin();
-  ASSERT_EQ(0, pthread_join(t1, nullptr));
+  pthread_t t;
+  ASSERT_EQ(0, pthread_create(&t, nullptr, spin_helper.GetFunction(), nullptr));
+  test_pthread_setname_np__pthread_getname_np(t);
+  spin_helper.UnSpin();
+  ASSERT_EQ(0, pthread_join(t, nullptr));
 }
 
-TEST(pthread, pthread_setname_np__no_such_thread) {
+// http://b/28051133: a kernel misfeature means that you can't change the
+// name of another thread if you've set PR_SET_DUMPABLE to 0.
+TEST(pthread, pthread_setname_np__pthread_getname_np__other_PR_SET_DUMPABLE) {
+  ASSERT_EQ(0, prctl(PR_SET_DUMPABLE, 0)) << strerror(errno);
+
+  SpinFunctionHelper spin_helper;
+
+  pthread_t t;
+  ASSERT_EQ(0, pthread_create(&t, nullptr, spin_helper.GetFunction(), nullptr));
+  test_pthread_setname_np__pthread_getname_np(t);
+  spin_helper.UnSpin();
+  ASSERT_EQ(0, pthread_join(t, nullptr));
+}
+
+TEST(pthread, pthread_setname_np__pthread_getname_np__no_such_thread) {
   pthread_t dead_thread;
   MakeDeadThread(dead_thread);
 
-  // Call pthread_setname_np after thread has already exited.
+  // Call pthread_getname_np and pthread_setname_np after the thread has already exited.
   ASSERT_EQ(ENOENT, pthread_setname_np(dead_thread, "short 3"));
+  char name[64];
+  ASSERT_EQ(ENOENT, pthread_getname_np(dead_thread, name, sizeof(name)));
 }
 
 TEST(pthread, pthread_kill__0) {
@@ -455,16 +484,16 @@
 }
 
 TEST(pthread, pthread_getcpuclockid__clock_gettime) {
-  SpinFunctionHelper spinhelper;
+  SpinFunctionHelper spin_helper;
 
   pthread_t t;
-  ASSERT_EQ(0, pthread_create(&t, NULL, spinhelper.GetFunction(), NULL));
+  ASSERT_EQ(0, pthread_create(&t, NULL, spin_helper.GetFunction(), NULL));
 
   clockid_t c;
   ASSERT_EQ(0, pthread_getcpuclockid(t, &c));
   timespec ts;
   ASSERT_EQ(0, clock_gettime(c, &ts));
-  spinhelper.UnSpin();
+  spin_helper.UnSpin();
   ASSERT_EQ(0, pthread_join(t, nullptr));
 }
 
@@ -509,10 +538,10 @@
 }
 
 TEST(pthread, pthread_join__multijoin) {
-  SpinFunctionHelper spinhelper;
+  SpinFunctionHelper spin_helper;
 
   pthread_t t1;
-  ASSERT_EQ(0, pthread_create(&t1, NULL, spinhelper.GetFunction(), NULL));
+  ASSERT_EQ(0, pthread_create(&t1, NULL, spin_helper.GetFunction(), NULL));
 
   pthread_t t2;
   ASSERT_EQ(0, pthread_create(&t2, NULL, JoinFn, reinterpret_cast<void*>(t1)));
@@ -522,7 +551,7 @@
   // Multiple joins to the same thread should fail.
   ASSERT_EQ(EINVAL, pthread_join(t1, NULL));
 
-  spinhelper.UnSpin();
+  spin_helper.UnSpin();
 
   // ...but t2's join on t1 still goes ahead (which we can tell because our join on t2 finishes).
   void* join_result;
@@ -897,7 +926,7 @@
   pthread_rwlock_t lock;
 
  public:
-  RwlockKindTestHelper(int kind_type) {
+  explicit RwlockKindTestHelper(int kind_type) {
     InitRwlock(kind_type);
   }
 
@@ -1318,7 +1347,8 @@
 
 struct GetStackSignalHandlerArg {
   volatile bool done;
-  void* signal_handler_sp;
+  void* signal_stack_base;
+  size_t signal_stack_size;
   void* main_stack_base;
   size_t main_stack_size;
 };
@@ -1334,9 +1364,17 @@
   void* stack_base;
   size_t stack_size;
   ASSERT_EQ(0, pthread_attr_getstack(&attr, &stack_base, &stack_size));
-  getstack_signal_handler_arg.signal_handler_sp = &attr;
-  getstack_signal_handler_arg.main_stack_base = stack_base;
-  getstack_signal_handler_arg.main_stack_size = stack_size;
+
+  // Verify if the stack used by the signal handler is the alternate stack just registered.
+  ASSERT_LE(getstack_signal_handler_arg.signal_stack_base, &attr);
+  ASSERT_LT(static_cast<void*>(&attr),
+            static_cast<char*>(getstack_signal_handler_arg.signal_stack_base) +
+            getstack_signal_handler_arg.signal_stack_size);
+
+  // Verify if the main thread's stack got in the signal handler is correct.
+  ASSERT_EQ(getstack_signal_handler_arg.main_stack_base, stack_base);
+  ASSERT_LE(getstack_signal_handler_arg.main_stack_size, stack_size);
+
   getstack_signal_handler_arg.done = true;
 }
 
@@ -1369,18 +1407,13 @@
 
   ScopedSignalHandler handler(SIGUSR1, getstack_signal_handler, SA_ONSTACK);
   getstack_signal_handler_arg.done = false;
+  getstack_signal_handler_arg.signal_stack_base = sig_stack;
+  getstack_signal_handler_arg.signal_stack_size = sig_stack_size;
+  getstack_signal_handler_arg.main_stack_base = main_stack_base;
+  getstack_signal_handler_arg.main_stack_size = main_stack_size;
   kill(getpid(), SIGUSR1);
   ASSERT_EQ(true, getstack_signal_handler_arg.done);
 
-  // Verify if the stack used by the signal handler is the alternate stack just registered.
-  ASSERT_LE(sig_stack, getstack_signal_handler_arg.signal_handler_sp);
-  ASSERT_GE(reinterpret_cast<char*>(sig_stack) + sig_stack_size,
-            getstack_signal_handler_arg.signal_handler_sp);
-
-  // Verify if the main thread's stack got in the signal handler is correct.
-  ASSERT_EQ(main_stack_base, getstack_signal_handler_arg.main_stack_base);
-  ASSERT_LE(main_stack_size, getstack_signal_handler_arg.main_stack_size);
-
   ASSERT_EQ(0, sigaltstack(&oss, nullptr));
   ASSERT_EQ(0, munmap(sig_stack, sig_stack_size));
 }
@@ -1510,7 +1543,7 @@
 struct PthreadMutex {
   pthread_mutex_t lock;
 
-  PthreadMutex(int mutex_type) {
+  explicit PthreadMutex(int mutex_type) {
     init(mutex_type);
   }
 
@@ -1611,7 +1644,7 @@
   }
 
  public:
-  MutexWakeupHelper(int mutex_type) : m(mutex_type) {
+  explicit MutexWakeupHelper(int mutex_type) : m(mutex_type) {
   }
 
   void test() {
@@ -1751,7 +1784,14 @@
 
 TEST(pthread, pthread_mutex_lock_null_32) {
 #if defined(__BIONIC__) && !defined(__LP64__)
-  ASSERT_EQ(EINVAL, pthread_mutex_lock(NULL));
+  // For LP32, the pthread lock/unlock functions allow a NULL mutex and return
+  // EINVAL in that case: http://b/19995172.
+  //
+  // We decorate the public defintion with _Nonnull so that people recompiling
+  // their code with get a warning and might fix their bug, but need to pass
+  // NULL here to test that we remain compatible.
+  pthread_mutex_t* null_value = nullptr;
+  ASSERT_EQ(EINVAL, pthread_mutex_lock(null_value));
 #else
   GTEST_LOG_(INFO) << "This test tests bionic implementation details on 32 bit devices.";
 #endif
@@ -1759,7 +1799,14 @@
 
 TEST(pthread, pthread_mutex_unlock_null_32) {
 #if defined(__BIONIC__) && !defined(__LP64__)
-  ASSERT_EQ(EINVAL, pthread_mutex_unlock(NULL));
+  // For LP32, the pthread lock/unlock functions allow a NULL mutex and return
+  // EINVAL in that case: http://b/19995172.
+  //
+  // We decorate the public defintion with _Nonnull so that people recompiling
+  // their code with get a warning and might fix their bug, but need to pass
+  // NULL here to test that we remain compatible.
+  pthread_mutex_t* null_value = nullptr;
+  ASSERT_EQ(EINVAL, pthread_mutex_unlock(null_value));
 #else
   GTEST_LOG_(INFO) << "This test tests bionic implementation details on 32 bit devices.";
 #endif
diff --git a/libstdc++/include/cstdint b/tests/resolv_test.cpp
similarity index 66%
copy from libstdc++/include/cstdint
copy to tests/resolv_test.cpp
index 3df56df..08f9d90 100644
--- a/libstdc++/include/cstdint
+++ b/tests/resolv_test.cpp
@@ -1,6 +1,5 @@
-/* -*- c++ -*- */
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2016 The Android Open Source Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,14 +26,19 @@
  * SUCH DAMAGE.
  */
 
-#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
-#define BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+#include <resolv.h>
 
-/*
- * Standard C++ Library wrapper around the C stdint.h header file.
- */
+#include <gtest/gtest.h>
 
-#include <stdint.h>
+TEST(resolv, b64_pton_28035006) {
+  // Test data from https://groups.google.com/forum/#!topic/mailing.openbsd.tech/w3ACIlklJkI.
+  const char* data =
+      "p1v3+nehH3N3n+/OokzXpsyGF2VVpxIxkjSn3Mv/Sq74OE1iFuVU+K4bQImuVj"
+      "S55RB2fpCpbB8Nye7tzrt6h9YPP3yyJfqORDETGmIB4lveZXA4KDxx50F9rYrO"
+      "dFbTLyWfNBb/8Q2TnD72eY/3Y5P9qwtJwyDL25Tleic8G3g=";
 
-
-#endif  // BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+  // This buffer is exactly the right size, but old versions of the BSD code
+  // incorrectly required an extra byte. http://b/28035006.
+  uint8_t buf[128];
+  ASSERT_EQ(128, b64_pton(data, buf, sizeof(buf)));
+}
diff --git a/tests/run-on-host.sh b/tests/run-on-host.sh
new file mode 100755
index 0000000..1f2cb96
--- /dev/null
+++ b/tests/run-on-host.sh
@@ -0,0 +1,35 @@
+#!/bin/bash -e
+
+. $(dirname $0)/../build/run-on-host.sh
+
+if [ "$1" = glibc ]; then
+    m -j bionic-unit-tests-glibc
+    (
+        cd ${ANDROID_BUILD_TOP}
+        export ANDROID_DATA=${TARGET_OUT_DATA}
+        export ANDROID_ROOT=${TARGET_OUT}
+        export LD_LIBRARY_PATH=${HOST_OUT}/obj/lib/
+        ${HOST_OUT}/nativetest64/bionic-unit-tests-glibc/bionic-unit-tests-glibc $@
+    )
+    exit 0
+elif [ "$1" != 32 -a "$1" != 64 ]; then
+    echo "Usage: $0 [ 32 | 64 | glibc ] [gtest flags]"
+    exit 1
+fi
+
+if [ ${HOST_OS}-${HOST_ARCH} = linux-x86 -o ${HOST_OS}-${HOST_ARCH} = linux-x86_64 ]; then
+
+    prepare $1 bionic-unit-tests
+
+    if [ ${TARGET_ARCH} = x86 -o ${TARGET_ARCH} = x86_64 ]; then
+        (
+            cd ${ANDROID_BUILD_TOP}
+            export ANDROID_DATA=${TARGET_OUT_DATA}
+            export ANDROID_DNS_MODE=local
+            export ANDROID_ROOT=${TARGET_OUT}
+            ${NATIVETEST}/bionic-unit-tests/bionic-unit-tests $@
+        )
+    else
+        echo "$0 not supported on TARGET_ARCH=$TARGET_ARCH"
+    fi
+fi
diff --git a/tests/sched_test.cpp b/tests/sched_test.cpp
index caf4c65..a4cffc0 100644
--- a/tests/sched_test.cpp
+++ b/tests/sched_test.cpp
@@ -21,12 +21,12 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#if defined(__BIONIC__)
 static int child_fn(void* i_ptr) {
   *reinterpret_cast<int*>(i_ptr) = 42;
   return 123;
 }
 
+#if defined(__BIONIC__)
 TEST(sched, clone) {
   void* child_stack[1024];
 
@@ -55,7 +55,15 @@
   // Check that our hand-written clone assembler sets errno correctly on failure.
   uintptr_t fake_child_stack[16];
   errno = 0;
-  ASSERT_EQ(-1, clone(NULL, &fake_child_stack[16], CLONE_THREAD, NULL));
+  // If CLONE_THREAD is set, CLONE_SIGHAND must be set too.
+  ASSERT_EQ(-1, clone(child_fn, &fake_child_stack[16], CLONE_THREAD, NULL));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(sched, clone_null_child_stack) {
+  int i = 0;
+  errno = 0;
+  ASSERT_EQ(-1, clone(child_fn, nullptr, CLONE_VM, &i));
   ASSERT_EQ(EINVAL, errno);
 }
 
diff --git a/tests/search_test.cpp b/tests/search_test.cpp
index 3900c89..d368f9f 100644
--- a/tests/search_test.cpp
+++ b/tests/search_test.cpp
@@ -49,7 +49,7 @@
 }
 
 struct node {
-  node(const char* s) : s(strdup(s)) {}
+  explicit node(const char* s) : s(strdup(s)) {}
 
   char* s;
 };
@@ -115,7 +115,7 @@
 }
 
 struct pod_node {
-  pod_node(int i) : i(i) {}
+  explicit pod_node(int i) : i(i) {}
   int i;
 };
 
@@ -136,7 +136,7 @@
 }
 
 struct q_node {
-  q_node(int i) : i(i) {}
+  explicit q_node(int i) : i(i) {}
 
   q_node* next;
   q_node* prev;
diff --git a/tests/setjmp_test.cpp b/tests/setjmp_test.cpp
index b7e856f..bb01601 100644
--- a/tests/setjmp_test.cpp
+++ b/tests/setjmp_test.cpp
@@ -254,7 +254,7 @@
 
   if (value == 0) {
     // Flip a bit.
-    reinterpret_cast<long*>(jb)[0] ^= 1;
+    reinterpret_cast<long*>(jb)[1] ^= 1;
 
     EXPECT_DEATH(longjmp(jb, 1), "checksum mismatch");
   } else {
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index c5128ea..36ac690 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -422,3 +422,108 @@
 
 #endif
 #endif
+
+TEST(signal, sigignore_EINVAL) {
+  errno = 0;
+  ASSERT_EQ(-1, sigignore(99999));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(signal, sigignore) {
+  errno = 0;
+  EXPECT_EQ(-1, sigignore(SIGKILL));
+  EXPECT_EQ(errno, EINVAL);
+
+  errno = 0;
+  EXPECT_EQ(-1, sigignore(SIGSTOP));
+  EXPECT_EQ(errno, EINVAL);
+
+  ScopedSignalHandler sigalrm{SIGALRM};
+  ASSERT_EQ(0, sigignore(SIGALRM));
+
+  struct sigaction sa;
+  ASSERT_EQ(0, sigaction(SIGALRM, nullptr, &sa));
+  EXPECT_EQ(SIG_IGN, sa.sa_handler);
+}
+
+TEST(signal, sighold_EINVAL) {
+  errno = 0;
+  ASSERT_EQ(-1, sighold(99999));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(signal, sigpause_EINVAL) {
+  errno = 0;
+  ASSERT_EQ(-1, sigpause(99999));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(signal, sigrelse_EINVAL) {
+  errno = 0;
+  ASSERT_EQ(-1, sigpause(99999));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(signal, sighold_sigpause_sigrelse) {
+  static int sigalrm_handler_call_count;
+  auto sigalrm_handler = [](int) { sigalrm_handler_call_count++; };
+  ScopedSignalHandler sigalrm{SIGALRM, sigalrm_handler};
+  ScopedSignalMask mask;
+  sigset_t set;
+
+  // sighold(SIGALRM) should add SIGALRM to the signal mask ...
+  ASSERT_EQ(0, sighold(SIGALRM));
+  ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
+  EXPECT_TRUE(sigismember(&set, SIGALRM));
+
+  // ... preventing our SIGALRM handler from running ...
+  raise(SIGALRM);
+  ASSERT_EQ(0, sigalrm_handler_call_count);
+  // ... until sigpause(SIGALRM) temporarily unblocks it.
+  ASSERT_EQ(-1, sigpause(SIGALRM));
+  ASSERT_EQ(EINTR, errno);
+  ASSERT_EQ(1, sigalrm_handler_call_count);
+
+  // But sigpause(SIGALRM) shouldn't permanently unblock SIGALRM.
+  ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
+  EXPECT_TRUE(sigismember(&set, SIGALRM));
+
+  ASSERT_EQ(0, sigrelse(SIGALRM));
+  ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
+  EXPECT_FALSE(sigismember(&set, SIGALRM));
+}
+
+TEST(signal, sigset_EINVAL) {
+  errno = 0;
+  ASSERT_EQ(SIG_ERR, sigset(99999, SIG_DFL));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(signal, sigset) {
+  auto sigalrm_handler = [](int) { };
+  ScopedSignalHandler sigalrm{SIGALRM, sigalrm_handler};
+  ScopedSignalMask mask;
+
+  // block SIGALRM so the next sigset(SIGARLM) call will return SIG_HOLD
+  sigset_t sigalrm_set;
+  sigemptyset(&sigalrm_set);
+  sigaddset(&sigalrm_set, SIGALRM);
+  ASSERT_EQ(0, sigprocmask(SIG_BLOCK, &sigalrm_set, nullptr));
+
+  sigset_t set;
+  ASSERT_EQ(SIG_HOLD, sigset(SIGALRM, sigalrm_handler));
+  ASSERT_EQ(0, sigprocmask(SIG_BLOCK, nullptr, &set));
+  EXPECT_FALSE(sigismember(&set, SIGALRM));
+
+  ASSERT_EQ(sigalrm_handler, sigset(SIGALRM, SIG_IGN));
+  ASSERT_EQ(0, sigprocmask(SIG_BLOCK, nullptr, &set));
+  EXPECT_FALSE(sigismember(&set, SIGALRM));
+
+  ASSERT_EQ(SIG_IGN, sigset(SIGALRM, SIG_DFL));
+  ASSERT_EQ(0, sigprocmask(SIG_BLOCK, nullptr, &set));
+  EXPECT_FALSE(sigismember(&set, SIGALRM));
+
+  ASSERT_EQ(SIG_DFL, sigset(SIGALRM, SIG_HOLD));
+  ASSERT_EQ(0, sigprocmask(SIG_BLOCK, nullptr, &set));
+  EXPECT_TRUE(sigismember(&set, SIGALRM));
+}
diff --git a/tests/stack_protector_test_helper.cpp b/tests/stack_protector_test_helper.cpp
index 53a5e05..3f15a12 100644
--- a/tests/stack_protector_test_helper.cpp
+++ b/tests/stack_protector_test_helper.cpp
@@ -22,10 +22,5 @@
   // Without volatile, the generic x86/x86-64 targets don't write to the stack.
   volatile char* p = buf;
   int size = static_cast<int>(sizeof(buf) + 1);
-#if __x86_64__
-  // The generic x86-64 target leaves an 8-byte gap between `buf` and the stack guard.
-  // We only need to corrupt one byte though.
-  size += 8;
-#endif
   while ((p - buf) < size) *p++ = '\0';
 }
diff --git a/tests/stdatomic_test.cpp b/tests/stdatomic_test.cpp
index eb030bf..22e0c50 100644
--- a/tests/stdatomic_test.cpp
+++ b/tests/stdatomic_test.cpp
@@ -66,8 +66,6 @@
 TEST(stdatomic, atomic_is_lock_free) {
   atomic_char small;
   ASSERT_TRUE(atomic_is_lock_free(&small));
-#if defined(__clang__) || __GNUC_PREREQ(4, 7)
-  // Otherwise stdatomic.h doesn't handle this.
   atomic_intmax_t big;
   // atomic_intmax_t(size = 64) is not lock free on mips32.
 #if defined(__mips__) && !defined(__LP64__)
@@ -75,7 +73,6 @@
 #else
   ASSERT_TRUE(atomic_is_lock_free(&big));
 #endif
-#endif
 }
 
 TEST(stdatomic, atomic_flag) {
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 7e82612..63da9e0 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -29,14 +29,38 @@
 
 #include <vector>
 
+#include "BionicDeathTest.h"
 #include "TemporaryFile.h"
 
 #if defined(NOFORTIFY)
 #define STDIO_TEST stdio_nofortify
+#define STDIO_DEATHTEST stdio_nofortify_DeathTest
 #else
 #define STDIO_TEST stdio
+#define STDIO_DEATHTEST stdio_DeathTest
 #endif
 
+class stdio_DeathTest : public BionicDeathTest {};
+class stdio_nofortify_DeathTest : public BionicDeathTest {};
+
+static void AssertFileIs(FILE* fp, const char* expected, bool is_fmemopen = false) {
+  rewind(fp);
+
+  char line[1024];
+  ASSERT_EQ(line, fgets(line, sizeof(line), fp));
+  ASSERT_STREQ(expected, line);
+
+  if (is_fmemopen) {
+    // fmemopen appends a trailing NUL byte, which probably shouldn't show up as an
+    // extra empty line, but does on every C library I tested...
+    ASSERT_EQ(line, fgets(line, sizeof(line), fp));
+    ASSERT_STREQ("", line);
+  }
+
+  // Make sure there isn't anything else in the file.
+  ASSERT_EQ(nullptr, fgets(line, sizeof(line), fp)) << "junk at end of file: " << line;
+}
+
 TEST(STDIO_TEST, flockfile_18208568_stderr) {
   // Check that we have a _recursive_ mutex for flockfile.
   flockfile(stderr);
@@ -69,13 +93,7 @@
   rc = fprintf(fp, "hello\n");
   ASSERT_EQ(rc, 6);
 
-  rewind(fp);
-
-  char buf[16];
-  char* s = fgets(buf, sizeof(buf), fp);
-  ASSERT_TRUE(s != NULL);
-  ASSERT_STREQ("hello\n", s);
-
+  AssertFileIs(fp, "hello\n");
   fclose(fp);
 }
 
@@ -95,11 +113,7 @@
   FILE* tfile = fdopen(tf.fd, "r");
   ASSERT_TRUE(tfile != NULL);
 
-  char buf[7];
-  ASSERT_EQ(buf, fgets(buf, sizeof(buf), tfile));
-  ASSERT_STREQ("hello\n", buf);
-  // Make sure there isn't anything else in the file.
-  ASSERT_EQ(NULL, fgets(buf, sizeof(buf), tfile));
+  AssertFileIs(tfile, "hello\n");
   fclose(tfile);
 }
 
@@ -388,51 +402,135 @@
 }
 
 template <typename T>
-void CheckInfNan(int snprintf_fn(T*, size_t, const T*, ...),
-                 const T* fmt, const T* fmt_plus,
-                 const T* minus_inf, const T* inf_, const T* plus_inf,
-                 const T* minus_nan, const T* nan_, const T* plus_nan) {
+static void CheckInfNan(int snprintf_fn(T*, size_t, const T*, ...),
+                        int sscanf_fn(const T*, const T*, ...),
+                        const T* fmt_string, const T* fmt, const T* fmt_plus,
+                        const T* minus_inf, const T* inf_, const T* plus_inf,
+                        const T* minus_nan, const T* nan_, const T* plus_nan) {
   T buf[BUFSIZ];
+  float f;
 
-  snprintf_fn(buf, sizeof(buf), fmt, nan(""));
+  // NaN.
+
+  snprintf_fn(buf, sizeof(buf), fmt, nanf(""));
   EXPECT_STREQ(nan_, buf) << fmt;
-  snprintf_fn(buf, sizeof(buf), fmt, -nan(""));
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_TRUE(isnan(f));
+
+  snprintf_fn(buf, sizeof(buf), fmt, -nanf(""));
   EXPECT_STREQ(minus_nan, buf) << fmt;
-  snprintf_fn(buf, sizeof(buf), fmt_plus, nan(""));
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_TRUE(isnan(f));
+
+  snprintf_fn(buf, sizeof(buf), fmt_plus, nanf(""));
   EXPECT_STREQ(plus_nan, buf) << fmt_plus;
-  snprintf_fn(buf, sizeof(buf), fmt_plus, -nan(""));
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_TRUE(isnan(f));
+
+  snprintf_fn(buf, sizeof(buf), fmt_plus, -nanf(""));
   EXPECT_STREQ(minus_nan, buf) << fmt_plus;
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_TRUE(isnan(f));
 
-  snprintf_fn(buf, sizeof(buf), fmt, HUGE_VAL);
+  // Inf.
+
+  snprintf_fn(buf, sizeof(buf), fmt, HUGE_VALF);
   EXPECT_STREQ(inf_, buf) << fmt;
-  snprintf_fn(buf, sizeof(buf), fmt, -HUGE_VAL);
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_EQ(HUGE_VALF, f);
+
+  snprintf_fn(buf, sizeof(buf), fmt, -HUGE_VALF);
   EXPECT_STREQ(minus_inf, buf) << fmt;
-  snprintf_fn(buf, sizeof(buf), fmt_plus, HUGE_VAL);
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_EQ(-HUGE_VALF, f);
+
+  snprintf_fn(buf, sizeof(buf), fmt_plus, HUGE_VALF);
   EXPECT_STREQ(plus_inf, buf) << fmt_plus;
-  snprintf_fn(buf, sizeof(buf), fmt_plus, -HUGE_VAL);
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_EQ(HUGE_VALF, f);
+
+  snprintf_fn(buf, sizeof(buf), fmt_plus, -HUGE_VALF);
   EXPECT_STREQ(minus_inf, buf) << fmt_plus;
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
+  EXPECT_EQ(-HUGE_VALF, f);
+
+  // Check case-insensitivity.
+  snprintf_fn(buf, sizeof(buf), fmt_string, "[InFiNiTy]");
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf;
+  EXPECT_EQ(HUGE_VALF, f);
+  snprintf_fn(buf, sizeof(buf), fmt_string, "[NaN]");
+  EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf;
+  EXPECT_TRUE(isnan(f));
 }
 
-TEST(STDIO_TEST, snprintf_inf_nan) {
-  CheckInfNan(snprintf, "%a", "%+a", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
-  CheckInfNan(snprintf, "%A", "%+A", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
-  CheckInfNan(snprintf, "%e", "%+e", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
-  CheckInfNan(snprintf, "%E", "%+E", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
-  CheckInfNan(snprintf, "%f", "%+f", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
-  CheckInfNan(snprintf, "%F", "%+F", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
-  CheckInfNan(snprintf, "%g", "%+g", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
-  CheckInfNan(snprintf, "%G", "%+G", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
+TEST(STDIO_TEST, snprintf_sscanf_inf_nan) {
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%a]", "[%+a]",
+              "[-inf]", "[inf]", "[+inf]",
+              "[-nan]", "[nan]", "[+nan]");
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%A]", "[%+A]",
+              "[-INF]", "[INF]", "[+INF]",
+              "[-NAN]", "[NAN]", "[+NAN]");
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%e]", "[%+e]",
+              "[-inf]", "[inf]", "[+inf]",
+              "[-nan]", "[nan]", "[+nan]");
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%E]", "[%+E]",
+              "[-INF]", "[INF]", "[+INF]",
+              "[-NAN]", "[NAN]", "[+NAN]");
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%f]", "[%+f]",
+              "[-inf]", "[inf]", "[+inf]",
+              "[-nan]", "[nan]", "[+nan]");
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%F]", "[%+F]",
+              "[-INF]", "[INF]", "[+INF]",
+              "[-NAN]", "[NAN]", "[+NAN]");
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%g]", "[%+g]",
+              "[-inf]", "[inf]", "[+inf]",
+              "[-nan]", "[nan]", "[+nan]");
+  CheckInfNan(snprintf, sscanf, "%s",
+              "[%G]", "[%+G]",
+              "[-INF]", "[INF]", "[+INF]",
+              "[-NAN]", "[NAN]", "[+NAN]");
 }
 
-TEST(STDIO_TEST, wsprintf_inf_nan) {
-  CheckInfNan(swprintf, L"%a", L"%+a", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
-  CheckInfNan(swprintf, L"%A", L"%+A", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
-  CheckInfNan(swprintf, L"%e", L"%+e", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
-  CheckInfNan(swprintf, L"%E", L"%+E", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
-  CheckInfNan(swprintf, L"%f", L"%+f", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
-  CheckInfNan(swprintf, L"%F", L"%+F", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
-  CheckInfNan(swprintf, L"%g", L"%+g", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
-  CheckInfNan(swprintf, L"%G", L"%+G", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
+TEST(STDIO_TEST, swprintf_swscanf_inf_nan) {
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%a]", L"[%+a]",
+              L"[-inf]", L"[inf]", L"[+inf]",
+              L"[-nan]", L"[nan]", L"[+nan]");
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%A]", L"[%+A]",
+              L"[-INF]", L"[INF]", L"[+INF]",
+              L"[-NAN]", L"[NAN]", L"[+NAN]");
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%e]", L"[%+e]",
+              L"[-inf]", L"[inf]", L"[+inf]",
+              L"[-nan]", L"[nan]", L"[+nan]");
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%E]", L"[%+E]",
+              L"[-INF]", L"[INF]", L"[+INF]",
+              L"[-NAN]", L"[NAN]", L"[+NAN]");
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%f]", L"[%+f]",
+              L"[-inf]", L"[inf]", L"[+inf]",
+              L"[-nan]", L"[nan]", L"[+nan]");
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%F]", L"[%+F]",
+              L"[-INF]", L"[INF]", L"[+INF]",
+              L"[-NAN]", L"[NAN]", L"[+NAN]");
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%g]", L"[%+g]",
+              L"[-inf]", L"[inf]", L"[+inf]",
+              L"[-nan]", L"[nan]", L"[+nan]");
+  CheckInfNan(swprintf, swscanf, L"%s",
+              L"[%G]", L"[%+G]",
+              L"[-INF]", L"[INF]", L"[+INF]",
+              L"[-NAN]", L"[NAN]", L"[+NAN]");
 }
 
 TEST(STDIO_TEST, snprintf_d_INT_MAX) {
@@ -450,7 +548,7 @@
 TEST(STDIO_TEST, snprintf_ld_LONG_MAX) {
   char buf[BUFSIZ];
   snprintf(buf, sizeof(buf), "%ld", LONG_MAX);
-#if __LP64__
+#if defined(__LP64__)
   EXPECT_STREQ("9223372036854775807", buf);
 #else
   EXPECT_STREQ("2147483647", buf);
@@ -460,7 +558,7 @@
 TEST(STDIO_TEST, snprintf_ld_LONG_MIN) {
   char buf[BUFSIZ];
   snprintf(buf, sizeof(buf), "%ld", LONG_MIN);
-#if __LP64__
+#if defined(__LP64__)
   EXPECT_STREQ("-9223372036854775808", buf);
 #else
   EXPECT_STREQ("-2147483648", buf);
@@ -568,6 +666,17 @@
   ASSERT_EQ(ENOMEM, errno);
 }
 
+TEST(STDIO_TEST, fprintf) {
+  TemporaryFile tf;
+
+  FILE* tfile = fdopen(tf.fd, "r+");
+  ASSERT_TRUE(tfile != nullptr);
+
+  ASSERT_EQ(7, fprintf(tfile, "%d %s", 123, "abc"));
+  AssertFileIs(tfile, "123 abc");
+  fclose(tfile);
+}
+
 TEST(STDIO_TEST, fprintf_failures_7229520) {
   // http://b/7229520
   FILE* fp;
@@ -621,15 +730,34 @@
   fclose(fp);
 }
 
-TEST(STDIO_TEST, sscanf) {
-  char s1[123];
-  int i1;
-  double d1;
-  char s2[123];
-  ASSERT_EQ(3, sscanf("  hello 123 1.23 ", "%s %i %lf %s", s1, &i1, &d1, s2));
-  ASSERT_STREQ("hello", s1);
-  ASSERT_EQ(123, i1);
-  ASSERT_DOUBLE_EQ(1.23, d1);
+TEST(STDIO_TEST, sscanf_swscanf) {
+  struct stuff {
+    char s1[123];
+    int i1;
+    double d1;
+    float f1;
+    char s2[123];
+
+    void Check() {
+      ASSERT_STREQ("hello", s1);
+      ASSERT_EQ(123, i1);
+      ASSERT_DOUBLE_EQ(1.23, d1);
+      ASSERT_FLOAT_EQ(9.0f, f1);
+      ASSERT_STREQ("world", s2);
+    }
+  } s;
+
+  memset(&s, 0, sizeof(s));
+  ASSERT_EQ(5, sscanf("  hello 123 1.23 0x1.2p3 world",
+                      "%s %i %lf %f %s",
+                      s.s1, &s.i1, &s.d1, &s.f1, s.s2));
+  s.Check();
+
+  memset(&s, 0, sizeof(s));
+  ASSERT_EQ(5, swscanf(L"  hello 123 1.23 0x1.2p3 world",
+                       L"%s %i %lf %f %s",
+                       s.s1, &s.i1, &s.d1, &s.f1, s.s2));
+  s.Check();
 }
 
 TEST(STDIO_TEST, cantwrite_EBADF) {
@@ -806,13 +934,7 @@
 
   ASSERT_STREQ("<abc>\n", buf);
 
-  rewind(fp);
-
-  char line[16];
-  char* s = fgets(line, sizeof(line), fp);
-  ASSERT_TRUE(s != NULL);
-  ASSERT_STREQ("<abc>\n", s);
-
+  AssertFileIs(fp, "<abc>\n", true);
   fclose(fp);
 }
 
@@ -820,13 +942,7 @@
   FILE* fp = fmemopen(nullptr, 128, "r+");
   ASSERT_NE(EOF, fputs("xyz\n", fp));
 
-  rewind(fp);
-
-  char line[16];
-  char* s = fgets(line, sizeof(line), fp);
-  ASSERT_TRUE(s != NULL);
-  ASSERT_STREQ("xyz\n", s);
-
+  AssertFileIs(fp, "xyz\n", true);
   fclose(fp);
 }
 
@@ -1196,15 +1312,10 @@
   }
 
   for (size_t i = 0; i < 256; ++i) {
-    rewind(fps[i]);
-
-    char buf[BUFSIZ];
-    ASSERT_TRUE(fgets(buf, sizeof(buf), fps[i]) != nullptr);
-
     char expected[BUFSIZ];
     snprintf(expected, sizeof(expected), "hello %zu!\n", i);
-    ASSERT_STREQ(expected, buf);
 
+    AssertFileIs(fps[i], expected);
     fclose(fps[i]);
     delete tfs[i];
   }
@@ -1297,3 +1408,58 @@
 
   fclose(fp);
 }
+
+TEST(STDIO_TEST, ctermid) {
+  ASSERT_STREQ("/dev/tty", ctermid(nullptr));
+
+  char buf[L_ctermid] = {};
+  ASSERT_EQ(buf, ctermid(buf));
+  ASSERT_STREQ("/dev/tty", buf);
+}
+
+TEST(STDIO_TEST, remove) {
+  struct stat sb;
+
+  TemporaryFile tf;
+  ASSERT_EQ(0, remove(tf.filename));
+  ASSERT_EQ(-1, lstat(tf.filename, &sb));
+  ASSERT_EQ(ENOENT, errno);
+
+  TemporaryDir td;
+  ASSERT_EQ(0, remove(td.dirname));
+  ASSERT_EQ(-1, lstat(td.dirname, &sb));
+  ASSERT_EQ(ENOENT, errno);
+
+  errno = 0;
+  ASSERT_EQ(-1, remove(tf.filename));
+  ASSERT_EQ(ENOENT, errno);
+
+  errno = 0;
+  ASSERT_EQ(-1, remove(td.dirname));
+  ASSERT_EQ(ENOENT, errno);
+}
+
+TEST(STDIO_DEATHTEST, snprintf_30445072_known_buffer_size) {
+  char buf[16];
+  ASSERT_EXIT(snprintf(buf, atol("-1"), "hello"),
+              testing::KilledBySignal(SIGABRT),
+#if defined(NOFORTIFY)
+              "FORTIFY: vsnprintf: size .* > SSIZE_MAX"
+#else
+              "FORTIFY: vsnprintf: prevented .*-byte write into 16-byte buffer"
+#endif
+              );
+}
+
+TEST(STDIO_DEATHTEST, snprintf_30445072_unknown_buffer_size) {
+  std::string buf = "world";
+  ASSERT_EXIT(snprintf(&buf[0], atol("-1"), "hello"),
+              testing::KilledBySignal(SIGABRT),
+              "FORTIFY: vsnprintf: size .* > SSIZE_MAX");
+}
+
+TEST(STDIO_TEST, sprintf_30445072) {
+  std::string buf = "world";
+  sprintf(&buf[0], "hello");
+  ASSERT_EQ(buf, "hello");
+}
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 6ae6cda..5b9442f 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -17,16 +17,18 @@
 #include <gtest/gtest.h>
 
 #include "BionicDeathTest.h"
+#include "math_data_test.h"
 #include "TemporaryFile.h"
 #include "utils.h"
 
 #include <errno.h>
+#include <fcntl.h>
 #include <libgen.h>
 #include <limits.h>
+#include <math.h>
 #include <pthread.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <fcntl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
@@ -288,16 +290,65 @@
   ASSERT_DOUBLE_EQ(1.23, atof("1.23"));
 }
 
+template <typename T>
+static void CheckStrToFloat(T fn(const char* s, char** end)) {
+  FpUlpEq<0, T> pred;
+
+  EXPECT_PRED_FORMAT2(pred, 9.0, fn("9.0", nullptr));
+  EXPECT_PRED_FORMAT2(pred, 9.0, fn("0.9e1", nullptr));
+  EXPECT_PRED_FORMAT2(pred, 9.0, fn("0x1.2p3", nullptr));
+
+  EXPECT_TRUE(isnan(fn("+nan", nullptr)));
+  EXPECT_TRUE(isnan(fn("nan", nullptr)));
+  EXPECT_TRUE(isnan(fn("-nan", nullptr)));
+
+  EXPECT_TRUE(isnan(fn("+nan(0xff)", nullptr)));
+  EXPECT_TRUE(isnan(fn("nan(0xff)", nullptr)));
+  EXPECT_TRUE(isnan(fn("-nan(0xff)", nullptr)));
+
+  char* p;
+  EXPECT_TRUE(isnan(fn("+nanny", &p)));
+  EXPECT_STREQ("ny", p);
+  EXPECT_TRUE(isnan(fn("nanny", &p)));
+  EXPECT_STREQ("ny", p);
+  EXPECT_TRUE(isnan(fn("-nanny", &p)));
+  EXPECT_STREQ("ny", p);
+
+  EXPECT_EQ(0, fn("muppet", &p));
+  EXPECT_STREQ("muppet", p);
+  EXPECT_EQ(0, fn("  muppet", &p));
+  EXPECT_STREQ("  muppet", p);
+
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn("+inf", nullptr));
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn("inf", nullptr));
+  EXPECT_EQ(-std::numeric_limits<T>::infinity(), fn("-inf", nullptr));
+
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn("+infinity", nullptr));
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn("infinity", nullptr));
+  EXPECT_EQ(-std::numeric_limits<T>::infinity(), fn("-infinity", nullptr));
+
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn("+infinitude", &p));
+  EXPECT_STREQ("initude", p);
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn("infinitude", &p));
+  EXPECT_STREQ("initude", p);
+  EXPECT_EQ(-std::numeric_limits<T>::infinity(), fn("-infinitude", &p));
+  EXPECT_STREQ("initude", p);
+
+  // Check case-insensitivity.
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn("InFiNiTy", nullptr));
+  EXPECT_TRUE(isnan(fn("NaN", nullptr)));
+}
+
 TEST(stdlib, strtod) {
-  ASSERT_DOUBLE_EQ(1.23, strtod("1.23", NULL));
+  CheckStrToFloat(strtod);
 }
 
 TEST(stdlib, strtof) {
-  ASSERT_FLOAT_EQ(1.23, strtof("1.23", NULL));
+  CheckStrToFloat(strtof);
 }
 
 TEST(stdlib, strtold) {
-  ASSERT_DOUBLE_EQ(1.23, strtold("1.23", NULL));
+  CheckStrToFloat(strtold);
 }
 
 TEST(stdlib, strtof_2206701) {
@@ -514,3 +565,49 @@
   strtoull("123", NULL, 37);
   ASSERT_EQ(EINVAL, errno);
 }
+
+TEST(stdlib, getsubopt) {
+  char* const tokens[] = {
+    const_cast<char*>("a"),
+    const_cast<char*>("b"),
+    const_cast<char*>("foo"),
+    nullptr
+  };
+  std::string input = "a,b,foo=bar,a,unknown";
+  char* subopts = &input[0];
+  char* value = nullptr;
+
+  ASSERT_EQ(0, getsubopt(&subopts, tokens, &value));
+  ASSERT_EQ(nullptr, value);
+  ASSERT_EQ(1, getsubopt(&subopts, tokens, &value));
+  ASSERT_EQ(nullptr, value);
+  ASSERT_EQ(2, getsubopt(&subopts, tokens, &value));
+  ASSERT_STREQ("bar", value);
+  ASSERT_EQ(0, getsubopt(&subopts, tokens, &value));
+  ASSERT_EQ(nullptr, value);
+
+  ASSERT_EQ(-1, getsubopt(&subopts, tokens, &value));
+}
+
+TEST(stdlib, mblen) {
+  // "If s is a null pointer, mblen() shall return a non-zero or 0 value, if character encodings,
+  // respectively, do or do not have state-dependent encodings." We're always UTF-8.
+  EXPECT_EQ(0, mblen(nullptr, 1));
+
+  ASSERT_STREQ("C.UTF-8", setlocale(LC_ALL, "C.UTF-8"));
+
+  // 1-byte UTF-8.
+  EXPECT_EQ(1, mblen("abcdef", 6));
+  // 2-byte UTF-8.
+  EXPECT_EQ(2, mblen("\xc2\xa2" "cdef", 6));
+  // 3-byte UTF-8.
+  EXPECT_EQ(3, mblen("\xe2\x82\xac" "def", 6));
+  // 4-byte UTF-8.
+  EXPECT_EQ(4, mblen("\xf0\xa4\xad\xa2" "ef", 6));
+
+  // Illegal over-long sequence.
+  ASSERT_EQ(-1, mblen("\xf0\x82\x82\xac" "ef", 6));
+
+  // "mblen() shall ... return 0 (if s points to the null byte)".
+  EXPECT_EQ(0, mblen("", 1));
+}
diff --git a/tests/string_posix_strerror_r_test.cpp b/tests/string_posix_strerror_r_test.cpp
index ae3b41a..596684b 100644
--- a/tests/string_posix_strerror_r_test.cpp
+++ b/tests/string_posix_strerror_r_test.cpp
@@ -20,7 +20,7 @@
 #if defined(__GLIBC__)
 
 // At the time of writing, libcxx -- which is dragged in by gtest -- assumes
-// declarations from glibc of things that aren't available without __USE_GNU.
+// declarations from glibc of things that aren't available without _GNU_SOURCE.
 // This means we can't even build this test (which is a problem because that
 // means it doesn't get included in CTS).
 // For glibc 2.15, the symbols in question are:
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index 4b2cca2..385fe33 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -40,10 +40,10 @@
 #define STRLCAT_SUPPORTED
 #endif
 
-#define KB 1024
-#define SMALL 1*KB
-#define MEDIUM 4*KB
-#define LARGE 64*KB
+constexpr auto KB = 1024;
+constexpr auto SMALL = 1 * KB;
+constexpr auto MEDIUM = 4 * KB;
+constexpr auto LARGE = 64 * KB;
 
 static int signum(int i) {
   if (i < 0) {
@@ -163,7 +163,7 @@
 template<class Character>
 class StringTestState {
  public:
-  StringTestState(size_t MAX_LEN) : MAX_LEN(MAX_LEN), align1_index_(0), align2_index_(0) {
+  explicit StringTestState(size_t MAX_LEN) : MAX_LEN(MAX_LEN), align1_index_(0), align2_index_(0) {
     int max_alignment = 64;
 
     // TODO: fix the tests to not sometimes use twice their specified "MAX_LEN".
@@ -1455,3 +1455,32 @@
   }
   RunSingleBufferAlignTest(MEDIUM, DoMemcpySameTest);
 }
+
+TEST(STRING_TEST, memmem_strstr_empty_needle) {
+  const char* some_haystack = "haystack";
+  const char* empty_haystack = "";
+
+  ASSERT_EQ(some_haystack, memmem(some_haystack, 8, "", 0));
+  ASSERT_EQ(empty_haystack, memmem(empty_haystack, 0, "", 0));
+
+  ASSERT_EQ(some_haystack, strstr(some_haystack, ""));
+  ASSERT_EQ(empty_haystack, strstr(empty_haystack, ""));
+}
+
+TEST(STRING_TEST, memmem_smoke) {
+  const char haystack[] = "big\0daddy\0giant\0haystacks";
+  ASSERT_EQ(haystack, memmem(haystack, sizeof(haystack), "", 0));
+  ASSERT_EQ(haystack + 3, memmem(haystack, sizeof(haystack), "", 1));
+  ASSERT_EQ(haystack + 0, memmem(haystack, sizeof(haystack), "b", 1));
+  ASSERT_EQ(haystack + 1, memmem(haystack, sizeof(haystack), "i", 1));
+  ASSERT_EQ(haystack + 4, memmem(haystack, sizeof(haystack), "da", 2));
+  ASSERT_EQ(haystack + 8, memmem(haystack, sizeof(haystack), "y\0g", 3));
+}
+
+TEST(STRING_TEST, strstr_smoke) {
+  const char* haystack = "big daddy/giant haystacks";
+  ASSERT_EQ(haystack, strstr(haystack, ""));
+  ASSERT_EQ(haystack + 0, strstr(haystack, "b"));
+  ASSERT_EQ(haystack + 1, strstr(haystack, "i"));
+  ASSERT_EQ(haystack + 4, strstr(haystack, "da"));
+}
diff --git a/tests/sys_epoll_test.cpp b/tests/sys_epoll_test.cpp
index 6e7a807..f6be4af 100644
--- a/tests/sys_epoll_test.cpp
+++ b/tests/sys_epoll_test.cpp
@@ -40,6 +40,12 @@
   ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, &ss));
 }
 
+TEST(sys_epoll, epoll_create_invalid_size) {
+  errno = 0;
+  ASSERT_EQ(-1, epoll_create(0));
+  ASSERT_EQ(EINVAL, errno);
+}
+
 TEST(sys_epoll, epoll_event_data) {
   int epoll_fd = epoll_create(1);
   ASSERT_NE(-1, epoll_fd) << strerror(errno);
diff --git a/tests/sys_msg_test.cpp b/tests/sys_msg_test.cpp
new file mode 100644
index 0000000..05ad01b
--- /dev/null
+++ b/tests/sys_msg_test.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <sys/msg.h>
+
+#include "TemporaryFile.h"
+
+TEST(sys_msg, smoke) {
+  if (msgctl(-1, IPC_STAT, nullptr) == -1 && errno == ENOSYS) {
+    GTEST_LOG_(INFO) << "no <sys/msg.h> support in this kernel\n";
+    return;
+  }
+
+  // Create a queue.
+  TemporaryDir dir;
+  key_t key = ftok(dir.dirname, 1);
+  int id = msgget(key, IPC_CREAT|0666);
+  ASSERT_NE(id, -1);
+
+  // Queue should be empty.
+  msqid_ds ds;
+  memset(&ds, 0, sizeof(ds));
+  ASSERT_EQ(0, msgctl(id, IPC_STAT, &ds));
+  ASSERT_EQ(0U, ds.msg_qnum);
+  ASSERT_EQ(0U, ds.msg_cbytes);
+
+  // Send a message.
+  struct {
+    long type;
+    char data[32];
+  } msg = { 1, "hello world" };
+  ASSERT_EQ(0, msgsnd(id, &msg, sizeof(msg), 0));
+
+  // Queue should be non-empty.
+  ASSERT_EQ(0, msgctl(id, IPC_STAT, &ds));
+  ASSERT_EQ(1U, ds.msg_qnum);
+  ASSERT_EQ(sizeof(msg), ds.msg_cbytes);
+
+  // Read the message.
+  memset(&msg, 0, sizeof(msg));
+  ASSERT_EQ(static_cast<ssize_t>(sizeof(msg)), msgrcv(id, &msg, sizeof(msg), 0, 0));
+  ASSERT_EQ(1, msg.type);
+  ASSERT_STREQ("hello world", msg.data);
+
+  // Destroy the queue.
+  ASSERT_EQ(0, msgctl(id, IPC_RMID, 0));
+}
+
+TEST(sys_msg, msgctl_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, msgctl(-1, IPC_STAT, nullptr));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_msg, msgget_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, msgget(-1, 0));
+  ASSERT_TRUE(errno == ENOENT || errno == ENOSYS);
+}
+
+TEST(sys_msg, msgrcv_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, msgrcv(-1, nullptr, 0, 0, 0));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_msg, msgsnd_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, msgsnd(-1, "", 0, 0));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
diff --git a/tests/sys_prctl_test.cpp b/tests/sys_prctl_test.cpp
index 5a563c1..205db86 100644
--- a/tests/sys_prctl_test.cpp
+++ b/tests/sys_prctl_test.cpp
@@ -14,24 +14,51 @@
  * limitations under the License.
  */
 
-#include <gtest/gtest.h>
-
+#include <inttypes.h>
+#include <stdio.h>
 #include <sys/mman.h>
 #include <sys/prctl.h>
 #include <unistd.h>
+
+#include <string>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include "android-base/file.h"
+#include "android-base/strings.h"
 #include "private/bionic_prctl.h"
 
 // http://b/20017123.
 TEST(sys_prctl, bug_20017123) {
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) // PR_SET_VMA is only available in Android kernels.
   size_t page_size = static_cast<size_t>(sysconf(_SC_PAGESIZE));
   void* p = mmap(NULL, page_size * 3, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   ASSERT_NE(MAP_FAILED, p);
   ASSERT_EQ(0, mprotect(p, page_size, PROT_NONE));
   ASSERT_NE(-1, prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, p, page_size * 3, "anonymous map space"));
-  volatile char* vp = reinterpret_cast<volatile char*>(p);
-  // Below memory access causes SEGV if the memory map is screwed up.
-  *(vp + page_size) = 0;
+  // Now read the maps and verify that there are no overlapped maps.
+  std::string file_data;
+  ASSERT_TRUE(android::base::ReadFileToString("/proc/self/maps", &file_data));
+
+  uintptr_t last_start = 0;
+  uintptr_t last_end = 0;
+  std::vector<std::string> lines = android::base::Split(file_data, "\n");
+  for (size_t i = 0; i < lines.size(); i++) {
+    if (lines[i].empty()) {
+      continue;
+    }
+    uintptr_t start;
+    uintptr_t end;
+    ASSERT_EQ(2, sscanf(lines[i].c_str(), "%" SCNxPTR "-%" SCNxPTR " ", &start, &end))
+        << "Failed to parse line: " << lines[i];
+    // This will never fail on the first line, so no need to do any special checking.
+    ASSERT_GE(start, last_end)
+        << "Overlapping map detected:\n" << lines[i -1] << '\n' << lines[i] << '\n';
+    last_start = start;
+    last_end = end;
+  }
+
   ASSERT_EQ(0, munmap(p, page_size * 3));
 #else
   GTEST_LOG_(INFO) << "This test does nothing as it tests an Android specific kernel feature.";
diff --git a/tests/sys_ptrace_test.cpp b/tests/sys_ptrace_test.cpp
new file mode 100644
index 0000000..bdd6a89
--- /dev/null
+++ b/tests/sys_ptrace_test.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/ptrace.h>
+
+#include <elf.h>
+#include <sched.h>
+#include <sys/prctl.h>
+#include <sys/uio.h>
+#include <sys/user.h>
+#include <unistd.h>
+
+#include <gtest/gtest.h>
+
+// Host libc does not define this.
+#ifndef TRAP_HWBKPT
+#define TRAP_HWBKPT 4
+#endif
+
+template<typename T>
+static void __attribute__((noreturn)) fork_child(unsigned cpu, T &data) {
+  // Extra precaution: make sure we go away if anything happens to our parent.
+  if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) == -1) {
+    perror("prctl(PR_SET_PDEATHSIG)");
+    _exit(1);
+  }
+
+  cpu_set_t cpus;
+  CPU_ZERO(&cpus);
+  CPU_SET(cpu, &cpus);
+  if (sched_setaffinity(0, sizeof cpus, &cpus) == -1) {
+    perror("sched_setaffinity");
+    _exit(2);
+  }
+  if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1) {
+    perror("ptrace(PTRACE_TRACEME)");
+    _exit(3);
+  }
+
+  raise(SIGSTOP); // Synchronize with the tracer, let it set the watchpoint.
+
+  data = 1; // Now trigger the watchpoint.
+
+  _exit(0);
+}
+
+class ChildGuard {
+ public:
+  explicit ChildGuard(pid_t pid) : pid(pid) {}
+
+  ~ChildGuard() {
+    kill(pid, SIGKILL);
+    int status;
+    waitpid(pid, &status, 0);
+  }
+
+ private:
+  pid_t pid;
+};
+
+static bool are_watchpoints_supported(pid_t child) {
+#if defined(__arm__)
+  long capabilities;
+  long result = ptrace(PTRACE_GETHBPREGS, child, 0, &capabilities);
+  if (result == -1) {
+    EXPECT_EQ(EIO, errno);
+    return false;
+  }
+  return ((capabilities >> 8) & 0xff) > 0;
+#elif defined(__aarch64__)
+  user_hwdebug_state dreg_state;
+  iovec iov;
+  iov.iov_base = &dreg_state;
+  iov.iov_len = sizeof(dreg_state);
+
+  long result = ptrace(PTRACE_GETREGSET, child, NT_ARM_HW_WATCH, &iov);
+  if (result == -1) {
+    EXPECT_EQ(EINVAL, errno);
+    return false;
+  }
+  return (dreg_state.dbg_info & 0xff) > 0;
+#elif defined(__i386__) || defined(__x86_64__)
+  // We assume watchpoints are always supported on x86.
+  (void) child;
+  return true;
+#else
+  // TODO: mips support.
+  (void) child;
+  return false;
+#endif
+}
+
+static void set_watchpoint(pid_t child, const void *address, size_t size) {
+#if defined(__arm__) || defined(__aarch64__)
+  const unsigned byte_mask = (1 << size) - 1;
+  const unsigned type = 2; // Write.
+  const unsigned enable = 1;
+  const unsigned control = byte_mask << 5 | type << 3 | enable;
+
+#ifdef __arm__
+  ASSERT_EQ(0, ptrace(PTRACE_SETHBPREGS, child, -1, &address)) << strerror(errno);
+  ASSERT_EQ(0, ptrace(PTRACE_SETHBPREGS, child, -2, &control)) << strerror(errno);
+#else // aarch64
+  user_hwdebug_state dreg_state;
+  memset(&dreg_state, 0, sizeof dreg_state);
+  dreg_state.dbg_regs[0].addr = reinterpret_cast<uintptr_t>(address);
+  dreg_state.dbg_regs[0].ctrl = control;
+
+  iovec iov;
+  iov.iov_base = &dreg_state;
+  iov.iov_len = offsetof(user_hwdebug_state, dbg_regs) + sizeof(dreg_state.dbg_regs[0]);
+
+  ASSERT_EQ(0, ptrace(PTRACE_SETREGSET, child, NT_ARM_HW_WATCH, &iov)) << strerror(errno);
+#endif
+#elif defined(__i386__) || defined(__x86_64__)
+  ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[0]), address)) << strerror(errno);
+  errno = 0;
+  unsigned data = ptrace(PTRACE_PEEKUSER, child, offsetof(user, u_debugreg[7]), nullptr);
+  ASSERT_EQ(0, errno);
+
+  const unsigned size_flag = (size == 8) ? 2 : size - 1;
+  const unsigned enable = 1;
+  const unsigned type = 1; // Write.
+
+  const unsigned mask = 3 << 18 | 3 << 16 | 1;
+  const unsigned value = size_flag << 18 | type << 16 | enable;
+  data &= mask;
+  data |= value;
+  ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[7]), data)) << strerror(errno);
+#else
+  (void) child;
+  (void) address;
+  (void) size;
+#endif
+}
+
+template<typename T>
+static void run_watchpoint_test_impl(unsigned cpu) {
+  alignas(8) T data = 0;
+
+  pid_t child = fork();
+  ASSERT_NE(-1, child) << strerror(errno);
+  if (child == 0) fork_child(cpu, data);
+
+  ChildGuard guard(child);
+
+  int status;
+  ASSERT_EQ(child, waitpid(child, &status, __WALL)) << strerror(errno);
+  ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status;
+  ASSERT_EQ(SIGSTOP, WSTOPSIG(status)) << "Status was: " << status;
+
+  if (!are_watchpoints_supported(child)) return;
+
+  set_watchpoint(child, &data, sizeof data);
+
+  ASSERT_EQ(0, ptrace(PTRACE_CONT, child, nullptr, nullptr)) << strerror(errno);
+  ASSERT_EQ(child, waitpid(child, &status, __WALL)) << strerror(errno);
+  ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status;
+  ASSERT_EQ(SIGTRAP, WSTOPSIG(status)) << "Status was: " << status;
+
+  siginfo_t siginfo;
+  ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child, nullptr, &siginfo)) << strerror(errno);
+  ASSERT_EQ(TRAP_HWBKPT, siginfo.si_code);
+#if defined(__arm__) || defined(__aarch64__)
+  ASSERT_EQ(&data, siginfo.si_addr);
+#endif
+}
+
+static void run_watchpoint_test(unsigned cpu) {
+  run_watchpoint_test_impl<uint8_t>(cpu);
+  run_watchpoint_test_impl<uint16_t>(cpu);
+  run_watchpoint_test_impl<uint32_t>(cpu);
+#if defined(__LP64__)
+  run_watchpoint_test_impl<uint64_t>(cpu);
+#endif
+}
+
+// Test watchpoint API. The test is considered successful if our watchpoints get hit OR the
+// system reports that watchpoint support is not present. We run the test for different
+// watchpoint sizes, while pinning the process to each cpu in turn, for better coverage.
+TEST(ptrace, watchpoint_stress) {
+  cpu_set_t available_cpus;
+  ASSERT_EQ(0, sched_getaffinity(0, sizeof available_cpus, &available_cpus));
+
+  for (size_t cpu = 0; cpu < CPU_SETSIZE; ++cpu) {
+    if (!CPU_ISSET(cpu, &available_cpus)) continue;
+    run_watchpoint_test(cpu);
+  }
+}
diff --git a/tests/sys_quota_test.cpp b/tests/sys_quota_test.cpp
new file mode 100644
index 0000000..e23207b
--- /dev/null
+++ b/tests/sys_quota_test.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/quota.h>
+
+#include <gtest/gtest.h>
+
+TEST(sys_quota, quotactl_dqblk) {
+  // We don't even have kernels with CONFIG_QUOTA enabled right now.
+  // This just tests that we can compile reasonable code.
+  dqblk current;
+  quotactl(QCMD(Q_GETQUOTA, USRQUOTA), "/", getuid(), reinterpret_cast<char*>(&current));
+}
+
+TEST(sys_quota, quotactl_dqinfo) {
+  // We don't even have kernels with CONFIG_QUOTA enabled right now.
+  // This just tests that we can compile reasonable code.
+  dqinfo current;
+  quotactl(QCMD(Q_GETINFO, USRQUOTA), "/", 0, reinterpret_cast<char*>(&current));
+}
diff --git a/tests/sys_sem_test.cpp b/tests/sys_sem_test.cpp
new file mode 100644
index 0000000..d8d83c5
--- /dev/null
+++ b/tests/sys_sem_test.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <sys/sem.h>
+
+#include "TemporaryFile.h"
+
+TEST(sys_sem, smoke) {
+  if (semctl(-1, 0, IPC_RMID) == -1 && errno == ENOSYS) {
+    GTEST_LOG_(INFO) << "no <sys/sem.h> support in this kernel\n";
+    return;
+  }
+
+  // Create a semaphore.
+  TemporaryDir dir;
+  key_t key = ftok(dir.dirname, 1);
+  int id = semget(key, 1, IPC_CREAT|0666);
+  ASSERT_NE(id, -1);
+
+  // Check semaphore info.
+  semid_ds ds;
+  memset(&ds, 0, sizeof(ds));
+  ASSERT_EQ(0, semctl(id, 0, IPC_STAT, &ds));
+  ASSERT_EQ(1U, ds.sem_nsems);
+
+  ASSERT_EQ(0, semctl(id, 0, GETVAL));
+
+  // Increment.
+  sembuf ops[] = {{ .sem_num = 0, .sem_op = 1, .sem_flg = 0 }};
+  ASSERT_EQ(0, semop(id, ops, 1));
+  ASSERT_EQ(1, semctl(id, 0, GETVAL));
+
+  // Test timeouts.
+  timespec ts = { .tv_sec = 0, .tv_nsec = 100 };
+  ops[0] = { .sem_num = 0, .sem_op = 0, .sem_flg = 0 };
+  errno = 0;
+  ASSERT_EQ(-1, semtimedop(id, ops, 1, &ts));
+  ASSERT_EQ(EAGAIN, errno);
+  ASSERT_EQ(1, semctl(id, 0, GETVAL));
+
+  // Decrement.
+  ops[0] = { .sem_num = 0, .sem_op = -1, .sem_flg = 0 };
+  ASSERT_EQ(0, semop(id, ops, 1));
+  ASSERT_EQ(0, semctl(id, 0, GETVAL));
+
+  // Destroy the semaphore.
+  ASSERT_EQ(0, semctl(id, 0, IPC_RMID));
+}
+
+TEST(sys_sem, semget_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, semget(-1, -1, 0));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_sem, semctl_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, semctl(-1, 0, IPC_RMID));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_sem, semop_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, semop(-1, nullptr, 0));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_sem, semtimedop_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, semtimedop(-1, nullptr, 0, nullptr));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
diff --git a/tests/sys_shm_test.cpp b/tests/sys_shm_test.cpp
new file mode 100644
index 0000000..cf7f3a5
--- /dev/null
+++ b/tests/sys_shm_test.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <sys/shm.h>
+
+#include "TemporaryFile.h"
+
+TEST(sys_shm, smoke) {
+  if (shmctl(-1, IPC_STAT, nullptr) == -1 && errno == ENOSYS) {
+    GTEST_LOG_(INFO) << "no <sys/shm.h> support in this kernel\n";
+    return;
+  }
+
+  // Create a segment.
+  TemporaryDir dir;
+  key_t key = ftok(dir.dirname, 1);
+  int id = shmget(key, 1234, IPC_CREAT|0666);
+  ASSERT_NE(id, -1);
+
+  // Check segment info.
+  shmid_ds ds;
+  memset(&ds, 0, sizeof(ds));
+  ASSERT_EQ(0, shmctl(id, IPC_STAT, &ds));
+  ASSERT_EQ(1234U, ds.shm_segsz);
+
+  // Attach.
+  void* p = shmat(id, 0, SHM_RDONLY);
+  ASSERT_NE(p, nullptr);
+
+  // Detach.
+  ASSERT_EQ(0, shmdt(p));
+
+  // Destroy the segment.
+  ASSERT_EQ(0, shmctl(id, IPC_RMID, 0));
+}
+
+TEST(sys_shm, shmat_failure) {
+  errno = 0;
+  ASSERT_EQ(reinterpret_cast<void*>(-1), shmat(-1, 0, SHM_RDONLY));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_shm, shmctl_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, shmctl(-1, IPC_STAT, nullptr));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_shm, shmdt_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, shmdt(nullptr));
+  ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
+}
+
+TEST(sys_shm, shmget_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, shmget(-1, 1234, 0));
+  ASSERT_TRUE(errno == ENOENT || errno == ENOSYS);
+}
diff --git a/tests/sys_syscall_test.cpp b/tests/sys_syscall_test.cpp
index 9c5e350..68a7167 100644
--- a/tests/sys_syscall_test.cpp
+++ b/tests/sys_syscall_test.cpp
@@ -21,3 +21,10 @@
 TEST(unistd, syscall) {
   ASSERT_EQ(getpid(), syscall(SYS_getpid));
 }
+
+// https://code.google.com/p/android/issues/detail?id=215853
+#if defined(__LP64__)
+  #if defined(SYS_mmap2)
+    #error SYS_mmap2 should not be defined for LP64
+  #endif
+#endif
diff --git a/tests/sys_sysinfo_test.cpp b/tests/sys_sysinfo_test.cpp
index b00e13f..d7d0f6e 100644
--- a/tests/sys_sysinfo_test.cpp
+++ b/tests/sys_sysinfo_test.cpp
@@ -17,17 +17,28 @@
 #include <gtest/gtest.h>
 
 #include <sys/sysinfo.h>
+#include <unistd.h>
 
 TEST(sys_sysinfo, smoke) {
-  int nprocessor = get_nprocs();
-  ASSERT_GT(nprocessor, 0);
+  int nprocs = get_nprocs();
+  ASSERT_GT(nprocs, 0);
+  ASSERT_EQ(sysconf(_SC_NPROCESSORS_ONLN), nprocs);
 
-  int nprocessor_conf = get_nprocs_conf();
-  ASSERT_GE(nprocessor_conf, nprocessor);
+  int nprocs_conf = get_nprocs_conf();
+  ASSERT_GE(nprocs_conf, nprocs);
+  ASSERT_EQ(sysconf(_SC_NPROCESSORS_CONF), nprocs_conf);
 
   long avail_phys_pages = get_avphys_pages();
   ASSERT_GT(avail_phys_pages, 0);
+  ASSERT_EQ(sysconf(_SC_AVPHYS_PAGES), avail_phys_pages);
 
   long phys_pages = get_phys_pages();
   ASSERT_GE(phys_pages, avail_phys_pages);
+  ASSERT_EQ(sysconf(_SC_PHYS_PAGES), phys_pages);
+}
+
+TEST(sys_sysinfo, sysinfo) {
+  struct sysinfo si;
+  memset(&si, 0, sizeof(si));
+  ASSERT_EQ(0, sysinfo(&si));
 }
diff --git a/tests/sys_time_test.cpp b/tests/sys_time_test.cpp
index 18fbe10..e041ba0 100644
--- a/tests/sys_time_test.cpp
+++ b/tests/sys_time_test.cpp
@@ -22,30 +22,113 @@
 
 #include "TemporaryFile.h"
 
-TEST(sys_time, utimes) {
-  timeval tv[2];
-  memset(&tv, 0, sizeof(tv));
+// http://b/11383777
+TEST(sys_time, utimes_nullptr) {
+  TemporaryFile tf;
+  ASSERT_EQ(0, utimes(tf.filename, nullptr));
+}
+
+TEST(sys_time, utimes_EINVAL) {
+  TemporaryFile tf;
+
+  timeval tv[2] = {};
 
   tv[0].tv_usec = -123;
-  ASSERT_EQ(-1, utimes("/", tv));
+  ASSERT_EQ(-1, utimes(tf.filename, tv));
   ASSERT_EQ(EINVAL, errno);
   tv[0].tv_usec = 1234567;
-  ASSERT_EQ(-1, utimes("/", tv));
+  ASSERT_EQ(-1, utimes(tf.filename, tv));
   ASSERT_EQ(EINVAL, errno);
+
   tv[0].tv_usec = 0;
 
   tv[1].tv_usec = -123;
-  ASSERT_EQ(-1, utimes("/", tv));
+  ASSERT_EQ(-1, utimes(tf.filename, tv));
   ASSERT_EQ(EINVAL, errno);
   tv[1].tv_usec = 1234567;
-  ASSERT_EQ(-1, utimes("/", tv));
+  ASSERT_EQ(-1, utimes(tf.filename, tv));
   ASSERT_EQ(EINVAL, errno);
 }
 
-// http://b/11383777
-TEST(sys_time, utimes_NULL) {
+TEST(sys_time, futimes_nullptr) {
   TemporaryFile tf;
-  ASSERT_EQ(0, utimes(tf.filename, NULL));
+  ASSERT_EQ(0, futimes(tf.fd, nullptr));
+}
+
+TEST(sys_time, futimes_EINVAL) {
+  TemporaryFile tf;
+
+  timeval tv[2] = {};
+
+  tv[0].tv_usec = -123;
+  ASSERT_EQ(-1, futimes(tf.fd, tv));
+  ASSERT_EQ(EINVAL, errno);
+  tv[0].tv_usec = 1234567;
+  ASSERT_EQ(-1, futimes(tf.fd, tv));
+  ASSERT_EQ(EINVAL, errno);
+
+  tv[0].tv_usec = 0;
+
+  tv[1].tv_usec = -123;
+  ASSERT_EQ(-1, futimes(tf.fd, tv));
+  ASSERT_EQ(EINVAL, errno);
+  tv[1].tv_usec = 1234567;
+  ASSERT_EQ(-1, futimes(tf.fd, tv));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(sys_time, futimesat_nullptr) {
+  TemporaryFile tf;
+  ASSERT_EQ(0, futimesat(AT_FDCWD, tf.filename, nullptr));
+}
+
+TEST(sys_time, futimesat_EINVAL) {
+  TemporaryFile tf;
+
+  timeval tv[2] = {};
+
+  tv[0].tv_usec = -123;
+  ASSERT_EQ(-1, futimesat(AT_FDCWD, tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
+  tv[0].tv_usec = 1234567;
+  ASSERT_EQ(-1, futimesat(AT_FDCWD, tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
+
+  tv[0].tv_usec = 0;
+
+  tv[1].tv_usec = -123;
+  ASSERT_EQ(-1, futimesat(AT_FDCWD, tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
+  tv[1].tv_usec = 1234567;
+  ASSERT_EQ(-1, futimesat(AT_FDCWD, tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
+}
+
+TEST(sys_time, lutimes_nullptr) {
+  TemporaryFile tf;
+  ASSERT_EQ(0, lutimes(tf.filename, nullptr));
+}
+
+TEST(sys_time, lutimes_EINVAL) {
+  TemporaryFile tf;
+
+  timeval tv[2] = {};
+
+  tv[0].tv_usec = -123;
+  ASSERT_EQ(-1, lutimes(tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
+  tv[0].tv_usec = 1234567;
+  ASSERT_EQ(-1, lutimes(tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
+
+  tv[0].tv_usec = 0;
+
+  tv[1].tv_usec = -123;
+  ASSERT_EQ(-1, lutimes(tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
+  tv[1].tv_usec = 1234567;
+  ASSERT_EQ(-1, lutimes(tf.filename, tv));
+  ASSERT_EQ(EINVAL, errno);
 }
 
 TEST(sys_time, gettimeofday) {
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 6cdabd2..914cb61 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -102,20 +102,47 @@
 #if !defined(__LP64__)
   // 32-bit bionic stupidly had a signed 32-bit time_t.
   ASSERT_EQ(-1, mktime(&t));
+  ASSERT_EQ(EOVERFLOW, errno);
 #else
   // Everyone else should be using a signed 64-bit time_t.
   ASSERT_GE(sizeof(time_t) * 8, 64U);
 
   setenv("TZ", "America/Los_Angeles", 1);
   tzset();
+  errno = 0;
   ASSERT_EQ(static_cast<time_t>(4108348800U), mktime(&t));
+  ASSERT_EQ(0, errno);
 
   setenv("TZ", "UTC", 1);
   tzset();
+  errno = 0;
   ASSERT_EQ(static_cast<time_t>(4108320000U), mktime(&t));
+  ASSERT_EQ(0, errno);
 #endif
 }
 
+TEST(time, mktime_EOVERFLOW) {
+  struct tm t;
+  memset(&t, 0, sizeof(tm));
+
+  // LP32 year range is 1901-2038, so this year is guaranteed not to overflow.
+  t.tm_year = 2016 - 1900;
+
+  t.tm_mon = 2;
+  t.tm_mday = 10;
+
+  errno = 0;
+  ASSERT_NE(static_cast<time_t>(-1), mktime(&t));
+  ASSERT_EQ(0, errno);
+
+  // This will overflow for LP32 or LP64.
+  t.tm_year = INT_MAX;
+
+  errno = 0;
+  ASSERT_EQ(static_cast<time_t>(-1), mktime(&t));
+  ASSERT_EQ(EOVERFLOW, errno);
+}
+
 TEST(time, strftime) {
   setenv("TZ", "UTC", 1);
 
@@ -176,6 +203,27 @@
 #endif
 }
 
+TEST(time, strftime_l) {
+  locale_t cloc = newlocale(LC_ALL, "C.UTF-8", 0);
+  locale_t old_locale = uselocale(cloc);
+
+  setenv("TZ", "UTC", 1);
+
+  struct tm t;
+  memset(&t, 0, sizeof(tm));
+  t.tm_year = 200;
+  t.tm_mon = 2;
+  t.tm_mday = 10;
+
+  // Date and time as text.
+  char buf[64];
+  EXPECT_EQ(24U, strftime_l(buf, sizeof(buf), "%c", &t, cloc));
+  EXPECT_STREQ("Sun Mar 10 00:00:00 2100", buf);
+
+  uselocale(old_locale);
+  freelocale(cloc);
+}
+
 TEST(time, strptime) {
   setenv("TZ", "UTC", 1);
 
@@ -273,7 +321,7 @@
   }
 
  public:
-  Counter(void (*fn)(sigval_t)) : value(0), timer_valid(false) {
+  explicit Counter(void (*fn)(sigval_t)) : value(0), timer_valid(false) {
     memset(&se, 0, sizeof(se));
     se.sigev_notify = SIGEV_THREAD;
     se.sigev_notify_function = fn;
@@ -573,3 +621,56 @@
   timespec out;
   ASSERT_EQ(EINVAL, clock_nanosleep(-1, 0, &in, &out));
 }
+
+TEST(time, clock_nanosleep_thread_cputime_id) {
+  timespec in;
+  in.tv_sec = 1;
+  in.tv_nsec = 0;
+  ASSERT_EQ(EINVAL, clock_nanosleep(CLOCK_THREAD_CPUTIME_ID, 0, &in, nullptr));
+}
+
+TEST(time, bug_31938693) {
+  // User-visible symptoms in N:
+  // http://b/31938693
+  // https://code.google.com/p/android/issues/detail?id=225132
+
+  // Actual underlying bug (the code change, not the tzdata upgrade that first exposed the bug):
+  // http://b/31848040
+
+  // This isn't a great test, because very few time zones were actually affected, and there's
+  // no real logic to which ones were affected: it was just a coincidence of the data that came
+  // after them in the tzdata file.
+
+  time_t t = 1475619727;
+  struct tm tm;
+
+  setenv("TZ", "America/Los_Angeles", 1);
+  tzset();
+  ASSERT_TRUE(localtime_r(&t, &tm) != nullptr);
+  EXPECT_EQ(15, tm.tm_hour);
+
+  setenv("TZ", "Europe/London", 1);
+  tzset();
+  ASSERT_TRUE(localtime_r(&t, &tm) != nullptr);
+  EXPECT_EQ(23, tm.tm_hour);
+
+  setenv("TZ", "America/Atka", 1);
+  tzset();
+  ASSERT_TRUE(localtime_r(&t, &tm) != nullptr);
+  EXPECT_EQ(13, tm.tm_hour);
+
+  setenv("TZ", "Pacific/Apia", 1);
+  tzset();
+  ASSERT_TRUE(localtime_r(&t, &tm) != nullptr);
+  EXPECT_EQ(12, tm.tm_hour);
+
+  setenv("TZ", "Pacific/Honolulu", 1);
+  tzset();
+  ASSERT_TRUE(localtime_r(&t, &tm) != nullptr);
+  EXPECT_EQ(12, tm.tm_hour);
+
+  setenv("TZ", "Asia/Magadan", 1);
+  tzset();
+  ASSERT_TRUE(localtime_r(&t, &tm) != nullptr);
+  EXPECT_EQ(9, tm.tm_hour);
+}
diff --git a/tests/uniqueptr_test.cpp b/tests/uniqueptr_test.cpp
deleted file mode 100644
index 4b6608a..0000000
--- a/tests/uniqueptr_test.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include <private/UniquePtr.h>
-
-static int cCount = 0;
-struct C {
-  C() { ++cCount; }
-  ~C() { --cCount; }
-};
-
-static bool freed = false;
-struct Freer {
-  void operator() (int* p) {
-    ASSERT_EQ(123, *p);
-    free(p);
-    freed = true;
-  }
-};
-
-TEST(UniquePtr, smoke) {
-  //
-  // UniquePtr<T> tests...
-  //
-
-  // Can we free a single object?
-  {
-    UniquePtr<C> c(new C);
-    ASSERT_TRUE(cCount == 1);
-  }
-  ASSERT_TRUE(cCount == 0);
-  // Does release work?
-  C* rawC;
-  {
-      UniquePtr<C> c(new C);
-      ASSERT_TRUE(cCount == 1);
-      rawC = c.release();
-  }
-  ASSERT_TRUE(cCount == 1);
-  delete rawC;
-  // Does reset work?
-  {
-      UniquePtr<C> c(new C);
-      ASSERT_TRUE(cCount == 1);
-      c.reset(new C);
-      ASSERT_TRUE(cCount == 1);
-  }
-  ASSERT_TRUE(cCount == 0);
-
-  //
-  // UniquePtr<T[]> tests...
-  //
-
-  // Can we free an array?
-  {
-      UniquePtr<C[]> cs(new C[4]);
-      ASSERT_TRUE(cCount == 4);
-  }
-  ASSERT_TRUE(cCount == 0);
-  // Does release work?
-  {
-      UniquePtr<C[]> c(new C[4]);
-      ASSERT_TRUE(cCount == 4);
-      rawC = c.release();
-  }
-  ASSERT_TRUE(cCount == 4);
-  delete[] rawC;
-  // Does reset work?
-  {
-      UniquePtr<C[]> c(new C[4]);
-      ASSERT_TRUE(cCount == 4);
-      c.reset(new C[2]);
-      ASSERT_TRUE(cCount == 2);
-  }
-  ASSERT_TRUE(cCount == 0);
-
-  //
-  // Custom deleter tests...
-  //
-  ASSERT_TRUE(!freed);
-  {
-      UniquePtr<int, Freer> i(reinterpret_cast<int*>(malloc(sizeof(int))));
-      *i = 123;
-  }
-  ASSERT_TRUE(freed);
-}
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index ccf4dcc..b488e82 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -23,8 +23,10 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <libgen.h>
 #include <limits.h>
 #include <stdint.h>
+#include <sys/capability.h>
 #include <sys/param.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
@@ -57,14 +59,24 @@
 TEST(UNISTD_TEST, brk) {
   void* initial_break = get_brk();
 
-  // The kernel aligns the break to a page.
   void* new_break = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(initial_break) + 1);
-  ASSERT_EQ(0, brk(new_break));
-  ASSERT_GE(get_brk(), new_break);
+  int ret = brk(new_break);
+  if (ret == -1) {
+    ASSERT_EQ(errno, ENOMEM);
+  } else {
+    ASSERT_EQ(0, ret);
+    ASSERT_GE(get_brk(), new_break);
+  }
 
+  // Expand by a full page to force the mapping to expand
   new_break = page_align(reinterpret_cast<uintptr_t>(initial_break) + sysconf(_SC_PAGE_SIZE));
-  ASSERT_EQ(0, brk(new_break));
-  ASSERT_EQ(get_brk(), new_break);
+  ret = brk(new_break);
+  if (ret == -1) {
+    ASSERT_EQ(errno, ENOMEM);
+  } else {
+    ASSERT_EQ(0, ret);
+    ASSERT_EQ(get_brk(), new_break);
+  }
 }
 
 TEST(UNISTD_TEST, brk_ENOMEM) {
@@ -414,7 +426,7 @@
   }
 }
 
-static void TestGetPidCachingWithFork(int (*fork_fn)()) {
+static void TestGetPidCachingWithFork(int (*fork_fn)(), void (*exit_fn)(int)) {
   pid_t parent_pid = getpid();
   ASSERT_EQ(syscall(__NR_getpid), parent_pid);
 
@@ -422,9 +434,9 @@
   ASSERT_NE(fork_result, -1);
   if (fork_result == 0) {
     // We're the child.
-    AssertGetPidCorrect();
+    ASSERT_NO_FATAL_FAILURE(AssertGetPidCorrect());
     ASSERT_EQ(parent_pid, getppid());
-    _exit(123);
+    exit_fn(123);
   } else {
     // We're the parent.
     ASSERT_EQ(parent_pid, getpid());
@@ -432,12 +444,98 @@
   }
 }
 
+// gettid() is marked as __attribute_const__, which will have the compiler
+// optimize out multiple calls to gettid in the same function. This wrapper
+// defeats that optimization.
+static __attribute__((__noinline__)) pid_t GetTidForTest() {
+  __asm__("");
+  return gettid();
+}
+
+static void AssertGetTidCorrect() {
+  // The loop is just to make manual testing/debugging with strace easier.
+  pid_t gettid_syscall_result = syscall(__NR_gettid);
+  for (size_t i = 0; i < 128; ++i) {
+    ASSERT_EQ(gettid_syscall_result, GetTidForTest());
+  }
+}
+
+static void TestGetTidCachingWithFork(int (*fork_fn)(), void (*exit_fn)(int)) {
+  pid_t parent_tid = GetTidForTest();
+  ASSERT_EQ(syscall(__NR_gettid), parent_tid);
+
+  pid_t fork_result = fork_fn();
+  ASSERT_NE(fork_result, -1);
+  if (fork_result == 0) {
+    // We're the child.
+    EXPECT_EQ(syscall(__NR_getpid), syscall(__NR_gettid));
+    EXPECT_EQ(getpid(), GetTidForTest()) << "real tid is " << syscall(__NR_gettid)
+                                         << ", pid is " << syscall(__NR_getpid);
+    ASSERT_NO_FATAL_FAILURE(AssertGetTidCorrect());
+    exit_fn(123);
+  } else {
+    // We're the parent.
+    ASSERT_EQ(parent_tid, GetTidForTest());
+    AssertChildExited(fork_result, 123);
+  }
+}
+
 TEST(UNISTD_TEST, getpid_caching_and_fork) {
-  TestGetPidCachingWithFork(fork);
+  TestGetPidCachingWithFork(fork, exit);
+}
+
+TEST(UNISTD_TEST, gettid_caching_and_fork) {
+  TestGetTidCachingWithFork(fork, exit);
 }
 
 TEST(UNISTD_TEST, getpid_caching_and_vfork) {
-  TestGetPidCachingWithFork(vfork);
+  TestGetPidCachingWithFork(vfork, _exit);
+}
+
+static int CloneLikeFork() {
+  return clone(nullptr, nullptr, SIGCHLD, nullptr);
+}
+
+TEST(UNISTD_TEST, getpid_caching_and_clone_process) {
+  TestGetPidCachingWithFork(CloneLikeFork, exit);
+}
+
+TEST(UNISTD_TEST, gettid_caching_and_clone_process) {
+  TestGetTidCachingWithFork(CloneLikeFork, exit);
+}
+
+static int CloneAndSetTid() {
+  pid_t child_tid = 0;
+  pid_t parent_tid = GetTidForTest();
+
+  int rv = clone(nullptr, nullptr, CLONE_CHILD_SETTID | SIGCHLD, nullptr, nullptr, nullptr, &child_tid);
+  EXPECT_NE(-1, rv);
+
+  if (rv == 0) {
+    // Child.
+    EXPECT_EQ(child_tid, GetTidForTest());
+    EXPECT_NE(child_tid, parent_tid);
+  } else {
+    EXPECT_NE(child_tid, GetTidForTest());
+    EXPECT_NE(child_tid, parent_tid);
+    EXPECT_EQ(GetTidForTest(), parent_tid);
+  }
+
+  return rv;
+}
+
+TEST(UNISTD_TEST, gettid_caching_and_clone_process_settid) {
+  TestGetTidCachingWithFork(CloneAndSetTid, exit);
+}
+
+static int CloneStartRoutine(int (*start_routine)(void*)) {
+  void* child_stack[1024];
+  int clone_result = clone(start_routine, &child_stack[1024], CLONE_NEWNS | SIGCHLD, NULL);
+  if (clone_result == -1 && errno == EPERM && getuid() != 0) {
+    GTEST_LOG_(INFO) << "This test only works if you have permission to CLONE_NEWNS; try running as root.\n";
+    return clone_result;
+  }
+  return clone_result;
 }
 
 static int GetPidCachingCloneStartRoutine(void*) {
@@ -449,12 +547,7 @@
   pid_t parent_pid = getpid();
   ASSERT_EQ(syscall(__NR_getpid), parent_pid);
 
-  void* child_stack[1024];
-  int clone_result = clone(GetPidCachingCloneStartRoutine, &child_stack[1024], CLONE_NEWNS | SIGCHLD, NULL);
-  if (clone_result == -1 && errno == EPERM && getuid() != 0) {
-    GTEST_LOG_(INFO) << "This test only works if you have permission to CLONE_NEWNS; try running as root.\n";
-    return;
-  }
+  int clone_result = CloneStartRoutine(GetPidCachingCloneStartRoutine);
   ASSERT_NE(clone_result, -1);
 
   ASSERT_EQ(parent_pid, getpid());
@@ -462,6 +555,39 @@
   AssertChildExited(clone_result, 123);
 }
 
+static int GetTidCachingCloneStartRoutine(void*) {
+  AssertGetTidCorrect();
+  return 123;
+}
+
+TEST(UNISTD_TEST, gettid_caching_and_clone) {
+  pid_t parent_tid = GetTidForTest();
+  ASSERT_EQ(syscall(__NR_gettid), parent_tid);
+
+  int clone_result = CloneStartRoutine(GetTidCachingCloneStartRoutine);
+  ASSERT_NE(clone_result, -1);
+
+  ASSERT_EQ(parent_tid, GetTidForTest());
+
+  AssertChildExited(clone_result, 123);
+}
+
+static int CloneChildExit(void*) {
+  AssertGetPidCorrect();
+  AssertGetTidCorrect();
+  exit(33);
+}
+
+TEST(UNISTD_TEST, clone_fn_and_exit) {
+  int clone_result = CloneStartRoutine(CloneChildExit);
+  ASSERT_NE(-1, clone_result);
+
+  AssertGetPidCorrect();
+  AssertGetTidCorrect();
+
+  AssertChildExited(clone_result, 33);
+}
+
 static void* GetPidCachingPthreadStartRoutine(void*) {
   AssertGetPidCorrect();
   return NULL;
@@ -480,6 +606,25 @@
   ASSERT_EQ(NULL, result);
 }
 
+static void* GetTidCachingPthreadStartRoutine(void*) {
+  AssertGetTidCorrect();
+  uint64_t tid = GetTidForTest();
+  return reinterpret_cast<void*>(tid);
+}
+
+TEST(UNISTD_TEST, gettid_caching_and_pthread_create) {
+  pid_t parent_tid = GetTidForTest();
+
+  pthread_t t;
+  ASSERT_EQ(0, pthread_create(&t, NULL, GetTidCachingPthreadStartRoutine, &parent_tid));
+
+  ASSERT_EQ(parent_tid, GetTidForTest());
+
+  void* result;
+  ASSERT_EQ(0, pthread_join(t, &result));
+  ASSERT_NE(static_cast<uint64_t>(parent_tid), reinterpret_cast<uint64_t>(result));
+}
+
 class UNISTD_DEATHTEST : public BionicDeathTest {};
 
 TEST_F(UNISTD_DEATHTEST, abort) {
@@ -547,6 +692,8 @@
   EXPECT_GT(_POSIX_AIO_LISTIO_MAX, 0);
   EXPECT_GT(_POSIX_AIO_MAX, 0);
   EXPECT_GT(_POSIX_ARG_MAX, 0);
+  EXPECT_GT(_POSIX_BARRIERS, 0);
+  EXPECT_GT(_POSIX_SPIN_LOCKS, 0);
   EXPECT_GT(_POSIX_CHILD_MAX, 0);
   EXPECT_NE(_POSIX_CHOWN_RESTRICTED, -1);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_CLOCK_SELECTION);
@@ -598,8 +745,8 @@
   EXPECT_GT(_POSIX_THREAD_DESTRUCTOR_ITERATIONS, 0);
   EXPECT_EQ(_POSIX_THREAD_KEYS_MAX, 128);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_PRIORITY_SCHEDULING);
-  EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_PRIO_INHERIT);
-  EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_PRIO_PROTECT);
+  EXPECT_EQ(-1, _POSIX_THREAD_PRIO_INHERIT);
+  EXPECT_EQ(-1, _POSIX_THREAD_PRIO_PROTECT);
   EXPECT_EQ(-1, _POSIX_THREAD_ROBUST_PRIO_PROTECT);
   EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_SAFE_FUNCTIONS);
   EXPECT_EQ(-1, _POSIX_THREAD_SPORADIC_SERVER);
@@ -635,12 +782,10 @@
   // These tests only pass on bionic, as bionic and glibc has different support on these macros.
   // Macros like _POSIX_ASYNCHRONOUS_IO are not supported on bionic yet.
   EXPECT_EQ(-1, _POSIX_ASYNCHRONOUS_IO);
-  EXPECT_EQ(-1, _POSIX_BARRIERS);
   EXPECT_EQ(-1, _POSIX_MESSAGE_PASSING);
   EXPECT_EQ(-1, _POSIX_PRIORITIZED_IO);
   EXPECT_EQ(-1, _POSIX_SHARED_MEMORY_OBJECTS);
   EXPECT_EQ(-1, _POSIX_SPAWN);
-  EXPECT_EQ(-1, _POSIX_SPIN_LOCKS);
   EXPECT_EQ(-1, _POSIX_THREAD_PROCESS_SHARED);
   EXPECT_EQ(-1, _POSIX_THREAD_ROBUST_PRIO_INHERIT);
 
@@ -661,7 +806,7 @@
 #endif // defined(__BIONIC__)
 }
 
-#define VERIFY_SYSCONF_NOT_SUPPORT(name) VerifySysconf(name, #name, [](long v){return v == -1;})
+#define VERIFY_SYSCONF_UNSUPPORTED(name) VerifySysconf(name, #name, [](long v){return v == -1;})
 
 // sysconf() means unlimited when it returns -1 with errno unchanged.
 #define VERIFY_SYSCONF_POSITIVE(name) \
@@ -680,6 +825,7 @@
 TEST(UNISTD_TEST, sysconf) {
   VERIFY_SYSCONF_POSIX_VERSION(_SC_ADVISORY_INFO);
   VERIFY_SYSCONF_POSITIVE(_SC_ARG_MAX);
+  VERIFY_SYSCONF_POSIX_VERSION(_SC_BARRIERS);
   VERIFY_SYSCONF_POSITIVE(_SC_BC_BASE_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_BC_DIM_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_BC_SCALE_MAX);
@@ -693,9 +839,9 @@
   VERIFY_SYSCONF_POSITIVE(_SC_OPEN_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_PASS_MAX);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_2_C_BIND);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_FORT_DEV);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_FORT_RUN);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_UPE);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_FORT_DEV);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_FORT_RUN);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_UPE);
   VERIFY_SYSCONF_POSITIVE(_SC_JOB_CONTROL);
   VERIFY_SYSCONF_POSITIVE(_SC_SAVED_IDS);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_VERSION);
@@ -719,6 +865,7 @@
   VERIFY_SYSCONF_POSITIVE(_SC_RTSIG_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_SEM_NSEMS_MAX);
   VERIFY_SYSCONF_POSITIVE(_SC_SEM_VALUE_MAX);
+  VERIFY_SYSCONF_POSIX_VERSION(_SC_SPIN_LOCKS);
   VERIFY_SYSCONF_POSITIVE(_SC_TIMER_MAX);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_FSYNC);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_MAPPED_FILES);
@@ -742,20 +889,20 @@
   VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_ATTR_STACKADDR);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_ATTR_STACKSIZE);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_PRIORITY_SCHEDULING);
-  VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_PRIO_INHERIT);
-  VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_PRIO_PROTECT);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_THREAD_PRIO_INHERIT);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_THREAD_PRIO_PROTECT);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_SAFE_FUNCTIONS);
   VERIFY_SYSCONF_POSITIVE(_SC_NPROCESSORS_CONF);
   VERIFY_SYSCONF_POSITIVE(_SC_NPROCESSORS_ONLN);
   VERIFY_SYSCONF_POSITIVE(_SC_PHYS_PAGES);
   VERIFY_SYSCONF_POSITIVE(_SC_AVPHYS_PAGES);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_MONOTONIC_CLOCK);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_ACCOUNTING);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_CHECKPOINT);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_LOCATE);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_MESSAGE);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_TRACK);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_PBS);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_PBS_ACCOUNTING);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_PBS_CHECKPOINT);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_PBS_LOCATE);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_PBS_MESSAGE);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_PBS_TRACK);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_CLOCK_SELECTION);
   VERIFY_SYSCONF_POSITIVE(_SC_HOST_NAME_MAX);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_IPV6);
@@ -763,64 +910,62 @@
   VERIFY_SYSCONF_POSIX_VERSION(_SC_READER_WRITER_LOCKS);
   VERIFY_SYSCONF_POSITIVE(_SC_REGEXP);
   VERIFY_SYSCONF_POSITIVE(_SC_SHELL);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_SPORADIC_SERVER);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_SPORADIC_SERVER);
   VERIFY_SYSCONF_POSITIVE(_SC_SYMLOOP_MAX);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_CPUTIME);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_SPORADIC_SERVER);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_THREAD_SPORADIC_SERVER);
   VERIFY_SYSCONF_POSIX_VERSION(_SC_TIMEOUTS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_EVENT_FILTER);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_EVENT_NAME_MAX);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_INHERIT);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_LOG);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_NAME_MAX);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_SYS_MAX);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_USER_EVENT_MAX);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_TYPED_MEMORY_OBJECTS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_STREAMS);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE_EVENT_FILTER);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE_EVENT_NAME_MAX);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE_INHERIT);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE_LOG);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE_NAME_MAX);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE_SYS_MAX);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TRACE_USER_EVENT_MAX);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_TYPED_MEMORY_OBJECTS);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_STREAMS);
 
 #if defined(__LP64__)
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_ILP32_OFF32);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_ILP32_OFFBIG);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_V7_ILP32_OFF32);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_V7_ILP32_OFFBIG);
   VERIFY_SYSCONF_POSITIVE(_SC_V7_LP64_OFF64);
   VERIFY_SYSCONF_POSITIVE(_SC_V7_LPBIG_OFFBIG);
 #else
   VERIFY_SYSCONF_POSITIVE(_SC_V7_ILP32_OFF32);
 #if defined(__BIONIC__)
   // bionic does not support 64 bits off_t type on 32bit machine.
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_ILP32_OFFBIG);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_V7_ILP32_OFFBIG);
 #endif
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_LP64_OFF64);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_LPBIG_OFFBIG);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_V7_LP64_OFF64);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_V7_LPBIG_OFFBIG);
 #endif
 
 #if defined(__BIONIC__)
   // Tests can only run on bionic, as bionic and glibc have different support for these options.
   // Below options are not supported on bionic yet.
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_ASYNCHRONOUS_IO);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_BARRIERS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_MESSAGE_PASSING);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_PRIORITIZED_IO);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_SHARED_MEMORY_OBJECTS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_SPAWN);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_SPIN_LOCKS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_PROCESS_SHARED);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_ROBUST_PRIO_INHERIT);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_ROBUST_PRIO_PROTECT);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_ASYNCHRONOUS_IO);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_MESSAGE_PASSING);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_PRIORITIZED_IO);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_SHARED_MEMORY_OBJECTS);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_SPAWN);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_THREAD_PROCESS_SHARED);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_THREAD_ROBUST_PRIO_INHERIT);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_THREAD_ROBUST_PRIO_PROTECT);
 
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_C_DEV);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_CHAR_TERM);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_LOCALEDEF);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_SW_DEV);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_VERSION);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_C_DEV);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_CHAR_TERM);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_LOCALEDEF);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_SW_DEV);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_2_VERSION);
 
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_CRYPT);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_ENH_I18N);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_LEGACY);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_REALTIME);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_REALTIME_THREADS);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_SHM);
-  VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_UUCP);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_CRYPT);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_ENH_I18N);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_LEGACY);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_REALTIME);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_REALTIME_THREADS);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_SHM);
+  VERIFY_SYSCONF_UNSUPPORTED(_SC_XOPEN_UUCP);
 #endif // defined(__BIONIC__)
 }
 
@@ -846,6 +991,39 @@
   ASSERT_EQ(online_cpus, sysconf(_SC_NPROCESSORS_ONLN));
 }
 
+TEST(UNISTD_TEST, sysconf_SC_ARG_MAX) {
+  // Since Linux 2.6.23, ARG_MAX isn't a constant and depends on RLIMIT_STACK.
+
+  // Get our current limit, and set things up so we restore the limit.
+  rlimit rl;
+  ASSERT_EQ(0, getrlimit(RLIMIT_STACK, &rl));
+  uint64_t original_rlim_cur = rl.rlim_cur;
+  if (rl.rlim_cur == RLIM_INFINITY) {
+    rl.rlim_cur = 8 * 1024 * 1024; // Bionic reports unlimited stacks as 8MiB.
+  }
+  auto guard = make_scope_guard([&rl, original_rlim_cur]() {
+    rl.rlim_cur = original_rlim_cur;
+    ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
+  });
+
+  // _SC_ARG_MAX should be 1/4 the stack size.
+  EXPECT_EQ(static_cast<long>(rl.rlim_cur / 4), sysconf(_SC_ARG_MAX));
+
+  // If you have a really small stack, the kernel still guarantees "32 pages" (fs/exec.c).
+  rl.rlim_cur = 1024;
+  rl.rlim_max = RLIM_INFINITY;
+  ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
+
+  EXPECT_EQ(static_cast<long>(32 * sysconf(_SC_PAGE_SIZE)), sysconf(_SC_ARG_MAX));
+
+  // With a 128-page stack limit, we know exactly what _SC_ARG_MAX should be...
+  rl.rlim_cur = 128 * sysconf(_SC_PAGE_SIZE);
+  rl.rlim_max = RLIM_INFINITY;
+  ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
+
+  EXPECT_EQ(static_cast<long>((128 * sysconf(_SC_PAGE_SIZE)) / 4), sysconf(_SC_ARG_MAX));
+}
+
 TEST(UNISTD_TEST, dup2_same) {
   // POSIX says of dup2:
   // If fildes2 is already a valid open file descriptor ...
@@ -986,3 +1164,253 @@
   ASSERT_EQ(file_size/2, lseek64(tf.fd, file_size/2, SEEK_SET));
   ASSERT_EQ(0, lockf64(tf.fd, F_TLOCK, file_size/2));
 }
+
+TEST(UNISTD_TEST, getdomainname) {
+  struct utsname u;
+  ASSERT_EQ(0, uname(&u));
+
+  char buf[sizeof(u.domainname)];
+  ASSERT_EQ(0, getdomainname(buf, sizeof(buf)));
+  EXPECT_STREQ(u.domainname, buf);
+
+#if defined(__BIONIC__)
+  // bionic and glibc have different behaviors when len is too small
+  ASSERT_EQ(-1, getdomainname(buf, strlen(u.domainname)));
+  EXPECT_EQ(EINVAL, errno);
+#endif
+}
+
+TEST(UNISTD_TEST, setdomainname) {
+  __user_cap_header_struct header;
+  memset(&header, 0, sizeof(header));
+  header.version = _LINUX_CAPABILITY_VERSION_3;
+
+  __user_cap_data_struct old_caps[_LINUX_CAPABILITY_U32S_3];
+  ASSERT_EQ(0, capget(&header, &old_caps[0]));
+
+  auto admin_idx = CAP_TO_INDEX(CAP_SYS_ADMIN);
+  auto admin_mask = CAP_TO_MASK(CAP_SYS_ADMIN);
+  bool has_admin = old_caps[admin_idx].effective & admin_mask;
+  if (has_admin) {
+    __user_cap_data_struct new_caps[_LINUX_CAPABILITY_U32S_3];
+    memcpy(new_caps, old_caps, sizeof(new_caps));
+    new_caps[admin_idx].effective &= ~admin_mask;
+
+    ASSERT_EQ(0, capset(&header, &new_caps[0])) << "failed to drop admin privileges";
+  }
+
+  const char* name = "newdomainname";
+  ASSERT_EQ(-1, setdomainname(name, strlen(name)));
+  ASSERT_EQ(EPERM, errno);
+
+  if (has_admin) {
+    ASSERT_EQ(0, capset(&header, &old_caps[0])) << "failed to restore admin privileges";
+  }
+}
+
+class ExecTestHelper {
+ public:
+  char** GetArgs() { return const_cast<char**>(args_.data()); }
+  char** GetEnv() { return const_cast<char**>(env_.data()); }
+
+  void SetArgs(const std::vector<const char*> args) { args_ = args; }
+  void SetEnv(const std::vector<const char*> env) { env_ = env; }
+
+  void Run(const std::function<void ()>& child_fn,
+           int expected_exit_status,
+           const char* expected_output) {
+      int fds[2];
+      ASSERT_NE(pipe2(fds, 0), -1);
+
+      pid_t pid = fork();
+      ASSERT_NE(pid, -1);
+
+      if (pid == 0) {
+          // Child.
+          close(fds[0]);
+          dup2(fds[1], STDOUT_FILENO);
+          dup2(fds[1], STDERR_FILENO);
+          if (fds[1] != STDOUT_FILENO && fds[1] != STDERR_FILENO) close(fds[1]);
+          child_fn();
+          FAIL();
+      }
+
+      // Parent.
+      close(fds[1]);
+      std::string output;
+      char buf[BUFSIZ];
+      ssize_t bytes_read;
+      while ((bytes_read = TEMP_FAILURE_RETRY(read(fds[0], buf, sizeof(buf)))) > 0) {
+          output.append(buf, bytes_read);
+      }
+      close(fds[0]);
+
+      AssertChildExited(pid, expected_exit_status);
+      ASSERT_EQ(expected_output, output);
+  }
+
+ private:
+  std::vector<const char*> args_;
+  std::vector<const char*> env_;
+};
+
+#if defined(__GLIBC__)
+#define BIN_DIR "/bin/"
+#else
+#define BIN_DIR "/system/bin/"
+#endif
+
+TEST(UNISTD_TEST, execve_failure) {
+  ExecTestHelper eth;
+  errno = 0;
+  ASSERT_EQ(-1, execve("/", eth.GetArgs(), eth.GetEnv()));
+  ASSERT_EQ(EACCES, errno);
+}
+
+TEST(UNISTD_TEST, execve_args) {
+  // int execve(const char* path, char* argv[], char* envp[]);
+
+  // Test basic argument passing.
+  ExecTestHelper eth;
+  eth.SetArgs({"echo", "hello", "world", nullptr});
+  eth.Run([&]() { execve(BIN_DIR "echo", eth.GetArgs(), eth.GetEnv()); }, 0, "hello world\n");
+
+  // Test environment variable setting too.
+  eth.SetArgs({"printenv", nullptr});
+  eth.SetEnv({"A=B", nullptr});
+  eth.Run([&]() { execve(BIN_DIR "printenv", eth.GetArgs(), eth.GetEnv()); }, 0, "A=B\n");
+}
+
+TEST(UNISTD_TEST, execl_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, execl("/", "/", nullptr));
+  ASSERT_EQ(EACCES, errno);
+}
+
+TEST(UNISTD_TEST, execl) {
+  ExecTestHelper eth;
+  // int execl(const char* path, const char* arg, ...);
+  eth.Run([&]() { execl(BIN_DIR "echo", "echo", "hello", "world", nullptr); }, 0, "hello world\n");
+}
+
+TEST(UNISTD_TEST, execle_failure) {
+  ExecTestHelper eth;
+  errno = 0;
+  ASSERT_EQ(-1, execle("/", "/", nullptr, eth.GetEnv()));
+  ASSERT_EQ(EACCES, errno);
+}
+
+TEST(UNISTD_TEST, execle) {
+  ExecTestHelper eth;
+  eth.SetEnv({"A=B", nullptr});
+  // int execle(const char* path, const char* arg, ..., char* envp[]);
+  eth.Run([&]() { execle(BIN_DIR "printenv", "printenv", nullptr, eth.GetEnv()); }, 0, "A=B\n");
+}
+
+TEST(UNISTD_TEST, execv_failure) {
+  ExecTestHelper eth;
+  errno = 0;
+  ASSERT_EQ(-1, execv("/", eth.GetArgs()));
+  ASSERT_EQ(EACCES, errno);
+}
+
+TEST(UNISTD_TEST, execv) {
+  ExecTestHelper eth;
+  eth.SetArgs({"echo", "hello", "world", nullptr});
+  // int execv(const char* path, char* argv[]);
+  eth.Run([&]() { execv(BIN_DIR "echo", eth.GetArgs()); }, 0, "hello world\n");
+}
+
+TEST(UNISTD_TEST, execlp_failure) {
+  errno = 0;
+  ASSERT_EQ(-1, execlp("/", "/", nullptr));
+  ASSERT_EQ(EACCES, errno);
+}
+
+TEST(UNISTD_TEST, execlp) {
+  ExecTestHelper eth;
+  // int execlp(const char* file, const char* arg, ...);
+  eth.Run([&]() { execlp("echo", "echo", "hello", "world", nullptr); }, 0, "hello world\n");
+}
+
+TEST(UNISTD_TEST, execvp_failure) {
+  ExecTestHelper eth;
+  eth.SetArgs({nullptr});
+  errno = 0;
+  ASSERT_EQ(-1, execvp("/", eth.GetArgs()));
+  ASSERT_EQ(EACCES, errno);
+}
+
+TEST(UNISTD_TEST, execvp) {
+  ExecTestHelper eth;
+  eth.SetArgs({"echo", "hello", "world", nullptr});
+  // int execvp(const char* file, char* argv[]);
+  eth.Run([&]() { execvp("echo", eth.GetArgs()); }, 0, "hello world\n");
+}
+
+TEST(UNISTD_TEST, execvpe_failure) {
+  ExecTestHelper eth;
+  errno = 0;
+  ASSERT_EQ(-1, execvpe("this-does-not-exist", eth.GetArgs(), eth.GetEnv()));
+  ASSERT_EQ(ENOENT, errno);
+}
+
+TEST(UNISTD_TEST, execvpe) {
+  // int execvpe(const char* file, char* argv[], char* envp[]);
+
+  // Test basic argument passing.
+  ExecTestHelper eth;
+  eth.SetArgs({"echo", "hello", "world", nullptr});
+  eth.Run([&]() { execvpe("echo", eth.GetArgs(), eth.GetEnv()); }, 0, "hello world\n");
+
+  // Test environment variable setting too.
+  eth.SetArgs({"printenv", nullptr});
+  eth.SetEnv({"A=B", nullptr});
+  eth.Run([&]() { execvpe("printenv", eth.GetArgs(), eth.GetEnv()); }, 0, "A=B\n");
+}
+
+TEST(UNISTD_TEST, execvpe_ENOEXEC) {
+  // Create a shell script with #!.
+  TemporaryFile tf;
+  ASSERT_TRUE(android::base::WriteStringToFile("#!" BIN_DIR "sh\necho script\n", tf.filename));
+
+  // Set $PATH so we can find it.
+  setenv("PATH", dirname(tf.filename), 1);
+
+  ExecTestHelper eth;
+  eth.SetArgs({basename(tf.filename), nullptr});
+
+  // It's not inherently executable.
+  errno = 0;
+  ASSERT_EQ(-1, execvpe(basename(tf.filename), eth.GetArgs(), eth.GetEnv()));
+  ASSERT_EQ(EACCES, errno);
+
+  // Make it executable.
+  ASSERT_EQ(0, chmod(tf.filename, 0555));
+
+  // TemporaryFile will have a writable fd, so we can test ETXTBSY while we're here...
+  errno = 0;
+  ASSERT_EQ(-1, execvpe(basename(tf.filename), eth.GetArgs(), eth.GetEnv()));
+  ASSERT_EQ(ETXTBSY, errno);
+
+  // 1. The simplest test: the kernel should handle this.
+  ASSERT_EQ(0, close(tf.fd));
+  eth.Run([&]() { execvpe(basename(tf.filename), eth.GetArgs(), eth.GetEnv()); }, 0, "script\n");
+
+  // 2. Try again without a #!. We should have to handle this ourselves.
+  ASSERT_TRUE(android::base::WriteStringToFile("echo script\n", tf.filename));
+  eth.Run([&]() { execvpe(basename(tf.filename), eth.GetArgs(), eth.GetEnv()); }, 0, "script\n");
+
+  // 3. Again without a #!, but also with a leading '/', since that's a special case in the
+  // implementation.
+  eth.Run([&]() { execvpe(tf.filename, eth.GetArgs(), eth.GetEnv()); }, 0, "script\n");
+}
+
+TEST(UNISTD_TEST, execvp_libcore_test_55017) {
+  ExecTestHelper eth;
+  eth.SetArgs({"/system/bin/does-not-exist", nullptr});
+
+  errno = 0;
+  ASSERT_EQ(-1, execvp("/system/bin/does-not-exist", eth.GetArgs()));
+  ASSERT_EQ(ENOENT, errno);
+}
diff --git a/tests/utils.h b/tests/utils.h
index f8e0039..c62da75 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -32,6 +32,8 @@
 
 #include "private/ScopeGuard.h"
 
+#if defined(__linux__)
+
 struct map_record {
   uintptr_t addr_start;
   uintptr_t addr_end;
@@ -95,6 +97,8 @@
 
 extern "C" pid_t gettid();
 
+#endif
+
 static inline void WaitUntilThreadSleep(std::atomic<pid_t>& tid) {
   while (tid == 0) {
     usleep(1000);
@@ -122,4 +126,12 @@
 // The absolute path to the executable
 const std::string& get_executable_path();
 
+// Get realpath
+bool get_realpath(const std::string& path, std::string* realpath);
+
+// Access to argc/argv/envp
+int get_argc();
+char** get_argv();
+char** get_envp();
+
 #endif
diff --git a/tests/wchar_test.cpp b/tests/wchar_test.cpp
index e86d56d..34ed5a7 100644
--- a/tests/wchar_test.cpp
+++ b/tests/wchar_test.cpp
@@ -22,7 +22,9 @@
 #include <stdint.h>
 #include <wchar.h>
 
-#define NUM_WCHARS(num_bytes) (num_bytes/sizeof(wchar_t))
+#include "math_data_test.h"
+
+#define NUM_WCHARS(num_bytes) ((num_bytes)/sizeof(wchar_t))
 
 TEST(wchar, sizeof_wchar_t) {
   EXPECT_EQ(4U, sizeof(wchar_t));
@@ -301,7 +303,7 @@
   ASSERT_EQ(EILSEQ, errno);
 }
 
-void test_mbrtowc_incomplete(mbstate_t* ps) {
+static void test_mbrtowc_incomplete(mbstate_t* ps) {
   ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
   uselocale(LC_GLOBAL_LOCALE);
 
@@ -338,10 +340,13 @@
   test_mbrtowc_incomplete(NULL);
 }
 
-void test_mbsrtowcs(mbstate_t* ps) {
+static void test_mbsrtowcs(mbstate_t* ps) {
+  constexpr const char* VALID = "A" "\xc2\xa2" "\xe2\x82\xac" "\xf0\xa4\xad\xa2" "ef";
+  constexpr const char* INVALID = "A" "\xc2\x20" "ef";
+  constexpr const char* INCOMPLETE = "A" "\xc2";
   wchar_t out[4];
 
-  const char* valid = "A" "\xc2\xa2" "\xe2\x82\xac" "\xf0\xa4\xad\xa2" "ef";
+  const char* valid = VALID;
   ASSERT_EQ(4U, mbsrtowcs(out, &valid, 4, ps));
   ASSERT_EQ(L'A', out[0]);
   ASSERT_EQ(static_cast<wchar_t>(0x00a2), out[1]);
@@ -360,15 +365,27 @@
   // Check that valid has advanced to the end of the string.
   ASSERT_EQ(nullptr, valid);
 
-  const char* invalid = "A" "\xc2\x20" "ef";
+  const char* invalid = INVALID;
   ASSERT_EQ(static_cast<size_t>(-1), mbsrtowcs(out, &invalid, 4, ps));
   EXPECT_EQ(EILSEQ, errno);
   ASSERT_EQ('\xc2', *invalid);
 
-  const char* incomplete = "A" "\xc2";
+  const char* incomplete = INCOMPLETE;
   ASSERT_EQ(static_cast<size_t>(-1), mbsrtowcs(out, &incomplete, 2, ps));
   EXPECT_EQ(EILSEQ, errno);
   ASSERT_EQ('\xc2', *incomplete);
+
+  // If dst is null, *src shouldn't be updated.
+  // https://code.google.com/p/android/issues/detail?id=166381
+  const char* mbs = VALID;
+  EXPECT_EQ(6U, mbsrtowcs(nullptr, &mbs, 0, ps));
+  EXPECT_EQ(VALID, mbs);
+  mbs = INVALID;
+  EXPECT_EQ(static_cast<size_t>(-1), mbsrtowcs(nullptr, &mbs, 0, ps));
+  EXPECT_EQ(INVALID, mbs);
+  mbs = INCOMPLETE;
+  EXPECT_EQ(static_cast<size_t>(-1), mbsrtowcs(nullptr, &mbs, 0, ps));
+  EXPECT_EQ(INCOMPLETE, mbs);
 }
 
 TEST(wchar, mbsrtowcs) {
@@ -389,14 +406,6 @@
   ASSERT_EQ('\x20', *invalid);
 }
 
-TEST(wchar, wcstod) {
-  ASSERT_DOUBLE_EQ(1.23, wcstod(L"1.23", NULL));
-}
-
-TEST(wchar, wcstof) {
-  ASSERT_FLOAT_EQ(1.23f, wcstof(L"1.23", NULL));
-}
-
 TEST(wchar, wcstol) {
   ASSERT_EQ(123L, wcstol(L"123", NULL, 0));
 }
@@ -405,10 +414,6 @@
   ASSERT_EQ(123LL, wcstol(L"123", NULL, 0));
 }
 
-TEST(wchar, wcstold) {
-  ASSERT_DOUBLE_EQ(1.23L, wcstold(L"1.23", NULL));
-}
-
 TEST(wchar, wcstoul) {
   ASSERT_EQ(123UL, wcstoul(L"123", NULL, 0));
 }
@@ -672,3 +677,64 @@
   wchar_t dst[6];
   ASSERT_EQ(&dst[4], wmempcpy(dst, L"hello", 4));
 }
+
+template <typename T>
+static void CheckWcsToFloat(T fn(const wchar_t* s, wchar_t** end)) {
+  FpUlpEq<0, T> pred;
+
+  EXPECT_PRED_FORMAT2(pred, 9.0, fn(L"9.0", nullptr));
+  EXPECT_PRED_FORMAT2(pred, 9.0, fn(L"0.9e1", nullptr));
+  EXPECT_PRED_FORMAT2(pred, 9.0, fn(L"0x1.2p3", nullptr));
+
+  EXPECT_TRUE(isnan(fn(L"+nan", nullptr)));
+  EXPECT_TRUE(isnan(fn(L"nan", nullptr)));
+  EXPECT_TRUE(isnan(fn(L"-nan", nullptr)));
+
+  EXPECT_TRUE(isnan(fn(L"+nan(0xff)", nullptr)));
+  EXPECT_TRUE(isnan(fn(L"nan(0xff)", nullptr)));
+  EXPECT_TRUE(isnan(fn(L"-nan(0xff)", nullptr)));
+
+  wchar_t* p;
+  EXPECT_TRUE(isnan(fn(L"+nanny", &p)));
+  EXPECT_STREQ(L"ny", p);
+  EXPECT_TRUE(isnan(fn(L"nanny", &p)));
+  EXPECT_STREQ(L"ny", p);
+  EXPECT_TRUE(isnan(fn(L"-nanny", &p)));
+  EXPECT_STREQ(L"ny", p);
+
+  EXPECT_EQ(0, fn(L"muppet", &p));
+  EXPECT_STREQ(L"muppet", p);
+  EXPECT_EQ(0, fn(L"  muppet", &p));
+  EXPECT_STREQ(L"  muppet", p);
+
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn(L"+inf", nullptr));
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn(L"inf", nullptr));
+  EXPECT_EQ(-std::numeric_limits<T>::infinity(), fn(L"-inf", nullptr));
+
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn(L"+infinity", nullptr));
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn(L"infinity", nullptr));
+  EXPECT_EQ(-std::numeric_limits<T>::infinity(), fn(L"-infinity", nullptr));
+
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn(L"+infinitude", &p));
+  EXPECT_STREQ(L"initude", p);
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn(L"infinitude", &p));
+  EXPECT_STREQ(L"initude", p);
+  EXPECT_EQ(-std::numeric_limits<T>::infinity(), fn(L"-infinitude", &p));
+  EXPECT_STREQ(L"initude", p);
+
+  // Check case-insensitivity.
+  EXPECT_EQ(std::numeric_limits<T>::infinity(), fn(L"InFiNiTy", nullptr));
+  EXPECT_TRUE(isnan(fn(L"NaN", nullptr)));
+}
+
+TEST(wchar, wcstod) {
+  CheckWcsToFloat(wcstod);
+}
+
+TEST(wchar, wcstof) {
+  CheckWcsToFloat(wcstof);
+}
+
+TEST(wchar, wcstold) {
+  CheckWcsToFloat(wcstold);
+}
diff --git a/tests/wctype_test.cpp b/tests/wctype_test.cpp
new file mode 100644
index 0000000..fe2e374
--- /dev/null
+++ b/tests/wctype_test.cpp
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <wctype.h>
+
+#include <gtest/gtest.h>
+
+class UtfLocale {
+ public:
+  UtfLocale() : l(newlocale(LC_ALL, "C.UTF-8", 0)) {}
+  ~UtfLocale() { freelocale(l); }
+  locale_t l;
+};
+
+static void TestIsWideFn(int fn(wint_t),
+                         int fn_l(wint_t, locale_t),
+                         const wchar_t* trues,
+                         const wchar_t* falses) {
+  UtfLocale l;
+  for (const wchar_t* p = trues; *p; ++p) {
+    EXPECT_TRUE(fn(*p)) << *p;
+    EXPECT_TRUE(fn_l(*p, l.l)) << *p;
+  }
+  for (const wchar_t* p = falses; *p; ++p) {
+    EXPECT_FALSE(fn(*p)) << *p;
+    EXPECT_FALSE(fn_l(*p, l.l)) << *p;
+  }
+}
+
+TEST(wctype, iswalnum) {
+  TestIsWideFn(iswalnum, iswalnum_l, L"1aA", L"! \b");
+}
+
+TEST(wctype, iswalpha) {
+  TestIsWideFn(iswalpha, iswalpha_l, L"aA", L"1! \b");
+}
+
+TEST(wctype, iswblank) {
+  TestIsWideFn(iswblank, iswblank_l, L" \t", L"1aA!\b");
+}
+
+TEST(wctype, iswcntrl) {
+  TestIsWideFn(iswcntrl, iswcntrl_l, L"\b", L"1aA! ");
+}
+
+TEST(wctype, iswdigit) {
+  TestIsWideFn(iswdigit, iswdigit_l, L"1", L"aA! \b");
+}
+
+TEST(wctype, iswgraph) {
+  TestIsWideFn(iswgraph, iswgraph_l, L"1aA!", L" \b");
+}
+
+TEST(wctype, iswlower) {
+  TestIsWideFn(iswlower, iswlower_l, L"a", L"1A! \b");
+}
+
+TEST(wctype, iswprint) {
+  TestIsWideFn(iswprint, iswprint_l, L"1aA! ", L"\b");
+}
+
+TEST(wctype, iswpunct) {
+  TestIsWideFn(iswpunct, iswpunct_l, L"!", L"1aA \b");
+}
+
+TEST(wctype, iswspace) {
+  TestIsWideFn(iswspace, iswspace_l, L" \f\t", L"1aA!\b");
+}
+
+TEST(wctype, iswupper) {
+  TestIsWideFn(iswupper, iswupper_l, L"A", L"1a! \b");
+}
+
+TEST(wctype, iswxdigit) {
+  TestIsWideFn(iswxdigit, iswxdigit_l, L"01aA", L"xg! \b");
+}
+
+TEST(wctype, towlower) {
+  EXPECT_EQ(wint_t('!'), towlower(L'!'));
+  EXPECT_EQ(wint_t('a'), towlower(L'a'));
+  EXPECT_EQ(wint_t('a'), towlower(L'A'));
+}
+
+TEST(wctype, towlower_l) {
+  UtfLocale l;
+  EXPECT_EQ(wint_t('!'), towlower_l(L'!', l.l));
+  EXPECT_EQ(wint_t('a'), towlower_l(L'a', l.l));
+  EXPECT_EQ(wint_t('a'), towlower_l(L'A', l.l));
+}
+
+TEST(wctype, towupper) {
+  EXPECT_EQ(wint_t('!'), towupper(L'!'));
+  EXPECT_EQ(wint_t('A'), towupper(L'a'));
+  EXPECT_EQ(wint_t('A'), towupper(L'A'));
+}
+
+TEST(wctype, towupper_l) {
+  UtfLocale l;
+  EXPECT_EQ(wint_t('!'), towupper_l(L'!', l.l));
+  EXPECT_EQ(wint_t('A'), towupper_l(L'a', l.l));
+  EXPECT_EQ(wint_t('A'), towupper_l(L'A', l.l));
+}
+
+TEST(wctype, wctype) {
+  EXPECT_TRUE(wctype("alnum") != 0);
+  EXPECT_TRUE(wctype("alpha") != 0);
+  EXPECT_TRUE(wctype("blank") != 0);
+  EXPECT_TRUE(wctype("cntrl") != 0);
+  EXPECT_TRUE(wctype("digit") != 0);
+  EXPECT_TRUE(wctype("graph") != 0);
+  EXPECT_TRUE(wctype("lower") != 0);
+  EXPECT_TRUE(wctype("print") != 0);
+  EXPECT_TRUE(wctype("punct") != 0);
+  EXPECT_TRUE(wctype("space") != 0);
+  EXPECT_TRUE(wctype("upper") != 0);
+  EXPECT_TRUE(wctype("xdigit") != 0);
+
+  EXPECT_TRUE(wctype("monkeys") == 0);
+}
+
+TEST(wctype, wctype_l) {
+  UtfLocale l;
+  EXPECT_TRUE(wctype_l("alnum", l.l) != 0);
+  EXPECT_TRUE(wctype_l("alpha", l.l) != 0);
+  EXPECT_TRUE(wctype_l("blank", l.l) != 0);
+  EXPECT_TRUE(wctype_l("cntrl", l.l) != 0);
+  EXPECT_TRUE(wctype_l("digit", l.l) != 0);
+  EXPECT_TRUE(wctype_l("graph", l.l) != 0);
+  EXPECT_TRUE(wctype_l("lower", l.l) != 0);
+  EXPECT_TRUE(wctype_l("print", l.l) != 0);
+  EXPECT_TRUE(wctype_l("punct", l.l) != 0);
+  EXPECT_TRUE(wctype_l("space", l.l) != 0);
+  EXPECT_TRUE(wctype_l("upper", l.l) != 0);
+  EXPECT_TRUE(wctype_l("xdigit", l.l) != 0);
+
+  EXPECT_TRUE(wctype_l("monkeys", l.l) == 0);
+}
+
+TEST(wctype, iswctype) {
+  EXPECT_TRUE(iswctype(L'a', wctype("alnum")));
+  EXPECT_TRUE(iswctype(L'1', wctype("alnum")));
+  EXPECT_FALSE(iswctype(L' ', wctype("alnum")));
+
+  EXPECT_EQ(0, iswctype(WEOF, wctype("alnum")));
+}
+
+TEST(wctype, iswctype_l) {
+  UtfLocale l;
+  EXPECT_TRUE(iswctype_l(L'a', wctype_l("alnum", l.l), l.l));
+  EXPECT_TRUE(iswctype_l(L'1', wctype_l("alnum", l.l), l.l));
+  EXPECT_FALSE(iswctype_l(L' ', wctype_l("alnum", l.l), l.l));
+
+  EXPECT_EQ(0, iswctype_l(WEOF, wctype_l("alnum", l.l), l.l));
+}
+
+TEST(wctype, towctrans) {
+  EXPECT_TRUE(wctrans("tolower") != 0);
+  EXPECT_TRUE(wctrans("toupper") != 0);
+
+  EXPECT_TRUE(wctrans("monkeys") == 0);
+}
+
+TEST(wctype, towctrans_l) {
+  UtfLocale l;
+  EXPECT_TRUE(wctrans_l("tolower", l.l) != 0);
+  EXPECT_TRUE(wctrans_l("toupper", l.l) != 0);
+
+  EXPECT_TRUE(wctrans_l("monkeys", l.l) == 0);
+}
+
+TEST(wctype, wctrans) {
+  EXPECT_EQ(wint_t('a'), towctrans(L'A', wctrans("tolower")));
+  EXPECT_EQ(WEOF, towctrans(WEOF, wctrans("tolower")));
+
+  EXPECT_EQ(wint_t('A'), towctrans(L'a', wctrans("toupper")));
+  EXPECT_EQ(WEOF, towctrans(WEOF, wctrans("toupper")));
+}
+
+TEST(wctype, wctrans_l) {
+  UtfLocale l;
+  EXPECT_EQ(wint_t('a'), towctrans_l(L'A', wctrans_l("tolower", l.l), l.l));
+  EXPECT_EQ(WEOF, towctrans_l(WEOF, wctrans_l("tolower", l.l), l.l));
+
+  EXPECT_EQ(wint_t('A'), towctrans_l(L'a', wctrans_l("toupper", l.l), l.l));
+  EXPECT_EQ(WEOF, towctrans_l(WEOF, wctrans_l("toupper", l.l), l.l));
+}
diff --git a/tools/Android.bp b/tools/Android.bp
new file mode 100644
index 0000000..b44c296
--- /dev/null
+++ b/tools/Android.bp
@@ -0,0 +1 @@
+subdirs = ["*"]
diff --git a/tools/relocation_packer/Android.bp b/tools/relocation_packer/Android.bp
new file mode 100644
index 0000000..2907b31
--- /dev/null
+++ b/tools/relocation_packer/Android.bp
@@ -0,0 +1,84 @@
+//
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_defaults {
+    name: "relocation_packer_flags",
+    cppflags: [
+        "-Wall",
+        "-Wextra",
+        "-Wunused",
+        "-Werror",
+        "-Wold-style-cast",
+    ],
+
+    target: {
+        darwin: {
+            enabled: false,
+        },
+    },
+}
+
+cc_library_host_static {
+    name: "lib_relocation_packer",
+    defaults: ["relocation_packer_flags"],
+    srcs: [
+        "src/debug.cc",
+        "src/delta_encoder.cc",
+        "src/elf_file.cc",
+        "src/packer.cc",
+        "src/sleb128.cc",
+    ],
+
+    static_libs: [
+        "libelf",
+        "libz",
+    ],
+}
+
+cc_binary_host {
+    name: "relocation_packer",
+    defaults: ["relocation_packer_flags"],
+
+    srcs: ["src/main.cc"],
+    static_libs: [
+        "lib_relocation_packer",
+        "libelf",
+        "libz",
+        "libbase",
+    ],
+
+    // Statically linking libc++ to make it work from prebuilts
+    stl: "libc++_static",
+}
+
+cc_test_host {
+    name: "relocation_packer_unit_tests",
+    defaults: ["relocation_packer_flags"],
+
+    srcs: [
+        "src/debug_unittest.cc",
+        "src/delta_encoder_unittest.cc",
+        "src/elf_file_unittest.cc",
+        "src/sleb128_unittest.cc",
+        "src/packer_unittest.cc",
+    ],
+
+    static_libs: [
+        "lib_relocation_packer",
+        "libelf",
+        "libz",
+    ],
+}
diff --git a/tools/relocation_packer/Android.mk b/tools/relocation_packer/Android.mk
index 2bf77b9..9905657 100644
--- a/tools/relocation_packer/Android.mk
+++ b/tools/relocation_packer/Android.mk
@@ -14,71 +14,9 @@
 # limitations under the License.
 #
 
-ifeq ($(HOST_OS),linux)
-common_cppflags := -Wall -Wextra -Wunused -Werror -Wold-style-cast
-
 LOCAL_PATH := $(call my-dir)
 
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_SRC_FILES := \
-  src/debug.cc \
-  src/delta_encoder.cc \
-  src/elf_file.cc \
-  src/packer.cc \
-  src/sleb128.cc \
-
-LOCAL_STATIC_LIBRARIES := libelf libz
-LOCAL_C_INCLUDES := external/elfutils/src/libelf
-LOCAL_MODULE := lib_relocation_packer
-
-LOCAL_CPPFLAGS := $(common_cppflags)
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_SRC_FILES := src/main.cc
-LOCAL_STATIC_LIBRARIES := lib_relocation_packer libelf libz
-
-# Statically linking libc++ to make it work from prebuilts
-LOCAL_CXX_STL := libc++_static
-LOCAL_C_INCLUDES := external/elfutils/src/libelf libnativehelper/include
-
-LOCAL_MODULE := relocation_packer
-
-LOCAL_CPPFLAGS := $(common_cppflags)
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_SRC_FILES := \
-  src/debug_unittest.cc \
-  src/delta_encoder_unittest.cc \
-  src/elf_file_unittest.cc \
-  src/sleb128_unittest.cc \
-  src/packer_unittest.cc \
-
-LOCAL_STATIC_LIBRARIES := lib_relocation_packer libelf libz
-LOCAL_C_INCLUDES := external/elfutils/src/libelf
-
-LOCAL_CPPFLAGS := $(common_cppflags)
-
-LOCAL_MODULE := relocation_packer_unit_tests
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_HOST_NATIVE_TEST)
+ifeq ($(HOST_OS),linux)
 
 # $(1) library name
 define copy-test-library
diff --git a/tools/relocation_packer/src/debug.h b/tools/relocation_packer/src/debug.h
index 48be6c1..fdfb795 100644
--- a/tools/relocation_packer/src/debug.h
+++ b/tools/relocation_packer/src/debug.h
@@ -81,26 +81,29 @@
 
 // Make logging severities visible globally.
 typedef relocation_packer::Logger::Severity LogSeverity;
-using LogSeverity::INFO;
-using LogSeverity::WARNING;
-using LogSeverity::ERROR;
-using LogSeverity::FATAL;
 
 // LOG(severity) prints a message with the given severity, and aborts if
 // severity is FATAL.  LOG_IF(severity, predicate) does the same but only if
 // predicate is true.  INT_MIN is guaranteed to be less than or equal to
 // any verbosity level.
-#define LOG(severity) \
-    (relocation_packer::Logger(severity, INT_MIN, true).GetStream())
-#define LOG_IF(severity, predicate) \
-    (relocation_packer::Logger(severity, INT_MIN, (predicate)).GetStream())
+#define LOG(severity)                                                      \
+  (relocation_packer::Logger(relocation_packer::Logger::severity, INT_MIN, \
+                             true)                                         \
+       .GetStream())
+#define LOG_IF(severity, predicate)                                        \
+  (relocation_packer::Logger(relocation_packer::Logger::severity, INT_MIN, \
+                             (predicate))                                  \
+       .GetStream())
 
 // VLOG(level) prints its message as INFO if level is less than or equal to
 // the current verbosity level.
-#define VLOG(level) \
-    (relocation_packer::Logger(INFO, (level), true).GetStream())
-#define VLOG_IF(level, predicate) \
-    (relocation_packer::Logger(INFO, (level), (predicate)).GetStream())
+#define VLOG(level)                                                          \
+  (relocation_packer::Logger(relocation_packer::Logger::INFO, (level), true) \
+       .GetStream())
+#define VLOG_IF(level, predicate)                                      \
+  (relocation_packer::Logger(relocation_packer::Logger::INFO, (level), \
+                             (predicate))                              \
+       .GetStream())
 
 // CHECK(predicate) fails with a FATAL log message if predicate is false.
 #define CHECK(predicate) (LOG_IF(FATAL, !(predicate)) \
diff --git a/tools/relocation_packer/src/elf_file.cc b/tools/relocation_packer/src/elf_file.cc
index 014883d..96e6efd 100644
--- a/tools/relocation_packer/src/elf_file.cc
+++ b/tools/relocation_packer/src/elf_file.cc
@@ -552,11 +552,11 @@
               << " d_val adjusted to " << dynamic->d_un.d_val;
     }
 
-    // Special case: DT_MIPS_RLD_MAP2 stores the difference between dynamic
+    // Special case: DT_MIPS_RLD_MAP_REL stores the difference between dynamic
     // entry address and the address of the _r_debug (used by GDB)
     // since the dynamic section and target address are on the
     // different sides of the hole it needs to be adjusted accordingly
-    if (tag == DT_MIPS_RLD_MAP2) {
+    if (tag == DT_MIPS_RLD_MAP_REL) {
       dynamic->d_un.d_val += hole_size;
       VLOG(1) << "dynamic[" << i << "] " << dynamic->d_tag
               << " d_val adjusted to " << dynamic->d_un.d_val;
diff --git a/tools/relocation_packer/src/elf_traits.h b/tools/relocation_packer/src/elf_traits.h
index 1c938fa..3e282b2 100644
--- a/tools/relocation_packer/src/elf_traits.h
+++ b/tools/relocation_packer/src/elf_traits.h
@@ -10,8 +10,8 @@
 #include "elf.h"
 #include "libelf.h"
 
-#if !defined(DT_MIPS_RLD_MAP2)
-#define DT_MIPS_RLD_MAP2 0x70000035
+#if !defined(DT_MIPS_RLD_MAP_REL)
+#define DT_MIPS_RLD_MAP_REL 0x70000035
 #endif
 
 // ELF is a traits structure used to provide convenient aliases for
diff --git a/tools/relocation_packer/src/main.cc b/tools/relocation_packer/src/main.cc
index 8e9de6d..d0a0dd4 100644
--- a/tools/relocation_packer/src/main.cc
+++ b/tools/relocation_packer/src/main.cc
@@ -25,7 +25,7 @@
 #include "elf_traits.h"
 #include "libelf.h"
 
-#include "nativehelper/ScopedFd.h"
+#include <android-base/unique_fd.h>
 
 static void PrintUsage(const char* argv0) {
   std::string temporary = argv0;
@@ -94,7 +94,7 @@
   }
 
   const char* file = argv[argc - 1];
-  ScopedFd fd(open(file, O_RDWR));
+  android::base::unique_fd fd(open(file, O_RDWR));
   if (fd.get() == -1) {
     LOG(ERROR) << file << ": " << strerror(errno);
     return 1;
diff --git a/tools/update_headers.sh b/tools/update_headers.sh
new file mode 100755
index 0000000..0095d50
--- /dev/null
+++ b/tools/update_headers.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd $DIR
+
+which versioner >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+  >&2 echo "versioner not in path; run mma in $DIR/versioner"
+  exit 1
+fi
+
+VERSION=$(git rev-parse --short HEAD)
+git diff-index --quiet HEAD
+DIRTY=$?
+git branch -r --contains HEAD | grep -q aosp/master
+SUBMITTED=$?
+
+if [ $DIRTY -ne 0 ]; then
+  >&2 echo "Warning: bionic has uncommitted changes"
+  VERSION="${VERSION}-dirty"
+elif [ $SUBMITTED -ne 0 ]; then
+  >&2 echo "Warning: current HEAD does not exist in aosp/master"
+  VERSION="${VERSION}-unsubmitted"
+fi
+
+PREBUILTS_DIR=$ANDROID_BUILD_TOP/prebuilts/ndk
+BRANCH_NAME=$(git -C $PREBUILTS_DIR symbolic-ref --short -q HEAD)
+if [ $? -ne 0 ]; then
+  BRANCH_NAME=update-bionic-headers-$VERSION
+  echo "prebuilts/ndk has detached head; creating branch $BRANCH_NAME"
+  repo start $BRANCH_NAME $PREBUILTS_DIR
+else
+  echo "prebuilts/ndk already on branch $BRANCH_NAME"
+fi
+
+HEADERS_INSTALL=$PREBUILTS_DIR/headers
+if [ -d "$HEADERS_INSTALL" ]; then
+  git -C $PREBUILTS_DIR rm -r --ignore-unmatch $HEADERS_INSTALL
+  if [ -d $HEADERS_INSTALL ]; then
+    rm -r $HEADERS_INSTALL
+  fi
+fi
+
+versioner -p versioner/platforms versioner/current versioner/dependencies \
+  -o $HEADERS_INSTALL
+if [ $? -ne 0 ]; then
+  >&2 echo "Header preprocessing failed"
+  exit 1
+fi
+
+cp ../libc/NOTICE $PREBUILTS_DIR
+
+git -C $PREBUILTS_DIR add $HEADERS_INSTALL $PREBUILTS_DIR/NOTICE
+git -C $PREBUILTS_DIR commit -m "Update bionic headers to $VERSION."
diff --git a/tools/update_notice.sh b/tools/update_notice.sh
new file mode 100755
index 0000000..9974da2
--- /dev/null
+++ b/tools/update_notice.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd $DIR/..
+./libc/tools/generate-NOTICE.py libc libdl libm linker libstdc++ > libc/NOTICE
+
+git diff --exit-code HEAD libc/NOTICE
+exit $?
diff --git a/tools/versioner/Android.mk b/tools/versioner/Android.mk
new file mode 100644
index 0000000..c455f97
--- /dev/null
+++ b/tools/versioner/Android.mk
@@ -0,0 +1,3 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
diff --git a/tools/versioner/README.md b/tools/versioner/README.md
new file mode 100644
index 0000000..39b5128
--- /dev/null
+++ b/tools/versioner/README.md
@@ -0,0 +1,8 @@
+## versioner
+Use clang to verify the correctness of bionic's availability attributes against the NDK platform definitions.
+
+#### Build
+Build with `FORCE_BUILD_LLVM_COMPONENTS=true mma -j48`
+
+#### Use
+`versioner -p platforms current dependencies`
diff --git a/tools/versioner/current b/tools/versioner/current
new file mode 120000
index 0000000..234dfe7
--- /dev/null
+++ b/tools/versioner/current
@@ -0,0 +1 @@
+../../libc/include
\ No newline at end of file
diff --git a/tools/versioner/dependencies/arm/arch-arm b/tools/versioner/dependencies/arm/arch-arm
new file mode 120000
index 0000000..ed69f41
--- /dev/null
+++ b/tools/versioner/dependencies/arm/arch-arm
@@ -0,0 +1 @@
+../../../../libc/arch-arm/include
\ No newline at end of file
diff --git a/tools/versioner/dependencies/arm/kernel_uapi_asm-arm b/tools/versioner/dependencies/arm/kernel_uapi_asm-arm
new file mode 120000
index 0000000..fabed85
--- /dev/null
+++ b/tools/versioner/dependencies/arm/kernel_uapi_asm-arm
@@ -0,0 +1 @@
+../../../../libc/kernel/uapi/asm-arm
\ No newline at end of file
diff --git a/tools/versioner/dependencies/arm64/arch-arm64 b/tools/versioner/dependencies/arm64/arch-arm64
new file mode 120000
index 0000000..21a21d4
--- /dev/null
+++ b/tools/versioner/dependencies/arm64/arch-arm64
@@ -0,0 +1 @@
+../../../../libc/arch-arm64/include
\ No newline at end of file
diff --git a/tools/versioner/dependencies/arm64/kernel_uapi_asm-arm64 b/tools/versioner/dependencies/arm64/kernel_uapi_asm-arm64
new file mode 120000
index 0000000..16e74a3
--- /dev/null
+++ b/tools/versioner/dependencies/arm64/kernel_uapi_asm-arm64
@@ -0,0 +1 @@
+../../../../libc/kernel/uapi/asm-arm64
\ No newline at end of file
diff --git a/tools/versioner/dependencies/common/clang-builtins b/tools/versioner/dependencies/common/clang-builtins
new file mode 120000
index 0000000..fc27e65
--- /dev/null
+++ b/tools/versioner/dependencies/common/clang-builtins
@@ -0,0 +1 @@
+../../../../../external/clang/lib/Headers
\ No newline at end of file
diff --git a/tools/versioner/dependencies/common/kernel_android_uapi b/tools/versioner/dependencies/common/kernel_android_uapi
new file mode 120000
index 0000000..bcf6daa
--- /dev/null
+++ b/tools/versioner/dependencies/common/kernel_android_uapi
@@ -0,0 +1 @@
+../../../../libc/kernel/android/uapi
\ No newline at end of file
diff --git a/tools/versioner/dependencies/common/kernel_uapi b/tools/versioner/dependencies/common/kernel_uapi
new file mode 120000
index 0000000..2a915ef
--- /dev/null
+++ b/tools/versioner/dependencies/common/kernel_uapi
@@ -0,0 +1 @@
+../../../../libc/kernel/uapi
\ No newline at end of file
diff --git a/tools/versioner/dependencies/mips/arch-mips b/tools/versioner/dependencies/mips/arch-mips
new file mode 120000
index 0000000..7f2f104
--- /dev/null
+++ b/tools/versioner/dependencies/mips/arch-mips
@@ -0,0 +1 @@
+../../../../libc/arch-mips/include
\ No newline at end of file
diff --git a/tools/versioner/dependencies/mips/kernel_uapi_asm-mips b/tools/versioner/dependencies/mips/kernel_uapi_asm-mips
new file mode 120000
index 0000000..dcd1955
--- /dev/null
+++ b/tools/versioner/dependencies/mips/kernel_uapi_asm-mips
@@ -0,0 +1 @@
+../../../../libc/kernel/uapi/asm-mips
\ No newline at end of file
diff --git a/tools/versioner/dependencies/mips64/arch-mips64 b/tools/versioner/dependencies/mips64/arch-mips64
new file mode 120000
index 0000000..48cea72
--- /dev/null
+++ b/tools/versioner/dependencies/mips64/arch-mips64
@@ -0,0 +1 @@
+../../../../libc/arch-mips64/include
\ No newline at end of file
diff --git a/tools/versioner/dependencies/mips64/kernel_uapi_asm-mips b/tools/versioner/dependencies/mips64/kernel_uapi_asm-mips
new file mode 120000
index 0000000..dcd1955
--- /dev/null
+++ b/tools/versioner/dependencies/mips64/kernel_uapi_asm-mips
@@ -0,0 +1 @@
+../../../../libc/kernel/uapi/asm-mips
\ No newline at end of file
diff --git a/tools/versioner/dependencies/x86/arch-x86 b/tools/versioner/dependencies/x86/arch-x86
new file mode 120000
index 0000000..d0f016a
--- /dev/null
+++ b/tools/versioner/dependencies/x86/arch-x86
@@ -0,0 +1 @@
+../../../../libc/arch-x86/include
\ No newline at end of file
diff --git a/tools/versioner/dependencies/x86/kernel_uapi_asm-x86 b/tools/versioner/dependencies/x86/kernel_uapi_asm-x86
new file mode 120000
index 0000000..0efae62
--- /dev/null
+++ b/tools/versioner/dependencies/x86/kernel_uapi_asm-x86
@@ -0,0 +1 @@
+../../../../libc/kernel/uapi/asm-x86
\ No newline at end of file
diff --git a/tools/versioner/dependencies/x86_64/arch-x86_64 b/tools/versioner/dependencies/x86_64/arch-x86_64
new file mode 120000
index 0000000..deb647d
--- /dev/null
+++ b/tools/versioner/dependencies/x86_64/arch-x86_64
@@ -0,0 +1 @@
+../../../../libc/arch-x86_64/include
\ No newline at end of file
diff --git a/tools/versioner/dependencies/x86_64/kernel_uapi_asm-x86 b/tools/versioner/dependencies/x86_64/kernel_uapi_asm-x86
new file mode 120000
index 0000000..0efae62
--- /dev/null
+++ b/tools/versioner/dependencies/x86_64/kernel_uapi_asm-x86
@@ -0,0 +1 @@
+../../../../libc/kernel/uapi/asm-x86
\ No newline at end of file
diff --git a/tools/versioner/platforms b/tools/versioner/platforms
new file mode 120000
index 0000000..bcb7da8
--- /dev/null
+++ b/tools/versioner/platforms
@@ -0,0 +1 @@
+../../../development/ndk/platforms
\ No newline at end of file
diff --git a/tools/versioner/preupload.sh b/tools/versioner/preupload.sh
new file mode 100755
index 0000000..45d6cca
--- /dev/null
+++ b/tools/versioner/preupload.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if ! which versioner > /dev/null; then
+  echo "versioner not found (lunch and mma in bionic)"
+  exit 1
+fi
+
+versioner -r arm -r arm64
+exit $?
diff --git a/tools/versioner/run_tests.py b/tools/versioner/run_tests.py
new file mode 100755
index 0000000..f3bb6db
--- /dev/null
+++ b/tools/versioner/run_tests.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python2
+
+import os
+import subprocess
+import sys
+
+red = '\033[91m'
+green = '\033[92m'
+bold = '\033[1m'
+reset = '\033[0m'
+prefix_pass = bold + "[" + green + "PASS" + reset + bold + "]" + reset
+prefix_fail = bold + "[" + red + "FAIL" + reset + bold + "]" + reset
+
+
+def indent(text, spaces=4):
+    text = text.decode("utf-8")
+    prefix = "    "
+    return "\n".join([prefix + line for line in text.split("\n")])
+
+
+def run_test(test_name, path):
+    os.chdir(path)
+    process = subprocess.Popen(
+        ["/bin/sh", "run.sh"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    (output, _) = process.communicate()
+
+    if os.path.exists("expected_fail"):
+        with open("expected_fail", "rb") as f:
+            expected_output = f.read()
+            if process.returncode == 0:
+                print("{} {}: unexpected success:".format(prefix_fail, test_name))
+                print("")
+                print("  Expected:")
+                print(indent(expected_output))
+                print("  Actual:")
+                print(indent(output))
+                return False
+            elif not output.endswith(expected_output):
+                print("{} {}: expected output mismatch".format(
+                    prefix_fail, test_name))
+                print("")
+                print("  Expected:")
+                print(indent(expected_output))
+                print("  Actual:")
+                print(indent(output))
+                return False
+    elif process.returncode != 0:
+        print("{} {}: unexpected failure:".format(prefix_fail, test_name))
+        print("")
+        print(indent(output))
+        return False
+
+    print("{} {}".format(prefix_pass, test_name))
+    return True
+
+
+def usage():
+    print("Usage: run_tests.py [-f]")
+    print("    -f\t\tdon't run slow tests")
+    sys.exit(0)
+
+
+root_dir = os.path.dirname(os.path.realpath(__file__))
+test_dir = os.path.join(root_dir, "tests")
+tests = os.listdir(test_dir)
+run_slow = True
+
+if len(sys.argv) > 2:
+    usage()
+elif len(sys.argv) == 2:
+    if sys.argv[1] != "-f":
+        usage()
+    run_slow = False
+
+success = True
+for test in sorted(tests):
+    if test.startswith("slow") and not run_slow:
+        continue
+    path = os.path.join(test_dir, test)
+    if not os.path.isdir(path):
+        continue
+    if not run_test(test, path):
+        success = False
+
+sys.exit(0 if success else 1)
diff --git a/tools/versioner/src/Android.mk b/tools/versioner/src/Android.mk
new file mode 100644
index 0000000..c43a525
--- /dev/null
+++ b/tools/versioner/src/Android.mk
@@ -0,0 +1,48 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+# Only do this when Clang is available.
+CLANG_ROOT_PATH := external/clang
+ifneq ($(wildcard $(CLANG_ROOT_PATH)/clang.mk),)
+
+LLVM_ROOT_PATH := external/llvm
+include $(CLANG_ROOT_PATH)/clang.mk
+
+LOCAL_MODULE := versioner
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := EXECUTABLES
+
+TBLGEN_TABLES := \
+  AttrList.inc \
+  AttrVisitor.inc \
+  Attrs.inc \
+  CommentCommandList.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  StmtNodes.inc \
+
+LOCAL_SRC_FILES := \
+  versioner.cpp \
+  Arch.cpp \
+  DeclarationDatabase.cpp \
+  Preprocessor.cpp \
+  SymbolDatabase.cpp \
+  Utils.cpp
+
+LOCAL_SHARED_LIBRARIES := libclang libLLVM
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+
+# Set these after including the clang makefiles, to avoid getting CFLAGS from them.
+LOCAL_CFLAGS := -Wall -Wextra -Werror -Wno-unused-parameter
+LOCAL_CFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
+LOCAL_CPPFLAGS := -std=c++14 -fno-rtti
+
+LOCAL_MODULE_HOST_OS := linux
+
+include $(BUILD_HOST_EXECUTABLE)
+
+endif
diff --git a/tools/versioner/src/Arch.cpp b/tools/versioner/src/Arch.cpp
new file mode 100644
index 0000000..8d1d41e
--- /dev/null
+++ b/tools/versioner/src/Arch.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Arch.h"
+
+#include <err.h>
+
+#include <string>
+
+std::string to_string(const Arch& arch) {
+  switch (arch) {
+    case Arch::arm:
+      return "arm";
+
+    case Arch::arm64:
+      return "arm64";
+
+    case Arch::mips:
+      return "mips";
+
+    case Arch::mips64:
+      return "mips64";
+
+    case Arch::x86:
+      return "x86";
+
+    case Arch::x86_64:
+      return "x86_64";
+  }
+
+  errx(1, "unknown arch '%zu'", size_t(arch));
+}
+
+Arch arch_from_string(const std::string& name) {
+  if (name == "arm") {
+    return Arch::arm;
+  } else if (name == "arm64") {
+    return Arch::arm64;
+  } else if (name == "mips") {
+    return Arch::mips;
+  } else if (name == "mips64") {
+    return Arch::mips64;
+  } else if (name == "x86") {
+    return Arch::x86;
+  } else if (name == "x86_64") {
+    return Arch::x86_64;
+  }
+
+  errx(1, "unknown architecture '%s'", name.c_str());
+}
diff --git a/tools/versioner/src/Arch.h b/tools/versioner/src/Arch.h
new file mode 100644
index 0000000..0c6f514
--- /dev/null
+++ b/tools/versioner/src/Arch.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdlib.h>
+
+#include <array>
+#include <initializer_list>
+#include <set>
+#include <string>
+
+enum class Arch : size_t {
+  arm = 0,
+  arm64,
+  mips,
+  mips64,
+  x86,
+  x86_64,
+};
+
+std::string to_string(const Arch& arch);
+Arch arch_from_string(const std::string& name);
+
+template <typename T>
+class ArchMapIterator;
+
+template <typename T>
+class ArchMap {
+ public:
+  ArchMap() {
+  }
+
+  ArchMap(std::initializer_list<std::pair<Arch, T>> initializer) {
+    for (auto& pair : initializer) {
+      this->operator[](pair.first) = pair.second;
+    }
+  }
+
+  T& operator[](Arch arch) {
+    return data_[size_t(arch)];
+  }
+
+  const T& operator[](Arch arch) const {
+    return data_[size_t(arch)];
+  }
+
+  bool operator==(const ArchMap& other) const {
+    for (size_t i = 0; i < data_.size(); ++i) {
+      if (data_[i] != other.data_[i]) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  ArchMapIterator<T> begin() const {
+    return ArchMapIterator<T>(*this, Arch::arm);
+  }
+
+  ArchMapIterator<T> end() const {
+    return ArchMapIterator<T>(*this, Arch(size_t(Arch::x86_64) + 1));
+  }
+
+ private:
+  std::array<T, size_t(Arch::x86_64) + 1> data_ = {};
+};
+
+template <typename T>
+class ArchMapIterator {
+  const ArchMap<T>& map_;
+  Arch arch_ = Arch::arm;
+
+ public:
+  ArchMapIterator() = delete;
+
+  ArchMapIterator(const ArchMap<T>& map, Arch arch) : map_(map), arch_(arch) {
+  }
+
+  bool operator==(const ArchMapIterator<T>& rhs) const {
+    return map_ == rhs.map_ && arch_ == rhs.arch_;
+  }
+
+  bool operator!=(const ArchMapIterator<T>& rhs) const {
+    return !(*this == rhs);
+  }
+
+  ArchMapIterator& operator++() {
+    arch_ = Arch(size_t(arch_) + 1);
+    return *this;
+  }
+
+  ArchMapIterator operator++(int) {
+    ArchMapIterator result = *this;
+    ++*this;
+    return result;
+  }
+
+  std::pair<const Arch&, const T&> operator*() const {
+    return std::tie(arch_, map_[arch_]);
+  }
+
+  std::pair<const Arch&, const T&> operator->() const {
+    return std::tie(arch_, map_[arch_]);
+  }
+};
+
+static const std::set<Arch> supported_archs = {
+  Arch::arm,
+  Arch::arm64,
+  Arch::mips,
+  Arch::mips64,
+  Arch::x86,
+  Arch::x86_64,
+};
+
+static ArchMap<std::string> arch_targets = {
+  { Arch::arm, "arm-linux-androideabi" },
+  { Arch::arm64, "aarch64-linux-android" },
+  { Arch::mips, "mipsel-linux-android" },
+  { Arch::mips64, "mips64el-linux-android" },
+  { Arch::x86, "i686-linux-android" },
+  { Arch::x86_64, "x86_64-linux-android" },
+};
+
+static const std::set<int> supported_levels = { 9, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 24 };
+
+static const ArchMap<int> arch_min_api = {
+  { Arch::arm, 9 },
+  { Arch::arm64, 21 },
+  { Arch::mips, 9 },
+  { Arch::mips64, 21 },
+  { Arch::x86, 9 },
+  { Arch::x86_64, 21 },
+};
diff --git a/tools/versioner/src/DeclarationDatabase.cpp b/tools/versioner/src/DeclarationDatabase.cpp
new file mode 100644
index 0000000..9c9bc83
--- /dev/null
+++ b/tools/versioner/src/DeclarationDatabase.cpp
@@ -0,0 +1,362 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DeclarationDatabase.h"
+
+#include <err.h>
+
+#include <iostream>
+#include <map>
+#include <mutex>
+#include <set>
+#include <sstream>
+#include <string>
+#include <utility>
+
+#include <clang/AST/AST.h>
+#include <clang/AST/Attr.h>
+#include <clang/AST/Mangle.h>
+#include <clang/AST/RecursiveASTVisitor.h>
+#include <clang/Frontend/ASTUnit.h>
+#include <llvm/Support/raw_ostream.h>
+
+using namespace clang;
+
+class Visitor : public RecursiveASTVisitor<Visitor> {
+  HeaderDatabase& database;
+  CompilationType type;
+  SourceManager& src_manager;
+  std::unique_ptr<MangleContext> mangler;
+
+ public:
+  Visitor(HeaderDatabase& database, CompilationType type, ASTContext& ctx)
+      : database(database), type(type), src_manager(ctx.getSourceManager()) {
+    mangler.reset(ItaniumMangleContext::create(ctx, ctx.getDiagnostics()));
+  }
+
+  std::string getDeclName(NamedDecl* decl) {
+    if (auto var_decl = dyn_cast<VarDecl>(decl)) {
+      if (!var_decl->isFileVarDecl()) {
+        return "<local var>";
+      }
+    }
+
+    if (mangler->shouldMangleDeclName(decl)) {
+      std::string mangled;
+      llvm::raw_string_ostream ss(mangled);
+      mangler->mangleName(decl, ss);
+      return mangled;
+    }
+
+    auto identifier = decl->getIdentifier();
+    if (!identifier) {
+      return "<error>";
+    }
+    return identifier->getName();
+  }
+
+  bool VisitDecl(Decl* decl) {
+    // Skip declarations inside of functions (function arguments, variable declarations inside of
+    // inline functions, etc).
+    if (decl->getParentFunctionOrMethod()) {
+      return true;
+    }
+
+    auto named_decl = dyn_cast<NamedDecl>(decl);
+    if (!named_decl) {
+      return true;
+    }
+
+    DeclarationType declaration_type;
+    std::string declaration_name = getDeclName(named_decl);
+    bool is_extern = named_decl->getFormalLinkage() == ExternalLinkage;
+    bool is_definition = false;
+    bool no_guard = false;
+
+    if (auto function_decl = dyn_cast<FunctionDecl>(decl)) {
+      declaration_type = DeclarationType::function;
+      is_definition = function_decl->isThisDeclarationADefinition();
+    } else if (auto var_decl = dyn_cast<VarDecl>(decl)) {
+      if (!var_decl->isFileVarDecl()) {
+        return true;
+      }
+
+      declaration_type = DeclarationType::variable;
+      switch (var_decl->isThisDeclarationADefinition()) {
+        case VarDecl::DeclarationOnly:
+          is_definition = false;
+          break;
+
+        case VarDecl::Definition:
+          is_definition = true;
+          break;
+
+        case VarDecl::TentativeDefinition:
+          // Forbid tentative definitions in headers.
+          fprintf(stderr, "ERROR: declaration '%s' is a tentative definition\n",
+                  declaration_name.c_str());
+          decl->dump();
+          abort();
+      }
+    } else {
+      // We only care about function and variable declarations.
+      return true;
+    }
+
+    if (decl->hasAttr<UnavailableAttr>()) {
+      // Skip declarations that exist only for compile-time diagnostics.
+      return true;
+    }
+
+    auto start_loc = src_manager.getPresumedLoc(decl->getLocStart());
+    auto end_loc = src_manager.getPresumedLoc(decl->getLocEnd());
+
+    Location location = {
+      .filename = start_loc.getFilename(),
+      .start = {
+        .line = start_loc.getLine(),
+        .column = start_loc.getColumn(),
+      },
+      .end = {
+        .line = end_loc.getLine(),
+        .column = end_loc.getColumn(),
+      }
+    };
+
+    DeclarationAvailability availability;
+
+    // Find and parse __ANDROID_AVAILABILITY_DUMP__ annotations.
+    for (const AnnotateAttr* attr : decl->specific_attrs<AnnotateAttr>()) {
+      llvm::StringRef annotation = attr->getAnnotation();
+      if (annotation == "versioner_no_guard") {
+        no_guard = true;
+      } else if (annotation == "introduced_in_future") {
+        // Tag the compiled-for arch, since this can vary across archs.
+        availability.arch_availability[type.arch].future = true;
+      } else {
+        llvm::SmallVector<llvm::StringRef, 2> fragments;
+        annotation.split(fragments, "=");
+        if (fragments.size() != 2) {
+          continue;
+        }
+
+        auto& global_availability = availability.global_availability;
+        auto& arch_availability = availability.arch_availability;
+        std::map<std::string, std::vector<int*>> prefix_map = {
+          { "introduced_in", { &global_availability.introduced } },
+          { "deprecated_in", { &global_availability.deprecated } },
+          { "obsoleted_in", { &global_availability.obsoleted } },
+          { "introduced_in_arm", { &arch_availability[Arch::arm].introduced } },
+          { "introduced_in_mips", { &arch_availability[Arch::mips].introduced } },
+          { "introduced_in_x86", { &arch_availability[Arch::x86].introduced } },
+          { "introduced_in_32",
+            { &arch_availability[Arch::arm].introduced,
+              &arch_availability[Arch::mips].introduced,
+              &arch_availability[Arch::x86].introduced } },
+          { "introduced_in_64",
+            { &arch_availability[Arch::arm64].introduced,
+              &arch_availability[Arch::mips64].introduced,
+              &arch_availability[Arch::x86_64].introduced } },
+        };
+
+        auto it = prefix_map.find(fragments[0]);
+        if (it == prefix_map.end()) {
+          continue;
+        }
+        int value;
+        if (fragments[1].getAsInteger(10, value)) {
+          errx(1, "invalid __ANDROID_AVAILABILITY_DUMP__ annotation: '%s'",
+               annotation.str().c_str());
+        }
+
+        for (int* ptr : it->second) {
+          *ptr = value;
+        }
+      }
+    }
+
+    auto symbol_it = database.symbols.find(declaration_name);
+    if (symbol_it == database.symbols.end()) {
+      Symbol symbol = {.name = declaration_name };
+      bool dummy;
+      std::tie(symbol_it, dummy) = database.symbols.insert({ declaration_name, symbol });
+    }
+
+    // Find or insert an entry for the declaration.
+    auto declaration_it = symbol_it->second.declarations.find(location);
+    if (declaration_it == symbol_it->second.declarations.end()) {
+      Declaration declaration;
+      declaration.name = declaration_name;
+      declaration.location = location;
+      declaration.is_extern = is_extern;
+      declaration.is_definition = is_definition;
+      declaration.no_guard = no_guard;
+      declaration.availability.insert(std::make_pair(type, availability));
+      symbol_it->second.declarations.insert(std::make_pair(location, declaration));
+    } else {
+      if (declaration_it->second.is_extern != is_extern ||
+          declaration_it->second.is_definition != is_definition ||
+          declaration_it->second.no_guard != no_guard) {
+        errx(1, "varying declaration of '%s' at %s:%u:%u", declaration_name.c_str(),
+             location.filename.c_str(), location.start.line, location.start.column);
+      }
+      declaration_it->second.availability.insert(std::make_pair(type, availability));
+    }
+
+    return true;
+  }
+};
+
+bool DeclarationAvailability::merge(const DeclarationAvailability& other) {
+#define check_avail(expr) error |= (!this->expr.empty() && this->expr != other.expr);
+  bool error = false;
+
+  if (!other.global_availability.empty()) {
+    check_avail(global_availability);
+    this->global_availability = other.global_availability;
+  }
+
+  for (Arch arch : supported_archs) {
+    if (!other.arch_availability[arch].empty()) {
+      check_avail(arch_availability[arch]);
+      this->arch_availability[arch] = other.arch_availability[arch];
+    }
+  }
+#undef check_avail
+
+  return !error;
+}
+
+bool Declaration::calculateAvailability(DeclarationAvailability* output) const {
+  DeclarationAvailability avail;
+  for (const auto& it : this->availability) {
+    if (!avail.merge(it.second)) {
+      return false;
+    }
+  }
+  *output = avail;
+  return true;
+}
+
+bool Symbol::calculateAvailability(DeclarationAvailability* output) const {
+  DeclarationAvailability avail;
+  for (const auto& it : this->declarations) {
+    // Don't merge availability for inline functions (because they shouldn't have any).
+    if (it.second.is_definition) {
+      continue;
+    }
+
+    DeclarationAvailability decl_availability;
+    if (!it.second.calculateAvailability(&decl_availability)) {
+      return false;
+      abort();
+    }
+
+    if (!avail.merge(decl_availability)) {
+      return false;
+    }
+  }
+  *output = avail;
+  return true;
+}
+
+bool Symbol::hasDeclaration(const CompilationType& type) const {
+  for (const auto& decl_it : this->declarations) {
+    for (const auto& compilation_it : decl_it.second.availability) {
+      if (compilation_it.first == type) {
+        return true;
+      }
+    }
+  }
+  return false;
+}
+
+void HeaderDatabase::parseAST(CompilationType type, ASTUnit* ast) {
+  std::unique_lock<std::mutex> lock(this->mutex);
+  ASTContext& ctx = ast->getASTContext();
+  Visitor visitor(*this, type, ctx);
+  visitor.TraverseDecl(ctx.getTranslationUnitDecl());
+}
+
+std::string to_string(const CompilationType& type) {
+  std::stringstream ss;
+  ss << to_string(type.arch) << "-" << type.api_level << " [fob = " << type.file_offset_bits << "]";
+  return ss.str();
+}
+
+std::string to_string(const AvailabilityValues& av) {
+  std::stringstream ss;
+
+  if (av.future) {
+    ss << "future, ";
+  }
+
+  if (av.introduced != 0) {
+    ss << "introduced = " << av.introduced << ", ";
+  }
+
+  if (av.deprecated != 0) {
+    ss << "deprecated = " << av.deprecated << ", ";
+  }
+
+  if (av.obsoleted != 0) {
+    ss << "obsoleted = " << av.obsoleted << ", ";
+  }
+
+  std::string result = ss.str();
+  if (!result.empty()) {
+    result = result.substr(0, result.length() - 2);
+  }
+  return result;
+}
+
+std::string to_string(const DeclarationType& type) {
+  switch (type) {
+    case DeclarationType::function:
+      return "function";
+    case DeclarationType::variable:
+      return "variable";
+    case DeclarationType::inconsistent:
+      return "inconsistent";
+  }
+  abort();
+}
+
+std::string to_string(const DeclarationAvailability& decl_av) {
+  std::stringstream ss;
+  if (!decl_av.global_availability.empty()) {
+    ss << to_string(decl_av.global_availability) << ", ";
+  }
+
+  for (const auto& it : decl_av.arch_availability) {
+    if (!it.second.empty()) {
+      ss << to_string(it.first) << ": " << to_string(it.second) << ", ";
+    }
+  }
+
+  std::string result = ss.str();
+  if (result.size() == 0) {
+    return "no availability";
+  }
+
+  return result.substr(0, result.length() - 2);
+}
+
+std::string to_string(const Location& loc) {
+  std::stringstream ss;
+  ss << loc.filename << ":" << loc.start.line << ":" << loc.start.column;
+  return ss.str();
+}
diff --git a/tools/versioner/src/DeclarationDatabase.h b/tools/versioner/src/DeclarationDatabase.h
new file mode 100644
index 0000000..cf3589b
--- /dev/null
+++ b/tools/versioner/src/DeclarationDatabase.h
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdio.h>
+
+#include <map>
+#include <mutex>
+#include <set>
+#include <string>
+#include <vector>
+
+#include <llvm/ADT/StringRef.h>
+
+#include "Arch.h"
+#include "Utils.h"
+
+namespace clang {
+class ASTUnit;
+class Decl;
+}
+
+enum class DeclarationType {
+  function,
+  variable,
+  inconsistent,
+};
+
+struct CompilationType {
+  Arch arch;
+  int api_level;
+  int file_offset_bits;
+
+ private:
+  auto tie() const {
+    return std::tie(arch, api_level, file_offset_bits);
+  }
+
+ public:
+  bool operator<(const CompilationType& other) const {
+    return tie() < other.tie();
+  }
+
+  bool operator==(const CompilationType& other) const {
+    return tie() == other.tie();
+  }
+};
+
+std::string to_string(const CompilationType& type);
+
+struct AvailabilityValues {
+  bool future = false;
+  int introduced = 0;
+  int deprecated = 0;
+  int obsoleted = 0;
+
+  bool empty() const {
+    return !(future || introduced || deprecated || obsoleted);
+  }
+
+  bool operator==(const AvailabilityValues& rhs) const {
+    return std::tie(introduced, deprecated, obsoleted) ==
+           std::tie(rhs.introduced, rhs.deprecated, rhs.obsoleted);
+  }
+
+  bool operator!=(const AvailabilityValues& rhs) const {
+    return !(*this == rhs);
+  }
+};
+
+std::string to_string(const AvailabilityValues& av);
+
+struct DeclarationAvailability {
+  AvailabilityValues global_availability;
+  ArchMap<AvailabilityValues> arch_availability;
+
+  bool empty() const {
+    if (!global_availability.empty()) {
+      return false;
+    }
+
+    for (const auto& it : arch_availability) {
+      if (!it.second.empty()) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+  bool operator==(const DeclarationAvailability& rhs) const {
+    return std::tie(global_availability, arch_availability) ==
+           std::tie(rhs.global_availability, rhs.arch_availability);
+  }
+
+  bool operator!=(const DeclarationAvailability& rhs) const {
+    return !(*this == rhs);
+  }
+
+  // Returns false if the availability declarations conflict.
+  bool merge(const DeclarationAvailability& other);
+};
+
+std::string to_string(const DeclarationAvailability& decl_av);
+
+struct FileLocation {
+  unsigned line;
+  unsigned column;
+
+  bool operator<(const FileLocation& rhs) const {
+    return std::tie(line, column) < std::tie(rhs.line, rhs.column);
+  }
+
+  bool operator==(const FileLocation& rhs) const {
+    return std::tie(line, column) == std::tie(rhs.line, rhs.column);
+  }
+};
+
+struct Location {
+  std::string filename;
+  FileLocation start;
+  FileLocation end;
+
+  bool operator<(const Location& rhs) const {
+    return std::tie(filename, start, end) < std::tie(rhs.filename, rhs.start, rhs.end);
+  }
+};
+
+std::string to_string(const Location& loc);
+
+struct Declaration {
+  std::string name;
+  Location location;
+
+  bool is_extern;
+  bool is_definition;
+  bool no_guard;
+  std::map<CompilationType, DeclarationAvailability> availability;
+
+  bool calculateAvailability(DeclarationAvailability* output) const;
+  bool operator<(const Declaration& rhs) const {
+    return location < rhs.location;
+  }
+
+  void dump(const std::string& base_path = "", FILE* out = stdout, unsigned indent = 0) const {
+    std::string indent_str(indent, ' ');
+    fprintf(out, "%s", indent_str.c_str());
+
+    fprintf(out, "%s ", is_extern ? "extern" : "static");
+    fprintf(out, "%s ", is_definition ? "definition" : "declaration");
+    if (no_guard) {
+      fprintf(out, "no_guard ");
+    }
+    fprintf(out, "@ %s:%u:%u", StripPrefix(location.filename, base_path).str().c_str(),
+            location.start.line, location.start.column);
+
+    if (!availability.empty()) {
+      DeclarationAvailability avail;
+
+      fprintf(out, "\n%s  ", indent_str.c_str());
+      if (!calculateAvailability(&avail)) {
+        fprintf(out, "invalid availability\n");
+      } else {
+        fprintf(out, "%s\n", to_string(avail).c_str());
+      }
+    }
+  }
+};
+
+struct Symbol {
+  std::string name;
+  std::map<Location, Declaration> declarations;
+
+  bool calculateAvailability(DeclarationAvailability* output) const;
+  bool hasDeclaration(const CompilationType& type) const;
+
+  bool operator<(const Symbol& rhs) const {
+    return name < rhs.name;
+  }
+
+  bool operator==(const Symbol& rhs) const {
+    return name == rhs.name;
+  }
+
+  void dump(const std::string& base_path = "", FILE* out = stdout) const {
+    DeclarationAvailability availability;
+    bool valid_availability = calculateAvailability(&availability);
+    fprintf(out, "  %s: ", name.c_str());
+
+    if (valid_availability) {
+      fprintf(out, "%s\n", to_string(availability).c_str());
+    } else {
+      fprintf(out, "invalid\n");
+    }
+
+    for (auto& it : declarations) {
+      it.second.dump(base_path, out, 4);
+    }
+  }
+};
+
+class HeaderDatabase {
+  std::mutex mutex;
+
+ public:
+  std::map<std::string, Symbol> symbols;
+
+  void parseAST(CompilationType type, clang::ASTUnit* ast);
+
+  void dump(const std::string& base_path = "", FILE* out = stdout) const {
+    fprintf(out, "HeaderDatabase contains %zu symbols:\n", symbols.size());
+    for (const auto& pair : symbols) {
+      pair.second.dump(base_path, out);
+    }
+  }
+};
diff --git a/tools/versioner/src/Preprocessor.cpp b/tools/versioner/src/Preprocessor.cpp
new file mode 100644
index 0000000..a52ce53
--- /dev/null
+++ b/tools/versioner/src/Preprocessor.cpp
@@ -0,0 +1,526 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Preprocessor.h"
+
+#include <err.h>
+#include <fcntl.h>
+#include <fts.h>
+#include <libgen.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <deque>
+#include <fstream>
+#include <string>
+#include <unordered_map>
+
+#include <llvm/ADT/StringRef.h>
+#include <llvm/ADT/Twine.h>
+#include <llvm/Support/FileSystem.h>
+#include <llvm/Support/Path.h>
+
+#include "Arch.h"
+#include "DeclarationDatabase.h"
+#include "versioner.h"
+
+using namespace std::string_literals;
+
+static DeclarationAvailability calculateRequiredGuard(const Declaration& declaration) {
+  // To avoid redundant macro guards, the availability calculated by this function is the set
+  // difference of 'targets marked-available' from 'targets the declaration is visible in'.
+  // For example, a declaration that is visible always and introduced in 9 would return introduced
+  // in 9, but the same declaration, except only visible in 9+ would return an empty
+  // DeclarationAvailability.
+
+  // This currently only handles __INTRODUCED_IN.
+  // TODO: Do the same for __REMOVED_IN.
+  int global_min_api_visible = 0;
+  ArchMap<int> arch_visibility;
+
+  for (const auto& it : declaration.availability) {
+    const CompilationType& type = it.first;
+
+    if (global_min_api_visible == 0 || global_min_api_visible > type.api_level) {
+      global_min_api_visible = type.api_level;
+    }
+
+    if (arch_visibility[type.arch] == 0 || arch_visibility[type.arch] > type.api_level) {
+      arch_visibility[type.arch] = type.api_level;
+    }
+  }
+
+  DeclarationAvailability decl_av;
+  if (!declaration.calculateAvailability(&decl_av)) {
+    fprintf(stderr, "versioner: failed to calculate availability while preprocessing:\n");
+    declaration.dump("", stderr, 2);
+    exit(1);
+  }
+
+  D("Calculating required guard for %s:\n", declaration.name.c_str());
+  D("  Declaration availability: %s\n", to_string(decl_av).c_str());
+
+  if (verbose) {
+    std::string arch_visibility_str;
+    for (Arch arch : supported_archs) {
+      if (arch_visibility[arch] != 0) {
+        arch_visibility_str += to_string(arch);
+        arch_visibility_str += ": ";
+        arch_visibility_str += std::to_string(arch_visibility[arch]);
+        arch_visibility_str += ", ";
+      }
+    }
+    if (!arch_visibility_str.empty()) {
+      arch_visibility_str.resize(arch_visibility_str.size() - 2);
+    }
+    D("  Declaration visibility: global = %d, arch = %s\n", global_min_api_visible,
+      arch_visibility_str.c_str());
+  }
+
+  DeclarationAvailability result = decl_av;
+  if (result.global_availability.introduced <= global_min_api_visible) {
+    result.global_availability.introduced = 0;
+  }
+
+  for (Arch arch : supported_archs) {
+    if (result.arch_availability[arch].introduced <= arch_visibility[arch]) {
+      result.arch_availability[arch].introduced = 0;
+    }
+  }
+
+  D("  Calculated result: %s\n", to_string(result).c_str());
+  D("\n");
+
+  return result;
+}
+
+static std::deque<std::string> readFileLines(const std::string& path) {
+  std::ifstream is(path.c_str());
+  std::deque<std::string> result;
+  std::string line;
+
+  while (std::getline(is, line)) {
+    result.push_back(std::move(line));
+  }
+
+  return result;
+}
+
+static std::string dirname(const std::string& path) {
+  std::unique_ptr<char, decltype(&free)> path_copy(strdup(path.c_str()), free);
+  return dirname(path_copy.get());
+}
+
+static bool mkdirs(const std::string& path) {
+  struct stat st;
+  if (stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode)) {
+    return true;
+  }
+
+  std::string parent = dirname(path);
+  if (parent == path) {
+    return false;
+  }
+
+  if (!mkdirs(parent)) {
+    return false;
+  }
+
+  if (mkdir(path.c_str(), 0700) != 0) {
+    return false;
+  }
+
+  return true;
+}
+
+static void writeFileLines(const std::string& path, const std::deque<std::string>& lines) {
+  if (!mkdirs(dirname(path))) {
+    err(1, "failed to create directory '%s'", dirname(path).c_str());
+  }
+
+  std::ofstream os(path.c_str(), std::ios_base::out | std::ios_base::trunc);
+
+  for (const std::string& line : lines) {
+    os << line << "\n";
+  }
+}
+
+using GuardMap = std::map<Location, DeclarationAvailability>;
+
+static std::string generateGuardCondition(const DeclarationAvailability& avail) {
+  // Logically orred expressions that constitute the macro guard.
+  std::vector<std::string> expressions;
+  static const std::vector<std::pair<std::string, std::set<Arch>>> arch_sets = {
+    { "", supported_archs },
+    { "!defined(__LP64__)", { Arch::arm, Arch::mips, Arch::x86 } },
+    { "defined(__LP64__)", { Arch::arm64, Arch::mips64, Arch::x86_64 } },
+    { "defined(__mips__)", { Arch::mips, Arch::mips64 } },
+  };
+  std::map<Arch, std::string> individual_archs = {
+    { Arch::arm, "defined(__arm__)" },
+    { Arch::arm64, "defined(__aarch64__)" },
+    { Arch::mips, "defined(__mips__) && !defined(__LP64__)" },
+    { Arch::mips64, "defined(__mips__) && defined(__LP64__)" },
+    { Arch::x86, "defined(__i386__)" },
+    { Arch::x86_64, "defined(__x86_64__)" },
+  };
+
+  auto generate_guard = [](const std::string& arch_expr, int min_version) {
+    if (min_version == 0) {
+      return arch_expr;
+    }
+    return arch_expr + " && __ANDROID_API__ >= " + std::to_string(min_version);
+  };
+
+  D("Generating guard for availability: %s\n", to_string(avail).c_str());
+  if (!avail.global_availability.empty()) {
+    for (Arch arch : supported_archs) {
+      if (!avail.arch_availability[arch].empty()) {
+        errx(1, "attempted to generate guard with global and per-arch values: %s",
+             to_string(avail).c_str());
+      }
+    }
+
+    if (avail.global_availability.introduced == 0) {
+      fprintf(stderr, "warning: attempted to generate guard with empty availability: %s\n",
+              to_string(avail).c_str());
+      return "";
+    }
+
+    if (avail.global_availability.introduced <= 9) {
+      return "";
+    }
+
+    return "__ANDROID_API__ >= "s + std::to_string(avail.global_availability.introduced);
+  }
+
+  for (const auto& it : arch_sets) {
+    const std::string& arch_expr = it.first;
+    const std::set<Arch>& archs = it.second;
+
+    D("  Checking arch set '%s'\n", arch_expr.c_str());
+
+    int version = avail.arch_availability[*it.second.begin()].introduced;
+
+    // Assume that the entire declaration is declared __INTRODUCED_IN_FUTURE if one arch is.
+    bool future = avail.arch_availability[*it.second.begin()].future;
+
+    if (future) {
+      return "__ANDROID_API__ >= __ANDROID_API_FUTURE__";
+    }
+
+    // The maximum min_version of the set.
+    int max_min_version = 0;
+    for (Arch arch : archs) {
+      if (arch_min_api[arch] > max_min_version) {
+        max_min_version = arch_min_api[arch];
+      }
+
+      if (avail.arch_availability[arch].introduced != version) {
+        D("    Skipping arch set, availability for %s doesn't match %s\n",
+          to_string(*it.second.begin()).c_str(), to_string(arch).c_str());
+        goto skip;
+      }
+    }
+
+    // If all of the archs in the set have a min_api that satifies version, elide the check.
+    if (max_min_version >= version) {
+      version = 0;
+    }
+
+    expressions.emplace_back(generate_guard(arch_expr, version));
+
+    D("    Generated expression '%s'\n", expressions.rbegin()->c_str());
+
+    for (Arch arch : archs) {
+      individual_archs.erase(arch);
+    }
+
+  skip:
+    continue;
+  }
+
+  for (const auto& it : individual_archs) {
+    const std::string& arch_expr = it.second;
+    int introduced = avail.arch_availability[it.first].introduced;
+    if (introduced == 0) {
+      expressions.emplace_back(arch_expr);
+    } else {
+      expressions.emplace_back(generate_guard(arch_expr, introduced));
+    }
+  }
+
+  if (expressions.size() == 0) {
+    errx(1, "generated empty guard for availability %s", to_string(avail).c_str());
+  } else if (expressions.size() == 1) {
+    return expressions[0];
+  }
+
+  return "("s + Join(expressions, ") || (") + ")";
+}
+
+// Assumes that nothing crazy is happening (e.g. having the semicolon be in a macro)
+static FileLocation findNextSemicolon(const std::deque<std::string>& lines, FileLocation start) {
+  unsigned current_line = start.line;
+  unsigned current_column = start.column;
+  while (current_line <= lines.size()) {
+    size_t result = lines[current_line - 1].find_first_of(';', current_column - 1);
+
+    if (result != std::string::npos) {
+      FileLocation loc = {
+        .line = current_line,
+        .column = unsigned(result) + 1,
+      };
+
+      return loc;
+    }
+
+    ++current_line;
+    current_column = 0;
+  }
+
+  errx(1, "failed to find semicolon starting from %u:%u", start.line, start.column);
+}
+
+// Merge adjacent blocks with identical guards.
+static void mergeGuards(std::deque<std::string>& file_lines, GuardMap& guard_map) {
+  if (guard_map.size() < 2) {
+    return;
+  }
+
+  auto current = guard_map.begin();
+  auto next = current;
+  ++next;
+
+  while (next != guard_map.end()) {
+    if (current->second != next->second) {
+      ++current;
+      ++next;
+      continue;
+    }
+
+    // Scan from the end of current to the beginning of next.
+    bool in_block_comment = false;
+    bool valid = true;
+
+    FileLocation current_location = current->first.end;
+    FileLocation end_location = next->first.start;
+
+    auto nextLine = [&current_location]() {
+      ++current_location.line;
+      current_location.column = 1;
+    };
+
+    auto nextCol = [&file_lines, &current_location, &nextLine]() {
+      if (current_location.column == file_lines[current_location.column - 1].length()) {
+        nextLine();
+      } else {
+        ++current_location.column;
+      }
+    };
+
+    // The end location will point to the semicolon, which we don't want to read, so skip it.
+    nextCol();
+
+    while (current_location < end_location) {
+      const std::string& line = file_lines[current_location.line - 1];
+      size_t line_index = current_location.column - 1;
+
+      if (in_block_comment) {
+        size_t pos = line.find("*/", line_index);
+        if (pos == std::string::npos) {
+          D("Didn't find block comment terminator, skipping line\n");
+          nextLine();
+          continue;
+        } else {
+          D("Found block comment terminator\n");
+          in_block_comment = false;
+          current_location.column = pos + 2;
+          nextCol();
+          continue;
+        }
+      } else {
+        size_t pos = line.find_first_not_of(" \t", line_index);
+        if (pos == std::string::npos) {
+          nextLine();
+          continue;
+        }
+
+        current_location.column = pos + 1;
+        if (line[pos] != '/') {
+          D("Trailing character '%c' is not a slash: %s\n", line[pos], line.substr(pos).c_str());
+          valid = false;
+          break;
+        }
+
+        nextCol();
+        if (line.length() <= pos + 1) {
+          // Trailing slash at the end of a line?
+          D("Trailing slash at end of line\n");
+          valid = false;
+          break;
+        }
+
+        if (line[pos + 1] == '/') {
+          // C++ style comment
+          nextLine();
+        } else if (line[pos + 1] == '*') {
+          // Block comment
+          nextCol();
+          in_block_comment = true;
+          D("In a block comment\n");
+        } else {
+          // Garbage?
+          D("Unexpected output after /: %s\n", line.substr(pos).c_str());
+          valid = false;
+          break;
+        }
+      }
+    }
+
+    if (!valid) {
+      D("Not merging blocks %s and %s\n", to_string(current->first).c_str(),
+        to_string(next->first).c_str());
+      ++current;
+      ++next;
+      continue;
+    }
+
+    D("Merging blocks %s and %s\n", to_string(current->first).c_str(),
+      to_string(next->first).c_str());
+
+    Location merged = current->first;
+    merged.end = next->first.end;
+
+    DeclarationAvailability avail = current->second;
+
+    guard_map.erase(current);
+    guard_map.erase(next);
+    bool dummy;
+    std::tie(current, dummy) = guard_map.insert(std::make_pair(merged, avail));
+    next = current;
+    ++next;
+  }
+}
+
+static void rewriteFile(const std::string& output_path, std::deque<std::string>& file_lines,
+                        const GuardMap& guard_map) {
+  for (auto it = guard_map.rbegin(); it != guard_map.rend(); ++it) {
+    const Location& loc = it->first;
+    const DeclarationAvailability& avail = it->second;
+
+    std::string condition = generateGuardCondition(avail);
+    if (condition.empty()) {
+      continue;
+    }
+
+    std::string prologue = "\n#if "s + condition + "\n";
+    std::string epilogue = "\n#endif /* " + condition + " */\n";
+
+    file_lines[loc.end.line - 1].insert(loc.end.column, epilogue);
+    file_lines[loc.start.line - 1].insert(loc.start.column - 1, prologue);
+  }
+
+  printf("Preprocessing %s...\n", output_path.c_str());
+  writeFileLines(output_path, file_lines);
+}
+
+bool preprocessHeaders(const std::string& dst_dir, const std::string& src_dir,
+                       HeaderDatabase* database) {
+  std::unordered_map<std::string, GuardMap> guards;
+  std::unordered_map<std::string, std::deque<std::string>> file_lines;
+
+  for (const auto& symbol_it : database->symbols) {
+    const Symbol& symbol = symbol_it.second;
+
+    for (const auto& decl_it : symbol.declarations) {
+      const Location& location = decl_it.first;
+      const Declaration& decl = decl_it.second;
+
+      if (decl.no_guard) {
+        // No guard required.
+        continue;
+      }
+
+      DeclarationAvailability macro_guard = calculateRequiredGuard(decl);
+      if (!macro_guard.empty()) {
+        guards[location.filename][location] = macro_guard;
+      }
+    }
+  }
+
+  // Copy over the original headers before preprocessing.
+  char* fts_paths[2] = { const_cast<char*>(src_dir.c_str()), nullptr };
+  FTS* fts = fts_open(fts_paths, FTS_LOGICAL, nullptr);
+  while (FTSENT* ent = fts_read(fts)) {
+    llvm::StringRef path = ent->fts_path;
+    if (!path.startswith(src_dir)) {
+      err(1, "path '%s' doesn't start with source dir '%s'", ent->fts_path, src_dir.c_str());
+    }
+
+    if (ent->fts_info != FTS_F) {
+      continue;
+    }
+
+    std::string rel_path = path.substr(src_dir.length() + 1);
+    std::string dst_path = dst_dir + "/" + rel_path;
+    llvm::StringRef parent_path = llvm::sys::path::parent_path(dst_path);
+    if (llvm::sys::fs::create_directories(parent_path)) {
+      errx(1, "failed to ensure existence of directory '%s'", parent_path.str().c_str());
+    }
+    if (llvm::sys::fs::copy_file(path, dst_path)) {
+      errx(1, "failed to copy '%s/%s' to '%s'", src_dir.c_str(), path.str().c_str(),
+           dst_path.c_str());
+    }
+  }
+  fts_close(fts);
+
+  for (const auto& file_it : guards) {
+    file_lines[file_it.first] = readFileLines(file_it.first);
+  }
+
+  for (auto& file_it : guards) {
+    llvm::StringRef file_path = file_it.first;
+    GuardMap& orig_guard_map = file_it.second;
+
+    // The end positions given to us are the end of the declaration, which is some point before the
+    // semicolon. Fix up the end positions by scanning for the next semicolon.
+    GuardMap guard_map;
+    for (const auto& it : orig_guard_map) {
+      Location loc = it.first;
+      loc.end = findNextSemicolon(file_lines[file_path], loc.end);
+      guard_map[loc] = it.second;
+    }
+
+    // TODO: Make sure that the Locations don't overlap.
+    // TODO: Merge adjacent non-identical guards.
+    mergeGuards(file_lines[file_path], guard_map);
+
+    if (!file_path.startswith(src_dir)) {
+      errx(1, "input file %s is not in %s\n", file_path.str().c_str(), src_dir.c_str());
+    }
+
+    // rel_path has a leading slash.
+    llvm::StringRef rel_path = file_path.substr(src_dir.size(), file_path.size() - src_dir.size());
+    std::string output_path = (llvm::Twine(dst_dir) + rel_path).str();
+
+    rewriteFile(output_path, file_lines[file_path], guard_map);
+  }
+
+  return true;
+}
diff --git a/tools/versioner/src/Preprocessor.h b/tools/versioner/src/Preprocessor.h
new file mode 100644
index 0000000..2a17534
--- /dev/null
+++ b/tools/versioner/src/Preprocessor.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <string>
+
+class HeaderDatabase;
+
+bool preprocessHeaders(const std::string& preprocessor_output_path, const std::string& source_dir,
+                       HeaderDatabase* database);
diff --git a/tools/versioner/src/SymbolDatabase.cpp b/tools/versioner/src/SymbolDatabase.cpp
new file mode 100644
index 0000000..90c0c9f
--- /dev/null
+++ b/tools/versioner/src/SymbolDatabase.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SymbolDatabase.h"
+
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <fstream>
+#include <streambuf>
+#include <string>
+#include <unordered_set>
+
+#include <llvm/ADT/SmallVector.h>
+#include <llvm/ADT/StringRef.h>
+#include <llvm/Object/Binary.h>
+#include <llvm/Object/ELFObjectFile.h>
+
+#include "versioner.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+std::unordered_set<std::string> getSymbols(const std::string& filename) {
+  std::unordered_set<std::string> result;
+  auto binaryOrError = createBinary(filename);
+  if (!binaryOrError) {
+    errx(1, "failed to open library at %s: %s\n", filename.c_str(),
+         llvm::toString(binaryOrError.takeError()).c_str());
+  }
+
+  ELFObjectFileBase* elf = dyn_cast_or_null<ELFObjectFileBase>(binaryOrError.get().getBinary());
+  if (!elf) {
+    errx(1, "failed to parse %s as ELF", filename.c_str());
+  }
+
+  for (const ELFSymbolRef symbol : elf->getDynamicSymbolIterators()) {
+    Expected<StringRef> symbolNameOrError = symbol.getName();
+
+    if (!symbolNameOrError) {
+      errx(1, "failed to get symbol name for symbol in %s: %s", filename.c_str(),
+           llvm::toString(symbolNameOrError.takeError()).c_str());
+    }
+
+    result.insert(symbolNameOrError.get().str());
+  }
+
+  return result;
+}
+
+// The NDK platforms are built by copying the platform directories on top of
+// each other to build each successive API version. Thus, we need to walk
+// backwards to find each desired file.
+static std::string readPlatformFile(const CompilationType& type, llvm::StringRef platform_dir,
+                                    const std::string& filename, bool required) {
+  int api_level = type.api_level;
+  std::ifstream stream;
+  while (api_level >= arch_min_api[type.arch]) {
+    if (supported_levels.count(api_level) == 0) {
+      --api_level;
+      continue;
+    }
+
+    std::string path = std::string(platform_dir) + "/android-" + std::to_string(api_level) +
+                       "/arch-" + to_string(type.arch) + "/symbols/" + filename;
+
+    stream = std::ifstream(path);
+    if (stream) {
+      return std::string(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>());
+    }
+
+    --api_level;
+  }
+
+  if (required) {
+    errx(1, "failed to find platform file '%s' for %s", filename.c_str(), to_string(type).c_str());
+  }
+
+  return std::string();
+}
+
+static std::map<std::string, NdkSymbolType> parsePlatform(const CompilationType& type,
+                                                          const std::string& platform_dir) {
+  std::map<std::string, NdkSymbolType> result;
+  std::map<std::string, bool /*required*/> wanted_files = {
+    { "libc.so.functions.txt", true },
+    { "libc.so.variables.txt", false },
+    { "libdl.so.functions.txt", false },
+    { "libm.so.functions.txt", false },
+    { "libm.so.variables.txt", false },
+  };
+
+  for (const auto& pair : wanted_files) {
+    llvm::StringRef file = pair.first;
+    bool required = pair.second;
+    NdkSymbolType symbol_type;
+    if (file.endswith(".functions.txt")) {
+      symbol_type = NdkSymbolType::function;
+    } else if (file.endswith(".variables.txt")) {
+      symbol_type = NdkSymbolType::variable;
+    } else {
+      errx(1, "internal error: unexpected platform filename '%s'\n", file.str().c_str());
+    }
+
+    std::string platform_file = readPlatformFile(type, platform_dir, file, required);
+    if (platform_file.empty()) {
+      continue;
+    }
+
+    llvm::SmallVector<llvm::StringRef, 0> symbols;
+    llvm::StringRef(platform_file).split(symbols, "\n");
+
+    for (llvm::StringRef symbol_name : symbols) {
+      if (symbol_name.empty()) {
+        continue;
+      }
+
+      if (result.count(symbol_name) != 0) {
+        if (verbose) {
+          printf("duplicated symbol '%s' in '%s'\n", symbol_name.str().c_str(), file.str().c_str());
+        }
+      }
+
+      result[symbol_name] = symbol_type;
+    }
+  }
+
+  return result;
+}
+
+NdkSymbolDatabase parsePlatforms(const std::set<CompilationType>& types,
+                                 const std::string& platform_dir) {
+  std::map<std::string, std::map<CompilationType, NdkSymbolType>> result;
+  for (const CompilationType& type : types) {
+    std::map<std::string, NdkSymbolType> symbols = parsePlatform(type, platform_dir);
+    for (const auto& it : symbols) {
+      result[it.first][type] = it.second;
+    }
+  }
+
+  return result;
+}
diff --git a/tools/versioner/src/SymbolDatabase.h b/tools/versioner/src/SymbolDatabase.h
new file mode 100644
index 0000000..09948f5
--- /dev/null
+++ b/tools/versioner/src/SymbolDatabase.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <map>
+#include <set>
+#include <string>
+#include <unordered_set>
+
+#include "DeclarationDatabase.h"
+
+using LibrarySymbolDatabase = std::unordered_set<std::string>;
+std::unordered_set<std::string> getSymbols(const std::string& filename);
+
+enum class NdkSymbolType {
+  function,
+  variable,
+};
+
+using NdkSymbolDatabase = std::map<std::string, std::map<CompilationType, NdkSymbolType>>;
+NdkSymbolDatabase parsePlatforms(const std::set<CompilationType>& types,
+                                 const std::string& platform_dir);
diff --git a/tools/versioner/src/Utils.cpp b/tools/versioner/src/Utils.cpp
new file mode 100644
index 0000000..dd087a5
--- /dev/null
+++ b/tools/versioner/src/Utils.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Utils.h"
+
+#include <err.h>
+#include <fts.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "DeclarationDatabase.h"
+
+std::string getWorkingDir() {
+  char buf[PATH_MAX];
+  if (!getcwd(buf, sizeof(buf))) {
+    err(1, "getcwd failed");
+  }
+  return buf;
+}
+
+std::vector<std::string> collectFiles(const std::string& directory) {
+  std::vector<std::string> files;
+
+  char* dir_argv[2] = { const_cast<char*>(directory.c_str()), nullptr };
+  FTS* fts = fts_open(dir_argv, FTS_LOGICAL | FTS_NOCHDIR, nullptr);
+
+  if (!fts) {
+    err(1, "failed to open directory '%s'", directory.c_str());
+  }
+
+  FTSENT* ent;
+  while ((ent = fts_read(fts))) {
+    if (ent->fts_info & (FTS_D | FTS_DP)) {
+      continue;
+    }
+
+    files.push_back(ent->fts_path);
+  }
+
+  fts_close(fts);
+  return files;
+}
+
+llvm::StringRef StripPrefix(llvm::StringRef string, llvm::StringRef prefix) {
+  if (string.startswith(prefix)) {
+    return string.drop_front(prefix.size());
+  }
+  return string;
+}
diff --git a/tools/versioner/src/Utils.h b/tools/versioner/src/Utils.h
new file mode 100644
index 0000000..d49fc88
--- /dev/null
+++ b/tools/versioner/src/Utils.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include <llvm/ADT/StringRef.h>
+
+std::string getWorkingDir();
+std::vector<std::string> collectFiles(const std::string& directory);
+
+static __attribute__((unused)) std::string to_string(const char* c) {
+  return c;
+}
+
+static __attribute__((unused)) const std::string& to_string(const std::string& str) {
+  return str;
+}
+
+template <typename Collection>
+static std::string Join(Collection c, const std::string& delimiter = ", ") {
+  std::string result;
+  for (const auto& item : c) {
+    using namespace std;
+    result.append(to_string(item));
+    result.append(delimiter);
+  }
+  if (!result.empty()) {
+    result.resize(result.length() - delimiter.length());
+  }
+  return result;
+}
+
+llvm::StringRef StripPrefix(llvm::StringRef string, llvm::StringRef prefix);
diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp
new file mode 100644
index 0000000..2f0656c
--- /dev/null
+++ b/tools/versioner/src/versioner.cpp
@@ -0,0 +1,674 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dirent.h>
+#include <err.h>
+#include <limits.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <atomic>
+#include <iostream>
+#include <map>
+#include <memory>
+#include <set>
+#include <sstream>
+#include <string>
+#include <thread>
+#include <unordered_map>
+#include <vector>
+
+#include <clang/Frontend/TextDiagnosticPrinter.h>
+#include <clang/Tooling/Tooling.h>
+#include <llvm/ADT/StringRef.h>
+
+#include "Arch.h"
+#include "DeclarationDatabase.h"
+#include "Preprocessor.h"
+#include "SymbolDatabase.h"
+#include "Utils.h"
+#include "versioner.h"
+
+using namespace std::string_literals;
+using namespace clang;
+using namespace clang::tooling;
+
+bool verbose;
+static bool add_include;
+
+class HeaderCompilationDatabase : public CompilationDatabase {
+  CompilationType type;
+  std::string cwd;
+  std::vector<std::string> headers;
+  std::vector<std::string> include_dirs;
+
+ public:
+  HeaderCompilationDatabase(CompilationType type, std::string cwd, std::vector<std::string> headers,
+                            std::vector<std::string> include_dirs)
+      : type(type),
+        cwd(std::move(cwd)),
+        headers(std::move(headers)),
+        include_dirs(std::move(include_dirs)) {
+  }
+
+  CompileCommand generateCompileCommand(const std::string& filename) const {
+    std::vector<std::string> command = { "clang-tool", filename, "-nostdlibinc" };
+    for (const auto& dir : include_dirs) {
+      command.push_back("-isystem");
+      command.push_back(dir);
+    }
+    command.push_back("-std=c11");
+    command.push_back("-DANDROID");
+    command.push_back("-D__ANDROID_API__="s + std::to_string(type.api_level));
+    command.push_back("-D_FORTIFY_SOURCE=2");
+    command.push_back("-D_GNU_SOURCE");
+    command.push_back("-Wall");
+    command.push_back("-Wextra");
+    command.push_back("-Werror");
+    command.push_back("-Wundef");
+    command.push_back("-Wno-unused-macros");
+    command.push_back("-Wno-unused-function");
+    command.push_back("-Wno-unused-variable");
+    command.push_back("-Wno-unknown-attributes");
+    command.push_back("-Wno-pragma-once-outside-header");
+    command.push_back("-target");
+    command.push_back(arch_targets[type.arch]);
+
+    if (add_include) {
+      const char* top = getenv("ANDROID_BUILD_TOP");
+      std::string header_path = to_string(top) + "/bionic/libc/include/android/versioning.h";
+      command.push_back("-include");
+      command.push_back(std::move(header_path));
+    }
+
+    command.push_back("-D_FILE_OFFSET_BITS="s + std::to_string(type.file_offset_bits));
+
+    return CompileCommand(cwd, filename, command);
+  }
+
+  std::vector<CompileCommand> getAllCompileCommands() const override {
+    std::vector<CompileCommand> commands;
+    for (const std::string& file : headers) {
+      commands.push_back(generateCompileCommand(file));
+    }
+    return commands;
+  }
+
+  std::vector<CompileCommand> getCompileCommands(StringRef file) const override {
+    std::vector<CompileCommand> commands;
+    commands.push_back(generateCompileCommand(file));
+    return commands;
+  }
+
+  std::vector<std::string> getAllFiles() const override {
+    return headers;
+  }
+};
+
+struct CompilationRequirements {
+  std::vector<std::string> headers;
+  std::vector<std::string> dependencies;
+};
+
+static CompilationRequirements collectRequirements(const Arch& arch, const std::string& header_dir,
+                                                   const std::string& dependency_dir) {
+  std::vector<std::string> headers = collectFiles(header_dir);
+
+  std::vector<std::string> dependencies = { header_dir };
+  if (!dependency_dir.empty()) {
+    auto collect_children = [&dependencies](const std::string& dir_path) {
+      DIR* dir = opendir(dir_path.c_str());
+      if (!dir) {
+        err(1, "failed to open dependency directory '%s'", dir_path.c_str());
+      }
+
+      struct dirent* dent;
+      while ((dent = readdir(dir))) {
+        if (dent->d_name[0] == '.') {
+          continue;
+        }
+
+        // TODO: Resolve symlinks.
+        std::string dependency = dir_path + "/" + dent->d_name;
+
+        struct stat st;
+        if (stat(dependency.c_str(), &st) != 0) {
+          err(1, "failed to stat dependency '%s'", dependency.c_str());
+        }
+
+        if (!S_ISDIR(st.st_mode)) {
+          errx(1, "'%s' is not a directory", dependency.c_str());
+        }
+
+        dependencies.push_back(dependency);
+      }
+
+      closedir(dir);
+    };
+
+    collect_children(dependency_dir + "/common");
+    collect_children(dependency_dir + "/" + to_string(arch));
+  }
+
+  auto new_end = std::remove_if(headers.begin(), headers.end(), [&arch](llvm::StringRef header) {
+    for (const auto& it : header_blacklist) {
+      if (it.second.find(arch) == it.second.end()) {
+        continue;
+      }
+
+      if (header.endswith("/" + it.first)) {
+        return true;
+      }
+    }
+    return false;
+  });
+
+  headers.erase(new_end, headers.end());
+
+  CompilationRequirements result = { .headers = headers, .dependencies = dependencies };
+  return result;
+}
+
+static std::set<CompilationType> generateCompilationTypes(const std::set<Arch> selected_architectures,
+                                                          const std::set<int>& selected_levels) {
+  std::set<CompilationType> result;
+  for (const auto& arch : selected_architectures) {
+    int min_api = arch_min_api[arch];
+    for (int api_level : selected_levels) {
+      if (api_level < min_api) {
+        continue;
+      }
+
+      for (int file_offset_bits : { 32, 64 }) {
+        CompilationType type = {
+          .arch = arch, .api_level = api_level, .file_offset_bits = file_offset_bits
+        };
+        result.insert(type);
+      }
+    }
+  }
+  return result;
+}
+
+static std::unique_ptr<HeaderDatabase> compileHeaders(const std::set<CompilationType>& types,
+                                                      const std::string& header_dir,
+                                                      const std::string& dependency_dir,
+                                                      bool* failed) {
+  constexpr size_t thread_count = 8;
+  size_t threads_created = 0;
+  std::mutex mutex;
+  std::vector<std::thread> threads(thread_count);
+
+  std::map<CompilationType, HeaderDatabase> header_databases;
+  std::unordered_map<Arch, CompilationRequirements> requirements;
+
+  std::string cwd = getWorkingDir();
+  bool errors = false;
+
+  for (const auto& type : types) {
+    if (requirements.count(type.arch) == 0) {
+      requirements[type.arch] = collectRequirements(type.arch, header_dir, dependency_dir);
+    }
+  }
+
+  auto result = std::make_unique<HeaderDatabase>();
+  for (const auto& type : types) {
+    size_t thread_id = threads_created++;
+    if (thread_id >= thread_count) {
+      thread_id = thread_id % thread_count;
+      threads[thread_id].join();
+    }
+
+    threads[thread_id] = std::thread(
+        [&](CompilationType type) {
+          const auto& req = requirements[type.arch];
+
+          HeaderCompilationDatabase compilation_database(type, cwd, req.headers, req.dependencies);
+
+          ClangTool tool(compilation_database, req.headers);
+
+          clang::DiagnosticOptions diagnostic_options;
+          std::vector<std::unique_ptr<ASTUnit>> asts;
+          tool.buildASTs(asts);
+          for (const auto& ast : asts) {
+            clang::DiagnosticsEngine& diagnostics_engine = ast->getDiagnostics();
+            if (diagnostics_engine.getNumWarnings() || diagnostics_engine.hasErrorOccurred()) {
+              std::unique_lock<std::mutex> l(mutex);
+              errors = true;
+              printf("versioner: compilation failure for %s in %s\n", to_string(type).c_str(),
+                     ast->getOriginalSourceFileName().str().c_str());
+            }
+
+            result->parseAST(type, ast.get());
+          }
+        },
+        type);
+  }
+
+  if (threads_created < thread_count) {
+    threads.resize(threads_created);
+  }
+
+  for (auto& thread : threads) {
+    thread.join();
+  }
+
+  if (errors) {
+    printf("versioner: compilation generated warnings or errors\n");
+    *failed = errors;
+  }
+
+  return result;
+}
+
+static std::set<CompilationType> getCompilationTypes(const Declaration* decl) {
+  std::set<CompilationType> result;
+  for (const auto& it : decl->availability) {
+    result.insert(it.first);
+  }
+  return result;
+}
+
+template<typename T>
+static std::vector<T> Intersection(const std::set<T>& a, const std::set<T>& b) {
+  std::vector<T> intersection;
+  std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(intersection));
+  return intersection;
+}
+
+// Perform a sanity check on a symbol's declarations, enforcing the following invariants:
+//   1. At most one inline definition of the function exists.
+//   2. All of the availability declarations for a symbol are compatible.
+//      If a function is declared as an inline before a certain version, the inline definition
+//      should have no version tag.
+//   3. Each availability type must only be present globally or on a per-arch basis.
+//      (e.g. __INTRODUCED_IN_ARM(9) __INTRODUCED_IN_X86(10) __DEPRECATED_IN(11) is fine,
+//      but not __INTRODUCED_IN(9) __INTRODUCED_IN_X86(10))
+static bool checkSymbol(const Symbol& symbol) {
+  std::string cwd = getWorkingDir() + "/";
+
+  std::unordered_map<const Declaration*, std::set<CompilationType>> inline_definitions;
+  for (const auto& decl_it : symbol.declarations) {
+    const Declaration* decl = &decl_it.second;
+    if (decl->is_definition) {
+      std::set<CompilationType> compilation_types = getCompilationTypes(decl);
+      for (const auto& inline_def_it : inline_definitions) {
+        auto intersection = Intersection(compilation_types, inline_def_it.second);
+        if (!intersection.empty()) {
+          fprintf(stderr, "versioner: conflicting inline definitions:\n");
+          fprintf(stderr, "  declarations visible in: %s\n", Join(intersection, ", ").c_str());
+          decl->dump(cwd, stderr, 4);
+          inline_def_it.first->dump(cwd, stderr, 4);
+          return false;
+        }
+      }
+
+      inline_definitions[decl] = std::move(compilation_types);
+    }
+
+    DeclarationAvailability availability;
+    if (!decl->calculateAvailability(&availability)) {
+      fprintf(stderr, "versioner: failed to calculate availability for declaration:\n");
+      decl->dump(cwd, stderr, 2);
+      return false;
+    }
+
+    if (decl->is_definition && !availability.empty()) {
+      fprintf(stderr, "versioner: inline definition has non-empty versioning information:\n");
+      decl->dump(cwd, stderr, 2);
+      return false;
+    }
+  }
+
+  DeclarationAvailability availability;
+  if (!symbol.calculateAvailability(&availability)) {
+    fprintf(stderr, "versioner: inconsistent availability for symbol '%s'\n", symbol.name.c_str());
+    symbol.dump(cwd);
+    return false;
+  }
+
+  // TODO: Check invariant #3.
+  return true;
+}
+
+static bool sanityCheck(const HeaderDatabase* database) {
+  bool error = false;
+  std::string cwd = getWorkingDir() + "/";
+
+  for (const auto& symbol_it : database->symbols) {
+    if (!checkSymbol(symbol_it.second)) {
+      error = true;
+    }
+  }
+  return !error;
+}
+
+// Check that our symbol availability declarations match the actual NDK
+// platform symbol availability.
+static bool checkVersions(const std::set<CompilationType>& types,
+                          const HeaderDatabase* header_database,
+                          const NdkSymbolDatabase& symbol_database) {
+  std::string cwd = getWorkingDir() + "/";
+  bool failed = false;
+
+  std::map<Arch, std::set<CompilationType>> arch_types;
+  for (const CompilationType& type : types) {
+    arch_types[type.arch].insert(type);
+  }
+
+  std::set<std::string> completely_unavailable;
+  std::map<std::string, std::set<CompilationType>> missing_availability;
+  std::map<std::string, std::set<CompilationType>> extra_availability;
+
+  for (const auto& symbol_it : header_database->symbols) {
+    const auto& symbol_name = symbol_it.first;
+    DeclarationAvailability symbol_availability;
+
+    if (!symbol_it.second.calculateAvailability(&symbol_availability)) {
+      errx(1, "failed to calculate symbol availability");
+    }
+
+    const auto platform_availability_it = symbol_database.find(symbol_name);
+    if (platform_availability_it == symbol_database.end()) {
+      completely_unavailable.insert(symbol_name);
+      continue;
+    }
+
+    const auto& platform_availability = platform_availability_it->second;
+
+    for (const CompilationType& type : types) {
+      bool should_be_available = true;
+      const auto& global_availability = symbol_availability.global_availability;
+      const auto& arch_availability = symbol_availability.arch_availability[type.arch];
+      if (global_availability.introduced != 0 && global_availability.introduced > type.api_level) {
+        should_be_available = false;
+      }
+
+      if (arch_availability.introduced != 0 && arch_availability.introduced > type.api_level) {
+        should_be_available = false;
+      }
+
+      if (global_availability.obsoleted != 0 && global_availability.obsoleted <= type.api_level) {
+        should_be_available = false;
+      }
+
+      if (arch_availability.obsoleted != 0 && arch_availability.obsoleted <= type.api_level) {
+        should_be_available = false;
+      }
+
+      if (arch_availability.future) {
+        continue;
+      }
+
+      // The function declaration might be (validly) missing for the given CompilationType.
+      if (!symbol_it.second.hasDeclaration(type)) {
+        should_be_available = false;
+      }
+
+      bool is_available = platform_availability.count(type);
+
+      if (should_be_available != is_available) {
+        if (is_available) {
+          extra_availability[symbol_name].insert(type);
+        } else {
+          missing_availability[symbol_name].insert(type);
+        }
+      }
+    }
+  }
+
+  for (const auto& it : symbol_database) {
+    const std::string& symbol_name = it.first;
+
+    bool symbol_error = false;
+    auto missing_it = missing_availability.find(symbol_name);
+    if (missing_it != missing_availability.end()) {
+      printf("%s: declaration marked available but symbol missing in [%s]\n", symbol_name.c_str(),
+             Join(missing_it->second, ", ").c_str());
+      symbol_error = true;
+      failed = true;
+    }
+
+    if (verbose) {
+      auto extra_it = extra_availability.find(symbol_name);
+      if (extra_it != extra_availability.end()) {
+        printf("%s: declaration marked unavailable but symbol available in [%s]\n",
+               symbol_name.c_str(), Join(extra_it->second, ", ").c_str());
+        symbol_error = true;
+        failed = true;
+      }
+    }
+
+    if (symbol_error) {
+      auto symbol_it = header_database->symbols.find(symbol_name);
+      if (symbol_it == header_database->symbols.end()) {
+        errx(1, "failed to find symbol in header database");
+      }
+      symbol_it->second.dump(cwd);
+    }
+  }
+
+  // TODO: Verify that function/variable declarations are actually function/variable symbols.
+  return !failed;
+}
+
+static void usage(bool help = false) {
+  fprintf(stderr, "Usage: versioner [OPTION]... [HEADER_PATH] [DEPS_PATH]\n");
+  if (!help) {
+    printf("Try 'versioner -h' for more information.\n");
+    exit(1);
+  } else {
+    fprintf(stderr, "Version headers at HEADER_PATH, with DEPS_PATH/ARCH/* on the include path\n");
+    fprintf(stderr, "Autodetects paths if HEADER_PATH and DEPS_PATH are not specified\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, "Target specification (defaults to all):\n");
+    fprintf(stderr, "  -a API_LEVEL\tbuild with specified API level (can be repeated)\n");
+    fprintf(stderr, "    \t\tvalid levels are %s\n", Join(supported_levels).c_str());
+    fprintf(stderr, "  -r ARCH\tbuild with specified architecture (can be repeated)\n");
+    fprintf(stderr, "    \t\tvalid architectures are %s\n", Join(supported_archs).c_str());
+    fprintf(stderr, "\n");
+    fprintf(stderr, "Validation:\n");
+    fprintf(stderr, "  -p PATH\tcompare against NDK platform at PATH\n");
+    fprintf(stderr, "  -v\t\tenable verbose warnings\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, "Preprocessing:\n");
+    fprintf(stderr, "  -o PATH\tpreprocess header files and emit them at PATH\n");
+    fprintf(stderr, "  -f\tpreprocess header files even if validation fails\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, "Miscellaneous:\n");
+    fprintf(stderr, "  -d\t\tdump function availability\n");
+    fprintf(stderr, "  -h\t\tdisplay this message\n");
+    exit(0);
+  }
+}
+
+int main(int argc, char** argv) {
+  std::string cwd = getWorkingDir() + "/";
+  bool default_args = true;
+  std::string platform_dir;
+  std::set<Arch> selected_architectures;
+  std::set<int> selected_levels;
+  bool dump = false;
+  std::string preprocessor_output_path;
+  bool force = false;
+
+  int c;
+  while ((c = getopt(argc, argv, "a:r:p:vo:fdhi")) != -1) {
+    default_args = false;
+    switch (c) {
+      case 'a': {
+        char* end;
+        int api_level = strtol(optarg, &end, 10);
+        if (end == optarg || strlen(end) > 0) {
+          usage();
+        }
+
+        if (supported_levels.count(api_level) == 0) {
+          errx(1, "unsupported API level %d", api_level);
+        }
+
+        selected_levels.insert(api_level);
+        break;
+      }
+
+      case 'r': {
+        Arch arch = arch_from_string(optarg);
+        selected_architectures.insert(arch);
+        break;
+      }
+
+      case 'p': {
+        if (!platform_dir.empty()) {
+          usage();
+        }
+
+        platform_dir = optarg;
+
+        if (platform_dir.empty()) {
+          usage();
+        }
+
+        struct stat st;
+        if (stat(platform_dir.c_str(), &st) != 0) {
+          err(1, "failed to stat platform directory '%s'", platform_dir.c_str());
+        }
+        if (!S_ISDIR(st.st_mode)) {
+          errx(1, "'%s' is not a directory", optarg);
+        }
+        break;
+      }
+
+      case 'v':
+        verbose = true;
+        break;
+
+      case 'o':
+        if (!preprocessor_output_path.empty()) {
+          usage();
+        }
+        preprocessor_output_path = optarg;
+        if (preprocessor_output_path.empty()) {
+          usage();
+        }
+        break;
+
+      case 'f':
+        force = true;
+        break;
+
+      case 'd':
+        dump = true;
+        break;
+
+      case 'h':
+        usage(true);
+        break;
+
+      case 'i':
+        // Secret option for tests to -include <android/versioning.h>.
+        add_include = true;
+        break;
+
+      default:
+        usage();
+        break;
+    }
+  }
+
+  if (argc - optind > 2 || optind > argc) {
+    usage();
+  }
+
+  std::string header_dir;
+  std::string dependency_dir;
+
+  const char* top = getenv("ANDROID_BUILD_TOP");
+  if (!top && (optind == argc || add_include)) {
+    fprintf(stderr, "versioner: failed to autodetect bionic paths. Is ANDROID_BUILD_TOP set?\n");
+    usage();
+  }
+
+  if (optind == argc) {
+    // Neither HEADER_PATH nor DEPS_PATH were specified, so try to figure them out.
+    std::string versioner_dir = to_string(top) + "/bionic/tools/versioner";
+    header_dir = versioner_dir + "/current";
+    dependency_dir = versioner_dir + "/dependencies";
+    if (platform_dir.empty()) {
+      platform_dir = versioner_dir + "/platforms";
+    }
+  } else {
+    // Intentional leak.
+    header_dir = realpath(argv[optind], nullptr);
+
+    if (argc - optind == 2) {
+      dependency_dir = argv[optind + 1];
+    }
+  }
+
+  if (selected_levels.empty()) {
+    selected_levels = supported_levels;
+  }
+
+  if (selected_architectures.empty()) {
+    selected_architectures = supported_archs;
+  }
+
+
+  struct stat st;
+  if (stat(header_dir.c_str(), &st) != 0) {
+    err(1, "failed to stat '%s'", header_dir.c_str());
+  } else if (!S_ISDIR(st.st_mode)) {
+    errx(1, "'%s' is not a directory", header_dir.c_str());
+  }
+
+  std::set<CompilationType> compilation_types;
+  NdkSymbolDatabase symbol_database;
+
+  compilation_types = generateCompilationTypes(selected_architectures, selected_levels);
+
+  // Do this before compiling so that we can early exit if the platforms don't match what we
+  // expect.
+  if (!platform_dir.empty()) {
+    symbol_database = parsePlatforms(compilation_types, platform_dir);
+  }
+
+  bool failed = false;
+  std::unique_ptr<HeaderDatabase> declaration_database =
+      compileHeaders(compilation_types, header_dir, dependency_dir, &failed);
+
+  if (dump) {
+    declaration_database->dump(header_dir + "/");
+  } else {
+    if (!sanityCheck(declaration_database.get())) {
+      printf("versioner: sanity check failed\n");
+      failed = true;
+    }
+
+    if (!platform_dir.empty()) {
+      if (!checkVersions(compilation_types, declaration_database.get(), symbol_database)) {
+        printf("versioner: version check failed\n");
+        failed = true;
+      }
+    }
+  }
+
+  if (!preprocessor_output_path.empty() && (force || !failed)) {
+    failed = !preprocessHeaders(preprocessor_output_path, header_dir, declaration_database.get());
+  }
+  return failed;
+}
diff --git a/tools/versioner/src/versioner.h b/tools/versioner/src/versioner.h
new file mode 100644
index 0000000..9547f2c
--- /dev/null
+++ b/tools/versioner/src/versioner.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <map>
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+
+extern bool verbose;
+
+#define D(...)             \
+  do {                     \
+    if (verbose) {         \
+      printf(__VA_ARGS__); \
+    }                      \
+  } while (0)
+
+static const std::unordered_map<std::string, std::set<Arch>> header_blacklist = {
+  // Internal header.
+  { "sys/_system_properties.h", supported_archs },
+
+  // time64.h #errors when included on LP64 archs.
+  { "time64.h", { Arch::arm64, Arch::mips64, Arch::x86_64 } },
+};
+
+static const std::unordered_set<std::string> missing_symbol_whitelist = {
+  // atexit comes from crtbegin.
+  "atexit",
+};
diff --git a/tools/versioner/tests/.gitignore b/tools/versioner/tests/.gitignore
new file mode 100644
index 0000000..89f9ac0
--- /dev/null
+++ b/tools/versioner/tests/.gitignore
@@ -0,0 +1 @@
+out/
diff --git a/tools/versioner/tests/arch_specific/headers/foo.h b/tools/versioner/tests/arch_specific/headers/foo.h
new file mode 100644
index 0000000..34035b4
--- /dev/null
+++ b/tools/versioner/tests/arch_specific/headers/foo.h
@@ -0,0 +1,5 @@
+int foo();
+
+#if defined(__i386__)
+int bar();
+#endif
diff --git a/tools/versioner/tests/arch_specific/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/arch_specific/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/arch_specific/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/arch_specific/platforms/android-9/arch-x86/symbols/libc.so.functions.txt b/tools/versioner/tests/arch_specific/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..3bd1f0e
--- /dev/null
+++ b/tools/versioner/tests/arch_specific/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
@@ -0,0 +1,2 @@
+foo
+bar
diff --git a/tools/versioner/tests/arch_specific/run.sh b/tools/versioner/tests/arch_specific/run.sh
new file mode 100644
index 0000000..f0d95ae
--- /dev/null
+++ b/tools/versioner/tests/arch_specific/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -r x86 -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/compilation_error/expected_fail b/tools/versioner/tests/compilation_error/expected_fail
new file mode 100644
index 0000000..f18b625
--- /dev/null
+++ b/tools/versioner/tests/compilation_error/expected_fail
@@ -0,0 +1 @@
+versioner: compilation generated warnings or errors
diff --git a/tools/versioner/tests/compilation_error/headers/foo.h b/tools/versioner/tests/compilation_error/headers/foo.h
new file mode 100644
index 0000000..c8c1473
--- /dev/null
+++ b/tools/versioner/tests/compilation_error/headers/foo.h
@@ -0,0 +1 @@
+#error foo
diff --git a/tools/versioner/tests/compilation_error/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/compilation_error/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/compilation_error/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/compilation_error/run.sh b/tools/versioner/tests/compilation_error/run.sh
new file mode 100644
index 0000000..a34fda8
--- /dev/null
+++ b/tools/versioner/tests/compilation_error/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/dependencies/dependencies/arm/archdep/archdep.h b/tools/versioner/tests/dependencies/dependencies/arm/archdep/archdep.h
new file mode 100644
index 0000000..2005972
--- /dev/null
+++ b/tools/versioner/tests/dependencies/dependencies/arm/archdep/archdep.h
@@ -0,0 +1 @@
+typedef int arm_t;
diff --git a/tools/versioner/tests/dependencies/dependencies/common/foo/foodep.h b/tools/versioner/tests/dependencies/dependencies/common/foo/foodep.h
new file mode 100644
index 0000000..9feeb6c
--- /dev/null
+++ b/tools/versioner/tests/dependencies/dependencies/common/foo/foodep.h
@@ -0,0 +1 @@
+typedef int foo_t;
diff --git a/tools/versioner/tests/dependencies/dependencies/x86/archdep/archdep.h b/tools/versioner/tests/dependencies/dependencies/x86/archdep/archdep.h
new file mode 100644
index 0000000..5cc7de2
--- /dev/null
+++ b/tools/versioner/tests/dependencies/dependencies/x86/archdep/archdep.h
@@ -0,0 +1 @@
+typedef int x86_t;
diff --git a/tools/versioner/tests/dependencies/headers/foo.h b/tools/versioner/tests/dependencies/headers/foo.h
new file mode 100644
index 0000000..4491f1c
--- /dev/null
+++ b/tools/versioner/tests/dependencies/headers/foo.h
@@ -0,0 +1,8 @@
+#include <archdep.h>
+#include <foodep.h>
+
+#if defined(__i386__)
+x86_t foo(foo_t);
+#elif defined(__arm__)
+arm_t foo(foo_t);
+#endif
diff --git a/tools/versioner/tests/dependencies/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/dependencies/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/dependencies/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/dependencies/platforms/android-9/arch-x86/symbols/libc.so.functions.txt b/tools/versioner/tests/dependencies/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/dependencies/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/dependencies/run.sh b/tools/versioner/tests/dependencies/run.sh
new file mode 100644
index 0000000..0c17907
--- /dev/null
+++ b/tools/versioner/tests/dependencies/run.sh
@@ -0,0 +1 @@
+versioner headers dependencies -p platforms -r arm -r x86 -a 9
\ No newline at end of file
diff --git a/tools/versioner/tests/future/headers/foo.h b/tools/versioner/tests/future/headers/foo.h
new file mode 100644
index 0000000..54e8f0c
--- /dev/null
+++ b/tools/versioner/tests/future/headers/foo.h
@@ -0,0 +1 @@
+int foo() __INTRODUCED_IN_FUTURE;
diff --git a/libc/arch-arm64/cortex-a53/cortex-a53.mk b/tools/versioner/tests/future/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
similarity index 100%
rename from libc/arch-arm64/cortex-a53/cortex-a53.mk
rename to tools/versioner/tests/future/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/future/run.sh b/tools/versioner/tests/future/run.sh
new file mode 100644
index 0000000..041b047
--- /dev/null
+++ b/tools/versioner/tests/future/run.sh
@@ -0,0 +1 @@
+versioner -v headers -p platforms -r arm -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/future_arch/headers/foo.h b/tools/versioner/tests/future_arch/headers/foo.h
new file mode 100644
index 0000000..9dd976e
--- /dev/null
+++ b/tools/versioner/tests/future_arch/headers/foo.h
@@ -0,0 +1,5 @@
+#if defined(__arm__)
+int foo() __INTRODUCED_IN(9);
+#else
+int foo() __INTRODUCED_IN_FUTURE;
+#endif
diff --git a/tools/versioner/tests/future_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/future_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/future_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/libc/arch-arm64/cortex-a53/cortex-a53.mk b/tools/versioner/tests/future_arch/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
similarity index 100%
copy from libc/arch-arm64/cortex-a53/cortex-a53.mk
copy to tools/versioner/tests/future_arch/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/future_arch/run.sh b/tools/versioner/tests/future_arch/run.sh
new file mode 100644
index 0000000..ad8f430
--- /dev/null
+++ b/tools/versioner/tests/future_arch/run.sh
@@ -0,0 +1 @@
+versioner -v headers -p platforms -r arm -r x86 -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/inline/headers/foo.h b/tools/versioner/tests/inline/headers/foo.h
new file mode 100644
index 0000000..a61b386
--- /dev/null
+++ b/tools/versioner/tests/inline/headers/foo.h
@@ -0,0 +1,7 @@
+#if __ANDROID_API__ < 12
+static int foo() {
+  return 0;
+}
+#else
+int foo() __INTRODUCED_IN(12);
+#endif
diff --git a/tools/versioner/tests/inline/platforms/android-12/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/inline/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/inline/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/libc/arch-arm64/cortex-a53/cortex-a53.mk b/tools/versioner/tests/inline/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
similarity index 100%
copy from libc/arch-arm64/cortex-a53/cortex-a53.mk
copy to tools/versioner/tests/inline/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/inline/run.sh b/tools/versioner/tests/inline/run.sh
new file mode 100644
index 0000000..9bfbe6d
--- /dev/null
+++ b/tools/versioner/tests/inline/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/missing_api/expected_fail b/tools/versioner/tests/missing_api/expected_fail
new file mode 100644
index 0000000..18e7845
--- /dev/null
+++ b/tools/versioner/tests/missing_api/expected_fail
@@ -0,0 +1,4 @@
+  foo: introduced = 9
+    extern declaration @ headers/foo.h:1:1
+      introduced = 9
+versioner: version check failed
diff --git a/tools/versioner/tests/missing_api/headers/foo.h b/tools/versioner/tests/missing_api/headers/foo.h
new file mode 100644
index 0000000..3ff3ff7
--- /dev/null
+++ b/tools/versioner/tests/missing_api/headers/foo.h
@@ -0,0 +1 @@
+int foo() __INTRODUCED_IN(9);
\ No newline at end of file
diff --git a/libc/arch-arm64/cortex-a53/cortex-a53.mk b/tools/versioner/tests/missing_api/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
similarity index 100%
copy from libc/arch-arm64/cortex-a53/cortex-a53.mk
copy to tools/versioner/tests/missing_api/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/missing_api/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/missing_api/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/missing_api/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/missing_api/run.sh b/tools/versioner/tests/missing_api/run.sh
new file mode 100644
index 0000000..9bfbe6d
--- /dev/null
+++ b/tools/versioner/tests/missing_api/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/missing_arch/expected_fail b/tools/versioner/tests/missing_arch/expected_fail
new file mode 100644
index 0000000..82c2b28
--- /dev/null
+++ b/tools/versioner/tests/missing_arch/expected_fail
@@ -0,0 +1,4 @@
+  foo: no availability
+    extern declaration @ headers/foo.h:1:1
+      no availability
+versioner: version check failed
diff --git a/tools/versioner/tests/missing_arch/headers/foo.h b/tools/versioner/tests/missing_arch/headers/foo.h
new file mode 100644
index 0000000..176e7a3
--- /dev/null
+++ b/tools/versioner/tests/missing_arch/headers/foo.h
@@ -0,0 +1 @@
+int foo();
\ No newline at end of file
diff --git a/tools/versioner/tests/missing_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/missing_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/missing_arch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/libc/arch-arm64/cortex-a53/cortex-a53.mk b/tools/versioner/tests/missing_arch/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
similarity index 100%
copy from libc/arch-arm64/cortex-a53/cortex-a53.mk
copy to tools/versioner/tests/missing_arch/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/missing_arch/run.sh b/tools/versioner/tests/missing_arch/run.sh
new file mode 100644
index 0000000..f0d95ae
--- /dev/null
+++ b/tools/versioner/tests/missing_arch/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -r x86 -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/multiple_decl/headers/bar.h b/tools/versioner/tests/multiple_decl/headers/bar.h
new file mode 100644
index 0000000..1d3a28c
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl/headers/bar.h
@@ -0,0 +1 @@
+int foo() __REMOVED_IN(12);
\ No newline at end of file
diff --git a/tools/versioner/tests/multiple_decl/headers/foo.h b/tools/versioner/tests/multiple_decl/headers/foo.h
new file mode 100644
index 0000000..1d3a28c
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl/headers/foo.h
@@ -0,0 +1 @@
+int foo() __REMOVED_IN(12);
\ No newline at end of file
diff --git a/tools/versioner/tests/multiple_decl/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/multiple_decl/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/multiple_decl/run.sh b/tools/versioner/tests/multiple_decl/run.sh
new file mode 100644
index 0000000..a34fda8
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/multiple_decl_mismatch/expected_fail b/tools/versioner/tests/multiple_decl_mismatch/expected_fail
new file mode 100644
index 0000000..8e8c846
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl_mismatch/expected_fail
@@ -0,0 +1,8 @@
+versioner: inconsistent availability for symbol 'foo'
+versioner: failed to calculate symbol availability
+  foo: invalid
+    extern declaration @ headers/bar.h:1:1
+      obsoleted = 12
+    extern declaration @ headers/foo.h:1:1
+      obsoleted = 9
+versioner: sanity check failed
diff --git a/tools/versioner/tests/multiple_decl_mismatch/headers/bar.h b/tools/versioner/tests/multiple_decl_mismatch/headers/bar.h
new file mode 100644
index 0000000..1d3a28c
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl_mismatch/headers/bar.h
@@ -0,0 +1 @@
+int foo() __REMOVED_IN(12);
\ No newline at end of file
diff --git a/tools/versioner/tests/multiple_decl_mismatch/headers/foo.h b/tools/versioner/tests/multiple_decl_mismatch/headers/foo.h
new file mode 100644
index 0000000..49a73ec
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl_mismatch/headers/foo.h
@@ -0,0 +1 @@
+int foo() __REMOVED_IN(9);
\ No newline at end of file
diff --git a/tools/versioner/tests/multiple_decl_mismatch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/multiple_decl_mismatch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl_mismatch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/multiple_decl_mismatch/run.sh b/tools/versioner/tests/multiple_decl_mismatch/run.sh
new file mode 100644
index 0000000..a34fda8
--- /dev/null
+++ b/tools/versioner/tests/multiple_decl_mismatch/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/multiple_definition/expected_fail b/tools/versioner/tests/multiple_definition/expected_fail
new file mode 100644
index 0000000..6c531bd
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition/expected_fail
@@ -0,0 +1,7 @@
+versioner: conflicting inline definitions:
+  declarations visible in: arm-9 [fob = 32], arm-9 [fob = 64], arm-12 [fob = 32], arm-12 [fob = 64]
+    static definition @ headers/foo.h:1:1
+      no availability
+    static definition @ headers/bar.h:1:1
+      no availability
+versioner: sanity check failed
diff --git a/tools/versioner/tests/multiple_definition/headers/bar.h b/tools/versioner/tests/multiple_definition/headers/bar.h
new file mode 100644
index 0000000..a9d0197
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition/headers/bar.h
@@ -0,0 +1,3 @@
+static int foo() {
+  return 0;
+}
diff --git a/tools/versioner/tests/multiple_definition/headers/foo.h b/tools/versioner/tests/multiple_definition/headers/foo.h
new file mode 100644
index 0000000..a9d0197
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition/headers/foo.h
@@ -0,0 +1,3 @@
+static int foo() {
+  return 0;
+}
diff --git a/tools/versioner/tests/multiple_definition/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/multiple_definition/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/multiple_definition/run.sh b/tools/versioner/tests/multiple_definition/run.sh
new file mode 100644
index 0000000..e4abbe7
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
diff --git a/tools/versioner/tests/multiple_definition_ok/headers/bar.h b/tools/versioner/tests/multiple_definition_ok/headers/bar.h
new file mode 100644
index 0000000..c3c87bb
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition_ok/headers/bar.h
@@ -0,0 +1,5 @@
+#if __ANDROID_API__ == 12
+static int foo() {
+  return 0;
+}
+#endif
diff --git a/tools/versioner/tests/multiple_definition_ok/headers/foo.h b/tools/versioner/tests/multiple_definition_ok/headers/foo.h
new file mode 100644
index 0000000..9da9b2a
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition_ok/headers/foo.h
@@ -0,0 +1,5 @@
+#if __ANDROID_API__ == 9
+static int foo() {
+  return 0;
+}
+#endif
diff --git a/tools/versioner/tests/multiple_definition_ok/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/multiple_definition_ok/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition_ok/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/multiple_definition_ok/run.sh b/tools/versioner/tests/multiple_definition_ok/run.sh
new file mode 100644
index 0000000..e4abbe7
--- /dev/null
+++ b/tools/versioner/tests/multiple_definition_ok/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
diff --git a/tools/versioner/tests/obsoleted/headers/foo.h b/tools/versioner/tests/obsoleted/headers/foo.h
new file mode 100644
index 0000000..68f3d43
--- /dev/null
+++ b/tools/versioner/tests/obsoleted/headers/foo.h
@@ -0,0 +1 @@
+int foo() __INTRODUCED_IN(9) __REMOVED_IN(11);
\ No newline at end of file
diff --git a/libc/arch-arm64/cortex-a53/cortex-a53.mk b/tools/versioner/tests/obsoleted/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
similarity index 100%
copy from libc/arch-arm64/cortex-a53/cortex-a53.mk
copy to tools/versioner/tests/obsoleted/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
diff --git a/tools/versioner/tests/obsoleted/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/obsoleted/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/obsoleted/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/obsoleted/run.sh b/tools/versioner/tests/obsoleted/run.sh
new file mode 100644
index 0000000..9bfbe6d
--- /dev/null
+++ b/tools/versioner/tests/obsoleted/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/preprocessor/expected/foo.h b/tools/versioner/tests/preprocessor/expected/foo.h
new file mode 100644
index 0000000..73947b2
--- /dev/null
+++ b/tools/versioner/tests/preprocessor/expected/foo.h
@@ -0,0 +1,76 @@
+int always_available();
+
+int also_always_available() __INTRODUCED_IN(9);
+
+
+#if __ANDROID_API__ >= 13
+int needs_guard() __INTRODUCED_IN(13);
+#endif /* __ANDROID_API__ >= 13 */
+
+
+#if __ANDROID_API__ >= 12
+
+#if __ANDROID_API__ >= 13
+int needs_guard_2() __INTRODUCED_IN(13);
+#endif /* __ANDROID_API__ >= 13 */
+
+#endif
+
+#if __ANDROID_API__ >= 13
+int already_guarded() __INTRODUCED_IN(13);
+#endif
+
+#if __ANDROID_API__ > 13
+int already_guarded_2() __INTRODUCED_IN(13);
+#endif
+
+#if defined(__arm__)
+
+#if __ANDROID_API__ >= 14
+int specific_arch() __INTRODUCED_IN(14);
+#endif /* __ANDROID_API__ >= 14 */
+
+
+#if __ANDROID_API__ >= 14
+int specific_arch_already_guarded() __INTRODUCED_IN(14);
+#endif
+
+#if __ANDROID_API__ > 14
+int specific_arch_already_guarded_2() __INTRODUCED_IN(14);
+#endif
+#endif
+
+#if defined(__arm__) || defined(__i386__)
+
+#if __ANDROID_API__ >= 14
+int multiple_archs() __INTRODUCED_IN(14);
+#endif /* __ANDROID_API__ >= 14 */
+
+#endif
+
+// __INTRODUCED_IN_64(21) should be ignored.
+
+#if (defined(__LP64__)) || (defined(__arm__) && __ANDROID_API__ >= 13) || (defined(__mips__) && !defined(__LP64__) && __ANDROID_API__ >= 14) || (defined(__i386__) && __ANDROID_API__ >= 13)
+int multiple_introduced_1() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_MIPS(14) __INTRODUCED_IN_X86(13)
+    __INTRODUCED_IN_64(21);
+#endif /* (defined(__LP64__)) || (defined(__arm__) && __ANDROID_API__ >= 13) || (defined(__mips__) && !defined(__LP64__) && __ANDROID_API__ >= 14) || (defined(__i386__) && __ANDROID_API__ >= 13) */
+
+
+
+#if (defined(__LP64__) && __ANDROID_API__ >= 22) || (defined(__arm__) && __ANDROID_API__ >= 13) || (defined(__mips__) && !defined(__LP64__) && __ANDROID_API__ >= 14) || (defined(__i386__) && __ANDROID_API__ >= 13)
+int multiple_introduced_2() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_MIPS(14) __INTRODUCED_IN_X86(13)
+    __INTRODUCED_IN_64(22);
+#endif /* (defined(__LP64__) && __ANDROID_API__ >= 22) || (defined(__arm__) && __ANDROID_API__ >= 13) || (defined(__mips__) && !defined(__LP64__) && __ANDROID_API__ >= 14) || (defined(__i386__) && __ANDROID_API__ >= 13) */
+
+
+
+#if (!defined(__LP64__) && __ANDROID_API__ >= 12) || (defined(__LP64__))
+int group_lp32() __INTRODUCED_IN_ARM(12) __INTRODUCED_IN_X86(12) __INTRODUCED_IN_MIPS(12);
+#endif /* (!defined(__LP64__) && __ANDROID_API__ >= 12) || (defined(__LP64__)) */
+
+
+
+#if __ANDROID_API__ >= __ANDROID_API_FUTURE__
+int future() __INTRODUCED_IN_FUTURE;
+#endif /* __ANDROID_API__ >= __ANDROID_API_FUTURE__ */
+
diff --git a/tools/versioner/tests/preprocessor/headers/foo.h b/tools/versioner/tests/preprocessor/headers/foo.h
new file mode 100644
index 0000000..81c8b4b
--- /dev/null
+++ b/tools/versioner/tests/preprocessor/headers/foo.h
@@ -0,0 +1,44 @@
+int always_available();
+
+int also_always_available() __INTRODUCED_IN(9);
+
+int needs_guard() __INTRODUCED_IN(13);
+
+#if __ANDROID_API__ >= 12
+int needs_guard_2() __INTRODUCED_IN(13);
+#endif
+
+#if __ANDROID_API__ >= 13
+int already_guarded() __INTRODUCED_IN(13);
+#endif
+
+#if __ANDROID_API__ > 13
+int already_guarded_2() __INTRODUCED_IN(13);
+#endif
+
+#if defined(__arm__)
+int specific_arch() __INTRODUCED_IN(14);
+
+#if __ANDROID_API__ >= 14
+int specific_arch_already_guarded() __INTRODUCED_IN(14);
+#endif
+
+#if __ANDROID_API__ > 14
+int specific_arch_already_guarded_2() __INTRODUCED_IN(14);
+#endif
+#endif
+
+#if defined(__arm__) || defined(__i386__)
+int multiple_archs() __INTRODUCED_IN(14);
+#endif
+
+// __INTRODUCED_IN_64(21) should be ignored.
+int multiple_introduced_1() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_MIPS(14) __INTRODUCED_IN_X86(13)
+    __INTRODUCED_IN_64(21);
+
+int multiple_introduced_2() __INTRODUCED_IN_ARM(13) __INTRODUCED_IN_MIPS(14) __INTRODUCED_IN_X86(13)
+    __INTRODUCED_IN_64(22);
+
+int group_lp32() __INTRODUCED_IN_ARM(12) __INTRODUCED_IN_X86(12) __INTRODUCED_IN_MIPS(12);
+
+int future() __INTRODUCED_IN_FUTURE;
diff --git a/tools/versioner/tests/preprocessor/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/preprocessor/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/preprocessor/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/preprocessor/run.sh b/tools/versioner/tests/preprocessor/run.sh
new file mode 100644
index 0000000..60e7024
--- /dev/null
+++ b/tools/versioner/tests/preprocessor/run.sh
@@ -0,0 +1,29 @@
+set -e
+
+function run_test {
+  SRC=$1
+  DST=$2
+  rm -rf $2
+  versioner $1 -i -o $2
+  diff -q -w -B $2 expected
+}
+
+run_test headers out
+run_test headers/ out
+run_test headers out/
+run_test headers/ out/
+
+run_test `pwd`/headers out
+run_test `pwd`/headers/ out
+run_test `pwd`/headers out/
+run_test `pwd`/headers/ out/
+
+run_test headers `pwd`/out
+run_test headers/ `pwd`/out
+run_test headers `pwd`/out/
+run_test headers/ `pwd`/out/
+
+run_test `pwd`/headers `pwd`/out
+run_test `pwd`/headers/ `pwd`/out
+run_test `pwd`/headers `pwd`/out/
+run_test `pwd`/headers/ `pwd`/out/
diff --git a/tools/versioner/tests/preprocessor_file_offset_bits/expected/foo.h b/tools/versioner/tests/preprocessor_file_offset_bits/expected/foo.h
new file mode 100644
index 0000000..7d31ec3
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_file_offset_bits/expected/foo.h
@@ -0,0 +1,34 @@
+typedef int off_t;
+typedef int ssize_t;
+typedef unsigned size_t;
+
+#if !defined(__LP64__) && defined(_FILE_OFFSET_BITS)
+#if _FILE_OFFSET_BITS == 64
+#define __USE_FILE_OFFSET64 1
+#endif
+#endif
+
+#define __RENAME(x) __asm__(#x)
+
+#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= 21
+int truncate(const char* __path, off_t __length) __RENAME(truncate64) __INTRODUCED_IN(21);
+#else
+int truncate(const char* __path, off_t __length);
+#endif
+
+#if defined(__USE_FILE_OFFSET64)
+
+#if __ANDROID_API__ >= 12
+ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset) __RENAME(pread64)
+    __INTRODUCED_IN(12);
+#endif /* __ANDROID_API__ >= 12 */
+
+#else
+ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset);
+#endif
+
+#if defined(__USE_FILE_OFFSET64)
+off_t lseek(int __fd, off_t __offset, int __whence) __RENAME(lseek64);
+#else
+off_t lseek(int __fd, off_t __offset, int __whence);
+#endif
diff --git a/tools/versioner/tests/preprocessor_file_offset_bits/headers/foo.h b/tools/versioner/tests/preprocessor_file_offset_bits/headers/foo.h
new file mode 100644
index 0000000..868d1fc
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_file_offset_bits/headers/foo.h
@@ -0,0 +1,30 @@
+typedef int off_t;
+typedef int ssize_t;
+typedef unsigned size_t;
+
+#if !defined(__LP64__) && defined(_FILE_OFFSET_BITS)
+#if _FILE_OFFSET_BITS == 64
+#define __USE_FILE_OFFSET64 1
+#endif
+#endif
+
+#define __RENAME(x) __asm__(#x)
+
+#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= 21
+int truncate(const char* __path, off_t __length) __RENAME(truncate64) __INTRODUCED_IN(21);
+#else
+int truncate(const char* __path, off_t __length);
+#endif
+
+#if defined(__USE_FILE_OFFSET64)
+ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset) __RENAME(pread64)
+    __INTRODUCED_IN(12);
+#else
+ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset);
+#endif
+
+#if defined(__USE_FILE_OFFSET64)
+off_t lseek(int __fd, off_t __offset, int __whence) __RENAME(lseek64);
+#else
+off_t lseek(int __fd, off_t __offset, int __whence);
+#endif
diff --git a/tools/versioner/tests/preprocessor_file_offset_bits/run.sh b/tools/versioner/tests/preprocessor_file_offset_bits/run.sh
new file mode 100644
index 0000000..c503867
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_file_offset_bits/run.sh
@@ -0,0 +1,5 @@
+set -e
+
+rm -rf out
+versioner headers -i -o out
+diff -q -w -B out expected
diff --git a/tools/versioner/tests/preprocessor_idempotence/expected/foo.h b/tools/versioner/tests/preprocessor_idempotence/expected/foo.h
new file mode 100644
index 0000000..ed31e8b
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_idempotence/expected/foo.h
@@ -0,0 +1,12 @@
+#if __ANDROID_API__ >= 10
+int foo() __INTRODUCED_IN(10);
+#endif
+
+#if __ANDROID_API__ >= 21
+int bar(int) __INTRODUCED_IN(21);
+#endif
+
+#if __ANDROID_API__ >= 10
+int multiple_1() __INTRODUCED_IN(10);
+int multiple_2() __INTRODUCED_IN(10);
+#endif
diff --git a/tools/versioner/tests/preprocessor_idempotence/headers/foo.h b/tools/versioner/tests/preprocessor_idempotence/headers/foo.h
new file mode 100644
index 0000000..ed31e8b
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_idempotence/headers/foo.h
@@ -0,0 +1,12 @@
+#if __ANDROID_API__ >= 10
+int foo() __INTRODUCED_IN(10);
+#endif
+
+#if __ANDROID_API__ >= 21
+int bar(int) __INTRODUCED_IN(21);
+#endif
+
+#if __ANDROID_API__ >= 10
+int multiple_1() __INTRODUCED_IN(10);
+int multiple_2() __INTRODUCED_IN(10);
+#endif
diff --git a/tools/versioner/tests/preprocessor_idempotence/run.sh b/tools/versioner/tests/preprocessor_idempotence/run.sh
new file mode 100644
index 0000000..1b0aae2
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_idempotence/run.sh
@@ -0,0 +1,4 @@
+rm -rf out
+set -e
+versioner headers -i -o out
+diff -q -w -B out expected
diff --git a/tools/versioner/tests/preprocessor_merging/expected/foo.h b/tools/versioner/tests/preprocessor_merging/expected/foo.h
new file mode 100644
index 0000000..45eb32d
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_merging/expected/foo.h
@@ -0,0 +1,9 @@
+
+#if __ANDROID_API__ >= 10
+int block_merging_1() __INTRODUCED_IN(10); // foo
+int block_merging_2() __INTRODUCED_IN(10); /* bar */
+int block_merging_3() __INTRODUCED_IN(10); /* baz
+//*/
+int block_merging_4() __INTRODUCED_IN(10);
+#endif /* __ANDROID_API__ >= 10 */
+
diff --git a/tools/versioner/tests/preprocessor_merging/headers/foo.h b/tools/versioner/tests/preprocessor_merging/headers/foo.h
new file mode 100644
index 0000000..ac9564b
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_merging/headers/foo.h
@@ -0,0 +1,5 @@
+int block_merging_1() __INTRODUCED_IN(10); // foo
+int block_merging_2() __INTRODUCED_IN(10); /* bar */
+int block_merging_3() __INTRODUCED_IN(10); /* baz
+//*/
+int block_merging_4() __INTRODUCED_IN(10);
diff --git a/tools/versioner/tests/preprocessor_merging/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/preprocessor_merging/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_merging/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/preprocessor_merging/run.sh b/tools/versioner/tests/preprocessor_merging/run.sh
new file mode 100644
index 0000000..1b0aae2
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_merging/run.sh
@@ -0,0 +1,4 @@
+rm -rf out
+set -e
+versioner headers -i -o out
+diff -q -w -B out expected
diff --git a/tools/versioner/tests/preprocessor_no_guard/expected/foo.h b/tools/versioner/tests/preprocessor_no_guard/expected/foo.h
new file mode 100644
index 0000000..2bf1dbf
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_no_guard/expected/foo.h
@@ -0,0 +1 @@
+int foo() __VERSIONER_NO_GUARD __INTRODUCED_IN(14);
diff --git a/tools/versioner/tests/preprocessor_no_guard/headers/foo.h b/tools/versioner/tests/preprocessor_no_guard/headers/foo.h
new file mode 100644
index 0000000..2bf1dbf
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_no_guard/headers/foo.h
@@ -0,0 +1 @@
+int foo() __VERSIONER_NO_GUARD __INTRODUCED_IN(14);
diff --git a/tools/versioner/tests/preprocessor_no_guard/run.sh b/tools/versioner/tests/preprocessor_no_guard/run.sh
new file mode 100644
index 0000000..1b0aae2
--- /dev/null
+++ b/tools/versioner/tests/preprocessor_no_guard/run.sh
@@ -0,0 +1,4 @@
+rm -rf out
+set -e
+versioner headers -i -o out
+diff -q -w -B out expected
diff --git a/tools/versioner/tests/slow_preprocessor_idempotence/run.sh b/tools/versioner/tests/slow_preprocessor_idempotence/run.sh
new file mode 100644
index 0000000..6426156
--- /dev/null
+++ b/tools/versioner/tests/slow_preprocessor_idempotence/run.sh
@@ -0,0 +1,6 @@
+rm -rf out
+set -e
+mkdir out
+versioner -o out/initial
+versioner out/initial ../../dependencies -o out/second
+diff -qrwB out/initial out/second
diff --git a/tools/versioner/tests/smoke/headers/foo.h b/tools/versioner/tests/smoke/headers/foo.h
new file mode 100644
index 0000000..3ff3ff7
--- /dev/null
+++ b/tools/versioner/tests/smoke/headers/foo.h
@@ -0,0 +1 @@
+int foo() __INTRODUCED_IN(9);
\ No newline at end of file
diff --git a/tools/versioner/tests/smoke/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/smoke/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/smoke/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/smoke/run.sh b/tools/versioner/tests/smoke/run.sh
new file mode 100644
index 0000000..a34fda8
--- /dev/null
+++ b/tools/versioner/tests/smoke/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -i
\ No newline at end of file
diff --git a/tools/versioner/tests/version_mismatch/expected_fail b/tools/versioner/tests/version_mismatch/expected_fail
new file mode 100644
index 0000000..f83f71c
--- /dev/null
+++ b/tools/versioner/tests/version_mismatch/expected_fail
@@ -0,0 +1,8 @@
+versioner: inconsistent availability for symbol 'foo'
+versioner: failed to calculate symbol availability
+  foo: invalid
+    extern declaration @ headers/foo.h:2:1
+      introduced = 9
+    extern declaration @ headers/foo.h:4:1
+      introduced = 10
+versioner: sanity check failed
diff --git a/tools/versioner/tests/version_mismatch/headers/foo.h b/tools/versioner/tests/version_mismatch/headers/foo.h
new file mode 100644
index 0000000..4604092
--- /dev/null
+++ b/tools/versioner/tests/version_mismatch/headers/foo.h
@@ -0,0 +1,5 @@
+#if __ANDROID_API__ <= 9
+int foo() __INTRODUCED_IN(9);
+#else
+int foo() __INTRODUCED_IN(10);
+#endif
diff --git a/tools/versioner/tests/version_mismatch/platforms/android-12/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/version_mismatch/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/version_mismatch/platforms/android-12/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/version_mismatch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/tools/versioner/tests/version_mismatch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/tools/versioner/tests/version_mismatch/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -0,0 +1 @@
+foo
diff --git a/tools/versioner/tests/version_mismatch/run.sh b/tools/versioner/tests/version_mismatch/run.sh
new file mode 100644
index 0000000..9bfbe6d
--- /dev/null
+++ b/tools/versioner/tests/version_mismatch/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
\ No newline at end of file