Merge "Adds functionality specified by uchar.h"
diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index cf3d692..f9722ae 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -24,7 +24,7 @@
benchmark_c_flags = \
-O2 \
- -Wall -Wextra \
+ -Wall -Wextra -Wunused \
-Werror \
-fno-builtin \
-std=gnu++11 \
diff --git a/benchmarks/unistd_benchmark.cpp b/benchmarks/unistd_benchmark.cpp
index e839bf8..12b788a 100644
--- a/benchmarks/unistd_benchmark.cpp
+++ b/benchmarks/unistd_benchmark.cpp
@@ -28,3 +28,14 @@
StopBenchmarkTiming();
}
BENCHMARK(BM_unistd_getpid);
+
+static void BM_unistd_gettid(int iters) {
+ StartBenchmarkTiming();
+
+ for (int i = 0; i < iters; ++i) {
+ gettid();
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_unistd_gettid);
diff --git a/libc/Android.mk b/libc/Android.mk
index 3ac74b7..cf407e1 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -130,6 +130,7 @@
bionic/getauxval.cpp \
bionic/getcwd.cpp \
bionic/getpgrp.cpp \
+ bionic/gettid.cpp \
bionic/inotify_init.cpp \
bionic/lchown.cpp \
bionic/lfs64_support.cpp \
@@ -490,7 +491,7 @@
# ========================================================
libc_common_cflags := \
-D_LIBC=1 \
- -Wall -Wextra \
+ -Wall -Wextra -Wunused \
# Try to catch typical 32-bit assumptions that break with 64-bit pointers.
libc_common_cflags += \
@@ -504,11 +505,9 @@
ifeq ($(MALLOC_IMPL),jemalloc)
libc_common_cflags += -DUSE_JEMALLOC
-
libc_malloc_src := bionic/jemalloc.cpp
else
libc_common_cflags += -DUSE_DLMALLOC
-
libc_malloc_src := bionic/dlmalloc.c
endif
@@ -713,8 +712,9 @@
LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files)
LOCAL_CFLAGS := \
$(libc_common_cflags) \
- -Wno-sign-compare -Wno-uninitialized \
+ -Wno-sign-compare -Wno-uninitialized -Wno-unused-parameter \
-Werror \
+ -Wno-error=unused-but-set-variable \
-I$(LOCAL_PATH)/upstream-openbsd/android/include \
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/gdtoa/ \
@@ -824,6 +824,7 @@
libc_dns \
libc_freebsd \
libc_gdtoa \
+ libc_malloc \
libc_netbsd \
libc_openbsd \
libc_stack_protector \
@@ -831,8 +832,7 @@
libc_tzcode \
ifeq ($(MALLOC_IMPL),jemalloc)
-LOCAL_WHOLE_STATIC_LIBRARIES += \
- libjemalloc
+LOCAL_WHOLE_STATIC_LIBRARIES += libjemalloc
endif
LOCAL_SYSTEM_SHARED_LIBRARIES :=
@@ -882,6 +882,24 @@
# ========================================================
+# libc_malloc.a: the _prefixed_ malloc functions (like dlcalloc).
+# ========================================================
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(libc_malloc_src)
+LOCAL_CFLAGS := $(libc_common_cflags) \
+ -Werror \
+ -fvisibility=hidden \
+
+LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
+LOCAL_CPPFLAGS := $(libc_common_cppflags)
+LOCAL_C_INCLUDES := $(libc_common_c_includes)
+LOCAL_MODULE := libc_malloc
+LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
+include $(BUILD_STATIC_LIBRARY)
+
+
+# ========================================================
# libc.a
# ========================================================
include $(CLEAR_VARS)
@@ -889,7 +907,6 @@
LOCAL_SRC_FILES := \
$(libc_arch_static_src_files) \
$(libc_static_common_src_files) \
- $(libc_malloc_src) \
bionic/malloc_debug_common.cpp \
bionic/libc_init_static.cpp \
@@ -922,7 +939,6 @@
LOCAL_SRC_FILES := \
$(libc_arch_dynamic_src_files) \
$(libc_static_common_src_files) \
- $(libc_malloc_src) \
bionic/malloc_debug_common.cpp \
bionic/debug_mapinfo.cpp \
bionic/debug_stacktrace.cpp \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 785d191..584c1ae 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -38,7 +38,6 @@
uid_t getresuid:getresuid(uid_t* ruid, uid_t* euid, uid_t* suid) arm64,mips,mips64,x86_64
gid_t getresgid:getresgid32(gid_t* rgid, gid_t* egid, gid_t* sgid) arm,x86
gid_t getresgid:getresgid(gid_t* rgid, gid_t* egid, gid_t* sgid) arm64,mips,mips64,x86_64
-pid_t gettid() all
ssize_t readahead(int, off64_t, size_t) all
int getgroups:getgroups32(int, gid_t*) arm,x86
int getgroups:getgroups(int, gid_t*) arm64,mips,mips64,x86_64
diff --git a/libc/arch-arm/syscalls/gettid.S b/libc/arch-arm/syscalls/gettid.S
deleted file mode 100644
index 3928be1..0000000
--- a/libc/arch-arm/syscalls/gettid.S
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(gettid)
- mov ip, r7
- ldr r7, =__NR_gettid
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(gettid)
diff --git a/libc/arch-arm64/generic/bionic/bcopy.S b/libc/arch-arm64/generic/bionic/bcopy.S
deleted file mode 100644
index 7079e8b..0000000
--- a/libc/arch-arm64/generic/bionic/bcopy.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (c) 2014, Linaro Limited
- 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 the Linaro 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
- HOLDER 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 BCOPY
-#include "memmove.S"
-#undef BCOPY
diff --git a/libc/arch-arm64/generic/bionic/bzero.S b/libc/arch-arm64/generic/bionic/bzero.S
deleted file mode 100644
index c6175d6..0000000
--- a/libc/arch-arm64/generic/bionic/bzero.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (c) 2014, Linaro Limited
- 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 the Linaro 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
- HOLDER 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 BZERO
-#include "memset.S"
-#undef BZERO
diff --git a/libc/arch-arm64/generic/generic.mk b/libc/arch-arm64/generic/generic.mk
index 976431a..e10cf66 100644
--- a/libc/arch-arm64/generic/generic.mk
+++ b/libc/arch-arm64/generic/generic.mk
@@ -1,6 +1,4 @@
libc_bionic_src_files_arm64 += \
- arch-arm64/generic/bionic/bcopy.S \
- arch-arm64/generic/bionic/bzero.S \
arch-arm64/generic/bionic/memcmp.S \
arch-arm64/generic/bionic/memcpy.S \
arch-arm64/generic/bionic/memmove.S \
diff --git a/libc/arch-arm64/syscalls/gettid.S b/libc/arch-arm64/syscalls/gettid.S
deleted file mode 100644
index 44ca913..0000000
--- a/libc/arch-arm64/syscalls/gettid.S
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(gettid)
- stp x29, x30, [sp, #-16]!
- .cfi_def_cfa_offset 16
- .cfi_rel_offset x29, 0
- .cfi_rel_offset x30, 8
- mov x29, sp
-
- mov x8, __NR_gettid
- svc #0
-
- ldp x29, x30, [sp], #16
- .cfi_def_cfa_offset 0
- .cfi_restore x29
- .cfi_restore x30
-
- cmn x0, #(MAX_ERRNO + 1)
- cneg x0, x0, hi
- b.hi __set_errno
-
- ret
-END(gettid)
diff --git a/libc/arch-mips/syscalls/gettid.S b/libc/arch-mips/syscalls/gettid.S
deleted file mode 100644
index cfdc57b..0000000
--- a/libc/arch-mips/syscalls/gettid.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(gettid)
- .set noreorder
- .cpload t9
- li v0, __NR_gettid
- syscall
- bnez a3, 1f
- move a0, v0
- j ra
- nop
-1:
- la t9,__set_errno
- j t9
- nop
- .set reorder
-END(gettid)
diff --git a/libc/arch-mips64/mips64.mk b/libc/arch-mips64/mips64.mk
index 5759104..9a24c61 100644
--- a/libc/arch-mips64/mips64.mk
+++ b/libc/arch-mips64/mips64.mk
@@ -17,7 +17,6 @@
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wmemmove.c \
- upstream-openbsd/lib/libc/string/bcopy.c \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/stpncpy.c \
upstream-openbsd/lib/libc/string/strcat.c \
@@ -42,7 +41,6 @@
### CPU specific source files
libc_bionic_src_files_mips64 := \
arch-mips64/bionic/__bionic_clone.S \
- arch-mips64/bionic/bzero.S \
arch-mips64/bionic/_exit_with_stack_teardown.S \
arch-mips64/bionic/__get_sp.S \
arch-mips64/bionic/getdents.cpp \
diff --git a/libc/arch-mips64/syscalls/gettid.S b/libc/arch-mips64/syscalls/gettid.S
deleted file mode 100644
index 30c30c8..0000000
--- a/libc/arch-mips64/syscalls/gettid.S
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(gettid)
- .set push
- .set noreorder
- li v0, __NR_gettid
- 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(gettid)
diff --git a/libc/arch-x86/syscalls/gettid.S b/libc/arch-x86/syscalls/gettid.S
deleted file mode 100644
index 1f264b1..0000000
--- a/libc/arch-x86/syscalls/gettid.S
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(gettid)
- movl $__NR_gettid, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- ret
-END(gettid)
diff --git a/libc/arch-x86_64/string/sse2-bcopy-slm.S b/libc/arch-x86_64/string/sse2-bcopy-slm.S
deleted file mode 100644
index effab0e..0000000
--- a/libc/arch-x86_64/string/sse2-bcopy-slm.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright (c) 2014, 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 USE_AS_BCOPY
-#define MEMMOVE bcopy
-#include "sse2-memmove-slm.S"
diff --git a/libc/arch-x86_64/string/sse2-bzero-slm.S b/libc/arch-x86_64/string/sse2-bzero-slm.S
deleted file mode 100644
index 446ea5b..0000000
--- a/libc/arch-x86_64/string/sse2-bzero-slm.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright (c) 2014, 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 USE_AS_BZERO_P
-#define MEMSET bzero
-#include "sse2-memset-slm.S"
diff --git a/libc/arch-x86_64/syscalls/gettid.S b/libc/arch-x86_64/syscalls/gettid.S
deleted file mode 100644
index 65ecc16..0000000
--- a/libc/arch-x86_64/syscalls/gettid.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(gettid)
- movl $__NR_gettid, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(gettid)
diff --git a/libc/arch-x86_64/x86_64.mk b/libc/arch-x86_64/x86_64.mk
index c54cdb8..2f0cf2d 100644
--- a/libc/arch-x86_64/x86_64.mk
+++ b/libc/arch-x86_64/x86_64.mk
@@ -42,8 +42,6 @@
bionic/__memcmp16.cpp \
libc_bionic_src_files_x86_64 += \
- arch-x86_64/string/sse2-bcopy-slm.S \
- arch-x86_64/string/sse2-bzero-slm.S \
arch-x86_64/string/sse2-memcpy-slm.S \
arch-x86_64/string/sse2-memmove-slm.S \
arch-x86_64/string/sse2-memset-slm.S \
diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c
index 3a615d2..2d67392 100644
--- a/libc/bionic/dlmalloc.c
+++ b/libc/bionic/dlmalloc.c
@@ -46,14 +46,11 @@
*((int**) 0xdeadbaad) = (int*) address;
}
-static void* named_anonymous_mmap(size_t length)
-{
- void* ret;
- ret = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- if (ret == MAP_FAILED)
- return ret;
-
- __bionic_name_mem(ret, length, "libc_malloc");
-
- return ret;
+static void* named_anonymous_mmap(size_t length) {
+ void* map = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (map == MAP_FAILED) {
+ return map;
+ }
+ __bionic_name_mem(map, length, "libc_malloc");
+ return map;
}
diff --git a/libc/bionic/dlmalloc.h b/libc/bionic/dlmalloc.h
index 71b3be8..e065687 100644
--- a/libc/bionic/dlmalloc.h
+++ b/libc/bionic/dlmalloc.h
@@ -17,6 +17,9 @@
#ifndef LIBC_BIONIC_DLMALLOC_H_
#define LIBC_BIONIC_DLMALLOC_H_
+#include <sys/cdefs.h>
+#include <stddef.h>
+
/* Configure dlmalloc. */
#define HAVE_GETPAGESIZE 1
#define MALLOC_INSPECT_ALL 1
@@ -29,6 +32,12 @@
#define USE_SPIN_LOCKS 0
#define DEFAULT_MMAP_THRESHOLD (64U * 1024U)
+/* Export two symbols used by the VM. */
+__BEGIN_DECLS
+int dlmalloc_trim(size_t) __LIBC_ABI_PUBLIC__;
+void dlmalloc_inspect_all(void (*handler)(void*, void*, size_t, void*), void*) __LIBC_ABI_PUBLIC__;
+__END_DECLS
+
/* Include the proper definitions. */
#include "../upstream-dlmalloc/malloc.h"
diff --git a/libc/arch-mips64/bionic/bzero.S b/libc/bionic/gettid.cpp
similarity index 84%
rename from libc/arch-mips64/bionic/bzero.S
rename to libc/bionic/gettid.cpp
index 76c6bc2..f42e36a 100644
--- a/libc/arch-mips64/bionic/bzero.S
+++ b/libc/bionic/gettid.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,16 +26,10 @@
* SUCH DAMAGE.
*/
-#include <private/bionic_asm.h>
+#include <unistd.h>
-/*
- * void bzero(void *s, size_t n);
- */
-LEAF(bzero,0)
- SETUP_GP64(t0,bzero)
- move a2,a1
- move a1,zero
- LA t9,memset
- RESTORE_GP64
- j t9
-END(bzero)
+#include "pthread_internal.h"
+
+pid_t gettid() {
+ return __get_thread()->tid;
+}
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index 659cf39..7c46364 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -94,7 +94,7 @@
// Note that the dynamic linker has also run all constructors in the
// executable at this point.
__noreturn void __libc_init(void* raw_args,
- void (*onexit)(void),
+ void (*onexit)(void) __unused,
int (*slingshot)(int, char**, char**),
structors_array_t const * const structors) {
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index e45422e..ab0b3a6 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -85,7 +85,7 @@
}
__noreturn void __libc_init(void* raw_args,
- void (*onexit)(void),
+ void (*onexit)(void) __unused,
int (*slingshot)(int, char**, char**),
structors_array_t const * const structors) {
KernelArgumentBlock args(raw_args);
diff --git a/libc/bionic/memmove.c b/libc/bionic/memmove.c
index a9fc1b5..39c766e 100644
--- a/libc/bionic/memmove.c
+++ b/libc/bionic/memmove.c
@@ -25,22 +25,6 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#undef _FORTIFY_SOURCE
-#include <string.h>
-#include <strings.h>
-void *memmove(void *dst, const void *src, size_t n)
-{
- const char *p = src;
- char *q = dst;
- /* We can use the optimized memcpy if the source and destination
- * don't overlap.
- */
- if (__builtin_expect(((q < p) && ((size_t)(p - q) >= n))
- || ((p < q) && ((size_t)(q - p) >= n)), 1)) {
- return memcpy(dst, src, n);
- } else {
- bcopy(src, dst, n);
- return dst;
- }
-}
+#define MEMMOVE
+#include "upstream-openbsd/lib/libc/string/bcopy.c"
diff --git a/libc/bionic/new.cpp b/libc/bionic/new.cpp
index cb19dfa..fcfd1bd 100644
--- a/libc/bionic/new.cpp
+++ b/libc/bionic/new.cpp
@@ -14,15 +14,18 @@
* limitations under the License.
*/
+#include <errno.h>
#include <new>
#include <stdlib.h>
+#include "private/libc_logging.h"
+
const std::nothrow_t std::nothrow = {};
void* operator new(std::size_t size) {
void* p = malloc(size);
if (p == NULL) {
- abort();
+ __libc_fatal("new failed to allocate %zu bytes", size);
}
return p;
}
@@ -30,7 +33,7 @@
void* operator new[](std::size_t size) {
void* p = malloc(size);
if (p == NULL) {
- abort();
+ __libc_fatal("new[] failed to allocate %zu bytes", size);
}
return p;
}
diff --git a/libc/include/strings.h b/libc/include/strings.h
index e72798b..8f5fec5 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -43,20 +43,14 @@
#include <sys/cdefs.h>
__BEGIN_DECLS
-void bcopy(const void *, void *, size_t);
-void bzero(void *, size_t);
+#define bcopy(b1, b2, len) (void)(memmove((b2), (b1), (len)))
+#define bzero(b, len) (void)(memset((b), '\0', (len)))
+
int ffs(int);
char *index(const char *, int);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
-#if defined(__BIONIC_FORTIFY)
-__BIONIC_FORTIFY_INLINE
-void bzero (void *s, size_t n) {
- __builtin___memset_chk(s, '\0', n, __builtin_object_size (s, 0));
-}
-#endif /* defined(__BIONIC_FORTIFY) */
-
__END_DECLS
#endif /* !defined(_STRINGS_H_) */
diff --git a/libdl/Android.mk b/libdl/Android.mk
index 3d60474..cb1cb7d 100644
--- a/libdl/Android.mk
+++ b/libdl/Android.mk
@@ -22,7 +22,7 @@
LOCAL_LDFLAGS_x86_64 := $(LOCAL_LDFLAGS_x86)
LOCAL_SRC_FILES:= libdl.c
-LOCAL_CFLAGS := -Wall -Wextra -Werror
+LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror
LOCAL_MODULE := libdl
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
diff --git a/linker/Android.mk b/linker/Android.mk
index d2bcfaf..811cf6e 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -26,7 +26,7 @@
-fno-stack-protector \
-Wstrict-overflow=5 \
-fvisibility=hidden \
- -Wall -Wextra -Werror \
+ -Wall -Wextra -Wunused -Werror \
LOCAL_CONLYFLAGS += \
-std=gnu99 \
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 7bcb59f..6d63ad6 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -65,10 +65,9 @@
do_android_update_LD_LIBRARY_PATH(ld_library_path);
}
-static void* dlopen_ext(const char* filename, int flags, const android_dlextinfo* extinfo, const void* caller_addr) {
+static void* dlopen_ext(const char* filename, int flags, const android_dlextinfo* extinfo) {
ScopedPthreadMutexLocker locker(&g_dl_mutex);
- soinfo* caller_soinfo = find_containing_library(caller_addr);
- soinfo* result = do_dlopen(filename, flags, caller_soinfo, extinfo);
+ soinfo* result = do_dlopen(filename, flags, extinfo);
if (result == NULL) {
__bionic_format_dlerror("dlopen failed", linker_get_error_buffer());
return NULL;
@@ -77,13 +76,11 @@
}
void* android_dlopen_ext(const char* filename, int flags, const android_dlextinfo* extinfo) {
- void* caller_addr = __builtin_return_address(0);
- return dlopen_ext(filename, flags, extinfo, caller_addr);
+ return dlopen_ext(filename, flags, extinfo);
}
void* dlopen(const char* filename, int flags) {
- void* caller_addr = __builtin_return_address(0);
- return dlopen_ext(filename, flags, NULL, caller_addr);
+ return dlopen_ext(filename, flags, NULL);
}
void* dlsym(void* handle, const char* symbol) {
@@ -258,4 +255,3 @@
return &__libdl_info;
}
-
diff --git a/linker/linked_list.h b/linker/linked_list.h
index a6bea6c..52af0f1 100644
--- a/linker/linked_list.h
+++ b/linker/linked_list.h
@@ -59,7 +59,6 @@
template<typename F>
void remove_if(F&& predicate) {
- LinkedListEntry<T>* e = head_;
for (LinkedListEntry<T>* e = head_; e != nullptr; e = e->next) {
if (e->element != nullptr && predicate(e->element)) {
e->element = nullptr;
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 98cb178..a22233d 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -827,7 +827,7 @@
}
}
-soinfo* do_dlopen(const char* name, int flags, soinfo* caller, const android_dlextinfo* extinfo) {
+soinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo) {
if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL|RTLD_NOLOAD)) != 0) {
DL_ERR("invalid flags to dlopen: %x", flags);
return NULL;
diff --git a/linker/linker.h b/linker/linker.h
index 9d4099d..0a72d92 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -231,7 +231,7 @@
void do_android_get_LD_LIBRARY_PATH(char*, size_t);
void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
-soinfo* do_dlopen(const char* name, int flags, soinfo* caller, const android_dlextinfo* extinfo);
+soinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo);
void do_dlclose(soinfo* si);
ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start);
diff --git a/linker/tests/Android.mk b/linker/tests/Android.mk
index 831cfcb..683f9ee 100644
--- a/linker/tests/Android.mk
+++ b/linker/tests/Android.mk
@@ -26,7 +26,7 @@
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_CFLAGS += -g -Wall -Wextra -Werror -std=gnu++11
+LOCAL_CFLAGS += -g -Wall -Wextra -Wunused -Werror -std=gnu++11
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../libc/
LOCAL_SRC_FILES := \
diff --git a/tests/Android.mk b/tests/Android.mk
index ffd4f2b..25f8b2b 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -34,7 +34,7 @@
test_cflags = \
-fstack-protector-all \
-g \
- -Wall -Wextra \
+ -Wall -Wextra -Wunused \
-Werror \
-fno-builtin \