Merge "Lose vmstat to toybox."
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c
index 8cbe840..61578aa 100644
--- a/adb/framebuffer_service.c
+++ b/adb/framebuffer_service.c
@@ -76,6 +76,7 @@
         exit(1);
     }
 
+    close(fds[1]);
     fd_screencap = fds[0];
 
     /* read w, h & format */
@@ -173,10 +174,9 @@
     }
 
 done:
-    TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
-
     close(fds[0]);
-    close(fds[1]);
+
+    TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
 pipefail:
     close(fd);
 }
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 13425e6..959d3ad 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -244,7 +244,7 @@
         // output compatible with "adb devices"
         if (!long_listing) {
             printf("%s\tfastboot\n", serial);
-        } else if (!info->device_path) {
+        } else if (strcmp("", info->device_path) == 0) {
             printf("%-22s fastboot\n", serial);
         } else {
             printf("%-22s fastboot %s\n", serial, info->device_path);
diff --git a/fastboot/fastboot_protocol.txt b/fastboot/fastboot_protocol.txt
index 2248992..37b1959 100644
--- a/fastboot/fastboot_protocol.txt
+++ b/fastboot/fastboot_protocol.txt
@@ -12,8 +12,8 @@
 ------------------
 
 * Two bulk endpoints (in, out) are required
-* Max packet size must be 64 bytes for full-speed and 512 bytes for 
-  high-speed USB
+* Max packet size must be 64 bytes for full-speed, 512 bytes for
+  high-speed and 1024 bytes for Super Speed USB.
 * The protocol is entirely host-driven and synchronous (unlike the
   multi-channel, bi-directional, asynchronous ADB protocol)
 
diff --git a/fastboot/protocol.c b/fastboot/protocol.c
index 84e9837..10a84c1 100644
--- a/fastboot/protocol.c
+++ b/fastboot/protocol.c
@@ -216,7 +216,7 @@
     }
 }
 
-#define USB_BUF_SIZE 512
+#define USB_BUF_SIZE 1024
 static char usb_buf[USB_BUF_SIZE];
 static int usb_buf_len;
 
diff --git a/libpixelflinger/Android.mk b/libpixelflinger/Android.mk
index da9829d..f1bd522 100644
--- a/libpixelflinger/Android.mk
+++ b/libpixelflinger/Android.mk
@@ -36,6 +36,7 @@
 
 ifeq ($(ARCH_ARM_HAVE_NEON),true)
 PIXELFLINGER_SRC_FILES_arm += col32cb16blend_neon.S
+PIXELFLINGER_CFLAGS_arm += -D__ARM_HAVE_NEON
 endif
 
 PIXELFLINGER_SRC_FILES_arm64 := \
diff --git a/libpixelflinger/codeflinger/load_store.cpp b/libpixelflinger/codeflinger/load_store.cpp
index 0a46eaa..e5a1ae0 100644
--- a/libpixelflinger/codeflinger/load_store.cpp
+++ b/libpixelflinger/codeflinger/load_store.cpp
@@ -20,10 +20,6 @@
 #include <cutils/log.h>
 #include "GGLAssembler.h"
 
-#ifdef __ARM_ARCH__
-#include <machine/cpu-features.h>
-#endif
-
 namespace android {
 
 // ----------------------------------------------------------------------------
@@ -117,20 +113,6 @@
 #endif
     assert(h);
     
-#if __ARM_ARCH__ >= 7
-    const int mask = (1<<maskLen)-1;
-    if ((h == bits) && !l && (s != d.reg)) {
-        MOV(AL, 0, d.reg, s);                   // component = packed;
-    } else if ((h == bits) && l) {
-        MOV(AL, 0, d.reg, reg_imm(s, LSR, l));  // component = packed >> l;
-    } else if (!l && isValidImmediate(mask)) {
-        AND(AL, 0, d.reg, s, imm(mask));        // component = packed & mask;
-    } else if (!l && isValidImmediate(~mask)) {
-        BIC(AL, 0, d.reg, s, imm(~mask));       // component = packed & mask;
-    } else {
-        UBFX(AL, d.reg, s, l, maskLen);         // component = (packed & mask) >> l;
-    }
-#else
     if (h != bits) {
         const int mask = ((1<<maskLen)-1) << l;
         if (isValidImmediate(mask)) {
@@ -153,7 +135,6 @@
     if (s != d.reg) {
         MOV(AL, 0, d.reg, s);
     }
-#endif
 
     d.s = maskLen;
 }
diff --git a/libpixelflinger/codeflinger/texturing.cpp b/libpixelflinger/codeflinger/texturing.cpp
index 81950bf..29a3742 100644
--- a/libpixelflinger/codeflinger/texturing.cpp
+++ b/libpixelflinger/codeflinger/texturing.cpp
@@ -25,10 +25,6 @@
 
 #include "GGLAssembler.h"
 
-#ifdef __ARM_ARCH__
-#include <machine/cpu-features.h>
-#endif
-
 namespace android {
 
 // ---------------------------------------------------------------------------
@@ -888,106 +884,6 @@
     load(txPtr, texel, 0);
 }
 
-#if __ARM_ARCH__ >= 6
-// ARMv6 version, using UXTB16, and scheduled for Cortex-A8 pipeline
-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;
-    const int prescale = 16 - adjust;
-
-    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 offsetrt = scratches.obtain();
-    int offsetlb = scratches.obtain();
-
-    int pixellb = offsetlb;
-
-    // RB -> U * V
-    CONTEXT_LOAD(offsetrt, generated_vars.rt);
-    CONTEXT_LOAD(offsetlb, generated_vars.lb);
-    if(!round) {
-        MOV(AL, 0, U, reg_imm(U, LSL, prescale));
-    }
-    ADD(AL, 0, u, offsetrt, offsetlb);
-
-    LDR(AL, pixel, txPtr.reg, reg_scale_pre(u));
-    if (round) {
-        SMULBB(AL, u, U, V);
-        RSB(AL, 0, U, U, imm(1<<FRAC_BITS));
-    } else {
-        SMULWB(AL, u, U, V);
-        RSB(AL, 0, U, U, imm(1<<(FRAC_BITS+prescale)));
-    }
-    UXTB16(AL, temp, pixel, 0);
-    if (round) {
-        ADD(AL, 0, u, u, imm(1<<(adjust-1)));
-        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
-    }
-    LDR(AL, pixellb, txPtr.reg, reg_scale_pre(offsetlb));
-    MUL(AL, 0, dh, temp, u);
-    UXTB16(AL, temp, pixel, 8);
-    MUL(AL, 0, dl, temp, u);
-    RSB(AL, 0, k, u, imm(0x100));
-
-    // LB -> (1-U) * V
-    if (round) {
-        SMULBB(AL, u, U, V);
-    } else {
-        SMULWB(AL, u, U, V);
-    }
-    UXTB16(AL, temp, pixellb, 0);
-    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);    
-    UXTB16(AL, temp, pixellb, 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);
-    if (round) {
-        SMULBB(AL, u, U, V);
-    } else {
-        SMULWB(AL, u, U, V);
-    }
-    UXTB16(AL, temp, pixel, 0);
-    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);    
-    UXTB16(AL, temp, pixel, 8);
-    MLA(AL, 0, dl, temp, u, dl);
-
-    // RT -> U*(1-V)            
-    LDR(AL, pixel, txPtr.reg, reg_scale_pre(offsetrt));
-    SUB(AL, 0, u, k, u);
-    UXTB16(AL, temp, pixel, 0);
-    MLA(AL, 0, dh, temp, u, dh);    
-    UXTB16(AL, temp, pixel, 8);
-    MLA(AL, 0, dl, temp, u, dl);
-
-    UXTB16(AL, dh, dh, 8);
-    UXTB16(AL, dl, dl, 8);
-    ORR(AL, 0, texel.reg, dh, reg_imm(dl, LSL, 8));
-}
-#else
 void GGLAssembler::filter32(
         const fragment_parts_t& /*parts*/,
         pixel_t& texel, const texture_unit_t& /*tmu*/,
@@ -1075,7 +971,6 @@
     AND(AL, 0, dl, dl, reg_imm(mask, LSL, 8));
     ORR(AL, 0, texel.reg, dh, dl);
 }
-#endif
 
 void GGLAssembler::build_texture_environment(
         component_t& fragment,
diff --git a/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp b/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
index fd96f7e..5f58797 100644
--- a/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
+++ b/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
@@ -493,16 +493,17 @@
         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]);
+            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]);
+        printf("Test %x failed, Expected(%" PRIx64 "), Actual(%" PRIx64 ")\n",
+               test.id, test.postRdValue, regs[Rd]);
     }
     else if(test.checkFlag == 1 && flags[test.postFlag] == 0)
     {
@@ -610,7 +611,7 @@
         if(regs[i] != savedRegs[i])
         {
             printf("Test %x failed Reg(%d) tampered"
-                   " Expected(0x%"PRIx64"), Actual(0x%"PRIx64") t\n",
+                   " Expected(0x%" PRIx64 "), Actual(0x%" PRIx64 ") t\n",
                    test.id, i, savedRegs[i], regs[i]);
             return;
         }
@@ -619,13 +620,13 @@
     if((uint64_t)regs[Rd] != test.postRdValue)
     {
         printf("Test %x failed, "
-               "Expected in Rd(0x%"PRIx64"), Actual(0x%"PRIx64")\n",
+               "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",
+               "Expected in Rn(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
                test.id, test.postRnValue, regs[Rn] - (uint64_t)dataMem);
     }
     else if(test.checkMem == true)
@@ -638,7 +639,7 @@
         if(value != test.postMemValue)
         {
             printf("Test %x failed, "
-                   "Expected in Mem(0x%"PRIx64"), Actual(0x%"PRIx64")\n",
+                   "Expected in Mem(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
                    test.id, test.postMemValue, value);
         }
         else
@@ -697,8 +698,8 @@
                 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]);
+                           "Reg%d expected(0x%x) Actual(0x%" PRIx64 ") \n",
+                           patterns[i], j, j, regs[j]);
                     break;
                 }
             }
diff --git a/libutils/SystemClock.cpp b/libutils/SystemClock.cpp
index dbad581..ac3dd98 100644
--- a/libutils/SystemClock.cpp
+++ b/libutils/SystemClock.cpp
@@ -68,7 +68,7 @@
  */
 #define DEBUG_TIMESTAMP         0
 
-#if DEBUG_TIMESTAMP && defined(ARCH_ARM)
+#if DEBUG_TIMESTAMP && defined(__arm__)
 static inline void checkTimeStamps(int64_t timestamp,
                                    int64_t volatile *prevTimestampPtr,
                                    int volatile *prevMethodPtr,
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index 65be241..005fab7 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -120,7 +120,6 @@
     cmp \
     date \
     df \
-    dmesg \
     getenforce \
     getevent \
     getprop \
@@ -144,7 +143,6 @@
     newfs_msdos \
     notify \
     ps \
-    readlink \
     renice \
     restorecon \
     route \
diff --git a/toolbox/dmesg.c b/toolbox/dmesg.c
deleted file mode 100644
index 9c73b00..0000000
--- a/toolbox/dmesg.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/klog.h>
-#include <string.h>
-
-#define FALLBACK_KLOG_BUF_SHIFT	17	/* CONFIG_LOG_BUF_SHIFT from our kernel */
-#define FALLBACK_KLOG_BUF_LEN	(1 << FALLBACK_KLOG_BUF_SHIFT)
-
-int dmesg_main(int argc, char **argv)
-{
-    char *buffer;
-    char *p;
-    ssize_t ret;
-    int n, op, klog_buf_len;
-
-    klog_buf_len = klogctl(KLOG_SIZE_BUFFER, 0, 0);
-
-    if (klog_buf_len <= 0) {
-        klog_buf_len = FALLBACK_KLOG_BUF_LEN;
-    }
-
-    buffer = (char *)malloc(klog_buf_len + 1);
-
-    if (!buffer) {
-        perror("malloc");
-        return EXIT_FAILURE;
-    }
-
-    p = buffer;
-
-    if((argc == 2) && (!strcmp(argv[1],"-c"))) {
-        op = KLOG_READ_CLEAR;
-    } else {
-        op = KLOG_READ_ALL;
-    }
-
-    n = klogctl(op, buffer, klog_buf_len);
-    if (n < 0) {
-        perror("klogctl");
-        return EXIT_FAILURE;
-    }
-    buffer[n] = '\0';
-
-    while((ret = write(STDOUT_FILENO, p, n))) {
-        if (ret == -1) {
-	    if (errno == EINTR)
-                continue;
-	    perror("write");
-	    return EXIT_FAILURE;
-	}
-	p += ret;
-	n -= ret;
-    }
-
-    return 0;
-}
diff --git a/toolbox/readlink.c b/toolbox/readlink.c
deleted file mode 100644
index d114e20..0000000
--- a/toolbox/readlink.c
+++ /dev/null
@@ -1,95 +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.
- *  * Neither the name of Google, Inc. nor the names of its contributors
- *    may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static int skip_newline, quiet_errors, canonicalize;
-
-static void usage(char* name) {
-    fprintf(stderr, "Usage: %s [OPTION]... FILE\n", name);
-}
-
-int readlink_main(int argc, char* argv[]) {
-    int c;
-    while ((c = getopt(argc, argv, "nfqs")) != -1) {
-        switch (c) {
-        case 'n':
-            skip_newline = 1;
-            break;
-        case 'f':
-            canonicalize = 1;
-            break;
-        case 'q':
-        case 's':
-            quiet_errors = 1;
-            break;
-        case '?':
-        default:
-            usage(argv[0]);
-            return EXIT_FAILURE;
-        }
-    }
-    int index = optind;
-    if (argc - index != 1) {
-        usage(argv[0]);
-        return EXIT_FAILURE;
-    }
-
-    char name[PATH_MAX+1];
-    if (canonicalize) {
-        if(!realpath(argv[optind], name)) {
-            if (!quiet_errors) {
-                perror("readlink");
-            }
-            return EXIT_FAILURE;
-        }
-    } else {
-        ssize_t len = readlink(argv[1], name, PATH_MAX);
-
-        if (len < 0) {
-            if (!quiet_errors) {
-                perror("readlink");
-            }
-            return EXIT_FAILURE;
-        }
-        name[len] = '\0';
-    }
-
-    fputs(name, stdout);
-    if (!skip_newline) {
-        fputs("\n", stdout);
-    }
-
-    return EXIT_SUCCESS;
-}