aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-05-11 15:29:03 -0700
committerElliott Hughes <enh@google.com>2017-05-11 15:29:03 -0700
commitdfcb82d92d00c7f1516477b19da97c1d2b07f0b4 (patch)
tree84acbc670a0b351ef7059e8ed2455f08e05b4fff
parent0e986b8d5ddd1d41db18d8e6af1eb5c58fb3dbe8 (diff)
downloadandroid_bionic-dfcb82d92d00c7f1516477b19da97c1d2b07f0b4.tar.gz
android_bionic-dfcb82d92d00c7f1516477b19da97c1d2b07f0b4.tar.bz2
android_bionic-dfcb82d92d00c7f1516477b19da97c1d2b07f0b4.zip
Clean up __isthreaded.
__isthreaded is annoying for ARC++ and useless for everyone. Just hard-code the value in ndk_cruft for LP32 and be done with it. Bug: N/A Test: builds Change-Id: I08f11a404bbec55ed57cb1e18b5116163c7d7d13
-rw-r--r--libc/bionic/ndk_cruft.cpp3
-rw-r--r--libc/bionic/pthread_create.cpp5
-rw-r--r--libc/stdlib/exit.c33
-rw-r--r--libc/upstream-openbsd/android/include/openbsd-compat.h3
4 files changed, 6 insertions, 38 deletions
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 016b47694..dbacf18f0 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -52,6 +52,9 @@ extern "C" {
// LP64 doesn't need to support any legacy cruft.
#if !defined(__LP64__)
+// By the time any NDK-built code is running, there are plenty of threads.
+int __isthreaded = 1;
+
// These were accidentally declared in <unistd.h> because we stupidly used to inline
// getpagesize() and __getpageshift(). Needed for backwards compatibility with old NDK apps.
unsigned int __page_size = PAGE_SIZE;
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 9f4481fd2..9197aa3fe 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -49,8 +49,6 @@
void __init_user_desc(struct user_desc*, bool, void*);
#endif
-extern "C" int __isthreaded;
-
// This code is used both by each new pthread and the code that initializes the main thread.
void __init_tls(pthread_internal_t* thread) {
// Slot 0 must point to itself. The x86 Linux kernel reads the TLS from %fs:0.
@@ -230,9 +228,6 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr,
void* (*start_routine)(void*), void* arg) {
ErrnoRestorer errno_restorer;
- // Inform the rest of the C library that at least one thread was created.
- __isthreaded = 1;
-
pthread_attr_t thread_attr;
if (attr == NULL) {
pthread_attr_init(&thread_attr);
diff --git a/libc/stdlib/exit.c b/libc/stdlib/exit.c
index 10ce674ab..510cb83c8 100644
--- a/libc/stdlib/exit.c
+++ b/libc/stdlib/exit.c
@@ -1,4 +1,3 @@
-/* $OpenBSD: exit.c,v 1.12 2007/09/03 14:40:16 millert Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -28,39 +27,13 @@
* SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdlib.h>
#include <unistd.h>
-/*
- * This variable is zero until a process has created a thread.
- * It is used to avoid calling locking functions in libc when they
- * are not required. By default, libc is intended to be(come)
- * thread-safe, but without a (significant) penalty to non-threaded
- * processes.
- */
-int __isthreaded = 0;
-
-/* BEGIN android-added: using __cxa_finalize and __cxa_thread_finalize */
extern void __cxa_finalize(void* dso_handle);
extern void __cxa_thread_finalize();
-/* END android-added */
-/*
- * Exit, flushing stdio buffers if necessary.
- */
-void
-exit(int status)
-{
- /* BEGIN android-added: call thread_local d-tors */
+void exit(int status) {
__cxa_thread_finalize();
- /* END android-added */
-
- /*
- * Call functions registered by atexit() or _cxa_atexit()
- * (including the stdio cleanup routine) and then _exit().
- */
- __cxa_finalize(NULL);
- _exit(status);
+ __cxa_finalize(NULL);
+ _exit(status);
}
diff --git a/libc/upstream-openbsd/android/include/openbsd-compat.h b/libc/upstream-openbsd/android/include/openbsd-compat.h
index caea45a93..bec860b83 100644
--- a/libc/upstream-openbsd/android/include/openbsd-compat.h
+++ b/libc/upstream-openbsd/android/include/openbsd-compat.h
@@ -81,7 +81,4 @@ __LIBC_HIDDEN__ extern const short _C_tolower_[];
__LIBC_HIDDEN__ extern char* __findenv(const char*, int, int*);
__LIBC_HIDDEN__ extern char* _mktemp(char*);
-/* TODO: hide this when android_support.a is fixed (http://b/16298580).*/
-/*__LIBC_HIDDEN__*/ extern int __isthreaded;
-
#endif