merge in jb-release history after reset to master
diff --git a/include/arch/darwin-x86/AndroidConfig.h b/include/arch/darwin-x86/AndroidConfig.h
index 48f8d9a..f79f364 100644
--- a/include/arch/darwin-x86/AndroidConfig.h
+++ b/include/arch/darwin-x86/AndroidConfig.h
@@ -305,14 +305,4 @@
  */
 #define HAVE_PRINTF_ZD 1
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/include/arch/freebsd-x86/AndroidConfig.h b/include/arch/freebsd-x86/AndroidConfig.h
index 4bc5559..a8176f4 100644
--- a/include/arch/freebsd-x86/AndroidConfig.h
+++ b/include/arch/freebsd-x86/AndroidConfig.h
@@ -363,14 +363,4 @@
  */
 #define HAVE_PRINTF_ZD 1
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/include/arch/linux-arm/AndroidConfig.h b/include/arch/linux-arm/AndroidConfig.h
index 233752b..b8e8713 100644
--- a/include/arch/linux-arm/AndroidConfig.h
+++ b/include/arch/linux-arm/AndroidConfig.h
@@ -361,14 +361,4 @@
  */
 #define HAVE_PRINTF_ZD 1
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/include/arch/linux-ppc/AndroidConfig.h b/include/arch/linux-ppc/AndroidConfig.h
index ae2569b..774c458 100644
--- a/include/arch/linux-ppc/AndroidConfig.h
+++ b/include/arch/linux-ppc/AndroidConfig.h
@@ -323,14 +323,4 @@
  */
 #define HAVE_PREAD 1
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 1
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/include/arch/linux-sh/AndroidConfig.h b/include/arch/linux-sh/AndroidConfig.h
index 818b628..cdfa2ac 100644
--- a/include/arch/linux-sh/AndroidConfig.h
+++ b/include/arch/linux-sh/AndroidConfig.h
@@ -366,14 +366,4 @@
  */
 #define HAVE_PRINTF_ZD 1
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/include/arch/linux-x86/AndroidConfig.h b/include/arch/linux-x86/AndroidConfig.h
index 431a54b..6521699 100644
--- a/include/arch/linux-x86/AndroidConfig.h
+++ b/include/arch/linux-x86/AndroidConfig.h
@@ -333,18 +333,4 @@
  */
 #define HAVE_PRINTF_ZD 1
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
-#define HAVE_GNU_QSORT_R 1
-#else
-#define HAVE_GNU_QSORT_R 0
-#endif
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/include/arch/target_linux-x86/AndroidConfig.h b/include/arch/target_linux-x86/AndroidConfig.h
index ab53892..9efb81a 100644
--- a/include/arch/target_linux-x86/AndroidConfig.h
+++ b/include/arch/target_linux-x86/AndroidConfig.h
@@ -350,14 +350,4 @@
  */
 #define HAVE_PRINTF_ZD 1
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/include/arch/windows/AndroidConfig.h b/include/arch/windows/AndroidConfig.h
index 0274da5..445e754 100644
--- a/include/arch/windows/AndroidConfig.h
+++ b/include/arch/windows/AndroidConfig.h
@@ -338,14 +338,4 @@
  */
 /* #define HAVE_PRINTF_ZD 1 */
 
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/include/cutils/list.h b/include/cutils/list.h
index 8190219..eb5a3c8 100644
--- a/include/cutils/list.h
+++ b/include/cutils/list.h
@@ -18,9 +18,6 @@
 #define _CUTILS_LIST_H_
 
 #include <stddef.h>
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
 
 struct listnode
 {
@@ -51,6 +48,4 @@
 #define list_head(list) ((list)->next)
 #define list_tail(list) ((list)->prev)
 
-__END_DECLS
-
 #endif
diff --git a/include/cutils/qsort_r_compat.h b/include/cutils/qsort_r_compat.h
deleted file mode 100644
index 479a1ab..0000000
--- a/include/cutils/qsort_r_compat.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-/*
- * Provides a portable version of qsort_r, called qsort_r_compat, which is a
- * reentrant variant of qsort that passes a user data pointer to its comparator.
- * This implementation follows the BSD parameter convention.
- */
-
-#ifndef _LIBS_CUTILS_QSORT_R_COMPAT_H
-#define _LIBS_CUTILS_QSORT_R_COMPAT_H
-
-#include <stdlib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk,
-        int (*compar)(void*, const void* , const void* ));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _LIBS_CUTILS_QSORT_R_COMPAT_H
diff --git a/include/system/audio.h b/include/system/audio.h
index 0276231..4aee2c0 100644
--- a/include/system/audio.h
+++ b/include/system/audio.h
@@ -384,7 +384,7 @@
         return false;
 }
 
-/* Derive an output channel mask from a channel count.
+/* Derive a channel mask from a channel count.
  * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel
  * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad,
  * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC
@@ -392,7 +392,7 @@
  * Returns the matching channel mask, or 0 if the number of channels exceeds that of the
  * configurations for which a default channel mask is defined.
  */
-static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count)
+static inline audio_channel_mask_t audio_channel_mask_from_count(uint32_t channel_count)
 {
     switch(channel_count) {
     case 1:
@@ -416,19 +416,6 @@
     }
 }
 
-/* Similar to above, but for input.  Currently handles only mono and stereo. */
-static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count)
-{
-    switch (channel_count) {
-    case 1:
-        return AUDIO_CHANNEL_IN_MONO;
-    case 2:
-        return AUDIO_CHANNEL_IN_STEREO;
-    default:
-        return 0;
-    }
-}
-
 static inline bool audio_is_valid_format(audio_format_t format)
 {
     switch (format & AUDIO_FORMAT_MAIN_MASK) {
diff --git a/init/init.c b/init/init.c
index 5458e34..1ee88a7 100755
--- a/init/init.c
+++ b/init/init.c
@@ -134,7 +134,6 @@
     if ((fd = open(console_name, O_RDWR)) < 0) {
         fd = open("/dev/null", O_RDWR);
     }
-    ioctl(fd, TIOCSCTTY, 0);
     dup2(fd, 0);
     dup2(fd, 1);
     dup2(fd, 2);
diff --git a/libcutils/Android.mk b/libcutils/Android.mk
index 0d49165..3809733 100644
--- a/libcutils/Android.mk
+++ b/libcutils/Android.mk
@@ -46,7 +46,6 @@
 	record_stream.c \
 	process_name.c \
 	properties.c \
-	qsort_r_compat.c \
 	threads.c \
 	sched_policy.c \
 	iosched_policy.c \
diff --git a/libcutils/process_name.c b/libcutils/process_name.c
index bda9d08..b235429 100644
--- a/libcutils/process_name.c
+++ b/libcutils/process_name.c
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include <stdlib.h>
 #include <string.h>
 #include <cutils/process_name.h>
 #include <cutils/properties.h>
diff --git a/libcutils/qsort_r_compat.c b/libcutils/qsort_r_compat.c
deleted file mode 100644
index 8971cb5..0000000
--- a/libcutils/qsort_r_compat.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2012 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 <stdlib.h>
-#include <cutils/qsort_r_compat.h>
-
-#if HAVE_BSD_QSORT_R
-
-/*
- * BSD qsort_r parameter order is as we have defined here.
- */
-
-void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk,
-        int (*compar)(void*, const void* , const void*)) {
-    qsort_r(base, nel, width, thunk, compar);
-}
-
-#elif HAVE_GNU_QSORT_R
-
-/*
- * GNU qsort_r parameter order places the thunk parameter last.
- */
-
-struct compar_data {
-    void* thunk;
-    int (*compar)(void*, const void* , const void*);
-};
-
-static int compar_wrapper(const void* a, const void* b, void* data) {
-    struct compar_data* compar_data = (struct compar_data*)data;
-    return compar_data->compar(compar_data->thunk, a, b);
-}
-
-void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk,
-        int (*compar)(void*, const void* , const void*)) {
-    struct compar_data compar_data;
-    compar_data.thunk = thunk;
-    compar_data.compar = compar;
-    qsort_r(base, nel, width, compar_wrapper, &compar_data);
-}
-
-#else
-
-/*
- * Emulate qsort_r using thread local storage to access the thunk data.
- */
-
-#include <cutils/threads.h>
-
-static thread_store_t compar_data_key = THREAD_STORE_INITIALIZER;
-
-struct compar_data {
-    void* thunk;
-    int (*compar)(void*, const void* , const void*);
-};
-
-static int compar_wrapper(const void* a, const void* b) {
-    struct compar_data* compar_data = (struct compar_data*)thread_store_get(&compar_data_key);
-    return compar_data->compar(compar_data->thunk, a, b);
-}
-
-void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk,
-        int (*compar)(void*, const void* , const void*)) {
-    struct compar_data compar_data;
-    compar_data.thunk = thunk;
-    compar_data.compar = compar;
-    thread_store_set(&compar_data_key, &compar_data, NULL);
-    qsort(base, nel, width, compar_wrapper);
-}
-
-#endif
diff --git a/libcutils/str_parms.c b/libcutils/str_parms.c
index 9e1d2dc..364695c 100644
--- a/libcutils/str_parms.c
+++ b/libcutils/str_parms.c
@@ -70,57 +70,19 @@
     return NULL;
 }
 
-struct remove_ctxt {
-    struct str_parms *str_parms;
-    const char *key;
-};
-
 static bool remove_pair(void *key, void *value, void *context)
 {
-    struct remove_ctxt *ctxt = context;
-    bool should_continue;
+    struct str_parms *str_parms = context;
 
-    /*
-     * - if key is not supplied, then we are removing all entries,
-     *   so remove key and continue (i.e. return true)
-     * - if key is supplied and matches, then remove it and don't
-     *   continue (return false). Otherwise, return true and keep searching
-     *   for key.
-     *
-     */
-    if (!ctxt->key) {
-        should_continue = true;
-        goto do_remove;
-    } else if (!strcmp(ctxt->key, key)) {
-        should_continue = false;
-        goto do_remove;
-    }
-
-    return true;
-
-do_remove:
-    hashmapRemove(ctxt->str_parms->map, key);
+    hashmapRemove(str_parms->map, key);
     free(key);
     free(value);
-    return should_continue;
-}
-
-void str_parms_del(struct str_parms *str_parms, const char *key)
-{
-    struct remove_ctxt ctxt = {
-        .str_parms = str_parms,
-        .key = key,
-    };
-    hashmapForEach(str_parms->map, remove_pair, &ctxt);
+    return true;
 }
 
 void str_parms_destroy(struct str_parms *str_parms)
 {
-    struct remove_ctxt ctxt = {
-        .str_parms = str_parms,
-    };
-
-    hashmapForEach(str_parms->map, remove_pair, &ctxt);
+    hashmapForEach(str_parms->map, remove_pair, str_parms);
     hashmapFree(str_parms->map);
     free(str_parms);
 }
@@ -189,6 +151,11 @@
     return NULL;
 }
 
+void str_parms_del(struct str_parms *str_parms, const char *key)
+{
+    hashmapRemove(str_parms->map, (void *)key);
+}
+
 int str_parms_add_str(struct str_parms *str_parms, const char *key,
                       const char *value)
 {
@@ -338,8 +305,6 @@
 
     str_parms = str_parms_create_str(str);
     str_parms_add_str(str_parms, "dude", "woah");
-    str_parms_add_str(str_parms, "dude", "woah");
-    str_parms_del(str_parms, "dude");
     str_parms_dump(str_parms);
     out_str = str_parms_to_str(str_parms);
     str_parms_destroy(str_parms);
diff --git a/libcutils/tzstrftime.c b/libcutils/tzstrftime.c
index e4f54df..e37d79a 100644
--- a/libcutils/tzstrftime.c
+++ b/libcutils/tzstrftime.c
@@ -8,7 +8,6 @@
 #endif /* !defined NOID */
 #endif /* !defined lint */
 
-#include <stdio.h>
 #include <time.h>
 #include <tzfile.h>
 #include <limits.h>