am 36a5aa05: Merge "Use the kernel\'s sa_restorer for aarch64."

* commit '36a5aa057cf1738577754a3fc16a14a5f817109f':
  Use the kernel's sa_restorer for aarch64.
diff --git a/libc/Android.mk b/libc/Android.mk
index 56e9876..5052cb1 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -89,7 +89,6 @@
     bionic/access.cpp \
     bionic/assert.cpp \
     bionic/atof.cpp \
-    bionic/bionic_systrace.cpp \
     bionic/bionic_time_conversions.cpp \
     bionic/brk.cpp \
     bionic/c16rtomb.cpp \
@@ -865,7 +864,8 @@
 LOCAL_CPPFLAGS := $(libc_common_cppflags)
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_MODULE := libc_cxa
-LOCAL_CLANG := true # GCC refuses to hide new/delete
+# GCC refuses to hide new/delete
+LOCAL_CLANG := true
 LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
 LOCAL_SYSTEM_SHARED_LIBRARIES :=
 
diff --git a/libc/bionic/bionic_systrace.cpp b/libc/bionic/bionic_systrace.cpp
deleted file mode 100644
index f5be415..0000000
--- a/libc/bionic/bionic_systrace.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cutils/trace.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "private/bionic_systrace.h"
-#include "private/libc_logging.h"
-
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#include <sys/_system_properties.h>
-
-#define WRITE_OFFSET   32
-
-static const prop_info* g_pinfo = NULL;
-static uint32_t g_serial = -1;
-static uint64_t g_tags = 0;
-static int g_trace_marker_fd = -1;
-
-static bool should_trace() {
-  // If g_pinfo is null, this means that systrace hasn't been run and it's safe to
-  // assume that no trace writing will need to take place.  However, to avoid running
-  // this costly find check each time, we set it to a non-tracing value so that next
-  // time, it will just check the serial to see if the value has been changed.
-  // this function also deals with the bootup case, during which the call to property
-  // set will fail if the property server hasn't yet started.
-  if (g_pinfo == NULL) {
-    g_pinfo = __system_property_find("debug.atrace.tags.enableflags");
-    if (g_pinfo == NULL) {
-      __system_property_set("debug.atrace.tags.enableflags", "0");
-      g_pinfo = __system_property_find("debug.atrace.tags.enableflags");
-      if (g_pinfo == NULL) {
-        return false;
-      }
-    }
-  }
-
-  // Find out which tags have been enabled on the command line and set
-  // the value of tags accordingly.  If the value of the property changes,
-  // the serial will also change, so the costly system_property_read function
-  // can be avoided by calling the much cheaper system_property_serial
-  // first.  The values within pinfo may change, but its location is guaranteed
-  // not to move.
-  const uint32_t cur_serial = __system_property_serial(g_pinfo);
-  if (cur_serial != g_serial) {
-    g_serial = cur_serial;
-    char value[PROP_VALUE_MAX];
-    __system_property_read(g_pinfo, 0, value);
-    g_tags = strtoull(value, NULL, 0);
-  }
-
-  // Finally, verify that this tag value enables bionic tracing.
-  return ((g_tags & ATRACE_TAG_BIONIC) != 0);
-}
-
-ScopedTrace::ScopedTrace(const char* message) {
-  if (!should_trace()) {
-    return;
-  }
-
-  if (g_trace_marker_fd == -1) {
-    g_trace_marker_fd = open("/sys/kernel/debug/tracing/trace_marker", O_CLOEXEC | O_WRONLY);
-    if (g_trace_marker_fd == -1) {
-      __libc_fatal("Could not open kernel trace file: %s\n", strerror(errno));
-    }
-  }
-
-  // If bionic tracing has been enabled, then write the message to the
-  // kernel trace_marker.
-  int length = strlen(message);
-  char buf[length + WRITE_OFFSET];
-  size_t len = snprintf(buf, length + WRITE_OFFSET, "B|%d|%s", getpid(), message);
-  ssize_t wbytes = TEMP_FAILURE_RETRY(write(g_trace_marker_fd, buf, len));
-
-  // Error while writing
-  if (static_cast<size_t>(wbytes) != len) {
-    __libc_fatal("Could not write to kernel trace file: %s\n", strerror(errno));
-  }
-}
-
-ScopedTrace::~ScopedTrace() {
-  if (!should_trace()) {
-    return;
-  }
-
-  ssize_t wbytes = TEMP_FAILURE_RETRY(write(g_trace_marker_fd, "E", 1));
-
-  // Error while writing
-  if (static_cast<size_t>(wbytes) != 1) {
-    __libc_fatal("Could not write to kernel trace file: %s\n", strerror(errno));
-  }
-}
diff --git a/libc/bionic/dirent.cpp b/libc/bionic/dirent.cpp
index 5e1c7a5..7abc7f3 100644
--- a/libc/bionic/dirent.cpp
+++ b/libc/bionic/dirent.cpp
@@ -78,7 +78,7 @@
 }
 
 DIR* opendir(const char* path) {
-  int fd = open(path, O_CLOEXEC | O_DIRECTORY | O_RDONLY);
+  int fd = open(path, O_RDONLY | O_DIRECTORY);
   return (fd != -1) ? __allocate_DIR(fd) : NULL;
 }
 
diff --git a/libc/bionic/malloc_debug_qemu.cpp b/libc/bionic/malloc_debug_qemu.cpp
index 2f4949b..b3b604d 100644
--- a/libc/bionic/malloc_debug_qemu.cpp
+++ b/libc/bionic/malloc_debug_qemu.cpp
@@ -606,7 +606,7 @@
      * the memory mapped spaces into writes to an I/O port that emulator
      * "listens to" on the other end. Note that until we open and map that
      * device, logging to emulator's stdout will not be available. */
-    int fd = open("/dev/qemu_trace", O_CLOEXEC | O_RDWR);
+    int fd = open("/dev/qemu_trace", O_RDWR);
     if (fd < 0) {
         error_log("Unable to open /dev/qemu_trace");
         return false;
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index e00ffb4..5461661 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -39,8 +39,6 @@
 #include "private/bionic_futex.h"
 #include "private/bionic_tls.h"
 
-#include "private/bionic_systrace.h"
-
 extern void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex);
 extern void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex);
 
@@ -335,10 +333,6 @@
          * that the mutex is in state 2 when we go to sleep on it, which
          * guarantees a wake-up call.
          */
-
-         ScopedTrace trace("Contending for pthread mutex");
-
-
         while (__bionic_swap(locked_contended, &mutex->value) != unlocked) {
             __futex_wait_ex(&mutex->value, shared, locked_contended, NULL);
         }
@@ -479,8 +473,6 @@
         mvalue = mutex->value;
     }
 
-    ScopedTrace trace("Contending for pthread mutex");
-
     for (;;) {
         int newval;
 
@@ -634,8 +626,6 @@
       return 0;
     }
 
-    ScopedTrace trace("Contending for timed pthread mutex");
-
     // Loop while needed.
     while (__bionic_swap(locked_contended, &mutex->value) != unlocked) {
       if (__timespec_from_absolute(&ts, abs_timeout, clock) < 0) {
@@ -668,8 +658,6 @@
     mvalue = mutex->value;
   }
 
-  ScopedTrace trace("Contending for timed pthread mutex");
-
   while (true) {
     // If the value is 'unlocked', try to acquire it directly.
     // NOTE: put state to 2 since we know there is contention.
diff --git a/libc/bionic/pthread_setname_np.cpp b/libc/bionic/pthread_setname_np.cpp
index 7b2fa6b..1ddf810 100644
--- a/libc/bionic/pthread_setname_np.cpp
+++ b/libc/bionic/pthread_setname_np.cpp
@@ -67,7 +67,7 @@
   }
   char comm_name[sizeof(TASK_COMM_FMT) + 8];
   snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, tid);
-  int fd = open(comm_name, O_CLOEXEC | O_WRONLY);
+  int fd = open(comm_name, O_WRONLY);
   if (fd == -1) {
     return errno;
   }
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp
index 411d6bf..ad69cf5 100644
--- a/libc/bionic/system_properties.cpp
+++ b/libc/bionic/system_properties.cpp
@@ -201,6 +201,14 @@
         return -1;
     }
 
+    // TODO: Is this really required ? Does android run on any kernels that
+    // don't support O_CLOEXEC ?
+    const int ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
+    if (ret < 0) {
+        close(fd);
+        return -1;
+    }
+
     if (ftruncate(fd, PA_SIZE) < 0) {
         close(fd);
         return -1;
@@ -263,9 +271,18 @@
 
 static int map_prop_area()
 {
-    int fd = open(property_filename, O_CLOEXEC | O_NOFOLLOW | O_RDONLY);
+    int fd(open(property_filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC));
+    if (fd >= 0) {
+        /* For old kernels that don't support O_CLOEXEC */
+        const int ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
+        if (ret < 0) {
+            close(fd);
+            return -1;
+        }
+    }
+
     bool close_fd = true;
-    if (fd == -1 && errno == ENOENT) {
+    if ((fd < 0) && (errno == ENOENT)) {
         /*
          * For backwards compatibility, if the file doesn't
          * exist, we use the environment to get the file descriptor.
diff --git a/libc/dns/gethnamaddr.c b/libc/dns/gethnamaddr.c
index cc33c61..0bd838e 100644
--- a/libc/dns/gethnamaddr.c
+++ b/libc/dns/gethnamaddr.c
@@ -565,7 +565,7 @@
 	char buf[4];
 	if (fread(buf, 1, sizeof(buf), proxy) != sizeof(buf)) return NULL;
 
-	/* This is reading serialized data from system/netd/DnsProxyListener.cpp
+	/* This is reading serialized data from system/netd/server/DnsProxyListener.cpp
 	 * and changes here need to be matched there */
 	int result_code = strtol(buf, NULL, 10);
 	if (result_code != DnsProxyQueryResult) {
@@ -763,7 +763,7 @@
 
 	netid = __netdClientDispatch.netIdForResolv(netid);
 
-	/* This is writing to system/netd/DnsProxyListener.cpp and changes
+	/* This is writing to system/netd/server/DnsProxyListener.cpp and changes
 	 * here need to be matched there */
 	if (fprintf(proxy, "gethostbyname %u %s %d",
 			netid,
diff --git a/libc/dns/include/resolv_cache.h b/libc/dns/include/resolv_cache.h
index 16f3e43..e049d95 100644
--- a/libc/dns/include/resolv_cache.h
+++ b/libc/dns/include/resolv_cache.h
@@ -32,11 +32,6 @@
 #include <sys/cdefs.h>
 
 struct __res_state;
-struct resolv_cache;  /* forward */
-
-/* Gets the cache for a network. Returned cache might be NULL. */
-__LIBC_HIDDEN__
-extern struct resolv_cache* __get_res_cache(unsigned netid);
 
 /* sets the name server addresses to the provided res_state structure. The
  * name servers are retrieved from the cache which is associated
@@ -53,7 +48,7 @@
 
 __LIBC_HIDDEN__
 extern ResolvCacheStatus
-_resolv_cache_lookup( struct resolv_cache*  cache,
+_resolv_cache_lookup( unsigned              netid,
                       const void*           query,
                       int                   querylen,
                       void*                 answer,
@@ -65,7 +60,7 @@
  */
 __LIBC_HIDDEN__
 extern void
-_resolv_cache_add( struct resolv_cache*  cache,
+_resolv_cache_add( unsigned              netid,
                    const void*           query,
                    int                   querylen,
                    const void*           answer,
@@ -74,7 +69,7 @@
 /* Notify the cache a request failed */
 __LIBC_HIDDEN__
 extern void
-_resolv_cache_query_failed( struct resolv_cache* cache,
+_resolv_cache_query_failed( unsigned     netid,
                    const void* query,
                    int         querylen);
 
diff --git a/libc/dns/include/resolv_netid.h b/libc/dns/include/resolv_netid.h
index bada18a..e5521b8 100644
--- a/libc/dns/include/resolv_netid.h
+++ b/libc/dns/include/resolv_netid.h
@@ -36,7 +36,7 @@
 #include <netinet/in.h>
 
 /*
- * Passing NETID_UNSET as the netId causes system/netd/DnsProxyListener.cpp to
+ * Passing NETID_UNSET as the netId causes system/netd/server/DnsProxyListener.cpp to
  * fill in the appropriate default netId for the query.
  */
 #define NETID_UNSET 0u
@@ -72,6 +72,9 @@
 int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t,
 		 int, unsigned, unsigned);
 
+/* delete the cache associated with a certain network */
+extern void _resolv_delete_cache_for_net(unsigned netid);
+
 __END_DECLS
 
 #endif /* _RESOLV_NETID_H */
diff --git a/libc/dns/include/resolv_private.h b/libc/dns/include/resolv_private.h
index f4c67f3..a91a4b8 100644
--- a/libc/dns/include/resolv_private.h
+++ b/libc/dns/include/resolv_private.h
@@ -498,6 +498,16 @@
 __LIBC_HIDDEN__ void res_setmark(res_state, unsigned);
 u_int  res_randomid(void);
 
+#ifdef __i386__
+# define __socketcall extern __attribute__((__cdecl__))
+#else
+# define __socketcall extern
+#endif
+
+__socketcall int __connect(int, const struct sockaddr*, socklen_t);
+
+#undef __socketcall
+
 __END_DECLS
 
 #pragma GCC visibility pop
diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c
index a492318..5443999 100644
--- a/libc/dns/net/getaddrinfo.c
+++ b/libc/dns/net/getaddrinfo.c
@@ -369,7 +369,7 @@
 		return 0;
 	int ret;
 	do {
-		ret = connect(s, addr, addrlen);
+		ret = __connect(s, addr, addrlen);
 	} while (ret < 0 && errno == EINTR);
 	int success = (ret == 0);
 	do {
@@ -1803,7 +1803,7 @@
 	if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0)
 		return 0;
 	do {
-		ret = connect(sock, addr, len);
+		ret = __connect(sock, addr, len);
 	} while (ret == -1 && errno == EINTR);
 
 	if (ret == -1) {
diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c
index 9ca5419..4c9deab 100644
--- a/libc/dns/resolv/res_cache.c
+++ b/libc/dns/resolv/res_cache.c
@@ -1218,7 +1218,6 @@
     int              max_entries;
     int              num_entries;
     Entry            mru_list;
-    pthread_mutex_t  lock;
     int              last_id;
     Entry*           entries;
     PendingReqInfo   pending_requests;
@@ -1236,6 +1235,15 @@
 
 #define  HTABLE_VALID(x)  ((x) != NULL && (x) != HTABLE_DELETED)
 
+static pthread_once_t        _res_cache_once = PTHREAD_ONCE_INIT;
+static void _res_cache_init(void);
+
+// lock protecting everything in the _resolve_cache_info structs (next ptr, etc)
+static pthread_mutex_t _res_cache_list_lock;
+
+/* gets cache associated with a network, or NULL if none exists */
+static struct resolv_cache* _find_named_cache_locked(unsigned netid);
+
 static void
 _cache_flush_pending_requests_locked( struct resolv_cache* cache )
 {
@@ -1256,18 +1264,18 @@
     }
 }
 
-/* return 0 if no pending request is found matching the key
- * if a matching request is found the calling thread will wait
- * and return 1 when released */
+/* Return 0 if no pending request is found matching the key.
+ * If a matching request is found the calling thread will wait until
+ * the matching request completes, then update *cache and return 1. */
 static int
-_cache_check_pending_request_locked( struct resolv_cache* cache, Entry* key )
+_cache_check_pending_request_locked( struct resolv_cache** cache, Entry* key, unsigned netid )
 {
     struct pending_req_info *ri, *prev;
     int exist = 0;
 
-    if (cache && key) {
-        ri = cache->pending_requests.next;
-        prev = &cache->pending_requests;
+    if (*cache && key) {
+        ri = (*cache)->pending_requests.next;
+        prev = &(*cache)->pending_requests;
         while (ri) {
             if (ri->hash == key->hash) {
                 exist = 1;
@@ -1288,7 +1296,9 @@
             struct timespec ts = {0,0};
             XLOG("Waiting for previous request");
             ts.tv_sec = _time_now() + PENDING_REQUEST_TIMEOUT;
-            pthread_cond_timedwait(&ri->cond, &cache->lock, &ts);
+            pthread_cond_timedwait(&ri->cond, &_res_cache_list_lock, &ts);
+            /* Must update *cache as it could have been deleted. */
+            *cache = _find_named_cache_locked(netid);
         }
     }
 
@@ -1325,17 +1335,25 @@
 
 /* notify the cache that the query failed */
 void
-_resolv_cache_query_failed( struct resolv_cache* cache,
+_resolv_cache_query_failed( unsigned    netid,
                    const void* query,
                    int         querylen)
 {
     Entry    key[1];
+    Cache*   cache;
 
-    if (cache && entry_init_key(key, query, querylen)) {
-        pthread_mutex_lock(&cache->lock);
+    if (!entry_init_key(key, query, querylen))
+        return;
+
+    pthread_mutex_lock(&_res_cache_list_lock);
+
+    cache = _find_named_cache_locked(netid);
+
+    if (cache) {
         _cache_notify_waiting_tid_locked(cache, key);
-        pthread_mutex_unlock(&cache->lock);
     }
+
+    pthread_mutex_unlock(&_res_cache_list_lock);
 }
 
 static void
@@ -1391,7 +1409,6 @@
         cache->max_entries = _res_cache_get_max_entries();
         cache->entries = calloc(sizeof(*cache->entries), cache->max_entries);
         if (cache->entries) {
-            pthread_mutex_init( &cache->lock, NULL );
             cache->mru_list.mru_prev = cache->mru_list.mru_next = &cache->mru_list;
             XLOG("%s: cache created\n", __FUNCTION__);
         } else {
@@ -1586,7 +1603,7 @@
 }
 
 ResolvCacheStatus
-_resolv_cache_lookup( struct resolv_cache*  cache,
+_resolv_cache_lookup( unsigned              netid,
                       const void*           query,
                       int                   querylen,
                       void*                 answer,
@@ -1597,6 +1614,7 @@
     Entry**    lookup;
     Entry*     e;
     time_t     now;
+    Cache*     cache;
 
     ResolvCacheStatus  result = RESOLV_CACHE_NOTFOUND;
 
@@ -1609,7 +1627,14 @@
         return RESOLV_CACHE_UNSUPPORTED;
     }
     /* lookup cache */
-    pthread_mutex_lock( &cache->lock );
+    pthread_once(&_res_cache_once, _res_cache_init);
+    pthread_mutex_lock(&_res_cache_list_lock);
+
+    cache = _find_named_cache_locked(netid);
+    if (cache == NULL) {
+        result = RESOLV_CACHE_UNSUPPORTED;
+        goto Exit;
+    }
 
     /* see the description of _lookup_p to understand this.
      * the function always return a non-NULL pointer.
@@ -1621,7 +1646,7 @@
         XLOG( "NOT IN CACHE");
         // calling thread will wait if an outstanding request is found
         // that matching this query
-        if (!_cache_check_pending_request_locked(cache, key)) {
+        if (!_cache_check_pending_request_locked(&cache, key, netid) || cache == NULL) {
             goto Exit;
         } else {
             lookup = _cache_lookup_p(cache, key);
@@ -1662,13 +1687,13 @@
     result = RESOLV_CACHE_FOUND;
 
 Exit:
-    pthread_mutex_unlock( &cache->lock );
+    pthread_mutex_unlock(&_res_cache_list_lock);
     return result;
 }
 
 
 void
-_resolv_cache_add( struct resolv_cache*  cache,
+_resolv_cache_add( unsigned              netid,
                    const void*           query,
                    int                   querylen,
                    const void*           answer,
@@ -1678,6 +1703,7 @@
     Entry*   e;
     Entry**  lookup;
     u_long   ttl;
+    Cache*   cache = NULL;
 
     /* don't assume that the query has already been cached
      */
@@ -1686,7 +1712,12 @@
         return;
     }
 
-    pthread_mutex_lock( &cache->lock );
+    pthread_mutex_lock(&_res_cache_list_lock);
+
+    cache = _find_named_cache_locked(netid);
+    if (cache == NULL) {
+        goto Exit;
+    }
 
     XLOG( "%s: query:", __FUNCTION__ );
     XLOG_QUERY(query,querylen);
@@ -1732,8 +1763,10 @@
     _cache_dump_mru(cache);
 #endif
 Exit:
-    _cache_notify_waiting_tid_locked(cache, key);
-    pthread_mutex_unlock( &cache->lock );
+    if (cache != NULL) {
+      _cache_notify_waiting_tid_locked(cache, key);
+    }
+    pthread_mutex_unlock(&_res_cache_list_lock);
 }
 
 /****************************************************************************/
@@ -1744,20 +1777,13 @@
 /****************************************************************************/
 /****************************************************************************/
 
-static pthread_once_t        _res_cache_once = PTHREAD_ONCE_INIT;
-
 // Head of the list of caches.  Protected by _res_cache_list_lock.
 static struct resolv_cache_info _res_cache_list;
 
-// lock protecting everything in the _resolve_cache_info structs (next ptr, etc)
-static pthread_mutex_t _res_cache_list_lock;
-
 /* insert resolv_cache_info into the list of resolv_cache_infos */
 static void _insert_cache_info_locked(struct resolv_cache_info* cache_info);
 /* creates a resolv_cache_info */
 static struct resolv_cache_info* _create_cache_info( void );
-/* gets cache associated with a network, or NULL if none exists */
-static struct resolv_cache* _find_named_cache_locked(unsigned netid);
 /* gets a resolv_cache_info associated with a network, or NULL if not found */
 static struct resolv_cache_info* _find_cache_info_locked(unsigned netid);
 /* look up the named cache, and creates one if needed */
@@ -1785,22 +1811,6 @@
     pthread_mutex_init(&_res_cache_list_lock, NULL);
 }
 
-struct resolv_cache*
-__get_res_cache(unsigned netid)
-{
-    struct resolv_cache *cache;
-
-    pthread_once(&_res_cache_once, _res_cache_init);
-    pthread_mutex_lock(&_res_cache_list_lock);
-
-    /* Does NOT create a cache if it does not exist. */
-    cache = _find_named_cache_locked(netid);
-
-    pthread_mutex_unlock(&_res_cache_list_lock);
-    XLOG("%s: netid=%u, cache=%p\n", __FUNCTION__, netid, cache);
-    return cache;
-}
-
 static struct resolv_cache*
 _get_res_cache_for_net_locked(unsigned netid)
 {
@@ -1837,12 +1847,36 @@
 {
     struct resolv_cache* cache = _find_named_cache_locked(netid);
     if (cache) {
-        pthread_mutex_lock(&cache->lock);
         _cache_flush_locked(cache);
-        pthread_mutex_unlock(&cache->lock);
     }
 }
 
+void _resolv_delete_cache_for_net(unsigned netid)
+{
+    pthread_once(&_res_cache_once, _res_cache_init);
+    pthread_mutex_lock(&_res_cache_list_lock);
+
+    struct resolv_cache_info* prev_cache_info = &_res_cache_list;
+
+    while (prev_cache_info->next) {
+        struct resolv_cache_info* cache_info = prev_cache_info->next;
+
+        if (cache_info->netid == netid) {
+            prev_cache_info->next = cache_info->next;
+            _cache_flush_locked(cache_info->cache);
+            free(cache_info->cache->entries);
+            free(cache_info->cache);
+            _free_nameservers_locked(cache_info);
+            free(cache_info);
+            break;
+        }
+
+        prev_cache_info = prev_cache_info->next;
+    }
+
+    pthread_mutex_unlock(&_res_cache_list_lock);
+}
+
 static struct resolv_cache_info*
 _create_cache_info(void)
 {
diff --git a/libc/dns/resolv/res_send.c b/libc/dns/resolv/res_send.c
index de09385..6439e31 100644
--- a/libc/dns/resolv/res_send.c
+++ b/libc/dns/resolv/res_send.c
@@ -367,7 +367,6 @@
 	int gotsomewhere, terrno, try, v_circuit, resplen, ns, n;
 	char abuf[NI_MAXHOST];
 #if USE_RESOLV_CACHE
-        struct resolv_cache*  cache;
         ResolvCacheStatus     cache_status = RESOLV_CACHE_UNSUPPORTED;
 #endif
 
@@ -389,21 +388,17 @@
 	terrno = ETIMEDOUT;
 
 #if USE_RESOLV_CACHE
-	// get the cache associated with the network
-	cache = __get_res_cache(statp->netid);
-	if (cache != NULL) {
-		int  anslen = 0;
-		cache_status = _resolv_cache_lookup(
-				cache, buf, buflen,
-				ans, anssiz, &anslen);
+	int  anslen = 0;
+	cache_status = _resolv_cache_lookup(
+			statp->netid, buf, buflen,
+			ans, anssiz, &anslen);
 
-		if (cache_status == RESOLV_CACHE_FOUND) {
-			return anslen;
-		} else {
-			// had a cache miss for a known network, so populate the thread private
-			// data so the normal resolve path can do its thing
-			_resolv_populate_res_for_net(statp);
-		}
+	if (cache_status == RESOLV_CACHE_FOUND) {
+		return anslen;
+	} else if (cache_status != RESOLV_CACHE_UNSUPPORTED) {
+		// had a cache miss for a known network, so populate the thread private
+		// data so the normal resolve path can do its thing
+		_resolv_populate_res_for_net(statp);
 	}
 
 	if (statp->nscount == 0) {
@@ -602,7 +597,7 @@
 
 #if USE_RESOLV_CACHE
                 if (cache_status == RESOLV_CACHE_NOTFOUND) {
-                    _resolv_cache_add(cache, buf, buflen,
+                    _resolv_cache_add(statp->netid, buf, buflen,
                                       ans, resplen);
                 }
 #endif
@@ -658,13 +653,13 @@
 		errno = terrno;
 
 #if USE_RESOLV_CACHE
-        _resolv_cache_query_failed(cache, buf, buflen);
+        _resolv_cache_query_failed(statp->netid, buf, buflen);
 #endif
 
 	return (-1);
  fail:
 #if USE_RESOLV_CACHE
-	_resolv_cache_query_failed(cache, buf, buflen);
+	_resolv_cache_query_failed(statp->netid, buf, buflen);
 #endif
 	res_nclose(statp);
 	return (-1);
@@ -951,7 +946,7 @@
 	origflags = fcntl(sock, F_GETFL, 0);
 	fcntl(sock, F_SETFL, origflags | O_NONBLOCK);
 
-	res = connect(sock, nsap, salen);
+	res = __connect(sock, nsap, salen);
 	if (res < 0 && errno != EINPROGRESS) {
                 res = -1;
                 goto done;
@@ -1108,7 +1103,7 @@
 			res_nclose(statp);
 			return (0);
 		}
-		if (connect(EXT(statp).nssocks[ns], nsap, (socklen_t)nsaplen) < 0) {
+		if (__connect(EXT(statp).nssocks[ns], nsap, (socklen_t)nsaplen) < 0) {
 			Aerror(statp, stderr, "connect(dg)", errno, nsap,
 			    nsaplen);
 			res_nclose(statp);
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index ce60fd7..594d231 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -66,10 +66,17 @@
  */
 
 /* stdio buffers */
+#if defined(__LP64__)
+struct __sbuf {
+  unsigned char* _base;
+  size_t _size;
+};
+#else
 struct __sbuf {
 	unsigned char *_base;
 	int	_size;
 };
+#endif
 
 /*
  * stdio state variables.
@@ -102,8 +109,13 @@
 	unsigned char *_p;	/* current position in (some) buffer */
 	int	_r;		/* read space left for getc() */
 	int	_w;		/* write space left for putc() */
+#if defined(__LP64__)
+	int	_flags;		/* flags, below; this FILE is free if 0 */
+	int	_file;		/* fileno, if Unix descriptor, else -1 */
+#else
 	short	_flags;		/* flags, below; this FILE is free if 0 */
 	short	_file;		/* fileno, if Unix descriptor, else -1 */
+#endif
 	struct	__sbuf _bf;	/* the buffer (at least 1 byte, if !NULL) */
 	int	_lbfsize;	/* 0 or -_bf._size, for inline putc */
 
diff --git a/libc/kernel/uapi/linux/input.h b/libc/kernel/uapi/linux/input.h
index df3200c..b9d5b2a 100644
--- a/libc/kernel/uapi/linux/input.h
+++ b/libc/kernel/uapi/linux/input.h
@@ -97,629 +97,644 @@
 #define INPUT_PROP_BUTTONPAD 0x02
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define INPUT_PROP_SEMI_MT 0x03
+#define INPUT_PROP_TOPBUTTONPAD 0x04
 #define INPUT_PROP_MAX 0x1f
 #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
-#define EV_SYN 0x00
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EV_SYN 0x00
 #define EV_KEY 0x01
 #define EV_REL 0x02
 #define EV_ABS 0x03
-#define EV_MSC 0x04
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EV_MSC 0x04
 #define EV_SW 0x05
 #define EV_LED 0x11
 #define EV_SND 0x12
-#define EV_REP 0x14
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EV_REP 0x14
 #define EV_FF 0x15
 #define EV_PWR 0x16
 #define EV_FF_STATUS 0x17
-#define EV_MAX 0x1f
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define EV_MAX 0x1f
 #define EV_CNT (EV_MAX+1)
 #define SYN_REPORT 0
 #define SYN_CONFIG 1
-#define SYN_MT_REPORT 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SYN_MT_REPORT 2
 #define SYN_DROPPED 3
 #define SYN_MAX 0xf
 #define SYN_CNT (SYN_MAX+1)
-#define KEY_RESERVED 0
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_RESERVED 0
 #define KEY_ESC 1
 #define KEY_1 2
 #define KEY_2 3
-#define KEY_3 4
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_3 4
 #define KEY_4 5
 #define KEY_5 6
 #define KEY_6 7
-#define KEY_7 8
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_7 8
 #define KEY_8 9
 #define KEY_9 10
 #define KEY_0 11
-#define KEY_MINUS 12
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_MINUS 12
 #define KEY_EQUAL 13
 #define KEY_BACKSPACE 14
 #define KEY_TAB 15
-#define KEY_Q 16
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_Q 16
 #define KEY_W 17
 #define KEY_E 18
 #define KEY_R 19
-#define KEY_T 20
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_T 20
 #define KEY_Y 21
 #define KEY_U 22
 #define KEY_I 23
-#define KEY_O 24
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_O 24
 #define KEY_P 25
 #define KEY_LEFTBRACE 26
 #define KEY_RIGHTBRACE 27
-#define KEY_ENTER 28
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_ENTER 28
 #define KEY_LEFTCTRL 29
 #define KEY_A 30
 #define KEY_S 31
-#define KEY_D 32
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_D 32
 #define KEY_F 33
 #define KEY_G 34
 #define KEY_H 35
-#define KEY_J 36
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_J 36
 #define KEY_K 37
 #define KEY_L 38
 #define KEY_SEMICOLON 39
-#define KEY_APOSTROPHE 40
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_APOSTROPHE 40
 #define KEY_GRAVE 41
 #define KEY_LEFTSHIFT 42
 #define KEY_BACKSLASH 43
-#define KEY_Z 44
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_Z 44
 #define KEY_X 45
 #define KEY_C 46
 #define KEY_V 47
-#define KEY_B 48
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_B 48
 #define KEY_N 49
 #define KEY_M 50
 #define KEY_COMMA 51
-#define KEY_DOT 52
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_DOT 52
 #define KEY_SLASH 53
 #define KEY_RIGHTSHIFT 54
 #define KEY_KPASTERISK 55
-#define KEY_LEFTALT 56
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_LEFTALT 56
 #define KEY_SPACE 57
 #define KEY_CAPSLOCK 58
 #define KEY_F1 59
-#define KEY_F2 60
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_F2 60
 #define KEY_F3 61
 #define KEY_F4 62
 #define KEY_F5 63
-#define KEY_F6 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_F6 64
 #define KEY_F7 65
 #define KEY_F8 66
 #define KEY_F9 67
-#define KEY_F10 68
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_F10 68
 #define KEY_NUMLOCK 69
 #define KEY_SCROLLLOCK 70
 #define KEY_KP7 71
-#define KEY_KP8 72
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KP8 72
 #define KEY_KP9 73
 #define KEY_KPMINUS 74
 #define KEY_KP4 75
-#define KEY_KP5 76
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KP5 76
 #define KEY_KP6 77
 #define KEY_KPPLUS 78
 #define KEY_KP1 79
-#define KEY_KP2 80
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KP2 80
 #define KEY_KP3 81
 #define KEY_KP0 82
 #define KEY_KPDOT 83
-#define KEY_ZENKAKUHANKAKU 85
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_ZENKAKUHANKAKU 85
 #define KEY_102ND 86
 #define KEY_F11 87
 #define KEY_F12 88
-#define KEY_RO 89
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_RO 89
 #define KEY_KATAKANA 90
 #define KEY_HIRAGANA 91
 #define KEY_HENKAN 92
-#define KEY_KATAKANAHIRAGANA 93
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KATAKANAHIRAGANA 93
 #define KEY_MUHENKAN 94
 #define KEY_KPJPCOMMA 95
 #define KEY_KPENTER 96
-#define KEY_RIGHTCTRL 97
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_RIGHTCTRL 97
 #define KEY_KPSLASH 98
 #define KEY_SYSRQ 99
 #define KEY_RIGHTALT 100
-#define KEY_LINEFEED 101
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_LINEFEED 101
 #define KEY_HOME 102
 #define KEY_UP 103
 #define KEY_PAGEUP 104
-#define KEY_LEFT 105
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_LEFT 105
 #define KEY_RIGHT 106
 #define KEY_END 107
 #define KEY_DOWN 108
-#define KEY_PAGEDOWN 109
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_PAGEDOWN 109
 #define KEY_INSERT 110
 #define KEY_DELETE 111
 #define KEY_MACRO 112
-#define KEY_MUTE 113
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_MUTE 113
 #define KEY_VOLUMEDOWN 114
 #define KEY_VOLUMEUP 115
 #define KEY_POWER 116
-#define KEY_KPEQUAL 117
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KPEQUAL 117
 #define KEY_KPPLUSMINUS 118
 #define KEY_PAUSE 119
 #define KEY_SCALE 120
-#define KEY_KPCOMMA 121
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KPCOMMA 121
 #define KEY_HANGEUL 122
 #define KEY_HANGUEL KEY_HANGEUL
 #define KEY_HANJA 123
-#define KEY_YEN 124
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_YEN 124
 #define KEY_LEFTMETA 125
 #define KEY_RIGHTMETA 126
 #define KEY_COMPOSE 127
-#define KEY_STOP 128
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_STOP 128
 #define KEY_AGAIN 129
 #define KEY_PROPS 130
 #define KEY_UNDO 131
-#define KEY_FRONT 132
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_FRONT 132
 #define KEY_COPY 133
 #define KEY_OPEN 134
 #define KEY_PASTE 135
-#define KEY_FIND 136
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_FIND 136
 #define KEY_CUT 137
 #define KEY_HELP 138
 #define KEY_MENU 139
-#define KEY_CALC 140
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_CALC 140
 #define KEY_SETUP 141
 #define KEY_SLEEP 142
 #define KEY_WAKEUP 143
-#define KEY_FILE 144
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_FILE 144
 #define KEY_SENDFILE 145
 #define KEY_DELETEFILE 146
 #define KEY_XFER 147
-#define KEY_PROG1 148
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_PROG1 148
 #define KEY_PROG2 149
 #define KEY_WWW 150
 #define KEY_MSDOS 151
-#define KEY_COFFEE 152
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_COFFEE 152
 #define KEY_SCREENLOCK KEY_COFFEE
 #define KEY_DIRECTION 153
 #define KEY_CYCLEWINDOWS 154
-#define KEY_MAIL 155
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_MAIL 155
 #define KEY_BOOKMARKS 156
 #define KEY_COMPUTER 157
 #define KEY_BACK 158
-#define KEY_FORWARD 159
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_FORWARD 159
 #define KEY_CLOSECD 160
 #define KEY_EJECTCD 161
 #define KEY_EJECTCLOSECD 162
-#define KEY_NEXTSONG 163
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_NEXTSONG 163
 #define KEY_PLAYPAUSE 164
 #define KEY_PREVIOUSSONG 165
 #define KEY_STOPCD 166
-#define KEY_RECORD 167
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_RECORD 167
 #define KEY_REWIND 168
 #define KEY_PHONE 169
 #define KEY_ISO 170
-#define KEY_CONFIG 171
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_CONFIG 171
 #define KEY_HOMEPAGE 172
 #define KEY_REFRESH 173
 #define KEY_EXIT 174
-#define KEY_MOVE 175
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_MOVE 175
 #define KEY_EDIT 176
 #define KEY_SCROLLUP 177
 #define KEY_SCROLLDOWN 178
-#define KEY_KPLEFTPAREN 179
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KPLEFTPAREN 179
 #define KEY_KPRIGHTPAREN 180
 #define KEY_NEW 181
 #define KEY_REDO 182
-#define KEY_F13 183
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_F13 183
 #define KEY_F14 184
 #define KEY_F15 185
 #define KEY_F16 186
-#define KEY_F17 187
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_F17 187
 #define KEY_F18 188
 #define KEY_F19 189
 #define KEY_F20 190
-#define KEY_F21 191
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_F21 191
 #define KEY_F22 192
 #define KEY_F23 193
 #define KEY_F24 194
-#define KEY_PLAYCD 200
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_PLAYCD 200
 #define KEY_PAUSECD 201
 #define KEY_PROG3 202
 #define KEY_PROG4 203
-#define KEY_DASHBOARD 204
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_DASHBOARD 204
 #define KEY_SUSPEND 205
 #define KEY_CLOSE 206
 #define KEY_PLAY 207
-#define KEY_FASTFORWARD 208
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_FASTFORWARD 208
 #define KEY_BASSBOOST 209
 #define KEY_PRINT 210
 #define KEY_HP 211
-#define KEY_CAMERA 212
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_CAMERA 212
 #define KEY_SOUND 213
 #define KEY_QUESTION 214
 #define KEY_EMAIL 215
-#define KEY_CHAT 216
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_CHAT 216
 #define KEY_SEARCH 217
 #define KEY_CONNECT 218
 #define KEY_FINANCE 219
-#define KEY_SPORT 220
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_SPORT 220
 #define KEY_SHOP 221
 #define KEY_ALTERASE 222
 #define KEY_CANCEL 223
-#define KEY_BRIGHTNESSDOWN 224
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_BRIGHTNESSDOWN 224
 #define KEY_BRIGHTNESSUP 225
 #define KEY_MEDIA 226
 #define KEY_SWITCHVIDEOMODE 227
-#define KEY_KBDILLUMTOGGLE 228
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_KBDILLUMTOGGLE 228
 #define KEY_KBDILLUMDOWN 229
 #define KEY_KBDILLUMUP 230
 #define KEY_SEND 231
-#define KEY_REPLY 232
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_REPLY 232
 #define KEY_FORWARDMAIL 233
 #define KEY_SAVE 234
 #define KEY_DOCUMENTS 235
-#define KEY_BATTERY 236
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_BATTERY 236
 #define KEY_BLUETOOTH 237
 #define KEY_WLAN 238
 #define KEY_UWB 239
-#define KEY_UNKNOWN 240
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_UNKNOWN 240
 #define KEY_VIDEO_NEXT 241
 #define KEY_VIDEO_PREV 242
 #define KEY_BRIGHTNESS_CYCLE 243
-#define KEY_BRIGHTNESS_ZERO 244
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_BRIGHTNESS_AUTO 244
+#define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO
 #define KEY_DISPLAY_OFF 245
 #define KEY_WWAN 246
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_WIMAX KEY_WWAN
 #define KEY_RFKILL 247
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_MICMUTE 248
 #define BTN_MISC 0x100
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_0 0x100
 #define BTN_1 0x101
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_2 0x102
 #define BTN_3 0x103
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_4 0x104
 #define BTN_5 0x105
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_6 0x106
 #define BTN_7 0x107
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_8 0x108
 #define BTN_9 0x109
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_MOUSE 0x110
 #define BTN_LEFT 0x110
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_RIGHT 0x111
 #define BTN_MIDDLE 0x112
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_SIDE 0x113
 #define BTN_EXTRA 0x114
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_FORWARD 0x115
 #define BTN_BACK 0x116
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TASK 0x117
 #define BTN_JOYSTICK 0x120
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER 0x120
 #define BTN_THUMB 0x121
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_THUMB2 0x122
 #define BTN_TOP 0x123
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOP2 0x124
 #define BTN_PINKIE 0x125
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_BASE 0x126
 #define BTN_BASE2 0x127
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_BASE3 0x128
 #define BTN_BASE4 0x129
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_BASE5 0x12a
 #define BTN_BASE6 0x12b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_DEAD 0x12f
 #define BTN_GAMEPAD 0x130
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_SOUTH 0x130
 #define BTN_A BTN_SOUTH
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_EAST 0x131
 #define BTN_B BTN_EAST
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_C 0x132
 #define BTN_NORTH 0x133
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_X BTN_NORTH
 #define BTN_WEST 0x134
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_Y BTN_WEST
 #define BTN_Z 0x135
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TL 0x136
 #define BTN_TR 0x137
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TL2 0x138
 #define BTN_TR2 0x139
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_SELECT 0x13a
 #define BTN_START 0x13b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_MODE 0x13c
 #define BTN_THUMBL 0x13d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_THUMBR 0x13e
 #define BTN_DIGI 0x140
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_PEN 0x140
 #define BTN_TOOL_RUBBER 0x141
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_BRUSH 0x142
 #define BTN_TOOL_PENCIL 0x143
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_AIRBRUSH 0x144
 #define BTN_TOOL_FINGER 0x145
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_MOUSE 0x146
 #define BTN_TOOL_LENS 0x147
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_QUINTTAP 0x148
 #define BTN_TOUCH 0x14a
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_STYLUS 0x14b
 #define BTN_STYLUS2 0x14c
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_DOUBLETAP 0x14d
 #define BTN_TOOL_TRIPLETAP 0x14e
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TOOL_QUADTAP 0x14f
 #define BTN_WHEEL 0x150
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_GEAR_DOWN 0x150
 #define BTN_GEAR_UP 0x151
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_OK 0x160
 #define KEY_SELECT 0x161
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_GOTO 0x162
 #define KEY_CLEAR 0x163
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_POWER2 0x164
 #define KEY_OPTION 0x165
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_INFO 0x166
 #define KEY_TIME 0x167
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_VENDOR 0x168
 #define KEY_ARCHIVE 0x169
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_PROGRAM 0x16a
 #define KEY_CHANNEL 0x16b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FAVORITES 0x16c
 #define KEY_EPG 0x16d
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_PVR 0x16e
 #define KEY_MHP 0x16f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_LANGUAGE 0x170
 #define KEY_TITLE 0x171
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_SUBTITLE 0x172
 #define KEY_ANGLE 0x173
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_ZOOM 0x174
 #define KEY_MODE 0x175
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_KEYBOARD 0x176
 #define KEY_SCREEN 0x177
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_PC 0x178
 #define KEY_TV 0x179
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_TV2 0x17a
 #define KEY_VCR 0x17b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_VCR2 0x17c
 #define KEY_SAT 0x17d
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_SAT2 0x17e
 #define KEY_CD 0x17f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_TAPE 0x180
 #define KEY_RADIO 0x181
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_TUNER 0x182
 #define KEY_PLAYER 0x183
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_TEXT 0x184
 #define KEY_DVD 0x185
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_AUX 0x186
 #define KEY_MP3 0x187
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_AUDIO 0x188
 #define KEY_VIDEO 0x189
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DIRECTORY 0x18a
 #define KEY_LIST 0x18b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_MEMO 0x18c
 #define KEY_CALENDAR 0x18d
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_RED 0x18e
 #define KEY_GREEN 0x18f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_YELLOW 0x190
 #define KEY_BLUE 0x191
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_CHANNELUP 0x192
 #define KEY_CHANNELDOWN 0x193
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FIRST 0x194
 #define KEY_LAST 0x195
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_AB 0x196
 #define KEY_NEXT 0x197
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_RESTART 0x198
 #define KEY_SLOW 0x199
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_SHUFFLE 0x19a
 #define KEY_BREAK 0x19b
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_PREVIOUS 0x19c
 #define KEY_DIGITS 0x19d
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_TEEN 0x19e
 #define KEY_TWEN 0x19f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_VIDEOPHONE 0x1a0
 #define KEY_GAMES 0x1a1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_ZOOMIN 0x1a2
 #define KEY_ZOOMOUT 0x1a3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_ZOOMRESET 0x1a4
 #define KEY_WORDPROCESSOR 0x1a5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_EDITOR 0x1a6
 #define KEY_SPREADSHEET 0x1a7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_GRAPHICSEDITOR 0x1a8
 #define KEY_PRESENTATION 0x1a9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DATABASE 0x1aa
 #define KEY_NEWS 0x1ab
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_VOICEMAIL 0x1ac
 #define KEY_ADDRESSBOOK 0x1ad
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_MESSENGER 0x1ae
 #define KEY_DISPLAYTOGGLE 0x1af
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE
 #define KEY_SPELLCHECK 0x1b0
 #define KEY_LOGOFF 0x1b1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DOLLAR 0x1b2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_EURO 0x1b3
 #define KEY_FRAMEBACK 0x1b4
 #define KEY_FRAMEFORWARD 0x1b5
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_CONTEXT_MENU 0x1b6
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_MEDIA_REPEAT 0x1b7
 #define KEY_10CHANNELSUP 0x1b8
 #define KEY_10CHANNELSDOWN 0x1b9
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_IMAGES 0x1ba
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DEL_EOL 0x1c0
 #define KEY_DEL_EOS 0x1c1
 #define KEY_INS_LINE 0x1c2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_DEL_LINE 0x1c3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN 0x1d0
 #define KEY_FN_ESC 0x1d1
 #define KEY_FN_F1 0x1d2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_F2 0x1d3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_F3 0x1d4
 #define KEY_FN_F4 0x1d5
 #define KEY_FN_F5 0x1d6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_F6 0x1d7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_F7 0x1d8
 #define KEY_FN_F8 0x1d9
 #define KEY_FN_F9 0x1da
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_F10 0x1db
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_F11 0x1dc
 #define KEY_FN_F12 0x1dd
 #define KEY_FN_1 0x1de
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_2 0x1df
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_D 0x1e0
 #define KEY_FN_E 0x1e1
 #define KEY_FN_F 0x1e2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_S 0x1e3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_FN_B 0x1e4
 #define KEY_BRL_DOT1 0x1f1
 #define KEY_BRL_DOT2 0x1f2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_BRL_DOT3 0x1f3
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_BRL_DOT4 0x1f4
 #define KEY_BRL_DOT5 0x1f5
 #define KEY_BRL_DOT6 0x1f6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_BRL_DOT7 0x1f7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_BRL_DOT8 0x1f8
 #define KEY_BRL_DOT9 0x1f9
 #define KEY_BRL_DOT10 0x1fa
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_NUMERIC_0 0x200
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_NUMERIC_1 0x201
 #define KEY_NUMERIC_2 0x202
 #define KEY_NUMERIC_3 0x203
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_NUMERIC_4 0x204
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_NUMERIC_5 0x205
 #define KEY_NUMERIC_6 0x206
 #define KEY_NUMERIC_7 0x207
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_NUMERIC_8 0x208
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_NUMERIC_9 0x209
 #define KEY_NUMERIC_STAR 0x20a
 #define KEY_NUMERIC_POUND 0x20b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_CAMERA_FOCUS 0x210
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_WPS_BUTTON 0x211
 #define KEY_TOUCHPAD_TOGGLE 0x212
 #define KEY_TOUCHPAD_ON 0x213
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_TOUCHPAD_OFF 0x214
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_CAMERA_ZOOMIN 0x215
 #define KEY_CAMERA_ZOOMOUT 0x216
 #define KEY_CAMERA_UP 0x217
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_CAMERA_DOWN 0x218
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_CAMERA_LEFT 0x219
 #define KEY_CAMERA_RIGHT 0x21a
 #define KEY_ATTENDANT_ON 0x21b
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_ATTENDANT_OFF 0x21c
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KEY_ATTENDANT_TOGGLE 0x21d
 #define KEY_LIGHTS_TOGGLE 0x21e
 #define BTN_DPAD_UP 0x220
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_DPAD_DOWN 0x221
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_DPAD_LEFT 0x222
 #define BTN_DPAD_RIGHT 0x223
 #define KEY_ALS_TOGGLE 0x230
+#define KEY_BUTTONCONFIG 0x240
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_TASKMANAGER 0x241
+#define KEY_JOURNAL 0x242
+#define KEY_CONTROLPANEL 0x243
+#define KEY_APPSELECT 0x244
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define KEY_SCREENSAVER 0x245
+#define KEY_VOICECOMMAND 0x246
+#define KEY_BRIGHTNESS_MIN 0x250
+#define KEY_BRIGHTNESS_MAX 0x251
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define BTN_TRIGGER_HAPPY 0x2c0
 #define BTN_TRIGGER_HAPPY1 0x2c0
diff --git a/libc/kernel/uapi/linux/ion.h b/libc/kernel/uapi/linux/ion.h
index f18939d..5af39d0 100644
--- a/libc/kernel/uapi/linux/ion.h
+++ b/libc/kernel/uapi/linux/ion.h
@@ -16,56 +16,63 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _LINUX_ION_H
-#define _LINUX_ION_H
+#ifndef _UAPI_LINUX_ION_H
+#define _UAPI_LINUX_ION_H
+#include <linux/ioctl.h>
 #include <linux/types.h>
-struct ion_handle;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+typedef int ion_user_handle_t;
 enum ion_heap_type {
  ION_HEAP_TYPE_SYSTEM,
  ION_HEAP_TYPE_SYSTEM_CONTIG,
- ION_HEAP_TYPE_CARVEOUT,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ ION_HEAP_TYPE_CARVEOUT,
+ ION_HEAP_TYPE_CHUNK,
+ ION_HEAP_TYPE_DMA,
  ION_HEAP_TYPE_CUSTOM,
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  ION_NUM_HEAPS = 16,
 };
 #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
-#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
-#define ION_FLAG_CACHED 1
-#define ION_FLAG_CACHED_NEEDS_SYNC 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
+#define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA)
+#define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8
+#define ION_FLAG_CACHED 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ION_FLAG_CACHED_NEEDS_SYNC 2
 struct ion_allocation_data {
  size_t len;
  size_t align;
- unsigned int heap_mask;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned int heap_id_mask;
  unsigned int flags;
- struct ion_handle *handle;
+ ion_user_handle_t handle;
 };
-struct ion_fd_data {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- struct ion_handle *handle;
+struct ion_fd_data {
+ ion_user_handle_t handle;
  int fd;
 };
-struct ion_handle_data {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- struct ion_handle *handle;
+struct ion_handle_data {
+ ion_user_handle_t handle;
 };
 struct ion_custom_data {
- unsigned int cmd;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned int cmd;
  unsigned long arg;
 };
 #define ION_IOC_MAGIC 'I'
-#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0,   struct ion_allocation_data)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0,   struct ion_allocation_data)
 #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
 #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data)
 #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
-#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
 #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
 #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/private/bionic_systrace.h b/libc/private/bionic_systrace.h
deleted file mode 100644
index 0b4560f..0000000
--- a/libc/private/bionic_systrace.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef BIONIC_SYSTRACE_H
-#define BIONIC_SYSTRACE_H
-
-#include "bionic_macros.h"
-
-// Tracing class for bionic. To begin a trace at a specified point:
-//   ScopedTrace("Trace message");
-// The trace will end when the contructor goes out of scope.
-
-class __LIBC_HIDDEN__ ScopedTrace {
- public:
-  explicit ScopedTrace(const char* message);
-  ~ScopedTrace();
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(ScopedTrace);
-};
-
-#endif