am e3d37a7b: Enable support RGBX_8888 for omap3

* commit 'e3d37a7b55f86f5d005dd67f828dcf51fe60c0f6':
  Enable support RGBX_8888 for omap3
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index b500a6b..3461e38 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -17,6 +17,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <inttypes.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stdbool.h>
@@ -83,6 +84,7 @@
     { "res",        "Resource Loading", ATRACE_TAG_RESOURCES, { } },
     { "dalvik",     "Dalvik VM",        ATRACE_TAG_DALVIK, { } },
     { "rs",         "RenderScript",     ATRACE_TAG_RS, { } },
+    { "bionic",     "Bionic C Library", ATRACE_TAG_BIONIC, { } },
     { "sched",      "CPU Scheduling",   0, {
         { REQ,      "/sys/kernel/debug/tracing/events/sched/sched_switch/enable" },
         { REQ,      "/sys/kernel/debug/tracing/events/sched/sched_wakeup/enable" },
@@ -368,7 +370,7 @@
 static bool setTagsProperty(uint64_t tags)
 {
     char buf[64];
-    snprintf(buf, 64, "%#llx", tags);
+    snprintf(buf, 64, "%#" PRIx64, tags);
     if (property_set(k_traceTagsProperty, buf) < 0) {
         fprintf(stderr, "error setting trace tags system property\n");
         return false;
@@ -665,7 +667,7 @@
     close(traceFD);
 }
 
-static void handleSignal(int signo)
+static void handleSignal(int /*signo*/)
 {
     if (!g_nohup) {
         g_traceAborted = true;
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
index dbf0877..ef5072a 100644
--- a/cmds/dumpstate/utils.c
+++ b/cmds/dumpstate/utils.c
@@ -469,7 +469,7 @@
         if (!mkdir(anr_traces_dir, 0775)) {
             chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM);
             chmod(anr_traces_dir, 0775);
-            if (selinux_android_restorecon(anr_traces_dir) == -1) {
+            if (selinux_android_restorecon(anr_traces_dir, 0) == -1) {
                 fprintf(stderr, "restorecon failed for %s: %s\n", anr_traces_dir, strerror(errno));
             }
         } else if (errno != EEXIST) {
diff --git a/cmds/flatland/Composers.cpp b/cmds/flatland/Composers.cpp
index 15cdb29..1173a81 100644
--- a/cmds/flatland/Composers.cpp
+++ b/cmds/flatland/Composers.cpp
@@ -122,12 +122,12 @@
     virtual void tearDown() {
     }
 
-    virtual bool compose(GLuint texName, const sp<GLConsumer>& glc) {
+    virtual bool compose(GLuint /*texName*/, const sp<GLConsumer>& /*glc*/) {
         return true;
     }
 
 protected:
-    virtual bool setUp(GLHelper* helper) {
+    virtual bool setUp(GLHelper* /*helper*/) {
         return true;
     }
 
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index 42694b3..05d082b 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -332,7 +332,7 @@
 
 static void printShaderSource(const char* const* src) {
     for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != NULL; i++) {
-        fprintf(stderr, "%3d: %s\n", i+1, src[i]);
+        fprintf(stderr, "%3zu: %s\n", i+1, src[i]);
     }
 }
 
diff --git a/cmds/flatland/Main.cpp b/cmds/flatland/Main.cpp
index d6ac3d2..c0e5b3d 100644
--- a/cmds/flatland/Main.cpp
+++ b/cmds/flatland/Main.cpp
@@ -600,7 +600,7 @@
 
     uint32_t runHeight = b.runHeights[run];
     uint32_t runWidth = b.width * runHeight / b.height;
-    printf(" %-*s | %4d x %4d | ", g_BenchmarkNameLen, b.name,
+    printf(" %-*s | %4d x %4d | ", static_cast<int>(g_BenchmarkNameLen), b.name,
             runWidth, runHeight);
     fflush(stdout);
 
@@ -690,8 +690,9 @@
     size_t len = strlen(scenario);
     size_t leftPad = (g_BenchmarkNameLen - len) / 2;
     size_t rightPad = g_BenchmarkNameLen - len - leftPad;
-    printf(" %*s%s%*s | Resolution  | Time (ms)\n", leftPad, "",
-            "Scenario", rightPad, "");
+    printf(" %*s%s%*s | Resolution  | Time (ms)\n",
+            static_cast<int>(leftPad), "",
+            "Scenario", static_cast<int>(rightPad), "");
 }
 
 // Run ALL the benchmarks!
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index e9d6b15..3930224 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -1,19 +1,20 @@
 /*
 ** Copyright 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 
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT 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 <sys/capability.h>
 #include "installd.h"
 #include <diskusage/dirsize.h>
@@ -84,6 +85,13 @@
         }
     }
 
+    if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
+        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(libsymlink);
+        unlink(pkgdir);
+        return -errno;
+    }
+
     if (symlink(applibdir, libsymlink) < 0) {
         ALOGE("couldn't symlink directory '%s' -> '%s': %s\n", libsymlink, applibdir,
                 strerror(errno));
@@ -91,13 +99,6 @@
         return -1;
     }
 
-    if (selinux_android_setfilecon2(pkgdir, pkgname, seinfo, uid) < 0) {
-        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(libsymlink);
-        unlink(pkgdir);
-        return -errno;
-    }
-
     if (chown(pkgdir, uid, gid) < 0) {
         ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
         unlink(libsymlink);
@@ -115,6 +116,8 @@
     if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, userid))
         return -1;
 
+    remove_profile_file(pkgname);
+
     /* delete contents AND directory, no exceptions */
     return delete_dir_contents(pkgdir, 1, NULL);
 }
@@ -155,7 +158,7 @@
     if (stat(pkgdir, &s) < 0) return -1;
 
     if (s.st_uid != 0 || s.st_gid != 0) {
-        ALOGE("fixing uid of non-root pkg: %s %lu %lu\n", pkgdir, s.st_uid, s.st_gid);
+        ALOGE("fixing uid of non-root pkg: %s %" PRIu32 " %" PRIu32 "\n", pkgdir, s.st_uid, s.st_gid);
         return -1;
     }
 
@@ -238,6 +241,13 @@
         }
     }
 
+    if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
+        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(libsymlink);
+        unlink(pkgdir);
+        return -errno;
+    }
+
     if (symlink(applibdir, libsymlink) < 0) {
         ALOGE("couldn't symlink directory for non-primary '%s' -> '%s': %s\n", libsymlink,
                 applibdir, strerror(errno));
@@ -245,13 +255,6 @@
         return -1;
     }
 
-    if (selinux_android_setfilecon2(pkgdir, pkgname, seinfo, uid) < 0) {
-        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(libsymlink);
-        unlink(pkgdir);
-        return -errno;
-    }
-
     if (chown(pkgdir, uid, uid) < 0) {
         ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
         unlink(libsymlink);
@@ -262,27 +265,40 @@
     return 0;
 }
 
-int delete_user(userid_t userid)
+int create_user(userid_t userid)
 {
-    char data_path[PKG_PATH_MAX];
-    if (create_user_path(data_path, userid)) {
-        return -1;
-    }
-    if (delete_dir_contents(data_path, 1, NULL)) {
-        return -1;
-    }
-
-    char media_path[PATH_MAX];
-    if (create_user_media_path(media_path, userid) == -1) {
-        return -1;
-    }
-    if (delete_dir_contents(media_path, 1, NULL) == -1) {
+    if (ensure_config_user_dirs(userid) == -1) {
         return -1;
     }
 
     return 0;
 }
 
+int delete_user(userid_t userid)
+{
+    int status = 0;
+
+    char data_path[PKG_PATH_MAX];
+    if ((create_user_path(data_path, userid) != 0)
+            || (delete_dir_contents(data_path, 1, NULL) != 0)) {
+        status = -1;
+    }
+
+    char media_path[PATH_MAX];
+    if ((create_user_media_path(media_path, userid) != 0)
+            || (delete_dir_contents(media_path, 1, NULL) != 0)) {
+        status = -1;
+    }
+
+    char config_path[PATH_MAX];
+    if ((create_user_config_path(config_path, userid) != 0)
+            || (delete_dir_contents(config_path, 1, NULL) != 0)) {
+        status = -1;
+    }
+
+    return status;
+}
+
 int delete_cache(const char *pkgname, userid_t userid)
 {
     char cachedir[PKG_PATH_MAX];
@@ -384,7 +400,7 @@
     return data_disk_free() >= free_size ? 0 : -1;
 }
 
-int move_dex(const char *src, const char *dst)
+int move_dex(const char *src, const char *dst, const char *instruction_set)
 {
     char src_dex[PKG_PATH_MAX];
     char dst_dex[PKG_PATH_MAX];
@@ -392,8 +408,8 @@
     if (validate_apk_path(src)) return -1;
     if (validate_apk_path(dst)) return -1;
 
-    if (create_cache_path(src_dex, src)) return -1;
-    if (create_cache_path(dst_dex, dst)) return -1;
+    if (create_cache_path(src_dex, src, instruction_set)) return -1;
+    if (create_cache_path(dst_dex, dst, instruction_set)) return -1;
 
     ALOGV("move %s -> %s\n", src_dex, dst_dex);
     if (rename(src_dex, dst_dex) < 0) {
@@ -404,12 +420,12 @@
     }
 }
 
-int rm_dex(const char *path)
+int rm_dex(const char *path, const char *instruction_set)
 {
     char dex_path[PKG_PATH_MAX];
 
     if (validate_apk_path(path)) return -1;
-    if (create_cache_path(dex_path, path)) return -1;
+    if (create_cache_path(dex_path, path, instruction_set)) return -1;
 
     ALOGV("unlink %s\n", dex_path);
     if (unlink(dex_path) < 0) {
@@ -422,8 +438,8 @@
 
 int get_size(const char *pkgname, userid_t userid, const char *apkpath,
              const char *libdirpath, const char *fwdlock_apkpath, const char *asecpath,
-             int64_t *_codesize, int64_t *_datasize, int64_t *_cachesize,
-             int64_t* _asecsize)
+             const char *instruction_set, int64_t *_codesize, int64_t *_datasize,
+             int64_t *_cachesize, int64_t* _asecsize)
 {
     DIR *d;
     int dfd;
@@ -453,7 +469,7 @@
         }
     }
         /* count the cached dexfile as code */
-    if (!create_cache_path(path, apkpath)) {
+    if (!create_cache_path(path, apkpath, instruction_set)) {
         if (stat(path, &s) == 0) {
             codesize += stat_size(&s);
         }
@@ -540,7 +556,7 @@
 }
 
 
-int create_cache_path(char path[PKG_PATH_MAX], const char *src)
+int create_cache_path(char path[PKG_PATH_MAX], const char *src, const char *instruction_set)
 {
     char *tmp;
     int srclen;
@@ -557,19 +573,21 @@
         return -1;
     }
 
-    dstlen = srclen + strlen(DALVIK_CACHE_PREFIX) + 
-        strlen(DALVIK_CACHE_POSTFIX) + 1;
-    
+    dstlen = srclen + strlen(DALVIK_CACHE_PREFIX) +
+        strlen(instruction_set) +
+        strlen(DALVIK_CACHE_POSTFIX) + 2;
+
     if (dstlen > PKG_PATH_MAX) {
         return -1;
     }
 
-    sprintf(path,"%s%s%s",
+    sprintf(path,"%s%s/%s%s",
             DALVIK_CACHE_PREFIX,
+            instruction_set,
             src + 1, /* skip the leading / */
             DALVIK_CACHE_POSTFIX);
-    
-    for(tmp = path + strlen(DALVIK_CACHE_PREFIX); *tmp; tmp++) {
+
+    for(tmp = path + strlen(DALVIK_CACHE_PREFIX) + strlen(instruction_set) + 1; *tmp; tmp++) {
         if (*tmp == '/') {
             *tmp = '@';
         }
@@ -579,8 +597,13 @@
 }
 
 static void run_dexopt(int zip_fd, int odex_fd, const char* input_file_name,
-    const char* output_file_name, const char* dexopt_flags)
+    const char* output_file_name)
 {
+    /* platform-specific flags affecting optimization and verification */
+    char dexopt_flags[PROPERTY_VALUE_MAX];
+    property_get("dalvik.vm.dexopt-flags", dexopt_flags, "");
+    ALOGV("dalvik.vm.dexopt-flags=%s\n", dexopt_flags);
+
     static const char* DEX_OPT_BIN = "/system/bin/dexopt";
     static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
     char zip_num[MAX_INT_LEN];
@@ -596,36 +619,90 @@
 }
 
 static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
-    const char* output_file_name, const char* dexopt_flags)
+    const char* output_file_name, const char *pkgname, const char *instruction_set)
 {
+    char dex2oat_flags[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_flags = property_get("dalvik.vm.dex2oat-flags", dex2oat_flags, NULL) > 0;
+    ALOGV("dalvik.vm.dex2oat-flags=%s\n", dex2oat_flags);
+
+    char prop_buf[PROPERTY_VALUE_MAX];
+    bool profiler = (property_get("dalvik.vm.profiler", prop_buf, "0") > 0) && (prop_buf[0] == '1');
+
     static const char* DEX2OAT_BIN = "/system/bin/dex2oat";
     static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
+    static const unsigned int MAX_INSTRUCTION_SET_LEN = 32;
+
+    if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) {
+        ALOGE("Instruction set %s longer than max length of %d",
+              instruction_set, MAX_INSTRUCTION_SET_LEN);
+        return;
+    }
+
     char zip_fd_arg[strlen("--zip-fd=") + MAX_INT_LEN];
     char zip_location_arg[strlen("--zip-location=") + PKG_PATH_MAX];
     char oat_fd_arg[strlen("--oat-fd=") + MAX_INT_LEN];
     char oat_location_arg[strlen("--oat-name=") + PKG_PATH_MAX];
+    char instruction_set_arg[strlen("--instruction-set=") + MAX_INSTRUCTION_SET_LEN];
+    char profile_file_arg[strlen("--profile-file=") + PKG_PATH_MAX];
+    char top_k_profile_threshold_arg[strlen("--top-k-profile-threshold=") + PROPERTY_VALUE_MAX];
 
     sprintf(zip_fd_arg, "--zip-fd=%d", zip_fd);
     sprintf(zip_location_arg, "--zip-location=%s", input_file_name);
     sprintf(oat_fd_arg, "--oat-fd=%d", oat_fd);
     sprintf(oat_location_arg, "--oat-location=%s", output_file_name);
+    sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
+
+    bool have_profile_file = false;
+    bool have_top_k_profile_threshold = false;
+    if (profiler && (strcmp(pkgname, "*") != 0)) {
+        char profile_file[PKG_PATH_MAX];
+        snprintf(profile_file, sizeof(profile_file), "%s/%s",
+                 DALVIK_CACHE_PREFIX "profiles", pkgname);
+        struct stat st;
+        if ((stat(profile_file, &st) == 0) && (st.st_size > 0)) {
+            sprintf(profile_file_arg, "--profile-file=%s", profile_file);
+            have_profile_file = true;
+            if (property_get("dalvik.vm.profile.top-k-thr", prop_buf, NULL) > 0) {
+                snprintf(top_k_profile_threshold_arg, sizeof(top_k_profile_threshold_arg),
+                         "--top-k-profile-threshold=%s", prop_buf);
+                have_top_k_profile_threshold = true;
+            }
+        }
+    }
 
     ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, input_file_name, output_file_name);
-    execl(DEX2OAT_BIN, DEX2OAT_BIN,
-          zip_fd_arg, zip_location_arg,
-          oat_fd_arg, oat_location_arg,
-          (char*) NULL);
+
+    char* argv[7  // program name, mandatory arguments and the final NULL
+               + (have_profile_file ? 1 : 0)
+               + (have_top_k_profile_threshold ? 1 : 0)
+               + (have_dex2oat_flags ? 1 : 0)];
+    int i = 0;
+    argv[i++] = (char*)DEX2OAT_BIN;
+    argv[i++] = zip_fd_arg;
+    argv[i++] = zip_location_arg;
+    argv[i++] = oat_fd_arg;
+    argv[i++] = oat_location_arg;
+    argv[i++] = instruction_set_arg;
+    if (have_profile_file) {
+        argv[i++] = profile_file_arg;
+    }
+    if (have_top_k_profile_threshold) {
+        argv[i++] = top_k_profile_threshold_arg;
+    }
+    if (have_dex2oat_flags) {
+        argv[i++] = dex2oat_flags;
+    }
+    argv[i] = NULL;
+
+    execv(DEX2OAT_BIN, (char* const *)argv);
     ALOGE("execl(%s) failed: %s\n", DEX2OAT_BIN, strerror(errno));
 }
 
-static int wait_dexopt(pid_t pid, const char* apk_path)
+static int wait_child(pid_t pid)
 {
     int status;
     pid_t got_pid;
 
-    /*
-     * Wait for the optimization process to finish.
-     */
     while (1) {
         got_pid = waitpid(pid, &status, 0);
         if (got_pid == -1 && errno == EINTR) {
@@ -641,21 +718,18 @@
     }
 
     if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
-        ALOGV("DexInv: --- END '%s' (success) ---\n", apk_path);
         return 0;
     } else {
-        ALOGW("DexInv: --- END '%s' --- status=0x%04x, process failed\n",
-            apk_path, status);
         return status;      /* always nonzero */
     }
 }
 
-int dexopt(const char *apk_path, uid_t uid, int is_public)
+int dexopt(const char *apk_path, uid_t uid, int is_public,
+           const char *pkgname, const char *instruction_set)
 {
     struct utimbuf ut;
     struct stat apk_stat, dex_stat;
     char out_path[PKG_PATH_MAX];
-    char dexopt_flags[PROPERTY_VALUE_MAX];
     char persist_sys_dalvik_vm_lib[PROPERTY_VALUE_MAX];
     char *end;
     int res, zip_fd=-1, out_fd=-1;
@@ -664,22 +738,22 @@
         return -1;
     }
 
-    /* platform-specific flags affecting optimization and verification */
-    property_get("dalvik.vm.dexopt-flags", dexopt_flags, "");
-    ALOGV("dalvik.vm.dexopt_flags=%s\n", dexopt_flags);
-
-    /* The command to run depend ones the value of persist.sys.dalvik.vm.lib */
-    property_get("persist.sys.dalvik.vm.lib", persist_sys_dalvik_vm_lib, "libdvm.so");
+    /* The command to run depend on the value of persist.sys.dalvik.vm.lib */
+    property_get("persist.sys.dalvik.vm.lib.2", persist_sys_dalvik_vm_lib, "libart.so");
 
     /* Before anything else: is there a .odex file?  If so, we have
      * precompiled the apk and there is nothing to do here.
      */
-    sprintf(out_path, "%s%s", apk_path, ".odex");
-    if (stat(out_path, &dex_stat) == 0) {
-        return 0;
+    strcpy(out_path, apk_path);
+    end = strrchr(out_path, '.');
+    if (end != NULL) {
+        strcpy(end, ".odex");
+        if (stat(out_path, &dex_stat) == 0) {
+            return 0;
+        }
     }
 
-    if (create_cache_path(out_path, apk_path)) {
+    if (create_cache_path(out_path, apk_path, instruction_set)) {
         return -1;
     }
 
@@ -709,6 +783,12 @@
         goto fail;
     }
 
+    // Create profile file if there is a package name present.
+    if (strcmp(pkgname, "*") != 0) {
+        create_profile_file(pkgname, uid);
+    }
+
+
     ALOGV("DexInv: --- BEGIN '%s' ---\n", apk_path);
 
     pid_t pid;
@@ -739,17 +819,19 @@
         }
 
         if (strncmp(persist_sys_dalvik_vm_lib, "libdvm", 6) == 0) {
-            run_dexopt(zip_fd, out_fd, apk_path, out_path, dexopt_flags);
+            run_dexopt(zip_fd, out_fd, apk_path, out_path);
         } else if (strncmp(persist_sys_dalvik_vm_lib, "libart", 6) == 0) {
-            run_dex2oat(zip_fd, out_fd, apk_path, out_path, dexopt_flags);
+            run_dex2oat(zip_fd, out_fd, apk_path, out_path, pkgname, instruction_set);
         } else {
             exit(69);   /* Unexpected persist.sys.dalvik.vm.lib value */
         }
         exit(68);   /* only get here on exec failure */
     } else {
-        res = wait_dexopt(pid, apk_path);
-        if (res != 0) {
-            ALOGE("dexopt in='%s' out='%s' res=%d\n", apk_path, out_path, res);
+        res = wait_child(pid);
+        if (res == 0) {
+            ALOGV("DexInv: --- END '%s' (success) ---\n", apk_path);
+        } else {
+            ALOGE("DexInv: --- END '%s' --- status=0x%04x, process failed\n", apk_path, res);
             goto fail;
         }
     }
@@ -803,12 +885,12 @@
 
     int srcend = strlen(srcpath);
     int dstend = strlen(dstpath);
-    
+
     if (lstat(srcpath, statbuf) < 0) {
         ALOGW("Unable to stat %s: %s\n", srcpath, strerror(errno));
         return 1;
     }
-    
+
     if ((statbuf->st_mode&S_IFDIR) == 0) {
         mkinnerdirs(dstpath, dstbasepos, S_IRWXU|S_IRWXG|S_IXOTH,
                 dstuid, dstgid, statbuf);
@@ -834,7 +916,7 @@
     }
 
     res = 0;
-    
+
     while ((de = readdir(d))) {
         const char *name = de->d_name;
             /* always skip "." and ".." */
@@ -842,32 +924,32 @@
             if (name[1] == 0) continue;
             if ((name[1] == '.') && (name[2] == 0)) continue;
         }
-        
+
         if ((srcend+strlen(name)) >= (PKG_PATH_MAX-2)) {
             ALOGW("Source path too long; skipping: %s/%s\n", srcpath, name);
             continue;
         }
-        
+
         if ((dstend+strlen(name)) >= (PKG_PATH_MAX-2)) {
             ALOGW("Destination path too long; skipping: %s/%s\n", dstpath, name);
             continue;
         }
-        
+
         srcpath[srcend] = dstpath[dstend] = '/';
         strcpy(srcpath+srcend+1, name);
         strcpy(dstpath+dstend+1, name);
-        
+
         if (movefileordir(srcpath, dstpath, dstbasepos, dstuid, dstgid, statbuf) != 0) {
             res = 1;
         }
-        
+
         // Note: we will be leaving empty directories behind in srcpath,
         // but that is okay, the package manager will be erasing all of the
         // data associated with .apks that disappear.
-        
+
         srcpath[srcend] = dstpath[dstend] = 0;
     }
-    
+
     closedir(d);
     return res;
 }
@@ -909,7 +991,7 @@
                         UPDATE_COMMANDS_DIR_PREFIX, name);
                 continue;
             }
-            
+
             bufp = 0;
             bufe = 0;
             buf[PKG_PATH_MAX] = 0;
@@ -1103,3 +1185,195 @@
 
     return rc;
 }
+
+static void run_idmap(const char *target_apk, const char *overlay_apk, int idmap_fd)
+{
+    static const char *IDMAP_BIN = "/system/bin/idmap";
+    static const size_t MAX_INT_LEN = 32;
+    char idmap_str[MAX_INT_LEN];
+
+    snprintf(idmap_str, sizeof(idmap_str), "%d", idmap_fd);
+
+    execl(IDMAP_BIN, IDMAP_BIN, "--fd", target_apk, overlay_apk, idmap_str, (char*)NULL);
+    ALOGE("execl(%s) failed: %s\n", IDMAP_BIN, strerror(errno));
+}
+
+// Transform string /a/b/c.apk to (prefix)/a@b@c.apk@(suffix)
+// eg /a/b/c.apk to /data/resource-cache/a@b@c.apk@idmap
+static int flatten_path(const char *prefix, const char *suffix,
+        const char *overlay_path, char *idmap_path, size_t N)
+{
+    if (overlay_path == NULL || idmap_path == NULL) {
+        return -1;
+    }
+    const size_t len_overlay_path = strlen(overlay_path);
+    // will access overlay_path + 1 further below; requires absolute path
+    if (len_overlay_path < 2 || *overlay_path != '/') {
+        return -1;
+    }
+    const size_t len_idmap_root = strlen(prefix);
+    const size_t len_suffix = strlen(suffix);
+    if (SIZE_MAX - len_idmap_root < len_overlay_path ||
+            SIZE_MAX - (len_idmap_root + len_overlay_path) < len_suffix) {
+        // additions below would cause overflow
+        return -1;
+    }
+    if (N < len_idmap_root + len_overlay_path + len_suffix) {
+        return -1;
+    }
+    memset(idmap_path, 0, N);
+    snprintf(idmap_path, N, "%s%s%s", prefix, overlay_path + 1, suffix);
+    char *ch = idmap_path + len_idmap_root;
+    while (*ch != '\0') {
+        if (*ch == '/') {
+            *ch = '@';
+        }
+        ++ch;
+    }
+    return 0;
+}
+
+int idmap(const char *target_apk, const char *overlay_apk, uid_t uid)
+{
+    ALOGV("idmap target_apk=%s overlay_apk=%s uid=%d\n", target_apk, overlay_apk, uid);
+
+    int idmap_fd = -1;
+    char idmap_path[PATH_MAX];
+
+    if (flatten_path(IDMAP_PREFIX, IDMAP_SUFFIX, overlay_apk,
+                idmap_path, sizeof(idmap_path)) == -1) {
+        ALOGE("idmap cannot generate idmap path for overlay %s\n", overlay_apk);
+        goto fail;
+    }
+
+    unlink(idmap_path);
+    idmap_fd = open(idmap_path, O_RDWR | O_CREAT | O_EXCL, 0644);
+    if (idmap_fd < 0) {
+        ALOGE("idmap cannot open '%s' for output: %s\n", idmap_path, strerror(errno));
+        goto fail;
+    }
+    if (fchown(idmap_fd, AID_SYSTEM, uid) < 0) {
+        ALOGE("idmap cannot chown '%s'\n", idmap_path);
+        goto fail;
+    }
+    if (fchmod(idmap_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) {
+        ALOGE("idmap cannot chmod '%s'\n", idmap_path);
+        goto fail;
+    }
+
+    pid_t pid;
+    pid = fork();
+    if (pid == 0) {
+        /* child -- drop privileges before continuing */
+        if (setgid(uid) != 0) {
+            ALOGE("setgid(%d) failed during idmap\n", uid);
+            exit(1);
+        }
+        if (setuid(uid) != 0) {
+            ALOGE("setuid(%d) failed during idmap\n", uid);
+            exit(1);
+        }
+        if (flock(idmap_fd, LOCK_EX | LOCK_NB) != 0) {
+            ALOGE("flock(%s) failed during idmap: %s\n", idmap_path, strerror(errno));
+            exit(1);
+        }
+
+        run_idmap(target_apk, overlay_apk, idmap_fd);
+        exit(1); /* only if exec call to idmap failed */
+    } else {
+        int status = wait_child(pid);
+        if (status != 0) {
+            ALOGE("idmap failed, status=0x%04x\n", status);
+            goto fail;
+        }
+    }
+
+    close(idmap_fd);
+    return 0;
+fail:
+    if (idmap_fd >= 0) {
+        close(idmap_fd);
+        unlink(idmap_path);
+    }
+    return -1;
+}
+
+int restorecon_data(const char* pkgName, const char* seinfo, uid_t uid)
+{
+    struct dirent *entry;
+    DIR *d;
+    struct stat s;
+    char *userdir;
+    char *primarydir;
+    char *pkgdir;
+    int ret = 0;
+
+    // SELINUX_ANDROID_RESTORECON_DATADATA flag is set by libselinux. Not needed here.
+    unsigned int flags = SELINUX_ANDROID_RESTORECON_RECURSE;
+
+    if (!pkgName || !seinfo) {
+        ALOGE("Package name or seinfo tag is null when trying to restorecon.");
+        return -1;
+    }
+
+    if (asprintf(&primarydir, "%s%s%s", android_data_dir.path, PRIMARY_USER_PREFIX, pkgName) < 0) {
+        return -1;
+    }
+
+    // Relabel for primary user.
+    if (selinux_android_restorecon_pkgdir(primarydir, seinfo, uid, flags) < 0) {
+        ALOGE("restorecon failed for %s: %s\n", primarydir, strerror(errno));
+        ret |= -1;
+    }
+
+    if (asprintf(&userdir, "%s%s", android_data_dir.path, SECONDARY_USER_PREFIX) < 0) {
+        free(primarydir);
+        return -1;
+    }
+
+    // Relabel package directory for all secondary users.
+    d = opendir(userdir);
+    if (d == NULL) {
+        free(primarydir);
+        free(userdir);
+        return -1;
+    }
+
+    while ((entry = readdir(d))) {
+        if (entry->d_type != DT_DIR) {
+            continue;
+        }
+
+        const char *user = entry->d_name;
+        // Ignore "." and ".."
+        if (!strcmp(user, ".") || !strcmp(user, "..")) {
+            continue;
+        }
+
+        // user directories start with a number
+        if (user[0] < '0' || user[0] > '9') {
+            ALOGE("Expecting numbered directory during restorecon. Instead got '%s'.", user);
+            continue;
+        }
+
+        if (asprintf(&pkgdir, "%s%s/%s", userdir, user, pkgName) < 0) {
+            continue;
+        }
+
+        if (stat(pkgdir, &s) < 0) {
+            free(pkgdir);
+            continue;
+        }
+
+        if (selinux_android_restorecon_pkgdir(pkgdir, seinfo, uid, flags) < 0) {
+            ALOGE("restorecon failed for %s: %s\n", pkgdir, strerror(errno));
+            ret |= -1;
+        }
+        free(pkgdir);
+    }
+
+    closedir(d);
+    free(primarydir);
+    free(userdir);
+    return ret;
+}
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
index 0c80dac..f714836 100644
--- a/cmds/installd/installd.c
+++ b/cmds/installd/installd.c
@@ -38,18 +38,18 @@
 
 static int do_dexopt(char **arg, char reply[REPLY_MAX])
 {
-        /* apk_path, uid, is_public */
-    return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]));
+        /* apk_path, uid, is_public, pkgname, instruction_set */
+    return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4]);
 }
 
 static int do_move_dex(char **arg, char reply[REPLY_MAX])
 {
-    return move_dex(arg[0], arg[1]); /* src, dst */
+    return move_dex(arg[0], arg[1], arg[2]); /* src, dst, instruction_set */
 }
 
 static int do_rm_dex(char **arg, char reply[REPLY_MAX])
 {
-    return rm_dex(arg[0]); /* pkgname */
+    return rm_dex(arg[0], arg[1]); /* pkgname, instruction_set */
 }
 
 static int do_remove(char **arg, char reply[REPLY_MAX])
@@ -87,7 +87,7 @@
 
         /* pkgdir, userid, apkpath */
     res = get_size(arg[0], atoi(arg[1]), arg[2], arg[3], arg[4], arg[5],
-            &codesize, &datasize, &cachesize, &asecsize);
+            arg[6], &codesize, &datasize, &cachesize, &asecsize);
 
     /*
      * Each int64_t can take up 22 characters printed out. Make sure it
@@ -109,6 +109,11 @@
                              /* pkgname, uid, userid, seinfo */
 }
 
+static int do_mk_user(char **arg, char reply[REPLY_MAX])
+{
+    return create_user(atoi(arg[0])); /* userid */
+}
+
 static int do_rm_user(char **arg, char reply[REPLY_MAX])
 {
     return delete_user(atoi(arg[0])); /* userid */
@@ -124,6 +129,17 @@
     return linklib(arg[0], arg[1], atoi(arg[2]));
 }
 
+static int do_idmap(char **arg, char reply[REPLY_MAX])
+{
+    return idmap(arg[0], arg[1], atoi(arg[2]));
+}
+
+static int do_restorecon_data(char **arg, char reply[REPLY_MAX] __attribute__((unused)))
+{
+    return restorecon_data(arg[0], arg[1], atoi(arg[2]));
+                             /* pkgName, seinfo, uid*/
+}
+
 struct cmdinfo {
     const char *name;
     unsigned numargs;
@@ -133,20 +149,23 @@
 struct cmdinfo cmds[] = {
     { "ping",                 0, do_ping },
     { "install",              4, do_install },
-    { "dexopt",               3, do_dexopt },
-    { "movedex",              2, do_move_dex },
-    { "rmdex",                1, do_rm_dex },
+    { "dexopt",               5, do_dexopt },
+    { "movedex",              3, do_move_dex },
+    { "rmdex",                2, do_rm_dex },
     { "remove",               2, do_remove },
     { "rename",               2, do_rename },
     { "fixuid",               3, do_fixuid },
     { "freecache",            1, do_free_cache },
     { "rmcache",              2, do_rm_cache },
-    { "getsize",              6, do_get_size },
+    { "getsize",              7, do_get_size },
     { "rmuserdata",           2, do_rm_user_data },
     { "movefiles",            0, do_movefiles },
     { "linklib",              3, do_linklib },
     { "mkuserdata",           4, do_mk_user_data },
+    { "mkuser",               1, do_mk_user },
     { "rmuser",               1, do_rm_user },
+    { "idmap",                3, do_idmap },
+    { "restorecondata",       3, do_restorecon_data },
 };
 
 static int readx(int s, void *_buf, int count)
@@ -392,7 +411,7 @@
             goto fail;
         }
 
-        if (selinux_android_restorecon(android_media_dir.path)) {
+        if (selinux_android_restorecon(android_media_dir.path, 0)) {
             goto fail;
         }
 
@@ -470,6 +489,66 @@
         goto fail;
     }
 
+    if (ensure_config_user_dirs(0) == -1) {
+        ALOGE("Failed to setup misc for user 0");
+        goto fail;
+    }
+
+    if (version == 2) {
+        ALOGD("Upgrading to /data/misc/user directories");
+
+        DIR *dir;
+        struct dirent *dirent;
+        char user_data_dir[PATH_MAX];
+
+        dir = opendir(user_data_dir);
+        if (dir != NULL) {
+            while ((dirent = readdir(dir))) {
+                if (dirent->d_type == DT_DIR) {
+                    const char *name = dirent->d_name;
+
+                    // skip "." and ".."
+                    if (name[0] == '.') {
+                        if (name[1] == 0) continue;
+                        if ((name[1] == '.') && (name[2] == 0)) continue;
+                    }
+
+                    // /data/misc/user/<user_id>
+                    if (ensure_config_user_dirs(atoi(name)) == -1) {
+                        goto fail;
+                    }
+                }
+            }
+            closedir(dir);
+        }
+
+        // Just rename keychain files into user/0; they should already have the right permissions
+        char misc_dir[PATH_MAX];
+        char keychain_added_dir[PATH_MAX];
+        char keychain_removed_dir[PATH_MAX];
+        char config_added_dir[PATH_MAX];
+        char config_removed_dir[PATH_MAX];
+
+        snprintf(misc_dir, PATH_MAX, "%s/misc", android_data_dir.path);
+        snprintf(keychain_added_dir, PATH_MAX, "%s/keychain/cacerts-added", misc_dir);
+        snprintf(keychain_removed_dir, PATH_MAX, "%s/keychain/cacerts-removed", misc_dir);
+        snprintf(config_added_dir, PATH_MAX, "%s/user/0/cacerts-added", misc_dir);
+        snprintf(config_removed_dir, PATH_MAX, "%s/user/0/cacerts-removed", misc_dir);
+
+        if (access(keychain_added_dir, F_OK) == 0) {
+            if (rename(keychain_added_dir, config_added_dir) != 0) {
+                goto fail;
+            }
+        }
+        if (access(keychain_removed_dir, F_OK) == 0) {
+            if (rename(keychain_removed_dir, config_removed_dir) != 0) {
+                goto fail;
+            }
+        }
+
+        version = 3;
+    }
+
     // Persist layout version if changed
     if (version != oldVersion) {
         if (fs_write_atomic_int(version_path, version) == -1) {
@@ -515,6 +594,7 @@
     capdata[CAP_TO_INDEX(CAP_CHOWN)].permitted        |= CAP_TO_MASK(CAP_CHOWN);
     capdata[CAP_TO_INDEX(CAP_SETUID)].permitted       |= CAP_TO_MASK(CAP_SETUID);
     capdata[CAP_TO_INDEX(CAP_SETGID)].permitted       |= CAP_TO_MASK(CAP_SETGID);
+    capdata[CAP_TO_INDEX(CAP_FOWNER)].permitted       |= CAP_TO_MASK(CAP_FOWNER);
 
     capdata[0].effective = capdata[0].permitted;
     capdata[1].effective = capdata[1].permitted;
@@ -527,6 +607,27 @@
     }
 }
 
+static int log_callback(int type, const char *fmt, ...) {
+    va_list ap;
+    int priority;
+
+    switch (type) {
+    case SELINUX_WARNING:
+        priority = ANDROID_LOG_WARN;
+        break;
+    case SELINUX_INFO:
+        priority = ANDROID_LOG_INFO;
+        break;
+    default:
+        priority = ANDROID_LOG_ERROR;
+        break;
+    }
+    va_start(ap, fmt);
+    LOG_PRI_VA(priority, "SELinux", fmt, ap);
+    va_end(ap);
+    return 0;
+}
+
 int main(const int argc, const char *argv[]) {
     char buf[BUFFER_MAX];
     struct sockaddr addr;
@@ -536,6 +637,10 @@
 
     ALOGI("installd firing up\n");
 
+    union selinux_callback cb;
+    cb.func_log = log_callback;
+    selinux_set_callback(SELINUX_CB_LOG, cb);
+
     if (initialize_globals() < 0) {
         ALOGE("Could not initialize globals; exiting.\n");
         exit(1);
diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h
index 9ca2f86..ff26e49 100644
--- a/cmds/installd/installd.h
+++ b/cmds/installd/installd.h
@@ -75,6 +75,9 @@
 
 #define UPDATE_COMMANDS_DIR_PREFIX  "/system/etc/updatecmds/"
 
+#define IDMAP_PREFIX           "/data/resource-cache/"
+#define IDMAP_SUFFIX           "@idmap"
+
 #define PKG_NAME_MAX  128   /* largest allowed package name */
 #define PKG_PATH_MAX  256   /* max size of any path we use */
 
@@ -142,6 +145,8 @@
 
 int create_user_media_path(char path[PKG_PATH_MAX], userid_t userid);
 
+int create_user_config_path(char path[PKG_PATH_MAX], userid_t userid);
+
 int create_move_path(char path[PKG_PATH_MAX],
                      const char* pkgname,
                      const char* leaf,
@@ -149,7 +154,8 @@
 
 int is_valid_package_name(const char* pkgname);
 
-int create_cache_path(char path[PKG_PATH_MAX], const char *src);
+int create_cache_path(char path[PKG_PATH_MAX], const char *src,
+                      const char *instruction_set);
 
 int delete_dir_contents(const char *pathname,
                         int also_delete_dir,
@@ -186,6 +192,9 @@
 
 int ensure_dir(const char* path, mode_t mode, uid_t uid, gid_t gid);
 int ensure_media_user_dirs(userid_t userid);
+int ensure_config_user_dirs(userid_t userid);
+int create_profile_file(const char *pkgname, gid_t gid);
+void remove_profile_file(const char *pkgname);
 
 /* commands.c */
 
@@ -195,15 +204,19 @@
 int fix_uid(const char *pkgname, uid_t uid, gid_t gid);
 int delete_user_data(const char *pkgname, userid_t userid);
 int make_user_data(const char *pkgname, uid_t uid, userid_t userid, const char* seinfo);
+int create_user(userid_t userid);
 int delete_user(userid_t userid);
 int delete_cache(const char *pkgname, userid_t userid);
-int move_dex(const char *src, const char *dst);
-int rm_dex(const char *path);
+int move_dex(const char *src, const char *dst, const char *instruction_set);
+int rm_dex(const char *path, const char *instruction_set);
 int protect(char *pkgname, gid_t gid);
 int get_size(const char *pkgname, userid_t userid, const char *apkpath, const char *libdirpath,
-             const char *fwdlock_apkpath, const char *asecpath, int64_t *codesize,
-             int64_t *datasize, int64_t *cachesize, int64_t *asecsize);
+             const char *fwdlock_apkpath, const char *asecpath, const char *instruction_set,
+             int64_t *codesize, int64_t *datasize, int64_t *cachesize, int64_t *asecsize);
 int free_cache(int64_t free_size);
-int dexopt(const char *apk_path, uid_t uid, int is_public);
+int dexopt(const char *apk_path, uid_t uid, int is_public, const char *pkgName,
+           const char *instruction_set);
 int movefiles();
 int linklib(const char* target, const char* source, int userId);
+int idmap(const char *target_path, const char *overlay_path, uid_t uid);
+int restorecon_data();
diff --git a/cmds/installd/tests/Android.mk b/cmds/installd/tests/Android.mk
index c0192f4..4faf3c0 100644
--- a/cmds/installd/tests/Android.mk
+++ b/cmds/installd/tests/Android.mk
@@ -18,7 +18,7 @@
     libgtest_main
 
 c_includes := \
-    frameworks/base/cmds/installd
+    frameworks/native/cmds/installd
 
 $(foreach file,$(test_src_files), \
     $(eval include $(CLEAR_VARS)) \
diff --git a/cmds/installd/utils.c b/cmds/installd/utils.c
index ef634c6..420ad5e 100644
--- a/cmds/installd/utils.c
+++ b/cmds/installd/utils.c
@@ -1,16 +1,16 @@
 /*
 ** Copyright 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 
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
@@ -149,6 +149,17 @@
     return 0;
 }
 
+/**
+ * Create the path name for config for a certain userid.
+ * Returns 0 on success, and -1 on failure.
+ */
+int create_user_config_path(char path[PATH_MAX], userid_t userid) {
+    if (snprintf(path, PATH_MAX, "%s%d", "/data/misc/user/", userid) > PATH_MAX) {
+        return -1;
+    }
+    return 0;
+}
+
 int create_move_path(char path[PKG_PATH_MAX],
     const char* pkgname,
     const char* leaf,
@@ -435,7 +446,7 @@
 {
     cache->numCollected++;
     if ((cache->numCollected%20000) == 0) {
-        ALOGI("Collected cache so far: %d directories, %d files",
+        ALOGI("Collected cache so far: %zd directories, %zd files",
             cache->numDirs, cache->numFiles);
     }
 }
@@ -730,7 +741,7 @@
     int skip = 0;
     char path[PATH_MAX];
 
-    ALOGI("Collected cache files: %d directories, %d files",
+    ALOGI("Collected cache files: %zd directories, %zd files",
         cache->numDirs, cache->numFiles);
 
     CACHE_NOISY(ALOGI("Sorting files..."));
@@ -1005,3 +1016,82 @@
 
     return 0;
 }
+
+int ensure_config_user_dirs(userid_t userid) {
+    char config_user_path[PATH_MAX];
+    char path[PATH_MAX];
+
+    // writable by system, readable by any app within the same user
+    const int uid = (userid * AID_USER) + AID_SYSTEM;
+    const int gid = (userid * AID_USER) + AID_EVERYBODY;
+
+    // Ensure /data/misc/user/<userid> exists
+    create_user_config_path(config_user_path, userid);
+    if (fs_prepare_dir(config_user_path, 0750, uid, gid) == -1) {
+        return -1;
+    }
+
+   return 0;
+}
+
+int create_profile_file(const char *pkgname, gid_t gid) {
+    const char *profile_dir = DALVIK_CACHE_PREFIX "profiles";
+    struct stat profileStat;
+    char profile_file[PKG_PATH_MAX];
+
+    // If we don't have a profile directory under dalvik-cache we need to create one.
+    if (stat(profile_dir, &profileStat) < 0) {
+        // Create the profile directory under dalvik-cache.
+        if (mkdir(profile_dir, 0711) < 0) {
+            ALOGE("cannot make profile dir '%s': %s\n", profile_dir, strerror(errno));
+            return -1;
+        }
+
+        // Make the profile directory write-only for group and other. Owner can rwx it.
+        if (chmod(profile_dir, 0711) < 0) {
+            ALOGE("cannot chown profile dir '%s': %s\n", profile_dir, strerror(errno));
+            rmdir(profile_dir);
+            return -1;
+        }
+
+        if (selinux_android_restorecon(profile_dir, 0) < 0) {
+            ALOGE("cannot restorecon profile dir '%s': %s\n", profile_dir, strerror(errno));
+            rmdir(profile_dir);
+            return -1;
+        }
+    }
+
+    snprintf(profile_file, sizeof(profile_file), "%s/%s", profile_dir, pkgname);
+
+    // The 'system' user needs to be able to read the profile to determine if dex2oat
+    // needs to be run.  This is done in dalvik.system.DexFile.isDexOptNeededInternal().  So
+    // we make it world readable.  Not a problem since the dalvik cache is world
+    // readable anyway.
+
+    int fd = open(profile_file, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0664);
+
+    // Open will fail if the file already exists.  We want to ignore that.
+    if (fd >= 0) {
+        if (fchown(fd, -1, gid) < 0) {
+            ALOGE("cannot chown profile file '%s': %s\n", profile_file, strerror(errno));
+            close(fd);
+            unlink(profile_file);
+            return -1;
+        }
+
+        if (fchmod(fd, 0664) < 0) {
+            ALOGE("cannot chmod profile file '%s': %s\n", profile_file, strerror(errno));
+            close(fd);
+            unlink(profile_file);
+            return -1;
+        }
+        close(fd);
+    }
+    return 0;
+}
+
+void remove_profile_file(const char *pkgname) {
+    char profile_file[PKG_PATH_MAX];
+    snprintf(profile_file, sizeof(profile_file), "%s/%s", DALVIK_CACHE_PREFIX "profiles", pkgname);
+    unlink(profile_file);
+}
diff --git a/cmds/servicemanager/Android.mk b/cmds/servicemanager/Android.mk
index 8840867..4ab8df6 100644
--- a/cmds/servicemanager/Android.mk
+++ b/cmds/servicemanager/Android.mk
@@ -1,12 +1,25 @@
 LOCAL_PATH:= $(call my-dir)
 
-#include $(CLEAR_VARS)
-#LOCAL_SRC_FILES := bctest.c binder.c
-#LOCAL_MODULE := bctest
-#include $(BUILD_EXECUTABLE)
+svc_c_flags =	\
+	-Wall -Wextra \
+
+ifneq ($(TARGET_USES_64_BIT_BINDER),true)
+ifneq ($(TARGET_IS_64_BIT),true)
+svc_c_flags += -DBINDER_IPC_32BIT=1
+endif
+endif
+
+include $(CLEAR_VARS)
+LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SRC_FILES := bctest.c binder.c
+LOCAL_CFLAGS += $(svc_c_flags)
+LOCAL_MODULE := bctest
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
 
 include $(CLEAR_VARS)
 LOCAL_SHARED_LIBRARIES := liblog
 LOCAL_SRC_FILES := service_manager.c binder.c
+LOCAL_CFLAGS += $(svc_c_flags)
 LOCAL_MODULE := servicemanager
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/servicemanager/bctest.c b/cmds/servicemanager/bctest.c
index ff5aced..e02b45d 100644
--- a/cmds/servicemanager/bctest.c
+++ b/cmds/servicemanager/bctest.c
@@ -7,9 +7,9 @@
 
 #include "binder.h"
 
-void *svcmgr_lookup(struct binder_state *bs, void *target, const char *name)
+uint32_t svcmgr_lookup(struct binder_state *bs, uint32_t target, const char *name)
 {
-    void *ptr;
+    uint32_t handle;
     unsigned iodata[512/4];
     struct binder_io msg, reply;
 
@@ -21,19 +21,19 @@
     if (binder_call(bs, &msg, &reply, target, SVC_MGR_CHECK_SERVICE))
         return 0;
 
-    ptr = bio_get_ref(&reply);
+    handle = bio_get_ref(&reply);
 
-    if (ptr)
-        binder_acquire(bs, ptr);
+    if (handle)
+        binder_acquire(bs, handle);
 
     binder_done(bs, &msg, &reply);
 
-    return ptr;
+    return handle;
 }
 
-int svcmgr_publish(struct binder_state *bs, void *target, const char *name, void *ptr)
+int svcmgr_publish(struct binder_state *bs, uint32_t target, const char *name, void *ptr)
 {
-    unsigned status;
+    int status;
     unsigned iodata[512/4];
     struct binder_io msg, reply;
 
@@ -59,29 +59,33 @@
 {
     int fd;
     struct binder_state *bs;
-    void *svcmgr = BINDER_SERVICE_MANAGER;
+    uint32_t svcmgr = BINDER_SERVICE_MANAGER;
+    uint32_t handle;
 
     bs = binder_open(128*1024);
+    if (!bs) {
+        fprintf(stderr, "failed to open binder driver\n");
+        return -1;
+    }
 
     argc--;
     argv++;
     while (argc > 0) {
         if (!strcmp(argv[0],"alt")) {
-            void *ptr = svcmgr_lookup(bs, svcmgr, "alt_svc_mgr");
-            if (!ptr) {
+            handle = svcmgr_lookup(bs, svcmgr, "alt_svc_mgr");
+            if (!handle) {
                 fprintf(stderr,"cannot find alt_svc_mgr\n");
                 return -1;
             }
-            svcmgr = ptr;
-            fprintf(stderr,"svcmgr is via %p\n", ptr);
+            svcmgr = handle;
+            fprintf(stderr,"svcmgr is via %x\n", handle);
         } else if (!strcmp(argv[0],"lookup")) {
-            void *ptr;
             if (argc < 2) {
                 fprintf(stderr,"argument required\n");
                 return -1;
             }
-            ptr = svcmgr_lookup(bs, svcmgr, argv[1]);
-            fprintf(stderr,"lookup(%s) = %p\n", argv[1], ptr);
+            handle = svcmgr_lookup(bs, svcmgr, argv[1]);
+            fprintf(stderr,"lookup(%s) = %x\n", argv[1], handle);
             argc--;
             argv++;
         } else if (!strcmp(argv[0],"publish")) {
diff --git a/cmds/servicemanager/binder.c b/cmds/servicemanager/binder.c
index 1985756..db7632d 100644
--- a/cmds/servicemanager/binder.c
+++ b/cmds/servicemanager/binder.c
@@ -1,6 +1,7 @@
 /* Copyright 2008 The Android Open Source Project
  */
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -17,17 +18,17 @@
 #define LOG_TAG "Binder"
 #include <cutils/log.h>
 
-void bio_init_from_txn(struct binder_io *io, struct binder_txn *txn);
+void bio_init_from_txn(struct binder_io *io, struct binder_transaction_data *txn);
 
 #if TRACE
-void hexdump(void *_data, unsigned len)
+void hexdump(void *_data, size_t len)
 {
     unsigned char *data = _data;
-    unsigned count;
+    size_t count;
 
     for (count = 0; count < len; count++) {
         if ((count & 15) == 0)
-            fprintf(stderr,"%04x:", count);
+            fprintf(stderr,"%04zu:", count);
         fprintf(stderr," %02x %c", *data,
                 (*data < 32) || (*data > 126) ? '.' : *data);
         data++;
@@ -38,21 +39,21 @@
         fprintf(stderr,"\n");
 }
 
-void binder_dump_txn(struct binder_txn *txn)
+void binder_dump_txn(struct binder_transaction_data *txn)
 {
-    struct binder_object *obj;
-    unsigned *offs = txn->offs;
-    unsigned count = txn->offs_size / 4;
+    struct flat_binder_object *obj;
+    binder_size_t *offs = (binder_size_t *)(uintptr_t)txn->data.ptr.offsets;
+    size_t count = txn->offsets_size / sizeof(binder_size_t);
 
-    fprintf(stderr,"  target %p  cookie %p  code %08x  flags %08x\n",
-            txn->target, txn->cookie, txn->code, txn->flags);
-    fprintf(stderr,"  pid %8d  uid %8d  data %8d  offs %8d\n",
-            txn->sender_pid, txn->sender_euid, txn->data_size, txn->offs_size);
-    hexdump(txn->data, txn->data_size);
+    fprintf(stderr,"  target %016"PRIx64"  cookie %016"PRIx64"  code %08x  flags %08x\n",
+            (uint64_t)txn->target.ptr, (uint64_t)txn->cookie, txn->code, txn->flags);
+    fprintf(stderr,"  pid %8d  uid %8d  data %"PRIu64"  offs %"PRIu64"\n",
+            txn->sender_pid, txn->sender_euid, (uint64_t)txn->data_size, (uint64_t)txn->offsets_size);
+    hexdump((void *)(uintptr_t)txn->data.ptr.buffer, txn->data_size);
     while (count--) {
-        obj = (void*) (((char*) txn->data) + *offs++);
-        fprintf(stderr,"  - type %08x  flags %08x  ptr %p  cookie %p\n",
-                obj->type, obj->flags, obj->pointer, obj->cookie);
+        obj = (struct flat_binder_object *) (((char*)(uintptr_t)txn->data.ptr.buffer) + *offs++);
+        fprintf(stderr,"  - type %08x  flags %08x  ptr %016"PRIx64"  cookie %016"PRIx64"\n",
+                obj->type, obj->flags, (uint64_t)obj->binder, (uint64_t)obj->cookie);
     }
 }
 
@@ -88,17 +89,18 @@
 {
     int fd;
     void *mapped;
-    unsigned mapsize;
+    size_t mapsize;
 };
 
-struct binder_state *binder_open(unsigned mapsize)
+struct binder_state *binder_open(size_t mapsize)
 {
     struct binder_state *bs;
+    struct binder_version vers;
 
     bs = malloc(sizeof(*bs));
     if (!bs) {
         errno = ENOMEM;
-        return 0;
+        return NULL;
     }
 
     bs->fd = open("/dev/binder", O_RDWR);
@@ -108,6 +110,12 @@
         goto fail_open;
     }
 
+    if ((ioctl(bs->fd, BINDER_VERSION, &vers) == -1) ||
+        (vers.protocol_version != BINDER_CURRENT_PROTOCOL_VERSION)) {
+        fprintf(stderr, "binder: driver version differs from user space\n");
+        goto fail_open;
+    }
+
     bs->mapsize = mapsize;
     bs->mapped = mmap(NULL, mapsize, PROT_READ, MAP_PRIVATE, bs->fd, 0);
     if (bs->mapped == MAP_FAILED) {
@@ -116,15 +124,13 @@
         goto fail_map;
     }
 
-        /* TODO: check version */
-
     return bs;
 
 fail_map:
     close(bs->fd);
 fail_open:
     free(bs);
-    return 0;
+    return NULL;
 }
 
 void binder_close(struct binder_state *bs)
@@ -139,13 +145,14 @@
     return ioctl(bs->fd, BINDER_SET_CONTEXT_MGR, 0);
 }
 
-int binder_write(struct binder_state *bs, void *data, unsigned len)
+int binder_write(struct binder_state *bs, void *data, size_t len)
 {
     struct binder_write_read bwr;
     int res;
+
     bwr.write_size = len;
     bwr.write_consumed = 0;
-    bwr.write_buffer = (unsigned) data;
+    bwr.write_buffer = (uintptr_t) data;
     bwr.read_size = 0;
     bwr.read_consumed = 0;
     bwr.read_buffer = 0;
@@ -159,46 +166,47 @@
 
 void binder_send_reply(struct binder_state *bs,
                        struct binder_io *reply,
-                       void *buffer_to_free,
+                       binder_uintptr_t buffer_to_free,
                        int status)
 {
     struct {
         uint32_t cmd_free;
-        void *buffer;
+        binder_uintptr_t buffer;
         uint32_t cmd_reply;
-        struct binder_txn txn;
+        struct binder_transaction_data txn;
     } __attribute__((packed)) data;
 
     data.cmd_free = BC_FREE_BUFFER;
     data.buffer = buffer_to_free;
     data.cmd_reply = BC_REPLY;
-    data.txn.target = 0;
+    data.txn.target.ptr = 0;
     data.txn.cookie = 0;
     data.txn.code = 0;
     if (status) {
         data.txn.flags = TF_STATUS_CODE;
         data.txn.data_size = sizeof(int);
-        data.txn.offs_size = 0;
-        data.txn.data = &status;
-        data.txn.offs = 0;
+        data.txn.offsets_size = 0;
+        data.txn.data.ptr.buffer = (uintptr_t)&status;
+        data.txn.data.ptr.offsets = 0;
     } else {
         data.txn.flags = 0;
         data.txn.data_size = reply->data - reply->data0;
-        data.txn.offs_size = ((char*) reply->offs) - ((char*) reply->offs0);
-        data.txn.data = reply->data0;
-        data.txn.offs = reply->offs0;
+        data.txn.offsets_size = ((char*) reply->offs) - ((char*) reply->offs0);
+        data.txn.data.ptr.buffer = (uintptr_t)reply->data0;
+        data.txn.data.ptr.offsets = (uintptr_t)reply->offs0;
     }
     binder_write(bs, &data, sizeof(data));
 }
 
 int binder_parse(struct binder_state *bs, struct binder_io *bio,
-                 uint32_t *ptr, uint32_t size, binder_handler func)
+                 uintptr_t ptr, size_t size, binder_handler func)
 {
     int r = 1;
-    uint32_t *end = ptr + (size / 4);
+    uintptr_t end = ptr + (uintptr_t) size;
 
     while (ptr < end) {
-        uint32_t cmd = *ptr++;
+        uint32_t cmd = *(uint32_t *) ptr;
+        ptr += sizeof(uint32_t);
 #if TRACE
         fprintf(stderr,"%s:\n", cmd_name(cmd));
 #endif
@@ -212,13 +220,13 @@
         case BR_RELEASE:
         case BR_DECREFS:
 #if TRACE
-            fprintf(stderr,"  %08x %08x\n", ptr[0], ptr[1]);
+            fprintf(stderr,"  %p, %p\n", (void *)ptr, (void *)(ptr + sizeof(void *)));
 #endif
-            ptr += 2;
+            ptr += sizeof(struct binder_ptr_cookie);
             break;
         case BR_TRANSACTION: {
-            struct binder_txn *txn = (void *) ptr;
-            if ((end - ptr) * sizeof(uint32_t) < sizeof(struct binder_txn)) {
+            struct binder_transaction_data *txn = (struct binder_transaction_data *) ptr;
+            if ((end - ptr) < sizeof(*txn)) {
                 ALOGE("parse: txn too small!\n");
                 return -1;
             }
@@ -232,14 +240,14 @@
                 bio_init(&reply, rdata, sizeof(rdata), 4);
                 bio_init_from_txn(&msg, txn);
                 res = func(bs, txn, &msg, &reply);
-                binder_send_reply(bs, &reply, txn->data, res);
+                binder_send_reply(bs, &reply, txn->data.ptr.buffer, res);
             }
-            ptr += sizeof(*txn) / sizeof(uint32_t);
+            ptr += sizeof(*txn);
             break;
         }
         case BR_REPLY: {
-            struct binder_txn *txn = (void*) ptr;
-            if ((end - ptr) * sizeof(uint32_t) < sizeof(struct binder_txn)) {
+            struct binder_transaction_data *txn = (struct binder_transaction_data *) ptr;
+            if ((end - ptr) < sizeof(*txn)) {
                 ALOGE("parse: reply too small!\n");
                 return -1;
             }
@@ -248,14 +256,15 @@
                 bio_init_from_txn(bio, txn);
                 bio = 0;
             } else {
-                    /* todo FREE BUFFER */
+                /* todo FREE BUFFER */
             }
-            ptr += (sizeof(*txn) / sizeof(uint32_t));
+            ptr += sizeof(*txn);
             r = 0;
             break;
         }
         case BR_DEAD_BINDER: {
-            struct binder_death *death = (void*) *ptr++;
+            struct binder_death *death = (struct binder_death *)(uintptr_t) *(binder_uintptr_t *)ptr;
+            ptr += sizeof(binder_uintptr_t);
             death->func(bs, death->ptr);
             break;
         }
@@ -274,42 +283,45 @@
     return r;
 }
 
-void binder_acquire(struct binder_state *bs, void *ptr)
+void binder_acquire(struct binder_state *bs, uint32_t target)
 {
     uint32_t cmd[2];
     cmd[0] = BC_ACQUIRE;
-    cmd[1] = (uint32_t) ptr;
+    cmd[1] = target;
     binder_write(bs, cmd, sizeof(cmd));
 }
 
-void binder_release(struct binder_state *bs, void *ptr)
+void binder_release(struct binder_state *bs, uint32_t target)
 {
     uint32_t cmd[2];
     cmd[0] = BC_RELEASE;
-    cmd[1] = (uint32_t) ptr;
+    cmd[1] = target;
     binder_write(bs, cmd, sizeof(cmd));
 }
 
-void binder_link_to_death(struct binder_state *bs, void *ptr, struct binder_death *death)
+void binder_link_to_death(struct binder_state *bs, uint32_t target, struct binder_death *death)
 {
-    uint32_t cmd[3];
-    cmd[0] = BC_REQUEST_DEATH_NOTIFICATION;
-    cmd[1] = (uint32_t) ptr;
-    cmd[2] = (uint32_t) death;
-    binder_write(bs, cmd, sizeof(cmd));
-}
+    struct {
+        uint32_t cmd;
+        struct binder_handle_cookie payload;
+    } __attribute__((packed)) data;
 
+    data.cmd = BC_REQUEST_DEATH_NOTIFICATION;
+    data.payload.handle = target;
+    data.payload.cookie = (uintptr_t) death;
+    binder_write(bs, &data, sizeof(data));
+}
 
 int binder_call(struct binder_state *bs,
                 struct binder_io *msg, struct binder_io *reply,
-                void *target, uint32_t code)
+                uint32_t target, uint32_t code)
 {
     int res;
     struct binder_write_read bwr;
     struct {
         uint32_t cmd;
-        struct binder_txn txn;
-    } writebuf;
+        struct binder_transaction_data txn;
+    } __attribute__((packed)) writebuf;
     unsigned readbuf[32];
 
     if (msg->flags & BIO_F_OVERFLOW) {
@@ -318,23 +330,23 @@
     }
 
     writebuf.cmd = BC_TRANSACTION;
-    writebuf.txn.target = target;
+    writebuf.txn.target.handle = target;
     writebuf.txn.code = code;
     writebuf.txn.flags = 0;
     writebuf.txn.data_size = msg->data - msg->data0;
-    writebuf.txn.offs_size = ((char*) msg->offs) - ((char*) msg->offs0);
-    writebuf.txn.data = msg->data0;
-    writebuf.txn.offs = msg->offs0;
+    writebuf.txn.offsets_size = ((char*) msg->offs) - ((char*) msg->offs0);
+    writebuf.txn.data.ptr.buffer = (uintptr_t)msg->data0;
+    writebuf.txn.data.ptr.offsets = (uintptr_t)msg->offs0;
 
     bwr.write_size = sizeof(writebuf);
     bwr.write_consumed = 0;
-    bwr.write_buffer = (unsigned) &writebuf;
-    
+    bwr.write_buffer = (uintptr_t) &writebuf;
+
     hexdump(msg->data0, msg->data - msg->data0);
     for (;;) {
         bwr.read_size = sizeof(readbuf);
         bwr.read_consumed = 0;
-        bwr.read_buffer = (unsigned) readbuf;
+        bwr.read_buffer = (uintptr_t) readbuf;
 
         res = ioctl(bs->fd, BINDER_WRITE_READ, &bwr);
 
@@ -343,7 +355,7 @@
             goto fail;
         }
 
-        res = binder_parse(bs, reply, readbuf, bwr.read_consumed, 0);
+        res = binder_parse(bs, reply, (uintptr_t) readbuf, bwr.read_consumed, 0);
         if (res == 0) return 0;
         if (res < 0) goto fail;
     }
@@ -358,19 +370,19 @@
 {
     int res;
     struct binder_write_read bwr;
-    unsigned readbuf[32];
+    uint32_t readbuf[32];
 
     bwr.write_size = 0;
     bwr.write_consumed = 0;
     bwr.write_buffer = 0;
-    
+
     readbuf[0] = BC_ENTER_LOOPER;
-    binder_write(bs, readbuf, sizeof(unsigned));
+    binder_write(bs, readbuf, sizeof(uint32_t));
 
     for (;;) {
         bwr.read_size = sizeof(readbuf);
         bwr.read_consumed = 0;
-        bwr.read_buffer = (unsigned) readbuf;
+        bwr.read_buffer = (uintptr_t) readbuf;
 
         res = ioctl(bs->fd, BINDER_WRITE_READ, &bwr);
 
@@ -379,7 +391,7 @@
             break;
         }
 
-        res = binder_parse(bs, 0, readbuf, bwr.read_consumed, func);
+        res = binder_parse(bs, 0, (uintptr_t) readbuf, bwr.read_consumed, func);
         if (res == 0) {
             ALOGE("binder_loop: unexpected reply?!\n");
             break;
@@ -391,19 +403,19 @@
     }
 }
 
-void bio_init_from_txn(struct binder_io *bio, struct binder_txn *txn)
+void bio_init_from_txn(struct binder_io *bio, struct binder_transaction_data *txn)
 {
-    bio->data = bio->data0 = txn->data;
-    bio->offs = bio->offs0 = txn->offs;
+    bio->data = bio->data0 = (char *)(intptr_t)txn->data.ptr.buffer;
+    bio->offs = bio->offs0 = (binder_size_t *)(intptr_t)txn->data.ptr.offsets;
     bio->data_avail = txn->data_size;
-    bio->offs_avail = txn->offs_size / 4;
+    bio->offs_avail = txn->offsets_size / sizeof(size_t);
     bio->flags = BIO_F_SHARED;
 }
 
 void bio_init(struct binder_io *bio, void *data,
-              uint32_t maxdata, uint32_t maxoffs)
+              size_t maxdata, size_t maxoffs)
 {
-    uint32_t n = maxoffs * sizeof(uint32_t);
+    size_t n = maxoffs * sizeof(size_t);
 
     if (n > maxdata) {
         bio->flags = BIO_F_OVERFLOW;
@@ -419,12 +431,12 @@
     bio->flags = 0;
 }
 
-static void *bio_alloc(struct binder_io *bio, uint32_t size)
+static void *bio_alloc(struct binder_io *bio, size_t size)
 {
     size = (size + 3) & (~3);
     if (size > bio->data_avail) {
         bio->flags |= BIO_F_OVERFLOW;
-        return 0;
+        return NULL;
     } else {
         void *ptr = bio->data;
         bio->data += size;
@@ -437,21 +449,25 @@
                  struct binder_io *msg,
                  struct binder_io *reply)
 {
+    struct {
+        uint32_t cmd;
+        uintptr_t buffer;
+    } __attribute__((packed)) data;
+
     if (reply->flags & BIO_F_SHARED) {
-        uint32_t cmd[2];
-        cmd[0] = BC_FREE_BUFFER;
-        cmd[1] = (uint32_t) reply->data0;
-        binder_write(bs, cmd, sizeof(cmd));
+        data.cmd = BC_FREE_BUFFER;
+        data.buffer = (uintptr_t) reply->data0;
+        binder_write(bs, &data, sizeof(data));
         reply->flags = 0;
     }
 }
 
-static struct binder_object *bio_alloc_obj(struct binder_io *bio)
+static struct flat_binder_object *bio_alloc_obj(struct binder_io *bio)
 {
-    struct binder_object *obj;
+    struct flat_binder_object *obj;
 
     obj = bio_alloc(bio, sizeof(*obj));
-    
+
     if (obj && bio->offs_avail) {
         bio->offs_avail--;
         *bio->offs++ = ((char*) obj) - ((char*) bio->data0);
@@ -459,7 +475,7 @@
     }
 
     bio->flags |= BIO_F_OVERFLOW;
-    return 0;
+    return NULL;
 }
 
 void bio_put_uint32(struct binder_io *bio, uint32_t n)
@@ -471,7 +487,7 @@
 
 void bio_put_obj(struct binder_io *bio, void *ptr)
 {
-    struct binder_object *obj;
+    struct flat_binder_object *obj;
 
     obj = bio_alloc_obj(bio);
     if (!obj)
@@ -479,15 +495,15 @@
 
     obj->flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
     obj->type = BINDER_TYPE_BINDER;
-    obj->pointer = ptr;
+    obj->binder = (uintptr_t)ptr;
     obj->cookie = 0;
 }
 
-void bio_put_ref(struct binder_io *bio, void *ptr)
+void bio_put_ref(struct binder_io *bio, uint32_t handle)
 {
-    struct binder_object *obj;
+    struct flat_binder_object *obj;
 
-    if (ptr)
+    if (handle)
         obj = bio_alloc_obj(bio);
     else
         obj = bio_alloc(bio, sizeof(*obj));
@@ -497,13 +513,13 @@
 
     obj->flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
     obj->type = BINDER_TYPE_HANDLE;
-    obj->pointer = ptr;
+    obj->handle = handle;
     obj->cookie = 0;
 }
 
 void bio_put_string16(struct binder_io *bio, const uint16_t *str)
 {
-    uint32_t len;
+    size_t len;
     uint16_t *ptr;
 
     if (!str) {
@@ -519,7 +535,8 @@
         return;
     }
 
-    bio_put_uint32(bio, len);
+    /* Note: The payload will carry 32bit size instead of size_t */
+    bio_put_uint32(bio, (uint32_t) len);
     len = (len + 1) * sizeof(uint16_t);
     ptr = bio_alloc(bio, len);
     if (ptr)
@@ -529,7 +546,7 @@
 void bio_put_string16_x(struct binder_io *bio, const char *_str)
 {
     unsigned char *str = (unsigned char*) _str;
-    uint32_t len;
+    size_t len;
     uint16_t *ptr;
 
     if (!str) {
@@ -544,6 +561,7 @@
         return;
     }
 
+    /* Note: The payload will carry 32bit size instead of size_t */
     bio_put_uint32(bio, len);
     ptr = bio_alloc(bio, (len + 1) * sizeof(uint16_t));
     if (!ptr)
@@ -554,14 +572,14 @@
     *ptr++ = 0;
 }
 
-static void *bio_get(struct binder_io *bio, uint32_t size)
+static void *bio_get(struct binder_io *bio, size_t size)
 {
     size = (size + 3) & (~3);
 
     if (bio->data_avail < size){
         bio->data_avail = 0;
         bio->flags |= BIO_F_OVERFLOW;
-        return 0;
+        return NULL;
     }  else {
         void *ptr = bio->data;
         bio->data += size;
@@ -576,41 +594,43 @@
     return ptr ? *ptr : 0;
 }
 
-uint16_t *bio_get_string16(struct binder_io *bio, unsigned *sz)
+uint16_t *bio_get_string16(struct binder_io *bio, size_t *sz)
 {
-    unsigned len;
-    len = bio_get_uint32(bio);
+    size_t len;
+
+    /* Note: The payload will carry 32bit size instead of size_t */
+    len = (size_t) bio_get_uint32(bio);
     if (sz)
         *sz = len;
     return bio_get(bio, (len + 1) * sizeof(uint16_t));
 }
 
-static struct binder_object *_bio_get_obj(struct binder_io *bio)
+static struct flat_binder_object *_bio_get_obj(struct binder_io *bio)
 {
-    unsigned n;
-    unsigned off = bio->data - bio->data0;
+    size_t n;
+    size_t off = bio->data - bio->data0;
 
-        /* TODO: be smarter about this? */
+    /* TODO: be smarter about this? */
     for (n = 0; n < bio->offs_avail; n++) {
         if (bio->offs[n] == off)
-            return bio_get(bio, sizeof(struct binder_object));
+            return bio_get(bio, sizeof(struct flat_binder_object));
     }
 
     bio->data_avail = 0;
     bio->flags |= BIO_F_OVERFLOW;
-    return 0;
+    return NULL;
 }
 
-void *bio_get_ref(struct binder_io *bio)
+uint32_t bio_get_ref(struct binder_io *bio)
 {
-    struct binder_object *obj;
+    struct flat_binder_object *obj;
 
     obj = _bio_get_obj(bio);
     if (!obj)
         return 0;
 
     if (obj->type == BINDER_TYPE_HANDLE)
-        return obj->pointer;
+        return obj->handle;
 
     return 0;
 }
diff --git a/cmds/servicemanager/binder.h b/cmds/servicemanager/binder.h
index d8c51ef..7915fc2 100644
--- a/cmds/servicemanager/binder.h
+++ b/cmds/servicemanager/binder.h
@@ -9,39 +9,15 @@
 
 struct binder_state;
 
-struct binder_object
-{
-    uint32_t type;
-    uint32_t flags;
-    void *pointer;
-    void *cookie;
-};
-
-struct binder_txn
-{
-    void *target;
-    void *cookie;
-    uint32_t code;
-    uint32_t flags;
-
-    uint32_t sender_pid;
-    uint32_t sender_euid;
-
-    uint32_t data_size;
-    uint32_t offs_size;
-    void *data;
-    void *offs;
-};
-
 struct binder_io
 {
     char *data;            /* pointer to read/write from */
-    uint32_t *offs;        /* array of offsets */
-    uint32_t data_avail;   /* bytes available in data buffer */
-    uint32_t offs_avail;   /* entries available in offsets array */
+    binder_size_t *offs;   /* array of offsets */
+    size_t data_avail;     /* bytes available in data buffer */
+    size_t offs_avail;     /* entries available in offsets array */
 
     char *data0;           /* start of data buffer */
-    uint32_t *offs0;       /* start of offsets buffer */
+    binder_size_t *offs0;  /* start of offsets buffer */
     uint32_t flags;
     uint32_t unused;
 };
@@ -49,14 +25,16 @@
 struct binder_death {
     void (*func)(struct binder_state *bs, void *ptr);
     void *ptr;
-};    
+};
 
-/* the one magic object */
-#define BINDER_SERVICE_MANAGER ((void*) 0)
+/* the one magic handle */
+#define BINDER_SERVICE_MANAGER  0U
 
 #define SVC_MGR_NAME "android.os.IServiceManager"
 
 enum {
+    /* Must match definitions in IBinder.h and IServiceManager.h */
+    PING_TRANSACTION  = B_PACK_CHARS('_','P','N','G'),
     SVC_MGR_GET_SERVICE = 1,
     SVC_MGR_CHECK_SERVICE,
     SVC_MGR_ADD_SERVICE,
@@ -64,11 +42,11 @@
 };
 
 typedef int (*binder_handler)(struct binder_state *bs,
-                              struct binder_txn *txn,
+                              struct binder_transaction_data *txn,
                               struct binder_io *msg,
                               struct binder_io *reply);
 
-struct binder_state *binder_open(unsigned mapsize);
+struct binder_state *binder_open(size_t mapsize);
 void binder_close(struct binder_state *bs);
 
 /* initiate a blocking binder call
@@ -76,7 +54,7 @@
  */
 int binder_call(struct binder_state *bs,
                 struct binder_io *msg, struct binder_io *reply,
-                void *target, uint32_t code);
+                uint32_t target, uint32_t code);
 
 /* release any state associate with the binder_io
  * - call once any necessary data has been extracted from the
@@ -87,10 +65,10 @@
                  struct binder_io *msg, struct binder_io *reply);
 
 /* manipulate strong references */
-void binder_acquire(struct binder_state *bs, void *ptr);
-void binder_release(struct binder_state *bs, void *ptr);
+void binder_acquire(struct binder_state *bs, uint32_t target);
+void binder_release(struct binder_state *bs, uint32_t target);
 
-void binder_link_to_death(struct binder_state *bs, void *ptr, struct binder_death *death);
+void binder_link_to_death(struct binder_state *bs, uint32_t target, struct binder_death *death);
 
 void binder_loop(struct binder_state *bs, binder_handler func);
 
@@ -101,19 +79,16 @@
  * offset entries to reserve from the buffer
  */
 void bio_init(struct binder_io *bio, void *data,
-           uint32_t maxdata, uint32_t maxobjects);
-
-void bio_destroy(struct binder_io *bio);
+           size_t maxdata, size_t maxobjects);
 
 void bio_put_obj(struct binder_io *bio, void *ptr);
-void bio_put_ref(struct binder_io *bio, void *ptr);
+void bio_put_ref(struct binder_io *bio, uint32_t handle);
 void bio_put_uint32(struct binder_io *bio, uint32_t n);
 void bio_put_string16(struct binder_io *bio, const uint16_t *str);
 void bio_put_string16_x(struct binder_io *bio, const char *_str);
 
 uint32_t bio_get_uint32(struct binder_io *bio);
-uint16_t *bio_get_string16(struct binder_io *bio, uint32_t *sz);
-void *bio_get_obj(struct binder_io *bio);
-void *bio_get_ref(struct binder_io *bio);
+uint16_t *bio_get_string16(struct binder_io *bio, size_t *sz);
+uint32_t bio_get_ref(struct binder_io *bio);
 
 #endif
diff --git a/cmds/servicemanager/service_manager.c b/cmds/servicemanager/service_manager.c
index 3eaf1eb..79ce6ed 100644
--- a/cmds/servicemanager/service_manager.c
+++ b/cmds/servicemanager/service_manager.c
@@ -24,7 +24,7 @@
  * uid can register media.*, etc)
  */
 static struct {
-    unsigned uid;
+    uid_t uid;
     const char *name;
 } allowed[] = {
     { AID_MEDIA, "media.audio_flinger" },
@@ -50,9 +50,9 @@
     { AID_KEYSTORE, "android.security.keystore" },
 };
 
-void *svcmgr_handle;
+uint32_t svcmgr_handle;
 
-const char *str8(uint16_t *x)
+const char *str8(const uint16_t *x)
 {
     static char buf[128];
     unsigned max = 127;
@@ -67,7 +67,7 @@
     return buf;
 }
 
-int str16eq(uint16_t *a, const char *b)
+int str16eq(const uint16_t *a, const char *b)
 {
     while (*a && *b)
         if (*a++ != *b++) return 0;
@@ -76,10 +76,10 @@
     return 1;
 }
 
-int svc_can_register(unsigned uid, uint16_t *name)
+int svc_can_register(uid_t uid, const uint16_t *name)
 {
-    unsigned n;
-    
+    size_t n;
+
     if ((uid == 0) || (uid == AID_SYSTEM))
         return 1;
 
@@ -90,19 +90,19 @@
     return 0;
 }
 
-struct svcinfo 
+struct svcinfo
 {
     struct svcinfo *next;
-    void *ptr;
+    uint32_t handle;
     struct binder_death death;
     int allow_isolated;
-    unsigned len;
+    size_t len;
     uint16_t name[0];
 };
 
-struct svcinfo *svclist = 0;
+struct svcinfo *svclist = NULL;
 
-struct svcinfo *find_svc(uint16_t *s16, unsigned len)
+struct svcinfo *find_svc(const uint16_t *s16, size_t len)
 {
     struct svcinfo *si;
 
@@ -112,112 +112,117 @@
             return si;
         }
     }
-    return 0;
+    return NULL;
 }
 
 void svcinfo_death(struct binder_state *bs, void *ptr)
 {
-    struct svcinfo *si = ptr;
+    struct svcinfo *si = (struct svcinfo* ) ptr;
+
     ALOGI("service '%s' died\n", str8(si->name));
-    if (si->ptr) {
-        binder_release(bs, si->ptr);
-        si->ptr = 0;
-    }   
+    if (si->handle) {
+        binder_release(bs, si->handle);
+        si->handle = 0;
+    }
 }
 
-uint16_t svcmgr_id[] = { 
+uint16_t svcmgr_id[] = {
     'a','n','d','r','o','i','d','.','o','s','.',
-    'I','S','e','r','v','i','c','e','M','a','n','a','g','e','r' 
+    'I','S','e','r','v','i','c','e','M','a','n','a','g','e','r'
 };
-  
 
-void *do_find_service(struct binder_state *bs, uint16_t *s, unsigned len, unsigned uid)
+
+uint32_t do_find_service(struct binder_state *bs, const uint16_t *s, size_t len, uid_t uid)
 {
     struct svcinfo *si;
-    si = find_svc(s, len);
 
-//    ALOGI("check_service('%s') ptr = %p\n", str8(s), si ? si->ptr : 0);
-    if (si && si->ptr) {
+    si = find_svc(s, len);
+    //ALOGI("check_service('%s') handle = %x\n", str8(s), si ? si->handle : 0);
+    if (si && si->handle) {
         if (!si->allow_isolated) {
             // If this service doesn't allow access from isolated processes,
             // then check the uid to see if it is isolated.
-            unsigned appid = uid % AID_USER;
+            uid_t appid = uid % AID_USER;
             if (appid >= AID_ISOLATED_START && appid <= AID_ISOLATED_END) {
                 return 0;
             }
         }
-        return si->ptr;
+        return si->handle;
     } else {
         return 0;
     }
 }
 
 int do_add_service(struct binder_state *bs,
-                   uint16_t *s, unsigned len,
-                   void *ptr, unsigned uid, int allow_isolated)
+                   const uint16_t *s, size_t len,
+                   uint32_t handle, uid_t uid, int allow_isolated)
 {
     struct svcinfo *si;
-    //ALOGI("add_service('%s',%p,%s) uid=%d\n", str8(s), ptr,
+
+    //ALOGI("add_service('%s',%x,%s) uid=%d\n", str8(s), handle,
     //        allow_isolated ? "allow_isolated" : "!allow_isolated", uid);
 
-    if (!ptr || (len == 0) || (len > 127))
+    if (!handle || (len == 0) || (len > 127))
         return -1;
 
     if (!svc_can_register(uid, s)) {
-        ALOGE("add_service('%s',%p) uid=%d - PERMISSION DENIED\n",
-             str8(s), ptr, uid);
+        ALOGE("add_service('%s',%x) uid=%d - PERMISSION DENIED\n",
+             str8(s), handle, uid);
         return -1;
     }
 
     si = find_svc(s, len);
     if (si) {
-        if (si->ptr) {
-            ALOGE("add_service('%s',%p) uid=%d - ALREADY REGISTERED, OVERRIDE\n",
-                 str8(s), ptr, uid);
+        if (si->handle) {
+            ALOGE("add_service('%s',%x) uid=%d - ALREADY REGISTERED, OVERRIDE\n",
+                 str8(s), handle, uid);
             svcinfo_death(bs, si);
         }
-        si->ptr = ptr;
+        si->handle = handle;
     } else {
         si = malloc(sizeof(*si) + (len + 1) * sizeof(uint16_t));
         if (!si) {
-            ALOGE("add_service('%s',%p) uid=%d - OUT OF MEMORY\n",
-                 str8(s), ptr, uid);
+            ALOGE("add_service('%s',%x) uid=%d - OUT OF MEMORY\n",
+                 str8(s), handle, uid);
             return -1;
         }
-        si->ptr = ptr;
+        si->handle = handle;
         si->len = len;
         memcpy(si->name, s, (len + 1) * sizeof(uint16_t));
         si->name[len] = '\0';
-        si->death.func = svcinfo_death;
+        si->death.func = (void*) svcinfo_death;
         si->death.ptr = si;
         si->allow_isolated = allow_isolated;
         si->next = svclist;
         svclist = si;
     }
 
-    binder_acquire(bs, ptr);
-    binder_link_to_death(bs, ptr, &si->death);
+    binder_acquire(bs, handle);
+    binder_link_to_death(bs, handle, &si->death);
     return 0;
 }
 
 int svcmgr_handler(struct binder_state *bs,
-                   struct binder_txn *txn,
+                   struct binder_transaction_data *txn,
                    struct binder_io *msg,
                    struct binder_io *reply)
 {
     struct svcinfo *si;
     uint16_t *s;
-    unsigned len;
-    void *ptr;
+    size_t len;
+    uint32_t handle;
     uint32_t strict_policy;
     int allow_isolated;
 
-//    ALOGI("target=%p code=%d pid=%d uid=%d\n",
-//         txn->target, txn->code, txn->sender_pid, txn->sender_euid);
+    //ALOGI("target=%x code=%d pid=%d uid=%d\n",
+    //  txn->target.handle, txn->code, txn->sender_pid, txn->sender_euid);
 
-    if (txn->target != svcmgr_handle)
+    if (txn->target.handle != svcmgr_handle)
         return -1;
 
+    if (txn->code == PING_TRANSACTION)
+        return 0;
+
     // Equivalent to Parcel::enforceInterface(), reading the RPC
     // header with the strict mode policy mask and the interface name.
     // Note that we ignore the strict_policy and don't propagate it
@@ -234,22 +239,22 @@
     case SVC_MGR_GET_SERVICE:
     case SVC_MGR_CHECK_SERVICE:
         s = bio_get_string16(msg, &len);
-        ptr = do_find_service(bs, s, len, txn->sender_euid);
-        if (!ptr)
+        handle = do_find_service(bs, s, len, txn->sender_euid);
+        if (!handle)
             break;
-        bio_put_ref(reply, ptr);
+        bio_put_ref(reply, handle);
         return 0;
 
     case SVC_MGR_ADD_SERVICE:
         s = bio_get_string16(msg, &len);
-        ptr = bio_get_ref(msg);
+        handle = bio_get_ref(msg);
         allow_isolated = bio_get_uint32(msg) ? 1 : 0;
-        if (do_add_service(bs, s, len, ptr, txn->sender_euid, allow_isolated))
+        if (do_add_service(bs, s, len, handle, txn->sender_euid, allow_isolated))
             return -1;
         break;
 
     case SVC_MGR_LIST_SERVICES: {
-        unsigned n = bio_get_uint32(msg);
+        uint32_t n = bio_get_uint32(msg);
 
         si = svclist;
         while ((n-- > 0) && si)
@@ -272,16 +277,20 @@
 int main(int argc, char **argv)
 {
     struct binder_state *bs;
-    void *svcmgr = BINDER_SERVICE_MANAGER;
 
     bs = binder_open(128*1024);
+    if (!bs) {
+        ALOGE("failed to open binder driver\n");
+        return -1;
+    }
 
     if (binder_become_context_manager(bs)) {
         ALOGE("cannot become context manager (%s)\n", strerror(errno));
         return -1;
     }
 
-    svcmgr_handle = svcmgr;
+    svcmgr_handle = BINDER_SERVICE_MANAGER;
     binder_loop(bs, svcmgr_handler);
+
     return 0;
 }
diff --git a/include/android/input.h b/include/android/input.h
index fead769..a660761 100644
--- a/include/android/input.h
+++ b/include/android/input.h
@@ -583,7 +583,7 @@
  * and views. */
 float AMotionEvent_getXOffset(const AInputEvent* motion_event);
 
-/* Get the precision of the Y coordinates being reported.
+/* Get the Y coordinate offset.
  * For touch events on the screen, this is the delta that was added to the raw
  * screen coordinates to adjust for the absolute position of the containing windows
  * and views. */
diff --git a/include/binder/IPCThreadState.h b/include/binder/IPCThreadState.h
index 5bc123e..6e0c01b 100644
--- a/include/binder/IPCThreadState.h
+++ b/include/binder/IPCThreadState.h
@@ -107,7 +107,7 @@
     static  void                threadDestructor(void *st);
     static  void                freeBuffer(Parcel* parcel,
                                            const uint8_t* data, size_t dataSize,
-                                           const size_t* objects, size_t objectsSize,
+                                           const binder_size_t* objects, size_t objectsSize,
                                            void* cookie);
     
     const   sp<ProcessState>    mProcess;
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index 98f20de..ce630bd 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -23,6 +23,7 @@
 #include <utils/String16.h>
 #include <utils/Vector.h>
 #include <utils/Flattenable.h>
+#include <linux/binder.h>
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -35,9 +36,8 @@
 class String8;
 class TextOutput;
 
-struct flat_binder_object;  // defined in support_p/binder_module.h
-
 class Parcel {
+    friend class IPCThreadState;
 public:
     class ReadableBlob;
     class WritableBlob;
@@ -81,7 +81,10 @@
 
     void                freeData();
 
-    const size_t*       objects() const;
+private:
+    const binder_size_t* objects() const;
+
+public:
     size_t              objectsCount() const;
     
     status_t            errorCheck() const;
@@ -194,19 +197,21 @@
     // Explicitly close all file descriptors in the parcel.
     void                closeFileDescriptors();
     
+private:
     typedef void        (*release_func)(Parcel* parcel,
                                         const uint8_t* data, size_t dataSize,
-                                        const size_t* objects, size_t objectsSize,
+                                        const binder_size_t* objects, size_t objectsSize,
                                         void* cookie);
                         
-    const uint8_t*      ipcData() const;
+    uintptr_t           ipcData() const;
     size_t              ipcDataSize() const;
-    const size_t*       ipcObjects() const;
+    uintptr_t           ipcObjects() const;
     size_t              ipcObjectsCount() const;
     void                ipcSetDataReference(const uint8_t* data, size_t dataSize,
-                                            const size_t* objects, size_t objectsCount,
+                                            const binder_size_t* objects, size_t objectsCount,
                                             release_func relFunc, void* relCookie);
     
+public:
     void                print(TextOutput& to, uint32_t flags = 0) const;
 
 private:
@@ -219,6 +224,9 @@
     status_t            growData(size_t len);
     status_t            restartWrite(size_t desired);
     status_t            continueWrite(size_t desired);
+    status_t            writePointer(uintptr_t val);
+    status_t            readPointer(uintptr_t *pArg) const;
+    uintptr_t           readPointer() const;
     void                freeDataNoInit();
     void                initState();
     void                scanForFds() const;
@@ -236,7 +244,7 @@
     size_t              mDataSize;
     size_t              mDataCapacity;
     mutable size_t      mDataPos;
-    size_t*             mObjects;
+    binder_size_t*      mObjects;
     size_t              mObjectsSize;
     size_t              mObjectsCapacity;
     mutable size_t      mNextObjectHint;
diff --git a/include/binder/ProcessState.h b/include/binder/ProcessState.h
index e63a0d0..3bc978d 100644
--- a/include/binder/ProcessState.h
+++ b/include/binder/ProcessState.h
@@ -27,11 +27,6 @@
 // ---------------------------------------------------------------------------
 namespace android {
 
-// Global variables
-extern int                 mArgC;
-extern const char* const*  mArgV;
-extern int                 mArgLen;
-
 class IPCThreadState;
 
 class ProcessState : public virtual RefBase
@@ -62,12 +57,6 @@
             wp<IBinder>         getWeakProxyForHandle(int32_t handle);
             void                expungeHandle(int32_t handle, IBinder* binder);
 
-            void                setArgs(int argc, const char* const argv[]);
-            int                 getArgC() const;
-            const char* const*  getArgV() const;
-
-            void                setArgV0(const char* txt);
-
             void                spawnPooledThread(bool isMain);
             
             status_t            setThreadPoolMaxThreadCount(size_t maxThreads);
diff --git a/include/gui/DisplayEventReceiver.h b/include/gui/DisplayEventReceiver.h
index f8267bf..a4718b9 100644
--- a/include/gui/DisplayEventReceiver.h
+++ b/include/gui/DisplayEventReceiver.h
@@ -49,7 +49,7 @@
         struct Header {
             uint32_t type;
             uint32_t id;
-            nsecs_t timestamp;
+            nsecs_t timestamp __attribute__((aligned(8)));
         };
 
         struct VSync {
diff --git a/include/input/Input.h b/include/input/Input.h
index 077a03b..793b414 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -195,7 +195,7 @@
     enum { MAX_AXES = 14 }; // 14 so that sizeof(PointerCoords) == 64
 
     // Bitfield of axes that are present in this structure.
-    uint64_t bits;
+    uint64_t bits __attribute__((aligned(8)));
 
     // Values of axes that are stored in this structure packed in order by axis id
     // for each axis that is present in the structure according to 'bits'.
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index 609b679..e7e383b 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -39,6 +39,9 @@
 
 /*
  * Intermediate representation used to send input events and related signals.
+ *
+ * Note that this structure is used for IPCs so its layout must be identical
+ * on 64 and 32 bit processes. This is tested in StructLayout_test.cpp.
  */
 struct InputMessage {
     enum {
@@ -49,13 +52,17 @@
 
     struct Header {
         uint32_t type;
-        uint32_t padding; // 8 byte alignment for the body that follows
+        // We don't need this field in order to align the body below but we
+        // leave it here because InputMessage::size() and other functions
+        // compute the size of this structure as sizeof(Header) + sizeof(Body).
+        uint32_t padding;
     } header;
 
+    // Body *must* be 8 byte aligned.
     union Body {
         struct Key {
             uint32_t seq;
-            nsecs_t eventTime;
+            nsecs_t eventTime __attribute__((aligned(8)));
             int32_t deviceId;
             int32_t source;
             int32_t action;
@@ -64,7 +71,7 @@
             int32_t scanCode;
             int32_t metaState;
             int32_t repeatCount;
-            nsecs_t downTime;
+            nsecs_t downTime __attribute__((aligned(8)));
 
             inline size_t size() const {
                 return sizeof(Key);
@@ -73,7 +80,7 @@
 
         struct Motion {
             uint32_t seq;
-            nsecs_t eventTime;
+            nsecs_t eventTime __attribute__((aligned(8)));
             int32_t deviceId;
             int32_t source;
             int32_t action;
@@ -81,13 +88,14 @@
             int32_t metaState;
             int32_t buttonState;
             int32_t edgeFlags;
-            nsecs_t downTime;
+            nsecs_t downTime __attribute__((aligned(8)));
             float xOffset;
             float yOffset;
             float xPrecision;
             float yPrecision;
-            size_t pointerCount;
-            struct Pointer {
+            uint32_t pointerCount;
+            // Note that PointerCoords requires 8 byte alignment.
+            struct Pointer{
                 PointerProperties properties;
                 PointerCoords coords;
             } pointers[MAX_POINTERS];
@@ -112,7 +120,7 @@
                 return sizeof(Finished);
             }
         } finished;
-    } body;
+    } __attribute__((aligned(8))) body;
 
     bool isValid(size_t actualSize) const;
     size_t size() const;
@@ -234,7 +242,7 @@
             float yPrecision,
             nsecs_t downTime,
             nsecs_t eventTime,
-            size_t pointerCount,
+            uint32_t pointerCount,
             const PointerProperties* pointerProperties,
             const PointerCoords* pointerCoords);
 
@@ -360,7 +368,7 @@
         void initializeFrom(const InputMessage* msg) {
             eventTime = msg->body.motion.eventTime;
             idBits.clear();
-            for (size_t i = 0; i < msg->body.motion.pointerCount; i++) {
+            for (uint32_t i = 0; i < msg->body.motion.pointerCount; i++) {
                 uint32_t id = msg->body.motion.pointers[i].properties.id;
                 idBits.markBit(id);
                 idToIndex[id] = i;
diff --git a/include/media/openmax/OMX_Types.h b/include/media/openmax/OMX_Types.h
index 03fd4bc..9dec372 100644
--- a/include/media/openmax/OMX_Types.h
+++ b/include/media/openmax/OMX_Types.h
@@ -48,6 +48,8 @@
 #ifndef OMX_Types_h
 #define OMX_Types_h
 
+#include <stdint.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -160,10 +162,10 @@
 typedef signed short OMX_S16;
 
 /** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
-typedef unsigned long OMX_U32;
+typedef uint32_t OMX_U32;
 
 /** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */
-typedef signed long OMX_S32;
+typedef int32_t OMX_S32;
 
 
 /* Users with compilers that cannot accept the "long long" designation should
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
index 3cf628c..b973c40 100644
--- a/include/ui/GraphicBuffer.h
+++ b/include/ui/GraphicBuffer.h
@@ -97,6 +97,11 @@
     status_t lockYCbCr(uint32_t usage, android_ycbcr *ycbcr);
     status_t lockYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr);
     status_t unlock();
+    status_t lockAsync(uint32_t usage, void** vaddr, int fenceFd);
+    status_t lockAsync(uint32_t usage, const Rect& rect, void** vaddr, int fenceFd);
+    status_t lockAsyncYCbCr(uint32_t usage, android_ycbcr *ycbcr, int fenceFd);
+    status_t lockAsyncYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd);
+    status_t unlockAsync(int *fenceFd);
 
     ANativeWindowBuffer* getNativeBuffer() const;
 
diff --git a/include/ui/GraphicBufferMapper.h b/include/ui/GraphicBufferMapper.h
index 99d8723..98fff0e 100644
--- a/include/ui/GraphicBufferMapper.h
+++ b/include/ui/GraphicBufferMapper.h
@@ -49,6 +49,14 @@
             int usage, const Rect& bounds, android_ycbcr *ycbcr);
 
     status_t unlock(buffer_handle_t handle);
+
+    status_t lockAsync(buffer_handle_t handle,
+            int usage, const Rect& bounds, void** vaddr, int fenceFd);
+
+    status_t lockAsyncYCbCr(buffer_handle_t handle,
+            int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd);
+
+    status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
     
     // dumps information about the mapping of this handle
     void dump(buffer_handle_t handle);
diff --git a/libs/binder/Android.mk b/libs/binder/Android.mk
index f3f8daf..6781407 100644
--- a/libs/binder/Android.mk
+++ b/libs/binder/Android.mk
@@ -38,15 +38,25 @@
 LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
-LOCAL_LDLIBS += -lpthread
 LOCAL_MODULE := libbinder
 LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
 LOCAL_SRC_FILES := $(sources)
+ifneq ($(TARGET_USES_64_BIT_BINDER),true)
+ifneq ($(TARGET_IS_64_BIT),true)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
+endif
+endif
+LOCAL_CFLAGS += -Werror
 include $(BUILD_SHARED_LIBRARY)
 
 include $(CLEAR_VARS)
-LOCAL_LDLIBS += -lpthread
 LOCAL_MODULE := libbinder
 LOCAL_STATIC_LIBRARIES += libutils
 LOCAL_SRC_FILES := $(sources)
+ifneq ($(TARGET_USES_64_BIT_BINDER),true)
+ifneq ($(TARGET_IS_64_BIT),true)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
+endif
+endif
+LOCAL_CFLAGS += -Werror
 include $(BUILD_STATIC_LIBRARY)
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index 1f21f9c..71e62ab 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -39,7 +39,7 @@
 
 // ---------------------------------------------------------------------------
 
-sp<IInterface>  IBinder::queryLocalInterface(const String16& descriptor)
+sp<IInterface>  IBinder::queryLocalInterface(const String16& /*descriptor*/)
 {
     return NULL;
 }
@@ -117,19 +117,20 @@
 }
 
 status_t BBinder::linkToDeath(
-    const sp<DeathRecipient>& recipient, void* cookie, uint32_t flags)
+    const sp<DeathRecipient>& /*recipient*/, void* /*cookie*/,
+    uint32_t /*flags*/)
 {
     return INVALID_OPERATION;
 }
 
 status_t BBinder::unlinkToDeath(
-    const wp<DeathRecipient>& recipient, void* cookie, uint32_t flags,
-    wp<DeathRecipient>* outRecipient)
+    const wp<DeathRecipient>& /*recipient*/, void* /*cookie*/,
+    uint32_t /*flags*/, wp<DeathRecipient>* /*outRecipient*/)
 {
     return INVALID_OPERATION;
 }
 
-status_t BBinder::dump(int fd, const Vector<String16>& args)
+    status_t BBinder::dump(int /*fd*/, const Vector<String16>& /*args*/)
 {
     return NO_ERROR;
 }
@@ -142,8 +143,13 @@
 
     if (!e) {
         e = new Extras;
+#ifdef __LP64__
+        if (android_atomic_release_cas64(0, reinterpret_cast<int64_t>(e),
+                reinterpret_cast<volatile int64_t*>(&mExtras)) != 0) {
+#else
         if (android_atomic_cmpxchg(0, reinterpret_cast<int32_t>(e),
                 reinterpret_cast<volatile int32_t*>(&mExtras)) != 0) {
+#endif
             delete e;
             e = mExtras;
         }
@@ -184,7 +190,7 @@
 
 
 status_t BBinder::onTransact(
-    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+    uint32_t code, const Parcel& data, Parcel* reply, uint32_t /*flags*/)
 {
     switch (code) {
         case INTERFACE_TRANSACTION:
@@ -246,14 +252,14 @@
     android_atomic_or(kRemoteAcquired, &mState);
 }
 
-void BpRefBase::onLastStrongRef(const void* id)
+void BpRefBase::onLastStrongRef(const void* /*id*/)
 {
     if (mRemote) {
         mRemote->decStrong(this);
     }
 }
 
-bool BpRefBase::onIncStrongAttempted(uint32_t flags, const void* id)
+bool BpRefBase::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/)
 {
     return mRemote ? mRefs->attemptIncStrong(this) : false;
 }
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp
index 47a62db..101de7e 100644
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -73,7 +73,7 @@
 void BpBinder::ObjectManager::kill()
 {
     const size_t N = mObjects.size();
-    ALOGV("Killing %d objects in manager %p", N, this);
+    ALOGV("Killing %zu objects in manager %p", N, this);
     for (size_t i=0; i<N; i++) {
         const entry_t& e = mObjects.valueAt(i);
         if (e.func != NULL) {
@@ -119,11 +119,11 @@
                 mDescriptorCache = res;
         }
     }
-    
+
     // we're returning a reference to a non-static object here. Usually this
-    // is not something smart to do, however, with binder objects it is 
+    // is not something smart to do, however, with binder objects it is
     // (usually) safe because they are reference-counted.
-    
+
     return mDescriptorCache;
 }
 
@@ -260,8 +260,8 @@
     mObitsSent = 1;
     mLock.unlock();
 
-    ALOGV("Reporting death of proxy %p for %d recipients\n",
-        this, obits ? obits->size() : 0);
+    ALOGV("Reporting death of proxy %p for %zu recipients\n",
+        this, obits ? obits->size() : 0U);
 
     if (obits != NULL) {
         const size_t N = obits->size();
@@ -343,7 +343,7 @@
     if (ipc) ipc->incStrongHandle(mHandle);
 }
 
-void BpBinder::onLastStrongRef(const void* id)
+void BpBinder::onLastStrongRef(const void* /*id*/)
 {
     ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, mHandle);
     IF_ALOGV() {
@@ -353,7 +353,7 @@
     if (ipc) ipc->decStrongHandle(mHandle);
 }
 
-bool BpBinder::onIncStrongAttempted(uint32_t flags, const void* id)
+bool BpBinder::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/)
 {
     ALOGV("onIncStrongAttempted BpBinder %p handle %d\n", this, mHandle);
     IPCThreadState* ipc = IPCThreadState::self();
diff --git a/libs/binder/Debug.cpp b/libs/binder/Debug.cpp
index a8b6e83..0ffafbb 100644
--- a/libs/binder/Debug.cpp
+++ b/libs/binder/Debug.cpp
@@ -38,7 +38,7 @@
 
 // ---------------------------------------------------------------------
 
-static void defaultPrintFunc(void* cookie, const char* txt)
+static void defaultPrintFunc(void* /*cookie*/, const char* txt)
 {
     printf("%s", txt);
 }
diff --git a/libs/binder/IAppOpsCallback.cpp b/libs/binder/IAppOpsCallback.cpp
index e0aad23..2aaf566 100644
--- a/libs/binder/IAppOpsCallback.cpp
+++ b/libs/binder/IAppOpsCallback.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IAppOpsCallback.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/Parcel.h>
 #include <utils/String8.h>
diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp
index 471e3e9..f58a352 100644
--- a/libs/binder/IAppOpsService.cpp
+++ b/libs/binder/IAppOpsService.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IAppOpsService.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/Parcel.h>
 #include <utils/String8.h>
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp
index 07cb41a..d8ed995 100644
--- a/libs/binder/IMemory.cpp
+++ b/libs/binder/IMemory.cpp
@@ -244,7 +244,7 @@
                 sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder();
 
                 if (VERBOSE) {
-                    ALOGD("UNMAPPING binder=%p, heap=%p, size=%d, fd=%d",
+                    ALOGD("UNMAPPING binder=%p, heap=%p, size=%zu, fd=%d",
                             binder.get(), this, mSize, mHeapId);
                     CallStack stack(LOG_TAG);
                 }
@@ -296,11 +296,11 @@
         uint32_t flags = reply.readInt32();
         uint32_t offset = reply.readInt32();
 
-        ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%ld, err=%d (%s)",
+        ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%zd, err=%d (%s)",
                 asBinder().get(), parcel_fd, size, err, strerror(-err));
 
         int fd = dup( parcel_fd );
-        ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%ld, err=%d (%s)",
+        ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)",
                 parcel_fd, size, err, strerror(errno));
 
         int access = PROT_READ;
@@ -313,7 +313,7 @@
             mRealHeap = true;
             mBase = mmap(0, size, access, MAP_SHARED, fd, offset);
             if (mBase == MAP_FAILED) {
-                ALOGE("cannot map BpMemoryHeap (binder=%p), size=%ld, fd=%d (%s)",
+                ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)",
                         asBinder().get(), size, fd, strerror(errno));
                 close(fd);
             } else {
@@ -402,7 +402,7 @@
     if (i>=0) {
         heap_info_t& info = mHeapCache.editValueAt(i);
         ALOGD_IF(VERBOSE,
-                "found binder=%p, heap=%p, size=%d, fd=%d, count=%d",
+                "found binder=%p, heap=%p, size=%zu, fd=%d, count=%d",
                 binder.get(), info.heap.get(),
                 static_cast<BpMemoryHeap*>(info.heap.get())->mSize,
                 static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId,
@@ -435,7 +435,7 @@
             int32_t c = android_atomic_dec(&info.count);
             if (c == 1) {
                 ALOGD_IF(VERBOSE,
-                        "removing binder=%p, heap=%p, size=%d, fd=%d, count=%d",
+                        "removing binder=%p, heap=%p, size=%zu, fd=%d, count=%d",
                         binder.unsafe_get(), info.heap.get(),
                         static_cast<BpMemoryHeap*>(info.heap.get())->mSize,
                         static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId,
@@ -466,7 +466,7 @@
     for (int i=0 ; i<c ; i++) {
         const heap_info_t& info = mHeapCache.valueAt(i);
         BpMemoryHeap const* h(static_cast<BpMemoryHeap const *>(info.heap.get()));
-        ALOGD("hey=%p, heap=%p, count=%d, (fd=%d, base=%p, size=%d)",
+        ALOGD("hey=%p, heap=%p, count=%d, (fd=%d, base=%p, size=%zu)",
                 mHeapCache.keyAt(i).unsafe_get(),
                 info.heap.get(), info.count,
                 h->mHeapId, h->mBase, h->mSize);
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 5951a3f..57c4638 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -23,7 +23,6 @@
 #include <binder/TextOutput.h>
 
 #include <cutils/sched_policy.h>
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <utils/threads.h>
 
@@ -533,7 +532,7 @@
     return result;
 }
 
-void IPCThreadState::stopProcess(bool immediate)
+void IPCThreadState::stopProcess(bool /*immediate*/)
 {
     //ALOGI("**** STOPPING PROCESS");
     flushCommands();
@@ -635,6 +634,7 @@
 
 status_t IPCThreadState::attemptIncStrongHandle(int32_t handle)
 {
+#if HAS_BC_ATTEMPT_ACQUIRE
     LOG_REMOTEREFS("IPCThreadState::attemptIncStrongHandle(%d)\n", handle);
     mOut.writeInt32(BC_ATTEMPT_ACQUIRE);
     mOut.writeInt32(0); // xxx was thread priority
@@ -649,6 +649,11 @@
 #endif
     
     return result;
+#else
+    (void)handle;
+    ALOGE("%s(%d): Not supported\n", __func__, handle);
+    return INVALID_OPERATION;
+#endif
 }
 
 void IPCThreadState::expungeHandle(int32_t handle, IBinder* binder)
@@ -663,7 +668,7 @@
 {
     mOut.writeInt32(BC_REQUEST_DEATH_NOTIFICATION);
     mOut.writeInt32((int32_t)handle);
-    mOut.writeInt32((int32_t)proxy);
+    mOut.writePointer((uintptr_t)proxy);
     return NO_ERROR;
 }
 
@@ -671,7 +676,7 @@
 {
     mOut.writeInt32(BC_CLEAR_DEATH_NOTIFICATION);
     mOut.writeInt32((int32_t)handle);
-    mOut.writeInt32((int32_t)proxy);
+    mOut.writePointer((uintptr_t)proxy);
     return NO_ERROR;
 }
 
@@ -753,23 +758,23 @@
                         reply->ipcSetDataReference(
                             reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
                             tr.data_size,
-                            reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
-                            tr.offsets_size/sizeof(size_t),
+                            reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
+                            tr.offsets_size/sizeof(binder_size_t),
                             freeBuffer, this);
                     } else {
-                        err = *static_cast<const status_t*>(tr.data.ptr.buffer);
+                        err = *reinterpret_cast<const status_t*>(tr.data.ptr.buffer);
                         freeBuffer(NULL,
                             reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
                             tr.data_size,
-                            reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
-                            tr.offsets_size/sizeof(size_t), this);
+                            reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
+                            tr.offsets_size/sizeof(binder_size_t), this);
                     }
                 } else {
                     freeBuffer(NULL,
                         reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
                         tr.data_size,
-                        reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
-                        tr.offsets_size/sizeof(size_t), this);
+                        reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
+                        tr.offsets_size/sizeof(binder_size_t), this);
                     continue;
                 }
             }
@@ -809,12 +814,12 @@
     const size_t outAvail = (!doReceive || needRead) ? mOut.dataSize() : 0;
     
     bwr.write_size = outAvail;
-    bwr.write_buffer = (long unsigned int)mOut.data();
+    bwr.write_buffer = (uintptr_t)mOut.data();
 
     // This is what we'll read.
     if (doReceive && needRead) {
         bwr.read_size = mIn.dataCapacity();
-        bwr.read_buffer = (long unsigned int)mIn.data();
+        bwr.read_buffer = (uintptr_t)mIn.data();
     } else {
         bwr.read_size = 0;
         bwr.read_buffer = 0;
@@ -861,14 +866,14 @@
     } while (err == -EINTR);
 
     IF_LOG_COMMANDS() {
-        alog << "Our err: " << (void*)err << ", write consumed: "
+        alog << "Our err: " << (void*)(intptr_t)err << ", write consumed: "
             << bwr.write_consumed << " (of " << mOut.dataSize()
                         << "), read consumed: " << bwr.read_consumed << endl;
     }
 
     if (err >= NO_ERROR) {
         if (bwr.write_consumed > 0) {
-            if (bwr.write_consumed < (ssize_t)mOut.dataSize())
+            if (bwr.write_consumed < mOut.dataSize())
                 mOut.remove(0, bwr.write_consumed);
             else
                 mOut.setDataSize(0);
@@ -898,6 +903,7 @@
 {
     binder_transaction_data tr;
 
+    tr.target.ptr = 0; /* Don't pass uninitialized stack data to a remote process */
     tr.target.handle = handle;
     tr.code = code;
     tr.flags = binderFlags;
@@ -909,15 +915,15 @@
     if (err == NO_ERROR) {
         tr.data_size = data.ipcDataSize();
         tr.data.ptr.buffer = data.ipcData();
-        tr.offsets_size = data.ipcObjectsCount()*sizeof(size_t);
+        tr.offsets_size = data.ipcObjectsCount()*sizeof(binder_size_t);
         tr.data.ptr.offsets = data.ipcObjects();
     } else if (statusBuffer) {
         tr.flags |= TF_STATUS_CODE;
         *statusBuffer = err;
         tr.data_size = sizeof(status_t);
-        tr.data.ptr.buffer = statusBuffer;
+        tr.data.ptr.buffer = reinterpret_cast<uintptr_t>(statusBuffer);
         tr.offsets_size = 0;
-        tr.data.ptr.offsets = NULL;
+        tr.data.ptr.offsets = 0;
     } else {
         return (mLastError = err);
     }
@@ -950,8 +956,8 @@
         break;
         
     case BR_ACQUIRE:
-        refs = (RefBase::weakref_type*)mIn.readInt32();
-        obj = (BBinder*)mIn.readInt32();
+        refs = (RefBase::weakref_type*)mIn.readPointer();
+        obj = (BBinder*)mIn.readPointer();
         ALOG_ASSERT(refs->refBase() == obj,
                    "BR_ACQUIRE: object %p does not match cookie %p (expected %p)",
                    refs, obj, refs->refBase());
@@ -961,13 +967,13 @@
             obj->printRefs();
         }
         mOut.writeInt32(BC_ACQUIRE_DONE);
-        mOut.writeInt32((int32_t)refs);
-        mOut.writeInt32((int32_t)obj);
+        mOut.writePointer((uintptr_t)refs);
+        mOut.writePointer((uintptr_t)obj);
         break;
         
     case BR_RELEASE:
-        refs = (RefBase::weakref_type*)mIn.readInt32();
-        obj = (BBinder*)mIn.readInt32();
+        refs = (RefBase::weakref_type*)mIn.readPointer();
+        obj = (BBinder*)mIn.readPointer();
         ALOG_ASSERT(refs->refBase() == obj,
                    "BR_RELEASE: object %p does not match cookie %p (expected %p)",
                    refs, obj, refs->refBase());
@@ -979,17 +985,17 @@
         break;
         
     case BR_INCREFS:
-        refs = (RefBase::weakref_type*)mIn.readInt32();
-        obj = (BBinder*)mIn.readInt32();
+        refs = (RefBase::weakref_type*)mIn.readPointer();
+        obj = (BBinder*)mIn.readPointer();
         refs->incWeak(mProcess.get());
         mOut.writeInt32(BC_INCREFS_DONE);
-        mOut.writeInt32((int32_t)refs);
-        mOut.writeInt32((int32_t)obj);
+        mOut.writePointer((uintptr_t)refs);
+        mOut.writePointer((uintptr_t)obj);
         break;
         
     case BR_DECREFS:
-        refs = (RefBase::weakref_type*)mIn.readInt32();
-        obj = (BBinder*)mIn.readInt32();
+        refs = (RefBase::weakref_type*)mIn.readPointer();
+        obj = (BBinder*)mIn.readPointer();
         // NOTE: This assertion is not valid, because the object may no
         // longer exist (thus the (BBinder*)cast above resulting in a different
         // memory address).
@@ -1000,8 +1006,8 @@
         break;
         
     case BR_ATTEMPT_ACQUIRE:
-        refs = (RefBase::weakref_type*)mIn.readInt32();
-        obj = (BBinder*)mIn.readInt32();
+        refs = (RefBase::weakref_type*)mIn.readPointer();
+        obj = (BBinder*)mIn.readPointer();
          
         {
             const bool success = refs->attemptIncStrong(mProcess.get());
@@ -1026,8 +1032,8 @@
             buffer.ipcSetDataReference(
                 reinterpret_cast<const uint8_t*>(tr.data.ptr.buffer),
                 tr.data_size,
-                reinterpret_cast<const size_t*>(tr.data.ptr.offsets),
-                tr.offsets_size/sizeof(size_t), freeBuffer, this);
+                reinterpret_cast<const binder_size_t*>(tr.data.ptr.offsets),
+                tr.offsets_size/sizeof(binder_size_t), freeBuffer, this);
             
             const pid_t origPid = mCallingPid;
             const uid_t origUid = mCallingUid;
@@ -1103,15 +1109,15 @@
     
     case BR_DEAD_BINDER:
         {
-            BpBinder *proxy = (BpBinder*)mIn.readInt32();
+            BpBinder *proxy = (BpBinder*)mIn.readPointer();
             proxy->sendObituary();
             mOut.writeInt32(BC_DEAD_BINDER_DONE);
-            mOut.writeInt32((int32_t)proxy);
+            mOut.writePointer((uintptr_t)proxy);
         } break;
         
     case BR_CLEAR_DEATH_NOTIFICATION_DONE:
         {
-            BpBinder *proxy = (BpBinder*)mIn.readInt32();
+            BpBinder *proxy = (BpBinder*)mIn.readPointer();
             proxy->getWeakRefs()->decWeak(proxy);
         } break;
         
@@ -1154,9 +1160,10 @@
 }
 
 
-void IPCThreadState::freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize,
-                                const size_t* objects, size_t objectsSize,
-                                void* cookie)
+void IPCThreadState::freeBuffer(Parcel* parcel, const uint8_t* data,
+                                size_t /*dataSize*/,
+                                const binder_size_t* /*objects*/,
+                                size_t /*objectsSize*/, void* /*cookie*/)
 {
     //ALOGI("Freeing parcel %p", &parcel);
     IF_LOG_COMMANDS() {
@@ -1166,7 +1173,7 @@
     if (parcel != NULL) parcel->closeFileDescriptors();
     IPCThreadState* state = self();
     state->mOut.writeInt32(BC_FREE_BUFFER);
-    state->mOut.writeInt32((int32_t)data);
+    state->mOut.writePointer((uintptr_t)data);
 }
 
 }; // namespace android
diff --git a/libs/binder/IPermissionController.cpp b/libs/binder/IPermissionController.cpp
index e13036f..437113d 100644
--- a/libs/binder/IPermissionController.cpp
+++ b/libs/binder/IPermissionController.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IPermissionController.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/Parcel.h>
 #include <utils/String8.h>
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index a341ca8..7b1b0e7 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IServiceManager.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/IPCThreadState.h>
 #include <binder/Parcel.h>
diff --git a/libs/binder/MemoryDealer.cpp b/libs/binder/MemoryDealer.cpp
index 8d0e0a7..a14c100 100644
--- a/libs/binder/MemoryDealer.cpp
+++ b/libs/binder/MemoryDealer.cpp
@@ -210,7 +210,7 @@
 #ifdef MADV_REMOVE
             if (size) {
                 int err = madvise(start_ptr, size, MADV_REMOVE);
-                ALOGW_IF(err, "madvise(%p, %u, MADV_REMOVE) returned %s",
+                ALOGW_IF(err, "madvise(%p, %zu, MADV_REMOVE) returned %s",
                         start_ptr, size, err<0 ? strerror(errno) : "Ok");
             }
 #endif
@@ -445,8 +445,8 @@
         int np = ((cur->next) && cur->next->prev != cur) ? 1 : 0;
         int pn = ((cur->prev) && cur->prev->next != cur) ? 2 : 0;
 
-        snprintf(buffer, SIZE, "  %3u: %08x | 0x%08X | 0x%08X | %s %s\n",
-            i, int(cur), int(cur->start*kMemoryAlign),
+        snprintf(buffer, SIZE, "  %3u: %p | 0x%08X | 0x%08X | %s %s\n",
+            i, cur, int(cur->start*kMemoryAlign),
             int(cur->size*kMemoryAlign),
                     int(cur->free) ? "F" : "A",
                     errs[np|pn]);
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index db9e0a1..729cf21 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -25,6 +25,7 @@
 #include <binder/ProcessState.h>
 #include <binder/TextOutput.h>
 
+#include <errno.h>
 #include <utils/Debug.h>
 #include <utils/Log.h>
 #include <utils/String8.h>
@@ -78,12 +79,12 @@
         case BINDER_TYPE_BINDER:
             if (obj.binder) {
                 LOG_REFS("Parcel %p acquiring reference on local %p", who, obj.cookie);
-                static_cast<IBinder*>(obj.cookie)->incStrong(who);
+                reinterpret_cast<IBinder*>(obj.cookie)->incStrong(who);
             }
             return;
         case BINDER_TYPE_WEAK_BINDER:
             if (obj.binder)
-                static_cast<RefBase::weakref_type*>(obj.binder)->incWeak(who);
+                reinterpret_cast<RefBase::weakref_type*>(obj.binder)->incWeak(who);
             return;
         case BINDER_TYPE_HANDLE: {
             const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle);
@@ -105,7 +106,7 @@
         }
     }
 
-    ALOGD("Invalid object type 0x%08lx", obj.type);
+    ALOGD("Invalid object type 0x%08x", obj.type);
 }
 
 void release_object(const sp<ProcessState>& proc,
@@ -115,12 +116,12 @@
         case BINDER_TYPE_BINDER:
             if (obj.binder) {
                 LOG_REFS("Parcel %p releasing reference on local %p", who, obj.cookie);
-                static_cast<IBinder*>(obj.cookie)->decStrong(who);
+                reinterpret_cast<IBinder*>(obj.cookie)->decStrong(who);
             }
             return;
         case BINDER_TYPE_WEAK_BINDER:
             if (obj.binder)
-                static_cast<RefBase::weakref_type*>(obj.binder)->decWeak(who);
+                reinterpret_cast<RefBase::weakref_type*>(obj.binder)->decWeak(who);
             return;
         case BINDER_TYPE_HANDLE: {
             const sp<IBinder> b = proc->getStrongProxyForHandle(obj.handle);
@@ -136,25 +137,25 @@
             return;
         }
         case BINDER_TYPE_FD: {
-            if (obj.cookie != (void*)0) close(obj.handle);
+            if (obj.cookie != 0) close(obj.handle);
             return;
         }
     }
 
-    ALOGE("Invalid object type 0x%08lx", obj.type);
+    ALOGE("Invalid object type 0x%08x", obj.type);
 }
 
 inline static status_t finish_flatten_binder(
-    const sp<IBinder>& binder, const flat_binder_object& flat, Parcel* out)
+    const sp<IBinder>& /*binder*/, const flat_binder_object& flat, Parcel* out)
 {
     return out->writeObject(flat, false);
 }
 
-status_t flatten_binder(const sp<ProcessState>& proc,
+status_t flatten_binder(const sp<ProcessState>& /*proc*/,
     const sp<IBinder>& binder, Parcel* out)
 {
     flat_binder_object obj;
-    
+
     obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
     if (binder != NULL) {
         IBinder *local = binder->localBinder();
@@ -165,27 +166,28 @@
             }
             const int32_t handle = proxy ? proxy->handle() : 0;
             obj.type = BINDER_TYPE_HANDLE;
+            obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */
             obj.handle = handle;
-            obj.cookie = NULL;
+            obj.cookie = 0;
         } else {
             obj.type = BINDER_TYPE_BINDER;
-            obj.binder = local->getWeakRefs();
-            obj.cookie = local;
+            obj.binder = reinterpret_cast<uintptr_t>(local->getWeakRefs());
+            obj.cookie = reinterpret_cast<uintptr_t>(local);
         }
     } else {
         obj.type = BINDER_TYPE_BINDER;
-        obj.binder = NULL;
-        obj.cookie = NULL;
+        obj.binder = 0;
+        obj.cookie = 0;
     }
-    
+
     return finish_flatten_binder(binder, obj, out);
 }
 
-status_t flatten_binder(const sp<ProcessState>& proc,
+status_t flatten_binder(const sp<ProcessState>& /*proc*/,
     const wp<IBinder>& binder, Parcel* out)
 {
     flat_binder_object obj;
-    
+
     obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
     if (binder != NULL) {
         sp<IBinder> real = binder.promote();
@@ -198,16 +200,17 @@
                 }
                 const int32_t handle = proxy ? proxy->handle() : 0;
                 obj.type = BINDER_TYPE_WEAK_HANDLE;
+                obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */
                 obj.handle = handle;
-                obj.cookie = NULL;
+                obj.cookie = 0;
             } else {
                 obj.type = BINDER_TYPE_WEAK_BINDER;
-                obj.binder = binder.get_refs();
-                obj.cookie = binder.unsafe_get();
+                obj.binder = reinterpret_cast<uintptr_t>(binder.get_refs());
+                obj.cookie = reinterpret_cast<uintptr_t>(binder.unsafe_get());
             }
             return finish_flatten_binder(real, obj, out);
         }
-        
+
         // XXX How to deal?  In order to flatten the given binder,
         // we need to probe it for information, which requires a primary
         // reference...  but we don't have one.
@@ -217,39 +220,40 @@
         // implementation we are using.
         ALOGE("Unable to unflatten Binder weak reference!");
         obj.type = BINDER_TYPE_BINDER;
-        obj.binder = NULL;
-        obj.cookie = NULL;
+        obj.binder = 0;
+        obj.cookie = 0;
         return finish_flatten_binder(NULL, obj, out);
-    
+
     } else {
         obj.type = BINDER_TYPE_BINDER;
-        obj.binder = NULL;
-        obj.cookie = NULL;
+        obj.binder = 0;
+        obj.cookie = 0;
         return finish_flatten_binder(NULL, obj, out);
     }
 }
 
 inline static status_t finish_unflatten_binder(
-    BpBinder* proxy, const flat_binder_object& flat, const Parcel& in)
+    BpBinder* /*proxy*/, const flat_binder_object& /*flat*/,
+    const Parcel& /*in*/)
 {
     return NO_ERROR;
 }
-    
+
 status_t unflatten_binder(const sp<ProcessState>& proc,
     const Parcel& in, sp<IBinder>* out)
 {
     const flat_binder_object* flat = in.readObject(false);
-    
+
     if (flat) {
         switch (flat->type) {
             case BINDER_TYPE_BINDER:
-                *out = static_cast<IBinder*>(flat->cookie);
+                *out = reinterpret_cast<IBinder*>(flat->cookie);
                 return finish_unflatten_binder(NULL, *flat, in);
             case BINDER_TYPE_HANDLE:
                 *out = proc->getStrongProxyForHandle(flat->handle);
                 return finish_unflatten_binder(
                     static_cast<BpBinder*>(out->get()), *flat, in);
-        }        
+        }
     }
     return BAD_TYPE;
 }
@@ -258,17 +262,17 @@
     const Parcel& in, wp<IBinder>* out)
 {
     const flat_binder_object* flat = in.readObject(false);
-    
+
     if (flat) {
         switch (flat->type) {
             case BINDER_TYPE_BINDER:
-                *out = static_cast<IBinder*>(flat->cookie);
+                *out = reinterpret_cast<IBinder*>(flat->cookie);
                 return finish_unflatten_binder(NULL, *flat, in);
             case BINDER_TYPE_WEAK_BINDER:
-                if (flat->binder != NULL) {
+                if (flat->binder != 0) {
                     out->set_object_and_refs(
-                        static_cast<IBinder*>(flat->cookie),
-                        static_cast<RefBase::weakref_type*>(flat->binder));
+                        reinterpret_cast<IBinder*>(flat->cookie),
+                        reinterpret_cast<RefBase::weakref_type*>(flat->binder));
                 } else {
                     *out = NULL;
                 }
@@ -332,7 +336,7 @@
     err = continueWrite(size);
     if (err == NO_ERROR) {
         mDataSize = size;
-        ALOGV("setDataSize Setting data size of %p to %d\n", this, mDataSize);
+        ALOGV("setDataSize Setting data size of %p to %zu", this, mDataSize);
     }
     return err;
 }
@@ -365,7 +369,7 @@
     const sp<ProcessState> proc(ProcessState::self());
     status_t err;
     const uint8_t *data = parcel->mData;
-    const size_t *objects = parcel->mObjects;
+    const binder_size_t *objects = parcel->mObjects;
     size_t size = parcel->mObjectsSize;
     int startPos = mDataPos;
     int firstIndex = -1, lastIndex = -2;
@@ -412,15 +416,15 @@
         // grow objects
         if (mObjectsCapacity < mObjectsSize + numObjects) {
             int newSize = ((mObjectsSize + numObjects)*3)/2;
-            size_t *objects =
-                (size_t*)realloc(mObjects, newSize*sizeof(size_t));
-            if (objects == (size_t*)0) {
+            binder_size_t *objects =
+                (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
+            if (objects == (binder_size_t*)0) {
                 return NO_MEMORY;
             }
             mObjects = objects;
             mObjectsCapacity = newSize;
         }
-        
+
         // append and acquire objects
         int idx = mObjectsSize;
         for (int i = firstIndex; i <= lastIndex; i++) {
@@ -437,7 +441,7 @@
                 // new Parcel now owns its own fd, and can declare that we
                 // officially know we have fds.
                 flat->handle = dup(flat->handle);
-                flat->cookie = (void*)1;
+                flat->cookie = 1;
                 mHasFds = mFdsKnown = true;
                 if (!mAllowFds) {
                     err = FDS_NOT_ALLOWED;
@@ -506,13 +510,13 @@
     if (str == interface) {
         return true;
     } else {
-        ALOGW("**** enforceInterface() expected '%s' but read '%s'\n",
+        ALOGW("**** enforceInterface() expected '%s' but read '%s'",
                 String8(interface).string(), String8(str).string());
         return false;
     }
 }
 
-const size_t* Parcel::objects() const
+const binder_size_t* Parcel::objects() const
 {
     return mObjects;
 }
@@ -536,10 +540,10 @@
 {
     //printf("Finish write of %d\n", len);
     mDataPos += len;
-    ALOGV("finishWrite Setting data pos of %p to %d\n", this, mDataPos);
+    ALOGV("finishWrite Setting data pos of %p to %zu", this, mDataPos);
     if (mDataPos > mDataSize) {
         mDataSize = mDataPos;
-        ALOGV("finishWrite Setting data size of %p to %d\n", this, mDataSize);
+        ALOGV("finishWrite Setting data size of %p to %zu", this, mDataSize);
     }
     //printf("New pos=%d, size=%d\n", mDataPos, mDataSize);
     return NO_ERROR;
@@ -644,6 +648,11 @@
     return writeAligned(val);
 }
 
+status_t Parcel::writePointer(uintptr_t val)
+{
+    return writeAligned<binder_uintptr_t>(val);
+}
+
 status_t Parcel::writeFloat(float val)
 {
     return writeAligned(val);
@@ -700,7 +709,7 @@
 status_t Parcel::writeString16(const char16_t* str, size_t len)
 {
     if (str == NULL) return writeInt32(-1);
-    
+
     status_t err = writeInt32(len);
     if (err == NO_ERROR) {
         len *= sizeof(char16_t);
@@ -753,8 +762,9 @@
     flat_binder_object obj;
     obj.type = BINDER_TYPE_FD;
     obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
+    obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */
     obj.handle = fd;
-    obj.cookie = (void*) (takeOwnership ? 1 : 0);
+    obj.cookie = takeOwnership ? 1 : 0;
     return writeObject(obj, true);
 }
 
@@ -862,14 +872,14 @@
     if (enoughData && enoughObjects) {
 restart_write:
         *reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val;
-        
+
         // Need to write meta-data?
-        if (nullMetaData || val.binder != NULL) {
+        if (nullMetaData || val.binder != 0) {
             mObjects[mObjectsSize] = mDataPos;
             acquire_object(ProcessState::self(), val, this);
             mObjectsSize++;
         }
-        
+
         // remember if it's a file descriptor
         if (val.type == BINDER_TYPE_FD) {
             if (!mAllowFds) {
@@ -887,12 +897,12 @@
     }
     if (!enoughObjects) {
         size_t newSize = ((mObjectsSize+2)*3)/2;
-        size_t* objects = (size_t*)realloc(mObjects, newSize*sizeof(size_t));
+        binder_size_t* objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
         if (objects == NULL) return NO_MEMORY;
         mObjects = objects;
         mObjectsCapacity = newSize;
     }
-    
+
     goto restart_write;
 }
 
@@ -901,7 +911,7 @@
     return writeInt32(0);
 }
 
-void Parcel::remove(size_t start, size_t amt)
+void Parcel::remove(size_t /*start*/, size_t /*amt*/)
 {
     LOG_ALWAYS_FATAL("Parcel::remove() not yet implemented!");
 }
@@ -912,7 +922,7 @@
             && len <= PAD_SIZE(len)) {
         memcpy(outData, mData+mDataPos, len);
         mDataPos += PAD_SIZE(len);
-        ALOGV("read Setting data pos of %p to %d\n", this, mDataPos);
+        ALOGV("read Setting data pos of %p to %zu", this, mDataPos);
         return NO_ERROR;
     }
     return NOT_ENOUGH_DATA;
@@ -924,7 +934,7 @@
             && len <= PAD_SIZE(len)) {
         const void* data = mData+mDataPos;
         mDataPos += PAD_SIZE(len);
-        ALOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
+        ALOGV("readInplace Setting data pos of %p to %zu", this, mDataPos);
         return data;
     }
     return NULL;
@@ -991,6 +1001,22 @@
     return readAligned<int64_t>();
 }
 
+status_t Parcel::readPointer(uintptr_t *pArg) const
+{
+    status_t ret;
+    binder_uintptr_t ptr;
+    ret = readAligned(&ptr);
+    if (!ret)
+        *pArg = ptr;
+    return ret;
+}
+
+uintptr_t Parcel::readPointer() const
+{
+    return readAligned<binder_uintptr_t>();
+}
+
+
 status_t Parcel::readFloat(float *pArg) const
 {
     return readAligned(pArg);
@@ -1010,6 +1036,7 @@
       double d;
       unsigned long long ll;
     } u;
+    u.d = 0;
     status_t status;
     status = readAligned(&u.ll);
     *pArg = u.d;
@@ -1062,7 +1089,7 @@
         if (eos) {
             const size_t len = eos - str;
             mDataPos += PAD_SIZE(len+1);
-            ALOGV("readCString Setting data pos of %p to %d\n", this, mDataPos);
+            ALOGV("readCString Setting data pos of %p to %zu", this, mDataPos);
             return str;
         }
     }
@@ -1164,9 +1191,9 @@
     if (flat) {
         switch (flat->type) {
             case BINDER_TYPE_FD:
-                //ALOGI("Returning file descriptor %ld from parcel %p\n", flat->handle, this);
+                //ALOGI("Returning file descriptor %ld from parcel %p", flat->handle, this);
                 return flat->handle;
-        }        
+        }
     }
     return BAD_TYPE;
 }
@@ -1216,7 +1243,11 @@
     status_t err = NO_ERROR;
     for (size_t i=0 ; i<fd_count && err==NO_ERROR ; i++) {
         fds[i] = dup(this->readFileDescriptor());
-        if (fds[i] < 0) err = BAD_VALUE;
+        if (fds[i] < 0) {
+            err = BAD_VALUE;
+            ALOGE("dup() failed in Parcel::read, i is %zu, fds[i] is %d, fd_count is %zu, error: %s",
+                i, fds[i], fd_count, strerror(errno));
+        }
     }
 
     if (err == NO_ERROR) {
@@ -1236,23 +1267,23 @@
         const flat_binder_object* obj
                 = reinterpret_cast<const flat_binder_object*>(mData+DPOS);
         mDataPos = DPOS + sizeof(flat_binder_object);
-        if (!nullMetaData && (obj->cookie == NULL && obj->binder == NULL)) {
+        if (!nullMetaData && (obj->cookie == 0 && obj->binder == 0)) {
             // When transferring a NULL object, we don't write it into
             // the object list, so we don't want to check for it when
             // reading.
-            ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+            ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
             return obj;
         }
-        
+
         // Ensure that this object is valid...
-        size_t* const OBJS = mObjects;
+        binder_size_t* const OBJS = mObjects;
         const size_t N = mObjectsSize;
         size_t opos = mNextObjectHint;
-        
+
         if (N > 0) {
-            ALOGV("Parcel %p looking for obj at %d, hint=%d\n",
+            ALOGV("Parcel %p looking for obj at %zu, hint=%zu",
                  this, DPOS, opos);
-            
+
             // Start at the current hint position, looking for an object at
             // the current data position.
             if (opos < N) {
@@ -1264,27 +1295,27 @@
             }
             if (OBJS[opos] == DPOS) {
                 // Found it!
-                ALOGV("Parcel found obj %d at index %d with forward search",
+                ALOGV("Parcel %p found obj %zu at index %zu with forward search",
                      this, DPOS, opos);
                 mNextObjectHint = opos+1;
-                ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+                ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
                 return obj;
             }
-        
+
             // Look backwards for it...
             while (opos > 0 && OBJS[opos] > DPOS) {
                 opos--;
             }
             if (OBJS[opos] == DPOS) {
                 // Found it!
-                ALOGV("Parcel found obj %d at index %d with backward search",
+                ALOGV("Parcel %p found obj %zu at index %zu with backward search",
                      this, DPOS, opos);
                 mNextObjectHint = opos+1;
-                ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+                ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
                 return obj;
             }
         }
-        ALOGW("Attempt to read object from Parcel %p at offset %d that is not in the object list",
+        ALOGW("Attempt to read object from Parcel %p at offset %zu that is not in the object list",
              this, DPOS);
     }
     return NULL;
@@ -1294,22 +1325,22 @@
 {
     size_t i = mObjectsSize;
     if (i > 0) {
-        //ALOGI("Closing file descriptors for %d objects...", mObjectsSize);
+        //ALOGI("Closing file descriptors for %zu objects...", i);
     }
     while (i > 0) {
         i--;
         const flat_binder_object* flat
             = reinterpret_cast<flat_binder_object*>(mData+mObjects[i]);
         if (flat->type == BINDER_TYPE_FD) {
-            //ALOGI("Closing fd: %ld\n", flat->handle);
+            //ALOGI("Closing fd: %ld", flat->handle);
             close(flat->handle);
         }
     }
 }
 
-const uint8_t* Parcel::ipcData() const
+uintptr_t Parcel::ipcData() const
 {
-    return mData;
+    return reinterpret_cast<uintptr_t>(mData);
 }
 
 size_t Parcel::ipcDataSize() const
@@ -1317,9 +1348,9 @@
     return (mDataSize > mDataPos ? mDataSize : mDataPos);
 }
 
-const size_t* Parcel::ipcObjects() const
+uintptr_t Parcel::ipcObjects() const
 {
-    return mObjects;
+    return reinterpret_cast<uintptr_t>(mObjects);
 }
 
 size_t Parcel::ipcObjectsCount() const
@@ -1328,26 +1359,26 @@
 }
 
 void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
-    const size_t* objects, size_t objectsCount, release_func relFunc, void* relCookie)
+    const binder_size_t* objects, size_t objectsCount, release_func relFunc, void* relCookie)
 {
-    size_t minOffset = 0;
+    binder_size_t minOffset = 0;
     freeDataNoInit();
     mError = NO_ERROR;
     mData = const_cast<uint8_t*>(data);
     mDataSize = mDataCapacity = dataSize;
-    //ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)\n", this, mDataSize, getpid());
+    //ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)", this, mDataSize, getpid());
     mDataPos = 0;
-    ALOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
-    mObjects = const_cast<size_t*>(objects);
+    ALOGV("setDataReference Setting data pos of %p to %zu", this, mDataPos);
+    mObjects = const_cast<binder_size_t*>(objects);
     mObjectsSize = mObjectsCapacity = objectsCount;
     mNextObjectHint = 0;
     mOwner = relFunc;
     mOwnerCookie = relCookie;
     for (size_t i = 0; i < mObjectsSize; i++) {
-        size_t offset = mObjects[i];
+        binder_size_t offset = mObjects[i];
         if (offset < minOffset) {
-            ALOGE("%s: bad object offset %zu < %zu\n",
-                  __func__, offset, minOffset);
+            ALOGE("%s: bad object offset %"PRIu64" < %"PRIu64"\n",
+                  __func__, (uint64_t)offset, (uint64_t)minOffset);
             mObjectsSize = 0;
             break;
         }
@@ -1356,17 +1387,17 @@
     scanForFds();
 }
 
-void Parcel::print(TextOutput& to, uint32_t flags) const
+void Parcel::print(TextOutput& to, uint32_t /*flags*/) const
 {
     to << "Parcel(";
-    
+
     if (errorCheck() != NO_ERROR) {
         const status_t err = errorCheck();
-        to << "Error: " << (void*)err << " \"" << strerror(-err) << "\"";
+        to << "Error: " << (void*)(intptr_t)err << " \"" << strerror(-err) << "\"";
     } else if (dataSize() > 0) {
         const uint8_t* DATA = data();
         to << indent << HexDump(DATA, dataSize()) << dedent;
-        const size_t* OBJS = objects();
+        const binder_size_t* OBJS = objects();
         const size_t N = objectsCount();
         for (size_t i=0; i<N; i++) {
             const flat_binder_object* flat
@@ -1378,7 +1409,7 @@
     } else {
         to << "NULL";
     }
-    
+
     to << ")";
 }
 
@@ -1387,7 +1418,7 @@
     const sp<ProcessState> proc(ProcessState::self());
     size_t i = mObjectsSize;
     uint8_t* const data = mData;
-    size_t* const objects = mObjects;
+    binder_size_t* const objects = mObjects;
     while (i > 0) {
         i--;
         const flat_binder_object* flat
@@ -1401,7 +1432,7 @@
     const sp<ProcessState> proc(ProcessState::self());
     size_t i = mObjectsSize;
     uint8_t* const data = mData;
-    size_t* const objects = mObjects;
+    binder_size_t* const objects = mObjects;
     while (i > 0) {
         i--;
         const flat_binder_object* flat
@@ -1419,7 +1450,7 @@
 void Parcel::freeDataNoInit()
 {
     if (mOwner) {
-        //ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
+        //ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
         mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
     } else {
         releaseObjects();
@@ -1442,24 +1473,24 @@
         freeData();
         return continueWrite(desired);
     }
-    
+
     uint8_t* data = (uint8_t*)realloc(mData, desired);
     if (!data && desired > mDataCapacity) {
         mError = NO_MEMORY;
         return NO_MEMORY;
     }
-    
+
     releaseObjects();
-    
+
     if (data) {
         mData = data;
         mDataCapacity = desired;
     }
-    
+
     mDataSize = mDataPos = 0;
-    ALOGV("restartWrite Setting data size of %p to %d\n", this, mDataSize);
-    ALOGV("restartWrite Setting data pos of %p to %d\n", this, mDataPos);
-        
+    ALOGV("restartWrite Setting data size of %p to %zu", this, mDataSize);
+    ALOGV("restartWrite Setting data pos of %p to %zu", this, mDataPos);
+
     free(mObjects);
     mObjects = NULL;
     mObjectsSize = mObjectsCapacity = 0;
@@ -1467,7 +1498,7 @@
     mHasFds = false;
     mFdsKnown = true;
     mAllowFds = true;
-    
+
     return NO_ERROR;
 }
 
@@ -1487,7 +1518,7 @@
             }
         }
     }
-    
+
     if (mOwner) {
         // If the size is going to zero, just release the owner's data.
         if (desired == 0) {
@@ -1502,10 +1533,10 @@
             mError = NO_MEMORY;
             return NO_MEMORY;
         }
-        size_t* objects = NULL;
-        
+        binder_size_t* objects = NULL;
+
         if (objectsSize) {
-            objects = (size_t*)malloc(objectsSize*sizeof(size_t));
+            objects = (binder_size_t*)malloc(objectsSize*sizeof(binder_size_t));
             if (!objects) {
                 free(data);
 
@@ -1520,21 +1551,21 @@
             acquireObjects();
             mObjectsSize = oldObjectsSize;
         }
-        
+
         if (mData) {
             memcpy(data, mData, mDataSize < desired ? mDataSize : desired);
         }
         if (objects && mObjects) {
-            memcpy(objects, mObjects, objectsSize*sizeof(size_t));
+            memcpy(objects, mObjects, objectsSize*sizeof(binder_size_t));
         }
-        //ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
+        //ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
         mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
         mOwner = NULL;
 
         mData = data;
         mObjects = objects;
         mDataSize = (mDataSize < desired) ? mDataSize : desired;
-        ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+        ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
         mDataCapacity = desired;
         mObjectsSize = mObjectsCapacity = objectsSize;
         mNextObjectHint = 0;
@@ -1552,8 +1583,8 @@
                 }
                 release_object(proc, *flat, this);
             }
-            size_t* objects =
-                (size_t*)realloc(mObjects, objectsSize*sizeof(size_t));
+            binder_size_t* objects =
+                (binder_size_t*)realloc(mObjects, objectsSize*sizeof(binder_size_t));
             if (objects) {
                 mObjects = objects;
             }
@@ -1574,14 +1605,14 @@
         } else {
             if (mDataSize > desired) {
                 mDataSize = desired;
-                ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+                ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
             }
             if (mDataPos > desired) {
                 mDataPos = desired;
-                ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+                ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
             }
         }
-        
+
     } else {
         // This is the first data.  Easy!
         uint8_t* data = (uint8_t*)malloc(desired);
@@ -1592,13 +1623,13 @@
 
         if(!(mDataCapacity == 0 && mObjects == NULL
              && mObjectsCapacity == 0)) {
-            ALOGE("continueWrite: %d/%p/%d/%d", mDataCapacity, mObjects, mObjectsCapacity, desired);
+            ALOGE("continueWrite: %zu/%p/%zu/%zu", mDataCapacity, mObjects, mObjectsCapacity, desired);
         }
-        
+
         mData = data;
         mDataSize = mDataPos = 0;
-        ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
-        ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+        ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
+        ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
         mDataCapacity = desired;
     }
 
@@ -1612,8 +1643,8 @@
     mDataSize = 0;
     mDataCapacity = 0;
     mDataPos = 0;
-    ALOGV("initState Setting data size of %p to %d\n", this, mDataSize);
-    ALOGV("initState Setting data pos of %p to %d\n", this, mDataPos);
+    ALOGV("initState Setting data size of %p to %zu", this, mDataSize);
+    ALOGV("initState Setting data pos of %p to %zu", this, mDataPos);
     mObjects = NULL;
     mObjectsSize = 0;
     mObjectsCapacity = 0;
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index c1e49bc..303d6cf 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -48,11 +48,6 @@
 
 namespace android {
  
-// Global variables
-int                 mArgC;
-const char* const*  mArgV;
-int                 mArgLen;
-
 class PoolThread : public Thread
 {
 public:
@@ -86,7 +81,7 @@
     setContextObject(object, String16("default"));
 }
 
-sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& caller)
+sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& /*caller*/)
 {
     return getStrongProxyForHandle(0);
 }
@@ -280,36 +275,6 @@
     if (e && e->binder == binder) e->binder = NULL;
 }
 
-void ProcessState::setArgs(int argc, const char* const argv[])
-{
-    mArgC = argc;
-    mArgV = (const char **)argv;
-
-    mArgLen = 0;
-    for (int i=0; i<argc; i++) {
-        mArgLen += strlen(argv[i]) + 1;
-    }
-    mArgLen--;
-}
-
-int ProcessState::getArgC() const
-{
-    return mArgC;
-}
-
-const char* const* ProcessState::getArgV() const
-{
-    return mArgV;
-}
-
-void ProcessState::setArgV0(const char* txt)
-{
-    if (mArgV != NULL) {
-        strncpy((char*)mArgV[0], txt, mArgLen);
-        set_process_name(txt);
-    }
-}
-
 String8 ProcessState::makeBinderThreadName() {
     int32_t s = android_atomic_add(1, &mThreadPoolSeq);
     String8 name;
@@ -345,7 +310,7 @@
     int fd = open("/dev/binder", O_RDWR);
     if (fd >= 0) {
         fcntl(fd, F_SETFD, FD_CLOEXEC);
-        int vers;
+        int vers = 0;
         status_t result = ioctl(fd, BINDER_VERSION, &vers);
         if (result == -1) {
             ALOGE("Binder ioctl to obtain version failed: %s", strerror(errno));
diff --git a/libs/gui/BitTube.cpp b/libs/gui/BitTube.cpp
index 85a7de7..0282834 100644
--- a/libs/gui/BitTube.cpp
+++ b/libs/gui/BitTube.cpp
@@ -145,7 +145,7 @@
 
     // should never happen because of SOCK_SEQPACKET
     LOG_ALWAYS_FATAL_IF((size >= 0) && (size % objSize),
-            "BitTube::sendObjects(count=%d, size=%d), res=%d (partial events were sent!)",
+            "BitTube::sendObjects(count=%zu, size=%zu), res=%zd (partial events were sent!)",
             count, objSize, size);
 
     //ALOGE_IF(size<0, "error %d sending %d events", size, count);
@@ -160,7 +160,7 @@
 
     // should never happen because of SOCK_SEQPACKET
     LOG_ALWAYS_FATAL_IF((size >= 0) && (size % objSize),
-            "BitTube::recvObjects(count=%d, size=%d), res=%d (partial events were received!)",
+            "BitTube::recvObjects(count=%zu, size=%zu), res=%zd (partial events were received!)",
             count, objSize, size);
 
     //ALOGE_IF(size<0, "error %d receiving %d events", size, count);
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index c4ec857..674ee5a 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
+
 #define LOG_TAG "ConsumerBase"
 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
 //#define LOG_NDEBUG 0
@@ -188,7 +190,7 @@
     mSlots[item->mBuf].mFrameNumber = item->mFrameNumber;
     mSlots[item->mBuf].mFence = item->mFence;
 
-    CB_LOGV("acquireBufferLocked: -> slot=%d/%llu",
+    CB_LOGV("acquireBufferLocked: -> slot=%d/%" PRIu64,
             item->mBuf, item->mFrameNumber);
 
     return OK;
@@ -239,7 +241,7 @@
         return OK;
     }
 
-    CB_LOGV("releaseBufferLocked: slot=%d/%llu",
+    CB_LOGV("releaseBufferLocked: slot=%d/%" PRIu64,
             slot, mSlots[slot].mFrameNumber);
     status_t err = mConsumer->releaseBuffer(slot, mSlots[slot].mFrameNumber,
             display, eglFence, mSlots[slot].mFence);
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 27dbc4e..21ffc06 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -740,15 +740,6 @@
     ALOGE_IF(err, "dequeueBuffer failed (%s)", strerror(-err));
     if (err == NO_ERROR) {
         sp<GraphicBuffer> backBuffer(GraphicBuffer::getSelf(out));
-        sp<Fence> fence(new Fence(fenceFd));
-
-        err = fence->waitForever("Surface::lock");
-        if (err != OK) {
-            ALOGE("Fence::wait failed (%s)", strerror(-err));
-            cancelBuffer(out, fenceFd);
-            return err;
-        }
-
         const Rect bounds(backBuffer->width, backBuffer->height);
 
         Region newDirtyRegion;
@@ -799,9 +790,9 @@
         }
 
         void* vaddr;
-        status_t res = backBuffer->lock(
+        status_t res = backBuffer->lockAsync(
                 GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
-                newDirtyRegion.bounds(), &vaddr);
+                newDirtyRegion.bounds(), &vaddr, fenceFd);
 
         ALOGW_IF(res, "failed locking buffer (handle = %p)",
                 backBuffer->handle);
@@ -827,10 +818,11 @@
         return INVALID_OPERATION;
     }
 
-    status_t err = mLockedBuffer->unlock();
+    int fd = -1;
+    status_t err = mLockedBuffer->unlockAsync(&fd);
     ALOGE_IF(err, "failed unlocking buffer (%p)", mLockedBuffer->handle);
 
-    err = queueBuffer(mLockedBuffer.get(), -1);
+    err = queueBuffer(mLockedBuffer.get(), fd);
     ALOGE_IF(err, "queueBuffer (handle=%p) failed (%s)",
             mLockedBuffer->handle, strerror(-err));
 
diff --git a/libs/gui/tests/CpuConsumer_test.cpp b/libs/gui/tests/CpuConsumer_test.cpp
index afbc026..b370a2d 100644
--- a/libs/gui/tests/CpuConsumer_test.cpp
+++ b/libs/gui/tests/CpuConsumer_test.cpp
@@ -656,7 +656,7 @@
     ALOGV("Locking frame %d (too many)", params.maxLockedBuffers);
     CpuConsumer::LockedBuffer bTooMuch;
     err = mCC->lockNextBuffer(&bTooMuch);
-    ASSERT_TRUE(err == INVALID_OPERATION) << "Allowing too many locks";
+    ASSERT_TRUE(err == NOT_ENOUGH_DATA) << "Allowing too many locks";
 
     ALOGV("Unlocking frame 0");
     err = mCC->unlockBuffer(b[0]);
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 09b2e7c..2d0fb8c 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -292,7 +292,7 @@
         float yPrecision,
         nsecs_t downTime,
         nsecs_t eventTime,
-        size_t pointerCount,
+        uint32_t pointerCount,
         const PointerProperties* pointerProperties,
         const PointerCoords* pointerCoords) {
 #if DEBUG_TRANSPORT_ACTIONS
@@ -334,7 +334,7 @@
     msg.body.motion.downTime = downTime;
     msg.body.motion.eventTime = eventTime;
     msg.body.motion.pointerCount = pointerCount;
-    for (size_t i = 0; i < pointerCount; i++) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
         msg.body.motion.pointers[i].properties.copyFrom(pointerProperties[i]);
         msg.body.motion.pointers[i].coords.copyFrom(pointerCoords[i]);
     }
@@ -654,7 +654,7 @@
 }
 
 void InputConsumer::rewriteMessage(const TouchState& state, InputMessage* msg) {
-    for (size_t i = 0; i < msg->body.motion.pointerCount; i++) {
+    for (uint32_t i = 0; i < msg->body.motion.pointerCount; i++) {
         uint32_t id = msg->body.motion.pointers[i].properties.id;
         if (state.lastResample.idBits.hasBit(id)) {
             PointerCoords& msgCoords = msg->body.motion.pointers[i].coords;
@@ -894,10 +894,10 @@
 }
 
 void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage* msg) {
-    size_t pointerCount = msg->body.motion.pointerCount;
+    uint32_t pointerCount = msg->body.motion.pointerCount;
     PointerProperties pointerProperties[pointerCount];
     PointerCoords pointerCoords[pointerCount];
-    for (size_t i = 0; i < pointerCount; i++) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
         pointerProperties[i].copyFrom(msg->body.motion.pointers[i].properties);
         pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords);
     }
@@ -922,9 +922,9 @@
 }
 
 void InputConsumer::addSample(MotionEvent* event, const InputMessage* msg) {
-    size_t pointerCount = msg->body.motion.pointerCount;
+    uint32_t pointerCount = msg->body.motion.pointerCount;
     PointerCoords pointerCoords[pointerCount];
-    for (size_t i = 0; i < pointerCount; i++) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
         pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords);
     }
 
@@ -934,7 +934,7 @@
 
 bool InputConsumer::canAddSample(const Batch& batch, const InputMessage *msg) {
     const InputMessage& head = batch.samples.itemAt(0);
-    size_t pointerCount = msg->body.motion.pointerCount;
+    uint32_t pointerCount = msg->body.motion.pointerCount;
     if (head.body.motion.pointerCount != pointerCount
             || head.body.motion.action != msg->body.motion.action) {
         return false;
diff --git a/libs/input/tests/Android.mk b/libs/input/tests/Android.mk
index c62dff1..9612a65 100644
--- a/libs/input/tests/Android.mk
+++ b/libs/input/tests/Android.mk
@@ -29,5 +29,16 @@
     $(eval include $(BUILD_NATIVE_TEST)) \
 )
 
+# NOTE: This is a compile time test, and does not need to be
+# run. All assertions are static_asserts and will fail during
+# buildtime if something's wrong.
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := StructLayout_test.cpp
+LOCAL_MODULE := StructLayout_test
+LOCAL_CFLAGS := -std=c++11 -O0
+LOCAL_MULTILIB := both
+include $(BUILD_STATIC_LIBRARY)
+
+
 # Build the manual test programs.
 include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libs/input/tests/StructLayout_test.cpp b/libs/input/tests/StructLayout_test.cpp
new file mode 100644
index 0000000..83bc6ae
--- /dev/null
+++ b/libs/input/tests/StructLayout_test.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 <input/InputTransport.h>
+#include <input/Input.h>
+
+namespace android {
+
+#define CHECK_OFFSET(type, member, expected_offset) \
+  static_assert((offsetof(type, member) == expected_offset), "")
+
+struct Foo {
+  uint32_t dummy;
+  PointerCoords coords;
+};
+
+void TestPointerCoordsAlignment() {
+  CHECK_OFFSET(Foo, coords, 8);
+}
+
+void TestInputMessageAlignment() {
+  CHECK_OFFSET(InputMessage, body, 8);
+
+  CHECK_OFFSET(InputMessage::Body::Key, seq, 0);
+  CHECK_OFFSET(InputMessage::Body::Key, eventTime, 8);
+  CHECK_OFFSET(InputMessage::Body::Key, deviceId, 16);
+  CHECK_OFFSET(InputMessage::Body::Key, source, 20);
+  CHECK_OFFSET(InputMessage::Body::Key, action, 24);
+  CHECK_OFFSET(InputMessage::Body::Key, flags, 28);
+  CHECK_OFFSET(InputMessage::Body::Key, keyCode, 32);
+  CHECK_OFFSET(InputMessage::Body::Key, scanCode, 36);
+  CHECK_OFFSET(InputMessage::Body::Key, metaState, 40);
+  CHECK_OFFSET(InputMessage::Body::Key, repeatCount, 44);
+  CHECK_OFFSET(InputMessage::Body::Key, downTime, 48);
+
+  CHECK_OFFSET(InputMessage::Body::Motion, seq, 0);
+  CHECK_OFFSET(InputMessage::Body::Motion, eventTime, 8);
+  CHECK_OFFSET(InputMessage::Body::Motion, deviceId, 16);
+  CHECK_OFFSET(InputMessage::Body::Motion, source, 20);
+  CHECK_OFFSET(InputMessage::Body::Motion, action, 24);
+  CHECK_OFFSET(InputMessage::Body::Motion, flags, 28);
+  CHECK_OFFSET(InputMessage::Body::Motion, metaState, 32);
+  CHECK_OFFSET(InputMessage::Body::Motion, buttonState, 36);
+  CHECK_OFFSET(InputMessage::Body::Motion, edgeFlags, 40);
+  CHECK_OFFSET(InputMessage::Body::Motion, downTime, 48);
+  CHECK_OFFSET(InputMessage::Body::Motion, xOffset, 56);
+  CHECK_OFFSET(InputMessage::Body::Motion, yOffset, 60);
+  CHECK_OFFSET(InputMessage::Body::Motion, xPrecision, 64);
+  CHECK_OFFSET(InputMessage::Body::Motion, yPrecision, 68);
+  CHECK_OFFSET(InputMessage::Body::Motion, pointerCount, 72);
+  CHECK_OFFSET(InputMessage::Body::Motion, pointers, 80);
+}
+
+} // namespace android
diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp
index 93ec0ce..3c0306c 100644
--- a/libs/ui/Fence.cpp
+++ b/libs/ui/Fence.cpp
@@ -138,7 +138,7 @@
     if (size < getFlattenedSize() || count < getFdCount()) {
         return NO_MEMORY;
     }
-    FlattenableUtils::write(buffer, size, getFdCount());
+    FlattenableUtils::write(buffer, size, (uint32_t)getFdCount());
     if (isValid()) {
         *fds++ = mFenceFd;
         count--;
@@ -156,7 +156,7 @@
         return NO_MEMORY;
     }
 
-    size_t numFds;
+    uint32_t numFds;
     FlattenableUtils::read(buffer, size, numFds);
 
     if (numFds > 1) {
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 31a69b2..918f2e7 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -259,8 +259,8 @@
     return 0;
 }
 
-int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* window, 
-        ANativeWindowBuffer* buffer)
+int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* /*window*/, 
+        ANativeWindowBuffer* /*buffer*/)
 {
     return NO_ERROR;
 }
@@ -326,7 +326,7 @@
     return BAD_VALUE;
 }
 
-int FramebufferNativeWindow::perform(ANativeWindow* window,
+int FramebufferNativeWindow::perform(ANativeWindow* /*window*/,
         int operation, ...)
 {
     switch (operation) {
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 96a7188..708888e 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -200,6 +200,52 @@
     return res;
 }
 
+status_t GraphicBuffer::lockAsync(uint32_t usage, void** vaddr, int fenceFd)
+{
+    const Rect lockBounds(width, height);
+    status_t res = lockAsync(usage, lockBounds, vaddr, fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::lockAsync(uint32_t usage, const Rect& rect, void** vaddr, int fenceFd)
+{
+    if (rect.left < 0 || rect.right  > this->width ||
+        rect.top  < 0 || rect.bottom > this->height) {
+        ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
+                rect.left, rect.top, rect.right, rect.bottom,
+                this->width, this->height);
+        return BAD_VALUE;
+    }
+    status_t res = getBufferMapper().lockAsync(handle, usage, rect, vaddr, fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::lockAsyncYCbCr(uint32_t usage, android_ycbcr *ycbcr, int fenceFd)
+{
+    const Rect lockBounds(width, height);
+    status_t res = lockAsyncYCbCr(usage, lockBounds, ycbcr, fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::lockAsyncYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd)
+{
+    if (rect.left < 0 || rect.right  > this->width ||
+        rect.top  < 0 || rect.bottom > this->height) {
+        ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
+                rect.left, rect.top, rect.right, rect.bottom,
+                this->width, this->height);
+        return BAD_VALUE;
+    }
+    status_t res = getBufferMapper().lockAsyncYCbCr(handle, usage, rect, ycbcr, fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::unlockAsync(int *fenceFd)
+{
+    status_t res = getBufferMapper().unlockAsync(handle, fenceFd);
+    return res;
+}
+
 size_t GraphicBuffer::getFlattenedSize() const {
     return (8 + (handle ? handle->numInts : 0))*sizeof(int);
 }
@@ -235,8 +281,10 @@
 
     buffer = reinterpret_cast<void*>(static_cast<int*>(buffer) + sizeNeeded);
     size -= sizeNeeded;
-    fds += handle->numFds;
-    count -= handle->numFds;
+    if (handle) {
+        fds += handle->numFds;
+        count -= handle->numFds;
+    }
 
     return NO_ERROR;
 }
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index a4cfce2..320b6c0 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -20,6 +20,8 @@
 #include <stdint.h>
 #include <errno.h>
 
+#include <sync/sync.h>
+
 #include <utils/Errors.h>
 #include <utils/Log.h>
 #include <utils/Trace.h>
@@ -109,5 +111,65 @@
     return err;
 }
 
+status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle,
+        int usage, const Rect& bounds, void** vaddr, int fenceFd)
+{
+    ATRACE_CALL();
+    status_t err;
+
+    if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
+        err = mAllocMod->lockAsync(mAllocMod, handle, usage,
+                bounds.left, bounds.top, bounds.width(), bounds.height(),
+                vaddr, fenceFd);
+    } else {
+        sync_wait(fenceFd, -1);
+        close(fenceFd);
+        err = mAllocMod->lock(mAllocMod, handle, usage,
+                bounds.left, bounds.top, bounds.width(), bounds.height(),
+                vaddr);
+    }
+
+    ALOGW_IF(err, "lockAsync(...) failed %d (%s)", err, strerror(-err));
+    return err;
+}
+
+status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
+        int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd)
+{
+    ATRACE_CALL();
+    status_t err;
+
+    if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
+        err = mAllocMod->lockAsync_ycbcr(mAllocMod, handle, usage,
+                bounds.left, bounds.top, bounds.width(), bounds.height(),
+                ycbcr, fenceFd);
+    } else {
+        sync_wait(fenceFd, -1);
+        close(fenceFd);
+        err = mAllocMod->lock_ycbcr(mAllocMod, handle, usage,
+                bounds.left, bounds.top, bounds.width(), bounds.height(),
+                ycbcr);
+    }
+
+    ALOGW_IF(err, "lock(...) failed %d (%s)", err, strerror(-err));
+    return err;
+}
+
+status_t GraphicBufferMapper::unlockAsync(buffer_handle_t handle, int *fenceFd)
+{
+    ATRACE_CALL();
+    status_t err;
+
+    if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
+        err = mAllocMod->unlockAsync(mAllocMod, handle, fenceFd);
+    } else {
+        *fenceFd = -1;
+        err = mAllocMod->unlock(mAllocMod, handle);
+    }
+
+    ALOGW_IF(err, "unlockAsync(...) failed %d (%s)", err, strerror(-err));
+    return err;
+}
+
 // ---------------------------------------------------------------------------
 }; // namespace android
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index e5abcf5..6d58f56 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -16,6 +16,7 @@
 
 #define LOG_TAG "Region"
 
+#include <inttypes.h>
 #include <limits.h>
 
 #include <utils/Log.h>
@@ -798,7 +799,7 @@
     size_t SIZE = 256;
     char buffer[SIZE];
 
-    snprintf(buffer, SIZE, "  Region %s (this=%p, count=%d)\n",
+    snprintf(buffer, SIZE, "  Region %s (this=%p, count=%" PRIdPTR ")\n",
             what, this, tail-head);
     out.append(buffer);
     while (head != tail) {
@@ -814,7 +815,7 @@
     (void)flags;
     const_iterator head = begin();
     const_iterator const tail = end();
-    ALOGD("  Region %s (this=%p, count=%d)\n", what, this, tail-head);
+    ALOGD("  Region %s (this=%p, count=%" PRIdPTR ")\n", what, this, tail-head);
     while (head != tail) {
         ALOGD("    [%3d, %3d, %3d, %3d]\n",
                 head->left, head->top, head->right, head->bottom);
diff --git a/libs/ui/tests/Android.mk b/libs/ui/tests/Android.mk
index 6f62a55..b0c57db 100644
--- a/libs/ui/tests/Android.mk
+++ b/libs/ui/tests/Android.mk
@@ -26,8 +26,6 @@
 )
 
 # Build the unit tests.
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
 
 # Build the manual test programs.
 include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 95a8ef2..64320cf 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -27,19 +27,14 @@
 LOCAL_CFLAGS += -fvisibility=hidden
 
 LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils liblog libpixelflinger libETC1 libui
-LOCAL_LDLIBS := -lpthread -ldl
 
-ifeq ($(TARGET_ARCH),arm)
-	LOCAL_SRC_FILES += fixed_asm.S iterators.S
-	LOCAL_CFLAGS += -fstrict-aliasing
-endif
+LOCAL_SRC_FILES_arm += fixed_asm.S iterators.S
+LOCAL_CFLAGS_arm += -fstrict-aliasing
 
-ifeq ($(TARGET_ARCH),mips)
-    LOCAL_SRC_FILES += arch-$(TARGET_ARCH)/fixed_asm.S
-    LOCAL_CFLAGS += -fstrict-aliasing
-    # The graphics code can generate division by zero
-    LOCAL_CFLAGS += -mno-check-zero-division
-endif
+LOCAL_SRC_FILES_mips += arch-mips/fixed_asm.S
+LOCAL_CFLAGS_mips += -fstrict-aliasing
+# The graphics code can generate division by zero
+LOCAL_CFLAGS_mips += -mno-check-zero-division
 
 # we need to access the private Bionic header <bionic_tls.h>
 LOCAL_C_INCLUDES += bionic/libc/private
diff --git a/opengl/libagl/BufferObjectManager.h b/opengl/libagl/BufferObjectManager.h
index 9e9340a..6487faa 100644
--- a/opengl/libagl/BufferObjectManager.h
+++ b/opengl/libagl/BufferObjectManager.h
@@ -69,10 +69,10 @@
     KeyedVector<GLuint, gl::buffer_t*>  mBuffers;
 };
 
-void EGLBufferObjectManager::incStrong(const void* id) const {
+void EGLBufferObjectManager::incStrong(const void* /*id*/) const {
     android_atomic_inc(&mCount);
 }
-void EGLBufferObjectManager::decStrong(const void* id) const {
+void EGLBufferObjectManager::decStrong(const void* /*id*/) const {
     if (android_atomic_dec(&mCount) == 1) {
         delete this;
     }
diff --git a/opengl/libagl/array.cpp b/opengl/libagl/array.cpp
index 7fbe9b5..54207fa 100644
--- a/opengl/libagl/array.cpp
+++ b/opengl/libagl/array.cpp
@@ -397,9 +397,9 @@
     }
 }
 
+#if VC_CACHE_STATISTICS
 void vertex_cache_t::dump_stats(GLenum mode)
 {
-#if VC_CACHE_STATISTICS
     nsecs_t time = systemTime(SYSTEM_TIME_THREAD) - startTime;
     uint32_t hits = total - misses;
     uint32_t prim_count;
@@ -418,8 +418,12 @@
             total, hits, misses, (hits*100)/total,
             prim_count, int(ns2us(time)), int(prim_count*float(seconds(1))/time),
             float(misses) / prim_count);
-#endif
 }
+#else
+void vertex_cache_t::dump_stats(GLenum /*mode*/)
+{
+}
+#endif
 
 // ----------------------------------------------------------------------------
 #if 0
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index f925e7d..1feac8b 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -206,7 +206,7 @@
     return EGL_BUFFER_PRESERVED;
 }
 EGLBoolean egl_surface_t::setSwapRectangle(
-        EGLint l, EGLint t, EGLint w, EGLint h)
+        EGLint /*l*/, EGLint /*t*/, EGLint /*w*/, EGLint /*h*/)
 {
     return EGL_FALSE;
 }
@@ -793,7 +793,7 @@
     static bool mask(GLint reqValue, GLint confValue) {
         return (confValue & reqValue) == reqValue;
     }
-    static bool ignore(GLint reqValue, GLint confValue) {
+    static bool ignore(GLint /*reqValue*/, GLint /*confValue*/) {
         return true;
     }
 };
@@ -1197,7 +1197,7 @@
     return 0;
 }
 
-static EGLBoolean getConfigAttrib(EGLDisplay dpy, EGLConfig config,
+static EGLBoolean getConfigAttrib(EGLDisplay /*dpy*/, EGLConfig config,
         EGLint attribute, EGLint *value)
 {
     size_t numConfigs =  NELEM(gConfigs);
@@ -1227,7 +1227,7 @@
 }
 
 static EGLSurface createWindowSurface(EGLDisplay dpy, EGLConfig config,
-        NativeWindowType window, const EGLint *attrib_list)
+        NativeWindowType window, const EGLint* /*attrib_list*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_NO_SURFACE);
@@ -1276,7 +1276,7 @@
 }
 
 static EGLSurface createPixmapSurface(EGLDisplay dpy, EGLConfig config,
-        NativePixmapType pixmap, const EGLint *attrib_list)
+        NativePixmapType pixmap, const EGLint* /*attrib_list*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_NO_SURFACE);
@@ -1655,7 +1655,7 @@
 }
 
 EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
-                            EGLContext share_list, const EGLint *attrib_list)
+                            EGLContext /*share_list*/, const EGLint* /*attrib_list*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_NO_SURFACE);
@@ -1853,7 +1853,7 @@
     return EGL_TRUE;
 }
 
-EGLBoolean eglWaitNative(EGLint engine)
+EGLBoolean eglWaitNative(EGLint /*engine*/)
 {
     return EGL_TRUE;
 }
@@ -1887,8 +1887,8 @@
     return EGL_TRUE;
 }
 
-EGLBoolean eglCopyBuffers(  EGLDisplay dpy, EGLSurface surface,
-                            NativePixmapType target)
+EGLBoolean eglCopyBuffers(  EGLDisplay dpy, EGLSurface /*surface*/,
+                            NativePixmapType /*target*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -1924,7 +1924,7 @@
 // ----------------------------------------------------------------------------
 
 EGLBoolean eglSurfaceAttrib(
-        EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+        EGLDisplay dpy, EGLSurface /*surface*/, EGLint /*attribute*/, EGLint /*value*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -1933,7 +1933,7 @@
 }
 
 EGLBoolean eglBindTexImage(
-        EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+        EGLDisplay dpy, EGLSurface /*surface*/, EGLint /*buffer*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -1942,7 +1942,7 @@
 }
 
 EGLBoolean eglReleaseTexImage(
-        EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+        EGLDisplay dpy, EGLSurface /*surface*/, EGLint /*buffer*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -1950,7 +1950,7 @@
     return setError(EGL_BAD_PARAMETER, EGL_FALSE);
 }
 
-EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint /*interval*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -1987,8 +1987,8 @@
 }
 
 EGLSurface eglCreatePbufferFromClientBuffer(
-          EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
-          EGLConfig config, const EGLint *attrib_list)
+          EGLDisplay dpy, EGLenum /*buftype*/, EGLClientBuffer /*buffer*/,
+          EGLConfig /*config*/, const EGLint* /*attrib_list*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_NO_SURFACE);
@@ -2011,21 +2011,21 @@
     return NULL;
 }
 
-EGLBoolean eglLockSurfaceKHR(EGLDisplay dpy, EGLSurface surface,
-        const EGLint *attrib_list)
+EGLBoolean eglLockSurfaceKHR(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
+        const EGLint* /*attrib_list*/)
 {
     EGLBoolean result = EGL_FALSE;
     return result;
 }
 
-EGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy, EGLSurface surface)
+EGLBoolean eglUnlockSurfaceKHR(EGLDisplay /*dpy*/, EGLSurface /*surface*/)
 {
     EGLBoolean result = EGL_FALSE;
     return result;
 }
 
 EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
-        EGLClientBuffer buffer, const EGLint *attrib_list)
+        EGLClientBuffer buffer, const EGLint* /*attrib_list*/)
 {
     if (egl_display_t::is_valid(dpy) == EGL_FALSE) {
         return setError(EGL_BAD_DISPLAY, EGL_NO_IMAGE_KHR);
@@ -2106,7 +2106,7 @@
     return FENCE_SYNC_HANDLE;
 }
 
-EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
+EGLBoolean eglDestroySyncKHR(EGLDisplay /*dpy*/, EGLSyncKHR sync)
 {
     if (sync != FENCE_SYNC_HANDLE) {
         return setError(EGL_BAD_PARAMETER, EGL_FALSE);
@@ -2115,8 +2115,8 @@
     return EGL_TRUE;
 }
 
-EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags,
-        EGLTimeKHR timeout)
+EGLint eglClientWaitSyncKHR(EGLDisplay /*dpy*/, EGLSyncKHR sync, EGLint /*flags*/,
+        EGLTimeKHR /*timeout*/)
 {
     if (sync != FENCE_SYNC_HANDLE) {
         return setError(EGL_BAD_PARAMETER, EGL_FALSE);
@@ -2125,7 +2125,7 @@
     return EGL_CONDITION_SATISFIED_KHR;
 }
 
-EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync,
+EGLBoolean eglGetSyncAttribKHR(EGLDisplay /*dpy*/, EGLSyncKHR sync,
         EGLint attribute, EGLint *value)
 {
     if (sync != FENCE_SYNC_HANDLE) {
diff --git a/opengl/libagl/fixed_asm.S b/opengl/libagl/fixed_asm.S
index 05044f2..5e08856 100644
--- a/opengl/libagl/fixed_asm.S
+++ b/opengl/libagl/fixed_asm.S
@@ -17,7 +17,7 @@
 
 
     .text
-    .align
+    .align 2
     
     .global gglFloatToFixed
     .type gglFloatToFixed, %function
diff --git a/opengl/libagl/iterators.S b/opengl/libagl/iterators.S
index 8c86482..8fe9039 100644
--- a/opengl/libagl/iterators.S
+++ b/opengl/libagl/iterators.S
@@ -17,7 +17,7 @@
 
 
     .text
-    .align
+    .align 2
     .arm
     
     .global iterators0032
diff --git a/opengl/libagl/light.cpp b/opengl/libagl/light.cpp
index fafec3f..479bf7e 100644
--- a/opengl/libagl/light.cpp
+++ b/opengl/libagl/light.cpp
@@ -105,7 +105,7 @@
     c->lighting.shadeModel = GL_SMOOTH;
 }
 
-void ogles_uninit_light(ogles_context_t* c)
+void ogles_uninit_light(ogles_context_t* /*c*/)
 {
 }
 
@@ -285,7 +285,7 @@
     invalidate_lighting(c);
 }
 
-void lightVertexNop(ogles_context_t*, vertex_t* v)
+void lightVertexNop(ogles_context_t*, vertex_t* /*v*/)
 {
     // we should never end-up here
 }
diff --git a/opengl/libagl/primitives.cpp b/opengl/libagl/primitives.cpp
index 769ec40..57a798d 100644
--- a/opengl/libagl/primitives.cpp
+++ b/opengl/libagl/primitives.cpp
@@ -94,7 +94,7 @@
 }
 
 static void lightTriangleDarkFlat(ogles_context_t* c,
-        vertex_t* v0, vertex_t* v1, vertex_t* v2)
+        vertex_t* /*v0*/, vertex_t* /*v1*/, vertex_t* v2)
 {
     if (!(v2->flags & vertex_t::LIT)) {
         v2->flags |= vertex_t::LIT;
@@ -118,7 +118,7 @@
 }
 
 static void lightTriangleFlat(ogles_context_t* c,
-        vertex_t* v0, vertex_t* v1, vertex_t* v2)
+        vertex_t* /*v0*/, vertex_t* /*v1*/, vertex_t* v2)
 {
     if (!(v2->flags & vertex_t::LIT))
         c->lighting.lightVertex(c, v2);
@@ -567,8 +567,8 @@
 #pragma mark Triangle
 #endif
 
-void primitive_nop_triangle(ogles_context_t* c,
-        vertex_t* v0, vertex_t* v1, vertex_t* v2) {
+void primitive_nop_triangle(ogles_context_t* /*c*/,
+        vertex_t* /*v0*/, vertex_t* /*v1*/, vertex_t* /*v2*/) {
 }
 
 void primitive_clip_triangle(ogles_context_t* c,
@@ -823,7 +823,7 @@
 
 
 static inline
-bool cull_triangle(ogles_context_t* c, vertex_t* v0, vertex_t* v1, vertex_t* v2)
+bool cull_triangle(ogles_context_t* c, vertex_t* /*v0*/, vertex_t* /*v1*/, vertex_t* /*v2*/)
 {
     if (ggl_likely(c->cull.enable)) {
         const GLenum winding = (c->lerp.area() > 0) ? GL_CW : GL_CCW;
diff --git a/opengl/libagl/state.cpp b/opengl/libagl/state.cpp
index 4bc653a..1d5def5 100644
--- a/opengl/libagl/state.cpp
+++ b/opengl/libagl/state.cpp
@@ -219,11 +219,11 @@
 #endif
 
 // These ones are super-easy, we're not supporting those features!
-void glSampleCoverage(GLclampf value, GLboolean invert) {
+void glSampleCoverage(GLclampf /*value*/, GLboolean /*invert*/) {
 }
-void glSampleCoveragex(GLclampx value, GLboolean invert) {
+void glSampleCoveragex(GLclampx /*value*/, GLboolean /*invert*/) {
 }
-void glStencilFunc(GLenum func, GLint ref, GLuint mask) {
+void glStencilFunc(GLenum func, GLint /*ref*/, GLuint /*mask*/) {
     ogles_context_t* c = ogles_context_t::get();
     if (func < GL_NEVER || func > GL_ALWAYS) {
         ogles_error(c, GL_INVALID_ENUM);
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index 08536df..9aa1c4f 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -1223,10 +1223,10 @@
 // ----------------------------------------------------------------------------
 
 void glCompressedTexSubImage2D(
-        GLenum target, GLint level, GLint xoffset,
-        GLint yoffset, GLsizei width, GLsizei height,
-        GLenum format, GLsizei imageSize,
-        const GLvoid *data)
+        GLenum /*target*/, GLint /*level*/, GLint /*xoffset*/,
+        GLint /*yoffset*/, GLsizei /*width*/, GLsizei /*height*/,
+        GLenum /*format*/, GLsizei /*imageSize*/,
+        const GLvoid* /*data*/)
 {
     ogles_context_t* c = ogles_context_t::get();
     ogles_error(c, GL_INVALID_ENUM);
diff --git a/opengl/libagl/vertex.cpp b/opengl/libagl/vertex.cpp
index dad04d6..9aacdb3 100644
--- a/opengl/libagl/vertex.cpp
+++ b/opengl/libagl/vertex.cpp
@@ -41,7 +41,7 @@
     c->currentNormal.z = 0x10000;
 }
 
-void ogles_uninit_vertex(ogles_context_t* c)
+void ogles_uninit_vertex(ogles_context_t* /*c*/)
 {
 }
 
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index 528b983..6b90243 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -33,7 +33,6 @@
 #
 
 LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libGLES_trace
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libEGL
 LOCAL_LDFLAGS += -Wl,--exclude-libs=ALL
 LOCAL_SHARED_LIBRARIES += libdl
@@ -79,7 +78,6 @@
 #
 
 LOCAL_SHARED_LIBRARIES += libcutils liblog libEGL
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libGLESv1_CM
 
 LOCAL_SHARED_LIBRARIES += libdl
@@ -104,7 +102,6 @@
 #
 
 LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libEGL
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libGLESv2
 
 LOCAL_SHARED_LIBRARIES += libdl
@@ -141,7 +138,6 @@
 	ETC1/etc1.cpp 	\
 #
 
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libETC1
 
 include $(BUILD_HOST_STATIC_LIBRARY)
@@ -156,7 +152,6 @@
 	ETC1/etc1.cpp 	\
 #
 
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libETC1
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 02914a0..1fcc048 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -187,8 +187,18 @@
 
     LOG_ALWAYS_FATAL_IF(!hnd, "couldn't find an OpenGL ES implementation");
 
+#if defined(__LP64__)
+    cnx->libEgl   = load_wrapper("/system/lib64/libEGL.so");
+    cnx->libGles2 = load_wrapper("/system/lib64/libGLESv2.so");
+    cnx->libGles1 = load_wrapper("/system/lib64/libGLESv1_CM.so");
+#else
+    cnx->libEgl   = load_wrapper("/system/lib/libEGL.so");
     cnx->libGles2 = load_wrapper("/system/lib/libGLESv2.so");
     cnx->libGles1 = load_wrapper("/system/lib/libGLESv1_CM.so");
+#endif
+    LOG_ALWAYS_FATAL_IF(!cnx->libEgl,
+            "couldn't load system EGL wrapper libraries");
+
     LOG_ALWAYS_FATAL_IF(!cnx->libGles2 || !cnx->libGles1,
             "couldn't load system OpenGL ES wrapper libraries");
 
@@ -268,8 +278,13 @@
             String8 pattern;
             pattern.appendFormat("lib%s", kind);
             const char* const searchPaths[] = {
+#if defined(__LP64__)
+                    "/vendor/lib64/egl",
+                    "/system/lib64/egl"
+#else
                     "/vendor/lib/egl",
                     "/system/lib/egl"
+#endif
             };
 
             // first, we search for the exact name of the GLES userspace
@@ -310,7 +325,11 @@
             if (checkGlesEmulationStatus() == 0) {
                 ALOGD("Emulator without GPU support detected. "
                       "Fallback to software renderer.");
+#if defined(__LP64__)
+                result.setTo("/system/lib64/egl/libGLES_android.so");
+#else
                 result.setTo("/system/lib/egl/libGLES_android.so");
+#endif
                 return true;
             }
 
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index d96b54f..22990f3 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -877,11 +877,14 @@
     return err;
 }
 
-static __eglMustCastToProperFunctionPointerType findBuiltinGLWrapper(
+static __eglMustCastToProperFunctionPointerType findBuiltinWrapper(
         const char* procname) {
     const egl_connection_t* cnx = &gEGLImpl;
     void* proc = NULL;
 
+    proc = dlsym(cnx->libEgl, procname);
+    if (proc) return (__eglMustCastToProperFunctionPointerType)proc;
+
     proc = dlsym(cnx->libGles2, procname);
     if (proc) return (__eglMustCastToProperFunctionPointerType)proc;
 
@@ -912,7 +915,7 @@
     addr = findProcAddress(procname, sExtensionMap, NELEM(sExtensionMap));
     if (addr) return addr;
 
-    addr = findBuiltinGLWrapper(procname);
+    addr = findBuiltinWrapper(procname);
     if (addr) return addr;
 
     // this protects accesses to sGLExtentionMap and sGLExtentionSlot
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 26240f1..7784ca6 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -313,7 +313,7 @@
 }
 
 EGLBoolean egl_display_t::makeCurrent(egl_context_t* c, egl_context_t* cur_c,
-        EGLSurface draw, EGLSurface read, EGLContext ctx,
+        EGLSurface draw, EGLSurface read, EGLContext /*ctx*/,
         EGLSurface impl_draw, EGLSurface impl_read, EGLContext impl_ctx)
 {
     EGLBoolean result;
diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h
index b905ea0..9858276 100644
--- a/opengl/libs/EGL/egldefs.h
+++ b/opengl/libs/EGL/egldefs.h
@@ -44,6 +44,7 @@
     EGLint              minor;
     egl_t               egl;
 
+    void*               libEgl;
     void*               libGles1;
     void*               libGles2;
 };
diff --git a/opengl/libs/EGL/getProcAddress.cpp b/opengl/libs/EGL/getProcAddress.cpp
index add2a79..fc61134 100644
--- a/opengl/libs/EGL/getProcAddress.cpp
+++ b/opengl/libs/EGL/getProcAddress.cpp
@@ -53,7 +53,71 @@
             : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
               [api] "J"(__builtin_offsetof(gl_hooks_t,          \
                                       ext.extensions[_api]))    \
-            :                                                   \
+            : "r12"                                             \
+            );
+
+#elif defined(__aarch64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_EXTENSION_API(_api)                             \
+        asm volatile(                                               \
+            "mrs x16, tpidr_el0\n"                                  \
+            "ldr x16, [x16, %[tls]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "ldr x16, [x16, %[api]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "br  x16\n"                                             \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)),      \
+              [api] "i" (__builtin_offsetof(gl_hooks_t,             \
+                                        ext.extensions[_api]))      \
+            : "x16"                                                 \
+        );
+
+#elif defined(__i386__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_EXTENSION_API(_api)                         \
+         register void** fn;                                    \
+         __asm__ volatile(                                      \
+            "mov %%gs:0, %[fn]\n"                               \
+            "mov %P[tls](%[fn]), %[fn]\n"                       \
+            "test %[fn], %[fn]\n"                               \
+            "cmovne %P[api](%[fn]), %[fn]\n"                    \
+            "test %[fn], %[fn]\n"                               \
+            "je 1f\n"                                           \
+            "jmp *%[fn]\n"                                      \
+            "1:\n"                                              \
+            : [fn] "=r" (fn)                                    \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),    \
+              [api] "i" (__builtin_offsetof(gl_hooks_t,         \
+                                      ext.extensions[_api]))    \
+            : "cc"                                              \
+            );
+
+#elif defined(__x86_64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_EXTENSION_API(_api)                         \
+         register void** fn;                                    \
+         __asm__ volatile(                                      \
+            "mov %%fs:0, %[fn]\n"                               \
+            "mov %P[tls](%[fn]), %[fn]\n"                       \
+            "test %[fn], %[fn]\n"                               \
+            "cmovne %P[api](%[fn]), %[fn]\n"                    \
+            "test %[fn], %[fn]\n"                               \
+            "je 1f\n"                                           \
+            "jmp *%[fn]\n"                                      \
+            "1:\n"                                              \
+            : [fn] "=r" (fn)                                    \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),    \
+              [api] "i" (__builtin_offsetof(gl_hooks_t,         \
+                                      ext.extensions[_api]))    \
+            : "cc"                                              \
             );
 
 #elif defined(__mips__)
@@ -86,6 +150,7 @@
                                           ext.extensions[_api]))    \
                 :                                                   \
             );
+
 #endif
 
 #if defined(CALL_GL_EXTENSION_API)
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp
index 3134e56..e112fec 100644
--- a/opengl/libs/GLES2/gl2.cpp
+++ b/opengl/libs/GLES2/gl2.cpp
@@ -40,7 +40,15 @@
 #undef CALL_GL_API
 #undef CALL_GL_API_RETURN
 
-#if defined(__arm__) && !USE_SLOW_BINDING
+#if USE_SLOW_BINDING
+
+    #define API_ENTRY(_api) _api
+
+    #define CALL_GL_API(_api, ...)                                       \
+        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
+        if (_c) return _c->_api(__VA_ARGS__);
+
+#elif defined(__arm__)
 
     #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
 
@@ -55,10 +63,66 @@
             :                                                   \
             : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
               [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \
-            :                                                   \
+            : "r12"                                             \
             );
 
-#elif defined(__mips__) && !USE_SLOW_BINDING
+#elif defined(__aarch64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_API(_api, ...)                                  \
+        asm volatile(                                               \
+            "mrs x16, tpidr_el0\n"                                  \
+            "ldr x16, [x16, %[tls]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "ldr x16, [x16, %[api]]\n"                              \
+            "br  x16\n"                                             \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)),      \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "x16"                                                 \
+        );
+
+#elif defined(__i386__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_API(_api, ...)                                  \
+        register void** fn;                                         \
+        __asm__ volatile(                                           \
+            "mov %%gs:0, %[fn]\n"                                   \
+            "mov %P[tls](%[fn]), %[fn]\n"                           \
+            "test %[fn], %[fn]\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%[fn])\n"                                 \
+            "1:\n"                                                  \
+            : [fn] "=r" (fn)                                        \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc"                                                  \
+            );
+
+#elif defined(__x86_64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_API(_api, ...)                                  \
+         register void** fn;                                        \
+         __asm__ volatile(                                          \
+            "mov %%fs:0, %[fn]\n"                                   \
+            "mov %P[tls](%[fn]), %[fn]\n"                           \
+            "test %[fn], %[fn]\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%[fn])\n"                                 \
+            "1:\n"                                                  \
+            : [fn] "=r" (fn)                                        \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc"                                                  \
+            );
+
+#elif defined(__mips__)
 
     #define API_ENTRY(_api) __attribute__((noinline)) _api
 
@@ -90,14 +154,6 @@
             :                                                    \
             );
 
-#else
-
-    #define API_ENTRY(_api) _api
-
-    #define CALL_GL_API(_api, ...)                                       \
-        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
-        if (_c) return _c->_api(__VA_ARGS__);
-
 #endif
 
 #define CALL_GL_API_RETURN(_api, ...) \
diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp
index 18ef6f9..71fbed1 100644
--- a/opengl/libs/GLES_CM/gl.cpp
+++ b/opengl/libs/GLES_CM/gl.cpp
@@ -53,34 +53,34 @@
 }
 
 void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count) {
+        const GLvoid *ptr, GLsizei /*count*/) {
     glColorPointer(size, type, stride, ptr);
 }
 void glNormalPointerBounds(GLenum type, GLsizei stride,
-        const GLvoid *pointer, GLsizei count) {
+        const GLvoid *pointer, GLsizei /*count*/) {
     glNormalPointer(type, stride, pointer);
 }
 void glTexCoordPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count) {
+        GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) {
     glTexCoordPointer(size, type, stride, pointer);
 }
 void glVertexPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count) {
+        GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) {
     glVertexPointer(size, type, stride, pointer);
 }
 
 void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count) {
+        GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) {
     glPointSizePointerOES(type, stride, pointer);
 }
 
 GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count) {
+        GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) {
     glMatrixIndexPointerOES(size, type, stride, pointer);
 }
 
 GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count) {
+        GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) {
     glWeightPointerOES(size, type, stride, pointer);
 }
 
@@ -92,7 +92,15 @@
 #undef CALL_GL_API
 #undef CALL_GL_API_RETURN
 
-#if defined(__arm__) && !USE_SLOW_BINDING
+#if USE_SLOW_BINDING
+
+    #define API_ENTRY(_api) _api
+
+    #define CALL_GL_API(_api, ...)                                       \
+        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
+        if (_c) return _c->_api(__VA_ARGS__);
+
+#elif defined(__arm__)
 
     #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
 
@@ -107,10 +115,66 @@
             :                                                   \
             : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
               [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \
-            :                                                   \
+            : "r12"                                             \
             );
 
-#elif defined(__mips__) && !USE_SLOW_BINDING
+#elif defined(__aarch64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_API(_api, ...)                                  \
+        asm volatile(                                               \
+            "mrs x16, tpidr_el0\n"                                  \
+            "ldr x16, [x16, %[tls]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "ldr x16, [x16, %[api]]\n"                              \
+            "br  x16\n"                                             \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)),      \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "x16"                                                 \
+        );
+
+#elif defined(__i386__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_API(_api, ...)                                  \
+        register void* fn;                                          \
+        __asm__ volatile(                                           \
+            "mov %%gs:0, %[fn]\n"                                   \
+            "mov %P[tls](%[fn]), %[fn]\n"                           \
+            "test %[fn], %[fn]\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%[fn])\n"                                 \
+            "1:\n"                                                  \
+            : [fn] "=r" (fn)                                        \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc"                                                  \
+            );
+
+#elif defined(__x86_64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_API(_api, ...)                                  \
+         register void** fn;                                        \
+         __asm__ volatile(                                          \
+            "mov %%fs:0, %[fn]\n"                                   \
+            "mov %P[tls](%[fn]), %[fn]\n"                           \
+            "test %[fn], %[fn]\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%[fn])\n"                                 \
+            "1:\n"                                                  \
+            : [fn] "=r" (fn)                                        \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc"                                                  \
+            );
+
+#elif defined(__mips__)
 
     #define API_ENTRY(_api) __attribute__((noinline)) _api
 
@@ -142,14 +206,6 @@
             :                                                    \
             );
 
-#else
-
-    #define API_ENTRY(_api) _api
-
-    #define CALL_GL_API(_api, ...)                                       \
-        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
-        if (_c) return _c->_api(__VA_ARGS__);
-
 #endif
 
 #define CALL_GL_API_RETURN(_api, ...) \
diff --git a/opengl/libs/GLES_trace/src/gltrace_api.cpp b/opengl/libs/GLES_trace/src/gltrace_api.cpp
index 2b1a702..e2cd0d8 100644
--- a/opengl/libs/GLES_trace/src/gltrace_api.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_api.cpp
@@ -113,8 +113,8 @@
     // copy argument name
     GLMessage_DataType *arg_name = glmsg.add_args();
     arg_name->set_isarray(false);
-    arg_name->set_type(GLMessage::DataType::INT);
-    arg_name->add_intvalue((int)name);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -478,8 +478,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // copy argument usage
     GLMessage_DataType *arg_usage = glmsg.add_args();
@@ -531,8 +531,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -842,8 +842,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -919,8 +919,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1188,8 +1188,8 @@
     // copy argument buffers
     GLMessage_DataType *arg_buffers = glmsg.add_args();
     arg_buffers->set_isarray(false);
-    arg_buffers->set_type(GLMessage::DataType::INT);
-    arg_buffers->add_intvalue((int)buffers);
+    arg_buffers->set_type(GLMessage::DataType::INT64);
+    arg_buffers->add_int64value((uintptr_t)buffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1223,8 +1223,8 @@
     // copy argument framebuffers
     GLMessage_DataType *arg_framebuffers = glmsg.add_args();
     arg_framebuffers->set_isarray(false);
-    arg_framebuffers->set_type(GLMessage::DataType::INT);
-    arg_framebuffers->add_intvalue((int)framebuffers);
+    arg_framebuffers->set_type(GLMessage::DataType::INT64);
+    arg_framebuffers->add_int64value((uintptr_t)framebuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1286,8 +1286,8 @@
     // copy argument renderbuffers
     GLMessage_DataType *arg_renderbuffers = glmsg.add_args();
     arg_renderbuffers->set_isarray(false);
-    arg_renderbuffers->set_type(GLMessage::DataType::INT);
-    arg_renderbuffers->add_intvalue((int)renderbuffers);
+    arg_renderbuffers->set_type(GLMessage::DataType::INT64);
+    arg_renderbuffers->add_int64value((uintptr_t)renderbuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1349,8 +1349,8 @@
     // copy argument textures
     GLMessage_DataType *arg_textures = glmsg.add_args();
     arg_textures->set_isarray(false);
-    arg_textures->set_type(GLMessage::DataType::INT);
-    arg_textures->add_intvalue((int)textures);
+    arg_textures->set_type(GLMessage::DataType::INT64);
+    arg_textures->add_int64value((uintptr_t)textures);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1616,8 +1616,8 @@
     // copy argument indices
     GLMessage_DataType *arg_indices = glmsg.add_args();
     arg_indices->set_isarray(false);
-    arg_indices->set_type(GLMessage::DataType::INT);
-    arg_indices->add_intvalue((int)indices);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1877,8 +1877,8 @@
     // copy argument buffers
     GLMessage_DataType *arg_buffers = glmsg.add_args();
     arg_buffers->set_isarray(false);
-    arg_buffers->set_type(GLMessage::DataType::INT);
-    arg_buffers->add_intvalue((int)buffers);
+    arg_buffers->set_type(GLMessage::DataType::INT64);
+    arg_buffers->add_int64value((uintptr_t)buffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1940,8 +1940,8 @@
     // copy argument framebuffers
     GLMessage_DataType *arg_framebuffers = glmsg.add_args();
     arg_framebuffers->set_isarray(false);
-    arg_framebuffers->set_type(GLMessage::DataType::INT);
-    arg_framebuffers->add_intvalue((int)framebuffers);
+    arg_framebuffers->set_type(GLMessage::DataType::INT64);
+    arg_framebuffers->add_int64value((uintptr_t)framebuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1975,8 +1975,8 @@
     // copy argument renderbuffers
     GLMessage_DataType *arg_renderbuffers = glmsg.add_args();
     arg_renderbuffers->set_isarray(false);
-    arg_renderbuffers->set_type(GLMessage::DataType::INT);
-    arg_renderbuffers->add_intvalue((int)renderbuffers);
+    arg_renderbuffers->set_type(GLMessage::DataType::INT64);
+    arg_renderbuffers->add_int64value((uintptr_t)renderbuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2010,8 +2010,8 @@
     // copy argument textures
     GLMessage_DataType *arg_textures = glmsg.add_args();
     arg_textures->set_isarray(false);
-    arg_textures->set_type(GLMessage::DataType::INT);
-    arg_textures->add_intvalue((int)textures);
+    arg_textures->set_type(GLMessage::DataType::INT64);
+    arg_textures->add_int64value((uintptr_t)textures);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2057,26 +2057,26 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument size
     GLMessage_DataType *arg_size = glmsg.add_args();
     arg_size->set_isarray(false);
-    arg_size->set_type(GLMessage::DataType::INT);
-    arg_size->add_intvalue((int)size);
+    arg_size->set_type(GLMessage::DataType::INT64);
+    arg_size->add_int64value((uintptr_t)size);
 
     // copy argument type
     GLMessage_DataType *arg_type = glmsg.add_args();
     arg_type->set_isarray(false);
-    arg_type->set_type(GLMessage::DataType::INT);
-    arg_type->add_intvalue((int)type);
+    arg_type->set_type(GLMessage::DataType::INT64);
+    arg_type->add_int64value((uintptr_t)type);
 
     // copy argument name
     GLMessage_DataType *arg_name = glmsg.add_args();
     arg_name->set_isarray(false);
-    arg_name->set_type(GLMessage::DataType::INT);
-    arg_name->add_intvalue((int)name);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2125,26 +2125,26 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument size
     GLMessage_DataType *arg_size = glmsg.add_args();
     arg_size->set_isarray(false);
-    arg_size->set_type(GLMessage::DataType::INT);
-    arg_size->add_intvalue((int)size);
+    arg_size->set_type(GLMessage::DataType::INT64);
+    arg_size->add_int64value((uintptr_t)size);
 
     // copy argument type
     GLMessage_DataType *arg_type = glmsg.add_args();
     arg_type->set_isarray(false);
-    arg_type->set_type(GLMessage::DataType::INT);
-    arg_type->add_intvalue((int)type);
+    arg_type->set_type(GLMessage::DataType::INT64);
+    arg_type->add_int64value((uintptr_t)type);
 
     // copy argument name
     GLMessage_DataType *arg_name = glmsg.add_args();
     arg_name->set_isarray(false);
-    arg_name->set_type(GLMessage::DataType::INT);
-    arg_name->add_intvalue((int)name);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2187,14 +2187,14 @@
     // copy argument count
     GLMessage_DataType *arg_count = glmsg.add_args();
     arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT);
-    arg_count->add_intvalue((int)count);
+    arg_count->set_type(GLMessage::DataType::INT64);
+    arg_count->add_int64value((uintptr_t)count);
 
     // copy argument shaders
     GLMessage_DataType *arg_shaders = glmsg.add_args();
     arg_shaders->set_isarray(false);
-    arg_shaders->set_type(GLMessage::DataType::INT);
-    arg_shaders->add_intvalue((int)shaders);
+    arg_shaders->set_type(GLMessage::DataType::INT64);
+    arg_shaders->add_int64value((uintptr_t)shaders);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2229,8 +2229,8 @@
     // copy argument name
     GLMessage_DataType *arg_name = glmsg.add_args();
     arg_name->set_isarray(false);
-    arg_name->set_type(GLMessage::DataType::INT);
-    arg_name->add_intvalue((int)name);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2272,8 +2272,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2313,8 +2313,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2378,8 +2378,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2425,8 +2425,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2460,8 +2460,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2501,8 +2501,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2542,14 +2542,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument infolog
     GLMessage_DataType *arg_infolog = glmsg.add_args();
     arg_infolog->set_isarray(false);
-    arg_infolog->set_type(GLMessage::DataType::INT);
-    arg_infolog->add_intvalue((int)infolog);
+    arg_infolog->set_type(GLMessage::DataType::INT64);
+    arg_infolog->add_int64value((uintptr_t)infolog);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2590,8 +2590,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2631,8 +2631,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2672,14 +2672,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument infolog
     GLMessage_DataType *arg_infolog = glmsg.add_args();
     arg_infolog->set_isarray(false);
-    arg_infolog->set_type(GLMessage::DataType::INT);
-    arg_infolog->add_intvalue((int)infolog);
+    arg_infolog->set_type(GLMessage::DataType::INT64);
+    arg_infolog->add_int64value((uintptr_t)infolog);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2720,14 +2720,14 @@
     // copy argument range
     GLMessage_DataType *arg_range = glmsg.add_args();
     arg_range->set_isarray(false);
-    arg_range->set_type(GLMessage::DataType::INT);
-    arg_range->add_intvalue((int)range);
+    arg_range->set_type(GLMessage::DataType::INT64);
+    arg_range->add_int64value((uintptr_t)range);
 
     // copy argument precision
     GLMessage_DataType *arg_precision = glmsg.add_args();
     arg_precision->set_isarray(false);
-    arg_precision->set_type(GLMessage::DataType::INT);
-    arg_precision->add_intvalue((int)precision);
+    arg_precision->set_type(GLMessage::DataType::INT64);
+    arg_precision->add_int64value((uintptr_t)precision);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2768,14 +2768,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument source
     GLMessage_DataType *arg_source = glmsg.add_args();
     arg_source->set_isarray(false);
-    arg_source->set_type(GLMessage::DataType::INT);
-    arg_source->add_intvalue((int)source);
+    arg_source->set_type(GLMessage::DataType::INT64);
+    arg_source->add_int64value((uintptr_t)source);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2817,8 +2817,8 @@
     // set return value
     GLMessage_DataType *rt = glmsg.mutable_returnvalue();
     rt->set_isarray(false);
-    rt->set_type(GLMessage::DataType::INT);
-    rt->add_intvalue((int)retValue);
+    rt->set_type(GLMessage::DataType::INT64);
+    rt->add_int64value((uintptr_t)retValue);
 
     void *pointerArgs[] = {
         (void *) retValue,
@@ -2853,8 +2853,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2894,8 +2894,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2935,8 +2935,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -2976,8 +2976,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -3011,8 +3011,8 @@
     // copy argument name
     GLMessage_DataType *arg_name = glmsg.add_args();
     arg_name->set_isarray(false);
-    arg_name->set_type(GLMessage::DataType::INT);
-    arg_name->add_intvalue((int)name);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -3060,8 +3060,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -3101,8 +3101,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -3142,8 +3142,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -3617,8 +3617,8 @@
     // copy argument pixels
     GLMessage_DataType *arg_pixels = glmsg.add_args();
     arg_pixels->set_isarray(false);
-    arg_pixels->set_type(GLMessage::DataType::INT);
-    arg_pixels->add_intvalue((int)pixels);
+    arg_pixels->set_type(GLMessage::DataType::INT64);
+    arg_pixels->add_int64value((uintptr_t)pixels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -3800,8 +3800,8 @@
     // copy argument shaders
     GLMessage_DataType *arg_shaders = glmsg.add_args();
     arg_shaders->set_isarray(false);
-    arg_shaders->set_type(GLMessage::DataType::INT);
-    arg_shaders->add_intvalue((int)shaders);
+    arg_shaders->set_type(GLMessage::DataType::INT64);
+    arg_shaders->add_int64value((uintptr_t)shaders);
 
     // copy argument binaryformat
     GLMessage_DataType *arg_binaryformat = glmsg.add_args();
@@ -3812,8 +3812,8 @@
     // copy argument binary
     GLMessage_DataType *arg_binary = glmsg.add_args();
     arg_binary->set_isarray(false);
-    arg_binary->set_type(GLMessage::DataType::INT);
-    arg_binary->add_intvalue((int)binary);
+    arg_binary->set_type(GLMessage::DataType::INT64);
+    arg_binary->add_int64value((uintptr_t)binary);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -3860,14 +3860,14 @@
     // copy argument string
     GLMessage_DataType *arg_string = glmsg.add_args();
     arg_string->set_isarray(false);
-    arg_string->set_type(GLMessage::DataType::INT);
-    arg_string->add_intvalue((int)string);
+    arg_string->set_type(GLMessage::DataType::INT64);
+    arg_string->add_int64value((uintptr_t)string);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4178,8 +4178,8 @@
     // copy argument pixels
     GLMessage_DataType *arg_pixels = glmsg.add_args();
     arg_pixels->set_isarray(false);
-    arg_pixels->set_type(GLMessage::DataType::INT);
-    arg_pixels->add_intvalue((int)pixels);
+    arg_pixels->set_type(GLMessage::DataType::INT64);
+    arg_pixels->add_int64value((uintptr_t)pixels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4259,8 +4259,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4340,8 +4340,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4417,8 +4417,8 @@
     // copy argument pixels
     GLMessage_DataType *arg_pixels = glmsg.add_args();
     arg_pixels->set_isarray(false);
-    arg_pixels->set_type(GLMessage::DataType::INT);
-    arg_pixels->add_intvalue((int)pixels);
+    arg_pixels->set_type(GLMessage::DataType::INT64);
+    arg_pixels->add_int64value((uintptr_t)pixels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4492,8 +4492,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4567,8 +4567,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4648,8 +4648,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4729,8 +4729,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4816,8 +4816,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4903,8 +4903,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -4996,8 +4996,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5089,8 +5089,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5136,8 +5136,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5183,8 +5183,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5230,8 +5230,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5355,8 +5355,8 @@
     // copy argument values
     GLMessage_DataType *arg_values = glmsg.add_args();
     arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT);
-    arg_values->add_intvalue((int)values);
+    arg_values->set_type(GLMessage::DataType::INT64);
+    arg_values->add_int64value((uintptr_t)values);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5430,8 +5430,8 @@
     // copy argument values
     GLMessage_DataType *arg_values = glmsg.add_args();
     arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT);
-    arg_values->add_intvalue((int)values);
+    arg_values->set_type(GLMessage::DataType::INT64);
+    arg_values->add_int64value((uintptr_t)values);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5511,8 +5511,8 @@
     // copy argument values
     GLMessage_DataType *arg_values = glmsg.add_args();
     arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT);
-    arg_values->add_intvalue((int)values);
+    arg_values->set_type(GLMessage::DataType::INT64);
+    arg_values->add_int64value((uintptr_t)values);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5598,8 +5598,8 @@
     // copy argument values
     GLMessage_DataType *arg_values = glmsg.add_args();
     arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT);
-    arg_values->add_intvalue((int)values);
+    arg_values->set_type(GLMessage::DataType::INT64);
+    arg_values->add_int64value((uintptr_t)values);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5657,8 +5657,8 @@
     // copy argument ptr
     GLMessage_DataType *arg_ptr = glmsg.add_args();
     arg_ptr->set_isarray(false);
-    arg_ptr->set_type(GLMessage::DataType::INT);
-    arg_ptr->add_intvalue((int)ptr);
+    arg_ptr->set_type(GLMessage::DataType::INT64);
+    arg_ptr->add_int64value((uintptr_t)ptr);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5790,8 +5790,8 @@
     // copy argument indices
     GLMessage_DataType *arg_indices = glmsg.add_args();
     arg_indices->set_isarray(false);
-    arg_indices->set_type(GLMessage::DataType::INT);
-    arg_indices->add_intvalue((int)indices);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5873,8 +5873,8 @@
     // copy argument pixels
     GLMessage_DataType *arg_pixels = glmsg.add_args();
     arg_pixels->set_isarray(false);
-    arg_pixels->set_type(GLMessage::DataType::INT);
-    arg_pixels->add_intvalue((int)pixels);
+    arg_pixels->set_type(GLMessage::DataType::INT64);
+    arg_pixels->add_int64value((uintptr_t)pixels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -5962,8 +5962,8 @@
     // copy argument pixels
     GLMessage_DataType *arg_pixels = glmsg.add_args();
     arg_pixels->set_isarray(false);
-    arg_pixels->set_type(GLMessage::DataType::INT);
-    arg_pixels->add_intvalue((int)pixels);
+    arg_pixels->set_type(GLMessage::DataType::INT64);
+    arg_pixels->add_int64value((uintptr_t)pixels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6115,8 +6115,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6204,8 +6204,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6239,8 +6239,8 @@
     // copy argument ids
     GLMessage_DataType *arg_ids = glmsg.add_args();
     arg_ids->set_isarray(false);
-    arg_ids->set_type(GLMessage::DataType::INT);
-    arg_ids->add_intvalue((int)ids);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6274,8 +6274,8 @@
     // copy argument ids
     GLMessage_DataType *arg_ids = glmsg.add_args();
     arg_ids->set_isarray(false);
-    arg_ids->set_type(GLMessage::DataType::INT);
-    arg_ids->add_intvalue((int)ids);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6413,8 +6413,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6454,8 +6454,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6531,8 +6531,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6566,8 +6566,8 @@
     // copy argument bufs
     GLMessage_DataType *arg_bufs = glmsg.add_args();
     arg_bufs->set_isarray(false);
-    arg_bufs->set_type(GLMessage::DataType::INT);
-    arg_bufs->add_intvalue((int)bufs);
+    arg_bufs->set_type(GLMessage::DataType::INT64);
+    arg_bufs->add_int64value((uintptr_t)bufs);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6613,8 +6613,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6660,8 +6660,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6707,8 +6707,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6754,8 +6754,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6801,8 +6801,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -6848,8 +6848,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7094,8 +7094,8 @@
     // set return value
     GLMessage_DataType *rt = glmsg.mutable_returnvalue();
     rt->set_isarray(false);
-    rt->set_type(GLMessage::DataType::INT);
-    rt->add_intvalue((int)retValue);
+    rt->set_type(GLMessage::DataType::INT64);
+    rt->add_int64value((uintptr_t)retValue);
 
     void *pointerArgs[] = {
         (void *) retValue,
@@ -7192,8 +7192,8 @@
     // copy argument arrays
     GLMessage_DataType *arg_arrays = glmsg.add_args();
     arg_arrays->set_isarray(false);
-    arg_arrays->set_type(GLMessage::DataType::INT);
-    arg_arrays->add_intvalue((int)arrays);
+    arg_arrays->set_type(GLMessage::DataType::INT64);
+    arg_arrays->add_int64value((uintptr_t)arrays);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7227,8 +7227,8 @@
     // copy argument arrays
     GLMessage_DataType *arg_arrays = glmsg.add_args();
     arg_arrays->set_isarray(false);
-    arg_arrays->set_type(GLMessage::DataType::INT);
-    arg_arrays->add_intvalue((int)arrays);
+    arg_arrays->set_type(GLMessage::DataType::INT64);
+    arg_arrays->add_int64value((uintptr_t)arrays);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7304,8 +7304,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7487,8 +7487,8 @@
     // copy argument varyings
     GLMessage_DataType *arg_varyings = glmsg.add_args();
     arg_varyings->set_isarray(false);
-    arg_varyings->set_type(GLMessage::DataType::INT);
-    arg_varyings->add_intvalue((int)varyings);
+    arg_varyings->set_type(GLMessage::DataType::INT64);
+    arg_varyings->add_int64value((uintptr_t)varyings);
 
     // copy argument bufferMode
     GLMessage_DataType *arg_bufferMode = glmsg.add_args();
@@ -7540,26 +7540,26 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument size
     GLMessage_DataType *arg_size = glmsg.add_args();
     arg_size->set_isarray(false);
-    arg_size->set_type(GLMessage::DataType::INT);
-    arg_size->add_intvalue((int)size);
+    arg_size->set_type(GLMessage::DataType::INT64);
+    arg_size->add_int64value((uintptr_t)size);
 
     // copy argument type
     GLMessage_DataType *arg_type = glmsg.add_args();
     arg_type->set_isarray(false);
-    arg_type->set_type(GLMessage::DataType::INT);
-    arg_type->add_intvalue((int)type);
+    arg_type->set_type(GLMessage::DataType::INT64);
+    arg_type->add_int64value((uintptr_t)type);
 
     // copy argument name
     GLMessage_DataType *arg_name = glmsg.add_args();
     arg_name->set_isarray(false);
-    arg_name->set_type(GLMessage::DataType::INT);
-    arg_name->add_intvalue((int)name);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7614,8 +7614,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7655,8 +7655,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7696,8 +7696,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7835,8 +7835,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7870,8 +7870,8 @@
     // copy argument v
     GLMessage_DataType *arg_v = glmsg.add_args();
     arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT);
-    arg_v->add_intvalue((int)v);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7911,8 +7911,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -7946,8 +7946,8 @@
     // copy argument name
     GLMessage_DataType *arg_name = glmsg.add_args();
     arg_name->set_isarray(false);
-    arg_name->set_type(GLMessage::DataType::INT);
-    arg_name->add_intvalue((int)name);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8167,8 +8167,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8208,8 +8208,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8249,8 +8249,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8290,8 +8290,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8331,8 +8331,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8372,8 +8372,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8413,8 +8413,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8507,8 +8507,8 @@
     // set return value
     GLMessage_DataType *rt = glmsg.mutable_returnvalue();
     rt->set_isarray(false);
-    rt->set_type(GLMessage::DataType::INT);
-    rt->add_intvalue((int)retValue);
+    rt->set_type(GLMessage::DataType::INT64);
+    rt->add_int64value((uintptr_t)retValue);
 
     void *pointerArgs[] = {
         (void *) retValue,
@@ -8595,14 +8595,14 @@
     // copy argument uniformNames
     GLMessage_DataType *arg_uniformNames = glmsg.add_args();
     arg_uniformNames->set_isarray(false);
-    arg_uniformNames->set_type(GLMessage::DataType::INT);
-    arg_uniformNames->add_intvalue((int)uniformNames);
+    arg_uniformNames->set_type(GLMessage::DataType::INT64);
+    arg_uniformNames->add_int64value((uintptr_t)uniformNames);
 
     // copy argument uniformIndices
     GLMessage_DataType *arg_uniformIndices = glmsg.add_args();
     arg_uniformIndices->set_isarray(false);
-    arg_uniformIndices->set_type(GLMessage::DataType::INT);
-    arg_uniformIndices->add_intvalue((int)uniformIndices);
+    arg_uniformIndices->set_type(GLMessage::DataType::INT64);
+    arg_uniformIndices->add_int64value((uintptr_t)uniformIndices);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8643,8 +8643,8 @@
     // copy argument uniformIndices
     GLMessage_DataType *arg_uniformIndices = glmsg.add_args();
     arg_uniformIndices->set_isarray(false);
-    arg_uniformIndices->set_type(GLMessage::DataType::INT);
-    arg_uniformIndices->add_intvalue((int)uniformIndices);
+    arg_uniformIndices->set_type(GLMessage::DataType::INT64);
+    arg_uniformIndices->add_int64value((uintptr_t)uniformIndices);
 
     // copy argument pname
     GLMessage_DataType *arg_pname = glmsg.add_args();
@@ -8655,8 +8655,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8691,8 +8691,8 @@
     // copy argument uniformBlockName
     GLMessage_DataType *arg_uniformBlockName = glmsg.add_args();
     arg_uniformBlockName->set_isarray(false);
-    arg_uniformBlockName->set_type(GLMessage::DataType::INT);
-    arg_uniformBlockName->add_intvalue((int)uniformBlockName);
+    arg_uniformBlockName->set_type(GLMessage::DataType::INT64);
+    arg_uniformBlockName->add_int64value((uintptr_t)uniformBlockName);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8746,8 +8746,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8793,14 +8793,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument uniformBlockName
     GLMessage_DataType *arg_uniformBlockName = glmsg.add_args();
     arg_uniformBlockName->set_isarray(false);
-    arg_uniformBlockName->set_type(GLMessage::DataType::INT);
-    arg_uniformBlockName->add_intvalue((int)uniformBlockName);
+    arg_uniformBlockName->set_type(GLMessage::DataType::INT64);
+    arg_uniformBlockName->add_int64value((uintptr_t)uniformBlockName);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -8933,8 +8933,8 @@
     // copy argument indices
     GLMessage_DataType *arg_indices = glmsg.add_args();
     arg_indices->set_isarray(false);
-    arg_indices->set_type(GLMessage::DataType::INT);
-    arg_indices->add_intvalue((int)indices);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
 
     // copy argument instanceCount
     GLMessage_DataType *arg_instanceCount = glmsg.add_args();
@@ -8987,8 +8987,8 @@
     // set return value
     GLMessage_DataType *rt = glmsg.mutable_returnvalue();
     rt->set_isarray(false);
-    rt->set_type(GLMessage::DataType::INT);
-    rt->add_intvalue((int)retValue);
+    rt->set_type(GLMessage::DataType::INT64);
+    rt->add_int64value((uintptr_t)retValue);
 
     void *pointerArgs[] = {
         (void *) retValue,
@@ -9011,8 +9011,8 @@
     // copy argument sync
     GLMessage_DataType *arg_sync = glmsg.add_args();
     arg_sync->set_isarray(false);
-    arg_sync->set_type(GLMessage::DataType::INT);
-    arg_sync->add_intvalue((int)sync);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9048,8 +9048,8 @@
     // copy argument sync
     GLMessage_DataType *arg_sync = glmsg.add_args();
     arg_sync->set_isarray(false);
-    arg_sync->set_type(GLMessage::DataType::INT);
-    arg_sync->add_intvalue((int)sync);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9077,8 +9077,8 @@
     // copy argument sync
     GLMessage_DataType *arg_sync = glmsg.add_args();
     arg_sync->set_isarray(false);
-    arg_sync->set_type(GLMessage::DataType::INT);
-    arg_sync->add_intvalue((int)sync);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
 
     // copy argument flags
     GLMessage_DataType *arg_flags = glmsg.add_args();
@@ -9126,8 +9126,8 @@
     // copy argument sync
     GLMessage_DataType *arg_sync = glmsg.add_args();
     arg_sync->set_isarray(false);
-    arg_sync->set_type(GLMessage::DataType::INT);
-    arg_sync->add_intvalue((int)sync);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
 
     // copy argument flags
     GLMessage_DataType *arg_flags = glmsg.add_args();
@@ -9173,8 +9173,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9202,8 +9202,8 @@
     // copy argument sync
     GLMessage_DataType *arg_sync = glmsg.add_args();
     arg_sync->set_isarray(false);
-    arg_sync->set_type(GLMessage::DataType::INT);
-    arg_sync->add_intvalue((int)sync);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
 
     // copy argument pname
     GLMessage_DataType *arg_pname = glmsg.add_args();
@@ -9220,14 +9220,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument values
     GLMessage_DataType *arg_values = glmsg.add_args();
     arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT);
-    arg_values->add_intvalue((int)values);
+    arg_values->set_type(GLMessage::DataType::INT64);
+    arg_values->add_int64value((uintptr_t)values);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9269,8 +9269,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9310,8 +9310,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9345,8 +9345,8 @@
     // copy argument samplers
     GLMessage_DataType *arg_samplers = glmsg.add_args();
     arg_samplers->set_isarray(false);
-    arg_samplers->set_type(GLMessage::DataType::INT);
-    arg_samplers->add_intvalue((int)samplers);
+    arg_samplers->set_type(GLMessage::DataType::INT64);
+    arg_samplers->add_int64value((uintptr_t)samplers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9380,8 +9380,8 @@
     // copy argument samplers
     GLMessage_DataType *arg_samplers = glmsg.add_args();
     arg_samplers->set_isarray(false);
-    arg_samplers->set_type(GLMessage::DataType::INT);
-    arg_samplers->add_intvalue((int)samplers);
+    arg_samplers->set_type(GLMessage::DataType::INT64);
+    arg_samplers->add_int64value((uintptr_t)samplers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9531,8 +9531,8 @@
     // copy argument param
     GLMessage_DataType *arg_param = glmsg.add_args();
     arg_param->set_isarray(false);
-    arg_param->set_type(GLMessage::DataType::INT);
-    arg_param->add_intvalue((int)param);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9612,8 +9612,8 @@
     // copy argument param
     GLMessage_DataType *arg_param = glmsg.add_args();
     arg_param->set_isarray(false);
-    arg_param->set_type(GLMessage::DataType::INT);
-    arg_param->add_intvalue((int)param);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9653,8 +9653,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9694,8 +9694,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9797,8 +9797,8 @@
     // copy argument ids
     GLMessage_DataType *arg_ids = glmsg.add_args();
     arg_ids->set_isarray(false);
-    arg_ids->set_type(GLMessage::DataType::INT);
-    arg_ids->add_intvalue((int)ids);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9832,8 +9832,8 @@
     // copy argument ids
     GLMessage_DataType *arg_ids = glmsg.add_args();
     arg_ids->set_isarray(false);
-    arg_ids->set_type(GLMessage::DataType::INT);
-    arg_ids->add_intvalue((int)ids);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -9953,20 +9953,20 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument binaryFormat
     GLMessage_DataType *arg_binaryFormat = glmsg.add_args();
     arg_binaryFormat->set_isarray(false);
-    arg_binaryFormat->set_type(GLMessage::DataType::INT);
-    arg_binaryFormat->add_intvalue((int)binaryFormat);
+    arg_binaryFormat->set_type(GLMessage::DataType::INT64);
+    arg_binaryFormat->add_int64value((uintptr_t)binaryFormat);
 
     // copy argument binary
     GLMessage_DataType *arg_binary = glmsg.add_args();
     arg_binary->set_isarray(false);
-    arg_binary->set_type(GLMessage::DataType::INT);
-    arg_binary->add_intvalue((int)binary);
+    arg_binary->set_type(GLMessage::DataType::INT64);
+    arg_binary->add_int64value((uintptr_t)binary);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10008,8 +10008,8 @@
     // copy argument binary
     GLMessage_DataType *arg_binary = glmsg.add_args();
     arg_binary->set_isarray(false);
-    arg_binary->set_type(GLMessage::DataType::INT);
-    arg_binary->add_intvalue((int)binary);
+    arg_binary->set_type(GLMessage::DataType::INT64);
+    arg_binary->add_int64value((uintptr_t)binary);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -10095,8 +10095,8 @@
     // copy argument attachments
     GLMessage_DataType *arg_attachments = glmsg.add_args();
     arg_attachments->set_isarray(false);
-    arg_attachments->set_type(GLMessage::DataType::INT);
-    arg_attachments->add_intvalue((int)attachments);
+    arg_attachments->set_type(GLMessage::DataType::INT64);
+    arg_attachments->add_int64value((uintptr_t)attachments);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10136,8 +10136,8 @@
     // copy argument attachments
     GLMessage_DataType *arg_attachments = glmsg.add_args();
     arg_attachments->set_isarray(false);
-    arg_attachments->set_type(GLMessage::DataType::INT);
-    arg_attachments->add_intvalue((int)attachments);
+    arg_attachments->set_type(GLMessage::DataType::INT64);
+    arg_attachments->add_int64value((uintptr_t)attachments);
 
     // copy argument x
     GLMessage_DataType *arg_x = glmsg.add_args();
@@ -10323,8 +10323,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10361,8 +10361,8 @@
     // copy argument image
     GLMessage_DataType *arg_image = glmsg.add_args();
     arg_image->set_isarray(false);
-    arg_image->set_type(GLMessage::DataType::INT);
-    arg_image->add_intvalue((int)image);
+    arg_image->set_type(GLMessage::DataType::INT64);
+    arg_image->add_int64value((uintptr_t)image);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10396,8 +10396,8 @@
     // copy argument image
     GLMessage_DataType *arg_image = glmsg.add_args();
     arg_image->set_isarray(false);
-    arg_image->set_type(GLMessage::DataType::INT);
-    arg_image->add_intvalue((int)image);
+    arg_image->set_type(GLMessage::DataType::INT64);
+    arg_image->add_int64value((uintptr_t)image);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10437,20 +10437,20 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument binaryFormat
     GLMessage_DataType *arg_binaryFormat = glmsg.add_args();
     arg_binaryFormat->set_isarray(false);
-    arg_binaryFormat->set_type(GLMessage::DataType::INT);
-    arg_binaryFormat->add_intvalue((int)binaryFormat);
+    arg_binaryFormat->set_type(GLMessage::DataType::INT64);
+    arg_binaryFormat->add_int64value((uintptr_t)binaryFormat);
 
     // copy argument binary
     GLMessage_DataType *arg_binary = glmsg.add_args();
     arg_binary->set_isarray(false);
-    arg_binary->set_type(GLMessage::DataType::INT);
-    arg_binary->add_intvalue((int)binary);
+    arg_binary->set_type(GLMessage::DataType::INT64);
+    arg_binary->add_int64value((uintptr_t)binary);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10492,8 +10492,8 @@
     // copy argument binary
     GLMessage_DataType *arg_binary = glmsg.add_args();
     arg_binary->set_isarray(false);
-    arg_binary->set_type(GLMessage::DataType::INT);
-    arg_binary->add_intvalue((int)binary);
+    arg_binary->set_type(GLMessage::DataType::INT64);
+    arg_binary->add_int64value((uintptr_t)binary);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -10546,8 +10546,8 @@
     // set return value
     GLMessage_DataType *rt = glmsg.mutable_returnvalue();
     rt->set_isarray(false);
-    rt->set_type(GLMessage::DataType::INT);
-    rt->add_intvalue((int)retValue);
+    rt->set_type(GLMessage::DataType::INT64);
+    rt->add_int64value((uintptr_t)retValue);
 
     void *pointerArgs[] = {
         (void *) retValue,
@@ -10618,8 +10618,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10701,8 +10701,8 @@
     // copy argument pixels
     GLMessage_DataType *arg_pixels = glmsg.add_args();
     arg_pixels->set_isarray(false);
-    arg_pixels->set_type(GLMessage::DataType::INT);
-    arg_pixels->add_intvalue((int)pixels);
+    arg_pixels->set_type(GLMessage::DataType::INT64);
+    arg_pixels->add_int64value((uintptr_t)pixels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10790,8 +10790,8 @@
     // copy argument pixels
     GLMessage_DataType *arg_pixels = glmsg.add_args();
     arg_pixels->set_isarray(false);
-    arg_pixels->set_type(GLMessage::DataType::INT);
-    arg_pixels->add_intvalue((int)pixels);
+    arg_pixels->set_type(GLMessage::DataType::INT64);
+    arg_pixels->add_int64value((uintptr_t)pixels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -10943,8 +10943,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11032,8 +11032,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11153,8 +11153,8 @@
     // copy argument arrays
     GLMessage_DataType *arg_arrays = glmsg.add_args();
     arg_arrays->set_isarray(false);
-    arg_arrays->set_type(GLMessage::DataType::INT);
-    arg_arrays->add_intvalue((int)arrays);
+    arg_arrays->set_type(GLMessage::DataType::INT64);
+    arg_arrays->add_int64value((uintptr_t)arrays);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11188,8 +11188,8 @@
     // copy argument arrays
     GLMessage_DataType *arg_arrays = glmsg.add_args();
     arg_arrays->set_isarray(false);
-    arg_arrays->set_type(GLMessage::DataType::INT);
-    arg_arrays->add_intvalue((int)arrays);
+    arg_arrays->set_type(GLMessage::DataType::INT64);
+    arg_arrays->add_int64value((uintptr_t)arrays);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11253,8 +11253,8 @@
     // copy argument numGroups
     GLMessage_DataType *arg_numGroups = glmsg.add_args();
     arg_numGroups->set_isarray(false);
-    arg_numGroups->set_type(GLMessage::DataType::INT);
-    arg_numGroups->add_intvalue((int)numGroups);
+    arg_numGroups->set_type(GLMessage::DataType::INT64);
+    arg_numGroups->add_int64value((uintptr_t)numGroups);
 
     // copy argument groupsSize
     GLMessage_DataType *arg_groupsSize = glmsg.add_args();
@@ -11265,8 +11265,8 @@
     // copy argument groups
     GLMessage_DataType *arg_groups = glmsg.add_args();
     arg_groups->set_isarray(false);
-    arg_groups->set_type(GLMessage::DataType::INT);
-    arg_groups->add_intvalue((int)groups);
+    arg_groups->set_type(GLMessage::DataType::INT64);
+    arg_groups->add_int64value((uintptr_t)groups);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11301,14 +11301,14 @@
     // copy argument numCounters
     GLMessage_DataType *arg_numCounters = glmsg.add_args();
     arg_numCounters->set_isarray(false);
-    arg_numCounters->set_type(GLMessage::DataType::INT);
-    arg_numCounters->add_intvalue((int)numCounters);
+    arg_numCounters->set_type(GLMessage::DataType::INT64);
+    arg_numCounters->add_int64value((uintptr_t)numCounters);
 
     // copy argument maxActiveCounters
     GLMessage_DataType *arg_maxActiveCounters = glmsg.add_args();
     arg_maxActiveCounters->set_isarray(false);
-    arg_maxActiveCounters->set_type(GLMessage::DataType::INT);
-    arg_maxActiveCounters->add_intvalue((int)maxActiveCounters);
+    arg_maxActiveCounters->set_type(GLMessage::DataType::INT64);
+    arg_maxActiveCounters->add_int64value((uintptr_t)maxActiveCounters);
 
     // copy argument counterSize
     GLMessage_DataType *arg_counterSize = glmsg.add_args();
@@ -11319,8 +11319,8 @@
     // copy argument counters
     GLMessage_DataType *arg_counters = glmsg.add_args();
     arg_counters->set_isarray(false);
-    arg_counters->set_type(GLMessage::DataType::INT);
-    arg_counters->add_intvalue((int)counters);
+    arg_counters->set_type(GLMessage::DataType::INT64);
+    arg_counters->add_int64value((uintptr_t)counters);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11362,14 +11362,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument groupString
     GLMessage_DataType *arg_groupString = glmsg.add_args();
     arg_groupString->set_isarray(false);
-    arg_groupString->set_type(GLMessage::DataType::INT);
-    arg_groupString->add_intvalue((int)groupString);
+    arg_groupString->set_type(GLMessage::DataType::INT64);
+    arg_groupString->add_int64value((uintptr_t)groupString);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11416,14 +11416,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument counterString
     GLMessage_DataType *arg_counterString = glmsg.add_args();
     arg_counterString->set_isarray(false);
-    arg_counterString->set_type(GLMessage::DataType::INT);
-    arg_counterString->add_intvalue((int)counterString);
+    arg_counterString->set_type(GLMessage::DataType::INT64);
+    arg_counterString->add_int64value((uintptr_t)counterString);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11470,8 +11470,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11505,8 +11505,8 @@
     // copy argument monitors
     GLMessage_DataType *arg_monitors = glmsg.add_args();
     arg_monitors->set_isarray(false);
-    arg_monitors->set_type(GLMessage::DataType::INT);
-    arg_monitors->add_intvalue((int)monitors);
+    arg_monitors->set_type(GLMessage::DataType::INT64);
+    arg_monitors->add_int64value((uintptr_t)monitors);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11540,8 +11540,8 @@
     // copy argument monitors
     GLMessage_DataType *arg_monitors = glmsg.add_args();
     arg_monitors->set_isarray(false);
-    arg_monitors->set_type(GLMessage::DataType::INT);
-    arg_monitors->add_intvalue((int)monitors);
+    arg_monitors->set_type(GLMessage::DataType::INT64);
+    arg_monitors->add_int64value((uintptr_t)monitors);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11593,8 +11593,8 @@
     // copy argument countersList
     GLMessage_DataType *arg_countersList = glmsg.add_args();
     arg_countersList->set_isarray(false);
-    arg_countersList->set_type(GLMessage::DataType::INT);
-    arg_countersList->add_intvalue((int)countersList);
+    arg_countersList->set_type(GLMessage::DataType::INT64);
+    arg_countersList->add_int64value((uintptr_t)countersList);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11696,14 +11696,14 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // copy argument bytesWritten
     GLMessage_DataType *arg_bytesWritten = glmsg.add_args();
     arg_bytesWritten->set_isarray(false);
-    arg_bytesWritten->set_type(GLMessage::DataType::INT);
-    arg_bytesWritten->add_intvalue((int)bytesWritten);
+    arg_bytesWritten->set_type(GLMessage::DataType::INT64);
+    arg_bytesWritten->add_int64value((uintptr_t)bytesWritten);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -11958,8 +11958,8 @@
     // copy argument label
     GLMessage_DataType *arg_label = glmsg.add_args();
     arg_label->set_isarray(false);
-    arg_label->set_type(GLMessage::DataType::INT);
-    arg_label->add_intvalue((int)label);
+    arg_label->set_type(GLMessage::DataType::INT64);
+    arg_label->add_int64value((uintptr_t)label);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12005,14 +12005,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument label
     GLMessage_DataType *arg_label = glmsg.add_args();
     arg_label->set_isarray(false);
-    arg_label->set_type(GLMessage::DataType::INT);
-    arg_label->add_intvalue((int)label);
+    arg_label->set_type(GLMessage::DataType::INT64);
+    arg_label->add_int64value((uintptr_t)label);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12047,8 +12047,8 @@
     // copy argument marker
     GLMessage_DataType *arg_marker = glmsg.add_args();
     arg_marker->set_isarray(false);
-    arg_marker->set_type(GLMessage::DataType::INT);
-    arg_marker->add_intvalue((int)marker);
+    arg_marker->set_type(GLMessage::DataType::INT64);
+    arg_marker->add_int64value((uintptr_t)marker);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12082,8 +12082,8 @@
     // copy argument marker
     GLMessage_DataType *arg_marker = glmsg.add_args();
     arg_marker->set_isarray(false);
-    arg_marker->set_type(GLMessage::DataType::INT);
-    arg_marker->add_intvalue((int)marker);
+    arg_marker->set_type(GLMessage::DataType::INT64);
+    arg_marker->add_int64value((uintptr_t)marker);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12145,8 +12145,8 @@
     // copy argument attachments
     GLMessage_DataType *arg_attachments = glmsg.add_args();
     arg_attachments->set_isarray(false);
-    arg_attachments->set_type(GLMessage::DataType::INT);
-    arg_attachments->add_intvalue((int)attachments);
+    arg_attachments->set_type(GLMessage::DataType::INT64);
+    arg_attachments->add_int64value((uintptr_t)attachments);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12290,14 +12290,14 @@
     // copy argument first
     GLMessage_DataType *arg_first = glmsg.add_args();
     arg_first->set_isarray(false);
-    arg_first->set_type(GLMessage::DataType::INT);
-    arg_first->add_intvalue((int)first);
+    arg_first->set_type(GLMessage::DataType::INT64);
+    arg_first->add_int64value((uintptr_t)first);
 
     // copy argument count
     GLMessage_DataType *arg_count = glmsg.add_args();
     arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT);
-    arg_count->add_intvalue((int)count);
+    arg_count->set_type(GLMessage::DataType::INT64);
+    arg_count->add_int64value((uintptr_t)count);
 
     // copy argument primcount
     GLMessage_DataType *arg_primcount = glmsg.add_args();
@@ -12338,8 +12338,8 @@
     // copy argument count
     GLMessage_DataType *arg_count = glmsg.add_args();
     arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT);
-    arg_count->add_intvalue((int)count);
+    arg_count->set_type(GLMessage::DataType::INT64);
+    arg_count->add_int64value((uintptr_t)count);
 
     // copy argument type
     GLMessage_DataType *arg_type = glmsg.add_args();
@@ -12350,8 +12350,8 @@
     // copy argument indices
     GLMessage_DataType *arg_indices = glmsg.add_args();
     arg_indices->set_isarray(false);
-    arg_indices->set_type(GLMessage::DataType::INT);
-    arg_indices->add_intvalue((int)indices);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
 
     // copy argument primcount
     GLMessage_DataType *arg_primcount = glmsg.add_args();
@@ -12392,8 +12392,8 @@
     // copy argument ids
     GLMessage_DataType *arg_ids = glmsg.add_args();
     arg_ids->set_isarray(false);
-    arg_ids->set_type(GLMessage::DataType::INT);
-    arg_ids->add_intvalue((int)ids);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12427,8 +12427,8 @@
     // copy argument ids
     GLMessage_DataType *arg_ids = glmsg.add_args();
     arg_ids->set_isarray(false);
-    arg_ids->set_type(GLMessage::DataType::INT);
-    arg_ids->add_intvalue((int)ids);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12566,8 +12566,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12607,8 +12607,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12708,8 +12708,8 @@
     // copy argument data
     GLMessage_DataType *arg_data = glmsg.add_args();
     arg_data->set_isarray(false);
-    arg_data->set_type(GLMessage::DataType::INT);
-    arg_data->add_intvalue((int)data);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12755,8 +12755,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12802,8 +12802,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12917,8 +12917,8 @@
     // copy argument strings
     GLMessage_DataType *arg_strings = glmsg.add_args();
     arg_strings->set_isarray(false);
-    arg_strings->set_type(GLMessage::DataType::INT);
-    arg_strings->add_intvalue((int)strings);
+    arg_strings->set_type(GLMessage::DataType::INT64);
+    arg_strings->add_int64value((uintptr_t)strings);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -12988,8 +12988,8 @@
     // copy argument pipelines
     GLMessage_DataType *arg_pipelines = glmsg.add_args();
     arg_pipelines->set_isarray(false);
-    arg_pipelines->set_type(GLMessage::DataType::INT);
-    arg_pipelines->add_intvalue((int)pipelines);
+    arg_pipelines->set_type(GLMessage::DataType::INT64);
+    arg_pipelines->add_int64value((uintptr_t)pipelines);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13023,8 +13023,8 @@
     // copy argument pipelines
     GLMessage_DataType *arg_pipelines = glmsg.add_args();
     arg_pipelines->set_isarray(false);
-    arg_pipelines->set_type(GLMessage::DataType::INT);
-    arg_pipelines->add_intvalue((int)pipelines);
+    arg_pipelines->set_type(GLMessage::DataType::INT64);
+    arg_pipelines->add_int64value((uintptr_t)pipelines);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13140,8 +13140,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13579,8 +13579,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13626,8 +13626,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13673,8 +13673,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13720,8 +13720,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13767,8 +13767,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13814,8 +13814,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13861,8 +13861,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13908,8 +13908,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -13961,8 +13961,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -14014,8 +14014,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -14067,8 +14067,8 @@
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
     arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT);
-    arg_value->add_intvalue((int)value);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -14136,14 +14136,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument infoLog
     GLMessage_DataType *arg_infoLog = glmsg.add_args();
     arg_infoLog->set_isarray(false);
-    arg_infoLog->set_type(GLMessage::DataType::INT);
-    arg_infoLog->add_intvalue((int)infoLog);
+    arg_infoLog->set_type(GLMessage::DataType::INT64);
+    arg_infoLog->add_int64value((uintptr_t)infoLog);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -14674,8 +14674,8 @@
     // copy argument bufs
     GLMessage_DataType *arg_bufs = glmsg.add_args();
     arg_bufs->set_isarray(false);
-    arg_bufs->set_type(GLMessage::DataType::INT);
-    arg_bufs->add_intvalue((int)bufs);
+    arg_bufs->set_type(GLMessage::DataType::INT64);
+    arg_bufs->add_int64value((uintptr_t)bufs);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -14709,8 +14709,8 @@
     // copy argument fences
     GLMessage_DataType *arg_fences = glmsg.add_args();
     arg_fences->set_isarray(false);
-    arg_fences->set_type(GLMessage::DataType::INT);
-    arg_fences->add_intvalue((int)fences);
+    arg_fences->set_type(GLMessage::DataType::INT64);
+    arg_fences->add_int64value((uintptr_t)fences);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -14744,8 +14744,8 @@
     // copy argument fences
     GLMessage_DataType *arg_fences = glmsg.add_args();
     arg_fences->set_isarray(false);
-    arg_fences->set_type(GLMessage::DataType::INT);
-    arg_fences->add_intvalue((int)fences);
+    arg_fences->set_type(GLMessage::DataType::INT64);
+    arg_fences->add_int64value((uintptr_t)fences);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -14857,8 +14857,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15010,8 +15010,8 @@
     // copy argument num
     GLMessage_DataType *arg_num = glmsg.add_args();
     arg_num->set_isarray(false);
-    arg_num->set_type(GLMessage::DataType::INT);
-    arg_num->add_intvalue((int)num);
+    arg_num->set_type(GLMessage::DataType::INT64);
+    arg_num->add_int64value((uintptr_t)num);
 
     // copy argument size
     GLMessage_DataType *arg_size = glmsg.add_args();
@@ -15022,8 +15022,8 @@
     // copy argument driverControls
     GLMessage_DataType *arg_driverControls = glmsg.add_args();
     arg_driverControls->set_isarray(false);
-    arg_driverControls->set_type(GLMessage::DataType::INT);
-    arg_driverControls->add_intvalue((int)driverControls);
+    arg_driverControls->set_type(GLMessage::DataType::INT64);
+    arg_driverControls->add_int64value((uintptr_t)driverControls);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15064,14 +15064,14 @@
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // copy argument driverControlString
     GLMessage_DataType *arg_driverControlString = glmsg.add_args();
     arg_driverControlString->set_isarray(false);
-    arg_driverControlString->set_type(GLMessage::DataType::INT);
-    arg_driverControlString->add_intvalue((int)driverControlString);
+    arg_driverControlString->set_type(GLMessage::DataType::INT64);
+    arg_driverControlString->add_int64value((uintptr_t)driverControlString);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15156,8 +15156,8 @@
     // copy argument textures
     GLMessage_DataType *arg_textures = glmsg.add_args();
     arg_textures->set_isarray(false);
-    arg_textures->set_type(GLMessage::DataType::INT);
-    arg_textures->add_intvalue((int)textures);
+    arg_textures->set_type(GLMessage::DataType::INT64);
+    arg_textures->add_int64value((uintptr_t)textures);
 
     // copy argument maxTextures
     GLMessage_DataType *arg_maxTextures = glmsg.add_args();
@@ -15168,8 +15168,8 @@
     // copy argument numTextures
     GLMessage_DataType *arg_numTextures = glmsg.add_args();
     arg_numTextures->set_isarray(false);
-    arg_numTextures->set_type(GLMessage::DataType::INT);
-    arg_numTextures->add_intvalue((int)numTextures);
+    arg_numTextures->set_type(GLMessage::DataType::INT64);
+    arg_numTextures->add_int64value((uintptr_t)numTextures);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15198,8 +15198,8 @@
     // copy argument buffers
     GLMessage_DataType *arg_buffers = glmsg.add_args();
     arg_buffers->set_isarray(false);
-    arg_buffers->set_type(GLMessage::DataType::INT);
-    arg_buffers->add_intvalue((int)buffers);
+    arg_buffers->set_type(GLMessage::DataType::INT64);
+    arg_buffers->add_int64value((uintptr_t)buffers);
 
     // copy argument maxBuffers
     GLMessage_DataType *arg_maxBuffers = glmsg.add_args();
@@ -15210,8 +15210,8 @@
     // copy argument numBuffers
     GLMessage_DataType *arg_numBuffers = glmsg.add_args();
     arg_numBuffers->set_isarray(false);
-    arg_numBuffers->set_type(GLMessage::DataType::INT);
-    arg_numBuffers->add_intvalue((int)numBuffers);
+    arg_numBuffers->set_type(GLMessage::DataType::INT64);
+    arg_numBuffers->add_int64value((uintptr_t)numBuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15240,8 +15240,8 @@
     // copy argument renderbuffers
     GLMessage_DataType *arg_renderbuffers = glmsg.add_args();
     arg_renderbuffers->set_isarray(false);
-    arg_renderbuffers->set_type(GLMessage::DataType::INT);
-    arg_renderbuffers->add_intvalue((int)renderbuffers);
+    arg_renderbuffers->set_type(GLMessage::DataType::INT64);
+    arg_renderbuffers->add_int64value((uintptr_t)renderbuffers);
 
     // copy argument maxRenderbuffers
     GLMessage_DataType *arg_maxRenderbuffers = glmsg.add_args();
@@ -15252,8 +15252,8 @@
     // copy argument numRenderbuffers
     GLMessage_DataType *arg_numRenderbuffers = glmsg.add_args();
     arg_numRenderbuffers->set_isarray(false);
-    arg_numRenderbuffers->set_type(GLMessage::DataType::INT);
-    arg_numRenderbuffers->add_intvalue((int)numRenderbuffers);
+    arg_numRenderbuffers->set_type(GLMessage::DataType::INT64);
+    arg_numRenderbuffers->add_int64value((uintptr_t)numRenderbuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15282,8 +15282,8 @@
     // copy argument framebuffers
     GLMessage_DataType *arg_framebuffers = glmsg.add_args();
     arg_framebuffers->set_isarray(false);
-    arg_framebuffers->set_type(GLMessage::DataType::INT);
-    arg_framebuffers->add_intvalue((int)framebuffers);
+    arg_framebuffers->set_type(GLMessage::DataType::INT64);
+    arg_framebuffers->add_int64value((uintptr_t)framebuffers);
 
     // copy argument maxFramebuffers
     GLMessage_DataType *arg_maxFramebuffers = glmsg.add_args();
@@ -15294,8 +15294,8 @@
     // copy argument numFramebuffers
     GLMessage_DataType *arg_numFramebuffers = glmsg.add_args();
     arg_numFramebuffers->set_isarray(false);
-    arg_numFramebuffers->set_type(GLMessage::DataType::INT);
-    arg_numFramebuffers->add_intvalue((int)numFramebuffers);
+    arg_numFramebuffers->set_type(GLMessage::DataType::INT64);
+    arg_numFramebuffers->add_int64value((uintptr_t)numFramebuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15348,8 +15348,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15477,8 +15477,8 @@
     // copy argument texels
     GLMessage_DataType *arg_texels = glmsg.add_args();
     arg_texels->set_isarray(false);
-    arg_texels->set_type(GLMessage::DataType::INT);
-    arg_texels->add_intvalue((int)texels);
+    arg_texels->set_type(GLMessage::DataType::INT64);
+    arg_texels->add_int64value((uintptr_t)texels);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15512,8 +15512,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15541,8 +15541,8 @@
     // copy argument shaders
     GLMessage_DataType *arg_shaders = glmsg.add_args();
     arg_shaders->set_isarray(false);
-    arg_shaders->set_type(GLMessage::DataType::INT);
-    arg_shaders->add_intvalue((int)shaders);
+    arg_shaders->set_type(GLMessage::DataType::INT64);
+    arg_shaders->add_int64value((uintptr_t)shaders);
 
     // copy argument maxShaders
     GLMessage_DataType *arg_maxShaders = glmsg.add_args();
@@ -15553,8 +15553,8 @@
     // copy argument numShaders
     GLMessage_DataType *arg_numShaders = glmsg.add_args();
     arg_numShaders->set_isarray(false);
-    arg_numShaders->set_type(GLMessage::DataType::INT);
-    arg_numShaders->add_intvalue((int)numShaders);
+    arg_numShaders->set_type(GLMessage::DataType::INT64);
+    arg_numShaders->add_int64value((uintptr_t)numShaders);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15583,8 +15583,8 @@
     // copy argument programs
     GLMessage_DataType *arg_programs = glmsg.add_args();
     arg_programs->set_isarray(false);
-    arg_programs->set_type(GLMessage::DataType::INT);
-    arg_programs->add_intvalue((int)programs);
+    arg_programs->set_type(GLMessage::DataType::INT64);
+    arg_programs->add_int64value((uintptr_t)programs);
 
     // copy argument maxPrograms
     GLMessage_DataType *arg_maxPrograms = glmsg.add_args();
@@ -15595,8 +15595,8 @@
     // copy argument numPrograms
     GLMessage_DataType *arg_numPrograms = glmsg.add_args();
     arg_numPrograms->set_isarray(false);
-    arg_numPrograms->set_type(GLMessage::DataType::INT);
-    arg_numPrograms->add_intvalue((int)numPrograms);
+    arg_numPrograms->set_type(GLMessage::DataType::INT64);
+    arg_numPrograms->add_int64value((uintptr_t)numPrograms);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15673,14 +15673,14 @@
     // copy argument source
     GLMessage_DataType *arg_source = glmsg.add_args();
     arg_source->set_isarray(false);
-    arg_source->set_type(GLMessage::DataType::INT);
-    arg_source->add_intvalue((int)source);
+    arg_source->set_type(GLMessage::DataType::INT64);
+    arg_source->add_int64value((uintptr_t)source);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
     arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT);
-    arg_length->add_intvalue((int)length);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15832,8 +15832,8 @@
     // copy argument equation
     GLMessage_DataType *arg_equation = glmsg.add_args();
     arg_equation->set_isarray(false);
-    arg_equation->set_type(GLMessage::DataType::INT);
-    arg_equation->add_intvalue((int)equation);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -15947,8 +15947,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16040,8 +16040,8 @@
     // copy argument eqn
     GLMessage_DataType *arg_eqn = glmsg.add_args();
     arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT);
-    arg_eqn->add_intvalue((int)eqn);
+    arg_eqn->set_type(GLMessage::DataType::INT64);
+    arg_eqn->add_int64value((uintptr_t)eqn);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16081,8 +16081,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16122,8 +16122,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16163,8 +16163,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16232,8 +16232,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16313,8 +16313,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16342,8 +16342,8 @@
     // copy argument m
     GLMessage_DataType *arg_m = glmsg.add_args();
     arg_m->set_isarray(false);
-    arg_m->set_type(GLMessage::DataType::INT);
-    arg_m->add_intvalue((int)m);
+    arg_m->set_type(GLMessage::DataType::INT64);
+    arg_m->add_int64value((uintptr_t)m);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16423,8 +16423,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16452,8 +16452,8 @@
     // copy argument m
     GLMessage_DataType *arg_m = glmsg.add_args();
     arg_m->set_isarray(false);
-    arg_m->set_type(GLMessage::DataType::INT);
-    arg_m->add_intvalue((int)m);
+    arg_m->set_type(GLMessage::DataType::INT64);
+    arg_m->add_int64value((uintptr_t)m);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16671,8 +16671,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -16866,8 +16866,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17077,8 +17077,8 @@
     // copy argument equation
     GLMessage_DataType *arg_equation = glmsg.add_args();
     arg_equation->set_isarray(false);
-    arg_equation->set_type(GLMessage::DataType::INT);
-    arg_equation->add_intvalue((int)equation);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17216,8 +17216,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17375,8 +17375,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17468,8 +17468,8 @@
     // copy argument eqn
     GLMessage_DataType *arg_eqn = glmsg.add_args();
     arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT);
-    arg_eqn->add_intvalue((int)eqn);
+    arg_eqn->set_type(GLMessage::DataType::INT64);
+    arg_eqn->add_int64value((uintptr_t)eqn);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17503,8 +17503,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17544,8 +17544,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17585,8 +17585,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17620,8 +17620,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17661,8 +17661,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17702,8 +17702,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17743,8 +17743,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17812,8 +17812,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17893,8 +17893,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -17972,8 +17972,8 @@
     // copy argument m
     GLMessage_DataType *arg_m = glmsg.add_args();
     arg_m->set_isarray(false);
-    arg_m->set_type(GLMessage::DataType::INT);
-    arg_m->add_intvalue((int)m);
+    arg_m->set_type(GLMessage::DataType::INT64);
+    arg_m->add_int64value((uintptr_t)m);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18081,8 +18081,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18138,8 +18138,8 @@
     // copy argument m
     GLMessage_DataType *arg_m = glmsg.add_args();
     arg_m->set_isarray(false);
-    arg_m->set_type(GLMessage::DataType::INT);
-    arg_m->add_intvalue((int)m);
+    arg_m->set_type(GLMessage::DataType::INT64);
+    arg_m->add_int64value((uintptr_t)m);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18271,8 +18271,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18398,8 +18398,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18699,8 +18699,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18820,8 +18820,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18861,8 +18861,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -18942,8 +18942,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19029,8 +19029,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19070,8 +19070,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19366,8 +19366,8 @@
     // copy argument coords
     GLMessage_DataType *arg_coords = glmsg.add_args();
     arg_coords->set_isarray(false);
-    arg_coords->set_type(GLMessage::DataType::INT);
-    arg_coords->add_intvalue((int)coords);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19395,8 +19395,8 @@
     // copy argument coords
     GLMessage_DataType *arg_coords = glmsg.add_args();
     arg_coords->set_isarray(false);
-    arg_coords->set_type(GLMessage::DataType::INT);
-    arg_coords->add_intvalue((int)coords);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19424,8 +19424,8 @@
     // copy argument coords
     GLMessage_DataType *arg_coords = glmsg.add_args();
     arg_coords->set_isarray(false);
-    arg_coords->set_type(GLMessage::DataType::INT);
-    arg_coords->add_intvalue((int)coords);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19505,8 +19505,8 @@
     // copy argument coords
     GLMessage_DataType *arg_coords = glmsg.add_args();
     arg_coords->set_isarray(false);
-    arg_coords->set_type(GLMessage::DataType::INT);
-    arg_coords->add_intvalue((int)coords);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19648,8 +19648,8 @@
     // copy argument equation
     GLMessage_DataType *arg_equation = glmsg.add_args();
     arg_equation->set_isarray(false);
-    arg_equation->set_type(GLMessage::DataType::INT);
-    arg_equation->add_intvalue((int)equation);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19797,8 +19797,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19890,8 +19890,8 @@
     // copy argument eqn
     GLMessage_DataType *arg_eqn = glmsg.add_args();
     arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT);
-    arg_eqn->add_intvalue((int)eqn);
+    arg_eqn->set_type(GLMessage::DataType::INT64);
+    arg_eqn->add_int64value((uintptr_t)eqn);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19925,8 +19925,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -19966,8 +19966,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20007,8 +20007,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20048,8 +20048,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20089,8 +20089,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20158,8 +20158,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20239,8 +20239,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20296,8 +20296,8 @@
     // copy argument m
     GLMessage_DataType *arg_m = glmsg.add_args();
     arg_m->set_isarray(false);
-    arg_m->set_type(GLMessage::DataType::INT);
-    arg_m->add_intvalue((int)m);
+    arg_m->set_type(GLMessage::DataType::INT64);
+    arg_m->add_int64value((uintptr_t)m);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20377,8 +20377,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20406,8 +20406,8 @@
     // copy argument m
     GLMessage_DataType *arg_m = glmsg.add_args();
     arg_m->set_isarray(false);
-    arg_m->set_type(GLMessage::DataType::INT);
-    arg_m->add_intvalue((int)m);
+    arg_m->set_type(GLMessage::DataType::INT64);
+    arg_m->add_int64value((uintptr_t)m);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20625,8 +20625,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20888,8 +20888,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -20969,8 +20969,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21114,8 +21114,8 @@
     // copy argument renderbuffers
     GLMessage_DataType *arg_renderbuffers = glmsg.add_args();
     arg_renderbuffers->set_isarray(false);
-    arg_renderbuffers->set_type(GLMessage::DataType::INT);
-    arg_renderbuffers->add_intvalue((int)renderbuffers);
+    arg_renderbuffers->set_type(GLMessage::DataType::INT64);
+    arg_renderbuffers->add_int64value((uintptr_t)renderbuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21149,8 +21149,8 @@
     // copy argument renderbuffers
     GLMessage_DataType *arg_renderbuffers = glmsg.add_args();
     arg_renderbuffers->set_isarray(false);
-    arg_renderbuffers->set_type(GLMessage::DataType::INT);
-    arg_renderbuffers->add_intvalue((int)renderbuffers);
+    arg_renderbuffers->set_type(GLMessage::DataType::INT64);
+    arg_renderbuffers->add_int64value((uintptr_t)renderbuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21236,8 +21236,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21341,8 +21341,8 @@
     // copy argument framebuffers
     GLMessage_DataType *arg_framebuffers = glmsg.add_args();
     arg_framebuffers->set_isarray(false);
-    arg_framebuffers->set_type(GLMessage::DataType::INT);
-    arg_framebuffers->add_intvalue((int)framebuffers);
+    arg_framebuffers->set_type(GLMessage::DataType::INT64);
+    arg_framebuffers->add_int64value((uintptr_t)framebuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21376,8 +21376,8 @@
     // copy argument framebuffers
     GLMessage_DataType *arg_framebuffers = glmsg.add_args();
     arg_framebuffers->set_isarray(false);
-    arg_framebuffers->set_type(GLMessage::DataType::INT);
-    arg_framebuffers->add_intvalue((int)framebuffers);
+    arg_framebuffers->set_type(GLMessage::DataType::INT64);
+    arg_framebuffers->add_int64value((uintptr_t)framebuffers);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21557,8 +21557,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21682,8 +21682,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21729,8 +21729,8 @@
     // copy argument pointer
     GLMessage_DataType *arg_pointer = glmsg.add_args();
     arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT);
-    arg_pointer->add_intvalue((int)pointer);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21758,14 +21758,14 @@
     // copy argument mantissa
     GLMessage_DataType *arg_mantissa = glmsg.add_args();
     arg_mantissa->set_isarray(false);
-    arg_mantissa->set_type(GLMessage::DataType::INT);
-    arg_mantissa->add_intvalue((int)mantissa);
+    arg_mantissa->set_type(GLMessage::DataType::INT64);
+    arg_mantissa->add_int64value((uintptr_t)mantissa);
 
     // copy argument exponent
     GLMessage_DataType *arg_exponent = glmsg.add_args();
     arg_exponent->set_isarray(false);
-    arg_exponent->set_type(GLMessage::DataType::INT);
-    arg_exponent->add_intvalue((int)exponent);
+    arg_exponent->set_type(GLMessage::DataType::INT64);
+    arg_exponent->add_int64value((uintptr_t)exponent);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21958,8 +21958,8 @@
     // copy argument equation
     GLMessage_DataType *arg_equation = glmsg.add_args();
     arg_equation->set_isarray(false);
-    arg_equation->set_type(GLMessage::DataType::INT);
-    arg_equation->add_intvalue((int)equation);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -21993,8 +21993,8 @@
     // copy argument eqn
     GLMessage_DataType *arg_eqn = glmsg.add_args();
     arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT);
-    arg_eqn->add_intvalue((int)eqn);
+    arg_eqn->set_type(GLMessage::DataType::INT64);
+    arg_eqn->add_int64value((uintptr_t)eqn);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22102,8 +22102,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22183,8 +22183,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22264,8 +22264,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22305,8 +22305,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22346,8 +22346,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22387,8 +22387,8 @@
     // copy argument params
     GLMessage_DataType *arg_params = glmsg.add_args();
     arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT);
-    arg_params->add_intvalue((int)params);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22422,8 +22422,8 @@
     // copy argument eqn
     GLMessage_DataType *arg_eqn = glmsg.add_args();
     arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT);
-    arg_eqn->add_intvalue((int)eqn);
+    arg_eqn->set_type(GLMessage::DataType::INT64);
+    arg_eqn->add_int64value((uintptr_t)eqn);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -22457,8 +22457,8 @@
     // copy argument eqn
     GLMessage_DataType *arg_eqn = glmsg.add_args();
     arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT);
-    arg_eqn->add_intvalue((int)eqn);
+    arg_eqn->set_type(GLMessage::DataType::INT64);
+    arg_eqn->add_int64value((uintptr_t)eqn);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
diff --git a/opengl/libs/GLES_trace/src/gltrace_egl.cpp b/opengl/libs/GLES_trace/src/gltrace_egl.cpp
index 9d1682a..4f9b006 100644
--- a/opengl/libs/GLES_trace/src/gltrace_egl.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_egl.cpp
@@ -71,7 +71,7 @@
     glContext->traceGLMessage(&glmessage);
 }
 
-void GLTrace_eglSwapBuffers(void *dpy, void *draw) {
+void GLTrace_eglSwapBuffers(void* /*dpy*/, void* /*draw*/) {
     GLMessage glmessage;
     GLTraceContext *glContext = getGLTraceContext();
 
diff --git a/opengl/libs/GLES_trace/tools/genapi.py b/opengl/libs/GLES_trace/tools/genapi.py
index 60686eb..76f7c78 100755
--- a/opengl/libs/GLES_trace/tools/genapi.py
+++ b/opengl/libs/GLES_trace/tools/genapi.py
@@ -25,9 +25,9 @@
 #   To generate C++ files, this script uses the 'pyratemp' template
 #   module. The only reason to use pyratemp is that it is extremly
 #   simple to install:
-#   $ wget http://www.simple-is-better.org/template/pyratemp-current/pyratemp.py
-#   Put the file in the GLES_trace/tools folder, or update PYTHONPATH
-#   to point to wherever it was downloaded.
+#   $ wget http://www.simple-is-better.org/template/pyratemp-0.3.2.tgz
+#   Extract and put the pyratemp.py file in the GLES_trace/tools folder,
+#   or update PYTHONPATH to point to wherever it was downloaded.
 #
 # USAGE
 #   $ cd GLES_trace       - run the program from GLES2_trace folder
@@ -44,16 +44,18 @@
         self.name = name
 
     def __str__(self):
-        if self.name == "pointer":  # pointers map to the INT DataType
-            return "INT"
+        if self.name == "pointer":  # pointers map to the INT64 DataType
+            return "INT64"
         return self.name.upper()
 
     def getProtobufCall(self):
         if self.name == "void":
             raise ValueError("Attempt to set void value")
         elif self.name == "char" or self.name == "byte" \
-                or self.name == "pointer" or self.name == "enum":
+                or self.name == "enum":
             return "add_intvalue((int)"
+        elif self.name == "pointer":
+            return "add_int64value((uintptr_t)"
         elif self.name == "int":
             return "add_intvalue("
         elif self.name == "float":
diff --git a/opengl/tests/hwc/Android.mk b/opengl/tests/hwc/Android.mk
index 2fdfcf8..86e1d46 100644
--- a/opengl/tests/hwc/Android.mk
+++ b/opengl/tests/hwc/Android.mk
@@ -57,7 +57,6 @@
 LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
 
 LOCAL_MODULE:= hwcStress
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativestresstest
 
 LOCAL_MODULE_TAGS := tests
 
@@ -88,7 +87,6 @@
 	$(call include-path-for, opengl-tests-includes)
 
 LOCAL_MODULE:= hwcRects
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativeutil
 
 LOCAL_MODULE_TAGS := tests
 
@@ -119,7 +117,6 @@
 	$(call include-path-for, opengl-tests-includes)
 
 LOCAL_MODULE:= hwcColorEquiv
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativeutil
 
 LOCAL_MODULE_TAGS := tests
 
@@ -150,7 +147,6 @@
 	$(call include-path-for, opengl-tests-includes)
 
 LOCAL_MODULE:= hwcCommit
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativebenchmark
 
 LOCAL_MODULE_TAGS := tests
 
diff --git a/opengl/tests/hwc/hwcStress.cpp b/opengl/tests/hwc/hwcStress.cpp
index 3e8ea8d..dfaa6c1 100644
--- a/opengl/tests/hwc/hwcStress.cpp
+++ b/opengl/tests/hwc/hwcStress.cpp
@@ -574,8 +574,8 @@
         // mod the wMod/hMod value must be equal to 0.
         size_t w = (width * maxSizeRatio) * testRandFract();
         size_t h = (height * maxSizeRatio) * testRandFract();
-        w = max(1u, w);
-        h = max(1u, h);
+        w = max(size_t(1u), w);
+        h = max(size_t(1u), h);
         if ((w % formatPtr->wMod) != 0) {
             w += formatPtr->wMod - (w % formatPtr->wMod);
         }
diff --git a/opengl/tools/glgen/src/JType.java b/opengl/tools/glgen/src/JType.java
index b10e7e2..c6e227e 100644
--- a/opengl/tools/glgen/src/JType.java
+++ b/opengl/tools/glgen/src/JType.java
@@ -57,8 +57,8 @@
     typeMapping.put(new CType("EGLenum"), new JType("int"));
     typeMapping.put(new CType("EGLNativePixmapType"), new JType("int"));
     typeMapping.put(new CType("EGLNativeWindowType"), new JType("int"));
-    typeMapping.put(new CType("EGLNativeDisplayType"), new JType("int"));
-    typeMapping.put(new CType("EGLClientBuffer"), new JType("int"));
+    typeMapping.put(new CType("EGLNativeDisplayType"), new JType("long"));
+    typeMapping.put(new CType("EGLClientBuffer"), new JType("long"));
     typeMapping.put(new CType("EGLnsecsANDROID"), new JType("long"));
 
     // EGL nonprimitive types
diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java
index b1bd1fd..e51b7a2 100644
--- a/opengl/tools/glgen/src/JniCodeEmitter.java
+++ b/opengl/tools/glgen/src/JniCodeEmitter.java
@@ -1283,7 +1283,7 @@
             for (int i = 0; i < numArgs; i++) {
                 String typecast;
                 if (i == numArgs - 1 && isPointerOffsetFunc) {
-                    typecast = "(GLvoid *)";
+                    typecast = "reinterpret_cast<GLvoid *>";
                 } else {
                     typecast = "(" + cfunc.getArgType(i).getDeclaration() + ")";
                 }
@@ -1297,6 +1297,8 @@
                 if (cfunc.getArgType(i).isEGLHandle() &&
                     !cfunc.getArgType(i).isPointer()){
                     out.print(cfunc.getArgName(i)+"_native");
+                } else if (i == numArgs - 1 && isPointerOffsetFunc){
+                    out.print("("+cfunc.getArgName(i)+")");
                 } else {
                     out.print(cfunc.getArgName(i));
                 }
diff --git a/opengl/tools/glgen/static/egl/EGLConfig.java b/opengl/tools/glgen/static/egl/EGLConfig.java
index a7a6bbb..9881070 100644
--- a/opengl/tools/glgen/static/egl/EGLConfig.java
+++ b/opengl/tools/glgen/static/egl/EGLConfig.java
@@ -22,7 +22,7 @@
  *
  */
 public class EGLConfig extends EGLObjectHandle {
-    private EGLConfig(int handle) {
+    private EGLConfig(long handle) {
         super(handle);
     }
 
@@ -32,6 +32,6 @@
         if (!(o instanceof EGLConfig)) return false;
 
         EGLConfig that = (EGLConfig) o;
-        return getHandle() == that.getHandle();
+        return getNativeHandle() == that.getNativeHandle();
     }
 }
diff --git a/opengl/tools/glgen/static/egl/EGLContext.java b/opengl/tools/glgen/static/egl/EGLContext.java
index c93bd6e..f791e7e 100644
--- a/opengl/tools/glgen/static/egl/EGLContext.java
+++ b/opengl/tools/glgen/static/egl/EGLContext.java
@@ -22,7 +22,7 @@
  *
  */
 public class EGLContext extends EGLObjectHandle {
-    private EGLContext(int handle) {
+    private EGLContext(long handle) {
         super(handle);
     }
 
@@ -32,6 +32,6 @@
         if (!(o instanceof EGLContext)) return false;
 
         EGLContext that = (EGLContext) o;
-        return getHandle() == that.getHandle();
+        return getNativeHandle() == that.getNativeHandle();
     }
 }
diff --git a/opengl/tools/glgen/static/egl/EGLDisplay.java b/opengl/tools/glgen/static/egl/EGLDisplay.java
index 5b8043a..e872761 100644
--- a/opengl/tools/glgen/static/egl/EGLDisplay.java
+++ b/opengl/tools/glgen/static/egl/EGLDisplay.java
@@ -22,7 +22,7 @@
  *
  */
 public class EGLDisplay extends EGLObjectHandle {
-    private EGLDisplay(int handle) {
+    private EGLDisplay(long handle) {
         super(handle);
     }
 
@@ -32,6 +32,6 @@
         if (!(o instanceof EGLDisplay)) return false;
 
         EGLDisplay that = (EGLDisplay) o;
-        return getHandle() == that.getHandle();
+        return getNativeHandle() == that.getNativeHandle();
     }
 }
diff --git a/opengl/tools/glgen/static/egl/EGLObjectHandle.java b/opengl/tools/glgen/static/egl/EGLObjectHandle.java
index d2710de..e6e3976 100644
--- a/opengl/tools/glgen/static/egl/EGLObjectHandle.java
+++ b/opengl/tools/glgen/static/egl/EGLObjectHandle.java
@@ -22,12 +22,20 @@
  *
  */
 public abstract class EGLObjectHandle {
-    private final int mHandle;
+    private final long mHandle;
 
+    // TODO Deprecate EGLObjectHandle(int) method
     protected EGLObjectHandle(int handle) {
         mHandle = handle;
     }
-
+    // TODO Unhide the EGLObjectHandle(long) method
+    /**
+     * {@hide}
+     */
+    protected EGLObjectHandle(long handle) {
+        mHandle = handle;
+    }
+    // TODO Deprecate getHandle() method in favor of getNativeHandle()
     /**
      * Returns the native handle of the wrapped EGL object. This handle can be
      * cast to the corresponding native type on the native side.
@@ -37,11 +45,27 @@
      * @return the native handle of the wrapped EGL object.
      */
     public int getHandle() {
-        return mHandle;
+        if ((mHandle & 0xffffffffL) != mHandle) {
+            throw new UnsupportedOperationException();
+        }
+        return (int)mHandle;
     }
 
+    // TODO Unhide getNativeHandle() method
+    /**
+     * {@hide}
+     */
+    public long getNativeHandle() {
+        return mHandle;
+    }
     @Override
     public int hashCode() {
-        return getHandle();
+        /*
+         * Based on the algorithm suggested in
+         * http://developer.android.com/reference/java/lang/Object.html
+         */
+        int result = 17;
+        result = 31 * result + (int) (mHandle ^ (mHandle >>> 32));
+        return result;
     }
 }
diff --git a/opengl/tools/glgen/static/egl/EGLSurface.java b/opengl/tools/glgen/static/egl/EGLSurface.java
index c379dc9..c200f72 100644
--- a/opengl/tools/glgen/static/egl/EGLSurface.java
+++ b/opengl/tools/glgen/static/egl/EGLSurface.java
@@ -22,7 +22,7 @@
  *
  */
 public class EGLSurface extends EGLObjectHandle {
-    private EGLSurface(int handle) {
+    private EGLSurface(long handle) {
         super(handle);
     }
 
@@ -32,6 +32,6 @@
         if (!(o instanceof EGLSurface)) return false;
 
         EGLSurface that = (EGLSurface) o;
-        return getHandle() == that.getHandle();
+        return getNativeHandle() == that.getNativeHandle();
     }
 }
diff --git a/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
index 54de1e7..a372362 100644
--- a/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
+++ b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
@@ -69,22 +69,22 @@
     jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
     eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
 
-    egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I");
-    eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I");
-    eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I");
-    eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I");
+    egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
+    eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
+    eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
+    eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
 
 
-    egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V");
-    eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V");
-    eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V");
-    eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V");
+    egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
+    eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
+    eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
+    eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
 
-    jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT);
+    jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, reinterpret_cast<jlong>(EGL_NO_CONTEXT));
     eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
-    jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY);
+    jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, reinterpret_cast<jlong>(EGL_NO_DISPLAY));
     eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
-    jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE);
+    jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, reinterpret_cast<jlong>(EGL_NO_SURFACE));
     eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
 
 
@@ -106,7 +106,8 @@
                           "Object is set to null.");
     }
 
-    return (void*) (_env->CallIntMethod(obj, mid));
+    jlong handle = _env->CallLongMethod(obj, mid);
+    return reinterpret_cast<void*>(handle);
 }
 
 static jobject
@@ -126,7 +127,7 @@
            return eglNoSurfaceObject;
     }
 
-    return _env->NewObject(cls, con, (jint)handle);
+    return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
 }
 
 // --------------------------------------------------------------------------
diff --git a/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp b/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp
index 5e1ffa1..b5c19df 100644
--- a/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp
+++ b/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp
@@ -70,22 +70,22 @@
     jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
     eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
 
-    egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I");
-    eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I");
-    eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I");
-    eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I");
+    egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
+    eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
+    eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
+    eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
 
 
-    egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V");
-    eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V");
-    eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V");
-    eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V");
+    egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
+    eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
+    eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
+    eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
 
-    jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT);
+    jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, reinterpret_cast<jlong>(EGL_NO_CONTEXT));
     eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
-    jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY);
+    jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, reinterpret_cast<jlong>(EGL_NO_DISPLAY));
     eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
-    jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE);
+    jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, reinterpret_cast<jlong>(EGL_NO_SURFACE));
     eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
 
 
@@ -107,7 +107,7 @@
                           "Object is set to null.");
     }
 
-    return (void*) (_env->CallIntMethod(obj, mid));
+    return reinterpret_cast<void*>(_env->CallLongMethod(obj, mid));
 }
 
 static jobject
@@ -127,7 +127,7 @@
            return eglNoSurfaceObject;
     }
 
-    return _env->NewObject(cls, con, (jint)handle);
+    return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
 }
 
 // --------------------------------------------------------------------------
diff --git a/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp
new file mode 100755
index 0000000..f09c171
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp
@@ -0,0 +1,74 @@
+/* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */
+static jobject
+android_eglCreatePbufferFromClientBuffer
+  (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jlong buffer, jobject config, jintArray attrib_list_ref, jint offset) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
+    EGLSurface _returnValue = (EGLSurface) 0;
+    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
+    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
+    bool attrib_list_sentinel = false;
+    EGLint *attrib_list_base = (EGLint *) 0;
+    jint _remaining;
+    EGLint *attrib_list = (EGLint *) 0;
+
+    if (!attrib_list_ref) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "attrib_list == null";
+        goto exit;
+    }
+    if (offset < 0) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "offset < 0";
+        goto exit;
+    }
+    _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
+    attrib_list_base = (EGLint *)
+        _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
+    attrib_list = attrib_list_base + offset;
+    attrib_list_sentinel = false;
+    for (int i = _remaining - 1; i >= 0; i--)  {
+        if (attrib_list[i] == EGL_NONE){
+            attrib_list_sentinel = true;
+            break;
+        }
+    }
+    if (attrib_list_sentinel == false) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "attrib_list must contain EGL_NONE!";
+        goto exit;
+    }
+
+    _returnValue = eglCreatePbufferFromClientBuffer(
+        (EGLDisplay)dpy_native,
+        (EGLenum)buftype,
+        reinterpret_cast<EGLClientBuffer>(buffer),
+        (EGLConfig)config_native,
+        (EGLint *)attrib_list
+    );
+
+exit:
+    if (attrib_list_base) {
+        _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
+            JNI_ABORT);
+    }
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
+}
+
+static jobject
+android_eglCreatePbufferFromClientBufferInt
+  (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) {
+    if(sizeof(void*) != sizeof(uint32_t)) {
+        jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePbufferFromClientBuffer");
+        return 0;
+    }
+    return android_eglCreatePbufferFromClientBuffer(_env, _this, dpy, buftype, buffer, config, attrib_list_ref, offset);
+}
+
diff --git a/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.java b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.java
new file mode 100755
index 0000000..c2ed1d7
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.java
@@ -0,0 +1,23 @@
+    // C function EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list )
+    // TODO Deprecate the below method
+    public static native EGLSurface eglCreatePbufferFromClientBuffer(
+        EGLDisplay dpy,
+        int buftype,
+        int buffer,
+        EGLConfig config,
+        int[] attrib_list,
+        int offset
+    );
+    // TODO Unhide the below method
+    /**
+     * {@hide}
+     */
+    public static native EGLSurface eglCreatePbufferFromClientBuffer(
+        EGLDisplay dpy,
+        int buftype,
+        long buffer,
+        EGLConfig config,
+        int[] attrib_list,
+        int offset
+    );
+
diff --git a/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.nativeReg b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.nativeReg
new file mode 100755
index 0000000..477e625
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.nativeReg
@@ -0,0 +1,2 @@
+{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IILandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBufferInt },

+{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IJLandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBuffer },
\ No newline at end of file
diff --git a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
index 0cfd886..0b6bf58 100644
--- a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
+++ b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
@@ -116,7 +116,7 @@
     if (producer == NULL)
         goto not_valid_surface;
 
-    window = new android::Surface(producer);
+    window = new android::Surface(producer, true);
 
     if (window == NULL)
         goto not_valid_surface;
diff --git a/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp b/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp
new file mode 100755
index 0000000..003efd3
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp
@@ -0,0 +1,23 @@
+/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */
+static jobject
+android_eglGetDisplay
+  (JNIEnv *_env, jobject _this, jlong display_id) {
+    EGLDisplay _returnValue = (EGLDisplay) 0;
+    _returnValue = eglGetDisplay(
+        reinterpret_cast<EGLNativeDisplayType>(display_id)
+    );
+    return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
+}
+
+/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */
+static jobject
+android_eglGetDisplayInt
+  (JNIEnv *_env, jobject _this, jint display_id) {
+
+    if ((EGLNativeDisplayType)display_id != EGL_DEFAULT_DISPLAY) {
+        jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglGetDisplay");
+        return 0;
+    }
+    return android_eglGetDisplay(_env, _this, display_id);
+}
+
diff --git a/opengl/tools/glgen/stubs/egl/eglGetDisplay.java b/opengl/tools/glgen/stubs/egl/eglGetDisplay.java
new file mode 100755
index 0000000..7532abf
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglGetDisplay.java
@@ -0,0 +1,13 @@
+    // C function EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id )
+
+    public static native EGLDisplay eglGetDisplay(
+        int display_id
+    );
+
+    /**
+     * {@hide}
+     */
+    public static native EGLDisplay eglGetDisplay(
+        long display_id
+    );
+
diff --git a/opengl/tools/glgen/stubs/egl/eglGetDisplay.nativeReg b/opengl/tools/glgen/stubs/egl/eglGetDisplay.nativeReg
new file mode 100755
index 0000000..acfbb1a
--- /dev/null
+++ b/opengl/tools/glgen/stubs/egl/eglGetDisplay.nativeReg
@@ -0,0 +1,2 @@
+{"eglGetDisplay", "(I)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplayInt },
+{"eglGetDisplay", "(J)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplay },
\ No newline at end of file
diff --git a/opengl/tools/glgen/stubs/gles11/common.cpp b/opengl/tools/glgen/stubs/gles11/common.cpp
index 75b75cb..c5a7a24 100644
--- a/opengl/tools/glgen/stubs/gles11/common.cpp
+++ b/opengl/tools/glgen/stubs/gles11/common.cpp
@@ -89,7 +89,7 @@
             getBasePointerID, buffer);
     if (pointer != 0L) {
         *array = NULL;
-        return (void *) (jint) pointer;
+        return reinterpret_cast<void*>(pointer);
     }
 
     *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
index 27b91fc..7d414d8 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
@@ -157,7 +157,7 @@
         (GLsizei *)length,
         (GLint *)size,
         (GLenum *)type,
-        (char *)name
+        reinterpret_cast<char *>(name)
     );
     if (_typeArray) {
         releasePointer(_env, _typeArray, type, JNI_TRUE);
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
index 58f704c..a7376ba 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
@@ -157,7 +157,7 @@
         (GLsizei *)length,
         (GLint *)size,
         (GLenum *)type,
-        (char *)name
+        reinterpret_cast<char *>(name)
     );
     if (_typeArray) {
         releasePointer(_env, _typeArray, type, JNI_TRUE);
diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
index a7e1cd2..c995d9c 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
@@ -85,7 +85,7 @@
         (GLuint)shader,
         (GLsizei)bufsize,
         (GLsizei *)length,
-        (char *)source
+        reinterpret_cast<char *>(source)
     );
     if (_array) {
         releasePointer(_env, _array, length, JNI_TRUE);
diff --git a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
index cc10336..df11c53 100644
--- a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
+++ b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
@@ -128,7 +128,7 @@
             getBasePointerID, buffer);
     if (pointer != 0L) {
         *array = NULL;
-        return (void *) (jint) pointer;
+        return reinterpret_cast<void *>(pointer);
     }
 
     *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
@@ -182,7 +182,7 @@
             if (array) {
                 releasePointer(_env, array, buf, 0);
             }
-            buf = buf + offset;
+            buf = (char*)buf + offset;
         } else {
             jniThrowException(_env, "java/lang/IllegalArgumentException",
                               "Must use a native order direct Buffer");
diff --git a/services/sensorservice/CorrectedGyroSensor.cpp b/services/sensorservice/CorrectedGyroSensor.cpp
index 31487a7..b07d544 100644
--- a/services/sensorservice/CorrectedGyroSensor.cpp
+++ b/services/sensorservice/CorrectedGyroSensor.cpp
@@ -61,7 +61,7 @@
     return mSensorFusion.activate(ident, enabled);
 }
 
-status_t CorrectedGyroSensor::setDelay(void* ident, int handle, int64_t ns) {
+status_t CorrectedGyroSensor::setDelay(void* ident, int /*handle*/, int64_t ns) {
     mSensorDevice.setDelay(ident, mGyro.getHandle(), ns);
     return mSensorFusion.setDelay(ident, ns);
 }
diff --git a/services/sensorservice/GravitySensor.cpp b/services/sensorservice/GravitySensor.cpp
index dd1f650..3cb3745 100644
--- a/services/sensorservice/GravitySensor.cpp
+++ b/services/sensorservice/GravitySensor.cpp
@@ -70,7 +70,7 @@
     return mSensorFusion.activate(ident, enabled);
 }
 
-status_t GravitySensor::setDelay(void* ident, int handle, int64_t ns) {
+status_t GravitySensor::setDelay(void* ident, int /*handle*/, int64_t ns) {
     return mSensorFusion.setDelay(ident, ns);
 }
 
diff --git a/services/sensorservice/OrientationSensor.cpp b/services/sensorservice/OrientationSensor.cpp
index 10b391c..6d85cca 100644
--- a/services/sensorservice/OrientationSensor.cpp
+++ b/services/sensorservice/OrientationSensor.cpp
@@ -69,7 +69,7 @@
     return mSensorFusion.activate(ident, enabled);
 }
 
-status_t OrientationSensor::setDelay(void* ident, int handle, int64_t ns) {
+status_t OrientationSensor::setDelay(void* ident, int /*handle*/, int64_t ns) {
     return mSensorFusion.setDelay(ident, ns);
 }
 
diff --git a/services/sensorservice/RotationVectorSensor.cpp b/services/sensorservice/RotationVectorSensor.cpp
index a2157b4..cb305eb 100644
--- a/services/sensorservice/RotationVectorSensor.cpp
+++ b/services/sensorservice/RotationVectorSensor.cpp
@@ -56,7 +56,7 @@
     return mSensorFusion.activate(ident, enabled);
 }
 
-status_t RotationVectorSensor::setDelay(void* ident, int handle, int64_t ns) {
+status_t RotationVectorSensor::setDelay(void* ident, int /*handle*/, int64_t ns) {
     return mSensorFusion.setDelay(ident, ns);
 }
 
@@ -105,7 +105,7 @@
     return mSensorFusion.activate(ident, enabled);
 }
 
-status_t GyroDriftSensor::setDelay(void* ident, int handle, int64_t ns) {
+status_t GyroDriftSensor::setDelay(void* ident, int /*handle*/, int64_t ns) {
     return mSensorFusion.setDelay(ident, ns);
 }
 
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 19caa5c..3b64f0a 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -78,7 +78,7 @@
     Mutex::Autolock _l(mLock);
     for (size_t i=0 ; i<size_t(count) ; i++) {
         const Info& info = mActivationCount.valueFor(list[i].handle);
-        result.appendFormat("handle=0x%08x, active-count=%d, batch_period(ms)={ ", list[i].handle,
+        result.appendFormat("handle=0x%08x, active-count=%zu, batch_period(ms)={ ", list[i].handle,
                             info.batchParams.size());
         for (size_t j = 0; j < info.batchParams.size(); j++) {
             BatchParams params = info.batchParams.valueAt(j);
@@ -87,7 +87,7 @@
         }
         result.appendFormat(" }, selected=%4.1f ms\n", info.bestBatchParams.batchDelay / 1e6f);
 
-        result.appendFormat("handle=0x%08x, active-count=%d, batch_timeout(ms)={ ", list[i].handle,
+        result.appendFormat("handle=0x%08x, active-count=%zu, batch_timeout(ms)={ ", list[i].handle,
                             info.batchParams.size());
         for (size_t j = 0; j < info.batchParams.size(); j++) {
             BatchParams params = info.batchParams.valueAt(j);
@@ -309,7 +309,7 @@
     return mSensorDevice->common.version;
 }
 
-status_t SensorDevice::flush(void* ident, int handle) {
+status_t SensorDevice::flush(void* /*ident*/, int handle) {
     if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_1) {
         return INVALID_OPERATION;
     }
diff --git a/services/sensorservice/SensorFusion.cpp b/services/sensorservice/SensorFusion.cpp
index 8512d6b..6d93009 100644
--- a/services/sensorservice/SensorFusion.cpp
+++ b/services/sensorservice/SensorFusion.cpp
@@ -139,7 +139,7 @@
 
 void SensorFusion::dump(String8& result) {
     const Fusion& fusion(mFusion);
-    result.appendFormat("9-axis fusion %s (%d clients), gyro-rate=%7.2fHz, "
+    result.appendFormat("9-axis fusion %s (%zd clients), gyro-rate=%7.2fHz, "
             "q=< %g, %g, %g, %g > (%g), "
             "b=< %g, %g, %g >\n",
             mEnabled ? "enabled" : "disabled",
diff --git a/services/sensorservice/SensorInterface.cpp b/services/sensorservice/SensorInterface.cpp
index f1d1663..2bf5e72 100644
--- a/services/sensorservice/SensorInterface.cpp
+++ b/services/sensorservice/SensorInterface.cpp
@@ -50,7 +50,7 @@
     return mSensorDevice.activate(ident, mSensor.getHandle(), enabled);
 }
 
-status_t HardwareSensor::batch(void* ident, int handle, int flags,
+status_t HardwareSensor::batch(void* ident, int /*handle*/, int flags,
                                int64_t samplingPeriodNs, int64_t maxBatchReportLatencyNs) {
     return mSensorDevice.batch(ident, mSensor.getHandle(), flags, samplingPeriodNs,
                                maxBatchReportLatencyNs);
diff --git a/services/sensorservice/SensorInterface.h b/services/sensorservice/SensorInterface.h
index c295e22..3e76377 100644
--- a/services/sensorservice/SensorInterface.h
+++ b/services/sensorservice/SensorInterface.h
@@ -40,7 +40,7 @@
     virtual status_t setDelay(void* ident, int handle, int64_t ns) = 0;
 
     // Not all sensors need to support batching.
-    virtual status_t batch(void* ident, int handle, int flags, int64_t samplingPeriodNs,
+    virtual status_t batch(void* ident, int handle, int /*flags*/, int64_t samplingPeriodNs,
                            int64_t maxBatchReportLatencyNs) {
         if (maxBatchReportLatencyNs == 0) {
             return setDelay(ident, handle, samplingPeriodNs);
@@ -48,13 +48,13 @@
         return -EINVAL;
     }
 
-    virtual status_t flush(void* ident, int handle) {
+    virtual status_t flush(void* /*ident*/, int /*handle*/) {
         return -EINVAL;
     }
 
     virtual Sensor getSensor() const = 0;
     virtual bool isVirtual() const = 0;
-    virtual void autoDisable(void *ident, int handle) { }
+    virtual void autoDisable(void* /*ident*/, int /*handle*/) { }
 };
 
 // ---------------------------------------------------------------------------
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index ca2fdf6..148f404 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include <stdint.h>
+#include <inttypes.h>
 #include <math.h>
+#include <stdint.h>
 #include <sys/types.h>
 
 #include <cutils/properties.h>
@@ -153,7 +154,7 @@
             char line[128];
             if (fp != NULL && fgets(line, sizeof(line), fp) != NULL) {
                 line[sizeof(line) - 1] = '\0';
-                sscanf(line, "%u", &mSocketBufferSize);
+                sscanf(line, "%zu", &mSocketBufferSize);
                 if (mSocketBufferSize > MAX_SOCKET_BUFFER_SIZE_BATCHED) {
                     mSocketBufferSize = MAX_SOCKET_BUFFER_SIZE_BATCHED;
                 }
@@ -200,7 +201,7 @@
 
 static const String16 sDump("android.permission.DUMP");
 
-status_t SensorService::dump(int fd, const Vector<String16>& args)
+status_t SensorService::dump(int fd, const Vector<String16>& /*args*/)
 {
     String8 result;
     if (!PermissionCache::checkCallingPermission(sDump)) {
@@ -260,7 +261,7 @@
                     result.appendFormat( "last=<%f>\n", e.data[0]);
                     break;
                 case SENSOR_TYPE_STEP_COUNTER:
-                    result.appendFormat( "last=<%llu>\n", e.u64.step_counter);
+                    result.appendFormat( "last=<%" PRIu64 ">\n", e.u64.step_counter);
                     break;
                 default:
                     // default to 3 values
@@ -276,19 +277,19 @@
         result.append("Active sensors:\n");
         for (size_t i=0 ; i<mActiveSensors.size() ; i++) {
             int handle = mActiveSensors.keyAt(i);
-            result.appendFormat("%s (handle=0x%08x, connections=%d)\n",
+            result.appendFormat("%s (handle=0x%08x, connections=%zu)\n",
                     getSensorName(handle).string(),
                     handle,
                     mActiveSensors.valueAt(i)->getNumConnections());
         }
 
-        result.appendFormat("%u Max Socket Buffer size\n", mSocketBufferSize);
-        result.appendFormat("%d active connections\n", mActiveConnections.size());
+        result.appendFormat("%zu Max Socket Buffer size\n", mSocketBufferSize);
+        result.appendFormat("%zd active connections\n", mActiveConnections.size());
 
         for (size_t i=0 ; i < mActiveConnections.size() ; i++) {
             sp<SensorEventConnection> connection(mActiveConnections[i].promote());
             if (connection != 0) {
-                result.appendFormat("Connection Number: %d \n", i);
+                result.appendFormat("Connection Number: %zu \n", i);
                 connection->dump(result);
             }
         }
diff --git a/services/sensorservice/main_sensorservice.cpp b/services/sensorservice/main_sensorservice.cpp
index 303b65f..0a96f42 100644
--- a/services/sensorservice/main_sensorservice.cpp
+++ b/services/sensorservice/main_sensorservice.cpp
@@ -19,7 +19,7 @@
 
 using namespace android;
 
-int main(int argc, char** argv) {
+int main(int /*argc*/, char** /*argv*/) {
     SensorService::publishAndJoinThreadPool();
     return 0;
 }
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index afa680f..5a8efeb 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -117,6 +117,10 @@
 
 LOCAL_MODULE:= surfaceflinger
 
+ifdef TARGET_32_BIT_SURFACEFLINGER
+LOCAL_32_BIT_ONLY := true
+endif
+
 include $(BUILD_EXECUTABLE)
 
 ###############################################################
diff --git a/services/surfaceflinger/DdmConnection.cpp b/services/surfaceflinger/DdmConnection.cpp
index d2c977d..2477921 100644
--- a/services/surfaceflinger/DdmConnection.cpp
+++ b/services/surfaceflinger/DdmConnection.cpp
@@ -45,18 +45,21 @@
     args.ignoreUnrecognized = JNI_FALSE;
 
 
-    void* libdvm_dso = dlopen("libdvm.so", RTLD_NOW);
-    ALOGE_IF(!libdvm_dso, "DdmConnection: %s", dlerror());
+    // TODO: Should this just link against libnativehelper and use its
+    // JNI_CreateJavaVM wrapper that essential does this dlopen/dlsym
+    // work based on the current system default runtime?
+    void* libart_dso = dlopen("libart.so", RTLD_NOW);
+    ALOGE_IF(!libart_dso, "DdmConnection: %s", dlerror());
 
     void* libandroid_runtime_dso = dlopen("libandroid_runtime.so", RTLD_NOW);
     ALOGE_IF(!libandroid_runtime_dso, "DdmConnection: %s", dlerror());
 
-    if (!libdvm_dso || !libandroid_runtime_dso) {
+    if (!libart_dso || !libandroid_runtime_dso) {
         goto error;
     }
 
     jint (*JNI_CreateJavaVM)(JavaVM** p_vm, JNIEnv** p_env, void* vm_args);
-    JNI_CreateJavaVM = (typeof JNI_CreateJavaVM)dlsym(libdvm_dso, "JNI_CreateJavaVM");
+    JNI_CreateJavaVM = (typeof JNI_CreateJavaVM)dlsym(libart_dso, "JNI_CreateJavaVM");
     ALOGE_IF(!JNI_CreateJavaVM, "DdmConnection: %s", dlerror());
 
     jint (*registerNatives)(JNIEnv* env, jclass clazz);
@@ -104,8 +107,8 @@
     if (libandroid_runtime_dso) {
         dlclose(libandroid_runtime_dso);
     }
-    if (libdvm_dso) {
-        dlclose(libdvm_dso);
+    if (libart_dso) {
+        dlclose(libart_dso);
     }
 }
 
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index c51d207..95839b7 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -288,7 +288,7 @@
 public:
     ZeroPhaseTracer() : mParity(false) {}
 
-    virtual void onDispSyncEvent(nsecs_t when) {
+    virtual void onDispSyncEvent(nsecs_t /*when*/) {
         mParity = !mParity;
         ATRACE_INT("ZERO_PHASE_VSYNC", mParity ? 1 : 0);
     }
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index e5ecf07..f9034a6 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -77,16 +77,6 @@
     mNativeWindow = new Surface(producer, false);
     ANativeWindow* const window = mNativeWindow.get();
 
-    // Make sure that composition can never be stalled by a virtual display
-    // consumer that isn't processing buffers fast enough. We have to do this
-    // in two places:
-    // * Here, in case the display is composed entirely by HWC.
-    // * In makeCurrent(), using eglSwapInterval. Some EGL drivers set the
-    //   window's swap interval in eglMakeCurrent, so they'll override the
-    //   interval we set here.
-    if (mType >= DisplayDevice::DISPLAY_VIRTUAL)
-        window->setSwapInterval(window, 0);
-
     /*
      * Create our display's surface
      */
@@ -101,6 +91,16 @@
     eglQuerySurface(display, surface, EGL_WIDTH,  &mDisplayWidth);
     eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight);
 
+    // Make sure that composition can never be stalled by a virtual display
+    // consumer that isn't processing buffers fast enough. We have to do this
+    // in two places:
+    // * Here, in case the display is composed entirely by HWC.
+    // * In makeCurrent(), using eglSwapInterval. Some EGL drivers set the
+    //   window's swap interval in eglMakeCurrent, so they'll override the
+    //   interval we set here.
+    if (mType >= DisplayDevice::DISPLAY_VIRTUAL)
+        window->setSwapInterval(window, 0);
+
     mDisplay = display;
     mSurface = surface;
     mFormat  = format;
@@ -462,7 +462,7 @@
     result.appendFormat(
         "+ DisplayDevice: %s\n"
         "   type=%x, hwcId=%d, layerStack=%u, (%4dx%4d), ANativeWindow=%p, orient=%2d (type=%08x), "
-        "flips=%u, isSecure=%d, secureVis=%d, acquired=%d, numLayers=%u\n"
+        "flips=%u, isSecure=%d, secureVis=%d, acquired=%d, numLayers=%zu\n"
         "   v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
         "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
         mDisplayName.string(), mType, mHwcDisplayId,
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index 0f34764..086ccf8 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -72,7 +72,7 @@
     return NO_ERROR;
 }
 
-status_t FramebufferSurface::prepareFrame(CompositionType compositionType) {
+status_t FramebufferSurface::prepareFrame(CompositionType /*compositionType*/) {
     return NO_ERROR;
 }
 
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 1b652c3..a48582e 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -16,12 +16,13 @@
 
 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
 
+#include <inttypes.h>
+#include <math.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
-#include <math.h>
 
 #include <utils/CallStack.h>
 #include <utils/Errors.h>
@@ -1022,12 +1023,12 @@
                     mFlinger->getLayerSortedByZForHwcDisplay(i);
 
             result.appendFormat(
-                    "  Display[%d] : %ux%u, xdpi=%f, ydpi=%f, refresh=%lld\n",
+                    "  Display[%zd] : %ux%u, xdpi=%f, ydpi=%f, refresh=%" PRId64 "\n",
                     i, disp.width, disp.height, disp.xdpi, disp.ydpi, disp.refresh);
 
             if (disp.list) {
                 result.appendFormat(
-                        "  numHwLayers=%u, flags=%08x\n",
+                        "  numHwLayers=%zu, flags=%08x\n",
                         disp.list->numHwLayers, disp.list->flags);
 
                 result.append(
@@ -1066,7 +1067,7 @@
 
                     if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
                         result.appendFormat(
-                                " %10s | %08x | %08x | %08x | %02x | %05x | %08x | [%7.1f,%7.1f,%7.1f,%7.1f] | [%5d,%5d,%5d,%5d] %s\n",
+                                " %10s | %08" PRIxPTR " | %08x | %08x | %02x | %05x | %08x | [%7.1f,%7.1f,%7.1f,%7.1f] | [%5d,%5d,%5d,%5d] %s\n",
                                         compositionTypeName[type],
                                         intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
                                         l.sourceCropf.left, l.sourceCropf.top, l.sourceCropf.right, l.sourceCropf.bottom,
@@ -1074,7 +1075,7 @@
                                         name.string());
                     } else {
                         result.appendFormat(
-                                " %10s | %08x | %08x | %08x | %02x | %05x | %08x | [%7d,%7d,%7d,%7d] | [%5d,%5d,%5d,%5d] %s\n",
+                                " %10s | %08" PRIxPTR " | %08x | %08x | %02x | %05x | %08x | [%7d,%7d,%7d,%7d] | [%5d,%5d,%5d,%5d] %s\n",
                                         compositionTypeName[type],
                                         intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
                                         l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom,
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index 3528b62..d868f32 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -328,7 +328,7 @@
             mDebugVsyncEnabled?"enabled":"disabled");
     result.appendFormat("  soft-vsync: %s\n",
             mUseSoftwareVSync?"enabled":"disabled");
-    result.appendFormat("  numListeners=%u,\n  events-delivered: %u\n",
+    result.appendFormat("  numListeners=%zu,\n  events-delivered: %u\n",
             mDisplayEventConnections.size(),
             mVSyncEvent[DisplayDevice::DISPLAY_PRIMARY].vsync.count);
     for (size_t i=0 ; i<mDisplayEventConnections.size() ; i++) {
diff --git a/services/surfaceflinger/FrameTracker.cpp b/services/surfaceflinger/FrameTracker.cpp
index d406672..2fb665e 100644
--- a/services/surfaceflinger/FrameTracker.cpp
+++ b/services/surfaceflinger/FrameTracker.cpp
@@ -17,6 +17,8 @@
 // This is needed for stdint.h to define INT64_MAX in C++
 #define __STDC_LIMIT_MACROS
 
+#include <inttypes.h>
+
 #include <cutils/log.h>
 
 #include <ui/Fence.h>
@@ -211,7 +213,7 @@
     const size_t o = mOffset;
     for (size_t i = 1; i < NUM_FRAME_RECORDS; i++) {
         const size_t index = (o+i) % NUM_FRAME_RECORDS;
-        result.appendFormat("%lld\t%lld\t%lld\n",
+        result.appendFormat("%" PRId64 "\t%" PRId64 "\t%" PRId64 "\n",
             mFrameRecords[index].desiredPresentTime,
             mFrameRecords[index].actualPresentTime,
             mFrameRecords[index].frameReadyTime);
diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp
index cc672b6..1ad86a6 100644
--- a/services/surfaceflinger/MessageQueue.cpp
+++ b/services/surfaceflinger/MessageQueue.cpp
@@ -179,7 +179,7 @@
     return queue->eventReceiver(fd, events);
 }
 
-int MessageQueue::eventReceiver(int fd, int events) {
+int MessageQueue::eventReceiver(int /*fd*/, int /*events*/) {
     ssize_t n;
     DisplayEventReceiver::Event buffer[8];
     while ((n = DisplayEventReceiver::getEvents(mEventTube, buffer, 8)) > 0) {
diff --git a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
index 521a5d2..cbff320 100644
--- a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
@@ -237,7 +237,7 @@
     }
 }
 
-void GLES11RenderEngine::beginGroup(const mat4& colorTransform) {
+void GLES11RenderEngine::beginGroup(const mat4& /*colorTransform*/) {
     // doesn't do anything in GLES 1.1
 }
 
diff --git a/services/surfaceflinger/RenderEngine/Program.cpp b/services/surfaceflinger/RenderEngine/Program.cpp
index 4a7fb58..0424e0c 100644
--- a/services/surfaceflinger/RenderEngine/Program.cpp
+++ b/services/surfaceflinger/RenderEngine/Program.cpp
@@ -25,7 +25,7 @@
 
 namespace android {
 
-Program::Program(const ProgramCache::Key& needs, const char* vertex, const char* fragment)
+Program::Program(const ProgramCache::Key& /*needs*/, const char* vertex, const char* fragment)
         : mInitialized(false) {
     GLuint vertexId = buildShader(vertex, GL_VERTEX_SHADER);
     GLuint fragmentId = buildShader(fragment, GL_FRAGMENT_SHADER);
@@ -112,7 +112,7 @@
     return shader;
 }
 
-String8& Program::dumpShader(String8& result, GLenum type) {
+String8& Program::dumpShader(String8& result, GLenum /*type*/) {
     GLuint shader = GL_FRAGMENT_SHADER ? mFragmentShader : mVertexShader;
     GLint l;
     glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &l);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 08cc506..3c447db 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <math.h>
 #include <dlfcn.h>
+#include <inttypes.h>
 
 #include <EGL/egl.h>
 
@@ -429,7 +430,7 @@
                 // FIXME: currently we don't get blank/unblank requests
                 // for displays other than the main display, so we always
                 // assume a connected display is unblanked.
-                ALOGD("marking display %d as acquired/unblanked", i);
+                ALOGD("marking display %zu as acquired/unblanked", i);
                 hw->acquireScreen();
             }
             mDisplays.add(token, hw);
@@ -1650,7 +1651,7 @@
                     case HWC_FRAMEBUFFER_TARGET: {
                         // this should not happen as the iterator shouldn't
                         // let us get there.
-                        ALOGW("HWC_FRAMEBUFFER_TARGET found in hwc list (index=%d)", i);
+                        ALOGW("HWC_FRAMEBUFFER_TARGET found in hwc list (index=%zu)", i);
                         break;
                     }
                 }
@@ -2235,7 +2236,7 @@
 
     const nsecs_t period =
             getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY);
-    result.appendFormat("%lld\n", period);
+    result.appendFormat("%" PRId64 "\n", period);
 
     if (name.isEmpty()) {
         mAnimFrameTracker.dump(result);
@@ -2345,7 +2346,7 @@
     const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
     const size_t count = currentLayers.size();
     colorizer.bold(result);
-    result.appendFormat("Visible layers (count = %d)\n", count);
+    result.appendFormat("Visible layers (count = %zu)\n", count);
     colorizer.reset(result);
     for (size_t i=0 ; i<count ; i++) {
         const sp<Layer>& layer(currentLayers[i]);
@@ -2357,7 +2358,7 @@
      */
 
     colorizer.bold(result);
-    result.appendFormat("Displays (%d entries)\n", mDisplays.size());
+    result.appendFormat("Displays (%zu entries)\n", mDisplays.size());
     colorizer.reset(result);
     for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
         const sp<const DisplayDevice>& hw(mDisplays[dpy]);
@@ -2646,7 +2647,7 @@
             looper->sendMessage(this, Message(MSG_API_CALL));
             barrier.wait();
         }
-        return NO_ERROR;
+        return result;
     }
 
     /*
@@ -2656,7 +2657,7 @@
     virtual void handleMessage(const Message& message) {
         android_atomic_release_load(&memoryBarrier);
         if (message.what == MSG_API_CALL) {
-            impl->asBinder()->transact(code, data[0], reply);
+            result = impl->asBinder()->transact(code, data[0], reply);
             barrier.open();
         } else if (message.what == MSG_EXIT) {
             exitRequested = true;
@@ -2940,7 +2941,7 @@
             const bool visible = (state.layerStack == hw->getLayerStack())
                                 && (state.z >= minLayerZ && state.z <= maxLayerZ)
                                 && (layer->isVisible());
-            ALOGE("%c index=%d, name=%s, layerStack=%d, z=%d, visible=%d, flags=%x, alpha=%x",
+            ALOGE("%c index=%zu, name=%s, layerStack=%d, z=%d, visible=%d, flags=%x, alpha=%x",
                     visible ? '+' : '-',
                             i, layer->getName().string(), state.layerStack, state.z,
                             layer->isVisible(), state.flags, state.alpha);