Merge "Revert "Backing this one out since the counterpart needs to be sent upstream.""
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 9389c9c..369b23c 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -275,10 +275,6 @@
 int __sched_getaffinity:sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set)  all
 int __getcpu:getcpu(unsigned*, unsigned*, void*) all
 
-# io priorities
-int ioprio_set(int which, int who, int ioprio) all
-int ioprio_get(int which, int who) all
-
 # other
 int     uname(struct utsname*)  all
 mode_t  umask(mode_t)  all
diff --git a/libc/arch-arm/syscalls/ioprio_get.S b/libc/arch-arm/syscalls/ioprio_get.S
deleted file mode 100644
index 19e04ed..0000000
--- a/libc/arch-arm/syscalls/ioprio_get.S
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_get)
-    mov     ip, r7
-    ldr     r7, =__NR_ioprio_get
-    swi     #0
-    mov     r7, ip
-    cmn     r0, #(MAX_ERRNO + 1)
-    bxls    lr
-    neg     r0, r0
-    b       __set_errno
-END(ioprio_get)
diff --git a/libc/arch-arm/syscalls/ioprio_set.S b/libc/arch-arm/syscalls/ioprio_set.S
deleted file mode 100644
index 9b94efb..0000000
--- a/libc/arch-arm/syscalls/ioprio_set.S
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_set)
-    mov     ip, r7
-    ldr     r7, =__NR_ioprio_set
-    swi     #0
-    mov     r7, ip
-    cmn     r0, #(MAX_ERRNO + 1)
-    bxls    lr
-    neg     r0, r0
-    b       __set_errno
-END(ioprio_set)
diff --git a/libc/arch-arm64/syscalls/ioprio_get.S b/libc/arch-arm64/syscalls/ioprio_get.S
deleted file mode 100644
index 7e394c6..0000000
--- a/libc/arch-arm64/syscalls/ioprio_get.S
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_get)
-    mov     x8, __NR_ioprio_get
-    svc     #0
-
-    cmn     x0, #(MAX_ERRNO + 1)
-    cneg    x0, x0, hi
-    b.hi    __set_errno
-
-    ret
-END(ioprio_get)
diff --git a/libc/arch-arm64/syscalls/ioprio_set.S b/libc/arch-arm64/syscalls/ioprio_set.S
deleted file mode 100644
index ca43ed6..0000000
--- a/libc/arch-arm64/syscalls/ioprio_set.S
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_set)
-    mov     x8, __NR_ioprio_set
-    svc     #0
-
-    cmn     x0, #(MAX_ERRNO + 1)
-    cneg    x0, x0, hi
-    b.hi    __set_errno
-
-    ret
-END(ioprio_set)
diff --git a/libc/arch-mips/syscalls/ioprio_get.S b/libc/arch-mips/syscalls/ioprio_get.S
deleted file mode 100644
index fbc8b17..0000000
--- a/libc/arch-mips/syscalls/ioprio_get.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_get)
-    .set noreorder
-    .cpload t9
-    li v0, __NR_ioprio_get
-    syscall
-    bnez a3, 1f
-    move a0, v0
-    j ra
-    nop
-1:
-    la t9,__set_errno
-    j t9
-    nop
-    .set reorder
-END(ioprio_get)
diff --git a/libc/arch-mips/syscalls/ioprio_set.S b/libc/arch-mips/syscalls/ioprio_set.S
deleted file mode 100644
index d0320ed..0000000
--- a/libc/arch-mips/syscalls/ioprio_set.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_set)
-    .set noreorder
-    .cpload t9
-    li v0, __NR_ioprio_set
-    syscall
-    bnez a3, 1f
-    move a0, v0
-    j ra
-    nop
-1:
-    la t9,__set_errno
-    j t9
-    nop
-    .set reorder
-END(ioprio_set)
diff --git a/libc/arch-mips64/syscalls/ioprio_get.S b/libc/arch-mips64/syscalls/ioprio_get.S
deleted file mode 100644
index 711890c..0000000
--- a/libc/arch-mips64/syscalls/ioprio_get.S
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_get)
-    .set push
-    .set noreorder
-    li v0, __NR_ioprio_get
-    syscall
-    bnez a3, 1f
-    move a0, v0
-    j ra
-    nop
-1:
-    move t0, ra
-    bal     2f
-    nop
-2:
-    .cpsetup ra, t1, 2b
-    LA t9,__set_errno
-    .cpreturn
-    j t9
-    move ra, t0
-    .set pop
-END(ioprio_get)
diff --git a/libc/arch-mips64/syscalls/ioprio_set.S b/libc/arch-mips64/syscalls/ioprio_set.S
deleted file mode 100644
index 738403a..0000000
--- a/libc/arch-mips64/syscalls/ioprio_set.S
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_set)
-    .set push
-    .set noreorder
-    li v0, __NR_ioprio_set
-    syscall
-    bnez a3, 1f
-    move a0, v0
-    j ra
-    nop
-1:
-    move t0, ra
-    bal     2f
-    nop
-2:
-    .cpsetup ra, t1, 2b
-    LA t9,__set_errno
-    .cpreturn
-    j t9
-    move ra, t0
-    .set pop
-END(ioprio_set)
diff --git a/libc/arch-x86/syscalls/ioprio_get.S b/libc/arch-x86/syscalls/ioprio_get.S
deleted file mode 100644
index 491c2f3..0000000
--- a/libc/arch-x86/syscalls/ioprio_get.S
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_get)
-    pushl   %ebx
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset ebx, 0
-    pushl   %ecx
-    .cfi_adjust_cfa_offset 4
-    .cfi_rel_offset ecx, 0
-    mov     12(%esp), %ebx
-    mov     16(%esp), %ecx
-    movl    $__NR_ioprio_get, %eax
-    int     $0x80
-    cmpl    $-MAX_ERRNO, %eax
-    jb      1f
-    negl    %eax
-    pushl   %eax
-    call    __set_errno
-    addl    $4, %esp
-1:
-    popl    %ecx
-    popl    %ebx
-    ret
-END(ioprio_get)
diff --git a/libc/arch-x86/syscalls/ioprio_set.S b/libc/arch-x86/syscalls/ioprio_set.S
deleted file mode 100644
index e80602c..0000000
--- a/libc/arch-x86/syscalls/ioprio_set.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_set)
-    pushl   %ebx
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset ebx, 0
-    pushl   %ecx
-    .cfi_adjust_cfa_offset 4
-    .cfi_rel_offset ecx, 0
-    pushl   %edx
-    .cfi_adjust_cfa_offset 4
-    .cfi_rel_offset edx, 0
-    mov     16(%esp), %ebx
-    mov     20(%esp), %ecx
-    mov     24(%esp), %edx
-    movl    $__NR_ioprio_set, %eax
-    int     $0x80
-    cmpl    $-MAX_ERRNO, %eax
-    jb      1f
-    negl    %eax
-    pushl   %eax
-    call    __set_errno
-    addl    $4, %esp
-1:
-    popl    %edx
-    popl    %ecx
-    popl    %ebx
-    ret
-END(ioprio_set)
diff --git a/libc/arch-x86_64/syscalls/ioprio_get.S b/libc/arch-x86_64/syscalls/ioprio_get.S
deleted file mode 100644
index 729a288..0000000
--- a/libc/arch-x86_64/syscalls/ioprio_get.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_get)
-    movl    $__NR_ioprio_get, %eax
-    syscall
-    cmpq    $-MAX_ERRNO, %rax
-    jb      1f
-    negl    %eax
-    movl    %eax, %edi
-    call    __set_errno
-1:
-    ret
-END(ioprio_get)
diff --git a/libc/arch-x86_64/syscalls/ioprio_set.S b/libc/arch-x86_64/syscalls/ioprio_set.S
deleted file mode 100644
index 477fe61..0000000
--- a/libc/arch-x86_64/syscalls/ioprio_set.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(ioprio_set)
-    movl    $__NR_ioprio_set, %eax
-    syscall
-    cmpq    $-MAX_ERRNO, %rax
-    jb      1f
-    negl    %eax
-    movl    %eax, %edi
-    call    __set_errno
-1:
-    ret
-END(ioprio_set)
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 15a3206..4834d6e 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -250,4 +250,9 @@
   return 0;
 }
 
+// This was removed from POSIX 2004.
+extern "C" pid_t wait3(int* status, int options, struct rusage* rusage) {
+  return wait4(-1, status, options, rusage);
+}
+
 #endif
diff --git a/libc/bionic/wait.cpp b/libc/bionic/wait.cpp
index cd75c10..e5c93aa 100644
--- a/libc/bionic/wait.cpp
+++ b/libc/bionic/wait.cpp
@@ -35,10 +35,6 @@
   return wait4(-1, status, 0, NULL);
 }
 
-pid_t wait3(int* status, int options, struct rusage* rusage) {
-  return wait4(-1, status, options, rusage);
-}
-
 pid_t waitpid(pid_t pid, int* status, int options) {
   return wait4(pid, status, options, NULL);
 }
diff --git a/libc/dns/include/resolv_private.h b/libc/dns/include/resolv_private.h
index 8914fae..f4c67f3 100644
--- a/libc/dns/include/resolv_private.h
+++ b/libc/dns/include/resolv_private.h
@@ -60,6 +60,9 @@
 #include "resolv_static.h"
 #include <net/if.h>
 
+/* Despite this file's name, it's part of libresolv. On Android, that means it's part of libc :-( */
+#pragma GCC visibility push(default)
+
 /*
  * Revision information.  This is the release date in YYYYMMDD format.
  * It can change every day so the right thing to do with it is use it
@@ -279,8 +282,9 @@
 
 /* Things involving an internal (static) resolver context. */
 __BEGIN_DECLS
-extern struct __res_state *__res_get_state(void);
-extern void __res_put_state(struct __res_state *);
+
+__LIBC_HIDDEN__ extern struct __res_state *__res_get_state(void);
+__LIBC_HIDDEN__ extern void __res_put_state(struct __res_state *);
 
 #ifndef ANDROID_CHANGES
 /*
@@ -320,7 +324,7 @@
 void		p_query(const u_char *);
 void		res_close(void);
 int		res_init(void);
-int		res_opt(int, u_char *, int, int);
+__LIBC_HIDDEN__ int		res_opt(int, u_char *, int, int);
 int		res_isourserver(const struct sockaddr_in *);
 int		res_mkquery(int, const char *, int, int, const u_char *, int, const u_char *, u_char *, int);
 int		res_query(const char *, int, int, u_char *, int);
@@ -339,11 +343,11 @@
  * Make them go away if a client is including this
  *
  */
-extern const struct res_sym __p_key_syms[];
-extern const struct res_sym __p_cert_syms[];
+__LIBC_HIDDEN__ extern const struct res_sym __p_key_syms[];
+__LIBC_HIDDEN__ extern const struct res_sym __p_cert_syms[];
 extern const struct res_sym __p_class_syms[];
 extern const struct res_sym __p_type_syms[];
-extern const struct res_sym __p_rcode_syms[];
+__LIBC_HIDDEN__ extern const struct res_sym __p_rcode_syms[];
 #endif /* SHARED_LIBBIND */
 
 #ifndef ANDROID_CHANGES
@@ -434,7 +438,7 @@
 const char *	p_time(uint32_t);
 const char *	p_type(int);
 const char *	p_rcode(int);
-const char *	p_sockun(union res_sockaddr_union, char *, size_t);
+__LIBC_HIDDEN__ const char *	p_sockun(union res_sockaddr_union, char *, size_t);
 const u_char *	p_cdnname(const u_char *, const u_char *, int, FILE *);
 const u_char *	p_cdname(const u_char *, const u_char *, FILE *);
 const u_char *	p_fqnname(const u_char *, const u_char *,
@@ -448,12 +452,12 @@
 				     const u_char *);
 int		res_queriesmatch(const u_char *, const u_char *,
 				      const u_char *, const u_char *);
-const char *	p_section(int, int);
+__LIBC_HIDDEN__ const char *	p_section(int, int);
 /* Things involving a resolver context. */
 int		res_ninit(res_state);
 int		res_nisourserver(const res_state, const struct sockaddr_in *);
 void		fp_resstat(const res_state, FILE *);
-void		res_pquery(const res_state, const u_char *, int, FILE *);
+__LIBC_HIDDEN__ void		res_pquery(const res_state, const u_char *, int, FILE *);
 const char *	res_hostalias(const res_state, const char *, char *, size_t);
 int		res_nquery(res_state, const char *, int, int, u_char *, int);
 int		res_nsearch(res_state, const char *, int, int, u_char *, int);
@@ -471,29 +475,31 @@
 				      char *, size_t,
 				      union res_sockaddr_union *, int);
 void		res_nclose(res_state);
-int		res_nopt(res_state, int, u_char *, int, int);
+__LIBC_HIDDEN__ int		res_nopt(res_state, int, u_char *, int, int);
 void		res_send_setqhook(res_send_qhook);
 void		res_send_setrhook(res_send_rhook);
-int		__res_vinit(res_state, int);
+__LIBC_HIDDEN__ int		__res_vinit(res_state, int);
 void		res_destroyservicelist(void);
 const char *	res_servicename(uint16_t, const char *);
 const char *	res_protocolname(int);
 void		res_destroyprotolist(void);
 void		res_buildprotolist(void);
-const char *	res_get_nibblesuffix(res_state);
-const char *	res_get_nibblesuffix2(res_state);
-void		res_ndestroy(res_state);
-uint16_t	res_nametoclass(const char *, int *);
-uint16_t	res_nametotype(const char *, int *);
-void		res_setservers(res_state,
+__LIBC_HIDDEN__ const char *	res_get_nibblesuffix(res_state);
+__LIBC_HIDDEN__ const char *	res_get_nibblesuffix2(res_state);
+__LIBC_HIDDEN__ void		res_ndestroy(res_state);
+__LIBC_HIDDEN__ uint16_t	res_nametoclass(const char *, int *);
+__LIBC_HIDDEN__ uint16_t	res_nametotype(const char *, int *);
+__LIBC_HIDDEN__ void		res_setservers(res_state,
 				    const union res_sockaddr_union *, int);
-int		res_getservers(res_state,
+__LIBC_HIDDEN__ int		res_getservers(res_state,
 				    union res_sockaddr_union *, int);
 
-void res_setnetid(res_state, unsigned);
-void res_setmark(res_state, unsigned);
+__LIBC_HIDDEN__ void res_setnetid(res_state, unsigned);
+__LIBC_HIDDEN__ void res_setmark(res_state, unsigned);
 u_int  res_randomid(void);
 
 __END_DECLS
 
+#pragma GCC visibility pop
+
 #endif /* !_RESOLV_PRIVATE_H_ */
diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h
index b30b7ec..8d9a5f6 100644
--- a/libc/include/sys/wait.h
+++ b/libc/include/sys/wait.h
@@ -47,7 +47,6 @@
 
 extern pid_t  wait(int *);
 extern pid_t  waitpid(pid_t, int *, int);
-extern pid_t  wait3(int *, int, struct rusage *);
 extern pid_t  wait4(pid_t, int *, int, struct rusage *);
 
 /* Posix states that idtype_t should be an enumeration type, but
diff --git a/libc/tools/check-symbols-glibc.py b/libc/tools/check-symbols-glibc.py
index d0e00f3..58a10e0 100755
--- a/libc/tools/check-symbols-glibc.py
+++ b/libc/tools/check-symbols-glibc.py
@@ -11,7 +11,6 @@
 arch = re.sub(r'.*/linux-x86/([^/]+)/.*', r'\1', toolchain)
 
 def GetSymbolsFromSo(so_file):
-
   # Example readelf output:
   #   264: 0001623c     4 FUNC    GLOBAL DEFAULT    8 cabsf
   #   266: 00016244     4 FUNC    GLOBAL DEFAULT    8 dremf
@@ -23,13 +22,13 @@
   symbols = set()
 
   for line in subprocess.check_output(['readelf', '--dyn-syms', '-W', so_file]).split('\n'):
-     if ' HIDDEN ' in line or ' UND ' in line:
-       continue
-     m = r.match(line)
-     if m:
-       symbol = m.group(2)
-       symbol = re.sub('@.*', '', symbol)
-       symbols.add(symbol)
+    if ' HIDDEN ' in line or ' UND ' in line:
+      continue
+    m = r.match(line)
+    if m:
+      symbol = m.group(2)
+      symbol = re.sub('@.*', '', symbol)
+      symbols.add(symbol)
 
   return symbols
 
@@ -46,9 +45,23 @@
     symbols = symbols | GetSymbolsFromSo(f)
   return symbols
 
+def MangleGlibcNameToBionic(name):
+  if name in glibc_to_bionic_names:
+    return glibc_to_bionic_names[name]
+  return name
+
+glibc_to_bionic_names = {
+  '__res_init': 'res_init',
+  '__res_mkquery': 'res_mkquery',
+  '__res_query': 'res_query',
+  '__res_search': 'res_search',
+}
+
 glibc = GetSymbolsFromSystemSo('libc.so.*', 'librt.so.*', 'libpthread.so.*', 'libresolv.so.*', 'libm.so.*')
 bionic = GetSymbolsFromAndroidSo('libc.so', 'libm.so')
 
+glibc = map(MangleGlibcNameToBionic, glibc)
+
 # bionic includes various BSD symbols to ease porting other BSD-licensed code.
 bsd_stuff = set([
   'basename_r',
diff --git a/libc/zoneinfo/tzdata b/libc/zoneinfo/tzdata
index b3c9444..a5ae1f6 100644
--- a/libc/zoneinfo/tzdata
+++ b/libc/zoneinfo/tzdata
Binary files differ