Merge "Add <linux/tty.h> to libc/include/sys/ioctl.h"
diff --git a/libc/Android.mk b/libc/Android.mk
index 5e86dac..2747a3e 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -43,9 +43,7 @@
bionic/err.c \
bionic/ether_aton.c \
bionic/ether_ntoa.c \
- bionic/ftime.c \
bionic/fts.c \
- bionic/getdtablesize.c \
bionic/gethostname.c \
bionic/getpriority.c \
bionic/getpt.c \
@@ -503,7 +501,7 @@
ifeq ($(MALLOC_IMPL),jemalloc)
libc_common_cflags += -DUSE_JEMALLOC
- libc_malloc_src := bionic/jemalloc.cpp
+ libc_malloc_src := bionic/jemalloc_wrapper.cpp
else
libc_common_cflags += -DUSE_DLMALLOC
libc_malloc_src := bionic/dlmalloc.c
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/arm.mk b/libc/arch-arm/arm.mk
index 26690ce..38301bc 100644
--- a/libc/arch-arm/arm.mk
+++ b/libc/arch-arm/arm.mk
@@ -12,7 +12,6 @@
bionic/mmap.cpp
libc_common_src_files_arm += \
- bionic/index.cpp \
bionic/memchr.c \
bionic/memrchr.c \
bionic/strchr.cpp \
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/mips.mk b/libc/arch-mips/mips.mk
index 529e284..fe5e24d 100644
--- a/libc/arch-mips/mips.mk
+++ b/libc/arch-mips/mips.mk
@@ -12,7 +12,6 @@
bionic/mmap.cpp
libc_common_src_files_mips += \
- bionic/index.cpp \
bionic/memchr.c \
bionic/memcmp.c \
bionic/memmove.c \
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/atom/atom.mk b/libc/arch-x86/atom/atom.mk
index abe940d..3f28fb2 100644
--- a/libc/arch-x86/atom/atom.mk
+++ b/libc/arch-x86/atom/atom.mk
@@ -1,6 +1,5 @@
libc_bionic_src_files_x86 += \
arch-x86/atom/string/sse2-bzero-atom.S \
- arch-x86/atom/string/sse2-index-atom.S \
arch-x86/atom/string/sse2-memchr-atom.S \
arch-x86/atom/string/sse2-memrchr-atom.S \
arch-x86/atom/string/sse2-memset-atom.S \
diff --git a/libc/arch-x86/atom/string/sse2-index-atom.S b/libc/arch-x86/atom/string/sse2-index-atom.S
deleted file mode 100644
index d51e1d4..0000000
--- a/libc/arch-x86/atom/string/sse2-index-atom.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-Copyright (c) 2011, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#define strchr index
-#include "sse2-strchr-atom.S"
diff --git a/libc/arch-x86/generic/generic.mk b/libc/arch-x86/generic/generic.mk
index 62e81b7..4aee5dc 100644
--- a/libc/arch-x86/generic/generic.mk
+++ b/libc/arch-x86/generic/generic.mk
@@ -1,5 +1,4 @@
libc_bionic_src_files_x86 += \
- arch-x86/atom/string/sse2-index-atom.S \
arch-x86/atom/string/sse2-memchr-atom.S \
arch-x86/atom/string/sse2-memrchr-atom.S \
arch-x86/atom/string/sse2-strchr-atom.S \
diff --git a/libc/arch-x86/silvermont/silvermont.mk b/libc/arch-x86/silvermont/silvermont.mk
index 9640a24..176bee3 100644
--- a/libc/arch-x86/silvermont/silvermont.mk
+++ b/libc/arch-x86/silvermont/silvermont.mk
@@ -17,7 +17,6 @@
arch-x86/atom/string/sse2-memrchr-atom.S \
arch-x86/atom/string/sse2-strchr-atom.S \
arch-x86/atom/string/sse2-strrchr-atom.S \
- arch-x86/atom/string/sse2-index-atom.S \
arch-x86/atom/string/sse2-strnlen-atom.S \
arch-x86/atom/string/sse2-wcschr-atom.S \
arch-x86/atom/string/sse2-wcsrchr-atom.S \
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/ftime.c b/libc/bionic/ftime.c
deleted file mode 100644
index 6513593..0000000
--- a/libc/bionic/ftime.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <sys/timeb.h>
-
-int ftime(struct timeb *tb)
-{
- struct timeval tv;
- struct timezone tz;
-
- if (gettimeofday (&tv, &tz) < 0)
- return -1;
-
- tb->time = tv.tv_sec;
- tb->millitm = (tv.tv_usec + 500) / 1000;
-
- if (tb->millitm == 1000) {
- ++tb->time;
- tb->millitm = 0;
- }
- tb->timezone = tz.tz_minuteswest;
- tb->dstflag = tz.tz_dsttime;
-
- return 0;
-}
diff --git a/libc/bionic/getdtablesize.c b/libc/bionic/getdtablesize.c
deleted file mode 100644
index 91315a5..0000000
--- a/libc/bionic/getdtablesize.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <sys/resource.h>
-#include <sys/sysconf.h>
-
-int getdtablesize()
-{
- struct rlimit r;
-
- if (getrlimit(RLIMIT_NOFILE, &r) < 0) {
- return sysconf(_SC_OPEN_MAX);
- }
- return r.rlim_cur;
-}
diff --git a/libc/bionic/index.cpp b/libc/bionic/index.cpp
deleted file mode 100644
index cc22d81..0000000
--- a/libc/bionic/index.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#undef _FORTIFY_SOURCE
-#include <string.h>
-
-char* index(const char* p, int ch) {
- return __strchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
-}
diff --git a/libc/bionic/jemalloc.cpp b/libc/bionic/jemalloc_wrapper.cpp
similarity index 100%
rename from libc/bionic/jemalloc.cpp
rename to libc/bionic/jemalloc_wrapper.cpp
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp
index 6677c22..cbca160 100644
--- a/libc/bionic/malloc_debug_common.cpp
+++ b/libc/bionic/malloc_debug_common.cpp
@@ -61,9 +61,13 @@
Malloc(malloc_usable_size),
Malloc(memalign),
Malloc(posix_memalign),
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
Malloc(pvalloc),
+#endif
Malloc(realloc),
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
Malloc(valloc),
+#endif
};
// Selector of dispatch table to use for dispatching malloc calls.
@@ -258,17 +262,21 @@
return __libc_malloc_dispatch->posix_memalign(memptr, alignment, size);
}
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
extern "C" void* pvalloc(size_t bytes) {
return __libc_malloc_dispatch->pvalloc(bytes);
}
+#endif
extern "C" void* realloc(void* oldMem, size_t bytes) {
return __libc_malloc_dispatch->realloc(oldMem, bytes);
}
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
extern "C" void* valloc(size_t bytes) {
return __libc_malloc_dispatch->valloc(bytes);
}
+#endif
// We implement malloc debugging only in libc.so, so the code below
// must be excluded if we compile this file for static libc.a
@@ -299,9 +307,13 @@
InitMallocFunction<MallocDebugMallocUsableSize>(malloc_impl_handler, &table->malloc_usable_size, prefix, "malloc_usable_size");
InitMallocFunction<MallocDebugMemalign>(malloc_impl_handler, &table->memalign, prefix, "memalign");
InitMallocFunction<MallocDebugPosixMemalign>(malloc_impl_handler, &table->posix_memalign, prefix, "posix_memalign");
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
InitMallocFunction<MallocDebugPvalloc>(malloc_impl_handler, &table->pvalloc, prefix, "pvalloc");
+#endif
InitMallocFunction<MallocDebugRealloc>(malloc_impl_handler, &table->realloc, prefix, "realloc");
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
InitMallocFunction<MallocDebugValloc>(malloc_impl_handler, &table->valloc, prefix, "valloc");
+#endif
}
// Initializes memory allocation framework once per process.
@@ -447,9 +459,14 @@
(malloc_dispatch_table.malloc_usable_size == NULL) ||
(malloc_dispatch_table.memalign == NULL) ||
(malloc_dispatch_table.posix_memalign == NULL) ||
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
(malloc_dispatch_table.pvalloc == NULL) ||
- (malloc_dispatch_table.realloc == NULL) ||
- (malloc_dispatch_table.valloc == NULL)) {
+#endif
+ (malloc_dispatch_table.realloc == NULL)
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+ || (malloc_dispatch_table.valloc == NULL)
+#endif
+ ) {
error_log("%s: some symbols for libc.debug.malloc level %d were not found (see above)",
getprogname(), g_malloc_debug_level);
dlclose(malloc_impl_handle);
diff --git a/libc/bionic/malloc_debug_common.h b/libc/bionic/malloc_debug_common.h
index 8052a17..fb2f03d 100644
--- a/libc/bionic/malloc_debug_common.h
+++ b/libc/bionic/malloc_debug_common.h
@@ -37,6 +37,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include "private/bionic_config.h"
#include "private/libc_logging.h"
#define HASHTABLE_SIZE 1543
@@ -90,9 +91,14 @@
typedef size_t (*MallocDebugMallocUsableSize)(const void*);
typedef void* (*MallocDebugMemalign)(size_t, size_t);
typedef int (*MallocDebugPosixMemalign)(void**, size_t, size_t);
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
typedef void* (*MallocDebugPvalloc)(size_t);
+#endif
typedef void* (*MallocDebugRealloc)(void*, size_t);
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
typedef void* (*MallocDebugValloc)(size_t);
+#endif
+
struct MallocDebug {
MallocDebugCalloc calloc;
MallocDebugFree free;
@@ -101,9 +107,13 @@
MallocDebugMallocUsableSize malloc_usable_size;
MallocDebugMemalign memalign;
MallocDebugPosixMemalign posix_memalign;
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
MallocDebugPvalloc pvalloc;
+#endif
MallocDebugRealloc realloc;
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
MallocDebugValloc valloc;
+#endif
};
typedef bool (*MallocDebugInit)(HashTable*);
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 15a3206..e3e640a 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -36,6 +36,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
@@ -250,4 +251,55 @@
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);
+}
+
+// This was removed from POSIX 2004.
+extern "C" int getdtablesize() {
+ struct rlimit r;
+
+ if (getrlimit(RLIMIT_NOFILE, &r) < 0) {
+ return sysconf(_SC_OPEN_MAX);
+ }
+
+ return r.rlim_cur;
+}
+
+// Only used by ftime, which was removed from POSIX.
+struct timeb {
+ time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
+
+// This was removed from POSIX 2008.
+extern "C" int ftime(struct timeb* tb) {
+ struct timeval tv;
+ struct timezone tz;
+
+ if (gettimeofday(&tv, &tz) < 0)
+ return -1;
+
+ tb->time = tv.tv_sec;
+ tb->millitm = (tv.tv_usec + 500) / 1000;
+
+ if (tb->millitm == 1000) {
+ ++tb->time;
+ tb->millitm = 0;
+ }
+
+ tb->timezone = tz.tz_minuteswest;
+ tb->dstflag = tz.tz_dsttime;
+
+ return 0;
+}
+
+// This was removed from POSIX 2008.
+extern "C" char* index(const char* str, int ch) {
+ return strchr(str, ch);
+}
+
#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/malloc.h b/libc/include/malloc.h
index 9a4e324..e6ea276 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -35,9 +35,6 @@
extern void* memalign(size_t alignment, size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(2)));
extern size_t malloc_usable_size(const void* p);
-extern void* valloc(size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(1)));
-extern void* pvalloc(size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(1)));
-
#ifndef STRUCT_MALLINFO_DECLARED
#define STRUCT_MALLINFO_DECLARED 1
struct mallinfo {
diff --git a/libc/include/sys/timeb.h b/libc/include/sys/timeb.h
deleted file mode 100644
index cf6f255..0000000
--- a/libc/include/sys/timeb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _SYS_TIMEB_H
-#define _SYS_TIMEB_H
-
-#include <sys/cdefs.h>
-#include <sys/time.h>
-
-__BEGIN_DECLS
-
-struct timeb {
- time_t time;
- unsigned short millitm;
- short timezone;
- short dstflag;
-};
-
-extern int ftime(struct timeb* timebuf);
-
-__END_DECLS
-
-#endif /* _SYS_TIMEB_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/include/unistd.h b/libc/include/unistd.h
index ee6d7b1..afe5f1a 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -164,8 +164,6 @@
extern int gethostname(char *, size_t);
-extern int getdtablesize(void);
-
extern void *__brk(void *);
extern int brk(void *);
extern void *sbrk(ptrdiff_t);
diff --git a/libc/private/bionic_config.h b/libc/private/bionic_config.h
new file mode 100644
index 0000000..0c9811c
--- /dev/null
+++ b/libc/private/bionic_config.h
@@ -0,0 +1,26 @@
+/*
+ * 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_CONFIG_H_
+#define _BIONIC_CONFIG_H_
+
+// valloc(3) and pvalloc(3) were removed from POSIX 2004. We do not include them
+// for LP64, but the symbols remain in LP32 for binary compatibility.
+#if !defined(__LP64__)
+#define HAVE_DEPRECATED_MALLOC_FUNCS 1
+#endif
+
+#endif // _BIONIC_CONFIG_H_
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
diff --git a/tests/Android.mk b/tests/Android.mk
index c2e76b6..ce0c5f2 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -115,9 +115,18 @@
libBionicStandardTests_cflags := \
$(test_cflags) \
+ifeq ($(MALLOC_IMPL),jemalloc)
+ libBionicStandardTests_cflags += -DUSE_JEMALLOC
+else
+ libBionicStandardTests_cflags += -DUSE_DLMALLOC
+endif
+
libBionicStandardTests_cppflags := \
$(test_cppflags) \
+libBionicStandardTests_c_includes := \
+ bionic/libc \
+
libBionicStandardTests_ldlibs_host := \
-lrt \
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index ed98f15..6b7a28b 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -22,6 +22,8 @@
#include <malloc.h>
#include <unistd.h>
+#include "private/bionic_config.h"
+
TEST(malloc, malloc_std) {
// Simple malloc test.
void *ptr = malloc(100);
@@ -291,6 +293,10 @@
free(ptr);
}
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+extern "C" void* pvalloc(size_t);
+extern "C" void* valloc(size_t);
+
TEST(malloc, pvalloc_std) {
size_t pagesize = sysconf(_SC_PAGESIZE);
void* ptr = pvalloc(100);
@@ -315,3 +321,4 @@
TEST(malloc, valloc_overflow) {
ASSERT_EQ(NULL, valloc(SIZE_MAX));
}
+#endif
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index a468b97..2ab60d7 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -17,6 +17,7 @@
#include <gtest/gtest.h>
#include <errno.h>
+#include <malloc.h>
#include <math.h>
#include <string.h>
@@ -143,9 +144,9 @@
int max_alignment = 64;
// TODO: fix the tests to not sometimes use twice their specified "MAX_LEN".
- glob_ptr = reinterpret_cast<Character*>(valloc(2 * sizeof(Character) * MAX_LEN + max_alignment));
- glob_ptr1 = reinterpret_cast<Character*>(valloc(2 * sizeof(Character) * MAX_LEN + max_alignment));
- glob_ptr2 = reinterpret_cast<Character*>(valloc(2 * sizeof(Character) * MAX_LEN + max_alignment));
+ glob_ptr = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
+ glob_ptr1 = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
+ glob_ptr2 = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
InitLenArray();