diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 0b4a925..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,4 +0,0 @@
-filegroup {
-    name: "android_filesystem_config_header",
-    srcs: ["include/private/android_filesystem_config.h"],
-}
diff --git a/OWNERS b/OWNERS
index 682a067..4f8e433 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1 +1,2 @@
 enh@google.com
+baligh@google.com
diff --git a/adb/Android.bp b/adb/Android.bp
index 8addf95..5c1e1fe 100644
--- a/adb/Android.bp
+++ b/adb/Android.bp
@@ -25,6 +25,7 @@
         "-Wextra",
         "-Werror",
         "-Wexit-time-destructors",
+        "-Wno-non-virtual-dtor",
         "-Wno-unused-parameter",
         "-Wno-missing-field-initializers",
         "-Wthread-safety",
@@ -270,6 +271,8 @@
     host_supported: true,
     compile_multilib: "both",
     min_sdk_version: "apex_inherit",
+    // This library doesn't use build::GetBuildNumber()
+    use_version_lib: false,
 
     srcs: [
         "sysdeps/env.cpp",
@@ -752,6 +755,8 @@
         "mdns_test.cpp",
     ],
 
+    test_config: "adb_test.xml",
+
     shared_libs: [
         "liblog",
     ],
diff --git a/adb/README.md b/adb/README.md
new file mode 100644
index 0000000..224387c
--- /dev/null
+++ b/adb/README.md
@@ -0,0 +1,94 @@
+# ADB Internals
+
+If you are new to adb source code, you should start by reading [OVERVIEW.TXT](OVERVIEW.TXT) which describes the three components of adb pipeline.
+
+This document is here to boost what can be achieved within a "window of naive interest". You will not find function or class documentation here but rather the "big picture" which should allow you to build a mental map to help navigate the code.
+
+## Three components of adb pipeline
+
+As outlined in the overview, this codebase generates three components (Client, Server (a.k.a Host), and Daemon (a.k.a adbd)). The central part is the Server which runs on the Host computer. On one side the Server exposes a "Smart Socket" to Clients such as adb or DDMLIB. On the other side, the Server continuously monitors for connecting Daemons (as USB devices or TCP emulator). Communication with a device is done with a Transport.
+
+```
++----------+              +------------------------+
+|   ADB    +----------+   |      ADB SERVER        |                   +----------+
+|  CLIENT  |          |   |                        |              (USB)|   ADBD   |
++----------+          |   |                     Transport+-------------+ (DEVICE) |
+                      |   |                        |                   +----------+
++-----------          |   |                        |
+|   ADB    |          v   +                        |                   +----------+
+|  CLIENT  +--------->SmartSocket                  |              (USB)|   ADBD   |
++----------+          ^   | (TCP/IP)            Transport+-------------+ (DEVICE) |
+                      |   |                        |                   +----------+
++----------+          |   |                        |
+|  DDMLIB  |          |   |                     Transport+--+          +----------+
+|  CLIENT  +----------+   |                        |        |  (TCP/IP)|   ADBD   |
++----------+              +------------------------+        +----------|(EMULATOR)|
+                                                                       +----------+
+```
+
+The Client and the Server are contained in the same executable and both run on the Host machine. Code sections specific to the Host is enclosed within `ADB_HOST` guard. adbd runs on the Android Device. Daemon specific code is enclosed in `!ADB_HOST` but also sometimes with-in `__ANDROID__` guard.
+
+
+## "SMART SOCKET" and TRANSPORT
+
+A smart socket is a simple TCP socket with a smart protocol built on top of it. This is what Clients connect onto from the Host side. The Client must always initiate communication via a human readable request but the response format varies. The smart protocol is documented in [SERVICES.TXT](SERVICES.TXT).
+
+On the other side, the Server communicate with a device via a Transport. adb initially targeted devices connecting over USB, which is restricted to a fixed number of data streams. Therefore, adb multiplexes multiple byte streams over a single pipe via Transport. When devices connecting over other mechanisms (e.g. emulators over TCP) were introduced, the existing transport protocol was maintained.
+
+## THREADING MODEL and FDEVENT system
+
+At the heart of both the Server and Daemon is a main thread running an fdevent loop, which is an platform-independent abstraction over poll/epoll/WSAPoll monitoring file descriptors events. Requests and services are usually server from the main thread but some service requests result in new threads being spawned.
+
+To allow for operations to run on the Main thread, fdevent features a RunQueue combined with an interrupt fd to force polling to return.
+
+```
++------------+    +-------------------------^
+|  RUNQUEUE  |    |                         |
++------------+    |  POLLING (Main thread)  |
+| Function<> |    |                         |
++------------+    |                         |
+| Function<> |    ^-^-------^-------^------^^
++------------+      |       |       |       |
+|    ...     |      |       |       |       |
++------------+      |       |       |       |
+|            |      |       |       |       |
+|============|      |       |       |       |
+|Interrupt fd+------+  +----+  +----+  +----+
++------------+         fd      Socket  Pipe
+```
+
+## ASOCKET, APACKET, and AMESSAGE
+
+The asocket, apacket, and amessage constructs exist only to wrap data while it transits on a Transport. An asocket handles a stream of apackets. An apacket consists in a amessage header featuring a command (`A_SYNC`, `A_OPEN`, `A_CLSE`, `A_WRTE`, `A_OKAY`, ...) followed by a payload (find more documentation in [protocol.txt](protocol.txt). There is no `A_READ` command because an asocket is unidirectional. To model a bi-directional stream, asocket have a peer which go in the opposite direction.
+
+An asocket features a buffer where the elemental unit is an apacket. Is traffic is inbound, the buffer stores apacket until they are consumed. If the traffic is oubound, the buffer store apackets until they are sent down the wire (with `A_WRTE` commands).
+
+```
++---------------------ASocket------------------------+
+ |                                                   |
+ | +----------------APacket Queue------------------+ |
+ | |                                               | |
+ | |            APacket     APacket     APacket    | |
+ | |          +--------+  +--------+  +--------+   | |
+ | |          |AMessage|  |AMessage|  |AMessage|   | |
+ | |          +--------+  +--------+  +--------+   | |
+ | |          |        |  |        |  |        |   | |
+ | |  .....   |        |  |        |  |        |   | |
+ | |          |  Data  |  |  Data  |  |  Data  |   | |
+ | |          |        |  |        |  |        |   | |
+ | |          |        |  |        |  |        |   | |
+ | |          +--------+  +--------+  +--------+   | |
+ | |                                               | |
+ | +-----------------------------------------------+ |
+ +---------------------------------------------------+
+```
+
+This system allows to multiplex data streams on an unique byte stream.  Without entering too much into details, the amessage fields arg1 and arg2 are used alike in the TCP protocol where local and remote ports identify an unique stream. Note that unlike TCP which feature an "unacknowledged-send window", an apacket is sent only after the previous one has been confirmed to be received.
+
+The two types of asocket (Remote and Local) differentiate between outbound and inbound traffic.
+
+## adbd <-> APPPLICATION communication
+
+This pipeline is detailed in [services.cpp](services.cpp). The JDWP extension implemented by Dalvik/ART are documented in:
+- platform/dalvik/+/master/docs/debugmon.html
+- platform/dalvik/+/master/docs/debugger.html
diff --git a/adb/adb_test.xml b/adb/adb_test.xml
new file mode 100644
index 0000000..cc3302d
--- /dev/null
+++ b/adb/adb_test.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+<!-- This test config file is auto-generated. -->
+<configuration description="Runs adbd_test.">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-native" />
+
+    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
+    </target_preparer>
+
+    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+        <option name="cleanup" value="true" />
+        <option name="push" value="adbd_test->/data/local/tmp/adbd_test" />
+    </target_preparer>
+
+    <test class="com.android.tradefed.testtype.GTest" >
+        <option name="native-test-device-path" value="/data/local/tmp" />
+        <option name="module-name" value="adbd_test" />
+    </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+      <option name="mainline-module-package-name" value="com.google.android.adbd" />
+    </object>
+</configuration>
diff --git a/adb/apex/apex_manifest.json b/adb/apex/apex_manifest.json
index ff2df12..4a07bdc 100644
--- a/adb/apex/apex_manifest.json
+++ b/adb/apex/apex_manifest.json
@@ -1,4 +1,4 @@
 {
   "name": "com.android.adbd",
-  "version": 1
+  "version": 300900700
 }
diff --git a/adb/client/bugreport.cpp b/adb/client/bugreport.cpp
index f2e722a..b765a30 100644
--- a/adb/client/bugreport.cpp
+++ b/adb/client/bugreport.cpp
@@ -224,7 +224,8 @@
         // 'bugreport' would generate a lot of output the user might not be prepared to handle).
         fprintf(stderr,
                 "Failed to get bugreportz version: 'bugreportz -v' returned '%s' (code %d).\n"
-                "If the device does not run Android 7.0 or above, try 'adb bugreport' instead.\n",
+                "If the device does not run Android 7.0 or above, try this instead:\n"
+                "\tadb bugreport > bugreport.txt\n",
                 bugz_output.c_str(), status);
         return status != 0 ? status : -1;
     }
diff --git a/adb/client/file_sync_client.cpp b/adb/client/file_sync_client.cpp
index 8bbe2a8..2e8b975 100644
--- a/adb/client/file_sync_client.cpp
+++ b/adb/client/file_sync_client.cpp
@@ -1053,7 +1053,7 @@
         if (!sc.SendSmallFile(rpath, mode, lpath, rpath, mtime, buf, data_length, dry_run)) {
             return false;
         }
-        return sc.ReadAcknowledgements();
+        return sc.ReadAcknowledgements(sync);
 #endif
     }
 
@@ -1077,7 +1077,7 @@
             return false;
         }
     }
-    return sc.ReadAcknowledgements();
+    return sc.ReadAcknowledgements(sync);
 }
 
 static bool sync_recv_v1(SyncConnection& sc, const char* rpath, const char* lpath, const char* name,
diff --git a/adb/client/incremental_utils.cpp b/adb/client/incremental_utils.cpp
index dd117d2..1a071fd 100644
--- a/adb/client/incremental_utils.cpp
+++ b/adb/client/incremental_utils.cpp
@@ -305,6 +305,7 @@
 static std::vector<int32_t> InstallationPriorityBlocks(borrowed_fd fd, Size fileSize) {
     static constexpr std::array<std::string_view, 3> additional_matches = {
             "resources.arsc"sv, "AndroidManifest.xml"sv, "classes.dex"sv};
+
     auto [zip, _] = openZipArchive(fd, fileSize);
     if (!zip) {
         return {};
@@ -325,7 +326,7 @@
     }
 
     std::vector<int32_t> installationPriorityBlocks;
-    ZipEntry entry;
+    ZipEntry64 entry;
     std::string_view entryName;
     while (Next(cookie, &entry, &entryName) == 0) {
         if (entryName == "classes.dex"sv) {
@@ -358,7 +359,7 @@
 
 std::vector<int32_t> PriorityBlocksForFile(const std::string& filepath, borrowed_fd fd,
                                            Size fileSize) {
-    if (!android::base::EndsWithIgnoreCase(filepath, ".apk"sv)) {
+    if (!android::base::EndsWithIgnoreCase(filepath, ".apk")) {
         return {};
     }
     off64_t signerOffset = SignerBlockOffset(fd, fileSize);
diff --git a/adb/daemon/adb_wifi.cpp b/adb/daemon/adb_wifi.cpp
index bce303b..2f9e9b4 100644
--- a/adb/daemon/adb_wifi.cpp
+++ b/adb/daemon/adb_wifi.cpp
@@ -42,7 +42,8 @@
 
 static void adb_disconnected(void* unused, atransport* t) {
     LOG(INFO) << "ADB wifi device disconnected";
-    adbd_auth_tls_device_disconnected(auth_ctx, kAdbTransportTypeWifi, t->auth_id);
+    CHECK(t->auth_id.has_value());
+    adbd_auth_tls_device_disconnected(auth_ctx, kAdbTransportTypeWifi, t->auth_id.value());
 }
 
 // TODO(b/31559095): need bionic host so that we can use 'prop_info' returned
diff --git a/adb/daemon/auth.cpp b/adb/daemon/auth.cpp
index 2edf582..1a1e4ad 100644
--- a/adb/daemon/auth.cpp
+++ b/adb/daemon/auth.cpp
@@ -207,15 +207,27 @@
 }
 
 static void adbd_auth_key_authorized(void* arg, uint64_t id) {
-    LOG(INFO) << "adb client authorized";
+    LOG(INFO) << "adb client " << id << " authorized";
     fdevent_run_on_main_thread([=]() {
-        LOG(INFO) << "arg = " << reinterpret_cast<uintptr_t>(arg);
         auto* transport = transport_from_callback_arg(arg);
         if (!transport) {
-            LOG(ERROR) << "authorization received for deleted transport, ignoring";
+            LOG(ERROR) << "authorization received for deleted transport (" << id << "), ignoring";
             return;
         }
-        transport->auth_id = id;
+
+        if (transport->auth_id.has_value()) {
+            if (transport->auth_id.value() != id) {
+                LOG(ERROR)
+                        << "authorization received, but auth id doesn't match, ignoring (expected "
+                        << transport->auth_id.value() << ", got " << id << ")";
+                return;
+            }
+        } else {
+            // Older versions (i.e. dogfood/beta builds) of libadbd_auth didn't pass the initial
+            // auth id to us, so we'll just have to trust it until R ships and we can retcon this.
+            transport->auth_id = id;
+        }
+
         adbd_auth_verified(transport);
     });
 }
@@ -265,14 +277,20 @@
 
 static void adb_disconnected(void* unused, atransport* t) {
     LOG(INFO) << "ADB disconnect";
-    adbd_auth_notify_disconnect(auth_ctx, t->auth_id);
+    CHECK(t->auth_id.has_value());
+    adbd_auth_notify_disconnect(auth_ctx, t->auth_id.value());
 }
 
 void adbd_auth_confirm_key(atransport* t) {
     LOG(INFO) << "prompting user to authorize key";
     t->AddDisconnect(&adb_disconnect);
-    adbd_auth_prompt_user(auth_ctx, t->auth_key.data(), t->auth_key.size(),
-                          transport_to_callback_arg(t));
+    if (adbd_auth_prompt_user_with_id) {
+        t->auth_id = adbd_auth_prompt_user_with_id(auth_ctx, t->auth_key.data(), t->auth_key.size(),
+                                                   transport_to_callback_arg(t));
+    } else {
+        adbd_auth_prompt_user(auth_ctx, t->auth_key.data(), t->auth_key.size(),
+                              transport_to_callback_arg(t));
+    }
 }
 
 void adbd_notify_framework_connected_key(atransport* t) {
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index eb28668..8c41c5e 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -108,9 +108,12 @@
     // AID_NET_BW_STATS to read out qtaguid statistics
     // AID_READPROC for reading /proc entries across UID boundaries
     // AID_UHID for using 'hid' command to read/write to /dev/uhid
+    // AID_EXT_DATA_RW for writing to /sdcard/Android/data (devices without sdcardfs)
+    // AID_EXT_OBB_RW for writing to /sdcard/Android/obb (devices without sdcardfs)
     gid_t groups[] = {AID_ADB,          AID_LOG,          AID_INPUT,    AID_INET,
                       AID_NET_BT,       AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW,
-                      AID_NET_BW_STATS, AID_READPROC,     AID_UHID};
+                      AID_NET_BW_STATS, AID_READPROC,     AID_UHID,     AID_EXT_DATA_RW,
+                      AID_EXT_OBB_RW};
     minijail_set_supplementary_gids(jail.get(), arraysize(groups), groups);
 
     // Don't listen on a port (default 5037) if running in secure mode.
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index a663871..50d7364 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -584,12 +584,11 @@
                 incoming_header_ = msg;
             } else {
                 size_t bytes_left = incoming_header_->data_length - incoming_payload_.size();
-                Block payload = std::move(block->payload);
                 if (block->payload.size() > bytes_left) {
                     HandleError("received too many bytes while waiting for payload");
                     return false;
                 }
-                incoming_payload_.append(std::move(payload));
+                incoming_payload_.append(std::move(block->payload));
             }
 
             if (incoming_header_->data_length == incoming_payload_.size()) {
diff --git a/adb/test_device.py b/adb/test_device.py
index c1caafc..a92d4a7 100755
--- a/adb/test_device.py
+++ b/adb/test_device.py
@@ -1271,6 +1271,31 @@
                 if temp_dir is not None:
                     shutil.rmtree(temp_dir)
 
+        def test_push_sync_multiple(self):
+            """Sync multiple host directories to a specific path."""
+
+            try:
+                temp_dir = tempfile.mkdtemp()
+                temp_files = make_random_host_files(in_dir=temp_dir, num_files=32)
+
+                device_dir = posixpath.join(self.DEVICE_TEMP_DIR, 'sync_src_dst')
+
+                # Clean up any stale files on the device.
+                device = adb.get_device()  # pylint: disable=no-member
+                device.shell(['rm', '-rf', device_dir])
+                device.shell(['mkdir', '-p', device_dir])
+
+                host_paths = [os.path.join(temp_dir, x.base_name) for x in temp_files]
+                device.push(host_paths, device_dir, sync=True)
+
+                self.verify_sync(device, temp_files, device_dir)
+
+                self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
+            finally:
+                if temp_dir is not None:
+                    shutil.rmtree(temp_dir)
+
+
         def test_push_dry_run_nonexistent_file(self):
             """Push with dry run."""
 
diff --git a/adb/transport.h b/adb/transport.h
index b1f2744..d59be59 100644
--- a/adb/transport.h
+++ b/adb/transport.h
@@ -27,6 +27,7 @@
 #include <list>
 #include <memory>
 #include <mutex>
+#include <optional>
 #include <string>
 #include <string_view>
 #include <thread>
@@ -320,7 +321,7 @@
 #if !ADB_HOST
     // Used to provide the key to the framework.
     std::string auth_key;
-    uint64_t auth_id;
+    std::optional<uint64_t> auth_id;
 #endif
 
     bool IsTcpDevice() const { return type == kTransportLocal; }
diff --git a/bootstat/boot_event_record_store.h b/bootstat/boot_event_record_store.h
index f872c85..e852304 100644
--- a/bootstat/boot_event_record_store.h
+++ b/bootstat/boot_event_record_store.h
@@ -69,4 +69,4 @@
   DISALLOW_COPY_AND_ASSIGN(BootEventRecordStore);
 };
 
-#endif  // BOOT_EVENT_RECORD_STORE_H_
\ No newline at end of file
+#endif  // BOOT_EVENT_RECORD_STORE_H_
diff --git a/cli-test/cli-test.cpp b/cli-test/cli-test.cpp
index d6e27ee..d1ef1b4 100644
--- a/cli-test/cli-test.cpp
+++ b/cli-test/cli-test.cpp
@@ -146,6 +146,13 @@
       test->befores.push_back(line);
     } else if (Match(&line, "after:")) {
       test->afters.push_back(line);
+    } else if (Match(&line, "expected-exit-status:")) {
+      char* end_p;
+      errno = 0;
+      test->exit_status = strtol(line.c_str(), &end_p, 10);
+      if (errno != 0 || *end_p != '\0') {
+        Die(0, "%s:%zu: bad exit status: \"%s\"", g_file, g_line, line.c_str());
+      }
     } else if (Match(&line, "expected-stdout:")) {
       // Collect tab-indented lines.
       std::string text;
@@ -231,15 +238,15 @@
       V("running command \"%s\"", test.command.c_str());
       CapturedStdout test_stdout;
       CapturedStderr test_stderr;
-      int exit_status = system(test.command.c_str());
+      int status = system(test.command.c_str());
       test_stdout.Stop();
       test_stderr.Stop();
 
-      V("exit status %d", exit_status);
-      if (exit_status != test.exit_status) {
+      V("system() returned status %d", status);
+      if (WEXITSTATUS(status) != test.exit_status) {
         failed = true;
         fprintf(stderr, "Incorrect exit status: expected %d but %s\n", test.exit_status,
-                ExitStatusToString(exit_status).c_str());
+                ExitStatusToString(status).c_str());
       }
 
       if (!CheckOutput("stdout", test_stdout.str(), test.expected_stdout, FILES)) failed = true;
diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp
index ad10a1f..99cabdd 100644
--- a/debuggerd/Android.bp
+++ b/debuggerd/Android.bp
@@ -343,6 +343,12 @@
     apex_available: [
         "com.android.runtime",
     ],
+
+    product_variables: {
+        experimental_mte: {
+            cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
+        },
+    },
 }
 
 cc_binary {
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index d7cb972..5280121 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -40,6 +40,7 @@
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
 #include <android-base/unique_fd.h>
+#include <bionic/mte_kernel.h>
 #include <bionic/reserved_signals.h>
 #include <cutils/sockets.h>
 #include <log/log.h>
@@ -486,6 +487,17 @@
         continue;
       }
 
+#ifdef ANDROID_EXPERIMENTAL_MTE
+      struct iovec iov = {
+          &info.tagged_addr_ctrl,
+          sizeof(info.tagged_addr_ctrl),
+      };
+      if (ptrace(PTRACE_GETREGSET, thread, NT_ARM_TAGGED_ADDR_CTRL,
+                 reinterpret_cast<void*>(&iov)) == -1) {
+        info.tagged_addr_ctrl = -1;
+      }
+#endif
+
       if (thread == g_target_thread) {
         // Read the thread's registers along with the rest of the crash info out of the pipe.
         ReadCrashInfo(input_pipe, &siginfo, &info.registers, &process_info);
@@ -585,8 +597,8 @@
   }
 
   // TODO: Use seccomp to lock ourselves down.
-  unwindstack::UnwinderFromPid unwinder(256, vm_pid);
-  if (!unwinder.Init(unwindstack::Regs::CurrentArch())) {
+  unwindstack::UnwinderFromPid unwinder(256, vm_pid, unwindstack::Regs::CurrentArch());
+  if (!unwinder.Init()) {
     LOG(FATAL) << "Failed to init unwinder object.";
   }
 
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index 108787e..5ed9e57 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -309,6 +309,11 @@
   std::string result;
   ConsumeFd(std::move(output_fd), &result);
   ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0xdead)");
+
+  if (mte_supported()) {
+    // Test that the default TAGGED_ADDR_CTRL value is set.
+    ASSERT_MATCH(result, R"(tagged_addr_ctrl: 000000000007fff3)");
+  }
 }
 
 TEST_F(CrasherTest, tagged_fault_addr) {
diff --git a/debuggerd/handler/debuggerd_fallback.cpp b/debuggerd/handler/debuggerd_fallback.cpp
index 9bcbdb3..e103c82 100644
--- a/debuggerd/handler/debuggerd_fallback.cpp
+++ b/debuggerd/handler/debuggerd_fallback.cpp
@@ -82,16 +82,12 @@
     thread.pid = getpid();
     thread.tid = gettid();
     thread.thread_name = get_thread_name(gettid());
-    unwindstack::ArchEnum arch = unwindstack::Regs::CurrentArch();
-    thread.registers.reset(unwindstack::Regs::CreateFromUcontext(arch, ucontext));
+    thread.registers.reset(
+        unwindstack::Regs::CreateFromUcontext(unwindstack::Regs::CurrentArch(), ucontext));
 
     // TODO: Create this once and store it in a global?
     unwindstack::UnwinderFromPid unwinder(kMaxFrames, getpid());
-    if (unwinder.Init(arch)) {
-      dump_backtrace_thread(output_fd, &unwinder, thread);
-    } else {
-      async_safe_format_log(ANDROID_LOG_ERROR, "libc", "Unable to init unwinder.");
-    }
+    dump_backtrace_thread(output_fd, &unwinder, thread);
   }
   __linker_disable_fallback_allocator();
 }
@@ -237,6 +233,8 @@
   // Fetch output fd from tombstoned.
   unique_fd tombstone_socket, output_fd;
   if (!tombstoned_connect(getpid(), &tombstone_socket, &output_fd, kDebuggerdNativeBacktrace)) {
+    async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+                          "missing crash_dump_fallback() in selinux policy?");
     goto exit;
   }
 
diff --git a/debuggerd/libdebuggerd/backtrace.cpp b/debuggerd/libdebuggerd/backtrace.cpp
index f5a873c..c543a83 100644
--- a/debuggerd/libdebuggerd/backtrace.cpp
+++ b/debuggerd/libdebuggerd/backtrace.cpp
@@ -18,8 +18,9 @@
 
 #include "libdebuggerd/backtrace.h"
 
-#include <errno.h>
 #include <dirent.h>
+#include <errno.h>
+#include <inttypes.h>
 #include <limits.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -65,7 +66,11 @@
   unwinder->SetRegs(thread.registers.get());
   unwinder->Unwind();
   if (unwinder->NumFrames() == 0) {
-    _LOG(&log, logtype::THREAD, "Unwind failed: tid = %d", thread.tid);
+    _LOG(&log, logtype::THREAD, "Unwind failed: tid = %d\n", thread.tid);
+    if (unwinder->LastErrorCode() != unwindstack::ERROR_NONE) {
+      _LOG(&log, logtype::THREAD, "  Error code: %s\n", unwinder->LastErrorCodeString());
+      _LOG(&log, logtype::THREAD, "  Error address: 0x%" PRIx64 "\n", unwinder->LastErrorAddress());
+    }
     return;
   }
 
diff --git a/debuggerd/libdebuggerd/include/libdebuggerd/types.h b/debuggerd/libdebuggerd/include/libdebuggerd/types.h
index 04c4b5c..30e75e1 100644
--- a/debuggerd/libdebuggerd/include/libdebuggerd/types.h
+++ b/debuggerd/libdebuggerd/include/libdebuggerd/types.h
@@ -23,6 +23,7 @@
 
 struct ThreadInfo {
   std::unique_ptr<unwindstack::Regs> registers;
+  long tagged_addr_ctrl = -1;
 
   pid_t uid;
 
diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp
index 7af99c9..d88c5a9 100644
--- a/debuggerd/libdebuggerd/tombstone.cpp
+++ b/debuggerd/libdebuggerd/tombstone.cpp
@@ -180,6 +180,9 @@
   _LOG(log, logtype::HEADER, "pid: %d, tid: %d, name: %s  >>> %s <<<\n", thread_info.pid,
        thread_info.tid, thread_info.thread_name.c_str(), thread_info.process_name.c_str());
   _LOG(log, logtype::HEADER, "uid: %d\n", thread_info.uid);
+  if (thread_info.tagged_addr_ctrl != -1) {
+    _LOG(log, logtype::HEADER, "tagged_addr_ctrl: %016lx\n", thread_info.tagged_addr_ctrl);
+  }
 }
 
 static std::string get_addr_string(uint64_t addr) {
@@ -404,7 +407,11 @@
   unwinder->SetRegs(regs_copy.get());
   unwinder->Unwind();
   if (unwinder->NumFrames() == 0) {
-    _LOG(log, logtype::THREAD, "Failed to unwind");
+    _LOG(log, logtype::THREAD, "Failed to unwind\n");
+    if (unwinder->LastErrorCode() != unwindstack::ERROR_NONE) {
+      _LOG(log, logtype::THREAD, "  Error code: %s\n", unwinder->LastErrorCodeString());
+      _LOG(log, logtype::THREAD, "  Error address: 0x%" PRIx64 "\n", unwinder->LastErrorAddress());
+    }
   } else {
     _LOG(log, logtype::BACKTRACE, "\nbacktrace:\n");
     log_backtrace(log, unwinder, "    ");
@@ -575,8 +582,8 @@
       .siginfo = siginfo,
   };
 
-  unwindstack::UnwinderFromPid unwinder(kMaxFrames, pid);
-  if (!unwinder.Init(unwindstack::Regs::CurrentArch())) {
+  unwindstack::UnwinderFromPid unwinder(kMaxFrames, pid, unwindstack::Regs::CurrentArch());
+  if (!unwinder.Init()) {
     LOG(FATAL) << "Failed to init unwinder object.";
   }
 
diff --git a/debuggerd/tombstoned/tombstoned.rc b/debuggerd/tombstoned/tombstoned.rc
index b4a1e71..c39f4e4 100644
--- a/debuggerd/tombstoned/tombstoned.rc
+++ b/debuggerd/tombstoned/tombstoned.rc
@@ -6,6 +6,3 @@
     socket tombstoned_intercept seqpacket 0666 system system
     socket tombstoned_java_trace seqpacket 0666 system system
     writepid /dev/cpuset/system-background/tasks
-
-on post-fs-data
-    start tombstoned
diff --git a/fastboot/Android.bp b/fastboot/Android.bp
index 6673543..fe05553 100644
--- a/fastboot/Android.bp
+++ b/fastboot/Android.bp
@@ -126,7 +126,7 @@
     shared_libs: [
         "android.hardware.boot@1.0",
         "android.hardware.boot@1.1",
-        "android.hardware.fastboot@1.0",
+        "android.hardware.fastboot@1.1",
         "android.hardware.health@2.0",
         "libasyncio",
         "libbase",
@@ -251,7 +251,7 @@
         darwin: {
             srcs: ["usb_osx.cpp"],
         },
-        linux_glibc: {
+        linux: {
             srcs: ["usb_linux.cpp"],
         },
     },
diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp
index 2553353..4601960 100644
--- a/fastboot/device/commands.cpp
+++ b/fastboot/device/commands.cpp
@@ -164,6 +164,28 @@
     return device->WriteOkay(message);
 }
 
+bool OemPostWipeData(FastbootDevice* device) {
+    auto fastboot_hal = device->fastboot_hal();
+    if (!fastboot_hal) {
+        return false;
+    }
+
+    Result ret;
+    auto ret_val = fastboot_hal->doOemSpecificErase([&](Result result) { ret = result; });
+    if (!ret_val.isOk()) {
+        return false;
+    }
+    if (ret.status == Status::NOT_SUPPORTED) {
+        return false;
+    } else if (ret.status != Status::SUCCESS) {
+        device->WriteStatus(FastbootResult::FAIL, ret.message);
+    } else {
+        device->WriteStatus(FastbootResult::OKAY, "Erasing succeeded");
+    }
+
+    return true;
+}
+
 bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args) {
     if (args.size() < 2) {
         return device->WriteStatus(FastbootResult::FAIL, "Invalid arguments");
@@ -184,7 +206,18 @@
         return device->WriteStatus(FastbootResult::FAIL, "Partition doesn't exist");
     }
     if (wipe_block_device(handle.fd(), get_block_device_size(handle.fd())) == 0) {
-        return device->WriteStatus(FastbootResult::OKAY, "Erasing succeeded");
+        //Perform oem PostWipeData if Android userdata partition has been erased
+        bool support_oem_postwipedata = false;
+        if (partition_name == "userdata") {
+            support_oem_postwipedata = OemPostWipeData(device);
+        }
+
+        if (!support_oem_postwipedata) {
+            return device->WriteStatus(FastbootResult::OKAY, "Erasing succeeded");
+        } else {
+            //Write device status in OemPostWipeData(), so just return true
+            return true;
+        }
     }
     return device->WriteStatus(FastbootResult::FAIL, "Erasing failed");
 }
diff --git a/fastboot/device/fastboot_device.cpp b/fastboot/device/fastboot_device.cpp
index 1b0859f..35f3de0 100644
--- a/fastboot/device/fastboot_device.cpp
+++ b/fastboot/device/fastboot_device.cpp
@@ -22,7 +22,7 @@
 #include <android-base/properties.h>
 #include <android-base/strings.h>
 #include <android/hardware/boot/1.0/IBootControl.h>
-#include <android/hardware/fastboot/1.0/IFastboot.h>
+#include <android/hardware/fastboot/1.1/IFastboot.h>
 #include <fs_mgr.h>
 #include <fs_mgr/roots.h>
 #include <healthhalutils/HealthHalUtils.h>
@@ -37,7 +37,7 @@
 using ::android::hardware::hidl_string;
 using ::android::hardware::boot::V1_0::IBootControl;
 using ::android::hardware::boot::V1_0::Slot;
-using ::android::hardware::fastboot::V1_0::IFastboot;
+using ::android::hardware::fastboot::V1_1::IFastboot;
 using ::android::hardware::health::V2_0::get_health_service;
 
 namespace sph = std::placeholders;
@@ -139,7 +139,13 @@
 bool FastbootDevice::HandleData(bool read, std::vector<char>* data) {
     auto read_write_data_size = read ? this->get_transport()->Read(data->data(), data->size())
                                      : this->get_transport()->Write(data->data(), data->size());
-    if (read_write_data_size == -1 || static_cast<size_t>(read_write_data_size) != data->size()) {
+    if (read_write_data_size == -1) {
+        LOG(ERROR) << (read ? "read from" : "write to") << " transport failed";
+        return false;
+    }
+    if (static_cast<size_t>(read_write_data_size) != data->size()) {
+        LOG(ERROR) << (read ? "read" : "write") << " expected " << data->size() << " bytes, got "
+                   << read_write_data_size;
         return false;
     }
     return true;
diff --git a/fastboot/device/fastboot_device.h b/fastboot/device/fastboot_device.h
index bbe8172..23be721 100644
--- a/fastboot/device/fastboot_device.h
+++ b/fastboot/device/fastboot_device.h
@@ -24,7 +24,7 @@
 
 #include <android/hardware/boot/1.0/IBootControl.h>
 #include <android/hardware/boot/1.1/IBootControl.h>
-#include <android/hardware/fastboot/1.0/IFastboot.h>
+#include <android/hardware/fastboot/1.1/IFastboot.h>
 #include <android/hardware/health/2.0/IHealth.h>
 
 #include "commands.h"
@@ -53,7 +53,7 @@
         return boot_control_hal_;
     }
     android::sp<android::hardware::boot::V1_1::IBootControl> boot1_1() { return boot1_1_; }
-    android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal() {
+    android::sp<android::hardware::fastboot::V1_1::IFastboot> fastboot_hal() {
         return fastboot_hal_;
     }
     android::sp<android::hardware::health::V2_0::IHealth> health_hal() { return health_hal_; }
@@ -67,7 +67,7 @@
     android::sp<android::hardware::boot::V1_0::IBootControl> boot_control_hal_;
     android::sp<android::hardware::boot::V1_1::IBootControl> boot1_1_;
     android::sp<android::hardware::health::V2_0::IHealth> health_hal_;
-    android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal_;
+    android::sp<android::hardware::fastboot::V1_1::IFastboot> fastboot_hal_;
     std::vector<char> download_data_;
     std::string active_slot_;
 };
diff --git a/fastboot/device/usb_client.cpp b/fastboot/device/usb_client.cpp
index c653167..2caced4 100644
--- a/fastboot/device/usb_client.cpp
+++ b/fastboot/device/usb_client.cpp
@@ -248,7 +248,12 @@
 }
 
 ssize_t ClientUsbTransport::Read(void* data, size_t len) {
-    if (handle_ == nullptr || len > SSIZE_MAX) {
+    if (handle_ == nullptr) {
+        LOG(ERROR) << "ClientUsbTransport: no handle";
+        return -1;
+    }
+    if (len > SSIZE_MAX) {
+        LOG(ERROR) << "ClientUsbTransport: maximum length exceeds bounds";
         return -1;
     }
     char* char_data = static_cast<char*>(data);
@@ -258,6 +263,7 @@
         auto bytes_read_now =
                 handle_->read(handle_.get(), char_data, bytes_to_read, true /* allow_partial */);
         if (bytes_read_now < 0) {
+            PLOG(ERROR) << "ClientUsbTransport: read failed";
             return bytes_read_total == 0 ? -1 : bytes_read_total;
         }
         bytes_read_total += bytes_read_now;
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index d33c987..4bf791e 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -526,12 +526,15 @@
 
 static bool UnzipToMemory(ZipArchiveHandle zip, const std::string& entry_name,
                           std::vector<char>* out) {
-    ZipEntry zip_entry;
+    ZipEntry64 zip_entry;
     if (FindEntry(zip, entry_name, &zip_entry) != 0) {
         fprintf(stderr, "archive does not contain '%s'\n", entry_name.c_str());
         return false;
     }
 
+    if (zip_entry.uncompressed_length > std::numeric_limits<size_t>::max()) {
+      die("entry '%s' is too large: %" PRIu64, entry_name.c_str(), zip_entry.uncompressed_length);
+    }
     out->resize(zip_entry.uncompressed_length);
 
     fprintf(stderr, "extracting %s (%zu MB) to RAM...\n", entry_name.c_str(),
@@ -637,14 +640,14 @@
 static int unzip_to_file(ZipArchiveHandle zip, const char* entry_name) {
     unique_fd fd(make_temporary_fd(entry_name));
 
-    ZipEntry zip_entry;
+    ZipEntry64 zip_entry;
     if (FindEntry(zip, entry_name, &zip_entry) != 0) {
         fprintf(stderr, "archive does not contain '%s'\n", entry_name);
         errno = ENOENT;
         return -1;
     }
 
-    fprintf(stderr, "extracting %s (%" PRIu32 " MB) to disk...", entry_name,
+    fprintf(stderr, "extracting %s (%" PRIu64 " MB) to disk...", entry_name,
             zip_entry.uncompressed_length / 1024 / 1024);
     double start = now();
     int error = ExtractEntryToFile(zip, &zip_entry, fd);
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 1462cc9..5ff01e1 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -521,13 +521,13 @@
 }
 
 // Enable casefold if needed.
-static void tune_casefold(const std::string& blk_device, const struct ext4_super_block* sb,
-                          int* fs_stat) {
+static void tune_casefold(const std::string& blk_device, const FstabEntry& entry,
+                          const struct ext4_super_block* sb, int* fs_stat) {
     bool has_casefold = (sb->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_CASEFOLD)) != 0;
     bool wants_casefold =
             android::base::GetBoolProperty("external_storage.casefold.enabled", false);
 
-    if (!wants_casefold || has_casefold) return;
+    if (entry.mount_point != "data" || !wants_casefold || has_casefold ) return;
 
     std::string casefold_support;
     if (!android::base::ReadFileToString(SYSFS_EXT4_CASEFOLD, &casefold_support)) {
@@ -696,7 +696,7 @@
             tune_reserved_size(blk_device, entry, &sb, &fs_stat);
             tune_encrypt(blk_device, entry, &sb, &fs_stat);
             tune_verity(blk_device, entry, &sb, &fs_stat);
-            tune_casefold(blk_device, &sb, &fs_stat);
+            tune_casefold(blk_device, entry, &sb, &fs_stat);
             tune_metadata_csum(blk_device, entry, &sb, &fs_stat);
         }
     }
@@ -740,15 +740,33 @@
     unsigned long mountflags = entry.flags;
     int ret = 0;
     int save_errno = 0;
+    int gc_allowance = 0;
+    std::string opts;
+    bool try_f2fs_gc_allowance = is_f2fs(entry.fs_type) && entry.fs_checkpoint_opts.length() > 0;
+    Timer t;
+
     do {
+        if (save_errno == EINVAL && try_f2fs_gc_allowance) {
+            PINFO << "Kernel does not support checkpoint=disable:[n]%, trying without.";
+            try_f2fs_gc_allowance = false;
+        }
+        if (try_f2fs_gc_allowance) {
+            opts = entry.fs_options + entry.fs_checkpoint_opts + ":" +
+                   std::to_string(gc_allowance) + "%";
+        } else {
+            opts = entry.fs_options;
+        }
         if (save_errno == EAGAIN) {
             PINFO << "Retrying mount (source=" << source << ",target=" << target
-                  << ",type=" << entry.fs_type << ")=" << ret << "(" << save_errno << ")";
+                  << ",type=" << entry.fs_type << ", gc_allowance=" << gc_allowance << "%)=" << ret
+                  << "(" << save_errno << ")";
         }
         ret = mount(source.c_str(), target.c_str(), entry.fs_type.c_str(), mountflags,
-                    entry.fs_options.c_str());
+                    opts.c_str());
         save_errno = errno;
-    } while (ret && save_errno == EAGAIN);
+        if (try_f2fs_gc_allowance) gc_allowance += 10;
+    } while ((ret && save_errno == EAGAIN && gc_allowance <= 100) ||
+             (ret && save_errno == EINVAL && try_f2fs_gc_allowance));
     const char* target_missing = "";
     const char* source_missing = "";
     if (save_errno == ENOENT) {
@@ -764,6 +782,8 @@
     if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
         fs_mgr_set_blk_ro(source);
     }
+    android::base::SetProperty("ro.boottime.init.mount." + Basename(target),
+                               std::to_string(t.duration().count()));
     errno = save_errno;
     return ret;
 }
@@ -976,6 +996,19 @@
     }
 }
 
+static void set_type_property(int status) {
+    switch (status) {
+        case FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED:
+            SetProperty("ro.crypto.type", "block");
+            break;
+        case FS_MGR_MNTALL_DEV_FILE_ENCRYPTED:
+        case FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED:
+        case FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION:
+            SetProperty("ro.crypto.type", "file");
+            break;
+    }
+}
+
 static bool call_vdc(const std::vector<std::string>& args, int* ret) {
     std::vector<char const*> argv;
     argv.emplace_back("/system/bin/vdc");
@@ -1079,7 +1112,7 @@
     bool UpdateCheckpointPartition(FstabEntry* entry, const std::string& block_device) {
         if (entry->fs_mgr_flags.checkpoint_fs) {
             if (is_f2fs(entry->fs_type)) {
-                entry->fs_options += ",checkpoint=disable";
+                entry->fs_checkpoint_opts = ",checkpoint=disable";
             } else {
                 LERROR << entry->fs_type << " does not implement checkpoints.";
             }
@@ -1283,14 +1316,15 @@
 // When multiple fstab records share the same mount_point, it will try to mount each
 // one in turn, and ignore any duplicates after a first successful mount.
 // Returns -1 on error, and  FS_MGR_MNTALL_* otherwise.
-int fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
+MountAllResult fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
     int encryptable = FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE;
     int error_count = 0;
     CheckpointManager checkpoint_manager;
     AvbUniquePtr avb_handle(nullptr);
 
+    bool userdata_mounted = false;
     if (fstab->empty()) {
-        return FS_MGR_MNTALL_FAIL;
+        return {FS_MGR_MNTALL_FAIL, userdata_mounted};
     }
 
     // Keep i int to prevent unsigned integer overflow from (i = top_idx - 1),
@@ -1330,7 +1364,7 @@
         }
 
         // Terrible hack to make it possible to remount /data.
-        // TODO: refact fs_mgr_mount_all and get rid of this.
+        // TODO: refactor fs_mgr_mount_all and get rid of this.
         if (mount_mode == MOUNT_MODE_ONLY_USERDATA && current_entry.mount_point != "/data") {
             continue;
         }
@@ -1366,7 +1400,8 @@
                 avb_handle = AvbHandle::Open();
                 if (!avb_handle) {
                     LERROR << "Failed to open AvbHandle";
-                    return FS_MGR_MNTALL_FAIL;
+                    set_type_property(encryptable);
+                    return {FS_MGR_MNTALL_FAIL, userdata_mounted};
                 }
             }
             if (avb_handle->SetUpAvbHashtree(&current_entry, true /* wait_for_verity_dev */) ==
@@ -1408,7 +1443,7 @@
 
             if (status == FS_MGR_MNTALL_FAIL) {
                 // Fatal error - no point continuing.
-                return status;
+                return {status, userdata_mounted};
             }
 
             if (status != FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE) {
@@ -1422,11 +1457,15 @@
                                    attempted_entry.mount_point},
                                   nullptr)) {
                         LERROR << "Encryption failed";
-                        return FS_MGR_MNTALL_FAIL;
+                        set_type_property(encryptable);
+                        return {FS_MGR_MNTALL_FAIL, userdata_mounted};
                     }
                 }
             }
 
+            if (current_entry.mount_point == "/data") {
+                userdata_mounted = true;
+            }
             // Success!  Go get the next one.
             continue;
         }
@@ -1519,14 +1558,16 @@
         }
     }
 
+    set_type_property(encryptable);
+
 #if ALLOW_ADBD_DISABLE_VERITY == 1  // "userdebug" build
     fs_mgr_overlayfs_mount_all(fstab);
 #endif
 
     if (error_count) {
-        return FS_MGR_MNTALL_FAIL;
+        return {FS_MGR_MNTALL_FAIL, userdata_mounted};
     } else {
-        return encryptable;
+        return {encryptable, userdata_mounted};
     }
 }
 
@@ -1748,8 +1789,8 @@
         }
         LINFO << "Remounting /data";
         // TODO(b/143970043): remove this hack after fs_mgr_mount_all is refactored.
-        int result = fs_mgr_mount_all(fstab, MOUNT_MODE_ONLY_USERDATA);
-        return result == FS_MGR_MNTALL_FAIL ? -1 : 0;
+        auto result = fs_mgr_mount_all(fstab, MOUNT_MODE_ONLY_USERDATA);
+        return result.code == FS_MGR_MNTALL_FAIL ? -1 : 0;
     }
     return 0;
 }
@@ -1931,21 +1972,19 @@
     return true;
 }
 
-static bool PrepareZramDevice(const std::string& loop, off64_t size, const std::string& bdev) {
-    if (loop.empty() && bdev.empty()) return true;
+static bool PrepareZramBackingDevice(off64_t size) {
 
-    if (bdev.length()) {
-        return InstallZramDevice(bdev);
-    }
+    constexpr const char* file_path = "/data/per_boot/zram_swap";
+    if (size == 0) return true;
 
     // Prepare target path
-    unique_fd target_fd(TEMP_FAILURE_RETRY(open(loop.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0600)));
+    unique_fd target_fd(TEMP_FAILURE_RETRY(open(file_path, O_RDWR | O_CREAT | O_CLOEXEC, 0600)));
     if (target_fd.get() == -1) {
-        PERROR << "Cannot open target path: " << loop;
+        PERROR << "Cannot open target path: " << file_path;
         return false;
     }
     if (fallocate(target_fd.get(), 0, 0, size) < 0) {
-        PERROR << "Cannot truncate target path: " << loop;
+        PERROR << "Cannot truncate target path: " << file_path;
         return false;
     }
 
@@ -1977,11 +2016,10 @@
             continue;
         }
 
-        if (!PrepareZramDevice(entry.zram_loopback_path, entry.zram_loopback_size, entry.zram_backing_dev_path)) {
-            LERROR << "Skipping losetup for '" << entry.blk_device << "'";
-        }
-
         if (entry.zram_size > 0) {
+	    if (!PrepareZramBackingDevice(entry.zram_backingdev_size)) {
+                LERROR << "Failure of zram backing device file for '" << entry.blk_device << "'";
+            }
             // A zram_size was specified, so we need to configure the
             // device.  There is no point in having multiple zram devices
             // on a system (all the memory comes from the same pool) so
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 54102ec..63b7ad2 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -286,15 +286,10 @@
         } else if (StartsWith(flag, "sysfs_path=")) {
             // The path to trigger device gc by idle-maint of vold.
             entry->sysfs_path = arg;
-        } else if (StartsWith(flag, "zram_loopback_path=")) {
-            // The path to use loopback for zram.
-            entry->zram_loopback_path = arg;
-        } else if (StartsWith(flag, "zram_loopback_size=")) {
-            if (!ParseByteCount(arg, &entry->zram_loopback_size)) {
-                LWARNING << "Warning: zram_loopback_size= flag malformed: " << arg;
+        } else if (StartsWith(flag, "zram_backingdev_size=")) {
+            if (!ParseByteCount(arg, &entry->zram_backingdev_size)) {
+                LWARNING << "Warning: zram_backingdev_size= flag malformed: " << arg;
             }
-        } else if (StartsWith(flag, "zram_backing_dev_path=")) {
-            entry->zram_backing_dev_path = arg;
         } else {
             LWARNING << "Warning: unknown flag: " << flag;
         }
@@ -640,13 +635,14 @@
             entry.fs_mgr_flags.wait = true;
             entry.fs_mgr_flags.logical = true;
             entry.fs_mgr_flags.first_stage_mount = true;
+            fstab->emplace_back(entry);
         } else {
             // If the corresponding partition exists, transform all its Fstab
             // by pointing .blk_device to the DSU partition.
             for (auto&& entry : entries) {
                 entry->blk_device = partition;
                 // AVB keys for DSU should always be under kDsuKeysDir.
-                entry->avb_keys += kDsuKeysDir;
+                entry->avb_keys = kDsuKeysDir;
             }
             // Make sure the ext4 is included to support GSI.
             auto partition_ext4 =
diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h
index 2a67b8c..11e3664 100644
--- a/fs_mgr/include/fs_mgr.h
+++ b/fs_mgr/include/fs_mgr.h
@@ -60,8 +60,20 @@
 #define FS_MGR_MNTALL_DEV_NOT_ENCRYPTED 1
 #define FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE 0
 #define FS_MGR_MNTALL_FAIL (-1)
+
+struct MountAllResult {
+    // One of the FS_MGR_MNTALL_* returned code defined above.
+    int code;
+    // Whether userdata was mounted as a result of |fs_mgr_mount_all| call.
+    bool userdata_mounted;
+};
+
 // fs_mgr_mount_all() updates fstab entries that reference device-mapper.
-int fs_mgr_mount_all(android::fs_mgr::Fstab* fstab, int mount_mode);
+// Returns a |MountAllResult|. The first element is one of the FS_MNG_MNTALL_* return codes
+// defined above, and the second element tells whether this call to fs_mgr_mount_all was responsible
+// for mounting userdata. Later is required for init to correctly enqueue fs-related events as part
+// of userdata remount during userspace reboot.
+MountAllResult fs_mgr_mount_all(android::fs_mgr::Fstab* fstab, int mount_mode);
 
 #define FS_MGR_DOMNT_FAILED (-1)
 #define FS_MGR_DOMNT_BUSY (-2)
diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h
index 7216402..4093445 100644
--- a/fs_mgr/include_fstab/fstab/fstab.h
+++ b/fs_mgr/include_fstab/fstab/fstab.h
@@ -36,6 +36,7 @@
     std::string fs_type;
     unsigned long flags = 0;
     std::string fs_options;
+    std::string fs_checkpoint_opts;
     std::string key_loc;
     std::string metadata_key_dir;
     std::string metadata_encryption;
@@ -51,9 +52,7 @@
     off64_t logical_blk_size = 0;
     std::string sysfs_path;
     std::string vbmeta_partition;
-    std::string zram_loopback_path;
-    uint64_t zram_loopback_size = 512 * 1024 * 1024;  // 512MB by default;
-    std::string zram_backing_dev_path;
+    uint64_t zram_backingdev_size = 0;
     std::string avb_keys;
 
     struct FsMgrFlags {
diff --git a/fs_mgr/libdm/Android.bp b/fs_mgr/libdm/Android.bp
index e425284..a0bc44d 100644
--- a/fs_mgr/libdm/Android.bp
+++ b/fs_mgr/libdm/Android.bp
@@ -99,7 +99,3 @@
         "liblog",
     ],
 }
-
-vts_config {
-    name: "VtsKernelLibdmTest",
-}
diff --git a/fs_mgr/libdm/AndroidTest.xml b/fs_mgr/libdm/AndroidTest.xml
deleted file mode 100644
index b4e0c23..0000000
--- a/fs_mgr/libdm/AndroidTest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 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.
--->
-<configuration description="Config for VTS VtsKernelLibdmTest">
-    <option name="config-descriptor:metadata" key="plan" value="vts-kernel" />
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
-        <option name="abort-on-push-failure" value="false"/>
-        <option name="push-group" value="HostDrivenTest.push"/>
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
-      <option name="test-module-name" value="VtsKernelLibdmTest"/>
-        <option name="binary-test-source" value="_32bit::DATA/nativetest/libdm_test/libdm_test" />
-        <option name="binary-test-source" value="_64bit::DATA/nativetest64/libdm_test/libdm_test" />
-        <option name="binary-test-type" value="gtest"/>
-        <option name="test-timeout" value="1m"/>
-        <option name="precondition-first-api-level" value="29" />
-    </test>
-</configuration>
-
diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp
index 7912688..bb7d8b3 100644
--- a/fs_mgr/libdm/dm.cpp
+++ b/fs_mgr/libdm/dm.cpp
@@ -427,6 +427,20 @@
     return true;
 }
 
+// Accepts a device mapper device name (like system_a, vendor_b etc) and
+// returns its UUID.
+bool DeviceMapper::GetDmDeviceUuidByName(const std::string& name, std::string* uuid) {
+    struct dm_ioctl io;
+    InitIo(&io, name);
+    if (ioctl(fd_, DM_DEV_STATUS, &io) < 0) {
+        PLOG(WARNING) << "DM_DEV_STATUS failed for " << name;
+        return false;
+    }
+
+    *uuid = std::string(io.uuid);
+    return true;
+}
+
 bool DeviceMapper::GetDeviceNumber(const std::string& name, dev_t* dev) {
     struct dm_ioctl io;
     InitIo(&io, name);
diff --git a/fs_mgr/libdm/include/libdm/dm.h b/fs_mgr/libdm/include/libdm/dm.h
index abe9c4c..5d6db46 100644
--- a/fs_mgr/libdm/include/libdm/dm.h
+++ b/fs_mgr/libdm/include/libdm/dm.h
@@ -172,6 +172,13 @@
     // could race with ueventd.
     bool GetDmDevicePathByName(const std::string& name, std::string* path);
 
+    // Returns the device mapper UUID for a given name.  If the device does not
+    // exist, false is returned, and the path parameter is not set.
+    //
+    // WaitForFile() should not be used in conjunction with this call, since it
+    // could race with ueventd.
+    bool GetDmDeviceUuidByName(const std::string& name, std::string* path);
+
     // Returns a device's unique path as generated by ueventd. This will return
     // true as long as the device has been created, even if ueventd has not
     // processed it yet.
diff --git a/fs_mgr/libfiemap/image_manager.cpp b/fs_mgr/libfiemap/image_manager.cpp
index f32e0eb..93fc131 100644
--- a/fs_mgr/libfiemap/image_manager.cpp
+++ b/fs_mgr/libfiemap/image_manager.cpp
@@ -640,16 +640,22 @@
         return false;
     }
 
+    bool ok = true;
     for (const auto& partition : metadata->partitions) {
         auto name = GetPartitionName(partition);
         auto image_path = GetImageHeaderPath(name);
         auto fiemap = SplitFiemap::Open(image_path);
-        if (!fiemap || !fiemap->HasPinnedExtents()) {
-            LOG(ERROR) << "Image is missing or was moved: " << image_path;
-            return false;
+        if (fiemap == nullptr) {
+            LOG(ERROR) << "SplitFiemap::Open(\"" << image_path << "\") failed";
+            ok = false;
+            continue;
+        }
+        if (!fiemap->HasPinnedExtents()) {
+            LOG(ERROR) << "Image doesn't have pinned extents: " << image_path;
+            ok = false;
         }
     }
-    return true;
+    return ok;
 }
 
 bool ImageManager::DisableImage(const std::string& name) {
diff --git a/fs_mgr/liblp/Android.bp b/fs_mgr/liblp/Android.bp
index a779a78..9517bd3 100644
--- a/fs_mgr/liblp/Android.bp
+++ b/fs_mgr/liblp/Android.bp
@@ -107,7 +107,3 @@
     name: "vts_kernel_liblp_test",
     defaults: ["liblp_test_defaults"],
 }
-
-vts_config {
-    name: "VtsKernelLiblpTest",
-}
diff --git a/fs_mgr/liblp/AndroidTest.xml b/fs_mgr/liblp/AndroidTest.xml
deleted file mode 100644
index 2eb0ad1..0000000
--- a/fs_mgr/liblp/AndroidTest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 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.
--->
-<configuration description="Config for VTS VtsKernelLiblpTest">
-    <option name="config-descriptor:metadata" key="plan" value="vts-kernel" />
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
-        <option name="abort-on-push-failure" value="false"/>
-        <option name="push-group" value="HostDrivenTest.push"/>
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
-      <option name="test-module-name" value="VtsKernelLiblpTest"/>
-        <option name="binary-test-source" value="_32bit::DATA/nativetest/vts_kernel_liblp_test/vts_kernel_liblp_test" />
-        <option name="binary-test-source" value="_64bit::DATA/nativetest64/vts_kernel_liblp_test/vts_kernel_liblp_test" />
-        <option name="binary-test-type" value="gtest"/>
-        <option name="test-timeout" value="1m"/>
-        <option name="precondition-first-api-level" value="29" />
-    </test>
-</configuration>
-
diff --git a/fs_mgr/liblp/partition_opener.cpp b/fs_mgr/liblp/partition_opener.cpp
index 3d3dde6..4696ff1 100644
--- a/fs_mgr/liblp/partition_opener.cpp
+++ b/fs_mgr/liblp/partition_opener.cpp
@@ -38,6 +38,9 @@
 namespace {
 
 std::string GetPartitionAbsolutePath(const std::string& path) {
+#if !defined(__ANDROID__)
+    return path;
+#else
     if (android::base::StartsWith(path, "/")) {
         return path;
     }
@@ -56,6 +59,7 @@
         }
     }
     return by_name;
+#endif
 }
 
 bool GetBlockDeviceInfo(const std::string& block_device, BlockDeviceInfo* device_info) {
diff --git a/fs_mgr/libsnapshot/Android.bp b/fs_mgr/libsnapshot/Android.bp
index eaef180..6e81c8b 100644
--- a/fs_mgr/libsnapshot/Android.bp
+++ b/fs_mgr/libsnapshot/Android.bp
@@ -30,6 +30,7 @@
     static_libs: [
         "libdm",
         "libfstab",
+        "libsnapshot_cow",
         "update_metadata-protos",
     ],
     whole_static_libs: [
@@ -38,7 +39,9 @@
         "libfstab",
     ],
     header_libs: [
+        "libchrome",
         "libfiemap_headers",
+        "libupdate_engine_headers",
     ],
     export_static_lib_headers: [
         "update_metadata-protos",
@@ -122,6 +125,74 @@
     ],
 }
 
+cc_defaults {
+    name: "libsnapshot_cow_defaults",
+    defaults: [
+        "fs_mgr_defaults",
+    ],
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-Wall",
+        "-Werror",
+    ],
+    export_include_dirs: ["include"],
+    srcs: [
+        "cow_decompress.cpp",
+        "cow_reader.cpp",
+        "cow_writer.cpp",
+    ],
+}
+
+cc_library_static {
+    name: "libsnapshot_cow",
+    defaults: [
+        "libsnapshot_cow_defaults",
+    ],
+    host_supported: true,
+    recovery_available: true,
+    shared_libs: [
+        "libbase",
+        "liblog",
+    ],
+    static_libs: [
+        "libbrotli",
+        "libz",
+    ],
+    ramdisk_available: true,
+}
+
+cc_defaults {
+    name: "libsnapshot_snapuserd_defaults",
+    defaults: [
+        "fs_mgr_defaults",
+    ],
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-Wall",
+        "-Werror",
+    ],
+    export_include_dirs: ["include"],
+    srcs: [
+        "snapuserd_client.cpp",
+    ],
+}
+
+cc_library_static {
+    name: "libsnapshot_snapuserd",
+    defaults: [
+        "libsnapshot_snapuserd_defaults",
+    ],
+    recovery_available: true,
+    static_libs: [
+        "libcutils_sockets",
+    ],
+    shared_libs: [
+        "libbase",
+        "liblog",
+    ],
+    ramdisk_available: true,
+}
+
 cc_library_static {
     name: "libsnapshot_test_helpers",
     defaults: ["libsnapshot_defaults"],
@@ -196,12 +267,6 @@
     defaults: ["libsnapshot_test_defaults"],
 }
 
-// For VTS 10
-vts_config {
-    name: "VtsLibsnapshotTest",
-    test_config: "VtsLibsnapshotTest.xml"
-}
-
 cc_binary {
     name: "snapshotctl",
     srcs: [
@@ -277,8 +342,10 @@
         "libprotobuf-mutator",
     ],
     header_libs: [
+        "libchrome",
         "libfiemap_headers",
         "libstorage_literals_headers",
+        "libupdate_engine_headers",
     ],
     proto: {
         type: "full",
@@ -313,8 +380,13 @@
 
 cc_defaults {
     name: "snapuserd_defaults",
+    defaults: [
+        "fs_mgr_defaults",
+    ],
     srcs: [
+	"snapuserd_server.cpp",
         "snapuserd.cpp",
+	"snapuserd_daemon.cpp",
     ],
 
     cflags: [
@@ -324,8 +396,12 @@
 
     static_libs: [
         "libbase",
+        "libbrotli",
+	"libcutils_sockets",
         "liblog",
         "libdm",
+        "libz",
+        "libsnapshot_cow",
     ],
 }
 
@@ -341,5 +417,134 @@
 
     ramdisk: true,
     static_executable: true,
-    system_shared_libs: [],
+}
+
+cc_test {
+    name: "cow_api_test",
+    defaults: [
+        "fs_mgr_defaults",
+    ],
+    srcs: [
+        "cow_api_test.cpp",
+    ],
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-Wall",
+        "-Werror",
+    ],
+    shared_libs: [
+        "libbase",
+        "libcrypto",
+        "liblog",
+        "libz",
+    ],
+    static_libs: [
+        "libbrotli",
+        "libgtest",
+        "libsnapshot_cow",
+    ],
+    test_min_api_level: 30,
+    auto_gen_config: true,
+    require_root: false,
+    host_supported: true,
+}
+
+cc_binary {
+    name: "make_cow_from_ab_ota",
+    host_supported: true,
+    device_supported: false,
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-Wall",
+        "-Werror",
+    ],
+    static_libs: [
+        "libbase",
+        "libbspatch",
+        "libbrotli",
+        "libbz",
+        "libchrome",
+        "libcrypto",
+        "libgflags",
+        "liblog",
+        "libprotobuf-cpp-lite",
+        "libpuffpatch",
+        "libsnapshot_cow",
+        "libsparse",
+        "libxz",
+        "libz",
+        "libziparchive",
+        "update_metadata-protos",
+    ],
+    srcs: [
+        "make_cow_from_ab_ota.cpp",
+    ],
+    target: {
+        darwin: {
+            enabled: false,
+        },
+    },
+}
+
+cc_binary {
+    name: "estimate_cow_from_nonab_ota",
+    host_supported: true,
+    device_supported: false,
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-Wall",
+        "-Werror",
+    ],
+    static_libs: [
+        "libbase",
+        "libbrotli",
+        "libbz",
+        "libcrypto",
+        "libgflags",
+        "liblog",
+        "libsnapshot_cow",
+        "libsparse",
+        "libz",
+        "libziparchive",
+    ],
+    srcs: [
+        "estimate_cow_from_nonab_ota.cpp",
+    ],
+    target: {
+        darwin: {
+            enabled: false,
+        },
+    },
+}
+
+cc_test {
+    name: "cow_snapuserd_test",
+    defaults: [
+        "fs_mgr_defaults",
+    ],
+    srcs: [
+        "cow_snapuserd_test.cpp",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    shared_libs: [
+        "libbase",
+        "liblog",
+    ],
+    static_libs: [
+        "libbrotli",
+        "libgtest",
+        "libsnapshot_cow",
+	"libsnapshot_snapuserd",
+        "libcutils_sockets",
+        "libz",
+    ],
+    header_libs: [
+        "libstorage_literals_headers",
+    ],
+    test_min_api_level: 30,
+    auto_gen_config: true,
+    require_root: false,
 }
diff --git a/fs_mgr/libsnapshot/VtsLibsnapshotTest.xml b/fs_mgr/libsnapshot/VtsLibsnapshotTest.xml
deleted file mode 100644
index b53b51e..0000000
--- a/fs_mgr/libsnapshot/VtsLibsnapshotTest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 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.
--->
-<configuration description="Config for VTS VtsLibsnapshotTest">
-    <option name="config-descriptor:metadata" key="plan" value="vts-kernel"/>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
-        <option name="abort-on-push-failure" value="false"/>
-        <option name="push-group" value="HostDrivenTest.push"/>
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
-        <option name="test-module-name" value="VtsLibsnapshotTest"/>
-        <option name="binary-test-source" value="_32bit::DATA/nativetest/vts_libsnapshot_test/vts_libsnapshot_test"/>
-        <option name="binary-test-source" value="_64bit::DATA/nativetest64/vts_libsnapshot_test/vts_libsnapshot_test"/>
-        <option name="binary-test-type" value="gtest"/>
-        <option name="test-timeout" value="5m"/>
-    </test>
-</configuration>
diff --git a/fs_mgr/libsnapshot/cow_api_test.cpp b/fs_mgr/libsnapshot/cow_api_test.cpp
new file mode 100644
index 0000000..40d5efb
--- /dev/null
+++ b/fs_mgr/libsnapshot/cow_api_test.cpp
@@ -0,0 +1,334 @@
+// Copyright (C) 2018 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/stat.h>
+
+#include <cstdio>
+#include <iostream>
+#include <memory>
+#include <string_view>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <gtest/gtest.h>
+#include <libsnapshot/cow_reader.h>
+#include <libsnapshot/cow_writer.h>
+
+namespace android {
+namespace snapshot {
+
+class CowTest : public ::testing::Test {
+  protected:
+    virtual void SetUp() override {
+        cow_ = std::make_unique<TemporaryFile>();
+        ASSERT_GE(cow_->fd, 0) << strerror(errno);
+    }
+
+    virtual void TearDown() override { cow_ = nullptr; }
+
+    std::unique_ptr<TemporaryFile> cow_;
+};
+
+// Sink that always appends to the end of a string.
+class StringSink : public IByteSink {
+  public:
+    void* GetBuffer(size_t requested, size_t* actual) override {
+        size_t old_size = stream_.size();
+        stream_.resize(old_size + requested, '\0');
+        *actual = requested;
+        return stream_.data() + old_size;
+    }
+    bool ReturnData(void*, size_t) override { return true; }
+    void Reset() { stream_.clear(); }
+
+    std::string& stream() { return stream_; }
+
+  private:
+    std::string stream_;
+};
+
+TEST_F(CowTest, ReadWrite) {
+    CowOptions options;
+    CowWriter writer(options);
+
+    ASSERT_TRUE(writer.Initialize(cow_->fd));
+
+    std::string data = "This is some data, believe it";
+    data.resize(options.block_size, '\0');
+
+    ASSERT_TRUE(writer.AddCopy(10, 20));
+    ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
+    ASSERT_TRUE(writer.AddZeroBlocks(51, 2));
+    ASSERT_TRUE(writer.Flush());
+
+    ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
+
+    CowReader reader;
+    CowHeader header;
+    ASSERT_TRUE(reader.Parse(cow_->fd));
+    ASSERT_TRUE(reader.GetHeader(&header));
+    ASSERT_EQ(header.magic, kCowMagicNumber);
+    ASSERT_EQ(header.major_version, kCowVersionMajor);
+    ASSERT_EQ(header.minor_version, kCowVersionMinor);
+    ASSERT_EQ(header.block_size, options.block_size);
+    ASSERT_EQ(header.num_ops, 4);
+
+    auto iter = reader.GetOpIter();
+    ASSERT_NE(iter, nullptr);
+    ASSERT_FALSE(iter->Done());
+    auto op = &iter->Get();
+
+    ASSERT_EQ(op->type, kCowCopyOp);
+    ASSERT_EQ(op->compression, kCowCompressNone);
+    ASSERT_EQ(op->data_length, 0);
+    ASSERT_EQ(op->new_block, 10);
+    ASSERT_EQ(op->source, 20);
+
+    StringSink sink;
+
+    iter->Next();
+    ASSERT_FALSE(iter->Done());
+    op = &iter->Get();
+
+    ASSERT_EQ(op->type, kCowReplaceOp);
+    ASSERT_EQ(op->compression, kCowCompressNone);
+    ASSERT_EQ(op->data_length, 4096);
+    ASSERT_EQ(op->new_block, 50);
+    ASSERT_EQ(op->source, 106);
+    ASSERT_TRUE(reader.ReadData(*op, &sink));
+    ASSERT_EQ(sink.stream(), data);
+
+    iter->Next();
+    ASSERT_FALSE(iter->Done());
+    op = &iter->Get();
+
+    // Note: the zero operation gets split into two blocks.
+    ASSERT_EQ(op->type, kCowZeroOp);
+    ASSERT_EQ(op->compression, kCowCompressNone);
+    ASSERT_EQ(op->data_length, 0);
+    ASSERT_EQ(op->new_block, 51);
+    ASSERT_EQ(op->source, 0);
+
+    iter->Next();
+    ASSERT_FALSE(iter->Done());
+    op = &iter->Get();
+
+    ASSERT_EQ(op->type, kCowZeroOp);
+    ASSERT_EQ(op->compression, kCowCompressNone);
+    ASSERT_EQ(op->data_length, 0);
+    ASSERT_EQ(op->new_block, 52);
+    ASSERT_EQ(op->source, 0);
+
+    iter->Next();
+    ASSERT_TRUE(iter->Done());
+}
+
+TEST_F(CowTest, CompressGz) {
+    CowOptions options;
+    options.compression = "gz";
+    CowWriter writer(options);
+
+    ASSERT_TRUE(writer.Initialize(cow_->fd));
+
+    std::string data = "This is some data, believe it";
+    data.resize(options.block_size, '\0');
+
+    ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
+    ASSERT_TRUE(writer.Flush());
+
+    ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
+
+    CowReader reader;
+    ASSERT_TRUE(reader.Parse(cow_->fd));
+
+    auto iter = reader.GetOpIter();
+    ASSERT_NE(iter, nullptr);
+    ASSERT_FALSE(iter->Done());
+    auto op = &iter->Get();
+
+    StringSink sink;
+
+    ASSERT_EQ(op->type, kCowReplaceOp);
+    ASSERT_EQ(op->compression, kCowCompressGz);
+    ASSERT_EQ(op->data_length, 56);  // compressed!
+    ASSERT_EQ(op->new_block, 50);
+    ASSERT_EQ(op->source, 106);
+    ASSERT_TRUE(reader.ReadData(*op, &sink));
+    ASSERT_EQ(sink.stream(), data);
+
+    iter->Next();
+    ASSERT_TRUE(iter->Done());
+}
+
+TEST_F(CowTest, CompressTwoBlocks) {
+    CowOptions options;
+    options.compression = "gz";
+    CowWriter writer(options);
+
+    ASSERT_TRUE(writer.Initialize(cow_->fd));
+
+    std::string data = "This is some data, believe it";
+    data.resize(options.block_size * 2, '\0');
+
+    ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
+    ASSERT_TRUE(writer.Flush());
+
+    ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
+
+    CowReader reader;
+    ASSERT_TRUE(reader.Parse(cow_->fd));
+
+    auto iter = reader.GetOpIter();
+    ASSERT_NE(iter, nullptr);
+    ASSERT_FALSE(iter->Done());
+    iter->Next();
+    ASSERT_FALSE(iter->Done());
+
+    StringSink sink;
+
+    auto op = &iter->Get();
+    ASSERT_EQ(op->type, kCowReplaceOp);
+    ASSERT_EQ(op->compression, kCowCompressGz);
+    ASSERT_EQ(op->new_block, 51);
+    ASSERT_TRUE(reader.ReadData(*op, &sink));
+}
+
+// Only return 1-byte buffers, to stress test the partial read logic in
+// CowReader.
+class HorribleStringSink : public StringSink {
+  public:
+    void* GetBuffer(size_t, size_t* actual) override { return StringSink::GetBuffer(1, actual); }
+};
+
+class CompressionTest : public CowTest, public testing::WithParamInterface<const char*> {};
+
+TEST_P(CompressionTest, HorribleSink) {
+    CowOptions options;
+    options.compression = GetParam();
+    CowWriter writer(options);
+
+    ASSERT_TRUE(writer.Initialize(cow_->fd));
+
+    std::string data = "This is some data, believe it";
+    data.resize(options.block_size, '\0');
+
+    ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
+    ASSERT_TRUE(writer.Flush());
+
+    ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
+
+    CowReader reader;
+    ASSERT_TRUE(reader.Parse(cow_->fd));
+
+    auto iter = reader.GetOpIter();
+    ASSERT_NE(iter, nullptr);
+    ASSERT_FALSE(iter->Done());
+
+    HorribleStringSink sink;
+    auto op = &iter->Get();
+    ASSERT_TRUE(reader.ReadData(*op, &sink));
+    ASSERT_EQ(sink.stream(), data);
+}
+
+INSTANTIATE_TEST_SUITE_P(CowApi, CompressionTest, testing::Values("none", "gz", "brotli"));
+
+TEST_F(CowTest, GetSize) {
+    CowOptions options;
+    CowWriter writer(options);
+    if (ftruncate(cow_->fd, 0) < 0) {
+        perror("Fails to set temp file size");
+        FAIL();
+    }
+    ASSERT_TRUE(writer.Initialize(cow_->fd));
+
+    std::string data = "This is some data, believe it";
+    data.resize(options.block_size, '\0');
+
+    ASSERT_TRUE(writer.AddCopy(10, 20));
+    ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
+    ASSERT_TRUE(writer.AddZeroBlocks(51, 2));
+    auto size_before = writer.GetCowSize();
+    ASSERT_TRUE(writer.Flush());
+    auto size_after = writer.GetCowSize();
+    ASSERT_EQ(size_before, size_after);
+    struct stat buf;
+
+    if (fstat(cow_->fd, &buf) < 0) {
+        perror("Fails to determine size of cow image written");
+        FAIL();
+    }
+    ASSERT_EQ(buf.st_size, writer.GetCowSize());
+}
+
+TEST_F(CowTest, Append) {
+    CowOptions options;
+    auto writer = std::make_unique<CowWriter>(options);
+    ASSERT_TRUE(writer->Initialize(cow_->fd));
+
+    std::string data = "This is some data, believe it";
+    data.resize(options.block_size, '\0');
+    ASSERT_TRUE(writer->AddRawBlocks(50, data.data(), data.size()));
+    ASSERT_TRUE(writer->Flush());
+
+    ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
+
+    writer = std::make_unique<CowWriter>(options);
+    ASSERT_TRUE(writer->Initialize(cow_->fd, CowWriter::OpenMode::APPEND));
+
+    std::string data2 = "More data!";
+    data2.resize(options.block_size, '\0');
+    ASSERT_TRUE(writer->AddRawBlocks(51, data2.data(), data2.size()));
+    ASSERT_TRUE(writer->Flush());
+
+    ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
+
+    struct stat buf;
+    ASSERT_EQ(fstat(cow_->fd, &buf), 0);
+    ASSERT_EQ(buf.st_size, writer->GetCowSize());
+
+    // Read back both operations.
+    CowReader reader;
+    ASSERT_TRUE(reader.Parse(cow_->fd));
+
+    StringSink sink;
+
+    auto iter = reader.GetOpIter();
+    ASSERT_NE(iter, nullptr);
+
+    ASSERT_FALSE(iter->Done());
+    auto op = &iter->Get();
+    ASSERT_EQ(op->type, kCowReplaceOp);
+    ASSERT_TRUE(reader.ReadData(*op, &sink));
+    ASSERT_EQ(sink.stream(), data);
+
+    iter->Next();
+    sink.Reset();
+
+    ASSERT_FALSE(iter->Done());
+    op = &iter->Get();
+    ASSERT_EQ(op->type, kCowReplaceOp);
+    ASSERT_TRUE(reader.ReadData(*op, &sink));
+    ASSERT_EQ(sink.stream(), data2);
+
+    iter->Next();
+    ASSERT_TRUE(iter->Done());
+}
+
+}  // namespace snapshot
+}  // namespace android
+
+int main(int argc, char** argv) {
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}
diff --git a/fs_mgr/libsnapshot/cow_decompress.cpp b/fs_mgr/libsnapshot/cow_decompress.cpp
new file mode 100644
index 0000000..faceafe
--- /dev/null
+++ b/fs_mgr/libsnapshot/cow_decompress.cpp
@@ -0,0 +1,264 @@
+//
+// Copyright (C) 2020 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 "cow_decompress.h"
+
+#include <utility>
+
+#include <android-base/logging.h>
+#include <brotli/decode.h>
+#include <zlib.h>
+
+namespace android {
+namespace snapshot {
+
+class NoDecompressor final : public IDecompressor {
+  public:
+    bool Decompress(size_t) override;
+};
+
+bool NoDecompressor::Decompress(size_t) {
+    size_t stream_remaining = stream_->Size();
+    while (stream_remaining) {
+        size_t buffer_size = stream_remaining;
+        uint8_t* buffer = reinterpret_cast<uint8_t*>(sink_->GetBuffer(buffer_size, &buffer_size));
+        if (!buffer) {
+            LOG(ERROR) << "Could not acquire buffer from sink";
+            return false;
+        }
+
+        // Read until we can fill the buffer.
+        uint8_t* buffer_pos = buffer;
+        size_t bytes_to_read = std::min(buffer_size, stream_remaining);
+        while (bytes_to_read) {
+            size_t read;
+            if (!stream_->Read(buffer_pos, bytes_to_read, &read)) {
+                return false;
+            }
+            if (!read) {
+                LOG(ERROR) << "Stream ended prematurely";
+                return false;
+            }
+            if (!sink_->ReturnData(buffer_pos, read)) {
+                LOG(ERROR) << "Could not return buffer to sink";
+                return false;
+            }
+            buffer_pos += read;
+            bytes_to_read -= read;
+            stream_remaining -= read;
+        }
+    }
+    return true;
+}
+
+std::unique_ptr<IDecompressor> IDecompressor::Uncompressed() {
+    return std::unique_ptr<IDecompressor>(new NoDecompressor());
+}
+
+// Read chunks of the COW and incrementally stream them to the decoder.
+class StreamDecompressor : public IDecompressor {
+  public:
+    bool Decompress(size_t output_bytes) override;
+
+    virtual bool Init() = 0;
+    virtual bool DecompressInput(const uint8_t* data, size_t length) = 0;
+    virtual bool Done() = 0;
+
+  protected:
+    bool GetFreshBuffer();
+
+    size_t output_bytes_;
+    size_t stream_remaining_;
+    uint8_t* output_buffer_ = nullptr;
+    size_t output_buffer_remaining_ = 0;
+};
+
+static constexpr size_t kChunkSize = 4096;
+
+bool StreamDecompressor::Decompress(size_t output_bytes) {
+    if (!Init()) {
+        return false;
+    }
+
+    stream_remaining_ = stream_->Size();
+    output_bytes_ = output_bytes;
+
+    uint8_t chunk[kChunkSize];
+    while (stream_remaining_) {
+        size_t read = std::min(stream_remaining_, sizeof(chunk));
+        if (!stream_->Read(chunk, read, &read)) {
+            return false;
+        }
+        if (!read) {
+            LOG(ERROR) << "Stream ended prematurely";
+            return false;
+        }
+        if (!DecompressInput(chunk, read)) {
+            return false;
+        }
+
+        stream_remaining_ -= read;
+
+        if (stream_remaining_ && Done()) {
+            LOG(ERROR) << "Decompressor terminated early";
+            return false;
+        }
+    }
+    if (!Done()) {
+        LOG(ERROR) << "Decompressor expected more bytes";
+        return false;
+    }
+    return true;
+}
+
+bool StreamDecompressor::GetFreshBuffer() {
+    size_t request_size = std::min(output_bytes_, kChunkSize);
+    output_buffer_ =
+            reinterpret_cast<uint8_t*>(sink_->GetBuffer(request_size, &output_buffer_remaining_));
+    if (!output_buffer_) {
+        LOG(ERROR) << "Could not acquire buffer from sink";
+        return false;
+    }
+    return true;
+}
+
+class GzDecompressor final : public StreamDecompressor {
+  public:
+    ~GzDecompressor();
+
+    bool Init() override;
+    bool DecompressInput(const uint8_t* data, size_t length) override;
+    bool Done() override { return ended_; }
+
+  private:
+    z_stream z_ = {};
+    bool ended_ = false;
+};
+
+bool GzDecompressor::Init() {
+    if (int rv = inflateInit(&z_); rv != Z_OK) {
+        LOG(ERROR) << "inflateInit returned error code " << rv;
+        return false;
+    }
+    return true;
+}
+
+GzDecompressor::~GzDecompressor() {
+    inflateEnd(&z_);
+}
+
+bool GzDecompressor::DecompressInput(const uint8_t* data, size_t length) {
+    z_.next_in = reinterpret_cast<Bytef*>(const_cast<uint8_t*>(data));
+    z_.avail_in = length;
+
+    while (z_.avail_in) {
+        // If no more output buffer, grab a new buffer.
+        if (z_.avail_out == 0) {
+            if (!GetFreshBuffer()) {
+                return false;
+            }
+            z_.next_out = reinterpret_cast<Bytef*>(output_buffer_);
+            z_.avail_out = output_buffer_remaining_;
+        }
+
+        // Remember the position of the output buffer so we can call ReturnData.
+        auto avail_out = z_.avail_out;
+
+        // Decompress.
+        int rv = inflate(&z_, Z_NO_FLUSH);
+        if (rv != Z_OK && rv != Z_STREAM_END) {
+            LOG(ERROR) << "inflate returned error code " << rv;
+            return false;
+        }
+
+        size_t returned = avail_out - z_.avail_out;
+        if (!sink_->ReturnData(output_buffer_, returned)) {
+            LOG(ERROR) << "Could not return buffer to sink";
+            return false;
+        }
+        output_buffer_ += returned;
+        output_buffer_remaining_ -= returned;
+
+        if (rv == Z_STREAM_END) {
+            if (z_.avail_in) {
+                LOG(ERROR) << "Gz stream ended prematurely";
+                return false;
+            }
+            ended_ = true;
+            return true;
+        }
+    }
+    return true;
+}
+
+std::unique_ptr<IDecompressor> IDecompressor::Gz() {
+    return std::unique_ptr<IDecompressor>(new GzDecompressor());
+}
+
+class BrotliDecompressor final : public StreamDecompressor {
+  public:
+    ~BrotliDecompressor();
+
+    bool Init() override;
+    bool DecompressInput(const uint8_t* data, size_t length) override;
+    bool Done() override { return BrotliDecoderIsFinished(decoder_); }
+
+  private:
+    BrotliDecoderState* decoder_ = nullptr;
+};
+
+bool BrotliDecompressor::Init() {
+    decoder_ = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr);
+    return true;
+}
+
+BrotliDecompressor::~BrotliDecompressor() {
+    if (decoder_) {
+        BrotliDecoderDestroyInstance(decoder_);
+    }
+}
+
+bool BrotliDecompressor::DecompressInput(const uint8_t* data, size_t length) {
+    size_t available_in = length;
+    const uint8_t* next_in = data;
+
+    bool needs_more_output = false;
+    while (available_in || needs_more_output) {
+        if (!output_buffer_remaining_ && !GetFreshBuffer()) {
+            return false;
+        }
+
+        auto output_buffer = output_buffer_;
+        auto r = BrotliDecoderDecompressStream(decoder_, &available_in, &next_in,
+                                               &output_buffer_remaining_, &output_buffer_, nullptr);
+        if (r == BROTLI_DECODER_RESULT_ERROR) {
+            LOG(ERROR) << "brotli decode failed";
+            return false;
+        }
+        if (!sink_->ReturnData(output_buffer, output_buffer_ - output_buffer)) {
+            return false;
+        }
+        needs_more_output = (r == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT);
+    }
+    return true;
+}
+
+std::unique_ptr<IDecompressor> IDecompressor::Brotli() {
+    return std::unique_ptr<IDecompressor>(new BrotliDecompressor());
+}
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/cow_decompress.h b/fs_mgr/libsnapshot/cow_decompress.h
new file mode 100644
index 0000000..f485256
--- /dev/null
+++ b/fs_mgr/libsnapshot/cow_decompress.h
@@ -0,0 +1,57 @@
+//
+// Copyright (C) 2020 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 <libsnapshot/cow_reader.h>
+
+namespace android {
+namespace snapshot {
+
+class IByteStream {
+  public:
+    virtual ~IByteStream() {}
+
+    // Read up to |length| bytes, storing the number of bytes read in the out-
+    // parameter. If the end of the stream is reached, 0 is returned.
+    virtual bool Read(void* buffer, size_t length, size_t* read) = 0;
+
+    // Size of the stream.
+    virtual size_t Size() const = 0;
+};
+
+class IDecompressor {
+  public:
+    virtual ~IDecompressor() {}
+
+    // Factory methods for decompression methods.
+    static std::unique_ptr<IDecompressor> Uncompressed();
+    static std::unique_ptr<IDecompressor> Gz();
+    static std::unique_ptr<IDecompressor> Brotli();
+
+    // |output_bytes| is the expected total number of bytes to sink.
+    virtual bool Decompress(size_t output_bytes) = 0;
+
+    void set_stream(IByteStream* stream) { stream_ = stream; }
+    void set_sink(IByteSink* sink) { sink_ = sink; }
+
+  protected:
+    IByteStream* stream_ = nullptr;
+    IByteSink* sink_ = nullptr;
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/cow_reader.cpp b/fs_mgr/libsnapshot/cow_reader.cpp
new file mode 100644
index 0000000..60093ab
--- /dev/null
+++ b/fs_mgr/libsnapshot/cow_reader.cpp
@@ -0,0 +1,256 @@
+//
+// Copyright (C) 2020 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/types.h>
+#include <unistd.h>
+
+#include <limits>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <libsnapshot/cow_reader.h>
+#include <zlib.h>
+#include "cow_decompress.h"
+
+namespace android {
+namespace snapshot {
+
+CowReader::CowReader() : fd_(-1), header_(), fd_size_(0) {}
+
+static void SHA256(const void*, size_t, uint8_t[]) {
+#if 0
+    SHA256_CTX c;
+    SHA256_Init(&c);
+    SHA256_Update(&c, data, length);
+    SHA256_Final(out, &c);
+#endif
+}
+
+bool CowReader::Parse(android::base::unique_fd&& fd) {
+    owned_fd_ = std::move(fd);
+    return Parse(android::base::borrowed_fd{owned_fd_});
+}
+
+bool CowReader::Parse(android::base::borrowed_fd fd) {
+    fd_ = fd;
+
+    auto pos = lseek(fd_.get(), 0, SEEK_END);
+    if (pos < 0) {
+        PLOG(ERROR) << "lseek end failed";
+        return false;
+    }
+    fd_size_ = pos;
+
+    if (lseek(fd_.get(), 0, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek header failed";
+        return false;
+    }
+    if (!android::base::ReadFully(fd_, &header_, sizeof(header_))) {
+        PLOG(ERROR) << "read header failed";
+        return false;
+    }
+
+    // Validity check the ops range.
+    if (header_.ops_offset >= fd_size_) {
+        LOG(ERROR) << "ops offset " << header_.ops_offset << " larger than fd size " << fd_size_;
+        return false;
+    }
+    if (fd_size_ - header_.ops_offset < header_.ops_size) {
+        LOG(ERROR) << "ops size " << header_.ops_size << " is too large";
+        return false;
+    }
+
+    if (header_.magic != kCowMagicNumber) {
+        LOG(ERROR) << "Header Magic corrupted. Magic: " << header_.magic
+                   << "Expected: " << kCowMagicNumber;
+        return false;
+    }
+    if (header_.header_size != sizeof(CowHeader)) {
+        LOG(ERROR) << "Header size unknown, read " << header_.header_size << ", expected "
+                   << sizeof(CowHeader);
+        return false;
+    }
+
+    if ((header_.major_version != kCowVersionMajor) ||
+        (header_.minor_version != kCowVersionMinor)) {
+        LOG(ERROR) << "Header version mismatch";
+        LOG(ERROR) << "Major version: " << header_.major_version
+                   << "Expected: " << kCowVersionMajor;
+        LOG(ERROR) << "Minor version: " << header_.minor_version
+                   << "Expected: " << kCowVersionMinor;
+        return false;
+    }
+
+    uint8_t header_csum[32];
+    {
+        CowHeader tmp = header_;
+        memset(&tmp.header_checksum, 0, sizeof(tmp.header_checksum));
+        memset(header_csum, 0, sizeof(uint8_t) * 32);
+
+        SHA256(&tmp, sizeof(tmp), header_csum);
+    }
+    if (memcmp(header_csum, header_.header_checksum, sizeof(header_csum)) != 0) {
+        LOG(ERROR) << "header checksum is invalid";
+        return false;
+    }
+
+    return true;
+}
+
+bool CowReader::GetHeader(CowHeader* header) {
+    *header = header_;
+    return true;
+}
+
+class CowOpIter final : public ICowOpIter {
+  public:
+    CowOpIter(std::unique_ptr<uint8_t[]>&& ops, size_t len);
+
+    bool Done() override;
+    const CowOperation& Get() override;
+    void Next() override;
+
+  private:
+    bool HasNext();
+
+    std::unique_ptr<uint8_t[]> ops_;
+    const uint8_t* pos_;
+    const uint8_t* end_;
+    bool done_;
+};
+
+CowOpIter::CowOpIter(std::unique_ptr<uint8_t[]>&& ops, size_t len)
+    : ops_(std::move(ops)), pos_(ops_.get()), end_(pos_ + len), done_(!HasNext()) {}
+
+bool CowOpIter::Done() {
+    return done_;
+}
+
+bool CowOpIter::HasNext() {
+    return pos_ < end_ && size_t(end_ - pos_) >= sizeof(CowOperation);
+}
+
+void CowOpIter::Next() {
+    CHECK(!Done());
+
+    pos_ += sizeof(CowOperation);
+    if (!HasNext()) done_ = true;
+}
+
+const CowOperation& CowOpIter::Get() {
+    CHECK(!Done());
+    CHECK(HasNext());
+    return *reinterpret_cast<const CowOperation*>(pos_);
+}
+
+std::unique_ptr<ICowOpIter> CowReader::GetOpIter() {
+    if (lseek(fd_.get(), header_.ops_offset, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek ops failed";
+        return nullptr;
+    }
+    auto ops_buffer = std::make_unique<uint8_t[]>(header_.ops_size);
+    if (!android::base::ReadFully(fd_, ops_buffer.get(), header_.ops_size)) {
+        PLOG(ERROR) << "read ops failed";
+        return nullptr;
+    }
+
+    uint8_t csum[32];
+    memset(csum, 0, sizeof(uint8_t) * 32);
+
+    SHA256(ops_buffer.get(), header_.ops_size, csum);
+    if (memcmp(csum, header_.ops_checksum, sizeof(csum)) != 0) {
+        LOG(ERROR) << "ops checksum does not match";
+        return nullptr;
+    }
+
+    return std::make_unique<CowOpIter>(std::move(ops_buffer), header_.ops_size);
+}
+
+bool CowReader::GetRawBytes(uint64_t offset, void* buffer, size_t len, size_t* read) {
+    // Validate the offset, taking care to acknowledge possible overflow of offset+len.
+    if (offset < sizeof(header_) || offset >= header_.ops_offset || len >= fd_size_ ||
+        offset + len > header_.ops_offset) {
+        LOG(ERROR) << "invalid data offset: " << offset << ", " << len << " bytes";
+        return false;
+    }
+    if (lseek(fd_.get(), offset, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek to read raw bytes failed";
+        return false;
+    }
+    ssize_t rv = TEMP_FAILURE_RETRY(::read(fd_.get(), buffer, len));
+    if (rv < 0) {
+        PLOG(ERROR) << "read failed";
+        return false;
+    }
+    *read = rv;
+    return true;
+}
+
+class CowDataStream final : public IByteStream {
+  public:
+    CowDataStream(CowReader* reader, uint64_t offset, size_t data_length)
+        : reader_(reader), offset_(offset), data_length_(data_length) {
+        remaining_ = data_length_;
+    }
+
+    bool Read(void* buffer, size_t length, size_t* read) override {
+        size_t to_read = std::min(length, remaining_);
+        if (!to_read) {
+            *read = 0;
+            return true;
+        }
+        if (!reader_->GetRawBytes(offset_, buffer, to_read, read)) {
+            return false;
+        }
+        offset_ += *read;
+        remaining_ -= *read;
+        return true;
+    }
+
+    size_t Size() const override { return data_length_; }
+
+  private:
+    CowReader* reader_;
+    uint64_t offset_;
+    size_t data_length_;
+    size_t remaining_;
+};
+
+bool CowReader::ReadData(const CowOperation& op, IByteSink* sink) {
+    std::unique_ptr<IDecompressor> decompressor;
+    switch (op.compression) {
+        case kCowCompressNone:
+            decompressor = IDecompressor::Uncompressed();
+            break;
+        case kCowCompressGz:
+            decompressor = IDecompressor::Gz();
+            break;
+        case kCowCompressBrotli:
+            decompressor = IDecompressor::Brotli();
+            break;
+        default:
+            LOG(ERROR) << "Unknown compression type: " << op.compression;
+            return false;
+    }
+
+    CowDataStream stream(this, op.source, op.data_length);
+    decompressor->set_stream(&stream);
+    decompressor->set_sink(sink);
+    return decompressor->Decompress(header_.block_size);
+}
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/cow_snapuserd_test.cpp b/fs_mgr/libsnapshot/cow_snapuserd_test.cpp
new file mode 100644
index 0000000..75e54f7
--- /dev/null
+++ b/fs_mgr/libsnapshot/cow_snapuserd_test.cpp
@@ -0,0 +1,422 @@
+// Copyright (C) 2018 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 <fcntl.h>
+#include <linux/fs.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <iostream>
+#include <memory>
+#include <string_view>
+
+#include <android-base/file.h>
+#include <android-base/unique_fd.h>
+#include <gtest/gtest.h>
+#include <libsnapshot/cow_writer.h>
+#include <libsnapshot/snapuserd_client.h>
+#include <storage_literals/storage_literals.h>
+
+namespace android {
+namespace snapshot {
+
+using namespace android::storage_literals;
+using android::base::unique_fd;
+
+class SnapuserdTest : public ::testing::Test {
+  protected:
+    void SetUp() override {
+        cow_system_ = std::make_unique<TemporaryFile>();
+        ASSERT_GE(cow_system_->fd, 0) << strerror(errno);
+
+        cow_product_ = std::make_unique<TemporaryFile>();
+        ASSERT_GE(cow_product_->fd, 0) << strerror(errno);
+
+        cow_system_1_ = std::make_unique<TemporaryFile>();
+        ASSERT_GE(cow_system_1_->fd, 0) << strerror(errno);
+
+        cow_product_1_ = std::make_unique<TemporaryFile>();
+        ASSERT_GE(cow_product_1_->fd, 0) << strerror(errno);
+
+        size_ = 100_MiB;
+    }
+
+    void TearDown() override {
+        cow_system_ = nullptr;
+        cow_product_ = nullptr;
+
+        cow_system_1_ = nullptr;
+        cow_product_1_ = nullptr;
+    }
+
+    std::unique_ptr<TemporaryFile> cow_system_;
+    std::unique_ptr<TemporaryFile> cow_product_;
+
+    std::unique_ptr<TemporaryFile> cow_system_1_;
+    std::unique_ptr<TemporaryFile> cow_product_1_;
+
+    unique_fd sys_fd_;
+    unique_fd product_fd_;
+    size_t size_;
+
+    int system_blksize_;
+    int product_blksize_;
+    std::string system_device_name_;
+    std::string product_device_name_;
+
+    std::unique_ptr<uint8_t[]> random_buffer_1_;
+    std::unique_ptr<uint8_t[]> random_buffer_2_;
+    std::unique_ptr<uint8_t[]> zero_buffer_;
+    std::unique_ptr<uint8_t[]> system_buffer_;
+    std::unique_ptr<uint8_t[]> product_buffer_;
+
+    void Init();
+    void CreateCowDevice(std::unique_ptr<TemporaryFile>& cow);
+    void CreateSystemDmUser(std::unique_ptr<TemporaryFile>& cow);
+    void CreateProductDmUser(std::unique_ptr<TemporaryFile>& cow);
+    void StartSnapuserdDaemon();
+    void CreateSnapshotDevices();
+    void SwitchSnapshotDevices();
+
+    void TestIO(unique_fd& snapshot_fd, std::unique_ptr<uint8_t[]>& buffer);
+    SnapuserdClient client_;
+};
+
+void SnapuserdTest::Init() {
+    unique_fd rnd_fd;
+    loff_t offset = 0;
+
+    rnd_fd.reset(open("/dev/random", O_RDONLY));
+    ASSERT_TRUE(rnd_fd > 0);
+
+    random_buffer_1_ = std::make_unique<uint8_t[]>(size_);
+    random_buffer_2_ = std::make_unique<uint8_t[]>(size_);
+    system_buffer_ = std::make_unique<uint8_t[]>(size_);
+    product_buffer_ = std::make_unique<uint8_t[]>(size_);
+    zero_buffer_ = std::make_unique<uint8_t[]>(size_);
+
+    // Fill random data
+    for (size_t j = 0; j < (size_ / 1_MiB); j++) {
+        ASSERT_EQ(ReadFullyAtOffset(rnd_fd, (char*)random_buffer_1_.get() + offset, 1_MiB, 0),
+                  true);
+
+        ASSERT_EQ(ReadFullyAtOffset(rnd_fd, (char*)random_buffer_2_.get() + offset, 1_MiB, 0),
+                  true);
+
+        offset += 1_MiB;
+    }
+
+    sys_fd_.reset(open("/dev/block/mapper/system_a", O_RDONLY));
+    ASSERT_TRUE(sys_fd_ > 0);
+
+    product_fd_.reset(open("/dev/block/mapper/product_a", O_RDONLY));
+    ASSERT_TRUE(product_fd_ > 0);
+
+    // Read from system partition from offset 0 of size 100MB
+    ASSERT_EQ(ReadFullyAtOffset(sys_fd_, system_buffer_.get(), size_, 0), true);
+
+    // Read from product partition from offset 0 of size 100MB
+    ASSERT_EQ(ReadFullyAtOffset(product_fd_, product_buffer_.get(), size_, 0), true);
+}
+
+void SnapuserdTest::CreateCowDevice(std::unique_ptr<TemporaryFile>& cow) {
+    //================Create a COW file with the following operations===========
+    //
+    // Create COW file which is gz compressed
+    //
+    // 0-100 MB of replace operation with random data
+    // 100-200 MB of copy operation
+    // 200-300 MB of zero operation
+    // 300-400 MB of replace operation with random data
+
+    CowOptions options;
+    options.compression = "gz";
+    CowWriter writer(options);
+
+    ASSERT_TRUE(writer.Initialize(cow->fd));
+
+    // Write 100MB random data to COW file which is gz compressed from block 0
+    ASSERT_TRUE(writer.AddRawBlocks(0, random_buffer_1_.get(), size_));
+
+    size_t num_blocks = size_ / options.block_size;
+    size_t blk_start_copy = num_blocks;
+    size_t blk_end_copy = blk_start_copy + num_blocks;
+    size_t source_blk = 0;
+
+    // Copy blocks - source_blk starts from 0 as snapuserd
+    // has to read from block 0 in system_a partition
+    //
+    // This initializes copy operation from block 0 of size 100 MB from
+    // /dev/block/mapper/system_a or product_a
+    for (size_t i = blk_start_copy; i < blk_end_copy; i++) {
+        ASSERT_TRUE(writer.AddCopy(i, source_blk));
+        source_blk += 1;
+    }
+
+    size_t blk_zero_copy_start = blk_end_copy;
+    size_t blk_zero_copy_end = blk_zero_copy_start + num_blocks;
+
+    // 100 MB filled with zeroes
+    ASSERT_TRUE(writer.AddZeroBlocks(blk_zero_copy_start, num_blocks));
+
+    // Final 100MB filled with random data which is gz compressed
+    size_t blk_random2_replace_start = blk_zero_copy_end;
+
+    ASSERT_TRUE(writer.AddRawBlocks(blk_random2_replace_start, random_buffer_2_.get(), size_));
+
+    // Flush operations
+    ASSERT_TRUE(writer.Flush());
+
+    ASSERT_EQ(lseek(cow->fd, 0, SEEK_SET), 0);
+}
+
+void SnapuserdTest::CreateSystemDmUser(std::unique_ptr<TemporaryFile>& cow) {
+    unique_fd system_a_fd;
+    std::string cmd;
+    system_device_name_.clear();
+
+    // Create a COW device. Number of sectors is chosen random which can
+    // hold at least 400MB of data
+
+    system_a_fd.reset(open("/dev/block/mapper/system_a", O_RDONLY));
+    ASSERT_TRUE(system_a_fd > 0);
+
+    int err = ioctl(system_a_fd.get(), BLKGETSIZE, &system_blksize_);
+    ASSERT_GE(err, 0);
+
+    std::string str(cow->path);
+    std::size_t found = str.find_last_of("/\\");
+    ASSERT_NE(found, std::string::npos);
+    system_device_name_ = str.substr(found + 1);
+    cmd = "dmctl create " + system_device_name_ + " user 0 " + std::to_string(system_blksize_);
+
+    system(cmd.c_str());
+}
+
+void SnapuserdTest::CreateProductDmUser(std::unique_ptr<TemporaryFile>& cow) {
+    unique_fd product_a_fd;
+    std::string cmd;
+    product_device_name_.clear();
+
+    // Create a COW device. Number of sectors is chosen random which can
+    // hold at least 400MB of data
+
+    product_a_fd.reset(open("/dev/block/mapper/product_a", O_RDONLY));
+    ASSERT_TRUE(product_a_fd > 0);
+
+    int err = ioctl(product_a_fd.get(), BLKGETSIZE, &product_blksize_);
+    ASSERT_GE(err, 0);
+
+    std::string str(cow->path);
+    std::size_t found = str.find_last_of("/\\");
+    ASSERT_NE(found, std::string::npos);
+    product_device_name_ = str.substr(found + 1);
+    cmd = "dmctl create " + product_device_name_ + " user 0 " + std::to_string(product_blksize_);
+
+    system(cmd.c_str());
+}
+
+void SnapuserdTest::StartSnapuserdDaemon() {
+    int ret;
+
+    ret = client_.StartSnapuserd();
+    ASSERT_EQ(ret, 0);
+
+    ret = client_.InitializeSnapuserd(cow_system_->path, "/dev/block/mapper/system_a");
+    ASSERT_EQ(ret, 0);
+
+    ret = client_.InitializeSnapuserd(cow_product_->path, "/dev/block/mapper/product_a");
+    ASSERT_EQ(ret, 0);
+}
+
+void SnapuserdTest::CreateSnapshotDevices() {
+    std::string cmd;
+
+    cmd = "dmctl create system-snapshot -ro snapshot 0 " + std::to_string(system_blksize_);
+    cmd += " /dev/block/mapper/system_a";
+    cmd += " /dev/block/mapper/" + system_device_name_;
+    cmd += " P 8";
+
+    system(cmd.c_str());
+
+    cmd.clear();
+
+    cmd = "dmctl create product-snapshot -ro snapshot 0 " + std::to_string(product_blksize_);
+    cmd += " /dev/block/mapper/product_a";
+    cmd += " /dev/block/mapper/" + product_device_name_;
+    cmd += " P 8";
+
+    system(cmd.c_str());
+}
+
+void SnapuserdTest::SwitchSnapshotDevices() {
+    std::string cmd;
+
+    cmd = "dmctl create system-snapshot-1 -ro snapshot 0 " + std::to_string(system_blksize_);
+    cmd += " /dev/block/mapper/system_a";
+    cmd += " /dev/block/mapper/" + system_device_name_;
+    cmd += " P 8";
+
+    system(cmd.c_str());
+
+    cmd.clear();
+
+    cmd = "dmctl create product-snapshot-1 -ro snapshot 0 " + std::to_string(product_blksize_);
+    cmd += " /dev/block/mapper/product_a";
+    cmd += " /dev/block/mapper/" + product_device_name_;
+    cmd += " P 8";
+
+    system(cmd.c_str());
+}
+
+void SnapuserdTest::TestIO(unique_fd& snapshot_fd, std::unique_ptr<uint8_t[]>& buffer) {
+    loff_t offset = 0;
+    // std::unique_ptr<uint8_t[]> buffer = std::move(buf);
+
+    std::unique_ptr<uint8_t[]> snapuserd_buffer = std::make_unique<uint8_t[]>(size_);
+
+    //================Start IO operation on dm-snapshot device=================
+    // This will test the following paths:
+    //
+    // 1: IO path for all three operations and interleaving of operations.
+    // 2: Merging of blocks in kernel during metadata read
+    // 3: Bulk IO issued by kernel duing merge operation
+
+    // Read from snapshot device of size 100MB from offset 0. This tests the
+    // 1st replace operation.
+    //
+    // IO path:
+    //
+    // dm-snap->dm-snap-persistent->dm-user->snapuserd->read_compressed_cow (replace
+    // op)->decompress_cow->return
+
+    ASSERT_EQ(ReadFullyAtOffset(snapshot_fd, snapuserd_buffer.get(), size_, offset), true);
+
+    // Update the offset
+    offset += size_;
+
+    // Compare data with random_buffer_1_.
+    ASSERT_EQ(memcmp(snapuserd_buffer.get(), random_buffer_1_.get(), size_), 0);
+
+    // Clear the buffer
+    memset(snapuserd_buffer.get(), 0, size_);
+
+    // Read from snapshot device of size 100MB from offset 100MB. This tests the
+    // copy operation.
+    //
+    // IO path:
+    //
+    // dm-snap->dm-snap-persistent->dm-user->snapuserd->read_from_system_a_partition
+    // (copy op) -> return
+    ASSERT_EQ(ReadFullyAtOffset(snapshot_fd, snapuserd_buffer.get(), size_, offset), true);
+
+    // Update the offset
+    offset += size_;
+
+    // Compare data with buffer.
+    ASSERT_EQ(memcmp(snapuserd_buffer.get(), buffer.get(), size_), 0);
+
+    // Read from snapshot device of size 100MB from offset 200MB. This tests the
+    // zero operation.
+    //
+    // IO path:
+    //
+    // dm-snap->dm-snap-persistent->dm-user->snapuserd->fill_memory_with_zero
+    // (zero op) -> return
+    ASSERT_EQ(ReadFullyAtOffset(snapshot_fd, snapuserd_buffer.get(), size_, offset), true);
+
+    // Compare data with zero filled buffer
+    ASSERT_EQ(memcmp(snapuserd_buffer.get(), zero_buffer_.get(), size_), 0);
+
+    // Update the offset
+    offset += size_;
+
+    // Read from snapshot device of size 100MB from offset 300MB. This tests the
+    // final replace operation.
+    //
+    // IO path:
+    //
+    // dm-snap->dm-snap-persistent->dm-user->snapuserd->read_compressed_cow (replace
+    // op)->decompress_cow->return
+    ASSERT_EQ(ReadFullyAtOffset(snapshot_fd, snapuserd_buffer.get(), size_, offset), true);
+
+    // Compare data with random_buffer_2_.
+    ASSERT_EQ(memcmp(snapuserd_buffer.get(), random_buffer_2_.get(), size_), 0);
+}
+
+TEST_F(SnapuserdTest, ReadWrite) {
+    unique_fd snapshot_fd;
+
+    Init();
+
+    CreateCowDevice(cow_system_);
+    CreateCowDevice(cow_product_);
+
+    CreateSystemDmUser(cow_system_);
+    CreateProductDmUser(cow_product_);
+
+    StartSnapuserdDaemon();
+
+    CreateSnapshotDevices();
+
+    snapshot_fd.reset(open("/dev/block/mapper/system-snapshot", O_RDONLY));
+    ASSERT_TRUE(snapshot_fd > 0);
+    TestIO(snapshot_fd, system_buffer_);
+
+    snapshot_fd.reset(open("/dev/block/mapper/product-snapshot", O_RDONLY));
+    ASSERT_TRUE(snapshot_fd > 0);
+    TestIO(snapshot_fd, product_buffer_);
+
+    // Sequence of operations for transition
+    CreateCowDevice(cow_system_1_);
+    CreateCowDevice(cow_product_1_);
+
+    CreateSystemDmUser(cow_system_1_);
+    CreateProductDmUser(cow_product_1_);
+
+    std::vector<std::pair<std::string, std::string>> vec;
+    vec.push_back(std::make_pair(cow_system_1_->path, "/dev/block/mapper/system_a"));
+    vec.push_back(std::make_pair(cow_product_1_->path, "/dev/block/mapper/product_a"));
+
+    // Start the second stage deamon and send the devices
+    ASSERT_EQ(client_.RestartSnapuserd(vec), 0);
+
+    // TODO: This is not switching snapshot device but creates a new table;
+    // however, it should serve the testing purpose.
+    SwitchSnapshotDevices();
+
+    // Stop the first stage daemon
+    ASSERT_EQ(client_.StopSnapuserd(true), 0);
+
+    // Test the IO again with the second stage daemon
+    snapshot_fd.reset(open("/dev/block/mapper/system-snapshot-1", O_RDONLY));
+    ASSERT_TRUE(snapshot_fd > 0);
+    TestIO(snapshot_fd, system_buffer_);
+
+    snapshot_fd.reset(open("/dev/block/mapper/product-snapshot-1", O_RDONLY));
+    ASSERT_TRUE(snapshot_fd > 0);
+    TestIO(snapshot_fd, product_buffer_);
+
+    // Stop the second stage daemon
+    ASSERT_EQ(client_.StopSnapuserd(false), 0);
+}
+
+}  // namespace snapshot
+}  // namespace android
+
+int main(int argc, char** argv) {
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}
diff --git a/fs_mgr/libsnapshot/cow_writer.cpp b/fs_mgr/libsnapshot/cow_writer.cpp
new file mode 100644
index 0000000..70fdac1
--- /dev/null
+++ b/fs_mgr/libsnapshot/cow_writer.cpp
@@ -0,0 +1,355 @@
+//
+// Copyright (C) 2020 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/types.h>
+#include <unistd.h>
+
+#include <limits>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/unique_fd.h>
+#include <brotli/encode.h>
+#include <libsnapshot/cow_reader.h>
+#include <libsnapshot/cow_writer.h>
+#include <zlib.h>
+
+namespace android {
+namespace snapshot {
+
+static_assert(sizeof(off_t) == sizeof(uint64_t));
+
+bool ICowWriter::AddCopy(uint64_t new_block, uint64_t old_block) {
+    if (!ValidateNewBlock(new_block)) {
+        return false;
+    }
+    return EmitCopy(new_block, old_block);
+}
+
+bool ICowWriter::AddRawBlocks(uint64_t new_block_start, const void* data, size_t size) {
+    if (size % options_.block_size != 0) {
+        LOG(ERROR) << "AddRawBlocks: size " << size << " is not a multiple of "
+                   << options_.block_size;
+        return false;
+    }
+
+    uint64_t num_blocks = size / options_.block_size;
+    uint64_t last_block = new_block_start + num_blocks - 1;
+    if (!ValidateNewBlock(last_block)) {
+        return false;
+    }
+    return EmitRawBlocks(new_block_start, data, size);
+}
+
+bool ICowWriter::AddZeroBlocks(uint64_t new_block_start, uint64_t num_blocks) {
+    uint64_t last_block = new_block_start + num_blocks - 1;
+    if (!ValidateNewBlock(last_block)) {
+        return false;
+    }
+    return EmitZeroBlocks(new_block_start, num_blocks);
+}
+
+bool ICowWriter::ValidateNewBlock(uint64_t new_block) {
+    if (options_.max_blocks && new_block >= options_.max_blocks.value()) {
+        LOG(ERROR) << "New block " << new_block << " exceeds maximum block count "
+                   << options_.max_blocks.value();
+        return false;
+    }
+    return true;
+}
+
+CowWriter::CowWriter(const CowOptions& options) : ICowWriter(options), fd_(-1) {
+    SetupHeaders();
+}
+
+void CowWriter::SetupHeaders() {
+    header_ = {};
+    header_.magic = kCowMagicNumber;
+    header_.major_version = kCowVersionMajor;
+    header_.minor_version = kCowVersionMinor;
+    header_.header_size = sizeof(CowHeader);
+    header_.block_size = options_.block_size;
+}
+
+bool CowWriter::ParseOptions() {
+    if (options_.compression == "gz") {
+        compression_ = kCowCompressGz;
+    } else if (options_.compression == "brotli") {
+        compression_ = kCowCompressBrotli;
+    } else if (options_.compression == "none") {
+        compression_ = kCowCompressNone;
+    } else if (!options_.compression.empty()) {
+        LOG(ERROR) << "unrecognized compression: " << options_.compression;
+        return false;
+    }
+    return true;
+}
+
+bool CowWriter::Initialize(android::base::unique_fd&& fd, OpenMode mode) {
+    owned_fd_ = std::move(fd);
+    return Initialize(android::base::borrowed_fd{owned_fd_}, mode);
+}
+
+bool CowWriter::Initialize(android::base::borrowed_fd fd, OpenMode mode) {
+    fd_ = fd;
+
+    if (!ParseOptions()) {
+        return false;
+    }
+
+    switch (mode) {
+        case OpenMode::WRITE:
+            return OpenForWrite();
+        case OpenMode::APPEND:
+            return OpenForAppend();
+        default:
+            LOG(ERROR) << "Unknown open mode in CowWriter";
+            return false;
+    }
+}
+
+bool CowWriter::OpenForWrite() {
+    // This limitation is tied to the data field size in CowOperation.
+    if (header_.block_size > std::numeric_limits<uint16_t>::max()) {
+        LOG(ERROR) << "Block size is too large";
+        return false;
+    }
+
+    if (lseek(fd_.get(), 0, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek failed";
+        return false;
+    }
+
+    // Headers are not complete, but this ensures the file is at the right
+    // position.
+    if (!android::base::WriteFully(fd_, &header_, sizeof(header_))) {
+        PLOG(ERROR) << "write failed";
+        return false;
+    }
+
+    header_.ops_offset = header_.header_size;
+    return true;
+}
+
+bool CowWriter::OpenForAppend() {
+    auto reader = std::make_unique<CowReader>();
+    if (!reader->Parse(fd_) || !reader->GetHeader(&header_)) {
+        return false;
+    }
+    options_.block_size = header_.block_size;
+
+    // Reset this, since we're going to reimport all operations.
+    header_.num_ops = 0;
+
+    auto iter = reader->GetOpIter();
+    while (!iter->Done()) {
+        auto& op = iter->Get();
+        AddOperation(op);
+
+        iter->Next();
+    }
+
+    // Free reader so we own the descriptor position again.
+    reader = nullptr;
+
+    // Seek to the end of the data section.
+    if (lseek(fd_.get(), header_.ops_offset, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek failed";
+        return false;
+    }
+    return true;
+}
+
+bool CowWriter::EmitCopy(uint64_t new_block, uint64_t old_block) {
+    CowOperation op = {};
+    op.type = kCowCopyOp;
+    op.new_block = new_block;
+    op.source = old_block;
+    AddOperation(op);
+    return true;
+}
+
+bool CowWriter::EmitRawBlocks(uint64_t new_block_start, const void* data, size_t size) {
+    uint64_t pos;
+    if (!GetDataPos(&pos)) {
+        return false;
+    }
+
+    const uint8_t* iter = reinterpret_cast<const uint8_t*>(data);
+    for (size_t i = 0; i < size / header_.block_size; i++) {
+        CowOperation op = {};
+        op.type = kCowReplaceOp;
+        op.new_block = new_block_start + i;
+        op.source = pos;
+
+        if (compression_) {
+            auto data = Compress(iter, header_.block_size);
+            if (data.empty()) {
+                PLOG(ERROR) << "AddRawBlocks: compression failed";
+                return false;
+            }
+            if (data.size() > std::numeric_limits<uint16_t>::max()) {
+                LOG(ERROR) << "Compressed block is too large: " << data.size() << " bytes";
+                return false;
+            }
+            if (!WriteRawData(data.data(), data.size())) {
+                PLOG(ERROR) << "AddRawBlocks: write failed";
+                return false;
+            }
+            op.compression = compression_;
+            op.data_length = static_cast<uint16_t>(data.size());
+            pos += data.size();
+        } else {
+            op.data_length = static_cast<uint16_t>(header_.block_size);
+            pos += header_.block_size;
+        }
+
+        AddOperation(op);
+        iter += header_.block_size;
+    }
+
+    if (!compression_ && !WriteRawData(data, size)) {
+        PLOG(ERROR) << "AddRawBlocks: write failed";
+        return false;
+    }
+    return true;
+}
+
+bool CowWriter::EmitZeroBlocks(uint64_t new_block_start, uint64_t num_blocks) {
+    for (uint64_t i = 0; i < num_blocks; i++) {
+        CowOperation op = {};
+        op.type = kCowZeroOp;
+        op.new_block = new_block_start + i;
+        op.source = 0;
+        AddOperation(op);
+    }
+    return true;
+}
+
+std::basic_string<uint8_t> CowWriter::Compress(const void* data, size_t length) {
+    switch (compression_) {
+        case kCowCompressGz: {
+            auto bound = compressBound(length);
+            auto buffer = std::make_unique<uint8_t[]>(bound);
+
+            uLongf dest_len = bound;
+            auto rv = compress2(buffer.get(), &dest_len, reinterpret_cast<const Bytef*>(data),
+                                length, Z_BEST_COMPRESSION);
+            if (rv != Z_OK) {
+                LOG(ERROR) << "compress2 returned: " << rv;
+                return {};
+            }
+            return std::basic_string<uint8_t>(buffer.get(), dest_len);
+        }
+        case kCowCompressBrotli: {
+            auto bound = BrotliEncoderMaxCompressedSize(length);
+            if (!bound) {
+                LOG(ERROR) << "BrotliEncoderMaxCompressedSize returned 0";
+                return {};
+            }
+            auto buffer = std::make_unique<uint8_t[]>(bound);
+
+            size_t encoded_size = bound;
+            auto rv = BrotliEncoderCompress(
+                    BROTLI_DEFAULT_QUALITY, BROTLI_DEFAULT_WINDOW, BROTLI_DEFAULT_MODE, length,
+                    reinterpret_cast<const uint8_t*>(data), &encoded_size, buffer.get());
+            if (!rv) {
+                LOG(ERROR) << "BrotliEncoderCompress failed";
+                return {};
+            }
+            return std::basic_string<uint8_t>(buffer.get(), encoded_size);
+        }
+        default:
+            LOG(ERROR) << "unhandled compression type: " << compression_;
+            break;
+    }
+    return {};
+}
+
+// TODO: Fix compilation issues when linking libcrypto library
+// when snapuserd is compiled as part of ramdisk.
+static void SHA256(const void*, size_t, uint8_t[]) {
+#if 0
+    SHA256_CTX c;
+    SHA256_Init(&c);
+    SHA256_Update(&c, data, length);
+    SHA256_Final(out, &c);
+#endif
+}
+
+bool CowWriter::Flush() {
+    header_.ops_size = ops_.size();
+
+    memset(header_.ops_checksum, 0, sizeof(uint8_t) * 32);
+    memset(header_.header_checksum, 0, sizeof(uint8_t) * 32);
+
+    SHA256(ops_.data(), ops_.size(), header_.ops_checksum);
+    SHA256(&header_, sizeof(header_), header_.header_checksum);
+
+    if (lseek(fd_.get(), 0, SEEK_SET)) {
+        PLOG(ERROR) << "lseek failed";
+        return false;
+    }
+    if (!android::base::WriteFully(fd_, &header_, sizeof(header_))) {
+        PLOG(ERROR) << "write header failed";
+        return false;
+    }
+    if (lseek(fd_.get(), header_.ops_offset, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek ops failed";
+        return false;
+    }
+    if (!WriteFully(fd_, ops_.data(), ops_.size())) {
+        PLOG(ERROR) << "write ops failed";
+        return false;
+    }
+
+    // Re-position for any subsequent writes.
+    if (lseek(fd_.get(), header_.ops_offset, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek ops failed";
+        return false;
+    }
+    return true;
+}
+
+uint64_t CowWriter::GetCowSize() {
+    return header_.ops_offset + header_.num_ops * sizeof(CowOperation);
+}
+
+bool CowWriter::GetDataPos(uint64_t* pos) {
+    off_t offs = lseek(fd_.get(), 0, SEEK_CUR);
+    if (offs < 0) {
+        PLOG(ERROR) << "lseek failed";
+        return false;
+    }
+    *pos = offs;
+    return true;
+}
+
+void CowWriter::AddOperation(const CowOperation& op) {
+    header_.num_ops++;
+    ops_.insert(ops_.size(), reinterpret_cast<const uint8_t*>(&op), sizeof(op));
+}
+
+bool CowWriter::WriteRawData(const void* data, size_t size) {
+    if (!android::base::WriteFully(fd_, data, size)) {
+        return false;
+    }
+    header_.ops_offset += size;
+    return true;
+}
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/estimate_cow_from_nonab_ota.cpp b/fs_mgr/libsnapshot/estimate_cow_from_nonab_ota.cpp
new file mode 100644
index 0000000..2a0136b
--- /dev/null
+++ b/fs_mgr/libsnapshot/estimate_cow_from_nonab_ota.cpp
@@ -0,0 +1,432 @@
+//
+// Copyright (C) 2020 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 <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <iostream>
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/strings.h>
+#include <android-base/unique_fd.h>
+#include <gflags/gflags.h>
+#include <libsnapshot/cow_writer.h>
+#include <openssl/sha.h>
+#include <sparse/sparse.h>
+#include <ziparchive/zip_archive.h>
+
+DEFINE_string(source_tf, "", "Source target files (dir or zip file)");
+DEFINE_string(ota_tf, "", "Target files of the build for an OTA");
+DEFINE_string(compression, "gz", "Compression (options: none, gz, brotli)");
+
+namespace android {
+namespace snapshot {
+
+using android::base::borrowed_fd;
+using android::base::unique_fd;
+
+static constexpr size_t kBlockSize = 4096;
+
+void MyLogger(android::base::LogId, android::base::LogSeverity severity, const char*, const char*,
+              unsigned int, const char* message) {
+    if (severity == android::base::ERROR) {
+        fprintf(stderr, "%s\n", message);
+    } else {
+        fprintf(stdout, "%s\n", message);
+    }
+}
+
+class TargetFilesPackage final {
+  public:
+    explicit TargetFilesPackage(const std::string& path);
+
+    bool Open();
+    bool HasFile(const std::string& path);
+    std::unordered_set<std::string> GetDynamicPartitionNames();
+    unique_fd OpenFile(const std::string& path);
+    unique_fd OpenImage(const std::string& path);
+
+  private:
+    std::string path_;
+    unique_fd fd_;
+    std::unique_ptr<ZipArchive, decltype(&CloseArchive)> zip_;
+};
+
+TargetFilesPackage::TargetFilesPackage(const std::string& path)
+    : path_(path), zip_(nullptr, &CloseArchive) {}
+
+bool TargetFilesPackage::Open() {
+    fd_.reset(open(path_.c_str(), O_RDONLY));
+    if (fd_ < 0) {
+        PLOG(ERROR) << "open failed: " << path_;
+        return false;
+    }
+
+    struct stat s;
+    if (fstat(fd_.get(), &s) < 0) {
+        PLOG(ERROR) << "fstat failed: " << path_;
+        return false;
+    }
+    if (S_ISDIR(s.st_mode)) {
+        return true;
+    }
+
+    // Otherwise, assume it's a zip file.
+    ZipArchiveHandle handle;
+    if (OpenArchiveFd(fd_.get(), path_.c_str(), &handle, false)) {
+        LOG(ERROR) << "Could not open " << path_ << " as a zip archive.";
+        return false;
+    }
+    zip_.reset(handle);
+    return true;
+}
+
+bool TargetFilesPackage::HasFile(const std::string& path) {
+    if (zip_) {
+        ZipEntry64 entry;
+        return !FindEntry(zip_.get(), path, &entry);
+    }
+
+    auto full_path = path_ + "/" + path;
+    return access(full_path.c_str(), F_OK) == 0;
+}
+
+unique_fd TargetFilesPackage::OpenFile(const std::string& path) {
+    if (!zip_) {
+        auto full_path = path_ + "/" + path;
+        unique_fd fd(open(full_path.c_str(), O_RDONLY));
+        if (fd < 0) {
+            PLOG(ERROR) << "open failed: " << full_path;
+            return {};
+        }
+        return fd;
+    }
+
+    ZipEntry64 entry;
+    if (FindEntry(zip_.get(), path, &entry)) {
+        LOG(ERROR) << path << " not found in archive: " << path_;
+        return {};
+    }
+
+    TemporaryFile temp;
+    if (temp.fd < 0) {
+        PLOG(ERROR) << "mkstemp failed";
+        return {};
+    }
+
+    LOG(INFO) << "Extracting " << path << " from " << path_ << " ...";
+    if (ExtractEntryToFile(zip_.get(), &entry, temp.fd)) {
+        LOG(ERROR) << "could not extract " << path << " from " << path_;
+        return {};
+    }
+    if (lseek(temp.fd, 0, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek failed";
+        return {};
+    }
+    return unique_fd{temp.release()};
+}
+
+unique_fd TargetFilesPackage::OpenImage(const std::string& path) {
+    auto fd = OpenFile(path);
+    if (fd < 0) {
+        return {};
+    }
+
+    LOG(INFO) << "Unsparsing " << path << " ...";
+    std::unique_ptr<struct sparse_file, decltype(&sparse_file_destroy)> s(
+            sparse_file_import(fd.get(), false, false), &sparse_file_destroy);
+    if (!s) {
+        return fd;
+    }
+
+    TemporaryFile temp;
+    if (temp.fd < 0) {
+        PLOG(ERROR) << "mkstemp failed";
+        return {};
+    }
+    if (sparse_file_write(s.get(), temp.fd, false, false, false) < 0) {
+        LOG(ERROR) << "sparse_file_write failed";
+        return {};
+    }
+    if (lseek(temp.fd, 0, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek failed";
+        return {};
+    }
+
+    fd.reset(temp.release());
+    return fd;
+}
+
+std::unordered_set<std::string> TargetFilesPackage::GetDynamicPartitionNames() {
+    auto fd = OpenFile("META/misc_info.txt");
+    if (fd < 0) {
+        return {};
+    }
+
+    std::string contents;
+    if (!android::base::ReadFdToString(fd, &contents)) {
+        PLOG(ERROR) << "read failed";
+        return {};
+    }
+
+    std::unordered_set<std::string> set;
+
+    auto lines = android::base::Split(contents, "\n");
+    for (const auto& line : lines) {
+        auto parts = android::base::Split(line, "=");
+        if (parts.size() == 2 && parts[0] == "dynamic_partition_list") {
+            auto partitions = android::base::Split(parts[1], " ");
+            for (const auto& name : partitions) {
+                if (!name.empty()) {
+                    set.emplace(name);
+                }
+            }
+            break;
+        }
+    }
+    return set;
+}
+
+class NonAbEstimator final {
+  public:
+    NonAbEstimator(const std::string& ota_tf_path, const std::string& source_tf_path)
+        : ota_tf_path_(ota_tf_path), source_tf_path_(source_tf_path) {}
+
+    bool Run();
+
+  private:
+    bool OpenPackages();
+    bool AnalyzePartition(const std::string& partition_name);
+    std::unordered_map<std::string, uint64_t> GetBlockMap(borrowed_fd fd);
+
+    std::string ota_tf_path_;
+    std::string source_tf_path_;
+    std::unique_ptr<TargetFilesPackage> ota_tf_;
+    std::unique_ptr<TargetFilesPackage> source_tf_;
+    uint64_t size_ = 0;
+};
+
+bool NonAbEstimator::Run() {
+    if (!OpenPackages()) {
+        return false;
+    }
+
+    auto partitions = ota_tf_->GetDynamicPartitionNames();
+    if (partitions.empty()) {
+        LOG(ERROR) << "No dynamic partitions found in META/misc_info.txt";
+        return false;
+    }
+    for (const auto& partition : partitions) {
+        if (!AnalyzePartition(partition)) {
+            return false;
+        }
+    }
+
+    int64_t size_in_mb = int64_t(double(size_) / 1024.0 / 1024.0);
+
+    std::cout << "Estimated COW size: " << size_ << " (" << size_in_mb << "MiB)\n";
+    return true;
+}
+
+bool NonAbEstimator::OpenPackages() {
+    ota_tf_ = std::make_unique<TargetFilesPackage>(ota_tf_path_);
+    if (!ota_tf_->Open()) {
+        return false;
+    }
+    if (!source_tf_path_.empty()) {
+        source_tf_ = std::make_unique<TargetFilesPackage>(source_tf_path_);
+        if (!source_tf_->Open()) {
+            return false;
+        }
+    }
+    return true;
+}
+
+static std::string SHA256(const std::string& input) {
+    std::string hash(32, '\0');
+    SHA256_CTX c;
+    SHA256_Init(&c);
+    SHA256_Update(&c, input.data(), input.size());
+    SHA256_Final(reinterpret_cast<unsigned char*>(hash.data()), &c);
+    return hash;
+}
+
+bool NonAbEstimator::AnalyzePartition(const std::string& partition_name) {
+    auto path = "IMAGES/" + partition_name + ".img";
+    auto fd = ota_tf_->OpenImage(path);
+    if (fd < 0) {
+        return false;
+    }
+
+    unique_fd source_fd;
+    uint64_t source_size = 0;
+    std::unordered_map<std::string, uint64_t> source_blocks;
+    if (source_tf_) {
+        auto dap = source_tf_->GetDynamicPartitionNames();
+
+        source_fd = source_tf_->OpenImage(path);
+        if (source_fd >= 0) {
+            struct stat s;
+            if (fstat(source_fd.get(), &s)) {
+                PLOG(ERROR) << "fstat failed";
+                return false;
+            }
+            source_size = s.st_size;
+
+            std::cout << "Hashing blocks for " << partition_name << "...\n";
+            source_blocks = GetBlockMap(source_fd);
+            if (source_blocks.empty()) {
+                LOG(ERROR) << "Could not build a block map for source partition: "
+                           << partition_name;
+                return false;
+            }
+        } else {
+            if (dap.count(partition_name)) {
+                return false;
+            }
+            LOG(ERROR) << "Warning: " << partition_name
+                       << " has no incremental diff since it's not in the source image.";
+        }
+    }
+
+    TemporaryFile cow;
+    if (cow.fd < 0) {
+        PLOG(ERROR) << "mkstemp failed";
+        return false;
+    }
+
+    CowOptions options;
+    options.block_size = kBlockSize;
+    options.compression = FLAGS_compression;
+
+    auto writer = std::make_unique<CowWriter>(options);
+    if (!writer->Initialize(borrowed_fd{cow.fd})) {
+        LOG(ERROR) << "Could not initialize COW writer";
+        return false;
+    }
+
+    LOG(INFO) << "Analyzing " << partition_name << " ...";
+
+    std::string zeroes(kBlockSize, '\0');
+    std::string chunk(kBlockSize, '\0');
+    std::string src_chunk(kBlockSize, '\0');
+    uint64_t next_block_number = 0;
+    while (true) {
+        if (!android::base::ReadFully(fd, chunk.data(), chunk.size())) {
+            if (errno) {
+                PLOG(ERROR) << "read failed";
+                return false;
+            }
+            break;
+        }
+
+        uint64_t block_number = next_block_number++;
+        if (chunk == zeroes) {
+            if (!writer->AddZeroBlocks(block_number, 1)) {
+                LOG(ERROR) << "Could not add zero block";
+                return false;
+            }
+            continue;
+        }
+
+        uint64_t source_offset = block_number * kBlockSize;
+        if (source_fd >= 0 && source_offset <= source_size) {
+            off64_t offset = block_number * kBlockSize;
+            if (android::base::ReadFullyAtOffset(source_fd, src_chunk.data(), src_chunk.size(),
+                                                 offset)) {
+                if (chunk == src_chunk) {
+                    continue;
+                }
+            } else if (errno) {
+                PLOG(ERROR) << "pread failed";
+                return false;
+            }
+        }
+
+        auto hash = SHA256(chunk);
+        if (auto iter = source_blocks.find(hash); iter != source_blocks.end()) {
+            if (!writer->AddCopy(block_number, iter->second)) {
+                return false;
+            }
+            continue;
+        }
+
+        if (!writer->AddRawBlocks(block_number, chunk.data(), chunk.size())) {
+            return false;
+        }
+    }
+
+    if (!writer->Flush()) {
+        return false;
+    }
+
+    struct stat s;
+    if (fstat(cow.fd, &s) < 0) {
+        PLOG(ERROR) << "fstat failed";
+        return false;
+    }
+
+    size_ += s.st_size;
+    return true;
+}
+
+std::unordered_map<std::string, uint64_t> NonAbEstimator::GetBlockMap(borrowed_fd fd) {
+    std::string chunk(kBlockSize, '\0');
+
+    std::unordered_map<std::string, uint64_t> block_map;
+    uint64_t block_number = 0;
+    while (true) {
+        if (!android::base::ReadFully(fd, chunk.data(), chunk.size())) {
+            if (errno) {
+                PLOG(ERROR) << "read failed";
+                return {};
+            }
+            break;
+        }
+        auto hash = SHA256(chunk);
+        block_map[hash] = block_number;
+        block_number++;
+    }
+    return block_map;
+}
+
+}  // namespace snapshot
+}  // namespace android
+
+using namespace android::snapshot;
+
+int main(int argc, char** argv) {
+    android::base::InitLogging(argv, android::snapshot::MyLogger);
+    gflags::SetUsageMessage("Estimate VAB disk usage from Non A/B builds");
+    gflags::ParseCommandLineFlags(&argc, &argv, false);
+
+    if (FLAGS_ota_tf.empty()) {
+        std::cerr << "Must specify -ota_tf on the command-line." << std::endl;
+        return 1;
+    }
+
+    NonAbEstimator estimator(FLAGS_ota_tf, FLAGS_source_tf);
+    if (!estimator.Run()) {
+        return 1;
+    }
+    return 0;
+}
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
new file mode 100644
index 0000000..4a6bd4e
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
@@ -0,0 +1,107 @@
+// Copyright (C) 2019 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 <stdint.h>
+
+namespace android {
+namespace snapshot {
+
+static constexpr uint64_t kCowMagicNumber = 0x436f77634f572121ULL;
+static constexpr uint32_t kCowVersionMajor = 1;
+static constexpr uint32_t kCowVersionMinor = 0;
+
+// This header appears as the first sequence of bytes in the COW. All fields
+// in the layout are little-endian encoded. The on-disk layout is:
+//
+//      +-----------------------+
+//      |     Header (fixed)    |
+//      +-----------------------+
+//      |  Raw Data (variable)  |
+//      +-----------------------+
+//      | Operations (variable) |
+//      +-----------------------+
+//
+// The "raw data" occurs immediately after the header, and the operation
+// sequence occurs after the raw data. This ordering is intentional. While
+// streaming an OTA, we can immediately write compressed data, but store the
+// metadata in memory. At the end, we can simply append the metadata and flush
+// the file. There is no need to create separate files to store the metadata
+// and block data.
+struct CowHeader {
+    uint64_t magic;
+    uint16_t major_version;
+    uint16_t minor_version;
+
+    // Size of this struct.
+    uint16_t header_size;
+
+    // Offset to the location of the operation sequence, and size of the
+    // operation sequence buffer. |ops_offset| is also the end of the
+    // raw data region.
+    uint64_t ops_offset;
+    uint64_t ops_size;
+    uint64_t num_ops;
+
+    // The size of block operations, in bytes.
+    uint32_t block_size;
+
+    // SHA256 checksums of this header, with this field set to 0.
+    uint8_t header_checksum[32];
+
+    // SHA256 of the operation sequence.
+    uint8_t ops_checksum[32];
+} __attribute__((packed));
+
+// Cow operations are currently fixed-size entries, but this may change if
+// needed.
+struct CowOperation {
+    // The operation code (see the constants and structures below).
+    uint8_t type;
+
+    // If this operation reads from the data section of the COW, this contains
+    // the compression type of that data (see constants below).
+    uint8_t compression;
+
+    // If this operation reads from the data section of the COW, this contains
+    // the length.
+    uint16_t data_length;
+
+    // The block of data in the new image that this operation modifies.
+    uint64_t new_block;
+
+    // The value of |source| depends on the operation code.
+    //
+    // For copy operations, this is a block location in the source image.
+    //
+    // For replace operations, this is a byte offset within the COW's data
+    // section (eg, not landing within the header or metadata). It is an
+    // absolute position within the image.
+    //
+    // For zero operations (replace with all zeroes), this is unused and must
+    // be zero.
+    uint64_t source;
+} __attribute__((packed));
+
+static constexpr uint8_t kCowCopyOp = 1;
+static constexpr uint8_t kCowReplaceOp = 2;
+static constexpr uint8_t kCowZeroOp = 3;
+
+static constexpr uint8_t kCowCompressNone = 0;
+static constexpr uint8_t kCowCompressGz = 1;
+static constexpr uint8_t kCowCompressBrotli = 2;
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
new file mode 100644
index 0000000..3998776
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
@@ -0,0 +1,109 @@
+// Copyright (C) 2019 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 <stdint.h>
+
+#include <functional>
+#include <memory>
+
+#include <android-base/unique_fd.h>
+#include <libsnapshot/cow_format.h>
+
+namespace android {
+namespace snapshot {
+
+class ICowOpIter;
+
+// A ByteSink object handles requests for a buffer of a specific size. It
+// always owns the underlying buffer. It's designed to minimize potential
+// copying as we parse or decompress the COW.
+class IByteSink {
+  public:
+    virtual ~IByteSink() {}
+
+    // Called when the reader has data. The size of the request is given. The
+    // sink must return a valid pointer (or null on failure), and return the
+    // maximum number of bytes that can be written to the returned buffer.
+    //
+    // The returned buffer is owned by IByteSink, but must remain valid until
+    // the ready operation has completed (or the entire buffer has been
+    // covered by calls to ReturnData).
+    //
+    // After calling GetBuffer(), all previous buffers returned are no longer
+    // valid.
+    virtual void* GetBuffer(size_t requested, size_t* actual) = 0;
+
+    // Called when a section returned by |GetBuffer| has been filled with data.
+    virtual bool ReturnData(void* buffer, size_t length) = 0;
+};
+
+// Interface for reading from a snapuserd COW.
+class ICowReader {
+  public:
+    virtual ~ICowReader() {}
+
+    // Return the file header.
+    virtual bool GetHeader(CowHeader* header) = 0;
+
+    // Return an iterator for retrieving CowOperation entries.
+    virtual std::unique_ptr<ICowOpIter> GetOpIter() = 0;
+
+    // Get decoded bytes from the data section, handling any decompression.
+    // All retrieved data is passed to the sink.
+    virtual bool ReadData(const CowOperation& op, IByteSink* sink) = 0;
+};
+
+// Iterate over a sequence of COW operations.
+class ICowOpIter {
+  public:
+    virtual ~ICowOpIter() {}
+
+    // True if there are more items to read, false otherwise.
+    virtual bool Done() = 0;
+
+    // Read the current operation.
+    virtual const CowOperation& Get() = 0;
+
+    // Advance to the next item.
+    virtual void Next() = 0;
+};
+
+class CowReader : public ICowReader {
+  public:
+    CowReader();
+
+    bool Parse(android::base::unique_fd&& fd);
+    bool Parse(android::base::borrowed_fd fd);
+
+    bool GetHeader(CowHeader* header) override;
+
+    // Create a CowOpIter object which contains header_.num_ops
+    // CowOperation objects. Get() returns a unique CowOperation object
+    // whose lifeteime depends on the CowOpIter object
+    std::unique_ptr<ICowOpIter> GetOpIter() override;
+    bool ReadData(const CowOperation& op, IByteSink* sink) override;
+
+    bool GetRawBytes(uint64_t offset, void* buffer, size_t len, size_t* read);
+
+  private:
+    android::base::unique_fd owned_fd_;
+    android::base::borrowed_fd fd_;
+    CowHeader header_;
+    uint64_t fd_size_;
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_writer.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_writer.h
new file mode 100644
index 0000000..245da0c
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_writer.h
@@ -0,0 +1,115 @@
+// Copyright (C) 2019 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 <stdint.h>
+
+#include <optional>
+#include <string>
+
+#include <android-base/unique_fd.h>
+#include <libsnapshot/cow_format.h>
+
+namespace android {
+namespace snapshot {
+
+struct CowOptions {
+    uint32_t block_size = 4096;
+    std::string compression;
+
+    // Maximum number of blocks that can be written.
+    std::optional<uint64_t> max_blocks;
+};
+
+// Interface for writing to a snapuserd COW. All operations are ordered; merges
+// will occur in the sequence they were added to the COW.
+class ICowWriter {
+  public:
+    explicit ICowWriter(const CowOptions& options) : options_(options) {}
+
+    virtual ~ICowWriter() {}
+
+    // Encode an operation that copies the contents of |old_block| to the
+    // location of |new_block|.
+    bool AddCopy(uint64_t new_block, uint64_t old_block);
+
+    // Encode a sequence of raw blocks. |size| must be a multiple of the block size.
+    bool AddRawBlocks(uint64_t new_block_start, const void* data, size_t size);
+
+    // Encode a sequence of zeroed blocks. |size| must be a multiple of the block size.
+    bool AddZeroBlocks(uint64_t new_block_start, uint64_t num_blocks);
+
+    // Flush all pending writes. This must be called before closing the writer
+    // to ensure that the correct headers and footers are written.
+    virtual bool Flush() = 0;
+
+    // Return number of bytes the cow image occupies on disk.
+    virtual uint64_t GetCowSize() = 0;
+
+    const CowOptions& options() { return options_; }
+
+  protected:
+    virtual bool EmitCopy(uint64_t new_block, uint64_t old_block) = 0;
+    virtual bool EmitRawBlocks(uint64_t new_block_start, const void* data, size_t size) = 0;
+    virtual bool EmitZeroBlocks(uint64_t new_block_start, uint64_t num_blocks) = 0;
+
+    bool ValidateNewBlock(uint64_t new_block);
+
+  protected:
+    CowOptions options_;
+};
+
+class CowWriter : public ICowWriter {
+  public:
+    enum class OpenMode { WRITE, APPEND };
+
+    explicit CowWriter(const CowOptions& options);
+
+    // Set up the writer.
+    bool Initialize(android::base::unique_fd&& fd, OpenMode mode = OpenMode::WRITE);
+    bool Initialize(android::base::borrowed_fd fd, OpenMode mode = OpenMode::WRITE);
+
+    bool Flush() override;
+
+    uint64_t GetCowSize() override;
+
+  protected:
+    virtual bool EmitCopy(uint64_t new_block, uint64_t old_block) override;
+    virtual bool EmitRawBlocks(uint64_t new_block_start, const void* data, size_t size) override;
+    virtual bool EmitZeroBlocks(uint64_t new_block_start, uint64_t num_blocks) override;
+
+  private:
+    void SetupHeaders();
+    bool ParseOptions();
+    bool OpenForWrite();
+    bool OpenForAppend();
+    bool GetDataPos(uint64_t* pos);
+    bool WriteRawData(const void* data, size_t size);
+    void AddOperation(const CowOperation& op);
+    std::basic_string<uint8_t> Compress(const void* data, size_t length);
+
+  private:
+    android::base::unique_fd owned_fd_;
+    android::base::borrowed_fd fd_;
+    CowHeader header_{};
+    int compression_ = 0;
+
+    // :TODO: this is not efficient, but stringstream ubsan aborts because some
+    // bytes overflow a signed char.
+    std::basic_string<uint8_t> ops_;
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot.h b/fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot.h
index 4457de3..eb6ad05 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot.h
@@ -15,6 +15,7 @@
 #pragma once
 
 #include <libsnapshot/snapshot.h>
+#include <payload_consumer/file_descriptor.h>
 
 #include <gmock/gmock.h>
 
@@ -37,6 +38,10 @@
                 (const android::fs_mgr::CreateLogicalPartitionParams& params,
                  std::string* snapshot_path),
                 (override));
+    MOCK_METHOD(std::unique_ptr<ICowWriter>, OpenSnapshotWriter,
+                (const android::fs_mgr::CreateLogicalPartitionParams& params), (override));
+    MOCK_METHOD(std::unique_ptr<FileDescriptor>, OpenSnapshotReader,
+                (const android::fs_mgr::CreateLogicalPartitionParams& params), (override));
     MOCK_METHOD(bool, UnmapUpdateSnapshot, (const std::string& target_partition_name), (override));
     MOCK_METHOD(bool, NeedSnapshotsInFirstStageMount, (), (override));
     MOCK_METHOD(bool, CreateLogicalAndSnapshotPartitions,
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
index a4a3150..6fef58a 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
@@ -35,6 +35,7 @@
 #include <update_engine/update_metadata.pb.h>
 
 #include <libsnapshot/auto_device.h>
+#include <libsnapshot/cow_writer.h>
 #include <libsnapshot/return.h>
 
 #ifndef FRIEND_TEST
@@ -43,6 +44,10 @@
 #define DEFINED_FRIEND_TEST
 #endif
 
+namespace chromeos_update_engine {
+class FileDescriptor;
+}  // namespace chromeos_update_engine
+
 namespace android {
 
 namespace fiemap {
@@ -105,6 +110,8 @@
     };
     virtual ~ISnapshotManager() = default;
 
+    using FileDescriptor = chromeos_update_engine::FileDescriptor;
+
     // Begin an update. This must be called before creating any snapshots. It
     // will fail if GetUpdateState() != None.
     virtual bool BeginUpdate() = 0;
@@ -173,11 +180,26 @@
 
     // Map a snapshotted partition for OTA clients to write to. Write-protected regions are
     // determined previously in CreateSnapshots.
+    //
     // |snapshot_path| must not be nullptr.
+    //
+    // This method will return false if ro.virtual_ab.compression.enabled is true.
     virtual bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params,
                                    std::string* snapshot_path) = 0;
 
-    // Unmap a snapshot device that's previously mapped with MapUpdateSnapshot.
+    // Create an ICowWriter to build a snapshot against a target partition. The partition name must
+    // be suffixed.
+    virtual std::unique_ptr<ICowWriter> OpenSnapshotWriter(
+            const android::fs_mgr::CreateLogicalPartitionParams& params) = 0;
+
+    // Open a snapshot for reading. A file-like interface is provided through the FileDescriptor.
+    // In this mode, writes are not supported. The partition name must be suffixed.
+    virtual std::unique_ptr<FileDescriptor> OpenSnapshotReader(
+            const android::fs_mgr::CreateLogicalPartitionParams& params) = 0;
+
+    // Unmap a snapshot device or CowWriter that was previously opened with MapUpdateSnapshot,
+    // OpenSnapshotWriter, or OpenSnapshotReader. All outstanding open descriptors, writers,
+    // or readers must be deleted before this is called.
     virtual bool UnmapUpdateSnapshot(const std::string& target_partition_name) = 0;
 
     // If this returns true, first-stage mount must call
@@ -288,6 +310,10 @@
     Return CreateUpdateSnapshots(const DeltaArchiveManifest& manifest) override;
     bool MapUpdateSnapshot(const CreateLogicalPartitionParams& params,
                            std::string* snapshot_path) override;
+    std::unique_ptr<ICowWriter> OpenSnapshotWriter(
+            const android::fs_mgr::CreateLogicalPartitionParams& params) override;
+    std::unique_ptr<FileDescriptor> OpenSnapshotReader(
+            const android::fs_mgr::CreateLogicalPartitionParams& params) override;
     bool UnmapUpdateSnapshot(const std::string& target_partition_name) override;
     bool NeedSnapshotsInFirstStageMount() override;
     bool CreateLogicalAndSnapshotPartitions(
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapshot_stub.h b/fs_mgr/libsnapshot/include/libsnapshot/snapshot_stub.h
index 7a27fad..149f463 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/snapshot_stub.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapshot_stub.h
@@ -15,6 +15,7 @@
 #pragma once
 
 #include <libsnapshot/snapshot.h>
+#include <payload_consumer/file_descriptor.h>
 
 namespace android::snapshot {
 
@@ -35,6 +36,10 @@
             const chromeos_update_engine::DeltaArchiveManifest& manifest) override;
     bool MapUpdateSnapshot(const android::fs_mgr::CreateLogicalPartitionParams& params,
                            std::string* snapshot_path) override;
+    std::unique_ptr<ICowWriter> OpenSnapshotWriter(
+            const android::fs_mgr::CreateLogicalPartitionParams& params) override;
+    std::unique_ptr<FileDescriptor> OpenSnapshotReader(
+            const android::fs_mgr::CreateLogicalPartitionParams& params) override;
     bool UnmapUpdateSnapshot(const std::string& target_partition_name) override;
     bool NeedSnapshotsInFirstStageMount() override;
     bool CreateLogicalAndSnapshotPartitions(
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapuserd.h b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd.h
new file mode 100644
index 0000000..d495014
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd.h
@@ -0,0 +1,108 @@
+// Copyright (C) 2020 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 <linux/types.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <csignal>
+#include <cstring>
+#include <iostream>
+#include <limits>
+#include <string>
+#include <thread>
+#include <vector>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
+#include <android-base/unique_fd.h>
+#include <libdm/dm.h>
+#include <libsnapshot/cow_reader.h>
+#include <libsnapshot/cow_writer.h>
+#include <libsnapshot/snapuserd_kernel.h>
+
+namespace android {
+namespace snapshot {
+
+using android::base::unique_fd;
+
+class BufferSink : public IByteSink {
+  public:
+    void Initialize(size_t size);
+    void* GetBufPtr() { return buffer_.get(); }
+    void Clear() { memset(GetBufPtr(), 0, buffer_size_); }
+    void* GetPayloadBuffer(size_t size);
+    void* GetBuffer(size_t requested, size_t* actual) override;
+    void UpdateBufferOffset(size_t size) { buffer_offset_ += size; }
+    struct dm_user_header* GetHeaderPtr();
+    bool ReturnData(void*, size_t) override { return true; }
+    void ResetBufferOffset() { buffer_offset_ = 0; }
+
+  private:
+    std::unique_ptr<uint8_t[]> buffer_;
+    loff_t buffer_offset_;
+    size_t buffer_size_;
+};
+
+class Snapuserd final {
+  public:
+    Snapuserd(const std::string& in_cow_device, const std::string& in_backing_store_device)
+        : cow_device_(in_cow_device),
+          backing_store_device_(in_backing_store_device),
+          metadata_read_done_(false) {}
+
+    bool Init();
+    int Run();
+    int ReadDmUserHeader();
+    int WriteDmUserPayload(size_t size);
+    int ConstructKernelCowHeader();
+    int ReadMetadata();
+    int ZerofillDiskExceptions(size_t read_size);
+    int ReadDiskExceptions(chunk_t chunk, size_t size);
+    int ReadData(chunk_t chunk, size_t size);
+
+  private:
+    int ProcessReplaceOp(const CowOperation* cow_op);
+    int ProcessCopyOp(const CowOperation* cow_op);
+    int ProcessZeroOp();
+
+    std::string cow_device_;
+    std::string backing_store_device_;
+
+    unique_fd cow_fd_;
+    unique_fd backing_store_fd_;
+    unique_fd ctrl_fd_;
+
+    uint32_t exceptions_per_area_;
+
+    std::unique_ptr<ICowOpIter> cowop_iter_;
+    std::unique_ptr<CowReader> reader_;
+
+    // Vector of disk exception which is a
+    // mapping of old-chunk to new-chunk
+    std::vector<std::unique_ptr<uint8_t[]>> vec_;
+
+    // Index - Chunk ID
+    // Value - cow operation
+    std::vector<const CowOperation*> chunk_vec_;
+
+    bool metadata_read_done_;
+    BufferSink bufsink_;
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h
new file mode 100644
index 0000000..535e923
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_client.h
@@ -0,0 +1,59 @@
+// Copyright (C) 2020 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 <cstring>
+#include <iostream>
+#include <string>
+#include <thread>
+#include <vector>
+
+namespace android {
+namespace snapshot {
+
+static constexpr uint32_t PACKET_SIZE = 512;
+static constexpr uint32_t MAX_CONNECT_RETRY_COUNT = 10;
+
+class SnapuserdClient {
+  private:
+    int sockfd_ = 0;
+
+    int Sendmsg(const char* msg, size_t size);
+    std::string Receivemsg();
+    int StartSnapuserdaemon(std::string socketname);
+    bool ConnectToServerSocket(std::string socketname);
+    bool ConnectToServer();
+
+    void DisconnectFromServer() { close(sockfd_); }
+
+    std::string GetSocketNameFirstStage() {
+        static std::string snapd_one("snapdone");
+        return snapd_one;
+    }
+
+    std::string GetSocketNameSecondStage() {
+        static std::string snapd_two("snapdtwo");
+        return snapd_two;
+    }
+
+  public:
+    int StartSnapuserd();
+    int StopSnapuserd(bool firstStageDaemon);
+    int RestartSnapuserd(std::vector<std::pair<std::string, std::string>>& vec);
+    int InitializeSnapuserd(std::string cow_device, std::string backing_device);
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_daemon.h b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_daemon.h
new file mode 100644
index 0000000..94542d7
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_daemon.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2020 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 <poll.h>
+
+#include <libsnapshot/snapuserd_server.h>
+
+namespace android {
+namespace snapshot {
+
+class Daemon {
+    // The Daemon class is a singleton to avoid
+    // instantiating more than once
+  public:
+    static Daemon& Instance() {
+        static Daemon instance;
+        return instance;
+    }
+
+    int StartServer(std::string socketname);
+    bool IsRunning();
+    void Run();
+
+  private:
+    bool is_running_;
+    std::unique_ptr<struct pollfd> poll_fd_;
+    // Signal mask used with ppoll()
+    sigset_t signal_mask_;
+
+    Daemon();
+    Daemon(Daemon const&) = delete;
+    void operator=(Daemon const&) = delete;
+
+    SnapuserdServer server_;
+    void MaskAllSignalsExceptIntAndTerm();
+    void MaskAllSignals();
+    static void SignalHandler(int signal);
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_kernel.h b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_kernel.h
new file mode 100644
index 0000000..1a6ba8f
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_kernel.h
@@ -0,0 +1,97 @@
+// Copyright (C) 2020 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
+
+namespace android {
+namespace snapshot {
+
+// Kernel COW header fields
+static constexpr uint32_t SNAP_MAGIC = 0x70416e53;
+
+static constexpr uint32_t SNAPSHOT_DISK_VERSION = 1;
+
+static constexpr uint32_t NUM_SNAPSHOT_HDR_CHUNKS = 1;
+
+static constexpr uint32_t SNAPSHOT_VALID = 1;
+
+/*
+ * The basic unit of block I/O is a sector. It is used in a number of contexts
+ * in Linux (blk, bio, genhd). The size of one sector is 512 = 2**9
+ * bytes. Variables of type sector_t represent an offset or size that is a
+ * multiple of 512 bytes. Hence these two constants.
+ */
+static constexpr uint32_t SECTOR_SHIFT = 9;
+
+typedef __u64 sector_t;
+typedef sector_t chunk_t;
+
+static constexpr uint32_t CHUNK_SIZE = 8;
+static constexpr uint32_t CHUNK_SHIFT = (__builtin_ffs(CHUNK_SIZE) - 1);
+
+static constexpr uint32_t BLOCK_SIZE = 4096;
+static constexpr uint32_t BLOCK_SHIFT = (__builtin_ffs(BLOCK_SIZE) - 1);
+
+// This structure represents the kernel COW header.
+// All the below fields should be in Little Endian format.
+struct disk_header {
+    uint32_t magic;
+
+    /*
+     * Is this snapshot valid.  There is no way of recovering
+     * an invalid snapshot.
+     */
+    uint32_t valid;
+
+    /*
+     * Simple, incrementing version. no backward
+     * compatibility.
+     */
+    uint32_t version;
+
+    /* In sectors */
+    uint32_t chunk_size;
+} __packed;
+
+// A disk exception is a mapping of old_chunk to new_chunk
+// old_chunk is the chunk ID of a dm-snapshot device.
+// new_chunk is the chunk ID of the COW device.
+struct disk_exception {
+    uint64_t old_chunk;
+    uint64_t new_chunk;
+} __packed;
+
+// Control structures to communicate with dm-user
+// It comprises of header and a payload
+struct dm_user_header {
+    __u64 seq;
+    __u64 type;
+    __u64 flags;
+    __u64 sector;
+    __u64 len;
+    __u64 io_in_progress;
+} __attribute__((packed));
+
+struct dm_user_payload {
+    __u8 buf[];
+};
+
+// Message comprising both header and payload
+struct dm_user_message {
+    struct dm_user_header header;
+    struct dm_user_payload payload;
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_server.h b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_server.h
new file mode 100644
index 0000000..584fe71
--- /dev/null
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapuserd_server.h
@@ -0,0 +1,103 @@
+// Copyright (C) 2020 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 <cstdio>
+#include <cstring>
+#include <functional>
+#include <future>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <thread>
+#include <vector>
+
+#include <android-base/unique_fd.h>
+
+namespace android {
+namespace snapshot {
+
+static constexpr uint32_t MAX_PACKET_SIZE = 512;
+
+enum class DaemonOperations {
+    START,
+    QUERY,
+    TERMINATING,
+    STOP,
+    INVALID,
+};
+
+class Client {
+  private:
+    std::unique_ptr<std::thread> threadHandler_;
+
+  public:
+    void SetThreadHandler(std::function<void(void)> func) {
+        threadHandler_ = std::make_unique<std::thread>(func);
+    }
+
+    std::unique_ptr<std::thread>& GetThreadHandler() { return threadHandler_; }
+};
+
+class Stoppable {
+    std::promise<void> exitSignal_;
+    std::future<void> futureObj_;
+
+  public:
+    Stoppable() : futureObj_(exitSignal_.get_future()) {}
+
+    virtual ~Stoppable() {}
+
+    virtual void ThreadStart(std::string cow_device, std::string backing_device) = 0;
+
+    bool StopRequested() {
+        // checks if value in future object is available
+        if (futureObj_.wait_for(std::chrono::milliseconds(0)) == std::future_status::timeout)
+            return false;
+        return true;
+    }
+    // Request the thread to stop by setting value in promise object
+    void StopThreads() { exitSignal_.set_value(); }
+};
+
+class SnapuserdServer : public Stoppable {
+  private:
+    android::base::unique_fd sockfd_;
+    bool terminating_;
+    std::vector<std::unique_ptr<Client>> clients_vec_;
+
+    void ThreadStart(std::string cow_device, std::string backing_device) override;
+    void ShutdownThreads();
+    DaemonOperations Resolveop(std::string& input);
+    std::string GetDaemonStatus();
+    void Parsemsg(std::string const& msg, const char delim, std::vector<std::string>& out);
+
+    void SetTerminating() { terminating_ = true; }
+
+    bool IsTerminating() { return terminating_; }
+
+  public:
+    SnapuserdServer() { terminating_ = false; }
+
+    int Start(std::string socketname);
+    int AcceptClient();
+    int Receivemsg(int fd);
+    int Sendmsg(int fd, char* msg, size_t len);
+    std::string Recvmsg(int fd, int* ret);
+    android::base::borrowed_fd GetSocketFd() { return sockfd_; }
+};
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/make_cow_from_ab_ota.cpp b/fs_mgr/libsnapshot/make_cow_from_ab_ota.cpp
new file mode 100644
index 0000000..f761077
--- /dev/null
+++ b/fs_mgr/libsnapshot/make_cow_from_ab_ota.cpp
@@ -0,0 +1,690 @@
+//
+// Copyright (C) 2020 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 <arpa/inet.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <iostream>
+#include <limits>
+#include <string>
+#include <unordered_set>
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/unique_fd.h>
+#include <bsdiff/bspatch.h>
+#include <bzlib.h>
+#include <gflags/gflags.h>
+#include <libsnapshot/cow_writer.h>
+#include <puffin/puffpatch.h>
+#include <sparse/sparse.h>
+#include <update_engine/update_metadata.pb.h>
+#include <xz.h>
+#include <ziparchive/zip_archive.h>
+
+namespace android {
+namespace snapshot {
+
+using android::base::borrowed_fd;
+using android::base::unique_fd;
+using chromeos_update_engine::DeltaArchiveManifest;
+using chromeos_update_engine::Extent;
+using chromeos_update_engine::InstallOperation;
+using chromeos_update_engine::PartitionUpdate;
+
+static constexpr uint64_t kBlockSize = 4096;
+
+DEFINE_string(source_tf, "", "Source target files (dir or zip file) for incremental payloads");
+DEFINE_string(compression, "gz", "Compression type to use (none or gz)");
+
+void MyLogger(android::base::LogId, android::base::LogSeverity severity, const char*, const char*,
+              unsigned int, const char* message) {
+    if (severity == android::base::ERROR) {
+        fprintf(stderr, "%s\n", message);
+    } else {
+        fprintf(stdout, "%s\n", message);
+    }
+}
+
+uint64_t ToLittleEndian(uint64_t value) {
+    union {
+        uint64_t u64;
+        char bytes[8];
+    } packed;
+    packed.u64 = value;
+    std::swap(packed.bytes[0], packed.bytes[7]);
+    std::swap(packed.bytes[1], packed.bytes[6]);
+    std::swap(packed.bytes[2], packed.bytes[5]);
+    std::swap(packed.bytes[3], packed.bytes[4]);
+    return packed.u64;
+}
+
+class PayloadConverter final {
+  public:
+    PayloadConverter(const std::string& in_file, const std::string& out_dir)
+        : in_file_(in_file), out_dir_(out_dir), source_tf_zip_(nullptr, &CloseArchive) {}
+
+    bool Run();
+
+  private:
+    bool OpenPayload();
+    bool OpenSourceTargetFiles();
+    bool ProcessPartition(const PartitionUpdate& update);
+    bool ProcessOperation(const InstallOperation& op);
+    bool ProcessZero(const InstallOperation& op);
+    bool ProcessCopy(const InstallOperation& op);
+    bool ProcessReplace(const InstallOperation& op);
+    bool ProcessDiff(const InstallOperation& op);
+    borrowed_fd OpenSourceImage();
+
+    std::string in_file_;
+    std::string out_dir_;
+    unique_fd in_fd_;
+    uint64_t payload_offset_ = 0;
+    DeltaArchiveManifest manifest_;
+    std::unordered_set<std::string> dap_;
+    unique_fd source_tf_fd_;
+    std::unique_ptr<ZipArchive, decltype(&CloseArchive)> source_tf_zip_;
+
+    // Updated during ProcessPartition().
+    std::string partition_name_;
+    std::unique_ptr<CowWriter> writer_;
+    unique_fd source_image_;
+};
+
+bool PayloadConverter::Run() {
+    if (!OpenPayload()) {
+        return false;
+    }
+
+    if (manifest_.has_dynamic_partition_metadata()) {
+        const auto& dpm = manifest_.dynamic_partition_metadata();
+        for (const auto& group : dpm.groups()) {
+            for (const auto& partition : group.partition_names()) {
+                dap_.emplace(partition);
+            }
+        }
+    }
+
+    if (dap_.empty()) {
+        LOG(ERROR) << "No dynamic partitions found.";
+        return false;
+    }
+
+    if (!OpenSourceTargetFiles()) {
+        return false;
+    }
+
+    for (const auto& update : manifest_.partitions()) {
+        if (!ProcessPartition(update)) {
+            return false;
+        }
+        writer_ = nullptr;
+        source_image_.reset();
+    }
+    return true;
+}
+
+bool PayloadConverter::OpenSourceTargetFiles() {
+    if (FLAGS_source_tf.empty()) {
+        return true;
+    }
+
+    source_tf_fd_.reset(open(FLAGS_source_tf.c_str(), O_RDONLY));
+    if (source_tf_fd_ < 0) {
+        LOG(ERROR) << "open failed: " << FLAGS_source_tf;
+        return false;
+    }
+
+    struct stat s;
+    if (fstat(source_tf_fd_.get(), &s) < 0) {
+        LOG(ERROR) << "fstat failed: " << FLAGS_source_tf;
+        return false;
+    }
+    if (S_ISDIR(s.st_mode)) {
+        return true;
+    }
+
+    // Otherwise, assume it's a zip file.
+    ZipArchiveHandle handle;
+    if (OpenArchiveFd(source_tf_fd_.get(), FLAGS_source_tf.c_str(), &handle, false)) {
+        LOG(ERROR) << "Could not open " << FLAGS_source_tf << " as a zip archive.";
+        return false;
+    }
+    source_tf_zip_.reset(handle);
+    return true;
+}
+
+bool PayloadConverter::ProcessPartition(const PartitionUpdate& update) {
+    auto partition_name = update.partition_name();
+    if (dap_.find(partition_name) == dap_.end()) {
+        // Skip non-DAP partitions.
+        return true;
+    }
+
+    auto path = out_dir_ + "/" + partition_name + ".cow";
+    unique_fd fd(open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0644));
+    if (fd < 0) {
+        PLOG(ERROR) << "open failed: " << path;
+        return false;
+    }
+
+    CowOptions options;
+    options.block_size = kBlockSize;
+    options.compression = FLAGS_compression;
+
+    writer_ = std::make_unique<CowWriter>(options);
+    if (!writer_->Initialize(std::move(fd))) {
+        LOG(ERROR) << "Unable to initialize COW writer";
+        return false;
+    }
+
+    partition_name_ = partition_name;
+
+    for (const auto& op : update.operations()) {
+        if (!ProcessOperation(op)) {
+            return false;
+        }
+    }
+
+    if (!writer_->Flush()) {
+        LOG(ERROR) << "Unable to finalize COW for " << partition_name;
+        return false;
+    }
+    return true;
+}
+
+bool PayloadConverter::ProcessOperation(const InstallOperation& op) {
+    switch (op.type()) {
+        case InstallOperation::SOURCE_COPY:
+            return ProcessCopy(op);
+        case InstallOperation::BROTLI_BSDIFF:
+        case InstallOperation::PUFFDIFF:
+            return ProcessDiff(op);
+        case InstallOperation::REPLACE:
+        case InstallOperation::REPLACE_XZ:
+        case InstallOperation::REPLACE_BZ:
+            return ProcessReplace(op);
+        case InstallOperation::ZERO:
+            return ProcessZero(op);
+        default:
+            LOG(ERROR) << "Unsupported op: " << (int)op.type();
+            return false;
+    }
+    return true;
+}
+
+bool PayloadConverter::ProcessZero(const InstallOperation& op) {
+    for (const auto& extent : op.dst_extents()) {
+        if (!writer_->AddZeroBlocks(extent.start_block(), extent.num_blocks())) {
+            LOG(ERROR) << "Could not add zero operation";
+            return false;
+        }
+    }
+    return true;
+}
+
+template <typename T>
+static uint64_t SizeOfAllExtents(const T& extents) {
+    uint64_t total = 0;
+    for (const auto& extent : extents) {
+        total += extent.num_blocks() * kBlockSize;
+    }
+    return total;
+}
+
+class PuffInputStream final : public puffin::StreamInterface {
+  public:
+    PuffInputStream(uint8_t* buffer, size_t length) : buffer_(buffer), length_(length), pos_(0) {}
+
+    bool GetSize(uint64_t* size) const override {
+        *size = length_;
+        return true;
+    }
+    bool GetOffset(uint64_t* offset) const override {
+        *offset = pos_;
+        return true;
+    }
+    bool Seek(uint64_t offset) override {
+        if (offset > length_) return false;
+        pos_ = offset;
+        return true;
+    }
+    bool Read(void* buffer, size_t length) override {
+        if (length_ - pos_ < length) return false;
+        memcpy(buffer, buffer_ + pos_, length);
+        pos_ += length;
+        return true;
+    }
+    bool Write(const void*, size_t) override { return false; }
+    bool Close() override { return true; }
+
+  private:
+    uint8_t* buffer_;
+    size_t length_;
+    size_t pos_;
+};
+
+class PuffOutputStream final : public puffin::StreamInterface {
+  public:
+    PuffOutputStream(std::vector<uint8_t>& stream) : stream_(stream), pos_(0) {}
+
+    bool GetSize(uint64_t* size) const override {
+        *size = stream_.size();
+        return true;
+    }
+    bool GetOffset(uint64_t* offset) const override {
+        *offset = pos_;
+        return true;
+    }
+    bool Seek(uint64_t offset) override {
+        if (offset > stream_.size()) {
+            return false;
+        }
+        pos_ = offset;
+        return true;
+    }
+    bool Read(void* buffer, size_t length) override {
+        if (stream_.size() - pos_ < length) {
+            return false;
+        }
+        memcpy(buffer, &stream_[0] + pos_, length);
+        pos_ += length;
+        return true;
+    }
+    bool Write(const void* buffer, size_t length) override {
+        auto remaining = stream_.size() - pos_;
+        if (remaining < length) {
+            stream_.resize(stream_.size() + (length - remaining));
+        }
+        memcpy(&stream_[0] + pos_, buffer, length);
+        pos_ += length;
+        return true;
+    }
+    bool Close() override { return true; }
+
+  private:
+    std::vector<uint8_t>& stream_;
+    size_t pos_;
+};
+
+bool PayloadConverter::ProcessDiff(const InstallOperation& op) {
+    auto source_image = OpenSourceImage();
+    if (source_image < 0) {
+        return false;
+    }
+
+    uint64_t src_length = SizeOfAllExtents(op.src_extents());
+    auto src = std::make_unique<uint8_t[]>(src_length);
+    size_t src_pos = 0;
+
+    // Read source bytes.
+    for (const auto& extent : op.src_extents()) {
+        uint64_t offset = extent.start_block() * kBlockSize;
+        if (lseek(source_image.get(), offset, SEEK_SET) < 0) {
+            PLOG(ERROR) << "lseek source image failed";
+            return false;
+        }
+
+        uint64_t size = extent.num_blocks() * kBlockSize;
+        CHECK(src_length - src_pos >= size);
+        if (!android::base::ReadFully(source_image, src.get() + src_pos, size)) {
+            PLOG(ERROR) << "read source image failed";
+            return false;
+        }
+        src_pos += size;
+    }
+    CHECK(src_pos == src_length);
+
+    // Read patch bytes.
+    auto patch = std::make_unique<uint8_t[]>(op.data_length());
+    if (lseek(in_fd_.get(), payload_offset_ + op.data_offset(), SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek payload failed";
+        return false;
+    }
+    if (!android::base::ReadFully(in_fd_, patch.get(), op.data_length())) {
+        PLOG(ERROR) << "read payload failed";
+        return false;
+    }
+
+    std::vector<uint8_t> dest(SizeOfAllExtents(op.dst_extents()));
+
+    // Apply the diff.
+    if (op.type() == InstallOperation::BROTLI_BSDIFF) {
+        size_t dest_pos = 0;
+        auto sink = [&](const uint8_t* data, size_t length) -> size_t {
+            CHECK(dest.size() - dest_pos >= length);
+            memcpy(&dest[dest_pos], data, length);
+            dest_pos += length;
+            return length;
+        };
+        if (int rv = bsdiff::bspatch(src.get(), src_pos, patch.get(), op.data_length(), sink)) {
+            LOG(ERROR) << "bspatch failed, error code " << rv;
+            return false;
+        }
+    } else if (op.type() == InstallOperation::PUFFDIFF) {
+        auto src_stream = std::make_unique<PuffInputStream>(src.get(), src_length);
+        auto dest_stream = std::make_unique<PuffOutputStream>(dest);
+        bool ok = PuffPatch(std::move(src_stream), std::move(dest_stream), patch.get(),
+                            op.data_length());
+        if (!ok) {
+            LOG(ERROR) << "puffdiff operation failed to apply";
+            return false;
+        }
+    } else {
+        LOG(ERROR) << "unsupported diff operation: " << op.type();
+        return false;
+    }
+
+    // Write the final blocks to the COW.
+    size_t dest_pos = 0;
+    for (const auto& extent : op.dst_extents()) {
+        uint64_t size = extent.num_blocks() * kBlockSize;
+        CHECK(dest.size() - dest_pos >= size);
+
+        if (!writer_->AddRawBlocks(extent.start_block(), &dest[dest_pos], size)) {
+            return false;
+        }
+        dest_pos += size;
+    }
+    return true;
+}
+
+borrowed_fd PayloadConverter::OpenSourceImage() {
+    if (source_image_ >= 0) {
+        return source_image_;
+    }
+
+    unique_fd unzip_fd;
+
+    auto local_path = "IMAGES/" + partition_name_ + ".img";
+    if (source_tf_zip_) {
+        {
+            TemporaryFile tmp;
+            if (tmp.fd < 0) {
+                PLOG(ERROR) << "mkstemp failed";
+                return -1;
+            }
+            unzip_fd.reset(tmp.release());
+        }
+
+        ZipEntry64 entry;
+        if (FindEntry(source_tf_zip_.get(), local_path, &entry)) {
+            LOG(ERROR) << "not found in archive: " << local_path;
+            return -1;
+        }
+        if (ExtractEntryToFile(source_tf_zip_.get(), &entry, unzip_fd.get())) {
+            LOG(ERROR) << "could not extract " << local_path;
+            return -1;
+        }
+        if (lseek(unzip_fd.get(), 0, SEEK_SET) < 0) {
+            PLOG(ERROR) << "lseek failed";
+            return -1;
+        }
+    } else if (source_tf_fd_ >= 0) {
+        unzip_fd.reset(openat(source_tf_fd_.get(), local_path.c_str(), O_RDONLY));
+        if (unzip_fd < 0) {
+            PLOG(ERROR) << "open failed: " << FLAGS_source_tf << "/" << local_path;
+            return -1;
+        }
+    } else {
+        LOG(ERROR) << "No source target files package was specified; need -source_tf";
+        return -1;
+    }
+
+    std::unique_ptr<struct sparse_file, decltype(&sparse_file_destroy)> s(
+            sparse_file_import(unzip_fd.get(), false, false), &sparse_file_destroy);
+    if (s) {
+        TemporaryFile tmp;
+        if (tmp.fd < 0) {
+            PLOG(ERROR) << "mkstemp failed";
+            return -1;
+        }
+        if (sparse_file_write(s.get(), tmp.fd, false, false, false) < 0) {
+            LOG(ERROR) << "sparse_file_write failed";
+            return -1;
+        }
+        source_image_.reset(tmp.release());
+    } else {
+        source_image_ = std::move(unzip_fd);
+    }
+    return source_image_;
+}
+
+template <typename ContainerType>
+class ExtentIter final {
+  public:
+    ExtentIter(const ContainerType& container)
+        : iter_(container.cbegin()), end_(container.cend()), dst_index_(0) {}
+
+    bool GetNext(uint64_t* block) {
+        while (iter_ != end_) {
+            if (dst_index_ < iter_->num_blocks()) {
+                break;
+            }
+            iter_++;
+            dst_index_ = 0;
+        }
+        if (iter_ == end_) {
+            return false;
+        }
+        *block = iter_->start_block() + dst_index_;
+        dst_index_++;
+        return true;
+    }
+
+  private:
+    typename ContainerType::const_iterator iter_;
+    typename ContainerType::const_iterator end_;
+    uint64_t dst_index_;
+};
+
+bool PayloadConverter::ProcessCopy(const InstallOperation& op) {
+    ExtentIter dst_blocks(op.dst_extents());
+
+    for (const auto& extent : op.src_extents()) {
+        for (uint64_t i = 0; i < extent.num_blocks(); i++) {
+            uint64_t src_block = extent.start_block() + i;
+            uint64_t dst_block;
+            if (!dst_blocks.GetNext(&dst_block)) {
+                LOG(ERROR) << "SOURCE_COPY contained mismatching extents";
+                return false;
+            }
+            if (src_block == dst_block) continue;
+            if (!writer_->AddCopy(dst_block, src_block)) {
+                LOG(ERROR) << "Could not add copy operation";
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+bool PayloadConverter::ProcessReplace(const InstallOperation& op) {
+    auto buffer_size = op.data_length();
+    auto buffer = std::make_unique<char[]>(buffer_size);
+    uint64_t offs = payload_offset_ + op.data_offset();
+    if (lseek(in_fd_.get(), offs, SEEK_SET) < 0) {
+        PLOG(ERROR) << "lseek " << offs << " failed";
+        return false;
+    }
+    if (!android::base::ReadFully(in_fd_, buffer.get(), buffer_size)) {
+        PLOG(ERROR) << "read " << buffer_size << " bytes from offset " << offs << "failed";
+        return false;
+    }
+
+    uint64_t dst_size = 0;
+    for (const auto& extent : op.dst_extents()) {
+        dst_size += extent.num_blocks() * kBlockSize;
+    }
+
+    if (op.type() == InstallOperation::REPLACE_BZ) {
+        auto tmp = std::make_unique<char[]>(dst_size);
+
+        uint32_t actual_size;
+        if (dst_size > std::numeric_limits<typeof(actual_size)>::max()) {
+            LOG(ERROR) << "too many bytes to decompress: " << dst_size;
+            return false;
+        }
+        actual_size = static_cast<uint32_t>(dst_size);
+
+        auto rv = BZ2_bzBuffToBuffDecompress(tmp.get(), &actual_size, buffer.get(), buffer_size, 0,
+                                             0);
+        if (rv) {
+            LOG(ERROR) << "bz2 decompress failed: " << rv;
+            return false;
+        }
+        if (actual_size != dst_size) {
+            LOG(ERROR) << "bz2 returned " << actual_size << " bytes, expected " << dst_size;
+            return false;
+        }
+        buffer = std::move(tmp);
+        buffer_size = dst_size;
+    } else if (op.type() == InstallOperation::REPLACE_XZ) {
+        constexpr uint32_t kXzMaxDictSize = 64 * 1024 * 1024;
+
+        if (dst_size > std::numeric_limits<size_t>::max()) {
+            LOG(ERROR) << "too many bytes to decompress: " << dst_size;
+            return false;
+        }
+
+        std::unique_ptr<struct xz_dec, decltype(&xz_dec_end)> s(
+                xz_dec_init(XZ_DYNALLOC, kXzMaxDictSize), xz_dec_end);
+        if (!s) {
+            LOG(ERROR) << "xz_dec_init failed";
+            return false;
+        }
+
+        auto tmp = std::make_unique<char[]>(dst_size);
+
+        struct xz_buf args;
+        args.in = reinterpret_cast<const uint8_t*>(buffer.get());
+        args.in_pos = 0;
+        args.in_size = buffer_size;
+        args.out = reinterpret_cast<uint8_t*>(tmp.get());
+        args.out_pos = 0;
+        args.out_size = dst_size;
+
+        auto rv = xz_dec_run(s.get(), &args);
+        if (rv != XZ_STREAM_END) {
+            LOG(ERROR) << "xz decompress failed: " << (int)rv;
+            return false;
+        }
+        buffer = std::move(tmp);
+        buffer_size = dst_size;
+    }
+
+    uint64_t buffer_pos = 0;
+    for (const auto& extent : op.dst_extents()) {
+        uint64_t extent_size = extent.num_blocks() * kBlockSize;
+        if (buffer_size - buffer_pos < extent_size) {
+            LOG(ERROR) << "replace op ran out of input buffer";
+            return false;
+        }
+        if (!writer_->AddRawBlocks(extent.start_block(), buffer.get() + buffer_pos, extent_size)) {
+            LOG(ERROR) << "failed to add raw blocks from replace op";
+            return false;
+        }
+        buffer_pos += extent_size;
+    }
+    return true;
+}
+
+bool PayloadConverter::OpenPayload() {
+    in_fd_.reset(open(in_file_.c_str(), O_RDONLY));
+    if (in_fd_ < 0) {
+        PLOG(ERROR) << "open " << in_file_;
+        return false;
+    }
+
+    char magic[4];
+    if (!android::base::ReadFully(in_fd_, magic, sizeof(magic))) {
+        PLOG(ERROR) << "read magic";
+        return false;
+    }
+    if (std::string(magic, sizeof(magic)) != "CrAU") {
+        LOG(ERROR) << "Invalid magic in " << in_file_;
+        return false;
+    }
+
+    uint64_t version;
+    uint64_t manifest_size;
+    uint32_t manifest_signature_size = 0;
+    if (!android::base::ReadFully(in_fd_, &version, sizeof(version))) {
+        PLOG(ERROR) << "read version";
+        return false;
+    }
+    version = ToLittleEndian(version);
+    if (version < 2) {
+        LOG(ERROR) << "Only payload version 2 or higher is supported.";
+        return false;
+    }
+
+    if (!android::base::ReadFully(in_fd_, &manifest_size, sizeof(manifest_size))) {
+        PLOG(ERROR) << "read manifest_size";
+        return false;
+    }
+    manifest_size = ToLittleEndian(manifest_size);
+    if (!android::base::ReadFully(in_fd_, &manifest_signature_size,
+                                  sizeof(manifest_signature_size))) {
+        PLOG(ERROR) << "read manifest_signature_size";
+        return false;
+    }
+    manifest_signature_size = ntohl(manifest_signature_size);
+
+    auto manifest = std::make_unique<uint8_t[]>(manifest_size);
+    if (!android::base::ReadFully(in_fd_, manifest.get(), manifest_size)) {
+        PLOG(ERROR) << "read manifest";
+        return false;
+    }
+
+    // Skip past manifest signature.
+    auto offs = lseek(in_fd_, manifest_signature_size, SEEK_CUR);
+    if (offs < 0) {
+        PLOG(ERROR) << "lseek failed";
+        return false;
+    }
+    payload_offset_ = offs;
+
+    if (!manifest_.ParseFromArray(manifest.get(), manifest_size)) {
+        LOG(ERROR) << "could not parse manifest";
+        return false;
+    }
+    return true;
+}
+
+}  // namespace snapshot
+}  // namespace android
+
+int main(int argc, char** argv) {
+    android::base::InitLogging(argv, android::snapshot::MyLogger);
+    gflags::SetUsageMessage("Convert OTA payload to a Virtual A/B COW");
+    int arg_start = gflags::ParseCommandLineFlags(&argc, &argv, false);
+
+    xz_crc32_init();
+
+    if (argc - arg_start != 2) {
+        std::cerr << "Usage: [options] <payload.bin> <out-dir>\n";
+        return 1;
+    }
+
+    android::snapshot::PayloadConverter pc(argv[arg_start], argv[arg_start + 1]);
+    return pc.Run() ? 0 : 1;
+}
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index b49f99e..0904fc7 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -27,6 +27,7 @@
 #include <android-base/file.h>
 #include <android-base/logging.h>
 #include <android-base/parseint.h>
+#include <android-base/properties.h>
 #include <android-base/strings.h>
 #include <android-base/unique_fd.h>
 #include <ext4_utils/ext4_utils.h>
@@ -68,6 +69,7 @@
 using android::hardware::boot::V1_1::MergeStatus;
 using chromeos_update_engine::DeltaArchiveManifest;
 using chromeos_update_engine::Extent;
+using chromeos_update_engine::FileDescriptor;
 using chromeos_update_engine::InstallOperation;
 template <typename T>
 using RepeatedPtrField = google::protobuf::RepeatedPtrField<T>;
@@ -103,6 +105,10 @@
     metadata_dir_ = device_->GetMetadataDir();
 }
 
+static inline bool IsCompressionEnabled() {
+    return android::base::GetBoolProperty("ro.virtual_ab.compression.enabled", false);
+}
+
 static std::string GetCowName(const std::string& snapshot_name) {
     return snapshot_name + "-cow";
 }
@@ -2420,6 +2426,11 @@
 
 bool SnapshotManager::MapUpdateSnapshot(const CreateLogicalPartitionParams& params,
                                         std::string* snapshot_path) {
+    if (IsCompressionEnabled()) {
+        LOG(ERROR) << "MapUpdateSnapshot cannot be used in compression mode.";
+        return false;
+    }
+
     auto lock = LockShared();
     if (!lock) return false;
     if (!UnmapPartitionWithSnapshot(lock.get(), params.GetPartitionName())) {
@@ -2430,6 +2441,22 @@
     return MapPartitionWithSnapshot(lock.get(), params, snapshot_path);
 }
 
+std::unique_ptr<ICowWriter> SnapshotManager::OpenSnapshotWriter(
+        const android::fs_mgr::CreateLogicalPartitionParams& params) {
+    (void)params;
+
+    LOG(ERROR) << "OpenSnapshotWriter not yet implemented";
+    return nullptr;
+}
+
+std::unique_ptr<FileDescriptor> SnapshotManager::OpenSnapshotReader(
+        const android::fs_mgr::CreateLogicalPartitionParams& params) {
+    (void)params;
+
+    LOG(ERROR) << "OpenSnapshotReader not yet implemented";
+    return nullptr;
+}
+
 bool SnapshotManager::UnmapUpdateSnapshot(const std::string& target_partition_name) {
     auto lock = LockShared();
     if (!lock) return false;
diff --git a/fs_mgr/libsnapshot/snapshot_stub.cpp b/fs_mgr/libsnapshot/snapshot_stub.cpp
index 9b6f758..8ae6305 100644
--- a/fs_mgr/libsnapshot/snapshot_stub.cpp
+++ b/fs_mgr/libsnapshot/snapshot_stub.cpp
@@ -20,6 +20,7 @@
 
 using android::fs_mgr::CreateLogicalPartitionParams;
 using chromeos_update_engine::DeltaArchiveManifest;
+using chromeos_update_engine::FileDescriptor;
 
 namespace android::snapshot {
 
@@ -129,4 +130,16 @@
     return &snapshot_merge_stats;
 }
 
+std::unique_ptr<ICowWriter> SnapshotManagerStub::OpenSnapshotWriter(
+        const CreateLogicalPartitionParams&) {
+    LOG(ERROR) << __FUNCTION__ << " should never be called.";
+    return nullptr;
+}
+
+std::unique_ptr<FileDescriptor> SnapshotManagerStub::OpenSnapshotReader(
+        const CreateLogicalPartitionParams&) {
+    LOG(ERROR) << __FUNCTION__ << " should never be called.";
+    return nullptr;
+}
+
 }  // namespace android::snapshot
diff --git a/fs_mgr/libsnapshot/snapuserd.cpp b/fs_mgr/libsnapshot/snapuserd.cpp
index a6ff4fd..3ed853f 100644
--- a/fs_mgr/libsnapshot/snapuserd.cpp
+++ b/fs_mgr/libsnapshot/snapuserd.cpp
@@ -14,113 +14,644 @@
  * limitations under the License.
  */
 
-#include <linux/types.h>
+#include <csignal>
 
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/stringprintf.h>
-#include <android-base/unique_fd.h>
-#include <libdm/dm.h>
+#include <libsnapshot/snapuserd.h>
+#include <libsnapshot/snapuserd_daemon.h>
+#include <libsnapshot/snapuserd_server.h>
 
+namespace android {
+namespace snapshot {
+
+using namespace android;
+using namespace android::dm;
 using android::base::unique_fd;
 
 #define DM_USER_MAP_READ 0
 #define DM_USER_MAP_WRITE 1
 
-struct dm_user_message {
-    __u64 seq;
-    __u64 type;
-    __u64 flags;
-    __u64 sector;
-    __u64 len;
-    __u8 buf[];
+static constexpr size_t PAYLOAD_SIZE = (1UL << 16);
+
+static_assert(PAYLOAD_SIZE >= BLOCK_SIZE);
+
+class Target {
+  public:
+    // Represents an already-created Target, which is referenced by UUID.
+    Target(std::string uuid) : uuid_(uuid) {}
+
+    const auto& uuid() { return uuid_; }
+    std::string control_path() { return std::string("/dev/dm-user-") + uuid(); }
+
+  private:
+    const std::string uuid_;
 };
 
-using namespace android::dm;
+void BufferSink::Initialize(size_t size) {
+    buffer_size_ = size;
+    buffer_offset_ = 0;
+    buffer_ = std::make_unique<uint8_t[]>(size);
+}
 
-static int daemon_main(const std::string& device) {
-    unique_fd block_fd(open(device.c_str(), O_RDWR));
-    if (block_fd < 0) {
-        PLOG(ERROR) << "Unable to open " << device;
-        return 1;
+void* BufferSink::GetPayloadBuffer(size_t size) {
+    if ((buffer_size_ - buffer_offset_) < size) return nullptr;
+
+    char* buffer = reinterpret_cast<char*>(GetBufPtr());
+    struct dm_user_message* msg = (struct dm_user_message*)(&(buffer[0]));
+    return (char*)msg->payload.buf + buffer_offset_;
+}
+
+void* BufferSink::GetBuffer(size_t requested, size_t* actual) {
+    void* buf = GetPayloadBuffer(requested);
+    if (!buf) {
+        *actual = 0;
+        return nullptr;
+    }
+    *actual = requested;
+    return buf;
+}
+
+struct dm_user_header* BufferSink::GetHeaderPtr() {
+    CHECK(sizeof(struct dm_user_header) <= buffer_size_);
+    char* buf = reinterpret_cast<char*>(GetBufPtr());
+    struct dm_user_header* header = (struct dm_user_header*)(&(buf[0]));
+    return header;
+}
+
+// Construct kernel COW header in memory
+// This header will be in sector 0. The IO
+// request will always be 4k. After constructing
+// the header, zero out the remaining block.
+int Snapuserd::ConstructKernelCowHeader() {
+    void* buffer = bufsink_.GetPayloadBuffer(BLOCK_SIZE);
+    CHECK(buffer != nullptr);
+
+    memset(buffer, 0, BLOCK_SIZE);
+
+    struct disk_header* dh = reinterpret_cast<struct disk_header*>(buffer);
+
+    dh->magic = SNAP_MAGIC;
+    dh->valid = SNAPSHOT_VALID;
+    dh->version = SNAPSHOT_DISK_VERSION;
+    dh->chunk_size = CHUNK_SIZE;
+
+    return BLOCK_SIZE;
+}
+
+// Start the replace operation. This will read the
+// internal COW format and if the block is compressed,
+// it will be de-compressed.
+int Snapuserd::ProcessReplaceOp(const CowOperation* cow_op) {
+    if (!reader_->ReadData(*cow_op, &bufsink_)) {
+        LOG(ERROR) << "ReadData failed for chunk: " << cow_op->new_block;
+        return -EIO;
     }
 
-    unique_fd ctrl_fd(open("/dev/dm-user", O_RDWR));
-    if (ctrl_fd < 0) {
-        PLOG(ERROR) << "Unable to open /dev/dm-user";
-        return 1;
+    return BLOCK_SIZE;
+}
+
+// Start the copy operation. This will read the backing
+// block device which is represented by cow_op->source.
+int Snapuserd::ProcessCopyOp(const CowOperation* cow_op) {
+    void* buffer = bufsink_.GetPayloadBuffer(BLOCK_SIZE);
+    CHECK(buffer != nullptr);
+
+    // Issue a single 4K IO. However, this can be optimized
+    // if the successive blocks are contiguous.
+    if (!android::base::ReadFullyAtOffset(backing_store_fd_, buffer, BLOCK_SIZE,
+                                          cow_op->source * BLOCK_SIZE)) {
+        LOG(ERROR) << "Copy-op failed. Read from backing store at: " << cow_op->source;
+        return -1;
     }
 
-    size_t buf_size = 1UL << 16;
-    auto buf = std::make_unique<char>(buf_size);
+    return BLOCK_SIZE;
+}
 
-    /* Just keeps pumping messages between userspace and the kernel.  We won't
-     * actually be doing anything, but the sequence numbers line up so it'll at
-     * least make forward progress. */
-    while (true) {
-        struct dm_user_message* msg = (struct dm_user_message*)buf.get();
+int Snapuserd::ProcessZeroOp() {
+    // Zero out the entire block
+    void* buffer = bufsink_.GetPayloadBuffer(BLOCK_SIZE);
+    CHECK(buffer != nullptr);
 
-        memset(buf.get(), 0, buf_size);
+    memset(buffer, 0, BLOCK_SIZE);
+    return BLOCK_SIZE;
+}
 
-        ssize_t readed = read(ctrl_fd.get(), buf.get(), buf_size);
-        if (readed < 0) {
-            PLOG(ERROR) << "Control read failed, trying with more space";
-            buf_size *= 2;
-            buf = std::make_unique<char>(buf_size);
-            continue;
-        }
+/*
+ * Read the data of size bytes from a given chunk.
+ *
+ * Kernel can potentially merge the blocks if the
+ * successive chunks are contiguous. For chunk size of 8,
+ * there can be 256 disk exceptions; and if
+ * all 256 disk exceptions are contiguous, kernel can merge
+ * them into a single IO.
+ *
+ * Since each chunk in the disk exception
+ * mapping represents a 4k block, kernel can potentially
+ * issue 256*4k = 1M IO in one shot.
+ *
+ * Even though kernel assumes that the blocks are
+ * contiguous, we need to split the 1M IO into 4k chunks
+ * as each operation represents 4k and it can either be:
+ *
+ * 1: Replace operation
+ * 2: Copy operation
+ * 3: Zero operation
+ *
+ */
+int Snapuserd::ReadData(chunk_t chunk, size_t size) {
+    int ret = 0;
 
-        LOG(DEBUG) << android::base::StringPrintf("read() from dm-user returned %d bytes:",
-                                                  (int)readed);
-        LOG(DEBUG) << android::base::StringPrintf("    msg->seq:    0x%016llx", msg->seq);
-        LOG(DEBUG) << android::base::StringPrintf("    msg->type:   0x%016llx", msg->type);
-        LOG(DEBUG) << android::base::StringPrintf("    msg->flags:  0x%016llx", msg->flags);
-        LOG(DEBUG) << android::base::StringPrintf("    msg->sector: 0x%016llx", msg->sector);
-        LOG(DEBUG) << android::base::StringPrintf("    msg->len:    0x%016llx", msg->len);
+    size_t read_size = size;
 
-        switch (msg->type) {
-            case DM_USER_MAP_READ: {
-                LOG(DEBUG) << android::base::StringPrintf(
-                        "Responding to read of sector %lld with %lld bytes data", msg->sector,
-                        msg->len);
+    chunk_t chunk_key = chunk;
+    uint32_t stride;
+    lldiv_t divresult;
 
-                if ((sizeof(*msg) + msg->len) > buf_size) {
-                    auto old_buf = std::move(buf);
-                    buf_size = sizeof(*msg) + msg->len;
-                    buf = std::make_unique<char>(buf_size);
-                    memcpy(buf.get(), old_buf.get(), sizeof(*msg));
-                    msg = (struct dm_user_message*)buf.get();
-                }
+    // Size should always be aligned
+    CHECK((read_size & (BLOCK_SIZE - 1)) == 0);
 
-                if (lseek(block_fd.get(), msg->sector * 512, SEEK_SET) < 0) {
-                    PLOG(ERROR) << "lseek failed: " << device;
-                    return 7;
-                }
-                if (!android::base::ReadFully(block_fd.get(), msg->buf, msg->len)) {
-                    PLOG(ERROR) << "read failed: " << device;
-                    return 7;
-                }
+    while (read_size > 0) {
+        const CowOperation* cow_op = chunk_vec_[chunk_key];
+        CHECK(cow_op != nullptr);
+        int result;
 
-                if (!android::base::WriteFully(ctrl_fd.get(), buf.get(), sizeof(*msg) + msg->len)) {
-                    PLOG(ERROR) << "write control failed";
-                    return 3;
-                }
+        switch (cow_op->type) {
+            case kCowReplaceOp: {
+                result = ProcessReplaceOp(cow_op);
                 break;
             }
 
-            case DM_USER_MAP_WRITE:
-                abort();
+            case kCowZeroOp: {
+                result = ProcessZeroOp();
                 break;
+            }
+
+            case kCowCopyOp: {
+                result = ProcessCopyOp(cow_op);
+                break;
+            }
+
+            default: {
+                LOG(ERROR) << "Unknown operation-type found: " << cow_op->type;
+                ret = -EIO;
+                goto done;
+            }
         }
 
-        LOG(DEBUG) << "read() finished, next message";
+        if (result < 0) {
+            ret = result;
+            goto done;
+        }
+
+        // Update the buffer offset
+        bufsink_.UpdateBufferOffset(BLOCK_SIZE);
+
+        read_size -= BLOCK_SIZE;
+        ret += BLOCK_SIZE;
+
+        // Start iterating the chunk incrementally; Since while
+        // constructing the metadata, we know that the chunk IDs
+        // are contiguous
+        chunk_key += 1;
+
+        // This is similar to the way when chunk IDs were assigned
+        // in ReadMetadata().
+        //
+        // Skip if the chunk id represents a metadata chunk.
+        stride = exceptions_per_area_ + 1;
+        divresult = lldiv(chunk_key, stride);
+        if (divresult.rem == NUM_SNAPSHOT_HDR_CHUNKS) {
+            // Crossing exception boundary. Kernel will never
+            // issue IO which is spanning between a data chunk
+            // and a metadata chunk. This should be perfectly aligned.
+            //
+            // Since the input read_size is 4k aligned, we will
+            // always end up reading all 256 data chunks in one area.
+            // Thus, every multiple of 4K IO represents 256 data chunks
+            CHECK(read_size == 0);
+            break;
+        }
+    }
+
+done:
+
+    // Reset the buffer offset
+    bufsink_.ResetBufferOffset();
+    return ret;
+}
+
+/*
+ * dm-snap does prefetch reads while reading disk-exceptions.
+ * By default, prefetch value is set to 12; this means that
+ * dm-snap will issue 12 areas wherein each area is a 4k page
+ * of disk-exceptions.
+ *
+ * If during prefetch, if the chunk-id seen is beyond the
+ * actual number of metadata page, fill the buffer with zero.
+ * When dm-snap starts parsing the buffer, it will stop
+ * reading metadata page once the buffer content is zero.
+ */
+int Snapuserd::ZerofillDiskExceptions(size_t read_size) {
+    size_t size = exceptions_per_area_ * sizeof(struct disk_exception);
+
+    if (read_size > size) return -EINVAL;
+
+    void* buffer = bufsink_.GetPayloadBuffer(size);
+    CHECK(buffer != nullptr);
+
+    memset(buffer, 0, size);
+    return size;
+}
+
+/*
+ * A disk exception is a simple mapping of old_chunk to new_chunk.
+ * When dm-snapshot device is created, kernel requests these mapping.
+ *
+ * Each disk exception is of size 16 bytes. Thus a single 4k page can
+ * have:
+ *
+ * exceptions_per_area_ = 4096/16 = 256. This entire 4k page
+ * is considered a metadata page and it is represented by chunk ID.
+ *
+ * Convert the chunk ID to index into the vector which gives us
+ * the metadata page.
+ */
+int Snapuserd::ReadDiskExceptions(chunk_t chunk, size_t read_size) {
+    uint32_t stride = exceptions_per_area_ + 1;
+    size_t size;
+
+    // ChunkID to vector index
+    lldiv_t divresult = lldiv(chunk, stride);
+
+    if (divresult.quot < vec_.size()) {
+        size = exceptions_per_area_ * sizeof(struct disk_exception);
+
+        if (read_size > size) return -EINVAL;
+
+        void* buffer = bufsink_.GetPayloadBuffer(size);
+        CHECK(buffer != nullptr);
+
+        memcpy(buffer, vec_[divresult.quot].get(), size);
+    } else {
+        size = ZerofillDiskExceptions(read_size);
+    }
+
+    return size;
+}
+
+/*
+ * Read the metadata from COW device and
+ * construct the metadata as required by the kernel.
+ *
+ * Please see design on kernel COW format
+ *
+ * 1: Read the metadata from internal COW device
+ * 2: There are 3 COW operations:
+ *     a: Replace op
+ *     b: Copy op
+ *     c: Zero op
+ * 3: For each of the 3 operations, op->new_block
+ *    represents the block number in the base device
+ *    for which one of the 3 operations have to be applied.
+ *    This represents the old_chunk in the kernel COW format
+ * 4: We need to assign new_chunk for a corresponding old_chunk
+ * 5: The algorithm is similar to how kernel assigns chunk number
+ *    while creating exceptions.
+ * 6: Use a monotonically increasing chunk number to assign the
+ *    new_chunk
+ * 7: Each chunk-id represents either a: Metadata page or b: Data page
+ * 8: Chunk-id representing a data page is stored in a vector. Index is the
+ *    chunk-id and value is the pointer to the CowOperation
+ * 9: Chunk-id representing a metadata page is converted into a vector
+ *    index. We store this in vector as kernel requests metadata during
+ *    two stage:
+ *       a: When initial dm-snapshot device is created, kernel requests
+ *          all the metadata and stores it in its internal data-structures.
+ *       b: During merge, kernel once again requests the same metadata
+ *          once-again.
+ *    In both these cases, a quick lookup based on chunk-id is done.
+ * 10: When chunk number is incremented, we need to make sure that
+ *    if the chunk is representing a metadata page and skip.
+ * 11: Each 4k page will contain 256 disk exceptions. We call this
+ *    exceptions_per_area_
+ * 12: Kernel will stop issuing metadata IO request when new-chunk ID is 0.
+ */
+int Snapuserd::ReadMetadata() {
+    reader_ = std::make_unique<CowReader>();
+    CowHeader header;
+
+    if (!reader_->Parse(cow_fd_)) {
+        LOG(ERROR) << "Failed to parse";
+        return 1;
+    }
+
+    if (!reader_->GetHeader(&header)) {
+        LOG(ERROR) << "Failed to get header";
+        return 1;
+    }
+
+    CHECK(header.block_size == BLOCK_SIZE);
+
+    LOG(DEBUG) << "Num-ops: " << std::hex << header.num_ops;
+    LOG(DEBUG) << "ops-offset: " << std::hex << header.ops_offset;
+    LOG(DEBUG) << "ops-size: " << std::hex << header.ops_size;
+
+    cowop_iter_ = reader_->GetOpIter();
+
+    if (cowop_iter_ == nullptr) {
+        LOG(ERROR) << "Failed to get cowop_iter";
+        return 1;
+    }
+
+    exceptions_per_area_ = (CHUNK_SIZE << SECTOR_SHIFT) / sizeof(struct disk_exception);
+
+    // Start from chunk number 2. Chunk 0 represents header and chunk 1
+    // represents first metadata page.
+    chunk_t next_free = NUM_SNAPSHOT_HDR_CHUNKS + 1;
+    chunk_vec_.push_back(nullptr);
+    chunk_vec_.push_back(nullptr);
+
+    loff_t offset = 0;
+    std::unique_ptr<uint8_t[]> de_ptr =
+            std::make_unique<uint8_t[]>(exceptions_per_area_ * sizeof(struct disk_exception));
+
+    // This memset is important. Kernel will stop issuing IO when new-chunk ID
+    // is 0. When Area is not filled completely will all 256 exceptions,
+    // this memset will ensure that metadata read is completed.
+    memset(de_ptr.get(), 0, (exceptions_per_area_ * sizeof(struct disk_exception)));
+    size_t num_ops = 0;
+
+    while (!cowop_iter_->Done()) {
+        const CowOperation* cow_op = &cowop_iter_->Get();
+        struct disk_exception* de =
+                reinterpret_cast<struct disk_exception*>((char*)de_ptr.get() + offset);
+
+        if (!(cow_op->type == kCowReplaceOp || cow_op->type == kCowZeroOp ||
+              cow_op->type == kCowCopyOp)) {
+            LOG(ERROR) << "Unknown operation-type found: " << cow_op->type;
+            return 1;
+        }
+
+        // Construct the disk-exception
+        de->old_chunk = cow_op->new_block;
+        de->new_chunk = next_free;
+
+        LOG(DEBUG) << "Old-chunk: " << de->old_chunk << "New-chunk: " << de->new_chunk;
+
+        // Store operation pointer. Note, new-chunk ID is the index
+        chunk_vec_.push_back(cow_op);
+        CHECK(next_free == (chunk_vec_.size() - 1));
+
+        offset += sizeof(struct disk_exception);
+
+        cowop_iter_->Next();
+
+        // Find the next free chunk-id to be assigned. Check if the next free
+        // chunk-id represents a metadata page. If so, skip it.
+        next_free += 1;
+        uint32_t stride = exceptions_per_area_ + 1;
+        lldiv_t divresult = lldiv(next_free, stride);
+        num_ops += 1;
+
+        if (divresult.rem == NUM_SNAPSHOT_HDR_CHUNKS) {
+            CHECK(num_ops == exceptions_per_area_);
+            // Store it in vector at the right index. This maps the chunk-id to
+            // vector index.
+            vec_.push_back(std::move(de_ptr));
+            offset = 0;
+            num_ops = 0;
+
+            chunk_t metadata_chunk = (next_free - exceptions_per_area_ - NUM_SNAPSHOT_HDR_CHUNKS);
+
+            LOG(DEBUG) << "Area: " << vec_.size() - 1;
+            LOG(DEBUG) << "Metadata-chunk: " << metadata_chunk;
+            LOG(DEBUG) << "Sector number of Metadata-chunk: " << (metadata_chunk << CHUNK_SHIFT);
+
+            // Create buffer for next area
+            de_ptr = std::make_unique<uint8_t[]>(exceptions_per_area_ *
+                                                 sizeof(struct disk_exception));
+            memset(de_ptr.get(), 0, (exceptions_per_area_ * sizeof(struct disk_exception)));
+
+            // Since this is a metadata, store at this index
+            chunk_vec_.push_back(nullptr);
+
+            // Find the next free chunk-id
+            next_free += 1;
+            if (cowop_iter_->Done()) {
+                vec_.push_back(std::move(de_ptr));
+            }
+        }
+    }
+
+    // Partially filled area
+    if (num_ops) {
+        LOG(DEBUG) << "Partially filled area num_ops: " << num_ops;
+        vec_.push_back(std::move(de_ptr));
     }
 
     return 0;
 }
 
+void MyLogger(android::base::LogId, android::base::LogSeverity severity, const char*, const char*,
+              unsigned int, const char* message) {
+    if (severity == android::base::ERROR) {
+        fprintf(stderr, "%s\n", message);
+    } else {
+        fprintf(stdout, "%s\n", message);
+    }
+}
+
+// Read Header from dm-user misc device. This gives
+// us the sector number for which IO is issued by dm-snapshot device
+int Snapuserd::ReadDmUserHeader() {
+    int ret;
+
+    ret = read(ctrl_fd_, bufsink_.GetBufPtr(), sizeof(struct dm_user_header));
+    if (ret < 0) {
+        PLOG(ERROR) << "Control-read failed with: " << ret;
+        return ret;
+    }
+
+    return sizeof(struct dm_user_header);
+}
+
+// Send the payload/data back to dm-user misc device.
+int Snapuserd::WriteDmUserPayload(size_t size) {
+    if (!android::base::WriteFully(ctrl_fd_, bufsink_.GetBufPtr(),
+                                   sizeof(struct dm_user_header) + size)) {
+        PLOG(ERROR) << "Write to dm-user failed";
+        return -1;
+    }
+
+    return sizeof(struct dm_user_header) + size;
+}
+
+bool Snapuserd::Init() {
+    backing_store_fd_.reset(open(backing_store_device_.c_str(), O_RDONLY));
+    if (backing_store_fd_ < 0) {
+        LOG(ERROR) << "Open Failed: " << backing_store_device_;
+        return false;
+    }
+
+    cow_fd_.reset(open(cow_device_.c_str(), O_RDWR));
+    if (cow_fd_ < 0) {
+        LOG(ERROR) << "Open Failed: " << cow_device_;
+        return false;
+    }
+
+    std::string str(cow_device_);
+    std::size_t found = str.find_last_of("/\\");
+    CHECK(found != std::string::npos);
+    std::string device_name = str.substr(found + 1);
+
+    LOG(DEBUG) << "Fetching UUID for: " << device_name;
+
+    auto& dm = dm::DeviceMapper::Instance();
+    std::string uuid;
+    if (!dm.GetDmDeviceUuidByName(device_name, &uuid)) {
+        LOG(ERROR) << "Unable to find UUID for " << cow_device_;
+        return false;
+    }
+
+    LOG(DEBUG) << "UUID: " << uuid;
+    Target t(uuid);
+
+    ctrl_fd_.reset(open(t.control_path().c_str(), O_RDWR));
+    if (ctrl_fd_ < 0) {
+        LOG(ERROR) << "Unable to open " << t.control_path();
+        return false;
+    }
+
+    // Allocate the buffer which is used to communicate between
+    // daemon and dm-user. The buffer comprises of header and a fixed payload.
+    // If the dm-user requests a big IO, the IO will be broken into chunks
+    // of PAYLOAD_SIZE.
+    size_t buf_size = sizeof(struct dm_user_header) + PAYLOAD_SIZE;
+    bufsink_.Initialize(buf_size);
+
+    return true;
+}
+
+int Snapuserd::Run() {
+    int ret = 0;
+
+    struct dm_user_header* header = bufsink_.GetHeaderPtr();
+
+    bufsink_.Clear();
+
+    ret = ReadDmUserHeader();
+    if (ret < 0) return ret;
+
+    LOG(DEBUG) << "dm-user returned " << ret << " bytes";
+
+    LOG(DEBUG) << "msg->seq: " << std::hex << header->seq;
+    LOG(DEBUG) << "msg->type: " << std::hex << header->type;
+    LOG(DEBUG) << "msg->flags: " << std::hex << header->flags;
+    LOG(DEBUG) << "msg->sector: " << std::hex << header->sector;
+    LOG(DEBUG) << "msg->len: " << std::hex << header->len;
+
+    switch (header->type) {
+        case DM_USER_MAP_READ: {
+            size_t remaining_size = header->len;
+            loff_t offset = 0;
+            header->io_in_progress = 0;
+            ret = 0;
+            do {
+                size_t read_size = std::min(PAYLOAD_SIZE, remaining_size);
+
+                // Request to sector 0 is always for kernel
+                // representation of COW header. This IO should be only
+                // once during dm-snapshot device creation. We should
+                // never see multiple IO requests. Additionally this IO
+                // will always be a single 4k.
+                if (header->sector == 0) {
+                    // Read the metadata from internal COW device
+                    // and build the in-memory data structures
+                    // for all the operations in the internal COW.
+                    if (!metadata_read_done_ && ReadMetadata()) {
+                        LOG(ERROR) << "Metadata read failed";
+                        return 1;
+                    }
+                    metadata_read_done_ = true;
+
+                    CHECK(read_size == BLOCK_SIZE);
+                    ret = ConstructKernelCowHeader();
+                    if (ret < 0) return ret;
+                } else {
+                    // Convert the sector number to a chunk ID.
+                    //
+                    // Check if the chunk ID represents a metadata
+                    // page. If the chunk ID is not found in the
+                    // vector, then it points to a metadata page.
+                    chunk_t chunk = (header->sector >> CHUNK_SHIFT);
+
+                    if (chunk >= chunk_vec_.size()) {
+                        ret = ZerofillDiskExceptions(read_size);
+                        if (ret < 0) {
+                            LOG(ERROR) << "ZerofillDiskExceptions failed";
+                            return ret;
+                        }
+                    } else if (chunk_vec_[chunk] == nullptr) {
+                        ret = ReadDiskExceptions(chunk, read_size);
+                        if (ret < 0) {
+                            LOG(ERROR) << "ReadDiskExceptions failed";
+                            return ret;
+                        }
+                    } else {
+                        chunk_t num_chunks_read = (offset >> BLOCK_SHIFT);
+                        ret = ReadData(chunk + num_chunks_read, read_size);
+                        if (ret < 0) {
+                            LOG(ERROR) << "ReadData failed";
+                            // TODO: Bug 168259959: All the error paths from this function
+                            // should send error code to dm-user thereby IO
+                            // terminates with an error from dm-user. Returning
+                            // here without sending error code will block the
+                            // IO.
+                            return ret;
+                        }
+                    }
+                }
+
+                ssize_t written = WriteDmUserPayload(ret);
+                if (written < 0) return written;
+
+                remaining_size -= ret;
+                offset += ret;
+                if (remaining_size) {
+                    LOG(DEBUG) << "Write done ret: " << ret
+                               << " remaining size: " << remaining_size;
+                    bufsink_.GetHeaderPtr()->io_in_progress = 1;
+                }
+            } while (remaining_size);
+
+            break;
+        }
+
+        case DM_USER_MAP_WRITE: {
+            // TODO: Bug: 168311203: After merge operation is completed, kernel issues write
+            // to flush all the exception mappings where the merge is
+            // completed. If dm-user routes the WRITE IO, we need to clear
+            // in-memory data structures representing those exception
+            // mappings.
+            abort();
+            break;
+        }
+    }
+
+    LOG(DEBUG) << "read() finished, next message";
+
+    return 0;
+}
+
+}  // namespace snapshot
+}  // namespace android
+
 int main([[maybe_unused]] int argc, char** argv) {
     android::base::InitLogging(argv, &android::base::KernelLogger);
-    daemon_main(argv[1]);
+
+    android::snapshot::Daemon& daemon = android::snapshot::Daemon::Instance();
+
+    daemon.StartServer(argv[1]);
+    daemon.Run();
+
     return 0;
 }
diff --git a/fs_mgr/libsnapshot/snapuserd_client.cpp b/fs_mgr/libsnapshot/snapuserd_client.cpp
new file mode 100644
index 0000000..bef8f5c
--- /dev/null
+++ b/fs_mgr/libsnapshot/snapuserd_client.cpp
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2020 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 <arpa/inet.h>
+#include <cutils/sockets.h>
+#include <errno.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <chrono>
+
+#include <android-base/logging.h>
+#include <libsnapshot/snapuserd_client.h>
+
+namespace android {
+namespace snapshot {
+
+bool SnapuserdClient::ConnectToServerSocket(std::string socketname) {
+    sockfd_ = 0;
+
+    sockfd_ =
+            socket_local_client(socketname.c_str(), ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM);
+    if (sockfd_ < 0) {
+        LOG(ERROR) << "Failed to connect to " << socketname;
+        return false;
+    }
+
+    std::string msg = "query";
+
+    int sendRet = Sendmsg(msg.c_str(), msg.size());
+    if (sendRet < 0) {
+        LOG(ERROR) << "Failed to send query message to snapuserd daemon with socket " << socketname;
+        DisconnectFromServer();
+        return false;
+    }
+
+    std::string str = Receivemsg();
+
+    if (str.find("fail") != std::string::npos) {
+        LOG(ERROR) << "Failed to receive message from snapuserd daemon with socket " << socketname;
+        DisconnectFromServer();
+        return false;
+    }
+
+    // If the daemon is passive then fallback to secondary active daemon. Daemon
+    // is passive during transition phase. Please see RestartSnapuserd()
+    if (str.find("passive") != std::string::npos) {
+        LOG(DEBUG) << "Snapuserd is passive with socket " << socketname;
+        DisconnectFromServer();
+        return false;
+    }
+
+    CHECK(str.find("active") != std::string::npos);
+
+    return true;
+}
+
+bool SnapuserdClient::ConnectToServer() {
+    if (ConnectToServerSocket(GetSocketNameFirstStage())) return true;
+
+    if (ConnectToServerSocket(GetSocketNameSecondStage())) return true;
+
+    return false;
+}
+
+int SnapuserdClient::Sendmsg(const char* msg, size_t size) {
+    int numBytesSent = TEMP_FAILURE_RETRY(send(sockfd_, msg, size, 0));
+    if (numBytesSent < 0) {
+        LOG(ERROR) << "Send failed " << strerror(errno);
+        return -1;
+    }
+
+    if ((uint)numBytesSent < size) {
+        LOG(ERROR) << "Partial data sent " << strerror(errno);
+        return -1;
+    }
+
+    return 0;
+}
+
+std::string SnapuserdClient::Receivemsg() {
+    int ret;
+    struct timeval tv;
+    fd_set set;
+    char msg[PACKET_SIZE];
+    std::string msgStr("fail");
+
+    tv.tv_sec = 2;
+    tv.tv_usec = 0;
+    FD_ZERO(&set);
+    FD_SET(sockfd_, &set);
+    ret = select(sockfd_ + 1, &set, NULL, NULL, &tv);
+    if (ret == -1) {  // select failed
+        LOG(ERROR) << "Snapuserd:client: Select call failed";
+    } else if (ret == 0) {  // timeout
+        LOG(ERROR) << "Snapuserd:client: Select call timeout";
+    } else {
+        ret = TEMP_FAILURE_RETRY(recv(sockfd_, msg, PACKET_SIZE, 0));
+        if (ret < 0) {
+            PLOG(ERROR) << "Snapuserd:client: recv failed";
+        } else if (ret == 0) {
+            LOG(DEBUG) << "Snapuserd:client disconnected";
+        } else {
+            msgStr.clear();
+            msgStr = msg;
+        }
+    }
+    return msgStr;
+}
+
+#if 0
+std::string SnapuserdClient::Receivemsg() {
+    char msg[PACKET_SIZE];
+    std::string msgStr("fail");
+    int ret;
+
+    ret = TEMP_FAILURE_RETRY(recv(sockfd_, msg, PACKET_SIZE, 0));
+    if (ret <= 0) {
+        LOG(ERROR) << "recv failed " << strerror(errno);
+        return msgStr;
+    }
+
+    msgStr.clear();
+    msgStr = msg;
+    return msgStr;
+}
+#endif
+
+int SnapuserdClient::StopSnapuserd(bool firstStageDaemon) {
+    if (firstStageDaemon) {
+        sockfd_ = socket_local_client(GetSocketNameFirstStage().c_str(),
+                                      ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM);
+        if (sockfd_ < 0) {
+            LOG(ERROR) << "Failed to connect to " << GetSocketNameFirstStage();
+            return -1;
+        }
+    } else {
+        if (!ConnectToServer()) {
+            LOG(ERROR) << "Failed to connect to socket " << GetSocketNameSecondStage();
+            return -1;
+        }
+    }
+
+    std::string msg = "stop";
+
+    int sendRet = Sendmsg(msg.c_str(), msg.size());
+    if (sendRet < 0) {
+        LOG(ERROR) << "Failed to send stop message to snapuserd daemon";
+        return -1;
+    }
+
+    DisconnectFromServer();
+
+    return 0;
+}
+
+int SnapuserdClient::StartSnapuserdaemon(std::string socketname) {
+    int retry_count = 0;
+
+    if (fork() == 0) {
+        const char* argv[] = {"/system/bin/snapuserd", socketname.c_str(), nullptr};
+        if (execv(argv[0], const_cast<char**>(argv))) {
+            LOG(ERROR) << "Failed to exec snapuserd daemon";
+            return -1;
+        }
+    }
+
+    // snapuserd is a daemon and will never exit; parent can't wait here
+    // to get the return code. Since Snapuserd starts the socket server,
+    // give it some time to fully launch.
+    //
+    // Try to connect to server to verify snapuserd server is started
+    while (retry_count < MAX_CONNECT_RETRY_COUNT) {
+        if (!ConnectToServer()) {
+            retry_count++;
+            std::this_thread::sleep_for(std::chrono::milliseconds(500));
+        } else {
+            close(sockfd_);
+            return 0;
+        }
+    }
+
+    LOG(ERROR) << "Failed to start snapuserd daemon";
+    return -1;
+}
+
+int SnapuserdClient::StartSnapuserd() {
+    if (StartSnapuserdaemon(GetSocketNameFirstStage()) < 0) return -1;
+
+    return 0;
+}
+
+int SnapuserdClient::InitializeSnapuserd(std::string cow_device, std::string backing_device) {
+    int ret = 0;
+
+    if (!ConnectToServer()) {
+        LOG(ERROR) << "Failed to connect to server ";
+        return -1;
+    }
+
+    std::string msg = "start," + cow_device + "," + backing_device;
+
+    ret = Sendmsg(msg.c_str(), msg.size());
+    if (ret < 0) {
+        LOG(ERROR) << "Failed to send message " << msg << " to snapuserd daemon";
+        return -1;
+    }
+
+    std::string str = Receivemsg();
+
+    if (str.find("fail") != std::string::npos) {
+        LOG(ERROR) << "Failed to receive ack for " << msg << " from snapuserd daemon";
+        return -1;
+    }
+
+    DisconnectFromServer();
+
+    LOG(DEBUG) << "Snapuserd daemon initialized with " << msg;
+    return 0;
+}
+
+/*
+ * Transition from first stage snapuserd daemon to second stage daemon involves
+ * series of steps viz:
+ *
+ * 1: Create new dm-user devices - This is done by libsnapshot
+ *
+ * 2: Spawn the new snapuserd daemon - This is the second stage daemon which
+ * will start the server but the dm-user misc devices is not binded yet.
+ *
+ * 3: Vector to this function contains pair of cow_device and source device.
+ *    Ex: {{system_cow,system_a}, {product_cow, product_a}, {vendor_cow,
+ *    vendor_a}}. This vector will be populated by the libsnapshot.
+ *
+ * 4: Initialize the Second stage daemon passing the information from the
+ * vector. This will bind the daemon with dm-user misc device and will be ready
+ * to serve the IO. Up until this point, first stage daemon is still active.
+ * However, client library will mark the first stage daemon as passive and hence
+ * all the control message from hereon will be sent to active second stage
+ * daemon.
+ *
+ * 5: Create new dm-snapshot table. This is done by libsnapshot. When new table
+ * is created, kernel will issue metadata read once again which will be served
+ * by second stage daemon. However, any active IO will still be served by first
+ * stage daemon.
+ *
+ * 6: Swap the snapshot table atomically - This is done by libsnapshot. Once
+ * the swapping is done, all the IO will be served by second stage daemon.
+ *
+ * 7: Stop the first stage daemon. After this point second stage daemon is
+ * completely active to serve the IO and merging process.
+ *
+ */
+int SnapuserdClient::RestartSnapuserd(std::vector<std::pair<std::string, std::string>>& vec) {
+    // Connect to first-stage daemon and send a terminate-request control
+    // message. This will not terminate the daemon but will mark the daemon as
+    // passive.
+    if (!ConnectToServer()) {
+        LOG(ERROR) << "Failed to connect to server ";
+        return -1;
+    }
+
+    std::string msg = "terminate-request";
+
+    int sendRet = Sendmsg(msg.c_str(), msg.size());
+    if (sendRet < 0) {
+        LOG(ERROR) << "Failed to send message " << msg << " to snapuserd daemon";
+        return -1;
+    }
+
+    std::string str = Receivemsg();
+
+    if (str.find("fail") != std::string::npos) {
+        LOG(ERROR) << "Failed to receive ack for " << msg << " from snapuserd daemon";
+        return -1;
+    }
+
+    CHECK(str.find("success") != std::string::npos);
+
+    DisconnectFromServer();
+
+    // Start the new daemon
+    if (StartSnapuserdaemon(GetSocketNameSecondStage()) < 0) {
+        LOG(ERROR) << "Failed to start new daemon at socket " << GetSocketNameSecondStage();
+        return -1;
+    }
+
+    LOG(DEBUG) << "Second stage Snapuserd daemon created successfully at socket "
+               << GetSocketNameSecondStage();
+    CHECK(vec.size() % 2 == 0);
+
+    for (int i = 0; i < vec.size(); i++) {
+        std::string& cow_device = vec[i].first;
+        std::string& base_device = vec[i].second;
+
+        InitializeSnapuserd(cow_device, base_device);
+        LOG(DEBUG) << "Daemon initialized with " << cow_device << " and " << base_device;
+    }
+
+    return 0;
+}
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/snapuserd_daemon.cpp b/fs_mgr/libsnapshot/snapuserd_daemon.cpp
new file mode 100644
index 0000000..8e76618
--- /dev/null
+++ b/fs_mgr/libsnapshot/snapuserd_daemon.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2020 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 <android-base/logging.h>
+#include <libsnapshot/snapuserd_daemon.h>
+
+namespace android {
+namespace snapshot {
+
+int Daemon::StartServer(std::string socketname) {
+    int ret;
+
+    ret = server_.Start(socketname);
+    if (ret < 0) {
+        LOG(ERROR) << "Snapuserd daemon failed to start...";
+        exit(EXIT_FAILURE);
+    }
+
+    return ret;
+}
+
+void Daemon::MaskAllSignalsExceptIntAndTerm() {
+    sigset_t signal_mask;
+    sigfillset(&signal_mask);
+    sigdelset(&signal_mask, SIGINT);
+    sigdelset(&signal_mask, SIGTERM);
+    sigdelset(&signal_mask, SIGPIPE);
+    if (sigprocmask(SIG_SETMASK, &signal_mask, NULL) != 0) {
+        PLOG(ERROR) << "Failed to set sigprocmask";
+    }
+}
+
+void Daemon::MaskAllSignals() {
+    sigset_t signal_mask;
+    sigfillset(&signal_mask);
+    if (sigprocmask(SIG_SETMASK, &signal_mask, NULL) != 0) {
+        PLOG(ERROR) << "Couldn't mask all signals";
+    }
+}
+
+Daemon::Daemon() {
+    is_running_ = true;
+}
+
+bool Daemon::IsRunning() {
+    return is_running_;
+}
+
+void Daemon::Run() {
+    poll_fd_ = std::make_unique<struct pollfd>();
+    poll_fd_->fd = server_.GetSocketFd().get();
+    poll_fd_->events = POLLIN;
+
+    sigfillset(&signal_mask_);
+    sigdelset(&signal_mask_, SIGINT);
+    sigdelset(&signal_mask_, SIGTERM);
+
+    // Masking signals here ensure that after this point, we won't handle INT/TERM
+    // until after we call into ppoll()
+    MaskAllSignals();
+    signal(SIGINT, Daemon::SignalHandler);
+    signal(SIGTERM, Daemon::SignalHandler);
+    signal(SIGPIPE, Daemon::SignalHandler);
+
+    LOG(DEBUG) << "Snapuserd-server: ready to accept connections";
+
+    while (IsRunning()) {
+        int ret = ppoll(poll_fd_.get(), 1, nullptr, &signal_mask_);
+        MaskAllSignalsExceptIntAndTerm();
+
+        if (ret == -1) {
+            PLOG(ERROR) << "Snapuserd:ppoll error";
+            break;
+        }
+
+        if (poll_fd_->revents == POLLIN) {
+            if (server_.AcceptClient() == static_cast<int>(DaemonOperations::STOP)) {
+                Daemon::Instance().is_running_ = false;
+            }
+        }
+
+        // Mask all signals to ensure that is_running_ can't become false between
+        // checking it in the while condition and calling into ppoll()
+        MaskAllSignals();
+    }
+}
+
+void Daemon::SignalHandler(int signal) {
+    LOG(DEBUG) << "Snapuserd received signal: " << signal;
+    switch (signal) {
+        case SIGINT:
+        case SIGTERM: {
+            Daemon::Instance().is_running_ = false;
+            break;
+        }
+        case SIGPIPE: {
+            LOG(ERROR) << "Received SIGPIPE signal";
+            break;
+        }
+        default:
+            LOG(ERROR) << "Received unknown signal " << signal;
+            break;
+    }
+}
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/libsnapshot/snapuserd_server.cpp b/fs_mgr/libsnapshot/snapuserd_server.cpp
new file mode 100644
index 0000000..1f8dd63
--- /dev/null
+++ b/fs_mgr/libsnapshot/snapuserd_server.cpp
@@ -0,0 +1,242 @@
+/*
+ * Copyright (C) 2020 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 <arpa/inet.h>
+#include <cutils/sockets.h>
+#include <errno.h>
+#include <netinet/in.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <android-base/logging.h>
+#include <libsnapshot/snapuserd.h>
+#include <libsnapshot/snapuserd_server.h>
+
+namespace android {
+namespace snapshot {
+
+DaemonOperations SnapuserdServer::Resolveop(std::string& input) {
+    if (input == "start") return DaemonOperations::START;
+    if (input == "stop") return DaemonOperations::STOP;
+    if (input == "terminate-request") return DaemonOperations::TERMINATING;
+    if (input == "query") return DaemonOperations::QUERY;
+
+    return DaemonOperations::INVALID;
+}
+
+std::string SnapuserdServer::GetDaemonStatus() {
+    std::string msg = "";
+
+    if (IsTerminating())
+        msg = "passive";
+    else
+        msg = "active";
+
+    return msg;
+}
+
+void SnapuserdServer::Parsemsg(std::string const& msg, const char delim,
+                               std::vector<std::string>& out) {
+    std::stringstream ss(msg);
+    std::string s;
+
+    while (std::getline(ss, s, delim)) {
+        out.push_back(s);
+    }
+}
+
+// new thread
+void SnapuserdServer::ThreadStart(std::string cow_device, std::string backing_device) {
+    Snapuserd snapd(cow_device, backing_device);
+    if (!snapd.Init()) {
+        PLOG(ERROR) << "Snapuserd: Init failed";
+        return;
+    }
+
+    while (StopRequested() == false) {
+        int ret = snapd.Run();
+
+        if (ret == -ETIMEDOUT) continue;
+
+        if (ret < 0) {
+            PLOG(ERROR) << "snapd.Run() failed..." << ret;
+        }
+    }
+}
+
+void SnapuserdServer::ShutdownThreads() {
+    StopThreads();
+
+    for (auto& client : clients_vec_) {
+        auto& th = client->GetThreadHandler();
+
+        if (th->joinable()) th->join();
+    }
+}
+
+int SnapuserdServer::Sendmsg(int fd, char* msg, size_t size) {
+    int ret = TEMP_FAILURE_RETRY(send(fd, (char*)msg, size, 0));
+    if (ret < 0) {
+        PLOG(ERROR) << "Snapuserd:server: send() failed";
+        return -1;
+    }
+
+    if (ret < size) {
+        PLOG(ERROR) << "Partial data sent";
+        return -1;
+    }
+
+    return 0;
+}
+
+std::string SnapuserdServer::Recvmsg(int fd, int* ret) {
+    struct timeval tv;
+    fd_set set;
+    char msg[MAX_PACKET_SIZE];
+
+    tv.tv_sec = 2;
+    tv.tv_usec = 0;
+    FD_ZERO(&set);
+    FD_SET(fd, &set);
+    *ret = select(fd + 1, &set, NULL, NULL, &tv);
+    if (*ret == -1) {  // select failed
+        return {};
+    } else if (*ret == 0) {  // timeout
+        return {};
+    } else {
+        *ret = TEMP_FAILURE_RETRY(recv(fd, msg, MAX_PACKET_SIZE, 0));
+        if (*ret < 0) {
+            PLOG(ERROR) << "Snapuserd:server: recv failed";
+            return {};
+        } else if (*ret == 0) {
+            LOG(DEBUG) << "Snapuserd client disconnected";
+            return {};
+        } else {
+            std::string str(msg);
+            return str;
+        }
+    }
+}
+
+int SnapuserdServer::Receivemsg(int fd) {
+    char msg[MAX_PACKET_SIZE];
+    std::unique_ptr<Client> newClient;
+    int ret = 0;
+
+    while (1) {
+        memset(msg, '\0', MAX_PACKET_SIZE);
+        std::string str = Recvmsg(fd, &ret);
+
+        if (ret <= 0) {
+            LOG(DEBUG) << "recv failed with ret: " << ret;
+            return 0;
+        }
+
+        const char delim = ',';
+
+        std::vector<std::string> out;
+        Parsemsg(str, delim, out);
+        DaemonOperations op = Resolveop(out[0]);
+        memset(msg, '\0', MAX_PACKET_SIZE);
+
+        switch (op) {
+            case DaemonOperations::START: {
+                // Message format:
+                // start,<cow_device_path>,<source_device_path>
+                //
+                // Start the new thread which binds to dm-user misc device
+                newClient = std::make_unique<Client>();
+                newClient->SetThreadHandler(
+                        std::bind(&SnapuserdServer::ThreadStart, this, out[1], out[2]));
+                clients_vec_.push_back(std::move(newClient));
+                sprintf(msg, "success");
+                Sendmsg(fd, msg, MAX_PACKET_SIZE);
+                return 0;
+            }
+            case DaemonOperations::STOP: {
+                // Message format: stop
+                //
+                // Stop all the threads gracefully and then shutdown the
+                // main thread
+                ShutdownThreads();
+                return static_cast<int>(DaemonOperations::STOP);
+            }
+            case DaemonOperations::TERMINATING: {
+                // Message format: terminate-request
+                //
+                // This is invoked during transition. First stage
+                // daemon will receive this request. First stage daemon
+                // will be considered as a passive daemon from hereon.
+                SetTerminating();
+                sprintf(msg, "success");
+                Sendmsg(fd, msg, MAX_PACKET_SIZE);
+                return 0;
+            }
+            case DaemonOperations::QUERY: {
+                // Message format: query
+                //
+                // As part of transition, Second stage daemon will be
+                // created before terminating the first stage daemon. Hence,
+                // for a brief period client may have to distiguish between
+                // first stage daemon and second stage daemon.
+                //
+                // Second stage daemon is marked as active and hence will
+                // be ready to receive control message.
+                std::string dstr = GetDaemonStatus();
+                memcpy(msg, dstr.c_str(), dstr.size());
+                Sendmsg(fd, msg, MAX_PACKET_SIZE);
+                if (dstr == "active")
+                    break;
+                else
+                    return 0;
+            }
+            default: {
+                sprintf(msg, "fail");
+                Sendmsg(fd, msg, MAX_PACKET_SIZE);
+                return 0;
+            }
+        }
+    }
+}
+
+int SnapuserdServer::Start(std::string socketname) {
+    sockfd_.reset(socket_local_server(socketname.c_str(), ANDROID_SOCKET_NAMESPACE_RESERVED,
+                                      SOCK_STREAM));
+    if (sockfd_ < 0) {
+        PLOG(ERROR) << "Failed to create server socket " << socketname;
+        return -1;
+    }
+
+    LOG(DEBUG) << "Snapuserd server successfully started with socket name " << socketname;
+    return 0;
+}
+
+int SnapuserdServer::AcceptClient() {
+    int fd = accept(sockfd_.get(), NULL, NULL);
+    if (fd < 0) {
+        PLOG(ERROR) << "Socket accept failed: " << strerror(errno);
+        return -1;
+    }
+
+    return Receivemsg(fd);
+}
+
+}  // namespace snapshot
+}  // namespace android
diff --git a/fs_mgr/tests/Android.bp b/fs_mgr/tests/Android.bp
index f68ab87..9ed283a 100644
--- a/fs_mgr/tests/Android.bp
+++ b/fs_mgr/tests/Android.bp
@@ -17,7 +17,6 @@
     test_suites: [
         "cts",
         "device-tests",
-        "vts10",
     ],
     compile_multilib: "both",
     multilib: {
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index d56f7f2..e995888 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -740,7 +740,7 @@
   grep -v \
     -e "^\(overlay\|tmpfs\|none\|sysfs\|proc\|selinuxfs\|debugfs\|bpf\) " \
     -e "^\(binfmt_misc\|cg2_bpf\|pstore\|tracefs\|adb\|mtp\|ptp\|devpts\) " \
-    -e "^\(ramdumpfs\) " \
+    -e "^\(ramdumpfs\|binder\|/sys/kernel/debug\) " \
     -e " functionfs " \
     -e "^\(/data/media\|/dev/block/loop[0-9]*\) " \
     -e "^rootfs / rootfs rw," \
@@ -755,7 +755,7 @@
 uninteresting to the test" ]
 skip_unrelated_mounts() {
     grep -v "^overlay.* /\(apex\|bionic\|system\|vendor\)/[^ ]" |
-      grep -v "[%] /\(apex\|bionic\|system\|vendor\)/[^ ][^ ]*$"
+      grep -v "[%] /\(data_mirror\|apex\|bionic\|system\|vendor\)/[^ ][^ ]*$"
 }
 
 ##
@@ -1301,9 +1301,9 @@
 fi
 check_ne "${BASE_SYSTEM_DEVT}" "${BASE_VENDOR_DEVT}" --warning system/vendor devt
 [ -n "${SYSTEM_DEVT%[0-9a-fA-F][0-9a-fA-F]}" ] ||
-  die "system devt ${SYSTEM_DEVT} is major 0"
+  echo "${YELLOW}[  WARNING ]${NORMAL} system devt ${SYSTEM_DEVT} major 0" >&2
 [ -n "${VENDOR_DEVT%[0-9a-fA-F][0-9a-fA-F]}" ] ||
-  die "vendor devt ${SYSTEM_DEVT} is major 0"
+  echo "${YELLOW}[  WARNING ]${NORMAL} vendor devt ${VENDOR_DEVT} major 0" >&2
 
 # Download libc.so, append some gargage, push back, and check if the file
 # is updated.
diff --git a/fs_mgr/tests/fs_mgr_test.cpp b/fs_mgr/tests/fs_mgr_test.cpp
index 27c8aae..46f1c59 100644
--- a/fs_mgr/tests/fs_mgr_test.cpp
+++ b/fs_mgr/tests/fs_mgr_test.cpp
@@ -394,9 +394,9 @@
     TemporaryFile tf;
     ASSERT_TRUE(tf.fd != -1);
     std::string fstab_contents = R"fs(
-source none0       swap   defaults      encryptable,forceencrypt,fileencryption,forcefdeorfbe,keydirectory,length,swapprio,zramsize,max_comp_streams,reservedsize,eraseblk,logicalblk,sysfs_path,zram_loopback_path,zram_loopback_size,zram_backing_dev_path
+source none0       swap   defaults      encryptable,forceencrypt,fileencryption,forcefdeorfbe,keydirectory,length,swapprio,zramsize,max_comp_streams,reservedsize,eraseblk,logicalblk,sysfs_path,zram_backingdev_size
 
-source none1       swap   defaults      encryptable=,forceencrypt=,fileencryption=,keydirectory=,length=,swapprio=,zramsize=,max_comp_streams=,avb=,reservedsize=,eraseblk=,logicalblk=,sysfs_path=,zram_loopback_path=,zram_loopback_size=,zram_backing_dev_path=
+source none1       swap   defaults      encryptable=,forceencrypt=,fileencryption=,keydirectory=,length=,swapprio=,zramsize=,max_comp_streams=,avb=,reservedsize=,eraseblk=,logicalblk=,sysfs_path=,zram_backingdev_size=
 
 source none2       swap   defaults      forcefdeorfbe=
 
@@ -426,9 +426,7 @@
     EXPECT_EQ(0, entry->erase_blk_size);
     EXPECT_EQ(0, entry->logical_blk_size);
     EXPECT_EQ("", entry->sysfs_path);
-    EXPECT_EQ("", entry->zram_loopback_path);
-    EXPECT_EQ(512U * 1024U * 1024U, entry->zram_loopback_size);
-    EXPECT_EQ("", entry->zram_backing_dev_path);
+    EXPECT_EQ(0U, entry->zram_backingdev_size);
     entry++;
 
     EXPECT_EQ("none1", entry->mount_point);
@@ -453,9 +451,7 @@
     EXPECT_EQ(0, entry->erase_blk_size);
     EXPECT_EQ(0, entry->logical_blk_size);
     EXPECT_EQ("", entry->sysfs_path);
-    EXPECT_EQ("", entry->zram_loopback_path);
-    EXPECT_EQ(512U * 1024U * 1024U, entry->zram_loopback_size);
-    EXPECT_EQ("", entry->zram_backing_dev_path);
+    EXPECT_EQ(0U, entry->zram_backingdev_size);
     entry++;
 
     // forcefdeorfbe has its own encryption_options defaults, so test it separately.
@@ -960,14 +956,10 @@
     TemporaryFile tf;
     ASSERT_TRUE(tf.fd != -1);
     std::string fstab_contents = R"fs(
-source none0       swap   defaults      zram_loopback_path=/dev/path
-
-source none1       swap   defaults      zram_loopback_size=blah
-source none2       swap   defaults      zram_loopback_size=2
-source none3       swap   defaults      zram_loopback_size=1K
-source none4       swap   defaults      zram_loopback_size=2m
-
-source none5       swap   defaults      zram_backing_dev_path=/dev/path2
+source none1       swap   defaults      zram_backingdev_size=blah
+source none2       swap   defaults      zram_backingdev_size=2
+source none3       swap   defaults      zram_backingdev_size=1K
+source none4       swap   defaults      zram_backingdev_size=2m
 
 )fs";
 
@@ -975,31 +967,25 @@
 
     Fstab fstab;
     EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
-    ASSERT_EQ(6U, fstab.size());
+    ASSERT_EQ(4U, fstab.size());
 
     auto entry = fstab.begin();
-    EXPECT_EQ("none0", entry->mount_point);
-    EXPECT_EQ("/dev/path", entry->zram_loopback_path);
-    entry++;
 
     EXPECT_EQ("none1", entry->mount_point);
-    EXPECT_EQ(512U * 1024U * 1024U, entry->zram_loopback_size);
+    EXPECT_EQ(0U, entry->zram_backingdev_size);
     entry++;
 
     EXPECT_EQ("none2", entry->mount_point);
-    EXPECT_EQ(2U, entry->zram_loopback_size);
+    EXPECT_EQ(2U, entry->zram_backingdev_size);
     entry++;
 
     EXPECT_EQ("none3", entry->mount_point);
-    EXPECT_EQ(1024U, entry->zram_loopback_size);
+    EXPECT_EQ(1024U, entry->zram_backingdev_size);
     entry++;
 
     EXPECT_EQ("none4", entry->mount_point);
-    EXPECT_EQ(2U * 1024U * 1024U, entry->zram_loopback_size);
+    EXPECT_EQ(2U * 1024U * 1024U, entry->zram_backingdev_size);
     entry++;
-
-    EXPECT_EQ("none5", entry->mount_point);
-    EXPECT_EQ("/dev/path2", entry->zram_backing_dev_path);
 }
 
 TEST(fs_mgr, DefaultFstabContainsUserdata) {
diff --git a/fs_mgr/tools/dmctl.cpp b/fs_mgr/tools/dmctl.cpp
index 7a3d9a9..9edcda7 100644
--- a/fs_mgr/tools/dmctl.cpp
+++ b/fs_mgr/tools/dmctl.cpp
@@ -38,6 +38,7 @@
 #include <vector>
 
 using namespace std::literals::string_literals;
+using namespace std::chrono_literals;
 using namespace android::dm;
 using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice;
 
@@ -49,6 +50,7 @@
     std::cerr << "  delete <dm-name>" << std::endl;
     std::cerr << "  list <devices | targets> [-v]" << std::endl;
     std::cerr << "  getpath <dm-name>" << std::endl;
+    std::cerr << "  getuuid <dm-name>" << std::endl;
     std::cerr << "  info <dm-name>" << std::endl;
     std::cerr << "  status <dm-name>" << std::endl;
     std::cerr << "  resume <dm-name>" << std::endl;
@@ -241,8 +243,9 @@
         return ret;
     }
 
+    std::string ignore_path;
     DeviceMapper& dm = DeviceMapper::Instance();
-    if (!dm.CreateDevice(name, table)) {
+    if (!dm.CreateDevice(name, table, &ignore_path, 5s)) {
         std::cerr << "Failed to create device-mapper device with name: " << name << std::endl;
         return -EIO;
     }
@@ -391,6 +394,22 @@
     return 0;
 }
 
+static int GetUuidCmdHandler(int argc, char** argv) {
+    if (argc != 1) {
+        std::cerr << "Invalid arguments, see \'dmctl help\'" << std::endl;
+        return -EINVAL;
+    }
+
+    DeviceMapper& dm = DeviceMapper::Instance();
+    std::string uuid;
+    if (!dm.GetDmDeviceUuidByName(argv[0], &uuid)) {
+        std::cerr << "Could not query uuid of device \"" << argv[0] << "\"." << std::endl;
+        return -EINVAL;
+    }
+    std::cout << uuid << std::endl;
+    return 0;
+}
+
 static int InfoCmdHandler(int argc, char** argv) {
     if (argc != 1) {
         std::cerr << "Invalid arguments, see \'dmctl help\'" << std::endl;
@@ -504,6 +523,7 @@
         {"list", DmListCmdHandler},
         {"help", HelpCmdHandler},
         {"getpath", GetPathCmdHandler},
+        {"getuuid", GetUuidCmdHandler},
         {"info", InfoCmdHandler},
         {"table", TableCmdHandler},
         {"status", StatusCmdHandler},
diff --git a/gatekeeperd/binder/android/service/gatekeeper/IGateKeeperService.aidl b/gatekeeperd/binder/android/service/gatekeeper/IGateKeeperService.aidl
index 57adaba..4646efc 100644
--- a/gatekeeperd/binder/android/service/gatekeeper/IGateKeeperService.aidl
+++ b/gatekeeperd/binder/android/service/gatekeeper/IGateKeeperService.aidl
@@ -30,7 +30,7 @@
 interface IGateKeeperService {
     /**
      * Enrolls a password, returning the handle to the enrollment to be stored locally.
-     * @param uid The Android user ID associated to this enrollment
+     * @param userId The Android user ID associated to this enrollment
      * @param currentPasswordHandle The previously enrolled handle, or null if none
      * @param currentPassword The previously enrolled plaintext password, or null if none.
      *                        If provided, must verify against the currentPasswordHandle.
@@ -38,22 +38,22 @@
      *                        upon success.
      * @return an EnrollResponse or null on failure
      */
-    GateKeeperResponse enroll(int uid, in @nullable byte[] currentPasswordHandle,
+    GateKeeperResponse enroll(int userId, in @nullable byte[] currentPasswordHandle,
             in @nullable byte[] currentPassword, in byte[] desiredPassword);
 
     /**
      * Verifies an enrolled handle against a provided, plaintext blob.
-     * @param uid The Android user ID associated to this enrollment
+     * @param userId The Android user ID associated to this enrollment
      * @param enrolledPasswordHandle The handle against which the provided password will be
      *                               verified.
      * @param The plaintext blob to verify against enrolledPassword.
      * @return a VerifyResponse, or null on failure.
      */
-    GateKeeperResponse verify(int uid, in byte[] enrolledPasswordHandle, in byte[] providedPassword);
+    GateKeeperResponse verify(int userId, in byte[] enrolledPasswordHandle, in byte[] providedPassword);
 
     /**
      * Verifies an enrolled handle against a provided, plaintext blob.
-     * @param uid The Android user ID associated to this enrollment
+     * @param userId The Android user ID associated to this enrollment
      * @param challenge a challenge to authenticate agaisnt the device credential. If successful
      *                  authentication occurs, this value will be written to the returned
      *                  authentication attestation.
@@ -62,22 +62,22 @@
      * @param The plaintext blob to verify against enrolledPassword.
      * @return a VerifyResponse with an attestation, or null on failure.
      */
-    GateKeeperResponse verifyChallenge(int uid, long challenge, in byte[] enrolledPasswordHandle,
+    GateKeeperResponse verifyChallenge(int userId, long challenge, in byte[] enrolledPasswordHandle,
             in byte[] providedPassword);
 
     /**
      * Retrieves the secure identifier for the user with the provided Android ID,
      * or 0 if none is found.
-     * @param uid the Android user id
+     * @param userId the Android user id
      */
-    long getSecureUserId(int uid);
+    long getSecureUserId(int userId);
 
     /**
      * Clears secure user id associated with the provided Android ID.
      * Must be called when password is set to NONE.
-     * @param uid the Android user id.
+     * @param userId the Android user id.
      */
-    void clearSecureUserId(int uid);
+    void clearSecureUserId(int userId);
 
     /**
      * Notifies gatekeeper that device setup has been completed and any potentially still existing
diff --git a/gatekeeperd/gatekeeperd.cpp b/gatekeeperd/gatekeeperd.cpp
index c81a80e..b982dbc 100644
--- a/gatekeeperd/gatekeeperd.cpp
+++ b/gatekeeperd/gatekeeperd.cpp
@@ -76,9 +76,9 @@
     virtual ~GateKeeperProxy() {
     }
 
-    void store_sid(uint32_t uid, uint64_t sid) {
+    void store_sid(uint32_t userId, uint64_t sid) {
         char filename[21];
-        snprintf(filename, sizeof(filename), "%u", uid);
+        snprintf(filename, sizeof(filename), "%u", userId);
         int fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
         if (fd < 0) {
             ALOGE("could not open file: %s: %s", filename, strerror(errno));
@@ -117,18 +117,18 @@
         return false;
     }
 
-    void maybe_store_sid(uint32_t uid, uint64_t sid) {
+    void maybe_store_sid(uint32_t userId, uint64_t sid) {
         char filename[21];
-        snprintf(filename, sizeof(filename), "%u", uid);
+        snprintf(filename, sizeof(filename), "%u", userId);
         if (access(filename, F_OK) == -1) {
-            store_sid(uid, sid);
+            store_sid(userId, sid);
         }
     }
 
-    uint64_t read_sid(uint32_t uid) {
+    uint64_t read_sid(uint32_t userId) {
         char filename[21];
         uint64_t sid;
-        snprintf(filename, sizeof(filename), "%u", uid);
+        snprintf(filename, sizeof(filename), "%u", userId);
         int fd = open(filename, O_RDONLY);
         if (fd < 0) return 0;
         read(fd, &sid, sizeof(sid));
@@ -136,30 +136,30 @@
         return sid;
     }
 
-    void clear_sid(uint32_t uid) {
+    void clear_sid(uint32_t userId) {
         char filename[21];
-        snprintf(filename, sizeof(filename), "%u", uid);
+        snprintf(filename, sizeof(filename), "%u", userId);
         if (remove(filename) < 0) {
             ALOGE("%s: could not remove file [%s], attempting 0 write", __func__, strerror(errno));
-            store_sid(uid, 0);
+            store_sid(userId, 0);
         }
     }
 
-    // This should only be called on uids being passed to the GateKeeper HAL. It ensures that
+    // This should only be called on userIds being passed to the GateKeeper HAL. It ensures that
     // secure storage shared across a GSI image and a host image will not overlap.
-    uint32_t adjust_uid(uint32_t uid) {
+    uint32_t adjust_userId(uint32_t userId) {
         static constexpr uint32_t kGsiOffset = 1000000;
-        CHECK(uid < kGsiOffset);
+        CHECK(userId < kGsiOffset);
         CHECK(hw_device != nullptr);
         if (is_running_gsi) {
-            return uid + kGsiOffset;
+            return userId + kGsiOffset;
         }
-        return uid;
+        return userId;
     }
 
 #define GK_ERROR *gkResponse = GKResponse::error(), Status::ok()
 
-    Status enroll(int32_t uid, const std::optional<std::vector<uint8_t>>& currentPasswordHandle,
+    Status enroll(int32_t userId, const std::optional<std::vector<uint8_t>>& currentPasswordHandle,
                   const std::optional<std::vector<uint8_t>>& currentPassword,
                   const std::vector<uint8_t>& desiredPassword, GKResponse* gkResponse) override {
         IPCThreadState* ipc = IPCThreadState::self();
@@ -198,9 +198,10 @@
         android::hardware::hidl_vec<uint8_t> newPwd;
         newPwd.setToExternal(const_cast<uint8_t*>(desiredPassword.data()), desiredPassword.size());
 
-        uint32_t hw_uid = adjust_uid(uid);
+        uint32_t hw_userId = adjust_userId(userId);
         Return<void> hwRes = hw_device->enroll(
-                hw_uid, curPwdHandle, curPwd, newPwd, [&gkResponse](const GatekeeperResponse& rsp) {
+                hw_userId, curPwdHandle, curPwd, newPwd,
+                [&gkResponse](const GatekeeperResponse& rsp) {
                     if (rsp.code >= GatekeeperStatusCode::STATUS_OK) {
                         *gkResponse = GKResponse::ok({rsp.data.begin(), rsp.data.end()});
                     } else if (rsp.code == GatekeeperStatusCode::ERROR_RETRY_TIMEOUT &&
@@ -225,12 +226,12 @@
             const gatekeeper::password_handle_t* handle =
                     reinterpret_cast<const gatekeeper::password_handle_t*>(
                             gkResponse->payload().data());
-            store_sid(uid, handle->user_id);
+            store_sid(userId, handle->user_id);
 
             GKResponse verifyResponse;
             // immediately verify this password so we don't ask the user to enter it again
             // if they just created it.
-            auto status = verify(uid, gkResponse->payload(), desiredPassword, &verifyResponse);
+            auto status = verify(userId, gkResponse->payload(), desiredPassword, &verifyResponse);
             if (!status.isOk() || verifyResponse.response_code() != GKResponseCode::OK) {
                 LOG(ERROR) << "Failed to verify password after enrolling";
             }
@@ -239,13 +240,13 @@
         return Status::ok();
     }
 
-    Status verify(int32_t uid, const ::std::vector<uint8_t>& enrolledPasswordHandle,
+    Status verify(int32_t userId, const ::std::vector<uint8_t>& enrolledPasswordHandle,
                   const ::std::vector<uint8_t>& providedPassword, GKResponse* gkResponse) override {
-        return verifyChallenge(uid, 0 /* challenge */, enrolledPasswordHandle, providedPassword,
+        return verifyChallenge(userId, 0 /* challenge */, enrolledPasswordHandle, providedPassword,
                                gkResponse);
     }
 
-    Status verifyChallenge(int32_t uid, int64_t challenge,
+    Status verifyChallenge(int32_t userId, int64_t challenge,
                            const std::vector<uint8_t>& enrolledPasswordHandle,
                            const std::vector<uint8_t>& providedPassword,
                            GKResponse* gkResponse) override {
@@ -269,7 +270,7 @@
                 reinterpret_cast<const gatekeeper::password_handle_t*>(
                         enrolledPasswordHandle.data());
 
-        uint32_t hw_uid = adjust_uid(uid);
+        uint32_t hw_userId = adjust_userId(userId);
         android::hardware::hidl_vec<uint8_t> curPwdHandle;
         curPwdHandle.setToExternal(const_cast<uint8_t*>(enrolledPasswordHandle.data()),
                                    enrolledPasswordHandle.size());
@@ -278,7 +279,7 @@
                                  providedPassword.size());
 
         Return<void> hwRes = hw_device->verify(
-                hw_uid, challenge, curPwdHandle, enteredPwd,
+                hw_userId, challenge, curPwdHandle, enteredPwd,
                 [&gkResponse](const GatekeeperResponse& rsp) {
                     if (rsp.code >= GatekeeperStatusCode::STATUS_OK) {
                         *gkResponse = GKResponse::ok(
@@ -315,18 +316,18 @@
                 }
             }
 
-            maybe_store_sid(uid, handle->user_id);
+            maybe_store_sid(userId, handle->user_id);
         }
 
         return Status::ok();
     }
 
-    Status getSecureUserId(int32_t uid, int64_t* sid) override {
-        *sid = read_sid(uid);
+    Status getSecureUserId(int32_t userId, int64_t* sid) override {
+        *sid = read_sid(userId);
         return Status::ok();
     }
 
-    Status clearSecureUserId(int32_t uid) override {
+    Status clearSecureUserId(int32_t userId) override {
         IPCThreadState* ipc = IPCThreadState::self();
         const int calling_pid = ipc->getCallingPid();
         const int calling_uid = ipc->getCallingUid();
@@ -334,11 +335,11 @@
             ALOGE("%s: permission denied for [%d:%d]", __func__, calling_pid, calling_uid);
             return Status::ok();
         }
-        clear_sid(uid);
+        clear_sid(userId);
 
         if (hw_device) {
-            uint32_t hw_uid = adjust_uid(uid);
-            hw_device->deleteUser(hw_uid, [] (const GatekeeperResponse &){});
+            uint32_t hw_userId = adjust_userId(userId);
+            hw_device->deleteUser(hw_userId, [](const GatekeeperResponse&) {});
         }
         return Status::ok();
     }
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 599f500..fd810cb 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -79,7 +79,7 @@
 
     // HIDL enum values are zero initialized, so they need to be initialized
     // properly.
-    health_info_2_1->batteryCapacityLevel = BatteryCapacityLevel::UNKNOWN;
+    health_info_2_1->batteryCapacityLevel = BatteryCapacityLevel::UNSUPPORTED;
     health_info_2_1->batteryChargeTimeToFullNowSeconds =
             (int64_t)Constants::BATTERY_CHARGE_TIME_TO_FULL_NOW_SECONDS_UNSUPPORTED;
     auto* props = &health_info_2_1->legacy.legacy;
diff --git a/healthd/android.hardware.health@2.0-service.rc b/healthd/android.hardware.health@2.0-service.rc
index 6960c5d..762771e 100644
--- a/healthd/android.hardware.health@2.0-service.rc
+++ b/healthd/android.hardware.health@2.0-service.rc
@@ -2,5 +2,5 @@
     class hal
     user system
     group system
-    capabilities WAKE_ALARM
+    capabilities WAKE_ALARM BLOCK_SUSPEND
     file /dev/kmsg w
diff --git a/healthd/api/charger_sysprop-current.txt b/healthd/api/charger_sysprop-current.txt
index 678c847..e69de29 100644
--- a/healthd/api/charger_sysprop-current.txt
+++ b/healthd/api/charger_sysprop-current.txt
@@ -1,29 +0,0 @@
-props {
-  module: "android.sysprop.ChargerProperties"
-  prop {
-    api_name: "disable_init_blank"
-    scope: Internal
-    prop_name: "ro.charger.disable_init_blank"
-  }
-  prop {
-    api_name: "draw_split_offset"
-    type: Long
-    scope: Internal
-    prop_name: "ro.charger.draw_split_offset"
-  }
-  prop {
-    api_name: "draw_split_screen"
-    scope: Internal
-    prop_name: "ro.charger.draw_split_screen"
-  }
-  prop {
-    api_name: "enable_suspend"
-    scope: Internal
-    prop_name: "ro.charger.enable_suspend"
-  }
-  prop {
-    api_name: "no_ui"
-    scope: Internal
-    prop_name: "ro.charger.no_ui"
-  }
-}
diff --git a/include/android/log.h b/include/android/log.h
deleted file mode 120000
index 736c448..0000000
--- a/include/android/log.h
+++ /dev/null
@@ -1 +0,0 @@
-../../liblog/include/android/log.h
\ No newline at end of file
diff --git a/include/log b/include/log
deleted file mode 120000
index 714065f..0000000
--- a/include/log
+++ /dev/null
@@ -1 +0,0 @@
-../liblog/include/log
\ No newline at end of file
diff --git a/include/private/android_filesystem_capability.h b/include/private/android_filesystem_capability.h
deleted file mode 120000
index f310b35..0000000
--- a/include/private/android_filesystem_capability.h
+++ /dev/null
@@ -1 +0,0 @@
-../../libcutils/include/private/android_filesystem_capability.h
\ No newline at end of file
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
deleted file mode 120000
index f28a564..0000000
--- a/include/private/android_filesystem_config.h
+++ /dev/null
@@ -1 +0,0 @@
-../../libcutils/include/private/android_filesystem_config.h
\ No newline at end of file
diff --git a/include/private/android_logger.h b/include/private/android_logger.h
deleted file mode 120000
index f187a6d..0000000
--- a/include/private/android_logger.h
+++ /dev/null
@@ -1 +0,0 @@
-../../liblog/include/private/android_logger.h
\ No newline at end of file
diff --git a/include/private/canned_fs_config.h b/include/private/canned_fs_config.h
deleted file mode 120000
index 8f92b2d..0000000
--- a/include/private/canned_fs_config.h
+++ /dev/null
@@ -1 +0,0 @@
-../../libcutils/include/private/canned_fs_config.h
\ No newline at end of file
diff --git a/include/private/fs_config.h b/include/private/fs_config.h
deleted file mode 100644
index e9868a4..0000000
--- a/include/private/fs_config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-// TODO(b/63135587) remove this file after the transitive dependency
-// from private/android_filesystem_config.h is resolved. All files that use
-// libcutils/include/private/fs_config.h should include the file directly, not
-// indirectly via private/android_filesystem_config.h.
diff --git a/include/sysutils b/include/sysutils
deleted file mode 120000
index 1c8e85b..0000000
--- a/include/sysutils
+++ /dev/null
@@ -1 +0,0 @@
-../libsysutils/include/sysutils/
\ No newline at end of file
diff --git a/init/Android.bp b/init/Android.bp
index 3f2cd07..13b1876 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -273,7 +273,6 @@
     test_suites: [
         "cts",
         "device-tests",
-        "vts10",
     ],
 }
 
diff --git a/init/Android.mk b/init/Android.mk
index 2fbbf4a..da94daf 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -119,13 +119,6 @@
 # First stage init is weird: it may start without stdout/stderr, and no /proc.
 LOCAL_NOSANITIZE := hwaddress
 include $(BUILD_EXECUTABLE)
-
-# LOCAL_FORCE_STATIC_EXECUTABLE targets are skipped and not defined for ASAN builds
-init_vendor_deps :=
-ifneq (true,$(my_skip_this_target))
-  init_vendor_deps += init_first_stage
-endif # my_skip_this_target is true
-
 endif
 
 include $(CLEAR_VARS)
@@ -140,7 +133,8 @@
 
 LOCAL_MODULE := init_vendor
 ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
-LOCAL_REQUIRED_MODULES := $(init_vendor_deps)
+LOCAL_REQUIRED_MODULES := \
+   init_first_stage \
+
 endif
 include $(BUILD_PHONY_PACKAGE)
-init_vendor_deps :=
diff --git a/init/README.md b/init/README.md
index c3b64f6..6439393 100644
--- a/init/README.md
+++ b/init/README.md
@@ -31,14 +31,13 @@
 extension.  There are typically multiple of these in multiple
 locations on the system, described below.
 
-/init.rc is the primary .rc file and is loaded by the init executable
-at the beginning of its execution.  It is responsible for the initial
-set up of the system.
+`/system/etc/init/hw/init.rc` is the primary .rc file and is loaded by the init executable at the
+beginning of its execution.  It is responsible for the initial set up of the system.
 
 Init loads all of the files contained within the
-/{system,vendor,odm}/etc/init/ directories immediately after loading
-the primary /init.rc.  This is explained in more details in the
-Imports section of this file.
+`/{system,system_ext,vendor,odm,product}/etc/init/` directories immediately after loading
+the primary `/system/etc/init/hw/init.rc`.  This is explained in more details in the
+[Imports](#imports) section of this file.
 
 Legacy devices without the first stage mount mechanism previously were
 able to import init scripts during mount_all, however that is deprecated
@@ -689,29 +688,22 @@
 
 There are only three times where the init executable imports .rc files:
 
-   1. When it imports /init.rc or the script indicated by the property
+   1. When it imports `/system/etc/init/hw/init.rc` or the script indicated by the property
       `ro.boot.init_rc` during initial boot.
-   2. When it imports /{system,vendor,odm}/etc/init/ for first stage mount
-      devices immediately after importing /init.rc.
+   2. When it imports `/{system,system_ext,vendor,odm,product}/etc/init/` immediately after
+      importing `/system/etc/init/hw/init.rc`.
    3. (Deprecated) When it imports /{system,vendor,odm}/etc/init/ or .rc files
       at specified paths during mount_all, not allowed for devices launching
       after Q.
 
-The order that files are imported is a bit complex for legacy reasons
-and to keep backwards compatibility.  It is not strictly guaranteed.
+The order that files are imported is a bit complex for legacy reasons.  The below is guaranteed:
 
-The only correct way to guarantee that a command has been run before a
-different command is to either 1) place it in an Action with an
-earlier executed trigger, or 2) place it in an Action with the same
-trigger within the same file at an earlier line.
-
-Nonetheless, the de facto order for first stage mount devices is:
-1. /init.rc is parsed then recursively each of its imports are
+1. `/system/etc/init/hw/init.rc` is parsed then recursively each of its imports are
    parsed.
-2. The contents of /system/etc/init/ are alphabetized and parsed
-   sequentially, with imports happening recursively after each file is
-   parsed.
-3. Step 2 is repeated for /vendor/etc/init then /odm/etc/init
+2. The contents of `/system/etc/init/` are alphabetized and parsed sequentially, with imports
+   happening recursively after each file is parsed.
+3. Step 2 is repeated for `/system_ext/etc/init`, `/vendor/etc/init`, `/odm/etc/init`,
+   `/product/etc/init`
 
 The below pseudocode may explain this more clearly:
 
@@ -720,13 +712,17 @@
       for (import : file.imports)
         Import(import)
 
-    Import(/init.rc)
-    Directories = [/system/etc/init, /vendor/etc/init, /odm/etc/init]
+    Import(/system/etc/init/hw/init.rc)
+    Directories = [/system/etc/init, /system_ext/etc/init, /vendor/etc/init, /odm/etc/init, /product/etc/init]
     for (directory : Directories)
       files = <Alphabetical order of directory's contents>
       for (file : files)
         Import(file)
 
+Actions are executed in the order that they are parsed.  For example the `post-fs-data` action(s)
+in `/system/etc/init/hw/init.rc` are always the first `post-fs-data` action(s) to be executed in
+order of how they appear in that file.  Then the `post-fs-data` actions of the imports of
+`/system/etc/init/hw/init.rc` in the order that they're imported, etc.
 
 Properties
 ----------
diff --git a/init/README.ueventd.md b/init/README.ueventd.md
index 053ebf8..4363f3c 100644
--- a/init/README.ueventd.md
+++ b/init/README.ueventd.md
@@ -86,6 +86,8 @@
 for a file matching the uevent `FIRMWARE`. It then forks a process to serve this firmware to the
 kernel.
 
+`/apex/*/etc/firmware` is also searched after a list of firmware directories.
+
 The list of firmware directories is customized by a `firmware_directories` line in a ueventd.rc
 file. This line takes the format of
 
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 0b456e7..d00d1b1 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -570,7 +570,6 @@
             trigger_shutdown("reboot,requested-userdata-remount-on-fde-device");
         }
         SetProperty("ro.crypto.state", "encrypted");
-        SetProperty("ro.crypto.type", "block");
         ActionManager::GetInstance().QueueEventTrigger("defaultcrypto");
         return {};
     } else if (code == FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) {
@@ -595,7 +594,6 @@
             return Error() << "FscryptInstallKeyring() failed";
         }
         SetProperty("ro.crypto.state", "encrypted");
-        SetProperty("ro.crypto.type", "file");
 
         // Although encrypted, we have device key, so we do not need to
         // do anything different from the nonencrypted case.
@@ -606,7 +604,6 @@
             return Error() << "FscryptInstallKeyring() failed";
         }
         SetProperty("ro.crypto.state", "encrypted");
-        SetProperty("ro.crypto.type", "file");
 
         // Although encrypted, vold has already set the device up, so we do not need to
         // do anything different from the nonencrypted case.
@@ -617,7 +614,6 @@
             return Error() << "FscryptInstallKeyring() failed";
         }
         SetProperty("ro.crypto.state", "encrypted");
-        SetProperty("ro.crypto.type", "file");
 
         // Although encrypted, vold has already set the device up, so we do not need to
         // do anything different from the nonencrypted case.
@@ -666,18 +662,26 @@
         }
     }
 
-    auto mount_fstab_return_code = fs_mgr_mount_all(&fstab, mount_all->mode);
+    auto mount_fstab_result = fs_mgr_mount_all(&fstab, mount_all->mode);
     SetProperty(prop_name, std::to_string(t.duration().count()));
 
     if (mount_all->import_rc) {
         import_late(mount_all->rc_paths);
     }
 
+    if (mount_fstab_result.userdata_mounted) {
+        // This call to fs_mgr_mount_all mounted userdata. Keep the result in
+        // order for userspace reboot to correctly remount userdata.
+        LOG(INFO) << "Userdata mounted using "
+                  << (mount_all->fstab_path.empty() ? "(default fstab)" : mount_all->fstab_path)
+                  << " result : " << mount_fstab_result.code;
+        initial_mount_fstab_return_code = mount_fstab_result.code;
+    }
+
     if (queue_event) {
         /* queue_fs_event will queue event based on mount_fstab return code
          * and return processed return code*/
-        initial_mount_fstab_return_code = mount_fstab_return_code;
-        auto queue_fs_result = queue_fs_event(mount_fstab_return_code, false);
+        auto queue_fs_result = queue_fs_event(mount_fstab_result.code, false);
         if (!queue_fs_result.ok()) {
             return Error() << "queue_fs_event() failed: " << queue_fs_result.error();
         }
@@ -1177,6 +1181,10 @@
     }
     // TODO(b/135984674): check that fstab contains /data.
     if (auto rc = fs_mgr_remount_userdata_into_checkpointing(&fstab); rc < 0) {
+        std::string proc_mounts_output;
+        android::base::ReadFileToString("/proc/mounts", &proc_mounts_output, true);
+        android::base::WriteStringToFile(proc_mounts_output,
+                                         "/metadata/userspacereboot/mount_info.txt");
         trigger_shutdown("reboot,mount_userdata_failed");
     }
     if (auto result = queue_fs_event(initial_mount_fstab_return_code, true); !result.ok()) {
diff --git a/init/firmware_handler.cpp b/init/firmware_handler.cpp
index dff7b69..ba7e6bd 100644
--- a/init/firmware_handler.cpp
+++ b/init/firmware_handler.cpp
@@ -17,6 +17,7 @@
 #include "firmware_handler.h"
 
 #include <fcntl.h>
+#include <glob.h>
 #include <pwd.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -30,6 +31,7 @@
 #include <android-base/chrono_utils.h>
 #include <android-base/file.h>
 #include <android-base/logging.h>
+#include <android-base/scopeguard.h>
 #include <android-base/strings.h>
 #include <android-base/unique_fd.h>
 
@@ -203,25 +205,28 @@
     }
 
     std::vector<std::string> attempted_paths_and_errors;
-
-    int booting = IsBooting();
-try_loading_again:
-    attempted_paths_and_errors.clear();
-    for (const auto& firmware_directory : firmware_directories_) {
+    auto TryLoadFirmware = [&](const std::string& firmware_directory) {
         std::string file = firmware_directory + firmware;
         unique_fd fw_fd(open(file.c_str(), O_RDONLY | O_CLOEXEC));
         if (fw_fd == -1) {
             attempted_paths_and_errors.emplace_back("firmware: attempted " + file +
                                                     ", open failed: " + strerror(errno));
-            continue;
+            return false;
         }
         struct stat sb;
         if (fstat(fw_fd, &sb) == -1) {
             attempted_paths_and_errors.emplace_back("firmware: attempted " + file +
                                                     ", fstat failed: " + strerror(errno));
-            continue;
+            return false;
         }
         LoadFirmware(firmware, root, fw_fd, sb.st_size, loading_fd, data_fd);
+        return true;
+    };
+
+    int booting = IsBooting();
+try_loading_again:
+    attempted_paths_and_errors.clear();
+    if (ForEachFirmwareDirectory(TryLoadFirmware)) {
         return;
     }
 
@@ -242,6 +247,33 @@
     write(loading_fd, "-1", 2);
 }
 
+bool FirmwareHandler::ForEachFirmwareDirectory(
+        std::function<bool(const std::string&)> handler) const {
+    for (const std::string& firmware_directory : firmware_directories_) {
+        if (std::invoke(handler, firmware_directory)) {
+            return true;
+        }
+    }
+
+    glob_t glob_result;
+    glob("/apex/*/etc/firmware/", GLOB_MARK, nullptr, &glob_result);
+    auto free_glob = android::base::make_scope_guard(std::bind(&globfree, &glob_result));
+    for (size_t i = 0; i < glob_result.gl_pathc; i++) {
+        char* apex_firmware_directory = glob_result.gl_pathv[i];
+        // Filter-out /apex/<name>@<ver> paths. The paths are bind-mounted to
+        // /apex/<name> paths, so unless we filter them out, we will look into the
+        // same apex twice.
+        if (strchr(apex_firmware_directory, '@')) {
+            continue;
+        }
+        if (std::invoke(handler, apex_firmware_directory)) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 void FirmwareHandler::HandleUevent(const Uevent& uevent) {
     if (uevent.subsystem != "firmware" || uevent.action != "add") return;
 
diff --git a/init/firmware_handler.h b/init/firmware_handler.h
index b4138f1..8b758ae 100644
--- a/init/firmware_handler.h
+++ b/init/firmware_handler.h
@@ -18,6 +18,7 @@
 
 #include <pwd.h>
 
+#include <functional>
 #include <string>
 #include <vector>
 
@@ -52,6 +53,7 @@
                                            const Uevent& uevent) const;
     std::string GetFirmwarePath(const Uevent& uevent) const;
     void ProcessFirmwareEvent(const std::string& root, const std::string& firmware) const;
+    bool ForEachFirmwareDirectory(std::function<bool(const std::string&)> handler) const;
 
     std::vector<std::string> firmware_directories_;
     std::vector<ExternalFirmwareHandler> external_firmware_handlers_;
diff --git a/init/mount_handler.cpp b/init/mount_handler.cpp
index 01abba8..46f8331 100644
--- a/init/mount_handler.cpp
+++ b/init/mount_handler.cpp
@@ -130,7 +130,11 @@
     char* buf = nullptr;
     size_t len = 0;
     while (getline(&buf, &len, fp_.get()) != -1) {
-        auto entry = ParseMount(std::string(buf));
+        auto buf_string = std::string(buf);
+        if (buf_string.find("/emulated") != std::string::npos) {
+            continue;
+        }
+        auto entry = ParseMount(buf_string);
         auto match = untouched.find(entry);
         if (match == untouched.end()) {
             touched.emplace_back(std::move(entry));
diff --git a/init/property_service.cpp b/init/property_service.cpp
index a1e0969..57e82fa 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -860,7 +860,7 @@
     build_fingerprint += '/';
     build_fingerprint += GetProperty("ro.product.device", UNKNOWN);
     build_fingerprint += ':';
-    build_fingerprint += GetProperty("ro.build.version.release", UNKNOWN);
+    build_fingerprint += GetProperty("ro.build.version.release_or_codename", UNKNOWN);
     build_fingerprint += '/';
     build_fingerprint += GetProperty("ro.build.id", UNKNOWN);
     build_fingerprint += '/';
diff --git a/init/reboot.cpp b/init/reboot.cpp
index 19e83cc..49baf9e 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -690,9 +690,12 @@
     // Reap subcontext pids.
     ReapAnyOutstandingChildren();
 
-    // 3. send volume shutdown to vold
+    // 3. send volume abort_fuse and volume shutdown to vold
     Service* vold_service = ServiceList::GetInstance().FindService("vold");
     if (vold_service != nullptr && vold_service->IsRunning()) {
+        // Manually abort FUSE connections, since the FUSE daemon is already dead
+        // at this point, and unmounting it might hang.
+        CallVdc("volume", "abort_fuse");
         CallVdc("volume", "shutdown");
         vold_service->Stop();
     } else {
@@ -804,11 +807,19 @@
     auto sigkill_timeout = GetMillisProperty("init.userspace_reboot.sigkill.timeoutmillis", 10s);
     LOG(INFO) << "Timeout to terminate services: " << sigterm_timeout.count() << "ms "
               << "Timeout to kill services: " << sigkill_timeout.count() << "ms";
+    std::string services_file_name = "/metadata/userspacereboot/services.txt";
+    const int flags = O_RDWR | O_CREAT | O_SYNC | O_APPEND | O_CLOEXEC;
     StopServicesAndLogViolations(stop_first, sigterm_timeout, true /* SIGTERM */);
     if (int r = StopServicesAndLogViolations(stop_first, sigkill_timeout, false /* SIGKILL */);
         r > 0) {
+        auto fd = unique_fd(TEMP_FAILURE_RETRY(open(services_file_name.c_str(), flags, 0666)));
+        android::base::WriteStringToFd("Post-data services still running: \n", fd);
+        for (const auto& s : stop_first) {
+            if (s->IsRunning()) {
+                android::base::WriteStringToFd(s->name() + "\n", fd);
+            }
+        }
         sub_reason = "sigkill";
-        // TODO(b/135984674): store information about offending services for debugging.
         return Error() << r << " post-data services are still running";
     }
     if (auto result = KillZramBackingDevice(); !result.ok()) {
@@ -822,8 +833,14 @@
     if (int r = StopServicesAndLogViolations(GetDebuggingServices(true /* only_post_data */),
                                              sigkill_timeout, false /* SIGKILL */);
         r > 0) {
+        auto fd = unique_fd(TEMP_FAILURE_RETRY(open(services_file_name.c_str(), flags, 0666)));
+        android::base::WriteStringToFd("Debugging services still running: \n", fd);
+        for (const auto& s : GetDebuggingServices(true)) {
+            if (s->IsRunning()) {
+                android::base::WriteStringToFd(s->name() + "\n", fd);
+            }
+        }
         sub_reason = "sigkill_debug";
-        // TODO(b/135984674): store information about offending services for debugging.
         return Error() << r << " debugging services are still running";
     }
     {
diff --git a/init/subcontext.cpp b/init/subcontext.cpp
index 9d4ea8c..dc2455e 100644
--- a/init/subcontext.cpp
+++ b/init/subcontext.cpp
@@ -30,6 +30,7 @@
 
 #include "action.h"
 #include "builtins.h"
+#include "mount_namespace.h"
 #include "proto_utils.h"
 #include "util.h"
 
@@ -217,7 +218,13 @@
                 PLOG(FATAL) << "Could not set execcon for '" << context_ << "'";
             }
         }
-
+#if defined(__ANDROID__)
+        // subcontext init runs in "default" mount namespace
+        // so that it can access /apex/*
+        if (auto result = SwitchToMountNamespaceIfNeeded(NS_DEFAULT); !result.ok()) {
+            LOG(FATAL) << "Could not switch to \"default\" mount namespace: " << result.error();
+        }
+#endif
         auto init_path = GetExecutablePath();
         auto child_fd_string = std::to_string(child_fd);
         const char* args[] = {init_path.c_str(), "subcontext", context_.c_str(),
diff --git a/init/sysprop/api/com.android.sysprop.init-latest.txt b/init/sysprop/api/com.android.sysprop.init-latest.txt
index c835b95..01f4e9a 100644
--- a/init/sysprop/api/com.android.sysprop.init-latest.txt
+++ b/init/sysprop/api/com.android.sysprop.init-latest.txt
@@ -1,8 +1,13 @@
 props {
   module: "android.sysprop.InitProperties"
   prop {
+    api_name: "is_userspace_reboot_supported"
+    prop_name: "init.userspace_reboot.is_supported"
+    integer_as_bool: true
+  }
+  prop {
     api_name: "userspace_reboot_in_progress"
-    scope: Public
+    access: ReadWrite
     prop_name: "sys.init.userspace_reboot.in_progress"
     integer_as_bool: true
   }
diff --git a/libbacktrace/BacktraceCurrent.cpp b/libbacktrace/BacktraceCurrent.cpp
index 038b59e..a506575 100644
--- a/libbacktrace/BacktraceCurrent.cpp
+++ b/libbacktrace/BacktraceCurrent.cpp
@@ -37,6 +37,12 @@
 #include "ThreadEntry.h"
 
 bool BacktraceCurrent::ReadWord(uint64_t ptr, word_t* out_value) {
+#if defined(__aarch64__)
+  // Tagged pointer after Android R would lead top byte to have random values
+  // https://source.android.com/devices/tech/debug/tagged-pointers
+  ptr &= (1ULL << 56) - 1;
+#endif
+
   if (!VerifyReadWordArgs(ptr, out_value)) {
     return false;
   }
@@ -54,6 +60,12 @@
 }
 
 size_t BacktraceCurrent::Read(uint64_t addr, uint8_t* buffer, size_t bytes) {
+#if defined(__aarch64__)
+  // Tagged pointer after Android R would lead top byte to have random values
+  // https://source.android.com/devices/tech/debug/tagged-pointers
+  addr &= (1ULL << 56) - 1;
+#endif
+
   backtrace_map_t map;
   FillInMap(addr, &map);
   if (!BacktraceMap::IsValid(map) || !(map.flags & PROT_READ)) {
diff --git a/libbacktrace/UnwindStack.cpp b/libbacktrace/UnwindStack.cpp
index 624711f..82ff21c 100644
--- a/libbacktrace/UnwindStack.cpp
+++ b/libbacktrace/UnwindStack.cpp
@@ -52,11 +52,11 @@
   unwinder.SetResolveNames(stack_map->ResolveNames());
   stack_map->SetArch(regs->Arch());
   if (stack_map->GetJitDebug() != nullptr) {
-    unwinder.SetJitDebug(stack_map->GetJitDebug(), regs->Arch());
+    unwinder.SetJitDebug(stack_map->GetJitDebug());
   }
 #if !defined(NO_LIBDEXFILE_SUPPORT)
   if (stack_map->GetDexFiles() != nullptr) {
-    unwinder.SetDexFiles(stack_map->GetDexFiles(), regs->Arch());
+    unwinder.SetDexFiles(stack_map->GetDexFiles());
   }
 #endif
   unwinder.Unwind(skip_names, &stack_map->GetSuffixesToIgnore());
@@ -180,5 +180,10 @@
 }
 
 size_t UnwindStackPtrace::Read(uint64_t addr, uint8_t* buffer, size_t bytes) {
+#if defined(__aarch64__)
+  // Tagged pointer after Android R would lead top byte to have random values
+  // https://source.android.com/devices/tech/debug/tagged-pointers
+  addr &= (1ULL << 56) - 1;
+#endif
   return memory_->Read(addr, buffer, bytes);
 }
diff --git a/liblog/.clang-format b/libcrypto_utils/.clang-format
similarity index 100%
rename from liblog/.clang-format
rename to libcrypto_utils/.clang-format
diff --git a/libcrypto_utils/Android.bp b/libcrypto_utils/Android.bp
index d7175e0..923b291 100644
--- a/libcrypto_utils/Android.bp
+++ b/libcrypto_utils/Android.bp
@@ -23,7 +23,7 @@
     },
     host_supported: true,
     srcs: [
-        "android_pubkey.c",
+        "android_pubkey.cpp",
     ],
     cflags: [
         "-Wall",
diff --git a/libcrypto_utils/android_pubkey.c b/libcrypto_utils/android_pubkey.cpp
similarity index 65%
rename from libcrypto_utils/android_pubkey.c
rename to libcrypto_utils/android_pubkey.cpp
index 3052e52..21e5663 100644
--- a/libcrypto_utils/android_pubkey.c
+++ b/libcrypto_utils/android_pubkey.cpp
@@ -35,37 +35,29 @@
 // little-endian 32 bit words. Note that Android only supports little-endian
 // processors, so we don't do any byte order conversions when parsing the binary
 // struct.
-typedef struct RSAPublicKey {
-    // Modulus length. This must be ANDROID_PUBKEY_MODULUS_SIZE.
-    uint32_t modulus_size_words;
+struct RSAPublicKey {
+  // Modulus length. This must be ANDROID_PUBKEY_MODULUS_SIZE.
+  uint32_t modulus_size_words;
 
-    // Precomputed montgomery parameter: -1 / n[0] mod 2^32
-    uint32_t n0inv;
+  // Precomputed montgomery parameter: -1 / n[0] mod 2^32
+  uint32_t n0inv;
 
-    // RSA modulus as a little-endian array.
-    uint8_t modulus[ANDROID_PUBKEY_MODULUS_SIZE];
+  // RSA modulus as a little-endian array.
+  uint8_t modulus[ANDROID_PUBKEY_MODULUS_SIZE];
 
-    // Montgomery parameter R^2 as a little-endian array of little-endian words.
-    uint8_t rr[ANDROID_PUBKEY_MODULUS_SIZE];
+  // Montgomery parameter R^2 as a little-endian array.
+  uint8_t rr[ANDROID_PUBKEY_MODULUS_SIZE];
 
-    // RSA modulus: 3 or 65537
-    uint32_t exponent;
-} RSAPublicKey;
-
-// Reverses byte order in |buffer|.
-static void reverse_bytes(uint8_t* buffer, size_t size) {
-  for (size_t i = 0; i < (size + 1) / 2; ++i) {
-    uint8_t tmp = buffer[i];
-    buffer[i] = buffer[size - i - 1];
-    buffer[size - i - 1] = tmp;
-  }
-}
+  // RSA modulus: 3 or 65537
+  uint32_t exponent;
+};
 
 bool android_pubkey_decode(const uint8_t* key_buffer, size_t size, RSA** key) {
   const RSAPublicKey* key_struct = (RSAPublicKey*)key_buffer;
   bool ret = false;
-  uint8_t modulus_buffer[ANDROID_PUBKEY_MODULUS_SIZE];
   RSA* new_key = RSA_new();
+  BIGNUM* n = NULL;
+  BIGNUM* e = NULL;
   if (!new_key) {
     goto cleanup;
   }
@@ -79,19 +71,24 @@
   }
 
   // Convert the modulus to big-endian byte order as expected by BN_bin2bn.
-  memcpy(modulus_buffer, key_struct->modulus, sizeof(modulus_buffer));
-  reverse_bytes(modulus_buffer, sizeof(modulus_buffer));
-  new_key->n = BN_bin2bn(modulus_buffer, sizeof(modulus_buffer), NULL);
-  if (!new_key->n) {
+  n = BN_le2bn(key_struct->modulus, ANDROID_PUBKEY_MODULUS_SIZE, NULL);
+  if (!n) {
     goto cleanup;
   }
 
   // Read the exponent.
-  new_key->e = BN_new();
-  if (!new_key->e || !BN_set_word(new_key->e, key_struct->exponent)) {
+  e = BN_new();
+  if (!e || !BN_set_word(e, key_struct->exponent)) {
     goto cleanup;
   }
 
+  if (!RSA_set0_key(new_key, n, e, NULL)) {
+    goto cleanup;
+  }
+  // RSA_set0_key takes ownership of its inputs on success.
+  n = NULL;
+  e = NULL;
+
   // Note that we don't extract the montgomery parameters n0inv and rr from
   // the RSAPublicKey structure. They assume a word size of 32 bits, but
   // BoringSSL may use a word size of 64 bits internally, so we're lacking the
@@ -101,24 +98,16 @@
   // pre-computed montgomery parameters.
 
   *key = new_key;
+  new_key = NULL;
   ret = true;
 
 cleanup:
-  if (!ret && new_key) {
-    RSA_free(new_key);
-  }
+  RSA_free(new_key);
+  BN_free(n);
+  BN_free(e);
   return ret;
 }
 
-static bool android_pubkey_encode_bignum(const BIGNUM* num, uint8_t* buffer) {
-  if (!BN_bn2bin_padded(buffer, ANDROID_PUBKEY_MODULUS_SIZE, num)) {
-    return false;
-  }
-
-  reverse_bytes(buffer, ANDROID_PUBKEY_MODULUS_SIZE);
-  return true;
-}
-
 bool android_pubkey_encode(const RSA* key, uint8_t* key_buffer, size_t size) {
   RSAPublicKey* key_struct = (RSAPublicKey*)key_buffer;
   bool ret = false;
@@ -127,8 +116,7 @@
   BIGNUM* n0inv = BN_new();
   BIGNUM* rr = BN_new();
 
-  if (sizeof(RSAPublicKey) > size ||
-      RSA_size(key) != ANDROID_PUBKEY_MODULUS_SIZE) {
+  if (sizeof(RSAPublicKey) > size || RSA_size(key) != ANDROID_PUBKEY_MODULUS_SIZE) {
     goto cleanup;
   }
 
@@ -136,27 +124,26 @@
   key_struct->modulus_size_words = ANDROID_PUBKEY_MODULUS_SIZE_WORDS;
 
   // Compute and store n0inv = -1 / N[0] mod 2^32.
-  if (!ctx || !r32 || !n0inv || !BN_set_bit(r32, 32) ||
-      !BN_mod(n0inv, key->n, r32, ctx) ||
+  if (!ctx || !r32 || !n0inv || !BN_set_bit(r32, 32) || !BN_mod(n0inv, RSA_get0_n(key), r32, ctx) ||
       !BN_mod_inverse(n0inv, n0inv, r32, ctx) || !BN_sub(n0inv, r32, n0inv)) {
     goto cleanup;
   }
   key_struct->n0inv = (uint32_t)BN_get_word(n0inv);
 
   // Store the modulus.
-  if (!android_pubkey_encode_bignum(key->n, key_struct->modulus)) {
+  if (!BN_bn2le_padded(key_struct->modulus, ANDROID_PUBKEY_MODULUS_SIZE, RSA_get0_n(key))) {
     goto cleanup;
   }
 
   // Compute and store rr = (2^(rsa_size)) ^ 2 mod N.
   if (!ctx || !rr || !BN_set_bit(rr, ANDROID_PUBKEY_MODULUS_SIZE * 8) ||
-      !BN_mod_sqr(rr, rr, key->n, ctx) ||
-      !android_pubkey_encode_bignum(rr, key_struct->rr)) {
+      !BN_mod_sqr(rr, rr, RSA_get0_n(key), ctx) ||
+      !BN_bn2le_padded(key_struct->rr, ANDROID_PUBKEY_MODULUS_SIZE, rr)) {
     goto cleanup;
   }
 
   // Store the exponent.
-  key_struct->exponent = (uint32_t)BN_get_word(key->e);
+  key_struct->exponent = (uint32_t)BN_get_word(RSA_get0_e(key));
 
   ret = true;
 
diff --git a/libcutils/Android.bp b/libcutils/Android.bp
index 60400c9..0c75dc7 100644
--- a/libcutils/Android.bp
+++ b/libcutils/Android.bp
@@ -14,6 +14,11 @@
 // limitations under the License.
 //
 
+filegroup {
+    name: "android_filesystem_config_header",
+    srcs: ["include/private/android_filesystem_config.h"],
+}
+
 // some files must not be compiled when building against Mingw
 // they correspond to features not used by our host development tools
 // which are also hard or even impossible to port to native Win32
@@ -28,6 +33,7 @@
     name: "libcutils_headers",
     vendor_available: true,
     recovery_available: true,
+    ramdisk_available: true,
     host_supported: true,
     apex_available: [
         "//apex_available:platform",
@@ -54,6 +60,7 @@
     name: "libcutils_sockets",
     vendor_available: true,
     recovery_available: true,
+    ramdisk_available: true,
     host_supported: true,
     native_bridge_supported: true,
     apex_available: [
@@ -151,6 +158,7 @@
         "canned_fs_config.cpp",
         "iosched_policy.cpp",
         "load_file.cpp",
+        "memory.cpp",
         "native_handle.cpp",
         "properties.cpp",
         "record_stream.cpp",
@@ -193,25 +201,22 @@
                 "uevent.cpp",
             ],
         },
+        bionic: {
+            header_libs: ["bionic_libc_platform_headers"],
+        },
 
         android_arm: {
-            srcs: ["arch-arm/memset32.S"],
             sanitize: {
                 misc_undefined: ["integer"],
             },
         },
         android_arm64: {
-            srcs: ["arch-arm64/android_memset.S"],
             sanitize: {
                 misc_undefined: ["integer"],
             },
         },
 
         android_x86: {
-            srcs: [
-                "arch-x86/android_memset16.S",
-                "arch-x86/android_memset32.S",
-            ],
             // TODO: This is to work around b/29412086.
             // Remove once __mulodi4 is available and move the "sanitize" block
             // to the android target.
@@ -221,10 +226,6 @@
         },
 
         android_x86_64: {
-            srcs: [
-                "arch-x86_64/android_memset16.S",
-                "arch-x86_64/android_memset32.S",
-            ],
             sanitize: {
                 misc_undefined: ["integer"],
             },
@@ -279,7 +280,6 @@
                 "android_get_control_socket_test.cpp",
                 "ashmem_test.cpp",
                 "fs_config_test.cpp",
-                "memset_test.cpp",
                 "multiuser_test.cpp",
                 "sched_policy_test.cpp",
                 "str_parms_test.cpp",
diff --git a/libcutils/arch-arm/memset32.S b/libcutils/arch-arm/memset32.S
deleted file mode 100644
index 1e89636..0000000
--- a/libcutils/arch-arm/memset32.S
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2006 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.
- */
-/*
- *  memset32.S
- *
- */
-
-    .syntax unified
-
-    .text
-    .align
-
-    .global android_memset32
-    .type   android_memset32, %function
-    .global android_memset16
-    .type   android_memset16, %function
-
-        /*
-         * Optimized memset32 and memset16 for ARM.
-         *
-         * void android_memset16(uint16_t* dst, uint16_t value, size_t size);
-         * void android_memset32(uint32_t* dst, uint32_t value, size_t size);
-         *
-         */
-
-android_memset16:
-        .fnstart
-        cmp         r2, #1
-        bxle        lr
-
-        /* expand the data to 32 bits */
-        mov         r1, r1, lsl #16
-        orr         r1, r1, r1, lsr #16
-
-        /* align to 32 bits */
-        tst         r0, #2
-        strhne      r1, [r0], #2
-        subne       r2, r2, #2
-        .fnend
-
-android_memset32:
-        .fnstart
-        .cfi_startproc
-        str         lr, [sp, #-4]!
-        .cfi_def_cfa_offset 4
-        .cfi_rel_offset lr, 0
-
-        /* align the destination to a cache-line */
-        mov         r12, r1
-        mov         lr, r1
-        rsb         r3, r0, #0
-        ands        r3, r3, #0x1C
-        beq         .Laligned32
-        cmp         r3, r2
-        andhi       r3, r2, #0x1C
-        sub         r2, r2, r3
-
-        /* conditionally writes 0 to 7 words (length in r3) */
-        movs        r3, r3, lsl #28
-        stmiacs     r0!, {r1, lr}
-        stmiacs     r0!, {r1, lr}
-        stmiami     r0!, {r1, lr}
-        movs        r3, r3, lsl #2
-        strcs       r1, [r0], #4
-
-.Laligned32:
-        mov         r3, r1
-1:      subs        r2, r2, #32
-        stmiahs     r0!, {r1,r3,r12,lr}
-        stmiahs     r0!, {r1,r3,r12,lr}
-        bhs         1b
-        add         r2, r2, #32
-
-        /* conditionally stores 0 to 30 bytes */
-        movs        r2, r2, lsl #28
-        stmiacs     r0!, {r1,r3,r12,lr}
-        stmiami     r0!, {r1,lr}
-        movs        r2, r2, lsl #2
-        strcs       r1, [r0], #4
-        strhmi      lr, [r0], #2
-
-        ldr         lr, [sp], #4
-        .cfi_def_cfa_offset 0
-        .cfi_restore lr
-        bx          lr
-        .cfi_endproc
-        .fnend
diff --git a/libcutils/arch-arm64/android_memset.S b/libcutils/arch-arm64/android_memset.S
deleted file mode 100644
index 9a83a68..0000000
--- a/libcutils/arch-arm64/android_memset.S
+++ /dev/null
@@ -1,211 +0,0 @@
-/* Copyright (c) 2012, Linaro Limited
-   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 the Linaro 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
-   HOLDER 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.
-*/
-
-/* Assumptions:
- *
- * ARMv8-a, AArch64
- * Unaligned accesses
- *
- */
-
-/* By default we assume that the DC instruction can be used to zero
-   data blocks more efficiently.  In some circumstances this might be
-   unsafe, for example in an asymmetric multiprocessor environment with
-   different DC clear lengths (neither the upper nor lower lengths are
-   safe to use). */
-
-#define dst  		x0
-#define count		x2
-#define tmp1		x3
-#define tmp1w		w3
-#define tmp2		x4
-#define tmp2w		w4
-#define zva_len_x	x5
-#define zva_len		w5
-#define zva_bits_x	x6
-
-#define A_l		x1
-#define A_lw		w1
-#define tmp3w		w9
-
-#define ENTRY(f) \
-  .text; \
-  .globl f; \
-  .align 0; \
-  .type f, %function; \
-  f: \
-  .cfi_startproc \
-
-#define END(f) \
-  .cfi_endproc; \
-  .size f, .-f; \
-
-ENTRY(android_memset16)
-	ands   A_lw, A_lw, #0xffff
-	b.eq	.Lzero_mem
-	orr	A_lw, A_lw, A_lw, lsl #16
-	b .Lexpand_to_64
-END(android_memset16)
-
-ENTRY(android_memset32)
-	cmp	    A_lw, #0
-	b.eq	.Lzero_mem
-.Lexpand_to_64:
-	orr	A_l, A_l, A_l, lsl #32
-.Ltail_maybe_long:
-	cmp	count, #64
-	b.ge	.Lnot_short
-.Ltail_maybe_tiny:
-	cmp	count, #15
-	b.le	.Ltail15tiny
-.Ltail63:
-	ands	tmp1, count, #0x30
-	b.eq	.Ltail15
-	add	dst, dst, tmp1
-	cmp	tmp1w, #0x20
-	b.eq	1f
-	b.lt	2f
-	stp	A_l, A_l, [dst, #-48]
-1:
-	stp	A_l, A_l, [dst, #-32]
-2:
-	stp	A_l, A_l, [dst, #-16]
-
-.Ltail15:
-	and	count, count, #15
-	add	dst, dst, count
-	stp	A_l, A_l, [dst, #-16]	/* Repeat some/all of last store. */
-	ret
-
-.Ltail15tiny:
-	/* Set up to 15 bytes.  Does not assume earlier memory
-	   being set.  */
-	tbz	count, #3, 1f
-	str	A_l, [dst], #8
-1:
-	tbz	count, #2, 1f
-	str	A_lw, [dst], #4
-1:
-	tbz	count, #1, 1f
-	strh	A_lw, [dst], #2
-1:
-	ret
-
-	/* Critical loop.  Start at a new cache line boundary.  Assuming
-	 * 64 bytes per line, this ensures the entire loop is in one line.  */
-	.p2align 6
-.Lnot_short:
-	neg	tmp2, dst
-	ands	tmp2, tmp2, #15
-	b.eq	2f
-	/* Bring DST to 128-bit (16-byte) alignment.  We know that there's
-	 * more than that to set, so we simply store 16 bytes and advance by
-	 * the amount required to reach alignment.  */
-	sub	count, count, tmp2
-	stp	A_l, A_l, [dst]
-	add	dst, dst, tmp2
-	/* There may be less than 63 bytes to go now.  */
-	cmp	count, #63
-	b.le	.Ltail63
-2:
-	sub	dst, dst, #16		/* Pre-bias.  */
-	sub	count, count, #64
-1:
-	stp	A_l, A_l, [dst, #16]
-	stp	A_l, A_l, [dst, #32]
-	stp	A_l, A_l, [dst, #48]
-	stp	A_l, A_l, [dst, #64]!
-	subs	count, count, #64
-	b.ge	1b
-	tst	count, #0x3f
-	add	dst, dst, #16
-	b.ne	.Ltail63
-	ret
-
-	/* For zeroing memory, check to see if we can use the ZVA feature to
-	 * zero entire 'cache' lines.  */
-.Lzero_mem:
-	mov	A_l, #0
-	cmp	count, #63
-	b.le	.Ltail_maybe_tiny
-	neg	tmp2, dst
-	ands	tmp2, tmp2, #15
-	b.eq	1f
-	sub	count, count, tmp2
-	stp	A_l, A_l, [dst]
-	add	dst, dst, tmp2
-	cmp	count, #63
-	b.le	.Ltail63
-1:
-	/* For zeroing small amounts of memory, it's not worth setting up
-	 * the line-clear code.  */
-	cmp	count, #128
-	b.lt	.Lnot_short
-	mrs	tmp1, dczid_el0
-	tbnz	tmp1, #4, .Lnot_short
-	mov	tmp3w, #4
-	and	zva_len, tmp1w, #15	/* Safety: other bits reserved.  */
-	lsl	zva_len, tmp3w, zva_len
-
-.Lzero_by_line:
-	/* Compute how far we need to go to become suitably aligned.  We're
-	 * already at quad-word alignment.  */
-	cmp	count, zva_len_x
-	b.lt	.Lnot_short		/* Not enough to reach alignment.  */
-	sub	zva_bits_x, zva_len_x, #1
-	neg	tmp2, dst
-	ands	tmp2, tmp2, zva_bits_x
-	b.eq	1f			/* Already aligned.  */
-	/* Not aligned, check that there's enough to copy after alignment.  */
-	sub	tmp1, count, tmp2
-	cmp	tmp1, #64
-	ccmp	tmp1, zva_len_x, #8, ge	/* NZCV=0b1000 */
-	b.lt	.Lnot_short
-	/* We know that there's at least 64 bytes to zero and that it's safe
-	 * to overrun by 64 bytes.  */
-	mov	count, tmp1
-2:
-	stp	A_l, A_l, [dst]
-	stp	A_l, A_l, [dst, #16]
-	stp	A_l, A_l, [dst, #32]
-	subs	tmp2, tmp2, #64
-	stp	A_l, A_l, [dst, #48]
-	add	dst, dst, #64
-	b.ge	2b
-	/* We've overrun a bit, so adjust dst downwards.  */
-	add	dst, dst, tmp2
-1:
-	sub	count, count, zva_len_x
-3:
-	dc	zva, dst
-	add	dst, dst, zva_len_x
-	subs	count, count, zva_len_x
-	b.ge	3b
-	ands	count, count, zva_bits_x
-	b.ne	.Ltail_maybe_long
-	ret
-END(android_memset32)
diff --git a/libcutils/arch-x86/android_memset16.S b/libcutils/arch-x86/android_memset16.S
deleted file mode 100755
index f4d497e..0000000
--- a/libcutils/arch-x86/android_memset16.S
+++ /dev/null
@@ -1,721 +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.
- */
-
-#include "cache.h"
-
-#ifndef MEMSET
-# define MEMSET		android_memset16
-#endif
-
-#ifndef L
-# define L(label)	.L##label
-#endif
-
-#ifndef ALIGN
-# 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)
-
-#define CFI_POP(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)
-
-#ifdef USE_AS_BZERO16
-# 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
-
-#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
-
-/* Load an entry in a jump table into EBX and branch to it.  TABLE is a
-   jump table with relative offsets.   */
-# define BRANCH_TO_JMPTBL_ENTRY(TABLE)				\
-    /* We first load PC into EBX.  */				\
-    call	__x86.get_pc_thunk.bx;				\
-    /* Get the address of the jump table.  */			\
-    add		$(TABLE - .), %ebx;				\
-    /* Get the entry and convert the relative offset to the	\
-       absolute address.  */					\
-    add		(%ebx,%ecx,4), %ebx;				\
-    /* We loaded the jump table and adjuested EDX. Go.  */	\
-    jmp		*%ebx
-
-	.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
-	.globl	__x86.get_pc_thunk.bx
-	.hidden	__x86.get_pc_thunk.bx
-	ALIGN (4)
-	.type	__x86.get_pc_thunk.bx,@function
-__x86.get_pc_thunk.bx:
-	cfi_startproc
-	movl	(%esp), %ebx
-	ret
-	cfi_endproc
-#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)				\
-    jmp		*TABLE(,%ecx,4)
-#endif
-
-	.section .text.sse2,"ax",@progbits
-	ALIGN (4)
-ENTRY (MEMSET)
-	ENTRANCE
-
-	movl	LEN(%esp), %ecx
-	shr	$1, %ecx
-#ifdef USE_AS_BZERO16
-	xor	%eax, %eax
-#else
-	movzwl	CHR(%esp), %eax
-	mov	%eax, %edx
-	shl	$16, %eax
-	or	%edx, %eax
-#endif
-	movl	DEST(%esp), %edx
-	cmp	$32, %ecx
-	jae	L(32wordsormore)
-
-L(write_less32words):
-	lea	(%edx, %ecx, 2), %edx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_less32words))
-
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_less32words):
-	.int	JMPTBL (L(write_0words), L(table_less32words))
-	.int	JMPTBL (L(write_1words), L(table_less32words))
-	.int	JMPTBL (L(write_2words), L(table_less32words))
-	.int	JMPTBL (L(write_3words), L(table_less32words))
-	.int	JMPTBL (L(write_4words), L(table_less32words))
-	.int	JMPTBL (L(write_5words), L(table_less32words))
-	.int	JMPTBL (L(write_6words), L(table_less32words))
-	.int	JMPTBL (L(write_7words), L(table_less32words))
-	.int	JMPTBL (L(write_8words), L(table_less32words))
-	.int	JMPTBL (L(write_9words), L(table_less32words))
-	.int	JMPTBL (L(write_10words), L(table_less32words))
-	.int	JMPTBL (L(write_11words), L(table_less32words))
-	.int	JMPTBL (L(write_12words), L(table_less32words))
-	.int	JMPTBL (L(write_13words), L(table_less32words))
-	.int	JMPTBL (L(write_14words), L(table_less32words))
-	.int	JMPTBL (L(write_15words), L(table_less32words))
-	.int	JMPTBL (L(write_16words), L(table_less32words))
-	.int	JMPTBL (L(write_17words), L(table_less32words))
-	.int	JMPTBL (L(write_18words), L(table_less32words))
-	.int	JMPTBL (L(write_19words), L(table_less32words))
-	.int	JMPTBL (L(write_20words), L(table_less32words))
-	.int	JMPTBL (L(write_21words), L(table_less32words))
-	.int	JMPTBL (L(write_22words), L(table_less32words))
-	.int	JMPTBL (L(write_23words), L(table_less32words))
-	.int	JMPTBL (L(write_24words), L(table_less32words))
-	.int	JMPTBL (L(write_25words), L(table_less32words))
-	.int	JMPTBL (L(write_26words), L(table_less32words))
-	.int	JMPTBL (L(write_27words), L(table_less32words))
-	.int	JMPTBL (L(write_28words), L(table_less32words))
-	.int	JMPTBL (L(write_29words), L(table_less32words))
-	.int	JMPTBL (L(write_30words), L(table_less32words))
-	.int	JMPTBL (L(write_31words), L(table_less32words))
-	.popsection
-
-	ALIGN (4)
-L(write_28words):
-	movl	%eax, -56(%edx)
-	movl	%eax, -52(%edx)
-L(write_24words):
-	movl	%eax, -48(%edx)
-	movl	%eax, -44(%edx)
-L(write_20words):
-	movl	%eax, -40(%edx)
-	movl	%eax, -36(%edx)
-L(write_16words):
-	movl	%eax, -32(%edx)
-	movl	%eax, -28(%edx)
-L(write_12words):
-	movl	%eax, -24(%edx)
-	movl	%eax, -20(%edx)
-L(write_8words):
-	movl	%eax, -16(%edx)
-	movl	%eax, -12(%edx)
-L(write_4words):
-	movl	%eax, -8(%edx)
-	movl	%eax, -4(%edx)
-L(write_0words):
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(write_29words):
-	movl	%eax, -58(%edx)
-	movl	%eax, -54(%edx)
-L(write_25words):
-	movl	%eax, -50(%edx)
-	movl	%eax, -46(%edx)
-L(write_21words):
-	movl	%eax, -42(%edx)
-	movl	%eax, -38(%edx)
-L(write_17words):
-	movl	%eax, -34(%edx)
-	movl	%eax, -30(%edx)
-L(write_13words):
-	movl	%eax, -26(%edx)
-	movl	%eax, -22(%edx)
-L(write_9words):
-	movl	%eax, -18(%edx)
-	movl	%eax, -14(%edx)
-L(write_5words):
-	movl	%eax, -10(%edx)
-	movl	%eax, -6(%edx)
-L(write_1words):
-	mov	%ax, -2(%edx)
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(write_30words):
-	movl	%eax, -60(%edx)
-	movl	%eax, -56(%edx)
-L(write_26words):
-	movl	%eax, -52(%edx)
-	movl	%eax, -48(%edx)
-L(write_22words):
-	movl	%eax, -44(%edx)
-	movl	%eax, -40(%edx)
-L(write_18words):
-	movl	%eax, -36(%edx)
-	movl	%eax, -32(%edx)
-L(write_14words):
-	movl	%eax, -28(%edx)
-	movl	%eax, -24(%edx)
-L(write_10words):
-	movl	%eax, -20(%edx)
-	movl	%eax, -16(%edx)
-L(write_6words):
-	movl	%eax, -12(%edx)
-	movl	%eax, -8(%edx)
-L(write_2words):
-	movl	%eax, -4(%edx)
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(write_31words):
-	movl	%eax, -62(%edx)
-	movl	%eax, -58(%edx)
-L(write_27words):
-	movl	%eax, -54(%edx)
-	movl	%eax, -50(%edx)
-L(write_23words):
-	movl	%eax, -46(%edx)
-	movl	%eax, -42(%edx)
-L(write_19words):
-	movl	%eax, -38(%edx)
-	movl	%eax, -34(%edx)
-L(write_15words):
-	movl	%eax, -30(%edx)
-	movl	%eax, -26(%edx)
-L(write_11words):
-	movl	%eax, -22(%edx)
-	movl	%eax, -18(%edx)
-L(write_7words):
-	movl	%eax, -14(%edx)
-	movl	%eax, -10(%edx)
-L(write_3words):
-	movl	%eax, -6(%edx)
-	movw	%ax, -2(%edx)
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-
-L(32wordsormore):
-	shl	$1, %ecx
-	test	$0x01, %edx
-	jz	L(aligned2bytes)
-	mov	%eax, (%edx)
-	mov	%eax, -4(%edx, %ecx)
-	sub	$2, %ecx
-	add	$1, %edx
-	rol	$8, %eax
-L(aligned2bytes):
-#ifdef USE_AS_BZERO16
-	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.  */
-L(not_aligned_16):
-	movdqu	%xmm0, (%edx)
-	movl	%edx, %eax
-	and	$-16, %edx
-	add	$16, %edx
-	sub	%edx, %eax
-	add	%eax, %ecx
-	movd	%xmm0, %eax
-
-	ALIGN (4)
-L(aligned_16):
-	cmp	$128, %ecx
-	jae	L(128bytesormore)
-
-L(aligned_16_less128bytes):
-	add	%ecx, %edx
-	shr	$1, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-	ALIGN (4)
-L(128bytesormore):
-#ifdef SHARED_CACHE_SIZE
-	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)
-	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
-L(128bytesormore_normal):
-	sub	$128, %ecx
-	movdqa	%xmm0, (%edx)
-	movdqa	%xmm0, 0x10(%edx)
-	movdqa	%xmm0, 0x20(%edx)
-	movdqa	%xmm0, 0x30(%edx)
-	movdqa	%xmm0, 0x40(%edx)
-	movdqa	%xmm0, 0x50(%edx)
-	movdqa	%xmm0, 0x60(%edx)
-	movdqa	%xmm0, 0x70(%edx)
-	lea	128(%edx), %edx
-	jb	L(128bytesless_normal)
-
-
-	sub	$128, %ecx
-	movdqa	%xmm0, (%edx)
-	movdqa	%xmm0, 0x10(%edx)
-	movdqa	%xmm0, 0x20(%edx)
-	movdqa	%xmm0, 0x30(%edx)
-	movdqa	%xmm0, 0x40(%edx)
-	movdqa	%xmm0, 0x50(%edx)
-	movdqa	%xmm0, 0x60(%edx)
-	movdqa	%xmm0, 0x70(%edx)
-	lea	128(%edx), %edx
-	jae	L(128bytesormore_normal)
-
-L(128bytesless_normal):
-	lea	128(%ecx), %ecx
-	add	%ecx, %edx
-	shr	$1, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-	ALIGN (4)
-L(128bytes_L2_normal):
-	prefetcht0	0x380(%edx)
-	prefetcht0	0x3c0(%edx)
-	sub	$128, %ecx
-	movdqa	%xmm0, (%edx)
-	movaps	%xmm0, 0x10(%edx)
-	movaps	%xmm0, 0x20(%edx)
-	movaps	%xmm0, 0x30(%edx)
-	movaps	%xmm0, 0x40(%edx)
-	movaps	%xmm0, 0x50(%edx)
-	movaps	%xmm0, 0x60(%edx)
-	movaps	%xmm0, 0x70(%edx)
-	add	$128, %edx
-	cmp	$128, %ecx
-	jae	L(128bytes_L2_normal)
-
-L(128bytesless_L2_normal):
-	add	%ecx, %edx
-	shr	$1, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-	RESTORE_EBX_STATE
-L(128bytesormore_nt_start):
-	sub	%ebx, %ecx
-	mov	%ebx, %eax
-	and	$0x7f, %eax
-	add	%eax, %ecx
-	movd	%xmm0, %eax
-	ALIGN (4)
-L(128bytesormore_shared_cache_loop):
-	prefetcht0	0x3c0(%edx)
-	prefetcht0	0x380(%edx)
-	sub	$0x80, %ebx
-	movdqa	%xmm0, (%edx)
-	movdqa	%xmm0, 0x10(%edx)
-	movdqa	%xmm0, 0x20(%edx)
-	movdqa	%xmm0, 0x30(%edx)
-	movdqa	%xmm0, 0x40(%edx)
-	movdqa	%xmm0, 0x50(%edx)
-	movdqa	%xmm0, 0x60(%edx)
-	movdqa	%xmm0, 0x70(%edx)
-	add	$0x80, %edx
-	cmp	$0x80, %ebx
-	jae	L(128bytesormore_shared_cache_loop)
-	cmp	$0x80, %ecx
-	jb	L(shared_cache_loop_end)
-	ALIGN (4)
-L(128bytesormore_nt):
-	sub	$0x80, %ecx
-	movntdq	%xmm0, (%edx)
-	movntdq	%xmm0, 0x10(%edx)
-	movntdq	%xmm0, 0x20(%edx)
-	movntdq	%xmm0, 0x30(%edx)
-	movntdq	%xmm0, 0x40(%edx)
-	movntdq	%xmm0, 0x50(%edx)
-	movntdq	%xmm0, 0x60(%edx)
-	movntdq	%xmm0, 0x70(%edx)
-	add	$0x80, %edx
-	cmp	$0x80, %ecx
-	jae	L(128bytesormore_nt)
-	sfence
-L(shared_cache_loop_end):
-#if defined DATA_CACHE_SIZE || !(defined SHARED || defined __PIC__)
-	POP (%ebx)
-#endif
-	add	%ecx, %edx
-	shr	$1, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_16_128bytes):
-	.int	JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_2bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_6bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_10bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_14bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_18bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_22bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_26bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_30bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_34bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_38bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_42bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_46bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_50bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_54bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_58bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_62bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_66bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_70bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_74bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_78bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_82bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_86bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_90bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_94bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_98bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_102bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_106bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_110bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_114bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_118bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_122bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_126bytes), L(table_16_128bytes))
-	.popsection
-
-
-	ALIGN (4)
-L(aligned_16_112bytes):
-	movdqa	%xmm0, -112(%edx)
-L(aligned_16_96bytes):
-	movdqa	%xmm0, -96(%edx)
-L(aligned_16_80bytes):
-	movdqa	%xmm0, -80(%edx)
-L(aligned_16_64bytes):
-	movdqa	%xmm0, -64(%edx)
-L(aligned_16_48bytes):
-	movdqa	%xmm0, -48(%edx)
-L(aligned_16_32bytes):
-	movdqa	%xmm0, -32(%edx)
-L(aligned_16_16bytes):
-	movdqa	%xmm0, -16(%edx)
-L(aligned_16_0bytes):
-	SETRTNVAL
-	RETURN
-
-
-	ALIGN (4)
-L(aligned_16_114bytes):
-	movdqa	%xmm0, -114(%edx)
-L(aligned_16_98bytes):
-	movdqa	%xmm0, -98(%edx)
-L(aligned_16_82bytes):
-	movdqa	%xmm0, -82(%edx)
-L(aligned_16_66bytes):
-	movdqa	%xmm0, -66(%edx)
-L(aligned_16_50bytes):
-	movdqa	%xmm0, -50(%edx)
-L(aligned_16_34bytes):
-	movdqa	%xmm0, -34(%edx)
-L(aligned_16_18bytes):
-	movdqa	%xmm0, -18(%edx)
-L(aligned_16_2bytes):
-	movw	%ax, -2(%edx)
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(aligned_16_116bytes):
-	movdqa	%xmm0, -116(%edx)
-L(aligned_16_100bytes):
-	movdqa	%xmm0, -100(%edx)
-L(aligned_16_84bytes):
-	movdqa	%xmm0, -84(%edx)
-L(aligned_16_68bytes):
-	movdqa	%xmm0, -68(%edx)
-L(aligned_16_52bytes):
-	movdqa	%xmm0, -52(%edx)
-L(aligned_16_36bytes):
-	movdqa	%xmm0, -36(%edx)
-L(aligned_16_20bytes):
-	movdqa	%xmm0, -20(%edx)
-L(aligned_16_4bytes):
-	movl	%eax, -4(%edx)
-	SETRTNVAL
-	RETURN
-
-
-	ALIGN (4)
-L(aligned_16_118bytes):
-	movdqa	%xmm0, -118(%edx)
-L(aligned_16_102bytes):
-	movdqa	%xmm0, -102(%edx)
-L(aligned_16_86bytes):
-	movdqa	%xmm0, -86(%edx)
-L(aligned_16_70bytes):
-	movdqa	%xmm0, -70(%edx)
-L(aligned_16_54bytes):
-	movdqa	%xmm0, -54(%edx)
-L(aligned_16_38bytes):
-	movdqa	%xmm0, -38(%edx)
-L(aligned_16_22bytes):
-	movdqa	%xmm0, -22(%edx)
-L(aligned_16_6bytes):
-	movl	%eax, -6(%edx)
-	movw	%ax, -2(%edx)
-	SETRTNVAL
-	RETURN
-
-
-	ALIGN (4)
-L(aligned_16_120bytes):
-	movdqa	%xmm0, -120(%edx)
-L(aligned_16_104bytes):
-	movdqa	%xmm0, -104(%edx)
-L(aligned_16_88bytes):
-	movdqa	%xmm0, -88(%edx)
-L(aligned_16_72bytes):
-	movdqa	%xmm0, -72(%edx)
-L(aligned_16_56bytes):
-	movdqa	%xmm0, -56(%edx)
-L(aligned_16_40bytes):
-	movdqa	%xmm0, -40(%edx)
-L(aligned_16_24bytes):
-	movdqa	%xmm0, -24(%edx)
-L(aligned_16_8bytes):
-	movq	%xmm0, -8(%edx)
-	SETRTNVAL
-	RETURN
-
-
-	ALIGN (4)
-L(aligned_16_122bytes):
-	movdqa	%xmm0, -122(%edx)
-L(aligned_16_106bytes):
-	movdqa	%xmm0, -106(%edx)
-L(aligned_16_90bytes):
-	movdqa	%xmm0, -90(%edx)
-L(aligned_16_74bytes):
-	movdqa	%xmm0, -74(%edx)
-L(aligned_16_58bytes):
-	movdqa	%xmm0, -58(%edx)
-L(aligned_16_42bytes):
-	movdqa	%xmm0, -42(%edx)
-L(aligned_16_26bytes):
-	movdqa	%xmm0, -26(%edx)
-L(aligned_16_10bytes):
-	movq	%xmm0, -10(%edx)
-	movw	%ax, -2(%edx)
-	SETRTNVAL
-	RETURN
-
-
-	ALIGN (4)
-L(aligned_16_124bytes):
-	movdqa	%xmm0, -124(%edx)
-L(aligned_16_108bytes):
-	movdqa	%xmm0, -108(%edx)
-L(aligned_16_92bytes):
-	movdqa	%xmm0, -92(%edx)
-L(aligned_16_76bytes):
-	movdqa	%xmm0, -76(%edx)
-L(aligned_16_60bytes):
-	movdqa	%xmm0, -60(%edx)
-L(aligned_16_44bytes):
-	movdqa	%xmm0, -44(%edx)
-L(aligned_16_28bytes):
-	movdqa	%xmm0, -28(%edx)
-L(aligned_16_12bytes):
-	movq	%xmm0, -12(%edx)
-	movl	%eax, -4(%edx)
-	SETRTNVAL
-	RETURN
-
-
-	ALIGN (4)
-L(aligned_16_126bytes):
-	movdqa	%xmm0, -126(%edx)
-L(aligned_16_110bytes):
-	movdqa	%xmm0, -110(%edx)
-L(aligned_16_94bytes):
-	movdqa	%xmm0, -94(%edx)
-L(aligned_16_78bytes):
-	movdqa	%xmm0, -78(%edx)
-L(aligned_16_62bytes):
-	movdqa	%xmm0, -62(%edx)
-L(aligned_16_46bytes):
-	movdqa	%xmm0, -46(%edx)
-L(aligned_16_30bytes):
-	movdqa	%xmm0, -30(%edx)
-L(aligned_16_14bytes):
-	movq	%xmm0, -14(%edx)
-	movl	%eax, -6(%edx)
-	movw	%ax, -2(%edx)
-	SETRTNVAL
-	RETURN
-
-END (MEMSET)
diff --git a/libcutils/arch-x86/android_memset32.S b/libcutils/arch-x86/android_memset32.S
deleted file mode 100755
index b928f6b..0000000
--- a/libcutils/arch-x86/android_memset32.S
+++ /dev/null
@@ -1,512 +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.
- */
-
-#include "cache.h"
-
-#ifndef MEMSET
-# define MEMSET 	android_memset32
-#endif
-
-#ifndef L
-# define L(label)	.L##label
-#endif
-
-#ifndef ALIGN
-# 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)
-
-#define CFI_POP(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)
-
-#ifdef USE_AS_BZERO32
-# define DEST		PARMS
-# define LEN		DEST+4
-# define SETRTNVAL
-#else
-# define DEST		PARMS
-# define DWDS		DEST+4
-# define LEN		DWDS+4
-# define SETRTNVAL	movl DEST(%esp), %eax
-#endif
-
-#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
-
-/* Load an entry in a jump table into EBX and branch to it.  TABLE is a
-   jump table with relative offsets.   */
-# define BRANCH_TO_JMPTBL_ENTRY(TABLE)				\
-    /* We first load PC into EBX.  */				\
-    call	__x86.get_pc_thunk.bx;				\
-    /* Get the address of the jump table.  */			\
-    add		$(TABLE - .), %ebx;				\
-    /* Get the entry and convert the relative offset to the	\
-       absolute address.  */					\
-    add		(%ebx,%ecx,4), %ebx;				\
-    /* We loaded the jump table and adjuested EDX. Go.  */	\
-    jmp		*%ebx
-
-	.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
-	.globl	__x86.get_pc_thunk.bx
-	.hidden	__x86.get_pc_thunk.bx
-	ALIGN (4)
-	.type	__x86.get_pc_thunk.bx,@function
-__x86.get_pc_thunk.bx:
-	cfi_startproc
-	movl	(%esp), %ebx
-	ret
-	cfi_endproc
-#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)				\
-    jmp		*TABLE(,%ecx,4)
-#endif
-
-	.section .text.sse2,"ax",@progbits
-	ALIGN (4)
-ENTRY (MEMSET)
-	ENTRANCE
-
-	movl	LEN(%esp), %ecx
-	shr     $2, %ecx
-#ifdef USE_AS_BZERO32
-	xor	%eax, %eax
-#else
-	mov	DWDS(%esp), %eax
-	mov	%eax, %edx
-#endif
-	movl	DEST(%esp), %edx
-	cmp	$16, %ecx
-	jae	L(16dbwordsormore)
-
-L(write_less16dbwords):
-	lea	(%edx, %ecx, 4), %edx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_less16dbwords))
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_less16dbwords):
-	.int	JMPTBL (L(write_0dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_1dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_2dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_3dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_4dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_5dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_6dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_7dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_8dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_9dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_10dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_11dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_12dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_13dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_14dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_15dbwords), L(table_less16dbwords))
-	.popsection
-
-	ALIGN (4)
-L(write_15dbwords):
-	movl	%eax, -60(%edx)
-L(write_14dbwords):
-	movl	%eax, -56(%edx)
-L(write_13dbwords):
-	movl	%eax, -52(%edx)
-L(write_12dbwords):
-	movl	%eax, -48(%edx)
-L(write_11dbwords):
-	movl	%eax, -44(%edx)
-L(write_10dbwords):
-	movl	%eax, -40(%edx)
-L(write_9dbwords):
-	movl	%eax, -36(%edx)
-L(write_8dbwords):
-	movl	%eax, -32(%edx)
-L(write_7dbwords):
-	movl	%eax, -28(%edx)
-L(write_6dbwords):
-	movl	%eax, -24(%edx)
-L(write_5dbwords):
-	movl	%eax, -20(%edx)
-L(write_4dbwords):
-	movl	%eax, -16(%edx)
-L(write_3dbwords):
-	movl	%eax, -12(%edx)
-L(write_2dbwords):
-	movl	%eax, -8(%edx)
-L(write_1dbwords):
-	movl	%eax, -4(%edx)
-L(write_0dbwords):
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(16dbwordsormore):
-	test	$3, %edx
-	jz	L(aligned4bytes)
-	mov	%eax, (%edx)
-	mov	%eax, -4(%edx, %ecx, 4)
-	sub	$1, %ecx
-	rol	$24, %eax
-	add	$1, %edx
-	test	$3, %edx
-	jz	L(aligned4bytes)
-	ror	$8, %eax
-	add	$1, %edx
-	test	$3, %edx
-	jz	L(aligned4bytes)
-	ror	$8, %eax
-	add	$1, %edx
-L(aligned4bytes):
-	shl	$2, %ecx
-
-#ifdef USE_AS_BZERO32
-	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.  */
-L(not_aligned_16):
-	movdqu	%xmm0, (%edx)
-	movl	%edx, %eax
-	and	$-16, %edx
-	add	$16, %edx
-	sub	%edx, %eax
-	add	%eax, %ecx
-	movd	%xmm0, %eax
-	ALIGN (4)
-L(aligned_16):
-	cmp	$128, %ecx
-	jae	L(128bytesormore)
-
-L(aligned_16_less128bytes):
-	add	%ecx, %edx
-	shr	$2, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-	ALIGN (4)
-L(128bytesormore):
-#ifdef SHARED_CACHE_SIZE
-	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)
-	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
-L(128bytesormore_normal):
-	sub	$128, %ecx
-	movdqa	%xmm0, (%edx)
-	movdqa	%xmm0, 0x10(%edx)
-	movdqa	%xmm0, 0x20(%edx)
-	movdqa	%xmm0, 0x30(%edx)
-	movdqa	%xmm0, 0x40(%edx)
-	movdqa	%xmm0, 0x50(%edx)
-	movdqa	%xmm0, 0x60(%edx)
-	movdqa	%xmm0, 0x70(%edx)
-	lea	128(%edx), %edx
-	jb	L(128bytesless_normal)
-
-
-	sub	$128, %ecx
-	movdqa	%xmm0, (%edx)
-	movdqa	%xmm0, 0x10(%edx)
-	movdqa	%xmm0, 0x20(%edx)
-	movdqa	%xmm0, 0x30(%edx)
-	movdqa	%xmm0, 0x40(%edx)
-	movdqa	%xmm0, 0x50(%edx)
-	movdqa	%xmm0, 0x60(%edx)
-	movdqa	%xmm0, 0x70(%edx)
-	lea	128(%edx), %edx
-	jae	L(128bytesormore_normal)
-
-L(128bytesless_normal):
-	lea	128(%ecx), %ecx
-	add	%ecx, %edx
-	shr	$2, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-	ALIGN (4)
-L(128bytes_L2_normal):
-	prefetcht0	0x380(%edx)
-	prefetcht0	0x3c0(%edx)
-	sub	$128, %ecx
-	movdqa	%xmm0, (%edx)
-	movaps	%xmm0, 0x10(%edx)
-	movaps	%xmm0, 0x20(%edx)
-	movaps	%xmm0, 0x30(%edx)
-	movaps	%xmm0, 0x40(%edx)
-	movaps	%xmm0, 0x50(%edx)
-	movaps	%xmm0, 0x60(%edx)
-	movaps	%xmm0, 0x70(%edx)
-	add	$128, %edx
-	cmp	$128, %ecx
-	jae	L(128bytes_L2_normal)
-
-L(128bytesless_L2_normal):
-	add	%ecx, %edx
-	shr	$2, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-	RESTORE_EBX_STATE
-L(128bytesormore_nt_start):
-	sub	%ebx, %ecx
-	mov	%ebx, %eax
-	and	$0x7f, %eax
-	add	%eax, %ecx
-	movd	%xmm0, %eax
-	ALIGN (4)
-L(128bytesormore_shared_cache_loop):
-	prefetcht0	0x3c0(%edx)
-	prefetcht0	0x380(%edx)
-	sub	$0x80, %ebx
-	movdqa	%xmm0, (%edx)
-	movdqa	%xmm0, 0x10(%edx)
-	movdqa	%xmm0, 0x20(%edx)
-	movdqa	%xmm0, 0x30(%edx)
-	movdqa	%xmm0, 0x40(%edx)
-	movdqa	%xmm0, 0x50(%edx)
-	movdqa	%xmm0, 0x60(%edx)
-	movdqa	%xmm0, 0x70(%edx)
-	add	$0x80, %edx
-	cmp	$0x80, %ebx
-	jae	L(128bytesormore_shared_cache_loop)
-	cmp	$0x80, %ecx
-	jb	L(shared_cache_loop_end)
-
-	ALIGN (4)
-L(128bytesormore_nt):
-	sub	$0x80, %ecx
-	movntdq	%xmm0, (%edx)
-	movntdq	%xmm0, 0x10(%edx)
-	movntdq	%xmm0, 0x20(%edx)
-	movntdq	%xmm0, 0x30(%edx)
-	movntdq	%xmm0, 0x40(%edx)
-	movntdq	%xmm0, 0x50(%edx)
-	movntdq	%xmm0, 0x60(%edx)
-	movntdq	%xmm0, 0x70(%edx)
-	add	$0x80, %edx
-	cmp	$0x80, %ecx
-	jae	L(128bytesormore_nt)
-	sfence
-L(shared_cache_loop_end):
-#if defined DATA_CACHE_SIZE || !(defined SHARED || defined __PIC__)
-	POP (%ebx)
-#endif
-	add	%ecx, %edx
-	shr	$2, %ecx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_16_128bytes):
-	.int	JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
-	.popsection
-
-	ALIGN (4)
-L(aligned_16_112bytes):
-	movdqa	%xmm0, -112(%edx)
-L(aligned_16_96bytes):
-	movdqa	%xmm0, -96(%edx)
-L(aligned_16_80bytes):
-	movdqa	%xmm0, -80(%edx)
-L(aligned_16_64bytes):
-	movdqa	%xmm0, -64(%edx)
-L(aligned_16_48bytes):
-	movdqa	%xmm0, -48(%edx)
-L(aligned_16_32bytes):
-	movdqa	%xmm0, -32(%edx)
-L(aligned_16_16bytes):
-	movdqa	%xmm0, -16(%edx)
-L(aligned_16_0bytes):
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(aligned_16_116bytes):
-	movdqa	%xmm0, -116(%edx)
-L(aligned_16_100bytes):
-	movdqa	%xmm0, -100(%edx)
-L(aligned_16_84bytes):
-	movdqa	%xmm0, -84(%edx)
-L(aligned_16_68bytes):
-	movdqa	%xmm0, -68(%edx)
-L(aligned_16_52bytes):
-	movdqa	%xmm0, -52(%edx)
-L(aligned_16_36bytes):
-	movdqa	%xmm0, -36(%edx)
-L(aligned_16_20bytes):
-	movdqa	%xmm0, -20(%edx)
-L(aligned_16_4bytes):
-	movl	%eax, -4(%edx)
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(aligned_16_120bytes):
-	movdqa	%xmm0, -120(%edx)
-L(aligned_16_104bytes):
-	movdqa	%xmm0, -104(%edx)
-L(aligned_16_88bytes):
-	movdqa	%xmm0, -88(%edx)
-L(aligned_16_72bytes):
-	movdqa	%xmm0, -72(%edx)
-L(aligned_16_56bytes):
-	movdqa	%xmm0, -56(%edx)
-L(aligned_16_40bytes):
-	movdqa	%xmm0, -40(%edx)
-L(aligned_16_24bytes):
-	movdqa	%xmm0, -24(%edx)
-L(aligned_16_8bytes):
-	movq	%xmm0, -8(%edx)
-	SETRTNVAL
-	RETURN
-
-	ALIGN (4)
-L(aligned_16_124bytes):
-	movdqa	%xmm0, -124(%edx)
-L(aligned_16_108bytes):
-	movdqa	%xmm0, -108(%edx)
-L(aligned_16_92bytes):
-	movdqa	%xmm0, -92(%edx)
-L(aligned_16_76bytes):
-	movdqa	%xmm0, -76(%edx)
-L(aligned_16_60bytes):
-	movdqa	%xmm0, -60(%edx)
-L(aligned_16_44bytes):
-	movdqa	%xmm0, -44(%edx)
-L(aligned_16_28bytes):
-	movdqa	%xmm0, -28(%edx)
-L(aligned_16_12bytes):
-	movq	%xmm0, -12(%edx)
-	movl	%eax, -4(%edx)
-	SETRTNVAL
-	RETURN
-
-END (MEMSET)
diff --git a/libcutils/arch-x86_64/android_memset16.S b/libcutils/arch-x86_64/android_memset16.S
deleted file mode 100644
index cb6d4a3..0000000
--- a/libcutils/arch-x86_64/android_memset16.S
+++ /dev/null
@@ -1,565 +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 "cache.h"
-
-#ifndef MEMSET
-# define MEMSET		android_memset16
-#endif
-
-#ifndef L
-# define L(label)	.L##label
-#endif
-
-#ifndef ALIGN
-# 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 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 JMPTBL(I, B)	I - B
-
-/* Branch to an entry in a jump table.  TABLE is a jump table with
-   relative offsets.  INDEX is a register contains the index into the
-   jump table.  SCALE is the scale of INDEX.  */
-#define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE) \
-	lea    TABLE(%rip), %r11;						\
-	movslq (%r11, INDEX, SCALE), INDEX;				\
-	lea    (%r11, INDEX), INDEX;					\
-	jmp    *INDEX
-
-	.section .text.sse2,"ax",@progbits
-	ALIGN (4)
-ENTRY (MEMSET)	// Address in rdi
-	shr    $1, %rdx			// Count in rdx
-	movzwl %si, %ecx
-	/* Fill the whole ECX with pattern.  */
-	shl    $16, %esi
-	or     %esi, %ecx		// Pattern in ecx
-
-	cmp    $32, %rdx
-	jae    L(32wordsormore)
-
-L(write_less32words):
-	lea    (%rdi, %rdx, 2), %rdi
-	BRANCH_TO_JMPTBL_ENTRY (L(table_less32words), %rdx, 4)
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_less32words):
-	.int	JMPTBL (L(write_0words), L(table_less32words))
-	.int	JMPTBL (L(write_1words), L(table_less32words))
-	.int	JMPTBL (L(write_2words), L(table_less32words))
-	.int	JMPTBL (L(write_3words), L(table_less32words))
-	.int	JMPTBL (L(write_4words), L(table_less32words))
-	.int	JMPTBL (L(write_5words), L(table_less32words))
-	.int	JMPTBL (L(write_6words), L(table_less32words))
-	.int	JMPTBL (L(write_7words), L(table_less32words))
-	.int	JMPTBL (L(write_8words), L(table_less32words))
-	.int	JMPTBL (L(write_9words), L(table_less32words))
-	.int	JMPTBL (L(write_10words), L(table_less32words))
-	.int	JMPTBL (L(write_11words), L(table_less32words))
-	.int	JMPTBL (L(write_12words), L(table_less32words))
-	.int	JMPTBL (L(write_13words), L(table_less32words))
-	.int	JMPTBL (L(write_14words), L(table_less32words))
-	.int	JMPTBL (L(write_15words), L(table_less32words))
-	.int	JMPTBL (L(write_16words), L(table_less32words))
-	.int	JMPTBL (L(write_17words), L(table_less32words))
-	.int	JMPTBL (L(write_18words), L(table_less32words))
-	.int	JMPTBL (L(write_19words), L(table_less32words))
-	.int	JMPTBL (L(write_20words), L(table_less32words))
-	.int	JMPTBL (L(write_21words), L(table_less32words))
-	.int	JMPTBL (L(write_22words), L(table_less32words))
-	.int	JMPTBL (L(write_23words), L(table_less32words))
-	.int	JMPTBL (L(write_24words), L(table_less32words))
-	.int	JMPTBL (L(write_25words), L(table_less32words))
-	.int	JMPTBL (L(write_26words), L(table_less32words))
-	.int	JMPTBL (L(write_27words), L(table_less32words))
-	.int	JMPTBL (L(write_28words), L(table_less32words))
-	.int	JMPTBL (L(write_29words), L(table_less32words))
-	.int	JMPTBL (L(write_30words), L(table_less32words))
-	.int	JMPTBL (L(write_31words), L(table_less32words))
-	.popsection
-
-	ALIGN (4)
-L(write_28words):
-	movl   %ecx, -56(%rdi)
-	movl   %ecx, -52(%rdi)
-L(write_24words):
-	movl   %ecx, -48(%rdi)
-	movl   %ecx, -44(%rdi)
-L(write_20words):
-	movl   %ecx, -40(%rdi)
-	movl   %ecx, -36(%rdi)
-L(write_16words):
-	movl   %ecx, -32(%rdi)
-	movl   %ecx, -28(%rdi)
-L(write_12words):
-	movl   %ecx, -24(%rdi)
-	movl   %ecx, -20(%rdi)
-L(write_8words):
-	movl   %ecx, -16(%rdi)
-	movl   %ecx, -12(%rdi)
-L(write_4words):
-	movl   %ecx, -8(%rdi)
-	movl   %ecx, -4(%rdi)
-L(write_0words):
-	ret
-
-	ALIGN (4)
-L(write_29words):
-	movl   %ecx, -58(%rdi)
-	movl   %ecx, -54(%rdi)
-L(write_25words):
-	movl   %ecx, -50(%rdi)
-	movl   %ecx, -46(%rdi)
-L(write_21words):
-	movl   %ecx, -42(%rdi)
-	movl   %ecx, -38(%rdi)
-L(write_17words):
-	movl   %ecx, -34(%rdi)
-	movl   %ecx, -30(%rdi)
-L(write_13words):
-	movl   %ecx, -26(%rdi)
-	movl   %ecx, -22(%rdi)
-L(write_9words):
-	movl   %ecx, -18(%rdi)
-	movl   %ecx, -14(%rdi)
-L(write_5words):
-	movl   %ecx, -10(%rdi)
-	movl   %ecx, -6(%rdi)
-L(write_1words):
-	mov	%cx, -2(%rdi)
-	ret
-
-	ALIGN (4)
-L(write_30words):
-	movl   %ecx, -60(%rdi)
-	movl   %ecx, -56(%rdi)
-L(write_26words):
-	movl   %ecx, -52(%rdi)
-	movl   %ecx, -48(%rdi)
-L(write_22words):
-	movl   %ecx, -44(%rdi)
-	movl   %ecx, -40(%rdi)
-L(write_18words):
-	movl   %ecx, -36(%rdi)
-	movl   %ecx, -32(%rdi)
-L(write_14words):
-	movl   %ecx, -28(%rdi)
-	movl   %ecx, -24(%rdi)
-L(write_10words):
-	movl   %ecx, -20(%rdi)
-	movl   %ecx, -16(%rdi)
-L(write_6words):
-	movl   %ecx, -12(%rdi)
-	movl   %ecx, -8(%rdi)
-L(write_2words):
-	movl   %ecx, -4(%rdi)
-	ret
-
-	ALIGN (4)
-L(write_31words):
-	movl   %ecx, -62(%rdi)
-	movl   %ecx, -58(%rdi)
-L(write_27words):
-	movl   %ecx, -54(%rdi)
-	movl   %ecx, -50(%rdi)
-L(write_23words):
-	movl   %ecx, -46(%rdi)
-	movl   %ecx, -42(%rdi)
-L(write_19words):
-	movl   %ecx, -38(%rdi)
-	movl   %ecx, -34(%rdi)
-L(write_15words):
-	movl   %ecx, -30(%rdi)
-	movl   %ecx, -26(%rdi)
-L(write_11words):
-	movl   %ecx, -22(%rdi)
-	movl   %ecx, -18(%rdi)
-L(write_7words):
-	movl   %ecx, -14(%rdi)
-	movl   %ecx, -10(%rdi)
-L(write_3words):
-	movl   %ecx, -6(%rdi)
-	movw   %cx, -2(%rdi)
-	ret
-
-	ALIGN (4)
-L(32wordsormore):
-	shl    $1, %rdx
-	test   $0x01, %edi
-	jz     L(aligned2bytes)
-	mov    %ecx, (%rdi)
-	mov    %ecx, -4(%rdi, %rdx)
-	sub    $2, %rdx
-	add    $1, %rdi
-	rol    $8, %ecx
-L(aligned2bytes):
-	/* Fill xmm0 with the pattern.  */
-	movd   %ecx, %xmm0
-	pshufd $0, %xmm0, %xmm0
-
-	testl  $0xf, %edi
-	jz     L(aligned_16)
-/* RDX > 32 and RDI is not 16 byte aligned.  */
-	movdqu %xmm0, (%rdi)
-	mov    %rdi, %rsi
-	and    $-16, %rdi
-	add    $16, %rdi
-	sub    %rdi, %rsi
-	add    %rsi, %rdx
-
-	ALIGN (4)
-L(aligned_16):
-	cmp    $128, %rdx
-	jge    L(128bytesormore)
-
-L(aligned_16_less128bytes):
-	add    %rdx, %rdi
-	shr    $1, %rdx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes), %rdx, 4)
-
-	ALIGN (4)
-L(128bytesormore):
-	cmp    $SHARED_CACHE_SIZE, %rdx
-	jg     L(128bytesormore_nt)
-
-L(128bytesormore_normal):
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jl     L(128bytesless_normal)
-
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jl     L(128bytesless_normal)
-
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jl     L(128bytesless_normal)
-
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jge    L(128bytesormore_normal)
-
-L(128bytesless_normal):
-	add    %rdx, %rdi
-	shr    $1, %rdx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes), %rdx, 4)
-
-	ALIGN (4)
-L(128bytesormore_nt):
-	sub    $128, %rdx
-	movntdq %xmm0, (%rdi)
-	movntdq %xmm0, 0x10(%rdi)
-	movntdq %xmm0, 0x20(%rdi)
-	movntdq %xmm0, 0x30(%rdi)
-	movntdq %xmm0, 0x40(%rdi)
-	movntdq %xmm0, 0x50(%rdi)
-	movntdq %xmm0, 0x60(%rdi)
-	movntdq %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jge    L(128bytesormore_nt)
-
-	sfence
-	add    %rdx, %rdi
-	shr    $1, %rdx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes), %rdx, 4)
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_16_128bytes):
-	.int	JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_2bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_6bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_10bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_14bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_18bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_22bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_26bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_30bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_34bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_38bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_42bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_46bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_50bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_54bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_58bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_62bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_66bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_70bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_74bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_78bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_82bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_86bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_90bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_94bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_98bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_102bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_106bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_110bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_114bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_118bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_122bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_126bytes), L(table_16_128bytes))
-	.popsection
-
-	ALIGN (4)
-L(aligned_16_112bytes):
-	movdqa %xmm0, -112(%rdi)
-L(aligned_16_96bytes):
-	movdqa %xmm0, -96(%rdi)
-L(aligned_16_80bytes):
-	movdqa %xmm0, -80(%rdi)
-L(aligned_16_64bytes):
-	movdqa %xmm0, -64(%rdi)
-L(aligned_16_48bytes):
-	movdqa %xmm0, -48(%rdi)
-L(aligned_16_32bytes):
-	movdqa %xmm0, -32(%rdi)
-L(aligned_16_16bytes):
-	movdqa %xmm0, -16(%rdi)
-L(aligned_16_0bytes):
-	ret
-
-	ALIGN (4)
-L(aligned_16_114bytes):
-	movdqa %xmm0, -114(%rdi)
-L(aligned_16_98bytes):
-	movdqa %xmm0, -98(%rdi)
-L(aligned_16_82bytes):
-	movdqa %xmm0, -82(%rdi)
-L(aligned_16_66bytes):
-	movdqa %xmm0, -66(%rdi)
-L(aligned_16_50bytes):
-	movdqa %xmm0, -50(%rdi)
-L(aligned_16_34bytes):
-	movdqa %xmm0, -34(%rdi)
-L(aligned_16_18bytes):
-	movdqa %xmm0, -18(%rdi)
-L(aligned_16_2bytes):
-	movw   %cx, -2(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_116bytes):
-	movdqa %xmm0, -116(%rdi)
-L(aligned_16_100bytes):
-	movdqa %xmm0, -100(%rdi)
-L(aligned_16_84bytes):
-	movdqa %xmm0, -84(%rdi)
-L(aligned_16_68bytes):
-	movdqa %xmm0, -68(%rdi)
-L(aligned_16_52bytes):
-	movdqa %xmm0, -52(%rdi)
-L(aligned_16_36bytes):
-	movdqa %xmm0, -36(%rdi)
-L(aligned_16_20bytes):
-	movdqa %xmm0, -20(%rdi)
-L(aligned_16_4bytes):
-	movl   %ecx, -4(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_118bytes):
-	movdqa %xmm0, -118(%rdi)
-L(aligned_16_102bytes):
-	movdqa %xmm0, -102(%rdi)
-L(aligned_16_86bytes):
-	movdqa %xmm0, -86(%rdi)
-L(aligned_16_70bytes):
-	movdqa %xmm0, -70(%rdi)
-L(aligned_16_54bytes):
-	movdqa %xmm0, -54(%rdi)
-L(aligned_16_38bytes):
-	movdqa %xmm0, -38(%rdi)
-L(aligned_16_22bytes):
-	movdqa %xmm0, -22(%rdi)
-L(aligned_16_6bytes):
-	movl   %ecx, -6(%rdi)
-	movw   %cx, -2(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_120bytes):
-	movdqa %xmm0, -120(%rdi)
-L(aligned_16_104bytes):
-	movdqa %xmm0, -104(%rdi)
-L(aligned_16_88bytes):
-	movdqa %xmm0, -88(%rdi)
-L(aligned_16_72bytes):
-	movdqa %xmm0, -72(%rdi)
-L(aligned_16_56bytes):
-	movdqa %xmm0, -56(%rdi)
-L(aligned_16_40bytes):
-	movdqa %xmm0, -40(%rdi)
-L(aligned_16_24bytes):
-	movdqa %xmm0, -24(%rdi)
-L(aligned_16_8bytes):
-	movq   %xmm0, -8(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_122bytes):
-	movdqa %xmm0, -122(%rdi)
-L(aligned_16_106bytes):
-	movdqa %xmm0, -106(%rdi)
-L(aligned_16_90bytes):
-	movdqa %xmm0, -90(%rdi)
-L(aligned_16_74bytes):
-	movdqa %xmm0, -74(%rdi)
-L(aligned_16_58bytes):
-	movdqa %xmm0, -58(%rdi)
-L(aligned_16_42bytes):
-	movdqa %xmm0, -42(%rdi)
-L(aligned_16_26bytes):
-	movdqa %xmm0, -26(%rdi)
-L(aligned_16_10bytes):
-	movq   %xmm0, -10(%rdi)
-	movw   %cx, -2(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_124bytes):
-	movdqa %xmm0, -124(%rdi)
-L(aligned_16_108bytes):
-	movdqa %xmm0, -108(%rdi)
-L(aligned_16_92bytes):
-	movdqa %xmm0, -92(%rdi)
-L(aligned_16_76bytes):
-	movdqa %xmm0, -76(%rdi)
-L(aligned_16_60bytes):
-	movdqa %xmm0, -60(%rdi)
-L(aligned_16_44bytes):
-	movdqa %xmm0, -44(%rdi)
-L(aligned_16_28bytes):
-	movdqa %xmm0, -28(%rdi)
-L(aligned_16_12bytes):
-	movq   %xmm0, -12(%rdi)
-	movl   %ecx, -4(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_126bytes):
-	movdqa %xmm0, -126(%rdi)
-L(aligned_16_110bytes):
-	movdqa %xmm0, -110(%rdi)
-L(aligned_16_94bytes):
-	movdqa %xmm0, -94(%rdi)
-L(aligned_16_78bytes):
-	movdqa %xmm0, -78(%rdi)
-L(aligned_16_62bytes):
-	movdqa %xmm0, -62(%rdi)
-L(aligned_16_46bytes):
-	movdqa %xmm0, -46(%rdi)
-L(aligned_16_30bytes):
-	movdqa %xmm0, -30(%rdi)
-L(aligned_16_14bytes):
-	movq   %xmm0, -14(%rdi)
-	movl   %ecx, -6(%rdi)
-	movw   %cx, -2(%rdi)
-	ret
-
-END (MEMSET)
diff --git a/libcutils/arch-x86_64/android_memset32.S b/libcutils/arch-x86_64/android_memset32.S
deleted file mode 100644
index 1514aa2..0000000
--- a/libcutils/arch-x86_64/android_memset32.S
+++ /dev/null
@@ -1,373 +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 "cache.h"
-
-#ifndef MEMSET
-# define MEMSET		android_memset32
-#endif
-
-#ifndef L
-# define L(label)	.L##label
-#endif
-
-#ifndef ALIGN
-# 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 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 JMPTBL(I, B)	I - B
-
-/* Branch to an entry in a jump table.  TABLE is a jump table with
-   relative offsets.  INDEX is a register contains the index into the
-   jump table.  SCALE is the scale of INDEX.  */
-#define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE) \
-	lea    TABLE(%rip), %r11;						\
-	movslq (%r11, INDEX, SCALE), INDEX;				\
-	lea    (%r11, INDEX), INDEX;					\
-	jmp    *INDEX
-
-	.section .text.sse2,"ax",@progbits
-	ALIGN (4)
-ENTRY (MEMSET)	// Address in rdi
-	shr    $2, %rdx			// Count in rdx
-	movl   %esi, %ecx		// Pattern in ecx
-
-	cmp    $16, %rdx
-	jae    L(16dbwordsormore)
-
-L(write_less16dbwords):
-	lea    (%rdi, %rdx, 4), %rdi
-	BRANCH_TO_JMPTBL_ENTRY (L(table_less16dbwords), %rdx, 4)
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_less16dbwords):
-	.int	JMPTBL (L(write_0dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_1dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_2dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_3dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_4dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_5dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_6dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_7dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_8dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_9dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_10dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_11dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_12dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_13dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_14dbwords), L(table_less16dbwords))
-	.int	JMPTBL (L(write_15dbwords), L(table_less16dbwords))
-	.popsection
-
-	ALIGN (4)
-L(write_15dbwords):
-	movl   %ecx, -60(%rdi)
-L(write_14dbwords):
-	movl   %ecx, -56(%rdi)
-L(write_13dbwords):
-	movl   %ecx, -52(%rdi)
-L(write_12dbwords):
-	movl   %ecx, -48(%rdi)
-L(write_11dbwords):
-	movl   %ecx, -44(%rdi)
-L(write_10dbwords):
-	movl   %ecx, -40(%rdi)
-L(write_9dbwords):
-	movl   %ecx, -36(%rdi)
-L(write_8dbwords):
-	movl   %ecx, -32(%rdi)
-L(write_7dbwords):
-	movl   %ecx, -28(%rdi)
-L(write_6dbwords):
-	movl   %ecx, -24(%rdi)
-L(write_5dbwords):
-	movl   %ecx, -20(%rdi)
-L(write_4dbwords):
-	movl   %ecx, -16(%rdi)
-L(write_3dbwords):
-	movl   %ecx, -12(%rdi)
-L(write_2dbwords):
-	movl   %ecx, -8(%rdi)
-L(write_1dbwords):
-	movl   %ecx, -4(%rdi)
-L(write_0dbwords):
-	ret
-
-	ALIGN (4)
-L(16dbwordsormore):
-	test   $3, %edi
-	jz     L(aligned4bytes)
-	mov    %ecx, (%rdi)
-	mov    %ecx, -4(%rdi, %rdx, 4)
-	sub    $1, %rdx
-	rol    $24, %ecx
-	add    $1, %rdi
-	test   $3, %edi
-	jz     L(aligned4bytes)
-	ror    $8, %ecx
-	add    $1, %rdi
-	test   $3, %edi
-	jz     L(aligned4bytes)
-	ror    $8, %ecx
-	add    $1, %rdi
-L(aligned4bytes):
-	shl    $2, %rdx
-
-	/* Fill xmm0 with the pattern.  */
-	movd   %ecx, %xmm0
-	pshufd $0, %xmm0, %xmm0
-
-	testl  $0xf, %edi
-	jz     L(aligned_16)
-/* RDX > 32 and RDI is not 16 byte aligned.  */
-	movdqu %xmm0, (%rdi)
-	mov    %rdi, %rsi
-	and    $-16, %rdi
-	add    $16, %rdi
-	sub    %rdi, %rsi
-	add    %rsi, %rdx
-
-	ALIGN (4)
-L(aligned_16):
-	cmp    $128, %rdx
-	jge    L(128bytesormore)
-
-L(aligned_16_less128bytes):
-	add    %rdx, %rdi
-	shr    $2, %rdx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes), %rdx, 4)
-
-	ALIGN (4)
-L(128bytesormore):
-	cmp    $SHARED_CACHE_SIZE, %rdx
-	jg     L(128bytesormore_nt)
-
-L(128bytesormore_normal):
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jl     L(128bytesless_normal)
-
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jl     L(128bytesless_normal)
-
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jl     L(128bytesless_normal)
-
-	sub    $128, %rdx
-	movdqa %xmm0, (%rdi)
-	movdqa %xmm0, 0x10(%rdi)
-	movdqa %xmm0, 0x20(%rdi)
-	movdqa %xmm0, 0x30(%rdi)
-	movdqa %xmm0, 0x40(%rdi)
-	movdqa %xmm0, 0x50(%rdi)
-	movdqa %xmm0, 0x60(%rdi)
-	movdqa %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jge    L(128bytesormore_normal)
-
-L(128bytesless_normal):
-	add    %rdx, %rdi
-	shr    $2, %rdx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes), %rdx, 4)
-
-	ALIGN (4)
-L(128bytesormore_nt):
-	sub    $128, %rdx
-	movntdq %xmm0, (%rdi)
-	movntdq %xmm0, 0x10(%rdi)
-	movntdq %xmm0, 0x20(%rdi)
-	movntdq %xmm0, 0x30(%rdi)
-	movntdq %xmm0, 0x40(%rdi)
-	movntdq %xmm0, 0x50(%rdi)
-	movntdq %xmm0, 0x60(%rdi)
-	movntdq %xmm0, 0x70(%rdi)
-	lea    128(%rdi), %rdi
-	cmp    $128, %rdx
-	jge    L(128bytesormore_nt)
-
-	sfence
-	add    %rdx, %rdi
-	shr    $2, %rdx
-	BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes), %rdx, 4)
-
-	.pushsection .rodata.sse2,"a",@progbits
-	ALIGN (2)
-L(table_16_128bytes):
-	.int	JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
-	.int	JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
-	.popsection
-
-	ALIGN (4)
-L(aligned_16_112bytes):
-	movdqa	%xmm0, -112(%rdi)
-L(aligned_16_96bytes):
-	movdqa	%xmm0, -96(%rdi)
-L(aligned_16_80bytes):
-	movdqa	%xmm0, -80(%rdi)
-L(aligned_16_64bytes):
-	movdqa	%xmm0, -64(%rdi)
-L(aligned_16_48bytes):
-	movdqa	%xmm0, -48(%rdi)
-L(aligned_16_32bytes):
-	movdqa	%xmm0, -32(%rdi)
-L(aligned_16_16bytes):
-	movdqa	%xmm0, -16(%rdi)
-L(aligned_16_0bytes):
-	ret
-
-	ALIGN (4)
-L(aligned_16_116bytes):
-	movdqa	%xmm0, -116(%rdi)
-L(aligned_16_100bytes):
-	movdqa	%xmm0, -100(%rdi)
-L(aligned_16_84bytes):
-	movdqa	%xmm0, -84(%rdi)
-L(aligned_16_68bytes):
-	movdqa	%xmm0, -68(%rdi)
-L(aligned_16_52bytes):
-	movdqa	%xmm0, -52(%rdi)
-L(aligned_16_36bytes):
-	movdqa	%xmm0, -36(%rdi)
-L(aligned_16_20bytes):
-	movdqa	%xmm0, -20(%rdi)
-L(aligned_16_4bytes):
-	movl	%ecx, -4(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_120bytes):
-	movdqa	%xmm0, -120(%rdi)
-L(aligned_16_104bytes):
-	movdqa	%xmm0, -104(%rdi)
-L(aligned_16_88bytes):
-	movdqa	%xmm0, -88(%rdi)
-L(aligned_16_72bytes):
-	movdqa	%xmm0, -72(%rdi)
-L(aligned_16_56bytes):
-	movdqa	%xmm0, -56(%rdi)
-L(aligned_16_40bytes):
-	movdqa	%xmm0, -40(%rdi)
-L(aligned_16_24bytes):
-	movdqa	%xmm0, -24(%rdi)
-L(aligned_16_8bytes):
-	movq	%xmm0, -8(%rdi)
-	ret
-
-	ALIGN (4)
-L(aligned_16_124bytes):
-	movdqa	%xmm0, -124(%rdi)
-L(aligned_16_108bytes):
-	movdqa	%xmm0, -108(%rdi)
-L(aligned_16_92bytes):
-	movdqa	%xmm0, -92(%rdi)
-L(aligned_16_76bytes):
-	movdqa	%xmm0, -76(%rdi)
-L(aligned_16_60bytes):
-	movdqa	%xmm0, -60(%rdi)
-L(aligned_16_44bytes):
-	movdqa	%xmm0, -44(%rdi)
-L(aligned_16_28bytes):
-	movdqa	%xmm0, -28(%rdi)
-L(aligned_16_12bytes):
-	movq	%xmm0, -12(%rdi)
-	movl	%ecx, -4(%rdi)
-	ret
-
-END (MEMSET)
diff --git a/libcutils/ashmem-dev.cpp b/libcutils/ashmem-dev.cpp
index 233d400..6a27f9a 100644
--- a/libcutils/ashmem-dev.cpp
+++ b/libcutils/ashmem-dev.cpp
@@ -159,9 +159,11 @@
         return false;
     }
 
-    /* Check if kernel support exists, otherwise fall back to ashmem */
+    // Check if kernel support exists, otherwise fall back to ashmem.
+    // This code needs to build on old API levels, so we can't use the libc
+    // wrapper.
     android::base::unique_fd fd(
-            syscall(__NR_memfd_create, "test_android_memfd", MFD_ALLOW_SEALING));
+            syscall(__NR_memfd_create, "test_android_memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING));
     if (fd == -1) {
         ALOGE("memfd_create failed: %s, no memfd support.\n", strerror(errno));
         return false;
@@ -333,7 +335,9 @@
 }
 
 static int memfd_create_region(const char* name, size_t size) {
-    android::base::unique_fd fd(syscall(__NR_memfd_create, name, MFD_ALLOW_SEALING));
+    // This code needs to build on old API levels, so we can't use the libc
+    // wrapper.
+    android::base::unique_fd fd(syscall(__NR_memfd_create, name, MFD_CLOEXEC | MFD_ALLOW_SEALING));
 
     if (fd == -1) {
         ALOGE("memfd_create(%s, %zd) failed: %s\n", name, size, strerror(errno));
diff --git a/libcutils/ashmem_test.cpp b/libcutils/ashmem_test.cpp
index b37d020..fb657f6 100644
--- a/libcutils/ashmem_test.cpp
+++ b/libcutils/ashmem_test.cpp
@@ -35,6 +35,11 @@
     ASSERT_TRUE(ashmem_valid(fd));
     ASSERT_EQ(size, static_cast<size_t>(ashmem_get_size_region(fd)));
     ASSERT_EQ(0, ashmem_set_prot_region(fd, prot));
+
+    // We've been inconsistent historically about whether or not these file
+    // descriptors were CLOEXEC. Make sure we're consistent going forward.
+    // https://issuetracker.google.com/165667331
+    ASSERT_EQ(FD_CLOEXEC, (fcntl(fd, F_GETFD) & FD_CLOEXEC));
 }
 
 void TestMmap(const unique_fd& fd, size_t size, int prot, void** region, off_t off = 0) {
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index b9fc82e..31e1679 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -80,6 +80,7 @@
     { 00771, AID_SYSTEM,       AID_SYSTEM,       0, "data" },
     { 00755, AID_ROOT,         AID_SYSTEM,       0, "mnt" },
     { 00751, AID_ROOT,         AID_SHELL,        0, "product/bin" },
+    { 00751, AID_ROOT,         AID_SHELL,        0, "product/apex/*/bin" },
     { 00777, AID_ROOT,         AID_ROOT,         0, "sdcard" },
     { 00751, AID_ROOT,         AID_SDCARD_R,     0, "storage" },
     { 00751, AID_ROOT,         AID_SHELL,        0, "system/bin" },
@@ -90,6 +91,7 @@
     { 00751, AID_ROOT,         AID_SHELL,        0, "system_ext/bin" },
     { 00751, AID_ROOT,         AID_SHELL,        0, "system_ext/apex/*/bin" },
     { 00751, AID_ROOT,         AID_SHELL,        0, "vendor/bin" },
+    { 00751, AID_ROOT,         AID_SHELL,        0, "vendor/apex/*/bin" },
     { 00755, AID_ROOT,         AID_SHELL,        0, "vendor" },
     { 00755, AID_ROOT,         AID_ROOT,         0, 0 },
         // clang-format on
@@ -210,12 +212,14 @@
     { 00750, AID_ROOT,      AID_SHELL,     0, "init*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "odm/bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "product/bin/*" },
+    { 00755, AID_ROOT,      AID_SHELL,     0, "product/apex/*bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "system/bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "system/xbin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "system/apex/*/bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "system_ext/bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "system_ext/apex/*/bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "vendor/bin/*" },
+    { 00755, AID_ROOT,      AID_SHELL,     0, "vendor/apex/*bin/*" },
     { 00755, AID_ROOT,      AID_SHELL,     0, "vendor/xbin/*" },
     { 00644, AID_ROOT,      AID_ROOT,      0, 0 },
         // clang-format on
diff --git a/libcutils/include/cutils/memory.h b/libcutils/include/cutils/memory.h
index 4d26882..0fba53c 100644
--- a/libcutils/include/cutils/memory.h
+++ b/libcutils/include/cutils/memory.h
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_CUTILS_MEMORY_H
-#define ANDROID_CUTILS_MEMORY_H
+#pragma once
 
 #include <stdint.h>
 #include <sys/types.h>
@@ -24,19 +23,14 @@
 extern "C" {
 #endif
 
-/* size is given in bytes and must be multiple of 2 */
-void android_memset16(uint16_t* dst, uint16_t value, size_t size);
-
-/* size is given in bytes and must be multiple of 4 */
-void android_memset32(uint32_t* dst, uint32_t value, size_t size);
-
 #if defined(__GLIBC__) || defined(_WIN32)
 /* Declaration of strlcpy() for platforms that don't already have it. */
 size_t strlcpy(char *dst, const char *src, size_t size);
 #endif
 
+// Disables memory mitigations for the entire process, and logs appropriately.
+void process_disable_memory_mitigations();
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
-
-#endif // ANDROID_CUTILS_MEMORY_H
diff --git a/libcutils/include/cutils/trace.h b/libcutils/include/cutils/trace.h
index c74ee3e..793e2ce 100644
--- a/libcutils/include/cutils/trace.h
+++ b/libcutils/include/cutils/trace.h
@@ -75,7 +75,8 @@
 #define ATRACE_TAG_AIDL             (1<<24)
 #define ATRACE_TAG_NNAPI            (1<<25)
 #define ATRACE_TAG_RRO              (1<<26)
-#define ATRACE_TAG_LAST             ATRACE_TAG_RRO
+#define ATRACE_TAG_SYSPROP          (1<<27)
+#define ATRACE_TAG_LAST             ATRACE_TAG_SYSPROP
 
 // Reserved for initialization.
 #define ATRACE_TAG_NOT_READY        (1ULL<<63)
diff --git a/libcutils/memory.cpp b/libcutils/memory.cpp
new file mode 100644
index 0000000..f526520
--- /dev/null
+++ b/libcutils/memory.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 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 <cutils/memory.h>
+
+#include <log/log.h>
+
+#ifdef __BIONIC__
+#include <bionic/malloc.h>
+#endif
+
+void process_disable_memory_mitigations() {
+    bool success = false;
+#ifdef __BIONIC__
+    // TODO(b/158870657) is fixed and scudo is used globally, we can assert when an
+    // an error is returned.
+
+    success = android_mallopt(M_DISABLE_MEMORY_MITIGATIONS, nullptr, 0);
+#endif
+
+    if (success) {
+        ALOGI("Disabled memory mitigations for process.");
+    } else {
+        ALOGE("Could not disable memory mitigations for process.");
+    }
+}
diff --git a/libcutils/memset_test.cpp b/libcutils/memset_test.cpp
deleted file mode 100644
index a98485f..0000000
--- a/libcutils/memset_test.cpp
+++ /dev/null
@@ -1,181 +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 <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-
-#include <memory>
-
-#include <cutils/memory.h>
-#include <gtest/gtest.h>
-
-#define FENCEPOST_LENGTH 8
-
-#define MAX_TEST_SIZE (64*1024)
-// Choose values that have no repeating byte values.
-#define MEMSET16_PATTERN 0xb139
-#define MEMSET32_PATTERN 0x48193a27
-
-enum test_e {
-  MEMSET16 = 0,
-  MEMSET32,
-};
-
-static int g_memset16_aligns[][2] = {
-  { 2, 0 },
-  { 4, 0 },
-  { 8, 0 },
-  { 16, 0 },
-  { 32, 0 },
-  { 64, 0 },
-  { 128, 0 },
-
-  { 4, 2 },
-
-  { 8, 2 },
-  { 8, 4 },
-  { 8, 6 },
-
-  { 128, 2 },
-  { 128, 4 },
-  { 128, 6 },
-  { 128, 8 },
-  { 128, 10 },
-  { 128, 12 },
-  { 128, 14 },
-  { 128, 16 },
-};
-
-static int g_memset32_aligns[][2] = {
-  { 4, 0 },
-  { 8, 0 },
-  { 16, 0 },
-  { 32, 0 },
-  { 64, 0 },
-  { 128, 0 },
-
-  { 8, 4 },
-
-  { 128, 4 },
-  { 128, 8 },
-  { 128, 12 },
-  { 128, 16 },
-};
-
-static size_t GetIncrement(size_t len, size_t min_incr) {
-  if (len >= 4096) {
-    return 1024;
-  } else if (len >= 1024) {
-    return 256;
-  }
-  return min_incr;
-}
-
-// Return a pointer into the current buffer with the specified alignment.
-static void *GetAlignedPtr(void *orig_ptr, int alignment, int or_mask) {
-  uint64_t ptr = reinterpret_cast<uint64_t>(orig_ptr);
-  if (alignment > 0) {
-      // When setting the alignment, set it to exactly the alignment chosen.
-      // The pointer returned will be guaranteed not to be aligned to anything
-      // more than that.
-      ptr += alignment - (ptr & (alignment - 1));
-      ptr |= alignment | or_mask;
-  }
-
-  return reinterpret_cast<void*>(ptr);
-}
-
-static void SetFencepost(uint8_t *buffer) {
-  for (int i = 0; i < FENCEPOST_LENGTH; i += 2) {
-    buffer[i] = 0xde;
-    buffer[i+1] = 0xad;
-  }
-}
-
-static void VerifyFencepost(uint8_t *buffer) {
-  for (int i = 0; i < FENCEPOST_LENGTH; i += 2) {
-    if (buffer[i] != 0xde || buffer[i+1] != 0xad) {
-      uint8_t expected_value;
-      if (buffer[i] == 0xde) {
-        i++;
-        expected_value = 0xad;
-      } else {
-        expected_value = 0xde;
-      }
-      ASSERT_EQ(expected_value, buffer[i]);
-    }
-  }
-}
-
-void RunMemsetTests(test_e test_type, uint32_t value, int align[][2], size_t num_aligns) {
-  size_t min_incr = 4;
-  if (test_type == MEMSET16) {
-    min_incr = 2;
-    value |= value << 16;
-  }
-  std::unique_ptr<uint32_t[]> expected_buf(new uint32_t[MAX_TEST_SIZE/sizeof(uint32_t)]);
-  for (size_t i = 0; i < MAX_TEST_SIZE/sizeof(uint32_t); i++) {
-    expected_buf[i] = value;
-  }
-
-  // Allocate one large buffer with lots of extra space so that we can
-  // guarantee that all possible alignments will fit.
-  std::unique_ptr<uint8_t[]> buf(new uint8_t[3*MAX_TEST_SIZE]);
-  uint8_t *buf_align;
-  for (size_t i = 0; i < num_aligns; i++) {
-    size_t incr = min_incr;
-    for (size_t len = incr; len <= MAX_TEST_SIZE; len += incr) {
-      incr = GetIncrement(len, min_incr);
-
-      buf_align = reinterpret_cast<uint8_t*>(GetAlignedPtr(
-          buf.get()+FENCEPOST_LENGTH, align[i][0], align[i][1]));
-
-      SetFencepost(&buf_align[-FENCEPOST_LENGTH]);
-      SetFencepost(&buf_align[len]);
-
-      memset(buf_align, 0xff, len);
-      if (test_type == MEMSET16) {
-        android_memset16(reinterpret_cast<uint16_t*>(buf_align), value, len);
-      } else {
-        android_memset32(reinterpret_cast<uint32_t*>(buf_align), value, len);
-      }
-      ASSERT_EQ(0, memcmp(expected_buf.get(), buf_align, len))
-          << "Failed size " << len << " align " << align[i][0] << " " << align[i][1] << "\n";
-
-      VerifyFencepost(&buf_align[-FENCEPOST_LENGTH]);
-      VerifyFencepost(&buf_align[len]);
-    }
-  }
-}
-
-TEST(libcutils, android_memset16_non_zero) {
-  RunMemsetTests(MEMSET16, MEMSET16_PATTERN, g_memset16_aligns, sizeof(g_memset16_aligns)/sizeof(int[2]));
-}
-
-TEST(libcutils, android_memset16_zero) {
-  RunMemsetTests(MEMSET16, 0, g_memset16_aligns, sizeof(g_memset16_aligns)/sizeof(int[2]));
-}
-
-TEST(libcutils, android_memset32_non_zero) {
-  RunMemsetTests(MEMSET32, MEMSET32_PATTERN, g_memset32_aligns, sizeof(g_memset32_aligns)/sizeof(int[2]));
-}
-
-TEST(libcutils, android_memset32_zero) {
-  RunMemsetTests(MEMSET32, 0, g_memset32_aligns, sizeof(g_memset32_aligns)/sizeof(int[2]));
-}
diff --git a/libcutils/trace-dev.cpp b/libcutils/trace-dev.cpp
index 5a09a2d..1ab63dc 100644
--- a/libcutils/trace-dev.cpp
+++ b/libcutils/trace-dev.cpp
@@ -30,9 +30,9 @@
 
 static void atrace_init_once()
 {
-    atrace_marker_fd = open("/sys/kernel/debug/tracing/trace_marker", O_WRONLY | O_CLOEXEC);
+    atrace_marker_fd = open("/sys/kernel/tracing/trace_marker", O_WRONLY | O_CLOEXEC);
     if (atrace_marker_fd == -1) {
-        atrace_marker_fd = open("/sys/kernel/tracing/trace_marker", O_WRONLY | O_CLOEXEC);
+        atrace_marker_fd = open("/sys/kernel/debug/tracing/trace_marker", O_WRONLY | O_CLOEXEC);
     }
 
     if (atrace_marker_fd == -1) {
diff --git a/libcutils/trace-dev.inc b/libcutils/trace-dev.inc
index 3ec98b3..6543426 100644
--- a/libcutils/trace-dev.inc
+++ b/libcutils/trace-dev.inc
@@ -198,7 +198,7 @@
 }
 
 #define WRITE_MSG(format_begin, format_end, name, value) { \
-    char buf[ATRACE_MESSAGE_LENGTH]; \
+    char buf[ATRACE_MESSAGE_LENGTH] __attribute__((uninitialized));     \
     int pid = getpid(); \
     int len = snprintf(buf, sizeof(buf), format_begin "%s" format_end, pid, \
         name, value); \
diff --git a/libcutils/uevent.cpp b/libcutils/uevent.cpp
index bf244d2..40bbd5c 100644
--- a/libcutils/uevent.cpp
+++ b/libcutils/uevent.cpp
@@ -101,7 +101,7 @@
 
     memset(&addr, 0, sizeof(addr));
     addr.nl_family = AF_NETLINK;
-    addr.nl_pid = getpid();
+    addr.nl_pid = 0;
     addr.nl_groups = 0xffffffff;
 
     s = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, NETLINK_KOBJECT_UEVENT);
diff --git a/liblog b/liblog
new file mode 120000
index 0000000..71443ae
--- /dev/null
+++ b/liblog
@@ -0,0 +1 @@
+../logging/liblog
\ No newline at end of file
diff --git a/liblog/Android.bp b/liblog/Android.bp
deleted file mode 100644
index 6051ac7..0000000
--- a/liblog/Android.bp
+++ /dev/null
@@ -1,154 +0,0 @@
-//
-// Copyright (C) 2008-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.
-//
-
-liblog_sources = [
-    "log_event_list.cpp",
-    "log_event_write.cpp",
-    "logger_name.cpp",
-    "logger_read.cpp",
-    "logger_write.cpp",
-    "logprint.cpp",
-    "properties.cpp",
-]
-liblog_target_sources = [
-    "event_tag_map.cpp",
-    "log_time.cpp",
-    "pmsg_reader.cpp",
-    "pmsg_writer.cpp",
-    "logd_reader.cpp",
-    "logd_writer.cpp",
-]
-
-cc_library_headers {
-    name: "liblog_headers",
-    host_supported: true,
-    vendor_available: true,
-    ramdisk_available: true,
-    recovery_available: true,
-    apex_available: [
-        "//apex_available:platform",
-        "//apex_available:anyapex",
-    ],
-    min_sdk_version: "29",
-    native_bridge_supported: true,
-    export_include_dirs: ["include"],
-    system_shared_libs: [],
-    stl: "none",
-    target: {
-        windows: {
-            enabled: true,
-        },
-        linux_bionic: {
-            enabled: true,
-        },
-        vendor: {
-            override_export_include_dirs: ["include_vndk"],
-        },
-    },
-}
-
-// Shared and static library for host and device
-// ========================================================
-cc_library {
-    name: "liblog",
-    host_supported: true,
-    ramdisk_available: true,
-    recovery_available: true,
-    native_bridge_supported: true,
-    srcs: liblog_sources,
-
-    target: {
-        android: {
-            version_script: "liblog.map.txt",
-            srcs: liblog_target_sources,
-            // AddressSanitizer runtime library depends on liblog.
-            sanitize: {
-                address: false,
-            },
-        },
-        android_arm: {
-            // TODO: This is to work around b/24465209. Remove after root cause is fixed
-            pack_relocations: false,
-            ldflags: ["-Wl,--hash-style=both"],
-        },
-        windows: {
-            enabled: true,
-        },
-        not_windows: {
-            srcs: ["event_tag_map.cpp"],
-        },
-        linux_bionic: {
-            enabled: true,
-        },
-    },
-
-    header_libs: [
-        "libbase_headers",
-        "liblog_headers",
-    ],
-    export_header_lib_headers: ["liblog_headers"],
-
-    stubs: {
-        symbol_file: "liblog.map.txt",
-        versions: ["29", "30"],
-    },
-
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wextra",
-        // This is what we want to do:
-        //  liblog_cflags := $(shell \
-        //   sed -n \
-        //       's/^\([0-9]*\)[ \t]*liblog[ \t].*/-DLIBLOG_LOG_TAG=\1/p' \
-        //       $(LOCAL_PATH)/event.logtags)
-        // so make sure we do not regret hard-coding it as follows:
-        "-DLIBLOG_LOG_TAG=1006",
-        "-DSNET_EVENT_LOG_TAG=1397638484",
-    ],
-    logtags: ["event.logtags"],
-    compile_multilib: "both",
-    apex_available: [
-        "//apex_available:platform",
-        // liblog is exceptionally available to the runtime APEX
-        // because the dynamic linker has to use it statically.
-        // See b/151051671
-        "com.android.runtime",
-        // DO NOT add more apex names here
-    ],
-}
-
-ndk_headers {
-    name: "liblog_ndk_headers",
-    from: "include/android",
-    to: "android",
-    srcs: ["include/android/log.h"],
-    license: "NOTICE",
-}
-
-ndk_library {
-    name: "liblog",
-    symbol_file: "liblog.map.txt",
-    first_version: "9",
-    unversioned_until: "current",
-}
-
-llndk_library {
-    name: "liblog",
-    native_bridge_supported: true,
-    symbol_file: "liblog.map.txt",
-    export_include_dirs: ["include_vndk"],
-}
diff --git a/liblog/NOTICE b/liblog/NOTICE
deleted file mode 100644
index 06a9081..0000000
--- a/liblog/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
-   Copyright (c) 2005-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.
-
-   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.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
diff --git a/liblog/OWNERS b/liblog/OWNERS
deleted file mode 100644
index babbe4d..0000000
--- a/liblog/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-tomcherry@google.com
diff --git a/liblog/README.md b/liblog/README.md
deleted file mode 100644
index 74a2cd7..0000000
--- a/liblog/README.md
+++ /dev/null
@@ -1,161 +0,0 @@
-Android liblog
---------------
-
-Public Functions and Macros
----------------------------
-
-    /*
-     * Please limit to 24 characters for runtime is loggable,
-     * 16 characters for persist is loggable, and logcat pretty
-     * alignment with limit of 7 characters.
-    */
-    #define LOG_TAG "yourtag"
-    #include <log/log.h>
-
-    ALOG(android_priority, tag, format, ...)
-    IF_ALOG(android_priority, tag)
-    LOG_PRI(priority, tag, format, ...)
-    LOG_PRI_VA(priority, tag, format, args)
-    #define LOG_TAG NULL
-    ALOGV(format, ...)
-    SLOGV(format, ...)
-    RLOGV(format, ...)
-    ALOGV_IF(cond, format, ...)
-    SLOGV_IF(cond, format, ...)
-    RLOGV_IF(cond, format, ...)
-    IF_ALOGC()
-    ALOGD(format, ...)
-    SLOGD(format, ...)
-    RLOGD(format, ...)
-    ALOGD_IF(cond, format, ...)
-    SLOGD_IF(cond, format, ...)
-    RLOGD_IF(cond, format, ...)
-    IF_ALOGD()
-    ALOGI(format, ...)
-    SLOGI(format, ...)
-    RLOGI(format, ...)
-    ALOGI_IF(cond, format, ...)
-    SLOGI_IF(cond, format, ...)
-    RLOGI_IF(cond, format, ...)
-    IF_ALOGI()
-    ALOGW(format, ...)
-    SLOGW(format, ...)
-    RLOGW(format, ...)
-    ALOGW_IF(cond, format, ...)
-    SLOGW_IF(cond, format, ...)
-    RLOGW_IF(cond, format, ...)
-    IF_ALOGW()
-    ALOGE(format, ...)
-    SLOGE(format, ...)
-    RLOGE(format, ...)
-    ALOGE_IF(cond, format, ...)
-    SLOGE_IF(cond, format, ...)
-    RLOGE_IF(cond, format, ...)
-    IF_ALOGE()
-    LOG_FATAL(format, ...)
-    LOG_ALWAYS_FATAL(format, ...)
-    LOG_FATAL_IF(cond, format, ...)
-    LOG_ALWAYS_FATAL_IF(cond, format, ...)
-    ALOG_ASSERT(cond, format, ...)
-    LOG_EVENT_INT(tag, value)
-    LOG_EVENT_LONG(tag, value)
-
-    log_id_t android_logger_get_id(struct logger *logger)
-    int android_logger_clear(struct logger *logger)
-    int android_logger_get_log_size(struct logger *logger)
-    int android_logger_get_log_readable_size(struct logger *logger)
-    int android_logger_get_log_version(struct logger *logger)
-
-    struct logger_list *android_logger_list_alloc(int mode, unsigned int tail, pid_t pid)
-    struct logger *android_logger_open(struct logger_list *logger_list, log_id_t id)
-    struct logger_list *android_logger_list_open(log_id_t id, int mode, unsigned int tail, pid_t pid)
-    int android_logger_list_read(struct logger_list *logger_list, struct log_msg *log_msg)
-    void android_logger_list_free(struct logger_list *logger_list)
-
-    log_id_t android_name_to_log_id(const char *logName)
-    const char *android_log_id_to_name(log_id_t log_id)
-
-    android_log_context create_android_logger(uint32_t tag)
-
-    int android_log_write_list_begin(android_log_context ctx)
-    int android_log_write_list_end(android_log_context ctx)
-
-    int android_log_write_int32(android_log_context ctx, int32_t value)
-    int android_log_write_int64(android_log_context ctx, int64_t value)
-    int android_log_write_string8(android_log_context ctx, const char *value)
-    int android_log_write_string8_len(android_log_context ctx, const char *value, size_t maxlen)
-    int android_log_write_float32(android_log_context ctx, float value)
-
-    int android_log_write_list(android_log_context ctx, log_id_t id = LOG_ID_EVENTS)
-
-    android_log_context create_android_log_parser(const char *msg, size_t len)
-    android_log_list_element android_log_read_next(android_log_context ctx)
-    android_log_list_element android_log_peek_next(android_log_context ctx)
-
-    int android_log_destroy(android_log_context *ctx)
-
-Description
------------
-
-liblog represents an interface to the volatile Android Logging system for NDK (Native) applications
-and libraries.  Interfaces for either writing or reading logs.  The log buffers are divided up in
-Main, System, Radio and Events sub-logs.
-
-The logging interfaces are a series of macros, all of which can be overridden individually in order
-to control the verbosity of the application or library.  `[ASR]LOG[VDIWE]` calls are used to log to
-BAsic, System or Radio sub-logs in either the Verbose, Debug, Info, Warning or Error priorities.
-`[ASR]LOG[VDIWE]_IF` calls are used to perform thus based on a condition being true.
-`IF_ALOG[VDIWE]` calls are true if the current `LOG_TAG` is enabled at the specified priority.
-`LOG_ALWAYS_FATAL` is used to `ALOG` a message, then kill the process.  `LOG_FATAL` call is a
-variant of `LOG_ALWAYS_FATAL`, only enabled in engineering, and not release builds.  `ALOG_ASSERT`
-is used to `ALOG` a message if the condition is false; the condition is part of the logged message.
-`LOG_EVENT_(INT|LONG)` is used to drop binary content into the Events sub-log.
-
-The log reading interfaces permit opening the logs either singly or multiply, retrieving a log entry
-at a time in time sorted order, optionally limited to a specific pid and tail of the log(s) and
-finally a call closing the logs.  A single log can be opened with `android_logger_list_open()`; or
-multiple logs can be opened with `android_logger_list_alloc()`, calling in turn the
-`android_logger_open()` for each log id.  Each entry can be retrieved with
-`android_logger_list_read()`.  The log(s) can be closed with `android_logger_list_free()`.
-`ANDROID_LOG_NONBLOCK` mode will report when the log reading is done with an `EAGAIN` error return
-code, otherwise the `android_logger_list_read()` call will block for new entries.
-
-The `ANDROID_LOG_WRAP` mode flag to the `android_logger_list_alloc_time()` signals logd to quiesce
-the reader until the buffer is about to prune at the start time then proceed to dumping content.
-
-The `ANDROID_LOG_PSTORE` mode flag to the `android_logger_open()` is used to switch from the active
-logs to the persistent logs from before the last reboot.
-
-The value returned by `android_logger_open()` can be used as a parameter to the
-`android_logger_clear()` function to empty the sub-log.
-
-The value returned by `android_logger_open()` can be used as a parameter to the
-`android_logger_get_log_(size|readable_size|version)` to retrieve the sub-log maximum size, readable
-size and log buffer format protocol version respectively.  `android_logger_get_id()` returns the id
-that was used when opening the sub-log.
-
-Errors
-------
-
-If messages fail, a negative error code will be returned to the caller.
-
-The `-ENOTCONN` return code indicates that the logger daemon is stopped.
-
-The `-EBADF` return code indicates that the log access point can not be opened, or the log buffer id
-is out of range.
-
-For the `-EAGAIN` return code, this means that the logging message was temporarily backed-up either
-because of Denial Of Service (DOS) logging pressure from some chatty application or service in the
-Android system, or if too small of a value is set in /proc/sys/net/unix/max_dgram_qlen.  To aid in
-diagnosing the occurence of this, a binary event from liblog will be sent to the log daemon once a
-new message can get through indicating how many messages were dropped as a result.  Please take
-action to resolve the structural problems at the source.
-
-It is generally not advised for the caller to retry the `-EAGAIN` return code as this will only make
-the problem(s) worse and cause your application to temporarily drop to the logger daemon priority,
-BATCH scheduling policy and background task cgroup. If you require a group of messages to be passed
-atomically, merge them into one message with embedded newlines to the maximum length
-`LOGGER_ENTRY_MAX_PAYLOAD`.
-
-Other return codes from writing operation can be returned.  Since the library retries on `EINTR`,
-`-EINTR` should never be returned.
diff --git a/liblog/README.protocol.md b/liblog/README.protocol.md
deleted file mode 100644
index f247b28..0000000
--- a/liblog/README.protocol.md
+++ /dev/null
@@ -1,92 +0,0 @@
-# liblog -> logd
-
-The data that liblog sends to logd is represented below.
-
-    struct {
-        android_log_header_t header;
-        union {
-           struct {
-                char     prio;
-                char     tag[...];
-                char     message[...];
-            } string;
-            struct {
-                android_event_header_t event_header;
-                android_event_*_t      payload[...];
-            } binary;
-        };
-    };
-
-where the embedded structs are defined as:
-
-    struct android_log_header_t {
-        uint8_t id;
-        uint16_t tid;
-        log_time realtime;
-    };
-
-    struct log_time {
-        uint32_t tv_sec = 0;
-        uint32_t tv_nsec = 0;
-    }
-
-    struct android_event_header_t {
-        int32_t tag;
-    };
-
-    struct android_event_list_t {
-        int8_t type;  // EVENT_TYPE_LIST
-        int8_t element_count;
-    };
-
-    struct android_event_float_t {
-        int8_t type;  // EVENT_TYPE_FLOAT
-        float data;
-    };
-
-    struct android_event_int_t {
-        int8_t type;   // EVENT_TYPE_INT
-        int32_t data;
-    } android_event_int_t;
-
-    struct android_event_long_t {
-        int8_t type;   // EVENT_TYPE_LONG
-        int64_t data;
-    };
-
-    struct android_event_string_t {
-        int8_t type;     // EVENT_TYPE_STRING;
-        int32_t length;
-        char data[];
-    };
-
-The payload, excluding the header, has a max size of LOGGER_ENTRY_MAX_PAYLOAD.
-
-## header
-
-The header is added immediately before sending the log message to logd.
-
-## `string` payload
-
-The `string` part of the union is for normal buffers (main, system, radio, etc) and consists of a
-single character priority, followed by a variable length null terminated string for the tag, and
-finally a variable length null terminated string for the message.
-
-This payload is used for the `__android_log_buf_write()` family of functions.
-
-## `binary` payload
-
-The `binary` part of the union is for binary buffers (events, security, etc) and consists of an
-android_event_header_t struct followed by a variable number of android_event_*_t
-(android_event_list_t, android_event_int_t, etc) structs.
-
-If multiple android_event_*_t elements are present, then they must be in a list and the first
-element in payload must be an android_event_list_t.
-
-This payload is used for the `__android_log_bwrite()` family of functions. It is additionally used
-for `android_log_write_list()` and the related functions that manipulate event lists.
-
-# logd -> liblog
-
-logd sends a `logger_entry` struct to liblog followed by the payload. The payload is identical to
-the payloads defined above. The max size of the entire message from logd is LOGGER_ENTRY_MAX_LEN.
diff --git a/liblog/event.logtags b/liblog/event.logtags
deleted file mode 100644
index 0a3b650..0000000
--- a/liblog/event.logtags
+++ /dev/null
@@ -1,37 +0,0 @@
-# The entries in this file map a sparse set of log tag numbers to tag names.
-# This is installed on the device, in /system/etc, and parsed by logcat.
-#
-# Tag numbers are decimal integers, from 0 to 2^31.  (Let's leave the
-# negative values alone for now.)
-#
-# Tag names are one or more ASCII letters and numbers or underscores, i.e.
-# "[A-Z][a-z][0-9]_".  Do not include spaces or punctuation (the former
-# impacts log readability, the latter makes regex searches more annoying).
-#
-# Tag numbers and names are separated by whitespace.  Blank lines and lines
-# starting with '#' are ignored.
-#
-# Optionally, after the tag names can be put a description for the value(s)
-# of the tag. Description are in the format
-#    (<name>|data type[|data unit])
-# Multiple values are separated by commas.
-#
-# The data type is a number from the following values:
-# 1: int
-# 2: long
-# 3: string
-# 4: list
-#
-# The data unit is a number taken from the following list:
-# 1: Number of objects
-# 2: Number of bytes
-# 3: Number of milliseconds
-# 4: Number of allocations
-# 5: Id
-# 6: Percent
-# s: Number of seconds (monotonic time)
-# Default value for data of type int/long is 2 (bytes).
-#
-# TODO: generate ".java" and ".h" files with integer constants from this file.
-
-1006  liblog (dropped|1)
diff --git a/liblog/event_tag_map.cpp b/liblog/event_tag_map.cpp
deleted file mode 100644
index 2c0156e..0000000
--- a/liblog/event_tag_map.cpp
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Copyright (C) 2007-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 <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-
-#include <functional>
-#include <string>
-#include <string_view>
-#include <unordered_map>
-
-#include <log/event_tag_map.h>
-#include <log/log_properties.h>
-#include <private/android_logger.h>
-#include <utils/FastStrcmp.h>
-#include <utils/RWLock.h>
-
-#include "logd_reader.h"
-
-#define OUT_TAG "EventTagMap"
-
-class MapString {
- private:
-  const std::string* alloc;                  // HAS-AN
-  const std::string_view str;                // HAS-A
-
- public:
-  operator const std::string_view() const {
-    return str;
-  }
-
-  const char* data() const {
-    return str.data();
-  }
-  size_t length() const {
-    return str.length();
-  }
-
-  bool operator==(const MapString& rval) const {
-    if (length() != rval.length()) return false;
-    if (length() == 0) return true;
-    return fastcmp<strncmp>(data(), rval.data(), length()) == 0;
-  }
-  bool operator!=(const MapString& rval) const {
-    return !(*this == rval);
-  }
-
-  MapString(const char* str, size_t len) : alloc(NULL), str(str, len) {
-  }
-  explicit MapString(const std::string& str)
-      : alloc(new std::string(str)), str(alloc->data(), alloc->length()) {
-  }
-  MapString(MapString&& rval) noexcept
-      : alloc(rval.alloc), str(rval.data(), rval.length()) {
-    rval.alloc = NULL;
-  }
-  explicit MapString(const MapString& rval)
-      : alloc(rval.alloc ? new std::string(*rval.alloc) : NULL),
-        str(alloc ? alloc->data() : rval.data(), rval.length()) {
-  }
-
-  ~MapString() {
-    if (alloc) delete alloc;
-  }
-};
-
-// Hash for MapString
-template <>
-struct std::hash<MapString>
-    : public std::unary_function<const MapString&, size_t> {
-  size_t operator()(const MapString& __t) const noexcept {
-    if (!__t.length()) return 0;
-    return std::hash<std::string_view>()(std::string_view(__t));
-  }
-};
-
-typedef std::pair<MapString, MapString> TagFmt;
-
-template <>
-struct std::hash<TagFmt> : public std::unary_function<const TagFmt&, size_t> {
-  size_t operator()(const TagFmt& __t) const noexcept {
-    // Tag is typically unique.  Will cost us an extra 100ns for the
-    // unordered_map lookup if we instead did a hash that combined
-    // both of tag and fmt members, e.g.:
-    //
-    // return std::hash<MapString>()(__t.first) ^
-    //        std::hash<MapString>()(__t.second);
-    return std::hash<MapString>()(__t.first);
-  }
-};
-
-// Map
-struct EventTagMap {
-#define NUM_MAPS 2
-  // memory-mapped source file; we get strings from here
-  void* mapAddr[NUM_MAPS];
-  size_t mapLen[NUM_MAPS];
-
- private:
-  std::unordered_map<uint32_t, TagFmt> Idx2TagFmt;
-  std::unordered_map<TagFmt, uint32_t> TagFmt2Idx;
-  std::unordered_map<MapString, uint32_t> Tag2Idx;
-  // protect unordered sets
-  android::RWLock rwlock;
-
- public:
-  EventTagMap() {
-    memset(mapAddr, 0, sizeof(mapAddr));
-    memset(mapLen, 0, sizeof(mapLen));
-  }
-
-  ~EventTagMap() {
-    Idx2TagFmt.clear();
-    TagFmt2Idx.clear();
-    Tag2Idx.clear();
-    for (size_t which = 0; which < NUM_MAPS; ++which) {
-      if (mapAddr[which]) {
-        munmap(mapAddr[which], mapLen[which]);
-        mapAddr[which] = 0;
-      }
-    }
-  }
-
-  bool emplaceUnique(uint32_t tag, const TagFmt& tagfmt, bool verbose = false);
-  const TagFmt* find(uint32_t tag) const;
-  int find(TagFmt&& tagfmt) const;
-  int find(MapString&& tag) const;
-};
-
-bool EventTagMap::emplaceUnique(uint32_t tag, const TagFmt& tagfmt,
-                                bool verbose) {
-  bool ret = true;
-  static const char errorFormat[] =
-      OUT_TAG ": duplicate tag entries %" PRIu32 ":%.*s:%.*s and %" PRIu32
-              ":%.*s:%.*s)\n";
-  android::RWLock::AutoWLock writeLock(rwlock);
-  {
-    std::unordered_map<uint32_t, TagFmt>::const_iterator it;
-    it = Idx2TagFmt.find(tag);
-    if (it != Idx2TagFmt.end()) {
-      if (verbose) {
-        fprintf(stderr, errorFormat, it->first, (int)it->second.first.length(),
-                it->second.first.data(), (int)it->second.second.length(),
-                it->second.second.data(), tag, (int)tagfmt.first.length(),
-                tagfmt.first.data(), (int)tagfmt.second.length(),
-                tagfmt.second.data());
-      }
-      ret = false;
-    } else {
-      Idx2TagFmt.emplace(std::make_pair(tag, tagfmt));
-    }
-  }
-
-  {
-    std::unordered_map<TagFmt, uint32_t>::const_iterator it;
-    it = TagFmt2Idx.find(tagfmt);
-    if (it != TagFmt2Idx.end()) {
-      if (verbose) {
-        fprintf(stderr, errorFormat, it->second, (int)it->first.first.length(),
-                it->first.first.data(), (int)it->first.second.length(),
-                it->first.second.data(), tag, (int)tagfmt.first.length(),
-                tagfmt.first.data(), (int)tagfmt.second.length(),
-                tagfmt.second.data());
-      }
-      ret = false;
-    } else {
-      TagFmt2Idx.emplace(std::make_pair(tagfmt, tag));
-    }
-  }
-
-  {
-    std::unordered_map<MapString, uint32_t>::const_iterator it;
-    it = Tag2Idx.find(tagfmt.first);
-    if (!tagfmt.second.length() && (it != Tag2Idx.end())) {
-      Tag2Idx.erase(it);
-      it = Tag2Idx.end();
-    }
-    if (it == Tag2Idx.end()) {
-      Tag2Idx.emplace(std::make_pair(tagfmt.first, tag));
-    }
-  }
-
-  return ret;
-}
-
-const TagFmt* EventTagMap::find(uint32_t tag) const {
-  std::unordered_map<uint32_t, TagFmt>::const_iterator it;
-  android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-  it = Idx2TagFmt.find(tag);
-  if (it == Idx2TagFmt.end()) return NULL;
-  return &(it->second);
-}
-
-int EventTagMap::find(TagFmt&& tagfmt) const {
-  std::unordered_map<TagFmt, uint32_t>::const_iterator it;
-  android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-  it = TagFmt2Idx.find(std::move(tagfmt));
-  if (it == TagFmt2Idx.end()) return -1;
-  return it->second;
-}
-
-int EventTagMap::find(MapString&& tag) const {
-  std::unordered_map<MapString, uint32_t>::const_iterator it;
-  android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-  it = Tag2Idx.find(std::move(tag));
-  if (it == Tag2Idx.end()) return -1;
-  return it->second;
-}
-
-// The position after the end of a valid section of the tag string,
-// caller makes sure delimited appropriately.
-static const char* endOfTag(const char* cp) {
-  while (*cp && (isalnum(*cp) || strchr("_.-@,", *cp))) ++cp;
-  return cp;
-}
-
-// Scan one tag line.
-//
-// "pData" should be pointing to the first digit in the tag number.  On
-// successful return, it will be pointing to the last character in the
-// tag line (i.e. the character before the start of the next line).
-//
-// lineNum = 0 removes verbose comments and requires us to cache the
-// content rather than make direct raw references since the content
-// will disappear after the call. A non-zero lineNum means we own the
-// data and it will outlive the call.
-//
-// Returns 0 on success, nonzero on failure.
-static int scanTagLine(EventTagMap* map, const char*& pData, int lineNum) {
-  char* ep;
-  unsigned long val = strtoul(pData, &ep, 10);
-  const char* cp = ep;
-  if (cp == pData) {
-    if (lineNum) {
-      fprintf(stderr, OUT_TAG ": malformed tag number on line %d\n", lineNum);
-    }
-    errno = EINVAL;
-    return -1;
-  }
-
-  uint32_t tagIndex = val;
-  if (tagIndex != val) {
-    if (lineNum) {
-      fprintf(stderr, OUT_TAG ": tag number too large on line %d\n", lineNum);
-    }
-    errno = ERANGE;
-    return -1;
-  }
-
-  while ((*++cp != '\n') && isspace(*cp)) {
-  }
-
-  if (*cp == '\n') {
-    if (lineNum) {
-      fprintf(stderr, OUT_TAG ": missing tag string on line %d\n", lineNum);
-    }
-    errno = EINVAL;
-    return -1;
-  }
-
-  const char* tag = cp;
-  cp = endOfTag(cp);
-  size_t tagLen = cp - tag;
-
-  if (!isspace(*cp)) {
-    if (lineNum) {
-      fprintf(stderr, OUT_TAG ": invalid tag char %c on line %d\n", *cp,
-              lineNum);
-    }
-    errno = EINVAL;
-    return -1;
-  }
-
-  while (isspace(*cp) && (*cp != '\n')) ++cp;
-  const char* fmt = NULL;
-  size_t fmtLen = 0;
-  if (*cp && (*cp != '#')) {
-    fmt = cp;
-    while (*cp && (*cp != '\n') && (*cp != '#')) ++cp;
-    while ((cp > fmt) && isspace(*(cp - 1))) --cp;
-    fmtLen = cp - fmt;
-  }
-
-  // KISS Only report identicals if they are global
-  // Ideally we want to check if there are identicals
-  // recorded for the same uid, but recording that
-  // unused detail in our database is too burdensome.
-  bool verbose = true;
-  while (*cp && (*cp != '#') && (*cp != '\n')) ++cp;
-  if (*cp == '#') {
-    do {
-      ++cp;
-    } while (isspace(*cp) && (*cp != '\n'));
-    verbose = !!fastcmp<strncmp>(cp, "uid=", strlen("uid="));
-  }
-
-  while (*cp && (*cp != '\n')) ++cp;
-#ifdef DEBUG
-  fprintf(stderr, "%d: %p: %.*s\n", lineNum, tag, (int)(cp - pData), pData);
-#endif
-  pData = cp;
-
-  if (lineNum) {
-    if (map->emplaceUnique(tagIndex,
-                           TagFmt(std::make_pair(MapString(tag, tagLen),
-                                                 MapString(fmt, fmtLen))),
-                           verbose)) {
-      return 0;
-    }
-  } else {
-    // cache
-    if (map->emplaceUnique(
-            tagIndex,
-            TagFmt(std::make_pair(MapString(std::string(tag, tagLen)),
-                                  MapString(std::string(fmt, fmtLen)))))) {
-      return 0;
-    }
-  }
-  errno = EMLINK;
-  return -1;
-}
-
-static const char* eventTagFiles[NUM_MAPS] = {
-  EVENT_TAG_MAP_FILE, "/dev/event-log-tags",
-};
-
-// Parse the tags out of the file.
-static int parseMapLines(EventTagMap* map, size_t which) {
-  const char* cp = static_cast<char*>(map->mapAddr[which]);
-  size_t len = map->mapLen[which];
-  const char* endp = cp + len;
-
-  // insist on EOL at EOF; simplifies parsing and null-termination
-  if (!len || (*(endp - 1) != '\n')) {
-#ifdef DEBUG
-    fprintf(stderr, OUT_TAG ": map file %zu[%zu] missing EOL on last line\n",
-            which, len);
-#endif
-    if (which) {  // do not propagate errors for other files
-      return 0;
-    }
-    errno = EINVAL;
-    return -1;
-  }
-
-  bool lineStart = true;
-  int lineNum = 1;
-  while (cp < endp) {
-    if (*cp == '\n') {
-      lineStart = true;
-      lineNum++;
-    } else if (lineStart) {
-      if (*cp == '#') {
-        // comment; just scan to end
-        lineStart = false;
-      } else if (isdigit(*cp)) {
-        // looks like a tag; scan it out
-        if (scanTagLine(map, cp, lineNum) != 0) {
-          if (!which || (errno != EMLINK)) {
-            return -1;
-          }
-        }
-        lineNum++;  // we eat the '\n'
-                    // leave lineStart==true
-      } else if (isspace(*cp)) {
-        // looks like leading whitespace; keep scanning
-      } else {
-        fprintf(stderr,
-                OUT_TAG
-                ": unexpected chars (0x%02x) in tag number on line %d\n",
-                *cp, lineNum);
-        errno = EINVAL;
-        return -1;
-      }
-    } else {
-      // this is a blank or comment line
-    }
-    cp++;
-  }
-
-  return 0;
-}
-
-// Open the map file and allocate a structure to manage it.
-//
-// We create a private mapping because we want to terminate the log tag
-// strings with '\0'.
-EventTagMap* android_openEventTagMap(const char* fileName) {
-  EventTagMap* newTagMap;
-  off_t end[NUM_MAPS];
-  int save_errno, fd[NUM_MAPS];
-  size_t which;
-
-  memset(fd, -1, sizeof(fd));
-  memset(end, 0, sizeof(end));
-
-  for (which = 0; which < NUM_MAPS; ++which) {
-    const char* tagfile = fileName ? fileName : eventTagFiles[which];
-
-    fd[which] = open(tagfile, O_RDONLY | O_CLOEXEC);
-    if (fd[which] < 0) {
-      if (!which) {
-        save_errno = errno;
-        fprintf(stderr, OUT_TAG ": unable to open map '%s': %s\n", tagfile,
-                strerror(save_errno));
-        goto fail_errno;
-      }
-      continue;
-    }
-    end[which] = lseek(fd[which], 0L, SEEK_END);
-    save_errno = errno;
-    (void)lseek(fd[which], 0L, SEEK_SET);
-    if (!which && (end[0] < 0)) {
-      fprintf(stderr, OUT_TAG ": unable to seek map '%s' %s\n", tagfile,
-              strerror(save_errno));
-      goto fail_close;
-    }
-    if (fileName) break;  // Only allow one as specified
-  }
-
-  newTagMap = new EventTagMap;
-  if (newTagMap == NULL) {
-    save_errno = errno;
-    goto fail_close;
-  }
-
-  for (which = 0; which < NUM_MAPS; ++which) {
-    if (fd[which] >= 0) {
-      newTagMap->mapAddr[which] =
-          mmap(NULL, end[which], which ? PROT_READ : PROT_READ | PROT_WRITE,
-               which ? MAP_SHARED : MAP_PRIVATE, fd[which], 0);
-      save_errno = errno;
-      close(fd[which]); /* fd DONE */
-      fd[which] = -1;
-      if ((newTagMap->mapAddr[which] != MAP_FAILED) &&
-          (newTagMap->mapAddr[which] != NULL)) {
-        newTagMap->mapLen[which] = end[which];
-      } else if (!which) {
-        const char* tagfile = fileName ? fileName : eventTagFiles[which];
-
-        fprintf(stderr, OUT_TAG ": mmap(%s) failed: %s\n", tagfile,
-                strerror(save_errno));
-        goto fail_unmap;
-      }
-    }
-  }
-
-  for (which = 0; which < NUM_MAPS; ++which) {
-    if (parseMapLines(newTagMap, which) != 0) {
-      delete newTagMap;
-      return NULL;
-    }
-    /* See 'fd DONE' comments above and below, no need to clean up here */
-  }
-
-  return newTagMap;
-
-fail_unmap:
-  save_errno = EINVAL;
-  delete newTagMap;
-fail_close:
-  for (which = 0; which < NUM_MAPS; ++which) close(fd[which]); /* fd DONE */
-fail_errno:
-  errno = save_errno;
-  return NULL;
-}
-
-// Close the map.
-void android_closeEventTagMap(EventTagMap* map) {
-  if (map) delete map;
-}
-
-// Cache miss, go to logd to acquire a public reference.
-// Because we lack access to a SHARED PUBLIC /dev/event-log-tags file map?
-static const TagFmt* __getEventTag([[maybe_unused]] EventTagMap* map, unsigned int tag) {
-  // call event tag service to arrange for a new tag
-  char* buf = NULL;
-  // Can not use android::base::StringPrintf, asprintf + free instead.
-  static const char command_template[] = "getEventTag id=%u";
-  int ret = asprintf(&buf, command_template, tag);
-  if (ret > 0) {
-    // Add some buffer margin for an estimate of the full return content.
-    size_t size =
-        ret - strlen(command_template) +
-        strlen("65535\n4294967295\t?\t\t\t?\t# uid=32767\n\n\f?success?");
-    if (size > (size_t)ret) {
-      char* np = static_cast<char*>(realloc(buf, size));
-      if (np) {
-        buf = np;
-      } else {
-        size = ret;
-      }
-    } else {
-      size = ret;
-    }
-#ifdef __ANDROID__
-    // Ask event log tag service for an existing entry
-    if (SendLogdControlMessage(buf, size) >= 0) {
-      buf[size - 1] = '\0';
-      char* ep;
-      unsigned long val = strtoul(buf, &ep, 10);  // return size
-      const char* cp = ep;
-      if ((buf != cp) && (val > 0) && (*cp == '\n')) {  // truncation OK
-        ++cp;
-        if (!scanTagLine(map, cp, 0)) {
-          free(buf);
-          return map->find(tag);
-        }
-      }
-    }
-#endif
-    free(buf);
-  }
-  return NULL;
-}
-
-// Look up an entry in the map.
-const char* android_lookupEventTag_len(const EventTagMap* map, size_t* len, unsigned int tag) {
-  if (len) *len = 0;
-  const TagFmt* str = map->find(tag);
-  if (!str) {
-    str = __getEventTag(const_cast<EventTagMap*>(map), tag);
-  }
-  if (!str) return NULL;
-  if (len) *len = str->first.length();
-  return str->first.data();
-}
-
-// Look up an entry in the map.
-const char* android_lookupEventFormat_len(const EventTagMap* map, size_t* len, unsigned int tag) {
-  if (len) *len = 0;
-  const TagFmt* str = map->find(tag);
-  if (!str) {
-    str = __getEventTag(const_cast<EventTagMap*>(map), tag);
-  }
-  if (!str) return NULL;
-  if (len) *len = str->second.length();
-  return str->second.data();
-}
-
-// Look up tagname, generate one if necessary, and return a tag
-int android_lookupEventTagNum(EventTagMap* map, const char* tagname, const char* format, int prio) {
-  const char* ep = endOfTag(tagname);
-  size_t len = ep - tagname;
-  if (!len || *ep) {
-    errno = EINVAL;
-    return -1;
-  }
-
-  if ((prio != ANDROID_LOG_UNKNOWN) && (prio < ANDROID_LOG_SILENT) &&
-      !__android_log_is_loggable_len(prio, tagname, len,
-                                     __android_log_is_debuggable()
-                                         ? ANDROID_LOG_VERBOSE
-                                         : ANDROID_LOG_DEBUG)) {
-    errno = EPERM;
-    return -1;
-  }
-
-  if (!format) format = "";
-  ssize_t fmtLen = strlen(format);
-  int ret = map->find(TagFmt(
-      std::make_pair(MapString(tagname, len), MapString(format, fmtLen))));
-  if (ret != -1) return ret;
-
-  // call event tag service to arrange for a new tag
-  char* buf = NULL;
-  // Can not use android::base::StringPrintf, asprintf + free instead.
-  static const char command_template[] = "getEventTag name=%s format=\"%s\"";
-  ret = asprintf(&buf, command_template, tagname, format);
-  if (ret > 0) {
-    // Add some buffer margin for an estimate of the full return content.
-    char* cp;
-    size_t size =
-        ret - strlen(command_template) +
-        strlen("65535\n4294967295\t?\t\t\t?\t# uid=32767\n\n\f?success?");
-    if (size > (size_t)ret) {
-      cp = static_cast<char*>(realloc(buf, size));
-      if (cp) {
-        buf = cp;
-      } else {
-        size = ret;
-      }
-    } else {
-      size = ret;
-    }
-#ifdef __ANDROID__
-    // Ask event log tag service for an allocation
-    if (SendLogdControlMessage(buf, size) >= 0) {
-      buf[size - 1] = '\0';
-      unsigned long val = strtoul(buf, &cp, 10);        // return size
-      if ((buf != cp) && (val > 0) && (*cp == '\n')) {  // truncation OK
-        val = strtoul(cp + 1, &cp, 10);                 // allocated tag number
-        if ((val > 0) && (val < UINT32_MAX) && (*cp == '\t')) {
-          free(buf);
-          ret = val;
-          // cache
-          map->emplaceUnique(ret, TagFmt(std::make_pair(
-                                      MapString(std::string(tagname, len)),
-                                      MapString(std::string(format, fmtLen)))));
-          return ret;
-        }
-      }
-    }
-#endif
-    free(buf);
-  }
-
-  // Hail Mary
-  ret = map->find(MapString(tagname, len));
-  if (ret == -1) errno = ESRCH;
-  return ret;
-}
diff --git a/liblog/include/android/log.h b/liblog/include/android/log.h
deleted file mode 100644
index 8a0ebf2..0000000
--- a/liblog/include/android/log.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright (C) 2009 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
-
-/**
- * @addtogroup Logging
- * @{
- */
-
-/**
- * \file
- *
- * Support routines to send messages to the Android log buffer,
- * which can later be accessed through the `logcat` utility.
- *
- * Each log message must have
- *   - a priority
- *   - a log tag
- *   - some text
- *
- * The tag normally corresponds to the component that emits the log message,
- * and should be reasonably small.
- *
- * Log message text may be truncated to less than an implementation-specific
- * limit (1023 bytes).
- *
- * Note that a newline character ("\n") will be appended automatically to your
- * log message, if not already there. It is not possible to send several
- * messages and have them appear on a single line in logcat.
- *
- * Please use logging in moderation:
- *
- *  - Sending log messages eats CPU and slow down your application and the
- *    system.
- *
- *  - The circular log buffer is pretty small, so sending many messages
- *    will hide other important log messages.
- *
- *  - In release builds, only send log messages to account for exceptional
- *    conditions.
- */
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/cdefs.h>
-
-#if !defined(__BIONIC__) && !defined(__INTRODUCED_IN)
-#define __INTRODUCED_IN(x)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Android log priority values, in increasing order of priority.
- */
-typedef enum android_LogPriority {
-  /** For internal use only.  */
-  ANDROID_LOG_UNKNOWN = 0,
-  /** The default priority, for internal use only.  */
-  ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
-  /** Verbose logging. Should typically be disabled for a release apk. */
-  ANDROID_LOG_VERBOSE,
-  /** Debug logging. Should typically be disabled for a release apk. */
-  ANDROID_LOG_DEBUG,
-  /** Informational logging. Should typically be disabled for a release apk. */
-  ANDROID_LOG_INFO,
-  /** Warning logging. For use with recoverable failures. */
-  ANDROID_LOG_WARN,
-  /** Error logging. For use with unrecoverable failures. */
-  ANDROID_LOG_ERROR,
-  /** Fatal logging. For use when aborting. */
-  ANDROID_LOG_FATAL,
-  /** For internal use only.  */
-  ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
-} android_LogPriority;
-
-/**
- * Writes the constant string `text` to the log, with priority `prio` and tag
- * `tag`.
- */
-int __android_log_write(int prio, const char* tag, const char* text);
-
-/**
- * Writes a formatted string to the log, with priority `prio` and tag `tag`.
- * The details of formatting are the same as for
- * [printf(3)](http://man7.org/linux/man-pages/man3/printf.3.html).
- */
-int __android_log_print(int prio, const char* tag, const char* fmt, ...)
-    __attribute__((__format__(printf, 3, 4)));
-
-/**
- * Equivalent to `__android_log_print`, but taking a `va_list`.
- * (If `__android_log_print` is like `printf`, this is like `vprintf`.)
- */
-int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
-    __attribute__((__format__(printf, 3, 0)));
-
-/**
- * Writes an assertion failure to the log (as `ANDROID_LOG_FATAL`) and to
- * stderr, before calling
- * [abort(3)](http://man7.org/linux/man-pages/man3/abort.3.html).
- *
- * If `fmt` is non-null, `cond` is unused. If `fmt` is null, the string
- * `Assertion failed: %s` is used with `cond` as the string argument.
- * If both `fmt` and `cond` are null, a default string is provided.
- *
- * Most callers should use
- * [assert(3)](http://man7.org/linux/man-pages/man3/assert.3.html) from
- * `&lt;assert.h&gt;` instead, or the `__assert` and `__assert2` functions
- * provided by bionic if more control is needed. They support automatically
- * including the source filename and line number more conveniently than this
- * function.
- */
-void __android_log_assert(const char* cond, const char* tag, const char* fmt, ...)
-    __attribute__((__noreturn__)) __attribute__((__format__(printf, 3, 4)));
-
-/**
- * Identifies a specific log buffer for __android_log_buf_write()
- * and __android_log_buf_print().
- */
-typedef enum log_id {
-  LOG_ID_MIN = 0,
-
-  /** The main log buffer. This is the only log buffer available to apps. */
-  LOG_ID_MAIN = 0,
-  /** The radio log buffer. */
-  LOG_ID_RADIO = 1,
-  /** The event log buffer. */
-  LOG_ID_EVENTS = 2,
-  /** The system log buffer. */
-  LOG_ID_SYSTEM = 3,
-  /** The crash log buffer. */
-  LOG_ID_CRASH = 4,
-  /** The statistics log buffer. */
-  LOG_ID_STATS = 5,
-  /** The security log buffer. */
-  LOG_ID_SECURITY = 6,
-  /** The kernel log buffer. */
-  LOG_ID_KERNEL = 7,
-
-  LOG_ID_MAX,
-
-  /** Let the logging function choose the best log target. */
-  LOG_ID_DEFAULT = 0x7FFFFFFF
-} log_id_t;
-
-/**
- * Writes the constant string `text` to the log buffer `id`,
- * with priority `prio` and tag `tag`.
- *
- * Apps should use __android_log_write() instead.
- */
-int __android_log_buf_write(int bufID, int prio, const char* tag, const char* text);
-
-/**
- * Writes a formatted string to log buffer `id`,
- * with priority `prio` and tag `tag`.
- * The details of formatting are the same as for
- * [printf(3)](http://man7.org/linux/man-pages/man3/printf.3.html).
- *
- * Apps should use __android_log_print() instead.
- */
-int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fmt, ...)
-    __attribute__((__format__(printf, 4, 5)));
-
-/**
- * Logger data struct used for writing log messages to liblog via __android_log_write_logger_data()
- * and sending log messages to user defined loggers specified in __android_log_set_logger().
- */
-struct __android_log_message {
-  /** Must be set to sizeof(__android_log_message) and is used for versioning. */
-  size_t struct_size;
-
-  /** {@link log_id_t} values. */
-  int32_t buffer_id;
-
-  /** {@link android_LogPriority} values. */
-  int32_t priority;
-
-  /** The tag for the log message. */
-  const char* tag;
-
-  /** Optional file name, may be set to nullptr. */
-  const char* file;
-
-  /** Optional line number, ignore if file is nullptr. */
-  uint32_t line;
-
-  /** The log message itself. */
-  const char* message;
-};
-
-/**
- * Prototype for the 'logger' function that is called for every log message.
- */
-typedef void (*__android_logger_function)(const struct __android_log_message* log_message);
-/**
- * Prototype for the 'abort' function that is called when liblog will abort due to
- * __android_log_assert() failures.
- */
-typedef void (*__android_aborter_function)(const char* abort_message);
-
-#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
-/**
- * Writes the log message specified by log_message.  log_message includes additional file name and
- * line number information that a logger may use.  log_message is versioned for backwards
- * compatibility.
- * This assumes that loggability has already been checked through __android_log_is_loggable().
- * Higher level logging libraries, such as libbase, first check loggability, then format their
- * buffers, then pass the message to liblog via this function, and therefore we do not want to
- * duplicate the loggability check here.
- *
- * @param log_message the log message itself, see __android_log_message.
- *
- * Available since API level 30.
- */
-void __android_log_write_log_message(struct __android_log_message* log_message) __INTRODUCED_IN(30);
-
-/**
- * Sets a user defined logger function.  All log messages sent to liblog will be set to the
- * function pointer specified by logger for processing.  It is not expected that log messages are
- * already terminated with a new line.  This function should add new lines if required for line
- * separation.
- *
- * @param logger the new function that will handle log messages.
- *
- * Available since API level 30.
- */
-void __android_log_set_logger(__android_logger_function logger) __INTRODUCED_IN(30);
-
-/**
- * Writes the log message to logd.  This is an __android_logger_function and can be provided to
- * __android_log_set_logger().  It is the default logger when running liblog on a device.
- *
- * @param log_message the log message to write, see __android_log_message.
- *
- * Available since API level 30.
- */
-void __android_log_logd_logger(const struct __android_log_message* log_message) __INTRODUCED_IN(30);
-
-/**
- * Writes the log message to stderr.  This is an __android_logger_function and can be provided to
- * __android_log_set_logger().  It is the default logger when running liblog on host.
- *
- * @param log_message the log message to write, see __android_log_message.
- *
- * Available since API level 30.
- */
-void __android_log_stderr_logger(const struct __android_log_message* log_message)
-    __INTRODUCED_IN(30);
-
-/**
- * Sets a user defined aborter function that is called for __android_log_assert() failures.  This
- * user defined aborter function is highly recommended to abort and be noreturn, but is not strictly
- * required to.
- *
- * @param aborter the new aborter function, see __android_aborter_function.
- *
- * Available since API level 30.
- */
-void __android_log_set_aborter(__android_aborter_function aborter) __INTRODUCED_IN(30);
-
-/**
- * Calls the stored aborter function.  This allows for other logging libraries to use the same
- * aborter function by calling this function in liblog.
- *
- * @param abort_message an additional message supplied when aborting, for example this is used to
- *                      call android_set_abort_message() in __android_log_default_aborter().
- *
- * Available since API level 30.
- */
-void __android_log_call_aborter(const char* abort_message) __INTRODUCED_IN(30);
-
-/**
- * Sets android_set_abort_message() on device then aborts().  This is the default aborter.
- *
- * @param abort_message an additional message supplied when aborting.  This functions calls
- *                      android_set_abort_message() with its contents.
- *
- * Available since API level 30.
- */
-void __android_log_default_aborter(const char* abort_message) __attribute__((noreturn))
-__INTRODUCED_IN(30);
-
-/**
- * Use the per-tag properties "log.tag.<tagname>" along with the minimum priority from
- * __android_log_set_minimum_priority() to determine if a log message with a given prio and tag will
- * be printed.  A non-zero result indicates yes, zero indicates false.
- *
- * If both a priority for a tag and a minimum priority are set by
- * __android_log_set_minimum_priority(), then the lowest of the two values are to determine the
- * minimum priority needed to log.  If only one is set, then that value is used to determine the
- * minimum priority needed.  If none are set, then default_priority is used.
- *
- * @param prio         the priority to test, takes android_LogPriority values.
- * @param tag          the tag to test.
- * @param default_prio the default priority to use if no properties or minimum priority are set.
- * @return an integer where 1 indicates that the message is loggable and 0 indicates that it is not.
- *
- * Available since API level 30.
- */
-int __android_log_is_loggable(int prio, const char* tag, int default_prio) __INTRODUCED_IN(30);
-
-/**
- * Use the per-tag properties "log.tag.<tagname>" along with the minimum priority from
- * __android_log_set_minimum_priority() to determine if a log message with a given prio and tag will
- * be printed.  A non-zero result indicates yes, zero indicates false.
- *
- * If both a priority for a tag and a minimum priority are set by
- * __android_log_set_minimum_priority(), then the lowest of the two values are to determine the
- * minimum priority needed to log.  If only one is set, then that value is used to determine the
- * minimum priority needed.  If none are set, then default_priority is used.
- *
- * @param prio         the priority to test, takes android_LogPriority values.
- * @param tag          the tag to test.
- * @param len          the length of the tag.
- * @param default_prio the default priority to use if no properties or minimum priority are set.
- * @return an integer where 1 indicates that the message is loggable and 0 indicates that it is not.
- *
- * Available since API level 30.
- */
-int __android_log_is_loggable_len(int prio, const char* tag, size_t len, int default_prio)
-    __INTRODUCED_IN(30);
-
-/**
- * Sets the minimum priority that will be logged for this process.
- *
- * @param priority the new minimum priority to set, takes android_LogPriority values.
- * @return the previous set minimum priority as android_LogPriority values, or
- *         ANDROID_LOG_DEFAULT if none was set.
- *
- * Available since API level 30.
- */
-int32_t __android_log_set_minimum_priority(int32_t priority) __INTRODUCED_IN(30);
-
-/**
- * Gets the minimum priority that will be logged for this process.  If none has been set by a
- * previous __android_log_set_minimum_priority() call, this returns ANDROID_LOG_DEFAULT.
- *
- * @return the current minimum priority as android_LogPriority values, or
- *         ANDROID_LOG_DEFAULT if none is set.
- *
- * Available since API level 30.
- */
-int32_t __android_log_get_minimum_priority(void) __INTRODUCED_IN(30);
-
-/**
- * Sets the default tag if no tag is provided when writing a log message.  Defaults to
- * getprogname().  This truncates tag to the maximum log message size, though appropriate tags
- * should be much smaller.
- *
- * @param tag the new log tag.
- *
- * Available since API level 30.
- */
-void __android_log_set_default_tag(const char* tag) __INTRODUCED_IN(30);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/** @} */
diff --git a/liblog/include/log/event_tag_map.h b/liblog/include/log/event_tag_map.h
deleted file mode 100644
index 4d0ebf9..0000000
--- a/liblog/include/log/event_tag_map.h
+++ /dev/null
@@ -1,64 +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.
- */
-
-#pragma once
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags"
-
-struct EventTagMap;
-typedef struct EventTagMap EventTagMap;
-
-/*
- * Open the specified file as an event log tag map.
- *
- * Returns NULL on failure.
- */
-EventTagMap* android_openEventTagMap(const char* fileName);
-
-/*
- * Close the map.
- */
-void android_closeEventTagMap(EventTagMap* map);
-
-/*
- * Look up a tag by index.  Returns the tag string & string length, or NULL if
- * not found.  Returned string is not guaranteed to be nul terminated.
- */
-const char* android_lookupEventTag_len(const EventTagMap* map, size_t* len,
-                                       unsigned int tag);
-
-/*
- * Look up a format by index. Returns the format string & string length,
- * or NULL if not found. Returned string is not guaranteed to be nul terminated.
- */
-const char* android_lookupEventFormat_len(const EventTagMap* map, size_t* len,
-                                          unsigned int tag);
-
-/*
- * Look up tagname, generate one if necessary, and return a tag
- */
-int android_lookupEventTagNum(EventTagMap* map, const char* tagname,
-                              const char* format, int prio);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/log/log.h b/liblog/include/log/log.h
deleted file mode 100644
index d7e9b7d..0000000
--- a/liblog/include/log/log.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2005-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.
- */
-
-#pragma once
-
-/* Too many in the ecosystem assume these are included */
-#if !defined(_WIN32)
-#include <pthread.h>
-#endif
-#include <stdint.h> /* uint16_t, int32_t */
-#include <stdio.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <android/log.h>
-#include <log/log_id.h>
-#include <log/log_main.h>
-#include <log/log_radio.h>
-#include <log/log_safetynet.h>
-#include <log/log_system.h>
-#include <log/log_time.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * LOG_TAG is the local tag used for the following simplified
- * logging macros.  You can change this preprocessor definition
- * before using the other macros to change the tag.
- */
-
-#ifndef LOG_TAG
-#define LOG_TAG NULL
-#endif
-
-/*
- * Normally we strip the effects of ALOGV (VERBOSE messages),
- * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
- * release builds be defining NDEBUG.  You can modify this (for
- * example with "#define LOG_NDEBUG 0" at the top of your source
- * file) to change that behavior.
- */
-
-#ifndef LOG_NDEBUG
-#ifdef NDEBUG
-#define LOG_NDEBUG 1
-#else
-#define LOG_NDEBUG 0
-#endif
-#endif
-
-/*
- * The maximum size of the log entry payload that can be
- * written to the logger. An attempt to write more than
- * this amount will result in a truncated log entry.
- */
-#define LOGGER_ENTRY_MAX_PAYLOAD 4068
-
-/*
- * Event logging.
- */
-
-/*
- * The following should not be used directly.
- */
-
-int __android_log_bwrite(int32_t tag, const void* payload, size_t len);
-int __android_log_btwrite(int32_t tag, char type, const void* payload,
-                          size_t len);
-int __android_log_bswrite(int32_t tag, const char* payload);
-
-int __android_log_stats_bwrite(int32_t tag, const void* payload, size_t len);
-
-#define android_bWriteLog(tag, payload, len) \
-  __android_log_bwrite(tag, payload, len)
-#define android_btWriteLog(tag, type, payload, len) \
-  __android_log_btwrite(tag, type, payload, len)
-
-/*
- * Event log entry types.
- */
-typedef enum {
-  /* Special markers for android_log_list_element type */
-  EVENT_TYPE_LIST_STOP = '\n', /* declare end of list  */
-  EVENT_TYPE_UNKNOWN = '?',    /* protocol error       */
-
-  /* must match with declaration in java/android/android/util/EventLog.java */
-  EVENT_TYPE_INT = 0,  /* int32_t */
-  EVENT_TYPE_LONG = 1, /* int64_t */
-  EVENT_TYPE_STRING = 2,
-  EVENT_TYPE_LIST = 3,
-  EVENT_TYPE_FLOAT = 4,
-} AndroidEventLogType;
-
-#ifndef LOG_EVENT_INT
-#define LOG_EVENT_INT(_tag, _value)                                          \
-  {                                                                          \
-    int intBuf = _value;                                                     \
-    (void)android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)); \
-  }
-#endif
-#ifndef LOG_EVENT_LONG
-#define LOG_EVENT_LONG(_tag, _value)                                            \
-  {                                                                             \
-    long long longBuf = _value;                                                 \
-    (void)android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, sizeof(longBuf)); \
-  }
-#endif
-#ifndef LOG_EVENT_FLOAT
-#define LOG_EVENT_FLOAT(_tag, _value)                           \
-  {                                                             \
-    float floatBuf = _value;                                    \
-    (void)android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \
-                             sizeof(floatBuf));                 \
-  }
-#endif
-#ifndef LOG_EVENT_STRING
-#define LOG_EVENT_STRING(_tag, _value) \
-  (void)__android_log_bswrite(_tag, _value);
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Release any logger resources (a new log write will immediately re-acquire)
- *
- * This is specifically meant to be used by Zygote to close open file descriptors after fork()
- * and before specialization.  O_CLOEXEC is used on file descriptors, so they will be closed upon
- * exec() in normal use cases.
- *
- * Note that this is not safe to call from a multi-threaded program.
- */
-void __android_log_close(void);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/log/log_event_list.h b/liblog/include/log/log_event_list.h
deleted file mode 100644
index deadf20..0000000
--- a/liblog/include/log/log_event_list.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2005-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 <errno.h>
-#include <stdint.h>
-
-#ifdef __cplusplus
-#include <string>
-#endif
-
-#include <log/log.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For manipulating lists of events. */
-
-#define ANDROID_MAX_LIST_NEST_DEPTH 8
-
-/*
- * The opaque context used to manipulate lists of events.
- */
-typedef struct android_log_context_internal* android_log_context;
-
-/*
- * Elements returned when reading a list of events.
- */
-typedef struct {
-  AndroidEventLogType type;
-  uint16_t complete;
-  uint16_t len;
-  union {
-    int32_t int32;
-    int64_t int64;
-    char* string;
-    float float32;
-  } data;
-} android_log_list_element;
-
-/*
- * Creates a context associated with an event tag to write elements to
- * the list of events.
- */
-android_log_context create_android_logger(uint32_t tag);
-
-/* All lists must be braced by a begin and end call */
-/*
- * NB: If the first level braces are missing when specifying multiple
- *     elements, we will manufacturer a list to embrace it for your API
- *     convenience. For a single element, it will remain solitary.
- */
-int android_log_write_list_begin(android_log_context ctx);
-int android_log_write_list_end(android_log_context ctx);
-
-int android_log_write_int32(android_log_context ctx, int32_t value);
-int android_log_write_int64(android_log_context ctx, int64_t value);
-int android_log_write_string8(android_log_context ctx, const char* value);
-int android_log_write_string8_len(android_log_context ctx, const char* value,
-                                  size_t maxlen);
-int android_log_write_float32(android_log_context ctx, float value);
-
-/* Submit the composed list context to the specified logger id */
-/* NB: LOG_ID_EVENTS and LOG_ID_SECURITY only valid binary buffers */
-int android_log_write_list(android_log_context ctx, log_id_t id);
-
-/*
- * Creates a context from a raw buffer representing a list of events to be read.
- */
-android_log_context create_android_log_parser(const char* msg, size_t len);
-
-android_log_list_element android_log_read_next(android_log_context ctx);
-android_log_list_element android_log_peek_next(android_log_context ctx);
-
-/* Reset writer context */
-int android_log_reset(android_log_context ctx);
-
-/* Reset reader context */
-int android_log_parser_reset(android_log_context ctx,
-                             const char* msg, size_t len);
-
-/* Finished with reader or writer context */
-int android_log_destroy(android_log_context* ctx);
-
-#ifdef __cplusplus
-/* android_log_list C++ helpers */
-extern "C++" {
-class android_log_event_list {
- private:
-  android_log_context ctx;
-  int ret;
-
-  android_log_event_list(const android_log_event_list&) = delete;
-  void operator=(const android_log_event_list&) = delete;
-
- public:
-  explicit android_log_event_list(int tag) : ret(0) {
-    ctx = create_android_logger(static_cast<uint32_t>(tag));
-  }
-  ~android_log_event_list() {
-    android_log_destroy(&ctx);
-  }
-
-  int close() {
-    int retval = android_log_destroy(&ctx);
-    if (retval < 0) ret = retval;
-    return retval;
-  }
-
-  /* To allow above C calls to use this class as parameter */
-  operator android_log_context() const {
-    return ctx;
-  }
-
-  /* return errors or transmit status */
-  int status() const {
-    return ret;
-  }
-
-  int begin() {
-    int retval = android_log_write_list_begin(ctx);
-    if (retval < 0) ret = retval;
-    return ret;
-  }
-  int end() {
-    int retval = android_log_write_list_end(ctx);
-    if (retval < 0) ret = retval;
-    return ret;
-  }
-
-  android_log_event_list& operator<<(int32_t value) {
-    int retval = android_log_write_int32(ctx, value);
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  android_log_event_list& operator<<(uint32_t value) {
-    int retval = android_log_write_int32(ctx, static_cast<int32_t>(value));
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  android_log_event_list& operator<<(bool value) {
-    int retval = android_log_write_int32(ctx, value ? 1 : 0);
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  android_log_event_list& operator<<(int64_t value) {
-    int retval = android_log_write_int64(ctx, value);
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  android_log_event_list& operator<<(uint64_t value) {
-    int retval = android_log_write_int64(ctx, static_cast<int64_t>(value));
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  android_log_event_list& operator<<(const char* value) {
-    int retval = android_log_write_string8(ctx, value);
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  android_log_event_list& operator<<(const std::string& value) {
-    int retval =
-        android_log_write_string8_len(ctx, value.data(), value.length());
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  android_log_event_list& operator<<(float value) {
-    int retval = android_log_write_float32(ctx, value);
-    if (retval < 0) ret = retval;
-    return *this;
-  }
-
-  int write(log_id_t id = LOG_ID_EVENTS) {
-    /* facilitate -EBUSY retry */
-    if ((ret == -EBUSY) || (ret > 0)) ret = 0;
-    int retval = android_log_write_list(ctx, id);
-    /* existing errors trump transmission errors */
-    if (!ret) ret = retval;
-    return ret;
-  }
-
-  int operator<<(log_id_t id) {
-    write(id);
-    android_log_destroy(&ctx);
-    return ret;
-  }
-
-  /*
-   * Append<Type> methods removes any integer promotion
-   * confusion, and adds access to string with length.
-   * Append methods are also added for all types for
-   * convenience.
-   */
-
-  bool AppendInt(int32_t value) {
-    int retval = android_log_write_int32(ctx, value);
-    if (retval < 0) ret = retval;
-    return ret >= 0;
-  }
-
-  bool AppendLong(int64_t value) {
-    int retval = android_log_write_int64(ctx, value);
-    if (retval < 0) ret = retval;
-    return ret >= 0;
-  }
-
-  bool AppendString(const char* value) {
-    int retval = android_log_write_string8(ctx, value);
-    if (retval < 0) ret = retval;
-    return ret >= 0;
-  }
-
-  bool AppendString(const char* value, size_t len) {
-    int retval = android_log_write_string8_len(ctx, value, len);
-    if (retval < 0) ret = retval;
-    return ret >= 0;
-  }
-
-  bool AppendString(const std::string& value) {
-    int retval =
-        android_log_write_string8_len(ctx, value.data(), value.length());
-    if (retval < 0) ret = retval;
-    return ret;
-  }
-
-  bool Append(const std::string& value) {
-    int retval =
-        android_log_write_string8_len(ctx, value.data(), value.length());
-    if (retval < 0) ret = retval;
-    return ret;
-  }
-
-  bool AppendFloat(float value) {
-    int retval = android_log_write_float32(ctx, value);
-    if (retval < 0) ret = retval;
-    return ret >= 0;
-  }
-
-  template <typename Tvalue>
-  bool Append(Tvalue value) {
-    *this << value;
-    return ret >= 0;
-  }
-
-  bool Append(const char* value, size_t len) {
-    int retval = android_log_write_string8_len(ctx, value, len);
-    if (retval < 0) ret = retval;
-    return ret >= 0;
-  }
-};
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/log/log_id.h b/liblog/include/log/log_id.h
deleted file mode 100644
index 8e4faeb..0000000
--- a/liblog/include/log/log_id.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2005-2017 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 <android/log.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * log_id_t helpers
- */
-log_id_t android_name_to_log_id(const char* logName);
-const char* android_log_id_to_name(log_id_t log_id);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/log/log_main.h b/liblog/include/log/log_main.h
deleted file mode 100644
index 1bd1c8a..0000000
--- a/liblog/include/log/log_main.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright (C) 2005-2017 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 <stdbool.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <android/log.h>
-
-__BEGIN_DECLS
-
-/*
- * Normally we strip the effects of ALOGV (VERBOSE messages),
- * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
- * release builds be defining NDEBUG.  You can modify this (for
- * example with "#define LOG_NDEBUG 0" at the top of your source
- * file) to change that behavior.
- */
-
-#ifndef LOG_NDEBUG
-#ifdef NDEBUG
-#define LOG_NDEBUG 1
-#else
-#define LOG_NDEBUG 0
-#endif
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/*
- * This file uses ", ## __VA_ARGS__" zero-argument token pasting to
- * work around issues with debug-only syntax errors in assertions
- * that are missing format strings.  See commit
- * 19299904343daf191267564fe32e6cd5c165cd42
- */
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
-#endif
-
-/*
- * Use __VA_ARGS__ if running a static analyzer,
- * to avoid warnings of unused variables in __VA_ARGS__.
- * Use constexpr function in C++ mode, so these macros can be used
- * in other constexpr functions without warning.
- */
-#ifdef __clang_analyzer__
-#ifdef __cplusplus
-extern "C++" {
-template <typename... Ts>
-constexpr int __fake_use_va_args(Ts...) {
-  return 0;
-}
-}
-#else
-extern int __fake_use_va_args(int, ...);
-#endif /* __cplusplus */
-#define __FAKE_USE_VA_ARGS(...) ((void)__fake_use_va_args(0, ##__VA_ARGS__))
-#else
-#define __FAKE_USE_VA_ARGS(...) ((void)(0))
-#endif /* __clang_analyzer__ */
-
-#ifndef __predict_false
-#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
-#endif
-
-#define android_writeLog(prio, tag, text) __android_log_write(prio, tag, text)
-
-#define android_printLog(prio, tag, ...) \
-  __android_log_print(prio, tag, __VA_ARGS__)
-
-#define android_vprintLog(prio, cond, tag, ...) \
-  __android_log_vprint(prio, tag, __VA_ARGS__)
-
-/*
- * Log macro that allows you to specify a number for the priority.
- */
-#ifndef LOG_PRI
-#define LOG_PRI(priority, tag, ...) android_printLog(priority, tag, __VA_ARGS__)
-#endif
-
-/*
- * Log macro that allows you to pass in a varargs ("args" is a va_list).
- */
-#ifndef LOG_PRI_VA
-#define LOG_PRI_VA(priority, tag, fmt, args) \
-  android_vprintLog(priority, NULL, tag, fmt, args)
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/* XXX Macros to work around syntax errors in places where format string
- * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
- * (happens only in debug builds).
- */
-
-/* Returns 2nd arg.  Used to substitute default value if caller's vararg list
- * is empty.
- */
-#define __android_second(dummy, second, ...) second
-
-/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
- * returns nothing.
- */
-#define __android_rest(first, ...) , ##__VA_ARGS__
-
-#define android_printAssert(cond, tag, ...)                     \
-  __android_log_assert(cond, tag,                               \
-                       __android_second(0, ##__VA_ARGS__, NULL) \
-                           __android_rest(__VA_ARGS__))
-
-/*
- * Log a fatal error.  If the given condition fails, this stops program
- * execution like a normal assertion, but also generating the given message.
- * It is NOT stripped from release builds.  Note that the condition test
- * is -inverted- from the normal assert() semantics.
- */
-#ifndef LOG_ALWAYS_FATAL_IF
-#define LOG_ALWAYS_FATAL_IF(cond, ...)                                                    \
-  ((__predict_false(cond)) ? (__FAKE_USE_VA_ARGS(__VA_ARGS__),                            \
-                              ((void)android_printAssert(#cond, LOG_TAG, ##__VA_ARGS__))) \
-                           : ((void)0))
-#endif
-
-#ifndef LOG_ALWAYS_FATAL
-#define LOG_ALWAYS_FATAL(...) \
-  (((void)android_printAssert(NULL, LOG_TAG, ##__VA_ARGS__)))
-#endif
-
-/*
- * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
- * are stripped out of release builds.
- */
-
-#if LOG_NDEBUG
-
-#ifndef LOG_FATAL_IF
-#define LOG_FATAL_IF(cond, ...) __FAKE_USE_VA_ARGS(__VA_ARGS__)
-#endif
-#ifndef LOG_FATAL
-#define LOG_FATAL(...) __FAKE_USE_VA_ARGS(__VA_ARGS__)
-#endif
-
-#else
-
-#ifndef LOG_FATAL_IF
-#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ##__VA_ARGS__)
-#endif
-#ifndef LOG_FATAL
-#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
-#endif
-
-#endif
-
-/*
- * Assertion that generates a log message when the assertion fails.
- * Stripped out of release builds.  Uses the current LOG_TAG.
- */
-#ifndef ALOG_ASSERT
-#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ##__VA_ARGS__)
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/*
- * C/C++ logging functions.  See the logging documentation for API details.
- *
- * We'd like these to be available from C code (in case we import some from
- * somewhere), so this has a C interface.
- *
- * The output will be correct when the log file is shared between multiple
- * threads and/or multiple processes so long as the operating system
- * supports O_APPEND.  These calls have mutex-protected data structures
- * and so are NOT reentrant.  Do not use LOG in a signal handler.
- */
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Simplified macro to send a verbose log message using the current LOG_TAG.
- */
-#ifndef ALOGV
-#define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
-#if LOG_NDEBUG
-#define ALOGV(...)                   \
-  do {                               \
-    __FAKE_USE_VA_ARGS(__VA_ARGS__); \
-    if (false) {                     \
-      __ALOGV(__VA_ARGS__);          \
-    }                                \
-  } while (false)
-#else
-#define ALOGV(...) __ALOGV(__VA_ARGS__)
-#endif
-#endif
-
-#ifndef ALOGV_IF
-#if LOG_NDEBUG
-#define ALOGV_IF(cond, ...) __FAKE_USE_VA_ARGS(__VA_ARGS__)
-#else
-#define ALOGV_IF(cond, ...)                                                               \
-  ((__predict_false(cond))                                                                \
-       ? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
-       : ((void)0))
-#endif
-#endif
-
-/*
- * Simplified macro to send a debug log message using the current LOG_TAG.
- */
-#ifndef ALOGD
-#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
-#endif
-
-#ifndef ALOGD_IF
-#define ALOGD_IF(cond, ...)                                                             \
-  ((__predict_false(cond))                                                              \
-       ? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
-       : ((void)0))
-#endif
-
-/*
- * Simplified macro to send an info log message using the current LOG_TAG.
- */
-#ifndef ALOGI
-#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
-#endif
-
-#ifndef ALOGI_IF
-#define ALOGI_IF(cond, ...)                                                            \
-  ((__predict_false(cond))                                                             \
-       ? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
-       : ((void)0))
-#endif
-
-/*
- * Simplified macro to send a warning log message using the current LOG_TAG.
- */
-#ifndef ALOGW
-#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
-#endif
-
-#ifndef ALOGW_IF
-#define ALOGW_IF(cond, ...)                                                            \
-  ((__predict_false(cond))                                                             \
-       ? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
-       : ((void)0))
-#endif
-
-/*
- * Simplified macro to send an error log message using the current LOG_TAG.
- */
-#ifndef ALOGE
-#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
-#endif
-
-#ifndef ALOGE_IF
-#define ALOGE_IF(cond, ...)                                                             \
-  ((__predict_false(cond))                                                              \
-       ? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
-       : ((void)0))
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Conditional based on whether the current LOG_TAG is enabled at
- * verbose priority.
- */
-#ifndef IF_ALOGV
-#if LOG_NDEBUG
-#define IF_ALOGV() if (false)
-#else
-#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG)
-#endif
-#endif
-
-/*
- * Conditional based on whether the current LOG_TAG is enabled at
- * debug priority.
- */
-#ifndef IF_ALOGD
-#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
-#endif
-
-/*
- * Conditional based on whether the current LOG_TAG is enabled at
- * info priority.
- */
-#ifndef IF_ALOGI
-#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG)
-#endif
-
-/*
- * Conditional based on whether the current LOG_TAG is enabled at
- * warn priority.
- */
-#ifndef IF_ALOGW
-#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG)
-#endif
-
-/*
- * Conditional based on whether the current LOG_TAG is enabled at
- * error priority.
- */
-#ifndef IF_ALOGE
-#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Basic log message macro.
- *
- * Example:
- *  ALOG(LOG_WARN, NULL, "Failed with error %d", errno);
- *
- * The second argument may be NULL or "" to indicate the "global" tag.
- */
-#ifndef ALOG
-#define ALOG(priority, tag, ...) LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
-#endif
-
-/*
- * Conditional given a desired logging priority and tag.
- */
-#ifndef IF_ALOG
-#define IF_ALOG(priority, tag) if (android_testLog(ANDROID_##priority, tag))
-#endif
-
-/* --------------------------------------------------------------------- */
-
-/*
- *    IF_ALOG uses android_testLog, but IF_ALOG can be overridden.
- *    android_testLog will remain constant in its purpose as a wrapper
- *        for Android logging filter policy, and can be subject to
- *        change. It can be reused by the developers that override
- *        IF_ALOG as a convenient means to reimplement their policy
- *        over Android.
- */
-
-/*
- * Use the per-tag properties "log.tag.<tagname>" to generate a runtime
- * result of non-zero to expose a log. prio is ANDROID_LOG_VERBOSE to
- * ANDROID_LOG_FATAL. default_prio if no property. Undefined behavior if
- * any other value.
- */
-int __android_log_is_loggable(int prio, const char* tag, int default_prio);
-int __android_log_is_loggable_len(int prio, const char* tag, size_t len, int default_prio);
-
-#if LOG_NDEBUG /* Production */
-#define android_testLog(prio, tag)                                           \
-  (__android_log_is_loggable_len(prio, tag, ((tag) && *(tag)) ? strlen(tag) : 0, \
-                                 ANDROID_LOG_DEBUG) != 0)
-#else
-#define android_testLog(prio, tag)                                           \
-  (__android_log_is_loggable_len(prio, tag, ((tag) && *(tag)) ? strlen(tag) : 0, \
-                                 ANDROID_LOG_VERBOSE) != 0)
-#endif
-
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
-__END_DECLS
diff --git a/liblog/include/log/log_properties.h b/liblog/include/log/log_properties.h
deleted file mode 100644
index 2a0230f..0000000
--- a/liblog/include/log/log_properties.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 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
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Returns `1` if the device is debuggable or `0` if not. */
-int __android_log_is_debuggable();
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/log/log_radio.h b/liblog/include/log/log_radio.h
deleted file mode 100644
index f5525c1..0000000
--- a/liblog/include/log/log_radio.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2005-2017 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 <android/log.h>
-
-/*
- * Normally we strip the effects of ALOGV (VERBOSE messages),
- * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
- * release builds be defining NDEBUG.  You can modify this (for
- * example with "#define LOG_NDEBUG 0" at the top of your source
- * file) to change that behavior.
- */
-
-#ifndef LOG_NDEBUG
-#ifdef NDEBUG
-#define LOG_NDEBUG 1
-#else
-#define LOG_NDEBUG 0
-#endif
-#endif
-
-/* --------------------------------------------------------------------- */
-
-#ifndef __predict_false
-#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
-#endif
-
-/*
- * Simplified macro to send a verbose radio log message using current LOG_TAG.
- */
-#ifndef RLOGV
-#define __RLOGV(...)                                                         \
-  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, \
-                                 __VA_ARGS__))
-#if LOG_NDEBUG
-#define RLOGV(...)          \
-  do {                      \
-    if (0) {                \
-      __RLOGV(__VA_ARGS__); \
-    }                       \
-  } while (0)
-#else
-#define RLOGV(...) __RLOGV(__VA_ARGS__)
-#endif
-#endif
-
-#ifndef RLOGV_IF
-#if LOG_NDEBUG
-#define RLOGV_IF(cond, ...) ((void)0)
-#else
-#define RLOGV_IF(cond, ...)                                                \
-  ((__predict_false(cond))                                                 \
-       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, \
-                                        LOG_TAG, __VA_ARGS__))             \
-       : (void)0)
-#endif
-#endif
-
-/*
- * Simplified macro to send a debug radio log message using  current LOG_TAG.
- */
-#ifndef RLOGD
-#define RLOGD(...)                                                         \
-  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef RLOGD_IF
-#define RLOGD_IF(cond, ...)                                              \
-  ((__predict_false(cond))                                               \
-       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, \
-                                        LOG_TAG, __VA_ARGS__))           \
-       : (void)0)
-#endif
-
-/*
- * Simplified macro to send an info radio log message using  current LOG_TAG.
- */
-#ifndef RLOGI
-#define RLOGI(...)                                                        \
-  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef RLOGI_IF
-#define RLOGI_IF(cond, ...)                                             \
-  ((__predict_false(cond))                                              \
-       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, \
-                                        LOG_TAG, __VA_ARGS__))          \
-       : (void)0)
-#endif
-
-/*
- * Simplified macro to send a warning radio log message using current LOG_TAG.
- */
-#ifndef RLOGW
-#define RLOGW(...)                                                        \
-  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef RLOGW_IF
-#define RLOGW_IF(cond, ...)                                             \
-  ((__predict_false(cond))                                              \
-       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, \
-                                        LOG_TAG, __VA_ARGS__))          \
-       : (void)0)
-#endif
-
-/*
- * Simplified macro to send an error radio log message using current LOG_TAG.
- */
-#ifndef RLOGE
-#define RLOGE(...)                                                         \
-  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef RLOGE_IF
-#define RLOGE_IF(cond, ...)                                              \
-  ((__predict_false(cond))                                               \
-       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, \
-                                        LOG_TAG, __VA_ARGS__))           \
-       : (void)0)
-#endif
diff --git a/liblog/include/log/log_read.h b/liblog/include/log/log_read.h
deleted file mode 100644
index 1736934..0000000
--- a/liblog/include/log/log_read.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2005-2017 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 <stdint.h>
-#include <sys/types.h>
-
-#include <android/log.h>
-#include <log/log_time.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ANDROID_LOG_WRAP_DEFAULT_TIMEOUT 7200 /* 2 hour default */
-
-/*
- * Native log reading interface section. See logcat for sample code.
- *
- * The preferred API is an exec of logcat. Likely uses of this interface
- * are if native code suffers from exec or filtration being too costly,
- * access to raw information, or parsing is an issue.
- */
-
-struct logger_entry {
-  uint16_t len;      /* length of the payload */
-  uint16_t hdr_size; /* sizeof(struct logger_entry) */
-  int32_t pid;       /* generating process's pid */
-  uint32_t tid;      /* generating process's tid */
-  uint32_t sec;      /* seconds since Epoch */
-  uint32_t nsec;     /* nanoseconds */
-  uint32_t lid;      /* log id of the payload, bottom 4 bits currently */
-  uint32_t uid;      /* generating process's uid */
-};
-
-/*
- * The maximum size of a log entry which can be read.
- * An attempt to read less than this amount may result
- * in read() returning EINVAL.
- */
-#define LOGGER_ENTRY_MAX_LEN (5 * 1024)
-
-struct log_msg {
-  union {
-    unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1];
-    struct logger_entry entry;
-  } __attribute__((aligned(4)));
-#ifdef __cplusplus
-  uint64_t nsec() const {
-    return static_cast<uint64_t>(entry.sec) * NS_PER_SEC + entry.nsec;
-  }
-  log_id_t id() {
-    return static_cast<log_id_t>(entry.lid);
-  }
-  char* msg() {
-    unsigned short hdr_size = entry.hdr_size;
-    if (hdr_size >= sizeof(struct log_msg) - sizeof(entry)) {
-      return nullptr;
-    }
-    return reinterpret_cast<char*>(buf) + hdr_size;
-  }
-  unsigned int len() { return entry.hdr_size + entry.len; }
-#endif
-};
-
-struct logger;
-
-log_id_t android_logger_get_id(struct logger* logger);
-
-/* Clears the given log buffer. */
-int android_logger_clear(struct logger* logger);
-/* Return the allotted size for the given log buffer. */
-long android_logger_get_log_size(struct logger* logger);
-/* Set the allotted size for the given log buffer. */
-int android_logger_set_log_size(struct logger* logger, unsigned long size);
-/* Return the actual, uncompressed size that can be read from the given log buffer. */
-long android_logger_get_log_readable_size(struct logger* logger);
-/* Return the actual, compressed size that the given log buffer is consuming. */
-long android_logger_get_log_consumed_size(struct logger* logger);
-/* Deprecated.  Always returns '4' regardless of input. */
-int android_logger_get_log_version(struct logger* logger);
-
-struct logger_list;
-
-ssize_t android_logger_get_statistics(struct logger_list* logger_list,
-                                      char* buf, size_t len);
-ssize_t android_logger_get_prune_list(struct logger_list* logger_list,
-                                      char* buf, size_t len);
-int android_logger_set_prune_list(struct logger_list* logger_list, const char* buf, size_t len);
-
-/* The below values are used for the `mode` argument of the below functions. */
-/* Note that 0x00000003 were previously used and should be considered reserved. */
-#define ANDROID_LOG_NONBLOCK 0x00000800
-#define ANDROID_LOG_WRAP 0x40000000 /* Block until buffer about to wrap */
-#define ANDROID_LOG_PSTORE 0x80000000
-
-struct logger_list* android_logger_list_alloc(int mode, unsigned int tail,
-                                              pid_t pid);
-struct logger_list* android_logger_list_alloc_time(int mode, log_time start,
-                                                   pid_t pid);
-void android_logger_list_free(struct logger_list* logger_list);
-/* In the purest sense, the following two are orthogonal interfaces */
-int android_logger_list_read(struct logger_list* logger_list,
-                             struct log_msg* log_msg);
-
-/* Multiple log_id_t opens */
-struct logger* android_logger_open(struct logger_list* logger_list, log_id_t id);
-/* Single log_id_t open */
-struct logger_list* android_logger_list_open(log_id_t id, int mode,
-                                             unsigned int tail, pid_t pid);
-#define android_logger_list_close android_logger_list_free
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/log/log_safetynet.h b/liblog/include/log/log_safetynet.h
deleted file mode 100644
index b2604b5..0000000
--- a/liblog/include/log/log_safetynet.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2017 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 <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define android_errorWriteLog(tag, subTag) \
-  __android_log_error_write(tag, subTag, -1, NULL, 0)
-
-#define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \
-  __android_log_error_write(tag, subTag, uid, data, dataLen)
-
-int __android_log_error_write(int tag, const char* subTag, int32_t uid,
-                              const char* data, uint32_t dataLen);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/log/log_system.h b/liblog/include/log/log_system.h
deleted file mode 100644
index 6f40515..0000000
--- a/liblog/include/log/log_system.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2005-2017 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 <android/log.h>
-
-/*
- * Normally we strip the effects of ALOGV (VERBOSE messages),
- * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
- * release builds be defining NDEBUG.  You can modify this (for
- * example with "#define LOG_NDEBUG 0" at the top of your source
- * file) to change that behavior.
- */
-
-#ifndef LOG_NDEBUG
-#ifdef NDEBUG
-#define LOG_NDEBUG 1
-#else
-#define LOG_NDEBUG 0
-#endif
-#endif
-
-#ifndef __predict_false
-#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
-#endif
-
-/*
- * Simplified macro to send a verbose system log message using current LOG_TAG.
- */
-#ifndef SLOGV
-#define __SLOGV(...)                                                          \
-  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, \
-                                 __VA_ARGS__))
-#if LOG_NDEBUG
-#define SLOGV(...)          \
-  do {                      \
-    if (0) {                \
-      __SLOGV(__VA_ARGS__); \
-    }                       \
-  } while (0)
-#else
-#define SLOGV(...) __SLOGV(__VA_ARGS__)
-#endif
-#endif
-
-#ifndef SLOGV_IF
-#if LOG_NDEBUG
-#define SLOGV_IF(cond, ...) ((void)0)
-#else
-#define SLOGV_IF(cond, ...)                                                 \
-  ((__predict_false(cond))                                                  \
-       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, \
-                                        LOG_TAG, __VA_ARGS__))              \
-       : (void)0)
-#endif
-#endif
-
-/*
- * Simplified macro to send a debug system log message using current LOG_TAG.
- */
-#ifndef SLOGD
-#define SLOGD(...)                                                          \
-  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef SLOGD_IF
-#define SLOGD_IF(cond, ...)                                               \
-  ((__predict_false(cond))                                                \
-       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, \
-                                        LOG_TAG, __VA_ARGS__))            \
-       : (void)0)
-#endif
-
-/*
- * Simplified macro to send an info system log message using current LOG_TAG.
- */
-#ifndef SLOGI
-#define SLOGI(...)                                                         \
-  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef SLOGI_IF
-#define SLOGI_IF(cond, ...)                                              \
-  ((__predict_false(cond))                                               \
-       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, \
-                                        LOG_TAG, __VA_ARGS__))           \
-       : (void)0)
-#endif
-
-/*
- * Simplified macro to send a warning system log message using current LOG_TAG.
- */
-#ifndef SLOGW
-#define SLOGW(...)                                                         \
-  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef SLOGW_IF
-#define SLOGW_IF(cond, ...)                                              \
-  ((__predict_false(cond))                                               \
-       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, \
-                                        LOG_TAG, __VA_ARGS__))           \
-       : (void)0)
-#endif
-
-/*
- * Simplified macro to send an error system log message using current LOG_TAG.
- */
-#ifndef SLOGE
-#define SLOGE(...)                                                          \
-  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, \
-                                 __VA_ARGS__))
-#endif
-
-#ifndef SLOGE_IF
-#define SLOGE_IF(cond, ...)                                               \
-  ((__predict_false(cond))                                                \
-       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, \
-                                        LOG_TAG, __VA_ARGS__))            \
-       : (void)0)
-#endif
diff --git a/liblog/include/log/log_time.h b/liblog/include/log/log_time.h
deleted file mode 100644
index f50764d..0000000
--- a/liblog/include/log/log_time.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2005-2017 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 <stdint.h>
-#include <time.h>
-
-/* struct log_time is a wire-format variant of struct timespec */
-#define NS_PER_SEC 1000000000ULL
-#define US_PER_SEC 1000000ULL
-#define MS_PER_SEC 1000ULL
-
-#define LOG_TIME_SEC(t) ((t)->tv_sec)
-/* next power of two after NS_PER_SEC */
-#define LOG_TIME_NSEC(t) ((t)->tv_nsec & (UINT32_MAX >> 2))
-
-#ifdef __cplusplus
-
-extern "C" {
-
-struct log_time {
- public:
-  uint32_t tv_sec = 0; /* good to Feb 5 2106 */
-  uint32_t tv_nsec = 0;
-
-  static constexpr timespec EPOCH = {0, 0};
-
-  log_time() {}
-  explicit log_time(const timespec& T)
-      : tv_sec(static_cast<uint32_t>(T.tv_sec)), tv_nsec(static_cast<uint32_t>(T.tv_nsec)) {}
-  explicit log_time(uint32_t sec, uint32_t nsec = 0)
-      : tv_sec(sec), tv_nsec(nsec) {
-  }
-#ifdef __linux__
-  explicit log_time(clockid_t id) {
-    timespec T;
-    clock_gettime(id, &T);
-    tv_sec = static_cast<uint32_t>(T.tv_sec);
-    tv_nsec = static_cast<uint32_t>(T.tv_nsec);
-  }
-#endif
-  /* timespec */
-  bool operator==(const timespec& T) const {
-    return (tv_sec == static_cast<uint32_t>(T.tv_sec)) &&
-           (tv_nsec == static_cast<uint32_t>(T.tv_nsec));
-  }
-  bool operator!=(const timespec& T) const {
-    return !(*this == T);
-  }
-  bool operator<(const timespec& T) const {
-    return (tv_sec < static_cast<uint32_t>(T.tv_sec)) ||
-           ((tv_sec == static_cast<uint32_t>(T.tv_sec)) &&
-            (tv_nsec < static_cast<uint32_t>(T.tv_nsec)));
-  }
-  bool operator>=(const timespec& T) const {
-    return !(*this < T);
-  }
-  bool operator>(const timespec& T) const {
-    return (tv_sec > static_cast<uint32_t>(T.tv_sec)) ||
-           ((tv_sec == static_cast<uint32_t>(T.tv_sec)) &&
-            (tv_nsec > static_cast<uint32_t>(T.tv_nsec)));
-  }
-  bool operator<=(const timespec& T) const {
-    return !(*this > T);
-  }
-
-  /* log_time */
-  bool operator==(const log_time& T) const {
-    return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec);
-  }
-  bool operator!=(const log_time& T) const {
-    return !(*this == T);
-  }
-  bool operator<(const log_time& T) const {
-    return (tv_sec < T.tv_sec) ||
-           ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec));
-  }
-  bool operator>=(const log_time& T) const {
-    return !(*this < T);
-  }
-  bool operator>(const log_time& T) const {
-    return (tv_sec > T.tv_sec) ||
-           ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec));
-  }
-  bool operator<=(const log_time& T) const {
-    return !(*this > T);
-  }
-
-  log_time operator-=(const log_time& T) {
-    // No concept of negative time, clamp to EPOCH
-    if (*this <= T) {
-      return *this = log_time(EPOCH);
-    }
-
-    if (this->tv_nsec < T.tv_nsec) {
-      --this->tv_sec;
-      this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec;
-    } else {
-      this->tv_nsec -= T.tv_nsec;
-    }
-    this->tv_sec -= T.tv_sec;
-
-    return *this;
-  }
-  log_time operator-(const log_time& T) const {
-    log_time local(*this);
-    return local -= T;
-  }
-  log_time operator+=(const log_time& T) {
-    this->tv_nsec += T.tv_nsec;
-    if (this->tv_nsec >= NS_PER_SEC) {
-      this->tv_nsec -= NS_PER_SEC;
-      ++this->tv_sec;
-    }
-    this->tv_sec += T.tv_sec;
-
-    return *this;
-  }
-  log_time operator+(const log_time& T) const {
-    log_time local(*this);
-    return local += T;
-  }
-
-  uint64_t nsec() const {
-    return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
-  }
-  uint64_t usec() const {
-    return static_cast<uint64_t>(tv_sec) * US_PER_SEC +
-           tv_nsec / (NS_PER_SEC / US_PER_SEC);
-  }
-  uint64_t msec() const {
-    return static_cast<uint64_t>(tv_sec) * MS_PER_SEC +
-           tv_nsec / (NS_PER_SEC / MS_PER_SEC);
-  }
-
-  /* Add %#q for the fraction of a second to the standard library functions */
-  char* strptime(const char* s, const char* format);
-} __attribute__((__packed__));
-}
-
-#else /* __cplusplus */
-
-typedef struct log_time {
-  uint32_t tv_sec;
-  uint32_t tv_nsec;
-} __attribute__((__packed__)) log_time;
-
-#endif /* __cplusplus */
diff --git a/liblog/include/log/logprint.h b/liblog/include/log/logprint.h
deleted file mode 100644
index 7dfd914..0000000
--- a/liblog/include/log/logprint.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2006 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 <stdint.h>
-#include <sys/types.h>
-
-#include <android/log.h>
-#include <log/event_tag_map.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
-  /* Verbs */
-  FORMAT_OFF = 0,
-  FORMAT_BRIEF,
-  FORMAT_PROCESS,
-  FORMAT_TAG,
-  FORMAT_THREAD,
-  FORMAT_RAW,
-  FORMAT_TIME,
-  FORMAT_THREADTIME,
-  FORMAT_LONG,
-  /* Adverbs. The following are modifiers to above format verbs */
-  FORMAT_MODIFIER_COLOR,     /* converts priority to color */
-  FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */
-  FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */
-  FORMAT_MODIFIER_YEAR,      /* Adds year to date */
-  FORMAT_MODIFIER_ZONE,      /* Adds zone to date, + UTC */
-  FORMAT_MODIFIER_EPOCH,     /* Print time as seconds since Jan 1 1970 */
-  FORMAT_MODIFIER_MONOTONIC, /* Print cpu time as seconds since start */
-  FORMAT_MODIFIER_UID,       /* Adds uid */
-  FORMAT_MODIFIER_DESCRIPT,  /* Adds descriptive */
-  /* private, undocumented */
-  FORMAT_MODIFIER_TIME_NSEC, /* switches from msec to nsec time precision */
-} AndroidLogPrintFormat;
-
-typedef struct AndroidLogFormat_t AndroidLogFormat;
-
-typedef struct AndroidLogEntry_t {
-  time_t tv_sec;
-  long tv_nsec;
-  android_LogPriority priority;
-  int32_t uid;
-  int32_t pid;
-  int32_t tid;
-  const char* tag;
-  size_t tagLen;
-  size_t messageLen;
-  const char* message;
-} AndroidLogEntry;
-
-AndroidLogFormat* android_log_format_new();
-
-void android_log_format_free(AndroidLogFormat* p_format);
-
-/* currently returns 0 if format is a modifier, 1 if not */
-int android_log_setPrintFormat(AndroidLogFormat* p_format,
-                               AndroidLogPrintFormat format);
-
-/**
- * Returns FORMAT_OFF on invalid string
- */
-AndroidLogPrintFormat android_log_formatFromString(const char* s);
-
-/**
- * filterExpression: a single filter expression
- * eg "AT:d"
- *
- * returns 0 on success and -1 on invalid expression
- *
- * Assumes single threaded execution
- *
- */
-
-int android_log_addFilterRule(AndroidLogFormat* p_format,
-                              const char* filterExpression);
-
-/**
- * filterString: a whitespace-separated set of filter expressions
- * eg "AT:d *:i"
- *
- * returns 0 on success and -1 on invalid expression
- *
- * Assumes single threaded execution
- *
- */
-
-int android_log_addFilterString(AndroidLogFormat* p_format,
-                                const char* filterString);
-
-/**
- * returns 1 if this log line should be printed based on its priority
- * and tag, and 0 if it should not
- */
-int android_log_shouldPrintLine(AndroidLogFormat* p_format, const char* tag,
-                                android_LogPriority pri);
-
-/**
- * Splits a wire-format buffer into an AndroidLogEntry
- * entry allocated by caller. Pointers will point directly into buf
- *
- * Returns 0 on success and -1 on invalid wire format (entry will be
- * in unspecified state)
- */
-int android_log_processLogBuffer(struct logger_entry* buf,
-                                 AndroidLogEntry* entry);
-
-/**
- * Like android_log_processLogBuffer, but for binary logs.
- *
- * If "map" is non-NULL, it will be used to convert the log tag number
- * into a string.
- */
-int android_log_processBinaryLogBuffer(struct logger_entry* buf,
-                                       AndroidLogEntry* entry,
-                                       const EventTagMap* map, char* messageBuf,
-                                       int messageBufLen);
-
-/**
- * Formats a log message into a buffer
- *
- * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer
- * If return value != defaultBuffer, caller must call free()
- * Returns NULL on malloc error
- */
-
-char* android_log_formatLogLine(AndroidLogFormat* p_format, char* defaultBuffer,
-                                size_t defaultBufferSize,
-                                const AndroidLogEntry* p_line,
-                                size_t* p_outLength);
-
-/**
- * Either print or do not print log line, based on filter
- *
- * Assumes single threaded execution
- *
- */
-int android_log_printLogLine(AndroidLogFormat* p_format, int fd,
-                             const AndroidLogEntry* entry);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/liblog/include/private/android_logger.h b/liblog/include/private/android_logger.h
deleted file mode 100644
index 166f387..0000000
--- a/liblog/include/private/android_logger.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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.
- */
-
-/* This file is used to define the internal protocol for the Android Logger */
-
-#pragma once
-
-/* Android private interfaces */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-#include <string>
-#endif
-
-#include <log/log.h>
-#include <log/log_event_list.h>
-
-#define LOGGER_MAGIC 'l'
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* Header Structure to pstore */
-typedef struct __attribute__((__packed__)) {
-  uint8_t magic;
-  uint16_t len;
-  uint16_t uid;
-  uint16_t pid;
-} android_pmsg_log_header_t;
-
-/* Header Structure to logd, and second header for pstore */
-typedef struct __attribute__((__packed__)) {
-  uint8_t id;
-  uint16_t tid;
-  log_time realtime;
-} android_log_header_t;
-
-/* Event Header Structure to logd */
-typedef struct __attribute__((__packed__)) {
-  int32_t tag;  // Little Endian Order
-} android_event_header_t;
-
-// Event payload EVENT_TYPE_LIST
-typedef struct __attribute__((__packed__)) {
-  int8_t type;  // EVENT_TYPE_LIST
-  int8_t element_count;
-} android_event_list_t;
-
-// Event payload EVENT_TYPE_FLOAT
-typedef struct __attribute__((__packed__)) {
-  int8_t type;  // EVENT_TYPE_FLOAT
-  float data;
-} android_event_float_t;
-
-/* Event payload EVENT_TYPE_INT */
-typedef struct __attribute__((__packed__)) {
-  int8_t type;   // EVENT_TYPE_INT
-  int32_t data;  // Little Endian Order
-} android_event_int_t;
-
-/* Event with single EVENT_TYPE_INT */
-typedef struct __attribute__((__packed__)) {
-  android_event_header_t header;
-  android_event_int_t payload;
-} android_log_event_int_t;
-
-/* Event payload EVENT_TYPE_LONG */
-typedef struct __attribute__((__packed__)) {
-  int8_t type;   // EVENT_TYPE_LONG
-  int64_t data;  // Little Endian Order
-} android_event_long_t;
-
-/* Event with single EVENT_TYPE_LONG */
-typedef struct __attribute__((__packed__)) {
-  android_event_header_t header;
-  android_event_long_t payload;
-} android_log_event_long_t;
-
-/*
- * Event payload EVENT_TYPE_STRING
- *
- * Danger: do not embed this structure into another structure.
- * This structure uses a flexible array member, and when
- * compiled using g++, __builtin_object_size(data, 1) returns
- * a bad value. This is possibly a g++ bug, or a bug due to
- * the fact that flexible array members are not supported
- * in C++.
- * http://stackoverflow.com/questions/4412749/are-flexible-array-members-valid-in-c
- */
-
-typedef struct __attribute__((__packed__)) {
-  int8_t type;     // EVENT_TYPE_STRING;
-  int32_t length;  // Little Endian Order
-  char data[];
-} android_event_string_t;
-
-/* Event with single EVENT_TYPE_STRING */
-typedef struct __attribute__((__packed__)) {
-  android_event_header_t header;
-  int8_t type;     // EVENT_TYPE_STRING;
-  int32_t length;  // Little Endian Order
-  char data[];
-} android_log_event_string_t;
-
-#define ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE 256 /* 1MB file */
-#define ANDROID_LOG_PMSG_FILE_SEQUENCE 1000
-
-ssize_t __android_log_pmsg_file_write(log_id_t logId, char prio,
-                                      const char* filename, const char* buf,
-                                      size_t len);
-
-#define LOG_ID_ANY ((log_id_t)-1)
-#define ANDROID_LOG_ANY ANDROID_LOG_UNKNOWN
-
-/* first 5 arguments match __android_log_msg_file_write, a cast is safe */
-typedef ssize_t (*__android_log_pmsg_file_read_fn)(log_id_t logId, char prio,
-                                                   const char* filename,
-                                                   const char* buf, size_t len,
-                                                   void* arg);
-
-ssize_t __android_log_pmsg_file_read(log_id_t logId, char prio,
-                                     const char* prefix,
-                                     __android_log_pmsg_file_read_fn fn,
-                                     void* arg);
-
-int __android_log_security_bwrite(int32_t tag, const void* payload, size_t len);
-int __android_log_security_bswrite(int32_t tag, const char* payload);
-int __android_log_security(); /* Device Owner is present */
-
-/* Retrieve the composed event buffer */
-int android_log_write_list_buffer(android_log_context ctx, const char** msg);
-
-#if defined(__cplusplus)
-}
-#endif
diff --git a/liblog/include_vndk/android b/liblog/include_vndk/android
deleted file mode 120000
index a3c0320..0000000
--- a/liblog/include_vndk/android
+++ /dev/null
@@ -1 +0,0 @@
-../include/android
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log.h b/liblog/include_vndk/log/log.h
deleted file mode 100644
index ab4adc4..0000000
--- a/liblog/include_vndk/log/log.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*Special log.h file for VNDK linking modules*/
-
-#ifndef _LIBS_LOG_LOG_H
-#define _LIBS_LOG_LOG_H
-
-/* Historically vendors have depended on this header being included. */
-#include <fcntl.h>
-
-#include <android/log.h>
-#include <log/log_id.h>
-#include <log/log_main.h>
-#include <log/log_radio.h>
-#include <log/log_read.h>
-#include <log/log_safetynet.h>
-#include <log/log_system.h>
-#include <log/log_time.h>
-
-/*
- * LOG_TAG is the local tag used for the following simplified
- * logging macros.  You can change this preprocessor definition
- * before using the other macros to change the tag.
- */
-
-#ifndef LOG_TAG
-#define LOG_TAG NULL
-#endif
-
-#endif /*_LIBS_LOG_LOG_H*/
diff --git a/liblog/include_vndk/log/log_event_list.h b/liblog/include_vndk/log/log_event_list.h
deleted file mode 100644
index 1f3dd37..0000000
--- a/liblog/include_vndk/log/log_event_list.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2005-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.
- */
-
-/* Special log_event_list.h file for VNDK linking modules */
-
-#ifndef _LIBS_LOG_EVENT_LIST_H
-#define _LIBS_LOG_EVENT_LIST_H
-
-#include <stdint.h>
-
-#include <log/log_id.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * The opaque context used to manipulate lists of events.
- */
-#ifndef __android_log_context_defined
-#define __android_log_context_defined
-typedef struct android_log_context_internal* android_log_context;
-#endif
-
-/*
- * Creates a context associated with an event tag to write elements to
- * the list of events.
- */
-android_log_context create_android_logger(uint32_t tag);
-
-/* All lists must be braced by a begin and end call */
-/*
- * NB: If the first level braces are missing when specifying multiple
- *     elements, we will manufacturer a list to embrace it for your API
- *     convenience. For a single element, it will remain solitary.
- */
-int android_log_write_list_begin(android_log_context ctx);
-int android_log_write_list_end(android_log_context ctx);
-
-int android_log_write_int32(android_log_context ctx, int32_t value);
-int android_log_write_int64(android_log_context ctx, int64_t value);
-int android_log_write_string8(android_log_context ctx, const char* value);
-int android_log_write_string8_len(android_log_context ctx, const char* value,
-                                  size_t maxlen);
-int android_log_write_float32(android_log_context ctx, float value);
-
-/* Submit the composed list context to the specified logger id */
-/* NB: LOG_ID_EVENTS and LOG_ID_SECURITY only valid binary buffers */
-int android_log_write_list(android_log_context ctx, log_id_t id);
-
-/* Reset writer context */
-int android_log_reset(android_log_context ctx);
-
-/* Reset reader context */
-int android_log_parser_reset(android_log_context ctx,
-                             const char* msg, size_t len);
-
-/* Finished with reader or writer context */
-int android_log_destroy(android_log_context* ctx);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBS_LOG_EVENT_LIST_H */
diff --git a/liblog/include_vndk/log/log_id.h b/liblog/include_vndk/log/log_id.h
deleted file mode 120000
index dce92b9..0000000
--- a/liblog/include_vndk/log/log_id.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_id.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_main.h b/liblog/include_vndk/log/log_main.h
deleted file mode 120000
index f2ec018..0000000
--- a/liblog/include_vndk/log/log_main.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_main.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_properties.h b/liblog/include_vndk/log/log_properties.h
deleted file mode 120000
index bbec426..0000000
--- a/liblog/include_vndk/log/log_properties.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_properties.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_radio.h b/liblog/include_vndk/log/log_radio.h
deleted file mode 120000
index 1e12b32..0000000
--- a/liblog/include_vndk/log/log_radio.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_radio.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_read.h b/liblog/include_vndk/log/log_read.h
deleted file mode 120000
index 01de8b9..0000000
--- a/liblog/include_vndk/log/log_read.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_read.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_safetynet.h b/liblog/include_vndk/log/log_safetynet.h
deleted file mode 120000
index a4614e7..0000000
--- a/liblog/include_vndk/log/log_safetynet.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_safetynet.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_system.h b/liblog/include_vndk/log/log_system.h
deleted file mode 120000
index d0d3904..0000000
--- a/liblog/include_vndk/log/log_system.h
+++ /dev/null
@@ -1 +0,0 @@
-../../include/log/log_system.h
\ No newline at end of file
diff --git a/liblog/include_vndk/log/log_time.h b/liblog/include_vndk/log/log_time.h
deleted file mode 100644
index 5a09959..0000000
--- a/liblog/include_vndk/log/log_time.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2005-2017 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 _LIBS_LOG_LOG_TIME_H
-#define _LIBS_LOG_LOG_TIME_H
-
-#include <stdint.h>
-
-/* struct log_time is a wire-format variant of struct timespec */
-#ifndef NS_PER_SEC
-#define NS_PER_SEC 1000000000ULL
-#endif
-#ifndef US_PER_SEC
-#define US_PER_SEC 1000000ULL
-#endif
-#ifndef MS_PER_SEC
-#define MS_PER_SEC 1000ULL
-#endif
-
-#ifndef __struct_log_time_defined
-#define __struct_log_time_defined
-
-#define LOG_TIME_SEC(t) ((t)->tv_sec)
-/* next power of two after NS_PER_SEC */
-#define LOG_TIME_NSEC(t) ((t)->tv_nsec & (UINT32_MAX >> 2))
-
-typedef struct log_time {
-  uint32_t tv_sec;
-  uint32_t tv_nsec;
-} __attribute__((__packed__)) log_time;
-
-#endif
-
-#endif /* _LIBS_LOG_LOG_TIME_H */
diff --git a/liblog/liblog.map.txt b/liblog/liblog.map.txt
deleted file mode 100644
index 8beb679..0000000
--- a/liblog/liblog.map.txt
+++ /dev/null
@@ -1,94 +0,0 @@
-LIBLOG {
-  global:
-    android_name_to_log_id; # apex llndk
-    android_log_id_to_name; # llndk
-    __android_log_assert;
-    __android_log_buf_print;
-    __android_log_buf_write;
-    __android_log_print;
-    __android_log_vprint;
-    __android_log_write;
-  local:
-    *;
-};
-
-LIBLOG_L {
-  global:
-    android_logger_clear; # llndk
-    android_logger_get_id; # llndk
-    android_logger_get_log_readable_size; # llndk
-    android_logger_get_log_version; # llndk
-    android_logger_get_log_size; # llndk
-    android_logger_list_alloc; # apex llndk
-    android_logger_list_alloc_time; # apex llndk
-    android_logger_list_free; # apex llndk
-    android_logger_list_open; # apex llndk
-    android_logger_list_read; # apex llndk
-    android_logger_open; # apex llndk
-    android_logger_set_log_size; # llndk
-};
-
-LIBLOG_M {
-  global:
-    android_logger_get_prune_list; # llndk
-    android_logger_set_prune_list; # llndk
-    android_logger_get_statistics; # llndk
-    __android_log_error_write; # apex llndk
-    __android_log_is_loggable;
-    create_android_logger; # apex llndk
-    android_log_destroy; # apex llndk
-    android_log_write_list_begin; # apex llndk
-    android_log_write_list_end; # apex llndk
-    android_log_write_int32; # apex llndk
-    android_log_write_int64; # apex llndk
-    android_log_write_string8; # apex llndk
-    android_log_write_string8_len; # apex llndk
-    android_log_write_float32; # apex llndk
-    android_log_write_list; # apex llndk
-
-};
-
-LIBLOG_O {
-  global:
-    __android_log_is_loggable_len;
-    __android_log_is_debuggable; # apex llndk
-};
-
-LIBLOG_Q { # introduced=29
-  global:
-    __android_log_bswrite; # apex
-    __android_log_btwrite; # apex
-    __android_log_bwrite; # apex
-    __android_log_close; # apex
-    __android_log_security; # apex
-    android_log_reset; # llndk
-    android_log_parser_reset; # llndk
-};
-
-LIBLOG_R { # introduced=30
-  global:
-    __android_log_call_aborter;
-    __android_log_default_aborter;
-    __android_log_get_minimum_priority;
-    __android_log_logd_logger;
-    __android_log_security_bswrite; # apex
-    __android_log_set_aborter;
-    __android_log_set_default_tag;
-    __android_log_set_logger;
-    __android_log_set_minimum_priority;
-    __android_log_stderr_logger;
-    __android_log_write_log_message;
-};
-
-LIBLOG_PRIVATE {
-  global:
-    __android_log_pmsg_file_read;
-    __android_log_pmsg_file_write;
-    android_openEventTagMap;
-    android_log_processBinaryLogBuffer;
-    android_log_processLogBuffer;
-    android_log_read_next;
-    android_log_write_list_buffer;
-    android_lookupEventTagNum;
-    create_android_log_parser;
-};
diff --git a/liblog/log_event_list.cpp b/liblog/log_event_list.cpp
deleted file mode 100644
index cb70d48..0000000
--- a/liblog/log_event_list.cpp
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
- * 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 <errno.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <log/log_event_list.h>
-#include <private/android_logger.h>
-
-#define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(int32_t))
-
-enum ReadWriteFlag {
-  kAndroidLoggerRead = 1,
-  kAndroidLoggerWrite = 2,
-};
-
-struct android_log_context_internal {
-  uint32_t tag;
-  unsigned pos;                                    /* Read/write position into buffer */
-  unsigned count[ANDROID_MAX_LIST_NEST_DEPTH + 1]; /* Number of elements   */
-  unsigned list[ANDROID_MAX_LIST_NEST_DEPTH + 1];  /* pos for list counter */
-  unsigned list_nest_depth;
-  unsigned len; /* Length or raw buffer. */
-  bool overflow;
-  bool list_stop; /* next call decrement list_nest_depth and issue a stop */
-  ReadWriteFlag read_write_flag;
-  uint8_t storage[LOGGER_ENTRY_MAX_PAYLOAD];
-};
-
-static void init_context(android_log_context_internal* context, uint32_t tag) {
-  context->tag = tag;
-  context->read_write_flag = kAndroidLoggerWrite;
-  size_t needed = sizeof(android_event_list_t);
-  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-    context->overflow = true;
-  }
-  /* Everything is a list */
-  context->storage[context->pos + 0] = EVENT_TYPE_LIST;
-  context->list[0] = context->pos + 1;
-  context->pos += needed;
-}
-
-static void init_parser_context(android_log_context_internal* context, const char* msg,
-                                size_t len) {
-  len = (len <= MAX_EVENT_PAYLOAD) ? len : MAX_EVENT_PAYLOAD;
-  context->len = len;
-  memcpy(context->storage, msg, len);
-  context->read_write_flag = kAndroidLoggerRead;
-}
-
-android_log_context create_android_logger(uint32_t tag) {
-  android_log_context_internal* context;
-
-  context =
-      static_cast<android_log_context_internal*>(calloc(1, sizeof(android_log_context_internal)));
-  if (!context) {
-    return NULL;
-  }
-  init_context(context, tag);
-
-  return (android_log_context)context;
-}
-
-android_log_context create_android_log_parser(const char* msg, size_t len) {
-  android_log_context_internal* context;
-
-  context =
-      static_cast<android_log_context_internal*>(calloc(1, sizeof(android_log_context_internal)));
-  if (!context) {
-    return NULL;
-  }
-  init_parser_context(context, msg, len);
-
-  return (android_log_context)context;
-}
-
-int android_log_destroy(android_log_context* ctx) {
-  android_log_context_internal* context;
-
-  context = (android_log_context_internal*)*ctx;
-  if (!context) {
-    return -EBADF;
-  }
-  memset(context, 0, sizeof(*context));
-  free(context);
-  *ctx = NULL;
-  return 0;
-}
-
-int android_log_reset(android_log_context context) {
-  uint32_t tag;
-
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-
-  tag = context->tag;
-  memset(context, 0, sizeof(*context));
-  init_context(context, tag);
-
-  return 0;
-}
-
-int android_log_parser_reset(android_log_context context, const char* msg, size_t len) {
-  if (!context || (kAndroidLoggerRead != context->read_write_flag)) {
-    return -EBADF;
-  }
-
-  memset(context, 0, sizeof(*context));
-  init_parser_context(context, msg, len);
-
-  return 0;
-}
-
-int android_log_write_list_begin(android_log_context context) {
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
-    context->overflow = true;
-    return -EOVERFLOW;
-  }
-  size_t needed = sizeof(android_event_list_t);
-  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-    context->overflow = true;
-    return -EIO;
-  }
-  context->count[context->list_nest_depth]++;
-  context->list_nest_depth++;
-  if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
-    context->overflow = true;
-    return -EOVERFLOW;
-  }
-  if (context->overflow) {
-    return -EIO;
-  }
-  auto* event_list = reinterpret_cast<android_event_list_t*>(&context->storage[context->pos]);
-  event_list->type = EVENT_TYPE_LIST;
-  event_list->element_count = 0;
-  context->list[context->list_nest_depth] = context->pos + 1;
-  context->count[context->list_nest_depth] = 0;
-  context->pos += needed;
-  return 0;
-}
-
-int android_log_write_int32(android_log_context context, int32_t value) {
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->overflow) {
-    return -EIO;
-  }
-  size_t needed = sizeof(android_event_int_t);
-  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-    context->overflow = true;
-    return -EIO;
-  }
-  context->count[context->list_nest_depth]++;
-  auto* event_int = reinterpret_cast<android_event_int_t*>(&context->storage[context->pos]);
-  event_int->type = EVENT_TYPE_INT;
-  event_int->data = value;
-  context->pos += needed;
-  return 0;
-}
-
-int android_log_write_int64(android_log_context context, int64_t value) {
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->overflow) {
-    return -EIO;
-  }
-  size_t needed = sizeof(android_event_long_t);
-  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-    context->overflow = true;
-    return -EIO;
-  }
-  context->count[context->list_nest_depth]++;
-  auto* event_long = reinterpret_cast<android_event_long_t*>(&context->storage[context->pos]);
-  event_long->type = EVENT_TYPE_LONG;
-  event_long->data = value;
-  context->pos += needed;
-  return 0;
-}
-
-int android_log_write_string8_len(android_log_context context, const char* value, size_t maxlen) {
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->overflow) {
-    return -EIO;
-  }
-  if (!value) {
-    value = "";
-  }
-  int32_t len = strnlen(value, maxlen);
-  size_t needed = sizeof(android_event_string_t) + len;
-  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-    /* Truncate string for delivery */
-    len = MAX_EVENT_PAYLOAD - context->pos - 1 - sizeof(int32_t);
-    if (len <= 0) {
-      context->overflow = true;
-      return -EIO;
-    }
-  }
-  context->count[context->list_nest_depth]++;
-  auto* event_string = reinterpret_cast<android_event_string_t*>(&context->storage[context->pos]);
-  event_string->type = EVENT_TYPE_STRING;
-  event_string->length = len;
-  if (len) {
-    memcpy(&event_string->data, value, len);
-  }
-  context->pos += needed;
-  return len;
-}
-
-int android_log_write_string8(android_log_context ctx, const char* value) {
-  return android_log_write_string8_len(ctx, value, MAX_EVENT_PAYLOAD);
-}
-
-int android_log_write_float32(android_log_context context, float value) {
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->overflow) {
-    return -EIO;
-  }
-  size_t needed = sizeof(android_event_float_t);
-  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-    context->overflow = true;
-    return -EIO;
-  }
-  context->count[context->list_nest_depth]++;
-  auto* event_float = reinterpret_cast<android_event_float_t*>(&context->storage[context->pos]);
-  event_float->type = EVENT_TYPE_FLOAT;
-  event_float->data = value;
-  context->pos += needed;
-  return 0;
-}
-
-int android_log_write_list_end(android_log_context context) {
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
-    context->overflow = true;
-    context->list_nest_depth--;
-    return -EOVERFLOW;
-  }
-  if (!context->list_nest_depth) {
-    context->overflow = true;
-    return -EOVERFLOW;
-  }
-  if (context->list[context->list_nest_depth] <= 0) {
-    context->list_nest_depth--;
-    context->overflow = true;
-    return -EOVERFLOW;
-  }
-  context->storage[context->list[context->list_nest_depth]] =
-      context->count[context->list_nest_depth];
-  context->list_nest_depth--;
-  return 0;
-}
-
-/*
- * Logs the list of elements to the event log.
- */
-int android_log_write_list(android_log_context context, log_id_t id) {
-  const char* msg;
-  ssize_t len;
-
-  if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY) && (id != LOG_ID_STATS)) {
-    return -EINVAL;
-  }
-
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->list_nest_depth) {
-    return -EIO;
-  }
-  /* NB: if there was overflow, then log is truncated. Nothing reported */
-  context->storage[1] = context->count[0];
-  len = context->len = context->pos;
-  msg = (const char*)context->storage;
-  /* it's not a list */
-  if (context->count[0] <= 1) {
-    len -= sizeof(uint8_t) + sizeof(uint8_t);
-    if (len < 0) {
-      len = 0;
-    }
-    msg += sizeof(uint8_t) + sizeof(uint8_t);
-  }
-  return (id == LOG_ID_EVENTS)
-             ? __android_log_bwrite(context->tag, msg, len)
-             : ((id == LOG_ID_STATS) ? __android_log_stats_bwrite(context->tag, msg, len)
-                                     : __android_log_security_bwrite(context->tag, msg, len));
-}
-
-int android_log_write_list_buffer(android_log_context context, const char** buffer) {
-  const char* msg;
-  ssize_t len;
-
-  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-    return -EBADF;
-  }
-  if (context->list_nest_depth) {
-    return -EIO;
-  }
-  if (buffer == NULL) {
-    return -EFAULT;
-  }
-  /* NB: if there was overflow, then log is truncated. Nothing reported */
-  context->storage[1] = context->count[0];
-  len = context->len = context->pos;
-  msg = (const char*)context->storage;
-  /* it's not a list */
-  if (context->count[0] <= 1) {
-    len -= sizeof(uint8_t) + sizeof(uint8_t);
-    if (len < 0) {
-      len = 0;
-    }
-    msg += sizeof(uint8_t) + sizeof(uint8_t);
-  }
-  *buffer = msg;
-  return len;
-}
-
-/*
- * Gets the next element. Parsing errors result in an EVENT_TYPE_UNKNOWN type.
- * If there is nothing to process, the complete field is set to non-zero. If
- * an EVENT_TYPE_UNKNOWN type is returned once, and the caller does not check
- * this and continues to call this function, the behavior is undefined
- * (although it won't crash).
- */
-static android_log_list_element android_log_read_next_internal(android_log_context context,
-                                                               int peek) {
-  android_log_list_element elem;
-  unsigned pos;
-
-  memset(&elem, 0, sizeof(elem));
-
-  /* Nothing to parse from this context, so return complete. */
-  if (!context || (kAndroidLoggerRead != context->read_write_flag) ||
-      (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) ||
-      (context->count[context->list_nest_depth] >=
-       (MAX_EVENT_PAYLOAD / (sizeof(uint8_t) + sizeof(uint8_t))))) {
-    elem.type = EVENT_TYPE_UNKNOWN;
-    if (context &&
-        (context->list_stop || ((context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) &&
-                                !context->count[context->list_nest_depth]))) {
-      elem.type = EVENT_TYPE_LIST_STOP;
-    }
-    elem.complete = true;
-    return elem;
-  }
-
-  /*
-   * Use a different variable to update the position in case this
-   * operation is a "peek".
-   */
-  pos = context->pos;
-  if (context->list_stop) {
-    elem.type = EVENT_TYPE_LIST_STOP;
-    elem.complete = !context->count[0] && (!context->list_nest_depth ||
-                                           ((context->list_nest_depth == 1) && !context->count[1]));
-    if (!peek) {
-      /* Suck in superfluous stop */
-      if (context->storage[pos] == EVENT_TYPE_LIST_STOP) {
-        context->pos = pos + 1;
-      }
-      if (context->list_nest_depth) {
-        --context->list_nest_depth;
-        if (context->count[context->list_nest_depth]) {
-          context->list_stop = false;
-        }
-      } else {
-        context->list_stop = false;
-      }
-    }
-    return elem;
-  }
-  if ((pos + 1) > context->len) {
-    elem.type = EVENT_TYPE_UNKNOWN;
-    elem.complete = true;
-    return elem;
-  }
-
-  elem.type = static_cast<AndroidEventLogType>(context->storage[pos]);
-  switch ((int)elem.type) {
-    case EVENT_TYPE_FLOAT:
-    /* Rely on union to translate elem.data.int32 into elem.data.float32 */
-    /* FALLTHRU */
-    case EVENT_TYPE_INT: {
-      elem.len = sizeof(int32_t);
-      if ((pos + sizeof(android_event_int_t)) > context->len) {
-        elem.type = EVENT_TYPE_UNKNOWN;
-        return elem;
-      }
-
-      auto* event_int = reinterpret_cast<android_event_int_t*>(&context->storage[pos]);
-      pos += sizeof(android_event_int_t);
-      elem.data.int32 = event_int->data;
-      /* common tangeable object suffix */
-      elem.complete = !context->list_nest_depth && !context->count[0];
-      if (!peek) {
-        if (!context->count[context->list_nest_depth] ||
-            !--(context->count[context->list_nest_depth])) {
-          context->list_stop = true;
-        }
-        context->pos = pos;
-      }
-      return elem;
-    }
-
-    case EVENT_TYPE_LONG: {
-      elem.len = sizeof(int64_t);
-      if ((pos + sizeof(android_event_long_t)) > context->len) {
-        elem.type = EVENT_TYPE_UNKNOWN;
-        return elem;
-      }
-
-      auto* event_long = reinterpret_cast<android_event_long_t*>(&context->storage[pos]);
-      pos += sizeof(android_event_long_t);
-      elem.data.int64 = event_long->data;
-      /* common tangeable object suffix */
-      elem.complete = !context->list_nest_depth && !context->count[0];
-      if (!peek) {
-        if (!context->count[context->list_nest_depth] ||
-            !--(context->count[context->list_nest_depth])) {
-          context->list_stop = true;
-        }
-        context->pos = pos;
-      }
-      return elem;
-    }
-
-    case EVENT_TYPE_STRING: {
-      if ((pos + sizeof(android_event_string_t)) > context->len) {
-        elem.type = EVENT_TYPE_UNKNOWN;
-        elem.complete = true;
-        return elem;
-      }
-      auto* event_string = reinterpret_cast<android_event_string_t*>(&context->storage[pos]);
-      pos += sizeof(android_event_string_t);
-      // Wire format is int32_t, but elem.len is uint16_t...
-      if (event_string->length >= UINT16_MAX) {
-        elem.type = EVENT_TYPE_UNKNOWN;
-        return elem;
-      }
-      elem.len = event_string->length;
-      if ((pos + elem.len) > context->len) {
-        elem.len = context->len - pos; /* truncate string */
-        elem.complete = true;
-        if (!elem.len) {
-          elem.type = EVENT_TYPE_UNKNOWN;
-          return elem;
-        }
-      }
-      elem.data.string = event_string->data;
-      /* common tangeable object suffix */
-      pos += elem.len;
-      elem.complete = !context->list_nest_depth && !context->count[0];
-      if (!peek) {
-        if (!context->count[context->list_nest_depth] ||
-            !--(context->count[context->list_nest_depth])) {
-          context->list_stop = true;
-        }
-        context->pos = pos;
-      }
-      return elem;
-    }
-
-    case EVENT_TYPE_LIST: {
-      if ((pos + sizeof(android_event_list_t)) > context->len) {
-        elem.type = EVENT_TYPE_UNKNOWN;
-        elem.complete = true;
-        return elem;
-      }
-      auto* event_list = reinterpret_cast<android_event_list_t*>(&context->storage[pos]);
-      pos += sizeof(android_event_list_t);
-      elem.complete = context->list_nest_depth >= ANDROID_MAX_LIST_NEST_DEPTH;
-      if (peek) {
-        return elem;
-      }
-      if (context->count[context->list_nest_depth]) {
-        context->count[context->list_nest_depth]--;
-      }
-      context->list_stop = event_list->element_count == 0;
-      context->list_nest_depth++;
-      if (context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) {
-        context->count[context->list_nest_depth] = event_list->element_count;
-      }
-      context->pos = pos;
-      return elem;
-    }
-
-    case EVENT_TYPE_LIST_STOP: /* Suprise Newline terminates lists. */
-      pos++;
-      if (!peek) {
-        context->pos = pos;
-      }
-      elem.type = EVENT_TYPE_UNKNOWN;
-      elem.complete = !context->list_nest_depth;
-      if (context->list_nest_depth > 0) {
-        elem.type = EVENT_TYPE_LIST_STOP;
-        if (!peek) {
-          context->list_nest_depth--;
-        }
-      }
-      return elem;
-
-    default:
-      elem.type = EVENT_TYPE_UNKNOWN;
-      return elem;
-  }
-}
-
-android_log_list_element android_log_read_next(android_log_context ctx) {
-  return android_log_read_next_internal(ctx, 0);
-}
-
-android_log_list_element android_log_peek_next(android_log_context ctx) {
-  return android_log_read_next_internal(ctx, 1);
-}
diff --git a/liblog/log_event_write.cpp b/liblog/log_event_write.cpp
deleted file mode 100644
index 39afd0c..0000000
--- a/liblog/log_event_write.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-#include <errno.h>
-#include <stdint.h>
-
-#include <log/log.h>
-#include <log/log_event_list.h>
-
-#define MAX_SUBTAG_LEN 32
-
-int __android_log_error_write(int tag, const char* subTag, int32_t uid, const char* data,
-                              uint32_t dataLen) {
-  int ret = -EINVAL;
-
-  if (subTag && (data || !dataLen)) {
-    android_log_context ctx = create_android_logger(tag);
-
-    ret = -ENOMEM;
-    if (ctx) {
-      ret = android_log_write_string8_len(ctx, subTag, MAX_SUBTAG_LEN);
-      if (ret >= 0) {
-        ret = android_log_write_int32(ctx, uid);
-        if (ret >= 0) {
-          ret = android_log_write_string8_len(ctx, data, dataLen);
-          if (ret >= 0) {
-            ret = android_log_write_list(ctx, LOG_ID_EVENTS);
-          }
-        }
-      }
-      android_log_destroy(&ctx);
-    }
-  }
-  return ret;
-}
diff --git a/liblog/log_time.cpp b/liblog/log_time.cpp
deleted file mode 100644
index 14c408c..0000000
--- a/liblog/log_time.cpp
+++ /dev/null
@@ -1,129 +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 <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <private/android_logger.h>
-
-// Add %#q for fractional seconds to standard strptime function
-char* log_time::strptime(const char* s, const char* format) {
-  time_t now;
-#ifdef __linux__
-  *this = log_time(CLOCK_REALTIME);
-  now = tv_sec;
-#else
-  time(&now);
-  tv_sec = now;
-  tv_nsec = 0;
-#endif
-
-  struct tm* ptm;
-#if !defined(_WIN32)
-  struct tm tmBuf;
-  ptm = localtime_r(&now, &tmBuf);
-#else
-  ptm = localtime(&now);
-#endif
-
-  char fmt[strlen(format) + 1];
-  strcpy(fmt, format);
-
-  char* ret = const_cast<char*>(s);
-  char* cp;
-  for (char* f = cp = fmt;; ++cp) {
-    if (!*cp) {
-      if (f != cp) {
-        ret = ::strptime(ret, f, ptm);
-      }
-      break;
-    }
-    if (*cp != '%') {
-      continue;
-    }
-    char* e = cp;
-    ++e;
-#if (defined(__BIONIC__))
-    if (*e == 's') {
-      *cp = '\0';
-      if (*f) {
-        ret = ::strptime(ret, f, ptm);
-        if (!ret) {
-          break;
-        }
-      }
-      tv_sec = 0;
-      while (isdigit(*ret)) {
-        tv_sec = tv_sec * 10 + *ret - '0';
-        ++ret;
-      }
-      now = tv_sec;
-#if !defined(_WIN32)
-      ptm = localtime_r(&now, &tmBuf);
-#else
-      ptm = localtime(&now);
-#endif
-    } else
-#endif
-    {
-      unsigned num = 0;
-      while (isdigit(*e)) {
-        num = num * 10 + *e - '0';
-        ++e;
-      }
-      if (*e != 'q') {
-        continue;
-      }
-      *cp = '\0';
-      if (*f) {
-        ret = ::strptime(ret, f, ptm);
-        if (!ret) {
-          break;
-        }
-      }
-      unsigned long mul = NS_PER_SEC;
-      if (num == 0) {
-        num = INT_MAX;
-      }
-      tv_nsec = 0;
-      while (isdigit(*ret) && num && (mul > 1)) {
-        --num;
-        mul /= 10;
-        tv_nsec = tv_nsec + (*ret - '0') * mul;
-        ++ret;
-      }
-    }
-    f = cp = e;
-    ++f;
-  }
-
-  if (ret) {
-    tv_sec = mktime(ptm);
-    return ret;
-  }
-
-// Upon error, place a known value into the class, the current time.
-#ifdef __linux__
-  *this = log_time(CLOCK_REALTIME);
-#else
-  time(&now);
-  tv_sec = now;
-  tv_nsec = 0;
-#endif
-  return ret;
-}
diff --git a/liblog/logd_reader.cpp b/liblog/logd_reader.cpp
deleted file mode 100644
index 611caed..0000000
--- a/liblog/logd_reader.cpp
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright (C) 2007-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 "logd_reader.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <poll.h>
-#include <stdarg.h>
-#include <stdatomic.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <string>
-
-#include <android-base/parseint.h>
-#include <private/android_logger.h>
-
-#include "logger.h"
-
-// Connects to /dev/socket/<name> and returns the associated fd or returns -1 on error.
-// O_CLOEXEC is always set.
-static int socket_local_client(const std::string& name, int type, bool timeout) {
-  sockaddr_un addr = {.sun_family = AF_LOCAL};
-
-  std::string path = "/dev/socket/" + name;
-  if (path.size() + 1 > sizeof(addr.sun_path)) {
-    return -1;
-  }
-  strlcpy(addr.sun_path, path.c_str(), sizeof(addr.sun_path));
-
-  int fd = socket(AF_LOCAL, type | SOCK_CLOEXEC, 0);
-  if (fd == -1) {
-    return -1;
-  }
-
-  if (timeout) {
-    // Sending and receiving messages should be instantaneous, but we don't want to wait forever if
-    // logd is hung, so we set a gracious 2s timeout.
-    struct timeval t = {2, 0};
-    if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &t, sizeof(t)) == -1) {
-      return -1;
-    }
-    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &t, sizeof(t)) == -1) {
-      return -1;
-    }
-  }
-
-  if (connect(fd, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1) {
-    close(fd);
-    return -1;
-  }
-
-  return fd;
-}
-
-/* worker for sending the command to the logger */
-ssize_t SendLogdControlMessage(char* buf, size_t buf_size) {
-  ssize_t ret;
-  size_t len;
-  char* cp;
-  int errno_save = 0;
-  int sock = socket_local_client("logd", SOCK_STREAM, true);
-  if (sock < 0) {
-    return sock;
-  }
-
-  len = strlen(buf) + 1;
-  ret = TEMP_FAILURE_RETRY(write(sock, buf, len));
-  if (ret <= 0) {
-    goto done;
-  }
-
-  len = buf_size;
-  cp = buf;
-  while ((ret = TEMP_FAILURE_RETRY(read(sock, cp, len))) > 0) {
-    struct pollfd p;
-
-    if (((size_t)ret == len) || (buf_size < PAGE_SIZE)) {
-      break;
-    }
-
-    len -= ret;
-    cp += ret;
-
-    memset(&p, 0, sizeof(p));
-    p.fd = sock;
-    p.events = POLLIN;
-
-    /* Give other side 20ms to refill pipe */
-    ret = TEMP_FAILURE_RETRY(poll(&p, 1, 20));
-
-    if (ret <= 0) {
-      break;
-    }
-
-    if (!(p.revents & POLLIN)) {
-      ret = 0;
-      break;
-    }
-  }
-
-  if (ret >= 0) {
-    ret += buf_size - len;
-  }
-
-done:
-  if ((ret == -1) && errno) {
-    errno_save = errno;
-  }
-  close(sock);
-  if (errno_save) {
-    errno = errno_save;
-  }
-  return ret;
-}
-
-static int check_log_success(char* buf, ssize_t ret) {
-  if (ret < 0) {
-    return ret;
-  }
-
-  if (strncmp(buf, "success", 7)) {
-    errno = EINVAL;
-    return -1;
-  }
-
-  return 0;
-}
-
-int android_logger_clear(struct logger* logger) {
-  if (!android_logger_is_logd(logger)) {
-    return -EINVAL;
-  }
-  uint32_t log_id = android_logger_get_id(logger);
-  char buf[512];
-  snprintf(buf, sizeof(buf), "clear %" PRIu32, log_id);
-
-  return check_log_success(buf, SendLogdControlMessage(buf, sizeof(buf)));
-}
-
-enum class LogSizeType : uint32_t {
-  kAllotted = 0,
-  kReadable,
-  kConsumed,
-};
-
-static long GetLogSize(struct logger* logger, LogSizeType type) {
-  if (!android_logger_is_logd(logger)) {
-    return -EINVAL;
-  }
-
-  uint32_t log_id = android_logger_get_id(logger);
-  char buf[512];
-  switch (type) {
-    case LogSizeType::kAllotted:
-      snprintf(buf, sizeof(buf), "getLogSize %" PRIu32, log_id);
-      break;
-    case LogSizeType::kReadable:
-      snprintf(buf, sizeof(buf), "getLogSizeReadable %" PRIu32, log_id);
-      break;
-    case LogSizeType::kConsumed:
-      snprintf(buf, sizeof(buf), "getLogSizeUsed %" PRIu32, log_id);
-      break;
-    default:
-      abort();
-  }
-
-  ssize_t ret = SendLogdControlMessage(buf, sizeof(buf));
-  if (ret < 0) {
-    return ret;
-  }
-
-  long size;
-  if (!android::base::ParseInt(buf, &size)) {
-    return -1;
-  }
-
-  return size;
-}
-
-long android_logger_get_log_size(struct logger* logger) {
-  return GetLogSize(logger, LogSizeType::kAllotted);
-}
-
-long android_logger_get_log_readable_size(struct logger* logger) {
-  return GetLogSize(logger, LogSizeType::kReadable);
-}
-
-long android_logger_get_log_consumed_size(struct logger* logger) {
-  return GetLogSize(logger, LogSizeType::kConsumed);
-}
-
-int android_logger_set_log_size(struct logger* logger, unsigned long size) {
-  if (!android_logger_is_logd(logger)) {
-    return -EINVAL;
-  }
-
-  uint32_t log_id = android_logger_get_id(logger);
-  char buf[512];
-  snprintf(buf, sizeof(buf), "setLogSize %" PRIu32 " %lu", log_id, size);
-
-  return check_log_success(buf, SendLogdControlMessage(buf, sizeof(buf)));
-}
-
-int android_logger_get_log_version(struct logger*) {
-  return 4;
-}
-
-ssize_t android_logger_get_statistics(struct logger_list* logger_list, char* buf, size_t len) {
-  if (logger_list->mode & ANDROID_LOG_PSTORE) {
-    return -EINVAL;
-  }
-
-  char* cp = buf;
-  size_t remaining = len;
-  size_t n;
-
-  n = snprintf(cp, remaining, "getStatistics");
-  n = MIN(n, remaining);
-  remaining -= n;
-  cp += n;
-
-  for (size_t log_id = 0; log_id < LOG_ID_MAX; ++log_id) {
-    if ((1 << log_id) & logger_list->log_mask) {
-      n = snprintf(cp, remaining, " %zu", log_id);
-      n = MIN(n, remaining);
-      remaining -= n;
-      cp += n;
-    }
-  }
-
-  if (logger_list->pid) {
-    snprintf(cp, remaining, " pid=%u", logger_list->pid);
-  }
-
-  return SendLogdControlMessage(buf, len);
-}
-ssize_t android_logger_get_prune_list(struct logger_list* logger_list, char* buf, size_t len) {
-  if (logger_list->mode & ANDROID_LOG_PSTORE) {
-    return -EINVAL;
-  }
-
-  snprintf(buf, len, "getPruneList");
-  return SendLogdControlMessage(buf, len);
-}
-
-int android_logger_set_prune_list(struct logger_list* logger_list, const char* buf, size_t len) {
-  if (logger_list->mode & ANDROID_LOG_PSTORE) {
-    return -EINVAL;
-  }
-
-  std::string cmd = "setPruneList " + std::string{buf, len};
-
-  return check_log_success(cmd.data(), SendLogdControlMessage(cmd.data(), cmd.size()));
-}
-
-static int logdOpen(struct logger_list* logger_list) {
-  char buffer[256], *cp, c;
-  int ret, remaining, sock;
-
-  sock = atomic_load(&logger_list->fd);
-  if (sock > 0) {
-    return sock;
-  }
-
-  sock = socket_local_client("logdr", SOCK_SEQPACKET, false);
-  if (sock <= 0) {
-    if ((sock == -1) && errno) {
-      return -errno;
-    }
-    return sock;
-  }
-
-  strcpy(buffer, (logger_list->mode & ANDROID_LOG_NONBLOCK) ? "dumpAndClose" : "stream");
-  cp = buffer + strlen(buffer);
-
-  strcpy(cp, " lids");
-  cp += 5;
-  c = '=';
-  remaining = sizeof(buffer) - (cp - buffer);
-
-  for (size_t log_id = 0; log_id < LOG_ID_MAX; ++log_id) {
-    if ((1 << log_id) & logger_list->log_mask) {
-      ret = snprintf(cp, remaining, "%c%zu", c, log_id);
-      ret = MIN(ret, remaining);
-      remaining -= ret;
-      cp += ret;
-      c = ',';
-    }
-  }
-
-  if (logger_list->tail) {
-    ret = snprintf(cp, remaining, " tail=%u", logger_list->tail);
-    ret = MIN(ret, remaining);
-    remaining -= ret;
-    cp += ret;
-  }
-
-  if (logger_list->start.tv_sec || logger_list->start.tv_nsec) {
-    if (logger_list->mode & ANDROID_LOG_WRAP) {
-      // ToDo: alternate API to allow timeout to be adjusted.
-      ret = snprintf(cp, remaining, " timeout=%u", ANDROID_LOG_WRAP_DEFAULT_TIMEOUT);
-      ret = MIN(ret, remaining);
-      remaining -= ret;
-      cp += ret;
-    }
-    ret = snprintf(cp, remaining, " start=%" PRIu32 ".%09" PRIu32, logger_list->start.tv_sec,
-                   logger_list->start.tv_nsec);
-    ret = MIN(ret, remaining);
-    remaining -= ret;
-    cp += ret;
-  }
-
-  if (logger_list->pid) {
-    ret = snprintf(cp, remaining, " pid=%u", logger_list->pid);
-    ret = MIN(ret, remaining);
-    cp += ret;
-  }
-
-  ret = TEMP_FAILURE_RETRY(write(sock, buffer, cp - buffer));
-  int write_errno = errno;
-
-  if (ret <= 0) {
-    close(sock);
-    if (ret == -1) {
-      return -write_errno;
-    }
-    if (ret == 0) {
-      return -EIO;
-    }
-    return ret;
-  }
-
-  ret = atomic_exchange(&logger_list->fd, sock);
-  if ((ret > 0) && (ret != sock)) {
-    close(ret);
-  }
-  return sock;
-}
-
-/* Read from the selected logs */
-int LogdRead(struct logger_list* logger_list, struct log_msg* log_msg) {
-  int ret = logdOpen(logger_list);
-  if (ret < 0) {
-    return ret;
-  }
-
-  /* NOTE: SOCK_SEQPACKET guarantees we read exactly one full entry */
-  ret = TEMP_FAILURE_RETRY(recv(ret, log_msg, LOGGER_ENTRY_MAX_LEN, 0));
-  if ((logger_list->mode & ANDROID_LOG_NONBLOCK) && ret == 0) {
-    return -EAGAIN;
-  }
-
-  if (ret == -1) {
-    return -errno;
-  }
-  return ret;
-}
-
-/* Close all the logs */
-void LogdClose(struct logger_list* logger_list) {
-  int sock = atomic_exchange(&logger_list->fd, -1);
-  if (sock > 0) {
-    close(sock);
-  }
-}
diff --git a/liblog/logd_reader.h b/liblog/logd_reader.h
deleted file mode 100644
index 68eef02..0000000
--- a/liblog/logd_reader.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 <sys/cdefs.h>
-#include <unistd.h>
-
-#include "log/log_read.h"
-
-__BEGIN_DECLS
-
-int LogdRead(struct logger_list* logger_list, struct log_msg* log_msg);
-void LogdClose(struct logger_list* logger_list);
-
-ssize_t SendLogdControlMessage(char* buf, size_t buf_size);
-
-__END_DECLS
diff --git a/liblog/logd_writer.cpp b/liblog/logd_writer.cpp
deleted file mode 100644
index f5d19ca..0000000
--- a/liblog/logd_writer.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2007-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 "logd_writer.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <poll.h>
-#include <stdarg.h>
-#include <stdatomic.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-
-#include "logger.h"
-#include "uio.h"
-
-static atomic_int logd_socket;
-
-// Note that it is safe to call connect() multiple times on DGRAM Unix domain sockets, so this
-// function is used to reconnect to logd without requiring a new socket.
-static void LogdConnect() {
-  sockaddr_un un = {};
-  un.sun_family = AF_UNIX;
-  strcpy(un.sun_path, "/dev/socket/logdw");
-  TEMP_FAILURE_RETRY(connect(logd_socket, reinterpret_cast<sockaddr*>(&un), sizeof(sockaddr_un)));
-}
-
-// logd_socket should only be opened once.  If we see that logd_socket is uninitialized, we create a
-// new socket and attempt to exchange it into the atomic logd_socket.  If the compare/exchange was
-// successful, then that will be the socket used for the duration of the program, otherwise a
-// different thread has already opened and written the socket to the atomic, so close the new socket
-// and return.
-static void GetSocket() {
-  if (logd_socket != 0) {
-    return;
-  }
-
-  int new_socket = TEMP_FAILURE_RETRY(socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0));
-  if (new_socket <= 0) {
-    return;
-  }
-
-  int uninitialized_value = 0;
-  if (!logd_socket.compare_exchange_strong(uninitialized_value, new_socket)) {
-    close(new_socket);
-    return;
-  }
-
-  LogdConnect();
-}
-
-// This is the one exception to the above.  Zygote uses this to clean up open FD's after fork() and
-// before specialization.  It is single threaded at this point and therefore this function is
-// explicitly not thread safe.  It sets logd_socket to 0, so future logs will be safely initialized
-// whenever they happen.
-void LogdClose() {
-  if (logd_socket > 0) {
-    close(logd_socket);
-  }
-  logd_socket = 0;
-}
-
-int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
-  ssize_t ret;
-  static const unsigned headerLength = 1;
-  struct iovec newVec[nr + headerLength];
-  android_log_header_t header;
-  size_t i, payloadSize;
-
-  GetSocket();
-
-  if (logd_socket <= 0) {
-    return -EBADF;
-  }
-
-  /* logd, after initialization and priv drop */
-  if (getuid() == AID_LOGD) {
-    /*
-     * ignore log messages we send to ourself (logd).
-     * Such log messages are often generated by libraries we depend on
-     * which use standard Android logging.
-     */
-    return 0;
-  }
-
-  header.id = logId;
-  header.tid = gettid();
-  header.realtime.tv_sec = ts->tv_sec;
-  header.realtime.tv_nsec = ts->tv_nsec;
-
-  newVec[0].iov_base = (unsigned char*)&header;
-  newVec[0].iov_len = sizeof(header);
-
-  for (payloadSize = 0, i = headerLength; i < nr + headerLength; i++) {
-    newVec[i].iov_base = vec[i - headerLength].iov_base;
-    payloadSize += newVec[i].iov_len = vec[i - headerLength].iov_len;
-
-    if (payloadSize > LOGGER_ENTRY_MAX_PAYLOAD) {
-      newVec[i].iov_len -= payloadSize - LOGGER_ENTRY_MAX_PAYLOAD;
-      if (newVec[i].iov_len) {
-        ++i;
-      }
-      break;
-    }
-  }
-
-  ret = TEMP_FAILURE_RETRY(writev(logd_socket, newVec, i));
-  if (ret < 0) {
-    LogdConnect();
-
-    ret = TEMP_FAILURE_RETRY(writev(logd_socket, newVec, i));
-  }
-
-  if (ret < 0) {
-    ret = -errno;
-  }
-
-  return ret;
-}
diff --git a/liblog/logd_writer.h b/liblog/logd_writer.h
deleted file mode 100644
index 41197b5..0000000
--- a/liblog/logd_writer.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2020 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 <stddef.h>
-
-#include <android/log.h>
-
-int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
-void LogdClose();
diff --git a/liblog/logger.h b/liblog/logger.h
deleted file mode 100644
index ddff19d..0000000
--- a/liblog/logger.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 <stdatomic.h>
-#include <sys/cdefs.h>
-
-#include <log/log.h>
-
-#include "uio.h"
-
-__BEGIN_DECLS
-
-struct logger_list {
-  atomic_int fd;
-  int mode;
-  unsigned int tail;
-  log_time start;
-  pid_t pid;
-  uint32_t log_mask;
-};
-
-// Format for a 'logger' entry: uintptr_t where only the bottom 32 bits are used.
-// bit 31: Set if this 'logger' is for logd.
-// bit 30: Set if this 'logger' is for pmsg
-// bits 0-2: the decimal value of the log buffer.
-// Other bits are unused.
-
-#define LOGGER_LOGD (1U << 31)
-#define LOGGER_PMSG (1U << 30)
-#define LOGGER_LOG_ID_MASK ((1U << 3) - 1)
-
-inline bool android_logger_is_logd(struct logger* logger) {
-  return reinterpret_cast<uintptr_t>(logger) & LOGGER_LOGD;
-}
-
-__END_DECLS
diff --git a/liblog/logger_name.cpp b/liblog/logger_name.cpp
deleted file mode 100644
index e72290e..0000000
--- a/liblog/logger_name.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-** Copyright 2013-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 <string.h>
-#include <type_traits>
-
-#include <log/log.h>
-
-/* In the future, we would like to make this list extensible */
-static const char* LOG_NAME[LOG_ID_MAX] = {
-    /* clang-format off */
-  [LOG_ID_MAIN] = "main",
-  [LOG_ID_RADIO] = "radio",
-  [LOG_ID_EVENTS] = "events",
-  [LOG_ID_SYSTEM] = "system",
-  [LOG_ID_CRASH] = "crash",
-  [LOG_ID_STATS] = "stats",
-  [LOG_ID_SECURITY] = "security",
-  [LOG_ID_KERNEL] = "kernel",
-    /* clang-format on */
-};
-
-const char* android_log_id_to_name(log_id_t log_id) {
-  if (log_id >= LOG_ID_MAX) {
-    log_id = LOG_ID_MAIN;
-  }
-  return LOG_NAME[log_id];
-}
-
-static_assert(std::is_same<std::underlying_type<log_id_t>::type, uint32_t>::value,
-              "log_id_t must be an uint32_t");
-
-static_assert(std::is_same<std::underlying_type<android_LogPriority>::type, uint32_t>::value,
-              "log_id_t must be an uint32_t");
-
-log_id_t android_name_to_log_id(const char* logName) {
-  const char* b;
-  unsigned int ret;
-
-  if (!logName) {
-    return static_cast<log_id_t>(LOG_ID_MAX);
-  }
-
-  b = strrchr(logName, '/');
-  if (!b) {
-    b = logName;
-  } else {
-    ++b;
-  }
-
-  for (ret = LOG_ID_MIN; ret < LOG_ID_MAX; ++ret) {
-    const char* l = LOG_NAME[ret];
-    if (l && !strcmp(b, l)) {
-      return static_cast<log_id_t>(ret);
-    }
-  }
-
-  return static_cast<log_id_t>(LOG_ID_MAX);
-}
diff --git a/liblog/logger_read.cpp b/liblog/logger_read.cpp
deleted file mode 100644
index 4937042..0000000
--- a/liblog/logger_read.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-** Copyright 2013-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 "log/log_read.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <sched.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <android/log.h>
-
-#include "logd_reader.h"
-#include "logger.h"
-#include "pmsg_reader.h"
-
-/* method for getting the associated sublog id */
-log_id_t android_logger_get_id(struct logger* logger) {
-  return static_cast<log_id_t>(reinterpret_cast<uintptr_t>(logger) & LOGGER_LOG_ID_MASK);
-}
-
-static struct logger_list* android_logger_list_alloc_internal(int mode, unsigned int tail,
-                                                              log_time start, pid_t pid) {
-  auto* logger_list = static_cast<struct logger_list*>(calloc(1, sizeof(struct logger_list)));
-  if (!logger_list) {
-    return nullptr;
-  }
-
-  logger_list->mode = mode;
-  logger_list->start = start;
-  logger_list->tail = tail;
-  logger_list->pid = pid;
-
-  return logger_list;
-}
-
-struct logger_list* android_logger_list_alloc(int mode, unsigned int tail, pid_t pid) {
-  return android_logger_list_alloc_internal(mode, tail, log_time(0, 0), pid);
-}
-
-struct logger_list* android_logger_list_alloc_time(int mode, log_time start, pid_t pid) {
-  return android_logger_list_alloc_internal(mode, 0, start, pid);
-}
-
-/* Open the named log and add it to the logger list */
-struct logger* android_logger_open(struct logger_list* logger_list, log_id_t logId) {
-  if (!logger_list || (logId >= LOG_ID_MAX)) {
-    return nullptr;
-  }
-
-  logger_list->log_mask |= 1 << logId;
-
-  uintptr_t logger = logId;
-  logger |= (logger_list->mode & ANDROID_LOG_PSTORE) ? LOGGER_PMSG : LOGGER_LOGD;
-  return reinterpret_cast<struct logger*>(logger);
-}
-
-/* Open the single named log and make it part of a new logger list */
-struct logger_list* android_logger_list_open(log_id_t logId, int mode, unsigned int tail,
-                                             pid_t pid) {
-  struct logger_list* logger_list = android_logger_list_alloc(mode, tail, pid);
-
-  if (!logger_list) {
-    return NULL;
-  }
-
-  if (!android_logger_open(logger_list, logId)) {
-    android_logger_list_free(logger_list);
-    return NULL;
-  }
-
-  return logger_list;
-}
-
-int android_logger_list_read(struct logger_list* logger_list, struct log_msg* log_msg) {
-  if (logger_list == nullptr || logger_list->log_mask == 0) {
-    return -EINVAL;
-  }
-
-  int ret = 0;
-
-#ifdef __ANDROID__
-  if (logger_list->mode & ANDROID_LOG_PSTORE) {
-    ret = PmsgRead(logger_list, log_msg);
-  } else {
-    ret = LogdRead(logger_list, log_msg);
-  }
-#endif
-
-  if (ret <= 0) {
-    return ret;
-  }
-
-  if (ret > LOGGER_ENTRY_MAX_LEN) {
-    ret = LOGGER_ENTRY_MAX_LEN;
-  }
-
-  if (ret < static_cast<int>(sizeof(log_msg->entry))) {
-    return -EINVAL;
-  }
-
-  if (log_msg->entry.hdr_size < sizeof(log_msg->entry) ||
-      log_msg->entry.hdr_size >= LOGGER_ENTRY_MAX_LEN - sizeof(log_msg->entry)) {
-    return -EINVAL;
-  }
-
-  if (log_msg->entry.len > ret - log_msg->entry.hdr_size) {
-    return -EINVAL;
-  }
-
-  log_msg->buf[log_msg->entry.len + log_msg->entry.hdr_size] = '\0';
-
-  return ret;
-}
-
-/* Close all the logs */
-void android_logger_list_free(struct logger_list* logger_list) {
-  if (logger_list == NULL) {
-    return;
-  }
-
-#ifdef __ANDROID__
-  if (logger_list->mode & ANDROID_LOG_PSTORE) {
-    PmsgClose(logger_list);
-  } else {
-    LogdClose(logger_list);
-  }
-#endif
-
-  free(logger_list);
-}
diff --git a/liblog/logger_write.cpp b/liblog/logger_write.cpp
deleted file mode 100644
index 22c7eca..0000000
--- a/liblog/logger_write.cpp
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * Copyright (C) 2007-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 "logger_write.h"
-
-#include <errno.h>
-#include <inttypes.h>
-#include <libgen.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-
-#ifdef __BIONIC__
-#include <android/set_abort_message.h>
-#endif
-
-#include <atomic>
-
-#include <android-base/errno_restorer.h>
-#include <android-base/macros.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-
-#include "android/log.h"
-#include "log/log_read.h"
-#include "logger.h"
-#include "uio.h"
-
-#ifdef __ANDROID__
-#include "logd_writer.h"
-#include "pmsg_writer.h"
-#endif
-
-#if defined(__APPLE__)
-#include <pthread.h>
-#elif defined(__linux__) && !defined(__ANDROID__)
-#include <syscall.h>
-#elif defined(_WIN32)
-#include <windows.h>
-#endif
-
-using android::base::ErrnoRestorer;
-
-#define LOG_BUF_SIZE 1024
-
-#if defined(__ANDROID__)
-static int check_log_uid_permissions() {
-  uid_t uid = getuid();
-
-  /* Matches clientHasLogCredentials() in logd */
-  if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG)) {
-    uid = geteuid();
-    if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG)) {
-      gid_t gid = getgid();
-      if ((gid != AID_SYSTEM) && (gid != AID_ROOT) && (gid != AID_LOG)) {
-        gid = getegid();
-        if ((gid != AID_SYSTEM) && (gid != AID_ROOT) && (gid != AID_LOG)) {
-          int num_groups;
-          gid_t* groups;
-
-          num_groups = getgroups(0, NULL);
-          if (num_groups <= 0) {
-            return -EPERM;
-          }
-          groups = static_cast<gid_t*>(calloc(num_groups, sizeof(gid_t)));
-          if (!groups) {
-            return -ENOMEM;
-          }
-          num_groups = getgroups(num_groups, groups);
-          while (num_groups > 0) {
-            if (groups[num_groups - 1] == AID_LOG) {
-              break;
-            }
-            --num_groups;
-          }
-          free(groups);
-          if (num_groups <= 0) {
-            return -EPERM;
-          }
-        }
-      }
-    }
-  }
-  return 0;
-}
-#endif
-
-/*
- * Release any logger resources. A new log write will immediately re-acquire.
- */
-void __android_log_close() {
-#ifdef __ANDROID__
-  LogdClose();
-  PmsgClose();
-#endif
-}
-
-#if defined(__GLIBC__) || defined(_WIN32)
-static const char* getprogname() {
-#if defined(__GLIBC__)
-  return program_invocation_short_name;
-#elif defined(_WIN32)
-  static bool first = true;
-  static char progname[MAX_PATH] = {};
-
-  if (first) {
-    char path[PATH_MAX + 1];
-    DWORD result = GetModuleFileName(nullptr, path, sizeof(path) - 1);
-    if (result == 0 || result == sizeof(path) - 1) return "";
-    path[PATH_MAX - 1] = 0;
-
-    char* path_basename = basename(path);
-
-    snprintf(progname, sizeof(progname), "%s", path_basename);
-    first = false;
-  }
-
-  return progname;
-#endif
-}
-#endif
-
-// It's possible for logging to happen during static initialization before our globals are
-// initialized, so we place this std::string in a function such that it is initialized on the first
-// call.
-std::string& GetDefaultTag() {
-  static std::string default_tag = getprogname();
-  return default_tag;
-}
-
-void __android_log_set_default_tag(const char* tag) {
-  GetDefaultTag().assign(tag, 0, LOGGER_ENTRY_MAX_PAYLOAD);
-}
-
-static std::atomic_int32_t minimum_log_priority = ANDROID_LOG_DEFAULT;
-int32_t __android_log_set_minimum_priority(int32_t priority) {
-  return minimum_log_priority.exchange(priority, std::memory_order_relaxed);
-}
-
-int32_t __android_log_get_minimum_priority() {
-  return minimum_log_priority;
-}
-
-#ifdef __ANDROID__
-static __android_logger_function logger_function = __android_log_logd_logger;
-#else
-static __android_logger_function logger_function = __android_log_stderr_logger;
-#endif
-
-void __android_log_set_logger(__android_logger_function logger) {
-  logger_function = logger;
-}
-
-void __android_log_default_aborter(const char* abort_message) {
-#ifdef __ANDROID__
-  android_set_abort_message(abort_message);
-#else
-  UNUSED(abort_message);
-#endif
-  abort();
-}
-
-static __android_aborter_function aborter_function = __android_log_default_aborter;
-
-void __android_log_set_aborter(__android_aborter_function aborter) {
-  aborter_function = aborter;
-}
-
-void __android_log_call_aborter(const char* abort_message) {
-  aborter_function(abort_message);
-}
-
-#ifdef __ANDROID__
-static int write_to_log(log_id_t log_id, struct iovec* vec, size_t nr) {
-  int ret;
-  struct timespec ts;
-
-  if (log_id == LOG_ID_KERNEL) {
-    return -EINVAL;
-  }
-
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  if (log_id == LOG_ID_SECURITY) {
-    if (vec[0].iov_len < 4) {
-      return -EINVAL;
-    }
-
-    ret = check_log_uid_permissions();
-    if (ret < 0) {
-      return ret;
-    }
-    if (!__android_log_security()) {
-      /* If only we could reset downstream logd counter */
-      return -EPERM;
-    }
-  } else if (log_id == LOG_ID_EVENTS || log_id == LOG_ID_STATS) {
-    if (vec[0].iov_len < 4) {
-      return -EINVAL;
-    }
-  }
-
-  ret = LogdWrite(log_id, &ts, vec, nr);
-  PmsgWrite(log_id, &ts, vec, nr);
-
-  return ret;
-}
-#else
-static int write_to_log(log_id_t, struct iovec*, size_t) {
-  // Non-Android text logs should go to __android_log_stderr_logger, not here.
-  // Non-Android binary logs are always dropped.
-  return 1;
-}
-#endif
-
-// Copied from base/threads.cpp
-static uint64_t GetThreadId() {
-#if defined(__BIONIC__)
-  return gettid();
-#elif defined(__APPLE__)
-  uint64_t tid;
-  pthread_threadid_np(NULL, &tid);
-  return tid;
-#elif defined(__linux__)
-  return syscall(__NR_gettid);
-#elif defined(_WIN32)
-  return GetCurrentThreadId();
-#endif
-}
-
-void __android_log_stderr_logger(const struct __android_log_message* log_message) {
-  struct tm now;
-  time_t t = time(nullptr);
-
-#if defined(_WIN32)
-  localtime_s(&now, &t);
-#else
-  localtime_r(&t, &now);
-#endif
-
-  char timestamp[32];
-  strftime(timestamp, sizeof(timestamp), "%m-%d %H:%M:%S", &now);
-
-  static const char log_characters[] = "XXVDIWEF";
-  static_assert(arraysize(log_characters) - 1 == ANDROID_LOG_SILENT,
-                "Mismatch in size of log_characters and values in android_LogPriority");
-  int32_t priority =
-      log_message->priority > ANDROID_LOG_SILENT ? ANDROID_LOG_FATAL : log_message->priority;
-  char priority_char = log_characters[priority];
-  uint64_t tid = GetThreadId();
-
-  if (log_message->file != nullptr) {
-    fprintf(stderr, "%s %c %s %5d %5" PRIu64 " %s:%u] %s\n",
-            log_message->tag ? log_message->tag : "nullptr", priority_char, timestamp, getpid(),
-            tid, log_message->file, log_message->line, log_message->message);
-  } else {
-    fprintf(stderr, "%s %c %s %5d %5" PRIu64 " %s\n",
-            log_message->tag ? log_message->tag : "nullptr", priority_char, timestamp, getpid(),
-            tid, log_message->message);
-  }
-}
-
-void __android_log_logd_logger(const struct __android_log_message* log_message) {
-  int buffer_id = log_message->buffer_id == LOG_ID_DEFAULT ? LOG_ID_MAIN : log_message->buffer_id;
-
-  struct iovec vec[3];
-  vec[0].iov_base =
-      const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(&log_message->priority));
-  vec[0].iov_len = 1;
-  vec[1].iov_base = const_cast<void*>(static_cast<const void*>(log_message->tag));
-  vec[1].iov_len = strlen(log_message->tag) + 1;
-  vec[2].iov_base = const_cast<void*>(static_cast<const void*>(log_message->message));
-  vec[2].iov_len = strlen(log_message->message) + 1;
-
-  write_to_log(static_cast<log_id_t>(buffer_id), vec, 3);
-}
-
-int __android_log_write(int prio, const char* tag, const char* msg) {
-  return __android_log_buf_write(LOG_ID_MAIN, prio, tag, msg);
-}
-
-void __android_log_write_log_message(__android_log_message* log_message) {
-  ErrnoRestorer errno_restorer;
-
-  if (log_message->buffer_id != LOG_ID_DEFAULT && log_message->buffer_id != LOG_ID_MAIN &&
-      log_message->buffer_id != LOG_ID_SYSTEM && log_message->buffer_id != LOG_ID_RADIO &&
-      log_message->buffer_id != LOG_ID_CRASH) {
-    return;
-  }
-
-  if (log_message->tag == nullptr) {
-    log_message->tag = GetDefaultTag().c_str();
-  }
-
-#if __BIONIC__
-  if (log_message->priority == ANDROID_LOG_FATAL) {
-    android_set_abort_message(log_message->message);
-  }
-#endif
-
-  logger_function(log_message);
-}
-
-int __android_log_buf_write(int bufID, int prio, const char* tag, const char* msg) {
-  ErrnoRestorer errno_restorer;
-
-  if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) {
-    return -EPERM;
-  }
-
-  __android_log_message log_message = {
-      sizeof(__android_log_message), bufID, prio, tag, nullptr, 0, msg};
-  __android_log_write_log_message(&log_message);
-  return 1;
-}
-
-int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap) {
-  ErrnoRestorer errno_restorer;
-
-  if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) {
-    return -EPERM;
-  }
-
-  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
-
-  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-
-  __android_log_message log_message = {
-      sizeof(__android_log_message), LOG_ID_MAIN, prio, tag, nullptr, 0, buf};
-  __android_log_write_log_message(&log_message);
-  return 1;
-}
-
-int __android_log_print(int prio, const char* tag, const char* fmt, ...) {
-  ErrnoRestorer errno_restorer;
-
-  if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) {
-    return -EPERM;
-  }
-
-  va_list ap;
-  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
-
-  va_start(ap, fmt);
-  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-  va_end(ap);
-
-  __android_log_message log_message = {
-      sizeof(__android_log_message), LOG_ID_MAIN, prio, tag, nullptr, 0, buf};
-  __android_log_write_log_message(&log_message);
-  return 1;
-}
-
-int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fmt, ...) {
-  ErrnoRestorer errno_restorer;
-
-  if (!__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE)) {
-    return -EPERM;
-  }
-
-  va_list ap;
-  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
-
-  va_start(ap, fmt);
-  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-  va_end(ap);
-
-  __android_log_message log_message = {
-      sizeof(__android_log_message), bufID, prio, tag, nullptr, 0, buf};
-  __android_log_write_log_message(&log_message);
-  return 1;
-}
-
-void __android_log_assert(const char* cond, const char* tag, const char* fmt, ...) {
-  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
-
-  if (fmt) {
-    va_list ap;
-    va_start(ap, fmt);
-    vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-    va_end(ap);
-  } else {
-    /* Msg not provided, log condition.  N.B. Do not use cond directly as
-     * format string as it could contain spurious '%' syntax (e.g.
-     * "%d" in "blocks%devs == 0").
-     */
-    if (cond)
-      snprintf(buf, LOG_BUF_SIZE, "Assertion failed: %s", cond);
-    else
-      strcpy(buf, "Unspecified assertion failed");
-  }
-
-  // Log assertion failures to stderr for the benefit of "adb shell" users
-  // and gtests (http://b/23675822).
-  TEMP_FAILURE_RETRY(write(2, buf, strlen(buf)));
-  TEMP_FAILURE_RETRY(write(2, "\n", 1));
-
-  __android_log_write(ANDROID_LOG_FATAL, tag, buf);
-  __android_log_call_aborter(buf);
-  abort();
-}
-
-int __android_log_bwrite(int32_t tag, const void* payload, size_t len) {
-  ErrnoRestorer errno_restorer;
-
-  struct iovec vec[2];
-
-  vec[0].iov_base = &tag;
-  vec[0].iov_len = sizeof(tag);
-  vec[1].iov_base = (void*)payload;
-  vec[1].iov_len = len;
-
-  return write_to_log(LOG_ID_EVENTS, vec, 2);
-}
-
-int __android_log_stats_bwrite(int32_t tag, const void* payload, size_t len) {
-  ErrnoRestorer errno_restorer;
-
-  struct iovec vec[2];
-
-  vec[0].iov_base = &tag;
-  vec[0].iov_len = sizeof(tag);
-  vec[1].iov_base = (void*)payload;
-  vec[1].iov_len = len;
-
-  return write_to_log(LOG_ID_STATS, vec, 2);
-}
-
-int __android_log_security_bwrite(int32_t tag, const void* payload, size_t len) {
-  ErrnoRestorer errno_restorer;
-
-  struct iovec vec[2];
-
-  vec[0].iov_base = &tag;
-  vec[0].iov_len = sizeof(tag);
-  vec[1].iov_base = (void*)payload;
-  vec[1].iov_len = len;
-
-  return write_to_log(LOG_ID_SECURITY, vec, 2);
-}
-
-/*
- * Like __android_log_bwrite, but takes the type as well.  Doesn't work
- * for the general case where we're generating lists of stuff, but very
- * handy if we just want to dump an integer into the log.
- */
-int __android_log_btwrite(int32_t tag, char type, const void* payload, size_t len) {
-  ErrnoRestorer errno_restorer;
-
-  struct iovec vec[3];
-
-  vec[0].iov_base = &tag;
-  vec[0].iov_len = sizeof(tag);
-  vec[1].iov_base = &type;
-  vec[1].iov_len = sizeof(type);
-  vec[2].iov_base = (void*)payload;
-  vec[2].iov_len = len;
-
-  return write_to_log(LOG_ID_EVENTS, vec, 3);
-}
-
-/*
- * Like __android_log_bwrite, but used for writing strings to the
- * event log.
- */
-int __android_log_bswrite(int32_t tag, const char* payload) {
-  ErrnoRestorer errno_restorer;
-
-  struct iovec vec[4];
-  char type = EVENT_TYPE_STRING;
-  uint32_t len = strlen(payload);
-
-  vec[0].iov_base = &tag;
-  vec[0].iov_len = sizeof(tag);
-  vec[1].iov_base = &type;
-  vec[1].iov_len = sizeof(type);
-  vec[2].iov_base = &len;
-  vec[2].iov_len = sizeof(len);
-  vec[3].iov_base = (void*)payload;
-  vec[3].iov_len = len;
-
-  return write_to_log(LOG_ID_EVENTS, vec, 4);
-}
-
-/*
- * Like __android_log_security_bwrite, but used for writing strings to the
- * security log.
- */
-int __android_log_security_bswrite(int32_t tag, const char* payload) {
-  ErrnoRestorer errno_restorer;
-
-  struct iovec vec[4];
-  char type = EVENT_TYPE_STRING;
-  uint32_t len = strlen(payload);
-
-  vec[0].iov_base = &tag;
-  vec[0].iov_len = sizeof(tag);
-  vec[1].iov_base = &type;
-  vec[1].iov_len = sizeof(type);
-  vec[2].iov_base = &len;
-  vec[2].iov_len = sizeof(len);
-  vec[3].iov_base = (void*)payload;
-  vec[3].iov_len = len;
-
-  return write_to_log(LOG_ID_SECURITY, vec, 4);
-}
diff --git a/liblog/logprint.cpp b/liblog/logprint.cpp
deleted file mode 100644
index a5c5edd..0000000
--- a/liblog/logprint.cpp
+++ /dev/null
@@ -1,1748 +0,0 @@
-/*
-**
-** Copyright 2006-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.
-*/
-
-#ifndef __MINGW32__
-#define HAVE_STRSEP
-#endif
-
-#include <log/logprint.h>
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <inttypes.h>
-#ifndef __MINGW32__
-#include <pwd.h>
-#endif
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <wchar.h>
-
-#include <cutils/list.h>
-
-#include <log/log.h>
-#include <log/log_read.h>
-#include <private/android_logger.h>
-
-#define MS_PER_NSEC 1000000
-#define US_PER_NSEC 1000
-
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-
-typedef struct FilterInfo_t {
-  char* mTag;
-  android_LogPriority mPri;
-  struct FilterInfo_t* p_next;
-} FilterInfo;
-
-struct AndroidLogFormat_t {
-  android_LogPriority global_pri;
-  FilterInfo* filters;
-  AndroidLogPrintFormat format;
-  bool colored_output;
-  bool usec_time_output;
-  bool nsec_time_output;
-  bool printable_output;
-  bool year_output;
-  bool zone_output;
-  bool epoch_output;
-  bool monotonic_output;
-  bool uid_output;
-  bool descriptive_output;
-};
-
-/*
- * API issues prevent us from exposing "descriptive" in AndroidLogFormat_t
- * during android_log_processBinaryLogBuffer(), so we break layering.
- */
-static bool descriptive_output = false;
-
-/*
- * 8-bit color tags. See ECMA-48 Set Graphics Rendition in
- * [console_codes(4)](https://man7.org/linux/man-pages/man4/console_codes.4.html).
- *
- * The text manipulation character stream is defined as:
- *   ESC [ <parameter #> m
- *
- * We use "set <color> foreground" escape sequences instead of
- * "256/24-bit foreground color". This allows colors to render
- * according to user preferences in terminal emulator settings
- */
-#define ANDROID_COLOR_BLUE 34
-#define ANDROID_COLOR_DEFAULT 39
-#define ANDROID_COLOR_GREEN 32
-#define ANDROID_COLOR_RED 31
-#define ANDROID_COLOR_YELLOW 33
-
-static FilterInfo* filterinfo_new(const char* tag, android_LogPriority pri) {
-  FilterInfo* p_ret;
-
-  p_ret = (FilterInfo*)calloc(1, sizeof(FilterInfo));
-  p_ret->mTag = strdup(tag);
-  p_ret->mPri = pri;
-
-  return p_ret;
-}
-
-/* balance to above, filterinfo_free left unimplemented */
-
-/*
- * Note: also accepts 0-9 priorities
- * returns ANDROID_LOG_UNKNOWN if the character is unrecognized
- */
-static android_LogPriority filterCharToPri(char c) {
-  android_LogPriority pri;
-
-  c = tolower(c);
-
-  if (c >= '0' && c <= '9') {
-    if (c >= ('0' + ANDROID_LOG_SILENT)) {
-      pri = ANDROID_LOG_VERBOSE;
-    } else {
-      pri = (android_LogPriority)(c - '0');
-    }
-  } else if (c == 'v') {
-    pri = ANDROID_LOG_VERBOSE;
-  } else if (c == 'd') {
-    pri = ANDROID_LOG_DEBUG;
-  } else if (c == 'i') {
-    pri = ANDROID_LOG_INFO;
-  } else if (c == 'w') {
-    pri = ANDROID_LOG_WARN;
-  } else if (c == 'e') {
-    pri = ANDROID_LOG_ERROR;
-  } else if (c == 'f') {
-    pri = ANDROID_LOG_FATAL;
-  } else if (c == 's') {
-    pri = ANDROID_LOG_SILENT;
-  } else if (c == '*') {
-    pri = ANDROID_LOG_DEFAULT;
-  } else {
-    pri = ANDROID_LOG_UNKNOWN;
-  }
-
-  return pri;
-}
-
-static char filterPriToChar(android_LogPriority pri) {
-  switch (pri) {
-    /* clang-format off */
-    case ANDROID_LOG_VERBOSE: return 'V';
-    case ANDROID_LOG_DEBUG:   return 'D';
-    case ANDROID_LOG_INFO:    return 'I';
-    case ANDROID_LOG_WARN:    return 'W';
-    case ANDROID_LOG_ERROR:   return 'E';
-    case ANDROID_LOG_FATAL:   return 'F';
-    case ANDROID_LOG_SILENT:  return 'S';
-
-    case ANDROID_LOG_DEFAULT:
-    case ANDROID_LOG_UNKNOWN:
-    default:                  return '?';
-      /* clang-format on */
-  }
-}
-
-static int colorFromPri(android_LogPriority pri) {
-  switch (pri) {
-    /* clang-format off */
-    case ANDROID_LOG_VERBOSE: return ANDROID_COLOR_DEFAULT;
-    case ANDROID_LOG_DEBUG:   return ANDROID_COLOR_BLUE;
-    case ANDROID_LOG_INFO:    return ANDROID_COLOR_GREEN;
-    case ANDROID_LOG_WARN:    return ANDROID_COLOR_YELLOW;
-    case ANDROID_LOG_ERROR:   return ANDROID_COLOR_RED;
-    case ANDROID_LOG_FATAL:   return ANDROID_COLOR_RED;
-    case ANDROID_LOG_SILENT:  return ANDROID_COLOR_DEFAULT;
-
-    case ANDROID_LOG_DEFAULT:
-    case ANDROID_LOG_UNKNOWN:
-    default:                  return ANDROID_COLOR_DEFAULT;
-      /* clang-format on */
-  }
-}
-
-static android_LogPriority filterPriForTag(AndroidLogFormat* p_format, const char* tag) {
-  FilterInfo* p_curFilter;
-
-  for (p_curFilter = p_format->filters; p_curFilter != NULL; p_curFilter = p_curFilter->p_next) {
-    if (0 == strcmp(tag, p_curFilter->mTag)) {
-      if (p_curFilter->mPri == ANDROID_LOG_DEFAULT) {
-        return p_format->global_pri;
-      } else {
-        return p_curFilter->mPri;
-      }
-    }
-  }
-
-  return p_format->global_pri;
-}
-
-/**
- * returns 1 if this log line should be printed based on its priority
- * and tag, and 0 if it should not
- */
-int android_log_shouldPrintLine(AndroidLogFormat* p_format, const char* tag,
-                                android_LogPriority pri) {
-  return pri >= filterPriForTag(p_format, tag);
-}
-
-AndroidLogFormat* android_log_format_new() {
-  AndroidLogFormat* p_ret;
-
-  p_ret = static_cast<AndroidLogFormat*>(calloc(1, sizeof(AndroidLogFormat)));
-
-  p_ret->global_pri = ANDROID_LOG_VERBOSE;
-  p_ret->format = FORMAT_BRIEF;
-  p_ret->colored_output = false;
-  p_ret->usec_time_output = false;
-  p_ret->nsec_time_output = false;
-  p_ret->printable_output = false;
-  p_ret->year_output = false;
-  p_ret->zone_output = false;
-  p_ret->epoch_output = false;
-  p_ret->monotonic_output = false;
-  p_ret->uid_output = false;
-  p_ret->descriptive_output = false;
-  descriptive_output = false;
-
-  return p_ret;
-}
-
-static list_declare(convertHead);
-
-void android_log_format_free(AndroidLogFormat* p_format) {
-  FilterInfo *p_info, *p_info_old;
-
-  p_info = p_format->filters;
-
-  while (p_info != NULL) {
-    p_info_old = p_info;
-    p_info = p_info->p_next;
-
-    free(p_info_old);
-  }
-
-  free(p_format);
-
-  /* Free conversion resource, can always be reconstructed */
-  while (!list_empty(&convertHead)) {
-    struct listnode* node = list_head(&convertHead);
-    list_remove(node);
-    LOG_ALWAYS_FATAL_IF(node == list_head(&convertHead), "corrupted list");
-    free(node);
-  }
-}
-
-int android_log_setPrintFormat(AndroidLogFormat* p_format, AndroidLogPrintFormat format) {
-  switch (format) {
-    case FORMAT_MODIFIER_COLOR:
-      p_format->colored_output = true;
-      return 0;
-    case FORMAT_MODIFIER_TIME_USEC:
-      p_format->usec_time_output = true;
-      return 0;
-    case FORMAT_MODIFIER_TIME_NSEC:
-      p_format->nsec_time_output = true;
-      return 0;
-    case FORMAT_MODIFIER_PRINTABLE:
-      p_format->printable_output = true;
-      return 0;
-    case FORMAT_MODIFIER_YEAR:
-      p_format->year_output = true;
-      return 0;
-    case FORMAT_MODIFIER_ZONE:
-      p_format->zone_output = !p_format->zone_output;
-      return 0;
-    case FORMAT_MODIFIER_EPOCH:
-      p_format->epoch_output = true;
-      return 0;
-    case FORMAT_MODIFIER_MONOTONIC:
-      p_format->monotonic_output = true;
-      return 0;
-    case FORMAT_MODIFIER_UID:
-      p_format->uid_output = true;
-      return 0;
-    case FORMAT_MODIFIER_DESCRIPT:
-      p_format->descriptive_output = true;
-      descriptive_output = true;
-      return 0;
-    default:
-      break;
-  }
-  p_format->format = format;
-  return 1;
-}
-
-#ifndef __MINGW32__
-static const char tz[] = "TZ";
-static const char utc[] = "UTC";
-#endif
-
-/**
- * Returns FORMAT_OFF on invalid string
- */
-AndroidLogPrintFormat android_log_formatFromString(const char* formatString) {
-  static AndroidLogPrintFormat format;
-
-  /* clang-format off */
-  if (!strcmp(formatString, "brief")) format = FORMAT_BRIEF;
-  else if (!strcmp(formatString, "process")) format = FORMAT_PROCESS;
-  else if (!strcmp(formatString, "tag")) format = FORMAT_TAG;
-  else if (!strcmp(formatString, "thread")) format = FORMAT_THREAD;
-  else if (!strcmp(formatString, "raw")) format = FORMAT_RAW;
-  else if (!strcmp(formatString, "time")) format = FORMAT_TIME;
-  else if (!strcmp(formatString, "threadtime")) format = FORMAT_THREADTIME;
-  else if (!strcmp(formatString, "long")) format = FORMAT_LONG;
-  else if (!strcmp(formatString, "color")) format = FORMAT_MODIFIER_COLOR;
-  else if (!strcmp(formatString, "colour")) format = FORMAT_MODIFIER_COLOR;
-  else if (!strcmp(formatString, "usec")) format = FORMAT_MODIFIER_TIME_USEC;
-  else if (!strcmp(formatString, "nsec")) format = FORMAT_MODIFIER_TIME_NSEC;
-  else if (!strcmp(formatString, "printable")) format = FORMAT_MODIFIER_PRINTABLE;
-  else if (!strcmp(formatString, "year")) format = FORMAT_MODIFIER_YEAR;
-  else if (!strcmp(formatString, "zone")) format = FORMAT_MODIFIER_ZONE;
-  else if (!strcmp(formatString, "epoch")) format = FORMAT_MODIFIER_EPOCH;
-  else if (!strcmp(formatString, "monotonic")) format = FORMAT_MODIFIER_MONOTONIC;
-  else if (!strcmp(formatString, "uid")) format = FORMAT_MODIFIER_UID;
-  else if (!strcmp(formatString, "descriptive")) format = FORMAT_MODIFIER_DESCRIPT;
-    /* clang-format on */
-
-#ifndef __MINGW32__
-  else {
-    extern char* tzname[2];
-    static const char gmt[] = "GMT";
-    char* cp = getenv(tz);
-    if (cp) {
-      cp = strdup(cp);
-    }
-    setenv(tz, formatString, 1);
-    /*
-     * Run tzset here to determine if the timezone is legitimate. If the
-     * zone is GMT, check if that is what was asked for, if not then
-     * did not match any on the system; report an error to caller.
-     */
-    tzset();
-    if (!tzname[0] ||
-        ((!strcmp(tzname[0], utc) || !strcmp(tzname[0], gmt))                  /* error? */
-         && strcasecmp(formatString, utc) && strcasecmp(formatString, gmt))) { /* ok */
-      if (cp) {
-        setenv(tz, cp, 1);
-      } else {
-        unsetenv(tz);
-      }
-      tzset();
-      format = FORMAT_OFF;
-    } else {
-      format = FORMAT_MODIFIER_ZONE;
-    }
-    free(cp);
-  }
-#endif
-
-  return format;
-}
-
-/**
- * filterExpression: a single filter expression
- * eg "AT:d"
- *
- * returns 0 on success and -1 on invalid expression
- *
- * Assumes single threaded execution
- */
-
-int android_log_addFilterRule(AndroidLogFormat* p_format, const char* filterExpression) {
-  size_t tagNameLength;
-  android_LogPriority pri = ANDROID_LOG_DEFAULT;
-
-  tagNameLength = strcspn(filterExpression, ":");
-
-  if (tagNameLength == 0) {
-    goto error;
-  }
-
-  if (filterExpression[tagNameLength] == ':') {
-    pri = filterCharToPri(filterExpression[tagNameLength + 1]);
-
-    if (pri == ANDROID_LOG_UNKNOWN) {
-      goto error;
-    }
-  }
-
-  if (0 == strncmp("*", filterExpression, tagNameLength)) {
-    /*
-     * This filter expression refers to the global filter
-     * The default level for this is DEBUG if the priority
-     * is unspecified
-     */
-    if (pri == ANDROID_LOG_DEFAULT) {
-      pri = ANDROID_LOG_DEBUG;
-    }
-
-    p_format->global_pri = pri;
-  } else {
-    /*
-     * for filter expressions that don't refer to the global
-     * filter, the default is verbose if the priority is unspecified
-     */
-    if (pri == ANDROID_LOG_DEFAULT) {
-      pri = ANDROID_LOG_VERBOSE;
-    }
-
-    char* tagName;
-
-/*
- * Presently HAVE_STRNDUP is never defined, so the second case is always taken
- * Darwin doesn't have strndup, everything else does
- */
-#ifdef HAVE_STRNDUP
-    tagName = strndup(filterExpression, tagNameLength);
-#else
-    /* a few extra bytes copied... */
-    tagName = strdup(filterExpression);
-    tagName[tagNameLength] = '\0';
-#endif /*HAVE_STRNDUP*/
-
-    FilterInfo* p_fi = filterinfo_new(tagName, pri);
-    free(tagName);
-
-    p_fi->p_next = p_format->filters;
-    p_format->filters = p_fi;
-  }
-
-  return 0;
-error:
-  return -1;
-}
-
-#ifndef HAVE_STRSEP
-/* KISS replacement helper for below */
-static char* strsep(char** stringp, const char* delim) {
-  char* token;
-  char* ret = *stringp;
-
-  if (!ret || !*ret) {
-    return NULL;
-  }
-  token = strpbrk(ret, delim);
-  if (token) {
-    *token = '\0';
-    ++token;
-  } else {
-    token = ret + strlen(ret);
-  }
-  *stringp = token;
-  return ret;
-}
-#endif
-
-/**
- * filterString: a comma/whitespace-separated set of filter expressions
- *
- * eg "AT:d *:i"
- *
- * returns 0 on success and -1 on invalid expression
- *
- * Assumes single threaded execution
- *
- */
-int android_log_addFilterString(AndroidLogFormat* p_format, const char* filterString) {
-  char* filterStringCopy = strdup(filterString);
-  char* p_cur = filterStringCopy;
-  char* p_ret;
-  int err;
-
-  /* Yes, I'm using strsep */
-  while (NULL != (p_ret = strsep(&p_cur, " \t,"))) {
-    /* ignore whitespace-only entries */
-    if (p_ret[0] != '\0') {
-      err = android_log_addFilterRule(p_format, p_ret);
-
-      if (err < 0) {
-        goto error;
-      }
-    }
-  }
-
-  free(filterStringCopy);
-  return 0;
-error:
-  free(filterStringCopy);
-  return -1;
-}
-
-/**
- * Splits a wire-format buffer into an AndroidLogEntry
- * entry allocated by caller. Pointers will point directly into buf
- *
- * Returns 0 on success and -1 on invalid wire format (entry will be
- * in unspecified state)
- */
-int android_log_processLogBuffer(struct logger_entry* buf, AndroidLogEntry* entry) {
-  entry->message = NULL;
-  entry->messageLen = 0;
-
-  entry->tv_sec = buf->sec;
-  entry->tv_nsec = buf->nsec;
-  entry->uid = -1;
-  entry->pid = buf->pid;
-  entry->tid = buf->tid;
-
-  /*
-   * format: <priority:1><tag:N>\0<message:N>\0
-   *
-   * tag str
-   *   starts at buf + buf->hdr_size + 1
-   * msg
-   *   starts at buf + buf->hdr_size + 1 + len(tag) + 1
-   *
-   * The message may have been truncated.  When that happens, we must null-terminate the message
-   * ourselves.
-   */
-  if (buf->len < 3) {
-    /*
-     * An well-formed entry must consist of at least a priority
-     * and two null characters
-     */
-    fprintf(stderr, "+++ LOG: entry too small\n");
-    return -1;
-  }
-
-  int msgStart = -1;
-  int msgEnd = -1;
-
-  int i;
-  if (buf->hdr_size < sizeof(logger_entry)) {
-    fprintf(stderr, "+++ LOG: hdr_size must be at least as big as struct logger_entry\n");
-    return -1;
-  }
-  char* msg = reinterpret_cast<char*>(buf) + buf->hdr_size;
-  entry->uid = buf->uid;
-
-  for (i = 1; i < buf->len; i++) {
-    if (msg[i] == '\0') {
-      if (msgStart == -1) {
-        msgStart = i + 1;
-      } else {
-        msgEnd = i;
-        break;
-      }
-    }
-  }
-
-  if (msgStart == -1) {
-    /* +++ LOG: malformed log message, DYB */
-    for (i = 1; i < buf->len; i++) {
-      /* odd characters in tag? */
-      if ((msg[i] <= ' ') || (msg[i] == ':') || (msg[i] >= 0x7f)) {
-        msg[i] = '\0';
-        msgStart = i + 1;
-        break;
-      }
-    }
-    if (msgStart == -1) {
-      msgStart = buf->len - 1; /* All tag, no message, print truncates */
-    }
-  }
-  if (msgEnd == -1) {
-    /* incoming message not null-terminated; force it */
-    msgEnd = buf->len - 1; /* may result in msgEnd < msgStart */
-    msg[msgEnd] = '\0';
-  }
-
-  entry->priority = static_cast<android_LogPriority>(msg[0]);
-  entry->tag = msg + 1;
-  entry->tagLen = msgStart - 1;
-  entry->message = msg + msgStart;
-  entry->messageLen = (msgEnd < msgStart) ? 0 : (msgEnd - msgStart);
-
-  return 0;
-}
-
-static bool findChar(const char** cp, size_t* len, int c) {
-  while ((*len) && isspace(*(*cp))) {
-    ++(*cp);
-    --(*len);
-  }
-  if (c == INT_MAX) return *len;
-  if ((*len) && (*(*cp) == c)) {
-    ++(*cp);
-    --(*len);
-    return true;
-  }
-  return false;
-}
-
-/*
- * Recursively convert binary log data to printable form.
- *
- * This needs to be recursive because you can have lists of lists.
- *
- * If we run out of room, we stop processing immediately.  It's important
- * for us to check for space on every output element to avoid producing
- * garbled output.
- *
- * Returns 0 on success, 1 on buffer full, -1 on failure.
- */
-enum objectType {
-  TYPE_OBJECTS = '1',
-  TYPE_BYTES = '2',
-  TYPE_MILLISECONDS = '3',
-  TYPE_ALLOCATIONS = '4',
-  TYPE_ID = '5',
-  TYPE_PERCENT = '6',
-  TYPE_MONOTONIC = 's'
-};
-
-static int android_log_printBinaryEvent(const unsigned char** pEventData, size_t* pEventDataLen,
-                                        char** pOutBuf, size_t* pOutBufLen, const char** fmtStr,
-                                        size_t* fmtLen) {
-  const unsigned char* eventData = *pEventData;
-  size_t eventDataLen = *pEventDataLen;
-  char* outBuf = *pOutBuf;
-  char* outBufSave = outBuf;
-  size_t outBufLen = *pOutBufLen;
-  size_t outBufLenSave = outBufLen;
-  unsigned char type;
-  size_t outCount = 0;
-  int result = 0;
-  const char* cp;
-  size_t len;
-  int64_t lval;
-
-  if (eventDataLen < 1) return -1;
-
-  type = *eventData;
-
-  cp = NULL;
-  len = 0;
-  if (fmtStr && *fmtStr && fmtLen && *fmtLen && **fmtStr) {
-    cp = *fmtStr;
-    len = *fmtLen;
-  }
-  /*
-   * event.logtag format specification:
-   *
-   * Optionally, after the tag names can be put a description for the value(s)
-   * of the tag. Description are in the format
-   *    (<name>|data type[|data unit])
-   * Multiple values are separated by commas.
-   *
-   * The data type is a number from the following values:
-   * 1: int
-   * 2: long
-   * 3: string
-   * 4: list
-   * 5: float
-   *
-   * The data unit is a number taken from the following list:
-   * 1: Number of objects
-   * 2: Number of bytes
-   * 3: Number of milliseconds
-   * 4: Number of allocations
-   * 5: Id
-   * 6: Percent
-   * s: Number of seconds (monotonic time)
-   * Default value for data of type int/long is 2 (bytes).
-   */
-  if (!cp || !findChar(&cp, &len, '(')) {
-    len = 0;
-  } else {
-    char* outBufLastSpace = NULL;
-
-    findChar(&cp, &len, INT_MAX);
-    while (len && *cp && (*cp != '|') && (*cp != ')')) {
-      if (outBufLen <= 0) {
-        /* halt output */
-        goto no_room;
-      }
-      outBufLastSpace = isspace(*cp) ? outBuf : NULL;
-      *outBuf = *cp;
-      ++outBuf;
-      ++cp;
-      --outBufLen;
-      --len;
-    }
-    if (outBufLastSpace) {
-      outBufLen += outBuf - outBufLastSpace;
-      outBuf = outBufLastSpace;
-    }
-    if (outBufLen <= 0) {
-      /* halt output */
-      goto no_room;
-    }
-    if (outBufSave != outBuf) {
-      *outBuf = '=';
-      ++outBuf;
-      --outBufLen;
-    }
-
-    if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
-      static const unsigned char typeTable[] = {EVENT_TYPE_INT, EVENT_TYPE_LONG, EVENT_TYPE_STRING,
-                                                EVENT_TYPE_LIST, EVENT_TYPE_FLOAT};
-
-      if ((*cp >= '1') && (*cp < (char)('1' + (sizeof(typeTable) / sizeof(typeTable[0])))) &&
-          (type != typeTable[(size_t)(*cp - '1')]))
-        len = 0;
-
-      if (len) {
-        ++cp;
-        --len;
-      } else {
-        /* reset the format */
-        outBuf = outBufSave;
-        outBufLen = outBufLenSave;
-      }
-    }
-  }
-  outCount = 0;
-  lval = 0;
-  switch (type) {
-    case EVENT_TYPE_INT:
-      /* 32-bit signed int */
-      {
-        if (eventDataLen < sizeof(android_event_int_t)) return -1;
-        auto* event_int = reinterpret_cast<const android_event_int_t*>(eventData);
-        lval = event_int->data;
-        eventData += sizeof(android_event_int_t);
-        eventDataLen -= sizeof(android_event_int_t);
-      }
-      goto pr_lval;
-    case EVENT_TYPE_LONG:
-      /* 64-bit signed long */
-      if (eventDataLen < sizeof(android_event_long_t)) {
-        return -1;
-      }
-      {
-        auto* event_long = reinterpret_cast<const android_event_long_t*>(eventData);
-        lval = event_long->data;
-      }
-      eventData += sizeof(android_event_long_t);
-      eventDataLen -= sizeof(android_event_long_t);
-    pr_lval:
-      outCount = snprintf(outBuf, outBufLen, "%" PRId64, lval);
-      if (outCount < outBufLen) {
-        outBuf += outCount;
-        outBufLen -= outCount;
-      } else {
-        /* halt output */
-        goto no_room;
-      }
-      break;
-    case EVENT_TYPE_FLOAT:
-      /* float */
-      {
-        if (eventDataLen < sizeof(android_event_float_t)) return -1;
-        auto* event_float = reinterpret_cast<const android_event_float_t*>(eventData);
-        float fval = event_float->data;
-        eventData += sizeof(android_event_int_t);
-        eventDataLen -= sizeof(android_event_int_t);
-
-        outCount = snprintf(outBuf, outBufLen, "%f", fval);
-        if (outCount < outBufLen) {
-          outBuf += outCount;
-          outBufLen -= outCount;
-        } else {
-          /* halt output */
-          goto no_room;
-        }
-      }
-      break;
-    case EVENT_TYPE_STRING:
-      /* UTF-8 chars, not NULL-terminated */
-      {
-        if (eventDataLen < sizeof(android_event_string_t)) return -1;
-        auto* event_string = reinterpret_cast<const android_event_string_t*>(eventData);
-        unsigned int strLen = event_string->length;
-        eventData += sizeof(android_event_string_t);
-        eventDataLen -= sizeof(android_event_string_t);
-
-        if (eventDataLen < strLen) {
-          result = -1; /* mark truncated */
-          strLen = eventDataLen;
-        }
-
-        if (cp && (strLen == 0)) {
-          /* reset the format if no content */
-          outBuf = outBufSave;
-          outBufLen = outBufLenSave;
-        }
-        if (strLen < outBufLen) {
-          memcpy(outBuf, eventData, strLen);
-          outBuf += strLen;
-          outBufLen -= strLen;
-        } else {
-          if (outBufLen > 0) {
-            /* copy what we can */
-            memcpy(outBuf, eventData, outBufLen);
-            outBuf += outBufLen;
-            outBufLen -= outBufLen;
-          }
-          if (!result) result = 1; /* if not truncated, return no room */
-        }
-        eventData += strLen;
-        eventDataLen -= strLen;
-        if (result != 0) goto bail;
-        break;
-      }
-    case EVENT_TYPE_LIST:
-      /* N items, all different types */
-      {
-        if (eventDataLen < sizeof(android_event_list_t)) return -1;
-        auto* event_list = reinterpret_cast<const android_event_list_t*>(eventData);
-
-        int8_t count = event_list->element_count;
-        eventData += sizeof(android_event_list_t);
-        eventDataLen -= sizeof(android_event_list_t);
-
-        if (outBufLen <= 0) goto no_room;
-
-        *outBuf++ = '[';
-        outBufLen--;
-
-        for (int i = 0; i < count; i++) {
-          result = android_log_printBinaryEvent(&eventData, &eventDataLen, &outBuf, &outBufLen,
-                                                fmtStr, fmtLen);
-          if (result != 0) goto bail;
-
-          if (i < (count - 1)) {
-            if (outBufLen <= 0) goto no_room;
-            *outBuf++ = ',';
-            outBufLen--;
-          }
-        }
-
-        if (outBufLen <= 0) goto no_room;
-
-        *outBuf++ = ']';
-        outBufLen--;
-      }
-      break;
-    default:
-      fprintf(stderr, "Unknown binary event type %d\n", type);
-      return -1;
-  }
-  if (cp && len) {
-    if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
-      switch (*cp) {
-        case TYPE_OBJECTS:
-          outCount = 0;
-          /* outCount = snprintf(outBuf, outBufLen, " objects"); */
-          break;
-        case TYPE_BYTES:
-          if ((lval != 0) && ((lval % 1024) == 0)) {
-            /* repaint with multiplier */
-            static const char suffixTable[] = {'K', 'M', 'G', 'T'};
-            size_t idx = 0;
-            outBuf -= outCount;
-            outBufLen += outCount;
-            do {
-              lval /= 1024;
-              if ((lval % 1024) != 0) break;
-            } while (++idx < ((sizeof(suffixTable) / sizeof(suffixTable[0])) - 1));
-            outCount = snprintf(outBuf, outBufLen, "%" PRId64 "%cB", lval, suffixTable[idx]);
-          } else {
-            outCount = snprintf(outBuf, outBufLen, "B");
-          }
-          break;
-        case TYPE_MILLISECONDS:
-          if (((lval <= -1000) || (1000 <= lval)) && (outBufLen || (outBuf[-1] == '0'))) {
-            /* repaint as (fractional) seconds, possibly saving space */
-            if (outBufLen) outBuf[0] = outBuf[-1];
-            outBuf[-1] = outBuf[-2];
-            outBuf[-2] = outBuf[-3];
-            outBuf[-3] = '.';
-            while ((outBufLen == 0) || (*outBuf == '0')) {
-              --outBuf;
-              ++outBufLen;
-            }
-            if (*outBuf != '.') {
-              ++outBuf;
-              --outBufLen;
-            }
-            outCount = snprintf(outBuf, outBufLen, "s");
-          } else {
-            outCount = snprintf(outBuf, outBufLen, "ms");
-          }
-          break;
-        case TYPE_MONOTONIC: {
-          static const uint64_t minute = 60;
-          static const uint64_t hour = 60 * minute;
-          static const uint64_t day = 24 * hour;
-
-          /* Repaint as unsigned seconds, minutes, hours ... */
-          outBuf -= outCount;
-          outBufLen += outCount;
-          uint64_t val = lval;
-          if (val >= day) {
-            outCount = snprintf(outBuf, outBufLen, "%" PRIu64 "d ", val / day);
-            if (outCount >= outBufLen) break;
-            outBuf += outCount;
-            outBufLen -= outCount;
-            val = (val % day) + day;
-          }
-          if (val >= minute) {
-            if (val >= hour) {
-              outCount = snprintf(outBuf, outBufLen, "%" PRIu64 ":", (val / hour) % (day / hour));
-              if (outCount >= outBufLen) break;
-              outBuf += outCount;
-              outBufLen -= outCount;
-            }
-            outCount =
-                snprintf(outBuf, outBufLen, (val >= hour) ? "%02" PRIu64 ":" : "%" PRIu64 ":",
-                         (val / minute) % (hour / minute));
-            if (outCount >= outBufLen) break;
-            outBuf += outCount;
-            outBufLen -= outCount;
-          }
-          outCount = snprintf(outBuf, outBufLen, (val >= minute) ? "%02" PRIu64 : "%" PRIu64 "s",
-                              val % minute);
-        } break;
-        case TYPE_ALLOCATIONS:
-          outCount = 0;
-          /* outCount = snprintf(outBuf, outBufLen, " allocations"); */
-          break;
-        case TYPE_ID:
-          outCount = 0;
-          break;
-        case TYPE_PERCENT:
-          outCount = snprintf(outBuf, outBufLen, "%%");
-          break;
-        default: /* ? */
-          outCount = 0;
-          break;
-      }
-      ++cp;
-      --len;
-      if (outCount < outBufLen) {
-        outBuf += outCount;
-        outBufLen -= outCount;
-      } else if (outCount) {
-        /* halt output */
-        goto no_room;
-      }
-    }
-    if (!findChar(&cp, &len, ')')) len = 0;
-    if (!findChar(&cp, &len, ',')) len = 0;
-  }
-
-bail:
-  *pEventData = eventData;
-  *pEventDataLen = eventDataLen;
-  *pOutBuf = outBuf;
-  *pOutBufLen = outBufLen;
-  if (cp) {
-    *fmtStr = cp;
-    *fmtLen = len;
-  }
-  return result;
-
-no_room:
-  result = 1;
-  goto bail;
-}
-
-/**
- * Convert a binary log entry to ASCII form.
- *
- * For convenience we mimic the processLogBuffer API.  There is no
- * pre-defined output length for the binary data, since we're free to format
- * it however we choose, which means we can't really use a fixed-size buffer
- * here.
- */
-int android_log_processBinaryLogBuffer(
-    struct logger_entry* buf, AndroidLogEntry* entry,
-    [[maybe_unused]] const EventTagMap* map, /* only on !__ANDROID__ */
-    char* messageBuf, int messageBufLen) {
-  size_t inCount;
-  uint32_t tagIndex;
-  const unsigned char* eventData;
-
-  entry->message = NULL;
-  entry->messageLen = 0;
-
-  entry->tv_sec = buf->sec;
-  entry->tv_nsec = buf->nsec;
-  entry->priority = ANDROID_LOG_INFO;
-  entry->uid = -1;
-  entry->pid = buf->pid;
-  entry->tid = buf->tid;
-
-  if (buf->hdr_size < sizeof(logger_entry)) {
-    fprintf(stderr, "+++ LOG: hdr_size must be at least as big as struct logger_entry\n");
-    return -1;
-  }
-  eventData = reinterpret_cast<unsigned char*>(buf) + buf->hdr_size;
-  if (buf->lid == LOG_ID_SECURITY) {
-    entry->priority = ANDROID_LOG_WARN;
-  }
-  entry->uid = buf->uid;
-  inCount = buf->len;
-  if (inCount < sizeof(android_event_header_t)) return -1;
-  auto* event_header = reinterpret_cast<const android_event_header_t*>(eventData);
-  tagIndex = event_header->tag;
-  eventData += sizeof(android_event_header_t);
-  inCount -= sizeof(android_event_header_t);
-
-  entry->tagLen = 0;
-  entry->tag = NULL;
-#ifdef __ANDROID__
-  if (map != NULL) {
-    entry->tag = android_lookupEventTag_len(map, &entry->tagLen, tagIndex);
-  }
-#endif
-
-  /*
-   * If we don't have a map, or didn't find the tag number in the map,
-   * stuff a generated tag value into the start of the output buffer and
-   * shift the buffer pointers down.
-   */
-  if (entry->tag == NULL) {
-    size_t tagLen;
-
-    tagLen = snprintf(messageBuf, messageBufLen, "[%" PRIu32 "]", tagIndex);
-    if (tagLen >= (size_t)messageBufLen) {
-      tagLen = messageBufLen - 1;
-    }
-    entry->tag = messageBuf;
-    entry->tagLen = tagLen;
-    messageBuf += tagLen + 1;
-    messageBufLen -= tagLen + 1;
-  }
-
-  /*
-   * Format the event log data into the buffer.
-   */
-  const char* fmtStr = NULL;
-  size_t fmtLen = 0;
-#ifdef __ANDROID__
-  if (descriptive_output && map) {
-    fmtStr = android_lookupEventFormat_len(map, &fmtLen, tagIndex);
-  }
-#endif
-
-  char* outBuf = messageBuf;
-  size_t outRemaining = messageBufLen - 1; /* leave one for nul byte */
-  int result = 0;
-
-  if ((inCount > 0) || fmtLen) {
-    result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf, &outRemaining, &fmtStr,
-                                          &fmtLen);
-  }
-  if ((result == 1) && fmtStr) {
-    /* We overflowed :-(, let's repaint the line w/o format dressings */
-    eventData = reinterpret_cast<unsigned char*>(buf) + buf->hdr_size;
-    eventData += 4;
-    outBuf = messageBuf;
-    outRemaining = messageBufLen - 1;
-    result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf, &outRemaining, NULL, NULL);
-  }
-  if (result < 0) {
-    fprintf(stderr, "Binary log entry conversion failed\n");
-  }
-  if (result) {
-    if (!outRemaining) {
-      /* make space to leave an indicator */
-      --outBuf;
-      ++outRemaining;
-    }
-    *outBuf++ = (result < 0) ? '!' : '^'; /* Error or Truncation? */
-    outRemaining--;
-    /* pretend we ate all the data to prevent log stutter */
-    inCount = 0;
-    if (result > 0) result = 0;
-  }
-
-  /* eat the silly terminating '\n' */
-  if (inCount == 1 && *eventData == '\n') {
-    eventData++;
-    inCount--;
-  }
-
-  if (inCount != 0) {
-    fprintf(stderr, "Warning: leftover binary log data (%zu bytes)\n", inCount);
-  }
-
-  /*
-   * Terminate the buffer.  The NUL byte does not count as part of
-   * entry->messageLen.
-   */
-  *outBuf = '\0';
-  entry->messageLen = outBuf - messageBuf;
-  assert(entry->messageLen == (messageBufLen - 1) - outRemaining);
-
-  entry->message = messageBuf;
-
-  return result;
-}
-
-/*
- * Convert to printable from message to p buffer, return string length. If p is
- * NULL, do not copy, but still return the expected string length.
- */
-size_t convertPrintable(char* p, const char* message, size_t messageLen) {
-  char* begin = p;
-  bool print = p != NULL;
-  mbstate_t mb_state = {};
-
-  while (messageLen) {
-    char buf[6];
-    ssize_t len = sizeof(buf) - 1;
-    if ((size_t)len > messageLen) {
-      len = messageLen;
-    }
-    len = mbrtowc(nullptr, message, len, &mb_state);
-
-    if (len < 0) {
-      snprintf(buf, sizeof(buf), "\\x%02X", static_cast<unsigned char>(*message));
-      len = 1;
-    } else {
-      buf[0] = '\0';
-      if (len == 1) {
-        if (*message == '\a') {
-          strcpy(buf, "\\a");
-        } else if (*message == '\b') {
-          strcpy(buf, "\\b");
-        } else if (*message == '\t') {
-          strcpy(buf, "\t"); /* Do not escape tabs */
-        } else if (*message == '\v') {
-          strcpy(buf, "\\v");
-        } else if (*message == '\f') {
-          strcpy(buf, "\\f");
-        } else if (*message == '\r') {
-          strcpy(buf, "\\r");
-        } else if (*message == '\\') {
-          strcpy(buf, "\\\\");
-        } else if ((*message < ' ') || (*message & 0x80)) {
-          snprintf(buf, sizeof(buf), "\\x%02X", static_cast<unsigned char>(*message));
-        }
-      }
-      if (!buf[0]) {
-        strncpy(buf, message, len);
-        buf[len] = '\0';
-      }
-    }
-    if (print) {
-      strcpy(p, buf);
-    }
-    p += strlen(buf);
-    message += len;
-    messageLen -= len;
-  }
-  return p - begin;
-}
-
-#ifdef __ANDROID__
-static char* readSeconds(char* e, struct timespec* t) {
-  unsigned long multiplier;
-  char* p;
-  t->tv_sec = strtoul(e, &p, 10);
-  if (*p != '.') {
-    return NULL;
-  }
-  t->tv_nsec = 0;
-  multiplier = NS_PER_SEC;
-  while (isdigit(*++p) && (multiplier /= 10)) {
-    t->tv_nsec += (*p - '0') * multiplier;
-  }
-  return p;
-}
-
-static struct timespec* sumTimespec(struct timespec* left, struct timespec* right) {
-  left->tv_nsec += right->tv_nsec;
-  left->tv_sec += right->tv_sec;
-  if (left->tv_nsec >= (long)NS_PER_SEC) {
-    left->tv_nsec -= NS_PER_SEC;
-    left->tv_sec += 1;
-  }
-  return left;
-}
-
-static struct timespec* subTimespec(struct timespec* result, struct timespec* left,
-                                    struct timespec* right) {
-  result->tv_nsec = left->tv_nsec - right->tv_nsec;
-  result->tv_sec = left->tv_sec - right->tv_sec;
-  if (result->tv_nsec < 0) {
-    result->tv_nsec += NS_PER_SEC;
-    result->tv_sec -= 1;
-  }
-  return result;
-}
-
-static long long nsecTimespec(struct timespec* now) {
-  return (long long)now->tv_sec * NS_PER_SEC + now->tv_nsec;
-}
-
-static void convertMonotonic(struct timespec* result, const AndroidLogEntry* entry) {
-  struct listnode* node;
-  struct conversionList {
-    struct listnode node; /* first */
-    struct timespec time;
-    struct timespec convert;
-  } * list, *next;
-  struct timespec time, convert;
-
-  /* If we do not have a conversion list, build one up */
-  if (list_empty(&convertHead)) {
-    bool suspended_pending = false;
-    struct timespec suspended_monotonic = {0, 0};
-    struct timespec suspended_diff = {0, 0};
-
-    /*
-     * Read dmesg for _some_ synchronization markers and insert
-     * Anything in the Android Logger before the dmesg logging span will
-     * be highly suspect regarding the monotonic time calculations.
-     */
-    FILE* p = popen("/system/bin/dmesg", "re");
-    if (p) {
-      char* line = NULL;
-      size_t len = 0;
-      while (getline(&line, &len, p) > 0) {
-        static const char suspend[] = "PM: suspend entry ";
-        static const char resume[] = "PM: suspend exit ";
-        static const char healthd[] = "healthd";
-        static const char battery[] = ": battery ";
-        static const char suspended[] = "Suspended for ";
-        struct timespec monotonic;
-        struct tm tm;
-        char *cp, *e = line;
-        bool add_entry = true;
-
-        if (*e == '<') {
-          while (*e && (*e != '>')) {
-            ++e;
-          }
-          if (*e != '>') {
-            continue;
-          }
-        }
-        if (*e != '[') {
-          continue;
-        }
-        while (*++e == ' ') {
-          ;
-        }
-        e = readSeconds(e, &monotonic);
-        if (!e || (*e != ']')) {
-          continue;
-        }
-
-        if ((e = strstr(e, suspend))) {
-          e += sizeof(suspend) - 1;
-        } else if ((e = strstr(line, resume))) {
-          e += sizeof(resume) - 1;
-        } else if (((e = strstr(line, healthd))) &&
-                   ((e = strstr(e + sizeof(healthd) - 1, battery)))) {
-          /* NB: healthd is roughly 150us late, worth the price to
-           * deal with ntp-induced or hardware clock drift. */
-          e += sizeof(battery) - 1;
-        } else if ((e = strstr(line, suspended))) {
-          e += sizeof(suspended) - 1;
-          e = readSeconds(e, &time);
-          if (!e) {
-            continue;
-          }
-          add_entry = false;
-          suspended_pending = true;
-          suspended_monotonic = monotonic;
-          suspended_diff = time;
-        } else {
-          continue;
-        }
-        if (add_entry) {
-          /* look for "????-??-?? ??:??:??.????????? UTC" */
-          cp = strstr(e, " UTC");
-          if (!cp || ((cp - e) < 29) || (cp[-10] != '.')) {
-            continue;
-          }
-          e = cp - 29;
-          cp = readSeconds(cp - 10, &time);
-          if (!cp) {
-            continue;
-          }
-          cp = strptime(e, "%Y-%m-%d %H:%M:%S.", &tm);
-          if (!cp) {
-            continue;
-          }
-          cp = getenv(tz);
-          if (cp) {
-            cp = strdup(cp);
-          }
-          setenv(tz, utc, 1);
-          time.tv_sec = mktime(&tm);
-          if (cp) {
-            setenv(tz, cp, 1);
-            free(cp);
-          } else {
-            unsetenv(tz);
-          }
-          list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
-          list_init(&list->node);
-          list->time = time;
-          subTimespec(&list->convert, &time, &monotonic);
-          list_add_tail(&convertHead, &list->node);
-        }
-        if (suspended_pending && !list_empty(&convertHead)) {
-          list = node_to_item(list_tail(&convertHead), struct conversionList, node);
-          if (subTimespec(&time, subTimespec(&time, &list->time, &list->convert),
-                          &suspended_monotonic)
-                  ->tv_sec > 0) {
-            /* resume, what is convert factor before? */
-            subTimespec(&convert, &list->convert, &suspended_diff);
-          } else {
-            /* suspend */
-            convert = list->convert;
-          }
-          time = suspended_monotonic;
-          sumTimespec(&time, &convert);
-          /* breakpoint just before sleep */
-          list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
-          list_init(&list->node);
-          list->time = time;
-          list->convert = convert;
-          list_add_tail(&convertHead, &list->node);
-          /* breakpoint just after sleep */
-          list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
-          list_init(&list->node);
-          list->time = time;
-          sumTimespec(&list->time, &suspended_diff);
-          list->convert = convert;
-          sumTimespec(&list->convert, &suspended_diff);
-          list_add_tail(&convertHead, &list->node);
-          suspended_pending = false;
-        }
-      }
-      pclose(p);
-    }
-    /* last entry is our current time conversion */
-    list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
-    list_init(&list->node);
-    clock_gettime(CLOCK_REALTIME, &list->time);
-    clock_gettime(CLOCK_MONOTONIC, &convert);
-    clock_gettime(CLOCK_MONOTONIC, &time);
-    /* Correct for instant clock_gettime latency (syscall or ~30ns) */
-    subTimespec(&time, &convert, subTimespec(&time, &time, &convert));
-    /* Calculate conversion factor */
-    subTimespec(&list->convert, &list->time, &time);
-    list_add_tail(&convertHead, &list->node);
-    if (suspended_pending) {
-      /* manufacture a suspend @ point before */
-      subTimespec(&convert, &list->convert, &suspended_diff);
-      time = suspended_monotonic;
-      sumTimespec(&time, &convert);
-      /* breakpoint just after sleep */
-      list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
-      list_init(&list->node);
-      list->time = time;
-      sumTimespec(&list->time, &suspended_diff);
-      list->convert = convert;
-      sumTimespec(&list->convert, &suspended_diff);
-      list_add_head(&convertHead, &list->node);
-      /* breakpoint just before sleep */
-      list = static_cast<conversionList*>(calloc(1, sizeof(conversionList)));
-      list_init(&list->node);
-      list->time = time;
-      list->convert = convert;
-      list_add_head(&convertHead, &list->node);
-    }
-  }
-
-  /* Find the breakpoint in the conversion list */
-  list = node_to_item(list_head(&convertHead), struct conversionList, node);
-  next = NULL;
-  list_for_each(node, &convertHead) {
-    next = node_to_item(node, struct conversionList, node);
-    if (entry->tv_sec < next->time.tv_sec) {
-      break;
-    } else if (entry->tv_sec == next->time.tv_sec) {
-      if (entry->tv_nsec < next->time.tv_nsec) {
-        break;
-      }
-    }
-    list = next;
-  }
-
-  /* blend time from one breakpoint to the next */
-  convert = list->convert;
-  if (next) {
-    unsigned long long total, run;
-
-    total = nsecTimespec(subTimespec(&time, &next->time, &list->time));
-    time.tv_sec = entry->tv_sec;
-    time.tv_nsec = entry->tv_nsec;
-    run = nsecTimespec(subTimespec(&time, &time, &list->time));
-    if (run < total) {
-      long long crun;
-
-      float f = nsecTimespec(subTimespec(&time, &next->convert, &convert));
-      f *= run;
-      f /= total;
-      crun = f;
-      convert.tv_sec += crun / (long long)NS_PER_SEC;
-      if (crun < 0) {
-        convert.tv_nsec -= (-crun) % NS_PER_SEC;
-        if (convert.tv_nsec < 0) {
-          convert.tv_nsec += NS_PER_SEC;
-          convert.tv_sec -= 1;
-        }
-      } else {
-        convert.tv_nsec += crun % NS_PER_SEC;
-        if (convert.tv_nsec >= (long)NS_PER_SEC) {
-          convert.tv_nsec -= NS_PER_SEC;
-          convert.tv_sec += 1;
-        }
-      }
-    }
-  }
-
-  /* Apply the correction factor */
-  result->tv_sec = entry->tv_sec;
-  result->tv_nsec = entry->tv_nsec;
-  subTimespec(result, result, &convert);
-}
-#endif
-
-/**
- * Formats a log message into a buffer
- *
- * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer
- * If return value != defaultBuffer, caller must call free()
- * Returns NULL on malloc error
- */
-
-char* android_log_formatLogLine(AndroidLogFormat* p_format, char* defaultBuffer,
-                                size_t defaultBufferSize, const AndroidLogEntry* entry,
-                                size_t* p_outLength) {
-#if !defined(_WIN32)
-  struct tm tmBuf;
-#endif
-  struct tm* ptm;
-  /* good margin, 23+nul for msec, 26+nul for usec, 29+nul to nsec */
-  char timeBuf[64];
-  char prefixBuf[128], suffixBuf[128];
-  char priChar;
-  int prefixSuffixIsHeaderFooter = 0;
-  char* ret;
-  time_t now;
-  unsigned long nsec;
-
-  priChar = filterPriToChar(entry->priority);
-  size_t prefixLen = 0, suffixLen = 0;
-  size_t len;
-
-  /*
-   * Get the current date/time in pretty form
-   *
-   * It's often useful when examining a log with "less" to jump to
-   * a specific point in the file by searching for the date/time stamp.
-   * For this reason it's very annoying to have regexp meta characters
-   * in the time stamp.  Don't use forward slashes, parenthesis,
-   * brackets, asterisks, or other special chars here.
-   *
-   * The caller may have affected the timezone environment, this is
-   * expected to be sensitive to that.
-   */
-  now = entry->tv_sec;
-  nsec = entry->tv_nsec;
-#if __ANDROID__
-  if (p_format->monotonic_output) {
-    struct timespec time;
-    convertMonotonic(&time, entry);
-    now = time.tv_sec;
-    nsec = time.tv_nsec;
-  }
-#endif
-  if (now < 0) {
-    nsec = NS_PER_SEC - nsec;
-  }
-  if (p_format->epoch_output || p_format->monotonic_output) {
-    ptm = NULL;
-    snprintf(timeBuf, sizeof(timeBuf), p_format->monotonic_output ? "%6lld" : "%19lld",
-             (long long)now);
-  } else {
-#if !defined(_WIN32)
-    ptm = localtime_r(&now, &tmBuf);
-#else
-    ptm = localtime(&now);
-#endif
-    strftime(timeBuf, sizeof(timeBuf), &"%Y-%m-%d %H:%M:%S"[p_format->year_output ? 0 : 3], ptm);
-  }
-  len = strlen(timeBuf);
-  if (p_format->nsec_time_output) {
-    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%09ld", nsec);
-  } else if (p_format->usec_time_output) {
-    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%06ld", nsec / US_PER_NSEC);
-  } else {
-    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%03ld", nsec / MS_PER_NSEC);
-  }
-  if (p_format->zone_output && ptm) {
-    strftime(timeBuf + len, sizeof(timeBuf) - len, " %z", ptm);
-  }
-
-  /*
-   * Construct a buffer containing the log header and log message.
-   */
-  if (p_format->colored_output) {
-    prefixLen =
-        snprintf(prefixBuf, sizeof(prefixBuf), "\x1B[%dm", colorFromPri(entry->priority));
-    prefixLen = MIN(prefixLen, sizeof(prefixBuf));
-
-    const char suffixContents[] = "\x1B[0m";
-    strcpy(suffixBuf, suffixContents);
-    suffixLen = strlen(suffixContents);
-  }
-
-  char uid[16];
-  uid[0] = '\0';
-  if (p_format->uid_output) {
-    if (entry->uid >= 0) {
-/*
- * This code is Android specific, bionic guarantees that
- * calls to non-reentrant getpwuid() are thread safe.
- */
-#ifdef __ANDROID__
-      struct passwd* pwd = getpwuid(entry->uid);
-      if (pwd && (strlen(pwd->pw_name) <= 5)) {
-        snprintf(uid, sizeof(uid), "%5s:", pwd->pw_name);
-      } else
-#endif
-      {
-        /* Not worth parsing package list, names all longer than 5 */
-        snprintf(uid, sizeof(uid), "%5d:", entry->uid);
-      }
-    } else {
-      snprintf(uid, sizeof(uid), "      ");
-    }
-  }
-
-  switch (p_format->format) {
-    case FORMAT_TAG:
-      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%c/%-8.*s: ", priChar,
-                     (int)entry->tagLen, entry->tag);
-      strcpy(suffixBuf + suffixLen, "\n");
-      ++suffixLen;
-      break;
-    case FORMAT_PROCESS:
-      len = snprintf(suffixBuf + suffixLen, sizeof(suffixBuf) - suffixLen, "  (%.*s)\n",
-                     (int)entry->tagLen, entry->tag);
-      suffixLen += MIN(len, sizeof(suffixBuf) - suffixLen);
-      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%c(%s%5d) ", priChar,
-                     uid, entry->pid);
-      break;
-    case FORMAT_THREAD:
-      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen, "%c(%s%5d:%5d) ",
-                     priChar, uid, entry->pid, entry->tid);
-      strcpy(suffixBuf + suffixLen, "\n");
-      ++suffixLen;
-      break;
-    case FORMAT_RAW:
-      prefixBuf[prefixLen] = 0;
-      len = 0;
-      strcpy(suffixBuf + suffixLen, "\n");
-      ++suffixLen;
-      break;
-    case FORMAT_TIME:
-      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                     "%s %c/%-8.*s(%s%5d): ", timeBuf, priChar, (int)entry->tagLen, entry->tag, uid,
-                     entry->pid);
-      strcpy(suffixBuf + suffixLen, "\n");
-      ++suffixLen;
-      break;
-    case FORMAT_THREADTIME:
-      ret = strchr(uid, ':');
-      if (ret) {
-        *ret = ' ';
-      }
-      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                     "%s %s%5d %5d %c %-8.*s: ", timeBuf, uid, entry->pid, entry->tid, priChar,
-                     (int)entry->tagLen, entry->tag);
-      strcpy(suffixBuf + suffixLen, "\n");
-      ++suffixLen;
-      break;
-    case FORMAT_LONG:
-      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                     "[ %s %s%5d:%5d %c/%-8.*s ]\n", timeBuf, uid, entry->pid, entry->tid, priChar,
-                     (int)entry->tagLen, entry->tag);
-      strcpy(suffixBuf + suffixLen, "\n\n");
-      suffixLen += 2;
-      prefixSuffixIsHeaderFooter = 1;
-      break;
-    case FORMAT_BRIEF:
-    default:
-      len =
-          snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                   "%c/%-8.*s(%s%5d): ", priChar, (int)entry->tagLen, entry->tag, uid, entry->pid);
-      strcpy(suffixBuf + suffixLen, "\n");
-      ++suffixLen;
-      break;
-  }
-
-  /* snprintf has a weird return value.   It returns what would have been
-   * written given a large enough buffer.  In the case that the prefix is
-   * longer then our buffer(128), it messes up the calculations below
-   * possibly causing heap corruption.  To avoid this we double check and
-   * set the length at the maximum (size minus null byte)
-   */
-  prefixLen += len;
-  if (prefixLen >= sizeof(prefixBuf)) {
-    prefixLen = sizeof(prefixBuf) - 1;
-    prefixBuf[sizeof(prefixBuf) - 1] = '\0';
-  }
-  if (suffixLen >= sizeof(suffixBuf)) {
-    suffixLen = sizeof(suffixBuf) - 1;
-    suffixBuf[sizeof(suffixBuf) - 2] = '\n';
-    suffixBuf[sizeof(suffixBuf) - 1] = '\0';
-  }
-
-  /* the following code is tragically unreadable */
-
-  size_t numLines;
-  char* p;
-  size_t bufferSize;
-  const char* pm;
-
-  if (prefixSuffixIsHeaderFooter) {
-    /* we're just wrapping message with a header/footer */
-    numLines = 1;
-  } else {
-    pm = entry->message;
-    numLines = 0;
-
-    /*
-     * The line-end finding here must match the line-end finding
-     * in for ( ... numLines...) loop below
-     */
-    while (pm < (entry->message + entry->messageLen)) {
-      if (*pm++ == '\n') numLines++;
-    }
-    /* plus one line for anything not newline-terminated at the end */
-    if (pm > entry->message && *(pm - 1) != '\n') numLines++;
-  }
-
-  /*
-   * this is an upper bound--newlines in message may be counted
-   * extraneously
-   */
-  bufferSize = (numLines * (prefixLen + suffixLen)) + 1;
-  if (p_format->printable_output) {
-    /* Calculate extra length to convert non-printable to printable */
-    bufferSize += convertPrintable(NULL, entry->message, entry->messageLen);
-  } else {
-    bufferSize += entry->messageLen;
-  }
-
-  if (defaultBufferSize >= bufferSize) {
-    ret = defaultBuffer;
-  } else {
-    ret = (char*)malloc(bufferSize);
-
-    if (ret == NULL) {
-      return ret;
-    }
-  }
-
-  ret[0] = '\0'; /* to start strcat off */
-
-  p = ret;
-  pm = entry->message;
-
-  if (prefixSuffixIsHeaderFooter) {
-    strcat(p, prefixBuf);
-    p += prefixLen;
-    if (p_format->printable_output) {
-      p += convertPrintable(p, entry->message, entry->messageLen);
-    } else {
-      strncat(p, entry->message, entry->messageLen);
-      p += entry->messageLen;
-    }
-    strcat(p, suffixBuf);
-    p += suffixLen;
-  } else {
-    do {
-      const char* lineStart;
-      size_t lineLen;
-      lineStart = pm;
-
-      /* Find the next end-of-line in message */
-      while (pm < (entry->message + entry->messageLen) && *pm != '\n') pm++;
-      lineLen = pm - lineStart;
-
-      strcat(p, prefixBuf);
-      p += prefixLen;
-      if (p_format->printable_output) {
-        p += convertPrintable(p, lineStart, lineLen);
-      } else {
-        strncat(p, lineStart, lineLen);
-        p += lineLen;
-      }
-      strcat(p, suffixBuf);
-      p += suffixLen;
-
-      if (*pm == '\n') pm++;
-    } while (pm < (entry->message + entry->messageLen));
-  }
-
-  if (p_outLength != NULL) {
-    *p_outLength = p - ret;
-  }
-
-  return ret;
-}
-
-/**
- * Either print or do not print log line, based on filter
- *
- * Returns count bytes written
- */
-
-int android_log_printLogLine(AndroidLogFormat* p_format, int fd, const AndroidLogEntry* entry) {
-  int ret;
-  char defaultBuffer[512];
-  char* outBuffer = NULL;
-  size_t totalLen;
-
-  outBuffer =
-      android_log_formatLogLine(p_format, defaultBuffer, sizeof(defaultBuffer), entry, &totalLen);
-
-  if (!outBuffer) return -1;
-
-  do {
-    ret = write(fd, outBuffer, totalLen);
-  } while (ret < 0 && errno == EINTR);
-
-  if (ret < 0) {
-    fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno);
-    ret = 0;
-    goto done;
-  }
-
-  if (((size_t)ret) < totalLen) {
-    fprintf(stderr, "+++ LOG: write partial (%d of %d)\n", ret, (int)totalLen);
-    goto done;
-  }
-
-done:
-  if (outBuffer != defaultBuffer) {
-    free(outBuffer);
-  }
-
-  return ret;
-}
diff --git a/liblog/pmsg_reader.cpp b/liblog/pmsg_reader.cpp
deleted file mode 100644
index 5640900..0000000
--- a/liblog/pmsg_reader.cpp
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Copyright (C) 2007-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 "pmsg_reader.h"
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include <cutils/list.h>
-#include <private/android_logger.h>
-
-#include "logger.h"
-
-int PmsgRead(struct logger_list* logger_list, struct log_msg* log_msg) {
-  ssize_t ret;
-  off_t current, next;
-  struct __attribute__((__packed__)) {
-    android_pmsg_log_header_t p;
-    android_log_header_t l;
-    uint8_t prio;
-  } buf;
-  static uint8_t preread_count;
-
-  memset(log_msg, 0, sizeof(*log_msg));
-
-  if (atomic_load(&logger_list->fd) <= 0) {
-    int i, fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
-
-    if (fd < 0) {
-      return -errno;
-    }
-    if (fd == 0) { /* Argggg */
-      fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
-      close(0);
-      if (fd < 0) {
-        return -errno;
-      }
-    }
-    i = atomic_exchange(&logger_list->fd, fd);
-    if ((i > 0) && (i != fd)) {
-      close(i);
-    }
-    preread_count = 0;
-  }
-
-  while (1) {
-    int fd;
-
-    if (preread_count < sizeof(buf)) {
-      fd = atomic_load(&logger_list->fd);
-      if (fd <= 0) {
-        return -EBADF;
-      }
-      ret = TEMP_FAILURE_RETRY(read(fd, &buf.p.magic + preread_count, sizeof(buf) - preread_count));
-      if (ret < 0) {
-        return -errno;
-      }
-      preread_count += ret;
-    }
-    if (preread_count != sizeof(buf)) {
-      return preread_count ? -EIO : -EAGAIN;
-    }
-    if ((buf.p.magic != LOGGER_MAGIC) || (buf.p.len <= sizeof(buf)) ||
-        (buf.p.len > (sizeof(buf) + LOGGER_ENTRY_MAX_PAYLOAD)) || (buf.l.id >= LOG_ID_MAX) ||
-        (buf.l.realtime.tv_nsec >= NS_PER_SEC) ||
-        ((buf.l.id != LOG_ID_EVENTS) && (buf.l.id != LOG_ID_SECURITY) &&
-         ((buf.prio == ANDROID_LOG_UNKNOWN) || (buf.prio == ANDROID_LOG_DEFAULT) ||
-          (buf.prio >= ANDROID_LOG_SILENT)))) {
-      do {
-        memmove(&buf.p.magic, &buf.p.magic + 1, --preread_count);
-      } while (preread_count && (buf.p.magic != LOGGER_MAGIC));
-      continue;
-    }
-    preread_count = 0;
-
-    if ((logger_list->log_mask & (1 << buf.l.id)) &&
-        ((!logger_list->start.tv_sec && !logger_list->start.tv_nsec) ||
-         ((logger_list->start.tv_sec <= buf.l.realtime.tv_sec) &&
-          ((logger_list->start.tv_sec != buf.l.realtime.tv_sec) ||
-           (logger_list->start.tv_nsec <= buf.l.realtime.tv_nsec)))) &&
-        (!logger_list->pid || (logger_list->pid == buf.p.pid))) {
-      char* msg = reinterpret_cast<char*>(&log_msg->entry) + sizeof(log_msg->entry);
-      *msg = buf.prio;
-      fd = atomic_load(&logger_list->fd);
-      if (fd <= 0) {
-        return -EBADF;
-      }
-      ret = TEMP_FAILURE_RETRY(read(fd, msg + sizeof(buf.prio), buf.p.len - sizeof(buf)));
-      if (ret < 0) {
-        return -errno;
-      }
-      if (ret != (ssize_t)(buf.p.len - sizeof(buf))) {
-        return -EIO;
-      }
-
-      log_msg->entry.len = buf.p.len - sizeof(buf) + sizeof(buf.prio);
-      log_msg->entry.hdr_size = sizeof(log_msg->entry);
-      log_msg->entry.pid = buf.p.pid;
-      log_msg->entry.tid = buf.l.tid;
-      log_msg->entry.sec = buf.l.realtime.tv_sec;
-      log_msg->entry.nsec = buf.l.realtime.tv_nsec;
-      log_msg->entry.lid = buf.l.id;
-      log_msg->entry.uid = buf.p.uid;
-
-      return ret + sizeof(buf.prio) + log_msg->entry.hdr_size;
-    }
-
-    fd = atomic_load(&logger_list->fd);
-    if (fd <= 0) {
-      return -EBADF;
-    }
-    current = TEMP_FAILURE_RETRY(lseek(fd, (off_t)0, SEEK_CUR));
-    if (current < 0) {
-      return -errno;
-    }
-    fd = atomic_load(&logger_list->fd);
-    if (fd <= 0) {
-      return -EBADF;
-    }
-    next = TEMP_FAILURE_RETRY(lseek(fd, (off_t)(buf.p.len - sizeof(buf)), SEEK_CUR));
-    if (next < 0) {
-      return -errno;
-    }
-    if ((next - current) != (ssize_t)(buf.p.len - sizeof(buf))) {
-      return -EIO;
-    }
-  }
-}
-
-void PmsgClose(struct logger_list* logger_list) {
-  int fd = atomic_exchange(&logger_list->fd, 0);
-  if (fd > 0) {
-    close(fd);
-  }
-}
-
-static void* realloc_or_free(void* ptr, size_t new_size) {
-  void* result = realloc(ptr, new_size);
-  if (!result) {
-    free(ptr);
-  }
-  return result;
-}
-
-ssize_t __android_log_pmsg_file_read(log_id_t logId, char prio, const char* prefix,
-                                     __android_log_pmsg_file_read_fn fn, void* arg) {
-  ssize_t ret;
-  struct logger_list logger_list;
-  struct content {
-    struct listnode node;
-    struct logger_entry entry;
-  } * content;
-  struct names {
-    struct listnode node;
-    struct listnode content;
-    log_id_t id;
-    char prio;
-    char name[];
-  } * names;
-  struct listnode name_list;
-  struct listnode *node, *n;
-  size_t len, prefix_len;
-
-  if (!fn) {
-    return -EINVAL;
-  }
-
-  /* Add just enough clues in logger_list and transp to make API function */
-  memset(&logger_list, 0, sizeof(logger_list));
-
-  logger_list.mode = ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK;
-  logger_list.log_mask = (unsigned)-1;
-  if (logId != LOG_ID_ANY) {
-    logger_list.log_mask = (1 << logId);
-  }
-  logger_list.log_mask &= ~((1 << LOG_ID_KERNEL) | (1 << LOG_ID_EVENTS) | (1 << LOG_ID_SECURITY));
-  if (!logger_list.log_mask) {
-    return -EINVAL;
-  }
-
-  /* Initialize name list */
-  list_init(&name_list);
-
-  ret = SSIZE_MAX;
-
-  /* Validate incoming prefix, shift until it contains only 0 or 1 : or / */
-  prefix_len = 0;
-  if (prefix) {
-    const char *prev = NULL, *last = NULL, *cp = prefix;
-    while ((cp = strpbrk(cp, "/:"))) {
-      prev = last;
-      last = cp;
-      cp = cp + 1;
-    }
-    if (prev) {
-      prefix = prev + 1;
-    }
-    prefix_len = strlen(prefix);
-  }
-
-  /* Read the file content */
-  log_msg log_msg;
-  while (PmsgRead(&logger_list, &log_msg) > 0) {
-    const char* cp;
-    size_t hdr_size = log_msg.entry.hdr_size;
-
-    char* msg = (char*)&log_msg + hdr_size;
-    const char* split = NULL;
-
-    if (hdr_size != sizeof(log_msg.entry)) {
-      continue;
-    }
-    /* Check for invalid sequence number */
-    if (log_msg.entry.nsec % ANDROID_LOG_PMSG_FILE_SEQUENCE ||
-        (log_msg.entry.nsec / ANDROID_LOG_PMSG_FILE_SEQUENCE) >=
-            ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE) {
-      continue;
-    }
-
-    /* Determine if it has <dirbase>:<filebase> format for tag */
-    len = log_msg.entry.len - sizeof(prio);
-    for (cp = msg + sizeof(prio); *cp && isprint(*cp) && !isspace(*cp) && --len; ++cp) {
-      if (*cp == ':') {
-        if (split) {
-          break;
-        }
-        split = cp;
-      }
-    }
-    if (*cp || !split) {
-      continue;
-    }
-
-    /* Filters */
-    if (prefix_len && strncmp(msg + sizeof(prio), prefix, prefix_len)) {
-      size_t offset;
-      /*
-       *   Allow : to be a synonym for /
-       * Things we do dealing with const char * and do not alloc
-       */
-      split = strchr(prefix, ':');
-      if (split) {
-        continue;
-      }
-      split = strchr(prefix, '/');
-      if (!split) {
-        continue;
-      }
-      offset = split - prefix;
-      if ((msg[offset + sizeof(prio)] != ':') || strncmp(msg + sizeof(prio), prefix, offset)) {
-        continue;
-      }
-      ++offset;
-      if ((prefix_len > offset) &&
-          strncmp(&msg[offset + sizeof(prio)], split + 1, prefix_len - offset)) {
-        continue;
-      }
-    }
-
-    if ((prio != ANDROID_LOG_ANY) && (*msg < prio)) {
-      continue;
-    }
-
-    /* check if there is an existing entry */
-    list_for_each(node, &name_list) {
-      names = node_to_item(node, struct names, node);
-      if (!strcmp(names->name, msg + sizeof(prio)) && names->id == log_msg.entry.lid &&
-          names->prio == *msg) {
-        break;
-      }
-    }
-
-    /* We do not have an existing entry, create and add one */
-    if (node == &name_list) {
-      static const char numbers[] = "0123456789";
-      unsigned long long nl;
-
-      len = strlen(msg + sizeof(prio)) + 1;
-      names = static_cast<struct names*>(calloc(1, sizeof(*names) + len));
-      if (!names) {
-        ret = -ENOMEM;
-        break;
-      }
-      strcpy(names->name, msg + sizeof(prio));
-      names->id = static_cast<log_id_t>(log_msg.entry.lid);
-      names->prio = *msg;
-      list_init(&names->content);
-      /*
-       * Insert in reverse numeric _then_ alpha sorted order as
-       * representative of log rotation:
-       *
-       *   log.10
-       *   klog.10
-       *   . . .
-       *   log.2
-       *   klog.2
-       *   log.1
-       *   klog.1
-       *   log
-       *   klog
-       *
-       * thus when we present the content, we are provided the oldest
-       * first, which when 'refreshed' could spill off the end of the
-       * pmsg FIFO but retaining the newest data for last with best
-       * chances to survive.
-       */
-      nl = 0;
-      cp = strpbrk(names->name, numbers);
-      if (cp) {
-        nl = strtoull(cp, NULL, 10);
-      }
-      list_for_each_reverse(node, &name_list) {
-        struct names* a_name = node_to_item(node, struct names, node);
-        const char* r = a_name->name;
-        int compare = 0;
-
-        unsigned long long nr = 0;
-        cp = strpbrk(r, numbers);
-        if (cp) {
-          nr = strtoull(cp, NULL, 10);
-        }
-        if (nr != nl) {
-          compare = (nl > nr) ? 1 : -1;
-        }
-        if (compare == 0) {
-          compare = strcmp(names->name, r);
-        }
-        if (compare <= 0) {
-          break;
-        }
-      }
-      list_add_head(node, &names->node);
-    }
-
-    /* Remove any file fragments that match our sequence number */
-    list_for_each_safe(node, n, &names->content) {
-      content = node_to_item(node, struct content, node);
-      if (log_msg.entry.nsec == content->entry.nsec) {
-        list_remove(&content->node);
-        free(content);
-      }
-    }
-
-    /* Add content */
-    content = static_cast<struct content*>(
-        calloc(1, sizeof(content->node) + hdr_size + log_msg.entry.len));
-    if (!content) {
-      ret = -ENOMEM;
-      break;
-    }
-    memcpy(&content->entry, &log_msg.entry, hdr_size + log_msg.entry.len);
-
-    /* Insert in sequence number sorted order, to ease reconstruction */
-    list_for_each_reverse(node, &names->content) {
-      if ((node_to_item(node, struct content, node))->entry.nsec < log_msg.entry.nsec) {
-        break;
-      }
-    }
-    list_add_head(node, &content->node);
-  }
-  PmsgClose(&logger_list);
-
-  /* Progress through all the collected files */
-  list_for_each_safe(node, n, &name_list) {
-    struct listnode *content_node, *m;
-    char* buf;
-    size_t sequence, tag_len;
-
-    names = node_to_item(node, struct names, node);
-
-    /* Construct content into a linear buffer */
-    buf = NULL;
-    len = 0;
-    sequence = 0;
-    tag_len = strlen(names->name) + sizeof(char); /* tag + nul */
-    list_for_each_safe(content_node, m, &names->content) {
-      ssize_t add_len;
-
-      content = node_to_item(content_node, struct content, node);
-      add_len = content->entry.len - tag_len - sizeof(prio);
-      if (add_len <= 0) {
-        list_remove(content_node);
-        free(content);
-        continue;
-      }
-
-      if (!buf) {
-        buf = static_cast<char*>(malloc(sizeof(char)));
-        if (!buf) {
-          ret = -ENOMEM;
-          list_remove(content_node);
-          free(content);
-          continue;
-        }
-        *buf = '\0';
-      }
-
-      /* Missing sequence numbers */
-      while (sequence < content->entry.nsec) {
-        /* plus space for enforced nul */
-        buf = static_cast<char*>(realloc_or_free(buf, len + sizeof(char) + sizeof(char)));
-        if (!buf) {
-          break;
-        }
-        buf[len] = '\f'; /* Mark missing content with a form feed */
-        buf[++len] = '\0';
-        sequence += ANDROID_LOG_PMSG_FILE_SEQUENCE;
-      }
-      if (!buf) {
-        ret = -ENOMEM;
-        list_remove(content_node);
-        free(content);
-        continue;
-      }
-      /* plus space for enforced nul */
-      buf = static_cast<char*>(realloc_or_free(buf, len + add_len + sizeof(char)));
-      if (!buf) {
-        ret = -ENOMEM;
-        list_remove(content_node);
-        free(content);
-        continue;
-      }
-      memcpy(buf + len, (char*)&content->entry + content->entry.hdr_size + tag_len + sizeof(prio),
-             add_len);
-      len += add_len;
-      buf[len] = '\0'; /* enforce trailing hidden nul */
-      sequence = content->entry.nsec + ANDROID_LOG_PMSG_FILE_SEQUENCE;
-
-      list_remove(content_node);
-      free(content);
-    }
-    if (buf) {
-      if (len) {
-        /* Buffer contains enforced trailing nul just beyond length */
-        ssize_t r;
-        *strchr(names->name, ':') = '/'; /* Convert back to filename */
-        r = (*fn)(names->id, names->prio, names->name, buf, len, arg);
-        if ((ret >= 0) && (r > 0)) {
-          if (ret == SSIZE_MAX) {
-            ret = r;
-          } else {
-            ret += r;
-          }
-        } else if (r < ret) {
-          ret = r;
-        }
-      }
-      free(buf);
-    }
-    list_remove(node);
-    free(names);
-  }
-  return (ret == SSIZE_MAX) ? -ENOENT : ret;
-}
diff --git a/liblog/pmsg_reader.h b/liblog/pmsg_reader.h
deleted file mode 100644
index b784f9f..0000000
--- a/liblog/pmsg_reader.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2019 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 <sys/cdefs.h>
-#include <unistd.h>
-
-#include "log/log_read.h"
-
-__BEGIN_DECLS
-
-int PmsgRead(struct logger_list* logger_list, struct log_msg* log_msg);
-void PmsgClose(struct logger_list* logger_list);
-
-__END_DECLS
diff --git a/liblog/pmsg_writer.cpp b/liblog/pmsg_writer.cpp
deleted file mode 100644
index 8e676bd..0000000
--- a/liblog/pmsg_writer.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2007-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 "pmsg_writer.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <time.h>
-
-#include <log/log_properties.h>
-#include <private/android_logger.h>
-
-#include "logger.h"
-#include "uio.h"
-
-static atomic_int pmsg_fd;
-
-// pmsg_fd should only beopened once.  If we see that pmsg_fd is uninitialized, we open "/dev/pmsg0"
-// then attempt to compare/exchange it into pmsg_fd.  If the compare/exchange was successful, then
-// that will be the fd used for the duration of the program, otherwise a different thread has
-// already opened and written the fd to the atomic, so close the new fd and return.
-static void GetPmsgFd() {
-  if (pmsg_fd != 0) {
-    return;
-  }
-
-  int new_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-  if (new_fd <= 0) {
-    return;
-  }
-
-  int uninitialized_value = 0;
-  if (!pmsg_fd.compare_exchange_strong(uninitialized_value, new_fd)) {
-    close(new_fd);
-    return;
-  }
-}
-
-void PmsgClose() {
-  if (pmsg_fd > 0) {
-    close(pmsg_fd);
-  }
-  pmsg_fd = 0;
-}
-
-int PmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
-  static const unsigned headerLength = 2;
-  struct iovec newVec[nr + headerLength];
-  android_log_header_t header;
-  android_pmsg_log_header_t pmsgHeader;
-  size_t i, payloadSize;
-  ssize_t ret;
-
-  if (!__android_log_is_debuggable()) {
-    if (logId != LOG_ID_EVENTS && logId != LOG_ID_SECURITY) {
-      return -1;
-    }
-
-    if (logId == LOG_ID_EVENTS) {
-      if (vec[0].iov_len < 4) {
-        return -EINVAL;
-      }
-
-      if (SNET_EVENT_LOG_TAG != *static_cast<uint32_t*>(vec[0].iov_base)) {
-        return -EPERM;
-      }
-    }
-  }
-
-  GetPmsgFd();
-
-  if (pmsg_fd <= 0) {
-    return -EBADF;
-  }
-
-  /*
-   *  struct {
-   *      // what we provide to pstore
-   *      android_pmsg_log_header_t pmsgHeader;
-   *      // what we provide to file
-   *      android_log_header_t header;
-   *      // caller provides
-   *      union {
-   *          struct {
-   *              char     prio;
-   *              char     payload[];
-   *          } string;
-   *          struct {
-   *              uint32_t tag
-   *              char     payload[];
-   *          } binary;
-   *      };
-   *  };
-   */
-
-  pmsgHeader.magic = LOGGER_MAGIC;
-  pmsgHeader.len = sizeof(pmsgHeader) + sizeof(header);
-  pmsgHeader.uid = getuid();
-  pmsgHeader.pid = getpid();
-
-  header.id = logId;
-  header.tid = gettid();
-  header.realtime.tv_sec = ts->tv_sec;
-  header.realtime.tv_nsec = ts->tv_nsec;
-
-  newVec[0].iov_base = (unsigned char*)&pmsgHeader;
-  newVec[0].iov_len = sizeof(pmsgHeader);
-  newVec[1].iov_base = (unsigned char*)&header;
-  newVec[1].iov_len = sizeof(header);
-
-  for (payloadSize = 0, i = headerLength; i < nr + headerLength; i++) {
-    newVec[i].iov_base = vec[i - headerLength].iov_base;
-    payloadSize += newVec[i].iov_len = vec[i - headerLength].iov_len;
-
-    if (payloadSize > LOGGER_ENTRY_MAX_PAYLOAD) {
-      newVec[i].iov_len -= payloadSize - LOGGER_ENTRY_MAX_PAYLOAD;
-      if (newVec[i].iov_len) {
-        ++i;
-      }
-      payloadSize = LOGGER_ENTRY_MAX_PAYLOAD;
-      break;
-    }
-  }
-  pmsgHeader.len += payloadSize;
-
-  ret = TEMP_FAILURE_RETRY(writev(pmsg_fd, newVec, i));
-  if (ret < 0) {
-    ret = errno ? -errno : -ENOTCONN;
-  }
-
-  if (ret > (ssize_t)(sizeof(header) + sizeof(pmsgHeader))) {
-    ret -= sizeof(header) - sizeof(pmsgHeader);
-  }
-
-  return ret;
-}
-
-/*
- * Virtual pmsg filesystem
- *
- * Payload will comprise the string "<basedir>:<basefile>\0<content>" to a
- * maximum of LOGGER_ENTRY_MAX_PAYLOAD, but scaled to the last newline in the
- * file.
- *
- * Will hijack the header.realtime.tv_nsec field for a sequence number in usec.
- */
-
-static inline const char* strnrchr(const char* buf, size_t len, char c) {
-  const char* cp = buf + len;
-  while ((--cp > buf) && (*cp != c))
-    ;
-  if (cp <= buf) {
-    return buf + len;
-  }
-  return cp;
-}
-
-/* Write a buffer as filename references (tag = <basedir>:<basename>) */
-ssize_t __android_log_pmsg_file_write(log_id_t logId, char prio, const char* filename,
-                                      const char* buf, size_t len) {
-  size_t length, packet_len;
-  const char* tag;
-  char *cp, *slash;
-  struct timespec ts;
-  struct iovec vec[3];
-
-  /* Make sure the logId value is not a bad idea */
-  if ((logId == LOG_ID_KERNEL) ||   /* Verbotten */
-      (logId == LOG_ID_EVENTS) ||   /* Do not support binary content */
-      (logId == LOG_ID_SECURITY) || /* Bad idea to allow */
-      ((unsigned)logId >= 32)) {    /* fit within logMask on arch32 */
-    return -EINVAL;
-  }
-
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  cp = strdup(filename);
-  if (!cp) {
-    return -ENOMEM;
-  }
-
-  tag = cp;
-  slash = strrchr(cp, '/');
-  if (slash) {
-    *slash = ':';
-    slash = strrchr(cp, '/');
-    if (slash) {
-      tag = slash + 1;
-    }
-  }
-
-  length = strlen(tag) + 1;
-  packet_len = LOGGER_ENTRY_MAX_PAYLOAD - sizeof(char) - length;
-
-  vec[0].iov_base = &prio;
-  vec[0].iov_len = sizeof(char);
-  vec[1].iov_base = (unsigned char*)tag;
-  vec[1].iov_len = length;
-
-  for (ts.tv_nsec = 0, length = len; length; ts.tv_nsec += ANDROID_LOG_PMSG_FILE_SEQUENCE) {
-    ssize_t ret;
-    size_t transfer;
-
-    if ((ts.tv_nsec / ANDROID_LOG_PMSG_FILE_SEQUENCE) >= ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE) {
-      len -= length;
-      break;
-    }
-
-    transfer = length;
-    if (transfer > packet_len) {
-      transfer = strnrchr(buf, packet_len - 1, '\n') - buf;
-      if ((transfer < length) && (buf[transfer] == '\n')) {
-        ++transfer;
-      }
-    }
-
-    vec[2].iov_base = (unsigned char*)buf;
-    vec[2].iov_len = transfer;
-
-    ret = PmsgWrite(logId, &ts, vec, sizeof(vec) / sizeof(vec[0]));
-
-    if (ret <= 0) {
-      free(cp);
-      return ret ? ret : (len - length);
-    }
-    length -= transfer;
-    buf += transfer;
-  }
-  free(cp);
-  return len;
-}
diff --git a/liblog/properties.cpp b/liblog/properties.cpp
deleted file mode 100644
index 88f0bf1..0000000
--- a/liblog/properties.cpp
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
-** Copyright 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 <log/log_properties.h>
-
-#include <ctype.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <algorithm>
-
-#include <private/android_logger.h>
-
-#include "logger_write.h"
-
-#ifdef __ANDROID__
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#include <sys/_system_properties.h>
-
-static pthread_mutex_t lock_loggable = PTHREAD_MUTEX_INITIALIZER;
-
-static int lock() {
-  /*
-   * If we trigger a signal handler in the middle of locked activity and the
-   * signal handler logs a message, we could get into a deadlock state.
-   */
-  /*
-   *  Any contention, and we can turn around and use the non-cached method
-   * in less time than the system call associated with a mutex to deal with
-   * the contention.
-   */
-  return pthread_mutex_trylock(&lock_loggable);
-}
-
-static void unlock() {
-  pthread_mutex_unlock(&lock_loggable);
-}
-
-struct cache {
-  const prop_info* pinfo;
-  uint32_t serial;
-};
-
-struct cache_char {
-  struct cache cache;
-  unsigned char c;
-};
-
-static int check_cache(struct cache* cache) {
-  return cache->pinfo && __system_property_serial(cache->pinfo) != cache->serial;
-}
-
-#define BOOLEAN_TRUE 0xFF
-#define BOOLEAN_FALSE 0xFE
-
-static void refresh_cache(struct cache_char* cache, const char* key) {
-  char buf[PROP_VALUE_MAX];
-
-  if (!cache->cache.pinfo) {
-    cache->cache.pinfo = __system_property_find(key);
-    if (!cache->cache.pinfo) {
-      return;
-    }
-  }
-  cache->cache.serial = __system_property_serial(cache->cache.pinfo);
-  __system_property_read(cache->cache.pinfo, 0, buf);
-  switch (buf[0]) {
-    case 't':
-    case 'T':
-      cache->c = strcasecmp(buf + 1, "rue") ? buf[0] : BOOLEAN_TRUE;
-      break;
-    case 'f':
-    case 'F':
-      cache->c = strcasecmp(buf + 1, "alse") ? buf[0] : BOOLEAN_FALSE;
-      break;
-    default:
-      cache->c = buf[0];
-  }
-}
-
-static int __android_log_level(const char* tag, size_t len) {
-  /* sizeof() is used on this array below */
-  static const char log_namespace[] = "persist.log.tag.";
-  static const size_t base_offset = 8; /* skip "persist." */
-
-  if (tag == nullptr || len == 0) {
-    auto& tag_string = GetDefaultTag();
-    tag = tag_string.c_str();
-    len = tag_string.size();
-  }
-
-  /* sizeof(log_namespace) = strlen(log_namespace) + 1 */
-  char key[sizeof(log_namespace) + len];
-  char* kp;
-  size_t i;
-  char c = 0;
-  /*
-   * Single layer cache of four properties. Priorities are:
-   *    log.tag.<tag>
-   *    persist.log.tag.<tag>
-   *    log.tag
-   *    persist.log.tag
-   * Where the missing tag matches all tags and becomes the
-   * system global default. We do not support ro.log.tag* .
-   */
-  static char* last_tag;
-  static size_t last_tag_len;
-  static uint32_t global_serial;
-  /* some compilers erroneously see uninitialized use. !not_locked */
-  uint32_t current_global_serial = 0;
-  static struct cache_char tag_cache[2];
-  static struct cache_char global_cache[2];
-  int change_detected;
-  int global_change_detected;
-  int not_locked;
-
-  strcpy(key, log_namespace);
-
-  global_change_detected = change_detected = not_locked = lock();
-
-  if (!not_locked) {
-    /*
-     *  check all known serial numbers to changes.
-     */
-    for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
-      if (check_cache(&tag_cache[i].cache)) {
-        change_detected = 1;
-      }
-    }
-    for (i = 0; i < (sizeof(global_cache) / sizeof(global_cache[0])); ++i) {
-      if (check_cache(&global_cache[i].cache)) {
-        global_change_detected = 1;
-      }
-    }
-
-    current_global_serial = __system_property_area_serial();
-    if (current_global_serial != global_serial) {
-      change_detected = 1;
-      global_change_detected = 1;
-    }
-  }
-
-  if (len) {
-    int local_change_detected = change_detected;
-    if (!not_locked) {
-      if (!last_tag || !last_tag[0] || (last_tag[0] != tag[0]) ||
-          strncmp(last_tag + 1, tag + 1, last_tag_len - 1)) {
-        /* invalidate log.tag.<tag> cache */
-        for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
-          tag_cache[i].cache.pinfo = NULL;
-          tag_cache[i].c = '\0';
-        }
-        if (last_tag) last_tag[0] = '\0';
-        local_change_detected = 1;
-      }
-      if (!last_tag || !last_tag[0]) {
-        if (!last_tag) {
-          last_tag = static_cast<char*>(calloc(1, len + 1));
-          last_tag_len = 0;
-          if (last_tag) last_tag_len = len + 1;
-        } else if (len >= last_tag_len) {
-          last_tag = static_cast<char*>(realloc(last_tag, len + 1));
-          last_tag_len = 0;
-          if (last_tag) last_tag_len = len + 1;
-        }
-        if (last_tag) {
-          strncpy(last_tag, tag, len);
-          last_tag[len] = '\0';
-        }
-      }
-    }
-    strncpy(key + sizeof(log_namespace) - 1, tag, len);
-    key[sizeof(log_namespace) - 1 + len] = '\0';
-
-    kp = key;
-    for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
-      struct cache_char* cache = &tag_cache[i];
-      struct cache_char temp_cache;
-
-      if (not_locked) {
-        temp_cache.cache.pinfo = NULL;
-        temp_cache.c = '\0';
-        cache = &temp_cache;
-      }
-      if (local_change_detected) {
-        refresh_cache(cache, kp);
-      }
-
-      if (cache->c) {
-        c = cache->c;
-        break;
-      }
-
-      kp = key + base_offset;
-    }
-  }
-
-  switch (toupper(c)) { /* if invalid, resort to global */
-    case 'V':
-    case 'D':
-    case 'I':
-    case 'W':
-    case 'E':
-    case 'F': /* Not officially supported */
-    case 'A':
-    case 'S':
-    case BOOLEAN_FALSE: /* Not officially supported */
-      break;
-    default:
-      /* clear '.' after log.tag */
-      key[sizeof(log_namespace) - 2] = '\0';
-
-      kp = key;
-      for (i = 0; i < (sizeof(global_cache) / sizeof(global_cache[0])); ++i) {
-        struct cache_char* cache = &global_cache[i];
-        struct cache_char temp_cache;
-
-        if (not_locked) {
-          temp_cache = *cache;
-          if (temp_cache.cache.pinfo != cache->cache.pinfo) { /* check atomic */
-            temp_cache.cache.pinfo = NULL;
-            temp_cache.c = '\0';
-          }
-          cache = &temp_cache;
-        }
-        if (global_change_detected) {
-          refresh_cache(cache, kp);
-        }
-
-        if (cache->c) {
-          c = cache->c;
-          break;
-        }
-
-        kp = key + base_offset;
-      }
-      break;
-  }
-
-  if (!not_locked) {
-    global_serial = current_global_serial;
-    unlock();
-  }
-
-  switch (toupper(c)) {
-    /* clang-format off */
-    case 'V': return ANDROID_LOG_VERBOSE;
-    case 'D': return ANDROID_LOG_DEBUG;
-    case 'I': return ANDROID_LOG_INFO;
-    case 'W': return ANDROID_LOG_WARN;
-    case 'E': return ANDROID_LOG_ERROR;
-    case 'F': /* FALLTHRU */ /* Not officially supported */
-    case 'A': return ANDROID_LOG_FATAL;
-    case BOOLEAN_FALSE: /* FALLTHRU */ /* Not Officially supported */
-    case 'S': return ANDROID_LOG_SILENT;
-      /* clang-format on */
-  }
-  return -1;
-}
-
-int __android_log_is_loggable_len(int prio, const char* tag, size_t len, int default_prio) {
-  int minimum_log_priority = __android_log_get_minimum_priority();
-  int property_log_level = __android_log_level(tag, len);
-
-  if (property_log_level >= 0 && minimum_log_priority != ANDROID_LOG_DEFAULT) {
-    return prio >= std::min(property_log_level, minimum_log_priority);
-  } else if (property_log_level >= 0) {
-    return prio >= property_log_level;
-  } else if (minimum_log_priority != ANDROID_LOG_DEFAULT) {
-    return prio >= minimum_log_priority;
-  } else {
-    return prio >= default_prio;
-  }
-}
-
-int __android_log_is_loggable(int prio, const char* tag, int default_prio) {
-  auto len = tag ? strlen(tag) : 0;
-  return __android_log_is_loggable_len(prio, tag, len, default_prio);
-}
-
-int __android_log_is_debuggable() {
-  static int is_debuggable = [] {
-    char value[PROP_VALUE_MAX] = {};
-    return __system_property_get("ro.debuggable", value) > 0 && !strcmp(value, "1");
-  }();
-
-  return is_debuggable;
-}
-
-/*
- * For properties that are read often, but generally remain constant.
- * Since a change is rare, we will accept a trylock failure gracefully.
- * Use a separate lock from is_loggable to keep contention down b/25563384.
- */
-struct cache2_char {
-  pthread_mutex_t lock;
-  uint32_t serial;
-  const char* key_persist;
-  struct cache_char cache_persist;
-  const char* key_ro;
-  struct cache_char cache_ro;
-  unsigned char (*const evaluate)(const struct cache2_char* self);
-};
-
-static inline unsigned char do_cache2_char(struct cache2_char* self) {
-  uint32_t current_serial;
-  int change_detected;
-  unsigned char c;
-
-  if (pthread_mutex_trylock(&self->lock)) {
-    /* We are willing to accept some race in this context */
-    return self->evaluate(self);
-  }
-
-  change_detected = check_cache(&self->cache_persist.cache) || check_cache(&self->cache_ro.cache);
-  current_serial = __system_property_area_serial();
-  if (current_serial != self->serial) {
-    change_detected = 1;
-  }
-  if (change_detected) {
-    refresh_cache(&self->cache_persist, self->key_persist);
-    refresh_cache(&self->cache_ro, self->key_ro);
-    self->serial = current_serial;
-  }
-  c = self->evaluate(self);
-
-  pthread_mutex_unlock(&self->lock);
-
-  return c;
-}
-
-/*
- * Security state generally remains constant, but the DO must be able
- * to turn off logging should it become spammy after an attack is detected.
- */
-static unsigned char evaluate_security(const struct cache2_char* self) {
-  unsigned char c = self->cache_ro.c;
-
-  return (c != BOOLEAN_FALSE) && c && (self->cache_persist.c == BOOLEAN_TRUE);
-}
-
-int __android_log_security() {
-  static struct cache2_char security = {
-      PTHREAD_MUTEX_INITIALIZER, 0,
-      "persist.logd.security",   {{NULL, 0xFFFFFFFF}, BOOLEAN_FALSE},
-      "ro.organization_owned",   {{NULL, 0xFFFFFFFF}, BOOLEAN_FALSE},
-      evaluate_security};
-
-  return do_cache2_char(&security);
-}
-
-#else
-
-int __android_log_is_loggable(int prio, const char*, int) {
-  int minimum_priority = __android_log_get_minimum_priority();
-  if (minimum_priority == ANDROID_LOG_DEFAULT) {
-    minimum_priority = ANDROID_LOG_INFO;
-  }
-  return prio >= minimum_priority;
-}
-
-int __android_log_is_loggable_len(int prio, const char*, size_t, int def) {
-  return __android_log_is_loggable(prio, nullptr, def);
-}
-
-int __android_log_is_debuggable() {
-  return 1;
-}
-
-#endif
diff --git a/liblog/tests/Android.bp b/liblog/tests/Android.bp
deleted file mode 100644
index a17d90c..0000000
--- a/liblog/tests/Android.bp
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// Copyright (C) 2013-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.
-//
-
-// -----------------------------------------------------------------------------
-// Benchmarks.
-// -----------------------------------------------------------------------------
-
-// Build benchmarks for the device. Run with:
-//   adb shell liblog-benchmarks
-cc_benchmark {
-    name: "liblog-benchmarks",
-    cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-        "-fno-builtin",
-    ],
-    shared_libs: [
-        "libm",
-        "libbase",
-        "libcutils",
-    ],
-    static_libs: ["liblog"],
-    srcs: ["liblog_benchmark.cpp"],
-}
-
-// -----------------------------------------------------------------------------
-// Unit tests.
-// -----------------------------------------------------------------------------
-
-cc_defaults {
-    name: "liblog-tests-defaults",
-
-    cflags: [
-        "-fstack-protector-all",
-        "-g",
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-        "-fno-builtin",
-    ],
-    srcs: [
-        "libc_test.cpp",
-        "liblog_default_tag.cpp",
-        "liblog_global_state.cpp",
-        "liblog_test.cpp",
-        "log_id_test.cpp",
-        "log_radio_test.cpp",
-        "log_read_test.cpp",
-        "log_system_test.cpp",
-        "log_time_test.cpp",
-        "log_wrap_test.cpp",
-        "logd_writer_test.cpp",
-        "logprint_test.cpp",
-    ],
-    shared_libs: [
-        "libcutils",
-        "libbase",
-    ],
-    static_libs: ["liblog"],
-    isolated: true,
-    require_root: true,
-}
-
-// Build tests for the device (with .so). Run with:
-//   adb shell /data/nativetest/liblog-unit-tests/liblog-unit-tests
-cc_test {
-    name: "liblog-unit-tests",
-    defaults: ["liblog-tests-defaults"],
-}
-
-cc_test {
-    name: "CtsLiblogTestCases",
-    defaults: ["liblog-tests-defaults"],
-    multilib: {
-        lib32: {
-            suffix: "32",
-        },
-        lib64: {
-            suffix: "64",
-        },
-    },
-
-    cflags: ["-DNO_PSTORE"],
-    test_suites: [
-        "cts",
-        "device-tests",
-        "vts10",
-    ],
-}
-
-cc_test_host {
-    name: "liblog-host-test",
-    static_libs: ["liblog"],
-    shared_libs: ["libbase"],
-    srcs: [
-        "liblog_host_test.cpp",
-        "liblog_default_tag.cpp",
-        "liblog_global_state.cpp",
-    ],
-    isolated: true,
-}
diff --git a/liblog/tests/AndroidTest.xml b/liblog/tests/AndroidTest.xml
deleted file mode 100644
index fcb46b1..0000000
--- a/liblog/tests/AndroidTest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Config for CTS Logging Library test cases">
-    <option name="test-suite-tag" value="cts" />
-    <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
-    <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
-    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="cleanup" value="true" />
-        <option name="push" value="CtsLiblogTestCases->/data/local/tmp/CtsLiblogTestCases" />
-        <option name="append-bitness" value="true" />
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.GTest" >
-        <option name="native-test-device-path" value="/data/local/tmp" />
-        <option name="module-name" value="CtsLiblogTestCases" />
-        <option name="runtime-hint" value="65s" />
-    </test>
-</configuration>
diff --git a/liblog/tests/libc_test.cpp b/liblog/tests/libc_test.cpp
deleted file mode 100644
index 1f26263..0000000
--- a/liblog/tests/libc_test.cpp
+++ /dev/null
@@ -1,57 +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 <errno.h>
-#include <stdio.h>
-
-TEST(libc, __pstore_append) {
-#ifdef __ANDROID__
-#ifndef NO_PSTORE
-  if (access("/dev/pmsg0", W_OK) != 0) {
-    GTEST_SKIP() << "pmsg0 not found, skipping test";
-  }
-
-  FILE* fp;
-  ASSERT_TRUE(NULL != (fp = fopen("/dev/pmsg0", "ae")));
-  static const char message[] = "libc.__pstore_append\n";
-  ASSERT_EQ((size_t)1, fwrite(message, sizeof(message), 1, fp));
-  int fflushReturn = fflush(fp);
-  int fflushErrno = fflushReturn ? errno : 0;
-  ASSERT_EQ(0, fflushReturn);
-  ASSERT_EQ(0, fflushErrno);
-  int fcloseReturn = fclose(fp);
-  int fcloseErrno = fcloseReturn ? errno : 0;
-  ASSERT_EQ(0, fcloseReturn);
-  ASSERT_EQ(0, fcloseErrno);
-  if ((fcloseErrno == ENOMEM) || (fflushErrno == ENOMEM)) {
-    fprintf(stderr,
-            "Kernel does not have space allocated to pmsg pstore driver "
-            "configured\n");
-  }
-  if (!fcloseReturn && !fcloseErrno && !fflushReturn && !fflushReturn) {
-    fprintf(stderr,
-            "Reboot, ensure string libc.__pstore_append is in "
-            "/sys/fs/pstore/pmsg-ramoops-0\n");
-  }
-#else  /* NO_PSTORE */
-  GTEST_LOG_(INFO) << "This test does nothing because of NO_PSTORE.\n";
-#endif /* NO_PSTORE */
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
diff --git a/liblog/tests/liblog_benchmark.cpp b/liblog/tests/liblog_benchmark.cpp
deleted file mode 100644
index 3bd5cf2..0000000
--- a/liblog/tests/liblog_benchmark.cpp
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*
- * Copyright (C) 2013-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 <fcntl.h>
-#include <inttypes.h>
-#include <poll.h>
-#include <sched.h>
-#include <sys/socket.h>
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-
-#include <unordered_set>
-
-#include <android-base/file.h>
-#include <android-base/properties.h>
-#include <benchmark/benchmark.h>
-#include <cutils/sockets.h>
-#include <log/event_tag_map.h>
-#include <log/log_read.h>
-#include <private/android_logger.h>
-
-BENCHMARK_MAIN();
-
-// enhanced version of LOG_FAILURE_RETRY to add support for EAGAIN and
-// non-syscall libs. Since we are benchmarking, or using this in the emergency
-// signal to stuff a terminating code, we do NOT want to introduce
-// a syscall or usleep on EAGAIN retry.
-#define LOG_FAILURE_RETRY(exp)                                           \
-  ({                                                                     \
-    typeof(exp) _rc;                                                     \
-    do {                                                                 \
-      _rc = (exp);                                                       \
-    } while (((_rc == -1) && ((errno == EINTR) || (errno == EAGAIN))) || \
-             (_rc == -EINTR) || (_rc == -EAGAIN));                       \
-    _rc;                                                                 \
-  })
-
-/*
- *	Measure the fastest rate we can reliabley stuff print messages into
- * the log at high pressure. Expect this to be less than double the process
- * wakeup time (2ms?)
- */
-static void BM_log_maximum_retry(benchmark::State& state) {
-  while (state.KeepRunning()) {
-    LOG_FAILURE_RETRY(__android_log_print(ANDROID_LOG_INFO, "BM_log_maximum_retry", "%" PRIu64,
-                                          state.iterations()));
-  }
-}
-BENCHMARK(BM_log_maximum_retry);
-
-/*
- *	Measure the fastest rate we can stuff print messages into the log
- * at high pressure. Expect this to be less than double the process wakeup
- * time (2ms?)
- */
-static void BM_log_maximum(benchmark::State& state) {
-  while (state.KeepRunning()) {
-    __android_log_print(ANDROID_LOG_INFO, "BM_log_maximum", "%" PRIu64, state.iterations());
-  }
-}
-BENCHMARK(BM_log_maximum);
-
-/*
- *	Measure the time it takes to collect the time using
- * discrete acquisition (state.PauseTiming() to state.ResumeTiming())
- * under light load. Expect this to be a syscall period (2us) or
- * data read time if zero-syscall.
- *
- * vdso support in the kernel and the library can allow
- * clock_gettime to be zero-syscall, but there there does remain some
- * benchmarking overhead to pause and resume; assumptions are both are
- * covered.
- */
-static void BM_clock_overhead(benchmark::State& state) {
-  while (state.KeepRunning()) {
-    state.PauseTiming();
-    state.ResumeTiming();
-  }
-}
-BENCHMARK(BM_clock_overhead);
-
-static void do_clock_overhead(benchmark::State& state, clockid_t clk_id) {
-  timespec t;
-  while (state.KeepRunning()) {
-    clock_gettime(clk_id, &t);
-  }
-}
-
-static void BM_time_clock_gettime_REALTIME(benchmark::State& state) {
-  do_clock_overhead(state, CLOCK_REALTIME);
-}
-BENCHMARK(BM_time_clock_gettime_REALTIME);
-
-static void BM_time_clock_gettime_MONOTONIC(benchmark::State& state) {
-  do_clock_overhead(state, CLOCK_MONOTONIC);
-}
-BENCHMARK(BM_time_clock_gettime_MONOTONIC);
-
-static void BM_time_clock_gettime_MONOTONIC_syscall(benchmark::State& state) {
-  timespec t;
-  while (state.KeepRunning()) {
-    syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &t);
-  }
-}
-BENCHMARK(BM_time_clock_gettime_MONOTONIC_syscall);
-
-static void BM_time_clock_gettime_MONOTONIC_RAW(benchmark::State& state) {
-  do_clock_overhead(state, CLOCK_MONOTONIC_RAW);
-}
-BENCHMARK(BM_time_clock_gettime_MONOTONIC_RAW);
-
-static void BM_time_clock_gettime_BOOTTIME(benchmark::State& state) {
-  do_clock_overhead(state, CLOCK_BOOTTIME);
-}
-BENCHMARK(BM_time_clock_gettime_BOOTTIME);
-
-static void BM_time_clock_getres_MONOTONIC(benchmark::State& state) {
-  timespec t;
-  while (state.KeepRunning()) {
-    clock_getres(CLOCK_MONOTONIC, &t);
-  }
-}
-BENCHMARK(BM_time_clock_getres_MONOTONIC);
-
-static void BM_time_clock_getres_MONOTONIC_syscall(benchmark::State& state) {
-  timespec t;
-  while (state.KeepRunning()) {
-    syscall(__NR_clock_getres, CLOCK_MONOTONIC, &t);
-  }
-}
-BENCHMARK(BM_time_clock_getres_MONOTONIC_syscall);
-
-static void BM_time_time(benchmark::State& state) {
-  while (state.KeepRunning()) {
-    time_t now;
-    now = time(&now);
-  }
-}
-BENCHMARK(BM_time_time);
-
-/*
- * Measure the time it takes to submit the android logging data to pstore
- */
-static void BM_pmsg_short(benchmark::State& state) {
-  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-  if (pstore_fd < 0) {
-    state.SkipWithError("/dev/pmsg0");
-    return;
-  }
-
-  /*
-   *  struct {
-   *      // what we provide to pstore
-   *      android_pmsg_log_header_t pmsg_header;
-   *      // what we provide to socket
-   *      android_log_header_t header;
-   *      // caller provides
-   *      union {
-   *          struct {
-   *              char     prio;
-   *              char     payload[];
-   *          } string;
-   *          struct {
-   *              uint32_t tag
-   *              char     payload[];
-   *          } binary;
-   *      };
-   *  };
-   */
-
-  struct timespec ts;
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  android_pmsg_log_header_t pmsg_header;
-  pmsg_header.magic = LOGGER_MAGIC;
-  pmsg_header.len =
-      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
-  pmsg_header.uid = getuid();
-  pmsg_header.pid = getpid();
-
-  android_log_header_t header;
-  header.tid = gettid();
-  header.realtime.tv_sec = ts.tv_sec;
-  header.realtime.tv_nsec = ts.tv_nsec;
-
-  static const unsigned nr = 1;
-  static const unsigned header_length = 2;
-  struct iovec newVec[nr + header_length];
-
-  newVec[0].iov_base = (unsigned char*)&pmsg_header;
-  newVec[0].iov_len = sizeof(pmsg_header);
-  newVec[1].iov_base = (unsigned char*)&header;
-  newVec[1].iov_len = sizeof(header);
-
-  android_log_event_int_t buffer;
-
-  header.id = LOG_ID_EVENTS;
-  buffer.header.tag = 0;
-  buffer.payload.type = EVENT_TYPE_INT;
-  uint32_t snapshot = 0;
-  buffer.payload.data = snapshot;
-
-  newVec[2].iov_base = &buffer;
-  newVec[2].iov_len = sizeof(buffer);
-
-  while (state.KeepRunning()) {
-    ++snapshot;
-    buffer.payload.data = snapshot;
-    writev(pstore_fd, newVec, nr);
-  }
-  state.PauseTiming();
-  close(pstore_fd);
-}
-BENCHMARK(BM_pmsg_short);
-
-/*
- * Measure the time it takes to submit the android logging data to pstore
- * best case aligned single block.
- */
-static void BM_pmsg_short_aligned(benchmark::State& state) {
-  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-  if (pstore_fd < 0) {
-    state.SkipWithError("/dev/pmsg0");
-    return;
-  }
-
-  /*
-   *  struct {
-   *      // what we provide to pstore
-   *      android_pmsg_log_header_t pmsg_header;
-   *      // what we provide to socket
-   *      android_log_header_t header;
-   *      // caller provides
-   *      union {
-   *          struct {
-   *              char     prio;
-   *              char     payload[];
-   *          } string;
-   *          struct {
-   *              uint32_t tag
-   *              char     payload[];
-   *          } binary;
-   *      };
-   *  };
-   */
-
-  struct timespec ts;
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  struct packet {
-    android_pmsg_log_header_t pmsg_header;
-    android_log_header_t header;
-    android_log_event_int_t payload;
-  };
-  alignas(8) char buf[sizeof(struct packet) + 8];
-  memset(buf, 0, sizeof(buf));
-  struct packet* buffer = (struct packet*)(((uintptr_t)buf + 7) & ~7);
-  if (((uintptr_t)&buffer->pmsg_header) & 7) {
-    fprintf(stderr, "&buffer=0x%p iterations=%" PRIu64 "\n", &buffer->pmsg_header,
-            state.iterations());
-  }
-
-  buffer->pmsg_header.magic = LOGGER_MAGIC;
-  buffer->pmsg_header.len =
-      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
-  buffer->pmsg_header.uid = getuid();
-  buffer->pmsg_header.pid = getpid();
-
-  buffer->header.tid = gettid();
-  buffer->header.realtime.tv_sec = ts.tv_sec;
-  buffer->header.realtime.tv_nsec = ts.tv_nsec;
-
-  buffer->header.id = LOG_ID_EVENTS;
-  buffer->payload.header.tag = 0;
-  buffer->payload.payload.type = EVENT_TYPE_INT;
-  uint32_t snapshot = 0;
-  buffer->payload.payload.data = snapshot;
-
-  while (state.KeepRunning()) {
-    ++snapshot;
-    buffer->payload.payload.data = snapshot;
-    write(pstore_fd, &buffer->pmsg_header,
-          sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t) +
-              sizeof(android_log_event_int_t));
-  }
-  state.PauseTiming();
-  close(pstore_fd);
-}
-BENCHMARK(BM_pmsg_short_aligned);
-
-/*
- * Measure the time it takes to submit the android logging data to pstore
- * best case aligned single block.
- */
-static void BM_pmsg_short_unaligned1(benchmark::State& state) {
-  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-  if (pstore_fd < 0) {
-    state.SkipWithError("/dev/pmsg0");
-    return;
-  }
-
-  /*
-   *  struct {
-   *      // what we provide to pstore
-   *      android_pmsg_log_header_t pmsg_header;
-   *      // what we provide to socket
-   *      android_log_header_t header;
-   *      // caller provides
-   *      union {
-   *          struct {
-   *              char     prio;
-   *              char     payload[];
-   *          } string;
-   *          struct {
-   *              uint32_t tag
-   *              char     payload[];
-   *          } binary;
-   *      };
-   *  };
-   */
-
-  struct timespec ts;
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  struct packet {
-    android_pmsg_log_header_t pmsg_header;
-    android_log_header_t header;
-    android_log_event_int_t payload;
-  };
-  alignas(8) char buf[sizeof(struct packet) + 8];
-  memset(buf, 0, sizeof(buf));
-  struct packet* buffer = (struct packet*)((((uintptr_t)buf + 7) & ~7) + 1);
-  if ((((uintptr_t)&buffer->pmsg_header) & 7) != 1) {
-    fprintf(stderr, "&buffer=0x%p iterations=%" PRIu64 "\n", &buffer->pmsg_header,
-            state.iterations());
-  }
-
-  buffer->pmsg_header.magic = LOGGER_MAGIC;
-  buffer->pmsg_header.len =
-      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
-  buffer->pmsg_header.uid = getuid();
-  buffer->pmsg_header.pid = getpid();
-
-  buffer->header.tid = gettid();
-  buffer->header.realtime.tv_sec = ts.tv_sec;
-  buffer->header.realtime.tv_nsec = ts.tv_nsec;
-
-  buffer->header.id = LOG_ID_EVENTS;
-  buffer->payload.header.tag = 0;
-  buffer->payload.payload.type = EVENT_TYPE_INT;
-  uint32_t snapshot = 0;
-  buffer->payload.payload.data = snapshot;
-
-  while (state.KeepRunning()) {
-    ++snapshot;
-    buffer->payload.payload.data = snapshot;
-    write(pstore_fd, &buffer->pmsg_header,
-          sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t) +
-              sizeof(android_log_event_int_t));
-  }
-  state.PauseTiming();
-  close(pstore_fd);
-}
-BENCHMARK(BM_pmsg_short_unaligned1);
-
-/*
- * Measure the time it takes to submit the android logging data to pstore
- * best case aligned single block.
- */
-static void BM_pmsg_long_aligned(benchmark::State& state) {
-  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-  if (pstore_fd < 0) {
-    state.SkipWithError("/dev/pmsg0");
-    return;
-  }
-
-  /*
-   *  struct {
-   *      // what we provide to pstore
-   *      android_pmsg_log_header_t pmsg_header;
-   *      // what we provide to socket
-   *      android_log_header_t header;
-   *      // caller provides
-   *      union {
-   *          struct {
-   *              char     prio;
-   *              char     payload[];
-   *          } string;
-   *          struct {
-   *              uint32_t tag
-   *              char     payload[];
-   *          } binary;
-   *      };
-   *  };
-   */
-
-  struct timespec ts;
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  struct packet {
-    android_pmsg_log_header_t pmsg_header;
-    android_log_header_t header;
-    android_log_event_int_t payload;
-  };
-  alignas(8) char buf[sizeof(struct packet) + 8 + LOGGER_ENTRY_MAX_PAYLOAD];
-  memset(buf, 0, sizeof(buf));
-  struct packet* buffer = (struct packet*)(((uintptr_t)buf + 7) & ~7);
-  if (((uintptr_t)&buffer->pmsg_header) & 7) {
-    fprintf(stderr, "&buffer=0x%p iterations=%" PRIu64 "\n", &buffer->pmsg_header,
-            state.iterations());
-  }
-
-  buffer->pmsg_header.magic = LOGGER_MAGIC;
-  buffer->pmsg_header.len =
-      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
-  buffer->pmsg_header.uid = getuid();
-  buffer->pmsg_header.pid = getpid();
-
-  buffer->header.tid = gettid();
-  buffer->header.realtime.tv_sec = ts.tv_sec;
-  buffer->header.realtime.tv_nsec = ts.tv_nsec;
-
-  buffer->header.id = LOG_ID_EVENTS;
-  buffer->payload.header.tag = 0;
-  buffer->payload.payload.type = EVENT_TYPE_INT;
-  uint32_t snapshot = 0;
-  buffer->payload.payload.data = snapshot;
-
-  while (state.KeepRunning()) {
-    ++snapshot;
-    buffer->payload.payload.data = snapshot;
-    write(pstore_fd, &buffer->pmsg_header, LOGGER_ENTRY_MAX_PAYLOAD);
-  }
-  state.PauseTiming();
-  close(pstore_fd);
-}
-BENCHMARK(BM_pmsg_long_aligned);
-
-/*
- * Measure the time it takes to submit the android logging data to pstore
- * best case aligned single block.
- */
-static void BM_pmsg_long_unaligned1(benchmark::State& state) {
-  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-  if (pstore_fd < 0) {
-    state.SkipWithError("/dev/pmsg0");
-    return;
-  }
-
-  /*
-   *  struct {
-   *      // what we provide to pstore
-   *      android_pmsg_log_header_t pmsg_header;
-   *      // what we provide to socket
-   *      android_log_header_t header;
-   *      // caller provides
-   *      union {
-   *          struct {
-   *              char     prio;
-   *              char     payload[];
-   *          } string;
-   *          struct {
-   *              uint32_t tag
-   *              char     payload[];
-   *          } binary;
-   *      };
-   *  };
-   */
-
-  struct timespec ts;
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  struct packet {
-    android_pmsg_log_header_t pmsg_header;
-    android_log_header_t header;
-    android_log_event_int_t payload;
-  };
-  alignas(8) char buf[sizeof(struct packet) + 8 + LOGGER_ENTRY_MAX_PAYLOAD];
-  memset(buf, 0, sizeof(buf));
-  struct packet* buffer = (struct packet*)((((uintptr_t)buf + 7) & ~7) + 1);
-  if ((((uintptr_t)&buffer->pmsg_header) & 7) != 1) {
-    fprintf(stderr, "&buffer=0x%p iterations=%" PRIu64 "\n", &buffer->pmsg_header,
-            state.iterations());
-  }
-
-  buffer->pmsg_header.magic = LOGGER_MAGIC;
-  buffer->pmsg_header.len =
-      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
-  buffer->pmsg_header.uid = getuid();
-  buffer->pmsg_header.pid = getpid();
-
-  buffer->header.tid = gettid();
-  buffer->header.realtime.tv_sec = ts.tv_sec;
-  buffer->header.realtime.tv_nsec = ts.tv_nsec;
-
-  buffer->header.id = LOG_ID_EVENTS;
-  buffer->payload.header.tag = 0;
-  buffer->payload.payload.type = EVENT_TYPE_INT;
-  uint32_t snapshot = 0;
-  buffer->payload.payload.data = snapshot;
-
-  while (state.KeepRunning()) {
-    ++snapshot;
-    buffer->payload.payload.data = snapshot;
-    write(pstore_fd, &buffer->pmsg_header, LOGGER_ENTRY_MAX_PAYLOAD);
-  }
-  state.PauseTiming();
-  close(pstore_fd);
-}
-BENCHMARK(BM_pmsg_long_unaligned1);
-
-/*
- *	Measure the time it takes to form sprintf plus time using
- * discrete acquisition under light load. Expect this to be a syscall period
- * (2us) or sprintf time if zero-syscall time.
- */
-/* helper function */
-static void test_print(const char* fmt, ...) {
-  va_list ap;
-  char buf[1024];
-
-  va_start(ap, fmt);
-  vsnprintf(buf, sizeof(buf), fmt, ap);
-  va_end(ap);
-}
-
-#define logd_yield() sched_yield()  // allow logd to catch up
-#define logd_sleep() usleep(50)     // really allow logd to catch up
-
-/* performance test */
-static void BM_sprintf_overhead(benchmark::State& state) {
-  while (state.KeepRunning()) {
-    test_print("BM_sprintf_overhead:%" PRIu64, state.iterations());
-    state.PauseTiming();
-    logd_yield();
-    state.ResumeTiming();
-  }
-}
-BENCHMARK(BM_sprintf_overhead);
-
-/*
- *	Measure the time it takes to submit the android printing logging call
- * using discrete acquisition discrete acquisition under light load. Expect
- * this to be a dozen or so syscall periods (40us) plus time to run *printf
- */
-static void BM_log_print_overhead(benchmark::State& state) {
-  while (state.KeepRunning()) {
-    __android_log_print(ANDROID_LOG_INFO, "BM_log_overhead", "%" PRIu64, state.iterations());
-    state.PauseTiming();
-    logd_yield();
-    state.ResumeTiming();
-  }
-}
-BENCHMARK(BM_log_print_overhead);
-
-/*
- *	Measure the time it takes to submit the android event logging call
- * using discrete acquisition under light load. Expect this to be a long path
- * to logger to convert the unknown tag (0) into a tagname (less than 200us).
- */
-static void BM_log_event_overhead(benchmark::State& state) {
-  for (int64_t i = 0; state.KeepRunning(); ++i) {
-    // log tag number 0 is not known, nor shall it ever be known
-    __android_log_btwrite(0, EVENT_TYPE_LONG, &i, sizeof(i));
-    state.PauseTiming();
-    logd_yield();
-    state.ResumeTiming();
-  }
-}
-BENCHMARK(BM_log_event_overhead);
-
-/*
- *	Measure the time it takes to submit the android event logging call
- * using discrete acquisition under light load with a known logtag.  Expect
- * this to be a dozen or so syscall periods (less than 40us)
- */
-static void BM_log_event_overhead_42(benchmark::State& state) {
-  for (int64_t i = 0; state.KeepRunning(); ++i) {
-    // In system/core/logcat/event.logtags:
-    // # These are used for testing, do not modify without updating
-    // # tests/framework-tests/src/android/util/EventLogFunctionalTest.java.
-    // # system/core/liblog/tests/liblog_benchmark.cpp
-    // # system/core/liblog/tests/liblog_test.cpp
-    // 42    answer (to life the universe etc|3)
-    __android_log_btwrite(42, EVENT_TYPE_LONG, &i, sizeof(i));
-    state.PauseTiming();
-    logd_yield();
-    state.ResumeTiming();
-  }
-}
-BENCHMARK(BM_log_event_overhead_42);
-
-/*
- *	Measure the time it takes to submit the android event logging call
- * using discrete acquisition under very-light load (<1% CPU utilization).
- */
-static void BM_log_light_overhead(benchmark::State& state) {
-  for (int64_t i = 0; state.KeepRunning(); ++i) {
-    __android_log_btwrite(0, EVENT_TYPE_LONG, &i, sizeof(i));
-    state.PauseTiming();
-    usleep(10000);
-    state.ResumeTiming();
-  }
-}
-BENCHMARK(BM_log_light_overhead);
-
-static void caught_latency(int /*signum*/) {
-  unsigned long long v = 0xDEADBEEFA55A5AA5ULL;
-
-  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-}
-
-static unsigned long long caught_convert(char* cp) {
-  unsigned long long l = cp[0] & 0xFF;
-  l |= (unsigned long long)(cp[1] & 0xFF) << 8;
-  l |= (unsigned long long)(cp[2] & 0xFF) << 16;
-  l |= (unsigned long long)(cp[3] & 0xFF) << 24;
-  l |= (unsigned long long)(cp[4] & 0xFF) << 32;
-  l |= (unsigned long long)(cp[5] & 0xFF) << 40;
-  l |= (unsigned long long)(cp[6] & 0xFF) << 48;
-  l |= (unsigned long long)(cp[7] & 0xFF) << 56;
-  return l;
-}
-
-static const int alarm_time = 3;
-
-/*
- *	Measure the time it takes for the logd posting call to acquire the
- * timestamp to place into the internal record.  Expect this to be less than
- * 4 syscalls (3us).  This test uses manual injection of timing because it is
- * comparing the timestamp at send, and then picking up the corresponding log
- * end-to-end long path from logd to see what actual timestamp was submitted.
- */
-static void BM_log_latency(benchmark::State& state) {
-  pid_t pid = getpid();
-
-  struct logger_list* logger_list = android_logger_list_open(LOG_ID_EVENTS, 0, 0, pid);
-
-  if (!logger_list) {
-    fprintf(stderr, "Unable to open events log: %s\n", strerror(errno));
-    exit(EXIT_FAILURE);
-  }
-
-  signal(SIGALRM, caught_latency);
-  alarm(alarm_time);
-
-  for (size_t j = 0; state.KeepRunning() && j < 10 * state.iterations(); ++j) {
-  retry:  // We allow transitory errors (logd overloaded) to be retried.
-    log_time ts;
-    LOG_FAILURE_RETRY((ts = log_time(CLOCK_REALTIME),
-                       android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts))));
-
-    for (;;) {
-      log_msg log_msg;
-      int ret = android_logger_list_read(logger_list, &log_msg);
-      alarm(alarm_time);
-
-      if (ret <= 0) {
-        state.SkipWithError("android_logger_list_read");
-        break;
-      }
-      if ((log_msg.entry.len != (4 + 1 + 8)) ||
-          (log_msg.id() != LOG_ID_EVENTS)) {
-        continue;
-      }
-
-      char* eventData = log_msg.msg();
-
-      if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) {
-        continue;
-      }
-      log_time* tx = reinterpret_cast<log_time*>(eventData + 4 + 1);
-      if (ts != *tx) {
-        if (0xDEADBEEFA55A5AA5ULL == caught_convert(eventData + 4 + 1)) {
-          state.SkipWithError("signal");
-          break;
-        }
-        continue;
-      }
-
-      uint64_t start = ts.nsec();
-      uint64_t end = log_msg.nsec();
-      if (end < start) goto retry;
-      state.SetIterationTime((end - start) / (double)NS_PER_SEC);
-      break;
-    }
-  }
-
-  signal(SIGALRM, SIG_DFL);
-  alarm(0);
-
-  android_logger_list_free(logger_list);
-}
-// Default gets out of hand for this test, so we set a reasonable number of
-// iterations for a timely result.
-BENCHMARK(BM_log_latency)->UseManualTime()->Iterations(200);
-
-static void caught_delay(int /*signum*/) {
-  unsigned long long v = 0xDEADBEEFA55A5AA6ULL;
-
-  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-}
-
-/*
- *	Measure the time it takes for the logd posting call to make it into
- * the logs. Expect this to be less than double the process wakeup time (2ms).
- */
-static void BM_log_delay(benchmark::State& state) {
-  pid_t pid = getpid();
-
-  struct logger_list* logger_list = android_logger_list_open(LOG_ID_EVENTS, 0, 0, pid);
-
-  if (!logger_list) {
-    fprintf(stderr, "Unable to open events log: %s\n", strerror(errno));
-    exit(EXIT_FAILURE);
-  }
-
-  signal(SIGALRM, caught_delay);
-  alarm(alarm_time);
-
-  while (state.KeepRunning()) {
-    log_time ts(CLOCK_REALTIME);
-
-    LOG_FAILURE_RETRY(android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-
-    for (;;) {
-      log_msg log_msg;
-      int ret = android_logger_list_read(logger_list, &log_msg);
-      alarm(alarm_time);
-
-      if (ret <= 0) {
-        state.SkipWithError("android_logger_list_read");
-        break;
-      }
-      if ((log_msg.entry.len != (4 + 1 + 8)) ||
-          (log_msg.id() != LOG_ID_EVENTS)) {
-        continue;
-      }
-
-      char* eventData = log_msg.msg();
-
-      if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) {
-        continue;
-      }
-      log_time* tx = reinterpret_cast<log_time*>(eventData + 4 + 1);
-      if (ts != *tx) {
-        if (0xDEADBEEFA55A5AA6ULL == caught_convert(eventData + 4 + 1)) {
-          state.SkipWithError("signal");
-          break;
-        }
-        continue;
-      }
-
-      break;
-    }
-  }
-  state.PauseTiming();
-
-  signal(SIGALRM, SIG_DFL);
-  alarm(0);
-
-  android_logger_list_free(logger_list);
-}
-BENCHMARK(BM_log_delay);
-
-/*
- *	Measure the time it takes for __android_log_is_loggable.
- */
-static void BM_is_loggable(benchmark::State& state) {
-  static const char logd[] = "logd";
-
-  while (state.KeepRunning()) {
-    __android_log_is_loggable_len(ANDROID_LOG_WARN, logd, strlen(logd),
-                                  ANDROID_LOG_VERBOSE);
-  }
-}
-BENCHMARK(BM_is_loggable);
-
-/*
- *	Measure the time it takes for __android_log_security.
- */
-static void BM_security(benchmark::State& state) {
-  while (state.KeepRunning()) {
-    __android_log_security();
-  }
-}
-BENCHMARK(BM_security);
-
-// Keep maps around for multiple iterations
-static std::unordered_set<uint32_t> set;
-static EventTagMap* map;
-
-static bool prechargeEventMap() {
-  if (map) return true;
-
-  fprintf(stderr, "Precharge: start\n");
-
-  map = android_openEventTagMap(NULL);
-  for (uint32_t tag = 1; tag < USHRT_MAX; ++tag) {
-    size_t len;
-    if (android_lookupEventTag_len(map, &len, tag) == NULL) continue;
-    set.insert(tag);
-  }
-
-  fprintf(stderr, "Precharge: stop %zu\n", set.size());
-
-  return true;
-}
-
-/*
- *	Measure the time it takes for android_lookupEventTag_len
- */
-static void BM_lookupEventTag(benchmark::State& state) {
-  prechargeEventMap();
-
-  std::unordered_set<uint32_t>::const_iterator it = set.begin();
-
-  while (state.KeepRunning()) {
-    size_t len;
-    android_lookupEventTag_len(map, &len, (*it));
-    ++it;
-    if (it == set.end()) it = set.begin();
-  }
-}
-BENCHMARK(BM_lookupEventTag);
-
-/*
- *	Measure the time it takes for android_lookupEventTag_len
- */
-static uint32_t notTag = 1;
-
-static void BM_lookupEventTag_NOT(benchmark::State& state) {
-  prechargeEventMap();
-
-  while (set.find(notTag) != set.end()) {
-    ++notTag;
-    if (notTag >= USHRT_MAX) notTag = 1;
-  }
-
-  while (state.KeepRunning()) {
-    size_t len;
-    android_lookupEventTag_len(map, &len, notTag);
-  }
-
-  ++notTag;
-  if (notTag >= USHRT_MAX) notTag = 1;
-}
-BENCHMARK(BM_lookupEventTag_NOT);
-
-/*
- *	Measure the time it takes for android_lookupEventFormat_len
- */
-static void BM_lookupEventFormat(benchmark::State& state) {
-  prechargeEventMap();
-
-  std::unordered_set<uint32_t>::const_iterator it = set.begin();
-
-  while (state.KeepRunning()) {
-    size_t len;
-    android_lookupEventFormat_len(map, &len, (*it));
-    ++it;
-    if (it == set.end()) it = set.begin();
-  }
-}
-BENCHMARK(BM_lookupEventFormat);
-
-/*
- *	Measure the time it takes for android_lookupEventTagNum plus above
- */
-static void BM_lookupEventTagNum(benchmark::State& state) {
-  prechargeEventMap();
-
-  std::unordered_set<uint32_t>::const_iterator it = set.begin();
-
-  while (state.KeepRunning()) {
-    size_t len;
-    const char* name = android_lookupEventTag_len(map, &len, (*it));
-    std::string Name(name, len);
-    const char* format = android_lookupEventFormat_len(map, &len, (*it));
-    std::string Format(format, len);
-    state.ResumeTiming();
-    android_lookupEventTagNum(map, Name.c_str(), Format.c_str(),
-                              ANDROID_LOG_UNKNOWN);
-    state.PauseTiming();
-    ++it;
-    if (it == set.end()) it = set.begin();
-  }
-}
-BENCHMARK(BM_lookupEventTagNum);
-
-// Must be functionally identical to liblog internal SendLogdControlMessage()
-static void send_to_control(char* buf, size_t len) {
-  int sock =
-      socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM | SOCK_CLOEXEC);
-  if (sock < 0) return;
-  size_t writeLen = strlen(buf) + 1;
-
-  ssize_t ret = TEMP_FAILURE_RETRY(write(sock, buf, writeLen));
-  if (ret <= 0) {
-    close(sock);
-    return;
-  }
-  while ((ret = read(sock, buf, len)) > 0) {
-    if (((size_t)ret == len) || (len < PAGE_SIZE)) {
-      break;
-    }
-    len -= ret;
-    buf += ret;
-
-    struct pollfd p = {.fd = sock, .events = POLLIN, .revents = 0 };
-
-    ret = poll(&p, 1, 20);
-    if ((ret <= 0) || !(p.revents & POLLIN)) {
-      break;
-    }
-  }
-  close(sock);
-}
-
-static void BM_lookupEventTagNum_logd_new(benchmark::State& state) {
-  fprintf(stderr,
-          "WARNING: "
-          "This test can cause logd to grow in size and hit DOS limiter\n");
-  // Make copies
-  static const char empty_event_log_tags[] = "# content owned by logd\n";
-  static const char dev_event_log_tags_path[] = "/dev/event-log-tags";
-  std::string dev_event_log_tags;
-  if (android::base::ReadFileToString(dev_event_log_tags_path,
-                                      &dev_event_log_tags) &&
-      (dev_event_log_tags.length() == 0)) {
-    dev_event_log_tags = empty_event_log_tags;
-  }
-  static const char data_event_log_tags_path[] =
-      "/data/misc/logd/event-log-tags";
-  std::string data_event_log_tags;
-  if (android::base::ReadFileToString(data_event_log_tags_path,
-                                      &data_event_log_tags) &&
-      (data_event_log_tags.length() == 0)) {
-    data_event_log_tags = empty_event_log_tags;
-  }
-
-  while (state.KeepRunning()) {
-    char buffer[256];
-    memset(buffer, 0, sizeof(buffer));
-    log_time now(CLOCK_MONOTONIC);
-    char name[64];
-    snprintf(name, sizeof(name), "a%" PRIu64, now.nsec());
-    snprintf(buffer, sizeof(buffer), "getEventTag name=%s format=\"(new|1)\"",
-             name);
-    state.ResumeTiming();
-    send_to_control(buffer, sizeof(buffer));
-    state.PauseTiming();
-  }
-
-  // Restore copies (logd still know about them, until crash or reboot)
-  if (dev_event_log_tags.length() &&
-      !android::base::WriteStringToFile(dev_event_log_tags,
-                                        dev_event_log_tags_path)) {
-    fprintf(stderr,
-            "WARNING: "
-            "failed to restore %s\n",
-            dev_event_log_tags_path);
-  }
-  if (data_event_log_tags.length() &&
-      !android::base::WriteStringToFile(data_event_log_tags,
-                                        data_event_log_tags_path)) {
-    fprintf(stderr,
-            "WARNING: "
-            "failed to restore %s\n",
-            data_event_log_tags_path);
-  }
-  fprintf(stderr,
-          "WARNING: "
-          "Restarting logd to make it forget what we just did\n");
-  system("stop logd ; start logd");
-}
-BENCHMARK(BM_lookupEventTagNum_logd_new);
-
-static void BM_lookupEventTagNum_logd_existing(benchmark::State& state) {
-  prechargeEventMap();
-
-  std::unordered_set<uint32_t>::const_iterator it = set.begin();
-
-  while (state.KeepRunning()) {
-    size_t len;
-    const char* name = android_lookupEventTag_len(map, &len, (*it));
-    std::string Name(name, len);
-    const char* format = android_lookupEventFormat_len(map, &len, (*it));
-    std::string Format(format, len);
-
-    char buffer[256];
-    snprintf(buffer, sizeof(buffer), "getEventTag name=%s format=\"%s\"",
-             Name.c_str(), Format.c_str());
-
-    state.ResumeTiming();
-    send_to_control(buffer, sizeof(buffer));
-    state.PauseTiming();
-    ++it;
-    if (it == set.end()) it = set.begin();
-  }
-}
-BENCHMARK(BM_lookupEventTagNum_logd_existing);
-
-static void BM_log_verbose_overhead(benchmark::State& state) {
-  std::string test_log_tag = "liblog_verbose_tag";
-  android::base::SetProperty("log.tag." + test_log_tag, "I");
-  for (auto _ : state) {
-    __android_log_print(ANDROID_LOG_VERBOSE, test_log_tag.c_str(), "%s test log message %d %d",
-                        "test test", 123, 456);
-  }
-  android::base::SetProperty("log.tag." + test_log_tag, "");
-}
-BENCHMARK(BM_log_verbose_overhead);
diff --git a/liblog/tests/liblog_default_tag.cpp b/liblog/tests/liblog_default_tag.cpp
deleted file mode 100644
index 31b7467..0000000
--- a/liblog/tests/liblog_default_tag.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-// LOG_TAG must be unset for android-base's logging to use a default tag.
-#undef LOG_TAG
-
-#include <stdlib.h>
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/properties.h>
-#include <android-base/scopeguard.h>
-#include <android/log.h>
-
-#include <gtest/gtest.h>
-
-#ifndef __ANDROID__
-static const char* getprogname() {
-  return program_invocation_short_name;
-}
-#endif
-
-TEST(liblog_default_tag, no_default_tag_libbase_write_first) {
-  using namespace android::base;
-  bool message_seen = false;
-  std::string expected_tag = "";
-  SetLogger([&](LogId, LogSeverity, const char* tag, const char*, unsigned int, const char*) {
-    message_seen = true;
-    EXPECT_EQ(expected_tag, tag);
-  });
-
-  expected_tag = getprogname();
-  LOG(WARNING) << "message";
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-
-  __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_WARN, nullptr, "message");
-  EXPECT_TRUE(message_seen);
-}
-
-TEST(liblog_default_tag, no_default_tag_liblog_write_first) {
-  using namespace android::base;
-  bool message_seen = false;
-  std::string expected_tag = "";
-  SetLogger([&](LogId, LogSeverity, const char* tag, const char*, unsigned int, const char*) {
-    message_seen = true;
-    EXPECT_EQ(expected_tag, tag);
-  });
-
-  expected_tag = getprogname();
-  __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_WARN, nullptr, "message");
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-
-  LOG(WARNING) << "message";
-  EXPECT_TRUE(message_seen);
-}
-
-TEST(liblog_default_tag, libbase_sets_default_tag) {
-  using namespace android::base;
-  bool message_seen = false;
-  std::string expected_tag = "libbase_test_tag";
-  SetLogger([&](LogId, LogSeverity, const char* tag, const char*, unsigned int, const char*) {
-    message_seen = true;
-    EXPECT_EQ(expected_tag, tag);
-  });
-  SetDefaultTag(expected_tag);
-
-  __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_WARN, nullptr, "message");
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-
-  LOG(WARNING) << "message";
-  EXPECT_TRUE(message_seen);
-}
-
-TEST(liblog_default_tag, liblog_sets_default_tag) {
-  using namespace android::base;
-  bool message_seen = false;
-  std::string expected_tag = "liblog_test_tag";
-  SetLogger([&](LogId, LogSeverity, const char* tag, const char*, unsigned int, const char*) {
-    message_seen = true;
-    EXPECT_EQ(expected_tag, tag);
-  });
-  __android_log_set_default_tag(expected_tag.c_str());
-
-  __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_WARN, nullptr, "message");
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-
-  LOG(WARNING) << "message";
-  EXPECT_TRUE(message_seen);
-}
-
-TEST(liblog_default_tag, default_tag_plus_log_severity) {
-#ifdef __ANDROID__
-  using namespace android::base;
-  bool message_seen = false;
-  std::string expected_tag = "liblog_test_tag";
-  SetLogger([&](LogId, LogSeverity, const char* tag, const char*, unsigned int, const char*) {
-    message_seen = true;
-    EXPECT_EQ(expected_tag, tag);
-  });
-  __android_log_set_default_tag(expected_tag.c_str());
-
-  auto log_tag_property = "log.tag." + expected_tag;
-  SetProperty(log_tag_property, "V");
-  auto reset_tag_property_guard = make_scope_guard([=] { SetProperty(log_tag_property, ""); });
-
-  __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_VERBOSE, nullptr, "message");
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-
-  LOG(VERBOSE) << "message";
-  EXPECT_TRUE(message_seen);
-#else
-  GTEST_SKIP() << "No log tag properties on host";
-#endif
-}
-
-TEST(liblog_default_tag, generated_default_tag_plus_log_severity) {
-#ifdef __ANDROID__
-  using namespace android::base;
-  bool message_seen = false;
-  std::string expected_tag = getprogname();
-  SetLogger([&](LogId, LogSeverity, const char* tag, const char*, unsigned int, const char*) {
-    message_seen = true;
-    EXPECT_EQ(expected_tag, tag);
-  });
-
-  // Even without any calls to SetDefaultTag(), the first message that attempts to log, will
-  // generate a default tag from getprogname() and check log.tag.<default tag> for loggability. This
-  // case checks that we can log a Verbose message when log.tag.<getprogname()> is set to 'V'.
-  auto log_tag_property = "log.tag." + expected_tag;
-  SetProperty(log_tag_property, "V");
-  auto reset_tag_property_guard = make_scope_guard([=] { SetProperty(log_tag_property, ""); });
-
-  __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_VERBOSE, nullptr, "message");
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-
-  LOG(VERBOSE) << "message";
-  EXPECT_TRUE(message_seen);
-#else
-  GTEST_SKIP() << "No log tag properties on host";
-#endif
-}
\ No newline at end of file
diff --git a/liblog/tests/liblog_global_state.cpp b/liblog/tests/liblog_global_state.cpp
deleted file mode 100644
index 1d7ff9f..0000000
--- a/liblog/tests/liblog_global_state.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-#define LOG_TAG "global_state_test_tag"
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/properties.h>
-#include <android/log.h>
-
-#include <gtest/gtest.h>
-
-TEST(liblog_global_state, libbase_logs_with_libbase_SetLogger) {
-  using namespace android::base;
-  bool message_seen = false;
-  LogSeverity expected_severity = WARNING;
-  std::string expected_file = Basename(__FILE__);
-  unsigned int expected_line;
-  std::string expected_message = "libbase test message";
-
-  auto LoggerFunction = [&](LogId log_id, LogSeverity severity, const char* tag, const char* file,
-                            unsigned int line, const char* message) {
-    message_seen = true;
-    EXPECT_EQ(DEFAULT, log_id);
-    EXPECT_EQ(expected_severity, severity);
-    EXPECT_STREQ(LOG_TAG, tag);
-    EXPECT_EQ(expected_file, file);
-    EXPECT_EQ(expected_line, line);
-    EXPECT_EQ(expected_message, message);
-  };
-
-  SetLogger(LoggerFunction);
-
-  expected_line = __LINE__ + 1;
-  LOG(expected_severity) << expected_message;
-  EXPECT_TRUE(message_seen);
-}
-
-TEST(liblog_global_state, libbase_logs_with_liblog_set_logger) {
-  using namespace android::base;
-  // These must be static since they're used by the liblog logger function, which only accepts
-  // lambdas without captures.  The items used by the libbase logger are explicitly not static, to
-  // ensure that lambdas with captures do work there.
-  static bool message_seen = false;
-  static std::string expected_file = Basename(__FILE__);
-  static unsigned int expected_line;
-  static std::string expected_message = "libbase test message";
-
-  auto liblog_logger_function = [](const struct __android_log_message* log_message) {
-    message_seen = true;
-    EXPECT_EQ(sizeof(__android_log_message), log_message->struct_size);
-    EXPECT_EQ(LOG_ID_DEFAULT, log_message->buffer_id);
-    EXPECT_EQ(ANDROID_LOG_WARN, log_message->priority);
-    EXPECT_STREQ(LOG_TAG, log_message->tag);
-    EXPECT_EQ(expected_file, log_message->file);
-    EXPECT_EQ(expected_line, log_message->line);
-    EXPECT_EQ(expected_message, log_message->message);
-  };
-
-  __android_log_set_logger(liblog_logger_function);
-
-  expected_line = __LINE__ + 1;
-  LOG(WARNING) << expected_message;
-  EXPECT_TRUE(message_seen);
-}
-
-TEST(liblog_global_state, liblog_logs_with_libbase_SetLogger) {
-  using namespace android::base;
-  bool message_seen = false;
-  std::string expected_message = "libbase test message";
-
-  auto LoggerFunction = [&](LogId log_id, LogSeverity severity, const char* tag, const char* file,
-                            unsigned int line, const char* message) {
-    message_seen = true;
-    EXPECT_EQ(MAIN, log_id);
-    EXPECT_EQ(WARNING, severity);
-    EXPECT_STREQ(LOG_TAG, tag);
-    EXPECT_EQ(nullptr, file);
-    EXPECT_EQ(0U, line);
-    EXPECT_EQ(expected_message, message);
-  };
-
-  SetLogger(LoggerFunction);
-
-  __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_WARN, LOG_TAG, expected_message.c_str());
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-}
-
-TEST(liblog_global_state, liblog_logs_with_liblog_set_logger) {
-  using namespace android::base;
-  // These must be static since they're used by the liblog logger function, which only accepts
-  // lambdas without captures.  The items used by the libbase logger are explicitly not static, to
-  // ensure that lambdas with captures do work there.
-  static bool message_seen = false;
-  static int expected_buffer_id = LOG_ID_MAIN;
-  static int expected_priority = ANDROID_LOG_WARN;
-  static std::string expected_message = "libbase test message";
-
-  auto liblog_logger_function = [](const struct __android_log_message* log_message) {
-    message_seen = true;
-    EXPECT_EQ(sizeof(__android_log_message), log_message->struct_size);
-    EXPECT_EQ(expected_buffer_id, log_message->buffer_id);
-    EXPECT_EQ(expected_priority, log_message->priority);
-    EXPECT_STREQ(LOG_TAG, log_message->tag);
-    EXPECT_STREQ(nullptr, log_message->file);
-    EXPECT_EQ(0U, log_message->line);
-    EXPECT_EQ(expected_message, log_message->message);
-  };
-
-  __android_log_set_logger(liblog_logger_function);
-
-  __android_log_buf_write(expected_buffer_id, expected_priority, LOG_TAG, expected_message.c_str());
-  EXPECT_TRUE(message_seen);
-}
-
-TEST(liblog_global_state, SetAborter_with_liblog) {
-  using namespace android::base;
-
-  std::string expected_message = "libbase test message";
-  static bool message_seen = false;
-  auto aborter_function = [&](const char* message) {
-    message_seen = true;
-    EXPECT_EQ(expected_message, message);
-  };
-
-  SetAborter(aborter_function);
-  LOG(FATAL) << expected_message;
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-
-  static std::string expected_message_static = "libbase test message";
-  auto liblog_aborter_function = [](const char* message) {
-    message_seen = true;
-    EXPECT_EQ(expected_message_static, message);
-  };
-  __android_log_set_aborter(liblog_aborter_function);
-  LOG(FATAL) << expected_message_static;
-  EXPECT_TRUE(message_seen);
-  message_seen = false;
-}
-
-static std::string UniqueLogTag() {
-  std::string tag = LOG_TAG;
-  tag += "-" + std::to_string(getpid());
-  return tag;
-}
-
-TEST(liblog_global_state, is_loggable_both_default) {
-  auto tag = UniqueLogTag();
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-}
-
-TEST(liblog_global_state, is_loggable_minimum_log_priority_only) {
-  auto tag = UniqueLogTag();
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  EXPECT_EQ(ANDROID_LOG_DEFAULT, __android_log_set_minimum_priority(ANDROID_LOG_DEBUG));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  EXPECT_EQ(ANDROID_LOG_DEBUG, __android_log_set_minimum_priority(ANDROID_LOG_WARN));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  EXPECT_EQ(android::base::WARNING, android::base::SetMinimumLogSeverity(android::base::DEBUG));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  EXPECT_EQ(android::base::DEBUG, android::base::SetMinimumLogSeverity(android::base::WARNING));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-}
-
-TEST(liblog_global_state, is_loggable_tag_log_priority_only) {
-#ifdef __ANDROID__
-  auto tag = UniqueLogTag();
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  auto log_tag_property = std::string("log.tag.") + tag;
-  ASSERT_TRUE(android::base::SetProperty(log_tag_property, "d"));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  ASSERT_TRUE(android::base::SetProperty(log_tag_property, "w"));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  ASSERT_TRUE(android::base::SetProperty(log_tag_property, ""));
-#else
-  GTEST_SKIP() << "No log tag properties on host";
-#endif
-}
-
-TEST(liblog_global_state, is_loggable_both_set) {
-#ifdef __ANDROID__
-  auto tag = UniqueLogTag();
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  // When both a tag and a minimum priority are set, we use the lower value of the two.
-
-  // tag = warning, minimum_priority = debug, expect 'debug'
-  auto log_tag_property = std::string("log.tag.") + tag;
-  ASSERT_TRUE(android::base::SetProperty(log_tag_property, "w"));
-  EXPECT_EQ(ANDROID_LOG_DEFAULT, __android_log_set_minimum_priority(ANDROID_LOG_DEBUG));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  // tag = warning, minimum_priority = warning, expect 'warning'
-  EXPECT_EQ(ANDROID_LOG_DEBUG, __android_log_set_minimum_priority(ANDROID_LOG_WARN));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(0, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  // tag = debug, minimum_priority = warning, expect 'debug'
-  ASSERT_TRUE(android::base::SetProperty(log_tag_property, "d"));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  // tag = debug, minimum_priority = debug, expect 'debug'
-  EXPECT_EQ(ANDROID_LOG_WARN, __android_log_set_minimum_priority(ANDROID_LOG_DEBUG));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_DEBUG, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_INFO, tag.c_str(), ANDROID_LOG_INFO));
-  EXPECT_EQ(1, __android_log_is_loggable(ANDROID_LOG_WARN, tag.c_str(), ANDROID_LOG_INFO));
-
-  ASSERT_TRUE(android::base::SetProperty(log_tag_property, ""));
-#else
-  GTEST_SKIP() << "No log tag properties on host";
-#endif
-}
diff --git a/liblog/tests/liblog_host_test.cpp b/liblog/tests/liblog_host_test.cpp
deleted file mode 100644
index ec186d4..0000000
--- a/liblog/tests/liblog_host_test.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2019 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 <log/log.h>
-#include <private/android_logger.h>
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <regex>
-#include <string>
-
-#include <android-base/logging.h>
-#include <android-base/macros.h>
-#include <android-base/stringprintf.h>
-#include <android-base/test_utils.h>
-#include <gtest/gtest.h>
-
-using android::base::InitLogging;
-using android::base::StderrLogger;
-using android::base::StringPrintf;
-
-static std::string MakeLogPattern(int priority, const char* tag, const char* message) {
-  static const char log_characters[] = "XXVDIWEF";
-  static_assert(arraysize(log_characters) - 1 == ANDROID_LOG_SILENT,
-                "Mismatch in size of log_characters and values in android_LogPriority");
-  priority = priority > ANDROID_LOG_SILENT ? ANDROID_LOG_FATAL : priority;
-  char log_char = log_characters[priority];
-
-  return StringPrintf("%s %c \\d+-\\d+ \\d+:\\d+:\\d+ \\s*\\d+ \\s*\\d+ %s", tag, log_char,
-                      message);
-}
-
-static void CheckMessage(bool expected, const std::string& output, int priority, const char* tag,
-                         const char* message) {
-  std::regex message_regex(MakeLogPattern(priority, tag, message));
-  EXPECT_EQ(expected, std::regex_search(output, message_regex)) << message;
-}
-
-static void GenerateLogContent() {
-  __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_VERBOSE, "tag", "verbose main");
-  __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO, "tag", "info main");
-  __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_ERROR, "tag", "error main");
-
-  __android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, "tag", "verbose radio");
-  __android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, "tag", "info radio");
-  __android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, "tag", "error radio");
-
-  __android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, "tag", "verbose system");
-  __android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, "tag", "info system");
-  __android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, "tag", "error system");
-
-  __android_log_buf_print(LOG_ID_CRASH, ANDROID_LOG_VERBOSE, "tag", "verbose crash");
-  __android_log_buf_print(LOG_ID_CRASH, ANDROID_LOG_INFO, "tag", "info crash");
-  __android_log_buf_print(LOG_ID_CRASH, ANDROID_LOG_ERROR, "tag", "error crash");
-}
-
-std::string GetPidString() {
-  int pid = getpid();
-  return StringPrintf("%5d", pid);
-}
-
-TEST(liblog, default_write) {
-  CapturedStderr captured_stderr;
-  InitLogging(nullptr, StderrLogger);
-
-  GenerateLogContent();
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose main");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info main");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error main");
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose radio");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info radio");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error radio");
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose system");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info system");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error system");
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose crash");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info crash");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error crash");
-}
-
-TEST(liblog, verbose_write) {
-  setenv("ANDROID_LOG_TAGS", "*:v", true);
-  CapturedStderr captured_stderr;
-  InitLogging(nullptr, StderrLogger);
-
-  GenerateLogContent();
-
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose main");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info main");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error main");
-
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose radio");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info radio");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error radio");
-
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose system");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info system");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error system");
-
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose crash");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info crash");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error crash");
-}
-
-TEST(liblog, error_write) {
-  setenv("ANDROID_LOG_TAGS", "*:e", true);
-  CapturedStderr captured_stderr;
-  InitLogging(nullptr, StderrLogger);
-
-  GenerateLogContent();
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose main");
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info main");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error main");
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose radio");
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info radio");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error radio");
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose system");
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info system");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error system");
-
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_VERBOSE, "tag", "verbose crash");
-  CheckMessage(false, captured_stderr.str(), ANDROID_LOG_INFO, "tag", "info crash");
-  CheckMessage(true, captured_stderr.str(), ANDROID_LOG_ERROR, "tag", "error crash");
-}
-
-TEST(liblog, kernel_no_write) {
-  CapturedStderr captured_stderr;
-  InitLogging(nullptr, StderrLogger);
-  __android_log_buf_print(LOG_ID_KERNEL, ANDROID_LOG_ERROR, "tag", "kernel error");
-  EXPECT_EQ("", captured_stderr.str());
-}
-
-TEST(liblog, binary_no_write) {
-  CapturedStderr captured_stderr;
-  InitLogging(nullptr, StderrLogger);
-  __android_log_buf_print(LOG_ID_EVENTS, ANDROID_LOG_ERROR, "tag", "error events");
-  __android_log_buf_print(LOG_ID_STATS, ANDROID_LOG_ERROR, "tag", "error stats");
-  __android_log_buf_print(LOG_ID_SECURITY, ANDROID_LOG_ERROR, "tag", "error security");
-
-  __android_log_bswrite(0x12, "events");
-  __android_log_stats_bwrite(0x34, "stats", strlen("stats"));
-  __android_log_security_bswrite(0x56, "security");
-
-  EXPECT_EQ("", captured_stderr.str());
-}
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
deleted file mode 100644
index fbc3d7a..0000000
--- a/liblog/tests/liblog_test.cpp
+++ /dev/null
@@ -1,2787 +0,0 @@
-/*
- * Copyright (C) 2013-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 <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <memory>
-#include <string>
-
-#include <android-base/file.h>
-#include <android-base/macros.h>
-#include <android-base/scopeguard.h>
-#include <android-base/stringprintf.h>
-#ifdef __ANDROID__  // includes sys/properties.h which does not exist outside
-#include <cutils/properties.h>
-#endif
-#include <gtest/gtest.h>
-#include <log/log_event_list.h>
-#include <log/log_properties.h>
-#include <log/log_read.h>
-#include <log/logprint.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-
-using android::base::make_scope_guard;
-
-// #define ENABLE_FLAKY_TESTS
-
-// enhanced version of LOG_FAILURE_RETRY to add support for EAGAIN and
-// non-syscall libs. Since we are only using this in the emergency of
-// a signal to stuff a terminating code into the logs, we will spin rather
-// than try a usleep.
-#define LOG_FAILURE_RETRY(exp)                                           \
-  ({                                                                     \
-    typeof(exp) _rc;                                                     \
-    do {                                                                 \
-      _rc = (exp);                                                       \
-    } while (((_rc == -1) && ((errno == EINTR) || (errno == EAGAIN))) || \
-             (_rc == -EINTR) || (_rc == -EAGAIN));                       \
-    _rc;                                                                 \
-  })
-
-// std::unique_ptr doesn't let you provide a pointer to a deleter (android_logger_list_close()) if
-// the type (struct logger_list) is an incomplete type, so we create ListCloser instead.
-struct ListCloser {
-  void operator()(struct logger_list* list) { android_logger_list_close(list); }
-};
-
-// This function is meant to be used for most log tests, it does the following:
-// 1) Open the log_buffer with a blocking reader
-// 2) Write the messages via write_messages
-// 3) Set an alarm for 2 seconds as a timeout
-// 4) Read until check_message returns true, which should be used to indicate the target message
-//    is found
-// 5) Open log_buffer with a non_blocking reader and dump all messages
-// 6) Count the number of times check_messages returns true for these messages and assert it's
-//    only 1.
-template <typename FWrite, typename FCheck>
-static void RunLogTests(log_id_t log_buffer, FWrite write_messages, FCheck check_message) {
-  pid_t pid = getpid();
-
-  auto logger_list = std::unique_ptr<struct logger_list, ListCloser>{
-      android_logger_list_open(log_buffer, 0, 1000, pid)};
-  ASSERT_TRUE(logger_list);
-
-  write_messages();
-
-  alarm(2);
-  auto alarm_guard = android::base::make_scope_guard([] { alarm(0); });
-  bool found = false;
-  while (!found) {
-    log_msg log_msg;
-    ASSERT_GT(android_logger_list_read(logger_list.get(), &log_msg), 0);
-
-    ASSERT_EQ(log_buffer, log_msg.id());
-    ASSERT_EQ(pid, log_msg.entry.pid);
-
-    ASSERT_NE(nullptr, log_msg.msg());
-
-    check_message(log_msg, &found);
-  }
-
-  auto logger_list_non_block = std::unique_ptr<struct logger_list, ListCloser>{
-      android_logger_list_open(log_buffer, ANDROID_LOG_NONBLOCK, 1000, pid)};
-  ASSERT_TRUE(logger_list_non_block);
-
-  size_t count = 0;
-  while (true) {
-    log_msg log_msg;
-    auto ret = android_logger_list_read(logger_list_non_block.get(), &log_msg);
-    if (ret == -EAGAIN) {
-      break;
-    }
-    ASSERT_GT(ret, 0);
-
-    ASSERT_EQ(log_buffer, log_msg.id());
-    ASSERT_EQ(pid, log_msg.entry.pid);
-
-    ASSERT_NE(nullptr, log_msg.msg());
-
-    found = false;
-    check_message(log_msg, &found);
-    if (found) {
-      ++count;
-    }
-  }
-
-  EXPECT_EQ(1U, count);
-}
-
-TEST(liblog, __android_log_btwrite) {
-  int intBuf = 0xDEADBEEF;
-  EXPECT_LT(0,
-            __android_log_btwrite(0, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)));
-  long long longBuf = 0xDEADBEEFA55A5AA5;
-  EXPECT_LT(
-      0, __android_log_btwrite(0, EVENT_TYPE_LONG, &longBuf, sizeof(longBuf)));
-  char Buf[] = "\20\0\0\0DeAdBeEfA55a5aA5";
-  EXPECT_LT(0,
-            __android_log_btwrite(0, EVENT_TYPE_STRING, Buf, sizeof(Buf) - 1));
-}
-
-#if defined(__ANDROID__)
-static std::string popenToString(const std::string& command) {
-  std::string ret;
-
-  FILE* fp = popen(command.c_str(), "re");
-  if (fp) {
-    if (!android::base::ReadFdToString(fileno(fp), &ret)) ret = "";
-    pclose(fp);
-  }
-  return ret;
-}
-
-static bool isPmsgActive() {
-  pid_t pid = getpid();
-
-  std::string myPidFds =
-      popenToString(android::base::StringPrintf("ls -l /proc/%d/fd", pid));
-  if (myPidFds.length() == 0) return true;  // guess it is?
-
-  return std::string::npos != myPidFds.find(" -> /dev/pmsg0");
-}
-
-static bool isLogdwActive() {
-  std::string logdwSignature =
-      popenToString("grep -a /dev/socket/logdw /proc/net/unix");
-  size_t beginning = logdwSignature.find(' ');
-  if (beginning == std::string::npos) return true;
-  beginning = logdwSignature.find(' ', beginning + 1);
-  if (beginning == std::string::npos) return true;
-  size_t end = logdwSignature.find(' ', beginning + 1);
-  if (end == std::string::npos) return true;
-  end = logdwSignature.find(' ', end + 1);
-  if (end == std::string::npos) return true;
-  end = logdwSignature.find(' ', end + 1);
-  if (end == std::string::npos) return true;
-  end = logdwSignature.find(' ', end + 1);
-  if (end == std::string::npos) return true;
-  std::string allLogdwEndpoints = popenToString(
-      "grep -a ' 00000002" + logdwSignature.substr(beginning, end - beginning) +
-      " ' /proc/net/unix | " +
-      "sed -n 's/.* \\([0-9][0-9]*\\)$/ -> socket:[\\1]/p'");
-  if (allLogdwEndpoints.length() == 0) return true;
-
-  // NB: allLogdwEndpoints has some false positives in it, but those
-  // strangers do not overlap with the simplistic activities inside this
-  // test suite.
-
-  pid_t pid = getpid();
-
-  std::string myPidFds =
-      popenToString(android::base::StringPrintf("ls -l /proc/%d/fd", pid));
-  if (myPidFds.length() == 0) return true;
-
-  // NB: fgrep with multiple strings is broken in Android
-  for (beginning = 0;
-       (end = allLogdwEndpoints.find('\n', beginning)) != std::string::npos;
-       beginning = end + 1) {
-    if (myPidFds.find(allLogdwEndpoints.substr(beginning, end - beginning)) !=
-        std::string::npos)
-      return true;
-  }
-  return false;
-}
-
-static bool tested__android_log_close;
-#endif
-
-TEST(liblog, __android_log_btwrite__android_logger_list_read) {
-#ifdef __ANDROID__
-  log_time ts(CLOCK_MONOTONIC);
-  log_time ts1(ts);
-
-  bool has_pstore = access("/dev/pmsg0", W_OK) == 0;
-
-  auto write_function = [&] {
-    EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-    // Check that we can close and reopen the logger
-    bool logdwActiveAfter__android_log_btwrite;
-    if (getuid() == AID_ROOT) {
-      tested__android_log_close = true;
-      if (has_pstore) {
-        bool pmsgActiveAfter__android_log_btwrite = isPmsgActive();
-        EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
-      }
-      logdwActiveAfter__android_log_btwrite = isLogdwActive();
-      EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
-    } else if (!tested__android_log_close) {
-      fprintf(stderr, "WARNING: can not test __android_log_close()\n");
-    }
-    __android_log_close();
-    if (getuid() == AID_ROOT) {
-      if (has_pstore) {
-        bool pmsgActiveAfter__android_log_close = isPmsgActive();
-        EXPECT_FALSE(pmsgActiveAfter__android_log_close);
-      }
-      bool logdwActiveAfter__android_log_close = isLogdwActive();
-      EXPECT_FALSE(logdwActiveAfter__android_log_close);
-    }
-
-    ts1 = log_time(CLOCK_MONOTONIC);
-    EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
-    if (getuid() == AID_ROOT) {
-      if (has_pstore) {
-        bool pmsgActiveAfter__android_log_btwrite = isPmsgActive();
-        EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
-      }
-      logdwActiveAfter__android_log_btwrite = isLogdwActive();
-      EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
-    }
-  };
-
-  int count = 0;
-  int second_count = 0;
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
-        (log_msg.id() != LOG_ID_EVENTS)) {
-      return;
-    }
-
-    android_log_event_long_t* eventData;
-    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-
-    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-      return;
-    }
-
-    log_time* tx = reinterpret_cast<log_time*>(&eventData->payload.data);
-    if (ts == *tx) {
-      ++count;
-    } else if (ts1 == *tx) {
-      ++second_count;
-    }
-
-    if (count == 1 && second_count == 1) {
-      count = 0;
-      second_count = 0;
-      *found = true;
-    }
-  };
-
-  RunLogTests(LOG_ID_EVENTS, write_function, check_function);
-
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, __android_log_write__android_logger_list_read) {
-#ifdef __ANDROID__
-  pid_t pid = getpid();
-
-  struct timespec ts;
-  clock_gettime(CLOCK_MONOTONIC, &ts);
-  std::string buf = android::base::StringPrintf("pid=%u ts=%ld.%09ld", pid, ts.tv_sec, ts.tv_nsec);
-  static const char tag[] = "liblog.__android_log_write__android_logger_list_read";
-  static const char prio = ANDROID_LOG_DEBUG;
-
-  std::string expected_message =
-      std::string(&prio, sizeof(prio)) + tag + std::string("", 1) + buf + std::string("", 1);
-
-  auto write_function = [&] { ASSERT_LT(0, __android_log_write(prio, tag, buf.c_str())); };
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    if (log_msg.entry.len != expected_message.length()) {
-      return;
-    }
-
-    if (expected_message != std::string(log_msg.msg(), log_msg.entry.len)) {
-      return;
-    }
-
-    *found = true;
-  };
-
-  RunLogTests(LOG_ID_MAIN, write_function, check_function);
-
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-static void bswrite_test(const char* message) {
-#ifdef __ANDROID__
-  pid_t pid = getpid();
-
-  size_t num_lines = 1, size = 0, length = 0, total = 0;
-  const char* cp = message;
-  while (*cp) {
-    if (*cp == '\n') {
-      if (cp[1]) {
-        ++num_lines;
-      }
-    } else {
-      ++size;
-    }
-    ++cp;
-    ++total;
-    ++length;
-    if ((LOGGER_ENTRY_MAX_PAYLOAD - 4 - 1 - 4) <= length) {
-      break;
-    }
-  }
-  while (*cp) {
-    ++cp;
-    ++total;
-  }
-
-  auto write_function = [&] { EXPECT_LT(0, __android_log_bswrite(0, message)); };
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    if ((size_t)log_msg.entry.len != (sizeof(android_log_event_string_t) + length) ||
-        log_msg.id() != LOG_ID_EVENTS) {
-      return;
-    }
-
-    android_log_event_string_t* eventData;
-    eventData = reinterpret_cast<android_log_event_string_t*>(log_msg.msg());
-
-    if (!eventData || (eventData->type != EVENT_TYPE_STRING)) {
-      return;
-    }
-
-    size_t len = eventData->length;
-    if (len == total) {
-      *found = true;
-
-      AndroidLogFormat* logformat = android_log_format_new();
-      EXPECT_TRUE(NULL != logformat);
-      AndroidLogEntry entry;
-      char msgBuf[1024];
-      if (length != total) {
-        fprintf(stderr, "Expect \"Binary log entry conversion failed\"\n");
-      }
-      int processBinaryLogBuffer = android_log_processBinaryLogBuffer(
-          &log_msg.entry, &entry, nullptr, msgBuf, sizeof(msgBuf));
-      EXPECT_EQ((length == total) ? 0 : -1, processBinaryLogBuffer);
-      if ((processBinaryLogBuffer == 0) || entry.message) {
-        size_t line_overhead = 20;
-        if (pid > 99999) ++line_overhead;
-        if (pid > 999999) ++line_overhead;
-        fflush(stderr);
-        if (processBinaryLogBuffer) {
-          EXPECT_GT((int)((line_overhead * num_lines) + size),
-                    android_log_printLogLine(logformat, fileno(stderr), &entry));
-        } else {
-          EXPECT_EQ((int)((line_overhead * num_lines) + size),
-                    android_log_printLogLine(logformat, fileno(stderr), &entry));
-        }
-      }
-      android_log_format_free(logformat);
-    }
-  };
-
-  RunLogTests(LOG_ID_EVENTS, write_function, check_function);
-
-#else
-  message = NULL;
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, __android_log_bswrite_and_print) {
-  bswrite_test("Hello World");
-}
-
-TEST(liblog, __android_log_bswrite_and_print__empty_string) {
-  bswrite_test("");
-}
-
-TEST(liblog, __android_log_bswrite_and_print__newline_prefix) {
-  bswrite_test("\nHello World\n");
-}
-
-TEST(liblog, __android_log_bswrite_and_print__newline_space_prefix) {
-  bswrite_test("\n Hello World \n");
-}
-
-TEST(liblog, __android_log_bswrite_and_print__multiple_newline) {
-  bswrite_test("one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten");
-}
-
-static void buf_write_test(const char* message) {
-#ifdef __ANDROID__
-  pid_t pid = getpid();
-
-  static const char tag[] = "TEST__android_log_buf_write";
-
-  auto write_function = [&] {
-    EXPECT_LT(0, __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO, tag, message));
-  };
-  size_t num_lines = 1, size = 0, length = 0;
-  const char* cp = message;
-  while (*cp) {
-    if (*cp == '\n') {
-      if (cp[1]) {
-        ++num_lines;
-      }
-    } else {
-      ++size;
-    }
-    ++length;
-    if ((LOGGER_ENTRY_MAX_PAYLOAD - 2 - sizeof(tag)) <= length) {
-      break;
-    }
-    ++cp;
-  }
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    if ((size_t)log_msg.entry.len != (sizeof(tag) + length + 2) || log_msg.id() != LOG_ID_MAIN) {
-      return;
-    }
-
-    *found = true;
-
-    AndroidLogFormat* logformat = android_log_format_new();
-    EXPECT_TRUE(NULL != logformat);
-    AndroidLogEntry entry;
-    int processLogBuffer = android_log_processLogBuffer(&log_msg.entry, &entry);
-    EXPECT_EQ(0, processLogBuffer);
-    if (processLogBuffer == 0) {
-      size_t line_overhead = 11;
-      if (pid > 99999) ++line_overhead;
-      if (pid > 999999) ++line_overhead;
-      fflush(stderr);
-      EXPECT_EQ((int)(((line_overhead + sizeof(tag)) * num_lines) + size),
-                android_log_printLogLine(logformat, fileno(stderr), &entry));
-    }
-    android_log_format_free(logformat);
-  };
-
-  RunLogTests(LOG_ID_MAIN, write_function, check_function);
-
-#else
-  message = NULL;
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, __android_log_buf_write_and_print__empty) {
-  buf_write_test("");
-}
-
-TEST(liblog, __android_log_buf_write_and_print__newline_prefix) {
-  buf_write_test("\nHello World\n");
-}
-
-TEST(liblog, __android_log_buf_write_and_print__newline_space_prefix) {
-  buf_write_test("\n Hello World \n");
-}
-
-#ifdef ENABLE_FLAKY_TESTS
-#ifdef __ANDROID__
-static unsigned signaled;
-static log_time signal_time;
-
-/*
- *  Strictly, we are not allowed to log messages in a signal context, but we
- * do make an effort to keep the failure surface minimized, and this in-effect
- * should catch any regressions in that effort. The odds of a logged message
- * in a signal handler causing a lockup problem should be _very_ small.
- */
-static void caught_blocking_signal(int /*signum*/) {
-  unsigned long long v = 0xDEADBEEFA55A0000ULL;
-
-  v += getpid() & 0xFFFF;
-
-  ++signaled;
-  if ((signal_time.tv_sec == 0) && (signal_time.tv_nsec == 0)) {
-    signal_time = log_time(CLOCK_MONOTONIC);
-    signal_time.tv_sec += 2;
-  }
-
-  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-}
-
-// Fill in current process user and system time in 10ms increments
-static void get_ticks(unsigned long long* uticks, unsigned long long* sticks) {
-  *uticks = *sticks = 0;
-
-  pid_t pid = getpid();
-
-  char buffer[512];
-  snprintf(buffer, sizeof(buffer), "/proc/%u/stat", pid);
-
-  FILE* fp = fopen(buffer, "re");
-  if (!fp) {
-    return;
-  }
-
-  char* cp = fgets(buffer, sizeof(buffer), fp);
-  fclose(fp);
-  if (!cp) {
-    return;
-  }
-
-  pid_t d;
-  char s[sizeof(buffer)];
-  char c;
-  long long ll;
-  unsigned long long ull;
-
-  if (15 != sscanf(buffer,
-                   "%d %s %c %lld %lld %lld %lld %lld %llu %llu %llu %llu %llu "
-                   "%llu %llu ",
-                   &d, s, &c, &ll, &ll, &ll, &ll, &ll, &ull, &ull, &ull, &ull,
-                   &ull, uticks, sticks)) {
-    *uticks = *sticks = 0;
-  }
-}
-#endif
-
-TEST(liblog, android_logger_list_read__cpu_signal) {
-#ifdef __ANDROID__
-  struct logger_list* logger_list;
-  unsigned long long v = 0xDEADBEEFA55A0000ULL;
-
-  pid_t pid = getpid();
-
-  v += pid & 0xFFFF;
-
-  ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(LOG_ID_EVENTS, 0, 1000, pid)));
-
-  int count = 0;
-
-  int signals = 0;
-
-  unsigned long long uticks_start;
-  unsigned long long sticks_start;
-  get_ticks(&uticks_start, &sticks_start);
-
-  const unsigned alarm_time = 10;
-
-  memset(&signal_time, 0, sizeof(signal_time));
-
-  signal(SIGALRM, caught_blocking_signal);
-  alarm(alarm_time);
-
-  signaled = 0;
-
-  do {
-    log_msg log_msg;
-    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-      break;
-    }
-
-    alarm(alarm_time);
-
-    ++count;
-
-    ASSERT_EQ(log_msg.entry.pid, pid);
-
-    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
-        (log_msg.id() != LOG_ID_EVENTS)) {
-      continue;
-    }
-
-    android_log_event_long_t* eventData;
-    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-
-    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-      continue;
-    }
-
-    char* cp = reinterpret_cast<char*>(&eventData->payload.data);
-    unsigned long long l = cp[0] & 0xFF;
-    l |= (unsigned long long)(cp[1] & 0xFF) << 8;
-    l |= (unsigned long long)(cp[2] & 0xFF) << 16;
-    l |= (unsigned long long)(cp[3] & 0xFF) << 24;
-    l |= (unsigned long long)(cp[4] & 0xFF) << 32;
-    l |= (unsigned long long)(cp[5] & 0xFF) << 40;
-    l |= (unsigned long long)(cp[6] & 0xFF) << 48;
-    l |= (unsigned long long)(cp[7] & 0xFF) << 56;
-
-    if (l == v) {
-      ++signals;
-      break;
-    }
-  } while (!signaled || (log_time(CLOCK_MONOTONIC) < signal_time));
-  alarm(0);
-  signal(SIGALRM, SIG_DFL);
-
-  EXPECT_LE(1, count);
-
-  EXPECT_EQ(1, signals);
-
-  android_logger_list_close(logger_list);
-
-  unsigned long long uticks_end;
-  unsigned long long sticks_end;
-  get_ticks(&uticks_end, &sticks_end);
-
-  // Less than 1% in either user or system time, or both
-  const unsigned long long one_percent_ticks = alarm_time;
-  unsigned long long user_ticks = uticks_end - uticks_start;
-  unsigned long long system_ticks = sticks_end - sticks_start;
-  EXPECT_GT(one_percent_ticks, user_ticks);
-  EXPECT_GT(one_percent_ticks, system_ticks);
-  EXPECT_GT(one_percent_ticks, user_ticks + system_ticks);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-#ifdef __ANDROID__
-/*
- *  Strictly, we are not allowed to log messages in a signal context, the
- * correct way to handle this is to ensure the messages are constructed in
- * a thread; the signal handler should only unblock the thread.
- */
-static sem_t thread_trigger;
-
-static void caught_blocking_thread(int /*signum*/) {
-  sem_post(&thread_trigger);
-}
-
-static void* running_thread(void*) {
-  unsigned long long v = 0xDEADBEAFA55A0000ULL;
-
-  v += getpid() & 0xFFFF;
-
-  struct timespec timeout;
-  clock_gettime(CLOCK_REALTIME, &timeout);
-  timeout.tv_sec += 55;
-  sem_timedwait(&thread_trigger, &timeout);
-
-  ++signaled;
-  if ((signal_time.tv_sec == 0) && (signal_time.tv_nsec == 0)) {
-    signal_time = log_time(CLOCK_MONOTONIC);
-    signal_time.tv_sec += 2;
-  }
-
-  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-
-  return NULL;
-}
-
-static int start_thread() {
-  sem_init(&thread_trigger, 0, 0);
-
-  pthread_attr_t attr;
-  if (pthread_attr_init(&attr)) {
-    return -1;
-  }
-
-  struct sched_param param;
-
-  memset(&param, 0, sizeof(param));
-  pthread_attr_setschedparam(&attr, &param);
-  pthread_attr_setschedpolicy(&attr, SCHED_BATCH);
-
-  if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
-    pthread_attr_destroy(&attr);
-    return -1;
-  }
-
-  pthread_t thread;
-  if (pthread_create(&thread, &attr, running_thread, NULL)) {
-    pthread_attr_destroy(&attr);
-    return -1;
-  }
-
-  pthread_attr_destroy(&attr);
-  return 0;
-}
-#endif
-
-TEST(liblog, android_logger_list_read__cpu_thread) {
-#ifdef __ANDROID__
-  struct logger_list* logger_list;
-  unsigned long long v = 0xDEADBEAFA55A0000ULL;
-
-  pid_t pid = getpid();
-
-  v += pid & 0xFFFF;
-
-  ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(LOG_ID_EVENTS, 0, 1000, pid)));
-
-  int count = 0;
-
-  int signals = 0;
-
-  unsigned long long uticks_start;
-  unsigned long long sticks_start;
-  get_ticks(&uticks_start, &sticks_start);
-
-  const unsigned alarm_time = 10;
-
-  memset(&signal_time, 0, sizeof(signal_time));
-
-  signaled = 0;
-  EXPECT_EQ(0, start_thread());
-
-  signal(SIGALRM, caught_blocking_thread);
-  alarm(alarm_time);
-
-  do {
-    log_msg log_msg;
-    if (LOG_FAILURE_RETRY(android_logger_list_read(logger_list, &log_msg)) <= 0) {
-      break;
-    }
-
-    alarm(alarm_time);
-
-    ++count;
-
-    ASSERT_EQ(log_msg.entry.pid, pid);
-
-    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
-        (log_msg.id() != LOG_ID_EVENTS)) {
-      continue;
-    }
-
-    android_log_event_long_t* eventData;
-    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-
-    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-      continue;
-    }
-
-    char* cp = reinterpret_cast<char*>(&eventData->payload.data);
-    unsigned long long l = cp[0] & 0xFF;
-    l |= (unsigned long long)(cp[1] & 0xFF) << 8;
-    l |= (unsigned long long)(cp[2] & 0xFF) << 16;
-    l |= (unsigned long long)(cp[3] & 0xFF) << 24;
-    l |= (unsigned long long)(cp[4] & 0xFF) << 32;
-    l |= (unsigned long long)(cp[5] & 0xFF) << 40;
-    l |= (unsigned long long)(cp[6] & 0xFF) << 48;
-    l |= (unsigned long long)(cp[7] & 0xFF) << 56;
-
-    if (l == v) {
-      ++signals;
-      break;
-    }
-  } while (!signaled || (log_time(CLOCK_MONOTONIC) < signal_time));
-  alarm(0);
-  signal(SIGALRM, SIG_DFL);
-
-  EXPECT_LE(1, count);
-
-  EXPECT_EQ(1, signals);
-
-  android_logger_list_close(logger_list);
-
-  unsigned long long uticks_end;
-  unsigned long long sticks_end;
-  get_ticks(&uticks_end, &sticks_end);
-
-  // Less than 1% in either user or system time, or both
-  const unsigned long long one_percent_ticks = alarm_time;
-  unsigned long long user_ticks = uticks_end - uticks_start;
-  unsigned long long system_ticks = sticks_end - sticks_start;
-  EXPECT_GT(one_percent_ticks, user_ticks);
-  EXPECT_GT(one_percent_ticks, system_ticks);
-  EXPECT_GT(one_percent_ticks, user_ticks + system_ticks);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif  // ENABLE_FLAKY_TESTS
-
-static const char max_payload_buf[] =
-    "LEONATO\n\
-I learn in this letter that Don Peter of Arragon\n\
-comes this night to Messina\n\
-MESSENGER\n\
-He is very near by this: he was not three leagues off\n\
-when I left him\n\
-LEONATO\n\
-How many gentlemen have you lost in this action?\n\
-MESSENGER\n\
-But few of any sort, and none of name\n\
-LEONATO\n\
-A victory is twice itself when the achiever brings\n\
-home full numbers. I find here that Don Peter hath\n\
-bestowed much honour on a young Florentine called Claudio\n\
-MESSENGER\n\
-Much deserved on his part and equally remembered by\n\
-Don Pedro: he hath borne himself beyond the\n\
-promise of his age, doing, in the figure of a lamb,\n\
-the feats of a lion: he hath indeed better\n\
-bettered expectation than you must expect of me to\n\
-tell you how\n\
-LEONATO\n\
-He hath an uncle here in Messina will be very much\n\
-glad of it.\n\
-MESSENGER\n\
-I have already delivered him letters, and there\n\
-appears much joy in him; even so much that joy could\n\
-not show itself modest enough without a badge of\n\
-bitterness.\n\
-LEONATO\n\
-Did he break out into tears?\n\
-MESSENGER\n\
-In great measure.\n\
-LEONATO\n\
-A kind overflow of kindness: there are no faces\n\
-truer than those that are so washed. How much\n\
-better is it to weep at joy than to joy at weeping!\n\
-BEATRICE\n\
-I pray you, is Signior Mountanto returned from the\n\
-wars or no?\n\
-MESSENGER\n\
-I know none of that name, lady: there was none such\n\
-in the army of any sort.\n\
-LEONATO\n\
-What is he that you ask for, niece?\n\
-HERO\n\
-My cousin means Signior Benedick of Padua.\n\
-MESSENGER\n\
-O, he's returned; and as pleasant as ever he was.\n\
-BEATRICE\n\
-He set up his bills here in Messina and challenged\n\
-Cupid at the flight; and my uncle's fool, reading\n\
-the challenge, subscribed for Cupid, and challenged\n\
-him at the bird-bolt. I pray you, how many hath he\n\
-killed and eaten in these wars? But how many hath\n\
-he killed? for indeed I promised to eat all of his killing.\n\
-LEONATO\n\
-Faith, niece, you tax Signior Benedick too much;\n\
-but he'll be meet with you, I doubt it not.\n\
-MESSENGER\n\
-He hath done good service, lady, in these wars.\n\
-BEATRICE\n\
-You had musty victual, and he hath holp to eat it:\n\
-he is a very valiant trencherman; he hath an\n\
-excellent stomach.\n\
-MESSENGER\n\
-And a good soldier too, lady.\n\
-BEATRICE\n\
-And a good soldier to a lady: but what is he to a lord?\n\
-MESSENGER\n\
-A lord to a lord, a man to a man; stuffed with all\n\
-honourable virtues.\n\
-BEATRICE\n\
-It is so, indeed; he is no less than a stuffed man:\n\
-but for the stuffing,--well, we are all mortal.\n\
-LEONATO\n\
-You must not, sir, mistake my niece. There is a\n\
-kind of merry war betwixt Signior Benedick and her:\n\
-they never meet but there's a skirmish of wit\n\
-between them.\n\
-BEATRICE\n\
-Alas! he gets nothing by that. In our last\n\
-conflict four of his five wits went halting off, and\n\
-now is the whole man governed with one: so that if\n\
-he have wit enough to keep himself warm, let him\n\
-bear it for a difference between himself and his\n\
-horse; for it is all the wealth that he hath left,\n\
-to be known a reasonable creature. Who is his\n\
-companion now? He hath every month a new sworn brother.\n\
-MESSENGER\n\
-Is't possible?\n\
-BEATRICE\n\
-Very easily possible: he wears his faith but as\n\
-the fashion of his hat; it ever changes with the\n\
-next block.\n\
-MESSENGER\n\
-I see, lady, the gentleman is not in your books.\n\
-BEATRICE\n\
-No; an he were, I would burn my study. But, I pray\n\
-you, who is his companion? Is there no young\n\
-squarer now that will make a voyage with him to the devil?\n\
-MESSENGER\n\
-He is most in the company of the right noble Claudio.\n\
-BEATRICE\n\
-O Lord, he will hang upon him like a disease: he\n\
-is sooner caught than the pestilence, and the taker\n\
-runs presently mad. God help the noble Claudio! if\n\
-he have caught the Benedick, it will cost him a\n\
-thousand pound ere a' be cured.\n\
-MESSENGER\n\
-I will hold friends with you, lady.\n\
-BEATRICE\n\
-Do, good friend.\n\
-LEONATO\n\
-You will never run mad, niece.\n\
-BEATRICE\n\
-No, not till a hot January.\n\
-MESSENGER\n\
-Don Pedro is approached.\n\
-Enter DON PEDRO, DON JOHN, CLAUDIO, BENEDICK, and BALTHASAR\n\
-\n\
-DON PEDRO\n\
-Good Signior Leonato, you are come to meet your\n\
-trouble: the fashion of the world is to avoid\n\
-cost, and you encounter it\n\
-LEONATO\n\
-Never came trouble to my house in the likeness of your grace,\n\
-for trouble being gone, comfort should remain, but\n\
-when you depart from me, sorrow abides and happiness\n\
-takes his leave.";
-
-TEST(liblog, max_payload) {
-#ifdef __ANDROID__
-  static const char max_payload_tag[] = "TEST_max_payload_and_longish_tag_XXXX";
-#define SIZEOF_MAX_PAYLOAD_BUF (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(max_payload_tag) - 1)
-
-  pid_t pid = getpid();
-  char tag[sizeof(max_payload_tag)];
-  memcpy(tag, max_payload_tag, sizeof(tag));
-  snprintf(tag + sizeof(tag) - 5, 5, "%04X", pid & 0xFFFF);
-
-  auto write_function = [&] {
-    LOG_FAILURE_RETRY(
-        __android_log_buf_write(LOG_ID_SYSTEM, ANDROID_LOG_INFO, tag, max_payload_buf));
-  };
-
-  ssize_t max_len = 0;
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    char* data = log_msg.msg();
-
-    if (!data || strcmp(++data, tag)) {
-      return;
-    }
-
-    data += strlen(data) + 1;
-
-    const char* left = data;
-    const char* right = max_payload_buf;
-    while (*left && *right && (*left == *right)) {
-      ++left;
-      ++right;
-    }
-
-    if (max_len <= (left - data)) {
-      max_len = left - data + 1;
-    }
-
-    if (max_len > 512) {
-      *found = true;
-    }
-  };
-
-  RunLogTests(LOG_ID_SYSTEM, write_function, check_function);
-
-  EXPECT_LE(SIZEOF_MAX_PAYLOAD_BUF, static_cast<size_t>(max_len));
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, __android_log_buf_print__maxtag) {
-#ifdef __ANDROID__
-  auto write_function = [&] {
-    EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO, max_payload_buf,
-                                         max_payload_buf));
-  };
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    if ((size_t)log_msg.entry.len < LOGGER_ENTRY_MAX_PAYLOAD) {
-      return;
-    }
-
-    *found = true;
-
-    AndroidLogFormat* logformat = android_log_format_new();
-    EXPECT_TRUE(NULL != logformat);
-    AndroidLogEntry entry;
-    int processLogBuffer = android_log_processLogBuffer(&log_msg.entry, &entry);
-    EXPECT_EQ(0, processLogBuffer);
-    if (processLogBuffer == 0) {
-      fflush(stderr);
-      int printLogLine =
-          android_log_printLogLine(logformat, fileno(stderr), &entry);
-      // Legacy tag truncation
-      EXPECT_LE(128, printLogLine);
-      // Measured maximum if we try to print part of the tag as message
-      EXPECT_GT(LOGGER_ENTRY_MAX_PAYLOAD * 13 / 8, printLogLine);
-    }
-    android_log_format_free(logformat);
-  };
-
-  RunLogTests(LOG_ID_MAIN, write_function, check_function);
-
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-// Note: This test is tautological. android_logger_list_read() calls recv() with
-// LOGGER_ENTRY_MAX_PAYLOAD as its size argument, so it's not possible for this test to read a
-// payload larger than that size.
-TEST(liblog, too_big_payload) {
-#ifdef __ANDROID__
-  pid_t pid = getpid();
-  static const char big_payload_tag[] = "TEST_big_payload_XXXX";
-  char tag[sizeof(big_payload_tag)];
-  memcpy(tag, big_payload_tag, sizeof(tag));
-  snprintf(tag + sizeof(tag) - 5, 5, "%04X", pid & 0xFFFF);
-
-  std::string longString(3266519, 'x');
-  ssize_t ret;
-
-  auto write_function = [&] {
-    ret = LOG_FAILURE_RETRY(
-        __android_log_buf_write(LOG_ID_SYSTEM, ANDROID_LOG_INFO, tag, longString.c_str()));
-  };
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    char* data = log_msg.msg();
-
-    if (!data || strcmp(++data, tag)) {
-      return;
-    }
-
-    data += strlen(data) + 1;
-
-    const char* left = data;
-    const char* right = longString.c_str();
-    while (*left && *right && (*left == *right)) {
-      ++left;
-      ++right;
-    }
-
-    ssize_t len = left - data + 1;
-    // Check that we don't see any entries larger than the max payload.
-    EXPECT_LE(static_cast<size_t>(len), LOGGER_ENTRY_MAX_PAYLOAD - sizeof(big_payload_tag));
-
-    // Once we've found our expected entry, break.
-    if (len == LOGGER_ENTRY_MAX_PAYLOAD - sizeof(big_payload_tag)) {
-      *found = true;
-    }
-  };
-
-  RunLogTests(LOG_ID_SYSTEM, write_function, check_function);
-
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, dual_reader) {
-#ifdef __ANDROID__
-  static const int expected_count1 = 25;
-  static const int expected_count2 = 25;
-
-  pid_t pid = getpid();
-
-  auto logger_list1 = std::unique_ptr<struct logger_list, ListCloser>{
-      android_logger_list_open(LOG_ID_MAIN, 0, expected_count1, pid)};
-  ASSERT_TRUE(logger_list1);
-
-  auto logger_list2 = std::unique_ptr<struct logger_list, ListCloser>{
-      android_logger_list_open(LOG_ID_MAIN, 0, expected_count2, pid)};
-  ASSERT_TRUE(logger_list2);
-
-  for (int i = 25; i > 0; --i) {
-    static const char fmt[] = "dual_reader %02d";
-    char buffer[sizeof(fmt) + 8];
-    snprintf(buffer, sizeof(buffer), fmt, i);
-    LOG_FAILURE_RETRY(__android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                              "liblog", buffer));
-  }
-
-  alarm(2);
-  auto alarm_guard = android::base::make_scope_guard([] { alarm(0); });
-
-  // Wait until we see all messages with the blocking reader.
-  int count1 = 0;
-  int count2 = 0;
-
-  while (count1 != expected_count2 || count2 != expected_count2) {
-    log_msg log_msg;
-    if (count1 < expected_count1) {
-      ASSERT_GT(android_logger_list_read(logger_list1.get(), &log_msg), 0);
-      count1++;
-    }
-    if (count2 < expected_count2) {
-      ASSERT_GT(android_logger_list_read(logger_list2.get(), &log_msg), 0);
-      count2++;
-    }
-  }
-
-  // Test again with the nonblocking reader.
-  auto logger_list_non_block1 = std::unique_ptr<struct logger_list, ListCloser>{
-      android_logger_list_open(LOG_ID_MAIN, ANDROID_LOG_NONBLOCK, expected_count1, pid)};
-  ASSERT_TRUE(logger_list_non_block1);
-
-  auto logger_list_non_block2 = std::unique_ptr<struct logger_list, ListCloser>{
-      android_logger_list_open(LOG_ID_MAIN, ANDROID_LOG_NONBLOCK, expected_count2, pid)};
-  ASSERT_TRUE(logger_list_non_block2);
-  count1 = 0;
-  count2 = 0;
-  bool done1 = false;
-  bool done2 = false;
-
-  while (!done1 || !done2) {
-    log_msg log_msg;
-
-    if (!done1) {
-      if (android_logger_list_read(logger_list_non_block1.get(), &log_msg) <= 0) {
-        done1 = true;
-      } else {
-        ++count1;
-      }
-    }
-
-    if (!done2) {
-      if (android_logger_list_read(logger_list_non_block2.get(), &log_msg) <= 0) {
-        done2 = true;
-      } else {
-        ++count2;
-      }
-    }
-  }
-
-  EXPECT_EQ(expected_count1, count1);
-  EXPECT_EQ(expected_count2, count2);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-static bool checkPriForTag(AndroidLogFormat* p_format, const char* tag,
-                           android_LogPriority pri) {
-  return android_log_shouldPrintLine(p_format, tag, pri) &&
-         !android_log_shouldPrintLine(p_format, tag,
-                                      (android_LogPriority)(pri - 1));
-}
-
-TEST(liblog, filterRule) {
-  static const char tag[] = "random";
-
-  AndroidLogFormat* p_format = android_log_format_new();
-
-  android_log_addFilterRule(p_format, "*:i");
-
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_INFO));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
-              0);
-  android_log_addFilterRule(p_format, "*");
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-  android_log_addFilterRule(p_format, "*:v");
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-  android_log_addFilterRule(p_format, "*:i");
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_INFO));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
-              0);
-
-  android_log_addFilterRule(p_format, tag);
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-  android_log_addFilterRule(p_format, "random:v");
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-  android_log_addFilterRule(p_format, "random:d");
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-  android_log_addFilterRule(p_format, "random:w");
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
-              0);
-
-  android_log_addFilterRule(p_format, "crap:*");
-  EXPECT_TRUE(checkPriForTag(p_format, "crap", ANDROID_LOG_VERBOSE));
-  EXPECT_TRUE(
-      android_log_shouldPrintLine(p_format, "crap", ANDROID_LOG_VERBOSE) > 0);
-
-  // invalid expression
-  EXPECT_TRUE(android_log_addFilterRule(p_format, "random:z") < 0);
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
-  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
-              0);
-
-  // Issue #550946
-  EXPECT_TRUE(android_log_addFilterString(p_format, " ") == 0);
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
-
-  // note trailing space
-  EXPECT_TRUE(android_log_addFilterString(p_format, "*:s random:d ") == 0);
-  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
-
-  EXPECT_TRUE(android_log_addFilterString(p_format, "*:s random:z") < 0);
-
-#if 0  // bitrot, seek update
-    char defaultBuffer[512];
-
-    android_log_formatLogLine(p_format,
-        defaultBuffer, sizeof(defaultBuffer), 0, ANDROID_LOG_ERROR, 123,
-        123, 123, tag, "nofile", strlen("Hello"), "Hello", NULL);
-
-    fprintf(stderr, "%s\n", defaultBuffer);
-#endif
-
-  android_log_format_free(p_format);
-}
-
-#ifdef ENABLE_FLAKY_TESTS
-TEST(liblog, is_loggable) {
-#ifdef __ANDROID__
-  static const char tag[] = "is_loggable";
-  static const char log_namespace[] = "persist.log.tag.";
-  static const size_t base_offset = 8; /* skip "persist." */
-  // sizeof("string") = strlen("string") + 1
-  char key[sizeof(log_namespace) + sizeof(tag) - 1];
-  char hold[4][PROP_VALUE_MAX];
-  static const struct {
-    int level;
-    char type;
-  } levels[] = {
-      {ANDROID_LOG_VERBOSE, 'v'}, {ANDROID_LOG_DEBUG, 'd'},
-      {ANDROID_LOG_INFO, 'i'},    {ANDROID_LOG_WARN, 'w'},
-      {ANDROID_LOG_ERROR, 'e'},   {ANDROID_LOG_FATAL, 'a'},
-      {ANDROID_LOG_SILENT, 's'},  {-2, 'g'},  // Illegal value, resort to default
-  };
-
-  // Set up initial test condition
-  memset(hold, 0, sizeof(hold));
-  snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-  property_get(key, hold[0], "");
-  property_set(key, "");
-  property_get(key + base_offset, hold[1], "");
-  property_set(key + base_offset, "");
-  strcpy(key, log_namespace);
-  key[sizeof(log_namespace) - 2] = '\0';
-  property_get(key, hold[2], "");
-  property_set(key, "");
-  property_get(key, hold[3], "");
-  property_set(key + base_offset, "");
-
-  // All combinations of level and defaults
-  for (size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
-    if (levels[i].level == -2) {
-      continue;
-    }
-    for (size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
-      if (levels[j].level == -2) {
-        continue;
-      }
-      fprintf(stderr, "i=%zu j=%zu\r", i, j);
-      bool android_log_is_loggable = __android_log_is_loggable_len(
-          levels[i].level, tag, strlen(tag), levels[j].level);
-      if ((levels[i].level < levels[j].level) || (levels[j].level == -1)) {
-        if (android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_FALSE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_FALSE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), levels[j].level));
-        }
-      } else {
-        if (!android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_TRUE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_TRUE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), levels[j].level));
-        }
-      }
-    }
-  }
-
-  // All combinations of level and tag and global properties
-  for (size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
-    if (levels[i].level == -2) {
-      continue;
-    }
-    for (size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
-      char buf[2];
-      buf[0] = levels[j].type;
-      buf[1] = '\0';
-
-      snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j, key,
-              buf);
-      usleep(20000);
-      property_set(key, buf);
-      bool android_log_is_loggable = __android_log_is_loggable_len(
-          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
-          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
-        if (android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_FALSE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_FALSE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      } else {
-        if (!android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_TRUE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_TRUE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      }
-      usleep(20000);
-      property_set(key, "");
-
-      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j,
-              key + base_offset, buf);
-      property_set(key + base_offset, buf);
-      android_log_is_loggable = __android_log_is_loggable_len(
-          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
-          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
-        if (android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_FALSE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_FALSE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      } else {
-        if (!android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_TRUE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_TRUE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      }
-      usleep(20000);
-      property_set(key + base_offset, "");
-
-      strcpy(key, log_namespace);
-      key[sizeof(log_namespace) - 2] = '\0';
-      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j, key,
-              buf);
-      property_set(key, buf);
-      android_log_is_loggable = __android_log_is_loggable_len(
-          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
-          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
-        if (android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_FALSE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_FALSE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      } else {
-        if (!android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_TRUE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_TRUE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      }
-      usleep(20000);
-      property_set(key, "");
-
-      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j,
-              key + base_offset, buf);
-      property_set(key + base_offset, buf);
-      android_log_is_loggable = __android_log_is_loggable_len(
-          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
-          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
-        if (android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_FALSE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_FALSE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      } else {
-        if (!android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_TRUE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_TRUE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      }
-      usleep(20000);
-      property_set(key + base_offset, "");
-    }
-  }
-
-  // All combinations of level and tag properties, but with global set to INFO
-  strcpy(key, log_namespace);
-  key[sizeof(log_namespace) - 2] = '\0';
-  usleep(20000);
-  property_set(key, "I");
-  snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-  for (size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
-    if (levels[i].level == -2) {
-      continue;
-    }
-    for (size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
-      char buf[2];
-      buf[0] = levels[j].type;
-      buf[1] = '\0';
-
-      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j, key,
-              buf);
-      usleep(20000);
-      property_set(key, buf);
-      bool android_log_is_loggable = __android_log_is_loggable_len(
-          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
-          ((levels[i].level < ANDROID_LOG_INFO)  // Yes INFO
-           && (levels[j].level == -2))) {
-        if (android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_FALSE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_FALSE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      } else {
-        if (!android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_TRUE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_TRUE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      }
-      usleep(20000);
-      property_set(key, "");
-
-      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j,
-              key + base_offset, buf);
-      property_set(key + base_offset, buf);
-      android_log_is_loggable = __android_log_is_loggable_len(
-          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
-          ((levels[i].level < ANDROID_LOG_INFO)  // Yes INFO
-           && (levels[j].level == -2))) {
-        if (android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_FALSE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_FALSE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      } else {
-        if (!android_log_is_loggable) {
-          fprintf(stderr, "\n");
-        }
-        EXPECT_TRUE(android_log_is_loggable);
-        for (size_t k = 10; k; --k) {
-          EXPECT_TRUE(__android_log_is_loggable_len(
-              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-        }
-      }
-      usleep(20000);
-      property_set(key + base_offset, "");
-    }
-  }
-
-  // reset parms
-  snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-  usleep(20000);
-  property_set(key, hold[0]);
-  property_set(key + base_offset, hold[1]);
-  strcpy(key, log_namespace);
-  key[sizeof(log_namespace) - 2] = '\0';
-  property_set(key, hold[2]);
-  property_set(key + base_offset, hold[3]);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif  // ENABLE_FLAKY_TESTS
-
-#ifdef ENABLE_FLAKY_TESTS
-// Following tests the specific issues surrounding error handling wrt logd.
-// Kills logd and toss all collected data, equivalent to logcat -b all -c,
-// except we also return errors to the logging callers.
-#ifdef __ANDROID__
-// helper to liblog.enoent to count end-to-end matching logging messages.
-static int count_matching_ts(log_time ts) {
-  usleep(1000000);
-
-  pid_t pid = getpid();
-
-  struct logger_list* logger_list =
-      android_logger_list_open(LOG_ID_EVENTS, ANDROID_LOG_NONBLOCK, 1000, pid);
-
-  int count = 0;
-  if (logger_list == NULL) return count;
-
-  for (;;) {
-    log_msg log_msg;
-    if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
-
-    if (log_msg.entry.len != sizeof(android_log_event_long_t)) continue;
-    if (log_msg.id() != LOG_ID_EVENTS) continue;
-
-    android_log_event_long_t* eventData;
-    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-    if (!eventData) continue;
-    if (eventData->payload.type != EVENT_TYPE_LONG) continue;
-
-    log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
-    if (ts != tx) continue;
-
-    // found event message with matching timestamp signature in payload
-    ++count;
-  }
-  android_logger_list_close(logger_list);
-
-  return count;
-}
-
-TEST(liblog, enoent) {
-#ifdef __ANDROID__
-  if (getuid() != 0) {
-    GTEST_SKIP() << "Skipping test, must be run as root.";
-    return;
-  }
-
-  log_time ts(CLOCK_MONOTONIC);
-  EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-  EXPECT_EQ(1, count_matching_ts(ts));
-
-  // This call will fail unless we are root, beware of any
-  // test prior to this one playing with setuid and causing interference.
-  // We need to run before these tests so that they do not interfere with
-  // this test.
-  //
-  // Stopping the logger can affect some other test's expectations as they
-  // count on the log buffers filled with existing content, and this
-  // effectively does a logcat -c emptying it.  So we want this test to be
-  // as near as possible to the bottom of the file.  For example
-  // liblog.android_logger_get_ is one of those tests that has no recourse
-  // and that would be adversely affected by emptying the log if it was run
-  // right after this test.
-  system("stop logd");
-  usleep(1000000);
-
-  // A clean stop like we are testing returns -ENOENT, but in the _real_
-  // world we could get -ENOTCONN or -ECONNREFUSED depending on timing.
-  // Alas we can not test these other return values; accept that they
-  // are treated equally within the open-retry logic in liblog.
-  ts = log_time(CLOCK_MONOTONIC);
-  int ret = __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts));
-  std::string content = android::base::StringPrintf(
-      "__android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)) = %d %s\n",
-      ret, (ret <= 0) ? strerror(-ret) : "(content sent)");
-  EXPECT_TRUE(ret == -ENOENT || ret == -ENOTCONN || ret == -ECONNREFUSED) << content;
-  ret = __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts));
-  content = android::base::StringPrintf(
-      "__android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)) = %d %s\n",
-      ret, (ret <= 0) ? strerror(-ret) : "(content sent)");
-  EXPECT_TRUE(ret == -ENOENT || ret == -ENOTCONN || ret == -ECONNREFUSED) << content;
-  EXPECT_EQ(0, count_matching_ts(ts));
-
-  system("start logd");
-  usleep(1000000);
-
-  EXPECT_EQ(0, count_matching_ts(ts));
-
-  ts = log_time(CLOCK_MONOTONIC);
-  EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-  EXPECT_EQ(1, count_matching_ts(ts));
-
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif  // __ANDROID__
-#endif  // ENABLE_FLAKY_TESTS
-
-// Below this point we run risks of setuid(AID_SYSTEM) which may affect others.
-
-#ifdef ENABLE_FLAKY_TESTS
-// Do not retest properties, and cannot log into LOG_ID_SECURITY
-TEST(liblog, __security) {
-#ifdef __ANDROID__
-  static const char persist_key[] = "persist.logd.security";
-  static const char readonly_key[] = "ro.organization_owned";
-  // A silly default value that can never be in readonly_key so
-  // that it can be determined the property is not set.
-  static const char nothing_val[] = "_NOTHING_TO_SEE_HERE_";
-  char persist[PROP_VALUE_MAX];
-  char persist_hold[PROP_VALUE_MAX];
-  char readonly[PROP_VALUE_MAX];
-
-  // First part of this test requires the test itself to have the appropriate
-  // permissions. If we do not have them, we can not override them, so we
-  // bail rather than give a failing grade.
-  property_get(persist_key, persist, "");
-  fprintf(stderr, "INFO: getprop %s -> %s\n", persist_key, persist);
-  strncpy(persist_hold, persist, PROP_VALUE_MAX);
-  property_get(readonly_key, readonly, nothing_val);
-  fprintf(stderr, "INFO: getprop %s -> %s\n", readonly_key, readonly);
-
-  if (!strcmp(readonly, nothing_val)) {
-    // Lets check if we can set the value (we should not be allowed to do so)
-    EXPECT_FALSE(__android_log_security());
-    fprintf(stderr, "WARNING: setting ro.organization_owned to a domain\n");
-    static const char domain[] = "com.google.android.SecOps.DeviceOwner";
-    EXPECT_NE(0, property_set(readonly_key, domain));
-    useconds_t total_time = 0;
-    static const useconds_t seconds = 1000000;
-    static const useconds_t max_time = 5 * seconds;  // not going to happen
-    static const useconds_t rest = 20 * 1000;
-    for (; total_time < max_time; total_time += rest) {
-      usleep(rest);  // property system does not guarantee performance.
-      property_get(readonly_key, readonly, nothing_val);
-      if (!strcmp(readonly, domain)) {
-        if (total_time > rest) {
-          fprintf(stderr, "INFO: took %u.%06u seconds to set property\n",
-                  (unsigned)(total_time / seconds),
-                  (unsigned)(total_time % seconds));
-        }
-        break;
-      }
-    }
-    EXPECT_STRNE(domain, readonly);
-  }
-
-  if (!strcasecmp(readonly, "false") || !readonly[0] ||
-      !strcmp(readonly, nothing_val)) {
-    // not enough permissions to run tests surrounding persist.logd.security
-    EXPECT_FALSE(__android_log_security());
-    return;
-  }
-
-  if (!strcasecmp(persist, "true")) {
-    EXPECT_TRUE(__android_log_security());
-  } else {
-    EXPECT_FALSE(__android_log_security());
-  }
-  property_set(persist_key, "TRUE");
-  property_get(persist_key, persist, "");
-  uid_t uid = getuid();
-  gid_t gid = getgid();
-  bool perm = (gid == AID_ROOT) || (uid == AID_ROOT);
-  EXPECT_STREQ(perm ? "TRUE" : persist_hold, persist);
-  if (!strcasecmp(persist, "true")) {
-    EXPECT_TRUE(__android_log_security());
-  } else {
-    EXPECT_FALSE(__android_log_security());
-  }
-  property_set(persist_key, "FALSE");
-  property_get(persist_key, persist, "");
-  EXPECT_STREQ(perm ? "FALSE" : persist_hold, persist);
-  if (!strcasecmp(persist, "true")) {
-    EXPECT_TRUE(__android_log_security());
-  } else {
-    EXPECT_FALSE(__android_log_security());
-  }
-  property_set(persist_key, "true");
-  property_get(persist_key, persist, "");
-  EXPECT_STREQ(perm ? "true" : persist_hold, persist);
-  if (!strcasecmp(persist, "true")) {
-    EXPECT_TRUE(__android_log_security());
-  } else {
-    EXPECT_FALSE(__android_log_security());
-  }
-  property_set(persist_key, "false");
-  property_get(persist_key, persist, "");
-  EXPECT_STREQ(perm ? "false" : persist_hold, persist);
-  if (!strcasecmp(persist, "true")) {
-    EXPECT_TRUE(__android_log_security());
-  } else {
-    EXPECT_FALSE(__android_log_security());
-  }
-  property_set(persist_key, "");
-  property_get(persist_key, persist, "");
-  EXPECT_STREQ(perm ? "" : persist_hold, persist);
-  if (!strcasecmp(persist, "true")) {
-    EXPECT_TRUE(__android_log_security());
-  } else {
-    EXPECT_FALSE(__android_log_security());
-  }
-  property_set(persist_key, persist_hold);
-  property_get(persist_key, persist, "");
-  EXPECT_STREQ(persist_hold, persist);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, __security_buffer) {
-#ifdef __ANDROID__
-  struct logger_list* logger_list;
-  android_event_long_t buffer;
-
-  static const char persist_key[] = "persist.logd.security";
-  char persist[PROP_VALUE_MAX];
-  bool set_persist = false;
-  bool allow_security = false;
-
-  if (__android_log_security()) {
-    allow_security = true;
-  } else {
-    property_get(persist_key, persist, "");
-    if (strcasecmp(persist, "true")) {
-      property_set(persist_key, "TRUE");
-      if (__android_log_security()) {
-        allow_security = true;
-        set_persist = true;
-      } else {
-        property_set(persist_key, persist);
-      }
-    }
-  }
-
-  if (!allow_security) {
-    fprintf(stderr,
-            "WARNING: "
-            "security buffer disabled, bypassing end-to-end test\n");
-
-    log_time ts(CLOCK_MONOTONIC);
-
-    buffer.type = EVENT_TYPE_LONG;
-    buffer.data = *(static_cast<uint64_t*>((void*)&ts));
-
-    // expect failure!
-    ASSERT_GE(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
-
-    return;
-  }
-
-  /* Matches clientHasLogCredentials() in logd */
-  uid_t uid = getuid();
-  gid_t gid = getgid();
-  bool clientHasLogCredentials = true;
-  if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG) &&
-      (gid != AID_SYSTEM) && (gid != AID_ROOT) && (gid != AID_LOG)) {
-    uid_t euid = geteuid();
-    if ((euid != AID_SYSTEM) && (euid != AID_ROOT) && (euid != AID_LOG)) {
-      gid_t egid = getegid();
-      if ((egid != AID_SYSTEM) && (egid != AID_ROOT) && (egid != AID_LOG)) {
-        int num_groups = getgroups(0, NULL);
-        if (num_groups > 0) {
-          gid_t groups[num_groups];
-          num_groups = getgroups(num_groups, groups);
-          while (num_groups > 0) {
-            if (groups[num_groups - 1] == AID_LOG) {
-              break;
-            }
-            --num_groups;
-          }
-        }
-        if (num_groups <= 0) {
-          clientHasLogCredentials = false;
-        }
-      }
-    }
-  }
-  if (!clientHasLogCredentials) {
-    fprintf(stderr,
-            "WARNING: "
-            "not in system context, bypassing end-to-end test\n");
-
-    log_time ts(CLOCK_MONOTONIC);
-
-    buffer.type = EVENT_TYPE_LONG;
-    buffer.data = *(static_cast<uint64_t*>((void*)&ts));
-
-    // expect failure!
-    ASSERT_GE(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
-
-    return;
-  }
-
-  EXPECT_EQ(0, setuid(AID_SYSTEM));  // only one that can read security buffer
-
-  uid = getuid();
-  gid = getgid();
-  pid_t pid = getpid();
-
-  ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(LOG_ID_SECURITY, ANDROID_LOG_NONBLOCK,
-                                                              1000, pid)));
-
-  log_time ts(CLOCK_MONOTONIC);
-
-  buffer.type = EVENT_TYPE_LONG;
-  buffer.data = *(static_cast<uint64_t*>((void*)&ts));
-
-  ASSERT_LT(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
-  usleep(1000000);
-
-  int count = 0;
-
-  for (;;) {
-    log_msg log_msg;
-    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-      break;
-    }
-
-    ASSERT_EQ(log_msg.entry.pid, pid);
-
-    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
-        (log_msg.id() != LOG_ID_SECURITY)) {
-      continue;
-    }
-
-    android_log_event_long_t* eventData;
-    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-
-    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-      continue;
-    }
-
-    log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
-    if (ts == tx) {
-      ++count;
-    }
-  }
-
-  if (set_persist) {
-    property_set(persist_key, persist);
-  }
-
-  android_logger_list_close(logger_list);
-
-  bool clientHasSecurityCredentials = (uid == AID_SYSTEM) || (gid == AID_SYSTEM);
-  if (!clientHasSecurityCredentials) {
-    fprintf(stderr,
-            "WARNING: "
-            "not system, content submitted but can not check end-to-end\n");
-  }
-  EXPECT_EQ(clientHasSecurityCredentials ? 1 : 0, count);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif  // ENABLE_FLAKY_TESTS
-
-#ifdef __ANDROID__
-static void android_errorWriteWithInfoLog_helper(int tag, const char* subtag, int uid,
-                                                 const char* payload, int data_len) {
-  auto write_function = [&] {
-    int ret = android_errorWriteWithInfoLog(tag, subtag, uid, payload, data_len);
-    ASSERT_LT(0, ret);
-  };
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    char* event_data = log_msg.msg();
-    char* original = event_data;
-
-    // Tag
-    auto* event_header = reinterpret_cast<android_event_header_t*>(event_data);
-    event_data += sizeof(android_event_header_t);
-    if (event_header->tag != tag) {
-      return;
-    }
-
-    // List type
-    auto* event_list = reinterpret_cast<android_event_list_t*>(event_data);
-    ASSERT_EQ(EVENT_TYPE_LIST, event_list->type);
-    ASSERT_EQ(3, event_list->element_count);
-    event_data += sizeof(android_event_list_t);
-
-    // Element #1: string type for subtag
-    auto* event_string_subtag = reinterpret_cast<android_event_string_t*>(event_data);
-    ASSERT_EQ(EVENT_TYPE_STRING, event_string_subtag->type);
-    int32_t subtag_len = strlen(subtag);
-    if (subtag_len > 32) {
-      subtag_len = 32;
-    }
-    ASSERT_EQ(subtag_len, event_string_subtag->length);
-    if (memcmp(subtag, &event_string_subtag->data, subtag_len)) {
-      return;
-    }
-    event_data += sizeof(android_event_string_t) + subtag_len;
-
-    // Element #2: int type for uid
-    auto* event_int_uid = reinterpret_cast<android_event_int_t*>(event_data);
-    ASSERT_EQ(EVENT_TYPE_INT, event_int_uid->type);
-    ASSERT_EQ(uid, event_int_uid->data);
-    event_data += sizeof(android_event_int_t);
-
-    // Element #3: string type for data
-    auto* event_string_data = reinterpret_cast<android_event_string_t*>(event_data);
-    ASSERT_EQ(EVENT_TYPE_STRING, event_string_data->type);
-    int32_t message_data_len = event_string_data->length;
-    if (data_len < 512) {
-      ASSERT_EQ(data_len, message_data_len);
-    }
-    if (memcmp(payload, &event_string_data->data, message_data_len) != 0) {
-      return;
-    }
-    event_data += sizeof(android_event_string_t);
-
-    if (data_len >= 512) {
-      event_data += message_data_len;
-      // 4 bytes for the tag, and max_payload_buf should be truncated.
-      ASSERT_LE(4 + 512, event_data - original);       // worst expectations
-      ASSERT_GT(4 + data_len, event_data - original);  // must be truncated
-    }
-    *found = true;
-  };
-
-  RunLogTests(LOG_ID_EVENTS, write_function, check_function);
-}
-#endif
-
-// Make multiple tests and re-tests orthogonal to prevent falsing.
-#ifdef TEST_LOGGER
-#define UNIQUE_TAG(X) \
-  (0x12340000 + (((X) + sizeof(int) + sizeof(void*)) << 8) + TEST_LOGGER)
-#else
-#define UNIQUE_TAG(X) \
-  (0x12340000 + (((X) + sizeof(int) + sizeof(void*)) << 8) + 0xBA)
-#endif
-
-TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__typical) {
-#ifdef __ANDROID__
-  android_errorWriteWithInfoLog_helper(UNIQUE_TAG(1), "test-subtag", -1, max_payload_buf, 200);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog,
-     android_errorWriteWithInfoLog__android_logger_list_read__data_too_large) {
-#ifdef __ANDROID__
-  android_errorWriteWithInfoLog_helper(UNIQUE_TAG(2), "test-subtag", -1, max_payload_buf,
-                                       sizeof(max_payload_buf));
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog,
-     android_errorWriteWithInfoLog__android_logger_list_read__null_data) {
-#ifdef __ANDROID__
-  int retval_android_errorWriteWithinInfoLog =
-      android_errorWriteWithInfoLog(UNIQUE_TAG(3), "test-subtag", -1, nullptr, 200);
-  ASSERT_GT(0, retval_android_errorWriteWithinInfoLog);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog,
-     android_errorWriteWithInfoLog__android_logger_list_read__subtag_too_long) {
-#ifdef __ANDROID__
-  android_errorWriteWithInfoLog_helper(
-      UNIQUE_TAG(4), "abcdefghijklmnopqrstuvwxyz now i know my abc", -1, max_payload_buf, 200);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, __android_log_bswrite_and_print___max) {
-  bswrite_test(max_payload_buf);
-}
-
-TEST(liblog, __android_log_buf_write_and_print__max) {
-  buf_write_test(max_payload_buf);
-}
-
-TEST(liblog, android_errorWriteLog__android_logger_list_read__success) {
-#ifdef __ANDROID__
-  int kTag = UNIQUE_TAG(5);
-  const char* kSubTag = "test-subtag";
-
-  auto write_function = [&] {
-    int retval_android_errorWriteLog = android_errorWriteLog(kTag, kSubTag);
-    ASSERT_LT(0, retval_android_errorWriteLog);
-  };
-
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    char* event_data = log_msg.msg();
-
-    // Tag
-    auto* event_header = reinterpret_cast<android_event_header_t*>(event_data);
-    event_data += sizeof(android_event_header_t);
-    if (event_header->tag != kTag) {
-      return;
-    }
-
-    // List type
-    auto* event_list = reinterpret_cast<android_event_list_t*>(event_data);
-    ASSERT_EQ(EVENT_TYPE_LIST, event_list->type);
-    ASSERT_EQ(3, event_list->element_count);
-    event_data += sizeof(android_event_list_t);
-
-    // Element #1: string type for subtag
-    auto* event_string_subtag = reinterpret_cast<android_event_string_t*>(event_data);
-    ASSERT_EQ(EVENT_TYPE_STRING, event_string_subtag->type);
-    int32_t subtag_len = strlen(kSubTag);
-    ASSERT_EQ(subtag_len, event_string_subtag->length);
-    if (memcmp(kSubTag, &event_string_subtag->data, subtag_len) == 0) {
-      *found = true;
-    }
-  };
-
-  RunLogTests(LOG_ID_EVENTS, write_function, check_function);
-
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, android_errorWriteLog__android_logger_list_read__null_subtag) {
-#ifdef __ANDROID__
-  EXPECT_LT(android_errorWriteLog(UNIQUE_TAG(6), nullptr), 0);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-// Do not retest logger list handling
-#ifdef __ANDROID__
-static int is_real_element(int type) {
-  return ((type == EVENT_TYPE_INT) || (type == EVENT_TYPE_LONG) ||
-          (type == EVENT_TYPE_STRING) || (type == EVENT_TYPE_FLOAT));
-}
-
-static int android_log_buffer_to_string(const char* msg, size_t len,
-                                        char* strOut, size_t strOutLen) {
-  android_log_context context = create_android_log_parser(msg, len);
-  android_log_list_element elem;
-  bool overflow = false;
-  /* Reserve 1 byte for null terminator. */
-  size_t origStrOutLen = strOutLen--;
-
-  if (!context) {
-    return -EBADF;
-  }
-
-  memset(&elem, 0, sizeof(elem));
-
-  size_t outCount;
-
-  do {
-    elem = android_log_read_next(context);
-    switch ((int)elem.type) {
-      case EVENT_TYPE_LIST:
-        if (strOutLen == 0) {
-          overflow = true;
-        } else {
-          *strOut++ = '[';
-          strOutLen--;
-        }
-        break;
-
-      case EVENT_TYPE_LIST_STOP:
-        if (strOutLen == 0) {
-          overflow = true;
-        } else {
-          *strOut++ = ']';
-          strOutLen--;
-        }
-        break;
-
-      case EVENT_TYPE_INT:
-        /*
-         * snprintf also requires room for the null terminator, which
-         * we don't care about  but we have allocated enough room for
-         * that
-         */
-        outCount = snprintf(strOut, strOutLen + 1, "%" PRId32, elem.data.int32);
-        if (outCount <= strOutLen) {
-          strOut += outCount;
-          strOutLen -= outCount;
-        } else {
-          overflow = true;
-        }
-        break;
-
-      case EVENT_TYPE_LONG:
-        /*
-         * snprintf also requires room for the null terminator, which
-         * we don't care about but we have allocated enough room for
-         * that
-         */
-        outCount = snprintf(strOut, strOutLen + 1, "%" PRId64, elem.data.int64);
-        if (outCount <= strOutLen) {
-          strOut += outCount;
-          strOutLen -= outCount;
-        } else {
-          overflow = true;
-        }
-        break;
-
-      case EVENT_TYPE_FLOAT:
-        /*
-         * snprintf also requires room for the null terminator, which
-         * we don't care about but we have allocated enough room for
-         * that
-         */
-        outCount = snprintf(strOut, strOutLen + 1, "%f", elem.data.float32);
-        if (outCount <= strOutLen) {
-          strOut += outCount;
-          strOutLen -= outCount;
-        } else {
-          overflow = true;
-        }
-        break;
-
-      default:
-        elem.complete = true;
-        break;
-
-      case EVENT_TYPE_UNKNOWN:
-#if 0  // Ideal purity in the test, we want to complain about UNKNOWN showing up
-            if (elem.complete) {
-                break;
-            }
-#endif
-        elem.data.string = const_cast<char*>("<unknown>");
-        elem.len = strlen(elem.data.string);
-        FALLTHROUGH_INTENDED;
-      case EVENT_TYPE_STRING:
-        if (elem.len <= strOutLen) {
-          memcpy(strOut, elem.data.string, elem.len);
-          strOut += elem.len;
-          strOutLen -= elem.len;
-        } else if (strOutLen > 0) {
-          /* copy what we can */
-          memcpy(strOut, elem.data.string, strOutLen);
-          strOut += strOutLen;
-          strOutLen = 0;
-          overflow = true;
-        }
-        break;
-    }
-
-    if (elem.complete) {
-      break;
-    }
-    /* Determine whether to put a comma or not. */
-    if (!overflow &&
-        (is_real_element(elem.type) || (elem.type == EVENT_TYPE_LIST_STOP))) {
-      android_log_list_element next = android_log_peek_next(context);
-      if (!next.complete &&
-          (is_real_element(next.type) || (next.type == EVENT_TYPE_LIST))) {
-        if (strOutLen == 0) {
-          overflow = true;
-        } else {
-          *strOut++ = ',';
-          strOutLen--;
-        }
-      }
-    }
-  } while ((elem.type != EVENT_TYPE_UNKNOWN) && !overflow && !elem.complete);
-
-  android_log_destroy(&context);
-
-  if (overflow) {
-    if (strOutLen < origStrOutLen) {
-      /* leave an indicator */
-      *(strOut - 1) = '!';
-    } else {
-      /* nothing was written at all */
-      *strOut++ = '!';
-    }
-  }
-  *strOut++ = '\0';
-
-  if ((elem.type == EVENT_TYPE_UNKNOWN) && !elem.complete) {
-    fprintf(stderr, "Binary log entry conversion failed\n");
-    return -EINVAL;
-  }
-
-  return 0;
-}
-#endif  // __ANDROID__
-
-#ifdef __ANDROID__
-static const char* event_test_int32(uint32_t tag, size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-  EXPECT_LE(0, android_log_write_int32(ctx, 0x40302010));
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t);
-
-  return "1076895760";
-}
-
-static const char* event_test_int64(uint32_t tag, size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-  EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint64_t);
-
-  return "-9191740941672636400";
-}
-
-static const char* event_test_list_int64(uint32_t tag, size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
-                 sizeof(uint8_t) + sizeof(uint64_t);
-
-  return "[-9191740941672636400]";
-}
-
-static const char* event_test_simple_automagic_list(uint32_t tag,
-                                                    size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-  // The convenience API where we allow a simple list to be
-  // created without explicit begin or end calls.
-  EXPECT_LE(0, android_log_write_int32(ctx, 0x40302010));
-  EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
-                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t) +
-                 sizeof(uint64_t);
-
-  return "[1076895760,-9191740941672636400]";
-}
-
-static const char* event_test_list_empty(uint32_t tag, size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t);
-
-  return "[]";
-}
-
-static const char* event_test_complex_nested_list(uint32_t tag,
-                                                  size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-
-  EXPECT_LE(0, android_log_write_list_begin(ctx));  // [
-  EXPECT_LE(0, android_log_write_int32(ctx, 0x01020304));
-  EXPECT_LE(0, android_log_write_int64(ctx, 0x0102030405060708));
-  EXPECT_LE(0, android_log_write_string8(ctx, "Hello World"));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));  // [
-  EXPECT_LE(0, android_log_write_int32(ctx, 1));
-  EXPECT_LE(0, android_log_write_int32(ctx, 2));
-  EXPECT_LE(0, android_log_write_int32(ctx, 3));
-  EXPECT_LE(0, android_log_write_int32(ctx, 4));
-  EXPECT_LE(0, android_log_write_list_end(ctx));  // ]
-  EXPECT_LE(0, android_log_write_float32(ctx, 1.0102030405060708));
-  EXPECT_LE(0, android_log_write_list_end(ctx));  // ]
-
-  //
-  // This one checks for the automagic list creation because a list
-  // begin and end was missing for it! This is actually an <oops> corner
-  // case, and not the behavior we morally support. The automagic API is to
-  // allow for a simple case of a series of objects in a single list. e.g.
-  //   int32,int32,int32,string -> [int32,int32,int32,string]
-  //
-  EXPECT_LE(0, android_log_write_string8(ctx, "dlroW olleH"));
-
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
-                 sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t) +
-                 sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint64_t) +
-                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") -
-                 1 + sizeof(uint8_t) + sizeof(uint8_t) +
-                 4 * (sizeof(uint8_t) + sizeof(uint32_t)) + sizeof(uint8_t) +
-                 sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t) +
-                 sizeof("dlroW olleH") - 1;
-
-  return "[[16909060,72623859790382856,Hello World,[1,2,3,4],1.010203],dlroW "
-         "olleH]";
-}
-
-static const char* event_test_7_level_prefix(uint32_t tag,
-                                             size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 1));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 2));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 3));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 4));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 5));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 6));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 7));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + 7 * (sizeof(uint8_t) + sizeof(uint8_t) +
-                                         sizeof(uint8_t) + sizeof(uint32_t));
-
-  return "[[[[[[[1],2],3],4],5],6],7]";
-}
-
-static const char* event_test_7_level_suffix(uint32_t tag,
-                                             size_t& expected_len) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-  if (!ctx) {
-    return NULL;
-  }
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 1));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 2));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 3));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 4));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 5));
-  EXPECT_LE(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_write_int32(ctx, 6));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list_end(ctx));
-  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  EXPECT_TRUE(NULL == ctx);
-
-  expected_len = sizeof(uint32_t) + 6 * (sizeof(uint8_t) + sizeof(uint8_t) +
-                                         sizeof(uint8_t) + sizeof(uint32_t));
-
-  return "[1,[2,[3,[4,[5,[6]]]]]]";
-}
-
-static const char* event_test_android_log_error_write(uint32_t tag,
-                                                      size_t& expected_len) {
-  EXPECT_LE(
-      0, __android_log_error_write(tag, "Hello World", 42, "dlroW olleH", 11));
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
-                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") -
-                 1 + sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t) +
-                 sizeof(uint32_t) + sizeof("dlroW olleH") - 1;
-
-  return "[Hello World,42,dlroW olleH]";
-}
-
-static const char* event_test_android_log_error_write_null(uint32_t tag,
-                                                           size_t& expected_len) {
-  EXPECT_LE(0, __android_log_error_write(tag, "Hello World", 42, NULL, 0));
-
-  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
-                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") -
-                 1 + sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t) +
-                 sizeof(uint32_t) + sizeof("") - 1;
-
-  return "[Hello World,42,]";
-}
-
-// make sure all user buffers are flushed
-static void print_barrier() {
-  std::cout.flush();
-  fflush(stdout);
-  std::cerr.flush();
-  fflush(stderr);  // everything else is paranoia ...
-}
-
-static void create_android_logger(const char* (*fn)(uint32_t tag,
-                                                    size_t& expected_len)) {
-  size_t expected_len;
-  const char* expected_string;
-  auto write_function = [&] {
-    expected_string = (*fn)(1005, expected_len);
-    ASSERT_NE(nullptr, expected_string);
-  };
-
-  pid_t pid = getpid();
-  auto check_function = [&](log_msg log_msg, bool* found) {
-    if (static_cast<size_t>(log_msg.entry.len) != expected_len) {
-      return;
-    }
-
-    char* eventData = log_msg.msg();
-
-    AndroidLogFormat* logformat = android_log_format_new();
-    EXPECT_TRUE(NULL != logformat);
-    AndroidLogEntry entry;
-    char msgBuf[1024];
-    int processBinaryLogBuffer =
-        android_log_processBinaryLogBuffer(&log_msg.entry, &entry, nullptr, msgBuf, sizeof(msgBuf));
-    EXPECT_EQ(0, processBinaryLogBuffer);
-    if (processBinaryLogBuffer == 0) {
-      int line_overhead = 20;
-      if (pid > 99999) ++line_overhead;
-      if (pid > 999999) ++line_overhead;
-      print_barrier();
-      int printLogLine =
-          android_log_printLogLine(logformat, fileno(stderr), &entry);
-      print_barrier();
-      EXPECT_EQ(line_overhead + (int)strlen(expected_string), printLogLine);
-    }
-    android_log_format_free(logformat);
-
-    // test buffer reading API
-    int buffer_to_string = -1;
-    if (eventData) {
-      auto* event_header = reinterpret_cast<android_event_header_t*>(eventData);
-      eventData += sizeof(android_event_header_t);
-      snprintf(msgBuf, sizeof(msgBuf), "I/[%" PRId32 "]", event_header->tag);
-      print_barrier();
-      fprintf(stderr, "%-10s(%5u): ", msgBuf, pid);
-      memset(msgBuf, 0, sizeof(msgBuf));
-      buffer_to_string =
-          android_log_buffer_to_string(eventData, log_msg.entry.len, msgBuf, sizeof(msgBuf));
-      fprintf(stderr, "%s\n", msgBuf);
-      print_barrier();
-    }
-    EXPECT_EQ(0, buffer_to_string);
-    EXPECT_STREQ(expected_string, msgBuf);
-    *found = true;
-  };
-
-  RunLogTests(LOG_ID_EVENTS, write_function, check_function);
-}
-#endif
-
-TEST(liblog, create_android_logger_int32) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_int32);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_int64) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_int64);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_list_int64) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_list_int64);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_simple_automagic_list) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_simple_automagic_list);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_list_empty) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_list_empty);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_complex_nested_list) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_complex_nested_list);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_7_level_prefix) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_7_level_prefix);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_7_level_suffix) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_7_level_suffix);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_android_log_error_write) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_android_log_error_write);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_android_log_error_write_null) {
-#ifdef __ANDROID__
-  create_android_logger(event_test_android_log_error_write_null);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(liblog, create_android_logger_overflow) {
-  android_log_context ctx;
-
-  EXPECT_TRUE(NULL != (ctx = create_android_logger(1005)));
-  if (ctx) {
-    for (size_t i = 0; i < ANDROID_MAX_LIST_NEST_DEPTH; ++i) {
-      EXPECT_LE(0, android_log_write_list_begin(ctx));
-    }
-    EXPECT_GT(0, android_log_write_list_begin(ctx));
-    /* One more for good measure, must be permanently unhappy */
-    EXPECT_GT(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
-  }
-
-  ASSERT_TRUE(NULL != (ctx = create_android_logger(1005)));
-  for (size_t i = 0; i < ANDROID_MAX_LIST_NEST_DEPTH; ++i) {
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, i));
-  }
-  EXPECT_GT(0, android_log_write_list_begin(ctx));
-  /* One more for good measure, must be permanently unhappy */
-  EXPECT_GT(0, android_log_write_list_begin(ctx));
-  EXPECT_LE(0, android_log_destroy(&ctx));
-  ASSERT_TRUE(NULL == ctx);
-}
-
-#ifdef ENABLE_FLAKY_TESTS
-#ifdef __ANDROID__
-#ifndef NO_PSTORE
-static const char __pmsg_file[] =
-    "/data/william-shakespeare/MuchAdoAboutNothing.txt";
-#endif /* NO_PSTORE */
-#endif
-
-TEST(liblog, __android_log_pmsg_file_write) {
-#ifdef __ANDROID__
-#ifndef NO_PSTORE
-  __android_log_close();
-  if (getuid() == AID_ROOT) {
-    tested__android_log_close = true;
-    bool pmsgActiveAfter__android_log_close = isPmsgActive();
-    bool logdwActiveAfter__android_log_close = isLogdwActive();
-    EXPECT_FALSE(pmsgActiveAfter__android_log_close);
-    EXPECT_FALSE(logdwActiveAfter__android_log_close);
-  } else if (!tested__android_log_close) {
-    fprintf(stderr, "WARNING: can not test __android_log_close()\n");
-  }
-  int return__android_log_pmsg_file_write = __android_log_pmsg_file_write(
-      LOG_ID_CRASH, ANDROID_LOG_VERBOSE, __pmsg_file, max_payload_buf,
-      sizeof(max_payload_buf));
-  EXPECT_LT(0, return__android_log_pmsg_file_write);
-  if (return__android_log_pmsg_file_write == -ENOMEM) {
-    fprintf(stderr,
-            "Kernel does not have space allocated to pmsg pstore driver "
-            "configured\n");
-  } else if (!return__android_log_pmsg_file_write) {
-    fprintf(stderr,
-            "Reboot, ensure file %s matches\n"
-            "with liblog.__android_log_msg_file_read test\n",
-            __pmsg_file);
-  }
-  bool pmsgActiveAfter__android_pmsg_file_write;
-  bool logdwActiveAfter__android_pmsg_file_write;
-  if (getuid() == AID_ROOT) {
-    pmsgActiveAfter__android_pmsg_file_write = isPmsgActive();
-    logdwActiveAfter__android_pmsg_file_write = isLogdwActive();
-    EXPECT_FALSE(pmsgActiveAfter__android_pmsg_file_write);
-    EXPECT_FALSE(logdwActiveAfter__android_pmsg_file_write);
-  }
-  EXPECT_LT(
-      0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                 "TEST__android_log_pmsg_file_write", "main"));
-  if (getuid() == AID_ROOT) {
-    bool pmsgActiveAfter__android_log_buf_print = isPmsgActive();
-    bool logdwActiveAfter__android_log_buf_print = isLogdwActive();
-    EXPECT_TRUE(pmsgActiveAfter__android_log_buf_print);
-    EXPECT_TRUE(logdwActiveAfter__android_log_buf_print);
-  }
-  EXPECT_LT(0, __android_log_pmsg_file_write(LOG_ID_CRASH, ANDROID_LOG_VERBOSE,
-                                             __pmsg_file, max_payload_buf,
-                                             sizeof(max_payload_buf)));
-  if (getuid() == AID_ROOT) {
-    pmsgActiveAfter__android_pmsg_file_write = isPmsgActive();
-    logdwActiveAfter__android_pmsg_file_write = isLogdwActive();
-    EXPECT_TRUE(pmsgActiveAfter__android_pmsg_file_write);
-    EXPECT_TRUE(logdwActiveAfter__android_pmsg_file_write);
-  }
-#else  /* NO_PSTORE */
-  GTEST_LOG_(INFO) << "This test does nothing because of NO_PSTORE.\n";
-#endif /* NO_PSTORE */
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-#ifdef __ANDROID__
-#ifndef NO_PSTORE
-static ssize_t __pmsg_fn(log_id_t logId, char prio, const char* filename,
-                         const char* buf, size_t len, void* arg) {
-  EXPECT_TRUE(NULL == arg);
-  EXPECT_EQ(LOG_ID_CRASH, logId);
-  EXPECT_EQ(ANDROID_LOG_VERBOSE, prio);
-  EXPECT_FALSE(NULL == strstr(__pmsg_file, filename));
-  EXPECT_EQ(len, sizeof(max_payload_buf));
-  EXPECT_STREQ(max_payload_buf, buf);
-
-  ++signaled;
-  if ((len != sizeof(max_payload_buf)) || strcmp(max_payload_buf, buf)) {
-    fprintf(stderr, "comparison fails on content \"%s\"\n", buf);
-  }
-  return arg || (LOG_ID_CRASH != logId) || (ANDROID_LOG_VERBOSE != prio) ||
-                 !strstr(__pmsg_file, filename) ||
-                 (len != sizeof(max_payload_buf)) ||
-                 !!strcmp(max_payload_buf, buf)
-             ? -ENOEXEC
-             : 1;
-}
-#endif /* NO_PSTORE */
-#endif
-
-TEST(liblog, __android_log_pmsg_file_read) {
-#ifdef __ANDROID__
-#ifndef NO_PSTORE
-  signaled = 0;
-
-  __android_log_close();
-  if (getuid() == AID_ROOT) {
-    tested__android_log_close = true;
-    bool pmsgActiveAfter__android_log_close = isPmsgActive();
-    bool logdwActiveAfter__android_log_close = isLogdwActive();
-    EXPECT_FALSE(pmsgActiveAfter__android_log_close);
-    EXPECT_FALSE(logdwActiveAfter__android_log_close);
-  } else if (!tested__android_log_close) {
-    fprintf(stderr, "WARNING: can not test __android_log_close()\n");
-  }
-
-  ssize_t ret = __android_log_pmsg_file_read(LOG_ID_CRASH, ANDROID_LOG_VERBOSE,
-                                             __pmsg_file, __pmsg_fn, NULL);
-
-  if (getuid() == AID_ROOT) {
-    bool pmsgActiveAfter__android_log_pmsg_file_read = isPmsgActive();
-    bool logdwActiveAfter__android_log_pmsg_file_read = isLogdwActive();
-    EXPECT_FALSE(pmsgActiveAfter__android_log_pmsg_file_read);
-    EXPECT_FALSE(logdwActiveAfter__android_log_pmsg_file_read);
-  }
-
-  if (ret == -ENOENT) {
-    fprintf(stderr,
-            "No pre-boot results of liblog.__android_log_mesg_file_write to "
-            "compare with,\n"
-            "false positive test result.\n");
-    return;
-  }
-
-  EXPECT_LT(0, ret);
-  EXPECT_EQ(1U, signaled);
-#else  /* NO_PSTORE */
-  GTEST_LOG_(INFO) << "This test does nothing because of NO_PSTORE.\n";
-#endif /* NO_PSTORE */
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif  // ENABLE_FLAKY_TESTS
-
-TEST(liblog, android_lookupEventTagNum) {
-#ifdef __ANDROID__
-  EventTagMap* map = android_openEventTagMap(NULL);
-  EXPECT_TRUE(NULL != map);
-  std::string Name = android::base::StringPrintf("a%d", getpid());
-  int tag = android_lookupEventTagNum(map, Name.c_str(), "(new|1)",
-                                      ANDROID_LOG_UNKNOWN);
-  android_closeEventTagMap(map);
-  if (tag == -1) system("tail -3 /dev/event-log-tags >&2");
-  EXPECT_NE(-1, tag);
-  EXPECT_NE(0, tag);
-  EXPECT_GT(UINT32_MAX, (unsigned)tag);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
diff --git a/liblog/tests/log_id_test.cpp b/liblog/tests/log_id_test.cpp
deleted file mode 100644
index 9fb5a2c..0000000
--- a/liblog/tests/log_id_test.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2013-2017 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 <inttypes.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <gtest/gtest.h>
-// Test the APIs in this standalone include file
-#include <log/log_id.h>
-
-// We do not want to include <android/log.h> to acquire ANDROID_LOG_INFO for
-// include file API purity.  We do however want to allow the _option_ that
-// log/log_id.h could include this file, or related content, in the future.
-#ifndef __android_LogPriority_defined
-#define ANDROID_LOG_INFO 4
-#endif
-
-TEST(liblog, log_id) {
-  int count = 0;
-
-  for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
-    log_id_t id = static_cast<log_id_t>(i);
-    const char* name = android_log_id_to_name(id);
-    if (id != android_name_to_log_id(name)) {
-      continue;
-    }
-    ++count;
-    fprintf(stderr, "log buffer %s\r", name);
-  }
-  ASSERT_EQ(LOG_ID_MAX, count);
-}
-
-TEST(liblog, __android_log_buf_print) {
-  EXPECT_LT(0, __android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO,
-                                       "TEST__android_log_buf_print", "radio"));
-  usleep(1000);
-  EXPECT_LT(0,
-            __android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
-                                    "TEST__android_log_buf_print", "system"));
-  usleep(1000);
-  EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                       "TEST__android_log_buf_print", "main"));
-  usleep(1000);
-}
-
-TEST(liblog, __android_log_buf_write) {
-  EXPECT_LT(0, __android_log_buf_write(LOG_ID_RADIO, ANDROID_LOG_INFO,
-                                       "TEST__android_log_buf_write", "radio"));
-  usleep(1000);
-  EXPECT_LT(0,
-            __android_log_buf_write(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
-                                    "TEST__android_log_buf_write", "system"));
-  usleep(1000);
-  EXPECT_LT(0, __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                       "TEST__android_log_buf_write", "main"));
-  usleep(1000);
-}
-
-static void* ConcurrentPrintFn(void* arg) {
-  int ret = __android_log_buf_print(
-      LOG_ID_MAIN, ANDROID_LOG_INFO, "TEST__android_log_print",
-      "Concurrent %" PRIuPTR, reinterpret_cast<uintptr_t>(arg));
-  return reinterpret_cast<void*>(ret);
-}
-
-#define NUM_CONCURRENT 64
-#define _concurrent_name(a, n) a##__concurrent##n
-#define concurrent_name(a, n) _concurrent_name(a, n)
-
-TEST(liblog, concurrent_name(__android_log_buf_print, NUM_CONCURRENT)) {
-  pthread_t t[NUM_CONCURRENT];
-  int i;
-  for (i = 0; i < NUM_CONCURRENT; i++) {
-    ASSERT_EQ(0, pthread_create(&t[i], NULL, ConcurrentPrintFn,
-                                reinterpret_cast<void*>(i)));
-  }
-  int ret = 1;
-  for (i = 0; i < NUM_CONCURRENT; i++) {
-    void* result;
-    ASSERT_EQ(0, pthread_join(t[i], &result));
-    int this_result = reinterpret_cast<uintptr_t>(result);
-    if ((0 < ret) && (ret != this_result)) {
-      ret = this_result;
-    }
-  }
-  ASSERT_LT(0, ret);
-}
diff --git a/liblog/tests/log_radio_test.cpp b/liblog/tests/log_radio_test.cpp
deleted file mode 100644
index fa1255e..0000000
--- a/liblog/tests/log_radio_test.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2017 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 <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <string>
-
-#include <android-base/file.h>
-#include <android-base/stringprintf.h>
-#include <gtest/gtest.h>
-// Test the APIs in this standalone include file
-#include <log/log_radio.h>
-
-TEST(liblog, RLOG) {
-  static const char content[] = "log_radio.h";
-  static const char content_false[] = "log_radio.h false";
-
-// ratelimit content to 10/s to keep away from spam filters
-// do not send identical content together to keep away from spam filters
-
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGV"
-  RLOGV(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGD"
-  RLOGD(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGI"
-  RLOGI(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGW"
-  RLOGW(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGE"
-  RLOGE(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGV"
-  RLOGV_IF(true, content);
-  usleep(100000);
-  RLOGV_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGD"
-  RLOGD_IF(true, content);
-  usleep(100000);
-  RLOGD_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGI"
-  RLOGI_IF(true, content);
-  usleep(100000);
-  RLOGI_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGW"
-  RLOGW_IF(true, content);
-  usleep(100000);
-  RLOGW_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__RLOGE"
-  RLOGE_IF(true, content);
-  usleep(100000);
-  RLOGE_IF(false, content_false);
-
-#ifdef __ANDROID__
-  // give time for content to long-path through logger
-  sleep(1);
-
-  std::string buf = android::base::StringPrintf(
-      "logcat -b radio --pid=%u -d -s"
-      " TEST__RLOGV TEST__RLOGD TEST__RLOGI TEST__RLOGW TEST__RLOGE",
-      (unsigned)getpid());
-  FILE* fp = popen(buf.c_str(), "re");
-  int count = 0;
-  int count_false = 0;
-  if (fp) {
-    if (!android::base::ReadFdToString(fileno(fp), &buf)) buf = "";
-    pclose(fp);
-    for (size_t pos = 0; (pos = buf.find(content, pos)) != std::string::npos;
-         ++pos) {
-      ++count;
-    }
-    for (size_t pos = 0;
-         (pos = buf.find(content_false, pos)) != std::string::npos; ++pos) {
-      ++count_false;
-    }
-  }
-  EXPECT_EQ(0, count_false);
-#if LOG_NDEBUG
-  ASSERT_EQ(8, count);
-#else
-  ASSERT_EQ(10, count);
-#endif
-
-#else
-  GTEST_LOG_(INFO) << "This test does not test end-to-end.\n";
-#endif
-}
diff --git a/liblog/tests/log_read_test.cpp b/liblog/tests/log_read_test.cpp
deleted file mode 100644
index 7acd363..0000000
--- a/liblog/tests/log_read_test.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2013-2017 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/types.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <string>
-
-#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
-#include <android/log.h>  // minimal logging API
-#include <gtest/gtest.h>
-#include <log/log_properties.h>
-// Test the APIs in this standalone include file
-#include <log/log_read.h>
-// Do not use anything in log/log_time.h despite side effects of the above.
-#include <private/android_logger.h>
-
-using android::base::GetBoolProperty;
-
-TEST(liblog, android_logger_get_) {
-#ifdef __ANDROID__
-  // This test assumes the log buffers are filled with noise from
-  // normal operations. It will fail if done immediately after a
-  // logcat -c.
-  struct logger_list* logger_list = android_logger_list_alloc(0, 0, 0);
-
-  for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
-    log_id_t id = static_cast<log_id_t>(i);
-    std::string name = android_log_id_to_name(id);
-    fprintf(stderr, "log buffer %s\r", name.c_str());
-    struct logger* logger;
-    EXPECT_TRUE(NULL != (logger = android_logger_open(logger_list, id)));
-    EXPECT_EQ(id, android_logger_get_id(logger));
-    ssize_t get_log_size = android_logger_get_log_size(logger);
-    /* security buffer is allowed to be denied */
-    if (name != "security") {
-      EXPECT_GT(get_log_size, 0);
-      // crash buffer is allowed to be empty, that is actually healthy!
-      // stats buffer is no longer in use.
-      if (name == "crash" || name == "stats") {
-        continue;
-      }
-
-      // kernel buffer is empty if ro.logd.kernel is false
-      if (name == "kernel" && !GetBoolProperty("ro.logd.kernel", false)) {
-        continue;
-      }
-
-      EXPECT_LE(0, android_logger_get_log_readable_size(logger));
-    } else {
-      EXPECT_NE(0, get_log_size);
-      if (get_log_size < 0) {
-        EXPECT_GT(0, android_logger_get_log_readable_size(logger));
-      } else {
-        EXPECT_LE(0, android_logger_get_log_readable_size(logger));
-      }
-    }
-  }
-
-  android_logger_list_close(logger_list);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
diff --git a/liblog/tests/log_system_test.cpp b/liblog/tests/log_system_test.cpp
deleted file mode 100644
index 13f026d..0000000
--- a/liblog/tests/log_system_test.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2017 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 <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <string>
-
-#include <android-base/file.h>
-#include <android-base/stringprintf.h>
-#include <gtest/gtest.h>
-// Test the APIs in this standalone include file
-#include <log/log_system.h>
-
-TEST(liblog, SLOG) {
-  static const char content[] = "log_system.h";
-  static const char content_false[] = "log_system.h false";
-
-// ratelimit content to 10/s to keep away from spam filters
-// do not send identical content together to keep away from spam filters
-
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGV"
-  SLOGV(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGD"
-  SLOGD(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGI"
-  SLOGI(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGW"
-  SLOGW(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGE"
-  SLOGE(content);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGV"
-  SLOGV_IF(true, content);
-  usleep(100000);
-  SLOGV_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGD"
-  SLOGD_IF(true, content);
-  usleep(100000);
-  SLOGD_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGI"
-  SLOGI_IF(true, content);
-  usleep(100000);
-  SLOGI_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGW"
-  SLOGW_IF(true, content);
-  usleep(100000);
-  SLOGW_IF(false, content_false);
-  usleep(100000);
-#undef LOG_TAG
-#define LOG_TAG "TEST__SLOGE"
-  SLOGE_IF(true, content);
-  usleep(100000);
-  SLOGE_IF(false, content_false);
-
-#ifdef __ANDROID__
-  // give time for content to long-path through logger
-  sleep(1);
-
-  std::string buf = android::base::StringPrintf(
-      "logcat -b system --pid=%u -d -s"
-      " TEST__SLOGV TEST__SLOGD TEST__SLOGI TEST__SLOGW TEST__SLOGE",
-      (unsigned)getpid());
-  FILE* fp = popen(buf.c_str(), "re");
-  int count = 0;
-  int count_false = 0;
-  if (fp) {
-    if (!android::base::ReadFdToString(fileno(fp), &buf)) buf = "";
-    pclose(fp);
-    for (size_t pos = 0; (pos = buf.find(content, pos)) != std::string::npos;
-         ++pos) {
-      ++count;
-    }
-    for (size_t pos = 0;
-         (pos = buf.find(content_false, pos)) != std::string::npos; ++pos) {
-      ++count_false;
-    }
-  }
-  EXPECT_EQ(0, count_false);
-#if LOG_NDEBUG
-  ASSERT_EQ(8, count);
-#else
-  ASSERT_EQ(10, count);
-#endif
-
-#else
-  GTEST_LOG_(INFO) << "This test does not test end-to-end.\n";
-#endif
-}
diff --git a/liblog/tests/log_time_test.cpp b/liblog/tests/log_time_test.cpp
deleted file mode 100644
index 47fe594..0000000
--- a/liblog/tests/log_time_test.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2017 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 <time.h>
-
-#include <gtest/gtest.h>
-// Test the APIs in this standalone include file
-#include <log/log_time.h>
-
-TEST(liblog, log_time) {
-  struct timespec ts;
-  clock_gettime(CLOCK_MONOTONIC, &ts);
-  log_time tl(ts);
-
-  EXPECT_EQ(tl, ts);
-  EXPECT_GE(tl, ts);
-  EXPECT_LE(tl, ts);
-}
diff --git a/liblog/tests/log_wrap_test.cpp b/liblog/tests/log_wrap_test.cpp
deleted file mode 100644
index 755898a..0000000
--- a/liblog/tests/log_wrap_test.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2013-2017 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/types.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <string>
-
-#include <android-base/chrono_utils.h>
-#include <android-base/stringprintf.h>
-#include <android/log.h>  // minimal logging API
-#include <gtest/gtest.h>
-#include <log/log_properties.h>
-#include <log/log_read.h>
-#include <log/log_time.h>
-
-#ifdef __ANDROID__
-static void read_with_wrap() {
-  // Read the last line in the log to get a starting timestamp. We're assuming
-  // the log is not empty.
-  const int mode = ANDROID_LOG_NONBLOCK;
-  struct logger_list* logger_list =
-      android_logger_list_open(LOG_ID_MAIN, mode, 1000, 0);
-
-  ASSERT_NE(logger_list, nullptr);
-
-  log_msg log_msg;
-  int ret = android_logger_list_read(logger_list, &log_msg);
-  android_logger_list_close(logger_list);
-  ASSERT_GT(ret, 0);
-
-  log_time start(log_msg.entry.sec, log_msg.entry.nsec);
-  ASSERT_NE(start, log_time());
-
-  logger_list =
-      android_logger_list_alloc_time(mode | ANDROID_LOG_WRAP, start, 0);
-  ASSERT_NE(logger_list, nullptr);
-
-  struct logger* logger = android_logger_open(logger_list, LOG_ID_MAIN);
-  EXPECT_NE(logger, nullptr);
-  if (logger) {
-    android_logger_list_read(logger_list, &log_msg);
-  }
-
-  android_logger_list_close(logger_list);
-}
-#endif
-
-// b/64143705 confirm fixed
-TEST(liblog, wrap_mode_blocks) {
-#ifdef __ANDROID__
-  // The read call is expected to take up to 2 hours in the happy case.  There was a previous bug
-  // where it would take only 30 seconds due to an alarm() in logd_reader.cpp.  That alarm has been
-  // removed, so we check here that the read call blocks for a reasonable amount of time (5s).
-
-  struct sigaction ignore = {.sa_handler = [](int) { _exit(0); }};
-  struct sigaction old_sigaction;
-  sigaction(SIGALRM, &ignore, &old_sigaction);
-  alarm(5);
-
-  android::base::Timer timer;
-  read_with_wrap();
-
-  FAIL() << "read_with_wrap() should not return before the alarm is triggered.";
-
-  alarm(0);
-  sigaction(SIGALRM, &old_sigaction, nullptr);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
diff --git a/liblog/tests/logd_writer_test.cpp b/liblog/tests/logd_writer_test.cpp
deleted file mode 100644
index b8e4726..0000000
--- a/liblog/tests/logd_writer_test.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2020 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/un.h>
-#include <unistd.h>
-
-#include <android-base/file.h>
-#include <android-base/stringprintf.h>
-#include <android-base/unique_fd.h>
-#include <gtest/gtest.h>
-
-using android::base::StringPrintf;
-using android::base::unique_fd;
-
-// logd_writer takes advantage of the fact that connect() can be called multiple times for a DGRAM
-// socket.  This tests for that behavior.
-TEST(liblog, multi_connect_dgram_socket) {
-#ifdef __ANDROID__
-  if (getuid() != 0) {
-    GTEST_SKIP() << "Skipping test, must be run as root.";
-    return;
-  }
-  auto temp_dir = TemporaryDir();
-  auto socket_path = StringPrintf("%s/test_socket", temp_dir.path);
-
-  unique_fd server_socket;
-
-  auto open_server_socket = [&] {
-    server_socket.reset(TEMP_FAILURE_RETRY(socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)));
-    ASSERT_TRUE(server_socket.ok());
-
-    sockaddr_un server_sockaddr = {};
-    server_sockaddr.sun_family = AF_UNIX;
-    strlcpy(server_sockaddr.sun_path, socket_path.c_str(), sizeof(server_sockaddr.sun_path));
-    ASSERT_EQ(0,
-              TEMP_FAILURE_RETRY(bind(server_socket, reinterpret_cast<sockaddr*>(&server_sockaddr),
-                                      sizeof(server_sockaddr))));
-  };
-
-  // Open the server socket.
-  open_server_socket();
-
-  // Open the client socket.
-  auto client_socket =
-      unique_fd{TEMP_FAILURE_RETRY(socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0))};
-  ASSERT_TRUE(client_socket.ok());
-  sockaddr_un client_sockaddr = {};
-  client_sockaddr.sun_family = AF_UNIX;
-  strlcpy(client_sockaddr.sun_path, socket_path.c_str(), sizeof(client_sockaddr.sun_path));
-  ASSERT_EQ(0,
-            TEMP_FAILURE_RETRY(connect(client_socket, reinterpret_cast<sockaddr*>(&client_sockaddr),
-                                       sizeof(client_sockaddr))));
-
-  // Ensure that communication works.
-  constexpr static char kSmoke[] = "smoke test";
-  ssize_t smoke_len = sizeof(kSmoke);
-  ASSERT_EQ(smoke_len, TEMP_FAILURE_RETRY(write(client_socket, kSmoke, sizeof(kSmoke))));
-  char read_buf[512];
-  ASSERT_EQ(smoke_len, TEMP_FAILURE_RETRY(read(server_socket, read_buf, sizeof(read_buf))));
-  ASSERT_STREQ(kSmoke, read_buf);
-
-  // Close the server socket.
-  server_socket.reset();
-  ASSERT_EQ(0, unlink(socket_path.c_str())) << strerror(errno);
-
-  // Ensure that write() from the client returns an error since the server is closed.
-  ASSERT_EQ(-1, TEMP_FAILURE_RETRY(write(client_socket, kSmoke, sizeof(kSmoke))));
-  ASSERT_EQ(errno, ECONNREFUSED) << strerror(errno);
-
-  // Open the server socket again.
-  open_server_socket();
-
-  // Reconnect the same client socket.
-  ASSERT_EQ(0,
-            TEMP_FAILURE_RETRY(connect(client_socket, reinterpret_cast<sockaddr*>(&client_sockaddr),
-                                       sizeof(client_sockaddr))))
-      << strerror(errno);
-
-  // Ensure that communication works.
-  ASSERT_EQ(smoke_len, TEMP_FAILURE_RETRY(write(client_socket, kSmoke, sizeof(kSmoke))));
-  ASSERT_EQ(smoke_len, TEMP_FAILURE_RETRY(read(server_socket, read_buf, sizeof(read_buf))));
-  ASSERT_STREQ(kSmoke, read_buf);
-#else
-  GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
\ No newline at end of file
diff --git a/liblog/tests/logprint_test.cpp b/liblog/tests/logprint_test.cpp
deleted file mode 100644
index 72e53f9..0000000
--- a/liblog/tests/logprint_test.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2019 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 <log/logprint.h>
-
-#include <string>
-
-#include <gtest/gtest.h>
-
-#include <log/log_read.h>
-
-size_t convertPrintable(char* p, const char* message, size_t messageLen);
-
-TEST(liblog, convertPrintable_ascii) {
-  auto input = "easy string, output same";
-  auto output_size = convertPrintable(nullptr, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(input));
-
-  char output[output_size];
-
-  output_size = convertPrintable(output, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(input));
-  EXPECT_STREQ(input, output);
-}
-
-TEST(liblog, convertPrintable_escapes) {
-  // Note that \t is not escaped.
-  auto input = "escape\a\b\t\v\f\r\\";
-  auto expected_output = "escape\\a\\b\t\\v\\f\\r\\\\";
-  auto output_size = convertPrintable(nullptr, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(expected_output));
-
-  char output[output_size];
-
-  output_size = convertPrintable(output, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(expected_output));
-  EXPECT_STREQ(expected_output, output);
-}
-
-TEST(liblog, convertPrintable_validutf8) {
-  auto input = u8"¢ह€𐍈";
-  auto output_size = convertPrintable(nullptr, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(input));
-
-  char output[output_size];
-
-  output_size = convertPrintable(output, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(input));
-  EXPECT_STREQ(input, output);
-}
-
-TEST(liblog, convertPrintable_invalidutf8) {
-  auto input = "\x80\xC2\x01\xE0\xA4\x06\xE0\x06\xF0\x90\x8D\x06\xF0\x90\x06\xF0\x0E";
-  auto expected_output =
-      "\\x80\\xC2\\x01\\xE0\\xA4\\x06\\xE0\\x06\\xF0\\x90\\x8D\\x06\\xF0\\x90\\x06\\xF0\\x0E";
-  auto output_size = convertPrintable(nullptr, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(expected_output));
-
-  char output[output_size];
-
-  output_size = convertPrintable(output, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(expected_output));
-  EXPECT_STREQ(expected_output, output);
-}
-
-TEST(liblog, convertPrintable_mixed) {
-  auto input =
-      u8"\x80\xC2¢ह€𐍈\x01\xE0\xA4\x06¢ह€𐍈\xE0\x06\a\b\xF0\x90¢ह€𐍈\x8D\x06\xF0\t\t\x90\x06\xF0\x0E";
-  auto expected_output =
-      u8"\\x80\\xC2¢ह€𐍈\\x01\\xE0\\xA4\\x06¢ह€𐍈\\xE0\\x06\\a\\b\\xF0\\x90¢ह€𐍈\\x8D\\x06\\xF0\t\t"
-      u8"\\x90\\x06\\xF0\\x0E";
-  auto output_size = convertPrintable(nullptr, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(expected_output));
-
-  char output[output_size];
-
-  output_size = convertPrintable(output, input, strlen(input));
-  EXPECT_EQ(output_size, strlen(expected_output));
-  EXPECT_STREQ(expected_output, output);
-}
-
-TEST(liblog, log_print_different_header_size) {
-  constexpr int32_t kPid = 123;
-  constexpr uint32_t kTid = 456;
-  constexpr uint32_t kSec = 1000;
-  constexpr uint32_t kNsec = 999;
-  constexpr uint32_t kLid = LOG_ID_MAIN;
-  constexpr uint32_t kUid = 987;
-  constexpr char kPriority = ANDROID_LOG_ERROR;
-
-  auto create_buf = [](char* buf, size_t len, uint16_t hdr_size) {
-    memset(buf, 0, len);
-    logger_entry* header = reinterpret_cast<logger_entry*>(buf);
-    header->hdr_size = hdr_size;
-    header->pid = kPid;
-    header->tid = kTid;
-    header->sec = kSec;
-    header->nsec = kNsec;
-    header->lid = kLid;
-    header->uid = kUid;
-    char* message = buf + header->hdr_size;
-    uint16_t message_len = 0;
-    message[message_len++] = kPriority;
-    message[message_len++] = 'T';
-    message[message_len++] = 'a';
-    message[message_len++] = 'g';
-    message[message_len++] = '\0';
-    message[message_len++] = 'm';
-    message[message_len++] = 's';
-    message[message_len++] = 'g';
-    message[message_len++] = '!';
-    message[message_len++] = '\0';
-    header->len = message_len;
-  };
-
-  auto check_entry = [&](const AndroidLogEntry& entry) {
-    EXPECT_EQ(kSec, static_cast<uint32_t>(entry.tv_sec));
-    EXPECT_EQ(kNsec, static_cast<uint32_t>(entry.tv_nsec));
-    EXPECT_EQ(kPriority, entry.priority);
-    EXPECT_EQ(kUid, static_cast<uint32_t>(entry.uid));
-    EXPECT_EQ(kPid, entry.pid);
-    EXPECT_EQ(kTid, static_cast<uint32_t>(entry.tid));
-    EXPECT_STREQ("Tag", entry.tag);
-    EXPECT_EQ(4U, entry.tagLen);  // Apparently taglen includes the nullptr?
-    EXPECT_EQ(4U, entry.messageLen);
-    EXPECT_STREQ("msg!", entry.message);
-  };
-  alignas(logger_entry) char buf[LOGGER_ENTRY_MAX_LEN];
-  create_buf(buf, sizeof(buf), sizeof(logger_entry));
-
-  AndroidLogEntry entry_normal_size;
-  ASSERT_EQ(0,
-            android_log_processLogBuffer(reinterpret_cast<logger_entry*>(buf), &entry_normal_size));
-  check_entry(entry_normal_size);
-
-  create_buf(buf, sizeof(buf), sizeof(logger_entry) + 3);
-  AndroidLogEntry entry_odd_size;
-  ASSERT_EQ(0, android_log_processLogBuffer(reinterpret_cast<logger_entry*>(buf), &entry_odd_size));
-  check_entry(entry_odd_size);
-}
\ No newline at end of file
diff --git a/liblog/uio.h b/liblog/uio.h
deleted file mode 100644
index c85893c..0000000
--- a/liblog/uio.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2019 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
-
-#if defined(_WIN32)
-#include <stddef.h>
-struct iovec {
-  void* iov_base;
-  size_t iov_len;
-};
-#else
-#include <sys/uio.h>
-#endif
diff --git a/libpixelflinger/Android.bp b/libpixelflinger/Android.bp
deleted file mode 100644
index 45a32da..0000000
--- a/libpixelflinger/Android.bp
+++ /dev/null
@@ -1,97 +0,0 @@
-cc_defaults {
-    name: "pixelflinger_defaults",
-
-    cflags: [
-        "-fstrict-aliasing",
-        "-fomit-frame-pointer",
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-function",
-    ],
-    export_include_dirs: ["include"],
-    header_libs: ["libbase_headers"],
-    shared_libs: [
-        "libcutils",
-        "liblog",
-        "libutils",
-    ],
-
-    arch: {
-        arm: {
-            neon: {
-                cflags: ["-D__ARM_HAVE_NEON"],
-            },
-        },
-    },
-}
-
-cc_library_static {
-    name: "libpixelflinger-arm",
-    defaults: ["pixelflinger_defaults"],
-
-    srcs: [
-        "fixed.cpp",
-        "picker.cpp",
-        "pixelflinger.cpp",
-        "trap.cpp",
-        "scanline.cpp",
-    ],
-
-    arch: {
-        arm: {
-            instruction_set: "arm",
-        },
-    },
-}
-
-// For the tests to use
-cc_library_headers {
-    name: "libpixelflinger_internal",
-    export_include_dirs: [
-        "include",
-        ".",
-    ],
-}
-
-cc_library {
-    name: "libpixelflinger",
-    defaults: ["pixelflinger_defaults"],
-
-    srcs: [
-        "codeflinger/ARMAssemblerInterface.cpp",
-        "codeflinger/ARMAssemblerProxy.cpp",
-        "codeflinger/CodeCache.cpp",
-        "codeflinger/GGLAssembler.cpp",
-        "codeflinger/load_store.cpp",
-        "codeflinger/blending.cpp",
-        "codeflinger/texturing.cpp",
-        "format.cpp",
-        "clear.cpp",
-        "raster.cpp",
-        "buffer.cpp",
-    ],
-    whole_static_libs: ["libpixelflinger-arm"],
-
-    arch: {
-        arm: {
-            srcs: [
-                "codeflinger/ARMAssembler.cpp",
-                "codeflinger/disassem.c",
-                "col32cb16blend.S",
-                "t32cb16blend.S",
-            ],
-
-            neon: {
-                srcs: ["col32cb16blend_neon.S"],
-            },
-        },
-        arm64: {
-            srcs: [
-                "codeflinger/Arm64Assembler.cpp",
-                "codeflinger/Arm64Disassembler.cpp",
-                "arch-arm64/col32cb16blend.S",
-                "arch-arm64/t32cb16blend.S",
-            ],
-        },
-    },
-}
diff --git a/libpixelflinger/MODULE_LICENSE_APACHE2 b/libpixelflinger/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/libpixelflinger/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/libpixelflinger/NOTICE b/libpixelflinger/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/libpixelflinger/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
-   Copyright (c) 2005-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.
-
-   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.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
diff --git a/libpixelflinger/arch-arm64/col32cb16blend.S b/libpixelflinger/arch-arm64/col32cb16blend.S
deleted file mode 100644
index 84596f9..0000000
--- a/libpixelflinger/arch-arm64/col32cb16blend.S
+++ /dev/null
@@ -1,87 +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.
- */
-    .text
-    .balign 0
-
-    .global scanline_col32cb16blend_arm64
-
-//
-// This function alpha blends a fixed color into a destination scanline, using
-// the formula:
-//
-//     d = s + (((a + (a >> 7)) * d) >> 8)
-//
-// where d is the destination pixel,
-//       s is the source color,
-//       a is the alpha channel of the source color.
-//
-
-// x0 = destination buffer pointer
-// w1 = color value
-// w2 = count
-
-
-scanline_col32cb16blend_arm64:
-
-    lsr         w5, w1, #24                     // shift down alpha
-    mov         w9, #0xff                       // create mask
-    add         w5, w5, w5, lsr #7              // add in top bit
-    mov         w4, #256                        // create #0x100
-    sub         w5, w4, w5                      // invert alpha
-    and         w10, w1, #0xff                  // extract red
-    and         w12, w9, w1, lsr #8             // extract green
-    and         w4,  w9, w1, lsr #16            // extract blue
-    lsl         w10, w10, #5                    // prescale red
-    lsl         w12, w12, #6                    // prescale green
-    lsl         w4,  w4,  #5                    // prescale blue
-    lsr         w9,  w9,  #2                    // create dest green mask
-
-1:
-    ldrh        w8, [x0]                        // load dest pixel
-    subs        w2, w2, #1                      // decrement loop counter
-    lsr         w6, w8, #11                     // extract dest red
-    and         w7, w9, w8, lsr #5              // extract dest green
-    and         w8, w8, #0x1f                   // extract dest blue
-
-    madd        w6, w6, w5, w10                 // dest red * alpha + src red
-    madd        w7, w7, w5, w12                 // dest green * alpha + src green
-    madd        w8, w8, w5, w4                  // dest blue * alpha + src blue
-
-    lsr         w6, w6, #8                      // shift down red
-    lsr         w7, w7, #8                      // shift down green
-    lsl         w6, w6, #11                     // shift red into 565
-    orr         w6, w6, w7, lsl #5              // shift green into 565
-    orr         w6, w6, w8, lsr #8              // shift blue into 565
-
-    strh        w6, [x0], #2                    // store pixel to dest, update ptr
-    b.ne        1b                              // if count != 0, loop
-
-    ret
-
-
-
diff --git a/libpixelflinger/arch-arm64/t32cb16blend.S b/libpixelflinger/arch-arm64/t32cb16blend.S
deleted file mode 100644
index a9733c0..0000000
--- a/libpixelflinger/arch-arm64/t32cb16blend.S
+++ /dev/null
@@ -1,213 +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.
- */
-    .text
-    .balign 0
-
-    .global scanline_t32cb16blend_arm64
-
-/*
- * .macro pixel
- *
- *  This macro alpha blends RGB565 original pixel located in either
- *  top or bottom 16 bits of DREG register with SRC 32 bit pixel value
- *  and writes the result to FB register
- *
- * \DREG is a 32-bit register containing *two* original destination RGB565
- *       pixels, with the even one in the low-16 bits, and the odd one in the
- *       high 16 bits.
- *
- * \SRC is a 32-bit 0xAABBGGRR pixel value, with pre-multiplied colors.
- *
- * \FB is a target register that will contain the blended pixel values.
- *
- * \ODD is either 0 or 1 and indicates if we're blending the lower or
- *      upper 16-bit pixels in DREG into FB
- *
- *
- * clobbered: w6, w7, w15, w16, w17
- *
- */
-
-.macro pixel,   DREG, SRC, FB, ODD
-
-    // SRC = 0xAABBGGRR
-    lsr     w7, \SRC, #24               // sA
-    add     w7, w7, w7, lsr #7          // sA + (sA >> 7)
-    mov     w6, #0x100
-    sub     w7, w6, w7                  // sA = 0x100 - (sA+(sA>>7))
-
-1:
-
-.if \ODD //Blending odd pixel present in top 16 bits of DREG register
-
-    // red
-    lsr     w16, \DREG, #(16 + 11)
-    mul     w16, w7, w16
-    lsr     w6, \SRC, #3
-    and     w6, w6, #0x1F
-    add     w16, w6, w16, lsr #8
-    cmp     w16, #0x1F
-    orr     w17, \FB, #(0x1F<<(16 + 11))
-    orr     w15, \FB, w16, lsl #(16 + 11)
-    csel    \FB, w17, w15, hi
-        // green
-        and     w6, \DREG, #(0x3F<<(16 + 5))
-        lsr     w17,w6,#(16+5)
-        mul     w6, w7, w17
-        lsr     w16, \SRC, #(8+2)
-        and     w16, w16, #0x3F
-        add     w6, w16, w6, lsr #8
-        cmp     w6, #0x3F
-        orr     w17, \FB, #(0x3F<<(16 + 5))
-        orr     w15, \FB, w6, lsl #(16 + 5)
-        csel    \FB, w17, w15, hi
-            // blue
-            and     w16, \DREG, #(0x1F << 16)
-            lsr     w17,w16,#16
-            mul     w16, w7, w17
-            lsr     w6, \SRC, #(8+8+3)
-            and     w6, w6, #0x1F
-            add     w16, w6, w16, lsr #8
-            cmp     w16, #0x1F
-            orr     w17, \FB, #(0x1F << 16)
-            orr     w15, \FB, w16, lsl #16
-            csel    \FB, w17, w15, hi
-
-.else //Blending even pixel present in bottom 16 bits of DREG register
-
-    // red
-    lsr     w16, \DREG, #11
-    and     w16, w16, #0x1F
-    mul     w16, w7, w16
-    lsr     w6, \SRC, #3
-    and     w6, w6, #0x1F
-    add     w16, w6, w16, lsr #8
-    cmp     w16, #0x1F
-    mov     w17, #(0x1F<<11)
-    lsl     w15, w16, #11
-    csel    \FB, w17, w15, hi
-
-
-        // green
-        and     w6, \DREG, #(0x3F<<5)
-        mul     w6, w7, w6
-        lsr     w16, \SRC, #(8+2)
-        and     w16, w16, #0x3F
-        add     w6, w16, w6, lsr #(5+8)
-        cmp     w6, #0x3F
-        orr     w17, \FB, #(0x3F<<5)
-        orr     w15, \FB, w6, lsl #5
-        csel    \FB, w17, w15, hi
-
-            // blue
-            and     w16, \DREG, #0x1F
-            mul     w16, w7, w16
-            lsr     w6, \SRC, #(8+8+3)
-            and     w6, w6, #0x1F
-            add     w16, w6, w16, lsr #8
-            cmp     w16, #0x1F
-            orr     w17, \FB, #0x1F
-            orr     w15, \FB, w16
-            csel    \FB, w17, w15, hi
-
-.endif // End of blending even pixel
-
-.endm // End of pixel macro
-
-
-// x0:  dst ptr
-// x1:  src ptr
-// w2:  count
-// w3:  d
-// w4:  s0
-// w5:  s1
-// w6:  pixel
-// w7:  pixel
-// w8:  free
-// w9:  free
-// w10: free
-// w11: free
-// w12: scratch
-// w14: pixel
-
-scanline_t32cb16blend_arm64:
-
-    // align DST to 32 bits
-    tst     x0, #0x3
-    b.eq    aligned
-    subs    w2, w2, #1
-    b.lo    return
-
-last:
-    ldr     w4, [x1], #4
-    ldrh    w3, [x0]
-    pixel   w3, w4, w12, 0
-    strh    w12, [x0], #2
-
-aligned:
-    subs    w2, w2, #2
-    b.lo    9f
-
-    // The main loop is unrolled twice and processes 4 pixels
-8:
-    ldp   w4,w5, [x1], #8
-    add     x0, x0, #4
-    // it's all zero, skip this pixel
-    orr     w3, w4, w5
-    cbz     w3, 7f
-
-    // load the destination
-    ldr     w3, [x0, #-4]
-    // stream the destination
-    pixel   w3, w4, w12, 0
-    pixel   w3, w5, w12, 1
-    str     w12, [x0, #-4]
-
-    // 2nd iteration of the loop, don't stream anything
-    subs    w2, w2, #2
-    csel    w4, w5, w4, lt
-    blt     9f
-    ldp     w4,w5, [x1], #8
-    add     x0, x0, #4
-    orr     w3, w4, w5
-    cbz     w3, 7f
-    ldr     w3, [x0, #-4]
-    pixel   w3, w4, w12, 0
-    pixel   w3, w5, w12, 1
-    str     w12, [x0, #-4]
-
-7:  subs    w2, w2, #2
-    bhs     8b
-    mov     w4, w5
-
-9:  adds    w2, w2, #1
-    b.lo    return
-    b       last
-
-return:
-    ret
diff --git a/libpixelflinger/buffer.cpp b/libpixelflinger/buffer.cpp
deleted file mode 100644
index ea9514c..0000000
--- a/libpixelflinger/buffer.cpp
+++ /dev/null
@@ -1,389 +0,0 @@
-/* libs/pixelflinger/buffer.cpp
-**
-** Copyright 2006, 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 <assert.h>
-
-#include <android-base/macros.h>
-
-#include "buffer.h"
-
-namespace android {
-// ----------------------------------------------------------------------------
-
-static void read_pixel(const surface_t* s, context_t* c,
-        uint32_t x, uint32_t y, pixel_t* pixel);
-static void write_pixel(const surface_t* s, context_t* c,
-        uint32_t x, uint32_t y, const pixel_t* pixel);
-static void readRGB565(const surface_t* s, context_t* c,
-        uint32_t x, uint32_t y, pixel_t* pixel);
-static void readABGR8888(const surface_t* s, context_t* c,
-        uint32_t x, uint32_t y, pixel_t* pixel);
-
-static uint32_t logic_op(int op, uint32_t s, uint32_t d);
-static uint32_t extract(uint32_t v, int h, int l, int bits);
-static uint32_t expand(uint32_t v, int sbits, int dbits);
-static uint32_t downshift_component(uint32_t in, uint32_t v,
-        int sh, int sl, int dh, int dl, int ch, int cl, int dither);
-
-// ----------------------------------------------------------------------------
-
-void ggl_init_texture(context_t* c)
-{
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; i++) {
-        texture_t& t = c->state.texture[i];
-        t.s_coord = GGL_ONE_TO_ONE;
-        t.t_coord = GGL_ONE_TO_ONE;
-        t.s_wrap = GGL_REPEAT;
-        t.t_wrap = GGL_REPEAT;
-        t.min_filter = GGL_NEAREST;
-        t.mag_filter = GGL_NEAREST;
-        t.env = GGL_MODULATE;
-    }
-    c->activeTMU = &(c->state.texture[0]);
-}
-
-void ggl_set_surface(context_t* c, surface_t* dst, const GGLSurface* src)
-{
-    dst->width = src->width;
-    dst->height = src->height;
-    dst->stride = src->stride;
-    dst->data = src->data;
-    dst->format = src->format;
-    dst->dirty = 1;
-    if (__builtin_expect(dst->stride < 0, false)) {
-        const GGLFormat& pixelFormat(c->formats[dst->format]);
-        const int32_t bpr = -dst->stride * pixelFormat.size;
-        dst->data += bpr * (dst->height-1);
-    }
-}
-
-static void pick_read_write(surface_t* s)
-{
-    // Choose best reader/writers.
-    switch (s->format) {
-        case GGL_PIXEL_FORMAT_RGBA_8888:    s->read = readABGR8888;  break;
-        case GGL_PIXEL_FORMAT_RGB_565:      s->read = readRGB565;    break;
-        default:                            s->read = read_pixel;    break;
-    }
-    s->write = write_pixel;
-}
-
-void ggl_pick_texture(context_t* c)
-{
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-        surface_t& s = c->state.texture[i].surface;
-        if ((!c->state.texture[i].enable) || (!s.dirty))
-            continue;
-        s.dirty = 0;
-        pick_read_write(&s);
-        generated_tex_vars_t& gen = c->generated_vars.texture[i];
-        gen.width   = s.width;
-        gen.height  = s.height;
-        gen.stride  = s.stride;
-        gen.data    = uintptr_t(s.data);
-    }
-}
-
-void ggl_pick_cb(context_t* c)
-{
-    surface_t& s = c->state.buffers.color;
-    if (s.dirty) {
-        s.dirty = 0;
-        pick_read_write(&s);
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-void read_pixel(const surface_t* s, context_t* c,
-        uint32_t x, uint32_t y, pixel_t* pixel)
-{
-    assert((x < s->width) && (y < s->height));
-
-    const GGLFormat* f = &(c->formats[s->format]);
-    int32_t index = x + (s->stride * y);
-    uint8_t* const data = s->data + index * f->size;
-    uint32_t v = 0;
-    switch (f->size) {
-        case 1:		v = *data;									break;
-        case 2:		v = *(uint16_t*)data;						break;
-        case 3:		v = (data[2]<<16)|(data[1]<<8)|data[0];     break;
-        case 4:		v = GGL_RGBA_TO_HOST(*(uint32_t*)data);		break;
-    }
-    for (int i=0 ; i<4 ; i++) {
-        pixel->s[i] = f->c[i].h - f->c[i].l;
-        if (pixel->s[i])
-            pixel->c[i] = extract(v,  f->c[i].h,  f->c[i].l, f->size*8);
-    }
-}
-
-void readRGB565(const surface_t* s, context_t* /*c*/,
-        uint32_t x, uint32_t y, pixel_t* pixel)
-{
-    uint16_t v = *(reinterpret_cast<uint16_t*>(s->data) + (x + (s->stride * y)));
-    pixel->c[0] = 0;
-    pixel->c[1] = v>>11;
-    pixel->c[2] = (v>>5)&0x3F;
-    pixel->c[3] = v&0x1F;
-    pixel->s[0] = 0;
-    pixel->s[1] = 5;
-    pixel->s[2] = 6;
-    pixel->s[3] = 5;
-}
-
-void readABGR8888(const surface_t* s, context_t* /*c*/,
-        uint32_t x, uint32_t y, pixel_t* pixel)
-{
-    uint32_t v = *(reinterpret_cast<uint32_t*>(s->data) + (x + (s->stride * y)));
-    v = GGL_RGBA_TO_HOST(v);
-    pixel->c[0] = v>>24;        // A
-    pixel->c[1] = v&0xFF;       // R
-    pixel->c[2] = (v>>8)&0xFF;  // G
-    pixel->c[3] = (v>>16)&0xFF; // B
-    pixel->s[0] = 
-    pixel->s[1] = 
-    pixel->s[2] = 
-    pixel->s[3] = 8;
-}
-
-void write_pixel(const surface_t* s, context_t* c,
-        uint32_t x, uint32_t y, const pixel_t* pixel)
-{
-    assert((x < s->width) && (y < s->height));
-
-    int dither = -1;
-    if (c->state.enables & GGL_ENABLE_DITHER) {
-        dither = c->ditherMatrix[ (x & GGL_DITHER_MASK) +
-                ((y & GGL_DITHER_MASK)<<GGL_DITHER_ORDER_SHIFT) ];
-    }
-
-    const GGLFormat* f = &(c->formats[s->format]);
-    int32_t index = x + (s->stride * y);
-    uint8_t* const data = s->data + index * f->size;
-        
-    uint32_t mask = 0;
-    uint32_t v = 0;
-    for (int i=0 ; i<4 ; i++) {
-        const int component_mask = 1 << i;
-        if (f->components>=GGL_LUMINANCE &&
-                (i==GGLFormat::GREEN || i==GGLFormat::BLUE)) {
-            // destinations L formats don't have G or B
-            continue;
-        }
-        const int l = f->c[i].l;
-        const int h = f->c[i].h;
-        if (h && (c->state.mask.color & component_mask)) {
-            mask |= (((1<<(h-l))-1)<<l);
-            uint32_t u = pixel->c[i];
-            int32_t pixelSize = pixel->s[i];
-            if (pixelSize < (h-l)) {
-                u = expand(u, pixelSize, h-l);
-                pixelSize = h-l;
-            }
-            v = downshift_component(v, u, pixelSize, 0, h, l, 0, 0, dither);
-        }
-    }
-
-    if ((c->state.mask.color != 0xF) || 
-        (c->state.enables & GGL_ENABLE_LOGIC_OP)) {
-        uint32_t d = 0;
-        switch (f->size) {
-            case 1:	d = *data;									break;
-            case 2:	d = *(uint16_t*)data;						break;
-            case 3:	d = (data[2]<<16)|(data[1]<<8)|data[0];     break;
-            case 4:	d = GGL_RGBA_TO_HOST(*(uint32_t*)data);		break;
-        }
-        if (c->state.enables & GGL_ENABLE_LOGIC_OP) {
-            v = logic_op(c->state.logic_op.opcode, v, d);            
-            v &= mask;
-        }
-        v |= (d & ~mask);
-    }
-
-    switch (f->size) {
-        case 1:		*data = v;									break;
-        case 2:		*(uint16_t*)data = v;						break;
-        case 3:
-            data[0] = v;
-            data[1] = v>>8;
-            data[2] = v>>16;
-            break;
-        case 4:		*(uint32_t*)data = GGL_HOST_TO_RGBA(v);     break;
-    }
-}
-
-static uint32_t logic_op(int op, uint32_t s, uint32_t d)
-{
-    switch(op) {
-    case GGL_CLEAR:         return 0;
-    case GGL_AND:           return s & d;
-    case GGL_AND_REVERSE:   return s & ~d;
-    case GGL_COPY:          return s;
-    case GGL_AND_INVERTED:  return ~s & d;
-    case GGL_NOOP:          return d;
-    case GGL_XOR:           return s ^ d;
-    case GGL_OR:            return s | d;
-    case GGL_NOR:           return ~(s | d);
-    case GGL_EQUIV:         return ~(s ^ d);
-    case GGL_INVERT:        return ~d;
-    case GGL_OR_REVERSE:    return s | ~d;
-    case GGL_COPY_INVERTED: return ~s;
-    case GGL_OR_INVERTED:   return ~s | d;
-    case GGL_NAND:          return ~(s & d);
-    case GGL_SET:           return ~0;
-    };
-    return s;
-}            
-
-
-uint32_t ggl_expand(uint32_t v, int sbits, int dbits)
-{
-    return expand(v, sbits, dbits);
-}
-
-uint32_t ggl_pack_color(context_t* c, int32_t format,
-        GGLcolor r, GGLcolor g, GGLcolor b, GGLcolor a)
-{
-    const GGLFormat* f = &(c->formats[format]);
-    uint32_t p = 0;
-    const int32_t hbits = GGL_COLOR_BITS;
-    const int32_t lbits = GGL_COLOR_BITS - 8;
-    p = downshift_component(p, r,   hbits, lbits,  f->rh, f->rl, 0, 1, -1);
-    p = downshift_component(p, g,   hbits, lbits,  f->gh, f->gl, 0, 1, -1);
-    p = downshift_component(p, b,   hbits, lbits,  f->bh, f->bl, 0, 1, -1);
-    p = downshift_component(p, a,   hbits, lbits,  f->ah, f->al, 0, 1, -1);
-    switch (f->size) {
-        case 1:
-            p |= p << 8;
-            FALLTHROUGH_INTENDED;
-        case 2:
-            p |= p << 16;
-    }
-    return p;
-}
-
-// ----------------------------------------------------------------------------
-
-// extract a component from a word
-uint32_t extract(uint32_t v, int h, int l, int bits)
-{
-	assert(h);
-	if (l) {
-		v >>= l;
-	}
-	if (h != bits) {
-		v &= (1<<(h-l))-1;
-	}
-	return v;
-}
-
-// expand a component from sbits to dbits
-uint32_t expand(uint32_t v, int sbits, int dbits)
-{
-    if (dbits > sbits) {
-        assert(sbits);
-        if (sbits==1) {
-            v = (v<<dbits) - v;
-        } else {
-            if (dbits % sbits) {
-                v <<= (dbits-sbits);
-                dbits -= sbits;
-                do {
-                    v |= v>>sbits;
-                    dbits -= sbits;
-                    sbits *= 2;
-                } while (dbits>0);
-            } else {
-                dbits -= sbits;
-                do {
-                    v |= v<<sbits;
-                    dbits -= sbits;
-                    if (sbits*2 < dbits) {
-                        sbits *= 2;
-                    }
-                } while (dbits > 0);
-            }
-        }
-    }
-	return v;
-}
-
-// downsample a component from sbits to dbits
-// and shift / construct the pixel
-uint32_t downshift_component(	uint32_t in, uint32_t v,
-                                int sh, int sl,		// src
-                                int dh, int dl,		// dst
-                                int ch, int cl,		// clear
-                                int dither)
-{
-	const int sbits = sh-sl;
-	const int dbits = dh-dl;
-    
-	assert(sbits>=dbits);
-
-
-    if (sbits>dbits) {
-        if (dither>=0) {
-            v -= (v>>dbits);				// fix up
-            const int shift = (GGL_DITHER_BITS - (sbits-dbits));
-            if (shift >= 0)   v += (dither >> shift) << sl;
-            else              v += (dither << (-shift)) << sl;
-        } else {
-            // don't do that right now, so we can reproduce the same
-            // artifacts we get on ARM (Where we don't do this)
-            // -> this is not really needed if we don't dither
-            //if (dBits > 1) { // result already OK if dBits==1
-            //    v -= (v>>dbits);				// fix up
-            //    v += 1 << ((sbits-dbits)-1);	// rounding
-            //}
-        }
-    }
-
-
-	// we need to clear the high bits of the source
-	if (ch) {
-		v <<= 32-sh;
-		sl += 32-sh;
-        sh = 32;
-	}
-	
-	if (dl) {
-		if (cl || (sbits>dbits)) {
-			v >>= sh-dbits;
-			sl = 0;
-			sh = dbits;
-            in |= v<<dl;
-		} else {
-			// sbits==dbits and we don't need to clean the lower bits
-			// so we just have to shift the component to the right location
-            int shift = dh-sh;
-            in |= v<<shift;
-		}
-	} else {
-		// destination starts at bit 0
-		// ie: sh-dh == sh-dbits
-		int shift = sh-dh;
-		if (shift > 0)      in |= v>>shift;
-		else if (shift < 0) in |= v<<shift;
-		else                in |= v;
-	}
-	return in;
-}
-
-// ----------------------------------------------------------------------------
-}; // namespace android
diff --git a/libpixelflinger/buffer.h b/libpixelflinger/buffer.h
deleted file mode 100644
index 9c9e4bc..0000000
--- a/libpixelflinger/buffer.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* libs/pixelflinger/buffer.h
-**
-** Copyright 2006, 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_GGL_TEXTURE_H
-#define ANDROID_GGL_TEXTURE_H
-
-#include <private/pixelflinger/ggl_context.h>
-
-namespace android {
-
-void ggl_init_texture(context_t* c);
-
-void ggl_set_surface(context_t* c, surface_t* dst, const GGLSurface* src);
-
-void ggl_pick_texture(context_t* c);
-void ggl_pick_cb(context_t* c);
-
-uint32_t ggl_expand(uint32_t v, int sbits, int dbits);
-uint32_t ggl_pack_color(context_t* c, int32_t format,
-            GGLcolor r, GGLcolor g, GGLcolor b, GGLcolor a);
-
-}; // namespace android
-
-#endif // ANDROID_GGL_TEXTURE_H
diff --git a/libpixelflinger/clear.cpp b/libpixelflinger/clear.cpp
deleted file mode 100644
index b962456..0000000
--- a/libpixelflinger/clear.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/* libs/pixelflinger/clear.cpp
-**
-** Copyright 2006, 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 <cutils/memory.h>
-
-#include "clear.h"
-#include "buffer.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-static void ggl_clear(void* c, GGLbitfield mask);
-static void ggl_clearColorx(void* c,
-        GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);        
-static void ggl_clearDepthx(void* c, GGLclampx depth);
-static void ggl_clearStencil(void* c, GGLint s);
-
-// ----------------------------------------------------------------------------
-
-void ggl_init_clear(context_t* c)
-{
-    GGLContext& procs = *(GGLContext*)c;
-    GGL_INIT_PROC(procs, clear);
-    GGL_INIT_PROC(procs, clearColorx);
-    GGL_INIT_PROC(procs, clearDepthx);
-    GGL_INIT_PROC(procs, clearStencil);
-    c->state.clear.dirty =  GGL_STENCIL_BUFFER_BIT |
-                            GGL_COLOR_BUFFER_BIT |
-                            GGL_DEPTH_BUFFER_BIT;
-    c->state.clear.depth = FIXED_ONE;
-}
-
-// ----------------------------------------------------------------------------
-
-static void memset2d(context_t* c, const surface_t& s, uint32_t packed,
-        uint32_t l, uint32_t t, uint32_t w, uint32_t h)
-{
-    const uint32_t size = c->formats[s.format].size;
-    const int32_t stride = s.stride * size;
-    uint8_t* dst = (uint8_t*)s.data + (l + t*s.stride)*size;
-    w *= size;
-
-    if (ggl_likely(int32_t(w) == stride)) {
-        // clear the whole thing in one call
-        w *= h;
-        h = 1;
-    }
-
-    switch (size) {
-    case 1:
-        do {
-            memset(dst, packed, w);
-            dst += stride;
-        } while(--h);
-        break;
-    case 2:
-        do {
-            android_memset16((uint16_t*)dst, packed, w);
-            dst += stride;
-        } while(--h);
-        break;
-    case 3: // XXX: 24-bit clear.
-        break;
-    case 4:
-        do {
-            android_memset32((uint32_t*)dst, packed, w);
-            dst += stride;
-        } while(--h);
-        break;
-    }    
-}
-
-static inline GGLfixed fixedToZ(GGLfixed z) {
-    return GGLfixed(((int64_t(z) << 16) - z) >> 16);
-}
-
-static void ggl_clear(void* con, GGLbitfield mask)
-{
-    GGL_CONTEXT(c, con);
-
-    // XXX: rgba-dithering, rgba-masking
-    // XXX: handle all formats of Z and S
-
-    const uint32_t l = c->state.scissor.left;
-    const uint32_t t = c->state.scissor.top;
-    uint32_t w = c->state.scissor.right - l;
-    uint32_t h = c->state.scissor.bottom - t;
-
-    if (!w || !h)
-        return;
-
-    // unexsiting buffers have no effect...
-    if (c->state.buffers.color.format == 0)
-        mask &= ~GGL_COLOR_BUFFER_BIT;
-
-    if (c->state.buffers.depth.format == 0)
-        mask &= ~GGL_DEPTH_BUFFER_BIT;
-
-    if (c->state.buffers.stencil.format == 0)
-        mask &= ~GGL_STENCIL_BUFFER_BIT;
-
-    if (mask & GGL_COLOR_BUFFER_BIT) {
-        if (c->state.clear.dirty & GGL_COLOR_BUFFER_BIT) {
-            c->state.clear.dirty &= ~GGL_COLOR_BUFFER_BIT;
-
-            uint32_t colorPacked = ggl_pack_color(c,
-                    c->state.buffers.color.format,
-                    gglFixedToIteratedColor(c->state.clear.r),
-                    gglFixedToIteratedColor(c->state.clear.g),
-                    gglFixedToIteratedColor(c->state.clear.b),
-                    gglFixedToIteratedColor(c->state.clear.a));
-
-            c->state.clear.colorPacked = GGL_HOST_TO_RGBA(colorPacked);
-        }
-        const uint32_t packed = c->state.clear.colorPacked;
-        memset2d(c, c->state.buffers.color, packed, l, t, w, h);
-    }
-    if (mask & GGL_DEPTH_BUFFER_BIT) {
-        if (c->state.clear.dirty & GGL_DEPTH_BUFFER_BIT) {
-            c->state.clear.dirty &= ~GGL_DEPTH_BUFFER_BIT;
-            uint32_t depth = fixedToZ(c->state.clear.depth);
-            c->state.clear.depthPacked = (depth<<16)|depth;
-        }
-        const uint32_t packed = c->state.clear.depthPacked;
-        memset2d(c, c->state.buffers.depth, packed, l, t, w, h);
-    }
-
-    // XXX: do stencil buffer
-}
-
-static void ggl_clearColorx(void* con,
-        GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a)
-{
-    GGL_CONTEXT(c, con);
-    c->state.clear.r = gglClampx(r);
-    c->state.clear.g = gglClampx(g);
-    c->state.clear.b = gglClampx(b);
-    c->state.clear.a = gglClampx(a);
-    c->state.clear.dirty |= GGL_COLOR_BUFFER_BIT;
-}
-
-static void ggl_clearDepthx(void* con, GGLclampx depth)
-{
-    GGL_CONTEXT(c, con);
-    c->state.clear.depth = gglClampx(depth);
-    c->state.clear.dirty |= GGL_DEPTH_BUFFER_BIT;
-}
-
-static void ggl_clearStencil(void* con, GGLint s)
-{
-    GGL_CONTEXT(c, con);
-    c->state.clear.stencil = s;
-    c->state.clear.dirty |= GGL_STENCIL_BUFFER_BIT;
-}
-
-}; // namespace android
diff --git a/libpixelflinger/clear.h b/libpixelflinger/clear.h
deleted file mode 100644
index b071df0..0000000
--- a/libpixelflinger/clear.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* libs/pixelflinger/clear.h
-**
-** Copyright 2006, 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_GGL_CLEAR_H
-#define ANDROID_GGL_CLEAR_H
-
-#include <pixelflinger/pixelflinger.h>
-#include <private/pixelflinger/ggl_context.h>
-
-namespace android {
-
-void ggl_init_clear(context_t* c);
-
-}; // namespace android
-
-#endif // ANDROID_GGL_CLEAR_H
diff --git a/libpixelflinger/codeflinger/ARMAssembler.cpp b/libpixelflinger/codeflinger/ARMAssembler.cpp
deleted file mode 100644
index f47b6e4..0000000
--- a/libpixelflinger/codeflinger/ARMAssembler.cpp
+++ /dev/null
@@ -1,579 +0,0 @@
-/* libs/pixelflinger/codeflinger/ARMAssembler.cpp
-**
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "ARMAssembler"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <cutils/properties.h>
-#include <log/log.h>
-#include <private/pixelflinger/ggl_context.h>
-
-#include "ARMAssembler.h"
-#include "CodeCache.h"
-#include "disassem.h"
-
-// ----------------------------------------------------------------------------
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark ARMAssembler...
-#endif
-
-ARMAssembler::ARMAssembler(const sp<Assembly>& assembly)
-    :   ARMAssemblerInterface(),
-        mAssembly(assembly)
-{
-    mBase = mPC = (uint32_t *)assembly->base();
-    mDuration = ggl_system_time();
-}
-
-ARMAssembler::~ARMAssembler()
-{
-}
-
-uint32_t* ARMAssembler::pc() const
-{
-    return mPC;
-}
-
-uint32_t* ARMAssembler::base() const
-{
-    return mBase;
-}
-
-void ARMAssembler::reset()
-{
-    mBase = mPC = (uint32_t *)mAssembly->base();
-    mBranchTargets.clear();
-    mLabels.clear();
-    mLabelsInverseMapping.clear();
-    mComments.clear();
-}
-
-int ARMAssembler::getCodegenArch()
-{
-    return CODEGEN_ARCH_ARM;
-}
-
-// ----------------------------------------------------------------------------
-
-void ARMAssembler::disassemble(const char* name)
-{
-    if (name) {
-        printf("%s:\n", name);
-    }
-    size_t count = pc()-base();
-    uint32_t* i = base();
-    while (count--) {
-        ssize_t label = mLabelsInverseMapping.indexOfKey(i);
-        if (label >= 0) {
-            printf("%s:\n", mLabelsInverseMapping.valueAt(label));
-        }
-        ssize_t comment = mComments.indexOfKey(i);
-        if (comment >= 0) {
-            printf("; %s\n", mComments.valueAt(comment));
-        }
-        printf("%08x:    %08x    ", uintptr_t(i), int(i[0]));
-        ::disassemble((uintptr_t)i);
-        i++;
-    }
-}
-
-void ARMAssembler::comment(const char* string)
-{
-    mComments.add(mPC, string);
-}
-
-void ARMAssembler::label(const char* theLabel)
-{
-    mLabels.add(theLabel, mPC);
-    mLabelsInverseMapping.add(mPC, theLabel);
-}
-
-void ARMAssembler::B(int cc, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (cc<<28) | (0xA<<24) | 0;
-}
-
-void ARMAssembler::BL(int cc, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (cc<<28) | (0xB<<24) | 0;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Prolog/Epilog & Generate...
-#endif
-
-
-void ARMAssembler::prolog()
-{
-    // write dummy prolog code
-    mPrologPC = mPC;
-    STM(AL, FD, SP, 1, LSAVED);
-}
-
-void ARMAssembler::epilog(uint32_t touched)
-{
-    touched &= LSAVED;
-    if (touched) {
-        // write prolog code
-        uint32_t* pc = mPC;
-        mPC = mPrologPC;
-        STM(AL, FD, SP, 1, touched | LLR);
-        mPC = pc;
-        // write epilog code
-        LDM(AL, FD, SP, 1, touched | LLR);
-        BX(AL, LR);
-    } else {   // heh, no registers to save!
-        // write prolog code
-        uint32_t* pc = mPC;
-        mPC = mPrologPC;
-        MOV(AL, 0, R0, R0); // NOP
-        mPC = pc;
-        // write epilog code
-        BX(AL, LR);
-    }
-}
-
-int ARMAssembler::generate(const char* name)
-{
-    // fixup all the branches
-    size_t count = mBranchTargets.size();
-    while (count--) {
-        const branch_target_t& bt = mBranchTargets[count];
-        uint32_t* target_pc = mLabels.valueFor(bt.label);
-        LOG_ALWAYS_FATAL_IF(!target_pc,
-                "error resolving branch targets, target_pc is null");
-        int32_t offset = int32_t(target_pc - (bt.pc+2));
-        *bt.pc |= offset & 0xFFFFFF;
-    }
-
-    mAssembly->resize( int(pc()-base())*4 );
-
-    // the instruction cache is flushed by CodeCache
-    const int64_t duration = ggl_system_time() - mDuration;
-    const char * const format = "generated %s (%d ins) at [%p:%p] in %lld ns\n";
-    ALOGI(format, name, int(pc()-base()), base(), pc(), duration);
-
-    char value[PROPERTY_VALUE_MAX];
-    property_get("debug.pf.disasm", value, "0");
-    if (atoi(value) != 0) {
-        printf(format, name, int(pc()-base()), base(), pc(), duration);
-        disassemble(name);
-    }
-
-    return OK;
-}
-
-uint32_t* ARMAssembler::pcForLabel(const char* label)
-{
-    return mLabels.valueFor(label);
-}
-
-// ----------------------------------------------------------------------------
-
-#if 0
-#pragma mark -
-#pragma mark Data Processing...
-#endif
-
-void ARMAssembler::dataProcessing(int opcode, int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-    *mPC++ = (cc<<28) | (opcode<<21) | (s<<20) | (Rn<<16) | (Rd<<12) | Op2;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Multiply...
-#endif
-
-// multiply...
-void ARMAssembler::MLA(int cc, int s,
-        int Rd, int Rm, int Rs, int Rn) {
-    if (Rd == Rm) { int t = Rm; Rm=Rs; Rs=t; }
-    LOG_FATAL_IF(Rd==Rm, "MLA(r%u,r%u,r%u,r%u)", Rd,Rm,Rs,Rn);
-    *mPC++ =    (cc<<28) | (1<<21) | (s<<20) |
-                (Rd<<16) | (Rn<<12) | (Rs<<8) | 0x90 | Rm;
-}
-void ARMAssembler::MUL(int cc, int s,
-        int Rd, int Rm, int Rs) {
-    if (Rd == Rm) { int t = Rm; Rm=Rs; Rs=t; }
-    LOG_FATAL_IF(Rd==Rm, "MUL(r%u,r%u,r%u)", Rd,Rm,Rs);
-    *mPC++ = (cc<<28) | (s<<20) | (Rd<<16) | (Rs<<8) | 0x90 | Rm;
-}
-void ARMAssembler::UMULL(int cc, int s,
-        int RdLo, int RdHi, int Rm, int Rs) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "UMULL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    *mPC++ =    (cc<<28) | (1<<23) | (s<<20) |
-                (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-}
-void ARMAssembler::UMUAL(int cc, int s,
-        int RdLo, int RdHi, int Rm, int Rs) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "UMUAL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    *mPC++ =    (cc<<28) | (1<<23) | (1<<21) | (s<<20) |
-                (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-}
-void ARMAssembler::SMULL(int cc, int s,
-        int RdLo, int RdHi, int Rm, int Rs) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "SMULL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    *mPC++ =    (cc<<28) | (1<<23) | (1<<22) | (s<<20) |
-                (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-}
-void ARMAssembler::SMUAL(int cc, int s,
-        int RdLo, int RdHi, int Rm, int Rs) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "SMUAL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    *mPC++ =    (cc<<28) | (1<<23) | (1<<22) | (1<<21) | (s<<20) |
-                (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Branches...
-#endif
-
-// branches...
-void ARMAssembler::B(int cc, uint32_t* pc)
-{
-    int32_t offset = int32_t(pc - (mPC+2));
-    *mPC++ = (cc<<28) | (0xA<<24) | (offset & 0xFFFFFF);
-}
-
-void ARMAssembler::BL(int cc, uint32_t* pc)
-{
-    int32_t offset = int32_t(pc - (mPC+2));
-    *mPC++ = (cc<<28) | (0xB<<24) | (offset & 0xFFFFFF);
-}
-
-void ARMAssembler::BX(int cc, int Rn)
-{
-    *mPC++ = (cc<<28) | 0x12FFF10 | Rn;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Data Transfer...
-#endif
-
-// data transfert...
-void ARMAssembler::LDR(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (1<<26) | (1<<20) | (Rn<<16) | (Rd<<12) | offset;
-}
-void ARMAssembler::LDRB(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (1<<26) | (1<<22) | (1<<20) | (Rn<<16) | (Rd<<12) | offset;
-}
-void ARMAssembler::STR(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (1<<26) | (Rn<<16) | (Rd<<12) | offset;
-}
-void ARMAssembler::STRB(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (1<<26) | (1<<22) | (Rn<<16) | (Rd<<12) | offset;
-}
-
-void ARMAssembler::LDRH(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (1<<20) | (Rn<<16) | (Rd<<12) | 0xB0 | offset;
-}
-void ARMAssembler::LDRSB(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (1<<20) | (Rn<<16) | (Rd<<12) | 0xD0 | offset;
-}
-void ARMAssembler::LDRSH(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (1<<20) | (Rn<<16) | (Rd<<12) | 0xF0 | offset;
-}
-void ARMAssembler::STRH(int cc, int Rd, int Rn, uint32_t offset) {
-    *mPC++ = (cc<<28) | (Rn<<16) | (Rd<<12) | 0xB0 | offset;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Block Data Transfer...
-#endif
-
-// block data transfer...
-void ARMAssembler::LDM(int cc, int dir,
-        int Rn, int W, uint32_t reg_list)
-{   //                    ED FD EA FA      IB IA DB DA
-    const uint8_t P[8] = { 1, 0, 1, 0,      1, 0, 1, 0 };
-    const uint8_t U[8] = { 1, 1, 0, 0,      1, 1, 0, 0 };
-    *mPC++ = (cc<<28) | (4<<25) | (uint32_t(P[dir])<<24) |
-            (uint32_t(U[dir])<<23) | (1<<20) | (W<<21) | (Rn<<16) | reg_list;
-}
-
-void ARMAssembler::STM(int cc, int dir,
-        int Rn, int W, uint32_t reg_list)
-{   //                    ED FD EA FA      IB IA DB DA
-    const uint8_t P[8] = { 0, 1, 0, 1,      1, 0, 1, 0 };
-    const uint8_t U[8] = { 0, 0, 1, 1,      1, 1, 0, 0 };
-    *mPC++ = (cc<<28) | (4<<25) | (uint32_t(P[dir])<<24) |
-            (uint32_t(U[dir])<<23) | (0<<20) | (W<<21) | (Rn<<16) | reg_list;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Special...
-#endif
-
-// special...
-void ARMAssembler::SWP(int cc, int Rn, int Rd, int Rm) {
-    *mPC++ = (cc<<28) | (2<<23) | (Rn<<16) | (Rd << 12) | 0x90 | Rm;
-}
-void ARMAssembler::SWPB(int cc, int Rn, int Rd, int Rm) {
-    *mPC++ = (cc<<28) | (2<<23) | (1<<22) | (Rn<<16) | (Rd << 12) | 0x90 | Rm;
-}
-void ARMAssembler::SWI(int cc, uint32_t comment) {
-    *mPC++ = (cc<<28) | (0xF<<24) | comment;
-}
-
-#if 0
-#pragma mark -
-#pragma mark DSP instructions...
-#endif
-
-// DSP instructions...
-void ARMAssembler::PLD(int Rn, uint32_t offset) {
-    LOG_ALWAYS_FATAL_IF(!((offset&(1<<24)) && !(offset&(1<<21))),
-                        "PLD only P=1, W=0");
-    *mPC++ = 0xF550F000 | (Rn<<16) | offset;
-}
-
-void ARMAssembler::CLZ(int cc, int Rd, int Rm)
-{
-    *mPC++ = (cc<<28) | 0x16F0F10| (Rd<<12) | Rm;
-}
-
-void ARMAssembler::QADD(int cc,  int Rd, int Rm, int Rn)
-{
-    *mPC++ = (cc<<28) | 0x1000050 | (Rn<<16) | (Rd<<12) | Rm;
-}
-
-void ARMAssembler::QDADD(int cc,  int Rd, int Rm, int Rn)
-{
-    *mPC++ = (cc<<28) | 0x1400050 | (Rn<<16) | (Rd<<12) | Rm;
-}
-
-void ARMAssembler::QSUB(int cc,  int Rd, int Rm, int Rn)
-{
-    *mPC++ = (cc<<28) | 0x1200050 | (Rn<<16) | (Rd<<12) | Rm;
-}
-
-void ARMAssembler::QDSUB(int cc,  int Rd, int Rm, int Rn)
-{
-    *mPC++ = (cc<<28) | 0x1600050 | (Rn<<16) | (Rd<<12) | Rm;
-}
-
-void ARMAssembler::SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs)
-{
-    *mPC++ = (cc<<28) | 0x1600080 | (Rd<<16) | (Rs<<8) | (xy<<4) | Rm;
-}
-
-void ARMAssembler::SMULW(int cc, int y,
-                int Rd, int Rm, int Rs)
-{
-    *mPC++ = (cc<<28) | 0x12000A0 | (Rd<<16) | (Rs<<8) | (y<<4) | Rm;
-}
-
-void ARMAssembler::SMLA(int cc, int xy,
-                int Rd, int Rm, int Rs, int Rn)
-{
-    *mPC++ = (cc<<28) | 0x1000080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (xy<<4) | Rm;
-}
-
-void ARMAssembler::SMLAL(int cc, int xy,
-                int RdHi, int RdLo, int Rs, int Rm)
-{
-    *mPC++ = (cc<<28) | 0x1400080 | (RdHi<<16) | (RdLo<<12) | (Rs<<8) | (xy<<4) | Rm;
-}
-
-void ARMAssembler::SMLAW(int cc, int y,
-                int Rd, int Rm, int Rs, int Rn)
-{
-    *mPC++ = (cc<<28) | 0x1200080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (y<<4) | Rm;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Byte/half word extract and extend (ARMv6+ only)...
-#endif
-
-void ARMAssembler::UXTB16(int cc, int Rd, int Rm, int rotate)
-{
-    *mPC++ = (cc<<28) | 0x6CF0070 | (Rd<<12) | ((rotate >> 3) << 10) | Rm;
-}
-#if 0
-#pragma mark -
-#pragma mark Bit manipulation (ARMv7+ only)...
-#endif
-
-// Bit manipulation (ARMv7+ only)...
-void ARMAssembler::UBFX(int cc, int Rd, int Rn, int lsb, int width)
-{
-    *mPC++ = (cc<<28) | 0x7E00000 | ((width-1)<<16) | (Rd<<12) | (lsb<<7) | 0x50 | Rn;
-}
-
-#if 0
-#pragma mark -
-#pragma mark Addressing modes...
-#endif
-
-int ARMAssembler::buildImmediate(
-        uint32_t immediate, uint32_t& rot, uint32_t& imm)
-{
-    rot = 0;
-    imm = immediate;
-    if (imm > 0x7F) { // skip the easy cases
-        while (!(imm&3)  || (imm&0xFC000000)) {
-            uint32_t newval;
-            newval = imm >> 2;
-            newval |= (imm&3) << 30;
-            imm = newval;
-            rot += 2;
-            if (rot == 32) {
-                rot = 0;
-                break;
-            }
-        }
-    }
-    rot = (16 - (rot>>1)) & 0xF;
-
-    if (imm>=0x100)
-        return -EINVAL;
-
-    if (((imm>>(rot<<1)) | (imm<<(32-(rot<<1)))) != immediate)
-        return -1;
-
-    return 0;
-}
-
-// shifters...
-
-bool ARMAssembler::isValidImmediate(uint32_t immediate)
-{
-    uint32_t rot, imm;
-    return buildImmediate(immediate, rot, imm) == 0;
-}
-
-uint32_t ARMAssembler::imm(uint32_t immediate)
-{
-    uint32_t rot, imm;
-    int err = buildImmediate(immediate, rot, imm);
-
-    LOG_ALWAYS_FATAL_IF(err==-EINVAL,
-                        "immediate %08x cannot be encoded",
-                        immediate);
-
-    LOG_ALWAYS_FATAL_IF(err,
-                        "immediate (%08x) encoding bogus!",
-                        immediate);
-
-    return (1<<25) | (rot<<8) | imm;
-}
-
-uint32_t ARMAssembler::reg_imm(int Rm, int type, uint32_t shift)
-{
-    return ((shift&0x1F)<<7) | ((type&0x3)<<5) | (Rm&0xF);
-}
-
-uint32_t ARMAssembler::reg_rrx(int Rm)
-{
-    return (ROR<<5) | (Rm&0xF);
-}
-
-uint32_t ARMAssembler::reg_reg(int Rm, int type, int Rs)
-{
-    return ((Rs&0xF)<<8) | ((type&0x3)<<5) | (1<<4) | (Rm&0xF);
-}
-
-// addressing modes...
-// LDR(B)/STR(B)/PLD (immediate and Rm can be negative, which indicate U=0)
-uint32_t ARMAssembler::immed12_pre(int32_t immed12, int W)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800,
-                        "LDR(B)/STR(B)/PLD immediate too big (%08x)",
-                        immed12);
-    return (1<<24) | (((uint32_t(immed12)>>31)^1)<<23) |
-            ((W&1)<<21) | (abs(immed12)&0x7FF);
-}
-
-uint32_t ARMAssembler::immed12_post(int32_t immed12)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800,
-                        "LDR(B)/STR(B)/PLD immediate too big (%08x)",
-                        immed12);
-
-    return (((uint32_t(immed12)>>31)^1)<<23) | (abs(immed12)&0x7FF);
-}
-
-uint32_t ARMAssembler::reg_scale_pre(int Rm, int type,
-        uint32_t shift, int W)
-{
-    return  (1<<25) | (1<<24) |
-            (((uint32_t(Rm)>>31)^1)<<23) | ((W&1)<<21) |
-            reg_imm(abs(Rm), type, shift);
-}
-
-uint32_t ARMAssembler::reg_scale_post(int Rm, int type, uint32_t shift)
-{
-    return (1<<25) | (((uint32_t(Rm)>>31)^1)<<23) | reg_imm(abs(Rm), type, shift);
-}
-
-// LDRH/LDRSB/LDRSH/STRH (immediate and Rm can be negative, which indicate U=0)
-uint32_t ARMAssembler::immed8_pre(int32_t immed8, int W)
-{
-    uint32_t offset = abs(immed8);
-
-    LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100,
-                        "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)",
-                        immed8);
-
-    return  (1<<24) | (1<<22) | (((uint32_t(immed8)>>31)^1)<<23) |
-            ((W&1)<<21) | (((offset&0xF0)<<4)|(offset&0xF));
-}
-
-uint32_t ARMAssembler::immed8_post(int32_t immed8)
-{
-    uint32_t offset = abs(immed8);
-
-    LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100,
-                        "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)",
-                        immed8);
-
-    return (1<<22) | (((uint32_t(immed8)>>31)^1)<<23) |
-            (((offset&0xF0)<<4) | (offset&0xF));
-}
-
-uint32_t ARMAssembler::reg_pre(int Rm, int W)
-{
-    return (1<<24) | (((uint32_t(Rm)>>31)^1)<<23) | ((W&1)<<21) | (abs(Rm)&0xF);
-}
-
-uint32_t ARMAssembler::reg_post(int Rm)
-{
-    return (((uint32_t(Rm)>>31)^1)<<23) | (abs(Rm)&0xF);
-}
-
-}; // namespace android
diff --git a/libpixelflinger/codeflinger/ARMAssembler.h b/libpixelflinger/codeflinger/ARMAssembler.h
deleted file mode 100644
index 76acf7e..0000000
--- a/libpixelflinger/codeflinger/ARMAssembler.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/* libs/pixelflinger/codeflinger/ARMAssembler.h
-**
-** Copyright 2006, 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_ARMASSEMBLER_H
-#define ANDROID_ARMASSEMBLER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "tinyutils/smartpointer.h"
-#include "utils/Vector.h"
-#include "utils/KeyedVector.h"
-
-#include "ARMAssemblerInterface.h"
-#include "CodeCache.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-class ARMAssembler : public ARMAssemblerInterface
-{
-public:
-    explicit    ARMAssembler(const sp<Assembly>& assembly);
-    virtual     ~ARMAssembler();
-
-    uint32_t*   base() const;
-    uint32_t*   pc() const;
-
-
-    void        disassemble(const char* name);
-
-    // ------------------------------------------------------------------------
-    // ARMAssemblerInterface...
-    // ------------------------------------------------------------------------
-
-    virtual void    reset();
-
-    virtual int     generate(const char* name);
-    virtual int     getCodegenArch();
-
-    virtual void    prolog();
-    virtual void    epilog(uint32_t touched);
-    virtual void    comment(const char* string);
-
-
-    // -----------------------------------------------------------------------
-    // shifters and addressing modes
-    // -----------------------------------------------------------------------
-
-    // shifters...
-    virtual bool        isValidImmediate(uint32_t immed);
-    virtual int         buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
-
-    virtual uint32_t    imm(uint32_t immediate);
-    virtual uint32_t    reg_imm(int Rm, int type, uint32_t shift);
-    virtual uint32_t    reg_rrx(int Rm);
-    virtual uint32_t    reg_reg(int Rm, int type, int Rs);
-
-    // addressing modes...
-    // LDR(B)/STR(B)/PLD
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed12_pre(int32_t immed12, int W=0);
-    virtual uint32_t    immed12_post(int32_t immed12);
-    virtual uint32_t    reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
-    virtual uint32_t    reg_scale_post(int Rm, int type=0, uint32_t shift=0);
-
-    // LDRH/LDRSB/LDRSH/STRH
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed8_pre(int32_t immed8, int W=0);
-    virtual uint32_t    immed8_post(int32_t immed8);
-    virtual uint32_t    reg_pre(int Rm, int W=0);
-    virtual uint32_t    reg_post(int Rm);
-
-
-    virtual void    dataProcessing(int opcode, int cc, int s,
-                                int Rd, int Rn,
-                                uint32_t Op2);
-    virtual void MLA(int cc, int s,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void MUL(int cc, int s,
-                int Rd, int Rm, int Rs);
-    virtual void UMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void UMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-
-    virtual void B(int cc, uint32_t* pc);
-    virtual void BL(int cc, uint32_t* pc);
-    virtual void BX(int cc, int Rn);
-    virtual void label(const char* theLabel);
-    virtual void B(int cc, const char* label);
-    virtual void BL(int cc, const char* label);
-
-    virtual uint32_t* pcForLabel(const char* label);
-
-    virtual void LDR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void LDRB(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void STR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void STRB(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void LDRH (int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0));
-    virtual void LDRSB(int cc, int Rd, 
-                int Rn, uint32_t offset = __immed8_pre(0));
-    virtual void LDRSH(int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0));
-    virtual void STRH (int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0));
-
-
-    virtual void LDM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-    virtual void STM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-
-    virtual void SWP(int cc, int Rn, int Rd, int Rm);
-    virtual void SWPB(int cc, int Rn, int Rd, int Rm);
-    virtual void SWI(int cc, uint32_t comment);
-
-    virtual void PLD(int Rn, uint32_t offset);
-    virtual void CLZ(int cc, int Rd, int Rm);
-    virtual void QADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QDADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs);
-    virtual void SMULW(int cc, int y,
-                int Rd, int Rm, int Rs);
-    virtual void SMLA(int cc, int xy,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void SMLAL(int cc, int xy,
-                int RdHi, int RdLo, int Rs, int Rm);
-    virtual void SMLAW(int cc, int y,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
-    virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
-
-private:
-                ARMAssembler(const ARMAssembler& rhs);
-                ARMAssembler& operator = (const ARMAssembler& rhs);
-
-    sp<Assembly>    mAssembly;
-    uint32_t*       mBase;
-    uint32_t*       mPC;
-    uint32_t*       mPrologPC;
-    int64_t         mDuration;
-    
-    struct branch_target_t {
-        inline branch_target_t() : label(0), pc(0) { }
-        inline branch_target_t(const char* l, uint32_t* p)
-            : label(l), pc(p) { }
-        const char* label;
-        uint32_t*   pc;
-    };
-    
-    Vector<branch_target_t>                 mBranchTargets;
-    KeyedVector< const char*, uint32_t* >   mLabels;
-    KeyedVector< uint32_t*, const char* >   mLabelsInverseMapping;
-    KeyedVector< uint32_t*, const char* >   mComments;
-};
-
-}; // namespace android
-
-#endif //ANDROID_ARMASSEMBLER_H
diff --git a/libpixelflinger/codeflinger/ARMAssemblerInterface.cpp b/libpixelflinger/codeflinger/ARMAssemblerInterface.cpp
deleted file mode 100644
index c96cf4b..0000000
--- a/libpixelflinger/codeflinger/ARMAssemblerInterface.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* libs/pixelflinger/codeflinger/ARMAssemblerInterface.cpp
-**
-** Copyright 2006, 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.
-*/
-#define LOG_TAG "pixelflinger-code"
-
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#include <log/log.h>
-
-#include "ARMAssemblerInterface.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-ARMAssemblerInterface::~ARMAssemblerInterface()
-{
-}
-
-// --------------------------------------------------------------------
-
-// The following two functions are static and used for initializers
-// in the original ARM code. The above versions (without __), are now
-// virtual, and can be overridden in the MIPS code. But since these are
-// needed at initialization time, they must be static. Not thrilled with
-// this implementation, but it works...
-
-uint32_t ARMAssemblerInterface::__immed12_pre(int32_t immed12, int W)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800,
-                        "LDR(B)/STR(B)/PLD immediate too big (%08x)",
-                        immed12);
-    return (1<<24) | (((uint32_t(immed12)>>31)^1)<<23) |
-            ((W&1)<<21) | (abs(immed12)&0x7FF);
-}
-
-uint32_t ARMAssemblerInterface::__immed8_pre(int32_t immed8, int W)
-{
-    uint32_t offset = abs(immed8);
-
-    LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100,
-                        "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)",
-                        immed8);
-
-    return  (1<<24) | (1<<22) | (((uint32_t(immed8)>>31)^1)<<23) |
-            ((W&1)<<21) | (((offset&0xF0)<<4)|(offset&0xF));
-}
-
-// The following four functions are required for address manipulation
-// These are virtual functions, which can be overridden by architectures
-// that need special handling of address values (e.g. 64-bit arch)
-
-void ARMAssemblerInterface::ADDR_LDR(int cc, int Rd,
-     int Rn, uint32_t offset)
-{
-    LDR(cc, Rd, Rn, offset);
-}
-void ARMAssemblerInterface::ADDR_STR(int cc, int Rd,
-     int Rn, uint32_t offset)
-{
-    STR(cc, Rd, Rn, offset);
-}
-void ARMAssemblerInterface::ADDR_ADD(int cc, int s,
-     int Rd, int Rn, uint32_t Op2)
-{
-    dataProcessing(opADD, cc, s, Rd, Rn, Op2);
-}
-void ARMAssemblerInterface::ADDR_SUB(int cc, int s,
-     int Rd, int Rn, uint32_t Op2)
-{
-    dataProcessing(opSUB, cc, s, Rd, Rn, Op2);
-}
-}; // namespace android
-
diff --git a/libpixelflinger/codeflinger/ARMAssemblerInterface.h b/libpixelflinger/codeflinger/ARMAssemblerInterface.h
deleted file mode 100644
index 72935ac..0000000
--- a/libpixelflinger/codeflinger/ARMAssemblerInterface.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/* libs/pixelflinger/codeflinger/ARMAssemblerInterface.h
-**
-** Copyright 2006, 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_ARMASSEMBLER_INTERFACE_H
-#define ANDROID_ARMASSEMBLER_INTERFACE_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-class ARMAssemblerInterface
-{
-public:
-    virtual ~ARMAssemblerInterface();
-
-    enum {
-        EQ, NE, CS, CC, MI, PL, VS, VC, HI, LS, GE, LT, GT, LE, AL, NV,
-        HS = CS,
-        LO = CC
-    };
-    enum {
-        S = 1
-    };
-    enum {
-        LSL, LSR, ASR, ROR
-    };
-    enum {
-        ED, FD, EA, FA,
-        IB, IA, DB, DA
-    };
-    enum {
-        R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15,
-        SP = R13,
-        LR = R14,
-        PC = R15
-    };
-    enum {
-        #define LIST(rr) L##rr=1<<rr
-        LIST(R0), LIST(R1), LIST(R2), LIST(R3), LIST(R4), LIST(R5), LIST(R6),
-        LIST(R7), LIST(R8), LIST(R9), LIST(R10), LIST(R11), LIST(R12),
-        LIST(R13), LIST(R14), LIST(R15),
-        LIST(SP), LIST(LR), LIST(PC),
-        #undef LIST
-        LSAVED = LR4|LR5|LR6|LR7|LR8|LR9|LR10|LR11 | LLR
-    };
-
-    enum {
-        CODEGEN_ARCH_ARM = 1, CODEGEN_ARCH_MIPS, CODEGEN_ARCH_ARM64, CODEGEN_ARCH_MIPS64
-    };
-
-    // -----------------------------------------------------------------------
-    // shifters and addressing modes
-    // -----------------------------------------------------------------------
-
-    // these static versions are used for initializers on LDxx/STxx below
-    static uint32_t    __immed12_pre(int32_t immed12, int W=0);
-    static uint32_t    __immed8_pre(int32_t immed12, int W=0);
-
-    virtual bool        isValidImmediate(uint32_t immed) = 0;
-    virtual int         buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm) = 0;
-
-    virtual uint32_t    imm(uint32_t immediate) = 0;
-    virtual uint32_t    reg_imm(int Rm, int type, uint32_t shift) = 0;
-    virtual uint32_t    reg_rrx(int Rm) = 0;
-    virtual uint32_t    reg_reg(int Rm, int type, int Rs) = 0;
-
-    // addressing modes... 
-    // LDR(B)/STR(B)/PLD
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed12_pre(int32_t immed12, int W=0) = 0;
-    virtual uint32_t    immed12_post(int32_t immed12) = 0;
-    virtual uint32_t    reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0) = 0;
-    virtual uint32_t    reg_scale_post(int Rm, int type=0, uint32_t shift=0) = 0;
-
-    // LDRH/LDRSB/LDRSH/STRH
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed8_pre(int32_t immed8, int W=0) = 0;
-    virtual uint32_t    immed8_post(int32_t immed8) = 0;
-    virtual uint32_t    reg_pre(int Rm, int W=0) = 0;
-    virtual uint32_t    reg_post(int Rm) = 0;
-
-    // -----------------------------------------------------------------------
-    // basic instructions & code generation
-    // -----------------------------------------------------------------------
-
-    // generate the code
-    virtual void reset() = 0;
-    virtual int  generate(const char* name) = 0;
-    virtual void disassemble(const char* name) = 0;
-    virtual int  getCodegenArch() = 0;
-    
-    // construct prolog and epilog
-    virtual void prolog() = 0;
-    virtual void epilog(uint32_t touched) = 0;
-    virtual void comment(const char* string) = 0;
-
-    // data processing...
-    enum {
-        opAND, opEOR, opSUB, opRSB, opADD, opADC, opSBC, opRSC, 
-        opTST, opTEQ, opCMP, opCMN, opORR, opMOV, opBIC, opMVN,
-        opADD64, opSUB64
-    };
-
-    virtual void
-            dataProcessing( int opcode, int cc, int s,
-                            int Rd, int Rn,
-                            uint32_t Op2) = 0;
-    
-    // multiply...
-    virtual void MLA(int cc, int s,
-                int Rd, int Rm, int Rs, int Rn) = 0;
-    virtual void MUL(int cc, int s,
-                int Rd, int Rm, int Rs) = 0;
-    virtual void UMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs) = 0;
-    virtual void UMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs) = 0;
-    virtual void SMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs) = 0;
-    virtual void SMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs) = 0;
-
-    // branches...
-    virtual void B(int cc, uint32_t* pc) = 0;
-    virtual void BL(int cc, uint32_t* pc) = 0;
-    virtual void BX(int cc, int Rn) = 0;
-
-    virtual void label(const char* theLabel) = 0;
-    virtual void B(int cc, const char* label) = 0;
-    virtual void BL(int cc, const char* label) = 0;
-
-    // valid only after generate() has been called
-    virtual uint32_t* pcForLabel(const char* label) = 0;
-
-    // data transfer...
-    virtual void LDR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0)) = 0;
-    virtual void LDRB(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0)) = 0;
-    virtual void STR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0)) = 0;
-    virtual void STRB(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0)) = 0;
-
-    virtual void LDRH (int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0)) = 0;
-    virtual void LDRSB(int cc, int Rd, 
-                int Rn, uint32_t offset = __immed8_pre(0)) = 0;
-    virtual void LDRSH(int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0)) = 0;
-    virtual void STRH (int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0)) = 0;
-
-    // block data transfer...
-    virtual void LDM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list) = 0;
-    virtual void STM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list) = 0;
-
-    // special...
-    virtual void SWP(int cc, int Rn, int Rd, int Rm) = 0;
-    virtual void SWPB(int cc, int Rn, int Rd, int Rm) = 0;
-    virtual void SWI(int cc, uint32_t comment) = 0;
-
-    // DSP instructions...
-    enum {
-        // B=0, T=1
-        //     yx
-        xyBB = 0, // 0000,
-        xyTB = 2, // 0010,
-        xyBT = 4, // 0100,
-        xyTT = 6, // 0110,
-        yB   = 0, // 0000,
-        yT   = 4, // 0100
-    };
-
-    virtual void PLD(int Rn, uint32_t offset) = 0;
-
-    virtual void CLZ(int cc, int Rd, int Rm) = 0;
-    
-    virtual void QADD(int cc, int Rd, int Rm, int Rn) = 0;
-    virtual void QDADD(int cc, int Rd, int Rm, int Rn) = 0;
-    virtual void QSUB(int cc, int Rd, int Rm, int Rn) = 0;
-    virtual void QDSUB(int cc, int Rd, int Rm, int Rn) = 0;
-    
-    virtual void SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs) = 0;
-    virtual void SMULW(int cc, int y,
-                int Rd, int Rm, int Rs) = 0;
-    virtual void SMLA(int cc, int xy,
-                int Rd, int Rm, int Rs, int Rn) = 0;
-    virtual void SMLAL(int cc, int xy,
-                int RdHi, int RdLo, int Rs, int Rm) = 0;
-    virtual void SMLAW(int cc, int y,
-                int Rd, int Rm, int Rs, int Rn) = 0;
-
-    // byte/half word extract...
-    virtual void UXTB16(int cc, int Rd, int Rm, int rotate) = 0;
-
-    // bit manipulation...
-    virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width) = 0;
-
-    // -----------------------------------------------------------------------
-    // convenience...
-    // -----------------------------------------------------------------------
-    inline void
-    ADC(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opADC, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    ADD(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opADD, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    AND(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opAND, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    BIC(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opBIC, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    EOR(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opEOR, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    MOV(int cc, int s, int Rd, uint32_t Op2) {
-        dataProcessing(opMOV, cc, s, Rd, 0, Op2);
-    }
-    inline void
-    MVN(int cc, int s, int Rd, uint32_t Op2) {
-        dataProcessing(opMVN, cc, s, Rd, 0, Op2);
-    }
-    inline void
-    ORR(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opORR, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    RSB(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opRSB, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    RSC(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opRSC, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    SBC(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opSBC, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    SUB(int cc, int s, int Rd, int Rn, uint32_t Op2) {
-        dataProcessing(opSUB, cc, s, Rd, Rn, Op2);
-    }
-    inline void
-    TEQ(int cc, int Rn, uint32_t Op2) {
-        dataProcessing(opTEQ, cc, 1, 0, Rn, Op2);
-    }
-    inline void
-    TST(int cc, int Rn, uint32_t Op2) {
-        dataProcessing(opTST, cc, 1, 0, Rn, Op2);
-    }
-    inline void
-    CMP(int cc, int Rn, uint32_t Op2) {
-        dataProcessing(opCMP, cc, 1, 0, Rn, Op2);
-    }
-    inline void
-    CMN(int cc, int Rn, uint32_t Op2) {
-        dataProcessing(opCMN, cc, 1, 0, Rn, Op2);
-    }
-
-    inline void SMULBB(int cc, int Rd, int Rm, int Rs) {
-        SMUL(cc, xyBB, Rd, Rm, Rs);    }
-    inline void SMULTB(int cc, int Rd, int Rm, int Rs) {
-        SMUL(cc, xyTB, Rd, Rm, Rs);    }
-    inline void SMULBT(int cc, int Rd, int Rm, int Rs) {
-        SMUL(cc, xyBT, Rd, Rm, Rs);    }
-    inline void SMULTT(int cc, int Rd, int Rm, int Rs) {
-        SMUL(cc, xyTT, Rd, Rm, Rs);    }
-
-    inline void SMULWB(int cc, int Rd, int Rm, int Rs) {
-        SMULW(cc, yB, Rd, Rm, Rs);    }
-    inline void SMULWT(int cc, int Rd, int Rm, int Rs) {
-        SMULW(cc, yT, Rd, Rm, Rs);    }
-
-    inline void
-    SMLABB(int cc, int Rd, int Rm, int Rs, int Rn) {
-        SMLA(cc, xyBB, Rd, Rm, Rs, Rn);    }
-    inline void
-    SMLATB(int cc, int Rd, int Rm, int Rs, int Rn) {
-        SMLA(cc, xyTB, Rd, Rm, Rs, Rn);    }
-    inline void
-    SMLABT(int cc, int Rd, int Rm, int Rs, int Rn) {
-        SMLA(cc, xyBT, Rd, Rm, Rs, Rn);    }
-    inline void
-    SMLATT(int cc, int Rd, int Rm, int Rs, int Rn) {
-        SMLA(cc, xyTT, Rd, Rm, Rs, Rn);    }
-
-    inline void
-    SMLALBB(int cc, int RdHi, int RdLo, int Rs, int Rm) {
-        SMLAL(cc, xyBB, RdHi, RdLo, Rs, Rm);    }
-    inline void
-    SMLALTB(int cc, int RdHi, int RdLo, int Rs, int Rm) {
-        SMLAL(cc, xyTB, RdHi, RdLo, Rs, Rm);    }
-    inline void
-    SMLALBT(int cc, int RdHi, int RdLo, int Rs, int Rm) {
-        SMLAL(cc, xyBT, RdHi, RdLo, Rs, Rm);    }
-    inline void
-    SMLALTT(int cc, int RdHi, int RdLo, int Rs, int Rm) {
-        SMLAL(cc, xyTT, RdHi, RdLo, Rs, Rm);    }
-
-    inline void
-    SMLAWB(int cc, int Rd, int Rm, int Rs, int Rn) {
-        SMLAW(cc, yB, Rd, Rm, Rs, Rn);    }
-    inline void
-    SMLAWT(int cc, int Rd, int Rm, int Rs, int Rn) {
-        SMLAW(cc, yT, Rd, Rm, Rs, Rn);    }
-
-    // Address loading/storing/manipulation
-    virtual void ADDR_LDR(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void ADDR_STR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void ADDR_ADD(int cc, int s, int Rd,
-                int Rn, uint32_t Op2);
-    virtual void ADDR_SUB(int cc, int s, int Rd,
-                int Rn, uint32_t Op2);
-};
-
-}; // namespace android
-
-#endif //ANDROID_ARMASSEMBLER_INTERFACE_H
diff --git a/libpixelflinger/codeflinger/ARMAssemblerProxy.cpp b/libpixelflinger/codeflinger/ARMAssemblerProxy.cpp
deleted file mode 100644
index 816de48..0000000
--- a/libpixelflinger/codeflinger/ARMAssemblerProxy.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/* libs/pixelflinger/codeflinger/ARMAssemblerProxy.cpp
-**
-** Copyright 2006, 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 <stdint.h>
-#include <sys/types.h>
-
-#include "ARMAssemblerProxy.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-ARMAssemblerProxy::ARMAssemblerProxy()
-    : mTarget(0)
-{
-}
-
-ARMAssemblerProxy::ARMAssemblerProxy(ARMAssemblerInterface* target)
-    : mTarget(target)
-{
-}
-
-ARMAssemblerProxy::~ARMAssemblerProxy()
-{
-    delete mTarget;
-}
-
-void ARMAssemblerProxy::setTarget(ARMAssemblerInterface* target)
-{
-    delete mTarget;
-    mTarget = target;
-}
-
-void ARMAssemblerProxy::reset() {
-    mTarget->reset();
-}
-int ARMAssemblerProxy::generate(const char* name) {
-    return mTarget->generate(name);
-}
-void ARMAssemblerProxy::disassemble(const char* name) {
-    return mTarget->disassemble(name);
-}
-int ARMAssemblerProxy::getCodegenArch()
-{
-    return mTarget->getCodegenArch();
-}
-void ARMAssemblerProxy::prolog() {
-    mTarget->prolog();
-}
-void ARMAssemblerProxy::epilog(uint32_t touched) {
-    mTarget->epilog(touched);
-}
-void ARMAssemblerProxy::comment(const char* string) {
-    mTarget->comment(string);
-}
-
-
-
-// addressing modes
-
-bool ARMAssemblerProxy::isValidImmediate(uint32_t immed)
-{
-    return mTarget->isValidImmediate(immed);
-}
-
-int ARMAssemblerProxy::buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm)
-{
-    return mTarget->buildImmediate(i, rot, imm);
-}
-
-
-
-uint32_t ARMAssemblerProxy::imm(uint32_t immediate)
-{
-    return mTarget->imm(immediate);
-}
-
-uint32_t ARMAssemblerProxy::reg_imm(int Rm, int type, uint32_t shift)
-{
-    return mTarget->reg_imm(Rm, type, shift);
-}
-
-uint32_t ARMAssemblerProxy::reg_rrx(int Rm)
-{
-    return mTarget->reg_rrx(Rm);
-}
-
-uint32_t ARMAssemblerProxy::reg_reg(int Rm, int type, int Rs)
-{
-    return mTarget->reg_reg(Rm, type, Rs);
-}
-
-
-// addressing modes...
-// LDR(B)/STR(B)/PLD
-// (immediate and Rm can be negative, which indicates U=0)
-uint32_t ARMAssemblerProxy::immed12_pre(int32_t immed12, int W)
-{
-    return mTarget->immed12_pre(immed12, W);
-}
-
-uint32_t ARMAssemblerProxy::immed12_post(int32_t immed12)
-{
-    return mTarget->immed12_post(immed12);
-}
-
-uint32_t ARMAssemblerProxy::reg_scale_pre(int Rm, int type, uint32_t shift, int W)
-{
-    return mTarget->reg_scale_pre(Rm, type, shift, W);
-}
-
-uint32_t ARMAssemblerProxy::reg_scale_post(int Rm, int type, uint32_t shift)
-{
-    return mTarget->reg_scale_post(Rm, type, shift);
-}
-
-
-// LDRH/LDRSB/LDRSH/STRH
-// (immediate and Rm can be negative, which indicates U=0)
-uint32_t ARMAssemblerProxy::immed8_pre(int32_t immed8, int W)
-{
-    return mTarget->immed8_pre(immed8, W);
-}
-
-uint32_t ARMAssemblerProxy::immed8_post(int32_t immed8)
-{
-    return mTarget->immed8_post(immed8);
-}
-
-uint32_t ARMAssemblerProxy::reg_pre(int Rm, int W)
-{
-    return mTarget->reg_pre(Rm, W);
-}
-
-uint32_t ARMAssemblerProxy::reg_post(int Rm)
-{
-    return mTarget->reg_post(Rm);
-}
-
-
-//------------------------------------------------------------------------
-
-
-
-void ARMAssemblerProxy::dataProcessing( int opcode, int cc, int s,
-                                        int Rd, int Rn, uint32_t Op2)
-{
-    mTarget->dataProcessing(opcode, cc, s, Rd, Rn, Op2);
-}
-
-void ARMAssemblerProxy::MLA(int cc, int s, int Rd, int Rm, int Rs, int Rn) {
-    mTarget->MLA(cc, s, Rd, Rm, Rs, Rn);
-}
-void ARMAssemblerProxy::MUL(int cc, int s, int Rd, int Rm, int Rs) {
-    mTarget->MUL(cc, s, Rd, Rm, Rs);
-}
-void ARMAssemblerProxy::UMULL(int cc, int s,
-            int RdLo, int RdHi, int Rm, int Rs) {
-    mTarget->UMULL(cc, s, RdLo, RdHi, Rm, Rs); 
-}
-void ARMAssemblerProxy::UMUAL(int cc, int s,
-            int RdLo, int RdHi, int Rm, int Rs) {
-    mTarget->UMUAL(cc, s, RdLo, RdHi, Rm, Rs); 
-}
-void ARMAssemblerProxy::SMULL(int cc, int s,
-            int RdLo, int RdHi, int Rm, int Rs) {
-    mTarget->SMULL(cc, s, RdLo, RdHi, Rm, Rs); 
-}
-void ARMAssemblerProxy::SMUAL(int cc, int s,
-            int RdLo, int RdHi, int Rm, int Rs) {
-    mTarget->SMUAL(cc, s, RdLo, RdHi, Rm, Rs); 
-}
-
-void ARMAssemblerProxy::B(int cc, uint32_t* pc) {
-    mTarget->B(cc, pc); 
-}
-void ARMAssemblerProxy::BL(int cc, uint32_t* pc) {
-    mTarget->BL(cc, pc); 
-}
-void ARMAssemblerProxy::BX(int cc, int Rn) {
-    mTarget->BX(cc, Rn); 
-}
-void ARMAssemblerProxy::label(const char* theLabel) {
-    mTarget->label(theLabel);
-}
-void ARMAssemblerProxy::B(int cc, const char* label) {
-    mTarget->B(cc, label);
-}
-void ARMAssemblerProxy::BL(int cc, const char* label) {
-    mTarget->BL(cc, label);
-}
-
-uint32_t* ARMAssemblerProxy::pcForLabel(const char* label) {
-    return mTarget->pcForLabel(label);
-}
-
-void ARMAssemblerProxy::LDR(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->LDR(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::LDRB(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->LDRB(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::STR(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->STR(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::STRB(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->STRB(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::LDRH(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->LDRH(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::LDRSB(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->LDRSB(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::LDRSH(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->LDRSH(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::STRH(int cc, int Rd, int Rn, uint32_t offset) {
-    mTarget->STRH(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::LDM(int cc, int dir, int Rn, int W, uint32_t reg_list) {
-    mTarget->LDM(cc, dir, Rn, W, reg_list);
-}
-void ARMAssemblerProxy::STM(int cc, int dir, int Rn, int W, uint32_t reg_list) {
-    mTarget->STM(cc, dir, Rn, W, reg_list);
-}
-
-void ARMAssemblerProxy::SWP(int cc, int Rn, int Rd, int Rm) {
-    mTarget->SWP(cc, Rn, Rd, Rm);
-}
-void ARMAssemblerProxy::SWPB(int cc, int Rn, int Rd, int Rm) {
-    mTarget->SWPB(cc, Rn, Rd, Rm);
-}
-void ARMAssemblerProxy::SWI(int cc, uint32_t comment) {
-    mTarget->SWI(cc, comment);
-}
-
-
-void ARMAssemblerProxy::PLD(int Rn, uint32_t offset) {
-    mTarget->PLD(Rn, offset);
-}
-void ARMAssemblerProxy::CLZ(int cc, int Rd, int Rm) {
-    mTarget->CLZ(cc, Rd, Rm);
-}
-void ARMAssemblerProxy::QADD(int cc, int Rd, int Rm, int Rn) {
-    mTarget->QADD(cc, Rd, Rm, Rn);
-}
-void ARMAssemblerProxy::QDADD(int cc, int Rd, int Rm, int Rn) {
-    mTarget->QDADD(cc, Rd, Rm, Rn);
-}
-void ARMAssemblerProxy::QSUB(int cc, int Rd, int Rm, int Rn) {
-    mTarget->QSUB(cc, Rd, Rm, Rn);
-}
-void ARMAssemblerProxy::QDSUB(int cc, int Rd, int Rm, int Rn) {
-    mTarget->QDSUB(cc, Rd, Rm, Rn);
-}
-void ARMAssemblerProxy::SMUL(int cc, int xy, int Rd, int Rm, int Rs) {
-    mTarget->SMUL(cc, xy, Rd, Rm, Rs);
-}
-void ARMAssemblerProxy::SMULW(int cc, int y, int Rd, int Rm, int Rs) {
-    mTarget->SMULW(cc, y, Rd, Rm, Rs);
-}
-void ARMAssemblerProxy::SMLA(int cc, int xy, int Rd, int Rm, int Rs, int Rn) {
-    mTarget->SMLA(cc, xy, Rd, Rm, Rs, Rn);
-}
-void ARMAssemblerProxy::SMLAL(  int cc, int xy,
-                                int RdHi, int RdLo, int Rs, int Rm) {
-    mTarget->SMLAL(cc, xy, RdHi, RdLo, Rs, Rm);
-}
-void ARMAssemblerProxy::SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) {
-    mTarget->SMLAW(cc, y, Rd, Rm, Rs, Rn);
-}
-
-void ARMAssemblerProxy::UXTB16(int cc, int Rd, int Rm, int rotate) {
-    mTarget->UXTB16(cc, Rd, Rm, rotate);
-}
-
-void ARMAssemblerProxy::UBFX(int cc, int Rd, int Rn, int lsb, int width) {
-    mTarget->UBFX(cc, Rd, Rn, lsb, width);
-}
-
-void ARMAssemblerProxy::ADDR_LDR(int cc, int Rd, int Rn, uint32_t offset) {
-     mTarget->ADDR_LDR(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::ADDR_STR(int cc, int Rd, int Rn, uint32_t offset) {
-     mTarget->ADDR_STR(cc, Rd, Rn, offset);
-}
-void ARMAssemblerProxy::ADDR_ADD(int cc, int s, int Rd, int Rn, uint32_t Op2){
-     mTarget->ADDR_ADD(cc, s, Rd, Rn, Op2);
-}
-void ARMAssemblerProxy::ADDR_SUB(int cc, int s, int Rd, int Rn, uint32_t Op2){
-     mTarget->ADDR_SUB(cc, s, Rd, Rn, Op2);
-}
-
-}; // namespace android
-
diff --git a/libpixelflinger/codeflinger/ARMAssemblerProxy.h b/libpixelflinger/codeflinger/ARMAssemblerProxy.h
deleted file mode 100644
index 10d0390..0000000
--- a/libpixelflinger/codeflinger/ARMAssemblerProxy.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/* libs/pixelflinger/codeflinger/ARMAssemblerProxy.h
-**
-** Copyright 2006, 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_ARMASSEMBLER_PROXY_H
-#define ANDROID_ARMASSEMBLER_PROXY_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "ARMAssemblerInterface.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-class ARMAssemblerProxy : public ARMAssemblerInterface
-{
-public:
-    // ARMAssemblerProxy take ownership of the target
-
-                ARMAssemblerProxy();
-    explicit    ARMAssemblerProxy(ARMAssemblerInterface* target);
-    virtual     ~ARMAssemblerProxy();
-
-    void setTarget(ARMAssemblerInterface* target);
-
-    virtual void    reset();
-    virtual int     generate(const char* name);
-    virtual void    disassemble(const char* name);
-    virtual int     getCodegenArch();
-
-    virtual void    prolog();
-    virtual void    epilog(uint32_t touched);
-    virtual void    comment(const char* string);
-
-    // -----------------------------------------------------------------------
-    // shifters and addressing modes
-    // -----------------------------------------------------------------------
-
-    virtual bool        isValidImmediate(uint32_t immed);
-    virtual int         buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
-
-    virtual uint32_t    imm(uint32_t immediate);
-    virtual uint32_t    reg_imm(int Rm, int type, uint32_t shift);
-    virtual uint32_t    reg_rrx(int Rm);
-    virtual uint32_t    reg_reg(int Rm, int type, int Rs);
-
-    // addressing modes...
-    // LDR(B)/STR(B)/PLD
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed12_pre(int32_t immed12, int W=0);
-    virtual uint32_t    immed12_post(int32_t immed12);
-    virtual uint32_t    reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
-    virtual uint32_t    reg_scale_post(int Rm, int type=0, uint32_t shift=0);
-
-    // LDRH/LDRSB/LDRSH/STRH
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed8_pre(int32_t immed8, int W=0);
-    virtual uint32_t    immed8_post(int32_t immed8);
-    virtual uint32_t    reg_pre(int Rm, int W=0);
-    virtual uint32_t    reg_post(int Rm);
-
-
-    virtual void    dataProcessing(int opcode, int cc, int s,
-                                int Rd, int Rn,
-                                uint32_t Op2);
-    virtual void MLA(int cc, int s,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void MUL(int cc, int s,
-                int Rd, int Rm, int Rs);
-    virtual void UMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void UMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-
-    virtual void B(int cc, uint32_t* pc);
-    virtual void BL(int cc, uint32_t* pc);
-    virtual void BX(int cc, int Rn);
-    virtual void label(const char* theLabel);
-    virtual void B(int cc, const char* label);
-    virtual void BL(int cc, const char* label);
-
-    uint32_t* pcForLabel(const char* label);
-
-    virtual void LDR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void LDRB(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void STR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void STRB(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void LDRH (int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0));
-    virtual void LDRSB(int cc, int Rd, 
-                int Rn, uint32_t offset = __immed8_pre(0));
-    virtual void LDRSH(int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0));
-    virtual void STRH (int cc, int Rd,
-                int Rn, uint32_t offset = __immed8_pre(0));
-    virtual void LDM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-    virtual void STM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-
-    virtual void SWP(int cc, int Rn, int Rd, int Rm);
-    virtual void SWPB(int cc, int Rn, int Rd, int Rm);
-    virtual void SWI(int cc, uint32_t comment);
-
-    virtual void PLD(int Rn, uint32_t offset);
-    virtual void CLZ(int cc, int Rd, int Rm);
-    virtual void QADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QDADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs);
-    virtual void SMULW(int cc, int y,
-                int Rd, int Rm, int Rs);
-    virtual void SMLA(int cc, int xy,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void SMLAL(int cc, int xy,
-                int RdHi, int RdLo, int Rs, int Rm);
-    virtual void SMLAW(int cc, int y,
-                int Rd, int Rm, int Rs, int Rn);
-
-    virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
-    virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
-
-    virtual void ADDR_LDR(int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void ADDR_STR (int cc, int Rd,
-                int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void ADDR_ADD(int cc, int s, int Rd,
-                int Rn, uint32_t Op2);
-    virtual void ADDR_SUB(int cc, int s, int Rd,
-                int Rn, uint32_t Op2);
-
-private:
-    ARMAssemblerInterface*  mTarget;
-};
-
-}; // namespace android
-
-#endif //ANDROID_ARMASSEMBLER_PROXY_H
diff --git a/libpixelflinger/codeflinger/Arm64Assembler.cpp b/libpixelflinger/codeflinger/Arm64Assembler.cpp
deleted file mode 100644
index 8926776..0000000
--- a/libpixelflinger/codeflinger/Arm64Assembler.cpp
+++ /dev/null
@@ -1,1240 +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.
- */
-
-#define LOG_TAG "ArmToArm64Assembler"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <cutils/properties.h>
-#include <log/log.h>
-#include <private/pixelflinger/ggl_context.h>
-
-#include "codeflinger/Arm64Assembler.h"
-#include "codeflinger/Arm64Disassembler.h"
-#include "codeflinger/CodeCache.h"
-
-/*
-** --------------------------------------------
-** Support for Arm64 in GGLAssembler JIT
-** --------------------------------------------
-**
-** Approach
-** - GGLAssembler and associated files are largely un-changed.
-** - A translator class maps ArmAssemblerInterface calls to
-**   generate Arm64 instructions.
-**
-** ----------------------
-** ArmToArm64Assembler
-** ----------------------
-**
-** - Subclassed from ArmAssemblerInterface
-**
-** - Translates each ArmAssemblerInterface call to generate
-**   one or more Arm64 instructions  as necessary.
-**
-** - Does not implement ArmAssemblerInterface portions unused by GGLAssembler
-**   It calls NOT_IMPLEMENTED() for such cases, which in turn logs
-**    a fatal message.
-**
-** - Uses A64_.. series of functions to generate instruction machine code
-**   for Arm64 instructions. These functions also log the instruction
-**   to LOG, if ARM64_ASM_DEBUG define is set to 1
-**
-** - Dumps machine code and eqvt assembly if "debug.pf.disasm" option is set
-**   It uses arm64_disassemble to perform disassembly
-**
-** - Uses register 13 (SP in ARM), 15 (PC in ARM), 16, 17 for storing
-**   intermediate results. GGLAssembler does not use SP and PC as these
-**   registers are marked as reserved. The temporary registers are not
-**   saved/restored on stack as these are caller-saved registers in Arm64
-**
-** - Uses CSEL instruction to support conditional execution. The result is
-**   stored in a temporary register and then copied to the target register
-**   if the condition is true.
-**
-** - In the case of conditional data transfer instructions, conditional
-**   branch is used to skip over instruction, if the condition is false
-**
-** - Wherever possible, immediate values are transferred to temporary
-**   register prior to processing. This simplifies overall implementation
-**   as instructions requiring immediate values are converted to
-**   move immediate instructions followed by register-register instruction.
-**
-** --------------------------------------------
-** ArmToArm64Assembler unit test bench
-** --------------------------------------------
-**
-** - Tests ArmToArm64Assembler interface for all the possible
-**   ways in which GGLAssembler uses ArmAssemblerInterface interface.
-**
-** - Uses test jacket (written in assembly) to set the registers,
-**   condition flags prior to calling generated instruction. It also
-**   copies registers and flags at the end of execution. Caller then
-**   checks if generated code performed correct operation based on
-**   output registers and flags.
-**
-** - Broadly contains three type of tests, (i) data operation tests
-**   (ii) data transfer tests and (iii) LDM/STM tests.
-**
-** ----------------------
-** Arm64 disassembler
-** ----------------------
-** - This disassembler disassembles only those machine codes which can be
-**   generated by ArmToArm64Assembler. It has a unit testbench which
-**   tests all the instructions supported by the disassembler.
-**
-** ------------------------------------------------------------------
-** ARMAssembler/ARMAssemblerInterface/ARMAssemblerProxy changes
-** ------------------------------------------------------------------
-**
-** - In existing code, addresses were being handled as 32 bit values at
-**   certain places.
-**
-** - Added a new set of functions for address load/store/manipulation.
-**   These are ADDR_LDR, ADDR_STR, ADDR_ADD, ADDR_SUB and they map to
-**   default 32 bit implementations in ARMAssemblerInterface.
-**
-** - ArmToArm64Assembler maps these functions to appropriate 64 bit
-**   functions.
-**
-** ----------------------
-** GGLAssembler changes
-** ----------------------
-** - Since ArmToArm64Assembler can generate 4 Arm64 instructions for
-**   each call in worst case, the memory required is set to 4 times
-**   ARM memory
-**
-** - Address load/store/manipulation were changed to use new functions
-**   added in the ARMAssemblerInterface.
-**
-*/
-
-
-#define NOT_IMPLEMENTED()  LOG_FATAL("Arm instruction %s not yet implemented\n", __func__)
-
-#define ARM64_ASM_DEBUG 0
-
-#if ARM64_ASM_DEBUG
-    #define LOG_INSTR(...) ALOGD("\t" __VA_ARGS__)
-    #define LOG_LABEL(...) ALOGD(__VA_ARGS__)
-#else
-    #define LOG_INSTR(...) ((void)0)
-    #define LOG_LABEL(...) ((void)0)
-#endif
-
-namespace android {
-
-static __unused const char* shift_codes[] =
-{
-    "LSL", "LSR", "ASR", "ROR"
-};
-static __unused const char *cc_codes[] =
-{
-    "EQ", "NE", "CS", "CC", "MI",
-    "PL", "VS", "VC", "HI", "LS",
-    "GE", "LT", "GT", "LE", "AL", "NV"
-};
-
-ArmToArm64Assembler::ArmToArm64Assembler(const sp<Assembly>& assembly)
-    :   ARMAssemblerInterface(),
-        mAssembly(assembly)
-{
-    mBase = mPC = (uint32_t *)assembly->base();
-    mDuration = ggl_system_time();
-    mZeroReg = 13;
-    mTmpReg1 = 15;
-    mTmpReg2 = 16;
-    mTmpReg3 = 17;
-}
-
-ArmToArm64Assembler::ArmToArm64Assembler(void *base)
-    :   ARMAssemblerInterface(), mAssembly(NULL)
-{
-    mBase = mPC = (uint32_t *)base;
-    mDuration = ggl_system_time();
-    // Regs 13, 15, 16, 17 are used as temporary registers
-    mZeroReg = 13;
-    mTmpReg1 = 15;
-    mTmpReg2 = 16;
-    mTmpReg3 = 17;
-}
-
-ArmToArm64Assembler::~ArmToArm64Assembler()
-{
-}
-
-uint32_t* ArmToArm64Assembler::pc() const
-{
-    return mPC;
-}
-
-uint32_t* ArmToArm64Assembler::base() const
-{
-    return mBase;
-}
-
-void ArmToArm64Assembler::reset()
-{
-    if(mAssembly == NULL)
-        mPC = mBase;
-    else
-        mBase = mPC = (uint32_t *)mAssembly->base();
-    mBranchTargets.clear();
-    mLabels.clear();
-    mLabelsInverseMapping.clear();
-    mComments.clear();
-#if ARM64_ASM_DEBUG
-    ALOGI("RESET\n");
-#endif
-}
-
-int ArmToArm64Assembler::getCodegenArch()
-{
-    return CODEGEN_ARCH_ARM64;
-}
-
-// ----------------------------------------------------------------------------
-
-void ArmToArm64Assembler::disassemble(const char* name)
-{
-    if(name)
-    {
-        printf("%s:\n", name);
-    }
-    size_t count = pc()-base();
-    uint32_t* i = base();
-    while (count--)
-    {
-        ssize_t label = mLabelsInverseMapping.indexOfKey(i);
-        if (label >= 0)
-        {
-            printf("%s:\n", mLabelsInverseMapping.valueAt(label));
-        }
-        ssize_t comment = mComments.indexOfKey(i);
-        if (comment >= 0)
-        {
-            printf("; %s\n", mComments.valueAt(comment));
-        }
-        printf("%p:    %08x    ", i, uint32_t(i[0]));
-        {
-            char instr[256];
-            ::arm64_disassemble(*i, instr);
-            printf("%s\n", instr);
-        }
-        i++;
-    }
-}
-
-void ArmToArm64Assembler::comment(const char* string)
-{
-    mComments.add(mPC, string);
-    LOG_INSTR("//%s\n", string);
-}
-
-void ArmToArm64Assembler::label(const char* theLabel)
-{
-    mLabels.add(theLabel, mPC);
-    mLabelsInverseMapping.add(mPC, theLabel);
-    LOG_LABEL("%s:\n", theLabel);
-}
-
-void ArmToArm64Assembler::B(int cc, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    LOG_INSTR("B%s %s\n", cc_codes[cc], label );
-    *mPC++ = (0x54 << 24) | cc;
-}
-
-void ArmToArm64Assembler::BL(int /*cc*/, const char* /*label*/)
-{
-    NOT_IMPLEMENTED(); //Not Required
-}
-
-// ----------------------------------------------------------------------------
-//Prolog/Epilog & Generate...
-// ----------------------------------------------------------------------------
-
-void ArmToArm64Assembler::prolog()
-{
-    // write prolog code
-    mPrologPC = mPC;
-    *mPC++ = A64_MOVZ_X(mZeroReg,0,0);
-}
-
-void ArmToArm64Assembler::epilog(uint32_t /*touched*/)
-{
-    // write epilog code
-    static const int XLR = 30;
-    *mPC++ = A64_RET(XLR);
-}
-
-int ArmToArm64Assembler::generate(const char* name)
-{
-    // fixup all the branches
-    size_t count = mBranchTargets.size();
-    while (count--)
-    {
-        const branch_target_t& bt = mBranchTargets[count];
-        uint32_t* target_pc = mLabels.valueFor(bt.label);
-        LOG_ALWAYS_FATAL_IF(!target_pc,
-                "error resolving branch targets, target_pc is null");
-        int32_t offset = int32_t(target_pc - bt.pc);
-        *bt.pc |= (offset & 0x7FFFF) << 5;
-    }
-
-    if(mAssembly != NULL)
-        mAssembly->resize( int(pc()-base())*4 );
-
-    // the instruction cache is flushed by CodeCache
-    const int64_t duration = ggl_system_time() - mDuration;
-    const char * const format = "generated %s (%d ins) at [%p:%p] in %ld ns\n";
-    ALOGI(format, name, int(pc()-base()), base(), pc(), duration);
-
-
-    char value[PROPERTY_VALUE_MAX];
-    property_get("debug.pf.disasm", value, "0");
-    if (atoi(value) != 0)
-    {
-        printf(format, name, int(pc()-base()), base(), pc(), duration);
-        disassemble(name);
-    }
-    return OK;
-}
-
-uint32_t* ArmToArm64Assembler::pcForLabel(const char* label)
-{
-    return mLabels.valueFor(label);
-}
-
-// ----------------------------------------------------------------------------
-// Data Processing...
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::dataProcessingCommon(int opcode,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-    if(opcode != opSUB && s == 1)
-    {
-        NOT_IMPLEMENTED(); //Not required
-        return;
-    }
-
-    if(opcode != opSUB && opcode != opADD && opcode != opAND &&
-       opcode != opORR && opcode != opMVN)
-    {
-        NOT_IMPLEMENTED(); //Not required
-        return;
-    }
-
-    if(Op2 == OPERAND_REG_IMM && mAddrMode.reg_imm_shift > 31)
-        {
-        NOT_IMPLEMENTED();
-        return;
-    }
-
-    //Store immediate in temporary register and convert
-    //immediate operation into register operation
-    if(Op2 == OPERAND_IMM)
-    {
-        int imm = mAddrMode.immediate;
-        *mPC++ = A64_MOVZ_W(mTmpReg2, imm & 0x0000FFFF, 0);
-        *mPC++ = A64_MOVK_W(mTmpReg2, (imm >> 16) & 0x0000FFFF, 16);
-        Op2 = mTmpReg2;
-    }
-
-
-    {
-        uint32_t shift;
-        uint32_t amount;
-        uint32_t Rm;
-
-        if(Op2 == OPERAND_REG_IMM)
-        {
-            shift   = mAddrMode.reg_imm_type;
-            amount  = mAddrMode.reg_imm_shift;
-            Rm      = mAddrMode.reg_imm_Rm;
-        }
-        else if(Op2 < OPERAND_REG)
-        {
-            shift   = 0;
-            amount  = 0;
-            Rm      = Op2;
-        }
-        else
-        {
-            NOT_IMPLEMENTED(); //Not required
-            return;
-        }
-
-        switch(opcode)
-        {
-            case opADD: *mPC++ = A64_ADD_W(Rd, Rn, Rm, shift, amount); break;
-            case opAND: *mPC++ = A64_AND_W(Rd, Rn, Rm, shift, amount); break;
-            case opORR: *mPC++ = A64_ORR_W(Rd, Rn, Rm, shift, amount); break;
-            case opMVN: *mPC++ = A64_ORN_W(Rd, Rn, Rm, shift, amount); break;
-            case opSUB: *mPC++ = A64_SUB_W(Rd, Rn, Rm, shift, amount, s);break;
-        };
-
-    }
-}
-
-void ArmToArm64Assembler::dataProcessing(int opcode, int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-    uint32_t Wd;
-
-    if(cc != AL)
-        Wd = mTmpReg1;
-    else
-        Wd = Rd;
-
-    if(opcode == opADD || opcode == opAND || opcode == opORR ||opcode == opSUB)
-    {
-        dataProcessingCommon(opcode, s, Wd, Rn, Op2);
-    }
-    else if(opcode == opCMP)
-    {
-        dataProcessingCommon(opSUB, 1, mTmpReg3, Rn, Op2);
-    }
-    else if(opcode == opRSB)
-    {
-        dataProcessingCommon(opSUB, s, Wd, Rn, Op2);
-        dataProcessingCommon(opSUB, s, Wd, mZeroReg, Wd);
-    }
-    else if(opcode == opMOV)
-    {
-        dataProcessingCommon(opORR, 0, Wd, mZeroReg, Op2);
-        if(s == 1)
-        {
-            dataProcessingCommon(opSUB, 1, mTmpReg3, Wd, mZeroReg);
-        }
-    }
-    else if(opcode == opMVN)
-    {
-        dataProcessingCommon(opMVN, s, Wd, mZeroReg, Op2);
-    }
-    else if(opcode == opBIC)
-    {
-        dataProcessingCommon(opMVN, s, mTmpReg3, mZeroReg, Op2);
-        dataProcessingCommon(opAND, s, Wd, Rn, mTmpReg3);
-    }
-    else
-    {
-        NOT_IMPLEMENTED();
-        return;
-    }
-
-    if(cc != AL)
-    {
-        *mPC++ = A64_CSEL_W(Rd, mTmpReg1, Rd, cc);
-    }
-}
-// ----------------------------------------------------------------------------
-// Address Processing...
-// ----------------------------------------------------------------------------
-
-void ArmToArm64Assembler::ADDR_ADD(int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-    if(s  != 0) { NOT_IMPLEMENTED(); return;} //Not required
-
-
-    if(Op2 == OPERAND_REG_IMM && mAddrMode.reg_imm_type == LSL)
-    {
-        int Rm = mAddrMode.reg_imm_Rm;
-        int amount = mAddrMode.reg_imm_shift;
-        *mPC++ = A64_ADD_X_Wm_SXTW(Rd, Rn, Rm, amount);
-    }
-    else if(Op2 < OPERAND_REG)
-    {
-        int Rm = Op2;
-        int amount = 0;
-        *mPC++ = A64_ADD_X_Wm_SXTW(Rd, Rn, Rm, amount);
-    }
-    else if(Op2 == OPERAND_IMM)
-    {
-        int imm = mAddrMode.immediate;
-        *mPC++ = A64_MOVZ_W(mTmpReg1, imm & 0x0000FFFF, 0);
-        *mPC++ = A64_MOVK_W(mTmpReg1, (imm >> 16) & 0x0000FFFF, 16);
-
-        int Rm = mTmpReg1;
-        int amount = 0;
-        *mPC++ = A64_ADD_X_Wm_SXTW(Rd, Rn, Rm, amount);
-    }
-    else
-    {
-        NOT_IMPLEMENTED(); //Not required
-    }
-}
-
-void ArmToArm64Assembler::ADDR_SUB(int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-    if(s  != 0) { NOT_IMPLEMENTED(); return;} //Not required
-
-    if(Op2 == OPERAND_REG_IMM && mAddrMode.reg_imm_type == LSR)
-    {
-        *mPC++ = A64_ADD_W(mTmpReg1, mZeroReg, mAddrMode.reg_imm_Rm,
-                           LSR, mAddrMode.reg_imm_shift);
-        *mPC++ = A64_SUB_X_Wm_SXTW(Rd, Rn, mTmpReg1, 0);
-    }
-    else
-    {
-        NOT_IMPLEMENTED(); //Not required
-    }
-}
-
-// ----------------------------------------------------------------------------
-// multiply...
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::MLA(int cc, int s,int Rd, int Rm, int Rs, int Rn)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-
-    *mPC++ = A64_MADD_W(Rd, Rm, Rs, Rn);
-    if(s == 1)
-        dataProcessingCommon(opSUB, 1, mTmpReg1, Rd, mZeroReg);
-}
-void ArmToArm64Assembler::MUL(int cc, int s, int Rd, int Rm, int Rs)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-    if(s  != 0) { NOT_IMPLEMENTED(); return;} //Not required
-    *mPC++ = A64_MADD_W(Rd, Rm, Rs, mZeroReg);
-}
-void ArmToArm64Assembler::UMULL(int /*cc*/, int /*s*/,
-        int /*RdLo*/, int /*RdHi*/, int /*Rm*/, int /*Rs*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-void ArmToArm64Assembler::UMUAL(int /*cc*/, int /*s*/,
-        int /*RdLo*/, int /*RdHi*/, int /*Rm*/, int /*Rs*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-void ArmToArm64Assembler::SMULL(int /*cc*/, int /*s*/,
-        int /*RdLo*/, int /*RdHi*/, int /*Rm*/, int /*Rs*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-void ArmToArm64Assembler::SMUAL(int /*cc*/, int /*s*/,
-        int /*RdLo*/, int /*RdHi*/, int /*Rm*/, int /*Rs*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-// ----------------------------------------------------------------------------
-// branches relative to PC...
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::B(int /*cc*/, uint32_t* /*pc*/){
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::BL(int /*cc*/, uint32_t* /*pc*/){
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::BX(int /*cc*/, int /*Rn*/){
-    NOT_IMPLEMENTED(); //Not required
-}
-
-// ----------------------------------------------------------------------------
-// data transfer...
-// ----------------------------------------------------------------------------
-enum dataTransferOp
-{
-    opLDR,opLDRB,opLDRH,opSTR,opSTRB,opSTRH
-};
-
-void ArmToArm64Assembler::dataTransfer(int op, int cc,
-                            int Rd, int Rn, uint32_t op_type, uint32_t size)
-{
-    const int XSP = 31;
-    if(Rn == SP)
-        Rn = XSP;
-
-    if(op_type == OPERAND_IMM)
-    {
-        int addrReg;
-        int imm = mAddrMode.immediate;
-        if(imm >= 0 && imm < (1<<12))
-            *mPC++ = A64_ADD_IMM_X(mTmpReg1, mZeroReg, imm, 0);
-        else if(imm < 0 && -imm < (1<<12))
-            *mPC++ = A64_SUB_IMM_X(mTmpReg1, mZeroReg, -imm, 0);
-        else
-        {
-            NOT_IMPLEMENTED();
-            return;
-        }
-
-        addrReg = Rn;
-        if(mAddrMode.preindex == true || mAddrMode.postindex == true)
-        {
-            *mPC++ = A64_ADD_X(mTmpReg2, addrReg, mTmpReg1);
-            if(mAddrMode.preindex == true)
-                addrReg = mTmpReg2;
-        }
-
-        if(cc != AL)
-            *mPC++ = A64_B_COND(cc^1, 8);
-
-        *mPC++ = A64_LDRSTR_Wm_SXTW_0(op, size, Rd, addrReg, mZeroReg);
-
-        if(mAddrMode.writeback == true)
-            *mPC++ = A64_CSEL_X(Rn, mTmpReg2, Rn, cc);
-    }
-    else if(op_type == OPERAND_REG_OFFSET)
-    {
-        if(cc != AL)
-            *mPC++ = A64_B_COND(cc^1, 8);
-        *mPC++ = A64_LDRSTR_Wm_SXTW_0(op, size, Rd, Rn, mAddrMode.reg_offset);
-
-    }
-    else if(op_type > OPERAND_UNSUPPORTED)
-    {
-        if(cc != AL)
-            *mPC++ = A64_B_COND(cc^1, 8);
-        *mPC++ = A64_LDRSTR_Wm_SXTW_0(op, size, Rd, Rn, mZeroReg);
-    }
-    else
-    {
-        NOT_IMPLEMENTED(); // Not required
-    }
-    return;
-
-}
-void ArmToArm64Assembler::ADDR_LDR(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opLDR, cc, Rd, Rn, op_type, 64);
-}
-void ArmToArm64Assembler::ADDR_STR(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opSTR, cc, Rd, Rn, op_type, 64);
-}
-void ArmToArm64Assembler::LDR(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opLDR, cc, Rd, Rn, op_type);
-}
-void ArmToArm64Assembler::LDRB(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opLDRB, cc, Rd, Rn, op_type);
-}
-void ArmToArm64Assembler::STR(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opSTR, cc, Rd, Rn, op_type);
-}
-
-void ArmToArm64Assembler::STRB(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opSTRB, cc, Rd, Rn, op_type);
-}
-
-void ArmToArm64Assembler::LDRH(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opLDRH, cc, Rd, Rn, op_type);
-}
-void ArmToArm64Assembler::LDRSB(int /*cc*/, int /*Rd*/, int /*Rn*/, uint32_t /*offset*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-void ArmToArm64Assembler::LDRSH(int /*cc*/, int /*Rd*/, int /*Rn*/, uint32_t /*offset*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::STRH(int cc, int Rd, int Rn, uint32_t op_type)
-{
-    return dataTransfer(opSTRH, cc, Rd, Rn, op_type);
-}
-
-// ----------------------------------------------------------------------------
-// block data transfer...
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::LDM(int cc, int dir,
-        int Rn, int W, uint32_t reg_list)
-{
-    const int XSP = 31;
-    if(cc != AL || dir != IA || W == 0 || Rn != SP)
-    {
-        NOT_IMPLEMENTED();
-        return;
-    }
-
-    for(int i = 0; i < 32; ++i)
-    {
-        if((reg_list & (1 << i)))
-        {
-            int reg = i;
-            int size = 16;
-            *mPC++ = A64_LDR_IMM_PostIndex(reg, XSP, size);
-        }
-    }
-}
-
-void ArmToArm64Assembler::STM(int cc, int dir,
-        int Rn, int W, uint32_t reg_list)
-{
-    const int XSP = 31;
-    if(cc != AL || dir != DB || W == 0 || Rn != SP)
-    {
-        NOT_IMPLEMENTED();
-        return;
-    }
-
-    for(int i = 31; i >= 0; --i)
-    {
-        if((reg_list & (1 << i)))
-        {
-            int size = -16;
-            int reg  = i;
-            *mPC++ = A64_STR_IMM_PreIndex(reg, XSP, size);
-        }
-    }
-}
-
-// ----------------------------------------------------------------------------
-// special...
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::SWP(int /*cc*/, int /*Rn*/, int /*Rd*/, int /*Rm*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-void ArmToArm64Assembler::SWPB(int /*cc*/, int /*Rn*/, int /*Rd*/, int /*Rm*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-void ArmToArm64Assembler::SWI(int /*cc*/, uint32_t /*comment*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-// ----------------------------------------------------------------------------
-// DSP instructions...
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::PLD(int /*Rn*/, uint32_t /*offset*/) {
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::CLZ(int /*cc*/, int /*Rd*/, int /*Rm*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::QADD(int /*cc*/, int /*Rd*/, int /*Rm*/, int /*Rn*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::QDADD(int /*cc*/, int /*Rd*/, int /*Rm*/, int /*Rn*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::QSUB(int /*cc*/, int /*Rd*/, int /*Rm*/, int /*Rn*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-void ArmToArm64Assembler::QDSUB(int /*cc*/, int /*Rd*/, int /*Rm*/, int /*Rn*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-}
-
-// ----------------------------------------------------------------------------
-// 16 x 16 multiplication
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-
-    if (xy & xyTB)
-        *mPC++ = A64_SBFM_W(mTmpReg1, Rm, 16, 31);
-    else
-        *mPC++ = A64_SBFM_W(mTmpReg1, Rm, 0, 15);
-
-    if (xy & xyBT)
-        *mPC++ = A64_SBFM_W(mTmpReg2, Rs, 16, 31);
-    else
-        *mPC++ = A64_SBFM_W(mTmpReg2, Rs, 0, 15);
-
-    *mPC++ = A64_MADD_W(Rd,mTmpReg1,mTmpReg2, mZeroReg);
-}
-// ----------------------------------------------------------------------------
-// 32 x 16 multiplication
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::SMULW(int cc, int y, int Rd, int Rm, int Rs)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-
-    if (y & yT)
-        *mPC++ = A64_SBFM_W(mTmpReg1, Rs, 16, 31);
-    else
-        *mPC++ = A64_SBFM_W(mTmpReg1, Rs, 0, 15);
-
-    *mPC++ = A64_SBFM_W(mTmpReg2, Rm, 0, 31);
-    *mPC++ = A64_SMADDL(mTmpReg3,mTmpReg1,mTmpReg2, mZeroReg);
-    *mPC++ = A64_UBFM_X(Rd,mTmpReg3, 16, 47);
-}
-// ----------------------------------------------------------------------------
-// 16 x 16 multiplication and accumulate
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::SMLA(int cc, int xy, int Rd, int Rm, int Rs, int Rn)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-    if(xy != xyBB) { NOT_IMPLEMENTED(); return;} //Not required
-
-    *mPC++ = A64_SBFM_W(mTmpReg1, Rm, 0, 15);
-    *mPC++ = A64_SBFM_W(mTmpReg2, Rs, 0, 15);
-    *mPC++ = A64_MADD_W(Rd, mTmpReg1, mTmpReg2, Rn);
-}
-
-void ArmToArm64Assembler::SMLAL(int /*cc*/, int /*xy*/,
-                int /*RdHi*/, int /*RdLo*/, int /*Rs*/, int /*Rm*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-    return;
-}
-
-void ArmToArm64Assembler::SMLAW(int /*cc*/, int /*y*/,
-                int /*Rd*/, int /*Rm*/, int /*Rs*/, int /*Rn*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-    return;
-}
-
-// ----------------------------------------------------------------------------
-// Byte/half word extract and extend
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::UXTB16(int cc, int Rd, int Rm, int rotate)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-
-    *mPC++ = A64_EXTR_W(mTmpReg1, Rm, Rm, rotate * 8);
-
-    uint32_t imm = 0x00FF00FF;
-    *mPC++ = A64_MOVZ_W(mTmpReg2, imm & 0xFFFF, 0);
-    *mPC++ = A64_MOVK_W(mTmpReg2, (imm >> 16) & 0x0000FFFF, 16);
-    *mPC++ = A64_AND_W(Rd,mTmpReg1, mTmpReg2);
-}
-
-// ----------------------------------------------------------------------------
-// Bit manipulation
-// ----------------------------------------------------------------------------
-void ArmToArm64Assembler::UBFX(int cc, int Rd, int Rn, int lsb, int width)
-{
-    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-    *mPC++ = A64_UBFM_W(Rd, Rn, lsb, lsb + width - 1);
-}
-// ----------------------------------------------------------------------------
-// Shifters...
-// ----------------------------------------------------------------------------
-int ArmToArm64Assembler::buildImmediate(
-        uint32_t immediate, uint32_t& rot, uint32_t& imm)
-{
-    rot = 0;
-    imm = immediate;
-    return 0; // Always true
-}
-
-
-bool ArmToArm64Assembler::isValidImmediate(uint32_t immediate)
-{
-    uint32_t rot, imm;
-    return buildImmediate(immediate, rot, imm) == 0;
-}
-
-uint32_t ArmToArm64Assembler::imm(uint32_t immediate)
-{
-    mAddrMode.immediate = immediate;
-    mAddrMode.writeback = false;
-    mAddrMode.preindex  = false;
-    mAddrMode.postindex = false;
-    return OPERAND_IMM;
-
-}
-
-uint32_t ArmToArm64Assembler::reg_imm(int Rm, int type, uint32_t shift)
-{
-    mAddrMode.reg_imm_Rm = Rm;
-    mAddrMode.reg_imm_type = type;
-    mAddrMode.reg_imm_shift = shift;
-    return OPERAND_REG_IMM;
-}
-
-uint32_t ArmToArm64Assembler::reg_rrx(int /*Rm*/)
-{
-    NOT_IMPLEMENTED();
-    return OPERAND_UNSUPPORTED;
-}
-
-uint32_t ArmToArm64Assembler::reg_reg(int /*Rm*/, int /*type*/, int /*Rs*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-    return OPERAND_UNSUPPORTED;
-}
-// ----------------------------------------------------------------------------
-// Addressing modes...
-// ----------------------------------------------------------------------------
-uint32_t ArmToArm64Assembler::immed12_pre(int32_t immed12, int W)
-{
-    mAddrMode.immediate = immed12;
-    mAddrMode.writeback = W;
-    mAddrMode.preindex  = true;
-    mAddrMode.postindex = false;
-    return OPERAND_IMM;
-}
-
-uint32_t ArmToArm64Assembler::immed12_post(int32_t immed12)
-{
-    mAddrMode.immediate = immed12;
-    mAddrMode.writeback = true;
-    mAddrMode.preindex  = false;
-    mAddrMode.postindex = true;
-    return OPERAND_IMM;
-}
-
-uint32_t ArmToArm64Assembler::reg_scale_pre(int Rm, int type,
-        uint32_t shift, int W)
-{
-    if(type != 0 || shift != 0 || W != 0)
-    {
-        NOT_IMPLEMENTED(); //Not required
-        return OPERAND_UNSUPPORTED;
-    }
-    else
-    {
-        mAddrMode.reg_offset = Rm;
-        return OPERAND_REG_OFFSET;
-    }
-}
-
-uint32_t ArmToArm64Assembler::reg_scale_post(int /*Rm*/, int /*type*/, uint32_t /*shift*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-    return OPERAND_UNSUPPORTED;
-}
-
-uint32_t ArmToArm64Assembler::immed8_pre(int32_t immed8, int W)
-{
-    mAddrMode.immediate = immed8;
-    mAddrMode.writeback = W;
-    mAddrMode.preindex  = true;
-    mAddrMode.postindex = false;
-    return OPERAND_IMM;
-}
-
-uint32_t ArmToArm64Assembler::immed8_post(int32_t immed8)
-{
-    mAddrMode.immediate = immed8;
-    mAddrMode.writeback = true;
-    mAddrMode.preindex  = false;
-    mAddrMode.postindex = true;
-    return OPERAND_IMM;
-}
-
-uint32_t ArmToArm64Assembler::reg_pre(int Rm, int W)
-{
-    if(W != 0)
-    {
-        NOT_IMPLEMENTED(); //Not required
-        return OPERAND_UNSUPPORTED;
-    }
-    else
-    {
-        mAddrMode.reg_offset = Rm;
-        return OPERAND_REG_OFFSET;
-    }
-}
-
-uint32_t ArmToArm64Assembler::reg_post(int /*Rm*/)
-{
-    NOT_IMPLEMENTED(); //Not required
-    return OPERAND_UNSUPPORTED;
-}
-
-// ----------------------------------------------------------------------------
-// A64 instructions
-// ----------------------------------------------------------------------------
-
-static __unused const char * dataTransferOpName[] =
-{
-    "LDR","LDRB","LDRH","STR","STRB","STRH"
-};
-
-static const uint32_t dataTransferOpCode [] =
-{
-    ((0xB8u << 24) | (0x3 << 21) | (0x6 << 13) | (0x0 << 12) |(0x1 << 11)),
-    ((0x38u << 24) | (0x3 << 21) | (0x6 << 13) | (0x1 << 12) |(0x1 << 11)),
-    ((0x78u << 24) | (0x3 << 21) | (0x6 << 13) | (0x0 << 12) |(0x1 << 11)),
-    ((0xB8u << 24) | (0x1 << 21) | (0x6 << 13) | (0x0 << 12) |(0x1 << 11)),
-    ((0x38u << 24) | (0x1 << 21) | (0x6 << 13) | (0x1 << 12) |(0x1 << 11)),
-    ((0x78u << 24) | (0x1 << 21) | (0x6 << 13) | (0x0 << 12) |(0x1 << 11))
-};
-uint32_t ArmToArm64Assembler::A64_LDRSTR_Wm_SXTW_0(uint32_t op,
-                            uint32_t size, uint32_t Rt,
-                            uint32_t Rn, uint32_t Rm)
-{
-    if(size == 32)
-    {
-        LOG_INSTR("%s W%d, [X%d, W%d, SXTW #0]\n",
-                   dataTransferOpName[op], Rt, Rn, Rm);
-        return(dataTransferOpCode[op] | (Rm << 16) | (Rn << 5) | Rt);
-    }
-    else
-    {
-        LOG_INSTR("%s X%d, [X%d, W%d, SXTW #0]\n",
-                  dataTransferOpName[op], Rt, Rn, Rm);
-        return(dataTransferOpCode[op] | (0x1<<30) | (Rm<<16) | (Rn<<5)|Rt);
-    }
-}
-
-uint32_t ArmToArm64Assembler::A64_STR_IMM_PreIndex(uint32_t Rt,
-                            uint32_t Rn, int32_t simm)
-{
-    if(Rn == 31)
-        LOG_INSTR("STR W%d, [SP, #%d]!\n", Rt, simm);
-    else
-        LOG_INSTR("STR W%d, [X%d, #%d]!\n", Rt, Rn, simm);
-
-    uint32_t imm9 = (unsigned)(simm) & 0x01FF;
-    return (0xB8 << 24) | (imm9 << 12) | (0x3 << 10) | (Rn << 5) | Rt;
-}
-
-uint32_t ArmToArm64Assembler::A64_LDR_IMM_PostIndex(uint32_t Rt,
-                            uint32_t Rn, int32_t simm)
-{
-    if(Rn == 31)
-        LOG_INSTR("LDR W%d, [SP], #%d\n",Rt,simm);
-    else
-        LOG_INSTR("LDR W%d, [X%d], #%d\n",Rt, Rn, simm);
-
-    uint32_t imm9 = (unsigned)(simm) & 0x01FF;
-    return (0xB8 << 24) | (0x1 << 22) |
-             (imm9 << 12) | (0x1 << 10) | (Rn << 5) | Rt;
-
-}
-uint32_t ArmToArm64Assembler::A64_ADD_X_Wm_SXTW(uint32_t Rd,
-                               uint32_t Rn,
-                               uint32_t Rm,
-                               uint32_t amount)
-{
-    LOG_INSTR("ADD X%d, X%d, W%d, SXTW #%d\n", Rd, Rn, Rm, amount);
-    return ((0x8B << 24) | (0x1 << 21) |(Rm << 16) |
-              (0x6 << 13) | (amount << 10) | (Rn << 5) | Rd);
-
-}
-
-uint32_t ArmToArm64Assembler::A64_SUB_X_Wm_SXTW(uint32_t Rd,
-                               uint32_t Rn,
-                               uint32_t Rm,
-                               uint32_t amount)
-{
-    LOG_INSTR("SUB X%d, X%d, W%d, SXTW #%d\n", Rd, Rn, Rm, amount);
-    return ((0xCB << 24) | (0x1 << 21) |(Rm << 16) |
-            (0x6 << 13) | (amount << 10) | (Rn << 5) | Rd);
-
-}
-
-uint32_t ArmToArm64Assembler::A64_B_COND(uint32_t cc, uint32_t offset)
-{
-    LOG_INSTR("B.%s #.+%d\n", cc_codes[cc], offset);
-    return (0x54 << 24) | ((offset/4) << 5) | (cc);
-
-}
-uint32_t ArmToArm64Assembler::A64_ADD_X(uint32_t Rd, uint32_t Rn,
-                                          uint32_t Rm, uint32_t shift,
-                                          uint32_t amount)
-{
-    LOG_INSTR("ADD X%d, X%d, X%d, %s #%d\n",
-               Rd, Rn, Rm, shift_codes[shift], amount);
-    return ((0x8B << 24) | (shift << 22) | ( Rm << 16) |
-            (amount << 10) |(Rn << 5) | Rd);
-}
-uint32_t ArmToArm64Assembler::A64_ADD_IMM_X(uint32_t Rd, uint32_t Rn,
-                                          uint32_t imm, uint32_t shift)
-{
-    LOG_INSTR("ADD X%d, X%d, #%d, LSL #%d\n", Rd, Rn, imm, shift);
-    return (0x91 << 24) | ((shift/12) << 22) | (imm << 10) | (Rn << 5) | Rd;
-}
-
-uint32_t ArmToArm64Assembler::A64_SUB_IMM_X(uint32_t Rd, uint32_t Rn,
-                                          uint32_t imm, uint32_t shift)
-{
-    LOG_INSTR("SUB X%d, X%d, #%d, LSL #%d\n", Rd, Rn, imm, shift);
-    return (0xD1 << 24) | ((shift/12) << 22) | (imm << 10) | (Rn << 5) | Rd;
-}
-
-uint32_t ArmToArm64Assembler::A64_ADD_W(uint32_t Rd, uint32_t Rn,
-                                          uint32_t Rm, uint32_t shift,
-                                          uint32_t amount)
-{
-    LOG_INSTR("ADD W%d, W%d, W%d, %s #%d\n",
-               Rd, Rn, Rm, shift_codes[shift], amount);
-    return ((0x0B << 24) | (shift << 22) | ( Rm << 16) |
-            (amount << 10) |(Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_SUB_W(uint32_t Rd, uint32_t Rn,
-                                          uint32_t Rm, uint32_t shift,
-                                          uint32_t amount,
-                                          uint32_t setflag)
-{
-    if(setflag == 0)
-    {
-        LOG_INSTR("SUB W%d, W%d, W%d, %s #%d\n",
-               Rd, Rn, Rm, shift_codes[shift], amount);
-        return ((0x4B << 24) | (shift << 22) | ( Rm << 16) |
-                (amount << 10) |(Rn << 5) | Rd);
-    }
-    else
-    {
-        LOG_INSTR("SUBS W%d, W%d, W%d, %s #%d\n",
-                   Rd, Rn, Rm, shift_codes[shift], amount);
-        return ((0x6B << 24) | (shift << 22) | ( Rm << 16) |
-                (amount << 10) |(Rn << 5) | Rd);
-    }
-}
-
-uint32_t ArmToArm64Assembler::A64_AND_W(uint32_t Rd, uint32_t Rn,
-                                          uint32_t Rm, uint32_t shift,
-                                          uint32_t amount)
-{
-    LOG_INSTR("AND W%d, W%d, W%d, %s #%d\n",
-               Rd, Rn, Rm, shift_codes[shift], amount);
-    return ((0x0A << 24) | (shift << 22) | ( Rm << 16) |
-            (amount << 10) |(Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_ORR_W(uint32_t Rd, uint32_t Rn,
-                                          uint32_t Rm, uint32_t shift,
-                                          uint32_t amount)
-{
-    LOG_INSTR("ORR W%d, W%d, W%d, %s #%d\n",
-               Rd, Rn, Rm, shift_codes[shift], amount);
-    return ((0x2A << 24) | (shift << 22) | ( Rm << 16) |
-            (amount << 10) |(Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_ORN_W(uint32_t Rd, uint32_t Rn,
-                                          uint32_t Rm, uint32_t shift,
-                                          uint32_t amount)
-{
-    LOG_INSTR("ORN W%d, W%d, W%d, %s #%d\n",
-               Rd, Rn, Rm, shift_codes[shift], amount);
-    return ((0x2A << 24) | (shift << 22) | (0x1 << 21) | ( Rm << 16) |
-            (amount << 10) |(Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_CSEL_X(uint32_t Rd, uint32_t Rn,
-                                           uint32_t Rm, uint32_t cond)
-{
-    LOG_INSTR("CSEL X%d, X%d, X%d, %s\n", Rd, Rn, Rm, cc_codes[cond]);
-    return ((0x9A << 24)|(0x1 << 23)|(Rm << 16) |(cond << 12)| (Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_CSEL_W(uint32_t Rd, uint32_t Rn,
-                                           uint32_t Rm, uint32_t cond)
-{
-    LOG_INSTR("CSEL W%d, W%d, W%d, %s\n", Rd, Rn, Rm, cc_codes[cond]);
-    return ((0x1A << 24)|(0x1 << 23)|(Rm << 16) |(cond << 12)| (Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_RET(uint32_t Rn)
-{
-    LOG_INSTR("RET X%d\n", Rn);
-    return ((0xD6 << 24) | (0x1 << 22) | (0x1F << 16) | (Rn << 5));
-}
-
-uint32_t ArmToArm64Assembler::A64_MOVZ_X(uint32_t Rd, uint32_t imm,
-                                         uint32_t shift)
-{
-    LOG_INSTR("MOVZ X%d, #0x%x, LSL #%d\n", Rd, imm, shift);
-    return(0xD2 << 24) | (0x1 << 23) | ((shift/16) << 21) |  (imm << 5) | Rd;
-}
-
-uint32_t ArmToArm64Assembler::A64_MOVK_W(uint32_t Rd, uint32_t imm,
-                                         uint32_t shift)
-{
-    LOG_INSTR("MOVK W%d, #0x%x, LSL #%d\n", Rd, imm, shift);
-    return (0x72 << 24) | (0x1 << 23) | ((shift/16) << 21) | (imm << 5) | Rd;
-}
-
-uint32_t ArmToArm64Assembler::A64_MOVZ_W(uint32_t Rd, uint32_t imm,
-                                         uint32_t shift)
-{
-    LOG_INSTR("MOVZ W%d, #0x%x, LSL #%d\n", Rd, imm, shift);
-    return(0x52 << 24) | (0x1 << 23) | ((shift/16) << 21) |  (imm << 5) | Rd;
-}
-
-uint32_t ArmToArm64Assembler::A64_SMADDL(uint32_t Rd, uint32_t Rn,
-                                           uint32_t Rm, uint32_t Ra)
-{
-    LOG_INSTR("SMADDL X%d, W%d, W%d, X%d\n",Rd, Rn, Rm, Ra);
-    return ((0x9B << 24) | (0x1 << 21) | (Rm << 16)|(Ra << 10)|(Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_MADD_W(uint32_t Rd, uint32_t Rn,
-                                           uint32_t Rm, uint32_t Ra)
-{
-    LOG_INSTR("MADD W%d, W%d, W%d, W%d\n",Rd, Rn, Rm, Ra);
-    return ((0x1B << 24) | (Rm << 16) | (Ra << 10) |(Rn << 5) | Rd);
-}
-
-uint32_t ArmToArm64Assembler::A64_SBFM_W(uint32_t Rd, uint32_t Rn,
-                                           uint32_t immr, uint32_t imms)
-{
-    LOG_INSTR("SBFM W%d, W%d, #%d, #%d\n", Rd, Rn, immr, imms);
-    return ((0x13 << 24) | (immr << 16) | (imms << 10) | (Rn << 5) | Rd);
-
-}
-uint32_t ArmToArm64Assembler::A64_UBFM_W(uint32_t Rd, uint32_t Rn,
-                                           uint32_t immr, uint32_t imms)
-{
-    LOG_INSTR("UBFM W%d, W%d, #%d, #%d\n", Rd, Rn, immr, imms);
-    return ((0x53 << 24) | (immr << 16) | (imms << 10) | (Rn << 5) | Rd);
-
-}
-uint32_t ArmToArm64Assembler::A64_UBFM_X(uint32_t Rd, uint32_t Rn,
-                                           uint32_t immr, uint32_t imms)
-{
-    LOG_INSTR("UBFM X%d, X%d, #%d, #%d\n", Rd, Rn, immr, imms);
-    return ((0xD3 << 24) | (0x1 << 22) |
-            (immr << 16) | (imms << 10) | (Rn << 5) | Rd);
-
-}
-uint32_t ArmToArm64Assembler::A64_EXTR_W(uint32_t Rd, uint32_t Rn,
-                                           uint32_t Rm, uint32_t lsb)
-{
-    LOG_INSTR("EXTR W%d, W%d, W%d, #%d\n", Rd, Rn, Rm, lsb);
-    return (0x13 << 24)|(0x1 << 23) | (Rm << 16) | (lsb << 10)|(Rn << 5) | Rd;
-}
-
-}; // namespace android
diff --git a/libpixelflinger/codeflinger/Arm64Assembler.h b/libpixelflinger/codeflinger/Arm64Assembler.h
deleted file mode 100644
index 527c757..0000000
--- a/libpixelflinger/codeflinger/Arm64Assembler.h
+++ /dev/null
@@ -1,290 +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 ANDROID_ARMTOARM64ASSEMBLER_H
-#define ANDROID_ARMTOARM64ASSEMBLER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "tinyutils/smartpointer.h"
-#include "utils/Vector.h"
-#include "utils/KeyedVector.h"
-
-#include "tinyutils/smartpointer.h"
-#include "codeflinger/ARMAssemblerInterface.h"
-#include "codeflinger/CodeCache.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-class ArmToArm64Assembler : public ARMAssemblerInterface
-{
-public:
-    explicit    ArmToArm64Assembler(const sp<Assembly>& assembly);
-    explicit    ArmToArm64Assembler(void *base);
-    virtual     ~ArmToArm64Assembler();
-
-    uint32_t*   base() const;
-    uint32_t*   pc() const;
-
-
-    void        disassemble(const char* name);
-
-    // ------------------------------------------------------------------------
-    // ARMAssemblerInterface...
-    // ------------------------------------------------------------------------
-
-    virtual void    reset();
-
-    virtual int     generate(const char* name);
-    virtual int     getCodegenArch();
-
-    virtual void    prolog();
-    virtual void    epilog(uint32_t touched);
-    virtual void    comment(const char* string);
-
-
-    // -----------------------------------------------------------------------
-    // shifters and addressing modes
-    // -----------------------------------------------------------------------
-
-    // shifters...
-    virtual bool        isValidImmediate(uint32_t immed);
-    virtual int         buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
-
-    virtual uint32_t    imm(uint32_t immediate);
-    virtual uint32_t    reg_imm(int Rm, int type, uint32_t shift);
-    virtual uint32_t    reg_rrx(int Rm);
-    virtual uint32_t    reg_reg(int Rm, int type, int Rs);
-
-    // addressing modes...
-    virtual uint32_t    immed12_pre(int32_t immed12, int W=0);
-    virtual uint32_t    immed12_post(int32_t immed12);
-    virtual uint32_t    reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
-    virtual uint32_t    reg_scale_post(int Rm, int type=0, uint32_t shift=0);
-    virtual uint32_t    immed8_pre(int32_t immed8, int W=0);
-    virtual uint32_t    immed8_post(int32_t immed8);
-    virtual uint32_t    reg_pre(int Rm, int W=0);
-    virtual uint32_t    reg_post(int Rm);
-
-
-    virtual void    dataProcessing(int opcode, int cc, int s,
-                                int Rd, int Rn,
-                                uint32_t Op2);
-    virtual void MLA(int cc, int s,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void MUL(int cc, int s,
-                int Rd, int Rm, int Rs);
-    virtual void UMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void UMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-
-    virtual void B(int cc, uint32_t* pc);
-    virtual void BL(int cc, uint32_t* pc);
-    virtual void BX(int cc, int Rn);
-    virtual void label(const char* theLabel);
-    virtual void B(int cc, const char* label);
-    virtual void BL(int cc, const char* label);
-
-    virtual uint32_t* pcForLabel(const char* label);
-
-    virtual void ADDR_LDR(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void ADDR_ADD(int cc, int s, int Rd,
-                int Rn, uint32_t Op2);
-    virtual void ADDR_SUB(int cc, int s, int Rd,
-                int Rn, uint32_t Op2);
-    virtual void ADDR_STR (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-
-    virtual void LDR (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STR (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STRB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRH (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRSB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRSH(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STRH (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-
-
-    virtual void LDM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-    virtual void STM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-
-    virtual void SWP(int cc, int Rn, int Rd, int Rm);
-    virtual void SWPB(int cc, int Rn, int Rd, int Rm);
-    virtual void SWI(int cc, uint32_t comment);
-
-    virtual void PLD(int Rn, uint32_t offset);
-    virtual void CLZ(int cc, int Rd, int Rm);
-    virtual void QADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QDADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs);
-    virtual void SMULW(int cc, int y,
-                int Rd, int Rm, int Rs);
-    virtual void SMLA(int cc, int xy,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void SMLAL(int cc, int xy,
-                int RdHi, int RdLo, int Rs, int Rm);
-    virtual void SMLAW(int cc, int y,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
-    virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
-
-private:
-    ArmToArm64Assembler(const ArmToArm64Assembler& rhs);
-    ArmToArm64Assembler& operator = (const ArmToArm64Assembler& rhs);
-
-    // -----------------------------------------------------------------------
-    // helper functions
-    // -----------------------------------------------------------------------
-
-    void dataTransfer(int operation, int cc, int Rd, int Rn,
-                      uint32_t operand_type, uint32_t size = 32);
-    void dataProcessingCommon(int opcode, int s,
-                      int Rd, int Rn, uint32_t Op2);
-
-    // -----------------------------------------------------------------------
-    // Arm64 instructions
-    // -----------------------------------------------------------------------
-    uint32_t A64_B_COND(uint32_t cc, uint32_t offset);
-    uint32_t A64_RET(uint32_t Rn);
-
-    uint32_t A64_LDRSTR_Wm_SXTW_0(uint32_t operation,
-                                uint32_t size, uint32_t Rt,
-                                uint32_t Rn, uint32_t Rm);
-
-    uint32_t A64_STR_IMM_PreIndex(uint32_t Rt, uint32_t Rn, int32_t simm);
-    uint32_t A64_LDR_IMM_PostIndex(uint32_t Rt,uint32_t Rn, int32_t simm);
-
-    uint32_t A64_ADD_X_Wm_SXTW(uint32_t Rd, uint32_t Rn, uint32_t Rm,
-                               uint32_t amount);
-    uint32_t A64_SUB_X_Wm_SXTW(uint32_t Rd, uint32_t Rn, uint32_t Rm,
-                               uint32_t amount);
-
-    uint32_t A64_ADD_IMM_X(uint32_t Rd, uint32_t Rn,
-                           uint32_t imm, uint32_t shift = 0);
-    uint32_t A64_SUB_IMM_X(uint32_t Rd, uint32_t Rn,
-                           uint32_t imm, uint32_t shift = 0);
-
-    uint32_t A64_ADD_X(uint32_t Rd, uint32_t Rn,
-                       uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
-    uint32_t A64_ADD_W(uint32_t Rd, uint32_t Rn, uint32_t Rm,
-                       uint32_t shift = 0, uint32_t amount = 0);
-    uint32_t A64_SUB_W(uint32_t Rd, uint32_t Rn, uint32_t Rm,
-                       uint32_t shift = 0, uint32_t amount = 0,
-                       uint32_t setflag = 0);
-    uint32_t A64_AND_W(uint32_t Rd, uint32_t Rn,
-                       uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
-    uint32_t A64_ORR_W(uint32_t Rd, uint32_t Rn,
-                       uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
-    uint32_t A64_ORN_W(uint32_t Rd, uint32_t Rn,
-                       uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
-
-    uint32_t A64_MOVZ_W(uint32_t Rd, uint32_t imm, uint32_t shift);
-    uint32_t A64_MOVZ_X(uint32_t Rd, uint32_t imm, uint32_t shift);
-    uint32_t A64_MOVK_W(uint32_t Rd, uint32_t imm, uint32_t shift);
-
-    uint32_t A64_SMADDL(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t Ra);
-    uint32_t A64_MADD_W(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t Ra);
-
-    uint32_t A64_SBFM_W(uint32_t Rd, uint32_t Rn,
-                        uint32_t immr, uint32_t imms);
-    uint32_t A64_UBFM_W(uint32_t Rd, uint32_t Rn,
-                        uint32_t immr, uint32_t imms);
-    uint32_t A64_UBFM_X(uint32_t Rd, uint32_t Rn,
-                        uint32_t immr, uint32_t imms);
-
-    uint32_t A64_EXTR_W(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t lsb);
-    uint32_t A64_CSEL_X(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t cond);
-    uint32_t A64_CSEL_W(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t cond);
-
-    uint32_t*       mBase;
-    uint32_t*       mPC;
-    uint32_t*       mPrologPC;
-    int64_t         mDuration;
-    uint32_t        mTmpReg1, mTmpReg2, mTmpReg3, mZeroReg;
-
-    struct branch_target_t {
-        inline branch_target_t() : label(0), pc(0) { }
-        inline branch_target_t(const char* l, uint32_t* p)
-            : label(l), pc(p) { }
-        const char* label;
-        uint32_t*   pc;
-    };
-
-    sp<Assembly>    mAssembly;
-    Vector<branch_target_t>                 mBranchTargets;
-    KeyedVector< const char*, uint32_t* >   mLabels;
-    KeyedVector< uint32_t*, const char* >   mLabelsInverseMapping;
-    KeyedVector< uint32_t*, const char* >   mComments;
-
-    enum operand_type_t
-    {
-        OPERAND_REG = 0x20,
-        OPERAND_IMM,
-        OPERAND_REG_IMM,
-        OPERAND_REG_OFFSET,
-        OPERAND_UNSUPPORTED
-    };
-
-    struct addr_mode_t {
-        int32_t         immediate;
-        bool            writeback;
-        bool            preindex;
-        bool            postindex;
-        int32_t         reg_imm_Rm;
-        int32_t         reg_imm_type;
-        uint32_t        reg_imm_shift;
-        int32_t         reg_offset;
-    } mAddrMode;
-
-};
-
-}; // namespace android
-
-#endif //ANDROID_ARM64ASSEMBLER_H
diff --git a/libpixelflinger/codeflinger/Arm64Disassembler.cpp b/libpixelflinger/codeflinger/Arm64Disassembler.cpp
deleted file mode 100644
index 70f1ff1..0000000
--- a/libpixelflinger/codeflinger/Arm64Disassembler.cpp
+++ /dev/null
@@ -1,316 +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 <stdio.h>
-#include <inttypes.h>
-#include <string.h>
-
-struct disasm_table_entry_t
-{
-    uint32_t       mask;
-    uint32_t       value;
-    const char*    instr_template;
-};
-
-
-static disasm_table_entry_t disasm_table[] =
-{
-    {0xff000000, 0x91000000, "add <xd|sp>, <xn|sp>, #<imm1>, <shift1>"},
-    {0xff000000, 0xd1000000, "sub <xd|sp>, <xn|sp>, #<imm1>, <shift1>"},
-    {0xff200000, 0x8b000000, "add <xd>, <xn>, <xm>, <shift2> #<amt1>"},
-    {0xff200000, 0x0b000000, "add <wd>, <wn>, <wm>, <shift2> #<amt1>"},
-    {0xff200000, 0x4b000000, "sub <wd>, <wn>, <wm>, <shift2> #<amt1>"},
-    {0xff200000, 0x6b000000, "subs <wd>, <wn>, <wm>, <shift2> #<amt1>"},
-    {0xff200000, 0x0a000000, "and <wd>, <wn>, <wm>, <shift2> #<amt1>"},
-    {0xff200000, 0x2a000000, "orr <wd>, <wn>, <wm>, <shift2> #<amt1>"},
-    {0xff200000, 0x2a200000, "orn <wd>, <wn>, <wm>, <shift2> #<amt1>"},
-    {0xff800000, 0x72800000, "movk <wd>, #<imm2>, lsl #<shift3>"},
-    {0xff800000, 0x52800000, "movz <wd>, #<imm2>, lsl #<shift3>"},
-    {0xff800000, 0xd2800000, "movz <xd>, #<imm2>, lsl #<shift3>"},
-    {0xffe00c00, 0x1a800000, "csel <wd>, <wn>, <wm>, <cond1>"},
-    {0xffe00c00, 0x9a800000, "csel <xd>, <xn>, <xm>, <cond1>"},
-    {0xffe00c00, 0x5a800000, "csinv <wd>, <wn>, <wm>, <cond1>"},
-    {0xffe08000, 0x1b000000, "madd <wd>, <wn>, <wm>, <wa>"},
-    {0xffe08000, 0x9b200000, "smaddl <xd>, <wn>, <wm>, <xa>"},
-    {0xffe04c00, 0xb8604800, "ldr <wt>, [<xn|sp>, <r1><m1>, <ext1> #<amt2>]"},
-    {0xffe04c00, 0xb8204800, "str <wt>, [<xn|sp>, <r1><m1>, <ext1> #<amt2>]"},
-    {0xffe04c00, 0xf8604800, "ldr <xt>, [<xn|sp>, <r1><m1>, <ext1> #<amt3>]"},
-    {0xffe04c00, 0xf8204800, "str <xt>, [<xn|sp>, <r1><m1>, <ext1> #<amt3>]"},
-    {0xffe04c00, 0x38604800, "ldrb <wt>, [<xn|sp>, <r1><m1>, <ext1> <amt5>]"},
-    {0xffe04c00, 0x38204800, "strb <wt>, [<xn|sp>, <r1><m1>, <ext1> <amt5>]"},
-    {0xffe04c00, 0x78604800, "ldrh <wt>, [<xn|sp>, <r1><m1>, <ext1> #<amt6>]"},
-    {0xffe04c00, 0x78204800, "strh <wt>, [<xn|sp>, <r1><m1>, <ext1> #<amt6>]"},
-    {0xffe00c00, 0xb8400400, "ldr <wt>, [<xn|sp>], #<simm1>"},
-    {0xffe00c00, 0xb8000c00, "str <wt>, [<xn|sp>, #<simm1>]!"},
-    {0xffc00000, 0x13000000, "sbfm <wd>, <wn>, #<immr1>, #<imms1>"},
-    {0xffc00000, 0x53000000, "ubfm <wd>, <wn>, #<immr1>, #<imms1>"},
-    {0xffc00000, 0xd3400000, "ubfm <xd>, <xn>, #<immr1>, #<imms1>"},
-    {0xffe00000, 0x13800000, "extr <wd>, <wn>, <wm>, #<lsb1>"},
-    {0xff000000, 0x54000000, "b.<cond2> <label1>"},
-    {0xfffffc1f, 0xd65f0000, "ret <xn>"},
-    {0xffe00000, 0x8b200000, "add <xd|sp>, <xn|sp>, <r2><m1>, <ext2> #<amt4>"},
-    {0xffe00000, 0xcb200000, "sub <xd|sp>, <xn|sp>, <r2><m1>, <ext2> #<amt4>"}
-};
-
-static int32_t bits_signed(uint32_t instr, uint32_t msb, uint32_t lsb)
-{
-    int32_t value;
-    value   = ((int32_t)instr) << (31 - msb);
-    value >>= (31 - msb);
-    value >>= lsb;
-    return value;
-}
-static uint32_t bits_unsigned(uint32_t instr, uint32_t msb, uint32_t lsb)
-{
-    uint32_t width = msb - lsb + 1;
-    uint32_t mask  = (1 << width) - 1;
-    return ((instr >> lsb) & mask);
-}
-
-static void get_token(const char *instr, uint32_t index, char *token)
-{
-    uint32_t i, j;
-    for(i = index, j = 0; i < strlen(instr); ++i)
-    {
-        if(instr[index] == '<' && instr[i] == '>')
-        {
-            token[j++] = instr[i];
-            break;
-        }
-        else if(instr[index] != '<' && instr[i] == '<')
-        {
-            break;
-        }
-        else
-        {
-            token[j++] = instr[i];
-        }
-    }
-    token[j] = '\0';
-    return;
-}
-
-
-static const char * token_cc_table[] =
-{
-    "eq", "ne", "cs", "cc", "mi",
-    "pl", "vs", "vc", "hi", "ls",
-    "ge", "lt", "gt", "le", "al", "nv"
-};
-
-static void decode_rx_zr_token(uint32_t reg, const char *prefix, char *instr_part)
-{
-    if(reg == 31)
-        sprintf(instr_part, "%s%s", prefix, "zr");
-    else
-        sprintf(instr_part, "%s%d", prefix, reg);
-}
-
-static void decode_token(uint32_t code, char *token, char *instr_part)
-{
-    if(strcmp(token, "<imm1>") == 0)
-        sprintf(instr_part, "0x%x", bits_unsigned(code, 21,10));
-    else if(strcmp(token, "<imm2>") == 0)
-        sprintf(instr_part, "0x%x", bits_unsigned(code, 20,5));
-    else if(strcmp(token, "<shift1>") == 0)
-        sprintf(instr_part, "lsl #%d", bits_unsigned(code, 23,22) * 12);
-    else if(strcmp(token, "<shift2>") == 0)
-    {
-        static const char * shift2_table[] = { "lsl", "lsr", "asr", "ror"};
-        sprintf(instr_part, "%s", shift2_table[bits_unsigned(code, 23,22)]);
-    }
-    else if(strcmp(token, "<shift3>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 22,21) * 16);
-    else if(strcmp(token, "<amt1>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 15,10));
-    else if(strcmp(token, "<amt2>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 12,12) * 2);
-    else if(strcmp(token, "<amt3>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 12,12) * 3);
-    else if(strcmp(token, "<amt4>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 12,10));
-    else if(strcmp(token, "<amt5>") == 0)
-    {
-        static const char * amt5_table[] = {"", "#0"};
-        sprintf(instr_part, "%s", amt5_table[bits_unsigned(code, 12,12)]);
-    }
-    else if(strcmp(token, "<amt6>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 12,12));
-    else if(strcmp(token, "<simm1>") == 0)
-        sprintf(instr_part, "%d", bits_signed(code, 20,12));
-    else if(strcmp(token, "<immr1>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 21,16));
-    else if(strcmp(token, "<imms1>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 15,10));
-    else if(strcmp(token, "<lsb1>") == 0)
-        sprintf(instr_part, "%d", bits_unsigned(code, 15,10));
-    else if(strcmp(token, "<cond1>") == 0)
-        sprintf(instr_part, "%s", token_cc_table[bits_unsigned(code, 15,12)]);
-    else if(strcmp(token, "<cond2>") == 0)
-        sprintf(instr_part, "%s", token_cc_table[bits_unsigned(code, 4,0)]);
-    else if(strcmp(token, "<r1>") == 0)
-    {
-        const char * token_r1_table[] =
-        {
-            "reserved", "reserved", "w", "x",
-            "reserved", "reserved", "w", "x"
-        };
-        sprintf(instr_part, "%s", token_r1_table[bits_unsigned(code, 15,13)]);
-    }
-    else if(strcmp(token, "<r2>") == 0)
-    {
-        static const char * token_r2_table[] =
-        {
-                "w","w","w", "x", "w", "w", "w", "x"
-        };
-        sprintf(instr_part, "%s", token_r2_table[bits_unsigned(code, 15,13)]);
-    }
-    else if(strcmp(token, "<m1>") == 0)
-    {
-        uint32_t reg = bits_unsigned(code, 20,16);
-        if(reg == 31)
-            sprintf(instr_part, "%s", "zr");
-        else
-            sprintf(instr_part, "%d", reg);
-    }
-    else if(strcmp(token, "<ext1>") == 0)
-    {
-        static const char * token_ext1_table[] =
-        {
-             "reserved","reserved","uxtw", "lsl",
-             "reserved","reserved", "sxtw", "sxtx"
-        };
-        sprintf(instr_part, "%s", token_ext1_table[bits_unsigned(code, 15,13)]);
-    }
-    else if(strcmp(token, "<ext2>") == 0)
-    {
-        static const char * token_ext2_table[] =
-        {
-                "uxtb","uxth","uxtw","uxtx",
-                "sxtb","sxth","sxtw","sxtx"
-        };
-        sprintf(instr_part, "%s", token_ext2_table[bits_unsigned(code, 15,13)]);
-    }
-    else if (strcmp(token, "<label1>") == 0)
-    {
-        int32_t offset = bits_signed(code, 23,5) * 4;
-        if(offset > 0)
-            sprintf(instr_part, "#.+%d", offset);
-        else
-            sprintf(instr_part, "#.-%d", -offset);
-    }
-    else if (strcmp(token, "<xn|sp>") == 0)
-    {
-        uint32_t reg = bits_unsigned(code, 9, 5);
-        if(reg == 31)
-            sprintf(instr_part, "%s", "sp");
-        else
-            sprintf(instr_part, "x%d", reg);
-    }
-    else if (strcmp(token, "<xd|sp>") == 0)
-    {
-        uint32_t reg = bits_unsigned(code, 4, 0);
-        if(reg == 31)
-            sprintf(instr_part, "%s", "sp");
-        else
-            sprintf(instr_part, "x%d", reg);
-    }
-    else if (strcmp(token, "<xn>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 9, 5), "x", instr_part);
-    else if (strcmp(token, "<xd>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 4, 0), "x", instr_part);
-    else if (strcmp(token, "<xm>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 20, 16), "x", instr_part);
-    else if (strcmp(token, "<xa>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 14, 10), "x", instr_part);
-    else if (strcmp(token, "<xt>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 4, 0), "x", instr_part);
-    else if (strcmp(token, "<wn>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 9, 5), "w", instr_part);
-    else if (strcmp(token, "<wd>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 4, 0), "w", instr_part);
-    else if (strcmp(token, "<wm>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 20, 16), "w", instr_part);
-    else if (strcmp(token, "<wa>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 14, 10), "w", instr_part);
-    else if (strcmp(token, "<wt>") == 0)
-        decode_rx_zr_token(bits_unsigned(code, 4, 0), "w", instr_part);
-    else
-    {
-        sprintf(instr_part, "error");
-    }
-    return;
-}
-
-int arm64_disassemble(uint32_t code, char* instr)
-{
-    uint32_t i;
-    char token[256];
-    char instr_part[256];
-
-    if(instr == NULL)
-        return -1;
-
-    bool matched = false;
-    disasm_table_entry_t *entry = NULL;
-    for(i = 0; i < sizeof(disasm_table)/sizeof(disasm_table_entry_t); ++i)
-    {
-        entry = &disasm_table[i];
-        if((code & entry->mask) == entry->value)
-        {
-            matched = true;
-            break;
-        }
-    }
-    if(matched == false)
-    {
-        strcpy(instr, "Unknown Instruction");
-        return -1;
-    }
-    else
-    {
-        uint32_t index = 0;
-        uint32_t length = strlen(entry->instr_template);
-        instr[0] = '\0';
-        do
-        {
-            get_token(entry->instr_template, index, token);
-            if(token[0] == '<')
-            {
-                decode_token(code, token, instr_part);
-                strcat(instr, instr_part);
-            }
-            else
-            {
-                strcat(instr, token);
-            }
-            index += strlen(token);
-        }while(index < length);
-        return 0;
-    }
-}
diff --git a/libpixelflinger/codeflinger/Arm64Disassembler.h b/libpixelflinger/codeflinger/Arm64Disassembler.h
deleted file mode 100644
index 86f3aba..0000000
--- a/libpixelflinger/codeflinger/Arm64Disassembler.h
+++ /dev/null
@@ -1,35 +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 ANDROID_ARM64DISASSEMBLER_H
-#define ANDROID_ARM64DISASSEMBLER_H
-
-#include <inttypes.h>
-int arm64_disassemble(uint32_t code, char* instr);
-
-#endif //ANDROID_ARM64ASSEMBLER_H
diff --git a/libpixelflinger/codeflinger/CodeCache.cpp b/libpixelflinger/codeflinger/CodeCache.cpp
deleted file mode 100644
index 32691a3..0000000
--- a/libpixelflinger/codeflinger/CodeCache.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/* libs/pixelflinger/codeflinger/CodeCache.cpp
-**
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "CodeCache"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include <cutils/ashmem.h>
-#include <log/log.h>
-
-#include "CodeCache.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-#if defined(__arm__) || defined(__aarch64__)
-#include <unistd.h>
-#include <errno.h>
-#endif
-
-#if defined(__mips__)
-#include <asm/cachectl.h>
-#include <errno.h>
-#endif
-
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-
-// A dlmalloc mspace is used to manage the code cache over a mmaped region.
-#define HAVE_MMAP 0
-#define HAVE_MREMAP 0
-#define HAVE_MORECORE 0
-#define MALLOC_ALIGNMENT 16
-#define MSPACES 1
-#define NO_MALLINFO 1
-#define ONLY_MSPACES 1
-// Custom heap error handling.
-#define PROCEED_ON_ERROR 0
-static void heap_error(const char* msg, const char* function, void* p);
-#define CORRUPTION_ERROR_ACTION(m) \
-    heap_error("HEAP MEMORY CORRUPTION", __FUNCTION__, NULL)
-#define USAGE_ERROR_ACTION(m,p) \
-    heap_error("ARGUMENT IS INVALID HEAP ADDRESS", __FUNCTION__, p)
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wexpansion-to-defined"
-#pragma GCC diagnostic ignored "-Wnull-pointer-arithmetic"
-#include "../../../../external/dlmalloc/malloc.c"
-#pragma GCC diagnostic pop
-
-static void heap_error(const char* msg, const char* function, void* p) {
-    ALOG(LOG_FATAL, LOG_TAG, "@@@ ABORTING: CODE FLINGER: %s IN %s addr=%p",
-         msg, function, p);
-    /* So that we can get a memory dump around p */
-    *((int **) 0xdeadbaad) = (int *) p;
-}
-
-// ----------------------------------------------------------------------------
-
-static void* gExecutableStore = NULL;
-static mspace gMspace = NULL;
-const size_t kMaxCodeCacheCapacity = 1024 * 1024;
-
-static mspace getMspace()
-{
-    if (gExecutableStore == NULL) {
-        int fd = ashmem_create_region("CodeFlinger code cache",
-                                      kMaxCodeCacheCapacity);
-        LOG_ALWAYS_FATAL_IF(fd < 0,
-                            "Creating code cache, ashmem_create_region "
-                            "failed with error '%s'", strerror(errno));
-        gExecutableStore = mmap(NULL, kMaxCodeCacheCapacity,
-                                PROT_READ | PROT_WRITE | PROT_EXEC,
-                                MAP_PRIVATE, fd, 0);
-        LOG_ALWAYS_FATAL_IF(gExecutableStore == MAP_FAILED,
-                            "Creating code cache, mmap failed with error "
-                            "'%s'", strerror(errno));
-        close(fd);
-        gMspace = create_mspace_with_base(gExecutableStore, kMaxCodeCacheCapacity,
-                                          /*locked=*/ false);
-        mspace_set_footprint_limit(gMspace, kMaxCodeCacheCapacity);
-    }
-    return gMspace;
-}
-
-Assembly::Assembly(size_t size)
-    : mCount(0), mSize(0)
-{
-    mBase = (uint32_t*)mspace_malloc(getMspace(), size);
-    LOG_ALWAYS_FATAL_IF(mBase == NULL,
-                        "Failed to create Assembly of size %zd in executable "
-                        "store of size %zd", size, kMaxCodeCacheCapacity);
-    mSize = size;
-}
-
-Assembly::~Assembly()
-{
-    mspace_free(getMspace(), mBase);
-}
-
-void Assembly::incStrong(const void*) const
-{
-    mCount.fetch_add(1, std::memory_order_relaxed);
-}
-
-void Assembly::decStrong(const void*) const
-{
-    if (mCount.fetch_sub(1, std::memory_order_acq_rel) == 1) {
-        delete this;
-    }
-}
-
-ssize_t Assembly::size() const
-{
-    if (!mBase) return NO_MEMORY;
-    return mSize;
-}
-
-uint32_t* Assembly::base() const
-{
-    return mBase;
-}
-
-ssize_t Assembly::resize(size_t newSize)
-{
-    mBase = (uint32_t*)mspace_realloc(getMspace(), mBase, newSize);
-    LOG_ALWAYS_FATAL_IF(mBase == NULL,
-                        "Failed to resize Assembly to %zd in code cache "
-                        "of size %zd", newSize, kMaxCodeCacheCapacity);
-    mSize = newSize;
-    return size();
-}
-
-// ----------------------------------------------------------------------------
-
-CodeCache::CodeCache(size_t size)
-    : mCacheSize(size), mCacheInUse(0)
-{
-    pthread_mutex_init(&mLock, 0);
-}
-
-CodeCache::~CodeCache()
-{
-    pthread_mutex_destroy(&mLock);
-}
-
-sp<Assembly> CodeCache::lookup(const AssemblyKeyBase& keyBase) const
-{
-    pthread_mutex_lock(&mLock);
-    sp<Assembly> r;
-    ssize_t index = mCacheData.indexOfKey(key_t(keyBase));
-    if (index >= 0) {
-        const cache_entry_t& e = mCacheData.valueAt(index);
-        e.when = mWhen++;
-        r = e.entry;
-    }
-    pthread_mutex_unlock(&mLock);
-    return r;
-}
-
-int CodeCache::cache(  const AssemblyKeyBase& keyBase,
-                            const sp<Assembly>& assembly)
-{
-    pthread_mutex_lock(&mLock);
-
-    const ssize_t assemblySize = assembly->size();
-    while (mCacheInUse + assemblySize > mCacheSize) {
-        // evict the LRU
-        size_t lru = 0;
-        size_t count = mCacheData.size();
-        for (size_t i=0 ; i<count ; i++) {
-            const cache_entry_t& e = mCacheData.valueAt(i);
-            if (e.when < mCacheData.valueAt(lru).when) {
-                lru = i;
-            }
-        }
-        const cache_entry_t& e = mCacheData.valueAt(lru);
-        mCacheInUse -= e.entry->size();
-        mCacheData.removeItemsAt(lru);
-    }
-
-    ssize_t err = mCacheData.add(key_t(keyBase), cache_entry_t(assembly, mWhen));
-    if (err >= 0) {
-        mCacheInUse += assemblySize;
-        mWhen++;
-        // synchronize caches...
-        char* base = reinterpret_cast<char*>(assembly->base());
-        char* curr = reinterpret_cast<char*>(base + assembly->size());
-        __builtin___clear_cache(base, curr);
-    }
-
-    pthread_mutex_unlock(&mLock);
-    return err;
-}
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/libpixelflinger/codeflinger/CodeCache.h b/libpixelflinger/codeflinger/CodeCache.h
deleted file mode 100644
index 9326453..0000000
--- a/libpixelflinger/codeflinger/CodeCache.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* libs/pixelflinger/codeflinger/CodeCache.h
-**
-** Copyright 2006, 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_CODECACHE_H
-#define ANDROID_CODECACHE_H
-
-#include <atomic>
-#include <stdint.h>
-#include <pthread.h>
-#include <sys/types.h>
-
-#include "utils/KeyedVector.h"
-#include "tinyutils/smartpointer.h"
-
-namespace android {
-
-using namespace tinyutils;
-
-// ----------------------------------------------------------------------------
-
-class AssemblyKeyBase {
-public:
-    virtual ~AssemblyKeyBase() { }
-    virtual int compare_type(const AssemblyKeyBase& key) const = 0;
-};
-
-template  <typename T>
-class AssemblyKey : public AssemblyKeyBase
-{
-public:
-    explicit AssemblyKey(const T& rhs) : mKey(rhs) { }
-    virtual int compare_type(const AssemblyKeyBase& key) const {
-        const T& rhs = static_cast<const AssemblyKey&>(key).mKey;
-        return android::compare_type(mKey, rhs);
-    }
-private:
-    T mKey;
-};
-
-// ----------------------------------------------------------------------------
-
-class Assembly
-{
-public:
-    explicit    Assembly(size_t size);
-    virtual     ~Assembly();
-
-    ssize_t     size() const;
-    uint32_t*   base() const;
-    ssize_t     resize(size_t size);
-
-    // protocol for sp<>
-            void    incStrong(const void* id) const;
-            void    decStrong(const void* id) const;
-    typedef void    weakref_type;
-
-private:
-    mutable std::atomic<int32_t>     mCount;
-            uint32_t*   mBase;
-            size_t      mSize;
-};
-
-// ----------------------------------------------------------------------------
-
-class CodeCache
-{
-public:
-// pretty simple cache API...
-    explicit            CodeCache(size_t size);
-                        ~CodeCache();
-
-    sp<Assembly>        lookup(const AssemblyKeyBase& key) const;
-
-    int                 cache(const AssemblyKeyBase& key,
-                              const sp<Assembly>& assembly);
-
-private:
-    // nothing to see here...
-    struct cache_entry_t {
-        inline cache_entry_t() { }
-        inline cache_entry_t(const sp<Assembly>& a, int64_t w)
-                : entry(a), when(w) { }
-        sp<Assembly>            entry;
-        mutable int64_t         when;
-    };
-
-    class key_t {
-        friend int compare_type(
-            const key_value_pair_t<key_t, cache_entry_t>&,
-            const key_value_pair_t<key_t, cache_entry_t>&);
-        const AssemblyKeyBase* mKey;
-    public:
-        key_t() { };
-        explicit key_t(const AssemblyKeyBase& k) : mKey(&k)  { }
-    };
-
-    mutable pthread_mutex_t             mLock;
-    mutable int64_t                     mWhen;
-    size_t                              mCacheSize;
-    size_t                              mCacheInUse;
-    KeyedVector<key_t, cache_entry_t>   mCacheData;
-
-    friend int compare_type(
-        const key_value_pair_t<key_t, cache_entry_t>&,
-        const key_value_pair_t<key_t, cache_entry_t>&);
-};
-
-// KeyedVector uses compare_type(), which is more efficient, than
-// just using operator < ()
-inline int compare_type(
-    const key_value_pair_t<CodeCache::key_t, CodeCache::cache_entry_t>& lhs,
-    const key_value_pair_t<CodeCache::key_t, CodeCache::cache_entry_t>& rhs)
-{
-    return lhs.key.mKey->compare_type(*(rhs.key.mKey));
-}
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif //ANDROID_CODECACHE_H
diff --git a/libpixelflinger/codeflinger/GGLAssembler.cpp b/libpixelflinger/codeflinger/GGLAssembler.cpp
deleted file mode 100644
index 04e285d..0000000
--- a/libpixelflinger/codeflinger/GGLAssembler.cpp
+++ /dev/null
@@ -1,1195 +0,0 @@
-/* libs/pixelflinger/codeflinger/GGLAssembler.cpp
-**
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "GGLAssembler"
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#include <log/log.h>
-
-#include "GGLAssembler.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-GGLAssembler::GGLAssembler(ARMAssemblerInterface* target)
-    : ARMAssemblerProxy(target),
-      RegisterAllocator(ARMAssemblerProxy::getCodegenArch()), mOptLevel(7)
-{
-}
-
-GGLAssembler::~GGLAssembler()
-{
-}
-
-void GGLAssembler::prolog()
-{
-    ARMAssemblerProxy::prolog();
-}
-
-void GGLAssembler::epilog(uint32_t touched)
-{
-    ARMAssemblerProxy::epilog(touched);
-}
-
-void GGLAssembler::reset(int opt_level)
-{
-    ARMAssemblerProxy::reset();
-    RegisterAllocator::reset();
-    mOptLevel = opt_level;
-}
-
-// ---------------------------------------------------------------------------
-
-int GGLAssembler::scanline(const needs_t& needs, context_t const* c)
-{
-    int err = 0;
-    int opt_level = mOptLevel;
-    while (opt_level >= 0) {
-        reset(opt_level);
-        err = scanline_core(needs, c);
-        if (err == 0)
-            break;
-        opt_level--;
-    }
-    
-    // XXX: in theory, pcForLabel is not valid before generate()
-    uint32_t* fragment_start_pc = pcForLabel("fragment_loop");
-    uint32_t* fragment_end_pc = pcForLabel("epilog");
-    const int per_fragment_ops = int(fragment_end_pc - fragment_start_pc);
-    
-    // build a name for our pipeline
-    char name[64];    
-    sprintf(name,
-            "scanline__%08X:%08X_%08X_%08X [%3d ipp]",
-            needs.p, needs.n, needs.t[0], needs.t[1], per_fragment_ops);
-
-    if (err) {
-        ALOGE("Error while generating ""%s""\n", name);
-        disassemble(name);
-        return -1;
-    }
-
-    return generate(name);
-}
-
-int GGLAssembler::scanline_core(const needs_t& needs, context_t const* c)
-{
-    mBlendFactorCached = 0;
-    mBlending = 0;
-    mMasking = 0;
-    mAA        = GGL_READ_NEEDS(P_AA, needs.p);
-    mDithering = GGL_READ_NEEDS(P_DITHER, needs.p);
-    mAlphaTest = GGL_READ_NEEDS(P_ALPHA_TEST, needs.p) + GGL_NEVER;
-    mDepthTest = GGL_READ_NEEDS(P_DEPTH_TEST, needs.p) + GGL_NEVER;
-    mFog       = GGL_READ_NEEDS(P_FOG, needs.p) != 0;
-    mSmooth    = GGL_READ_NEEDS(SHADE, needs.n) != 0;
-    mBuilderContext.needs = needs;
-    mBuilderContext.c = c;
-    mBuilderContext.Rctx = reserveReg(R0); // context always in R0
-    mCbFormat = c->formats[ GGL_READ_NEEDS(CB_FORMAT, needs.n) ];
-
-    // ------------------------------------------------------------------------
-
-    decodeLogicOpNeeds(needs);
-
-    decodeTMUNeeds(needs, c);
-
-    mBlendSrc  = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_SRC, needs.n));
-    mBlendDst  = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_DST, needs.n));
-    mBlendSrcA = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_SRCA, needs.n));
-    mBlendDstA = ggl_needs_to_blendfactor(GGL_READ_NEEDS(BLEND_DSTA, needs.n));
-
-    if (!mCbFormat.c[GGLFormat::ALPHA].h) {
-        if ((mBlendSrc == GGL_ONE_MINUS_DST_ALPHA) ||
-            (mBlendSrc == GGL_DST_ALPHA)) {
-            mBlendSrc = GGL_ONE;
-        }
-        if ((mBlendSrcA == GGL_ONE_MINUS_DST_ALPHA) ||
-            (mBlendSrcA == GGL_DST_ALPHA)) {
-            mBlendSrcA = GGL_ONE;
-        }
-        if ((mBlendDst == GGL_ONE_MINUS_DST_ALPHA) ||
-            (mBlendDst == GGL_DST_ALPHA)) {
-            mBlendDst = GGL_ONE;
-        }
-        if ((mBlendDstA == GGL_ONE_MINUS_DST_ALPHA) ||
-            (mBlendDstA == GGL_DST_ALPHA)) {
-            mBlendDstA = GGL_ONE;
-        }
-    }
-
-    // if we need the framebuffer, read it now
-    const int blending =    blending_codes(mBlendSrc, mBlendDst) |
-                            blending_codes(mBlendSrcA, mBlendDstA);
-
-    // XXX: handle special cases, destination not modified...
-    if ((mBlendSrc==GGL_ZERO) && (mBlendSrcA==GGL_ZERO) &&
-        (mBlendDst==GGL_ONE) && (mBlendDstA==GGL_ONE)) {
-        // Destination unmodified (beware of logic ops)
-    } else if ((mBlendSrc==GGL_ZERO) && (mBlendSrcA==GGL_ZERO) &&
-        (mBlendDst==GGL_ZERO) && (mBlendDstA==GGL_ZERO)) {
-        // Destination is zero (beware of logic ops)
-    }
-    
-    int fbComponents = 0;
-    const int masking = GGL_READ_NEEDS(MASK_ARGB, needs.n);
-    for (int i=0 ; i<4 ; i++) {
-        const int mask = 1<<i;
-        component_info_t& info = mInfo[i];
-        int fs = i==GGLFormat::ALPHA ? mBlendSrcA : mBlendSrc;
-        int fd = i==GGLFormat::ALPHA ? mBlendDstA : mBlendDst;
-        if (fs==GGL_SRC_ALPHA_SATURATE && i==GGLFormat::ALPHA)
-            fs = GGL_ONE;
-        info.masked =   !!(masking & mask);
-        info.inDest =   !info.masked && mCbFormat.c[i].h && 
-                        ((mLogicOp & LOGIC_OP_SRC) || (!mLogicOp));
-        if (mCbFormat.components >= GGL_LUMINANCE &&
-                (i==GGLFormat::GREEN || i==GGLFormat::BLUE)) {
-            info.inDest = false;
-        }
-        info.needed =   (i==GGLFormat::ALPHA) && 
-                        (isAlphaSourceNeeded() || mAlphaTest != GGL_ALWAYS);
-        info.replaced = !!(mTextureMachine.replaced & mask);
-        info.iterated = (!info.replaced && (info.inDest || info.needed)); 
-        info.smooth =   mSmooth && info.iterated;
-        info.fog =      mFog && info.inDest && (i != GGLFormat::ALPHA);
-        info.blend =    (fs != int(GGL_ONE)) || (fd > int(GGL_ZERO));
-
-        mBlending |= (info.blend ? mask : 0);
-        mMasking |= (mCbFormat.c[i].h && info.masked) ? mask : 0;
-        fbComponents |= mCbFormat.c[i].h ? mask : 0;
-    }
-
-    mAllMasked = (mMasking == fbComponents);
-    if (mAllMasked) {
-        mDithering = 0;
-    }
-    
-    fragment_parts_t parts;
-
-    // ------------------------------------------------------------------------
-    prolog();
-    // ------------------------------------------------------------------------
-
-    build_scanline_prolog(parts, needs);
-
-    if (registerFile().status())
-        return registerFile().status();
-
-    // ------------------------------------------------------------------------
-    label("fragment_loop");
-    // ------------------------------------------------------------------------
-    {
-        Scratch regs(registerFile());
-
-        if (mDithering) {
-            // update the dither index.
-            MOV(AL, 0, parts.count.reg,
-                    reg_imm(parts.count.reg, ROR, GGL_DITHER_ORDER_SHIFT));
-            ADD(AL, 0, parts.count.reg, parts.count.reg,
-                    imm( 1 << (32 - GGL_DITHER_ORDER_SHIFT)));
-            MOV(AL, 0, parts.count.reg,
-                    reg_imm(parts.count.reg, ROR, 32 - GGL_DITHER_ORDER_SHIFT));
-        }
-
-        // XXX: could we do an early alpha-test here in some cases?
-        // It would probaly be used only with smooth-alpha and no texture
-        // (or no alpha component in the texture).
-
-        // Early z-test
-        if (mAlphaTest==GGL_ALWAYS) {
-            build_depth_test(parts, Z_TEST|Z_WRITE);
-        } else {
-            // we cannot do the z-write here, because
-            // it might be killed by the alpha-test later
-            build_depth_test(parts, Z_TEST);
-        }
-
-        { // texture coordinates
-            Scratch scratches(registerFile());
-
-            // texel generation
-            build_textures(parts, regs);
-            if (registerFile().status())
-                return registerFile().status();
-        }
-
-        if ((blending & (FACTOR_DST|BLEND_DST)) || 
-                (mMasking && !mAllMasked) ||
-                (mLogicOp & LOGIC_OP_DST)) 
-        {
-            // blending / logic_op / masking need the framebuffer
-            mDstPixel.setTo(regs.obtain(), &mCbFormat);
-
-            // load the framebuffer pixel
-            comment("fetch color-buffer");
-            load(parts.cbPtr, mDstPixel);
-        }
-
-        if (registerFile().status())
-            return registerFile().status();
-
-        pixel_t pixel;
-        int directTex = mTextureMachine.directTexture;
-        if (directTex | parts.packed) {
-            // note: we can't have both here
-            // iterated color or direct texture
-            pixel = directTex ? parts.texel[directTex-1] : parts.iterated;
-            pixel.flags &= ~CORRUPTIBLE;
-        } else {
-            if (mDithering) {
-                const int ctxtReg = mBuilderContext.Rctx;
-                const int mask = GGL_DITHER_SIZE-1;
-                parts.dither = reg_t(regs.obtain());
-                AND(AL, 0, parts.dither.reg, parts.count.reg, imm(mask));
-                ADDR_ADD(AL, 0, parts.dither.reg, ctxtReg, parts.dither.reg);
-                LDRB(AL, parts.dither.reg, parts.dither.reg,
-                        immed12_pre(GGL_OFFSETOF(ditherMatrix)));
-            }
-        
-            // allocate a register for the resulting pixel
-            pixel.setTo(regs.obtain(), &mCbFormat, FIRST);
-
-            build_component(pixel, parts, GGLFormat::ALPHA,    regs);
-
-            if (mAlphaTest!=GGL_ALWAYS) {
-                // only handle the z-write part here. We know z-test
-                // was successful, as well as alpha-test.
-                build_depth_test(parts, Z_WRITE);
-            }
-
-            build_component(pixel, parts, GGLFormat::RED,      regs);
-            build_component(pixel, parts, GGLFormat::GREEN,    regs);
-            build_component(pixel, parts, GGLFormat::BLUE,     regs);
-
-            pixel.flags |= CORRUPTIBLE;
-        }
-
-        if (registerFile().status())
-            return registerFile().status();
-        
-        if (pixel.reg == -1) {
-            // be defensive here. if we're here it's probably
-            // that this whole fragment is a no-op.
-            pixel = mDstPixel;
-        }
-        
-        if (!mAllMasked) {
-            // logic operation
-            build_logic_op(pixel, regs);
-    
-            // masking
-            build_masking(pixel, regs); 
-    
-            comment("store");
-            store(parts.cbPtr, pixel, WRITE_BACK);
-        }
-    }
-
-    if (registerFile().status())
-        return registerFile().status();
-
-    // update the iterated color...
-    if (parts.reload != 3) {
-        build_smooth_shade(parts);
-    }
-
-    // update iterated z
-    build_iterate_z(parts);
-
-    // update iterated fog
-    build_iterate_f(parts);
-
-    SUB(AL, S, parts.count.reg, parts.count.reg, imm(1<<16));
-    B(PL, "fragment_loop");
-    label("epilog");
-    epilog(registerFile().touched());
-
-    if ((mAlphaTest!=GGL_ALWAYS) || (mDepthTest!=GGL_ALWAYS)) {
-        if (mDepthTest!=GGL_ALWAYS) {
-            label("discard_before_textures");
-            build_iterate_texture_coordinates(parts);
-        }
-        label("discard_after_textures");
-        build_smooth_shade(parts);
-        build_iterate_z(parts);
-        build_iterate_f(parts);
-        if (!mAllMasked) {
-            ADDR_ADD(AL, 0, parts.cbPtr.reg, parts.cbPtr.reg, imm(parts.cbPtr.size>>3));
-        }
-        SUB(AL, S, parts.count.reg, parts.count.reg, imm(1<<16));
-        B(PL, "fragment_loop");
-        epilog(registerFile().touched());
-    }
-
-    return registerFile().status();
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::build_scanline_prolog(
-    fragment_parts_t& parts, const needs_t& needs)
-{
-    Scratch scratches(registerFile());
-
-    // compute count
-    comment("compute ct (# of pixels to process)");
-    parts.count.setTo(obtainReg());
-    int Rx = scratches.obtain();    
-    int Ry = scratches.obtain();
-    CONTEXT_LOAD(Rx, iterators.xl);
-    CONTEXT_LOAD(parts.count.reg, iterators.xr);
-    CONTEXT_LOAD(Ry, iterators.y);
-
-    // parts.count = iterators.xr - Rx
-    SUB(AL, 0, parts.count.reg, parts.count.reg, Rx);
-    SUB(AL, 0, parts.count.reg, parts.count.reg, imm(1));
-
-    if (mDithering) {
-        // parts.count.reg = 0xNNNNXXDD
-        // NNNN = count-1
-        // DD   = dither offset
-        // XX   = 0xxxxxxx (x = garbage)
-        Scratch scratches(registerFile());
-        int tx = scratches.obtain();
-        int ty = scratches.obtain();
-        AND(AL, 0, tx, Rx, imm(GGL_DITHER_MASK));
-        AND(AL, 0, ty, Ry, imm(GGL_DITHER_MASK));
-        ADD(AL, 0, tx, tx, reg_imm(ty, LSL, GGL_DITHER_ORDER_SHIFT));
-        ORR(AL, 0, parts.count.reg, tx, reg_imm(parts.count.reg, LSL, 16));
-    } else {
-        // parts.count.reg = 0xNNNN0000
-        // NNNN = count-1
-        MOV(AL, 0, parts.count.reg, reg_imm(parts.count.reg, LSL, 16));
-    }
-
-    if (!mAllMasked) {
-        // compute dst ptr
-        comment("compute color-buffer pointer");
-        const int cb_bits = mCbFormat.size*8;
-        int Rs = scratches.obtain();
-        parts.cbPtr.setTo(obtainReg(), cb_bits);
-        CONTEXT_LOAD(Rs, state.buffers.color.stride);
-        CONTEXT_ADDR_LOAD(parts.cbPtr.reg, state.buffers.color.data);
-        SMLABB(AL, Rs, Ry, Rs, Rx);  // Rs = Rx + Ry*Rs
-        base_offset(parts.cbPtr, parts.cbPtr, Rs);
-        scratches.recycle(Rs);
-    }
-    
-    // init fog
-    const int need_fog = GGL_READ_NEEDS(P_FOG, needs.p);
-    if (need_fog) {
-        comment("compute initial fog coordinate");
-        Scratch scratches(registerFile());
-        int dfdx = scratches.obtain();
-        int ydfdy = scratches.obtain();
-        int f = ydfdy;
-        CONTEXT_LOAD(dfdx,  generated_vars.dfdx);
-        CONTEXT_LOAD(ydfdy, iterators.ydfdy);
-        MLA(AL, 0, f, Rx, dfdx, ydfdy);
-        CONTEXT_STORE(f, generated_vars.f);
-    }
-
-    // init Z coordinate
-    if ((mDepthTest != GGL_ALWAYS) || GGL_READ_NEEDS(P_MASK_Z, needs.p)) {
-        parts.z = reg_t(obtainReg());
-        comment("compute initial Z coordinate");
-        Scratch scratches(registerFile());
-        int dzdx = scratches.obtain();
-        int ydzdy = parts.z.reg;
-        CONTEXT_LOAD(dzdx,  generated_vars.dzdx);   // 1.31 fixed-point
-        CONTEXT_LOAD(ydzdy, iterators.ydzdy);       // 1.31 fixed-point
-        MLA(AL, 0, parts.z.reg, Rx, dzdx, ydzdy);
-
-        // we're going to index zbase of parts.count
-        // zbase = base + (xl-count + stride*y)*2
-        int Rs = dzdx;
-        int zbase = scratches.obtain();
-        CONTEXT_LOAD(Rs, state.buffers.depth.stride);
-        CONTEXT_ADDR_LOAD(zbase, state.buffers.depth.data);
-        SMLABB(AL, Rs, Ry, Rs, Rx);
-        ADD(AL, 0, Rs, Rs, reg_imm(parts.count.reg, LSR, 16));
-        ADDR_ADD(AL, 0, zbase, zbase, reg_imm(Rs, LSL, 1));
-        CONTEXT_ADDR_STORE(zbase, generated_vars.zbase);
-    }
-
-    // init texture coordinates
-    init_textures(parts.coords, reg_t(Rx), reg_t(Ry));
-    scratches.recycle(Ry);
-
-    // iterated color
-    init_iterated_color(parts, reg_t(Rx));
-
-    // init coverage factor application (anti-aliasing)
-    if (mAA) {
-        parts.covPtr.setTo(obtainReg(), 16);
-        CONTEXT_ADDR_LOAD(parts.covPtr.reg, state.buffers.coverage);
-        ADDR_ADD(AL, 0, parts.covPtr.reg, parts.covPtr.reg, reg_imm(Rx, LSL, 1));
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::build_component( pixel_t& pixel,
-                                    const fragment_parts_t& parts,
-                                    int component,
-                                    Scratch& regs)
-{
-    static char const * comments[] = {"alpha", "red", "green", "blue"};
-    comment(comments[component]);
-
-    // local register file
-    Scratch scratches(registerFile());
-    const int dst_component_size = pixel.component_size(component);
-
-    component_t temp(-1);
-    build_incoming_component( temp, dst_component_size,
-            parts, component, scratches, regs);
-
-    if (mInfo[component].inDest) {
-
-        // blending...
-        build_blending( temp, mDstPixel, component, scratches );
-
-        // downshift component and rebuild pixel...
-        downshift(pixel, component, temp, parts.dither);
-    }
-}
-
-void GGLAssembler::build_incoming_component(
-                                    component_t& temp,
-                                    int dst_size,
-                                    const fragment_parts_t& parts,
-                                    int component,
-                                    Scratch& scratches,
-                                    Scratch& global_regs)
-{
-    const uint32_t component_mask = 1<<component;
-
-    // Figure out what we need for the blending stage...
-    int fs = component==GGLFormat::ALPHA ? mBlendSrcA : mBlendSrc;
-    int fd = component==GGLFormat::ALPHA ? mBlendDstA : mBlendDst;
-    if (fs==GGL_SRC_ALPHA_SATURATE && component==GGLFormat::ALPHA) {
-        fs = GGL_ONE;
-    }
-
-    // Figure out what we need to extract and for what reason
-    const int blending = blending_codes(fs, fd);
-
-    // Are we actually going to blend?
-    const int need_blending = (fs != int(GGL_ONE)) || (fd > int(GGL_ZERO));
-    
-    // expand the source if the destination has more bits
-    int need_expander = false;
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT-1 ; i++) {
-        texture_unit_t& tmu = mTextureMachine.tmu[i];
-        if ((tmu.format_idx) &&
-            (parts.texel[i].component_size(component) < dst_size)) {
-            need_expander = true;
-        }
-    }
-
-    // do we need to extract this component?
-    const bool multiTexture = mTextureMachine.activeUnits > 1;
-    const int blend_needs_alpha_source = (component==GGLFormat::ALPHA) &&
-                                        (isAlphaSourceNeeded());
-    int need_extract = mInfo[component].needed;
-    if (mInfo[component].inDest)
-    {
-        need_extract |= ((need_blending ?
-                (blending & (BLEND_SRC|FACTOR_SRC)) : need_expander));
-        need_extract |= (mTextureMachine.mask != mTextureMachine.replaced);
-        need_extract |= mInfo[component].smooth;
-        need_extract |= mInfo[component].fog;
-        need_extract |= mDithering;
-        need_extract |= multiTexture;
-    }
-
-    if (need_extract) {
-        Scratch& regs = blend_needs_alpha_source ? global_regs : scratches;
-        component_t fragment;
-
-        // iterated color
-        build_iterated_color(fragment, parts, component, regs);
-
-        // texture environement (decal, modulate, replace)
-        build_texture_environment(fragment, parts, component, regs);
-
-        // expand the source if the destination has more bits
-        if (need_expander && (fragment.size() < dst_size)) {
-            // we're here only if we fetched a texel
-            // (so we know for sure fragment is CORRUPTIBLE)
-            expand(fragment, fragment, dst_size);
-        }
-
-        // We have a few specific things to do for the alpha-channel
-        if ((component==GGLFormat::ALPHA) &&
-            (mInfo[component].needed || fragment.size()<dst_size))
-        {
-            // convert to integer_t first and make sure
-            // we don't corrupt a needed register
-            if (fragment.l) {
-                component_t incoming(fragment);
-                modify(fragment, regs);
-                MOV(AL, 0, fragment.reg, reg_imm(incoming.reg, LSR, incoming.l));
-                fragment.h -= fragment.l;
-                fragment.l = 0;
-            }
-
-            // coverage factor application
-            build_coverage_application(fragment, parts, regs);
-
-            // alpha-test
-            build_alpha_test(fragment, parts);
-
-            if (blend_needs_alpha_source) {
-                // We keep only 8 bits for the blending stage
-                const int shift = fragment.h <= 8 ? 0 : fragment.h-8;
-                if (fragment.flags & CORRUPTIBLE) {
-                    fragment.flags &= ~CORRUPTIBLE;
-                    mAlphaSource.setTo(fragment.reg,
-                            fragment.size(), fragment.flags);
-                    if (shift) {
-                        MOV(AL, 0, mAlphaSource.reg,
-                            reg_imm(mAlphaSource.reg, LSR, shift));
-                    }
-                } else {
-                    // XXX: it would better to do this in build_blend_factor()
-                    // so we can avoid the extra MOV below.
-                    mAlphaSource.setTo(regs.obtain(),
-                            fragment.size(), CORRUPTIBLE);
-                    if (shift) {
-                        MOV(AL, 0, mAlphaSource.reg,
-                            reg_imm(fragment.reg, LSR, shift));
-                    } else {
-                        MOV(AL, 0, mAlphaSource.reg, fragment.reg);
-                    }
-                }
-                mAlphaSource.s -= shift;
-            }
-        }
-
-        // fog...
-        build_fog( fragment, component, regs );
-
-        temp = fragment;
-    } else {
-        if (mInfo[component].inDest) {
-            // extraction not needed and replace
-            // we just select the right component
-            if ((mTextureMachine.replaced & component_mask) == 0) {
-                // component wasn't replaced, so use it!
-                temp = component_t(parts.iterated, component);
-            }
-            for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; i++) {
-                const texture_unit_t& tmu = mTextureMachine.tmu[i];
-                if ((tmu.mask & component_mask) &&
-                    ((tmu.replaced & component_mask) == 0)) {
-                    temp = component_t(parts.texel[i], component);
-                }
-            }
-        }
-    }
-}
-
-bool GGLAssembler::isAlphaSourceNeeded() const
-{
-    // XXX: also needed for alpha-test
-    const int bs = mBlendSrc;
-    const int bd = mBlendDst;
-    return  bs==GGL_SRC_ALPHA_SATURATE ||
-            bs==GGL_SRC_ALPHA || bs==GGL_ONE_MINUS_SRC_ALPHA ||
-            bd==GGL_SRC_ALPHA || bd==GGL_ONE_MINUS_SRC_ALPHA ; 
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::build_smooth_shade(const fragment_parts_t& parts)
-{
-    if (mSmooth && !parts.iterated_packed) {
-        // update the iterated color in a pipelined way...
-        comment("update iterated color");
-        Scratch scratches(registerFile());
-
-        const int reload = parts.reload;
-        for (int i=0 ; i<4 ; i++) {
-            if (!mInfo[i].iterated) 
-                continue;
-                
-            int c = parts.argb[i].reg;
-            int dx = parts.argb_dx[i].reg;
-            
-            if (reload & 1) {
-                c = scratches.obtain();
-                CONTEXT_LOAD(c, generated_vars.argb[i].c);
-            }
-            if (reload & 2) {
-                dx = scratches.obtain();
-                CONTEXT_LOAD(dx, generated_vars.argb[i].dx);
-            }
-            
-            if (mSmooth) {
-                ADD(AL, 0, c, c, dx);
-            }
-            
-            if (reload & 1) {
-                CONTEXT_STORE(c, generated_vars.argb[i].c);
-                scratches.recycle(c);
-            }
-            if (reload & 2) {
-                scratches.recycle(dx);
-            }
-        }
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::build_coverage_application(component_t& fragment,
-        const fragment_parts_t& parts, Scratch& regs)
-{
-    // here fragment.l is guarenteed to be 0
-    if (mAA) {
-        // coverages are 1.15 fixed-point numbers
-        comment("coverage application");
-
-        component_t incoming(fragment);
-        modify(fragment, regs);
-
-        Scratch scratches(registerFile());
-        int cf = scratches.obtain();
-        LDRH(AL, cf, parts.covPtr.reg, immed8_post(2));
-        if (fragment.h > 31) {
-            fragment.h--;
-            SMULWB(AL, fragment.reg, incoming.reg, cf);
-        } else {
-            MOV(AL, 0, fragment.reg, reg_imm(incoming.reg, LSL, 1));
-            SMULWB(AL, fragment.reg, fragment.reg, cf);
-        }
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::build_alpha_test(component_t& fragment,
-                                    const fragment_parts_t& /*parts*/)
-{
-    if (mAlphaTest != GGL_ALWAYS) {
-        comment("Alpha Test");
-        Scratch scratches(registerFile());
-        int ref = scratches.obtain();
-        const int shift = GGL_COLOR_BITS-fragment.size();
-        CONTEXT_LOAD(ref, state.alpha_test.ref);
-        if (shift) CMP(AL, fragment.reg, reg_imm(ref, LSR, shift));
-        else       CMP(AL, fragment.reg, ref);
-        int cc = NV;
-        switch (mAlphaTest) {
-        case GGL_NEVER:     cc = NV;    break;
-        case GGL_LESS:      cc = LT;    break;
-        case GGL_EQUAL:     cc = EQ;    break;
-        case GGL_LEQUAL:    cc = LS;    break;
-        case GGL_GREATER:   cc = HI;    break;
-        case GGL_NOTEQUAL:  cc = NE;    break;
-        case GGL_GEQUAL:    cc = HS;    break;
-        }
-        B(cc^1, "discard_after_textures");
-    }
-}
-
-// ---------------------------------------------------------------------------
-            
-void GGLAssembler::build_depth_test(
-        const fragment_parts_t& parts, uint32_t mask)
-{
-    mask &= Z_TEST|Z_WRITE;
-    const needs_t& needs = mBuilderContext.needs;
-    const int zmask = GGL_READ_NEEDS(P_MASK_Z, needs.p);
-    Scratch scratches(registerFile());
-
-    if (mDepthTest != GGL_ALWAYS || zmask) {
-        int cc=AL, ic=AL;
-        switch (mDepthTest) {
-        case GGL_LESS:      ic = HI;    break;
-        case GGL_EQUAL:     ic = EQ;    break;
-        case GGL_LEQUAL:    ic = HS;    break;
-        case GGL_GREATER:   ic = LT;    break;
-        case GGL_NOTEQUAL:  ic = NE;    break;
-        case GGL_GEQUAL:    ic = LS;    break;
-        case GGL_NEVER:
-            // this never happens, because it's taken care of when 
-            // computing the needs. but we keep it for completness.
-            comment("Depth Test (NEVER)");
-            B(AL, "discard_before_textures");
-            return;
-        case GGL_ALWAYS:
-            // we're here because zmask is enabled
-            mask &= ~Z_TEST;    // test always passes.
-            break;
-        }
-        
-        // inverse the condition
-        cc = ic^1;
-        
-        if ((mask & Z_WRITE) && !zmask) {
-            mask &= ~Z_WRITE;
-        }
-        
-        if (!mask)
-            return;
-
-        comment("Depth Test");
-
-        int zbase = scratches.obtain();
-        int depth = scratches.obtain();
-        int z = parts.z.reg;
-        
-        CONTEXT_ADDR_LOAD(zbase, generated_vars.zbase);  // stall
-        ADDR_SUB(AL, 0, zbase, zbase, reg_imm(parts.count.reg, LSR, 15));
-            // above does zbase = zbase + ((count >> 16) << 1)
-
-        if (mask & Z_TEST) {
-            LDRH(AL, depth, zbase);  // stall
-            CMP(AL, depth, reg_imm(z, LSR, 16));
-            B(cc, "discard_before_textures");
-        }
-        if (mask & Z_WRITE) {
-            if (mask == Z_WRITE) {
-                // only z-write asked, cc is meaningless
-                ic = AL;
-            }
-            MOV(AL, 0, depth, reg_imm(z, LSR, 16));
-            STRH(ic, depth, zbase);
-        }
-    }
-}
-
-void GGLAssembler::build_iterate_z(const fragment_parts_t& parts)
-{
-    const needs_t& needs = mBuilderContext.needs;
-    if ((mDepthTest != GGL_ALWAYS) || GGL_READ_NEEDS(P_MASK_Z, needs.p)) {
-        Scratch scratches(registerFile());
-        int dzdx = scratches.obtain();
-        CONTEXT_LOAD(dzdx, generated_vars.dzdx);    // stall
-        ADD(AL, 0, parts.z.reg, parts.z.reg, dzdx); 
-    }
-}
-
-void GGLAssembler::build_iterate_f(const fragment_parts_t& /*parts*/)
-{
-    const needs_t& needs = mBuilderContext.needs;
-    if (GGL_READ_NEEDS(P_FOG, needs.p)) {
-        Scratch scratches(registerFile());
-        int dfdx = scratches.obtain();
-        int f = scratches.obtain();
-        CONTEXT_LOAD(f,     generated_vars.f);
-        CONTEXT_LOAD(dfdx,  generated_vars.dfdx);   // stall
-        ADD(AL, 0, f, f, dfdx);
-        CONTEXT_STORE(f,    generated_vars.f);
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::build_logic_op(pixel_t& pixel, Scratch& regs)
-{
-    const needs_t& needs = mBuilderContext.needs;
-    const int opcode = GGL_READ_NEEDS(LOGIC_OP, needs.n) | GGL_CLEAR;
-    if (opcode == GGL_COPY)
-        return;
-    
-    comment("logic operation");
-
-    pixel_t s(pixel);
-    if (!(pixel.flags & CORRUPTIBLE)) {
-        pixel.reg = regs.obtain();
-        pixel.flags |= CORRUPTIBLE;
-    }
-    
-    pixel_t d(mDstPixel);
-    switch(opcode) {
-    case GGL_CLEAR:         MOV(AL, 0, pixel.reg, imm(0));          break;
-    case GGL_AND:           AND(AL, 0, pixel.reg, s.reg, d.reg);    break;
-    case GGL_AND_REVERSE:   BIC(AL, 0, pixel.reg, s.reg, d.reg);    break;
-    case GGL_COPY:                                                  break;
-    case GGL_AND_INVERTED:  BIC(AL, 0, pixel.reg, d.reg, s.reg);    break;
-    case GGL_NOOP:          MOV(AL, 0, pixel.reg, d.reg);           break;
-    case GGL_XOR:           EOR(AL, 0, pixel.reg, s.reg, d.reg);    break;
-    case GGL_OR:            ORR(AL, 0, pixel.reg, s.reg, d.reg);    break;
-    case GGL_NOR:           ORR(AL, 0, pixel.reg, s.reg, d.reg);
-                            MVN(AL, 0, pixel.reg, pixel.reg);       break;
-    case GGL_EQUIV:         EOR(AL, 0, pixel.reg, s.reg, d.reg);
-                            MVN(AL, 0, pixel.reg, pixel.reg);       break;
-    case GGL_INVERT:        MVN(AL, 0, pixel.reg, d.reg);           break;
-    case GGL_OR_REVERSE:    // s | ~d == ~(~s & d)
-                            BIC(AL, 0, pixel.reg, d.reg, s.reg);
-                            MVN(AL, 0, pixel.reg, pixel.reg);       break;
-    case GGL_COPY_INVERTED: MVN(AL, 0, pixel.reg, s.reg);           break;
-    case GGL_OR_INVERTED:   // ~s | d == ~(s & ~d)
-                            BIC(AL, 0, pixel.reg, s.reg, d.reg);
-                            MVN(AL, 0, pixel.reg, pixel.reg);       break;
-    case GGL_NAND:          AND(AL, 0, pixel.reg, s.reg, d.reg);
-                            MVN(AL, 0, pixel.reg, pixel.reg);       break;
-    case GGL_SET:           MVN(AL, 0, pixel.reg, imm(0));          break;
-    };        
-}
-
-// ---------------------------------------------------------------------------
-
-static uint32_t find_bottom(uint32_t val)
-{
-    uint32_t i = 0;
-    while (!(val & (3<<i)))
-        i+= 2;
-    return i;
-}
-
-static void normalize(uint32_t& val, uint32_t& rot)
-{
-    rot = 0;
-    while (!(val&3)  || (val & 0xFC000000)) {
-        uint32_t newval;
-        newval = val >> 2;
-        newval |= (val&3) << 30;
-        val = newval;
-        rot += 2;
-        if (rot == 32) {
-            rot = 0;
-            break;
-        }
-    }
-}
-
-void GGLAssembler::build_and_immediate(int d, int s, uint32_t mask, int bits)
-{
-    uint32_t rot;
-    uint32_t size = ((bits>=32) ? 0 : (1LU << bits)) - 1;
-    mask &= size;
-
-    if (mask == size) {
-        if (d != s)
-            MOV( AL, 0, d, s);
-        return;
-    }
-    
-    if ((getCodegenArch() == CODEGEN_ARCH_MIPS) ||
-        (getCodegenArch() == CODEGEN_ARCH_MIPS64)) {
-        // MIPS can do 16-bit imm in 1 instr, 32-bit in 3 instr
-        // the below ' while (mask)' code is buggy on mips
-        // since mips returns true on isValidImmediate()
-        // then we get multiple AND instr (positive logic)
-        AND( AL, 0, d, s, imm(mask) );
-        return;
-    }
-    else if (getCodegenArch() == CODEGEN_ARCH_ARM64) {
-        AND( AL, 0, d, s, imm(mask) );
-        return;
-    }
-
-    int negative_logic = !isValidImmediate(mask);
-    if (negative_logic) {
-        mask = ~mask & size;
-    }
-    normalize(mask, rot);
-
-    if (mask) {
-        while (mask) {
-            uint32_t bitpos = find_bottom(mask);
-            int shift = rot + bitpos;
-            uint32_t m = mask & (0xff << bitpos);
-            mask &= ~m;
-            m >>= bitpos;
-            int32_t newMask =  (m<<shift) | (m>>(32-shift));
-            if (!negative_logic) {
-                AND( AL, 0, d, s, imm(newMask) );
-            } else {
-                BIC( AL, 0, d, s, imm(newMask) );
-            }
-            s = d;
-        }
-    } else {
-        MOV( AL, 0, d, imm(0));
-    }
-}		
-
-void GGLAssembler::build_masking(pixel_t& pixel, Scratch& regs)
-{
-    if (!mMasking || mAllMasked) {
-        return;
-    }
-
-    comment("color mask");
-
-    pixel_t fb(mDstPixel);
-    pixel_t s(pixel);
-    if (!(pixel.flags & CORRUPTIBLE)) {
-        pixel.reg = regs.obtain();
-        pixel.flags |= CORRUPTIBLE;
-    }
-
-    int mask = 0;
-    for (int i=0 ; i<4 ; i++) {
-        const int component_mask = 1<<i;
-        const int h = fb.format.c[i].h;
-        const int l = fb.format.c[i].l;
-        if (h && (!(mMasking & component_mask))) {
-            mask |= ((1<<(h-l))-1) << l;
-        }
-    }
-
-    // There is no need to clear the masked components of the source
-    // (unless we applied a logic op), because they're already zeroed 
-    // by construction (masked components are not computed)
-
-    if (mLogicOp) {
-        const needs_t& needs = mBuilderContext.needs;
-        const int opcode = GGL_READ_NEEDS(LOGIC_OP, needs.n) | GGL_CLEAR;
-        if (opcode != GGL_CLEAR) {
-            // clear masked component of source
-            build_and_immediate(pixel.reg, s.reg, mask, fb.size());
-            s = pixel;
-        }
-    }
-
-    // clear non masked components of destination
-    build_and_immediate(fb.reg, fb.reg, ~mask, fb.size()); 
-
-    // or back the channels that were masked
-    if (s.reg == fb.reg) {
-         // this is in fact a MOV
-        if (s.reg == pixel.reg) {
-            // ugh. this in in fact a nop
-        } else {
-            MOV(AL, 0, pixel.reg, fb.reg);
-        }
-    } else {
-        ORR(AL, 0, pixel.reg, s.reg, fb.reg);
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::base_offset(
-        const pointer_t& d, const pointer_t& b, const reg_t& o)
-{
-    switch (b.size) {
-    case 32:
-        ADDR_ADD(AL, 0, d.reg, b.reg, reg_imm(o.reg, LSL, 2));
-        break;
-    case 24:
-        if (d.reg == b.reg) {
-            ADDR_ADD(AL, 0, d.reg, b.reg, reg_imm(o.reg, LSL, 1));
-            ADDR_ADD(AL, 0, d.reg, d.reg, o.reg);
-        } else {
-            ADDR_ADD(AL, 0, d.reg, o.reg, reg_imm(o.reg, LSL, 1));
-            ADDR_ADD(AL, 0, d.reg, d.reg, b.reg);
-        }
-        break;
-    case 16:
-        ADDR_ADD(AL, 0, d.reg, b.reg, reg_imm(o.reg, LSL, 1));
-        break;
-    case 8:
-        ADDR_ADD(AL, 0, d.reg, b.reg, o.reg);
-        break;
-    }
-}
-
-// ----------------------------------------------------------------------------
-// cheezy register allocator...
-// ----------------------------------------------------------------------------
-
-// Modified to support MIPS processors, in a very simple way. We retain the
-// (Arm) limit of 16 total registers, but shift the mapping of those registers
-// from 0-15, to 2-17. Register 0 on Mips cannot be used as GP registers, and
-// register 1 has a traditional use as a temp).
-
-RegisterAllocator::RegisterAllocator(int arch) : mRegs(arch)
-{
-}
-
-void RegisterAllocator::reset()
-{
-    mRegs.reset();
-}
-
-int RegisterAllocator::reserveReg(int reg)
-{
-    return mRegs.reserve(reg);
-}
-
-int RegisterAllocator::obtainReg()
-{
-    return mRegs.obtain();
-}
-
-void RegisterAllocator::recycleReg(int reg)
-{
-    mRegs.recycle(reg);
-}
-
-RegisterAllocator::RegisterFile& RegisterAllocator::registerFile()
-{
-    return mRegs;
-}
-
-// ----------------------------------------------------------------------------
-
-RegisterAllocator::RegisterFile::RegisterFile(int codegen_arch)
-    : mRegs(0), mTouched(0), mStatus(0), mArch(codegen_arch), mRegisterOffset(0)
-{
-    if ((mArch == ARMAssemblerInterface::CODEGEN_ARCH_MIPS) ||
-        (mArch == ARMAssemblerInterface::CODEGEN_ARCH_MIPS64)) {
-        mRegisterOffset = 2;    // ARM has regs 0..15, MIPS offset to 2..17
-    }
-    reserve(ARMAssemblerInterface::SP);
-    reserve(ARMAssemblerInterface::PC);
-}
-
-RegisterAllocator::RegisterFile::RegisterFile(const RegisterFile& rhs, int codegen_arch)
-    : mRegs(rhs.mRegs), mTouched(rhs.mTouched), mArch(codegen_arch), mRegisterOffset(0)
-{
-    if ((mArch == ARMAssemblerInterface::CODEGEN_ARCH_MIPS) ||
-        (mArch == ARMAssemblerInterface::CODEGEN_ARCH_MIPS64)) {
-        mRegisterOffset = 2;    // ARM has regs 0..15, MIPS offset to 2..17
-    }
-}
-
-RegisterAllocator::RegisterFile::~RegisterFile()
-{
-}
-
-bool RegisterAllocator::RegisterFile::operator == (const RegisterFile& rhs) const
-{
-    return (mRegs == rhs.mRegs);
-}
-
-void RegisterAllocator::RegisterFile::reset()
-{
-    mRegs = mTouched = mStatus = 0;
-    reserve(ARMAssemblerInterface::SP);
-    reserve(ARMAssemblerInterface::PC);
-}
-
-// RegisterFile::reserve() take a register parameter in the
-// range 0-15 (Arm compatible), but on a Mips processor, will
-// return the actual allocated register in the range 2-17.
-int RegisterAllocator::RegisterFile::reserve(int reg)
-{
-    reg += mRegisterOffset;
-    LOG_ALWAYS_FATAL_IF(isUsed(reg),
-                        "reserving register %d, but already in use",
-                        reg);
-    mRegs |= (1<<reg);
-    mTouched |= mRegs;
-    return reg;
-}
-
-// This interface uses regMask in range 2-17 on MIPS, no translation.
-void RegisterAllocator::RegisterFile::reserveSeveral(uint32_t regMask)
-{
-    mRegs |= regMask;
-    mTouched |= regMask;
-}
-
-int RegisterAllocator::RegisterFile::isUsed(int reg) const
-{
-    LOG_ALWAYS_FATAL_IF(reg>=16+(int)mRegisterOffset, "invalid register %d", reg);
-    return mRegs & (1<<reg);
-}
-
-int RegisterAllocator::RegisterFile::obtain()
-{
-    const char priorityList[14] = {  0,  1, 2, 3, 
-                                    12, 14, 4, 5, 
-                                     6,  7, 8, 9,
-                                    10, 11 };
-    const int nbreg = sizeof(priorityList);
-    int i, r, reg;
-    for (i=0 ; i<nbreg ; i++) {
-        r = priorityList[i];
-        if (!isUsed(r + mRegisterOffset)) {
-            break;
-        }
-    }
-    // this is not an error anymore because, we'll try again with
-    // a lower optimization level.
-    //ALOGE_IF(i >= nbreg, "pixelflinger ran out of registers\n");
-    if (i >= nbreg) {
-        mStatus |= OUT_OF_REGISTERS;
-        // we return SP so we can more easily debug things
-        // the code will never be run anyway.
-        return ARMAssemblerInterface::SP; 
-    }
-    reg = reserve(r);  // Param in Arm range 0-15, returns range 2-17 on Mips.
-    return reg;
-}
-
-bool RegisterAllocator::RegisterFile::hasFreeRegs() const
-{
-    uint32_t regs = mRegs >> mRegisterOffset;   // MIPS fix.
-    return ((regs & 0xFFFF) == 0xFFFF) ? false : true;
-}
-
-int RegisterAllocator::RegisterFile::countFreeRegs() const
-{
-    uint32_t regs = mRegs >> mRegisterOffset;   // MIPS fix.
-    int f = ~regs & 0xFFFF;
-    // now count number of 1
-   f = (f & 0x5555) + ((f>>1) & 0x5555);
-   f = (f & 0x3333) + ((f>>2) & 0x3333);
-   f = (f & 0x0F0F) + ((f>>4) & 0x0F0F);
-   f = (f & 0x00FF) + ((f>>8) & 0x00FF);
-   return f;
-}
-
-void RegisterAllocator::RegisterFile::recycle(int reg)
-{
-    // commented out, since common failure of running out of regs
-    // triggers this assertion. Since the code is not execectued
-    // in that case, it does not matter. No reason to FATAL err.
-    // LOG_FATAL_IF(!isUsed(reg),
-    //         "recycling unallocated register %d",
-    //         reg);
-    mRegs &= ~(1<<reg);
-}
-
-void RegisterAllocator::RegisterFile::recycleSeveral(uint32_t regMask)
-{
-    // commented out, since common failure of running out of regs
-    // triggers this assertion. Since the code is not execectued
-    // in that case, it does not matter. No reason to FATAL err.
-    // LOG_FATAL_IF((mRegs & regMask)!=regMask,
-    //         "recycling unallocated registers "
-    //         "(recycle=%08x, allocated=%08x, unallocated=%08x)",
-    //         regMask, mRegs, mRegs&regMask);
-    mRegs &= ~regMask;
-}
-
-uint32_t RegisterAllocator::RegisterFile::touched() const
-{
-    return mTouched;
-}
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
diff --git a/libpixelflinger/codeflinger/GGLAssembler.h b/libpixelflinger/codeflinger/GGLAssembler.h
deleted file mode 100644
index 47dbf3a..0000000
--- a/libpixelflinger/codeflinger/GGLAssembler.h
+++ /dev/null
@@ -1,572 +0,0 @@
-/* libs/pixelflinger/codeflinger/GGLAssembler.h
-**
-** Copyright 2006, 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_GGLASSEMBLER_H
-#define ANDROID_GGLASSEMBLER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <private/pixelflinger/ggl_context.h>
-
-#include "ARMAssemblerProxy.h"
-
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-#define CONTEXT_ADDR_LOAD(REG, FIELD) \
-    ADDR_LDR(AL, REG, mBuilderContext.Rctx, immed12_pre(GGL_OFFSETOF(FIELD)))
-
-#define CONTEXT_ADDR_STORE(REG, FIELD) \
-    ADDR_STR(AL, REG, mBuilderContext.Rctx, immed12_pre(GGL_OFFSETOF(FIELD)))
-
-#define CONTEXT_LOAD(REG, FIELD) \
-    LDR(AL, REG, mBuilderContext.Rctx, immed12_pre(GGL_OFFSETOF(FIELD)))
-
-#define CONTEXT_STORE(REG, FIELD) \
-    STR(AL, REG, mBuilderContext.Rctx, immed12_pre(GGL_OFFSETOF(FIELD)))
-
-
-class RegisterAllocator
-{
-public:
-    class RegisterFile;
-    
-                    RegisterAllocator(int arch);  // NOLINT, implicit
-    RegisterFile&   registerFile();
-    int             reserveReg(int reg);
-    int             obtainReg();
-    void            recycleReg(int reg);
-    void            reset();
-
-    class RegisterFile
-    {
-    public:
-                            RegisterFile(int arch);  // NOLINT, implicit
-                            RegisterFile(const RegisterFile& rhs, int arch);
-                            ~RegisterFile();
-
-                void        reset();
-
-                bool operator == (const RegisterFile& rhs) const;
-                bool operator != (const RegisterFile& rhs) const {
-                    return !operator == (rhs);
-                }
-
-                int         reserve(int reg);
-                void        reserveSeveral(uint32_t regMask);
-
-                void        recycle(int reg);
-                void        recycleSeveral(uint32_t regMask);
-
-                int         obtain();
-        inline  int         isUsed(int reg) const;
-
-                bool        hasFreeRegs() const;
-                int         countFreeRegs() const;                
-
-                uint32_t    touched() const;
-        inline  uint32_t    status() const { return mStatus; }
-        
-        enum {
-            OUT_OF_REGISTERS = 0x1
-        };
-
-    private:
-        uint32_t    mRegs;
-        uint32_t    mTouched;
-        uint32_t    mStatus;
-        int         mArch;
-        uint32_t    mRegisterOffset;    // lets reg alloc use 2..17 for mips
-                                        // while arm uses 0..15
-    };
- 
-    class Scratch
-    {
-    public:
-            explicit Scratch(RegisterFile& regFile)
-                : mRegFile(regFile), mScratch(0) { 
-            }
-            ~Scratch() {
-                mRegFile.recycleSeveral(mScratch);
-            }
-        int obtain() { 
-            int reg = mRegFile.obtain();
-            mScratch |= 1<<reg;
-            return reg;
-        }
-        void recycle(int reg) {
-            mRegFile.recycle(reg);
-            mScratch &= ~(1<<reg);
-        }
-        bool isUsed(int reg) {
-            return (mScratch & (1<<reg));
-        }
-        int countFreeRegs() {
-            return mRegFile.countFreeRegs();
-        }
-    private:
-        RegisterFile&   mRegFile;
-        uint32_t        mScratch;
-    };
-
-    class Spill
-    {
-    public:
-        Spill(RegisterFile& regFile, ARMAssemblerInterface& gen, uint32_t reglist)
-            : mRegFile(regFile), mGen(gen), mRegList(reglist), mCount(0)
-        {
-            if (reglist) {
-                int count = 0;
-                while (reglist) {
-                    count++;
-                    reglist &= ~(1 << (31 - __builtin_clz(reglist)));
-                }
-                if (count == 1) {
-                    int reg = 31 - __builtin_clz(mRegList);
-                    mGen.STR(mGen.AL, reg, mGen.SP, mGen.immed12_pre(-4, 1));
-                } else {
-                    mGen.STM(mGen.AL, mGen.DB, mGen.SP, 1, mRegList);
-                }
-                mRegFile.recycleSeveral(mRegList);
-                mCount = count;
-            }
-        }
-        ~Spill() {
-            if (mRegList) {
-                if (mCount == 1) {
-                    int reg = 31 - __builtin_clz(mRegList);
-                    mGen.LDR(mGen.AL, reg, mGen.SP, mGen.immed12_post(4));
-                } else {
-                    mGen.LDM(mGen.AL, mGen.IA, mGen.SP, 1, mRegList);
-                }
-                mRegFile.reserveSeveral(mRegList);
-            }
-        }
-    private:
-        RegisterFile&           mRegFile;
-        ARMAssemblerInterface&  mGen;
-        uint32_t                mRegList;
-        int                     mCount;
-    };
-    
-private:
-    RegisterFile    mRegs;
-};
-
-// ----------------------------------------------------------------------------
-
-class GGLAssembler : public ARMAssemblerProxy, public RegisterAllocator
-{
-public:
-
-    explicit    GGLAssembler(ARMAssemblerInterface* target);
-    virtual     ~GGLAssembler();
-
-    uint32_t*   base() const { return 0; } // XXX
-    uint32_t*   pc() const { return 0; } // XXX
-
-    void        reset(int opt_level);
-
-    virtual void    prolog();
-    virtual void    epilog(uint32_t touched);
-
-        // generate scanline code for given needs
-    int         scanline(const needs_t& needs, context_t const* c);
-    int         scanline_core(const needs_t& needs, context_t const* c);
-
-        enum {
-            CLEAR_LO    = 0x0001,
-            CLEAR_HI    = 0x0002,
-            CORRUPTIBLE = 0x0004,
-            FIRST       = 0x0008
-        };
-
-        enum { //load/store flags
-            WRITE_BACK  = 0x0001
-        };
-
-        struct reg_t {
-            reg_t() : reg(-1), flags(0) {
-            }
-            reg_t(int r, int f=0)  // NOLINT, implicit
-                : reg(r), flags(f) {
-            }
-            void setTo(int r, int f=0) {
-                reg=r; flags=f;
-            }
-            int         reg;
-            uint16_t    flags;
-        };
-
-        struct integer_t : public reg_t {
-            integer_t() : reg_t(), s(0) {
-            }
-            integer_t(int r, int sz=32, int f=0)  // NOLINT, implicit
-                : reg_t(r, f), s(sz) {
-            }
-            void setTo(int r, int sz=32, int f=0) {
-                reg_t::setTo(r, f); s=sz;
-            }
-            int8_t s;
-            inline int size() const { return s; }
-        };
-        
-        struct pixel_t : public reg_t {
-            pixel_t() : reg_t() {
-                memset(&format, 0, sizeof(GGLFormat));
-            }
-            pixel_t(int r, const GGLFormat* fmt, int f=0)
-                : reg_t(r, f), format(*fmt) {
-            }
-            void setTo(int r, const GGLFormat* fmt, int f=0) {
-                reg_t::setTo(r, f); format = *fmt;
-            }
-            GGLFormat format;
-            inline int hi(int c) const { return format.c[c].h; }
-            inline int low(int c) const { return format.c[c].l; }
-            inline int mask(int c) const { return ((1<<size(c))-1) << low(c); }
-            inline int size() const { return format.size*8; }
-            inline int size(int c) const { return component_size(c); }
-            inline int component_size(int c) const { return hi(c) - low(c); }
-        };
-
-        struct component_t : public reg_t {
-            component_t() : reg_t(), h(0), l(0) {
-            }
-            component_t(int r, int f=0)  // NOLINT, implicit
-                : reg_t(r, f), h(0), l(0) {
-            }
-            component_t(int r, int lo, int hi, int f=0)
-                : reg_t(r, f), h(hi), l(lo) {
-            }
-            explicit component_t(const integer_t& rhs)
-                : reg_t(rhs.reg, rhs.flags), h(rhs.s), l(0) {
-            }
-            explicit component_t(const pixel_t& rhs, int component) {
-                setTo(  rhs.reg, 
-                        rhs.format.c[component].l,
-                        rhs.format.c[component].h,
-                        rhs.flags|CLEAR_LO|CLEAR_HI);
-            }
-            void setTo(int r, int lo=0, int hi=0, int f=0) {
-                reg_t::setTo(r, f); h=hi; l=lo;
-            }
-            int8_t h;
-            int8_t l;
-            inline int size() const { return h-l; }
-        };
-
-        struct pointer_t : public reg_t {
-            pointer_t() : reg_t(), size(0) {
-            }
-            pointer_t(int r, int s, int f=0)
-                : reg_t(r, f), size(s) {
-            }
-            void setTo(int r, int s, int f=0) {
-                reg_t::setTo(r, f); size=s;
-            }
-            int8_t size;
-        };
-
-
-private:
-    // GGLAssembler hides RegisterAllocator's and ARMAssemblerProxy's reset
-    // methods by providing a reset method with a different parameter set. The
-    // intent of GGLAssembler's reset method is to wrap the inherited reset
-    // methods, so make these methods private in order to prevent direct calls
-    // to these methods from clients.
-    using RegisterAllocator::reset;
-    using ARMAssemblerProxy::reset;
-
-    struct tex_coord_t {
-        reg_t       s;
-        reg_t       t;
-        pointer_t   ptr;
-    };
-
-    struct fragment_parts_t {
-        uint32_t    packed  : 1;
-        uint32_t    reload  : 2;
-        uint32_t    iterated_packed  : 1;
-        pixel_t     iterated;
-        pointer_t   cbPtr;
-        pointer_t   covPtr;
-        reg_t       count;
-        reg_t       argb[4];
-        reg_t       argb_dx[4];
-        reg_t       z;
-        reg_t       dither;
-        pixel_t     texel[GGL_TEXTURE_UNIT_COUNT];
-        tex_coord_t coords[GGL_TEXTURE_UNIT_COUNT];
-    };
-    
-    struct texture_unit_t {
-        int         format_idx;
-        GGLFormat   format;
-        int         bits;
-        int         swrap;
-        int         twrap;
-        int         env;
-        int         pot;
-        int         linear;
-        uint8_t     mask;
-        uint8_t     replaced;
-    };
-
-    struct texture_machine_t {
-        texture_unit_t  tmu[GGL_TEXTURE_UNIT_COUNT];
-        uint8_t         mask;
-        uint8_t         replaced;
-        uint8_t         directTexture;
-        uint8_t         activeUnits;
-    };
-
-    struct component_info_t {
-        bool    masked      : 1;
-        bool    inDest      : 1;
-        bool    needed      : 1;
-        bool    replaced    : 1;
-        bool    iterated    : 1;
-        bool    smooth      : 1;
-        bool    blend       : 1;
-        bool    fog         : 1;
-    };
-
-    struct builder_context_t {
-        context_t const*    c;
-        needs_t             needs;
-        int                 Rctx;
-    };
-
-    template <typename T>
-    void modify(T& r, Scratch& regs)
-    {
-        if (!(r.flags & CORRUPTIBLE)) {
-            r.reg = regs.obtain();
-            r.flags |= CORRUPTIBLE;
-        }
-    }
-
-    // helpers
-    void    base_offset(const pointer_t& d, const pointer_t& b, const reg_t& o);
-
-    // texture environement
-    void    modulate(   component_t& dest,
-                        const component_t& incoming,
-                        const pixel_t& texel, int component);
-
-    void    decal(  component_t& dest,
-                    const component_t& incoming,
-                    const pixel_t& texel, int component);
-
-    void    blend(  component_t& dest,
-                    const component_t& incoming,
-                    const pixel_t& texel, int component, int tmu);
-
-    void    add(  component_t& dest,
-                    const component_t& incoming,
-                    const pixel_t& texel, int component);
-
-    // load/store stuff
-    void    store(const pointer_t& addr, const pixel_t& src, uint32_t flags=0);
-    void    load(const pointer_t& addr, const pixel_t& dest, uint32_t flags=0);
-    void    extract(integer_t& d, const pixel_t& s, int component);    
-    void    extract(component_t& d, const pixel_t& s, int component);    
-    void    extract(integer_t& d, int s, int h, int l, int bits=32);
-    void    expand(integer_t& d, const integer_t& s, int dbits);
-    void    expand(integer_t& d, const component_t& s, int dbits);
-    void    expand(component_t& d, const component_t& s, int dbits);
-    void    downshift(pixel_t& d, int component, component_t s, const reg_t& dither);
-
-
-    void    mul_factor( component_t& d,
-                        const integer_t& v,
-                        const integer_t& f);
-
-    void    mul_factor_add( component_t& d,
-                            const integer_t& v,
-                            const integer_t& f,
-                            const component_t& a);
-
-    void    component_add(  component_t& d,
-                            const integer_t& dst,
-                            const integer_t& src);
-
-    void    component_sat(  const component_t& v);
-
-
-    void    build_scanline_prolog(  fragment_parts_t& parts,
-                                    const needs_t& needs);
-
-    void    build_smooth_shade(const fragment_parts_t& parts);
-
-    void    build_component(    pixel_t& pixel,
-                                const fragment_parts_t& parts,
-                                int component,
-                                Scratch& global_scratches);
-                                
-    void    build_incoming_component(
-                                component_t& temp,
-                                int dst_size,
-                                const fragment_parts_t& parts,
-                                int component,
-                                Scratch& scratches,
-                                Scratch& global_scratches);
-
-    void    init_iterated_color(fragment_parts_t& parts, const reg_t& x);
-
-    void    build_iterated_color(   component_t& fragment,
-                                    const fragment_parts_t& parts,
-                                    int component,
-                                    Scratch& regs);
-
-    void    decodeLogicOpNeeds(const needs_t& needs);
-    
-    void    decodeTMUNeeds(const needs_t& needs, context_t const* c);
-
-    void    init_textures(  tex_coord_t* coords,
-                            const reg_t& x,
-                            const reg_t& y);
-
-    void    build_textures( fragment_parts_t& parts,
-                            Scratch& regs);
-
-    void    filter8(   const fragment_parts_t& parts,
-                        pixel_t& texel, const texture_unit_t& tmu,
-                        int U, int V, pointer_t& txPtr,
-                        int FRAC_BITS);
-
-    void    filter16(   const fragment_parts_t& parts,
-                        pixel_t& texel, const texture_unit_t& tmu,
-                        int U, int V, pointer_t& txPtr,
-                        int FRAC_BITS);
-
-    void    filter24(   const fragment_parts_t& parts,
-                        pixel_t& texel, const texture_unit_t& tmu,
-                        int U, int V, pointer_t& txPtr,
-                        int FRAC_BITS);
-
-    void    filter32(   const fragment_parts_t& parts,
-                        pixel_t& texel, const texture_unit_t& tmu,
-                        int U, int V, pointer_t& txPtr,
-                        int FRAC_BITS);
-
-    void    build_texture_environment(  component_t& fragment,
-                                        const fragment_parts_t& parts,
-                                        int component,
-                                        Scratch& regs);
-
-    void    wrapping(   int d,
-                        int coord, int size,
-                        int tx_wrap, int tx_linear);
-
-    void    build_fog(  component_t& temp,
-                        int component,
-                        Scratch& parent_scratches);
-
-    void    build_blending(     component_t& in_out,
-                                const pixel_t& pixel,
-                                int component,
-                                Scratch& parent_scratches);
-
-    void    build_blend_factor(
-                integer_t& factor, int f, int component,
-                const pixel_t& dst_pixel,
-                integer_t& fragment,
-                integer_t& fb,
-                Scratch& scratches);
-
-    void    build_blendFOneMinusF(  component_t& temp,
-                                    const integer_t& factor, 
-                                    const integer_t& fragment,
-                                    const integer_t& fb);
-
-    void    build_blendOneMinusFF(  component_t& temp,
-                                    const integer_t& factor, 
-                                    const integer_t& fragment,
-                                    const integer_t& fb);
-
-    void build_coverage_application(component_t& fragment,
-                                    const fragment_parts_t& parts,
-                                    Scratch& regs);
-
-    void build_alpha_test(component_t& fragment, const fragment_parts_t& parts);
-
-    enum { Z_TEST=1, Z_WRITE=2 }; 
-    void build_depth_test(const fragment_parts_t& parts, uint32_t mask);
-    void build_iterate_z(const fragment_parts_t& parts);
-    void build_iterate_f(const fragment_parts_t& parts);
-    void build_iterate_texture_coordinates(const fragment_parts_t& parts);
-
-    void build_logic_op(pixel_t& pixel, Scratch& regs);
-
-    void build_masking(pixel_t& pixel, Scratch& regs);
-
-    void build_and_immediate(int d, int s, uint32_t mask, int bits);
-
-    bool    isAlphaSourceNeeded() const;
-
-    enum {
-        FACTOR_SRC=1, FACTOR_DST=2, BLEND_SRC=4, BLEND_DST=8 
-    };
-    
-    enum {
-        LOGIC_OP=1, LOGIC_OP_SRC=2, LOGIC_OP_DST=4
-    };
-
-    static int blending_codes(int fs, int fd);
-
-    builder_context_t   mBuilderContext;
-    texture_machine_t   mTextureMachine;
-    component_info_t    mInfo[4];
-    int                 mBlending;
-    int                 mMasking;
-    int                 mAllMasked;
-    int                 mLogicOp;
-    int                 mAlphaTest;
-    int                 mAA;
-    int                 mDithering;
-    int                 mDepthTest;
-
-    int             mSmooth;
-    int             mFog;
-    pixel_t         mDstPixel;
-    
-    GGLFormat       mCbFormat;
-    
-    int             mBlendFactorCached;
-    integer_t       mAlphaSource;
-    
-    int             mBaseRegister;
-    
-    int             mBlendSrc;
-    int             mBlendDst;
-    int             mBlendSrcA;
-    int             mBlendDstA;
-    
-    int             mOptLevel;
-};
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_GGLASSEMBLER_H
diff --git a/libpixelflinger/codeflinger/MIPS64Assembler.cpp b/libpixelflinger/codeflinger/MIPS64Assembler.cpp
deleted file mode 100644
index d6d2156..0000000
--- a/libpixelflinger/codeflinger/MIPS64Assembler.cpp
+++ /dev/null
@@ -1,1447 +0,0 @@
-/* libs/pixelflinger/codeflinger/MIPS64Assembler.cpp
-**
-** 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.
-*/
-
-
-/* MIPS64 assembler and ARM->MIPS64 assembly translator
-**
-** The approach is utilize MIPSAssembler generator, using inherited MIPS64Assembler
-** that overrides just the specific MIPS64r6 instructions.
-** For now ArmToMips64Assembler is copied over from ArmToMipsAssembler class,
-** changing some MIPS64r6 related stuff.
-**
-*/
-
-#define LOG_TAG "MIPS64Assembler"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <cutils/properties.h>
-#include <log/log.h>
-#include <private/pixelflinger/ggl_context.h>
-
-#include "MIPS64Assembler.h"
-#include "CodeCache.h"
-#include "mips64_disassem.h"
-
-#define NOT_IMPLEMENTED()  LOG_ALWAYS_FATAL("Arm instruction %s not yet implemented\n", __func__)
-#define __unused __attribute__((__unused__))
-
-// ----------------------------------------------------------------------------
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark ArmToMips64Assembler...
-#endif
-
-ArmToMips64Assembler::ArmToMips64Assembler(const sp<Assembly>& assembly,
-                                           char *abuf, int linesz, int instr_count)
-    :   ARMAssemblerInterface(),
-        mArmDisassemblyBuffer(abuf),
-        mArmLineLength(linesz),
-        mArmInstrCount(instr_count),
-        mInum(0),
-        mAssembly(assembly)
-{
-    mMips = new MIPS64Assembler(assembly, this);
-    mArmPC = (uint32_t **) malloc(ARM_MAX_INSTUCTIONS * sizeof(uint32_t *));
-    init_conditional_labels();
-}
-
-ArmToMips64Assembler::ArmToMips64Assembler(void* assembly)
-    :   ARMAssemblerInterface(),
-        mArmDisassemblyBuffer(NULL),
-        mInum(0),
-        mAssembly(NULL)
-{
-    mMips = new MIPS64Assembler(assembly, this);
-    mArmPC = (uint32_t **) malloc(ARM_MAX_INSTUCTIONS * sizeof(uint32_t *));
-    init_conditional_labels();
-}
-
-ArmToMips64Assembler::~ArmToMips64Assembler()
-{
-    delete mMips;
-    free((void *) mArmPC);
-}
-
-uint32_t* ArmToMips64Assembler::pc() const
-{
-    return mMips->pc();
-}
-
-uint32_t* ArmToMips64Assembler::base() const
-{
-    return mMips->base();
-}
-
-void ArmToMips64Assembler::reset()
-{
-    cond.labelnum = 0;
-    mInum = 0;
-    mMips->reset();
-}
-
-int ArmToMips64Assembler::getCodegenArch()
-{
-    return CODEGEN_ARCH_MIPS64;
-}
-
-void ArmToMips64Assembler::comment(const char* string)
-{
-    mMips->comment(string);
-}
-
-void ArmToMips64Assembler::label(const char* theLabel)
-{
-    mMips->label(theLabel);
-}
-
-void ArmToMips64Assembler::disassemble(const char* name)
-{
-    mMips->disassemble(name);
-}
-
-void ArmToMips64Assembler::init_conditional_labels()
-{
-    int i;
-    for (i=0;i<99; ++i) {
-        sprintf(cond.label[i], "cond_%d", i);
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Prolog/Epilog & Generate...
-#endif
-
-void ArmToMips64Assembler::prolog()
-{
-    mArmPC[mInum++] = pc();  // save starting PC for this instr
-
-    mMips->DADDIU(R_sp, R_sp, -(5 * 8));
-    mMips->SD(R_s0, R_sp, 0);
-    mMips->SD(R_s1, R_sp, 8);
-    mMips->SD(R_s2, R_sp, 16);
-    mMips->SD(R_s3, R_sp, 24);
-    mMips->SD(R_s4, R_sp, 32);
-    mMips->MOVE(R_v0, R_a0);    // move context * passed in a0 to v0 (arm r0)
-}
-
-void ArmToMips64Assembler::epilog(uint32_t touched __unused)
-{
-    mArmPC[mInum++] = pc();  // save starting PC for this instr
-
-    mMips->LD(R_s0, R_sp, 0);
-    mMips->LD(R_s1, R_sp, 8);
-    mMips->LD(R_s2, R_sp, 16);
-    mMips->LD(R_s3, R_sp, 24);
-    mMips->LD(R_s4, R_sp, 32);
-    mMips->DADDIU(R_sp, R_sp, (5 * 8));
-    mMips->JR(R_ra);
-
-}
-
-int ArmToMips64Assembler::generate(const char* name)
-{
-    return mMips->generate(name);
-}
-
-void ArmToMips64Assembler::fix_branches()
-{
-    mMips->fix_branches();
-}
-
-uint32_t* ArmToMips64Assembler::pcForLabel(const char* label)
-{
-    return mMips->pcForLabel(label);
-}
-
-void ArmToMips64Assembler::set_condition(int mode, int R1, int R2) {
-    if (mode == 2) {
-        cond.type = SBIT_COND;
-    } else {
-        cond.type = CMP_COND;
-    }
-    cond.r1 = R1;
-    cond.r2 = R2;
-}
-
-//----------------------------------------------------------
-
-#if 0
-#pragma mark -
-#pragma mark Addressing modes & shifters...
-#endif
-
-
-// do not need this for MIPS, but it is in the Interface (virtual)
-int ArmToMips64Assembler::buildImmediate(
-        uint32_t immediate, uint32_t& rot, uint32_t& imm)
-{
-    // for MIPS, any 32-bit immediate is OK
-    rot = 0;
-    imm = immediate;
-    return 0;
-}
-
-// shifters...
-
-bool ArmToMips64Assembler::isValidImmediate(uint32_t immediate __unused)
-{
-    // for MIPS, any 32-bit immediate is OK
-    return true;
-}
-
-uint32_t ArmToMips64Assembler::imm(uint32_t immediate)
-{
-    amode.value = immediate;
-    return AMODE_IMM;
-}
-
-uint32_t ArmToMips64Assembler::reg_imm(int Rm, int type, uint32_t shift)
-{
-    amode.reg = Rm;
-    amode.stype = type;
-    amode.value = shift;
-    return AMODE_REG_IMM;
-}
-
-uint32_t ArmToMips64Assembler::reg_rrx(int Rm __unused)
-{
-    // reg_rrx mode is not used in the GLLAssember code at this time
-    return AMODE_UNSUPPORTED;
-}
-
-uint32_t ArmToMips64Assembler::reg_reg(int Rm __unused, int type __unused,
-                                       int Rs __unused)
-{
-    // reg_reg mode is not used in the GLLAssember code at this time
-    return AMODE_UNSUPPORTED;
-}
-
-
-// addressing modes...
-// LDR(B)/STR(B)/PLD (immediate and Rm can be negative, which indicate U=0)
-uint32_t ArmToMips64Assembler::immed12_pre(int32_t immed12, int W)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800,
-                        "LDR(B)/STR(B)/PLD immediate too big (%08x)",
-                        immed12);
-    amode.value = immed12;
-    amode.writeback = W;
-    return AMODE_IMM_12_PRE;
-}
-
-uint32_t ArmToMips64Assembler::immed12_post(int32_t immed12)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800,
-                        "LDR(B)/STR(B)/PLD immediate too big (%08x)",
-                        immed12);
-
-    amode.value = immed12;
-    return AMODE_IMM_12_POST;
-}
-
-uint32_t ArmToMips64Assembler::reg_scale_pre(int Rm, int type,
-        uint32_t shift, int W)
-{
-    LOG_ALWAYS_FATAL_IF(W | type | shift, "reg_scale_pre adv modes not yet implemented");
-
-    amode.reg = Rm;
-    // amode.stype = type;      // more advanced modes not used in GGLAssembler yet
-    // amode.value = shift;
-    // amode.writeback = W;
-    return AMODE_REG_SCALE_PRE;
-}
-
-uint32_t ArmToMips64Assembler::reg_scale_post(int Rm __unused, int type __unused,
-                                              uint32_t shift __unused)
-{
-    LOG_ALWAYS_FATAL("adr mode reg_scale_post not yet implemented\n");
-    return AMODE_UNSUPPORTED;
-}
-
-// LDRH/LDRSB/LDRSH/STRH (immediate and Rm can be negative, which indicate U=0)
-uint32_t ArmToMips64Assembler::immed8_pre(int32_t immed8, int W __unused)
-{
-    LOG_ALWAYS_FATAL("adr mode immed8_pre not yet implemented\n");
-
-    LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100,
-                        "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)",
-                        immed8);
-    return AMODE_IMM_8_PRE;
-}
-
-uint32_t ArmToMips64Assembler::immed8_post(int32_t immed8)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100,
-                        "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)",
-                        immed8);
-    amode.value = immed8;
-    return AMODE_IMM_8_POST;
-}
-
-uint32_t ArmToMips64Assembler::reg_pre(int Rm, int W)
-{
-    LOG_ALWAYS_FATAL_IF(W, "reg_pre writeback not yet implemented");
-    amode.reg = Rm;
-    return AMODE_REG_PRE;
-}
-
-uint32_t ArmToMips64Assembler::reg_post(int Rm __unused)
-{
-    LOG_ALWAYS_FATAL("adr mode reg_post not yet implemented\n");
-    return AMODE_UNSUPPORTED;
-}
-
-
-
-// ----------------------------------------------------------------------------
-
-#if 0
-#pragma mark -
-#pragma mark Data Processing...
-#endif
-
-// check if the operand registers from a previous CMP or S-bit instruction
-// would be overwritten by this instruction. If so, move the value to a
-// safe register.
-// Note that we cannot tell at _this_ instruction time if a future (conditional)
-// instruction will _also_ use this value (a defect of the simple 1-pass, one-
-// instruction-at-a-time translation). Therefore we must be conservative and
-// save the value before it is overwritten. This costs an extra MOVE instr.
-
-void ArmToMips64Assembler::protectConditionalOperands(int Rd)
-{
-    if (Rd == cond.r1) {
-        mMips->MOVE(R_cmp, cond.r1);
-        cond.r1 = R_cmp;
-    }
-    if (cond.type == CMP_COND && Rd == cond.r2) {
-        mMips->MOVE(R_cmp2, cond.r2);
-        cond.r2 = R_cmp2;
-    }
-}
-
-
-// interprets the addressing mode, and generates the common code
-// used by the majority of data-processing ops. Many MIPS instructions
-// have a register-based form and a different immediate form. See
-// opAND below for an example. (this could be inlined)
-//
-// this works with the imm(), reg_imm() methods above, which are directly
-// called by the GLLAssembler.
-// note: _signed parameter defaults to false (un-signed)
-// note: tmpReg parameter defaults to 1, MIPS register AT
-int ArmToMips64Assembler::dataProcAdrModes(int op, int& source, bool _signed, int tmpReg)
-{
-    if (op < AMODE_REG) {
-        source = op;
-        return SRC_REG;
-    } else if (op == AMODE_IMM) {
-        if ((!_signed && amode.value > 0xffff)
-                || (_signed && ((int)amode.value < -32768 || (int)amode.value > 32767) )) {
-            mMips->LUI(tmpReg, (amode.value >> 16));
-            if (amode.value & 0x0000ffff) {
-                mMips->ORI(tmpReg, tmpReg, (amode.value & 0x0000ffff));
-            }
-            source = tmpReg;
-            return SRC_REG;
-        } else {
-            source = amode.value;
-            return SRC_IMM;
-        }
-    } else if (op == AMODE_REG_IMM) {
-        switch (amode.stype) {
-            case LSL: mMips->SLL(tmpReg, amode.reg, amode.value); break;
-            case LSR: mMips->SRL(tmpReg, amode.reg, amode.value); break;
-            case ASR: mMips->SRA(tmpReg, amode.reg, amode.value); break;
-            case ROR: mMips->ROTR(tmpReg, amode.reg, amode.value); break;
-        }
-        source = tmpReg;
-        return SRC_REG;
-    } else {  // adr mode RRX is not used in GGL Assembler at this time
-        // we are screwed, this should be exception, assert-fail or something
-        LOG_ALWAYS_FATAL("adr mode reg_rrx not yet implemented\n");
-        return SRC_ERROR;
-    }
-}
-
-
-void ArmToMips64Assembler::dataProcessing(int opcode, int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-    int src;    // src is modified by dataProcAdrModes() - passed as int&
-
-    if (cc != AL) {
-        protectConditionalOperands(Rd);
-        // the branch tests register(s) set by prev CMP or instr with 'S' bit set
-        // inverse the condition to jump past this conditional instruction
-        ArmToMips64Assembler::B(cc^1, cond.label[++cond.labelnum]);
-    } else {
-        mArmPC[mInum++] = pc();  // save starting PC for this instr
-    }
-
-    switch (opcode) {
-    case opAND:
-        if (dataProcAdrModes(Op2, src) == SRC_REG) {
-            mMips->AND(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->ANDI(Rd, Rn, src);
-        }
-        break;
-
-    case opADD:
-        // set "signed" to true for adr modes
-        if (dataProcAdrModes(Op2, src, true) == SRC_REG) {
-            mMips->ADDU(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->ADDIU(Rd, Rn, src);
-        }
-        break;
-
-    case opSUB:
-        // set "signed" to true for adr modes
-        if (dataProcAdrModes(Op2, src, true) == SRC_REG) {
-            mMips->SUBU(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->SUBIU(Rd, Rn, src);
-        }
-        break;
-
-    case opADD64:
-        // set "signed" to true for adr modes
-        if (dataProcAdrModes(Op2, src, true) == SRC_REG) {
-            mMips->DADDU(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->DADDIU(Rd, Rn, src);
-        }
-        break;
-
-    case opSUB64:
-        // set "signed" to true for adr modes
-        if (dataProcAdrModes(Op2, src, true) == SRC_REG) {
-            mMips->DSUBU(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->DSUBIU(Rd, Rn, src);
-        }
-        break;
-
-    case opEOR:
-        if (dataProcAdrModes(Op2, src) == SRC_REG) {
-            mMips->XOR(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->XORI(Rd, Rn, src);
-        }
-        break;
-
-    case opORR:
-        if (dataProcAdrModes(Op2, src) == SRC_REG) {
-            mMips->OR(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->ORI(Rd, Rn, src);
-        }
-        break;
-
-    case opBIC:
-        if (dataProcAdrModes(Op2, src) == SRC_IMM) {
-            // if we are 16-bit imnmediate, load to AT reg
-            mMips->ORI(R_at, 0, src);
-            src = R_at;
-        }
-        mMips->NOT(R_at, src);
-        mMips->AND(Rd, Rn, R_at);
-        break;
-
-    case opRSB:
-        if (dataProcAdrModes(Op2, src) == SRC_IMM) {
-            // if we are 16-bit imnmediate, load to AT reg
-            mMips->ORI(R_at, 0, src);
-            src = R_at;
-        }
-        mMips->SUBU(Rd, src, Rn);   // subu with the parameters reversed
-        break;
-
-    case opMOV:
-        if (Op2 < AMODE_REG) {  // op2 is reg # in this case
-            mMips->MOVE(Rd, Op2);
-        } else if (Op2 == AMODE_IMM) {
-            if (amode.value > 0xffff) {
-                mMips->LUI(Rd, (amode.value >> 16));
-                if (amode.value & 0x0000ffff) {
-                    mMips->ORI(Rd, Rd, (amode.value & 0x0000ffff));
-                }
-             } else {
-                mMips->ORI(Rd, 0, amode.value);
-            }
-        } else if (Op2 == AMODE_REG_IMM) {
-            switch (amode.stype) {
-            case LSL: mMips->SLL(Rd, amode.reg, amode.value); break;
-            case LSR: mMips->SRL(Rd, amode.reg, amode.value); break;
-            case ASR: mMips->SRA(Rd, amode.reg, amode.value); break;
-            case ROR: mMips->ROTR(Rd, amode.reg, amode.value); break;
-            }
-        }
-        else {
-            // adr mode RRX is not used in GGL Assembler at this time
-            mMips->UNIMPL();
-        }
-        break;
-
-    case opMVN:     // this is a 1's complement: NOT
-        if (Op2 < AMODE_REG) {  // op2 is reg # in this case
-            mMips->NOR(Rd, Op2, 0);     // NOT is NOR with 0
-            break;
-        } else if (Op2 == AMODE_IMM) {
-            if (amode.value > 0xffff) {
-                mMips->LUI(Rd, (amode.value >> 16));
-                if (amode.value & 0x0000ffff) {
-                    mMips->ORI(Rd, Rd, (amode.value & 0x0000ffff));
-                }
-             } else {
-                mMips->ORI(Rd, 0, amode.value);
-             }
-        } else if (Op2 == AMODE_REG_IMM) {
-            switch (amode.stype) {
-            case LSL: mMips->SLL(Rd, amode.reg, amode.value); break;
-            case LSR: mMips->SRL(Rd, amode.reg, amode.value); break;
-            case ASR: mMips->SRA(Rd, amode.reg, amode.value); break;
-            case ROR: mMips->ROTR(Rd, amode.reg, amode.value); break;
-            }
-        }
-        else {
-            // adr mode RRX is not used in GGL Assembler at this time
-            mMips->UNIMPL();
-        }
-        mMips->NOR(Rd, Rd, 0);     // NOT is NOR with 0
-        break;
-
-    case opCMP:
-        // Either operand of a CMP instr could get overwritten by a subsequent
-        // conditional instruction, which is ok, _UNLESS_ there is a _second_
-        // conditional instruction. Under MIPS, this requires doing the comparison
-        // again (SLT), and the original operands must be available. (and this
-        // pattern of multiple conditional instructions from same CMP _is_ used
-        // in GGL-Assembler)
-        //
-        // For now, if a conditional instr overwrites the operands, we will
-        // move them to dedicated temp regs. This is ugly, and inefficient,
-        // and should be optimized.
-        //
-        // WARNING: making an _Assumption_ that CMP operand regs will NOT be
-        // trashed by intervening NON-conditional instructions. In the general
-        // case this is legal, but it is NOT currently done in GGL-Assembler.
-
-        cond.type = CMP_COND;
-        cond.r1 = Rn;
-        if (dataProcAdrModes(Op2, src, false, R_cmp2) == SRC_REG) {
-            cond.r2 = src;
-        } else {                        // adr mode was SRC_IMM
-            mMips->ORI(R_cmp2, R_zero, src);
-            cond.r2 = R_cmp2;
-        }
-
-        break;
-
-
-    case opTST:
-    case opTEQ:
-    case opCMN:
-    case opADC:
-    case opSBC:
-    case opRSC:
-        mMips->UNIMPL(); // currently unused in GGL Assembler code
-        break;
-    }
-
-    if (cc != AL) {
-        mMips->label(cond.label[cond.labelnum]);
-    }
-    if (s && opcode != opCMP) {
-        cond.type = SBIT_COND;
-        cond.r1 = Rd;
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Multiply...
-#endif
-
-// multiply, accumulate
-void ArmToMips64Assembler::MLA(int cc __unused, int s,
-        int Rd, int Rm, int Rs, int Rn) {
-
-    //ALOGW("MLA");
-    mArmPC[mInum++] = pc();  // save starting PC for this instr
-
-    mMips->MUL(R_at, Rm, Rs);
-    mMips->ADDU(Rd, R_at, Rn);
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = Rd;
-    }
-}
-
-void ArmToMips64Assembler::MUL(int cc __unused, int s,
-        int Rd, int Rm, int Rs) {
-    mArmPC[mInum++] = pc();
-    mMips->MUL(Rd, Rm, Rs);
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = Rd;
-    }
-}
-
-void ArmToMips64Assembler::UMULL(int cc __unused, int s,
-        int RdLo, int RdHi, int Rm, int Rs) {
-    mArmPC[mInum++] = pc();
-    mMips->MUH(RdHi, Rm, Rs);
-    mMips->MUL(RdLo, Rm, Rs);
-
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on UMULL must be on 64-bit result\n");
-    }
-}
-
-void ArmToMips64Assembler::UMUAL(int cc __unused, int s,
-        int RdLo __unused, int RdHi, int Rm __unused, int Rs __unused) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "UMUAL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    // *mPC++ =    (cc<<28) | (1<<23) | (1<<21) | (s<<20) |
-    //             (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on UMULL must be on 64-bit result\n");
-    }
-}
-
-void ArmToMips64Assembler::SMULL(int cc __unused, int s,
-        int RdLo __unused, int RdHi, int Rm __unused, int Rs __unused) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "SMULL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    // *mPC++ =    (cc<<28) | (1<<23) | (1<<22) | (s<<20) |
-    //             (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on SMULL must be on 64-bit result\n");
-    }
-}
-void ArmToMips64Assembler::SMUAL(int cc __unused, int s,
-        int RdLo __unused, int RdHi, int Rm __unused, int Rs __unused) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "SMUAL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    // *mPC++ =    (cc<<28) | (1<<23) | (1<<22) | (1<<21) | (s<<20) |
-    //             (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on SMUAL must be on 64-bit result\n");
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Branches...
-#endif
-
-// branches...
-
-void ArmToMips64Assembler::B(int cc, const char* label)
-{
-    mArmPC[mInum++] = pc();
-    if (cond.type == SBIT_COND) { cond.r2 = R_zero; }
-
-    switch(cc) {
-        case EQ: mMips->BEQ(cond.r1, cond.r2, label); break;
-        case NE: mMips->BNE(cond.r1, cond.r2, label); break;
-        case HS: mMips->BGEU(cond.r1, cond.r2, label); break;
-        case LO: mMips->BLTU(cond.r1, cond.r2, label); break;
-        case MI: mMips->BLT(cond.r1, cond.r2, label); break;
-        case PL: mMips->BGE(cond.r1, cond.r2, label); break;
-
-        case HI: mMips->BGTU(cond.r1, cond.r2, label); break;
-        case LS: mMips->BLEU(cond.r1, cond.r2, label); break;
-        case GE: mMips->BGE(cond.r1, cond.r2, label); break;
-        case LT: mMips->BLT(cond.r1, cond.r2, label); break;
-        case GT: mMips->BGT(cond.r1, cond.r2, label); break;
-        case LE: mMips->BLE(cond.r1, cond.r2, label); break;
-        case AL: mMips->B(label); break;
-        case NV: /* B Never - no instruction */ break;
-
-        case VS:
-        case VC:
-        default:
-            LOG_ALWAYS_FATAL("Unsupported cc: %02x\n", cc);
-            break;
-    }
-}
-
-void ArmToMips64Assembler::BL(int cc __unused, const char* label __unused)
-{
-    LOG_ALWAYS_FATAL("branch-and-link not supported yet\n");
-    mArmPC[mInum++] = pc();
-}
-
-// no use for Branches with integer PC, but they're in the Interface class ....
-void ArmToMips64Assembler::B(int cc __unused, uint32_t* to_pc __unused)
-{
-    LOG_ALWAYS_FATAL("branch to absolute PC not supported, use Label\n");
-    mArmPC[mInum++] = pc();
-}
-
-void ArmToMips64Assembler::BL(int cc __unused, uint32_t* to_pc __unused)
-{
-    LOG_ALWAYS_FATAL("branch to absolute PC not supported, use Label\n");
-    mArmPC[mInum++] = pc();
-}
-
-void ArmToMips64Assembler::BX(int cc __unused, int Rn __unused)
-{
-    LOG_ALWAYS_FATAL("branch to absolute PC not supported, use Label\n");
-    mArmPC[mInum++] = pc();
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Data Transfer...
-#endif
-
-// data transfer...
-void ArmToMips64Assembler::LDR(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;      // convert LDR via Arm SP to LW via Mips SP
-            }
-            mMips->LW(Rd, Rn, amode.value);
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                mMips->DADDIU(Rn, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;      // convert STR thru Arm SP to STR thru Mips SP
-            }
-            mMips->LW(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->DADDU(R_at, Rn, amode.reg);
-            mMips->LW(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMips64Assembler::LDRB(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            mMips->LBU(Rd, Rn, amode.value);
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                mMips->DADDIU(Rn, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            mMips->LBU(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->DADDU(R_at, Rn, amode.reg);
-            mMips->LBU(Rd, R_at, 0);
-            break;
-    }
-
-}
-
-void ArmToMips64Assembler::STR(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;  // convert STR thru Arm SP to SW thru Mips SP
-            }
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                // If we will writeback, then update the index reg, then store.
-                // This correctly handles stack-push case.
-                mMips->DADDIU(Rn, Rn, amode.value);
-                mMips->SW(Rd, Rn, 0);
-            } else {
-                // No writeback so store offset by value
-                mMips->SW(Rd, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            mMips->SW(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);  // post index always writes back
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->DADDU(R_at, Rn, amode.reg);
-            mMips->SW(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMips64Assembler::STRB(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            mMips->SB(Rd, Rn, amode.value);
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                mMips->DADDIU(Rn, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            mMips->SB(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->DADDU(R_at, Rn, amode.reg);
-            mMips->SB(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMips64Assembler::LDRH(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed8_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_8_PRE:      // no support yet for writeback
-            mMips->LHU(Rd, Rn, amode.value);
-            break;
-        case AMODE_IMM_8_POST:
-            mMips->LHU(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_PRE:
-            // we only support simple base +/- index
-            if (amode.reg >= 0) {
-                mMips->DADDU(R_at, Rn, amode.reg);
-            } else {
-                mMips->DSUBU(R_at, Rn, abs(amode.reg));
-            }
-            mMips->LHU(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMips64Assembler::LDRSB(int cc __unused, int Rd __unused,
-                                 int Rn __unused, uint32_t offset __unused)
-{
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::LDRSH(int cc __unused, int Rd __unused,
-                                 int Rn __unused, uint32_t offset __unused)
-{
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::STRH(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed8_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_8_PRE:      // no support yet for writeback
-            mMips->SH(Rd, Rn, amode.value);
-            break;
-        case AMODE_IMM_8_POST:
-            mMips->SH(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_PRE:
-            // we only support simple base +/- index
-            if (amode.reg >= 0) {
-                mMips->DADDU(R_at, Rn, amode.reg);
-            } else {
-                mMips->DSUBU(R_at, Rn, abs(amode.reg));
-            }
-            mMips->SH(Rd, R_at, 0);
-            break;
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Block Data Transfer...
-#endif
-
-// block data transfer...
-void ArmToMips64Assembler::LDM(int cc __unused, int dir __unused,
-        int Rn __unused, int W __unused, uint32_t reg_list __unused)
-{   //                        ED FD EA FA      IB IA DB DA
-    // const uint8_t P[8] = { 1, 0, 1, 0,      1, 0, 1, 0 };
-    // const uint8_t U[8] = { 1, 1, 0, 0,      1, 1, 0, 0 };
-    // *mPC++ = (cc<<28) | (4<<25) | (uint32_t(P[dir])<<24) |
-    //         (uint32_t(U[dir])<<23) | (1<<20) | (W<<21) | (Rn<<16) | reg_list;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::STM(int cc __unused, int dir __unused,
-        int Rn __unused, int W __unused, uint32_t reg_list __unused)
-{   //                        FA EA FD ED      IB IA DB DA
-    // const uint8_t P[8] = { 0, 1, 0, 1,      1, 0, 1, 0 };
-    // const uint8_t U[8] = { 0, 0, 1, 1,      1, 1, 0, 0 };
-    // *mPC++ = (cc<<28) | (4<<25) | (uint32_t(P[dir])<<24) |
-    //         (uint32_t(U[dir])<<23) | (0<<20) | (W<<21) | (Rn<<16) | reg_list;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Special...
-#endif
-
-// special...
-void ArmToMips64Assembler::SWP(int cc __unused, int Rn __unused,
-                               int Rd __unused, int Rm __unused) {
-    // *mPC++ = (cc<<28) | (2<<23) | (Rn<<16) | (Rd << 12) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::SWPB(int cc __unused, int Rn __unused,
-                                int Rd __unused, int Rm __unused) {
-    // *mPC++ = (cc<<28) | (2<<23) | (1<<22) | (Rn<<16) | (Rd << 12) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::SWI(int cc __unused, uint32_t comment __unused) {
-    // *mPC++ = (cc<<28) | (0xF<<24) | comment;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-
-#if 0
-#pragma mark -
-#pragma mark DSP instructions...
-#endif
-
-// DSP instructions...
-void ArmToMips64Assembler::PLD(int Rn __unused, uint32_t offset) {
-    LOG_ALWAYS_FATAL_IF(!((offset&(1<<24)) && !(offset&(1<<21))),
-                        "PLD only P=1, W=0");
-    // *mPC++ = 0xF550F000 | (Rn<<16) | offset;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::CLZ(int cc __unused, int Rd, int Rm)
-{
-    mArmPC[mInum++] = pc();
-    mMips->CLZ(Rd, Rm);
-}
-
-void ArmToMips64Assembler::QADD(int cc __unused, int Rd __unused,
-                                int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1000050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::QDADD(int cc __unused, int Rd __unused,
-                                 int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1400050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::QSUB(int cc __unused, int Rd __unused,
-                                int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1200050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::QDSUB(int cc __unused, int Rd __unused,
-                                 int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1600050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-// 16 x 16 signed multiply (like SMLAxx without the accumulate)
-void ArmToMips64Assembler::SMUL(int cc __unused, int xy,
-                int Rd, int Rm, int Rs)
-{
-    mArmPC[mInum++] = pc();
-
-    // the 16 bits may be in the top or bottom half of 32-bit source reg,
-    // as defined by the codes BB, BT, TB, TT (compressed param xy)
-    // where x corresponds to Rm and y to Rs
-
-    // select half-reg for Rm
-    if (xy & xyTB) {
-        // use top 16-bits
-        mMips->SRA(R_at, Rm, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        mMips->SEH(R_at, Rm);
-    }
-    // select half-reg for Rs
-    if (xy & xyBT) {
-        // use top 16-bits
-        mMips->SRA(R_at2, Rs, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        mMips->SEH(R_at2, Rs);
-    }
-    mMips->MUL(Rd, R_at, R_at2);
-}
-
-// signed 32b x 16b multiple, save top 32-bits of 48-bit result
-void ArmToMips64Assembler::SMULW(int cc __unused, int y,
-                int Rd, int Rm, int Rs)
-{
-    mArmPC[mInum++] = pc();
-
-    // the selector yT or yB refers to reg Rs
-    if (y & yT) {
-        // zero the bottom 16-bits, with 2 shifts, it can affect result
-        mMips->SRL(R_at, Rs, 16);
-        mMips->SLL(R_at, R_at, 16);
-
-    } else {
-        // move low 16-bit half, to high half
-        mMips->SLL(R_at, Rs, 16);
-    }
-    mMips->MUH(Rd, Rm, R_at);
-}
-
-// 16 x 16 signed multiply, accumulate: Rd = Rm{16} * Rs{16} + Rn
-void ArmToMips64Assembler::SMLA(int cc __unused, int xy,
-                int Rd, int Rm, int Rs, int Rn)
-{
-    mArmPC[mInum++] = pc();
-
-    // the 16 bits may be in the top or bottom half of 32-bit source reg,
-    // as defined by the codes BB, BT, TB, TT (compressed param xy)
-    // where x corresponds to Rm and y to Rs
-
-    // select half-reg for Rm
-    if (xy & xyTB) {
-        // use top 16-bits
-        mMips->SRA(R_at, Rm, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        mMips->SEH(R_at, Rm);
-    }
-    // select half-reg for Rs
-    if (xy & xyBT) {
-        // use top 16-bits
-        mMips->SRA(R_at2, Rs, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        mMips->SEH(R_at2, Rs);
-    }
-
-    mMips->MUL(R_at, R_at, R_at2);
-    mMips->ADDU(Rd, R_at, Rn);
-}
-
-void ArmToMips64Assembler::SMLAL(int cc __unused, int xy __unused,
-                                 int RdHi __unused, int RdLo __unused,
-                                 int Rs __unused, int Rm __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1400080 | (RdHi<<16) | (RdLo<<12) | (Rs<<8) | (xy<<4) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMips64Assembler::SMLAW(int cc __unused, int y __unused,
-                                 int Rd __unused, int Rm __unused,
-                                 int Rs __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1200080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (y<<4) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-// used by ARMv6 version of GGLAssembler::filter32
-void ArmToMips64Assembler::UXTB16(int cc __unused, int Rd, int Rm, int rotate)
-{
-    mArmPC[mInum++] = pc();
-
-    //Rd[31:16] := ZeroExtend((Rm ROR (8 * sh))[23:16]),
-    //Rd[15:0] := ZeroExtend((Rm ROR (8 * sh))[7:0]). sh 0-3.
-
-    mMips->ROTR(R_at2, Rm, rotate * 8);
-    mMips->LUI(R_at, 0xFF);
-    mMips->ORI(R_at, R_at, 0xFF);
-    mMips->AND(Rd, R_at2, R_at);
-}
-
-void ArmToMips64Assembler::UBFX(int cc __unused, int Rd __unused, int Rn __unused,
-                                int lsb __unused, int width __unused)
-{
-     /* Placeholder for UBFX */
-     mArmPC[mInum++] = pc();
-
-     mMips->NOP2();
-     NOT_IMPLEMENTED();
-}
-
-// ----------------------------------------------------------------------------
-// Address Processing...
-// ----------------------------------------------------------------------------
-
-void ArmToMips64Assembler::ADDR_ADD(int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-//    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-//    if(s  != 0) { NOT_IMPLEMENTED(); return;} //Not required
-    dataProcessing(opADD64, cc, s, Rd, Rn, Op2);
-}
-
-void ArmToMips64Assembler::ADDR_SUB(int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-//    if(cc != AL){ NOT_IMPLEMENTED(); return;} //Not required
-//    if(s  != 0) { NOT_IMPLEMENTED(); return;} //Not required
-    dataProcessing(opSUB64, cc, s, Rd, Rn, Op2);
-}
-
-void ArmToMips64Assembler::ADDR_LDR(int cc __unused, int Rd,
-                                    int Rn, uint32_t offset) {
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;      // convert LDR via Arm SP to LW via Mips SP
-            }
-            mMips->LD(Rd, Rn, amode.value);
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                mMips->DADDIU(Rn, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;      // convert STR thru Arm SP to STR thru Mips SP
-            }
-            mMips->LD(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->DADDU(R_at, Rn, amode.reg);
-            mMips->LD(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMips64Assembler::ADDR_STR(int cc __unused, int Rd,
-                                    int Rn, uint32_t offset) {
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;  // convert STR thru Arm SP to SW thru Mips SP
-            }
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                // If we will writeback, then update the index reg, then store.
-                // This correctly handles stack-push case.
-                mMips->DADDIU(Rn, Rn, amode.value);
-                mMips->SD(Rd, Rn, 0);
-            } else {
-                // No writeback so store offset by value
-                mMips->SD(Rd, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            mMips->SD(Rd, Rn, 0);
-            mMips->DADDIU(Rn, Rn, amode.value);  // post index always writes back
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->DADDU(R_at, Rn, amode.reg);
-            mMips->SD(Rd, R_at, 0);
-            break;
-    }
-}
-
-#if 0
-#pragma mark -
-#pragma mark MIPS Assembler...
-#endif
-
-
-//**************************************************************************
-//**************************************************************************
-//**************************************************************************
-
-
-/* MIPS64 assembler
-** this is a subset of mips64r6, targeted specifically at ARM instruction
-** replacement in the pixelflinger/codeflinger code.
-**
-** This class is extended from MIPSAssembler class and overrides only
-** MIPS64r6 specific stuff.
-*/
-
-MIPS64Assembler::MIPS64Assembler(const sp<Assembly>& assembly, ArmToMips64Assembler *parent)
-    : MIPSAssembler::MIPSAssembler(assembly, NULL), mParent(parent)
-{
-}
-
-MIPS64Assembler::MIPS64Assembler(void* assembly, ArmToMips64Assembler *parent)
-    : MIPSAssembler::MIPSAssembler(assembly), mParent(parent)
-{
-}
-
-MIPS64Assembler::~MIPS64Assembler()
-{
-}
-
-void MIPS64Assembler::reset()
-{
-    if (mAssembly != NULL) {
-        mBase = mPC = (uint32_t *)mAssembly->base();
-    } else {
-        mPC = mBase = base();
-    }
-    mBranchTargets.clear();
-    mLabels.clear();
-    mLabelsInverseMapping.clear();
-    mComments.clear();
-}
-
-
-void MIPS64Assembler::disassemble(const char* name __unused)
-{
-    char di_buf[140];
-
-    bool arm_disasm_fmt = (mParent->mArmDisassemblyBuffer == NULL) ? false : true;
-
-    typedef char dstr[40];
-    dstr *lines = (dstr *)mParent->mArmDisassemblyBuffer;
-
-    if (mParent->mArmDisassemblyBuffer != NULL) {
-        for (int i=0; i<mParent->mArmInstrCount; ++i) {
-            string_detab(lines[i]);
-        }
-    }
-
-    size_t count = pc()-base();
-    uint32_t* mipsPC = base();
-
-    while (count--) {
-        ssize_t label = mLabelsInverseMapping.indexOfKey(mipsPC);
-        if (label >= 0) {
-            ALOGW("%s:\n", mLabelsInverseMapping.valueAt(label));
-        }
-        ssize_t comment = mComments.indexOfKey(mipsPC);
-        if (comment >= 0) {
-            ALOGW("; %s\n", mComments.valueAt(comment));
-        }
-        ::mips_disassem(mipsPC, di_buf, arm_disasm_fmt);
-        string_detab(di_buf);
-        string_pad(di_buf, 30);
-        ALOGW("%08lx:    %08x    %s", uintptr_t(mipsPC), uint32_t(*mipsPC), di_buf);
-        mipsPC++;
-    }
-}
-
-void MIPS64Assembler::fix_branches()
-{
-    // fixup all the branches
-    size_t count = mBranchTargets.size();
-    while (count--) {
-        const branch_target_t& bt = mBranchTargets[count];
-        uint32_t* target_pc = mLabels.valueFor(bt.label);
-        LOG_ALWAYS_FATAL_IF(!target_pc,
-                "error resolving branch targets, target_pc is null");
-        int32_t offset = int32_t(target_pc - (bt.pc+1));
-        *bt.pc |= offset & 0x00FFFF;
-    }
-}
-
-void MIPS64Assembler::DADDU(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (daddu_fn<<FUNC_SHF)
-                    | (Rs<<RS_SHF) | (Rt<<RT_SHF) | (Rd<<RD_SHF);
-}
-
-void MIPS64Assembler::DADDIU(int Rt, int Rs, int16_t imm)
-{
-    *mPC++ = (daddiu_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | (imm & MSK_16);
-}
-
-void MIPS64Assembler::DSUBU(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (dsubu_fn<<FUNC_SHF) |
-                        (Rs<<RS_SHF) | (Rt<<RT_SHF) | (Rd<<RD_SHF) ;
-}
-
-void MIPS64Assembler::DSUBIU(int Rt, int Rs, int16_t imm)   // really addiu(d, s, -j)
-{
-    *mPC++ = (daddiu_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | ((-imm) & MSK_16);
-}
-
-void MIPS64Assembler::MUL(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (mul_fn<<RE_SHF) | (sop30_fn<<FUNC_SHF) |
-                        (Rs<<RS_SHF) | (Rt<<RT_SHF) | (Rd<<RD_SHF) ;
-}
-
-void MIPS64Assembler::MUH(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (muh_fn<<RE_SHF) | (sop30_fn<<FUNC_SHF) |
-                        (Rs<<RS_SHF) | (Rt<<RT_SHF) | (Rd<<RD_SHF) ;
-}
-
-void MIPS64Assembler::CLO(int Rd, int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (17<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (1<<RE_SHF);
-}
-
-void MIPS64Assembler::CLZ(int Rd, int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (16<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (1<<RE_SHF);
-}
-
-void MIPS64Assembler::LD(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (ld_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPS64Assembler::SD(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (sd_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPS64Assembler::LUI(int Rt, int16_t offset)
-{
-    *mPC++ = (aui_op<<OP_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-
-void MIPS64Assembler::JR(int Rs)
-{
-        *mPC++ = (spec_op<<OP_SHF) | (Rs<<RS_SHF) | (jalr_fn << FUNC_SHF);
-        MIPS64Assembler::NOP();
-}
-
-}; // namespace android:
diff --git a/libpixelflinger/codeflinger/MIPS64Assembler.h b/libpixelflinger/codeflinger/MIPS64Assembler.h
deleted file mode 100644
index b43e5da..0000000
--- a/libpixelflinger/codeflinger/MIPS64Assembler.h
+++ /dev/null
@@ -1,404 +0,0 @@
-/* libs/pixelflinger/codeflinger/MIPS64Assembler.h
-**
-** 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.
-*/
-
-#ifndef ANDROID_MIPS64ASSEMBLER_H
-#define ANDROID_MIPS64ASSEMBLER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "utils/KeyedVector.h"
-#include "utils/Vector.h"
-#include "tinyutils/smartpointer.h"
-
-#include "ARMAssemblerInterface.h"
-#include "MIPSAssembler.h"
-#include "CodeCache.h"
-
-namespace android {
-
-class MIPS64Assembler;    // forward reference
-
-// this class mimics ARMAssembler interface
-// intent is to translate each ARM instruction to 1 or more MIPS instr
-// implementation calls MIPS64Assembler class to generate mips code
-class ArmToMips64Assembler : public ARMAssemblerInterface
-{
-public:
-                ArmToMips64Assembler(const sp<Assembly>& assembly,
-                        char *abuf = 0, int linesz = 0, int instr_count = 0);
-                ArmToMips64Assembler(void* assembly);
-    virtual     ~ArmToMips64Assembler();
-
-    uint32_t*   base() const;
-    uint32_t*   pc() const;
-    void        disassemble(const char* name);
-
-    virtual void    reset();
-
-    virtual int     generate(const char* name);
-    virtual int     getCodegenArch();
-
-    virtual void    prolog();
-    virtual void    epilog(uint32_t touched);
-    virtual void    comment(const char* string);
-    // for testing purposes
-    void        fix_branches();
-    void        set_condition(int mode, int R1, int R2);
-
-
-    // -----------------------------------------------------------------------
-    // shifters and addressing modes
-    // -----------------------------------------------------------------------
-
-    // shifters...
-    virtual bool        isValidImmediate(uint32_t immed);
-    virtual int         buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
-
-    virtual uint32_t    imm(uint32_t immediate);
-    virtual uint32_t    reg_imm(int Rm, int type, uint32_t shift);
-    virtual uint32_t    reg_rrx(int Rm);
-    virtual uint32_t    reg_reg(int Rm, int type, int Rs);
-
-    // addressing modes...
-    // LDR(B)/STR(B)/PLD
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed12_pre(int32_t immed12, int W=0);
-    virtual uint32_t    immed12_post(int32_t immed12);
-    virtual uint32_t    reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
-    virtual uint32_t    reg_scale_post(int Rm, int type=0, uint32_t shift=0);
-
-    // LDRH/LDRSB/LDRSH/STRH
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed8_pre(int32_t immed8, int W=0);
-    virtual uint32_t    immed8_post(int32_t immed8);
-    virtual uint32_t    reg_pre(int Rm, int W=0);
-    virtual uint32_t    reg_post(int Rm);
-
-
-
-
-    virtual void    dataProcessing(int opcode, int cc, int s,
-                                int Rd, int Rn,
-                                uint32_t Op2);
-    virtual void MLA(int cc, int s,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void MUL(int cc, int s,
-                int Rd, int Rm, int Rs);
-    virtual void UMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void UMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-
-    virtual void B(int cc, uint32_t* pc);
-    virtual void BL(int cc, uint32_t* pc);
-    virtual void BX(int cc, int Rn);
-    virtual void label(const char* theLabel);
-    virtual void B(int cc, const char* label);
-    virtual void BL(int cc, const char* label);
-
-    virtual uint32_t* pcForLabel(const char* label);
-
-    virtual void LDR (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STR (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STRB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRH (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRSB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRSH(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STRH (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-
-    virtual void LDM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-    virtual void STM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-
-    virtual void SWP(int cc, int Rn, int Rd, int Rm);
-    virtual void SWPB(int cc, int Rn, int Rd, int Rm);
-    virtual void SWI(int cc, uint32_t comment);
-
-    virtual void PLD(int Rn, uint32_t offset);
-    virtual void CLZ(int cc, int Rd, int Rm);
-    virtual void QADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QDADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs);
-    virtual void SMULW(int cc, int y,
-                int Rd, int Rm, int Rs);
-    virtual void SMLA(int cc, int xy,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void SMLAL(int cc, int xy,
-                int RdHi, int RdLo, int Rs, int Rm);
-    virtual void SMLAW(int cc, int y,
-                int Rd, int Rm, int Rs, int Rn);
-
-    // byte/half word extract...
-    virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
-
-    // bit manipulation...
-    virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
-
-    // Address loading/storing/manipulation
-    virtual void ADDR_LDR(int cc, int Rd, int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void ADDR_STR(int cc, int Rd, int Rn, uint32_t offset = __immed12_pre(0));
-    virtual void ADDR_ADD(int cc, int s, int Rd, int Rn, uint32_t Op2);
-    virtual void ADDR_SUB(int cc, int s, int Rd, int Rn, uint32_t Op2);
-
-    // this is some crap to share is MIPS64Assembler class for debug
-    char *      mArmDisassemblyBuffer;
-    int         mArmLineLength;
-    int         mArmInstrCount;
-
-    int         mInum;      // current arm instuction number (0..n)
-    uint32_t**  mArmPC;     // array: PC for 1st mips instr of
-                            //      each translated ARM instr
-
-
-private:
-    ArmToMips64Assembler(const ArmToMips64Assembler& rhs);
-    ArmToMips64Assembler& operator = (const ArmToMips64Assembler& rhs);
-
-    void init_conditional_labels(void);
-
-    void protectConditionalOperands(int Rd);
-
-    // reg__tmp set to MIPS AT, reg 1
-    int dataProcAdrModes(int op, int& source, bool sign = false, int reg_tmp = 1);
-
-    sp<Assembly>        mAssembly;
-    MIPS64Assembler*    mMips;
-
-
-    enum misc_constants_t {
-        ARM_MAX_INSTUCTIONS = 512  // based on ASSEMBLY_SCRATCH_SIZE
-    };
-
-    enum {
-        SRC_REG = 0,
-        SRC_IMM,
-        SRC_ERROR = -1
-    };
-
-    enum addr_modes {
-        // start above the range of legal mips reg #'s (0-31)
-        AMODE_REG = 0x20,
-        AMODE_IMM, AMODE_REG_IMM,               // for data processing
-        AMODE_IMM_12_PRE, AMODE_IMM_12_POST,    // for load/store
-        AMODE_REG_SCALE_PRE, AMODE_IMM_8_PRE,
-        AMODE_IMM_8_POST, AMODE_REG_PRE,
-        AMODE_UNSUPPORTED
-    };
-
-    struct addr_mode_t {    // address modes for current ARM instruction
-        int         reg;
-        int         stype;
-        uint32_t    value;
-        bool        writeback;  // writeback the adr reg after modification
-    } amode;
-
-    enum cond_types {
-        CMP_COND = 1,
-        SBIT_COND
-    };
-
-    struct cond_mode_t {    // conditional-execution info for current ARM instruction
-        cond_types  type;
-        int         r1;
-        int         r2;
-        int         labelnum;
-        char        label[100][10];
-    } cond;
-};
-
-
-
-
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-
-// This is the basic MIPS64 assembler, which just creates the opcodes in memory.
-// All the more complicated work is done in ArmToMips64Assember above.
-// Inherits MIPSAssembler class, and overrides only MIPS64r6 specific stuff
-
-class MIPS64Assembler : public MIPSAssembler
-{
-public:
-                MIPS64Assembler(const sp<Assembly>& assembly, ArmToMips64Assembler *parent);
-                MIPS64Assembler(void* assembly, ArmToMips64Assembler *parent);
-    virtual     ~MIPS64Assembler();
-
-    virtual void        reset();
-    virtual void        disassemble(const char* name);
-
-    void        fix_branches();
-
-    // ------------------------------------------------------------------------
-    // MIPS64AssemblerInterface...
-    // ------------------------------------------------------------------------
-
-#if 0
-#pragma mark -
-#pragma mark Arithmetic...
-#endif
-
-    void DADDU(int Rd, int Rs, int Rt);
-    void DADDIU(int Rt, int Rs, int16_t imm);
-    void DSUBU(int Rd, int Rs, int Rt);
-    void DSUBIU(int Rt, int Rs, int16_t imm);
-    virtual void MUL(int Rd, int Rs, int Rt);
-    void MUH(int Rd, int Rs, int Rt);
-
-#if 0
-#pragma mark -
-#pragma mark Logical...
-#endif
-
-    virtual void CLO(int Rd, int Rs);
-    virtual void CLZ(int Rd, int Rs);
-
-#if 0
-#pragma mark -
-#pragma mark Load/store...
-#endif
-
-    void LD(int Rt, int Rbase, int16_t offset);
-    void SD(int Rt, int Rbase, int16_t offset);
-    virtual void LUI(int Rt, int16_t offset);
-
-#if 0
-#pragma mark -
-#pragma mark Branch...
-#endif
-
-    void JR(int Rs);
-
-
-protected:
-    ArmToMips64Assembler *mParent;
-
-    // opcode field of all instructions
-    enum opcode_field {
-        spec_op, regimm_op, j_op, jal_op,                  // 0x00 - 0x03
-        beq_op, bne_op, pop06_op, pop07_op,                // 0x04 - 0x07
-        pop10_op, addiu_op, slti_op, sltiu_op,             // 0x08 - 0x0b
-        andi_op, ori_op, xori_op, aui_op,                  // 0x0c - 0x0f
-        cop0_op, cop1_op, cop2_op, rsrv_opc_0,             // 0x10 - 0x13
-        rsrv_opc_1, rsrv_opc_2, pop26_op, pop27_op,        // 0x14 - 0x17
-        pop30_op, daddiu_op, rsrv_opc_3, rsrv_opc_4,       // 0x18 - 0x1b
-        rsrv_opc_5, daui_op, msa_op, spec3_op,             // 0x1c - 0x1f
-        lb_op, lh_op, rsrv_opc_6, lw_op,                   // 0x20 - 0x23
-        lbu_op, lhu_op, rsrv_opc_7, lwu_op,                // 0x24 - 0x27
-        sb_op, sh_op, rsrv_opc_8, sw_op,                   // 0x28 - 0x2b
-        rsrv_opc_9, rsrv_opc_10, rsrv_opc_11, rsrv_opc_12, // 0x2c - 0x2f
-        rsrv_opc_13, lwc1_op, bc_op, rsrv_opc_14,          // 0x2c - 0x2f
-        rsrv_opc_15, ldc1_op, pop66_op, ld_op,             // 0x30 - 0x33
-        rsrv_opc_16, swc1_op, balc_op, pcrel_op,           // 0x34 - 0x37
-        rsrv_opc_17, sdc1_op, pop76_op, sd_op              // 0x38 - 0x3b
-    };
-
-
-    // func field for special opcode
-    enum func_spec_op {
-        sll_fn, rsrv_spec_0, srl_fn, sra_fn,
-        sllv_fn, lsa_fn, srlv_fn, srav_fn,
-        rsrv_spec_1, jalr_fn, rsrv_spec_2, rsrv_spec_3,
-        syscall_fn, break_fn, sdbbp_fn, sync_fn,
-        clz_fn, clo_fn, dclz_fn, dclo_fn,
-        dsllv_fn, dlsa_fn, dsrlv_fn, dsrav_fn,
-        sop30_fn, sop31_fn, sop32_fn, sop33_fn,
-        sop34_fn, sop35_fn, sop36_fn, sop37_fn,
-        add_fn, addu_fn, sub_fn, subu_fn,
-        and_fn, or_fn, xor_fn, nor_fn,
-        rsrv_spec_4, rsrv_spec_5, slt_fn, sltu_fn,
-        dadd_fn, daddu_fn, dsub_fn, dsubu_fn,
-        tge_fn, tgeu_fn, tlt_fn, tltu_fn,
-        teq_fn, seleqz_fn, tne_fn, selnez_fn,
-        dsll_fn, rsrv_spec_6, dsrl_fn, dsra_fn,
-        dsll32_fn, rsrv_spec_7, dsrl32_fn, dsra32_fn
-    };
-
-    // func field for spec3 opcode
-    enum func_spec3_op {
-        ext_fn, dextm_fn, dextu_fn, dext_fn,
-        ins_fn, dinsm_fn, dinsu_fn, dins_fn,
-        cachee_fn = 0x1b, sbe_fn, she_fn, sce_fn, swe_fn,
-        bshfl_fn, prefe_fn = 0x23, dbshfl_fn, cache_fn, sc_fn, scd_fn,
-        lbue_fn, lhue_fn, lbe_fn = 0x2c, lhe_fn, lle_fn, lwe_fn,
-        pref_fn = 0x35, ll_fn, lld_fn, rdhwr_fn = 0x3b
-    };
-
-    // sa field for spec3 opcodes, with BSHFL function
-    enum func_spec3_bshfl {
-        bitswap_fn,
-        wsbh_fn = 0x02,
-        dshd_fn = 0x05,
-        seb_fn = 0x10,
-        seh_fn = 0x18
-    };
-
-    // rt field of regimm opcodes.
-    enum regimm_fn {
-        bltz_fn, bgez_fn,
-        dahi_fn = 0x6,
-        nal_fn = 0x10, bal_fn, bltzall_fn, bgezall_fn,
-        sigrie_fn = 0x17,
-        dati_fn = 0x1e, synci_fn
-    };
-
-    enum muldiv_fn {
-        mul_fn = 0x02, muh_fn
-    };
-
-    enum mips_inst_shifts {
-        OP_SHF       = 26,
-        JTARGET_SHF  = 0,
-        RS_SHF       = 21,
-        RT_SHF       = 16,
-        RD_SHF       = 11,
-        RE_SHF       = 6,
-        SA_SHF       = RE_SHF,  // synonym
-        IMM_SHF      = 0,
-        FUNC_SHF     = 0,
-
-        // mask values
-        MSK_16       = 0xffff,
-
-
-        CACHEOP_SHF  = 18,
-        CACHESEL_SHF = 16,
-    };
-};
-
-
-}; // namespace android
-
-#endif //ANDROID_MIPS64ASSEMBLER_H
diff --git a/libpixelflinger/codeflinger/MIPSAssembler.cpp b/libpixelflinger/codeflinger/MIPSAssembler.cpp
deleted file mode 100644
index 7de8cc1..0000000
--- a/libpixelflinger/codeflinger/MIPSAssembler.cpp
+++ /dev/null
@@ -1,1955 +0,0 @@
-/* libs/pixelflinger/codeflinger/MIPSAssembler.cpp
-**
-** Copyright 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.
-*/
-
-
-/* MIPS assembler and ARM->MIPS assembly translator
-**
-** The approach is to leave the GGLAssembler and associated files largely
-** un-changed, still utilizing all Arm instruction generation. Via the
-** ArmToMipsAssembler (subclassed from ArmAssemblerInterface) each Arm
-** instruction is translated to one or more Mips instructions as necessary. This
-** is clearly less efficient than a direct implementation within the
-** GGLAssembler, but is far cleaner, more maintainable, and has yielded very
-** significant performance gains on Mips compared to the generic pixel pipeline.
-**
-**
-** GGLAssembler changes
-**
-** - The register allocator has been modified to re-map Arm registers 0-15 to mips
-** registers 2-17. Mips register 0 cannot be used as general-purpose register,
-** and register 1 has traditional uses as a short-term temporary.
-**
-** - Added some early bailouts for OUT_OF_REGISTERS in texturing.cpp and
-** GGLAssembler.cpp, since this is not fatal, and can be retried at lower
-** optimization level.
-**
-**
-** ARMAssembler and ARMAssemblerInterface changes
-**
-** Refactored ARM address-mode static functions (imm(), reg_imm(), imm12_pre(), etc.)
-** to virtual, so they can be overridden in MIPSAssembler. The implementation of these
-** functions on ARM is moved from ARMAssemblerInterface.cpp to ARMAssembler.cpp, and
-** is unchanged from the original. (This required duplicating 2 of these as static
-** functions in ARMAssemblerInterface.cpp so they could be used as static initializers).
-*/
-
-#define LOG_TAG "MIPSAssembler"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include <cutils/properties.h>
-#include <log/log.h>
-#include <private/pixelflinger/ggl_context.h>
-
-#include "CodeCache.h"
-#include "MIPSAssembler.h"
-#include "mips_disassem.h"
-
-#define __unused __attribute__((__unused__))
-
-// Choose MIPS arch variant following gcc flags
-#if defined(__mips__) && __mips==32 && __mips_isa_rev>=2
-#define mips32r2 1
-#else
-#define mips32r2 0
-#endif
-
-
-#define NOT_IMPLEMENTED()  LOG_ALWAYS_FATAL("Arm instruction %s not yet implemented\n", __func__)
-
-
-
-// ----------------------------------------------------------------------------
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark ArmToMipsAssembler...
-#endif
-
-ArmToMipsAssembler::ArmToMipsAssembler(const sp<Assembly>& assembly,
-                                       char *abuf, int linesz, int instr_count)
-    :   ARMAssemblerInterface(),
-        mArmDisassemblyBuffer(abuf),
-        mArmLineLength(linesz),
-        mArmInstrCount(instr_count),
-        mInum(0),
-        mAssembly(assembly)
-{
-    mMips = new MIPSAssembler(assembly, this);
-    mArmPC = (uint32_t **) malloc(ARM_MAX_INSTUCTIONS * sizeof(uint32_t *));
-    init_conditional_labels();
-}
-
-ArmToMipsAssembler::~ArmToMipsAssembler()
-{
-    delete mMips;
-    free((void *) mArmPC);
-}
-
-uint32_t* ArmToMipsAssembler::pc() const
-{
-    return mMips->pc();
-}
-
-uint32_t* ArmToMipsAssembler::base() const
-{
-    return mMips->base();
-}
-
-void ArmToMipsAssembler::reset()
-{
-    cond.labelnum = 0;
-    mInum = 0;
-    mMips->reset();
-}
-
-int ArmToMipsAssembler::getCodegenArch()
-{
-    return CODEGEN_ARCH_MIPS;
-}
-
-void ArmToMipsAssembler::comment(const char* string)
-{
-    mMips->comment(string);
-}
-
-void ArmToMipsAssembler::label(const char* theLabel)
-{
-    mMips->label(theLabel);
-}
-
-void ArmToMipsAssembler::disassemble(const char* name)
-{
-    mMips->disassemble(name);
-}
-
-void ArmToMipsAssembler::init_conditional_labels()
-{
-    int i;
-    for (i=0;i<99; ++i) {
-        sprintf(cond.label[i], "cond_%d", i);
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Prolog/Epilog & Generate...
-#endif
-
-void ArmToMipsAssembler::prolog()
-{
-    mArmPC[mInum++] = pc();  // save starting PC for this instr
-
-    mMips->ADDIU(R_sp, R_sp, -(5 * 4));
-    mMips->SW(R_s0, R_sp, 0);
-    mMips->SW(R_s1, R_sp, 4);
-    mMips->SW(R_s2, R_sp, 8);
-    mMips->SW(R_s3, R_sp, 12);
-    mMips->SW(R_s4, R_sp, 16);
-    mMips->MOVE(R_v0, R_a0);    // move context * passed in a0 to v0 (arm r0)
-}
-
-void ArmToMipsAssembler::epilog(uint32_t touched __unused)
-{
-    mArmPC[mInum++] = pc();  // save starting PC for this instr
-
-    mMips->LW(R_s0, R_sp, 0);
-    mMips->LW(R_s1, R_sp, 4);
-    mMips->LW(R_s2, R_sp, 8);
-    mMips->LW(R_s3, R_sp, 12);
-    mMips->LW(R_s4, R_sp, 16);
-    mMips->ADDIU(R_sp, R_sp, (5 * 4));
-    mMips->JR(R_ra);
-
-}
-
-int ArmToMipsAssembler::generate(const char* name)
-{
-    return mMips->generate(name);
-}
-
-uint32_t* ArmToMipsAssembler::pcForLabel(const char* label)
-{
-    return mMips->pcForLabel(label);
-}
-
-
-
-//----------------------------------------------------------
-
-#if 0
-#pragma mark -
-#pragma mark Addressing modes & shifters...
-#endif
-
-
-// do not need this for MIPS, but it is in the Interface (virtual)
-int ArmToMipsAssembler::buildImmediate(
-        uint32_t immediate, uint32_t& rot, uint32_t& imm)
-{
-    // for MIPS, any 32-bit immediate is OK
-    rot = 0;
-    imm = immediate;
-    return 0;
-}
-
-// shifters...
-
-bool ArmToMipsAssembler::isValidImmediate(uint32_t immediate __unused)
-{
-    // for MIPS, any 32-bit immediate is OK
-    return true;
-}
-
-uint32_t ArmToMipsAssembler::imm(uint32_t immediate)
-{
-    // ALOGW("immediate value %08x at pc %08x\n", immediate, (int)pc());
-    amode.value = immediate;
-    return AMODE_IMM;
-}
-
-uint32_t ArmToMipsAssembler::reg_imm(int Rm, int type, uint32_t shift)
-{
-    amode.reg = Rm;
-    amode.stype = type;
-    amode.value = shift;
-    return AMODE_REG_IMM;
-}
-
-uint32_t ArmToMipsAssembler::reg_rrx(int Rm __unused)
-{
-    // reg_rrx mode is not used in the GLLAssember code at this time
-    return AMODE_UNSUPPORTED;
-}
-
-uint32_t ArmToMipsAssembler::reg_reg(int Rm __unused, int type __unused,
-                                     int Rs __unused)
-{
-    // reg_reg mode is not used in the GLLAssember code at this time
-    return AMODE_UNSUPPORTED;
-}
-
-
-// addressing modes...
-// LDR(B)/STR(B)/PLD (immediate and Rm can be negative, which indicate U=0)
-uint32_t ArmToMipsAssembler::immed12_pre(int32_t immed12, int W)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800,
-                        "LDR(B)/STR(B)/PLD immediate too big (%08x)",
-                        immed12);
-    amode.value = immed12;
-    amode.writeback = W;
-    return AMODE_IMM_12_PRE;
-}
-
-uint32_t ArmToMipsAssembler::immed12_post(int32_t immed12)
-{
-    LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800,
-                        "LDR(B)/STR(B)/PLD immediate too big (%08x)",
-                        immed12);
-
-    amode.value = immed12;
-    return AMODE_IMM_12_POST;
-}
-
-uint32_t ArmToMipsAssembler::reg_scale_pre(int Rm, int type,
-        uint32_t shift, int W)
-{
-    LOG_ALWAYS_FATAL_IF(W | type | shift, "reg_scale_pre adv modes not yet implemented");
-
-    amode.reg = Rm;
-    // amode.stype = type;      // more advanced modes not used in GGLAssembler yet
-    // amode.value = shift;
-    // amode.writeback = W;
-    return AMODE_REG_SCALE_PRE;
-}
-
-uint32_t ArmToMipsAssembler::reg_scale_post(int Rm __unused, int type __unused,
-                                            uint32_t shift __unused)
-{
-    LOG_ALWAYS_FATAL("adr mode reg_scale_post not yet implemented\n");
-    return AMODE_UNSUPPORTED;
-}
-
-// LDRH/LDRSB/LDRSH/STRH (immediate and Rm can be negative, which indicate U=0)
-uint32_t ArmToMipsAssembler::immed8_pre(int32_t immed8, int W __unused)
-{
-    // uint32_t offset = abs(immed8);
-
-    LOG_ALWAYS_FATAL("adr mode immed8_pre not yet implemented\n");
-
-    LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100,
-                        "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)",
-                        immed8);
-    return AMODE_IMM_8_PRE;
-}
-
-uint32_t ArmToMipsAssembler::immed8_post(int32_t immed8)
-{
-    // uint32_t offset = abs(immed8);
-
-    LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100,
-                        "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)",
-                        immed8);
-    amode.value = immed8;
-    return AMODE_IMM_8_POST;
-}
-
-uint32_t ArmToMipsAssembler::reg_pre(int Rm, int W)
-{
-    LOG_ALWAYS_FATAL_IF(W, "reg_pre writeback not yet implemented");
-    amode.reg = Rm;
-    return AMODE_REG_PRE;
-}
-
-uint32_t ArmToMipsAssembler::reg_post(int Rm __unused)
-{
-    LOG_ALWAYS_FATAL("adr mode reg_post not yet implemented\n");
-    return AMODE_UNSUPPORTED;
-}
-
-
-
-// ----------------------------------------------------------------------------
-
-#if 0
-#pragma mark -
-#pragma mark Data Processing...
-#endif
-
-// check if the operand registers from a previous CMP or S-bit instruction
-// would be overwritten by this instruction. If so, move the value to a
-// safe register.
-// Note that we cannot tell at _this_ instruction time if a future (conditional)
-// instruction will _also_ use this value (a defect of the simple 1-pass, one-
-// instruction-at-a-time translation). Therefore we must be conservative and
-// save the value before it is overwritten. This costs an extra MOVE instr.
-
-void ArmToMipsAssembler::protectConditionalOperands(int Rd)
-{
-    if (Rd == cond.r1) {
-        mMips->MOVE(R_cmp, cond.r1);
-        cond.r1 = R_cmp;
-    }
-    if (cond.type == CMP_COND && Rd == cond.r2) {
-        mMips->MOVE(R_cmp2, cond.r2);
-        cond.r2 = R_cmp2;
-    }
-}
-
-
-// interprets the addressing mode, and generates the common code
-// used by the majority of data-processing ops. Many MIPS instructions
-// have a register-based form and a different immediate form. See
-// opAND below for an example. (this could be inlined)
-//
-// this works with the imm(), reg_imm() methods above, which are directly
-// called by the GLLAssembler.
-// note: _signed parameter defaults to false (un-signed)
-// note: tmpReg parameter defaults to 1, MIPS register AT
-int ArmToMipsAssembler::dataProcAdrModes(int op, int& source, bool _signed, int tmpReg)
-{
-    if (op < AMODE_REG) {
-        source = op;
-        return SRC_REG;
-    } else if (op == AMODE_IMM) {
-        if ((!_signed && amode.value > 0xffff)
-                || (_signed && ((int)amode.value < -32768 || (int)amode.value > 32767) )) {
-            mMips->LUI(tmpReg, (amode.value >> 16));
-            if (amode.value & 0x0000ffff) {
-                mMips->ORI(tmpReg, tmpReg, (amode.value & 0x0000ffff));
-            }
-            source = tmpReg;
-            return SRC_REG;
-        } else {
-            source = amode.value;
-            return SRC_IMM;
-        }
-    } else if (op == AMODE_REG_IMM) {
-        switch (amode.stype) {
-            case LSL: mMips->SLL(tmpReg, amode.reg, amode.value); break;
-            case LSR: mMips->SRL(tmpReg, amode.reg, amode.value); break;
-            case ASR: mMips->SRA(tmpReg, amode.reg, amode.value); break;
-            case ROR: if (mips32r2) {
-                          mMips->ROTR(tmpReg, amode.reg, amode.value);
-                      } else {
-                          mMips->RORIsyn(tmpReg, amode.reg, amode.value);
-                      }
-                      break;
-        }
-        source = tmpReg;
-        return SRC_REG;
-    } else {  // adr mode RRX is not used in GGL Assembler at this time
-        // we are screwed, this should be exception, assert-fail or something
-        LOG_ALWAYS_FATAL("adr mode reg_rrx not yet implemented\n");
-        return SRC_ERROR;
-    }
-}
-
-
-void ArmToMipsAssembler::dataProcessing(int opcode, int cc,
-        int s, int Rd, int Rn, uint32_t Op2)
-{
-    int src;    // src is modified by dataProcAdrModes() - passed as int&
-
-
-    if (cc != AL) {
-        protectConditionalOperands(Rd);
-        // the branch tests register(s) set by prev CMP or instr with 'S' bit set
-        // inverse the condition to jump past this conditional instruction
-        ArmToMipsAssembler::B(cc^1, cond.label[++cond.labelnum]);
-    } else {
-        mArmPC[mInum++] = pc();  // save starting PC for this instr
-    }
-
-    switch (opcode) {
-    case opAND:
-        if (dataProcAdrModes(Op2, src) == SRC_REG) {
-            mMips->AND(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->ANDI(Rd, Rn, src);
-        }
-        break;
-
-    case opADD:
-        // set "signed" to true for adr modes
-        if (dataProcAdrModes(Op2, src, true) == SRC_REG) {
-            mMips->ADDU(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->ADDIU(Rd, Rn, src);
-        }
-        break;
-
-    case opSUB:
-        // set "signed" to true for adr modes
-        if (dataProcAdrModes(Op2, src, true) == SRC_REG) {
-            mMips->SUBU(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->SUBIU(Rd, Rn, src);
-        }
-        break;
-
-    case opEOR:
-        if (dataProcAdrModes(Op2, src) == SRC_REG) {
-            mMips->XOR(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->XORI(Rd, Rn, src);
-        }
-        break;
-
-    case opORR:
-        if (dataProcAdrModes(Op2, src) == SRC_REG) {
-            mMips->OR(Rd, Rn, src);
-        } else {                        // adr mode was SRC_IMM
-            mMips->ORI(Rd, Rn, src);
-        }
-        break;
-
-    case opBIC:
-        if (dataProcAdrModes(Op2, src) == SRC_IMM) {
-            // if we are 16-bit imnmediate, load to AT reg
-            mMips->ORI(R_at, 0, src);
-            src = R_at;
-        }
-        mMips->NOT(R_at, src);
-        mMips->AND(Rd, Rn, R_at);
-        break;
-
-    case opRSB:
-        if (dataProcAdrModes(Op2, src) == SRC_IMM) {
-            // if we are 16-bit imnmediate, load to AT reg
-            mMips->ORI(R_at, 0, src);
-            src = R_at;
-        }
-        mMips->SUBU(Rd, src, Rn);   // subu with the parameters reversed
-        break;
-
-    case opMOV:
-        if (Op2 < AMODE_REG) {  // op2 is reg # in this case
-            mMips->MOVE(Rd, Op2);
-        } else if (Op2 == AMODE_IMM) {
-            if (amode.value > 0xffff) {
-                mMips->LUI(Rd, (amode.value >> 16));
-                if (amode.value & 0x0000ffff) {
-                    mMips->ORI(Rd, Rd, (amode.value & 0x0000ffff));
-                }
-             } else {
-                mMips->ORI(Rd, 0, amode.value);
-            }
-        } else if (Op2 == AMODE_REG_IMM) {
-            switch (amode.stype) {
-            case LSL: mMips->SLL(Rd, amode.reg, amode.value); break;
-            case LSR: mMips->SRL(Rd, amode.reg, amode.value); break;
-            case ASR: mMips->SRA(Rd, amode.reg, amode.value); break;
-            case ROR: if (mips32r2) {
-                          mMips->ROTR(Rd, amode.reg, amode.value);
-                      } else {
-                          mMips->RORIsyn(Rd, amode.reg, amode.value);
-                      }
-                      break;
-            }
-        }
-        else {
-            // adr mode RRX is not used in GGL Assembler at this time
-            mMips->UNIMPL();
-        }
-        break;
-
-    case opMVN:     // this is a 1's complement: NOT
-        if (Op2 < AMODE_REG) {  // op2 is reg # in this case
-            mMips->NOR(Rd, Op2, 0);     // NOT is NOR with 0
-            break;
-        } else if (Op2 == AMODE_IMM) {
-            if (amode.value > 0xffff) {
-                mMips->LUI(Rd, (amode.value >> 16));
-                if (amode.value & 0x0000ffff) {
-                    mMips->ORI(Rd, Rd, (amode.value & 0x0000ffff));
-                }
-             } else {
-                mMips->ORI(Rd, 0, amode.value);
-             }
-        } else if (Op2 == AMODE_REG_IMM) {
-            switch (amode.stype) {
-            case LSL: mMips->SLL(Rd, amode.reg, amode.value); break;
-            case LSR: mMips->SRL(Rd, amode.reg, amode.value); break;
-            case ASR: mMips->SRA(Rd, amode.reg, amode.value); break;
-            case ROR: if (mips32r2) {
-                          mMips->ROTR(Rd, amode.reg, amode.value);
-                      } else {
-                          mMips->RORIsyn(Rd, amode.reg, amode.value);
-                      }
-                      break;
-            }
-        }
-        else {
-            // adr mode RRX is not used in GGL Assembler at this time
-            mMips->UNIMPL();
-        }
-        mMips->NOR(Rd, Rd, 0);     // NOT is NOR with 0
-        break;
-
-    case opCMP:
-        // Either operand of a CMP instr could get overwritten by a subsequent
-        // conditional instruction, which is ok, _UNLESS_ there is a _second_
-        // conditional instruction. Under MIPS, this requires doing the comparison
-        // again (SLT), and the original operands must be available. (and this
-        // pattern of multiple conditional instructions from same CMP _is_ used
-        // in GGL-Assembler)
-        //
-        // For now, if a conditional instr overwrites the operands, we will
-        // move them to dedicated temp regs. This is ugly, and inefficient,
-        // and should be optimized.
-        //
-        // WARNING: making an _Assumption_ that CMP operand regs will NOT be
-        // trashed by intervening NON-conditional instructions. In the general
-        // case this is legal, but it is NOT currently done in GGL-Assembler.
-
-        cond.type = CMP_COND;
-        cond.r1 = Rn;
-        if (dataProcAdrModes(Op2, src, false, R_cmp2) == SRC_REG) {
-            cond.r2 = src;
-        } else {                        // adr mode was SRC_IMM
-            mMips->ORI(R_cmp2, R_zero, src);
-            cond.r2 = R_cmp2;
-        }
-
-        break;
-
-
-    case opTST:
-    case opTEQ:
-    case opCMN:
-    case opADC:
-    case opSBC:
-    case opRSC:
-        mMips->UNIMPL(); // currently unused in GGL Assembler code
-        break;
-    }
-
-    if (cc != AL) {
-        mMips->label(cond.label[cond.labelnum]);
-    }
-    if (s && opcode != opCMP) {
-        cond.type = SBIT_COND;
-        cond.r1 = Rd;
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Multiply...
-#endif
-
-// multiply, accumulate
-void ArmToMipsAssembler::MLA(int cc __unused, int s,
-        int Rd, int Rm, int Rs, int Rn) {
-
-    mArmPC[mInum++] = pc();  // save starting PC for this instr
-
-    mMips->MUL(R_at, Rm, Rs);
-    mMips->ADDU(Rd, R_at, Rn);
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = Rd;
-    }
-}
-
-void ArmToMipsAssembler::MUL(int cc __unused, int s,
-        int Rd, int Rm, int Rs) {
-    mArmPC[mInum++] = pc();
-    mMips->MUL(Rd, Rm, Rs);
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = Rd;
-    }
-}
-
-void ArmToMipsAssembler::UMULL(int cc __unused, int s,
-        int RdLo, int RdHi, int Rm, int Rs) {
-    mArmPC[mInum++] = pc();
-    mMips->MULT(Rm, Rs);
-    mMips->MFHI(RdHi);
-    mMips->MFLO(RdLo);
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on UMULL must be on 64-bit result\n");
-    }
-}
-
-void ArmToMipsAssembler::UMUAL(int cc __unused, int s,
-        int RdLo __unused, int RdHi, int Rm __unused, int Rs __unused) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "UMUAL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    // *mPC++ =    (cc<<28) | (1<<23) | (1<<21) | (s<<20) |
-    //             (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on UMULL must be on 64-bit result\n");
-    }
-}
-
-void ArmToMipsAssembler::SMULL(int cc __unused, int s,
-        int RdLo __unused, int RdHi, int Rm __unused, int Rs __unused) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "SMULL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    // *mPC++ =    (cc<<28) | (1<<23) | (1<<22) | (s<<20) |
-    //             (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on SMULL must be on 64-bit result\n");
-    }
-}
-void ArmToMipsAssembler::SMUAL(int cc __unused, int s,
-        int RdLo __unused, int RdHi, int Rm __unused, int Rs __unused) {
-    LOG_FATAL_IF(RdLo==Rm || RdHi==Rm || RdLo==RdHi,
-                        "SMUAL(r%u,r%u,r%u,r%u)", RdLo,RdHi,Rm,Rs);
-    // *mPC++ =    (cc<<28) | (1<<23) | (1<<22) | (1<<21) | (s<<20) |
-    //             (RdHi<<16) | (RdLo<<12) | (Rs<<8) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-    if (s) {
-        cond.type = SBIT_COND;
-        cond.r1 = RdHi;     // BUG...
-        LOG_ALWAYS_FATAL("Condition on SMUAL must be on 64-bit result\n");
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Branches...
-#endif
-
-// branches...
-
-void ArmToMipsAssembler::B(int cc, const char* label)
-{
-    mArmPC[mInum++] = pc();
-    if (cond.type == SBIT_COND) { cond.r2 = R_zero; }
-
-    switch(cc) {
-        case EQ: mMips->BEQ(cond.r1, cond.r2, label); break;
-        case NE: mMips->BNE(cond.r1, cond.r2, label); break;
-        case HS: mMips->BGEU(cond.r1, cond.r2, label); break;
-        case LO: mMips->BLTU(cond.r1, cond.r2, label); break;
-        case MI: mMips->BLT(cond.r1, cond.r2, label); break;
-        case PL: mMips->BGE(cond.r1, cond.r2, label); break;
-
-        case HI: mMips->BGTU(cond.r1, cond.r2, label); break;
-        case LS: mMips->BLEU(cond.r1, cond.r2, label); break;
-        case GE: mMips->BGE(cond.r1, cond.r2, label); break;
-        case LT: mMips->BLT(cond.r1, cond.r2, label); break;
-        case GT: mMips->BGT(cond.r1, cond.r2, label); break;
-        case LE: mMips->BLE(cond.r1, cond.r2, label); break;
-        case AL: mMips->B(label); break;
-        case NV: /* B Never - no instruction */ break;
-
-        case VS:
-        case VC:
-        default:
-            LOG_ALWAYS_FATAL("Unsupported cc: %02x\n", cc);
-            break;
-    }
-}
-
-void ArmToMipsAssembler::BL(int cc __unused, const char* label __unused)
-{
-    LOG_ALWAYS_FATAL("branch-and-link not supported yet\n");
-    mArmPC[mInum++] = pc();
-}
-
-// no use for Branches with integer PC, but they're in the Interface class ....
-void ArmToMipsAssembler::B(int cc __unused, uint32_t* to_pc __unused)
-{
-    LOG_ALWAYS_FATAL("branch to absolute PC not supported, use Label\n");
-    mArmPC[mInum++] = pc();
-}
-
-void ArmToMipsAssembler::BL(int cc __unused, uint32_t* to_pc __unused)
-{
-    LOG_ALWAYS_FATAL("branch to absolute PC not supported, use Label\n");
-    mArmPC[mInum++] = pc();
-}
-
-void ArmToMipsAssembler::BX(int cc __unused, int Rn __unused)
-{
-    LOG_ALWAYS_FATAL("branch to absolute PC not supported, use Label\n");
-    mArmPC[mInum++] = pc();
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Data Transfer...
-#endif
-
-// data transfer...
-void ArmToMipsAssembler::LDR(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;      // convert LDR via Arm SP to LW via Mips SP
-            }
-            mMips->LW(Rd, Rn, amode.value);
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                mMips->ADDIU(Rn, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;      // convert STR thru Arm SP to STR thru Mips SP
-            }
-            mMips->LW(Rd, Rn, 0);
-            mMips->ADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->ADDU(R_at, Rn, amode.reg);
-            mMips->LW(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMipsAssembler::LDRB(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            mMips->LBU(Rd, Rn, amode.value);
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                mMips->ADDIU(Rn, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            mMips->LBU(Rd, Rn, 0);
-            mMips->ADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->ADDU(R_at, Rn, amode.reg);
-            mMips->LBU(Rd, R_at, 0);
-            break;
-    }
-
-}
-
-void ArmToMipsAssembler::STR(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            if (Rn == ARMAssemblerInterface::SP) {
-                Rn = R_sp;  // convert STR thru Arm SP to SW thru Mips SP
-            }
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                // If we will writeback, then update the index reg, then store.
-                // This correctly handles stack-push case.
-                mMips->ADDIU(Rn, Rn, amode.value);
-                mMips->SW(Rd, Rn, 0);
-            } else {
-                // No writeback so store offset by value
-                mMips->SW(Rd, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            mMips->SW(Rd, Rn, 0);
-            mMips->ADDIU(Rn, Rn, amode.value);  // post index always writes back
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->ADDU(R_at, Rn, amode.reg);
-            mMips->SW(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMipsAssembler::STRB(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed12_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            amode.writeback = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_12_PRE:
-            mMips->SB(Rd, Rn, amode.value);
-            if (amode.writeback) {      // OPTIONAL writeback on pre-index mode
-                mMips->ADDIU(Rn, Rn, amode.value);
-            }
-            break;
-        case AMODE_IMM_12_POST:
-            mMips->SB(Rd, Rn, 0);
-            mMips->ADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_SCALE_PRE:
-            // we only support simple base + index, no advanced modes for this one yet
-            mMips->ADDU(R_at, Rn, amode.reg);
-            mMips->SB(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMipsAssembler::LDRH(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed8_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_8_PRE:      // no support yet for writeback
-            mMips->LHU(Rd, Rn, amode.value);
-            break;
-        case AMODE_IMM_8_POST:
-            mMips->LHU(Rd, Rn, 0);
-            mMips->ADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_PRE:
-            // we only support simple base +/- index
-            if (amode.reg >= 0) {
-                mMips->ADDU(R_at, Rn, amode.reg);
-            } else {
-                mMips->SUBU(R_at, Rn, abs(amode.reg));
-            }
-            mMips->LHU(Rd, R_at, 0);
-            break;
-    }
-}
-
-void ArmToMipsAssembler::LDRSB(int cc __unused, int Rd __unused,
-                               int Rn __unused, uint32_t offset __unused)
-{
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::LDRSH(int cc __unused, int Rd __unused,
-                               int Rn __unused, uint32_t offset __unused)
-{
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::STRH(int cc __unused, int Rd, int Rn, uint32_t offset)
-{
-    mArmPC[mInum++] = pc();
-    // work-around for ARM default address mode of immed8_pre(0)
-    if (offset > AMODE_UNSUPPORTED) offset = 0;
-    switch (offset) {
-        case 0:
-            amode.value = 0;
-            // fall thru to next case ....
-        case AMODE_IMM_8_PRE:      // no support yet for writeback
-            mMips->SH(Rd, Rn, amode.value);
-            break;
-        case AMODE_IMM_8_POST:
-            mMips->SH(Rd, Rn, 0);
-            mMips->ADDIU(Rn, Rn, amode.value);
-            break;
-        case AMODE_REG_PRE:
-            // we only support simple base +/- index
-            if (amode.reg >= 0) {
-                mMips->ADDU(R_at, Rn, amode.reg);
-            } else {
-                mMips->SUBU(R_at, Rn, abs(amode.reg));
-            }
-            mMips->SH(Rd, R_at, 0);
-            break;
-    }
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Block Data Transfer...
-#endif
-
-// block data transfer...
-void ArmToMipsAssembler::LDM(int cc __unused, int dir __unused,
-        int Rn __unused, int W __unused, uint32_t reg_list __unused)
-{   //                        ED FD EA FA      IB IA DB DA
-    // const uint8_t P[8] = { 1, 0, 1, 0,      1, 0, 1, 0 };
-    // const uint8_t U[8] = { 1, 1, 0, 0,      1, 1, 0, 0 };
-    // *mPC++ = (cc<<28) | (4<<25) | (uint32_t(P[dir])<<24) |
-    //         (uint32_t(U[dir])<<23) | (1<<20) | (W<<21) | (Rn<<16) | reg_list;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::STM(int cc __unused, int dir __unused,
-        int Rn __unused, int W __unused, uint32_t reg_list __unused)
-{   //                        FA EA FD ED      IB IA DB DA
-    // const uint8_t P[8] = { 0, 1, 0, 1,      1, 0, 1, 0 };
-    // const uint8_t U[8] = { 0, 0, 1, 1,      1, 1, 0, 0 };
-    // *mPC++ = (cc<<28) | (4<<25) | (uint32_t(P[dir])<<24) |
-    //         (uint32_t(U[dir])<<23) | (0<<20) | (W<<21) | (Rn<<16) | reg_list;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Special...
-#endif
-
-// special...
-void ArmToMipsAssembler::SWP(int cc __unused, int Rn __unused,
-                             int Rd __unused, int Rm __unused) {
-    // *mPC++ = (cc<<28) | (2<<23) | (Rn<<16) | (Rd << 12) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::SWPB(int cc __unused, int Rn __unused,
-                              int Rd __unused, int Rm __unused) {
-    // *mPC++ = (cc<<28) | (2<<23) | (1<<22) | (Rn<<16) | (Rd << 12) | 0x90 | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::SWI(int cc __unused, uint32_t comment __unused) {
-    // *mPC++ = (cc<<28) | (0xF<<24) | comment;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-
-#if 0
-#pragma mark -
-#pragma mark DSP instructions...
-#endif
-
-// DSP instructions...
-void ArmToMipsAssembler::PLD(int Rn __unused, uint32_t offset) {
-    LOG_ALWAYS_FATAL_IF(!((offset&(1<<24)) && !(offset&(1<<21))),
-                        "PLD only P=1, W=0");
-    // *mPC++ = 0xF550F000 | (Rn<<16) | offset;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::CLZ(int cc __unused, int Rd, int Rm)
-{
-    mArmPC[mInum++] = pc();
-    mMips->CLZ(Rd, Rm);
-}
-
-void ArmToMipsAssembler::QADD(int cc __unused,  int Rd __unused,
-                              int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1000050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::QDADD(int cc __unused,  int Rd __unused,
-                               int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1400050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::QSUB(int cc __unused,  int Rd __unused,
-                              int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1200050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::QDSUB(int cc __unused,  int Rd __unused,
-                               int Rm __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1600050 | (Rn<<16) | (Rd<<12) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-// 16 x 16 signed multiply (like SMLAxx without the accumulate)
-void ArmToMipsAssembler::SMUL(int cc __unused, int xy,
-                int Rd, int Rm, int Rs)
-{
-    mArmPC[mInum++] = pc();
-
-    // the 16 bits may be in the top or bottom half of 32-bit source reg,
-    // as defined by the codes BB, BT, TB, TT (compressed param xy)
-    // where x corresponds to Rm and y to Rs
-
-    // select half-reg for Rm
-    if (xy & xyTB) {
-        // use top 16-bits
-        mMips->SRA(R_at, Rm, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        if (mips32r2) {
-            mMips->SEH(R_at, Rm);
-        } else {
-            mMips->SLL(R_at, Rm, 16);
-            mMips->SRA(R_at, R_at, 16);
-        }
-    }
-    // select half-reg for Rs
-    if (xy & xyBT) {
-        // use top 16-bits
-        mMips->SRA(R_at2, Rs, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        if (mips32r2) {
-            mMips->SEH(R_at2, Rs);
-        } else {
-            mMips->SLL(R_at2, Rs, 16);
-            mMips->SRA(R_at2, R_at2, 16);
-        }
-    }
-    mMips->MUL(Rd, R_at, R_at2);
-}
-
-// signed 32b x 16b multiple, save top 32-bits of 48-bit result
-void ArmToMipsAssembler::SMULW(int cc __unused, int y,
-                int Rd, int Rm, int Rs)
-{
-    mArmPC[mInum++] = pc();
-
-    // the selector yT or yB refers to reg Rs
-    if (y & yT) {
-        // zero the bottom 16-bits, with 2 shifts, it can affect result
-        mMips->SRL(R_at, Rs, 16);
-        mMips->SLL(R_at, R_at, 16);
-
-    } else {
-        // move low 16-bit half, to high half
-        mMips->SLL(R_at, Rs, 16);
-    }
-    mMips->MULT(Rm, R_at);
-    mMips->MFHI(Rd);
-}
-
-// 16 x 16 signed multiply, accumulate: Rd = Rm{16} * Rs{16} + Rn
-void ArmToMipsAssembler::SMLA(int cc __unused, int xy,
-                int Rd, int Rm, int Rs, int Rn)
-{
-    mArmPC[mInum++] = pc();
-
-    // the 16 bits may be in the top or bottom half of 32-bit source reg,
-    // as defined by the codes BB, BT, TB, TT (compressed param xy)
-    // where x corresponds to Rm and y to Rs
-
-    // select half-reg for Rm
-    if (xy & xyTB) {
-        // use top 16-bits
-        mMips->SRA(R_at, Rm, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        if (mips32r2) {
-            mMips->SEH(R_at, Rm);
-        } else {
-            mMips->SLL(R_at, Rm, 16);
-            mMips->SRA(R_at, R_at, 16);
-        }
-    }
-    // select half-reg for Rs
-    if (xy & xyBT) {
-        // use top 16-bits
-        mMips->SRA(R_at2, Rs, 16);
-    } else {
-        // use bottom 16, but sign-extend to 32
-        if (mips32r2) {
-            mMips->SEH(R_at2, Rs);
-        } else {
-            mMips->SLL(R_at2, Rs, 16);
-            mMips->SRA(R_at2, R_at2, 16);
-        }
-    }
-
-    mMips->MUL(R_at, R_at, R_at2);
-    mMips->ADDU(Rd, R_at, Rn);
-}
-
-void ArmToMipsAssembler::SMLAL(int cc __unused, int xy __unused,
-                               int RdHi __unused, int RdLo __unused,
-                               int Rs __unused, int Rm __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1400080 | (RdHi<<16) | (RdLo<<12) | (Rs<<8) | (xy<<4) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-void ArmToMipsAssembler::SMLAW(int cc __unused, int y __unused,
-                               int Rd __unused, int Rm __unused,
-                               int Rs __unused, int Rn __unused)
-{
-    // *mPC++ = (cc<<28) | 0x1200080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (y<<4) | Rm;
-    mArmPC[mInum++] = pc();
-    mMips->NOP2();
-    NOT_IMPLEMENTED();
-}
-
-// used by ARMv6 version of GGLAssembler::filter32
-void ArmToMipsAssembler::UXTB16(int cc __unused, int Rd, int Rm, int rotate)
-{
-    mArmPC[mInum++] = pc();
-
-    //Rd[31:16] := ZeroExtend((Rm ROR (8 * sh))[23:16]),
-    //Rd[15:0] := ZeroExtend((Rm ROR (8 * sh))[7:0]). sh 0-3.
-
-    mMips->ROTR(Rm, Rm, rotate * 8);
-    mMips->AND(Rd, Rm, 0x00FF00FF);
-}
-
-void ArmToMipsAssembler::UBFX(int cc __unused, int Rd __unused,
-                              int Rn __unused, int lsb __unused,
-                              int width __unused)
-{
-     /* Placeholder for UBFX */
-     mArmPC[mInum++] = pc();
-
-     mMips->NOP2();
-     NOT_IMPLEMENTED();
-}
-
-
-
-
-
-#if 0
-#pragma mark -
-#pragma mark MIPS Assembler...
-#endif
-
-
-//**************************************************************************
-//**************************************************************************
-//**************************************************************************
-
-
-/* mips assembler
-** this is a subset of mips32r2, targeted specifically at ARM instruction
-** replacement in the pixelflinger/codeflinger code.
-**
-** To that end, there is no need for floating point, or priviledged
-** instructions. This all runs in user space, no float.
-**
-** The syntax makes no attempt to be as complete as the assember, with
-** synthetic instructions, and automatic recognition of immedate operands
-** (use the immediate form of the instruction), etc.
-**
-** We start with mips32r1, and may add r2 and dsp extensions if cpu
-** supports. Decision will be made at compile time, based on gcc
-** options. (makes sense since android will be built for a a specific
-** device)
-*/
-
-MIPSAssembler::MIPSAssembler(const sp<Assembly>& assembly, ArmToMipsAssembler *parent)
-    : mParent(parent),
-    mAssembly(assembly)
-{
-    mBase = mPC = (uint32_t *)assembly->base();
-    mDuration = ggl_system_time();
-}
-
-MIPSAssembler::MIPSAssembler(void* assembly)
-    : mParent(NULL), mAssembly(NULL)
-{
-    mBase = mPC = (uint32_t *)assembly;
-}
-
-MIPSAssembler::~MIPSAssembler()
-{
-}
-
-
-uint32_t* MIPSAssembler::pc() const
-{
-    return mPC;
-}
-
-uint32_t* MIPSAssembler::base() const
-{
-    return mBase;
-}
-
-void MIPSAssembler::reset()
-{
-    mBase = mPC = (uint32_t *)mAssembly->base();
-    mBranchTargets.clear();
-    mLabels.clear();
-    mLabelsInverseMapping.clear();
-    mComments.clear();
-}
-
-
-// convert tabs to spaces, and remove any newline
-// works with strings of limited size (makes a temp copy)
-#define TABSTOP 8
-void MIPSAssembler::string_detab(char *s)
-{
-    char *os = s;
-    char temp[100];
-    char *t = temp;
-    int len = 99;
-    int i = TABSTOP;
-
-    while (*s && len-- > 0) {
-        if (*s == '\n') { s++; continue; }
-        if (*s == '\t') {
-            s++;
-            for ( ; i>0; i--) {*t++ = ' '; len--; }
-        } else {
-            *t++ = *s++;
-        }
-        if (i <= 0) i = TABSTOP;
-        i--;
-    }
-    *t = '\0';
-    strcpy(os, temp);
-}
-
-void MIPSAssembler::string_pad(char *s, int padded_len)
-{
-    int len = strlen(s);
-    s += len;
-    for (int i = padded_len - len; i > 0; --i) {
-        *s++ = ' ';
-    }
-    *s = '\0';
-}
-
-// ----------------------------------------------------------------------------
-
-void MIPSAssembler::disassemble(const char* name)
-{
-    char di_buf[140];
-
-    if (name) {
-        ALOGW("%s:\n", name);
-    }
-
-    bool arm_disasm_fmt = (mParent->mArmDisassemblyBuffer == NULL) ? false : true;
-
-    typedef char dstr[40];
-    dstr *lines = (dstr *)mParent->mArmDisassemblyBuffer;
-
-    if (mParent->mArmDisassemblyBuffer != NULL) {
-        for (int i=0; i<mParent->mArmInstrCount; ++i) {
-            string_detab(lines[i]);
-        }
-    }
-
-    size_t count = pc()-base();
-    uint32_t* mipsPC = base();
-    while (count--) {
-        ssize_t label = mLabelsInverseMapping.indexOfKey(mipsPC);
-        if (label >= 0) {
-            ALOGW("%s:\n", mLabelsInverseMapping.valueAt(label));
-        }
-        ssize_t comment = mComments.indexOfKey(mipsPC);
-        if (comment >= 0) {
-            ALOGW("; %s\n", mComments.valueAt(comment));
-        }
-        // ALOGW("%08x:    %08x    ", int(i), int(i[0]));
-        ::mips_disassem(mipsPC, di_buf, arm_disasm_fmt);
-        string_detab(di_buf);
-        string_pad(di_buf, 30);
-        ALOGW("0x%p:    %08x    %s", mipsPC, uint32_t(*mipsPC), di_buf);
-        mipsPC++;
-    }
-}
-
-void MIPSAssembler::comment(const char* string)
-{
-    mComments.add(pc(), string);
-}
-
-void MIPSAssembler::label(const char* theLabel)
-{
-    mLabels.add(theLabel, pc());
-    mLabelsInverseMapping.add(pc(), theLabel);
-}
-
-
-void MIPSAssembler::prolog()
-{
-    // empty - done in ArmToMipsAssembler
-}
-
-void MIPSAssembler::epilog(uint32_t touched __unused)
-{
-    // empty - done in ArmToMipsAssembler
-}
-
-int MIPSAssembler::generate(const char* name)
-{
-    // fixup all the branches
-    size_t count = mBranchTargets.size();
-    while (count--) {
-        const branch_target_t& bt = mBranchTargets[count];
-        uint32_t* target_pc = mLabels.valueFor(bt.label);
-        LOG_ALWAYS_FATAL_IF(!target_pc,
-                "error resolving branch targets, target_pc is null");
-        int32_t offset = int32_t(target_pc - (bt.pc+1));
-        *bt.pc |= offset & 0x00FFFF;
-    }
-
-    mAssembly->resize( int(pc()-base())*4 );
-
-    // the instruction & data caches are flushed by CodeCache
-    const int64_t duration = ggl_system_time() - mDuration;
-    const char * const format = "generated %s (%d ins) at [%p:%p] in %" PRId64 " ns\n";
-    ALOGI(format, name, int(pc()-base()), base(), pc(), duration);
-
-    char value[PROPERTY_VALUE_MAX];
-    value[0] = '\0';
-
-    property_get("debug.pf.disasm", value, "0");
-
-    if (atoi(value) != 0) {
-        disassemble(name);
-    }
-
-    return OK;
-}
-
-uint32_t* MIPSAssembler::pcForLabel(const char* label)
-{
-    return mLabels.valueFor(label);
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Arithmetic...
-#endif
-
-void MIPSAssembler::ADDU(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (addu_fn<<FUNC_SHF)
-                    | (Rs<<RS_SHF) | (Rt<<RT_SHF) | (Rd<<RD_SHF);
-}
-
-// MD00086 pdf says this is: ADDIU rt, rs, imm -- they do not use Rd
-void MIPSAssembler::ADDIU(int Rt, int Rs, int16_t imm)
-{
-    *mPC++ = (addiu_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | (imm & MSK_16);
-}
-
-
-void MIPSAssembler::SUBU(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (subu_fn<<FUNC_SHF) |
-                        (Rs<<RS_SHF) | (Rt<<RT_SHF) | (Rd<<RD_SHF) ;
-}
-
-
-void MIPSAssembler::SUBIU(int Rt, int Rs, int16_t imm)   // really addiu(d, s, -j)
-{
-    *mPC++ = (addiu_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | ((-imm) & MSK_16);
-}
-
-
-void MIPSAssembler::NEGU(int Rd, int Rs)    // really subu(d, zero, s)
-{
-    MIPSAssembler::SUBU(Rd, 0, Rs);
-}
-
-void MIPSAssembler::MUL(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec2_op<<OP_SHF) | (mul_fn<<FUNC_SHF) |
-                        (Rs<<RS_SHF) | (Rt<<RT_SHF) | (Rd<<RD_SHF) ;
-}
-
-void MIPSAssembler::MULT(int Rs, int Rt)    // dest is hi,lo
-{
-    *mPC++ = (spec_op<<OP_SHF) | (mult_fn<<FUNC_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF);
-}
-
-void MIPSAssembler::MULTU(int Rs, int Rt)    // dest is hi,lo
-{
-    *mPC++ = (spec_op<<OP_SHF) | (multu_fn<<FUNC_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF);
-}
-
-void MIPSAssembler::MADD(int Rs, int Rt)    // hi,lo = hi,lo + Rs * Rt
-{
-    *mPC++ = (spec2_op<<OP_SHF) | (madd_fn<<FUNC_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF);
-}
-
-void MIPSAssembler::MADDU(int Rs, int Rt)    // hi,lo = hi,lo + Rs * Rt
-{
-    *mPC++ = (spec2_op<<OP_SHF) | (maddu_fn<<FUNC_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF);
-}
-
-
-void MIPSAssembler::MSUB(int Rs, int Rt)    // hi,lo = hi,lo - Rs * Rt
-{
-    *mPC++ = (spec2_op<<OP_SHF) | (msub_fn<<FUNC_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF);
-}
-
-void MIPSAssembler::MSUBU(int Rs, int Rt)    // hi,lo = hi,lo - Rs * Rt
-{
-    *mPC++ = (spec2_op<<OP_SHF) | (msubu_fn<<FUNC_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF);
-}
-
-
-void MIPSAssembler::SEB(int Rd, int Rt)    // sign-extend byte (mips32r2)
-{
-    *mPC++ = (spec3_op<<OP_SHF) | (bshfl_fn<<FUNC_SHF) | (seb_fn << SA_SHF) |
-                    (Rt<<RT_SHF) | (Rd<<RD_SHF);
-}
-
-void MIPSAssembler::SEH(int Rd, int Rt)    // sign-extend half-word (mips32r2)
-{
-    *mPC++ = (spec3_op<<OP_SHF) | (bshfl_fn<<FUNC_SHF) | (seh_fn << SA_SHF) |
-                    (Rt<<RT_SHF) | (Rd<<RD_SHF);
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Comparisons...
-#endif
-
-void MIPSAssembler::SLT(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (slt_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::SLTI(int Rt, int Rs, int16_t imm)
-{
-    *mPC++ = (slti_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | (imm & MSK_16);
-}
-
-
-void MIPSAssembler::SLTU(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (sltu_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::SLTIU(int Rt, int Rs, int16_t imm)
-{
-    *mPC++ = (sltiu_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | (imm & MSK_16);
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Logical...
-#endif
-
-void MIPSAssembler::AND(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (and_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::ANDI(int Rt, int Rs, uint16_t imm)      // todo: support larger immediate
-{
-    *mPC++ = (andi_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | (imm & MSK_16);
-}
-
-
-void MIPSAssembler::OR(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (or_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::ORI(int Rt, int Rs, uint16_t imm)
-{
-    *mPC++ = (ori_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | (imm & MSK_16);
-}
-
-void MIPSAssembler::NOR(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (nor_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::NOT(int Rd, int Rs)
-{
-    MIPSAssembler::NOR(Rd, Rs, 0);  // NOT(d,s) = NOR(d,s,zero)
-}
-
-void MIPSAssembler::XOR(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (xor_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::XORI(int Rt, int Rs, uint16_t imm)  // todo: support larger immediate
-{
-    *mPC++ = (xori_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | (imm & MSK_16);
-}
-
-void MIPSAssembler::SLL(int Rd, int Rt, int shft)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (sll_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rt<<RT_SHF) | (shft<<RE_SHF);
-}
-
-void MIPSAssembler::SLLV(int Rd, int Rt, int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (sllv_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::SRL(int Rd, int Rt, int shft)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (srl_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rt<<RT_SHF) | (shft<<RE_SHF);
-}
-
-void MIPSAssembler::SRLV(int Rd, int Rt, int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (srlv_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::SRA(int Rd, int Rt, int shft)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (sra_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rt<<RT_SHF) | (shft<<RE_SHF);
-}
-
-void MIPSAssembler::SRAV(int Rd, int Rt, int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (srav_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::ROTR(int Rd, int Rt, int shft)      // mips32r2
-{
-    // note weird encoding (SRL + 1)
-    *mPC++ = (spec_op<<OP_SHF) | (srl_fn<<FUNC_SHF) |
-                        (1<<RS_SHF) | (Rd<<RD_SHF) | (Rt<<RT_SHF) | (shft<<RE_SHF);
-}
-
-void MIPSAssembler::ROTRV(int Rd, int Rt, int Rs)       // mips32r2
-{
-    // note weird encoding (SRLV + 1)
-    *mPC++ = (spec_op<<OP_SHF) | (srlv_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF) | (1<<RE_SHF);
-}
-
-// uses at2 register (mapped to some appropriate mips reg)
-void MIPSAssembler::RORsyn(int Rd, int Rt, int Rs)
-{
-    // synthetic: d = t rotated by s
-    MIPSAssembler::NEGU(R_at2, Rs);
-    MIPSAssembler::SLLV(R_at2, Rt, R_at2);
-    MIPSAssembler::SRLV(Rd, Rt, Rs);
-    MIPSAssembler::OR(Rd, Rd, R_at2);
-}
-
-// immediate version - uses at2 register (mapped to some appropriate mips reg)
-void MIPSAssembler::RORIsyn(int Rd, int Rt, int rot)
-{
-    // synthetic: d = t rotated by immed rot
-    // d = s >> rot | s << (32-rot)
-    MIPSAssembler::SLL(R_at2, Rt, 32-rot);
-    MIPSAssembler::SRL(Rd, Rt, rot);
-    MIPSAssembler::OR(Rd, Rd, R_at2);
-}
-
-void MIPSAssembler::CLO(int Rd, int Rs)
-{
-    // Rt field must have same gpr # as Rd
-    *mPC++ = (spec2_op<<OP_SHF) | (clo_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rd<<RT_SHF);
-}
-
-void MIPSAssembler::CLZ(int Rd, int Rs)
-{
-    // Rt field must have same gpr # as Rd
-    *mPC++ = (spec2_op<<OP_SHF) | (clz_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rd<<RT_SHF);
-}
-
-void MIPSAssembler::WSBH(int Rd, int Rt)      // mips32r2
-{
-    *mPC++ = (spec3_op<<OP_SHF) | (bshfl_fn<<FUNC_SHF) | (wsbh_fn << SA_SHF) |
-                        (Rt<<RT_SHF) | (Rd<<RD_SHF);
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Load/store...
-#endif
-
-void MIPSAssembler::LW(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (lw_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPSAssembler::SW(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (sw_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-// lb is sign-extended
-void MIPSAssembler::LB(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (lb_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPSAssembler::LBU(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (lbu_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPSAssembler::SB(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (sb_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-// lh is sign-extended
-void MIPSAssembler::LH(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (lh_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPSAssembler::LHU(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (lhu_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPSAssembler::SH(int Rt, int Rbase, int16_t offset)
-{
-    *mPC++ = (sh_op<<OP_SHF) | (Rbase<<RS_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-void MIPSAssembler::LUI(int Rt, int16_t offset)
-{
-    *mPC++ = (lui_op<<OP_SHF) | (Rt<<RT_SHF) | (offset & MSK_16);
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Register move...
-#endif
-
-void MIPSAssembler::MOVE(int Rd, int Rs)
-{
-    // encoded as "or rd, rs, zero"
-    *mPC++ = (spec_op<<OP_SHF) | (or_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (0<<RT_SHF);
-}
-
-void MIPSAssembler::MOVN(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (movn_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::MOVZ(int Rd, int Rs, int Rt)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (movz_fn<<FUNC_SHF) |
-                        (Rd<<RD_SHF) | (Rs<<RS_SHF) | (Rt<<RT_SHF);
-}
-
-void MIPSAssembler::MFHI(int Rd)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (mfhi_fn<<FUNC_SHF) | (Rd<<RD_SHF);
-}
-
-void MIPSAssembler::MFLO(int Rd)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (mflo_fn<<FUNC_SHF) | (Rd<<RD_SHF);
-}
-
-void MIPSAssembler::MTHI(int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (mthi_fn<<FUNC_SHF) | (Rs<<RS_SHF);
-}
-
-void MIPSAssembler::MTLO(int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (mtlo_fn<<FUNC_SHF) | (Rs<<RS_SHF);
-}
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Branch...
-#endif
-
-// temporarily forcing a NOP into branch-delay slot, just to be safe
-// todo: remove NOP, optimze use of delay slots
-void MIPSAssembler::B(const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-
-    // encoded as BEQ zero, zero, offset
-    *mPC++ = (beq_op<<OP_SHF) | (0<<RT_SHF)
-                        | (0<<RS_SHF) | 0;  // offset filled in later
-
-    MIPSAssembler::NOP();
-}
-
-void MIPSAssembler::BEQ(int Rs, int Rt, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (beq_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | 0;
-    MIPSAssembler::NOP();
-}
-
-void MIPSAssembler::BNE(int Rs, int Rt, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (bne_op<<OP_SHF) | (Rt<<RT_SHF) | (Rs<<RS_SHF) | 0;
-    MIPSAssembler::NOP();
-}
-
-void MIPSAssembler::BLEZ(int Rs, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (blez_op<<OP_SHF) | (0<<RT_SHF) | (Rs<<RS_SHF) | 0;
-    MIPSAssembler::NOP();
-}
-
-void MIPSAssembler::BLTZ(int Rs, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (regimm_op<<OP_SHF) | (bltz_fn<<RT_SHF) | (Rs<<RS_SHF) | 0;
-    MIPSAssembler::NOP();
-}
-
-void MIPSAssembler::BGTZ(int Rs, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (bgtz_op<<OP_SHF) | (0<<RT_SHF) | (Rs<<RS_SHF) | 0;
-    MIPSAssembler::NOP();
-}
-
-
-void MIPSAssembler::BGEZ(int Rs, const char* label)
-{
-    mBranchTargets.add(branch_target_t(label, mPC));
-    *mPC++ = (regimm_op<<OP_SHF) | (bgez_fn<<RT_SHF) | (Rs<<RS_SHF) | 0;
-    MIPSAssembler::NOP();
-}
-
-void MIPSAssembler::JR(int Rs)
-{
-    *mPC++ = (spec_op<<OP_SHF) | (Rs<<RS_SHF) | (jr_fn << FUNC_SHF);
-    MIPSAssembler::NOP();
-}
-
-
-#if 0
-#pragma mark -
-#pragma mark Synthesized Branch...
-#endif
-
-// synthetic variants of branches (using slt & friends)
-void MIPSAssembler::BEQZ(int Rs, const char* label)
-{
-    BEQ(Rs, R_zero, label);
-}
-
-void MIPSAssembler::BNEZ(int Rs __unused, const char* label)
-{
-    BNE(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BGE(int Rs, int Rt, const char* label)
-{
-    SLT(R_at, Rs, Rt);
-    BEQ(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BGEU(int Rs, int Rt, const char* label)
-{
-    SLTU(R_at, Rs, Rt);
-    BEQ(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BGT(int Rs, int Rt, const char* label)
-{
-    SLT(R_at, Rt, Rs);   // rev
-    BNE(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BGTU(int Rs, int Rt, const char* label)
-{
-    SLTU(R_at, Rt, Rs);   // rev
-    BNE(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BLE(int Rs, int Rt, const char* label)
-{
-    SLT(R_at, Rt, Rs);   // rev
-    BEQ(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BLEU(int Rs, int Rt, const char* label)
-{
-    SLTU(R_at, Rt, Rs);  // rev
-    BEQ(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BLT(int Rs, int Rt, const char* label)
-{
-    SLT(R_at, Rs, Rt);
-    BNE(R_at, R_zero, label);
-}
-
-void MIPSAssembler::BLTU(int Rs, int Rt, const char* label)
-{
-    SLTU(R_at, Rs, Rt);
-    BNE(R_at, R_zero, label);
-}
-
-
-
-
-#if 0
-#pragma mark -
-#pragma mark Misc...
-#endif
-
-void MIPSAssembler::NOP(void)
-{
-    // encoded as "sll zero, zero, 0", which is all zero
-    *mPC++ = (spec_op<<OP_SHF) | (sll_fn<<FUNC_SHF);
-}
-
-// using this as special opcode for not-yet-implemented ARM instruction
-void MIPSAssembler::NOP2(void)
-{
-    // encoded as "sll zero, zero, 2", still a nop, but a unique code
-    *mPC++ = (spec_op<<OP_SHF) | (sll_fn<<FUNC_SHF) | (2 << RE_SHF);
-}
-
-// using this as special opcode for purposefully NOT implemented ARM instruction
-void MIPSAssembler::UNIMPL(void)
-{
-    // encoded as "sll zero, zero, 3", still a nop, but a unique code
-    *mPC++ = (spec_op<<OP_SHF) | (sll_fn<<FUNC_SHF) | (3 << RE_SHF);
-}
-
-
-}; // namespace android:
diff --git a/libpixelflinger/codeflinger/MIPSAssembler.h b/libpixelflinger/codeflinger/MIPSAssembler.h
deleted file mode 100644
index c1178b6..0000000
--- a/libpixelflinger/codeflinger/MIPSAssembler.h
+++ /dev/null
@@ -1,557 +0,0 @@
-/* libs/pixelflinger/codeflinger/MIPSAssembler.h
-**
-** Copyright 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.
-*/
-
-#ifndef ANDROID_MIPSASSEMBLER_H
-#define ANDROID_MIPSASSEMBLER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "tinyutils/smartpointer.h"
-#include "utils/KeyedVector.h"
-#include "utils/Vector.h"
-
-#include "ARMAssemblerInterface.h"
-#include "CodeCache.h"
-
-namespace android {
-
-class MIPSAssembler;    // forward reference
-
-// this class mimics ARMAssembler interface
-//  intent is to translate each ARM instruction to 1 or more MIPS instr
-//  implementation calls MIPSAssembler class to generate mips code
-class ArmToMipsAssembler : public ARMAssemblerInterface
-{
-public:
-                ArmToMipsAssembler(const sp<Assembly>& assembly,
-                        char *abuf = 0, int linesz = 0, int instr_count = 0);
-    virtual     ~ArmToMipsAssembler();
-
-    uint32_t*   base() const;
-    uint32_t*   pc() const;
-    void        disassemble(const char* name);
-
-    virtual void    reset();
-
-    virtual int     generate(const char* name);
-    virtual int     getCodegenArch();
-
-    virtual void    prolog();
-    virtual void    epilog(uint32_t touched);
-    virtual void    comment(const char* string);
-
-
-    // -----------------------------------------------------------------------
-    // shifters and addressing modes
-    // -----------------------------------------------------------------------
-
-    // shifters...
-    virtual bool        isValidImmediate(uint32_t immed);
-    virtual int         buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
-
-    virtual uint32_t    imm(uint32_t immediate);
-    virtual uint32_t    reg_imm(int Rm, int type, uint32_t shift);
-    virtual uint32_t    reg_rrx(int Rm);
-    virtual uint32_t    reg_reg(int Rm, int type, int Rs);
-
-    // addressing modes...
-    // LDR(B)/STR(B)/PLD
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed12_pre(int32_t immed12, int W=0);
-    virtual uint32_t    immed12_post(int32_t immed12);
-    virtual uint32_t    reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
-    virtual uint32_t    reg_scale_post(int Rm, int type=0, uint32_t shift=0);
-
-    // LDRH/LDRSB/LDRSH/STRH
-    // (immediate and Rm can be negative, which indicates U=0)
-    virtual uint32_t    immed8_pre(int32_t immed8, int W=0);
-    virtual uint32_t    immed8_post(int32_t immed8);
-    virtual uint32_t    reg_pre(int Rm, int W=0);
-    virtual uint32_t    reg_post(int Rm);
-
-
-
-
-    virtual void    dataProcessing(int opcode, int cc, int s,
-                                int Rd, int Rn,
-                                uint32_t Op2);
-    virtual void MLA(int cc, int s,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void MUL(int cc, int s,
-                int Rd, int Rm, int Rs);
-    virtual void UMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void UMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMULL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-    virtual void SMUAL(int cc, int s,
-                int RdLo, int RdHi, int Rm, int Rs);
-
-    virtual void B(int cc, uint32_t* pc);
-    virtual void BL(int cc, uint32_t* pc);
-    virtual void BX(int cc, int Rn);
-    virtual void label(const char* theLabel);
-    virtual void B(int cc, const char* label);
-    virtual void BL(int cc, const char* label);
-
-    virtual uint32_t* pcForLabel(const char* label);
-
-    virtual void LDR (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STR (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STRB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRH (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRSB(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void LDRSH(int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-    virtual void STRH (int cc, int Rd,
-                int Rn, uint32_t offset = 0);
-
-    virtual void LDM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-    virtual void STM(int cc, int dir,
-                int Rn, int W, uint32_t reg_list);
-
-    virtual void SWP(int cc, int Rn, int Rd, int Rm);
-    virtual void SWPB(int cc, int Rn, int Rd, int Rm);
-    virtual void SWI(int cc, uint32_t comment);
-
-    virtual void PLD(int Rn, uint32_t offset);
-    virtual void CLZ(int cc, int Rd, int Rm);
-    virtual void QADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QDADD(int cc, int Rd, int Rm, int Rn);
-    virtual void QSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
-    virtual void SMUL(int cc, int xy,
-                int Rd, int Rm, int Rs);
-    virtual void SMULW(int cc, int y,
-                int Rd, int Rm, int Rs);
-    virtual void SMLA(int cc, int xy,
-                int Rd, int Rm, int Rs, int Rn);
-    virtual void SMLAL(int cc, int xy,
-                int RdHi, int RdLo, int Rs, int Rm);
-    virtual void SMLAW(int cc, int y,
-                int Rd, int Rm, int Rs, int Rn);
-
-    // byte/half word extract...
-    virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
-
-    // bit manipulation...
-    virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
-
-    // this is some crap to share is MIPSAssembler class for debug
-    char *      mArmDisassemblyBuffer;
-    int         mArmLineLength;
-    int         mArmInstrCount;
-
-    int         mInum;      // current arm instuction number (0..n)
-    uint32_t**  mArmPC;     // array: PC for 1st mips instr of
-                            //      each translated ARM instr
-
-
-private:
-    ArmToMipsAssembler(const ArmToMipsAssembler& rhs);
-    ArmToMipsAssembler& operator = (const ArmToMipsAssembler& rhs);
-
-    void init_conditional_labels(void);
-
-    void protectConditionalOperands(int Rd);
-
-    // reg__tmp set to MIPS AT, reg 1
-    int dataProcAdrModes(int op, int& source, bool sign = false, int reg_tmp = 1);
-
-    sp<Assembly>        mAssembly;
-    MIPSAssembler*      mMips;
-
-
-    enum misc_constants_t {
-        ARM_MAX_INSTUCTIONS = 512  // based on ASSEMBLY_SCRATCH_SIZE
-    };
-
-    enum {
-        SRC_REG = 0,
-        SRC_IMM,
-        SRC_ERROR = -1
-    };
-
-    enum addr_modes {
-        // start above the range of legal mips reg #'s (0-31)
-        AMODE_REG = 0x20,
-        AMODE_IMM, AMODE_REG_IMM,               // for data processing
-        AMODE_IMM_12_PRE, AMODE_IMM_12_POST,    // for load/store
-        AMODE_REG_SCALE_PRE, AMODE_IMM_8_PRE,
-        AMODE_IMM_8_POST, AMODE_REG_PRE,
-        AMODE_UNSUPPORTED
-    };
-
-    struct addr_mode_t {    // address modes for current ARM instruction
-        int         reg;
-        int         stype;
-        uint32_t    value;
-        bool        writeback;  // writeback the adr reg after modification
-    } amode;
-
-    enum cond_types {
-        CMP_COND = 1,
-        SBIT_COND
-    };
-
-    struct cond_mode_t {    // conditional-execution info for current ARM instruction
-        cond_types  type;
-        int         r1;
-        int         r2;
-        int         labelnum;
-        char        label[100][10];
-    } cond;
-
-};
-
-
-
-
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-
-// This is the basic MIPS assembler, which just creates the opcodes in memory.
-// All the more complicated work is done in ArmToMipsAssember above.
-
-class MIPSAssembler
-{
-public:
-                MIPSAssembler(const sp<Assembly>& assembly, ArmToMipsAssembler *parent);
-                MIPSAssembler(void* assembly);
-    virtual     ~MIPSAssembler();
-
-    virtual uint32_t*   base() const;
-    virtual uint32_t*   pc() const;
-    virtual void        reset();
-
-    virtual void        disassemble(const char* name);
-
-    virtual void        prolog();
-    virtual void        epilog(uint32_t touched);
-    virtual int         generate(const char* name);
-    virtual void        comment(const char* string);
-    virtual void        label(const char* string);
-
-    // valid only after generate() has been called
-    virtual uint32_t*   pcForLabel(const char* label);
-
-
-    // ------------------------------------------------------------------------
-    // MIPSAssemblerInterface...
-    // ------------------------------------------------------------------------
-
-#if 0
-#pragma mark -
-#pragma mark Arithmetic...
-#endif
-
-    void ADDU(int Rd, int Rs, int Rt);
-    void ADDIU(int Rt, int Rs, int16_t imm);
-    void SUBU(int Rd, int Rs, int Rt);
-    void SUBIU(int Rt, int Rs, int16_t imm);
-    void NEGU(int Rd, int Rs);
-    void MUL(int Rd, int Rs, int Rt);
-    void MULT(int Rs, int Rt);      // dest is hi,lo
-    void MULTU(int Rs, int Rt);     // dest is hi,lo
-    void MADD(int Rs, int Rt);      // hi,lo = hi,lo + Rs * Rt
-    void MADDU(int Rs, int Rt);     // hi,lo = hi,lo + Rs * Rt
-    void MSUB(int Rs, int Rt);      // hi,lo = hi,lo - Rs * Rt
-    void MSUBU(int Rs, int Rt);     // hi,lo = hi,lo - Rs * Rt
-    void SEB(int Rd, int Rt);       // sign-extend byte (mips32r2)
-    void SEH(int Rd, int Rt);       // sign-extend half-word (mips32r2)
-
-
-#if 0
-#pragma mark -
-#pragma mark Comparisons...
-#endif
-
-    void SLT(int Rd, int Rs, int Rt);
-    void SLTI(int Rt, int Rs, int16_t imm);
-    void SLTU(int Rd, int Rs, int Rt);
-    void SLTIU(int Rt, int Rs, int16_t imm);
-
-
-#if 0
-#pragma mark -
-#pragma mark Logical...
-#endif
-
-    void AND(int Rd, int Rs, int Rt);
-    void ANDI(int Rd, int Rs, uint16_t imm);
-    void OR(int Rd, int Rs, int Rt);
-    void ORI(int Rt, int Rs, uint16_t imm);
-    void NOR(int Rd, int Rs, int Rt);
-    void NOT(int Rd, int Rs);
-    void XOR(int Rd, int Rs, int Rt);
-    void XORI(int Rt, int Rs, uint16_t imm);
-
-    void SLL(int Rd, int Rt, int shft);
-    void SLLV(int Rd, int Rt, int Rs);
-    void SRL(int Rd, int Rt, int shft);
-    void SRLV(int Rd, int Rt, int Rs);
-    void SRA(int Rd, int Rt, int shft);
-    void SRAV(int Rd, int Rt, int Rs);
-    void ROTR(int Rd, int Rt, int shft);    // mips32r2
-    void ROTRV(int Rd, int Rt, int Rs);     // mips32r2
-    void RORsyn(int Rd, int Rs, int Rt);    // synthetic: d = s rotated by t
-    void RORIsyn(int Rd, int Rt, int rot);  // synthetic: d = s rotated by immed
-
-    void CLO(int Rd, int Rs);
-    void CLZ(int Rd, int Rs);
-    void WSBH(int Rd, int Rt);
-
-
-#if 0
-#pragma mark -
-#pragma mark Load/store...
-#endif
-
-    void LW(int Rt, int Rbase, int16_t offset);
-    void SW(int Rt, int Rbase, int16_t offset);
-    void LB(int Rt, int Rbase, int16_t offset);
-    void LBU(int Rt, int Rbase, int16_t offset);
-    void SB(int Rt, int Rbase, int16_t offset);
-    void LH(int Rt, int Rbase, int16_t offset);
-    void LHU(int Rt, int Rbase, int16_t offset);
-    void SH(int Rt, int Rbase, int16_t offset);
-    void LUI(int Rt, int16_t offset);
-
-#if 0
-#pragma mark -
-#pragma mark Register moves...
-#endif
-
-    void MOVE(int Rd, int Rs);
-    void MOVN(int Rd, int Rs, int Rt);
-    void MOVZ(int Rd, int Rs, int Rt);
-    void MFHI(int Rd);
-    void MFLO(int Rd);
-    void MTHI(int Rs);
-    void MTLO(int Rs);
-
-#if 0
-#pragma mark -
-#pragma mark Branch...
-#endif
-
-    void B(const char* label);
-    void BEQ(int Rs, int Rt, const char* label);
-    void BNE(int Rs, int Rt, const char* label);
-    void BGEZ(int Rs, const char* label);
-    void BGTZ(int Rs, const char* label);
-    void BLEZ(int Rs, const char* label);
-    void BLTZ(int Rs, const char* label);
-    void JR(int Rs);
-
-
-#if 0
-#pragma mark -
-#pragma mark Synthesized Branch...
-#endif
-
-    // synthetic variants of above (using slt & friends)
-    void BEQZ(int Rs, const char* label);
-    void BNEZ(int Rs, const char* label);
-    void BGE(int Rs, int Rt, const char* label);
-    void BGEU(int Rs, int Rt, const char* label);
-    void BGT(int Rs, int Rt, const char* label);
-    void BGTU(int Rs, int Rt, const char* label);
-    void BLE(int Rs, int Rt, const char* label);
-    void BLEU(int Rs, int Rt, const char* label);
-    void BLT(int Rs, int Rt, const char* label);
-    void BLTU(int Rs, int Rt, const char* label);
-
-#if 0
-#pragma mark -
-#pragma mark Misc...
-#endif
-
-    void NOP(void);
-    void NOP2(void);
-    void UNIMPL(void);
-
-
-
-
-
-protected:
-    virtual void string_detab(char *s);
-    virtual void string_pad(char *s, int padded_len);
-
-    ArmToMipsAssembler *mParent;
-    sp<Assembly>    mAssembly;
-    uint32_t*       mBase;
-    uint32_t*       mPC;
-    uint32_t*       mPrologPC;
-    int64_t         mDuration;
-
-    struct branch_target_t {
-        inline branch_target_t() : label(0), pc(0) { }
-        inline branch_target_t(const char* l, uint32_t* p)
-            : label(l), pc(p) { }
-        const char* label;
-        uint32_t*   pc;
-    };
-
-    Vector<branch_target_t>                 mBranchTargets;
-    KeyedVector< const char*, uint32_t* >   mLabels;
-    KeyedVector< uint32_t*, const char* >   mLabelsInverseMapping;
-    KeyedVector< uint32_t*, const char* >   mComments;
-
-
-
-
-    // opcode field of all instructions
-    enum opcode_field {
-        spec_op, regimm_op, j_op, jal_op,           // 00
-        beq_op, bne_op, blez_op, bgtz_op,
-        addi_op, addiu_op, slti_op, sltiu_op,       // 08
-        andi_op, ori_op, xori_op, lui_op,
-        cop0_op, cop1_op, cop2_op, cop1x_op,        // 10
-        beql_op, bnel_op, blezl_op, bgtzl_op,
-        daddi_op, daddiu_op, ldl_op, ldr_op,        // 18
-        spec2_op, jalx_op, mdmx_op, spec3_op,
-        lb_op, lh_op, lwl_op, lw_op,                // 20
-        lbu_op, lhu_op, lwr_op, lwu_op,
-        sb_op, sh_op, swl_op, sw_op,                // 28
-        sdl_op, sdr_op, swr_op, cache_op,
-        ll_op, lwc1_op, lwc2_op, pref_op,           // 30
-        lld_op, ldc1_op, ldc2_op, ld_op,
-        sc_op, swc1_op, swc2_op, rsrv_3b_op,        // 38
-        scd_op, sdc1_op, sdc2_op, sd_op
-    };
-
-
-    // func field for special opcode
-    enum func_spec_op {
-        sll_fn, movc_fn, srl_fn, sra_fn,            // 00
-        sllv_fn, pmon_fn, srlv_fn, srav_fn,
-        jr_fn, jalr_fn, movz_fn, movn_fn,           // 08
-        syscall_fn, break_fn, spim_fn, sync_fn,
-        mfhi_fn, mthi_fn, mflo_fn, mtlo_fn,         // 10
-        dsllv_fn, rsrv_spec_2, dsrlv_fn, dsrav_fn,
-        mult_fn, multu_fn, div_fn, divu_fn,         // 18
-        dmult_fn, dmultu_fn, ddiv_fn, ddivu_fn,
-        add_fn, addu_fn, sub_fn, subu_fn,           // 20
-        and_fn, or_fn, xor_fn, nor_fn,
-        rsrv_spec_3, rsrv_spec_4, slt_fn, sltu_fn,  // 28
-        dadd_fn, daddu_fn, dsub_fn, dsubu_fn,
-        tge_fn, tgeu_fn, tlt_fn, tltu_fn,           // 30
-        teq_fn, rsrv_spec_5, tne_fn, rsrv_spec_6,
-        dsll_fn, rsrv_spec_7, dsrl_fn, dsra_fn,     // 38
-        dsll32_fn, rsrv_spec_8, dsrl32_fn, dsra32_fn
-    };
-
-    // func field for spec2 opcode
-    enum func_spec2_op {
-        madd_fn, maddu_fn, mul_fn, rsrv_spec2_3,
-        msub_fn, msubu_fn,
-        clz_fn = 0x20, clo_fn,
-        dclz_fn = 0x24, dclo_fn,
-        sdbbp_fn = 0x3f
-    };
-
-    // func field for spec3 opcode
-    enum func_spec3_op {
-        ext_fn, dextm_fn, dextu_fn, dext_fn,
-        ins_fn, dinsm_fn, dinsu_fn, dins_fn,
-        bshfl_fn = 0x20,
-        dbshfl_fn = 0x24,
-        rdhwr_fn = 0x3b
-    };
-
-    // sa field for spec3 opcodes, with BSHFL function
-    enum func_spec3_bshfl {
-        wsbh_fn = 0x02,
-        seb_fn = 0x10,
-        seh_fn = 0x18
-    };
-
-    // rt field of regimm opcodes.
-    enum regimm_fn {
-        bltz_fn, bgez_fn, bltzl_fn, bgezl_fn,
-        rsrv_ri_fn4, rsrv_ri_fn5, rsrv_ri_fn6, rsrv_ri_fn7,
-        tgei_fn, tgeiu_fn, tlti_fn, tltiu_fn,
-        teqi_fn, rsrv_ri_fn_0d, tnei_fn, rsrv_ri_fn0f,
-        bltzal_fn, bgezal_fn, bltzall_fn, bgezall_fn,
-        bposge32_fn= 0x1c,
-        synci_fn = 0x1f
-    };
-
-
-    // func field for mad opcodes (MIPS IV).
-    enum mad_func {
-        madd_fp_op      = 0x08, msub_fp_op      = 0x0a,
-        nmadd_fp_op     = 0x0c, nmsub_fp_op     = 0x0e
-    };
-
-
-    enum mips_inst_shifts {
-        OP_SHF       = 26,
-        JTARGET_SHF  = 0,
-        RS_SHF       = 21,
-        RT_SHF       = 16,
-        RD_SHF       = 11,
-        RE_SHF       = 6,
-        SA_SHF       = RE_SHF,  // synonym
-        IMM_SHF      = 0,
-        FUNC_SHF     = 0,
-
-        // mask values
-        MSK_16       = 0xffff,
-
-
-        CACHEOP_SHF  = 18,
-        CACHESEL_SHF = 16,
-    };
-};
-
-enum mips_regnames {
-    R_zero = 0,
-            R_at,   R_v0,   R_v1,   R_a0,   R_a1,   R_a2,   R_a3,
-#if __mips_isa_rev < 6
-    R_t0,   R_t1,   R_t2,   R_t3,   R_t4,   R_t5,   R_t6,   R_t7,
-#else
-    R_a4,   R_a5,   R_a6,   R_a7,   R_t0,   R_t1,   R_t2,   R_t3,
-#endif
-    R_s0,   R_s1,   R_s2,   R_s3,   R_s4,   R_s5,   R_s6,   R_s7,
-    R_t8,   R_t9,   R_k0,   R_k1,   R_gp,   R_sp,   R_s8,   R_ra,
-    R_lr = R_s8,
-
-    // arm regs 0-15 are mips regs 2-17 (meaning s0 & s1 are used)
-    R_at2  = R_s2,    // R_at2 = 18 = s2
-    R_cmp  = R_s3,    // R_cmp = 19 = s3
-    R_cmp2 = R_s4     // R_cmp2 = 20 = s4
-};
-
-
-
-}; // namespace android
-
-#endif //ANDROID_MIPSASSEMBLER_H
diff --git a/libpixelflinger/codeflinger/armreg.h b/libpixelflinger/codeflinger/armreg.h
deleted file mode 100644
index fde81ba..0000000
--- a/libpixelflinger/codeflinger/armreg.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/*	$NetBSD: armreg.h,v 1.28 2003/10/31 16:30:15 scw Exp $	*/
-
-/*-
- * Copyright (c) 1998, 2001 Ben Harris
- * Copyright (c) 1994-1996 Mark Brinicombe.
- * Copyright (c) 1994 Brini.
- * All rights reserved.
- *
- * This code is derived from software written for Brini by Mark Brinicombe
- *
- * 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 Brini.
- * 4. The name of the company nor the name of the author may be used to
- *    endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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: /repoman/r/ncvs/src/sys/arm/include/armreg.h,v 1.3 2005/11/21 19:06:25 cognet Exp $
- */
-
-#ifndef MACHINE_ARMREG_H
-#define MACHINE_ARMREG_H
-#define INSN_SIZE	4
-#define INSN_COND_MASK	0xf0000000	/* Condition mask */
-#define PSR_MODE        0x0000001f      /* mode mask */
-#define PSR_USR26_MODE  0x00000000
-#define PSR_FIQ26_MODE  0x00000001
-#define PSR_IRQ26_MODE  0x00000002
-#define PSR_SVC26_MODE  0x00000003
-#define PSR_USR32_MODE  0x00000010
-#define PSR_FIQ32_MODE  0x00000011
-#define PSR_IRQ32_MODE  0x00000012
-#define PSR_SVC32_MODE  0x00000013
-#define PSR_ABT32_MODE  0x00000017
-#define PSR_UND32_MODE  0x0000001b
-#define PSR_SYS32_MODE  0x0000001f
-#define PSR_32_MODE     0x00000010
-#define PSR_FLAGS	0xf0000000    /* flags */
-
-#define PSR_C_bit (1 << 29)       /* carry */
-
-/* The high-order byte is always the implementor */
-#define CPU_ID_IMPLEMENTOR_MASK	0xff000000
-#define CPU_ID_ARM_LTD		0x41000000 /* 'A' */
-#define CPU_ID_DEC		0x44000000 /* 'D' */
-#define CPU_ID_INTEL		0x69000000 /* 'i' */
-#define	CPU_ID_TI		0x54000000 /* 'T' */
-
-/* How to decide what format the CPUID is in. */
-#define CPU_ID_ISOLD(x)		(((x) & 0x0000f000) == 0x00000000)
-#define CPU_ID_IS7(x)		(((x) & 0x0000f000) == 0x00007000)
-#define CPU_ID_ISNEW(x)		(!CPU_ID_ISOLD(x) && !CPU_ID_IS7(x))
-
-/* On ARM3 and ARM6, this byte holds the foundry ID. */
-#define CPU_ID_FOUNDRY_MASK	0x00ff0000
-#define CPU_ID_FOUNDRY_VLSI	0x00560000
-
-/* On ARM7 it holds the architecture and variant (sub-model) */
-#define CPU_ID_7ARCH_MASK	0x00800000
-#define CPU_ID_7ARCH_V3		0x00000000
-#define CPU_ID_7ARCH_V4T	0x00800000
-#define CPU_ID_7VARIANT_MASK	0x007f0000
-
-/* On more recent ARMs, it does the same, but in a different format */
-#define CPU_ID_ARCH_MASK	0x000f0000
-#define CPU_ID_ARCH_V3		0x00000000
-#define CPU_ID_ARCH_V4		0x00010000
-#define CPU_ID_ARCH_V4T		0x00020000
-#define CPU_ID_ARCH_V5		0x00030000
-#define CPU_ID_ARCH_V5T		0x00040000
-#define CPU_ID_ARCH_V5TE	0x00050000
-#define CPU_ID_VARIANT_MASK	0x00f00000
-
-/* Next three nybbles are part number */
-#define CPU_ID_PARTNO_MASK	0x0000fff0
-
-/* Intel XScale has sub fields in part number */
-#define CPU_ID_XSCALE_COREGEN_MASK	0x0000e000 /* core generation */
-#define CPU_ID_XSCALE_COREREV_MASK	0x00001c00 /* core revision */
-#define CPU_ID_XSCALE_PRODUCT_MASK	0x000003f0 /* product number */
-
-/* And finally, the revision number. */
-#define CPU_ID_REVISION_MASK	0x0000000f
-
-/* Individual CPUs are probably best IDed by everything but the revision. */
-#define CPU_ID_CPU_MASK		0xfffffff0
-
-/* Fake CPU IDs for ARMs without CP15 */
-#define CPU_ID_ARM2		0x41560200
-#define CPU_ID_ARM250		0x41560250
-
-/* Pre-ARM7 CPUs -- [15:12] == 0 */
-#define CPU_ID_ARM3		0x41560300
-#define CPU_ID_ARM600		0x41560600
-#define CPU_ID_ARM610		0x41560610
-#define CPU_ID_ARM620		0x41560620
-
-/* ARM7 CPUs -- [15:12] == 7 */
-#define CPU_ID_ARM700		0x41007000 /* XXX This is a guess. */
-#define CPU_ID_ARM710		0x41007100
-#define CPU_ID_ARM7500		0x41027100 /* XXX This is a guess. */
-#define CPU_ID_ARM710A		0x41047100 /* inc ARM7100 */
-#define CPU_ID_ARM7500FE	0x41077100
-#define CPU_ID_ARM710T		0x41807100
-#define CPU_ID_ARM720T		0x41807200
-#define CPU_ID_ARM740T8K	0x41807400 /* XXX no MMU, 8KB cache */
-#define CPU_ID_ARM740T4K	0x41817400 /* XXX no MMU, 4KB cache */
-
-/* Post-ARM7 CPUs */
-#define CPU_ID_ARM810		0x41018100
-#define CPU_ID_ARM920T		0x41129200
-#define CPU_ID_ARM920T_ALT	0x41009200
-#define CPU_ID_ARM922T		0x41029220
-#define CPU_ID_ARM940T		0x41029400 /* XXX no MMU */
-#define CPU_ID_ARM946ES		0x41049460 /* XXX no MMU */
-#define	CPU_ID_ARM966ES		0x41049660 /* XXX no MMU */
-#define	CPU_ID_ARM966ESR1	0x41059660 /* XXX no MMU */
-#define CPU_ID_ARM1020E		0x4115a200 /* (AKA arm10 rev 1) */
-#define CPU_ID_ARM1022ES	0x4105a220
-#define CPU_ID_SA110		0x4401a100
-#define CPU_ID_SA1100		0x4401a110
-#define	CPU_ID_TI925T		0x54029250
-#define CPU_ID_SA1110		0x6901b110
-#define CPU_ID_IXP1200		0x6901c120
-#define CPU_ID_80200		0x69052000
-#define CPU_ID_PXA250    	0x69052100 /* sans core revision */
-#define CPU_ID_PXA210    	0x69052120
-#define CPU_ID_PXA250A		0x69052100 /* 1st version Core */
-#define CPU_ID_PXA210A		0x69052120 /* 1st version Core */
-#define CPU_ID_PXA250B		0x69052900 /* 3rd version Core */
-#define CPU_ID_PXA210B		0x69052920 /* 3rd version Core */
-#define CPU_ID_PXA250C		0x69052d00 /* 4th version Core */
-#define CPU_ID_PXA210C		0x69052d20 /* 4th version Core */
-#define	CPU_ID_80321_400	0x69052420
-#define	CPU_ID_80321_600	0x69052430
-#define	CPU_ID_80321_400_B0	0x69052c20
-#define	CPU_ID_80321_600_B0	0x69052c30
-#define	CPU_ID_IXP425_533	0x690541c0
-#define	CPU_ID_IXP425_400	0x690541d0
-#define	CPU_ID_IXP425_266	0x690541f0
-
-/* ARM3-specific coprocessor 15 registers */
-#define ARM3_CP15_FLUSH		1
-#define ARM3_CP15_CONTROL	2
-#define ARM3_CP15_CACHEABLE	3
-#define ARM3_CP15_UPDATEABLE	4
-#define ARM3_CP15_DISRUPTIVE	5	
-
-/* ARM3 Control register bits */
-#define ARM3_CTL_CACHE_ON	0x00000001
-#define ARM3_CTL_SHARED		0x00000002
-#define ARM3_CTL_MONITOR	0x00000004
-
-/*
- * Post-ARM3 CP15 registers:
- *
- *	1	Control register
- *
- *	2	Translation Table Base
- *
- *	3	Domain Access Control
- *
- *	4	Reserved
- *
- *	5	Fault Status
- *
- *	6	Fault Address
- *
- *	7	Cache/write-buffer Control
- *
- *	8	TLB Control
- *
- *	9	Cache Lockdown
- *
- *	10	TLB Lockdown
- *
- *	11	Reserved
- *
- *	12	Reserved
- *
- *	13	Process ID (for FCSE)
- *
- *	14	Reserved
- *
- *	15	Implementation Dependent
- */
-
-/* Some of the definitions below need cleaning up for V3/V4 architectures */
-
-/* CPU control register (CP15 register 1) */
-#define CPU_CONTROL_MMU_ENABLE	0x00000001 /* M: MMU/Protection unit enable */
-#define CPU_CONTROL_AFLT_ENABLE	0x00000002 /* A: Alignment fault enable */
-#define CPU_CONTROL_DC_ENABLE	0x00000004 /* C: IDC/DC enable */
-#define CPU_CONTROL_WBUF_ENABLE 0x00000008 /* W: Write buffer enable */
-#define CPU_CONTROL_32BP_ENABLE 0x00000010 /* P: 32-bit exception handlers */
-#define CPU_CONTROL_32BD_ENABLE 0x00000020 /* D: 32-bit addressing */
-#define CPU_CONTROL_LABT_ENABLE 0x00000040 /* L: Late abort enable */
-#define CPU_CONTROL_BEND_ENABLE 0x00000080 /* B: Big-endian mode */
-#define CPU_CONTROL_SYST_ENABLE 0x00000100 /* S: System protection bit */
-#define CPU_CONTROL_ROM_ENABLE	0x00000200 /* R: ROM protection bit */
-#define CPU_CONTROL_CPCLK	0x00000400 /* F: Implementation defined */
-#define CPU_CONTROL_BPRD_ENABLE 0x00000800 /* Z: Branch prediction enable */
-#define CPU_CONTROL_IC_ENABLE   0x00001000 /* I: IC enable */
-#define CPU_CONTROL_VECRELOC	0x00002000 /* V: Vector relocation */
-#define CPU_CONTROL_ROUNDROBIN	0x00004000 /* RR: Predictable replacement */
-#define CPU_CONTROL_V4COMPAT	0x00008000 /* L4: ARMv4 compat LDR R15 etc */
-
-#define CPU_CONTROL_IDC_ENABLE	CPU_CONTROL_DC_ENABLE
-
-/* XScale Auxillary Control Register (CP15 register 1, opcode2 1) */
-#define	XSCALE_AUXCTL_K		0x00000001 /* dis. write buffer coalescing */
-#define	XSCALE_AUXCTL_P		0x00000002 /* ECC protect page table access */
-#define	XSCALE_AUXCTL_MD_WB_RA	0x00000000 /* mini-D$ wb, read-allocate */
-#define	XSCALE_AUXCTL_MD_WB_RWA	0x00000010 /* mini-D$ wb, read/write-allocate */
-#define	XSCALE_AUXCTL_MD_WT	0x00000020 /* mini-D$ wt, read-allocate */
-#define	XSCALE_AUXCTL_MD_MASK	0x00000030
-
-/* Cache type register definitions */
-#define	CPU_CT_ISIZE(x)		((x) & 0xfff)		/* I$ info */
-#define	CPU_CT_DSIZE(x)		(((x) >> 12) & 0xfff)	/* D$ info */
-#define	CPU_CT_S		(1U << 24)		/* split cache */
-#define	CPU_CT_CTYPE(x)		(((x) >> 25) & 0xf)	/* cache type */
-
-#define	CPU_CT_CTYPE_WT		0	/* write-through */
-#define	CPU_CT_CTYPE_WB1	1	/* write-back, clean w/ read */
-#define	CPU_CT_CTYPE_WB2	2	/* w/b, clean w/ cp15,7 */
-#define	CPU_CT_CTYPE_WB6	6	/* w/b, cp15,7, lockdown fmt A */
-#define	CPU_CT_CTYPE_WB7	7	/* w/b, cp15,7, lockdown fmt B */
-
-#define	CPU_CT_xSIZE_LEN(x)	((x) & 0x3)		/* line size */
-#define	CPU_CT_xSIZE_M		(1U << 2)		/* multiplier */
-#define	CPU_CT_xSIZE_ASSOC(x)	(((x) >> 3) & 0x7)	/* associativity */
-#define	CPU_CT_xSIZE_SIZE(x)	(((x) >> 6) & 0x7)	/* size */
-
-/* Fault status register definitions */
-
-#define FAULT_TYPE_MASK 0x0f
-#define FAULT_USER      0x10
-
-#define FAULT_WRTBUF_0  0x00 /* Vector Exception */
-#define FAULT_WRTBUF_1  0x02 /* Terminal Exception */
-#define FAULT_BUSERR_0  0x04 /* External Abort on Linefetch -- Section */
-#define FAULT_BUSERR_1  0x06 /* External Abort on Linefetch -- Page */
-#define FAULT_BUSERR_2  0x08 /* External Abort on Non-linefetch -- Section */
-#define FAULT_BUSERR_3  0x0a /* External Abort on Non-linefetch -- Page */
-#define FAULT_BUSTRNL1  0x0c /* External abort on Translation -- Level 1 */
-#define FAULT_BUSTRNL2  0x0e /* External abort on Translation -- Level 2 */
-#define FAULT_ALIGN_0   0x01 /* Alignment */
-#define FAULT_ALIGN_1   0x03 /* Alignment */
-#define FAULT_TRANS_S   0x05 /* Translation -- Section */
-#define FAULT_TRANS_P   0x07 /* Translation -- Page */
-#define FAULT_DOMAIN_S  0x09 /* Domain -- Section */
-#define FAULT_DOMAIN_P  0x0b /* Domain -- Page */
-#define FAULT_PERM_S    0x0d /* Permission -- Section */
-#define FAULT_PERM_P    0x0f /* Permission -- Page */
-
-#define	FAULT_IMPRECISE	0x400	/* Imprecise exception (XSCALE) */
-
-/*
- * Address of the vector page, low and high versions.
- */
-#define	ARM_VECTORS_LOW		0x00000000U
-#define	ARM_VECTORS_HIGH	0xffff0000U
-
-/*
- * ARM Instructions
- *
- *       3 3 2 2 2                              
- *       1 0 9 8 7                                                     0
- *      +-------+-------------------------------------------------------+
- *      | cond  |              instruction dependant                    |
- *      |c c c c|                                                       |
- *      +-------+-------------------------------------------------------+
- */
-
-#define INSN_SIZE		4		/* Always 4 bytes */
-#define INSN_COND_MASK		0xf0000000	/* Condition mask */
-#define INSN_COND_AL		0xe0000000	/* Always condition */
-
-#endif /* !MACHINE_ARMREG_H */
diff --git a/libpixelflinger/codeflinger/blending.cpp b/libpixelflinger/codeflinger/blending.cpp
deleted file mode 100644
index 2cbb00f..0000000
--- a/libpixelflinger/codeflinger/blending.cpp
+++ /dev/null
@@ -1,674 +0,0 @@
-/* libs/pixelflinger/codeflinger/blending.cpp
-**
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "pixelflinger-code"
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#include <android-base/macros.h>
-#include <log/log.h>
-
-#include "GGLAssembler.h"
-
-namespace android {
-
-void GGLAssembler::build_fog(
-                        component_t& temp,      // incomming fragment / output
-                        int component,
-                        Scratch& regs)
-{
-   if (mInfo[component].fog) {
-        Scratch scratches(registerFile());
-        comment("fog");
-
-        integer_t fragment(temp.reg, temp.h, temp.flags);
-        if (!(temp.flags & CORRUPTIBLE)) {
-            temp.reg = regs.obtain();
-            temp.flags |= CORRUPTIBLE;
-        }
-
-        integer_t fogColor(scratches.obtain(), 8, CORRUPTIBLE); 
-        LDRB(AL, fogColor.reg, mBuilderContext.Rctx,
-                immed12_pre(GGL_OFFSETOF(state.fog.color[component])));
-
-        integer_t factor(scratches.obtain(), 16, CORRUPTIBLE);
-        CONTEXT_LOAD(factor.reg, generated_vars.f);
-
-        // clamp fog factor (TODO: see if there is a way to guarantee
-        // we won't overflow, when setting the iterators)
-        BIC(AL, 0, factor.reg, factor.reg, reg_imm(factor.reg, ASR, 31));
-        CMP(AL, factor.reg, imm( 0x10000 ));
-        MOV(HS, 0, factor.reg, imm( 0x10000 ));
-
-        build_blendFOneMinusF(temp, factor, fragment, fogColor);
-    }
-}
-
-void GGLAssembler::build_blending(
-                        component_t& temp,      // incomming fragment / output
-                        const pixel_t& pixel,   // framebuffer
-                        int component,
-                        Scratch& regs)
-{
-   if (!mInfo[component].blend)
-        return;
-        
-    int fs = component==GGLFormat::ALPHA ? mBlendSrcA : mBlendSrc;
-    int fd = component==GGLFormat::ALPHA ? mBlendDstA : mBlendDst;
-    if (fs==GGL_SRC_ALPHA_SATURATE && component==GGLFormat::ALPHA)
-        fs = GGL_ONE;
-    const int blending = blending_codes(fs, fd);
-    if (!temp.size()) {
-        // here, blending will produce something which doesn't depend on
-        // that component (eg: GL_ZERO:GL_*), so the register has not been
-        // allocated yet. Will never be used as a source.
-        temp = component_t(regs.obtain(), CORRUPTIBLE);
-    }
-
-    // we are doing real blending...
-    // fb:          extracted dst
-    // fragment:    extracted src
-    // temp:        component_t(fragment) and result
-
-    // scoped register allocator
-    Scratch scratches(registerFile());
-    comment("blending");
-
-    // we can optimize these cases a bit...
-    // (1) saturation is not needed
-    // (2) we can use only one multiply instead of 2
-    // (3) we can reduce the register pressure
-    //      R = S*f + D*(1-f) = (S-D)*f + D
-    //      R = S*(1-f) + D*f = (D-S)*f + S
-
-    const bool same_factor_opt1 =
-        (fs==GGL_DST_COLOR && fd==GGL_ONE_MINUS_DST_COLOR) ||
-        (fs==GGL_SRC_COLOR && fd==GGL_ONE_MINUS_SRC_COLOR) ||
-        (fs==GGL_DST_ALPHA && fd==GGL_ONE_MINUS_DST_ALPHA) ||
-        (fs==GGL_SRC_ALPHA && fd==GGL_ONE_MINUS_SRC_ALPHA);
-
-    const bool same_factor_opt2 =
-        (fs==GGL_ONE_MINUS_DST_COLOR && fd==GGL_DST_COLOR) ||
-        (fs==GGL_ONE_MINUS_SRC_COLOR && fd==GGL_SRC_COLOR) || 
-        (fs==GGL_ONE_MINUS_DST_ALPHA && fd==GGL_DST_ALPHA) ||
-        (fs==GGL_ONE_MINUS_SRC_ALPHA && fd==GGL_SRC_ALPHA);
-
-
-    // XXX: we could also optimize these cases:
-    // R = S*f + D*f = (S+D)*f
-    // R = S*(1-f) + D*(1-f) = (S+D)*(1-f)
-    // R = S*D + D*S = 2*S*D
-
-
-    // see if we need to extract 'component' from the destination (fb)
-    integer_t fb;
-    if (blending & (BLEND_DST|FACTOR_DST)) { 
-        fb.setTo(scratches.obtain(), 32); 
-        extract(fb, pixel, component);
-        if (mDithering) {
-            // XXX: maybe what we should do instead, is simply
-            // expand fb -or- fragment to the larger of the two
-            if (fb.size() < temp.size()) {
-                // for now we expand 'fb' to min(fragment, 8)
-                int new_size = temp.size() < 8 ? temp.size() : 8;
-                expand(fb, fb, new_size);
-            }
-        }
-    }
-
-
-    // convert input fragment to integer_t
-    if (temp.l && (temp.flags & CORRUPTIBLE)) {
-        MOV(AL, 0, temp.reg, reg_imm(temp.reg, LSR, temp.l));
-        temp.h -= temp.l;
-        temp.l = 0;
-    }
-    integer_t fragment(temp.reg, temp.size(), temp.flags);
-
-    // if not done yet, convert input fragment to integer_t
-    if (temp.l) {
-        // here we know temp is not CORRUPTIBLE
-        fragment.reg = scratches.obtain();
-        MOV(AL, 0, fragment.reg, reg_imm(temp.reg, LSR, temp.l));
-        fragment.flags |= CORRUPTIBLE;
-    }
-
-    if (!(temp.flags & CORRUPTIBLE)) {
-        // temp is not corruptible, but since it's the destination it
-        // will be modified, so we need to allocate a new register.
-        temp.reg = regs.obtain();
-        temp.flags &= ~CORRUPTIBLE;
-        fragment.flags &= ~CORRUPTIBLE;
-    }
-
-    if ((blending & BLEND_SRC) && !same_factor_opt1) {
-        // source (fragment) is needed for the blending stage
-        // so it's not CORRUPTIBLE (unless we're doing same_factor_opt1)
-        fragment.flags &= ~CORRUPTIBLE;
-    }
-
-
-    if (same_factor_opt1) {
-        //  R = S*f + D*(1-f) = (S-D)*f + D
-        integer_t factor;
-        build_blend_factor(factor, fs, 
-                component, pixel, fragment, fb, scratches);
-        // fb is always corruptible from this point
-        fb.flags |= CORRUPTIBLE;
-        build_blendFOneMinusF(temp, factor, fragment, fb);
-    } else if (same_factor_opt2) {
-        //  R = S*(1-f) + D*f = (D-S)*f + S
-        integer_t factor;
-        // fb is always corrruptible here
-        fb.flags |= CORRUPTIBLE;
-        build_blend_factor(factor, fd,
-                component, pixel, fragment, fb, scratches);
-        build_blendOneMinusFF(temp, factor, fragment, fb);
-    } else {
-        integer_t src_factor;
-        integer_t dst_factor;
-
-        // if destination (fb) is not needed for the blending stage, 
-        // then it can be marked as CORRUPTIBLE
-        if (!(blending & BLEND_DST)) {
-            fb.flags |= CORRUPTIBLE;
-        }
-
-        // XXX: try to mark some registers as CORRUPTIBLE
-        // in most case we could make those corruptible
-        // when we're processing the last component
-        // but not always, for instance
-        //    when fragment is constant and not reloaded
-        //    when fb is needed for logic-ops or masking
-        //    when a register is aliased (for instance with mAlphaSource)
-
-        // blend away...
-        if (fs==GGL_ZERO) {
-            if (fd==GGL_ZERO) {         // R = 0
-                // already taken care of
-            } else if (fd==GGL_ONE) {   // R = D
-                // already taken care of
-            } else {                    // R = D*fd
-                // compute fd
-                build_blend_factor(dst_factor, fd,
-                        component, pixel, fragment, fb, scratches);
-                mul_factor(temp, fb, dst_factor);
-            }
-        } else if (fs==GGL_ONE) {
-            if (fd==GGL_ZERO) {         // R = S
-                // NOP, taken care of
-            } else if (fd==GGL_ONE) {   // R = S + D
-                component_add(temp, fb, fragment); // args order matters
-                component_sat(temp);
-            } else {                    // R = S + D*fd
-                // compute fd
-                build_blend_factor(dst_factor, fd,
-                        component, pixel, fragment, fb, scratches);
-                mul_factor_add(temp, fb, dst_factor, component_t(fragment));
-                component_sat(temp);
-            }
-        } else {
-            // compute fs
-            build_blend_factor(src_factor, fs, 
-                    component, pixel, fragment, fb, scratches);
-            if (fd==GGL_ZERO) {         // R = S*fs
-                mul_factor(temp, fragment, src_factor);
-            } else if (fd==GGL_ONE) {   // R = S*fs + D
-                mul_factor_add(temp, fragment, src_factor, component_t(fb));
-                component_sat(temp);
-            } else {                    // R = S*fs + D*fd
-                mul_factor(temp, fragment, src_factor);
-                if (scratches.isUsed(src_factor.reg))
-                    scratches.recycle(src_factor.reg);
-                // compute fd
-                build_blend_factor(dst_factor, fd,
-                        component, pixel, fragment, fb, scratches);
-                mul_factor_add(temp, fb, dst_factor, temp);
-                if (!same_factor_opt1 && !same_factor_opt2) {
-                    component_sat(temp);
-                }
-            }
-        }
-    }
-
-    // now we can be corrupted (it's the dest)
-    temp.flags |= CORRUPTIBLE;
-}
-
-void GGLAssembler::build_blend_factor(
-        integer_t& factor, int f, int component,
-        const pixel_t& dst_pixel,
-        integer_t& fragment,
-        integer_t& fb,
-        Scratch& scratches)
-{
-    integer_t src_alpha(fragment);
-
-    // src_factor/dst_factor won't be used after blending,
-    // so it's fine to mark them as CORRUPTIBLE (if not aliased)
-    factor.flags |= CORRUPTIBLE;
-
-    switch(f) {
-    case GGL_ONE_MINUS_SRC_ALPHA:
-    case GGL_SRC_ALPHA:
-        if (component==GGLFormat::ALPHA && !isAlphaSourceNeeded()) {
-            // we're processing alpha, so we already have
-            // src-alpha in fragment, and we need src-alpha just this time.
-        } else {
-           // alpha-src will be needed for other components
-            if (!mBlendFactorCached || mBlendFactorCached==f) {
-                src_alpha = mAlphaSource;
-                factor = mAlphaSource;
-                factor.flags &= ~CORRUPTIBLE;           
-                // we already computed the blend factor before, nothing to do.
-                if (mBlendFactorCached)
-                    return;
-                // this is the first time, make sure to compute the blend
-                // factor properly.
-                mBlendFactorCached = f;
-                break;
-            } else {
-                // we have a cached alpha blend factor, but we want another one,
-                // this should really not happen because by construction,
-                // we cannot have BOTH source and destination
-                // blend factors use ALPHA *and* ONE_MINUS_ALPHA (because
-                // the blending stage uses the f/(1-f) optimization
-                
-                // for completeness, we handle this case though. Since there
-                // are only 2 choices, this meens we want "the other one"
-                // (1-factor)
-                factor = mAlphaSource;
-                factor.flags &= ~CORRUPTIBLE;           
-                RSB(AL, 0, factor.reg, factor.reg, imm((1<<factor.s)));
-                mBlendFactorCached = f;
-                return;
-            }                
-        }
-        FALLTHROUGH_INTENDED;
-    case GGL_ONE_MINUS_DST_COLOR:
-    case GGL_DST_COLOR:
-    case GGL_ONE_MINUS_SRC_COLOR:
-    case GGL_SRC_COLOR:
-    case GGL_ONE_MINUS_DST_ALPHA:
-    case GGL_DST_ALPHA:
-    case GGL_SRC_ALPHA_SATURATE:
-        // help us find out what register we can use for the blend-factor
-        // CORRUPTIBLE registers are chosen first, or a new one is allocated.
-        if (fragment.flags & CORRUPTIBLE) {
-            factor.setTo(fragment.reg, 32, CORRUPTIBLE);
-            fragment.flags &= ~CORRUPTIBLE;
-        } else if (fb.flags & CORRUPTIBLE) {
-            factor.setTo(fb.reg, 32, CORRUPTIBLE);
-            fb.flags &= ~CORRUPTIBLE;
-        } else {
-            factor.setTo(scratches.obtain(), 32, CORRUPTIBLE);
-        } 
-        break;
-    }
-
-    // XXX: doesn't work if size==1
-
-    switch(f) {
-    case GGL_ONE_MINUS_DST_COLOR:
-    case GGL_DST_COLOR:
-        factor.s = fb.s;
-        ADD(AL, 0, factor.reg, fb.reg, reg_imm(fb.reg, LSR, fb.s-1));
-        break;
-    case GGL_ONE_MINUS_SRC_COLOR:
-    case GGL_SRC_COLOR:
-        factor.s = fragment.s;
-        ADD(AL, 0, factor.reg, fragment.reg,
-            reg_imm(fragment.reg, LSR, fragment.s-1));
-        break;
-    case GGL_ONE_MINUS_SRC_ALPHA:
-    case GGL_SRC_ALPHA:
-        factor.s = src_alpha.s;
-        ADD(AL, 0, factor.reg, src_alpha.reg,
-                reg_imm(src_alpha.reg, LSR, src_alpha.s-1));
-        break;
-    case GGL_ONE_MINUS_DST_ALPHA:
-    case GGL_DST_ALPHA:
-        // XXX: should be precomputed
-        extract(factor, dst_pixel, GGLFormat::ALPHA);
-        ADD(AL, 0, factor.reg, factor.reg,
-                reg_imm(factor.reg, LSR, factor.s-1));
-        break;
-    case GGL_SRC_ALPHA_SATURATE:
-        // XXX: should be precomputed
-        // XXX: f = min(As, 1-Ad)
-        // btw, we're guaranteed that Ad's size is <= 8, because
-        // it's extracted from the framebuffer
-        break;
-    }
-
-    switch(f) {
-    case GGL_ONE_MINUS_DST_COLOR:
-    case GGL_ONE_MINUS_SRC_COLOR:
-    case GGL_ONE_MINUS_DST_ALPHA:
-    case GGL_ONE_MINUS_SRC_ALPHA:
-        RSB(AL, 0, factor.reg, factor.reg, imm((1<<factor.s)));
-    }
-    
-    // don't need more than 8-bits for the blend factor
-    // and this will prevent overflows in the multiplies later
-    if (factor.s > 8) {
-        MOV(AL, 0, factor.reg, reg_imm(factor.reg, LSR, factor.s-8));
-        factor.s = 8;
-    }
-}
-
-int GGLAssembler::blending_codes(int fs, int fd)
-{
-    int blending = 0;
-    switch(fs) {
-    case GGL_ONE:
-        blending |= BLEND_SRC;
-        break;
-
-    case GGL_ONE_MINUS_DST_COLOR:
-    case GGL_DST_COLOR:
-        blending |= FACTOR_DST|BLEND_SRC;
-        break;
-    case GGL_ONE_MINUS_DST_ALPHA:
-    case GGL_DST_ALPHA:
-        // no need to extract 'component' from the destination
-        // for the blend factor, because we need ALPHA only.
-        blending |= BLEND_SRC;
-        break;
-
-    case GGL_ONE_MINUS_SRC_COLOR:
-    case GGL_SRC_COLOR:    
-        blending |= FACTOR_SRC|BLEND_SRC;
-        break;
-    case GGL_ONE_MINUS_SRC_ALPHA:
-    case GGL_SRC_ALPHA:
-    case GGL_SRC_ALPHA_SATURATE:
-        blending |= FACTOR_SRC|BLEND_SRC;
-        break;
-    }
-    switch(fd) {
-    case GGL_ONE:
-        blending |= BLEND_DST;
-        break;
-
-    case GGL_ONE_MINUS_DST_COLOR:
-    case GGL_DST_COLOR:
-        blending |= FACTOR_DST|BLEND_DST;
-        break;
-    case GGL_ONE_MINUS_DST_ALPHA:
-    case GGL_DST_ALPHA:
-        blending |= FACTOR_DST|BLEND_DST;
-        break;
-
-    case GGL_ONE_MINUS_SRC_COLOR:
-    case GGL_SRC_COLOR:    
-        blending |= FACTOR_SRC|BLEND_DST;
-        break;
-    case GGL_ONE_MINUS_SRC_ALPHA:
-    case GGL_SRC_ALPHA:
-        // no need to extract 'component' from the source
-        // for the blend factor, because we need ALPHA only.
-        blending |= BLEND_DST;
-        break;
-    }
-    return blending;
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::build_blendFOneMinusF(
-        component_t& temp,
-        const integer_t& factor, 
-        const integer_t& fragment,
-        const integer_t& fb)
-{
-    //  R = S*f + D*(1-f) = (S-D)*f + D
-    Scratch scratches(registerFile());
-    // compute S-D
-    integer_t diff(fragment.flags & CORRUPTIBLE ?
-            fragment.reg : scratches.obtain(), fb.size(), CORRUPTIBLE);
-    const int shift = fragment.size() - fb.size();
-    if (shift>0)        RSB(AL, 0, diff.reg, fb.reg, reg_imm(fragment.reg, LSR, shift));
-    else if (shift<0)   RSB(AL, 0, diff.reg, fb.reg, reg_imm(fragment.reg, LSL,-shift));
-    else                RSB(AL, 0, diff.reg, fb.reg, fragment.reg);
-    mul_factor_add(temp, diff, factor, component_t(fb));
-}
-
-void GGLAssembler::build_blendOneMinusFF(
-        component_t& temp,
-        const integer_t& factor, 
-        const integer_t& fragment,
-        const integer_t& fb)
-{
-    //  R = S*f + D*(1-f) = (S-D)*f + D
-    Scratch scratches(registerFile());
-    // compute D-S
-    integer_t diff(fb.flags & CORRUPTIBLE ?
-            fb.reg : scratches.obtain(), fb.size(), CORRUPTIBLE);
-    const int shift = fragment.size() - fb.size();
-    if (shift>0)        SUB(AL, 0, diff.reg, fb.reg, reg_imm(fragment.reg, LSR, shift));
-    else if (shift<0)   SUB(AL, 0, diff.reg, fb.reg, reg_imm(fragment.reg, LSL,-shift));
-    else                SUB(AL, 0, diff.reg, fb.reg, fragment.reg);
-    mul_factor_add(temp, diff, factor, component_t(fragment));
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::mul_factor(  component_t& d,
-                                const integer_t& v,
-                                const integer_t& f)
-{
-    int vs = v.size();
-    int fs = f.size();
-    int ms = vs+fs;
-
-    // XXX: we could have special cases for 1 bit mul
-
-    // all this code below to use the best multiply instruction
-    // wrt the parameters size. We take advantage of the fact
-    // that the 16-bits multiplies allow a 16-bit shift
-    // The trick is that we just make sure that we have at least 8-bits
-    // per component (which is enough for a 8 bits display).
-
-    int xy;
-    int vshift = 0;
-    int fshift = 0;
-    int smulw = 0;
-
-    if (vs<16) {
-        if (fs<16) {
-            xy = xyBB;
-        } else if (GGL_BETWEEN(fs, 24, 31)) {
-            ms -= 16;
-            xy = xyTB;
-        } else {
-            // eg: 15 * 18  ->  15 * 15
-            fshift = fs - 15;
-            ms -= fshift;
-            xy = xyBB;
-        }
-    } else if (GGL_BETWEEN(vs, 24, 31)) {
-        if (fs<16) {
-            ms -= 16;
-            xy = xyTB;
-        } else if (GGL_BETWEEN(fs, 24, 31)) {
-            ms -= 32;
-            xy = xyTT;
-        } else {
-            // eg: 24 * 18  ->  8 * 18
-            fshift = fs - 15;
-            ms -= 16 + fshift;
-            xy = xyTB;
-        }
-    } else {
-        if (fs<16) {
-            // eg: 18 * 15  ->  15 * 15
-            vshift = vs - 15;
-            ms -= vshift;
-            xy = xyBB;
-        } else if (GGL_BETWEEN(fs, 24, 31)) {
-            // eg: 18 * 24  ->  15 * 8
-            vshift = vs - 15;
-            ms -= 16 + vshift;
-            xy = xyBT;
-        } else {
-            // eg: 18 * 18  ->  (15 * 18)>>16
-            fshift = fs - 15;
-            ms -= 16 + fshift;
-            xy = yB;    //XXX SMULWB
-            smulw = 1;
-        }
-    }
-
-    ALOGE_IF(ms>=32, "mul_factor overflow vs=%d, fs=%d", vs, fs);
-
-    int vreg = v.reg;
-    int freg = f.reg;
-    if (vshift) {
-        MOV(AL, 0, d.reg, reg_imm(vreg, LSR, vshift));
-        vreg = d.reg;
-    }
-    if (fshift) {
-        MOV(AL, 0, d.reg, reg_imm(vreg, LSR, fshift));
-        freg = d.reg;
-    }
-    if (smulw)  SMULW(AL, xy, d.reg, vreg, freg);
-    else        SMUL(AL, xy, d.reg, vreg, freg);
-
-
-    d.h = ms;
-    if (mDithering) {
-        d.l = 0; 
-    } else {
-        d.l = fs; 
-        d.flags |= CLEAR_LO;
-    }
-}
-
-void GGLAssembler::mul_factor_add(  component_t& d,
-                                    const integer_t& v,
-                                    const integer_t& f,
-                                    const component_t& a)
-{
-    // XXX: we could have special cases for 1 bit mul
-    Scratch scratches(registerFile());
-
-    int vs = v.size();
-    int fs = f.size();
-    int as = a.h;
-    int ms = vs+fs;
-
-    ALOGE_IF(ms>=32, "mul_factor_add overflow vs=%d, fs=%d, as=%d", vs, fs, as);
-
-    integer_t add(a.reg, a.h, a.flags);
-
-    // 'a' is a component_t but it is guaranteed to have
-    // its high bits set to 0. However in the dithering case,
-    // we can't get away with truncating the potentially bad bits
-    // so extraction is needed.
-
-   if ((mDithering) && (a.size() < ms)) {
-        // we need to expand a
-        if (!(a.flags & CORRUPTIBLE)) {
-            // ... but it's not corruptible, so we need to pick a
-            // temporary register.
-            // Try to uses the destination register first (it's likely
-            // to be usable, unless it aliases an input).
-            if (d.reg!=a.reg && d.reg!=v.reg && d.reg!=f.reg) {
-                add.reg = d.reg;
-            } else {
-                add.reg = scratches.obtain();
-            }
-        }
-        expand(add, a, ms); // extracts and expands
-        as = ms;
-    }
-
-    if (ms == as) {
-        if (vs<16 && fs<16) SMLABB(AL, d.reg, v.reg, f.reg, add.reg);
-        else                MLA(AL, 0, d.reg, v.reg, f.reg, add.reg);
-    } else {
-        int temp = d.reg;
-        if (temp == add.reg) {
-            // the mul will modify add.reg, we need an intermediary reg
-            if (v.flags & CORRUPTIBLE)      temp = v.reg;
-            else if (f.flags & CORRUPTIBLE) temp = f.reg;
-            else                            temp = scratches.obtain();
-        }
-
-        if (vs<16 && fs<16) SMULBB(AL, temp, v.reg, f.reg);
-        else                MUL(AL, 0, temp, v.reg, f.reg);
-
-        if (ms>as) {
-            ADD(AL, 0, d.reg, temp, reg_imm(add.reg, LSL, ms-as));
-        } else if (ms<as) {
-            // not sure if we should expand the mul instead?
-            ADD(AL, 0, d.reg, temp, reg_imm(add.reg, LSR, as-ms));
-        }
-    }
-
-    d.h = ms;
-    if (mDithering) {
-        d.l = a.l; 
-    } else {
-        d.l = fs>a.l ? fs : a.l;
-        d.flags |= CLEAR_LO;
-    }
-}
-
-void GGLAssembler::component_add(component_t& d,
-        const integer_t& dst, const integer_t& src)
-{
-    // here we're guaranteed that fragment.size() >= fb.size()
-    const int shift = src.size() - dst.size();
-    if (!shift) {
-        ADD(AL, 0, d.reg, src.reg, dst.reg);
-    } else {
-        ADD(AL, 0, d.reg, src.reg, reg_imm(dst.reg, LSL, shift));
-    }
-
-    d.h = src.size();
-    if (mDithering) {
-        d.l = 0;
-    } else {
-        d.l = shift;
-        d.flags |= CLEAR_LO;
-    }
-}
-
-void GGLAssembler::component_sat(const component_t& v)
-{
-    const int one = ((1<<v.size())-1)<<v.l;
-    CMP(AL, v.reg, imm( 1<<v.h ));
-    if (isValidImmediate(one)) {
-        MOV(HS, 0, v.reg, imm( one ));
-    } else if (isValidImmediate(~one)) {
-        MVN(HS, 0, v.reg, imm( ~one ));
-    } else {
-        MOV(HS, 0, v.reg, imm( 1<<v.h ));
-        SUB(HS, 0, v.reg, v.reg, imm( 1<<v.l ));
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
diff --git a/libpixelflinger/codeflinger/disassem.c b/libpixelflinger/codeflinger/disassem.c
deleted file mode 100644
index 5cbd63d..0000000
--- a/libpixelflinger/codeflinger/disassem.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/*	$NetBSD: disassem.c,v 1.14 2003/03/27 16:58:36 mycroft Exp $	*/
-
-/*-
- * Copyright (c) 1996 Mark Brinicombe.
- * Copyright (c) 1996 Brini.
- *
- * 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 Brini.
- * 4. The name of the company nor the name of the author may be used to
- *    endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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.
- *
- * RiscBSD kernel project
- *
- * db_disasm.c
- *
- * Kernel disassembler
- *
- * Created      : 10/02/96
- *
- * Structured after the sparc/sparc/db_disasm.c by David S. Miller &
- * Paul Kranenburg
- *
- * This code is not complete. Not all instructions are disassembled.
- */
-
-#include <sys/cdefs.h>
-//__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/arm/arm/disassem.c,v 1.2 2005/01/05 21:58:47 imp Exp $");
-#include <sys/param.h>
-#include <stdio.h>
-
-#include "disassem.h"
-#include "armreg.h"
-//#include <ddb/ddb.h>
-
-/*
- * General instruction format
- *
- *	insn[cc][mod]	[operands]
- *
- * Those fields with an uppercase format code indicate that the field
- * follows directly after the instruction before the separator i.e.
- * they modify the instruction rather than just being an operand to
- * the instruction. The only exception is the writeback flag which
- * follows a operand.
- *
- *
- * 2 - print Operand 2 of a data processing instruction
- * d - destination register (bits 12-15)
- * n - n register (bits 16-19)
- * s - s register (bits 8-11)
- * o - indirect register rn (bits 16-19) (used by swap)
- * m - m register (bits 0-3)
- * a - address operand of ldr/str instruction
- * e - address operand of ldrh/strh instruction
- * l - register list for ldm/stm instruction
- * f - 1st fp operand (register) (bits 12-14)
- * g - 2nd fp operand (register) (bits 16-18)
- * h - 3rd fp operand (register/immediate) (bits 0-4)
- * j - xtb rotate literal (bits 10-11)
- * i - bfx lsb literal (bits 7-11)
- * w - bfx width literal (bits 16-20)
- * b - branch address
- * t - thumb branch address (bits 24, 0-23)
- * k - breakpoint comment (bits 0-3, 8-19)
- * X - block transfer type
- * Y - block transfer type (r13 base)
- * c - comment field bits(0-23)
- * p - saved or current status register
- * F - PSR transfer fields
- * D - destination-is-r15 (P) flag on TST, TEQ, CMP, CMN
- * L - co-processor transfer size
- * S - set status flag
- * P - fp precision
- * Q - fp precision (for ldf/stf)
- * R - fp rounding
- * v - co-processor data transfer registers + addressing mode
- * W - writeback flag
- * x - instruction in hex
- * # - co-processor number
- * y - co-processor data processing registers
- * z - co-processor register transfer registers
- */
-
-struct arm32_insn {
-	u_int mask;
-	u_int pattern;
-	char* name;
-	char* format;
-};
-
-static const struct arm32_insn arm32_i[] = {
-    { 0x0fffffff, 0x0ff00000, "imb",	"c" },		/* Before swi */
-    { 0x0fffffff, 0x0ff00001, "imbrange",	"c" },	/* Before swi */
-    { 0x0f000000, 0x0f000000, "swi",	"c" },
-    { 0xfe000000, 0xfa000000, "blx",	"t" },		/* Before b and bl */
-    { 0x0f000000, 0x0a000000, "b",	"b" },
-    { 0x0f000000, 0x0b000000, "bl",	"b" },
-    { 0x0fe000f0, 0x00000090, "mul",	"Snms" },
-    { 0x0fe000f0, 0x00200090, "mla",	"Snmsd" },
-    { 0x0fe000f0, 0x00800090, "umull",	"Sdnms" },
-    { 0x0fe000f0, 0x00c00090, "smull",	"Sdnms" },
-    { 0x0fe000f0, 0x00a00090, "umlal",	"Sdnms" },
-    { 0x0fe000f0, 0x00e00090, "smlal",	"Sdnms" },
-    { 0x0fff03f0, 0x06cf0070, "uxtb16", "dmj" },
-    { 0x0fe00070, 0x07e00050, "ubfx",   "dmiw" },
-    { 0x0d700000, 0x04200000, "strt",	"daW" },
-    { 0x0d700000, 0x04300000, "ldrt",	"daW" },
-    { 0x0d700000, 0x04600000, "strbt",	"daW" },
-    { 0x0d700000, 0x04700000, "ldrbt",	"daW" },
-    { 0x0c500000, 0x04000000, "str",	"daW" },
-    { 0x0c500000, 0x04100000, "ldr",	"daW" },
-    { 0x0c500000, 0x04400000, "strb",	"daW" },
-    { 0x0c500000, 0x04500000, "ldrb",	"daW" },
-    { 0x0e1f0000, 0x080d0000, "stm",	"YnWl" },/* separate out r13 base */
-    { 0x0e1f0000, 0x081d0000, "ldm",	"YnWl" },/* separate out r13 base */    
-    { 0x0e100000, 0x08000000, "stm",	"XnWl" },
-    { 0x0e100000, 0x08100000, "ldm",	"XnWl" },    
-    { 0x0e1000f0, 0x00100090, "ldrb",	"deW" },
-    { 0x0e1000f0, 0x00000090, "strb",	"deW" },
-    { 0x0e1000f0, 0x001000d0, "ldrsb",	"deW" },
-    { 0x0e1000f0, 0x001000b0, "ldrh",	"deW" },
-    { 0x0e1000f0, 0x000000b0, "strh",	"deW" },
-    { 0x0e1000f0, 0x001000f0, "ldrsh",	"deW" },
-    { 0x0f200090, 0x00200090, "und",	"x" },	/* Before data processing */
-    { 0x0e1000d0, 0x000000d0, "und",	"x" },	/* Before data processing */
-    { 0x0ff00ff0, 0x01000090, "swp",	"dmo" },
-    { 0x0ff00ff0, 0x01400090, "swpb",	"dmo" },
-    { 0x0fbf0fff, 0x010f0000, "mrs",	"dp" },	/* Before data processing */
-    { 0x0fb0fff0, 0x0120f000, "msr",	"pFm" },/* Before data processing */
-    { 0x0fb0f000, 0x0320f000, "msr",	"pF2" },/* Before data processing */
-    { 0x0ffffff0, 0x012fff10, "bx",     "m" },
-    { 0x0fff0ff0, 0x016f0f10, "clz",	"dm" },
-    { 0x0ffffff0, 0x012fff30, "blx",	"m" },
-    { 0xfff000f0, 0xe1200070, "bkpt",	"k" },
-    { 0x0de00000, 0x00000000, "and",	"Sdn2" },
-    { 0x0de00000, 0x00200000, "eor",	"Sdn2" },
-    { 0x0de00000, 0x00400000, "sub",	"Sdn2" },
-    { 0x0de00000, 0x00600000, "rsb",	"Sdn2" },
-    { 0x0de00000, 0x00800000, "add",	"Sdn2" },
-    { 0x0de00000, 0x00a00000, "adc",	"Sdn2" },
-    { 0x0de00000, 0x00c00000, "sbc",	"Sdn2" },
-    { 0x0de00000, 0x00e00000, "rsc",	"Sdn2" },
-    { 0x0df00000, 0x01100000, "tst",	"Dn2" },
-    { 0x0df00000, 0x01300000, "teq",	"Dn2" },
-    { 0x0df00000, 0x01500000, "cmp",	"Dn2" },
-    { 0x0df00000, 0x01700000, "cmn",	"Dn2" },
-    { 0x0de00000, 0x01800000, "orr",	"Sdn2" },
-    { 0x0de00000, 0x01a00000, "mov",	"Sd2" },
-    { 0x0de00000, 0x01c00000, "bic",	"Sdn2" },
-    { 0x0de00000, 0x01e00000, "mvn",	"Sd2" },
-    { 0x0ff08f10, 0x0e000100, "adf",	"PRfgh" },
-    { 0x0ff08f10, 0x0e100100, "muf",	"PRfgh" },
-    { 0x0ff08f10, 0x0e200100, "suf",	"PRfgh" },
-    { 0x0ff08f10, 0x0e300100, "rsf",	"PRfgh" },
-    { 0x0ff08f10, 0x0e400100, "dvf",	"PRfgh" },
-    { 0x0ff08f10, 0x0e500100, "rdf",	"PRfgh" },
-    { 0x0ff08f10, 0x0e600100, "pow",	"PRfgh" },
-    { 0x0ff08f10, 0x0e700100, "rpw",	"PRfgh" },
-    { 0x0ff08f10, 0x0e800100, "rmf",	"PRfgh" },
-    { 0x0ff08f10, 0x0e900100, "fml",	"PRfgh" },
-    { 0x0ff08f10, 0x0ea00100, "fdv",	"PRfgh" },
-    { 0x0ff08f10, 0x0eb00100, "frd",	"PRfgh" },
-    { 0x0ff08f10, 0x0ec00100, "pol",	"PRfgh" },
-    { 0x0f008f10, 0x0e000100, "fpbop",	"PRfgh" },
-    { 0x0ff08f10, 0x0e008100, "mvf",	"PRfh" },
-    { 0x0ff08f10, 0x0e108100, "mnf",	"PRfh" },
-    { 0x0ff08f10, 0x0e208100, "abs",	"PRfh" },
-    { 0x0ff08f10, 0x0e308100, "rnd",	"PRfh" },
-    { 0x0ff08f10, 0x0e408100, "sqt",	"PRfh" },
-    { 0x0ff08f10, 0x0e508100, "log",	"PRfh" },
-    { 0x0ff08f10, 0x0e608100, "lgn",	"PRfh" },
-    { 0x0ff08f10, 0x0e708100, "exp",	"PRfh" },
-    { 0x0ff08f10, 0x0e808100, "sin",	"PRfh" },
-    { 0x0ff08f10, 0x0e908100, "cos",	"PRfh" },
-    { 0x0ff08f10, 0x0ea08100, "tan",	"PRfh" },
-    { 0x0ff08f10, 0x0eb08100, "asn",	"PRfh" },
-    { 0x0ff08f10, 0x0ec08100, "acs",	"PRfh" },
-    { 0x0ff08f10, 0x0ed08100, "atn",	"PRfh" },
-    { 0x0f008f10, 0x0e008100, "fpuop",	"PRfh" },
-    { 0x0e100f00, 0x0c000100, "stf",	"QLv" },
-    { 0x0e100f00, 0x0c100100, "ldf",	"QLv" },
-    { 0x0ff00f10, 0x0e000110, "flt",	"PRgd" },
-    { 0x0ff00f10, 0x0e100110, "fix",	"PRdh" },
-    { 0x0ff00f10, 0x0e200110, "wfs",	"d" },
-    { 0x0ff00f10, 0x0e300110, "rfs",	"d" },
-    { 0x0ff00f10, 0x0e400110, "wfc",	"d" },
-    { 0x0ff00f10, 0x0e500110, "rfc",	"d" },
-    { 0x0ff0ff10, 0x0e90f110, "cmf",	"PRgh" },
-    { 0x0ff0ff10, 0x0eb0f110, "cnf",	"PRgh" },
-    { 0x0ff0ff10, 0x0ed0f110, "cmfe",	"PRgh" },
-    { 0x0ff0ff10, 0x0ef0f110, "cnfe",	"PRgh" },
-    { 0xff100010, 0xfe000010, "mcr2",	"#z" },
-    { 0x0f100010, 0x0e000010, "mcr",	"#z" },
-    { 0xff100010, 0xfe100010, "mrc2",	"#z" },
-    { 0x0f100010, 0x0e100010, "mrc",	"#z" },
-    { 0xff000010, 0xfe000000, "cdp2",	"#y" },
-    { 0x0f000010, 0x0e000000, "cdp",	"#y" },
-    { 0xfe100090, 0xfc100000, "ldc2",	"L#v" },
-    { 0x0e100090, 0x0c100000, "ldc",	"L#v" },
-    { 0xfe100090, 0xfc000000, "stc2",	"L#v" },
-    { 0x0e100090, 0x0c000000, "stc",	"L#v" },
-    { 0xf550f000, 0xf550f000, "pld",	"ne" },
-    { 0x0ff00ff0, 0x01000050, "qaad",	"dmn" },
-    { 0x0ff00ff0, 0x01400050, "qdaad",	"dmn" },
-    { 0x0ff00ff0, 0x01600050, "qdsub",	"dmn" },
-    { 0x0ff00ff0, 0x01200050, "dsub",	"dmn" },
-    { 0x0ff000f0, 0x01000080, "smlabb",	"nmsd" },   // d & n inverted!!
-    { 0x0ff000f0, 0x010000a0, "smlatb",	"nmsd" },   // d & n inverted!!
-    { 0x0ff000f0, 0x010000c0, "smlabt",	"nmsd" },   // d & n inverted!!
-    { 0x0ff000f0, 0x010000e0, "smlatt",	"nmsd" },   // d & n inverted!!
-    { 0x0ff000f0, 0x01400080, "smlalbb","ndms" },   // d & n inverted!!
-    { 0x0ff000f0, 0x014000a0, "smlaltb","ndms" },   // d & n inverted!!
-    { 0x0ff000f0, 0x014000c0, "smlalbt","ndms" },   // d & n inverted!!
-    { 0x0ff000f0, 0x014000e0, "smlaltt","ndms" },   // d & n inverted!!
-    { 0x0ff000f0, 0x01200080, "smlawb", "nmsd" },   // d & n inverted!!
-    { 0x0ff0f0f0, 0x012000a0, "smulwb","nms" },   // d & n inverted!!
-    { 0x0ff000f0, 0x012000c0, "smlawt", "nmsd" },   // d & n inverted!!
-    { 0x0ff0f0f0, 0x012000e0, "smulwt","nms" },   // d & n inverted!!
-    { 0x0ff0f0f0, 0x01600080, "smulbb","nms" },   // d & n inverted!!
-    { 0x0ff0f0f0, 0x016000a0, "smultb","nms" },   // d & n inverted!!
-    { 0x0ff0f0f0, 0x016000c0, "smulbt","nms" },   // d & n inverted!!
-    { 0x0ff0f0f0, 0x016000e0, "smultt","nms" },   // d & n inverted!!
-    { 0x00000000, 0x00000000, NULL,	NULL }
-};
-
-static char const arm32_insn_conditions[][4] = {
-	"eq", "ne", "cs", "cc",
-	"mi", "pl", "vs", "vc",
-	"hi", "ls", "ge", "lt",
-	"gt", "le", "",   "nv"
-};
-
-static char const insn_block_transfers[][4] = {
-	"da", "ia", "db", "ib"
-};
-
-static char const insn_stack_block_transfers[][4] = {
-	"ed", "ea", "fd", "fa"
-};
-
-static char const op_shifts[][4] = {
-	"lsl", "lsr", "asr", "ror"
-};
-
-static char const insn_fpa_rounding[][2] = {
-	"", "p", "m", "z"
-};
-
-static char const insn_fpa_precision[][2] = {
-	"s", "d", "e", "p"
-};
-
-static char const insn_fpaconstants[][8] = {
-	"0.0", "1.0", "2.0", "3.0",
-	"4.0", "5.0", "0.5", "10.0"
-};
-
-#define insn_condition(x)	arm32_insn_conditions[((x) >> 28) & 0x0f]
-#define insn_blktrans(x)	insn_block_transfers[((x) >> 23) & 3]
-#define insn_stkblktrans(x)	insn_stack_block_transfers[(3*(((x) >> 20)&1))^(((x) >> 23)&3)]
-#define op2_shift(x)		op_shifts[((x) >> 5) & 3]
-#define insn_fparnd(x)		insn_fpa_rounding[((x) >> 5) & 0x03]
-#define insn_fpaprec(x)		insn_fpa_precision[((((x) >> 18) & 2)|((x) >> 7)) & 1]
-#define insn_fpaprect(x)	insn_fpa_precision[((((x) >> 21) & 2)|((x) >> 15)) & 1]
-#define insn_fpaimm(x)		insn_fpaconstants[(x) & 0x07]
-
-/* Local prototypes */
-static void disasm_register_shift(const disasm_interface_t *di, u_int insn);
-static void disasm_print_reglist(const disasm_interface_t *di, u_int insn);
-static void disasm_insn_ldrstr(const disasm_interface_t *di, u_int insn,
-    u_int loc);
-static void disasm_insn_ldrhstrh(const disasm_interface_t *di, u_int insn,
-    u_int loc);
-static void disasm_insn_ldcstc(const disasm_interface_t *di, u_int insn,
-    u_int loc);
-static u_int disassemble_readword(u_int address);
-static void disassemble_printaddr(u_int address);
-
-u_int
-disasm(const disasm_interface_t *di, u_int loc, int __unused altfmt)
-{
-	const struct arm32_insn *i_ptr = &arm32_i[0];
-	u_int insn = di->di_readword(loc);
-	int matchp = 0;
-	int branch;
-	char* f_ptr;
-	int fmt = 0;
-
-/*	di->di_printf("loc=%08x insn=%08x : ", loc, insn);*/
-
-	while (i_ptr->name) {
-		if ((insn & i_ptr->mask) ==  i_ptr->pattern) {
-			matchp = 1;
-			break;
-		}
-		i_ptr++;
-	}
-
-	if (!matchp) {
-		di->di_printf("und%s\t%08x\n", insn_condition(insn), insn);
-		return(loc + INSN_SIZE);
-	}
-
-	/* If instruction forces condition code, don't print it. */
-	if ((i_ptr->mask & 0xf0000000) == 0xf0000000)
-		di->di_printf("%s", i_ptr->name);
-	else
-		di->di_printf("%s%s", i_ptr->name, insn_condition(insn));
-
-	f_ptr = i_ptr->format;
-
-	/* Insert tab if there are no instruction modifiers */
-
-	if (*(f_ptr) < 'A' || *(f_ptr) > 'Z') {
-		++fmt;
-		di->di_printf("\t");
-	}
-
-	while (*f_ptr) {
-		switch (*f_ptr) {
-		/* 2 - print Operand 2 of a data processing instruction */
-		case '2':
-			if (insn & 0x02000000) {
-				int rotate= ((insn >> 7) & 0x1e);
-
-				di->di_printf("#0x%08x",
-					      (insn & 0xff) << (32 - rotate) |
-					      (insn & 0xff) >> rotate);
-			} else {  
-				disasm_register_shift(di, insn);
-			}
-			break;
-		/* d - destination register (bits 12-15) */
-		case 'd':
-			di->di_printf("r%d", ((insn >> 12) & 0x0f));
-			break;
-		/* D - insert 'p' if Rd is R15 */
-		case 'D':
-			if (((insn >> 12) & 0x0f) == 15)
-				di->di_printf("p");
-			break;
-		/* n - n register (bits 16-19) */
-		case 'n':
-			di->di_printf("r%d", ((insn >> 16) & 0x0f));
-			break;
-		/* s - s register (bits 8-11) */
-		case 's':
-			di->di_printf("r%d", ((insn >> 8) & 0x0f));
-			break;
-		/* o - indirect register rn (bits 16-19) (used by swap) */
-		case 'o':
-			di->di_printf("[r%d]", ((insn >> 16) & 0x0f));
-			break;
-		/* m - m register (bits 0-4) */
-		case 'm':
-			di->di_printf("r%d", ((insn >> 0) & 0x0f));
-			break;
-		/* a - address operand of ldr/str instruction */
-		case 'a':
-			disasm_insn_ldrstr(di, insn, loc);
-			break;
-		/* e - address operand of ldrh/strh instruction */
-		case 'e':
-			disasm_insn_ldrhstrh(di, insn, loc);
-			break;
-		/* l - register list for ldm/stm instruction */
-		case 'l':
-			disasm_print_reglist(di, insn);
-			break;
-		/* f - 1st fp operand (register) (bits 12-14) */
-		case 'f':
-			di->di_printf("f%d", (insn >> 12) & 7);
-			break;
-		/* g - 2nd fp operand (register) (bits 16-18) */
-		case 'g':
-			di->di_printf("f%d", (insn >> 16) & 7);
-			break;
-		/* h - 3rd fp operand (register/immediate) (bits 0-4) */
-		case 'h':
-			if (insn & (1 << 3))
-				di->di_printf("#%s", insn_fpaimm(insn));
-			else
-				di->di_printf("f%d", insn & 7);
-			break;
-		/* j - xtb rotate literal (bits 10-11) */
-		case 'j':
-			di->di_printf("ror #%d", ((insn >> 10) & 3) << 3);
-			break;
-        /* i - bfx lsb literal (bits 7-11) */
-        case 'i':
-            di->di_printf("#%d", (insn >> 7) & 31);
-            break;
-        /* w - bfx width literal (bits 16-20) */
-        case 'w':
-            di->di_printf("#%d", 1 + ((insn >> 16) & 31));
-            break;
-		/* b - branch address */
-		case 'b':
-			branch = ((insn << 2) & 0x03ffffff);
-			if (branch & 0x02000000)
-				branch |= 0xfc000000;
-			di->di_printaddr(loc + 8 + branch);
-			break;
-		/* t - blx address */
-		case 't':
-			branch = ((insn << 2) & 0x03ffffff) |
-			    (insn >> 23 & 0x00000002);
-			if (branch & 0x02000000)
-				branch |= 0xfc000000;
-			di->di_printaddr(loc + 8 + branch);
-			break;
-		/* X - block transfer type */
-		case 'X':
-			di->di_printf("%s", insn_blktrans(insn));
-			break;
-		/* Y - block transfer type (r13 base) */
-		case 'Y':
-			di->di_printf("%s", insn_stkblktrans(insn));
-			break;
-		/* c - comment field bits(0-23) */
-		case 'c':
-			di->di_printf("0x%08x", (insn & 0x00ffffff));
-			break;
-		/* k - breakpoint comment (bits 0-3, 8-19) */
-		case 'k':
-			di->di_printf("0x%04x",
-			    (insn & 0x000fff00) >> 4 | (insn & 0x0000000f));
-			break;
-		/* p - saved or current status register */
-		case 'p':
-			if (insn & 0x00400000)
-				di->di_printf("spsr");
-			else
-				di->di_printf("cpsr");
-			break;
-		/* F - PSR transfer fields */
-		case 'F':
-			di->di_printf("_");
-			if (insn & (1 << 16))
-				di->di_printf("c");
-			if (insn & (1 << 17))
-				di->di_printf("x");
-			if (insn & (1 << 18))
-				di->di_printf("s");
-			if (insn & (1 << 19))
-				di->di_printf("f");
-			break;
-		/* B - byte transfer flag */
-		case 'B':
-			if (insn & 0x00400000)
-				di->di_printf("b");
-			break;
-		/* L - co-processor transfer size */
-		case 'L':
-			if (insn & (1 << 22))
-				di->di_printf("l");
-			break;
-		/* S - set status flag */
-		case 'S':
-			if (insn & 0x00100000)
-				di->di_printf("s");
-			break;
-		/* P - fp precision */
-		case 'P':
-			di->di_printf("%s", insn_fpaprec(insn));
-			break;
-		/* Q - fp precision (for ldf/stf) */
-		case 'Q':
-			break;
-		/* R - fp rounding */
-		case 'R':
-			di->di_printf("%s", insn_fparnd(insn));
-			break;
-		/* W - writeback flag */
-		case 'W':
-			if (insn & (1 << 21))
-				di->di_printf("!");
-			break;
-		/* # - co-processor number */
-		case '#':
-			di->di_printf("p%d", (insn >> 8) & 0x0f);
-			break;
-		/* v - co-processor data transfer registers+addressing mode */
-		case 'v':
-			disasm_insn_ldcstc(di, insn, loc);
-			break;
-		/* x - instruction in hex */
-		case 'x':
-			di->di_printf("0x%08x", insn);
-			break;
-		/* y - co-processor data processing registers */
-		case 'y':
-			di->di_printf("%d, ", (insn >> 20) & 0x0f);
-
-			di->di_printf("c%d, c%d, c%d", (insn >> 12) & 0x0f,
-			    (insn >> 16) & 0x0f, insn & 0x0f);
-
-			di->di_printf(", %d", (insn >> 5) & 0x07);
-			break;
-		/* z - co-processor register transfer registers */
-		case 'z':
-			di->di_printf("%d, ", (insn >> 21) & 0x07);
-			di->di_printf("r%d, c%d, c%d, %d",
-			    (insn >> 12) & 0x0f, (insn >> 16) & 0x0f,
-			    insn & 0x0f, (insn >> 5) & 0x07);
-
-/*			if (((insn >> 5) & 0x07) != 0)
-				di->di_printf(", %d", (insn >> 5) & 0x07);*/
-			break;
-		default:
-			di->di_printf("[%c - unknown]", *f_ptr);
-			break;
-		}
-		if (*(f_ptr+1) >= 'A' && *(f_ptr+1) <= 'Z')
-			++f_ptr;
-		else if (*(++f_ptr)) {
-			++fmt;
-			if (fmt == 1)
-				di->di_printf("\t");
-			else
-				di->di_printf(", ");
-		}
-	};
-
-	di->di_printf("\n");
-
-	return(loc + INSN_SIZE);
-}
-
-
-static void
-disasm_register_shift(const disasm_interface_t *di, u_int insn)
-{
-	di->di_printf("r%d", (insn & 0x0f));
-	if ((insn & 0x00000ff0) == 0)
-		;
-	else if ((insn & 0x00000ff0) == 0x00000060)
-		di->di_printf(", rrx");
-	else {
-		if (insn & 0x10)
-			di->di_printf(", %s r%d", op2_shift(insn),
-			    (insn >> 8) & 0x0f);
-		else
-			di->di_printf(", %s #%d", op2_shift(insn),
-			    (insn >> 7) & 0x1f);
-	}
-}
-
-
-static void
-disasm_print_reglist(const disasm_interface_t *di, u_int insn)
-{
-	int loop;
-	int start;
-	int comma;
-
-	di->di_printf("{");
-	start = -1;
-	comma = 0;
-
-	for (loop = 0; loop < 17; ++loop) {
-		if (start != -1) {
-			if (loop == 16 || !(insn & (1 << loop))) {
-				if (comma)
-					di->di_printf(", ");
-				else
-					comma = 1;
-        			if (start == loop - 1)
-        				di->di_printf("r%d", start);
-        			else
-        				di->di_printf("r%d-r%d", start, loop - 1);
-        			start = -1;
-        		}
-        	} else {
-        		if (insn & (1 << loop))
-        			start = loop;
-        	}
-        }
-	di->di_printf("}");
-
-	if (insn & (1 << 22))
-		di->di_printf("^");
-}
-
-static void
-disasm_insn_ldrstr(const disasm_interface_t *di, u_int insn, u_int loc)
-{
-	int offset;
-
-	offset = insn & 0xfff;
-	if ((insn & 0x032f0000) == 0x010f0000) {
-		/* rA = pc, immediate index */
-		if (insn & 0x00800000)
-			loc += offset;
-		else
-			loc -= offset;
-		di->di_printaddr(loc + 8);
- 	} else {
-		di->di_printf("[r%d", (insn >> 16) & 0x0f);
-		if ((insn & 0x03000fff) != 0x01000000) {
-			di->di_printf("%s, ", (insn & (1 << 24)) ? "" : "]");
-			if (!(insn & 0x00800000))
-				di->di_printf("-");
-			if (insn & (1 << 25))
-				disasm_register_shift(di, insn);
-			else
-				di->di_printf("#0x%03x", offset);
-		}
-		if (insn & (1 << 24))
-			di->di_printf("]");
-	}
-}
-
-static void
-disasm_insn_ldrhstrh(const disasm_interface_t *di, u_int insn, u_int loc)
-{
-	int offset;
-
-	offset = ((insn & 0xf00) >> 4) | (insn & 0xf);
-	if ((insn & 0x004f0000) == 0x004f0000) {
-		/* rA = pc, immediate index */
-		if (insn & 0x00800000)
-			loc += offset;
-		else
-			loc -= offset;
-		di->di_printaddr(loc + 8);
- 	} else {
-		di->di_printf("[r%d", (insn >> 16) & 0x0f);
-		if ((insn & 0x01400f0f) != 0x01400000) {
-			di->di_printf("%s, ", (insn & (1 << 24)) ? "" : "]");
-			if (!(insn & 0x00800000))
-				di->di_printf("-");
-			if (insn & (1 << 22))
-				di->di_printf("#0x%02x", offset);
-			else
-				di->di_printf("r%d", (insn & 0x0f));
-		}
-		if (insn & (1 << 24))
-			di->di_printf("]");
-	}
-}
-
-static void
-disasm_insn_ldcstc(const disasm_interface_t *di, u_int insn, u_int __unused loc)
-{
-	if (((insn >> 8) & 0xf) == 1)
-		di->di_printf("f%d, ", (insn >> 12) & 0x07);
-	else
-		di->di_printf("c%d, ", (insn >> 12) & 0x0f);
-
-	di->di_printf("[r%d", (insn >> 16) & 0x0f);
-
-	di->di_printf("%s, ", (insn & (1 << 24)) ? "" : "]");
-
-	if (!(insn & (1 << 23)))
-		di->di_printf("-");
-
-	di->di_printf("#0x%03x", (insn & 0xff) << 2);
-
-	if (insn & (1 << 24))
-		di->di_printf("]");
-
-	if (insn & (1 << 21))
-		di->di_printf("!");
-}
-
-static u_int
-disassemble_readword(u_int address)
-{
-	return(*((u_int *)address));
-}
-
-static void
-disassemble_printaddr(u_int address)
-{
-	printf("0x%08x", address);
-}
-
-static const disasm_interface_t disassemble_di = {
-	disassemble_readword, disassemble_printaddr, printf
-};
-
-void
-disassemble(u_int address)
-{
-
-	(void)disasm(&disassemble_di, address, 0);
-}
-
-/* End of disassem.c */
diff --git a/libpixelflinger/codeflinger/disassem.h b/libpixelflinger/codeflinger/disassem.h
deleted file mode 100644
index c7c60b6..0000000
--- a/libpixelflinger/codeflinger/disassem.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*	$NetBSD: disassem.h,v 1.4 2001/03/04 04:15:58 matt Exp $	*/
-
-/*-
- * Copyright (c) 1997 Mark Brinicombe.
- * Copyright (c) 1997 Causality Limited.
- *
- * 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 Mark Brinicombe.
- * 4. The name of the company nor the name of the author may 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 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 the interface structure required by the disassembler.
- *
- * $FreeBSD: /repoman/r/ncvs/src/sys/arm/include/disassem.h,v 1.2 2005/01/05 21:58:48 imp Exp $
- */
-
-#ifndef ANDROID_MACHINE_DISASSEM_H
-#define ANDROID_MACHINE_DISASSEM_H
-
-#include <sys/types.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
-	u_int	(*di_readword)(u_int);
-	void	(*di_printaddr)(u_int);
-	int	(*di_printf)(const char *, ...);
-} disasm_interface_t;
-
-/* Prototypes for callable functions */
-
-u_int disasm(const disasm_interface_t *, u_int, int);
-void disassemble(u_int);
-
-#if __cplusplus
-}
-#endif
-
-#endif /* !ANDROID_MACHINE_DISASSEM_H */
diff --git a/libpixelflinger/codeflinger/load_store.cpp b/libpixelflinger/codeflinger/load_store.cpp
deleted file mode 100644
index 4db0a49..0000000
--- a/libpixelflinger/codeflinger/load_store.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/* libs/pixelflinger/codeflinger/load_store.cpp
-**
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "pixelflinger-code"
-
-#include <assert.h>
-#include <stdio.h>
-
-#include <log/log.h>
-
-#include "GGLAssembler.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-void GGLAssembler::store(const pointer_t& addr, const pixel_t& s, uint32_t flags)
-{
-    const int bits = addr.size;
-    const int inc = (flags & WRITE_BACK)?1:0;
-    switch (bits) {
-    case 32:
-        if (inc)    STR(AL, s.reg, addr.reg, immed12_post(4));
-        else        STR(AL, s.reg, addr.reg);
-        break;
-    case 24:
-        // 24 bits formats are a little special and used only for RGB
-        // 0x00BBGGRR is unpacked as R,G,B
-        STRB(AL, s.reg, addr.reg, immed12_pre(0));
-        MOV(AL, 0, s.reg, reg_imm(s.reg, ROR, 8));
-        STRB(AL, s.reg, addr.reg, immed12_pre(1));
-        MOV(AL, 0, s.reg, reg_imm(s.reg, ROR, 8));
-        STRB(AL, s.reg, addr.reg, immed12_pre(2));
-        if (!(s.flags & CORRUPTIBLE)) {
-            MOV(AL, 0, s.reg, reg_imm(s.reg, ROR, 16));
-        }
-        if (inc)
-            ADD(AL, 0, addr.reg, addr.reg, imm(3));
-        break;
-    case 16:
-        if (inc)    STRH(AL, s.reg, addr.reg, immed8_post(2));
-        else        STRH(AL, s.reg, addr.reg);
-        break;
-    case  8:
-        if (inc)    STRB(AL, s.reg, addr.reg, immed12_post(1));
-        else        STRB(AL, s.reg, addr.reg);
-        break;
-    }
-}
-
-void GGLAssembler::load(const pointer_t& addr, const pixel_t& s, uint32_t flags)
-{
-    Scratch scratches(registerFile());
-    int s0;
-
-    const int bits = addr.size;
-    const int inc = (flags & WRITE_BACK)?1:0;
-    switch (bits) {
-    case 32:
-        if (inc)    LDR(AL, s.reg, addr.reg, immed12_post(4));
-        else        LDR(AL, s.reg, addr.reg);
-        break;
-    case 24:
-        // 24 bits formats are a little special and used only for RGB
-        // R,G,B is packed as 0x00BBGGRR
-        s0 = scratches.obtain();
-        if (s.reg != addr.reg) {
-            LDRB(AL, s.reg, addr.reg, immed12_pre(0));      // R
-            LDRB(AL, s0, addr.reg, immed12_pre(1));         // G
-            ORR(AL, 0, s.reg, s.reg, reg_imm(s0, LSL, 8));
-            LDRB(AL, s0, addr.reg, immed12_pre(2));         // B
-            ORR(AL, 0, s.reg, s.reg, reg_imm(s0, LSL, 16));
-        } else {
-            int s1 = scratches.obtain();
-            LDRB(AL, s1, addr.reg, immed12_pre(0));         // R
-            LDRB(AL, s0, addr.reg, immed12_pre(1));         // G
-            ORR(AL, 0, s1, s1, reg_imm(s0, LSL, 8));
-            LDRB(AL, s0, addr.reg, immed12_pre(2));         // B
-            ORR(AL, 0, s.reg, s1, reg_imm(s0, LSL, 16));
-        }
-        if (inc)
-            ADD(AL, 0, addr.reg, addr.reg, imm(3));
-        break;
-    case 16:
-        if (inc)    LDRH(AL, s.reg, addr.reg, immed8_post(2));
-        else        LDRH(AL, s.reg, addr.reg);
-        break;
-    case  8:
-        if (inc)    LDRB(AL, s.reg, addr.reg, immed12_post(1));
-        else        LDRB(AL, s.reg, addr.reg);
-        break;
-    }
-}
-
-void GGLAssembler::extract(integer_t& d, int s, int h, int l, int bits)
-{
-    const int maskLen = h-l;
-
-#ifdef __mips__
-    assert(maskLen<=11);
-#else
-    assert(maskLen<=8);
-#endif
-    assert(h);
-
-    if (h != bits) {
-        const int mask = ((1<<maskLen)-1) << l;
-        if (isValidImmediate(mask)) {
-            AND(AL, 0, d.reg, s, imm(mask));    // component = packed & mask;
-        } else if (isValidImmediate(~mask)) {
-            BIC(AL, 0, d.reg, s, imm(~mask));   // component = packed & mask;
-        } else {
-            MOV(AL, 0, d.reg, reg_imm(s, LSL, 32-h));
-            l += 32-h;
-            h = 32;
-        }
-        s = d.reg;
-    }
-
-    if (l) {
-        MOV(AL, 0, d.reg, reg_imm(s, LSR, l));  // component = packed >> l;
-        s = d.reg;
-    }
-
-    if (s != d.reg) {
-        MOV(AL, 0, d.reg, s);
-    }
-
-    d.s = maskLen;
-}
-
-void GGLAssembler::extract(integer_t& d, const pixel_t& s, int component)
-{
-    extract(d,  s.reg,
-                s.format.c[component].h,
-                s.format.c[component].l,
-                s.size());
-}
-
-void GGLAssembler::extract(component_t& d, const pixel_t& s, int component)
-{
-    integer_t r(d.reg, 32, d.flags);
-    extract(r,  s.reg,
-                s.format.c[component].h,
-                s.format.c[component].l,
-                s.size());
-    d = component_t(r);
-}
-
-
-void GGLAssembler::expand(integer_t& d, const component_t& s, int dbits)
-{
-    if (s.l || (s.flags & CLEAR_HI)) {
-        extract(d, s.reg, s.h, s.l, 32);
-        expand(d, d, dbits);
-    } else {
-        expand(d, integer_t(s.reg, s.size(), s.flags), dbits);
-    }
-}
-
-void GGLAssembler::expand(component_t& d, const component_t& s, int dbits)
-{
-    integer_t r(d.reg, 32, d.flags);
-    expand(r, s, dbits);
-    d = component_t(r);
-}
-
-void GGLAssembler::expand(integer_t& dst, const integer_t& src, int dbits)
-{
-    assert(src.size());
-
-    int sbits = src.size();
-    int s = src.reg;
-    int d = dst.reg;
-
-    // be sure to set 'dst' after we read 'src' as they may be identical
-    dst.s = dbits;
-    dst.flags = 0;
-
-    if (dbits<=sbits) {
-        if (s != d) {
-            MOV(AL, 0, d, s);
-        }
-        return;
-    }
-
-    if (sbits == 1) {
-        RSB(AL, 0, d, s, reg_imm(s, LSL, dbits));
-            // d = (s<<dbits) - s;
-        return;
-    }
-
-    if (dbits % sbits) {
-        MOV(AL, 0, d, reg_imm(s, LSL, dbits-sbits));
-            // d = s << (dbits-sbits);
-        dbits -= sbits;
-        do {
-            ORR(AL, 0, d, d, reg_imm(d, LSR, sbits));
-                // d |= d >> sbits;
-            dbits -= sbits;
-            sbits *= 2;
-        } while(dbits>0);
-        return;
-    }
-
-    dbits -= sbits;
-    do {
-        ORR(AL, 0, d, s, reg_imm(s, LSL, sbits));
-            // d |= d<<sbits;
-        s = d;
-        dbits -= sbits;
-        if (sbits*2 < dbits) {
-            sbits *= 2;
-        }
-    } while(dbits>0);
-}
-
-void GGLAssembler::downshift(
-        pixel_t& d, int component, component_t s, const reg_t& dither)
-{
-    Scratch scratches(registerFile());
-
-    int sh = s.h;
-    int sl = s.l;
-    int maskHiBits = (sh!=32) ? ((s.flags & CLEAR_HI)?1:0) : 0;
-    int maskLoBits = (sl!=0)  ? ((s.flags & CLEAR_LO)?1:0) : 0;
-    int sbits = sh - sl;
-
-    int dh = d.format.c[component].h;
-    int dl = d.format.c[component].l;
-    int dbits = dh - dl;
-    int dithering = 0;
-
-    ALOGE_IF(sbits<dbits, "sbits (%d) < dbits (%d) in downshift", sbits, dbits);
-
-    if (sbits>dbits) {
-        // see if we need to dither
-        dithering = mDithering;
-    }
-
-    int ireg = d.reg;
-    if (!(d.flags & FIRST)) {
-        if (s.flags & CORRUPTIBLE)  {
-            ireg = s.reg;
-        } else {
-            ireg = scratches.obtain();
-        }
-    }
-    d.flags &= ~FIRST;
-
-    if (maskHiBits) {
-        // we need to mask the high bits (and possibly the lowbits too)
-        // and we might be able to use immediate mask.
-        if (!dithering) {
-            // we don't do this if we only have maskLoBits because we can
-            // do it more efficiently below (in the case where dl=0)
-            const int offset = sh - dbits;
-            if (dbits<=8 && offset >= 0) {
-                const uint32_t mask = ((1<<dbits)-1) << offset;
-                if (isValidImmediate(mask) || isValidImmediate(~mask)) {
-                    build_and_immediate(ireg, s.reg, mask, 32);
-                    sl = offset;
-                    s.reg = ireg;
-                    sbits = dbits;
-                    maskLoBits = maskHiBits = 0;
-                }
-            }
-        } else {
-            // in the dithering case though, we need to preserve the lower bits
-            const uint32_t mask = ((1<<sbits)-1) << sl;
-            if (isValidImmediate(mask) || isValidImmediate(~mask)) {
-                build_and_immediate(ireg, s.reg, mask, 32);
-                s.reg = ireg;
-                maskLoBits = maskHiBits = 0;
-            }
-        }
-    }
-
-    // XXX: we could special case (maskHiBits & !maskLoBits)
-    // like we do for maskLoBits below, but it happens very rarely
-    // that we have maskHiBits only and the conditions necessary to lead
-    // to better code (like doing d |= s << 24)
-
-    if (maskHiBits) {
-        MOV(AL, 0, ireg, reg_imm(s.reg, LSL, 32-sh));
-        sl += 32-sh;
-        sh = 32;
-        s.reg = ireg;
-        maskHiBits = 0;
-    }
-
-    //	Downsampling should be performed as follows:
-    //  V * ((1<<dbits)-1) / ((1<<sbits)-1)
-    //	V * [(1<<dbits)/((1<<sbits)-1)	-	1/((1<<sbits)-1)]
-    //	V * [1/((1<<sbits)-1)>>dbits	-	1/((1<<sbits)-1)]
-    //	V/((1<<(sbits-dbits))-(1>>dbits))	-	(V>>sbits)/((1<<sbits)-1)>>sbits
-    //	V/((1<<(sbits-dbits))-(1>>dbits))	-	(V>>sbits)/(1-(1>>sbits))
-    //
-    //	By approximating (1>>dbits) and (1>>sbits) to 0:
-    //
-    //		V>>(sbits-dbits)	-	V>>sbits
-    //
-	//  A good approximation is V>>(sbits-dbits),
-    //  but better one (needed for dithering) is:
-    //
-    //		(V>>(sbits-dbits)<<sbits	-	V)>>sbits
-    //		(V<<dbits	-	V)>>sbits
-    //		(V	-	V>>dbits)>>(sbits-dbits)
-
-    // Dithering is done here
-    if (dithering) {
-        comment("dithering");
-        if (sl) {
-            MOV(AL, 0, ireg, reg_imm(s.reg, LSR, sl));
-            sh -= sl;
-            sl = 0;
-            s.reg = ireg;
-        }
-        // scaling (V-V>>dbits)
-        SUB(AL, 0, ireg, s.reg, reg_imm(s.reg, LSR, dbits));
-        const int shift = (GGL_DITHER_BITS - (sbits-dbits));
-        if (shift>0)        ADD(AL, 0, ireg, ireg, reg_imm(dither.reg, LSR, shift));
-        else if (shift<0)   ADD(AL, 0, ireg, ireg, reg_imm(dither.reg, LSL,-shift));
-        else                ADD(AL, 0, ireg, ireg, dither.reg);
-        s.reg = ireg;
-    }
-
-    if ((maskLoBits|dithering) && (sh > dbits)) {
-        int shift = sh-dbits;
-        if (dl) {
-            MOV(AL, 0, ireg, reg_imm(s.reg, LSR, shift));
-            if (ireg == d.reg) {
-                MOV(AL, 0, d.reg, reg_imm(ireg, LSL, dl));
-            } else {
-                ORR(AL, 0, d.reg, d.reg, reg_imm(ireg, LSL, dl));
-            }
-        } else {
-            if (ireg == d.reg) {
-                MOV(AL, 0, d.reg, reg_imm(s.reg, LSR, shift));
-            } else {
-                ORR(AL, 0, d.reg, d.reg, reg_imm(s.reg, LSR, shift));
-            }
-        }
-    } else {
-        int shift = sh-dh;
-        if (shift>0) {
-            if (ireg == d.reg) {
-                MOV(AL, 0, d.reg, reg_imm(s.reg, LSR, shift));
-            } else {
-                ORR(AL, 0, d.reg, d.reg, reg_imm(s.reg, LSR, shift));
-            }
-        } else if (shift<0) {
-            if (ireg == d.reg) {
-                MOV(AL, 0, d.reg, reg_imm(s.reg, LSL, -shift));
-            } else {
-                ORR(AL, 0, d.reg, d.reg, reg_imm(s.reg, LSL, -shift));
-            }
-        } else {
-            if (ireg == d.reg) {
-                if (s.reg != d.reg) {
-                    MOV(AL, 0, d.reg, s.reg);
-                }
-            } else {
-                ORR(AL, 0, d.reg, d.reg, s.reg);
-            }
-        }
-    }
-}
-
-}; // namespace android
diff --git a/libpixelflinger/codeflinger/mips64_disassem.c b/libpixelflinger/codeflinger/mips64_disassem.c
deleted file mode 100644
index 8528299..0000000
--- a/libpixelflinger/codeflinger/mips64_disassem.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/*  $NetBSD: db_disasm.c,v 1.19 2007/02/28 04:21:53 thorpej Exp $   */
-
-/*-
- * Copyright (c) 1991, 1993
- *  The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * 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.
- *
- *  from: @(#)kadb.c    8.1 (Berkeley) 6/10/93
- */
-
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <android/log.h>
-
-#include "mips_opcode.h"
-
-#define __unused __attribute__((__unused__))
-
-static char *sprintf_buffer;
-static int sprintf_buf_len;
-
-typedef uint64_t db_addr_t;
-static void db_printf(const char* fmt, ...);
-
-static const char * const op_name[64] = {
-/* 0 */ "spec", "bcond", "j", "jal", "beq", "bne", "blez", "bgtz",
-/* 8 */ "pop10", "addiu", "slti", "sltiu", "andi", "ori", "xori", "aui",
-/*16 */ "cop0", "cop1", "cop2", "?", "?", "?", "pop26", "pop27",
-/*24 */ "pop30", "daddiu", "?", "?", "?", "daui", "msa", "op37",
-/*32 */ "lb", "lh", "?",  "lw", "lbu", "lhu", "?", "lwu",
-/*40 */ "sb", "sh", "?", "sw", "?", "?", "?", "?",
-/*48 */ "?", "lwc1", "bc", "?", "?",  "ldc1", "pop66", "ld",
-/*56 */ "?", "swc1", "balc", "pcrel", "?", "sdc1", "pop76", "sd"
-};
-
-static const char * const spec_name[64] = {
-/* 0 */ "sll", "?", "srl", "sra", "sllv", "?", "srlv", "srav",
-/* 8 */ "?", "jalr", "?", "?", "syscall", "break", "sdbpp", "sync",
-/*16 */ "clz", "clo", "dclz", "dclo", "dsllv", "dlsa", "dsrlv", "dsrav",
-/*24 */ "sop30", "sop31", "sop32", "sop33", "sop34", "sop35", "sop36", "sop37",
-/*32 */ "add", "addu", "sub", "subu", "and", "or", "xor", "nor",
-/*40 */ "?", "?", "slt", "sltu", "dadd", "daddu", "dsub", "dsubu",
-/*48 */ "tge", "tgeu", "tlt", "tltu", "teq", "seleqz", "tne", "selnez",
-/*56 */ "dsll", "?", "dsrl", "dsra", "dsll32", "?", "dsrl32", "dsra32"
-};
-
-static const char * const bcond_name[32] = {
-/* 0 */ "bltz", "bgez", "?", "?", "?", "?", "dahi", "?",
-/* 8 */ "?", "?", "?", "?", "?", "?", "?", "?",
-/*16 */ "nal", "bal", "?", "?", "?", "?", "?", "sigrie",
-/*24 */ "?", "?", "?", "?", "?", "?", "dati", "synci",
-};
-
-static const char * const cop1_name[64] = {
-/* 0 */ "fadd",  "fsub", "fmpy", "fdiv", "fsqrt","fabs", "fmov", "fneg",
-/* 8 */ "fop08","fop09","fop0a","fop0b","fop0c","fop0d","fop0e","fop0f",
-/*16 */ "fop10","fop11","fop12","fop13","fop14","fop15","fop16","fop17",
-/*24 */ "fop18","fop19","fop1a","fop1b","fop1c","fop1d","fop1e","fop1f",
-/*32 */ "fcvts","fcvtd","fcvte","fop23","fcvtw","fop25","fop26","fop27",
-/*40 */ "fop28","fop29","fop2a","fop2b","fop2c","fop2d","fop2e","fop2f",
-/*48 */ "fcmp.f","fcmp.un","fcmp.eq","fcmp.ueq","fcmp.olt","fcmp.ult",
-    "fcmp.ole","fcmp.ule",
-/*56 */ "fcmp.sf","fcmp.ngle","fcmp.seq","fcmp.ngl","fcmp.lt","fcmp.nge",
-    "fcmp.le","fcmp.ngt"
-};
-
-static const char * const fmt_name[16] = {
-    "s",    "d",    "e",    "fmt3",
-    "w",    "fmt5", "fmt6", "fmt7",
-    "fmt8", "fmt9", "fmta", "fmtb",
-    "fmtc", "fmtd", "fmte", "fmtf"
-};
-
-static char * const mips_reg_name[32] = {
-    "zero", "at",   "v0",   "v1",   "a0",   "a1",   "a2",   "a3",
-    "a4",   "a5",   "a6",   "a7",   "t0",   "t1",   "t2",   "t3",
-    "s0",   "s1",   "s2",   "s3",   "s4",   "s5",   "s6",   "s7",
-    "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "s8",   "ra"
-};
-
-static char * alt_arm_reg_name[32] = {  // hacked names for comparison with ARM code
-    "zero", "at",   "r0",   "r1",   "r2",   "r3",   "r4",   "r5",
-    "r6",   "r7",   "r8",   "r9",   "r10",  "r11",  "r12",  "r13",
-    "r14",  "r15",  "at2",  "cmp",  "s4",   "s5",   "s6",   "s7",
-    "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "s8",   "ra"
-};
-
-static char * const * reg_name =  &mips_reg_name[0];
-
-static const char * const c0_opname[64] = {
-    "c0op00","tlbr",  "tlbwi", "c0op03","c0op04","c0op05","tlbwr", "c0op07",
-    "tlbp",  "c0op11","c0op12","c0op13","c0op14","c0op15","c0op16","c0op17",
-    "rfe",   "c0op21","c0op22","c0op23","c0op24","c0op25","c0op26","c0op27",
-    "eret",  "c0op31","c0op32","c0op33","c0op34","c0op35","c0op36","c0op37",
-    "c0op40","c0op41","c0op42","c0op43","c0op44","c0op45","c0op46","c0op47",
-    "c0op50","c0op51","c0op52","c0op53","c0op54","c0op55","c0op56","c0op57",
-    "c0op60","c0op61","c0op62","c0op63","c0op64","c0op65","c0op66","c0op67",
-    "c0op70","c0op71","c0op72","c0op73","c0op74","c0op75","c0op77","c0op77",
-};
-
-static const char * const c0_reg[32] = {
-    "index",    "random",   "tlblo0",  "tlblo1",
-    "context",  "pagemask", "wired",   "cp0r7",
-    "badvaddr", "count",    "tlbhi",   "compare",
-    "status",   "cause",    "epc",     "prid",
-    "config",   "lladdr",   "watchlo", "watchhi",
-    "xcontext", "cp0r21",   "cp0r22",  "debug",
-    "depc",     "perfcnt",  "ecc",     "cacheerr",
-    "taglo",    "taghi",    "errepc",  "desave"
-};
-
-static void print_addr(db_addr_t);
-db_addr_t mips_disassem(db_addr_t loc, char *di_buffer, int alt_dis_format);
-
-
-/*
- * Disassemble instruction 'insn' nominally at 'loc'.
- * 'loc' may in fact contain a breakpoint instruction.
- */
-static db_addr_t
-db_disasm_insn(int insn, db_addr_t loc, bool altfmt __unused)
-{
-    bool bdslot = false;
-    InstFmt i;
-
-    i.word = insn;
-
-    switch (i.JType.op) {
-    case OP_SPECIAL:
-        if (i.word == 0) {
-            db_printf("nop");
-            break;
-        }
-        if (i.word == 0x0080) {
-            db_printf("NIY");
-            break;
-        }
-        if (i.word == 0x00c0) {
-            db_printf("NOT IMPL");
-            break;
-        }
-        /* Special cases --------------------------------------------------
-         * "addu" is a "move" only in 32-bit mode.  What's the correct
-         * answer - never decode addu/daddu as "move"?
-         */
-        if ( (i.RType.func == OP_ADDU && i.RType.rt == 0)  ||
-             (i.RType.func == OP_OR   && i.RType.rt == 0) ) {
-            db_printf("move\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rs]);
-            break;
-        }
-
-        if (i.RType.func == OP_SRL && (i.RType.rs & 1) == 1) {
-            db_printf("rotr\t%s,%s,%d", reg_name[i.RType.rd],
-                reg_name[i.RType.rt], i.RType.shamt);
-            break;
-        }
-        if (i.RType.func == OP_SRLV && (i.RType.shamt & 1) == 1) {
-            db_printf("rotrv\t%s,%s,%s", reg_name[i.RType.rd],
-                reg_name[i.RType.rt], reg_name[i.RType.rs]);
-            break;
-        }
-
-        if (i.RType.func == OP_SOP30) {
-            if (i.RType.shamt == OP_MUL) {
-                db_printf("mul");
-            } else if (i.RType.shamt == OP_MUH) {
-                db_printf("muh");
-            }
-            db_printf("\t%s,%s,%s", reg_name[i.RType.rd],
-                reg_name[i.RType.rs], reg_name[i.RType.rt]);
-            break;
-        }
-        if (i.RType.func == OP_SOP31) {
-            if (i.RType.shamt == OP_MUL) {
-                db_printf("mulu");
-            } else if (i.RType.shamt == OP_MUH) {
-                db_printf("muhu");
-            }
-            db_printf("\t%s,%s,%s", reg_name[i.RType.rd],
-                reg_name[i.RType.rs], reg_name[i.RType.rt]);
-            break;
-        }
-
-        if (i.RType.func == OP_JALR && i.RType.rd == 0) {
-            db_printf("jr\t%s", reg_name[i.RType.rs]);
-            bdslot = true;
-            break;
-        }
-
-        db_printf("%s", spec_name[i.RType.func]);
-        switch (i.RType.func) {
-        case OP_SLL:
-        case OP_SRL:
-        case OP_SRA:
-        case OP_DSLL:
-
-        case OP_DSRL:
-        case OP_DSRA:
-        case OP_DSLL32:
-        case OP_DSRL32:
-        case OP_DSRA32:
-            db_printf("\t%s,%s,%d",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt],
-                i.RType.shamt);
-            break;
-
-        case OP_SLLV:
-        case OP_SRLV:
-        case OP_SRAV:
-        case OP_DSLLV:
-        case OP_DSRLV:
-        case OP_DSRAV:
-            db_printf("\t%s,%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt],
-                reg_name[i.RType.rs]);
-            break;
-
-        case OP_CLZ:
-        case OP_CLO:
-        case OP_DCLZ:
-        case OP_DCLO:
-            db_printf("\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rs]);
-            break;
-
-        case OP_JALR:
-            db_printf("\t");
-            if (i.RType.rd != 31) {
-                db_printf("%s,", reg_name[i.RType.rd]);
-            }
-            db_printf("%s", reg_name[i.RType.rs]);
-            bdslot = true;
-            break;
-
-        case OP_SYSCALL:
-        case OP_SYNC:
-            break;
-
-        case OP_BREAK:
-            db_printf("\t%d", (i.RType.rs << 5) | i.RType.rt);
-            break;
-
-        default:
-            db_printf("\t%s,%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rs],
-                reg_name[i.RType.rt]);
-        }
-        break;
-
-    case OP_SPECIAL3:
-        if (i.RType.func == OP_EXT)
-            db_printf("ext\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd+1);
-        else if (i.RType.func == OP_DEXT)
-            db_printf("dext\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd+1);
-        else if (i.RType.func == OP_DEXTM)
-            db_printf("dextm\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd+33);
-        else if (i.RType.func == OP_DEXTU)
-            db_printf("dextu\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt+32,
-                    i.RType.rd+1);
-        else if (i.RType.func == OP_INS)
-            db_printf("ins\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd-i.RType.shamt+1);
-        else if (i.RType.func == OP_DINS)
-            db_printf("dins\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd-i.RType.shamt+1);
-        else if (i.RType.func == OP_DINSM)
-            db_printf("dinsm\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd-i.RType.shamt+33);
-        else if (i.RType.func == OP_DINSU)
-            db_printf("dinsu\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt+32,
-                    i.RType.rd-i.RType.shamt+1);
-        else if (i.RType.func == OP_BSHFL && i.RType.shamt == OP_WSBH)
-            db_printf("wsbh\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt]);
-        else if (i.RType.func == OP_BSHFL && i.RType.shamt == OP_SEB)
-            db_printf("seb\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt]);
-        else if (i.RType.func == OP_BSHFL && i.RType.shamt == OP_SEH)
-            db_printf("seh\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt]);
-        else if (i.RType.func == OP_RDHWR)
-            db_printf("rdhwr\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt]);
-        else
-            db_printf("Unknown");
-        break;
-
-    case OP_BCOND:
-        db_printf("%s\t%s,", bcond_name[i.IType.rt],
-            reg_name[i.IType.rs]);
-        goto pr_displ;
-
-    case OP_BLEZ:
-    case OP_BGTZ:
-        db_printf("%s\t%s,", op_name[i.IType.op],
-            reg_name[i.IType.rs]);
-        goto pr_displ;
-
-    case OP_BEQ:
-        if (i.IType.rs == 0 && i.IType.rt == 0) {
-            db_printf("b\t");
-            goto pr_displ;
-        }
-        /* FALLTHROUGH */
-    case OP_BNE:
-        db_printf("%s\t%s,%s,", op_name[i.IType.op],
-            reg_name[i.IType.rs],
-            reg_name[i.IType.rt]);
-    pr_displ:
-        print_addr(loc + 4 + ((short)i.IType.imm << 2));
-        bdslot = true;
-        break;
-
-    case OP_COP0:
-        switch (i.RType.rs) {
-        case OP_BCx:
-        case OP_BCy:
-
-            db_printf("bc0%c\t",
-                "ft"[i.RType.rt & COPz_BC_TF_MASK]);
-            goto pr_displ;
-
-        case OP_MT:
-            db_printf("mtc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        case OP_DMT:
-            db_printf("dmtc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        case OP_MF:
-            db_printf("mfc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        case OP_DMF:
-            db_printf("dmfc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        default:
-            db_printf("%s", c0_opname[i.FRType.func]);
-        }
-        break;
-
-    case OP_COP1:
-        switch (i.RType.rs) {
-        case OP_BCx:
-        case OP_BCy:
-            db_printf("bc1%c\t",
-                "ft"[i.RType.rt & COPz_BC_TF_MASK]);
-            goto pr_displ;
-
-        case OP_MT:
-            db_printf("mtc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        case OP_MF:
-            db_printf("mfc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        case OP_CT:
-            db_printf("ctc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        case OP_CF:
-            db_printf("cfc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        default:
-            db_printf("%s.%s\tf%d,f%d,f%d",
-                cop1_name[i.FRType.func],
-                fmt_name[i.FRType.fmt],
-                i.FRType.fd, i.FRType.fs, i.FRType.ft);
-        }
-        break;
-
-    case OP_J:
-    case OP_JAL:
-        db_printf("%s\t", op_name[i.JType.op]);
-        print_addr((loc & 0xFFFFFFFFF0000000) | (i.JType.target << 2));
-        bdslot = true;
-        break;
-
-    case OP_LWC1:
-    case OP_SWC1:
-        db_printf("%s\tf%d,", op_name[i.IType.op],
-            i.IType.rt);
-        goto loadstore;
-
-    case OP_LB:
-    case OP_LH:
-    case OP_LW:
-    case OP_LD:
-    case OP_LBU:
-    case OP_LHU:
-    case OP_LWU:
-    case OP_SB:
-    case OP_SH:
-    case OP_SW:
-    case OP_SD:
-        db_printf("%s\t%s,", op_name[i.IType.op],
-            reg_name[i.IType.rt]);
-    loadstore:
-        db_printf("%d(%s)", (short)i.IType.imm,
-            reg_name[i.IType.rs]);
-        break;
-
-    case OP_ORI:
-    case OP_XORI:
-        if (i.IType.rs == 0) {
-            db_printf("li\t%s,0x%x",
-                reg_name[i.IType.rt],
-                i.IType.imm);
-            break;
-        }
-        /* FALLTHROUGH */
-    case OP_ANDI:
-        db_printf("%s\t%s,%s,0x%x", op_name[i.IType.op],
-            reg_name[i.IType.rt],
-            reg_name[i.IType.rs],
-            i.IType.imm);
-        break;
-
-    case OP_AUI:
-        if (i.IType.rs == 0) {
-            db_printf("lui\t%s,0x%x", reg_name[i.IType.rt],
-                i.IType.imm);
-        } else {
-            db_printf("%s\t%s,%s,%d", op_name[i.IType.op],
-            reg_name[i.IType.rt], reg_name[i.IType.rs],
-            (short)i.IType.imm);
-        }
-        break;
-
-    case OP_ADDIU:
-    case OP_DADDIU:
-        if (i.IType.rs == 0) {
-            db_printf("li\t%s,%d",
-                reg_name[i.IType.rt],
-                (short)i.IType.imm);
-            break;
-        }
-        /* FALLTHROUGH */
-    default:
-        db_printf("%s\t%s,%s,%d", op_name[i.IType.op],
-            reg_name[i.IType.rt],
-            reg_name[i.IType.rs],
-            (short)i.IType.imm);
-    }
-    // db_printf("\n");
-    // if (bdslot) {
-    //     db_printf("   bd: ");
-    //     mips_disassem(loc+4);
-    //     return (loc + 8);
-    // }
-    return (loc + 4);
-}
-
-static void
-print_addr(db_addr_t loc)
-{
-    db_printf("0x%08lx", loc);
-}
-
-static void db_printf(const char* fmt, ...)
-{
-    int cnt;
-    va_list argp;
-    va_start(argp, fmt);
-    if (sprintf_buffer) {
-        cnt = vsnprintf(sprintf_buffer, sprintf_buf_len, fmt, argp);
-        sprintf_buffer += cnt;
-        sprintf_buf_len -= cnt;
-    } else {
-        vprintf(fmt, argp);
-    }
-    va_end(argp);
-}
-
-/*
- * Disassemble instruction at 'loc'.
- * Return address of start of next instruction.
- * Since this function is used by 'examine' and by 'step'
- * "next instruction" does NOT mean the next instruction to
- * be executed but the 'linear' next instruction.
- */
-db_addr_t
-mips_disassem(db_addr_t loc, char *di_buffer, int alt_dis_format)
-{
-    u_int32_t instr;
-
-    if (alt_dis_format) {   // use ARM register names for disassembly
-        reg_name = &alt_arm_reg_name[0];
-    }
-
-    sprintf_buffer = di_buffer;     // quick 'n' dirty printf() vs sprintf()
-    sprintf_buf_len = 39;           // should be passed in
-
-    instr =  *(u_int32_t *)loc;
-    return (db_disasm_insn(instr, loc, false));
-}
diff --git a/libpixelflinger/codeflinger/mips64_disassem.h b/libpixelflinger/codeflinger/mips64_disassem.h
deleted file mode 100644
index c94f04f..0000000
--- a/libpixelflinger/codeflinger/mips64_disassem.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*  $NetBSD: db_disasm.c,v 1.19 2007/02/28 04:21:53 thorpej Exp $   */
-
-/*-
- * Copyright (c) 1991, 1993
- *  The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * 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.
- *
- *  from: @(#)kadb.c    8.1 (Berkeley) 6/10/93
- */
-
-
-
-#ifndef ANDROID_MIPS_DISASSEM_H
-#define ANDROID_MIPS_DISASSEM_H
-
-#include <sys/types.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-/* Prototypes for callable functions */
-
-void mips_disassem(uint32_t *location, char *di_buffer, int alt_fmt);
-
-#if __cplusplus
-}
-#endif
-
-#endif /* !ANDROID_MIPS_DISASSEM_H */
diff --git a/libpixelflinger/codeflinger/mips_disassem.c b/libpixelflinger/codeflinger/mips_disassem.c
deleted file mode 100644
index 1fe6806..0000000
--- a/libpixelflinger/codeflinger/mips_disassem.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/*  $NetBSD: db_disasm.c,v 1.19 2007/02/28 04:21:53 thorpej Exp $   */
-
-/*-
- * Copyright (c) 1991, 1993
- *  The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * 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.
- *
- *  from: @(#)kadb.c    8.1 (Berkeley) 6/10/93
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <sys/cdefs.h>
-
-#include <sys/types.h>
-#include "mips_opcode.h"
-
-
-// #include <sys/systm.h>
-// #include <sys/param.h>
-
-// #include <machine/reg.h>
-// #include <machine/cpu.h>
-/*#include <machine/param.h>*/
-// #include <machine/db_machdep.h>
-
-// #include <ddb/db_interface.h>
-// #include <ddb/db_output.h>
-// #include <ddb/db_extern.h>
-// #include <ddb/db_sym.h>
-
-#define __unused __attribute__((__unused__))
-
-static char *sprintf_buffer;
-static int sprintf_buf_len;
-
-
-typedef uint32_t db_addr_t;
-static void db_printf(const char* fmt, ...);
-
-static const char * const op_name[64] = {
-/* 0 */ "spec", "bcond","j  ",    "jal",  "beq",  "bne",  "blez", "bgtz",
-/* 8 */ "addi", "addiu","slti", "sltiu","andi", "ori",  "xori", "lui",
-/*16 */ "cop0", "cop1", "cop2", "cop3", "beql", "bnel", "blezl","bgtzl",
-/*24 */ "daddi","daddiu","ldl", "ldr",  "op34", "op35", "op36", "op37",
-/*32 */ "lb ",   "lh ",   "lwl",  "lw ",   "lbu",  "lhu",  "lwr",  "lwu",
-/*40 */ "sb ",   "sh ",   "swl",  "sw ",   "sdl",  "sdr",  "swr",  "cache",
-/*48 */ "ll ",   "lwc1", "lwc2", "lwc3", "lld",  "ldc1", "ldc2", "ld ",
-/*56 */ "sc ",   "swc1", "swc2", "swc3", "scd",  "sdc1", "sdc2", "sd "
-};
-
-static const char * const spec_name[64] = {
-/* 0 */ "sll",  "spec01","srl", "sra",  "sllv", "spec05","srlv","srav",
-/* 8 */ "jr",   "jalr", "movz","movn","syscall","break","spec16","sync",
-/*16 */ "mfhi", "mthi", "mflo", "mtlo", "dsllv","spec25","dsrlv","dsrav",
-/*24 */ "mult", "multu","div",  "divu", "dmult","dmultu","ddiv","ddivu",
-/*32 */ "add",  "addu", "sub",  "subu", "and",  "or ",   "xor",  "nor",
-/*40 */ "spec50","spec51","slt","sltu", "dadd","daddu","dsub","dsubu",
-/*48 */ "tge","tgeu","tlt","tltu","teq","spec65","tne","spec67",
-/*56 */ "dsll","spec71","dsrl","dsra","dsll32","spec75","dsrl32","dsra32"
-};
-
-static const char * const spec2_name[64] = {     /* QED RM4650, R5000, etc. */
-/* 0x00 */ "madd", "maddu", "mul", "spec3", "msub", "msubu", "rsrv6", "rsrv7",
-/* 0x08 */ "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv",
-/* 0x10 */ "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv",
-/* 0x18 */ "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv",
-/* 0x20 */ "clz",  "clo",  "rsrv", "rsrv", "dclz", "dclo", "rsrv", "rsrv",
-/* 0x28 */ "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv",
-/* 0x30 */ "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv", "rsrv",
-/* 0x38 */ "rsrv", "rsrv", "rsrv", "resv", "rsrv", "rsrv", "rsrv", "sdbbp"
-};
-
-static const char * const bcond_name[32] = {
-/* 0 */ "bltz", "bgez", "bltzl", "bgezl", "?", "?", "?", "?",
-/* 8 */ "tgei", "tgeiu", "tlti", "tltiu", "teqi", "?", "tnei", "?",
-/*16 */ "bltzal", "bgezal", "bltzall", "bgezall", "?", "?", "?", "?",
-/*24 */ "?", "?", "?", "?", "?", "?", "?", "?",
-};
-
-static const char * const cop1_name[64] = {
-/* 0 */ "fadd",  "fsub", "fmpy", "fdiv", "fsqrt","fabs", "fmov", "fneg",
-/* 8 */ "fop08","fop09","fop0a","fop0b","fop0c","fop0d","fop0e","fop0f",
-/*16 */ "fop10","fop11","fop12","fop13","fop14","fop15","fop16","fop17",
-/*24 */ "fop18","fop19","fop1a","fop1b","fop1c","fop1d","fop1e","fop1f",
-/*32 */ "fcvts","fcvtd","fcvte","fop23","fcvtw","fop25","fop26","fop27",
-/*40 */ "fop28","fop29","fop2a","fop2b","fop2c","fop2d","fop2e","fop2f",
-/*48 */ "fcmp.f","fcmp.un","fcmp.eq","fcmp.ueq","fcmp.olt","fcmp.ult",
-    "fcmp.ole","fcmp.ule",
-/*56 */ "fcmp.sf","fcmp.ngle","fcmp.seq","fcmp.ngl","fcmp.lt","fcmp.nge",
-    "fcmp.le","fcmp.ngt"
-};
-
-static const char * const fmt_name[16] = {
-    "s",    "d",    "e",    "fmt3",
-    "w",    "fmt5", "fmt6", "fmt7",
-    "fmt8", "fmt9", "fmta", "fmtb",
-    "fmtc", "fmtd", "fmte", "fmtf"
-};
-
-#if defined(__mips_n32) || defined(__mips_n64)
-static char * const reg_name[32] = {
-    "zero", "at",   "v0",   "v1",   "a0",   "a1",   "a2",   "a3",
-    "a4",   "a5",   "a6",   "a7",   "t0",   "t1",   "t2",   "t3",
-    "s0",   "s1",   "s2",   "s3",   "s4",   "s5",   "s6",   "s7",
-    "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "s8",   "ra"
-};
-#else
-
-static char * alt_arm_reg_name[32] = {  // hacked names for comparison with ARM code
-    "zero", "at",   "r0",   "r1",   "r2",   "r3",   "r4",   "r5",
-    "r6",   "r7",   "r8",   "r9",   "r10",  "r11",  "r12",  "r13",
-    "r14",  "r15",  "at2",  "cmp",  "s4",   "s5",   "s6",   "s7",
-    "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "s8",   "ra"
-};
-
-static char * mips_reg_name[32] = {
-    "zero", "at",   "v0",   "v1",   "a0",   "a1",   "a2",   "a3",
-    "t0",   "t1",   "t2",   "t3",   "t4",   "t5",   "t6",   "t7",
-    "s0",   "s1",   "s2",   "s3",   "s4",   "s5",   "s6",   "s7",
-    "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "s8",   "ra"
-};
-
-static char ** reg_name =  &mips_reg_name[0];
-
-#endif /* __mips_n32 || __mips_n64 */
-
-static const char * const c0_opname[64] = {
-    "c0op00","tlbr",  "tlbwi", "c0op03","c0op04","c0op05","tlbwr", "c0op07",
-    "tlbp",  "c0op11","c0op12","c0op13","c0op14","c0op15","c0op16","c0op17",
-    "rfe",   "c0op21","c0op22","c0op23","c0op24","c0op25","c0op26","c0op27",
-    "eret",  "c0op31","c0op32","c0op33","c0op34","c0op35","c0op36","c0op37",
-    "c0op40","c0op41","c0op42","c0op43","c0op44","c0op45","c0op46","c0op47",
-    "c0op50","c0op51","c0op52","c0op53","c0op54","c0op55","c0op56","c0op57",
-    "c0op60","c0op61","c0op62","c0op63","c0op64","c0op65","c0op66","c0op67",
-    "c0op70","c0op71","c0op72","c0op73","c0op74","c0op75","c0op77","c0op77",
-};
-
-static const char * const c0_reg[32] = {
-    "index",    "random",   "tlblo0",  "tlblo1",
-    "context",  "pagemask", "wired",   "cp0r7",
-    "badvaddr", "count",    "tlbhi",   "compare",
-    "status",   "cause",    "epc",     "prid",
-    "config",   "lladdr",   "watchlo", "watchhi",
-    "xcontext", "cp0r21",   "cp0r22",  "debug",
-    "depc",     "perfcnt",  "ecc",     "cacheerr",
-    "taglo",    "taghi",    "errepc",  "desave"
-};
-
-static void print_addr(db_addr_t);
-db_addr_t mips_disassem(db_addr_t loc, char *di_buffer, int alt_dis_format);
-
-
-/*
- * Disassemble instruction 'insn' nominally at 'loc'.
- * 'loc' may in fact contain a breakpoint instruction.
- */
-static db_addr_t
-db_disasm_insn(int insn, db_addr_t loc, bool altfmt __unused)
-{
-    bool bdslot = false;
-    InstFmt i;
-
-    i.word = insn;
-
-    switch (i.JType.op) {
-    case OP_SPECIAL:
-        if (i.word == 0) {
-            db_printf("nop");
-            break;
-        }
-        if (i.word == 0x0080) {
-            db_printf("NIY");
-            break;
-        }
-        if (i.word == 0x00c0) {
-            db_printf("NOT IMPL");
-            break;
-        }
-        /* Special cases --------------------------------------------------
-         * "addu" is a "move" only in 32-bit mode.  What's the correct
-         * answer - never decode addu/daddu as "move"?
-         */
-        if ( (i.RType.func == OP_ADDU && i.RType.rt == 0)  ||
-             (i.RType.func == OP_OR   && i.RType.rt == 0) ) {
-            db_printf("move\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rs]);
-            break;
-        }
-        // mips32r2, rotr & rotrv
-        if (i.RType.func == OP_SRL && (i.RType.rs & 1) == 1) {
-            db_printf("rotr\t%s,%s,%d", reg_name[i.RType.rd],
-                reg_name[i.RType.rt], i.RType.shamt);
-            break;
-        }
-        if (i.RType.func == OP_SRLV && (i.RType.shamt & 1) == 1) {
-            db_printf("rotrv\t%s,%s,%s", reg_name[i.RType.rd],
-                reg_name[i.RType.rt], reg_name[i.RType.rs]);
-            break;
-        }
-
-
-        db_printf("%s", spec_name[i.RType.func]);
-        switch (i.RType.func) {
-        case OP_SLL:
-        case OP_SRL:
-        case OP_SRA:
-        case OP_DSLL:
-
-        case OP_DSRL:
-        case OP_DSRA:
-        case OP_DSLL32:
-        case OP_DSRL32:
-        case OP_DSRA32:
-            db_printf("\t%s,%s,%d",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt],
-                i.RType.shamt);
-            break;
-
-        case OP_SLLV:
-        case OP_SRLV:
-        case OP_SRAV:
-        case OP_DSLLV:
-        case OP_DSRLV:
-        case OP_DSRAV:
-            db_printf("\t%s,%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt],
-                reg_name[i.RType.rs]);
-            break;
-
-        case OP_MFHI:
-        case OP_MFLO:
-            db_printf("\t%s", reg_name[i.RType.rd]);
-            break;
-
-        case OP_JR:
-        case OP_JALR:
-            db_printf("\t%s", reg_name[i.RType.rs]);
-            bdslot = true;
-            break;
-        case OP_MTLO:
-        case OP_MTHI:
-            db_printf("\t%s", reg_name[i.RType.rs]);
-            break;
-
-        case OP_MULT:
-        case OP_MULTU:
-        case OP_DMULT:
-        case OP_DMULTU:
-        case OP_DIV:
-        case OP_DIVU:
-        case OP_DDIV:
-        case OP_DDIVU:
-            db_printf("\t%s,%s",
-                reg_name[i.RType.rs],
-                reg_name[i.RType.rt]);
-            break;
-
-
-        case OP_SYSCALL:
-        case OP_SYNC:
-            break;
-
-        case OP_BREAK:
-            db_printf("\t%d", (i.RType.rs << 5) | i.RType.rt);
-            break;
-
-        default:
-            db_printf("\t%s,%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rs],
-                reg_name[i.RType.rt]);
-        }
-        break;
-
-    case OP_SPECIAL2:
-        if (i.RType.func == OP_MUL)
-            db_printf("%s\t%s,%s,%s",
-                spec2_name[i.RType.func & 0x3f],
-                    reg_name[i.RType.rd],
-                    reg_name[i.RType.rs],
-                    reg_name[i.RType.rt]);
-        else
-            db_printf("%s\t%s,%s",
-                spec2_name[i.RType.func & 0x3f],
-                    reg_name[i.RType.rs],
-                    reg_name[i.RType.rt]);
-
-        break;
-
-    case OP_SPECIAL3:
-        if (i.RType.func == OP_EXT)
-            db_printf("ext\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd+1);
-        else if (i.RType.func == OP_INS)
-            db_printf("ins\t%s,%s,%d,%d",
-                    reg_name[i.RType.rt],
-                    reg_name[i.RType.rs],
-                    i.RType.shamt,
-                    i.RType.rd-i.RType.shamt+1);
-        else if (i.RType.func == OP_BSHFL && i.RType.shamt == OP_WSBH)
-            db_printf("wsbh\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt]);
-        else if (i.RType.func == OP_BSHFL && i.RType.shamt == OP_SEB)
-            db_printf("seb\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt]);
-        else if (i.RType.func == OP_BSHFL && i.RType.shamt == OP_SEH)
-            db_printf("seh\t%s,%s",
-                reg_name[i.RType.rd],
-                reg_name[i.RType.rt]);
-        else
-            db_printf("Unknown");
-        break;
-
-    case OP_BCOND:
-        db_printf("%s\t%s,", bcond_name[i.IType.rt],
-            reg_name[i.IType.rs]);
-        goto pr_displ;
-
-    case OP_BLEZ:
-    case OP_BLEZL:
-    case OP_BGTZ:
-    case OP_BGTZL:
-        db_printf("%s\t%s,", op_name[i.IType.op],
-            reg_name[i.IType.rs]);
-        goto pr_displ;
-
-    case OP_BEQ:
-    case OP_BEQL:
-        if (i.IType.rs == 0 && i.IType.rt == 0) {
-            db_printf("b  \t");
-            goto pr_displ;
-        }
-        /* FALLTHROUGH */
-    case OP_BNE:
-    case OP_BNEL:
-        db_printf("%s\t%s,%s,", op_name[i.IType.op],
-            reg_name[i.IType.rs],
-            reg_name[i.IType.rt]);
-    pr_displ:
-        print_addr(loc + 4 + ((short)i.IType.imm << 2));
-        bdslot = true;
-        break;
-
-    case OP_COP0:
-        switch (i.RType.rs) {
-        case OP_BCx:
-        case OP_BCy:
-
-            db_printf("bc0%c\t",
-                "ft"[i.RType.rt & COPz_BC_TF_MASK]);
-            goto pr_displ;
-
-        case OP_MT:
-            db_printf("mtc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        case OP_DMT:
-            db_printf("dmtc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        case OP_MF:
-            db_printf("mfc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        case OP_DMF:
-            db_printf("dmfc0\t%s,%s",
-                reg_name[i.RType.rt],
-                c0_reg[i.RType.rd]);
-            break;
-
-        default:
-            db_printf("%s", c0_opname[i.FRType.func]);
-        }
-        break;
-
-    case OP_COP1:
-        switch (i.RType.rs) {
-        case OP_BCx:
-        case OP_BCy:
-            db_printf("bc1%c\t",
-                "ft"[i.RType.rt & COPz_BC_TF_MASK]);
-            goto pr_displ;
-
-        case OP_MT:
-            db_printf("mtc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        case OP_MF:
-            db_printf("mfc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        case OP_CT:
-            db_printf("ctc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        case OP_CF:
-            db_printf("cfc1\t%s,f%d",
-                reg_name[i.RType.rt],
-                i.RType.rd);
-            break;
-
-        default:
-            db_printf("%s.%s\tf%d,f%d,f%d",
-                cop1_name[i.FRType.func],
-                fmt_name[i.FRType.fmt],
-                i.FRType.fd, i.FRType.fs, i.FRType.ft);
-        }
-        break;
-
-    case OP_J:
-    case OP_JAL:
-        db_printf("%s\t", op_name[i.JType.op]);
-        print_addr((loc & 0xF0000000) | (i.JType.target << 2));
-        bdslot = true;
-        break;
-
-    case OP_LWC1:
-    case OP_SWC1:
-        db_printf("%s\tf%d,", op_name[i.IType.op],
-            i.IType.rt);
-        goto loadstore;
-
-    case OP_LB:
-    case OP_LH:
-    case OP_LW:
-    case OP_LD:
-    case OP_LBU:
-    case OP_LHU:
-    case OP_LWU:
-    case OP_SB:
-    case OP_SH:
-    case OP_SW:
-    case OP_SD:
-        db_printf("%s\t%s,", op_name[i.IType.op],
-            reg_name[i.IType.rt]);
-    loadstore:
-        db_printf("%d(%s)", (short)i.IType.imm,
-            reg_name[i.IType.rs]);
-        break;
-
-    case OP_ORI:
-    case OP_XORI:
-        if (i.IType.rs == 0) {
-            db_printf("li\t%s,0x%x",
-                reg_name[i.IType.rt],
-                i.IType.imm);
-            break;
-        }
-        /* FALLTHROUGH */
-    case OP_ANDI:
-        db_printf("%s\t%s,%s,0x%x", op_name[i.IType.op],
-            reg_name[i.IType.rt],
-            reg_name[i.IType.rs],
-            i.IType.imm);
-        break;
-
-    case OP_LUI:
-        db_printf("%s\t%s,0x%x", op_name[i.IType.op],
-            reg_name[i.IType.rt],
-            i.IType.imm);
-        break;
-
-    case OP_CACHE:
-        db_printf("%s\t0x%x,0x%x(%s)",
-            op_name[i.IType.op],
-            i.IType.rt,
-            i.IType.imm,
-            reg_name[i.IType.rs]);
-        break;
-
-    case OP_ADDI:
-    case OP_DADDI:
-    case OP_ADDIU:
-    case OP_DADDIU:
-        if (i.IType.rs == 0) {
-            db_printf("li\t%s,%d",
-                reg_name[i.IType.rt],
-                (short)i.IType.imm);
-            break;
-        }
-        /* FALLTHROUGH */
-    default:
-        db_printf("%s\t%s,%s,%d", op_name[i.IType.op],
-            reg_name[i.IType.rt],
-            reg_name[i.IType.rs],
-            (short)i.IType.imm);
-    }
-    // db_printf("\n");
-    // if (bdslot) {
-    //     db_printf("   bd: ");
-    //     mips_disassem(loc+4);
-    //     return (loc + 8);
-    // }
-    return (loc + 4);
-}
-
-static void
-print_addr(db_addr_t loc)
-{
-    db_printf("0x%08x", loc);
-}
-
-
-
-static void db_printf(const char* fmt, ...)
-{
-    int cnt;
-    va_list argp;
-    va_start(argp, fmt);
-    if (sprintf_buffer) {
-        cnt = vsnprintf(sprintf_buffer, sprintf_buf_len, fmt, argp);
-        sprintf_buffer += cnt;
-        sprintf_buf_len -= cnt;
-    } else {
-        vprintf(fmt, argp);
-    }
-    va_end(argp);
-}
-
-
-/*
- * Disassemble instruction at 'loc'.
- * Return address of start of next instruction.
- * Since this function is used by 'examine' and by 'step'
- * "next instruction" does NOT mean the next instruction to
- * be executed but the 'linear' next instruction.
- */
-db_addr_t
-mips_disassem(db_addr_t loc, char *di_buffer, int alt_dis_format)
-{
-    u_int32_t instr;
-
-    if (alt_dis_format) {   // use ARM register names for disassembly
-        reg_name = &alt_arm_reg_name[0];
-    }
-
-    sprintf_buffer = di_buffer;     // quick 'n' dirty printf() vs sprintf()
-    sprintf_buf_len = 39;           // should be passed in
-
-    instr =  *(u_int32_t *)loc;
-    return (db_disasm_insn(instr, loc, false));
-}
-
diff --git a/libpixelflinger/codeflinger/mips_disassem.h b/libpixelflinger/codeflinger/mips_disassem.h
deleted file mode 100644
index 2d5b7f5..0000000
--- a/libpixelflinger/codeflinger/mips_disassem.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*  $NetBSD: db_disasm.c,v 1.19 2007/02/28 04:21:53 thorpej Exp $   */
-
-/*-
- * Copyright (c) 1991, 1993
- *  The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * 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.
- *
- *  from: @(#)kadb.c    8.1 (Berkeley) 6/10/93
- */
-
-
-
-#ifndef ANDROID_MIPS_DISASSEM_H
-#define ANDROID_MIPS_DISASSEM_H
-
-#include <sys/types.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-
-// could add an interface like this, but I have not
-// typedef struct {
-//  u_int   (*di_readword)(u_int);
-//  void    (*di_printaddr)(u_int);
-//  void    (*di_printf)(const char *, ...);
-// } disasm_interface_t;
-
-/* Prototypes for callable functions */
-
-// u_int disasm(const disasm_interface_t *, u_int, int);
-
-void mips_disassem(uint32_t *location, char *di_buffer, int alt_fmt);
-
-#if __cplusplus
-}
-#endif
-
-#endif /* !ANDROID_MIPS_DISASSEM_H */
diff --git a/libpixelflinger/codeflinger/mips_opcode.h b/libpixelflinger/codeflinger/mips_opcode.h
deleted file mode 100644
index 45bb19e..0000000
--- a/libpixelflinger/codeflinger/mips_opcode.h
+++ /dev/null
@@ -1,410 +0,0 @@
-/*  $NetBSD: mips_opcode.h,v 1.12 2005/12/11 12:18:09 christos Exp $    */
-
-/*-
- * Copyright (c) 1992, 1993
- *  The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * 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.
- *
- *  @(#)mips_opcode.h   8.1 (Berkeley) 6/10/93
- */
-
-/*
- * Define the instruction formats and opcode values for the
- * MIPS instruction set.
- */
-
-#include <endian.h>
-
-/*
- * Define the instruction formats.
- */
-typedef union {
-    unsigned word;
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-    struct {
-        unsigned imm: 16;
-        unsigned rt: 5;
-        unsigned rs: 5;
-        unsigned op: 6;
-    } IType;
-
-    struct {
-        unsigned target: 26;
-        unsigned op: 6;
-    } JType;
-
-    struct {
-        unsigned func: 6;
-        unsigned shamt: 5;
-        unsigned rd: 5;
-        unsigned rt: 5;
-        unsigned rs: 5;
-        unsigned op: 6;
-    } RType;
-
-    struct {
-        unsigned func: 6;
-        unsigned fd: 5;
-        unsigned fs: 5;
-        unsigned ft: 5;
-        unsigned fmt: 4;
-        unsigned : 1;       /* always '1' */
-        unsigned op: 6;     /* always '0x11' */
-    } FRType;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
-    struct {
-        unsigned op: 6;
-        unsigned rs: 5;
-        unsigned rt: 5;
-        unsigned imm: 16;
-    } IType;
-
-    struct {
-        unsigned op: 6;
-        unsigned target: 26;
-    } JType;
-
-    struct {
-        unsigned op: 6;
-        unsigned rs: 5;
-        unsigned rt: 5;
-        unsigned rd: 5;
-        unsigned shamt: 5;
-        unsigned func: 6;
-    } RType;
-
-    struct {
-        unsigned op: 6;     /* always '0x11' */
-        unsigned : 1;       /* always '1' */
-        unsigned fmt: 4;
-        unsigned ft: 5;
-        unsigned fs: 5;
-        unsigned fd: 5;
-        unsigned func: 6;
-    } FRType;
-#endif
-} InstFmt;
-
-/*
- * Values for the 'op' field.
- */
-#define OP_SPECIAL  000
-#define OP_BCOND    001
-#define OP_J        002
-#define OP_JAL      003
-#define OP_BEQ      004
-#define OP_BNE      005
-#define OP_BLEZ     006
-#define OP_BGTZ     007
-
-#if __mips_isa_rev < 6
-#define OP_ADDI     010
-#else
-#define OP_POP10    010
-#endif
-
-#define OP_ADDIU    011
-#define OP_SLTI     012
-#define OP_SLTIU    013
-#define OP_ANDI     014
-#define OP_ORI      015
-#define OP_XORI     016
-
-#if __mips_isa_rev < 6
-#define OP_LUI      017
-#else
-#define OP_AUI      017
-#endif
-
-#define OP_COP0     020
-#define OP_COP1     021
-#define OP_COP2     022
-
-#if __mips_isa_rev < 6
-#define OP_COP3     023
-#define OP_BEQL     024
-#define OP_BNEL     025
-#define OP_BLEZL    026
-#define OP_BGTZL    027
-#define OP_DADDI    030
-#else
-#define OP_POP26    026
-#define OP_POP27    027
-#define OP_POP30    030
-#endif
-
-#define OP_DADDIU   031
-
-#if __mips_isa_rev < 6
-#define OP_LDL      032
-#define OP_LDR      033
-#define OP_SPECIAL2 034
-#else
-#define OP_DAUI     035
-#endif
-
-#define OP_SPECIAL3 037
-
-#define OP_LB       040
-#define OP_LH       041
-
-#if __mips_isa_rev < 6
-#define OP_LWL      042
-#endif
-
-#define OP_LW       043
-#define OP_LBU      044
-#define OP_LHU      045
-#define OP_LWR      046
-#define OP_LHU      045
-
-#if __mips_isa_rev < 6
-#define OP_LWR      046
-#endif
-
-#define OP_LWU      047
-
-#define OP_SB       050
-#define OP_SH       051
-
-#if __mips_isa_rev < 6
-#define OP_SWL      052
-#endif
-
-#define OP_SW       053
-
-#if __mips_isa_rev < 6
-#define OP_SDL      054
-#define OP_SDR      055
-#define OP_SWR      056
-#define OP_CACHE    057
-#define OP_LL       060
-#define OP_LWC0     OP_LL
-#define OP_LWC1     061
-#define OP_LWC2     062
-#define OP_LWC3     063
-#define OP_LLD      064
-#else
-#define OP_LWC1     061
-#define OP_BC       062
-#endif
-
-#define OP_LDC1     065
-#define OP_LD       067
-
-#if __mips_isa_rev < 6
-#define OP_SC       070
-#define OP_SWC0     OP_SC
-#endif
-
-#define OP_SWC1     071
-
-#if __mips_isa_rev < 6
-#define OP_SWC2     072
-#define OP_SWC3     073
-#define OP_SCD      074
-#else
-#define OP_BALC     072
-#endif
-
-#define OP_SDC1     075
-#define OP_SD       077
-
-/*
- * Values for the 'func' field when 'op' == OP_SPECIAL.
- */
-#define OP_SLL      000
-#define OP_SRL      002
-#define OP_SRA      003
-#define OP_SLLV     004
-#define OP_SRLV     006
-#define OP_SRAV     007
-
-#if __mips_isa_rev < 6
-#define OP_JR       010
-#endif
-
-#define OP_JALR     011
-#define OP_SYSCALL  014
-#define OP_BREAK    015
-#define OP_SYNC     017
-
-#if __mips_isa_rev < 6
-#define OP_MFHI     020
-#define OP_MTHI     021
-#define OP_MFLO     022
-#define OP_MTLO     023
-#else
-#define OP_CLZ      020
-#define OP_CLO      021
-#define OP_DCLZ     022
-#define OP_DCLO     023
-#endif
-
-#define OP_DSLLV    024
-#define OP_DSRLV    026
-#define OP_DSRAV    027
-
-#if __mips_isa_rev < 6
-#define OP_MULT     030
-#define OP_MULTU    031
-#define OP_DIV      032
-#define OP_DIVU     033
-#define OP_DMULT    034
-#define OP_DMULTU   035
-#define OP_DDIV     036
-#define OP_DDIVU    037
-#else
-#define OP_SOP30    030
-#define OP_SOP31    031
-#define OP_SOP32    032
-#define OP_SOP33    033
-#define OP_SOP34    034
-#define OP_SOP35    035
-#define OP_SOP36    036
-#define OP_SOP37    037
-#endif
-
-#define OP_ADD      040
-#define OP_ADDU     041
-#define OP_SUB      042
-#define OP_SUBU     043
-#define OP_AND      044
-#define OP_OR       045
-#define OP_XOR      046
-#define OP_NOR      047
-
-#define OP_SLT      052
-#define OP_SLTU     053
-#define OP_DADD     054
-#define OP_DADDU    055
-#define OP_DSUB     056
-#define OP_DSUBU    057
-
-#define OP_TGE      060
-#define OP_TGEU     061
-#define OP_TLT      062
-#define OP_TLTU     063
-#define OP_TEQ      064
-#define OP_TNE      066
-
-#define OP_DSLL     070
-#define OP_DSRL     072
-#define OP_DSRA     073
-#define OP_DSLL32   074
-#define OP_DSRL32   076
-#define OP_DSRA32   077
-
-#if __mips_isa_rev < 6
-/*
- * Values for the 'func' field when 'op' == OP_SPECIAL2.
- * OP_SPECIAL2 opcodes are removed in mips32r6
- */
-#define OP_MAD      000     /* QED */
-#define OP_MADU     001     /* QED */
-#define OP_MUL      002     /* QED */
-#endif
-
-/*
- * Values for the 'func' field when 'op' == OP_SPECIAL3.
- */
-#define OP_EXT      000
-#define OP_DEXTM    001
-#define OP_DEXTU    002
-#define OP_DEXT     003
-#define OP_INS      004
-#define OP_DINSM    005
-#define OP_DINSU    006
-#define OP_DINS     007
-#define OP_BSHFL    040
-#define OP_RDHWR    073
-
-/*
- * Values for the 'shamt' field when OP_SPECIAL3 && func OP_BSHFL.
- */
-
-#define OP_WSBH     002
-#define OP_SEB      020
-#define OP_SEH      030
-
-#if __mips_isa_rev == 6
-/*
- * Values for the 'shamt' field when OP_SOP30.
- */
-#define OP_MUL      002
-#define OP_MUH      003
-#endif
-
-/*
- * Values for the 'func' field when 'op' == OP_BCOND.
- */
-#define OP_BLTZ     000
-#define OP_BGEZ     001
-
-#if __mips_isa_rev < 6
-#define OP_BLTZL    002
-#define OP_BGEZL    003
-#define OP_TGEI     010
-#define OP_TGEIU    011
-#define OP_TLTI     012
-#define OP_TLTIU    013
-#define OP_TEQI     014
-#define OP_TNEI     016
-#define OP_BLTZAL   020
-#define OP_BGEZAL   021
-#define OP_BLTZALL  022
-#define OP_BGEZALL  023
-#else
-#define OP_NAL      020
-#define OP_BAL      021
-#endif
-
-/*
- * Values for the 'rs' field when 'op' == OP_COPz.
- */
-#define OP_MF       000
-#define OP_DMF      001
-#define OP_MT       004
-#define OP_DMT      005
-#define OP_BCx      010
-#define OP_BCy      014
-#define OP_CF       002
-#define OP_CT       006
-
-/*
- * Values for the 'rt' field when 'op' == OP_COPz.
- */
-#define COPz_BC_TF_MASK 0x01
-#define COPz_BC_TRUE    0x01
-#define COPz_BC_FALSE   0x00
-#define COPz_BCL_TF_MASK    0x02
-#define COPz_BCL_TRUE   0x02
-#define COPz_BCL_FALSE  0x00
diff --git a/libpixelflinger/codeflinger/texturing.cpp b/libpixelflinger/codeflinger/texturing.cpp
deleted file mode 100644
index e6997bd..0000000
--- a/libpixelflinger/codeflinger/texturing.cpp
+++ /dev/null
@@ -1,1261 +0,0 @@
-/* libs/pixelflinger/codeflinger/texturing.cpp
-**
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "pixelflinger-code"
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#include <log/log.h>
-
-#include "GGLAssembler.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-// iterators are initialized like this:
-// (intToFixedCenter(x) * dx)>>16 + x0
-// ((x<<16 + 0x8000) * dx)>>16 + x0
-// ((x<<16)*dx + (0x8000*dx))>>16 + x0
-// ( (x*dx) + dx>>1 ) + x0
-// (x*dx) + (dx>>1 + x0)
-
-void GGLAssembler::init_iterated_color(fragment_parts_t& parts, const reg_t& x)
-{
-    context_t const* c = mBuilderContext.c;
-
-    if (mSmooth) {
-        // NOTE: we could take this case in the mDithering + !mSmooth case,
-        // but this would use up to 4 more registers for the color components
-        // for only a little added quality.
-        // Currently, this causes the system to run out of registers in
-        // some case (see issue #719496)
-
-        comment("compute initial iterated color (smooth and/or dither case)");
-
-        parts.iterated_packed = 0;
-        parts.packed = 0;
-
-        // 0x1: color component
-        // 0x2: iterators
-        const int optReload = mOptLevel >> 1;
-        if (optReload >= 3)         parts.reload = 0; // reload nothing
-        else if (optReload == 2)    parts.reload = 2; // reload iterators
-        else if (optReload == 1)    parts.reload = 1; // reload colors
-        else if (optReload <= 0)    parts.reload = 3; // reload both
-
-        if (!mSmooth) {
-            // we're not smoothing (just dithering), we never have to 
-            // reload the iterators
-            parts.reload &= ~2;
-        }
-
-        Scratch scratches(registerFile());
-        const int t0 = (parts.reload & 1) ? scratches.obtain() : 0;
-        const int t1 = (parts.reload & 2) ? scratches.obtain() : 0;
-        for (int i=0 ; i<4 ; i++) {
-            if (!mInfo[i].iterated)
-                continue;            
-            
-            // this component exists in the destination and is not replaced
-            // by a texture unit.
-            const int c = (parts.reload & 1) ? t0 : obtainReg();              
-            if (i==0) CONTEXT_LOAD(c, iterators.ydady);
-            if (i==1) CONTEXT_LOAD(c, iterators.ydrdy);
-            if (i==2) CONTEXT_LOAD(c, iterators.ydgdy);
-            if (i==3) CONTEXT_LOAD(c, iterators.ydbdy);
-            parts.argb[i].reg = c;
-
-            if (mInfo[i].smooth) {
-                parts.argb_dx[i].reg = (parts.reload & 2) ? t1 : obtainReg();
-                const int dvdx = parts.argb_dx[i].reg;
-                CONTEXT_LOAD(dvdx, generated_vars.argb[i].dx);
-                MLA(AL, 0, c, x.reg, dvdx, c);
-                
-                // adjust the color iterator to make sure it won't overflow
-                if (!mAA) {
-                    // this is not needed when we're using anti-aliasing
-                    // because we will (have to) clamp the components
-                    // anyway.
-                    int end = scratches.obtain();
-                    MOV(AL, 0, end, reg_imm(parts.count.reg, LSR, 16));
-                    MLA(AL, 1, end, dvdx, end, c);
-                    SUB(MI, 0, c, c, end);
-                    BIC(AL, 0, c, c, reg_imm(c, ASR, 31)); 
-                    scratches.recycle(end);
-                }
-            }
-            
-            if (parts.reload & 1) {
-                CONTEXT_STORE(c, generated_vars.argb[i].c);
-            }
-        }
-    } else {
-        // We're not smoothed, so we can 
-        // just use a packed version of the color and extract the
-        // components as needed (or not at all if we don't blend)
-
-        // figure out if we need the iterated color
-        int load = 0;
-        for (int i=0 ; i<4 ; i++) {
-            component_info_t& info = mInfo[i];
-            if ((info.inDest || info.needed) && !info.replaced)
-                load |= 1;
-        }
-        
-        parts.iterated_packed = 1;
-        parts.packed = (!mTextureMachine.mask && !mBlending
-                && !mFog && !mDithering);
-        parts.reload = 0;
-        if (load || parts.packed) {
-            if (mBlending || mDithering || mInfo[GGLFormat::ALPHA].needed) {
-                comment("load initial iterated color (8888 packed)");
-                parts.iterated.setTo(obtainReg(),
-                        &(c->formats[GGL_PIXEL_FORMAT_RGBA_8888]));
-                CONTEXT_LOAD(parts.iterated.reg, packed8888);
-            } else {
-                comment("load initial iterated color (dest format packed)");
-
-                parts.iterated.setTo(obtainReg(), &mCbFormat);
-
-                // pre-mask the iterated color
-                const int bits = parts.iterated.size();
-                const uint32_t size = ((bits>=32) ? 0 : (1LU << bits)) - 1;
-                uint32_t mask = 0;
-                if (mMasking) {
-                    for (int i=0 ; i<4 ; i++) {
-                        const int component_mask = 1<<i;
-                        const int h = parts.iterated.format.c[i].h;
-                        const int l = parts.iterated.format.c[i].l;
-                        if (h && (!(mMasking & component_mask))) {
-                            mask |= ((1<<(h-l))-1) << l;
-                        }
-                    }
-                }
-
-                if (mMasking && ((mask & size)==0)) {
-                    // none of the components are present in the mask
-                } else {
-                    CONTEXT_LOAD(parts.iterated.reg, packed);
-                    if (mCbFormat.size == 1) {
-                        AND(AL, 0, parts.iterated.reg,
-                                parts.iterated.reg, imm(0xFF));
-                    } else if (mCbFormat.size == 2) {
-                        MOV(AL, 0, parts.iterated.reg,
-                                reg_imm(parts.iterated.reg, LSR, 16));
-                    }
-                }
-
-                // pre-mask the iterated color
-                if (mMasking) {
-                    build_and_immediate(parts.iterated.reg, parts.iterated.reg,
-                            mask, bits);
-                }
-            }
-        }
-    }
-}
-
-void GGLAssembler::build_iterated_color(
-        component_t& fragment,
-        const fragment_parts_t& parts,
-        int component,
-        Scratch& regs)
-{
-    fragment.setTo( regs.obtain(), 0, 32, CORRUPTIBLE); 
-
-    if (!mInfo[component].iterated)
-        return;
-
-    if (parts.iterated_packed) {
-        // iterated colors are packed, extract the one we need
-        extract(fragment, parts.iterated, component);
-    } else {
-        fragment.h = GGL_COLOR_BITS;
-        fragment.l = GGL_COLOR_BITS - 8;
-        fragment.flags |= CLEAR_LO;
-        // iterated colors are held in their own register,
-        // (smooth and/or dithering case)
-        if (parts.reload==3) {
-            // this implies mSmooth
-            Scratch scratches(registerFile());
-            int dx = scratches.obtain();
-            CONTEXT_LOAD(fragment.reg, generated_vars.argb[component].c);
-            CONTEXT_LOAD(dx, generated_vars.argb[component].dx);
-            ADD(AL, 0, dx, fragment.reg, dx);
-            CONTEXT_STORE(dx, generated_vars.argb[component].c);
-        } else if (parts.reload & 1) {
-            CONTEXT_LOAD(fragment.reg, generated_vars.argb[component].c);
-        } else {
-            // we don't reload, so simply rename the register and mark as
-            // non CORRUPTIBLE so that the texture env or blending code
-            // won't modify this (renamed) register
-            regs.recycle(fragment.reg);
-            fragment.reg = parts.argb[component].reg;
-            fragment.flags &= ~CORRUPTIBLE;
-        }
-        if (mInfo[component].smooth && mAA) {
-            // when using smooth shading AND anti-aliasing, we need to clamp
-            // the iterators because there is always an extra pixel on the
-            // edges, which most of the time will cause an overflow
-            // (since technically its outside of the domain).
-            BIC(AL, 0, fragment.reg, fragment.reg,
-                    reg_imm(fragment.reg, ASR, 31));
-            component_sat(fragment);
-        }
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::decodeLogicOpNeeds(const needs_t& needs)
-{
-    // gather some informations about the components we need to process...
-    const int opcode = GGL_READ_NEEDS(LOGIC_OP, needs.n) | GGL_CLEAR;
-    switch(opcode) {
-    case GGL_COPY:
-        mLogicOp = 0;
-        break;
-    case GGL_CLEAR:
-    case GGL_SET:
-        mLogicOp = LOGIC_OP;
-        break;
-    case GGL_AND:
-    case GGL_AND_REVERSE:
-    case GGL_AND_INVERTED:
-    case GGL_XOR:
-    case GGL_OR:
-    case GGL_NOR:
-    case GGL_EQUIV:
-    case GGL_OR_REVERSE:
-    case GGL_OR_INVERTED:
-    case GGL_NAND:
-        mLogicOp = LOGIC_OP|LOGIC_OP_SRC|LOGIC_OP_DST;
-        break;
-    case GGL_NOOP:
-    case GGL_INVERT:
-        mLogicOp = LOGIC_OP|LOGIC_OP_DST;
-        break;        
-    case GGL_COPY_INVERTED:
-        mLogicOp = LOGIC_OP|LOGIC_OP_SRC;
-        break;
-    };        
-}
-
-void GGLAssembler::decodeTMUNeeds(const needs_t& needs, context_t const* c)
-{
-    uint8_t replaced=0;
-    mTextureMachine.mask = 0;
-    mTextureMachine.activeUnits = 0;
-    for (int i=GGL_TEXTURE_UNIT_COUNT-1 ; i>=0 ; i--) {
-        texture_unit_t& tmu = mTextureMachine.tmu[i];
-        if (replaced == 0xF) {
-            // all components are replaced, skip this TMU.
-            tmu.format_idx = 0;
-            tmu.mask = 0;
-            tmu.replaced = replaced;
-            continue;
-        }
-        tmu.format_idx = GGL_READ_NEEDS(T_FORMAT, needs.t[i]);
-        tmu.format = c->formats[tmu.format_idx];
-        tmu.bits = tmu.format.size*8;
-        tmu.swrap = GGL_READ_NEEDS(T_S_WRAP, needs.t[i]);
-        tmu.twrap = GGL_READ_NEEDS(T_T_WRAP, needs.t[i]);
-        tmu.env = ggl_needs_to_env(GGL_READ_NEEDS(T_ENV, needs.t[i]));
-        tmu.pot = GGL_READ_NEEDS(T_POT, needs.t[i]);
-        tmu.linear = GGL_READ_NEEDS(T_LINEAR, needs.t[i])
-                && tmu.format.size!=3; // XXX: only 8, 16 and 32 modes for now
-
-        // 5551 linear filtering is not supported
-        if (tmu.format_idx == GGL_PIXEL_FORMAT_RGBA_5551)
-            tmu.linear = 0;
-        
-        tmu.mask = 0;
-        tmu.replaced = replaced;
-
-        if (tmu.format_idx) {
-            mTextureMachine.activeUnits++;
-            if (tmu.format.c[0].h)    tmu.mask |= 0x1;
-            if (tmu.format.c[1].h)    tmu.mask |= 0x2;
-            if (tmu.format.c[2].h)    tmu.mask |= 0x4;
-            if (tmu.format.c[3].h)    tmu.mask |= 0x8;
-            if (tmu.env == GGL_REPLACE) {
-                replaced |= tmu.mask;
-            } else if (tmu.env == GGL_DECAL) {
-                if (!tmu.format.c[GGLFormat::ALPHA].h) {
-                    // if we don't have alpha, decal does nothing
-                    tmu.mask = 0;
-                } else {
-                    // decal always ignores At
-                    tmu.mask &= ~(1<<GGLFormat::ALPHA);
-                }
-            }
-        }
-        mTextureMachine.mask |= tmu.mask;
-        //printf("%d: mask=%08lx, replaced=%08lx\n",
-        //    i, int(tmu.mask), int(tmu.replaced));
-    }
-    mTextureMachine.replaced = replaced;
-    mTextureMachine.directTexture = 0;
-    //printf("replaced=%08lx\n", mTextureMachine.replaced);
-}
-
-
-void GGLAssembler::init_textures(
-        tex_coord_t* coords,
-        const reg_t& x, const reg_t& y)
-{
-    const needs_t& needs = mBuilderContext.needs;
-    int Rx = x.reg;
-    int Ry = y.reg;
-
-    if (mTextureMachine.mask) {
-        comment("compute texture coordinates");
-    }
-
-    // init texture coordinates for each tmu
-    const int cb_format_idx = GGL_READ_NEEDS(CB_FORMAT, needs.n);
-    const bool multiTexture = mTextureMachine.activeUnits > 1;
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT; i++) {
-        const texture_unit_t& tmu = mTextureMachine.tmu[i];
-        if (tmu.format_idx == 0)
-            continue;
-        if ((tmu.swrap == GGL_NEEDS_WRAP_11) &&
-            (tmu.twrap == GGL_NEEDS_WRAP_11)) 
-        {
-            // 1:1 texture
-            pointer_t& txPtr = coords[i].ptr;
-            txPtr.setTo(obtainReg(), tmu.bits);
-            CONTEXT_LOAD(txPtr.reg, state.texture[i].iterators.ydsdy);
-            ADD(AL, 0, Rx, Rx, reg_imm(txPtr.reg, ASR, 16));    // x += (s>>16)
-            CONTEXT_LOAD(txPtr.reg, state.texture[i].iterators.ydtdy);
-            ADD(AL, 0, Ry, Ry, reg_imm(txPtr.reg, ASR, 16));    // y += (t>>16)
-            // merge base & offset
-            CONTEXT_LOAD(txPtr.reg, generated_vars.texture[i].stride);
-            SMLABB(AL, Rx, Ry, txPtr.reg, Rx);               // x+y*stride
-            CONTEXT_ADDR_LOAD(txPtr.reg, generated_vars.texture[i].data);
-            base_offset(txPtr, txPtr, Rx);
-        } else {
-            Scratch scratches(registerFile());
-            reg_t& s = coords[i].s;
-            reg_t& t = coords[i].t;
-            // s = (x * dsdx)>>16 + ydsdy
-            // s = (x * dsdx)>>16 + (y*dsdy)>>16 + s0
-            // t = (x * dtdx)>>16 + ydtdy
-            // t = (x * dtdx)>>16 + (y*dtdy)>>16 + t0
-            s.setTo(obtainReg());
-            t.setTo(obtainReg());
-            const int need_w = GGL_READ_NEEDS(W, needs.n);
-            if (need_w) {
-                CONTEXT_LOAD(s.reg, state.texture[i].iterators.ydsdy);
-                CONTEXT_LOAD(t.reg, state.texture[i].iterators.ydtdy);
-            } else {
-                int ydsdy = scratches.obtain();
-                int ydtdy = scratches.obtain();
-                CONTEXT_LOAD(s.reg, generated_vars.texture[i].dsdx);
-                CONTEXT_LOAD(ydsdy, state.texture[i].iterators.ydsdy);
-                CONTEXT_LOAD(t.reg, generated_vars.texture[i].dtdx);
-                CONTEXT_LOAD(ydtdy, state.texture[i].iterators.ydtdy);
-                MLA(AL, 0, s.reg, Rx, s.reg, ydsdy);
-                MLA(AL, 0, t.reg, Rx, t.reg, ydtdy);
-            }
-            
-            if ((mOptLevel&1)==0) {
-                CONTEXT_STORE(s.reg, generated_vars.texture[i].spill[0]);
-                CONTEXT_STORE(t.reg, generated_vars.texture[i].spill[1]);
-                recycleReg(s.reg);
-                recycleReg(t.reg);
-            }
-        }
-
-        // direct texture?
-        if (!multiTexture && !mBlending && !mDithering && !mFog && 
-            cb_format_idx == tmu.format_idx && !tmu.linear &&
-            mTextureMachine.replaced == tmu.mask) 
-        {
-                mTextureMachine.directTexture = i + 1; 
-        }
-    }
-}
-
-void GGLAssembler::build_textures(  fragment_parts_t& parts,
-                                    Scratch& regs)
-{
-    // We don't have a way to spill registers automatically
-    // spill depth and AA regs, when we know we may have to.
-    // build the spill list...
-    uint32_t spill_list = 0;
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT; i++) {
-        const texture_unit_t& tmu = mTextureMachine.tmu[i];
-        if (tmu.format_idx == 0)
-            continue;
-        if (tmu.linear) {
-            // we may run out of register if we have linear filtering
-            // at 1 or 4 bytes / pixel on any texture unit.
-            if (tmu.format.size == 1) {
-                // if depth and AA enabled, we'll run out of 1 register
-                if (parts.z.reg > 0 && parts.covPtr.reg > 0)
-                    spill_list |= 1<<parts.covPtr.reg;
-            }
-            if (tmu.format.size == 4) {
-                // if depth or AA enabled, we'll run out of 1 or 2 registers
-                if (parts.z.reg > 0)
-                    spill_list |= 1<<parts.z.reg;
-                if (parts.covPtr.reg > 0)   
-                    spill_list |= 1<<parts.covPtr.reg;
-            }
-        }
-    }
-
-    Spill spill(registerFile(), *this, spill_list);
-
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT; i++) {
-        const texture_unit_t& tmu = mTextureMachine.tmu[i];
-        if (tmu.format_idx == 0)
-            continue;
-
-        pointer_t& txPtr = parts.coords[i].ptr;
-        pixel_t& texel = parts.texel[i];
-
-        // repeat...
-        if ((tmu.swrap == GGL_NEEDS_WRAP_11) &&
-            (tmu.twrap == GGL_NEEDS_WRAP_11))
-        { // 1:1 textures
-            comment("fetch texel");
-            texel.setTo(regs.obtain(), &tmu.format);
-            load(txPtr, texel, WRITE_BACK);
-        } else {
-            Scratch scratches(registerFile());
-            reg_t& s = parts.coords[i].s;
-            reg_t& t = parts.coords[i].t;
-            if ((mOptLevel&1)==0) {
-                comment("reload s/t (multitexture or linear filtering)");
-                s.reg = scratches.obtain();
-                t.reg = scratches.obtain();
-                CONTEXT_LOAD(s.reg, generated_vars.texture[i].spill[0]);
-                CONTEXT_LOAD(t.reg, generated_vars.texture[i].spill[1]);
-            }
-
-            if (registerFile().status() & RegisterFile::OUT_OF_REGISTERS)
-                return;
-
-            comment("compute repeat/clamp");
-            int u       = scratches.obtain();
-            int v       = scratches.obtain();
-            int width   = scratches.obtain();
-            int height  = scratches.obtain();
-            int U = 0;
-            int V = 0;
-
-            if (registerFile().status() & RegisterFile::OUT_OF_REGISTERS)
-                return;
-
-            CONTEXT_LOAD(width,  generated_vars.texture[i].width);
-            CONTEXT_LOAD(height, generated_vars.texture[i].height);
-
-            int FRAC_BITS = 0;
-            if (tmu.linear) {
-                // linear interpolation
-                if (tmu.format.size == 1) {
-                    // for 8-bits textures, we can afford
-                    // 7 bits of fractional precision at no
-                    // additional cost (we can't do 8 bits
-                    // because filter8 uses signed 16 bits muls)
-                    FRAC_BITS = 7;
-                } else if (tmu.format.size == 2) {
-                    // filter16() is internally limited to 4 bits, so:
-                    // FRAC_BITS=2 generates less instructions,
-                    // FRAC_BITS=3,4,5 creates unpleasant artifacts,
-                    // FRAC_BITS=6+ looks good
-                    FRAC_BITS = 6;
-                } else if (tmu.format.size == 4) {
-                    // filter32() is internally limited to 8 bits, so:
-                    // FRAC_BITS=4 looks good
-                    // FRAC_BITS=5+ looks better, but generates 3 extra ipp
-                    FRAC_BITS = 6;
-                } else {
-                    // for all other cases we use 4 bits.
-                    FRAC_BITS = 4;
-                }
-            }
-            wrapping(u, s.reg, width,  tmu.swrap, FRAC_BITS);
-            wrapping(v, t.reg, height, tmu.twrap, FRAC_BITS);
-
-            if (tmu.linear) {
-                comment("compute linear filtering offsets");
-                // pixel size scale
-                const int shift = 31 - gglClz(tmu.format.size);
-                U = scratches.obtain();
-                V = scratches.obtain();
-
-                if (registerFile().status() & RegisterFile::OUT_OF_REGISTERS)
-                    return;
-
-                // sample the texel center
-                SUB(AL, 0, u, u, imm(1<<(FRAC_BITS-1)));
-                SUB(AL, 0, v, v, imm(1<<(FRAC_BITS-1)));
-
-                // get the fractionnal part of U,V
-                AND(AL, 0, U, u, imm((1<<FRAC_BITS)-1));
-                AND(AL, 0, V, v, imm((1<<FRAC_BITS)-1));
-
-                // compute width-1 and height-1
-                SUB(AL, 0, width,  width,  imm(1));
-                SUB(AL, 0, height, height, imm(1));
-
-                // get the integer part of U,V and clamp/wrap
-                // and compute offset to the next texel
-                if (tmu.swrap == GGL_NEEDS_WRAP_REPEAT) {
-                    // u has already been REPEATed
-                    MOV(AL, 1, u, reg_imm(u, ASR, FRAC_BITS));
-                    MOV(MI, 0, u, width);                    
-                    CMP(AL, u, width);
-                    MOV(LT, 0, width, imm(1 << shift));
-                    if (shift)
-                        MOV(GE, 0, width, reg_imm(width, LSL, shift));
-                    RSB(GE, 0, width, width, imm(0));
-                } else {
-                    // u has not been CLAMPed yet
-                    // algorithm:
-                    // if ((u>>4) >= width)
-                    //      u = width<<4
-                    //      width = 0
-                    // else
-                    //      width = 1<<shift
-                    // u = u>>4; // get integer part
-                    // if (u<0)
-                    //      u = 0
-                    //      width = 0
-                    // generated_vars.rt = width
-                    
-                    CMP(AL, width, reg_imm(u, ASR, FRAC_BITS));
-                    MOV(LE, 0, u, reg_imm(width, LSL, FRAC_BITS));
-                    MOV(LE, 0, width, imm(0));
-                    MOV(GT, 0, width, imm(1 << shift));
-                    MOV(AL, 1, u, reg_imm(u, ASR, FRAC_BITS));
-                    MOV(MI, 0, u, imm(0));
-                    MOV(MI, 0, width, imm(0));
-                }
-                CONTEXT_STORE(width, generated_vars.rt);
-
-                const int stride = width;
-                CONTEXT_LOAD(stride, generated_vars.texture[i].stride);
-                if (tmu.twrap == GGL_NEEDS_WRAP_REPEAT) {
-                    // v has already been REPEATed
-                    MOV(AL, 1, v, reg_imm(v, ASR, FRAC_BITS));
-                    MOV(MI, 0, v, height);
-                    CMP(AL, v, height);
-                    MOV(LT, 0, height, imm(1 << shift));
-                    if (shift)
-                        MOV(GE, 0, height, reg_imm(height, LSL, shift));
-                    RSB(GE, 0, height, height, imm(0));
-                    MUL(AL, 0, height, stride, height);
-                } else {
-                    // v has not been CLAMPed yet
-                    CMP(AL, height, reg_imm(v, ASR, FRAC_BITS));
-                    MOV(LE, 0, v, reg_imm(height, LSL, FRAC_BITS));
-                    MOV(LE, 0, height, imm(0));
-                    if (shift) {
-                        MOV(GT, 0, height, reg_imm(stride, LSL, shift));
-                    } else {
-                        MOV(GT, 0, height, stride);
-                    }
-                    MOV(AL, 1, v, reg_imm(v, ASR, FRAC_BITS));
-                    MOV(MI, 0, v, imm(0));
-                    MOV(MI, 0, height, imm(0));
-                }
-                CONTEXT_STORE(height, generated_vars.lb);
-            }
-    
-            scratches.recycle(width);
-            scratches.recycle(height);
-
-            // iterate texture coordinates...
-            comment("iterate s,t");
-            int dsdx = scratches.obtain();
-            int dtdx = scratches.obtain();
-
-            if (registerFile().status() & RegisterFile::OUT_OF_REGISTERS)
-                return;
-
-            CONTEXT_LOAD(dsdx, generated_vars.texture[i].dsdx);
-            CONTEXT_LOAD(dtdx, generated_vars.texture[i].dtdx);
-            ADD(AL, 0, s.reg, s.reg, dsdx);
-            ADD(AL, 0, t.reg, t.reg, dtdx);
-            if ((mOptLevel&1)==0) {
-                CONTEXT_STORE(s.reg, generated_vars.texture[i].spill[0]);
-                CONTEXT_STORE(t.reg, generated_vars.texture[i].spill[1]);
-                scratches.recycle(s.reg);
-                scratches.recycle(t.reg);
-            }
-            scratches.recycle(dsdx);
-            scratches.recycle(dtdx);
-
-            // merge base & offset...
-            comment("merge base & offset");
-            texel.setTo(regs.obtain(), &tmu.format);
-            txPtr.setTo(texel.reg, tmu.bits);
-            int stride = scratches.obtain();
-
-            if (registerFile().status() & RegisterFile::OUT_OF_REGISTERS)
-                return;
-
-            CONTEXT_LOAD(stride,    generated_vars.texture[i].stride);
-            CONTEXT_ADDR_LOAD(txPtr.reg, generated_vars.texture[i].data);
-            SMLABB(AL, u, v, stride, u);    // u+v*stride 
-            base_offset(txPtr, txPtr, u);
-
-            // load texel
-            if (!tmu.linear) {
-                comment("fetch texel");
-                load(txPtr, texel, 0);
-            } else {
-                // recycle registers we don't need anymore
-                scratches.recycle(u);
-                scratches.recycle(v);
-                scratches.recycle(stride);
-
-                comment("fetch texel, bilinear");
-                switch (tmu.format.size) {
-                case 1:  filter8(parts, texel, tmu, U, V, txPtr, FRAC_BITS); break;
-                case 2: filter16(parts, texel, tmu, U, V, txPtr, FRAC_BITS); break;
-                case 3: filter24(parts, texel, tmu, U, V, txPtr, FRAC_BITS); break;
-                case 4: filter32(parts, texel, tmu, U, V, txPtr, FRAC_BITS); break;
-                }
-            }            
-        }
-    }
-}
-
-void GGLAssembler::build_iterate_texture_coordinates(
-    const fragment_parts_t& parts)
-{
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT; i++) {
-        const texture_unit_t& tmu = mTextureMachine.tmu[i];
-        if (tmu.format_idx == 0)
-            continue;
-
-        if ((tmu.swrap == GGL_NEEDS_WRAP_11) &&
-            (tmu.twrap == GGL_NEEDS_WRAP_11))
-        { // 1:1 textures
-            const pointer_t& txPtr = parts.coords[i].ptr;
-            ADD(AL, 0, txPtr.reg, txPtr.reg, imm(txPtr.size>>3));
-        } else {
-            Scratch scratches(registerFile());
-            int s = parts.coords[i].s.reg;
-            int t = parts.coords[i].t.reg;
-            if ((mOptLevel&1)==0) {
-                s = scratches.obtain();
-                t = scratches.obtain();
-                CONTEXT_LOAD(s, generated_vars.texture[i].spill[0]);
-                CONTEXT_LOAD(t, generated_vars.texture[i].spill[1]);
-            }
-            int dsdx = scratches.obtain();
-            int dtdx = scratches.obtain();
-            CONTEXT_LOAD(dsdx, generated_vars.texture[i].dsdx);
-            CONTEXT_LOAD(dtdx, generated_vars.texture[i].dtdx);
-            ADD(AL, 0, s, s, dsdx);
-            ADD(AL, 0, t, t, dtdx);
-            if ((mOptLevel&1)==0) {
-                CONTEXT_STORE(s, generated_vars.texture[i].spill[0]);
-                CONTEXT_STORE(t, generated_vars.texture[i].spill[1]);
-            }
-        }
-    }
-}
-
-void GGLAssembler::filter8(
-        const fragment_parts_t& /*parts*/,
-        pixel_t& texel, const texture_unit_t& tmu,
-        int U, int V, pointer_t& txPtr,
-        int FRAC_BITS)
-{
-    if (tmu.format.components != GGL_ALPHA &&
-        tmu.format.components != GGL_LUMINANCE)
-    {
-        // this is a packed format, and we don't support
-        // linear filtering (it's probably RGB 332)
-        // Should not happen with OpenGL|ES
-        LDRB(AL, texel.reg, txPtr.reg);
-        return;
-    }
-
-    // ------------------------
-    // about ~22 cycles / pixel
-    Scratch scratches(registerFile());
-
-    int pixel= scratches.obtain();
-    int d    = scratches.obtain();
-    int u    = scratches.obtain();
-    int k    = scratches.obtain();
-    int rt   = scratches.obtain();
-    int lb   = scratches.obtain();
-
-    // RB -> U * V
-
-    CONTEXT_LOAD(rt, generated_vars.rt);
-    CONTEXT_LOAD(lb, generated_vars.lb);
-
-    int offset = pixel;
-    ADD(AL, 0, offset, lb, rt);
-    LDRB(AL, pixel, txPtr.reg, reg_scale_pre(offset));
-    SMULBB(AL, u, U, V);
-    SMULBB(AL, d, pixel, u);
-    RSB(AL, 0, k, u, imm(1<<(FRAC_BITS*2)));
-    
-    // LB -> (1-U) * V
-    RSB(AL, 0, U, U, imm(1<<FRAC_BITS));
-    LDRB(AL, pixel, txPtr.reg, reg_scale_pre(lb));
-    SMULBB(AL, u, U, V);
-    SMLABB(AL, d, pixel, u, d);
-    SUB(AL, 0, k, k, u);
-    
-    // LT -> (1-U)*(1-V)
-    RSB(AL, 0, V, V, imm(1<<FRAC_BITS));
-    LDRB(AL, pixel, txPtr.reg);
-    SMULBB(AL, u, U, V);
-    SMLABB(AL, d, pixel, u, d);
-
-    // RT -> U*(1-V)
-    LDRB(AL, pixel, txPtr.reg, reg_scale_pre(rt));
-    SUB(AL, 0, u, k, u);
-    SMLABB(AL, texel.reg, pixel, u, d);
-    
-    for (int i=0 ; i<4 ; i++) {
-        if (!texel.format.c[i].h) continue;
-        texel.format.c[i].h = FRAC_BITS*2+8;
-        texel.format.c[i].l = FRAC_BITS*2; // keeping 8 bits in enough
-    }
-    texel.format.size = 4;
-    texel.format.bitsPerPixel = 32;
-    texel.flags |= CLEAR_LO;
-}
-
-void GGLAssembler::filter16(
-        const fragment_parts_t& /*parts*/,
-        pixel_t& texel, const texture_unit_t& tmu,
-        int U, int V, pointer_t& txPtr,
-        int FRAC_BITS)
-{    
-    // compute the mask
-    // XXX: it would be nice if the mask below could be computed
-    // automatically.
-    uint32_t mask = 0;
-    int shift = 0;
-    int prec = 0;
-    switch (tmu.format_idx) {
-        case GGL_PIXEL_FORMAT_RGB_565:
-            // source: 00000ggg.ggg00000 | rrrrr000.000bbbbb
-            // result: gggggggg.gggrrrrr | rrrrr0bb.bbbbbbbb
-            mask = 0x07E0F81F;
-            shift = 16;
-            prec = 5;
-            break;
-        case GGL_PIXEL_FORMAT_RGBA_4444:
-            // 0000,1111,0000,1111 | 0000,1111,0000,1111
-            mask = 0x0F0F0F0F;
-            shift = 12;
-            prec = 4;
-            break;
-        case GGL_PIXEL_FORMAT_LA_88:
-            // 0000,0000,1111,1111 | 0000,0000,1111,1111
-            // AALL -> 00AA | 00LL
-            mask = 0x00FF00FF;
-            shift = 8;
-            prec = 8;
-            break;
-        default:
-            // unsupported format, do something sensical...
-            ALOGE("Unsupported 16-bits texture format (%d)", tmu.format_idx);
-            LDRH(AL, texel.reg, txPtr.reg);
-            return;
-    }
-
-    const int adjust = FRAC_BITS*2 - prec;
-    const int round  = 0;
-
-    // update the texel format
-    texel.format.size = 4;
-    texel.format.bitsPerPixel = 32;
-    texel.flags |= CLEAR_HI|CLEAR_LO;
-    for (int i=0 ; i<4 ; i++) {
-        if (!texel.format.c[i].h) continue;
-        const uint32_t offset = (mask & tmu.format.mask(i)) ? 0 : shift;
-        texel.format.c[i].h = tmu.format.c[i].h + offset + prec;
-        texel.format.c[i].l = texel.format.c[i].h - (tmu.format.bits(i) + prec);
-    }
-
-    // ------------------------
-    // about ~40 cycles / pixel
-    Scratch scratches(registerFile());
-
-    int pixel= scratches.obtain();
-    int d    = scratches.obtain();
-    int u    = scratches.obtain();
-    int k    = scratches.obtain();
-
-    // RB -> U * V
-    int offset = pixel;
-    CONTEXT_LOAD(offset, generated_vars.rt);
-    CONTEXT_LOAD(u, generated_vars.lb);
-    ADD(AL, 0, offset, offset, u);
-
-    LDRH(AL, pixel, txPtr.reg, reg_pre(offset));
-    SMULBB(AL, u, U, V);
-    ORR(AL, 0, pixel, pixel, reg_imm(pixel, LSL, shift));
-    build_and_immediate(pixel, pixel, mask, 32);
-    if (adjust) {
-        if (round)
-            ADD(AL, 0, u, u, imm(1<<(adjust-1)));
-        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
-    }
-    MUL(AL, 0, d, pixel, u);
-    RSB(AL, 0, k, u, imm(1<<prec));
-    
-    // LB -> (1-U) * V
-    CONTEXT_LOAD(offset, generated_vars.lb);
-    RSB(AL, 0, U, U, imm(1<<FRAC_BITS));
-    LDRH(AL, pixel, txPtr.reg, reg_pre(offset));
-    SMULBB(AL, u, U, V);
-    ORR(AL, 0, pixel, pixel, reg_imm(pixel, LSL, shift));
-    build_and_immediate(pixel, pixel, mask, 32);
-    if (adjust) {
-        if (round)
-            ADD(AL, 0, u, u, imm(1<<(adjust-1)));
-        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
-    }
-    MLA(AL, 0, d, pixel, u, d);
-    SUB(AL, 0, k, k, u);
-    
-    // LT -> (1-U)*(1-V)
-    RSB(AL, 0, V, V, imm(1<<FRAC_BITS));
-    LDRH(AL, pixel, txPtr.reg);
-    SMULBB(AL, u, U, V);
-    ORR(AL, 0, pixel, pixel, reg_imm(pixel, LSL, shift));
-    build_and_immediate(pixel, pixel, mask, 32);
-    if (adjust) {
-        if (round)
-            ADD(AL, 0, u, u, imm(1<<(adjust-1)));
-        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
-    }
-    MLA(AL, 0, d, pixel, u, d);
-
-    // RT -> U*(1-V)            
-    CONTEXT_LOAD(offset, generated_vars.rt);
-    LDRH(AL, pixel, txPtr.reg, reg_pre(offset));
-    SUB(AL, 0, u, k, u);
-    ORR(AL, 0, pixel, pixel, reg_imm(pixel, LSL, shift));
-    build_and_immediate(pixel, pixel, mask, 32);
-    MLA(AL, 0, texel.reg, pixel, u, d);
-}
-
-void GGLAssembler::filter24(
-        const fragment_parts_t& /*parts*/,
-        pixel_t& texel, const texture_unit_t& /*tmu*/,
-        int /*U*/, int /*V*/, pointer_t& txPtr,
-        int /*FRAC_BITS*/)
-{
-    // not supported yet (currently disabled)
-    load(txPtr, texel, 0);
-}
-
-void GGLAssembler::filter32(
-        const fragment_parts_t& /*parts*/,
-        pixel_t& texel, const texture_unit_t& /*tmu*/,
-        int U, int V, pointer_t& txPtr,
-        int FRAC_BITS)
-{
-    const int adjust = FRAC_BITS*2 - 8;
-    const int round  = 0;
-
-    // ------------------------
-    // about ~38 cycles / pixel
-    Scratch scratches(registerFile());
-    
-    int pixel= scratches.obtain();
-    int dh   = scratches.obtain();
-    int u    = scratches.obtain();
-    int k    = scratches.obtain();
-
-    int temp = scratches.obtain();
-    int dl   = scratches.obtain();
-    int mask = scratches.obtain();
-
-    MOV(AL, 0, mask, imm(0xFF));
-    ORR(AL, 0, mask, mask, imm(0xFF0000));
-
-    // RB -> U * V
-    int offset = pixel;
-    CONTEXT_LOAD(offset, generated_vars.rt);
-    CONTEXT_LOAD(u, generated_vars.lb);
-    ADD(AL, 0, offset, offset, u);
-
-    LDR(AL, pixel, txPtr.reg, reg_scale_pre(offset));
-    SMULBB(AL, u, U, V);
-    AND(AL, 0, temp, mask, pixel);
-    if (adjust) {
-        if (round)
-            ADD(AL, 0, u, u, imm(1<<(adjust-1)));
-        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
-    }
-    MUL(AL, 0, dh, temp, u);
-    AND(AL, 0, temp, mask, reg_imm(pixel, LSR, 8));
-    MUL(AL, 0, dl, temp, u);
-    RSB(AL, 0, k, u, imm(0x100));
-
-    // LB -> (1-U) * V
-    CONTEXT_LOAD(offset, generated_vars.lb);
-    RSB(AL, 0, U, U, imm(1<<FRAC_BITS));
-    LDR(AL, pixel, txPtr.reg, reg_scale_pre(offset));
-    SMULBB(AL, u, U, V);
-    AND(AL, 0, temp, mask, pixel);
-    if (adjust) {
-        if (round)
-            ADD(AL, 0, u, u, imm(1<<(adjust-1)));
-        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
-    }
-    MLA(AL, 0, dh, temp, u, dh);    
-    AND(AL, 0, temp, mask, reg_imm(pixel, LSR, 8));
-    MLA(AL, 0, dl, temp, u, dl);
-    SUB(AL, 0, k, k, u);
-
-    // LT -> (1-U)*(1-V)
-    RSB(AL, 0, V, V, imm(1<<FRAC_BITS));
-    LDR(AL, pixel, txPtr.reg);
-    SMULBB(AL, u, U, V);
-    AND(AL, 0, temp, mask, pixel);
-    if (adjust) {
-        if (round)
-            ADD(AL, 0, u, u, imm(1<<(adjust-1)));
-        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
-    }
-    MLA(AL, 0, dh, temp, u, dh);    
-    AND(AL, 0, temp, mask, reg_imm(pixel, LSR, 8));
-    MLA(AL, 0, dl, temp, u, dl);
-
-    // RT -> U*(1-V)            
-    CONTEXT_LOAD(offset, generated_vars.rt);
-    LDR(AL, pixel, txPtr.reg, reg_scale_pre(offset));
-    SUB(AL, 0, u, k, u);
-    AND(AL, 0, temp, mask, pixel);
-    MLA(AL, 0, dh, temp, u, dh);    
-    AND(AL, 0, temp, mask, reg_imm(pixel, LSR, 8));
-    MLA(AL, 0, dl, temp, u, dl);
-
-    AND(AL, 0, dh, mask, reg_imm(dh, LSR, 8));
-    AND(AL, 0, dl, dl, reg_imm(mask, LSL, 8));
-    ORR(AL, 0, texel.reg, dh, dl);
-}
-
-void GGLAssembler::build_texture_environment(
-        component_t& fragment,
-        const fragment_parts_t& parts,
-        int component,
-        Scratch& regs)
-{
-    const uint32_t component_mask = 1<<component;
-    const bool multiTexture = mTextureMachine.activeUnits > 1;
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; i++) {
-        texture_unit_t& tmu = mTextureMachine.tmu[i];
-
-        if (tmu.mask & component_mask) {
-            // replace or modulate with this texture
-            if ((tmu.replaced & component_mask) == 0) {
-                // not replaced by a later tmu...
-
-                Scratch scratches(registerFile());
-                pixel_t texel(parts.texel[i]);
-
-                if (multiTexture && 
-                    tmu.swrap == GGL_NEEDS_WRAP_11 &&
-                    tmu.twrap == GGL_NEEDS_WRAP_11)
-                {
-                    texel.reg = scratches.obtain();
-                    texel.flags |= CORRUPTIBLE;
-                    comment("fetch texel (multitexture 1:1)");
-                    load(parts.coords[i].ptr, texel, WRITE_BACK);
-                 }
-
-                component_t incoming(fragment);
-                modify(fragment, regs);
-                
-                switch (tmu.env) {
-                case GGL_REPLACE:
-                    extract(fragment, texel, component);
-                    break;
-                case GGL_MODULATE:
-                    modulate(fragment, incoming, texel, component);
-                    break;
-                case GGL_DECAL:
-                    decal(fragment, incoming, texel, component);
-                    break;
-                case GGL_BLEND:
-                    blend(fragment, incoming, texel, component, i);
-                    break;
-                case GGL_ADD:
-                    add(fragment, incoming, texel, component);
-                    break;
-                }
-            }
-        }
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::wrapping(
-            int d,
-            int coord, int size,
-            int tx_wrap, int tx_linear)
-{
-    // notes:
-    // if tx_linear is set, we need 4 extra bits of precision on the result
-    // SMULL/UMULL is 3 cycles
-    Scratch scratches(registerFile());
-    int c = coord;
-    if (tx_wrap == GGL_NEEDS_WRAP_REPEAT) {
-        // UMULL takes 4 cycles (interlocked), and we can get away with
-        // 2 cycles using SMULWB, but we're loosing 16 bits of precision
-        // out of 32 (this is not a problem because the iterator keeps
-        // its full precision)
-        // UMULL(AL, 0, size, d, c, size);
-        // note: we can't use SMULTB because it's signed.
-        MOV(AL, 0, d, reg_imm(c, LSR, 16-tx_linear));
-        SMULWB(AL, d, d, size);
-    } else if (tx_wrap == GGL_NEEDS_WRAP_CLAMP_TO_EDGE) {
-        if (tx_linear) {
-            // 1 cycle
-            MOV(AL, 0, d, reg_imm(coord, ASR, 16-tx_linear));
-        } else {
-            // 4 cycles (common case)
-            MOV(AL, 0, d, reg_imm(coord, ASR, 16));
-            BIC(AL, 0, d, d, reg_imm(d, ASR, 31));
-            CMP(AL, d, size);
-            SUB(GE, 0, d, size, imm(1));
-        }
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-void GGLAssembler::modulate(
-        component_t& dest, 
-        const component_t& incoming,
-        const pixel_t& incomingTexel, int component)
-{
-    Scratch locals(registerFile());
-    integer_t texel(locals.obtain(), 32, CORRUPTIBLE);            
-    extract(texel, incomingTexel, component);
-
-    const int Nt = texel.size();
-        // Nt should always be less than 10 bits because it comes
-        // from the TMU.
-
-    int Ni = incoming.size();
-        // Ni could be big because it comes from previous MODULATEs
-
-    if (Nt == 1) {
-        // texel acts as a bit-mask
-        // dest = incoming & ((texel << incoming.h)-texel)
-        RSB(AL, 0, dest.reg, texel.reg, reg_imm(texel.reg, LSL, incoming.h));
-        AND(AL, 0, dest.reg, dest.reg, incoming.reg);
-        dest.l = incoming.l;
-        dest.h = incoming.h;
-        dest.flags |= (incoming.flags & CLEAR_LO);
-    } else if (Ni == 1) {
-        MOV(AL, 0, dest.reg, reg_imm(incoming.reg, LSL, 31-incoming.h));
-        AND(AL, 0, dest.reg, texel.reg, reg_imm(dest.reg, ASR, 31));
-        dest.l = 0;
-        dest.h = Nt;
-    } else {
-        int inReg = incoming.reg;
-        int shift = incoming.l;
-        if ((Nt + Ni) > 32) {
-            // we will overflow, reduce the precision of Ni to 8 bits
-            // (Note Nt cannot be more than 10 bits which happens with 
-            // 565 textures and GGL_LINEAR)
-            shift += Ni-8;
-            Ni = 8;
-        }
-
-        // modulate by the component with the lowest precision
-        if (Nt >= Ni) {
-            if (shift) {
-                // XXX: we should be able to avoid this shift
-                // when shift==16 && Nt<16 && Ni<16, in which
-                // we could use SMULBT below.
-                MOV(AL, 0, dest.reg, reg_imm(inReg, LSR, shift));
-                inReg = dest.reg;
-                shift = 0;
-            }
-            // operation:           (Cf*Ct)/((1<<Ni)-1)
-            // approximated with:   Cf*(Ct + Ct>>(Ni-1))>>Ni
-            // this operation doesn't change texel's size
-            ADD(AL, 0, dest.reg, inReg, reg_imm(inReg, LSR, Ni-1));
-            if (Nt<16 && Ni<16) SMULBB(AL, dest.reg, texel.reg, dest.reg);
-            else                MUL(AL, 0, dest.reg, texel.reg, dest.reg);
-            dest.l = Ni;
-            dest.h = Nt + Ni;            
-        } else {
-            if (shift && (shift != 16)) {
-                // if shift==16, we can use 16-bits mul instructions later
-                MOV(AL, 0, dest.reg, reg_imm(inReg, LSR, shift));
-                inReg = dest.reg;
-                shift = 0;
-            }
-            // operation:           (Cf*Ct)/((1<<Nt)-1)
-            // approximated with:   Ct*(Cf + Cf>>(Nt-1))>>Nt
-            // this operation doesn't change incoming's size
-            Scratch scratches(registerFile());
-            int t = (texel.flags & CORRUPTIBLE) ? texel.reg : dest.reg;
-            if (t == inReg)
-                t = scratches.obtain();
-            ADD(AL, 0, t, texel.reg, reg_imm(texel.reg, LSR, Nt-1));
-            if (Nt<16 && Ni<16) {
-                if (shift==16)  SMULBT(AL, dest.reg, t, inReg);
-                else            SMULBB(AL, dest.reg, t, inReg);
-            } else              MUL(AL, 0, dest.reg, t, inReg);
-            dest.l = Nt;
-            dest.h = Nt + Ni;
-        }
-
-        // low bits are not valid
-        dest.flags |= CLEAR_LO;
-
-        // no need to keep more than 8 bits/component
-        if (dest.size() > 8)
-            dest.l = dest.h-8;
-    }
-}
-
-void GGLAssembler::decal(
-        component_t& dest, 
-        const component_t& incoming,
-        const pixel_t& incomingTexel, int component)
-{
-    // RGBA:
-    // Cv = Cf*(1 - At) + Ct*At = Cf + (Ct - Cf)*At
-    // Av = Af
-    Scratch locals(registerFile());
-    integer_t texel(locals.obtain(), 32, CORRUPTIBLE);            
-    integer_t factor(locals.obtain(), 32, CORRUPTIBLE);
-    extract(texel, incomingTexel, component);
-    extract(factor, incomingTexel, GGLFormat::ALPHA);
-
-    // no need to keep more than 8-bits for decal 
-    int Ni = incoming.size();
-    int shift = incoming.l;
-    if (Ni > 8) {
-        shift += Ni-8;
-        Ni = 8;
-    }
-    integer_t incomingNorm(incoming.reg, Ni, incoming.flags);
-    if (shift) {
-        MOV(AL, 0, dest.reg, reg_imm(incomingNorm.reg, LSR, shift));
-        incomingNorm.reg = dest.reg;
-        incomingNorm.flags |= CORRUPTIBLE;
-    }
-    ADD(AL, 0, factor.reg, factor.reg, reg_imm(factor.reg, LSR, factor.s-1));
-    build_blendOneMinusFF(dest, factor, incomingNorm, texel);
-}
-
-void GGLAssembler::blend(
-        component_t& dest, 
-        const component_t& incoming,
-        const pixel_t& incomingTexel, int component, int tmu)
-{
-    // RGBA:
-    // Cv = (1 - Ct)*Cf + Ct*Cc = Cf + (Cc - Cf)*Ct
-    // Av = At*Af
-
-    if (component == GGLFormat::ALPHA) {
-        modulate(dest, incoming, incomingTexel, component);
-        return;
-    }
-    
-    Scratch locals(registerFile());
-    integer_t color(locals.obtain(), 8, CORRUPTIBLE);            
-    integer_t factor(locals.obtain(), 32, CORRUPTIBLE);
-    LDRB(AL, color.reg, mBuilderContext.Rctx,
-            immed12_pre(GGL_OFFSETOF(state.texture[tmu].env_color[component])));
-    extract(factor, incomingTexel, component);
-
-    // no need to keep more than 8-bits for blend 
-    int Ni = incoming.size();
-    int shift = incoming.l;
-    if (Ni > 8) {
-        shift += Ni-8;
-        Ni = 8;
-    }
-    integer_t incomingNorm(incoming.reg, Ni, incoming.flags);
-    if (shift) {
-        MOV(AL, 0, dest.reg, reg_imm(incomingNorm.reg, LSR, shift));
-        incomingNorm.reg = dest.reg;
-        incomingNorm.flags |= CORRUPTIBLE;
-    }
-    ADD(AL, 0, factor.reg, factor.reg, reg_imm(factor.reg, LSR, factor.s-1));
-    build_blendOneMinusFF(dest, factor, incomingNorm, color);
-}
-
-void GGLAssembler::add(
-        component_t& dest, 
-        const component_t& incoming,
-        const pixel_t& incomingTexel, int component)
-{
-    // RGBA:
-    // Cv = Cf + Ct;
-    Scratch locals(registerFile());
-    
-    component_t incomingTemp(incoming);
-
-    // use "dest" as a temporary for extracting the texel, unless "dest"
-    // overlaps "incoming".
-    integer_t texel(dest.reg, 32, CORRUPTIBLE);
-    if (dest.reg == incomingTemp.reg)
-        texel.reg = locals.obtain();
-    extract(texel, incomingTexel, component);
-
-    if (texel.s < incomingTemp.size()) {
-        expand(texel, texel, incomingTemp.size());
-    } else if (texel.s > incomingTemp.size()) {
-        if (incomingTemp.flags & CORRUPTIBLE) {
-            expand(incomingTemp, incomingTemp, texel.s);
-        } else {
-            incomingTemp.reg = locals.obtain();
-            expand(incomingTemp, incoming, texel.s);
-        }
-    }
-
-    if (incomingTemp.l) {
-        ADD(AL, 0, dest.reg, texel.reg,
-                reg_imm(incomingTemp.reg, LSR, incomingTemp.l));
-    } else {
-        ADD(AL, 0, dest.reg, texel.reg, incomingTemp.reg);
-    }
-    dest.l = 0;
-    dest.h = texel.size();
-    component_sat(dest);
-}
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
diff --git a/libpixelflinger/codeflinger/tinyutils/smartpointer.h b/libpixelflinger/codeflinger/tinyutils/smartpointer.h
deleted file mode 100644
index 23a5f7e..0000000
--- a/libpixelflinger/codeflinger/tinyutils/smartpointer.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2005 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_PIXELFLINGER_SMART_POINTER_H
-#define ANDROID_PIXELFLINGER_SMART_POINTER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace tinyutils {
-
-// ---------------------------------------------------------------------------
-
-#define COMPARE(_op_)                                           \
-inline bool operator _op_ (const sp<T>& o) const {              \
-    return m_ptr _op_ o.m_ptr;                                  \
-}                                                               \
-inline bool operator _op_ (const T* o) const {                  \
-    return m_ptr _op_ o;                                        \
-}                                                               \
-template<typename U>                                            \
-inline bool operator _op_ (const sp<U>& o) const {              \
-    return m_ptr _op_ o.m_ptr;                                  \
-}                                                               \
-template<typename U>                                            \
-inline bool operator _op_ (const U* o) const {                  \
-    return m_ptr _op_ o;                                        \
-}
-
-// ---------------------------------------------------------------------------
-
-template <typename T>
-class sp
-{
-public:
-    inline sp() : m_ptr(0) { }
-
-    sp(T* other);  // NOLINT, implicit
-    sp(const sp<T>& other);
-    template<typename U> sp(U* other);  // NOLINT, implicit
-    template<typename U> sp(const sp<U>& other);  // NOLINT, implicit
-
-    ~sp();
-    
-    // Assignment
-
-    sp& operator = (T* other);
-    sp& operator = (const sp<T>& other);
-    
-    template<typename U> sp& operator = (const sp<U>& other);
-    template<typename U> sp& operator = (U* other);
-    
-    // Reset
-    void clear();
-    
-    // Accessors
-
-    inline  T&      operator* () const  { return *m_ptr; }
-    inline  T*      operator-> () const { return m_ptr;  }
-    inline  T*      get() const         { return m_ptr; }
-
-    // Operators
-        
-    COMPARE(==)
-    COMPARE(!=)
-    COMPARE(>)
-    COMPARE(<)
-    COMPARE(<=)
-    COMPARE(>=)
-
-private:    
-    template<typename Y> friend class sp;
-
-    T*              m_ptr;
-};
-
-// ---------------------------------------------------------------------------
-// No user serviceable parts below here.
-
-template<typename T>
-sp<T>::sp(T* other)
-    : m_ptr(other)
-{
-    if (other) other->incStrong(this);
-}
-
-template<typename T>
-sp<T>::sp(const sp<T>& other)
-    : m_ptr(other.m_ptr)
-{
-    if (m_ptr) m_ptr->incStrong(this);
-}
-
-template<typename T> template<typename U>
-sp<T>::sp(U* other) : m_ptr(other)
-{
-    if (other) other->incStrong(this);
-}
-
-template<typename T> template<typename U>
-sp<T>::sp(const sp<U>& other)
-    : m_ptr(other.m_ptr)
-{
-    if (m_ptr) m_ptr->incStrong(this);
-}
-
-template<typename T>
-sp<T>::~sp()
-{
-    if (m_ptr) m_ptr->decStrong(this);
-}
-
-template<typename T>
-sp<T>& sp<T>::operator = (const sp<T>& other) {
-    if (other.m_ptr) other.m_ptr->incStrong(this);
-    if (m_ptr) m_ptr->decStrong(this);
-    m_ptr = other.m_ptr;
-    return *this;
-}
-
-template<typename T>
-sp<T>& sp<T>::operator = (T* other)
-{
-    if (other) other->incStrong(this);
-    if (m_ptr) m_ptr->decStrong(this);
-    m_ptr = other;
-    return *this;
-}
-
-template<typename T> template<typename U>
-sp<T>& sp<T>::operator = (const sp<U>& other)
-{
-    if (other.m_ptr) other.m_ptr->incStrong(this);
-    if (m_ptr) m_ptr->decStrong(this);
-    m_ptr = other.m_ptr;
-    return *this;
-}
-
-template<typename T> template<typename U>
-sp<T>& sp<T>::operator = (U* other)
-{
-    if (other) other->incStrong(this);
-    if (m_ptr) m_ptr->decStrong(this);
-    m_ptr = other;
-    return *this;
-}
-
-template<typename T>
-void sp<T>::clear()
-{
-    if (m_ptr) {
-        m_ptr->decStrong(this);
-        m_ptr = 0;
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-} // namespace tinyutils
-} // namespace android
-
-// ---------------------------------------------------------------------------
-
-#endif // ANDROID_PIXELFLINGER_SMART_POINTER_H
diff --git a/libpixelflinger/col32cb16blend.S b/libpixelflinger/col32cb16blend.S
deleted file mode 100644
index 39f94e1..0000000
--- a/libpixelflinger/col32cb16blend.S
+++ /dev/null
@@ -1,77 +0,0 @@
-/* libs/pixelflinger/col32cb16blend.S
- *
- * Copyright (C) 2009 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.
- */
-
-    .text
-    .balign 4
-
-    .global scanline_col32cb16blend_arm
-
-//
-// This function alpha blends a fixed color into a destination scanline, using
-// the formula:
-//
-//     d = s + (((a + (a >> 7)) * d) >> 8)
-//
-// where d is the destination pixel,
-//       s is the source color,
-//       a is the alpha channel of the source color.
-//
-
-// r0 = destination buffer pointer
-// r1 = color value
-// r2 = count
-
-
-scanline_col32cb16blend_arm:
-    push        {r4-r10, lr}                    // stack ARM regs
-
-    mov         r5, r1, lsr #24                 // shift down alpha
-    mov         r9, #0xff                       // create mask
-    add         r5, r5, r5, lsr #7              // add in top bit
-    rsb         r5, r5, #256                    // invert alpha
-    and         r10, r1, #0xff                  // extract red
-    and         r12, r9, r1, lsr #8             // extract green
-    and         r4, r9, r1, lsr #16             // extract blue
-    mov         r10, r10, lsl #5                // prescale red
-    mov         r12, r12, lsl #6                // prescale green
-    mov         r4, r4, lsl #5                  // prescale blue
-    mov         r9, r9, lsr #2                  // create dest green mask
-
-1:
-    ldrh        r8, [r0]                        // load dest pixel
-    subs        r2, r2, #1                      // decrement loop counter
-    mov         r6, r8, lsr #11                 // extract dest red
-    and         r7, r9, r8, lsr #5              // extract dest green
-    and         r8, r8, #0x1f                   // extract dest blue
-
-    smlabb      r6, r6, r5, r10                 // dest red * alpha + src red
-    smlabb      r7, r7, r5, r12                 // dest green * alpha + src green
-    smlabb      r8, r8, r5, r4                  // dest blue * alpha + src blue
-
-    mov         r6, r6, lsr #8                  // shift down red
-    mov         r7, r7, lsr #8                  // shift down green
-    mov         r6, r6, lsl #11                 // shift red into 565
-    orr         r6, r7, lsl #5                  // shift green into 565
-    orr         r6, r8, lsr #8                  // shift blue into 565
-
-    strh        r6, [r0], #2                    // store pixel to dest, update ptr
-    bne         1b                              // if count != 0, loop
-
-    pop         {r4-r10, pc}                    // return
-
-
-
diff --git a/libpixelflinger/col32cb16blend_neon.S b/libpixelflinger/col32cb16blend_neon.S
deleted file mode 100644
index 7ad34b0..0000000
--- a/libpixelflinger/col32cb16blend_neon.S
+++ /dev/null
@@ -1,153 +0,0 @@
-/* libs/pixelflinger/col32cb16blend_neon.S
- *
- * Copyright (C) 2009 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.
- */
-
-
-    .text
-    .balign 4
-
-    .global scanline_col32cb16blend_neon
-
-//
-// This function alpha blends a fixed color into a destination scanline, using
-// the formula:
-//
-//     d = s + (((a + (a >> 7)) * d) >> 8)
-//
-// where d is the destination pixel,
-//       s is the source color,
-//       a is the alpha channel of the source color.
-//
-// The NEON implementation processes 16 pixels per iteration. The remaining 0 - 15
-// pixels are processed in ARM code.
-//
-
-// r0 = destination buffer pointer
-// r1 = color pointer
-// r2 = count
-
-
-scanline_col32cb16blend_neon:
-    push        {r4-r11, lr}                    // stack ARM regs
-
-    vmov.u16    q15, #256                       // create alpha constant
-    movs        r3, r2, lsr #4                  // calc. sixteens iterations
-    vmov.u16    q14, #0x1f                      // create blue mask
-
-    beq         2f                              // if r3 == 0, branch to singles
-
-    vld4.8      {d0[], d2[], d4[], d6[]}, [r1]  // load color into four registers
-                                                //  split and duplicate them, such that
-                                                //  d0 = 8 equal red values
-                                                //  d2 = 8 equal green values
-                                                //  d4 = 8 equal blue values
-                                                //  d6 = 8 equal alpha values
-    vshll.u8    q0, d0, #5                      // shift up red and widen
-    vshll.u8    q1, d2, #6                      // shift up green and widen
-    vshll.u8    q2, d4, #5                      // shift up blue and widen
-
-    vshr.u8     d7, d6, #7                      // extract top bit of alpha
-    vaddl.u8    q3, d6, d7                      // add top bit into alpha
-    vsub.u16    q3, q15, q3                     // invert alpha
-
-1:
-    // This loop processes 16 pixels per iteration. In the comments, references to
-    // the first eight pixels are suffixed with "0" (red0, green0, blue0), 
-    // the second eight are suffixed "1".
-                                                // q8  = dst red0
-                                                // q9  = dst green0
-                                                // q10 = dst blue0
-                                                // q13 = dst red1
-                                                // q12 = dst green1
-                                                // q11 = dst blue1
-
-    vld1.16     {d20, d21, d22, d23}, [r0]      // load 16 dest pixels
-    vshr.u16    q8, q10, #11                    // shift dst red0 to low 5 bits
-    pld         [r0, #63]                       // preload next dest pixels
-    vshl.u16    q9, q10, #5                     // shift dst green0 to top 6 bits
-    vand        q10, q10, q14                   // extract dst blue0
-    vshr.u16    q9, q9, #10                     // shift dst green0 to low 6 bits
-    vmul.u16    q8, q8, q3                      // multiply dst red0 by src alpha
-    vshl.u16    q12, q11, #5                    // shift dst green1 to top 6 bits
-    vmul.u16    q9, q9, q3                      // multiply dst green0 by src alpha
-    vshr.u16    q13, q11, #11                   // shift dst red1 to low 5 bits
-    vmul.u16    q10, q10, q3                    // multiply dst blue0 by src alpha
-    vshr.u16    q12, q12, #10                   // shift dst green1 to low 6 bits
-    vand        q11, q11, q14                   // extract dst blue1
-    vadd.u16    q8, q8, q0                      // add src red to dst red0
-    vmul.u16    q13, q13, q3                    // multiply dst red1 by src alpha
-    vadd.u16    q9, q9, q1                      // add src green to dst green0 
-    vmul.u16    q12, q12, q3                    // multiply dst green1 by src alpha
-    vadd.u16    q10, q10, q2                    // add src blue to dst blue0
-    vmul.u16    q11, q11, q3                    // multiply dst blue1 by src alpha
-    vshr.u16    q8, q8, #8                      // shift down red0
-    vadd.u16    q13, q13, q0                    // add src red to dst red1
-    vshr.u16    q9, q9, #8                      // shift down green0
-    vadd.u16    q12, q12, q1                    // add src green to dst green1
-    vshr.u16    q10, q10, #8                    // shift down blue0
-    vadd.u16    q11, q11, q2                    // add src blue to dst blue1
-    vsli.u16    q10, q9, #5                     // shift & insert green0 into blue0
-    vshr.u16    q13, q13, #8                    // shift down red1
-    vsli.u16    q10, q8, #11                    // shift & insert red0 into blue0    
-    vshr.u16    q12, q12, #8                    // shift down green1
-    vshr.u16    q11, q11, #8                    // shift down blue1
-    subs        r3, r3, #1                      // decrement loop counter
-    vsli.u16    q11, q12, #5                    // shift & insert green1 into blue1
-    vsli.u16    q11, q13, #11                   // shift & insert red1 into blue1
-
-    vst1.16     {d20, d21, d22, d23}, [r0]!     // write 16 pixels back to dst
-    bne         1b                              // if count != 0, loop
-
-2:
-    ands        r3, r2, #15                     // calc. single iterations 
-    beq         4f                              // if r3 == 0, exit
-
-    ldr         r4, [r1]                        // load source color
-    mov         r5, r4, lsr #24                 // shift down alpha
-    add         r5, r5, r5, lsr #7              // add in top bit
-    rsb         r5, r5, #256                    // invert alpha
-    and         r11, r4, #0xff                  // extract red
-    ubfx        r12, r4, #8, #8                 // extract green
-    ubfx        r4, r4, #16, #8                 // extract blue
-    mov         r11, r11, lsl #5                // prescale red
-    mov         r12, r12, lsl #6                // prescale green
-    mov         r4, r4, lsl #5                  // prescale blue
-
-3:
-    ldrh        r8, [r0]                        // load dest pixel
-    subs        r3, r3, #1                      // decrement loop counter
-    mov         r6, r8, lsr #11                 // extract dest red
-    ubfx        r7, r8, #5, #6                  // extract dest green
-    and         r8, r8, #0x1f                   // extract dest blue
-
-    smlabb      r6, r6, r5, r11                 // dest red * alpha + src red
-    smlabb      r7, r7, r5, r12                 // dest green * alpha + src green
-    smlabb      r8, r8, r5, r4                  // dest blue * alpha + src blue
-
-    mov         r6, r6, lsr #8                  // shift down red
-    mov         r7, r7, lsr #8                  // shift down green
-    mov         r6, r6, lsl #11                 // shift red into 565
-    orr         r6, r7, lsl #5                  // shift green into 565
-    orr         r6, r8, lsr #8                  // shift blue into 565
-
-    strh        r6, [r0], #2                    // store pixel to dest, update ptr
-    bne         3b                              // if count != 0, loop
-4:
-
-    pop         {r4-r11, pc}                    // return
-
-
-
diff --git a/libpixelflinger/fixed.cpp b/libpixelflinger/fixed.cpp
deleted file mode 100644
index de6b479..0000000
--- a/libpixelflinger/fixed.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-/* libs/pixelflinger/fixed.cpp
-**
-** Copyright 2006, 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 <stdio.h>
-
-#include <private/pixelflinger/ggl_context.h>
-#include <private/pixelflinger/ggl_fixed.h>
-
-
-// ------------------------------------------------------------------------
-
-int32_t gglRecipQNormalized(int32_t x, int* exponent)
-{
-    const int32_t s = x>>31;
-    uint32_t a = s ? -x : x;
-
-    // the result will overflow, so just set it to the biggest/inf value
-    if (ggl_unlikely(a <= 2LU)) {
-        *exponent = 0;
-        return s ? FIXED_MIN : FIXED_MAX;
-    }
-
-    // Newton-Raphson iteration:
-    // x = r*(2 - a*r)
-
-    const int32_t lz = gglClz(a);
-    a <<= lz;  // 0.32
-    uint32_t r = a;
-    // note: if a == 0x80000000, this means x was a power-of-2, in this
-    // case we don't need to compute anything. We get the reciprocal for
-    // (almost) free.
-    if (a != 0x80000000) {
-        r = (0x2E800 << (30-16)) - (r>>(2-1)); // 2.30, r = 2.90625 - 2*a
-        // 0.32 + 2.30 = 2.62 -> 2.30
-        // 2.30 + 2.30 = 4.60 -> 2.30
-        r = (((2LU<<30) - uint32_t((uint64_t(a)*r) >> 32)) * uint64_t(r)) >> 30;
-        r = (((2LU<<30) - uint32_t((uint64_t(a)*r) >> 32)) * uint64_t(r)) >> 30;
-    }
-
-    // shift right 1-bit to make room for the sign bit
-    *exponent = 30-lz-1;
-    r >>= 1;
-    return s ? -r : r;
-}
-
-int32_t gglRecipQ(GGLfixed x, int q)
-{
-    int shift;
-    x = gglRecipQNormalized(x, &shift);
-    shift += 16-q;
-    if (shift > 0)
-        x += 1L << (shift-1);   // rounding
-    x >>= shift;
-    return x;
-}    
-
-// ------------------------------------------------------------------------
-
-static const GGLfixed ggl_sqrt_reciproc_approx_tab[8] = {
-    // 1/sqrt(x) with x = 1-N/16, N=[8...1]
-    0x16A09, 0x15555, 0x143D1, 0x134BF, 0x1279A, 0x11C01, 0x111AC, 0x10865
-};
-
-GGLfixed gglSqrtRecipx(GGLfixed x)
-{
-    if (x == 0)         return FIXED_MAX;
-    if (x == FIXED_ONE) return x;
-    const GGLfixed a = x;
-    const int32_t lz = gglClz(x);
-    x = ggl_sqrt_reciproc_approx_tab[(a>>(28-lz))&0x7];
-    const int32_t exp = lz - 16;
-    if (exp <= 0)   x >>= -exp>>1;
-    else            x <<= (exp>>1) + (exp & 1);        
-    if (exp & 1) {
-        x = gglMulx(x, ggl_sqrt_reciproc_approx_tab[0])>>1;
-    }
-    // 2 Newton-Raphson iterations: x = x/2*(3-(a*x)*x)
-    x = gglMulx((x>>1),(0x30000 - gglMulx(gglMulx(a,x),x)));
-    x = gglMulx((x>>1),(0x30000 - gglMulx(gglMulx(a,x),x)));
-    return x;
-}
-
-GGLfixed gglSqrtx(GGLfixed a)
-{
-    // Compute a full precision square-root (24 bits accuracy)
-    GGLfixed r = 0;
-    GGLfixed bit = 0x800000;
-    int32_t bshift = 15;
-    do {
-        GGLfixed temp = bit + (r<<1);
-        if (bshift >= 8)    temp <<= (bshift-8);
-        else                temp >>= (8-bshift);
-        if (a >= temp) {
-            r += bit;
-            a -= temp;
-        }
-        bshift--;
-    } while (bit>>=1);
-    return r;
-}
-
-// ------------------------------------------------------------------------
-
-static const GGLfixed ggl_log_approx_tab[] = {
-    // -ln(x)/ln(2) with x = N/16, N=[8...16]
-    0xFFFF, 0xd47f, 0xad96, 0x8a62, 0x6a3f, 0x4caf, 0x3151, 0x17d6, 0x0000
-};
-
-static const GGLfixed ggl_alog_approx_tab[] = { // domain [0 - 1.0]
-	0xffff, 0xeac0, 0xd744, 0xc567, 0xb504, 0xa5fe, 0x9837, 0x8b95, 0x8000
-};
-
-GGLfixed gglPowx(GGLfixed x, GGLfixed y)
-{
-    // prerequisite: 0 <= x <= 1, and y >=0
-
-    // pow(x,y) = 2^(y*log2(x))
-    // =  2^(y*log2(x*(2^exp)*(2^-exp))))
-    // =  2^(y*(log2(X)-exp))
-    // =  2^(log2(X)*y - y*exp)
-    // =  2^( - (-log2(X)*y + y*exp) )
-    
-    int32_t exp = gglClz(x) - 16;
-    GGLfixed f = x << exp;
-    x = (f & 0x0FFF)<<4;
-    f = (f >> 12) & 0x7;
-    GGLfixed p = gglMulAddx(
-            ggl_log_approx_tab[f+1] - ggl_log_approx_tab[f], x,
-            ggl_log_approx_tab[f]);
-    p = gglMulAddx(p, y, y*exp);
-    exp = gglFixedToIntFloor(p);
-    if (exp < 31) {
-        p = gglFracx(p);
-        x = (p & 0x1FFF)<<3;
-        p >>= 13;    
-        p = gglMulAddx(
-                ggl_alog_approx_tab[p+1] - ggl_alog_approx_tab[p], x,
-                ggl_alog_approx_tab[p]);
-        p >>= exp;
-    } else {
-        p = 0;
-    }
-    return p;
-        // ( powf((a*65536.0f), (b*65536.0f)) ) * 65536.0f;
-}
-
-// ------------------------------------------------------------------------
-
-int32_t gglDivQ(GGLfixed n, GGLfixed d, int32_t i)
-{
-    //int32_t r =int32_t((int64_t(n)<<i)/d);
-    const int32_t ds = n^d;
-    if (n<0) n = -n;
-    if (d<0) d = -d;
-    int nd = gglClz(d) - gglClz(n);
-    i += nd + 1;
-    if (nd > 0) d <<= nd;
-    else        n <<= -nd;
-    uint32_t q = 0;
-
-    int j = i & 7;
-    i >>= 3;
-
-    // gcc deals with the code below pretty well.
-    // we get 3.75 cycles per bit in the main loop
-    // and 8 cycles per bit in the termination loop
-    if (ggl_likely(i)) {
-        n -= d;
-        do {
-            q <<= 8;
-            if (n>=0)   q |= 128;
-            else        n += d;
-            n = n*2 - d;
-            if (n>=0)   q |= 64;
-            else        n += d;
-            n = n*2 - d;
-            if (n>=0)   q |= 32;
-            else        n += d;
-            n = n*2 - d;
-            if (n>=0)   q |= 16;
-            else        n += d;
-            n = n*2 - d;
-            if (n>=0)   q |= 8;
-            else        n += d;
-            n = n*2 - d;
-            if (n>=0)   q |= 4;
-            else        n += d;
-            n = n*2 - d;
-            if (n>=0)   q |= 2;
-            else        n += d;
-            n = n*2 - d;
-            if (n>=0)   q |= 1;
-            else        n += d;
-            
-            if (--i == 0)
-                goto finish;
-
-            n = n*2 - d;
-        } while(true);
-        do {
-            q <<= 1;
-            n = n*2 - d;
-            if (n>=0)   q |= 1;
-            else        n += d;
-        finish: ;
-        } while (j--);
-        return (ds<0) ? -q : q;
-    }
-
-    n -= d;
-    if (n>=0)   q |= 1;
-    else        n += d;
-    j--;
-    goto finish;
-}
-
-// ------------------------------------------------------------------------
-
-// assumes that the int32_t values of a, b, and c are all positive
-// use when both a and b are larger than c
-
-template <typename T>
-static inline void swap(T& a, T& b) {
-    T t(a);
-    a = b;
-    b = t;
-}
-
-static __attribute__((noinline))
-int32_t slow_muldiv(uint32_t a, uint32_t b, uint32_t c)
-{
-	// first we compute a*b as a 64-bit integer
-    // (GCC generates umull with the code below)
-    uint64_t ab = uint64_t(a)*b;
-    uint32_t hi = ab>>32;
-    uint32_t lo = ab;
-    uint32_t result;
-
-	// now perform the division
-	if (hi >= c) {
-	overflow:
-		result = 0x7fffffff;  // basic overflow
-	} else if (hi == 0) {
-		result = lo/c;  // note: c can't be 0
-		if ((result >> 31) != 0)  // result must fit in 31 bits
-			goto overflow;
-	} else {
-		uint32_t r = hi;
-		int bits = 31;
-	    result = 0;
-		do {
-			r = (r << 1) | (lo >> 31);
-			lo <<= 1;
-			result <<= 1;
-			if (r >= c) {
-				r -= c;
-				result |= 1;
-			}
-		} while (bits--);
-	}
-	return int32_t(result);
-}
-
-// assumes a >= 0 and c >= b >= 0
-static inline
-int32_t quick_muldiv(int32_t a, int32_t b, int32_t c)
-{
-    int32_t r = 0, q = 0, i;
-    int leading = gglClz(a);
-    i = 32 - leading;
-    a <<= leading;
-    do {
-        r <<= 1;
-        if (a < 0)
-            r += b;
-        a <<= 1;
-        q <<= 1;
-        if (r >= c) {
-            r -= c;
-            q++;
-        }
-        asm(""::); // gcc generates better code this way
-        if (r >= c) {
-            r -= c;
-            q++;
-        }
-    }
-    while (--i);
-    return q;
-}
-
-// this function computes a*b/c with 64-bit intermediate accuracy
-// overflows (e.g. division by 0) are handled and return INT_MAX
-
-int32_t gglMulDivi(int32_t a, int32_t b, int32_t c)
-{
-	int32_t result;
-	int32_t sign = a^b^c;
-
-	if (a < 0) a = -a;
-	if (b < 0) b = -b;
-	if (c < 0) c = -c;
-
-    if (a < b) {
-        swap(a, b);
-    }
-    
-	if (b <= c) result = quick_muldiv(a, b, c);
-	else        result = slow_muldiv((uint32_t)a, (uint32_t)b, (uint32_t)c);
-	
-	if (sign < 0)
-		result = -result;
-	  
-    return result;
-}
diff --git a/libpixelflinger/format.cpp b/libpixelflinger/format.cpp
deleted file mode 100644
index 6546e8c..0000000
--- a/libpixelflinger/format.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* libs/pixelflinger/format.cpp
-**
-** Copyright 2006, 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 <stdio.h>
-#include <pixelflinger/format.h>
-
-namespace android {
-
-static GGLFormat const gPixelFormatInfos[] =
-{   //          Alpha    Red     Green   Blue
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  4, 32, {{32,24,   8, 0,  16, 8,  24,16 }}, GGL_RGBA },   // PIXEL_FORMAT_RGBA_8888
-    {  4, 24, {{ 0, 0,   8, 0,  16, 8,  24,16 }}, GGL_RGB  },   // PIXEL_FORMAT_RGBX_8888
-    {  3, 24, {{ 0, 0,   8, 0,  16, 8,  24,16 }}, GGL_RGB  },   // PIXEL_FORMAT_RGB_888
-    {  2, 16, {{ 0, 0,  16,11,  11, 5,   5, 0 }}, GGL_RGB  },   // PIXEL_FORMAT_RGB_565
-    {  4, 32, {{32,24,  24,16,  16, 8,   8, 0 }}, GGL_RGBA },   // PIXEL_FORMAT_BGRA_8888
-    {  2, 16, {{ 1, 0,  16,11,  11, 6,   6, 1 }}, GGL_RGBA },   // PIXEL_FORMAT_RGBA_5551
-    {  2, 16, {{ 4, 0,  16,12,  12, 8,   8, 4 }}, GGL_RGBA },   // PIXEL_FORMAT_RGBA_4444
-    {  1,  8, {{ 8, 0,   0, 0,   0, 0,   0, 0 }}, GGL_ALPHA},   // PIXEL_FORMAT_A8
-    {  1,  8, {{ 0, 0,   8, 0,   8, 0,   8, 0 }}, GGL_LUMINANCE},//PIXEL_FORMAT_L8
-    {  2, 16, {{16, 8,   8, 0,   8, 0,   8, 0 }}, GGL_LUMINANCE_ALPHA},// PIXEL_FORMAT_LA_88
-    {  1,  8, {{ 0, 0,   8, 5,   5, 2,   2, 0 }}, GGL_RGB  },   // PIXEL_FORMAT_RGB_332
-    
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    
-    {  2, 16, {{  0, 0, 16, 0,   0, 0,   0, 0 }}, GGL_DEPTH_COMPONENT},
-    {  1,  8, {{  8, 0,  0, 0,   0, 0,   0, 0 }}, GGL_STENCIL_INDEX  },
-    {  4, 24, {{  0, 0, 24, 0,   0, 0,   0, 0 }}, GGL_DEPTH_COMPONENT},
-    {  4,  8, {{ 32,24,  0, 0,   0, 0,   0, 0 }}, GGL_STENCIL_INDEX  },
-
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-    {  0,  0, {{ 0, 0,   0, 0,   0, 0,   0, 0 }},        0 },   // PIXEL_FORMAT_NONE
-
-};
-
-}; // namespace android
-
-
-const GGLFormat* gglGetPixelFormatTable(size_t* numEntries)
-{
-    if (numEntries) {
-        *numEntries = sizeof(android::gPixelFormatInfos)/sizeof(GGLFormat);
-    }
-    return android::gPixelFormatInfos;
-}
diff --git a/libpixelflinger/include/pixelflinger/format.h b/libpixelflinger/include/pixelflinger/format.h
deleted file mode 100644
index d429477..0000000
--- a/libpixelflinger/include/pixelflinger/format.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2005 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_PIXELFLINGER_FORMAT_H
-#define ANDROID_PIXELFLINGER_FORMAT_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-enum GGLPixelFormat {
-    // these constants need to match those
-    // in graphics/PixelFormat.java, ui/PixelFormat.h, BlitHardware.h
-    GGL_PIXEL_FORMAT_UNKNOWN    =   0,
-    GGL_PIXEL_FORMAT_NONE       =   0,
-
-    GGL_PIXEL_FORMAT_RGBA_8888   =   1,  // 4x8-bit ARGB
-    GGL_PIXEL_FORMAT_RGBX_8888   =   2,  // 3x8-bit RGB stored in 32-bit chunks
-    GGL_PIXEL_FORMAT_RGB_888     =   3,  // 3x8-bit RGB
-    GGL_PIXEL_FORMAT_RGB_565     =   4,  // 16-bit RGB
-    GGL_PIXEL_FORMAT_BGRA_8888   =   5,  // 4x8-bit BGRA
-    GGL_PIXEL_FORMAT_RGBA_5551   =   6,  // 16-bit RGBA
-    GGL_PIXEL_FORMAT_RGBA_4444   =   7,  // 16-bit RGBA
-
-    GGL_PIXEL_FORMAT_A_8         =   8,  // 8-bit A
-    GGL_PIXEL_FORMAT_L_8         =   9,  // 8-bit L (R=G=B = L)
-    GGL_PIXEL_FORMAT_LA_88       = 0xA,  // 16-bit LA
-    GGL_PIXEL_FORMAT_RGB_332     = 0xB,  // 8-bit RGB (non paletted)
-
-    // reserved range. don't use.
-    GGL_PIXEL_FORMAT_RESERVED_10 = 0x10,
-    GGL_PIXEL_FORMAT_RESERVED_11 = 0x11,
-    GGL_PIXEL_FORMAT_RESERVED_12 = 0x12,
-    GGL_PIXEL_FORMAT_RESERVED_13 = 0x13,
-    GGL_PIXEL_FORMAT_RESERVED_14 = 0x14,
-    GGL_PIXEL_FORMAT_RESERVED_15 = 0x15,
-    GGL_PIXEL_FORMAT_RESERVED_16 = 0x16,
-    GGL_PIXEL_FORMAT_RESERVED_17 = 0x17,
-
-    // reserved/special formats
-    GGL_PIXEL_FORMAT_Z_16       =  0x18,
-    GGL_PIXEL_FORMAT_S_8        =  0x19,
-    GGL_PIXEL_FORMAT_SZ_24      =  0x1A,
-    GGL_PIXEL_FORMAT_SZ_8       =  0x1B,
-
-    // reserved range. don't use.
-    GGL_PIXEL_FORMAT_RESERVED_20 = 0x20,
-    GGL_PIXEL_FORMAT_RESERVED_21 = 0x21,
-};
-
-enum GGLFormatComponents {
-	GGL_STENCIL_INDEX		= 0x1901,
-	GGL_DEPTH_COMPONENT		= 0x1902,
-	GGL_ALPHA				= 0x1906,
-	GGL_RGB					= 0x1907,
-	GGL_RGBA				= 0x1908,
-	GGL_LUMINANCE			= 0x1909,
-	GGL_LUMINANCE_ALPHA		= 0x190A,
-};
-
-enum GGLFormatComponentIndex {
-    GGL_INDEX_ALPHA   = 0,
-    GGL_INDEX_RED     = 1,
-    GGL_INDEX_GREEN   = 2,
-    GGL_INDEX_BLUE    = 3,
-    GGL_INDEX_STENCIL = 0,
-    GGL_INDEX_DEPTH   = 1,
-    GGL_INDEX_Y       = 0,
-    GGL_INDEX_CB      = 1,
-    GGL_INDEX_CR      = 2,
-};
-
-typedef struct GGLFormat {
-#ifdef __cplusplus
-    enum {
-        ALPHA   = GGL_INDEX_ALPHA,
-        RED     = GGL_INDEX_RED,
-        GREEN   = GGL_INDEX_GREEN,
-        BLUE    = GGL_INDEX_BLUE,
-        STENCIL = GGL_INDEX_STENCIL,
-        DEPTH   = GGL_INDEX_DEPTH,
-        LUMA    = GGL_INDEX_Y,
-        CHROMAB = GGL_INDEX_CB,
-        CHROMAR = GGL_INDEX_CR,
-    };
-    inline uint32_t mask(int i) const {
-            return ((1<<(c[i].h-c[i].l))-1)<<c[i].l;
-    }
-    inline uint32_t bits(int i) const {
-            return c[i].h - c[i].l;
-    }
-#endif
-	uint8_t     size;	// bytes per pixel
-    uint8_t     bitsPerPixel;
-    union {    
-        struct {
-            uint8_t     ah;		// alpha high bit position + 1
-            uint8_t     al;		// alpha low bit position
-            uint8_t     rh;		// red high bit position + 1
-            uint8_t     rl;		// red low bit position
-            uint8_t     gh;		// green high bit position + 1
-            uint8_t     gl;		// green low bit position
-            uint8_t     bh;		// blue high bit position + 1
-            uint8_t     bl;		// blue low bit position
-        };
-        struct {
-            uint8_t h;
-            uint8_t l;
-        } __attribute__((__packed__)) c[4];        
-    } __attribute__((__packed__));
-	uint16_t    components;	// GGLFormatComponents
-} GGLFormat;
-
-
-#ifdef __cplusplus
-extern "C" const GGLFormat* gglGetPixelFormatTable(size_t* numEntries = 0);
-#else
-const GGLFormat* gglGetPixelFormatTable(size_t* numEntries);
-#endif
-
-
-// ----------------------------------------------------------------------------
-
-#endif // ANDROID_PIXELFLINGER_FORMAT_H
diff --git a/libpixelflinger/include/pixelflinger/pixelflinger.h b/libpixelflinger/include/pixelflinger/pixelflinger.h
deleted file mode 100644
index 8a2b442..0000000
--- a/libpixelflinger/include/pixelflinger/pixelflinger.h
+++ /dev/null
@@ -1,330 +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.
- */
-
-#ifndef ANDROID_PIXELFLINGER_H
-#define ANDROID_PIXELFLINGER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <pixelflinger/format.h>
-
-// GGL types
-
-typedef int8_t			GGLbyte;		// b
-typedef int16_t			GGLshort;		// s
-typedef int32_t			GGLint;			// i
-typedef ssize_t			GGLsizei;		// i
-typedef int32_t			GGLfixed;		// x
-typedef int32_t			GGLclampx;		// x
-typedef float			GGLfloat;		// f
-typedef float			GGLclampf;		// f
-typedef double			GGLdouble;		// d
-typedef double			GGLclampd;		// d
-typedef uint8_t			GGLubyte;		// ub
-typedef uint8_t			GGLboolean;		// ub
-typedef uint16_t		GGLushort;		// us
-typedef uint32_t		GGLuint;		// ui
-typedef unsigned int	GGLenum;		// ui
-typedef unsigned int	GGLbitfield;	// ui
-typedef void			GGLvoid;
-typedef int32_t         GGLfixed32;
-typedef	int32_t         GGLcolor;
-typedef int32_t         GGLcoord;
-
-// ----------------------------------------------------------------------------
-
-#define GGL_MAX_VIEWPORT_DIMS           4096
-#define GGL_MAX_TEXTURE_SIZE            4096
-#define GGL_MAX_ALIASED_POINT_SIZE      0x7FFFFFF
-#define GGL_MAX_SMOOTH_POINT_SIZE       2048
-#define GGL_MAX_SMOOTH_LINE_WIDTH       2048
-
-// ----------------------------------------------------------------------------
-
-// All these names are compatible with their OpenGL equivalents
-// some of them are listed only for completeness
-enum GGLNames {
-	GGL_FALSE						= 0,
-	GGL_TRUE						= 1,
-
-	// enable/disable
-    GGL_SCISSOR_TEST                = 0x0C11,
-	GGL_TEXTURE_2D					= 0x0DE1,
-	GGL_ALPHA_TEST					= 0x0BC0,
-	GGL_BLEND						= 0x0BE2,
-	GGL_COLOR_LOGIC_OP				= 0x0BF2,
-	GGL_DITHER						= 0x0BD0,
-	GGL_STENCIL_TEST				= 0x0B90,
-	GGL_DEPTH_TEST					= 0x0B71,
-    GGL_AA                          = 0x80000001,
-    GGL_W_LERP                      = 0x80000004,
-    GGL_POINT_SMOOTH_NICE           = 0x80000005,
-
-    // buffers, pixel drawing/reading
-    GGL_COLOR                       = 0x1800,
-    
-    // fog
-    GGL_FOG                         = 0x0B60,
-    
-	// shade model
-	GGL_FLAT						= 0x1D00,
-	GGL_SMOOTH						= 0x1D01,
-
-	// Texture parameter name
-	GGL_TEXTURE_MIN_FILTER			= 0x2801,
-	GGL_TEXTURE_MAG_FILTER			= 0x2800,
-	GGL_TEXTURE_WRAP_S				= 0x2802,
-	GGL_TEXTURE_WRAP_T				= 0x2803,
-	GGL_TEXTURE_WRAP_R				= 0x2804,
-
-	// Texture Filter	
-	GGL_NEAREST						= 0x2600,
-	GGL_LINEAR						= 0x2601,
-	GGL_NEAREST_MIPMAP_NEAREST		= 0x2700,
-	GGL_LINEAR_MIPMAP_NEAREST		= 0x2701,
-	GGL_NEAREST_MIPMAP_LINEAR		= 0x2702,
-	GGL_LINEAR_MIPMAP_LINEAR		= 0x2703,
-
-	// Texture Wrap Mode
-	GGL_CLAMP						= 0x2900,
-	GGL_REPEAT						= 0x2901,
-    GGL_CLAMP_TO_EDGE               = 0x812F,
-
-	// Texture Env Mode
-	GGL_REPLACE						= 0x1E01,
-	GGL_MODULATE					= 0x2100,
-	GGL_DECAL						= 0x2101,
-	GGL_ADD							= 0x0104,
-
-	// Texture Env Parameter
-	GGL_TEXTURE_ENV_MODE			= 0x2200,
-	GGL_TEXTURE_ENV_COLOR			= 0x2201,
-
-	// Texture Env Target
-	GGL_TEXTURE_ENV					= 0x2300,
-
-    // Texture coord generation
-    GGL_TEXTURE_GEN_MODE            = 0x2500,
-    GGL_S                           = 0x2000,
-    GGL_T                           = 0x2001,
-    GGL_R                           = 0x2002,
-    GGL_Q                           = 0x2003,
-    GGL_ONE_TO_ONE                  = 0x80000002,
-    GGL_AUTOMATIC                   = 0x80000003,
-
-    // AlphaFunction
-    GGL_NEVER                       = 0x0200,
-    GGL_LESS                        = 0x0201,
-    GGL_EQUAL                       = 0x0202,
-    GGL_LEQUAL                      = 0x0203,
-    GGL_GREATER                     = 0x0204,
-    GGL_NOTEQUAL                    = 0x0205,
-    GGL_GEQUAL                      = 0x0206,
-    GGL_ALWAYS                      = 0x0207,
-
-    // LogicOp
-    GGL_CLEAR                       = 0x1500,   // 0
-    GGL_AND                         = 0x1501,   // s & d
-    GGL_AND_REVERSE                 = 0x1502,   // s & ~d
-    GGL_COPY                        = 0x1503,   // s
-    GGL_AND_INVERTED                = 0x1504,   // ~s & d
-    GGL_NOOP                        = 0x1505,   // d
-    GGL_XOR                         = 0x1506,   // s ^ d
-    GGL_OR                          = 0x1507,   // s | d
-    GGL_NOR                         = 0x1508,   // ~(s | d)
-    GGL_EQUIV                       = 0x1509,   // ~(s ^ d)
-    GGL_INVERT                      = 0x150A,   // ~d
-    GGL_OR_REVERSE                  = 0x150B,   // s | ~d
-    GGL_COPY_INVERTED               = 0x150C,   // ~s 
-    GGL_OR_INVERTED                 = 0x150D,   // ~s | d
-    GGL_NAND                        = 0x150E,   // ~(s & d)
-    GGL_SET                         = 0x150F,   // 1
-
-	// blending equation & function
-	GGL_ZERO                        = 0,		// SD
-	GGL_ONE                         = 1,		// SD
-	GGL_SRC_COLOR                   = 0x0300,	//  D
-	GGL_ONE_MINUS_SRC_COLOR         = 0x0301,	//	D
-	GGL_SRC_ALPHA                   = 0x0302,	// SD
-	GGL_ONE_MINUS_SRC_ALPHA			= 0x0303,	// SD
-	GGL_DST_ALPHA					= 0x0304,	// SD
-	GGL_ONE_MINUS_DST_ALPHA			= 0x0305,	// SD
-	GGL_DST_COLOR					= 0x0306,	// S
-	GGL_ONE_MINUS_DST_COLOR			= 0x0307,	// S
-	GGL_SRC_ALPHA_SATURATE			= 0x0308,	// S
-    
-    // clear bits
-    GGL_DEPTH_BUFFER_BIT            = 0x00000100,
-    GGL_STENCIL_BUFFER_BIT          = 0x00000400,
-    GGL_COLOR_BUFFER_BIT            = 0x00004000,
-
-    // errors
-    GGL_NO_ERROR                    = 0,
-    GGL_INVALID_ENUM                = 0x0500,
-    GGL_INVALID_VALUE               = 0x0501,
-    GGL_INVALID_OPERATION           = 0x0502,
-    GGL_STACK_OVERFLOW              = 0x0503,
-    GGL_STACK_UNDERFLOW             = 0x0504,
-    GGL_OUT_OF_MEMORY               = 0x0505
-};
-
-// ----------------------------------------------------------------------------
-
-typedef struct {
-    GGLsizei    version;    // always set to sizeof(GGLSurface)
-    GGLuint     width;      // width in pixels
-    GGLuint     height;     // height in pixels
-    GGLint      stride;     // stride in pixels
-    GGLubyte*   data;       // pointer to the bits
-    GGLubyte    format;     // pixel format
-    GGLubyte    rfu[3];     // must be zero
-    // these values are dependent on the used format
-    union {
-        GGLint  compressedFormat;
-        GGLint  vstride;
-    };
-    void*       reserved;
-} GGLSurface;
-
-
-typedef struct {
-    // immediate rendering
-    void (*pointx)(void *con, const GGLcoord* v, GGLcoord r);
-    void (*linex)(void *con, 
-            const GGLcoord* v0, const GGLcoord* v1, GGLcoord width);
-    void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b); 
-    void (*trianglex)(void* c,
-            GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2);
-
-    // scissor
-    void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height);
-
-    // Set the textures and color buffers
-    void (*activeTexture)(void* c, GGLuint tmu);
-    void (*bindTexture)(void* c, const GGLSurface* surface);
-    void (*colorBuffer)(void* c, const GGLSurface* surface);
-    void (*readBuffer)(void* c, const GGLSurface* surface);
-    void (*depthBuffer)(void* c, const GGLSurface* surface);
-    void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);
-
-    // enable/disable features
-    void (*enable)(void* c, GGLenum name);
-    void (*disable)(void* c, GGLenum name);
-    void (*enableDisable)(void* c, GGLenum name, GGLboolean en);
-
-    // specify the fragment's color
-    void (*shadeModel)(void* c, GGLenum mode);
-    void (*color4xv)(void* c, const GGLclampx* color);
-    // specify color iterators (16.16)
-    void (*colorGrad12xv)(void* c, const GGLcolor* grad);
-
-    // specify Z coordinate iterators (0.32)
-    void (*zGrad3xv)(void* c, const GGLfixed32* grad);
-
-    // specify W coordinate iterators (16.16)
-    void (*wGrad3xv)(void* c, const GGLfixed* grad);
-
-    // specify fog iterator & color (16.16)
-    void (*fogGrad3xv)(void* c, const GGLfixed* grad);
-    void (*fogColor3xv)(void* c, const GGLclampx* color);
-
-    // specify blending parameters
-    void (*blendFunc)(void* c, GGLenum src, GGLenum dst);
-    void (*blendFuncSeparate)(void* c,  GGLenum src, GGLenum dst,
-                                        GGLenum srcAlpha, GGLenum dstAplha);
-
-    // texture environnement (REPLACE / MODULATE / DECAL / BLEND)
-    void (*texEnvi)(void* c,    GGLenum target,
-                                GGLenum pname,
-                                GGLint param);
-
-    void (*texEnvxv)(void* c, GGLenum target,
-            GGLenum pname, const GGLfixed* params);
-
-    // texture parameters (Wrapping, filter)
-    void (*texParameteri)(void* c,  GGLenum target,
-                                    GGLenum pname,
-                                    GGLint param);
-
-    // texture iterators (16.16)
-    void (*texCoord2i)(void* c, GGLint s, GGLint t);
-    void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t);
-    
-    // s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale
-    // This api uses block floating-point for S and T texture coordinates.
-    // All values are given in 16.16, scaled by 'scale'. In other words,
-    // set scale to 0, for 16.16 values.
-    void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);
-    
-    void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);
-
-    // masking
-    void (*colorMask)(void* c,  GGLboolean red,
-                                GGLboolean green,
-                                GGLboolean blue,
-                                GGLboolean alpha);
-
-    void (*depthMask)(void* c, GGLboolean flag);
-
-    void (*stencilMask)(void* c, GGLuint mask);
-
-    // alpha func
-    void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref);
-
-    // depth func
-    void (*depthFunc)(void* c, GGLenum func);
-
-    // logic op
-    void (*logicOp)(void* c, GGLenum opcode); 
-
-    // clear
-    void (*clear)(void* c, GGLbitfield mask);
-    void (*clearColorx)(void* c,
-            GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);
-    void (*clearDepthx)(void* c, GGLclampx depth);
-    void (*clearStencil)(void* c, GGLint s);
-
-    // framebuffer operations
-    void (*copyPixels)(void* c, GGLint x, GGLint y,
-            GGLsizei width, GGLsizei height, GGLenum type);
-    void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y);
-    void (*rasterPos2i)(void* c, GGLint x, GGLint y);
-} GGLContext;
-
-// ----------------------------------------------------------------------------
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// construct / destroy the context
-ssize_t gglInit(GGLContext** context);
-ssize_t gglUninit(GGLContext* context);
-
-GGLint gglBitBlit(
-        GGLContext* c,
-        int tmu,
-        GGLint crop[4],
-        GGLint where[4]);
-
-#ifdef __cplusplus
-};
-#endif
-
-// ----------------------------------------------------------------------------
-
-#endif // ANDROID_PIXELFLINGER_H
diff --git a/libpixelflinger/include/private/pixelflinger/ggl_context.h b/libpixelflinger/include/private/pixelflinger/ggl_context.h
deleted file mode 100644
index 563b0f1..0000000
--- a/libpixelflinger/include/private/pixelflinger/ggl_context.h
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * Copyright (C) 2006 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_GGL_CONTEXT_H
-#define ANDROID_GGL_CONTEXT_H
-
-#include <stdint.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/types.h>
-#include <endian.h>
-
-#include <pixelflinger/pixelflinger.h>
-#include <private/pixelflinger/ggl_fixed.h>
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-
-inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
-    return v;
-}
-inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
-    return v;
-}
-
-#else
-
-inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
-#if defined(__mips__) && __mips_isa_rev>=2
-    uint32_t r;
-    __asm__("wsbh %0, %1;"
-        "rotr %0, %0, 16"
-        : "=r" (r)
-        : "r" (v)
-        );
-    return r;
-#else
-    return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-#endif
-}
-inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
-#if defined(__mips__) && __mips_isa_rev>=2
-    uint32_t r;
-    __asm__("wsbh %0, %1;"
-        "rotr %0, %0, 16"
-        : "=r" (r)
-        : "r" (v)
-        );
-    return r;
-#else
-    return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-#endif
-}
-
-#endif
-
-// ----------------------------------------------------------------------------
-
-const int GGL_DITHER_BITS = 6;  // dither weights stored on 6 bits
-const int GGL_DITHER_ORDER_SHIFT= 3;
-const int GGL_DITHER_ORDER      = (1<<GGL_DITHER_ORDER_SHIFT);
-const int GGL_DITHER_SIZE       = GGL_DITHER_ORDER * GGL_DITHER_ORDER;
-const int GGL_DITHER_MASK       = GGL_DITHER_ORDER-1;
-
-// ----------------------------------------------------------------------------
-
-const int GGL_SUBPIXEL_BITS = 4;
-
-// TRI_FRACTION_BITS defines the number of bits we want to use
-// for the sub-pixel coordinates during the edge stepping, the
-// value shouldn't be more than 7, or bad things are going to
-// happen when drawing large triangles (8 doesn't work because
-// 32 bit muls will loose the sign bit)
-
-#define  TRI_FRACTION_BITS  (GGL_SUBPIXEL_BITS)
-#define  TRI_ONE            (1 << TRI_FRACTION_BITS)
-#define  TRI_HALF           (1 << (TRI_FRACTION_BITS-1))
-#define  TRI_FROM_INT(x)    ((x) << TRI_FRACTION_BITS)
-#define  TRI_FRAC(x)        ((x)                 &  (TRI_ONE-1))
-#define  TRI_FLOOR(x)       ((x)                 & ~(TRI_ONE-1))
-#define  TRI_CEIL(x)        (((x) + (TRI_ONE-1)) & ~(TRI_ONE-1))
-#define  TRI_ROUND(x)       (((x) +  TRI_HALF  ) & ~(TRI_ONE-1))
-
-#define  TRI_ROUDNING       (1 << (16 - TRI_FRACTION_BITS - 1))
-#define  TRI_FROM_FIXED(x)  (((x)+TRI_ROUDNING) >> (16-TRI_FRACTION_BITS))
-
-#define  TRI_SNAP_NEXT_HALF(x)   (TRI_CEIL((x)+TRI_HALF) - TRI_HALF)
-#define  TRI_SNAP_PREV_HALF(x)   (TRI_CEIL((x)-TRI_HALF) - TRI_HALF)
-
-// ----------------------------------------------------------------------------
-
-const int GGL_COLOR_BITS = 24;
-
-// To maintain 8-bits color chanels, with a maximum GGLSurface
-// size of 4096 and GGL_SUBPIXEL_BITS=4, we need 8 + 12 + 4 = 24 bits
-// for encoding the color iterators
-
-inline GGLcolor gglFixedToIteratedColor(GGLfixed c) {
-    return (c << 8) - c;
-}
-
-// ----------------------------------------------------------------------------
-
-template<bool> struct CTA;
-template<> struct CTA<true> { };
-
-#define GGL_CONTEXT(con, c)         context_t *(con) = static_cast<context_t *>(c) /* NOLINT */
-#define GGL_OFFSETOF(field)         uintptr_t(&(((context_t*)0)->field))
-#define GGL_INIT_PROC(p, f)         p.f = ggl_ ## f;
-#define GGL_BETWEEN(x, L, H)        (uint32_t((x)-(L)) <= ((H)-(L)))
-
-#define ggl_likely(x)	__builtin_expect(!!(x), 1)
-#define ggl_unlikely(x)	__builtin_expect(!!(x), 0)
-
-const int GGL_TEXTURE_UNIT_COUNT    = 2;
-const int GGL_TMU_STATE             = 0x00000001;
-const int GGL_CB_STATE              = 0x00000002;
-const int GGL_PIXEL_PIPELINE_STATE  = 0x00000004;
-
-// ----------------------------------------------------------------------------
-
-#define GGL_RESERVE_NEEDS(name, l, s)                               \
-    const uint32_t  GGL_NEEDS_##name##_MASK = (((1LU<<(s))-1)<<(l));  \
-    const uint32_t  GGL_NEEDS_##name##_SHIFT = (l);
-
-#define GGL_BUILD_NEEDS(val, name)                                  \
-    (((val)<<(GGL_NEEDS_##name##_SHIFT)) & GGL_NEEDS_##name##_MASK)
-
-#define GGL_READ_NEEDS(name, n)                                     \
-    (uint32_t((n) & GGL_NEEDS_##name##_MASK) >> GGL_NEEDS_##name##_SHIFT)
-
-#define GGL_NEED_MASK(name)     (uint32_t(GGL_NEEDS_##name##_MASK))
-#define GGL_NEED(name, val)     GGL_BUILD_NEEDS(val, name)
-
-GGL_RESERVE_NEEDS( CB_FORMAT,       0, 6 )
-GGL_RESERVE_NEEDS( SHADE,           6, 1 )
-GGL_RESERVE_NEEDS( W,               7, 1 )
-GGL_RESERVE_NEEDS( BLEND_SRC,       8, 4 )
-GGL_RESERVE_NEEDS( BLEND_DST,      12, 4 )
-GGL_RESERVE_NEEDS( BLEND_SRCA,     16, 4 )
-GGL_RESERVE_NEEDS( BLEND_DSTA,     20, 4 )
-GGL_RESERVE_NEEDS( LOGIC_OP,       24, 4 )
-GGL_RESERVE_NEEDS( MASK_ARGB,      28, 4 )
-
-GGL_RESERVE_NEEDS( P_ALPHA_TEST,    0, 3 )
-GGL_RESERVE_NEEDS( P_AA,            3, 1 )
-GGL_RESERVE_NEEDS( P_DEPTH_TEST,    4, 3 )
-GGL_RESERVE_NEEDS( P_MASK_Z,        7, 1 )
-GGL_RESERVE_NEEDS( P_DITHER,        8, 1 )
-GGL_RESERVE_NEEDS( P_FOG,           9, 1 )
-GGL_RESERVE_NEEDS( P_RESERVED1,    10,22 )
-
-GGL_RESERVE_NEEDS( T_FORMAT,        0, 6 )
-GGL_RESERVE_NEEDS( T_RESERVED0,     6, 1 )
-GGL_RESERVE_NEEDS( T_POT,           7, 1 )
-GGL_RESERVE_NEEDS( T_S_WRAP,        8, 2 )
-GGL_RESERVE_NEEDS( T_T_WRAP,       10, 2 )
-GGL_RESERVE_NEEDS( T_ENV,          12, 3 )
-GGL_RESERVE_NEEDS( T_LINEAR,       15, 1 )
-
-const int GGL_NEEDS_WRAP_CLAMP_TO_EDGE  = 0;
-const int GGL_NEEDS_WRAP_REPEAT         = 1;
-const int GGL_NEEDS_WRAP_11             = 2;
-
-inline uint32_t ggl_wrap_to_needs(uint32_t e) {
-    switch (e) {
-    case GGL_CLAMP:         return GGL_NEEDS_WRAP_CLAMP_TO_EDGE;
-    case GGL_REPEAT:        return GGL_NEEDS_WRAP_REPEAT;
-    }
-    return 0;
-}
-
-inline uint32_t ggl_blendfactor_to_needs(uint32_t b) {
-    if (b <= 1) return b;
-    return (b & 0xF)+2;
-}
-
-inline uint32_t ggl_needs_to_blendfactor(uint32_t n) {
-    if (n <= 1) return n;
-    return (n - 2) + 0x300;
-}
-
-inline uint32_t ggl_env_to_needs(uint32_t e) {
-    switch (e) {
-    case GGL_REPLACE:   return 0;
-    case GGL_MODULATE:  return 1;
-    case GGL_DECAL:     return 2;
-    case GGL_BLEND:     return 3;
-    case GGL_ADD:       return 4;
-    }
-    return 0;
-}
-
-inline uint32_t ggl_needs_to_env(uint32_t n) {
-    const uint32_t envs[] = { GGL_REPLACE, GGL_MODULATE, 
-            GGL_DECAL, GGL_BLEND, GGL_ADD };
-    return envs[n];
-
-}
-
-// ----------------------------------------------------------------------------
-
-enum {
-    GGL_ENABLE_BLENDING     = 0x00000001,
-    GGL_ENABLE_SMOOTH       = 0x00000002,
-    GGL_ENABLE_AA           = 0x00000004,
-    GGL_ENABLE_LOGIC_OP     = 0x00000008,
-    GGL_ENABLE_ALPHA_TEST   = 0x00000010,
-    GGL_ENABLE_SCISSOR_TEST = 0x00000020,
-    GGL_ENABLE_TMUS         = 0x00000040,
-    GGL_ENABLE_DEPTH_TEST   = 0x00000080,
-    GGL_ENABLE_STENCIL_TEST = 0x00000100,
-    GGL_ENABLE_W            = 0x00000200,
-    GGL_ENABLE_DITHER       = 0x00000400,
-    GGL_ENABLE_FOG          = 0x00000800,
-    GGL_ENABLE_POINT_AA_NICE= 0x00001000
-};
-
-// ----------------------------------------------------------------------------
-
-struct needs_filter_t;
-struct needs_t {
-    inline int match(const needs_filter_t& filter);
-    inline bool operator == (const needs_t& rhs) const {
-        return  (n==rhs.n) &&
-                (p==rhs.p) &&
-                (t[0]==rhs.t[0]) &&
-                (t[1]==rhs.t[1]);
-    }
-    inline bool operator != (const needs_t& rhs) const {
-        return !operator == (rhs);
-    }
-    uint32_t    n;
-    uint32_t    p;
-    uint32_t    t[GGL_TEXTURE_UNIT_COUNT];
-};
-
-inline int compare_type(const needs_t& lhs, const needs_t& rhs) {
-    return memcmp(&lhs, &rhs, sizeof(needs_t));
-}
-
-struct needs_filter_t {
-    needs_t     value;
-    needs_t     mask;
-};
-
-int needs_t::match(const needs_filter_t& filter) {
-    uint32_t result = 
-        ((filter.value.n ^ n)       & filter.mask.n)    |
-        ((filter.value.p ^ p)       & filter.mask.p)    |
-        ((filter.value.t[0] ^ t[0]) & filter.mask.t[0]) |
-        ((filter.value.t[1] ^ t[1]) & filter.mask.t[1]);
-    return (result == 0);
-}
-
-// ----------------------------------------------------------------------------
-
-struct context_t;
-class Assembly;
-
-struct blend_state_t {
-	uint32_t			src;
-	uint32_t			dst;
-	uint32_t			src_alpha;
-	uint32_t			dst_alpha;
-	uint8_t				reserved;
-	uint8_t				alpha_separate;
-	uint8_t				operation;
-	uint8_t				equation;
-};
-
-struct mask_state_t {
-    uint8_t             color;
-    uint8_t             depth;
-    uint32_t            stencil;
-};
-
-struct clear_state_t {
-    GGLclampx           r;
-    GGLclampx           g;
-    GGLclampx           b;
-    GGLclampx           a;
-    GGLclampx           depth;
-    GGLint              stencil;
-    uint32_t            colorPacked;
-    uint32_t            depthPacked;
-    uint32_t            stencilPacked;
-    uint32_t            dirty;
-};
-
-struct fog_state_t {
-    uint8_t     color[4];
-};
-
-struct logic_op_state_t {
-    uint16_t            opcode;
-};
-
-struct alpha_test_state_t {
-    uint16_t            func;
-    GGLcolor            ref;
-};
-
-struct depth_test_state_t {
-    uint16_t            func;
-    GGLclampx           clearValue;
-};
-
-struct scissor_t {
-    uint32_t            user_left;
-    uint32_t            user_right;
-    uint32_t            user_top;
-    uint32_t            user_bottom;
-    uint32_t            left;
-    uint32_t            right;
-    uint32_t            top;
-    uint32_t            bottom;
-};
-
-struct pixel_t {
-    uint32_t    c[4];
-    uint8_t     s[4];
-};
-
-struct surface_t {
-    union {
-        GGLSurface          s;
-        // Keep the following struct field types in line with the corresponding
-        // GGLSurface fields to avoid mismatches leading to errors.
-        struct {
-            GGLsizei        reserved;
-            GGLuint         width;
-            GGLuint         height;
-            GGLint          stride;
-            GGLubyte*       data;
-            GGLubyte        format;
-            GGLubyte        dirty;
-            GGLubyte        pad[2];
-        };
-    };
-    void                (*read) (const surface_t* s, context_t* c,
-                                uint32_t x, uint32_t y, pixel_t* pixel);
-    void                (*write)(const surface_t* s, context_t* c,
-                                uint32_t x, uint32_t y, const pixel_t* pixel);
-};
-
-// ----------------------------------------------------------------------------
-
-struct texture_shade_t {
-    union {
-        struct {
-            int32_t             is0;
-            int32_t             idsdx;
-            int32_t             idsdy;
-            int                 sscale;
-            int32_t             it0;
-            int32_t             idtdx;
-            int32_t             idtdy;
-            int                 tscale;
-        };
-        struct {
-            int32_t             v;
-            int32_t             dx;
-            int32_t             dy;
-            int                 scale;
-        } st[2];
-    };
-};
-
-struct texture_iterators_t {
-    // these are not encoded in the same way than in the
-    // texture_shade_t structure
-    union {
-        struct {
-            GGLfixed			ydsdy;
-            GGLfixed            dsdx;
-            GGLfixed            dsdy;
-            int                 sscale;
-            GGLfixed			ydtdy;
-            GGLfixed            dtdx;
-            GGLfixed            dtdy;
-            int                 tscale;
-        };
-        struct {
-            GGLfixed			ydvdy;
-            GGLfixed            dvdx;
-            GGLfixed            dvdy;
-            int                 scale;
-        } st[2];
-    };
-};
-
-struct texture_t {
-	surface_t			surface;
-	texture_iterators_t	iterators;
-    texture_shade_t     shade;
-	uint32_t			s_coord;
-	uint32_t            t_coord;
-	uint16_t			s_wrap;
-	uint16_t            t_wrap;
-	uint16_t            min_filter;
-	uint16_t            mag_filter;
-    uint16_t            env;
-    uint8_t             env_color[4];
-	uint8_t				enable;
-	uint8_t				dirty;
-};
-
-struct raster_t {
-    GGLfixed            x;
-    GGLfixed            y;
-};
-
-struct framebuffer_t {
-    surface_t           color;
-    surface_t           read;
-	surface_t			depth;
-	surface_t			stencil;
-    int16_t             *coverage;
-    size_t              coverageBufferSize;
-};
-
-// ----------------------------------------------------------------------------
-
-struct iterators_t {
-	int32_t             xl;
-	int32_t             xr;
-    int32_t             y;
-	GGLcolor			ydady;
-	GGLcolor			ydrdy;
-	GGLcolor			ydgdy;
-	GGLcolor			ydbdy;
-	GGLfixed			ydzdy;
-	GGLfixed			ydwdy;
-	GGLfixed			ydfdy;
-};
-
-struct shade_t {
-	GGLcolor			a0;
-    GGLcolor            dadx;
-    GGLcolor            dady;
-	GGLcolor			r0;
-    GGLcolor            drdx;
-    GGLcolor            drdy;
-	GGLcolor			g0;
-    GGLcolor            dgdx;
-    GGLcolor            dgdy;
-	GGLcolor			b0;
-    GGLcolor            dbdx;
-    GGLcolor            dbdy;
-	uint32_t            z0;
-    GGLfixed32          dzdx;
-    GGLfixed32          dzdy;
-	GGLfixed            w0;
-    GGLfixed            dwdx;
-    GGLfixed            dwdy;
-	uint32_t			f0;
-    GGLfixed            dfdx;
-    GGLfixed            dfdy;
-};
-
-// these are used in the generated code
-// we use this mirror structure to improve
-// data locality in the pixel pipeline
-struct generated_tex_vars_t {
-    uint32_t    width;
-    uint32_t    height;
-    uint32_t    stride;
-    uintptr_t   data;
-    int32_t     dsdx;
-    int32_t     dtdx;
-    int32_t     spill[2];
-};
-
-struct generated_vars_t {
-    struct {
-        int32_t c;
-        int32_t dx;
-    } argb[4];
-    int32_t     aref;
-    int32_t     dzdx;
-    int32_t     zbase;
-    int32_t     f;
-    int32_t     dfdx;
-    int32_t     spill[3];
-    generated_tex_vars_t    texture[GGL_TEXTURE_UNIT_COUNT];
-    int32_t     rt;
-    int32_t     lb;
-};
-
-// ----------------------------------------------------------------------------
-
-struct state_t {
-	framebuffer_t		buffers;
-	texture_t			texture[GGL_TEXTURE_UNIT_COUNT];
-    scissor_t           scissor;
-    raster_t            raster;
-	blend_state_t		blend;
-    alpha_test_state_t  alpha_test;
-    depth_test_state_t  depth_test;
-    mask_state_t        mask;
-    clear_state_t       clear;
-    fog_state_t         fog;
-    logic_op_state_t    logic_op;
-    uint32_t            enables;
-    uint32_t            enabled_tmu;
-    needs_t             needs;
-};
-
-// ----------------------------------------------------------------------------
-
-struct context_t {
-	GGLContext          procs;
-	state_t             state;
-    shade_t             shade;
-	iterators_t         iterators;
-    generated_vars_t    generated_vars                __attribute__((aligned(32)));
-    uint8_t             ditherMatrix[GGL_DITHER_SIZE] __attribute__((aligned(32)));
-    uint32_t            packed;
-    uint32_t            packed8888;
-    const GGLFormat*    formats;
-    uint32_t            dirty;
-    texture_t*          activeTMU;
-    uint32_t            activeTMUIndex;
-
-    void                (*init_y)(context_t* c, int32_t y);
-	void                (*step_y)(context_t* c);
-	void                (*scanline)(context_t* c);
-    void                (*span)(context_t* c);
-    void                (*rect)(context_t* c, size_t yc);
-    
-    void*               base;
-    Assembly*           scanline_as;
-    GGLenum             error;
-};
-
-// ----------------------------------------------------------------------------
-
-void ggl_init_context(context_t* context);
-void ggl_uninit_context(context_t* context);
-void ggl_error(context_t* c, GGLenum error);
-int64_t ggl_system_time();
-
-// ----------------------------------------------------------------------------
-
-};
-
-#endif // ANDROID_GGL_CONTEXT_H
-
diff --git a/libpixelflinger/include/private/pixelflinger/ggl_fixed.h b/libpixelflinger/include/private/pixelflinger/ggl_fixed.h
deleted file mode 100644
index 4217a89..0000000
--- a/libpixelflinger/include/private/pixelflinger/ggl_fixed.h
+++ /dev/null
@@ -1,878 +0,0 @@
-/*
- * Copyright (C) 2005 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_GGL_FIXED_H
-#define ANDROID_GGL_FIXED_H
-
-#include <math.h>
-#include <pixelflinger/pixelflinger.h>
-
-// ----------------------------------------------------------------------------
-
-#define CONST           __attribute__((const))
-#define ALWAYS_INLINE   __attribute__((always_inline))
-
-const GGLfixed FIXED_BITS = 16;
-const GGLfixed FIXED_EPSILON  = 1;
-const GGLfixed FIXED_ONE  = 1L<<FIXED_BITS;
-const GGLfixed FIXED_HALF = 1L<<(FIXED_BITS-1);
-const GGLfixed FIXED_MIN  = 0x80000000L;
-const GGLfixed FIXED_MAX  = 0x7FFFFFFFL;
-
-inline GGLfixed gglIntToFixed(GGLfixed i)       ALWAYS_INLINE ;
-inline GGLfixed gglFixedToIntRound(GGLfixed f)  ALWAYS_INLINE ;
-inline GGLfixed gglFixedToIntFloor(GGLfixed f)  ALWAYS_INLINE ;
-inline GGLfixed gglFixedToIntCeil(GGLfixed f)   ALWAYS_INLINE ;
-inline GGLfixed gglFracx(GGLfixed v)            ALWAYS_INLINE ;
-inline GGLfixed gglFloorx(GGLfixed v)           ALWAYS_INLINE ;
-inline GGLfixed gglCeilx(GGLfixed v)            ALWAYS_INLINE ;
-inline GGLfixed gglCenterx(GGLfixed v)          ALWAYS_INLINE ;
-inline GGLfixed gglRoundx(GGLfixed v)           ALWAYS_INLINE ;
-
-GGLfixed gglIntToFixed(GGLfixed i) {
-    return i<<FIXED_BITS;
-}
-GGLfixed gglFixedToIntRound(GGLfixed f) {
-    return (f + FIXED_HALF)>>FIXED_BITS;
-}
-GGLfixed gglFixedToIntFloor(GGLfixed f) {
-    return f>>FIXED_BITS;
-}
-GGLfixed gglFixedToIntCeil(GGLfixed f) {
-    return (f + ((1<<FIXED_BITS) - 1))>>FIXED_BITS;
-}
-
-GGLfixed gglFracx(GGLfixed v) {
-    return v & ((1<<FIXED_BITS)-1);
-}
-GGLfixed gglFloorx(GGLfixed v) {
-    return gglFixedToIntFloor(v)<<FIXED_BITS;
-}
-GGLfixed gglCeilx(GGLfixed v) {
-    return gglFixedToIntCeil(v)<<FIXED_BITS;
-}
-GGLfixed gglCenterx(GGLfixed v) {
-    return gglFloorx(v + FIXED_HALF) | FIXED_HALF;
-}
-GGLfixed gglRoundx(GGLfixed v) {
-    return gglFixedToIntRound(v)<<FIXED_BITS;
-}
-
-// conversion from (unsigned) int, short, byte to fixed...
-#define GGL_B_TO_X(_x)      GGLfixed( ((int32_t(_x)+1)>>1)<<10 )
-#define GGL_S_TO_X(_x)      GGLfixed( ((int32_t(_x)+1)>>1)<<2 )
-#define GGL_I_TO_X(_x)      GGLfixed( ((int32_t(_x)>>1)+1)>>14 )
-#define GGL_UB_TO_X(_x)     GGLfixed(   uint32_t(_x) +      \
-                                        (uint32_t(_x)<<8) + \
-                                        (uint32_t(_x)>>7) )
-#define GGL_US_TO_X(_x)     GGLfixed( (_x) + ((_x)>>15) )
-#define GGL_UI_TO_X(_x)     GGLfixed( (((_x)>>1)+1)>>15 )
-
-// ----------------------------------------------------------------------------
-
-GGLfixed gglPowx(GGLfixed x, GGLfixed y) CONST;
-GGLfixed gglSqrtx(GGLfixed a) CONST;
-GGLfixed gglSqrtRecipx(GGLfixed x) CONST;
-int32_t gglMulDivi(int32_t a, int32_t b, int32_t c);
-
-int32_t gglRecipQNormalized(int32_t x, int* exponent);
-int32_t gglRecipQ(GGLfixed x, int q) CONST;
-
-inline GGLfixed gglRecip(GGLfixed x) CONST;
-inline GGLfixed gglRecip(GGLfixed x) {
-    return gglRecipQ(x, 16);
-}
-
-inline GGLfixed gglRecip28(GGLfixed x) CONST;
-int32_t gglRecip28(GGLfixed x) {
-    return gglRecipQ(x, 28);
-}
-
-// ----------------------------------------------------------------------------
-
-#if defined(__arm__) && !defined(__thumb__)
-
-// inline ARM implementations
-inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) CONST;
-__attribute__((always_inline)) inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) {
-    GGLfixed result, t;
-    if (__builtin_constant_p(shift)) {
-    asm("smull  %[lo], %[hi], %[x], %[y]            \n"
-        "movs   %[lo], %[lo], lsr %[rshift]         \n"
-        "adc    %[lo], %[lo], %[hi], lsl %[lshift]  \n"
-        : [lo]"=r"(result), [hi]"=r"(t), [x]"=r"(x)
-        : "%[x]"(x), [y]"r"(y), [lshift] "I"(32-shift), [rshift] "I"(shift)
-        : "cc"
-        );
-    } else {
-    asm("smull  %[lo], %[hi], %[x], %[y]            \n"
-        "movs   %[lo], %[lo], lsr %[rshift]         \n"
-        "adc    %[lo], %[lo], %[hi], lsl %[lshift]  \n"
-        : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
-        : "%[x]"(x), [y]"r"(y), [lshift] "r"(32-shift), [rshift] "r"(shift)
-        : "cc"
-        );
-    }
-    return result;
-}
-
-inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-__attribute__((always_inline)) inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a,
-                                                          int shift) {
-    GGLfixed result, t;
-    if (__builtin_constant_p(shift)) {
-    asm("smull  %[lo], %[hi], %[x], %[y]            \n"
-        "add    %[lo], %[a],  %[lo], lsr %[rshift]  \n"
-        "add    %[lo], %[lo], %[hi], lsl %[lshift]  \n"
-        : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
-        : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "I"(32-shift), [rshift] "I"(shift)
-        );
-    } else {
-    asm("smull  %[lo], %[hi], %[x], %[y]            \n"
-        "add    %[lo], %[a],  %[lo], lsr %[rshift]  \n"
-        "add    %[lo], %[lo], %[hi], lsl %[lshift]  \n"
-        : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
-        : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "r"(32-shift), [rshift] "r"(shift)
-        );
-    }
-    return result;
-}
-
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) {
-    GGLfixed result, t;
-    if (__builtin_constant_p(shift)) {
-    asm("smull  %[lo], %[hi], %[x], %[y]            \n"
-        "rsb    %[lo], %[a],  %[lo], lsr %[rshift]  \n"
-        "add    %[lo], %[lo], %[hi], lsl %[lshift]  \n"
-        : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
-        : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "I"(32-shift), [rshift] "I"(shift)
-        );
-    } else {
-    asm("smull  %[lo], %[hi], %[x], %[y]            \n"
-        "rsb    %[lo], %[a],  %[lo], lsr %[rshift]  \n"
-        "add    %[lo], %[lo], %[hi], lsl %[lshift]  \n"
-        : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
-        : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "r"(32-shift), [rshift] "r"(shift)
-        );
-    }
-    return result;
-}
-
-inline int64_t gglMulii(int32_t x, int32_t y) CONST;
-inline int64_t gglMulii(int32_t x, int32_t y)
-{
-    // 64-bits result: r0=low, r1=high
-    union {
-        struct {
-            int32_t lo;
-            int32_t hi;
-        } s;
-        int64_t res;
-    };
-    asm("smull %0, %1, %2, %3   \n"
-        : "=r"(s.lo), "=&r"(s.hi)
-        : "%r"(x), "r"(y)
-        :
-        );
-    return res;
-}
-#elif defined(__mips__) && __mips_isa_rev < 6
-
-/*inline MIPS implementations*/
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) {
-    GGLfixed result,tmp,tmp1,tmp2;
-
-    if (__builtin_constant_p(shift)) {
-        if (shift == 0) {
-            asm ("mult %[a], %[b] \t\n"
-              "mflo  %[res]   \t\n"
-            : [res]"=&r"(result),[tmp]"=&r"(tmp)
-            : [a]"r"(a),[b]"r"(b)
-            : "%hi","%lo"
-            );
-        } else if (shift == 32)
-        {
-            asm ("mult %[a], %[b] \t\n"
-            "li  %[tmp],1\t\n"
-            "sll  %[tmp],%[tmp],0x1f\t\n"
-            "mflo %[res]   \t\n"
-            "addu %[tmp1],%[tmp],%[res] \t\n"
-            "sltu %[tmp1],%[tmp1],%[tmp]\t\n"   /*obit*/
-            "sra %[tmp],%[tmp],0x1f \t\n"
-            "mfhi  %[res]   \t\n"
-            "addu %[res],%[res],%[tmp]\t\n"
-            "addu %[res],%[res],%[tmp1]\t\n"
-            : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1)
-            : [a]"r"(a),[b]"r"(b),[shift]"I"(shift)
-            : "%hi","%lo"
-            );
-        } else if ((shift >0) && (shift < 32))
-        {
-            asm ("mult %[a], %[b] \t\n"
-            "li  %[tmp],1 \t\n"
-            "sll  %[tmp],%[tmp],%[shiftm1] \t\n"
-            "mflo  %[res]   \t\n"
-            "addu %[tmp1],%[tmp],%[res] \t\n"
-            "sltu %[tmp1],%[tmp1],%[tmp] \t\n"  /*obit?*/
-            "addu  %[res],%[res],%[tmp] \t\n"
-            "mfhi  %[tmp]   \t\n"
-            "addu  %[tmp],%[tmp],%[tmp1] \t\n"
-            "sll   %[tmp],%[tmp],%[lshift] \t\n"
-            "srl   %[res],%[res],%[rshift]    \t\n"
-            "or    %[res],%[res],%[tmp] \t\n"
-            : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-            : [a]"r"(a),[b]"r"(b),[lshift]"I"(32-shift),[rshift]"I"(shift),[shiftm1]"I"(shift-1)
-            : "%hi","%lo"
-            );
-        } else {
-            asm ("mult %[a], %[b] \t\n"
-            "li  %[tmp],1 \t\n"
-            "sll  %[tmp],%[tmp],%[shiftm1] \t\n"
-            "mflo  %[res]   \t\n"
-            "addu %[tmp1],%[tmp],%[res] \t\n"
-            "sltu %[tmp1],%[tmp1],%[tmp] \t\n"  /*obit?*/
-            "sra  %[tmp2],%[tmp],0x1f \t\n"
-            "addu  %[res],%[res],%[tmp] \t\n"
-            "mfhi  %[tmp]   \t\n"
-            "addu  %[tmp],%[tmp],%[tmp2] \t\n"
-            "addu  %[tmp],%[tmp],%[tmp1] \t\n"            /*tmp=hi*/
-            "srl   %[tmp2],%[res],%[rshift]    \t\n"
-            "srav  %[res], %[tmp],%[rshift]\t\n"
-            "sll   %[tmp],%[tmp],1 \t\n"
-            "sll   %[tmp],%[tmp],%[norbits] \t\n"
-            "or    %[tmp],%[tmp],%[tmp2] \t\n"
-            "movz  %[res],%[tmp],%[bit5] \t\n"
-            : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-            : [a]"r"(a),[b]"r"(b),[norbits]"I"(~(shift)),[rshift]"I"(shift),[shiftm1] "I"(shift-1),[bit5]"I"(shift & 0x20)
-            : "%hi","%lo"
-            );
-        }
-    } else {
-        asm ("mult %[a], %[b] \t\n"
-        "li  %[tmp],1 \t\n"
-        "sll  %[tmp],%[tmp],%[shiftm1] \t\n"
-        "mflo  %[res]   \t\n"
-        "addu %[tmp1],%[tmp],%[res] \t\n"
-        "sltu %[tmp1],%[tmp1],%[tmp] \t\n"  /*obit?*/
-        "sra  %[tmp2],%[tmp],0x1f \t\n"
-        "addu  %[res],%[res],%[tmp] \t\n"
-        "mfhi  %[tmp]   \t\n"
-        "addu  %[tmp],%[tmp],%[tmp2] \t\n"
-        "addu  %[tmp],%[tmp],%[tmp1] \t\n"            /*tmp=hi*/
-        "srl   %[tmp2],%[res],%[rshift]    \t\n"
-        "srav  %[res], %[tmp],%[rshift]\t\n"
-        "sll   %[tmp],%[tmp],1 \t\n"
-        "sll   %[tmp],%[tmp],%[norbits] \t\n"
-        "or    %[tmp],%[tmp],%[tmp2] \t\n"
-        "movz  %[res],%[tmp],%[bit5] \t\n"
-         : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-         : [a]"r"(a),[b]"r"(b),[norbits]"r"(~(shift)),[rshift] "r"(shift),[shiftm1]"r"(shift-1),[bit5] "r"(shift & 0x20)
-         : "%hi","%lo"
-         );
-        }
-
-        return result;
-}
-
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
-    GGLfixed result,t,tmp1,tmp2;
-
-    if (__builtin_constant_p(shift)) {
-        if (shift == 0) {
-                 asm ("mult %[a], %[b] \t\n"
-                 "mflo  %[lo]   \t\n"
-                 "addu  %[lo],%[lo],%[c]    \t\n"
-                 : [lo]"=&r"(result)
-                 : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                 : "%hi","%lo"
-                 );
-                } else if (shift == 32) {
-                    asm ("mult %[a], %[b] \t\n"
-                    "mfhi  %[lo]   \t\n"
-                    "addu  %[lo],%[lo],%[c]    \t\n"
-                    : [lo]"=&r"(result)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                    : "%hi","%lo"
-                    );
-                } else if ((shift>0) && (shift<32)) {
-                    asm ("mult %[a], %[b] \t\n"
-                    "mflo  %[res]   \t\n"
-                    "mfhi  %[t]   \t\n"
-                    "srl   %[res],%[res],%[rshift]    \t\n"
-                    "sll   %[t],%[t],%[lshift]     \t\n"
-                    "or  %[res],%[res],%[t]    \t\n"
-                    "addu  %[res],%[res],%[c]    \t\n"
-                    : [res]"=&r"(result),[t]"=&r"(t)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c),[lshift]"I"(32-shift),[rshift]"I"(shift)
-                    : "%hi","%lo"
-                    );
-                } else {
-                    asm ("mult %[a], %[b] \t\n"
-                    "nor %[tmp1],$zero,%[shift]\t\n"
-                    "mflo  %[res]   \t\n"
-                    "mfhi  %[t]   \t\n"
-                    "srl   %[res],%[res],%[shift]    \t\n"
-                    "sll   %[tmp2],%[t],1     \t\n"
-                    "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                    "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                    "srav  %[res],%[t],%[shift]     \t\n"
-                    "andi %[tmp2],%[shift],0x20\t\n"
-                    "movz %[res],%[tmp1],%[tmp2]\t\n"
-                    "addu  %[res],%[res],%[c]    \t\n"
-                    : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"I"(shift)
-                    : "%hi","%lo"
-                    );
-                }
-            } else {
-                asm ("mult %[a], %[b] \t\n"
-                "nor %[tmp1],$zero,%[shift]\t\n"
-                "mflo  %[res]   \t\n"
-                "mfhi  %[t]   \t\n"
-                "srl   %[res],%[res],%[shift]    \t\n"
-                "sll   %[tmp2],%[t],1     \t\n"
-                "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                "srav  %[res],%[t],%[shift]     \t\n"
-                "andi %[tmp2],%[shift],0x20\t\n"
-                "movz %[res],%[tmp1],%[tmp2]\t\n"
-                "addu  %[res],%[res],%[c]    \t\n"
-                : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"r"(shift)
-                : "%hi","%lo"
-                );
-            }
-            return result;
-}
-
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
-    GGLfixed result,t,tmp1,tmp2;
-
-    if (__builtin_constant_p(shift)) {
-        if (shift == 0) {
-                 asm ("mult %[a], %[b] \t\n"
-                 "mflo  %[lo]   \t\n"
-                 "subu  %[lo],%[lo],%[c]    \t\n"
-                 : [lo]"=&r"(result)
-                 : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                 : "%hi","%lo"
-                 );
-                } else if (shift == 32) {
-                    asm ("mult %[a], %[b] \t\n"
-                    "mfhi  %[lo]   \t\n"
-                    "subu  %[lo],%[lo],%[c]    \t\n"
-                    : [lo]"=&r"(result)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                    : "%hi","%lo"
-                    );
-                } else if ((shift>0) && (shift<32)) {
-                    asm ("mult %[a], %[b] \t\n"
-                    "mflo  %[res]   \t\n"
-                    "mfhi  %[t]   \t\n"
-                    "srl   %[res],%[res],%[rshift]    \t\n"
-                    "sll   %[t],%[t],%[lshift]     \t\n"
-                    "or  %[res],%[res],%[t]    \t\n"
-                    "subu  %[res],%[res],%[c]    \t\n"
-                    : [res]"=&r"(result),[t]"=&r"(t)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c),[lshift]"I"(32-shift),[rshift]"I"(shift)
-                    : "%hi","%lo"
-                    );
-                } else {
-                    asm ("mult %[a], %[b] \t\n"
-                    "nor %[tmp1],$zero,%[shift]\t\n"
-                     "mflo  %[res]   \t\n"
-                     "mfhi  %[t]   \t\n"
-                     "srl   %[res],%[res],%[shift]    \t\n"
-                     "sll   %[tmp2],%[t],1     \t\n"
-                     "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                     "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                     "srav  %[res],%[t],%[shift]     \t\n"
-                     "andi %[tmp2],%[shift],0x20\t\n"
-                     "movz %[res],%[tmp1],%[tmp2]\t\n"
-                     "subu  %[res],%[res],%[c]    \t\n"
-                     : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                     : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"I"(shift)
-                     : "%hi","%lo"
-                     );
-                    }
-                } else {
-                asm ("mult %[a], %[b] \t\n"
-                "nor %[tmp1],$zero,%[shift]\t\n"
-                "mflo  %[res]   \t\n"
-                "mfhi  %[t]   \t\n"
-                "srl   %[res],%[res],%[shift]    \t\n"
-                "sll   %[tmp2],%[t],1     \t\n"
-                "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                "srav  %[res],%[t],%[shift]     \t\n"
-                "andi %[tmp2],%[shift],0x20\t\n"
-                "movz %[res],%[tmp1],%[tmp2]\t\n"
-                "subu  %[res],%[res],%[c]    \t\n"
-                : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"r"(shift)
-                : "%hi","%lo"
-                );
-            }
-    return result;
-}
-
-inline int64_t gglMulii(int32_t x, int32_t y) CONST;
-inline int64_t gglMulii(int32_t x, int32_t y) {
-    union {
-        struct {
-#if defined(__MIPSEL__)
-            int32_t lo;
-            int32_t hi;
-#elif defined(__MIPSEB__)
-            int32_t hi;
-            int32_t lo;
-#endif
-        } s;
-        int64_t res;
-    }u;
-    asm("mult %2, %3 \t\n"
-        "mfhi %1   \t\n"
-        "mflo %0   \t\n"
-        : "=r"(u.s.lo), "=&r"(u.s.hi)
-        : "%r"(x), "r"(y)
-	: "%hi","%lo"
-        );
-    return u.res;
-}
-
-#elif defined(__aarch64__)
-
-// inline AArch64 implementations
-
-inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift)
-{
-    GGLfixed result;
-    GGLfixed round;
-
-    asm("mov    %x[round], #1                        \n"
-        "lsl    %x[round], %x[round], %x[shift]      \n"
-        "lsr    %x[round], %x[round], #1             \n"
-        "smaddl %x[result], %w[x], %w[y],%x[round]   \n"
-        "lsr    %x[result], %x[result], %x[shift]    \n"
-        : [round]"=&r"(round), [result]"=&r"(result) \
-        : [x]"r"(x), [y]"r"(y), [shift] "r"(shift)   \
-        :
-       );
-    return result;
-}
-inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift)
-{
-    GGLfixed result;
-    asm("smull  %x[result], %w[x], %w[y]                     \n"
-        "lsr    %x[result], %x[result], %x[shift]            \n"
-        "add    %w[result], %w[result], %w[a]                \n"
-        : [result]"=&r"(result)                               \
-        : [x]"r"(x), [y]"r"(y), [a]"r"(a), [shift] "r"(shift) \
-        :
-        );
-    return result;
-}
-
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift)
-{
-
-    GGLfixed result;
-
-    asm("smull  %x[result], %w[x], %w[y]                     \n"
-        "lsr    %x[result], %x[result], %x[shift]            \n"
-        "sub    %w[result], %w[result], %w[a]                \n"
-        : [result]"=&r"(result)                               \
-        : [x]"r"(x), [y]"r"(y), [a]"r"(a), [shift] "r"(shift) \
-        :
-        );
-    return result;
-}
-inline int64_t gglMulii(int32_t x, int32_t y) CONST;
-inline int64_t gglMulii(int32_t x, int32_t y)
-{
-    int64_t res;
-    asm("smull  %x0, %w1, %w2 \n"
-        : "=r"(res)
-        : "%r"(x), "r"(y)
-        :
-        );
-    return res;
-}
-
-#elif defined(__mips__) && __mips_isa_rev == 6
-
-/*inline MIPS implementations*/
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) {
-    GGLfixed result,tmp,tmp1,tmp2;
-
-    if (__builtin_constant_p(shift)) {
-        if (shift == 0) {
-            asm ("mul %[res], %[a], %[b] \t\n"
-            : [res]"=&r"(result)
-            : [a]"r"(a),[b]"r"(b)
-            );
-        } else if (shift == 32)
-        {
-            asm ("mul %[res], %[a], %[b] \t\n"
-            "li  %[tmp],1\t\n"
-            "sll  %[tmp],%[tmp],0x1f\t\n"
-            "addu %[tmp1],%[tmp],%[res] \t\n"
-            "muh %[res], %[a], %[b] \t\n"
-            "sltu %[tmp1],%[tmp1],%[tmp]\t\n"   /*obit*/
-            "sra %[tmp],%[tmp],0x1f \t\n"
-            "addu %[res],%[res],%[tmp]\t\n"
-            "addu %[res],%[res],%[tmp1]\t\n"
-            : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1)
-            : [a]"r"(a),[b]"r"(b),[shift]"I"(shift)
-            );
-        } else if ((shift >0) && (shift < 32))
-        {
-            asm ("mul %[res], %[a], %[b] \t\n"
-            "li  %[tmp],1 \t\n"
-            "sll  %[tmp],%[tmp],%[shiftm1] \t\n"
-            "addu %[tmp1],%[tmp],%[res] \t\n"
-            "sltu %[tmp1],%[tmp1],%[tmp] \t\n"  /*obit?*/
-            "addu  %[res],%[res],%[tmp] \t\n"
-            "muh %[tmp], %[a], %[b] \t\n"
-            "addu  %[tmp],%[tmp],%[tmp1] \t\n"
-            "sll   %[tmp],%[tmp],%[lshift] \t\n"
-            "srl   %[res],%[res],%[rshift]    \t\n"
-            "or    %[res],%[res],%[tmp] \t\n"
-            : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-            : [a]"r"(a),[b]"r"(b),[lshift]"I"(32-shift),[rshift]"I"(shift),[shiftm1]"I"(shift-1)
-            );
-        } else {
-            asm ("mul %[res], %[a], %[b] \t\n"
-            "li  %[tmp],1 \t\n"
-            "sll  %[tmp],%[tmp],%[shiftm1] \t\n"
-            "addu %[tmp1],%[tmp],%[res] \t\n"
-            "sltu %[tmp1],%[tmp1],%[tmp] \t\n"  /*obit?*/
-            "sra  %[tmp2],%[tmp],0x1f \t\n"
-            "addu  %[res],%[res],%[tmp] \t\n"
-            "muh  %[tmp], %[a], %[b]   \t\n"
-            "addu  %[tmp],%[tmp],%[tmp2] \t\n"
-            "addu  %[tmp],%[tmp],%[tmp1] \t\n"            /*tmp=hi*/
-            "srl   %[tmp2],%[res],%[rshift]    \t\n"
-            "srav  %[res], %[tmp],%[rshift]\t\n"
-            "sll   %[tmp],%[tmp],1 \t\n"
-            "sll   %[tmp],%[tmp],%[norbits] \t\n"
-            "or    %[tmp],%[tmp],%[tmp2] \t\n"
-            "seleqz  %[tmp],%[tmp],%[bit5] \t\n"
-            "selnez  %[res],%[res],%[bit5] \t\n"
-            "or    %[res],%[res],%[tmp] \t\n"
-            : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-            : [a]"r"(a),[b]"r"(b),[norbits]"I"(~(shift)),[rshift]"I"(shift),[shiftm1] "I"(shift-1),[bit5]"I"(shift & 0x20)
-            );
-        }
-    } else {
-        asm ("mul %[res], %[a], %[b] \t\n"
-        "li  %[tmp],1 \t\n"
-        "sll  %[tmp],%[tmp],%[shiftm1] \t\n"
-        "addu %[tmp1],%[tmp],%[res] \t\n"
-        "sltu %[tmp1],%[tmp1],%[tmp] \t\n"  /*obit?*/
-        "sra  %[tmp2],%[tmp],0x1f \t\n"
-        "addu  %[res],%[res],%[tmp] \t\n"
-        "muh  %[tmp], %[a], %[b] \t\n"
-        "addu  %[tmp],%[tmp],%[tmp2] \t\n"
-        "addu  %[tmp],%[tmp],%[tmp1] \t\n"            /*tmp=hi*/
-        "srl   %[tmp2],%[res],%[rshift]    \t\n"
-        "srav  %[res], %[tmp],%[rshift]\t\n"
-        "sll   %[tmp],%[tmp],1 \t\n"
-        "sll   %[tmp],%[tmp],%[norbits] \t\n"
-        "or    %[tmp],%[tmp],%[tmp2] \t\n"
-        "seleqz  %[tmp],%[tmp],%[bit5] \t\n"
-        "selnez  %[res],%[res],%[bit5] \t\n"
-        "or    %[res],%[res],%[tmp] \t\n"
-         : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-         : [a]"r"(a),[b]"r"(b),[norbits]"r"(~(shift)),[rshift] "r"(shift),[shiftm1]"r"(shift-1),[bit5] "r"(shift & 0x20)
-         );
-        }
-        return result;
-}
-
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
-    GGLfixed result,t,tmp1,tmp2;
-
-    if (__builtin_constant_p(shift)) {
-        if (shift == 0) {
-                 asm ("mul %[lo], %[a], %[b] \t\n"
-                 "addu  %[lo],%[lo],%[c]    \t\n"
-                 : [lo]"=&r"(result)
-                 : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                 );
-                } else if (shift == 32) {
-                    asm ("muh %[lo], %[a], %[b] \t\n"
-                    "addu  %[lo],%[lo],%[c]    \t\n"
-                    : [lo]"=&r"(result)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                    );
-                } else if ((shift>0) && (shift<32)) {
-                    asm ("mul %[res], %[a], %[b] \t\n"
-                    "muh  %[t], %[a], %[b] \t\n"
-                    "srl   %[res],%[res],%[rshift]    \t\n"
-                    "sll   %[t],%[t],%[lshift]     \t\n"
-                    "or  %[res],%[res],%[t]    \t\n"
-                    "addu  %[res],%[res],%[c]    \t\n"
-                    : [res]"=&r"(result),[t]"=&r"(t)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c),[lshift]"I"(32-shift),[rshift]"I"(shift)
-                    );
-                } else {
-                    asm ("mul %[res], %[a], %[b] \t\n"
-                    "muh %[t], %[a], %[b] \t\n"
-                    "nor %[tmp1],$zero,%[shift]\t\n"
-                    "srl   %[res],%[res],%[shift]    \t\n"
-                    "sll   %[tmp2],%[t],1     \t\n"
-                    "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                    "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                    "srav  %[res],%[t],%[shift]     \t\n"
-                    "andi %[tmp2],%[shift],0x20\t\n"
-                    "seleqz %[tmp1],%[tmp1],%[tmp2]\t\n"
-                    "selnez %[res],%[res],%[tmp2]\t\n"
-                    "or %[res],%[res],%[tmp1]\t\n"
-                    "addu  %[res],%[res],%[c]    \t\n"
-                    : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"I"(shift)
-                    );
-                }
-            } else {
-                asm ("mul %[res], %[a], %[b] \t\n"
-                "muh %[t], %[a], %[b] \t\n"
-                "nor %[tmp1],$zero,%[shift]\t\n"
-                "srl   %[res],%[res],%[shift]    \t\n"
-                "sll   %[tmp2],%[t],1     \t\n"
-                "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                "srav  %[res],%[t],%[shift]     \t\n"
-                "andi %[tmp2],%[shift],0x20\t\n"
-                "seleqz %[tmp1],%[tmp1],%[tmp2]\t\n"
-                "selnez %[res],%[res],%[tmp2]\t\n"
-                "or %[res],%[res],%[tmp1]\t\n"
-                "addu  %[res],%[res],%[c]    \t\n"
-                : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"r"(shift)
-                );
-            }
-            return result;
-}
-
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
-    GGLfixed result,t,tmp1,tmp2;
-
-    if (__builtin_constant_p(shift)) {
-        if (shift == 0) {
-                 asm ("mul %[lo], %[a], %[b] \t\n"
-                 "subu  %[lo],%[lo],%[c]    \t\n"
-                 : [lo]"=&r"(result)
-                 : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                 );
-                } else if (shift == 32) {
-                    asm ("muh %[lo], %[a], %[b] \t\n"
-                    "subu  %[lo],%[lo],%[c]    \t\n"
-                    : [lo]"=&r"(result)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c)
-                    );
-                } else if ((shift>0) && (shift<32)) {
-                    asm ("mul %[res], %[a], %[b] \t\n"
-                    "muh %[t], %[a], %[b] \t\n"
-                    "srl   %[res],%[res],%[rshift]    \t\n"
-                    "sll   %[t],%[t],%[lshift]     \t\n"
-                    "or  %[res],%[res],%[t]    \t\n"
-                    "subu  %[res],%[res],%[c]    \t\n"
-                    : [res]"=&r"(result),[t]"=&r"(t)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c),[lshift]"I"(32-shift),[rshift]"I"(shift)
-                    );
-                } else {
-                    asm ("mul %[res], %[a], %[b] \t\n"
-                    "muh %[t], %[a], %[b] \t\n"
-                    "nor %[tmp1],$zero,%[shift]\t\n"
-                    "srl   %[res],%[res],%[shift]    \t\n"
-                    "sll   %[tmp2],%[t],1     \t\n"
-                    "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                    "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                    "srav  %[res],%[t],%[shift]     \t\n"
-                    "andi %[tmp2],%[shift],0x20\t\n"
-                    "seleqz %[tmp1],%[tmp1],%[tmp2]\t\n"
-                    "selnez %[res],%[res],%[tmp2]\t\n"
-                    "or %[res],%[res],%[tmp1]\t\n"
-                    "subu  %[res],%[res],%[c]    \t\n"
-                    : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                    : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"I"(shift)
-                     );
-                    }
-                } else {
-                asm ("mul %[res], %[a], %[b] \t\n"
-                "muh %[t], %[a], %[b] \t\n"
-                "nor %[tmp1],$zero,%[shift]\t\n"
-                "srl   %[res],%[res],%[shift]    \t\n"
-                "sll   %[tmp2],%[t],1     \t\n"
-                "sllv  %[tmp2],%[tmp2],%[tmp1]     \t\n"
-                "or  %[tmp1],%[tmp2],%[res]    \t\n"
-                "srav  %[res],%[t],%[shift]     \t\n"
-                "andi %[tmp2],%[shift],0x20\t\n"
-                "seleqz %[tmp1],%[tmp1],%[tmp2]\t\n"
-                "selnez %[res],%[res],%[tmp2]\t\n"
-                "or %[res],%[res],%[tmp1]\t\n"
-                "subu  %[res],%[res],%[c]    \t\n"
-                : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
-                : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"r"(shift)
-                );
-            }
-    return result;
-}
-
-inline int64_t gglMulii(int32_t x, int32_t y) CONST;
-inline int64_t gglMulii(int32_t x, int32_t y) {
-    union {
-        struct {
-#if defined(__MIPSEL__)
-            int32_t lo;
-            int32_t hi;
-#elif defined(__MIPSEB__)
-            int32_t hi;
-            int32_t lo;
-#endif
-        } s;
-        int64_t res;
-    }u;
-    asm("mul %0, %2, %3 \t\n"
-        "muh %1, %2, %3 \t\n"
-        : "=r"(u.s.lo), "=&r"(u.s.hi)
-        : "%r"(x), "r"(y)
-        );
-    return u.res;
-}
-
-#else // ----------------------------------------------------------------------
-
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) {
-    return GGLfixed((int64_t(a)*b + (1<<(shift-1)))>>shift);
-}
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
-    return GGLfixed((int64_t(a)*b)>>shift) + c;
-}
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
-    return GGLfixed((int64_t(a)*b)>>shift) - c;
-}
-inline int64_t gglMulii(int32_t a, int32_t b) CONST;
-inline int64_t gglMulii(int32_t a, int32_t b) {
-    return int64_t(a)*b;
-}
-
-#endif
-
-// ------------------------------------------------------------------------
-
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b) CONST;
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b) {
-    return gglMulx(a, b, 16);
-}
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c) CONST;
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c) {
-    return gglMulAddx(a, b, c, 16);
-}
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c) CONST;
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c) {
-    return gglMulSubx(a, b, c, 16);
-}
-
-// ------------------------------------------------------------------------
-
-inline int32_t gglClz(int32_t x) CONST;
-inline int32_t gglClz(int32_t x)
-{
-#if (defined(__arm__) && !defined(__thumb__)) || defined(__mips__) || defined(__aarch64__)
-    return __builtin_clz(x);
-#else
-    if (!x) return 32;
-    int32_t exp = 31;
-    if (x & 0xFFFF0000) { exp -=16; x >>= 16; }
-    if (x & 0x0000ff00) { exp -= 8; x >>= 8; }
-    if (x & 0x000000f0) { exp -= 4; x >>= 4; }
-    if (x & 0x0000000c) { exp -= 2; x >>= 2; }
-    if (x & 0x00000002) { exp -= 1; }
-    return exp;
-#endif
-}
-
-// ------------------------------------------------------------------------
-
-int32_t gglDivQ(GGLfixed n, GGLfixed d, int32_t i) CONST;
-
-inline int32_t gglDivQ16(GGLfixed n, GGLfixed d) CONST;
-inline int32_t gglDivQ16(GGLfixed n, GGLfixed d) {
-    return gglDivQ(n, d, 16);
-}
-
-inline int32_t gglDivx(GGLfixed n, GGLfixed d) CONST;
-inline int32_t gglDivx(GGLfixed n, GGLfixed d) {
-    return gglDivQ(n, d, 16);
-}
-
-// ------------------------------------------------------------------------
-
-inline GGLfixed gglRecipFast(GGLfixed x) CONST;
-inline GGLfixed gglRecipFast(GGLfixed x)
-{
-    // This is a really bad approximation of 1/x, but it's also
-    // very fast. x must be strictly positive.
-    // if x between [0.5, 1[ , then 1/x = 3-2*x
-    // (we use 2.30 fixed-point)
-    const int32_t lz = gglClz(x);
-    return (0xC0000000 - (x << (lz - 1))) >> (30-lz);
-}
-
-// ------------------------------------------------------------------------
-
-inline GGLfixed gglClampx(GGLfixed c) CONST;
-inline GGLfixed gglClampx(GGLfixed c)
-{
-#if defined(__thumb__)
-    // clamp without branches
-    c &= ~(c>>31);  c = FIXED_ONE - c;
-    c &= ~(c>>31);  c = FIXED_ONE - c;
-#else
-#if defined(__arm__)
-    // I don't know why gcc thinks its smarter than me! The code below
-    // clamps to zero in one instruction, but gcc won't generate it and
-    // replace it by a cmp + movlt (it's quite amazing actually).
-    asm("bic %0, %1, %1, asr #31\n" : "=r"(c) : "r"(c));
-#elif defined(__aarch64__)
-    asm("bic %w0, %w1, %w1, asr #31\n" : "=r"(c) : "r"(c));
-#else
-    c &= ~(c>>31);
-#endif
-    if (c>FIXED_ONE)
-        c = FIXED_ONE;
-#endif
-    return c;
-}
-
-// ------------------------------------------------------------------------
-
-#endif // ANDROID_GGL_FIXED_H
diff --git a/libpixelflinger/picker.cpp b/libpixelflinger/picker.cpp
deleted file mode 100644
index aa55229..0000000
--- a/libpixelflinger/picker.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/* libs/pixelflinger/picker.cpp
-**
-** Copyright 2006, 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 <stdio.h>
-
-#include "buffer.h"
-#include "scanline.h"
-#include "picker.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-void ggl_init_picker(context_t* /*c*/)
-{
-}
-
-void ggl_pick(context_t* c)
-{
-    if (ggl_likely(!c->dirty))
-        return;
-        
-    // compute needs, see if they changed...
-    const uint32_t enables = c->state.enables;
-    needs_t new_needs(c->state.needs);
-
-    if (c->dirty & GGL_CB_STATE) {
-        new_needs.n &= ~GGL_NEEDS_CB_FORMAT_MASK;
-        new_needs.n |= GGL_BUILD_NEEDS(c->state.buffers.color.format, CB_FORMAT);
-        if (enables & GGL_ENABLE_BLENDING)
-            c->dirty |= GGL_PIXEL_PIPELINE_STATE;
-    }
-
-    if (c->dirty & GGL_PIXEL_PIPELINE_STATE) {
-        uint32_t n = GGL_BUILD_NEEDS(c->state.buffers.color.format, CB_FORMAT);
-        uint32_t p = 0;
-        if (enables & GGL_ENABLE_BLENDING) {
-            uint32_t src = c->state.blend.src;
-            uint32_t dst = c->state.blend.dst;
-            uint32_t src_alpha = c->state.blend.src_alpha;
-            uint32_t dst_alpha = c->state.blend.dst_alpha;
-            const GGLFormat& cbf = c->formats[ c->state.buffers.color.format ];
-            if (!cbf.c[GGLFormat::ALPHA].h) {
-                if ((src == GGL_ONE_MINUS_DST_ALPHA) ||
-                    (src == GGL_DST_ALPHA)) {
-                    src = GGL_ONE;
-                }
-                if ((src_alpha == GGL_ONE_MINUS_DST_ALPHA) ||
-                    (src_alpha == GGL_DST_ALPHA)) {
-                    src_alpha = GGL_ONE;
-                }
-                if ((dst == GGL_ONE_MINUS_DST_ALPHA) ||
-                    (dst == GGL_DST_ALPHA)) {
-                    dst = GGL_ONE;
-                }
-                if ((dst_alpha == GGL_ONE_MINUS_DST_ALPHA) ||
-                    (dst_alpha == GGL_DST_ALPHA)) {
-                    dst_alpha = GGL_ONE;
-                }
-            }
-
-            src       = ggl_blendfactor_to_needs(src);
-            dst       = ggl_blendfactor_to_needs(dst);
-            src_alpha = ggl_blendfactor_to_needs(src_alpha);
-            dst_alpha = ggl_blendfactor_to_needs(dst_alpha);
-                    
-            n |= GGL_BUILD_NEEDS( src, BLEND_SRC );
-            n |= GGL_BUILD_NEEDS( dst, BLEND_DST );
-            if (c->state.blend.alpha_separate) {
-                n |= GGL_BUILD_NEEDS( src_alpha, BLEND_SRCA );
-                n |= GGL_BUILD_NEEDS( dst_alpha, BLEND_DSTA );
-            } else {
-                n |= GGL_BUILD_NEEDS( src, BLEND_SRCA );
-                n |= GGL_BUILD_NEEDS( dst, BLEND_DSTA );
-            }
-        } else {
-            n |= GGL_BUILD_NEEDS( GGL_ONE,  BLEND_SRC );
-            n |= GGL_BUILD_NEEDS( GGL_ZERO, BLEND_DST );
-            n |= GGL_BUILD_NEEDS( GGL_ONE,  BLEND_SRCA );
-            n |= GGL_BUILD_NEEDS( GGL_ZERO, BLEND_DSTA );
-        }
-
-
-        n |= GGL_BUILD_NEEDS(c->state.mask.color^0xF,               MASK_ARGB);
-        n |= GGL_BUILD_NEEDS((enables & GGL_ENABLE_SMOOTH)  ?1:0,   SHADE);
-        if (enables & GGL_ENABLE_TMUS) {
-            n |= GGL_BUILD_NEEDS((enables & GGL_ENABLE_W)       ?1:0,   W);
-        }
-        p |= GGL_BUILD_NEEDS((enables & GGL_ENABLE_DITHER)  ?1:0,   P_DITHER);
-        p |= GGL_BUILD_NEEDS((enables & GGL_ENABLE_AA)      ?1:0,   P_AA);
-        p |= GGL_BUILD_NEEDS((enables & GGL_ENABLE_FOG)     ?1:0,   P_FOG);
-
-        if (enables & GGL_ENABLE_LOGIC_OP) {
-            n |= GGL_BUILD_NEEDS(c->state.logic_op.opcode, LOGIC_OP);
-        } else {
-            n |= GGL_BUILD_NEEDS(GGL_COPY, LOGIC_OP);
-        }
-
-        if (enables & GGL_ENABLE_ALPHA_TEST) {
-            p |= GGL_BUILD_NEEDS(c->state.alpha_test.func, P_ALPHA_TEST);
-        } else {
-            p |= GGL_BUILD_NEEDS(GGL_ALWAYS, P_ALPHA_TEST);
-        }
-
-        if (enables & GGL_ENABLE_DEPTH_TEST) {
-            p |= GGL_BUILD_NEEDS(c->state.depth_test.func, P_DEPTH_TEST);
-            p |= GGL_BUILD_NEEDS(c->state.mask.depth&1, P_MASK_Z);
-        } else {
-            p |= GGL_BUILD_NEEDS(GGL_ALWAYS, P_DEPTH_TEST);
-            // writing to the z-buffer is always disabled if depth-test
-            // is disabled.
-        }
-        new_needs.n = n;
-        new_needs.p = p;
-    }
-
-    if (c->dirty & GGL_TMU_STATE) {
-        int idx = 0;
-        for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-            const texture_t& tx = c->state.texture[i];
-            if (tx.enable) {
-                uint32_t t = 0;
-                t |= GGL_BUILD_NEEDS(tx.surface.format, T_FORMAT);
-                t |= GGL_BUILD_NEEDS(ggl_env_to_needs(tx.env), T_ENV);
-                t |= GGL_BUILD_NEEDS(0, T_POT);       // XXX: not used yet
-                if (tx.s_coord==GGL_ONE_TO_ONE && tx.t_coord==GGL_ONE_TO_ONE) {
-                    // we encode 1-to-1 into the wrap mode
-                    t |= GGL_BUILD_NEEDS(GGL_NEEDS_WRAP_11, T_S_WRAP);
-                    t |= GGL_BUILD_NEEDS(GGL_NEEDS_WRAP_11, T_T_WRAP);
-                } else {
-                    t |= GGL_BUILD_NEEDS(ggl_wrap_to_needs(tx.s_wrap), T_S_WRAP);
-                    t |= GGL_BUILD_NEEDS(ggl_wrap_to_needs(tx.t_wrap), T_T_WRAP);
-                }
-                if (tx.mag_filter == GGL_LINEAR) {
-                    t |= GGL_BUILD_NEEDS(1, T_LINEAR);
-                }
-                if (tx.min_filter == GGL_LINEAR) {
-                    t |= GGL_BUILD_NEEDS(1, T_LINEAR);
-                }
-                new_needs.t[idx++] = t;
-            } else {
-                new_needs.t[i] = 0;
-            }
-        }
-    }
-
-    if (new_needs != c->state.needs) {
-        c->state.needs = new_needs;
-        ggl_pick_texture(c);
-        ggl_pick_cb(c);
-        ggl_pick_scanline(c);
-    }
-    c->dirty = 0;
-}
-
-// ----------------------------------------------------------------------------
-}; // namespace android
-
diff --git a/libpixelflinger/picker.h b/libpixelflinger/picker.h
deleted file mode 100644
index 9cdbc3c..0000000
--- a/libpixelflinger/picker.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* libs/pixelflinger/picker.h
-**
-** Copyright 2006, 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_PICKER_H
-#define ANDROID_PICKER_H
-
-#include <private/pixelflinger/ggl_context.h>
-
-namespace android {
-
-void ggl_init_picker(context_t* c);
-void ggl_pick(context_t* c);
-
-}; // namespace android
-
-#endif
diff --git a/libpixelflinger/pixelflinger.cpp b/libpixelflinger/pixelflinger.cpp
deleted file mode 100644
index fd449b2..0000000
--- a/libpixelflinger/pixelflinger.cpp
+++ /dev/null
@@ -1,836 +0,0 @@
-/* libs/pixelflinger/pixelflinger.cpp
-**
-** Copyright 2006, 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 <assert.h>
-
-#include <sys/time.h>
-
-#include <pixelflinger/pixelflinger.h>
-#include <private/pixelflinger/ggl_context.h>
-
-#include "buffer.h"
-#include "clear.h"
-#include "picker.h"
-#include "raster.h"
-#include "scanline.h"
-#include "trap.h"
-
-#include "codeflinger/GGLAssembler.h"
-#include "codeflinger/CodeCache.h"
-
-#include <stdio.h> 
-
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-// 8x8 Bayer dither matrix
-static const uint8_t gDitherMatrix[GGL_DITHER_SIZE] = {
-     0, 32,  8, 40,  2, 34, 10, 42,
-    48, 16, 56, 24, 50, 18, 58, 26,
-    12, 44,  4, 36, 14, 46,  6, 38,
-    60, 28, 52, 20, 62, 30, 54, 22,
-     3, 35, 11, 43,  1, 33,  9, 41,
-    51, 19, 59, 27, 49, 17, 57, 25,
-    15, 47,  7, 39, 13, 45,  5, 37,
-    63, 31, 55, 23, 61, 29, 53, 21
-};
-
-static void ggl_init_procs(context_t* c);
-static void ggl_set_scissor(context_t* c);
-
-static void ggl_enable_blending(context_t* c, int enable);
-static void ggl_enable_scissor_test(context_t* c, int enable);
-static void ggl_enable_alpha_test(context_t* c, int enable);
-static void ggl_enable_logic_op(context_t* c, int enable);
-static void ggl_enable_dither(context_t* c, int enable);
-static void ggl_enable_stencil_test(context_t* c, int enable);
-static void ggl_enable_depth_test(context_t* c, int enable);
-static void ggl_enable_aa(context_t* c, int enable);
-static void ggl_enable_point_aa_nice(context_t* c, int enable);
-static void ggl_enable_texture2d(context_t* c, int enable);
-static void ggl_enable_w_lerp(context_t* c, int enable);
-static void ggl_enable_fog(context_t* c, int enable);
-
-static inline int min(int a, int b) CONST;
-static inline int min(int a, int b) {
-    return a < b ? a : b;
-}
-
-static inline int max(int a, int b) CONST;
-static inline int max(int a, int b) {
-    return a < b ? b : a;
-}
-
-// ----------------------------------------------------------------------------
-
-void ggl_error(context_t* c, GGLenum error)
-{
-    if (c->error == GGL_NO_ERROR)
-        c->error = error;
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_bindTexture(void* con, const GGLSurface* surface)
-{
-    GGL_CONTEXT(c, con);
-    if (surface->format != c->activeTMU->surface.format)
-        ggl_state_changed(c, GGL_TMU_STATE);    
-    ggl_set_surface(c, &(c->activeTMU->surface), surface);
-}
-
-
-static void ggl_bindTextureLod(void* con, GGLuint tmu,const GGLSurface* surface)
-{
-    GGL_CONTEXT(c, con);
-    // All LODs must have the same format
-    ggl_set_surface(c, &c->state.texture[tmu].surface, surface);
-}
-
-static void ggl_colorBuffer(void* con, const GGLSurface* surface)
-{
-    GGL_CONTEXT(c, con);
-    if (surface->format != c->state.buffers.color.format)
-        ggl_state_changed(c, GGL_CB_STATE);
-
-    if (surface->width > c->state.buffers.coverageBufferSize) {
-        // allocate the coverage factor buffer
-        free(c->state.buffers.coverage);
-        c->state.buffers.coverage = (int16_t*)malloc(surface->width * 2);
-        c->state.buffers.coverageBufferSize =
-                c->state.buffers.coverage ? surface->width : 0;
-    }
-    ggl_set_surface(c, &(c->state.buffers.color), surface);
-    if (c->state.buffers.read.format == 0) {
-        ggl_set_surface(c, &(c->state.buffers.read), surface);
-    }
-    ggl_set_scissor(c);
-}
-
-static void ggl_readBuffer(void* con, const GGLSurface* surface)
-{
-    GGL_CONTEXT(c, con);
-    ggl_set_surface(c, &(c->state.buffers.read), surface);
-}
-
-static void ggl_depthBuffer(void* con, const GGLSurface* surface)
-{
-    GGL_CONTEXT(c, con);
-    if (surface->format == GGL_PIXEL_FORMAT_Z_16) {
-        ggl_set_surface(c, &(c->state.buffers.depth), surface);
-    } else {
-        c->state.buffers.depth.format = GGL_PIXEL_FORMAT_NONE;
-        ggl_enable_depth_test(c, 0);
-    }
-}
-
-static void ggl_scissor(void* con, GGLint x, GGLint y,
-        GGLsizei width, GGLsizei height)
-{
-    GGL_CONTEXT(c, con);
-    c->state.scissor.user_left = x;
-    c->state.scissor.user_top = y;
-    c->state.scissor.user_right = x + width;
-    c->state.scissor.user_bottom = y + height;
-    ggl_set_scissor(c);
-}
-
-// ----------------------------------------------------------------------------
-
-static void enable_disable(context_t* c, GGLenum name, int en)
-{
-    switch (name) {
-    case GGL_BLEND:             ggl_enable_blending(c, en);      break;
-    case GGL_SCISSOR_TEST:      ggl_enable_scissor_test(c, en);  break;
-    case GGL_ALPHA_TEST:        ggl_enable_alpha_test(c, en);    break;
-    case GGL_COLOR_LOGIC_OP:    ggl_enable_logic_op(c, en);      break;
-    case GGL_DITHER:            ggl_enable_dither(c, en);        break;
-    case GGL_STENCIL_TEST:      ggl_enable_stencil_test(c, en);  break;
-    case GGL_DEPTH_TEST:        ggl_enable_depth_test(c, en);    break;
-    case GGL_AA:                ggl_enable_aa(c, en);            break;
-    case GGL_TEXTURE_2D:        ggl_enable_texture2d(c, en);     break;
-    case GGL_W_LERP:            ggl_enable_w_lerp(c, en);        break;
-    case GGL_FOG:               ggl_enable_fog(c, en);           break;
-    case GGL_POINT_SMOOTH_NICE: ggl_enable_point_aa_nice(c, en); break;
-    }
-}
-
-static void ggl_enable(void* con, GGLenum name)
-{
-    GGL_CONTEXT(c, con);
-    enable_disable(c, name, 1);
-}
-
-static void ggl_disable(void* con, GGLenum name)
-{
-    GGL_CONTEXT(c, con);
-    enable_disable(c, name, 0);
-}
-
-static void ggl_enableDisable(void* con, GGLenum name, GGLboolean en)
-{
-    GGL_CONTEXT(c, con);
-    enable_disable(c, name, en ? 1 : 0);
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_shadeModel(void* con, GGLenum mode)
-{
-    GGL_CONTEXT(c, con);
-    switch (mode) {
-    case GGL_FLAT:
-        if (c->state.enables & GGL_ENABLE_SMOOTH) {
-            c->state.enables &= ~GGL_ENABLE_SMOOTH;
-            ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-        }
-        break;
-    case GGL_SMOOTH:
-        if (!(c->state.enables & GGL_ENABLE_SMOOTH)) {
-            c->state.enables |= GGL_ENABLE_SMOOTH;
-            ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-        }
-        break;
-    default:
-        ggl_error(c, GGL_INVALID_ENUM);
-    }
-}
-
-static void ggl_color4xv(void* con, const GGLclampx* color)
-{
-    GGL_CONTEXT(c, con);
-	c->shade.r0 = gglFixedToIteratedColor(color[0]);
-	c->shade.g0 = gglFixedToIteratedColor(color[1]);
-	c->shade.b0 = gglFixedToIteratedColor(color[2]);
-	c->shade.a0 = gglFixedToIteratedColor(color[3]);
-}
-
-static void ggl_colorGrad12xv(void* con, const GGLcolor* grad)
-{
-    GGL_CONTEXT(c, con);
-    // it is very important to round the iterated value here because
-    // the rasterizer doesn't clamp them, therefore the iterated value
-    //must absolutely be correct.
-    // GGLColor is encoded as 8.16 value
-    const int32_t round = 0x8000;
-	c->shade.r0   = grad[ 0] + round;
-	c->shade.drdx = grad[ 1];
-	c->shade.drdy = grad[ 2];
-	c->shade.g0   = grad[ 3] + round;
-	c->shade.dgdx = grad[ 4];
-	c->shade.dgdy = grad[ 5];
-	c->shade.b0   = grad[ 6] + round;
-	c->shade.dbdx = grad[ 7];
-	c->shade.dbdy = grad[ 8];
-	c->shade.a0   = grad[ 9] + round;
-	c->shade.dadx = grad[10];
-	c->shade.dady = grad[11];
-}
-
-static void ggl_zGrad3xv(void* con, const GGLfixed32* grad)
-{
-    GGL_CONTEXT(c, con);
-    // z iterators are encoded as 0.32 fixed point and the z-buffer
-    // holds 16 bits, the rounding value is 0x8000.
-    const uint32_t round = 0x8000;
-	c->shade.z0   = grad[0] + round;
-	c->shade.dzdx = grad[1];
-	c->shade.dzdy = grad[2];
-}
-
-static void ggl_wGrad3xv(void* con, const GGLfixed* grad)
-{
-    GGL_CONTEXT(c, con);
-	c->shade.w0   = grad[0];
-	c->shade.dwdx = grad[1];
-	c->shade.dwdy = grad[2];
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_fogGrad3xv(void* con, const GGLfixed* grad)
-{
-    GGL_CONTEXT(c, con);
-	c->shade.f0     = grad[0];
-	c->shade.dfdx   = grad[1];
-	c->shade.dfdy   = grad[2];
-}
-
-static void ggl_fogColor3xv(void* con, const GGLclampx* color)
-{
-    GGL_CONTEXT(c, con);
-    const int32_t r = gglClampx(color[0]);
-    const int32_t g = gglClampx(color[1]);
-    const int32_t b = gglClampx(color[2]);
-    c->state.fog.color[GGLFormat::ALPHA]= 0xFF; // unused
-	c->state.fog.color[GGLFormat::RED]  = (r - (r>>8))>>8;
-	c->state.fog.color[GGLFormat::GREEN]= (g - (g>>8))>>8;
-	c->state.fog.color[GGLFormat::BLUE] = (b - (b>>8))>>8;
-}
-
-static void ggl_enable_fog(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_FOG)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_FOG;
-        else        c->state.enables &= ~GGL_ENABLE_FOG;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_blendFunc(void* con, GGLenum src, GGLenum dst)
-{
-    GGL_CONTEXT(c, con);
-    c->state.blend.src = src;
-    c->state.blend.src_alpha = src;
-    c->state.blend.dst = dst;
-    c->state.blend.dst_alpha = dst;
-    c->state.blend.alpha_separate = 0;
-    if (c->state.enables & GGL_ENABLE_BLENDING) {
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-static void ggl_blendFuncSeparate(void* con,
-        GGLenum src, GGLenum dst,
-        GGLenum srcAlpha, GGLenum dstAplha)
-{
-    GGL_CONTEXT(c, con);
-    c->state.blend.src = src;
-    c->state.blend.src_alpha = srcAlpha;
-    c->state.blend.dst = dst;
-    c->state.blend.dst_alpha = dstAplha;
-    c->state.blend.alpha_separate = 1;
-    if (c->state.enables & GGL_ENABLE_BLENDING) {
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_texEnvi(void* con,	GGLenum target,
-							GGLenum pname,
-							GGLint param)
-{
-    GGL_CONTEXT(c, con);
-    if (target != GGL_TEXTURE_ENV || pname != GGL_TEXTURE_ENV_MODE) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-    switch (param) {
-    case GGL_REPLACE:
-    case GGL_MODULATE:
-    case GGL_DECAL:
-    case GGL_BLEND:
-    case GGL_ADD:
-        if (c->activeTMU->env != param) {
-            c->activeTMU->env = param;
-            ggl_state_changed(c, GGL_TMU_STATE);
-        }
-        break;
-    default:
-        ggl_error(c, GGL_INVALID_ENUM);
-    }
-}
-
-static void ggl_texEnvxv(void* con, GGLenum target,
-        GGLenum pname, const GGLfixed* params)
-{
-    GGL_CONTEXT(c, con);
-    if (target != GGL_TEXTURE_ENV) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-    switch (pname) {
-    case GGL_TEXTURE_ENV_MODE:
-        ggl_texEnvi(con, target, pname, params[0]);
-        break;
-    case GGL_TEXTURE_ENV_COLOR: {
-        uint8_t* const color = c->activeTMU->env_color;
-        const GGLclampx r = gglClampx(params[0]);
-        const GGLclampx g = gglClampx(params[1]);
-        const GGLclampx b = gglClampx(params[2]);
-        const GGLclampx a = gglClampx(params[3]);
-        color[0] = (a-(a>>8))>>8;
-        color[1] = (r-(r>>8))>>8;
-        color[2] = (g-(g>>8))>>8;
-        color[3] = (b-(b>>8))>>8;
-        break;
-    }
-    default:
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-}
-
-
-static void ggl_texParameteri(void* con,
-        GGLenum target,
-        GGLenum pname,
-        GGLint param)
-{
-    GGL_CONTEXT(c, con);
-    if (target != GGL_TEXTURE_2D) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-
-    if (param == GGL_CLAMP_TO_EDGE)
-        param = GGL_CLAMP;
-
-    uint16_t* what = 0;
-    switch (pname) {
-    case GGL_TEXTURE_WRAP_S:
-        if ((param == GGL_CLAMP) ||
-            (param == GGL_REPEAT)) {
-            what = &c->activeTMU->s_wrap;
-        }
-        break;
-    case GGL_TEXTURE_WRAP_T:
-        if ((param == GGL_CLAMP) ||
-            (param == GGL_REPEAT)) {
-            what = &c->activeTMU->t_wrap;
-        }
-        break;
-    case GGL_TEXTURE_MIN_FILTER:
-        if ((param == GGL_NEAREST) ||
-            (param == GGL_NEAREST_MIPMAP_NEAREST) ||
-            (param == GGL_NEAREST_MIPMAP_LINEAR)) {
-            what = &c->activeTMU->min_filter;
-            param = GGL_NEAREST;
-        }
-        if ((param == GGL_LINEAR) ||
-            (param == GGL_LINEAR_MIPMAP_NEAREST) ||
-            (param == GGL_LINEAR_MIPMAP_LINEAR)) {
-            what = &c->activeTMU->min_filter;
-            param = GGL_LINEAR;
-        }
-        break;
-    case GGL_TEXTURE_MAG_FILTER:
-        if ((param == GGL_NEAREST) ||
-            (param == GGL_LINEAR)) {
-            what = &c->activeTMU->mag_filter;
-        }
-        break;
-    }
-    
-    if (!what) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-    
-    if (*what != param) {
-        *what = param;
-        ggl_state_changed(c, GGL_TMU_STATE);
-    }
-}
-
-static void ggl_texCoordGradScale8xv(void* con, GGLint tmu, const int32_t* grad)
-{
-    GGL_CONTEXT(c, con);
-    texture_t& u = c->state.texture[tmu];
-	u.shade.is0   = grad[0];
-	u.shade.idsdx = grad[1];
-	u.shade.idsdy = grad[2];
-	u.shade.it0   = grad[3];
-	u.shade.idtdx = grad[4];
-	u.shade.idtdy = grad[5];
-    u.shade.sscale= grad[6];
-    u.shade.tscale= grad[7];
-}
-
-static void ggl_texCoord2x(void* con, GGLfixed s, GGLfixed t)
-{
-    GGL_CONTEXT(c, con);
-	c->activeTMU->shade.is0 = s;
-	c->activeTMU->shade.it0 = t;
-    c->activeTMU->shade.sscale= 0;
-    c->activeTMU->shade.tscale= 0;
-}
-
-static void ggl_texCoord2i(void* con, GGLint s, GGLint t)
-{
-    ggl_texCoord2x(con, s<<16, t<<16);
-}
-
-static void ggl_texGeni(void* con, GGLenum coord, GGLenum pname, GGLint param)
-{
-    GGL_CONTEXT(c, con);
-    if (pname != GGL_TEXTURE_GEN_MODE) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-
-    uint32_t* coord_ptr = 0;
-    if (coord == GGL_S)         coord_ptr = &(c->activeTMU->s_coord);
-    else if (coord == GGL_T)    coord_ptr = &(c->activeTMU->t_coord);
-
-    if (coord_ptr) {
-        if (*coord_ptr != uint32_t(param)) {
-            *coord_ptr = uint32_t(param);
-            ggl_state_changed(c, GGL_TMU_STATE);
-        }
-    } else {
-        ggl_error(c, GGL_INVALID_ENUM);
-    }
-}
-
-static void ggl_activeTexture(void* con, GGLuint tmu)
-{
-    GGL_CONTEXT(c, con);
-    if (tmu >= GGLuint(GGL_TEXTURE_UNIT_COUNT)) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-    c->activeTMUIndex = tmu;
-    c->activeTMU = &(c->state.texture[tmu]);
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_colorMask(void* con, GGLboolean r,
-                                     GGLboolean g,
-                                     GGLboolean b,
-                                     GGLboolean a)
-{
-    GGL_CONTEXT(c, con);
-    int mask = 0;
-    if (a)  mask |= 1 << GGLFormat::ALPHA;
-    if (r)  mask |= 1 << GGLFormat::RED;
-    if (g)  mask |= 1 << GGLFormat::GREEN;
-    if (b)  mask |= 1 << GGLFormat::BLUE;
-    if (c->state.mask.color != mask) {
-        c->state.mask.color = mask;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-static void ggl_depthMask(void* con, GGLboolean flag)
-{
-    GGL_CONTEXT(c, con);
-    if (c->state.mask.depth != flag?1:0) {
-        c->state.mask.depth = flag?1:0;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-static void ggl_stencilMask(void* con, GGLuint mask)
-{
-    GGL_CONTEXT(c, con);
-    if (c->state.mask.stencil != mask) {
-        c->state.mask.stencil = mask;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_alphaFuncx(void* con, GGLenum func, GGLclampx ref)
-{
-    GGL_CONTEXT(c, con);
-    if ((func < GGL_NEVER) || (func > GGL_ALWAYS)) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-    c->state.alpha_test.ref = gglFixedToIteratedColor(gglClampx(ref));
-    if (c->state.alpha_test.func != func) {
-        c->state.alpha_test.func = func;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_depthFunc(void* con, GGLenum func)
-{
-    GGL_CONTEXT(c, con);
-    if ((func < GGL_NEVER) || (func > GGL_ALWAYS)) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-    if (c->state.depth_test.func != func) {
-        c->state.depth_test.func = func;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-static void ggl_logicOp(void* con, GGLenum opcode)
-{
-    GGL_CONTEXT(c, con);
-    if ((opcode < GGL_CLEAR) || (opcode > GGL_SET)) {
-        ggl_error(c, GGL_INVALID_ENUM);
-        return;
-    }
-    if (c->state.logic_op.opcode != opcode) {
-        c->state.logic_op.opcode = opcode;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-
-// ----------------------------------------------------------------------------
-
-void ggl_set_scissor(context_t* c)
-{
-    if (c->state.enables & GGL_ENABLE_SCISSOR_TEST) {
-        const int32_t l = c->state.scissor.user_left;
-        const int32_t t = c->state.scissor.user_top;
-        const int32_t r = c->state.scissor.user_right;
-        const int32_t b = c->state.scissor.user_bottom;
-        c->state.scissor.left   = max(0, l);
-        c->state.scissor.right  = min(c->state.buffers.color.width, r);
-        c->state.scissor.top    = max(0, t);
-        c->state.scissor.bottom = min(c->state.buffers.color.height, b);
-    } else {
-        c->state.scissor.left   = 0;
-        c->state.scissor.top    = 0;
-        c->state.scissor.right  = c->state.buffers.color.width;
-        c->state.scissor.bottom = c->state.buffers.color.height;
-    }
-}
-
-void ggl_enable_blending(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_BLENDING)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_BLENDING;
-        else        c->state.enables &= ~GGL_ENABLE_BLENDING;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_scissor_test(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_SCISSOR_TEST)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_SCISSOR_TEST;
-        else        c->state.enables &= ~GGL_ENABLE_SCISSOR_TEST;
-        ggl_set_scissor(c);
-    }
-}
-
-void ggl_enable_alpha_test(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_ALPHA_TEST)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_ALPHA_TEST;
-        else        c->state.enables &= ~GGL_ENABLE_ALPHA_TEST;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_logic_op(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_LOGIC_OP)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_LOGIC_OP;
-        else        c->state.enables &= ~GGL_ENABLE_LOGIC_OP;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_dither(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_DITHER)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_DITHER;
-        else        c->state.enables &= ~GGL_ENABLE_DITHER;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_stencil_test(context_t* /*c*/, int /*enable*/)
-{
-}
-
-void ggl_enable_depth_test(context_t* c, int enable)
-{
-    if (c->state.buffers.depth.format == 0)
-        enable = 0;
-    const int e = (c->state.enables & GGL_ENABLE_DEPTH_TEST)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_DEPTH_TEST;
-        else        c->state.enables &= ~GGL_ENABLE_DEPTH_TEST;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_aa(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_AA)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_AA;
-        else        c->state.enables &= ~GGL_ENABLE_AA;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_point_aa_nice(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_POINT_AA_NICE)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_POINT_AA_NICE;
-        else        c->state.enables &= ~GGL_ENABLE_POINT_AA_NICE;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_w_lerp(context_t* c, int enable)
-{
-    const int e = (c->state.enables & GGL_ENABLE_W)?1:0;
-    if (e != enable) {
-        if (enable) c->state.enables |= GGL_ENABLE_W;
-        else        c->state.enables &= ~GGL_ENABLE_W;
-        ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE);
-    }
-}
-
-void ggl_enable_texture2d(context_t* c, int enable)
-{
-    if (c->activeTMU->enable != enable) {
-        const uint32_t tmu = c->activeTMUIndex;
-        c->activeTMU->enable = enable;
-        const uint32_t mask = 1UL << tmu;
-        if (enable)                 c->state.enabled_tmu |= mask;
-        else                        c->state.enabled_tmu &= ~mask;
-        if (c->state.enabled_tmu)   c->state.enables |= GGL_ENABLE_TMUS;
-        else                        c->state.enables &= ~GGL_ENABLE_TMUS;
-        ggl_state_changed(c, GGL_TMU_STATE);
-    }
-}
-
-        
-// ----------------------------------------------------------------------------
-
-int64_t ggl_system_time()
-{
-    struct timespec t;
-    t.tv_sec = t.tv_nsec = 0;
-    clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t);
-    return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
-}
-
-// ----------------------------------------------------------------------------
-
-void ggl_init_procs(context_t* c)
-{
-    GGLContext& procs = *(GGLContext*)c;
-    GGL_INIT_PROC(procs, scissor);
-    GGL_INIT_PROC(procs, activeTexture);
-    GGL_INIT_PROC(procs, bindTexture);
-    GGL_INIT_PROC(procs, bindTextureLod);
-    GGL_INIT_PROC(procs, colorBuffer);
-    GGL_INIT_PROC(procs, readBuffer);
-    GGL_INIT_PROC(procs, depthBuffer);
-    GGL_INIT_PROC(procs, enable);
-    GGL_INIT_PROC(procs, disable);
-    GGL_INIT_PROC(procs, enableDisable);
-    GGL_INIT_PROC(procs, shadeModel);
-    GGL_INIT_PROC(procs, color4xv);
-    GGL_INIT_PROC(procs, colorGrad12xv);
-    GGL_INIT_PROC(procs, zGrad3xv);
-    GGL_INIT_PROC(procs, wGrad3xv);
-    GGL_INIT_PROC(procs, fogGrad3xv);
-    GGL_INIT_PROC(procs, fogColor3xv);
-    GGL_INIT_PROC(procs, blendFunc);
-    GGL_INIT_PROC(procs, blendFuncSeparate);
-    GGL_INIT_PROC(procs, texEnvi);
-    GGL_INIT_PROC(procs, texEnvxv);
-    GGL_INIT_PROC(procs, texParameteri);
-    GGL_INIT_PROC(procs, texCoord2i);
-    GGL_INIT_PROC(procs, texCoord2x);
-    GGL_INIT_PROC(procs, texCoordGradScale8xv);
-    GGL_INIT_PROC(procs, texGeni);
-    GGL_INIT_PROC(procs, colorMask);
-    GGL_INIT_PROC(procs, depthMask);
-    GGL_INIT_PROC(procs, stencilMask);
-    GGL_INIT_PROC(procs, alphaFuncx);
-    GGL_INIT_PROC(procs, depthFunc);
-    GGL_INIT_PROC(procs, logicOp);
-    ggl_init_clear(c);
-}
-
-void ggl_init_context(context_t* c)
-{
-    memset(c, 0, sizeof(context_t));
-    ggl_init_procs(c);
-    ggl_init_trap(c);
-    ggl_init_scanline(c);
-    ggl_init_texture(c);
-    ggl_init_picker(c);
-    ggl_init_raster(c);
-    c->formats = gglGetPixelFormatTable();
-    c->state.blend.src = GGL_ONE;
-    c->state.blend.dst = GGL_ZERO;
-    c->state.blend.src_alpha = GGL_ONE;
-    c->state.blend.dst_alpha = GGL_ZERO;
-    c->state.mask.color = 0xF;
-    c->state.mask.depth = 0;
-    c->state.mask.stencil = 0xFFFFFFFF;
-    c->state.logic_op.opcode = GGL_COPY;
-    c->state.alpha_test.func = GGL_ALWAYS;
-    c->state.depth_test.func = GGL_LESS;
-    c->state.depth_test.clearValue = FIXED_ONE;
-    c->shade.w0 = FIXED_ONE;
-    memcpy(c->ditherMatrix, gDitherMatrix, sizeof(gDitherMatrix));
-}
-
-void ggl_uninit_context(context_t* c)
-{
-    ggl_uninit_scanline(c);
-}
-
-// ----------------------------------------------------------------------------
-}; // namespace android
-// ----------------------------------------------------------------------------
-
-
-
-using namespace android;
-
-ssize_t gglInit(GGLContext** context)
-{
-    void* const base = malloc(sizeof(context_t) + 32);
-	if (base) {
-        // always align the context on cache lines
-        context_t *c = (context_t *)((ptrdiff_t(base)+31) & ~0x1FL);
-        ggl_init_context(c);
-        c->base = base;
-		*context = (GGLContext*)c;
-	} else {
-		return -1;
-	}
-	return 0;
-}
-
-ssize_t gglUninit(GGLContext* con)
-{
-    GGL_CONTEXT(c, (void*)con);
-    ggl_uninit_context(c);
-	free(c->base);
-	return 0;
-}
-
diff --git a/libpixelflinger/raster.cpp b/libpixelflinger/raster.cpp
deleted file mode 100644
index e95c2c8..0000000
--- a/libpixelflinger/raster.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/* libs/pixelflinger/raster.cpp
-**
-** Copyright 2006, 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 <string.h>
-
-#include "raster.h"
-#include "trap.h"
-
-namespace android {
-
-static void ggl_rasterPos2x(void* con, GGLfixed x, GGLfixed y);
-static void ggl_rasterPos2i(void* con, GGLint x, GGLint y);
-static void ggl_copyPixels(void* con, GGLint xs, GGLint ys,
-        GGLsizei width, GGLsizei height, GGLenum type);
-
-void ggl_init_raster(context_t* c)
-{
-    GGLContext& procs = *(GGLContext*)c;
-    GGL_INIT_PROC(procs, copyPixels);
-    GGL_INIT_PROC(procs, rasterPos2x);
-    GGL_INIT_PROC(procs, rasterPos2i);
-}
-
-void ggl_rasterPos2x(void* con, GGLfixed x, GGLfixed y)
-{
-    GGL_CONTEXT(c, con);
-    // raster pos should be processed just like glVertex
-    c->state.raster.x = x;
-    c->state.raster.y = y;
-}
-
-void ggl_rasterPos2i(void* con, GGLint x, GGLint y)
-{
-    ggl_rasterPos2x(con, gglIntToFixed(x), gglIntToFixed(y));
-}
-
-void ggl_copyPixels(void* con, GGLint xs, GGLint ys,
-        GGLsizei width, GGLsizei height, GGLenum /*type*/)
-{
-    GGL_CONTEXT(c, con);
-
-    // color-buffer
-    surface_t* cb = &(c->state.buffers.color);
-
-    // undefined behaviour if we try to copy from outside the surface
-    if (uint32_t(xs) > cb->width)
-        return;
-    if (uint32_t(ys) > cb->height)
-        return;
-    if (uint32_t(xs + width) > cb->width)
-        return;
-    if (uint32_t(ys + height) > cb->height)
-        return;
-
-    // copy to current raster position
-    GGLint xd = gglFixedToIntRound(c->state.raster.x);
-    GGLint yd = gglFixedToIntRound(c->state.raster.y);
-
-    // clip to scissor
-    if (xd < GGLint(c->state.scissor.left)) {
-        GGLint offset = GGLint(c->state.scissor.left) - xd;
-        xd = GGLint(c->state.scissor.left);
-        xs += offset;
-        width -= offset;
-    }
-    if (yd < GGLint(c->state.scissor.top)) {
-        GGLint offset = GGLint(c->state.scissor.top) - yd;
-        yd = GGLint(c->state.scissor.top);
-        ys += offset;
-        height -= offset;
-    }
-    if ((xd + width) > GGLint(c->state.scissor.right)) {
-        width = GGLint(c->state.scissor.right) - xd;
-    }
-    if ((yd + height) > GGLint(c->state.scissor.bottom)) {
-        height = GGLint(c->state.scissor.bottom) - yd;
-    }
-
-    if (width<=0 || height<=0) {
-        return; // nothing to copy
-    }
-
-    if (xs==xd && ys==yd) {
-        // nothing to do, but be careful, this might not be true when we support
-        // gglPixelTransfer, gglPixelMap and gglPixelZoom
-        return;
-    }
-
-    const GGLFormat* fp = &(c->formats[cb->format]);
-    uint8_t* src = reinterpret_cast<uint8_t*>(cb->data)
-            + (xs + (cb->stride * ys)) * fp->size;
-    uint8_t* dst = reinterpret_cast<uint8_t*>(cb->data)
-            + (xd + (cb->stride * yd)) * fp->size;
-    const size_t bpr = cb->stride * fp->size;
-    const size_t rowsize = width * fp->size;
-    size_t yc = height;
-
-    if (ys < yd) {
-        // bottom to top
-        src += height * bpr;
-        dst += height * bpr;
-        do {
-            dst -= bpr;
-            src -= bpr;
-            memcpy(dst, src, rowsize);
-        } while (--yc);
-    } else {
-        if (ys == yd) {
-            // might be right to left
-            do {
-                memmove(dst, src, rowsize);
-                dst += bpr;
-                src += bpr;
-            } while (--yc);
-        } else {
-            // top to bottom
-            do {
-                memcpy(dst, src, rowsize);
-                dst += bpr;
-                src += bpr;
-            } while (--yc);
-        }
-    }
-}
-
-}; // namespace android
-
-using namespace android;
-
-GGLint gglBitBlit(GGLContext* con, int tmu, GGLint crop[4], GGLint where[4])
-{
-    GGL_CONTEXT(c, (void*)con);
-
-     GGLint x = where[0];
-     GGLint y = where[1];
-     GGLint w = where[2];
-     GGLint h = where[3];
-
-    // exclsively enable this tmu
-    c->procs.activeTexture(c, tmu);
-    c->procs.disable(c, GGL_W_LERP);
-
-    uint32_t tmus = 1UL<<tmu;
-    if (c->state.enabled_tmu != tmus) {
-        c->activeTMU->enable = 1;
-        c->state.enabled_tmu = tmus;
-        c->state.enables |= GGL_ENABLE_TMUS;
-        ggl_state_changed(c, GGL_TMU_STATE);
-    }
-
-    const GGLint Wcr = crop[2];
-    const GGLint Hcr = crop[3];
-    if ((w == Wcr) && (h == Hcr)) {
-        c->procs.texGeni(c, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
-        c->procs.texGeni(c, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
-        const GGLint Ucr = crop[0];
-        const GGLint Vcr = crop[1];
-        const GGLint s0  = Ucr - x;
-        const GGLint t0  = Vcr - y;
-        c->procs.texCoord2i(c, s0, t0);
-        c->procs.recti(c, x, y, x+w, y+h);
-    } else {
-        int32_t texcoords[8];
-        x = gglIntToFixed(x);
-        y = gglIntToFixed(y); 
-    
-        // we CLAMP here, which works with premultiplied (s,t)
-        c->procs.texParameteri(c, GGL_TEXTURE_2D, GGL_TEXTURE_WRAP_S, GGL_CLAMP);
-        c->procs.texParameteri(c, GGL_TEXTURE_2D, GGL_TEXTURE_WRAP_T, GGL_CLAMP);
-        c->procs.texGeni(c, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_AUTOMATIC);
-        c->procs.texGeni(c, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_AUTOMATIC);
-    
-        const GGLint Ucr = crop[0] << 16;
-        const GGLint Vcr = crop[1] << 16;
-        const GGLint Wcr = crop[2] << 16;
-        const GGLint Hcr = crop[3] << 16;
-    
-        // computes texture coordinates (pre-multiplied)
-        int32_t dsdx = Wcr / w;   // dsdx = ((Wcr/w)/Wt)*Wt
-        int32_t dtdy = Hcr / h;   // dtdy = ((Hcr/h)/Ht)*Ht
-        int32_t s0   = Ucr - gglMulx(dsdx, x); // s0 = Ucr - x * dsdx
-        int32_t t0   = Vcr - gglMulx(dtdy, y); // t0 = Vcr - y * dtdy
-        texcoords[0] = s0;
-        texcoords[1] = dsdx;
-        texcoords[2] = 0;
-        texcoords[3] = t0;
-        texcoords[4] = 0;
-        texcoords[5] = dtdy;
-        texcoords[6] = 0;
-        texcoords[7] = 0;
-        c->procs.texCoordGradScale8xv(c, tmu, texcoords);
-        c->procs.recti(c, 
-                gglFixedToIntRound(x),
-                gglFixedToIntRound(y),
-                gglFixedToIntRound(x)+w,
-                gglFixedToIntRound(y)+h);
-    }
-    return 0;
-}
-
diff --git a/libpixelflinger/raster.h b/libpixelflinger/raster.h
deleted file mode 100644
index 9f0f240..0000000
--- a/libpixelflinger/raster.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* libs/pixelflinger/raster.h
-**
-** Copyright 2006, 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_GGL_RASTER_H
-#define ANDROID_GGL_RASTER_H
-
-#include <private/pixelflinger/ggl_context.h>
-
-namespace android {
-
-void ggl_init_raster(context_t* c);
-
-void gglCopyPixels(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height, GGLenum type);
-void gglRasterPos2d(void* c, GGLint x, GGLint y);
-
-}; // namespace android
-
-#endif // ANDROID_GGL_RASTER_H
diff --git a/libpixelflinger/scanline.cpp b/libpixelflinger/scanline.cpp
deleted file mode 100644
index 4cc23c7..0000000
--- a/libpixelflinger/scanline.cpp
+++ /dev/null
@@ -1,2373 +0,0 @@
-/* libs/pixelflinger/scanline.cpp
-**
-** Copyright 2006-2011, 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.
-*/
-
-#define LOG_TAG "pixelflinger"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <cutils/memory.h>
-#include <log/log.h>
-
-#include "buffer.h"
-#include "scanline.h"
-
-#include "codeflinger/CodeCache.h"
-#include "codeflinger/GGLAssembler.h"
-#if defined(__arm__)
-#include "codeflinger/ARMAssembler.h"
-#elif defined(__aarch64__)
-#include "codeflinger/Arm64Assembler.h"
-#elif defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
-#include "codeflinger/MIPSAssembler.h"
-#elif defined(__mips__) && defined(__LP64__)
-#include "codeflinger/MIPS64Assembler.h"
-#endif
-//#include "codeflinger/ARMAssemblerOptimizer.h"
-
-// ----------------------------------------------------------------------------
-
-#define ANDROID_CODEGEN_GENERIC     0   // force generic pixel pipeline
-#define ANDROID_CODEGEN_C           1   // hand-written C, fallback generic 
-#define ANDROID_CODEGEN_ASM         2   // hand-written asm, fallback generic
-#define ANDROID_CODEGEN_GENERATED   3   // hand-written asm, fallback codegen
-
-#ifdef NDEBUG
-#   define ANDROID_RELEASE
-#   define ANDROID_CODEGEN      ANDROID_CODEGEN_GENERATED
-#else
-#   define ANDROID_DEBUG
-#   define ANDROID_CODEGEN      ANDROID_CODEGEN_GENERATED
-#endif
-
-#if defined(__arm__) || (defined(__mips__) && ((!defined(__LP64__) && __mips_isa_rev < 6) || defined(__LP64__))) || defined(__aarch64__)
-#   define ANDROID_ARM_CODEGEN  1
-#else
-#   define ANDROID_ARM_CODEGEN  0
-#endif
-
-#define DEBUG__CODEGEN_ONLY     0
-
-/* Set to 1 to dump to the log the states that need a new
- * code-generated scanline callback, i.e. those that don't
- * have a corresponding shortcut function.
- */
-#define DEBUG_NEEDS  0
-
-#if defined( __mips__) && ((!defined(__LP64__) && __mips_isa_rev < 6) || defined(__LP64__))
-#define ASSEMBLY_SCRATCH_SIZE   4096
-#elif defined(__aarch64__)
-#define ASSEMBLY_SCRATCH_SIZE   8192
-#else
-#define ASSEMBLY_SCRATCH_SIZE   2048
-#endif
-
-// ----------------------------------------------------------------------------
-namespace android {
-// ----------------------------------------------------------------------------
-
-static void init_y(context_t*, int32_t);
-static void init_y_noop(context_t*, int32_t);
-static void init_y_packed(context_t*, int32_t);
-static void init_y_error(context_t*, int32_t);
-
-static void step_y__generic(context_t* c);
-static void step_y__nop(context_t*);
-static void step_y__smooth(context_t* c);
-static void step_y__tmu(context_t* c);
-static void step_y__w(context_t* c);
-
-static void scanline(context_t* c);
-static void scanline_perspective(context_t* c);
-static void scanline_perspective_single(context_t* c);
-static void scanline_t32cb16blend(context_t* c);
-static void scanline_t32cb16blend_dither(context_t* c);
-static void scanline_t32cb16blend_srca(context_t* c);
-static void scanline_t32cb16blend_clamp(context_t* c);
-static void scanline_t32cb16blend_clamp_dither(context_t* c);
-static void scanline_t32cb16blend_clamp_mod(context_t* c);
-static void scanline_x32cb16blend_clamp_mod(context_t* c);
-static void scanline_t32cb16blend_clamp_mod_dither(context_t* c);
-static void scanline_x32cb16blend_clamp_mod_dither(context_t* c);
-static void scanline_t32cb16(context_t* c);
-static void scanline_t32cb16_dither(context_t* c);
-static void scanline_t32cb16_clamp(context_t* c);
-static void scanline_t32cb16_clamp_dither(context_t* c);
-static void scanline_col32cb16blend(context_t* c);
-static void scanline_t16cb16_clamp(context_t* c);
-static void scanline_t16cb16blend_clamp_mod(context_t* c);
-static void scanline_memcpy(context_t* c);
-static void scanline_memset8(context_t* c);
-static void scanline_memset16(context_t* c);
-static void scanline_memset32(context_t* c);
-static void scanline_noop(context_t* c);
-static void scanline_set(context_t* c);
-static void scanline_clear(context_t* c);
-
-static void rect_generic(context_t* c, size_t yc);
-static void rect_memcpy(context_t* c, size_t yc);
-
-#if defined( __arm__)
-extern "C" void scanline_t32cb16blend_arm(uint16_t*, uint32_t*, size_t);
-extern "C" void scanline_t32cb16_arm(uint16_t *dst, uint32_t *src, size_t ct);
-extern "C" void scanline_col32cb16blend_neon(uint16_t *dst, uint32_t *col, size_t ct);
-extern "C" void scanline_col32cb16blend_arm(uint16_t *dst, uint32_t col, size_t ct);
-#elif defined(__aarch64__)
-extern "C" void scanline_t32cb16blend_arm64(uint16_t*, uint32_t*, size_t);
-extern "C" void scanline_col32cb16blend_arm64(uint16_t *dst, uint32_t col, size_t ct);
-#elif defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
-extern "C" void scanline_t32cb16blend_mips(uint16_t*, uint32_t*, size_t);
-#elif defined(__mips__) && defined(__LP64__)
-extern "C" void scanline_t32cb16blend_mips64(uint16_t*, uint32_t*, size_t);
-extern "C" void scanline_col32cb16blend_mips64(uint16_t *dst, uint32_t col, size_t ct);
-#endif
-
-// ----------------------------------------------------------------------------
-
-static inline uint16_t  convertAbgr8888ToRgb565(uint32_t  pix)
-{
-    return uint16_t( ((pix << 8) & 0xf800) |
-                      ((pix >> 5) & 0x07e0) |
-                      ((pix >> 19) & 0x001f) );
-}
-
-struct shortcut_t {
-    needs_filter_t  filter;
-    const char*     desc;
-    void            (*scanline)(context_t*);
-    void            (*init_y)(context_t*, int32_t);
-};
-
-// Keep in sync with needs
-
-/* To understand the values here, have a look at:
- *     system/core/include/private/pixelflinger/ggl_context.h
- *
- * Especially the lines defining and using GGL_RESERVE_NEEDS
- *
- * Quick reminders:
- *   - the last nibble of the first value is the destination buffer format.
- *   - the last nibble of the third value is the source texture format
- *   - formats: 4=rgb565 1=abgr8888 2=xbgr8888
- *
- * In the descriptions below:
- *
- *   SRC      means we copy the source pixels to the destination
- *
- *   SRC_OVER means we blend the source pixels to the destination
- *            with dstFactor = 1-srcA, srcFactor=1  (premultiplied source).
- *            This mode is otherwise called 'blend'.
- *
- *   SRCA_OVER means we blend the source pixels to the destination
- *             with dstFactor=srcA*(1-srcA) srcFactor=srcA (non-premul source).
- *             This mode is otherwise called 'blend_srca'
- *
- *   clamp    means we fetch source pixels from a texture with u/v clamping
- *
- *   mod      means the source pixels are modulated (multiplied) by the
- *            a/r/g/b of the current context's color. Typically used for
- *            fade-in / fade-out.
- *
- *   dither   means we dither 32 bit values to 16 bits
- */
-static shortcut_t shortcuts[] = {
-    { { { 0x03515104, 0x00000077, { 0x00000A01, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, blend SRC_OVER", scanline_t32cb16blend, init_y_noop },
-    { { { 0x03010104, 0x00000077, { 0x00000A01, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC", scanline_t32cb16, init_y_noop  },
-    /* same as first entry, but with dithering */
-    { { { 0x03515104, 0x00000177, { 0x00000A01, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, blend SRC_OVER dither", scanline_t32cb16blend_dither, init_y_noop },
-    /* same as second entry, but with dithering */
-    { { { 0x03010104, 0x00000177, { 0x00000A01, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC dither", scanline_t32cb16_dither, init_y_noop  },
-    /* this is used during the boot animation - CHEAT: ignore dithering */
-    { { { 0x03545404, 0x00000077, { 0x00000A01, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFEFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, blend dst:ONE_MINUS_SRCA src:SRCA", scanline_t32cb16blend_srca, init_y_noop },
-    /* special case for arbitrary texture coordinates (think scaling) */
-    { { { 0x03515104, 0x00000077, { 0x00000001, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC_OVER clamp", scanline_t32cb16blend_clamp, init_y },
-    { { { 0x03515104, 0x00000177, { 0x00000001, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC_OVER clamp dither", scanline_t32cb16blend_clamp_dither, init_y },
-    /* another case used during emulation */
-    { { { 0x03515104, 0x00000077, { 0x00001001, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC_OVER clamp modulate", scanline_t32cb16blend_clamp_mod, init_y },
-    /* and this */
-    { { { 0x03515104, 0x00000077, { 0x00001002, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, x888 tx, SRC_OVER clamp modulate", scanline_x32cb16blend_clamp_mod, init_y },
-    { { { 0x03515104, 0x00000177, { 0x00001001, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC_OVER clamp modulate dither", scanline_t32cb16blend_clamp_mod_dither, init_y },
-    { { { 0x03515104, 0x00000177, { 0x00001002, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, x888 tx, SRC_OVER clamp modulate dither", scanline_x32cb16blend_clamp_mod_dither, init_y },
-    { { { 0x03010104, 0x00000077, { 0x00000001, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC clamp", scanline_t32cb16_clamp, init_y  },
-    { { { 0x03010104, 0x00000077, { 0x00000002, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, x888 tx, SRC clamp", scanline_t32cb16_clamp, init_y  },
-    { { { 0x03010104, 0x00000177, { 0x00000001, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 8888 tx, SRC clamp dither", scanline_t32cb16_clamp_dither, init_y  },
-    { { { 0x03010104, 0x00000177, { 0x00000002, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, x888 tx, SRC clamp dither", scanline_t32cb16_clamp_dither, init_y  },
-    { { { 0x03010104, 0x00000077, { 0x00000004, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 565 tx, SRC clamp", scanline_t16cb16_clamp, init_y  },
-    { { { 0x03515104, 0x00000077, { 0x00001004, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0x0000003F } } },
-        "565 fb, 565 tx, SRC_OVER clamp", scanline_t16cb16blend_clamp_mod, init_y  },
-    { { { 0x03515104, 0x00000077, { 0x00000000, 0x00000000 } },
-        { 0xFFFFFFFF, 0xFFFFFFFF, { 0xFFFFFFFF, 0xFFFFFFFF } } },
-        "565 fb, 8888 fixed color", scanline_col32cb16blend, init_y_packed  },  
-    { { { 0x00000000, 0x00000000, { 0x00000000, 0x00000000 } },
-        { 0x00000000, 0x00000007, { 0x00000000, 0x00000000 } } },
-        "(nop) alpha test", scanline_noop, init_y_noop },
-    { { { 0x00000000, 0x00000000, { 0x00000000, 0x00000000 } },
-        { 0x00000000, 0x00000070, { 0x00000000, 0x00000000 } } },
-        "(nop) depth test", scanline_noop, init_y_noop },
-    { { { 0x05000000, 0x00000000, { 0x00000000, 0x00000000 } },
-        { 0x0F000000, 0x00000080, { 0x00000000, 0x00000000 } } },
-        "(nop) logic_op", scanline_noop, init_y_noop },
-    { { { 0xF0000000, 0x00000000, { 0x00000000, 0x00000000 } },
-        { 0xF0000000, 0x00000080, { 0x00000000, 0x00000000 } } },
-        "(nop) color mask", scanline_noop, init_y_noop },
-    { { { 0x0F000000, 0x00000077, { 0x00000000, 0x00000000 } },
-        { 0xFF000000, 0x000000F7, { 0x00000000, 0x00000000 } } },
-        "(set) logic_op", scanline_set, init_y_noop },
-    { { { 0x00000000, 0x00000077, { 0x00000000, 0x00000000 } },
-        { 0xFF000000, 0x000000F7, { 0x00000000, 0x00000000 } } },
-        "(clear) logic_op", scanline_clear, init_y_noop },
-    { { { 0x03000000, 0x00000077, { 0x00000000, 0x00000000 } },
-        { 0xFFFFFF00, 0x000000F7, { 0x00000000, 0x00000000 } } },
-        "(clear) blending 0/0", scanline_clear, init_y_noop },
-    { { { 0x00000000, 0x00000000, { 0x00000000, 0x00000000 } },
-        { 0x0000003F, 0x00000000, { 0x00000000, 0x00000000 } } },
-        "(error) invalid color-buffer format", scanline_noop, init_y_error },
-};
-static const needs_filter_t noblend1to1 = {
-        // (disregard dithering, see below)
-        { 0x03010100, 0x00000077, { 0x00000A00, 0x00000000 } },
-        { 0xFFFFFFC0, 0xFFFFFEFF, { 0xFFFFFFC0, 0x0000003F } }
-};
-static  const needs_filter_t fill16noblend = {
-        { 0x03010100, 0x00000077, { 0x00000000, 0x00000000 } },
-        { 0xFFFFFFC0, 0xFFFFFFFF, { 0x0000003F, 0x0000003F } }
-};
-
-// ----------------------------------------------------------------------------
-
-#if ANDROID_ARM_CODEGEN
-
-#if defined(__mips__) && ((!defined(__LP64__) && __mips_isa_rev < 6) || defined(__LP64__))
-static CodeCache gCodeCache(32 * 1024);
-#elif defined(__aarch64__)
-static CodeCache gCodeCache(48 * 1024);
-#else
-static CodeCache gCodeCache(12 * 1024);
-#endif
-
-class ScanlineAssembly : public Assembly {
-    AssemblyKey<needs_t> mKey;
-public:
-    ScanlineAssembly(needs_t needs, size_t size)
-        : Assembly(size), mKey(needs) { }
-    const AssemblyKey<needs_t>& key() const { return mKey; }
-};
-#endif
-
-// ----------------------------------------------------------------------------
-
-void ggl_init_scanline(context_t* c)
-{
-    c->init_y = init_y;
-    c->step_y = step_y__generic;
-    c->scanline = scanline;
-}
-
-void ggl_uninit_scanline(context_t* c)
-{
-    if (c->state.buffers.coverage)
-        free(c->state.buffers.coverage);
-#if ANDROID_ARM_CODEGEN
-    if (c->scanline_as)
-        c->scanline_as->decStrong(c);
-#endif
-}
-
-// ----------------------------------------------------------------------------
-
-static void pick_scanline(context_t* c)
-{
-#if (!defined(DEBUG__CODEGEN_ONLY) || (DEBUG__CODEGEN_ONLY == 0))
-
-#if ANDROID_CODEGEN == ANDROID_CODEGEN_GENERIC
-    c->init_y = init_y;
-    c->step_y = step_y__generic;
-    c->scanline = scanline;
-    return;
-#endif
-
-    //printf("*** needs [%08lx:%08lx:%08lx:%08lx]\n",
-    //    c->state.needs.n, c->state.needs.p,
-    //    c->state.needs.t[0], c->state.needs.t[1]);
-
-    // first handle the special case that we cannot test with a filter
-    const uint32_t cb_format = GGL_READ_NEEDS(CB_FORMAT, c->state.needs.n);
-    if (GGL_READ_NEEDS(T_FORMAT, c->state.needs.t[0]) == cb_format) {
-        if (c->state.needs.match(noblend1to1)) {
-            // this will match regardless of dithering state, since both
-            // src and dest have the same format anyway, there is no dithering
-            // to be done.
-            const GGLFormat* f =
-                &(c->formats[GGL_READ_NEEDS(T_FORMAT, c->state.needs.t[0])]);
-            if ((f->components == GGL_RGB) ||
-                (f->components == GGL_RGBA) ||
-                (f->components == GGL_LUMINANCE) ||
-                (f->components == GGL_LUMINANCE_ALPHA))
-            {
-                // format must have all of RGB components
-                // (so the current color doesn't show through)
-                c->scanline = scanline_memcpy;
-                c->init_y = init_y_noop;
-                return;
-            }
-        }
-    }
-
-    if (c->state.needs.match(fill16noblend)) {
-        c->init_y = init_y_packed;
-        switch (c->formats[cb_format].size) {
-        case 1: c->scanline = scanline_memset8;  return;
-        case 2: c->scanline = scanline_memset16; return;
-        case 4: c->scanline = scanline_memset32; return;
-        }
-    }
-
-    const int numFilters = sizeof(shortcuts)/sizeof(shortcut_t);
-    for (int i=0 ; i<numFilters ; i++) {
-        if (c->state.needs.match(shortcuts[i].filter)) {
-            c->scanline = shortcuts[i].scanline;
-            c->init_y = shortcuts[i].init_y;
-            return;
-        }
-    }
-
-#if DEBUG_NEEDS
-    ALOGI("Needs: n=0x%08x p=0x%08x t0=0x%08x t1=0x%08x",
-         c->state.needs.n, c->state.needs.p,
-         c->state.needs.t[0], c->state.needs.t[1]);
-#endif
-
-#endif // DEBUG__CODEGEN_ONLY
-
-    c->init_y = init_y;
-    c->step_y = step_y__generic;
-
-#if ANDROID_ARM_CODEGEN
-    // we're going to have to generate some code...
-    // here, generate code for our pixel pipeline
-    const AssemblyKey<needs_t> key(c->state.needs);
-    sp<Assembly> assembly = gCodeCache.lookup(key);
-    if (assembly == 0) {
-        // create a new assembly region
-        sp<ScanlineAssembly> a = new ScanlineAssembly(c->state.needs, 
-                ASSEMBLY_SCRATCH_SIZE);
-        // initialize our assembler
-#if defined(__arm__)
-        GGLAssembler assembler( new ARMAssembler(a) );
-        //GGLAssembler assembler(
-        //        new ARMAssemblerOptimizer(new ARMAssembler(a)) );
-#endif
-#if defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
-        GGLAssembler assembler( new ArmToMipsAssembler(a) );
-#elif defined(__mips__) && defined(__LP64__)
-        GGLAssembler assembler( new ArmToMips64Assembler(a) );
-#elif defined(__aarch64__)
-        GGLAssembler assembler( new ArmToArm64Assembler(a) );
-#endif
-        // generate the scanline code for the given needs
-        bool err = assembler.scanline(c->state.needs, c) != 0;
-        if (ggl_likely(!err)) {
-            // finally, cache this assembly
-            err = gCodeCache.cache(a->key(), a) < 0;
-        }
-        if (ggl_unlikely(err)) {
-            ALOGE("error generating or caching assembly. Reverting to NOP.");
-            c->scanline = scanline_noop;
-            c->init_y = init_y_noop;
-            c->step_y = step_y__nop;
-            return;
-        }
-        assembly = a;
-    }
-
-    // release the previous assembly
-    if (c->scanline_as) {
-        c->scanline_as->decStrong(c);
-    }
-
-    //ALOGI("using generated pixel-pipeline");
-    c->scanline_as = assembly.get();
-    c->scanline_as->incStrong(c); //  hold on to assembly
-    c->scanline = (void(*)(context_t* c))assembly->base();
-#else
-//    ALOGW("using generic (slow) pixel-pipeline");
-    c->scanline = scanline;
-#endif
-}
-
-void ggl_pick_scanline(context_t* c)
-{
-    pick_scanline(c);
-    if ((c->state.enables & GGL_ENABLE_W) &&
-        (c->state.enables & GGL_ENABLE_TMUS))
-    {
-        c->span = c->scanline;
-        c->scanline = scanline_perspective;
-        if (!(c->state.enabled_tmu & (c->state.enabled_tmu - 1))) {
-            // only one TMU enabled
-            c->scanline = scanline_perspective_single;
-        }
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-static void blending(context_t* c, pixel_t* fragment, pixel_t* fb);
-static void blend_factor(context_t* c, pixel_t* r, uint32_t factor,
-        const pixel_t* src, const pixel_t* dst);
-static void rescale(uint32_t& u, uint8_t& su, uint32_t& v, uint8_t& sv);
-
-#if ANDROID_ARM_CODEGEN && (ANDROID_CODEGEN == ANDROID_CODEGEN_GENERATED)
-
-// no need to compile the generic-pipeline, it can't be reached
-void scanline(context_t*)
-{
-}
-
-#else
-
-void rescale(uint32_t& u, uint8_t& su, uint32_t& v, uint8_t& sv)
-{
-    if (su && sv) {
-        if (su > sv) {
-            v = ggl_expand(v, sv, su);
-            sv = su;
-        } else if (su < sv) {
-            u = ggl_expand(u, su, sv);
-            su = sv;
-        }
-    }
-}
-
-void blending(context_t* c, pixel_t* fragment, pixel_t* fb)
-{
-    rescale(fragment->c[0], fragment->s[0], fb->c[0], fb->s[0]);
-    rescale(fragment->c[1], fragment->s[1], fb->c[1], fb->s[1]);
-    rescale(fragment->c[2], fragment->s[2], fb->c[2], fb->s[2]);
-    rescale(fragment->c[3], fragment->s[3], fb->c[3], fb->s[3]);
-
-    pixel_t sf, df;
-    blend_factor(c, &sf, c->state.blend.src, fragment, fb);
-    blend_factor(c, &df, c->state.blend.dst, fragment, fb);
-
-    fragment->c[1] =
-            gglMulAddx(fragment->c[1], sf.c[1], gglMulx(fb->c[1], df.c[1]));
-    fragment->c[2] =
-            gglMulAddx(fragment->c[2], sf.c[2], gglMulx(fb->c[2], df.c[2]));
-    fragment->c[3] =
-            gglMulAddx(fragment->c[3], sf.c[3], gglMulx(fb->c[3], df.c[3]));
-
-    if (c->state.blend.alpha_separate) {
-        blend_factor(c, &sf, c->state.blend.src_alpha, fragment, fb);
-        blend_factor(c, &df, c->state.blend.dst_alpha, fragment, fb);
-    }
-
-    fragment->c[0] =
-            gglMulAddx(fragment->c[0], sf.c[0], gglMulx(fb->c[0], df.c[0]));
-
-    // clamp to 1.0
-    if (fragment->c[0] >= (1LU<<fragment->s[0]))
-        fragment->c[0] = (1<<fragment->s[0])-1;
-    if (fragment->c[1] >= (1LU<<fragment->s[1]))
-        fragment->c[1] = (1<<fragment->s[1])-1;
-    if (fragment->c[2] >= (1LU<<fragment->s[2]))
-        fragment->c[2] = (1<<fragment->s[2])-1;
-    if (fragment->c[3] >= (1LU<<fragment->s[3]))
-        fragment->c[3] = (1<<fragment->s[3])-1;
-}
-
-static inline int blendfactor(uint32_t x, uint32_t size, uint32_t def = 0)
-{
-    if (!size)
-        return def;
-
-    // scale to 16 bits
-    if (size > 16) {
-        x >>= (size - 16);
-    } else if (size < 16) {
-        x = ggl_expand(x, size, 16);
-    }
-    x += x >> 15;
-    return x;
-}
-
-void blend_factor(context_t* /*c*/, pixel_t* r, 
-        uint32_t factor, const pixel_t* src, const pixel_t* dst)
-{
-    switch (factor) {
-        case GGL_ZERO:
-            r->c[1] = 
-            r->c[2] = 
-            r->c[3] = 
-            r->c[0] = 0;
-            break;
-        case GGL_ONE:
-            r->c[1] = 
-            r->c[2] = 
-            r->c[3] = 
-            r->c[0] = FIXED_ONE;
-            break;
-        case GGL_DST_COLOR:
-            r->c[1] = blendfactor(dst->c[1], dst->s[1]);
-            r->c[2] = blendfactor(dst->c[2], dst->s[2]);
-            r->c[3] = blendfactor(dst->c[3], dst->s[3]);
-            r->c[0] = blendfactor(dst->c[0], dst->s[0]);
-            break;
-        case GGL_SRC_COLOR:
-            r->c[1] = blendfactor(src->c[1], src->s[1]);
-            r->c[2] = blendfactor(src->c[2], src->s[2]);
-            r->c[3] = blendfactor(src->c[3], src->s[3]);
-            r->c[0] = blendfactor(src->c[0], src->s[0]);
-            break;
-        case GGL_ONE_MINUS_DST_COLOR:
-            r->c[1] = FIXED_ONE - blendfactor(dst->c[1], dst->s[1]);
-            r->c[2] = FIXED_ONE - blendfactor(dst->c[2], dst->s[2]);
-            r->c[3] = FIXED_ONE - blendfactor(dst->c[3], dst->s[3]);
-            r->c[0] = FIXED_ONE - blendfactor(dst->c[0], dst->s[0]);
-            break;
-        case GGL_ONE_MINUS_SRC_COLOR:
-            r->c[1] = FIXED_ONE - blendfactor(src->c[1], src->s[1]);
-            r->c[2] = FIXED_ONE - blendfactor(src->c[2], src->s[2]);
-            r->c[3] = FIXED_ONE - blendfactor(src->c[3], src->s[3]);
-            r->c[0] = FIXED_ONE - blendfactor(src->c[0], src->s[0]);
-            break;
-        case GGL_SRC_ALPHA:
-            r->c[1] = 
-            r->c[2] = 
-            r->c[3] = 
-            r->c[0] = blendfactor(src->c[0], src->s[0], FIXED_ONE);
-            break;
-        case GGL_ONE_MINUS_SRC_ALPHA:
-            r->c[1] = 
-            r->c[2] = 
-            r->c[3] = 
-            r->c[0] = FIXED_ONE - blendfactor(src->c[0], src->s[0], FIXED_ONE);
-            break;
-        case GGL_DST_ALPHA:
-            r->c[1] = 
-            r->c[2] = 
-            r->c[3] = 
-            r->c[0] = blendfactor(dst->c[0], dst->s[0], FIXED_ONE);
-            break;
-        case GGL_ONE_MINUS_DST_ALPHA:
-            r->c[1] = 
-            r->c[2] = 
-            r->c[3] = 
-            r->c[0] = FIXED_ONE - blendfactor(dst->c[0], dst->s[0], FIXED_ONE);
-            break;
-        case GGL_SRC_ALPHA_SATURATE:
-            // XXX: GGL_SRC_ALPHA_SATURATE
-            break;
-    }
-}
-
-static GGLfixed wrapping(int32_t coord, uint32_t size, int tx_wrap)
-{
-    GGLfixed d;
-    if (tx_wrap == GGL_REPEAT) {
-        d = (uint32_t(coord)>>16) * size;
-    } else if (tx_wrap == GGL_CLAMP) { // CLAMP_TO_EDGE semantics
-        const GGLfixed clamp_min = FIXED_HALF;
-        const GGLfixed clamp_max = (size << 16) - FIXED_HALF;
-        if (coord < clamp_min)     coord = clamp_min;
-        if (coord > clamp_max)     coord = clamp_max;
-        d = coord;
-    } else { // 1:1
-        const GGLfixed clamp_min = 0;
-        const GGLfixed clamp_max = (size << 16);
-        if (coord < clamp_min)     coord = clamp_min;
-        if (coord > clamp_max)     coord = clamp_max;
-        d = coord;
-    }
-    return d;
-}
-
-static inline
-GGLcolor ADJUST_COLOR_ITERATOR(GGLcolor v, GGLcolor dvdx, int len)
-{
-    const int32_t end = dvdx * (len-1) + v;
-    if (end < 0)
-        v -= end;
-    v &= ~(v>>31);
-    return v;
-}
-
-void scanline(context_t* c)
-{
-    const uint32_t enables = c->state.enables;
-    const int xs = c->iterators.xl;
-    const int x1 = c->iterators.xr;
-	int xc = x1 - xs;
-    const int16_t* covPtr = c->state.buffers.coverage + xs;
-
-    // All iterated values are sampled at the pixel center
-
-    // reset iterators for that scanline...
-    GGLcolor r, g, b, a;
-    iterators_t& ci = c->iterators;
-    if (enables & GGL_ENABLE_SMOOTH) {
-        r = (xs * c->shade.drdx) + ci.ydrdy;
-        g = (xs * c->shade.dgdx) + ci.ydgdy;
-        b = (xs * c->shade.dbdx) + ci.ydbdy;
-        a = (xs * c->shade.dadx) + ci.ydady;
-        r = ADJUST_COLOR_ITERATOR(r, c->shade.drdx, xc);
-        g = ADJUST_COLOR_ITERATOR(g, c->shade.dgdx, xc);
-        b = ADJUST_COLOR_ITERATOR(b, c->shade.dbdx, xc);
-        a = ADJUST_COLOR_ITERATOR(a, c->shade.dadx, xc);
-    } else {
-        r = ci.ydrdy;
-        g = ci.ydgdy;
-        b = ci.ydbdy;
-        a = ci.ydady;
-    }
-
-    // z iterators are 1.31
-    GGLfixed z = (xs * c->shade.dzdx) + ci.ydzdy;
-    GGLfixed f = (xs * c->shade.dfdx) + ci.ydfdy;
-
-    struct {
-        GGLfixed s, t;
-    } tc[GGL_TEXTURE_UNIT_COUNT];
-    if (enables & GGL_ENABLE_TMUS) {
-        for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-            if (c->state.texture[i].enable) {
-                texture_iterators_t& ti = c->state.texture[i].iterators;
-                if (enables & GGL_ENABLE_W) {
-                    tc[i].s = ti.ydsdy;
-                    tc[i].t = ti.ydtdy;
-                } else {
-                    tc[i].s = (xs * ti.dsdx) + ti.ydsdy;
-                    tc[i].t = (xs * ti.dtdx) + ti.ydtdy;
-                }
-            }
-        }
-    }
-
-    pixel_t fragment;
-    pixel_t texel;
-    pixel_t fb;
-
-	uint32_t x = xs;
-	uint32_t y = c->iterators.y;
-
-	while (xc--) {
-    
-        { // just a scope
-
-		// read color (convert to 8 bits by keeping only the integer part)
-        fragment.s[1] = fragment.s[2] =
-        fragment.s[3] = fragment.s[0] = 8;
-        fragment.c[1] = r >> (GGL_COLOR_BITS-8);
-        fragment.c[2] = g >> (GGL_COLOR_BITS-8);
-        fragment.c[3] = b >> (GGL_COLOR_BITS-8);
-        fragment.c[0] = a >> (GGL_COLOR_BITS-8);
-
-		// texturing
-        if (enables & GGL_ENABLE_TMUS) {
-            for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-                texture_t& tx = c->state.texture[i];
-                if (!tx.enable)
-                    continue;
-                texture_iterators_t& ti = tx.iterators;
-                int32_t u, v;
-
-                // s-coordinate
-                if (tx.s_coord != GGL_ONE_TO_ONE) {
-                    const int w = tx.surface.width;
-                    u = wrapping(tc[i].s, w, tx.s_wrap);
-                    tc[i].s += ti.dsdx;
-                } else {
-                    u = (((tx.shade.is0>>16) + x)<<16) + FIXED_HALF;
-                }
-
-                // t-coordinate
-                if (tx.t_coord != GGL_ONE_TO_ONE) {
-                    const int h = tx.surface.height;
-                    v = wrapping(tc[i].t, h, tx.t_wrap);
-                    tc[i].t += ti.dtdx;
-                } else {
-                    v = (((tx.shade.it0>>16) + y)<<16) + FIXED_HALF;
-                }
-
-                // read texture
-                if (tx.mag_filter == GGL_NEAREST &&
-                    tx.min_filter == GGL_NEAREST)
-                {
-                    u >>= 16;
-                    v >>= 16;
-                    tx.surface.read(&tx.surface, c, u, v, &texel);
-                } else {
-                    const int w = tx.surface.width;
-                    const int h = tx.surface.height;
-                    u -= FIXED_HALF;
-                    v -= FIXED_HALF;
-                    int u0 = u >> 16;
-                    int v0 = v >> 16;
-                    int u1 = u0 + 1;
-                    int v1 = v0 + 1;
-                    if (tx.s_wrap == GGL_REPEAT) {
-                        if (u0<0)  u0 += w;
-                        if (u1<0)  u1 += w;
-                        if (u0>=w) u0 -= w;
-                        if (u1>=w) u1 -= w;
-                    } else {
-                        if (u0<0)  u0 = 0;
-                        if (u1<0)  u1 = 0;
-                        if (u0>=w) u0 = w-1;
-                        if (u1>=w) u1 = w-1;
-                    }
-                    if (tx.t_wrap == GGL_REPEAT) {
-                        if (v0<0)  v0 += h;
-                        if (v1<0)  v1 += h;
-                        if (v0>=h) v0 -= h;
-                        if (v1>=h) v1 -= h;
-                    } else {
-                        if (v0<0)  v0 = 0;
-                        if (v1<0)  v1 = 0;
-                        if (v0>=h) v0 = h-1;
-                        if (v1>=h) v1 = h-1;
-                    }
-                    pixel_t texels[4];
-                    uint32_t mm[4];
-                    tx.surface.read(&tx.surface, c, u0, v0, &texels[0]);
-                    tx.surface.read(&tx.surface, c, u0, v1, &texels[1]);
-                    tx.surface.read(&tx.surface, c, u1, v0, &texels[2]);
-                    tx.surface.read(&tx.surface, c, u1, v1, &texels[3]);
-                    u = (u >> 12) & 0xF; 
-                    v = (v >> 12) & 0xF;
-                    u += u>>3;
-                    v += v>>3;
-                    mm[0] = (0x10 - u) * (0x10 - v);
-                    mm[1] = (0x10 - u) * v;
-                    mm[2] = u * (0x10 - v);
-                    mm[3] = 0x100 - (mm[0] + mm[1] + mm[2]);
-                    for (int j=0 ; j<4 ; j++) {
-                        texel.s[j] = texels[0].s[j];
-                        if (!texel.s[j]) continue;
-                        texel.s[j] += 8;
-                        texel.c[j] =    texels[0].c[j]*mm[0] +
-                                        texels[1].c[j]*mm[1] +
-                                        texels[2].c[j]*mm[2] +
-                                        texels[3].c[j]*mm[3] ;
-                    }
-                }
-
-                // Texture environnement...
-                for (int j=0 ; j<4 ; j++) {
-                    uint32_t& Cf = fragment.c[j];
-                    uint32_t& Ct = texel.c[j];
-                    uint8_t& sf  = fragment.s[j];
-                    uint8_t& st  = texel.s[j];
-                    uint32_t At = texel.c[0];
-                    uint8_t sat = texel.s[0];
-                    switch (tx.env) {
-                    case GGL_REPLACE:
-                        if (st) {
-                            Cf = Ct;
-                            sf = st;
-                        }
-                        break;
-                    case GGL_MODULATE:
-                        if (st) {
-                            uint32_t factor = Ct + (Ct>>(st-1));
-                            Cf = (Cf * factor) >> st;
-                        }
-                        break;
-                    case GGL_DECAL:
-                        if (sat) {
-                            rescale(Cf, sf, Ct, st);
-                            Cf += ((Ct - Cf) * (At + (At>>(sat-1)))) >> sat;
-                        }
-                        break;
-                    case GGL_BLEND:
-                        if (st) {
-                            uint32_t Cc = tx.env_color[i];
-                            if (sf>8)       Cc = (Cc * ((1<<sf)-1))>>8;
-                            else if (sf<8)  Cc = (Cc - (Cc>>(8-sf)))>>(8-sf);
-                            uint32_t factor = Ct + (Ct>>(st-1));
-                            Cf = ((((1<<st) - factor) * Cf) + Ct*Cc)>>st;
-                        }
-                        break;
-                    case GGL_ADD:
-                        if (st) {
-                            rescale(Cf, sf, Ct, st);
-                            Cf += Ct;
-                        }
-                        break;
-                    }
-                }
-            }
-		}
-    
-        // coverage application
-        if (enables & GGL_ENABLE_AA) {
-            int16_t cf = *covPtr++;
-            fragment.c[0] = (int64_t(fragment.c[0]) * cf) >> 15;
-        }
-        
-        // alpha-test
-        if (enables & GGL_ENABLE_ALPHA_TEST) {
-            GGLcolor ref = c->state.alpha_test.ref;
-            GGLcolor alpha = (uint64_t(fragment.c[0]) *
-                    ((1<<GGL_COLOR_BITS)-1)) / ((1<<fragment.s[0])-1);
-            switch (c->state.alpha_test.func) {
-            case GGL_NEVER:     goto discard;
-            case GGL_LESS:      if (alpha<ref)  break; goto discard;
-            case GGL_EQUAL:     if (alpha==ref) break; goto discard;
-            case GGL_LEQUAL:    if (alpha<=ref) break; goto discard;
-            case GGL_GREATER:   if (alpha>ref)  break; goto discard;
-            case GGL_NOTEQUAL:  if (alpha!=ref) break; goto discard;
-            case GGL_GEQUAL:    if (alpha>=ref) break; goto discard;
-            }
-        }
-        
-        // depth test
-        if (c->state.buffers.depth.format) {
-            if (enables & GGL_ENABLE_DEPTH_TEST) {
-                surface_t* cb = &(c->state.buffers.depth);
-                uint16_t* p = (uint16_t*)(cb->data)+(x+(cb->stride*y));
-                uint16_t zz = uint32_t(z)>>(16);
-                uint16_t depth = *p;
-                switch (c->state.depth_test.func) {
-                case GGL_NEVER:     goto discard;
-                case GGL_LESS:      if (zz<depth)    break; goto discard;
-                case GGL_EQUAL:     if (zz==depth)   break; goto discard;
-                case GGL_LEQUAL:    if (zz<=depth)   break; goto discard;
-                case GGL_GREATER:   if (zz>depth)    break; goto discard;
-                case GGL_NOTEQUAL:  if (zz!=depth)   break; goto discard;
-                case GGL_GEQUAL:    if (zz>=depth)   break; goto discard;
-                }
-                // depth buffer is not enabled, if depth-test is not enabled
-/*
-        fragment.s[1] = fragment.s[2] =
-        fragment.s[3] = fragment.s[0] = 8;
-        fragment.c[1] = 
-        fragment.c[2] = 
-        fragment.c[3] = 
-        fragment.c[0] = 255 - (zz>>8);
-*/
-                if (c->state.mask.depth) {
-                    *p = zz;
-                }
-            }
-        }
-
-        // fog
-        if (enables & GGL_ENABLE_FOG) {
-            for (int i=1 ; i<=3 ; i++) {
-                GGLfixed fc = (c->state.fog.color[i] * 0x10000) / 0xFF;
-                uint32_t& c = fragment.c[i];
-                uint8_t& s  = fragment.s[i];
-                c = (c * 0x10000) / ((1<<s)-1);
-                c = gglMulAddx(c, f, gglMulx(fc, 0x10000 - f));
-                s = 16;
-            }
-        }
-
-        // blending
-        if (enables & GGL_ENABLE_BLENDING) {
-            fb.c[1] = fb.c[2] = fb.c[3] = fb.c[0] = 0; // placate valgrind
-            fb.s[1] = fb.s[2] = fb.s[3] = fb.s[0] = 0;
-            c->state.buffers.color.read(
-                    &(c->state.buffers.color), c, x, y, &fb);
-            blending( c, &fragment, &fb );
-        }
-
-		// write
-        c->state.buffers.color.write(
-                &(c->state.buffers.color), c, x, y, &fragment);
-        }
-
-discard:
-		// iterate...
-        x += 1;
-        if (enables & GGL_ENABLE_SMOOTH) {
-            r += c->shade.drdx;
-            g += c->shade.dgdx;
-            b += c->shade.dbdx;
-            a += c->shade.dadx;
-        }
-        z += c->shade.dzdx;
-        f += c->shade.dfdx;
-	}
-}
-
-#endif // ANDROID_ARM_CODEGEN && (ANDROID_CODEGEN == ANDROID_CODEGEN_GENERATED)
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Scanline
-#endif
-
-/* Used to parse a 32-bit source texture linearly. Usage is:
- *
- * horz_iterator32  hi(context);
- * while (...) {
- *    uint32_t  src_pixel = hi.get_pixel32();
- *    ...
- * }
- *
- * Use only for one-to-one texture mapping.
- */
-struct horz_iterator32 {
-    explicit horz_iterator32(context_t* c) {
-        const int x = c->iterators.xl;
-        const int y = c->iterators.y;
-        texture_t& tx = c->state.texture[0];
-        const int32_t u = (tx.shade.is0>>16) + x;
-        const int32_t v = (tx.shade.it0>>16) + y;
-        m_src = reinterpret_cast<uint32_t*>(tx.surface.data)+(u+(tx.surface.stride*v));
-    }
-    uint32_t  get_pixel32() {
-        return *m_src++;
-    }
-protected:
-    uint32_t* m_src;
-};
-
-/* A variant for 16-bit source textures. */
-struct horz_iterator16 {
-    explicit horz_iterator16(context_t* c) {
-        const int x = c->iterators.xl;
-        const int y = c->iterators.y;
-        texture_t& tx = c->state.texture[0];
-        const int32_t u = (tx.shade.is0>>16) + x;
-        const int32_t v = (tx.shade.it0>>16) + y;
-        m_src = reinterpret_cast<uint16_t*>(tx.surface.data)+(u+(tx.surface.stride*v));
-    }
-    uint16_t  get_pixel16() {
-        return *m_src++;
-    }
-protected:
-    uint16_t* m_src;
-};
-
-/* A clamp iterator is used to iterate inside a texture with GGL_CLAMP.
- * After initialization, call get_src16() or get_src32() to get the current
- * texture pixel value.
- */
-struct clamp_iterator {
-    explicit clamp_iterator(context_t* c) {
-        const int xs = c->iterators.xl;
-        texture_t& tx = c->state.texture[0];
-        texture_iterators_t& ti = tx.iterators;
-        m_s = (xs * ti.dsdx) + ti.ydsdy;
-        m_t = (xs * ti.dtdx) + ti.ydtdy;
-        m_ds = ti.dsdx;
-        m_dt = ti.dtdx;
-        m_width_m1 = tx.surface.width - 1;
-        m_height_m1 = tx.surface.height - 1;
-        m_data = tx.surface.data;
-        m_stride = tx.surface.stride;
-    }
-    uint16_t get_pixel16() {
-        int  u, v;
-        get_uv(u, v);
-        uint16_t* src = reinterpret_cast<uint16_t*>(m_data) + (u + (m_stride*v));
-        return src[0];
-    }
-    uint32_t get_pixel32() {
-        int  u, v;
-        get_uv(u, v);
-        uint32_t* src = reinterpret_cast<uint32_t*>(m_data) + (u + (m_stride*v));
-        return src[0];
-    }
-private:
-    void   get_uv(int& u, int& v) {
-        int  uu = m_s >> 16;
-        int  vv = m_t >> 16;
-        if (uu < 0)
-            uu = 0;
-        if (uu > m_width_m1)
-            uu = m_width_m1;
-        if (vv < 0)
-            vv = 0;
-        if (vv > m_height_m1)
-            vv = m_height_m1;
-        u = uu;
-        v = vv;
-        m_s += m_ds;
-        m_t += m_dt;
-    }
-
-    GGLfixed  m_s, m_t;
-    GGLfixed  m_ds, m_dt;
-    int       m_width_m1, m_height_m1;
-    uint8_t*  m_data;
-    int       m_stride;
-};
-
-/*
- * The 'horizontal clamp iterator' variant corresponds to the case where
- * the 'v' coordinate doesn't change. This is useful to avoid one mult and
- * extra adds / checks per pixels, if the blending/processing operation after
- * this is very fast.
- */
-static int is_context_horizontal(const context_t* c) {
-    return (c->state.texture[0].iterators.dtdx == 0);
-}
-
-struct horz_clamp_iterator {
-    uint16_t  get_pixel16() {
-        int  u = m_s >> 16;
-        m_s += m_ds;
-        if (u < 0)
-            u = 0;
-        if (u > m_width_m1)
-            u = m_width_m1;
-        const uint16_t* src = reinterpret_cast<const uint16_t*>(m_data);
-        return src[u];
-    }
-    uint32_t  get_pixel32() {
-        int  u = m_s >> 16;
-        m_s += m_ds;
-        if (u < 0)
-            u = 0;
-        if (u > m_width_m1)
-            u = m_width_m1;
-        const uint32_t* src = reinterpret_cast<const uint32_t*>(m_data);
-        return src[u];
-    }
-protected:
-    void init(const context_t* c, int shift);
-    GGLfixed       m_s;
-    GGLfixed       m_ds;
-    int            m_width_m1;
-    const uint8_t* m_data;
-};
-
-void horz_clamp_iterator::init(const context_t* c, int shift)
-{
-    const int xs = c->iterators.xl;
-    const texture_t& tx = c->state.texture[0];
-    const texture_iterators_t& ti = tx.iterators;
-    m_s = (xs * ti.dsdx) + ti.ydsdy;
-    m_ds = ti.dsdx;
-    m_width_m1 = tx.surface.width-1;
-    m_data = tx.surface.data;
-
-    GGLfixed t = (xs * ti.dtdx) + ti.ydtdy;
-    int      v = t >> 16;
-    if (v < 0)
-        v = 0;
-    else if (v >= (int)tx.surface.height)
-        v = (int)tx.surface.height-1;
-
-    m_data += (tx.surface.stride*v) << shift;
-}
-
-struct horz_clamp_iterator16 : horz_clamp_iterator {
-    explicit horz_clamp_iterator16(const context_t* c) {
-        init(c,1);
-    };
-};
-
-struct horz_clamp_iterator32 : horz_clamp_iterator {
-    explicit horz_clamp_iterator32(context_t* c) {
-        init(c,2);
-    };
-};
-
-/* This is used to perform dithering operations.
- */
-struct ditherer {
-    explicit ditherer(const context_t* c) {
-        const int x = c->iterators.xl;
-        const int y = c->iterators.y;
-        m_line = &c->ditherMatrix[ ((y & GGL_DITHER_MASK)<<GGL_DITHER_ORDER_SHIFT) ];
-        m_index = x & GGL_DITHER_MASK;
-    }
-    void step(void) {
-        m_index++;
-    }
-    int  get_value(void) {
-        int ret = m_line[m_index & GGL_DITHER_MASK];
-        m_index++;
-        return ret;
-    }
-    uint16_t abgr8888ToRgb565(uint32_t s) {
-        uint32_t r = s & 0xff;
-        uint32_t g = (s >> 8) & 0xff;
-        uint32_t b = (s >> 16) & 0xff;
-        return rgb888ToRgb565(r,g,b);
-    }
-    /* The following assumes that r/g/b are in the 0..255 range each */
-    uint16_t rgb888ToRgb565(uint32_t& r, uint32_t& g, uint32_t &b) {
-        int threshold = get_value();
-        /* dither in on GGL_DITHER_BITS, and each of r, g, b is on 8 bits */
-        r += (threshold >> (GGL_DITHER_BITS-8 +5));
-        g += (threshold >> (GGL_DITHER_BITS-8 +6));
-        b += (threshold >> (GGL_DITHER_BITS-8 +5));
-        if (r > 0xff)
-            r = 0xff;
-        if (g > 0xff)
-            g = 0xff;
-        if (b > 0xff)
-            b = 0xff;
-        return uint16_t(((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3));
-    }
-protected:
-    const uint8_t* m_line;
-    int            m_index;
-};
-
-/* This structure is used to blend (SRC_OVER) 32-bit source pixels
- * onto 16-bit destination ones. Usage is simply:
- *
- *   blender.blend(<32-bit-src-pixel-value>,<ptr-to-16-bit-dest-pixel>)
- */
-struct blender_32to16 {
-    explicit blender_32to16(context_t* /*c*/) { }
-    void write(uint32_t s, uint16_t* dst) {
-        if (s == 0)
-            return;
-        s = GGL_RGBA_TO_HOST(s);
-        int sA = (s>>24);
-        if (sA == 0xff) {
-            *dst = convertAbgr8888ToRgb565(s);
-        } else {
-            int f = 0x100 - (sA + (sA>>7));
-            int sR = (s >> (   3))&0x1F;
-            int sG = (s >> ( 8+2))&0x3F;
-            int sB = (s >> (16+3))&0x1F;
-            uint16_t d = *dst;
-            int dR = (d>>11)&0x1f;
-            int dG = (d>>5)&0x3f;
-            int dB = (d)&0x1f;
-            sR += (f*dR)>>8;
-            sG += (f*dG)>>8;
-            sB += (f*dB)>>8;
-            *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-        }
-    }
-    void write(uint32_t s, uint16_t* dst, ditherer& di) {
-        if (s == 0) {
-            di.step();
-            return;
-        }
-        s = GGL_RGBA_TO_HOST(s);
-        int sA = (s>>24);
-        if (sA == 0xff) {
-            *dst = di.abgr8888ToRgb565(s);
-        } else {
-            int threshold = di.get_value() << (8 - GGL_DITHER_BITS);
-            int f = 0x100 - (sA + (sA>>7));
-            int sR = (s >> (   3))&0x1F;
-            int sG = (s >> ( 8+2))&0x3F;
-            int sB = (s >> (16+3))&0x1F;
-            uint16_t d = *dst;
-            int dR = (d>>11)&0x1f;
-            int dG = (d>>5)&0x3f;
-            int dB = (d)&0x1f;
-            sR = ((sR << 8) + f*dR + threshold)>>8;
-            sG = ((sG << 8) + f*dG + threshold)>>8;
-            sB = ((sB << 8) + f*dB + threshold)>>8;
-            if (sR > 0x1f) sR = 0x1f;
-            if (sG > 0x3f) sG = 0x3f;
-            if (sB > 0x1f) sB = 0x1f;
-            *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-        }
-    }
-};
-
-/* This blender does the same for the 'blend_srca' operation.
- * where dstFactor=srcA*(1-srcA) srcFactor=srcA
- */
-struct blender_32to16_srcA {
-    explicit blender_32to16_srcA(const context_t* /*c*/) { }
-    void write(uint32_t s, uint16_t* dst) {
-        if (!s) {
-            return;
-        }
-        uint16_t d = *dst;
-        s = GGL_RGBA_TO_HOST(s);
-        int sR = (s >> (   3))&0x1F;
-        int sG = (s >> ( 8+2))&0x3F;
-        int sB = (s >> (16+3))&0x1F;
-        int sA = (s>>24);
-        int f1 = (sA + (sA>>7));
-        int f2 = 0x100-f1;
-        int dR = (d>>11)&0x1f;
-        int dG = (d>>5)&0x3f;
-        int dB = (d)&0x1f;
-        sR = (f1*sR + f2*dR)>>8;
-        sG = (f1*sG + f2*dG)>>8;
-        sB = (f1*sB + f2*dB)>>8;
-        *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-    }
-};
-
-/* Common init code the modulating blenders */
-struct blender_modulate {
-    void init(const context_t* c) {
-        const int r = c->iterators.ydrdy >> (GGL_COLOR_BITS-8);
-        const int g = c->iterators.ydgdy >> (GGL_COLOR_BITS-8);
-        const int b = c->iterators.ydbdy >> (GGL_COLOR_BITS-8);
-        const int a = c->iterators.ydady >> (GGL_COLOR_BITS-8);
-        m_r = r + (r >> 7);
-        m_g = g + (g >> 7);
-        m_b = b + (b >> 7);
-        m_a = a + (a >> 7);
-    }
-protected:
-    int m_r, m_g, m_b, m_a;
-};
-
-/* This blender does a normal blend after modulation.
- */
-struct blender_32to16_modulate : blender_modulate {
-    explicit blender_32to16_modulate(const context_t* c) {
-        init(c);
-    }
-    void write(uint32_t s, uint16_t* dst) {
-        // blend source and destination
-        if (!s) {
-            return;
-        }
-        s = GGL_RGBA_TO_HOST(s);
-
-        /* We need to modulate s */
-        uint32_t  sA = (s >> 24);
-        uint32_t  sB = (s >> 16) & 0xff;
-        uint32_t  sG = (s >> 8) & 0xff;
-        uint32_t  sR = s & 0xff;
-
-        sA = (sA*m_a) >> 8;
-        /* Keep R/G/B scaled to 5.8 or 6.8 fixed float format */
-        sR = (sR*m_r) >> (8 - 5);
-        sG = (sG*m_g) >> (8 - 6);
-        sB = (sB*m_b) >> (8 - 5);
-
-        /* Now do a normal blend */
-        int f = 0x100 - (sA + (sA>>7));
-        uint16_t d = *dst;
-        int dR = (d>>11)&0x1f;
-        int dG = (d>>5)&0x3f;
-        int dB = (d)&0x1f;
-        sR = (sR + f*dR)>>8;
-        sG = (sG + f*dG)>>8;
-        sB = (sB + f*dB)>>8;
-        *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-    }
-    void write(uint32_t s, uint16_t* dst, ditherer& di) {
-        // blend source and destination
-        if (!s) {
-            di.step();
-            return;
-        }
-        s = GGL_RGBA_TO_HOST(s);
-
-        /* We need to modulate s */
-        uint32_t  sA = (s >> 24);
-        uint32_t  sB = (s >> 16) & 0xff;
-        uint32_t  sG = (s >> 8) & 0xff;
-        uint32_t  sR = s & 0xff;
-
-        sA = (sA*m_a) >> 8;
-        /* keep R/G/B scaled to 5.8 or 6.8 fixed float format */
-        sR = (sR*m_r) >> (8 - 5);
-        sG = (sG*m_g) >> (8 - 6);
-        sB = (sB*m_b) >> (8 - 5);
-
-        /* Scale threshold to 0.8 fixed float format */
-        int threshold = di.get_value() << (8 - GGL_DITHER_BITS);
-        int f = 0x100 - (sA + (sA>>7));
-        uint16_t d = *dst;
-        int dR = (d>>11)&0x1f;
-        int dG = (d>>5)&0x3f;
-        int dB = (d)&0x1f;
-        sR = (sR + f*dR + threshold)>>8;
-        sG = (sG + f*dG + threshold)>>8;
-        sB = (sB + f*dB + threshold)>>8;
-        if (sR > 0x1f) sR = 0x1f;
-        if (sG > 0x3f) sG = 0x3f;
-        if (sB > 0x1f) sB = 0x1f;
-        *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-    }
-};
-
-/* same as 32to16_modulate, except that the input is xRGB, instead of ARGB */
-struct blender_x32to16_modulate : blender_modulate {
-    explicit blender_x32to16_modulate(const context_t* c) {
-        init(c);
-    }
-    void write(uint32_t s, uint16_t* dst) {
-        s = GGL_RGBA_TO_HOST(s);
-
-        uint32_t  sB = (s >> 16) & 0xff;
-        uint32_t  sG = (s >> 8) & 0xff;
-        uint32_t  sR = s & 0xff;
-
-        /* Keep R/G/B in 5.8 or 6.8 format */
-        sR = (sR*m_r) >> (8 - 5);
-        sG = (sG*m_g) >> (8 - 6);
-        sB = (sB*m_b) >> (8 - 5);
-
-        int f = 0x100 - m_a;
-        uint16_t d = *dst;
-        int dR = (d>>11)&0x1f;
-        int dG = (d>>5)&0x3f;
-        int dB = (d)&0x1f;
-        sR = (sR + f*dR)>>8;
-        sG = (sG + f*dG)>>8;
-        sB = (sB + f*dB)>>8;
-        *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-    }
-    void write(uint32_t s, uint16_t* dst, ditherer& di) {
-        s = GGL_RGBA_TO_HOST(s);
-
-        uint32_t  sB = (s >> 16) & 0xff;
-        uint32_t  sG = (s >> 8) & 0xff;
-        uint32_t  sR = s & 0xff;
-
-        sR = (sR*m_r) >> (8 - 5);
-        sG = (sG*m_g) >> (8 - 6);
-        sB = (sB*m_b) >> (8 - 5);
-
-        /* Now do a normal blend */
-        int threshold = di.get_value() << (8 - GGL_DITHER_BITS);
-        int f = 0x100 - m_a;
-        uint16_t d = *dst;
-        int dR = (d>>11)&0x1f;
-        int dG = (d>>5)&0x3f;
-        int dB = (d)&0x1f;
-        sR = (sR + f*dR + threshold)>>8;
-        sG = (sG + f*dG + threshold)>>8;
-        sB = (sB + f*dB + threshold)>>8;
-        if (sR > 0x1f) sR = 0x1f;
-        if (sG > 0x3f) sG = 0x3f;
-        if (sB > 0x1f) sB = 0x1f;
-        *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-    }
-};
-
-/* Same as above, but source is 16bit rgb565 */
-struct blender_16to16_modulate : blender_modulate {
-    explicit blender_16to16_modulate(const context_t* c) {
-        init(c);
-    }
-    void write(uint16_t s16, uint16_t* dst) {
-        uint32_t  s = s16;
-
-        uint32_t  sR = s >> 11;
-        uint32_t  sG = (s >> 5) & 0x3f;
-        uint32_t  sB = s & 0x1f;
-
-        sR = (sR*m_r);
-        sG = (sG*m_g);
-        sB = (sB*m_b);
-
-        int f = 0x100 - m_a;
-        uint16_t d = *dst;
-        int dR = (d>>11)&0x1f;
-        int dG = (d>>5)&0x3f;
-        int dB = (d)&0x1f;
-        sR = (sR + f*dR)>>8;
-        sG = (sG + f*dG)>>8;
-        sB = (sB + f*dB)>>8;
-        *dst = uint16_t((sR<<11)|(sG<<5)|sB);
-    }
-};
-
-/* This is used to iterate over a 16-bit destination color buffer.
- * Usage is:
- *
- *   dst_iterator16  di(context);
- *   while (di.count--) {
- *       <do stuff with dest pixel at di.dst>
- *       di.dst++;
- *   }
- */
-struct dst_iterator16 {
-    explicit dst_iterator16(const context_t* c) {
-        const int x = c->iterators.xl;
-        const int width = c->iterators.xr - x;
-        const int32_t y = c->iterators.y;
-        const surface_t* cb = &(c->state.buffers.color);
-        count = width;
-        dst = reinterpret_cast<uint16_t*>(cb->data) + (x+(cb->stride*y));
-    }
-    int        count;
-    uint16_t*  dst;
-};
-
-
-static void scanline_t32cb16_clamp(context_t* c)
-{
-    dst_iterator16  di(c);
-
-    if (is_context_horizontal(c)) {
-        /* Special case for simple horizontal scaling */
-        horz_clamp_iterator32 ci(c);
-        while (di.count--) {
-            uint32_t s = ci.get_pixel32();
-            *di.dst++ = convertAbgr8888ToRgb565(s);
-        }
-    } else {
-        /* General case */
-        clamp_iterator ci(c);
-        while (di.count--) {
-            uint32_t s = ci.get_pixel32();
-            *di.dst++ = convertAbgr8888ToRgb565(s);
-        }
-    }
-}
-
-static void scanline_t32cb16_dither(context_t* c)
-{
-    horz_iterator32 si(c);
-    dst_iterator16  di(c);
-    ditherer        dither(c);
-
-    while (di.count--) {
-        uint32_t s = si.get_pixel32();
-        *di.dst++ = dither.abgr8888ToRgb565(s);
-    }
-}
-
-static void scanline_t32cb16_clamp_dither(context_t* c)
-{
-    dst_iterator16  di(c);
-    ditherer        dither(c);
-
-    if (is_context_horizontal(c)) {
-        /* Special case for simple horizontal scaling */
-        horz_clamp_iterator32 ci(c);
-        while (di.count--) {
-            uint32_t s = ci.get_pixel32();
-            *di.dst++ = dither.abgr8888ToRgb565(s);
-        }
-    } else {
-        /* General case */
-        clamp_iterator ci(c);
-        while (di.count--) {
-            uint32_t s = ci.get_pixel32();
-            *di.dst++ = dither.abgr8888ToRgb565(s);
-        }
-    }
-}
-
-static void scanline_t32cb16blend_dither(context_t* c)
-{
-    dst_iterator16 di(c);
-    ditherer       dither(c);
-    blender_32to16 bl(c);
-    horz_iterator32  hi(c);
-    while (di.count--) {
-        uint32_t s = hi.get_pixel32();
-        bl.write(s, di.dst, dither);
-        di.dst++;
-    }
-}
-
-static void scanline_t32cb16blend_clamp(context_t* c)
-{
-    dst_iterator16  di(c);
-    blender_32to16  bl(c);
-
-    if (is_context_horizontal(c)) {
-        horz_clamp_iterator32 ci(c);
-        while (di.count--) {
-            uint32_t s = ci.get_pixel32();
-            bl.write(s, di.dst);
-            di.dst++;
-        }
-    } else {
-        clamp_iterator ci(c);
-        while (di.count--) {
-            uint32_t s = ci.get_pixel32();
-            bl.write(s, di.dst);
-            di.dst++;
-        }
-    }
-}
-
-static void scanline_t32cb16blend_clamp_dither(context_t* c)
-{
-    dst_iterator16 di(c);
-    ditherer       dither(c);
-    blender_32to16 bl(c);
-
-    clamp_iterator ci(c);
-    while (di.count--) {
-        uint32_t s = ci.get_pixel32();
-        bl.write(s, di.dst, dither);
-        di.dst++;
-    }
-}
-
-void scanline_t32cb16blend_clamp_mod(context_t* c)
-{
-    dst_iterator16 di(c);
-    blender_32to16_modulate bl(c);
-
-    clamp_iterator ci(c);
-    while (di.count--) {
-        uint32_t s = ci.get_pixel32();
-        bl.write(s, di.dst);
-        di.dst++;
-    }
-}
-
-void scanline_t32cb16blend_clamp_mod_dither(context_t* c)
-{
-    dst_iterator16 di(c);
-    blender_32to16_modulate bl(c);
-    ditherer dither(c);
-
-    clamp_iterator ci(c);
-    while (di.count--) {
-        uint32_t s = ci.get_pixel32();
-        bl.write(s, di.dst, dither);
-        di.dst++;
-    }
-}
-
-/* Variant of scanline_t32cb16blend_clamp_mod with a xRGB texture */
-void scanline_x32cb16blend_clamp_mod(context_t* c)
-{
-    dst_iterator16 di(c);
-    blender_x32to16_modulate  bl(c);
-
-    clamp_iterator ci(c);
-    while (di.count--) {
-        uint32_t s = ci.get_pixel32();
-        bl.write(s, di.dst);
-        di.dst++;
-    }
-}
-
-void scanline_x32cb16blend_clamp_mod_dither(context_t* c)
-{
-    dst_iterator16 di(c);
-    blender_x32to16_modulate  bl(c);
-    ditherer dither(c);
-
-    clamp_iterator ci(c);
-    while (di.count--) {
-        uint32_t s = ci.get_pixel32();
-        bl.write(s, di.dst, dither);
-        di.dst++;
-    }
-}
-
-void scanline_t16cb16_clamp(context_t* c)
-{
-    dst_iterator16  di(c);
-
-    /* Special case for simple horizontal scaling */
-    if (is_context_horizontal(c)) {
-        horz_clamp_iterator16 ci(c);
-        while (di.count--) {
-            *di.dst++ = ci.get_pixel16();
-        }
-    } else {
-        clamp_iterator ci(c);
-        while (di.count--) {
-            *di.dst++ = ci.get_pixel16();
-        }
-    }
-}
-
-
-
-template <typename T, typename U>
-static inline __attribute__((const))
-T interpolate(int y, T v0, U dvdx, U dvdy) {
-    // interpolates in pixel's centers
-    // v = v0 + (y + 0.5) * dvdy + (0.5 * dvdx)
-    return (y * dvdy) + (v0 + ((dvdy + dvdx) >> 1));
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#endif
-
-void init_y(context_t* c, int32_t ys)
-{
-    const uint32_t enables = c->state.enables;
-
-    // compute iterators...
-    iterators_t& ci = c->iterators;
-    
-    // sample in the center
-    ci.y = ys;
-
-    if (enables & (GGL_ENABLE_DEPTH_TEST|GGL_ENABLE_W|GGL_ENABLE_FOG)) {
-        ci.ydzdy = interpolate(ys, c->shade.z0, c->shade.dzdx, c->shade.dzdy);
-        ci.ydwdy = interpolate(ys, c->shade.w0, c->shade.dwdx, c->shade.dwdy);
-        ci.ydfdy = interpolate(ys, c->shade.f0, c->shade.dfdx, c->shade.dfdy);
-    }
-
-    if (ggl_unlikely(enables & GGL_ENABLE_SMOOTH)) {
-        ci.ydrdy = interpolate(ys, c->shade.r0, c->shade.drdx, c->shade.drdy);
-        ci.ydgdy = interpolate(ys, c->shade.g0, c->shade.dgdx, c->shade.dgdy);
-        ci.ydbdy = interpolate(ys, c->shade.b0, c->shade.dbdx, c->shade.dbdy);
-        ci.ydady = interpolate(ys, c->shade.a0, c->shade.dadx, c->shade.dady);
-        c->step_y = step_y__smooth;
-    } else {
-        ci.ydrdy = c->shade.r0;
-        ci.ydgdy = c->shade.g0;
-        ci.ydbdy = c->shade.b0;
-        ci.ydady = c->shade.a0;
-        // XXX: do only if needed, or make sure this is fast
-        c->packed = ggl_pack_color(c, c->state.buffers.color.format,
-                ci.ydrdy, ci.ydgdy, ci.ydbdy, ci.ydady);
-        c->packed8888 = ggl_pack_color(c, GGL_PIXEL_FORMAT_RGBA_8888, 
-                ci.ydrdy, ci.ydgdy, ci.ydbdy, ci.ydady);
-    }
-
-    // initialize the variables we need in the shader
-    generated_vars_t& gen = c->generated_vars;
-    gen.argb[GGLFormat::ALPHA].c  = ci.ydady;
-    gen.argb[GGLFormat::ALPHA].dx = c->shade.dadx;
-    gen.argb[GGLFormat::RED  ].c  = ci.ydrdy;
-    gen.argb[GGLFormat::RED  ].dx = c->shade.drdx;
-    gen.argb[GGLFormat::GREEN].c  = ci.ydgdy;
-    gen.argb[GGLFormat::GREEN].dx = c->shade.dgdx;
-    gen.argb[GGLFormat::BLUE ].c  = ci.ydbdy;
-    gen.argb[GGLFormat::BLUE ].dx = c->shade.dbdx;
-    gen.dzdx = c->shade.dzdx;
-    gen.f    = ci.ydfdy;
-    gen.dfdx = c->shade.dfdx;
-
-    if (enables & GGL_ENABLE_TMUS) {
-        for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-            texture_t& t = c->state.texture[i];
-            if (!t.enable) continue;
-
-            texture_iterators_t& ti = t.iterators;
-            if (t.s_coord == GGL_ONE_TO_ONE && t.t_coord == GGL_ONE_TO_ONE) {
-                // we need to set all of these to 0 because in some cases
-                // step_y__generic() or step_y__tmu() will be used and
-                // therefore will update dtdy, however, in 1:1 mode
-                // this is always done by the scanline rasterizer.
-                ti.dsdx = ti.dsdy = ti.dtdx = ti.dtdy = 0;
-                ti.ydsdy = t.shade.is0;
-                ti.ydtdy = t.shade.it0;
-            } else {
-                const int adjustSWrap = ((t.s_wrap==GGL_CLAMP)?0:16);
-                const int adjustTWrap = ((t.t_wrap==GGL_CLAMP)?0:16);
-                ti.sscale = t.shade.sscale + adjustSWrap;
-                ti.tscale = t.shade.tscale + adjustTWrap;
-                if (!(enables & GGL_ENABLE_W)) {
-                    // S coordinate
-                    const int32_t sscale = ti.sscale;
-                    const int32_t sy = interpolate(ys,
-                            t.shade.is0, t.shade.idsdx, t.shade.idsdy);
-                    if (sscale>=0) {
-                        ti.ydsdy= sy            << sscale;
-                        ti.dsdx = t.shade.idsdx << sscale; 
-                        ti.dsdy = t.shade.idsdy << sscale;
-                    } else {
-                        ti.ydsdy= sy            >> -sscale;
-                        ti.dsdx = t.shade.idsdx >> -sscale; 
-                        ti.dsdy = t.shade.idsdy >> -sscale;
-                    }
-                    // T coordinate
-                    const int32_t tscale = ti.tscale;
-                    const int32_t ty = interpolate(ys,
-                            t.shade.it0, t.shade.idtdx, t.shade.idtdy);
-                    if (tscale>=0) {
-                        ti.ydtdy= ty            << tscale;
-                        ti.dtdx = t.shade.idtdx << tscale; 
-                        ti.dtdy = t.shade.idtdy << tscale;
-                    } else {
-                        ti.ydtdy= ty            >> -tscale;
-                        ti.dtdx = t.shade.idtdx >> -tscale; 
-                        ti.dtdy = t.shade.idtdy >> -tscale;
-                    }
-                }
-            }
-            // mirror for generated code...
-            generated_tex_vars_t& gen = c->generated_vars.texture[i];
-            gen.width   = t.surface.width;
-            gen.height  = t.surface.height;
-            gen.stride  = t.surface.stride;
-            gen.data    = uintptr_t(t.surface.data);
-            gen.dsdx = ti.dsdx;
-            gen.dtdx = ti.dtdx;
-        }
-    }
-
-    // choose the y-stepper
-    c->step_y = step_y__nop;
-    if (enables & GGL_ENABLE_FOG) {
-        c->step_y = step_y__generic;
-    } else if (enables & GGL_ENABLE_TMUS) {
-        if (enables & GGL_ENABLE_SMOOTH) {
-            c->step_y = step_y__generic;
-        } else if (enables & GGL_ENABLE_W) {
-            c->step_y = step_y__w;
-        } else {
-            c->step_y = step_y__tmu;
-        }
-    } else {
-        if (enables & GGL_ENABLE_SMOOTH) {
-            c->step_y = step_y__smooth;
-        }
-    }
-    
-    // choose the rectangle blitter
-    c->rect = rect_generic;
-    if ((c->step_y == step_y__nop) &&
-        (c->scanline == scanline_memcpy))
-    {
-        c->rect = rect_memcpy;
-    }
-}
-
-void init_y_packed(context_t* c, int32_t y0)
-{
-    uint8_t f = c->state.buffers.color.format;
-    c->packed = ggl_pack_color(c, f,
-            c->shade.r0, c->shade.g0, c->shade.b0, c->shade.a0);
-    c->packed8888 = ggl_pack_color(c, GGL_PIXEL_FORMAT_RGBA_8888,
-            c->shade.r0, c->shade.g0, c->shade.b0, c->shade.a0);
-    c->iterators.y = y0;
-    c->step_y = step_y__nop;
-    // choose the rectangle blitter
-    c->rect = rect_generic;
-    if (c->scanline == scanline_memcpy) {
-        c->rect = rect_memcpy;
-    }
-}
-
-void init_y_noop(context_t* c, int32_t y0)
-{
-    c->iterators.y = y0;
-    c->step_y = step_y__nop;
-    // choose the rectangle blitter
-    c->rect = rect_generic;
-    if (c->scanline == scanline_memcpy) {
-        c->rect = rect_memcpy;
-    }
-}
-
-void init_y_error(context_t* c, int32_t y0)
-{
-    // woooops, shoud never happen,
-    // fail gracefully (don't display anything)
-    init_y_noop(c, y0);
-    ALOGE("color-buffer has an invalid format!");
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#endif
-
-void step_y__generic(context_t* c)
-{
-    const uint32_t enables = c->state.enables;
-
-    // iterate...
-    iterators_t& ci = c->iterators;
-    ci.y += 1;
-                
-    if (enables & GGL_ENABLE_SMOOTH) {
-        ci.ydrdy += c->shade.drdy;
-        ci.ydgdy += c->shade.dgdy;
-        ci.ydbdy += c->shade.dbdy;
-        ci.ydady += c->shade.dady;
-    }
-
-    const uint32_t mask =
-            GGL_ENABLE_DEPTH_TEST |
-            GGL_ENABLE_W |
-            GGL_ENABLE_FOG;
-    if (enables & mask) {
-        ci.ydzdy += c->shade.dzdy;
-        ci.ydwdy += c->shade.dwdy;
-        ci.ydfdy += c->shade.dfdy;
-    }
-
-    if ((enables & GGL_ENABLE_TMUS) && (!(enables & GGL_ENABLE_W))) {
-        for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-            if (c->state.texture[i].enable) {
-                texture_iterators_t& ti = c->state.texture[i].iterators;
-                ti.ydsdy += ti.dsdy;
-                ti.ydtdy += ti.dtdy;
-            }
-        }
-    }
-}
-
-void step_y__nop(context_t* c)
-{
-    c->iterators.y += 1;
-    c->iterators.ydzdy += c->shade.dzdy;
-}
-
-void step_y__smooth(context_t* c)
-{
-    iterators_t& ci = c->iterators;
-    ci.y += 1;
-    ci.ydrdy += c->shade.drdy;
-    ci.ydgdy += c->shade.dgdy;
-    ci.ydbdy += c->shade.dbdy;
-    ci.ydady += c->shade.dady;
-    ci.ydzdy += c->shade.dzdy;
-}
-
-void step_y__w(context_t* c)
-{
-    iterators_t& ci = c->iterators;
-    ci.y += 1;
-    ci.ydzdy += c->shade.dzdy;
-    ci.ydwdy += c->shade.dwdy;
-}
-
-void step_y__tmu(context_t* c)
-{
-    iterators_t& ci = c->iterators;
-    ci.y += 1;
-    ci.ydzdy += c->shade.dzdy;
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-        if (c->state.texture[i].enable) {
-            texture_iterators_t& ti = c->state.texture[i].iterators;
-            ti.ydsdy += ti.dsdy;
-            ti.ydtdy += ti.dtdy;
-        }
-    }
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#endif
-
-void scanline_perspective(context_t* c)
-{
-    struct {
-        union {
-            struct {
-                int32_t s, sq;
-                int32_t t, tq;
-            } sqtq;
-            struct {
-                int32_t v, q;
-            } st[2];
-        };
-    } tc[GGL_TEXTURE_UNIT_COUNT] __attribute__((aligned(16)));
-
-    // XXX: we should have a special case when dwdx = 0
-
-    // 32 pixels spans works okay. 16 is a lot better,
-    // but hey, it's a software renderer...
-    const uint32_t SPAN_BITS = 5; 
-    const uint32_t ys = c->iterators.y;
-    const uint32_t xs = c->iterators.xl;
-    const uint32_t x1 = c->iterators.xr;
-	const uint32_t xc = x1 - xs;
-    uint32_t remainder = xc & ((1<<SPAN_BITS)-1);
-    uint32_t numSpans = xc >> SPAN_BITS;
-
-    const iterators_t& ci = c->iterators;
-    int32_t w0 = (xs * c->shade.dwdx) + ci.ydwdy;
-    int32_t q0 = gglRecipQ(w0, 30);
-    const int iwscale = 32 - gglClz(q0);
-
-    const int32_t dwdx = c->shade.dwdx << SPAN_BITS;
-    int32_t xl = c->iterators.xl;
-
-    // We process s & t with a loop to reduce the code size
-    // (and i-cache pressure).
-
-    for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-        const texture_t& tmu = c->state.texture[i];
-        if (!tmu.enable) continue;
-        int32_t s =   tmu.shade.is0 +
-                     (tmu.shade.idsdy * ys) + (tmu.shade.idsdx * xs) +
-                     ((tmu.shade.idsdx + tmu.shade.idsdy)>>1);
-        int32_t t =   tmu.shade.it0 +
-                     (tmu.shade.idtdy * ys) + (tmu.shade.idtdx * xs) +
-                     ((tmu.shade.idtdx + tmu.shade.idtdy)>>1);
-        tc[i].sqtq.s  = s;
-        tc[i].sqtq.t  = t;
-        tc[i].sqtq.sq = gglMulx(s, q0, iwscale);
-        tc[i].sqtq.tq = gglMulx(t, q0, iwscale);
-    }
-
-    int32_t span = 0;
-    do {
-        int32_t w1;
-        if (ggl_likely(numSpans)) {
-            w1 = w0 + dwdx;
-        } else {
-            if (remainder) {
-                // finish off the scanline...
-                span = remainder;
-                w1 = (c->shade.dwdx * span) + w0;
-            } else {
-                break;
-            }
-        }
-        int32_t q1 = gglRecipQ(w1, 30);
-        for (int i=0 ; i<GGL_TEXTURE_UNIT_COUNT ; ++i) {
-            texture_t& tmu = c->state.texture[i];
-            if (!tmu.enable) continue;
-            texture_iterators_t& ti = tmu.iterators;
-
-            for (int j=0 ; j<2 ; j++) {
-                int32_t v = tc[i].st[j].v;
-                if (span)   v += (tmu.shade.st[j].dx)*span;
-                else        v += (tmu.shade.st[j].dx)<<SPAN_BITS;
-                const int32_t v0 = tc[i].st[j].q;
-                const int32_t v1 = gglMulx(v, q1, iwscale);
-                int32_t dvdx = v1 - v0;
-                if (span)   dvdx /= span;
-                else        dvdx >>= SPAN_BITS;
-                tc[i].st[j].v = v;
-                tc[i].st[j].q = v1;
-
-                const int scale = ti.st[j].scale + (iwscale - 30);
-                if (scale >= 0) {
-                    ti.st[j].ydvdy = v0   << scale;
-                    ti.st[j].dvdx  = dvdx << scale;
-                } else {
-                    ti.st[j].ydvdy = v0   >> -scale;
-                    ti.st[j].dvdx  = dvdx >> -scale;
-                }
-            }
-            generated_tex_vars_t& gen = c->generated_vars.texture[i];
-            gen.dsdx = ti.st[0].dvdx;
-            gen.dtdx = ti.st[1].dvdx;
-        }
-        c->iterators.xl = xl;
-        c->iterators.xr = xl = xl + (span ? span : (1<<SPAN_BITS));
-        w0 = w1;
-        q0 = q1;
-        c->span(c);
-    } while(numSpans--);
-}
-
-void scanline_perspective_single(context_t* c)
-{
-    // 32 pixels spans works okay. 16 is a lot better,
-    // but hey, it's a software renderer...
-    const uint32_t SPAN_BITS = 5; 
-    const uint32_t ys = c->iterators.y;
-    const uint32_t xs = c->iterators.xl;
-    const uint32_t x1 = c->iterators.xr;
-	const uint32_t xc = x1 - xs;
-
-    const iterators_t& ci = c->iterators;
-    int32_t w = (xs * c->shade.dwdx) + ci.ydwdy;
-    int32_t iw = gglRecipQ(w, 30);
-    const int iwscale = 32 - gglClz(iw);
-
-    const int i = 31 - gglClz(c->state.enabled_tmu);
-    generated_tex_vars_t& gen = c->generated_vars.texture[i];
-    texture_t& tmu = c->state.texture[i];
-    texture_iterators_t& ti = tmu.iterators;
-    const int sscale = ti.sscale + (iwscale - 30);
-    const int tscale = ti.tscale + (iwscale - 30);
-    int32_t s =   tmu.shade.is0 +
-                 (tmu.shade.idsdy * ys) + (tmu.shade.idsdx * xs) +
-                 ((tmu.shade.idsdx + tmu.shade.idsdy)>>1);
-    int32_t t =   tmu.shade.it0 +
-                 (tmu.shade.idtdy * ys) + (tmu.shade.idtdx * xs) +
-                 ((tmu.shade.idtdx + tmu.shade.idtdy)>>1);
-    int32_t s0 = gglMulx(s, iw, iwscale);
-    int32_t t0 = gglMulx(t, iw, iwscale);
-    int32_t xl = c->iterators.xl;
-
-    int32_t sq, tq, dsdx, dtdx;
-    int32_t premainder = xc & ((1<<SPAN_BITS)-1);
-    uint32_t numSpans = xc >> SPAN_BITS;
-    if (c->shade.dwdx == 0) {
-        // XXX: we could choose to do this if the error is small enough
-        numSpans = 0;
-        premainder = xc;
-        goto no_perspective;
-    }
-
-    if (premainder) {
-        w += c->shade.dwdx   * premainder;
-        iw = gglRecipQ(w, 30);
-no_perspective:        
-        s += tmu.shade.idsdx * premainder;
-        t += tmu.shade.idtdx * premainder;
-        sq = gglMulx(s, iw, iwscale);
-        tq = gglMulx(t, iw, iwscale);
-        dsdx = (sq - s0) / premainder;
-        dtdx = (tq - t0) / premainder;
-        c->iterators.xl = xl;
-        c->iterators.xr = xl = xl + premainder;
-        goto finish;
-    }
-
-    while (numSpans--) {
-        w += c->shade.dwdx   << SPAN_BITS;
-        s += tmu.shade.idsdx << SPAN_BITS;
-        t += tmu.shade.idtdx << SPAN_BITS;
-        iw = gglRecipQ(w, 30);
-        sq = gglMulx(s, iw, iwscale);
-        tq = gglMulx(t, iw, iwscale);
-        dsdx = (sq - s0) >> SPAN_BITS;
-        dtdx = (tq - t0) >> SPAN_BITS;
-        c->iterators.xl = xl;
-        c->iterators.xr = xl = xl + (1<<SPAN_BITS);
-finish:
-        if (sscale >= 0) {
-            ti.ydsdy = s0   << sscale;
-            ti.dsdx  = dsdx << sscale;
-        } else {
-            ti.ydsdy = s0   >>-sscale;
-            ti.dsdx  = dsdx >>-sscale;
-        }
-        if (tscale >= 0) {
-            ti.ydtdy = t0   << tscale;
-            ti.dtdx  = dtdx << tscale;
-        } else {
-            ti.ydtdy = t0   >>-tscale;
-            ti.dtdx  = dtdx >>-tscale;
-        }
-        s0 = sq;
-        t0 = tq;
-        gen.dsdx = ti.dsdx;
-        gen.dtdx = ti.dtdx;
-        c->span(c);
-    }
-}
-
-// ----------------------------------------------------------------------------
-
-void scanline_col32cb16blend(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    union {
-        uint16_t* dst;
-        uint32_t* dst32;
-    };
-    dst = reinterpret_cast<uint16_t*>(cb->data) + (x+(cb->stride*y));
-
-#if ((ANDROID_CODEGEN >= ANDROID_CODEGEN_ASM) && defined(__arm__))
-#if defined(__ARM_HAVE_NEON) && BYTE_ORDER == LITTLE_ENDIAN
-    scanline_col32cb16blend_neon(dst, &(c->packed8888), ct);
-#else  // defined(__ARM_HAVE_NEON) && BYTE_ORDER == LITTLE_ENDIAN
-    scanline_col32cb16blend_arm(dst, GGL_RGBA_TO_HOST(c->packed8888), ct);
-#endif // defined(__ARM_HAVE_NEON) && BYTE_ORDER == LITTLE_ENDIAN
-#elif ((ANDROID_CODEGEN >= ANDROID_CODEGEN_ASM) && defined(__aarch64__))
-    scanline_col32cb16blend_arm64(dst, GGL_RGBA_TO_HOST(c->packed8888), ct);
-#elif ((ANDROID_CODEGEN >= ANDROID_CODEGEN_ASM) && (defined(__mips__) && defined(__LP64__)))
-    scanline_col32cb16blend_mips64(dst, GGL_RGBA_TO_HOST(c->packed8888), ct);
-#else
-    uint32_t s = GGL_RGBA_TO_HOST(c->packed8888);
-    int sA = (s>>24);
-    int f = 0x100 - (sA + (sA>>7));
-    while (ct--) {
-        uint16_t d = *dst;
-        int dR = (d>>11)&0x1f;
-        int dG = (d>>5)&0x3f;
-        int dB = (d)&0x1f;
-        int sR = (s >> (   3))&0x1F;
-        int sG = (s >> ( 8+2))&0x3F;
-        int sB = (s >> (16+3))&0x1F;
-        sR += (f*dR)>>8;
-        sG += (f*dG)>>8;
-        sB += (f*dB)>>8;
-        *dst++ = uint16_t((sR<<11)|(sG<<5)|sB);
-    }
-#endif
-
-}
-
-void scanline_t32cb16(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;    
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    union {
-        uint16_t* dst;
-        uint32_t* dst32;
-    };
-    dst = reinterpret_cast<uint16_t*>(cb->data) + (x+(cb->stride*y));
-
-    surface_t* tex = &(c->state.texture[0].surface);
-    const int32_t u = (c->state.texture[0].shade.is0>>16) + x;
-    const int32_t v = (c->state.texture[0].shade.it0>>16) + y;
-    uint32_t *src = reinterpret_cast<uint32_t*>(tex->data)+(u+(tex->stride*v));
-    uint32_t s, d;
-
-    if (ct==1 || uintptr_t(dst)&2) {
-last_one:
-        s = GGL_RGBA_TO_HOST( *src++ );
-        *dst++ = convertAbgr8888ToRgb565(s);
-        ct--;
-    }
-
-    while (ct >= 2) {
-#if BYTE_ORDER == BIG_ENDIAN
-        s = GGL_RGBA_TO_HOST( *src++ );
-        d = convertAbgr8888ToRgb565_hi16(s);
-
-        s = GGL_RGBA_TO_HOST( *src++ );
-        d |= convertAbgr8888ToRgb565(s);
-#else
-        s = GGL_RGBA_TO_HOST( *src++ );
-        d = convertAbgr8888ToRgb565(s);
-
-        s = GGL_RGBA_TO_HOST( *src++ );
-        d |= convertAbgr8888ToRgb565(s) << 16;
-#endif
-        *dst32++ = d;
-        ct -= 2;
-    }
-    
-    if (ct > 0) {
-        goto last_one;
-    }
-}
-
-void scanline_t32cb16blend(context_t* c)
-{
-#if ((ANDROID_CODEGEN >= ANDROID_CODEGEN_ASM) && (defined(__arm__) || defined(__aarch64__) || \
-    (defined(__mips__) && ((!defined(__LP64__) && __mips_isa_rev < 6) || defined(__LP64__)))))
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    uint16_t* dst = reinterpret_cast<uint16_t*>(cb->data) + (x+(cb->stride*y));
-
-    surface_t* tex = &(c->state.texture[0].surface);
-    const int32_t u = (c->state.texture[0].shade.is0>>16) + x;
-    const int32_t v = (c->state.texture[0].shade.it0>>16) + y;
-    uint32_t *src = reinterpret_cast<uint32_t*>(tex->data)+(u+(tex->stride*v));
-
-#ifdef __arm__
-    scanline_t32cb16blend_arm(dst, src, ct);
-#elif defined(__aarch64__)
-    scanline_t32cb16blend_arm64(dst, src, ct);
-#elif defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
-    scanline_t32cb16blend_mips(dst, src, ct);
-#elif defined(__mips__) && defined(__LP64__)
-    scanline_t32cb16blend_mips64(dst, src, ct);
-#endif
-#else
-    dst_iterator16  di(c);
-    horz_iterator32  hi(c);
-    blender_32to16  bl(c);
-    while (di.count--) {
-        uint32_t s = hi.get_pixel32();
-        bl.write(s, di.dst);
-        di.dst++;
-    }
-#endif
-}
-
-void scanline_t32cb16blend_srca(context_t* c)
-{
-    dst_iterator16  di(c);
-    horz_iterator32  hi(c);
-    blender_32to16_srcA  blender(c);
-
-    while (di.count--) {
-        uint32_t s = hi.get_pixel32();
-        blender.write(s,di.dst);
-        di.dst++;
-    }
-}
-
-void scanline_t16cb16blend_clamp_mod(context_t* c)
-{
-    const int a = c->iterators.ydady >> (GGL_COLOR_BITS-8);
-    if (a == 0) {
-        return;
-    }
-
-    if (a == 255) {
-        scanline_t16cb16_clamp(c);
-        return;
-    }
-
-    dst_iterator16  di(c);
-    blender_16to16_modulate  blender(c);
-    clamp_iterator  ci(c);
-
-    while (di.count--) {
-        uint16_t s = ci.get_pixel16();
-        blender.write(s, di.dst);
-        di.dst++;
-    }
-}
-
-void scanline_memcpy(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    const GGLFormat* fp = &(c->formats[cb->format]);
-    uint8_t* dst = reinterpret_cast<uint8_t*>(cb->data) +
-                            (x + (cb->stride * y)) * fp->size;
-
-    surface_t* tex = &(c->state.texture[0].surface);
-    const int32_t u = (c->state.texture[0].shade.is0>>16) + x;
-    const int32_t v = (c->state.texture[0].shade.it0>>16) + y;
-    uint8_t *src = reinterpret_cast<uint8_t*>(tex->data) +
-                            (u + (tex->stride * v)) * fp->size;
-
-    const size_t size = ct * fp->size;
-    memcpy(dst, src, size);
-}
-
-void scanline_memset8(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    uint8_t* dst = reinterpret_cast<uint8_t*>(cb->data) + (x+(cb->stride*y));
-    uint32_t packed = c->packed;
-    memset(dst, packed, ct);
-}
-
-void scanline_memset16(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    uint16_t* dst = reinterpret_cast<uint16_t*>(cb->data) + (x+(cb->stride*y));
-    uint32_t packed = c->packed;
-    android_memset16(dst, packed, ct*2);
-}
-
-void scanline_memset32(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    uint32_t* dst = reinterpret_cast<uint32_t*>(cb->data) + (x+(cb->stride*y));
-    uint32_t packed = GGL_HOST_TO_RGBA(c->packed);
-    android_memset32(dst, packed, ct*4);
-}
-
-void scanline_clear(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    const GGLFormat* fp = &(c->formats[cb->format]);
-    uint8_t* dst = reinterpret_cast<uint8_t*>(cb->data) +
-                            (x + (cb->stride * y)) * fp->size;
-    const size_t size = ct * fp->size;
-    memset(dst, 0, size);
-}
-
-void scanline_set(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    const GGLFormat* fp = &(c->formats[cb->format]);
-    uint8_t* dst = reinterpret_cast<uint8_t*>(cb->data) +
-                            (x + (cb->stride * y)) * fp->size;
-    const size_t size = ct * fp->size;
-    memset(dst, 0xFF, size);
-}
-
-void scanline_noop(context_t* /*c*/)
-{
-}
-
-void rect_generic(context_t* c, size_t yc)
-{
-    do {
-        c->scanline(c);
-        c->step_y(c);
-    } while (--yc);
-}
-
-void rect_memcpy(context_t* c, size_t yc)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    const GGLFormat* fp = &(c->formats[cb->format]);
-    uint8_t* dst = reinterpret_cast<uint8_t*>(cb->data) +
-                            (x + (cb->stride * y)) * fp->size;
-
-    surface_t* tex = &(c->state.texture[0].surface);
-    const int32_t u = (c->state.texture[0].shade.is0>>16) + x;
-    const int32_t v = (c->state.texture[0].shade.it0>>16) + y;
-    uint8_t *src = reinterpret_cast<uint8_t*>(tex->data) +
-                            (u + (tex->stride * v)) * fp->size;
-
-    if (cb->stride == tex->stride && ct == size_t(cb->stride)) {
-        memcpy(dst, src, ct * fp->size * yc);
-    } else {
-        const size_t size = ct * fp->size;
-        const size_t dbpr = cb->stride  * fp->size;
-        const size_t sbpr = tex->stride * fp->size;
-        do {
-            memcpy(dst, src, size);
-            dst += dbpr;
-            src += sbpr;        
-        } while (--yc);
-    }
-}
-// ----------------------------------------------------------------------------
-}; // namespace android
-
diff --git a/libpixelflinger/scanline.h b/libpixelflinger/scanline.h
deleted file mode 100644
index b6f4d37..0000000
--- a/libpixelflinger/scanline.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* libs/pixelflinger/scanline.h
-**
-** Copyright 2006, 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_SCANLINE_H
-#define ANDROID_SCANLINE_H
-
-#include <private/pixelflinger/ggl_context.h>
-
-namespace android {
-
-void ggl_init_scanline(context_t* c);
-void ggl_uninit_scanline(context_t* c);
-void ggl_pick_scanline(context_t* c);
-
-}; // namespace android
-
-#endif
diff --git a/libpixelflinger/t32cb16blend.S b/libpixelflinger/t32cb16blend.S
deleted file mode 100644
index 5e4995a..0000000
--- a/libpixelflinger/t32cb16blend.S
+++ /dev/null
@@ -1,203 +0,0 @@
-/* libs/pixelflinger/t32cb16blend.S
-**
-** Copyright 2006, 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.
-*/
-
-
-	.text
-	.syntax unified
-	.balign 4
-	
-	.global scanline_t32cb16blend_arm
-
-
-/*
- * .macro pixel
- *
- * \DREG is a 32-bit register containing *two* original destination RGB565 
- *       pixels, with the even one in the low-16 bits, and the odd one in the
- *       high 16 bits.
- *
- * \SRC is a 32-bit 0xAABBGGRR pixel value, with pre-multiplied colors.
- *
- * \FB is a target register that will contain the blended pixel values.
- *
- * \ODD is either 0 or 1 and indicates if we're blending the lower or 
- *      upper 16-bit pixels in DREG into FB
- *
- *
- * clobbered: r6, r7, lr
- *
- */
-
-.macro pixel,   DREG, SRC, FB, ODD
-
-    // SRC = 0xAABBGGRR
-    mov     r7, \SRC, lsr #24           // sA
-    add     r7, r7, r7, lsr #7          // sA + (sA >> 7)
-    rsb     r7, r7, #0x100              // sA = 0x100 - (sA+(sA>>7))
-
-1:
-
-.if \ODD
-
-    // red
-    mov     lr, \DREG, lsr #(16 + 11)
-    smulbb  lr, r7, lr
-    mov     r6, \SRC, lsr #3
-    and     r6, r6, #0x1F
-    add     lr, r6, lr, lsr #8
-    cmp     lr, #0x1F
-    orrhs   \FB, \FB, #(0x1F<<(16 + 11))
-    orrlo   \FB, \FB, lr, lsl #(16 + 11)
-
-        // green
-        and     r6, \DREG, #(0x3F<<(16 + 5))
-        smulbt  r6, r7, r6
-        mov     lr, \SRC, lsr #(8+2)
-        and     lr, lr, #0x3F
-        add     r6, lr, r6, lsr #(5+8)
-        cmp     r6, #0x3F
-        orrhs   \FB, \FB, #(0x3F<<(16 + 5))
-        orrlo   \FB, \FB, r6, lsl #(16 + 5)
-
-            // blue
-            and     lr, \DREG, #(0x1F << 16)
-            smulbt  lr, r7, lr
-            mov     r6, \SRC, lsr #(8+8+3)
-            and     r6, r6, #0x1F
-            add     lr, r6, lr, lsr #8
-            cmp     lr, #0x1F
-            orrhs   \FB, \FB, #(0x1F << 16)
-            orrlo   \FB, \FB, lr, lsl #16
-
-.else
-
-    // red
-    mov     lr, \DREG, lsr #11
-    and     lr, lr, #0x1F
-    smulbb  lr, r7, lr
-    mov     r6, \SRC, lsr #3
-    and     r6, r6, #0x1F
-    add     lr, r6, lr, lsr #8
-    cmp     lr, #0x1F
-    movhs   \FB, #(0x1F<<11)
-    movlo   \FB, lr, lsl #11
-
-
-        // green
-        and     r6, \DREG, #(0x3F<<5)
-        smulbb  r6, r7, r6
-        mov     lr, \SRC, lsr #(8+2)
-        and     lr, lr, #0x3F
-        add     r6, lr, r6, lsr #(5+8)
-        cmp     r6, #0x3F
-        orrhs   \FB, \FB, #(0x3F<<5)
-        orrlo   \FB, \FB, r6, lsl #5
-
-            // blue
-            and     lr, \DREG, #0x1F
-            smulbb  lr, r7, lr
-            mov     r6, \SRC, lsr #(8+8+3)
-            and     r6, r6, #0x1F
-            add     lr, r6, lr, lsr #8
-            cmp     lr, #0x1F
-            orrhs   \FB, \FB, #0x1F
-            orrlo   \FB, \FB, lr
-
-.endif
-
-    .endm
-    
-
-// r0:  dst ptr
-// r1:  src ptr
-// r2:  count
-// r3:  d
-// r4:  s0
-// r5:  s1
-// r6:  pixel
-// r7:  pixel
-// r8:  free
-// r9:  free
-// r10: free
-// r11: free
-// r12: scratch
-// r14: pixel
-
-scanline_t32cb16blend_arm:
-    stmfd	sp!, {r4-r7, lr}
-
-    pld     [r0]
-    pld     [r1]
-
-    // align DST to 32 bits
-    tst     r0, #0x3
-    beq     aligned
-    subs    r2, r2, #1
-    ldmfdlo sp!, {r4-r7, lr}        // return
-    bxlo    lr
-
-last:
-    ldr     r4, [r1], #4
-    ldrh    r3, [r0]
-    pixel   r3, r4, r12, 0
-    strh    r12, [r0], #2
-
-aligned:
-    subs    r2, r2, #2
-    blo     9f
-
-    // The main loop is unrolled twice and processes 4 pixels
-8:  ldmia   r1!, {r4, r5}
-    // stream the source
-    pld     [r1, #32]
-    add     r0, r0, #4
-    // it's all zero, skip this pixel
-    orrs    r3, r4, r5
-    beq     7f
-    
-    // load the destination
-    ldr     r3, [r0, #-4]
-    // stream the destination
-    pld     [r0, #32]
-    pixel   r3, r4, r12, 0
-    pixel   r3, r5, r12, 1
-    // effectively, we're getting write-combining by virtue of the
-    // cpu's write-back cache.
-    str     r12, [r0, #-4]
-
-    // 2nd iterration of the loop, don't stream anything
-    subs    r2, r2, #2
-    movlt   r4, r5
-    blt     9f
-    ldmia   r1!, {r4, r5}
-    add     r0, r0, #4
-    orrs    r3, r4, r5
-    beq     7f
-    ldr     r3, [r0, #-4]
-    pixel   r3, r4, r12, 0
-    pixel   r3, r5, r12, 16
-    str     r12, [r0, #-4]
-
-    
-7:  subs    r2, r2, #2
-    bhs     8b
-    mov     r4, r5
-
-9:  adds    r2, r2, #1
-    ldmfdlo sp!, {r4-r7, lr}        // return
-    bxlo    lr
-    b       last
diff --git a/libpixelflinger/tests/Android.bp b/libpixelflinger/tests/Android.bp
deleted file mode 100644
index e20dd93..0000000
--- a/libpixelflinger/tests/Android.bp
+++ /dev/null
@@ -1,17 +0,0 @@
-cc_defaults {
-    name: "pixelflinger-tests",
-
-    cflags: [
-        "-Wall",
-        "-Werror",
-    ],
-
-    header_libs: ["libpixelflinger_internal"],
-    static_libs: [
-        "libbase",
-        "libcutils",
-        "liblog",
-        "libpixelflinger",
-        "libutils",
-    ],
-}
diff --git a/libpixelflinger/tests/arch-arm64/Android.bp b/libpixelflinger/tests/arch-arm64/Android.bp
deleted file mode 100644
index 2f5586a..0000000
--- a/libpixelflinger/tests/arch-arm64/Android.bp
+++ /dev/null
@@ -1,11 +0,0 @@
-cc_defaults {
-    name: "pixelflinger-tests-arm64",
-    defaults: ["pixelflinger-tests"],
-
-    enabled: false,
-    arch: {
-        arm64: {
-            enabled: true,
-        },
-    },
-}
diff --git a/libpixelflinger/tests/arch-arm64/assembler/Android.bp b/libpixelflinger/tests/arch-arm64/assembler/Android.bp
deleted file mode 100644
index 003f485..0000000
--- a/libpixelflinger/tests/arch-arm64/assembler/Android.bp
+++ /dev/null
@@ -1,9 +0,0 @@
-cc_test {
-    name: "test-pixelflinger-arm64-assembler-test",
-    defaults: ["pixelflinger-tests-arm64"],
-
-    srcs: [
-        "arm64_assembler_test.cpp",
-        "asm_test_jacket.S",
-    ],
-}
diff --git a/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp b/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
deleted file mode 100644
index 63642c4..0000000
--- a/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
+++ /dev/null
@@ -1,782 +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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <sys/mman.h>
-#include <cutils/ashmem.h>
-
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
-
-#include "codeflinger/ARMAssemblerInterface.h"
-#include "codeflinger/Arm64Assembler.h"
-using namespace android;
-
-#define TESTS_DATAOP_ENABLE             1
-#define TESTS_DATATRANSFER_ENABLE       1
-#define TESTS_LDMSTM_ENABLE             1
-#define TESTS_REG_CORRUPTION_ENABLE     0
-
-void *instrMem;
-uint32_t  instrMemSize = 128 * 1024;
-char     dataMem[8192];
-
-typedef void (*asm_function_t)();
-extern "C" void asm_test_jacket(asm_function_t function,
-                                int64_t regs[], int32_t flags[]);
-
-#define MAX_32BIT (uint32_t)(((uint64_t)1 << 32) - 1)
-const uint32_t NA = 0;
-const uint32_t NUM_REGS = 32;
-const uint32_t NUM_FLAGS = 16;
-
-enum instr_t
-{
-    INSTR_ADD,
-    INSTR_SUB,
-    INSTR_AND,
-    INSTR_ORR,
-    INSTR_RSB,
-    INSTR_BIC,
-    INSTR_CMP,
-    INSTR_MOV,
-    INSTR_MVN,
-    INSTR_MUL,
-    INSTR_MLA,
-    INSTR_SMULBB,
-    INSTR_SMULBT,
-    INSTR_SMULTB,
-    INSTR_SMULTT,
-    INSTR_SMULWB,
-    INSTR_SMULWT,
-    INSTR_SMLABB,
-    INSTR_UXTB16,
-    INSTR_UBFX,
-    INSTR_ADDR_ADD,
-    INSTR_ADDR_SUB,
-    INSTR_LDR,
-    INSTR_LDRB,
-    INSTR_LDRH,
-    INSTR_ADDR_LDR,
-    INSTR_LDM,
-    INSTR_STR,
-    INSTR_STRB,
-    INSTR_STRH,
-    INSTR_ADDR_STR,
-    INSTR_STM
-};
-
-enum shift_t
-{
-    SHIFT_LSL,
-    SHIFT_LSR,
-    SHIFT_ASR,
-    SHIFT_ROR,
-    SHIFT_NONE
-};
-
-enum offset_t
-{
-    REG_SCALE_OFFSET,
-    REG_OFFSET,
-    IMM8_OFFSET,
-    IMM12_OFFSET,
-    NO_OFFSET
-};
-
-enum cond_t
-{
-    EQ, NE, CS, CC, MI, PL, VS, VC, HI, LS, GE, LT, GT, LE, AL, NV,
-    HS = CS,
-    LO = CC
-};
-
-const char * cc_code[] =
-{
-    "EQ", "NE", "CS", "CC", "MI", "PL", "VS", "VC",
-    "HI", "LS","GE","LT", "GT", "LE", "AL", "NV"
-};
-
-
-struct dataOpTest_t
-{
-    uint32_t id;
-    instr_t  op;
-    uint32_t preFlag;
-    cond_t   cond;
-    bool     setFlags;
-    uint64_t RnValue;
-    uint64_t RsValue;
-    bool     immediate;
-    uint32_t immValue;
-    uint64_t RmValue;
-    uint32_t shiftMode;
-    uint32_t shiftAmount;
-    uint64_t RdValue;
-    bool     checkRd;
-    uint64_t postRdValue;
-    bool     checkFlag;
-    uint32_t postFlag;
-};
-
-struct dataTransferTest_t
-{
-    uint32_t id;
-    instr_t op;
-    uint32_t preFlag;
-    cond_t   cond;
-    bool     setMem;
-    uint64_t memOffset;
-    uint64_t memValue;
-    uint64_t RnValue;
-    offset_t offsetType;
-    uint64_t RmValue;
-    uint32_t immValue;
-    bool     writeBack;
-    bool     preIndex;
-    bool     postIndex;
-    uint64_t RdValue;
-    uint64_t postRdValue;
-    uint64_t postRnValue;
-    bool     checkMem;
-    uint64_t postMemOffset;
-    uint32_t postMemLength;
-    uint64_t postMemValue;
-};
-
-
-dataOpTest_t dataOpTests [] =
-{
-     {0xA000,INSTR_ADD,AL,AL,0,1,NA,1,MAX_32BIT ,NA,NA,NA,NA,1,0,0,0},
-     {0xA001,INSTR_ADD,AL,AL,0,1,NA,1,MAX_32BIT -1,NA,NA,NA,NA,1,MAX_32BIT,0,0},
-     {0xA002,INSTR_ADD,AL,AL,0,1,NA,0,NA,MAX_32BIT ,NA,NA,NA,1,0,0,0},
-     {0xA003,INSTR_ADD,AL,AL,0,1,NA,0,NA,MAX_32BIT -1,NA,NA,NA,1,MAX_32BIT,0,0},
-     {0xA004,INSTR_ADD,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSL,0,NA,1,0,0,0},
-     {0xA005,INSTR_ADD,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSL,31,NA,1,0x80000001,0,0},
-     {0xA006,INSTR_ADD,AL,AL,0,1,NA,0,0,3,SHIFT_LSR,1,NA,1,2,0,0},
-     {0xA007,INSTR_ADD,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSR,31,NA,1,2,0,0},
-     {0xA008,INSTR_ADD,AL,AL,0,0,NA,0,0,3,SHIFT_ASR,1,NA,1,1,0,0},
-     {0xA009,INSTR_ADD,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_ASR,31,NA,1,0,0,0},
-     {0xA010,INSTR_AND,AL,AL,0,1,NA,1,MAX_32BIT ,0,0,0,NA,1,1,0,0},
-     {0xA011,INSTR_AND,AL,AL,0,1,NA,1,MAX_32BIT -1,0,0,0,NA,1,0,0,0},
-     {0xA012,INSTR_AND,AL,AL,0,1,NA,0,0,MAX_32BIT ,0,0,NA,1,1,0,0},
-     {0xA013,INSTR_AND,AL,AL,0,1,NA,0,0,MAX_32BIT -1,0,0,NA,1,0,0,0},
-     {0xA014,INSTR_AND,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSL,0,NA,1,1,0,0},
-     {0xA015,INSTR_AND,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSL,31,NA,1,0,0,0},
-     {0xA016,INSTR_AND,AL,AL,0,1,NA,0,0,3,SHIFT_LSR,1,NA,1,1,0,0},
-     {0xA017,INSTR_AND,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSR,31,NA,1,1,0,0},
-     {0xA018,INSTR_AND,AL,AL,0,0,NA,0,0,3,SHIFT_ASR,1,NA,1,0,0,0},
-     {0xA019,INSTR_AND,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_ASR,31,NA,1,1,0,0},
-     {0xA020,INSTR_ORR,AL,AL,0,3,NA,1,MAX_32BIT ,0,0,0,NA,1,MAX_32BIT,0,0},
-     {0xA021,INSTR_ORR,AL,AL,0,2,NA,1,MAX_32BIT -1,0,0,0,NA,1,MAX_32BIT-1,0,0},
-     {0xA022,INSTR_ORR,AL,AL,0,3,NA,0,0,MAX_32BIT ,0,0,NA,1,MAX_32BIT,0,0},
-     {0xA023,INSTR_ORR,AL,AL,0,2,NA,0,0,MAX_32BIT -1,0,0,NA,1,MAX_32BIT-1,0,0},
-     {0xA024,INSTR_ORR,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSL,0,NA,1,MAX_32BIT,0,0},
-     {0xA025,INSTR_ORR,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_LSL,31,NA,1,0x80000001,0,0},
-     {0xA026,INSTR_ORR,AL,AL,0,1,NA,0,0,3,SHIFT_LSR,1,NA,1,1,0,0},
-     {0xA027,INSTR_ORR,AL,AL,0,0,NA,0,0,MAX_32BIT ,SHIFT_LSR,31,NA,1,1,0,0},
-     {0xA028,INSTR_ORR,AL,AL,0,0,NA,0,0,3,SHIFT_ASR,1,NA,1,1,0,0},
-     {0xA029,INSTR_ORR,AL,AL,0,1,NA,0,0,MAX_32BIT ,SHIFT_ASR,31,NA,1,MAX_32BIT ,0,0},
-     {0xA030,INSTR_CMP,AL,AL,1,0x10000,NA,1,0x10000,0,0,0,NA,0,0,1,HS},
-     {0xA031,INSTR_CMP,AL,AL,1,0x00000,NA,1,0x10000,0,0,0,NA,0,0,1,CC},
-     {0xA032,INSTR_CMP,AL,AL,1,0x00000,NA,0,0,0x10000,0,0,NA,0,0,1,LT},
-     {0xA033,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x10000,0,0,NA,0,0,1,EQ},
-     {0xA034,INSTR_CMP,AL,AL,1,0x00000,NA,0,0,0x10000,0,0,NA,0,0,1,LS},
-     {0xA035,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x10000,0,0,NA,0,0,1,LS},
-     {0xA036,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x00000,0,0,NA,0,0,1,HI},
-     {0xA037,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x10000,0,0,NA,0,0,1,HS},
-     {0xA038,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x00000,0,0,NA,0,0,1,HS},
-     {0xA039,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x00000,0,0,NA,0,0,1,NE},
-     {0xA040,INSTR_CMP,AL,AL,1,0,NA,0,0,MAX_32BIT ,SHIFT_LSR,1,NA,0,0,1,LT},
-     {0xA041,INSTR_CMP,AL,AL,1,1,NA,0,0,MAX_32BIT ,SHIFT_LSR,31,NA,0,0,1,EQ},
-     {0xA042,INSTR_CMP,AL,AL,1,0,NA,0,0,0x10000,SHIFT_LSR,31,NA,0,0,1,LS},
-     {0xA043,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x30000,SHIFT_LSR,1,NA,0,0,1,LS},
-     {0xA044,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x00000,SHIFT_LSR,31,NA,0,0,1,HI},
-     {0xA045,INSTR_CMP,AL,AL,1,1,NA,0,0,MAX_32BIT ,SHIFT_LSR,31,NA,0,0,1,HS},
-     {0xA046,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x2000,SHIFT_LSR,1,NA,0,0,1,HS},
-     {0xA047,INSTR_CMP,AL,AL,1,0,NA,0,0,MAX_32BIT ,SHIFT_LSR,1,NA,0,0,1,NE},
-     {0xA048,INSTR_CMP,AL,AL,1,0,NA,0,0,0x10000,SHIFT_ASR,2,NA,0,0,1,LT},
-     {0xA049,INSTR_CMP,AL,AL,1,MAX_32BIT ,NA,0,0,MAX_32BIT ,SHIFT_ASR,1,NA,0,0,1,EQ},
-     {0xA050,INSTR_CMP,AL,AL,1,MAX_32BIT ,NA,0,0,MAX_32BIT ,SHIFT_ASR,31,NA,0,0,1,LS},
-     {0xA051,INSTR_CMP,AL,AL,1,0,NA,0,0,0x10000,SHIFT_ASR,1,NA,0,0,1,LS},
-     {0xA052,INSTR_CMP,AL,AL,1,0x10000,NA,0,0,0x10000,SHIFT_ASR,1,NA,0,0,1,HI},
-     {0xA053,INSTR_CMP,AL,AL,1,1,NA,0,0,0x10000,SHIFT_ASR,31,NA,0,0,1,HS},
-     {0xA054,INSTR_CMP,AL,AL,1,1,NA,0,0,0x10000,SHIFT_ASR,16,NA,0,0,1,HS},
-     {0xA055,INSTR_CMP,AL,AL,1,1,NA,0,0,MAX_32BIT ,SHIFT_ASR,1,NA,0,0,1,NE},
-     {0xA056,INSTR_MUL,AL,AL,0,0,0x10000,0,0,0x10000,0,0,NA,1,0,0,0},
-     {0xA057,INSTR_MUL,AL,AL,0,0,0x1000,0,0,0x10000,0,0,NA,1,0x10000000,0,0},
-     {0xA058,INSTR_MUL,AL,AL,0,0,MAX_32BIT ,0,0,1,0,0,NA,1,MAX_32BIT ,0,0},
-     {0xA059,INSTR_MLA,AL,AL,0,0x10000,0x10000,0,0,0x10000,0,0,NA,1,0x10000,0,0},
-     {0xA060,INSTR_MLA,AL,AL,0,0x10000,0x1000,0,0,0x10000,0,0,NA,1,0x10010000,0,0},
-     {0xA061,INSTR_MLA,AL,AL,1,1,MAX_32BIT ,0,0,1,0,0,NA,1,0,1,PL},
-     {0xA062,INSTR_MLA,AL,AL,1,0,MAX_32BIT ,0,0,1,0,0,NA,1,MAX_32BIT ,1,MI},
-     {0xA063,INSTR_SUB,AL,AL,1,1 << 16,NA,1,1 << 16,NA,NA,NA,NA,1,0,1,PL},
-     {0xA064,INSTR_SUB,AL,AL,1,(1 << 16) + 1,NA,1,1 << 16,NA,NA,NA,NA,1,1,1,PL},
-     {0xA065,INSTR_SUB,AL,AL,1,0,NA,1,1 << 16,NA,NA,NA,NA,1,(uint32_t)(0 - (1<<16)),1,MI},
-     {0xA066,INSTR_SUB,MI,MI,0,2,NA,0,NA,1,NA,NA,2,1,1,0,NA},
-     {0xA067,INSTR_SUB,EQ,MI,0,2,NA,0,NA,1,NA,NA,2,1,2,0,NA},
-     {0xA068,INSTR_SUB,GT,GE,0,2,NA,1,1,NA,NA,NA,2,1,1,0,NA},
-     {0xA069,INSTR_SUB,LT,GE,0,2,NA,1,1,NA,NA,NA,2,1,2,0,NA},
-     {0xA070,INSTR_SUB,CS,HS,0,2,NA,1,1,NA,NA,NA,2,1,1,0,NA},
-     {0xA071,INSTR_SUB,CC,HS,0,2,NA,1,1,NA,NA,NA,2,1,2,0,NA},
-     {0xA072,INSTR_SUB,AL,AL,0,1,NA,1,1 << 16,0,0,0,NA,1,(uint32_t)(1 - (1 << 16)),0,NA},
-     {0xA073,INSTR_SUB,AL,AL,0,MAX_32BIT,NA,1,1,0,0,0,NA,1,MAX_32BIT  - 1,0,NA},
-     {0xA074,INSTR_SUB,AL,AL,0,1,NA,1,1,0,0,0,NA,1,0,0,NA},
-     {0xA075,INSTR_SUB,AL,AL,0,1,NA,0,NA,1 << 16,0,0,NA,1,(uint32_t)(1 - (1 << 16)),0,NA},
-     {0xA076,INSTR_SUB,AL,AL,0,MAX_32BIT,NA,0,NA,1,0,0,NA,1,MAX_32BIT  - 1,0,NA},
-     {0xA077,INSTR_SUB,AL,AL,0,1,NA,0,NA,1,0,0,NA,1,0,0,NA},
-     {0xA078,INSTR_SUB,AL,AL,0,1,NA,0,NA,1,SHIFT_LSL,16,NA,1,(uint32_t)(1 - (1 << 16)),0,NA},
-     {0xA079,INSTR_SUB,AL,AL,0,0x80000001,NA,0,NA,MAX_32BIT ,SHIFT_LSL,31,NA,1,1,0,NA},
-     {0xA080,INSTR_SUB,AL,AL,0,1,NA,0,NA,3,SHIFT_LSR,1,NA,1,0,0,NA},
-     {0xA081,INSTR_SUB,AL,AL,0,1,NA,0,NA,MAX_32BIT ,SHIFT_LSR,31,NA,1,0,0,NA},
-     {0xA082,INSTR_RSB,GT,GE,0,2,NA,1,0,NA,NA,NA,2,1,(uint32_t)-2,0,NA},
-     {0xA083,INSTR_RSB,LT,GE,0,2,NA,1,0,NA,NA,NA,2,1,2,0,NA},
-     {0xA084,INSTR_RSB,AL,AL,0,1,NA,1,1 << 16,NA,NA,NA,NA,1,(1 << 16) - 1,0,NA},
-     {0xA085,INSTR_RSB,AL,AL,0,MAX_32BIT,NA,1,1,NA,NA,NA,NA,1,(uint32_t) (1 - MAX_32BIT),0,NA},
-     {0xA086,INSTR_RSB,AL,AL,0,1,NA,1,1,NA,NA,NA,NA,1,0,0,NA},
-     {0xA087,INSTR_RSB,AL,AL,0,1,NA,0,NA,1 << 16,0,0,NA,1,(1 << 16) - 1,0,NA},
-     {0xA088,INSTR_RSB,AL,AL,0,MAX_32BIT,NA,0,NA,1,0,0,NA,1,(uint32_t) (1 - MAX_32BIT),0,NA},
-     {0xA089,INSTR_RSB,AL,AL,0,1,NA,0,NA,1,0,0,NA,1,0,0,NA},
-     {0xA090,INSTR_RSB,AL,AL,0,1,NA,0,NA,1,SHIFT_LSL,16,NA,1,(1 << 16) - 1,0,NA},
-     {0xA091,INSTR_RSB,AL,AL,0,0x80000001,NA,0,NA,MAX_32BIT ,SHIFT_LSL,31,NA,1,(uint32_t)-1,0,NA},
-     {0xA092,INSTR_RSB,AL,AL,0,1,NA,0,NA,3,SHIFT_LSR,1,NA,1,0,0,NA},
-     {0xA093,INSTR_RSB,AL,AL,0,1,NA,0,NA,MAX_32BIT ,SHIFT_LSR,31,NA,1,0,0,NA},
-     {0xA094,INSTR_MOV,AL,AL,0,NA,NA,1,0x80000001,NA,NA,NA,NA,1,0x80000001,0,0},
-     {0xA095,INSTR_MOV,AL,AL,0,NA,NA,0,0,0x80000001,0,0,NA,1,0x80000001,0,0},
-     {0xA096,INSTR_MOV,AL,AL,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,1,NA,1,MAX_32BIT -1,0,0},
-     {0xA097,INSTR_MOV,AL,AL,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,31,NA,1,0x80000000,0,0},
-     {0xA098,INSTR_MOV,AL,AL,0,NA,NA,0,0,3,SHIFT_LSR,1,NA,1,1,0,0},
-     {0xA099,INSTR_MOV,AL,AL,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSR,31,NA,1,1,0,0},
-     {0xA100,INSTR_MOV,AL,AL,0,NA,NA,0,0,3,SHIFT_ASR,1,NA,1,1,0,0},
-     {0xA101,INSTR_MOV,AL,AL,0,NA,NA,0,0,MAX_32BIT ,SHIFT_ASR,31,NA,1,MAX_32BIT ,0,0},
-     {0xA102,INSTR_MOV,AL,AL,0,NA,NA,0,0,3,SHIFT_ROR,1,NA,1,0x80000001,0,0},
-     {0xA103,INSTR_MOV,AL,AL,0,NA,NA,0,0,0x80000001,SHIFT_ROR,31,NA,1,3,0,0},
-     {0xA104,INSTR_MOV,AL,AL,1,NA,NA,0,0,MAX_32BIT -1,SHIFT_ASR,1,NA,1,MAX_32BIT,1,MI},
-     {0xA105,INSTR_MOV,AL,AL,1,NA,NA,0,0,3,SHIFT_ASR,1,NA,1,1,1,PL},
-     {0xA106,INSTR_MOV,PL,MI,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,2,0,0},
-     {0xA107,INSTR_MOV,MI,MI,0,NA,NA,0,0,0x80000001,0,0,2,1,0x80000001,0,0},
-     {0xA108,INSTR_MOV,EQ,LT,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,2,0,0},
-     {0xA109,INSTR_MOV,LT,LT,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,0x80000001,0,0},
-     {0xA110,INSTR_MOV,GT,GE,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,1,2,1,MAX_32BIT -1,0,0},
-     {0xA111,INSTR_MOV,EQ,GE,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,31,2,1,0x80000000,0,0},
-     {0xA112,INSTR_MOV,LT,GE,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,31,2,1,2,0,0},
-     {0xA113,INSTR_MOV,GT,LE,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,1,2,1,2,0,0},
-     {0xA114,INSTR_MOV,EQ,LE,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,0x80000001,0,0},
-     {0xA115,INSTR_MOV,LT,LE,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,31,2,1,0x80000000,0,0},
-     {0xA116,INSTR_MOV,EQ,GT,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,2,0,0},
-     {0xA117,INSTR_MOV,GT,GT,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,0x80000001,0,0},
-     {0xA118,INSTR_MOV,LE,GT,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,2,0,0},
-     {0xA119,INSTR_MOV,EQ,GT,0,NA,NA,0,0,0x80000001,0,0,2,1,2,0,0},
-     {0xA120,INSTR_MOV,GT,GT,0,NA,NA,0,0,0x80000001,0,0,2,1,0x80000001,0,0},
-     {0xA121,INSTR_MOV,LE,GT,0,NA,NA,0,0,0x80000001,0,0,2,1,2,0,0},
-     {0xA122,INSTR_MOV,EQ,GT,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,1,2,1,2,0,0},
-     {0xA123,INSTR_MOV,GT,GT,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,1,2,1,MAX_32BIT -1,0,0},
-     {0xA124,INSTR_MOV,LE,GT,0,NA,NA,0,0,MAX_32BIT ,SHIFT_LSL,1,2,1,2,0,0},
-     {0xA125,INSTR_MOV,LO,HS,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,2,0,0},
-     {0xA126,INSTR_MOV,HS,HS,0,NA,NA,1,0x80000001,NA,NA,NA,2,1,0x80000001,0,0},
-     {0xA127,INSTR_MVN,LO,HS,0,NA,NA,1,MAX_32BIT -1,NA,NA,NA,2,1,2,0,0},
-     {0xA128,INSTR_MVN,HS,HS,0,NA,NA,1,MAX_32BIT -1,NA,NA,NA,2,1,1,0,0},
-     {0xA129,INSTR_MVN,AL,AL,0,NA,NA,1,0,NA,NA,NA,2,1,MAX_32BIT,0,NA},
-     {0xA130,INSTR_MVN,AL,AL,0,NA,NA,0,NA,MAX_32BIT -1,NA,0,2,1,1,0,NA},
-     {0xA131,INSTR_MVN,AL,AL,0,NA,NA,0,NA,0x80000001,NA,0,2,1,0x7FFFFFFE,0,NA},
-     {0xA132,INSTR_BIC,AL,AL,0,1,NA,1,MAX_32BIT ,NA,NA,NA,NA,1,0,0,0},
-     {0xA133,INSTR_BIC,AL,AL,0,1,NA,1,MAX_32BIT -1,NA,NA,NA,NA,1,1,0,0},
-     {0xA134,INSTR_BIC,AL,AL,0,1,NA,0,0,MAX_32BIT ,0,0,NA,1,0,0,0},
-     {0xA135,INSTR_BIC,AL,AL,0,1,NA,0,0,MAX_32BIT -1,0,0,NA,1,1,0,0},
-     {0xA136,INSTR_BIC,AL,AL,0,0xF0,NA,0,0,3,SHIFT_ASR,1,NA,1,0xF0,0,0},
-     {0xA137,INSTR_BIC,AL,AL,0,0xF0,NA,0,0,MAX_32BIT ,SHIFT_ASR,31,NA,1,0,0,0},
-     {0xA138,INSTR_SMULBB,AL,AL,0,NA,0xABCDFFFF,0,NA,0xABCD0001,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA139,INSTR_SMULBB,AL,AL,0,NA,0xABCD0001,0,NA,0xABCD0FFF,NA,NA,NA,1,0x00000FFF,0,0},
-     {0xA140,INSTR_SMULBB,AL,AL,0,NA,0xABCD0001,0,NA,0xABCDFFFF,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA141,INSTR_SMULBB,AL,AL,0,NA,0xABCDFFFF,0,NA,0xABCDFFFF,NA,NA,NA,1,1,0,0},
-     {0xA142,INSTR_SMULBT,AL,AL,0,NA,0xFFFFABCD,0,NA,0xABCD0001,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA143,INSTR_SMULBT,AL,AL,0,NA,0x0001ABCD,0,NA,0xABCD0FFF,NA,NA,NA,1,0x00000FFF,0,0},
-     {0xA144,INSTR_SMULBT,AL,AL,0,NA,0x0001ABCD,0,NA,0xABCDFFFF,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA145,INSTR_SMULBT,AL,AL,0,NA,0xFFFFABCD,0,NA,0xABCDFFFF,NA,NA,NA,1,1,0,0},
-     {0xA146,INSTR_SMULTB,AL,AL,0,NA,0xABCDFFFF,0,NA,0x0001ABCD,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA147,INSTR_SMULTB,AL,AL,0,NA,0xABCD0001,0,NA,0x0FFFABCD,NA,NA,NA,1,0x00000FFF,0,0},
-     {0xA148,INSTR_SMULTB,AL,AL,0,NA,0xABCD0001,0,NA,0xFFFFABCD,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA149,INSTR_SMULTB,AL,AL,0,NA,0xABCDFFFF,0,NA,0xFFFFABCD,NA,NA,NA,1,1,0,0},
-     {0xA150,INSTR_SMULTT,AL,AL,0,NA,0xFFFFABCD,0,NA,0x0001ABCD,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA151,INSTR_SMULTT,AL,AL,0,NA,0x0001ABCD,0,NA,0x0FFFABCD,NA,NA,NA,1,0x00000FFF,0,0},
-     {0xA152,INSTR_SMULTT,AL,AL,0,NA,0x0001ABCD,0,NA,0xFFFFABCD,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA153,INSTR_SMULTT,AL,AL,0,NA,0xFFFFABCD,0,NA,0xFFFFABCD,NA,NA,NA,1,1,0,0},
-     {0xA154,INSTR_SMULWB,AL,AL,0,NA,0xABCDFFFF,0,NA,0x0001ABCD,NA,NA,NA,1,0xFFFFFFFE,0,0},
-     {0xA155,INSTR_SMULWB,AL,AL,0,NA,0xABCD0001,0,NA,0x0FFFABCD,NA,NA,NA,1,0x00000FFF,0,0},
-     {0xA156,INSTR_SMULWB,AL,AL,0,NA,0xABCD0001,0,NA,0xFFFFABCD,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA157,INSTR_SMULWB,AL,AL,0,NA,0xABCDFFFF,0,NA,0xFFFFABCD,NA,NA,NA,1,0,0,0},
-     {0xA158,INSTR_SMULWT,AL,AL,0,NA,0xFFFFABCD,0,NA,0x0001ABCD,NA,NA,NA,1,0xFFFFFFFE,0,0},
-     {0xA159,INSTR_SMULWT,AL,AL,0,NA,0x0001ABCD,0,NA,0x0FFFABCD,NA,NA,NA,1,0x00000FFF,0,0},
-     {0xA160,INSTR_SMULWT,AL,AL,0,NA,0x0001ABCD,0,NA,0xFFFFABCD,NA,NA,NA,1,0xFFFFFFFF,0,0},
-     {0xA161,INSTR_SMULWT,AL,AL,0,NA,0xFFFFABCD,0,NA,0xFFFFABCD,NA,NA,NA,1,0,0,0},
-     {0xA162,INSTR_SMLABB,AL,AL,0,1,0xABCDFFFF,0,NA,0xABCD0001,NA,NA,NA,1,0,0,0},
-     {0xA163,INSTR_SMLABB,AL,AL,0,1,0xABCD0001,0,NA,0xABCD0FFF,NA,NA,NA,1,0x00001000,0,0},
-     {0xA164,INSTR_SMLABB,AL,AL,0,0xFFFFFFFF,0xABCD0001,0,NA,0xABCDFFFF,NA,NA,NA,1,0xFFFFFFFE,0,0},
-     {0xA165,INSTR_SMLABB,AL,AL,0,0xFFFFFFFF,0xABCDFFFF,0,NA,0xABCDFFFF,NA,NA,NA,1,0,0,0},
-     {0xA166,INSTR_UXTB16,AL,AL,0,NA,NA,0,NA,0xABCDEF01,SHIFT_ROR,0,NA,1,0x00CD0001,0,0},
-     {0xA167,INSTR_UXTB16,AL,AL,0,NA,NA,0,NA,0xABCDEF01,SHIFT_ROR,1,NA,1,0x00AB00EF,0,0},
-     {0xA168,INSTR_UXTB16,AL,AL,0,NA,NA,0,NA,0xABCDEF01,SHIFT_ROR,2,NA,1,0x000100CD,0,0},
-     {0xA169,INSTR_UXTB16,AL,AL,0,NA,NA,0,NA,0xABCDEF01,SHIFT_ROR,3,NA,1,0x00EF00AB,0,0},
-     {0xA170,INSTR_UBFX,AL,AL,0,0xABCDEF01,4,0,NA,24,NA,NA,NA,1,0x00BCDEF0,0,0},
-     {0xA171,INSTR_UBFX,AL,AL,0,0xABCDEF01,1,0,NA,2,NA,NA,NA,1,0,0,0},
-     {0xA172,INSTR_UBFX,AL,AL,0,0xABCDEF01,16,0,NA,8,NA,NA,NA,1,0xCD,0,0},
-     {0xA173,INSTR_UBFX,AL,AL,0,0xABCDEF01,31,0,NA,1,NA,NA,NA,1,1,0,0},
-     {0xA174,INSTR_ADDR_ADD,AL,AL,0,0xCFFFFFFFF,NA,0,NA,0x1,SHIFT_LSL,1,NA,1,0xD00000001,0,0},
-     {0xA175,INSTR_ADDR_ADD,AL,AL,0,0x01,NA,0,NA,0x1,SHIFT_LSL,2,NA,1,0x5,0,0},
-     {0xA176,INSTR_ADDR_ADD,AL,AL,0,0xCFFFFFFFF,NA,0,NA,0x1,NA,0,NA,1,0xD00000000,0,0},
-     {0xA177,INSTR_ADDR_SUB,AL,AL,0,0xD00000001,NA,0,NA,0x010000,SHIFT_LSR,15,NA,1,0xCFFFFFFFF,0,0},
-     {0xA178,INSTR_ADDR_SUB,AL,AL,0,0xCFFFFFFFF,NA,0,NA,0x020000,SHIFT_LSR,15,NA,1,0xCFFFFFFFB,0,0},
-     {0xA179,INSTR_ADDR_SUB,AL,AL,0,3,NA,0,NA,0x010000,SHIFT_LSR,15,NA,1,1,0,0},
-};
-
-dataTransferTest_t dataTransferTests [] =
-{
-    {0xB000,INSTR_LDR,AL,AL,1,24,0xABCDEF0123456789,0,REG_SCALE_OFFSET,24,NA,NA,NA,NA,NA,0x23456789,0,0,NA,NA,NA},
-    {0xB001,INSTR_LDR,AL,AL,1,4064,0xABCDEF0123456789,0,IMM12_OFFSET,NA,4068,0,1,0,NA,0xABCDEF01,0,0,NA,NA,NA},
-    {0xB002,INSTR_LDR,AL,AL,1,0,0xABCDEF0123456789,0,IMM12_OFFSET,NA,4,1,0,1,NA,0x23456789,4,0,NA,NA,NA},
-    {0xB003,INSTR_LDR,AL,AL,1,0,0xABCDEF0123456789,0,NO_OFFSET,NA,NA,0,0,0,NA,0x23456789,0,0,NA,NA,NA},
-    {0xB004,INSTR_LDRB,AL,AL,1,4064,0xABCDEF0123456789,0,REG_SCALE_OFFSET,4064,NA,NA,NA,NA,NA,0x89,0,0,NA,NA,NA},
-    {0xB005,INSTR_LDRB,AL,AL,1,4064,0xABCDEF0123456789,0,IMM12_OFFSET,NA,4065,0,1,0,NA,0x67,0,0,NA,NA,NA},
-    {0xB006,INSTR_LDRB,AL,AL,1,4064,0xABCDEF0123456789,4065,IMM12_OFFSET,NA,0,0,1,0,NA,0x67,4065,0,NA,NA,NA},
-    {0xB007,INSTR_LDRB,AL,AL,1,4064,0xABCDEF0123456789,4065,IMM12_OFFSET,NA,1,0,1,0,NA,0x45,4065,0,NA,NA,NA},
-    {0xB008,INSTR_LDRB,AL,AL,1,4064,0xABCDEF0123456789,4065,IMM12_OFFSET,NA,2,0,1,0,NA,0x23,4065,0,NA,NA,NA},
-    {0xB009,INSTR_LDRB,AL,AL,1,4064,0xABCDEF0123456789,4065,IMM12_OFFSET,NA,1,1,0,1,NA,0x67,4066,0,NA,NA,NA},
-    {0xB010,INSTR_LDRB,AL,AL,1,4064,0xABCDEF0123456789,0,NO_OFFSET,NA,NA,0,0,0,NA,0x89,0,0,NA,NA,NA},
-    {0xB011,INSTR_LDRH,AL,AL,1,0,0xABCDEF0123456789,0,IMM8_OFFSET,NA,2,1,0,1,NA,0x6789,2,0,NA,NA,NA},
-    {0xB012,INSTR_LDRH,AL,AL,1,4064,0xABCDEF0123456789,0,REG_OFFSET,4064,0,0,1,0,NA,0x6789,0,0,NA,NA,NA},
-    {0xB013,INSTR_LDRH,AL,AL,1,4064,0xABCDEF0123456789,0,REG_OFFSET,4066,0,0,1,0,NA,0x2345,0,0,NA,NA,NA},
-    {0xB014,INSTR_LDRH,AL,AL,1,0,0xABCDEF0123456789,0,NO_OFFSET,NA,0,0,0,0,NA,0x6789,0,0,NA,NA,NA},
-    {0xB015,INSTR_LDRH,AL,AL,1,0,0xABCDEF0123456789,2,NO_OFFSET,NA,0,0,0,0,NA,0x2345,2,0,NA,NA,NA},
-    {0xB016,INSTR_ADDR_LDR,AL,AL,1,4064,0xABCDEF0123456789,0,IMM12_OFFSET,NA,4064,0,1,0,NA,0xABCDEF0123456789,0,0,NA,NA,NA},
-    {0xB017,INSTR_STR,AL,AL,1,2,0xDEADBEEFDEADBEEF,4,IMM12_OFFSET,NA,4,1,0,1,0xABCDEF0123456789,0xABCDEF0123456789,8,1,2,8,0xDEAD23456789BEEF},
-    {0xB018,INSTR_STR,AL,AL,1,2,0xDEADBEEFDEADBEEF,4,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4,1,2,8,0xDEAD23456789BEEF},
-    {0xB019,INSTR_STR,AL,AL,1,4066,0xDEADBEEFDEADBEEF,4,IMM12_OFFSET,NA,4064,0,1,0,0xABCDEF0123456789,0xABCDEF0123456789,4,1,4066,8,0xDEAD23456789BEEF},
-    {0xB020,INSTR_STRB,AL,AL,1,0,0xDEADBEEFDEADBEEF,1,IMM12_OFFSET,NA,0,0,1,0,0xABCDEF0123456789,0xABCDEF0123456789,1,1,0,8,0xDEADBEEFDEAD89EF},
-    {0xB021,INSTR_STRB,AL,AL,1,0,0xDEADBEEFDEADBEEF,1,IMM12_OFFSET,NA,1,0,1,0,0xABCDEF0123456789,0xABCDEF0123456789,1,1,0,8,0xDEADBEEFDE89BEEF},
-    {0xB022,INSTR_STRB,AL,AL,1,0,0xDEADBEEFDEADBEEF,1,IMM12_OFFSET,NA,2,0,1,0,0xABCDEF0123456789,0xABCDEF0123456789,1,1,0,8,0xDEADBEEF89ADBEEF},
-    {0xB023,INSTR_STRB,AL,AL,1,0,0xDEADBEEFDEADBEEF,1,IMM12_OFFSET,NA,4,1,0,1,0xABCDEF0123456789,0xABCDEF0123456789,5,1,0,8,0xDEADBEEFDEAD89EF},
-    {0xB024,INSTR_STRB,AL,AL,1,0,0xDEADBEEFDEADBEEF,1,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,1,1,0,8,0xDEADBEEFDEAD89EF},
-    {0xB025,INSTR_STRH,AL,AL,1,4066,0xDEADBEEFDEADBEEF,4070,IMM12_OFFSET,NA,2,1,0,1,0xABCDEF0123456789,0xABCDEF0123456789,4072,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB026,INSTR_STRH,AL,AL,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB027,INSTR_STRH,EQ,NE,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEADBEEFDEADBEEF},
-    {0xB028,INSTR_STRH,NE,NE,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB029,INSTR_STRH,NE,EQ,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEADBEEFDEADBEEF},
-    {0xB030,INSTR_STRH,EQ,EQ,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB031,INSTR_STRH,HI,LS,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEADBEEFDEADBEEF},
-    {0xB032,INSTR_STRH,LS,LS,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB033,INSTR_STRH,LS,HI,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEADBEEFDEADBEEF},
-    {0xB034,INSTR_STRH,HI,HI,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB035,INSTR_STRH,CC,HS,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEADBEEFDEADBEEF},
-    {0xB036,INSTR_STRH,CS,HS,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB037,INSTR_STRH,GE,LT,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEADBEEFDEADBEEF},
-    {0xB038,INSTR_STRH,LT,LT,1,4066,0xDEADBEEFDEADBEEF,4070,NO_OFFSET,NA,NA,0,0,0,0xABCDEF0123456789,0xABCDEF0123456789,4070,1,4066,8,0xDEAD6789DEADBEEF},
-    {0xB039,INSTR_ADDR_STR,AL,AL,1,4064,0xDEADBEEFDEADBEEF,4,IMM12_OFFSET,NA,4060,0,1,0,0xABCDEF0123456789,0xABCDEF0123456789,4,1,4064,8,0xABCDEF0123456789},
-};
-
-
-void flushcache()
-{
-    const long base = long(instrMem);
-    const long curr = base + long(instrMemSize);
-    __builtin___clear_cache((char*)base, (char*)curr);
-}
-void dataOpTest(dataOpTest_t test, ARMAssemblerInterface *a64asm, uint32_t Rd = 0,
-                uint32_t Rn = 1, uint32_t Rm = 2, uint32_t Rs = 3)
-{
-    int64_t  regs[NUM_REGS] = {0};
-    int32_t  flags[NUM_FLAGS] = {0};
-    int64_t  savedRegs[NUM_REGS] = {0};
-    uint32_t i;
-    uint32_t op2;
-
-    for(i = 0; i < NUM_REGS; ++i)
-    {
-        regs[i] = i;
-    }
-
-    regs[Rd] = test.RdValue;
-    regs[Rn] = test.RnValue;
-    regs[Rs] = test.RsValue;
-    flags[test.preFlag] = 1;
-    a64asm->reset();
-    a64asm->prolog();
-    if(test.immediate == true)
-    {
-        op2 = a64asm->imm(test.immValue);
-    }
-    else if(test.immediate == false && test.shiftAmount == 0)
-    {
-        op2 = Rm;
-        regs[Rm] = test.RmValue;
-    }
-    else
-    {
-        op2 = a64asm->reg_imm(Rm, test.shiftMode, test.shiftAmount);
-        regs[Rm] = test.RmValue;
-    }
-    switch(test.op)
-    {
-    case INSTR_ADD: a64asm->ADD(test.cond, test.setFlags, Rd,Rn,op2); break;
-    case INSTR_SUB: a64asm->SUB(test.cond, test.setFlags, Rd,Rn,op2); break;
-    case INSTR_RSB: a64asm->RSB(test.cond, test.setFlags, Rd,Rn,op2); break;
-    case INSTR_AND: a64asm->AND(test.cond, test.setFlags, Rd,Rn,op2); break;
-    case INSTR_ORR: a64asm->ORR(test.cond, test.setFlags, Rd,Rn,op2); break;
-    case INSTR_BIC: a64asm->BIC(test.cond, test.setFlags, Rd,Rn,op2); break;
-    case INSTR_MUL: a64asm->MUL(test.cond, test.setFlags, Rd,Rm,Rs); break;
-    case INSTR_MLA: a64asm->MLA(test.cond, test.setFlags, Rd,Rm,Rs,Rn); break;
-    case INSTR_CMP: a64asm->CMP(test.cond, Rn,op2); break;
-    case INSTR_MOV: a64asm->MOV(test.cond, test.setFlags,Rd,op2); break;
-    case INSTR_MVN: a64asm->MVN(test.cond, test.setFlags,Rd,op2); break;
-    case INSTR_SMULBB:a64asm->SMULBB(test.cond, Rd,Rm,Rs); break;
-    case INSTR_SMULBT:a64asm->SMULBT(test.cond, Rd,Rm,Rs); break;
-    case INSTR_SMULTB:a64asm->SMULTB(test.cond, Rd,Rm,Rs); break;
-    case INSTR_SMULTT:a64asm->SMULTT(test.cond, Rd,Rm,Rs); break;
-    case INSTR_SMULWB:a64asm->SMULWB(test.cond, Rd,Rm,Rs); break;
-    case INSTR_SMULWT:a64asm->SMULWT(test.cond, Rd,Rm,Rs); break;
-    case INSTR_SMLABB:a64asm->SMLABB(test.cond, Rd,Rm,Rs,Rn); break;
-    case INSTR_UXTB16:a64asm->UXTB16(test.cond, Rd,Rm,test.shiftAmount); break;
-    case INSTR_UBFX:
-    {
-        int32_t lsb   = test.RsValue;
-        int32_t width = test.RmValue;
-        a64asm->UBFX(test.cond, Rd,Rn,lsb, width);
-        break;
-    }
-    case INSTR_ADDR_ADD: a64asm->ADDR_ADD(test.cond, test.setFlags, Rd,Rn,op2); break;
-    case INSTR_ADDR_SUB: a64asm->ADDR_SUB(test.cond, test.setFlags, Rd,Rn,op2); break;
-    default: printf("Error"); return;
-    }
-    a64asm->epilog(0);
-    flushcache();
-
-    asm_function_t asm_function = (asm_function_t)(instrMem);
-
-    for(i = 0; i < NUM_REGS; ++i)
-        savedRegs[i] = regs[i];
-
-    asm_test_jacket(asm_function, regs, flags);
-
-    /* Check if all regs except Rd is same */
-    for(i = 0; i < NUM_REGS; ++i)
-    {
-        if(i == Rd) continue;
-        if(regs[i] != savedRegs[i])
-        {
-            printf("Test %x failed Reg(%d) tampered Expected(0x%" PRIx64 "),"
-                   "Actual(0x%" PRIx64 ") t\n", test.id, i, savedRegs[i],
-                   regs[i]);
-            return;
-        }
-    }
-
-    if(test.checkRd == 1 && (uint64_t)regs[Rd] != test.postRdValue)
-    {
-        printf("Test %x failed, Expected(%" PRIx64 "), Actual(%" PRIx64 ")\n",
-               test.id, test.postRdValue, regs[Rd]);
-    }
-    else if(test.checkFlag == 1 && flags[test.postFlag] == 0)
-    {
-        printf("Test %x failed Flag(%s) NOT set\n",
-                test.id,cc_code[test.postFlag]);
-    }
-    else
-    {
-        printf("Test %x passed\n", test.id);
-    }
-}
-
-
-void dataTransferTest(dataTransferTest_t test, ARMAssemblerInterface *a64asm,
-                      uint32_t Rd = 0, uint32_t Rn = 1,uint32_t Rm = 2)
-{
-    int64_t regs[NUM_REGS] = {0};
-    int64_t savedRegs[NUM_REGS] = {0};
-    int32_t flags[NUM_FLAGS] = {0};
-    uint32_t i;
-    for(i = 0; i < NUM_REGS; ++i)
-    {
-        regs[i] = i;
-    }
-
-    uint32_t op2;
-
-    regs[Rd] = test.RdValue;
-    regs[Rn] = (uint64_t)(&dataMem[test.RnValue]);
-    regs[Rm] = test.RmValue;
-    flags[test.preFlag] = 1;
-
-    if(test.setMem == true)
-    {
-        unsigned char *mem = (unsigned char *)&dataMem[test.memOffset];
-        uint64_t value = test.memValue;
-        for(int j = 0; j < 8; ++j)
-        {
-            mem[j] = value & 0x00FF;
-            value >>= 8;
-        }
-    }
-    a64asm->reset();
-    a64asm->prolog();
-    if(test.offsetType == REG_SCALE_OFFSET)
-    {
-        op2 = a64asm->reg_scale_pre(Rm);
-    }
-    else if(test.offsetType == REG_OFFSET)
-    {
-        op2 = a64asm->reg_pre(Rm);
-    }
-    else if(test.offsetType == IMM12_OFFSET && test.preIndex == true)
-    {
-        op2 = a64asm->immed12_pre(test.immValue, test.writeBack);
-    }
-    else if(test.offsetType == IMM12_OFFSET && test.postIndex == true)
-    {
-        op2 = a64asm->immed12_post(test.immValue);
-    }
-    else if(test.offsetType == IMM8_OFFSET && test.preIndex == true)
-    {
-        op2 = a64asm->immed8_pre(test.immValue, test.writeBack);
-    }
-    else if(test.offsetType == IMM8_OFFSET && test.postIndex == true)
-    {
-        op2 = a64asm->immed8_post(test.immValue);
-    }
-    else if(test.offsetType == NO_OFFSET)
-    {
-        op2 = a64asm->__immed12_pre(0);
-    }
-    else
-    {
-        printf("Error - Unknown offset\n"); return;
-    }
-
-    switch(test.op)
-    {
-    case INSTR_LDR:  a64asm->LDR(test.cond, Rd,Rn,op2); break;
-    case INSTR_LDRB: a64asm->LDRB(test.cond, Rd,Rn,op2); break;
-    case INSTR_LDRH: a64asm->LDRH(test.cond, Rd,Rn,op2); break;
-    case INSTR_ADDR_LDR: a64asm->ADDR_LDR(test.cond, Rd,Rn,op2); break;
-    case INSTR_STR:  a64asm->STR(test.cond, Rd,Rn,op2); break;
-    case INSTR_STRB: a64asm->STRB(test.cond, Rd,Rn,op2); break;
-    case INSTR_STRH: a64asm->STRH(test.cond, Rd,Rn,op2); break;
-    case INSTR_ADDR_STR: a64asm->ADDR_STR(test.cond, Rd,Rn,op2); break;
-    default: printf("Error"); return;
-    }
-    a64asm->epilog(0);
-    flushcache();
-
-    asm_function_t asm_function = (asm_function_t)(instrMem);
-
-    for(i = 0; i < NUM_REGS; ++i)
-        savedRegs[i] = regs[i];
-
-
-    asm_test_jacket(asm_function, regs, flags);
-
-    /* Check if all regs except Rd/Rn are same */
-    for(i = 0; i < NUM_REGS; ++i)
-    {
-        if(i == Rd || i == Rn) continue;
-        if(regs[i] != savedRegs[i])
-        {
-            printf("Test %x failed Reg(%d) tampered"
-                   " Expected(0x%" PRIx64 "), Actual(0x%" PRIx64 ") t\n",
-                   test.id, i, savedRegs[i], regs[i]);
-            return;
-        }
-    }
-
-    if((uint64_t)regs[Rd] != test.postRdValue)
-    {
-        printf("Test %x failed, "
-               "Expected in Rd(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
-               test.id, test.postRdValue, regs[Rd]);
-    }
-    else if((uint64_t)regs[Rn] != (uint64_t)(&dataMem[test.postRnValue]))
-    {
-        printf("Test %x failed, "
-               "Expected in Rn(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
-               test.id, test.postRnValue, regs[Rn] - (uint64_t)dataMem);
-    }
-    else if(test.checkMem == true)
-    {
-        unsigned char *addr = (unsigned char *)&dataMem[test.postMemOffset];
-        uint64_t value;
-        value = 0;
-        for(uint32_t j = 0; j < test.postMemLength; ++j)
-            value = (value << 8) | addr[test.postMemLength-j-1];
-        if(value != test.postMemValue)
-        {
-            printf("Test %x failed, "
-                   "Expected in Mem(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
-                   test.id, test.postMemValue, value);
-        }
-        else
-        {
-            printf("Test %x passed\n", test.id);
-        }
-    }
-    else
-    {
-        printf("Test %x passed\n", test.id);
-    }
-}
-
-void dataTransferLDMSTM(ARMAssemblerInterface *a64asm)
-{
-    int64_t regs[NUM_REGS] = {0};
-    int32_t flags[NUM_FLAGS] = {0};
-    const uint32_t numArmv7Regs = 16;
-
-    uint32_t Rn = ARMAssemblerInterface::SP;
-
-    uint32_t patterns[] =
-    {
-        0x5A03,
-        0x4CF0,
-        0x1EA6,
-        0x0DBF,
-    };
-
-    uint32_t i, j;
-    for(i = 0; i < sizeof(patterns)/sizeof(uint32_t); ++i)
-    {
-        for(j = 0; j < NUM_REGS; ++j)
-        {
-            regs[j] = j;
-        }
-        a64asm->reset();
-        a64asm->prolog();
-        a64asm->STM(AL,ARMAssemblerInterface::DB,Rn,1,patterns[i]);
-        for(j = 0; j < numArmv7Regs; ++j)
-        {
-            uint32_t op2 = a64asm->imm(0x31);
-            a64asm->MOV(AL, 0,j,op2);
-        }
-        a64asm->LDM(AL,ARMAssemblerInterface::IA,Rn,1,patterns[i]);
-        a64asm->epilog(0);
-        flushcache();
-
-        asm_function_t asm_function = (asm_function_t)(instrMem);
-        asm_test_jacket(asm_function, regs, flags);
-
-        for(j = 0; j < numArmv7Regs; ++j)
-        {
-            if((1 << j) & patterns[i])
-            {
-                if(regs[j] != j)
-                {
-                    printf("LDM/STM Test %x failed "
-                           "Reg%d expected(0x%x) Actual(0x%" PRIx64 ") \n",
-                           patterns[i], j, j, regs[j]);
-                    break;
-                }
-            }
-        }
-        if(j == numArmv7Regs)
-            printf("LDM/STM Test %x passed\n", patterns[i]);
-    }
-}
-
-int main(void)
-{
-    uint32_t i;
-
-    /* Allocate memory to store instructions generated by ArmToArm64Assembler */
-    {
-        int fd = ashmem_create_region("code cache", instrMemSize);
-        if(fd < 0)
-            printf("Creating code cache, ashmem_create_region "
-                                "failed with error '%s'", strerror(errno));
-        instrMem = mmap(NULL, instrMemSize,
-                                    PROT_READ | PROT_WRITE | PROT_EXEC,
-                                MAP_PRIVATE, fd, 0);
-    }
-
-    ArmToArm64Assembler a64asm(instrMem);
-
-    if(TESTS_DATAOP_ENABLE)
-    {
-        printf("Running data processing tests\n");
-        for(i = 0; i < sizeof(dataOpTests)/sizeof(dataOpTest_t); ++i)
-            dataOpTest(dataOpTests[i], &a64asm);
-    }
-
-    if(TESTS_DATATRANSFER_ENABLE)
-    {
-        printf("Running data transfer tests\n");
-        for(i = 0; i < sizeof(dataTransferTests)/sizeof(dataTransferTest_t); ++i)
-            dataTransferTest(dataTransferTests[i], &a64asm);
-    }
-
-    if(TESTS_LDMSTM_ENABLE)
-    {
-        printf("Running LDM/STM tests\n");
-        dataTransferLDMSTM(&a64asm);
-    }
-
-
-    if(TESTS_REG_CORRUPTION_ENABLE)
-    {
-        uint32_t reg_list[] = {0,1,12,14};
-        uint32_t Rd, Rm, Rs, Rn;
-        uint32_t i;
-        uint32_t numRegs = sizeof(reg_list)/sizeof(uint32_t);
-
-        printf("Running Register corruption tests\n");
-        for(i = 0; i < sizeof(dataOpTests)/sizeof(dataOpTest_t); ++i)
-        {
-            for(Rd = 0; Rd < numRegs; ++Rd)
-            {
-                for(Rn = 0; Rn < numRegs; ++Rn)
-                {
-                    for(Rm = 0; Rm < numRegs; ++Rm)
-                    {
-                        for(Rs = 0; Rs < numRegs;++Rs)
-                        {
-                            if(Rd == Rn || Rd == Rm || Rd == Rs) continue;
-                            if(Rn == Rm || Rn == Rs) continue;
-                            if(Rm == Rs) continue;
-                            printf("Testing combination Rd(%d), Rn(%d),"
-                                   " Rm(%d), Rs(%d): ",
-                                   reg_list[Rd], reg_list[Rn], reg_list[Rm], reg_list[Rs]);
-                            dataOpTest(dataOpTests[i], &a64asm, reg_list[Rd],
-                                       reg_list[Rn], reg_list[Rm], reg_list[Rs]);
-                        }
-                    }
-                }
-            }
-        }
-    }
-    return 0;
-}
diff --git a/libpixelflinger/tests/arch-arm64/assembler/asm_test_jacket.S b/libpixelflinger/tests/arch-arm64/assembler/asm_test_jacket.S
deleted file mode 100644
index 3f900f8..0000000
--- a/libpixelflinger/tests/arch-arm64/assembler/asm_test_jacket.S
+++ /dev/null
@@ -1,221 +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.
- */
-
-    .text
-    .balign 0
-
-    .global asm_test_jacket
-
-    // Set the register and flag values
-    // Calls the asm function
-    // Reads the register/flag values to output register
-
-    // Parameters
-    // X0 - Function to jump
-    // X1 - register values array
-    // X2 - flag values array
-asm_test_jacket:
-    // Save registers to stack
-    stp    x29, x30, [sp,#-16]!
-    stp    x27, x28, [sp,#-16]!
-
-    mov x30, x0
-    mov x28, x1
-    mov x27, x2
-
-    //Set the flags based on flag array
-    //EQ
-    ldr w0, [x27,#0]
-    cmp w0, #1
-    b.ne bt_aeq
-    cmp w0,#1
-    b bt_end
-bt_aeq:
-
-    //NE
-    ldr w0, [x27,#4]
-    cmp w0, #1
-    b.ne bt_ane
-    cmp w0,#2
-    b bt_end
-bt_ane:
-
-    //CS
-    ldr w0, [x27,#8]
-    cmp w0, #1
-    b.ne bt_acs
-    cmp w0,#0
-    b bt_end
-bt_acs:
-
-    //CC
-    ldr w0, [x27,#12]
-    cmp w0, #1
-    b.ne bt_acc
-    cmp w0,#2
-    b bt_end
-bt_acc:
-
-    //MI
-    ldr w0, [x27,#16]
-    cmp w0, #1
-    b.ne bt_ami
-    subs w0,w0,#2
-    b bt_end
-bt_ami:
-
-    //PL
-    ldr w0, [x27,#20]
-    cmp w0, #1
-    b.ne bt_apl
-    subs w0,w0,#0
-    b bt_end
-bt_apl:
-    //HI - (C==1) && (Z==0)
-    ldr w0, [x27,#32]
-    cmp w0, #1
-    b.ne bt_ahi
-    cmp w0,#0
-    b bt_end
-bt_ahi:
-
-    //LS - (C==0) || (Z==1)
-    ldr w0, [x27,#36]
-    cmp w0, #1
-    b.ne bt_als
-    cmp w0,#1
-    b bt_end
-bt_als:
-
-    //GE
-    ldr w0, [x27,#40]
-    cmp w0, #1
-    b.ne bt_age
-    cmp w0,#0
-    b bt_end
-bt_age:
-
-    //LT
-    ldr w0, [x27,#44]
-    cmp w0, #1
-    b.ne bt_alt
-    cmp w0,#2
-    b bt_end
-bt_alt:
-
-    //GT
-    ldr w0, [x27,#48]
-    cmp w0, #1
-    b.ne bt_agt
-    cmp w0,#0
-    b bt_end
-bt_agt:
-
-    //LE
-    ldr w0, [x27,#52]
-    cmp w0, #1
-    b.ne bt_ale
-    cmp w0,#2
-    b bt_end
-bt_ale:
-
-
-bt_end:
-
-    // Load the registers from reg array
-    ldr x0, [x28,#0]
-    ldr x1, [x28,#8]
-    ldr x2, [x28,#16]
-    ldr x3, [x28,#24]
-    ldr x4, [x28,#32]
-    ldr x5, [x28,#40]
-    ldr x6, [x28,#48]
-    ldr x7, [x28,#56]
-    ldr x8, [x28,#64]
-    ldr x9, [x28,#72]
-    ldr x10, [x28,#80]
-    ldr x11, [x28,#88]
-    ldr x12, [x28,#96]
-    ldr x14, [x28,#112]
-
-    // Call the function
-    blr X30
-
-    // Save the registers to reg array
-    str x0, [x28,#0]
-    str x1, [x28,#8]
-    str x2, [x28,#16]
-    str x3, [x28,#24]
-    str x4, [x28,#32]
-    str x5, [x28,#40]
-    str x6, [x28,#48]
-    str x7, [x28,#56]
-    str x8, [x28,#64]
-    str x9, [x28,#72]
-    str x10, [x28,#80]
-    str x11, [x28,#88]
-    str x12, [x28,#96]
-    str x14, [x28,#112]
-
-    //Set the flags array based on result flags
-    movz w0, #0
-    movz w1, #1
-    csel w2, w1, w0, EQ
-    str w2, [x27,#0]
-    csel w2, w1, w0, NE
-    str w2, [x27,#4]
-    csel w2, w1, w0, CS
-    str w2, [x27,#8]
-    csel w2, w1, w0, CC
-    str w2, [x27,#12]
-    csel w2, w1, w0, MI
-    str w2, [x27,#16]
-    csel w2, w1, w0, PL
-    str w2, [x27,#20]
-    csel w2, w1, w0, VS
-    str w2, [x27,#24]
-    csel w2, w1, w0, VC
-    str w2, [x27,#28]
-    csel w2, w1, w0, HI
-    str w2, [x27,#32]
-    csel w2, w1, w0, LS
-    str w2, [x27,#36]
-    csel w2, w1, w0, GE
-    str w2, [x27,#40]
-    csel w2, w1, w0, LT
-    str w2, [x27,#44]
-    csel w2, w1, w0, GT
-    str w2, [x27,#48]
-    csel w2, w1, w0, LE
-    str w2, [x27,#52]
-
-    // Restore registers from stack
-    ldp    x27, x28, [sp],#16
-    ldp    x29, x30, [sp],#16
-    ret
-
diff --git a/libpixelflinger/tests/arch-arm64/col32cb16blend/Android.bp b/libpixelflinger/tests/arch-arm64/col32cb16blend/Android.bp
deleted file mode 100644
index e640aeb..0000000
--- a/libpixelflinger/tests/arch-arm64/col32cb16blend/Android.bp
+++ /dev/null
@@ -1,6 +0,0 @@
-cc_test {
-    name: "test-pixelflinger-arm64-col32cb16blend",
-    defaults: ["pixelflinger-tests-arm64"],
-
-    srcs: ["col32cb16blend_test.c"],
-}
diff --git a/libpixelflinger/tests/arch-arm64/col32cb16blend/col32cb16blend_test.c b/libpixelflinger/tests/arch-arm64/col32cb16blend/col32cb16blend_test.c
deleted file mode 100644
index c6a3017..0000000
--- a/libpixelflinger/tests/arch-arm64/col32cb16blend/col32cb16blend_test.c
+++ /dev/null
@@ -1,125 +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 <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-
-
-#define ARGB_8888_MAX   0xFFFFFFFF
-#define ARGB_8888_MIN   0x00000000
-#define RGB_565_MAX 0xFFFF
-#define RGB_565_MIN 0x0000
-
-struct test_t
-{
-    char name[256];
-    uint32_t dst_color;
-    uint32_t src_color;
-    size_t count;
-};
-
-struct test_t tests[] =
-{
-    {"Count 1, Src=Max, Dst=Min", ARGB_8888_MAX, RGB_565_MIN, 1},
-    {"Count 2, Src=Min, Dst=Max", ARGB_8888_MIN, RGB_565_MAX, 2},
-    {"Count 3, Src=Max, Dst=Max", ARGB_8888_MAX, RGB_565_MAX, 3},
-    {"Count 4, Src=Min, Dst=Min", ARGB_8888_MAX, RGB_565_MAX, 4},
-    {"Count 1, Src=Rand, Dst=Rand", 0x12345678, 0x9ABC, 1},
-    {"Count 2, Src=Rand, Dst=Rand", 0xABCDEF12, 0x2345, 2},
-    {"Count 3, Src=Rand, Dst=Rand", 0x11111111, 0xEDFE, 3},
-    {"Count 4, Src=Rand, Dst=Rand", 0x12345678, 0x9ABC, 4},
-    {"Count 5, Src=Rand, Dst=Rand", 0xEFEFFEFE, 0xFACC, 5},
-    {"Count 10, Src=Rand, Dst=Rand", 0x12345678, 0x9ABC, 10}
-};
-
-void scanline_col32cb16blend_arm64(uint16_t *dst, int32_t src, size_t count);
-void scanline_col32cb16blend_c(uint16_t * dst, int32_t src, size_t count)
-{
-    int srcAlpha = (src>>24);
-    int f = 0x100 - (srcAlpha + (srcAlpha>>7));
-    while (count--)
-    {
-        uint16_t d = *dst;
-        int dstR = (d>>11)&0x1f;
-        int dstG = (d>>5)&0x3f;
-        int dstB = (d)&0x1f;
-        int srcR = (src >> (   3))&0x1F;
-        int srcG = (src >> ( 8+2))&0x3F;
-        int srcB = (src >> (16+3))&0x1F;
-        srcR += (f*dstR)>>8;
-        srcG += (f*dstG)>>8;
-        srcB += (f*dstB)>>8;
-        *dst++ = (uint16_t)((srcR<<11)|(srcG<<5)|srcB);
-    }
-}
-
-void scanline_col32cb16blend_test()
-{
-    uint16_t dst_c[16], dst_asm[16];
-    uint32_t i, j;
-
-    for(i = 0; i < sizeof(tests)/sizeof(struct test_t); ++i)
-    {
-        struct test_t test = tests[i];
-
-        printf("Testing - %s:",test.name);
-
-        memset(dst_c, 0, sizeof(dst_c));
-        memset(dst_asm, 0, sizeof(dst_asm));
-
-        for(j = 0; j < test.count; ++j)
-        {
-            dst_c[j]   = test.dst_color;
-            dst_asm[j] = test.dst_color;
-        }
-
-
-        scanline_col32cb16blend_c(dst_c, test.src_color, test.count);
-        scanline_col32cb16blend_arm64(dst_asm, test.src_color, test.count);
-
-
-        if(memcmp(dst_c, dst_asm, sizeof(dst_c)) == 0)
-            printf("Passed\n");
-        else
-            printf("Failed\n");
-
-        for(j = 0; j < test.count; ++j)
-        {
-            printf("dst_c[%d] = %x, dst_asm[%d] = %x \n", j, dst_c[j], j, dst_asm[j]);
-        }
-    }
-}
-
-int main()
-{
-    scanline_col32cb16blend_test();
-    return 0;
-}
diff --git a/libpixelflinger/tests/arch-arm64/disassembler/Android.bp b/libpixelflinger/tests/arch-arm64/disassembler/Android.bp
deleted file mode 100644
index 38dc99a..0000000
--- a/libpixelflinger/tests/arch-arm64/disassembler/Android.bp
+++ /dev/null
@@ -1,6 +0,0 @@
-cc_test {
-    name: "test-pixelflinger-arm64-disassembler-test",
-    defaults: ["pixelflinger-tests-arm64"],
-
-    srcs: ["arm64_diassembler_test.cpp"],
-}
diff --git a/libpixelflinger/tests/arch-arm64/disassembler/arm64_diassembler_test.cpp b/libpixelflinger/tests/arch-arm64/disassembler/arm64_diassembler_test.cpp
deleted file mode 100644
index af3183b..0000000
--- a/libpixelflinger/tests/arch-arm64/disassembler/arm64_diassembler_test.cpp
+++ /dev/null
@@ -1,321 +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 <stdio.h>
-#include <inttypes.h>
-#include <string.h>
-
-int arm64_disassemble(uint32_t code, char* instr);
-
-struct test_table_entry_t
-{
-     uint32_t code;
-     const char *instr;
-};
-static test_table_entry_t test_table [] =
-{
-    { 0x91000240, "add x0, x18, #0x0, lsl #0"         },
-    { 0x9140041f, "add sp, x0, #0x1, lsl #12"         },
-    { 0x917ffff2, "add x18, sp, #0xfff, lsl #12"      },
-
-    { 0xd13ffe40, "sub x0, x18, #0xfff, lsl #0"       },
-    { 0xd140001f, "sub sp, x0, #0x0, lsl #12"         },
-    { 0xd14007f2, "sub x18, sp, #0x1, lsl #12"        },
-
-    { 0x8b1e0200, "add x0, x16, x30, lsl #0"          },
-    { 0x8b507fdf, "add xzr, x30, x16, lsr #31"        },
-    { 0x8b8043f0, "add x16, xzr, x0, asr #16"         },
-    { 0x8b5f401e, "add x30, x0, xzr, lsr #16"         },
-
-
-    { 0x4b1e0200, "sub w0, w16, w30, lsl #0"          },
-    { 0x4b507fdf, "sub wzr, w30, w16, lsr #31"        },
-    { 0x4b8043f0, "sub w16, wzr, w0, asr #16"         },
-    { 0x4b5f401e, "sub w30, w0, wzr, lsr #16"         },
-
-    { 0x6b1e0200, "subs w0, w16, w30, lsl #0"         },
-    { 0x6b507fdf, "subs wzr, w30, w16, lsr #31"       },
-    { 0x6b8043f0, "subs w16, wzr, w0, asr #16"        },
-    { 0x6b5f401e, "subs w30, w0, wzr, lsr #16"        },
-
-    { 0x0a1e0200, "and w0, w16, w30, lsl #0"          },
-    { 0x0a507fdf, "and wzr, w30, w16, lsr #31"        },
-    { 0x0a8043f0, "and w16, wzr, w0, asr #16"         },
-    { 0x0adf401e, "and w30, w0, wzr, ror #16"         },
-
-    { 0x2a1e0200, "orr w0, w16, w30, lsl #0"          },
-    { 0x2a507fdf, "orr wzr, w30, w16, lsr #31"        },
-    { 0x2a8043f0, "orr w16, wzr, w0, asr #16"         },
-    { 0x2adf401e, "orr w30, w0, wzr, ror #16"         },
-
-    { 0x2a3e0200, "orn w0, w16, w30, lsl #0"          },
-    { 0x2a707fdf, "orn wzr, w30, w16, lsr #31"        },
-    { 0x2aa043f0, "orn w16, wzr, w0, asr #16"         },
-    { 0x2aff401e, "orn w30, w0, wzr, ror #16"         },
-
-    { 0x729fffe0, "movk w0, #0xffff, lsl #0"          },
-    { 0x72a0000f, "movk w15, #0x0, lsl #16"           },
-    { 0x7281fffe, "movk w30, #0xfff, lsl #0"          },
-    { 0x72a0003f, "movk wzr, #0x1, lsl #16"           },
-
-    { 0x529fffe0, "movz w0, #0xffff, lsl #0"          },
-    { 0x52a0000f, "movz w15, #0x0, lsl #16"           },
-    { 0x5281fffe, "movz w30, #0xfff, lsl #0"          },
-    { 0x52a0003f, "movz wzr, #0x1, lsl #16"           },
-
-    { 0xd29fffe0, "movz x0, #0xffff, lsl #0"          },
-    { 0xd2a0000f, "movz x15, #0x0, lsl #16"           },
-    { 0xd2c1fffe, "movz x30, #0xfff, lsl #32"         },
-    { 0xd2e0003f, "movz xzr, #0x1, lsl #48"           },
-
-    { 0x1a8003e0, "csel w0, wzr, w0, eq"              },
-    { 0x1a831001, "csel w1, w0, w3, ne"               },
-    { 0x1a9e2022, "csel w2, w1, w30, cs"              },
-    { 0x1a8a3083, "csel w3, w4, w10, cc"              },
-    { 0x1a8b40e4, "csel w4, w7, w11, mi"              },
-    { 0x1a9b5105, "csel w5, w8, w27, pl"              },
-    { 0x1a846167, "csel w7, w11, w4, vs"              },
-    { 0x1a8671c8, "csel w8, w14, w6, vc"              },
-    { 0x1a878289, "csel w9, w20, w7, hi"              },
-    { 0x1a8c92aa, "csel w10, w21, w12, ls"            },
-    { 0x1a8ea2ce, "csel w14, w22, w14, ge"            },
-    { 0x1a9fb3b2, "csel w18, w29, wzr, lt"            },
-    { 0x1a9fc3d8, "csel w24, w30, wzr, gt"            },
-    { 0x1a82d17e, "csel w30, w11, w2, le"             },
-    { 0x1a81e19f, "csel wzr, w12, w1, al"             },
-
-    { 0x9a8003e0, "csel x0, xzr, x0, eq"              },
-    { 0x9a831001, "csel x1, x0, x3, ne"               },
-    { 0x9a9e2022, "csel x2, x1, x30, cs"              },
-    { 0x9a8a3083, "csel x3, x4, x10, cc"              },
-    { 0x9a8b40e4, "csel x4, x7, x11, mi"              },
-    { 0x9a9b5105, "csel x5, x8, x27, pl"              },
-    { 0x9a846167, "csel x7, x11, x4, vs"              },
-    { 0x9a8671c8, "csel x8, x14, x6, vc"              },
-    { 0x9a878289, "csel x9, x20, x7, hi"              },
-    { 0x9a8c92aa, "csel x10, x21, x12, ls"            },
-    { 0x9a8ea2ce, "csel x14, x22, x14, ge"            },
-    { 0x9a9fb3b2, "csel x18, x29, xzr, lt"            },
-    { 0x9a9fc3d8, "csel x24, x30, xzr, gt"            },
-    { 0x9a82d17e, "csel x30, x11, x2, le"             },
-    { 0x9a81e19f, "csel xzr, x12, x1, al"             },
-
-    { 0x5a8003e0, "csinv w0, wzr, w0, eq"             },
-    { 0x5a831001, "csinv w1, w0, w3, ne"              },
-    { 0x5a9e2022, "csinv w2, w1, w30, cs"             },
-    { 0x5a8a3083, "csinv w3, w4, w10, cc"             },
-    { 0x5a8b40e4, "csinv w4, w7, w11, mi"             },
-    { 0x5a9b5105, "csinv w5, w8, w27, pl"             },
-    { 0x5a846167, "csinv w7, w11, w4, vs"             },
-    { 0x5a8671c8, "csinv w8, w14, w6, vc"             },
-    { 0x5a878289, "csinv w9, w20, w7, hi"             },
-    { 0x5a8c92aa, "csinv w10, w21, w12, ls"           },
-    { 0x5a8ea2ce, "csinv w14, w22, w14, ge"           },
-    { 0x5a9fb3b2, "csinv w18, w29, wzr, lt"           },
-    { 0x5a9fc3d8, "csinv w24, w30, wzr, gt"           },
-    { 0x5a82d17e, "csinv w30, w11, w2, le"            },
-    { 0x5a81e19f, "csinv wzr, w12, w1, al"            },
-
-    { 0x1b1f3fc0, "madd w0, w30, wzr, w15"            },
-    { 0x1b0079ef, "madd w15, w15, w0, w30"            },
-    { 0x1b0f7ffe, "madd w30, wzr, w15, wzr"           },
-    { 0x1b1e001f, "madd wzr, w0, w30, w0"             },
-
-    { 0x9b3f3fc0, "smaddl x0, w30, wzr, x15"          },
-    { 0x9b2079ef, "smaddl x15, w15, w0, x30"          },
-    { 0x9b2f7ffe, "smaddl x30, wzr, w15, xzr"         },
-    { 0x9b3e001f, "smaddl xzr, w0, w30, x0"           },
-
-    { 0xd65f0000, "ret x0"                            },
-    { 0xd65f01e0, "ret x15"                           },
-    { 0xd65f03c0, "ret x30"                           },
-    { 0xd65f03e0, "ret xzr"                           },
-
-    { 0xb87f4be0, "ldr w0, [sp, wzr, uxtw #0]"        },
-    { 0xb87ed80f, "ldr w15, [x0, w30, sxtw #2]"       },
-    { 0xb86fc9fe, "ldr w30, [x15, w15, sxtw #0]"      },
-    { 0xb8605bdf, "ldr wzr, [x30, w0, uxtw #2]"       },
-    { 0xb87febe0, "ldr w0, [sp, xzr, sxtx #0]"        },
-    { 0xb87e780f, "ldr w15, [x0, x30, lsl #2]"        },
-    { 0xb86f69fe, "ldr w30, [x15, x15, lsl #0]"       },
-    { 0xb860fbdf, "ldr wzr, [x30, x0, sxtx #2]"       },
-
-    { 0xb83f4be0, "str w0, [sp, wzr, uxtw #0]"        },
-    { 0xb83ed80f, "str w15, [x0, w30, sxtw #2]"       },
-    { 0xb82fc9fe, "str w30, [x15, w15, sxtw #0]"      },
-    { 0xb8205bdf, "str wzr, [x30, w0, uxtw #2]"       },
-    { 0xb83febe0, "str w0, [sp, xzr, sxtx #0]"        },
-    { 0xb83e780f, "str w15, [x0, x30, lsl #2]"        },
-    { 0xb82f69fe, "str w30, [x15, x15, lsl #0]"       },
-    { 0xb820fbdf, "str wzr, [x30, x0, sxtx #2]"       },
-
-    { 0x787f4be0, "ldrh w0, [sp, wzr, uxtw #0]"       },
-    { 0x787ed80f, "ldrh w15, [x0, w30, sxtw #1]"      },
-    { 0x786fc9fe, "ldrh w30, [x15, w15, sxtw #0]"     },
-    { 0x78605bdf, "ldrh wzr, [x30, w0, uxtw #1]"      },
-    { 0x787febe0, "ldrh w0, [sp, xzr, sxtx #0]"       },
-    { 0x787e780f, "ldrh w15, [x0, x30, lsl #1]"       },
-    { 0x786f69fe, "ldrh w30, [x15, x15, lsl #0]"      },
-    { 0x7860fbdf, "ldrh wzr, [x30, x0, sxtx #1]"      },
-
-    { 0x783f4be0, "strh w0, [sp, wzr, uxtw #0]"       },
-    { 0x783ed80f, "strh w15, [x0, w30, sxtw #1]"      },
-    { 0x782fc9fe, "strh w30, [x15, w15, sxtw #0]"     },
-    { 0x78205bdf, "strh wzr, [x30, w0, uxtw #1]"      },
-    { 0x783febe0, "strh w0, [sp, xzr, sxtx #0]"       },
-    { 0x783e780f, "strh w15, [x0, x30, lsl #1]"       },
-    { 0x782f69fe, "strh w30, [x15, x15, lsl #0]"      },
-    { 0x7820fbdf, "strh wzr, [x30, x0, sxtx #1]"      },
-
-    { 0x387f5be0, "ldrb w0, [sp, wzr, uxtw #0]"       },
-    { 0x387ec80f, "ldrb w15, [x0, w30, sxtw ]"        },
-    { 0x386fd9fe, "ldrb w30, [x15, w15, sxtw #0]"     },
-    { 0x38604bdf, "ldrb wzr, [x30, w0, uxtw ]"        },
-    { 0x387ffbe0, "ldrb w0, [sp, xzr, sxtx #0]"       },
-    { 0x387e780f, "ldrb w15, [x0, x30, lsl #0]"       },
-    { 0x386f79fe, "ldrb w30, [x15, x15, lsl #0]"      },
-    { 0x3860ebdf, "ldrb wzr, [x30, x0, sxtx ]"        },
-
-    { 0x383f5be0, "strb w0, [sp, wzr, uxtw #0]"       },
-    { 0x383ec80f, "strb w15, [x0, w30, sxtw ]"        },
-    { 0x382fd9fe, "strb w30, [x15, w15, sxtw #0]"     },
-    { 0x38204bdf, "strb wzr, [x30, w0, uxtw ]"        },
-    { 0x383ffbe0, "strb w0, [sp, xzr, sxtx #0]"       },
-    { 0x383e780f, "strb w15, [x0, x30, lsl #0]"       },
-    { 0x382f79fe, "strb w30, [x15, x15, lsl #0]"      },
-    { 0x3820ebdf, "strb wzr, [x30, x0, sxtx ]"        },
-
-    { 0xf87f4be0, "ldr x0, [sp, wzr, uxtw #0]"        },
-    { 0xf87ed80f, "ldr x15, [x0, w30, sxtw #3]"       },
-    { 0xf86fc9fe, "ldr x30, [x15, w15, sxtw #0]"      },
-    { 0xf8605bdf, "ldr xzr, [x30, w0, uxtw #3]"       },
-    { 0xf87febe0, "ldr x0, [sp, xzr, sxtx #0]"        },
-    { 0xf87e780f, "ldr x15, [x0, x30, lsl #3]"        },
-    { 0xf86f69fe, "ldr x30, [x15, x15, lsl #0]"       },
-    { 0xf860fbdf, "ldr xzr, [x30, x0, sxtx #3]"       },
-
-    { 0xf83f4be0, "str x0, [sp, wzr, uxtw #0]"        },
-    { 0xf83ed80f, "str x15, [x0, w30, sxtw #3]"       },
-    { 0xf82fc9fe, "str x30, [x15, w15, sxtw #0]"      },
-    { 0xf8205bdf, "str xzr, [x30, w0, uxtw #3]"       },
-    { 0xf83febe0, "str x0, [sp, xzr, sxtx #0]"        },
-    { 0xf83e780f, "str x15, [x0, x30, lsl #3]"        },
-    { 0xf82f69fe, "str x30, [x15, x15, lsl #0]"       },
-    { 0xf820fbdf, "str xzr, [x30, x0, sxtx #3]"       },
-
-    { 0xb85007e0, "ldr w0, [sp], #-256"               },
-    { 0xb840040f, "ldr w15, [x0], #0"                 },
-    { 0xb84015fe, "ldr w30, [x15], #1"                },
-    { 0xb84ff7df, "ldr wzr, [x30], #255"              },
-    { 0xb8100fe0, "str w0, [sp, #-256]!"              },
-    { 0xb8000c0f, "str w15, [x0, #0]!"                },
-    { 0xb8001dfe, "str w30, [x15, #1]!"               },
-    { 0xb80fffdf, "str wzr, [x30, #255]!"             },
-
-    { 0x13017be0, "sbfm w0, wzr, #1, #30"             },
-    { 0x131e7fcf, "sbfm w15, w30, #30, #31"           },
-    { 0x131f01fe, "sbfm w30, w15, #31, #0"            },
-    { 0x1300041f, "sbfm wzr, w0, #0, #1"              },
-
-    { 0x53017be0, "ubfm w0, wzr, #1, #30"             },
-    { 0x531e7fcf, "ubfm w15, w30, #30, #31"           },
-    { 0x531f01fe, "ubfm w30, w15, #31, #0"            },
-    { 0x5300041f, "ubfm wzr, w0, #0, #1"              },
-    { 0xd3417fe0, "ubfm x0, xzr, #1, #31"             },
-    { 0xd35fffcf, "ubfm x15, x30, #31, #63"           },
-    { 0xd35f01fe, "ubfm x30, x15, #31, #0"            },
-    { 0xd340041f, "ubfm xzr, x0, #0, #1"              },
-
-    { 0x139e7be0, "extr w0, wzr, w30, #30"            },
-    { 0x138f7fcf, "extr w15, w30, w15, #31"           },
-    { 0x138001fe, "extr w30, w15, w0, #0"             },
-    { 0x139f041f, "extr wzr, w0, wzr, #1"             },
-
-    { 0x54000020, "b.eq #.+4"                         },
-    { 0x54000201, "b.ne #.+64"                        },
-    { 0x54000802, "b.cs #.+256"                       },
-    { 0x54002003, "b.cc #.+1024"                      },
-    { 0x54008004, "b.mi #.+4096"                      },
-    { 0x54ffffe5, "b.pl #.-4"                         },
-    { 0x54ffff06, "b.vs #.-32"                        },
-    { 0x54fffc07, "b.vc #.-128"                       },
-    { 0x54fff008, "b.hi #.-512"                       },
-    { 0x54000049, "b.ls #.+8"                         },
-    { 0x5400006a, "b.ge #.+12"                        },
-    { 0x5400008b, "b.lt #.+16"                        },
-    { 0x54ffffcc, "b.gt #.-8"                         },
-    { 0x54ffffad, "b.le #.-12"                        },
-    { 0x54ffff8e, "b.al #.-16"                        },
-
-    { 0x8b2001e0, "add x0, x15, w0, uxtb #0"          },
-    { 0x8b2f27cf, "add x15, x30, w15, uxth #1"        },
-    { 0x8b3e4bfe, "add x30, sp, w30, uxtw #2"         },
-    { 0x8b3f6c1f, "add sp, x0, xzr, uxtx #3"          },
-    { 0x8b2091e0, "add x0, x15, w0, sxtb #4"          },
-    { 0x8b2fa3cf, "add x15, x30, w15, sxth #0"        },
-    { 0x8b3ec7fe, "add x30, sp, w30, sxtw #1"         },
-    { 0x8b3fe81f, "add sp, x0, xzr, sxtx #2"          },
-
-    { 0xcb2001e0, "sub x0, x15, w0, uxtb #0"          },
-    { 0xcb2f27cf, "sub x15, x30, w15, uxth #1"        },
-    { 0xcb3e4bfe, "sub x30, sp, w30, uxtw #2"         },
-    { 0xcb3f6c1f, "sub sp, x0, xzr, uxtx #3"          },
-    { 0xcb2091e0, "sub x0, x15, w0, sxtb #4"          },
-    { 0xcb2fa3cf, "sub x15, x30, w15, sxth #0"        },
-    { 0xcb3ec7fe, "sub x30, sp, w30, sxtw #1"         },
-    { 0xcb3fe81f, "sub sp, x0, xzr, sxtx #2"          }
-};
-
-int main()
-{
-    char instr[256];
-    uint32_t failed = 0;
-    for(uint32_t i = 0; i < sizeof(test_table)/sizeof(test_table_entry_t); ++i)
-    {
-        test_table_entry_t *test;
-        test = &test_table[i];
-        arm64_disassemble(test->code, instr);
-        if(strcmp(instr, test->instr) != 0)
-        {
-            printf("Test Failed \n"
-                   "Code     : 0x%0x\n"
-                   "Expected : %s\n"
-                   "Actual   : %s\n", test->code, test->instr, instr);
-            failed++;
-        }
-    }
-    if(failed == 0)
-    {
-        printf("All tests PASSED\n");
-        return 0;
-    }
-    else
-    {
-        printf("%d tests FAILED\n", failed);
-        return -1;
-    }
-}
diff --git a/libpixelflinger/tests/arch-arm64/t32cb16blend/Android.bp b/libpixelflinger/tests/arch-arm64/t32cb16blend/Android.bp
deleted file mode 100644
index 9d060d1..0000000
--- a/libpixelflinger/tests/arch-arm64/t32cb16blend/Android.bp
+++ /dev/null
@@ -1,6 +0,0 @@
-cc_test {
-    name: "test-pixelflinger-arm64-t32cb16blend",
-    defaults: ["pixelflinger-tests-arm64"],
-
-    srcs: ["t32cb16blend_test.c"],
-}
diff --git a/libpixelflinger/tests/arch-arm64/t32cb16blend/t32cb16blend_test.c b/libpixelflinger/tests/arch-arm64/t32cb16blend/t32cb16blend_test.c
deleted file mode 100644
index afb36fb..0000000
--- a/libpixelflinger/tests/arch-arm64/t32cb16blend/t32cb16blend_test.c
+++ /dev/null
@@ -1,134 +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 <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-
-#define ARGB_8888_MAX   0xFFFFFFFF
-#define ARGB_8888_MIN   0x00000000
-#define RGB_565_MAX     0xFFFF
-#define RGB_565_MIN     0x0000
-
-struct test_t
-{
-    char name[256];
-    uint32_t src_color;
-    uint16_t dst_color;
-    size_t count;
-};
-
-struct test_t tests[] =
-{
-    {"Count 0", 0, 0, 0},
-    {"Count 1, Src=Max, Dst=Min", ARGB_8888_MAX, RGB_565_MIN, 1},
-    {"Count 2, Src=Min, Dst=Max", ARGB_8888_MIN, RGB_565_MAX, 2},
-    {"Count 3, Src=Max, Dst=Max", ARGB_8888_MAX, RGB_565_MAX, 3},
-    {"Count 4, Src=Min, Dst=Min", ARGB_8888_MAX, RGB_565_MAX, 4},
-    {"Count 1, Src=Rand, Dst=Rand", 0x12345678, 0x9ABC, 1},
-    {"Count 2, Src=Rand, Dst=Rand", 0xABCDEF12, 0x2345, 2},
-    {"Count 3, Src=Rand, Dst=Rand", 0x11111111, 0xEDFE, 3},
-    {"Count 4, Src=Rand, Dst=Rand", 0x12345678, 0x9ABC, 4},
-    {"Count 5, Src=Rand, Dst=Rand", 0xEFEFFEFE, 0xFACC, 5},
-    {"Count 10, Src=Rand, Dst=Rand", 0x12345678, 0x9ABC, 10}
-
-};
-
-void scanline_t32cb16blend_arm64(uint16_t*, uint32_t*, size_t);
-void scanline_t32cb16blend_c(uint16_t * dst, uint32_t* src, size_t count)
-{
-    while (count--)
-    {
-        uint16_t d = *dst;
-        uint32_t s = *src++;
-        int dstR = (d>>11)&0x1f;
-        int dstG = (d>>5)&0x3f;
-        int dstB = (d)&0x1f;
-        int srcR = (s >> (   3))&0x1F;
-        int srcG = (s >> ( 8+2))&0x3F;
-        int srcB = (s >> (16+3))&0x1F;
-        int srcAlpha = (s>>24) & 0xFF;
-
-
-        int f = 0x100 - (srcAlpha + ((srcAlpha>>7) & 0x1));
-        srcR += (f*dstR)>>8;
-        srcG += (f*dstG)>>8;
-        srcB += (f*dstB)>>8;
-        srcR = srcR > 0x1F? 0x1F: srcR;
-        srcG = srcG > 0x3F? 0x3F: srcG;
-        srcB = srcB > 0x1F? 0x1F: srcB;
-        *dst++ = (uint16_t)((srcR<<11)|(srcG<<5)|srcB);
-    }
-}
-
-void scanline_t32cb16blend_test()
-{
-    uint16_t dst_c[16], dst_asm[16];
-    uint32_t src[16];
-    uint32_t i;
-    uint32_t  j;
-
-    for(i = 0; i < sizeof(tests)/sizeof(struct test_t); ++i)
-    {
-        struct test_t test = tests[i];
-
-        printf("Testing - %s:",test.name);
-
-        memset(dst_c, 0, sizeof(dst_c));
-        memset(dst_asm, 0, sizeof(dst_asm));
-
-        for(j = 0; j < test.count; ++j)
-        {
-            dst_c[j]   = test.dst_color;
-            dst_asm[j] = test.dst_color;
-            src[j] = test.src_color;
-        }
-
-        scanline_t32cb16blend_c(dst_c,src,test.count);
-        scanline_t32cb16blend_arm64(dst_asm,src,test.count);
-
-
-        if(memcmp(dst_c, dst_asm, sizeof(dst_c)) == 0)
-            printf("Passed\n");
-        else
-            printf("Failed\n");
-
-        for(j = 0; j < test.count; ++j)
-        {
-            printf("dst_c[%d] = %x, dst_asm[%d] = %x \n", j, dst_c[j], j, dst_asm[j]);
-        }
-    }
-}
-
-int main()
-{
-    scanline_t32cb16blend_test();
-    return 0;
-}
diff --git a/libpixelflinger/tests/codegen/Android.bp b/libpixelflinger/tests/codegen/Android.bp
deleted file mode 100644
index 7e4bcfb..0000000
--- a/libpixelflinger/tests/codegen/Android.bp
+++ /dev/null
@@ -1,12 +0,0 @@
-cc_test {
-    name: "test-opengl-codegen",
-    defaults: ["pixelflinger-tests"],
-
-    srcs: ["codegen.cpp"],
-
-    arch: {
-        arm: {
-            instruction_set: "arm",
-        },
-    },
-}
diff --git a/libpixelflinger/tests/codegen/codegen.cpp b/libpixelflinger/tests/codegen/codegen.cpp
deleted file mode 100644
index dce4ed7..0000000
--- a/libpixelflinger/tests/codegen/codegen.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-#include <stdio.h>
-#include <stdint.h>
-
-#include "private/pixelflinger/ggl_context.h"
-
-#include "buffer.h"
-#include "scanline.h"
-
-#include "codeflinger/CodeCache.h"
-#include "codeflinger/GGLAssembler.h"
-#include "codeflinger/ARMAssembler.h"
-#if defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
-#include "codeflinger/MIPSAssembler.h"
-#elif defined(__mips__) && defined(__LP64__) && __mips_isa_rev == 6
-#include "codeflinger/MIPS64Assembler.h"
-#endif
-#include "codeflinger/Arm64Assembler.h"
-
-#if defined(__arm__) || (defined(__mips__) && ((!defined(__LP64__) && __mips_isa_rev < 6) || (defined(__LP64__) && __mips_isa_rev == 6))) || defined(__aarch64__)
-#   define ANDROID_ARM_CODEGEN  1
-#else
-#   define ANDROID_ARM_CODEGEN  0
-#endif
-
-#if defined(__mips__) && ((!defined(__LP64__) && __mips_isa_rev < 6) || (defined(__LP64__) && __mips_isa_rev == 6))
-#define ASSEMBLY_SCRATCH_SIZE   4096
-#elif defined(__aarch64__)
-#define ASSEMBLY_SCRATCH_SIZE   8192
-#else
-#define ASSEMBLY_SCRATCH_SIZE   2048
-#endif
-
-using namespace android;
-
-class ScanlineAssembly : public Assembly {
-    AssemblyKey<needs_t> mKey;
-public:
-    ScanlineAssembly(needs_t needs, size_t size)
-        : Assembly(size), mKey(needs) { }
-    const AssemblyKey<needs_t>& key() const { return mKey; }
-};
-
-#if ANDROID_ARM_CODEGEN
-static void ggl_test_codegen(uint32_t n, uint32_t p, uint32_t t0, uint32_t t1)
-{
-    GGLContext* c;
-    gglInit(&c);
-    needs_t needs;
-    needs.n = n;
-    needs.p = p;
-    needs.t[0] = t0;
-    needs.t[1] = t1;
-    sp<ScanlineAssembly> a(new ScanlineAssembly(needs, ASSEMBLY_SCRATCH_SIZE));
-
-#if defined(__arm__)
-    GGLAssembler assembler( new ARMAssembler(a) );
-#endif
-
-#if defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
-    GGLAssembler assembler( new ArmToMipsAssembler(a) );
-#endif
-
-#if defined(__mips__) && defined(__LP64__) && __mips_isa_rev == 6
-    GGLAssembler assembler( new ArmToMips64Assembler(a) );
-#endif
-
-#if defined(__aarch64__)
-    GGLAssembler assembler( new ArmToArm64Assembler(a) );
-#endif
-
-    int err = assembler.scanline(needs, (context_t*)c);
-    if (err != 0) {
-        printf("error %08x (%s)\n", err, strerror(-err));
-    }
-    gglUninit(c);
-}
-#else
-static void ggl_test_codegen(uint32_t, uint32_t, uint32_t, uint32_t) {
-    printf("This test runs only on ARM, Arm64 or MIPS\n");
-}
-#endif
-
-int main(int argc, char** argv)
-{
-    if (argc != 2) {
-        printf("usage: %s 00000117:03454504_00001501_00000000\n", argv[0]);
-        return 0;
-    }
-    uint32_t n;
-    uint32_t p;
-    uint32_t t0;
-    uint32_t t1;
-    sscanf(argv[1], "%08x:%08x_%08x_%08x", &p, &n, &t0, &t1);
-    ggl_test_codegen(n, p,  t0, t1);
-    return 0;
-}
diff --git a/libpixelflinger/tests/gglmul/Android.bp b/libpixelflinger/tests/gglmul/Android.bp
deleted file mode 100644
index 288337b..0000000
--- a/libpixelflinger/tests/gglmul/Android.bp
+++ /dev/null
@@ -1,12 +0,0 @@
-cc_test {
-    name: "test-pixelflinger-gglmul",
-
-    srcs: ["gglmul_test.cpp"],
-
-    header_libs: ["libpixelflinger_internal"],
-
-    cflags: [
-        "-Wall",
-        "-Werror",
-    ],
-}
diff --git a/libpixelflinger/tests/gglmul/gglmul_test.cpp b/libpixelflinger/tests/gglmul/gglmul_test.cpp
deleted file mode 100644
index 5d460d6..0000000
--- a/libpixelflinger/tests/gglmul/gglmul_test.cpp
+++ /dev/null
@@ -1,278 +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 <stdio.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-#include "private/pixelflinger/ggl_fixed.h"
-
-// gglClampx() tests
-struct gglClampx_test_t
-{
-    GGLfixed input;
-    GGLfixed output;
-};
-
-gglClampx_test_t gglClampx_tests[] =
-{
-    {FIXED_ONE + 1, FIXED_ONE},
-    {FIXED_ONE, FIXED_ONE},
-    {FIXED_ONE - 1, FIXED_ONE - 1},
-    {1, 1},
-    {0, 0},
-    {FIXED_MIN,0}
-};
-
-void gglClampx_test()
-{
-    uint32_t i;
-
-    printf("Testing gglClampx\n");
-    for(i = 0; i < sizeof(gglClampx_tests)/sizeof(gglClampx_test_t); ++i)
-    {
-        gglClampx_test_t *test = &gglClampx_tests[i];
-        printf("Test input=0x%08x output=0x%08x :",
-                test->input, test->output);
-        if(gglClampx(test->input) == test->output)
-            printf("Passed\n");
-        else
-            printf("Failed\n");
-    }
-}
-
-// gglClz() tests
-struct gglClz_test_t
-{
-    GGLfixed input;
-    GGLfixed output;
-};
-
-gglClz_test_t gglClz_tests[] =
-{
-    {0, 32},
-    {1, 31},
-    {-1,0}
-};
-
-void gglClz_test()
-{
-    uint32_t i;
-
-    printf("Testing gglClz\n");
-    for(i = 0; i < sizeof(gglClz_tests)/sizeof(gglClz_test_t); ++i)
-    {
-        gglClz_test_t *test = &gglClz_tests[i];
-        printf("Test input=0x%08x output=%2d :", test->input, test->output);
-        if(gglClz(test->input) == test->output)
-            printf("Passed\n");
-        else
-            printf("Failed\n");
-    }
-}
-
-// gglMulx() tests
-struct gglMulx_test_t
-{
-    GGLfixed x;
-    GGLfixed y;
-    int      shift;
-};
-
-gglMulx_test_t gglMulx_tests[] =
-{
-    {1,1,1},
-    {0,1,1},
-    {FIXED_ONE,FIXED_ONE,16},
-    {FIXED_MIN,FIXED_MAX,16},
-    {FIXED_MAX,FIXED_MAX,16},
-    {FIXED_MIN,FIXED_MIN,16},
-    {FIXED_HALF,FIXED_ONE,16},
-    {FIXED_MAX,FIXED_MAX,31},
-    {FIXED_ONE,FIXED_MAX,31}
-};
-
-void gglMulx_test()
-{
-    uint32_t i;
-    GGLfixed actual, expected;
-
-    printf("Testing gglMulx\n");
-    for(i = 0; i < sizeof(gglMulx_tests)/sizeof(gglMulx_test_t); ++i)
-    {
-        gglMulx_test_t *test = &gglMulx_tests[i];
-        printf("Test x=0x%08x y=0x%08x shift=%2d :",
-                test->x, test->y, test->shift);
-        actual = gglMulx(test->x, test->y, test->shift);
-        expected =
-          ((int64_t)test->x * test->y + (1 << (test->shift-1))) >> test->shift;
-    if(actual == expected)
-        printf(" Passed\n");
-    else
-        printf(" Failed Actual(0x%08x) Expected(0x%08x)\n",
-               actual, expected);
-    }
-}
-// gglMulAddx() tests
-struct gglMulAddx_test_t
-{
-    GGLfixed x;
-    GGLfixed y;
-    int      shift;
-    GGLfixed a;
-};
-
-gglMulAddx_test_t gglMulAddx_tests[] =
-{
-    {1,2,1,1},
-    {0,1,1,1},
-    {FIXED_ONE,FIXED_ONE,16, 0},
-    {FIXED_MIN,FIXED_MAX,16, FIXED_HALF},
-    {FIXED_MAX,FIXED_MAX,16, FIXED_MIN},
-    {FIXED_MIN,FIXED_MIN,16, FIXED_MAX},
-    {FIXED_HALF,FIXED_ONE,16,FIXED_ONE},
-    {FIXED_MAX,FIXED_MAX,31, FIXED_HALF},
-    {FIXED_ONE,FIXED_MAX,31, FIXED_HALF}
-};
-
-void gglMulAddx_test()
-{
-    uint32_t i;
-    GGLfixed actual, expected;
-
-    printf("Testing gglMulAddx\n");
-    for(i = 0; i < sizeof(gglMulAddx_tests)/sizeof(gglMulAddx_test_t); ++i)
-    {
-        gglMulAddx_test_t *test = &gglMulAddx_tests[i];
-        printf("Test x=0x%08x y=0x%08x shift=%2d a=0x%08x :",
-                test->x, test->y, test->shift, test->a);
-        actual = gglMulAddx(test->x, test->y,test->a, test->shift);
-        expected = (((int64_t)test->x * test->y) >> test->shift) + test->a;
-
-        if(actual == expected)
-            printf(" Passed\n");
-        else
-            printf(" Failed Actual(0x%08x) Expected(0x%08x)\n",
-                    actual, expected);
-    }
-}
-// gglMulSubx() tests
-struct gglMulSubx_test_t
-{
-    GGLfixed x;
-    GGLfixed y;
-    int      shift;
-    GGLfixed a;
-};
-
-gglMulSubx_test_t gglMulSubx_tests[] =
-{
-    {1,2,1,1},
-    {0,1,1,1},
-    {FIXED_ONE,FIXED_ONE,16, 0},
-    {FIXED_MIN,FIXED_MAX,16, FIXED_HALF},
-    {FIXED_MAX,FIXED_MAX,16, FIXED_MIN},
-    {FIXED_MIN,FIXED_MIN,16, FIXED_MAX},
-    {FIXED_HALF,FIXED_ONE,16,FIXED_ONE},
-    {FIXED_MAX,FIXED_MAX,31, FIXED_HALF},
-    {FIXED_ONE,FIXED_MAX,31, FIXED_HALF}
-};
-
-void gglMulSubx_test()
-{
-    uint32_t i;
-    GGLfixed actual, expected;
-
-    printf("Testing gglMulSubx\n");
-    for(i = 0; i < sizeof(gglMulSubx_tests)/sizeof(gglMulSubx_test_t); ++i)
-    {
-        gglMulSubx_test_t *test = &gglMulSubx_tests[i];
-        printf("Test x=0x%08x y=0x%08x shift=%2d a=0x%08x :",
-                test->x, test->y, test->shift, test->a);
-        actual = gglMulSubx(test->x, test->y, test->a, test->shift);
-        expected = (((int64_t)test->x * test->y) >> test->shift) - test->a;
-
-        if(actual == expected)
-            printf(" Passed\n");
-        else
-            printf(" Failed Actual(0x%08x) Expected(0x%08x)\n",
-                actual, expected);
-    }
-}
-
-// gglMulii() tests
-
-struct gglMulii_test_t
-{
-    int32_t x;
-    int32_t y;
-};
-
-gglMulii_test_t gglMulii_tests[] =
-{
-    {1,INT32_MIN},
-    {1,INT32_MAX},
-    {0,INT32_MIN},
-    {0,INT32_MAX},
-    {INT32_MIN, INT32_MAX},
-    {INT32_MAX, INT32_MIN},
-    {INT32_MIN, INT32_MIN},
-    {INT32_MAX, INT32_MAX}
-};
-
-void gglMulii_test()
-{
-    uint32_t i;
-    int64_t actual, expected;
-
-    printf("Testing gglMulii\n");
-    for(i = 0; i < sizeof(gglMulii_tests)/sizeof(gglMulii_test_t); ++i)
-    {
-        gglMulii_test_t *test = &gglMulii_tests[i];
-        printf("Test x=0x%08x y=0x%08x :", test->x, test->y);
-        actual = gglMulii(test->x, test->y);
-        expected = ((int64_t)test->x * test->y);
-
-        if(actual == expected)
-            printf(" Passed\n");
-        else
-            printf(" Failed Actual(%" PRId64 ") Expected(%" PRId64 ")\n",
-                    actual, expected);
-    }
-}
-
-int main(int /*argc*/, char** /*argv*/)
-{
-    gglClampx_test();
-    gglClz_test();
-    gglMulx_test();
-    gglMulAddx_test();
-    gglMulSubx_test();
-    gglMulii_test();
-    return 0;
-}
diff --git a/libpixelflinger/trap.cpp b/libpixelflinger/trap.cpp
deleted file mode 100644
index 06ad237..0000000
--- a/libpixelflinger/trap.cpp
+++ /dev/null
@@ -1,1173 +0,0 @@
-/* libs/pixelflinger/trap.cpp
-**
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "pixelflinger-trap"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <cutils/memory.h>
-#include <log/log.h>
-
-#include "trap.h"
-#include "picker.h"
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-// enable to see triangles edges
-#define DEBUG_TRANGLES  0
-
-// ----------------------------------------------------------------------------
-
-static void pointx_validate(void *con, const GGLcoord* c, GGLcoord r);
-static void pointx(void *con, const GGLcoord* c, GGLcoord r);
-static void aa_pointx(void *con, const GGLcoord* c, GGLcoord r);
-static void aa_nice_pointx(void *con, const GGLcoord* c, GGLcoord r);
-
-static void linex_validate(void *con, const GGLcoord* v0, const GGLcoord* v1, GGLcoord w);
-static void linex(void *con, const GGLcoord* v0, const GGLcoord* v1, GGLcoord w);
-static void aa_linex(void *con, const GGLcoord* v0, const GGLcoord* v1, GGLcoord w);
-
-static void recti_validate(void* c, GGLint l, GGLint t, GGLint r, GGLint b); 
-static void recti(void* c, GGLint l, GGLint t, GGLint r, GGLint b); 
-
-static void trianglex_validate(void*,
-        const GGLcoord*, const GGLcoord*, const GGLcoord*);
-static void trianglex_small(void*,
-        const GGLcoord*, const GGLcoord*, const GGLcoord*);
-static void trianglex_big(void*,
-        const GGLcoord*, const GGLcoord*, const GGLcoord*);
-static void aa_trianglex(void*,
-        const GGLcoord*, const GGLcoord*, const GGLcoord*);
-static void trianglex_debug(void* con,
-        const GGLcoord*, const GGLcoord*, const GGLcoord*);
-
-static void aapolyx(void* con,
-        const GGLcoord* pts, int count);
-
-static inline int min(int a, int b) CONST;
-static inline int max(int a, int b) CONST;
-static inline int min(int a, int b, int c) CONST;
-static inline int max(int a, int b, int c) CONST;
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Tools
-#endif
-
-inline int min(int a, int b) {
-    return a<b ? a : b;
-}
-inline int max(int a, int b) {
-    return a<b ? b : a;
-}
-inline int min(int a, int b, int c) {
-    return min(a,min(b,c));
-}
-inline int max(int a, int b, int c) {
-    return max(a,max(b,c));
-}
-
-template <typename T>
-static inline void swap(T& a, T& b) {
-    T t(a);
-    a = b;
-    b = t;
-}
-
-static void
-triangle_dump_points( const GGLcoord*  v0,
-                      const GGLcoord*  v1,
-                      const GGLcoord*  v2 )
-{
-    float tri = 1.0f / TRI_ONE;
-    ALOGD("  P0=(%.3f, %.3f)  [%08x, %08x]\n"
-          "  P1=(%.3f, %.3f)  [%08x, %08x]\n"
-          "  P2=(%.3f, %.3f)  [%08x, %08x]\n",
-          v0[0]*tri, v0[1]*tri, v0[0], v0[1],
-          v1[0]*tri, v1[1]*tri, v1[0], v1[1],
-          v2[0]*tri, v2[1]*tri, v2[0], v2[1] );
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Misc
-#endif
-
-void ggl_init_trap(context_t* c)
-{
-    ggl_state_changed(c, GGL_PIXEL_PIPELINE_STATE|GGL_TMU_STATE|GGL_CB_STATE);
-}
-
-void ggl_state_changed(context_t* c, int flags)
-{
-    if (ggl_likely(!c->dirty)) {
-        c->procs.pointx     = pointx_validate;
-        c->procs.linex      = linex_validate;
-        c->procs.recti      = recti_validate;
-        c->procs.trianglex  = trianglex_validate;
-    }
-    c->dirty |= uint32_t(flags);
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Point
-#endif
-
-void pointx_validate(void *con, const GGLcoord* v, GGLcoord rad)
-{
-    GGL_CONTEXT(c, con);
-    ggl_pick(c);
-    if (c->state.needs.p & GGL_NEED_MASK(P_AA)) {
-        if (c->state.enables & GGL_ENABLE_POINT_AA_NICE) {
-            c->procs.pointx = aa_nice_pointx;
-        } else {
-            c->procs.pointx = aa_pointx;
-        }
-    } else {
-        c->procs.pointx = pointx;
-    }
-    c->procs.pointx(con, v, rad);
-}
-
-void pointx(void *con, const GGLcoord* v, GGLcoord rad)
-{
-    GGL_CONTEXT(c, con);
-    GGLcoord halfSize = TRI_ROUND(rad) >> 1;
-    if (halfSize == 0)
-        halfSize = TRI_HALF;
-    GGLcoord xc = v[0]; 
-    GGLcoord yc = v[1];
-    if (halfSize & TRI_HALF) { // size odd
-        xc = TRI_FLOOR(xc) + TRI_HALF;
-        yc = TRI_FLOOR(yc) + TRI_HALF;
-    } else { // size even
-        xc = TRI_ROUND(xc);
-        yc = TRI_ROUND(yc);
-    }
-    GGLint l = (xc - halfSize) >> TRI_FRACTION_BITS;
-    GGLint t = (yc - halfSize) >> TRI_FRACTION_BITS;
-    GGLint r = (xc + halfSize) >> TRI_FRACTION_BITS;
-    GGLint b = (yc + halfSize) >> TRI_FRACTION_BITS;
-    recti(c, l, t, r, b);
-}
-
-// This way of computing the coverage factor, is more accurate and gives
-// better results for small circles, but it is also a lot slower.
-// Here we use super-sampling.
-static int32_t coverageNice(GGLcoord x, GGLcoord y, 
-        GGLcoord rmin, GGLcoord rmax, GGLcoord rr)
-{
-    const GGLcoord d2 = x*x + y*y;
-    if (d2 >= rmax) return 0;
-    if (d2 < rmin)  return 0x7FFF;
-
-    const int kSamples              =  4;
-    const int kInc                  =  4;    // 1/4 = 0.25
-    const int kCoverageUnit         =  1;    // 1/(4^2) = 0.0625
-    const GGLcoord kCoordOffset     = -6;    // -0.375
-
-    int hits = 0;
-    int x_sample = x + kCoordOffset;
-    for (int i=0 ; i<kSamples ; i++, x_sample += kInc) {
-        const int xval = rr - (x_sample * x_sample);
-        int y_sample = y + kCoordOffset;
-        for (int j=0 ; j<kSamples ; j++, y_sample += kInc) {
-            if (xval - (y_sample * y_sample) > 0)
-                hits += kCoverageUnit;
-        }
-    }
-    return min(0x7FFF, hits << (15 - kSamples));
-}
-
-
-void aa_nice_pointx(void *con, const GGLcoord* v, GGLcoord size)
-{
-    GGL_CONTEXT(c, con);
-
-    GGLcoord rad = ((size + 1)>>1);
-    GGLint l = (v[0] - rad) >> TRI_FRACTION_BITS;
-    GGLint t = (v[1] - rad) >> TRI_FRACTION_BITS;
-    GGLint r = (v[0] + rad + (TRI_ONE-1)) >> TRI_FRACTION_BITS;
-    GGLint b = (v[1] + rad + (TRI_ONE-1)) >> TRI_FRACTION_BITS;
-    GGLcoord xstart = TRI_FROM_INT(l) - v[0] + TRI_HALF; 
-    GGLcoord ystart = TRI_FROM_INT(t) - v[1] + TRI_HALF; 
-
-    // scissor...
-    if (l < GGLint(c->state.scissor.left)) {
-        xstart += TRI_FROM_INT(c->state.scissor.left-l);
-        l = GGLint(c->state.scissor.left);
-    }
-    if (t < GGLint(c->state.scissor.top)) {
-        ystart += TRI_FROM_INT(c->state.scissor.top-t);
-        t = GGLint(c->state.scissor.top);
-    }
-    if (r > GGLint(c->state.scissor.right)) {
-        r = GGLint(c->state.scissor.right);
-    }
-    if (b > GGLint(c->state.scissor.bottom)) {
-        b = GGLint(c->state.scissor.bottom);
-    }
-
-    int xc = r - l;
-    int yc = b - t;
-    if (xc>0 && yc>0) {
-        int16_t* covPtr = c->state.buffers.coverage;
-        const int32_t sqr2Over2 = 0xC; // rounded up
-        GGLcoord rr = rad*rad;
-        GGLcoord rmin = (rad - sqr2Over2)*(rad - sqr2Over2);
-        GGLcoord rmax = (rad + sqr2Over2)*(rad + sqr2Over2);
-        GGLcoord y = ystart;
-        c->iterators.xl = l;
-        c->iterators.xr = r;
-        c->init_y(c, t);
-        do {
-            // compute coverage factors for each pixel
-            GGLcoord x = xstart;
-            for (int i=l ; i<r ; i++) {
-                covPtr[i] = coverageNice(x, y, rmin, rmax, rr);
-                x += TRI_ONE;
-            }
-            y += TRI_ONE;
-            c->scanline(c);
-            c->step_y(c);
-        } while (--yc);
-    }
-}
-
-// This is a cheap way of computing the coverage factor for a circle.
-// We just lerp between the circles of radii r-sqrt(2)/2 and r+sqrt(2)/2
-static inline int32_t coverageFast(GGLcoord x, GGLcoord y,
-        GGLcoord rmin, GGLcoord rmax, GGLcoord scale)
-{
-    const GGLcoord d2 = x*x + y*y;
-    if (d2 >= rmax) return 0;
-    if (d2 < rmin)  return 0x7FFF;
-    return 0x7FFF - (d2-rmin)*scale;
-}
-
-void aa_pointx(void *con, const GGLcoord* v, GGLcoord size)
-{
-    GGL_CONTEXT(c, con);
-
-    GGLcoord rad = ((size + 1)>>1);
-    GGLint l = (v[0] - rad) >> TRI_FRACTION_BITS;
-    GGLint t = (v[1] - rad) >> TRI_FRACTION_BITS;
-    GGLint r = (v[0] + rad + (TRI_ONE-1)) >> TRI_FRACTION_BITS;
-    GGLint b = (v[1] + rad + (TRI_ONE-1)) >> TRI_FRACTION_BITS;
-    GGLcoord xstart = TRI_FROM_INT(l) - v[0] + TRI_HALF; 
-    GGLcoord ystart = TRI_FROM_INT(t) - v[1] + TRI_HALF; 
-
-    // scissor...
-    if (l < GGLint(c->state.scissor.left)) {
-        xstart += TRI_FROM_INT(c->state.scissor.left-l);
-        l = GGLint(c->state.scissor.left);
-    }
-    if (t < GGLint(c->state.scissor.top)) {
-        ystart += TRI_FROM_INT(c->state.scissor.top-t);
-        t = GGLint(c->state.scissor.top);
-    }
-    if (r > GGLint(c->state.scissor.right)) {
-        r = GGLint(c->state.scissor.right);
-    }
-    if (b > GGLint(c->state.scissor.bottom)) {
-        b = GGLint(c->state.scissor.bottom);
-    }
-
-    int xc = r - l;
-    int yc = b - t;
-    if (xc>0 && yc>0) {
-        int16_t* covPtr = c->state.buffers.coverage;
-        rad <<= 4;
-        const int32_t sqr2Over2 = 0xB5;    // fixed-point 24.8
-        GGLcoord rmin = rad - sqr2Over2;
-        GGLcoord rmax = rad + sqr2Over2;
-        GGLcoord scale;
-        rmin *= rmin;
-        rmax *= rmax;
-        scale = 0x800000 / (rmax - rmin);
-        rmin >>= 8;
-        rmax >>= 8;
-
-        GGLcoord y = ystart;
-        c->iterators.xl = l;
-        c->iterators.xr = r;
-        c->init_y(c, t);
-
-        do {
-            // compute coverage factors for each pixel
-            GGLcoord x = xstart;
-            for (int i=l ; i<r ; i++) {
-                covPtr[i] = coverageFast(x, y, rmin, rmax, scale);
-                x += TRI_ONE;
-            }
-            y += TRI_ONE;
-            c->scanline(c);
-            c->step_y(c);
-        } while (--yc);
-    }
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Line
-#endif
-
-void linex_validate(void *con, const GGLcoord* v0, const GGLcoord* v1, GGLcoord w)
-{
-    GGL_CONTEXT(c, con);
-    ggl_pick(c);
-    if (c->state.needs.p & GGL_NEED_MASK(P_AA)) {
-        c->procs.linex = aa_linex;
-    } else {
-        c->procs.linex = linex;
-    }
-    c->procs.linex(con, v0, v1, w);
-}
-
-static void linex(void *con, const GGLcoord* v0, const GGLcoord* v1, GGLcoord width)
-{
-    GGLcoord v[4][2];
-    v[0][0] = v0[0];    v[0][1] = v0[1];
-    v[1][0] = v1[0];    v[1][1] = v1[1];
-    v0 = v[0];
-    v1 = v[1];
-    const GGLcoord dx = abs(v0[0] - v1[0]);
-    const GGLcoord dy = abs(v0[1] - v1[1]);
-    GGLcoord nx, ny;
-    nx = ny = 0;
-
-    GGLcoord halfWidth = TRI_ROUND(width) >> 1;
-    if (halfWidth == 0)
-        halfWidth = TRI_HALF;
-
-    ((dx > dy) ? ny : nx) = halfWidth;
-    v[2][0] = v1[0];    v[2][1] = v1[1];
-    v[3][0] = v0[0];    v[3][1] = v0[1];
-    v[0][0] += nx;      v[0][1] += ny;
-    v[1][0] += nx;      v[1][1] += ny;
-    v[2][0] -= nx;      v[2][1] -= ny;
-    v[3][0] -= nx;      v[3][1] -= ny;
-    trianglex_big(con, v[0], v[1], v[2]);
-    trianglex_big(con, v[0], v[2], v[3]);
-}
-
-static void aa_linex(void *con, const GGLcoord* v0, const GGLcoord* v1, GGLcoord width)
-{
-    GGLcoord v[4][2];
-    v[0][0] = v0[0];    v[0][1] = v0[1];
-    v[1][0] = v1[0];    v[1][1] = v1[1];
-    v0 = v[0];
-    v1 = v[1];
-    
-    const GGLcoord dx = v0[0] - v1[0];
-    const GGLcoord dy = v0[1] - v1[1];
-    GGLcoord nx = -dy;
-    GGLcoord ny =  dx;
-
-    // generally, this will be well below 1.0
-    const GGLfixed norm = gglMulx(width, gglSqrtRecipx(nx*nx+ny*ny), 4);
-    nx = gglMulx(nx, norm, 21);
-    ny = gglMulx(ny, norm, 21);
-    
-    v[2][0] = v1[0];    v[2][1] = v1[1];
-    v[3][0] = v0[0];    v[3][1] = v0[1];
-    v[0][0] += nx;      v[0][1] += ny;
-    v[1][0] += nx;      v[1][1] += ny;
-    v[2][0] -= nx;      v[2][1] -= ny;
-    v[3][0] -= nx;      v[3][1] -= ny;
-    aapolyx(con, v[0], 4);        
-}
-
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Rect
-#endif
-
-void recti_validate(void *con, GGLint l, GGLint t, GGLint r, GGLint b)
-{
-    GGL_CONTEXT(c, con);
-    ggl_pick(c);
-    c->procs.recti = recti;
-    c->procs.recti(con, l, t, r, b);
-}
-
-void recti(void* con, GGLint l, GGLint t, GGLint r, GGLint b)
-{
-    GGL_CONTEXT(c, con);
-
-    // scissor...
-    if (l < GGLint(c->state.scissor.left))
-        l = GGLint(c->state.scissor.left);
-    if (t < GGLint(c->state.scissor.top))
-        t = GGLint(c->state.scissor.top);
-    if (r > GGLint(c->state.scissor.right))
-        r = GGLint(c->state.scissor.right);
-    if (b > GGLint(c->state.scissor.bottom))
-        b = GGLint(c->state.scissor.bottom);
-
-    int xc = r - l;
-    int yc = b - t;
-    if (xc>0 && yc>0) {
-        c->iterators.xl = l;
-        c->iterators.xr = r;
-        c->init_y(c, t);
-        c->rect(c, yc);
-    }
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Triangle / Debugging
-#endif
-
-static void scanline_set(context_t* c)
-{
-    int32_t x = c->iterators.xl;
-    size_t ct = c->iterators.xr - x;
-    int32_t y = c->iterators.y;
-    surface_t* cb = &(c->state.buffers.color);
-    const GGLFormat* fp = &(c->formats[cb->format]);
-    uint8_t* dst = reinterpret_cast<uint8_t*>(cb->data) +
-                            (x + (cb->stride * y)) * fp->size;
-    const size_t size = ct * fp->size;
-    memset(dst, 0xFF, size);
-}
-
-static void trianglex_debug(void* con,
-        const GGLcoord* v0, const GGLcoord* v1, const GGLcoord* v2)
-{
-    GGL_CONTEXT(c, con);
-    if (c->state.needs.p & GGL_NEED_MASK(P_AA)) {
-        aa_trianglex(con,v0,v1,v2);
-    } else {
-        trianglex_big(con,v0,v1,v2);
-    }
-	void (*save_scanline)(context_t*)  = c->scanline;
-    c->scanline = scanline_set;
-    linex(con, v0, v1, TRI_ONE);
-    linex(con, v1, v2, TRI_ONE);
-    linex(con, v2, v0, TRI_ONE);
-    c->scanline = save_scanline;
-}
-
-static void trianglex_xor(void* con,
-        const GGLcoord* v0, const GGLcoord* v1, const GGLcoord* v2)
-{
-    trianglex_big(con,v0,v1,v2);
-    trianglex_small(con,v0,v1,v2);
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#pragma mark Triangle
-#endif
-
-void trianglex_validate(void *con,
-        const GGLcoord* v0, const GGLcoord* v1, const GGLcoord* v2)
-{
-    GGL_CONTEXT(c, con);
-    ggl_pick(c);
-    if (c->state.needs.p & GGL_NEED_MASK(P_AA)) {
-        c->procs.trianglex = DEBUG_TRANGLES ? trianglex_debug : aa_trianglex;
-    } else {
-        c->procs.trianglex = DEBUG_TRANGLES ? trianglex_debug : trianglex_big;
-    }
-    c->procs.trianglex(con, v0, v1, v2);
-}
-
-// ----------------------------------------------------------------------------
-
-void trianglex_small(void* con,
-        const GGLcoord* v0, const GGLcoord* v1, const GGLcoord* v2)
-{
-    GGL_CONTEXT(c, con);
-
-    // vertices are in 28.4 fixed point, which allows
-    // us to use 32 bits multiplies below.
-    int32_t x0 = v0[0];
-    int32_t y0 = v0[1];
-    int32_t x1 = v1[0];
-    int32_t y1 = v1[1];
-    int32_t x2 = v2[0];
-    int32_t y2 = v2[1];
-
-    int32_t dx01 = x0 - x1;
-    int32_t dy20 = y2 - y0;
-    int32_t dy01 = y0 - y1;
-    int32_t dx20 = x2 - x0;
-
-    // The code below works only with CCW triangles
-    // so if we get a CW triangle, we need to swap two of its vertices
-    if (dx01*dy20 < dy01*dx20) {
-        swap(x0, x1);
-        swap(y0, y1);
-        dx01 = x0 - x1;
-        dy01 = y0 - y1;
-        dx20 = x2 - x0;
-        dy20 = y2 - y0;
-    }
-    int32_t dx12 = x1 - x2;
-    int32_t dy12 = y1 - y2;
-
-    // bounding box & scissor
-    const int32_t bminx = TRI_FLOOR(min(x0, x1, x2)) >> TRI_FRACTION_BITS;
-    const int32_t bminy = TRI_FLOOR(min(y0, y1, y2)) >> TRI_FRACTION_BITS;
-    const int32_t bmaxx = TRI_CEIL( max(x0, x1, x2)) >> TRI_FRACTION_BITS;
-    const int32_t bmaxy = TRI_CEIL( max(y0, y1, y2)) >> TRI_FRACTION_BITS;
-    const int32_t minx = max(bminx, c->state.scissor.left);
-    const int32_t miny = max(bminy, c->state.scissor.top);
-    const int32_t maxx = min(bmaxx, c->state.scissor.right);
-    const int32_t maxy = min(bmaxy, c->state.scissor.bottom);
-    if ((minx >= maxx) || (miny >= maxy))
-        return; // too small or clipped out...
-
-    // step equations to the bounding box and snap to pixel center
-    const int32_t my = (miny << TRI_FRACTION_BITS) + TRI_HALF;
-    const int32_t mx = (minx << TRI_FRACTION_BITS) + TRI_HALF;
-    int32_t ey0 = dy01 * (x0 - mx) - dx01 * (y0 - my);
-    int32_t ey1 = dy12 * (x1 - mx) - dx12 * (y1 - my);
-    int32_t ey2 = dy20 * (x2 - mx) - dx20 * (y2 - my);
-
-    // right-exclusive fill rule, to avoid rare cases
-    // of over drawing
-    if (dy01<0 || (dy01 == 0 && dx01>0)) ey0++;
-    if (dy12<0 || (dy12 == 0 && dx12>0)) ey1++;
-    if (dy20<0 || (dy20 == 0 && dx20>0)) ey2++;
-    
-    c->init_y(c, miny);
-    for (int32_t y = miny; y < maxy; y++) {
-        int32_t ex0 = ey0;
-        int32_t ex1 = ey1;
-        int32_t ex2 = ey2;    
-        int32_t xl, xr;
-        for (xl=minx ; xl<maxx ; xl++) {
-            if (ex0>0 && ex1>0 && ex2>0)
-                break; // all strictly positive
-            ex0 -= dy01 << TRI_FRACTION_BITS;
-            ex1 -= dy12 << TRI_FRACTION_BITS;
-            ex2 -= dy20 << TRI_FRACTION_BITS;
-        }
-        xr = xl;
-        for ( ; xr<maxx ; xr++) {
-            if (!(ex0>0 && ex1>0 && ex2>0))
-                break; // not all strictly positive
-            ex0 -= dy01 << TRI_FRACTION_BITS;
-            ex1 -= dy12 << TRI_FRACTION_BITS;
-            ex2 -= dy20 << TRI_FRACTION_BITS;
-        }
-
-        if (xl < xr) {
-            c->iterators.xl = xl;
-            c->iterators.xr = xr;
-            c->scanline(c);
-        }
-        c->step_y(c);
-
-        ey0 += dx01 << TRI_FRACTION_BITS;
-        ey1 += dx12 << TRI_FRACTION_BITS;
-        ey2 += dx20 << TRI_FRACTION_BITS;
-    }
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#endif
-
-// the following routine fills a triangle via edge stepping, which
-// unfortunately requires divisions in the setup phase to get right,
-// it should probably only be used for relatively large trianges
-
-
-// x = y*DX/DY    (ou DX and DY are constants, DY > 0, et y >= 0)
-// 
-// for an equation of the type:
-//      x' = y*K/2^p     (with K and p constants "carefully chosen")
-// 
-// We can now do a DDA without precision loss. We define 'e' by:
-//      x' - x = y*(DX/DY - K/2^p) = y*e
-// 
-// If we choose K = round(DX*2^p/DY) then,
-//      abs(e) <= 1/2^(p+1) by construction
-// 
-// therefore abs(x'-x) = y*abs(e) <= y/2^(p+1) <= DY/2^(p+1) <= DMAX/2^(p+1)
-// 
-// which means that if DMAX <= 2^p, therefore abs(x-x') <= 1/2, including
-// at the last line. In fact, it's even a strict inequality except in one
-// extrem case (DY == DMAX et e = +/- 1/2)
-// 
-// Applying that to our coordinates, we need 2^p >= 4096*16 = 65536
-// so p = 16 is enough, we're so lucky!
-
-const int TRI_ITERATORS_BITS = 16;
-
-struct Edge
-{
-  int32_t  x;      // edge position in 16.16 coordinates
-  int32_t  x_incr; // on each step, increment x by that amount
-  int32_t  y_top;  // starting scanline, 16.4 format
-  int32_t  y_bot;
-};
-
-static void
-edge_dump( Edge*  edge )
-{
-  ALOGI( "  top=%d (%.3f)  bot=%d (%.3f)  x=%d (%.3f)  ix=%d (%.3f)",
-        edge->y_top, edge->y_top/float(TRI_ONE),
-		edge->y_bot, edge->y_bot/float(TRI_ONE),
-		edge->x, edge->x/float(FIXED_ONE),
-		edge->x_incr, edge->x_incr/float(FIXED_ONE) );
-}
-
-static void
-triangle_dump_edges( Edge*  edges,
-                     int            count )
-{ 
-    ALOGI( "%d edge%s:\n", count, count == 1 ? "" : "s" );
-	for ( ; count > 0; count--, edges++ )
-	  edge_dump( edges );
-}
-
-// the following function sets up an edge, it assumes
-// that ymin and ymax are in already in the 'reduced'
-// format
-static __attribute__((noinline))
-void edge_setup(
-        Edge*           edges,
-        int*            pcount,
-        const GGLcoord* p1,
-        const GGLcoord* p2,
-        int32_t         ymin,
-        int32_t         ymax )
-{
-	const GGLfixed*  top = p1;
-	const GGLfixed*  bot = p2;
-	Edge*    edge = edges + *pcount;
-
-	if (top[1] > bot[1]) {
-        swap(top, bot);
-	}
-
-	int  y1 = top[1] | 1;
-	int  y2 = bot[1] | 1;
-	int  dy = y2 - y1;
-
-	if ( dy == 0 || y1 > ymax || y2 < ymin )
-		return;
-
-	if ( y1 > ymin )
-		ymin = TRI_SNAP_NEXT_HALF(y1);
-	
-	if ( y2 < ymax )
-		ymax = TRI_SNAP_PREV_HALF(y2);
-
-	if ( ymin > ymax )  // when the edge doesn't cross any scanline
-	  return;
-
-	const int x1 = top[0];
-	const int dx = bot[0] - x1;
-    const int shift = TRI_ITERATORS_BITS - TRI_FRACTION_BITS;
-
-	// setup edge fields
-    // We add 0.5 to edge->x here because it simplifies the rounding
-    // in triangle_sweep_edges() -- this doesn't change the ordering of 'x'
-	edge->x      = (x1 << shift) + (1LU << (TRI_ITERATORS_BITS-1));
-	edge->x_incr = 0;
-	edge->y_top  = ymin;
-	edge->y_bot  = ymax;
-
-	if (ggl_likely(ymin <= ymax && dx)) {
-        edge->x_incr = gglDivQ16(dx, dy);
-    }
-    if (ggl_likely(y1 < ymin)) {
-        int32_t xadjust = (edge->x_incr * (ymin-y1)) >> TRI_FRACTION_BITS;
-        edge->x += xadjust;
-    }
-  
-	++*pcount;
-}
-
-
-static void
-triangle_sweep_edges( Edge*  left,
-                      Edge*  right,
-					  int            ytop,
-					  int            ybot,
-					  context_t*     c )
-{
-    int count = ((ybot - ytop)>>TRI_FRACTION_BITS) + 1;
-    if (count<=0) return;
-
-    // sort the edges horizontally
-    if ((left->x > right->x) || 
-        ((left->x == right->x) && (left->x_incr > right->x_incr))) {
-        swap(left, right);
-    }
-
-    int left_x = left->x;
-    int right_x = right->x;
-    const int left_xi = left->x_incr;
-    const int right_xi  = right->x_incr;
-    left->x  += left_xi * count;
-    right->x += right_xi * count;
-
-	const int xmin = c->state.scissor.left;
-	const int xmax = c->state.scissor.right;
-    do {
-        // horizontal scissoring
-        const int32_t xl = max(left_x  >> TRI_ITERATORS_BITS, xmin);
-        const int32_t xr = min(right_x >> TRI_ITERATORS_BITS, xmax);
-        left_x  += left_xi;
-        right_x += right_xi;
-        // invoke the scanline rasterizer
-        if (ggl_likely(xl < xr)) {
-            c->iterators.xl = xl;
-            c->iterators.xr = xr;
-            c->scanline(c);
-        }
-		c->step_y(c);
-	} while (--count);
-}
-
-
-void trianglex_big(void* con,
-        const GGLcoord* v0, const GGLcoord* v1, const GGLcoord* v2)
-{
-    GGL_CONTEXT(c, con);
-
-    Edge edges[3];
-	int num_edges = 0;
-	int32_t ymin = TRI_FROM_INT(c->state.scissor.top)    + TRI_HALF;
-	int32_t ymax = TRI_FROM_INT(c->state.scissor.bottom) - TRI_HALF;
-	    
-	edge_setup( edges, &num_edges, v0, v1, ymin, ymax );
-	edge_setup( edges, &num_edges, v0, v2, ymin, ymax );
-	edge_setup( edges, &num_edges, v1, v2, ymin, ymax );
-
-    if (ggl_unlikely(num_edges<2))  // for really tiny triangles that don't
-		return;                     // cross any scanline centers
-
-    Edge* left  = &edges[0];
-    Edge* right = &edges[1];
-    Edge* other = &edges[2];
-    int32_t y_top = min(left->y_top, right->y_top);
-    int32_t y_bot = max(left->y_bot, right->y_bot);
-
-	if (ggl_likely(num_edges==3)) {
-        y_top = min(y_top, edges[2].y_top);
-        y_bot = max(y_bot, edges[2].y_bot);
-		if (edges[0].y_top > y_top) {
-            other = &edges[0];
-            left  = &edges[2];
-		} else if (edges[1].y_top > y_top) {
-            other = &edges[1];
-            right = &edges[2];
-		}
-    }
-
-    c->init_y(c, y_top >> TRI_FRACTION_BITS);
-
-    int32_t y_mid = min(left->y_bot, right->y_bot);
-    triangle_sweep_edges( left, right, y_top, y_mid, c );
-
-    // second scanline sweep loop, if necessary
-    y_mid += TRI_ONE;
-    if (y_mid <= y_bot) {
-        ((left->y_bot == y_bot) ? right : left) = other;
-        if (other->y_top < y_mid) {
-            other->x += other->x_incr;
-        }
-        triangle_sweep_edges( left, right, y_mid, y_bot, c );
-    }
-}
-
-void aa_trianglex(void* con,
-        const GGLcoord* a, const GGLcoord* b, const GGLcoord* c)
-{
-    GGLcoord pts[6] = { a[0], a[1], b[0], b[1], c[0], c[1] };
-    aapolyx(con, pts, 3);
-}
-
-// ----------------------------------------------------------------------------
-#if 0
-#pragma mark -
-#endif
-
-struct AAEdge
-{
-    GGLfixed x;         // edge position in 12.16 coordinates
-    GGLfixed x_incr;    // on each y step, increment x by that amount
-    GGLfixed y_incr;    // on each x step, increment y by that amount
-    int16_t y_top;      // starting scanline, 12.4 format
-    int16_t y_bot;      // starting scanline, 12.4 format
-    void dump();
-};
-
-void AAEdge::dump()
-{
-    float tri  = 1.0f / TRI_ONE;
-    float iter = 1.0f / (1<<TRI_ITERATORS_BITS);
-    float fix  = 1.0f / FIXED_ONE;
-    ALOGD(   "x=%08x (%.3f), "
-            "x_incr=%08x (%.3f), y_incr=%08x (%.3f), "
-            "y_top=%08x (%.3f), y_bot=%08x (%.3f) ",
-        x, x*fix,
-        x_incr, x_incr*iter,
-        y_incr, y_incr*iter,
-        y_top, y_top*tri,
-        y_bot, y_bot*tri );
-}
-
-// the following function sets up an edge, it assumes
-// that ymin and ymax are in already in the 'reduced'
-// format
-static __attribute__((noinline))
-void aa_edge_setup(
-        AAEdge*         edges,
-        int*            pcount,
-        const GGLcoord* p1,
-        const GGLcoord* p2,
-        int32_t         ymin,
-        int32_t         ymax )
-{
-    const GGLfixed*  top = p1;
-    const GGLfixed*  bot = p2;
-    AAEdge* edge = edges + *pcount;
-
-    if (top[1] > bot[1])
-        swap(top, bot);
-
-    int  y1 = top[1];
-    int  y2 = bot[1];
-    int  dy = y2 - y1;
-
-    if (dy==0 || y1>ymax || y2<ymin)
-        return;
-
-    if (y1 > ymin)
-        ymin = y1;
-    
-    if (y2 < ymax)
-        ymax = y2;
-
-    const int x1 = top[0];
-    const int dx = bot[0] - x1;
-    const int shift = FIXED_BITS - TRI_FRACTION_BITS;
-
-    // setup edge fields
-    edge->x      = x1 << shift;
-    edge->x_incr = 0;
-    edge->y_top  = ymin;
-    edge->y_bot  = ymax;
-    edge->y_incr = 0x7FFFFFFF;
-
-    if (ggl_likely(ymin <= ymax && dx)) {
-        edge->x_incr = gglDivQ16(dx, dy);
-        if (dx != 0) {
-            edge->y_incr = abs(gglDivQ16(dy, dx));
-        }
-    }
-    if (ggl_likely(y1 < ymin)) {
-        int32_t xadjust = (edge->x_incr * (ymin-y1))
-                >> (TRI_FRACTION_BITS + TRI_ITERATORS_BITS - FIXED_BITS);
-        edge->x += xadjust;
-    }
-  
-    ++*pcount;
-}
-
-
-typedef int (*compar_t)(const void*, const void*);
-static int compare_edges(const AAEdge *e0, const AAEdge *e1) {
-    if (e0->y_top > e1->y_top)      return 1;
-    if (e0->y_top < e1->y_top)      return -1;
-    if (e0->x > e1->x)              return 1;
-    if (e0->x < e1->x)              return -1;
-    if (e0->x_incr > e1->x_incr)    return 1;
-    if (e0->x_incr < e1->x_incr)    return -1;
-    return 0; // same edges, should never happen
-}
-
-static inline 
-void SET_COVERAGE(int16_t*& p, int32_t value, ssize_t n)
-{
-    android_memset16((uint16_t*)p, value, n*2);
-    p += n;
-}
-
-static inline 
-void ADD_COVERAGE(int16_t*& p, int32_t value)
-{
-    value = *p + value;
-    if (value >= 0x8000)
-        value = 0x7FFF;
-    *p++ = value;
-}
-
-static inline
-void SUB_COVERAGE(int16_t*& p, int32_t value)
-{
-    value = *p - value;
-    value &= ~(value>>31);
-    *p++ = value;
-}
-
-void aapolyx(void* con,
-        const GGLcoord* pts, int count)
-{
-    /*
-     * NOTE: This routine assumes that the polygon has been clipped to the
-     * viewport already, that is, no vertex lies outside of the framebuffer.
-     * If this happens, the code below won't corrupt memory but the 
-     * coverage values may not be correct.
-     */
-    
-    GGL_CONTEXT(c, con);
-
-    // we do only quads for now (it's used for thick lines)
-    if ((count>4) || (count<2)) return;
-
-    // take scissor into account
-    const int xmin = c->state.scissor.left;
-    const int xmax = c->state.scissor.right;
-    if (xmin >= xmax) return;
-
-    // generate edges from the vertices
-    int32_t ymin = TRI_FROM_INT(c->state.scissor.top);
-    int32_t ymax = TRI_FROM_INT(c->state.scissor.bottom);
-    if (ymin >= ymax) return;
-
-    AAEdge edges[4];
-    int num_edges = 0;
-    GGLcoord const * p = pts;
-    for (int i=0 ; i<count-1 ; i++, p+=2) {
-        aa_edge_setup(edges, &num_edges, p, p+2, ymin, ymax);
-    }
-    aa_edge_setup(edges, &num_edges, p, pts, ymin, ymax );
-    if (ggl_unlikely(num_edges<2))
-        return;
-
-    // sort the edge list top to bottom, left to right.
-    qsort(edges, num_edges, sizeof(AAEdge), (compar_t)compare_edges);
-
-    int16_t* const covPtr = c->state.buffers.coverage;
-    memset(covPtr+xmin, 0, (xmax-xmin)*sizeof(*covPtr));
-
-    // now, sweep all edges in order
-    // start with the 2 first edges. We know that they share their top
-    // vertex, by construction.
-    int i = 2;
-    AAEdge* left  = &edges[0];
-    AAEdge* right = &edges[1];
-    int32_t yt = left->y_top;
-    GGLfixed l = left->x;
-    GGLfixed r = right->x;
-    int retire = 0;
-    int16_t* coverage;
-
-    // at this point we can initialize the rasterizer    
-    c->init_y(c, yt>>TRI_FRACTION_BITS);
-    c->iterators.xl = xmax;
-    c->iterators.xr = xmin;
-
-    do {
-        int32_t y = min(min(left->y_bot, right->y_bot), TRI_FLOOR(yt + TRI_ONE));
-        const int32_t shift = TRI_FRACTION_BITS + TRI_ITERATORS_BITS - FIXED_BITS;
-        const int cf_shift = (1 + TRI_FRACTION_BITS*2 + TRI_ITERATORS_BITS - 15);
-
-        // compute xmin and xmax for the left edge
-        GGLfixed l_min = gglMulAddx(left->x_incr, y - left->y_top, left->x, shift);
-        GGLfixed l_max = l;
-        l = l_min;
-        if (l_min > l_max)
-            swap(l_min, l_max);
-
-        // compute xmin and xmax for the right edge
-        GGLfixed r_min = gglMulAddx(right->x_incr, y - right->y_top, right->x, shift);
-        GGLfixed r_max = r;
-        r = r_min;
-        if (r_min > r_max)
-            swap(r_min, r_max);
-
-        // make sure we're not touching coverage values outside of the
-        // framebuffer
-        l_min &= ~(l_min>>31);
-        r_min &= ~(r_min>>31);
-        l_max &= ~(l_max>>31);
-        r_max &= ~(r_max>>31);
-        if (gglFixedToIntFloor(l_min) >= xmax) l_min = gglIntToFixed(xmax)-1;
-        if (gglFixedToIntFloor(r_min) >= xmax) r_min = gglIntToFixed(xmax)-1;
-        if (gglFixedToIntCeil(l_max) >= xmax)  l_max = gglIntToFixed(xmax)-1;
-        if (gglFixedToIntCeil(r_max) >= xmax)  r_max = gglIntToFixed(xmax)-1;
-
-        // compute the integer versions of the above
-        const GGLfixed l_min_i = gglFloorx(l_min);
-        const GGLfixed l_max_i = gglCeilx (l_max);
-        const GGLfixed r_min_i = gglFloorx(r_min);
-        const GGLfixed r_max_i = gglCeilx (r_max);
-
-        // clip horizontally using the scissor
-        const int xml = max(xmin, gglFixedToIntFloor(l_min_i));
-        const int xmr = min(xmax, gglFixedToIntFloor(r_max_i));
-
-        // if we just stepped to a new scanline, render the previous one.
-        // and clear the coverage buffer
-        if (retire) {
-            if (c->iterators.xl < c->iterators.xr)
-                c->scanline(c);
-            c->step_y(c);
-            memset(covPtr+xmin, 0, (xmax-xmin)*sizeof(*covPtr));
-            c->iterators.xl = xml;
-            c->iterators.xr = xmr;
-        } else {
-            // update the horizontal range of this scanline
-            c->iterators.xl = min(c->iterators.xl, xml);
-            c->iterators.xr = max(c->iterators.xr, xmr);
-        }
-
-        coverage = covPtr + gglFixedToIntFloor(l_min_i);
-        if (l_min_i == gglFloorx(l_max)) {
-            
-            /*
-             *  fully traverse this pixel vertically
-             *       l_max
-             *  +-----/--+  yt
-             *  |    /   |  
-             *  |   /    |
-             *  |  /     |
-             *  +-/------+  y
-             *   l_min  (l_min_i + TRI_ONE)
-             */
-              
-            GGLfixed dx = l_max - l_min;
-            int32_t dy = y - yt;
-            int cf = gglMulx((dx >> 1) + (l_min_i + FIXED_ONE - l_max), dy,
-                FIXED_BITS + TRI_FRACTION_BITS - 15);
-            ADD_COVERAGE(coverage, cf);
-            // all pixels on the right have cf = 1.0
-        } else {
-            /*
-             *  spans several pixels in one scanline
-             *            l_max
-             *  +--------+--/-----+  yt
-             *  |        |/       |
-             *  |       /|        |
-             *  |     /  |        |
-             *  +---/----+--------+  y
-             *   l_min (l_min_i + TRI_ONE)
-             */
-
-            // handle the first pixel separately...
-            const int32_t y_incr = left->y_incr;
-            int32_t dx = TRI_FROM_FIXED(l_min_i - l_min) + TRI_ONE;
-            int32_t cf = (dx * dx * y_incr) >> cf_shift;
-            ADD_COVERAGE(coverage, cf);
-
-            // following pixels get covered by y_incr, but we need
-            // to fix-up the cf to account for previous partial pixel
-            dx = TRI_FROM_FIXED(l_min - l_min_i);
-            cf -= (dx * dx * y_incr) >> cf_shift;
-            for (int x = l_min_i+FIXED_ONE ; x < l_max_i-FIXED_ONE ; x += FIXED_ONE) {
-                cf += y_incr >> (TRI_ITERATORS_BITS-15);
-                ADD_COVERAGE(coverage, cf);
-            }
-            
-            // and the last pixel
-            dx = TRI_FROM_FIXED(l_max - l_max_i) - TRI_ONE;
-            cf += (dx * dx * y_incr) >> cf_shift;
-            ADD_COVERAGE(coverage, cf);
-        }
-        
-        // now, fill up all fully covered pixels
-        coverage = covPtr + gglFixedToIntFloor(l_max_i);
-        int cf = ((y - yt) << (15 - TRI_FRACTION_BITS));
-        if (ggl_likely(cf >= 0x8000)) {
-            SET_COVERAGE(coverage, 0x7FFF, ((r_max - l_max_i)>>FIXED_BITS)+1);
-        } else {
-            for (int x=l_max_i ; x<r_max ; x+=FIXED_ONE) {
-                ADD_COVERAGE(coverage, cf);
-            }
-        }
-        
-        // subtract the coverage of the right edge
-        coverage = covPtr + gglFixedToIntFloor(r_min_i); 
-        if (r_min_i == gglFloorx(r_max)) {
-            GGLfixed dx = r_max - r_min;
-            int32_t dy = y - yt;
-            int cf = gglMulx((dx >> 1) + (r_min_i + FIXED_ONE - r_max), dy,
-                FIXED_BITS + TRI_FRACTION_BITS - 15);
-            SUB_COVERAGE(coverage, cf);
-            // all pixels on the right have cf = 1.0
-        } else {
-            // handle the first pixel separately...
-            const int32_t y_incr = right->y_incr;
-            int32_t dx = TRI_FROM_FIXED(r_min_i - r_min) + TRI_ONE;
-            int32_t cf = (dx * dx * y_incr) >> cf_shift;
-            SUB_COVERAGE(coverage, cf);
-            
-            // following pixels get covered by y_incr, but we need
-            // to fix-up the cf to account for previous partial pixel
-            dx = TRI_FROM_FIXED(r_min - r_min_i);
-            cf -= (dx * dx * y_incr) >> cf_shift;
-            for (int x = r_min_i+FIXED_ONE ; x < r_max_i-FIXED_ONE ; x += FIXED_ONE) {
-                cf += y_incr >> (TRI_ITERATORS_BITS-15);
-                SUB_COVERAGE(coverage, cf);
-            }
-            
-            // and the last pixel
-            dx = TRI_FROM_FIXED(r_max - r_max_i) - TRI_ONE;
-            cf += (dx * dx * y_incr) >> cf_shift;
-            SUB_COVERAGE(coverage, cf);
-        }
-
-        // did we reach the end of an edge? if so, get a new one.
-        if (y == left->y_bot || y == right->y_bot) {
-            // bail out if we're done
-            if (i>=num_edges)
-                break;
-            if (y == left->y_bot)
-                left = &edges[i++];
-            if (y == right->y_bot)
-                right = &edges[i++];
-        }
-
-        // next scanline
-        yt = y;
-        
-        // did we just finish a scanline?        
-        retire = (y << (32-TRI_FRACTION_BITS)) == 0;
-    } while (true);
-
-    // render the last scanline
-    if (c->iterators.xl < c->iterators.xr)
-        c->scanline(c);
-}
-
-}; // namespace android
diff --git a/libpixelflinger/trap.h b/libpixelflinger/trap.h
deleted file mode 100644
index 7cce7b3..0000000
--- a/libpixelflinger/trap.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* libs/pixelflinger/trap.h
-**
-** Copyright 2006, 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_TRAP_H
-#define ANDROID_TRAP_H
-
-#include <private/pixelflinger/ggl_context.h>
-
-namespace android {
-
-void ggl_init_trap(context_t* c);
-void ggl_state_changed(context_t* c, int flags);
-
-}; // namespace android
-
-#endif
diff --git a/libprocessgroup/profiles/Android.bp b/libprocessgroup/profiles/Android.bp
index ccc6f62..c371ef7 100644
--- a/libprocessgroup/profiles/Android.bp
+++ b/libprocessgroup/profiles/Android.bp
@@ -104,8 +104,3 @@
         "vts",
     ],
 }
-
-vts_config {
-    name: "VtsProcessgroupValidateTest",
-    test_config: "vts_processgroup_validate_test.xml",
-}
diff --git a/libprocessgroup/profiles/cgroups.json b/libprocessgroup/profiles/cgroups.json
index 0341902..4518487 100644
--- a/libprocessgroup/profiles/cgroups.json
+++ b/libprocessgroup/profiles/cgroups.json
@@ -39,19 +39,21 @@
       "Mode": "0755",
       "UID": "system",
       "GID": "system"
-    },
-    {
-      "Controller": "freezer",
-      "Path": "/dev/freezer",
-      "Mode": "0755",
-      "UID": "system",
-      "GID": "system"
     }
   ],
   "Cgroups2": {
-    "Path": "/dev/cg2_bpf",
-    "Mode": "0600",
-    "UID": "root",
-    "GID": "root"
+    "Path": "/sys/fs/cgroup",
+    "Mode": "0755",
+    "UID": "system",
+    "GID": "system",
+    "Controllers": [
+      {
+        "Controller": "freezer",
+        "Path": "freezer",
+        "Mode": "0755",
+        "UID": "system",
+        "GID": "system"
+      }
+    ]
   }
 }
diff --git a/libprocessgroup/profiles/cgroups.proto b/libprocessgroup/profiles/cgroups.proto
index f4070c5..13adcae 100644
--- a/libprocessgroup/profiles/cgroups.proto
+++ b/libprocessgroup/profiles/cgroups.proto
@@ -24,19 +24,24 @@
     Cgroups2 cgroups2 = 2 [json_name = "Cgroups2"];
 }
 
-// Next: 6
+// Next: 7
 message Cgroup {
     string controller = 1 [json_name = "Controller"];
     string path = 2 [json_name = "Path"];
     string mode = 3 [json_name = "Mode"];
     string uid = 4 [json_name = "UID"];
     string gid = 5 [json_name = "GID"];
+// Booleans default to false when not specified. File reconstruction fails
+// when a boolean is specified as false, so leave unspecified in that case
+// https://developers.google.com/protocol-buffers/docs/proto3#default
+    bool needs_activation = 6 [json_name = "NeedsActivation"];
 }
 
-// Next: 5
+// Next: 6
 message Cgroups2 {
     string path = 1 [json_name = "Path"];
     string mode = 2 [json_name = "Mode"];
     string uid = 3 [json_name = "UID"];
     string gid = 4 [json_name = "GID"];
+    repeated Cgroup controllers = 5 [json_name = "Controllers"];
 }
diff --git a/libprocessgroup/profiles/task_profiles.json b/libprocessgroup/profiles/task_profiles.json
index a515e58..c4dbf8e 100644
--- a/libprocessgroup/profiles/task_profiles.json
+++ b/libprocessgroup/profiles/task_profiles.json
@@ -49,6 +49,11 @@
       "Name": "UClampMax",
       "Controller": "cpu",
       "File": "cpu.uclamp.max"
+    },
+    {
+      "Name": "FreezerState",
+      "Controller": "freezer",
+      "File": "cgroup.freeze"
     }
   ],
 
@@ -74,7 +79,7 @@
           "Params":
           {
             "Controller": "freezer",
-            "Path": "frozen"
+            "Path": ""
           }
         }
       ]
@@ -87,7 +92,7 @@
           "Params":
           {
             "Controller": "freezer",
-            "Path": ""
+            "Path": "../"
           }
         }
       ]
@@ -531,6 +536,32 @@
           }
         }
       ]
+    },
+    {
+      "Name": "FreezerDisabled",
+      "Actions": [
+        {
+          "Name": "SetAttribute",
+          "Params":
+          {
+            "Name": "FreezerState",
+            "Value": "0"
+          }
+        }
+      ]
+    },
+    {
+      "Name": "FreezerEnabled",
+      "Actions": [
+        {
+          "Name": "SetAttribute",
+          "Params":
+          {
+            "Name": "FreezerState",
+            "Value": "1"
+          }
+        }
+      ]
     }
   ],
 
diff --git a/libprocessgroup/profiles/vts_processgroup_validate_test.xml b/libprocessgroup/profiles/vts_processgroup_validate_test.xml
deleted file mode 100644
index 21d29cd..0000000
--- a/libprocessgroup/profiles/vts_processgroup_validate_test.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 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.
--->
-<configuration description="Config for VtsProcessgroupValidateTest">
-    <option name="config-descriptor:metadata" key="plan" value="vts-treble" />
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
-        <option name="abort-on-push-failure" value="false"/>
-        <option name="push-group" value="HostDrivenTest.push"/>
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
-        <option name="test-module-name" value="VtsProcessgroupValidateTest"/>
-        <option name="binary-test-working-directory" value="_32bit::/data/nativetest/" />
-        <option name="binary-test-working-directory" value="_64bit::/data/nativetest64/" />
-        <option name="binary-test-source" value="_32bit::DATA/nativetest/vts_processgroup_validate_test/vts_processgroup_validate_test" />
-        <option name="binary-test-source" value="_64bit::DATA/nativetest64/vts_processgroup_validate_test/vts_processgroup_validate_test" />
-        <option name="binary-test-type" value="gtest"/>
-        <option name="binary-test-disable-framework" value="false"/>
-        <option name="test-timeout" value="30s"/>
-    </test>
-</configuration>
diff --git a/libsparse/Android.bp b/libsparse/Android.bp
index 135904b..bf06bbc 100644
--- a/libsparse/Android.bp
+++ b/libsparse/Android.bp
@@ -6,6 +6,7 @@
     ramdisk_available: true,
     recovery_available: true,
     unique_host_soname: true,
+    vendor_available: true,
     srcs: [
         "backed_block.cpp",
         "output_file.cpp",
diff --git a/libstats/pull/Android.bp b/libstats/pull/Android.bp
new file mode 100644
index 0000000..a8b4a4f
--- /dev/null
+++ b/libstats/pull/Android.bp
@@ -0,0 +1,110 @@
+//
+// Copyright (C) 2019 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.
+//
+
+// ==========================================================
+// Native library to register a pull atom callback with statsd
+// ==========================================================
+cc_defaults {
+    name: "libstatspull_defaults",
+    srcs: [
+        "stats_pull_atom_callback.cpp",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    export_include_dirs: ["include"],
+    shared_libs: [
+        "libbinder_ndk",
+        "liblog",
+        "libstatssocket",
+    ],
+    static_libs: [
+        "libutils",
+        "statsd-aidl-ndk_platform",
+    ],
+}
+cc_library_shared {
+    name: "libstatspull",
+    defaults: [
+        "libstatspull_defaults"
+    ],
+    // enumerate stable entry points for APEX use
+    stubs: {
+        symbol_file: "libstatspull.map.txt",
+        versions: [
+            "30",
+        ],
+    },
+    apex_available: [
+        "com.android.os.statsd",
+        "test_com.android.os.statsd",
+    ],
+
+    stl: "libc++_static",
+
+    // TODO(b/151102177): Enable it when the build error is fixed.
+    header_abi_checker: {
+        enabled: false,
+    },
+}
+
+// ONLY USE IN TESTS.
+cc_library_static {
+    name: "libstatspull_private",
+    defaults: [
+        "libstatspull_defaults",
+    ],
+    visibility: [
+        "//frameworks/base/apex/statsd/tests/libstatspull",
+    ],
+}
+
+// Note: These unit tests only test PullAtomMetadata.
+// For full E2E tests of libstatspull, use LibStatsPullTests
+cc_test {
+    name: "libstatspull_test",
+    srcs: [
+        "tests/pull_atom_metadata_test.cpp",
+    ],
+    shared_libs: [
+        "libstatspull",
+        "libstatssocket",
+    ],
+    test_suites: ["general-tests", "mts"],
+    test_config: "libstatspull_test.xml",
+
+    //TODO(b/153588990): Remove when the build system properly separates 
+    //32bit and 64bit architectures.
+    compile_multilib: "both",
+    multilib: {
+        lib64: {
+            suffix: "64",
+        },
+        lib32: {
+            suffix: "32",
+        },
+    },
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-variable",
+        "-Wno-unused-function",
+        "-Wno-unused-parameter",
+    ],
+    require_root: true,
+}
diff --git a/libstats/pull/OWNERS b/libstats/pull/OWNERS
new file mode 100644
index 0000000..7855774
--- /dev/null
+++ b/libstats/pull/OWNERS
@@ -0,0 +1,7 @@
+joeo@google.com
+muhammadq@google.com
+ruchirr@google.com
+singhtejinder@google.com
+tsaichristine@google.com
+yaochen@google.com
+yro@google.com
diff --git a/libstats/pull/TEST_MAPPING b/libstats/pull/TEST_MAPPING
new file mode 100644
index 0000000..76f4f02
--- /dev/null
+++ b/libstats/pull/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+  "presubmit" : [
+    {
+      "name" : "libstatspull_test"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/libstats/pull/include/stats_pull_atom_callback.h b/libstats/pull/include/stats_pull_atom_callback.h
new file mode 100644
index 0000000..17df584
--- /dev/null
+++ b/libstats/pull/include/stats_pull_atom_callback.h
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2019, 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 <stats_event.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Opaque struct representing the metadata for registering an AStatsManager_PullAtomCallback.
+ */
+struct AStatsManager_PullAtomMetadata;
+typedef struct AStatsManager_PullAtomMetadata AStatsManager_PullAtomMetadata;
+
+/**
+ * Allocate and initialize new PullAtomMetadata.
+ *
+ * Must call AStatsManager_PullAtomMetadata_release to free the memory.
+ */
+AStatsManager_PullAtomMetadata* AStatsManager_PullAtomMetadata_obtain();
+
+/**
+ * Frees the memory held by this PullAtomMetadata
+ *
+ * After calling this, the PullAtomMetadata must not be used or modified in any way.
+ */
+void AStatsManager_PullAtomMetadata_release(AStatsManager_PullAtomMetadata* metadata);
+
+/**
+ * Set the cool down time of the pull in milliseconds. If two successive pulls are issued
+ * within the cool down, a cached version of the first will be used for the second. The minimum
+ * allowed cool down is one second.
+ */
+void AStatsManager_PullAtomMetadata_setCoolDownMillis(AStatsManager_PullAtomMetadata* metadata,
+                                                      int64_t cool_down_millis);
+
+/**
+ * Get the cool down time of the pull in milliseconds.
+ */
+int64_t AStatsManager_PullAtomMetadata_getCoolDownMillis(AStatsManager_PullAtomMetadata* metadata);
+
+/**
+ * Set the maximum time the pull can take in milliseconds.
+ * The maximum allowed timeout is 10 seconds.
+ */
+void AStatsManager_PullAtomMetadata_setTimeoutMillis(AStatsManager_PullAtomMetadata* metadata,
+                                                     int64_t timeout_millis);
+
+/**
+ * Get the maximum time the pull can take in milliseconds.
+ */
+int64_t AStatsManager_PullAtomMetadata_getTimeoutMillis(AStatsManager_PullAtomMetadata* metadata);
+
+/**
+ * Set the additive fields of this pulled atom.
+ *
+ * This is only applicable for atoms which have a uid field. When tasks are run in
+ * isolated processes, the data will be attributed to the host uid. Additive fields
+ * will be combined when the non-additive fields are the same.
+ */
+void AStatsManager_PullAtomMetadata_setAdditiveFields(AStatsManager_PullAtomMetadata* metadata,
+                                                      int32_t* additive_fields, int32_t num_fields);
+
+/**
+ * Get the number of additive fields for this pulled atom. This is intended to be called before
+ * AStatsManager_PullAtomMetadata_getAdditiveFields to determine the size of the array.
+ */
+int32_t AStatsManager_PullAtomMetadata_getNumAdditiveFields(
+        AStatsManager_PullAtomMetadata* metadata);
+
+/**
+ * Get the additive fields of this pulled atom.
+ *
+ * \param fields an output parameter containing the additive fields for this PullAtomMetadata.
+ *               Fields is an array and it is assumed that it is at least as large as the number of
+ *               additive fields, which can be obtained by calling
+ *               AStatsManager_PullAtomMetadata_getNumAdditiveFields.
+ */
+void AStatsManager_PullAtomMetadata_getAdditiveFields(AStatsManager_PullAtomMetadata* metadata,
+                                                      int32_t* fields);
+
+/**
+ * Return codes for the result of a pull.
+ */
+typedef int32_t AStatsManager_PullAtomCallbackReturn;
+enum {
+    // Value indicating that this pull was successful and that the result should be used.
+    AStatsManager_PULL_SUCCESS = 0,
+    // Value indicating that this pull was unsuccessful and that the result should not be used.
+    AStatsManager_PULL_SKIP = 1,
+};
+
+/**
+ * Opaque struct representing a list of AStatsEvent objects.
+ */
+struct AStatsEventList;
+typedef struct AStatsEventList AStatsEventList;
+
+/**
+ * Appends and returns an AStatsEvent to the end of the AStatsEventList.
+ *
+ * If an AStatsEvent is obtained in this manner, the memory is internally managed and
+ * AStatsEvent_release does not need to be called. The lifetime of the AStatsEvent is that of the
+ * AStatsEventList.
+ *
+ * The AStatsEvent does still need to be built by calling AStatsEvent_build.
+ */
+AStatsEvent* AStatsEventList_addStatsEvent(AStatsEventList* pull_data);
+
+/**
+ * Callback interface for pulling atoms requested by the stats service.
+ *
+ * \param atom_tag the tag of the atom to pull.
+ * \param data an output parameter in which the caller should fill the results of the pull. This
+ *             param cannot be NULL and it's lifetime is as long as the execution of the callback.
+ *             It must not be accessed or modified after returning from the callback.
+ * \param cookie the opaque pointer passed in AStatsManager_registerPullAtomCallback.
+ * \return AStatsManager_PULL_SUCCESS if the pull was successful, or AStatsManager_PULL_SKIP if not.
+ */
+typedef AStatsManager_PullAtomCallbackReturn (*AStatsManager_PullAtomCallback)(
+        int32_t atom_tag, AStatsEventList* data, void* cookie);
+/**
+ * Sets a callback for an atom when that atom is to be pulled. The stats service will
+ * invoke the callback when the stats service determines that this atom needs to be
+ * pulled.
+ *
+ * Requires the REGISTER_STATS_PULL_ATOM permission.
+ *
+ * \param atom_tag          The tag of the atom for this pull atom callback.
+ * \param metadata          Optional metadata specifying the timeout, cool down time, and
+ *                          additive fields for mapping isolated to host uids.
+ *                          This param is nullable, in which case defaults will be used.
+ * \param callback          The callback to be invoked when the stats service pulls the atom.
+ * \param cookie            A pointer that will be passed back to the callback.
+ *                          It has no meaning to statsd.
+ */
+void AStatsManager_setPullAtomCallback(int32_t atom_tag, AStatsManager_PullAtomMetadata* metadata,
+                                       AStatsManager_PullAtomCallback callback, void* cookie);
+
+/**
+ * Clears a callback for an atom when that atom is to be pulled. Note that any ongoing
+ * pulls will still occur.
+ *
+ * Requires the REGISTER_STATS_PULL_ATOM permission.
+ *
+ * \param atomTag           The tag of the atom of which to unregister
+ */
+void AStatsManager_clearPullAtomCallback(int32_t atom_tag);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/libstats/pull/libstatspull.map.txt b/libstats/pull/libstatspull.map.txt
new file mode 100644
index 0000000..e0e851a
--- /dev/null
+++ b/libstats/pull/libstatspull.map.txt
@@ -0,0 +1,17 @@
+LIBSTATSPULL {
+    global:
+        AStatsManager_PullAtomMetadata_obtain; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_release; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_setCoolDownMillis; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_getCoolDownMillis; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_setTimeoutMillis; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_getTimeoutMillis; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_setAdditiveFields; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_getNumAdditiveFields; # apex # introduced=30
+        AStatsManager_PullAtomMetadata_getAdditiveFields; # apex # introduced=30
+        AStatsEventList_addStatsEvent; # apex # introduced=30
+        AStatsManager_setPullAtomCallback; # apex # introduced=30
+        AStatsManager_clearPullAtomCallback; # apex # introduced=30
+    local:
+        *;
+};
diff --git a/libstats/pull/libstatspull_test.xml b/libstats/pull/libstatspull_test.xml
new file mode 100644
index 0000000..233fc1f
--- /dev/null
+++ b/libstats/pull/libstatspull_test.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+<configuration description="Runs libstatspull_test.">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-native" />
+    <option name="test-suite-tag" value="mts" />
+
+    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+       <option name="cleanup" value="true" />
+       <option name="push" value="libstatspull_test->/data/local/tmp/libstatspull_test" />
+       <option name="append-bitness" value="true" />
+    </target_preparer>
+
+    <test class="com.android.tradefed.testtype.GTest" >
+        <option name="native-test-device-path" value="/data/local/tmp" />
+        <option name="module-name" value="libstatspull_test" />
+    </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.os.statsd" />
+    </object>
+</configuration>
diff --git a/libstats/pull/stats_pull_atom_callback.cpp b/libstats/pull/stats_pull_atom_callback.cpp
new file mode 100644
index 0000000..478cae7
--- /dev/null
+++ b/libstats/pull/stats_pull_atom_callback.cpp
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2019, 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 <map>
+#include <thread>
+#include <vector>
+
+#include <stats_event.h>
+#include <stats_pull_atom_callback.h>
+
+#include <aidl/android/os/BnPullAtomCallback.h>
+#include <aidl/android/os/IPullAtomResultReceiver.h>
+#include <aidl/android/os/IStatsd.h>
+#include <aidl/android/util/StatsEventParcel.h>
+#include <android/binder_auto_utils.h>
+#include <android/binder_ibinder.h>
+#include <android/binder_manager.h>
+
+using Status = ::ndk::ScopedAStatus;
+using aidl::android::os::BnPullAtomCallback;
+using aidl::android::os::IPullAtomResultReceiver;
+using aidl::android::os::IStatsd;
+using aidl::android::util::StatsEventParcel;
+using ::ndk::SharedRefBase;
+
+struct AStatsEventList {
+    std::vector<AStatsEvent*> data;
+};
+
+AStatsEvent* AStatsEventList_addStatsEvent(AStatsEventList* pull_data) {
+    AStatsEvent* event = AStatsEvent_obtain();
+    pull_data->data.push_back(event);
+    return event;
+}
+
+static const int64_t DEFAULT_COOL_DOWN_MILLIS = 1000LL;  // 1 second.
+static const int64_t DEFAULT_TIMEOUT_MILLIS = 2000LL;    // 2 seconds.
+
+struct AStatsManager_PullAtomMetadata {
+    int64_t cool_down_millis;
+    int64_t timeout_millis;
+    std::vector<int32_t> additive_fields;
+};
+
+AStatsManager_PullAtomMetadata* AStatsManager_PullAtomMetadata_obtain() {
+    AStatsManager_PullAtomMetadata* metadata = new AStatsManager_PullAtomMetadata();
+    metadata->cool_down_millis = DEFAULT_COOL_DOWN_MILLIS;
+    metadata->timeout_millis = DEFAULT_TIMEOUT_MILLIS;
+    metadata->additive_fields = std::vector<int32_t>();
+    return metadata;
+}
+
+void AStatsManager_PullAtomMetadata_release(AStatsManager_PullAtomMetadata* metadata) {
+    delete metadata;
+}
+
+void AStatsManager_PullAtomMetadata_setCoolDownMillis(AStatsManager_PullAtomMetadata* metadata,
+                                                      int64_t cool_down_millis) {
+    metadata->cool_down_millis = cool_down_millis;
+}
+
+int64_t AStatsManager_PullAtomMetadata_getCoolDownMillis(AStatsManager_PullAtomMetadata* metadata) {
+    return metadata->cool_down_millis;
+}
+
+void AStatsManager_PullAtomMetadata_setTimeoutMillis(AStatsManager_PullAtomMetadata* metadata,
+                                                     int64_t timeout_millis) {
+    metadata->timeout_millis = timeout_millis;
+}
+
+int64_t AStatsManager_PullAtomMetadata_getTimeoutMillis(AStatsManager_PullAtomMetadata* metadata) {
+    return metadata->timeout_millis;
+}
+
+void AStatsManager_PullAtomMetadata_setAdditiveFields(AStatsManager_PullAtomMetadata* metadata,
+                                                      int32_t* additive_fields,
+                                                      int32_t num_fields) {
+    metadata->additive_fields.assign(additive_fields, additive_fields + num_fields);
+}
+
+int32_t AStatsManager_PullAtomMetadata_getNumAdditiveFields(
+        AStatsManager_PullAtomMetadata* metadata) {
+    return metadata->additive_fields.size();
+}
+
+void AStatsManager_PullAtomMetadata_getAdditiveFields(AStatsManager_PullAtomMetadata* metadata,
+                                                      int32_t* fields) {
+    std::copy(metadata->additive_fields.begin(), metadata->additive_fields.end(), fields);
+}
+
+class StatsPullAtomCallbackInternal : public BnPullAtomCallback {
+  public:
+    StatsPullAtomCallbackInternal(const AStatsManager_PullAtomCallback callback, void* cookie,
+                                  const int64_t coolDownMillis, const int64_t timeoutMillis,
+                                  const std::vector<int32_t> additiveFields)
+        : mCallback(callback),
+          mCookie(cookie),
+          mCoolDownMillis(coolDownMillis),
+          mTimeoutMillis(timeoutMillis),
+          mAdditiveFields(additiveFields) {}
+
+    Status onPullAtom(int32_t atomTag,
+                      const std::shared_ptr<IPullAtomResultReceiver>& resultReceiver) override {
+        AStatsEventList statsEventList;
+        int successInt = mCallback(atomTag, &statsEventList, mCookie);
+        bool success = successInt == AStatsManager_PULL_SUCCESS;
+
+        // Convert stats_events into StatsEventParcels.
+        std::vector<StatsEventParcel> parcels;
+        for (int i = 0; i < statsEventList.data.size(); i++) {
+            size_t size;
+            uint8_t* buffer = AStatsEvent_getBuffer(statsEventList.data[i], &size);
+
+            StatsEventParcel p;
+            // vector.assign() creates a copy, but this is inevitable unless
+            // stats_event.h/c uses a vector as opposed to a buffer.
+            p.buffer.assign(buffer, buffer + size);
+            parcels.push_back(std::move(p));
+        }
+
+        Status status = resultReceiver->pullFinished(atomTag, success, parcels);
+        if (!status.isOk()) {
+            std::vector<StatsEventParcel> emptyParcels;
+            resultReceiver->pullFinished(atomTag, /*success=*/false, emptyParcels);
+        }
+        for (int i = 0; i < statsEventList.data.size(); i++) {
+            AStatsEvent_release(statsEventList.data[i]);
+        }
+        return Status::ok();
+    }
+
+    int64_t getCoolDownMillis() const { return mCoolDownMillis; }
+    int64_t getTimeoutMillis() const { return mTimeoutMillis; }
+    const std::vector<int32_t>& getAdditiveFields() const { return mAdditiveFields; }
+
+  private:
+    const AStatsManager_PullAtomCallback mCallback;
+    void* mCookie;
+    const int64_t mCoolDownMillis;
+    const int64_t mTimeoutMillis;
+    const std::vector<int32_t> mAdditiveFields;
+};
+
+static std::mutex pullAtomMutex;
+static std::shared_ptr<IStatsd> sStatsd = nullptr;
+
+static std::map<int32_t, std::shared_ptr<StatsPullAtomCallbackInternal>> mPullers;
+static std::shared_ptr<IStatsd> getStatsService();
+
+static void binderDied(void* /*cookie*/) {
+    {
+        std::lock_guard<std::mutex> lock(pullAtomMutex);
+        sStatsd = nullptr;
+    }
+
+    std::shared_ptr<IStatsd> statsService = getStatsService();
+    if (statsService == nullptr) {
+        return;
+    }
+
+    // Since we do not want to make an IPC with the lock held, we first create a
+    // copy of the data with the lock held before iterating through the map.
+    std::map<int32_t, std::shared_ptr<StatsPullAtomCallbackInternal>> pullersCopy;
+    {
+        std::lock_guard<std::mutex> lock(pullAtomMutex);
+        pullersCopy = mPullers;
+    }
+    for (const auto& it : pullersCopy) {
+        statsService->registerNativePullAtomCallback(it.first, it.second->getCoolDownMillis(),
+                                                     it.second->getTimeoutMillis(),
+                                                     it.second->getAdditiveFields(), it.second);
+    }
+}
+
+static ::ndk::ScopedAIBinder_DeathRecipient sDeathRecipient(
+        AIBinder_DeathRecipient_new(binderDied));
+
+static std::shared_ptr<IStatsd> getStatsService() {
+    std::lock_guard<std::mutex> lock(pullAtomMutex);
+    if (!sStatsd) {
+        // Fetch statsd
+        ::ndk::SpAIBinder binder(AServiceManager_getService("stats"));
+        sStatsd = IStatsd::fromBinder(binder);
+        if (sStatsd) {
+            AIBinder_linkToDeath(binder.get(), sDeathRecipient.get(), /*cookie=*/nullptr);
+        }
+    }
+    return sStatsd;
+}
+
+void registerStatsPullAtomCallbackBlocking(int32_t atomTag,
+                                           std::shared_ptr<StatsPullAtomCallbackInternal> cb) {
+    const std::shared_ptr<IStatsd> statsService = getStatsService();
+    if (statsService == nullptr) {
+        // Statsd not available
+        return;
+    }
+
+    statsService->registerNativePullAtomCallback(
+            atomTag, cb->getCoolDownMillis(), cb->getTimeoutMillis(), cb->getAdditiveFields(), cb);
+}
+
+void unregisterStatsPullAtomCallbackBlocking(int32_t atomTag) {
+    const std::shared_ptr<IStatsd> statsService = getStatsService();
+    if (statsService == nullptr) {
+        // Statsd not available
+        return;
+    }
+
+    statsService->unregisterNativePullAtomCallback(atomTag);
+}
+
+void AStatsManager_setPullAtomCallback(int32_t atom_tag, AStatsManager_PullAtomMetadata* metadata,
+                                       AStatsManager_PullAtomCallback callback, void* cookie) {
+    int64_t coolDownMillis =
+            metadata == nullptr ? DEFAULT_COOL_DOWN_MILLIS : metadata->cool_down_millis;
+    int64_t timeoutMillis = metadata == nullptr ? DEFAULT_TIMEOUT_MILLIS : metadata->timeout_millis;
+
+    std::vector<int32_t> additiveFields;
+    if (metadata != nullptr) {
+        additiveFields = metadata->additive_fields;
+    }
+
+    std::shared_ptr<StatsPullAtomCallbackInternal> callbackBinder =
+            SharedRefBase::make<StatsPullAtomCallbackInternal>(callback, cookie, coolDownMillis,
+                                                               timeoutMillis, additiveFields);
+
+    {
+        std::lock_guard<std::mutex> lg(pullAtomMutex);
+        // Always add to the map. If statsd is dead, we will add them when it comes back.
+        mPullers[atom_tag] = callbackBinder;
+    }
+
+    std::thread registerThread(registerStatsPullAtomCallbackBlocking, atom_tag, callbackBinder);
+    registerThread.detach();
+}
+
+void AStatsManager_clearPullAtomCallback(int32_t atom_tag) {
+    {
+        std::lock_guard<std::mutex> lg(pullAtomMutex);
+        // Always remove the puller from our map.
+        // If statsd is down, we will not register it when it comes back.
+        mPullers.erase(atom_tag);
+    }
+    std::thread unregisterThread(unregisterStatsPullAtomCallbackBlocking, atom_tag);
+    unregisterThread.detach();
+}
diff --git a/libstats/pull/tests/pull_atom_metadata_test.cpp b/libstats/pull/tests/pull_atom_metadata_test.cpp
new file mode 100644
index 0000000..abc8e47
--- /dev/null
+++ b/libstats/pull/tests/pull_atom_metadata_test.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2020, 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 <stats_pull_atom_callback.h>
+
+namespace {
+
+static const int64_t DEFAULT_COOL_DOWN_MILLIS = 1000LL;  // 1 second.
+static const int64_t DEFAULT_TIMEOUT_MILLIS = 2000LL;    // 2 seconds.
+
+}  // anonymous namespace
+
+TEST(AStatsManager_PullAtomMetadataTest, TestEmpty) {
+    AStatsManager_PullAtomMetadata* metadata = AStatsManager_PullAtomMetadata_obtain();
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getCoolDownMillis(metadata), DEFAULT_COOL_DOWN_MILLIS);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getTimeoutMillis(metadata), DEFAULT_TIMEOUT_MILLIS);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getNumAdditiveFields(metadata), 0);
+    AStatsManager_PullAtomMetadata_release(metadata);
+}
+
+TEST(AStatsManager_PullAtomMetadataTest, TestSetTimeoutMillis) {
+    int64_t timeoutMillis = 500;
+    AStatsManager_PullAtomMetadata* metadata = AStatsManager_PullAtomMetadata_obtain();
+    AStatsManager_PullAtomMetadata_setTimeoutMillis(metadata, timeoutMillis);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getCoolDownMillis(metadata), DEFAULT_COOL_DOWN_MILLIS);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getTimeoutMillis(metadata), timeoutMillis);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getNumAdditiveFields(metadata), 0);
+    AStatsManager_PullAtomMetadata_release(metadata);
+}
+
+TEST(AStatsManager_PullAtomMetadataTest, TestSetCoolDownMillis) {
+    int64_t coolDownMillis = 10000;
+    AStatsManager_PullAtomMetadata* metadata = AStatsManager_PullAtomMetadata_obtain();
+    AStatsManager_PullAtomMetadata_setCoolDownMillis(metadata, coolDownMillis);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getCoolDownMillis(metadata), coolDownMillis);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getTimeoutMillis(metadata), DEFAULT_TIMEOUT_MILLIS);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getNumAdditiveFields(metadata), 0);
+    AStatsManager_PullAtomMetadata_release(metadata);
+}
+
+TEST(AStatsManager_PullAtomMetadataTest, TestSetAdditiveFields) {
+    const int numFields = 3;
+    int inputFields[numFields] = {2, 4, 6};
+    AStatsManager_PullAtomMetadata* metadata = AStatsManager_PullAtomMetadata_obtain();
+    AStatsManager_PullAtomMetadata_setAdditiveFields(metadata, inputFields, numFields);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getCoolDownMillis(metadata), DEFAULT_COOL_DOWN_MILLIS);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getTimeoutMillis(metadata), DEFAULT_TIMEOUT_MILLIS);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getNumAdditiveFields(metadata), numFields);
+    int outputFields[numFields];
+    AStatsManager_PullAtomMetadata_getAdditiveFields(metadata, outputFields);
+    for (int i = 0; i < numFields; i++) {
+        EXPECT_EQ(inputFields[i], outputFields[i]);
+    }
+    AStatsManager_PullAtomMetadata_release(metadata);
+}
+
+TEST(AStatsManager_PullAtomMetadataTest, TestSetAllElements) {
+    int64_t timeoutMillis = 500;
+    int64_t coolDownMillis = 10000;
+    const int numFields = 3;
+    int inputFields[numFields] = {2, 4, 6};
+
+    AStatsManager_PullAtomMetadata* metadata = AStatsManager_PullAtomMetadata_obtain();
+    AStatsManager_PullAtomMetadata_setTimeoutMillis(metadata, timeoutMillis);
+    AStatsManager_PullAtomMetadata_setCoolDownMillis(metadata, coolDownMillis);
+    AStatsManager_PullAtomMetadata_setAdditiveFields(metadata, inputFields, numFields);
+
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getCoolDownMillis(metadata), coolDownMillis);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getTimeoutMillis(metadata), timeoutMillis);
+    EXPECT_EQ(AStatsManager_PullAtomMetadata_getNumAdditiveFields(metadata), numFields);
+    int outputFields[numFields];
+    AStatsManager_PullAtomMetadata_getAdditiveFields(metadata, outputFields);
+    for (int i = 0; i < numFields; i++) {
+        EXPECT_EQ(inputFields[i], outputFields[i]);
+    }
+    AStatsManager_PullAtomMetadata_release(metadata);
+}
diff --git a/libstats/push_compat/Android.bp b/libstats/push_compat/Android.bp
index cbc65ff..43ae69d 100644
--- a/libstats/push_compat/Android.bp
+++ b/libstats/push_compat/Android.bp
@@ -32,13 +32,15 @@
         "-DWRITE_TO_STATSD=1",
         "-DWRITE_TO_LOGD=0",
     ],
-    header_libs: ["libstatssocket_headers"],
+    header_libs: [
+        "libcutils_headers",
+        "libstatssocket_headers",
+    ],
     static_libs: [
         "libbase",
     ],
     shared_libs: [
         "liblog",
-        "libutils",
     ],
 }
 
@@ -46,6 +48,9 @@
     name: "libstatspush_compat",
     defaults: ["libstatspush_compat_defaults"],
     export_include_dirs: ["include"],
+    export_header_lib_headers: [
+        "libstatssocket_headers",
+    ],
     static_libs: ["libgtest_prod"],
     apex_available: ["com.android.resolv"],
     min_sdk_version: "29",
diff --git a/libstats/push_compat/StatsEventCompat.cpp b/libstats/push_compat/StatsEventCompat.cpp
index edfa070..12a5dd4 100644
--- a/libstats/push_compat/StatsEventCompat.cpp
+++ b/libstats/push_compat/StatsEventCompat.cpp
@@ -15,41 +15,42 @@
  */
 
 #include "include/StatsEventCompat.h"
+
+#include <chrono>
+
+#include <android-base/chrono_utils.h>
 #include <android-base/properties.h>
 #include <android/api-level.h>
 #include <android/log.h>
 #include <dlfcn.h>
-#include <utils/SystemClock.h>
 
+using android::base::boot_clock;
 using android::base::GetProperty;
 
 const static int kStatsEventTag = 1937006964;
-
-/* Checking ro.build.version.release is fragile, as the release field is
- * an opaque string without structural guarantees. However, testing confirms
- * that on Q devices, the property is "10," and on R, it is "R." Until
- * android_get_device_api_level() is updated, this is the only solution.
- *
- * TODO(b/146019024): migrate to android_get_device_api_level()
- */
 const bool StatsEventCompat::mPlatformAtLeastR =
-        GetProperty("ro.build.version.codename", "") == "R" ||
-        android_get_device_api_level() > __ANDROID_API_Q__;
+        android_get_device_api_level() >= __ANDROID_API_R__;
 
-// definitions of static class variables
+// initializations of static class variables
 bool StatsEventCompat::mAttemptedLoad = false;
-struct stats_event_api_table* StatsEventCompat::mStatsEventApi = nullptr;
 std::mutex StatsEventCompat::mLoadLock;
+AStatsEventApi StatsEventCompat::mAStatsEventApi;
+
+static int64_t elapsedRealtimeNano() {
+    return std::chrono::time_point_cast<std::chrono::nanoseconds>(boot_clock::now())
+            .time_since_epoch()
+            .count();
+}
 
 StatsEventCompat::StatsEventCompat() : mEventQ(kStatsEventTag) {
     // guard loading because StatsEventCompat might be called from multithreaded
     // environment
     {
         std::lock_guard<std::mutex> lg(mLoadLock);
-        if (!mAttemptedLoad) {
+        if (!mAttemptedLoad && mPlatformAtLeastR) {
             void* handle = dlopen("libstatssocket.so", RTLD_NOW);
             if (handle) {
-                mStatsEventApi = (struct stats_event_api_table*)dlsym(handle, "table");
+                initializeApiTableLocked(handle);
             } else {
                 ALOGE("dlopen failed: %s\n", dlerror());
             }
@@ -57,61 +58,93 @@
         mAttemptedLoad = true;
     }
 
-    if (mStatsEventApi) {
-        mEventR = mStatsEventApi->obtain();
-    } else if (!mPlatformAtLeastR) {
-        mEventQ << android::elapsedRealtimeNano();
+    if (useRSchema()) {
+        mEventR = mAStatsEventApi.obtain();
+    } else if (useQSchema()) {
+        mEventQ << elapsedRealtimeNano();
     }
 }
 
 StatsEventCompat::~StatsEventCompat() {
-    if (mStatsEventApi) mStatsEventApi->release(mEventR);
+    if (useRSchema()) mAStatsEventApi.release(mEventR);
+}
+
+// Populates the AStatsEventApi struct by calling dlsym to find the address of
+// each API function.
+void StatsEventCompat::initializeApiTableLocked(void* handle) {
+    mAStatsEventApi.obtain = (AStatsEvent* (*)())dlsym(handle, "AStatsEvent_obtain");
+    mAStatsEventApi.build = (void (*)(AStatsEvent*))dlsym(handle, "AStatsEvent_build");
+    mAStatsEventApi.write = (int (*)(AStatsEvent*))dlsym(handle, "AStatsEvent_write");
+    mAStatsEventApi.release = (void (*)(AStatsEvent*))dlsym(handle, "AStatsEvent_release");
+    mAStatsEventApi.setAtomId =
+            (void (*)(AStatsEvent*, uint32_t))dlsym(handle, "AStatsEvent_setAtomId");
+    mAStatsEventApi.writeInt32 =
+            (void (*)(AStatsEvent*, int32_t))dlsym(handle, "AStatsEvent_writeInt32");
+    mAStatsEventApi.writeInt64 =
+            (void (*)(AStatsEvent*, int64_t))dlsym(handle, "AStatsEvent_writeInt64");
+    mAStatsEventApi.writeFloat =
+            (void (*)(AStatsEvent*, float))dlsym(handle, "AStatsEvent_writeFloat");
+    mAStatsEventApi.writeBool =
+            (void (*)(AStatsEvent*, bool))dlsym(handle, "AStatsEvent_writeBool");
+    mAStatsEventApi.writeByteArray = (void (*)(AStatsEvent*, const uint8_t*, size_t))dlsym(
+            handle, "AStatsEvent_writeByteArray");
+    mAStatsEventApi.writeString =
+            (void (*)(AStatsEvent*, const char*))dlsym(handle, "AStatsEvent_writeString");
+    mAStatsEventApi.writeAttributionChain =
+            (void (*)(AStatsEvent*, const uint32_t*, const char* const*, uint8_t))dlsym(
+                    handle, "AStatsEvent_writeAttributionChain");
+    mAStatsEventApi.addBoolAnnotation =
+            (void (*)(AStatsEvent*, uint8_t, bool))dlsym(handle, "AStatsEvent_addBoolAnnotation");
+    mAStatsEventApi.addInt32Annotation = (void (*)(AStatsEvent*, uint8_t, int32_t))dlsym(
+            handle, "AStatsEvent_addInt32Annotation");
+
+    mAStatsEventApi.initialized = true;
 }
 
 void StatsEventCompat::setAtomId(int32_t atomId) {
-    if (mStatsEventApi) {
-        mStatsEventApi->set_atom_id(mEventR, (uint32_t)atomId);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.setAtomId(mEventR, (uint32_t)atomId);
+    } else if (useQSchema()) {
         mEventQ << atomId;
     }
 }
 
 void StatsEventCompat::writeInt32(int32_t value) {
-    if (mStatsEventApi) {
-        mStatsEventApi->write_int32(mEventR, value);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.writeInt32(mEventR, value);
+    } else if (useQSchema()) {
         mEventQ << value;
     }
 }
 
 void StatsEventCompat::writeInt64(int64_t value) {
-    if (mStatsEventApi) {
-        mStatsEventApi->write_int64(mEventR, value);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.writeInt64(mEventR, value);
+    } else if (useQSchema()) {
         mEventQ << value;
     }
 }
 
 void StatsEventCompat::writeFloat(float value) {
-    if (mStatsEventApi) {
-        mStatsEventApi->write_float(mEventR, value);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.writeFloat(mEventR, value);
+    } else if (useQSchema()) {
         mEventQ << value;
     }
 }
 
 void StatsEventCompat::writeBool(bool value) {
-    if (mStatsEventApi) {
-        mStatsEventApi->write_bool(mEventR, value);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.writeBool(mEventR, value);
+    } else if (useQSchema()) {
         mEventQ << value;
     }
 }
 
 void StatsEventCompat::writeByteArray(const char* buffer, size_t length) {
-    if (mStatsEventApi) {
-        mStatsEventApi->write_byte_array(mEventR, (const uint8_t*)buffer, length);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.writeByteArray(mEventR, reinterpret_cast<const uint8_t*>(buffer), length);
+    } else if (useQSchema()) {
         mEventQ.AppendCharArray(buffer, length);
     }
 }
@@ -119,19 +152,19 @@
 void StatsEventCompat::writeString(const char* value) {
     if (value == nullptr) value = "";
 
-    if (mStatsEventApi) {
-        mStatsEventApi->write_string8(mEventR, value);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.writeString(mEventR, value);
+    } else if (useQSchema()) {
         mEventQ << value;
     }
 }
 
 void StatsEventCompat::writeAttributionChain(const int32_t* uids, size_t numUids,
                                              const vector<const char*>& tags) {
-    if (mStatsEventApi) {
-        mStatsEventApi->write_attribution_chain(mEventR, (const uint32_t*)uids, tags.data(),
-                                                (uint8_t)numUids);
-    } else if (!mPlatformAtLeastR) {
+    if (useRSchema()) {
+        mAStatsEventApi.writeAttributionChain(mEventR, (const uint32_t*)uids, tags.data(),
+                                              (uint8_t)numUids);
+    } else if (useQSchema()) {
         mEventQ.begin();
         for (size_t i = 0; i < numUids; i++) {
             mEventQ.begin();
@@ -148,26 +181,8 @@
                                           const map<int, int64_t>& int64Map,
                                           const map<int, const char*>& stringMap,
                                           const map<int, float>& floatMap) {
-    if (mStatsEventApi) {
-        vector<struct key_value_pair> pairs;
-
-        for (const auto& it : int32Map) {
-            pairs.push_back({.key = it.first, .valueType = INT32_TYPE, .int32Value = it.second});
-        }
-        for (const auto& it : int64Map) {
-            pairs.push_back({.key = it.first, .valueType = INT64_TYPE, .int64Value = it.second});
-        }
-        for (const auto& it : stringMap) {
-            pairs.push_back({.key = it.first, .valueType = STRING_TYPE, .stringValue = it.second});
-        }
-        for (const auto& it : floatMap) {
-            pairs.push_back({.key = it.first, .valueType = FLOAT_TYPE, .floatValue = it.second});
-        }
-
-        mStatsEventApi->write_key_value_pairs(mEventR, pairs.data(), (uint8_t)pairs.size());
-    }
-
-    else if (!mPlatformAtLeastR) {
+    // AStatsEvent does not support key value pairs.
+    if (useQSchema()) {
         mEventQ.begin();
         writeKeyValuePairMap(int32Map);
         writeKeyValuePairMap(int64Map);
@@ -194,28 +209,35 @@
 template void StatsEventCompat::writeKeyValuePairMap<const char*>(const map<int, const char*>&);
 
 void StatsEventCompat::addBoolAnnotation(uint8_t annotationId, bool value) {
-    if (mStatsEventApi) mStatsEventApi->add_bool_annotation(mEventR, annotationId, value);
+    if (useRSchema()) {
+        mAStatsEventApi.addBoolAnnotation(mEventR, annotationId, value);
+    }
     // Don't do anything if on Q.
 }
 
 void StatsEventCompat::addInt32Annotation(uint8_t annotationId, int32_t value) {
-    if (mStatsEventApi) mStatsEventApi->add_int32_annotation(mEventR, annotationId, value);
+    if (useRSchema()) {
+        mAStatsEventApi.addInt32Annotation(mEventR, annotationId, value);
+    }
     // Don't do anything if on Q.
 }
 
 int StatsEventCompat::writeToSocket() {
-    if (mStatsEventApi) {
-        mStatsEventApi->build(mEventR);
-        return mStatsEventApi->write(mEventR);
+    if (useRSchema()) {
+        return mAStatsEventApi.write(mEventR);
     }
 
-    if (!mPlatformAtLeastR) return mEventQ.write(LOG_ID_STATS);
+    if (useQSchema()) return mEventQ.write(LOG_ID_STATS);
 
-    // We reach here only if we're on R, but libstatspush_compat was unable to
+    // We reach here only if we're on R, but libstatssocket was unable to
     // be loaded using dlopen.
     return -ENOLINK;
 }
 
-bool StatsEventCompat::usesNewSchema() {
-    return mStatsEventApi != nullptr;
+bool StatsEventCompat::useRSchema() {
+    return mPlatformAtLeastR && mAStatsEventApi.initialized;
+}
+
+bool StatsEventCompat::useQSchema() {
+    return !mPlatformAtLeastR;
 }
diff --git a/libstats/push_compat/include/StatsEventCompat.h b/libstats/push_compat/include/StatsEventCompat.h
index a8cde68..00bf48b 100644
--- a/libstats/push_compat/include/StatsEventCompat.h
+++ b/libstats/push_compat/include/StatsEventCompat.h
@@ -26,6 +26,26 @@
 using std::map;
 using std::vector;
 
+struct AStatsEventApi {
+    // Indicates whether the below function pointers have been set using dlsym.
+    bool initialized = false;
+
+    AStatsEvent* (*obtain)(void);
+    void (*build)(AStatsEvent*);
+    int (*write)(AStatsEvent*);
+    void (*release)(AStatsEvent*);
+    void (*setAtomId)(AStatsEvent*, uint32_t);
+    void (*writeInt32)(AStatsEvent*, int32_t);
+    void (*writeInt64)(AStatsEvent*, int64_t);
+    void (*writeFloat)(AStatsEvent*, float);
+    void (*writeBool)(AStatsEvent*, bool);
+    void (*writeByteArray)(AStatsEvent*, const uint8_t*, size_t);
+    void (*writeString)(AStatsEvent*, const char*);
+    void (*writeAttributionChain)(AStatsEvent*, const uint32_t*, const char* const*, uint8_t);
+    void (*addBoolAnnotation)(AStatsEvent*, uint8_t, bool);
+    void (*addInt32Annotation)(AStatsEvent*, uint8_t, int32_t);
+};
+
 class StatsEventCompat {
   public:
     StatsEventCompat();
@@ -57,15 +77,18 @@
     const static bool mPlatformAtLeastR;
     static bool mAttemptedLoad;
     static std::mutex mLoadLock;
-    static struct stats_event_api_table* mStatsEventApi;
+    static AStatsEventApi mAStatsEventApi;
 
     // non-static member variables
-    struct stats_event* mEventR = nullptr;
+    AStatsEvent* mEventR = nullptr;
     stats_event_list mEventQ;
 
     template <class T>
     void writeKeyValuePairMap(const map<int, T>& keyValuePairMap);
 
-    bool usesNewSchema();
+    void initializeApiTableLocked(void* handle);
+    bool useRSchema();
+    bool useQSchema();
+
     FRIEND_TEST(StatsEventCompatTest, TestDynamicLoading);
 };
diff --git a/libstats/push_compat/tests/StatsEventCompat_test.cpp b/libstats/push_compat/tests/StatsEventCompat_test.cpp
index 2be24ec..2a70db5 100644
--- a/libstats/push_compat/tests/StatsEventCompat_test.cpp
+++ b/libstats/push_compat/tests/StatsEventCompat_test.cpp
@@ -21,18 +21,9 @@
 
 using android::base::GetProperty;
 
-/* Checking ro.build.version.release is fragile, as the release field is
- * an opaque string without structural guarantees. However, testing confirms
- * that on Q devices, the property is "10," and on R, it is "R." Until
- * android_get_device_api_level() is updated, this is the only solution.
- *
- *
- * TODO(b/146019024): migrate to android_get_device_api_level()
- */
-const static bool mPlatformAtLeastR = GetProperty("ro.build.version.release", "") == "R" ||
-                                      android_get_device_api_level() > __ANDROID_API_Q__;
+const static bool mPlatformAtLeastR = android_get_device_api_level() >= __ANDROID_API_R__;
 
 TEST(StatsEventCompatTest, TestDynamicLoading) {
     StatsEventCompat event;
-    EXPECT_EQ(mPlatformAtLeastR, event.usesNewSchema());
+    EXPECT_EQ(mPlatformAtLeastR, event.useRSchema());
 }
diff --git a/libstats/socket/Android.bp b/libstats/socket/Android.bp
index 6882ab2..89cdfe5 100644
--- a/libstats/socket/Android.bp
+++ b/libstats/socket/Android.bp
@@ -17,37 +17,69 @@
 // =========================================================================
 // Native library to write stats log to statsd socket on Android R and later
 // =========================================================================
-cc_library {
-    name: "libstatssocket",
+cc_defaults {
+    name: "libstatssocket_defaults",
     srcs: [
         "stats_buffer_writer.c",
         "stats_event.c",
-        // TODO(b/145573568): Remove stats_event_list once stats_event
-        // migration is complete.
-        "stats_event_list.c",
+        "stats_socket.c",
         "statsd_writer.c",
     ],
-    host_supported: true,
+    export_include_dirs: ["include"],
+    static_libs: [
+        "libcutils", // does not expose a stable C API
+    ],
+    header_libs: ["liblog_headers"],
     cflags: [
         "-Wall",
         "-Werror",
-        "-DLIBLOG_LOG_TAG=1006",
-        "-DWRITE_TO_STATSD=1",
-        "-DWRITE_TO_LOGD=0",
     ],
-    export_include_dirs: ["include"],
-    shared_libs: [
-        "libcutils",
-        "liblog",
+}
+
+cc_library {
+    name: "libstatssocket",
+    defaults: [
+        "libstatssocket_defaults",
     ],
+    host_supported: true,
+    target: {
+        // On android, libstatssocket should only be linked as a shared lib
+        android: {
+            static: {
+                enabled: false,
+            },
+        },
+        host: {
+            shared: {
+                enabled: false,
+            },
+        },
+    },
+    stl: "libc++_static",
 
     // enumerate stable entry points for APEX use
     stubs: {
         symbol_file: "libstatssocket.map.txt",
         versions: [
-            "1",
+            "30",
         ],
-    }
+    },
+    apex_available: [
+        "com.android.os.statsd",
+        "test_com.android.os.statsd",
+    ],
+}
+
+//TODO (b/149842105): Figure out if there is a better solution for this.
+cc_test_library {
+    name: "libstatssocket_private",
+    defaults: [
+        "libstatssocket_defaults",
+    ],
+    visibility: [
+        "//frameworks/base/apex/statsd/tests/libstatspull",
+        "//frameworks/base/cmds/statsd",
+    ],
 }
 
 cc_library_headers {
@@ -58,41 +90,36 @@
     min_sdk_version: "29",
 }
 
-cc_benchmark {
-    name: "libstatssocket_benchmark",
-    srcs: [
-        "benchmark/main.cpp",
-        "benchmark/stats_event_benchmark.cpp",
-    ],
-    cflags: [
-        "-Wall",
-        "-Werror",
-    ],
-    static_libs: [
-        "libstatssocket",
-    ],
-    shared_libs: [
-        "libcutils",
-        "liblog",
-        "libgtest_prod",
-    ],
-}
-
 cc_test {
     name: "libstatssocket_test",
-    srcs: ["tests/stats_event_test.cpp"],
+    srcs: [
+        "tests/stats_event_test.cpp",
+        "tests/stats_writer_test.cpp",
+    ],
     cflags: [
         "-Wall",
         "-Werror",
     ],
     static_libs: [
         "libgmock",
-        "libstatssocket",
+        "libstatssocket_private",
     ],
     shared_libs: [
         "libcutils",
-        "liblog",
         "libutils",
     ],
-    test_suites: ["device_tests"],
+    test_suites: ["device-tests", "mts"],
+    test_config: "libstatssocket_test.xml",
+    //TODO(b/153588990): Remove when the build system properly separates.
+    //32bit and 64bit architectures.
+    compile_multilib: "both",
+    multilib: {
+        lib64: {
+            suffix: "64",
+        },
+        lib32: {
+            suffix: "32",
+        },
+    },
+    require_root: true,
 }
diff --git a/libstats/socket/TEST_MAPPING b/libstats/socket/TEST_MAPPING
new file mode 100644
index 0000000..0224998
--- /dev/null
+++ b/libstats/socket/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+  "presubmit" : [
+    {
+      "name" : "libstatssocket_test"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/libstats/socket/benchmark/main.cpp b/libstats/socket/benchmark/main.cpp
deleted file mode 100644
index 5ebdf6e..0000000
--- a/libstats/socket/benchmark/main.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2019 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 <benchmark/benchmark.h>
-
-BENCHMARK_MAIN();
diff --git a/libstats/socket/benchmark/stats_event_benchmark.cpp b/libstats/socket/benchmark/stats_event_benchmark.cpp
deleted file mode 100644
index 9488168..0000000
--- a/libstats/socket/benchmark/stats_event_benchmark.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2019 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 "benchmark/benchmark.h"
-#include "stats_event.h"
-
-static struct stats_event* constructStatsEvent() {
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, 100);
-
-    // randomly sample atom size
-    int numElements = rand() % 800;
-    for (int i = 0; i < numElements; i++) {
-        stats_event_write_int32(event, i);
-    }
-
-    return event;
-}
-
-static void BM_stats_event_truncate_buffer(benchmark::State& state) {
-    while (state.KeepRunning()) {
-        struct stats_event* event = constructStatsEvent();
-        stats_event_build(event);
-        stats_event_write(event);
-        stats_event_release(event);
-    }
-}
-
-BENCHMARK(BM_stats_event_truncate_buffer);
-
-static void BM_stats_event_full_buffer(benchmark::State& state) {
-    while (state.KeepRunning()) {
-        struct stats_event* event = constructStatsEvent();
-        stats_event_truncate_buffer(event, false);
-        stats_event_build(event);
-        stats_event_write(event);
-        stats_event_release(event);
-    }
-}
-
-BENCHMARK(BM_stats_event_full_buffer);
diff --git a/libstats/socket/include/stats_buffer_writer.h b/libstats/socket/include/stats_buffer_writer.h
index de4a5e2..5b41f0e 100644
--- a/libstats/socket/include/stats_buffer_writer.h
+++ b/libstats/socket/include/stats_buffer_writer.h
@@ -23,6 +23,7 @@
 extern "C" {
 #endif  // __CPLUSPLUS
 void stats_log_close();
+int stats_log_is_closed();
 int write_buffer_to_statsd(void* buffer, size_t size, uint32_t atomId);
 #ifdef __cplusplus
 }
diff --git a/libstats/socket/include/stats_event.h b/libstats/socket/include/stats_event.h
index 080e957..3d3baf9 100644
--- a/libstats/socket/include/stats_event.h
+++ b/libstats/socket/include/stats_event.h
@@ -26,136 +26,136 @@
  * This code defines and encapsulates the socket protocol.
  *
  * Usage:
- *      struct stats_event* event = stats_event_obtain();
+ *      AStatsEvent* event = AStatsEvent_obtain();
  *
- *      stats_event_set_atom_id(event, atomId);
- *      stats_event_write_int32(event, 24);
- *      stats_event_add_bool_annotation(event, 1, true); // annotations apply to the previous field
- *      stats_event_add_int32_annotation(event, 2, 128);
- *      stats_event_write_float(event, 2.0);
+ *      AStatsEvent_setAtomId(event, atomId);
+ *      AStatsEvent_addBoolAnnotation(event, 5, false); // atom-level annotation
+ *      AStatsEvent_writeInt32(event, 24);
+ *      AStatsEvent_addBoolAnnotation(event, 1, true); // annotation for preceding atom field
+ *      AStatsEvent_addInt32Annotation(event, 2, 128);
+ *      AStatsEvent_writeFloat(event, 2.0);
  *
- *      stats_event_build(event);
- *      stats_event_write(event);
- *      stats_event_release(event);
+ *      AStatsEvent_write(event);
+ *      AStatsEvent_release(event);
  *
- * Notes:
- *    (a) write_<type>() and add_<type>_annotation() should be called in the order that fields
- *        and annotations are defined in the atom.
- *    (b) set_atom_id() can be called anytime before stats_event_write().
- *    (c) add_<type>_annotation() calls apply to the previous field.
- *    (d) If errors occur, stats_event_write() will write a bitmask of the errors to the socket.
- *    (e) All strings should be encoded using UTF8.
+ * Note that calls to add atom fields and annotations should be made in the
+ * order that they are defined in the atom.
  */
 
-/* ERRORS */
-#define ERROR_NO_TIMESTAMP 0x1
-#define ERROR_NO_ATOM_ID 0x2
-#define ERROR_OVERFLOW 0x4
-#define ERROR_ATTRIBUTION_CHAIN_TOO_LONG 0x8
-#define ERROR_TOO_MANY_KEY_VALUE_PAIRS 0x10
-#define ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD 0x20
-#define ERROR_INVALID_ANNOTATION_ID 0x40
-#define ERROR_ANNOTATION_ID_TOO_LARGE 0x80
-#define ERROR_TOO_MANY_ANNOTATIONS 0x100
-#define ERROR_TOO_MANY_FIELDS 0x200
-#define ERROR_INVALID_VALUE_TYPE 0x400
-#define ERROR_STRING_NOT_NULL_TERMINATED 0x800
-
-/* TYPE IDS */
-#define INT32_TYPE 0x00
-#define INT64_TYPE 0x01
-#define STRING_TYPE 0x02
-#define LIST_TYPE 0x03
-#define FLOAT_TYPE 0x04
-#define BOOL_TYPE 0x05
-#define BYTE_ARRAY_TYPE 0x06
-#define OBJECT_TYPE 0x07
-#define KEY_VALUE_PAIRS_TYPE 0x08
-#define ATTRIBUTION_CHAIN_TYPE 0x09
-#define ERROR_TYPE 0x0F
-
 #ifdef __cplusplus
 extern "C" {
 #endif  // __CPLUSPLUS
 
-struct stats_event;
-
-/* SYSTEM API */
-struct stats_event* stats_event_obtain();
-// The build function can be called multiple times without error. If the event
-// has been built before, this function is a no-op.
-void stats_event_build(struct stats_event* event);
-int stats_event_write(struct stats_event* event);
-void stats_event_release(struct stats_event* event);
-
-void stats_event_set_atom_id(struct stats_event* event, uint32_t atomId);
-
-void stats_event_write_int32(struct stats_event* event, int32_t value);
-void stats_event_write_int64(struct stats_event* event, int64_t value);
-void stats_event_write_float(struct stats_event* event, float value);
-void stats_event_write_bool(struct stats_event* event, bool value);
-
-void stats_event_write_byte_array(struct stats_event* event, const uint8_t* buf, size_t numBytes);
-
-// Buf must be null-terminated.
-void stats_event_write_string8(struct stats_event* event, const char* value);
-
-// Tags must be null-terminated.
-void stats_event_write_attribution_chain(struct stats_event* event, const uint32_t* uids,
-                                         const char* const* tags, uint8_t numNodes);
-
-/* key_value_pair struct can be constructed as follows:
- *    struct key_value_pair pair = {.key = key, .valueType = STRING_TYPE,
- *                                  .stringValue = buf};
+/**
+ * Opaque struct use to represent a StatsEvent. It builds and stores the data that is sent to
+ * statsd.
  */
-struct key_value_pair {
-    int32_t key;
-    uint8_t valueType;  // expected to be INT32_TYPE, INT64_TYPE, FLOAT_TYPE, or STRING_TYPE
-    union {
-        int32_t int32Value;
-        int64_t int64Value;
-        float floatValue;
-        const char* stringValue;  // must be null terminated
-    };
-};
+struct AStatsEvent;
+typedef struct AStatsEvent AStatsEvent;
 
-void stats_event_write_key_value_pairs(struct stats_event* event, struct key_value_pair* pairs,
-                                       uint8_t numPairs);
+/**
+ * Returns a new AStatsEvent. If you call this function, you must call AStatsEvent_release to free
+ * the allocated memory.
+ */
+AStatsEvent* AStatsEvent_obtain();
 
-void stats_event_add_bool_annotation(struct stats_event* event, uint8_t annotationId, bool value);
-void stats_event_add_int32_annotation(struct stats_event* event, uint8_t annotationId,
-                                      int32_t value);
+/**
+ * Builds and finalizes the AStatsEvent for a pulled event.
+ * This should only be called for pulled AStatsEvents.
+ *
+ * After this function, the StatsEvent must not be modified in any way other than calling release or
+ * write.
+ *
+ * Build can be called multiple times without error.
+ * If the event has been built before, this function is a no-op.
+ */
+void AStatsEvent_build(AStatsEvent* event);
 
-uint32_t stats_event_get_atom_id(struct stats_event* event);
+/**
+ * Writes the StatsEvent to the stats log.
+ *
+ * After calling this, AStatsEvent_release must be called,
+ * and is the only function that can be safely called.
+ */
+int AStatsEvent_write(AStatsEvent* event);
+
+/**
+ * Frees the memory held by this StatsEvent.
+ *
+ * After calling this, the StatsEvent must not be used or modified in any way.
+ */
+void AStatsEvent_release(AStatsEvent* event);
+
+/**
+ * Sets the atom id for this StatsEvent.
+ *
+ * This function should be called immediately after AStatsEvent_obtain. It may
+ * be called additional times as well, but subsequent calls will have no effect.
+ **/
+void AStatsEvent_setAtomId(AStatsEvent* event, uint32_t atomId);
+
+/**
+ * Writes an int32_t field to this StatsEvent.
+ **/
+void AStatsEvent_writeInt32(AStatsEvent* event, int32_t value);
+
+/**
+ * Writes an int64_t field to this StatsEvent.
+ **/
+void AStatsEvent_writeInt64(AStatsEvent* event, int64_t value);
+
+/**
+ * Writes a float field to this StatsEvent.
+ **/
+void AStatsEvent_writeFloat(AStatsEvent* event, float value);
+
+/**
+ * Write a bool field to this StatsEvent.
+ **/
+void AStatsEvent_writeBool(AStatsEvent* event, bool value);
+
+/**
+ * Write a byte array field to this StatsEvent.
+ **/
+void AStatsEvent_writeByteArray(AStatsEvent* event, const uint8_t* buf, size_t numBytes);
+
+/**
+ * Write a string field to this StatsEvent.
+ *
+ * The string must be null-terminated.
+ **/
+void AStatsEvent_writeString(AStatsEvent* event, const char* value);
+
+/**
+ * Write an attribution chain field to this StatsEvent.
+ *
+ * The sizes of uids and tags must be equal. The AttributionNode at position i is
+ * made up of uids[i] and tags[i].
+ *
+ * \param uids array of uids in the attribution chain.
+ * \param tags array of tags in the attribution chain. Each tag must be null-terminated.
+ * \param numNodes the number of AttributionNodes in the attribution chain. This is the length of
+ *                 the uids and the tags.
+ **/
+void AStatsEvent_writeAttributionChain(AStatsEvent* event, const uint32_t* uids,
+                                       const char* const* tags, uint8_t numNodes);
+
+/**
+ * Write a bool annotation for the previous field written.
+ **/
+void AStatsEvent_addBoolAnnotation(AStatsEvent* event, uint8_t annotationId, bool value);
+
+/**
+ * Write an integer annotation for the previous field written.
+ **/
+void AStatsEvent_addInt32Annotation(AStatsEvent* event, uint8_t annotationId, int32_t value);
+
+// Internal/test APIs. Should not be exposed outside of the APEX.
+void AStatsEvent_overwriteTimestamp(AStatsEvent* event, uint64_t timestampNs);
+uint32_t AStatsEvent_getAtomId(AStatsEvent* event);
 // Size is an output parameter.
-uint8_t* stats_event_get_buffer(struct stats_event* event, size_t* size);
-uint32_t stats_event_get_errors(struct stats_event* event);
-
-// This table is used by StatsEventCompat to access the stats_event API.
-struct stats_event_api_table {
-    struct stats_event* (*obtain)(void);
-    void (*build)(struct stats_event*);
-    int (*write)(struct stats_event*);
-    void (*release)(struct stats_event*);
-    void (*set_atom_id)(struct stats_event*, uint32_t);
-    void (*write_int32)(struct stats_event*, int32_t);
-    void (*write_int64)(struct stats_event*, int64_t);
-    void (*write_float)(struct stats_event*, float);
-    void (*write_bool)(struct stats_event*, bool);
-    void (*write_byte_array)(struct stats_event*, const uint8_t*, size_t);
-    void (*write_string8)(struct stats_event*, const char*);
-    void (*write_attribution_chain)(struct stats_event*, const uint32_t*, const char* const*,
-                                    uint8_t);
-    void (*write_key_value_pairs)(struct stats_event*, struct key_value_pair*, uint8_t);
-    void (*add_bool_annotation)(struct stats_event*, uint8_t, bool);
-    void (*add_int32_annotation)(struct stats_event*, uint8_t, int32_t);
-    uint32_t (*get_atom_id)(struct stats_event*);
-    uint8_t* (*get_buffer)(struct stats_event*, size_t*);
-    uint32_t (*get_errors)(struct stats_event*);
-};
-
-// exposed for benchmarking only
-void stats_event_truncate_buffer(struct stats_event* event, bool truncate);
+uint8_t* AStatsEvent_getBuffer(AStatsEvent* event, size_t* size);
+uint32_t AStatsEvent_getErrors(AStatsEvent* event);
 
 #ifdef __cplusplus
 }
diff --git a/libstats/socket/include/stats_event_list.h b/libstats/socket/include/stats_event_list.h
deleted file mode 100644
index 7a26536..0000000
--- a/libstats/socket/include/stats_event_list.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2018, 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 <log/log_event_list.h>
-#include <sys/uio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-void reset_log_context(android_log_context ctx);
-int write_to_logger(android_log_context context, log_id_t id);
-void note_log_drop(int error, int atomId);
-void stats_log_close();
-int android_log_write_char_array(android_log_context ctx, const char* value, size_t len);
-#ifdef __cplusplus
-}
-#endif
-
-#ifdef __cplusplus
-/**
- * A copy of android_log_event_list class.
- *
- * android_log_event_list is going to be deprecated soon, so copy it here to
- * avoid creating dependency on upstream code. TODO(b/78304629): Rewrite this
- * code.
- */
-class stats_event_list {
-  private:
-    android_log_context ctx;
-    int ret;
-
-    stats_event_list(const stats_event_list&) = delete;
-    void operator=(const stats_event_list&) = delete;
-
-  public:
-    explicit stats_event_list(int tag) : ret(0) {
-        ctx = create_android_logger(static_cast<uint32_t>(tag));
-    }
-    ~stats_event_list() { android_log_destroy(&ctx); }
-
-    int close() {
-        int retval = android_log_destroy(&ctx);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return retval;
-    }
-
-    /* To allow above C calls to use this class as parameter */
-    operator android_log_context() const { return ctx; }
-
-    /* return errors or transmit status */
-    int status() const { return ret; }
-
-    int begin() {
-        int retval = android_log_write_list_begin(ctx);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret;
-    }
-    int end() {
-        int retval = android_log_write_list_end(ctx);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret;
-    }
-
-    stats_event_list& operator<<(int32_t value) {
-        int retval = android_log_write_int32(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    stats_event_list& operator<<(uint32_t value) {
-        int retval = android_log_write_int32(ctx, static_cast<int32_t>(value));
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    stats_event_list& operator<<(bool value) {
-        int retval = android_log_write_int32(ctx, value ? 1 : 0);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    stats_event_list& operator<<(int64_t value) {
-        int retval = android_log_write_int64(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    stats_event_list& operator<<(uint64_t value) {
-        int retval = android_log_write_int64(ctx, static_cast<int64_t>(value));
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    stats_event_list& operator<<(const char* value) {
-        int retval = android_log_write_string8(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    stats_event_list& operator<<(const std::string& value) {
-        int retval = android_log_write_string8_len(ctx, value.data(), value.length());
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    stats_event_list& operator<<(float value) {
-        int retval = android_log_write_float32(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return *this;
-    }
-
-    int write(log_id_t id = LOG_ID_EVENTS) {
-        /* facilitate -EBUSY retry */
-        if ((ret == -EBUSY) || (ret > 0)) {
-            ret = 0;
-        }
-        int retval = write_to_logger(ctx, id);
-        /* existing errors trump transmission errors */
-        if (!ret) {
-            ret = retval;
-        }
-        return ret;
-    }
-
-    /*
-     * Append<Type> methods removes any integer promotion
-     * confusion, and adds access to string with length.
-     * Append methods are also added for all types for
-     * convenience.
-     */
-
-    bool AppendInt(int32_t value) {
-        int retval = android_log_write_int32(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret >= 0;
-    }
-
-    bool AppendLong(int64_t value) {
-        int retval = android_log_write_int64(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret >= 0;
-    }
-
-    bool AppendString(const char* value) {
-        int retval = android_log_write_string8(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret >= 0;
-    }
-
-    bool AppendString(const char* value, size_t len) {
-        int retval = android_log_write_string8_len(ctx, value, len);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret >= 0;
-    }
-
-    bool AppendString(const std::string& value) {
-        int retval = android_log_write_string8_len(ctx, value.data(), value.length());
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret;
-    }
-
-    bool Append(const std::string& value) {
-        int retval = android_log_write_string8_len(ctx, value.data(), value.length());
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret;
-    }
-
-    bool AppendFloat(float value) {
-        int retval = android_log_write_float32(ctx, value);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret >= 0;
-    }
-
-    template <typename Tvalue>
-    bool Append(Tvalue value) {
-        *this << value;
-        return ret >= 0;
-    }
-
-    bool Append(const char* value, size_t len) {
-        int retval = android_log_write_string8_len(ctx, value, len);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret >= 0;
-    }
-
-    bool AppendCharArray(const char* value, size_t len) {
-        int retval = android_log_write_char_array(ctx, value, len);
-        if (retval < 0) {
-            ret = retval;
-        }
-        return ret >= 0;
-    }
-};
-
-#endif
diff --git a/liblog/pmsg_writer.h b/libstats/socket/include/stats_socket.h
similarity index 72%
rename from liblog/pmsg_writer.h
rename to libstats/socket/include/stats_socket.h
index d5e1a1c..5a75fc0 100644
--- a/liblog/pmsg_writer.h
+++ b/libstats/socket/include/stats_socket.h
@@ -16,9 +16,18 @@
 
 #pragma once
 
-#include <stddef.h>
+/**
+ * Helpers to manage the statsd socket.
+ **/
 
-#include <android/log.h>
+#ifdef __cplusplus
+extern "C" {
+#endif  // __CPLUSPLUS
 
-int PmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
-void PmsgClose();
+/**
+ * Closes the statsd socket file descriptor.
+ **/
+void AStatsSocket_close();
+#ifdef __cplusplus
+}
+#endif  // __CPLUSPLUS
diff --git a/libstats/socket/libstatssocket.map.txt b/libstats/socket/libstatssocket.map.txt
index 55bfbda..5c13904 100644
--- a/libstats/socket/libstatssocket.map.txt
+++ b/libstats/socket/libstatssocket.map.txt
@@ -1,23 +1,20 @@
 LIBSTATSSOCKET {
     global:
-        stats_event_obtain; # apex # introduced=1
-        stats_event_build; # apex # introduced=1
-        stats_event_write; # apex # introduced=1
-        stats_event_release; # apex # introduced=1
-        stats_event_set_atom_id; # apex # introduced=1
-        stats_event_write_int32; # apex # introduced=1
-        stats_event_write_int64; # apex # introduced=1
-        stats_event_write_float; # apex # introduced=1
-        stats_event_write_bool; # apex # introduced=1
-        stats_event_write_byte_array; # apex # introduced=1
-        stats_event_write_string8; # apex # introduced=1
-        stats_event_write_attribution_chain; # apex # introduced=1
-        stats_event_write_key_value_pairs; # apex # introduced=1
-        stats_event_add_bool_annotation; # apex # introduced=1
-        stats_event_add_int32_annotation; # apex # introduced=1
-        stats_event_get_atom_id; # apex # introduced=1
-        stats_event_get_buffer; # apex # introduced=1
-        stats_event_get_errors; # apex # introduced=1
+        AStatsEvent_obtain; # apex # introduced=30
+        AStatsEvent_build; # apex # introduced=30
+        AStatsEvent_write; # apex # introduced=30
+        AStatsEvent_release; # apex # introduced=30
+        AStatsEvent_setAtomId; # apex # introduced=30
+        AStatsEvent_writeInt32; # apex # introduced=30
+        AStatsEvent_writeInt64; # apex # introduced=30
+        AStatsEvent_writeFloat; # apex # introduced=30
+        AStatsEvent_writeBool; # apex # introduced=30
+        AStatsEvent_writeByteArray; # apex # introduced=30
+        AStatsEvent_writeString; # apex # introduced=30
+        AStatsEvent_writeAttributionChain; # apex # introduced=30
+        AStatsEvent_addBoolAnnotation; # apex # introduced=30
+        AStatsEvent_addInt32Annotation; # apex # introduced=30
+        AStatsSocket_close; # apex # introduced=30
     local:
         *;
 };
diff --git a/libstats/socket/libstatssocket_test.xml b/libstats/socket/libstatssocket_test.xml
new file mode 100644
index 0000000..d2694d1
--- /dev/null
+++ b/libstats/socket/libstatssocket_test.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+<configuration description="Runs libstatssocket_test.">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-native" />
+    <option name="test-suite-tag" value="mts" />
+
+    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+       <option name="cleanup" value="true" />
+       <option name="push" value="libstatssocket_test->/data/local/tmp/libstatssocket_test" />
+       <option name="append-bitness" value="true" />
+    </target_preparer>
+
+    <test class="com.android.tradefed.testtype.GTest" >
+        <option name="native-test-device-path" value="/data/local/tmp" />
+        <option name="module-name" value="libstatssocket_test" />
+    </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.os.statsd" />
+    </object>
+</configuration>
+
diff --git a/libstats/socket/stats_buffer_writer.c b/libstats/socket/stats_buffer_writer.c
index c5c591d..549acdc 100644
--- a/libstats/socket/stats_buffer_writer.c
+++ b/libstats/socket/stats_buffer_writer.c
@@ -43,27 +43,23 @@
     statsd_writer_init_unlock();
 }
 
+int stats_log_is_closed() {
+    return statsdLoggerWrite.isClosed && (*statsdLoggerWrite.isClosed)();
+}
+
 int write_buffer_to_statsd(void* buffer, size_t size, uint32_t atomId) {
     int ret = 1;
 
-#ifdef __ANDROID__
-    bool statsdEnabled = property_get_bool("ro.statsd.enable", true);
-#else
-    bool statsdEnabled = false;
-#endif
+    struct iovec vecs[2];
+    vecs[0].iov_base = (void*)&kStatsEventTag;
+    vecs[0].iov_len = sizeof(kStatsEventTag);
+    vecs[1].iov_base = buffer;
+    vecs[1].iov_len = size;
 
-    if (statsdEnabled) {
-        struct iovec vecs[2];
-        vecs[0].iov_base = (void*)&kStatsEventTag;
-        vecs[0].iov_len = sizeof(kStatsEventTag);
-        vecs[1].iov_base = buffer;
-        vecs[1].iov_len = size;
+    ret = __write_to_statsd(vecs, 2);
 
-        ret = __write_to_statsd(vecs, 2);
-
-        if (ret < 0) {
-            note_log_drop(ret, atomId);
-        }
+    if (ret < 0) {
+        note_log_drop(ret, atomId);
     }
 
     return ret;
diff --git a/libstats/socket/stats_event.c b/libstats/socket/stats_event.c
index 15039c6..f3e8087 100644
--- a/libstats/socket/stats_event.c
+++ b/libstats/socket/stats_event.c
@@ -23,29 +23,61 @@
 #define LOGGER_ENTRY_MAX_PAYLOAD 4068
 // Max payload size is 4 bytes less as 4 bytes are reserved for stats_eventTag.
 // See android_util_Stats_Log.cpp
-#define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - 4)
+#define MAX_PUSH_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - 4)
+
+#define MAX_PULL_EVENT_PAYLOAD (50 * 1024)  // 50 KB
 
 /* POSITIONS */
 #define POS_NUM_ELEMENTS 1
 #define POS_TIMESTAMP (POS_NUM_ELEMENTS + sizeof(uint8_t))
 #define POS_ATOM_ID (POS_TIMESTAMP + sizeof(uint8_t) + sizeof(uint64_t))
-#define POS_FIRST_FIELD (POS_ATOM_ID + sizeof(uint8_t) + sizeof(uint32_t))
 
 /* LIMITS */
 #define MAX_ANNOTATION_COUNT 15
 #define MAX_BYTE_VALUE 127  // parsing side requires that lengths fit in 7 bits
 
-// The stats_event struct holds the serialized encoding of an event
+/* ERRORS */
+#define ERROR_NO_TIMESTAMP 0x1
+#define ERROR_NO_ATOM_ID 0x2
+#define ERROR_OVERFLOW 0x4
+#define ERROR_ATTRIBUTION_CHAIN_TOO_LONG 0x8
+#define ERROR_TOO_MANY_KEY_VALUE_PAIRS 0x10
+#define ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD 0x20
+#define ERROR_INVALID_ANNOTATION_ID 0x40
+#define ERROR_ANNOTATION_ID_TOO_LARGE 0x80
+#define ERROR_TOO_MANY_ANNOTATIONS 0x100
+#define ERROR_TOO_MANY_FIELDS 0x200
+#define ERROR_INVALID_VALUE_TYPE 0x400
+#define ERROR_STRING_NOT_NULL_TERMINATED 0x800
+#define ERROR_ATOM_ID_INVALID_POSITION 0x2000
+
+/* TYPE IDS */
+#define INT32_TYPE 0x00
+#define INT64_TYPE 0x01
+#define STRING_TYPE 0x02
+#define LIST_TYPE 0x03
+#define FLOAT_TYPE 0x04
+#define BOOL_TYPE 0x05
+#define BYTE_ARRAY_TYPE 0x06
+#define OBJECT_TYPE 0x07
+#define KEY_VALUE_PAIRS_TYPE 0x08
+#define ATTRIBUTION_CHAIN_TYPE 0x09
+#define ERROR_TYPE 0x0F
+
+// The AStatsEvent struct holds the serialized encoding of an event
 // within a buf. Also includes other required fields.
-struct stats_event {
+struct AStatsEvent {
     uint8_t* buf;
-    size_t lastFieldPos;  // location of last field within the buf
-    size_t size;          // number of valid bytes within buffer
+    // Location of last field within the buf. Here, field denotes either a
+    // metadata field (e.g. timestamp) or an atom field.
+    size_t lastFieldPos;
+    // Number of valid bytes within the buffer.
+    size_t numBytesWritten;
     uint32_t numElements;
     uint32_t atomId;
     uint32_t errors;
-    bool truncate;
     bool built;
+    size_t bufSize;
 };
 
 static int64_t get_elapsed_realtime_ns() {
@@ -55,93 +87,115 @@
     return (int64_t)t.tv_sec * 1000000000LL + t.tv_nsec;
 }
 
-struct stats_event* stats_event_obtain() {
-    struct stats_event* event = malloc(sizeof(struct stats_event));
-    event->buf = (uint8_t*)calloc(MAX_EVENT_PAYLOAD, 1);
-    event->buf[0] = OBJECT_TYPE;
+AStatsEvent* AStatsEvent_obtain() {
+    AStatsEvent* event = malloc(sizeof(AStatsEvent));
+    event->lastFieldPos = 0;
+    event->numBytesWritten = 2;  // reserve first 2 bytes for root event type and number of elements
+    event->numElements = 0;
     event->atomId = 0;
     event->errors = 0;
-    event->truncate = true;  // truncate for both pulled and pushed atoms
     event->built = false;
+    event->bufSize = MAX_PUSH_EVENT_PAYLOAD;
+    event->buf = (uint8_t*)calloc(event->bufSize, 1);
 
-    // place the timestamp
-    uint64_t timestampNs = get_elapsed_realtime_ns();
-    event->buf[POS_TIMESTAMP] = INT64_TYPE;
-    memcpy(&event->buf[POS_TIMESTAMP + sizeof(uint8_t)], &timestampNs, sizeof(timestampNs));
-
-    event->numElements = 1;
-    event->lastFieldPos = 0;  // 0 since we haven't written a field yet
-    event->size = POS_FIRST_FIELD;
+    event->buf[0] = OBJECT_TYPE;
+    AStatsEvent_writeInt64(event, get_elapsed_realtime_ns());  // write the timestamp
 
     return event;
 }
 
-void stats_event_release(struct stats_event* event) {
+void AStatsEvent_release(AStatsEvent* event) {
     free(event->buf);
     free(event);
 }
 
-void stats_event_set_atom_id(struct stats_event* event, uint32_t atomId) {
+void AStatsEvent_setAtomId(AStatsEvent* event, uint32_t atomId) {
+    if (event->atomId != 0) return;
+    if (event->numElements != 1) {
+        event->errors |= ERROR_ATOM_ID_INVALID_POSITION;
+        return;
+    }
+
     event->atomId = atomId;
-    event->buf[POS_ATOM_ID] = INT32_TYPE;
-    memcpy(&event->buf[POS_ATOM_ID + sizeof(uint8_t)], &atomId, sizeof(atomId));
-    event->numElements++;
+    AStatsEvent_writeInt32(event, atomId);
+}
+
+// Overwrites the timestamp populated in AStatsEvent_obtain with a custom
+// timestamp. Should only be called from test code.
+void AStatsEvent_overwriteTimestamp(AStatsEvent* event, uint64_t timestampNs) {
+    memcpy(&event->buf[POS_TIMESTAMP + sizeof(uint8_t)], &timestampNs, sizeof(timestampNs));
+    // Do not increment numElements because we already accounted for the timestamp
+    // within AStatsEvent_obtain.
 }
 
 // Side-effect: modifies event->errors if the buffer would overflow
-static bool overflows(struct stats_event* event, size_t size) {
-    if (event->size + size > MAX_EVENT_PAYLOAD) {
+static bool overflows(AStatsEvent* event, size_t size) {
+    const size_t totalBytesNeeded = event->numBytesWritten + size;
+    if (totalBytesNeeded > MAX_PULL_EVENT_PAYLOAD) {
         event->errors |= ERROR_OVERFLOW;
         return true;
     }
+
+    // Expand buffer if needed.
+    if (event->bufSize < MAX_PULL_EVENT_PAYLOAD && totalBytesNeeded > event->bufSize) {
+        do {
+            event->bufSize *= 2;
+        } while (event->bufSize <= totalBytesNeeded);
+
+        if (event->bufSize > MAX_PULL_EVENT_PAYLOAD) {
+            event->bufSize = MAX_PULL_EVENT_PAYLOAD;
+        }
+
+        event->buf = (uint8_t*)realloc(event->buf, event->bufSize);
+    }
     return false;
 }
 
-// Side-effect: all append functions increment event->size if there is
+// Side-effect: all append functions increment event->numBytesWritten if there is
 // sufficient space within the buffer to place the value
-static void append_byte(struct stats_event* event, uint8_t value) {
+static void append_byte(AStatsEvent* event, uint8_t value) {
     if (!overflows(event, sizeof(value))) {
-        event->buf[event->size] = value;
-        event->size += sizeof(value);
+        event->buf[event->numBytesWritten] = value;
+        event->numBytesWritten += sizeof(value);
     }
 }
 
-static void append_bool(struct stats_event* event, bool value) {
+static void append_bool(AStatsEvent* event, bool value) {
     append_byte(event, (uint8_t)value);
 }
 
-static void append_int32(struct stats_event* event, int32_t value) {
+static void append_int32(AStatsEvent* event, int32_t value) {
     if (!overflows(event, sizeof(value))) {
-        memcpy(&event->buf[event->size], &value, sizeof(value));
-        event->size += sizeof(value);
+        memcpy(&event->buf[event->numBytesWritten], &value, sizeof(value));
+        event->numBytesWritten += sizeof(value);
     }
 }
 
-static void append_int64(struct stats_event* event, int64_t value) {
+static void append_int64(AStatsEvent* event, int64_t value) {
     if (!overflows(event, sizeof(value))) {
-        memcpy(&event->buf[event->size], &value, sizeof(value));
-        event->size += sizeof(value);
+        memcpy(&event->buf[event->numBytesWritten], &value, sizeof(value));
+        event->numBytesWritten += sizeof(value);
     }
 }
 
-static void append_float(struct stats_event* event, float value) {
+static void append_float(AStatsEvent* event, float value) {
     if (!overflows(event, sizeof(value))) {
-        memcpy(&event->buf[event->size], &value, sizeof(value));
-        event->size += sizeof(float);
+        memcpy(&event->buf[event->numBytesWritten], &value, sizeof(value));
+        event->numBytesWritten += sizeof(float);
     }
 }
 
-static void append_byte_array(struct stats_event* event, const uint8_t* buf, size_t size) {
+static void append_byte_array(AStatsEvent* event, const uint8_t* buf, size_t size) {
     if (!overflows(event, size)) {
-        memcpy(&event->buf[event->size], buf, size);
-        event->size += size;
+        memcpy(&event->buf[event->numBytesWritten], buf, size);
+        event->numBytesWritten += size;
     }
 }
 
 // Side-effect: modifies event->errors if buf is not properly null-terminated
-static void append_string(struct stats_event* event, const char* buf) {
-    size_t size = strnlen(buf, MAX_EVENT_PAYLOAD);
-    if (size == MAX_EVENT_PAYLOAD) {
+static void append_string(AStatsEvent* event, const char* buf) {
+    size_t size = strnlen(buf, MAX_PULL_EVENT_PAYLOAD);
+    if (size == MAX_PULL_EVENT_PAYLOAD) {
         event->errors |= ERROR_STRING_NOT_NULL_TERMINATED;
         return;
     }
@@ -150,61 +204,51 @@
     append_byte_array(event, (uint8_t*)buf, size);
 }
 
-static void start_field(struct stats_event* event, uint8_t typeId) {
-    event->lastFieldPos = event->size;
+static void start_field(AStatsEvent* event, uint8_t typeId) {
+    event->lastFieldPos = event->numBytesWritten;
     append_byte(event, typeId);
     event->numElements++;
 }
 
-void stats_event_write_int32(struct stats_event* event, int32_t value) {
-    if (event->errors) return;
-
+void AStatsEvent_writeInt32(AStatsEvent* event, int32_t value) {
     start_field(event, INT32_TYPE);
     append_int32(event, value);
 }
 
-void stats_event_write_int64(struct stats_event* event, int64_t value) {
-    if (event->errors) return;
-
+void AStatsEvent_writeInt64(AStatsEvent* event, int64_t value) {
     start_field(event, INT64_TYPE);
     append_int64(event, value);
 }
 
-void stats_event_write_float(struct stats_event* event, float value) {
-    if (event->errors) return;
-
+void AStatsEvent_writeFloat(AStatsEvent* event, float value) {
     start_field(event, FLOAT_TYPE);
     append_float(event, value);
 }
 
-void stats_event_write_bool(struct stats_event* event, bool value) {
-    if (event->errors) return;
-
+void AStatsEvent_writeBool(AStatsEvent* event, bool value) {
     start_field(event, BOOL_TYPE);
     append_bool(event, value);
 }
 
-void stats_event_write_byte_array(struct stats_event* event, const uint8_t* buf, size_t numBytes) {
-    if (event->errors) return;
-
+void AStatsEvent_writeByteArray(AStatsEvent* event, const uint8_t* buf, size_t numBytes) {
     start_field(event, BYTE_ARRAY_TYPE);
     append_int32(event, numBytes);
     append_byte_array(event, buf, numBytes);
 }
 
 // Value is assumed to be encoded using UTF8
-void stats_event_write_string8(struct stats_event* event, const char* value) {
-    if (event->errors) return;
-
+void AStatsEvent_writeString(AStatsEvent* event, const char* value) {
     start_field(event, STRING_TYPE);
     append_string(event, value);
 }
 
 // Tags are assumed to be encoded using UTF8
-void stats_event_write_attribution_chain(struct stats_event* event, const uint32_t* uids,
-                                         const char* const* tags, uint8_t numNodes) {
-    if (numNodes > MAX_BYTE_VALUE) event->errors |= ERROR_ATTRIBUTION_CHAIN_TOO_LONG;
-    if (event->errors) return;
+void AStatsEvent_writeAttributionChain(AStatsEvent* event, const uint32_t* uids,
+                                       const char* const* tags, uint8_t numNodes) {
+    if (numNodes > MAX_BYTE_VALUE) {
+        event->errors |= ERROR_ATTRIBUTION_CHAIN_TOO_LONG;
+        return;
+    }
 
     start_field(event, ATTRIBUTION_CHAIN_TYPE);
     append_byte(event, numNodes);
@@ -215,39 +259,8 @@
     }
 }
 
-void stats_event_write_key_value_pairs(struct stats_event* event, struct key_value_pair* pairs,
-                                       uint8_t numPairs) {
-    if (numPairs > MAX_BYTE_VALUE) event->errors |= ERROR_TOO_MANY_KEY_VALUE_PAIRS;
-    if (event->errors) return;
-
-    start_field(event, KEY_VALUE_PAIRS_TYPE);
-    append_byte(event, numPairs);
-
-    for (uint8_t i = 0; i < numPairs; i++) {
-        append_int32(event, pairs[i].key);
-        append_byte(event, pairs[i].valueType);
-        switch (pairs[i].valueType) {
-            case INT32_TYPE:
-                append_int32(event, pairs[i].int32Value);
-                break;
-            case INT64_TYPE:
-                append_int64(event, pairs[i].int64Value);
-                break;
-            case FLOAT_TYPE:
-                append_float(event, pairs[i].floatValue);
-                break;
-            case STRING_TYPE:
-                append_string(event, pairs[i].stringValue);
-                break;
-            default:
-                event->errors |= ERROR_INVALID_VALUE_TYPE;
-                return;
-        }
-    }
-}
-
 // Side-effect: modifies event->errors if field has too many annotations
-static void increment_annotation_count(struct stats_event* event) {
+static void increment_annotation_count(AStatsEvent* event) {
     uint8_t fieldType = event->buf[event->lastFieldPos] & 0x0F;
     uint32_t oldAnnotationCount = (event->buf[event->lastFieldPos] & 0xF0) >> 4;
     uint32_t newAnnotationCount = oldAnnotationCount + 1;
@@ -260,10 +273,14 @@
     event->buf[event->lastFieldPos] = (((uint8_t)newAnnotationCount << 4) & 0xF0) | fieldType;
 }
 
-void stats_event_add_bool_annotation(struct stats_event* event, uint8_t annotationId, bool value) {
-    if (event->lastFieldPos == 0) event->errors |= ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD;
-    if (annotationId > MAX_BYTE_VALUE) event->errors |= ERROR_ANNOTATION_ID_TOO_LARGE;
-    if (event->errors) return;
+void AStatsEvent_addBoolAnnotation(AStatsEvent* event, uint8_t annotationId, bool value) {
+    if (event->numElements < 2) {
+        event->errors |= ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD;
+        return;
+    } else if (annotationId > MAX_BYTE_VALUE) {
+        event->errors |= ERROR_ANNOTATION_ID_TOO_LARGE;
+        return;
+    }
 
     append_byte(event, annotationId);
     append_byte(event, BOOL_TYPE);
@@ -271,11 +288,14 @@
     increment_annotation_count(event);
 }
 
-void stats_event_add_int32_annotation(struct stats_event* event, uint8_t annotationId,
-                                      int32_t value) {
-    if (event->lastFieldPos == 0) event->errors |= ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD;
-    if (annotationId > MAX_BYTE_VALUE) event->errors |= ERROR_ANNOTATION_ID_TOO_LARGE;
-    if (event->errors) return;
+void AStatsEvent_addInt32Annotation(AStatsEvent* event, uint8_t annotationId, int32_t value) {
+    if (event->numElements < 2) {
+        event->errors |= ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD;
+        return;
+    } else if (annotationId > MAX_BYTE_VALUE) {
+        event->errors |= ERROR_ANNOTATION_ID_TOO_LARGE;
+        return;
+    }
 
     append_byte(event, annotationId);
     append_byte(event, INT32_TYPE);
@@ -283,72 +303,49 @@
     increment_annotation_count(event);
 }
 
-uint32_t stats_event_get_atom_id(struct stats_event* event) {
+uint32_t AStatsEvent_getAtomId(AStatsEvent* event) {
     return event->atomId;
 }
 
-uint8_t* stats_event_get_buffer(struct stats_event* event, size_t* size) {
-    if (size) *size = event->size;
+uint8_t* AStatsEvent_getBuffer(AStatsEvent* event, size_t* size) {
+    if (size) *size = event->numBytesWritten;
     return event->buf;
 }
 
-uint32_t stats_event_get_errors(struct stats_event* event) {
+uint32_t AStatsEvent_getErrors(AStatsEvent* event) {
     return event->errors;
 }
 
-void stats_event_truncate_buffer(struct stats_event* event, bool truncate) {
-    event->truncate = truncate;
-}
-
-void stats_event_build(struct stats_event* event) {
-    if (event->built) return;
-
-    if (event->atomId == 0) event->errors |= ERROR_NO_ATOM_ID;
-
-    if (event->numElements > MAX_BYTE_VALUE) {
-        event->errors |= ERROR_TOO_MANY_FIELDS;
-    } else {
-        event->buf[POS_NUM_ELEMENTS] = event->numElements;
-    }
+static void build_internal(AStatsEvent* event, const bool push) {
+    if (event->numElements > MAX_BYTE_VALUE) event->errors |= ERROR_TOO_MANY_FIELDS;
+    if (0 == event->atomId) event->errors |= ERROR_NO_ATOM_ID;
+    if (push && event->numBytesWritten > MAX_PUSH_EVENT_PAYLOAD) event->errors |= ERROR_OVERFLOW;
 
     // If there are errors, rewrite buffer.
     if (event->errors) {
-        event->buf[POS_NUM_ELEMENTS] = 3;
-        event->buf[POS_FIRST_FIELD] = ERROR_TYPE;
-        memcpy(&event->buf[POS_FIRST_FIELD + sizeof(uint8_t)], &event->errors,
-               sizeof(event->errors));
-        event->size = POS_FIRST_FIELD + sizeof(uint8_t) + sizeof(uint32_t);
+        // Discard everything after the atom id (including atom-level
+        // annotations). This leaves only two elements (timestamp and atom id).
+        event->numElements = 2;
+        // Reset number of atom-level annotations to 0.
+        event->buf[POS_ATOM_ID] = INT32_TYPE;
+        // Now, write errors to the buffer immediately after the atom id.
+        event->numBytesWritten = POS_ATOM_ID + sizeof(uint8_t) + sizeof(uint32_t);
+        start_field(event, ERROR_TYPE);
+        append_int32(event, event->errors);
     }
 
-    // Truncate the buffer to the appropriate length in order to limit our
-    // memory usage.
-    if (event->truncate) event->buf = (uint8_t*)realloc(event->buf, event->size);
+    event->buf[POS_NUM_ELEMENTS] = event->numElements;
+}
+
+void AStatsEvent_build(AStatsEvent* event) {
+    if (event->built) return;
+
+    build_internal(event, false /* push */);
 
     event->built = true;
 }
 
-int stats_event_write(struct stats_event* event) {
-    stats_event_build(event);
-    return write_buffer_to_statsd(&event->buf, event->size, event->atomId);
+int AStatsEvent_write(AStatsEvent* event) {
+    build_internal(event, true /* push */);
+    return write_buffer_to_statsd(event->buf, event->numBytesWritten, event->atomId);
 }
-
-struct stats_event_api_table table = {
-        stats_event_obtain,
-        stats_event_build,
-        stats_event_write,
-        stats_event_release,
-        stats_event_set_atom_id,
-        stats_event_write_int32,
-        stats_event_write_int64,
-        stats_event_write_float,
-        stats_event_write_bool,
-        stats_event_write_byte_array,
-        stats_event_write_string8,
-        stats_event_write_attribution_chain,
-        stats_event_write_key_value_pairs,
-        stats_event_add_bool_annotation,
-        stats_event_add_int32_annotation,
-        stats_event_get_atom_id,
-        stats_event_get_buffer,
-        stats_event_get_errors,
-};
diff --git a/libstats/socket/stats_event_list.c b/libstats/socket/stats_event_list.c
deleted file mode 100644
index 661a223..0000000
--- a/libstats/socket/stats_event_list.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2018, 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 "include/stats_event_list.h"
-
-#include <string.h>
-#include <sys/time.h>
-#include "stats_buffer_writer.h"
-
-#define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(int32_t))
-
-typedef struct {
-    uint32_t tag;
-    unsigned pos;                                    /* Read/write position into buffer */
-    unsigned count[ANDROID_MAX_LIST_NEST_DEPTH + 1]; /* Number of elements   */
-    unsigned list[ANDROID_MAX_LIST_NEST_DEPTH + 1];  /* pos for list counter */
-    unsigned list_nest_depth;
-    unsigned len; /* Length or raw buffer. */
-    bool overflow;
-    bool list_stop; /* next call decrement list_nest_depth and issue a stop */
-    enum {
-        kAndroidLoggerRead = 1,
-        kAndroidLoggerWrite = 2,
-    } read_write_flag;
-    uint8_t storage[LOGGER_ENTRY_MAX_PAYLOAD];
-} android_log_context_internal;
-
-// Similar to create_android_logger(), but instead of allocation a new buffer,
-// this function resets the buffer for resuse.
-void reset_log_context(android_log_context ctx) {
-    if (!ctx) {
-        return;
-    }
-    android_log_context_internal* context = (android_log_context_internal*)(ctx);
-    uint32_t tag = context->tag;
-    memset(context, 0, sizeof(android_log_context_internal));
-
-    context->tag = tag;
-    context->read_write_flag = kAndroidLoggerWrite;
-    size_t needed = sizeof(uint8_t) + sizeof(uint8_t);
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        context->overflow = true;
-    }
-    /* Everything is a list */
-    context->storage[context->pos + 0] = EVENT_TYPE_LIST;
-    context->list[0] = context->pos + 1;
-    context->pos += needed;
-}
-
-int stats_write_list(android_log_context ctx) {
-    android_log_context_internal* context;
-    const char* msg;
-    ssize_t len;
-
-    context = (android_log_context_internal*)(ctx);
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
-    }
-
-    if (context->list_nest_depth) {
-        return -EIO;
-    }
-
-    /* NB: if there was overflow, then log is truncated. Nothing reported */
-    context->storage[1] = context->count[0];
-    len = context->len = context->pos;
-    msg = (const char*)context->storage;
-    /* it's not a list */
-    if (context->count[0] <= 1) {
-        len -= sizeof(uint8_t) + sizeof(uint8_t);
-        if (len < 0) {
-            len = 0;
-        }
-        msg += sizeof(uint8_t) + sizeof(uint8_t);
-    }
-
-    return write_buffer_to_statsd((void*)msg, len, 0);
-}
-
-int write_to_logger(android_log_context ctx, log_id_t id) {
-    int retValue = 0;
-
-    if (WRITE_TO_LOGD) {
-        retValue = android_log_write_list(ctx, id);
-    }
-
-    if (WRITE_TO_STATSD) {
-        // log_event_list's cast operator is overloaded.
-        int ret = stats_write_list(ctx);
-        // In debugging phase, we may write to both logd and statsd. Prefer to
-        // return statsd socket write error code here.
-        if (ret < 0) {
-            retValue = ret;
-        }
-    }
-
-    return retValue;
-}
-
-static inline void copy4LE(uint8_t* buf, uint32_t val) {
-    buf[0] = val & 0xFF;
-    buf[1] = (val >> 8) & 0xFF;
-    buf[2] = (val >> 16) & 0xFF;
-    buf[3] = (val >> 24) & 0xFF;
-}
-
-// Note: this function differs from android_log_write_string8_len in that the length passed in
-// should be treated as actual length and not max length.
-int android_log_write_char_array(android_log_context ctx, const char* value, size_t actual_len) {
-    size_t needed;
-    ssize_t len = actual_len;
-    android_log_context_internal* context;
-
-    context = (android_log_context_internal*)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
-    }
-    if (context->overflow) {
-        return -EIO;
-    }
-    if (!value) {
-        value = "";
-        len = 0;
-    }
-    needed = sizeof(uint8_t) + sizeof(int32_t) + len;
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        /* Truncate string for delivery */
-        len = MAX_EVENT_PAYLOAD - context->pos - 1 - sizeof(int32_t);
-        if (len <= 0) {
-            context->overflow = true;
-            return -EIO;
-        }
-    }
-    context->count[context->list_nest_depth]++;
-    context->storage[context->pos + 0] = EVENT_TYPE_STRING;
-    copy4LE(&context->storage[context->pos + 1], len);
-    if (len) {
-        memcpy(&context->storage[context->pos + 5], value, len);
-    }
-    context->pos += needed;
-    return len;
-}
diff --git a/liblog/logger_write.h b/libstats/socket/stats_socket.c
similarity index 83%
rename from liblog/logger_write.h
rename to libstats/socket/stats_socket.c
index eee2778..09f8967 100644
--- a/liblog/logger_write.h
+++ b/libstats/socket/stats_socket.c
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#pragma once
+#include "include/stats_socket.h"
+#include "stats_buffer_writer.h"
 
-#include <string>
-
-std::string& GetDefaultTag();
+void AStatsSocket_close() {
+    stats_log_close();
+}
diff --git a/libstats/socket/statsd_writer.c b/libstats/socket/statsd_writer.c
index 04d3b46..73b7a7e 100644
--- a/libstats/socket/statsd_writer.c
+++ b/libstats/socket/statsd_writer.c
@@ -62,6 +62,7 @@
 static void statsdClose();
 static int statsdWrite(struct timespec* ts, struct iovec* vec, size_t nr);
 static void statsdNoteDrop();
+static int statsdIsClosed();
 
 struct android_log_transport_write statsdLoggerWrite = {
         .name = "statsd",
@@ -71,6 +72,7 @@
         .close = statsdClose,
         .write = statsdWrite,
         .noteDrop = statsdNoteDrop,
+        .isClosed = statsdIsClosed,
 };
 
 /* log_init_lock assumed */
@@ -153,6 +155,13 @@
     atomic_exchange_explicit(&atom_tag, tag, memory_order_relaxed);
 }
 
+static int statsdIsClosed() {
+    if (atomic_load(&statsdLoggerWrite.sock) < 0) {
+        return 1;
+    }
+    return 0;
+}
+
 static int statsdWrite(struct timespec* ts, struct iovec* vec, size_t nr) {
     ssize_t ret;
     int sock;
diff --git a/libstats/socket/statsd_writer.h b/libstats/socket/statsd_writer.h
index fe2d37c..562bda5 100644
--- a/libstats/socket/statsd_writer.h
+++ b/libstats/socket/statsd_writer.h
@@ -40,6 +40,8 @@
     int (*write)(struct timespec* ts, struct iovec* vec, size_t nr);
     /* note one log drop */
     void (*noteDrop)(int error, int tag);
+    /* checks if the socket is closed */
+    int (*isClosed)();
 };
 
 #endif  // ANDROID_STATS_LOG_STATS_WRITER_H
diff --git a/libstats/socket/tests/stats_event_test.cpp b/libstats/socket/tests/stats_event_test.cpp
index cf0592c..9a1fac8 100644
--- a/libstats/socket/tests/stats_event_test.cpp
+++ b/libstats/socket/tests/stats_event_test.cpp
@@ -18,13 +18,47 @@
 #include <gtest/gtest.h>
 #include <utils/SystemClock.h>
 
+// Keep in sync with stats_event.c. Consider moving to separate header file to avoid duplication.
+/* ERRORS */
+#define ERROR_NO_TIMESTAMP 0x1
+#define ERROR_NO_ATOM_ID 0x2
+#define ERROR_OVERFLOW 0x4
+#define ERROR_ATTRIBUTION_CHAIN_TOO_LONG 0x8
+#define ERROR_TOO_MANY_KEY_VALUE_PAIRS 0x10
+#define ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD 0x20
+#define ERROR_INVALID_ANNOTATION_ID 0x40
+#define ERROR_ANNOTATION_ID_TOO_LARGE 0x80
+#define ERROR_TOO_MANY_ANNOTATIONS 0x100
+#define ERROR_TOO_MANY_FIELDS 0x200
+#define ERROR_INVALID_VALUE_TYPE 0x400
+#define ERROR_STRING_NOT_NULL_TERMINATED 0x800
+#define ERROR_ATOM_ID_INVALID_POSITION 0x2000
+
+/* TYPE IDS */
+#define INT32_TYPE 0x00
+#define INT64_TYPE 0x01
+#define STRING_TYPE 0x02
+#define LIST_TYPE 0x03
+#define FLOAT_TYPE 0x04
+#define BOOL_TYPE 0x05
+#define BYTE_ARRAY_TYPE 0x06
+#define OBJECT_TYPE 0x07
+#define KEY_VALUE_PAIRS_TYPE 0x08
+#define ATTRIBUTION_CHAIN_TYPE 0x09
+#define ERROR_TYPE 0x0F
+
 using std::string;
 using std::vector;
 
 // Side-effect: this function moves the start of the buffer past the read value
 template <class T>
 T readNext(uint8_t** buffer) {
-    T value = *(T*)(*buffer);
+    T value;
+    if ((reinterpret_cast<uintptr_t>(*buffer) % alignof(T)) == 0) {
+        value = *(T*)(*buffer);
+    } else {
+        memcpy(&value, *buffer, sizeof(T));
+    }
     *buffer += sizeof(T);
     return value;
 }
@@ -61,7 +95,7 @@
 }
 
 void checkMetadata(uint8_t** buffer, uint8_t numElements, int64_t startTime, int64_t endTime,
-                   uint32_t atomId) {
+                   uint32_t atomId, uint8_t numAtomLevelAnnotations = 0) {
     // All events start with OBJECT_TYPE id.
     checkTypeHeader(buffer, OBJECT_TYPE);
 
@@ -76,7 +110,7 @@
     EXPECT_LE(timestamp, endTime);
 
     // Check atom id
-    checkTypeHeader(buffer, INT32_TYPE);
+    checkTypeHeader(buffer, INT32_TYPE, numAtomLevelAnnotations);
     checkScalar(buffer, atomId);
 }
 
@@ -88,17 +122,17 @@
     bool boolValue = false;
 
     int64_t startTime = android::elapsedRealtimeNano();
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, atomId);
-    stats_event_write_int32(event, int32Value);
-    stats_event_write_int64(event, int64Value);
-    stats_event_write_float(event, floatValue);
-    stats_event_write_bool(event, boolValue);
-    stats_event_build(event);
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+    AStatsEvent_writeInt32(event, int32Value);
+    AStatsEvent_writeInt64(event, int64Value);
+    AStatsEvent_writeFloat(event, floatValue);
+    AStatsEvent_writeBool(event, boolValue);
+    AStatsEvent_build(event);
     int64_t endTime = android::elapsedRealtimeNano();
 
     size_t bufferSize;
-    uint8_t* buffer = stats_event_get_buffer(event, &bufferSize);
+    uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize);
     uint8_t* bufferEnd = buffer + bufferSize;
 
     checkMetadata(&buffer, /*numElements=*/4, startTime, endTime, atomId);
@@ -120,8 +154,8 @@
     checkScalar(&buffer, boolValue);
 
     EXPECT_EQ(buffer, bufferEnd);  // ensure that we have read the entire buffer
-    EXPECT_EQ(stats_event_get_errors(event), 0);
-    stats_event_release(event);
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
 }
 
 TEST(StatsEventTest, TestStrings) {
@@ -129,14 +163,14 @@
     string str = "test_string";
 
     int64_t startTime = android::elapsedRealtimeNano();
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, atomId);
-    stats_event_write_string8(event, str.c_str());
-    stats_event_build(event);
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+    AStatsEvent_writeString(event, str.c_str());
+    AStatsEvent_build(event);
     int64_t endTime = android::elapsedRealtimeNano();
 
     size_t bufferSize;
-    uint8_t* buffer = stats_event_get_buffer(event, &bufferSize);
+    uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize);
     uint8_t* bufferEnd = buffer + bufferSize;
 
     checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId);
@@ -145,8 +179,8 @@
     checkString(&buffer, str);
 
     EXPECT_EQ(buffer, bufferEnd);  // ensure that we have read the entire buffer
-    EXPECT_EQ(stats_event_get_errors(event), 0);
-    stats_event_release(event);
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
 }
 
 TEST(StatsEventTest, TestByteArrays) {
@@ -154,14 +188,14 @@
     vector<uint8_t> message = {'b', 'y', 't', '\0', 'e', 's'};
 
     int64_t startTime = android::elapsedRealtimeNano();
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, atomId);
-    stats_event_write_byte_array(event, message.data(), message.size());
-    stats_event_build(event);
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+    AStatsEvent_writeByteArray(event, message.data(), message.size());
+    AStatsEvent_build(event);
     int64_t endTime = android::elapsedRealtimeNano();
 
     size_t bufferSize;
-    uint8_t* buffer = stats_event_get_buffer(event, &bufferSize);
+    uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize);
     uint8_t* bufferEnd = buffer + bufferSize;
 
     checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId);
@@ -170,8 +204,8 @@
     checkByteArray(&buffer, message);
 
     EXPECT_EQ(buffer, bufferEnd);  // ensure that we have read the entire buffer
-    EXPECT_EQ(stats_event_get_errors(event), 0);
-    stats_event_release(event);
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
 }
 
 TEST(StatsEventTest, TestAttributionChains) {
@@ -188,14 +222,14 @@
     }
 
     int64_t startTime = android::elapsedRealtimeNano();
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, atomId);
-    stats_event_write_attribution_chain(event, uids, cTags, numNodes);
-    stats_event_build(event);
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+    AStatsEvent_writeAttributionChain(event, uids, cTags, numNodes);
+    AStatsEvent_build(event);
     int64_t endTime = android::elapsedRealtimeNano();
 
     size_t bufferSize;
-    uint8_t* buffer = stats_event_get_buffer(event, &bufferSize);
+    uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize);
     uint8_t* bufferEnd = buffer + bufferSize;
 
     checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId);
@@ -208,63 +242,11 @@
     }
 
     EXPECT_EQ(buffer, bufferEnd);  // ensure that we have read the entire buffer
-    EXPECT_EQ(stats_event_get_errors(event), 0);
-    stats_event_release(event);
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
 }
 
-TEST(StatsEventTest, TestKeyValuePairs) {
-    uint32_t atomId = 100;
-
-    uint8_t numPairs = 4;
-    struct key_value_pair pairs[numPairs];
-    pairs[0] = {.key = 0, .valueType = INT32_TYPE, .int32Value = -1};
-    pairs[1] = {.key = 1, .valueType = INT64_TYPE, .int64Value = 0x123456789};
-    pairs[2] = {.key = 2, .valueType = FLOAT_TYPE, .floatValue = 5.5};
-    string str = "test_key_value_pair_string";
-    pairs[3] = {.key = 3, .valueType = STRING_TYPE, .stringValue = str.c_str()};
-
-    int64_t startTime = android::elapsedRealtimeNano();
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, atomId);
-    stats_event_write_key_value_pairs(event, pairs, numPairs);
-    stats_event_build(event);
-    int64_t endTime = android::elapsedRealtimeNano();
-
-    size_t bufferSize;
-    uint8_t* buffer = stats_event_get_buffer(event, &bufferSize);
-    uint8_t* bufferEnd = buffer + bufferSize;
-
-    checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId);
-
-    checkTypeHeader(&buffer, KEY_VALUE_PAIRS_TYPE);
-    checkScalar(&buffer, numPairs);
-
-    // first pair
-    checkScalar(&buffer, pairs[0].key);
-    checkTypeHeader(&buffer, pairs[0].valueType);
-    checkScalar(&buffer, pairs[0].int32Value);
-
-    // second pair
-    checkScalar(&buffer, pairs[1].key);
-    checkTypeHeader(&buffer, pairs[1].valueType);
-    checkScalar(&buffer, pairs[1].int64Value);
-
-    // third pair
-    checkScalar(&buffer, pairs[2].key);
-    checkTypeHeader(&buffer, pairs[2].valueType);
-    checkScalar(&buffer, pairs[2].floatValue);
-
-    // fourth pair
-    checkScalar(&buffer, pairs[3].key);
-    checkTypeHeader(&buffer, pairs[3].valueType);
-    checkString(&buffer, str);
-
-    EXPECT_EQ(buffer, bufferEnd);  // ensure that we have read the entire buffer
-    EXPECT_EQ(stats_event_get_errors(event), 0);
-    stats_event_release(event);
-}
-
-TEST(StatsEventTest, TestAnnotations) {
+TEST(StatsEventTest, TestFieldAnnotations) {
     uint32_t atomId = 100;
 
     // first element information
@@ -282,19 +264,19 @@
     bool floatAnnotation2Value = false;
 
     int64_t startTime = android::elapsedRealtimeNano();
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, 100);
-    stats_event_write_bool(event, boolValue);
-    stats_event_add_bool_annotation(event, boolAnnotation1Id, boolAnnotation1Value);
-    stats_event_add_int32_annotation(event, boolAnnotation2Id, boolAnnotation2Value);
-    stats_event_write_float(event, floatValue);
-    stats_event_add_int32_annotation(event, floatAnnotation1Id, floatAnnotation1Value);
-    stats_event_add_bool_annotation(event, floatAnnotation2Id, floatAnnotation2Value);
-    stats_event_build(event);
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+    AStatsEvent_writeBool(event, boolValue);
+    AStatsEvent_addBoolAnnotation(event, boolAnnotation1Id, boolAnnotation1Value);
+    AStatsEvent_addInt32Annotation(event, boolAnnotation2Id, boolAnnotation2Value);
+    AStatsEvent_writeFloat(event, floatValue);
+    AStatsEvent_addInt32Annotation(event, floatAnnotation1Id, floatAnnotation1Value);
+    AStatsEvent_addBoolAnnotation(event, floatAnnotation2Id, floatAnnotation2Value);
+    AStatsEvent_build(event);
     int64_t endTime = android::elapsedRealtimeNano();
 
     size_t bufferSize;
-    uint8_t* buffer = stats_event_get_buffer(event, &bufferSize);
+    uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize);
     uint8_t* bufferEnd = buffer + bufferSize;
 
     checkMetadata(&buffer, /*numElements=*/2, startTime, endTime, atomId);
@@ -312,33 +294,167 @@
     checkAnnotation(&buffer, floatAnnotation2Id, BOOL_TYPE, floatAnnotation2Value);
 
     EXPECT_EQ(buffer, bufferEnd);  // ensure that we have read the entire buffer
-    EXPECT_EQ(stats_event_get_errors(event), 0);
-    stats_event_release(event);
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
+}
+
+TEST(StatsEventTest, TestAtomLevelAnnotations) {
+    uint32_t atomId = 100;
+    // atom-level annotation information
+    uint8_t boolAnnotationId = 1;
+    uint8_t int32AnnotationId = 2;
+    bool boolAnnotationValue = false;
+    int32_t int32AnnotationValue = 5;
+
+    float fieldValue = -3.5;
+
+    int64_t startTime = android::elapsedRealtimeNano();
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+    AStatsEvent_addBoolAnnotation(event, boolAnnotationId, boolAnnotationValue);
+    AStatsEvent_addInt32Annotation(event, int32AnnotationId, int32AnnotationValue);
+    AStatsEvent_writeFloat(event, fieldValue);
+    AStatsEvent_build(event);
+    int64_t endTime = android::elapsedRealtimeNano();
+
+    size_t bufferSize;
+    uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize);
+    uint8_t* bufferEnd = buffer + bufferSize;
+
+    checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId,
+                  /*numAtomLevelAnnotations=*/2);
+
+    // check atom-level annotations
+    checkAnnotation(&buffer, boolAnnotationId, BOOL_TYPE, boolAnnotationValue);
+    checkAnnotation(&buffer, int32AnnotationId, INT32_TYPE, int32AnnotationValue);
+
+    // check first element
+    checkTypeHeader(&buffer, FLOAT_TYPE);
+    checkScalar(&buffer, fieldValue);
+
+    EXPECT_EQ(buffer, bufferEnd);  // ensure that we have read the entire buffer
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
 }
 
 TEST(StatsEventTest, TestNoAtomIdError) {
-    struct stats_event* event = stats_event_obtain();
+    AStatsEvent* event = AStatsEvent_obtain();
     // Don't set the atom id in order to trigger the error.
-    stats_event_build(event);
+    AStatsEvent_build(event);
 
-    uint32_t errors = stats_event_get_errors(event);
-    EXPECT_NE(errors | ERROR_NO_ATOM_ID, 0);
+    uint32_t errors = AStatsEvent_getErrors(event);
+    EXPECT_EQ(errors & ERROR_NO_ATOM_ID, ERROR_NO_ATOM_ID);
 
-    stats_event_release(event);
+    AStatsEvent_release(event);
 }
 
-TEST(StatsEventTest, TestOverflowError) {
-    struct stats_event* event = stats_event_obtain();
-    stats_event_set_atom_id(event, 100);
-    // Add 1000 int32s to the event. Each int32 takes 5 bytes so this will
+TEST(StatsEventTest, TestPushOverflowError) {
+    const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+    const int writeCount = 120;  // Number of times to write str in the event.
+
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, 100);
+
+    // Add str to the event 120 times. Each str takes >35 bytes so this will
     // overflow the 4068 byte buffer.
-    for (int i = 0; i < 1000; i++) {
-        stats_event_write_int32(event, 0);
+    // We want to keep writeCount less than 127 to avoid hitting
+    // ERROR_TOO_MANY_FIELDS.
+    for (int i = 0; i < writeCount; i++) {
+        AStatsEvent_writeString(event, str);
     }
-    stats_event_build(event);
+    AStatsEvent_write(event);
 
-    uint32_t errors = stats_event_get_errors(event);
-    EXPECT_NE(errors | ERROR_OVERFLOW, 0);
+    uint32_t errors = AStatsEvent_getErrors(event);
+    EXPECT_EQ(errors & ERROR_OVERFLOW, ERROR_OVERFLOW);
 
-    stats_event_release(event);
+    AStatsEvent_release(event);
+}
+
+TEST(StatsEventTest, TestPullOverflowError) {
+    const uint32_t atomId = 10100;
+    const vector<uint8_t> bytes(430 /* number of elements */, 1 /* value of each element */);
+    const int writeCount = 120;  // Number of times to write bytes in the event.
+
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+
+    // Add bytes to the event 120 times. Size of bytes is 430 so this will
+    // overflow the 50 KB pulled event buffer.
+    // We want to keep writeCount less than 127 to avoid hitting
+    // ERROR_TOO_MANY_FIELDS.
+    for (int i = 0; i < writeCount; i++) {
+        AStatsEvent_writeByteArray(event, bytes.data(), bytes.size());
+    }
+    AStatsEvent_build(event);
+
+    uint32_t errors = AStatsEvent_getErrors(event);
+    EXPECT_EQ(errors & ERROR_OVERFLOW, ERROR_OVERFLOW);
+
+    AStatsEvent_release(event);
+}
+
+TEST(StatsEventTest, TestLargePull) {
+    const uint32_t atomId = 100;
+    const string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+    const int writeCount = 120;  // Number of times to write str in the event.
+    const int64_t startTime = android::elapsedRealtimeNano();
+
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+
+    // Add str to the event 120 times.
+    // We want to keep writeCount less than 127 to avoid hitting
+    // ERROR_TOO_MANY_FIELDS.
+    for (int i = 0; i < writeCount; i++) {
+        AStatsEvent_writeString(event, str.c_str());
+    }
+    AStatsEvent_build(event);
+    int64_t endTime = android::elapsedRealtimeNano();
+
+    size_t bufferSize;
+    uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize);
+    uint8_t* bufferEnd = buffer + bufferSize;
+
+    checkMetadata(&buffer, writeCount, startTime, endTime, atomId);
+
+    // Check all instances of str have been written.
+    for (int i = 0; i < writeCount; i++) {
+        checkTypeHeader(&buffer, STRING_TYPE);
+        checkString(&buffer, str);
+    }
+
+    EXPECT_EQ(buffer, bufferEnd);  // Ensure that we have read the entire buffer.
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
+}
+
+TEST(StatsEventTest, TestAtomIdInvalidPositionError) {
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_writeInt32(event, 0);
+    AStatsEvent_setAtomId(event, 100);
+    AStatsEvent_writeBool(event, true);
+    AStatsEvent_build(event);
+
+    uint32_t errors = AStatsEvent_getErrors(event);
+    EXPECT_EQ(errors & ERROR_ATOM_ID_INVALID_POSITION, ERROR_ATOM_ID_INVALID_POSITION);
+
+    AStatsEvent_release(event);
+}
+
+TEST(StatsEventTest, TestOverwriteTimestamp) {
+    uint32_t atomId = 100;
+    int64_t expectedTimestamp = 0x123456789;
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, atomId);
+    AStatsEvent_overwriteTimestamp(event, expectedTimestamp);
+    AStatsEvent_build(event);
+
+    uint8_t* buffer = AStatsEvent_getBuffer(event, NULL);
+
+    // Make sure that the timestamp is being overwritten.
+    checkMetadata(&buffer, /*numElements=*/0, /*startTime=*/expectedTimestamp,
+                  /*endTime=*/expectedTimestamp, atomId);
+
+    EXPECT_EQ(AStatsEvent_getErrors(event), 0);
+    AStatsEvent_release(event);
 }
diff --git a/libstats/socket/tests/stats_writer_test.cpp b/libstats/socket/tests/stats_writer_test.cpp
new file mode 100644
index 0000000..749599f
--- /dev/null
+++ b/libstats/socket/tests/stats_writer_test.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 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 "stats_buffer_writer.h"
+#include "stats_event.h"
+#include "stats_socket.h"
+
+TEST(StatsWriterTest, TestSocketClose) {
+    AStatsEvent* event = AStatsEvent_obtain();
+    AStatsEvent_setAtomId(event, 100);
+    AStatsEvent_writeInt32(event, 5);
+    int successResult = AStatsEvent_write(event);
+    AStatsEvent_release(event);
+
+    // In the case of a successful write, we return the number of bytes written.
+    EXPECT_GT(successResult, 0);
+    EXPECT_FALSE(stats_log_is_closed());
+
+    AStatsSocket_close();
+
+    EXPECT_TRUE(stats_log_is_closed());
+}
diff --git a/libunwindstack/Android.bp b/libunwindstack/Android.bp
index 8cc780a..8ea286e 100644
--- a/libunwindstack/Android.bp
+++ b/libunwindstack/Android.bp
@@ -131,7 +131,6 @@
         support_system_process: true,
     },
     defaults: ["libunwindstack_defaults"],
-
     srcs: ["DexFile.cpp"],
     cflags: ["-DDEXFILE_SUPPORT"],
     shared_libs: ["libdexfile_support"],
@@ -168,9 +167,12 @@
     defaults: ["libunwindstack_defaults"],
 
     visibility: [
+        "//external/gwp_asan",
         "//system/core/debuggerd",
         "//system/core/init",
         "//system/core/libbacktrace",
+	// Temporary add the new path in preparation for migration.
+        "//system/unwinding/libbacktrace",
     ],
     apex_available: [
         "//apex_available:platform",
@@ -296,6 +298,8 @@
         "tests/files/offline/shared_lib_in_apk_memory_only_arm64/*",
         "tests/files/offline/shared_lib_in_apk_single_map_arm64/*",
         "tests/files/offline/signal_load_bias_arm/*",
+        "tests/files/offline/signal_fde_x86/*",
+        "tests/files/offline/signal_fde_x86_64/*",
         "tests/files/offline/straddle_arm/*",
         "tests/files/offline/straddle_arm64/*",
     ],
diff --git a/libunwindstack/DwarfSection.cpp b/libunwindstack/DwarfSection.cpp
index 9e2a3cd..ad25e80 100644
--- a/libunwindstack/DwarfSection.cpp
+++ b/libunwindstack/DwarfSection.cpp
@@ -37,7 +37,8 @@
 
 DwarfSection::DwarfSection(Memory* memory) : memory_(memory) {}
 
-bool DwarfSection::Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished) {
+bool DwarfSection::Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished,
+                        bool* is_signal_frame) {
   // Lookup the pc in the cache.
   auto it = loc_regs_.upper_bound(pc);
   if (it == loc_regs_.end() || pc < it->second.pc_start) {
@@ -59,6 +60,8 @@
     it = loc_regs_.emplace(loc_regs.pc_end, std::move(loc_regs)).first;
   }
 
+  *is_signal_frame = it->second.cie->is_signal_frame;
+
   // Now eval the actual registers.
   return Eval(it->second.cie, process_memory, it->second, regs, finished);
 }
@@ -241,6 +244,9 @@
           return false;
         }
         break;
+      case 'S':
+        cie->is_signal_frame = true;
+        break;
     }
   }
   return true;
@@ -465,13 +471,9 @@
         eval_info->return_address_undefined = true;
       }
       break;
-    case DWARF_LOCATION_PSEUDO_REGISTER: {
-      if (!eval_info->regs_info.regs->SetPseudoRegister(reg, loc->values[0])) {
-        last_error_.code = DWARF_ERROR_ILLEGAL_VALUE;
-        return false;
-      }
-      break;
-    }
+    case DWARF_LOCATION_PSEUDO_REGISTER:
+      last_error_.code = DWARF_ERROR_ILLEGAL_VALUE;
+      return false;
     default:
       break;
   }
@@ -543,11 +545,15 @@
         // Skip this unknown register.
         continue;
       }
-    }
-
-    reg_ptr = eval_info.regs_info.Save(reg);
-    if (!EvalRegister(&entry.second, reg, reg_ptr, &eval_info)) {
-      return false;
+      if (!eval_info.regs_info.regs->SetPseudoRegister(reg, entry.second.values[0])) {
+        last_error_.code = DWARF_ERROR_ILLEGAL_VALUE;
+        return false;
+      }
+    } else {
+      reg_ptr = eval_info.regs_info.Save(reg);
+      if (!EvalRegister(&entry.second, reg, reg_ptr, &eval_info)) {
+        return false;
+      }
     }
   }
 
@@ -558,8 +564,10 @@
     cur_regs->set_pc((*cur_regs)[cie->return_address_register]);
   }
 
-  // If the pc was set to zero, consider this the final frame.
-  *finished = (cur_regs->pc() == 0) ? true : false;
+  // If the pc was set to zero, consider this the final frame. Exception: if
+  // this is the sigreturn frame, then we want to try to recover the real PC
+  // using the return address (from LR or the stack), so keep going.
+  *finished = (cur_regs->pc() == 0 && !cie->is_signal_frame) ? true : false;
 
   cur_regs->set_sp(eval_info.cfa);
 
diff --git a/libunwindstack/Elf.cpp b/libunwindstack/Elf.cpp
index 286febc..e098a58 100644
--- a/libunwindstack/Elf.cpp
+++ b/libunwindstack/Elf.cpp
@@ -188,14 +188,15 @@
 }
 
 // The relative pc is always relative to the start of the map from which it comes.
-bool Elf::Step(uint64_t rel_pc, Regs* regs, Memory* process_memory, bool* finished) {
+bool Elf::Step(uint64_t rel_pc, Regs* regs, Memory* process_memory, bool* finished,
+               bool* is_signal_frame) {
   if (!valid_) {
     return false;
   }
 
   // Lock during the step which can update information in the object.
   std::lock_guard<std::mutex> guard(lock_);
-  return interface_->Step(rel_pc, regs, process_memory, finished);
+  return interface_->Step(rel_pc, regs, process_memory, finished, is_signal_frame);
 }
 
 bool Elf::IsValidElf(Memory* memory) {
diff --git a/libunwindstack/ElfInterface.cpp b/libunwindstack/ElfInterface.cpp
index 17470fd..0188def 100644
--- a/libunwindstack/ElfInterface.cpp
+++ b/libunwindstack/ElfInterface.cpp
@@ -499,25 +499,27 @@
   return false;
 }
 
-bool ElfInterface::Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished) {
+bool ElfInterface::Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished,
+                        bool* is_signal_frame) {
   last_error_.code = ERROR_NONE;
   last_error_.address = 0;
 
   // Try the debug_frame first since it contains the most specific unwind
   // information.
   DwarfSection* debug_frame = debug_frame_.get();
-  if (debug_frame != nullptr && debug_frame->Step(pc, regs, process_memory, finished)) {
+  if (debug_frame != nullptr &&
+      debug_frame->Step(pc, regs, process_memory, finished, is_signal_frame)) {
     return true;
   }
 
   // Try the eh_frame next.
   DwarfSection* eh_frame = eh_frame_.get();
-  if (eh_frame != nullptr && eh_frame->Step(pc, regs, process_memory, finished)) {
+  if (eh_frame != nullptr && eh_frame->Step(pc, regs, process_memory, finished, is_signal_frame)) {
     return true;
   }
 
   if (gnu_debugdata_interface_ != nullptr &&
-      gnu_debugdata_interface_->Step(pc, regs, process_memory, finished)) {
+      gnu_debugdata_interface_->Step(pc, regs, process_memory, finished, is_signal_frame)) {
     return true;
   }
 
diff --git a/libunwindstack/ElfInterfaceArm.cpp b/libunwindstack/ElfInterfaceArm.cpp
index 76f2dc8..9352a5d 100644
--- a/libunwindstack/ElfInterfaceArm.cpp
+++ b/libunwindstack/ElfInterfaceArm.cpp
@@ -100,12 +100,13 @@
   total_entries_ = ph_filesz / 8;
 }
 
-bool ElfInterfaceArm::Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished) {
+bool ElfInterfaceArm::Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished,
+                           bool* is_signal_frame) {
   // Dwarf unwind information is precise about whether a pc is covered or not,
   // but arm unwind information only has ranges of pc. In order to avoid
   // incorrectly doing a bad unwind using arm unwind information for a
   // different function, always try and unwind with the dwarf information first.
-  return ElfInterface32::Step(pc, regs, process_memory, finished) ||
+  return ElfInterface32::Step(pc, regs, process_memory, finished, is_signal_frame) ||
          StepExidx(pc, regs, process_memory, finished);
 }
 
diff --git a/libunwindstack/ElfInterfaceArm.h b/libunwindstack/ElfInterfaceArm.h
index 1d71cac..fd824f8 100644
--- a/libunwindstack/ElfInterfaceArm.h
+++ b/libunwindstack/ElfInterfaceArm.h
@@ -72,7 +72,8 @@
 
   void HandleUnknownType(uint32_t type, uint64_t ph_offset, uint64_t ph_filesz) override;
 
-  bool Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished) override;
+  bool Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished,
+            bool* is_signal_frame) override;
 
   bool StepExidx(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished);
 
diff --git a/libunwindstack/LocalUnwinder.cpp b/libunwindstack/LocalUnwinder.cpp
index 05650fb..5f51a73 100644
--- a/libunwindstack/LocalUnwinder.cpp
+++ b/libunwindstack/LocalUnwinder.cpp
@@ -113,9 +113,11 @@
     step_pc -= pc_adjustment;
 
     bool finished = false;
+    bool is_signal_frame = false;
     if (elf->StepIfSignalHandler(rel_pc, regs.get(), process_memory_.get())) {
       step_pc = rel_pc;
-    } else if (!elf->Step(step_pc, regs.get(), process_memory_.get(), &finished)) {
+    } else if (!elf->Step(step_pc, regs.get(), process_memory_.get(), &finished,
+                          &is_signal_frame)) {
       finished = true;
     }
 
diff --git a/libunwindstack/RegsX86_64.cpp b/libunwindstack/RegsX86_64.cpp
index c9e245d..26d9f65 100644
--- a/libunwindstack/RegsX86_64.cpp
+++ b/libunwindstack/RegsX86_64.cpp
@@ -141,15 +141,14 @@
     return false;
   }
 
-  uint16_t data2;
-  if (!elf_memory->ReadFully(elf_offset + 8, &data2, sizeof(data2)) || data2 != 0x0f05) {
+  uint8_t data2;
+  if (!elf_memory->ReadFully(elf_offset + 8, &data2, sizeof(data2)) || data2 != 0x05) {
     return false;
   }
 
   // __restore_rt:
   // 0x48 0xc7 0xc0 0x0f 0x00 0x00 0x00   mov $0xf,%rax
   // 0x0f 0x05                            syscall
-  // 0x0f                                 nopl 0x0($rax)
 
   // Read the mcontext data from the stack.
   // sp points to the ucontext data structure, read only the mcontext part.
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp
index b904632..9ffc0f7 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -27,6 +27,7 @@
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
 
+#include <unwindstack/DexFiles.h>
 #include <unwindstack/Elf.h>
 #include <unwindstack/JitDebug.h>
 #include <unwindstack/MapInfo.h>
@@ -34,7 +35,7 @@
 #include <unwindstack/Memory.h>
 #include <unwindstack/Unwinder.h>
 
-#include <unwindstack/DexFiles.h>
+#include "Check.h"
 
 // Use the demangler from libc++.
 extern "C" char* __cxa_demangle(const char*, char*, size_t*, int* status);
@@ -76,6 +77,7 @@
   } else {
     frame->rel_pc = dex_pc;
     warnings_ |= WARNING_DEX_PC_NOT_IN_MAP;
+    return;
   }
 
   if (!resolve_names_) {
@@ -141,13 +143,11 @@
 
 void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip,
                       const std::vector<std::string>* map_suffixes_to_ignore) {
-  frames_.clear();
-  warnings_ = WARNING_NONE;
-  last_error_.code = ERROR_NONE;
-  last_error_.address = 0;
-  elf_from_memory_not_file_ = false;
+  CHECK(arch_ != ARCH_UNKNOWN);
+  ClearErrors();
 
-  ArchEnum arch = regs_->Arch();
+  frames_.clear();
+  elf_from_memory_not_file_ = false;
 
   bool return_address_attempt = false;
   bool adjust_pc = false;
@@ -168,7 +168,7 @@
       if (ShouldStop(map_suffixes_to_ignore, map_info->name)) {
         break;
       }
-      elf = map_info->GetElf(process_memory_, arch);
+      elf = map_info->GetElf(process_memory_, arch_);
       // If this elf is memory backed, and there is a valid file, then set
       // an indicator that we couldn't open the file.
       if (!elf_from_memory_not_file_ && map_info->memory_backed_elf && !map_info->name.empty() &&
@@ -182,7 +182,7 @@
         step_pc = rel_pc;
       }
       if (adjust_pc) {
-        pc_adjustment = GetPcAdjustment(rel_pc, elf, arch);
+        pc_adjustment = GetPcAdjustment(rel_pc, elf, arch_);
       } else {
         pc_adjustment = 0;
       }
@@ -242,18 +242,21 @@
           // some of the speculative frames.
           in_device_map = true;
         } else {
+          bool is_signal_frame = false;
           if (elf->StepIfSignalHandler(rel_pc, regs_, process_memory_.get())) {
             stepped = true;
-            if (frame != nullptr) {
-              // Need to adjust the relative pc because the signal handler
-              // pc should not be adjusted.
-              frame->rel_pc = rel_pc;
-              frame->pc += pc_adjustment;
-              step_pc = rel_pc;
-            }
-          } else if (elf->Step(step_pc, regs_, process_memory_.get(), &finished)) {
+            is_signal_frame = true;
+          } else if (elf->Step(step_pc, regs_, process_memory_.get(), &finished,
+                               &is_signal_frame)) {
             stepped = true;
           }
+          if (is_signal_frame && frame != nullptr) {
+            // Need to adjust the relative pc because the signal handler
+            // pc should not be adjusted.
+            frame->rel_pc = rel_pc;
+            frame->pc += pc_adjustment;
+            step_pc = rel_pc;
+          }
           elf->GetLastError(&last_error_);
         }
       }
@@ -310,7 +313,7 @@
 
 std::string Unwinder::FormatFrame(const FrameData& frame) const {
   std::string data;
-  if (regs_->Is32Bit()) {
+  if (ArchIs32Bit(arch_)) {
     data += android::base::StringPrintf("  #%02zu pc %08" PRIx64, frame.num, frame.rel_pc);
   } else {
     data += android::base::StringPrintf("  #%02zu pc %016" PRIx64, frame.num, frame.rel_pc);
@@ -361,23 +364,33 @@
   return FormatFrame(frames_[frame_num]);
 }
 
-void Unwinder::SetJitDebug(JitDebug* jit_debug, ArchEnum arch) {
-  jit_debug->SetArch(arch);
+void Unwinder::SetJitDebug(JitDebug* jit_debug) {
+  CHECK(arch_ != ARCH_UNKNOWN);
+  jit_debug->SetArch(arch_);
   jit_debug_ = jit_debug;
 }
 
-void Unwinder::SetDexFiles(DexFiles* dex_files, ArchEnum arch) {
-  dex_files->SetArch(arch);
+void Unwinder::SetDexFiles(DexFiles* dex_files) {
+  CHECK(arch_ != ARCH_UNKNOWN);
+  dex_files->SetArch(arch_);
   dex_files_ = dex_files;
 }
 
-bool UnwinderFromPid::Init(ArchEnum arch) {
+bool UnwinderFromPid::Init() {
+  CHECK(arch_ != ARCH_UNKNOWN);
+  if (initted_) {
+    return true;
+  }
+  initted_ = true;
+
   if (pid_ == getpid()) {
     maps_ptr_.reset(new LocalMaps());
   } else {
     maps_ptr_.reset(new RemoteMaps(pid_));
   }
   if (!maps_ptr_->Parse()) {
+    ClearErrors();
+    last_error_.code = ERROR_INVALID_MAP;
     return false;
   }
   maps_ = maps_ptr_.get();
@@ -386,28 +399,38 @@
 
   jit_debug_ptr_.reset(new JitDebug(process_memory_));
   jit_debug_ = jit_debug_ptr_.get();
-  SetJitDebug(jit_debug_, arch);
+  SetJitDebug(jit_debug_);
 #if defined(DEXFILE_SUPPORT)
   dex_files_ptr_.reset(new DexFiles(process_memory_));
   dex_files_ = dex_files_ptr_.get();
-  SetDexFiles(dex_files_, arch);
+  SetDexFiles(dex_files_);
 #endif
 
   return true;
 }
 
-FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
+void UnwinderFromPid::Unwind(const std::vector<std::string>* initial_map_names_to_skip,
+                             const std::vector<std::string>* map_suffixes_to_ignore) {
+  if (!Init()) {
+    return;
+  }
+  Unwinder::Unwind(initial_map_names_to_skip, map_suffixes_to_ignore);
+}
+
+FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc, ArchEnum arch, Maps* maps,
+                                         JitDebug* jit_debug,
+                                         std::shared_ptr<Memory> process_memory,
+                                         bool resolve_names) {
   FrameData frame;
 
-  Maps* maps = GetMaps();
   MapInfo* map_info = maps->Find(pc);
-  if (!map_info) {
+  if (map_info == nullptr || arch == ARCH_UNKNOWN) {
+    frame.pc = pc;
     frame.rel_pc = pc;
     return frame;
   }
 
-  ArchEnum arch = Regs::CurrentArch();
-  Elf* elf = map_info->GetElf(GetProcessMemory(), arch);
+  Elf* elf = map_info->GetElf(process_memory, arch);
 
   uint64_t relative_pc = elf->GetRelPc(pc, map_info);
 
@@ -417,10 +440,9 @@
   uint64_t debug_pc = relative_pc;
 
   // If we don't have a valid ELF file, check the JIT.
-  if (!elf->valid()) {
-    JitDebug jit_debug(GetProcessMemory());
+  if (!elf->valid() && jit_debug != nullptr) {
     uint64_t jit_pc = pc - pc_adjustment;
-    Elf* jit_elf = jit_debug.GetElf(maps, jit_pc);
+    Elf* jit_elf = jit_debug->GetElf(maps, jit_pc);
     if (jit_elf != nullptr) {
       debug_pc = jit_pc;
       elf = jit_elf;
@@ -438,12 +460,16 @@
   frame.map_flags = map_info->flags;
   frame.map_load_bias = elf->GetLoadBias();
 
-  if (!resolve_names_ ||
-      !elf->GetFunctionName(relative_pc, &frame.function_name, &frame.function_offset)) {
+  if (!resolve_names ||
+      !elf->GetFunctionName(debug_pc, &frame.function_name, &frame.function_offset)) {
     frame.function_name = "";
     frame.function_offset = 0;
   }
   return frame;
 }
 
+FrameData Unwinder::BuildFrameFromPcOnly(uint64_t pc) {
+  return BuildFrameFromPcOnly(pc, arch_, maps_, jit_debug_, process_memory_, resolve_names_);
+}
+
 }  // namespace unwindstack
diff --git a/libunwindstack/include/unwindstack/Arch.h b/libunwindstack/include/unwindstack/Arch.h
new file mode 100644
index 0000000..7060004
--- /dev/null
+++ b/libunwindstack/include/unwindstack/Arch.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 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 _LIBUNWINDSTACK_ARCH_H
+#define _LIBUNWINDSTACK_ARCH_H
+
+#include <stddef.h>
+
+namespace unwindstack {
+
+enum ArchEnum : uint8_t {
+  ARCH_UNKNOWN = 0,
+  ARCH_ARM,
+  ARCH_ARM64,
+  ARCH_X86,
+  ARCH_X86_64,
+  ARCH_MIPS,
+  ARCH_MIPS64,
+};
+
+static inline bool ArchIs32Bit(ArchEnum arch) {
+  switch (arch) {
+    case ARCH_ARM:
+    case ARCH_X86:
+    case ARCH_MIPS:
+      return true;
+    default:
+      return false;
+  }
+}
+
+}  // namespace unwindstack
+
+#endif  // _LIBUNWINDSTACK_ARCH_H
diff --git a/libunwindstack/include/unwindstack/DwarfSection.h b/libunwindstack/include/unwindstack/DwarfSection.h
index af823da..f28cf25 100644
--- a/libunwindstack/include/unwindstack/DwarfSection.h
+++ b/libunwindstack/include/unwindstack/DwarfSection.h
@@ -106,7 +106,7 @@
 
   virtual uint64_t AdjustPcFromFde(uint64_t pc) = 0;
 
-  bool Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished);
+  bool Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* finished, bool* is_signal_frame);
 
  protected:
   DwarfMemory memory_;
diff --git a/libunwindstack/include/unwindstack/DwarfStructs.h b/libunwindstack/include/unwindstack/DwarfStructs.h
index 4b481f0..3d8c2db 100644
--- a/libunwindstack/include/unwindstack/DwarfStructs.h
+++ b/libunwindstack/include/unwindstack/DwarfStructs.h
@@ -35,6 +35,7 @@
   uint64_t code_alignment_factor = 0;
   int64_t data_alignment_factor = 0;
   uint64_t return_address_register = 0;
+  bool is_signal_frame = false;
 };
 
 struct DwarfFde {
diff --git a/libunwindstack/include/unwindstack/Elf.h b/libunwindstack/include/unwindstack/Elf.h
index 472ed92..e15b221 100644
--- a/libunwindstack/include/unwindstack/Elf.h
+++ b/libunwindstack/include/unwindstack/Elf.h
@@ -25,6 +25,7 @@
 #include <unordered_map>
 #include <utility>
 
+#include <unwindstack/Arch.h>
 #include <unwindstack/ElfInterface.h>
 #include <unwindstack/Memory.h>
 
@@ -38,16 +39,6 @@
 struct MapInfo;
 class Regs;
 
-enum ArchEnum : uint8_t {
-  ARCH_UNKNOWN = 0,
-  ARCH_ARM,
-  ARCH_ARM64,
-  ARCH_X86,
-  ARCH_X86_64,
-  ARCH_MIPS,
-  ARCH_MIPS64,
-};
-
 class Elf {
  public:
   Elf(Memory* memory) : memory_(memory) {}
@@ -69,7 +60,8 @@
 
   bool StepIfSignalHandler(uint64_t rel_pc, Regs* regs, Memory* process_memory);
 
-  bool Step(uint64_t rel_pc, Regs* regs, Memory* process_memory, bool* finished);
+  bool Step(uint64_t rel_pc, Regs* regs, Memory* process_memory, bool* finished,
+            bool* is_signal_frame);
 
   ElfInterface* CreateInterfaceFromMemory(Memory* memory);
 
diff --git a/libunwindstack/include/unwindstack/ElfInterface.h b/libunwindstack/include/unwindstack/ElfInterface.h
index 0c39b23..5df7ddf 100644
--- a/libunwindstack/include/unwindstack/ElfInterface.h
+++ b/libunwindstack/include/unwindstack/ElfInterface.h
@@ -64,7 +64,8 @@
 
   virtual std::string GetBuildID() = 0;
 
-  virtual bool Step(uint64_t rel_pc, Regs* regs, Memory* process_memory, bool* finished);
+  virtual bool Step(uint64_t rel_pc, Regs* regs, Memory* process_memory, bool* finished,
+                    bool* is_signal_frame);
 
   virtual bool IsValidPc(uint64_t pc);
 
diff --git a/libunwindstack/include/unwindstack/Error.h b/libunwindstack/include/unwindstack/Error.h
index 66fefe7..0be4572 100644
--- a/libunwindstack/include/unwindstack/Error.h
+++ b/libunwindstack/include/unwindstack/Error.h
@@ -39,6 +39,27 @@
   ERROR_INVALID_ELF,          // Unwind in an invalid elf.
 };
 
+static inline const char* GetErrorCodeString(ErrorCode error) {
+  switch (error) {
+    case ERROR_NONE:
+      return "None";
+    case ERROR_MEMORY_INVALID:
+      return "Memory Invalid";
+    case ERROR_UNWIND_INFO:
+      return "Unwind Info";
+    case ERROR_UNSUPPORTED:
+      return "Unsupported";
+    case ERROR_INVALID_MAP:
+      return "Invalid Map";
+    case ERROR_MAX_FRAMES_EXCEEDED:
+      return "Maximum Frames Exceeded";
+    case ERROR_REPEATED_FRAME:
+      return "Repeated Frame";
+    case ERROR_INVALID_ELF:
+      return "Invalid Elf";
+  }
+}
+
 struct ErrorData {
   ErrorCode code;
   uint64_t address;  // Only valid when code is ERROR_MEMORY_INVALID.
diff --git a/libunwindstack/include/unwindstack/Regs.h b/libunwindstack/include/unwindstack/Regs.h
index 5f42565..1a2a704 100644
--- a/libunwindstack/include/unwindstack/Regs.h
+++ b/libunwindstack/include/unwindstack/Regs.h
@@ -24,11 +24,12 @@
 #include <string>
 #include <vector>
 
+#include <unwindstack/Arch.h>
+
 namespace unwindstack {
 
 // Forward declarations.
 class Elf;
-enum ArchEnum : uint8_t;
 class Memory;
 
 class Regs {
@@ -52,7 +53,7 @@
 
   virtual ArchEnum Arch() = 0;
 
-  virtual bool Is32Bit() = 0;
+  bool Is32Bit() { return ArchIs32Bit(Arch()); }
 
   virtual void* RawData() = 0;
   virtual uint64_t pc() = 0;
@@ -96,8 +97,6 @@
       : Regs(total_regs, return_loc), regs_(total_regs) {}
   virtual ~RegsImpl() = default;
 
-  bool Is32Bit() override { return sizeof(AddressType) == sizeof(uint32_t); }
-
   inline AddressType& operator[](size_t reg) { return regs_[reg]; }
 
   void* RawData() override { return regs_.data(); }
diff --git a/libunwindstack/include/unwindstack/Unwinder.h b/libunwindstack/include/unwindstack/Unwinder.h
index a974b63..b274c4c 100644
--- a/libunwindstack/include/unwindstack/Unwinder.h
+++ b/libunwindstack/include/unwindstack/Unwinder.h
@@ -24,6 +24,7 @@
 #include <string>
 #include <vector>
 
+#include <unwindstack/Arch.h>
 #include <unwindstack/DexFiles.h>
 #include <unwindstack/Error.h>
 #include <unwindstack/JitDebug.h>
@@ -35,7 +36,6 @@
 
 // Forward declarations.
 class Elf;
-enum ArchEnum : uint8_t;
 
 struct FrameData {
   size_t num;
@@ -64,7 +64,11 @@
 class Unwinder {
  public:
   Unwinder(size_t max_frames, Maps* maps, Regs* regs, std::shared_ptr<Memory> process_memory)
-      : max_frames_(max_frames), maps_(maps), regs_(regs), process_memory_(process_memory) {
+      : max_frames_(max_frames),
+        maps_(maps),
+        regs_(regs),
+        process_memory_(process_memory),
+        arch_(regs->Arch()) {
     frames_.reserve(max_frames);
   }
   Unwinder(size_t max_frames, Maps* maps, std::shared_ptr<Memory> process_memory)
@@ -74,8 +78,8 @@
 
   virtual ~Unwinder() = default;
 
-  void Unwind(const std::vector<std::string>* initial_map_names_to_skip = nullptr,
-              const std::vector<std::string>* map_suffixes_to_ignore = nullptr);
+  virtual void Unwind(const std::vector<std::string>* initial_map_names_to_skip = nullptr,
+                      const std::vector<std::string>* map_suffixes_to_ignore = nullptr);
 
   size_t NumFrames() const { return frames_.size(); }
 
@@ -90,9 +94,14 @@
   std::string FormatFrame(size_t frame_num) const;
   std::string FormatFrame(const FrameData& frame) const;
 
-  void SetJitDebug(JitDebug* jit_debug, ArchEnum arch);
+  void SetArch(ArchEnum arch) { arch_ = arch; };
 
-  void SetRegs(Regs* regs) { regs_ = regs; }
+  void SetJitDebug(JitDebug* jit_debug);
+
+  void SetRegs(Regs* regs) {
+    regs_ = regs;
+    arch_ = regs_ != nullptr ? regs->Arch() : ARCH_UNKNOWN;
+  }
   Maps* GetMaps() { return maps_; }
   std::shared_ptr<Memory>& GetProcessMemory() { return process_memory_; }
 
@@ -107,11 +116,12 @@
 
   void SetDisplayBuildID(bool display_build_id) { display_build_id_ = display_build_id; }
 
-  void SetDexFiles(DexFiles* dex_files, ArchEnum arch);
+  void SetDexFiles(DexFiles* dex_files);
 
   bool elf_from_memory_not_file() { return elf_from_memory_not_file_; }
 
   ErrorCode LastErrorCode() { return last_error_.code; }
+  const char* LastErrorCodeString() { return GetErrorCodeString(last_error_.code); }
   uint64_t LastErrorAddress() { return last_error_.address; }
   uint64_t warnings() { return warnings_; }
 
@@ -120,10 +130,21 @@
   // frames collected by frame-pointer unwinding that's done outside of
   // libunwindstack. This is used by tombstoned to symbolize frame pointer-based
   // stack traces that are collected by tools such as GWP-ASan and MTE.
+  static FrameData BuildFrameFromPcOnly(uint64_t pc, ArchEnum arch, Maps* maps, JitDebug* jit_debug,
+                                        std::shared_ptr<Memory> process_memory, bool resolve_names);
   FrameData BuildFrameFromPcOnly(uint64_t pc);
 
  protected:
   Unwinder(size_t max_frames) : max_frames_(max_frames) { frames_.reserve(max_frames); }
+  Unwinder(size_t max_frames, ArchEnum arch) : max_frames_(max_frames), arch_(arch) {
+    frames_.reserve(max_frames);
+  }
+
+  void ClearErrors() {
+    warnings_ = WARNING_NONE;
+    last_error_.code = ERROR_NONE;
+    last_error_.address = 0;
+  }
 
   void FillInDexFrame();
   FrameData* FillInFrame(MapInfo* map_info, Elf* elf, uint64_t rel_pc, uint64_t pc_adjustment);
@@ -143,20 +164,27 @@
   bool elf_from_memory_not_file_ = false;
   ErrorData last_error_;
   uint64_t warnings_;
+  ArchEnum arch_ = ARCH_UNKNOWN;
 };
 
 class UnwinderFromPid : public Unwinder {
  public:
   UnwinderFromPid(size_t max_frames, pid_t pid) : Unwinder(max_frames), pid_(pid) {}
+  UnwinderFromPid(size_t max_frames, pid_t pid, ArchEnum arch)
+      : Unwinder(max_frames, arch), pid_(pid) {}
   virtual ~UnwinderFromPid() = default;
 
-  bool Init(ArchEnum arch);
+  bool Init();
+
+  void Unwind(const std::vector<std::string>* initial_map_names_to_skip = nullptr,
+              const std::vector<std::string>* map_suffixes_to_ignore = nullptr) override;
 
  private:
   pid_t pid_;
   std::unique_ptr<Maps> maps_ptr_;
   std::unique_ptr<JitDebug> jit_debug_ptr_;
   std::unique_ptr<DexFiles> dex_files_ptr_;
+  bool initted_ = false;
 };
 
 }  // namespace unwindstack
diff --git a/libunwindstack/tests/DwarfSectionImplTest.cpp b/libunwindstack/tests/DwarfSectionImplTest.cpp
index d57cd33..a08a8d0 100644
--- a/libunwindstack/tests/DwarfSectionImplTest.cpp
+++ b/libunwindstack/tests/DwarfSectionImplTest.cpp
@@ -492,6 +492,40 @@
   EXPECT_EQ(0x80000000U, regs.pc());
 }
 
+TYPED_TEST_P(DwarfSectionImplTest, Eval_pseudo_register_invalid) {
+  DwarfCie cie{.return_address_register = 5};
+  RegsImplFake<TypeParam> regs(10);
+  regs.set_pseudo_reg(11);
+  dwarf_loc_regs_t loc_regs;
+
+  loc_regs[CFA_REG] = DwarfLocation{DWARF_LOCATION_REGISTER, {8, 0}};
+  loc_regs[1] = DwarfLocation{DWARF_LOCATION_PSEUDO_REGISTER, {20, 0}};
+  bool finished;
+  ASSERT_FALSE(this->section_->Eval(&cie, &this->memory_, loc_regs, &regs, &finished));
+  EXPECT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->section_->LastErrorCode());
+
+  loc_regs.clear();
+  loc_regs[CFA_REG] = DwarfLocation{DWARF_LOCATION_REGISTER, {8, 0}};
+  loc_regs[12] = DwarfLocation{DWARF_LOCATION_PSEUDO_REGISTER, {20, 0}};
+  ASSERT_FALSE(this->section_->Eval(&cie, &this->memory_, loc_regs, &regs, &finished));
+  EXPECT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->section_->LastErrorCode());
+}
+
+TYPED_TEST_P(DwarfSectionImplTest, Eval_pseudo_register) {
+  DwarfCie cie{.return_address_register = 5};
+  RegsImplFake<TypeParam> regs(10);
+  regs.set_pseudo_reg(11);
+  dwarf_loc_regs_t loc_regs;
+
+  loc_regs[CFA_REG] = DwarfLocation{DWARF_LOCATION_REGISTER, {8, 0}};
+  loc_regs[11] = DwarfLocation{DWARF_LOCATION_PSEUDO_REGISTER, {20, 0}};
+  bool finished;
+  ASSERT_TRUE(this->section_->Eval(&cie, &this->memory_, loc_regs, &regs, &finished));
+  uint64_t pseudo_value = 0;
+  ASSERT_TRUE(regs.GetPseudoRegister(11, &pseudo_value));
+  EXPECT_EQ(20U, pseudo_value);
+}
+
 TYPED_TEST_P(DwarfSectionImplTest, GetCfaLocationInfo_cie_not_cached) {
   DwarfCie cie{};
   cie.cfa_instructions_offset = 0x3000;
@@ -581,6 +615,7 @@
                             Eval_invalid_register, Eval_different_reg_locations,
                             Eval_return_address_undefined, Eval_pc_zero, Eval_return_address,
                             Eval_ignore_large_reg_loc, Eval_reg_expr, Eval_reg_val_expr,
+                            Eval_pseudo_register_invalid, Eval_pseudo_register,
                             GetCfaLocationInfo_cie_not_cached, GetCfaLocationInfo_cie_cached, Log);
 
 typedef ::testing::Types<uint32_t, uint64_t> DwarfSectionImplTestTypes;
diff --git a/libunwindstack/tests/DwarfSectionTest.cpp b/libunwindstack/tests/DwarfSectionTest.cpp
index febd6d3..e5a1aed 100644
--- a/libunwindstack/tests/DwarfSectionTest.cpp
+++ b/libunwindstack/tests/DwarfSectionTest.cpp
@@ -68,7 +68,8 @@
   EXPECT_CALL(*section_, GetFdeFromPc(0x1000)).WillOnce(::testing::Return(nullptr));
 
   bool finished;
-  ASSERT_FALSE(section_->Step(0x1000, nullptr, nullptr, &finished));
+  bool is_signal_frame;
+  ASSERT_FALSE(section_->Step(0x1000, nullptr, nullptr, &finished, &is_signal_frame));
 }
 
 TEST_F(DwarfSectionTest, Step_fail_cie_null) {
@@ -79,7 +80,8 @@
   EXPECT_CALL(*section_, GetFdeFromPc(0x1000)).WillOnce(::testing::Return(&fde));
 
   bool finished;
-  ASSERT_FALSE(section_->Step(0x1000, &regs_, nullptr, &finished));
+  bool is_signal_frame;
+  ASSERT_FALSE(section_->Step(0x1000, &regs_, nullptr, &finished, &is_signal_frame));
 }
 
 TEST_F(DwarfSectionTest, Step_fail_cfa_location) {
@@ -93,7 +95,8 @@
       .WillOnce(::testing::Return(false));
 
   bool finished;
-  ASSERT_FALSE(section_->Step(0x1000, &regs_, nullptr, &finished));
+  bool is_signal_frame;
+  ASSERT_FALSE(section_->Step(0x1000, &regs_, nullptr, &finished, &is_signal_frame));
 }
 
 TEST_F(DwarfSectionTest, Step_pass) {
@@ -111,7 +114,8 @@
       .WillOnce(::testing::Return(true));
 
   bool finished;
-  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished));
+  bool is_signal_frame;
+  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished, &is_signal_frame));
 }
 
 static bool MockGetCfaLocationInfo(::testing::Unused, const DwarfFde* fde,
@@ -137,9 +141,10 @@
       .WillRepeatedly(::testing::Return(true));
 
   bool finished;
-  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished));
-  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished));
-  ASSERT_TRUE(section_->Step(0x1500, &regs_, &process, &finished));
+  bool is_signal_frame;
+  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished, &is_signal_frame));
+  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished, &is_signal_frame));
+  ASSERT_TRUE(section_->Step(0x1500, &regs_, &process, &finished, &is_signal_frame));
 }
 
 TEST_F(DwarfSectionTest, Step_cache_not_in_pc) {
@@ -157,7 +162,8 @@
       .WillRepeatedly(::testing::Return(true));
 
   bool finished;
-  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished));
+  bool is_signal_frame;
+  ASSERT_TRUE(section_->Step(0x1000, &regs_, &process, &finished, &is_signal_frame));
 
   DwarfFde fde1{};
   fde1.pc_start = 0x500;
@@ -167,8 +173,8 @@
   EXPECT_CALL(*section_, GetCfaLocationInfo(0x600, &fde1, ::testing::_, ::testing::_))
       .WillOnce(::testing::Invoke(MockGetCfaLocationInfo));
 
-  ASSERT_TRUE(section_->Step(0x600, &regs_, &process, &finished));
-  ASSERT_TRUE(section_->Step(0x700, &regs_, &process, &finished));
+  ASSERT_TRUE(section_->Step(0x600, &regs_, &process, &finished, &is_signal_frame));
+  ASSERT_TRUE(section_->Step(0x700, &regs_, &process, &finished, &is_signal_frame));
 }
 
 }  // namespace unwindstack
diff --git a/libunwindstack/tests/ElfFake.cpp b/libunwindstack/tests/ElfFake.cpp
index 3d5ddd6..b16cd53 100644
--- a/libunwindstack/tests/ElfFake.cpp
+++ b/libunwindstack/tests/ElfFake.cpp
@@ -52,7 +52,7 @@
   return true;
 }
 
-bool ElfInterfaceFake::Step(uint64_t, Regs* regs, Memory*, bool* finished) {
+bool ElfInterfaceFake::Step(uint64_t, Regs* regs, Memory*, bool* finished, bool* is_signal_frame) {
   if (steps_.empty()) {
     return false;
   }
@@ -68,6 +68,7 @@
   fake_regs->set_pc(entry.pc);
   fake_regs->set_sp(entry.sp);
   *finished = entry.finished;
+  *is_signal_frame = false;
   return true;
 }
 
diff --git a/libunwindstack/tests/ElfFake.h b/libunwindstack/tests/ElfFake.h
index 3b6cb80..abda7b8 100644
--- a/libunwindstack/tests/ElfFake.h
+++ b/libunwindstack/tests/ElfFake.h
@@ -76,7 +76,7 @@
   bool GetGlobalVariable(const std::string&, uint64_t*) override;
   std::string GetBuildID() override { return fake_build_id_; }
 
-  bool Step(uint64_t, Regs*, Memory*, bool*) override;
+  bool Step(uint64_t, Regs*, Memory*, bool*, bool*) override;
 
   void FakeSetGlobalVariable(const std::string& global, uint64_t offset) {
     globals_[global] = offset;
diff --git a/libunwindstack/tests/ElfTest.cpp b/libunwindstack/tests/ElfTest.cpp
index f0852a4..d81edbf 100644
--- a/libunwindstack/tests/ElfTest.cpp
+++ b/libunwindstack/tests/ElfTest.cpp
@@ -138,7 +138,8 @@
   EXPECT_EQ(ERROR_INVALID_ELF, elf.GetLastErrorCode());
 
   bool finished;
-  ASSERT_FALSE(elf.Step(0, nullptr, nullptr, &finished));
+  bool is_signal_frame;
+  ASSERT_FALSE(elf.Step(0, nullptr, nullptr, &finished, &is_signal_frame));
   EXPECT_EQ(ERROR_INVALID_ELF, elf.GetLastErrorCode());
 }
 
@@ -327,7 +328,7 @@
   bool GetFunctionName(uint64_t, std::string*, uint64_t*) override { return false; }
   std::string GetBuildID() override { return ""; }
 
-  MOCK_METHOD(bool, Step, (uint64_t, Regs*, Memory*, bool*), (override));
+  MOCK_METHOD(bool, Step, (uint64_t, Regs*, Memory*, bool*, bool*), (override));
   MOCK_METHOD(bool, GetGlobalVariable, (const std::string&, uint64_t*), (override));
   MOCK_METHOD(bool, IsValidPc, (uint64_t), (override));
 
@@ -351,10 +352,11 @@
   MemoryFake process_memory;
 
   bool finished;
-  EXPECT_CALL(*interface, Step(0x1000, &regs, &process_memory, &finished))
+  bool is_signal_frame;
+  EXPECT_CALL(*interface, Step(0x1000, &regs, &process_memory, &finished, &is_signal_frame))
       .WillOnce(::testing::Return(true));
 
-  ASSERT_TRUE(elf.Step(0x1000, &regs, &process_memory, &finished));
+  ASSERT_TRUE(elf.Step(0x1000, &regs, &process_memory, &finished, &is_signal_frame));
 }
 
 TEST_F(ElfTest, get_global_invalid_elf) {
diff --git a/libunwindstack/tests/RegsFake.h b/libunwindstack/tests/RegsFake.h
index 75fc9d0..f67d7dc 100644
--- a/libunwindstack/tests/RegsFake.h
+++ b/libunwindstack/tests/RegsFake.h
@@ -83,15 +83,33 @@
   uint64_t sp() override { return fake_sp_; }
   void set_pc(uint64_t pc) override { fake_pc_ = pc; }
   void set_sp(uint64_t sp) override { fake_sp_ = sp; }
+  void set_pseudo_reg(uint64_t reg) { fake_pseudo_reg_ = reg; }
 
   bool SetPcFromReturnAddress(Memory*) override { return false; }
   bool StepIfSignalHandler(uint64_t, Elf*, Memory*) override { return false; }
 
+  bool SetPseudoRegister(uint16_t reg, uint64_t value) override {
+    if (fake_pseudo_reg_ != reg) {
+      return false;
+    }
+    fake_pseudo_reg_value_ = value;
+    return true;
+  }
+  bool GetPseudoRegister(uint16_t reg, uint64_t* value) override {
+    if (fake_pseudo_reg_ != reg) {
+      return false;
+    }
+    *value = fake_pseudo_reg_value_;
+    return true;
+  }
+
   Regs* Clone() override { return nullptr; }
 
  private:
   uint64_t fake_pc_ = 0;
   uint64_t fake_sp_ = 0;
+  uint16_t fake_pseudo_reg_ = 0;
+  uint64_t fake_pseudo_reg_value_ = 0;
 };
 
 }  // namespace unwindstack
diff --git a/libunwindstack/tests/UnwindOfflineTest.cpp b/libunwindstack/tests/UnwindOfflineTest.cpp
index c2bd836..ab427b5 100644
--- a/libunwindstack/tests/UnwindOfflineTest.cpp
+++ b/libunwindstack/tests/UnwindOfflineTest.cpp
@@ -314,7 +314,7 @@
 
   JitDebug jit_debug(process_memory_);
   Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
-  unwinder.SetJitDebug(&jit_debug, regs_->Arch());
+  unwinder.SetJitDebug(&jit_debug);
   unwinder.Unwind();
 
   std::string frame_info(DumpFrames(unwinder));
@@ -616,7 +616,7 @@
 
   JitDebug jit_debug(process_memory_);
   Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
-  unwinder.SetJitDebug(&jit_debug, regs_->Arch());
+  unwinder.SetJitDebug(&jit_debug);
   unwinder.Unwind();
 
   std::string frame_info(DumpFrames(unwinder));
@@ -939,7 +939,7 @@
   std::unique_ptr<Regs> regs_copy(leak_data->regs->Clone());
   JitDebug jit_debug(leak_data->process_memory);
   Unwinder unwinder(128, leak_data->maps, regs_copy.get(), leak_data->process_memory);
-  unwinder.SetJitDebug(&jit_debug, regs_copy->Arch());
+  unwinder.SetJitDebug(&jit_debug);
   unwinder.Unwind();
   ASSERT_EQ(76U, unwinder.NumFrames());
 }
@@ -1062,7 +1062,7 @@
 
   JitDebug jit_debug(process_memory_);
   Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
-  unwinder.SetJitDebug(&jit_debug, regs_->Arch());
+  unwinder.SetJitDebug(&jit_debug);
   unwinder.Unwind();
 
   std::string frame_info(DumpFrames(unwinder));
@@ -1736,4 +1736,158 @@
   EXPECT_EQ(0x7ffb6c0f30U, unwinder.frames()[6].sp);
 }
 
+// This test has a libc.so where the __restore has been changed so
+// that the signal handler match does not occur and it uses the
+// fde to do the unwind.
+TEST_F(UnwindOfflineTest, signal_fde_x86) {
+  ASSERT_NO_FATAL_FAILURE(Init("signal_fde_x86/", ARCH_X86));
+
+  Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
+  unwinder.Unwind();
+
+  std::string frame_info(DumpFrames(unwinder));
+  ASSERT_EQ(20U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
+  EXPECT_EQ(
+      "  #00 pc 007914d9  libunwindstack_test (SignalInnerFunction+25)\n"
+      "  #01 pc 007914fc  libunwindstack_test (SignalMiddleFunction+28)\n"
+      "  #02 pc 0079152c  libunwindstack_test (SignalOuterFunction+28)\n"
+      "  #03 pc 0079af62  libunwindstack_test (unwindstack::SignalCallerHandler(int, siginfo*, "
+      "void*)+50)\n"
+      "  #04 pc 00058fb0  libc.so (__restore)\n"
+      "  #05 pc 00000000  <unknown>\n"
+      "  #06 pc 0079161a  libunwindstack_test (InnerFunction+218)\n"
+      "  #07 pc 007923aa  libunwindstack_test (MiddleFunction+42)\n"
+      "  #08 pc 007923ea  libunwindstack_test (OuterFunction+42)\n"
+      "  #09 pc 00797444  libunwindstack_test (unwindstack::RemoteThroughSignal(int, unsigned "
+      "int)+868)\n"
+      "  #10 pc 007985b8  libunwindstack_test "
+      "(unwindstack::UnwindTest_remote_through_signal_with_invalid_func_Test::TestBody()+56)\n"
+      "  #11 pc 00817a19  libunwindstack_test\n"
+      "  #12 pc 008178c5  libunwindstack_test (testing::Test::Run()+277)\n"
+      "  #13 pc 00818d3e  libunwindstack_test (testing::TestInfo::Run()+318)\n"
+      "  #14 pc 008198b4  libunwindstack_test (testing::TestSuite::Run()+436)\n"
+      "  #15 pc 00828cb0  libunwindstack_test "
+      "(testing::internal::UnitTestImpl::RunAllTests()+1216)\n"
+      "  #16 pc 0082870f  libunwindstack_test (testing::UnitTest::Run()+367)\n"
+      "  #17 pc 0084031e  libunwindstack_test (IsolateMain+2334)\n"
+      "  #18 pc 0083f9e9  libunwindstack_test (main+41)\n"
+      "  #19 pc 00050646  libc.so (__libc_init+118)\n",
+      frame_info);
+
+  EXPECT_EQ(0x5ae0d4d9U, unwinder.frames()[0].pc);
+  EXPECT_EQ(0xecb37188U, unwinder.frames()[0].sp);
+  EXPECT_EQ(0x5ae0d4fcU, unwinder.frames()[1].pc);
+  EXPECT_EQ(0xecb37190U, unwinder.frames()[1].sp);
+  EXPECT_EQ(0x5ae0d52cU, unwinder.frames()[2].pc);
+  EXPECT_EQ(0xecb371b0U, unwinder.frames()[2].sp);
+  EXPECT_EQ(0x5ae16f62U, unwinder.frames()[3].pc);
+  EXPECT_EQ(0xecb371d0U, unwinder.frames()[3].sp);
+  EXPECT_EQ(0xec169fb0U, unwinder.frames()[4].pc);
+  EXPECT_EQ(0xecb371f0U, unwinder.frames()[4].sp);
+  EXPECT_EQ(0x0U, unwinder.frames()[5].pc);
+  EXPECT_EQ(0xffcfac6cU, unwinder.frames()[5].sp);
+  EXPECT_EQ(0x5ae0d61aU, unwinder.frames()[6].pc);
+  EXPECT_EQ(0xffcfac6cU, unwinder.frames()[6].sp);
+  EXPECT_EQ(0x5ae0e3aaU, unwinder.frames()[7].pc);
+  EXPECT_EQ(0xffcfad60U, unwinder.frames()[7].sp);
+  EXPECT_EQ(0x5ae0e3eaU, unwinder.frames()[8].pc);
+  EXPECT_EQ(0xffcfad90U, unwinder.frames()[8].sp);
+  EXPECT_EQ(0x5ae13444U, unwinder.frames()[9].pc);
+  EXPECT_EQ(0xffcfadc0U, unwinder.frames()[9].sp);
+  EXPECT_EQ(0x5ae145b8U, unwinder.frames()[10].pc);
+  EXPECT_EQ(0xffcfb020U, unwinder.frames()[10].sp);
+  EXPECT_EQ(0x5ae93a19U, unwinder.frames()[11].pc);
+  EXPECT_EQ(0xffcfb050U, unwinder.frames()[11].sp);
+  EXPECT_EQ(0x5ae938c5U, unwinder.frames()[12].pc);
+  EXPECT_EQ(0xffcfb090U, unwinder.frames()[12].sp);
+  EXPECT_EQ(0x5ae94d3eU, unwinder.frames()[13].pc);
+  EXPECT_EQ(0xffcfb0f0U, unwinder.frames()[13].sp);
+  EXPECT_EQ(0x5ae958b4U, unwinder.frames()[14].pc);
+  EXPECT_EQ(0xffcfb160U, unwinder.frames()[14].sp);
+  EXPECT_EQ(0x5aea4cb0U, unwinder.frames()[15].pc);
+  EXPECT_EQ(0xffcfb1d0U, unwinder.frames()[15].sp);
+  EXPECT_EQ(0x5aea470fU, unwinder.frames()[16].pc);
+  EXPECT_EQ(0xffcfb270U, unwinder.frames()[16].sp);
+  EXPECT_EQ(0x5aebc31eU, unwinder.frames()[17].pc);
+  EXPECT_EQ(0xffcfb2c0U, unwinder.frames()[17].sp);
+  EXPECT_EQ(0x5aebb9e9U, unwinder.frames()[18].pc);
+  EXPECT_EQ(0xffcfc3c0U, unwinder.frames()[18].sp);
+  EXPECT_EQ(0xec161646U, unwinder.frames()[19].pc);
+  EXPECT_EQ(0xffcfc3f0U, unwinder.frames()[19].sp);
+}
+
+// This test has a libc.so where the __restore_rt has been changed so
+// that the signal handler match does not occur and it uses the
+// fde to do the unwind.
+TEST_F(UnwindOfflineTest, signal_fde_x86_64) {
+  ASSERT_NO_FATAL_FAILURE(Init("signal_fde_x86_64/", ARCH_X86_64));
+
+  Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
+  unwinder.Unwind();
+
+  std::string frame_info(DumpFrames(unwinder));
+  ASSERT_EQ(18U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
+  EXPECT_EQ(
+      "  #00 pc 000000000058415b  libunwindstack_test (SignalInnerFunction+11)\n"
+      "  #01 pc 0000000000584168  libunwindstack_test (SignalMiddleFunction+8)\n"
+      "  #02 pc 0000000000584178  libunwindstack_test (SignalOuterFunction+8)\n"
+      "  #03 pc 000000000058ac77  libunwindstack_test (unwindstack::SignalCallerHandler(int, "
+      "siginfo*, void*)+23)\n"
+      "  #04 pc 0000000000057d10  libc.so (__restore_rt)\n"
+      "  #05 pc 0000000000000000  <unknown>\n"
+      "  #06 pc 0000000000584244  libunwindstack_test (InnerFunction+196)\n"
+      "  #07 pc 0000000000584b44  libunwindstack_test (MiddleFunction+20)\n"
+      "  #08 pc 0000000000584b64  libunwindstack_test (OuterFunction+20)\n"
+      "  #09 pc 0000000000588457  libunwindstack_test (unwindstack::RemoteThroughSignal(int, "
+      "unsigned int)+583)\n"
+      "  #10 pc 0000000000588f67  libunwindstack_test "
+      "(unwindstack::UnwindTest_remote_through_signal_with_invalid_func_Test::TestBody()+23)\n"
+      "  #11 pc 00000000005d9c38  libunwindstack_test (testing::Test::Run()+216)\n"
+      "  #12 pc 00000000005daf9a  libunwindstack_test (testing::TestInfo::Run()+266)\n"
+      "  #13 pc 00000000005dba46  libunwindstack_test (testing::TestSuite::Run()+390)\n"
+      "  #14 pc 00000000005ea4c6  libunwindstack_test "
+      "(testing::internal::UnitTestImpl::RunAllTests()+1190)\n"
+      "  #15 pc 00000000005e9f61  libunwindstack_test (testing::UnitTest::Run()+337)\n"
+      "  #16 pc 0000000000600155  libunwindstack_test (IsolateMain+2037)\n"
+      "  #17 pc 000000000004e405  libc.so (__libc_init+101)\n",
+      frame_info);
+
+  EXPECT_EQ(0x5bb41271e15bU, unwinder.frames()[0].pc);
+  EXPECT_EQ(0x707eb5aa8320U, unwinder.frames()[0].sp);
+  EXPECT_EQ(0x5bb41271e168U, unwinder.frames()[1].pc);
+  EXPECT_EQ(0x707eb5aa8330U, unwinder.frames()[1].sp);
+  EXPECT_EQ(0x5bb41271e178U, unwinder.frames()[2].pc);
+  EXPECT_EQ(0x707eb5aa8340U, unwinder.frames()[2].sp);
+  EXPECT_EQ(0x5bb412724c77U, unwinder.frames()[3].pc);
+  EXPECT_EQ(0x707eb5aa8350U, unwinder.frames()[3].sp);
+  EXPECT_EQ(0x707eb2ca5d10U, unwinder.frames()[4].pc);
+  EXPECT_EQ(0x707eb5aa8380U, unwinder.frames()[4].sp);
+  EXPECT_EQ(0x0U, unwinder.frames()[5].pc);
+  EXPECT_EQ(0x7ffcaadde078U, unwinder.frames()[5].sp);
+  EXPECT_EQ(0x5bb41271e244U, unwinder.frames()[6].pc);
+  EXPECT_EQ(0x7ffcaadde078U, unwinder.frames()[6].sp);
+  EXPECT_EQ(0x5bb41271eb44U, unwinder.frames()[7].pc);
+  EXPECT_EQ(0x7ffcaadde1a0U, unwinder.frames()[7].sp);
+  EXPECT_EQ(0x5bb41271eb64U, unwinder.frames()[8].pc);
+  EXPECT_EQ(0x7ffcaadde1c0U, unwinder.frames()[8].sp);
+  EXPECT_EQ(0x5bb412722457U, unwinder.frames()[9].pc);
+  EXPECT_EQ(0x7ffcaadde1e0U, unwinder.frames()[9].sp);
+  EXPECT_EQ(0x5bb412722f67U, unwinder.frames()[10].pc);
+  EXPECT_EQ(0x7ffcaadde510U, unwinder.frames()[10].sp);
+  EXPECT_EQ(0x5bb412773c38U, unwinder.frames()[11].pc);
+  EXPECT_EQ(0x7ffcaadde530U, unwinder.frames()[11].sp);
+  EXPECT_EQ(0x5bb412774f9aU, unwinder.frames()[12].pc);
+  EXPECT_EQ(0x7ffcaadde560U, unwinder.frames()[12].sp);
+  EXPECT_EQ(0x5bb412775a46U, unwinder.frames()[13].pc);
+  EXPECT_EQ(0x7ffcaadde5b0U, unwinder.frames()[13].sp);
+  EXPECT_EQ(0x5bb4127844c6U, unwinder.frames()[14].pc);
+  EXPECT_EQ(0x7ffcaadde5f0U, unwinder.frames()[14].sp);
+  EXPECT_EQ(0x5bb412783f61U, unwinder.frames()[15].pc);
+  EXPECT_EQ(0x7ffcaadde6c0U, unwinder.frames()[15].sp);
+  EXPECT_EQ(0x5bb41279a155U, unwinder.frames()[16].pc);
+  EXPECT_EQ(0x7ffcaadde720U, unwinder.frames()[16].sp);
+  EXPECT_EQ(0x707eb2c9c405U, unwinder.frames()[17].pc);
+  EXPECT_EQ(0x7ffcaaddf870U, unwinder.frames()[17].sp);
+}
+
 }  // namespace unwindstack
diff --git a/libunwindstack/tests/UnwindTest.cpp b/libunwindstack/tests/UnwindTest.cpp
index f76a101..b11d213 100644
--- a/libunwindstack/tests/UnwindTest.cpp
+++ b/libunwindstack/tests/UnwindTest.cpp
@@ -170,7 +170,6 @@
     unwinder.reset(new Unwinder(512, maps.get(), regs.get(), process_memory));
   } else {
     UnwinderFromPid* unwinder_from_pid = new UnwinderFromPid(512, getpid());
-    ASSERT_TRUE(unwinder_from_pid->Init(regs->Arch()));
     unwinder_from_pid->SetRegs(regs.get());
     unwinder.reset(unwinder_from_pid);
   }
@@ -283,7 +282,6 @@
   ASSERT_TRUE(regs.get() != nullptr);
 
   UnwinderFromPid unwinder(512, pid);
-  ASSERT_TRUE(unwinder.Init(regs->Arch()));
   unwinder.SetRegs(regs.get());
 
   VerifyUnwind(&unwinder, kFunctionOrder);
@@ -335,7 +333,6 @@
   ASSERT_TRUE(regs.get() != nullptr);
 
   UnwinderFromPid unwinder(512, *pid);
-  ASSERT_TRUE(unwinder.Init(regs->Arch()));
   unwinder.SetRegs(regs.get());
 
   VerifyUnwind(&unwinder, kFunctionOrder);
diff --git a/libunwindstack/tests/UnwinderTest.cpp b/libunwindstack/tests/UnwinderTest.cpp
index d10af2f..8bae242 100644
--- a/libunwindstack/tests/UnwinderTest.cpp
+++ b/libunwindstack/tests/UnwinderTest.cpp
@@ -37,6 +37,7 @@
 #include <unwindstack/Unwinder.h>
 
 #include "ElfFake.h"
+#include "ElfTestUtils.h"
 #include "MemoryFake.h"
 #include "RegsFake.h"
 
@@ -44,23 +45,31 @@
 
 class UnwinderTest : public ::testing::Test {
  protected:
-  static void AddMapInfo(uint64_t start, uint64_t end, uint64_t offset, uint64_t flags,
-                         const char* name, Elf* elf = nullptr) {
+  static MapInfo* AddMapInfo(uint64_t start, uint64_t end, uint64_t offset, uint64_t flags,
+                             const char* name, Elf* elf = nullptr) {
     std::string str_name(name);
     maps_->Add(start, end, offset, flags, name, static_cast<uint64_t>(-1));
+    MapInfo* map_info = maps_->Find(start);
     if (elf != nullptr) {
-      const auto& map_info = *--maps_->end();
       map_info->elf.reset(elf);
     }
+    return map_info;
   }
 
   static void SetUpTestSuite() {
     maps_.reset(new Maps);
 
-    ElfFake* elf = new ElfFake(new MemoryFake);
-    ElfInterfaceFake* interface_fake = new ElfInterfaceFake(nullptr);
-    interface_fake->FakeSetBuildID("FAKE");
-    elf->FakeSetInterface(interface_fake);
+    memory_ = new MemoryFake;
+    process_memory_.reset(memory_);
+
+    ElfFake* elf;
+    ElfInterfaceFake* interface;
+    MapInfo* map_info;
+
+    elf = new ElfFake(new MemoryFake);
+    interface = new ElfInterfaceFake(nullptr);
+    interface->FakeSetBuildID("FAKE");
+    elf->FakeSetInterface(interface);
     AddMapInfo(0x1000, 0x8000, 0, PROT_READ | PROT_WRITE, "/system/fake/libc.so", elf);
 
     AddMapInfo(0x10000, 0x12000, 0, PROT_READ | PROT_WRITE, "[stack]");
@@ -81,19 +90,17 @@
     AddMapInfo(0x33000, 0x34000, 0, PROT_READ | PROT_WRITE, "/fake/compressed.so", elf);
 
     elf = new ElfFake(new MemoryFake);
-    ElfInterfaceFake* interface = new ElfInterfaceFake(nullptr);
+    interface = new ElfInterfaceFake(nullptr);
     interface->FakeSetSoname("lib_fake.so");
     elf->FakeSetInterface(interface);
-    AddMapInfo(0x43000, 0x44000, 0x1d000, PROT_READ | PROT_WRITE, "/fake/fake.apk", elf);
-    MapInfo* map_info = maps_->Find(0x43000);
-    ASSERT_TRUE(map_info != nullptr);
+    map_info = AddMapInfo(0x43000, 0x44000, 0x1d000, PROT_READ | PROT_WRITE, "/fake/fake.apk", elf);
     map_info->elf_start_offset = 0x1d000;
 
     AddMapInfo(0x53000, 0x54000, 0, PROT_READ | PROT_WRITE, "/fake/fake.oat");
 
-    AddMapInfo(0xa3000, 0xa4000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake.vdex");
-    const auto& info = *--maps_->end();
-    info->load_bias = 0;
+    map_info =
+        AddMapInfo(0xa3000, 0xa4000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake.vdex");
+    map_info->load_bias = 0;
 
     elf = new ElfFake(new MemoryFake);
     elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
@@ -103,40 +110,76 @@
 
     elf = new ElfFake(new MemoryFake);
     elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
-    AddMapInfo(0xa7000, 0xa8000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake_offset.oat",
-               elf);
-    const auto& info2 = *--maps_->end();
-    info2->elf_offset = 0x8000;
+    map_info = AddMapInfo(0xa7000, 0xa8000, 0, PROT_READ | PROT_WRITE | PROT_EXEC,
+                          "/fake/fake_offset.oat", elf);
+    map_info->elf_offset = 0x8000;
 
     elf = new ElfFake(new MemoryFake);
     elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
-    AddMapInfo(0xc0000, 0xc1000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/unreadable.so", elf);
-    const auto& info3 = *--maps_->end();
-    info3->memory_backed_elf = true;
+    map_info = AddMapInfo(0xc0000, 0xc1000, 0, PROT_READ | PROT_WRITE | PROT_EXEC,
+                          "/fake/unreadable.so", elf);
+    map_info->memory_backed_elf = true;
 
     elf = new ElfFake(new MemoryFake);
     elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
-    AddMapInfo(0xc1000, 0xc2000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "[vdso]", elf);
-    const auto& info4 = *--maps_->end();
-    info4->memory_backed_elf = true;
+    map_info = AddMapInfo(0xc1000, 0xc2000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "[vdso]", elf);
+    map_info->memory_backed_elf = true;
 
     elf = new ElfFake(new MemoryFake);
     elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
-    AddMapInfo(0xc2000, 0xc3000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "", elf);
-    const auto& info5 = *--maps_->end();
-    info5->memory_backed_elf = true;
+    map_info = AddMapInfo(0xc2000, 0xc3000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "", elf);
+    map_info->memory_backed_elf = true;
 
     elf = new ElfFake(new MemoryFake);
     elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
-    AddMapInfo(0xc3000, 0xc4000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/memfd:/jit-cache", elf);
-    const auto& info6 = *--maps_->end();
-    info6->memory_backed_elf = true;
+    map_info = AddMapInfo(0xc3000, 0xc4000, 0, PROT_READ | PROT_WRITE | PROT_EXEC,
+                          "/memfd:/jit-cache", elf);
+    map_info->memory_backed_elf = true;
 
-    AddMapInfo(0xd0000, 0xd1000, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake.apk");
-    const auto& info7 = *--maps_->end();
-    info7->load_bias = 0;
+    map_info =
+        AddMapInfo(0xd0000, 0xd1000, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake.apk");
+    map_info->load_bias = 0;
 
-    process_memory_.reset(new MemoryFake);
+    elf = new ElfFake(new MemoryFake);
+    interface = new ElfInterfaceFake(nullptr);
+    elf->FakeSetInterface(interface);
+    interface->FakeSetGlobalVariable("__dex_debug_descriptor", 0x1800);
+    interface->FakeSetGlobalVariable("__jit_debug_descriptor", 0x1900);
+    interface->FakeSetDataOffset(0x1000);
+    interface->FakeSetDataVaddrStart(0x1000);
+    interface->FakeSetDataVaddrEnd(0x8000);
+    AddMapInfo(0xf0000, 0xf1000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/global.so", elf);
+    AddMapInfo(0xf1000, 0xf9000, 0x1000, PROT_READ | PROT_WRITE, "/fake/global.so");
+    // dex debug data
+    memory_->SetData32(0xf180c, 0xf3000);
+    memory_->SetData32(0xf3000, 0xf4000);
+    memory_->SetData32(0xf3004, 0xf4000);
+    memory_->SetData32(0xf3008, 0xf5000);
+    // jit debug data
+    memory_->SetData32(0xf1900, 1);
+    memory_->SetData32(0xf1904, 0);
+    memory_->SetData32(0xf1908, 0xf6000);
+    memory_->SetData32(0xf190c, 0xf6000);
+    memory_->SetData32(0xf6000, 0);
+    memory_->SetData32(0xf6004, 0);
+    memory_->SetData32(0xf6008, 0xf7000);
+    memory_->SetData32(0xf600c, 0);
+    memory_->SetData64(0xf6010, 0x1000);
+
+    elf = new ElfFake(new MemoryFake);
+    elf->FakeSetValid(false);
+    elf->FakeSetLoadBias(0x300);
+    map_info = AddMapInfo(0x100000, 0x101000, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC,
+                          "/fake/jit.so", elf);
+    map_info->elf_start_offset = 0x100;
+    map_info->offset = 0x200;
+
+#if 0
+    elf = new ElfFake(new MemoryFake);
+    interface = new ElfInterfaceFake(nullptr);
+    interface->FakePushFunctionData(FunctionData("Fake0", 10));
+    AddMapInfo(0x110000, 0x111000, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/elf.so", elf);
+#endif
   }
 
   void SetUp() override {
@@ -147,11 +190,13 @@
 
   static std::unique_ptr<Maps> maps_;
   static RegsFake regs_;
+  static MemoryFake* memory_;
   static std::shared_ptr<Memory> process_memory_;
 };
 
 std::unique_ptr<Maps> UnwinderTest::maps_;
 RegsFake UnwinderTest::regs_(5);
+MemoryFake* UnwinderTest::memory_;
 std::shared_ptr<Memory> UnwinderTest::process_memory_(nullptr);
 
 TEST_F(UnwinderTest, multiple_frames) {
@@ -1129,6 +1174,53 @@
   EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags);
 }
 
+TEST_F(UnwinderTest, dex_pc_not_in_map_valid_dex_files) {
+  ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
+  regs_.set_pc(0x1000);
+  regs_.set_sp(0x10000);
+  regs_.FakeSetDexPc(0x50000);
+
+  DexFiles dex_files(process_memory_);
+  Unwinder unwinder(64, maps_.get(), &regs_, process_memory_);
+  unwinder.SetDexFiles(&dex_files);
+  unwinder.Unwind();
+  EXPECT_EQ(ERROR_NONE, unwinder.LastErrorCode());
+  EXPECT_EQ(WARNING_DEX_PC_NOT_IN_MAP, unwinder.warnings());
+  EXPECT_FALSE(unwinder.elf_from_memory_not_file());
+
+  ASSERT_EQ(2U, unwinder.NumFrames());
+
+  auto* frame = &unwinder.frames()[0];
+  EXPECT_EQ(0U, frame->num);
+  EXPECT_EQ(0x50000U, frame->rel_pc);
+  EXPECT_EQ(0x50000U, frame->pc);
+  EXPECT_EQ(0x10000U, frame->sp);
+  EXPECT_EQ("", frame->function_name);
+  EXPECT_EQ(0U, frame->function_offset);
+  EXPECT_EQ("", frame->map_name);
+  EXPECT_EQ(0U, frame->map_elf_start_offset);
+  EXPECT_EQ(0U, frame->map_exact_offset);
+  EXPECT_EQ(0U, frame->map_start);
+  EXPECT_EQ(0U, frame->map_end);
+  EXPECT_EQ(0U, frame->map_load_bias);
+  EXPECT_EQ(0, frame->map_flags);
+
+  frame = &unwinder.frames()[1];
+  EXPECT_EQ(1U, frame->num);
+  EXPECT_EQ(0U, frame->rel_pc);
+  EXPECT_EQ(0x1000U, frame->pc);
+  EXPECT_EQ(0x10000U, frame->sp);
+  EXPECT_EQ("Frame0", frame->function_name);
+  EXPECT_EQ(0U, frame->function_offset);
+  EXPECT_EQ("/system/fake/libc.so", frame->map_name);
+  EXPECT_EQ(0U, frame->map_elf_start_offset);
+  EXPECT_EQ(0U, frame->map_exact_offset);
+  EXPECT_EQ(0x1000U, frame->map_start);
+  EXPECT_EQ(0x8000U, frame->map_end);
+  EXPECT_EQ(0U, frame->map_load_bias);
+  EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags);
+}
+
 TEST_F(UnwinderTest, dex_pc_multiple_frames) {
   ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
   ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame1", 1));
@@ -1502,4 +1594,178 @@
   }
 }
 
+TEST_F(UnwinderTest, build_frame_pc_only_errors) {
+  RegsFake regs(10);
+  regs.FakeSetArch(ARCH_ARM);
+  Unwinder unwinder(10, maps_.get(), &regs, process_memory_);
+
+  FrameData frame;
+
+  // Pc not in map
+  frame = unwinder.BuildFrameFromPcOnly(0x10);
+  EXPECT_EQ(0x10U, frame.pc);
+  EXPECT_EQ(0x10U, frame.rel_pc);
+
+  // No regs set
+  unwinder.SetRegs(nullptr);
+  frame = unwinder.BuildFrameFromPcOnly(0x100310);
+  EXPECT_EQ(0x100310U, frame.pc);
+  EXPECT_EQ(0x100310U, frame.rel_pc);
+  unwinder.SetRegs(&regs);
+
+  // Invalid elf
+  frame = unwinder.BuildFrameFromPcOnly(0x100310);
+  EXPECT_EQ(0x10030eU, frame.pc);
+  EXPECT_EQ(0x60eU, frame.rel_pc);
+  EXPECT_EQ("/fake/jit.so", frame.map_name);
+  EXPECT_EQ(0x100U, frame.map_elf_start_offset);
+  EXPECT_EQ(0x200U, frame.map_exact_offset);
+  EXPECT_EQ(0x100000U, frame.map_start);
+  EXPECT_EQ(0x101000U, frame.map_end);
+  EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, frame.map_flags);
+  EXPECT_EQ(0x300U, frame.map_load_bias);
+  EXPECT_EQ("", frame.function_name);
+  EXPECT_EQ(0U, frame.function_offset);
+}
+
+TEST_F(UnwinderTest, build_frame_pc_valid_elf) {
+  RegsFake regs(10);
+  regs.FakeSetArch(ARCH_ARM);
+  Unwinder unwinder(10, maps_.get(), &regs, process_memory_);
+
+  FrameData frame;
+
+  // Valid elf, no function data.
+  frame = unwinder.BuildFrameFromPcOnly(0x1010);
+  EXPECT_EQ(0x100cU, frame.pc);
+  EXPECT_EQ(0xcU, frame.rel_pc);
+  EXPECT_EQ("/system/fake/libc.so", frame.map_name);
+  EXPECT_EQ(0U, frame.map_elf_start_offset);
+  EXPECT_EQ(0U, frame.map_exact_offset);
+  EXPECT_EQ(0x1000U, frame.map_start);
+  EXPECT_EQ(0x8000U, frame.map_end);
+  EXPECT_EQ(PROT_READ | PROT_WRITE, frame.map_flags);
+  EXPECT_EQ(0U, frame.map_load_bias);
+  EXPECT_EQ("", frame.function_name);
+  EXPECT_EQ(0U, frame.function_offset);
+
+  // Valid elf, function data present, but do not resolve.
+  ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 10));
+  unwinder.SetResolveNames(false);
+
+  frame = unwinder.BuildFrameFromPcOnly(0x1010);
+  EXPECT_EQ(0x100cU, frame.pc);
+  EXPECT_EQ(0xcU, frame.rel_pc);
+  EXPECT_EQ("/system/fake/libc.so", frame.map_name);
+  EXPECT_EQ(0U, frame.map_elf_start_offset);
+  EXPECT_EQ(0U, frame.map_exact_offset);
+  EXPECT_EQ(0x1000U, frame.map_start);
+  EXPECT_EQ(0x8000U, frame.map_end);
+  EXPECT_EQ(PROT_READ | PROT_WRITE, frame.map_flags);
+  EXPECT_EQ(0U, frame.map_load_bias);
+  EXPECT_EQ("", frame.function_name);
+  EXPECT_EQ(0U, frame.function_offset);
+
+  // Valid elf, function data present.
+  unwinder.SetResolveNames(true);
+
+  frame = unwinder.BuildFrameFromPcOnly(0x1010);
+  EXPECT_EQ(0x100cU, frame.pc);
+  EXPECT_EQ(0xcU, frame.rel_pc);
+  EXPECT_EQ("/system/fake/libc.so", frame.map_name);
+  EXPECT_EQ(0U, frame.map_elf_start_offset);
+  EXPECT_EQ(0U, frame.map_exact_offset);
+  EXPECT_EQ(0x1000U, frame.map_start);
+  EXPECT_EQ(0x8000U, frame.map_end);
+  EXPECT_EQ(PROT_READ | PROT_WRITE, frame.map_flags);
+  EXPECT_EQ(0U, frame.map_load_bias);
+  EXPECT_EQ("Frame0", frame.function_name);
+  EXPECT_EQ(10U, frame.function_offset);
+}
+
+TEST_F(UnwinderTest, build_frame_pc_in_jit) {
+  // Create the elf data for the jit debug information.
+  Elf32_Ehdr ehdr = {};
+  TestInitEhdr<Elf32_Ehdr>(&ehdr, ELFCLASS32, EM_ARM);
+  ehdr.e_phoff = 0x50;
+  ehdr.e_phnum = 1;
+  ehdr.e_phentsize = sizeof(Elf32_Phdr);
+  ehdr.e_shoff = 0x100;
+  ehdr.e_shstrndx = 1;
+  ehdr.e_shentsize = sizeof(Elf32_Shdr);
+  ehdr.e_shnum = 3;
+  memory_->SetMemory(0xf7000, &ehdr, sizeof(ehdr));
+
+  Elf32_Phdr phdr = {};
+  phdr.p_flags = PF_X;
+  phdr.p_type = PT_LOAD;
+  phdr.p_offset = 0x100000;
+  phdr.p_vaddr = 0x100000;
+  phdr.p_memsz = 0x1000;
+  memory_->SetMemory(0xf7050, &phdr, sizeof(phdr));
+
+  Elf32_Shdr shdr = {};
+  shdr.sh_type = SHT_NULL;
+  memory_->SetMemory(0xf7100, &shdr, sizeof(shdr));
+
+  shdr.sh_type = SHT_SYMTAB;
+  shdr.sh_link = 2;
+  shdr.sh_addr = 0x300;
+  shdr.sh_offset = 0x300;
+  shdr.sh_entsize = sizeof(Elf32_Sym);
+  shdr.sh_size = shdr.sh_entsize;
+  memory_->SetMemory(0xf7100 + sizeof(shdr), &shdr, sizeof(shdr));
+
+  memset(&shdr, 0, sizeof(shdr));
+  shdr.sh_type = SHT_STRTAB;
+  shdr.sh_name = 0x500;
+  shdr.sh_offset = 0x400;
+  shdr.sh_size = 0x100;
+  memory_->SetMemory(0xf7100 + 2 * sizeof(shdr), &shdr, sizeof(shdr));
+
+  Elf32_Sym sym = {};
+  sym.st_shndx = 2;
+  sym.st_info = STT_FUNC;
+  sym.st_value = 0x100300;
+  sym.st_size = 0x100;
+  memory_->SetMemory(0xf7300, &sym, sizeof(sym));
+  memory_->SetMemory(0xf7400, "FakeJitFunction");
+
+  RegsFake regs(10);
+  regs.FakeSetArch(ARCH_ARM);
+  JitDebug jit_debug(process_memory_);
+  Unwinder unwinder(10, maps_.get(), &regs, process_memory_);
+  unwinder.SetJitDebug(&jit_debug);
+
+  FrameData frame = unwinder.BuildFrameFromPcOnly(0x100310);
+  EXPECT_EQ(0x10030eU, frame.pc);
+  EXPECT_EQ(0x60eU, frame.rel_pc);
+  EXPECT_EQ("/fake/jit.so", frame.map_name);
+  EXPECT_EQ(0x100U, frame.map_elf_start_offset);
+  EXPECT_EQ(0x200U, frame.map_exact_offset);
+  EXPECT_EQ(0x100000U, frame.map_start);
+  EXPECT_EQ(0x101000U, frame.map_end);
+  EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, frame.map_flags);
+  EXPECT_EQ(0U, frame.map_load_bias);
+  EXPECT_EQ("FakeJitFunction", frame.function_name);
+  EXPECT_EQ(0xeU, frame.function_offset);
+}
+
+TEST_F(UnwinderTest, unwinder_from_pid_init_error) {
+  UnwinderFromPid unwinder(10, getpid());
+  ASSERT_DEATH(unwinder.Init(), "");
+}
+
+TEST_F(UnwinderTest, set_jit_debug_error) {
+  Unwinder unwinder(10, maps_.get(), process_memory_);
+  JitDebug jit_debug(process_memory_);
+  ASSERT_DEATH(unwinder.SetJitDebug(&jit_debug), "");
+}
+
+TEST_F(UnwinderTest, set_dex_files_error) {
+  Unwinder unwinder(10, maps_.get(), process_memory_);
+  DexFiles dex_files(process_memory_);
+  ASSERT_DEATH(unwinder.SetDexFiles(&dex_files), "");
+}
+
 }  // namespace unwindstack
diff --git a/libunwindstack/tests/VerifyBionicTerminationTest.cpp b/libunwindstack/tests/VerifyBionicTerminationTest.cpp
index eb2b01d..3e67dc9 100644
--- a/libunwindstack/tests/VerifyBionicTerminationTest.cpp
+++ b/libunwindstack/tests/VerifyBionicTerminationTest.cpp
@@ -94,7 +94,6 @@
   std::unique_ptr<Regs> regs(Regs::CreateFromLocal());
 
   UnwinderFromPid unwinder(512, getpid());
-  ASSERT_TRUE(unwinder.Init(regs->Arch()));
   unwinder.SetRegs(regs.get());
 
   RegsGetLocal(regs.get());
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86/libc.so b/libunwindstack/tests/files/offline/signal_fde_x86/libc.so
new file mode 100644
index 0000000..5c882e4
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86/libc.so
Binary files differ
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86/libunwindstack_test b/libunwindstack/tests/files/offline/signal_fde_x86/libunwindstack_test
new file mode 100644
index 0000000..8dcff67
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86/libunwindstack_test
Binary files differ
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86/maps.txt b/libunwindstack/tests/files/offline/signal_fde_x86/maps.txt
new file mode 100644
index 0000000..6166a9d
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86/maps.txt
@@ -0,0 +1,4 @@
+5a67c000-5a7ba000 r--p 0 00:00 0   libunwindstack_test
+5a7ba000-5aedd000 r-xp 13d000 00:00 0   libunwindstack_test
+ec111000-ec153000 r--p 0 00:00 0   libc.so
+ec153000-ec200000 r-xp 41000 00:00 0   libc.so
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86/regs.txt b/libunwindstack/tests/files/offline/signal_fde_x86/regs.txt
new file mode 100644
index 0000000..456b212
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86/regs.txt
@@ -0,0 +1,9 @@
+eax: 5aeec4ac
+ebx: 5aeec4ac
+ecx: 0
+edx: 6b
+ebp: ecb37188
+edi: ebecda30
+esi: b
+esp: ecb37188
+eip: 5ae0d4d9
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86/stack0.data b/libunwindstack/tests/files/offline/signal_fde_x86/stack0.data
new file mode 100644
index 0000000..0bbbe22
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86/stack0.data
Binary files differ
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86/stack1.data b/libunwindstack/tests/files/offline/signal_fde_x86/stack1.data
new file mode 100644
index 0000000..0873046
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86/stack1.data
Binary files differ
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86_64/libc.so b/libunwindstack/tests/files/offline/signal_fde_x86_64/libc.so
new file mode 100644
index 0000000..cea7336
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86_64/libc.so
Binary files differ
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86_64/libunwindstack_test b/libunwindstack/tests/files/offline/signal_fde_x86_64/libunwindstack_test
new file mode 100644
index 0000000..c48e84e
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86_64/libunwindstack_test
Binary files differ
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86_64/maps.txt b/libunwindstack/tests/files/offline/signal_fde_x86_64/maps.txt
new file mode 100644
index 0000000..514aa71
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86_64/maps.txt
@@ -0,0 +1,4 @@
+5bb41219a000-5bb4122cd000 r--p 0 00:00 0   libunwindstack_test
+5bb4122cd000-5bb4127b9000 r-xp 132000 00:00 0   libunwindstack_test
+707eb2c4e000-707eb2c91000 r--p 0 00:00 0   libc.so
+707eb2c91000-707eb2d1b000 r-xp 42000 00:00 0   libc.so
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86_64/regs.txt b/libunwindstack/tests/files/offline/signal_fde_x86_64/regs.txt
new file mode 100644
index 0000000..8da7b4e
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86_64/regs.txt
@@ -0,0 +1,17 @@
+rax: 0
+rbx: 707d82c59c60
+rcx: 4
+rdx: 707eb5aa8380
+r8: 7ffcaadde470
+r9: 7ffcaadde478
+r10: 8
+r11: 206
+r12: 707cb2c64330
+r13: 0
+r14: 174e9096a8f
+r15: 707d52c96cb0
+rdi: b
+rsi: 707eb5aa84b0
+rbp: 707eb5aa8320
+rsp: 707eb5aa8320
+rip: 5bb41271e15b
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86_64/stack0.data b/libunwindstack/tests/files/offline/signal_fde_x86_64/stack0.data
new file mode 100644
index 0000000..e19a016
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86_64/stack0.data
Binary files differ
diff --git a/libunwindstack/tests/files/offline/signal_fde_x86_64/stack1.data b/libunwindstack/tests/files/offline/signal_fde_x86_64/stack1.data
new file mode 100644
index 0000000..3435f7c
--- /dev/null
+++ b/libunwindstack/tests/files/offline/signal_fde_x86_64/stack1.data
Binary files differ
diff --git a/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp b/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp
index 0415ef6..65052b6 100644
--- a/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp
+++ b/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp
@@ -116,8 +116,12 @@
 
 static constexpr size_t kPageSize = 4096;
 
-static constexpr uint64_t AlignToPage(uint64_t address) {
-  return (address + kPageSize - 1) & ~(kPageSize - 1);
+static inline bool AlignToPage(uint64_t address, uint64_t* aligned_address) {
+  if (__builtin_add_overflow(address, kPageSize - 1, aligned_address)) {
+    return false;
+  }
+  *aligned_address &= ~(kPageSize - 1);
+  return true;
 }
 
 std::unique_ptr<Maps> GetMaps(FuzzedDataProvider* data_provider) {
@@ -125,8 +129,23 @@
   std::map<uint64_t, uint64_t> map_ends;
   uint8_t entry_count = data_provider->ConsumeIntegralInRange<uint8_t>(0, kMaxMapEntryCount);
   for (uint8_t i = 0; i < entry_count; i++) {
-    uint64_t start = AlignToPage(data_provider->ConsumeIntegral<uint64_t>());
-    uint64_t end = AlignToPage(data_provider->ConsumeIntegralInRange<uint64_t>(start, UINT64_MAX));
+    uint64_t start;
+    if (!AlignToPage(data_provider->ConsumeIntegral<uint64_t>(), &start)) {
+      // Overflowed.
+      continue;
+    }
+    uint64_t end;
+    if (!AlignToPage(data_provider->ConsumeIntegralInRange<uint64_t>(start, UINT64_MAX), &end)) {
+      // Overflowed.
+      continue;
+    }
+    if (start == end) {
+      // It's impossible to see start == end in the real world, so
+      // make sure the map contains at least one page of data.
+      if (__builtin_add_overflow(end, 0x1000, &end)) {
+        continue;
+      }
+    }
     // Make sure not to add overlapping maps, that is not something that can
     // happen in the real world.
     auto entry = map_ends.upper_bound(start);
@@ -135,7 +154,11 @@
     }
     map_ends[end] = start;
 
-    uint64_t offset = AlignToPage(data_provider->ConsumeIntegral<uint64_t>());
+    uint64_t offset;
+    if (!AlignToPage(data_provider->ConsumeIntegral<uint64_t>(), &offset)) {
+      // Overflowed.
+      continue;
+    }
     std::string map_info_name = data_provider->ConsumeRandomLengthString(kMaxMapInfoNameLen);
     uint8_t flags = PROT_READ | PROT_WRITE;
 
diff --git a/libunwindstack/tests/fuzz/UnwinderFuzz.cpp b/libunwindstack/tests/fuzz/UnwinderFuzz.cpp
index 2f4986a..1600547 100644
--- a/libunwindstack/tests/fuzz/UnwinderFuzz.cpp
+++ b/libunwindstack/tests/fuzz/UnwinderFuzz.cpp
@@ -85,7 +85,7 @@
 
   // Create instance
   Unwinder unwinder(max_frames, maps.get(), regs.get(), memory);
-  unwinder.SetJitDebug(jit_debug_ptr.get(), arch);
+  unwinder.SetJitDebug(jit_debug_ptr.get());
   unwinder.SetResolveNames(data_provider.ConsumeBool());
   // Call unwind
   PerformUnwind(&data_provider, &unwinder);
diff --git a/libunwindstack/tools/unwind.cpp b/libunwindstack/tools/unwind.cpp
index 1812e50..ae45f06 100644
--- a/libunwindstack/tools/unwind.cpp
+++ b/libunwindstack/tools/unwind.cpp
@@ -90,11 +90,6 @@
   printf("\n");
 
   unwindstack::UnwinderFromPid unwinder(1024, pid);
-  if (!unwinder.Init(regs->Arch())) {
-    printf("Failed to init unwinder object.\n");
-    return;
-  }
-
   unwinder.SetRegs(regs);
   unwinder.Unwind();
 
diff --git a/libunwindstack/tools/unwind_for_offline.cpp b/libunwindstack/tools/unwind_for_offline.cpp
index 64b58a8..c44a121 100644
--- a/libunwindstack/tools/unwind_for_offline.cpp
+++ b/libunwindstack/tools/unwind_for_offline.cpp
@@ -248,10 +248,6 @@
   // Do an unwind so we know how much of the stack to save, and what
   // elf files are involved.
   unwindstack::UnwinderFromPid unwinder(1024, pid);
-  if (!unwinder.Init(regs->Arch())) {
-    printf("Unable to init unwinder object.\n");
-    return 1;
-  }
   unwinder.SetRegs(regs);
   uint64_t sp = regs->sp();
   unwinder.Unwind();
diff --git a/libutils/Android.bp b/libutils/Android.bp
index 9c012a9..dd9fea0 100644
--- a/libutils/Android.bp
+++ b/libutils/Android.bp
@@ -132,7 +132,6 @@
         "JenkinsHash.cpp",
         "NativeHandle.cpp",
         "Printer.cpp",
-        "PropertyMap.cpp",
         "RefBase.cpp",
         "SharedBuffer.cpp",
         "StopWatch.cpp",
@@ -270,18 +269,6 @@
 }
 
 cc_fuzz {
-    name: "libutils_fuzz_propertymap",
-    defaults: ["libutils_fuzz_defaults"],
-    srcs: ["PropertyMap_fuzz.cpp"],
-}
-
-cc_fuzz {
-    name: "libutils_fuzz_rwlock",
-    defaults: ["libutils_fuzz_defaults"],
-    srcs: ["RWLock_fuzz.cpp"],
-}
-
-cc_fuzz {
     name: "libutils_fuzz_refbase",
     defaults: ["libutils_fuzz_defaults"],
     srcs: ["RefBase_fuzz.cpp"],
diff --git a/libutils/FuzzFormatTypes.h b/libutils/FuzzFormatTypes.h
new file mode 100644
index 0000000..aa9e503
--- /dev/null
+++ b/libutils/FuzzFormatTypes.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2020 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>
+
+static const std::string kFormatChars = std::string("duoxXfFeEgGaAcsp");
+static constexpr int32_t kMaxFormatFlagValue = INT16_MAX;
+enum FormatChar : uint8_t {
+    SIGNED_DECIMAL = 0,
+    UNSIGNED_DECIMAL = 1,
+    UNSIGNED_OCTAL = 2,
+    UNSIGNED_HEX_LOWER = 3,
+    UNSIGNED_HEX_UPPER = 4,
+    // Uppercase/lowercase floating point impacts 'inf', 'infinity', and 'nan'
+    FLOAT_LOWER = 5,
+    FLOAT_UPPER = 6,
+    // Upper/lower impacts the "e" in exponents.
+    EXPONENT_LOWER = 7,
+    EXPONENT_UPPER = 8,
+    // %g will use %e or %f, whichever is shortest
+    SHORT_EXP_LOWER = 9,
+    // %G will use %E or %F, whichever is shortest
+    SHORT_EXP_UPPER = 10,
+    HEX_FLOAT_LOWER = 11,
+    HEX_FLOAT_UPPER = 12,
+    CHAR = 13,
+    STRING = 14,
+    POINTER = 15,
+    // Used by libfuzzer
+    kMaxValue = POINTER
+};
+
+bool canApplyFlag(FormatChar formatChar, char modifier) {
+    if (modifier == '#') {
+        return formatChar == UNSIGNED_OCTAL || formatChar == UNSIGNED_HEX_LOWER ||
+               formatChar == UNSIGNED_HEX_UPPER || formatChar == FLOAT_LOWER ||
+               formatChar == FLOAT_UPPER || formatChar == SHORT_EXP_LOWER ||
+               formatChar == SHORT_EXP_UPPER;
+    } else if (modifier == '.') {
+        return formatChar == SIGNED_DECIMAL || formatChar == UNSIGNED_DECIMAL ||
+               formatChar == UNSIGNED_OCTAL || formatChar == UNSIGNED_HEX_LOWER ||
+               formatChar == UNSIGNED_HEX_UPPER || formatChar == FLOAT_LOWER ||
+               formatChar == FLOAT_UPPER || formatChar == SHORT_EXP_LOWER ||
+               formatChar == SHORT_EXP_UPPER || formatChar == STRING;
+    }
+    return true;
+}
diff --git a/libutils/PropertyMap.cpp b/libutils/PropertyMap.cpp
deleted file mode 100644
index f00272a..0000000
--- a/libutils/PropertyMap.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * 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.
- */
-
-#define LOG_TAG "PropertyMap"
-
-#include <utils/PropertyMap.h>
-
-// Enables debug output for the parser.
-#define DEBUG_PARSER 0
-
-// Enables debug output for parser performance.
-#define DEBUG_PARSER_PERFORMANCE 0
-
-
-namespace android {
-
-static const char* WHITESPACE = " \t\r";
-static const char* WHITESPACE_OR_PROPERTY_DELIMITER = " \t\r=";
-
-
-// --- PropertyMap ---
-
-PropertyMap::PropertyMap() {
-}
-
-PropertyMap::~PropertyMap() {
-}
-
-void PropertyMap::clear() {
-    mProperties.clear();
-}
-
-void PropertyMap::addProperty(const String8& key, const String8& value) {
-    mProperties.add(key, value);
-}
-
-bool PropertyMap::hasProperty(const String8& key) const {
-    return mProperties.indexOfKey(key) >= 0;
-}
-
-bool PropertyMap::tryGetProperty(const String8& key, String8& outValue) const {
-    ssize_t index = mProperties.indexOfKey(key);
-    if (index < 0) {
-        return false;
-    }
-
-    outValue = mProperties.valueAt(index);
-    return true;
-}
-
-bool PropertyMap::tryGetProperty(const String8& key, bool& outValue) const {
-    int32_t intValue;
-    if (!tryGetProperty(key, intValue)) {
-        return false;
-    }
-
-    outValue = intValue;
-    return true;
-}
-
-bool PropertyMap::tryGetProperty(const String8& key, int32_t& outValue) const {
-    String8 stringValue;
-    if (! tryGetProperty(key, stringValue) || stringValue.length() == 0) {
-        return false;
-    }
-
-    char* end;
-    int value = strtol(stringValue.string(), & end, 10);
-    if (*end != '\0') {
-        ALOGW("Property key '%s' has invalid value '%s'.  Expected an integer.",
-                key.string(), stringValue.string());
-        return false;
-    }
-    outValue = value;
-    return true;
-}
-
-bool PropertyMap::tryGetProperty(const String8& key, float& outValue) const {
-    String8 stringValue;
-    if (! tryGetProperty(key, stringValue) || stringValue.length() == 0) {
-        return false;
-    }
-
-    char* end;
-    float value = strtof(stringValue.string(), & end);
-    if (*end != '\0') {
-        ALOGW("Property key '%s' has invalid value '%s'.  Expected a float.",
-                key.string(), stringValue.string());
-        return false;
-    }
-    outValue = value;
-    return true;
-}
-
-void PropertyMap::addAll(const PropertyMap* map) {
-    for (size_t i = 0; i < map->mProperties.size(); i++) {
-        mProperties.add(map->mProperties.keyAt(i), map->mProperties.valueAt(i));
-    }
-}
-
-status_t PropertyMap::load(const String8& filename, PropertyMap** outMap) {
-    *outMap = nullptr;
-
-    Tokenizer* tokenizer;
-    status_t status = Tokenizer::open(filename, &tokenizer);
-    if (status) {
-        ALOGE("Error %d opening property file %s.", status, filename.string());
-    } else {
-        PropertyMap* map = new PropertyMap();
-        if (!map) {
-            ALOGE("Error allocating property map.");
-            status = NO_MEMORY;
-        } else {
-#if DEBUG_PARSER_PERFORMANCE
-            nsecs_t startTime = systemTime(SYSTEM_TIME_MONOTONIC);
-#endif
-            Parser parser(map, tokenizer);
-            status = parser.parse();
-#if DEBUG_PARSER_PERFORMANCE
-            nsecs_t elapsedTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime;
-            ALOGD("Parsed property file '%s' %d lines in %0.3fms.",
-                    tokenizer->getFilename().string(), tokenizer->getLineNumber(),
-                    elapsedTime / 1000000.0);
-#endif
-            if (status) {
-                delete map;
-            } else {
-                *outMap = map;
-            }
-        }
-        delete tokenizer;
-    }
-    return status;
-}
-
-
-// --- PropertyMap::Parser ---
-
-PropertyMap::Parser::Parser(PropertyMap* map, Tokenizer* tokenizer) :
-        mMap(map), mTokenizer(tokenizer) {
-}
-
-PropertyMap::Parser::~Parser() {
-}
-
-status_t PropertyMap::Parser::parse() {
-    while (!mTokenizer->isEof()) {
-#if DEBUG_PARSER
-        ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().string(),
-                mTokenizer->peekRemainderOfLine().string());
-#endif
-
-        mTokenizer->skipDelimiters(WHITESPACE);
-
-        if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
-            String8 keyToken = mTokenizer->nextToken(WHITESPACE_OR_PROPERTY_DELIMITER);
-            if (keyToken.isEmpty()) {
-                ALOGE("%s: Expected non-empty property key.", mTokenizer->getLocation().string());
-                return BAD_VALUE;
-            }
-
-            mTokenizer->skipDelimiters(WHITESPACE);
-
-            if (mTokenizer->nextChar() != '=') {
-                ALOGE("%s: Expected '=' between property key and value.",
-                        mTokenizer->getLocation().string());
-                return BAD_VALUE;
-            }
-
-            mTokenizer->skipDelimiters(WHITESPACE);
-
-            String8 valueToken = mTokenizer->nextToken(WHITESPACE);
-            if (valueToken.find("\\", 0) >= 0 || valueToken.find("\"", 0) >= 0) {
-                ALOGE("%s: Found reserved character '\\' or '\"' in property value.",
-                        mTokenizer->getLocation().string());
-                return BAD_VALUE;
-            }
-
-            mTokenizer->skipDelimiters(WHITESPACE);
-            if (!mTokenizer->isEol()) {
-                ALOGE("%s: Expected end of line, got '%s'.",
-                        mTokenizer->getLocation().string(),
-                        mTokenizer->peekRemainderOfLine().string());
-                return BAD_VALUE;
-            }
-
-            if (mMap->hasProperty(keyToken)) {
-                ALOGE("%s: Duplicate property value for key '%s'.",
-                        mTokenizer->getLocation().string(), keyToken.string());
-                return BAD_VALUE;
-            }
-
-            mMap->addProperty(keyToken, valueToken);
-        }
-
-        mTokenizer->nextLine();
-    }
-    return OK;
-}
-
-} // namespace android
diff --git a/libutils/PropertyMap_fuzz.cpp b/libutils/PropertyMap_fuzz.cpp
deleted file mode 100755
index fd50729..0000000
--- a/libutils/PropertyMap_fuzz.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2020 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 "android-base/file.h"
-#include "fuzzer/FuzzedDataProvider.h"
-#include "utils/PropertyMap.h"
-#include "utils/String8.h"
-
-static constexpr int MAX_FILE_SIZE = 256;
-static constexpr int MAX_STR_LEN = 2048;
-static constexpr int MAX_OPERATIONS = 1000;
-
-static const std::vector<std::function<void(FuzzedDataProvider*, android::PropertyMap)>>
-        operations = {
-                [](FuzzedDataProvider*, android::PropertyMap propertyMap) -> void {
-                    propertyMap.getProperties();
-                },
-                [](FuzzedDataProvider*, android::PropertyMap propertyMap) -> void {
-                    propertyMap.clear();
-                },
-                [](FuzzedDataProvider* dataProvider, android::PropertyMap propertyMap) -> void {
-                    std::string keyStr = dataProvider->ConsumeRandomLengthString(MAX_STR_LEN);
-                    android::String8 key = android::String8(keyStr.c_str());
-                    propertyMap.hasProperty(key);
-                },
-                [](FuzzedDataProvider* dataProvider, android::PropertyMap propertyMap) -> void {
-                    std::string keyStr = dataProvider->ConsumeRandomLengthString(MAX_STR_LEN);
-                    android::String8 key = android::String8(keyStr.c_str());
-                    android::String8 out;
-                    propertyMap.tryGetProperty(key, out);
-                },
-                [](FuzzedDataProvider* dataProvider, android::PropertyMap propertyMap) -> void {
-                    TemporaryFile tf;
-                    // Generate file contents
-                    std::string contents = dataProvider->ConsumeRandomLengthString(MAX_FILE_SIZE);
-                    // If we have string contents, dump them into the file.
-                    // Otherwise, just leave it as an empty file.
-                    if (contents.length() > 0) {
-                        const char* bytes = contents.c_str();
-                        android::base::WriteStringToFd(bytes, tf.fd);
-                    }
-                    android::PropertyMap* mapPtr = &propertyMap;
-                    android::PropertyMap::load(android::String8(tf.path), &mapPtr);
-                },
-                [](FuzzedDataProvider* dataProvider, android::PropertyMap propertyMap) -> void {
-                    std::string keyStr = dataProvider->ConsumeRandomLengthString(MAX_STR_LEN);
-                    std::string valStr = dataProvider->ConsumeRandomLengthString(MAX_STR_LEN);
-                    android::String8 key = android::String8(keyStr.c_str());
-                    android::String8 val = android::String8(valStr.c_str());
-                    propertyMap.addProperty(key, val);
-                },
-};
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
-    FuzzedDataProvider dataProvider(data, size);
-    android::PropertyMap proprtyMap = android::PropertyMap();
-
-    int opsRun = 0;
-    while (dataProvider.remaining_bytes() > 0 && opsRun++ < MAX_OPERATIONS) {
-        uint8_t op = dataProvider.ConsumeIntegralInRange<uint8_t>(0, operations.size() - 1);
-        operations[op](&dataProvider, proprtyMap);
-    }
-    return 0;
-}
diff --git a/libutils/RWLock_fuzz.cpp b/libutils/RWLock_fuzz.cpp
deleted file mode 100755
index e075905..0000000
--- a/libutils/RWLock_fuzz.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2020 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 <functional>
-
-#include "fuzzer/FuzzedDataProvider.h"
-#include "utils/RWLock.h"
-
-static constexpr int MAX_OPERATIONS = 100;
-static constexpr int MAX_NAME_LEN = 2048;
-
-static const std::vector<std::function<void(android::RWLock*)>> operations = {
-        [](android::RWLock* lock) -> void {
-            // This might return a non-zero value if already locked
-            // Either way we are definitely locked now.
-            lock->tryWriteLock();
-        },
-        [](android::RWLock* lock) -> void { lock->tryReadLock(); },
-        [](android::RWLock* lock) -> void { lock->unlock(); },
-};
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
-    FuzzedDataProvider dataProvider(data, size);
-    std::string nameStr = dataProvider.ConsumeRandomLengthString(MAX_NAME_LEN);
-    int type = dataProvider.ConsumeIntegral<int>();
-    android::RWLock rwLock = android::RWLock(type, nameStr.c_str());
-    std::vector<uint8_t> opsToRun = dataProvider.ConsumeRemainingBytes<uint8_t>();
-    int opsRun = 0;
-    for (auto it : opsToRun) {
-        if (opsRun++ >= MAX_OPERATIONS) {
-            break;
-        }
-        it = it % operations.size();
-        operations[it](&rwLock);
-    }
-    rwLock.unlock();
-    return 0;
-}
diff --git a/libutils/String16.cpp b/libutils/String16.cpp
index d514f29..70bf5a0 100644
--- a/libutils/String16.cpp
+++ b/libutils/String16.cpp
@@ -441,7 +441,7 @@
         mString = getEmptyString();
         return OK;
     }
-    if ((begin+len) > N) len = N-begin;
+    if (len > N || len > N - begin) len = N - begin;
     if (begin == 0 && len == N) {
         return OK;
     }
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index c837891..3dc2026 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -309,8 +309,14 @@
     n = vsnprintf(nullptr, 0, fmt, tmp_args);
     va_end(tmp_args);
 
-    if (n != 0) {
+    if (n < 0) return UNKNOWN_ERROR;
+
+    if (n > 0) {
         size_t oldLength = length();
+        if ((size_t)n > SIZE_MAX - 1 ||
+            oldLength > SIZE_MAX - (size_t)n - 1) {
+            return NO_MEMORY;
+        }
         char* buf = lockBuffer(oldLength + n);
         if (buf) {
             vsnprintf(buf + oldLength, n + 1, fmt, args);
diff --git a/libutils/String8_fuzz.cpp b/libutils/String8_fuzz.cpp
index 2adfe98..b02683c 100644
--- a/libutils/String8_fuzz.cpp
+++ b/libutils/String8_fuzz.cpp
@@ -15,97 +15,199 @@
  */
 #include <functional>
 #include <iostream>
+#include <memory>
 
+#include "FuzzFormatTypes.h"
 #include "fuzzer/FuzzedDataProvider.h"
 #include "utils/String8.h"
 
 static constexpr int MAX_STRING_BYTES = 256;
 static constexpr uint8_t MAX_OPERATIONS = 50;
+// Interestingly, 2147483614 (INT32_MAX - 33) seems to be the max value that is handled for format
+// flags. Unfortunately we need to use a smaller value so we avoid consuming too much memory.
 
-std::vector<std::function<void(FuzzedDataProvider&, android::String8, android::String8)>>
+void fuzzFormat(FuzzedDataProvider* dataProvider, android::String8* str1, bool shouldAppend);
+std::vector<std::function<void(FuzzedDataProvider*, android::String8*, android::String8*)>>
         operations = {
-
                 // Bytes and size
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.bytes();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->bytes();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.isEmpty();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->isEmpty();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.length();
-                },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.size();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->length();
                 },
 
                 // Casing
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.toUpper();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->toUpper();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.toLower();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->toLower();
                 },
-
-                [](FuzzedDataProvider&, android::String8 str1, android::String8 str2) -> void {
-                    str1.removeAll(str2.c_str());
+                [](FuzzedDataProvider*, android::String8* str1, android::String8* str2) -> void {
+                    str1->removeAll(str2->c_str());
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8 str2) -> void {
-                    str1.compare(str2);
+                [](FuzzedDataProvider*, android::String8* str1, android::String8* str2) -> void {
+                    const android::String8& constRef(*str2);
+                    str1->compare(constRef);
                 },
 
                 // Append and format
-                [](FuzzedDataProvider&, android::String8 str1, android::String8 str2) -> void {
-                    str1.append(str2);
+                [](FuzzedDataProvider*, android::String8* str1, android::String8* str2) -> void {
+                    str1->append(str2->c_str());
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8 str2) -> void {
-                    str1.appendFormat(str1.c_str(), str2.c_str());
-                },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8 str2) -> void {
-                    str1.format(str1.c_str(), str2.c_str());
-                },
+                [](FuzzedDataProvider* dataProvider, android::String8* str1, android::String8*)
+                        -> void { fuzzFormat(dataProvider, str1, dataProvider->ConsumeBool()); },
 
                 // Find operation
-                [](FuzzedDataProvider& dataProvider, android::String8 str1,
-                   android::String8) -> void {
+                [](FuzzedDataProvider* dataProvider, android::String8* str1,
+                   android::String8* str2) -> void {
                     // We need to get a value from our fuzzer here.
-                    int start_index = dataProvider.ConsumeIntegralInRange<int>(0, str1.size());
-                    str1.find(str1.c_str(), start_index);
+                    int start_index = dataProvider->ConsumeIntegralInRange<int>(0, str1->size());
+                    str1->find(str2->c_str(), start_index);
                 },
 
                 // Path handling
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.getBasePath();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->getBasePath();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.getPathExtension();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->getPathExtension();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.getPathLeaf();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->getPathLeaf();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.getPathDir();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->getPathDir();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    str1.convertToResPath();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    str1->convertToResPath();
                 },
-                [](FuzzedDataProvider&, android::String8 str1, android::String8) -> void {
-                    android::String8 path_out_str = android::String8();
-                    str1.walkPath(&path_out_str);
-                    path_out_str.clear();
+                [](FuzzedDataProvider*, android::String8* str1, android::String8*) -> void {
+                    std::shared_ptr<android::String8> path_out_str =
+                            std::make_shared<android::String8>();
+                    str1->walkPath(path_out_str.get());
+                    path_out_str->clear();
                 },
-                [](FuzzedDataProvider& dataProvider, android::String8 str1,
-                   android::String8) -> void {
-                    str1.setPathName(dataProvider.ConsumeBytesWithTerminator<char>(5).data());
+                [](FuzzedDataProvider* dataProvider, android::String8* str1,
+                   android::String8*) -> void {
+                    str1->setPathName(dataProvider->ConsumeBytesWithTerminator<char>(5).data());
                 },
-                [](FuzzedDataProvider& dataProvider, android::String8 str1,
-                   android::String8) -> void {
-                    str1.appendPath(dataProvider.ConsumeBytesWithTerminator<char>(5).data());
+                [](FuzzedDataProvider* dataProvider, android::String8* str1,
+                   android::String8*) -> void {
+                    str1->appendPath(dataProvider->ConsumeBytesWithTerminator<char>(5).data());
                 },
 };
 
-void callFunc(uint8_t index, FuzzedDataProvider& dataProvider, android::String8 str1,
-              android::String8 str2) {
+void fuzzFormat(FuzzedDataProvider* dataProvider, android::String8* str1, bool shouldAppend) {
+    FormatChar formatType = dataProvider->ConsumeEnum<FormatChar>();
+
+    std::string formatString("%");
+    // Width specifier
+    if (dataProvider->ConsumeBool()) {
+        // Left pad with zeroes
+        if (dataProvider->ConsumeBool()) {
+            formatString.push_back('0');
+        }
+        // Right justify (or left justify if negative)
+        int32_t justify = dataProvider->ConsumeIntegralInRange<int32_t>(-kMaxFormatFlagValue,
+                                                                        kMaxFormatFlagValue);
+        formatString += std::to_string(justify);
+    }
+
+    // The # specifier only works with o, x, X, a, A, e, E, f, F, g, and G
+    if (canApplyFlag(formatType, '#') && dataProvider->ConsumeBool()) {
+        formatString.push_back('#');
+    }
+
+    // Precision specifier
+    if (canApplyFlag(formatType, '.') && dataProvider->ConsumeBool()) {
+        formatString.push_back('.');
+        formatString +=
+                std::to_string(dataProvider->ConsumeIntegralInRange<int>(0, kMaxFormatFlagValue));
+    }
+
+    formatString.push_back(kFormatChars.at(static_cast<uint8_t>(formatType)));
+
+    switch (formatType) {
+        case SIGNED_DECIMAL: {
+            int val = dataProvider->ConsumeIntegral<int>();
+            if (shouldAppend) {
+                str1->appendFormat(formatString.c_str(), val);
+            } else {
+                str1->format(formatString.c_str(), dataProvider->ConsumeIntegral<int>());
+            }
+            break;
+        }
+
+        case UNSIGNED_DECIMAL:
+        case UNSIGNED_OCTAL:
+        case UNSIGNED_HEX_LOWER:
+        case UNSIGNED_HEX_UPPER: {
+            // Unsigned integers for u, o, x, and X
+            uint val = dataProvider->ConsumeIntegral<uint>();
+            if (shouldAppend) {
+                str1->appendFormat(formatString.c_str(), val);
+            } else {
+                str1->format(formatString.c_str(), val);
+            }
+            break;
+        }
+
+        case FLOAT_LOWER:
+        case FLOAT_UPPER:
+        case EXPONENT_LOWER:
+        case EXPONENT_UPPER:
+        case SHORT_EXP_LOWER:
+        case SHORT_EXP_UPPER:
+        case HEX_FLOAT_LOWER:
+        case HEX_FLOAT_UPPER: {
+            // Floating points for f, F, e, E, g, G, a, and A
+            float val = dataProvider->ConsumeFloatingPoint<float>();
+            if (shouldAppend) {
+                str1->appendFormat(formatString.c_str(), val);
+            } else {
+                str1->format(formatString.c_str(), val);
+            }
+            break;
+        }
+
+        case CHAR: {
+            char val = dataProvider->ConsumeIntegral<char>();
+            if (shouldAppend) {
+                str1->appendFormat(formatString.c_str(), val);
+            } else {
+                str1->format(formatString.c_str(), val);
+            }
+            break;
+        }
+
+        case STRING: {
+            std::string val = dataProvider->ConsumeRandomLengthString(MAX_STRING_BYTES);
+            if (shouldAppend) {
+                str1->appendFormat(formatString.c_str(), val.c_str());
+            } else {
+                str1->format(formatString.c_str(), val.c_str());
+            }
+            break;
+        }
+        case POINTER: {
+            uintptr_t val = dataProvider->ConsumeIntegral<uintptr_t>();
+            if (shouldAppend) {
+                str1->appendFormat(formatString.c_str(), val);
+            } else {
+                str1->format(formatString.c_str(), val);
+            }
+            break;
+        }
+    }
+}
+
+void callFunc(uint8_t index, FuzzedDataProvider* dataProvider, android::String8* str1,
+              android::String8* str2) {
     operations[index](dataProvider, str1, str2);
 }
 
@@ -120,14 +222,12 @@
     // Create UTF-8 pointers
     android::String8 str_one_utf8 = android::String8(vec.data());
     android::String8 str_two_utf8 = android::String8(vec_two.data());
-
     // Run operations against strings
     int opsRun = 0;
     while (dataProvider.remaining_bytes() > 0 && opsRun++ < MAX_OPERATIONS) {
         uint8_t op = dataProvider.ConsumeIntegralInRange<uint8_t>(0, operations.size() - 1);
-        callFunc(op, dataProvider, str_one_utf8, str_two_utf8);
+        operations[op](&dataProvider, &str_one_utf8, &str_two_utf8);
     }
-
     // Just to be extra sure these can be freed, we're going to explicitly clear
     // them
     str_one_utf8.clear();
diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp
index 147db54..540dcf4 100644
--- a/libutils/Threads.cpp
+++ b/libutils/Threads.cpp
@@ -302,7 +302,8 @@
 }
 
 #if defined(__ANDROID__)
-int androidSetThreadPriority(pid_t tid, int pri, bool change_policy) {
+int androidSetThreadPriority(pid_t tid, int pri)
+{
     int rc = 0;
     int lasterr = 0;
     int curr_pri = getpriority(PRIO_PROCESS, tid);
@@ -311,19 +312,17 @@
         return rc;
     }
 
-    if (change_policy) {
-        if (pri >= ANDROID_PRIORITY_BACKGROUND) {
-            rc = SetTaskProfiles(tid, {"SCHED_SP_BACKGROUND"}, true) ? 0 : -1;
-        } else if (curr_pri >= ANDROID_PRIORITY_BACKGROUND) {
-            SchedPolicy policy = SP_FOREGROUND;
-            // Change to the sched policy group of the process.
-            get_sched_policy(getpid(), &policy);
-            rc = SetTaskProfiles(tid, {get_sched_policy_profile_name(policy)}, true) ? 0 : -1;
-        }
+    if (pri >= ANDROID_PRIORITY_BACKGROUND) {
+        rc = SetTaskProfiles(tid, {"SCHED_SP_BACKGROUND"}, true) ? 0 : -1;
+    } else if (curr_pri >= ANDROID_PRIORITY_BACKGROUND) {
+        SchedPolicy policy = SP_FOREGROUND;
+        // Change to the sched policy group of the process.
+        get_sched_policy(getpid(), &policy);
+        rc = SetTaskProfiles(tid, {get_sched_policy_profile_name(policy)}, true) ? 0 : -1;
+    }
 
-        if (rc) {
-            lasterr = errno;
-        }
+    if (rc) {
+        lasterr = errno;
     }
 
     if (setpriority(PRIO_PROCESS, tid, pri) < 0) {
diff --git a/libutils/include/utils/AndroidThreads.h b/libutils/include/utils/AndroidThreads.h
index 3c30a2a..a8d7851 100644
--- a/libutils/include/utils/AndroidThreads.h
+++ b/libutils/include/utils/AndroidThreads.h
@@ -78,9 +78,7 @@
 // should be one of the ANDROID_PRIORITY constants.  Returns INVALID_OPERATION
 // if the priority set failed, else another value if just the group set failed;
 // in either case errno is set.  Thread ID zero means current thread.
-// Parameter "change_policy" indicates if sched policy should be changed. It needs
-// not be checked again if the change is done elsewhere like activity manager.
-extern int androidSetThreadPriority(pid_t tid, int prio, bool change_policy = true);
+extern int androidSetThreadPriority(pid_t tid, int prio);
 
 // Get the current priority of a particular thread. Returns one of the
 // ANDROID_PRIORITY constants or a negative result in case of error.
diff --git a/libutils/include/utils/Debug.h b/libutils/include/utils/Debug.h
index 96bd70e..c3b9026 100644
--- a/libutils/include/utils/Debug.h
+++ b/libutils/include/utils/Debug.h
@@ -14,27 +14,9 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_UTILS_DEBUG_H
-#define ANDROID_UTILS_DEBUG_H
+#pragma once
 
-#include <stdint.h>
-#include <sys/types.h>
+// Note: new code should use static_assert directly.
 
-namespace android {
-// ---------------------------------------------------------------------------
-
-#ifdef __cplusplus
-template<bool> struct CompileTimeAssert;
-template<> struct CompileTimeAssert<true> {};
-#define COMPILE_TIME_ASSERT(_exp) \
-    template class CompileTimeAssert< (_exp) >;
-#endif
-
-// DO NOT USE: Please use static_assert instead
-#define COMPILE_TIME_ASSERT_FUNCTION_SCOPE(_exp) \
-    CompileTimeAssert<( _exp )>();
-
-// ---------------------------------------------------------------------------
-}  // namespace android
-
-#endif // ANDROID_UTILS_DEBUG_H
+#define COMPILE_TIME_ASSERT static_assert
+#define COMPILE_TIME_ASSERT_FUNCTION_SCOPE static_assert
diff --git a/libutils/include/utils/Flattenable.h b/libutils/include/utils/Flattenable.h
index 17c5e10..8aa381a 100644
--- a/libutils/include/utils/Flattenable.h
+++ b/libutils/include/utils/Flattenable.h
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_UTILS_FLATTENABLE_H
-#define ANDROID_UTILS_FLATTENABLE_H
+#pragma once
 
 // DO NOT USE: please use parcelable instead
 // This code is deprecated and will not be supported via AIDL code gen. For data
@@ -25,7 +24,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <utils/Errors.h>
-#include <utils/Debug.h>
 
 #include <type_traits>
 
@@ -217,5 +215,3 @@
 };
 
 }  // namespace android
-
-#endif /* ANDROID_UTILS_FLATTENABLE_H */
diff --git a/libutils/include/utils/PropertyMap.h b/libutils/include/utils/PropertyMap.h
deleted file mode 100644
index a9e674f..0000000
--- a/libutils/include/utils/PropertyMap.h
+++ /dev/null
@@ -1,106 +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 _UTILS_PROPERTY_MAP_H
-#define _UTILS_PROPERTY_MAP_H
-
-#include <utils/KeyedVector.h>
-#include <utils/String8.h>
-#include <utils/Errors.h>
-#include <utils/Tokenizer.h>
-
-namespace android {
-
-/*
- * Provides a mechanism for passing around string-based property key / value pairs
- * and loading them from property files.
- *
- * The property files have the following simple structure:
- *
- * # Comment
- * key = value
- *
- * Keys and values are any sequence of printable ASCII characters.
- * The '=' separates the key from the value.
- * The key and value may not contain whitespace.
- *
- * The '\' character is reserved for escape sequences and is not currently supported.
- * The '"" character is reserved for quoting and is not currently supported.
- * Files that contain the '\' or '"' character will fail to parse.
- *
- * The file must not contain duplicate keys.
- *
- * TODO Support escape sequences and quoted values when needed.
- */
-class PropertyMap {
-public:
-    /* Creates an empty property map. */
-    PropertyMap();
-    ~PropertyMap();
-
-    /* Clears the property map. */
-    void clear();
-
-    /* Adds a property.
-     * Replaces the property with the same key if it is already present.
-     */
-    void addProperty(const String8& key, const String8& value);
-
-    /* Returns true if the property map contains the specified key. */
-    bool hasProperty(const String8& key) const;
-
-    /* Gets the value of a property and parses it.
-     * Returns true and sets outValue if the key was found and its value was parsed successfully.
-     * Otherwise returns false and does not modify outValue.  (Also logs a warning.)
-     */
-    bool tryGetProperty(const String8& key, String8& outValue) const;
-    bool tryGetProperty(const String8& key, bool& outValue) const;
-    bool tryGetProperty(const String8& key, int32_t& outValue) const;
-    bool tryGetProperty(const String8& key, float& outValue) const;
-
-    /* Adds all values from the specified property map. */
-    void addAll(const PropertyMap* map);
-
-    /* Gets the underlying property map. */
-    inline const KeyedVector<String8, String8>& getProperties() const { return mProperties; }
-
-    /* Loads a property map from a file. */
-    static status_t load(const String8& filename, PropertyMap** outMap);
-
-private:
-    class Parser {
-        PropertyMap* mMap;
-        Tokenizer* mTokenizer;
-
-    public:
-        Parser(PropertyMap* map, Tokenizer* tokenizer);
-        ~Parser();
-        status_t parse();
-
-    private:
-        status_t parseType();
-        status_t parseKey();
-        status_t parseKeyProperty();
-        status_t parseModifier(const String8& token, int32_t* outMetaState);
-        status_t parseCharacterLiteral(char16_t* outCharacter);
-    };
-
-    KeyedVector<String8, String8> mProperties;
-};
-
-} // namespace android
-
-#endif // _UTILS_PROPERTY_MAP_H
diff --git a/logcat/Android.bp b/logcat/Android.bp
deleted file mode 100644
index 61fba59..0000000
--- a/logcat/Android.bp
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// Copyright (C) 2006 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: "logcat_defaults",
-
-    cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-        "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION=1",
-    ],
-    shared_libs: [
-        "libbase",
-        "libprocessgroup",
-    ],
-    static_libs: ["liblog"],
-    logtags: ["event.logtags"],
-}
-
-cc_binary {
-    name: "logcat",
-
-    defaults: ["logcat_defaults"],
-    srcs: [
-        "logcat.cpp",
-    ],
-}
-
-sh_binary {
-    name: "logcatd",
-    src: "logcatd",
-}
-
-sh_binary {
-    name: "logpersist.start",
-    src: "logpersist",
-    init_rc: ["logcatd.rc"],
-    required: ["logcatd"],
-    symlinks: [
-        "logpersist.stop",
-        "logpersist.cat",
-    ],
-}
diff --git a/logcat/MODULE_LICENSE_APACHE2 b/logcat/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/logcat/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/logcat/NOTICE b/logcat/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/logcat/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
-   Copyright (c) 2005-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.
-
-   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.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
diff --git a/logcat/OWNERS b/logcat/OWNERS
deleted file mode 100644
index babbe4d..0000000
--- a/logcat/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-tomcherry@google.com
diff --git a/logcat/event.logtags b/logcat/event.logtags
deleted file mode 100644
index 93c3d6d..0000000
--- a/logcat/event.logtags
+++ /dev/null
@@ -1,159 +0,0 @@
-# The entries in this file map a sparse set of log tag numbers to tag names.
-# This is installed on the device, in /system/etc, and parsed by logcat.
-#
-# Tag numbers are decimal integers, from 0 to 2^31.  (Let's leave the
-# negative values alone for now.)
-#
-# Tag names are one or more ASCII letters and numbers or underscores, i.e.
-# "[A-Z][a-z][0-9]_".  Do not include spaces or punctuation (the former
-# impacts log readability, the latter makes regex searches more annoying).
-#
-# Tag numbers and names are separated by whitespace.  Blank lines and lines
-# starting with '#' are ignored.
-#
-# Optionally, after the tag names can be put a description for the value(s)
-# of the tag. Description are in the format
-#    (<name>|data type[|data unit])
-# Multiple values are separated by commas.
-#
-# The data type is a number from the following values:
-# 1: int
-# 2: long
-# 3: string
-# 4: list
-# 5: float
-#
-# The data unit is a number taken from the following list:
-# 1: Number of objects
-# 2: Number of bytes
-# 3: Number of milliseconds
-# 4: Number of allocations
-# 5: Id
-# 6: Percent
-# s: Number of seconds (monotonic time)
-# Default value for data of type int/long is 2 (bytes).
-#
-# TODO: generate ".java" and ".h" files with integer constants from this file.
-
-# These are used for testing, do not modify without updating
-# tests/framework-tests/src/android/util/EventLogFunctionalTest.java.
-# system/core/liblog/tests/liblog_benchmark.cpp
-# system/core/liblog/tests/liblog_test.cpp
-42    answer (to life the universe etc|3)
-314   pi
-2718  e
-
-# "account" is the java hash of the account name
-2720 sync (id|3),(event|1|5),(source|1|5),(account|1|5)
-
-# This event is logged when the location service uploads location data.
-2740 location_controller
-# This event is logged when someone is deciding to force a garbage collection
-2741 force_gc (reason|3)
-# This event is logged on each tickle
-2742 tickle (authority|3)
-
-# contacts aggregation: time and number of contacts.
-# count is negative for query phase, positive for merge phase
-2747 contacts_aggregation (aggregation time|2|3), (count|1|1)
-
-# Device boot timings.  We include monotonic clock values because the
-# intrinsic event log times are wall-clock.
-#
-# Runtime starts:
-3000 boot_progress_start (time|2|3)
-# ZygoteInit class preloading starts:
-3020 boot_progress_preload_start (time|2|3)
-# ZygoteInit class preloading ends:
-3030 boot_progress_preload_end (time|2|3)
-
-# Dalvik VM / ART
-20003 dvm_lock_sample (process|3),(main|1|5),(thread|3),(time|1|3),(file|3),(line|1|5),(ownerfile|3),(ownerline|1|5),(sample_percent|1|6)
-20004 art_hidden_api_access (access_method|1),(flags|1),(class|3),(member|3),(type_signature|3)
-
-75000 sqlite_mem_alarm_current (current|1|2)
-75001 sqlite_mem_alarm_max (max|1|2)
-75002 sqlite_mem_alarm_alloc_attempt (attempts|1|4)
-75003 sqlite_mem_released (Memory released|1|2)
-75004 sqlite_db_corrupt (Database file corrupt|3)
-
-50000 menu_item_selected (Menu type where 0 is options and 1 is context|1|5),(Menu item title|3)
-50001 menu_opened (Menu type where 0 is options and 1 is context|1|5)
-
-# HSM wifi state change
-# Hierarchical state class name (as defined in WifiStateTracker.java)
-# Logged on every state change in the hierarchical state machine
-50021 wifi_state_changed (wifi_state|3)
-# HSM wifi event
-# [31-16] Reserved for future use
-# [15 - 0] HSM event (as defined in WifiStateTracker.java)
-# Logged when an event is handled in a hierarchical state
-50022 wifi_event_handled (wifi_event|1|5)
-# Supplicant state change
-# [31-13] Reserved for future use
-# [8 - 0] Supplicant state (as defined in SupplicantState.java)
-# Logged when the supplicant switches to a new state
-50023 wifi_supplicant_state_changed (supplicant_state|1|5)
-
-# Database operation samples.
-# db: the filename of the database
-# sql: the executed query (without query args)
-# time: cpu time millis (not wall time), including lock acquisition
-# blocking_package: if this is on a main thread, the package name, otherwise ""
-# sample_percent: the percent likelihood this query was logged
-52000 db_sample (db|3),(sql|3),(time|1|3),(blocking_package|3),(sample_percent|1|6)
-
-# http request/response stats
-52001 http_stats (useragent|3),(response|2|3),(processing|2|3),(tx|1|2),(rx|1|2)
-60000 viewroot_draw (Draw time|1|3)
-60001 viewroot_layout (Layout time|1|3)
-60002 view_build_drawing_cache (View created drawing cache|1|5)
-60003 view_use_drawing_cache (View drawn using bitmap cache|1|5)
-
-# graphics timestamp
-# 60100 - 60199 reserved for surfaceflinger
-
-# audio
-# 61000 - 61199 reserved for audioserver
-
-# input
-# 62000 - 62199 reserved for inputflinger
-
-# com.android.server.policy
-# 70000 - 70199 reserved for PhoneWindowManager and other policies
-
-# aggregation service
-70200 aggregation (aggregation time|2|3)
-70201 aggregation_test (field1|1|2),(field2|1|2),(field3|1|2),(field4|1|2),(field5|1|2)
-
-# gms refuses to register this log tag, b/30156345
-70220 gms_unknown
-
-# libc failure logging
-80100 bionic_event_memcpy_buffer_overflow (uid|1)
-80105 bionic_event_strcat_buffer_overflow (uid|1)
-80110 bionic_event_memmov_buffer_overflow (uid|1)
-80115 bionic_event_strncat_buffer_overflow (uid|1)
-80120 bionic_event_strncpy_buffer_overflow (uid|1)
-80125 bionic_event_memset_buffer_overflow (uid|1)
-80130 bionic_event_strcpy_buffer_overflow (uid|1)
-
-80200 bionic_event_strcat_integer_overflow (uid|1)
-80205 bionic_event_strncat_integer_overflow (uid|1)
-
-80300 bionic_event_resolver_old_response (uid|1)
-80305 bionic_event_resolver_wrong_server (uid|1)
-80310 bionic_event_resolver_wrong_query (uid|1)
-
-# libcore failure logging
-90100 exp_det_cert_pin_failure (certs|4)
-
-# 150000 - 160000 reserved for Android Automotive builds
-
-1397638484 snet_event_log (subtag|3) (uid|1) (message|3)
-
-# for events that go to stats log buffer
-1937006964 stats_log (atom_id|1|5),(data|4)
-
-# NOTE - the range 1000000-2000000 is reserved for partners and others who
-# want to define their own log tags without conflicting with the core platform.
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
deleted file mode 100644
index 6b7e016..0000000
--- a/logcat/logcat.cpp
+++ /dev/null
@@ -1,1212 +0,0 @@
-/*
- * Copyright (C) 2006-2017 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 <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <error.h>
-#include <fcntl.h>
-#include <getopt.h>
-#include <math.h>
-#include <sched.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/cdefs.h>
-#include <sys/ioctl.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <memory>
-#include <regex>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <android-base/file.h>
-#include <android-base/macros.h>
-#include <android-base/parseint.h>
-#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
-#include <android-base/strings.h>
-#include <android-base/unique_fd.h>
-#include <android/log.h>
-#include <log/event_tag_map.h>
-#include <log/log_id.h>
-#include <log/log_read.h>
-#include <log/logprint.h>
-#include <private/android_logger.h>
-#include <processgroup/sched_policy.h>
-#include <system/thread_defs.h>
-
-#define DEFAULT_MAX_ROTATED_LOGS 4
-
-using android::base::Join;
-using android::base::ParseByteCount;
-using android::base::ParseUint;
-using android::base::Split;
-using android::base::StringPrintf;
-using android::base::WriteFully;
-
-class Logcat {
-  public:
-    int Run(int argc, char** argv);
-
-  private:
-    void RotateLogs();
-    void ProcessBuffer(struct log_msg* buf);
-    void PrintDividers(log_id_t log_id, bool print_dividers);
-    void SetupOutputAndSchedulingPolicy(bool blocking);
-    int SetLogFormat(const char* format_string);
-
-    // Used for all options
-    android::base::unique_fd output_fd_{dup(STDOUT_FILENO)};
-    std::unique_ptr<AndroidLogFormat, decltype(&android_log_format_free)> logformat_{
-            android_log_format_new(), &android_log_format_free};
-
-    // For logging to a file and log rotation
-    const char* output_file_name_ = nullptr;
-    size_t log_rotate_size_kb_ = 0;                       // 0 means "no log rotation"
-    size_t max_rotated_logs_ = DEFAULT_MAX_ROTATED_LOGS;  // 0 means "unbounded"
-    size_t out_byte_count_ = 0;
-
-    // For binary log buffers
-    int print_binary_ = 0;
-    std::unique_ptr<EventTagMap, decltype(&android_closeEventTagMap)> event_tag_map_{
-            nullptr, &android_closeEventTagMap};
-    bool has_opened_event_tag_map_ = false;
-
-    // For the related --regex, --max-count, --print
-    std::unique_ptr<std::regex> regex_;
-    size_t max_count_ = 0;  // 0 means "infinite"
-    size_t print_count_ = 0;
-    bool print_it_anyways_ = false;
-
-    // For PrintDividers()
-    log_id_t last_printed_id_ = LOG_ID_MAX;
-    bool printed_start_[LOG_ID_MAX] = {};
-
-    bool debug_ = false;
-};
-
-#ifndef F2FS_IOC_SET_PIN_FILE
-#define F2FS_IOCTL_MAGIC       0xf5
-#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
-#endif
-
-static int openLogFile(const char* pathname, size_t sizeKB) {
-    int fd = open(pathname, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP);
-    if (fd < 0) {
-        return fd;
-    }
-
-    // no need to check errors
-    __u32 set = 1;
-    ioctl(fd, F2FS_IOC_SET_PIN_FILE, &set);
-    fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, (sizeKB << 10));
-    return fd;
-}
-
-static void closeLogFile(const char* pathname) {
-    int fd = open(pathname, O_WRONLY | O_CLOEXEC);
-    if (fd == -1) {
-        return;
-    }
-
-    // no need to check errors
-    __u32 set = 0;
-    ioctl(fd, F2FS_IOC_SET_PIN_FILE, &set);
-    close(fd);
-}
-
-void Logcat::RotateLogs() {
-    // Can't rotate logs if we're not outputting to a file
-    if (!output_file_name_) return;
-
-    output_fd_.reset();
-
-    // Compute the maximum number of digits needed to count up to
-    // maxRotatedLogs in decimal.  eg:
-    // maxRotatedLogs == 30
-    //   -> log10(30) == 1.477
-    //   -> maxRotationCountDigits == 2
-    int max_rotation_count_digits =
-            max_rotated_logs_ > 0 ? (int)(floor(log10(max_rotated_logs_) + 1)) : 0;
-
-    for (int i = max_rotated_logs_; i > 0; i--) {
-        std::string file1 =
-                StringPrintf("%s.%.*d", output_file_name_, max_rotation_count_digits, i);
-
-        std::string file0;
-        if (!(i - 1)) {
-            file0 = output_file_name_;
-        } else {
-            file0 = StringPrintf("%s.%.*d", output_file_name_, max_rotation_count_digits, i - 1);
-        }
-
-        if (!file0.length() || !file1.length()) {
-            perror("while rotating log files");
-            break;
-        }
-
-        closeLogFile(file0.c_str());
-
-        int err = rename(file0.c_str(), file1.c_str());
-
-        if (err < 0 && errno != ENOENT) {
-            perror("while rotating log files");
-        }
-    }
-
-    output_fd_.reset(openLogFile(output_file_name_, log_rotate_size_kb_));
-
-    if (!output_fd_.ok()) {
-        error(EXIT_FAILURE, errno, "Couldn't open output file");
-    }
-
-    out_byte_count_ = 0;
-}
-
-void Logcat::ProcessBuffer(struct log_msg* buf) {
-    int bytesWritten = 0;
-    int err;
-    AndroidLogEntry entry;
-    char binaryMsgBuf[1024];
-
-    bool is_binary =
-            buf->id() == LOG_ID_EVENTS || buf->id() == LOG_ID_STATS || buf->id() == LOG_ID_SECURITY;
-
-    if (is_binary) {
-        if (!event_tag_map_ && !has_opened_event_tag_map_) {
-            event_tag_map_.reset(android_openEventTagMap(nullptr));
-            has_opened_event_tag_map_ = true;
-        }
-        err = android_log_processBinaryLogBuffer(&buf->entry, &entry, event_tag_map_.get(),
-                                                 binaryMsgBuf, sizeof(binaryMsgBuf));
-        // printf(">>> pri=%d len=%d msg='%s'\n",
-        //    entry.priority, entry.messageLen, entry.message);
-    } else {
-        err = android_log_processLogBuffer(&buf->entry, &entry);
-    }
-    if (err < 0 && !debug_) return;
-
-    if (android_log_shouldPrintLine(logformat_.get(), std::string(entry.tag, entry.tagLen).c_str(),
-                                    entry.priority)) {
-        bool match = !regex_ ||
-                     std::regex_search(entry.message, entry.message + entry.messageLen, *regex_);
-
-        print_count_ += match;
-        if (match || print_it_anyways_) {
-            bytesWritten = android_log_printLogLine(logformat_.get(), output_fd_.get(), &entry);
-
-            if (bytesWritten < 0) {
-                error(EXIT_FAILURE, 0, "Output error.");
-            }
-        }
-    }
-
-    out_byte_count_ += bytesWritten;
-
-    if (log_rotate_size_kb_ > 0 && (out_byte_count_ / 1024) >= log_rotate_size_kb_) {
-        RotateLogs();
-    }
-}
-
-void Logcat::PrintDividers(log_id_t log_id, bool print_dividers) {
-    if (log_id == last_printed_id_ || print_binary_) {
-        return;
-    }
-    if (!printed_start_[log_id] || print_dividers) {
-        if (dprintf(output_fd_.get(), "--------- %s %s\n",
-                    printed_start_[log_id] ? "switch to" : "beginning of",
-                    android_log_id_to_name(log_id)) < 0) {
-            error(EXIT_FAILURE, errno, "Output error");
-        }
-    }
-    last_printed_id_ = log_id;
-    printed_start_[log_id] = true;
-}
-
-void Logcat::SetupOutputAndSchedulingPolicy(bool blocking) {
-    if (!output_file_name_) return;
-
-    if (blocking) {
-        // Lower priority and set to batch scheduling if we are saving
-        // the logs into files and taking continuous content.
-        if (set_sched_policy(0, SP_BACKGROUND) < 0) {
-            fprintf(stderr, "failed to set background scheduling policy\n");
-        }
-
-        struct sched_param param = {};
-        if (sched_setscheduler((pid_t)0, SCHED_BATCH, &param) < 0) {
-            fprintf(stderr, "failed to set to batch scheduler\n");
-        }
-
-        if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) {
-            fprintf(stderr, "failed set to priority\n");
-        }
-    }
-
-    output_fd_.reset(openLogFile(output_file_name_, log_rotate_size_kb_));
-
-    if (!output_fd_.ok()) {
-        error(EXIT_FAILURE, errno, "Couldn't open output file");
-    }
-
-    struct stat statbuf;
-    if (fstat(output_fd_.get(), &statbuf) == -1) {
-        error(EXIT_FAILURE, errno, "Couldn't get output file stat");
-    }
-
-    if ((size_t)statbuf.st_size > SIZE_MAX || statbuf.st_size < 0) {
-        error(EXIT_FAILURE, 0, "Invalid output file stat.");
-    }
-
-    out_byte_count_ = statbuf.st_size;
-}
-
-// clang-format off
-static void show_help() {
-    const char* cmd = getprogname();
-
-    fprintf(stderr, "Usage: %s [options] [filterspecs]\n", cmd);
-
-    fprintf(stderr, R"init(
-General options:
-  -b, --buffer=<buffer>       Request alternate ring buffer(s):
-                                main system radio events crash default all
-                              Additionally, 'kernel' for userdebug and eng builds, and
-                              'security' for Device Owner installations.
-                              Multiple -b parameters or comma separated list of buffers are
-                              allowed. Buffers are interleaved.
-                              Default -b main,system,crash,kernel.
-  -L, --last                  Dump logs from prior to last reboot from pstore.
-  -c, --clear                 Clear (flush) the entire log and exit.
-                              if -f is specified, clear the specified file and its related rotated
-                              log files instead.
-                              if -L is specified, clear pstore log instead.
-  -d                          Dump the log and then exit (don't block).
-  --pid=<pid>                 Only print logs from the given pid.
-  --wrap                      Sleep for 2 hours or when buffer about to wrap whichever
-                              comes first. Improves efficiency of polling by providing
-                              an about-to-wrap wakeup.
-
-Formatting:
-  -v, --format=<format>       Sets log print format verb and adverbs, where <format> is one of:
-                                brief help long process raw tag thread threadtime time
-                              Modifying adverbs can be added:
-                                color descriptive epoch monotonic printable uid usec UTC year zone
-                              Multiple -v parameters or comma separated list of format and format
-                              modifiers are allowed.
-  -D, --dividers              Print dividers between each log buffer.
-  -B, --binary                Output the log in binary.
-
-Outfile files:
-  -f, --file=<file>           Log to file instead of stdout.
-  -r, --rotate-kbytes=<n>     Rotate log every <n> kbytes. Requires -f option.
-  -n, --rotate-count=<count>  Sets max number of rotated logs to <count>, default 4.
-  --id=<id>                   If the signature <id> for logging to file changes, then clear the
-                              associated files and continue.
-
-Logd control:
- These options send a control message to the logd daemon on device, print its return message if
- applicable, then exit. They are incompatible with -L, as these attributes do not apply to pstore.
-  -g, --buffer-size           Get the size of the ring buffers within logd.
-  -G, --buffer-size=<size>    Set size of a ring buffer in logd. May suffix with K or M.
-                              This can individually control each buffer's size with -b.
-  -S, --statistics            Output statistics.
-                              --pid can be used to provide pid specific stats.
-  -p, --prune                 Print prune rules. Each rule is specified as UID, UID/PID or /PID. A
-                              '~' prefix indicates that elements matching the rule should be pruned
-                              with higher priority otherwise they're pruned with lower priority. All
-                              other pruning activity is oldest first. Special case ~! represents an
-                              automatic pruning for the noisiest UID as determined by the current
-                              statistics.  Special case ~1000/! represents pruning of the worst PID
-                              within AID_SYSTEM when AID_SYSTEM is the noisiest UID.
-  -P, --prune='<list> ...'    Set prune rules, using same format as listed above. Must be quoted.
-
-Filtering:
-  -s                          Set default filter to silent. Equivalent to filterspec '*:S'
-  -e, --regex=<expr>          Only print lines where the log message matches <expr> where <expr> is
-                              an ECMAScript regular expression.
-  -m, --max-count=<count>     Quit after printing <count> lines. This is meant to be paired with
-                              --regex, but will work on its own.
-  --print                     This option is only applicable when --regex is set and only useful if
-                              --max-count is also provided.
-                              With --print, logcat will print all messages even if they do not
-                              match the regex. Logcat will quit after printing the max-count number
-                              of lines that match the regex.
-  -t <count>                  Print only the most recent <count> lines (implies -d).
-  -t '<time>'                 Print the lines since specified time (implies -d).
-  -T <count>                  Print only the most recent <count> lines (does not imply -d).
-  -T '<time>'                 Print the lines since specified time (not imply -d).
-                              count is pure numerical, time is 'MM-DD hh:mm:ss.mmm...'
-                              'YYYY-MM-DD hh:mm:ss.mmm...' or 'sssss.mmm...' format.
-  --uid=<uids>                Only display log messages from UIDs present in the comma separate list
-                              <uids>. No name look-up is performed, so UIDs must be provided as
-                              numeric values. This option is only useful for the 'root', 'log', and
-                              'system' users since only those users can view logs from other users.
-)init");
-
-    fprintf(stderr, "\nfilterspecs are a series of \n"
-                   "  <tag>[:priority]\n\n"
-                   "where <tag> is a log component tag (or * for all) and priority is:\n"
-                   "  V    Verbose (default for <tag>)\n"
-                   "  D    Debug (default for '*')\n"
-                   "  I    Info\n"
-                   "  W    Warn\n"
-                   "  E    Error\n"
-                   "  F    Fatal\n"
-                   "  S    Silent (suppress all output)\n"
-                   "\n'*' by itself means '*:D' and <tag> by itself means <tag>:V.\n"
-                   "If no '*' filterspec or -s on command line, all filter defaults to '*:V'.\n"
-                   "eg: '*:S <tag>' prints only <tag>, '<tag>:S' suppresses all <tag> log messages.\n"
-                   "\nIf not specified on the command line, filterspec is set from ANDROID_LOG_TAGS.\n"
-                   "\nIf not specified with -v on command line, format is set from ANDROID_PRINTF_LOG\n"
-                   "or defaults to \"threadtime\"\n\n");
-}
-
-static void show_format_help() {
-    fprintf(stderr,
-        "-v <format>, --format=<format> options:\n"
-        "  Sets log print format verb and adverbs, where <format> is:\n"
-        "    brief long process raw tag thread threadtime time\n"
-        "  and individually flagged modifying adverbs can be added:\n"
-        "    color descriptive epoch monotonic printable uid usec UTC year zone\n"
-        "\nSingle format verbs:\n"
-        "  brief      — Display priority/tag and PID of the process issuing the message.\n"
-        "  long       — Display all metadata fields, separate messages with blank lines.\n"
-        "  process    — Display PID only.\n"
-        "  raw        — Display the raw log message, with no other metadata fields.\n"
-        "  tag        — Display the priority/tag only.\n"
-        "  thread     — Display priority, PID and TID of process issuing the message.\n"
-        "  threadtime — Display the date, invocation time, priority, tag, and the PID\n"
-        "               and TID of the thread issuing the message. (the default format).\n"
-        "  time       — Display the date, invocation time, priority/tag, and PID of the\n"
-        "             process issuing the message.\n"
-        "\nAdverb modifiers can be used in combination:\n"
-        "  color       — Display in highlighted color to match priority. i.e. \x1B[39mVERBOSE\n"
-        "                \x1B[34mDEBUG \x1B[32mINFO \x1B[33mWARNING \x1B[31mERROR FATAL\x1B[0m\n"
-        "  descriptive — events logs only, descriptions from event-log-tags database.\n"
-        "  epoch       — Display time as seconds since Jan 1 1970.\n"
-        "  monotonic   — Display time as cpu seconds since last boot.\n"
-        "  printable   — Ensure that any binary logging content is escaped.\n"
-        "  uid         — If permitted, display the UID or Android ID of logged process.\n"
-        "  usec        — Display time down the microsecond precision.\n"
-        "  UTC         — Display time as UTC.\n"
-        "  year        — Add the year to the displayed time.\n"
-        "  zone        — Add the local timezone to the displayed time.\n"
-        "  \"<zone>\"    — Print using this public named timezone (experimental).\n\n"
-    );
-}
-// clang-format on
-
-int Logcat::SetLogFormat(const char* format_string) {
-    AndroidLogPrintFormat format = android_log_formatFromString(format_string);
-
-    // invalid string?
-    if (format == FORMAT_OFF) return -1;
-
-    return android_log_setPrintFormat(logformat_.get(), format);
-}
-
-static std::pair<unsigned long, const char*> format_of_size(unsigned long value) {
-    static const char multipliers[][3] = {{""}, {"Ki"}, {"Mi"}, {"Gi"}};
-    size_t i;
-    for (i = 0;
-         (i < sizeof(multipliers) / sizeof(multipliers[0])) && (value >= 1024);
-         value /= 1024, ++i)
-        ;
-    return std::make_pair(value, multipliers[i]);
-}
-
-static char* parseTime(log_time& t, const char* cp) {
-    char* ep = t.strptime(cp, "%m-%d %H:%M:%S.%q");
-    if (ep) return ep;
-    ep = t.strptime(cp, "%Y-%m-%d %H:%M:%S.%q");
-    if (ep) return ep;
-    return t.strptime(cp, "%s.%q");
-}
-
-// Find last logged line in <outputFileName>, or <outputFileName>.1
-static log_time lastLogTime(const char* outputFileName) {
-    log_time retval(log_time::EPOCH);
-    if (!outputFileName) return retval;
-
-    std::string directory;
-    const char* file = strrchr(outputFileName, '/');
-    if (!file) {
-        directory = ".";
-        file = outputFileName;
-    } else {
-        directory = std::string(outputFileName, file - outputFileName);
-        ++file;
-    }
-
-    std::unique_ptr<DIR, int (*)(DIR*)> dir(opendir(directory.c_str()),
-                                            closedir);
-    if (!dir.get()) return retval;
-
-    log_time now(CLOCK_REALTIME);
-
-    size_t len = strlen(file);
-    log_time modulo(0, NS_PER_SEC);
-    struct dirent* dp;
-
-    while (!!(dp = readdir(dir.get()))) {
-        if ((dp->d_type != DT_REG) || !!strncmp(dp->d_name, file, len) ||
-            (dp->d_name[len] && ((dp->d_name[len] != '.') ||
-                                 (strtoll(dp->d_name + 1, nullptr, 10) != 1)))) {
-            continue;
-        }
-
-        std::string file_name = directory;
-        file_name += "/";
-        file_name += dp->d_name;
-        std::string file;
-        if (!android::base::ReadFileToString(file_name, &file)) continue;
-
-        bool found = false;
-        for (const auto& line : android::base::Split(file, "\n")) {
-            log_time t(log_time::EPOCH);
-            char* ep = parseTime(t, line.c_str());
-            if (!ep || (*ep != ' ')) continue;
-            // determine the time precision of the logs (eg: msec or usec)
-            for (unsigned long mod = 1UL; mod < modulo.tv_nsec; mod *= 10) {
-                if (t.tv_nsec % (mod * 10)) {
-                    modulo.tv_nsec = mod;
-                    break;
-                }
-            }
-            // We filter any times later than current as we may not have the
-            // year stored with each log entry. Also, since it is possible for
-            // entries to be recorded out of order (very rare) we select the
-            // maximum we find just in case.
-            if ((t < now) && (t > retval)) {
-                retval = t;
-                found = true;
-            }
-        }
-        // We count on the basename file to be the definitive end, so stop here.
-        if (!dp->d_name[len] && found) break;
-    }
-    if (retval == log_time::EPOCH) return retval;
-    // tail_time prints matching or higher, round up by the modulo to prevent
-    // a replay of the last entry we have just checked.
-    retval += modulo;
-    return retval;
-}
-
-void ReportErrorName(const std::string& name, bool allow_security,
-                     std::vector<std::string>* errors) {
-    if (allow_security || name != "security") {
-        errors->emplace_back(name);
-    }
-}
-
-int Logcat::Run(int argc, char** argv) {
-    bool hasSetLogFormat = false;
-    bool clearLog = false;
-    bool security_buffer_selected =
-            false;  // Do not report errors on the security buffer unless it is explicitly named.
-    bool getLogSize = false;
-    bool getPruneList = false;
-    bool printStatistics = false;
-    bool printDividers = false;
-    unsigned long setLogSize = 0;
-    const char* setPruneList = nullptr;
-    const char* setId = nullptr;
-    int mode = 0;
-    std::string forceFilters;
-    size_t tail_lines = 0;
-    log_time tail_time(log_time::EPOCH);
-    size_t pid = 0;
-    bool got_t = false;
-    unsigned id_mask = 0;
-    std::set<uid_t> uids;
-
-    if (argc == 2 && !strcmp(argv[1], "--help")) {
-        show_help();
-        return EXIT_SUCCESS;
-    }
-
-    // meant to catch comma-delimited values, but cast a wider
-    // net for stability dealing with possible mistaken inputs.
-    static const char delimiters[] = ",:; \t\n\r\f";
-
-    optind = 0;
-    while (true) {
-        int option_index = 0;
-        // list of long-argument only strings for later comparison
-        static const char pid_str[] = "pid";
-        static const char debug_str[] = "debug";
-        static const char id_str[] = "id";
-        static const char wrap_str[] = "wrap";
-        static const char print_str[] = "print";
-        static const char uid_str[] = "uid";
-        // clang-format off
-        static const struct option long_options[] = {
-          { "binary",        no_argument,       nullptr, 'B' },
-          { "buffer",        required_argument, nullptr, 'b' },
-          { "buffer-size",   optional_argument, nullptr, 'g' },
-          { "clear",         no_argument,       nullptr, 'c' },
-          { debug_str,       no_argument,       nullptr, 0 },
-          { "dividers",      no_argument,       nullptr, 'D' },
-          { "file",          required_argument, nullptr, 'f' },
-          { "format",        required_argument, nullptr, 'v' },
-          // hidden and undocumented reserved alias for --regex
-          { "grep",          required_argument, nullptr, 'e' },
-          // hidden and undocumented reserved alias for --max-count
-          { "head",          required_argument, nullptr, 'm' },
-          { "help",          no_argument,       nullptr, 'h' },
-          { id_str,          required_argument, nullptr, 0 },
-          { "last",          no_argument,       nullptr, 'L' },
-          { "max-count",     required_argument, nullptr, 'm' },
-          { pid_str,         required_argument, nullptr, 0 },
-          { print_str,       no_argument,       nullptr, 0 },
-          { "prune",         optional_argument, nullptr, 'p' },
-          { "regex",         required_argument, nullptr, 'e' },
-          { "rotate-count",  required_argument, nullptr, 'n' },
-          { "rotate-kbytes", required_argument, nullptr, 'r' },
-          { "statistics",    no_argument,       nullptr, 'S' },
-          // hidden and undocumented reserved alias for -t
-          { "tail",          required_argument, nullptr, 't' },
-          { uid_str,         required_argument, nullptr, 0 },
-          // support, but ignore and do not document, the optional argument
-          { wrap_str,        optional_argument, nullptr, 0 },
-          { nullptr,         0,                 nullptr, 0 }
-        };
-        // clang-format on
-
-        int c = getopt_long(argc, argv, ":cdDhLt:T:gG:sQf:r:n:v:b:BSpP:m:e:", long_options,
-                            &option_index);
-        if (c == -1) break;
-
-        switch (c) {
-            case 0:
-                // only long options
-                if (long_options[option_index].name == pid_str) {
-                    if (pid != 0) {
-                        error(EXIT_FAILURE, 0, "Only one --pid argument can be provided.");
-                    }
-
-                    if (!ParseUint(optarg, &pid) || pid < 1) {
-                        error(EXIT_FAILURE, 0, "%s %s out of range.",
-                              long_options[option_index].name, optarg);
-                    }
-                    break;
-                }
-                if (long_options[option_index].name == wrap_str) {
-                    mode |= ANDROID_LOG_WRAP | ANDROID_LOG_NONBLOCK;
-                    // ToDo: implement API that supports setting a wrap timeout
-                    size_t timeout = ANDROID_LOG_WRAP_DEFAULT_TIMEOUT;
-                    if (optarg && (!ParseUint(optarg, &timeout) || timeout < 1)) {
-                        error(EXIT_FAILURE, 0, "%s %s out of range.",
-                              long_options[option_index].name, optarg);
-                    }
-                    if (timeout != ANDROID_LOG_WRAP_DEFAULT_TIMEOUT) {
-                        fprintf(stderr, "WARNING: %s %u seconds, ignoring %zu\n",
-                                long_options[option_index].name, ANDROID_LOG_WRAP_DEFAULT_TIMEOUT,
-                                timeout);
-                    }
-                    break;
-                }
-                if (long_options[option_index].name == print_str) {
-                    print_it_anyways_ = true;
-                    break;
-                }
-                if (long_options[option_index].name == debug_str) {
-                    debug_ = true;
-                    break;
-                }
-                if (long_options[option_index].name == id_str) {
-                    setId = (optarg && optarg[0]) ? optarg : nullptr;
-                }
-                if (long_options[option_index].name == uid_str) {
-                    auto uid_strings = Split(optarg, delimiters);
-                    for (const auto& uid_string : uid_strings) {
-                        uid_t uid;
-                        if (!ParseUint(uid_string, &uid)) {
-                            error(EXIT_FAILURE, 0, "Unable to parse UID '%s'", uid_string.c_str());
-                        }
-                        uids.emplace(uid);
-                    }
-                    break;
-                }
-                break;
-
-            case 's':
-                // default to all silent
-                android_log_addFilterRule(logformat_.get(), "*:s");
-                break;
-
-            case 'c':
-                clearLog = true;
-                break;
-
-            case 'L':
-                mode |= ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK;
-                break;
-
-            case 'd':
-                mode |= ANDROID_LOG_NONBLOCK;
-                break;
-
-            case 't':
-                got_t = true;
-                mode |= ANDROID_LOG_NONBLOCK;
-                FALLTHROUGH_INTENDED;
-            case 'T':
-                if (strspn(optarg, "0123456789") != strlen(optarg)) {
-                    char* cp = parseTime(tail_time, optarg);
-                    if (!cp) {
-                        error(EXIT_FAILURE, 0, "-%c '%s' not in time format.", c, optarg);
-                    }
-                    if (*cp) {
-                        char ch = *cp;
-                        *cp = '\0';
-                        fprintf(stderr, "WARNING: -%c '%s' '%c%s' time truncated\n", c, optarg, ch,
-                                cp + 1);
-                        *cp = ch;
-                    }
-                } else {
-                    if (!ParseUint(optarg, &tail_lines) || tail_lines < 1) {
-                        fprintf(stderr, "WARNING: -%c %s invalid, setting to 1\n", c, optarg);
-                        tail_lines = 1;
-                    }
-                }
-                break;
-
-            case 'D':
-                printDividers = true;
-                break;
-
-            case 'e':
-                regex_.reset(new std::regex(optarg));
-                break;
-
-            case 'm': {
-                if (!ParseUint(optarg, &max_count_) || max_count_ < 1) {
-                    error(EXIT_FAILURE, 0, "-%c '%s' isn't an integer greater than zero.", c,
-                          optarg);
-                }
-            } break;
-
-            case 'g':
-                if (!optarg) {
-                    getLogSize = true;
-                    break;
-                }
-                FALLTHROUGH_INTENDED;
-
-            case 'G': {
-                if (!ParseByteCount(optarg, &setLogSize) || setLogSize < 1) {
-                    error(EXIT_FAILURE, 0, "-G must be specified as <num><multiplier>.");
-                }
-            } break;
-
-            case 'p':
-                if (!optarg) {
-                    getPruneList = true;
-                    break;
-                }
-                FALLTHROUGH_INTENDED;
-
-            case 'P':
-                setPruneList = optarg;
-                break;
-
-            case 'b':
-                for (const auto& buffer : Split(optarg, delimiters)) {
-                    if (buffer == "default") {
-                        id_mask |= (1 << LOG_ID_MAIN) | (1 << LOG_ID_SYSTEM) | (1 << LOG_ID_CRASH);
-                    } else if (buffer == "all") {
-                        id_mask = -1;
-                    } else {
-                        log_id_t log_id = android_name_to_log_id(buffer.c_str());
-                        if (log_id >= LOG_ID_MAX) {
-                            error(EXIT_FAILURE, 0, "Unknown buffer '%s' listed for -b.",
-                                  buffer.c_str());
-                        }
-                        if (log_id == LOG_ID_SECURITY) {
-                            security_buffer_selected = true;
-                        }
-                        id_mask |= (1 << log_id);
-                    }
-                }
-                break;
-
-            case 'B':
-                print_binary_ = 1;
-                break;
-
-            case 'f':
-                if ((tail_time == log_time::EPOCH) && !tail_lines) {
-                    tail_time = lastLogTime(optarg);
-                }
-                // redirect output to a file
-                output_file_name_ = optarg;
-                break;
-
-            case 'r':
-                if (!ParseUint(optarg, &log_rotate_size_kb_) || log_rotate_size_kb_ < 1) {
-                    error(EXIT_FAILURE, 0, "Invalid parameter '%s' to -r.", optarg);
-                }
-                break;
-
-            case 'n':
-                if (!ParseUint(optarg, &max_rotated_logs_) || max_rotated_logs_ < 1) {
-                    error(EXIT_FAILURE, 0, "Invalid parameter '%s' to -n.", optarg);
-                }
-                break;
-
-            case 'v':
-                if (!strcmp(optarg, "help") || !strcmp(optarg, "--help")) {
-                    show_format_help();
-                    return EXIT_SUCCESS;
-                }
-                for (const auto& arg : Split(optarg, delimiters)) {
-                    int err = SetLogFormat(arg.c_str());
-                    if (err < 0) {
-                        error(EXIT_FAILURE, 0, "Invalid parameter '%s' to -v.", arg.c_str());
-                    }
-                    if (err) hasSetLogFormat = true;
-                }
-                break;
-
-            case 'Q':
-#define LOGCAT_FILTER "androidboot.logcat="
-#define CONSOLE_PIPE_OPTION "androidboot.consolepipe="
-#define CONSOLE_OPTION "androidboot.console="
-#define QEMU_PROPERTY "ro.kernel.qemu"
-#define QEMU_CMDLINE "qemu.cmdline"
-                // This is a *hidden* option used to start a version of logcat
-                // in an emulated device only.  It basically looks for
-                // androidboot.logcat= on the kernel command line.  If
-                // something is found, it extracts a log filter and uses it to
-                // run the program. The logcat output will go to consolepipe if
-                // androiboot.consolepipe (e.g. qemu_pipe) is given, otherwise,
-                // it goes to androidboot.console (e.g. tty)
-                {
-                    // if not in emulator, exit quietly
-                    if (false == android::base::GetBoolProperty(QEMU_PROPERTY, false)) {
-                        return EXIT_SUCCESS;
-                    }
-
-                    std::string cmdline = android::base::GetProperty(QEMU_CMDLINE, "");
-                    if (cmdline.empty()) {
-                        android::base::ReadFileToString("/proc/cmdline", &cmdline);
-                    }
-
-                    const char* logcatFilter = strstr(cmdline.c_str(), LOGCAT_FILTER);
-                    // if nothing found or invalid filters, exit quietly
-                    if (!logcatFilter) {
-                        return EXIT_SUCCESS;
-                    }
-
-                    const char* p = logcatFilter + strlen(LOGCAT_FILTER);
-                    const char* q = strpbrk(p, " \t\n\r");
-                    if (!q) q = p + strlen(p);
-                    forceFilters = std::string(p, q);
-
-                    // redirect our output to the emulator console pipe or console
-                    const char* consolePipe =
-                        strstr(cmdline.c_str(), CONSOLE_PIPE_OPTION);
-                    const char* console =
-                        strstr(cmdline.c_str(), CONSOLE_OPTION);
-
-                    if (consolePipe) {
-                        p = consolePipe + strlen(CONSOLE_PIPE_OPTION);
-                    } else if (console) {
-                        p = console + strlen(CONSOLE_OPTION);
-                    } else {
-                        return EXIT_FAILURE;
-                    }
-
-                    q = strpbrk(p, " \t\n\r");
-                    int len = q ? q - p : strlen(p);
-                    std::string devname = "/dev/" + std::string(p, len);
-                    std::string pipePurpose("pipe:logcat");
-                    if (consolePipe) {
-                        // example: "qemu_pipe,pipe:logcat"
-                        // upon opening of /dev/qemu_pipe, the "pipe:logcat"
-                        // string with trailing '\0' should be written to the fd
-                        size_t pos = devname.find(',');
-                        if (pos != std::string::npos) {
-                            pipePurpose = devname.substr(pos + 1);
-                            devname = devname.substr(0, pos);
-                        }
-                    }
-
-                    fprintf(stderr, "logcat using %s\n", devname.c_str());
-
-                    int fd = open(devname.c_str(), O_WRONLY | O_CLOEXEC);
-                    if (fd < 0) {
-                        break;
-                    }
-
-                    if (consolePipe) {
-                        // need the trailing '\0'
-                        if (!WriteFully(fd, pipePurpose.c_str(), pipePurpose.size() + 1)) {
-                            close(fd);
-                            return EXIT_FAILURE;
-                        }
-                    }
-                    // close output and error channels, replace with console
-                    dup2(fd, output_fd_.get());
-                    dup2(fd, STDERR_FILENO);
-                    close(fd);
-                }
-                break;
-
-            case 'S':
-                printStatistics = true;
-                break;
-
-            case ':':
-                error(EXIT_FAILURE, 0, "Option '%s' needs an argument.", argv[optind - 1]);
-                break;
-
-            case 'h':
-                show_help();
-                show_format_help();
-                return EXIT_SUCCESS;
-
-            case '?':
-                error(EXIT_FAILURE, 0, "Unknown option '%s'.", argv[optind - 1]);
-                break;
-
-            default:
-                error(EXIT_FAILURE, 0, "Unknown getopt_long() result '%c'.", c);
-        }
-    }
-
-    if (max_count_ && got_t) {
-        error(EXIT_FAILURE, 0, "Cannot use -m (--max-count) and -t together.");
-    }
-    if (print_it_anyways_ && (!regex_ || !max_count_)) {
-        // One day it would be nice if --print -v color and --regex <expr>
-        // could play with each other and show regex highlighted content.
-        fprintf(stderr,
-                "WARNING: "
-                "--print ignored, to be used in combination with\n"
-                "         "
-                "--regex <expr> and --max-count <N>\n");
-        print_it_anyways_ = false;
-    }
-
-    // If no buffers are specified, default to using these buffers.
-    if (id_mask == 0) {
-        id_mask = (1 << LOG_ID_MAIN) | (1 << LOG_ID_SYSTEM) | (1 << LOG_ID_CRASH) |
-                  (1 << LOG_ID_KERNEL);
-    }
-
-    if (log_rotate_size_kb_ != 0 && !output_file_name_) {
-        error(EXIT_FAILURE, 0, "-r requires -f as well.");
-    }
-
-    if (setId != 0) {
-        if (!output_file_name_) {
-            error(EXIT_FAILURE, 0, "--id='%s' requires -f as well.", setId);
-        }
-
-        std::string file_name = StringPrintf("%s.id", output_file_name_);
-        std::string file;
-        bool file_ok = android::base::ReadFileToString(file_name, &file);
-        android::base::WriteStringToFile(setId, file_name, S_IRUSR | S_IWUSR,
-                                         getuid(), getgid());
-        if (!file_ok || !file.compare(setId)) setId = nullptr;
-    }
-
-    if (!hasSetLogFormat) {
-        const char* logFormat = getenv("ANDROID_PRINTF_LOG");
-
-        if (!!logFormat) {
-            for (const auto& arg : Split(logFormat, delimiters)) {
-                int err = SetLogFormat(arg.c_str());
-                // environment should not cause crash of logcat
-                if (err < 0) {
-                    fprintf(stderr, "invalid format in ANDROID_PRINTF_LOG '%s'\n", arg.c_str());
-                }
-                if (err > 0) hasSetLogFormat = true;
-            }
-        }
-        if (!hasSetLogFormat) {
-            SetLogFormat("threadtime");
-        }
-    }
-
-    if (forceFilters.size()) {
-        int err = android_log_addFilterString(logformat_.get(), forceFilters.c_str());
-        if (err < 0) {
-            error(EXIT_FAILURE, 0, "Invalid filter expression in logcat args.");
-        }
-    } else if (argc == optind) {
-        // Add from environment variable
-        const char* env_tags_orig = getenv("ANDROID_LOG_TAGS");
-
-        if (!!env_tags_orig) {
-            int err = android_log_addFilterString(logformat_.get(), env_tags_orig);
-
-            if (err < 0) {
-                error(EXIT_FAILURE, 0, "Invalid filter expression in ANDROID_LOG_TAGS.");
-            }
-        }
-    } else {
-        // Add from commandline
-        for (int i = optind ; i < argc ; i++) {
-            int err = android_log_addFilterString(logformat_.get(), argv[i]);
-            if (err < 0) {
-                error(EXIT_FAILURE, 0, "Invalid filter expression '%s'.", argv[i]);
-            }
-        }
-    }
-
-    if (mode & ANDROID_LOG_PSTORE) {
-        if (output_file_name_) {
-            error(EXIT_FAILURE, 0, "-c is ambiguous with both -f and -L specified.");
-        }
-        if (setLogSize || getLogSize || printStatistics || getPruneList || setPruneList) {
-            error(EXIT_FAILURE, 0, "-L is incompatible with -g/-G, -S, and -p/-P.");
-        }
-        if (clearLog) {
-            unlink("/sys/fs/pstore/pmsg-ramoops-0");
-            return EXIT_SUCCESS;
-        }
-    }
-
-    if (output_file_name_) {
-        if (setLogSize || getLogSize || printStatistics || getPruneList || setPruneList) {
-            error(EXIT_FAILURE, 0, "-f is incompatible with -g/-G, -S, and -p/-P.");
-        }
-
-        if (clearLog || setId) {
-            int max_rotation_count_digits =
-                    max_rotated_logs_ > 0 ? (int)(floor(log10(max_rotated_logs_) + 1)) : 0;
-
-            for (int i = max_rotated_logs_; i >= 0; --i) {
-                std::string file;
-
-                if (!i) {
-                    file = output_file_name_;
-                } else {
-                    file = StringPrintf("%s.%.*d", output_file_name_, max_rotation_count_digits, i);
-                }
-
-                int err = unlink(file.c_str());
-
-                if (err < 0 && errno != ENOENT) {
-                    fprintf(stderr, "failed to delete log file '%s': %s\n", file.c_str(),
-                            strerror(errno));
-                }
-            }
-        }
-
-        if (clearLog) {
-            return EXIT_SUCCESS;
-        }
-    }
-
-    std::unique_ptr<logger_list, decltype(&android_logger_list_free)> logger_list{
-            nullptr, &android_logger_list_free};
-    if (tail_time != log_time::EPOCH) {
-        logger_list.reset(android_logger_list_alloc_time(mode, tail_time, pid));
-    } else {
-        logger_list.reset(android_logger_list_alloc(mode, tail_lines, pid));
-    }
-    // We have three orthogonal actions below to clear, set log size and
-    // get log size. All sharing the same iteration loop.
-    std::vector<std::string> open_device_failures;
-    std::vector<std::string> clear_failures;
-    std::vector<std::string> set_size_failures;
-    std::vector<std::string> get_size_failures;
-
-    for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
-        if (!(id_mask & (1 << i))) continue;
-        const char* buffer_name = android_log_id_to_name(static_cast<log_id_t>(i));
-
-        auto logger = android_logger_open(logger_list.get(), static_cast<log_id_t>(i));
-        if (logger == nullptr) {
-            ReportErrorName(buffer_name, security_buffer_selected, &open_device_failures);
-            continue;
-        }
-
-        if (clearLog) {
-            if (android_logger_clear(logger)) {
-                ReportErrorName(buffer_name, security_buffer_selected, &clear_failures);
-            }
-        }
-
-        if (setLogSize) {
-            if (android_logger_set_log_size(logger, setLogSize)) {
-                ReportErrorName(buffer_name, security_buffer_selected, &set_size_failures);
-            }
-        }
-
-        if (getLogSize) {
-            long size = android_logger_get_log_size(logger);
-            long readable = android_logger_get_log_readable_size(logger);
-            long consumed = android_logger_get_log_consumed_size(logger);
-
-            if (size < 0 || readable < 0) {
-                ReportErrorName(buffer_name, security_buffer_selected, &get_size_failures);
-            } else {
-                auto size_format = format_of_size(size);
-                auto readable_format = format_of_size(readable);
-                auto consumed_format = format_of_size(consumed);
-                std::string str = android::base::StringPrintf(
-                        "%s: ring buffer is %lu %sB (%lu %sB consumed, %lu %sB readable),"
-                        " max entry is %d B, max payload is %d B\n",
-                        buffer_name, size_format.first, size_format.second, consumed_format.first,
-                        consumed_format.second, readable_format.first, readable_format.second,
-                        (int)LOGGER_ENTRY_MAX_LEN, (int)LOGGER_ENTRY_MAX_PAYLOAD);
-                if (!WriteFully(output_fd_, str.data(), str.length())) {
-                    error(EXIT_FAILURE, errno, "Failed to write to output fd");
-                }
-            }
-        }
-    }
-
-    // report any errors in the above loop and exit
-    if (!open_device_failures.empty()) {
-        error(EXIT_FAILURE, 0, "Unable to open log device%s '%s'.",
-              open_device_failures.size() > 1 ? "s" : "", Join(open_device_failures, ",").c_str());
-    }
-    if (!clear_failures.empty()) {
-        error(EXIT_FAILURE, 0, "failed to clear the '%s' log%s.", Join(clear_failures, ",").c_str(),
-              clear_failures.size() > 1 ? "s" : "");
-    }
-    if (!set_size_failures.empty()) {
-        error(EXIT_FAILURE, 0, "failed to set the '%s' log size%s.",
-              Join(set_size_failures, ",").c_str(), set_size_failures.size() > 1 ? "s" : "");
-    }
-    if (!get_size_failures.empty()) {
-        error(EXIT_FAILURE, 0, "failed to get the readable '%s' log size%s.",
-              Join(get_size_failures, ",").c_str(), get_size_failures.size() > 1 ? "s" : "");
-    }
-
-    if (setPruneList) {
-        size_t len = strlen(setPruneList);
-        if (android_logger_set_prune_list(logger_list.get(), setPruneList, len)) {
-            error(EXIT_FAILURE, 0, "Failed to set the prune list.");
-        }
-        return EXIT_SUCCESS;
-    }
-
-    if (printStatistics || getPruneList) {
-        std::string buf(8192, '\0');
-        size_t ret_length = 0;
-        int retry = 32;
-
-        for (; retry >= 0; --retry) {
-            if (getPruneList) {
-                android_logger_get_prune_list(logger_list.get(), buf.data(), buf.size());
-            } else {
-                android_logger_get_statistics(logger_list.get(), buf.data(), buf.size());
-            }
-
-            ret_length = atol(buf.c_str());
-            if (ret_length < 3) {
-                error(EXIT_FAILURE, 0, "Failed to read data.");
-            }
-
-            if (ret_length < buf.size()) {
-                break;
-            }
-
-            buf.resize(ret_length + 1);
-        }
-
-        if (retry < 0) {
-            error(EXIT_FAILURE, 0, "Failed to read data.");
-        }
-
-        buf.resize(ret_length);
-        if (buf.back() == '\f') {
-            buf.pop_back();
-        }
-
-        // Remove the byte count prefix
-        const char* cp = buf.c_str();
-        while (isdigit(*cp)) ++cp;
-        if (*cp == '\n') ++cp;
-
-        size_t len = strlen(cp);
-        if (!WriteFully(output_fd_, cp, len)) {
-            error(EXIT_FAILURE, errno, "Failed to write to output fd");
-        }
-        return EXIT_SUCCESS;
-    }
-
-    if (getLogSize || setLogSize || clearLog) return EXIT_SUCCESS;
-
-    SetupOutputAndSchedulingPolicy(!(mode & ANDROID_LOG_NONBLOCK));
-
-    while (!max_count_ || print_count_ < max_count_) {
-        struct log_msg log_msg;
-        int ret = android_logger_list_read(logger_list.get(), &log_msg);
-        if (!ret) {
-            error(EXIT_FAILURE, 0, R"init(Unexpected EOF!
-
-This means that either the device shut down, logd crashed, or this instance of logcat was unable to read log
-messages as quickly as they were being produced.
-
-If you have enabled significant logging, look into using the -G option to increase log buffer sizes.)init");
-        }
-
-        if (ret < 0) {
-            if (ret == -EAGAIN) break;
-
-            if (ret == -EIO) {
-                error(EXIT_FAILURE, 0, "Unexpected EOF!");
-            }
-            if (ret == -EINVAL) {
-                error(EXIT_FAILURE, 0, "Unexpected length.");
-            }
-            error(EXIT_FAILURE, errno, "Logcat read failure");
-        }
-
-        if (log_msg.id() > LOG_ID_MAX) {
-            error(EXIT_FAILURE, 0, "Unexpected log id (%d) over LOG_ID_MAX (%d).", log_msg.id(),
-                  LOG_ID_MAX);
-        }
-
-        if (!uids.empty() && uids.count(log_msg.entry.uid) == 0) {
-            continue;
-        }
-
-        PrintDividers(log_msg.id(), printDividers);
-
-        if (print_binary_) {
-            if (!WriteFully(output_fd_, &log_msg, log_msg.len())) {
-                error(EXIT_FAILURE, errno, "Failed to write to output fd");
-            }
-        } else {
-            ProcessBuffer(&log_msg);
-        }
-    }
-    return EXIT_SUCCESS;
-}
-
-int main(int argc, char** argv) {
-    Logcat logcat;
-    return logcat.Run(argc, argv);
-}
diff --git a/logcat/logcatd b/logcat/logcatd
deleted file mode 100755
index 5a1415d..0000000
--- a/logcat/logcatd
+++ /dev/null
@@ -1,29 +0,0 @@
-#! /system/bin/sh
-
-# This is primarily meant to be used by logpersist.  This script is run as an init service, which
-# first reads the 'last' logcat to persistent storage with `-L` then run logcat again without
-# `-L` to read the current logcat buffers to persistent storage.
-
-# init sets the umask to 077 for forked processes. logpersist needs to create files that are group
-# readable. So relax the umask to only disallow group wx and world rwx.
-umask 037
-
-has_last="false"
-for arg in "$@"; do
-  if [ "$arg" == "-L" -o "$arg" == "--last" ]; then
-    has_last="true"
-  fi
-done
-
-if [ "$has_last" == "true" ]; then
-  logcat "$@"
-fi
-
-args_without_last=()
-for arg in "$@"; do
-  if [ "$arg" != "-L" -a "$arg" != "--last" ]; then
-    ARGS+=("$arg")
-  fi
-done
-
-exec logcat "${ARGS[@]}"
diff --git a/logcat/logcatd.rc b/logcat/logcatd.rc
deleted file mode 100644
index 64d5500..0000000
--- a/logcat/logcatd.rc
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# init scriptures for logcatd persistent logging.
-#
-# Make sure any property changes are only performed with /data mounted, after
-# post-fs-data state because otherwise behavior is undefined. The exceptions
-# are device adjustments for logcatd service properties (persist.* overrides
-# notwithstanding) for logd.logpersistd.size logd.logpersistd.rotate_kbytes and
-# logd.logpersistd.buffer.
-
-# persist to non-persistent trampolines to permit device properties can be
-# overridden when /data mounts, or during runtime.
-on property:persist.logd.logpersistd.count=*
-    # expect /init to report failure if property empty (default)
-    setprop persist.logd.logpersistd.size ${persist.logd.logpersistd.count}
-
-on property:persist.logd.logpersistd.size=*
-    setprop logd.logpersistd.size ${persist.logd.logpersistd.size}
-
-on property:persist.logd.logpersistd.rotate_kbytes=*
-    setprop logd.logpersistd.rotate_kbytes ${persist.logd.logpersistd.rotate_kbytes}
-
-on property:persist.logd.logpersistd.buffer=*
-    setprop logd.logpersistd.buffer ${persist.logd.logpersistd.buffer}
-
-on property:persist.logd.logpersistd=logcatd
-    setprop logd.logpersistd logcatd
-
-# enable, prep and start logcatd service
-on load_persist_props_action
-    setprop logd.logpersistd.enable true
-
-on property:logd.logpersistd.enable=true && property:logd.logpersistd=logcatd
-    # log group should be able to read persisted logs
-    mkdir /data/misc/logd 0750 logd log
-    start logcatd
-
-# stop logcatd service and clear data
-on property:logd.logpersistd.enable=true && property:logd.logpersistd=clear
-    setprop persist.logd.logpersistd ""
-    stop logcatd
-    # logd for clear of only our files in /data/misc/logd
-    exec - logd log -- /system/bin/logcat -c -f /data/misc/logd/logcat -n ${logd.logpersistd.size:-256}
-    setprop logd.logpersistd ""
-
-# stop logcatd service
-on property:logd.logpersistd=stop
-    setprop persist.logd.logpersistd ""
-    stop logcatd
-    setprop logd.logpersistd ""
-
-on property:logd.logpersistd.enable=false
-    stop logcatd
-
-# logcatd service
-service logcatd /system/bin/logcatd -L -b ${logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r ${logd.logpersistd.rotate_kbytes:-2048} -n ${logd.logpersistd.size:-256} --id=${ro.build.id}
-    class late_start
-    disabled
-    # logd for write to /data/misc/logd, log group for read from log daemon
-    user logd
-    group log
-    writepid /dev/cpuset/system-background/tasks
-    oom_score_adjust -600
diff --git a/logcat/logpersist b/logcat/logpersist
deleted file mode 100755
index 05b46f0..0000000
--- a/logcat/logpersist
+++ /dev/null
@@ -1,178 +0,0 @@
-#! /system/bin/sh
-# logpersist cat, start and stop handlers
-progname="${0##*/}"
-case `getprop ro.debuggable` in
-1) ;;
-*) echo "${progname} - Permission denied"
-   exit 1
-   ;;
-esac
-
-property=persist.logd.logpersistd
-
-case `getprop ${property#persist.}.enable` in
-true) ;;
-*) echo "${progname} - Disabled"
-   exit 1
-   ;;
-esac
-
-log_uid=logd
-log_tag_property=persist.log.tag
-data=/data/misc/logd/logcat
-service=logcatd
-size_default=256
-buffer_default=all
-args="${@}"
-
-size=${size_default}
-buffer=${buffer_default}
-clear=false
-while [ ${#} -gt 0 ]; do
-  case ${1} in
-    -c|--clear) clear=true ;;
-    --size=*) size="${1#--size=}" ;;
-    --rotate-count=*) size="${1#--rotate-count=}" ;;
-    -n|--size|--rotate-count) size="${2}" ; shift ;;
-    --buffer=*) buffer="${1#--buffer=}" ;;
-    -b|--buffer) buffer="${2}" ; shift ;;
-    -h|--help|*)
-      LEAD_SPACE_="`echo ${progname%.*} | tr '[ -~]' ' '`"
-      echo "${progname%.*}.cat             - dump current ${service} logs"
-      echo "${progname%.*}.start [--size=<size_in_kb>] [--buffer=<buffers>] [--clear]"
-      echo "${LEAD_SPACE_}                 - start ${service} service"
-      echo "${progname%.*}.stop [--clear]  - stop ${service} service"
-      case ${1} in
-        -h|--help) exit 0 ;;
-        *) echo ERROR: bad argument ${@} >&2 ; exit 1 ;;
-      esac
-      ;;
-  esac
-  shift
-done
-
-if [ -z "${size}" -o "${size_default}" = "${size}" ]; then
-  unset size
-fi
-if [ -n "${size}" ] &&
-  ! ( [ 0 -lt "${size}" ] && [ 2048 -ge "${size}" ] ) >/dev/null 2>&1; then
-  echo ERROR: Invalid --size ${size} >&2
-  exit 1
-fi
-if [ -z "${buffer}" -o "${buffer_default}" = "${buffer}" ]; then
-  unset buffer
-fi
-if [ -n "${buffer}" ] && ! logcat -b ${buffer} -g >/dev/null 2>&1; then
-  echo ERROR: Invalid --buffer ${buffer} >&2
-  exit 1
-fi
-
-log_tag="`getprop ${log_tag_property}`"
-logd_logpersistd="`getprop ${property}`"
-
-case ${progname} in
-*.cat)
-  if [ -n "${size}${buffer}" -o "true" = "${clear}" ]; then
-    echo WARNING: Can not use --clear, --size or --buffer with ${progname%.*}.cat >&2
-  fi
-  su ${log_uid} ls "${data%/*}" |
-  tr -d '\r' |
-  sort -ru |
-  sed "s#^#${data%/*}/#" |
-  grep "${data}[.]*[0-9]*\$" |
-  su ${log_uid} xargs cat
-  ;;
-*.start)
-  current_buffer="`getprop ${property#persist.}.buffer`"
-  current_size="`getprop ${property#persist.}.size`"
-  if [ "${service}" = "`getprop ${property#persist.}`" ]; then
-    if [ "true" = "${clear}" ]; then
-      setprop ${property#persist.} "clear"
-    elif [ "${buffer}|${size}" != "${current_buffer}|${current_size}" ]; then
-      echo   "ERROR: Changing existing collection parameters from" >&2
-      if [ "${buffer}" != "${current_buffer}" ]; then
-        a=${current_buffer}
-        b=${buffer}
-        if [ -z "${a}" ]; then a="${default_buffer}"; fi
-        if [ -z "${b}" ]; then b="${default_buffer}"; fi
-        echo "           --buffer ${a} to ${b}" >&2
-      fi
-      if [ "${size}" != "${current_size}" ]; then
-        a=${current_size}
-        b=${size}
-        if [ -z "${a}" ]; then a="${default_size}"; fi
-        if [ -z "${b}" ]; then b="${default_size}"; fi
-        echo "           --size ${a} to ${b}" >&2
-      fi
-      echo   "       Are you sure you want to do this?" >&2
-      echo   "       Suggest add --clear to erase data and restart with new settings." >&2
-      echo   "       To blindly override and retain data, ${progname%.*}.stop first." >&2
-      exit 1
-    fi
-  elif [ "true" = "${clear}" ]; then
-    setprop ${property#persist.} "clear"
-  fi
-  if [ -n "${buffer}${current_buffer}" ]; then
-    setprop ${property}.buffer "${buffer}"
-    if [ -z "${buffer}" ]; then
-      # deal with trampoline for empty properties
-      setprop ${property#persist.}.buffer ""
-    fi
-  fi
-  if [ -n "${size}${current_size}" ]; then
-    setprop ${property}.size "${size}"
-    if [ -z "${size}" ]; then
-      # deal with trampoline for empty properties
-      setprop ${property#persist.}.size ""
-    fi
-  fi
-  while [ "clear" = "`getprop ${property#persist.}`" ]; do
-    continue
-  done
-  # Tell Settings that we are back on again if we turned logging off
-  tag="${log_tag#Settings}"
-  if [ X"${log_tag}" != X"${tag}" ]; then
-    echo "WARNING: enabling logd service" >&2
-    setprop ${log_tag_property} "${tag#,}"
-  fi
-  # ${service}.rc does the heavy lifting with the following trigger
-  setprop ${property} ${service}
-  # 20ms done, to permit process feedback check
-  sleep 1
-  getprop ${property#persist.}
-  # also generate an error return code if not found running
-  pgrep -u ${log_uid} ${service%d}
-  ;;
-*.stop)
-  if [ -n "${size}${buffer}" ]; then
-    echo "WARNING: Can not use --size or --buffer with ${progname%.*}.stop" >&2
-  fi
-  if [ "true" = "${clear}" ]; then
-    setprop ${property#persist.} "clear"
-  else
-    setprop ${property#persist.} "stop"
-  fi
-  if [ -n "`getprop ${property#persist.}.buffer`" ]; then
-    setprop ${property}.buffer ""
-    # deal with trampoline for empty properties
-    setprop ${property#persist.}.buffer ""
-  fi
-  if [ -n "`getprop ${property#persist.}.size`" ]; then
-    setprop ${property}.size ""
-    # deal with trampoline for empty properties
-    setprop ${property#persist.}.size ""
-  fi
-  while [ "clear" = "`getprop ${property#persist.}`" ]; do
-    continue
-  done
-  ;;
-*)
-  echo "ERROR: Unexpected command ${0##*/} ${args}" >&2
-  exit 1
-esac
-
-if [ X"${log_tag}" != X"`getprop ${log_tag_property}`" ] ||
-   [ X"${logd_logpersistd}" != X"`getprop ${property}`" ]; then
-  echo "WARNING: killing Settings application to pull in new values" >&2
-  am force-stop com.android.settings
-fi
diff --git a/logcat/tests/Android.bp b/logcat/tests/Android.bp
deleted file mode 100644
index ab84150..0000000
--- a/logcat/tests/Android.bp
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// Copyright (C) 2013-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.
-//
-
-cc_defaults {
-    name: "logcat-tests-defaults",
-    cflags: [
-        "-fstack-protector-all",
-        "-g",
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-        "-fno-builtin",
-    ],
-}
-
-// -----------------------------------------------------------------------------
-// Benchmarks
-// ----------------------------------------------------------------------------
-
-// Build benchmarks for the device. Run with:
-//   adb shell /data/nativetest/logcat-benchmarks/logcat-benchmarks
-cc_benchmark {
-    name: "logcat-benchmarks",
-    defaults: ["logcat-tests-defaults"],
-    srcs: ["logcat_benchmark.cpp"],
-    shared_libs: ["libbase"],
-}
-
-// -----------------------------------------------------------------------------
-// Unit tests.
-// -----------------------------------------------------------------------------
-
-// Build tests for the device (with .so). Run with:
-//   adb shell /data/nativetest/logcat-unit-tests/logcat-unit-tests
-cc_test {
-    name: "logcat-unit-tests",
-    defaults: ["logcat-tests-defaults"],
-    shared_libs: ["libbase"],
-    static_libs: ["liblog"],
-    srcs: [
-        "logcat_test.cpp",
-        "logcatd_test.cpp",
-    ],
-}
diff --git a/logcat/tests/logcat_benchmark.cpp b/logcat/tests/logcat_benchmark.cpp
deleted file mode 100644
index 8d88628..0000000
--- a/logcat/tests/logcat_benchmark.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2013-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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <benchmark/benchmark.h>
-
-static const char begin[] = "--------- beginning of ";
-
-static void BM_logcat_sorted_order(benchmark::State& state) {
-    FILE* fp;
-
-    if (!state.KeepRunning()) return;
-
-    fp = popen(
-        "logcat -v time -b radio -b events -b system -b main -d 2>/dev/null",
-        "r");
-    if (!fp) return;
-
-    class timestamp {
-       private:
-        int month;
-        int day;
-        int hour;
-        int minute;
-        int second;
-        int millisecond;
-        bool ok;
-
-       public:
-        void init(const char* buffer) {
-            ok = false;
-            if (buffer != NULL) {
-                ok = sscanf(buffer, "%d-%d %d:%d:%d.%d ", &month, &day, &hour,
-                            &minute, &second, &millisecond) == 6;
-            }
-        }
-
-        explicit timestamp(const char* buffer) {
-            init(buffer);
-        }
-
-        bool operator<(timestamp& T) {
-            return !ok || !T.ok || (month < T.month) ||
-                   ((month == T.month) &&
-                    ((day < T.day) ||
-                     ((day == T.day) &&
-                      ((hour < T.hour) ||
-                       ((hour == T.hour) &&
-                        ((minute < T.minute) ||
-                         ((minute == T.minute) &&
-                          ((second < T.second) ||
-                           ((second == T.second) &&
-                            (millisecond < T.millisecond))))))))));
-        }
-
-        bool valid(void) {
-            return ok;
-        }
-    } last(NULL);
-
-    char* last_buffer = NULL;
-    char buffer[5120];
-
-    int count = 0;
-    int next_lt_last = 0;
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (!strncmp(begin, buffer, sizeof(begin) - 1)) {
-            continue;
-        }
-        if (!last.valid()) {
-            free(last_buffer);
-            last_buffer = strdup(buffer);
-            last.init(buffer);
-        }
-        timestamp next(buffer);
-        if (next < last) {
-            if (last_buffer) {
-                fprintf(stderr, "<%s", last_buffer);
-            }
-            fprintf(stderr, ">%s", buffer);
-            ++next_lt_last;
-        }
-        if (next.valid()) {
-            free(last_buffer);
-            last_buffer = strdup(buffer);
-            last.init(buffer);
-        }
-        ++count;
-    }
-    free(last_buffer);
-
-    pclose(fp);
-
-    static const int max_ok = 2;
-
-    // Allow few fails, happens with readers active
-    fprintf(stderr, "%s: %d/%d out of order entries\n",
-            (next_lt_last) ? ((next_lt_last <= max_ok) ? "WARNING" : "ERROR")
-                           : "INFO",
-            next_lt_last, count);
-
-    if (next_lt_last > max_ok) {
-        fprintf(stderr, "EXPECT_GE(max_ok=%d, next_lt_last=%d)\n", max_ok,
-                next_lt_last);
-    }
-
-    // sample statistically too small
-    if (count < 100) {
-        fprintf(stderr, "EXPECT_LT(100, count=%d)\n", count);
-    }
-
-    state.KeepRunning();
-}
-BENCHMARK(BM_logcat_sorted_order);
-
-BENCHMARK_MAIN();
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
deleted file mode 100644
index 61aa938..0000000
--- a/logcat/tests/logcat_test.cpp
+++ /dev/null
@@ -1,1833 +0,0 @@
-/*
- * Copyright (C) 2013-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 <ctype.h>
-#include <dirent.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/cdefs.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include <memory>
-#include <regex>
-#include <string>
-
-#include <android-base/file.h>
-#include <android-base/macros.h>
-#include <android-base/parseint.h>
-#include <android-base/stringprintf.h>
-#include <android-base/strings.h>
-#include <gtest/gtest.h>
-#include <log/event_tag_map.h>
-#include <log/log.h>
-#include <log/log_event_list.h>
-
-#ifndef logcat_executable
-#define USING_LOGCAT_EXECUTABLE_DEFAULT
-#define logcat_executable "logcat"
-#endif
-
-#define BIG_BUFFER (5 * 1024)
-
-// rest(), let the logs settle.
-//
-// logd is in a background cgroup and under extreme load can take up to
-// 3 seconds to land a log entry. Under moderate load we can do with 200ms.
-static void rest() {
-    static const useconds_t restPeriod = 200000;
-
-    usleep(restPeriod);
-}
-
-// enhanced version of LOG_FAILURE_RETRY to add support for EAGAIN and
-// non-syscall libs. Since we are only using this in the emergency of
-// a signal to stuff a terminating code into the logs, we will spin rather
-// than try a usleep.
-#define LOG_FAILURE_RETRY(exp)                                               \
-    ({                                                                       \
-        typeof(exp) _rc;                                                     \
-        do {                                                                 \
-            _rc = (exp);                                                     \
-        } while (((_rc == -1) && ((errno == EINTR) || (errno == EAGAIN))) || \
-                 (_rc == -EINTR) || (_rc == -EAGAIN));                       \
-        _rc;                                                                 \
-    })
-
-static const char begin[] = "--------- beginning of ";
-
-TEST(logcat, buckets) {
-    FILE* fp;
-
-#undef LOG_TAG
-#define LOG_TAG "inject.buckets"
-    // inject messages into radio, system, main and events buffers to
-    // ensure that we see all the begin[] bucket messages.
-    RLOGE(logcat_executable);
-    SLOGE(logcat_executable);
-    ALOGE(logcat_executable);
-    __android_log_bswrite(0, logcat_executable ".inject.buckets");
-    rest();
-
-    ASSERT_TRUE(NULL != (fp = popen(logcat_executable
-                                    " -b radio -b events -b system -b main -d 2>/dev/null",
-                                    "r")));
-
-    char buffer[BIG_BUFFER];
-
-    int ids = 0;
-    int count = 0;
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (!strncmp(begin, buffer, sizeof(begin) - 1)) {
-            while (char* cp = strrchr(buffer, '\n')) {
-                *cp = '\0';
-            }
-            log_id_t id = android_name_to_log_id(buffer + sizeof(begin) - 1);
-            ids |= 1 << id;
-            ++count;
-        }
-    }
-
-    pclose(fp);
-
-    EXPECT_EQ(ids, 15);
-
-    EXPECT_EQ(count, 4);
-}
-
-TEST(logcat, event_tag_filter) {
-    FILE* fp;
-
-#undef LOG_TAG
-#define LOG_TAG "inject.filter"
-    // inject messages into radio, system and main buffers
-    // with our unique log tag to test logcat filter.
-    RLOGE(logcat_executable);
-    SLOGE(logcat_executable);
-    ALOGE(logcat_executable);
-    rest();
-
-    std::string command = android::base::StringPrintf(
-        logcat_executable
-        " -b radio -b system -b main --pid=%d -d -s inject.filter 2>/dev/null",
-        getpid());
-    ASSERT_TRUE(NULL != (fp = popen(command.c_str(), "r")));
-
-    char buffer[BIG_BUFFER];
-
-    int count = 0;
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (strncmp(begin, buffer, sizeof(begin) - 1)) ++count;
-    }
-
-    pclose(fp);
-
-    // logcat, liblogcat and logcatd test instances result in the progression
-    // of 3, 6 and 9 for our counts as each round is performed.
-    EXPECT_GE(count, 3);
-    EXPECT_LE(count, 9);
-    EXPECT_EQ(count % 3, 0);
-}
-
-// If there is not enough background noise in the logs, then spam the logs to
-// permit tail checking so that the tests can progress.
-static size_t inject(ssize_t count) {
-    if (count <= 0) return 0;
-
-    static const size_t retry = 4;
-    size_t errors = retry;
-    size_t num = 0;
-    for (;;) {
-        log_time ts(CLOCK_MONOTONIC);
-        if (__android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)) >= 0) {
-            if (++num >= (size_t)count) {
-                // let data settle end-to-end
-                sleep(3);
-                return num;
-            }
-            errors = retry;
-            usleep(100);  // ~32 per timer tick, we are a spammer regardless
-        } else if (--errors <= 0) {
-            return num;
-        }
-    }
-    // NOTREACH
-    return num;
-}
-
-TEST(logcat, year) {
-    int count;
-    int tries = 3;  // in case run too soon after system start or buffer clear
-
-    do {
-        FILE* fp;
-
-        char needle[32];
-        time_t now;
-        time(&now);
-        struct tm* ptm;
-#if !defined(_WIN32)
-        struct tm tmBuf;
-        ptm = localtime_r(&now, &tmBuf);
-#else
-        ptm = localtime(&&now);
-#endif
-        strftime(needle, sizeof(needle), "[ %Y-", ptm);
-
-        ASSERT_TRUE(NULL !=
-                    (fp = popen(logcat_executable " -v long -v year -b all -t 3 2>/dev/null", "r")));
-
-        char buffer[BIG_BUFFER];
-
-        count = 0;
-
-        while (fgets(buffer, sizeof(buffer), fp)) {
-            if (!strncmp(buffer, needle, strlen(needle))) {
-                ++count;
-            }
-        }
-        pclose(fp);
-
-    } while ((count < 3) && --tries && inject(3 - count));
-
-    ASSERT_EQ(3, count);
-}
-
-// Return a pointer to each null terminated -v long time field.
-static char* fgetLongTime(char* buffer, size_t buflen, FILE* fp) {
-    while (fgets(buffer, buflen, fp)) {
-        char* cp = buffer;
-        if (*cp != '[') {
-            continue;
-        }
-        while (*++cp == ' ') {
-            ;
-        }
-        char* ep = cp;
-        while (isdigit(*ep)) {
-            ++ep;
-        }
-        if ((*ep != '-') && (*ep != '.')) {
-            continue;
-        }
-        // Find PID field.  Look for ': ' or ':[0-9][0-9][0-9]'
-        while (((ep = strchr(ep, ':'))) && (*++ep != ' ')) {
-            if (isdigit(ep[0]) && isdigit(ep[1]) && isdigit(ep[2])) break;
-        }
-        if (!ep) {
-            continue;
-        }
-        static const size_t pid_field_width = 7;
-        ep -= pid_field_width;
-        *ep = '\0';
-        return cp;
-    }
-    return NULL;
-}
-
-TEST(logcat, tz) {
-    int tries = 4;  // in case run too soon after system start or buffer clear
-    int count;
-
-    do {
-        FILE* fp;
-
-        ASSERT_TRUE(NULL != (fp = popen(logcat_executable
-                                        " -v long -v America/Los_Angeles -b all -t 3 2>/dev/null",
-                                        "r")));
-
-        char buffer[BIG_BUFFER];
-
-        count = 0;
-
-        while (fgetLongTime(buffer, sizeof(buffer), fp)) {
-            if (strstr(buffer, " -0700") || strstr(buffer, " -0800")) {
-                ++count;
-            } else {
-                fprintf(stderr, "ts=\"%s\"\n", buffer + 2);
-            }
-        }
-
-        pclose(fp);
-
-    } while ((count < 3) && --tries && inject(3 - count));
-
-    ASSERT_EQ(3, count);
-}
-
-TEST(logcat, ntz) {
-    FILE* fp;
-
-    ASSERT_TRUE(NULL !=
-                (fp = popen(logcat_executable
-                            " -v long -v America/Los_Angeles -v zone -b all -t 3 2>/dev/null",
-                            "r")));
-
-    char buffer[BIG_BUFFER];
-
-    int count = 0;
-
-    while (fgetLongTime(buffer, sizeof(buffer), fp)) {
-        if (strstr(buffer, " -0700") || strstr(buffer, " -0800")) {
-            ++count;
-        }
-    }
-
-    pclose(fp);
-
-    ASSERT_EQ(0, count);
-}
-
-static void do_tail(int num) {
-    int tries = 4;  // in case run too soon after system start or buffer clear
-    int count;
-
-    if (num > 10) ++tries;
-    if (num > 100) ++tries;
-    do {
-        char buffer[BIG_BUFFER];
-
-        snprintf(buffer, sizeof(buffer),
-                 "ANDROID_PRINTF_LOG=long logcat -b all -t %d 2>/dev/null", num);
-
-        FILE* fp;
-        ASSERT_TRUE(NULL != (fp = popen(buffer, "r")));
-
-        count = 0;
-
-        while (fgetLongTime(buffer, sizeof(buffer), fp)) {
-            ++count;
-        }
-
-        pclose(fp);
-
-    } while ((count < num) && --tries && inject(num - count));
-
-    ASSERT_EQ(num, count);
-}
-
-TEST(logcat, tail_3) {
-    do_tail(3);
-}
-
-TEST(logcat, tail_10) {
-    do_tail(10);
-}
-
-TEST(logcat, tail_100) {
-    do_tail(100);
-}
-
-TEST(logcat, tail_1000) {
-    do_tail(1000);
-}
-
-static void do_tail_time(const char* cmd) {
-    FILE* fp;
-    int count;
-    char buffer[BIG_BUFFER];
-    char* last_timestamp = NULL;
-    // Hard to predict 100% if first (overlap) or second line will match.
-    // -v nsec will in a substantial majority be the second line.
-    char* first_timestamp = NULL;
-    char* second_timestamp = NULL;
-    char* input;
-
-    int tries = 4;  // in case run too soon after system start or buffer clear
-
-    do {
-        snprintf(buffer, sizeof(buffer), "%s -t 10 2>&1", cmd);
-        ASSERT_TRUE(NULL != (fp = popen(buffer, "r")));
-        count = 0;
-
-        while ((input = fgetLongTime(buffer, sizeof(buffer), fp))) {
-            ++count;
-            if (!first_timestamp) {
-                first_timestamp = strdup(input);
-            } else if (!second_timestamp) {
-                second_timestamp = strdup(input);
-            }
-            free(last_timestamp);
-            last_timestamp = strdup(input);
-        }
-        pclose(fp);
-
-    } while ((count < 10) && --tries && inject(10 - count));
-
-    EXPECT_EQ(count, 10);  // We want _some_ history, too small, falses below
-    EXPECT_TRUE(last_timestamp != NULL);
-    EXPECT_TRUE(first_timestamp != NULL);
-    EXPECT_TRUE(second_timestamp != NULL);
-
-    snprintf(buffer, sizeof(buffer), "%s -t '%s' 2>&1", cmd, first_timestamp);
-    ASSERT_TRUE(NULL != (fp = popen(buffer, "r")));
-
-    int second_count = 0;
-    int last_timestamp_count = -1;
-
-    --count;  // One less unless we match the first_timestamp
-    bool found = false;
-    while ((input = fgetLongTime(buffer, sizeof(buffer), fp))) {
-        ++second_count;
-        // We want to highlight if we skip to the next entry.
-        // WAI, if the time in logd is *exactly*
-        // XX-XX XX:XX:XX.XXXXXX000 (usec) or XX-XX XX:XX:XX.XXX000000
-        // this can happen, but it should not happen with nsec.
-        // We can make this WAI behavior happen 1000 times less
-        // frequently if the caller does not use the -v usec flag,
-        // but always the second (always skip) if they use the
-        // (undocumented) -v nsec flag.
-        if (first_timestamp) {
-            found = !strcmp(input, first_timestamp);
-            if (found) {
-                ++count;
-                GTEST_LOG_(INFO)
-                    << "input = first(" << first_timestamp << ")\n";
-            }
-            free(first_timestamp);
-            first_timestamp = NULL;
-        }
-        if (second_timestamp) {
-            found = found || !strcmp(input, second_timestamp);
-            if (!found) {
-                GTEST_LOG_(INFO) << "input(" << input << ") != second("
-                                 << second_timestamp << ")\n";
-            }
-            free(second_timestamp);
-            second_timestamp = NULL;
-        }
-        if (!strcmp(input, last_timestamp)) {
-            last_timestamp_count = second_count;
-        }
-    }
-    pclose(fp);
-
-    EXPECT_TRUE(found);
-    if (!found) {
-        if (first_timestamp) {
-            GTEST_LOG_(INFO) << "first = " << first_timestamp << "\n";
-        }
-        if (second_timestamp) {
-            GTEST_LOG_(INFO) << "second = " << second_timestamp << "\n";
-        }
-        if (last_timestamp) {
-            GTEST_LOG_(INFO) << "last = " << last_timestamp << "\n";
-        }
-    }
-    free(last_timestamp);
-    last_timestamp = NULL;
-    free(first_timestamp);
-    free(second_timestamp);
-
-    EXPECT_TRUE(first_timestamp == NULL);
-    EXPECT_TRUE(second_timestamp == NULL);
-    EXPECT_LE(count, second_count);
-    EXPECT_LE(count, last_timestamp_count);
-}
-
-TEST(logcat, tail_time) {
-    do_tail_time(logcat_executable " -v long -v nsec -b all");
-}
-
-TEST(logcat, tail_time_epoch) {
-    do_tail_time(logcat_executable " -v long -v nsec -v epoch -b all");
-}
-
-TEST(logcat, End_to_End) {
-    pid_t pid = getpid();
-
-    log_time ts(CLOCK_MONOTONIC);
-
-    ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-
-    FILE* fp;
-    ASSERT_TRUE(NULL !=
-                (fp = popen(logcat_executable " -v brief -b events -t 100 2>/dev/null", "r")));
-
-    char buffer[BIG_BUFFER];
-
-    int count = 0;
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        int p;
-        unsigned long long t;
-
-        if ((2 != sscanf(buffer, "I/[0]     ( %d): %llu", &p, &t)) ||
-            (p != pid)) {
-            continue;
-        }
-
-        log_time* tx = reinterpret_cast<log_time*>(&t);
-        if (ts == *tx) {
-            ++count;
-        }
-    }
-
-    pclose(fp);
-
-    ASSERT_EQ(1, count);
-}
-
-TEST(logcat, End_to_End_multitude) {
-    pid_t pid = getpid();
-
-    log_time ts(CLOCK_MONOTONIC);
-
-    ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-
-    FILE* fp[256];  // does this count as a multitude!
-    memset(fp, 0, sizeof(fp));
-    size_t num = 0;
-    do {
-        EXPECT_TRUE(NULL != (fp[num] = popen(logcat_executable " -v brief -b events -t 100", "r")));
-        if (!fp[num]) {
-            fprintf(stderr,
-                    "WARNING: limiting to %zu simultaneous logcat operations\n",
-                    num);
-            break;
-        }
-    } while (++num < sizeof(fp) / sizeof(fp[0]));
-
-    char buffer[BIG_BUFFER];
-
-    size_t count = 0;
-
-    for (size_t idx = 0; idx < sizeof(fp) / sizeof(fp[0]); ++idx) {
-        if (!fp[idx]) break;
-        while (fgets(buffer, sizeof(buffer), fp[idx])) {
-            int p;
-            unsigned long long t;
-
-            if ((2 != sscanf(buffer, "I/[0]     ( %d): %llu", &p, &t)) ||
-                (p != pid)) {
-                continue;
-            }
-
-            log_time* tx = reinterpret_cast<log_time*>(&t);
-            if (ts == *tx) {
-                ++count;
-            }
-        }
-
-        pclose(fp[idx]);
-    }
-
-    ASSERT_EQ(num, count);
-}
-
-static int get_groups(const char* cmd) {
-    FILE* fp;
-
-    // NB: crash log only available in user space
-    EXPECT_TRUE(NULL != (fp = popen(cmd, "r")));
-
-    if (fp == NULL) {
-        return 0;
-    }
-
-    char buffer[BIG_BUFFER];
-
-    int count = 0;
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        int size, consumed, max, payload;
-        char size_mult[4], consumed_mult[4];
-        long full_size, full_consumed;
-
-        size = consumed = max = payload = 0;
-        // NB: crash log can be very small, not hit a Kb of consumed space
-        //     doubly lucky we are not including it.
-        EXPECT_EQ(6, sscanf(buffer,
-                            "%*s ring buffer is %d %3s (%d %3s consumed),"
-                            " max entry is %d B, max payload is %d B",
-                            &size, size_mult, &consumed, consumed_mult, &max, &payload))
-                << "Parse error on: " << buffer;
-        full_size = size;
-        switch (size_mult[0]) {
-            case 'G':
-                full_size *= 1024;
-                FALLTHROUGH_INTENDED;
-            case 'M':
-                full_size *= 1024;
-                FALLTHROUGH_INTENDED;
-            case 'K':
-                full_size *= 1024;
-                FALLTHROUGH_INTENDED;
-            case 'B':
-                break;
-            default:
-                ADD_FAILURE() << "Parse error on multiplier: " << size_mult;
-        }
-        full_consumed = consumed;
-        switch (consumed_mult[0]) {
-            case 'G':
-                full_consumed *= 1024;
-                FALLTHROUGH_INTENDED;
-            case 'M':
-                full_consumed *= 1024;
-                FALLTHROUGH_INTENDED;
-            case 'K':
-                full_consumed *= 1024;
-                FALLTHROUGH_INTENDED;
-            case 'B':
-                break;
-            default:
-                ADD_FAILURE() << "Parse error on multiplier: " << consumed_mult;
-        }
-        EXPECT_GT((full_size * 9) / 4, full_consumed);
-        EXPECT_GT(full_size, max);
-        EXPECT_GT(max, payload);
-
-        if ((((full_size * 9) / 4) >= full_consumed) && (full_size > max) &&
-            (max > payload)) {
-            ++count;
-        }
-    }
-
-    pclose(fp);
-
-    return count;
-}
-
-TEST(logcat, get_size) {
-    ASSERT_EQ(4, get_groups(logcat_executable
-                            " -v brief -b radio -b events -b system -b "
-                            "main -g 2>/dev/null"));
-}
-
-// duplicate test for get_size, but use comma-separated list of buffers
-TEST(logcat, multiple_buffer) {
-    ASSERT_EQ(
-        4, get_groups(logcat_executable
-                      " -v brief -b radio,events,system,main -g 2>/dev/null"));
-}
-
-TEST(logcat, bad_buffer) {
-    ASSERT_EQ(0,
-              get_groups(
-                  logcat_executable
-                  " -v brief -b radio,events,bogo,system,main -g 2>/dev/null"));
-}
-
-#ifndef logcat
-static void caught_blocking(int signum) {
-    unsigned long long v = 0xDEADBEEFA55A0000ULL;
-
-    v += getpid() & 0xFFFF;
-    if (signum == 0) ++v;
-
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-}
-
-TEST(logcat, blocking) {
-    FILE* fp;
-    unsigned long long v = 0xDEADBEEFA55F0000ULL;
-
-    pid_t pid = getpid();
-
-    v += pid & 0xFFFF;
-
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-
-    v &= 0xFFFFFFFFFFFAFFFFULL;
-
-    ASSERT_TRUE(
-        NULL !=
-        (fp = popen("( trap exit HUP QUIT INT PIPE KILL ; sleep 6; echo DONE )&"
-                    " logcat -v brief -b events 2>&1",
-                    "r")));
-
-    char buffer[BIG_BUFFER];
-
-    int count = 0;
-
-    int signals = 0;
-
-    signal(SIGALRM, caught_blocking);
-    alarm(2);
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (!strncmp(buffer, "DONE", 4)) {
-            break;
-        }
-
-        ++count;
-
-        int p;
-        unsigned long long l;
-
-        if ((2 != sscanf(buffer, "I/[0] ( %u): %lld", &p, &l)) || (p != pid)) {
-            continue;
-        }
-
-        if (l == v) {
-            ++signals;
-            break;
-        }
-    }
-    alarm(0);
-    signal(SIGALRM, SIG_DFL);
-
-    // Generate SIGPIPE
-    fclose(fp);
-    caught_blocking(0);
-
-    pclose(fp);
-
-    EXPECT_GE(count, 2);
-
-    EXPECT_EQ(signals, 1);
-}
-
-static void caught_blocking_tail(int signum) {
-    unsigned long long v = 0xA55ADEADBEEF0000ULL;
-
-    v += getpid() & 0xFFFF;
-    if (signum == 0) ++v;
-
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-}
-
-TEST(logcat, blocking_tail) {
-    FILE* fp;
-    unsigned long long v = 0xA55FDEADBEEF0000ULL;
-
-    pid_t pid = getpid();
-
-    v += pid & 0xFFFF;
-
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-
-    v &= 0xFFFAFFFFFFFFFFFFULL;
-
-    ASSERT_TRUE(
-        NULL !=
-        (fp = popen("( trap exit HUP QUIT INT PIPE KILL ; sleep 6; echo DONE )&"
-                    " logcat -v brief -b events -T 5 2>&1",
-                    "r")));
-
-    char buffer[BIG_BUFFER];
-
-    int count = 0;
-
-    int signals = 0;
-
-    signal(SIGALRM, caught_blocking_tail);
-    alarm(2);
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (!strncmp(buffer, "DONE", 4)) {
-            break;
-        }
-
-        ++count;
-
-        int p;
-        unsigned long long l;
-
-        if ((2 != sscanf(buffer, "I/[0] ( %u): %lld", &p, &l)) || (p != pid)) {
-            continue;
-        }
-
-        if (l == v) {
-            if (count >= 5) {
-                ++signals;
-            }
-            break;
-        }
-    }
-    alarm(0);
-    signal(SIGALRM, SIG_DFL);
-
-    // Generate SIGPIPE
-    fclose(fp);
-    caught_blocking_tail(0);
-
-    pclose(fp);
-
-    EXPECT_GE(count, 2);
-
-    EXPECT_EQ(signals, 1);
-}
-#endif
-
-// meant to be handed to ASSERT_FALSE / EXPECT_FALSE to expand the message
-static testing::AssertionResult IsFalse(int ret, const char* command) {
-    return ret ? (testing::AssertionSuccess()
-                  << "ret=" << ret << " command=\"" << command << "\"")
-               : testing::AssertionFailure();
-}
-
-TEST(logcat, logrotate) {
-    static const char form[] = "/data/local/tmp/logcat.logrotate.XXXXXX";
-    char buf[sizeof(form)];
-    ASSERT_TRUE(NULL != mkdtemp(strcpy(buf, form)));
-
-    static const char comm[] = logcat_executable
-        " -b radio -b events -b system -b main"
-        " -d -f %s/log.txt -n 7 -r 1";
-    char command[sizeof(buf) + sizeof(comm)];
-    snprintf(command, sizeof(command), comm, buf);
-
-    int ret;
-    EXPECT_FALSE(IsFalse(ret = system(command), command));
-    if (!ret) {
-        snprintf(command, sizeof(command), "ls -s %s 2>/dev/null", buf);
-
-        FILE* fp;
-        EXPECT_TRUE(NULL != (fp = popen(command, "r")));
-        if (fp) {
-            char buffer[BIG_BUFFER];
-            int count = 0;
-
-            while (fgets(buffer, sizeof(buffer), fp)) {
-                static const char total[] = "total ";
-                int num;
-                char c;
-
-                if ((2 == sscanf(buffer, "%d log.tx%c", &num, &c)) &&
-                    (num <= 40)) {
-                    ++count;
-                } else if (strncmp(buffer, total, sizeof(total) - 1)) {
-                    fprintf(stderr, "WARNING: Parse error: %s", buffer);
-                }
-            }
-            pclose(fp);
-            if ((count != 7) && (count != 8)) {
-                fprintf(stderr, "count=%d\n", count);
-            }
-            EXPECT_TRUE(count == 7 || count == 8);
-        }
-    }
-    snprintf(command, sizeof(command), "rm -rf %s", buf);
-    EXPECT_FALSE(IsFalse(system(command), command));
-}
-
-TEST(logcat, logrotate_suffix) {
-    static const char tmp_out_dir_form[] =
-        "/data/local/tmp/logcat.logrotate.XXXXXX";
-    char tmp_out_dir[sizeof(tmp_out_dir_form)];
-    ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form)));
-
-    static const char logcat_cmd[] = logcat_executable
-        " -b radio -b events -b system -b main"
-        " -d -f %s/log.txt -n 10 -r 1";
-    char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd)];
-    snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir);
-
-    int ret;
-    EXPECT_FALSE(IsFalse(ret = system(command), command));
-    if (!ret) {
-        snprintf(command, sizeof(command), "ls %s 2>/dev/null", tmp_out_dir);
-
-        FILE* fp;
-        EXPECT_TRUE(NULL != (fp = popen(command, "r")));
-        char buffer[BIG_BUFFER];
-        int log_file_count = 0;
-
-        while (fgets(buffer, sizeof(buffer), fp)) {
-            static const char rotated_log_filename_prefix[] = "log.txt.";
-            static const size_t rotated_log_filename_prefix_len =
-                strlen(rotated_log_filename_prefix);
-            static const char log_filename[] = "log.txt";
-
-            if (!strncmp(buffer, rotated_log_filename_prefix,
-                         rotated_log_filename_prefix_len)) {
-                // Rotated file should have form log.txt.##
-                char* rotated_log_filename_suffix =
-                    buffer + rotated_log_filename_prefix_len;
-                char* endptr;
-                const long int suffix_value =
-                    strtol(rotated_log_filename_suffix, &endptr, 10);
-                EXPECT_EQ(rotated_log_filename_suffix + 2, endptr);
-                EXPECT_LE(suffix_value, 10);
-                EXPECT_GT(suffix_value, 0);
-                ++log_file_count;
-                continue;
-            }
-
-            if (!strncmp(buffer, log_filename, strlen(log_filename))) {
-                ++log_file_count;
-                continue;
-            }
-
-            fprintf(stderr, "ERROR: Unexpected file: %s", buffer);
-            ADD_FAILURE();
-        }
-        pclose(fp);
-        EXPECT_EQ(log_file_count, 11);
-    }
-    snprintf(command, sizeof(command), "rm -rf %s", tmp_out_dir);
-    EXPECT_FALSE(IsFalse(system(command), command));
-}
-
-TEST(logcat, logrotate_continue) {
-    static const char tmp_out_dir_form[] =
-        "/data/local/tmp/logcat.logrotate.XXXXXX";
-    char tmp_out_dir[sizeof(tmp_out_dir_form)];
-    ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form)));
-
-    static const char log_filename[] = "log.txt";
-    static const char logcat_cmd[] =
-        logcat_executable " -b all -v nsec -d -f %s/%s -n 256 -r 1024";
-    static const char cleanup_cmd[] = "rm -rf %s";
-    char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd) + sizeof(log_filename)];
-    snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename);
-
-    int ret;
-    EXPECT_FALSE(IsFalse(ret = system(command), command));
-    if (ret) {
-        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-        EXPECT_FALSE(IsFalse(system(command), command));
-        return;
-    }
-    FILE* fp;
-    snprintf(command, sizeof(command), "%s/%s", tmp_out_dir, log_filename);
-    EXPECT_TRUE(NULL != ((fp = fopen(command, "r"))));
-    if (!fp) {
-        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-        EXPECT_FALSE(IsFalse(system(command), command));
-        return;
-    }
-    char* line = NULL;
-    char* last_line =
-        NULL;  // this line is allowed to stutter, one-line overlap
-    char* second_last_line = NULL;  // should never stutter
-    char* first_line = NULL;        // help diagnose failure?
-    size_t len = 0;
-    while (getline(&line, &len, fp) != -1) {
-        if (!first_line) {
-            first_line = line;
-            line = NULL;
-            continue;
-        }
-        free(second_last_line);
-        second_last_line = last_line;
-        last_line = line;
-        line = NULL;
-    }
-    fclose(fp);
-    free(line);
-    if (second_last_line == NULL) {
-        fprintf(stderr, "No second to last line, using last, test may fail\n");
-        second_last_line = last_line;
-        last_line = NULL;
-    }
-    free(last_line);
-    EXPECT_TRUE(NULL != second_last_line);
-    if (!second_last_line) {
-        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-        EXPECT_FALSE(IsFalse(system(command), command));
-        free(first_line);
-        return;
-    }
-    // re-run the command, it should only add a few lines more content if it
-    // continues where it left off.
-    snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename);
-    EXPECT_FALSE(IsFalse(ret = system(command), command));
-    if (ret) {
-        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-        EXPECT_FALSE(IsFalse(system(command), command));
-        free(second_last_line);
-        free(first_line);
-        return;
-    }
-    std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir),
-                                                  closedir);
-    EXPECT_NE(nullptr, dir);
-    if (!dir) {
-        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-        EXPECT_FALSE(IsFalse(system(command), command));
-        free(second_last_line);
-        free(first_line);
-        return;
-    }
-    struct dirent* entry;
-    unsigned count = 0;
-    while ((entry = readdir(dir.get()))) {
-        if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) {
-            continue;
-        }
-        snprintf(command, sizeof(command), "%s/%s", tmp_out_dir, entry->d_name);
-        EXPECT_TRUE(NULL != ((fp = fopen(command, "r"))));
-        if (!fp) {
-            fprintf(stderr, "%s ?\n", command);
-            continue;
-        }
-        line = NULL;
-        size_t number = 0;
-        while (getline(&line, &len, fp) != -1) {
-            ++number;
-            if (!strcmp(line, second_last_line)) {
-                EXPECT_TRUE(++count <= 1);
-                fprintf(stderr, "%s(%zu):\n", entry->d_name, number);
-            }
-        }
-        fclose(fp);
-        free(line);
-        unlink(command);
-    }
-    if (count > 1) {
-        char* brk = strpbrk(second_last_line, "\r\n");
-        if (!brk) brk = second_last_line + strlen(second_last_line);
-        fprintf(stderr, "\"%.*s\" occurred %u times\n",
-                (int)(brk - second_last_line), second_last_line, count);
-        if (first_line) {
-            brk = strpbrk(first_line, "\r\n");
-            if (!brk) brk = first_line + strlen(first_line);
-            fprintf(stderr, "\"%.*s\" was first line, fault?\n",
-                    (int)(brk - first_line), first_line);
-        }
-    }
-    free(second_last_line);
-    free(first_line);
-
-    snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-    EXPECT_FALSE(IsFalse(system(command), command));
-}
-
-TEST(logcat, logrotate_clear) {
-    static const char tmp_out_dir_form[] =
-        "/data/local/tmp/logcat.logrotate.XXXXXX";
-    char tmp_out_dir[sizeof(tmp_out_dir_form)];
-    ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form)));
-
-    static const char log_filename[] = "log.txt";
-    static const unsigned num_val = 32;
-    static const char logcat_cmd[] =
-        logcat_executable " -b all -d -f %s/%s -n %d -r 1";
-    static const char clear_cmd[] = " -c";
-    static const char cleanup_cmd[] = "rm -rf %s";
-    char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd) +
-                 sizeof(log_filename) + sizeof(clear_cmd) + 32];
-
-    // Run command with all data
-    {
-        snprintf(command, sizeof(command) - sizeof(clear_cmd), logcat_cmd,
-                 tmp_out_dir, log_filename, num_val);
-
-        int ret;
-        EXPECT_FALSE(IsFalse(ret = system(command), command));
-        if (ret) {
-            snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-            EXPECT_FALSE(IsFalse(system(command), command));
-            return;
-        }
-        std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir),
-                                                      closedir);
-        EXPECT_NE(nullptr, dir);
-        if (!dir) {
-            snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-            EXPECT_FALSE(IsFalse(system(command), command));
-            return;
-        }
-        struct dirent* entry;
-        unsigned count = 0;
-        while ((entry = readdir(dir.get()))) {
-            if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) {
-                continue;
-            }
-            ++count;
-        }
-        EXPECT_EQ(count, num_val + 1);
-    }
-
-    {
-        // Now with -c option tacked onto the end
-        strcat(command, clear_cmd);
-
-        int ret;
-        EXPECT_FALSE(IsFalse(ret = system(command), command));
-        if (ret) {
-            snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-            EXPECT_FALSE(system(command));
-            EXPECT_FALSE(IsFalse(system(command), command));
-            return;
-        }
-        std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir),
-                                                      closedir);
-        EXPECT_NE(nullptr, dir);
-        if (!dir) {
-            snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-            EXPECT_FALSE(IsFalse(system(command), command));
-            return;
-        }
-        struct dirent* entry;
-        unsigned count = 0;
-        while ((entry = readdir(dir.get()))) {
-            if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) {
-                continue;
-            }
-            fprintf(stderr, "Found %s/%s!!!\n", tmp_out_dir, entry->d_name);
-            ++count;
-        }
-        EXPECT_EQ(count, 0U);
-    }
-
-    snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-    EXPECT_FALSE(IsFalse(system(command), command));
-}
-
-static int logrotate_count_id(const char* logcat_cmd, const char* tmp_out_dir) {
-    static const char log_filename[] = "log.txt";
-    char command[strlen(tmp_out_dir) + strlen(logcat_cmd) +
-                 strlen(log_filename) + 32];
-
-    snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename);
-
-    int ret = system(command);
-    if (ret) {
-        fprintf(stderr, "system(\"%s\")=%d", command, ret);
-        return -1;
-    }
-    std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir),
-                                                  closedir);
-    if (!dir) {
-        fprintf(stderr, "opendir(\"%s\") failed", tmp_out_dir);
-        return -1;
-    }
-    struct dirent* entry;
-    int count = 0;
-    while ((entry = readdir(dir.get()))) {
-        if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) {
-            continue;
-        }
-        ++count;
-    }
-    return count;
-}
-
-TEST(logcat, logrotate_id) {
-    static const char logcat_cmd[] =
-        logcat_executable " -b all -d -f %s/%s -n 32 -r 1 --id=test";
-    static const char logcat_short_cmd[] =
-        logcat_executable " -b all -t 10 -f %s/%s -n 32 -r 1 --id=test";
-    static const char tmp_out_dir_form[] =
-        "/data/local/tmp/logcat.logrotate.XXXXXX";
-    static const char log_filename[] = "log.txt";
-    char tmp_out_dir[strlen(tmp_out_dir_form) + 1];
-    ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form)));
-
-    EXPECT_EQ(logrotate_count_id(logcat_cmd, tmp_out_dir), 34);
-    EXPECT_EQ(logrotate_count_id(logcat_short_cmd, tmp_out_dir), 34);
-
-    char id_file[strlen(tmp_out_dir_form) + strlen(log_filename) + 5];
-    snprintf(id_file, sizeof(id_file), "%s/%s.id", tmp_out_dir, log_filename);
-    if (getuid() != 0) {
-        chmod(id_file, 0);
-        EXPECT_EQ(logrotate_count_id(logcat_short_cmd, tmp_out_dir), 34);
-    }
-    unlink(id_file);
-    EXPECT_EQ(logrotate_count_id(logcat_short_cmd, tmp_out_dir), 34);
-
-    FILE* fp = fopen(id_file, "w");
-    if (fp) {
-        fprintf(fp, "not_a_test");
-        fclose(fp);
-    }
-    if (getuid() != 0) {
-        chmod(id_file,
-              0);  // API to preserve content even with signature change
-        ASSERT_EQ(34, logrotate_count_id(logcat_short_cmd, tmp_out_dir));
-        chmod(id_file, 0600);
-    }
-
-    int new_signature;
-    EXPECT_GE(
-        (new_signature = logrotate_count_id(logcat_short_cmd, tmp_out_dir)), 2);
-    EXPECT_LT(new_signature, 34);
-
-    static const char cleanup_cmd[] = "rm -rf %s";
-    char command[strlen(cleanup_cmd) + strlen(tmp_out_dir_form)];
-    snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
-    EXPECT_FALSE(IsFalse(system(command), command));
-}
-
-TEST(logcat, logrotate_nodir) {
-    // expect logcat to error out on writing content and not exit(0) for nodir
-    static const char command[] = logcat_executable
-        " -b all -d"
-        " -f /das/nein/gerfingerpoken/logcat/log.txt"
-        " -n 256 -r 1024";
-    EXPECT_FALSE(IsFalse(0 == system(command), command));
-}
-
-#ifndef logcat
-static void caught_blocking_clear(int signum) {
-    unsigned long long v = 0xDEADBEEFA55C0000ULL;
-
-    v += getpid() & 0xFFFF;
-    if (signum == 0) ++v;
-
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
-}
-
-TEST(logcat, blocking_clear) {
-    FILE* fp;
-    unsigned long long v = 0xDEADBEEFA55C0000ULL;
-
-    pid_t pid = getpid();
-
-    v += pid & 0xFFFF;
-
-    // This test is racey; an event occurs between clear and dump.
-    // We accept that we will get a false positive, but never a false negative.
-    ASSERT_TRUE(
-        NULL !=
-        (fp = popen("( trap exit HUP QUIT INT PIPE KILL ; sleep 6; echo DONE )&"
-                    " logcat -b events -c 2>&1 ;"
-                    " logcat -b events -g 2>&1 ;"
-                    " logcat -v brief -b events 2>&1",
-                    "r")));
-
-    char buffer[BIG_BUFFER];
-
-    int count = 0;
-    int minus_g = 0;
-
-    int signals = 0;
-
-    signal(SIGALRM, caught_blocking_clear);
-    alarm(2);
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (!strncmp(buffer, "clearLog: ", strlen("clearLog: "))) {
-            fprintf(stderr, "WARNING: Test lacks permission to run :-(\n");
-            count = signals = 1;
-            break;
-        }
-        if (!strncmp(buffer, "failed to clear", strlen("failed to clear"))) {
-            fprintf(stderr, "WARNING: Test lacks permission to run :-(\n");
-            count = signals = 1;
-            break;
-        }
-
-        if (!strncmp(buffer, "DONE", 4)) {
-            break;
-        }
-
-        int size, consumed, max, payload;
-        char size_mult[4], consumed_mult[4];
-        size = consumed = max = payload = 0;
-        if (6 == sscanf(buffer,
-                        "events: ring buffer is %d %3s (%d %3s consumed),"
-                        " max entry is %d B, max payload is %d B",
-                        &size, size_mult, &consumed, consumed_mult, &max, &payload)) {
-            long full_size = size, full_consumed = consumed;
-
-            switch (size_mult[0]) {
-                case 'G':
-                    full_size *= 1024;
-                    FALLTHROUGH_INTENDED;
-                case 'M':
-                    full_size *= 1024;
-                    FALLTHROUGH_INTENDED;
-                case 'K':
-                    full_size *= 1024;
-                    FALLTHROUGH_INTENDED;
-                case 'B':
-                    break;
-            }
-            switch (consumed_mult[0]) {
-                case 'G':
-                    full_consumed *= 1024;
-                    FALLTHROUGH_INTENDED;
-                case 'M':
-                    full_consumed *= 1024;
-                    FALLTHROUGH_INTENDED;
-                case 'K':
-                    full_consumed *= 1024;
-                    FALLTHROUGH_INTENDED;
-                case 'B':
-                    break;
-            }
-            EXPECT_GT(full_size, full_consumed);
-            EXPECT_GT(full_size, max);
-            EXPECT_GT(max, payload);
-            EXPECT_GT(max, full_consumed);
-
-            ++minus_g;
-            continue;
-        }
-
-        ++count;
-
-        int p;
-        unsigned long long l;
-
-        if ((2 != sscanf(buffer, "I/[0] ( %u): %lld", &p, &l)) || (p != pid)) {
-            continue;
-        }
-
-        if (l == v) {
-            if (count > 1) {
-                fprintf(stderr, "WARNING: Possible false positive\n");
-            }
-            ++signals;
-            break;
-        }
-    }
-    alarm(0);
-    signal(SIGALRM, SIG_DFL);
-
-    // Generate SIGPIPE
-    fclose(fp);
-    caught_blocking_clear(0);
-
-    pclose(fp);
-
-    EXPECT_GE(count, 1);
-    EXPECT_EQ(minus_g, 1);
-
-    EXPECT_EQ(signals, 1);
-}
-#endif
-
-static bool get_prune_rules(char** list) {
-    FILE* fp = popen(logcat_executable " -p 2>/dev/null", "r");
-    if (fp == NULL) {
-        fprintf(stderr, "ERROR: logcat -p 2>/dev/null\n");
-        return false;
-    }
-
-    char buffer[BIG_BUFFER];
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        char* hold = *list;
-        char* buf = buffer;
-        while (isspace(*buf)) {
-            ++buf;
-        }
-        char* end = buf + strlen(buf);
-        while (isspace(*--end) && (end >= buf)) {
-            *end = '\0';
-        }
-        if (end < buf) {
-            continue;
-        }
-        if (hold) {
-            asprintf(list, "%s %s", hold, buf);
-            free(hold);
-        } else {
-            asprintf(list, "%s", buf);
-        }
-    }
-    pclose(fp);
-    return *list != NULL;
-}
-
-static bool set_prune_rules(const char* list) {
-    char buffer[BIG_BUFFER];
-    snprintf(buffer, sizeof(buffer), logcat_executable " -P '%s' 2>&1",
-             list ? list : "");
-    FILE* fp = popen(buffer, "r");
-    if (fp == NULL) {
-        fprintf(stderr, "ERROR: %s\n", buffer);
-        return false;
-    }
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        char* buf = buffer;
-        while (isspace(*buf)) {
-            ++buf;
-        }
-        char* end = buf + strlen(buf);
-        while ((end > buf) && isspace(*--end)) {
-            *end = '\0';
-        }
-        if (end <= buf) {
-            continue;
-        }
-        fprintf(stderr, "%s\n", buf);
-        pclose(fp);
-        return false;
-    }
-    return pclose(fp) == 0;
-}
-
-TEST(logcat, prune_rules_adjust) {
-    char* list = NULL;
-    char* adjust = NULL;
-
-    get_prune_rules(&list);
-
-    static const char adjustment[] = "~! 300/20 300/25 2000 ~1000/5 ~1000/30";
-    ASSERT_EQ(true, set_prune_rules(adjustment));
-    ASSERT_EQ(true, get_prune_rules(&adjust));
-    EXPECT_STREQ(adjustment, adjust);
-    free(adjust);
-    adjust = NULL;
-
-    static const char adjustment2[] = "300/20 300/21 2000 ~1000";
-    ASSERT_EQ(true, set_prune_rules(adjustment2));
-    ASSERT_EQ(true, get_prune_rules(&adjust));
-    EXPECT_STREQ(adjustment2, adjust);
-    free(adjust);
-    adjust = NULL;
-
-    ASSERT_EQ(true, set_prune_rules(list));
-    get_prune_rules(&adjust);
-    EXPECT_STREQ(list ? list : "", adjust ? adjust : "");
-    free(adjust);
-    adjust = NULL;
-
-    free(list);
-    list = NULL;
-}
-
-TEST(logcat, regex) {
-    FILE* fp;
-    int count = 0;
-
-    char buffer[BIG_BUFFER];
-#define logcat_regex_prefix logcat_executable "_test"
-
-    snprintf(buffer, sizeof(buffer),
-             logcat_executable " --pid %d -d -e " logcat_regex_prefix "_a+b",
-             getpid());
-
-    LOG_FAILURE_RETRY(__android_log_print(ANDROID_LOG_WARN, logcat_regex_prefix,
-                                          logcat_regex_prefix "_ab"));
-    LOG_FAILURE_RETRY(__android_log_print(ANDROID_LOG_WARN, logcat_regex_prefix,
-                                          logcat_regex_prefix "_b"));
-    LOG_FAILURE_RETRY(__android_log_print(ANDROID_LOG_WARN, logcat_regex_prefix,
-                                          logcat_regex_prefix "_aaaab"));
-    LOG_FAILURE_RETRY(__android_log_print(ANDROID_LOG_WARN, logcat_regex_prefix,
-                                          logcat_regex_prefix "_aaaa"));
-    // Let the logs settle
-    rest();
-
-    ASSERT_TRUE(NULL != (fp = popen(buffer, "r")));
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (!strncmp(begin, buffer, sizeof(begin) - 1)) {
-            continue;
-        }
-
-        EXPECT_TRUE(strstr(buffer, logcat_regex_prefix "_") != NULL);
-
-        count++;
-    }
-
-    pclose(fp);
-
-    ASSERT_EQ(2, count);
-}
-
-TEST(logcat, maxcount) {
-    FILE* fp;
-    int count = 0;
-
-    char buffer[BIG_BUFFER];
-
-    snprintf(buffer, sizeof(buffer),
-             logcat_executable " --pid %d -d --max-count 3", getpid());
-
-    LOG_FAILURE_RETRY(
-        __android_log_print(ANDROID_LOG_WARN, "logcat_test", "logcat_test"));
-    LOG_FAILURE_RETRY(
-        __android_log_print(ANDROID_LOG_WARN, "logcat_test", "logcat_test"));
-    LOG_FAILURE_RETRY(
-        __android_log_print(ANDROID_LOG_WARN, "logcat_test", "logcat_test"));
-    LOG_FAILURE_RETRY(
-        __android_log_print(ANDROID_LOG_WARN, "logcat_test", "logcat_test"));
-
-    rest();
-
-    ASSERT_TRUE(NULL != (fp = popen(buffer, "r")));
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        if (!strncmp(begin, buffer, sizeof(begin) - 1)) {
-            continue;
-        }
-
-        count++;
-    }
-
-    pclose(fp);
-
-    ASSERT_EQ(3, count);
-}
-
-static bool End_to_End(const char* tag, const char* fmt, ...)
-#if defined(__GNUC__)
-    __attribute__((__format__(printf, 2, 3)))
-#endif
-    ;
-
-static bool End_to_End(const char* tag, const char* fmt, ...) {
-    FILE* fp = popen(logcat_executable " -v brief -b events -v descriptive -t 100 2>/dev/null", "r");
-    if (!fp) {
-        fprintf(stderr, "End_to_End: popen failed");
-        return false;
-    }
-
-    char buffer[BIG_BUFFER];
-    va_list ap;
-
-    va_start(ap, fmt);
-    vsnprintf(buffer, sizeof(buffer), fmt, ap);
-    va_end(ap);
-
-    char* str = NULL;
-    asprintf(&str, "I/%s ( %%d):%%c%s%%c", tag, buffer);
-    std::string expect(str);
-    free(str);
-
-    int count = 0;
-    pid_t pid = getpid();
-    std::string lastMatch;
-    int maxMatch = 1;
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        char space;
-        char newline;
-        int p;
-        int ret = sscanf(buffer, expect.c_str(), &p, &space, &newline);
-        if ((ret == 3) && (p == pid) && (space == ' ') && (newline == '\n')) {
-            ++count;
-        } else if ((ret >= maxMatch) && (p == pid) && (count == 0)) {
-            lastMatch = buffer;
-            maxMatch = ret;
-        }
-    }
-
-    pclose(fp);
-
-    if ((count == 0) && (lastMatch.length() > 0)) {
-        // Help us pinpoint where things went wrong ...
-        fprintf(stderr, "Closest match for\n    %s\n  is\n    %s",
-                expect.c_str(), lastMatch.c_str());
-    } else if (count > 3) {
-        fprintf(stderr, "Too many matches (%d) for %s\n", count, expect.c_str());
-    }
-
-    // Three different known tests, we can see pollution from the others
-    return count && (count <= 3);
-}
-
-TEST(logcat, descriptive) {
-    struct tag {
-        uint32_t tagNo;
-        const char* tagStr;
-    };
-    int ret;
-
-    {
-        static const struct tag hhgtg = { 42, "answer" };
-        android_log_event_list ctx(hhgtg.tagNo);
-        static const char theAnswer[] = "what is five by seven";
-        ctx << theAnswer;
-        // crafted to rest at least once after, and rest between retries.
-        for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-        EXPECT_GE(ret, 0);
-        EXPECT_TRUE(
-            End_to_End(hhgtg.tagStr, "to life the universe etc=%s", theAnswer));
-    }
-
-    {
-        static const struct tag sync = { 2720, "sync" };
-        static const char id[] = logcat_executable ".descriptive-sync";
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << id << (int32_t)42 << (int32_t)-1 << (int32_t)0;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr,
-                                   "[id=%s,event=42,source=-1,account=0]", id));
-        }
-
-        // Partial match to description
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << id << (int32_t)43 << (int64_t)-1 << (int32_t)0;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "[id=%s,event=43,-1,0]", id));
-        }
-
-        // Negative Test of End_to_End, ensure it is working
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << id << (int32_t)44 << (int32_t)-1 << (int64_t)0;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            fprintf(stderr, "Expect a \"Closest match\" message\n");
-            EXPECT_FALSE(End_to_End(
-                sync.tagStr, "[id=%s,event=44,source=-1,account=0]", id));
-        }
-    }
-
-    {
-        static const struct tag sync = { 2747, "contacts_aggregation" };
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint64_t)30 << (int32_t)2;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(
-                End_to_End(sync.tagStr, "[aggregation time=30ms,count=2]"));
-        }
-
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint64_t)31570 << (int32_t)911;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(
-                End_to_End(sync.tagStr, "[aggregation time=31.57s,count=911]"));
-        }
-    }
-
-    {
-        static const struct tag sync = { 75000, "sqlite_mem_alarm_current" };
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)512;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "current=512B"));
-        }
-
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)3072;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "current=3KB"));
-        }
-
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)2097152;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "current=2MB"));
-        }
-
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)2097153;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "current=2097153B"));
-        }
-
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)1073741824;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "current=1GB"));
-        }
-
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)3221225472;  // 3MB, but on purpose overflowed
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "current=-1GB"));
-        }
-    }
-
-    {
-        static const struct tag sync = { 27501, "notification_panel_hidden" };
-        android_log_event_list ctx(sync.tagNo);
-        for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-        EXPECT_GE(ret, 0);
-        EXPECT_TRUE(End_to_End(sync.tagStr, ""));
-    }
-
-    {
-        // Invent new entries because existing can not serve
-        EventTagMap* map = android_openEventTagMap(nullptr);
-        ASSERT_TRUE(nullptr != map);
-        static const char name[] = logcat_executable ".descriptive-monotonic";
-        int myTag = android_lookupEventTagNum(map, name, "(new|1|s)",
-                                              ANDROID_LOG_UNKNOWN);
-        android_closeEventTagMap(map);
-        ASSERT_NE(-1, myTag);
-
-        const struct tag sync = { (uint32_t)myTag, name };
-
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)7;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "new=7s"));
-        }
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)62;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "new=1:02"));
-        }
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)3673;
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "new=1:01:13"));
-        }
-        {
-            android_log_event_list ctx(sync.tagNo);
-            ctx << (uint32_t)(86400 + 7200 + 180 + 58);
-            for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write();
-            EXPECT_GE(ret, 0);
-            EXPECT_TRUE(End_to_End(sync.tagStr, "new=1d 2:03:58"));
-        }
-    }
-}
-
-static bool reportedSecurity(const char* command) {
-    FILE* fp = popen(command, "r");
-    if (!fp) return true;
-
-    std::string ret;
-    bool val = android::base::ReadFdToString(fileno(fp), &ret);
-    pclose(fp);
-
-    if (!val) return true;
-    return std::string::npos != ret.find("'security'");
-}
-
-TEST(logcat, security) {
-    EXPECT_FALSE(reportedSecurity(logcat_executable " -b all -g 2>&1"));
-    EXPECT_TRUE(reportedSecurity(logcat_executable " -b security -g 2>&1"));
-    EXPECT_TRUE(reportedSecurity(logcat_executable " -b security -c 2>&1"));
-    EXPECT_TRUE(
-        reportedSecurity(logcat_executable " -b security -G 256K 2>&1"));
-}
-
-static size_t commandOutputSize(const char* command) {
-    FILE* fp = popen(command, "r");
-    if (!fp) return 0;
-
-    std::string ret;
-    if (!android::base::ReadFdToString(fileno(fp), &ret)) return 0;
-    if (pclose(fp) != 0) return 0;
-
-    return ret.size();
-}
-
-TEST(logcat, help) {
-    size_t logcatHelpTextSize = commandOutputSize(logcat_executable " -h 2>&1");
-    EXPECT_GT(logcatHelpTextSize, 4096UL);
-    size_t logcatLastHelpTextSize =
-        commandOutputSize(logcat_executable " -L -h 2>&1");
-#ifdef USING_LOGCAT_EXECUTABLE_DEFAULT  // logcat and liblogcat
-    EXPECT_EQ(logcatHelpTextSize, logcatLastHelpTextSize);
-#else
-    // logcatd -L -h prints the help twice, as designed.
-    EXPECT_EQ(logcatHelpTextSize * 2, logcatLastHelpTextSize);
-#endif
-}
-
-TEST(logcat, invalid_buffer) {
-  FILE* fp = popen("logcat -b foo 2>&1", "r");
-  ASSERT_NE(nullptr, fp);
-  std::string output;
-  ASSERT_TRUE(android::base::ReadFdToString(fileno(fp), &output));
-  pclose(fp);
-
-  ASSERT_TRUE(android::base::StartsWith(output, "unknown buffer foo\n"));
-}
-
-static void SniffUid(const std::string& line, uid_t& uid) {
-    auto uid_regex = std::regex{"\\S+\\s+\\S+\\s+(\\S+).*"};
-
-    auto trimmed_line = android::base::Trim(line);
-
-    std::smatch match_results;
-    ASSERT_TRUE(std::regex_match(trimmed_line, match_results, uid_regex))
-            << "Unable to find UID in line '" << trimmed_line << "'";
-    auto uid_string = match_results[1];
-    if (!android::base::ParseUint(uid_string, &uid)) {
-        auto pwd = getpwnam(uid_string.str().c_str());
-        ASSERT_NE(nullptr, pwd) << "uid '" << uid_string << "' in line '" << trimmed_line << "'";
-        uid = pwd->pw_uid;
-    }
-}
-
-static void UidsInLog(std::optional<std::vector<uid_t>> filter_uid, std::map<uid_t, size_t>& uids) {
-    std::string command;
-    if (filter_uid) {
-        std::vector<std::string> uid_strings;
-        for (const auto& uid : *filter_uid) {
-            uid_strings.emplace_back(std::to_string(uid));
-        }
-        command = android::base::StringPrintf(logcat_executable
-                                              " -v uid -b all -d 2>/dev/null --uid=%s",
-                                              android::base::Join(uid_strings, ",").c_str());
-    } else {
-        command = logcat_executable " -v uid -b all -d 2>/dev/null";
-    }
-    auto fp = std::unique_ptr<FILE, decltype(&pclose)>(popen(command.c_str(), "r"), pclose);
-    ASSERT_NE(nullptr, fp);
-
-    char buffer[BIG_BUFFER];
-    while (fgets(buffer, sizeof(buffer), fp.get())) {
-        // Ignore dividers, e.g. '--------- beginning of radio'
-        if (android::base::StartsWith(buffer, "---------")) {
-            continue;
-        }
-        uid_t uid;
-        SniffUid(buffer, uid);
-        uids[uid]++;
-    }
-}
-
-static std::vector<uid_t> TopTwoInMap(const std::map<uid_t, size_t>& uids) {
-    std::pair<uid_t, size_t> top = {0, 0};
-    std::pair<uid_t, size_t> second = {0, 0};
-    for (const auto& [uid, count] : uids) {
-        if (count > top.second) {
-            top = second;
-            top = {uid, count};
-        } else if (count > second.second) {
-            second = {uid, count};
-        }
-    }
-    return {top.first, second.first};
-}
-
-TEST(logcat, uid_filter) {
-    std::map<uid_t, size_t> uids;
-    UidsInLog({}, uids);
-
-    ASSERT_GT(uids.size(), 2U);
-    auto top_uids = TopTwoInMap(uids);
-
-    // Test filtering with --uid=<top uid>
-    std::map<uid_t, size_t> uids_only_top;
-    std::vector<uid_t> top_uid = {top_uids[0]};
-    UidsInLog(top_uid, uids_only_top);
-
-    EXPECT_EQ(1U, uids_only_top.size());
-
-    // Test filtering with --uid=<top uid>,<2nd top uid>
-    std::map<uid_t, size_t> uids_only_top2;
-    std::vector<uid_t> top2_uids = {top_uids[0], top_uids[1]};
-    UidsInLog(top2_uids, uids_only_top2);
-
-    EXPECT_EQ(2U, uids_only_top2.size());
-}
diff --git a/logcat/tests/logcatd_test.cpp b/logcat/tests/logcatd_test.cpp
deleted file mode 100644
index bb7534e..0000000
--- a/logcat/tests/logcatd_test.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#define logcat logcatd
-#define logcat_executable "logcatd"
-
-#include "logcat_test.cpp"
diff --git a/logd/.clang-format b/logd/.clang-format
deleted file mode 120000
index 1af4f51..0000000
--- a/logd/.clang-format
+++ /dev/null
@@ -1 +0,0 @@
-../.clang-format-4
\ No newline at end of file
diff --git a/logd/Android.bp b/logd/Android.bp
deleted file mode 100644
index 7f67ab0..0000000
--- a/logd/Android.bp
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright (C) 2017 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.
-
-// This is what we want to do:
-//  event_logtags = $(shell
-//    sed -n
-//        "s/^\([0-9]*\)[ \t]*$1[ \t].*/-D`echo $1 | tr a-z A-Z`_LOG_TAG=\1/p"
-//        $(LOCAL_PATH)/$2/event.logtags)
-//  event_flag := $(call event_logtags,auditd)
-//  event_flag += $(call event_logtags,logd)
-//  event_flag += $(call event_logtags,tag_def)
-// so make sure we do not regret hard-coding it as follows:
-event_flag = [
-    "-DAUDITD_LOG_TAG=1003",
-    "-DCHATTY_LOG_TAG=1004",
-    "-DTAG_DEF_LOG_TAG=1005",
-    "-DLIBLOG_LOG_TAG=1006",
-]
-
-cc_defaults {
-    name: "logd_defaults",
-
-    shared_libs: [
-        "libbase",
-        "libz",
-    ],
-    static_libs: ["libzstd"],
-    cflags: [
-        "-Wextra",
-        "-Wthread-safety",
-    ] + event_flag,
-
-    lto: {
-        thin: true,
-    },
-    cpp_std: "experimental",
-}
-
-cc_library_static {
-    name: "liblogd",
-    defaults: ["logd_defaults"],
-    host_supported: true,
-    srcs: [
-        "ChattyLogBuffer.cpp",
-        "CompressionEngine.cpp",
-        "LogReaderList.cpp",
-        "LogReaderThread.cpp",
-        "LogBufferElement.cpp",
-        "LogSize.cpp",
-        "LogStatistics.cpp",
-        "LogTags.cpp",
-        "PruneList.cpp",
-        "SerializedFlushToState.cpp",
-        "SerializedLogBuffer.cpp",
-        "SerializedLogChunk.cpp",
-        "SimpleLogBuffer.cpp",
-    ],
-    logtags: ["event.logtags"],
-
-    export_include_dirs: ["."],
-}
-
-cc_binary {
-    name: "logd",
-    defaults: ["logd_defaults"],
-    init_rc: ["logd.rc"],
-
-    srcs: [
-        "main.cpp",
-        "LogPermissions.cpp",
-        "CommandListener.cpp",
-        "LogListener.cpp",
-        "LogReader.cpp",
-        "LogAudit.cpp",
-        "LogKlog.cpp",
-        "libaudit.cpp",
-    ],
-
-    static_libs: [
-        "liblog",
-        "liblogd",
-    ],
-
-    shared_libs: [
-        "libsysutils",
-        "libcutils",
-        "libpackagelistparser",
-        "libprocessgroup",
-        "libcap",
-    ],
-}
-
-cc_binary {
-    name: "auditctl",
-
-    srcs: [
-        "auditctl.cpp",
-        "libaudit.cpp",
-    ],
-
-    shared_libs: ["libbase"],
-
-    cflags: [
-        "-Wextra",
-    ],
-}
-
-prebuilt_etc {
-    name: "logtagd.rc",
-    src: "logtagd.rc",
-    sub_dir: "init",
-}
-
-// -----------------------------------------------------------------------------
-// Unit tests.
-// -----------------------------------------------------------------------------
-
-cc_defaults {
-    name: "logd-unit-test-defaults",
-
-    cflags: [
-        "-fstack-protector-all",
-        "-g",
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-        "-fno-builtin",
-    ] + event_flag,
-
-    srcs: [
-        "ChattyLogBufferTest.cpp",
-        "logd_test.cpp",
-        "LogBufferTest.cpp",
-        "SerializedLogChunkTest.cpp",
-        "SerializedFlushToStateTest.cpp",
-    ],
-
-    static_libs: [
-        "libbase",
-        "libcutils",
-        "liblog",
-        "liblogd",
-        "libselinux",
-        "libz",
-        "libzstd",
-    ],
-}
-
-// Build tests for the logger. Run with:
-//   adb shell /data/nativetest/logd-unit-tests/logd-unit-tests
-cc_test {
-    name: "logd-unit-tests",
-    host_supported: true,
-    defaults: ["logd-unit-test-defaults"],
-}
-
-cc_test {
-    name: "CtsLogdTestCases",
-    defaults: ["logd-unit-test-defaults"],
-    multilib: {
-        lib32: {
-            suffix: "32",
-        },
-        lib64: {
-            suffix: "64",
-        },
-    },
-    test_suites: [
-        "cts",
-        "device-tests",
-        "vts10",
-    ],
-}
-
-cc_binary {
-    name: "replay_messages",
-    defaults: ["logd_defaults"],
-    host_supported: true,
-
-    srcs: [
-        "ReplayMessages.cpp",
-    ],
-
-    static_libs: [
-        "libbase",
-        "libcutils",
-        "liblog",
-        "liblogd",
-        "libselinux",
-        "libz",
-        "libzstd",
-    ],
-}
diff --git a/logd/AndroidTest.xml b/logd/AndroidTest.xml
deleted file mode 100644
index a25dc44..0000000
--- a/logd/AndroidTest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Config for CTS Logging Daemon test cases">
-    <option name="test-suite-tag" value="cts" />
-    <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
-    <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
-    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="cleanup" value="true" />
-        <option name="push" value="CtsLogdTestCases->/data/local/tmp/CtsLogdTestCases" />
-        <option name="append-bitness" value="true" />
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.GTest" >
-        <option name="native-test-device-path" value="/data/local/tmp" />
-        <option name="module-name" value="CtsLogdTestCases" />
-        <option name="runtime-hint" value="65s" />
-    </test>
-</configuration>
diff --git a/logd/ChattyLogBuffer.cpp b/logd/ChattyLogBuffer.cpp
deleted file mode 100644
index fd183e4..0000000
--- a/logd/ChattyLogBuffer.cpp
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-// for manual checking of stale entries during ChattyLogBuffer::erase()
-//#define DEBUG_CHECK_FOR_STALE_ENTRIES
-
-#include "ChattyLogBuffer.h"
-
-#include <ctype.h>
-#include <endian.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/cdefs.h>
-#include <sys/user.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <limits>
-#include <unordered_map>
-#include <utility>
-
-#include <private/android_logger.h>
-
-#include "LogUtils.h"
-
-#ifndef __predict_false
-#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
-#endif
-
-ChattyLogBuffer::ChattyLogBuffer(LogReaderList* reader_list, LogTags* tags, PruneList* prune,
-                                 LogStatistics* stats)
-    : SimpleLogBuffer(reader_list, tags, stats), prune_(prune) {}
-
-ChattyLogBuffer::~ChattyLogBuffer() {}
-
-enum match_type { DIFFERENT, SAME, SAME_LIBLOG };
-
-static enum match_type Identical(const LogBufferElement& elem, const LogBufferElement& last) {
-    ssize_t lenl = elem.msg_len();
-    if (lenl <= 0) return DIFFERENT;  // value if this represents a chatty elem
-    ssize_t lenr = last.msg_len();
-    if (lenr <= 0) return DIFFERENT;  // value if this represents a chatty elem
-    if (elem.uid() != last.uid()) return DIFFERENT;
-    if (elem.pid() != last.pid()) return DIFFERENT;
-    if (elem.tid() != last.tid()) return DIFFERENT;
-
-    // last is more than a minute old, stop squashing identical messages
-    if (elem.realtime().nsec() > (last.realtime().nsec() + 60 * NS_PER_SEC)) return DIFFERENT;
-
-    // Identical message
-    const char* msgl = elem.msg();
-    const char* msgr = last.msg();
-    if (lenl == lenr) {
-        if (!fastcmp<memcmp>(msgl, msgr, lenl)) return SAME;
-        // liblog tagged messages (content gets summed)
-        if (elem.log_id() == LOG_ID_EVENTS && lenl == sizeof(android_log_event_int_t) &&
-            !fastcmp<memcmp>(msgl, msgr, sizeof(android_log_event_int_t) - sizeof(int32_t)) &&
-            elem.GetTag() == LIBLOG_LOG_TAG) {
-            return SAME_LIBLOG;
-        }
-    }
-
-    // audit message (except sequence number) identical?
-    if (IsBinary(last.log_id()) &&
-        lenl > static_cast<ssize_t>(sizeof(android_log_event_string_t)) &&
-        lenr > static_cast<ssize_t>(sizeof(android_log_event_string_t))) {
-        if (fastcmp<memcmp>(msgl, msgr, sizeof(android_log_event_string_t) - sizeof(int32_t))) {
-            return DIFFERENT;
-        }
-        msgl += sizeof(android_log_event_string_t);
-        lenl -= sizeof(android_log_event_string_t);
-        msgr += sizeof(android_log_event_string_t);
-        lenr -= sizeof(android_log_event_string_t);
-    }
-    static const char avc[] = "): avc: ";
-    const char* avcl = android::strnstr(msgl, lenl, avc);
-    if (!avcl) return DIFFERENT;
-    lenl -= avcl - msgl;
-    const char* avcr = android::strnstr(msgr, lenr, avc);
-    if (!avcr) return DIFFERENT;
-    lenr -= avcr - msgr;
-    if (lenl != lenr) return DIFFERENT;
-    if (fastcmp<memcmp>(avcl + strlen(avc), avcr + strlen(avc), lenl - strlen(avc))) {
-        return DIFFERENT;
-    }
-    return SAME;
-}
-
-void ChattyLogBuffer::LogInternal(LogBufferElement&& elem) {
-    // b/137093665: don't coalesce security messages.
-    if (elem.log_id() == LOG_ID_SECURITY) {
-        SimpleLogBuffer::LogInternal(std::move(elem));
-        return;
-    }
-    int log_id = elem.log_id();
-
-    // Initialize last_logged_elements_ to a copy of elem if logging the first element for a log_id.
-    if (!last_logged_elements_[log_id]) {
-        last_logged_elements_[log_id].emplace(elem);
-        SimpleLogBuffer::LogInternal(std::move(elem));
-        return;
-    }
-
-    LogBufferElement& current_last = *last_logged_elements_[log_id];
-    enum match_type match = Identical(elem, current_last);
-
-    if (match == DIFFERENT) {
-        if (duplicate_elements_[log_id]) {
-            // If we previously had 3+ identical messages, log the chatty message.
-            if (duplicate_elements_[log_id]->dropped_count() > 0) {
-                SimpleLogBuffer::LogInternal(std::move(*duplicate_elements_[log_id]));
-            }
-            duplicate_elements_[log_id].reset();
-            // Log the saved copy of the last identical message seen.
-            SimpleLogBuffer::LogInternal(std::move(current_last));
-        }
-        last_logged_elements_[log_id].emplace(elem);
-        SimpleLogBuffer::LogInternal(std::move(elem));
-        return;
-    }
-
-    // 2 identical message: set duplicate_elements_ appropriately.
-    if (!duplicate_elements_[log_id]) {
-        duplicate_elements_[log_id].emplace(std::move(current_last));
-        last_logged_elements_[log_id].emplace(std::move(elem));
-        return;
-    }
-
-    // 3+ identical LIBLOG event messages: coalesce them into last_logged_elements_.
-    if (match == SAME_LIBLOG) {
-        const android_log_event_int_t* current_last_event =
-                reinterpret_cast<const android_log_event_int_t*>(current_last.msg());
-        int64_t current_last_count = current_last_event->payload.data;
-        android_log_event_int_t* elem_event =
-                reinterpret_cast<android_log_event_int_t*>(const_cast<char*>(elem.msg()));
-        int64_t elem_count = elem_event->payload.data;
-
-        int64_t total = current_last_count + elem_count;
-        if (total > std::numeric_limits<int32_t>::max()) {
-            SimpleLogBuffer::LogInternal(std::move(current_last));
-            last_logged_elements_[log_id].emplace(std::move(elem));
-            return;
-        }
-        stats()->AddTotal(current_last.log_id(), current_last.msg_len());
-        elem_event->payload.data = total;
-        last_logged_elements_[log_id].emplace(std::move(elem));
-        return;
-    }
-
-    // 3+ identical messages (not LIBLOG) messages: increase the drop count.
-    uint16_t dropped_count = duplicate_elements_[log_id]->dropped_count();
-    if (dropped_count == std::numeric_limits<uint16_t>::max()) {
-        SimpleLogBuffer::LogInternal(std::move(*duplicate_elements_[log_id]));
-        dropped_count = 0;
-    }
-    // We're dropping the current_last log so add its stats to the total.
-    stats()->AddTotal(current_last.log_id(), current_last.msg_len());
-    // Use current_last for tracking the dropped count to always use the latest timestamp.
-    current_last.SetDropped(dropped_count + 1);
-    duplicate_elements_[log_id].emplace(std::move(current_last));
-    last_logged_elements_[log_id].emplace(std::move(elem));
-}
-
-LogBufferElementCollection::iterator ChattyLogBuffer::Erase(LogBufferElementCollection::iterator it,
-                                                            bool coalesce) {
-    LogBufferElement& element = *it;
-    log_id_t id = element.log_id();
-
-    // Remove iterator references in the various lists that will become stale
-    // after the element is erased from the main logging list.
-
-    {  // start of scope for found iterator
-        int key = (id == LOG_ID_EVENTS || id == LOG_ID_SECURITY) ? element.GetTag() : element.uid();
-        LogBufferIteratorMap::iterator found = mLastWorst[id].find(key);
-        if ((found != mLastWorst[id].end()) && (it == found->second)) {
-            mLastWorst[id].erase(found);
-        }
-    }
-
-    {  // start of scope for pid found iterator
-        // element->uid() may not be AID_SYSTEM for next-best-watermark.
-        // will not assume id != LOG_ID_EVENTS or LOG_ID_SECURITY for KISS and
-        // long term code stability, find() check should be fast for those ids.
-        LogBufferPidIteratorMap::iterator found = mLastWorstPidOfSystem[id].find(element.pid());
-        if (found != mLastWorstPidOfSystem[id].end() && it == found->second) {
-            mLastWorstPidOfSystem[id].erase(found);
-        }
-    }
-
-#ifdef DEBUG_CHECK_FOR_STALE_ENTRIES
-    LogBufferElementCollection::iterator bad = it;
-    int key = (id == LOG_ID_EVENTS || id == LOG_ID_SECURITY) ? element->GetTag() : element->uid();
-#endif
-
-    if (coalesce) {
-        stats()->Erase(element.ToLogStatisticsElement());
-    } else {
-        stats()->Subtract(element.ToLogStatisticsElement());
-    }
-
-    it = SimpleLogBuffer::Erase(it);
-
-#ifdef DEBUG_CHECK_FOR_STALE_ENTRIES
-    log_id_for_each(i) {
-        for (auto b : mLastWorst[i]) {
-            if (bad == b.second) {
-                LOG(ERROR) << StringPrintf("stale mLastWorst[%d] key=%d mykey=%d", i, b.first, key);
-            }
-        }
-        for (auto b : mLastWorstPidOfSystem[i]) {
-            if (bad == b.second) {
-                LOG(ERROR) << StringPrintf("stale mLastWorstPidOfSystem[%d] pid=%d", i, b.first);
-            }
-        }
-    }
-#endif
-    return it;
-}
-
-// Define a temporary mechanism to report the last LogBufferElement pointer
-// for the specified uid, pid and tid. Used below to help merge-sort when
-// pruning for worst UID.
-class LogBufferElementLast {
-    typedef std::unordered_map<uint64_t, LogBufferElement*> LogBufferElementMap;
-    LogBufferElementMap map;
-
-  public:
-    bool coalesce(LogBufferElement* element, uint16_t dropped) {
-        uint64_t key = LogBufferElementKey(element->uid(), element->pid(), element->tid());
-        LogBufferElementMap::iterator it = map.find(key);
-        if (it != map.end()) {
-            LogBufferElement* found = it->second;
-            uint16_t moreDropped = found->dropped_count();
-            if ((dropped + moreDropped) > USHRT_MAX) {
-                map.erase(it);
-            } else {
-                found->SetDropped(dropped + moreDropped);
-                return true;
-            }
-        }
-        return false;
-    }
-
-    void add(LogBufferElement* element) {
-        uint64_t key = LogBufferElementKey(element->uid(), element->pid(), element->tid());
-        map[key] = element;
-    }
-
-    void clear() { map.clear(); }
-
-    void clear(LogBufferElement* element) {
-        uint64_t current = element->realtime().nsec() - (EXPIRE_RATELIMIT * NS_PER_SEC);
-        for (LogBufferElementMap::iterator it = map.begin(); it != map.end();) {
-            LogBufferElement* mapElement = it->second;
-            if (mapElement->dropped_count() >= EXPIRE_THRESHOLD &&
-                current > mapElement->realtime().nsec()) {
-                it = map.erase(it);
-            } else {
-                ++it;
-            }
-        }
-    }
-
-  private:
-    uint64_t LogBufferElementKey(uid_t uid, pid_t pid, pid_t tid) {
-        return uint64_t(uid) << 32 | uint64_t(pid) << 16 | uint64_t(tid);
-    }
-};
-
-// prune "pruneRows" of type "id" from the buffer.
-//
-// This garbage collection task is used to expire log entries. It is called to
-// remove all logs (clear), all UID logs (unprivileged clear), or every
-// 256 or 10% of the total logs (whichever is less) to prune the logs.
-//
-// First there is a prep phase where we discover the reader region lock that
-// acts as a backstop to any pruning activity to stop there and go no further.
-//
-// There are three major pruning loops that follow. All expire from the oldest
-// entries. Since there are multiple log buffers, the Android logging facility
-// will appear to drop entries 'in the middle' when looking at multiple log
-// sources and buffers. This effect is slightly more prominent when we prune
-// the worst offender by logging source. Thus the logs slowly loose content
-// and value as you move back in time. This is preferred since chatty sources
-// invariably move the logs value down faster as less chatty sources would be
-// expired in the noise.
-//
-// The first pass prunes elements that match 3 possible rules:
-// 1) A high priority prune rule, for example ~100/20, which indicates elements from UID 100 and PID
-//    20 should be pruned in this first pass.
-// 2) The default chatty pruning rule, ~!.  This rule sums the total size spent on log messages for
-//    each UID this log buffer.  If the highest sum consumes more than 12.5% of the log buffer, then
-//    these elements from that UID are pruned.
-// 3) The default AID_SYSTEM pruning rule, ~1000/!.  This rule is a special case to 2), if
-//    AID_SYSTEM is the top consumer of the log buffer, then this rule sums the total size spent on
-//    log messages for each PID in AID_SYSTEM in this log buffer and prunes elements from the PID
-//    with the highest sum.
-// This pass reevaluates the sums for rules 2) and 3) for every log message pruned. It creates
-// 'chatty' entries for the elements that it prunes and merges related chatty entries together. It
-// completes when one of three conditions have been met:
-// 1) The requested element count has been pruned.
-// 2) There are no elements that match any of these rules.
-// 3) A reader is referencing the oldest element that would match these rules.
-//
-// The second pass prunes elements starting from the beginning of the log.  It skips elements that
-// match any low priority prune rules.  It completes when one of three conditions have been met:
-// 1) The requested element count has been pruned.
-// 2) All elements except those mwatching low priority prune rules have been pruned.
-// 3) A reader is referencing the oldest element that would match these rules.
-//
-// The final pass only happens if there are any low priority prune rules and if the first two passes
-// were unable to prune the requested number of elements.  It prunes elements all starting from the
-// beginning of the log, regardless of if they match any low priority prune rules.
-//
-// If the requested number of logs was unable to be pruned, KickReader() is called to mitigate the
-// situation before the next call to Prune() and the function returns false.  Otherwise, if the
-// requested number of logs or all logs present in the buffer are pruned, in the case of Clear(),
-// it returns true.
-bool ChattyLogBuffer::Prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
-    LogReaderThread* oldest = nullptr;
-    bool clearAll = pruneRows == ULONG_MAX;
-
-    auto reader_threads_lock = std::lock_guard{reader_list()->reader_threads_lock()};
-
-    // Region locked?
-    for (const auto& reader_thread : reader_list()->reader_threads()) {
-        if (!reader_thread->IsWatching(id)) {
-            continue;
-        }
-        if (!oldest || oldest->start() > reader_thread->start() ||
-            (oldest->start() == reader_thread->start() &&
-             reader_thread->deadline().time_since_epoch().count() != 0)) {
-            oldest = reader_thread.get();
-        }
-    }
-
-    LogBufferElementCollection::iterator it;
-
-    if (__predict_false(caller_uid != AID_ROOT)) {  // unlikely
-        // Only here if clear all request from non system source, so chatty
-        // filter logistics is not required.
-        it = GetOldest(id);
-        while (it != logs().end()) {
-            LogBufferElement& element = *it;
-
-            if (element.log_id() != id || element.uid() != caller_uid) {
-                ++it;
-                continue;
-            }
-
-            if (oldest && oldest->start() <= element.sequence()) {
-                KickReader(oldest, id, pruneRows);
-                return false;
-            }
-
-            it = Erase(it);
-            if (--pruneRows == 0) {
-                return true;
-            }
-        }
-        return true;
-    }
-
-    // First prune pass.
-    bool check_high_priority = id != LOG_ID_SECURITY && prune_->HasHighPriorityPruneRules();
-    while (!clearAll && (pruneRows > 0)) {
-        // recalculate the worst offender on every batched pass
-        int worst = -1;  // not valid for uid() or getKey()
-        size_t worst_sizes = 0;
-        size_t second_worst_sizes = 0;
-        pid_t worstPid = 0;  // POSIX guarantees PID != 0
-
-        if (worstUidEnabledForLogid(id) && prune_->worst_uid_enabled()) {
-            // Calculate threshold as 12.5% of available storage
-            size_t threshold = max_size(id) / 8;
-
-            if (id == LOG_ID_EVENTS || id == LOG_ID_SECURITY) {
-                stats()->WorstTwoTags(threshold, &worst, &worst_sizes, &second_worst_sizes);
-                // per-pid filter for AID_SYSTEM sources is too complex
-            } else {
-                stats()->WorstTwoUids(id, threshold, &worst, &worst_sizes, &second_worst_sizes);
-
-                if (worst == AID_SYSTEM && prune_->worst_pid_of_system_enabled()) {
-                    stats()->WorstTwoSystemPids(id, worst_sizes, &worstPid, &second_worst_sizes);
-                }
-            }
-        }
-
-        // skip if we have neither a worst UID or high priority prune rules
-        if (worst == -1 && !check_high_priority) {
-            break;
-        }
-
-        bool kick = false;
-        bool leading = true;  // true if starting from the oldest log entry, false if starting from
-                              // a specific chatty entry.
-        // Perform at least one mandatory garbage collection cycle in following
-        // - clear leading chatty tags
-        // - coalesce chatty tags
-        // - check age-out of preserved logs
-        bool gc = pruneRows <= 1;
-        if (!gc && (worst != -1)) {
-            {  // begin scope for worst found iterator
-                LogBufferIteratorMap::iterator found = mLastWorst[id].find(worst);
-                if (found != mLastWorst[id].end() && found->second != logs().end()) {
-                    leading = false;
-                    it = found->second;
-                }
-            }
-            if (worstPid) {  // begin scope for pid worst found iterator
-                // FYI: worstPid only set if !LOG_ID_EVENTS and
-                //      !LOG_ID_SECURITY, not going to make that assumption ...
-                LogBufferPidIteratorMap::iterator found = mLastWorstPidOfSystem[id].find(worstPid);
-                if (found != mLastWorstPidOfSystem[id].end() && found->second != logs().end()) {
-                    leading = false;
-                    it = found->second;
-                }
-            }
-        }
-        if (leading) {
-            it = GetOldest(id);
-        }
-        static const log_time too_old{EXPIRE_HOUR_THRESHOLD * 60 * 60, 0};
-        LogBufferElementCollection::iterator lastt;
-        lastt = logs().end();
-        --lastt;
-        LogBufferElementLast last;
-        while (it != logs().end()) {
-            LogBufferElement& element = *it;
-
-            if (oldest && oldest->start() <= element.sequence()) {
-                // Do not let chatty eliding trigger any reader mitigation
-                break;
-            }
-
-            if (element.log_id() != id) {
-                ++it;
-                continue;
-            }
-            // below this point element->log_id() == id
-
-            uint16_t dropped = element.dropped_count();
-
-            // remove any leading drops
-            if (leading && dropped) {
-                it = Erase(it);
-                continue;
-            }
-
-            if (dropped && last.coalesce(&element, dropped)) {
-                it = Erase(it, true);
-                continue;
-            }
-
-            int key = (id == LOG_ID_EVENTS || id == LOG_ID_SECURITY) ? element.GetTag()
-                                                                     : element.uid();
-
-            if (check_high_priority && prune_->IsHighPriority(&element)) {
-                last.clear(&element);
-                it = Erase(it);
-                if (dropped) {
-                    continue;
-                }
-
-                pruneRows--;
-                if (pruneRows == 0) {
-                    break;
-                }
-
-                if (key == worst) {
-                    kick = true;
-                    if (worst_sizes < second_worst_sizes) {
-                        break;
-                    }
-                    worst_sizes -= element.msg_len();
-                }
-                continue;
-            }
-
-            if (element.realtime() < (lastt->realtime() - too_old) ||
-                element.realtime() > lastt->realtime()) {
-                break;
-            }
-
-            if (dropped) {
-                last.add(&element);
-                if (worstPid && ((!gc && element.pid() == worstPid) ||
-                                 mLastWorstPidOfSystem[id].find(element.pid()) ==
-                                         mLastWorstPidOfSystem[id].end())) {
-                    // element->uid() may not be AID_SYSTEM, next best
-                    // watermark if current one empty. id is not LOG_ID_EVENTS
-                    // or LOG_ID_SECURITY because of worstPid check.
-                    mLastWorstPidOfSystem[id][element.pid()] = it;
-                }
-                if ((!gc && !worstPid && (key == worst)) ||
-                    (mLastWorst[id].find(key) == mLastWorst[id].end())) {
-                    mLastWorst[id][key] = it;
-                }
-                ++it;
-                continue;
-            }
-
-            if (key != worst || (worstPid && element.pid() != worstPid)) {
-                leading = false;
-                last.clear(&element);
-                ++it;
-                continue;
-            }
-            // key == worst below here
-            // If worstPid set, then element->pid() == worstPid below here
-
-            pruneRows--;
-            if (pruneRows == 0) {
-                break;
-            }
-
-            kick = true;
-
-            uint16_t len = element.msg_len();
-
-            // do not create any leading drops
-            if (leading) {
-                it = Erase(it);
-            } else {
-                stats()->Drop(element.ToLogStatisticsElement());
-                element.SetDropped(1);
-                if (last.coalesce(&element, 1)) {
-                    it = Erase(it, true);
-                } else {
-                    last.add(&element);
-                    if (worstPid && (!gc || mLastWorstPidOfSystem[id].find(worstPid) ==
-                                                    mLastWorstPidOfSystem[id].end())) {
-                        // element->uid() may not be AID_SYSTEM, next best
-                        // watermark if current one empty. id is not
-                        // LOG_ID_EVENTS or LOG_ID_SECURITY because of worstPid.
-                        mLastWorstPidOfSystem[id][worstPid] = it;
-                    }
-                    if ((!gc && !worstPid) || mLastWorst[id].find(worst) == mLastWorst[id].end()) {
-                        mLastWorst[id][worst] = it;
-                    }
-                    ++it;
-                }
-            }
-            if (worst_sizes < second_worst_sizes) {
-                break;
-            }
-            worst_sizes -= len;
-        }
-        last.clear();
-
-        if (!kick || !prune_->worst_uid_enabled()) {
-            break;  // the following loop will ask bad clients to skip/drop
-        }
-    }
-
-    // Second prune pass.
-    bool skipped_low_priority_prune = false;
-    bool check_low_priority =
-            id != LOG_ID_SECURITY && prune_->HasLowPriorityPruneRules() && !clearAll;
-    it = GetOldest(id);
-    while (pruneRows > 0 && it != logs().end()) {
-        LogBufferElement& element = *it;
-
-        if (element.log_id() != id) {
-            it++;
-            continue;
-        }
-
-        if (oldest && oldest->start() <= element.sequence()) {
-            if (!skipped_low_priority_prune) KickReader(oldest, id, pruneRows);
-            break;
-        }
-
-        if (check_low_priority && !element.dropped_count() && prune_->IsLowPriority(&element)) {
-            skipped_low_priority_prune = true;
-            it++;
-            continue;
-        }
-
-        it = Erase(it);
-        pruneRows--;
-    }
-
-    // Third prune pass.
-    if (skipped_low_priority_prune && pruneRows > 0) {
-        it = GetOldest(id);
-        while (it != logs().end() && pruneRows > 0) {
-            LogBufferElement& element = *it;
-
-            if (element.log_id() != id) {
-                ++it;
-                continue;
-            }
-
-            if (oldest && oldest->start() <= element.sequence()) {
-                KickReader(oldest, id, pruneRows);
-                break;
-            }
-
-            it = Erase(it);
-            pruneRows--;
-        }
-    }
-
-    return pruneRows == 0 || it == logs().end();
-}
diff --git a/logd/ChattyLogBuffer.h b/logd/ChattyLogBuffer.h
deleted file mode 100644
index ce3dc7b..0000000
--- a/logd/ChattyLogBuffer.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include <sys/types.h>
-
-#include <list>
-#include <optional>
-#include <string>
-
-#include <android-base/thread_annotations.h>
-#include <android/log.h>
-#include <private/android_filesystem_config.h>
-#include <sysutils/SocketClient.h>
-
-#include "LogBuffer.h"
-#include "LogBufferElement.h"
-#include "LogReaderList.h"
-#include "LogReaderThread.h"
-#include "LogStatistics.h"
-#include "LogTags.h"
-#include "LogWriter.h"
-#include "PruneList.h"
-#include "SimpleLogBuffer.h"
-#include "rwlock.h"
-
-typedef std::list<LogBufferElement> LogBufferElementCollection;
-
-class ChattyLogBuffer : public SimpleLogBuffer {
-    // watermark of any worst/chatty uid processing
-    typedef std::unordered_map<uid_t, LogBufferElementCollection::iterator> LogBufferIteratorMap;
-    LogBufferIteratorMap mLastWorst[LOG_ID_MAX] GUARDED_BY(lock_);
-    // watermark of any worst/chatty pid of system processing
-    typedef std::unordered_map<pid_t, LogBufferElementCollection::iterator> LogBufferPidIteratorMap;
-    LogBufferPidIteratorMap mLastWorstPidOfSystem[LOG_ID_MAX] GUARDED_BY(lock_);
-
-  public:
-    ChattyLogBuffer(LogReaderList* reader_list, LogTags* tags, PruneList* prune,
-                    LogStatistics* stats);
-    ~ChattyLogBuffer();
-
-  protected:
-    bool Prune(log_id_t id, unsigned long pruneRows, uid_t uid) REQUIRES(lock_) override;
-    void LogInternal(LogBufferElement&& elem) REQUIRES(lock_) override;
-
-  private:
-    LogBufferElementCollection::iterator Erase(LogBufferElementCollection::iterator it,
-                                               bool coalesce = false) REQUIRES(lock_);
-
-    PruneList* prune_;
-
-    // This always contains a copy of the last message logged, for deduplication.
-    std::optional<LogBufferElement> last_logged_elements_[LOG_ID_MAX] GUARDED_BY(lock_);
-    // This contains an element if duplicate messages are seen.
-    // Its `dropped` count is `duplicates seen - 1`.
-    std::optional<LogBufferElement> duplicate_elements_[LOG_ID_MAX] GUARDED_BY(lock_);
-};
diff --git a/logd/ChattyLogBufferTest.cpp b/logd/ChattyLogBufferTest.cpp
deleted file mode 100644
index 3d9005a..0000000
--- a/logd/ChattyLogBufferTest.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (C) 2020 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 "LogBufferTest.h"
-
-class ChattyLogBufferTest : public LogBufferTest {};
-
-TEST_P(ChattyLogBufferTest, deduplication_simple) {
-    auto make_message = [&](uint32_t sec, const char* tag, const char* msg,
-                            bool regex = false) -> LogMessage {
-        logger_entry entry = {
-                .pid = 1, .tid = 1, .sec = sec, .nsec = 1, .lid = LOG_ID_MAIN, .uid = 0};
-        std::string message;
-        message.push_back(ANDROID_LOG_INFO);
-        message.append(tag);
-        message.push_back('\0');
-        message.append(msg);
-        message.push_back('\0');
-        return {entry, message, regex};
-    };
-
-    // clang-format off
-    std::vector<LogMessage> log_messages = {
-            make_message(0, "test_tag", "duplicate"),
-            make_message(1, "test_tag", "duplicate"),
-            make_message(2, "test_tag", "not_same"),
-            make_message(3, "test_tag", "duplicate"),
-            make_message(4, "test_tag", "duplicate"),
-            make_message(5, "test_tag", "not_same"),
-            make_message(6, "test_tag", "duplicate"),
-            make_message(7, "test_tag", "duplicate"),
-            make_message(8, "test_tag", "duplicate"),
-            make_message(9, "test_tag", "not_same"),
-            make_message(10, "test_tag", "duplicate"),
-            make_message(11, "test_tag", "duplicate"),
-            make_message(12, "test_tag", "duplicate"),
-            make_message(13, "test_tag", "duplicate"),
-            make_message(14, "test_tag", "duplicate"),
-            make_message(15, "test_tag", "duplicate"),
-            make_message(16, "test_tag", "not_same"),
-            make_message(100, "test_tag", "duplicate"),
-            make_message(200, "test_tag", "duplicate"),
-            make_message(300, "test_tag", "duplicate"),
-    };
-    // clang-format on
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, nullptr));
-    std::unique_ptr<FlushToState> flush_to_state = log_buffer_->CreateFlushToState(1, kLogMaskAll);
-    EXPECT_TRUE(log_buffer_->FlushTo(test_writer.get(), *flush_to_state, nullptr));
-
-    std::vector<LogMessage> expected_log_messages = {
-            make_message(0, "test_tag", "duplicate"),
-            make_message(1, "test_tag", "duplicate"),
-            make_message(2, "test_tag", "not_same"),
-            make_message(3, "test_tag", "duplicate"),
-            make_message(4, "test_tag", "duplicate"),
-            make_message(5, "test_tag", "not_same"),
-            // 3 duplicate logs together print the first, a 1 count chatty message, then the last.
-            make_message(6, "test_tag", "duplicate"),
-            make_message(7, "chatty", "uid=0\\([^\\)]+\\) [^ ]+ identical 1 line", true),
-            make_message(8, "test_tag", "duplicate"),
-            make_message(9, "test_tag", "not_same"),
-            // 6 duplicate logs together print the first, a 4 count chatty message, then the last.
-            make_message(10, "test_tag", "duplicate"),
-            make_message(14, "chatty", "uid=0\\([^\\)]+\\) [^ ]+ identical 4 lines", true),
-            make_message(15, "test_tag", "duplicate"),
-            make_message(16, "test_tag", "not_same"),
-            // duplicate logs > 1 minute apart are not deduplicated.
-            make_message(100, "test_tag", "duplicate"),
-            make_message(200, "test_tag", "duplicate"),
-            make_message(300, "test_tag", "duplicate"),
-    };
-    FixupMessages(&expected_log_messages);
-    CompareLogMessages(expected_log_messages, read_log_messages);
-};
-
-TEST_P(ChattyLogBufferTest, deduplication_overflow) {
-    auto make_message = [&](uint32_t sec, const char* tag, const char* msg,
-                            bool regex = false) -> LogMessage {
-        logger_entry entry = {
-                .pid = 1, .tid = 1, .sec = sec, .nsec = 1, .lid = LOG_ID_MAIN, .uid = 0};
-        std::string message;
-        message.push_back(ANDROID_LOG_INFO);
-        message.append(tag);
-        message.push_back('\0');
-        message.append(msg);
-        message.push_back('\0');
-        return {entry, message, regex};
-    };
-
-    uint32_t sec = 0;
-    std::vector<LogMessage> log_messages = {
-            make_message(sec++, "test_tag", "normal"),
-    };
-    size_t expired_per_chatty_message = std::numeric_limits<uint16_t>::max();
-    for (size_t i = 0; i < expired_per_chatty_message + 3; ++i) {
-        log_messages.emplace_back(make_message(sec++, "test_tag", "duplicate"));
-    }
-    log_messages.emplace_back(make_message(sec++, "test_tag", "normal"));
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, nullptr));
-    std::unique_ptr<FlushToState> flush_to_state = log_buffer_->CreateFlushToState(1, kLogMaskAll);
-    EXPECT_TRUE(log_buffer_->FlushTo(test_writer.get(), *flush_to_state, nullptr));
-
-    std::vector<LogMessage> expected_log_messages = {
-            make_message(0, "test_tag", "normal"),
-            make_message(1, "test_tag", "duplicate"),
-            make_message(expired_per_chatty_message + 1, "chatty",
-                         "uid=0\\([^\\)]+\\) [^ ]+ identical 65535 lines", true),
-            make_message(expired_per_chatty_message + 2, "chatty",
-                         "uid=0\\([^\\)]+\\) [^ ]+ identical 1 line", true),
-            make_message(expired_per_chatty_message + 3, "test_tag", "duplicate"),
-            make_message(expired_per_chatty_message + 4, "test_tag", "normal"),
-    };
-    FixupMessages(&expected_log_messages);
-    CompareLogMessages(expected_log_messages, read_log_messages);
-}
-
-TEST_P(ChattyLogBufferTest, deduplication_liblog) {
-    auto make_message = [&](uint32_t sec, int32_t tag, int32_t count) -> LogMessage {
-        logger_entry entry = {
-                .pid = 1, .tid = 1, .sec = sec, .nsec = 1, .lid = LOG_ID_EVENTS, .uid = 0};
-        android_log_event_int_t liblog_event = {
-                .header.tag = tag, .payload.type = EVENT_TYPE_INT, .payload.data = count};
-        return {entry, std::string(reinterpret_cast<char*>(&liblog_event), sizeof(liblog_event)),
-                false};
-    };
-
-    // LIBLOG_LOG_TAG
-    std::vector<LogMessage> log_messages = {
-            make_message(0, 1234, 1),
-            make_message(1, LIBLOG_LOG_TAG, 3),
-            make_message(2, 1234, 2),
-            make_message(3, LIBLOG_LOG_TAG, 3),
-            make_message(4, LIBLOG_LOG_TAG, 4),
-            make_message(5, 1234, 223),
-            make_message(6, LIBLOG_LOG_TAG, 2),
-            make_message(7, LIBLOG_LOG_TAG, 3),
-            make_message(8, LIBLOG_LOG_TAG, 4),
-            make_message(9, 1234, 227),
-            make_message(10, LIBLOG_LOG_TAG, 1),
-            make_message(11, LIBLOG_LOG_TAG, 3),
-            make_message(12, LIBLOG_LOG_TAG, 2),
-            make_message(13, LIBLOG_LOG_TAG, 3),
-            make_message(14, LIBLOG_LOG_TAG, 5),
-            make_message(15, 1234, 227),
-            make_message(16, LIBLOG_LOG_TAG, 2),
-            make_message(17, LIBLOG_LOG_TAG, std::numeric_limits<int32_t>::max()),
-            make_message(18, LIBLOG_LOG_TAG, 3),
-            make_message(19, LIBLOG_LOG_TAG, 5),
-            make_message(20, 1234, 227),
-    };
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, nullptr));
-    std::unique_ptr<FlushToState> flush_to_state = log_buffer_->CreateFlushToState(1, kLogMaskAll);
-    EXPECT_TRUE(log_buffer_->FlushTo(test_writer.get(), *flush_to_state, nullptr));
-
-    std::vector<LogMessage> expected_log_messages = {
-            make_message(0, 1234, 1),
-            make_message(1, LIBLOG_LOG_TAG, 3),
-            make_message(2, 1234, 2),
-            make_message(3, LIBLOG_LOG_TAG, 3),
-            make_message(4, LIBLOG_LOG_TAG, 4),
-            make_message(5, 1234, 223),
-            // More than 2 liblog events (3 here), sum their value into the third message.
-            make_message(6, LIBLOG_LOG_TAG, 2),
-            make_message(8, LIBLOG_LOG_TAG, 7),
-            make_message(9, 1234, 227),
-            // More than 2 liblog events (5 here), sum their value into the third message.
-            make_message(10, LIBLOG_LOG_TAG, 1),
-            make_message(14, LIBLOG_LOG_TAG, 13),
-            make_message(15, 1234, 227),
-            // int32_t max is the max for a chatty message, beyond that we must use new messages.
-            make_message(16, LIBLOG_LOG_TAG, 2),
-            make_message(17, LIBLOG_LOG_TAG, std::numeric_limits<int32_t>::max()),
-            make_message(19, LIBLOG_LOG_TAG, 8),
-            make_message(20, 1234, 227),
-    };
-    FixupMessages(&expected_log_messages);
-    CompareLogMessages(expected_log_messages, read_log_messages);
-};
-
-TEST_P(ChattyLogBufferTest, no_leading_chatty_simple) {
-    auto make_message = [&](uint32_t sec, int32_t pid, uint32_t uid, uint32_t lid, const char* tag,
-                            const char* msg, bool regex = false) -> LogMessage {
-        logger_entry entry = {.pid = pid, .tid = 1, .sec = sec, .nsec = 1, .lid = lid, .uid = uid};
-        std::string message;
-        message.push_back(ANDROID_LOG_INFO);
-        message.append(tag);
-        message.push_back('\0');
-        message.append(msg);
-        message.push_back('\0');
-        return {entry, message, regex};
-    };
-
-    // clang-format off
-    std::vector<LogMessage> log_messages = {
-            make_message(1, 1, 1, LOG_ID_MAIN, "test_tag", "duplicate1"),
-            make_message(2, 2, 2, LOG_ID_SYSTEM, "test_tag", "duplicate2"),
-            make_message(3, 2, 2, LOG_ID_SYSTEM, "test_tag", "duplicate2"),
-            make_message(4, 2, 2, LOG_ID_SYSTEM, "test_tag", "duplicate2"),
-            make_message(6, 2, 2, LOG_ID_SYSTEM, "test_tag", "not duplicate2"),
-            make_message(7, 1, 1, LOG_ID_MAIN, "test_tag", "duplicate1"),
-            make_message(8, 1, 1, LOG_ID_MAIN, "test_tag", "duplicate1"),
-            make_message(9, 1, 1, LOG_ID_MAIN, "test_tag", "duplicate1"),
-            make_message(10, 1, 1, LOG_ID_MAIN, "test_tag", "not duplicate1"),
-    };
-    // clang-format on
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    // After logging log_messages, the below is what should be in the buffer:
-    // PID=1, LOG_ID_MAIN duplicate1
-    // [1] PID=2, LOG_ID_SYSTEM duplicate2
-    // PID=2, LOG_ID_SYSTEM chatty drop
-    // PID=2, LOG_ID_SYSTEM duplicate2
-    // PID=2, LOG_ID_SYSTEM not duplicate2
-    // [2] PID=1, LOG_ID_MAIN chatty drop
-    // [3] PID=1, LOG_ID_MAIN duplicate1
-    // PID=1, LOG_ID_MAIN not duplicate1
-
-    // We then read from the 2nd sequence number, starting from log message [1], but filtering out
-    // everything but PID=1, which results in us starting with log message [2], which is a chatty
-    // drop.  Code prior to this test case would erroneously print it.  The intended behavior that
-    // this test checks prints logs starting from log message [3].
-
-    // clang-format off
-    std::vector<LogMessage> expected_log_messages = {
-            make_message(9, 1, 1, LOG_ID_MAIN, "test_tag", "duplicate1"),
-            make_message(10, 1, 1, LOG_ID_MAIN, "test_tag", "not duplicate1"),
-    };
-    FixupMessages(&expected_log_messages);
-    // clang-format on
-
-    std::vector<LogMessage> read_log_messages;
-    bool released = false;
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, &released));
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer_.get(), &reader_list_, std::move(test_writer), true,
-                                    0, ~0, 1, {}, 2, {}));
-        reader_list_.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    while (!released) {
-        usleep(5000);
-    }
-
-    CompareLogMessages(expected_log_messages, read_log_messages);
-}
-
-TEST_P(ChattyLogBufferTest, no_leading_chatty_tail) {
-    auto make_message = [&](uint32_t sec, const char* tag, const char* msg,
-                            bool regex = false) -> LogMessage {
-        logger_entry entry = {
-                .pid = 1, .tid = 1, .sec = sec, .nsec = 1, .lid = LOG_ID_MAIN, .uid = 0};
-        std::string message;
-        message.push_back(ANDROID_LOG_INFO);
-        message.append(tag);
-        message.push_back('\0');
-        message.append(msg);
-        message.push_back('\0');
-        return {entry, message, regex};
-    };
-
-    // clang-format off
-    std::vector<LogMessage> log_messages = {
-            make_message(1, "test_tag", "duplicate"),
-            make_message(2, "test_tag", "duplicate"),
-            make_message(3, "test_tag", "duplicate"),
-            make_message(4, "test_tag", "not_duplicate"),
-    };
-    // clang-format on
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    // After logging log_messages, the below is what should be in the buffer:
-    // "duplicate"
-    // chatty
-    // "duplicate"
-    // "not duplicate"
-
-    // We then read the tail 3 messages expecting there to not be a chatty message, meaning that we
-    // should only see the last two messages.
-
-    // clang-format off
-    std::vector<LogMessage> expected_log_messages = {
-            make_message(3, "test_tag", "duplicate"),
-            make_message(4, "test_tag", "not_duplicate"),
-    };
-    FixupMessages(&expected_log_messages);
-    // clang-format on
-
-    std::vector<LogMessage> read_log_messages;
-    bool released = false;
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, &released));
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer_.get(), &reader_list_, std::move(test_writer), true,
-                                    3, ~0, 0, {}, 1, {}));
-        reader_list_.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    while (!released) {
-        usleep(5000);
-    }
-
-    CompareLogMessages(expected_log_messages, read_log_messages);
-}
-
-INSTANTIATE_TEST_CASE_P(ChattyLogBufferTests, ChattyLogBufferTest, testing::Values("chatty"));
diff --git a/logd/CommandListener.cpp b/logd/CommandListener.cpp
deleted file mode 100644
index 0ba1621..0000000
--- a/logd/CommandListener.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (C) 2012-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 "CommandListener.h"
-
-#include <arpa/inet.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <math.h>
-#include <netinet/in.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/prctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <string>
-
-#include <android-base/logging.h>
-#include <android-base/parseint.h>
-#include <android-base/stringprintf.h>
-#include <cutils/sockets.h>
-#include <log/log_properties.h>
-#include <private/android_filesystem_config.h>
-#include <sysutils/SocketClient.h>
-
-#include "LogPermissions.h"
-
-CommandListener::CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune,
-                                 LogStatistics* stats)
-    : FrameworkListener(getLogSocket()), buf_(buf), tags_(tags), prune_(prune), stats_(stats) {
-    registerCmd(new ClearCmd(this));
-    registerCmd(new GetBufSizeCmd(this));
-    registerCmd(new SetBufSizeCmd(this));
-    registerCmd(new GetBufSizeReadableCmd(this));
-    registerCmd(new GetBufSizeUsedCmd(this));
-    registerCmd(new GetStatisticsCmd(this));
-    registerCmd(new SetPruneListCmd(this));
-    registerCmd(new GetPruneListCmd(this));
-    registerCmd(new GetEventTagCmd(this));
-    registerCmd(new ReinitCmd(this));
-    registerCmd(new ExitCmd(this));
-}
-
-static void setname() {
-    static bool name_set;
-    if (!name_set) {
-        prctl(PR_SET_NAME, "logd.control");
-        name_set = true;
-    }
-}
-
-template <typename F>
-static int LogIdCommand(SocketClient* cli, int argc, char** argv, F&& function) {
-    setname();
-    if (argc < 2) {
-        cli->sendMsg("Missing Argument");
-        return 0;
-    }
-
-    int log_id;
-    if (!android::base::ParseInt(argv[1], &log_id, static_cast<int>(LOG_ID_MAIN),
-                                 static_cast<int>(LOG_ID_KERNEL))) {
-        cli->sendMsg("Range Error");
-        return 0;
-    }
-
-    function(static_cast<log_id_t>(log_id));
-    return 0;
-}
-
-int CommandListener::ClearCmd::runCommand(SocketClient* cli, int argc, char** argv) {
-    uid_t uid = cli->getUid();
-    if (clientHasLogCredentials(cli)) {
-        uid = AID_ROOT;
-    }
-
-    return LogIdCommand(cli, argc, argv, [&](log_id_t id) {
-        cli->sendMsg(buf()->Clear(id, uid) ? "success" : "busy");
-    });
-}
-
-template <typename F>
-static int LogSizeCommand(SocketClient* cli, int argc, char** argv, F&& size_function) {
-    return LogIdCommand(cli, argc, argv, [&](log_id_t log_id) {
-        cli->sendMsg(std::to_string(size_function(log_id)).c_str());
-    });
-}
-
-int CommandListener::GetBufSizeCmd::runCommand(SocketClient* cli, int argc, char** argv) {
-    return LogSizeCommand(cli, argc, argv, [this](log_id_t id) { return buf()->GetSize(id); });
-}
-
-int CommandListener::GetBufSizeReadableCmd::runCommand(SocketClient* cli, int argc, char** argv) {
-    return LogSizeCommand(cli, argc, argv,
-                          [this](log_id_t id) { return stats()->SizeReadable(id); });
-}
-
-int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient* cli, int argc, char** argv) {
-    return LogSizeCommand(cli, argc, argv, [this](log_id_t id) { return stats()->Sizes(id); });
-}
-
-int CommandListener::SetBufSizeCmd::runCommand(SocketClient* cli, int argc,
-                                               char** argv) {
-    if (!clientHasLogCredentials(cli)) {
-        cli->sendMsg("Permission Denied");
-        return 0;
-    }
-
-    if (argc < 3) {
-        cli->sendMsg("Missing Argument");
-        return 0;
-    }
-    size_t size = atol(argv[2]);
-
-    return LogIdCommand(cli, argc, argv, [&](log_id_t log_id) {
-        cli->sendMsg(buf()->SetSize(log_id, size) ? "success" : "busy");
-    });
-}
-
-// This returns a string with a length prefix with the format <length>\n<data>\n\f.  The length
-// prefix includes the length of the prefix itself.
-static std::string PackageString(const std::string& str) {
-    size_t overhead_length = 3;  // \n \n \f.
-
-    // Number of digits needed to represent length(str + overhead_length).
-    size_t str_size_digits = 1 + static_cast<size_t>(log10(str.size() + overhead_length));
-    // Number of digits needed to represent the total size.
-    size_t total_size_digits =
-            1 + static_cast<size_t>(log10(str.size() + overhead_length + str_size_digits));
-
-    // If adding the size prefix causes a new digit to be required to represent the new total
-    // size, add it to the 'overhead_length'.  This can only happen once, since each new digit
-    // allows for 10x the previous size to be recorded.
-    if (total_size_digits != str_size_digits) {
-        overhead_length++;
-    }
-
-    size_t total_size = str.size() + overhead_length + str_size_digits;
-    return android::base::StringPrintf("%zu\n%s\n\f", total_size, str.c_str());
-}
-
-int CommandListener::GetStatisticsCmd::runCommand(SocketClient* cli, int argc, char** argv) {
-    setname();
-    uid_t uid = cli->getUid();
-    if (clientHasLogCredentials(cli)) {
-        uid = AID_ROOT;
-    }
-
-    unsigned int logMask = -1;
-    pid_t pid = 0;
-    if (argc > 1) {
-        logMask = 0;
-        for (int i = 1; i < argc; ++i) {
-            static const char _pid[] = "pid=";
-            if (!strncmp(argv[i], _pid, sizeof(_pid) - 1)) {
-                pid = atol(argv[i] + sizeof(_pid) - 1);
-                if (pid == 0) {
-                    cli->sendMsg("PID Error");
-                    return 0;
-                }
-                continue;
-            }
-
-            int id = atoi(argv[i]);
-            if ((id < LOG_ID_MIN) || (LOG_ID_MAX <= id)) {
-                cli->sendMsg("Range Error");
-                return 0;
-            }
-            logMask |= 1 << id;
-        }
-    }
-
-    cli->sendMsg(PackageString(stats()->Format(uid, pid, logMask)).c_str());
-    return 0;
-}
-
-int CommandListener::GetPruneListCmd::runCommand(SocketClient* cli, int, char**) {
-    setname();
-    cli->sendMsg(PackageString(prune()->Format()).c_str());
-    return 0;
-}
-
-int CommandListener::SetPruneListCmd::runCommand(SocketClient* cli, int argc, char** argv) {
-    setname();
-    if (!clientHasLogCredentials(cli)) {
-        cli->sendMsg("Permission Denied");
-        return 0;
-    }
-
-    std::string str;
-    for (int i = 1; i < argc; ++i) {
-        if (str.length()) {
-            str += " ";
-        }
-        str += argv[i];
-    }
-
-    if (!prune()->Init(str.c_str())) {
-        cli->sendMsg("Invalid");
-        return 0;
-    }
-
-    cli->sendMsg("success");
-    return 0;
-}
-
-int CommandListener::GetEventTagCmd::runCommand(SocketClient* cli, int argc, char** argv) {
-    setname();
-    uid_t uid = cli->getUid();
-    if (clientHasLogCredentials(cli)) {
-        uid = AID_ROOT;
-    }
-
-    const char* name = nullptr;
-    const char* format = nullptr;
-    const char* id = nullptr;
-    for (int i = 1; i < argc; ++i) {
-        static const char _name[] = "name=";
-        if (!strncmp(argv[i], _name, strlen(_name))) {
-            name = argv[i] + strlen(_name);
-            continue;
-        }
-
-        static const char _format[] = "format=";
-        if (!strncmp(argv[i], _format, strlen(_format))) {
-            format = argv[i] + strlen(_format);
-            continue;
-        }
-
-        static const char _id[] = "id=";
-        if (!strncmp(argv[i], _id, strlen(_id))) {
-            id = argv[i] + strlen(_id);
-            continue;
-        }
-    }
-
-    if (id) {
-        if (format || name) {
-            cli->sendMsg("can not mix id= with either format= or name=");
-            return 0;
-        }
-        cli->sendMsg(PackageString(tags()->formatEntry(atoi(id), uid)).c_str());
-        return 0;
-    }
-
-    cli->sendMsg(PackageString(tags()->formatGetEventTag(uid, name, format)).c_str());
-
-    return 0;
-}
-
-int CommandListener::ReinitCmd::runCommand(SocketClient* cli, int, char**) {
-    setname();
-
-    LOG(INFO) << "logd reinit";
-    buf()->Init();
-    prune()->Init(nullptr);
-
-    // This only works on userdebug and eng devices to re-read the
-    // /data/misc/logd/event-log-tags file right after /data is mounted.
-    // The operation is near to boot and should only happen once.  There
-    // are races associated with its use since it can trigger a Rebuild
-    // of the file, but that is a can-not-happen since the file was not
-    // read yet.  More dangerous if called later, but if all is well it
-    // should just skip over everything and not write any new entries.
-    if (__android_log_is_debuggable()) {
-        tags()->ReadFileEventLogTags(tags()->debug_event_log_tags);
-    }
-
-    cli->sendMsg("success");
-
-    return 0;
-}
-
-int CommandListener::ExitCmd::runCommand(SocketClient* cli, int, char**) {
-    setname();
-
-    cli->sendMsg("success");
-    parent_->release(cli);
-
-    return 0;
-}
-
-int CommandListener::getLogSocket() {
-    static const char socketName[] = "logd";
-    int sock = android_get_control_socket(socketName);
-
-    if (sock < 0) {
-        sock = socket_local_server(
-            socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM);
-    }
-
-    return sock;
-}
diff --git a/logd/CommandListener.h b/logd/CommandListener.h
deleted file mode 100644
index 8e12634..0000000
--- a/logd/CommandListener.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include <sysutils/FrameworkCommand.h>
-#include <sysutils/FrameworkListener.h>
-
-#include "LogBuffer.h"
-#include "LogListener.h"
-#include "LogStatistics.h"
-#include "LogTags.h"
-#include "PruneList.h"
-
-class CommandListener : public FrameworkListener {
-  public:
-    CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune, LogStatistics* log_statistics);
-    virtual ~CommandListener() {}
-
-  private:
-    static int getLogSocket();
-
-    LogBuffer* buf_;
-    LogTags* tags_;
-    PruneList* prune_;
-    LogStatistics* stats_;
-
-#define LogCmd(name, command_string)                                \
-    class name##Cmd : public FrameworkCommand {                     \
-      public:                                                       \
-        explicit name##Cmd(CommandListener* parent)                 \
-            : FrameworkCommand(#command_string), parent_(parent) {} \
-        virtual ~name##Cmd() {}                                     \
-        int runCommand(SocketClient* c, int argc, char** argv);     \
-                                                                    \
-      private:                                                      \
-        LogBuffer* buf() const { return parent_->buf_; }            \
-        LogTags* tags() const { return parent_->tags_; }            \
-        PruneList* prune() const { return parent_->prune_; }        \
-        LogStatistics* stats() const { return parent_->stats_; }    \
-        CommandListener* parent_;                                   \
-    }
-
-    LogCmd(Clear, clear);
-    LogCmd(GetBufSize, getLogSize);
-    LogCmd(SetBufSize, setLogSize);
-    LogCmd(GetBufSizeReadable, getLogSizeReadable);
-    LogCmd(GetBufSizeUsed, getLogSizeUsed);
-    LogCmd(GetStatistics, getStatistics);
-    LogCmd(GetPruneList, getPruneList);
-    LogCmd(SetPruneList, setPruneList);
-    LogCmd(GetEventTag, getEventTag);
-    LogCmd(Reinit, reinit);
-    LogCmd(Exit, EXIT);
-#undef LogCmd
-};
diff --git a/logd/CompressionEngine.cpp b/logd/CompressionEngine.cpp
deleted file mode 100644
index da2628c..0000000
--- a/logd/CompressionEngine.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2020 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 "CompressionEngine.h"
-
-#include <limits>
-
-#include <android-base/logging.h>
-#include <zlib.h>
-#include <zstd.h>
-
-CompressionEngine& CompressionEngine::GetInstance() {
-    static CompressionEngine* engine = new ZstdCompressionEngine();
-    return *engine;
-}
-
-bool ZlibCompressionEngine::Compress(SerializedData& in, size_t data_length, SerializedData& out) {
-    z_stream strm;
-    strm.zalloc = Z_NULL;
-    strm.zfree = Z_NULL;
-    strm.opaque = Z_NULL;
-    int ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
-    if (ret != Z_OK) {
-        LOG(FATAL) << "deflateInit() failed";
-    }
-
-    CHECK_LE(data_length, in.size());
-    CHECK_LE(in.size(), std::numeric_limits<uint32_t>::max());
-    uint32_t deflate_bound = deflateBound(&strm, in.size());
-
-    out.Resize(deflate_bound);
-
-    strm.avail_in = data_length;
-    strm.next_in = in.data();
-    strm.avail_out = out.size();
-    strm.next_out = out.data();
-    ret = deflate(&strm, Z_FINISH);
-    CHECK_EQ(ret, Z_STREAM_END);
-
-    uint32_t compressed_size = strm.total_out;
-    deflateEnd(&strm);
-
-    out.Resize(compressed_size);
-
-    return true;
-}
-
-bool ZlibCompressionEngine::Decompress(SerializedData& in, SerializedData& out) {
-    z_stream strm;
-    strm.zalloc = Z_NULL;
-    strm.zfree = Z_NULL;
-    strm.opaque = Z_NULL;
-    strm.avail_in = in.size();
-    strm.next_in = in.data();
-    strm.avail_out = out.size();
-    strm.next_out = out.data();
-
-    inflateInit(&strm);
-    int ret = inflate(&strm, Z_NO_FLUSH);
-
-    CHECK_EQ(strm.avail_in, 0U);
-    CHECK_EQ(strm.avail_out, 0U);
-    CHECK_EQ(ret, Z_STREAM_END);
-    inflateEnd(&strm);
-
-    return true;
-}
-
-bool ZstdCompressionEngine::Compress(SerializedData& in, size_t data_length, SerializedData& out) {
-    CHECK_LE(data_length, in.size());
-
-    size_t compress_bound = ZSTD_compressBound(data_length);
-    out.Resize(compress_bound);
-
-    size_t out_size = ZSTD_compress(out.data(), out.size(), in.data(), data_length, 1);
-    if (ZSTD_isError(out_size)) {
-        LOG(FATAL) << "ZSTD_compress failed: " << ZSTD_getErrorName(out_size);
-    }
-    out.Resize(out_size);
-
-    return true;
-}
-
-bool ZstdCompressionEngine::Decompress(SerializedData& in, SerializedData& out) {
-    size_t result = ZSTD_decompress(out.data(), out.size(), in.data(), in.size());
-    if (ZSTD_isError(result)) {
-        LOG(FATAL) << "ZSTD_decompress failed: " << ZSTD_getErrorName(result);
-    }
-    CHECK_EQ(result, out.size());
-    return true;
-}
diff --git a/logd/CompressionEngine.h b/logd/CompressionEngine.h
deleted file mode 100644
index 0f760ed..0000000
--- a/logd/CompressionEngine.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2020 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 <memory>
-
-#include "SerializedData.h"
-
-class CompressionEngine {
-  public:
-    static CompressionEngine& GetInstance();
-
-    virtual ~CompressionEngine(){};
-
-    virtual bool Compress(SerializedData& in, size_t data_length, SerializedData& out) = 0;
-    // Decompress the contents of `in` into `out`.  `out.size()` must be set to the decompressed
-    // size of the contents.
-    virtual bool Decompress(SerializedData& in, SerializedData& out) = 0;
-};
-
-class ZlibCompressionEngine : public CompressionEngine {
-  public:
-    bool Compress(SerializedData& in, size_t data_length, SerializedData& out) override;
-    bool Decompress(SerializedData& in, SerializedData& out) override;
-};
-
-class ZstdCompressionEngine : public CompressionEngine {
-  public:
-    bool Compress(SerializedData& in, size_t data_length, SerializedData& out) override;
-    bool Decompress(SerializedData& in, SerializedData& out) override;
-};
\ No newline at end of file
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp
deleted file mode 100644
index 0e17476..0000000
--- a/logd/LogAudit.cpp
+++ /dev/null
@@ -1,382 +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 "LogAudit.h"
-
-#include <ctype.h>
-#include <endian.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/prctl.h>
-#include <sys/uio.h>
-#include <syslog.h>
-
-#include <fstream>
-#include <sstream>
-
-#include <android-base/macros.h>
-#include <android-base/properties.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-
-#include "LogKlog.h"
-#include "LogUtils.h"
-#include "libaudit.h"
-
-using android::base::GetBoolProperty;
-
-#define KMSG_PRIORITY(PRI)                               \
-    '<', '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) / 10, \
-        '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) % 10, '>'
-
-LogAudit::LogAudit(LogBuffer* buf, int fdDmesg, LogStatistics* stats)
-    : SocketListener(getLogSocket(), false),
-      logbuf(buf),
-      fdDmesg(fdDmesg),
-      main(GetBoolProperty("ro.logd.auditd.main", true)),
-      events(GetBoolProperty("ro.logd.auditd.events", true)),
-      initialized(false),
-      stats_(stats) {
-    static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO),
-                                           'l',
-                                           'o',
-                                           'g',
-                                           'd',
-                                           '.',
-                                           'a',
-                                           'u',
-                                           'd',
-                                           'i',
-                                           't',
-                                           'd',
-                                           ':',
-                                           ' ',
-                                           's',
-                                           't',
-                                           'a',
-                                           'r',
-                                           't',
-                                           '\n' };
-    write(fdDmesg, auditd_message, sizeof(auditd_message));
-}
-
-bool LogAudit::onDataAvailable(SocketClient* cli) {
-    if (!initialized) {
-        prctl(PR_SET_NAME, "logd.auditd");
-        initialized = true;
-    }
-
-    struct audit_message rep;
-
-    rep.nlh.nlmsg_type = 0;
-    rep.nlh.nlmsg_len = 0;
-    rep.data[0] = '\0';
-
-    if (audit_get_reply(cli->getSocket(), &rep, GET_REPLY_BLOCKING, 0) < 0) {
-        SLOGE("Failed on audit_get_reply with error: %s", strerror(errno));
-        return false;
-    }
-
-    logPrint("type=%d %.*s", rep.nlh.nlmsg_type, rep.nlh.nlmsg_len, rep.data);
-
-    return true;
-}
-
-static inline bool hasMetadata(char* str, int str_len) {
-    // need to check and see if str already contains bug metadata from
-    // possibility of stuttering if log audit crashes and then reloads kernel
-    // messages. Kernel denials that contain metadata will either end in
-    // "b/[0-9]+$" or "b/[0-9]+  duplicate messages suppressed$" which will put
-    // a '/' character at either 9 or 39 indices away from the end of the str.
-    return str_len >= 39 &&
-           (str[str_len - 9] == '/' || str[str_len - 39] == '/');
-}
-
-std::map<std::string, std::string> LogAudit::populateDenialMap() {
-    std::ifstream bug_file("/vendor/etc/selinux/selinux_denial_metadata");
-    std::string line;
-    // allocate a map for the static map pointer in auditParse to keep track of,
-    // this function only runs once
-    std::map<std::string, std::string> denial_to_bug;
-    if (bug_file.good()) {
-        std::string scontext;
-        std::string tcontext;
-        std::string tclass;
-        std::string bug_num;
-        while (std::getline(bug_file, line)) {
-            std::stringstream split_line(line);
-            split_line >> scontext >> tcontext >> tclass >> bug_num;
-            denial_to_bug.emplace(scontext + tcontext + tclass, bug_num);
-        }
-    }
-    return denial_to_bug;
-}
-
-std::string LogAudit::denialParse(const std::string& denial, char terminator,
-                                  const std::string& search_term) {
-    size_t start_index = denial.find(search_term);
-    if (start_index != std::string::npos) {
-        start_index += search_term.length();
-        return denial.substr(
-            start_index, denial.find(terminator, start_index) - start_index);
-    }
-    return "";
-}
-
-void LogAudit::auditParse(const std::string& string, uid_t uid,
-                          std::string* bug_num) {
-    static std::map<std::string, std::string> denial_to_bug =
-        populateDenialMap();
-    std::string scontext = denialParse(string, ':', "scontext=u:object_r:");
-    std::string tcontext = denialParse(string, ':', "tcontext=u:object_r:");
-    std::string tclass = denialParse(string, ' ', "tclass=");
-    if (scontext.empty()) {
-        scontext = denialParse(string, ':', "scontext=u:r:");
-    }
-    if (tcontext.empty()) {
-        tcontext = denialParse(string, ':', "tcontext=u:r:");
-    }
-    auto search = denial_to_bug.find(scontext + tcontext + tclass);
-    if (search != denial_to_bug.end()) {
-        bug_num->assign(" " + search->second);
-    } else {
-        bug_num->assign("");
-    }
-
-    // Ensure the uid name is not null before passing it to the bug string.
-    if (uid >= AID_APP_START && uid <= AID_APP_END) {
-        char* uidname = android::uidToName(uid);
-        if (uidname) {
-            bug_num->append(" app=");
-            bug_num->append(uidname);
-            free(uidname);
-        }
-    }
-}
-
-int LogAudit::logPrint(const char* fmt, ...) {
-    if (fmt == nullptr) {
-        return -EINVAL;
-    }
-
-    va_list args;
-
-    char* str = nullptr;
-    va_start(args, fmt);
-    int rc = vasprintf(&str, fmt, args);
-    va_end(args);
-
-    if (rc < 0) {
-        return rc;
-    }
-    char* cp;
-    // Work around kernels missing
-    // https://github.com/torvalds/linux/commit/b8f89caafeb55fba75b74bea25adc4e4cd91be67
-    // Such kernels improperly add newlines inside audit messages.
-    while ((cp = strchr(str, '\n'))) {
-        *cp = ' ';
-    }
-
-    while ((cp = strstr(str, "  "))) {
-        memmove(cp, cp + 1, strlen(cp + 1) + 1);
-    }
-    pid_t pid = getpid();
-    pid_t tid = gettid();
-    uid_t uid = AID_LOGD;
-    static const char pid_str[] = " pid=";
-    char* pidptr = strstr(str, pid_str);
-    if (pidptr && isdigit(pidptr[sizeof(pid_str) - 1])) {
-        cp = pidptr + sizeof(pid_str) - 1;
-        pid = 0;
-        while (isdigit(*cp)) {
-            pid = (pid * 10) + (*cp - '0');
-            ++cp;
-        }
-        tid = pid;
-        uid = stats_->PidToUid(pid);
-        memmove(pidptr, cp, strlen(cp) + 1);
-    }
-
-    bool info = strstr(str, " permissive=1") || strstr(str, " policy loaded ");
-    static std::string denial_metadata;
-    if ((fdDmesg >= 0) && initialized) {
-        struct iovec iov[4];
-        static const char log_info[] = { KMSG_PRIORITY(LOG_INFO) };
-        static const char log_warning[] = { KMSG_PRIORITY(LOG_WARNING) };
-        static const char newline[] = "\n";
-
-        auditParse(str, uid, &denial_metadata);
-        iov[0].iov_base = info ? const_cast<char*>(log_info) : const_cast<char*>(log_warning);
-        iov[0].iov_len = info ? sizeof(log_info) : sizeof(log_warning);
-        iov[1].iov_base = str;
-        iov[1].iov_len = strlen(str);
-        iov[2].iov_base = const_cast<char*>(denial_metadata.c_str());
-        iov[2].iov_len = denial_metadata.length();
-        iov[3].iov_base = const_cast<char*>(newline);
-        iov[3].iov_len = strlen(newline);
-
-        writev(fdDmesg, iov, arraysize(iov));
-    }
-
-    if (!main && !events) {
-        free(str);
-        return 0;
-    }
-
-    log_time now(log_time::EPOCH);
-
-    static const char audit_str[] = " audit(";
-    char* timeptr = strstr(str, audit_str);
-    if (timeptr && ((cp = now.strptime(timeptr + sizeof(audit_str) - 1, "%s.%q"))) &&
-        (*cp == ':')) {
-        memcpy(timeptr + sizeof(audit_str) - 1, "0.0", 3);
-        memmove(timeptr + sizeof(audit_str) - 1 + 3, cp, strlen(cp) + 1);
-    } else {
-        now = log_time(CLOCK_REALTIME);
-    }
-
-    // log to events
-
-    size_t str_len = strnlen(str, LOGGER_ENTRY_MAX_PAYLOAD);
-    if (((fdDmesg < 0) || !initialized) && !hasMetadata(str, str_len))
-        auditParse(str, uid, &denial_metadata);
-    str_len = (str_len + denial_metadata.length() <= LOGGER_ENTRY_MAX_PAYLOAD)
-                  ? str_len + denial_metadata.length()
-                  : LOGGER_ENTRY_MAX_PAYLOAD;
-    size_t message_len = str_len + sizeof(android_log_event_string_t);
-
-    unsigned int notify = 0;
-
-    if (events) {  // begin scope for event buffer
-        uint32_t buffer[(message_len + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
-
-        android_log_event_string_t* event =
-            reinterpret_cast<android_log_event_string_t*>(buffer);
-        event->header.tag = htole32(AUDITD_LOG_TAG);
-        event->type = EVENT_TYPE_STRING;
-        event->length = htole32(str_len);
-        memcpy(event->data, str, str_len - denial_metadata.length());
-        memcpy(event->data + str_len - denial_metadata.length(),
-               denial_metadata.c_str(), denial_metadata.length());
-
-        rc = logbuf->Log(LOG_ID_EVENTS, now, uid, pid, tid, reinterpret_cast<char*>(event),
-                         (message_len <= UINT16_MAX) ? (uint16_t)message_len : UINT16_MAX);
-        if (rc >= 0) {
-            notify |= 1 << LOG_ID_EVENTS;
-        }
-        // end scope for event buffer
-    }
-
-    // log to main
-
-    static const char comm_str[] = " comm=\"";
-    const char* comm = strstr(str, comm_str);
-    const char* estr = str + strlen(str);
-    const char* commfree = nullptr;
-    if (comm) {
-        estr = comm;
-        comm += sizeof(comm_str) - 1;
-    } else if (pid == getpid()) {
-        pid = tid;
-        comm = "auditd";
-    } else {
-        comm = commfree = stats_->PidToName(pid);
-        if (!comm) {
-            comm = "unknown";
-        }
-    }
-
-    const char* ecomm = strchr(comm, '"');
-    if (ecomm) {
-        ++ecomm;
-        str_len = ecomm - comm;
-    } else {
-        str_len = strlen(comm) + 1;
-        ecomm = "";
-    }
-    size_t prefix_len = estr - str;
-    if (prefix_len > LOGGER_ENTRY_MAX_PAYLOAD) {
-        prefix_len = LOGGER_ENTRY_MAX_PAYLOAD;
-    }
-    size_t suffix_len = strnlen(ecomm, LOGGER_ENTRY_MAX_PAYLOAD - prefix_len);
-    message_len =
-        str_len + prefix_len + suffix_len + denial_metadata.length() + 2;
-
-    if (main) {  // begin scope for main buffer
-        char newstr[message_len];
-
-        *newstr = info ? ANDROID_LOG_INFO : ANDROID_LOG_WARN;
-        strlcpy(newstr + 1, comm, str_len);
-        strncpy(newstr + 1 + str_len, str, prefix_len);
-        strncpy(newstr + 1 + str_len + prefix_len, ecomm, suffix_len);
-        strncpy(newstr + 1 + str_len + prefix_len + suffix_len,
-                denial_metadata.c_str(), denial_metadata.length());
-
-        rc = logbuf->Log(LOG_ID_MAIN, now, uid, pid, tid, newstr,
-                         (message_len <= UINT16_MAX) ? (uint16_t)message_len : UINT16_MAX);
-
-        if (rc >= 0) {
-            notify |= 1 << LOG_ID_MAIN;
-        }
-        // end scope for main buffer
-    }
-
-    free(const_cast<char*>(commfree));
-    free(str);
-
-    if (notify) {
-        if (rc < 0) {
-            rc = message_len;
-        }
-    }
-
-    return rc;
-}
-
-int LogAudit::log(char* buf, size_t len) {
-    char* audit = strstr(buf, " audit(");
-    if (!audit || (audit >= &buf[len])) {
-        return 0;
-    }
-
-    *audit = '\0';
-
-    int rc;
-    char* type = strstr(buf, "type=");
-    if (type && (type < &buf[len])) {
-        rc = logPrint("%s %s", type, audit + 1);
-    } else {
-        rc = logPrint("%s", audit + 1);
-    }
-    *audit = ' ';
-    return rc;
-}
-
-int LogAudit::getLogSocket() {
-    int fd = audit_open();
-    if (fd < 0) {
-        return fd;
-    }
-    if (audit_setup(fd, getpid()) < 0) {
-        audit_close(fd);
-        fd = -1;
-    }
-    return fd;
-}
diff --git a/logd/LogAudit.h b/logd/LogAudit.h
deleted file mode 100644
index 181920e..0000000
--- a/logd/LogAudit.h
+++ /dev/null
@@ -1,50 +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.
- */
-
-#pragma once
-
-#include <map>
-
-#include <sysutils/SocketListener.h>
-
-#include "LogBuffer.h"
-#include "LogStatistics.h"
-
-class LogAudit : public SocketListener {
-    LogBuffer* logbuf;
-    int fdDmesg;  // fdDmesg >= 0 is functionally bool dmesg
-    bool main;
-    bool events;
-    bool initialized;
-
-  public:
-    LogAudit(LogBuffer* buf, int fdDmesg, LogStatistics* stats);
-    int log(char* buf, size_t len);
-
-  protected:
-    virtual bool onDataAvailable(SocketClient* cli);
-
-  private:
-    static int getLogSocket();
-    std::map<std::string, std::string> populateDenialMap();
-    std::string denialParse(const std::string& denial, char terminator,
-                            const std::string& search_term);
-    void auditParse(const std::string& string, uid_t uid, std::string* bug_num);
-    int logPrint(const char* fmt, ...)
-        __attribute__((__format__(__printf__, 2, 3)));
-
-    LogStatistics* stats_;
-};
diff --git a/logd/LogBuffer.h b/logd/LogBuffer.h
deleted file mode 100644
index a98c4b9..0000000
--- a/logd/LogBuffer.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2020 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 <sys/types.h>
-
-#include <functional>
-
-#include <log/log.h>
-#include <log/log_read.h>
-
-#include "LogWriter.h"
-
-// A mask to represent which log buffers a reader is watching, values are (1 << LOG_ID_MAIN), etc.
-using LogMask = uint32_t;
-constexpr uint32_t kLogMaskAll = 0xFFFFFFFF;
-
-// State that a LogBuffer may want to persist across calls to FlushTo().
-class FlushToState {
-  public:
-    FlushToState(uint64_t start, LogMask log_mask) : start_(start), log_mask_(log_mask) {}
-    virtual ~FlushToState() {}
-
-    uint64_t start() const { return start_; }
-    void set_start(uint64_t start) { start_ = start; }
-
-    LogMask log_mask() const { return log_mask_; }
-
-  private:
-    uint64_t start_;
-    LogMask log_mask_;
-};
-
-// Enum for the return values of the `filter` function passed to FlushTo().
-enum class FilterResult {
-    kSkip,
-    kStop,
-    kWrite,
-};
-
-class LogBuffer {
-  public:
-    virtual ~LogBuffer() {}
-
-    virtual void Init() = 0;
-
-    virtual int Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
-                    const char* msg, uint16_t len) = 0;
-
-    virtual std::unique_ptr<FlushToState> CreateFlushToState(uint64_t start, LogMask log_mask) = 0;
-    virtual bool FlushTo(
-            LogWriter* writer, FlushToState& state,
-            const std::function<FilterResult(log_id_t log_id, pid_t pid, uint64_t sequence,
-                                             log_time realtime)>& filter) = 0;
-
-    virtual bool Clear(log_id_t id, uid_t uid) = 0;
-    virtual size_t GetSize(log_id_t id) = 0;
-    virtual bool SetSize(log_id_t id, size_t size) = 0;
-
-    virtual uint64_t sequence() const = 0;
-};
diff --git a/logd/LogBufferElement.cpp b/logd/LogBufferElement.cpp
deleted file mode 100644
index 26affa8..0000000
--- a/logd/LogBufferElement.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (C) 2012-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 "LogBufferElement.h"
-
-#include <ctype.h>
-#include <endian.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <log/log_read.h>
-#include <private/android_logger.h>
-
-#include "LogStatistics.h"
-#include "LogUtils.h"
-
-LogBufferElement::LogBufferElement(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
-                                   pid_t tid, uint64_t sequence, const char* msg, uint16_t len)
-    : uid_(uid),
-      pid_(pid),
-      tid_(tid),
-      sequence_(sequence),
-      realtime_(realtime),
-      msg_len_(len),
-      log_id_(log_id),
-      dropped_(false) {
-    msg_ = new char[len];
-    memcpy(msg_, msg, len);
-}
-
-LogBufferElement::LogBufferElement(const LogBufferElement& elem)
-    : uid_(elem.uid_),
-      pid_(elem.pid_),
-      tid_(elem.tid_),
-      sequence_(elem.sequence_),
-      realtime_(elem.realtime_),
-      msg_len_(elem.msg_len_),
-      log_id_(elem.log_id_),
-      dropped_(elem.dropped_) {
-    if (dropped_) {
-        tag_ = elem.GetTag();
-    } else {
-        msg_ = new char[msg_len_];
-        memcpy(msg_, elem.msg_, msg_len_);
-    }
-}
-
-LogBufferElement::LogBufferElement(LogBufferElement&& elem) noexcept
-    : uid_(elem.uid_),
-      pid_(elem.pid_),
-      tid_(elem.tid_),
-      sequence_(elem.sequence_),
-      realtime_(elem.realtime_),
-      msg_len_(elem.msg_len_),
-      log_id_(elem.log_id_),
-      dropped_(elem.dropped_) {
-    if (dropped_) {
-        tag_ = elem.GetTag();
-    } else {
-        msg_ = elem.msg_;
-        elem.msg_ = nullptr;
-    }
-}
-
-LogBufferElement::~LogBufferElement() {
-    if (!dropped_) {
-        delete[] msg_;
-    }
-}
-
-uint32_t LogBufferElement::GetTag() const {
-    // Binary buffers have no tag.
-    if (!IsBinary(log_id())) {
-        return 0;
-    }
-
-    // Dropped messages store the tag in place of msg_.
-    if (dropped_) {
-        return tag_;
-    }
-
-    return MsgToTag(msg(), msg_len());
-}
-
-LogStatisticsElement LogBufferElement::ToLogStatisticsElement() const {
-    // Estimate the size of this element in the parent std::list<> by adding two void*'s
-    // corresponding to the next/prev pointers and aligning to 64 bit.
-    uint16_t element_in_list_size =
-            (sizeof(*this) + 2 * sizeof(void*) + sizeof(uint64_t) - 1) & -sizeof(uint64_t);
-    return LogStatisticsElement{
-            .uid = uid(),
-            .pid = pid(),
-            .tid = tid(),
-            .tag = GetTag(),
-            .realtime = realtime(),
-            .msg = msg(),
-            .msg_len = msg_len(),
-            .dropped_count = dropped_count(),
-            .log_id = log_id(),
-            .total_len = static_cast<uint16_t>(element_in_list_size + msg_len()),
-    };
-}
-
-uint16_t LogBufferElement::SetDropped(uint16_t value) {
-    if (dropped_) {
-        return dropped_count_ = value;
-    }
-
-    // The tag information is saved in msg_ data, which is in a union with tag_, used after dropped_
-    // is set to true. Therefore we save the tag value aside, delete msg_, then set tag_ to the tag
-    // value in its place.
-    auto old_tag = GetTag();
-    delete[] msg_;
-    msg_ = nullptr;
-
-    tag_ = old_tag;
-    dropped_ = true;
-    return dropped_count_ = value;
-}
-
-// caller must own and free character string
-char* android::tidToName(pid_t tid) {
-    char* retval = nullptr;
-    char buffer[256];
-    snprintf(buffer, sizeof(buffer), "/proc/%u/comm", tid);
-    int fd = open(buffer, O_RDONLY | O_CLOEXEC);
-    if (fd >= 0) {
-        ssize_t ret = read(fd, buffer, sizeof(buffer));
-        if (ret >= (ssize_t)sizeof(buffer)) {
-            ret = sizeof(buffer) - 1;
-        }
-        while ((ret > 0) && isspace(buffer[ret - 1])) {
-            --ret;
-        }
-        if (ret > 0) {
-            buffer[ret] = '\0';
-            retval = strdup(buffer);
-        }
-        close(fd);
-    }
-
-    // if nothing for comm, check out cmdline
-    char* name = android::pidToName(tid);
-    if (!retval) {
-        retval = name;
-        name = nullptr;
-    }
-
-    // check if comm is truncated, see if cmdline has full representation
-    if (name) {
-        // impossible for retval to be NULL if name not NULL
-        size_t retval_len = strlen(retval);
-        size_t name_len = strlen(name);
-        // KISS: ToDo: Only checks prefix truncated, not suffix, or both
-        if ((retval_len < name_len) &&
-            !fastcmp<strcmp>(retval, name + name_len - retval_len)) {
-            free(retval);
-            retval = name;
-        } else {
-            free(name);
-        }
-    }
-    return retval;
-}
-
-// assumption: msg_ == NULL
-size_t LogBufferElement::PopulateDroppedMessage(char*& buffer, LogStatistics* stats,
-                                                bool lastSame) {
-    static const char tag[] = "chatty";
-
-    if (!__android_log_is_loggable_len(ANDROID_LOG_INFO, tag, strlen(tag),
-                                       ANDROID_LOG_VERBOSE)) {
-        return 0;
-    }
-
-    static const char format_uid[] = "uid=%u%s%s %s %u line%s";
-    const char* name = stats->UidToName(uid_);
-    const char* commName = android::tidToName(tid_);
-    if (!commName && (tid_ != pid_)) {
-        commName = android::tidToName(pid_);
-    }
-    if (!commName) {
-        commName = stats->PidToName(pid_);
-    }
-    if (name && name[0] && commName && (name[0] == commName[0])) {
-        size_t len = strlen(name + 1);
-        if (!strncmp(name + 1, commName + 1, len)) {
-            if (commName[len + 1] == '\0') {
-                free(const_cast<char*>(commName));
-                commName = nullptr;
-            } else {
-                free(const_cast<char*>(name));
-                name = nullptr;
-            }
-        }
-    }
-    if (name) {
-        char* buf = nullptr;
-        int result = asprintf(&buf, "(%s)", name);
-        if (result != -1) {
-            free(const_cast<char*>(name));
-            name = buf;
-        }
-    }
-    if (commName) {
-        char* buf = nullptr;
-        int result = asprintf(&buf, " %s", commName);
-        if (result != -1) {
-            free(const_cast<char*>(commName));
-            commName = buf;
-        }
-    }
-    // identical to below to calculate the buffer size required
-    const char* type = lastSame ? "identical" : "expire";
-    size_t len = snprintf(nullptr, 0, format_uid, uid_, name ? name : "", commName ? commName : "",
-                          type, dropped_count(), (dropped_count() > 1) ? "s" : "");
-
-    size_t hdrLen;
-    if (IsBinary(log_id())) {
-        hdrLen = sizeof(android_log_event_string_t);
-    } else {
-        hdrLen = 1 + sizeof(tag);
-    }
-
-    buffer = static_cast<char*>(calloc(1, hdrLen + len + 1));
-    if (!buffer) {
-        free(const_cast<char*>(name));
-        free(const_cast<char*>(commName));
-        return 0;
-    }
-
-    size_t retval = hdrLen + len;
-    if (IsBinary(log_id())) {
-        android_log_event_string_t* event =
-            reinterpret_cast<android_log_event_string_t*>(buffer);
-
-        event->header.tag = htole32(CHATTY_LOG_TAG);
-        event->type = EVENT_TYPE_STRING;
-        event->length = htole32(len);
-    } else {
-        ++retval;
-        buffer[0] = ANDROID_LOG_INFO;
-        strcpy(buffer + 1, tag);
-    }
-
-    snprintf(buffer + hdrLen, len + 1, format_uid, uid_, name ? name : "", commName ? commName : "",
-             type, dropped_count(), (dropped_count() > 1) ? "s" : "");
-    free(const_cast<char*>(name));
-    free(const_cast<char*>(commName));
-
-    return retval;
-}
-
-bool LogBufferElement::FlushTo(LogWriter* writer, LogStatistics* stats, bool lastSame) {
-    struct logger_entry entry = {};
-
-    entry.hdr_size = sizeof(struct logger_entry);
-    entry.lid = log_id_;
-    entry.pid = pid_;
-    entry.tid = tid_;
-    entry.uid = uid_;
-    entry.sec = realtime_.tv_sec;
-    entry.nsec = realtime_.tv_nsec;
-
-    char* buffer = nullptr;
-    const char* msg;
-    if (dropped_) {
-        entry.len = PopulateDroppedMessage(buffer, stats, lastSame);
-        if (!entry.len) return true;
-        msg = buffer;
-    } else {
-        msg = msg_;
-        entry.len = msg_len_;
-    }
-
-    bool retval = writer->Write(entry, msg);
-
-    if (buffer) free(buffer);
-
-    return retval;
-}
diff --git a/logd/LogBufferElement.h b/logd/LogBufferElement.h
deleted file mode 100644
index b263ca5..0000000
--- a/logd/LogBufferElement.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#include <log/log.h>
-
-#include "LogWriter.h"
-
-#include "LogStatistics.h"
-
-#define EXPIRE_HOUR_THRESHOLD 24  // Only expire chatty UID logs to preserve
-                                  // non-chatty UIDs less than this age in hours
-#define EXPIRE_THRESHOLD 10       // A smaller expire count is considered too
-                                  // chatty for the temporal expire messages
-#define EXPIRE_RATELIMIT 10  // maximum rate in seconds to report expiration
-
-class __attribute__((packed)) LogBufferElement {
-  public:
-    LogBufferElement(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
-                     uint64_t sequence, const char* msg, uint16_t len);
-    LogBufferElement(const LogBufferElement& elem);
-    LogBufferElement(LogBufferElement&& elem) noexcept;
-    ~LogBufferElement();
-
-    uint32_t GetTag() const;
-    uint16_t SetDropped(uint16_t value);
-
-    bool FlushTo(LogWriter* writer, LogStatistics* parent, bool lastSame);
-
-    LogStatisticsElement ToLogStatisticsElement() const;
-
-    log_id_t log_id() const { return static_cast<log_id_t>(log_id_); }
-    uid_t uid() const { return uid_; }
-    pid_t pid() const { return pid_; }
-    pid_t tid() const { return tid_; }
-    uint16_t msg_len() const { return dropped_ ? 0 : msg_len_; }
-    const char* msg() const { return dropped_ ? nullptr : msg_; }
-    uint64_t sequence() const { return sequence_; }
-    log_time realtime() const { return realtime_; }
-    uint16_t dropped_count() const { return dropped_ ? dropped_count_ : 0; }
-
-  private:
-    // assumption: mDropped == true
-    size_t PopulateDroppedMessage(char*& buffer, LogStatistics* parent, bool lastSame);
-
-    // sized to match reality of incoming log packets
-    const uint32_t uid_;
-    const uint32_t pid_;
-    const uint32_t tid_;
-    uint64_t sequence_;
-    log_time realtime_;
-    union {
-        char* msg_;    // mDropped == false
-        int32_t tag_;  // mDropped == true
-    };
-    union {
-        const uint16_t msg_len_;  // mDropped == false
-        uint16_t dropped_count_;  // mDropped == true
-    };
-    const uint8_t log_id_;
-    bool dropped_;
-};
diff --git a/logd/LogBufferTest.cpp b/logd/LogBufferTest.cpp
deleted file mode 100644
index 1911105..0000000
--- a/logd/LogBufferTest.cpp
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * Copyright (C) 2020 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 "LogBufferTest.h"
-
-#include <unistd.h>
-
-#include <limits>
-#include <memory>
-#include <regex>
-#include <vector>
-
-#include <android-base/stringprintf.h>
-#include <android-base/strings.h>
-
-#include "LogBuffer.h"
-#include "LogReaderThread.h"
-#include "LogWriter.h"
-
-using android::base::Join;
-using android::base::Split;
-using android::base::StringPrintf;
-
-char* android::uidToName(uid_t) {
-    return nullptr;
-}
-
-static std::vector<std::string> CompareLoggerEntries(const logger_entry& expected,
-                                                     const logger_entry& result, bool ignore_len) {
-    std::vector<std::string> errors;
-    if (!ignore_len && expected.len != result.len) {
-        errors.emplace_back(
-                StringPrintf("len: expected %" PRIu16 " vs %" PRIu16, expected.len, result.len));
-    }
-    if (expected.hdr_size != result.hdr_size) {
-        errors.emplace_back(StringPrintf("hdr_size: %" PRIu16 " vs %" PRIu16, expected.hdr_size,
-                                         result.hdr_size));
-    }
-    if (expected.pid != result.pid) {
-        errors.emplace_back(
-                StringPrintf("pid: expected %" PRIi32 " vs %" PRIi32, expected.pid, result.pid));
-    }
-    if (expected.tid != result.tid) {
-        errors.emplace_back(
-                StringPrintf("tid: expected %" PRIu32 " vs %" PRIu32, expected.tid, result.tid));
-    }
-    if (expected.sec != result.sec) {
-        errors.emplace_back(
-                StringPrintf("sec: expected %" PRIu32 " vs %" PRIu32, expected.sec, result.sec));
-    }
-    if (expected.nsec != result.nsec) {
-        errors.emplace_back(
-                StringPrintf("nsec: expected %" PRIu32 " vs %" PRIu32, expected.nsec, result.nsec));
-    }
-    if (expected.lid != result.lid) {
-        errors.emplace_back(
-                StringPrintf("lid: expected %" PRIu32 " vs %" PRIu32, expected.lid, result.lid));
-    }
-    if (expected.uid != result.uid) {
-        errors.emplace_back(
-                StringPrintf("uid: expected %" PRIu32 " vs %" PRIu32, expected.uid, result.uid));
-    }
-    return errors;
-}
-
-static std::string MakePrintable(std::string in) {
-    if (in.size() > 80) {
-        in = in.substr(0, 80) + "...";
-    }
-    std::string result;
-    for (const char c : in) {
-        if (isprint(c)) {
-            result.push_back(c);
-        } else {
-            result.append(StringPrintf("\\%02x", static_cast<int>(c) & 0xFF));
-        }
-    }
-    return result;
-}
-
-static std::string CompareMessages(const std::string& expected, const std::string& result) {
-    if (expected == result) {
-        return {};
-    }
-    size_t diff_index = 0;
-    for (; diff_index < std::min(expected.size(), result.size()); ++diff_index) {
-        if (expected[diff_index] != result[diff_index]) {
-            break;
-        }
-    }
-
-    if (diff_index < 80) {
-        auto expected_short = MakePrintable(expected);
-        auto result_short = MakePrintable(result);
-        return StringPrintf("msg: expected '%s' vs '%s'", expected_short.c_str(),
-                            result_short.c_str());
-    }
-
-    auto expected_short = MakePrintable(expected.substr(diff_index));
-    auto result_short = MakePrintable(result.substr(diff_index));
-    return StringPrintf("msg: index %zu: expected '%s' vs '%s'", diff_index, expected_short.c_str(),
-                        result_short.c_str());
-}
-
-static std::string CompareRegexMessages(const std::string& expected, const std::string& result) {
-    auto expected_pieces = Split(expected, std::string("\0", 1));
-    auto result_pieces = Split(result, std::string("\0", 1));
-
-    if (expected_pieces.size() != 3 || result_pieces.size() != 3) {
-        return StringPrintf(
-                "msg: should have 3 null delimited strings found %d in expected, %d in result: "
-                "'%s' vs '%s'",
-                static_cast<int>(expected_pieces.size()), static_cast<int>(result_pieces.size()),
-                MakePrintable(expected).c_str(), MakePrintable(result).c_str());
-    }
-    if (expected_pieces[0] != result_pieces[0]) {
-        return StringPrintf("msg: tag/priority mismatch expected '%s' vs '%s'",
-                            MakePrintable(expected_pieces[0]).c_str(),
-                            MakePrintable(result_pieces[0]).c_str());
-    }
-    std::regex expected_tag_regex(expected_pieces[1]);
-    if (!std::regex_search(result_pieces[1], expected_tag_regex)) {
-        return StringPrintf("msg: message regex mismatch expected '%s' vs '%s'",
-                            MakePrintable(expected_pieces[1]).c_str(),
-                            MakePrintable(result_pieces[1]).c_str());
-    }
-    if (expected_pieces[2] != result_pieces[2]) {
-        return StringPrintf("msg: nothing expected after final null character '%s' vs '%s'",
-                            MakePrintable(expected_pieces[2]).c_str(),
-                            MakePrintable(result_pieces[2]).c_str());
-    }
-    return {};
-}
-
-void CompareLogMessages(const std::vector<LogMessage>& expected,
-                        const std::vector<LogMessage>& result) {
-    EXPECT_EQ(expected.size(), result.size());
-    size_t end = std::min(expected.size(), result.size());
-    size_t num_errors = 0;
-    for (size_t i = 0; i < end; ++i) {
-        auto errors =
-                CompareLoggerEntries(expected[i].entry, result[i].entry, expected[i].regex_compare);
-        auto msg_error = expected[i].regex_compare
-                                 ? CompareRegexMessages(expected[i].message, result[i].message)
-                                 : CompareMessages(expected[i].message, result[i].message);
-        if (!msg_error.empty()) {
-            errors.emplace_back(msg_error);
-        }
-        if (!errors.empty()) {
-            GTEST_LOG_(ERROR) << "Mismatch log message " << i << "\n" << Join(errors, "\n");
-            ++num_errors;
-        }
-    }
-    EXPECT_EQ(0U, num_errors);
-}
-
-void FixupMessages(std::vector<LogMessage>* messages) {
-    for (auto& [entry, message, _] : *messages) {
-        entry.hdr_size = sizeof(logger_entry);
-        entry.len = message.size();
-    }
-}
-
-TEST_P(LogBufferTest, smoke) {
-    std::vector<LogMessage> log_messages = {
-            {{
-                     .pid = 1,
-                     .tid = 1,
-                     .sec = 1234,
-                     .nsec = 323001,
-                     .lid = LOG_ID_MAIN,
-                     .uid = 0,
-             },
-             "smoke test"},
-    };
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, nullptr));
-    std::unique_ptr<FlushToState> flush_to_state = log_buffer_->CreateFlushToState(1, kLogMaskAll);
-    EXPECT_TRUE(log_buffer_->FlushTo(test_writer.get(), *flush_to_state, nullptr));
-    EXPECT_EQ(2ULL, flush_to_state->start());
-    CompareLogMessages(log_messages, read_log_messages);
-}
-
-TEST_P(LogBufferTest, smoke_with_reader_thread) {
-    std::vector<LogMessage> log_messages = {
-            {{.pid = 1, .tid = 2, .sec = 10000, .nsec = 20001, .lid = LOG_ID_MAIN, .uid = 0},
-             "first"},
-            {{.pid = 10, .tid = 2, .sec = 10000, .nsec = 20002, .lid = LOG_ID_MAIN, .uid = 0},
-             "second"},
-            {{.pid = 100, .tid = 2, .sec = 10000, .nsec = 20003, .lid = LOG_ID_KERNEL, .uid = 0},
-             "third"},
-            {{.pid = 10, .tid = 2, .sec = 10000, .nsec = 20004, .lid = LOG_ID_MAIN, .uid = 0},
-             "fourth"},
-            {{.pid = 1, .tid = 2, .sec = 10000, .nsec = 20005, .lid = LOG_ID_RADIO, .uid = 0},
-             "fifth"},
-            {{.pid = 2, .tid = 2, .sec = 10000, .nsec = 20006, .lid = LOG_ID_RADIO, .uid = 0},
-             "sixth"},
-            {{.pid = 3, .tid = 2, .sec = 10000, .nsec = 20007, .lid = LOG_ID_RADIO, .uid = 0},
-             "seventh"},
-            {{.pid = 4, .tid = 2, .sec = 10000, .nsec = 20008, .lid = LOG_ID_MAIN, .uid = 0},
-             "eighth"},
-            {{.pid = 5, .tid = 2, .sec = 10000, .nsec = 20009, .lid = LOG_ID_CRASH, .uid = 0},
-             "nineth"},
-            {{.pid = 6, .tid = 2, .sec = 10000, .nsec = 20011, .lid = LOG_ID_MAIN, .uid = 0},
-             "tenth"},
-    };
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    bool released = false;
-
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, &released));
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer_.get(), &reader_list_, std::move(test_writer), true,
-                                    0, kLogMaskAll, 0, {}, 1, {}));
-        reader_list_.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    while (!released) {
-        usleep(5000);
-    }
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        EXPECT_EQ(0U, reader_list_.reader_threads().size());
-    }
-    CompareLogMessages(log_messages, read_log_messages);
-}
-
-// Generate random messages, set the 'sec' parameter explicit though, to be able to track the
-// expected order of messages.
-LogMessage GenerateRandomLogMessage(uint32_t sec) {
-    auto rand_uint32 = [](int max) -> uint32_t { return rand() % max; };
-    logger_entry entry = {
-            .hdr_size = sizeof(logger_entry),
-            .pid = rand() % 5000,
-            .tid = rand_uint32(5000),
-            .sec = sec,
-            .nsec = rand_uint32(NS_PER_SEC),
-            .lid = rand_uint32(LOG_ID_STATS),
-            .uid = rand_uint32(100000),
-    };
-
-    // See comment in ChattyLogBuffer::Log() for why this is disallowed.
-    if (entry.nsec % 1000 == 0) {
-        ++entry.nsec;
-    }
-
-    if (entry.lid == LOG_ID_EVENTS) {
-        entry.lid = LOG_ID_KERNEL;
-    }
-
-    std::string message;
-    char priority = ANDROID_LOG_INFO + rand() % 2;
-    message.push_back(priority);
-
-    int tag_length = 2 + rand() % 10;
-    for (int i = 0; i < tag_length; ++i) {
-        message.push_back('a' + rand() % 26);
-    }
-    message.push_back('\0');
-
-    int msg_length = 2 + rand() % 1000;
-    for (int i = 0; i < msg_length; ++i) {
-        message.push_back('a' + rand() % 26);
-    }
-    message.push_back('\0');
-
-    entry.len = message.size();
-
-    return {entry, message};
-}
-
-TEST_P(LogBufferTest, random_messages) {
-    srand(1);
-    std::vector<LogMessage> log_messages;
-    for (size_t i = 0; i < 1000; ++i) {
-        log_messages.emplace_back(GenerateRandomLogMessage(i));
-    }
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    bool released = false;
-
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, &released));
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer_.get(), &reader_list_, std::move(test_writer), true,
-                                    0, kLogMaskAll, 0, {}, 1, {}));
-        reader_list_.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    while (!released) {
-        usleep(5000);
-    }
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        EXPECT_EQ(0U, reader_list_.reader_threads().size());
-    }
-    CompareLogMessages(log_messages, read_log_messages);
-}
-
-TEST_P(LogBufferTest, read_last_sequence) {
-    std::vector<LogMessage> log_messages = {
-            {{.pid = 1, .tid = 2, .sec = 10000, .nsec = 20001, .lid = LOG_ID_MAIN, .uid = 0},
-             "first"},
-            {{.pid = 10, .tid = 2, .sec = 10000, .nsec = 20002, .lid = LOG_ID_MAIN, .uid = 0},
-             "second"},
-            {{.pid = 100, .tid = 2, .sec = 10000, .nsec = 20003, .lid = LOG_ID_MAIN, .uid = 0},
-             "third"},
-    };
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    bool released = false;
-
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, &released));
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer_.get(), &reader_list_, std::move(test_writer), true,
-                                    0, kLogMaskAll, 0, {}, 3, {}));
-        reader_list_.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    while (!released) {
-        usleep(5000);
-    }
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        EXPECT_EQ(0U, reader_list_.reader_threads().size());
-    }
-    std::vector<LogMessage> expected_log_messages = {log_messages.back()};
-    CompareLogMessages(expected_log_messages, read_log_messages);
-}
-
-TEST_P(LogBufferTest, clear_logs) {
-    // Log 3 initial logs.
-    std::vector<LogMessage> log_messages = {
-            {{.pid = 1, .tid = 2, .sec = 10000, .nsec = 20001, .lid = LOG_ID_MAIN, .uid = 0},
-             "first"},
-            {{.pid = 10, .tid = 2, .sec = 10000, .nsec = 20002, .lid = LOG_ID_MAIN, .uid = 0},
-             "second"},
-            {{.pid = 100, .tid = 2, .sec = 10000, .nsec = 20003, .lid = LOG_ID_MAIN, .uid = 0},
-             "third"},
-    };
-    FixupMessages(&log_messages);
-    LogMessages(log_messages);
-
-    std::vector<LogMessage> read_log_messages;
-    bool released = false;
-
-    // Connect a blocking reader.
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages, &released));
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer_.get(), &reader_list_, std::move(test_writer), false,
-                                    0, kLogMaskAll, 0, {}, 1, {}));
-        reader_list_.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    // Wait up to 250ms for the reader to read the first 3 logs.
-    constexpr int kMaxRetryCount = 50;
-    int count = 0;
-    for (; count < kMaxRetryCount; ++count) {
-        usleep(5000);
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        if (reader_list_.reader_threads().back()->start() == 4) {
-            break;
-        }
-    }
-    ASSERT_LT(count, kMaxRetryCount);
-
-    // Clear the log buffer.
-    log_buffer_->Clear(LOG_ID_MAIN, 0);
-
-    // Log 3 more logs.
-    std::vector<LogMessage> after_clear_messages = {
-            {{.pid = 1, .tid = 2, .sec = 10000, .nsec = 20001, .lid = LOG_ID_MAIN, .uid = 0},
-             "4th"},
-            {{.pid = 10, .tid = 2, .sec = 10000, .nsec = 20002, .lid = LOG_ID_MAIN, .uid = 0},
-             "5th"},
-            {{.pid = 100, .tid = 2, .sec = 10000, .nsec = 20003, .lid = LOG_ID_MAIN, .uid = 0},
-             "6th"},
-    };
-    FixupMessages(&after_clear_messages);
-    LogMessages(after_clear_messages);
-
-    // Wait up to 250ms for the reader to read the 3 additional logs.
-    for (count = 0; count < kMaxRetryCount; ++count) {
-        usleep(5000);
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        if (reader_list_.reader_threads().back()->start() == 7) {
-            break;
-        }
-    }
-    ASSERT_LT(count, kMaxRetryCount);
-
-    // Release the reader, wait for it to get the signal then check that it has been deleted.
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        reader_list_.reader_threads().back()->release_Locked();
-    }
-    while (!released) {
-        usleep(5000);
-    }
-    {
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        EXPECT_EQ(0U, reader_list_.reader_threads().size());
-    }
-
-    // Check that we have read all 6 messages.
-    std::vector<LogMessage> expected_log_messages = log_messages;
-    expected_log_messages.insert(expected_log_messages.end(), after_clear_messages.begin(),
-                                 after_clear_messages.end());
-    CompareLogMessages(expected_log_messages, read_log_messages);
-
-    // Finally, call FlushTo and ensure that only the 3 logs after the clear remain in the buffer.
-    std::vector<LogMessage> read_log_messages_after_clear;
-    std::unique_ptr<LogWriter> test_writer(new TestWriter(&read_log_messages_after_clear, nullptr));
-    std::unique_ptr<FlushToState> flush_to_state = log_buffer_->CreateFlushToState(1, kLogMaskAll);
-    EXPECT_TRUE(log_buffer_->FlushTo(test_writer.get(), *flush_to_state, nullptr));
-    EXPECT_EQ(7ULL, flush_to_state->start());
-    CompareLogMessages(after_clear_messages, read_log_messages_after_clear);
-}
-
-INSTANTIATE_TEST_CASE_P(LogBufferTests, LogBufferTest,
-                        testing::Values("chatty", "serialized", "simple"));
diff --git a/logd/LogBufferTest.h b/logd/LogBufferTest.h
deleted file mode 100644
index eeeb980..0000000
--- a/logd/LogBufferTest.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2020 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 <gtest/gtest.h>
-
-#include "ChattyLogBuffer.h"
-#include "LogReaderList.h"
-#include "LogStatistics.h"
-#include "LogTags.h"
-#include "PruneList.h"
-#include "SerializedLogBuffer.h"
-#include "SimpleLogBuffer.h"
-
-struct LogMessage {
-    logger_entry entry;
-    std::string message;
-    bool regex_compare = false;  // Only set for expected messages, when true 'message' should be
-                                 // interpretted as a regex.
-};
-
-// Compares the ordered list of expected and result, causing a test failure with appropriate
-// information on failure.
-void CompareLogMessages(const std::vector<LogMessage>& expected,
-                        const std::vector<LogMessage>& result);
-// Sets hdr_size and len parameters appropriately.
-void FixupMessages(std::vector<LogMessage>* messages);
-
-class TestWriter : public LogWriter {
-  public:
-    TestWriter(std::vector<LogMessage>* msgs, bool* released)
-        : LogWriter(0, true), msgs_(msgs), released_(released) {}
-    bool Write(const logger_entry& entry, const char* message) override {
-        msgs_->emplace_back(LogMessage{entry, std::string(message, entry.len), false});
-        return true;
-    }
-
-    void Release() {
-        if (released_) *released_ = true;
-    }
-
-    std::string name() const override { return "test_writer"; }
-
-  private:
-    std::vector<LogMessage>* msgs_;
-    bool* released_;
-};
-
-class LogBufferTest : public testing::TestWithParam<std::string> {
-  protected:
-    void SetUp() override {
-        if (GetParam() == "chatty") {
-            log_buffer_.reset(new ChattyLogBuffer(&reader_list_, &tags_, &prune_, &stats_));
-        } else if (GetParam() == "serialized") {
-            log_buffer_.reset(new SerializedLogBuffer(&reader_list_, &tags_, &stats_));
-        } else if (GetParam() == "simple") {
-            log_buffer_.reset(new SimpleLogBuffer(&reader_list_, &tags_, &stats_));
-        } else {
-            FAIL() << "Unknown buffer type selected for test";
-        }
-
-        log_id_for_each(i) { log_buffer_->SetSize(i, 1024 * 1024); }
-    }
-
-    void LogMessages(const std::vector<LogMessage>& messages) {
-        for (auto& [entry, message, _] : messages) {
-            log_buffer_->Log(static_cast<log_id_t>(entry.lid), log_time(entry.sec, entry.nsec),
-                             entry.uid, entry.pid, entry.tid, message.c_str(), message.size());
-        }
-    }
-
-    LogReaderList reader_list_;
-    LogTags tags_;
-    PruneList prune_;
-    LogStatistics stats_{false, true};
-    std::unique_ptr<LogBuffer> log_buffer_;
-};
diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp
deleted file mode 100644
index d6c7d25..0000000
--- a/logd/LogKlog.cpp
+++ /dev/null
@@ -1,772 +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 "LogKlog.h"
-
-#include <ctype.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/prctl.h>
-#include <sys/uio.h>
-#include <syslog.h>
-
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-
-#include "LogBuffer.h"
-
-#define KMSG_PRIORITY(PRI) \
-    '<', '0' + (LOG_SYSLOG | (PRI)) / 10, '0' + (LOG_SYSLOG | (PRI)) % 10, '>'
-
-static const char priority_message[] = { KMSG_PRIORITY(LOG_INFO), '\0' };
-
-// List of the _only_ needles we supply here to android::strnstr
-static const char suspendStr[] = "PM: suspend entry ";
-static const char resumeStr[] = "PM: suspend exit ";
-static const char suspendedStr[] = "Suspended for ";
-static const char healthdStr[] = "healthd";
-static const char batteryStr[] = ": battery ";
-static const char auditStr[] = " audit(";
-static const char klogdStr[] = "logd.klogd: ";
-
-// Parsing is hard
-
-// called if we see a '<', s is the next character, returns pointer after '>'
-static char* is_prio(char* s, ssize_t len) {
-    if ((len <= 0) || !isdigit(*s++)) return nullptr;
-    --len;
-    static const size_t max_prio_len = (len < 4) ? len : 4;
-    size_t priolen = 0;
-    char c;
-    while (((c = *s++)) && (++priolen <= max_prio_len)) {
-        if (!isdigit(c)) return ((c == '>') && (*s == '[')) ? s : nullptr;
-    }
-    return nullptr;
-}
-
-// called if we see a '[', s is the next character, returns pointer after ']'
-static char* is_timestamp(char* s, ssize_t len) {
-    while ((len > 0) && (*s == ' ')) {
-        ++s;
-        --len;
-    }
-    if ((len <= 0) || !isdigit(*s++)) return nullptr;
-    --len;
-    bool first_period = true;
-    char c;
-    while ((len > 0) && ((c = *s++))) {
-        --len;
-        if ((c == '.') && first_period) {
-            first_period = false;
-        } else if (!isdigit(c)) {
-            return ((c == ']') && !first_period && (*s == ' ')) ? s : nullptr;
-        }
-    }
-    return nullptr;
-}
-
-// Like strtok_r with "\r\n" except that we look for log signatures (regex)
-//  \(\(<[0-9]\{1,4\}>\)\([[] *[0-9]+[.][0-9]+[]] \)\{0,1\}\|[[]
-//  *[0-9]+[.][0-9]+[]] \)
-// and split if we see a second one without a newline.
-// We allow nuls in content, monitoring the overall length and sub-length of
-// the discovered tokens.
-
-#define SIGNATURE_MASK 0xF0
-// <digit> following ('0' to '9' masked with ~SIGNATURE_MASK) added to signature
-#define LESS_THAN_SIG SIGNATURE_MASK
-#define OPEN_BRACKET_SIG ((SIGNATURE_MASK << 1) & SIGNATURE_MASK)
-// space is one more than <digit> of 9
-#define OPEN_BRACKET_SPACE ((char)(OPEN_BRACKET_SIG | 10))
-
-char* android::log_strntok_r(char* s, ssize_t& len, char*& last,
-                             ssize_t& sublen) {
-    sublen = 0;
-    if (len <= 0) return nullptr;
-    if (!s) {
-        if (!(s = last)) return nullptr;
-        // fixup for log signature split <,
-        // LESS_THAN_SIG + <digit>
-        if ((*s & SIGNATURE_MASK) == LESS_THAN_SIG) {
-            *s = (*s & ~SIGNATURE_MASK) + '0';
-            *--s = '<';
-            ++len;
-        }
-        // fixup for log signature split [,
-        // OPEN_BRACKET_SPACE is space, OPEN_BRACKET_SIG + <digit>
-        if ((*s & SIGNATURE_MASK) == OPEN_BRACKET_SIG) {
-            *s = (*s == OPEN_BRACKET_SPACE) ? ' ' : (*s & ~SIGNATURE_MASK) + '0';
-            *--s = '[';
-            ++len;
-        }
-    }
-
-    while ((len > 0) && ((*s == '\r') || (*s == '\n'))) {
-        ++s;
-        --len;
-    }
-
-    if (len <= 0) return last = nullptr;
-    char *peek, *tok = s;
-
-    for (;;) {
-        if (len <= 0) {
-            last = nullptr;
-            return tok;
-        }
-        char c = *s++;
-        --len;
-        ssize_t adjust;
-        switch (c) {
-            case '\r':
-            case '\n':
-                s[-1] = '\0';
-                last = s;
-                return tok;
-
-            case '<':
-                peek = is_prio(s, len);
-                if (!peek) break;
-                if (s != (tok + 1)) {  // not first?
-                    s[-1] = '\0';
-                    *s &= ~SIGNATURE_MASK;
-                    *s |= LESS_THAN_SIG;  // signature for '<'
-                    last = s;
-                    return tok;
-                }
-                adjust = peek - s;
-                if (adjust > len) {
-                    adjust = len;
-                }
-                sublen += adjust;
-                len -= adjust;
-                s = peek;
-                if ((*s == '[') && ((peek = is_timestamp(s + 1, len - 1)))) {
-                    adjust = peek - s;
-                    if (adjust > len) {
-                        adjust = len;
-                    }
-                    sublen += adjust;
-                    len -= adjust;
-                    s = peek;
-                }
-                break;
-
-            case '[':
-                peek = is_timestamp(s, len);
-                if (!peek) break;
-                if (s != (tok + 1)) {  // not first?
-                    s[-1] = '\0';
-                    if (*s == ' ') {
-                        *s = OPEN_BRACKET_SPACE;
-                    } else {
-                        *s &= ~SIGNATURE_MASK;
-                        *s |= OPEN_BRACKET_SIG;  // signature for '['
-                    }
-                    last = s;
-                    return tok;
-                }
-                adjust = peek - s;
-                if (adjust > len) {
-                    adjust = len;
-                }
-                sublen += adjust;
-                len -= adjust;
-                s = peek;
-                break;
-        }
-        ++sublen;
-    }
-    // NOTREACHED
-}
-
-log_time LogKlog::correction = (log_time(CLOCK_REALTIME) < log_time(CLOCK_MONOTONIC))
-                                       ? log_time(log_time::EPOCH)
-                                       : (log_time(CLOCK_REALTIME) - log_time(CLOCK_MONOTONIC));
-
-LogKlog::LogKlog(LogBuffer* buf, int fdWrite, int fdRead, bool auditd, LogStatistics* stats)
-    : SocketListener(fdRead, false),
-      logbuf(buf),
-      signature(CLOCK_MONOTONIC),
-      initialized(false),
-      enableLogging(true),
-      auditd(auditd),
-      stats_(stats) {
-    static const char klogd_message[] = "%s%s%" PRIu64 "\n";
-    char buffer[strlen(priority_message) + strlen(klogdStr) +
-                strlen(klogd_message) + 20];
-    snprintf(buffer, sizeof(buffer), klogd_message, priority_message, klogdStr,
-             signature.nsec());
-    write(fdWrite, buffer, strlen(buffer));
-}
-
-bool LogKlog::onDataAvailable(SocketClient* cli) {
-    if (!initialized) {
-        prctl(PR_SET_NAME, "logd.klogd");
-        initialized = true;
-        enableLogging = false;
-    }
-
-    char buffer[LOGGER_ENTRY_MAX_PAYLOAD];
-    ssize_t len = 0;
-
-    for (;;) {
-        ssize_t retval = 0;
-        if (len < (ssize_t)(sizeof(buffer) - 1)) {
-            retval =
-                read(cli->getSocket(), buffer + len, sizeof(buffer) - 1 - len);
-        }
-        if ((retval == 0) && (len <= 0)) {
-            break;
-        }
-        if (retval < 0) {
-            return false;
-        }
-        len += retval;
-        bool full = len == (sizeof(buffer) - 1);
-        char* ep = buffer + len;
-        *ep = '\0';
-        ssize_t sublen;
-        for (char *ptr = nullptr, *tok = buffer;
-             !!(tok = android::log_strntok_r(tok, len, ptr, sublen));
-             tok = nullptr) {
-            if (((tok + sublen) >= ep) && (retval != 0) && full) {
-                if (sublen > 0) memmove(buffer, tok, sublen);
-                len = sublen;
-                break;
-            }
-            if ((sublen > 0) && *tok) {
-                log(tok, sublen);
-            }
-        }
-    }
-
-    return true;
-}
-
-void LogKlog::calculateCorrection(const log_time& monotonic,
-                                  const char* real_string, ssize_t len) {
-    static const char real_format[] = "%Y-%m-%d %H:%M:%S.%09q UTC";
-    if (len < (ssize_t)(strlen(real_format) + 5)) return;
-
-    log_time real(log_time::EPOCH);
-    const char* ep = real.strptime(real_string, real_format);
-    if (!ep || (ep > &real_string[len]) || (real > log_time(CLOCK_REALTIME))) {
-        return;
-    }
-    // kernel report UTC, log_time::strptime is localtime from calendar.
-    // Bionic and liblog strptime does not support %z or %Z to pick up
-    // timezone so we are calculating our own correction.
-    time_t now = real.tv_sec;
-    struct tm tm;
-    memset(&tm, 0, sizeof(tm));
-    tm.tm_isdst = -1;
-    localtime_r(&now, &tm);
-    if ((tm.tm_gmtoff < 0) && ((-tm.tm_gmtoff) > (long)real.tv_sec)) {
-        real = log_time(log_time::EPOCH);
-    } else {
-        real.tv_sec += tm.tm_gmtoff;
-    }
-    if (monotonic > real) {
-        correction = log_time(log_time::EPOCH);
-    } else {
-        correction = real - monotonic;
-    }
-}
-
-log_time LogKlog::sniffTime(const char*& buf, ssize_t len, bool reverse) {
-    log_time now(log_time::EPOCH);
-    if (len <= 0) return now;
-
-    const char* cp = nullptr;
-    if ((len > 10) && (*buf == '[')) {
-        cp = now.strptime(buf, "[ %s.%q]");  // can index beyond buffer bounds
-        if (cp && (cp > &buf[len - 1])) cp = nullptr;
-    }
-    if (cp) {
-        len -= cp - buf;
-        if ((len > 0) && isspace(*cp)) {
-            ++cp;
-            --len;
-        }
-        buf = cp;
-
-        const char* b;
-        if (((b = android::strnstr(cp, len, suspendStr))) &&
-            (((b += strlen(suspendStr)) - cp) < len)) {
-            len -= b - cp;
-            calculateCorrection(now, b, len);
-        } else if (((b = android::strnstr(cp, len, resumeStr))) &&
-                   (((b += strlen(resumeStr)) - cp) < len)) {
-            len -= b - cp;
-            calculateCorrection(now, b, len);
-        } else if (((b = android::strnstr(cp, len, healthdStr))) &&
-                   (((b += strlen(healthdStr)) - cp) < len) &&
-                   ((b = android::strnstr(b, len -= b - cp, batteryStr))) &&
-                   (((b += strlen(batteryStr)) - cp) < len)) {
-            // NB: healthd is roughly 150us late, so we use it instead to
-            //     trigger a check for ntp-induced or hardware clock drift.
-            log_time real(CLOCK_REALTIME);
-            log_time mono(CLOCK_MONOTONIC);
-            correction = (real < mono) ? log_time(log_time::EPOCH) : (real - mono);
-        } else if (((b = android::strnstr(cp, len, suspendedStr))) &&
-                   (((b += strlen(suspendStr)) - cp) < len)) {
-            len -= b - cp;
-            log_time real(log_time::EPOCH);
-            char* endp;
-            real.tv_sec = strtol(b, &endp, 10);
-            if ((*endp == '.') && ((endp - b) < len)) {
-                unsigned long multiplier = NS_PER_SEC;
-                real.tv_nsec = 0;
-                len -= endp - b;
-                while (--len && isdigit(*++endp) && (multiplier /= 10)) {
-                    real.tv_nsec += (*endp - '0') * multiplier;
-                }
-                if (reverse) {
-                    if (real > correction) {
-                        correction = log_time(log_time::EPOCH);
-                    } else {
-                        correction -= real;
-                    }
-                } else {
-                    correction += real;
-                }
-            }
-        }
-
-        convertMonotonicToReal(now);
-    } else {
-        now = log_time(CLOCK_REALTIME);
-    }
-    return now;
-}
-
-pid_t LogKlog::sniffPid(const char*& buf, ssize_t len) {
-    if (len <= 0) return 0;
-
-    const char* cp = buf;
-    // sscanf does a strlen, let's check if the string is not nul terminated.
-    // pseudo out-of-bounds access since we always have an extra char on buffer.
-    if (((ssize_t)strnlen(cp, len) == len) && cp[len]) {
-        return 0;
-    }
-    // HTC kernels with modified printk "c0   1648 "
-    if ((len > 9) && (cp[0] == 'c') && isdigit(cp[1]) &&
-        (isdigit(cp[2]) || (cp[2] == ' ')) && (cp[3] == ' ')) {
-        bool gotDigit = false;
-        int i;
-        for (i = 4; i < 9; ++i) {
-            if (isdigit(cp[i])) {
-                gotDigit = true;
-            } else if (gotDigit || (cp[i] != ' ')) {
-                break;
-            }
-        }
-        if ((i == 9) && (cp[i] == ' ')) {
-            int pid = 0;
-            char placeholder;
-            if (sscanf(cp + 4, "%d%c", &pid, &placeholder) == 2) {
-                buf = cp + 10;  // skip-it-all
-                return pid;
-            }
-        }
-    }
-    while (len) {
-        // Mediatek kernels with modified printk
-        if (*cp == '[') {
-            int pid = 0;
-            char placeholder;
-            if (sscanf(cp, "[%d:%*[a-z_./0-9:A-Z]]%c", &pid, &placeholder) == 2) {
-                return pid;
-            }
-            break;  // Only the first one
-        }
-        ++cp;
-        --len;
-    }
-    return 0;
-}
-
-// kernel log prefix, convert to a kernel log priority number
-static int parseKernelPrio(const char*& buf, ssize_t len) {
-    int pri = LOG_USER | LOG_INFO;
-    const char* cp = buf;
-    if ((len > 0) && (*cp == '<')) {
-        pri = 0;
-        while (--len && isdigit(*++cp)) {
-            pri = (pri * 10) + *cp - '0';
-        }
-        if ((len > 0) && (*cp == '>')) {
-            ++cp;
-        } else {
-            cp = buf;
-            pri = LOG_USER | LOG_INFO;
-        }
-        buf = cp;
-    }
-    return pri;
-}
-
-// Convert kernel log priority number into an Android Logger priority number
-static int convertKernelPrioToAndroidPrio(int pri) {
-    switch (pri & LOG_PRIMASK) {
-        case LOG_EMERG:
-        case LOG_ALERT:
-        case LOG_CRIT:
-            return ANDROID_LOG_FATAL;
-
-        case LOG_ERR:
-            return ANDROID_LOG_ERROR;
-
-        case LOG_WARNING:
-            return ANDROID_LOG_WARN;
-
-        default:
-        case LOG_NOTICE:
-        case LOG_INFO:
-            break;
-
-        case LOG_DEBUG:
-            return ANDROID_LOG_DEBUG;
-    }
-
-    return ANDROID_LOG_INFO;
-}
-
-static const char* strnrchr(const char* s, ssize_t len, char c) {
-    const char* save = nullptr;
-    for (; len > 0; ++s, len--) {
-        if (*s == c) {
-            save = s;
-        }
-    }
-    return save;
-}
-
-//
-// log a message into the kernel log buffer
-//
-// Filter rules to parse <PRI> <TIME> <tag> and <message> in order for
-// them to appear correct in the logcat output:
-//
-// LOG_KERN (0):
-// <PRI>[<TIME>] <tag> ":" <message>
-// <PRI>[<TIME>] <tag> <tag> ":" <message>
-// <PRI>[<TIME>] <tag> <tag>_work ":" <message>
-// <PRI>[<TIME>] <tag> '<tag>.<num>' ":" <message>
-// <PRI>[<TIME>] <tag> '<tag><num>' ":" <message>
-// <PRI>[<TIME>] <tag>_host '<tag>.<num>' ":" <message>
-// (unimplemented) <PRI>[<TIME>] <tag> '<num>.<tag>' ":" <message>
-// <PRI>[<TIME>] "[INFO]"<tag> : <message>
-// <PRI>[<TIME>] "------------[ cut here ]------------"   (?)
-// <PRI>[<TIME>] "---[ end trace 3225a3070ca3e4ac ]---"   (?)
-// LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH, LOG_SYSLOG, LOG_LPR, LOG_NEWS
-// LOG_UUCP, LOG_CRON, LOG_AUTHPRIV, LOG_FTP:
-// <PRI+TAG>[<TIME>] (see sys/syslog.h)
-// Observe:
-//  Minimum tag length = 3   NB: drops things like r5:c00bbadf, but allow PM:
-//  Maximum tag words = 2
-//  Maximum tag length = 16  NB: we are thinking of how ugly logcat can get.
-//  Not a Tag if there is no message content.
-//  leading additional spaces means no tag, inherit last tag.
-//  Not a Tag if <tag>: is "ERROR:", "WARNING:", "INFO:" or "CPU:"
-// Drop:
-//  empty messages
-//  messages with ' audit(' in them if auditd is running
-//  logd.klogd:
-// return -1 if message logd.klogd: <signature>
-//
-int LogKlog::log(const char* buf, ssize_t len) {
-    if (auditd && android::strnstr(buf, len, auditStr)) {
-        return 0;
-    }
-
-    const char* p = buf;
-    int pri = parseKernelPrio(p, len);
-
-    log_time now = sniffTime(p, len - (p - buf), false);
-
-    // sniff for start marker
-    const char* start = android::strnstr(p, len - (p - buf), klogdStr);
-    if (start) {
-        uint64_t sig = strtoll(start + strlen(klogdStr), nullptr, 10);
-        if (sig == signature.nsec()) {
-            if (initialized) {
-                enableLogging = true;
-            } else {
-                enableLogging = false;
-            }
-            return -1;
-        }
-        return 0;
-    }
-
-    if (!enableLogging) {
-        return 0;
-    }
-
-    // Parse pid, tid and uid
-    const pid_t pid = sniffPid(p, len - (p - buf));
-    const pid_t tid = pid;
-    uid_t uid = AID_ROOT;
-    if (pid) {
-        uid = stats_->PidToUid(pid);
-    }
-
-    // Parse (rules at top) to pull out a tag from the incoming kernel message.
-    // Some may view the following as an ugly heuristic, the desire is to
-    // beautify the kernel logs into an Android Logging format; the goal is
-    // admirable but costly.
-    while ((p < &buf[len]) && (isspace(*p) || !*p)) {
-        ++p;
-    }
-    if (p >= &buf[len]) {  // timestamp, no content
-        return 0;
-    }
-    start = p;
-    const char* tag = "";
-    const char* etag = tag;
-    ssize_t taglen = len - (p - buf);
-    const char* bt = p;
-
-    static const char infoBrace[] = "[INFO]";
-    static const ssize_t infoBraceLen = strlen(infoBrace);
-    if ((taglen >= infoBraceLen) &&
-        !fastcmp<strncmp>(p, infoBrace, infoBraceLen)) {
-        // <PRI>[<TIME>] "[INFO]"<tag> ":" message
-        bt = p + infoBraceLen;
-        taglen -= infoBraceLen;
-    }
-
-    const char* et;
-    for (et = bt; (taglen > 0) && *et && (*et != ':') && !isspace(*et);
-         ++et, --taglen) {
-        // skip ':' within [ ... ]
-        if (*et == '[') {
-            while ((taglen > 0) && *et && *et != ']') {
-                ++et;
-                --taglen;
-            }
-            if (taglen <= 0) {
-                break;
-            }
-        }
-    }
-    const char* cp;
-    for (cp = et; (taglen > 0) && isspace(*cp); ++cp, --taglen) {
-    }
-
-    // Validate tag
-    ssize_t size = et - bt;
-    if ((taglen > 0) && (size > 0)) {
-        if (*cp == ':') {
-            // ToDo: handle case insensitive colon separated logging stutter:
-            //       <tag> : <tag>: ...
-
-            // One Word
-            tag = bt;
-            etag = et;
-            p = cp + 1;
-        } else if ((taglen > size) && (tolower(*bt) == tolower(*cp))) {
-            // clean up any tag stutter
-            if (!fastcmp<strncasecmp>(bt + 1, cp + 1, size - 1)) {  // no match
-                // <PRI>[<TIME>] <tag> <tag> : message
-                // <PRI>[<TIME>] <tag> <tag>: message
-                // <PRI>[<TIME>] <tag> '<tag>.<num>' : message
-                // <PRI>[<TIME>] <tag> '<tag><num>' : message
-                // <PRI>[<TIME>] <tag> '<tag><stuff>' : message
-                const char* b = cp;
-                cp += size;
-                taglen -= size;
-                while ((--taglen > 0) && !isspace(*++cp) && (*cp != ':')) {
-                }
-                const char* e;
-                for (e = cp; (taglen > 0) && isspace(*cp); ++cp, --taglen) {
-                }
-                if ((taglen > 0) && (*cp == ':')) {
-                    tag = b;
-                    etag = e;
-                    p = cp + 1;
-                }
-            } else {
-                // what about <PRI>[<TIME>] <tag>_host '<tag><stuff>' : message
-                static const char host[] = "_host";
-                static const ssize_t hostlen = strlen(host);
-                if ((size > hostlen) &&
-                    !fastcmp<strncmp>(bt + size - hostlen, host, hostlen) &&
-                    !fastcmp<strncmp>(bt + 1, cp + 1, size - hostlen - 1)) {
-                    const char* b = cp;
-                    cp += size - hostlen;
-                    taglen -= size - hostlen;
-                    if (*cp == '.') {
-                        while ((--taglen > 0) && !isspace(*++cp) &&
-                               (*cp != ':')) {
-                        }
-                        const char* e;
-                        for (e = cp; (taglen > 0) && isspace(*cp);
-                             ++cp, --taglen) {
-                        }
-                        if ((taglen > 0) && (*cp == ':')) {
-                            tag = b;
-                            etag = e;
-                            p = cp + 1;
-                        }
-                    }
-                } else {
-                    goto twoWord;
-                }
-            }
-        } else {
-        // <PRI>[<TIME>] <tag> <stuff>' : message
-        twoWord:
-            while ((--taglen > 0) && !isspace(*++cp) && (*cp != ':')) {
-            }
-            const char* e;
-            for (e = cp; (taglen > 0) && isspace(*cp); ++cp, --taglen) {
-            }
-            // Two words
-            if ((taglen > 0) && (*cp == ':')) {
-                tag = bt;
-                etag = e;
-                p = cp + 1;
-            }
-        }
-    }  // else no tag
-
-    static const char cpu[] = "CPU";
-    static const ssize_t cpuLen = strlen(cpu);
-    static const char warning[] = "WARNING";
-    static const ssize_t warningLen = strlen(warning);
-    static const char error[] = "ERROR";
-    static const ssize_t errorLen = strlen(error);
-    static const char info[] = "INFO";
-    static const ssize_t infoLen = strlen(info);
-
-    size = etag - tag;
-    if ((size <= 1) ||
-        // register names like x9
-        ((size == 2) && (isdigit(tag[0]) || isdigit(tag[1]))) ||
-        // register names like x18 but not driver names like en0
-        ((size == 3) && (isdigit(tag[1]) && isdigit(tag[2]))) ||
-        // ignore
-        ((size == cpuLen) && !fastcmp<strncmp>(tag, cpu, cpuLen)) ||
-        ((size == warningLen) && !fastcmp<strncasecmp>(tag, warning, warningLen)) ||
-        ((size == errorLen) && !fastcmp<strncasecmp>(tag, error, errorLen)) ||
-        ((size == infoLen) && !fastcmp<strncasecmp>(tag, info, infoLen))) {
-        p = start;
-        etag = tag = "";
-    }
-
-    // Suppress additional stutter in tag:
-    //   eg: [143:healthd]healthd -> [143:healthd]
-    taglen = etag - tag;
-    // Mediatek-special printk induced stutter
-    const char* mp = strnrchr(tag, taglen, ']');
-    if (mp && (++mp < etag)) {
-        ssize_t s = etag - mp;
-        if (((s + s) < taglen) && !fastcmp<memcmp>(mp, mp - 1 - s, s)) {
-            taglen = mp - tag;
-        }
-    }
-    // Deal with sloppy and simplistic harmless p = cp + 1 etc above.
-    if (len < (p - buf)) {
-        p = &buf[len];
-    }
-    // skip leading space
-    while ((p < &buf[len]) && (isspace(*p) || !*p)) {
-        ++p;
-    }
-    // truncate trailing space or nuls
-    ssize_t b = len - (p - buf);
-    while ((b > 0) && (isspace(p[b - 1]) || !p[b - 1])) {
-        --b;
-    }
-    // trick ... allow tag with empty content to be logged. log() drops empty
-    if ((b <= 0) && (taglen > 0)) {
-        p = " ";
-        b = 1;
-    }
-    // This shouldn't happen, but clamp the size if it does.
-    if (b > LOGGER_ENTRY_MAX_PAYLOAD) {
-        b = LOGGER_ENTRY_MAX_PAYLOAD;
-    }
-    if (taglen > LOGGER_ENTRY_MAX_PAYLOAD) {
-        taglen = LOGGER_ENTRY_MAX_PAYLOAD;
-    }
-    // calculate buffer copy requirements
-    ssize_t n = 1 + taglen + 1 + b + 1;
-    // Extra checks for likely impossible cases.
-    if ((taglen > n) || (b > n) || (n > (ssize_t)USHRT_MAX) || (n <= 0)) {
-        return -EINVAL;
-    }
-
-    // Careful.
-    // We are using the stack to house the log buffer for speed reasons.
-    // If we malloc'd this buffer, we could get away without n's USHRT_MAX
-    // test above, but we would then required a max(n, USHRT_MAX) as
-    // truncating length argument to logbuf->log() below. Gain is protection
-    // against stack corruption and speedup, loss is truncated long-line content.
-    char newstr[n];
-    char* np = newstr;
-
-    // Convert priority into single-byte Android logger priority
-    *np = convertKernelPrioToAndroidPrio(pri);
-    ++np;
-
-    // Copy parsed tag following priority
-    memcpy(np, tag, taglen);
-    np += taglen;
-    *np = '\0';
-    ++np;
-
-    // Copy main message to the remainder
-    memcpy(np, p, b);
-    np[b] = '\0';
-
-    {
-        // Watch out for singular race conditions with timezone causing near
-        // integer quarter-hour jumps in the time and compensate accordingly.
-        // Entries will be temporal within near_seconds * 2. b/21868540
-        static uint32_t vote_time[3];
-        vote_time[2] = vote_time[1];
-        vote_time[1] = vote_time[0];
-        vote_time[0] = now.tv_sec;
-
-        if (vote_time[1] && vote_time[2]) {
-            static const unsigned near_seconds = 10;
-            static const unsigned timezones_seconds = 900;
-            int diff0 = (vote_time[0] - vote_time[1]) / near_seconds;
-            unsigned abs0 = (diff0 < 0) ? -diff0 : diff0;
-            int diff1 = (vote_time[1] - vote_time[2]) / near_seconds;
-            unsigned abs1 = (diff1 < 0) ? -diff1 : diff1;
-            if ((abs1 <= 1) &&  // last two were in agreement on timezone
-                ((abs0 + 1) % (timezones_seconds / near_seconds)) <= 2) {
-                abs0 = (abs0 + 1) / (timezones_seconds / near_seconds) *
-                       timezones_seconds;
-                now.tv_sec -= (diff0 < 0) ? -abs0 : abs0;
-            }
-        }
-    }
-
-    // Log message
-    int rc = logbuf->Log(LOG_ID_KERNEL, now, uid, pid, tid, newstr, (uint16_t)n);
-
-    return rc;
-}
diff --git a/logd/LogKlog.h b/logd/LogKlog.h
deleted file mode 100644
index 56e0452..0000000
--- a/logd/LogKlog.h
+++ /dev/null
@@ -1,53 +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.
- */
-
-#pragma once
-
-#include <private/android_logger.h>
-#include <sysutils/SocketListener.h>
-
-#include "LogBuffer.h"
-#include "LogStatistics.h"
-
-class LogKlog : public SocketListener {
-    LogBuffer* logbuf;
-    const log_time signature;
-    // Set once thread is started, separates KLOG_ACTION_READ_ALL
-    // and KLOG_ACTION_READ phases.
-    bool initialized;
-    // Used during each of the above phases to control logging.
-    bool enableLogging;
-    // set if we are also running auditd, to filter out audit reports from
-    // our copy of the kernel log
-    bool auditd;
-
-    static log_time correction;
-
-  public:
-    LogKlog(LogBuffer* buf, int fdWrite, int fdRead, bool auditd, LogStatistics* stats);
-    int log(const char* buf, ssize_t len);
-
-    static void convertMonotonicToReal(log_time& real) { real += correction; }
-
-  protected:
-    log_time sniffTime(const char*& buf, ssize_t len, bool reverse);
-    pid_t sniffPid(const char*& buf, ssize_t len);
-    void calculateCorrection(const log_time& monotonic, const char* real_string, ssize_t len);
-    virtual bool onDataAvailable(SocketClient* cli);
-
-  private:
-    LogStatistics* stats_;
-};
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
deleted file mode 100644
index a6ab50b..0000000
--- a/logd/LogListener.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2012-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 <limits.h>
-#include <sys/cdefs.h>
-#include <sys/prctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <unistd.h>
-
-#include <thread>
-
-#include <cutils/sockets.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-
-#include "LogBuffer.h"
-#include "LogListener.h"
-#include "LogPermissions.h"
-
-LogListener::LogListener(LogBuffer* buf) : socket_(GetLogSocket()), logbuf_(buf) {}
-
-bool LogListener::StartListener() {
-    if (socket_ <= 0) {
-        return false;
-    }
-    auto thread = std::thread(&LogListener::ThreadFunction, this);
-    thread.detach();
-    return true;
-}
-
-void LogListener::ThreadFunction() {
-    prctl(PR_SET_NAME, "logd.writer");
-
-    while (true) {
-        HandleData();
-    }
-}
-
-void LogListener::HandleData() {
-    // + 1 to ensure null terminator if MAX_PAYLOAD buffer is received
-    __attribute__((uninitialized)) char
-            buffer[sizeof(android_log_header_t) + LOGGER_ENTRY_MAX_PAYLOAD + 1];
-    struct iovec iov = {buffer, sizeof(buffer) - 1};
-
-    alignas(4) char control[CMSG_SPACE(sizeof(struct ucred))];
-    struct msghdr hdr = {
-        nullptr, 0, &iov, 1, control, sizeof(control), 0,
-    };
-
-    // To clear the entire buffer is secure/safe, but this contributes to 1.68%
-    // overhead under logging load. We are safe because we check counts, but
-    // still need to clear null terminator
-    // memset(buffer, 0, sizeof(buffer));
-    ssize_t n = recvmsg(socket_, &hdr, 0);
-    if (n <= (ssize_t)(sizeof(android_log_header_t))) {
-        return;
-    }
-
-    buffer[n] = 0;
-
-    struct ucred* cred = nullptr;
-
-    struct cmsghdr* cmsg = CMSG_FIRSTHDR(&hdr);
-    while (cmsg != nullptr) {
-        if (cmsg->cmsg_level == SOL_SOCKET &&
-            cmsg->cmsg_type == SCM_CREDENTIALS) {
-            cred = (struct ucred*)CMSG_DATA(cmsg);
-            break;
-        }
-        cmsg = CMSG_NXTHDR(&hdr, cmsg);
-    }
-
-    if (cred == nullptr) {
-        return;
-    }
-
-    if (cred->uid == AID_LOGD) {
-        // ignore log messages we send to ourself.
-        // Such log messages are often generated by libraries we depend on
-        // which use standard Android logging.
-        return;
-    }
-
-    android_log_header_t* header =
-        reinterpret_cast<android_log_header_t*>(buffer);
-    log_id_t logId = static_cast<log_id_t>(header->id);
-    if (/* logId < LOG_ID_MIN || */ logId >= LOG_ID_MAX ||
-        logId == LOG_ID_KERNEL) {
-        return;
-    }
-
-    if ((logId == LOG_ID_SECURITY) &&
-        (!__android_log_security() ||
-         !clientHasLogCredentials(cred->uid, cred->gid, cred->pid))) {
-        return;
-    }
-
-    char* msg = ((char*)buffer) + sizeof(android_log_header_t);
-    n -= sizeof(android_log_header_t);
-
-    // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a
-    // truncated message to the logs.
-
-    logbuf_->Log(logId, header->realtime, cred->uid, cred->pid, header->tid, msg,
-                 ((size_t)n <= UINT16_MAX) ? (uint16_t)n : UINT16_MAX);
-}
-
-int LogListener::GetLogSocket() {
-    static const char socketName[] = "logdw";
-    int sock = android_get_control_socket(socketName);
-
-    if (sock < 0) {  // logd started up in init.sh
-        sock = socket_local_server(
-            socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_DGRAM);
-
-        int on = 1;
-        if (setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on))) {
-            return -1;
-        }
-    }
-    return sock;
-}
diff --git a/logd/LogListener.h b/logd/LogListener.h
deleted file mode 100644
index 566af5b..0000000
--- a/logd/LogListener.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include "LogBuffer.h"
-
-class LogListener {
-  public:
-    explicit LogListener(LogBuffer* buf);
-    bool StartListener();
-
-  private:
-    void ThreadFunction();
-    void HandleData();
-    static int GetLogSocket();
-
-    int socket_;
-    LogBuffer* logbuf_;
-};
diff --git a/logd/LogPermissions.cpp b/logd/LogPermissions.cpp
deleted file mode 100644
index 3fd0ea1..0000000
--- a/logd/LogPermissions.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2012-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 "LogPermissions.h"
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <private/android_filesystem_config.h>
-
-// gets a list of supplementary group IDs associated with
-// the socket peer.  This is implemented by opening
-// /proc/PID/status and look for the "Group:" line.
-//
-// This function introduces races especially since status
-// can change 'shape' while reading, the net result is err
-// on lack of permission.
-//
-// Race-free alternative is to introduce pairs of sockets
-// and threads for each command and reading, one each that
-// has open permissions, and one that has restricted
-// permissions.
-
-static bool groupIsLog(char* buf) {
-    char* ptr;
-    static const char ws[] = " \n";
-
-    for (buf = strtok_r(buf, ws, &ptr); buf; buf = strtok_r(nullptr, ws, &ptr)) {
-        errno = 0;
-        gid_t Gid = strtol(buf, nullptr, 10);
-        if (errno != 0) {
-            return false;
-        }
-        if (Gid == AID_LOG) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool clientHasLogCredentials(uid_t uid, gid_t gid, pid_t pid) {
-    if ((uid == AID_ROOT) || (uid == AID_SYSTEM) || (uid == AID_LOG)) {
-        return true;
-    }
-
-    if ((gid == AID_ROOT) || (gid == AID_SYSTEM) || (gid == AID_LOG)) {
-        return true;
-    }
-
-    // FYI We will typically be here for 'adb logcat'
-    char filename[256];
-    snprintf(filename, sizeof(filename), "/proc/%u/status", pid);
-
-    bool ret;
-    bool foundLog = false;
-    bool foundGid = false;
-    bool foundUid = false;
-
-    //
-    // Reading /proc/<pid>/status is rife with race conditions. All of /proc
-    // suffers from this and its use should be minimized. However, we have no
-    // choice.
-    //
-    // Notably the content from one 4KB page to the next 4KB page can be from a
-    // change in shape even if we are gracious enough to attempt to read
-    // atomically. getline can not even guarantee a page read is not split up
-    // and in effect can read from different vintages of the content.
-    //
-    // We are finding out in the field that a 'logcat -c' via adb occasionally
-    // is returned with permission denied when we did only one pass and thus
-    // breaking scripts. For security we still err on denying access if in
-    // doubt, but we expect the falses  should be reduced significantly as
-    // three times is a charm.
-    //
-    for (int retry = 3; !(ret = foundGid && foundUid && foundLog) && retry;
-         --retry) {
-        FILE* file = fopen(filename, "re");
-        if (!file) {
-            continue;
-        }
-
-        char* line = nullptr;
-        size_t len = 0;
-        while (getline(&line, &len, file) > 0) {
-            static const char groups_string[] = "Groups:\t";
-            static const char uid_string[] = "Uid:\t";
-            static const char gid_string[] = "Gid:\t";
-
-            if (strncmp(groups_string, line, sizeof(groups_string) - 1) == 0) {
-                if (groupIsLog(line + sizeof(groups_string) - 1)) {
-                    foundLog = true;
-                }
-            } else if (strncmp(uid_string, line, sizeof(uid_string) - 1) == 0) {
-                uid_t u[4] = { (uid_t)-1, (uid_t)-1, (uid_t)-1, (uid_t)-1 };
-
-                sscanf(line + sizeof(uid_string) - 1, "%u\t%u\t%u\t%u", &u[0],
-                       &u[1], &u[2], &u[3]);
-
-                // Protect against PID reuse by checking that UID is the same
-                if ((uid == u[0]) && (uid == u[1]) && (uid == u[2]) &&
-                    (uid == u[3])) {
-                    foundUid = true;
-                }
-            } else if (strncmp(gid_string, line, sizeof(gid_string) - 1) == 0) {
-                gid_t g[4] = { (gid_t)-1, (gid_t)-1, (gid_t)-1, (gid_t)-1 };
-
-                sscanf(line + sizeof(gid_string) - 1, "%u\t%u\t%u\t%u", &g[0],
-                       &g[1], &g[2], &g[3]);
-
-                // Protect against PID reuse by checking that GID is the same
-                if ((gid == g[0]) && (gid == g[1]) && (gid == g[2]) &&
-                    (gid == g[3])) {
-                    foundGid = true;
-                }
-            }
-        }
-        free(line);
-        fclose(file);
-    }
-
-    return ret;
-}
-
-bool clientHasLogCredentials(SocketClient* cli) {
-    return clientHasLogCredentials(cli->getUid(), cli->getGid(), cli->getPid());
-}
diff --git a/logd/LogPermissions.h b/logd/LogPermissions.h
deleted file mode 100644
index 3130db5..0000000
--- a/logd/LogPermissions.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include <sys/types.h>
-
-#include <sysutils/SocketClient.h>
-
-bool clientHasLogCredentials(uid_t uid, gid_t gid, pid_t pid);
-bool clientHasLogCredentials(SocketClient* cli);
diff --git a/logd/LogReader.cpp b/logd/LogReader.cpp
deleted file mode 100644
index 6c97693..0000000
--- a/logd/LogReader.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#include <ctype.h>
-#include <inttypes.h>
-#include <poll.h>
-#include <sys/prctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <chrono>
-
-#include <android-base/logging.h>
-#include <android-base/stringprintf.h>
-#include <cutils/sockets.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-
-#include "LogBuffer.h"
-#include "LogBufferElement.h"
-#include "LogPermissions.h"
-#include "LogReader.h"
-#include "LogUtils.h"
-#include "LogWriter.h"
-
-static bool CanReadSecurityLogs(SocketClient* client) {
-    return client->getUid() == AID_SYSTEM || client->getGid() == AID_SYSTEM;
-}
-
-static std::string SocketClientToName(SocketClient* client) {
-    return android::base::StringPrintf("pid %d, fd %d", client->getPid(), client->getSocket());
-}
-
-class SocketLogWriter : public LogWriter {
-  public:
-    SocketLogWriter(LogReader* reader, SocketClient* client, bool privileged)
-        : LogWriter(client->getUid(), privileged), reader_(reader), client_(client) {}
-
-    bool Write(const logger_entry& entry, const char* msg) override {
-        struct iovec iovec[2];
-        iovec[0].iov_base = const_cast<logger_entry*>(&entry);
-        iovec[0].iov_len = entry.hdr_size;
-        iovec[1].iov_base = const_cast<char*>(msg);
-        iovec[1].iov_len = entry.len;
-
-        return client_->sendDatav(iovec, 1 + (entry.len != 0)) == 0;
-    }
-
-    void Release() override {
-        reader_->release(client_);
-        client_->decRef();
-    }
-
-    void Shutdown() override { shutdown(client_->getSocket(), SHUT_RDWR); }
-
-    std::string name() const override { return SocketClientToName(client_); }
-
-  private:
-    LogReader* reader_;
-    SocketClient* client_;
-};
-
-LogReader::LogReader(LogBuffer* logbuf, LogReaderList* reader_list)
-    : SocketListener(getLogSocket(), true), log_buffer_(logbuf), reader_list_(reader_list) {}
-
-// Note returning false will release the SocketClient instance.
-bool LogReader::onDataAvailable(SocketClient* cli) {
-    static bool name_set;
-    if (!name_set) {
-        prctl(PR_SET_NAME, "logd.reader");
-        name_set = true;
-    }
-
-    char buffer[255];
-
-    int len = read(cli->getSocket(), buffer, sizeof(buffer) - 1);
-    if (len <= 0) {
-        DoSocketDelete(cli);
-        return false;
-    }
-    buffer[len] = '\0';
-
-    // Clients are only allowed to send one command, disconnect them if they send another.
-    if (DoSocketDelete(cli)) {
-        return false;
-    }
-
-    unsigned long tail = 0;
-    static const char _tail[] = " tail=";
-    char* cp = strstr(buffer, _tail);
-    if (cp) {
-        tail = atol(cp + sizeof(_tail) - 1);
-    }
-
-    log_time start(log_time::EPOCH);
-    static const char _start[] = " start=";
-    cp = strstr(buffer, _start);
-    if (cp) {
-        // Parse errors will result in current time
-        start.strptime(cp + sizeof(_start) - 1, "%s.%q");
-    }
-
-    std::chrono::steady_clock::time_point deadline = {};
-    static const char _timeout[] = " timeout=";
-    cp = strstr(buffer, _timeout);
-    if (cp) {
-        long timeout_seconds = atol(cp + sizeof(_timeout) - 1);
-        deadline = std::chrono::steady_clock::now() + std::chrono::seconds(timeout_seconds);
-    }
-
-    unsigned int logMask = -1;
-    static const char _logIds[] = " lids=";
-    cp = strstr(buffer, _logIds);
-    if (cp) {
-        logMask = 0;
-        cp += sizeof(_logIds) - 1;
-        while (*cp != '\0') {
-            int val = 0;
-            while (isdigit(*cp)) {
-                val = val * 10 + *cp - '0';
-                ++cp;
-            }
-            logMask |= 1 << val;
-            if (*cp != ',') {
-                break;
-            }
-            ++cp;
-        }
-    }
-
-    pid_t pid = 0;
-    static const char _pid[] = " pid=";
-    cp = strstr(buffer, _pid);
-    if (cp) {
-        pid = atol(cp + sizeof(_pid) - 1);
-    }
-
-    bool nonBlock = false;
-    if (!fastcmp<strncmp>(buffer, "dumpAndClose", 12)) {
-        // Allow writer to get some cycles, and wait for pending notifications
-        sched_yield();
-        reader_list_->reader_threads_lock().lock();
-        reader_list_->reader_threads_lock().unlock();
-        sched_yield();
-        nonBlock = true;
-    }
-
-    bool privileged = clientHasLogCredentials(cli);
-    bool can_read_security = CanReadSecurityLogs(cli);
-    if (!can_read_security) {
-        logMask &= ~(1 << LOG_ID_SECURITY);
-    }
-
-    std::unique_ptr<LogWriter> socket_log_writer(new SocketLogWriter(this, cli, privileged));
-
-    uint64_t sequence = 1;
-    // Convert realtime to sequence number
-    if (start != log_time::EPOCH) {
-        bool start_time_set = false;
-        uint64_t last = sequence;
-        auto log_find_start = [pid, start, &sequence, &start_time_set, &last](
-                                      log_id_t, pid_t element_pid, uint64_t element_sequence,
-                                      log_time element_realtime) -> FilterResult {
-            if (pid && pid != element_pid) {
-                return FilterResult::kSkip;
-            }
-            if (start == element_realtime) {
-                sequence = element_sequence;
-                start_time_set = true;
-                return FilterResult::kStop;
-            } else {
-                if (start < element_realtime) {
-                    sequence = last;
-                    start_time_set = true;
-                    return FilterResult::kStop;
-                }
-                last = element_sequence;
-            }
-            return FilterResult::kSkip;
-        };
-        auto flush_to_state = log_buffer_->CreateFlushToState(sequence, logMask);
-        log_buffer_->FlushTo(socket_log_writer.get(), *flush_to_state, log_find_start);
-
-        if (!start_time_set) {
-            if (nonBlock) {
-                return false;
-            }
-            sequence = log_buffer_->sequence();
-        }
-    }
-
-    LOG(INFO) << android::base::StringPrintf(
-            "logdr: UID=%d GID=%d PID=%d %c tail=%lu logMask=%x pid=%d "
-            "start=%" PRIu64 "ns deadline=%" PRIi64 "ns",
-            cli->getUid(), cli->getGid(), cli->getPid(), nonBlock ? 'n' : 'b', tail, logMask,
-            (int)pid, start.nsec(), static_cast<int64_t>(deadline.time_since_epoch().count()));
-
-    if (start == log_time::EPOCH) {
-        deadline = {};
-    }
-
-    auto lock = std::lock_guard{reader_list_->reader_threads_lock()};
-    auto entry = std::make_unique<LogReaderThread>(log_buffer_, reader_list_,
-                                                   std::move(socket_log_writer), nonBlock, tail,
-                                                   logMask, pid, start, sequence, deadline);
-    // release client and entry reference counts once done
-    cli->incRef();
-    reader_list_->reader_threads().emplace_front(std::move(entry));
-
-    // Set acceptable upper limit to wait for slow reader processing b/27242723
-    struct timeval t = { LOGD_SNDTIMEO, 0 };
-    setsockopt(cli->getSocket(), SOL_SOCKET, SO_SNDTIMEO, (const char*)&t,
-               sizeof(t));
-
-    return true;
-}
-
-bool LogReader::DoSocketDelete(SocketClient* cli) {
-    auto cli_name = SocketClientToName(cli);
-    auto lock = std::lock_guard{reader_list_->reader_threads_lock()};
-    for (const auto& reader : reader_list_->reader_threads()) {
-        if (reader->name() == cli_name) {
-            reader->release_Locked();
-            return true;
-        }
-    }
-    return false;
-}
-
-int LogReader::getLogSocket() {
-    static const char socketName[] = "logdr";
-    int sock = android_get_control_socket(socketName);
-
-    if (sock < 0) {
-        sock = socket_local_server(
-            socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET);
-    }
-
-    return sock;
-}
diff --git a/logd/LogReader.h b/logd/LogReader.h
deleted file mode 100644
index b85a584..0000000
--- a/logd/LogReader.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include <sysutils/SocketListener.h>
-
-#include "LogBuffer.h"
-#include "LogReaderList.h"
-#include "LogReaderThread.h"
-
-#define LOGD_SNDTIMEO 32
-
-class LogReader : public SocketListener {
-  public:
-    explicit LogReader(LogBuffer* logbuf, LogReaderList* reader_list);
-
-  protected:
-    virtual bool onDataAvailable(SocketClient* cli);
-
-  private:
-    static int getLogSocket();
-
-    bool DoSocketDelete(SocketClient* cli);
-
-    LogBuffer* log_buffer_;
-    LogReaderList* reader_list_;
-};
diff --git a/logd/LogReaderList.cpp b/logd/LogReaderList.cpp
deleted file mode 100644
index 32ba291..0000000
--- a/logd/LogReaderList.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2020 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 "LogReaderList.h"
-
-// When we are notified a new log entry is available, inform
-// listening sockets who are watching this entry's log id.
-void LogReaderList::NotifyNewLog(LogMask log_mask) const {
-    auto lock = std::lock_guard{reader_threads_lock_};
-
-    for (const auto& entry : reader_threads_) {
-        if (!entry->IsWatchingMultiple(log_mask)) {
-            continue;
-        }
-        if (entry->deadline().time_since_epoch().count() != 0) {
-            continue;
-        }
-        entry->triggerReader_Locked();
-    }
-}
diff --git a/logd/LogReaderList.h b/logd/LogReaderList.h
deleted file mode 100644
index 594716a..0000000
--- a/logd/LogReaderList.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2020 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 <list>
-#include <memory>
-#include <mutex>
-
-#include "LogBuffer.h"
-#include "LogReaderThread.h"
-
-class LogReaderList {
-  public:
-    void NotifyNewLog(LogMask log_mask) const;
-
-    std::list<std::unique_ptr<LogReaderThread>>& reader_threads() { return reader_threads_; }
-    std::mutex& reader_threads_lock() { return reader_threads_lock_; }
-
-  private:
-    std::list<std::unique_ptr<LogReaderThread>> reader_threads_;
-    mutable std::mutex reader_threads_lock_;
-};
\ No newline at end of file
diff --git a/logd/LogReaderThread.cpp b/logd/LogReaderThread.cpp
deleted file mode 100644
index 4a8be01..0000000
--- a/logd/LogReaderThread.cpp
+++ /dev/null
@@ -1,180 +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 "LogReaderThread.h"
-
-#include <errno.h>
-#include <string.h>
-#include <sys/prctl.h>
-
-#include <thread>
-
-#include "LogBuffer.h"
-#include "LogReaderList.h"
-
-LogReaderThread::LogReaderThread(LogBuffer* log_buffer, LogReaderList* reader_list,
-                                 std::unique_ptr<LogWriter> writer, bool non_block,
-                                 unsigned long tail, LogMask log_mask, pid_t pid,
-                                 log_time start_time, uint64_t start,
-                                 std::chrono::steady_clock::time_point deadline)
-    : log_buffer_(log_buffer),
-      reader_list_(reader_list),
-      writer_(std::move(writer)),
-      pid_(pid),
-      tail_(tail),
-      count_(0),
-      index_(0),
-      start_time_(start_time),
-      deadline_(deadline),
-      non_block_(non_block) {
-    cleanSkip_Locked();
-    flush_to_state_ = log_buffer_->CreateFlushToState(start, log_mask);
-    auto thread = std::thread{&LogReaderThread::ThreadFunction, this};
-    thread.detach();
-}
-
-void LogReaderThread::ThreadFunction() {
-    prctl(PR_SET_NAME, "logd.reader.per");
-
-    auto lock = std::unique_lock{reader_list_->reader_threads_lock()};
-
-    while (!release_) {
-        if (deadline_.time_since_epoch().count() != 0) {
-            if (thread_triggered_condition_.wait_until(lock, deadline_) ==
-                std::cv_status::timeout) {
-                deadline_ = {};
-            }
-            if (release_) {
-                break;
-            }
-        }
-
-        lock.unlock();
-
-        if (tail_) {
-            auto first_pass_state = log_buffer_->CreateFlushToState(flush_to_state_->start(),
-                                                                    flush_to_state_->log_mask());
-            log_buffer_->FlushTo(
-                    writer_.get(), *first_pass_state,
-                    [this](log_id_t log_id, pid_t pid, uint64_t sequence, log_time realtime) {
-                        return FilterFirstPass(log_id, pid, sequence, realtime);
-                    });
-        }
-        bool flush_success = log_buffer_->FlushTo(
-                writer_.get(), *flush_to_state_,
-                [this](log_id_t log_id, pid_t pid, uint64_t sequence, log_time realtime) {
-                    return FilterSecondPass(log_id, pid, sequence, realtime);
-                });
-
-        // We only ignore entries before the original start time for the first flushTo(), if we
-        // get entries after this first flush before the original start time, then the client
-        // wouldn't have seen them.
-        // Note: this is still racy and may skip out of order events that came in since the last
-        // time the client disconnected and then reconnected with the new start time.  The long term
-        // solution here is that clients must request events since a specific sequence number.
-        start_time_.tv_sec = 0;
-        start_time_.tv_nsec = 0;
-
-        lock.lock();
-
-        if (!flush_success) {
-            break;
-        }
-
-        if (non_block_ || release_) {
-            break;
-        }
-
-        cleanSkip_Locked();
-
-        if (deadline_.time_since_epoch().count() == 0) {
-            thread_triggered_condition_.wait(lock);
-        }
-    }
-
-    writer_->Release();
-
-    auto& log_reader_threads = reader_list_->reader_threads();
-    auto it = std::find_if(log_reader_threads.begin(), log_reader_threads.end(),
-                           [this](const auto& other) { return other.get() == this; });
-
-    if (it != log_reader_threads.end()) {
-        log_reader_threads.erase(it);
-    }
-}
-
-// A first pass to count the number of elements
-FilterResult LogReaderThread::FilterFirstPass(log_id_t, pid_t pid, uint64_t, log_time realtime) {
-    auto lock = std::lock_guard{reader_list_->reader_threads_lock()};
-
-    if ((!pid_ || pid_ == pid) && (start_time_ == log_time::EPOCH || start_time_ <= realtime)) {
-        ++count_;
-    }
-
-    return FilterResult::kSkip;
-}
-
-// A second pass to send the selected elements
-FilterResult LogReaderThread::FilterSecondPass(log_id_t log_id, pid_t pid, uint64_t,
-                                               log_time realtime) {
-    auto lock = std::lock_guard{reader_list_->reader_threads_lock()};
-
-    if (skip_ahead_[log_id]) {
-        skip_ahead_[log_id]--;
-        return FilterResult::kSkip;
-    }
-
-    // Truncate to close race between first and second pass
-    if (non_block_ && tail_ && index_ >= count_) {
-        return FilterResult::kStop;
-    }
-
-    if (pid_ && pid_ != pid) {
-        return FilterResult::kSkip;
-    }
-
-    if (start_time_ != log_time::EPOCH && realtime <= start_time_) {
-        return FilterResult::kSkip;
-    }
-
-    if (release_) {
-        return FilterResult::kStop;
-    }
-
-    if (!tail_) {
-        goto ok;
-    }
-
-    ++index_;
-
-    if (count_ > tail_ && index_ <= (count_ - tail_)) {
-        return FilterResult::kSkip;
-    }
-
-    if (!non_block_) {
-        tail_ = 0;
-    }
-
-ok:
-    if (!skip_ahead_[log_id]) {
-        return FilterResult::kWrite;
-    }
-    return FilterResult::kSkip;
-}
-
-void LogReaderThread::cleanSkip_Locked(void) {
-    memset(skip_ahead_, 0, sizeof(skip_ahead_));
-}
diff --git a/logd/LogReaderThread.h b/logd/LogReaderThread.h
deleted file mode 100644
index 1855c0e..0000000
--- a/logd/LogReaderThread.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include <pthread.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <time.h>
-
-#include <chrono>
-#include <condition_variable>
-#include <list>
-#include <memory>
-
-#include <log/log.h>
-#include <sysutils/SocketClient.h>
-
-#include "LogBuffer.h"
-#include "LogWriter.h"
-
-class LogReaderList;
-
-class LogReaderThread {
-  public:
-    LogReaderThread(LogBuffer* log_buffer, LogReaderList* reader_list,
-                    std::unique_ptr<LogWriter> writer, bool non_block, unsigned long tail,
-                    LogMask log_mask, pid_t pid, log_time start_time, uint64_t sequence,
-                    std::chrono::steady_clock::time_point deadline);
-    void triggerReader_Locked() { thread_triggered_condition_.notify_all(); }
-
-    void triggerSkip_Locked(log_id_t id, unsigned int skip) { skip_ahead_[id] = skip; }
-    void cleanSkip_Locked();
-
-    void release_Locked() {
-        // gracefully shut down the socket.
-        writer_->Shutdown();
-        release_ = true;
-        thread_triggered_condition_.notify_all();
-    }
-
-    bool IsWatching(log_id_t id) const { return flush_to_state_->log_mask() & (1 << id); }
-    bool IsWatchingMultiple(LogMask log_mask) const {
-        return flush_to_state_->log_mask() & log_mask;
-    }
-
-    std::string name() const { return writer_->name(); }
-    uint64_t start() const { return flush_to_state_->start(); }
-    std::chrono::steady_clock::time_point deadline() const { return deadline_; }
-    FlushToState& flush_to_state() { return *flush_to_state_; }
-
-  private:
-    void ThreadFunction();
-    // flushTo filter callbacks
-    FilterResult FilterFirstPass(log_id_t log_id, pid_t pid, uint64_t sequence, log_time realtime);
-    FilterResult FilterSecondPass(log_id_t log_id, pid_t pid, uint64_t sequence, log_time realtime);
-
-    std::condition_variable thread_triggered_condition_;
-    LogBuffer* log_buffer_;
-    LogReaderList* reader_list_;
-    std::unique_ptr<LogWriter> writer_;
-
-    // Set to true to cause the thread to end and the LogReaderThread to delete itself.
-    bool release_ = false;
-
-    // If set to non-zero, only pids equal to this are read by the reader.
-    const pid_t pid_;
-    // When a reader is referencing (via start_) old elements in the log buffer, and the log
-    // buffer's size grows past its memory limit, the log buffer may request the reader to skip
-    // ahead a specified number of logs.
-    unsigned int skip_ahead_[LOG_ID_MAX];
-    // LogBuffer::FlushTo() needs to store state across subsequent calls.
-    std::unique_ptr<FlushToState> flush_to_state_;
-
-    // These next three variables are used for reading only the most recent lines aka `adb logcat
-    // -t` / `adb logcat -T`.
-    // tail_ is the number of most recent lines to print.
-    unsigned long tail_;
-    // count_ is the result of a first pass through the log buffer to determine how many total
-    // messages there are.
-    unsigned long count_;
-    // index_ is used along with count_ to only start sending lines once index_ > (count_ - tail_)
-    // and to disconnect the reader (if it is dumpAndClose, `adb logcat -t`), when index_ >= count_.
-    unsigned long index_;
-
-    // When a reader requests logs starting from a given timestamp, its stored here for the first
-    // pass, such that logs before this time stamp that are accumulated in the buffer are ignored.
-    log_time start_time_;
-    // CLOCK_MONOTONIC based deadline used for log wrapping.  If this deadline expires before logs
-    // wrap, then wake up and send the logs to the reader anyway.
-    std::chrono::steady_clock::time_point deadline_;
-    // If this reader is 'dumpAndClose' and will disconnect once it has read its intended logs.
-    const bool non_block_;
-};
diff --git a/logd/LogSize.cpp b/logd/LogSize.cpp
deleted file mode 100644
index fe829ba..0000000
--- a/logd/LogSize.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2020 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 <LogSize.h>
-
-#include <array>
-#include <optional>
-#include <string>
-
-#include <android-base/parseint.h>
-#include <android-base/properties.h>
-
-bool IsValidBufferSize(size_t value) {
-    return kLogBufferMinSize <= value && value <= kLogBufferMaxSize;
-}
-
-static std::optional<size_t> GetBufferSizeProperty(const std::string& key) {
-    std::string value = android::base::GetProperty(key, "");
-    if (value.empty()) {
-        return {};
-    }
-
-    uint32_t size;
-    if (!android::base::ParseByteCount(value, &size)) {
-        return {};
-    }
-
-    if (!IsValidBufferSize(size)) {
-        return {};
-    }
-
-    return size;
-}
-
-size_t GetBufferSizeFromProperties(log_id_t log_id) {
-    std::string buffer_name = android_log_id_to_name(log_id);
-    std::array<std::string, 4> properties = {
-            "persist.logd.size." + buffer_name,
-            "ro.logd.size." + buffer_name,
-            "persist.logd.size",
-            "ro.logd.size",
-    };
-
-    for (const auto& property : properties) {
-        if (auto size = GetBufferSizeProperty(property)) {
-            return *size;
-        }
-    }
-
-    if (android::base::GetBoolProperty("ro.config.low_ram", false)) {
-        return kLogBufferMinSize;
-    }
-
-    return kDefaultLogBufferSize;
-}
diff --git a/logd/LogSize.h b/logd/LogSize.h
deleted file mode 100644
index d5716ff..0000000
--- a/logd/LogSize.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2020 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 <stddef.h>
-
-#include <log/log.h>
-
-static constexpr size_t kDefaultLogBufferSize = 256 * 1024;
-static constexpr size_t kLogBufferMinSize = 64 * 1024;
-static constexpr size_t kLogBufferMaxSize = 256 * 1024 * 1024;
-
-bool IsValidBufferSize(size_t value);
-
-// This returns the buffer size as set in system properties for use in LogBuffer::Init().
-// Note that `logcat -G` calls LogBuffer::SetSize(), which configures log buffer sizes without
-// setting these properties, so this function should never be used except for LogBuffer::Init().
-// LogBuffer::GetSize() should be used instead within logd.  Other processes can use
-// android_logger_get_log_size() or `logcat -g` to query the actual allotted buffer size.
-size_t GetBufferSizeFromProperties(log_id_t log_id);
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
deleted file mode 100644
index 87069b3..0000000
--- a/logd/LogStatistics.cpp
+++ /dev/null
@@ -1,1071 +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 "LogStatistics.h"
-
-#include <ctype.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <list>
-#include <vector>
-
-#include <android-base/logging.h>
-#include <android-base/strings.h>
-#include <private/android_logger.h>
-
-#include "LogBufferElement.h"
-
-static const uint64_t hourSec = 60 * 60;
-static const uint64_t monthSec = 31 * 24 * hourSec;
-
-std::atomic<size_t> LogStatistics::SizesTotal;
-
-static std::string TagNameKey(const LogStatisticsElement& element) {
-    if (IsBinary(element.log_id)) {
-        uint32_t tag = element.tag;
-        if (tag) {
-            const char* cp = android::tagToName(tag);
-            if (cp) {
-                return std::string(cp);
-            }
-        }
-        return android::base::StringPrintf("[%" PRIu32 "]", tag);
-    }
-    const char* msg = element.msg;
-    if (!msg) {
-        return "chatty";
-    }
-    ++msg;
-    uint16_t len = element.msg_len;
-    len = (len <= 1) ? 0 : strnlen(msg, len - 1);
-    if (!len) {
-        return "<NULL>";
-    }
-    return std::string(msg, len);
-}
-
-LogStatistics::LogStatistics(bool enable_statistics, bool track_total_size,
-                             std::optional<log_time> start_time)
-    : enable(enable_statistics), track_total_size_(track_total_size) {
-    log_time now(CLOCK_REALTIME);
-    log_id_for_each(id) {
-        mSizes[id] = 0;
-        mElements[id] = 0;
-        mDroppedElements[id] = 0;
-        mSizesTotal[id] = 0;
-        mElementsTotal[id] = 0;
-        if (start_time) {
-            mOldest[id] = *start_time;
-            mNewest[id] = *start_time;
-        } else {
-            mOldest[id] = now;
-            mNewest[id] = now;
-        }
-        mNewestDropped[id] = now;
-    }
-}
-
-namespace android {
-
-size_t sizesTotal() {
-    return LogStatistics::sizesTotal();
-}
-
-// caller must own and free character string
-char* pidToName(pid_t pid) {
-    char* retval = nullptr;
-    if (pid == 0) {  // special case from auditd/klogd for kernel
-        retval = strdup("logd");
-    } else {
-        char buffer[512];
-        snprintf(buffer, sizeof(buffer), "/proc/%u/cmdline", pid);
-        int fd = open(buffer, O_RDONLY | O_CLOEXEC);
-        if (fd >= 0) {
-            ssize_t ret = read(fd, buffer, sizeof(buffer));
-            if (ret > 0) {
-                buffer[sizeof(buffer) - 1] = '\0';
-                // frameworks intermediate state
-                if (fastcmp<strcmp>(buffer, "<pre-initialized>")) {
-                    retval = strdup(buffer);
-                }
-            }
-            close(fd);
-        }
-    }
-    return retval;
-}
-}
-
-void LogStatistics::AddTotal(log_id_t log_id, uint16_t size) {
-    auto lock = std::lock_guard{lock_};
-
-    mSizesTotal[log_id] += size;
-    SizesTotal += size;
-    ++mElementsTotal[log_id];
-}
-
-void LogStatistics::Add(LogStatisticsElement element) {
-    auto lock = std::lock_guard{lock_};
-
-    if (!track_total_size_) {
-        element.total_len = element.msg_len;
-    }
-
-    log_id_t log_id = element.log_id;
-    uint16_t size = element.total_len;
-    mSizes[log_id] += size;
-    ++mElements[log_id];
-
-    // When caller adding a chatty entry, they will have already
-    // called add() and subtract() for each entry as they are
-    // evaluated and trimmed, thus recording size and number of
-    // elements, but we must recognize the manufactured dropped
-    // entry as not contributing to the lifetime totals.
-    if (element.dropped_count) {
-        ++mDroppedElements[log_id];
-    } else {
-        mSizesTotal[log_id] += size;
-        SizesTotal += size;
-        ++mElementsTotal[log_id];
-    }
-
-    log_time stamp(element.realtime);
-    if (mNewest[log_id] < stamp) {
-        // A major time update invalidates the statistics :-(
-        log_time diff = stamp - mNewest[log_id];
-        mNewest[log_id] = stamp;
-
-        if (diff.tv_sec > hourSec) {
-            // approximate Do-Your-Best fixup
-            diff += mOldest[log_id];
-            if ((diff > stamp) && ((diff - stamp).tv_sec < hourSec)) {
-                diff = stamp;
-            }
-            if (diff <= stamp) {
-                mOldest[log_id] = diff;
-                if (mNewestDropped[log_id] < diff) {
-                    mNewestDropped[log_id] = diff;
-                }
-            }
-        }
-    }
-
-    if (log_id == LOG_ID_KERNEL) {
-        return;
-    }
-
-    uidTable[log_id].Add(element.uid, element);
-    if (element.uid == AID_SYSTEM) {
-        pidSystemTable[log_id].Add(element.pid, element);
-    }
-
-    if (!enable) {
-        return;
-    }
-
-    pidTable.Add(element.pid, element);
-    tidTable.Add(element.tid, element);
-
-    uint32_t tag = element.tag;
-    if (tag) {
-        if (log_id == LOG_ID_SECURITY) {
-            securityTagTable.Add(tag, element);
-        } else {
-            tagTable.Add(tag, element);
-        }
-    }
-
-    if (!element.dropped_count) {
-        tagNameTable.Add(TagNameKey(element), element);
-    }
-}
-
-void LogStatistics::Subtract(LogStatisticsElement element) {
-    auto lock = std::lock_guard{lock_};
-
-    if (!track_total_size_) {
-        element.total_len = element.msg_len;
-    }
-
-    log_id_t log_id = element.log_id;
-    uint16_t size = element.total_len;
-    mSizes[log_id] -= size;
-    --mElements[log_id];
-    if (element.dropped_count) {
-        --mDroppedElements[log_id];
-    }
-
-    if (mOldest[log_id] < element.realtime) {
-        mOldest[log_id] = element.realtime;
-    }
-
-    if (log_id == LOG_ID_KERNEL) {
-        return;
-    }
-
-    uidTable[log_id].Subtract(element.uid, element);
-    if (element.uid == AID_SYSTEM) {
-        pidSystemTable[log_id].Subtract(element.pid, element);
-    }
-
-    if (!enable) {
-        return;
-    }
-
-    pidTable.Subtract(element.pid, element);
-    tidTable.Subtract(element.tid, element);
-
-    uint32_t tag = element.tag;
-    if (tag) {
-        if (log_id == LOG_ID_SECURITY) {
-            securityTagTable.Subtract(tag, element);
-        } else {
-            tagTable.Subtract(tag, element);
-        }
-    }
-
-    if (!element.dropped_count) {
-        tagNameTable.Subtract(TagNameKey(element), element);
-    }
-}
-
-// Atomically set an entry to drop
-// entry->setDropped(1) must follow this call, caller should do this explicitly.
-void LogStatistics::Drop(LogStatisticsElement element) {
-    CHECK_EQ(element.dropped_count, 0U);
-
-    auto lock = std::lock_guard{lock_};
-    log_id_t log_id = element.log_id;
-    uint16_t size = element.msg_len;
-    mSizes[log_id] -= size;
-    ++mDroppedElements[log_id];
-
-    if (mNewestDropped[log_id] < element.realtime) {
-        mNewestDropped[log_id] = element.realtime;
-    }
-
-    uidTable[log_id].Drop(element.uid, element);
-    if (element.uid == AID_SYSTEM) {
-        pidSystemTable[log_id].Drop(element.pid, element);
-    }
-
-    if (!enable) {
-        return;
-    }
-
-    pidTable.Drop(element.pid, element);
-    tidTable.Drop(element.tid, element);
-
-    uint32_t tag = element.tag;
-    if (tag) {
-        if (log_id == LOG_ID_SECURITY) {
-            securityTagTable.Drop(tag, element);
-        } else {
-            tagTable.Drop(tag, element);
-        }
-    }
-
-    tagNameTable.Subtract(TagNameKey(element), element);
-}
-
-void LogStatistics::Erase(LogStatisticsElement element) {
-    CHECK_GT(element.dropped_count, 0U);
-    CHECK_EQ(element.msg_len, 0U);
-
-    auto lock = std::lock_guard{lock_};
-
-    if (!track_total_size_) {
-        element.total_len = 0;
-    }
-
-    log_id_t log_id = element.log_id;
-    --mElements[log_id];
-    --mDroppedElements[log_id];
-    mSizes[log_id] -= element.total_len;
-
-    uidTable[log_id].Erase(element.uid, element);
-    if (element.uid == AID_SYSTEM) {
-        pidSystemTable[log_id].Erase(element.pid, element);
-    }
-
-    if (!enable) {
-        return;
-    }
-
-    pidTable.Erase(element.pid, element);
-    tidTable.Erase(element.tid, element);
-
-    uint32_t tag = element.tag;
-    if (tag) {
-        if (log_id == LOG_ID_SECURITY) {
-            securityTagTable.Erase(tag, element);
-        } else {
-            tagTable.Erase(tag, element);
-        }
-    }
-}
-
-const char* LogStatistics::UidToName(uid_t uid) const {
-    auto lock = std::lock_guard{lock_};
-    return UidToNameLocked(uid);
-}
-
-// caller must own and free character string
-const char* LogStatistics::UidToNameLocked(uid_t uid) const {
-    // Local hard coded favourites
-    if (uid == AID_LOGD) {
-        return strdup("auditd");
-    }
-
-    // Android system
-    if (uid < AID_APP) {
-        // in bionic, thread safe as long as we copy the results
-        struct passwd* pwd = getpwuid(uid);
-        if (pwd) {
-            return strdup(pwd->pw_name);
-        }
-    }
-
-    // Parse /data/system/packages.list
-    uid_t userId = uid % AID_USER_OFFSET;
-    const char* name = android::uidToName(userId);
-    if (!name && (userId > (AID_SHARED_GID_START - AID_APP))) {
-        name = android::uidToName(userId - (AID_SHARED_GID_START - AID_APP));
-    }
-    if (name) {
-        return name;
-    }
-
-    // Android application
-    if (uid >= AID_APP) {
-        struct passwd* pwd = getpwuid(uid);
-        if (pwd) {
-            return strdup(pwd->pw_name);
-        }
-    }
-
-    // report uid -> pid(s) -> pidToName if unique
-    for (pidTable_t::const_iterator it = pidTable.begin(); it != pidTable.end();
-         ++it) {
-        const PidEntry& entry = it->second;
-
-        if (entry.uid() == uid) {
-            const char* nameTmp = entry.name();
-
-            if (nameTmp) {
-                if (!name) {
-                    name = strdup(nameTmp);
-                } else if (fastcmp<strcmp>(name, nameTmp)) {
-                    free(const_cast<char*>(name));
-                    name = nullptr;
-                    break;
-                }
-            }
-        }
-    }
-
-    // No one
-    return name;
-}
-
-template <typename TKey, typename TEntry>
-void LogStatistics::WorstTwoWithThreshold(const LogHashtable<TKey, TEntry>& table, size_t threshold,
-                                          int* worst, size_t* worst_sizes,
-                                          size_t* second_worst_sizes) const {
-    std::array<const TKey*, 2> max_keys;
-    std::array<const TEntry*, 2> max_entries;
-    table.MaxEntries(AID_ROOT, 0, max_keys, max_entries);
-    if (max_entries[0] == nullptr || max_entries[1] == nullptr) {
-        return;
-    }
-    *worst_sizes = max_entries[0]->getSizes();
-    // b/24782000: Allow time horizon to extend roughly tenfold, assume average entry length is
-    // 100 characters.
-    if (*worst_sizes > threshold && *worst_sizes > (10 * max_entries[0]->dropped_count())) {
-        *worst = *max_keys[0];
-        *second_worst_sizes = max_entries[1]->getSizes();
-        if (*second_worst_sizes < threshold) {
-            *second_worst_sizes = threshold;
-        }
-    }
-}
-
-void LogStatistics::WorstTwoUids(log_id id, size_t threshold, int* worst, size_t* worst_sizes,
-                                 size_t* second_worst_sizes) const {
-    auto lock = std::lock_guard{lock_};
-    WorstTwoWithThreshold(uidTable[id], threshold, worst, worst_sizes, second_worst_sizes);
-}
-
-void LogStatistics::WorstTwoTags(size_t threshold, int* worst, size_t* worst_sizes,
-                                 size_t* second_worst_sizes) const {
-    auto lock = std::lock_guard{lock_};
-    WorstTwoWithThreshold(tagTable, threshold, worst, worst_sizes, second_worst_sizes);
-}
-
-void LogStatistics::WorstTwoSystemPids(log_id id, size_t worst_uid_sizes, int* worst,
-                                       size_t* second_worst_sizes) const {
-    auto lock = std::lock_guard{lock_};
-    std::array<const pid_t*, 2> max_keys;
-    std::array<const PidEntry*, 2> max_entries;
-    pidSystemTable[id].MaxEntries(AID_SYSTEM, 0, max_keys, max_entries);
-    if (max_entries[0] == nullptr || max_entries[1] == nullptr) {
-        return;
-    }
-
-    *worst = *max_keys[0];
-    *second_worst_sizes = worst_uid_sizes - max_entries[0]->getSizes() + max_entries[1]->getSizes();
-}
-
-// Prune at most 10% of the log entries or maxPrune, whichever is less.
-bool LogStatistics::ShouldPrune(log_id id, unsigned long max_size,
-                                unsigned long* prune_rows) const {
-    static constexpr size_t kMinPrune = 4;
-    static constexpr size_t kMaxPrune = 256;
-
-    auto lock = std::lock_guard{lock_};
-    size_t sizes = mSizes[id];
-    if (sizes <= max_size) {
-        return false;
-    }
-    size_t size_over = sizes - ((max_size * 9) / 10);
-    size_t elements = mElements[id] - mDroppedElements[id];
-    size_t min_elements = elements / 100;
-    if (min_elements < kMinPrune) {
-        min_elements = kMinPrune;
-    }
-    *prune_rows = elements * size_over / sizes;
-    if (*prune_rows < min_elements) {
-        *prune_rows = min_elements;
-    }
-    if (*prune_rows > kMaxPrune) {
-        *prune_rows = kMaxPrune;
-    }
-
-    return true;
-}
-
-std::string UidEntry::formatHeader(const std::string& name, log_id_t id) const {
-    bool isprune = worstUidEnabledForLogid(id);
-    return formatLine(android::base::StringPrintf(name.c_str(),
-                                                  android_log_id_to_name(id)),
-                      std::string("Size"),
-                      std::string(isprune ? "+/-  Pruned" : "")) +
-           formatLine(std::string("UID   PACKAGE"), std::string("BYTES"),
-                      std::string(isprune ? "NUM" : ""));
-}
-
-// Helper to truncate name, if too long, and add name dressings
-void LogStatistics::FormatTmp(const char* nameTmp, uid_t uid, std::string& name, std::string& size,
-                              size_t nameLen) const {
-    const char* allocNameTmp = nullptr;
-    if (!nameTmp) nameTmp = allocNameTmp = UidToNameLocked(uid);
-    if (nameTmp) {
-        size_t lenSpace = std::max(nameLen - name.length(), (size_t)1);
-        size_t len = EntryBase::TOTAL_LEN - EntryBase::PRUNED_LEN - size.length() - name.length() -
-                     lenSpace - 2;
-        size_t lenNameTmp = strlen(nameTmp);
-        while ((len < lenNameTmp) && (lenSpace > 1)) {
-            ++len;
-            --lenSpace;
-        }
-        name += android::base::StringPrintf("%*s", (int)lenSpace, "");
-        if (len < lenNameTmp) {
-            name += "...";
-            nameTmp += lenNameTmp - std::max(len - 3, (size_t)1);
-        }
-        name += nameTmp;
-        free(const_cast<char*>(allocNameTmp));
-    }
-}
-
-std::string UidEntry::format(const LogStatistics& stat, log_id_t id, uid_t uid) const
-        REQUIRES(stat.lock_) {
-    std::string name = android::base::StringPrintf("%u", uid);
-    std::string size = android::base::StringPrintf("%zu", getSizes());
-
-    stat.FormatTmp(nullptr, uid, name, size, 6);
-
-    std::string pruned = "";
-    if (worstUidEnabledForLogid(id)) {
-        size_t totalDropped = 0;
-        for (LogStatistics::uidTable_t::const_iterator it =
-                 stat.uidTable[id].begin();
-             it != stat.uidTable[id].end(); ++it) {
-            totalDropped += it->second.dropped_count();
-        }
-        size_t sizes = stat.mSizes[id];
-        size_t totalSize = stat.mSizesTotal[id];
-        size_t totalElements = stat.mElementsTotal[id];
-        float totalVirtualSize =
-            (float)sizes + (float)totalDropped * totalSize / totalElements;
-        size_t entrySize = getSizes();
-        float virtualEntrySize = entrySize;
-        int realPermille = virtualEntrySize * 1000.0 / sizes;
-        size_t dropped = dropped_count();
-        if (dropped) {
-            pruned = android::base::StringPrintf("%zu", dropped);
-            virtualEntrySize += (float)dropped * totalSize / totalElements;
-        }
-        int virtualPermille = virtualEntrySize * 1000.0 / totalVirtualSize;
-        int permille =
-            (realPermille - virtualPermille) * 1000L / (virtualPermille ?: 1);
-        if ((permille < -1) || (1 < permille)) {
-            std::string change;
-            const char* units = "%";
-            const char* prefix = (permille > 0) ? "+" : "";
-
-            if (permille > 999) {
-                permille = (permille + 1000) / 100;  // Now tenths fold
-                units = "X";
-                prefix = "";
-            }
-            if ((-99 < permille) && (permille < 99)) {
-                change = android::base::StringPrintf(
-                    "%s%d.%u%s", prefix, permille / 10,
-                    ((permille < 0) ? (-permille % 10) : (permille % 10)),
-                    units);
-            } else {
-                change = android::base::StringPrintf(
-                    "%s%d%s", prefix, (permille + 5) / 10, units);
-            }
-            ssize_t spaces = EntryBase::PRUNED_LEN - 2 - pruned.length() - change.length();
-            if ((spaces <= 0) && pruned.length()) {
-                spaces = 1;
-            }
-            if (spaces > 0) {
-                change += android::base::StringPrintf("%*s", (int)spaces, "");
-            }
-            pruned = change + pruned;
-        }
-    }
-
-    std::string output = formatLine(name, size, pruned);
-
-    if (uid != AID_SYSTEM) {
-        return output;
-    }
-
-    static const size_t maximum_sorted_entries = 32;
-    std::array<const pid_t*, maximum_sorted_entries> sorted_pids;
-    std::array<const PidEntry*, maximum_sorted_entries> sorted_entries;
-    stat.pidSystemTable[id].MaxEntries(uid, 0, sorted_pids, sorted_entries);
-
-    std::string byPid;
-    size_t index;
-    bool hasDropped = false;
-    for (index = 0; index < maximum_sorted_entries; ++index) {
-        const PidEntry* entry = sorted_entries[index];
-        if (!entry) {
-            break;
-        }
-        if (entry->getSizes() <= (getSizes() / 100)) {
-            break;
-        }
-        if (entry->dropped_count()) {
-            hasDropped = true;
-        }
-        byPid += entry->format(stat, id, *sorted_pids[index]);
-    }
-    if (index > 1) {  // print this only if interesting
-        std::string ditto("\" ");
-        output += formatLine(std::string("  PID/UID   COMMAND LINE"), ditto,
-                             hasDropped ? ditto : std::string(""));
-        output += byPid;
-    }
-
-    return output;
-}
-
-std::string PidEntry::formatHeader(const std::string& name,
-                                   log_id_t /* id */) const {
-    return formatLine(name, std::string("Size"), std::string("Pruned")) +
-           formatLine(std::string("  PID/UID   COMMAND LINE"),
-                      std::string("BYTES"), std::string("NUM"));
-}
-
-std::string PidEntry::format(const LogStatistics& stat, log_id_t, pid_t pid) const
-        REQUIRES(stat.lock_) {
-    std::string name = android::base::StringPrintf("%5u/%u", pid, uid_);
-    std::string size = android::base::StringPrintf("%zu", getSizes());
-
-    stat.FormatTmp(name_, uid_, name, size, 12);
-
-    std::string pruned = "";
-    size_t dropped = dropped_count();
-    if (dropped) {
-        pruned = android::base::StringPrintf("%zu", dropped);
-    }
-
-    return formatLine(name, size, pruned);
-}
-
-std::string TidEntry::formatHeader(const std::string& name,
-                                   log_id_t /* id */) const {
-    return formatLine(name, std::string("Size"), std::string("Pruned")) +
-           formatLine(std::string("  TID/UID   COMM"), std::string("BYTES"),
-                      std::string("NUM"));
-}
-
-std::string TidEntry::format(const LogStatistics& stat, log_id_t, pid_t tid) const
-        REQUIRES(stat.lock_) {
-    std::string name = android::base::StringPrintf("%5u/%u", tid, uid_);
-    std::string size = android::base::StringPrintf("%zu", getSizes());
-
-    stat.FormatTmp(name_, uid_, name, size, 12);
-
-    std::string pruned = "";
-    size_t dropped = dropped_count();
-    if (dropped) {
-        pruned = android::base::StringPrintf("%zu", dropped);
-    }
-
-    return formatLine(name, size, pruned);
-}
-
-std::string TagEntry::formatHeader(const std::string& name, log_id_t id) const {
-    bool isprune = worstUidEnabledForLogid(id);
-    return formatLine(name, std::string("Size"),
-                      std::string(isprune ? "Prune" : "")) +
-           formatLine(std::string("    TAG/UID   TAGNAME"),
-                      std::string("BYTES"), std::string(isprune ? "NUM" : ""));
-}
-
-std::string TagEntry::format(const LogStatistics&, log_id_t, uint32_t) const {
-    std::string name;
-    if (uid_ == (uid_t)-1) {
-        name = android::base::StringPrintf("%7u", key());
-    } else {
-        name = android::base::StringPrintf("%7u/%u", key(), uid_);
-    }
-    const char* nameTmp = this->name();
-    if (nameTmp) {
-        name += android::base::StringPrintf(
-            "%*s%s", (int)std::max(14 - name.length(), (size_t)1), "", nameTmp);
-    }
-
-    std::string size = android::base::StringPrintf("%zu", getSizes());
-
-    std::string pruned = "";
-    size_t dropped = dropped_count();
-    if (dropped) {
-        pruned = android::base::StringPrintf("%zu", dropped);
-    }
-
-    return formatLine(name, size, pruned);
-}
-
-std::string TagNameEntry::formatHeader(const std::string& name,
-                                       log_id_t /* id */) const {
-    return formatLine(name, std::string("Size"), std::string("")) +
-           formatLine(std::string("  TID/PID/UID   LOG_TAG NAME"),
-                      std::string("BYTES"), std::string(""));
-}
-
-std::string TagNameEntry::format(const LogStatistics&, log_id_t,
-                                 const std::string& key_name) const {
-    std::string name;
-    std::string pidstr;
-    if (pid_ != (pid_t)-1) {
-        pidstr = android::base::StringPrintf("%u", pid_);
-        if (tid_ != (pid_t)-1 && tid_ != pid_) pidstr = "/" + pidstr;
-    }
-    int len = 9 - pidstr.length();
-    if (len < 0) len = 0;
-    if (tid_ == (pid_t)-1 || tid_ == pid_) {
-        name = android::base::StringPrintf("%*s", len, "");
-    } else {
-        name = android::base::StringPrintf("%*u", len, tid_);
-    }
-    name += pidstr;
-    if (uid_ != (uid_t)-1) {
-        name += android::base::StringPrintf("/%u", uid_);
-    }
-
-    std::string size = android::base::StringPrintf("%zu", getSizes());
-
-    const char* nameTmp = key_name.data();
-    if (nameTmp) {
-        size_t lenSpace = std::max(16 - name.length(), (size_t)1);
-        size_t len = EntryBase::TOTAL_LEN - EntryBase::PRUNED_LEN - size.length() - name.length() -
-                     lenSpace - 2;
-        size_t lenNameTmp = strlen(nameTmp);
-        while ((len < lenNameTmp) && (lenSpace > 1)) {
-            ++len;
-            --lenSpace;
-        }
-        name += android::base::StringPrintf("%*s", (int)lenSpace, "");
-        if (len < lenNameTmp) {
-            name += "...";
-            nameTmp += lenNameTmp - std::max(len - 3, (size_t)1);
-        }
-        name += nameTmp;
-    }
-
-    std::string pruned = "";
-
-    return formatLine(name, size, pruned);
-}
-
-static std::string formatMsec(uint64_t val) {
-    static const unsigned subsecDigits = 3;
-    static const uint64_t sec = MS_PER_SEC;
-
-    static const uint64_t minute = 60 * sec;
-    static const uint64_t hour = 60 * minute;
-    static const uint64_t day = 24 * hour;
-
-    std::string output;
-    if (val < sec) return output;
-
-    if (val >= day) {
-        output = android::base::StringPrintf("%" PRIu64 "d ", val / day);
-        val = (val % day) + day;
-    }
-    if (val >= minute) {
-        if (val >= hour) {
-            output += android::base::StringPrintf("%" PRIu64 ":",
-                                                  (val / hour) % (day / hour));
-        }
-        output += android::base::StringPrintf(
-            (val >= hour) ? "%02" PRIu64 ":" : "%" PRIu64 ":",
-            (val / minute) % (hour / minute));
-    }
-    output +=
-        android::base::StringPrintf((val >= minute) ? "%02" PRIu64 : "%" PRIu64,
-                                    (val / sec) % (minute / sec));
-    val %= sec;
-    unsigned digits = subsecDigits;
-    while (digits && ((val % 10) == 0)) {
-        val /= 10;
-        --digits;
-    }
-    if (digits) {
-        output += android::base::StringPrintf(".%0*" PRIu64, digits, val);
-    }
-    return output;
-}
-
-template <typename TKey, typename TEntry>
-std::string LogStatistics::FormatTable(const LogHashtable<TKey, TEntry>& table, uid_t uid,
-                                       pid_t pid, const std::string& name, log_id_t id) const
-        REQUIRES(lock_) {
-    static const size_t maximum_sorted_entries = 32;
-    std::string output;
-    std::array<const TKey*, maximum_sorted_entries> sorted_keys;
-    std::array<const TEntry*, maximum_sorted_entries> sorted_entries;
-    table.MaxEntries(uid, pid, sorted_keys, sorted_entries);
-    bool header_printed = false;
-    for (size_t index = 0; index < maximum_sorted_entries; ++index) {
-        const TEntry* entry = sorted_entries[index];
-        if (!entry) {
-            break;
-        }
-        if (entry->getSizes() <= (sorted_entries[0]->getSizes() / 100)) {
-            break;
-        }
-        if (!header_printed) {
-            output += "\n\n";
-            output += entry->formatHeader(name, id);
-            header_printed = true;
-        }
-        output += entry->format(*this, id, *sorted_keys[index]);
-    }
-    return output;
-}
-
-std::string LogStatistics::ReportInteresting() const {
-    auto lock = std::lock_guard{lock_};
-
-    std::vector<std::string> items;
-
-    log_id_for_each(i) { items.emplace_back(std::to_string(mElements[i])); }
-
-    log_id_for_each(i) { items.emplace_back(std::to_string(mSizes[i])); }
-
-    log_id_for_each(i) {
-        items.emplace_back(std::to_string(overhead_[i] ? *overhead_[i] : mSizes[i]));
-    }
-
-    log_id_for_each(i) {
-        uint64_t oldest = mOldest[i].msec() / 1000;
-        uint64_t newest = mNewest[i].msec() / 1000;
-
-        int span = newest - oldest;
-
-        items.emplace_back(std::to_string(span));
-    }
-
-    return android::base::Join(items, ",");
-}
-
-std::string LogStatistics::Format(uid_t uid, pid_t pid, unsigned int logMask) const {
-    auto lock = std::lock_guard{lock_};
-
-    static const uint16_t spaces_total = 19;
-
-    // Report on total logging, current and for all time
-
-    std::string output = "size/num";
-    size_t oldLength;
-    int16_t spaces = 1;
-
-    log_id_for_each(id) {
-        if (!(logMask & (1 << id))) continue;
-        oldLength = output.length();
-        if (spaces < 0) spaces = 0;
-        output += android::base::StringPrintf("%*s%s", spaces, "",
-                                              android_log_id_to_name(id));
-        spaces += spaces_total + oldLength - output.length();
-    }
-    if (spaces < 0) spaces = 0;
-    output += android::base::StringPrintf("%*sTotal", spaces, "");
-
-    static const char TotalStr[] = "\nTotal";
-    spaces = 10 - strlen(TotalStr);
-    output += TotalStr;
-
-    size_t totalSize = 0;
-    size_t totalEls = 0;
-    log_id_for_each(id) {
-        if (!(logMask & (1 << id))) continue;
-        oldLength = output.length();
-        if (spaces < 0) spaces = 0;
-        size_t szs = mSizesTotal[id];
-        totalSize += szs;
-        size_t els = mElementsTotal[id];
-        totalEls += els;
-        output +=
-            android::base::StringPrintf("%*s%zu/%zu", spaces, "", szs, els);
-        spaces += spaces_total + oldLength - output.length();
-    }
-    if (spaces < 0) spaces = 0;
-    output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", totalSize,
-                                          totalEls);
-
-    static const char NowStr[] = "\nNow";
-    spaces = 10 - strlen(NowStr);
-    output += NowStr;
-
-    totalSize = 0;
-    totalEls = 0;
-    log_id_for_each(id) {
-        if (!(logMask & (1 << id))) continue;
-
-        size_t els = mElements[id];
-        if (els) {
-            oldLength = output.length();
-            if (spaces < 0) spaces = 0;
-            size_t szs = mSizes[id];
-            totalSize += szs;
-            totalEls += els;
-            output +=
-                android::base::StringPrintf("%*s%zu/%zu", spaces, "", szs, els);
-            spaces -= output.length() - oldLength;
-        }
-        spaces += spaces_total;
-    }
-    if (spaces < 0) spaces = 0;
-    output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", totalSize,
-                                          totalEls);
-
-    static const char SpanStr[] = "\nLogspan";
-    spaces = 10 - strlen(SpanStr);
-    output += SpanStr;
-
-    // Total reports the greater of the individual maximum time span, or the
-    // validated minimum start and maximum end time span if it makes sense.
-    uint64_t minTime = UINT64_MAX;
-    uint64_t maxTime = 0;
-    uint64_t maxSpan = 0;
-    totalSize = 0;
-
-    log_id_for_each(id) {
-        if (!(logMask & (1 << id))) continue;
-
-        // validity checking
-        uint64_t oldest = mOldest[id].msec();
-        uint64_t newest = mNewest[id].msec();
-        if (newest <= oldest) {
-            spaces += spaces_total;
-            continue;
-        }
-
-        uint64_t span = newest - oldest;
-        if (span > (monthSec * MS_PER_SEC)) {
-            spaces += spaces_total;
-            continue;
-        }
-
-        // total span
-        if (minTime > oldest) minTime = oldest;
-        if (maxTime < newest) maxTime = newest;
-        if (span > maxSpan) maxSpan = span;
-        totalSize += span;
-
-        uint64_t dropped = mNewestDropped[id].msec();
-        if (dropped < oldest) dropped = oldest;
-        if (dropped > newest) dropped = newest;
-
-        oldLength = output.length();
-        output += android::base::StringPrintf("%*s%s", spaces, "",
-                                              formatMsec(span).c_str());
-        unsigned permille = ((newest - dropped) * 1000 + (span / 2)) / span;
-        if ((permille > 1) && (permille < 999)) {
-            output += android::base::StringPrintf("(%u", permille / 10);
-            permille %= 10;
-            if (permille) {
-                output += android::base::StringPrintf(".%u", permille);
-            }
-            output += android::base::StringPrintf("%%)");
-        }
-        spaces -= output.length() - oldLength;
-        spaces += spaces_total;
-    }
-    if ((maxTime > minTime) && ((maxTime -= minTime) < totalSize) &&
-        (maxTime > maxSpan)) {
-        maxSpan = maxTime;
-    }
-    if (spaces < 0) spaces = 0;
-    output += android::base::StringPrintf("%*s%s", spaces, "",
-                                          formatMsec(maxSpan).c_str());
-
-    static const char OverheadStr[] = "\nOverhead";
-    spaces = 10 - strlen(OverheadStr);
-    output += OverheadStr;
-
-    totalSize = 0;
-    log_id_for_each(id) {
-        if (!(logMask & (1 << id))) continue;
-
-        size_t els = mElements[id];
-        if (els) {
-            oldLength = output.length();
-            if (spaces < 0) spaces = 0;
-            size_t szs = 0;
-            if (overhead_[id]) {
-                szs = *overhead_[id];
-            } else if (track_total_size_) {
-                szs = mSizes[id];
-            } else {
-                // Legacy fallback for Chatty without track_total_size_
-                // Estimate the size of this element in the parent std::list<> by adding two void*'s
-                // corresponding to the next/prev pointers and aligning to 64 bit.
-                static const size_t overhead =
-                        (sizeof(LogBufferElement) + 2 * sizeof(void*) + sizeof(uint64_t) - 1) &
-                        -sizeof(uint64_t);
-                szs = mSizes[id] + els * overhead;
-            }
-            totalSize += szs;
-            output += android::base::StringPrintf("%*s%zu", spaces, "", szs);
-            spaces -= output.length() - oldLength;
-        }
-        spaces += spaces_total;
-    }
-    totalSize += sizeOf();
-    if (spaces < 0) spaces = 0;
-    output += android::base::StringPrintf("%*s%zu", spaces, "", totalSize);
-
-    // Report on Chattiest
-
-    std::string name;
-
-    // Chattiest by application (UID)
-    log_id_for_each(id) {
-        if (!(logMask & (1 << id))) continue;
-
-        name = (uid == AID_ROOT) ? "Chattiest UIDs in %s log buffer:"
-                                 : "Logging for your UID in %s log buffer:";
-        output += FormatTable(uidTable[id], uid, pid, name, id);
-    }
-
-    if (enable) {
-        name = ((uid == AID_ROOT) && !pid) ? "Chattiest PIDs:"
-                                           : "Logging for this PID:";
-        output += FormatTable(pidTable, uid, pid, name);
-        name = "Chattiest TIDs";
-        if (pid) name += android::base::StringPrintf(" for PID %d", pid);
-        name += ":";
-        output += FormatTable(tidTable, uid, pid, name);
-    }
-
-    if (enable && (logMask & (1 << LOG_ID_EVENTS))) {
-        name = "Chattiest events log buffer TAGs";
-        if (pid) name += android::base::StringPrintf(" for PID %d", pid);
-        name += ":";
-        output += FormatTable(tagTable, uid, pid, name, LOG_ID_EVENTS);
-    }
-
-    if (enable && (logMask & (1 << LOG_ID_SECURITY))) {
-        name = "Chattiest security log buffer TAGs";
-        if (pid) name += android::base::StringPrintf(" for PID %d", pid);
-        name += ":";
-        output += FormatTable(securityTagTable, uid, pid, name, LOG_ID_SECURITY);
-    }
-
-    if (enable) {
-        name = "Chattiest TAGs";
-        if (pid) name += android::base::StringPrintf(" for PID %d", pid);
-        name += ":";
-        output += FormatTable(tagNameTable, uid, pid, name);
-    }
-
-    return output;
-}
-
-namespace android {
-
-uid_t pidToUid(pid_t pid) {
-    char buffer[512];
-    snprintf(buffer, sizeof(buffer), "/proc/%u/status", pid);
-    FILE* fp = fopen(buffer, "re");
-    if (fp) {
-        while (fgets(buffer, sizeof(buffer), fp)) {
-            int uid = AID_LOGD;
-            char space = 0;
-            if ((sscanf(buffer, "Uid: %d%c", &uid, &space) == 2) &&
-                isspace(space)) {
-                fclose(fp);
-                return uid;
-            }
-        }
-        fclose(fp);
-    }
-    return AID_LOGD;  // associate this with the logger
-}
-}
-
-uid_t LogStatistics::PidToUid(pid_t pid) {
-    auto lock = std::lock_guard{lock_};
-    return pidTable.Add(pid)->second.uid();
-}
-
-// caller must free character string
-const char* LogStatistics::PidToName(pid_t pid) const {
-    auto lock = std::lock_guard{lock_};
-    // An inconvenient truth ... getName() can alter the object
-    pidTable_t& writablePidTable = const_cast<pidTable_t&>(pidTable);
-    const char* name = writablePidTable.Add(pid)->second.name();
-    if (!name) {
-        return nullptr;
-    }
-    return strdup(name);
-}
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
deleted file mode 100644
index faf9283..0000000
--- a/logd/LogStatistics.h
+++ /dev/null
@@ -1,595 +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.
- */
-
-#pragma once
-
-#include <ctype.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include <algorithm>  // std::max
-#include <array>
-#include <memory>
-#include <mutex>
-#include <string>
-#include <string_view>
-#include <unordered_map>
-
-#include <android-base/stringprintf.h>
-#include <android-base/thread_annotations.h>
-#include <android/log.h>
-#include <log/log_time.h>
-#include <private/android_filesystem_config.h>
-#include <utils/FastStrcmp.h>
-
-#include "LogUtils.h"
-
-#define log_id_for_each(i) \
-    for (log_id_t i = LOG_ID_MIN; (i) < LOG_ID_MAX; (i) = (log_id_t)((i) + 1))
-
-class LogStatistics;
-class UidEntry;
-class PidEntry;
-
-struct LogStatisticsElement {
-    uid_t uid;
-    pid_t pid;
-    pid_t tid;
-    uint32_t tag;
-    log_time realtime;
-    const char* msg;
-    uint16_t msg_len;
-    uint16_t dropped_count;
-    log_id_t log_id;
-    uint16_t total_len;
-};
-
-template <typename TKey, typename TEntry>
-class LogHashtable {
-    std::unordered_map<TKey, TEntry> map;
-
-    size_t bucket_size() const {
-        size_t count = 0;
-        for (size_t idx = 0; idx < map.bucket_count(); ++idx) {
-            size_t bucket_size = map.bucket_size(idx);
-            if (bucket_size == 0) bucket_size = 1;
-            count += bucket_size;
-        }
-        float load_factor = map.max_load_factor();
-        if (load_factor < 1.0) return count;
-        return count * load_factor;
-    }
-
-    static const size_t unordered_map_per_entry_overhead = sizeof(void*);
-    static const size_t unordered_map_bucket_overhead = sizeof(void*);
-
-  public:
-    size_t size() const {
-        return map.size();
-    }
-
-    // Estimate unordered_map memory usage.
-    size_t sizeOf() const {
-        return sizeof(*this) +
-               (size() * (sizeof(TEntry) + unordered_map_per_entry_overhead)) +
-               (bucket_size() * sizeof(size_t) + unordered_map_bucket_overhead);
-    }
-
-    typedef typename std::unordered_map<TKey, TEntry>::iterator iterator;
-    typedef
-        typename std::unordered_map<TKey, TEntry>::const_iterator const_iterator;
-
-    // Returns a sorted array of up to len highest entries sorted by size.  If fewer than len
-    // entries are found, their positions are set to nullptr.
-    template <size_t len>
-    void MaxEntries(uid_t uid, pid_t pid, std::array<const TKey*, len>& out_keys,
-                    std::array<const TEntry*, len>& out_entries) const {
-        out_keys.fill(nullptr);
-        out_entries.fill(nullptr);
-        for (const auto& [key, entry] : map) {
-            uid_t entry_uid = 0;
-            if constexpr (std::is_same_v<TEntry, UidEntry>) {
-                entry_uid = key;
-            } else {
-                entry_uid = entry.uid();
-            }
-            if (uid != AID_ROOT && uid != entry_uid) {
-                continue;
-            }
-            pid_t entry_pid = 0;
-            if constexpr (std::is_same_v<TEntry, PidEntry>) {
-                entry_pid = key;
-            } else {
-                entry_pid = entry.pid();
-            }
-            if (pid && entry_pid && pid != entry_pid) {
-                continue;
-            }
-
-            size_t sizes = entry.getSizes();
-            ssize_t index = len - 1;
-            while ((!out_entries[index] || sizes > out_entries[index]->getSizes()) && --index >= 0)
-                ;
-            if (++index < (ssize_t)len) {
-                size_t num = len - index - 1;
-                if (num) {
-                    memmove(&out_keys[index + 1], &out_keys[index], num * sizeof(const TKey*));
-                    memmove(&out_entries[index + 1], &out_entries[index],
-                            num * sizeof(const TEntry*));
-                }
-                out_keys[index] = &key;
-                out_entries[index] = &entry;
-            }
-        }
-    }
-
-    iterator Add(const TKey& key, const LogStatisticsElement& element) {
-        iterator it = map.find(key);
-        if (it == map.end()) {
-            it = map.insert(std::make_pair(key, TEntry(element))).first;
-        } else {
-            it->second.Add(element);
-        }
-        return it;
-    }
-
-    iterator Add(const TKey& key) {
-        iterator it = map.find(key);
-        if (it == map.end()) {
-            it = map.insert(std::make_pair(key, TEntry(key))).first;
-        } else {
-            it->second.Add(key);
-        }
-        return it;
-    }
-
-    void Subtract(const TKey& key, const LogStatisticsElement& element) {
-        iterator it = map.find(key);
-        if (it != map.end() && it->second.Subtract(element)) {
-            map.erase(it);
-        }
-    }
-
-    void Drop(const TKey& key, const LogStatisticsElement& element) {
-        iterator it = map.find(key);
-        if (it != map.end()) {
-            it->second.Drop(element);
-        }
-    }
-
-    void Erase(const TKey& key, const LogStatisticsElement& element) {
-        iterator it = map.find(key);
-        if (it != map.end()) {
-            it->second.Erase(element);
-        }
-    }
-
-    iterator begin() { return map.begin(); }
-    const_iterator begin() const { return map.begin(); }
-    iterator end() { return map.end(); }
-    const_iterator end() const { return map.end(); }
-};
-
-class EntryBase {
-  public:
-    EntryBase() : size_(0) {}
-    explicit EntryBase(const LogStatisticsElement& element) : size_(element.total_len) {}
-
-    size_t getSizes() const { return size_; }
-
-    void Add(const LogStatisticsElement& element) { size_ += element.total_len; }
-    bool Subtract(const LogStatisticsElement& element) {
-        size_ -= element.total_len;
-        return size_ == 0;
-    }
-    void Drop(const LogStatisticsElement& element) { size_ -= element.msg_len; }
-    void Erase(const LogStatisticsElement& element) { size_ -= element.total_len; }
-
-    static constexpr size_t PRUNED_LEN = 14;
-    static constexpr size_t TOTAL_LEN = 80;
-
-    static std::string formatLine(const std::string& name,
-                                  const std::string& size,
-                                  const std::string& pruned) {
-        ssize_t drop_len = std::max(pruned.length() + 1, PRUNED_LEN);
-        ssize_t size_len = std::max(size.length() + 1, TOTAL_LEN - name.length() - drop_len - 1);
-
-        std::string ret = android::base::StringPrintf(
-            "%s%*s%*s", name.c_str(), (int)size_len, size.c_str(),
-            (int)drop_len, pruned.c_str());
-        // remove any trailing spaces
-        size_t pos = ret.size();
-        size_t len = 0;
-        while (pos && isspace(ret[--pos])) ++len;
-        if (len) ret.erase(pos + 1, len);
-        return ret + "\n";
-    }
-
-  private:
-    size_t size_;
-};
-
-class EntryBaseDropped : public EntryBase {
-  public:
-    EntryBaseDropped() : dropped_(0) {}
-    explicit EntryBaseDropped(const LogStatisticsElement& element)
-        : EntryBase(element), dropped_(element.dropped_count) {}
-
-    size_t dropped_count() const { return dropped_; }
-
-    void Add(const LogStatisticsElement& element) {
-        dropped_ += element.dropped_count;
-        EntryBase::Add(element);
-    }
-    bool Subtract(const LogStatisticsElement& element) {
-        dropped_ -= element.dropped_count;
-        return EntryBase::Subtract(element) && dropped_ == 0;
-    }
-    void Drop(const LogStatisticsElement& element) {
-        dropped_ += 1;
-        EntryBase::Drop(element);
-    }
-
-  private:
-    size_t dropped_;
-};
-
-class UidEntry : public EntryBaseDropped {
-  public:
-    explicit UidEntry(const LogStatisticsElement& element)
-        : EntryBaseDropped(element), pid_(element.pid) {}
-
-    pid_t pid() const { return pid_; }
-
-    void Add(const LogStatisticsElement& element) {
-        if (pid_ != element.pid) {
-            pid_ = -1;
-        }
-        EntryBaseDropped::Add(element);
-    }
-
-    std::string formatHeader(const std::string& name, log_id_t id) const;
-    std::string format(const LogStatistics& stat, log_id_t id, uid_t uid) const;
-
-  private:
-    pid_t pid_;
-};
-
-namespace android {
-uid_t pidToUid(pid_t pid);
-}
-
-class PidEntry : public EntryBaseDropped {
-  public:
-    explicit PidEntry(pid_t pid)
-        : EntryBaseDropped(),
-          uid_(android::pidToUid(pid)),
-          name_(android::pidToName(pid)) {}
-    explicit PidEntry(const LogStatisticsElement& element)
-        : EntryBaseDropped(element), uid_(element.uid), name_(android::pidToName(element.pid)) {}
-    PidEntry(const PidEntry& element)
-        : EntryBaseDropped(element),
-          uid_(element.uid_),
-          name_(element.name_ ? strdup(element.name_) : nullptr) {}
-    ~PidEntry() { free(name_); }
-
-    uid_t uid() const { return uid_; }
-    const char* name() const { return name_; }
-
-    void Add(pid_t new_pid) {
-        if (name_ && !fastcmp<strncmp>(name_, "zygote", 6)) {
-            free(name_);
-            name_ = nullptr;
-        }
-        if (!name_) {
-            name_ = android::pidToName(new_pid);
-        }
-    }
-
-    void Add(const LogStatisticsElement& element) {
-        uid_t incoming_uid = element.uid;
-        if (uid() != incoming_uid) {
-            uid_ = incoming_uid;
-            free(name_);
-            name_ = android::pidToName(element.pid);
-        } else {
-            Add(element.pid);
-        }
-        EntryBaseDropped::Add(element);
-    }
-
-    std::string formatHeader(const std::string& name, log_id_t id) const;
-    std::string format(const LogStatistics& stat, log_id_t id, pid_t pid) const;
-
-  private:
-    uid_t uid_;
-    char* name_;
-};
-
-class TidEntry : public EntryBaseDropped {
-  public:
-    TidEntry(pid_t tid, pid_t pid)
-        : EntryBaseDropped(),
-          pid_(pid),
-          uid_(android::pidToUid(tid)),
-          name_(android::tidToName(tid)) {}
-    explicit TidEntry(const LogStatisticsElement& element)
-        : EntryBaseDropped(element),
-          pid_(element.pid),
-          uid_(element.uid),
-          name_(android::tidToName(element.tid)) {}
-    TidEntry(const TidEntry& element)
-        : EntryBaseDropped(element),
-          pid_(element.pid_),
-          uid_(element.uid_),
-          name_(element.name_ ? strdup(element.name_) : nullptr) {}
-    ~TidEntry() { free(name_); }
-
-    pid_t pid() const { return pid_; }
-    uid_t uid() const { return uid_; }
-    const char* name() const { return name_; }
-
-    void Add(pid_t incomingTid) {
-        if (name_ && !fastcmp<strncmp>(name_, "zygote", 6)) {
-            free(name_);
-            name_ = nullptr;
-        }
-        if (!name_) {
-            name_ = android::tidToName(incomingTid);
-        }
-    }
-
-    void Add(const LogStatisticsElement& element) {
-        uid_t incoming_uid = element.uid;
-        pid_t incoming_pid = element.pid;
-        if (uid() != incoming_uid || pid() != incoming_pid) {
-            uid_ = incoming_uid;
-            pid_ = incoming_pid;
-            free(name_);
-            name_ = android::tidToName(element.tid);
-        } else {
-            Add(element.tid);
-        }
-        EntryBaseDropped::Add(element);
-    }
-
-    std::string formatHeader(const std::string& name, log_id_t id) const;
-    std::string format(const LogStatistics& stat, log_id_t id, pid_t pid) const;
-
-  private:
-    pid_t pid_;
-    uid_t uid_;
-    char* name_;
-};
-
-class TagEntry : public EntryBaseDropped {
-  public:
-    explicit TagEntry(const LogStatisticsElement& element)
-        : EntryBaseDropped(element), tag_(element.tag), pid_(element.pid), uid_(element.uid) {}
-
-    uint32_t key() const { return tag_; }
-    pid_t pid() const { return pid_; }
-    uid_t uid() const { return uid_; }
-    const char* name() const { return android::tagToName(tag_); }
-
-    void Add(const LogStatisticsElement& element) {
-        if (uid_ != element.uid) {
-            uid_ = -1;
-        }
-        if (pid_ != element.pid) {
-            pid_ = -1;
-        }
-        EntryBaseDropped::Add(element);
-    }
-
-    std::string formatHeader(const std::string& name, log_id_t id) const;
-    std::string format(const LogStatistics& stat, log_id_t id, uint32_t) const;
-
-  private:
-    const uint32_t tag_;
-    pid_t pid_;
-    uid_t uid_;
-};
-
-class TagNameEntry : public EntryBase {
-  public:
-    explicit TagNameEntry(const LogStatisticsElement& element)
-        : EntryBase(element), tid_(element.tid), pid_(element.pid), uid_(element.uid) {}
-
-    pid_t tid() const { return tid_; }
-    pid_t pid() const { return pid_; }
-    uid_t uid() const { return uid_; }
-
-    void Add(const LogStatisticsElement& element) {
-        if (uid_ != element.uid) {
-            uid_ = -1;
-        }
-        if (pid_ != element.pid) {
-            pid_ = -1;
-        }
-        if (tid_ != element.tid) {
-            tid_ = -1;
-        }
-        EntryBase::Add(element);
-    }
-
-    std::string formatHeader(const std::string& name, log_id_t id) const;
-    std::string format(const LogStatistics& stat, log_id_t id, const std::string& key_name) const;
-
-  private:
-    pid_t tid_;
-    pid_t pid_;
-    uid_t uid_;
-};
-
-class LogStatistics {
-    friend UidEntry;
-    friend PidEntry;
-    friend TidEntry;
-
-    size_t mSizes[LOG_ID_MAX] GUARDED_BY(lock_);
-    size_t mElements[LOG_ID_MAX] GUARDED_BY(lock_);
-    size_t mDroppedElements[LOG_ID_MAX] GUARDED_BY(lock_);
-    size_t mSizesTotal[LOG_ID_MAX] GUARDED_BY(lock_);
-    size_t mElementsTotal[LOG_ID_MAX] GUARDED_BY(lock_);
-    log_time mOldest[LOG_ID_MAX] GUARDED_BY(lock_);
-    log_time mNewest[LOG_ID_MAX] GUARDED_BY(lock_);
-    log_time mNewestDropped[LOG_ID_MAX] GUARDED_BY(lock_);
-    static std::atomic<size_t> SizesTotal;
-    bool enable;
-
-    // uid to size list
-    typedef LogHashtable<uid_t, UidEntry> uidTable_t;
-    uidTable_t uidTable[LOG_ID_MAX] GUARDED_BY(lock_);
-
-    // pid of system to size list
-    typedef LogHashtable<pid_t, PidEntry> pidSystemTable_t;
-    pidSystemTable_t pidSystemTable[LOG_ID_MAX] GUARDED_BY(lock_);
-
-    // pid to uid list
-    typedef LogHashtable<pid_t, PidEntry> pidTable_t;
-    pidTable_t pidTable GUARDED_BY(lock_);
-
-    // tid to uid list
-    typedef LogHashtable<pid_t, TidEntry> tidTable_t;
-    tidTable_t tidTable GUARDED_BY(lock_);
-
-    // tag list
-    typedef LogHashtable<uint32_t, TagEntry> tagTable_t;
-    tagTable_t tagTable GUARDED_BY(lock_);
-
-    // security tag list
-    tagTable_t securityTagTable GUARDED_BY(lock_);
-
-    // global tag list
-    typedef LogHashtable<std::string, TagNameEntry> tagNameTable_t;
-    tagNameTable_t tagNameTable;
-
-    size_t sizeOf() const REQUIRES(lock_) {
-        size_t size = sizeof(*this) + pidTable.sizeOf() + tidTable.sizeOf() +
-                      tagTable.sizeOf() + securityTagTable.sizeOf() +
-                      tagNameTable.sizeOf() +
-                      (pidTable.size() * sizeof(pidTable_t::iterator)) +
-                      (tagTable.size() * sizeof(tagTable_t::iterator));
-        for (const auto& it : pidTable) {
-            const char* name = it.second.name();
-            if (name) size += strlen(name) + 1;
-        }
-        for (const auto& it : tidTable) {
-            const char* name = it.second.name();
-            if (name) size += strlen(name) + 1;
-        }
-        for (const auto& it : tagNameTable) {
-            size += sizeof(std::string);
-            size_t len = it.first.size();
-            // Account for short string optimization: if the string's length is <= 22 bytes for 64
-            // bit or <= 10 bytes for 32 bit, then there is no additional allocation.
-            if ((sizeof(std::string) == 24 && len > 22) ||
-                (sizeof(std::string) != 24 && len > 10)) {
-                size += len;
-            }
-        }
-        log_id_for_each(id) {
-            size += uidTable[id].sizeOf();
-            size += uidTable[id].size() * sizeof(uidTable_t::iterator);
-            size += pidSystemTable[id].sizeOf();
-            size += pidSystemTable[id].size() * sizeof(pidSystemTable_t::iterator);
-        }
-        return size;
-    }
-
-  public:
-    LogStatistics(bool enable_statistics, bool track_total_size,
-                  std::optional<log_time> start_time = {});
-
-    void AddTotal(log_id_t log_id, uint16_t size) EXCLUDES(lock_);
-
-    // Add is for adding an element to the log buffer.  It may be a chatty element in the case of
-    // log deduplication.  Add the total size of the element to statistics.
-    void Add(LogStatisticsElement entry) EXCLUDES(lock_);
-    // Subtract is for removing an element from the log buffer.  It may be a chatty element.
-    // Subtract the total size of the element from statistics.
-    void Subtract(LogStatisticsElement entry) EXCLUDES(lock_);
-    // Drop is for converting a normal element into a chatty element. entry->setDropped(1) must
-    // follow this call.  Subtract only msg_len from statistics, since a chatty element will remain.
-    void Drop(LogStatisticsElement entry) EXCLUDES(lock_);
-    // Erase is for coalescing two chatty elements into one.  Erase() is called on the element that
-    // is removed from the log buffer.  Subtract the total size of the element, which is by
-    // definition only the size of the LogBufferElement + list overhead for chatty elements.
-    void Erase(LogStatisticsElement element) EXCLUDES(lock_);
-
-    void WorstTwoUids(log_id id, size_t threshold, int* worst, size_t* worst_sizes,
-                      size_t* second_worst_sizes) const EXCLUDES(lock_);
-    void WorstTwoTags(size_t threshold, int* worst, size_t* worst_sizes,
-                      size_t* second_worst_sizes) const EXCLUDES(lock_);
-    void WorstTwoSystemPids(log_id id, size_t worst_uid_sizes, int* worst,
-                            size_t* second_worst_sizes) const EXCLUDES(lock_);
-
-    bool ShouldPrune(log_id id, unsigned long max_size, unsigned long* prune_rows) const
-            EXCLUDES(lock_);
-
-    // Return the consumed size of the given buffer.
-    size_t Sizes(log_id_t id) const EXCLUDES(lock_) {
-        auto lock = std::lock_guard{lock_};
-        if (overhead_[id]) {
-            return *overhead_[id];
-        }
-        return mSizes[id];
-    }
-
-    // Return the uncompressed size of the contents of the given buffer.
-    size_t SizeReadable(log_id_t id) const EXCLUDES(lock_) {
-        auto lock = std::lock_guard{lock_};
-        return mSizes[id];
-    }
-
-    // TODO: Get rid of this entirely.
-    static size_t sizesTotal() {
-        return SizesTotal;
-    }
-
-    std::string ReportInteresting() const EXCLUDES(lock_);
-    std::string Format(uid_t uid, pid_t pid, unsigned int logMask) const EXCLUDES(lock_);
-
-    const char* PidToName(pid_t pid) const EXCLUDES(lock_);
-    uid_t PidToUid(pid_t pid) EXCLUDES(lock_);
-    const char* UidToName(uid_t uid) const EXCLUDES(lock_);
-
-    void set_overhead(log_id_t id, size_t size) {
-        auto lock = std::lock_guard{lock_};
-        overhead_[id] = size;
-    }
-
-  private:
-    template <typename TKey, typename TEntry>
-    void WorstTwoWithThreshold(const LogHashtable<TKey, TEntry>& table, size_t threshold,
-                               int* worst, size_t* worst_sizes, size_t* second_worst_sizes) const;
-    template <typename TKey, typename TEntry>
-    std::string FormatTable(const LogHashtable<TKey, TEntry>& table, uid_t uid, pid_t pid,
-                            const std::string& name = std::string(""),
-                            log_id_t id = LOG_ID_MAX) const REQUIRES(lock_);
-    void FormatTmp(const char* nameTmp, uid_t uid, std::string& name, std::string& size,
-                   size_t nameLen) const REQUIRES(lock_);
-    const char* UidToNameLocked(uid_t uid) const REQUIRES(lock_);
-
-    mutable std::mutex lock_;
-    bool track_total_size_;
-
-    std::optional<size_t> overhead_[LOG_ID_MAX] GUARDED_BY(lock_);
-};
diff --git a/logd/LogTags.cpp b/logd/LogTags.cpp
deleted file mode 100644
index 1b7107f..0000000
--- a/logd/LogTags.cpp
+++ /dev/null
@@ -1,888 +0,0 @@
-/*
- * Copyright (C) 2017 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 <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <string>
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/macros.h>
-#include <android-base/scopeguard.h>
-#include <android-base/stringprintf.h>
-#include <android-base/threads.h>
-#include <log/log_event_list.h>
-#include <log/log_properties.h>
-#include <log/log_read.h>
-#include <private/android_filesystem_config.h>
-
-#include "LogStatistics.h"
-#include "LogTags.h"
-#include "LogUtils.h"
-
-using android::base::make_scope_guard;
-
-static LogTags* logtags;
-
-const char LogTags::system_event_log_tags[] = "/system/etc/event-log-tags";
-const char LogTags::dynamic_event_log_tags[] = "/dev/event-log-tags";
-// Only for debug
-const char LogTags::debug_event_log_tags[] = "/data/misc/logd/event-log-tags";
-
-// Sniff for first uid=%d in utf8z comment string
-static uid_t sniffUid(const char* comment, const char* endp) {
-    if (!comment) return AID_ROOT;
-
-    if (*comment == '#') ++comment;
-    while ((comment < endp) && (*comment != '\n') && isspace(*comment))
-        ++comment;
-    static const char uid_str[] = "uid=";
-    if (((comment + strlen(uid_str)) >= endp) ||
-        fastcmp<strncmp>(comment, uid_str, strlen(uid_str)) ||
-        !isdigit(comment[strlen(uid_str)]))
-        return AID_ROOT;
-    char* cp;
-    unsigned long Uid = strtoul(comment + 4, &cp, 10);
-    if ((cp > endp) || (Uid >= INT_MAX)) return AID_ROOT;
-
-    return Uid;
-}
-
-// Checks for file corruption, and report false if there was no need
-// to rebuild the referenced file.  Failure to rebuild is only logged,
-// does not cause a return value of false.
-bool LogTags::RebuildFileEventLogTags(const char* filename, bool warn) {
-    int fd;
-
-    {
-        android::RWLock::AutoRLock readLock(rwlock);
-
-        if (tag2total.begin() == tag2total.end()) {
-            return false;
-        }
-
-        file2watermark_const_iterator iwater = file2watermark.find(filename);
-        if (iwater == file2watermark.end()) {
-            return false;
-        }
-
-        struct stat sb;
-        if (!stat(filename, &sb) && ((size_t)sb.st_size >= iwater->second)) {
-            return false;
-        }
-
-        // dump what we already know back into the file?
-        fd = TEMP_FAILURE_RETRY(open(
-            filename, O_WRONLY | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY));
-        if (fd >= 0) {
-            time_t now = time(nullptr);
-            struct tm tm;
-            localtime_r(&now, &tm);
-            char timebuf[20];
-            strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", &tm);
-            android::base::WriteStringToFd(
-                android::base::StringPrintf(
-                    "# Rebuilt %.20s, content owned by logd\n", timebuf),
-                fd);
-            for (const auto& it : tag2total) {
-                android::base::WriteStringToFd(
-                    formatEntry_locked(it.first, AID_ROOT), fd);
-            }
-            close(fd);
-        }
-    }
-
-    if (warn) {
-        if (fd < 0) {
-            LOG(ERROR) << filename << " failed to rebuild";
-        } else {
-            LOG(ERROR) << filename << " missing, damaged or truncated; rebuilt";
-        }
-    }
-
-    if (fd >= 0) {
-        android::RWLock::AutoWLock writeLock(rwlock);
-
-        struct stat sb;
-        if (!stat(filename, &sb)) file2watermark[filename] = sb.st_size;
-    }
-
-    return true;
-}
-
-void LogTags::AddEventLogTags(uint32_t tag, uid_t uid, const std::string& Name,
-                              const std::string& Format, const char* source,
-                              bool warn) {
-    std::string Key = Name;
-    if (Format.length()) Key += "+" + Format;
-
-    bool update = !source || !!strcmp(source, system_event_log_tags);
-    bool newOne;
-
-    {
-        android::RWLock::AutoWLock writeLock(rwlock);
-
-        tag2total_const_iterator itot = tag2total.find(tag);
-
-        // unlikely except for dupes, or updates to uid list (more later)
-        if (itot != tag2total.end()) update = false;
-
-        newOne = tag2name.find(tag) == tag2name.end();
-        key2tag[Key] = tag;
-
-        if (Format.length()) {
-            if (key2tag.find(Name) == key2tag.end()) {
-                key2tag[Name] = tag;
-            }
-            tag2format[tag] = Format;
-        }
-        tag2name[tag] = Name;
-
-        tag2uid_const_iterator ut = tag2uid.find(tag);
-        if (ut != tag2uid.end()) {
-            if (uid == AID_ROOT) {
-                tag2uid.erase(ut);
-                update = true;
-            } else if (ut->second.find(uid) == ut->second.end()) {
-                const_cast<uid_list&>(ut->second).emplace(uid);
-                update = true;
-            }
-        } else if (newOne && (uid != AID_ROOT)) {
-            tag2uid[tag].emplace(uid);
-            update = true;
-        }
-
-        // updatePersist -> trigger output on modified
-        // content, reset tag2total if available
-        if (update && (itot != tag2total.end())) tag2total[tag] = 0;
-    }
-
-    if (update) {
-        WritePersistEventLogTags(tag, uid, source);
-    } else if (warn && !newOne && source) {
-        // For the files, we want to report dupes.
-        LOG(DEBUG) << "Multiple tag " << tag << " " << Name << " " << Format << " " << source;
-    }
-}
-
-// Read the event log tags file, and build up our internal database
-void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
-    bool etc = !strcmp(filename, system_event_log_tags);
-
-    if (!etc) {
-        RebuildFileEventLogTags(filename, warn);
-    }
-    std::string content;
-    if (android::base::ReadFileToString(filename, &content)) {
-        char* cp = (char*)content.c_str();
-        char* endp = cp + content.length();
-
-        {
-            android::RWLock::AutoRLock writeLock(rwlock);
-
-            file2watermark[filename] = content.length();
-        }
-
-        char* lineStart = cp;
-        while (cp < endp) {
-            if (*cp == '\n') {
-                lineStart = cp;
-            } else if (lineStart) {
-                if (*cp == '#') {
-                    /* comment; just scan to end */
-                    lineStart = nullptr;
-                } else if (isdigit(*cp)) {
-                    unsigned long Tag = strtoul(cp, &cp, 10);
-                    if (warn && (Tag > emptyTag)) {
-                        LOG(WARNING) << "tag too large " << Tag;
-                    }
-                    while ((cp < endp) && (*cp != '\n') && isspace(*cp)) ++cp;
-                    if (cp >= endp) break;
-                    if (*cp == '\n') continue;
-                    const char* name = cp;
-                    /* Determine whether it is a valid tag name [a-zA-Z0-9_] */
-                    bool hasAlpha = false;
-                    while ((cp < endp) && (isalnum(*cp) || (*cp == '_'))) {
-                        if (!isdigit(*cp)) hasAlpha = true;
-                        ++cp;
-                    }
-                    std::string Name(name, cp - name);
-#ifdef ALLOW_NOISY_LOGGING_OF_PROBLEM_WITH_LOTS_OF_TECHNICAL_DEBT
-                    static const size_t maximum_official_tag_name_size = 24;
-                    if (warn && (Name.length() > maximum_official_tag_name_size)) {
-                        LOG(WARNING) << "tag name too long " << Name;
-                    }
-#endif
-                    if (hasAlpha &&
-                        ((cp >= endp) || (*cp == '#') || isspace(*cp))) {
-                        if (Tag > emptyTag) {
-                            if (*cp != '\n') lineStart = nullptr;
-                            continue;
-                        }
-                        while ((cp < endp) && (*cp != '\n') && isspace(*cp))
-                            ++cp;
-                        const char* format = cp;
-                        uid_t uid = AID_ROOT;
-                        while ((cp < endp) && (*cp != '\n')) {
-                            if (*cp == '#') {
-                                uid = sniffUid(cp, endp);
-                                lineStart = nullptr;
-                                break;
-                            }
-                            ++cp;
-                        }
-                        while ((cp > format) && isspace(cp[-1])) {
-                            --cp;
-                            lineStart = nullptr;
-                        }
-                        std::string Format(format, cp - format);
-
-                        AddEventLogTags((uint32_t)Tag, uid, Name, Format,
-                                        filename, warn);
-                    } else {
-                        if (warn) {
-                            LOG(ERROR) << android::base::StringPrintf("tag name invalid %.*s",
-                                                                      (int)(cp - name + 1), name);
-                        }
-                        lineStart = nullptr;
-                    }
-                } else if (!isspace(*cp)) {
-                    break;
-                }
-            }
-            cp++;
-        }
-    } else if (warn) {
-#ifdef __ANDROID__
-        LOG(ERROR) << "Cannot read " << filename;
-#endif
-    }
-}
-
-// Extract a 4-byte value from a byte stream.
-static inline uint32_t get4LE(const char* msg) {
-    const uint8_t* src = reinterpret_cast<const uint8_t*>(msg);
-    return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
-}
-
-// Additional persistent sources for invented log tags.  Read the
-// special pmsg event for log tags, and build up our internal
-// database with any found.
-void LogTags::ReadPersistEventLogTags() {
-    struct logger_list* logger_list =
-            android_logger_list_alloc(ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK, 0, (pid_t)0);
-    if (!logger_list) return;
-
-    struct logger* e = android_logger_open(logger_list, LOG_ID_EVENTS);
-    struct logger* s = android_logger_open(logger_list, LOG_ID_SECURITY);
-    if (!e && !s) {
-        android_logger_list_free(logger_list);
-        return;
-    }
-
-    for (;;) {
-        struct log_msg log_msg;
-        int ret = android_logger_list_read(logger_list, &log_msg);
-        if (ret <= 0) break;
-
-        const char* msg = log_msg.msg();
-        if (!msg) continue;
-        if (log_msg.entry.len <= sizeof(uint32_t)) continue;
-        uint32_t Tag = get4LE(msg);
-        if (Tag != TAG_DEF_LOG_TAG) continue;
-        uid_t uid = log_msg.entry.uid;
-
-        std::string Name;
-        std::string Format;
-        android_log_list_element elem;
-        {
-            auto ctx = create_android_log_parser(log_msg.msg() + sizeof(uint32_t),
-                                                 log_msg.entry.len - sizeof(uint32_t));
-            auto guard = make_scope_guard([&ctx]() { android_log_destroy(&ctx); });
-            elem = android_log_read_next(ctx);
-            if (elem.type != EVENT_TYPE_LIST) {
-                continue;
-            }
-            elem = android_log_read_next(ctx);
-            if (elem.type != EVENT_TYPE_INT) {
-                continue;
-            }
-            Tag = elem.data.int32;
-            elem = android_log_read_next(ctx);
-            if (elem.type != EVENT_TYPE_STRING) {
-                continue;
-            }
-            Name = std::string(elem.data.string, elem.len);
-            elem = android_log_read_next(ctx);
-            if (elem.type != EVENT_TYPE_STRING) {
-                continue;
-            }
-            Format = std::string(elem.data.string, elem.len);
-            elem = android_log_read_next(ctx);
-        }
-        if ((elem.type != EVENT_TYPE_LIST_STOP) || !elem.complete) continue;
-
-        AddEventLogTags(Tag, uid, Name, Format);
-    }
-    android_logger_list_free(logger_list);
-}
-
-LogTags::LogTags() {
-    ReadFileEventLogTags(system_event_log_tags);
-    // Following will likely fail on boot, but is required if logd restarts
-    ReadFileEventLogTags(dynamic_event_log_tags, false);
-    if (__android_log_is_debuggable()) {
-        ReadFileEventLogTags(debug_event_log_tags, false);
-    }
-    ReadPersistEventLogTags();
-
-    logtags = this;
-}
-
-// Converts an event tag into a name
-const char* LogTags::tagToName(uint32_t tag) const {
-    tag2name_const_iterator it;
-
-    android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-
-    it = tag2name.find(tag);
-    if ((it == tag2name.end()) || (it->second.length() == 0)) return nullptr;
-
-    return it->second.c_str();
-}
-
-// Prototype in LogUtils.h allowing external access to our database.
-//
-// This must be a pure reader to our database, as everything else is
-// guaranteed single-threaded except this access point which is
-// asynchonous and can be multithreaded and thus rentrant.  The
-// object's rwlock is only used to guarantee atomic access to the
-// unordered_map to prevent corruption, with a requirement to be a
-// low chance of contention for this call.  If we end up changing
-// this algorithm resulting in write, then we should use a different
-// lock than the object's rwlock to protect groups of associated
-// actions.
-const char* android::tagToName(uint32_t tag) {
-    LogTags* me = logtags;
-
-    if (!me) return nullptr;
-    me->WritePmsgEventLogTags(tag);
-    return me->tagToName(tag);
-}
-
-// converts an event tag into a format
-const char* LogTags::tagToFormat(uint32_t tag) const {
-    tag2format_const_iterator iform;
-
-    android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-
-    iform = tag2format.find(tag);
-    if (iform == tag2format.end()) return nullptr;
-
-    return iform->second.c_str();
-}
-
-// converts a name into an event tag
-uint32_t LogTags::nameToTag(const char* name) const {
-    uint32_t ret = emptyTag;
-
-    // Bug: Only works for a single entry, we can have multiple entries,
-    // one for each format, so we find first entry recorded, or entry with
-    // no format associated with it.
-
-    android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-
-    key2tag_const_iterator ik = key2tag.find(std::string(name));
-    if (ik != key2tag.end()) ret = ik->second;
-
-    return ret;
-}
-
-// Caller must perform locks, can be under reader (for pre-check) or
-// writer lock.  We use this call to invent a new deterministically
-// random tag, unique is cleared if no conflicts.  If format is NULL,
-// we are in readonly mode.
-uint32_t LogTags::nameToTag_locked(const std::string& name, const char* format,
-                                   bool& unique) {
-    key2tag_const_iterator ik;
-
-    bool write = format != nullptr;
-    unique = write;
-
-    if (!write) {
-        // Bug: Only works for a single entry, we can have multiple entries,
-        // one for each format, so we find first entry recorded, or entry with
-        // no format associated with it.
-        ik = key2tag.find(name);
-        if (ik == key2tag.end()) return emptyTag;
-        return ik->second;
-    }
-
-    std::string Key(name);
-    if (*format) Key += std::string("+") + format;
-
-    ik = key2tag.find(Key);
-    if (ik != key2tag.end()) {
-        unique = false;
-        return ik->second;
-    }
-
-    size_t Hash = key2tag.hash_function()(Key);
-    uint32_t Tag = Hash;
-    // This sets an upper limit on the conflics we are allowed to deal with.
-    for (unsigned i = 0; i < 256;) {
-        tag2name_const_iterator it = tag2name.find(Tag);
-        if (it == tag2name.end()) return Tag;
-        std::string localKey(it->second);
-        tag2format_const_iterator iform = tag2format.find(Tag);
-        if ((iform == tag2format.end()) && iform->second.length()) {
-            localKey += "+" + iform->second;
-        }
-        unique = !!it->second.compare(localKey);
-        if (!unique) return Tag;  // unlikely except in a race
-
-        ++i;
-        // Algorithm to convert hash to next tag
-        if (i < 32) {
-            Tag = (Hash >> i);
-            // size_t is 32 bits, or upper word zero, rotate
-            if ((sizeof(Hash) <= 4) || ((Hash & (uint64_t(-1LL) << 32)) == 0)) {
-                Tag |= Hash << (32 - i);
-            }
-        } else {
-            Tag = Hash + i - 31;
-        }
-    }
-    return emptyTag;
-}
-
-static int openFile(const char* name, int mode, bool warning) {
-    int fd = TEMP_FAILURE_RETRY(open(name, mode));
-    if (fd < 0 && warning) {
-        PLOG(ERROR) << "Failed to open " << name;
-    }
-    return fd;
-}
-
-void LogTags::WritePmsgEventLogTags(uint32_t tag, uid_t uid) {
-    android::RWLock::AutoRLock readLock(rwlock);
-
-    tag2total_const_iterator itot = tag2total.find(tag);
-    if (itot == tag2total.end()) return;  // source is a static entry
-
-    size_t lastTotal = itot->second;
-
-    // Every 16K (half the smallest configurable pmsg buffer size) record
-    static const size_t rate_to_pmsg = 16 * 1024;
-    if (lastTotal && (LogStatistics::sizesTotal() - lastTotal) < rate_to_pmsg) {
-        return;
-    }
-
-    static int pmsg_fd = -1;
-    if (pmsg_fd < 0) {
-        pmsg_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-        // unlikely, but deal with partners with borken pmsg
-        if (pmsg_fd < 0) return;
-    }
-
-    std::string Name = tag2name[tag];
-    tag2format_const_iterator iform = tag2format.find(tag);
-    std::string Format = (iform != tag2format.end()) ? iform->second : "";
-
-    auto ctx = create_android_logger(TAG_DEF_LOG_TAG);
-    auto guard = make_scope_guard([&ctx]() { android_log_destroy(&ctx); });
-    if (android_log_write_int32(ctx, static_cast<int32_t>(tag) < 0) ||
-        android_log_write_string8_len(ctx, Name.c_str(), Name.size()) < 0 ||
-        android_log_write_string8_len(ctx, Format.c_str(), Format.size()) < 0) {
-        return;
-    }
-
-    const char* cp = nullptr;
-    ssize_t len = android_log_write_list_buffer(ctx, &cp);
-
-    if (len <= 0 || cp == nullptr) {
-        return;
-    }
-
-    std::string buffer(cp, len);
-
-    /*
-     *  struct {
-     *      // what we provide to pstore
-     *      android_pmsg_log_header_t pmsgHeader;
-     *      // what we provide to file
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
-
-    struct timespec ts;
-    clock_gettime(CLOCK_REALTIME, &ts);
-
-    android_log_header_t header = {
-            .id = LOG_ID_EVENTS,
-            .tid = static_cast<uint16_t>(android::base::GetThreadId()),
-            .realtime.tv_sec = static_cast<uint32_t>(ts.tv_sec),
-            .realtime.tv_nsec = static_cast<uint32_t>(ts.tv_nsec),
-    };
-
-    uint32_t outTag = TAG_DEF_LOG_TAG;
-    outTag = get4LE((const char*)&outTag);
-
-    android_pmsg_log_header_t pmsgHeader = {
-        .magic = LOGGER_MAGIC,
-        .len = (uint16_t)(sizeof(pmsgHeader) + sizeof(header) + sizeof(outTag) +
-                          buffer.length()),
-        .uid = (uint16_t)AID_ROOT,
-        .pid = (uint16_t)getpid(),
-    };
-
-    struct iovec Vec[] = { { (unsigned char*)&pmsgHeader, sizeof(pmsgHeader) },
-                           { (unsigned char*)&header, sizeof(header) },
-                           { (unsigned char*)&outTag, sizeof(outTag) },
-                           { (unsigned char*)const_cast<char*>(buffer.data()),
-                             buffer.length() } };
-
-    tag2uid_const_iterator ut = tag2uid.find(tag);
-    if (ut == tag2uid.end()) {
-        TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec)));
-    } else if (uid != AID_ROOT) {
-        pmsgHeader.uid = (uint16_t)uid;
-        TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec)));
-    } else {
-        for (auto& it : ut->second) {
-            pmsgHeader.uid = (uint16_t)it;
-            TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec)));
-        }
-    }
-}
-
-void LogTags::WriteDynamicEventLogTags(uint32_t tag, uid_t uid) {
-    static const int mode =
-        O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
-
-    int fd = openFile(dynamic_event_log_tags, mode, true);
-    if (fd < 0) return;
-
-    android::RWLock::AutoWLock writeLock(rwlock);
-
-    std::string ret = formatEntry_locked(tag, uid, false);
-    android::base::WriteStringToFd(ret, fd);
-    close(fd);
-
-    size_t size = 0;
-    file2watermark_const_iterator iwater;
-
-    iwater = file2watermark.find(dynamic_event_log_tags);
-    if (iwater != file2watermark.end()) size = iwater->second;
-
-    file2watermark[dynamic_event_log_tags] = size + ret.length();
-}
-
-void LogTags::WriteDebugEventLogTags(uint32_t tag, uid_t uid) {
-    static const int mode =
-        O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
-
-    static bool one = true;
-    int fd = openFile(debug_event_log_tags, mode, one);
-    one = fd >= 0;
-    if (!one) return;
-
-    android::RWLock::AutoWLock writeLock(rwlock);
-
-    std::string ret = formatEntry_locked(tag, uid, false);
-    android::base::WriteStringToFd(ret, fd);
-    close(fd);
-
-    size_t size = 0;
-    file2watermark_const_iterator iwater;
-
-    iwater = file2watermark.find(debug_event_log_tags);
-    if (iwater != file2watermark.end()) size = iwater->second;
-
-    file2watermark[debug_event_log_tags] = size + ret.length();
-}
-
-// How we maintain some runtime or reboot stickiness
-void LogTags::WritePersistEventLogTags(uint32_t tag, uid_t uid,
-                                       const char* source) {
-    // very unlikely
-    bool etc = source && !strcmp(source, system_event_log_tags);
-    if (etc) return;
-
-    bool dynamic = source && !strcmp(source, dynamic_event_log_tags);
-    bool debug = (!dynamic && source && !strcmp(source, debug_event_log_tags)) ||
-                 !__android_log_is_debuggable();
-
-    WritePmsgEventLogTags(tag, uid);
-
-    size_t lastTotal = 0;
-    {
-        android::RWLock::AutoRLock readLock(rwlock);
-
-        tag2total_const_iterator itot = tag2total.find(tag);
-        if (itot != tag2total.end()) lastTotal = itot->second;
-    }
-
-    if (lastTotal == 0) {  // denotes first time for this one
-        if (!dynamic || !RebuildFileEventLogTags(dynamic_event_log_tags)) {
-            WriteDynamicEventLogTags(tag, uid);
-        }
-
-        if (!debug && !RebuildFileEventLogTags(debug_event_log_tags)) {
-            WriteDebugEventLogTags(tag, uid);
-        }
-    }
-
-    lastTotal = LogStatistics::sizesTotal();
-    if (!lastTotal) ++lastTotal;
-
-    // record totals for next watermark.
-    android::RWLock::AutoWLock writeLock(rwlock);
-    tag2total[tag] = lastTotal;
-}
-
-// nameToTag converts a name into an event tag. If format is NULL, then we
-// are in readonly mode.
-uint32_t LogTags::nameToTag(uid_t uid, const char* name, const char* format) {
-    std::string Name = std::string(name);
-    bool write = format != nullptr;
-    bool updateUid = uid != AID_ROOT;
-    bool updateFormat = format && *format;
-    bool unique;
-    uint32_t Tag;
-
-    {
-        android::RWLock::AutoRLock readLock(rwlock);
-
-        Tag = nameToTag_locked(Name, format, unique);
-        if (updateUid && (Tag != emptyTag) && !unique) {
-            tag2uid_const_iterator ut = tag2uid.find(Tag);
-            if (updateUid) {
-                if ((ut != tag2uid.end()) &&
-                    (ut->second.find(uid) == ut->second.end())) {
-                    unique = write;  // write passthrough to update uid counts
-                    if (!write) Tag = emptyTag;  // deny read access
-                }
-            } else {
-                unique = write && (ut != tag2uid.end());
-            }
-        }
-    }
-
-    if (Tag == emptyTag) return Tag;
-    WritePmsgEventLogTags(Tag, uid);  // record references periodically
-    if (!unique) return Tag;
-
-    bool updateWrite = false;
-    bool updateTag;
-
-    // Special case of AddEventLogTags, checks per-uid counter which makes
-    // no sense there, and is also optimized somewhat to reduce write times.
-    {
-        android::RWLock::AutoWLock writeLock(rwlock);
-
-        // double check after switch from read lock to write lock for Tag
-        updateTag = tag2name.find(Tag) == tag2name.end();
-        // unlikely, either update, race inviting conflict or multiple uids
-        if (!updateTag) {
-            Tag = nameToTag_locked(Name, format, unique);
-            if (Tag == emptyTag) return Tag;
-            // is it multiple uid's setting this value
-            if (!unique) {
-                tag2uid_const_iterator ut = tag2uid.find(Tag);
-                if (updateUid) {
-                    // Add it to the uid list
-                    if ((ut == tag2uid.end()) ||
-                        (ut->second.find(uid) != ut->second.end())) {
-                        return Tag;
-                    }
-                    const_cast<uid_list&>(ut->second).emplace(uid);
-                    updateWrite = true;
-                } else {
-                    if (ut == tag2uid.end()) return Tag;
-                    // (system) adding a global one, erase the uid list
-                    tag2uid.erase(ut);
-                    updateWrite = true;
-                }
-            }
-        }
-
-        // Update section
-        size_t count;
-        if (updateUid) {
-            count = 0;
-            uid2count_const_iterator ci = uid2count.find(uid);
-            if (ci != uid2count.end()) {
-                count = ci->second;
-                if (count >= max_per_uid) {
-                    if (!updateWrite) return emptyTag;
-                    // If we are added to the per-Uid perms, leak the Tag
-                    // if it already exists.
-                    updateUid = false;
-                    updateTag = false;
-                    updateFormat = false;
-                }
-            }
-        }
-
-        // updateWrite -> trigger output on modified content, reset tag2total
-        //    also sets static to dynamic entries if they are alterred,
-        //    only occurs if they have a uid, and runtime adds another uid.
-        if (updateWrite) tag2total[Tag] = 0;
-
-        if (updateTag) {
-            // mark as a dynamic entry, but do not upset current total counter
-            tag2total_const_iterator itot = tag2total.find(Tag);
-            if (itot == tag2total.end()) tag2total[Tag] = 0;
-
-            if (*format) {
-                key2tag[Name + "+" + format] = Tag;
-                if (key2tag.find(Name) == key2tag.end()) key2tag[Name] = Tag;
-            } else {
-                key2tag[Name] = Tag;
-            }
-            tag2name[Tag] = Name;
-        }
-        if (updateFormat) tag2format[Tag] = format;
-
-        if (updateUid) {
-            tag2uid[Tag].emplace(uid);
-            uid2count[uid] = count + 1;
-        }
-    }
-
-    if (updateTag || updateFormat || updateWrite) {
-        WritePersistEventLogTags(Tag, uid);
-    }
-
-    return Tag;
-}
-
-std::string LogTags::formatEntry(uint32_t tag, uid_t uid, const char* name,
-                                 const char* format) {
-    if (!format || !format[0]) {
-        return android::base::StringPrintf("%" PRIu32 "\t%s\n", tag, name);
-    }
-    size_t len = (strlen(name) + 7) / 8;
-    static const char tabs[] = "\t\t\t";
-    if (len > strlen(tabs)) len = strlen(tabs);
-    std::string Uid;
-    if (uid != AID_ROOT) Uid = android::base::StringPrintf(" # uid=%u", uid);
-    return android::base::StringPrintf("%" PRIu32 "\t%s%s\t%s%s\n", tag, name,
-                                       &tabs[len], format, Uid.c_str());
-}
-
-std::string LogTags::formatEntry_locked(uint32_t tag, uid_t uid,
-                                        bool authenticate) {
-    const char* name = tag2name[tag].c_str();
-
-    const char* format = "";
-    tag2format_const_iterator iform = tag2format.find(tag);
-    if (iform != tag2format.end()) format = iform->second.c_str();
-
-    // Access permission test, do not report dynamic entries
-    // that do not belong to us.
-    tag2uid_const_iterator ut = tag2uid.find(tag);
-    if (ut == tag2uid.end()) {
-        return formatEntry(tag, AID_ROOT, name, format);
-    }
-    if (uid != AID_ROOT) {
-        if (authenticate && (ut->second.find(uid) == ut->second.end())) {
-            return std::string("");
-        }
-        return formatEntry(tag, uid, name, format);
-    }
-
-    // Show all, one for each registered uid (we are group root)
-    std::string ret;
-    for (auto& it : ut->second) {
-        ret += formatEntry(tag, it, name, format);
-    }
-    return ret;
-}
-
-std::string LogTags::formatEntry(uint32_t tag, uid_t uid) {
-    android::RWLock::AutoRLock readLock(rwlock);
-    return formatEntry_locked(tag, uid);
-}
-
-std::string LogTags::formatGetEventTag(uid_t uid, const char* name,
-                                       const char* format) {
-    bool all = name && (name[0] == '*') && !name[1];
-    bool list = !name || all;
-    std::string ret;
-
-    if (!list) {
-        // switch to read entry only if format == "*"
-        if (format && (format[0] == '*') && !format[1]) format = nullptr;
-
-        // WAI: for null format, only works for a single entry, we can have
-        // multiple entries, one for each format, so we find first entry
-        // recorded, or entry with no format associated with it.
-        // We may desire to print all that match the name, but we did not
-        // add a mapping table for that and the cost is too high.
-        uint32_t tag = nameToTag(uid, name, format);
-        if (tag == emptyTag) return std::string("-1 ESRCH");
-        if (uid == AID_ROOT) {
-            android::RWLock::AutoRLock readLock(rwlock);
-
-            // first uid in list so as to manufacture an accurate reference
-            tag2uid_const_iterator ut = tag2uid.find(tag);
-            if ((ut != tag2uid.end()) &&
-                (ut->second.begin() != ut->second.end())) {
-                uid = *(ut->second.begin());
-            }
-        }
-        ret = formatEntry(tag, uid, name, format ?: tagToFormat(tag));
-        if (!ret.length()) return std::string("-1 ESRCH");
-        return ret;
-    }
-
-    android::RWLock::AutoRLock readLock(rwlock);
-    if (all) {
-        // everything under the sun
-        for (const auto& it : tag2name) {
-            ret += formatEntry_locked(it.first, uid);
-        }
-    } else {
-        // set entries are dynamic
-        for (const auto& it : tag2total) {
-            ret += formatEntry_locked(it.first, uid);
-        }
-    }
-    return ret;
-}
diff --git a/logd/LogTags.h b/logd/LogTags.h
deleted file mode 100644
index cce700c..0000000
--- a/logd/LogTags.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2017 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 <unordered_map>
-#include <unordered_set>
-
-#include <private/android_filesystem_config.h>
-#include <utils/RWLock.h>
-
-class LogTags {
-    // This lock protects all the unordered_map accesses below.  It
-    // is a reader/writer lock so that contentions are kept to a
-    // minimum since writes are rare, even administratably when
-    // reads are extended.  Resist the temptation to use the writer
-    // lock to protect anything outside the following unordered_maps
-    // as that would increase the reader contentions.  Use a separate
-    // mutex to protect the other entities.
-    android::RWLock rwlock;
-
-    // key is Name + "+" + Format
-    std::unordered_map<std::string, uint32_t> key2tag;
-    typedef std::unordered_map<std::string, uint32_t>::const_iterator
-        key2tag_const_iterator;
-
-    // Allows us to manage access permissions based on uid registrants
-    // Global entries are specifically erased.
-    typedef std::unordered_set<uid_t> uid_list;
-    std::unordered_map<uint32_t, uid_list> tag2uid;
-    typedef std::unordered_map<uint32_t, uid_list>::const_iterator
-        tag2uid_const_iterator;
-
-    std::unordered_map<uint32_t, std::string> tag2name;
-    typedef std::unordered_map<uint32_t, std::string>::const_iterator
-        tag2name_const_iterator;
-
-    std::unordered_map<uint32_t, std::string> tag2format;
-    typedef std::unordered_map<uint32_t, std::string>::const_iterator
-        tag2format_const_iterator;
-
-    static const size_t max_per_uid = 256;  // Put a cap on the tags per uid
-    std::unordered_map<uid_t, size_t> uid2count;
-    typedef std::unordered_map<uid_t, size_t>::const_iterator
-        uid2count_const_iterator;
-
-    // Dynamic entries are assigned
-    std::unordered_map<uint32_t, size_t> tag2total;
-    typedef std::unordered_map<uint32_t, size_t>::const_iterator
-        tag2total_const_iterator;
-
-    // emplace unique tag
-    uint32_t nameToTag(uid_t uid, const char* name, const char* format);
-    // find unique or associated tag
-    uint32_t nameToTag_locked(const std::string& name, const char* format,
-                              bool& unique);
-
-    // Record expected file watermarks to detect corruption.
-    std::unordered_map<std::string, size_t> file2watermark;
-    typedef std::unordered_map<std::string, size_t>::const_iterator
-        file2watermark_const_iterator;
-
-    void ReadPersistEventLogTags();
-
-    // format helpers
-    // format a single entry, does not need object data
-    static std::string formatEntry(uint32_t tag, uid_t uid, const char* name,
-                                   const char* format);
-    // caller locks, database lookup, authenticate against uid
-    std::string formatEntry_locked(uint32_t tag, uid_t uid,
-                                   bool authenticate = true);
-
-    bool RebuildFileEventLogTags(const char* filename, bool warn = true);
-
-    void AddEventLogTags(uint32_t tag, uid_t uid, const std::string& Name,
-                         const std::string& Format, const char* source = nullptr,
-                         bool warn = false);
-
-    void WriteDynamicEventLogTags(uint32_t tag, uid_t uid);
-    void WriteDebugEventLogTags(uint32_t tag, uid_t uid);
-    // push tag details to persistent storage
-    void WritePersistEventLogTags(uint32_t tag, uid_t uid = AID_ROOT,
-                                  const char* source = nullptr);
-
-    static const uint32_t emptyTag = uint32_t(-1);
-
-   public:
-    static const char system_event_log_tags[];
-    static const char dynamic_event_log_tags[];
-    // Only for userdebug and eng
-    static const char debug_event_log_tags[];
-
-    LogTags();
-
-    void WritePmsgEventLogTags(uint32_t tag, uid_t uid = AID_ROOT);
-    void ReadFileEventLogTags(const char* filename, bool warn = true);
-
-    // reverse lookup from tag
-    const char* tagToName(uint32_t tag) const;
-    const char* tagToFormat(uint32_t tag) const;
-    std::string formatEntry(uint32_t tag, uid_t uid);
-    // find associated tag
-    uint32_t nameToTag(const char* name) const;
-
-    // emplace tag if necessary, provide event-log-tag formated output in string
-    std::string formatGetEventTag(uid_t uid, const char* name,
-                                  const char* format);
-};
diff --git a/logd/LogUtils.h b/logd/LogUtils.h
deleted file mode 100644
index df78a50..0000000
--- a/logd/LogUtils.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#pragma once
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <private/android_logger.h>
-#include <sysutils/SocketClient.h>
-#include <utils/FastStrcmp.h>
-
-// Hijack this header as a common include file used by most all sources
-// to report some utilities defined here and there.
-
-namespace android {
-
-// Furnished in main.cpp. Caller must own and free returned value
-char* uidToName(uid_t uid);
-
-// Caller must own and free returned value
-char* pidToName(pid_t pid);
-char* tidToName(pid_t tid);
-
-// Furnished in LogTags.cpp. Thread safe.
-const char* tagToName(uint32_t tag);
-
-// Furnished by LogKlog.cpp
-char* log_strntok_r(char* s, ssize_t& len, char*& saveptr, ssize_t& sublen);
-
-// needle should reference a string longer than 1 character
-static inline const char* strnstr(const char* s, ssize_t len,
-                                  const char* needle) {
-    if (len <= 0) return nullptr;
-
-    const char c = *needle++;
-    const size_t needleLen = strlen(needle);
-    do {
-        do {
-            if (len <= (ssize_t)needleLen) return nullptr;
-            --len;
-        } while (*s++ != c);
-    } while (fastcmp<memcmp>(s, needle, needleLen));
-    s--;
-    return s;
-}
-}
-
-// Returns true if the log buffer is meant for binary logs.
-static inline bool IsBinary(log_id_t log_id) {
-    return log_id == LOG_ID_EVENTS || log_id == LOG_ID_STATS || log_id == LOG_ID_SECURITY;
-}
-
-// Returns the numeric log tag for binary log messages.
-static inline uint32_t MsgToTag(const char* msg, uint16_t msg_len) {
-    if (msg_len < sizeof(android_event_header_t)) {
-        return 0;
-    }
-
-    return reinterpret_cast<const android_event_header_t*>(msg)->tag;
-}
-
-static inline bool worstUidEnabledForLogid(log_id_t id) {
-    return (id == LOG_ID_MAIN) || (id == LOG_ID_SYSTEM) ||
-           (id == LOG_ID_RADIO) || (id == LOG_ID_EVENTS);
-}
diff --git a/logd/LogWriter.h b/logd/LogWriter.h
deleted file mode 100644
index d43c604..0000000
--- a/logd/LogWriter.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2020 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 <log/log_read.h>
-
-// An interface for writing logs to a reader.
-class LogWriter {
-  public:
-    LogWriter(uid_t uid, bool privileged) : uid_(uid), privileged_(privileged) {}
-    virtual ~LogWriter() {}
-
-    virtual bool Write(const logger_entry& entry, const char* msg) = 0;
-    virtual void Shutdown() {}
-    virtual void Release() {}
-
-    virtual std::string name() const = 0;
-    uid_t uid() const { return uid_; }
-
-    bool privileged() const { return privileged_; }
-
-  private:
-    uid_t uid_;
-
-    // If this writer sees logs from all UIDs or only its own UID.  See clientHasLogCredentials().
-    bool privileged_;
-};
\ No newline at end of file
diff --git a/logd/OWNERS b/logd/OWNERS
deleted file mode 100644
index 2394e32..0000000
--- a/logd/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-cferris@google.com
-tomcherry@google.com
diff --git a/logd/PruneList.cpp b/logd/PruneList.cpp
deleted file mode 100644
index c3859f3..0000000
--- a/logd/PruneList.cpp
+++ /dev/null
@@ -1,201 +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 "PruneList.h"
-
-#include <ctype.h>
-
-#include <android-base/logging.h>
-#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
-#include <android-base/strings.h>
-
-bool Prune::Matches(LogBufferElement* element) const {
-    return (uid_ == UID_ALL || uid_ == element->uid()) &&
-           (pid_ == PID_ALL || pid_ == element->pid());
-}
-
-std::string Prune::Format() const {
-    if (uid_ != UID_ALL) {
-        if (pid_ != PID_ALL) {
-            return android::base::StringPrintf("%u/%u", uid_, pid_);
-        }
-        return android::base::StringPrintf("%u", uid_);
-    }
-    if (pid_ != PID_ALL) {
-        return android::base::StringPrintf("/%u", pid_);
-    }
-    // NB: pid_ == PID_ALL can not happen if uid_ == UID_ALL
-    return std::string("/");
-}
-
-PruneList::PruneList() {
-    Init(nullptr);
-}
-
-bool PruneList::Init(const char* str) {
-    high_priority_prune_.clear();
-    low_priority_prune_.clear();
-
-    // default here means take ro.logd.filter, persist.logd.filter then internal default in order.
-    if (str && !strcmp(str, "default")) {
-        str = nullptr;
-    }
-    if (str && !strcmp(str, "disable")) {
-        str = "";
-    }
-
-    std::string filter;
-
-    if (str) {
-        filter = str;
-    } else {
-        filter = android::base::GetProperty("ro.logd.filter", "default");
-        auto persist_filter = android::base::GetProperty("persist.logd.filter", "default");
-        // default here means take ro.logd.filter
-        if (persist_filter != "default") {
-            filter = persist_filter;
-        }
-    }
-
-    // default here means take internal default.
-    if (filter == "default") {
-        filter = "~! ~1000/!";
-    }
-    if (filter == "disable") {
-        filter = "";
-    }
-
-    worst_uid_enabled_ = false;
-    worst_pid_of_system_enabled_ = false;
-
-    for (str = filter.c_str(); *str; ++str) {
-        if (isspace(*str)) {
-            continue;
-        }
-
-        std::list<Prune>* list;
-        if (*str == '~' || *str == '!') {  // ~ supported, ! undocumented
-            ++str;
-            // special case, prune the worst UID of those using at least 1/8th of the buffer.
-            if (*str == '!') {
-                worst_uid_enabled_ = true;
-                ++str;
-                if (!*str) {
-                    break;
-                }
-                if (!isspace(*str)) {
-                    LOG(ERROR) << "Nothing expected after '~!', but found '" << str << "'";
-                    return false;
-                }
-                continue;
-            }
-            // special case, translated to worst PID of System at priority
-            static const char WORST_SYSTEM_PID[] = "1000/!";
-            if (!strncmp(str, WORST_SYSTEM_PID, sizeof(WORST_SYSTEM_PID) - 1)) {
-                worst_pid_of_system_enabled_ = true;
-                str += sizeof(WORST_SYSTEM_PID) - 1;
-                if (!*str) {
-                    break;
-                }
-                if (!isspace(*str)) {
-                    LOG(ERROR) << "Nothing expected after '~1000/!', but found '" << str << "'";
-                    return false;
-                }
-                continue;
-            }
-            if (!*str) {
-                LOG(ERROR) << "Expected UID or PID after '~', but found nothing";
-                return false;
-            }
-            list = &high_priority_prune_;
-        } else {
-            list = &low_priority_prune_;
-        }
-
-        uid_t uid = Prune::UID_ALL;
-        if (isdigit(*str)) {
-            uid = 0;
-            do {
-                uid = uid * 10 + *str++ - '0';
-            } while (isdigit(*str));
-        }
-
-        pid_t pid = Prune::PID_ALL;
-        if (*str == '/') {
-            ++str;
-            if (isdigit(*str)) {
-                pid = 0;
-                do {
-                    pid = pid * 10 + *str++ - '0';
-                } while (isdigit(*str));
-            }
-        }
-
-        if (uid == Prune::UID_ALL && pid == Prune::PID_ALL) {
-            LOG(ERROR) << "Expected UID/PID combination, but found none";
-            return false;
-        }
-
-        if (*str && !isspace(*str)) {
-            LOG(ERROR) << "Nothing expected after UID/PID combination, but found '" << str << "'";
-            return false;
-        }
-
-        list->emplace_back(uid, pid);
-        if (!*str) {
-            break;
-        }
-    }
-
-    return true;
-}
-
-std::string PruneList::Format() const {
-    std::vector<std::string> prune_rules;
-
-    if (worst_uid_enabled_) {
-        prune_rules.emplace_back("~!");
-    }
-    if (worst_pid_of_system_enabled_) {
-        prune_rules.emplace_back("~1000/!");
-    }
-    for (const auto& rule : low_priority_prune_) {
-        prune_rules.emplace_back(rule.Format());
-    }
-    for (const auto& rule : high_priority_prune_) {
-        prune_rules.emplace_back("~" + rule.Format());
-    }
-    return android::base::Join(prune_rules, " ");
-}
-
-bool PruneList::IsHighPriority(LogBufferElement* element) const {
-    for (const auto& rule : high_priority_prune_) {
-        if (rule.Matches(element)) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool PruneList::IsLowPriority(LogBufferElement* element) const {
-    for (const auto& rule : low_priority_prune_) {
-        if (rule.Matches(element)) {
-            return true;
-        }
-    }
-    return false;
-}
diff --git a/logd/PruneList.h b/logd/PruneList.h
deleted file mode 100644
index 94de5c5..0000000
--- a/logd/PruneList.h
+++ /dev/null
@@ -1,66 +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.
- */
-
-#pragma once
-
-#include <sys/types.h>
-
-#include <string.h>
-#include <list>
-
-#include "LogBufferElement.h"
-
-class Prune {
-  public:
-    static const uid_t UID_ALL = (uid_t)-1;
-    static const pid_t PID_ALL = (pid_t)-1;
-
-    Prune(uid_t uid, pid_t pid) : uid_(uid), pid_(pid) {}
-
-    bool Matches(LogBufferElement* element) const;
-    std::string Format() const;
-
-    uid_t uid() const { return uid_; }
-    pid_t pid() const { return pid_; }
-
-  private:
-    const uid_t uid_;
-    const pid_t pid_;
-};
-
-class PruneList {
-  public:
-    PruneList();
-
-    bool Init(const char* str);
-    std::string Format() const;
-
-    bool IsHighPriority(LogBufferElement* element) const;
-    bool IsLowPriority(LogBufferElement* element) const;
-
-    bool HasHighPriorityPruneRules() const { return !high_priority_prune_.empty(); }
-    bool HasLowPriorityPruneRules() const { return !low_priority_prune_.empty(); }
-
-    bool worst_uid_enabled() const { return worst_uid_enabled_; }
-    bool worst_pid_of_system_enabled() const { return worst_pid_of_system_enabled_; }
-
-  private:
-    std::list<Prune> high_priority_prune_;
-    std::list<Prune> low_priority_prune_;
-
-    bool worst_uid_enabled_;
-    bool worst_pid_of_system_enabled_;
-};
diff --git a/logd/README.auditd b/logd/README.auditd
deleted file mode 100644
index 3f614a3..0000000
--- a/logd/README.auditd
+++ /dev/null
@@ -1,17 +0,0 @@
-Auditd Daemon
-
-The audit daemon is a simplified version of its desktop
-counterpart designed to gather the audit logs from the
-audit kernel subsystem. The audit subsystem of the kernel
-includes Linux Security Modules (LSM) messages as well.
-
-To enable the audit subsystem, you must add this to your
-kernel config:
-CONFIG_AUDIT=y
-
-To enable a LSM, you must consult that LSM's documentation, the
-example below is for SELinux:
-CONFIG_SECURITY_SELINUX=y
-
-This does not include possible dependencies that may need to be
-satisfied for that particular LSM.
diff --git a/logd/README.compression.md b/logd/README.compression.md
deleted file mode 100644
index 4ba634a..0000000
--- a/logd/README.compression.md
+++ /dev/null
@@ -1,81 +0,0 @@
-# Log Compression instead of Chatty in Android S
-
-## The problem
-
-* Log buffer space is precious, but suffers from the tragedy of the commons
-* Log spam fills the buffers making them less useful in logcat/bugreports
-* “Spam” is often in the eye of the beholder: which messages are important depends on what you’re trying to debug
-
-## The idea
-
-* Chatty isn’t helping as much as we’d hoped, and is surprisingly expensive
-* Compress logs to make more efficient use of the buffer
-* Address the root cause of log spam at its source:
-    * Do not hide log spam at runtime, which de-incentivize fixes
-    * Add presubmit coverage similar to SELinux violations to keep log spam down
-
----
-
-## Chatty in Theory
-
-* Delete messages classified as spam to extend the range of logs from other sources
-* “Spam” defined as:
-    * Logs from UIDs whose logs consume over 12.5% of a log buffer
-    * Back-to-back exact duplicate messages
-
-## Chatty in Practice
-
-* Developer confusion about missing and de-duplicated logs
-* Lowered incentive to fix the root cause of bad logging behavior
-* High CPU overhead
-* Memory usage greatly exceeds configured buffer size
-* Only marginal increase in log range
-
----
-
-## Log Compression in Theory
-
-* Store many more logs in the same log buffer size => better for diagnosis
-* Memory usage stays below configured log size => better system health
-* No gaps in logs, no de-duplicated logs => no developer confusion
-* No hiding bad behavior => increased accountability/incentive to fix root causes
-
-## Log Compression Preliminary Results
-
-* Captured 2, 5 day periods of full time personal usage of Pixel 4 and replayed the logs offline
-* Compression vs Chatty:
-    * **3.5x more log messages on average**
-    * **50% less CPU usage**
-    * **50% less memory usage**
-
----
-
-## Log Messages in 1MB
-
-* The number of log messages still available in logcat after ‘Message Count’ messages have been logged to a 1MB log buffer
-* Note: ‘Simple’ is the Chatty code without log spam detection and without de-duplication.
-
-![Total Log Count](doc_images/total_log_count.png)
-
----
-
-## CPU Time
-
-* Total CPU time on ARM64 (Walleye) and 32bit x86 (Cuttlefish)
-* X axis represents different log buffer size configurations.
-    * Chatty uses significantly more CPU time at 1MB (the default Pixel configuration)
-    * Chatty scales poorly with increased log buffer sizes
-* Note: “simple” isn’t “compression without actually compressing”, it’s “chatty without doing the chatty elimination”, which is why “simple” is more expensive than “compression” on walleye.
-
-![CPU Time Walleye](doc_images/cpu_walleye.png)
-![CPU Time Cuttlefish](doc_images/cpu_cuttlefish.png)
-
----
-
-## Memory Usage
-
-* The memory used by ‘Message Count’ messages, on both Walleye and Cuttlefish
-* Note: Chatty does not consider the metadata (UID, PID, timestamp, etc) in its calculation of log buffer size, so a 1MB log buffer will consume more than 1MB.  Note that there are 8 log buffers, 5 of which are typically filled.
-
-![Memory Usage](doc_images/memory_usage.png)
-
diff --git a/logd/README.property b/logd/README.property
deleted file mode 100644
index 8fd7f48..0000000
--- a/logd/README.property
+++ /dev/null
@@ -1,72 +0,0 @@
-The properties that logd and friends react to are:
-
-name                       type default  description
-ro.logd.auditd             bool   true   Enable selinux audit daemon
-ro.logd.auditd.dmesg       bool   true   selinux audit messages sent to dmesg.
-ro.logd.auditd.main        bool   true   selinux audit messages sent to main.
-ro.logd.auditd.events      bool   true   selinux audit messages sent to events.
-persist.logd.security      bool   false  Enable security buffer.
-ro.organization_owned      bool   false  Override persist.logd.security to false
-ro.logd.kernel             bool  svelte+ Enable klogd daemon
-logd.statistics            bool  svelte+ Enable logcat -S statistics.
-ro.debuggable              number        if not "1", logd.statistics &
-                                         ro.logd.kernel default false.
-logd.logpersistd.enable    bool   auto   Safe to start logpersist daemon service
-logd.logpersistd          string persist Enable logpersist daemon, "logcatd"
-                                         turns on logcat -f in logd context.
-					 Responds to logcatd, clear and stop.
-logd.logpersistd.buffer          persist logpersistd buffers to collect
-logd.logpersistd.size            persist logpersistd size in MB
-logd.logpersistd.rotate_kbytes   	 persist logpersistd outout file size in KB.
-persist.logd.logpersistd   string        Enable logpersist daemon, "logcatd"
-                                         turns on logcat -f in logd context.
-persist.logd.logpersistd.buffer    all   logpersistd buffers to collect
-persist.logd.logpersistd.size      256   logpersistd size in MB
-persist.logd.logpersistd.count     256   sets max number of rotated logs to <count>.
-persist.logd.logpersistd.rotate_kbytes   1024  logpersistd output file size in KB
-persist.logd.size          number  ro    Global default size of the buffer for
-                                         all log ids at initial startup, at
-                                         runtime use: logcat -b all -G <value>
-ro.logd.size               number svelte default for persist.logd.size. Larger
-                                         platform default sizes than 256KB are
-                                         known to not scale well under log spam
-                                         pressure. Address the spam first,
-                                         resist increasing the log buffer.
-persist.logd.size.<buffer> number  ro    Size of the buffer for <buffer> log
-ro.logd.size.<buffer>      number svelte default for persist.logd.size.<buffer>
-ro.config.low_ram          bool   false  if true, logd.statistics,
-                                         ro.logd.kernel default false,
-                                         logd.size 64K instead of 256K.
-persist.logd.filter        string        Pruning filter to optimize content.
-                                         At runtime use: logcat -P "<string>"
-ro.logd.filter       string "~! ~1000/!" default for persist.logd.filter.
-                                         This default means to prune the
-                                         oldest entries of chattiest UID, and
-                                         the chattiest PID of system
-                                         (1000, or AID_SYSTEM).
-log.tag                   string persist The global logging level, VERBOSE,
-                                         DEBUG, INFO, WARN, ERROR, ASSERT or
-                                         SILENT. Only the first character is
-                                         the key character.
-persist.log.tag            string build  default for log.tag
-log.tag.<tag>             string persist The <tag> specific logging level.
-persist.log.tag.<tag>      string build  default for log.tag.<tag>
-
-logd.buffer_type           string (empty) Set the log buffer type.  Current choices are 'simple',
-                                          'chatty', or 'serialized'.  Defaults to 'chatty' if empty.
-
-NB:
-- auto - managed by /init
-- svelte - see ro.config.low_ram for details.
-- svelte+ - If empty, default to true if `ro.config.low_ram == false && ro.debuggable == true`
-- ro - <base property> temporary override, ro.<base property> platform default.
-- persist - <base property> override, persist.<base property> platform default.
-- build - VERBOSE for native, DEBUG for jvm isLoggable, or developer option.
-- number - support multipliers (K or M) for convenience. Range is limited
-  to between 64K and 256M for log buffer sizes. Individual log buffer ids
-  such as main, system, ... override global default.
-- Pruning filter rules are specified as UID, UID/PID or /PID. A '~' prefix indicates that elements
-  matching the rule should be pruned with higher priority otherwise they're pruned with lower
-  priority. All other pruning activity is oldest first. Special case ~! represents an automatic
-  pruning for the noisiest UID as determined by the current statistics.  Special case ~1000/!
-  represents pruning of the worst PID within AID_SYSTEM when AID_SYSTEM is the noisiest UID.
diff --git a/logd/README.replay.md b/logd/README.replay.md
deleted file mode 100644
index 5f7ec9e..0000000
--- a/logd/README.replay.md
+++ /dev/null
@@ -1,46 +0,0 @@
-logd can record and replay log messages for offline analysis.
-
-Recording Messages
-------------------
-
-logd has a `RecordingLogBuffer` buffer that records messages to /data/misc/logd/recorded-messages.
-It stores messages in memory until that file is accessible, in order to capture all messages since
-the beginning of boot.  It is only meant for logging developers to use and must be manually enabled
-in by adding `RecordingLogBuffer.cpp` to `Android.bp` and setting
-`log_buffer = new SimpleLogBuffer(&reader_list, &log_tags, &log_statistics);` in `main.cpp`.
-
-Recording messages may delay the Log() function from completing and it is highly recommended to make
-the logd socket in `liblog` blocking, by removing `SOCK_NONBLOCK` from the `socket()` call in
-`liblog/logd_writer.cpp`.
-
-Replaying Messages
-------------------
-
-Recorded messages can be replayed offline with the `replay_messages` tool.  It runs on host and
-device and supports the following options:
-
-1. `interesting` - this prints 'interesting' statistics for each of the log buffer types (simple,
-   chatty, serialized).  The statistics are:
-    1. Log Entry Count
-    2. Size (the uncompressed size of the log messages in bytes)
-    3. Overhead (the total cost of the log messages in memory in bytes)
-    4. Range (the range of time that the logs cover in seconds)
-2. `memory_usage BUFFER_TYPE` - this prints the memory usage (sum of private dirty pages of the
-  `replay_messages` process).  Note that the input file is mmap()'ed as RO/Shared so it does not
-  appear in these dirty pages, and a baseline is taken before allocating the log buffers, so only
-  their contributions are measured.  The tool outputs the memory usage every 100,000 messages.
-3. `latency BUFFER_TYPE` - this prints statistics of the latency of the Log() function for the given
-  buffer type.  It specifically prints the 1st, 2nd, and 3rd quartiles; the 95th, 99th, and 99.99th
-  percentiles; and the maximum latency.
-4. `print_logs BUFFER_TYPE [buffers] [print_point]` - this prints the logs as processed by the given
-  buffer_type from the buffers specified by `buffers` starting after the number of logs specified by
-  `print_point` have been logged.  This acts as if a user called `logcat` immediately after the
-  specified logs have been logged, which is particularly useful since it will show the chatty
-  pruning messages at that point.  It additionally prints the statistics from `logcat -S` after the
-  logs.
-  `buffers` is a comma separated list of the numeric buffer id values from `<android/log.h>`.  For
-  example, `0,1,3` represents the main, radio, and system buffers.  It can can also be `all`.
-  `print_point` is an positive integer.  If it is unspecified, logs are printed after the entire
-  input file is consumed.
-5. `nothing BUFFER_TYPE` - this does nothing other than read the input file and call Log() for the
-  given buffer type.  This is used for profiling CPU usage of strictly the log buffer.
diff --git a/logd/RecordedLogMessage.h b/logd/RecordedLogMessage.h
deleted file mode 100644
index f18c422..0000000
--- a/logd/RecordedLogMessage.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2020 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 <inttypes.h>
-
-#include <log/log_time.h>
-
-struct __attribute__((packed)) RecordedLogMessage {
-    uint32_t uid;
-    uint32_t pid;
-    uint32_t tid;
-    log_time realtime;
-    uint16_t msg_len;
-    uint8_t log_id;
-};
diff --git a/logd/RecordingLogBuffer.cpp b/logd/RecordingLogBuffer.cpp
deleted file mode 100644
index f5991f3..0000000
--- a/logd/RecordingLogBuffer.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2020 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 "RecordingLogBuffer.h"
-
-#include <android-base/file.h>
-
-static void WriteLogMessage(int fd, const RecordedLogMessage& meta, const std::string& msg) {
-    android::base::WriteFully(fd, &meta, sizeof(meta));
-    android::base::WriteFully(fd, msg.c_str(), meta.msg_len);
-}
-
-void RecordingLogBuffer::RecordLogMessage(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
-                                          pid_t tid, const char* msg, uint16_t len) {
-    auto lock = std::lock_guard{lock_};
-    if (len > LOGGER_ENTRY_MAX_PAYLOAD) {
-        len = LOGGER_ENTRY_MAX_PAYLOAD;
-    }
-
-    RecordedLogMessage recorded_log_message = {
-            .uid = uid,
-            .pid = static_cast<uint32_t>(pid),
-            .tid = static_cast<uint32_t>(tid),
-            .realtime = realtime,
-            .msg_len = len,
-            .log_id = static_cast<uint8_t>(log_id),
-    };
-
-    if (!fd_.ok()) {
-        fd_.reset(open("/data/misc/logd/recorded-messages",
-                       O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0666));
-        if (!fd_.ok()) {
-            since_boot_messages_.emplace_back(recorded_log_message, std::string(msg, len));
-            return;
-        } else {
-            for (const auto& [meta, msg] : since_boot_messages_) {
-                WriteLogMessage(fd_.get(), meta, msg);
-            }
-        }
-    }
-
-    WriteLogMessage(fd_.get(), recorded_log_message, std::string(msg, len));
-}
-
-int RecordingLogBuffer::Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
-                            const char* msg, uint16_t len) {
-    RecordLogMessage(log_id, realtime, uid, pid, tid, msg, len);
-    return SimpleLogBuffer::Log(log_id, realtime, uid, pid, tid, msg, len);
-}
\ No newline at end of file
diff --git a/logd/RecordingLogBuffer.h b/logd/RecordingLogBuffer.h
deleted file mode 100644
index 49a0aba..0000000
--- a/logd/RecordingLogBuffer.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2020 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 "SimpleLogBuffer.h"
-
-#include <string>
-#include <tuple>
-#include <vector>
-
-#include <android-base/unique_fd.h>
-
-#include "RecordedLogMessage.h"
-
-class RecordingLogBuffer : public SimpleLogBuffer {
-  public:
-    RecordingLogBuffer(LogReaderList* reader_list, LogTags* tags, LogStatistics* stats)
-        : SimpleLogBuffer(reader_list, tags, stats) {}
-
-    int Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid, const char* msg,
-            uint16_t len) override;
-
-  private:
-    void RecordLogMessage(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
-                          const char* msg, uint16_t len);
-
-    std::vector<std::pair<RecordedLogMessage, std::string>> since_boot_messages_;
-    android::base::unique_fd fd_;
-};
diff --git a/logd/ReplayMessages.cpp b/logd/ReplayMessages.cpp
deleted file mode 100644
index 56509ec..0000000
--- a/logd/ReplayMessages.cpp
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * Copyright (C) 2020 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 <inttypes.h>
-
-#include <chrono>
-#include <map>
-
-#include <android-base/file.h>
-#include <android-base/mapped_file.h>
-#include <android-base/parseint.h>
-#include <android-base/strings.h>
-#include <android-base/unique_fd.h>
-#include <android/log.h>
-#include <log/log_time.h>
-#include <log/logprint.h>
-
-#include "ChattyLogBuffer.h"
-#include "LogBuffer.h"
-#include "LogStatistics.h"
-#include "RecordedLogMessage.h"
-#include "SerializedLogBuffer.h"
-#include "SimpleLogBuffer.h"
-
-using android::base::MappedFile;
-using android::base::ParseInt;
-using android::base::ParseUint;
-using android::base::Split;
-
-char* android::uidToName(uid_t) {
-    return nullptr;
-}
-
-static size_t GetPrivateDirty() {
-    // Allocate once and hope that we don't need to reallocate >40000, to prevent heap fragmentation
-    static std::string smaps(40000, '\0');
-    android::base::ReadFileToString("/proc/self/smaps", &smaps);
-
-    size_t result = 0;
-    size_t base = 0;
-    size_t found;
-    while (true) {
-        found = smaps.find("Private_Dirty:", base);
-        if (found == smaps.npos) break;
-
-        found += sizeof("Private_Dirty:");
-
-        result += atoi(&smaps[found]);
-
-        base = found + 1;
-    }
-
-    return result;
-}
-
-static AndroidLogFormat* GetLogFormat() {
-    static AndroidLogFormat* format = [] {
-        auto* format = android_log_format_new();
-        android_log_setPrintFormat(format, android_log_formatFromString("threadtime"));
-        android_log_setPrintFormat(format, android_log_formatFromString("uid"));
-        return format;
-    }();
-    return format;
-}
-
-static void PrintMessage(struct log_msg* buf) {
-    bool is_binary =
-            buf->id() == LOG_ID_EVENTS || buf->id() == LOG_ID_STATS || buf->id() == LOG_ID_SECURITY;
-
-    AndroidLogEntry entry;
-    int err;
-    if (is_binary) {
-        char binaryMsgBuf[1024];
-        err = android_log_processBinaryLogBuffer(&buf->entry, &entry, nullptr, binaryMsgBuf,
-                                                 sizeof(binaryMsgBuf));
-    } else {
-        err = android_log_processLogBuffer(&buf->entry, &entry);
-    }
-    if (err < 0) {
-        fprintf(stderr, "Error parsing log message\n");
-    }
-
-    android_log_printLogLine(GetLogFormat(), STDOUT_FILENO, &entry);
-}
-
-static log_time GetFirstTimeStamp(const MappedFile& recorded_messages) {
-    if (sizeof(RecordedLogMessage) >= recorded_messages.size()) {
-        fprintf(stderr, "At least one log message must be present in the input\n");
-        exit(1);
-    }
-
-    auto* meta = reinterpret_cast<RecordedLogMessage*>(recorded_messages.data());
-    return meta->realtime;
-}
-
-static LogMask BuffersToLogMask(const char* buffers) {
-    if (buffers == nullptr || !strcmp(buffers, "all")) {
-        return kLogMaskAll;
-    }
-    auto string_ids = Split(buffers, ",");
-    LogMask log_mask = 0;
-    for (const auto& string_id : string_ids) {
-        int buffer_id;
-        if (!ParseInt(string_id, &buffer_id, 0, 7)) {
-            fprintf(stderr, "Could not parse buffer_id '%s'\n", string_id.c_str());
-            exit(1);
-        }
-        log_mask |= 1 << buffer_id;
-    }
-    return log_mask;
-}
-
-class StdoutWriter : public LogWriter {
-  public:
-    StdoutWriter() : LogWriter(0, true) {}
-    bool Write(const logger_entry& entry, const char* message) override {
-        struct log_msg log_msg;
-        log_msg.entry = entry;
-        if (log_msg.entry.len > LOGGER_ENTRY_MAX_PAYLOAD) {
-            fprintf(stderr, "payload too large %" PRIu16, log_msg.entry.len);
-            exit(1);
-        }
-        memcpy(log_msg.msg(), message, log_msg.entry.len);
-
-        PrintMessage(&log_msg);
-
-        return true;
-    }
-
-    void Shutdown() override {
-        fprintf(stderr, "LogWriter::Shutdown() called\n");
-        exit(1);
-    }
-
-    std::string name() const override { return "stdout writer"; }
-};
-
-class Operation {
-  public:
-    virtual ~Operation() {}
-
-    virtual void Begin() {}
-    virtual void Log(const RecordedLogMessage& meta, const char* msg) = 0;
-    virtual void End() {}
-};
-
-class PrintInteresting : public Operation {
-  public:
-    PrintInteresting(log_time first_log_timestamp)
-        : stats_simple_{false, false, first_log_timestamp},
-          stats_chatty_{false, false, first_log_timestamp},
-          stats_serialized_{false, true, first_log_timestamp} {}
-
-    void Begin() override {
-        printf("message_count,simple_main_lines,simple_radio_lines,simple_events_lines,simple_"
-               "system_lines,simple_crash_lines,simple_stats_lines,simple_security_lines,simple_"
-               "kernel_lines,simple_main_size,simple_radio_size,simple_events_size,simple_system_"
-               "size,simple_crash_size,simple_stats_size,simple_security_size,simple_kernel_size,"
-               "simple_main_overhead,simple_radio_overhead,simple_events_overhead,simple_system_"
-               "overhead,simple_crash_overhead,simple_stats_overhead,simple_security_overhead,"
-               "simple_kernel_overhead,simple_main_range,simple_radio_range,simple_events_range,"
-               "simple_system_range,simple_crash_range,simple_stats_range,simple_security_range,"
-               "simple_kernel_range,chatty_main_lines,chatty_radio_lines,chatty_events_lines,"
-               "chatty_system_lines,chatty_crash_lines,chatty_stats_lines,chatty_security_lines,"
-               "chatty_"
-               "kernel_lines,chatty_main_size,chatty_radio_size,chatty_events_size,chatty_system_"
-               "size,chatty_crash_size,chatty_stats_size,chatty_security_size,chatty_kernel_size,"
-               "chatty_main_overhead,chatty_radio_overhead,chatty_events_overhead,chatty_system_"
-               "overhead,chatty_crash_overhead,chatty_stats_overhead,chatty_security_overhead,"
-               "chatty_kernel_overhead,chatty_main_range,chatty_radio_range,chatty_events_range,"
-               "chatty_system_range,chatty_crash_range,chatty_stats_range,chatty_security_range,"
-               "chatty_kernel_range,serialized_main_lines,serialized_radio_lines,serialized_events_"
-               "lines,serialized_"
-               "system_lines,serialized_crash_lines,serialized_stats_lines,serialized_security_"
-               "lines,serialized_"
-               "kernel_lines,serialized_main_size,serialized_radio_size,serialized_events_size,"
-               "serialized_system_"
-               "size,serialized_crash_size,serialized_stats_size,serialized_security_size,"
-               "serialized_kernel_size,"
-               "serialized_main_overhead,serialized_radio_overhead,serialized_events_overhead,"
-               "serialized_system_"
-               "overhead,serialized_crash_overhead,serialized_stats_overhead,serialized_security_"
-               "overhead,"
-               "serialized_kernel_overhead,serialized_main_range,serialized_radio_range,serialized_"
-               "events_range,"
-               "serialized_system_range,serialized_crash_range,serialized_stats_range,serialized_"
-               "security_range,"
-               "serialized_kernel_range\n");
-    }
-
-    void Log(const RecordedLogMessage& meta, const char* msg) override {
-        simple_log_buffer_.Log(static_cast<log_id_t>(meta.log_id), meta.realtime, meta.uid,
-                               meta.pid, meta.tid, msg, meta.msg_len);
-
-        chatty_log_buffer_.Log(static_cast<log_id_t>(meta.log_id), meta.realtime, meta.uid,
-                               meta.pid, meta.tid, msg, meta.msg_len);
-
-        serialized_log_buffer_.Log(static_cast<log_id_t>(meta.log_id), meta.realtime, meta.uid,
-                                   meta.pid, meta.tid, msg, meta.msg_len);
-
-        if (num_message_ % 10000 == 0) {
-            printf("%" PRIu64 ",%s,%s,%s\n", num_message_,
-                   stats_simple_.ReportInteresting().c_str(),
-                   stats_chatty_.ReportInteresting().c_str(),
-                   stats_serialized_.ReportInteresting().c_str());
-        }
-
-        num_message_++;
-    }
-
-  private:
-    uint64_t num_message_ = 1;
-
-    LogReaderList reader_list_;
-    LogTags tags_;
-    PruneList prune_list_;
-
-    LogStatistics stats_simple_;
-    SimpleLogBuffer simple_log_buffer_{&reader_list_, &tags_, &stats_simple_};
-
-    LogStatistics stats_chatty_;
-    ChattyLogBuffer chatty_log_buffer_{&reader_list_, &tags_, &prune_list_, &stats_chatty_};
-
-    LogStatistics stats_serialized_;
-    SerializedLogBuffer serialized_log_buffer_{&reader_list_, &tags_, &stats_serialized_};
-};
-
-class SingleBufferOperation : public Operation {
-  public:
-    SingleBufferOperation(log_time first_log_timestamp, const char* buffer) {
-        if (!strcmp(buffer, "simple")) {
-            stats_.reset(new LogStatistics{false, false, first_log_timestamp});
-            log_buffer_.reset(new SimpleLogBuffer(&reader_list_, &tags_, stats_.get()));
-        } else if (!strcmp(buffer, "chatty")) {
-            stats_.reset(new LogStatistics{false, false, first_log_timestamp});
-            log_buffer_.reset(
-                    new ChattyLogBuffer(&reader_list_, &tags_, &prune_list_, stats_.get()));
-        } else if (!strcmp(buffer, "serialized")) {
-            stats_.reset(new LogStatistics{false, true, first_log_timestamp});
-            log_buffer_.reset(new SerializedLogBuffer(&reader_list_, &tags_, stats_.get()));
-        } else {
-            fprintf(stderr, "invalid log buffer type '%s'\n", buffer);
-            abort();
-        }
-    }
-
-    void Log(const RecordedLogMessage& meta, const char* msg) override {
-        PreOperation();
-        log_buffer_->Log(static_cast<log_id_t>(meta.log_id), meta.realtime, meta.uid, meta.pid,
-                         meta.tid, msg, meta.msg_len);
-
-        Operation();
-
-        num_message_++;
-    }
-
-    virtual void PreOperation() {}
-    virtual void Operation() {}
-
-  protected:
-    uint64_t num_message_ = 1;
-
-    LogReaderList reader_list_;
-    LogTags tags_;
-    PruneList prune_list_;
-
-    std::unique_ptr<LogStatistics> stats_;
-    std::unique_ptr<LogBuffer> log_buffer_;
-};
-
-class PrintMemory : public SingleBufferOperation {
-  public:
-    PrintMemory(log_time first_log_timestamp, const char* buffer)
-        : SingleBufferOperation(first_log_timestamp, buffer) {}
-
-    void Operation() override {
-        if (num_message_ % 100000 == 0) {
-            printf("%" PRIu64 ",%s\n", num_message_,
-                   std::to_string(GetPrivateDirty() - baseline_memory_).c_str());
-        }
-    }
-
-  private:
-    size_t baseline_memory_ = GetPrivateDirty();
-};
-
-class PrintLogs : public SingleBufferOperation {
-  public:
-    PrintLogs(log_time first_log_timestamp, const char* buffer, const char* buffers,
-              const char* print_point)
-        : SingleBufferOperation(first_log_timestamp, buffer) {
-        mask_ = BuffersToLogMask(buffers);
-        if (print_point != nullptr) {
-            uint64_t result = 0;
-            if (!ParseUint(print_point, &result)) {
-                fprintf(stderr, "Could not parse print point '%s'\n", print_point);
-                exit(1);
-            }
-            print_point_ = result;
-        }
-    }
-
-    void Operation() override {
-        if (print_point_ && num_message_ >= *print_point_) {
-            End();
-            exit(0);
-        }
-    }
-
-    void End() override {
-        std::unique_ptr<LogWriter> test_writer(new StdoutWriter());
-        std::unique_ptr<FlushToState> flush_to_state = log_buffer_->CreateFlushToState(1, mask_);
-        log_buffer_->FlushTo(test_writer.get(), *flush_to_state, nullptr);
-
-        auto stats_string = stats_->Format(0, 0, mask_);
-        printf("%s\n", stats_string.c_str());
-    }
-
-  private:
-    LogMask mask_ = kLogMaskAll;
-    std::optional<uint64_t> print_point_;
-};
-
-class PrintLatency : public SingleBufferOperation {
-  public:
-    PrintLatency(log_time first_log_timestamp, const char* buffer)
-        : SingleBufferOperation(first_log_timestamp, buffer) {}
-
-    void PreOperation() override { operation_start_ = std::chrono::steady_clock::now(); }
-
-    void Operation() override {
-        auto end = std::chrono::steady_clock::now();
-        auto duration = (end - operation_start_).count();
-        durations_.emplace_back(duration);
-    }
-
-    void End() override {
-        std::sort(durations_.begin(), durations_.end());
-        auto q1 = durations_.size() / 4;
-        auto q2 = durations_.size() / 2;
-        auto q3 = 3 * durations_.size() / 4;
-
-        auto p95 = 95 * durations_.size() / 100;
-        auto p99 = 99 * durations_.size() / 100;
-        auto p9999 = 9999 * durations_.size() / 10000;
-
-        printf("q1: %lld q2: %lld q3: %lld  p95: %lld p99: %lld p99.99: %lld  max: %lld\n",
-               durations_[q1], durations_[q2], durations_[q3], durations_[p95], durations_[p99],
-               durations_[p9999], durations_.back());
-    }
-
-  private:
-    std::chrono::steady_clock::time_point operation_start_;
-    std::vector<long long> durations_;
-};
-
-class PrintAllLogs : public SingleBufferOperation {
-  public:
-    PrintAllLogs(log_time first_log_timestamp, const char* buffer, const char* buffers)
-        : SingleBufferOperation(first_log_timestamp, buffer) {
-        LogMask mask = BuffersToLogMask(buffers);
-        auto lock = std::unique_lock{reader_list_.reader_threads_lock()};
-        std::unique_ptr<LogWriter> stdout_writer(new StdoutWriter());
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer_.get(), &reader_list_, std::move(stdout_writer),
-                                    false, 0, mask, 0, {}, 1, {}));
-        reader_list_.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    void Operation() override {
-        // If the rate of reading logs is slower than the rate of incoming logs, then the reader
-        // thread is disconnected to not overflow log buffers, therefore we artificially slow down
-        // the incoming log rate.
-        usleep(100);
-    }
-};
-
-int main(int argc, char** argv) {
-    if (argc < 3) {
-        fprintf(stderr, "Usage: %s FILE OPERATION [BUFFER] [OPTIONS]\n", argv[0]);
-        return 1;
-    }
-
-    if (strcmp(argv[2], "interesting") != 0 && argc < 4) {
-        fprintf(stderr, "Operations other than 'interesting' require a BUFFER argument\n");
-        return 1;
-    }
-
-    int recorded_messages_fd = open(argv[1], O_RDONLY);
-    if (recorded_messages_fd == -1) {
-        fprintf(stderr, "Couldn't open input file\n");
-        return 1;
-    }
-    struct stat fd_stat;
-    if (fstat(recorded_messages_fd, &fd_stat) != 0) {
-        fprintf(stderr, "Couldn't fstat input file\n");
-        return 1;
-    }
-    auto recorded_messages = MappedFile::FromFd(recorded_messages_fd, 0,
-                                                static_cast<size_t>(fd_stat.st_size), PROT_READ);
-    if (recorded_messages == nullptr) {
-        fprintf(stderr, "Couldn't mmap input file\n");
-        return 1;
-    }
-
-    // LogStatistics typically uses 'now()' to initialize its log range state, but this doesn't work
-    // when replaying older logs, so we instead give it the timestamp from the first log.
-    log_time first_log_timestamp = GetFirstTimeStamp(*recorded_messages);
-
-    std::unique_ptr<Operation> operation;
-    if (!strcmp(argv[2], "interesting")) {
-        operation.reset(new PrintInteresting(first_log_timestamp));
-    } else if (!strcmp(argv[2], "memory_usage")) {
-        operation.reset(new PrintMemory(first_log_timestamp, argv[3]));
-    } else if (!strcmp(argv[2], "latency")) {
-        operation.reset(new PrintLatency(first_log_timestamp, argv[3]));
-    } else if (!strcmp(argv[2], "print_logs")) {
-        operation.reset(new PrintLogs(first_log_timestamp, argv[3], argc > 4 ? argv[4] : nullptr,
-                                      argc > 5 ? argv[5] : nullptr));
-    } else if (!strcmp(argv[2], "print_all_logs")) {
-        operation.reset(
-                new PrintAllLogs(first_log_timestamp, argv[3], argc > 4 ? argv[4] : nullptr));
-    } else if (!strcmp(argv[2], "nothing")) {
-        operation.reset(new SingleBufferOperation(first_log_timestamp, argv[3]));
-    } else {
-        fprintf(stderr, "unknown operation '%s'\n", argv[2]);
-        return 1;
-    }
-
-    // LogBuffer::Log() won't log without this on host.
-    __android_log_set_minimum_priority(ANDROID_LOG_VERBOSE);
-    // But we still want to suppress messages <= error to not interrupt the rest of the output.
-    __android_log_set_logger([](const struct __android_log_message* log_message) {
-        if (log_message->priority < ANDROID_LOG_ERROR) {
-            return;
-        }
-        __android_log_stderr_logger(log_message);
-    });
-
-    operation->Begin();
-
-    uint64_t read_position = 0;
-    while (read_position + sizeof(RecordedLogMessage) < recorded_messages->size()) {
-        auto* meta =
-                reinterpret_cast<RecordedLogMessage*>(recorded_messages->data() + read_position);
-        if (read_position + sizeof(RecordedLogMessage) + meta->msg_len >=
-            recorded_messages->size()) {
-            break;
-        }
-        char* msg = recorded_messages->data() + read_position + sizeof(RecordedLogMessage);
-        read_position += sizeof(RecordedLogMessage) + meta->msg_len;
-
-        operation->Log(*meta, msg);
-    }
-
-    operation->End();
-
-    return 0;
-}
diff --git a/logd/SerializedData.h b/logd/SerializedData.h
deleted file mode 100644
index d3d1e18..0000000
--- a/logd/SerializedData.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2020 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 <sys/types.h>
-
-#include <algorithm>
-#include <memory>
-
-// This class is used instead of std::string or std::vector because their clear(), erase(), etc
-// functions don't actually deallocate.  shrink_to_fit() does deallocate but is not guaranteed to
-// work and swapping with an empty string/vector is clunky.
-class SerializedData {
-  public:
-    SerializedData() {}
-    SerializedData(size_t size) : data_(new uint8_t[size]), size_(size) {}
-
-    void Resize(size_t new_size) {
-        if (size_ == 0) {
-            data_.reset(new uint8_t[new_size]);
-            size_ = new_size;
-        } else if (new_size == 0) {
-            data_.reset();
-            size_ = 0;
-        } else if (new_size != size_) {
-            std::unique_ptr<uint8_t[]> new_data(new uint8_t[new_size]);
-            size_t copy_size = std::min(size_, new_size);
-            memcpy(new_data.get(), data_.get(), copy_size);
-            data_.swap(new_data);
-            size_ = new_size;
-        }
-    }
-
-    uint8_t* data() { return data_.get(); }
-    const uint8_t* data() const { return data_.get(); }
-    size_t size() const { return size_; }
-
-  private:
-    std::unique_ptr<uint8_t[]> data_;
-    size_t size_ = 0;
-};
\ No newline at end of file
diff --git a/logd/SerializedFlushToState.cpp b/logd/SerializedFlushToState.cpp
deleted file mode 100644
index b02ccc3..0000000
--- a/logd/SerializedFlushToState.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2020 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 "SerializedFlushToState.h"
-
-#include <android-base/logging.h>
-
-SerializedFlushToState::SerializedFlushToState(uint64_t start, LogMask log_mask)
-    : FlushToState(start, log_mask) {
-    log_id_for_each(i) {
-        if (((1 << i) & log_mask) == 0) {
-            continue;
-        }
-        logs_needed_from_next_position_[i] = true;
-    }
-}
-
-SerializedFlushToState::~SerializedFlushToState() {
-    log_id_for_each(i) {
-        if (log_positions_[i]) {
-            log_positions_[i]->buffer_it->DecReaderRefCount();
-        }
-    }
-}
-
-void SerializedFlushToState::CreateLogPosition(log_id_t log_id) {
-    CHECK(!logs_[log_id].empty());
-    LogPosition log_position;
-    auto it = logs_[log_id].begin();
-    while (it != logs_[log_id].end() && start() > it->highest_sequence_number()) {
-        ++it;
-    }
-    if (it == logs_[log_id].end()) {
-        --it;
-    }
-    it->IncReaderRefCount();
-    log_position.buffer_it = it;
-
-    // Find the offset of the first log with sequence number >= start().
-    int read_offset = 0;
-    while (read_offset < it->write_offset()) {
-        const auto* entry = it->log_entry(read_offset);
-        if (entry->sequence() >= start()) {
-            break;
-        }
-        read_offset += entry->total_len();
-    }
-    log_position.read_offset = read_offset;
-
-    log_positions_[log_id].emplace(log_position);
-}
-
-void SerializedFlushToState::AddMinHeapEntry(log_id_t log_id) {
-    auto& buffer_it = log_positions_[log_id]->buffer_it;
-    auto read_offset = log_positions_[log_id]->read_offset;
-
-    // If there is another log to read in this buffer, add it to the min heap.
-    if (read_offset < buffer_it->write_offset()) {
-        auto* entry = buffer_it->log_entry(read_offset);
-        min_heap_.emplace(log_id, entry);
-    } else if (read_offset == buffer_it->write_offset()) {
-        // If there are no more logs to read in this buffer and it's the last buffer, then
-        // set logs_needed_from_next_position_ to wait until more logs get logged.
-        if (buffer_it == std::prev(logs_[log_id].end())) {
-            logs_needed_from_next_position_[log_id] = true;
-        } else {
-            // Otherwise, if there is another buffer piece, move to that and do the same check.
-            buffer_it->DecReaderRefCount();
-            ++buffer_it;
-            buffer_it->IncReaderRefCount();
-            log_positions_[log_id]->read_offset = 0;
-            if (buffer_it->write_offset() == 0) {
-                logs_needed_from_next_position_[log_id] = true;
-            } else {
-                auto* entry = buffer_it->log_entry(0);
-                min_heap_.emplace(log_id, entry);
-            }
-        }
-    } else {
-        // read_offset > buffer_it->write_offset() should never happen.
-        CHECK(false);
-    }
-}
-
-void SerializedFlushToState::CheckForNewLogs() {
-    log_id_for_each(i) {
-        if (!logs_needed_from_next_position_[i]) {
-            continue;
-        }
-        if (!log_positions_[i]) {
-            if (logs_[i].empty()) {
-                continue;
-            }
-            CreateLogPosition(i);
-        }
-        logs_needed_from_next_position_[i] = false;
-        // If it wasn't possible to insert, logs_needed_from_next_position will be set back to true.
-        AddMinHeapEntry(i);
-    }
-}
-
-MinHeapElement SerializedFlushToState::PopNextUnreadLog() {
-    auto top = min_heap_.top();
-    min_heap_.pop();
-
-    auto* entry = top.entry;
-    auto log_id = top.log_id;
-
-    log_positions_[log_id]->read_offset += entry->total_len();
-
-    logs_needed_from_next_position_[log_id] = true;
-
-    return top;
-}
-
-void SerializedFlushToState::Prune(log_id_t log_id,
-                                   const std::list<SerializedLogChunk>::iterator& buffer_it) {
-    // If we don't have a position for this log or if we're not referencing buffer_it, ignore.
-    if (!log_positions_[log_id].has_value() || log_positions_[log_id]->buffer_it != buffer_it) {
-        return;
-    }
-
-    // // Decrease the ref count since we're deleting our reference.
-    buffer_it->DecReaderRefCount();
-
-    // Delete in the reference.
-    log_positions_[log_id].reset();
-
-    // Remove the MinHeapElement referencing log_id, if it exists, but retain the others.
-    std::vector<MinHeapElement> old_elements;
-    while (!min_heap_.empty()) {
-        auto& element = min_heap_.top();
-        if (element.log_id != log_id) {
-            old_elements.emplace_back(element);
-        }
-        min_heap_.pop();
-    }
-    for (auto&& element : old_elements) {
-        min_heap_.emplace(element);
-    }
-
-    // Finally set logs_needed_from_next_position_, so CheckForNewLogs() will re-create the
-    // log_position_ object during the next read.
-    logs_needed_from_next_position_[log_id] = true;
-}
diff --git a/logd/SerializedFlushToState.h b/logd/SerializedFlushToState.h
deleted file mode 100644
index 0b20822..0000000
--- a/logd/SerializedFlushToState.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2020 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 <bitset>
-#include <list>
-#include <queue>
-
-#include "LogBuffer.h"
-#include "SerializedLogChunk.h"
-#include "SerializedLogEntry.h"
-
-struct LogPosition {
-    std::list<SerializedLogChunk>::iterator buffer_it;
-    int read_offset;
-};
-
-struct MinHeapElement {
-    MinHeapElement(log_id_t log_id, const SerializedLogEntry* entry)
-        : log_id(log_id), entry(entry) {}
-    log_id_t log_id;
-    const SerializedLogEntry* entry;
-    // The change of comparison operators is intentional, std::priority_queue uses operator<() to
-    // compare but creates a max heap.  Since we want a min heap, we return the opposite result.
-    bool operator<(const MinHeapElement& rhs) const {
-        return entry->sequence() > rhs.entry->sequence();
-    }
-};
-
-// This class tracks the specific point where a FlushTo client has read through the logs.  It
-// directly references the std::list<> iterators from the parent SerializedLogBuffer and the offset
-// into each log chunk where it has last read.  All interactions with this class, except for its
-// construction, must be done with SerializedLogBuffer::lock_ held.  No log chunks that it
-// references may be pruned, which is handled by ensuring prune does not touch any log chunk with
-// highest sequence number greater or equal to start().
-class SerializedFlushToState : public FlushToState {
-  public:
-    // Initializes this state object.  For each log buffer set in log_mask, this sets
-    // logs_needed_from_next_position_.
-    SerializedFlushToState(uint64_t start, LogMask log_mask);
-
-    // Decrease the reference of all referenced logs.  This happens when a reader is disconnected.
-    ~SerializedFlushToState() override;
-
-    // We can't hold SerializedLogBuffer::lock_ in the constructor, so we must initialize logs here.
-    void InitializeLogs(std::list<SerializedLogChunk>* logs) {
-        if (logs_ == nullptr) logs_ = logs;
-    }
-
-    bool HasUnreadLogs() {
-        CheckForNewLogs();
-        return !min_heap_.empty();
-    }
-
-    // Pops the next unread log from the min heap and sets logs_needed_from_next_position_ to
-    // indicate that we're waiting for more logs from the associated log buffer.
-    MinHeapElement PopNextUnreadLog();
-
-    // If the parent log buffer prunes logs, the reference that this class contains may become
-    // invalid, so this must be called first to drop the reference to buffer_it, if any.
-    void Prune(log_id_t log_id, const std::list<SerializedLogChunk>::iterator& buffer_it);
-
-  private:
-    // If there is a log in the serialized log buffer for `log_id` at the read_offset, add it to the
-    // min heap for reading, otherwise set logs_needed_from_next_position_ to indicate that we're
-    // waiting for the next log.
-    void AddMinHeapEntry(log_id_t log_id);
-
-    // Create a LogPosition object for the given log_id by searching through the log chunks for the
-    // first chunk and then first log entry within that chunk that is greater or equal to start().
-    void CreateLogPosition(log_id_t log_id);
-
-    // Checks to see if any log buffers set in logs_needed_from_next_position_ have new logs and
-    // calls AddMinHeapEntry() if so.
-    void CheckForNewLogs();
-
-    std::list<SerializedLogChunk>* logs_ = nullptr;
-    // An optional structure that contains an iterator to the serialized log buffer and offset into
-    // it that this logger should handle next.
-    std::optional<LogPosition> log_positions_[LOG_ID_MAX];
-    // A bit for each log that is set if a given log_id has no logs or if this client has read all
-    // of its logs. In order words: `logs_[i].empty() || (buffer_it == std::prev(logs_.end) &&
-    // next_log_position == logs_write_position_)`.  These will be re-checked in each
-    // loop in case new logs came in.
-    std::bitset<LOG_ID_MAX> logs_needed_from_next_position_ = {};
-    // A min heap that has up to one entry per log buffer, sorted by sequence number, of the next
-    // element that this reader should read.
-    std::priority_queue<MinHeapElement> min_heap_;
-};
diff --git a/logd/SerializedFlushToStateTest.cpp b/logd/SerializedFlushToStateTest.cpp
deleted file mode 100644
index f4515c8..0000000
--- a/logd/SerializedFlushToStateTest.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2020 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 "SerializedFlushToState.h"
-
-#include <map>
-
-#include <android-base/logging.h>
-#include <android-base/stringprintf.h>
-#include <android-base/strings.h>
-#include <gtest/gtest.h>
-
-using android::base::Join;
-using android::base::StringPrintf;
-
-constexpr size_t kChunkSize = 3 * 4096;
-
-class SerializedFlushToStateTest : public testing::Test {
-  protected:
-    void SetUp() override {
-        // This test spams many unneeded INFO logs, so we suppress them.
-        old_log_severity_ = android::base::SetMinimumLogSeverity(android::base::WARNING);
-    }
-    void TearDown() override { android::base::SetMinimumLogSeverity(old_log_severity_); }
-
-    std::string TestReport(const std::vector<uint64_t>& expected,
-                           const std::vector<uint64_t>& read) {
-        auto sequence_to_log_id = [&](uint64_t sequence) -> int {
-            for (const auto& [log_id, sequences] : sequence_numbers_per_buffer_) {
-                if (std::find(sequences.begin(), sequences.end(), sequence) != sequences.end()) {
-                    return log_id;
-                }
-            }
-            return -1;
-        };
-
-        std::map<int, std::vector<uint64_t>> missing_sequences;
-        std::vector<uint64_t> missing_expected;
-        std::set_difference(expected.begin(), expected.end(), read.begin(), read.end(),
-                            std::back_inserter(missing_expected));
-        for (uint64_t sequence : missing_expected) {
-            int log_id = sequence_to_log_id(sequence);
-            missing_sequences[log_id].emplace_back(sequence);
-        }
-
-        std::map<int, std::vector<uint64_t>> extra_sequences;
-        std::vector<uint64_t> extra_read;
-        std::set_difference(read.begin(), read.end(), expected.begin(), expected.end(),
-                            std::back_inserter(extra_read));
-        for (uint64_t sequence : extra_read) {
-            int log_id = sequence_to_log_id(sequence);
-            extra_sequences[log_id].emplace_back(sequence);
-        }
-
-        std::vector<std::string> errors;
-        for (const auto& [log_id, sequences] : missing_sequences) {
-            errors.emplace_back(
-                    StringPrintf("Log id %d missing %zu sequences", log_id, sequences.size()));
-        }
-
-        for (const auto& [log_id, sequences] : extra_sequences) {
-            errors.emplace_back(
-                    StringPrintf("Log id %d has extra %zu sequences", log_id, sequences.size()));
-        }
-
-        return Join(errors, ", ");
-    }
-
-    // Read sequence numbers in order from SerializedFlushToState for every mask combination and all
-    // sequence numbers from 0 through the highest logged sequence number + 1.
-    // This assumes that all of the logs have already been written.
-    void TestAllReading() {
-        uint64_t max_sequence = sequence_ + 1;
-        uint32_t max_mask = (1 << LOG_ID_MAX) - 1;
-        for (uint64_t sequence = 0; sequence < max_sequence; ++sequence) {
-            for (uint32_t mask = 0; mask < max_mask; ++mask) {
-                auto state = SerializedFlushToState{sequence, mask};
-                state.InitializeLogs(log_chunks_);
-                TestReading(sequence, mask, state);
-            }
-        }
-    }
-
-    // Similar to TestAllReading() except that it doesn't assume any logs are in the buffer, instead
-    // it calls write_logs() in a loop for sequence/mask combination.  It clears log_chunks_ and
-    // sequence_numbers_per_buffer_ between calls, such that only the sequence numbers written in
-    // the previous call to write_logs() are expected.
-    void TestAllReadingWithFutureMessages(const std::function<bool(int)>& write_logs) {
-        uint64_t max_sequence = sequence_ + 1;
-        uint32_t max_mask = (1 << LOG_ID_MAX) - 1;
-        for (uint64_t sequence = 1; sequence < max_sequence; ++sequence) {
-            for (uint32_t mask = 1; mask < max_mask; ++mask) {
-                log_id_for_each(i) { log_chunks_[i].clear(); }
-                auto state = SerializedFlushToState{sequence, mask};
-                state.InitializeLogs(log_chunks_);
-                int loop_count = 0;
-                while (write_logs(loop_count++)) {
-                    TestReading(sequence, mask, state);
-                    sequence_numbers_per_buffer_.clear();
-                }
-            }
-        }
-    }
-
-    void TestReading(uint64_t start, LogMask log_mask, SerializedFlushToState& state) {
-        std::vector<uint64_t> expected_sequence;
-        log_id_for_each(i) {
-            if (((1 << i) & log_mask) == 0) {
-                continue;
-            }
-            for (const auto& sequence : sequence_numbers_per_buffer_[i]) {
-                if (sequence >= start) {
-                    expected_sequence.emplace_back(sequence);
-                }
-            }
-        }
-        std::sort(expected_sequence.begin(), expected_sequence.end());
-
-        std::vector<uint64_t> read_sequence;
-
-        while (state.HasUnreadLogs()) {
-            auto top = state.PopNextUnreadLog();
-            read_sequence.emplace_back(top.entry->sequence());
-        }
-
-        EXPECT_TRUE(std::is_sorted(read_sequence.begin(), read_sequence.end()));
-
-        EXPECT_EQ(expected_sequence.size(), read_sequence.size());
-
-        EXPECT_EQ(expected_sequence, read_sequence)
-                << "start: " << start << " log_mask: " << log_mask << " "
-                << TestReport(expected_sequence, read_sequence);
-    }
-
-    // Add a chunk with the given messages to the a given log buffer.  Keep track of the sequence
-    // numbers for future validation.  Optionally mark the block as having finished writing.
-    void AddChunkWithMessages(bool finish_writing, int buffer,
-                              const std::vector<std::string>& messages) {
-        auto chunk = SerializedLogChunk{kChunkSize};
-        for (const auto& message : messages) {
-            auto sequence = sequence_++;
-            sequence_numbers_per_buffer_[buffer].emplace_back(sequence);
-            ASSERT_TRUE(chunk.CanLog(message.size() + 1));
-            chunk.Log(sequence, log_time(), 0, 1, 1, message.c_str(), message.size() + 1);
-        }
-        if (finish_writing) {
-            chunk.FinishWriting();
-        }
-        log_chunks_[buffer].emplace_back(std::move(chunk));
-    }
-
-    android::base::LogSeverity old_log_severity_;
-    std::map<int, std::vector<uint64_t>> sequence_numbers_per_buffer_;
-    std::list<SerializedLogChunk> log_chunks_[LOG_ID_MAX];
-    uint64_t sequence_ = 1;
-};
-
-// 0: multiple chunks, with variable number of entries, with/without finishing writing
-// 1: 1 chunk with 1 log and finished writing
-// 2: 1 chunk with 1 log and not finished writing
-// 3: 1 chunk with 0 logs and not finished writing
-// 4: 1 chunk with 0 logs and finished writing (impossible, but SerializedFlushToState handles it)
-// 5-7: 0 chunks
-TEST_F(SerializedFlushToStateTest, smoke) {
-    AddChunkWithMessages(true, 0, {"1st", "2nd"});
-    AddChunkWithMessages(true, 1, {"3rd"});
-    AddChunkWithMessages(false, 0, {"4th"});
-    AddChunkWithMessages(true, 0, {"4th", "5th", "more", "even", "more", "go", "here"});
-    AddChunkWithMessages(false, 2, {"6th"});
-    AddChunkWithMessages(true, 0, {"7th"});
-    AddChunkWithMessages(false, 3, {});
-    AddChunkWithMessages(true, 4, {});
-
-    TestAllReading();
-}
-
-TEST_F(SerializedFlushToStateTest, random) {
-    srand(1);
-    for (int count = 0; count < 20; ++count) {
-        unsigned int num_messages = 1 + rand() % 15;
-        auto messages = std::vector<std::string>{num_messages, "same message"};
-
-        bool compress = rand() % 2;
-        int buf = rand() % LOG_ID_MAX;
-
-        AddChunkWithMessages(compress, buf, messages);
-    }
-
-    TestAllReading();
-}
-
-// Same start as smoke, but we selectively write logs to the buffers and ensure they're read.
-TEST_F(SerializedFlushToStateTest, future_writes) {
-    auto write_logs = [&](int loop_count) {
-        switch (loop_count) {
-            case 0:
-                // Initial writes.
-                AddChunkWithMessages(true, 0, {"1st", "2nd"});
-                AddChunkWithMessages(true, 1, {"3rd"});
-                AddChunkWithMessages(false, 0, {"4th"});
-                AddChunkWithMessages(true, 0, {"4th", "5th", "more", "even", "more", "go", "here"});
-                AddChunkWithMessages(false, 2, {"6th"});
-                AddChunkWithMessages(true, 0, {"7th"});
-                AddChunkWithMessages(false, 3, {});
-                AddChunkWithMessages(true, 4, {});
-                break;
-            case 1:
-                // Smoke test, add a simple chunk.
-                AddChunkWithMessages(true, 0, {"1st", "2nd"});
-                break;
-            case 2:
-                // Add chunks to all but one of the logs.
-                AddChunkWithMessages(true, 0, {"1st", "2nd"});
-                AddChunkWithMessages(true, 1, {"1st", "2nd"});
-                AddChunkWithMessages(true, 2, {"1st", "2nd"});
-                AddChunkWithMessages(true, 3, {"1st", "2nd"});
-                AddChunkWithMessages(true, 4, {"1st", "2nd"});
-                AddChunkWithMessages(true, 5, {"1st", "2nd"});
-                AddChunkWithMessages(true, 6, {"1st", "2nd"});
-                break;
-            case 3:
-                // Finally add chunks to all logs.
-                AddChunkWithMessages(true, 0, {"1st", "2nd"});
-                AddChunkWithMessages(true, 1, {"1st", "2nd"});
-                AddChunkWithMessages(true, 2, {"1st", "2nd"});
-                AddChunkWithMessages(true, 3, {"1st", "2nd"});
-                AddChunkWithMessages(true, 4, {"1st", "2nd"});
-                AddChunkWithMessages(true, 5, {"1st", "2nd"});
-                AddChunkWithMessages(true, 6, {"1st", "2nd"});
-                AddChunkWithMessages(true, 7, {"1st", "2nd"});
-                break;
-            default:
-                return false;
-        }
-        return true;
-    };
-
-    TestAllReadingWithFutureMessages(write_logs);
-}
-
-TEST_F(SerializedFlushToStateTest, no_dangling_references) {
-    AddChunkWithMessages(true, 0, {"1st", "2nd"});
-    AddChunkWithMessages(true, 0, {"3rd", "4th"});
-
-    auto state = SerializedFlushToState{1, kLogMaskAll};
-    state.InitializeLogs(log_chunks_);
-
-    ASSERT_EQ(log_chunks_[0].size(), 2U);
-    auto first_chunk = log_chunks_[0].begin();
-    auto second_chunk = std::next(first_chunk);
-
-    ASSERT_TRUE(state.HasUnreadLogs());
-    auto first_log = state.PopNextUnreadLog();
-    EXPECT_STREQ(first_log.entry->msg(), "1st");
-    EXPECT_EQ(first_chunk->reader_ref_count(), 1U);
-    EXPECT_EQ(second_chunk->reader_ref_count(), 0U);
-
-    ASSERT_TRUE(state.HasUnreadLogs());
-    auto second_log = state.PopNextUnreadLog();
-    EXPECT_STREQ(second_log.entry->msg(), "2nd");
-    EXPECT_EQ(first_chunk->reader_ref_count(), 1U);
-    EXPECT_EQ(second_chunk->reader_ref_count(), 0U);
-
-    ASSERT_TRUE(state.HasUnreadLogs());
-    auto third_log = state.PopNextUnreadLog();
-    EXPECT_STREQ(third_log.entry->msg(), "3rd");
-    EXPECT_EQ(first_chunk->reader_ref_count(), 0U);
-    EXPECT_EQ(second_chunk->reader_ref_count(), 1U);
-
-    ASSERT_TRUE(state.HasUnreadLogs());
-    auto fourth_log = state.PopNextUnreadLog();
-    EXPECT_STREQ(fourth_log.entry->msg(), "4th");
-    EXPECT_EQ(first_chunk->reader_ref_count(), 0U);
-    EXPECT_EQ(second_chunk->reader_ref_count(), 1U);
-
-    EXPECT_FALSE(state.HasUnreadLogs());
-}
\ No newline at end of file
diff --git a/logd/SerializedLogBuffer.cpp b/logd/SerializedLogBuffer.cpp
deleted file mode 100644
index 5012d3d..0000000
--- a/logd/SerializedLogBuffer.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (C) 2020 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 "SerializedLogBuffer.h"
-
-#include <sys/prctl.h>
-
-#include <limits>
-
-#include <android-base/logging.h>
-#include <android-base/scopeguard.h>
-
-#include "LogSize.h"
-#include "LogStatistics.h"
-#include "SerializedFlushToState.h"
-
-SerializedLogBuffer::SerializedLogBuffer(LogReaderList* reader_list, LogTags* tags,
-                                         LogStatistics* stats)
-    : reader_list_(reader_list), tags_(tags), stats_(stats) {
-    Init();
-}
-
-void SerializedLogBuffer::Init() {
-    log_id_for_each(i) {
-        if (!SetSize(i, GetBufferSizeFromProperties(i))) {
-            SetSize(i, kLogBufferMinSize);
-        }
-    }
-
-    // Release any sleeping reader threads to dump their current content.
-    auto reader_threads_lock = std::lock_guard{reader_list_->reader_threads_lock()};
-    for (const auto& reader_thread : reader_list_->reader_threads()) {
-        reader_thread->triggerReader_Locked();
-    }
-}
-
-bool SerializedLogBuffer::ShouldLog(log_id_t log_id, const char* msg, uint16_t len) {
-    if (log_id == LOG_ID_SECURITY) {
-        return true;
-    }
-
-    int prio = ANDROID_LOG_INFO;
-    const char* tag = nullptr;
-    size_t tag_len = 0;
-    if (IsBinary(log_id)) {
-        int32_t tag_int = MsgToTag(msg, len);
-        tag = tags_->tagToName(tag_int);
-        if (tag) {
-            tag_len = strlen(tag);
-        }
-    } else {
-        prio = *msg;
-        tag = msg + 1;
-        tag_len = strnlen(tag, len - 1);
-    }
-    return __android_log_is_loggable_len(prio, tag, tag_len, ANDROID_LOG_VERBOSE);
-}
-
-int SerializedLogBuffer::Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
-                             const char* msg, uint16_t len) {
-    if (log_id >= LOG_ID_MAX || len == 0) {
-        return -EINVAL;
-    }
-
-    if (len > LOGGER_ENTRY_MAX_PAYLOAD) {
-        len = LOGGER_ENTRY_MAX_PAYLOAD;
-    }
-
-    if (!ShouldLog(log_id, msg, len)) {
-        stats_->AddTotal(log_id, len);
-        return -EACCES;
-    }
-
-    auto sequence = sequence_.fetch_add(1, std::memory_order_relaxed);
-
-    auto lock = std::lock_guard{lock_};
-
-    if (logs_[log_id].empty()) {
-        logs_[log_id].push_back(SerializedLogChunk(max_size_[log_id] / 4));
-    }
-
-    auto total_len = sizeof(SerializedLogEntry) + len;
-    if (!logs_[log_id].back().CanLog(total_len)) {
-        logs_[log_id].back().FinishWriting();
-        logs_[log_id].push_back(SerializedLogChunk(max_size_[log_id] / 4));
-    }
-
-    auto entry = logs_[log_id].back().Log(sequence, realtime, uid, pid, tid, msg, len);
-    stats_->Add(entry->ToLogStatisticsElement(log_id));
-
-    MaybePrune(log_id);
-
-    reader_list_->NotifyNewLog(1 << log_id);
-    return len;
-}
-
-void SerializedLogBuffer::MaybePrune(log_id_t log_id) {
-    size_t total_size = GetSizeUsed(log_id);
-    size_t after_size = total_size;
-    if (total_size > max_size_[log_id]) {
-        Prune(log_id, total_size - max_size_[log_id], 0);
-        after_size = GetSizeUsed(log_id);
-        LOG(INFO) << "Pruned Logs from log_id: " << log_id << ", previous size: " << total_size
-                  << " after size: " << after_size;
-    }
-
-    stats_->set_overhead(log_id, after_size);
-}
-
-void SerializedLogBuffer::RemoveChunkFromStats(log_id_t log_id, SerializedLogChunk& chunk) {
-    chunk.IncReaderRefCount();
-    int read_offset = 0;
-    while (read_offset < chunk.write_offset()) {
-        auto* entry = chunk.log_entry(read_offset);
-        stats_->Subtract(entry->ToLogStatisticsElement(log_id));
-        read_offset += entry->total_len();
-    }
-    chunk.DecReaderRefCount();
-}
-
-void SerializedLogBuffer::NotifyReadersOfPrune(
-        log_id_t log_id, const std::list<SerializedLogChunk>::iterator& chunk) {
-    for (const auto& reader_thread : reader_list_->reader_threads()) {
-        auto& state = reinterpret_cast<SerializedFlushToState&>(reader_thread->flush_to_state());
-        state.Prune(log_id, chunk);
-    }
-}
-
-void SerializedLogBuffer::Prune(log_id_t log_id, size_t bytes_to_free, uid_t uid) {
-    auto reader_threads_lock = std::lock_guard{reader_list_->reader_threads_lock()};
-
-    auto& log_buffer = logs_[log_id];
-    auto it = log_buffer.begin();
-    while (it != log_buffer.end()) {
-        for (const auto& reader_thread : reader_list_->reader_threads()) {
-            if (!reader_thread->IsWatching(log_id)) {
-                continue;
-            }
-
-            if (reader_thread->deadline().time_since_epoch().count() != 0) {
-                // Always wake up wrapped readers when pruning.  'Wrapped' readers are an
-                // optimization that allows the reader to wait until logs starting at a specified
-                // time stamp are about to be pruned.  This is error-prone however, since if that
-                // timestamp is about to be pruned, the reader is not likely to read the messages
-                // fast enough to not back-up logd.  Instead, we can achieve an nearly-as-efficient
-                // but not error-prune batching effect by waking the reader whenever any chunk is
-                // about to be pruned.
-                reader_thread->triggerReader_Locked();
-            }
-
-            // Some readers may be still reading from this log chunk, log a warning that they are
-            // about to lose logs.
-            // TODO: We should forcefully disconnect the reader instead, such that the reader itself
-            // has an indication that they've lost logs.
-            if (reader_thread->start() <= it->highest_sequence_number()) {
-                LOG(WARNING) << "Skipping entries from slow reader, " << reader_thread->name()
-                             << ", from LogBuffer::Prune()";
-            }
-        }
-
-        // Increment ahead of time since we're going to erase this iterator from the list.
-        auto it_to_prune = it++;
-
-        // Readers may have a reference to the chunk to track their last read log_position.
-        // Notify them to delete the reference.
-        NotifyReadersOfPrune(log_id, it_to_prune);
-
-        if (uid != 0) {
-            // Reorder the log buffer to remove logs from the given UID.  If there are no logs left
-            // in the buffer after the removal, delete it.
-            if (it_to_prune->ClearUidLogs(uid, log_id, stats_)) {
-                log_buffer.erase(it_to_prune);
-            }
-        } else {
-            size_t buffer_size = it_to_prune->PruneSize();
-            RemoveChunkFromStats(log_id, *it_to_prune);
-            log_buffer.erase(it_to_prune);
-            if (buffer_size >= bytes_to_free) {
-                return;
-            }
-            bytes_to_free -= buffer_size;
-        }
-    }
-}
-
-std::unique_ptr<FlushToState> SerializedLogBuffer::CreateFlushToState(uint64_t start,
-                                                                      LogMask log_mask) {
-    return std::make_unique<SerializedFlushToState>(start, log_mask);
-}
-
-bool SerializedLogBuffer::FlushTo(
-        LogWriter* writer, FlushToState& abstract_state,
-        const std::function<FilterResult(log_id_t log_id, pid_t pid, uint64_t sequence,
-                                         log_time realtime)>& filter) {
-    auto lock = std::unique_lock{lock_};
-
-    auto& state = reinterpret_cast<SerializedFlushToState&>(abstract_state);
-    state.InitializeLogs(logs_);
-
-    while (state.HasUnreadLogs()) {
-        MinHeapElement top = state.PopNextUnreadLog();
-        auto* entry = top.entry;
-        auto log_id = top.log_id;
-
-        if (entry->sequence() < state.start()) {
-            continue;
-        }
-        state.set_start(entry->sequence());
-
-        if (!writer->privileged() && entry->uid() != writer->uid()) {
-            continue;
-        }
-
-        if (filter) {
-            auto ret = filter(log_id, entry->pid(), entry->sequence(), entry->realtime());
-            if (ret == FilterResult::kSkip) {
-                continue;
-            }
-            if (ret == FilterResult::kStop) {
-                break;
-            }
-        }
-
-        // We copy the log entry such that we can flush it without the lock.  We never block pruning
-        // waiting for this Flush() to complete.
-        constexpr size_t kMaxEntrySize = sizeof(*entry) + LOGGER_ENTRY_MAX_PAYLOAD + 1;
-        unsigned char entry_copy[kMaxEntrySize] __attribute__((uninitialized));
-        CHECK_LT(entry->msg_len(), LOGGER_ENTRY_MAX_PAYLOAD + 1);
-        memcpy(entry_copy, entry, sizeof(*entry) + entry->msg_len());
-        lock.unlock();
-
-        if (!reinterpret_cast<SerializedLogEntry*>(entry_copy)->Flush(writer, log_id)) {
-            return false;
-        }
-
-        lock.lock();
-    }
-
-    state.set_start(state.start() + 1);
-    return true;
-}
-
-bool SerializedLogBuffer::Clear(log_id_t id, uid_t uid) {
-    auto lock = std::lock_guard{lock_};
-    Prune(id, ULONG_MAX, uid);
-
-    // Clearing SerializedLogBuffer never waits for readers and therefore is always successful.
-    return true;
-}
-
-size_t SerializedLogBuffer::GetSizeUsed(log_id_t id) {
-    size_t total_size = 0;
-    for (const auto& chunk : logs_[id]) {
-        total_size += chunk.PruneSize();
-    }
-    return total_size;
-}
-
-size_t SerializedLogBuffer::GetSize(log_id_t id) {
-    auto lock = std::lock_guard{lock_};
-    return max_size_[id];
-}
-
-// New SerializedLogChunk objects will be allocated according to the new size, but older one are
-// unchanged.  MaybePrune() is called on the log buffer to reduce it to an appropriate size if the
-// new size is lower.
-bool SerializedLogBuffer::SetSize(log_id_t id, size_t size) {
-    // Reasonable limits ...
-    if (!IsValidBufferSize(size)) {
-        return false;
-    }
-
-    auto lock = std::lock_guard{lock_};
-    max_size_[id] = size;
-
-    MaybePrune(id);
-
-    return true;
-}
diff --git a/logd/SerializedLogBuffer.h b/logd/SerializedLogBuffer.h
deleted file mode 100644
index 294cfe6..0000000
--- a/logd/SerializedLogBuffer.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2020 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 <atomic>
-#include <bitset>
-#include <list>
-#include <mutex>
-#include <queue>
-#include <thread>
-#include <vector>
-
-#include <android-base/thread_annotations.h>
-
-#include "LogBuffer.h"
-#include "LogReaderList.h"
-#include "LogStatistics.h"
-#include "LogTags.h"
-#include "SerializedLogChunk.h"
-#include "SerializedLogEntry.h"
-#include "rwlock.h"
-
-class SerializedLogBuffer final : public LogBuffer {
-  public:
-    SerializedLogBuffer(LogReaderList* reader_list, LogTags* tags, LogStatistics* stats);
-    void Init() override;
-
-    int Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid, const char* msg,
-            uint16_t len) override;
-    std::unique_ptr<FlushToState> CreateFlushToState(uint64_t start, LogMask log_mask) override;
-    bool FlushTo(LogWriter* writer, FlushToState& state,
-                 const std::function<FilterResult(log_id_t log_id, pid_t pid, uint64_t sequence,
-                                                  log_time realtime)>& filter) override;
-
-    bool Clear(log_id_t id, uid_t uid) override;
-    size_t GetSize(log_id_t id) override;
-    bool SetSize(log_id_t id, size_t size) override;
-
-    uint64_t sequence() const override { return sequence_.load(std::memory_order_relaxed); }
-
-  private:
-    bool ShouldLog(log_id_t log_id, const char* msg, uint16_t len);
-    void MaybePrune(log_id_t log_id) REQUIRES(lock_);
-    void Prune(log_id_t log_id, size_t bytes_to_free, uid_t uid) REQUIRES(lock_);
-    void NotifyReadersOfPrune(log_id_t log_id, const std::list<SerializedLogChunk>::iterator& chunk)
-            REQUIRES(reader_list_->reader_threads_lock());
-    void RemoveChunkFromStats(log_id_t log_id, SerializedLogChunk& chunk);
-    size_t GetSizeUsed(log_id_t id) REQUIRES(lock_);
-
-    LogReaderList* reader_list_;
-    LogTags* tags_;
-    LogStatistics* stats_;
-
-    size_t max_size_[LOG_ID_MAX] GUARDED_BY(lock_) = {};
-    std::list<SerializedLogChunk> logs_[LOG_ID_MAX] GUARDED_BY(lock_);
-    RwLock lock_;
-
-    std::atomic<uint64_t> sequence_ = 1;
-};
diff --git a/logd/SerializedLogChunk.cpp b/logd/SerializedLogChunk.cpp
deleted file mode 100644
index de641d6..0000000
--- a/logd/SerializedLogChunk.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2020 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 "SerializedLogChunk.h"
-
-#include <android-base/logging.h>
-
-#include "CompressionEngine.h"
-
-SerializedLogChunk::~SerializedLogChunk() {
-    CHECK_EQ(reader_ref_count_, 0U);
-}
-
-void SerializedLogChunk::Compress() {
-    if (compressed_log_.size() == 0) {
-        CompressionEngine::GetInstance().Compress(contents_, write_offset_, compressed_log_);
-        LOG(INFO) << "Compressed Log, buffer max size: " << contents_.size()
-                  << " size used: " << write_offset_
-                  << " compressed size: " << compressed_log_.size();
-    }
-}
-
-// TODO: Develop a better reference counting strategy to guard against the case where the writer is
-// much faster than the reader, and we needlessly compess / decompress the logs.
-void SerializedLogChunk::IncReaderRefCount() {
-    if (++reader_ref_count_ != 1 || writer_active_) {
-        return;
-    }
-    contents_.Resize(write_offset_);
-    CompressionEngine::GetInstance().Decompress(compressed_log_, contents_);
-}
-
-void SerializedLogChunk::DecReaderRefCount() {
-    CHECK_NE(reader_ref_count_, 0U);
-    if (--reader_ref_count_ != 0) {
-        return;
-    }
-    if (!writer_active_) {
-        contents_.Resize(0);
-    }
-}
-
-bool SerializedLogChunk::ClearUidLogs(uid_t uid, log_id_t log_id, LogStatistics* stats) {
-    CHECK_EQ(reader_ref_count_, 0U);
-    if (write_offset_ == 0) {
-        return true;
-    }
-
-    IncReaderRefCount();
-
-    int read_offset = 0;
-    int new_write_offset = 0;
-    while (read_offset < write_offset_) {
-        const auto* entry = log_entry(read_offset);
-        if (entry->uid() == uid) {
-            read_offset += entry->total_len();
-            if (stats != nullptr) {
-                stats->Subtract(entry->ToLogStatisticsElement(log_id));
-            }
-            continue;
-        }
-        size_t entry_total_len = entry->total_len();
-        if (read_offset != new_write_offset) {
-            memmove(contents_.data() + new_write_offset, contents_.data() + read_offset,
-                    entry_total_len);
-        }
-        read_offset += entry_total_len;
-        new_write_offset += entry_total_len;
-    }
-
-    if (new_write_offset == 0) {
-        DecReaderRefCount();
-        return true;
-    }
-
-    // Clear the old compressed logs and set write_offset_ appropriately to compress the new
-    // partially cleared log.
-    if (new_write_offset != write_offset_) {
-        compressed_log_.Resize(0);
-        write_offset_ = new_write_offset;
-        Compress();
-    }
-
-    DecReaderRefCount();
-
-    return false;
-}
-
-bool SerializedLogChunk::CanLog(size_t len) {
-    return write_offset_ + len <= contents_.size();
-}
-
-SerializedLogEntry* SerializedLogChunk::Log(uint64_t sequence, log_time realtime, uid_t uid,
-                                            pid_t pid, pid_t tid, const char* msg, uint16_t len) {
-    auto new_log_address = contents_.data() + write_offset_;
-    auto* entry = new (new_log_address) SerializedLogEntry(uid, pid, tid, sequence, realtime, len);
-    memcpy(entry->msg(), msg, len);
-    write_offset_ += entry->total_len();
-    highest_sequence_number_ = sequence;
-    return entry;
-}
\ No newline at end of file
diff --git a/logd/SerializedLogChunk.h b/logd/SerializedLogChunk.h
deleted file mode 100644
index 0991eac..0000000
--- a/logd/SerializedLogChunk.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2020 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 <sys/types.h>
-
-#include "LogWriter.h"
-#include "SerializedData.h"
-#include "SerializedLogEntry.h"
-
-class SerializedLogChunk {
-  public:
-    explicit SerializedLogChunk(size_t size) : contents_(size) {}
-    SerializedLogChunk(SerializedLogChunk&& other) noexcept = default;
-    ~SerializedLogChunk();
-
-    void Compress();
-    void IncReaderRefCount();
-    void DecReaderRefCount();
-
-    // Must have no readers referencing this.  Return true if there are no logs left in this chunk.
-    bool ClearUidLogs(uid_t uid, log_id_t log_id, LogStatistics* stats);
-
-    bool CanLog(size_t len);
-    SerializedLogEntry* Log(uint64_t sequence, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
-                            const char* msg, uint16_t len);
-
-    // If this buffer has been compressed, we only consider its compressed size when accounting for
-    // memory consumption for pruning.  This is since the uncompressed log is only by used by
-    // readers, and thus not a representation of how much these logs cost to keep in memory.
-    size_t PruneSize() const {
-        return sizeof(*this) + (compressed_log_.size() ?: contents_.size());
-    }
-
-    void FinishWriting() {
-        writer_active_ = false;
-        Compress();
-        if (reader_ref_count_ == 0) {
-            contents_.Resize(0);
-        }
-    }
-
-    const SerializedLogEntry* log_entry(int offset) const {
-        return reinterpret_cast<const SerializedLogEntry*>(data() + offset);
-    }
-    const uint8_t* data() const { return contents_.data(); }
-    int write_offset() const { return write_offset_; }
-    uint64_t highest_sequence_number() const { return highest_sequence_number_; }
-
-    // Exposed for testing
-    uint32_t reader_ref_count() const { return reader_ref_count_; }
-
-  private:
-    // The decompressed contents of this log buffer.  Deallocated when the ref_count reaches 0 and
-    // writer_active_ is false.
-    SerializedData contents_;
-    int write_offset_ = 0;
-    uint32_t reader_ref_count_ = 0;
-    bool writer_active_ = true;
-    uint64_t highest_sequence_number_ = 1;
-    SerializedData compressed_log_;
-};
diff --git a/logd/SerializedLogChunkTest.cpp b/logd/SerializedLogChunkTest.cpp
deleted file mode 100644
index f10b9c6..0000000
--- a/logd/SerializedLogChunkTest.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2020 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 "SerializedLogChunk.h"
-
-#include <limits>
-
-#include <android-base/stringprintf.h>
-#include <android/log.h>
-#include <gtest/gtest.h>
-
-using android::base::StringPrintf;
-
-TEST(SerializedLogChunk, smoke) {
-    size_t chunk_size = 10 * 4096;
-    auto chunk = SerializedLogChunk{chunk_size};
-    EXPECT_EQ(chunk_size + sizeof(SerializedLogChunk), chunk.PruneSize());
-
-    static const char log_message[] = "log message";
-    size_t expected_total_len = sizeof(SerializedLogEntry) + sizeof(log_message);
-    ASSERT_TRUE(chunk.CanLog(expected_total_len));
-    EXPECT_TRUE(chunk.CanLog(chunk_size));
-    EXPECT_FALSE(chunk.CanLog(chunk_size + 1));
-
-    log_time time(CLOCK_REALTIME);
-    auto* entry = chunk.Log(1234, time, 0, 1, 2, log_message, sizeof(log_message));
-    ASSERT_NE(nullptr, entry);
-
-    EXPECT_EQ(1234U, entry->sequence());
-    EXPECT_EQ(time, entry->realtime());
-    EXPECT_EQ(0U, entry->uid());
-    EXPECT_EQ(1, entry->pid());
-    EXPECT_EQ(2, entry->tid());
-    EXPECT_EQ(sizeof(log_message), entry->msg_len());
-    EXPECT_STREQ(log_message, entry->msg());
-    EXPECT_EQ(expected_total_len, entry->total_len());
-
-    EXPECT_FALSE(chunk.CanLog(chunk_size));
-    EXPECT_EQ(static_cast<int>(expected_total_len), chunk.write_offset());
-    EXPECT_EQ(1234U, chunk.highest_sequence_number());
-}
-
-TEST(SerializedLogChunk, fill_log_exactly) {
-    static const char log_message[] = "this is a log message";
-    size_t individual_message_size = sizeof(SerializedLogEntry) + sizeof(log_message);
-    size_t chunk_size = individual_message_size * 3;
-    auto chunk = SerializedLogChunk{chunk_size};
-    EXPECT_EQ(chunk_size + sizeof(SerializedLogChunk), chunk.PruneSize());
-
-    ASSERT_TRUE(chunk.CanLog(individual_message_size));
-    EXPECT_NE(nullptr, chunk.Log(1, log_time(), 1000, 1, 1, log_message, sizeof(log_message)));
-
-    ASSERT_TRUE(chunk.CanLog(individual_message_size));
-    EXPECT_NE(nullptr, chunk.Log(2, log_time(), 1000, 2, 1, log_message, sizeof(log_message)));
-
-    ASSERT_TRUE(chunk.CanLog(individual_message_size));
-    EXPECT_NE(nullptr, chunk.Log(3, log_time(), 1000, 3, 1, log_message, sizeof(log_message)));
-
-    EXPECT_FALSE(chunk.CanLog(1));
-}
-
-TEST(SerializedLogChunk, three_logs) {
-    size_t chunk_size = 10 * 4096;
-    auto chunk = SerializedLogChunk{chunk_size};
-
-    chunk.Log(2, log_time(0x1234, 0x5678), 0x111, 0x222, 0x333, "initial message",
-              strlen("initial message"));
-    chunk.Log(3, log_time(0x2345, 0x6789), 0x444, 0x555, 0x666, "second message",
-              strlen("second message"));
-    auto uint64_t_max = std::numeric_limits<uint64_t>::max();
-    auto uint32_t_max = std::numeric_limits<uint32_t>::max();
-    chunk.Log(uint64_t_max, log_time(uint32_t_max, uint32_t_max), uint32_t_max, uint32_t_max,
-              uint32_t_max, "last message", strlen("last message"));
-
-    static const char expected_buffer_data[] =
-            "\x11\x01\x00\x00\x22\x02\x00\x00\x33\x03\x00\x00"  // UID PID TID
-            "\x02\x00\x00\x00\x00\x00\x00\x00"                  // Sequence
-            "\x34\x12\x00\x00\x78\x56\x00\x00"                  // Timestamp
-            "\x0F\x00initial message"                           // msg_len + message
-            "\x44\x04\x00\x00\x55\x05\x00\x00\x66\x06\x00\x00"  // UID PID TID
-            "\x03\x00\x00\x00\x00\x00\x00\x00"                  // Sequence
-            "\x45\x23\x00\x00\x89\x67\x00\x00"                  // Timestamp
-            "\x0E\x00second message"                            // msg_len + message
-            "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"  // UID PID TID
-            "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"                  // Sequence
-            "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"                  // Timestamp
-            "\x0C\x00last message";                             // msg_len + message
-
-    for (size_t i = 0; i < chunk_size; ++i) {
-        if (i < sizeof(expected_buffer_data)) {
-            EXPECT_EQ(static_cast<uint8_t>(expected_buffer_data[i]), chunk.data()[i])
-                    << "position: " << i;
-        } else {
-            EXPECT_EQ(0, chunk.data()[i]) << "position: " << i;
-        }
-    }
-}
-
-// Check that the CHECK() in DecReaderRefCount() if the ref count goes bad is caught.
-TEST(SerializedLogChunk, catch_DecCompressedRef_CHECK) {
-    size_t chunk_size = 10 * 4096;
-    auto chunk = SerializedLogChunk{chunk_size};
-    EXPECT_DEATH({ chunk.DecReaderRefCount(); }, "");
-}
-
-// Check that the CHECK() in ClearUidLogs() if the ref count is greater than 0 is caught.
-TEST(SerializedLogChunk, catch_ClearUidLogs_CHECK) {
-    size_t chunk_size = 10 * 4096;
-    auto chunk = SerializedLogChunk{chunk_size};
-    chunk.IncReaderRefCount();
-    EXPECT_DEATH({ chunk.ClearUidLogs(1000, LOG_ID_MAIN, nullptr); }, "");
-    chunk.DecReaderRefCount();
-}
-
-class UidClearTest : public testing::TestWithParam<bool> {
-  protected:
-    template <typename Write, typename Check>
-    void Test(const Write& write, const Check& check, bool expected_result) {
-        write(chunk_);
-
-        bool finish_writing = GetParam();
-        if (finish_writing) {
-            chunk_.FinishWriting();
-        }
-        EXPECT_EQ(expected_result, chunk_.ClearUidLogs(kUidToClear, LOG_ID_MAIN, nullptr));
-        if (finish_writing) {
-            chunk_.IncReaderRefCount();
-        }
-
-        check(chunk_);
-
-        if (finish_writing) {
-            chunk_.DecReaderRefCount();
-        }
-    }
-
-    static constexpr size_t kChunkSize = 10 * 4096;
-    static constexpr uid_t kUidToClear = 1000;
-    static constexpr uid_t kOtherUid = 1234;
-
-    SerializedLogChunk chunk_{kChunkSize};
-};
-
-// Test that ClearUidLogs() is a no-op if there are no logs of that UID in the buffer.
-TEST_P(UidClearTest, no_logs_in_chunk) {
-    auto write = [](SerializedLogChunk&) {};
-    auto check = [](SerializedLogChunk&) {};
-
-    Test(write, check, true);
-}
-
-// Test that ClearUidLogs() is a no-op if there are no logs of that UID in the buffer.
-TEST_P(UidClearTest, no_logs_from_uid) {
-    static const char msg[] = "this is a log message";
-    auto write = [](SerializedLogChunk& chunk) {
-        chunk.Log(1, log_time(), kOtherUid, 1, 2, msg, sizeof(msg));
-    };
-
-    auto check = [](SerializedLogChunk& chunk) {
-        auto* entry = chunk.log_entry(0);
-        EXPECT_STREQ(msg, entry->msg());
-    };
-
-    Test(write, check, false);
-}
-
-// Test that ClearUidLogs() returns true if all logs in a given buffer correspond to the given UID.
-TEST_P(UidClearTest, all_single) {
-    static const char msg[] = "this is a log message";
-    auto write = [](SerializedLogChunk& chunk) {
-        chunk.Log(1, log_time(), kUidToClear, 1, 2, msg, sizeof(msg));
-    };
-    auto check = [](SerializedLogChunk&) {};
-
-    Test(write, check, true);
-}
-
-// Test that ClearUidLogs() returns true if all logs in a given buffer correspond to the given UID.
-TEST_P(UidClearTest, all_multiple) {
-    static const char msg[] = "this is a log message";
-    auto write = [](SerializedLogChunk& chunk) {
-        chunk.Log(2, log_time(), kUidToClear, 1, 2, msg, sizeof(msg));
-        chunk.Log(3, log_time(), kUidToClear, 1, 2, msg, sizeof(msg));
-        chunk.Log(4, log_time(), kUidToClear, 1, 2, msg, sizeof(msg));
-    };
-    auto check = [](SerializedLogChunk&) {};
-
-    Test(write, check, true);
-}
-
-static std::string MakePrintable(const uint8_t* in, size_t length) {
-    std::string result;
-    for (size_t i = 0; i < length; ++i) {
-        uint8_t c = in[i];
-        if (isprint(c)) {
-            result.push_back(c);
-        } else {
-            result.append(StringPrintf("\\%02x", static_cast<int>(c) & 0xFF));
-        }
-    }
-    return result;
-}
-
-// This test clears UID logs at the beginning and end of the buffer, as well as two back to back
-// logs in the interior.
-TEST_P(UidClearTest, clear_beginning_and_end) {
-    static const char msg1[] = "this is a log message";
-    static const char msg2[] = "non-cleared message";
-    static const char msg3[] = "back to back cleared messages";
-    static const char msg4[] = "second in a row gone";
-    static const char msg5[] = "but we save this one";
-    static const char msg6[] = "and this 1!";
-    static const char msg7[] = "the last one goes too";
-    auto write = [](SerializedLogChunk& chunk) {
-        ASSERT_NE(nullptr, chunk.Log(1, log_time(), kUidToClear, 1, 2, msg1, sizeof(msg1)));
-        ASSERT_NE(nullptr, chunk.Log(2, log_time(), kOtherUid, 1, 2, msg2, sizeof(msg2)));
-        ASSERT_NE(nullptr, chunk.Log(3, log_time(), kUidToClear, 1, 2, msg3, sizeof(msg3)));
-        ASSERT_NE(nullptr, chunk.Log(4, log_time(), kUidToClear, 1, 2, msg4, sizeof(msg4)));
-        ASSERT_NE(nullptr, chunk.Log(5, log_time(), kOtherUid, 1, 2, msg5, sizeof(msg5)));
-        ASSERT_NE(nullptr, chunk.Log(6, log_time(), kOtherUid, 1, 2, msg6, sizeof(msg6)));
-        ASSERT_NE(nullptr, chunk.Log(7, log_time(), kUidToClear, 1, 2, msg7, sizeof(msg7)));
-    };
-
-    auto check = [](SerializedLogChunk& chunk) {
-        size_t read_offset = 0;
-        auto* entry = chunk.log_entry(read_offset);
-        EXPECT_STREQ(msg2, entry->msg());
-        read_offset += entry->total_len();
-
-        entry = chunk.log_entry(read_offset);
-        EXPECT_STREQ(msg5, entry->msg());
-        read_offset += entry->total_len();
-
-        entry = chunk.log_entry(read_offset);
-        EXPECT_STREQ(msg6, entry->msg()) << MakePrintable(chunk.data(), chunk.write_offset());
-        read_offset += entry->total_len();
-
-        EXPECT_EQ(static_cast<int>(read_offset), chunk.write_offset());
-    };
-    Test(write, check, false);
-}
-
-// This tests the opposite case of beginning_and_end, in which we don't clear the beginning or end
-// logs.  There is a single log pruned in the middle instead of back to back logs.
-TEST_P(UidClearTest, save_beginning_and_end) {
-    static const char msg1[] = "saved first message";
-    static const char msg2[] = "cleared interior message";
-    static const char msg3[] = "last message stays";
-    auto write = [](SerializedLogChunk& chunk) {
-        ASSERT_NE(nullptr, chunk.Log(1, log_time(), kOtherUid, 1, 2, msg1, sizeof(msg1)));
-        ASSERT_NE(nullptr, chunk.Log(2, log_time(), kUidToClear, 1, 2, msg2, sizeof(msg2)));
-        ASSERT_NE(nullptr, chunk.Log(3, log_time(), kOtherUid, 1, 2, msg3, sizeof(msg3)));
-    };
-
-    auto check = [](SerializedLogChunk& chunk) {
-        size_t read_offset = 0;
-        auto* entry = chunk.log_entry(read_offset);
-        EXPECT_STREQ(msg1, entry->msg());
-        read_offset += entry->total_len();
-
-        entry = chunk.log_entry(read_offset);
-        EXPECT_STREQ(msg3, entry->msg());
-        read_offset += entry->total_len();
-
-        EXPECT_EQ(static_cast<int>(read_offset), chunk.write_offset());
-    };
-    Test(write, check, false);
-}
-
-INSTANTIATE_TEST_CASE_P(UidClearTests, UidClearTest, testing::Values(true, false));
diff --git a/logd/SerializedLogEntry.h b/logd/SerializedLogEntry.h
deleted file mode 100644
index 2f2c244..0000000
--- a/logd/SerializedLogEntry.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2020 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 <stdint.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#include <log/log.h>
-#include <log/log_read.h>
-
-#include "LogStatistics.h"
-#include "LogWriter.h"
-
-// These structs are packed into a single chunk of memory for each log type within a
-// SerializedLogChunk object.  Their message is contained immediately at the end of the struct.  The
-// address of the next log in the buffer is *this + sizeof(SerializedLogEntry) + msg_len_.  If that
-// value would overflow the chunk of memory associated with the SerializedLogChunk object, then a
-// new SerializedLogChunk must be allocated to contain the next SerializedLogEntry.
-class __attribute__((packed)) SerializedLogEntry {
-  public:
-    SerializedLogEntry(uid_t uid, pid_t pid, pid_t tid, uint64_t sequence, log_time realtime,
-                       uint16_t len)
-        : uid_(uid),
-          pid_(pid),
-          tid_(tid),
-          sequence_(sequence),
-          realtime_(realtime),
-          msg_len_(len) {}
-    SerializedLogEntry(const SerializedLogEntry& elem) = delete;
-    SerializedLogEntry& operator=(const SerializedLogEntry& elem) = delete;
-    ~SerializedLogEntry() {
-        // Never place anything in this destructor.  This class is in place constructed and never
-        // destructed.
-    }
-
-    LogStatisticsElement ToLogStatisticsElement(log_id_t log_id) const {
-        return LogStatisticsElement{
-                .uid = uid(),
-                .pid = pid(),
-                .tid = tid(),
-                .tag = IsBinary(log_id) ? MsgToTag(msg(), msg_len()) : 0,
-                .realtime = realtime(),
-                .msg = msg(),
-                .msg_len = msg_len(),
-                .dropped_count = 0,
-                .log_id = log_id,
-                .total_len = total_len(),
-        };
-    }
-
-    bool Flush(LogWriter* writer, log_id_t log_id) const {
-        struct logger_entry entry = {};
-
-        entry.hdr_size = sizeof(struct logger_entry);
-        entry.lid = log_id;
-        entry.pid = pid();
-        entry.tid = tid();
-        entry.uid = uid();
-        entry.sec = realtime().tv_sec;
-        entry.nsec = realtime().tv_nsec;
-        entry.len = msg_len();
-
-        return writer->Write(entry, msg());
-    }
-
-    uid_t uid() const { return uid_; }
-    pid_t pid() const { return pid_; }
-    pid_t tid() const { return tid_; }
-    uint16_t msg_len() const { return msg_len_; }
-    uint64_t sequence() const { return sequence_; }
-    log_time realtime() const { return realtime_; }
-
-    char* msg() { return reinterpret_cast<char*>(this) + sizeof(*this); }
-    const char* msg() const { return reinterpret_cast<const char*>(this) + sizeof(*this); }
-    uint16_t total_len() const { return sizeof(*this) + msg_len_; }
-
-  private:
-    const uint32_t uid_;
-    const uint32_t pid_;
-    const uint32_t tid_;
-    const uint64_t sequence_;
-    const log_time realtime_;
-    const uint16_t msg_len_;
-};
diff --git a/logd/SimpleLogBuffer.cpp b/logd/SimpleLogBuffer.cpp
deleted file mode 100644
index b00dd25..0000000
--- a/logd/SimpleLogBuffer.cpp
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright (C) 2020 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 "SimpleLogBuffer.h"
-
-#include <android-base/logging.h>
-
-#include "LogBufferElement.h"
-#include "LogSize.h"
-
-SimpleLogBuffer::SimpleLogBuffer(LogReaderList* reader_list, LogTags* tags, LogStatistics* stats)
-    : reader_list_(reader_list), tags_(tags), stats_(stats) {
-    Init();
-}
-
-SimpleLogBuffer::~SimpleLogBuffer() {}
-
-void SimpleLogBuffer::Init() {
-    log_id_for_each(i) {
-        if (!SetSize(i, GetBufferSizeFromProperties(i))) {
-            SetSize(i, kLogBufferMinSize);
-        }
-    }
-
-    // Release any sleeping reader threads to dump their current content.
-    auto reader_threads_lock = std::lock_guard{reader_list_->reader_threads_lock()};
-    for (const auto& reader_thread : reader_list_->reader_threads()) {
-        reader_thread->triggerReader_Locked();
-    }
-}
-
-std::list<LogBufferElement>::iterator SimpleLogBuffer::GetOldest(log_id_t log_id) {
-    auto it = logs().begin();
-    if (oldest_[log_id]) {
-        it = *oldest_[log_id];
-    }
-    while (it != logs().end() && it->log_id() != log_id) {
-        it++;
-    }
-    if (it != logs().end()) {
-        oldest_[log_id] = it;
-    }
-    return it;
-}
-
-bool SimpleLogBuffer::ShouldLog(log_id_t log_id, const char* msg, uint16_t len) {
-    if (log_id == LOG_ID_SECURITY) {
-        return true;
-    }
-
-    int prio = ANDROID_LOG_INFO;
-    const char* tag = nullptr;
-    size_t tag_len = 0;
-    if (IsBinary(log_id)) {
-        int32_t numeric_tag = MsgToTag(msg, len);
-        tag = tags_->tagToName(numeric_tag);
-        if (tag) {
-            tag_len = strlen(tag);
-        }
-    } else {
-        prio = *msg;
-        tag = msg + 1;
-        tag_len = strnlen(tag, len - 1);
-    }
-    return __android_log_is_loggable_len(prio, tag, tag_len, ANDROID_LOG_VERBOSE);
-}
-
-int SimpleLogBuffer::Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
-                         const char* msg, uint16_t len) {
-    if (log_id >= LOG_ID_MAX) {
-        return -EINVAL;
-    }
-
-    if (!ShouldLog(log_id, msg, len)) {
-        // Log traffic received to total
-        stats_->AddTotal(log_id, len);
-        return -EACCES;
-    }
-
-    // Slip the time by 1 nsec if the incoming lands on xxxxxx000 ns.
-    // This prevents any chance that an outside source can request an
-    // exact entry with time specified in ms or us precision.
-    if ((realtime.tv_nsec % 1000) == 0) ++realtime.tv_nsec;
-
-    auto lock = std::lock_guard{lock_};
-    auto sequence = sequence_.fetch_add(1, std::memory_order_relaxed);
-    LogInternal(LogBufferElement(log_id, realtime, uid, pid, tid, sequence, msg, len));
-    return len;
-}
-
-void SimpleLogBuffer::LogInternal(LogBufferElement&& elem) {
-    log_id_t log_id = elem.log_id();
-
-    logs_.emplace_back(std::move(elem));
-    stats_->Add(logs_.back().ToLogStatisticsElement());
-    MaybePrune(log_id);
-    reader_list_->NotifyNewLog(1 << log_id);
-}
-
-// These extra parameters are only required for chatty, but since they're a no-op for
-// SimpleLogBuffer, it's easier to include them here, then to duplicate FlushTo() for
-// ChattyLogBuffer.
-class ChattyFlushToState : public FlushToState {
-  public:
-    ChattyFlushToState(uint64_t start, LogMask log_mask) : FlushToState(start, log_mask) {}
-
-    pid_t* last_tid() { return last_tid_; }
-
-    bool drop_chatty_messages() const { return drop_chatty_messages_; }
-    void set_drop_chatty_messages(bool value) { drop_chatty_messages_ = value; }
-
-  private:
-    pid_t last_tid_[LOG_ID_MAX] = {};
-    bool drop_chatty_messages_ = true;
-};
-
-std::unique_ptr<FlushToState> SimpleLogBuffer::CreateFlushToState(uint64_t start,
-                                                                  LogMask log_mask) {
-    return std::make_unique<ChattyFlushToState>(start, log_mask);
-}
-
-bool SimpleLogBuffer::FlushTo(
-        LogWriter* writer, FlushToState& abstract_state,
-        const std::function<FilterResult(log_id_t log_id, pid_t pid, uint64_t sequence,
-                                         log_time realtime)>& filter) {
-    auto shared_lock = SharedLock{lock_};
-
-    auto& state = reinterpret_cast<ChattyFlushToState&>(abstract_state);
-
-    std::list<LogBufferElement>::iterator it;
-    if (state.start() <= 1) {
-        // client wants to start from the beginning
-        it = logs_.begin();
-    } else {
-        // Client wants to start from some specified time. Chances are
-        // we are better off starting from the end of the time sorted list.
-        for (it = logs_.end(); it != logs_.begin();
-             /* do nothing */) {
-            --it;
-            if (it->sequence() == state.start()) {
-                break;
-            } else if (it->sequence() < state.start()) {
-                it++;
-                break;
-            }
-        }
-    }
-
-    for (; it != logs_.end(); ++it) {
-        LogBufferElement& element = *it;
-
-        state.set_start(element.sequence());
-
-        if (!writer->privileged() && element.uid() != writer->uid()) {
-            continue;
-        }
-
-        if (((1 << element.log_id()) & state.log_mask()) == 0) {
-            continue;
-        }
-
-        if (filter) {
-            FilterResult ret =
-                    filter(element.log_id(), element.pid(), element.sequence(), element.realtime());
-            if (ret == FilterResult::kSkip) {
-                continue;
-            }
-            if (ret == FilterResult::kStop) {
-                break;
-            }
-        }
-
-        // drop_chatty_messages is initialized to true, so if the first message that we attempt to
-        // flush is a chatty message, we drop it.  Once we see a non-chatty message it gets set to
-        // false to let further chatty messages be printed.
-        if (state.drop_chatty_messages()) {
-            if (element.dropped_count() != 0) {
-                continue;
-            }
-            state.set_drop_chatty_messages(false);
-        }
-
-        bool same_tid = state.last_tid()[element.log_id()] == element.tid();
-        // Dropped (chatty) immediately following a valid log from the same source in the same log
-        // buffer indicates we have a multiple identical squash.  chatty that differs source is due
-        // to spam filter.  chatty to chatty of different source is also due to spam filter.
-        state.last_tid()[element.log_id()] =
-                (element.dropped_count() && !same_tid) ? 0 : element.tid();
-
-        shared_lock.unlock();
-        // We never prune logs equal to or newer than any LogReaderThreads' `start` value, so the
-        // `element` pointer is safe here without the lock
-        if (!element.FlushTo(writer, stats_, same_tid)) {
-            return false;
-        }
-        shared_lock.lock_shared();
-    }
-
-    state.set_start(state.start() + 1);
-    return true;
-}
-
-bool SimpleLogBuffer::Clear(log_id_t id, uid_t uid) {
-    // Try three times to clear, then disconnect the readers and try one final time.
-    for (int retry = 0; retry < 3; ++retry) {
-        {
-            auto lock = std::lock_guard{lock_};
-            if (Prune(id, ULONG_MAX, uid)) {
-                return true;
-            }
-        }
-        sleep(1);
-    }
-    // Check if it is still busy after the sleep, we try to prune one entry, not another clear run,
-    // so we are looking for the quick side effect of the return value to tell us if we have a
-    // _blocked_ reader.
-    bool busy = false;
-    {
-        auto lock = std::lock_guard{lock_};
-        busy = !Prune(id, 1, uid);
-    }
-    // It is still busy, disconnect all readers.
-    if (busy) {
-        auto reader_threads_lock = std::lock_guard{reader_list_->reader_threads_lock()};
-        for (const auto& reader_thread : reader_list_->reader_threads()) {
-            if (reader_thread->IsWatching(id)) {
-                LOG(WARNING) << "Kicking blocked reader, " << reader_thread->name()
-                             << ", from LogBuffer::clear()";
-                reader_thread->release_Locked();
-            }
-        }
-    }
-    auto lock = std::lock_guard{lock_};
-    return Prune(id, ULONG_MAX, uid);
-}
-
-// get the total space allocated to "id"
-size_t SimpleLogBuffer::GetSize(log_id_t id) {
-    auto lock = SharedLock{lock_};
-    size_t retval = max_size_[id];
-    return retval;
-}
-
-// set the total space allocated to "id"
-bool SimpleLogBuffer::SetSize(log_id_t id, size_t size) {
-    // Reasonable limits ...
-    if (!IsValidBufferSize(size)) {
-        return false;
-    }
-
-    auto lock = std::lock_guard{lock_};
-    max_size_[id] = size;
-    return true;
-}
-
-void SimpleLogBuffer::MaybePrune(log_id_t id) {
-    unsigned long prune_rows;
-    if (stats_->ShouldPrune(id, max_size_[id], &prune_rows)) {
-        Prune(id, prune_rows, 0);
-    }
-}
-
-bool SimpleLogBuffer::Prune(log_id_t id, unsigned long prune_rows, uid_t caller_uid) {
-    auto reader_threads_lock = std::lock_guard{reader_list_->reader_threads_lock()};
-
-    // Don't prune logs that are newer than the point at which any reader threads are reading from.
-    LogReaderThread* oldest = nullptr;
-    for (const auto& reader_thread : reader_list_->reader_threads()) {
-        if (!reader_thread->IsWatching(id)) {
-            continue;
-        }
-        if (!oldest || oldest->start() > reader_thread->start() ||
-            (oldest->start() == reader_thread->start() &&
-             reader_thread->deadline().time_since_epoch().count() != 0)) {
-            oldest = reader_thread.get();
-        }
-    }
-
-    auto it = GetOldest(id);
-
-    while (it != logs_.end()) {
-        LogBufferElement& element = *it;
-
-        if (element.log_id() != id) {
-            ++it;
-            continue;
-        }
-
-        if (caller_uid != 0 && element.uid() != caller_uid) {
-            ++it;
-            continue;
-        }
-
-        if (oldest && oldest->start() <= element.sequence()) {
-            KickReader(oldest, id, prune_rows);
-            return false;
-        }
-
-        stats_->Subtract(element.ToLogStatisticsElement());
-        it = Erase(it);
-        if (--prune_rows == 0) {
-            return true;
-        }
-    }
-    return true;
-}
-
-std::list<LogBufferElement>::iterator SimpleLogBuffer::Erase(
-        std::list<LogBufferElement>::iterator it) {
-    bool oldest_is_it[LOG_ID_MAX];
-    log_id_for_each(i) { oldest_is_it[i] = oldest_[i] && it == *oldest_[i]; }
-
-    it = logs_.erase(it);
-
-    log_id_for_each(i) {
-        if (oldest_is_it[i]) {
-            if (__predict_false(it == logs().end())) {
-                oldest_[i] = std::nullopt;
-            } else {
-                oldest_[i] = it;  // Store the next iterator even if it does not correspond to
-                                  // the same log_id, as a starting point for GetOldest().
-            }
-        }
-    }
-
-    return it;
-}
-
-// If the selected reader is blocking our pruning progress, decide on
-// what kind of mitigation is necessary to unblock the situation.
-void SimpleLogBuffer::KickReader(LogReaderThread* reader, log_id_t id, unsigned long prune_rows) {
-    if (stats_->Sizes(id) > (2 * max_size_[id])) {  // +100%
-        // A misbehaving or slow reader has its connection
-        // dropped if we hit too much memory pressure.
-        LOG(WARNING) << "Kicking blocked reader, " << reader->name()
-                     << ", from LogBuffer::kickMe()";
-        reader->release_Locked();
-    } else if (reader->deadline().time_since_epoch().count() != 0) {
-        // Allow a blocked WRAP deadline reader to trigger and start reporting the log data.
-        reader->triggerReader_Locked();
-    } else {
-        // tell slow reader to skip entries to catch up
-        LOG(WARNING) << "Skipping " << prune_rows << " entries from slow reader, " << reader->name()
-                     << ", from LogBuffer::kickMe()";
-        reader->triggerSkip_Locked(id, prune_rows);
-    }
-}
diff --git a/logd/SimpleLogBuffer.h b/logd/SimpleLogBuffer.h
deleted file mode 100644
index 8e5b50e..0000000
--- a/logd/SimpleLogBuffer.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2020 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 <atomic>
-#include <list>
-#include <mutex>
-
-#include "LogBuffer.h"
-#include "LogBufferElement.h"
-#include "LogReaderList.h"
-#include "LogStatistics.h"
-#include "LogTags.h"
-#include "rwlock.h"
-
-class SimpleLogBuffer : public LogBuffer {
-  public:
-    SimpleLogBuffer(LogReaderList* reader_list, LogTags* tags, LogStatistics* stats);
-    ~SimpleLogBuffer();
-    void Init() override final;
-
-    int Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid, const char* msg,
-            uint16_t len) override;
-    std::unique_ptr<FlushToState> CreateFlushToState(uint64_t start, LogMask log_mask) override;
-    bool FlushTo(LogWriter* writer, FlushToState& state,
-                 const std::function<FilterResult(log_id_t log_id, pid_t pid, uint64_t sequence,
-                                                  log_time realtime)>& filter) override;
-
-    bool Clear(log_id_t id, uid_t uid) override;
-    size_t GetSize(log_id_t id) override;
-    bool SetSize(log_id_t id, size_t size) override final;
-
-    uint64_t sequence() const override { return sequence_.load(std::memory_order_relaxed); }
-
-  protected:
-    virtual bool Prune(log_id_t id, unsigned long prune_rows, uid_t uid) REQUIRES(lock_);
-    virtual void LogInternal(LogBufferElement&& elem) REQUIRES(lock_);
-
-    // Returns an iterator to the oldest element for a given log type, or logs_.end() if
-    // there are no logs for the given log type. Requires logs_lock_ to be held.
-    std::list<LogBufferElement>::iterator GetOldest(log_id_t log_id) REQUIRES(lock_);
-    std::list<LogBufferElement>::iterator Erase(std::list<LogBufferElement>::iterator it)
-            REQUIRES(lock_);
-    void KickReader(LogReaderThread* reader, log_id_t id, unsigned long prune_rows)
-            REQUIRES_SHARED(lock_);
-
-    LogStatistics* stats() { return stats_; }
-    LogReaderList* reader_list() { return reader_list_; }
-    size_t max_size(log_id_t id) REQUIRES_SHARED(lock_) { return max_size_[id]; }
-    std::list<LogBufferElement>& logs() { return logs_; }
-
-    RwLock lock_;
-
-  private:
-    bool ShouldLog(log_id_t log_id, const char* msg, uint16_t len);
-    void MaybePrune(log_id_t id) REQUIRES(lock_);
-
-    LogReaderList* reader_list_;
-    LogTags* tags_;
-    LogStatistics* stats_;
-
-    std::atomic<uint64_t> sequence_ = 1;
-
-    size_t max_size_[LOG_ID_MAX] GUARDED_BY(lock_);
-    std::list<LogBufferElement> logs_ GUARDED_BY(lock_);
-    // Keeps track of the iterator to the oldest log message of a given log type, as an
-    // optimization when pruning logs.  Use GetOldest() to retrieve.
-    std::optional<std::list<LogBufferElement>::iterator> oldest_[LOG_ID_MAX] GUARDED_BY(lock_);
-};
diff --git a/logd/auditctl.cpp b/logd/auditctl.cpp
deleted file mode 100644
index 98bb02d..0000000
--- a/logd/auditctl.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2019 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 <android-base/parseint.h>
-#include <error.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "libaudit.h"
-
-static void usage(const char* cmdline) {
-    fprintf(stderr, "Usage: %s [-r rate]\n", cmdline);
-}
-
-static void do_update_rate(uint32_t rate) {
-    int fd = audit_open();
-    if (fd == -1) {
-        error(EXIT_FAILURE, errno, "Unable to open audit socket");
-    }
-    int result = audit_rate_limit(fd, rate);
-    close(fd);
-    if (result < 0) {
-        fprintf(stderr, "Can't update audit rate limit: %d\n", result);
-        exit(EXIT_FAILURE);
-    }
-}
-
-int main(int argc, char* argv[]) {
-    uint32_t rate = 0;
-    bool update_rate = false;
-    int opt;
-
-    while ((opt = getopt(argc, argv, "r:")) != -1) {
-        switch (opt) {
-            case 'r':
-                if (!android::base::ParseUint<uint32_t>(optarg, &rate)) {
-                    error(EXIT_FAILURE, errno, "Invalid Rate");
-                }
-                update_rate = true;
-                break;
-            default: /* '?' */
-                usage(argv[0]);
-                exit(EXIT_FAILURE);
-        }
-    }
-
-    // In the future, we may add other options to auditctl
-    // so this if statement will expand.
-    // if (!update_rate && !update_backlog && !update_whatever) ...
-    if (!update_rate) {
-        fprintf(stderr, "Nothing to do\n");
-        usage(argv[0]);
-        exit(EXIT_FAILURE);
-    }
-
-    if (update_rate) {
-        do_update_rate(rate);
-    }
-
-    return 0;
-}
diff --git a/logd/doc_images/cpu_cuttlefish.png b/logd/doc_images/cpu_cuttlefish.png
deleted file mode 100644
index 8d809ca..0000000
--- a/logd/doc_images/cpu_cuttlefish.png
+++ /dev/null
Binary files differ
diff --git a/logd/doc_images/cpu_walleye.png b/logd/doc_images/cpu_walleye.png
deleted file mode 100644
index 39c951b..0000000
--- a/logd/doc_images/cpu_walleye.png
+++ /dev/null
Binary files differ
diff --git a/logd/doc_images/memory_usage.png b/logd/doc_images/memory_usage.png
deleted file mode 100644
index 434d6d3..0000000
--- a/logd/doc_images/memory_usage.png
+++ /dev/null
Binary files differ
diff --git a/logd/doc_images/total_log_count.png b/logd/doc_images/total_log_count.png
deleted file mode 100644
index e73c2c1..0000000
--- a/logd/doc_images/total_log_count.png
+++ /dev/null
Binary files differ
diff --git a/logd/event.logtags b/logd/event.logtags
deleted file mode 100644
index fa13a62..0000000
--- a/logd/event.logtags
+++ /dev/null
@@ -1,39 +0,0 @@
-# The entries in this file map a sparse set of log tag numbers to tag names.
-# This is installed on the device, in /system/etc, and parsed by logcat.
-#
-# Tag numbers are decimal integers, from 0 to 2^31.  (Let's leave the
-# negative values alone for now.)
-#
-# Tag names are one or more ASCII letters and numbers or underscores, i.e.
-# "[A-Z][a-z][0-9]_".  Do not include spaces or punctuation (the former
-# impacts log readability, the latter makes regex searches more annoying).
-#
-# Tag numbers and names are separated by whitespace.  Blank lines and lines
-# starting with '#' are ignored.
-#
-# Optionally, after the tag names can be put a description for the value(s)
-# of the tag. Description are in the format
-#    (<name>|data type[|data unit])
-# Multiple values are separated by commas.
-#
-# The data type is a number from the following values:
-# 1: int
-# 2: long
-# 3: string
-# 4: list
-#
-# The data unit is a number taken from the following list:
-# 1: Number of objects
-# 2: Number of bytes
-# 3: Number of milliseconds
-# 4: Number of allocations
-# 5: Id
-# 6: Percent
-# s: Number of seconds (monotonic time)
-# Default value for data of type int/long is 2 (bytes).
-#
-# TODO: generate ".java" and ".h" files with integer constants from this file.
-
-1003  auditd (avc|3)
-1004  chatty (dropped|3)
-1005  tag_def (tag|1),(name|3),(format|3)
diff --git a/logd/fuzz/Android.bp b/logd/fuzz/Android.bp
deleted file mode 100644
index d346cd7..0000000
--- a/logd/fuzz/Android.bp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2019 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: "log_fuzzer_defaults",
-    static_libs: [
-        "libbase",
-        "libcutils",
-        "libselinux",
-        "liblog",
-        "liblogd",
-        "libcutils",
-        "libz",
-        "libzstd",
-    ],
-    cflags: ["-Wextra"],
-    host_supported: true,
-}
-
-cc_fuzz {
-    name: "log_buffer_log_fuzzer",
-    defaults: ["log_fuzzer_defaults"],
-    srcs: [
-        "log_buffer_log_fuzzer.cpp",
-    ],
-}
-
-cc_fuzz {
-    name: "serialized_log_buffer_fuzzer",
-    defaults: ["log_fuzzer_defaults"],
-    srcs: [
-        "serialized_log_buffer_fuzzer.cpp",
-    ],
-    corpus: [
-        "corpus/logentry_use_after_compress",
-    ]
-}
diff --git a/logd/fuzz/corpus/logentry_use_after_compress b/logd/fuzz/corpus/logentry_use_after_compress
deleted file mode 100644
index 2081b13..0000000
--- a/logd/fuzz/corpus/logentry_use_after_compress
+++ /dev/null
Binary files differ
diff --git a/logd/fuzz/log_buffer_log_fuzzer.cpp b/logd/fuzz/log_buffer_log_fuzzer.cpp
deleted file mode 100644
index d71a2f9..0000000
--- a/logd/fuzz/log_buffer_log_fuzzer.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2019 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 <string>
-
-#include <android-base/logging.h>
-
-#include "../ChattyLogBuffer.h"
-#include "../LogReaderList.h"
-#include "../LogReaderThread.h"
-#include "../LogStatistics.h"
-#include "../SerializedLogBuffer.h"
-
-// We don't want to waste a lot of entropy on messages
-#define MAX_MSG_LENGTH 5
-
-// Tag IDs usually start at 1000, we only want to try 1000 through 1009
-#define MIN_TAG_ID 1000
-#define TAG_MOD 10
-
-char* android::uidToName(uid_t) {
-    return strdup("fake");
-}
-
-struct LogInput {
-  public:
-    log_id_t log_id;
-    log_time realtime;
-    uid_t uid;
-    pid_t pid;
-    pid_t tid;
-    unsigned int log_mask;
-};
-
-int write_log_messages(const uint8_t** pdata, size_t* data_left, LogBuffer* log_buffer,
-                       LogStatistics* stats) {
-    const uint8_t* data = *pdata;
-    const LogInput* logInput = reinterpret_cast<const LogInput*>(data);
-    data += sizeof(LogInput);
-    *data_left -= sizeof(LogInput);
-
-    uint32_t tag = MIN_TAG_ID + data[0] % TAG_MOD;
-    uint8_t msg_length = data[1] % MAX_MSG_LENGTH;
-    if (msg_length < 2) {
-        // Not enough data for message
-        return 0;
-    }
-
-    data += 2 * sizeof(uint8_t);
-    *data_left -= 2 * sizeof(uint8_t);
-
-    if (*data_left < msg_length) {
-        // Not enough data for tag and message
-        *pdata = data;
-        return 0;
-    }
-
-    // We need nullterm'd strings
-    char msg[sizeof(uint32_t) + MAX_MSG_LENGTH + sizeof(char)];
-    char* msg_only = msg + sizeof(uint32_t);
-    memcpy(msg, &tag, sizeof(uint32_t));
-    memcpy(msg_only, data, msg_length);
-    msg_only[msg_length] = '\0';
-    data += msg_length;
-    *data_left -= msg_length;
-
-    // Other elements not in enum.
-    log_id_t log_id = static_cast<log_id_t>(unsigned(logInput->log_id) % (LOG_ID_MAX + 1));
-    log_buffer->Log(log_id, logInput->realtime, logInput->uid, logInput->pid, logInput->tid, msg,
-                    sizeof(uint32_t) + msg_length + 1);
-    stats->Format(logInput->uid, logInput->pid, logInput->log_mask);
-    *pdata = data;
-    return 1;
-}
-
-class NoopWriter : public LogWriter {
-  public:
-    NoopWriter() : LogWriter(0, true) {}
-    bool Write(const logger_entry&, const char*) override { return true; }
-
-    std::string name() const override { return "noop_writer"; }
-};
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
-    // We want a random tag length and a random remaining message length
-    if (data == nullptr || size < sizeof(LogInput) + 2 * sizeof(uint8_t)) {
-        return 0;
-    }
-
-    android::base::SetMinimumLogSeverity(android::base::ERROR);
-
-    LogReaderList reader_list;
-    LogTags tags;
-    PruneList prune_list;
-    LogStatistics stats(true, true);
-    std::unique_ptr<LogBuffer> log_buffer;
-#ifdef FUZZ_SERIALIZED
-    log_buffer.reset(new SerializedLogBuffer(&reader_list, &tags, &stats));
-#else
-    log_buffer.reset(new ChattyLogBuffer(&reader_list, &tags, &prune_list, &stats));
-#endif
-    size_t data_left = size;
-    const uint8_t** pdata = &data;
-
-    prune_list.Init(nullptr);
-    // We want to get pruning code to get called.
-    log_id_for_each(i) { log_buffer->SetSize(i, 10000); }
-
-    while (data_left >= sizeof(LogInput) + 2 * sizeof(uint8_t)) {
-        if (!write_log_messages(pdata, &data_left, log_buffer.get(), &stats)) {
-            return 0;
-        }
-    }
-
-    // Read out all of the logs.
-    {
-        auto lock = std::unique_lock{reader_list.reader_threads_lock()};
-        std::unique_ptr<LogWriter> test_writer(new NoopWriter());
-        std::unique_ptr<LogReaderThread> log_reader(
-                new LogReaderThread(log_buffer.get(), &reader_list, std::move(test_writer), true, 0,
-                                    kLogMaskAll, 0, {}, 1, {}));
-        reader_list.reader_threads().emplace_back(std::move(log_reader));
-    }
-
-    // Wait until the reader has finished.
-    while (true) {
-        usleep(50);
-        auto lock = std::unique_lock{reader_list.reader_threads_lock()};
-        if (reader_list.reader_threads().size() == 0) {
-            break;
-        }
-    }
-
-    log_id_for_each(i) { log_buffer->Clear(i, 0); }
-    return 0;
-}
diff --git a/logd/fuzz/serialized_log_buffer_fuzzer.cpp b/logd/fuzz/serialized_log_buffer_fuzzer.cpp
deleted file mode 100644
index d4795b0..0000000
--- a/logd/fuzz/serialized_log_buffer_fuzzer.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2020 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.
- */
-
-#define FUZZ_SERIALIZED
-
-#include "log_buffer_log_fuzzer.cpp"
diff --git a/logd/libaudit.cpp b/logd/libaudit.cpp
deleted file mode 100644
index ccea0a2..0000000
--- a/logd/libaudit.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright 2012, Samsung Telecommunications of America
- * 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.
- *
- * Written by William Roberts <w.roberts@sta.samsung.com>
- *
- */
-
-#include "libaudit.h"
-
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <limits>
-
-/**
- * Waits for an ack from the kernel
- * @param fd
- *  The netlink socket fd
- * @return
- *  This function returns 0 on success, else -errno.
- */
-static int get_ack(int fd) {
-    struct audit_message rep = {};
-    int rc = audit_get_reply(fd, &rep, GET_REPLY_BLOCKING, MSG_PEEK);
-    if (rc < 0) {
-        return rc;
-    }
-
-    if (rep.nlh.nlmsg_type == NLMSG_ERROR) {
-        audit_get_reply(fd, &rep, GET_REPLY_BLOCKING, 0);
-        rc = reinterpret_cast<struct nlmsgerr*>(rep.data)->error;
-        if (rc) {
-            return -rc;
-        }
-    }
-
-    return 0;
-}
-
-/**
- *
- * @param fd
- *  The netlink socket fd
- * @param type
- *  The type of netlink message
- * @param data
- *  The data to send
- * @param size
- *  The length of the data in bytes
- * @return
- *  This function returns a positive sequence number on success, else -errno.
- */
-static int audit_send(int fd, int type, const void* data, size_t size) {
-    struct sockaddr_nl addr = {.nl_family = AF_NETLINK};
-
-    /* Set up the netlink headers */
-    struct audit_message req = {};
-    req.nlh.nlmsg_type = static_cast<uint16_t>(type);
-    req.nlh.nlmsg_len = NLMSG_SPACE(size);
-    req.nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
-
-    /*
-     * Check for a valid fd, even though sendto would catch this, its easier
-     * to always blindly increment the sequence number
-     */
-    if (fd < 0) {
-        return -EBADF;
-    }
-
-    /* Ensure the message is not too big */
-    if (NLMSG_SPACE(size) > MAX_AUDIT_MESSAGE_LENGTH) {
-        return -EINVAL;
-    }
-
-    /* Only memcpy in the data if it was specified */
-    if (size && data) {
-        memcpy(NLMSG_DATA(&req.nlh), data, size);
-    }
-
-    /*
-     * Only increment the sequence number on a guarantee
-     * you will send it to the kernel.
-     */
-    static uint32_t sequence = 0;
-    if (sequence == std::numeric_limits<uint32_t>::max()) {
-        sequence = 1;
-    } else {
-        sequence++;
-    }
-    req.nlh.nlmsg_seq = sequence;
-
-    ssize_t rc = TEMP_FAILURE_RETRY(
-            sendto(fd, &req, req.nlh.nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)));
-
-    /* Not all the bytes were sent */
-    if (rc < 0) {
-        return -errno;
-    } else if ((uint32_t)rc != req.nlh.nlmsg_len) {
-        return -EPROTO;
-    }
-
-    /* We sent all the bytes, get the ack */
-    rc = get_ack(fd);
-
-    /* If the ack failed, return the error, else return the sequence number */
-    rc = (rc == 0) ? (int)sequence : rc;
-
-    return rc;
-}
-
-int audit_setup(int fd, pid_t pid) {
-    /*
-     * In order to set the auditd PID we send an audit message over the netlink
-     * socket with the pid field of the status struct set to our current pid,
-     * and the the mask set to AUDIT_STATUS_PID
-     */
-    struct audit_status status = {
-            .mask = AUDIT_STATUS_PID,
-            .pid = static_cast<uint32_t>(pid),
-    };
-
-    /* Let the kernel know this pid will be registering for audit events */
-    int rc = audit_send(fd, AUDIT_SET, &status, sizeof(status));
-    if (rc < 0) {
-        return rc;
-    }
-
-    /*
-     * In a request where we need to wait for a response, wait for the message
-     * and discard it. This message confirms and sync's us with the kernel.
-     * This daemon is now registered as the audit logger.
-     *
-     * TODO
-     * If the daemon dies and restarts the message didn't come back,
-     * so I went to non-blocking and it seemed to fix the bug.
-     * Need to investigate further.
-     */
-    struct audit_message rep = {};
-    audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0);
-
-    return 0;
-}
-
-int audit_open() {
-    return socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_AUDIT);
-}
-
-int audit_rate_limit(int fd, uint32_t limit) {
-    struct audit_status status = {
-            .mask = AUDIT_STATUS_RATE_LIMIT, .rate_limit = limit, /* audit entries per second */
-    };
-    return audit_send(fd, AUDIT_SET, &status, sizeof(status));
-}
-
-int audit_get_reply(int fd, struct audit_message* rep, reply_t block, int peek) {
-    if (fd < 0) {
-        return -EBADF;
-    }
-
-    int flags = (block == GET_REPLY_NONBLOCKING) ? MSG_DONTWAIT : 0;
-    flags |= peek;
-
-    /*
-     * Get the data from the netlink socket but on error we need to be carefull,
-     * the interface shows that EINTR can never be returned, other errors,
-     * however, can be returned.
-     */
-    struct sockaddr_nl nladdr;
-    socklen_t nladdrlen = sizeof(nladdr);
-    ssize_t len = TEMP_FAILURE_RETRY(
-            recvfrom(fd, rep, sizeof(*rep), flags, (struct sockaddr*)&nladdr, &nladdrlen));
-
-    /*
-     * EAGAIN should be re-tried until success or another error manifests.
-     */
-    if (len < 0) {
-        if (block == GET_REPLY_NONBLOCKING && errno == EAGAIN) {
-            /* If request is non blocking and errno is EAGAIN, just return 0 */
-            return 0;
-        }
-        return -errno;
-    }
-
-    if (nladdrlen != sizeof(nladdr)) {
-        return -EPROTO;
-    }
-
-    /* Make sure the netlink message was not spoof'd */
-    if (nladdr.nl_pid) {
-        return -EINVAL;
-    }
-
-    /* Check if the reply from the kernel was ok */
-    if (!NLMSG_OK(&rep->nlh, (size_t)len)) {
-        return len == sizeof(*rep) ? -EFBIG : -EBADE;
-    }
-
-    return 0;
-}
-
-void audit_close(int fd) {
-    close(fd);
-}
diff --git a/logd/libaudit.h b/logd/libaudit.h
deleted file mode 100644
index 27b0866..0000000
--- a/logd/libaudit.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2012, Samsung Telecommunications of America
- * 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.
- *
- * Written by William Roberts <w.roberts@sta.samsung.com>
- */
-
-#pragma once
-
-#include <stdint.h>
-#include <sys/cdefs.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <linux/audit.h>
-#include <linux/netlink.h>
-
-__BEGIN_DECLS
-
-#define MAX_AUDIT_MESSAGE_LENGTH 8970
-
-typedef enum { GET_REPLY_BLOCKING = 0, GET_REPLY_NONBLOCKING } reply_t;
-
-/* type == AUDIT_SIGNAL_INFO */
-struct audit_sig_info {
-    uid_t uid;
-    pid_t pid;
-    char ctx[0];
-};
-
-struct audit_message {
-    struct nlmsghdr nlh;
-    char data[MAX_AUDIT_MESSAGE_LENGTH];
-};
-
-/**
- * Opens a connection to the Audit netlink socket
- * @return
- *  A valid fd on success or < 0 on error with errno set.
- *  Returns the same errors as man 2 socket.
- */
-extern int audit_open(void);
-
-/**
- * Closes the fd returned from audit_open()
- * @param fd
- *  The fd to close
- */
-extern void audit_close(int fd);
-
-/**
- *
- * @param fd
- *  The fd returned by a call to audit_open()
- * @param rep
- *  The response struct to store the response in.
- * @param block
- *  Whether or not to block on IO
- * @param peek
- *  Whether or not we are to remove the message from
- *  the queue when we do a read on the netlink socket.
- * @return
- *  This function returns 0 on success, else -errno.
- */
-extern int audit_get_reply(int fd, struct audit_message* rep, reply_t block,
-                           int peek);
-
-/**
- * Sets a pid to receive audit netlink events from the kernel
- * @param fd
- *  The fd returned by a call to audit_open()
- * @param pid
- *  The pid whom to set as the receiver of audit messages
- * @return
- *  This function returns 0 on success, -errno on error.
- */
-extern int audit_setup(int fd, pid_t pid);
-
-/**
- * Throttle kernel messages at the provided rate
- * @param fd
- *  The fd returned by a call to audit_open()
- * @param rate
- *  The rate, in messages per second, above which the kernel
- *  should drop audit messages.
- * @return
- *  This function returns 0 on success, -errno on error.
- */
-extern int audit_rate_limit(int fd, uint32_t limit);
-
-__END_DECLS
diff --git a/logd/logd.rc b/logd/logd.rc
deleted file mode 100644
index 530f342..0000000
--- a/logd/logd.rc
+++ /dev/null
@@ -1,35 +0,0 @@
-service logd /system/bin/logd
-    socket logd stream 0666 logd logd
-    socket logdr seqpacket 0666 logd logd
-    socket logdw dgram+passcred 0222 logd logd
-    file /proc/kmsg r
-    file /dev/kmsg w
-    user logd
-    group logd system package_info readproc
-    capabilities SYSLOG AUDIT_CONTROL
-    priority 10
-    writepid /dev/cpuset/system-background/tasks
-
-service logd-reinit /system/bin/logd --reinit
-    oneshot
-    disabled
-    user logd
-    group logd
-    writepid /dev/cpuset/system-background/tasks
-
-# Limit SELinux denial generation to 5/second
-service logd-auditctl /system/bin/auditctl -r 5
-    oneshot
-    disabled
-    user logd
-    group logd
-    capabilities AUDIT_CONTROL
-
-on fs
-    write /dev/event-log-tags "# content owned by logd
-"
-    chown logd logd /dev/event-log-tags
-    chmod 0644 /dev/event-log-tags
-
-on property:sys.boot_completed=1
-    start logd-auditctl
diff --git a/logd/logd_test.cpp b/logd/logd_test.cpp
deleted file mode 100644
index 202ab06..0000000
--- a/logd/logd_test.cpp
+++ /dev/null
@@ -1,872 +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 <ctype.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <poll.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <string>
-
-#include <android-base/file.h>
-#include <android-base/macros.h>
-#include <android-base/stringprintf.h>
-#include <android-base/unique_fd.h>
-#include <cutils/sockets.h>
-#include <gtest/gtest.h>
-#include <log/log_read.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-#ifdef __ANDROID__
-#include <selinux/selinux.h>
-#endif
-
-#include "LogReader.h"  // pickup LOGD_SNDTIMEO
-
-using android::base::unique_fd;
-
-#ifdef __ANDROID__
-static void send_to_control(char* buf, size_t len) {
-    int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                   SOCK_STREAM);
-    if (sock >= 0) {
-        if (write(sock, buf, strlen(buf) + 1) > 0) {
-            ssize_t ret;
-            while ((ret = read(sock, buf, len)) > 0) {
-                if (((size_t)ret == len) || (len < PAGE_SIZE)) {
-                    break;
-                }
-                len -= ret;
-                buf += ret;
-
-                struct pollfd p = {.fd = sock, .events = POLLIN, .revents = 0 };
-
-                ret = poll(&p, 1, 20);
-                if ((ret <= 0) || !(p.revents & POLLIN)) {
-                    break;
-                }
-            }
-        }
-        close(sock);
-    }
-}
-
-/*
- * returns statistics
- */
-static void my_android_logger_get_statistics(char* buf, size_t len) {
-    snprintf(buf, len, "getStatistics 0 1 2 3 4");
-    send_to_control(buf, len);
-}
-
-static void alloc_statistics(char** buffer, size_t* length) {
-    size_t len = 8192;
-    char* buf;
-
-    for (int retry = 32; (retry >= 0); delete[] buf, --retry) {
-        buf = new char[len];
-        my_android_logger_get_statistics(buf, len);
-
-        buf[len - 1] = '\0';
-        size_t ret = atol(buf) + 1;
-        if (ret < 4) {
-            delete[] buf;
-            buf = nullptr;
-            break;
-        }
-        bool check = ret <= len;
-        len = ret;
-        if (check) {
-            break;
-        }
-        len += len / 8;  // allow for some slop
-    }
-    *buffer = buf;
-    *length = len;
-}
-
-static char* find_benchmark_spam(char* cp) {
-    // liblog_benchmarks has been run designed to SPAM.  The signature of
-    // a noisiest UID statistics is:
-    //
-    // Chattiest UIDs in main log buffer:                           Size Pruned
-    // UID   PACKAGE                                                BYTES LINES
-    // 0     root                                                  54164 147569
-    //
-    char* benchmark = nullptr;
-    do {
-        static const char signature[] = "\n0     root ";
-
-        benchmark = strstr(cp, signature);
-        if (!benchmark) {
-            break;
-        }
-        cp = benchmark + sizeof(signature);
-        while (isspace(*cp)) {
-            ++cp;
-        }
-        benchmark = cp;
-#ifdef DEBUG
-        char* end = strstr(benchmark, "\n");
-        if (end == nullptr) {
-            end = benchmark + strlen(benchmark);
-        }
-        fprintf(stderr, "parse for spam counter in \"%.*s\"\n",
-                (int)(end - benchmark), benchmark);
-#endif
-        // content
-        while (isdigit(*cp)) {
-            ++cp;
-        }
-        while (isspace(*cp)) {
-            ++cp;
-        }
-        // optional +/- field?
-        if ((*cp == '-') || (*cp == '+')) {
-            while (isdigit(*++cp) || (*cp == '.') || (*cp == '%') ||
-                   (*cp == 'X')) {
-                ;
-            }
-            while (isspace(*cp)) {
-                ++cp;
-            }
-        }
-        // number of entries pruned
-        unsigned long value = 0;
-        while (isdigit(*cp)) {
-            value = value * 10ULL + *cp - '0';
-            ++cp;
-        }
-        if (value > 10UL) {
-            break;
-        }
-        benchmark = nullptr;
-    } while (*cp);
-    return benchmark;
-}
-#endif
-
-#ifdef LOGD_ENABLE_FLAKY_TESTS
-TEST(logd, statistics) {
-#ifdef __ANDROID__
-    size_t len;
-    char* buf;
-
-    // Drop cache so that any access problems can be discovered.
-    if (!android::base::WriteStringToFile("3\n", "/proc/sys/vm/drop_caches")) {
-        GTEST_LOG_(INFO) << "Could not open trigger dropping inode cache";
-    }
-
-    alloc_statistics(&buf, &len);
-
-    ASSERT_TRUE(nullptr != buf);
-
-    // remove trailing FF
-    char* cp = buf + len - 1;
-    *cp = '\0';
-    bool truncated = *--cp != '\f';
-    if (!truncated) {
-        *cp = '\0';
-    }
-
-    // squash out the byte count
-    cp = buf;
-    if (!truncated) {
-        while (isdigit(*cp) || (*cp == '\n')) {
-            ++cp;
-        }
-    }
-
-    fprintf(stderr, "%s", cp);
-
-    EXPECT_LT((size_t)64, strlen(cp));
-
-    EXPECT_EQ(0, truncated);
-
-    char* main_logs = strstr(cp, "\nChattiest UIDs in main ");
-    EXPECT_TRUE(nullptr != main_logs);
-
-    char* radio_logs = strstr(cp, "\nChattiest UIDs in radio ");
-    if (!radio_logs)
-        GTEST_LOG_(INFO) << "Value of: nullptr != radio_logs\n"
-                            "Actual: false\n"
-                            "Expected: false\n";
-
-    char* system_logs = strstr(cp, "\nChattiest UIDs in system ");
-    EXPECT_TRUE(nullptr != system_logs);
-
-    char* events_logs = strstr(cp, "\nChattiest UIDs in events ");
-    EXPECT_TRUE(nullptr != events_logs);
-
-    // Check if there is any " u0_a#### " as this means packagelistparser broken
-    char* used_getpwuid = nullptr;
-    int used_getpwuid_len;
-    char* uid_name = cp;
-    static const char getpwuid_prefix[] = " u0_a";
-    while ((uid_name = strstr(uid_name, getpwuid_prefix)) != nullptr) {
-        used_getpwuid = uid_name + 1;
-        uid_name += strlen(getpwuid_prefix);
-        while (isdigit(*uid_name)) ++uid_name;
-        used_getpwuid_len = uid_name - used_getpwuid;
-        if (isspace(*uid_name)) break;
-        used_getpwuid = nullptr;
-    }
-    EXPECT_TRUE(nullptr == used_getpwuid);
-    if (used_getpwuid) {
-        fprintf(stderr, "libpackagelistparser failed to pick up %.*s\n",
-                used_getpwuid_len, used_getpwuid);
-    }
-
-    delete[] buf;
-#else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif
-
-#ifdef __ANDROID__
-static void caught_signal(int /* signum */) {
-}
-
-static void dump_log_msg(const char* prefix, log_msg* msg, int lid) {
-    std::cout << std::flush;
-    std::cerr << std::flush;
-    fflush(stdout);
-    fflush(stderr);
-    EXPECT_GE(msg->entry.hdr_size, sizeof(logger_entry));
-
-    fprintf(stderr, "%s: [%u] ", prefix, msg->len());
-    fprintf(stderr, "hdr_size=%u ", msg->entry.hdr_size);
-    fprintf(stderr, "pid=%u tid=%u %u.%09u ", msg->entry.pid, msg->entry.tid, msg->entry.sec,
-            msg->entry.nsec);
-    lid = msg->entry.lid;
-
-    switch (lid) {
-        case 0:
-            fprintf(stderr, "lid=main ");
-            break;
-        case 1:
-            fprintf(stderr, "lid=radio ");
-            break;
-        case 2:
-            fprintf(stderr, "lid=events ");
-            break;
-        case 3:
-            fprintf(stderr, "lid=system ");
-            break;
-        case 4:
-            fprintf(stderr, "lid=crash ");
-            break;
-        case 5:
-            fprintf(stderr, "lid=security ");
-            break;
-        case 6:
-            fprintf(stderr, "lid=kernel ");
-            break;
-        default:
-            if (lid >= 0) {
-                fprintf(stderr, "lid=%d ", lid);
-            }
-    }
-
-    unsigned int len = msg->entry.len;
-    fprintf(stderr, "msg[%u]={", len);
-    unsigned char* cp = reinterpret_cast<unsigned char*>(msg->msg());
-    if (!cp) {
-        static const unsigned char garbage[] = "<INVALID>";
-        cp = const_cast<unsigned char*>(garbage);
-        len = strlen(reinterpret_cast<const char*>(garbage));
-    }
-    while (len) {
-        unsigned char* p = cp;
-        while (*p && (((' ' <= *p) && (*p < 0x7F)) || (*p == '\n'))) {
-            ++p;
-        }
-        if (((p - cp) > 3) && !*p && ((unsigned int)(p - cp) < len)) {
-            fprintf(stderr, "\"");
-            while (*cp) {
-                if (*cp != '\n') {
-                    fprintf(stderr, "%c", *cp);
-                } else {
-                    fprintf(stderr, "\\n");
-                }
-                ++cp;
-                --len;
-            }
-            fprintf(stderr, "\"");
-        } else {
-            fprintf(stderr, "%02x", *cp);
-        }
-        ++cp;
-        if (--len) {
-            fprintf(stderr, ", ");
-        }
-    }
-    fprintf(stderr, "}\n");
-    fflush(stderr);
-}
-#endif
-
-#ifdef __ANDROID__
-// BAD ROBOT
-//   Benchmark threshold are generally considered bad form unless there is
-//   is some human love applied to the continued maintenance and whether the
-//   thresholds are tuned on a per-target basis. Here we check if the values
-//   are more than double what is expected. Doubling will not prevent failure
-//   on busy or low-end systems that could have a tendency to stretch values.
-//
-//   The primary goal of this test is to simulate a spammy app (benchmark
-//   being the worst) and check to make sure the logger can deal with it
-//   appropriately by checking all the statistics are in an expected range.
-//
-TEST(logd, benchmark) {
-    size_t len;
-    char* buf;
-
-    alloc_statistics(&buf, &len);
-    bool benchmark_already_run = buf && find_benchmark_spam(buf);
-    delete[] buf;
-
-    if (benchmark_already_run) {
-        fprintf(stderr,
-                "WARNING: spam already present and too much history\n"
-                "         false OK for prune by worst UID check\n");
-    }
-
-    FILE* fp;
-
-    // Introduce some extreme spam for the worst UID filter
-    ASSERT_TRUE(
-        nullptr !=
-        (fp = popen("/data/nativetest/liblog-benchmarks/liblog-benchmarks"
-                    " BM_log_maximum_retry"
-                    " BM_log_maximum"
-                    " BM_clock_overhead"
-                    " BM_log_print_overhead"
-                    " BM_log_latency"
-                    " BM_log_delay",
-                    "r")));
-
-    char buffer[5120];
-
-    static const char* benchmarks[] = {
-        "BM_log_maximum_retry ",  "BM_log_maximum ", "BM_clock_overhead ",
-        "BM_log_print_overhead ", "BM_log_latency ", "BM_log_delay "
-    };
-    static const unsigned int log_maximum_retry = 0;
-    static const unsigned int log_maximum = 1;
-    static const unsigned int clock_overhead = 2;
-    static const unsigned int log_print_overhead = 3;
-    static const unsigned int log_latency = 4;
-    static const unsigned int log_delay = 5;
-
-    unsigned long ns[arraysize(benchmarks)];
-
-    memset(ns, 0, sizeof(ns));
-
-    while (fgets(buffer, sizeof(buffer), fp)) {
-        for (unsigned i = 0; i < arraysize(ns); ++i) {
-            char* cp = strstr(buffer, benchmarks[i]);
-            if (!cp) {
-                continue;
-            }
-            sscanf(cp, "%*s %lu %lu", &ns[i], &ns[i]);
-            fprintf(stderr, "%-22s%8lu\n", benchmarks[i], ns[i]);
-        }
-    }
-    int ret = pclose(fp);
-
-    if (!WIFEXITED(ret) || (WEXITSTATUS(ret) == 127)) {
-        fprintf(stderr,
-                "WARNING: "
-                "/data/nativetest/liblog-benchmarks/liblog-benchmarks missing\n"
-                "         can not perform test\n");
-        return;
-    }
-
-    EXPECT_GE(200000UL, ns[log_maximum_retry]);  // 104734 user
-    EXPECT_NE(0UL, ns[log_maximum_retry]);       // failure to parse
-
-    EXPECT_GE(90000UL, ns[log_maximum]);  // 46913 user
-    EXPECT_NE(0UL, ns[log_maximum]);      // failure to parse
-
-    EXPECT_GE(4096UL, ns[clock_overhead]);  // 4095
-    EXPECT_NE(0UL, ns[clock_overhead]);     // failure to parse
-
-    EXPECT_GE(250000UL, ns[log_print_overhead]);  // 126886 user
-    EXPECT_NE(0UL, ns[log_print_overhead]);       // failure to parse
-
-    EXPECT_GE(10000000UL,
-              ns[log_latency]);  // 1453559 user space (background cgroup)
-    EXPECT_NE(0UL, ns[log_latency]);  // failure to parse
-
-    EXPECT_GE(20000000UL, ns[log_delay]);  // 10500289 user
-    EXPECT_NE(0UL, ns[log_delay]);         // failure to parse
-
-    alloc_statistics(&buf, &len);
-
-    bool collected_statistics = !!buf;
-    EXPECT_EQ(true, collected_statistics);
-
-    ASSERT_TRUE(nullptr != buf);
-
-    char* benchmark_statistics_found = find_benchmark_spam(buf);
-    ASSERT_TRUE(benchmark_statistics_found != nullptr);
-
-    // Check how effective the SPAM filter is, parse out Now size.
-    // 0     root                      54164 147569
-    //                                 ^-- benchmark_statistics_found
-
-    unsigned long nowSpamSize = atol(benchmark_statistics_found);
-
-    delete[] buf;
-
-    ASSERT_NE(0UL, nowSpamSize);
-
-    // Determine if we have the spam filter enabled
-    int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                   SOCK_STREAM);
-
-    ASSERT_TRUE(sock >= 0);
-
-    static const char getPruneList[] = "getPruneList";
-    if (write(sock, getPruneList, sizeof(getPruneList)) > 0) {
-        char buffer[80];
-        memset(buffer, 0, sizeof(buffer));
-        read(sock, buffer, sizeof(buffer));
-        char* cp = strchr(buffer, '\n');
-        if (!cp || (cp[1] != '~') || (cp[2] != '!')) {
-            close(sock);
-            fprintf(stderr,
-                    "WARNING: "
-                    "Logger has SPAM filtration turned off \"%s\"\n",
-                    buffer);
-            return;
-        }
-    } else {
-        int save_errno = errno;
-        close(sock);
-        FAIL() << "Can not send " << getPruneList << " to logger -- "
-               << strerror(save_errno);
-    }
-
-    static const unsigned long expected_absolute_minimum_log_size = 65536UL;
-    unsigned long totalSize = expected_absolute_minimum_log_size;
-    static const char getSize[] = { 'g', 'e', 't', 'L', 'o', 'g',
-                                    'S', 'i', 'z', 'e', ' ', LOG_ID_MAIN + '0',
-                                    '\0' };
-    if (write(sock, getSize, sizeof(getSize)) > 0) {
-        char buffer[80];
-        memset(buffer, 0, sizeof(buffer));
-        read(sock, buffer, sizeof(buffer));
-        totalSize = atol(buffer);
-        if (totalSize < expected_absolute_minimum_log_size) {
-            fprintf(stderr,
-                    "WARNING: "
-                    "Logger had unexpected referenced size \"%s\"\n",
-                    buffer);
-            totalSize = expected_absolute_minimum_log_size;
-        }
-    }
-    close(sock);
-
-    // logd allows excursions to 110% of total size
-    totalSize = (totalSize * 11) / 10;
-
-    // 50% threshold for SPAM filter (<20% typical, lots of engineering margin)
-    ASSERT_GT(totalSize, nowSpamSize * 2);
-}
-#endif
-
-// b/26447386 confirm fixed
-void timeout_negative(const char* command) {
-#ifdef __ANDROID__
-    log_msg msg_wrap, msg_timeout;
-    bool content_wrap = false, content_timeout = false, written = false;
-    unsigned int alarm_wrap = 0, alarm_timeout = 0;
-    // A few tries to get it right just in case wrap kicks in due to
-    // content providers being active during the test.
-    int i = 3;
-
-    while (--i) {
-        int fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                     SOCK_SEQPACKET);
-        ASSERT_LT(0, fd);
-
-        std::string ask(command);
-
-        struct sigaction ignore, old_sigaction;
-        memset(&ignore, 0, sizeof(ignore));
-        ignore.sa_handler = caught_signal;
-        sigemptyset(&ignore.sa_mask);
-        sigaction(SIGALRM, &ignore, &old_sigaction);
-        unsigned int old_alarm = alarm(3);
-
-        size_t len = ask.length() + 1;
-        written = write(fd, ask.c_str(), len) == (ssize_t)len;
-        if (!written) {
-            alarm(old_alarm);
-            sigaction(SIGALRM, &old_sigaction, nullptr);
-            close(fd);
-            continue;
-        }
-
-        // alarm triggers at 50% of the --wrap time out
-        content_wrap = recv(fd, msg_wrap.buf, sizeof(msg_wrap), 0) > 0;
-
-        alarm_wrap = alarm(5);
-
-        // alarm triggers at 133% of the --wrap time out
-        content_timeout = recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
-        if (!content_timeout) {  // make sure we hit dumpAndClose
-            content_timeout =
-                recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
-        }
-
-        if (old_alarm > 0) {
-            unsigned int time_spent = 3 - alarm_wrap;
-            if (old_alarm > time_spent + 1) {
-                old_alarm -= time_spent;
-            } else {
-                old_alarm = 2;
-            }
-        }
-        alarm_timeout = alarm(old_alarm);
-        sigaction(SIGALRM, &old_sigaction, nullptr);
-
-        close(fd);
-
-        if (content_wrap && alarm_wrap && content_timeout && alarm_timeout) {
-            break;
-        }
-    }
-
-    if (content_wrap) {
-        dump_log_msg("wrap", &msg_wrap, -1);
-    }
-
-    if (content_timeout) {
-        dump_log_msg("timeout", &msg_timeout, -1);
-    }
-
-    EXPECT_TRUE(written);
-    EXPECT_TRUE(content_wrap);
-    EXPECT_NE(0U, alarm_wrap);
-    EXPECT_TRUE(content_timeout);
-    EXPECT_NE(0U, alarm_timeout);
-#else
-    command = nullptr;
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(logd, timeout_no_start) {
-    timeout_negative("dumpAndClose lids=0,1,2,3,4,5 timeout=6");
-}
-
-TEST(logd, timeout_start_epoch) {
-    timeout_negative(
-        "dumpAndClose lids=0,1,2,3,4,5 timeout=6 start=0.000000000");
-}
-
-#ifdef ENABLE_FLAKY_TESTS
-// b/26447386 refined behavior
-TEST(logd, timeout) {
-#ifdef __ANDROID__
-    // b/33962045 This test interferes with other log reader tests that
-    // follow because of file descriptor socket persistence in the same
-    // process.  So let's fork it to isolate it from giving us pain.
-
-    pid_t pid = fork();
-
-    if (pid) {
-        siginfo_t info = {};
-        ASSERT_EQ(0, TEMP_FAILURE_RETRY(waitid(P_PID, pid, &info, WEXITED)));
-        ASSERT_EQ(0, info.si_status);
-        return;
-    }
-
-    log_msg msg_wrap, msg_timeout;
-    bool content_wrap = false, content_timeout = false, written = false;
-    unsigned int alarm_wrap = 0, alarm_timeout = 0;
-    // A few tries to get it right just in case wrap kicks in due to
-    // content providers being active during the test.
-    int i = 5;
-    log_time start(CLOCK_REALTIME);
-    start.tv_sec -= 30;  // reach back a moderate period of time
-
-    while (--i) {
-        int fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                     SOCK_SEQPACKET);
-        int save_errno = errno;
-        if (fd < 0) {
-            fprintf(stderr, "failed to open /dev/socket/logdr %s\n",
-                    strerror(save_errno));
-            _exit(fd);
-        }
-
-        std::string ask = android::base::StringPrintf(
-            "dumpAndClose lids=0,1,2,3,4,5 timeout=6 start=%" PRIu32
-            ".%09" PRIu32,
-            start.tv_sec, start.tv_nsec);
-
-        struct sigaction ignore, old_sigaction;
-        memset(&ignore, 0, sizeof(ignore));
-        ignore.sa_handler = caught_signal;
-        sigemptyset(&ignore.sa_mask);
-        sigaction(SIGALRM, &ignore, &old_sigaction);
-        unsigned int old_alarm = alarm(3);
-
-        size_t len = ask.length() + 1;
-        written = write(fd, ask.c_str(), len) == (ssize_t)len;
-        if (!written) {
-            alarm(old_alarm);
-            sigaction(SIGALRM, &old_sigaction, nullptr);
-            close(fd);
-            continue;
-        }
-
-        // alarm triggers at 50% of the --wrap time out
-        content_wrap = recv(fd, msg_wrap.buf, sizeof(msg_wrap), 0) > 0;
-
-        alarm_wrap = alarm(5);
-
-        // alarm triggers at 133% of the --wrap time out
-        content_timeout = recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
-        if (!content_timeout) {  // make sure we hit dumpAndClose
-            content_timeout =
-                recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
-        }
-
-        if (old_alarm > 0) {
-            unsigned int time_spent = 3 - alarm_wrap;
-            if (old_alarm > time_spent + 1) {
-                old_alarm -= time_spent;
-            } else {
-                old_alarm = 2;
-            }
-        }
-        alarm_timeout = alarm(old_alarm);
-        sigaction(SIGALRM, &old_sigaction, nullptr);
-
-        close(fd);
-
-        if (!content_wrap && !alarm_wrap && content_timeout && alarm_timeout) {
-            break;
-        }
-
-        // modify start time in case content providers are relatively
-        // active _or_ inactive during the test.
-        if (content_timeout) {
-            log_time msg(msg_timeout.entry.sec, msg_timeout.entry.nsec);
-            if (msg < start) {
-                fprintf(stderr, "%u.%09u < %u.%09u\n", msg_timeout.entry.sec,
-                        msg_timeout.entry.nsec, (unsigned)start.tv_sec,
-                        (unsigned)start.tv_nsec);
-                _exit(-1);
-            }
-            if (msg > start) {
-                start = msg;
-                start.tv_sec += 30;
-                log_time now = log_time(CLOCK_REALTIME);
-                if (start > now) {
-                    start = now;
-                    --start.tv_sec;
-                }
-            }
-        } else {
-            start.tv_sec -= 120;  // inactive, reach further back!
-        }
-    }
-
-    if (content_wrap) {
-        dump_log_msg("wrap", &msg_wrap, -1);
-    }
-
-    if (content_timeout) {
-        dump_log_msg("timeout", &msg_timeout, -1);
-    }
-
-    if (content_wrap || !content_timeout) {
-        fprintf(stderr, "start=%" PRIu32 ".%09" PRIu32 "\n", start.tv_sec,
-                start.tv_nsec);
-    }
-
-    EXPECT_TRUE(written);
-    EXPECT_FALSE(content_wrap);
-    EXPECT_EQ(0U, alarm_wrap);
-    EXPECT_TRUE(content_timeout);
-    EXPECT_NE(0U, alarm_timeout);
-
-    _exit(!written + content_wrap + alarm_wrap + !content_timeout +
-          !alarm_timeout);
-#else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif
-
-#ifdef LOGD_ENABLE_FLAKY_TESTS
-// b/27242723 confirmed fixed
-TEST(logd, SNDTIMEO) {
-#ifdef __ANDROID__
-    static const unsigned sndtimeo =
-        LOGD_SNDTIMEO;  // <sigh> it has to be done!
-    static const unsigned sleep_time = sndtimeo + 3;
-    static const unsigned alarm_time = sleep_time + 5;
-
-    int fd;
-
-    ASSERT_TRUE(
-        (fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                  SOCK_SEQPACKET)) > 0);
-
-    struct sigaction ignore, old_sigaction;
-    memset(&ignore, 0, sizeof(ignore));
-    ignore.sa_handler = caught_signal;
-    sigemptyset(&ignore.sa_mask);
-    sigaction(SIGALRM, &ignore, &old_sigaction);
-    unsigned int old_alarm = alarm(alarm_time);
-
-    static const char ask[] = "stream lids=0,1,2,3,4,5,6";  // all sources
-    bool reader_requested = write(fd, ask, sizeof(ask)) == sizeof(ask);
-    EXPECT_TRUE(reader_requested);
-
-    log_msg msg;
-    bool read_one = recv(fd, msg.buf, sizeof(msg), 0) > 0;
-
-    EXPECT_TRUE(read_one);
-    if (read_one) {
-        dump_log_msg("user", &msg, -1);
-    }
-
-    fprintf(stderr, "Sleep for >%d seconds logd SO_SNDTIMEO ...\n", sndtimeo);
-    sleep(sleep_time);
-
-    // flush will block if we did not trigger. if it did, last entry returns 0
-    int recv_ret;
-    do {
-        recv_ret = recv(fd, msg.buf, sizeof(msg), 0);
-    } while (recv_ret > 0);
-    int save_errno = (recv_ret < 0) ? errno : 0;
-
-    EXPECT_NE(0U, alarm(old_alarm));
-    sigaction(SIGALRM, &old_sigaction, nullptr);
-
-    EXPECT_EQ(0, recv_ret);
-    if (recv_ret > 0) {
-        dump_log_msg("user", &msg, -1);
-    }
-    EXPECT_EQ(0, save_errno);
-
-    close(fd);
-#else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-#endif
-
-TEST(logd, getEventTag_list) {
-#ifdef __ANDROID__
-    char buffer[256];
-    memset(buffer, 0, sizeof(buffer));
-    snprintf(buffer, sizeof(buffer), "getEventTag name=*");
-    send_to_control(buffer, sizeof(buffer));
-    buffer[sizeof(buffer) - 1] = '\0';
-    char* cp;
-    long ret = strtol(buffer, &cp, 10);
-    EXPECT_GT(ret, 4096);
-#else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(logd, getEventTag_42) {
-#ifdef __ANDROID__
-    char buffer[256];
-    memset(buffer, 0, sizeof(buffer));
-    snprintf(buffer, sizeof(buffer), "getEventTag id=42");
-    send_to_control(buffer, sizeof(buffer));
-    buffer[sizeof(buffer) - 1] = '\0';
-    char* cp;
-    long ret = strtol(buffer, &cp, 10);
-    EXPECT_GT(ret, 16);
-    EXPECT_TRUE(strstr(buffer, "\t(to life the universe etc|3)") != nullptr);
-    EXPECT_TRUE(strstr(buffer, "answer") != nullptr);
-#else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(logd, getEventTag_newentry) {
-#ifdef __ANDROID__
-    char buffer[256];
-    memset(buffer, 0, sizeof(buffer));
-    log_time now(CLOCK_MONOTONIC);
-    char name[64];
-    snprintf(name, sizeof(name), "a%" PRIu64, now.nsec());
-    snprintf(buffer, sizeof(buffer), "getEventTag name=%s format=\"(new|1)\"",
-             name);
-    send_to_control(buffer, sizeof(buffer));
-    buffer[sizeof(buffer) - 1] = '\0';
-    char* cp;
-    long ret = strtol(buffer, &cp, 10);
-    EXPECT_GT(ret, 16);
-    EXPECT_TRUE(strstr(buffer, "\t(new|1)") != nullptr);
-    EXPECT_TRUE(strstr(buffer, name) != nullptr);
-// ToDo: also look for this in /data/misc/logd/event-log-tags and
-// /dev/event-log-tags.
-#else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
-
-TEST(logd, no_epipe) {
-#ifdef __ANDROID__
-    // Actually generating SIGPIPE in logd is racy, since we need to close the socket quicker than
-    // logd finishes writing the data to it, so we try 10 times, which should be enough to trigger
-    // SIGPIPE if logd isn't ignoring SIGPIPE
-    for (int i = 0; i < 10; ++i) {
-        unique_fd sock1(
-                socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM));
-        ASSERT_GT(sock1, 0);
-        unique_fd sock2(
-                socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM));
-        ASSERT_GT(sock2, 0);
-
-        std::string message = "getStatistics 0 1 2 3 4 5 6 7";
-
-        ASSERT_GT(write(sock1, message.c_str(), message.length()), 0);
-        sock1.reset();
-        ASSERT_GT(write(sock2, message.c_str(), message.length()), 0);
-
-        struct pollfd p = {.fd = sock2, .events = POLLIN, .revents = 0};
-
-        int ret = poll(&p, 1, 20);
-        EXPECT_EQ(ret, 1);
-        EXPECT_TRUE(p.revents & POLLIN);
-        EXPECT_FALSE(p.revents & POLL_ERR);
-    }
-#else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
-}
diff --git a/logd/logtagd.rc b/logd/logtagd.rc
deleted file mode 100644
index 248a78c..0000000
--- a/logd/logtagd.rc
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# logtagd event log tag service (debug only)
-#
-on post-fs-data
-    mkdir /data/misc/logd 0750 logd log
-    write /data/misc/logd/event-log-tags ""
-    chown logd log /data/misc/logd/event-log-tags
-    chmod 0600 /data/misc/logd/event-log-tags
-    restorecon /data/misc/logd/event-log-tags
diff --git a/logd/main.cpp b/logd/main.cpp
deleted file mode 100644
index c92c5b7..0000000
--- a/logd/main.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright (C) 2012-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.
- */
-
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/capability.h>
-#include <poll.h>
-#include <sched.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/capability.h>
-#include <sys/klog.h>
-#include <sys/prctl.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#include <memory>
-
-#include <android-base/logging.h>
-#include <android-base/macros.h>
-#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
-#include <cutils/android_get_control_file.h>
-#include <cutils/sockets.h>
-#include <log/event_tag_map.h>
-#include <packagelistparser/packagelistparser.h>
-#include <private/android_filesystem_config.h>
-#include <private/android_logger.h>
-#include <processgroup/sched_policy.h>
-#include <utils/threads.h>
-
-#include "ChattyLogBuffer.h"
-#include "CommandListener.h"
-#include "LogAudit.h"
-#include "LogBuffer.h"
-#include "LogKlog.h"
-#include "LogListener.h"
-#include "LogReader.h"
-#include "LogStatistics.h"
-#include "LogTags.h"
-#include "LogUtils.h"
-#include "SerializedLogBuffer.h"
-#include "SimpleLogBuffer.h"
-
-using android::base::GetBoolProperty;
-using android::base::GetProperty;
-using android::base::SetProperty;
-
-#define KMSG_PRIORITY(PRI)                                 \
-    '<', '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) / 10, \
-        '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) % 10, '>'
-
-// The service is designed to be run by init, it does not respond well to starting up manually. Init
-// has a 'sigstop' feature that sends SIGSTOP to a service immediately before calling exec().  This
-// allows debuggers, etc to be attached to logd at the very beginning, while still having init
-// handle the user, groups, capabilities, files, etc setup.
-static void DropPrivs(bool klogd, bool auditd) {
-    if (set_sched_policy(0, SP_BACKGROUND) < 0) {
-        PLOG(FATAL) << "failed to set background scheduling policy";
-    }
-
-    sched_param param = {};
-    if (sched_setscheduler((pid_t)0, SCHED_BATCH, &param) < 0) {
-        PLOG(FATAL) << "failed to set batch scheduler";
-    }
-
-    if (!GetBoolProperty("ro.debuggable", false)) {
-        if (prctl(PR_SET_DUMPABLE, 0) == -1) {
-            PLOG(FATAL) << "failed to clear PR_SET_DUMPABLE";
-        }
-    }
-
-    std::unique_ptr<struct _cap_struct, int (*)(void*)> caps(cap_init(), cap_free);
-    if (cap_clear(caps.get()) < 0) {
-        PLOG(FATAL) << "cap_clear() failed";
-    }
-    if (klogd) {
-        cap_value_t cap_syslog = CAP_SYSLOG;
-        if (cap_set_flag(caps.get(), CAP_PERMITTED, 1, &cap_syslog, CAP_SET) < 0 ||
-            cap_set_flag(caps.get(), CAP_EFFECTIVE, 1, &cap_syslog, CAP_SET) < 0) {
-            PLOG(FATAL) << "Failed to set CAP_SYSLOG";
-        }
-    }
-    if (auditd) {
-        cap_value_t cap_audit_control = CAP_AUDIT_CONTROL;
-        if (cap_set_flag(caps.get(), CAP_PERMITTED, 1, &cap_audit_control, CAP_SET) < 0 ||
-            cap_set_flag(caps.get(), CAP_EFFECTIVE, 1, &cap_audit_control, CAP_SET) < 0) {
-            PLOG(FATAL) << "Failed to set CAP_AUDIT_CONTROL";
-        }
-    }
-    if (cap_set_proc(caps.get()) < 0) {
-        PLOG(FATAL) << "cap_set_proc() failed";
-    }
-}
-
-// GetBoolProperty that defaults to true if `ro.debuggable == true && ro.config.low_rawm == false`.
-static bool GetBoolPropertyEngSvelteDefault(const std::string& name) {
-    bool default_value =
-            GetBoolProperty("ro.debuggable", false) && !GetBoolProperty("ro.config.low_ram", false);
-
-    return GetBoolProperty(name, default_value);
-}
-
-char* android::uidToName(uid_t u) {
-    struct Userdata {
-        uid_t uid;
-        char* name;
-    } userdata = {
-            .uid = u,
-            .name = nullptr,
-    };
-
-    packagelist_parse(
-            [](pkg_info* info, void* callback_parameter) {
-                auto userdata = reinterpret_cast<Userdata*>(callback_parameter);
-                bool result = true;
-                if (info->uid == userdata->uid) {
-                    userdata->name = strdup(info->name);
-                    // false to stop processing
-                    result = false;
-                }
-                packagelist_free(info);
-                return result;
-            },
-            &userdata);
-
-    return userdata.name;
-}
-
-static void readDmesg(LogAudit* al, LogKlog* kl) {
-    if (!al && !kl) {
-        return;
-    }
-
-    int rc = klogctl(KLOG_SIZE_BUFFER, nullptr, 0);
-    if (rc <= 0) {
-        return;
-    }
-
-    // Margin for additional input race or trailing nul
-    ssize_t len = rc + 1024;
-    std::unique_ptr<char[]> buf(new char[len]);
-
-    rc = klogctl(KLOG_READ_ALL, buf.get(), len);
-    if (rc <= 0) {
-        return;
-    }
-
-    if (rc < len) {
-        len = rc + 1;
-    }
-    buf[--len] = '\0';
-
-    ssize_t sublen;
-    for (char *ptr = nullptr, *tok = buf.get();
-         (rc >= 0) && !!(tok = android::log_strntok_r(tok, len, ptr, sublen));
-         tok = nullptr) {
-        if ((sublen <= 0) || !*tok) continue;
-        if (al) {
-            rc = al->log(tok, sublen);
-        }
-        if (kl) {
-            rc = kl->log(tok, sublen);
-        }
-    }
-}
-
-static int issueReinit() {
-    int sock = TEMP_FAILURE_RETRY(socket_local_client(
-        "logd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM));
-    if (sock < 0) return -errno;
-
-    static const char reinitStr[] = "reinit";
-    ssize_t ret = TEMP_FAILURE_RETRY(write(sock, reinitStr, sizeof(reinitStr)));
-    if (ret < 0) return -errno;
-
-    struct pollfd p;
-    memset(&p, 0, sizeof(p));
-    p.fd = sock;
-    p.events = POLLIN;
-    ret = TEMP_FAILURE_RETRY(poll(&p, 1, 1000));
-    if (ret < 0) return -errno;
-    if ((ret == 0) || !(p.revents & POLLIN)) return -ETIME;
-
-    static const char success[] = "success";
-    char buffer[sizeof(success) - 1];
-    memset(buffer, 0, sizeof(buffer));
-    ret = TEMP_FAILURE_RETRY(read(sock, buffer, sizeof(buffer)));
-    if (ret < 0) return -errno;
-
-    return strncmp(buffer, success, sizeof(success) - 1) != 0;
-}
-
-// Foreground waits for exit of the main persistent threads
-// that are started here. The threads are created to manage
-// UNIX domain client sockets for writing, reading and
-// controlling the user space logger, and for any additional
-// logging plugins like auditd and restart control. Additional
-// transitory per-client threads are created for each reader.
-int main(int argc, char* argv[]) {
-    // We want EPIPE when a reader disconnects, not to terminate logd.
-    signal(SIGPIPE, SIG_IGN);
-    // logd is written under the assumption that the timezone is UTC.
-    // If TZ is not set, persist.sys.timezone is looked up in some time utility
-    // libc functions, including mktime. It confuses the logd time handling,
-    // so here explicitly set TZ to UTC, which overrides the property.
-    setenv("TZ", "UTC", 1);
-    // issue reinit command. KISS argument parsing.
-    if ((argc > 1) && argv[1] && !strcmp(argv[1], "--reinit")) {
-        return issueReinit();
-    }
-
-    android::base::InitLogging(
-            argv, [](android::base::LogId log_id, android::base::LogSeverity severity,
-                     const char* tag, const char* file, unsigned int line, const char* message) {
-                if (tag && strcmp(tag, "logd") != 0) {
-                    auto prefixed_message = android::base::StringPrintf("%s: %s", tag, message);
-                    android::base::KernelLogger(log_id, severity, "logd", file, line,
-                                                prefixed_message.c_str());
-                } else {
-                    android::base::KernelLogger(log_id, severity, "logd", file, line, message);
-                }
-            });
-
-    static const char dev_kmsg[] = "/dev/kmsg";
-    int fdDmesg = android_get_control_file(dev_kmsg);
-    if (fdDmesg < 0) {
-        fdDmesg = TEMP_FAILURE_RETRY(open(dev_kmsg, O_WRONLY | O_CLOEXEC));
-    }
-
-    int fdPmesg = -1;
-    bool klogd = GetBoolPropertyEngSvelteDefault("ro.logd.kernel");
-    if (klogd) {
-        SetProperty("ro.logd.kernel", "true");
-        static const char proc_kmsg[] = "/proc/kmsg";
-        fdPmesg = android_get_control_file(proc_kmsg);
-        if (fdPmesg < 0) {
-            fdPmesg = TEMP_FAILURE_RETRY(
-                open(proc_kmsg, O_RDONLY | O_NDELAY | O_CLOEXEC));
-        }
-        if (fdPmesg < 0) PLOG(ERROR) << "Failed to open " << proc_kmsg;
-    }
-
-    bool auditd = GetBoolProperty("ro.logd.auditd", true);
-    DropPrivs(klogd, auditd);
-
-    // A cache of event log tags
-    LogTags log_tags;
-
-    // Pruning configuration.
-    PruneList prune_list;
-
-    std::string buffer_type = GetProperty("logd.buffer_type", "serialized");
-
-    // Partial (required for chatty) or full logging statistics.
-    LogStatistics log_statistics(GetBoolPropertyEngSvelteDefault("logd.statistics"),
-                                 buffer_type == "serialized");
-
-    // Serves the purpose of managing the last logs times read on a socket connection, and as a
-    // reader lock on a range of log entries.
-    LogReaderList reader_list;
-
-    // LogBuffer is the object which is responsible for holding all log entries.
-    LogBuffer* log_buffer = nullptr;
-    if (buffer_type == "chatty") {
-        log_buffer = new ChattyLogBuffer(&reader_list, &log_tags, &prune_list, &log_statistics);
-    } else if (buffer_type == "serialized") {
-        log_buffer = new SerializedLogBuffer(&reader_list, &log_tags, &log_statistics);
-    } else if (buffer_type == "simple") {
-        log_buffer = new SimpleLogBuffer(&reader_list, &log_tags, &log_statistics);
-    } else {
-        LOG(FATAL) << "buffer_type must be one of 'chatty', 'serialized', or 'simple'";
-    }
-
-    // LogReader listens on /dev/socket/logdr. When a client
-    // connects, log entries in the LogBuffer are written to the client.
-    LogReader* reader = new LogReader(log_buffer, &reader_list);
-    if (reader->startListener()) {
-        return EXIT_FAILURE;
-    }
-
-    // LogListener listens on /dev/socket/logdw for client
-    // initiated log messages. New log entries are added to LogBuffer
-    // and LogReader is notified to send updates to connected clients.
-    LogListener* swl = new LogListener(log_buffer);
-    if (!swl->StartListener()) {
-        return EXIT_FAILURE;
-    }
-
-    // Command listener listens on /dev/socket/logd for incoming logd
-    // administrative commands.
-    CommandListener* cl = new CommandListener(log_buffer, &log_tags, &prune_list, &log_statistics);
-    if (cl->startListener()) {
-        return EXIT_FAILURE;
-    }
-
-    // LogAudit listens on NETLINK_AUDIT socket for selinux
-    // initiated log messages. New log entries are added to LogBuffer
-    // and LogReader is notified to send updates to connected clients.
-    LogAudit* al = nullptr;
-    if (auditd) {
-        int dmesg_fd = GetBoolProperty("ro.logd.auditd.dmesg", true) ? fdDmesg : -1;
-        al = new LogAudit(log_buffer, dmesg_fd, &log_statistics);
-    }
-
-    LogKlog* kl = nullptr;
-    if (klogd) {
-        kl = new LogKlog(log_buffer, fdDmesg, fdPmesg, al != nullptr, &log_statistics);
-    }
-
-    readDmesg(al, kl);
-
-    // failure is an option ... messages are in dmesg (required by standard)
-    if (kl && kl->startListener()) {
-        delete kl;
-    }
-
-    if (al && al->startListener()) {
-        delete al;
-    }
-
-    TEMP_FAILURE_RETRY(pause());
-
-    return EXIT_SUCCESS;
-}
diff --git a/logd/rwlock.h b/logd/rwlock.h
deleted file mode 100644
index c37721e..0000000
--- a/logd/rwlock.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2020 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/LICENSE2.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 <pthread.h>
-
-#include <android-base/macros.h>
-#include <android-base/thread_annotations.h>
-
-// As of the end of May 2020, std::shared_mutex is *not* simply a pthread_rwlock, but rather a
-// combination of std::mutex and std::condition variable, which is obviously less efficient.  This
-// immitates what std::shared_mutex should be doing and is compatible with RAII thread wrappers.
-
-class SHARED_CAPABILITY("mutex") RwLock {
-  public:
-    RwLock() {}
-    ~RwLock() {}
-
-    void lock() ACQUIRE() { pthread_rwlock_wrlock(&rwlock_); }
-    void lock_shared() ACQUIRE_SHARED() { pthread_rwlock_rdlock(&rwlock_); }
-
-    void unlock() RELEASE() { pthread_rwlock_unlock(&rwlock_); }
-
-  private:
-    pthread_rwlock_t rwlock_ = PTHREAD_RWLOCK_INITIALIZER;
-};
-
-// std::shared_lock does not have thread annotations, so we need our own.
-
-class SCOPED_CAPABILITY SharedLock {
-  public:
-    explicit SharedLock(RwLock& lock) ACQUIRE_SHARED(lock) : lock_(lock) { lock_.lock_shared(); }
-    ~SharedLock() RELEASE() { lock_.unlock(); }
-
-    void lock_shared() ACQUIRE_SHARED() { lock_.lock_shared(); }
-    void unlock() RELEASE() { lock_.unlock(); }
-
-    DISALLOW_IMPLICIT_CONSTRUCTORS(SharedLock);
-
-  private:
-    RwLock& lock_;
-};
diff --git a/logwrapper/Android.bp b/logwrapper/Android.bp
deleted file mode 100644
index 8851a47..0000000
--- a/logwrapper/Android.bp
+++ /dev/null
@@ -1,70 +0,0 @@
-cc_defaults {
-    name: "logwrapper_defaults",
-    cflags: [
-        "-Werror",
-    ],
-}
-
-// ========================================================
-// Static and shared library
-// ========================================================
-
-cc_library {
-    name: "liblogwrap",
-    defaults: ["logwrapper_defaults"],
-    recovery_available: true,
-    srcs: ["logwrap.cpp"],
-    shared_libs: [
-        "libcutils",
-        "liblog",
-    ],
-    header_libs: ["libbase_headers"],
-    export_include_dirs: ["include"],
-    local_include_dirs: ["include"],
-}
-
-// ========================================================
-// Executable
-// ========================================================
-
-cc_defaults {
-    name: "logwrapper_common",
-    defaults: ["logwrapper_defaults"],
-    local_include_dirs: ["include"],
-    srcs: [
-        "logwrap.cpp",
-        "logwrapper.cpp",
-    ],
-    header_libs: ["libbase_headers"],
-    shared_libs: ["libcutils", "liblog"],
-}
-
-cc_binary {
-    name: "logwrapper",
-    defaults: ["logwrapper_common"],
-}
-
-cc_binary {
-    name: "logwrapper_vendor",
-    defaults: ["logwrapper_common"],
-    stem: "logwrapper",
-    vendor: true,
-}
-
-// ========================================================
-// Benchmark
-// ========================================================
-
-cc_benchmark {
-    name: "logwrap_fork_execvp_benchmark",
-    defaults: ["logwrapper_defaults"],
-    srcs: [
-        "logwrap_fork_execvp_benchmark.cpp",
-    ],
-    shared_libs: [
-        "libbase",
-        "libcutils",
-        "liblog",
-        "liblogwrap",
-    ],
-}
diff --git a/logwrapper/NOTICE b/logwrapper/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/logwrapper/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
-   Copyright (c) 2005-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.
-
-   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.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
diff --git a/logwrapper/OWNERS b/logwrapper/OWNERS
deleted file mode 100644
index babbe4d..0000000
--- a/logwrapper/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-tomcherry@google.com
diff --git a/logwrapper/include/logwrap/logwrap.h b/logwrapper/include/logwrap/logwrap.h
deleted file mode 100644
index cb40ee2..0000000
--- a/logwrapper/include/logwrap/logwrap.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* system/core/include/logwrap/logwrap.h
- *
- * Copyright 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.
- */
-
-#pragma once
-
-/*
- * Run a command while logging its stdout and stderr
- *
- * Arguments:
- *   argc:   the number of elements in argv
- *   argv:   an array of strings containing the command to be executed and its
- *           arguments as separate strings. argv does not need to be
- *           NULL-terminated
- *   status: the equivalent child status as populated by wait(status). This
- *           value is only valid when logwrap successfully completes. If NULL
- *           the return value of the child will be the function's return value.
- *   forward_signals: set to true if you want to forward SIGINT, SIGQUIT, and
- *           SIGHUP to the child process, while it is running.  You likely do
- *           not need to use this; it is primarily for the logwrapper
- *           executable itself.
- *   log_target: Specify where to log the output of the child, either LOG_NONE,
- *           LOG_ALOG (for the Android system log), LOG_KLOG (for the kernel
- *           log), or LOG_FILE (and you need to specify a pathname in the
- *           file_path argument, otherwise pass NULL).  These are bit fields,
- *           and can be OR'ed together to log to multiple places.
- *   abbreviated: If true, capture up to the first 100 lines and last 4K of
- *           output from the child.  The abbreviated output is not dumped to
- *           the specified log until the child has exited.
- *   file_path: if log_target has the LOG_FILE bit set, then this parameter
- *           must be set to the pathname of the file to log to.
- *
- * Return value:
- *   0 when logwrap successfully run the child process and captured its status
- *   -1 when an internal error occurred
- *   -ECHILD if status is NULL and the child didn't exit properly
- *   the return value of the child if it exited properly and status is NULL
- *
- */
-
-/* Values for the log_target parameter logwrap_fork_execvp() */
-#define LOG_NONE        0
-#define LOG_ALOG        1
-#define LOG_KLOG        2
-#define LOG_FILE        4
-
-int logwrap_fork_execvp(int argc, const char* const* argv, int* status, bool forward_signals,
-                        int log_target, bool abbreviated, const char* file_path);
diff --git a/logwrapper/logwrap.cpp b/logwrapper/logwrap.cpp
deleted file mode 100644
index 5a518bc..0000000
--- a/logwrapper/logwrap.cpp
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- * 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.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <libgen.h>
-#include <poll.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include <algorithm>
-
-#include <android-base/macros.h>
-#include <cutils/klog.h>
-#include <log/log.h>
-#include <logwrap/logwrap.h>
-
-static pthread_mutex_t fd_mutex = PTHREAD_MUTEX_INITIALIZER;
-// Protected by fd_mutex.  These signals must be blocked while modifying as well.
-static pid_t child_pid;
-static struct sigaction old_int;
-static struct sigaction old_quit;
-static struct sigaction old_hup;
-
-#define ERROR(fmt, args...)                         \
-    do {                                            \
-        fprintf(stderr, fmt, ##args);               \
-        ALOG(LOG_ERROR, "logwrapper", fmt, ##args); \
-    } while (0)
-
-#define FATAL_CHILD(fmt, args...) \
-    do {                          \
-        ERROR(fmt, ##args);       \
-        _exit(-1);                \
-    } while (0)
-
-#define MAX_KLOG_TAG 16
-
-/* This is a simple buffer that holds up to the first beginning_buf->buf_size
- * bytes of output from a command.
- */
-#define BEGINNING_BUF_SIZE 0x1000
-struct beginning_buf {
-    char* buf;
-    size_t alloc_len;
-    /* buf_size is the usable space, which is one less than the allocated size */
-    size_t buf_size;
-    size_t used_len;
-};
-
-/* This is a circular buf that holds up to the last ending_buf->buf_size bytes
- * of output from a command after the first beginning_buf->buf_size bytes
- * (which are held in beginning_buf above).
- */
-#define ENDING_BUF_SIZE 0x1000
-struct ending_buf {
-    char* buf;
-    ssize_t alloc_len;
-    /* buf_size is the usable space, which is one less than the allocated size */
-    ssize_t buf_size;
-    ssize_t used_len;
-    /* read and write offsets into the circular buffer */
-    int read;
-    int write;
-};
-
-/* A structure to hold all the abbreviated buf data */
-struct abbr_buf {
-    struct beginning_buf b_buf;
-    struct ending_buf e_buf;
-    int beginning_buf_full;
-};
-
-/* Collect all the various bits of info needed for logging in one place. */
-struct log_info {
-    int log_target;
-    char klog_fmt[MAX_KLOG_TAG * 2];
-    const char* btag;
-    bool abbreviated;
-    FILE* fp;
-    struct abbr_buf a_buf;
-};
-
-/* Forware declaration */
-static void add_line_to_abbr_buf(struct abbr_buf* a_buf, char* linebuf, int linelen);
-
-/* Return 0 on success, and 1 when full */
-static int add_line_to_linear_buf(struct beginning_buf* b_buf, char* line, ssize_t line_len) {
-    int full = 0;
-
-    if ((line_len + b_buf->used_len) > b_buf->buf_size) {
-        full = 1;
-    } else {
-        /* Add to the end of the buf */
-        memcpy(b_buf->buf + b_buf->used_len, line, line_len);
-        b_buf->used_len += line_len;
-    }
-
-    return full;
-}
-
-static void add_line_to_circular_buf(struct ending_buf* e_buf, char* line, ssize_t line_len) {
-    ssize_t free_len;
-    ssize_t needed_space;
-    int cnt;
-
-    if (e_buf->buf == nullptr) {
-        return;
-    }
-
-    if (line_len > e_buf->buf_size) {
-        return;
-    }
-
-    free_len = e_buf->buf_size - e_buf->used_len;
-
-    if (line_len > free_len) {
-        /* remove oldest entries at read, and move read to make
-         * room for the new string */
-        needed_space = line_len - free_len;
-        e_buf->read = (e_buf->read + needed_space) % e_buf->buf_size;
-        e_buf->used_len -= needed_space;
-    }
-
-    /* Copy the line into the circular buffer, dealing with possible
-     * wraparound.
-     */
-    cnt = std::min(line_len, e_buf->buf_size - e_buf->write);
-    memcpy(e_buf->buf + e_buf->write, line, cnt);
-    if (cnt < line_len) {
-        memcpy(e_buf->buf, line + cnt, line_len - cnt);
-    }
-    e_buf->used_len += line_len;
-    e_buf->write = (e_buf->write + line_len) % e_buf->buf_size;
-}
-
-/* Log directly to the specified log */
-static void do_log_line(struct log_info* log_info, const char* line) {
-    if (log_info->log_target & LOG_KLOG) {
-        klog_write(6, log_info->klog_fmt, line);
-    }
-    if (log_info->log_target & LOG_ALOG) {
-        ALOG(LOG_INFO, log_info->btag, "%s", line);
-    }
-    if (log_info->log_target & LOG_FILE) {
-        fprintf(log_info->fp, "%s\n", line);
-    }
-}
-
-/* Log to either the abbreviated buf, or directly to the specified log
- * via do_log_line() above.
- */
-static void log_line(struct log_info* log_info, char* line, int len) {
-    if (log_info->abbreviated) {
-        add_line_to_abbr_buf(&log_info->a_buf, line, len);
-    } else {
-        do_log_line(log_info, line);
-    }
-}
-
-/*
- * The kernel will take a maximum of 1024 bytes in any single write to
- * the kernel logging device file, so find and print each line one at
- * a time.  The allocated size for buf should be at least 1 byte larger
- * than buf_size (the usable size of the buffer) to make sure there is
- * room to temporarily stuff a null byte to terminate a line for logging.
- */
-static void print_buf_lines(struct log_info* log_info, char* buf, int buf_size) {
-    char* line_start;
-    char c;
-    int i;
-
-    line_start = buf;
-    for (i = 0; i < buf_size; i++) {
-        if (*(buf + i) == '\n') {
-            /* Found a line ending, print the line and compute new line_start */
-            /* Save the next char and replace with \0 */
-            c = *(buf + i + 1);
-            *(buf + i + 1) = '\0';
-            do_log_line(log_info, line_start);
-            /* Restore the saved char */
-            *(buf + i + 1) = c;
-            line_start = buf + i + 1;
-        } else if (*(buf + i) == '\0') {
-            /* The end of the buffer, print the last bit */
-            do_log_line(log_info, line_start);
-            break;
-        }
-    }
-    /* If the buffer was completely full, and didn't end with a newline, just
-     * ignore the partial last line.
-     */
-}
-
-static void init_abbr_buf(struct abbr_buf* a_buf) {
-    char* new_buf;
-
-    memset(a_buf, 0, sizeof(struct abbr_buf));
-    new_buf = static_cast<char*>(malloc(BEGINNING_BUF_SIZE));
-    if (new_buf) {
-        a_buf->b_buf.buf = new_buf;
-        a_buf->b_buf.alloc_len = BEGINNING_BUF_SIZE;
-        a_buf->b_buf.buf_size = BEGINNING_BUF_SIZE - 1;
-    }
-    new_buf = static_cast<char*>(malloc(ENDING_BUF_SIZE));
-    if (new_buf) {
-        a_buf->e_buf.buf = new_buf;
-        a_buf->e_buf.alloc_len = ENDING_BUF_SIZE;
-        a_buf->e_buf.buf_size = ENDING_BUF_SIZE - 1;
-    }
-}
-
-static void free_abbr_buf(struct abbr_buf* a_buf) {
-    free(a_buf->b_buf.buf);
-    free(a_buf->e_buf.buf);
-}
-
-static void add_line_to_abbr_buf(struct abbr_buf* a_buf, char* linebuf, int linelen) {
-    if (!a_buf->beginning_buf_full) {
-        a_buf->beginning_buf_full = add_line_to_linear_buf(&a_buf->b_buf, linebuf, linelen);
-    }
-    if (a_buf->beginning_buf_full) {
-        add_line_to_circular_buf(&a_buf->e_buf, linebuf, linelen);
-    }
-}
-
-static void print_abbr_buf(struct log_info* log_info) {
-    struct abbr_buf* a_buf = &log_info->a_buf;
-
-    /* Add the abbreviated output to the kernel log */
-    if (a_buf->b_buf.alloc_len) {
-        print_buf_lines(log_info, a_buf->b_buf.buf, a_buf->b_buf.used_len);
-    }
-
-    /* Print an ellipsis to indicate that the buffer has wrapped or
-     * is full, and some data was not logged.
-     */
-    if (a_buf->e_buf.used_len == a_buf->e_buf.buf_size) {
-        do_log_line(log_info, "...\n");
-    }
-
-    if (a_buf->e_buf.used_len == 0) {
-        return;
-    }
-
-    /* Simplest way to print the circular buffer is allocate a second buf
-     * of the same size, and memcpy it so it's a simple linear buffer,
-     * and then cal print_buf_lines on it */
-    if (a_buf->e_buf.read < a_buf->e_buf.write) {
-        /* no wrap around, just print it */
-        print_buf_lines(log_info, a_buf->e_buf.buf + a_buf->e_buf.read, a_buf->e_buf.used_len);
-    } else {
-        /* The circular buffer will always have at least 1 byte unused,
-         * so by allocating alloc_len here we will have at least
-         * 1 byte of space available as required by print_buf_lines().
-         */
-        char* nbuf = static_cast<char*>(malloc(a_buf->e_buf.alloc_len));
-        if (!nbuf) {
-            return;
-        }
-        int first_chunk_len = a_buf->e_buf.buf_size - a_buf->e_buf.read;
-        memcpy(nbuf, a_buf->e_buf.buf + a_buf->e_buf.read, first_chunk_len);
-        /* copy second chunk */
-        memcpy(nbuf + first_chunk_len, a_buf->e_buf.buf, a_buf->e_buf.write);
-        print_buf_lines(log_info, nbuf, first_chunk_len + a_buf->e_buf.write);
-        free(nbuf);
-    }
-}
-
-static void signal_handler(int signal_num);
-
-static void block_signals(sigset_t* oldset) {
-    sigset_t blockset;
-
-    sigemptyset(&blockset);
-    sigaddset(&blockset, SIGINT);
-    sigaddset(&blockset, SIGQUIT);
-    sigaddset(&blockset, SIGHUP);
-    pthread_sigmask(SIG_BLOCK, &blockset, oldset);
-}
-
-static void unblock_signals(sigset_t* oldset) {
-    pthread_sigmask(SIG_SETMASK, oldset, nullptr);
-}
-
-static void setup_signal_handlers(pid_t pid) {
-    struct sigaction handler = {.sa_handler = signal_handler};
-
-    child_pid = pid;
-    sigaction(SIGINT, &handler, &old_int);
-    sigaction(SIGQUIT, &handler, &old_quit);
-    sigaction(SIGHUP, &handler, &old_hup);
-}
-
-static void restore_signal_handlers() {
-    sigaction(SIGINT, &old_int, nullptr);
-    sigaction(SIGQUIT, &old_quit, nullptr);
-    sigaction(SIGHUP, &old_hup, nullptr);
-    child_pid = 0;
-}
-
-static void signal_handler(int signal_num) {
-    if (child_pid == 0 || kill(child_pid, signal_num) != 0) {
-        restore_signal_handlers();
-        raise(signal_num);
-    }
-}
-
-static int parent(const char* tag, int parent_read, pid_t pid, int* chld_sts, int log_target,
-                  bool abbreviated, const char* file_path, bool forward_signals) {
-    int status = 0;
-    char buffer[4096];
-    struct pollfd poll_fds[] = {
-            {
-                    .fd = parent_read,
-                    .events = POLLIN,
-            },
-    };
-    int rc = 0;
-    int fd;
-
-    struct log_info log_info;
-
-    int a = 0;  // start index of unprocessed data
-    int b = 0;  // end index of unprocessed data
-    int sz;
-    bool found_child = false;
-    // There is a very small chance that opening child_ptty in the child will fail, but in this case
-    // POLLHUP will not be generated below.  Therefore, we use a 1 second timeout for poll() until
-    // we receive a message from child_ptty.  If this times out, we call waitpid() with WNOHANG to
-    // check the status of the child process and exit appropriately if it has terminated.
-    bool received_messages = false;
-    char tmpbuf[256];
-
-    log_info.btag = basename(tag);
-    if (!log_info.btag) {
-        log_info.btag = tag;
-    }
-
-    if (abbreviated && (log_target == LOG_NONE)) {
-        abbreviated = 0;
-    }
-    if (abbreviated) {
-        init_abbr_buf(&log_info.a_buf);
-    }
-
-    if (log_target & LOG_KLOG) {
-        snprintf(log_info.klog_fmt, sizeof(log_info.klog_fmt), "<6>%.*s: %%s\n", MAX_KLOG_TAG,
-                 log_info.btag);
-    }
-
-    if ((log_target & LOG_FILE) && !file_path) {
-        /* No file_path specified, clear the LOG_FILE bit */
-        log_target &= ~LOG_FILE;
-    }
-
-    if (log_target & LOG_FILE) {
-        fd = open(file_path, O_WRONLY | O_CREAT | O_CLOEXEC, 0664);
-        if (fd < 0) {
-            ERROR("Cannot log to file %s\n", file_path);
-            log_target &= ~LOG_FILE;
-        } else {
-            lseek(fd, 0, SEEK_END);
-            log_info.fp = fdopen(fd, "a");
-        }
-    }
-
-    log_info.log_target = log_target;
-    log_info.abbreviated = abbreviated;
-
-    while (!found_child) {
-        int timeout = received_messages ? -1 : 1000;
-        if (TEMP_FAILURE_RETRY(poll(poll_fds, arraysize(poll_fds), timeout)) < 0) {
-            ERROR("poll failed\n");
-            rc = -1;
-            goto err_poll;
-        }
-
-        if (poll_fds[0].revents & POLLIN) {
-            received_messages = true;
-            sz = TEMP_FAILURE_RETRY(read(parent_read, &buffer[b], sizeof(buffer) - 1 - b));
-
-            sz += b;
-            // Log one line at a time
-            for (b = 0; b < sz; b++) {
-                if (buffer[b] == '\r') {
-                    if (abbreviated) {
-                        /* The abbreviated logging code uses newline as
-                         * the line separator.  Lucikly, the pty layer
-                         * helpfully cooks the output of the command
-                         * being run and inserts a CR before NL.  So
-                         * I just change it to NL here when doing
-                         * abbreviated logging.
-                         */
-                        buffer[b] = '\n';
-                    } else {
-                        buffer[b] = '\0';
-                    }
-                } else if (buffer[b] == '\n') {
-                    buffer[b] = '\0';
-                    log_line(&log_info, &buffer[a], b - a);
-                    a = b + 1;
-                }
-            }
-
-            if (a == 0 && b == sizeof(buffer) - 1) {
-                // buffer is full, flush
-                buffer[b] = '\0';
-                log_line(&log_info, &buffer[a], b - a);
-                b = 0;
-            } else if (a != b) {
-                // Keep left-overs
-                b -= a;
-                memmove(buffer, &buffer[a], b);
-                a = 0;
-            } else {
-                a = 0;
-                b = 0;
-            }
-        }
-
-        if (!received_messages || (poll_fds[0].revents & POLLHUP)) {
-            int ret;
-            sigset_t oldset;
-
-            if (forward_signals) {
-                // Our signal handlers forward these signals to 'child_pid', but waitpid() may reap
-                // the child, so we must block these signals until we either 1) conclude that the
-                // child is still running or 2) determine the child has been reaped and we have
-                // reset the signals to their original disposition.
-                block_signals(&oldset);
-            }
-
-            int flags = (poll_fds[0].revents & POLLHUP) ? 0 : WNOHANG;
-            ret = TEMP_FAILURE_RETRY(waitpid(pid, &status, flags));
-            if (ret < 0) {
-                rc = errno;
-                ALOG(LOG_ERROR, "logwrap", "waitpid failed with %s\n", strerror(errno));
-                goto err_waitpid;
-            }
-            if (ret > 0) {
-                found_child = true;
-            }
-
-            if (forward_signals) {
-                if (found_child) {
-                    restore_signal_handlers();
-                }
-                unblock_signals(&oldset);
-            }
-        }
-    }
-
-    if (chld_sts != nullptr) {
-        *chld_sts = status;
-    } else {
-        if (WIFEXITED(status))
-            rc = WEXITSTATUS(status);
-        else
-            rc = -ECHILD;
-    }
-
-    // Flush remaining data
-    if (a != b) {
-        buffer[b] = '\0';
-        log_line(&log_info, &buffer[a], b - a);
-    }
-
-    /* All the output has been processed, time to dump the abbreviated output */
-    if (abbreviated) {
-        print_abbr_buf(&log_info);
-    }
-
-    if (WIFEXITED(status)) {
-        if (WEXITSTATUS(status)) {
-            snprintf(tmpbuf, sizeof(tmpbuf), "%s terminated by exit(%d)\n", log_info.btag,
-                     WEXITSTATUS(status));
-            do_log_line(&log_info, tmpbuf);
-        }
-    } else {
-        if (WIFSIGNALED(status)) {
-            snprintf(tmpbuf, sizeof(tmpbuf), "%s terminated by signal %d\n", log_info.btag,
-                     WTERMSIG(status));
-            do_log_line(&log_info, tmpbuf);
-        } else if (WIFSTOPPED(status)) {
-            snprintf(tmpbuf, sizeof(tmpbuf), "%s stopped by signal %d\n", log_info.btag,
-                     WSTOPSIG(status));
-            do_log_line(&log_info, tmpbuf);
-        }
-    }
-
-err_waitpid:
-err_poll:
-    if (log_target & LOG_FILE) {
-        fclose(log_info.fp); /* Also closes underlying fd */
-    }
-    if (abbreviated) {
-        free_abbr_buf(&log_info.a_buf);
-    }
-    return rc;
-}
-
-static void child(int argc, const char* const* argv) {
-    // create null terminated argv_child array
-    char* argv_child[argc + 1];
-    memcpy(argv_child, argv, argc * sizeof(char*));
-    argv_child[argc] = nullptr;
-
-    if (execvp(argv_child[0], argv_child)) {
-        FATAL_CHILD("executing %s failed: %s\n", argv_child[0], strerror(errno));
-    }
-}
-
-int logwrap_fork_execvp(int argc, const char* const* argv, int* status, bool forward_signals,
-                        int log_target, bool abbreviated, const char* file_path) {
-    pid_t pid;
-    int parent_ptty;
-    sigset_t oldset;
-    int rc = 0;
-
-    rc = pthread_mutex_lock(&fd_mutex);
-    if (rc) {
-        ERROR("failed to lock signal_fd mutex\n");
-        goto err_lock;
-    }
-
-    /* Use ptty instead of socketpair so that STDOUT is not buffered */
-    parent_ptty = TEMP_FAILURE_RETRY(posix_openpt(O_RDWR | O_CLOEXEC));
-    if (parent_ptty < 0) {
-        ERROR("Cannot create parent ptty\n");
-        rc = -1;
-        goto err_open;
-    }
-
-    char child_devname[64];
-    if (grantpt(parent_ptty) || unlockpt(parent_ptty) ||
-        ptsname_r(parent_ptty, child_devname, sizeof(child_devname)) != 0) {
-        ERROR("Problem with /dev/ptmx\n");
-        rc = -1;
-        goto err_ptty;
-    }
-
-    if (forward_signals) {
-        // Block these signals until we have the child pid and our signal handlers set up.
-        block_signals(&oldset);
-    }
-
-    pid = fork();
-    if (pid < 0) {
-        ERROR("Failed to fork\n");
-        rc = -1;
-        goto err_fork;
-    } else if (pid == 0) {
-        pthread_mutex_unlock(&fd_mutex);
-        if (forward_signals) {
-            unblock_signals(&oldset);
-        }
-
-        setsid();
-
-        int child_ptty = TEMP_FAILURE_RETRY(open(child_devname, O_RDWR | O_CLOEXEC));
-        if (child_ptty < 0) {
-            FATAL_CHILD("Cannot open child_ptty: %s\n", strerror(errno));
-        }
-        close(parent_ptty);
-
-        dup2(child_ptty, 1);
-        dup2(child_ptty, 2);
-        close(child_ptty);
-
-        child(argc, argv);
-    } else {
-        if (forward_signals) {
-            setup_signal_handlers(pid);
-            unblock_signals(&oldset);
-        }
-
-        rc = parent(argv[0], parent_ptty, pid, status, log_target, abbreviated, file_path,
-                    forward_signals);
-
-        if (forward_signals) {
-            restore_signal_handlers();
-        }
-    }
-
-err_fork:
-    if (forward_signals) {
-        unblock_signals(&oldset);
-    }
-err_ptty:
-    close(parent_ptty);
-err_open:
-    pthread_mutex_unlock(&fd_mutex);
-err_lock:
-    return rc;
-}
diff --git a/logwrapper/logwrap_fork_execvp_benchmark.cpp b/logwrapper/logwrap_fork_execvp_benchmark.cpp
deleted file mode 100644
index b2d0c71..0000000
--- a/logwrapper/logwrap_fork_execvp_benchmark.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2017 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 "logwrap/logwrap.h"
-
-#include <android-base/logging.h>
-#include <benchmark/benchmark.h>
-
-static void BM_android_fork_execvp_ext(benchmark::State& state) {
-    const char* argv[] = {"/system/bin/echo", "hello", "world"};
-    const int argc = 3;
-    while (state.KeepRunning()) {
-        int rc = logwrap_fork_execvp(argc, argv, nullptr, false, LOG_NONE, false, nullptr);
-        CHECK_EQ(0, rc);
-    }
-}
-BENCHMARK(BM_android_fork_execvp_ext);
-
-BENCHMARK_MAIN();
diff --git a/logwrapper/logwrapper.cpp b/logwrapper/logwrapper.cpp
deleted file mode 100644
index 7118d12..0000000
--- a/logwrapper/logwrapper.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include <cutils/klog.h>
-#include <log/log.h>
-#include <logwrap/logwrap.h>
-
-void fatal(const char* msg) {
-    fprintf(stderr, "%s", msg);
-    ALOG(LOG_ERROR, "logwrapper", "%s", msg);
-    exit(-1);
-}
-
-void usage() {
-    fatal("Usage: logwrapper [-a] [-d] [-k] BINARY [ARGS ...]\n"
-          "\n"
-          "Forks and executes BINARY ARGS, redirecting stdout and stderr to\n"
-          "the Android logging system. Tag is set to BINARY, priority is\n"
-          "always LOG_INFO.\n"
-          "\n"
-          "-a: Causes logwrapper to do abbreviated logging.\n"
-          "    This logs up to the first 4K and last 4K of the command\n"
-          "    being run, and logs the output when the command exits\n"
-          "-d: Causes logwrapper to SIGSEGV when BINARY terminates\n"
-          "    fault address is set to the status of wait()\n"
-          "-k: Causes logwrapper to log to the kernel log instead of\n"
-          "    the Android system log\n");
-}
-
-int main(int argc, char* argv[]) {
-    int seg_fault_on_exit = 0;
-    int log_target = LOG_ALOG;
-    bool abbreviated = false;
-    int ch;
-    int status = 0xAAAA;
-    int rc;
-
-    while ((ch = getopt(argc, argv, "adk")) != -1) {
-        switch (ch) {
-            case 'a':
-                abbreviated = true;
-                break;
-            case 'd':
-                seg_fault_on_exit = 1;
-                break;
-            case 'k':
-                log_target = LOG_KLOG;
-                klog_set_level(6);
-                break;
-            case '?':
-            default:
-                usage();
-        }
-    }
-    argc -= optind;
-    argv += optind;
-
-    if (argc < 1) {
-        usage();
-    }
-
-    rc = logwrap_fork_execvp(argc, &argv[0], &status, true, log_target, abbreviated, nullptr);
-    if (!rc) {
-        if (WIFEXITED(status))
-            rc = WEXITSTATUS(status);
-        else
-            rc = -ECHILD;
-    }
-
-    if (seg_fault_on_exit) {
-        uintptr_t fault_address = (uintptr_t)status;
-        *(int*)fault_address = 0;  // causes SIGSEGV with fault_address = status
-    }
-
-    return rc;
-}
diff --git a/rootdir/avb/Android.mk b/rootdir/avb/Android.mk
index f96ffdd..3978593 100644
--- a/rootdir/avb/Android.mk
+++ b/rootdir/avb/Android.mk
@@ -1,5 +1,11 @@
 LOCAL_PATH:= $(call my-dir)
 
+ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
+  my_gsi_avb_keys_path := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb
+else
+  my_gsi_avb_keys_path := $(TARGET_RAMDISK_OUT)/avb
+endif
+
 #######################################
 # q-gsi.avbpubkey
 include $(CLEAR_VARS)
@@ -7,11 +13,7 @@
 LOCAL_MODULE := q-gsi.avbpubkey
 LOCAL_MODULE_CLASS := ETC
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
-ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
-LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb
-else
-LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT)/avb
-endif
+LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path)
 
 include $(BUILD_PREBUILT)
 
@@ -22,11 +24,7 @@
 LOCAL_MODULE := q-developer-gsi.avbpubkey
 LOCAL_MODULE_CLASS := ETC
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
-ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
-LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb
-else
-LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT)/avb
-endif
+LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path)
 
 include $(BUILD_PREBUILT)
 
@@ -37,11 +35,7 @@
 LOCAL_MODULE := r-gsi.avbpubkey
 LOCAL_MODULE_CLASS := ETC
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
-ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
-LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb
-else
-LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT)/avb
-endif
+LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path)
 
 include $(BUILD_PREBUILT)
 
@@ -52,11 +46,7 @@
 LOCAL_MODULE := r-developer-gsi.avbpubkey
 LOCAL_MODULE_CLASS := ETC
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
-ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
-LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb
-else
-LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT)/avb
-endif
+LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path)
 
 include $(BUILD_PREBUILT)
 
@@ -67,11 +57,7 @@
 LOCAL_MODULE := s-gsi.avbpubkey
 LOCAL_MODULE_CLASS := ETC
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
-ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
-LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb
-else
-LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT)/avb
-endif
+LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path)
 
 include $(BUILD_PREBUILT)
 
@@ -82,10 +68,8 @@
 LOCAL_MODULE := s-developer-gsi.avbpubkey
 LOCAL_MODULE_CLASS := ETC
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
-ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
-LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/avb
-else
-LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT)/avb
-endif
+LOCAL_MODULE_PATH := $(my_gsi_avb_keys_path)
 
 include $(BUILD_PREBUILT)
+
+my_gsi_avb_keys_path :=
diff --git a/rootdir/etc/public.libraries.android.txt b/rootdir/etc/public.libraries.android.txt
index 5de422f..967205f 100644
--- a/rootdir/etc/public.libraries.android.txt
+++ b/rootdir/etc/public.libraries.android.txt
@@ -10,6 +10,7 @@
 libGLESv1_CM.so
 libGLESv2.so
 libGLESv3.so
+libicu.so
 libicui18n.so
 libicuuc.so
 libjnigraphics.so
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 9b0cf13..7edf3c3 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -182,6 +182,9 @@
     mount binder binder /dev/binderfs stats=global
     chmod 0755 /dev/binderfs
 
+    # Mount fusectl
+    mount fusectl none /sys/fs/fuse/connections
+
     symlink /dev/binderfs/binder /dev/binder
     symlink /dev/binderfs/hwbinder /dev/hwbinder
     symlink /dev/binderfs/vndbinder /dev/vndbinder
@@ -324,16 +327,6 @@
     chmod 0664 /dev/cpuset/restricted/tasks
     chmod 0664 /dev/cpuset/tasks
 
-    # freezer cgroup entries
-    mkdir /dev/freezer/frozen
-    write /dev/freezer/frozen/freezer.state FROZEN
-    chown system system /dev/freezer/cgroup.procs
-    chown system system /dev/freezer/frozen
-    chown system system /dev/freezer/frozen/freezer.state
-    chown system system /dev/freezer/frozen/cgroup.procs
-
-    chmod 0444 /dev/freezer/frozen/freezer.state
-
     # make the PSI monitor accessible to others
     chown system system /proc/pressure/memory
     chmod 0664 /proc/pressure/memory
@@ -348,8 +341,6 @@
     # This is needed by any process that uses socket tagging.
     chmod 0644 /dev/xt_qtaguid
 
-    chown root root /dev/cg2_bpf
-    chmod 0600 /dev/cg2_bpf
     mount bpf bpf /sys/fs/bpf nodev noexec nosuid
 
     # Create location for fs_mgr to store abbreviated output from filesystem
@@ -473,6 +464,10 @@
     # The bind+remount combination allows this to work in containers.
     mount rootfs rootfs / remount bind ro nodev
 
+    # Mount default storage into root namespace
+    mount none /mnt/user/0 /storage bind rec
+    mount none none /storage slave rec
+
     # Make sure /sys/kernel/debug (if present) is labeled properly
     # Note that tracefs may be mounted under debug, so we need to cross filesystems
     restorecon --recursive --cross-filesystems /sys/kernel/debug
@@ -522,6 +517,7 @@
     mkdir /metadata/bootstat 0750 system log
     mkdir /metadata/ota 0700 root system
     mkdir /metadata/ota/snapshots 0700 root system
+    mkdir /metadata/userspacereboot 0770 root system
 
     mkdir /metadata/apex 0700 root system
     mkdir /metadata/apex/sessions 0700 root system
@@ -532,6 +528,7 @@
     # no-op.
     restorecon_recursive /metadata/apex
 
+    mkdir /metadata/staged-install 0770 root system
 on late-fs
     # Ensure that tracefs has the correct permissions.
     # This does not work correctly if it is called in post-fs.
@@ -564,13 +561,19 @@
     # Make sure that apexd is started in the default namespace
     enter_default_mount_ns
 
+    # Start tombstoned early to be able to store tombstones.
+    mkdir /data/tombstones 0771 system system encryption=Require
+    mkdir /data/vendor/tombstones 0771 root root
+    mkdir /data/vendor/tombstones/wifi 0771 wifi wifi
+    start tombstoned
+
     # /data/apex is now available. Start apexd to scan and activate APEXes.
     mkdir /data/apex 0755 root system encryption=None
     mkdir /data/apex/active 0755 root system
     mkdir /data/apex/backup 0700 root system
     mkdir /data/apex/hashtree 0700 root system
     mkdir /data/apex/sessions 0700 root system
-    mkdir /data/app-staging 0750 system system encryption=None
+    mkdir /data/app-staging 0750 system system encryption=DeleteIfNecessary
     start apexd
 
     # Avoid predictable entropy pool. Carry over entropy from previous boot.
@@ -666,9 +669,15 @@
     mkdir /data/app-lib 0771 system system encryption=Require
     mkdir /data/app 0771 system system encryption=Require
     mkdir /data/property 0700 root root encryption=Require
-    mkdir /data/tombstones 0771 system system encryption=Require
-    mkdir /data/vendor/tombstones 0771 root root
-    mkdir /data/vendor/tombstones/wifi 0771 wifi wifi
+
+    # Create directories to push tests to for each linker namespace.
+    # Create the subdirectories in case the first test is run as root
+    # so it doesn't end up owned by root.
+    mkdir /data/local/tests 0700 shell shell
+    mkdir /data/local/tests/product 0700 shell shell
+    mkdir /data/local/tests/system 0700 shell shell
+    mkdir /data/local/tests/unrestricted 0700 shell shell
+    mkdir /data/local/tests/vendor 0700 shell shell
 
     # create dalvik-cache, so as to enforce our permissions
     mkdir /data/dalvik-cache 0771 root root encryption=Require
@@ -802,34 +811,19 @@
     # IOCTLs on ashmem fds any more.
     setprop sys.use_memfd false
 
-    # Explicitly disable FUSE
-    setprop persist.sys.fuse false
-
     # Set fscklog permission
     chown root system /dev/fscklogs/log
     chmod 0770 /dev/fscklogs/log
 
-# Switch between sdcardfs and FUSE depending on persist property
-# TODO: Move this to ro property before launch because FDE devices
-# interact with persistent properties differently during boot
-on zygote-start && property:persist.sys.fuse=true
-  # Mount default storage into root namespace
-  mount none /mnt/user/0 /storage bind rec
-  mount none none /storage slave rec
-on zygote-start && property:persist.sys.fuse=false
-  # Mount default storage into root namespace
-  mount none /mnt/runtime/default /storage bind rec
-  mount none none /storage slave rec
-on zygote-start && property:persist.sys.fuse=""
-  # Mount default storage into root namespace
-  mount none /mnt/runtime/default /storage bind rec
-  mount none none /storage slave rec
+    # Enable FUSE by default
+    setprop persist.sys.fuse true
 
 # It is recommended to put unnecessary data/ initialization from post-fs-data
 # to start-zygote in device's init.rc to unblock zygote start.
 on zygote-start && property:ro.crypto.state=unencrypted
     # A/B update verifier that marks a successful boot.
     exec_start update_verifier_nonencrypted
+    start statsd
     start netd
     start zygote
     start zygote_secondary
@@ -837,6 +831,7 @@
 on zygote-start && property:ro.crypto.state=unsupported
     # A/B update verifier that marks a successful boot.
     exec_start update_verifier_nonencrypted
+    start statsd
     start netd
     start zygote
     start zygote_secondary
@@ -844,6 +839,7 @@
 on zygote-start && property:ro.crypto.state=encrypted && property:ro.crypto.type=file
     # A/B update verifier that marks a successful boot.
     exec_start update_verifier_nonencrypted
+    start statsd
     start netd
     start zygote
     start zygote_secondary
diff --git a/rootdir/init.zygote32.rc b/rootdir/init.zygote32.rc
index 9adbcba..e827cf5 100644
--- a/rootdir/init.zygote32.rc
+++ b/rootdir/init.zygote32.rc
@@ -5,6 +5,7 @@
     group root readproc reserved_disk
     socket zygote stream 660 root system
     socket usap_pool_primary stream 660 root system
+    onrestart exec_background - system system -- /system/bin/vdc volume abort_fuse
     onrestart write /sys/power/state on
     onrestart restart audioserver
     onrestart restart cameraserver
diff --git a/rootdir/init.zygote64.rc b/rootdir/init.zygote64.rc
index 0e69b16..adc7031 100644
--- a/rootdir/init.zygote64.rc
+++ b/rootdir/init.zygote64.rc
@@ -5,6 +5,7 @@
     group root readproc reserved_disk
     socket zygote stream 660 root system
     socket usap_pool_primary stream 660 root system
+    onrestart exec_background - system system -- /system/bin/vdc volume abort_fuse
     onrestart write /sys/power/state on
     onrestart restart audioserver
     onrestart restart cameraserver
diff --git a/rootdir/init.zygote64_32.rc b/rootdir/init.zygote64_32.rc
index 3e80168..fb9e99b 100644
--- a/rootdir/init.zygote64_32.rc
+++ b/rootdir/init.zygote64_32.rc
@@ -5,13 +5,14 @@
     group root readproc reserved_disk
     socket zygote stream 660 root system
     socket usap_pool_primary stream 660 root system
+    onrestart exec_background - system system -- /system/bin/vdc volume abort_fuse
     onrestart write /sys/power/state on
     onrestart restart audioserver
     onrestart restart cameraserver
     onrestart restart media
     onrestart restart netd
     onrestart restart wificond
-    writepid /dev/cpuset/foreground/tasks
+    task_profiles ProcessCapacityHigh MaxPerformance
 
 service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote --socket-name=zygote_secondary --enable-lazy-preload
     class main
@@ -21,4 +22,4 @@
     socket zygote_secondary stream 660 root system
     socket usap_pool_secondary stream 660 root system
     onrestart restart zygote
-    writepid /dev/cpuset/foreground/tasks
+    task_profiles ProcessCapacityHigh MaxPerformance
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
index 9c2cdf2..1994bdb 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -17,6 +17,9 @@
     devname uevent_devpath
     dirname /dev/snd
 
+subsystem dma_heap
+   devname uevent_devpath
+   dirname /dev/dma_heap
 # ueventd can only set permissions on device nodes and their associated
 # sysfs attributes, not on arbitrary paths.
 #
@@ -39,6 +42,7 @@
 /dev/vndbinder            0666   root       root
 
 /dev/pmsg0                0222   root       log
+/dev/dma_heap/system      0666   system     system
 
 # kms driver for drm based gpu
 /dev/dri/*                0666   root       graphics
diff --git a/run-as/Android.bp b/run-as/Android.bp
index 840a43c..accd07d 100644
--- a/run-as/Android.bp
+++ b/run-as/Android.bp
@@ -25,4 +25,5 @@
         "libpackagelistparser",
         "libminijail",
     ],
+    header_libs: ["libcutils_headers"],
 }
diff --git a/toolbox/start.cpp b/toolbox/start.cpp
index 46314cf..cffb89c 100644
--- a/toolbox/start.cpp
+++ b/toolbox/start.cpp
@@ -37,6 +37,7 @@
 
 static void ControlDefaultServices(bool start) {
     std::vector<std::string> services = {
+        "iorapd",
         "netd",
         "surfaceflinger",
         "audioserver",
@@ -91,4 +92,4 @@
 
 extern "C" int stop_main(int argc, char** argv) {
     return StartStop(argc, argv, false);
-}
+}
\ No newline at end of file
diff --git a/trusty/keymaster/Android.bp b/trusty/keymaster/Android.bp
index 6840baa..27e1a3f 100644
--- a/trusty/keymaster/Android.bp
+++ b/trusty/keymaster/Android.bp
@@ -75,3 +75,36 @@
 
     vintf_fragments: ["4.0/android.hardware.keymaster@4.0-service.trusty.xml"],
 }
+
+prebuilt_etc {
+    name: "keymaster_soft_attestation_keys.xml",
+    vendor: true,
+    src: "set_attestation_key/keymaster_soft_attestation_keys.xml",
+}
+
+cc_binary {
+    name: "trusty_keymaster_set_attestation_key",
+    vendor: true,
+
+    srcs: [
+        "set_attestation_key/set_attestation_key.cpp",
+        "ipc/trusty_keymaster_ipc.cpp",
+    ],
+
+    local_include_dirs: ["include"],
+
+    shared_libs: [
+        "libc",
+        "libcrypto",
+        "liblog",
+        "libtrusty",
+        "libhardware",
+        "libkeymaster_messages",
+        "libxml2",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+}
+
diff --git a/trusty/keymaster/include/trusty_keymaster/ipc/keymaster_ipc.h b/trusty/keymaster/include/trusty_keymaster/ipc/keymaster_ipc.h
index 13e6725..ce2cc2e 100644
--- a/trusty/keymaster/include/trusty_keymaster/ipc/keymaster_ipc.h
+++ b/trusty/keymaster/include/trusty_keymaster/ipc/keymaster_ipc.h
@@ -53,6 +53,19 @@
     KM_DELETE_ALL_KEYS              = (23 << KEYMASTER_REQ_SHIFT),
     KM_DESTROY_ATTESTATION_IDS      = (24 << KEYMASTER_REQ_SHIFT),
     KM_IMPORT_WRAPPED_KEY           = (25 << KEYMASTER_REQ_SHIFT),
+
+    // Bootloader/provisioning calls.
+    KM_SET_BOOT_PARAMS = (0x1000 << KEYMASTER_REQ_SHIFT),
+    KM_SET_ATTESTATION_KEY = (0x2000 << KEYMASTER_REQ_SHIFT),
+    KM_APPEND_ATTESTATION_CERT_CHAIN = (0x3000 << KEYMASTER_REQ_SHIFT),
+    KM_ATAP_GET_CA_REQUEST = (0x4000 << KEYMASTER_REQ_SHIFT),
+    KM_ATAP_SET_CA_RESPONSE_BEGIN = (0x5000 << KEYMASTER_REQ_SHIFT),
+    KM_ATAP_SET_CA_RESPONSE_UPDATE = (0x6000 << KEYMASTER_REQ_SHIFT),
+    KM_ATAP_SET_CA_RESPONSE_FINISH = (0x7000 << KEYMASTER_REQ_SHIFT),
+    KM_ATAP_READ_UUID = (0x8000 << KEYMASTER_REQ_SHIFT),
+    KM_SET_PRODUCT_ID = (0x9000 << KEYMASTER_REQ_SHIFT),
+    KM_CLEAR_ATTESTATION_CERT_CHAIN = (0xa000 << KEYMASTER_REQ_SHIFT),
+    KM_SET_WRAPPED_ATTESTATION_KEY = (0xb000 << KEYMASTER_REQ_SHIFT),
 };
 
 #ifdef __ANDROID__
diff --git a/trusty/keymaster/set_attestation_key/keymaster_soft_attestation_keys.xml b/trusty/keymaster/set_attestation_key/keymaster_soft_attestation_keys.xml
new file mode 100644
index 0000000..fce2ac2
--- /dev/null
+++ b/trusty/keymaster/set_attestation_key/keymaster_soft_attestation_keys.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<AndroidAttestation>
+  <NumberOfKeyboxes>10</NumberOfKeyboxes>
+  <Keybox DeviceID="dev1">
+    <Key algorithm="rsa">
+      <PrivateKey format="pem">
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDAgyPcVogbuDAgafWwhWHG7r5/BeL1qEIEir6LR752/q7yXPKb
+KvoyABQWAUKZiaFfz8aBXrNjWDwv0vIL5Jgyg92BSxbX4YVBeuVKvClqOm21wAQI
+O2jFVsHwIzmRZBmGTVC3TUCuykhMdzVsiVoMJ1q/rEmdXX0jYvKcXgLocQIDAQAB
+AoGBAL6GCwuZqAKm+xpZQ4p7txUGWwmjbcbpysxr88AsNNfXnpTGYGQo2Ix7f2V3
+wc3qZAdKvo5yht8fCBHclygmCGjeldMu/Ja20IT/JxpfYN78xwPno45uKbqaPF/C
+woB2tqiWrx0014gozpvdsfNPnJQEQweBKY4gExZyW728mTpBAkEA4cbZJ2RsCRbs
+NoJtWUmDdAwh8bB0xKGlmGfGaXlchdPcRkxbkp6Uv7NODcxQFLEPEzQat/3V9gQU
+0qMmytQcxQJBANpIWZd4XNVjD7D9jFJU+Y5TjhiYOq6ea35qWntdNDdVuSGOvUAy
+DSg4fXifdvohi8wti2il9kGPu+ylF5qzr70CQFD+/DJklVlhbtZTThVFCTKdk6PY
+ENvlvbmCKSz3i9i624Agro1X9LcdBThv/p6dsnHKNHejSZnbdvjl7OnA1J0CQBW3
+TPJ8zv+Ls2vwTZ2DRrCaL3DS9EObDyasfgP36dH3fUuRX9KbKCPwOstdUgDghX/y
+qAPpPu6W1iNc6VRCvCECQQCQp0XaiXCyzWSWYDJCKMX4KFb/1mW6moXI1g8bi+5x
+fs0scurgHa2GunZU1M9FrbXx8rMdn4Eiz6XxpVcPmy0l
+-----END RSA PRIVATE KEY-----
+      </PrivateKey>
+      <CertificateChain>
+        <NumberOfCertificates>2</NumberOfCertificates>
+        <Certificate format="pem">
+-----BEGIN CERTIFICATE-----
+MIICtjCCAh+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwYzELMAkGA1UEBhMCVVMx
+EzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxFTAT
+BgNVBAoMDEdvb2dsZSwgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDAeFw0xNjAxMDQx
+MjQwNTNaFw0zNTEyMzAxMjQwNTNaMHYxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApD
+YWxpZm9ybmlhMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xEDAOBgNVBAsMB0FuZHJv
+aWQxKTAnBgNVBAMMIEFuZHJvaWQgU29mdHdhcmUgQXR0ZXN0YXRpb24gS2V5MIGf
+MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDAgyPcVogbuDAgafWwhWHG7r5/BeL1
+qEIEir6LR752/q7yXPKbKvoyABQWAUKZiaFfz8aBXrNjWDwv0vIL5Jgyg92BSxbX
+4YVBeuVKvClqOm21wAQIO2jFVsHwIzmRZBmGTVC3TUCuykhMdzVsiVoMJ1q/rEmd
+XX0jYvKcXgLocQIDAQABo2YwZDAdBgNVHQ4EFgQU1AwQG/jNY7n3OVK1DhNcpteZ
+k4YwHwYDVR0jBBgwFoAUKfrxrMxN0kyWQCd1trDpMuUH/i4wEgYDVR0TAQH/BAgw
+BgEB/wIBADAOBgNVHQ8BAf8EBAMCAoQwDQYJKoZIhvcNAQELBQADgYEAni1IX4xn
+M9waha2Z11Aj6hTsQ7DhnerCI0YecrUZ3GAi5KVoMWwLVcTmnKItnzpPk2sxixZ4
+Fg2Iy9mLzICdhPDCJ+NrOPH90ecXcjFZNX2W88V/q52PlmEmT7K+gbsNSQQiis6f
+9/VCLiVE+iEHElqDtVWtGIL4QBSbnCBjBH8=
+-----END CERTIFICATE-----
+        </Certificate>
+        <Certificate format="pem">
+-----BEGIN CERTIFICATE-----
+MIICpzCCAhCgAwIBAgIJAP+U2d2fB8gMMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNV
+BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW
+aWV3MRUwEwYDVQQKDAxHb29nbGUsIEluYy4xEDAOBgNVBAsMB0FuZHJvaWQwHhcN
+MTYwMTA0MTIzMTA4WhcNMzUxMjMwMTIzMTA4WjBjMQswCQYDVQQGEwJVUzETMBEG
+A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEVMBMGA1UE
+CgwMR29vZ2xlLCBJbmMuMRAwDgYDVQQLDAdBbmRyb2lkMIGfMA0GCSqGSIb3DQEB
+AQUAA4GNADCBiQKBgQCia63rbi5EYe/VDoLmt5TRdSMfd5tjkWP/96r/C3JHTsAs
+Q+wzfNes7UA+jCigZtX3hwszl94OuE4TQKuvpSe/lWmgMdsGUmX4RFlXYfC78hdL
+t0GAZMAoDo9Sd47b0ke2RekZyOmLw9vCkT/X11DEHTVm+Vfkl5YLCazOkjWFmwID
+AQABo2MwYTAdBgNVHQ4EFgQUKfrxrMxN0kyWQCd1trDpMuUH/i4wHwYDVR0jBBgw
+FoAUKfrxrMxN0kyWQCd1trDpMuUH/i4wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
+Af8EBAMCAoQwDQYJKoZIhvcNAQELBQADgYEAT3LzNlmNDsG5dFsxWfbwjSVJMJ6j
+HBwp0kUtILlNX2S06IDHeHqcOd6os/W/L3BfRxBcxebrTQaZYdKumgf/93y4q+uc
+DyQHXrF/unlx/U1bnt8Uqf7f7XzAiF343ZtkMlbVNZriE/mPzsF83O+kqrJVw4Op
+Lvtc9mL1J1IXvmM=
+-----END CERTIFICATE-----
+        </Certificate>
+      </CertificateChain>
+    </Key>
+  </Keybox>
+  <Keybox DeviceID="dev1">
+    <Key algorithm="ecdsa">
+      <PrivateKey format="pem">
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEICHghkMqFRmEWc82OlD8FMnarfk19SfC39ceTW28QuVEoAoGCCqGSM49
+AwEHoUQDQgAE6555+EJjWazLKpFMiYbMcK2QZpOCqXMmE/6sy/ghJ0whdJdKKv6l
+uU1/ZtTgZRBmNbxTt6CjpnFYPts+Ea4QFA==
+-----END EC PRIVATE KEY-----
+      </PrivateKey>
+      <CertificateChain>
+        <NumberOfCertificates>2</NumberOfCertificates>
+        <Certificate format="pem">
+-----BEGIN CERTIFICATE-----
+MIICeDCCAh6gAwIBAgICEAEwCgYIKoZIzj0EAwIwgZgxCzAJBgNVBAYTAlVTMRMw
+EQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRUwEwYD
+VQQKDAxHb29nbGUsIEluYy4xEDAOBgNVBAsMB0FuZHJvaWQxMzAxBgNVBAMMKkFu
+ZHJvaWQgS2V5c3RvcmUgU29mdHdhcmUgQXR0ZXN0YXRpb24gUm9vdDAeFw0xNjAx
+MTEwMDQ2MDlaFw0yNjAxMDgwMDQ2MDlaMIGIMQswCQYDVQQGEwJVUzETMBEGA1UE
+CAwKQ2FsaWZvcm5pYTEVMBMGA1UECgwMR29vZ2xlLCBJbmMuMRAwDgYDVQQLDAdB
+bmRyb2lkMTswOQYDVQQDDDJBbmRyb2lkIEtleXN0b3JlIFNvZnR3YXJlIEF0dGVz
+dGF0aW9uIEludGVybWVkaWF0ZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABOue
+efhCY1msyyqRTImGzHCtkGaTgqlzJhP+rMv4ISdMIXSXSir+pblNf2bU4GUQZjW8
+U7ego6ZxWD7bPhGuEBSjZjBkMB0GA1UdDgQWBBQ//KzWGrE6noEguNUlHMVlux6R
+qTAfBgNVHSMEGDAWgBTIrel3TEXDo88NFhDkeUM6IVowzzASBgNVHRMBAf8ECDAG
+AQH/AgEAMA4GA1UdDwEB/wQEAwIChDAKBggqhkjOPQQDAgNIADBFAiBLipt77oK8
+wDOHri/AiZi03cONqycqRZ9pDMfDktQPjgIhAO7aAV229DLp1IQ7YkyUBO86fMy9
+Xvsiu+f+uXc/WT/7
+-----END CERTIFICATE-----
+        </Certificate>
+        <Certificate format="pem">
+-----BEGIN CERTIFICATE-----
+MIICizCCAjKgAwIBAgIJAKIFntEOQ1tXMAoGCCqGSM49BAMCMIGYMQswCQYDVQQG
+EwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmll
+dzEVMBMGA1UECgwMR29vZ2xlLCBJbmMuMRAwDgYDVQQLDAdBbmRyb2lkMTMwMQYD
+VQQDDCpBbmRyb2lkIEtleXN0b3JlIFNvZnR3YXJlIEF0dGVzdGF0aW9uIFJvb3Qw
+HhcNMTYwMTExMDA0MzUwWhcNMzYwMTA2MDA0MzUwWjCBmDELMAkGA1UEBhMCVVMx
+EzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxFTAT
+BgNVBAoMDEdvb2dsZSwgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDEzMDEGA1UEAwwq
+QW5kcm9pZCBLZXlzdG9yZSBTb2Z0d2FyZSBBdHRlc3RhdGlvbiBSb290MFkwEwYH
+KoZIzj0CAQYIKoZIzj0DAQcDQgAE7l1ex+HA220Dpn7mthvsTWpdamguD/9/SQ59
+dx9EIm29sa/6FsvHrcV30lacqrewLVQBXT5DKyqO107sSHVBpKNjMGEwHQYDVR0O
+BBYEFMit6XdMRcOjzw0WEOR5QzohWjDPMB8GA1UdIwQYMBaAFMit6XdMRcOjzw0W
+EOR5QzohWjDPMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgKEMAoGCCqG
+SM49BAMCA0cAMEQCIDUho++LNEYenNVg8x1YiSBq3KNlQfYNns6KGYxmSGB7AiBN
+C/NR2TB8fVvaNTQdqEcbY6WFZTytTySn502vQX3xvw==
+-----END CERTIFICATE-----
+        </Certificate>
+      </CertificateChain>
+    </Key>
+  </Keybox>
+</AndroidAttestation>
diff --git a/trusty/keymaster/set_attestation_key/set_attestation_key.cpp b/trusty/keymaster/set_attestation_key/set_attestation_key.cpp
new file mode 100644
index 0000000..6f74833
--- /dev/null
+++ b/trusty/keymaster/set_attestation_key/set_attestation_key.cpp
@@ -0,0 +1,362 @@
+/*
+ * Copyright (C) 2020 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 <errno.h>
+#include <getopt.h>
+#include <libxml/xmlreader.h>
+#include <openssl/pem.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <string>
+
+using std::string;
+
+#include <trusty_keymaster/ipc/trusty_keymaster_ipc.h>
+
+static const char* _sopts = "h";
+static const struct option _lopts[] = {
+        {"help", no_argument, 0, 'h'},
+        {0, 0, 0, 0},
+};
+
+static const char* usage =
+        "Usage: %s [options] xml-file\n"
+        "\n"
+        "options:\n"
+        "  -h, --help            prints this message and exit\n"
+        "\n";
+
+static void print_usage_and_exit(const char* prog, int code) {
+    fprintf(stderr, usage, prog);
+    exit(code);
+}
+
+static void parse_options(int argc, char** argv) {
+    int c;
+    int oidx = 0;
+
+    while (1) {
+        c = getopt_long(argc, argv, _sopts, _lopts, &oidx);
+        if (c == -1) {
+            break; /* done */
+        }
+
+        switch (c) {
+            case 'h':
+                print_usage_and_exit(argv[0], EXIT_SUCCESS);
+                break;
+
+            default:
+                print_usage_and_exit(argv[0], EXIT_FAILURE);
+        }
+    }
+}
+
+struct SetAttestationKeyRequest : public keymaster::KeymasterMessage {
+    explicit SetAttestationKeyRequest(int32_t ver = keymaster::MAX_MESSAGE_VERSION)
+        : KeymasterMessage(ver) {}
+
+    size_t SerializedSize() const override { return sizeof(uint32_t) + key_data.SerializedSize(); }
+    uint8_t* Serialize(uint8_t* buf, const uint8_t* end) const override {
+        buf = keymaster::append_uint32_to_buf(buf, end, algorithm);
+        return key_data.Serialize(buf, end);
+    }
+    bool Deserialize(const uint8_t** buf_ptr, const uint8_t* end) override {
+        return keymaster::copy_uint32_from_buf(buf_ptr, end, &algorithm) &&
+               key_data.Deserialize(buf_ptr, end);
+    }
+
+    keymaster_algorithm_t algorithm;
+    keymaster::Buffer key_data;
+};
+
+struct KeymasterNoResponse : public keymaster::KeymasterResponse {
+    explicit KeymasterNoResponse(int32_t ver = keymaster::MAX_MESSAGE_VERSION)
+        : keymaster::KeymasterResponse(ver) {}
+
+    size_t NonErrorSerializedSize() const override { return 0; }
+    uint8_t* NonErrorSerialize(uint8_t* buf, const uint8_t*) const override { return buf; }
+    bool NonErrorDeserialize(const uint8_t**, const uint8_t*) override { return true; }
+};
+
+struct SetAttestationKeyResponse : public KeymasterNoResponse {};
+
+struct ClearAttestationCertChainRequest : public keymaster::KeymasterMessage {
+    explicit ClearAttestationCertChainRequest(int32_t ver = keymaster::MAX_MESSAGE_VERSION)
+        : KeymasterMessage(ver) {}
+
+    size_t SerializedSize() const override { return sizeof(uint32_t); }
+    uint8_t* Serialize(uint8_t* buf, const uint8_t* end) const override {
+        return keymaster::append_uint32_to_buf(buf, end, algorithm);
+    }
+    bool Deserialize(const uint8_t** buf_ptr, const uint8_t* end) override {
+        return keymaster::copy_uint32_from_buf(buf_ptr, end, &algorithm);
+    }
+
+    keymaster_algorithm_t algorithm;
+};
+
+struct ClearAttestationCertChainResponse : public KeymasterNoResponse {};
+
+static int set_attestation_key_or_cert_bin(uint32_t cmd, keymaster_algorithm_t algorithm,
+                                           const void* key_data, size_t key_data_size) {
+    int ret;
+
+    SetAttestationKeyRequest req;
+    req.algorithm = algorithm;
+    req.key_data.Reinitialize(key_data, key_data_size);
+    SetAttestationKeyResponse rsp;
+
+    ret = trusty_keymaster_send(cmd, req, &rsp);
+    if (ret) {
+        fprintf(stderr, "trusty_keymaster_send cmd 0x%x failed %d\n", cmd, ret);
+        return ret;
+    }
+
+    return 0;
+}
+
+static int set_attestation_key_or_cert_pem(uint32_t cmd, keymaster_algorithm_t algorithm,
+                                           const xmlChar* pemkey) {
+    int ret;
+    int sslret;
+
+    /* Convert from pem to binary */
+    BIO* bio = BIO_new_mem_buf(pemkey, xmlStrlen(pemkey));
+    if (!bio) {
+        fprintf(stderr, "BIO_new_mem_buf failed\n");
+        ERR_print_errors_fp(stderr);
+        return -1;
+    }
+
+    char* key_name;
+    char* key_header;
+    uint8_t* key;
+    long keylen;
+    sslret = PEM_read_bio(bio, &key_name, &key_header, &key, &keylen);
+    BIO_free(bio);
+
+    if (!sslret) {
+        fprintf(stderr, "PEM_read_bio failed\n");
+        ERR_print_errors_fp(stderr);
+        return -1;
+    }
+
+    /* Send key in binary format to trusty */
+    ret = set_attestation_key_or_cert_bin(cmd, algorithm, key, keylen);
+
+    OPENSSL_free(key_name);
+    OPENSSL_free(key_header);
+    OPENSSL_free(key);
+
+    return ret;
+}
+
+static int set_attestation_key_or_cert_iecs(uint32_t cmd, keymaster_algorithm_t algorithm,
+                                            const xmlChar* key_base64) {
+    int ret;
+    int sslret;
+
+    /* Remove all whitespace. EVP_DecodeBase64 does not support whitespace. */
+    string key_base64_str((const char*)key_base64);
+    key_base64_str.erase(remove_if(key_base64_str.begin(), key_base64_str.end(), isspace),
+                         key_base64_str.end());
+
+    /* Convert from base64 to binary */
+    uint8_t* key;
+    size_t keylen;
+    size_t key_base64_len = key_base64_str.length();
+
+    sslret = EVP_DecodedLength(&keylen, key_base64_len);
+    if (!sslret) {
+        fprintf(stderr, "invalid input length, %zu\n", key_base64_len);
+        return -1;
+    }
+    key = (uint8_t*)malloc(keylen);
+    if (!key) {
+        fprintf(stderr, "failed to allocate key, size %zu\n", key_base64_len);
+        return -1;
+    }
+    sslret = EVP_DecodeBase64(key, &keylen, keylen, (const uint8_t*)key_base64_str.data(),
+                              key_base64_len);
+    if (!sslret) {
+        fprintf(stderr, "EVP_DecodeBase64 failed\n");
+        ERR_print_errors_fp(stderr);
+        free(key);
+        return -1;
+    }
+
+    /* Send key in binary format to trusty */
+    ret = set_attestation_key_or_cert_bin(cmd, algorithm, key, keylen);
+
+    free(key);
+
+    return ret;
+}
+
+static int str_to_algorithm(keymaster_algorithm_t* algorithm, const xmlChar* algorithm_str) {
+    if (xmlStrEqual(algorithm_str, BAD_CAST "rsa")) {
+        *algorithm = KM_ALGORITHM_RSA;
+    } else if (xmlStrEqual(algorithm_str, BAD_CAST "ecdsa")) {
+        *algorithm = KM_ALGORITHM_EC;
+    } else {
+        printf("unsupported algorithm: %s\n", algorithm_str);
+        return -1;
+    }
+    return 0;
+}
+
+static int set_attestation_key_or_cert(uint32_t cmd, const xmlChar* algorithm_str,
+                                       const xmlChar* format, const xmlChar* str) {
+    int ret;
+    keymaster_algorithm_t algorithm;
+
+    ret = str_to_algorithm(&algorithm, algorithm_str);
+    if (ret) {
+        return ret;
+    }
+
+    if (xmlStrEqual(format, BAD_CAST "pem")) {
+        ret = set_attestation_key_or_cert_pem(cmd, algorithm, str);
+    } else if (xmlStrEqual(format, BAD_CAST "iecs")) {
+        ret = set_attestation_key_or_cert_iecs(cmd, algorithm, str);
+    } else {
+        printf("unsupported key/cert format: %s\n", format);
+        return -1;
+    }
+    return ret;
+}
+
+static int clear_cert_chain(const xmlChar* algorithm_str) {
+    int ret;
+    ClearAttestationCertChainRequest req;
+    ClearAttestationCertChainResponse rsp;
+
+    ret = str_to_algorithm(&req.algorithm, algorithm_str);
+    if (ret) {
+        return ret;
+    }
+
+    ret = trusty_keymaster_send(KM_CLEAR_ATTESTATION_CERT_CHAIN, req, &rsp);
+    if (ret) {
+        fprintf(stderr, "%s: trusty_keymaster_send failed %d\n", __func__, ret);
+        return ret;
+    }
+    return 0;
+}
+
+static int process_xml(xmlTextReaderPtr xml) {
+    int ret;
+    const xmlChar* algorithm = NULL;
+    const xmlChar* element = NULL;
+    const xmlChar* element_format = NULL;
+
+    while ((ret = xmlTextReaderRead(xml)) == 1) {
+        int nodetype = xmlTextReaderNodeType(xml);
+        const xmlChar *name, *value;
+        name = xmlTextReaderConstName(xml);
+        switch (nodetype) {
+            case XML_READER_TYPE_ELEMENT:
+                element = name;
+                element_format = xmlTextReaderGetAttribute(xml, BAD_CAST "format");
+                if (xmlStrEqual(name, BAD_CAST "Key")) {
+                    algorithm = xmlTextReaderGetAttribute(xml, BAD_CAST "algorithm");
+                } else if (xmlStrEqual(name, BAD_CAST "CertificateChain")) {
+                    ret = clear_cert_chain(algorithm);
+                    if (ret) {
+                        fprintf(stderr, "%s, algorithm %s: Clear cert chain cmd failed, %d\n",
+                                element, algorithm, ret);
+                        return ret;
+                    }
+                    printf("%s, algorithm %s: Clear cert chain cmd done\n", element, algorithm);
+                }
+                break;
+            case XML_READER_TYPE_TEXT:
+                value = xmlTextReaderConstValue(xml);
+                uint32_t cmd;
+                if (xmlStrEqual(element, BAD_CAST "PrivateKey")) {
+                    if (xmlStrEqual(element_format, BAD_CAST "pem")) {
+                        cmd = KM_SET_ATTESTATION_KEY;
+                    } else if (xmlStrEqual(element_format, BAD_CAST "iecs")) {
+                        cmd = KM_SET_WRAPPED_ATTESTATION_KEY;
+                    } else {
+                        printf("unsupported key format: %s\n", element_format);
+                        return -1;
+                    }
+                } else if (xmlStrEqual(element, BAD_CAST "Certificate")) {
+                    cmd = KM_APPEND_ATTESTATION_CERT_CHAIN;
+                } else {
+                    break;
+                }
+
+                ret = set_attestation_key_or_cert(cmd, algorithm, element_format, value);
+                if (ret) {
+                    fprintf(stderr, "%s, algorithm %s, format %s: Cmd 0x%x failed, %d\n", element,
+                            algorithm, element_format, cmd, ret);
+                    return ret;
+                }
+                printf("%s, algorithm %s, format %s: Cmd 0x%x done\n", element, algorithm,
+                       element_format, cmd);
+                break;
+            case XML_READER_TYPE_END_ELEMENT:
+                element = NULL;
+                break;
+        }
+    }
+    return ret;
+}
+
+static int parse_xml_file(const char* filename) {
+    int ret;
+    xmlTextReaderPtr xml = xmlReaderForFile(filename, NULL, 0);
+    if (!xml) {
+        fprintf(stderr, "failed to open %s\n", filename);
+        return -1;
+    }
+
+    ret = process_xml(xml);
+
+    xmlFreeTextReader(xml);
+    if (ret != 0) {
+        fprintf(stderr, "Failed to parse or process %s\n", filename);
+        return -1;
+    }
+
+    return 0;
+}
+
+int main(int argc, char** argv) {
+    int ret = 0;
+
+    parse_options(argc, argv);
+    if (optind + 1 != argc) {
+        print_usage_and_exit(argv[0], EXIT_FAILURE);
+    }
+
+    ret = trusty_keymaster_connect();
+    if (ret) {
+        fprintf(stderr, "trusty_keymaster_connect failed %d\n", ret);
+    } else {
+        ret = parse_xml_file(argv[optind]);
+        trusty_keymaster_disconnect();
+    }
+
+    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/trusty/trusty-test.mk b/trusty/trusty-test.mk
index fd353d1..dc4c962 100644
--- a/trusty/trusty-test.mk
+++ b/trusty/trusty-test.mk
@@ -14,3 +14,5 @@
 
 PRODUCT_PACKAGES += \
 	spiproxyd \
+	trusty_keymaster_set_attestation_key \
+	keymaster_soft_attestation_keys.xml \
\ No newline at end of file
diff --git a/trusty/utils/rpmb_dev/rpmb_dev.c b/trusty/utils/rpmb_dev/rpmb_dev.c
index 5de1efa..2025621 100644
--- a/trusty/utils/rpmb_dev/rpmb_dev.c
+++ b/trusty/utils/rpmb_dev/rpmb_dev.c
@@ -283,6 +283,7 @@
                 {
                         .func = rpmb_dev_data_read,
                         .resp = RPMB_RESP_DATA_READ,
+                        .check_key_programmed = true,
                         .check_addr = true,
                         .multi_packet_res = true,
                         .res_mac = true,
diff --git a/trusty/utils/rpmb_dev/rpmb_dev.rc b/trusty/utils/rpmb_dev/rpmb_dev.rc
index 9f60e81..9e203b8 100644
--- a/trusty/utils/rpmb_dev/rpmb_dev.rc
+++ b/trusty/utils/rpmb_dev/rpmb_dev.rc
@@ -16,7 +16,7 @@
     disabled
     user root
 
-service rpmb_mock_init /vendor/bin/rpmb_dev --dev /data/vendor/ss/RPMB_DATA --init --key "ea df 64 44 ea 65 5d 1c 87 27 d4 20 71 0d 53 42 dd 73 a3 38 63 e1 d7 94 c3 72 a6 ea e0 64 64 e6" --size 2048
+service rpmb_mock_init /vendor/bin/rpmb_dev --dev /data/vendor/ss/RPMB_DATA --init --size 2048
     disabled
     user system
     group system
