summaryrefslogtreecommitdiffstats
path: root/libc/bionic
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-10-09 23:29:00 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-10-09 23:29:00 +0000
commitbc545e8a98dd4e1148e8b9c9ca491d1a481ee94d (patch)
treef0af7a07b2ea3ba19b1f083df9430fc0d57f4c0b /libc/bionic
parentc147478cb75cfaa2aadc67fd920e8765503d97cc (diff)
parenteb847bc8666842a3cfc9c06e8458ad1abebebaf0 (diff)
downloadbionic-bc545e8a98dd4e1148e8b9c9ca491d1a481ee94d.zip
bionic-bc545e8a98dd4e1148e8b9c9ca491d1a481ee94d.tar.gz
bionic-bc545e8a98dd4e1148e8b9c9ca491d1a481ee94d.tar.bz2
Merge "Fix x86_64 build, clean up intermediate libraries."
Diffstat (limited to 'libc/bionic')
-rw-r--r--libc/bionic/__FD_chk.cpp2
-rw-r--r--libc/bionic/__errno.cpp3
-rw-r--r--libc/bionic/__fgets_chk.cpp2
-rw-r--r--libc/bionic/__memcpy_chk.cpp2
-rw-r--r--libc/bionic/__memmove_chk.cpp2
-rw-r--r--libc/bionic/__memset_chk.cpp2
-rw-r--r--libc/bionic/__recvfrom_chk.cpp2
-rw-r--r--libc/bionic/__stack_chk_fail.cpp4
-rw-r--r--libc/bionic/__strcat_chk.cpp2
-rw-r--r--libc/bionic/__strchr_chk.cpp2
-rw-r--r--libc/bionic/__strcpy_chk.cpp2
-rw-r--r--libc/bionic/__strlcat_chk.cpp2
-rw-r--r--libc/bionic/__strlcpy_chk.cpp2
-rw-r--r--libc/bionic/__strlen_chk.cpp2
-rw-r--r--libc/bionic/__strncat_chk.cpp2
-rw-r--r--libc/bionic/__strncpy_chk.cpp2
-rw-r--r--libc/bionic/__strrchr_chk.cpp2
-rw-r--r--libc/bionic/__thread_entry.cpp57
-rw-r--r--libc/bionic/__umask_chk.cpp3
-rw-r--r--libc/bionic/__vsnprintf_chk.cpp2
-rw-r--r--libc/bionic/__vsprintf_chk.cpp2
-rw-r--r--libc/bionic/arc4random.c2
-rw-r--r--libc/bionic/assert.cpp2
-rw-r--r--libc/bionic/cpuacct.h41
-rw-r--r--libc/bionic/debug_stacktrace.cpp2
-rw-r--r--libc/bionic/fork.c3
-rw-r--r--libc/bionic/libc_init_common.cpp5
-rw-r--r--libc/bionic/libc_init_dynamic.cpp5
-rw-r--r--libc/bionic/libc_init_static.cpp5
-rw-r--r--libc/bionic/libc_logging.cpp4
-rw-r--r--libc/bionic/libgen.cpp2
-rw-r--r--libc/bionic/malloc_debug_check.cpp4
-rw-r--r--libc/bionic/malloc_debug_common.cpp4
-rw-r--r--libc/bionic/malloc_debug_common.h2
-rw-r--r--libc/bionic/malloc_debug_leak.cpp5
-rw-r--r--libc/bionic/malloc_debug_qemu.cpp2
-rw-r--r--libc/bionic/open.c2
-rw-r--r--libc/bionic/openat.c2
-rw-r--r--libc/bionic/pthread.c11
-rw-r--r--libc/bionic/pthread_create.cpp28
-rw-r--r--libc/bionic/pthread_debug.cpp5
-rw-r--r--libc/bionic/pthread_getschedparam.cpp2
-rw-r--r--libc/bionic/pthread_internal.h2
-rw-r--r--libc/bionic/pthread_internals.cpp4
-rw-r--r--libc/bionic/pthread_key.cpp2
-rw-r--r--libc/bionic/pthread_kill.cpp2
-rw-r--r--libc/bionic/pthread_setschedparam.cpp2
-rw-r--r--libc/bionic/semaphore.c5
-rw-r--r--libc/bionic/strerror.cpp2
-rw-r--r--libc/bionic/strsignal.cpp2
-rw-r--r--libc/bionic/sysconf.cpp3
-rw-r--r--libc/bionic/system_properties.c3
52 files changed, 173 insertions, 93 deletions
diff --git a/libc/bionic/__FD_chk.cpp b/libc/bionic/__FD_chk.cpp
index 23d3084..5c2338d 100644
--- a/libc/bionic/__FD_chk.cpp
+++ b/libc/bionic/__FD_chk.cpp
@@ -28,7 +28,7 @@
#undef _FORTIFY_SOURCE
#include <sys/select.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
extern "C" int __FD_ISSET_chk(int fd, fd_set* set, size_t set_size) {
if (__predict_false(fd < 0)) {
diff --git a/libc/bionic/__errno.cpp b/libc/bionic/__errno.cpp
index 9caa618..c9c1605 100644
--- a/libc/bionic/__errno.cpp
+++ b/libc/bionic/__errno.cpp
@@ -27,9 +27,10 @@
*/
#include <errno.h>
-#include <bionic_tls.h>
#include <stdint.h>
+#include "private/bionic_tls.h"
+
volatile int* __errno() {
return reinterpret_cast<int*>(&(__get_tls()[TLS_SLOT_ERRNO]));
}
diff --git a/libc/bionic/__fgets_chk.cpp b/libc/bionic/__fgets_chk.cpp
index 7f6b067..fc903e4 100644
--- a/libc/bionic/__fgets_chk.cpp
+++ b/libc/bionic/__fgets_chk.cpp
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* __fgets_chk. Called in place of fgets() when we know the
diff --git a/libc/bionic/__memcpy_chk.cpp b/libc/bionic/__memcpy_chk.cpp
index 2839795..9416e49 100644
--- a/libc/bionic/__memcpy_chk.cpp
+++ b/libc/bionic/__memcpy_chk.cpp
@@ -29,7 +29,7 @@
#undef _FORTIFY_SOURCE
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __memcpy_chk.
diff --git a/libc/bionic/__memmove_chk.cpp b/libc/bionic/__memmove_chk.cpp
index b653968..b52f7c8 100644
--- a/libc/bionic/__memmove_chk.cpp
+++ b/libc/bionic/__memmove_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____memmove_chk.
diff --git a/libc/bionic/__memset_chk.cpp b/libc/bionic/__memset_chk.cpp
index 49a1548..72551f0 100644
--- a/libc/bionic/__memset_chk.cpp
+++ b/libc/bionic/__memset_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____memset_chk.
diff --git a/libc/bionic/__recvfrom_chk.cpp b/libc/bionic/__recvfrom_chk.cpp
index 0c042cc..00de1d9 100644
--- a/libc/bionic/__recvfrom_chk.cpp
+++ b/libc/bionic/__recvfrom_chk.cpp
@@ -30,7 +30,7 @@
#include <stddef.h>
#include <sys/socket.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
extern "C"
ssize_t __recvfrom_chk(int socket, void* buf, size_t len, size_t buflen, unsigned int flags,
diff --git a/libc/bionic/__stack_chk_fail.cpp b/libc/bionic/__stack_chk_fail.cpp
index 8b9ed5e..6e052e3 100644
--- a/libc/bionic/__stack_chk_fail.cpp
+++ b/libc/bionic/__stack_chk_fail.cpp
@@ -28,8 +28,8 @@
#include <stdlib.h>
-#include "bionic_ssp.h"
-#include "libc_logging.h"
+#include "private/bionic_ssp.h"
+#include "private/libc_logging.h"
void __stack_chk_fail() {
__libc_fatal("stack corruption detected");
diff --git a/libc/bionic/__strcat_chk.cpp b/libc/bionic/__strcat_chk.cpp
index 3dda43a..f15cb5c 100644
--- a/libc/bionic/__strcat_chk.cpp
+++ b/libc/bionic/__strcat_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____strcat_chk.
diff --git a/libc/bionic/__strchr_chk.cpp b/libc/bionic/__strchr_chk.cpp
index 3982d60..51d35d0 100644
--- a/libc/bionic/__strchr_chk.cpp
+++ b/libc/bionic/__strchr_chk.cpp
@@ -28,7 +28,7 @@
*/
#include <string.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
extern "C" char* __strchr_chk(const char* p, int ch, size_t s_len) {
for (;; ++p, s_len--) {
diff --git a/libc/bionic/__strcpy_chk.cpp b/libc/bionic/__strcpy_chk.cpp
index 41990f9..9b39627 100644
--- a/libc/bionic/__strcpy_chk.cpp
+++ b/libc/bionic/__strcpy_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____strcpy_chk.
diff --git a/libc/bionic/__strlcat_chk.cpp b/libc/bionic/__strlcat_chk.cpp
index 32573c2..783dd84 100644
--- a/libc/bionic/__strlcat_chk.cpp
+++ b/libc/bionic/__strlcat_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* __strlcat_chk. Called in place of strlcat() when we know the
diff --git a/libc/bionic/__strlcpy_chk.cpp b/libc/bionic/__strlcpy_chk.cpp
index 1e482e1..359e918 100644
--- a/libc/bionic/__strlcpy_chk.cpp
+++ b/libc/bionic/__strlcpy_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* __strlcpy_chk. Called in place of strlcpy() when we know the
diff --git a/libc/bionic/__strlen_chk.cpp b/libc/bionic/__strlen_chk.cpp
index 494f7bf..d4c5e43 100644
--- a/libc/bionic/__strlen_chk.cpp
+++ b/libc/bionic/__strlen_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __strlen_chk.
diff --git a/libc/bionic/__strncat_chk.cpp b/libc/bionic/__strncat_chk.cpp
index 296217e..cdb3c80 100644
--- a/libc/bionic/__strncat_chk.cpp
+++ b/libc/bionic/__strncat_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____strncat_chk.
diff --git a/libc/bionic/__strncpy_chk.cpp b/libc/bionic/__strncpy_chk.cpp
index 5e72c2c..d0e9013 100644
--- a/libc/bionic/__strncpy_chk.cpp
+++ b/libc/bionic/__strncpy_chk.cpp
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____strncpy_chk.
diff --git a/libc/bionic/__strrchr_chk.cpp b/libc/bionic/__strrchr_chk.cpp
index e6daf8f..fe56c9a 100644
--- a/libc/bionic/__strrchr_chk.cpp
+++ b/libc/bionic/__strrchr_chk.cpp
@@ -29,7 +29,7 @@
*/
#include <string.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
extern "C" char* __strrchr_chk(const char *p, int ch, size_t s_len)
{
diff --git a/libc/bionic/__thread_entry.cpp b/libc/bionic/__thread_entry.cpp
new file mode 100644
index 0000000..8300a64
--- /dev/null
+++ b/libc/bionic/__thread_entry.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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 <pthread.h>
+
+#include "pthread_internal.h"
+
+#include "private/bionic_tls.h"
+
+// This trampoline is called from the assembly _pthread_clone function.
+// Our 'tls' and __pthread_clone's 'child_stack' are one and the same, just growing in
+// opposite directions.
+extern "C" void __thread_entry(void* (*func)(void*), void* arg, void** tls) {
+ // Wait for our creating thread to release us. This lets it have time to
+ // notify gdb about this thread before we start doing anything.
+ // This also provides the memory barrier needed to ensure that all memory
+ // accesses previously made by the creating thread are visible to us.
+ pthread_mutex_t* start_mutex = (pthread_mutex_t*) &tls[TLS_SLOT_SELF];
+ pthread_mutex_lock(start_mutex);
+ pthread_mutex_destroy(start_mutex);
+
+ pthread_internal_t* thread = (pthread_internal_t*) tls[TLS_SLOT_THREAD_ID];
+ thread->tls = tls;
+ __init_tls(thread);
+
+ if ((thread->internal_flags & PTHREAD_INTERNAL_FLAG_THREAD_INIT_FAILED) != 0) {
+ pthread_exit(NULL);
+ }
+
+ void* result = func(arg);
+ pthread_exit(result);
+}
diff --git a/libc/bionic/__umask_chk.cpp b/libc/bionic/__umask_chk.cpp
index 8fe95a2..7d2a99a 100644
--- a/libc/bionic/__umask_chk.cpp
+++ b/libc/bionic/__umask_chk.cpp
@@ -30,9 +30,10 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include "libc_logging.h"
#include <stdlib.h>
+#include "private/libc_logging.h"
+
/*
* Runtime implementation of __umask_chk.
*
diff --git a/libc/bionic/__vsnprintf_chk.cpp b/libc/bionic/__vsnprintf_chk.cpp
index 257cf5e..a03d12f 100644
--- a/libc/bionic/__vsnprintf_chk.cpp
+++ b/libc/bionic/__vsnprintf_chk.cpp
@@ -29,7 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____vsnprintf_chk.
diff --git a/libc/bionic/__vsprintf_chk.cpp b/libc/bionic/__vsprintf_chk.cpp
index 290de9b..3810694 100644
--- a/libc/bionic/__vsprintf_chk.cpp
+++ b/libc/bionic/__vsprintf_chk.cpp
@@ -29,7 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* Runtime implementation of __builtin____vsprintf_chk.
diff --git a/libc/bionic/arc4random.c b/libc/bionic/arc4random.c
index d70580a..eac4b0c 100644
--- a/libc/bionic/arc4random.c
+++ b/libc/bionic/arc4random.c
@@ -41,7 +41,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
-#include "thread_private.h"
+#include "private/thread_private.h"
/* BIONIC-BEGIN */
/* this lock should protect the global variables in this file */
diff --git a/libc/bionic/assert.cpp b/libc/bionic/assert.cpp
index 84024c7..ba67143 100644
--- a/libc/bionic/assert.cpp
+++ b/libc/bionic/assert.cpp
@@ -30,7 +30,7 @@
#include <assert.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
void __assert(const char* file, int line, const char* failed_expression) {
__libc_fatal("%s:%d: assertion \"%s\" failed", file, line, failed_expression);
diff --git a/libc/bionic/cpuacct.h b/libc/bionic/cpuacct.h
new file mode 100644
index 0000000..8e24c8c
--- /dev/null
+++ b/libc/bionic/cpuacct.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 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 _BIONIC_CPUACCT_H
+#define _BIONIC_CPUACCT_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+extern int cpuacct_add(uid_t uid);
+
+__END_DECLS
+
+#endif /* _BIONIC_CPUACCT_H */
diff --git a/libc/bionic/debug_stacktrace.cpp b/libc/bionic/debug_stacktrace.cpp
index 26d5c6a..5ddc00c 100644
--- a/libc/bionic/debug_stacktrace.cpp
+++ b/libc/bionic/debug_stacktrace.cpp
@@ -35,7 +35,7 @@
#include <sys/types.h>
#include "debug_mapinfo.h"
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/* depends how the system includes define this */
#ifdef HAVE_UNWIND_CONTEXT_STRUCT
diff --git a/libc/bionic/fork.c b/libc/bionic/fork.c
index d83c535..d30b41b 100644
--- a/libc/bionic/fork.c
+++ b/libc/bionic/fork.c
@@ -27,9 +27,10 @@
*/
#include <unistd.h>
#include "pthread_internal.h"
-#include "bionic_pthread.h"
#include "cpuacct.h"
+#include "private/bionic_pthread.h"
+
extern int __fork(void);
int fork(void)
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 714d0bc..479cadf 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -28,8 +28,6 @@
#include "libc_init_common.h"
-#include <asm/page.h>
-#include <bionic_tls.h>
#include <elf.h>
#include <errno.h>
#include <stddef.h>
@@ -44,6 +42,7 @@
#include "atexit.h"
#include "private/bionic_auxv.h"
#include "private/bionic_ssp.h"
+#include "private/bionic_tls.h"
#include "private/KernelArgumentBlock.h"
#include "pthread_internal.h"
@@ -57,7 +56,7 @@ const char* __progname;
// Declared in <unistd.h>.
char** environ;
-// Declared in <private/bionic_ssp.h>.
+// Declared in "private/bionic_ssp.h".
uintptr_t __stack_chk_guard = 0;
static size_t get_main_thread_stack_size() {
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index 4e1374e..61fb887 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -49,9 +49,10 @@
#include <stdint.h>
#include <elf.h>
#include "atexit.h"
-#include "KernelArgumentBlock.h"
#include "libc_init_common.h"
-#include <bionic_tls.h>
+
+#include "private/bionic_tls.h"
+#include "private/KernelArgumentBlock.h"
extern "C" {
extern void pthread_debug_init(void);
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index a60e414..1825167 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -47,11 +47,12 @@
#include <sys/mman.h>
#include "atexit.h"
-#include "bionic_tls.h"
-#include "KernelArgumentBlock.h"
#include "libc_init_common.h"
#include "pthread_internal.h"
+#include "private/bionic_tls.h"
+#include "private/KernelArgumentBlock.h"
+
// Returns the address of the page containing address 'x'.
#define PAGE_START(x) ((x) & PAGE_MASK)
diff --git a/libc/bionic/libc_logging.cpp b/libc/bionic/libc_logging.cpp
index 635f8d1..c7eca8a 100644
--- a/libc/bionic/libc_logging.cpp
+++ b/libc/bionic/libc_logging.cpp
@@ -26,8 +26,8 @@
* SUCH DAMAGE.
*/
-#include <../private/libc_logging.h> // Relative path so we can #include this .cpp file for testing.
-#include <../private/ScopedPthreadMutexLocker.h>
+#include "../private/libc_logging.h" // Relative path so we can #include this .cpp file for testing.
+#include "../private/ScopedPthreadMutexLocker.h"
#include <assert.h>
#include <errno.h>
diff --git a/libc/bionic/libgen.cpp b/libc/bionic/libgen.cpp
index f7181e7..d8df494 100644
--- a/libc/bionic/libgen.cpp
+++ b/libc/bionic/libgen.cpp
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#include <sys/param.h>
-#include "ThreadLocalBuffer.h"
+#include "private/ThreadLocalBuffer.h"
GLOBAL_INIT_THREAD_LOCAL_BUFFER(basename);
GLOBAL_INIT_THREAD_LOCAL_BUFFER(dirname);
diff --git a/libc/bionic/malloc_debug_check.cpp b/libc/bionic/malloc_debug_check.cpp
index a5d49cb..7dd8e3c 100644
--- a/libc/bionic/malloc_debug_check.cpp
+++ b/libc/bionic/malloc_debug_check.cpp
@@ -48,9 +48,9 @@
#include "debug_mapinfo.h"
#include "debug_stacktrace.h"
#include "dlmalloc.h"
-#include "libc_logging.h"
+#include "private/libc_logging.h"
#include "malloc_debug_common.h"
-#include "ScopedPthreadMutexLocker.h"
+#include "private/ScopedPthreadMutexLocker.h"
/* libc.debug.malloc.backlog */
extern unsigned int gMallocDebugBacklog;
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp
index e33405e..85f7791 100644
--- a/libc/bionic/malloc_debug_common.cpp
+++ b/libc/bionic/malloc_debug_common.cpp
@@ -47,7 +47,7 @@
#include <unistd.h>
#include "dlmalloc.h"
-#include "ScopedPthreadMutexLocker.h"
+#include "private/ScopedPthreadMutexLocker.h"
/*
* In a VM process, this is set to 1 after fork()ing out of zygote.
@@ -250,7 +250,7 @@ extern "C" size_t malloc_usable_size(const void* mem) {
#include <sys/system_properties.h>
#include <dlfcn.h>
#include <stdio.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/* Table for dispatching malloc calls, depending on environment. */
static MallocDebug gMallocUse __attribute__((aligned(32))) = {
diff --git a/libc/bionic/malloc_debug_common.h b/libc/bionic/malloc_debug_common.h
index a3f9909..28be042 100644
--- a/libc/bionic/malloc_debug_common.h
+++ b/libc/bionic/malloc_debug_common.h
@@ -35,7 +35,7 @@
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
#define HASHTABLE_SIZE 1543
#define BACKTRACE_SIZE 32
diff --git a/libc/bionic/malloc_debug_leak.cpp b/libc/bionic/malloc_debug_leak.cpp
index 45b45c2..3397def 100644
--- a/libc/bionic/malloc_debug_leak.cpp
+++ b/libc/bionic/malloc_debug_leak.cpp
@@ -47,9 +47,10 @@
#include "debug_stacktrace.h"
#include "dlmalloc.h"
-#include "libc_logging.h"
#include "malloc_debug_common.h"
-#include "ScopedPthreadMutexLocker.h"
+
+#include "private/libc_logging.h"
+#include "private/ScopedPthreadMutexLocker.h"
// This file should be included into the build only when
// MALLOC_LEAK_CHECK, or MALLOC_QEMU_INSTRUMENT, or both
diff --git a/libc/bionic/malloc_debug_qemu.cpp b/libc/bionic/malloc_debug_qemu.cpp
index 4d00066..5a91daa 100644
--- a/libc/bionic/malloc_debug_qemu.cpp
+++ b/libc/bionic/malloc_debug_qemu.cpp
@@ -51,7 +51,7 @@
#include <unistd.h>
#include <errno.h>
#include "dlmalloc.h"
-#include "libc_logging.h"
+#include "private/libc_logging.h"
#include "malloc_debug_common.h"
/* This file should be included into the build only when
diff --git a/libc/bionic/open.c b/libc/bionic/open.c
index 424573f..cde3029 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/open.c
@@ -29,7 +29,7 @@
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
extern int __open(const char*, int, int);
diff --git a/libc/bionic/openat.c b/libc/bionic/openat.c
index 2d09d17..b8c887e 100644
--- a/libc/bionic/openat.c
+++ b/libc/bionic/openat.c
@@ -29,7 +29,7 @@
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
-#include "libc_logging.h"
+#include "private/libc_logging.h"
extern int __openat(int, const char*, int, int);
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index ab806c0..32812b4 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -34,12 +34,13 @@
#include <sys/mman.h>
#include <unistd.h>
-#include "bionic_atomic_inline.h"
-#include "bionic_futex.h"
-#include "bionic_pthread.h"
-#include "bionic_tls.h"
#include "pthread_internal.h"
-#include "thread_private.h"
+
+#include "private/bionic_atomic_inline.h"
+#include "private/bionic_futex.h"
+#include "private/bionic_pthread.h"
+#include "private/bionic_tls.h"
+#include "private/thread_private.h"
extern void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex);
extern void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex);
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 9e06afc..8338ad5 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -52,8 +52,6 @@ extern "C" void ATTRIBUTES _thread_created_hook(pid_t thread_id);
extern "C" int __set_tls(void* ptr);
-static const int kPthreadInitFailed = 1;
-
static pthread_mutex_t gPthreadStackCreationLock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t gDebuggerNotificationLock = PTHREAD_MUTEX_INITIALIZER;
@@ -84,30 +82,6 @@ void __init_tls(pthread_internal_t* thread) {
}
}
-// This trampoline is called from the assembly _pthread_clone function.
-// Our 'tls' and __pthread_clone's 'child_stack' are one and the same, just growing in
-// opposite directions.
-extern "C" void __thread_entry(void* (*func)(void*), void* arg, void** tls) {
- // Wait for our creating thread to release us. This lets it have time to
- // notify gdb about this thread before we start doing anything.
- // This also provides the memory barrier needed to ensure that all memory
- // accesses previously made by the creating thread are visible to us.
- pthread_mutex_t* start_mutex = (pthread_mutex_t*) &tls[TLS_SLOT_SELF];
- pthread_mutex_lock(start_mutex);
- pthread_mutex_destroy(start_mutex);
-
- pthread_internal_t* thread = (pthread_internal_t*) tls[TLS_SLOT_THREAD_ID];
- thread->tls = tls;
- __init_tls(thread);
-
- if ((thread->internal_flags & kPthreadInitFailed) != 0) {
- pthread_exit(NULL);
- }
-
- void* result = func(arg);
- pthread_exit(result);
-}
-
__LIBC_ABI_PRIVATE__
int _init_thread(pthread_internal_t* thread, bool add_to_thread_list) {
int error = 0;
@@ -240,7 +214,7 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr,
if (init_errno != 0) {
// Mark the thread detached and let its __thread_entry run to
// completion. (It'll just exit immediately, cleaning up its resources.)
- thread->internal_flags |= kPthreadInitFailed;
+ thread->internal_flags |= PTHREAD_INTERNAL_FLAG_THREAD_INIT_FAILED;
thread->attr.flags |= PTHREAD_ATTR_FLAG_DETACHED;
return init_errno;
}
diff --git a/libc/bionic/pthread_debug.cpp b/libc/bionic/pthread_debug.cpp
index 94c23de..79a193d 100644
--- a/libc/bionic/pthread_debug.cpp
+++ b/libc/bionic/pthread_debug.cpp
@@ -31,7 +31,6 @@
#include <sys/system_properties.h>
#include <sys/mman.h>
-//#include <dlfcn.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,10 +39,10 @@
#include <unwind.h>
#include <unistd.h>
-#include "bionic_tls.h"
+#include "private/bionic_tls.h"
#include "debug_mapinfo.h"
#include "debug_stacktrace.h"
-#include "libc_logging.h"
+#include "private/libc_logging.h"
/*
* ===========================================================================
diff --git a/libc/bionic/pthread_getschedparam.cpp b/libc/bionic/pthread_getschedparam.cpp
index 03fa5f2..2cdc11a 100644
--- a/libc/bionic/pthread_getschedparam.cpp
+++ b/libc/bionic/pthread_getschedparam.cpp
@@ -28,7 +28,7 @@
#include <errno.h>
-#include "ErrnoRestorer.h"
+#include "private/ErrnoRestorer.h"
#include "pthread_accessor.h"
int pthread_getschedparam(pthread_t t, int* policy, sched_param* param) {
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index 6fe2a98..6b009d4 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -77,6 +77,8 @@ __LIBC_HIDDEN__ void _pthread_internal_remove_locked(pthread_internal_t* thread)
/* Has the thread already exited but not been joined? */
#define PTHREAD_ATTR_FLAG_ZOMBIE 0x00000008
+#define PTHREAD_INTERNAL_FLAG_THREAD_INIT_FAILED 1
+
/*
* Traditionally we give threads a 1MiB stack. When we started
* allocating per-thread alternate signal stacks to ease debugging of
diff --git a/libc/bionic/pthread_internals.cpp b/libc/bionic/pthread_internals.cpp
index 59c6e48..01ecd5f 100644
--- a/libc/bionic/pthread_internals.cpp
+++ b/libc/bionic/pthread_internals.cpp
@@ -28,8 +28,8 @@
#include "pthread_internal.h"
-#include "bionic_tls.h"
-#include "ScopedPthreadMutexLocker.h"
+#include "private/bionic_tls.h"
+#include "private/ScopedPthreadMutexLocker.h"
__LIBC_HIDDEN__ pthread_internal_t* gThreadList = NULL;
__LIBC_HIDDEN__ pthread_mutex_t gThreadListLock = PTHREAD_MUTEX_INITIALIZER;
diff --git a/libc/bionic/pthread_key.cpp b/libc/bionic/pthread_key.cpp
index 706758b..440a715 100644
--- a/libc/bionic/pthread_key.cpp
+++ b/libc/bionic/pthread_key.cpp
@@ -28,7 +28,7 @@
#include <pthread.h>
-#include "bionic_tls.h"
+#include "private/bionic_tls.h"
#include "pthread_internal.h"
/* A technical note regarding our thread-local-storage (TLS) implementation:
diff --git a/libc/bionic/pthread_kill.cpp b/libc/bionic/pthread_kill.cpp
index 54f71ee..163317e 100644
--- a/libc/bionic/pthread_kill.cpp
+++ b/libc/bionic/pthread_kill.cpp
@@ -29,7 +29,7 @@
#include <errno.h>
#include <unistd.h>
-#include "ErrnoRestorer.h"
+#include "private/ErrnoRestorer.h"
#include "pthread_accessor.h"
extern "C" int tgkill(int tgid, int tid, int sig);
diff --git a/libc/bionic/pthread_setschedparam.cpp b/libc/bionic/pthread_setschedparam.cpp
index c383cca..55ec791 100644
--- a/libc/bionic/pthread_setschedparam.cpp
+++ b/libc/bionic/pthread_setschedparam.cpp
@@ -28,7 +28,7 @@
#include <errno.h>
-#include "ErrnoRestorer.h"
+#include "private/ErrnoRestorer.h"
#include "pthread_accessor.h"
int pthread_setschedparam(pthread_t t, int policy, struct sched_param const* param) {
diff --git a/libc/bionic/semaphore.c b/libc/bionic/semaphore.c
index 9bc8412..28fcb1b 100644
--- a/libc/bionic/semaphore.c
+++ b/libc/bionic/semaphore.c
@@ -30,10 +30,11 @@
#include <sys/time.h>
#include <sys/atomics.h>
#include <time.h>
-#include <bionic_atomic_inline.h>
-#include <bionic_futex.h>
#include <limits.h>
+#include "private/bionic_atomic_inline.h"
+#include "private/bionic_futex.h"
+
/* In this implementation, a semaphore contains a
* 31-bit signed value and a 1-bit 'shared' flag
* (for process-sharing purpose).
diff --git a/libc/bionic/strerror.cpp b/libc/bionic/strerror.cpp
index a50c99f..d1518ff 100644
--- a/libc/bionic/strerror.cpp
+++ b/libc/bionic/strerror.cpp
@@ -27,7 +27,7 @@
*/
#include <string.h>
-#include "ThreadLocalBuffer.h"
+#include "private/ThreadLocalBuffer.h"
extern "C" const char* __strerror_lookup(int);
diff --git a/libc/bionic/strsignal.cpp b/libc/bionic/strsignal.cpp
index c549e74..9f0193a 100644
--- a/libc/bionic/strsignal.cpp
+++ b/libc/bionic/strsignal.cpp
@@ -27,7 +27,7 @@
*/
#include <string.h>
-#include "ThreadLocalBuffer.h"
+#include "private/ThreadLocalBuffer.h"
extern "C" const char* __strsignal_lookup(int);
extern "C" const char* __strsignal(int, char*, size_t);
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index e945fbf..db808c2 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -26,8 +26,6 @@
* SUCH DAMAGE.
*/
-#include <asm/page.h>
-#include <bionic_tls.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
@@ -40,6 +38,7 @@
#include <time.h>
#include <unistd.h>
+#include "private/bionic_tls.h"
#include "private/ScopedReaddir.h"
/* seems to be the default on Linux, per the GLibc sources and my own digging */
diff --git a/libc/bionic/system_properties.c b/libc/bionic/system_properties.c
index fd56431..9fdb6f5 100644
--- a/libc/bionic/system_properties.c
+++ b/libc/bionic/system_properties.c
@@ -50,7 +50,8 @@
#include <sys/_system_properties.h>
#include <sys/atomics.h>
-#include <bionic_atomic_inline.h>
+
+#include "private/bionic_atomic_inline.h"
#define ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))