am c7b54666: Merge remote branch \'goog/honeycomb-mr2\' into honeycomb-LTE

* commit 'c7b54666e097fbc102ac6754da99e1513f60d5ea':
  Update to tzdata2011g.
diff --git a/libc/arch-x86/bionic/syscall.S b/libc/arch-x86/bionic/syscall.S
index 71abe6b..3cca85c 100644
--- a/libc/arch-x86/bionic/syscall.S
+++ b/libc/arch-x86/bionic/syscall.S
@@ -20,18 +20,15 @@
     .align 4
 
 syscall:
-    push    %eax
     push    %ebx
-    push    %ecx
-    push    %edx
     push    %esi
     push    %edi
-    mov     28(%esp),%eax
-    mov     32(%esp),%ebx
-    mov     36(%esp),%ecx
-    mov     40(%esp),%edx
-    mov     44(%esp),%esi
-    mov     48(%esp),%edi
+    mov     16(%esp),%eax
+    mov     20(%esp),%ebx
+    mov     24(%esp),%ecx
+    mov     28(%esp),%edx
+    mov     32(%esp),%esi
+    mov     36(%esp),%edi
 
     int     $0x80
 
@@ -45,8 +42,5 @@
 1:
     pop    %edi
     pop    %esi
-    pop    %edx
-    pop    %ecx
     pop    %ebx
-    pop    %eax
     ret
diff --git a/libc/bionic/malloc_debug_common.c b/libc/bionic/malloc_debug_common.c
index ebf0006..b9fcbc4 100644
--- a/libc/bionic/malloc_debug_common.c
+++ b/libc/bionic/malloc_debug_common.c
@@ -84,7 +84,6 @@
         //
         // This is used for sorting, not determination of equality, so we don't
         // need to compare the bit flags.
-        int result;
         if (alloc1 > alloc2) {
             result = -1;
         } else if (alloc1 < alloc2) {
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 9b6da31..92035d4 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -79,7 +79,7 @@
 #define	___STRING(x)	__STRING(x)
 #define	___CONCAT(x,y)	__CONCAT(x,y)
 
-#if __STDC__ || defined(__cplusplus)
+#if defined(__STDC__) || defined(__cplusplus)
 #define	__P(protos)	protos		/* full-blown ANSI C */
 #define	__CONCAT(x,y)	x ## y
 #define	__STRING(x)	#x
@@ -213,7 +213,7 @@
  * C99 defines the restrict type qualifier keyword, which was made available
  * in GCC 2.92.
  */
-#if __STDC_VERSION__ >= 199901L
+#if defined(__STDC__VERSION__) && __STDC_VERSION__ >= 199901L
 #define	__restrict	restrict
 #else
 #if !__GNUC_PREREQ__(2, 92)
@@ -225,7 +225,7 @@
  * C99 defines __func__ predefined identifier, which was made available
  * in GCC 2.95.
  */
-#if !(__STDC_VERSION__ >= 199901L)
+#if !defined(__STDC_VERSION__) || !(__STDC_VERSION__ >= 199901L)
 #if __GNUC_PREREQ__(2, 6)
 #define	__func__	__PRETTY_FUNCTION__
 #elif __GNUC_PREREQ__(2, 4)
diff --git a/libc/netbsd/resolv/res_cache.c b/libc/netbsd/resolv/res_cache.c
index f0c51ab..e6302ed 100644
--- a/libc/netbsd/resolv/res_cache.c
+++ b/libc/netbsd/resolv/res_cache.c
@@ -34,6 +34,7 @@
 
 #include <errno.h>
 #include "arpa_nameser.h"
+#include <sys/system_properties.h>
 
 /* This code implements a small and *simple* DNS resolver cache.
  *
@@ -106,7 +107,7 @@
  */
 #define  CONFIG_SECONDS    (60*10)    /* 10 minutes */
 
-/* maximum number of entries kept in the cache. This value has been
+/* default number of entries kept in the cache. This value has been
  * determined by browsing through various sites and counting the number
  * of corresponding requests. Keep in mind that our framework is currently
  * performing two requests per name lookup (one for IPv4, the other for IPv6)
@@ -125,10 +126,16 @@
  * most high-level websites use lots of media/ad servers with different names
  * but these are generally reused when browsing through the site.
  *
- * As such, a valud of 64 should be relatively conformtable at the moment.
+ * As such, a value of 64 should be relatively comfortable at the moment.
+ *
+ * The system property ro.net.dns_cache_size can be used to override the default
+ * value with a custom value
  */
 #define  CONFIG_MAX_ENTRIES    64
 
+/* name of the system property that can be used to set the cache size */
+#define  DNS_CACHE_SIZE_PROP_NAME   "ro.net.dns_cache_size"
+
 /****************************************************************************/
 /****************************************************************************/
 /*****                                                                  *****/
@@ -1147,15 +1154,15 @@
  * for simplicity, the hash-table fields 'hash' and 'hlink' are
  * inlined in the Entry structure.
  */
-#define  MAX_HASH_ENTRIES   (2*CONFIG_MAX_ENTRIES)
 
 typedef struct resolv_cache {
+    int              max_entries;
     int              num_entries;
     Entry            mru_list;
     pthread_mutex_t  lock;
     unsigned         generation;
     int              last_id;
-    Entry*           entries[ MAX_HASH_ENTRIES ];
+    Entry*           entries;
 } Cache;
 
 
@@ -1167,9 +1174,9 @@
     int     nn;
     time_t  now = _time_now();
 
-    for (nn = 0; nn < MAX_HASH_ENTRIES; nn++) 
+    for (nn = 0; nn < cache->max_entries; nn++)
     {
-        Entry**  pnode = &cache->entries[nn];
+        Entry**  pnode = (Entry**) &cache->entries[nn];
 
         while (*pnode != NULL) {
             Entry*  node = *pnode;
@@ -1187,6 +1194,30 @@
          "*************************");
 }
 
+/* Return max number of entries allowed in the cache,
+ * i.e. cache size. The cache size is either defined
+ * by system property ro.net.dns_cache_size or by
+ * CONFIG_MAX_ENTRIES if system property not set
+ * or set to invalid value. */
+static int
+_res_cache_get_max_entries( void )
+{
+    int result = -1;
+    char cache_size[PROP_VALUE_MAX];
+
+    if (__system_property_get(DNS_CACHE_SIZE_PROP_NAME, cache_size) > 0) {
+        result = atoi(cache_size);
+    }
+
+    // ro.net.dns_cache_size not set or set to negative value
+    if (result <= 0) {
+        result = CONFIG_MAX_ENTRIES;
+    }
+
+    XLOG("cache size: %d", result);
+    return result;
+}
+
 static struct resolv_cache*
 _resolv_cache_create( void )
 {
@@ -1194,10 +1225,17 @@
 
     cache = calloc(sizeof(*cache), 1);
     if (cache) {
-        cache->generation = ~0U;
-        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__);
+        cache->max_entries = _res_cache_get_max_entries();
+        cache->entries = calloc(sizeof(*cache->entries), cache->max_entries);
+        if (cache->entries) {
+            cache->generation = ~0U;
+            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 {
+            free(cache);
+            cache = NULL;
+        }
     }
     return cache;
 }
@@ -1288,8 +1326,8 @@
 _cache_lookup_p( Cache*   cache,
                  Entry*   key )
 {
-    int      index = key->hash % MAX_HASH_ENTRIES;
-    Entry**  pnode = &cache->entries[ key->hash % MAX_HASH_ENTRIES ];
+    int      index = key->hash % cache->max_entries;
+    Entry**  pnode = (Entry**) &cache->entries[ index ];
 
     while (*pnode != NULL) {
         Entry*  node = *pnode;
@@ -1470,7 +1508,7 @@
         goto Exit;
     }
 
-    if (cache->num_entries >= CONFIG_MAX_ENTRIES) {
+    if (cache->num_entries >= cache->max_entries) {
         _cache_remove_oldest(cache);
         /* need to lookup again */
         lookup = _cache_lookup_p(cache, key);
diff --git a/libc/unistd/sigblock.c b/libc/unistd/sigblock.c
index 863d7da..176bc13 100644
--- a/libc/unistd/sigblock.c
+++ b/libc/unistd/sigblock.c
@@ -37,6 +37,7 @@
         sigset_t  the_sigset;
     } in, out;
 
+    sigemptyset(&in.the_sigset);
     in.the_mask = mask;
 
     n = sigprocmask(SIG_BLOCK, &in.the_sigset, &out.the_sigset);
diff --git a/libc/unistd/sigsetmask.c b/libc/unistd/sigsetmask.c
index 4f46458..7842bf1 100644
--- a/libc/unistd/sigsetmask.c
+++ b/libc/unistd/sigsetmask.c
@@ -38,6 +38,7 @@
         sigset_t  the_sigset;
     } in, out;
 
+    sigemptyset(&in.the_sigset);
     in.the_mask = mask;
 
     n = sigprocmask(SIG_SETMASK, &in.the_sigset, &out.the_sigset);
diff --git a/linker/linker.c b/linker/linker.c
index 5a9dccf..e350d89 100644
--- a/linker/linker.c
+++ b/linker/linker.c
@@ -822,7 +822,7 @@
 static int reserve_mem_region(soinfo *si)
 {
     void *base = mmap((void *)si->base, si->size, PROT_READ | PROT_EXEC,
-                      MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+                      MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
     if (base == MAP_FAILED) {
         DL_ERR("%5d can NOT map (%sprelinked) library '%s' at 0x%08x "
               "as requested, will try general pool: %d (%s)",