Merge changes I22f1b358,I5496d0de,Ifd98966b into jb-mr2-dev

* changes:
  replace eglWaitSyncANDROID by eglWaitSyncKHR
  update EGL headers to most recent
  cleanup EGL extensions strings and entry-points
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index d85a1d7..76ba81f 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -42,6 +42,7 @@
 enum { MAX_SYS_FILES = 8 };
 
 const char* k_traceTagsProperty = "debug.atrace.tags.enableflags";
+const char* k_traceAppCmdlineProperty = "debug.atrace.app_cmdlines";
 
 typedef enum { OPT, REQ } requiredness  ;
 
@@ -118,6 +119,7 @@
 static bool g_nohup = false;
 static int g_initialSleepSecs = 0;
 static const char* g_kernelTraceFuncs = NULL;
+static const char* g_debugAppCmdLine = "";
 
 /* Global state */
 static bool g_traceAborted = false;
@@ -365,7 +367,18 @@
         fprintf(stderr, "error setting trace tags system property\n");
         return false;
     }
-    return pokeBinderServices();
+    return true;
+}
+
+// Set the system property that indicates which apps should perform
+// application-level tracing.
+static bool setAppCmdlineProperty(const char* cmdline)
+{
+    if (property_set(k_traceAppCmdlineProperty, cmdline) < 0) {
+        fprintf(stderr, "error setting trace app system property\n");
+        return false;
+    }
+    return true;
 }
 
 // Disable all /sys/ enable files.
@@ -433,8 +446,10 @@
 
     if (funcs == NULL || funcs[0] == '\0') {
         // Disable kernel function tracing.
-        ok &= writeStr(k_currentTracerPath, "nop");
-        if (fileExists(k_ftraceFilterPath)) {
+        if (fileIsWritable(k_currentTracerPath)) {
+            ok &= writeStr(k_currentTracerPath, "nop");
+        }
+        if (fileIsWritable(k_ftraceFilterPath)) {
             ok &= truncateFile(k_ftraceFilterPath);
         }
     } else {
@@ -486,6 +501,8 @@
         }
     }
     ok &= setTagsProperty(tags);
+    ok &= setAppCmdlineProperty(g_debugAppCmdLine);
+    ok &= pokeBinderServices();
 
     // Disable all the sysfs enables.  This is done as a separate loop from
     // the enables to allow the same enable to exist in multiple categories.
@@ -519,8 +536,10 @@
     // Disable all tracing that we're able to.
     disableKernelTraceEvents();
 
-    // Disable all the trace tags.
+    // Reset the system properties.
     setTagsProperty(0);
+    setAppCmdlineProperty("");
+    pokeBinderServices();
 
     // Set the options back to their defaults.
     setTraceOverwriteEnable(true);
@@ -698,6 +717,8 @@
 {
     fprintf(stderr, "usage: %s [options] [categories...]\n", cmd);
     fprintf(stderr, "options include:\n"
+                    "  -a appname      enable app-level tracing for a comma "
+                        "separated list of cmdlines\n"
                     "  -b N            use a trace buffer size of N KB\n"
                     "  -c              trace into a circular buffer\n"
                     "  -k fname,...    trace the listed kernel functions\n"
@@ -737,7 +758,7 @@
             {           0,                0, 0,  0 }
         };
 
-        ret = getopt_long(argc, argv, "b:ck:ns:t:z",
+        ret = getopt_long(argc, argv, "a:b:ck:ns:t:z",
                           long_options, &option_index);
 
         if (ret < 0) {
@@ -751,6 +772,10 @@
         }
 
         switch(ret) {
+            case 'a':
+                g_debugAppCmdLine = optarg;
+            break;
+
             case 'b':
                 g_traceBufferSizeKB = atoi(optarg);
             break;
@@ -761,11 +786,11 @@
 
             case 'k':
                 g_kernelTraceFuncs = optarg;
-                break;
+            break;
 
             case 'n':
                 g_nohup = true;
-                break;
+            break;
 
             case 's':
                 g_initialSleepSecs = atoi(optarg);
@@ -796,7 +821,7 @@
                     listSupportedCategories();
                     exit(0);
                 }
-                break;
+            break;
 
             default:
                 fprintf(stderr, "\n");
diff --git a/opengl/tests/gl2_jni/Android.mk b/opengl/tests/gl2_jni/Android.mk
index 5d90ff6..25187c9 100644
--- a/opengl/tests/gl2_jni/Android.mk
+++ b/opengl/tests/gl2_jni/Android.mk
@@ -30,7 +30,7 @@
 # Optional tag would mean it doesn't get installed by default
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_CFLAGS := -Werror
+LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter
 
 LOCAL_SRC_FILES:= \
   gl_code.cpp
diff --git a/opengl/tests/gl_jni/Android.mk b/opengl/tests/gl_jni/Android.mk
index 3d20e72..80b4bac 100644
--- a/opengl/tests/gl_jni/Android.mk
+++ b/opengl/tests/gl_jni/Android.mk
@@ -30,7 +30,7 @@
 # Optional tag would mean it doesn't get installed by default
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_CFLAGS := -Werror
+LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter
 
 LOCAL_SRC_FILES:= \
   gl_code.cpp
diff --git a/opengl/tests/gl_perfapp/Android.mk b/opengl/tests/gl_perfapp/Android.mk
index 65e50e9..45a5516 100644
--- a/opengl/tests/gl_perfapp/Android.mk
+++ b/opengl/tests/gl_perfapp/Android.mk
@@ -33,7 +33,7 @@
 # Optional tag would mean it doesn't get installed by default
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_CFLAGS := -Werror
+LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter
 
 LOCAL_SRC_FILES:= \
   gl_code.cpp
diff --git a/opengl/tests/gldual/Android.mk b/opengl/tests/gldual/Android.mk
index b4b378e..42094c8 100644
--- a/opengl/tests/gldual/Android.mk
+++ b/opengl/tests/gldual/Android.mk
@@ -30,7 +30,7 @@
 # Optional tag would mean it doesn't get installed by default
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_CFLAGS := -Werror
+LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter
 
 LOCAL_SRC_FILES:= \
   gl_code.cpp
diff --git a/services/surfaceflinger/clz.cpp b/services/surfaceflinger/clz.cpp
deleted file mode 100644
index 2456b86..0000000
--- a/services/surfaceflinger/clz.cpp
+++ /dev/null
@@ -1,37 +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.
- */
-
-#include "clz.h"
-
-namespace android {
-
-int clz_impl(int32_t x)
-{
-#if defined(__arm__) && !defined(__thumb__)
-    return __builtin_clz(x);
-#else
-    if (!x) return 32;
-    int e = 31;
-    if (x&0xFFFF0000)   { e -=16; x >>=16; }
-    if (x&0x0000FF00)   { e -= 8; x >>= 8; }
-    if (x&0x000000F0)   { e -= 4; x >>= 4; }
-    if (x&0x0000000C)   { e -= 2; x >>= 2; }
-    if (x&0x00000002)   { e -= 1; }
-    return e;
-#endif
-}
-
-}; // namespace android