merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index 14d2fec..da3a551 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -205,6 +205,8 @@
pthread_exit((void*) result);
}
+#include <private/logd.h>
+
__LIBC_ABI_PRIVATE__
int _init_thread(pthread_internal_t* thread, pid_t kernel_id, pthread_attr_t* attr,
void* stack_base, bool add_to_thread_list)
@@ -229,7 +231,9 @@
struct sched_param param;
param.sched_priority = thread->attr.sched_priority;
if (sched_setscheduler(kernel_id, thread->attr.sched_policy, ¶m) == -1) {
- error = errno;
+ // For back compat reasons, we just warn about possible invalid sched_policy
+ const char* msg = "pthread_create sched_setscheduler call failed: %s\n";
+ __libc_android_log_print(ANDROID_LOG_WARN, "libc", msg, strerror(errno));
}
}
diff --git a/libc/bionic/strerror.cpp b/libc/bionic/strerror.cpp
index 036ec8d..455dc52 100644
--- a/libc/bionic/strerror.cpp
+++ b/libc/bionic/strerror.cpp
@@ -29,9 +29,17 @@
#include <string.h>
#include "ThreadLocalBuffer.h"
+extern "C" const char* __strerror_lookup(int);
+
GLOBAL_INIT_THREAD_LOCAL_BUFFER(strerror);
char* strerror(int error_number) {
+ // Just return the original constant in the easy cases.
+ char* result = const_cast<char*>(__strerror_lookup(error_number));
+ if (result != NULL) {
+ return result;
+ }
+
LOCAL_INIT_THREAD_LOCAL_BUFFER(char*, strerror, NL_TEXTMAX);
strerror_r(error_number, strerror_buffer, strerror_buffer_size);
return strerror_buffer;
diff --git a/libc/bionic/strerror_r.cpp b/libc/bionic/strerror_r.cpp
index 92235a5..a00ebe5 100644
--- a/libc/bionic/strerror_r.cpp
+++ b/libc/bionic/strerror_r.cpp
@@ -27,11 +27,25 @@
{ 0, NULL }
};
+extern "C" const char* __strerror_lookup(int error_number) {
+ return __code_string_lookup(_sys_error_strings, error_number);
+}
+
+static const Pair _sys_signal_strings[] = {
+#define __BIONIC_SIGDEF(x,y,z) { y, z },
+#include <sys/_sigdefs.h>
+ { 0, NULL }
+};
+
+extern "C" const char* __strsignal_lookup(int signal_number) {
+ return __code_string_lookup(_sys_signal_strings, signal_number);
+}
+
int strerror_r(int error_number, char* buf, size_t buf_len) {
int saved_errno = errno;
size_t length;
- const char* error_name = __code_string_lookup(_sys_error_strings, error_number);
+ const char* error_name = __strerror_lookup(error_number);
if (error_name != NULL) {
length = snprintf(buf, buf_len, "%s", error_name);
} else {
@@ -46,14 +60,8 @@
return 0;
}
-static const Pair _sys_signal_strings[] = {
-#define __BIONIC_SIGDEF(x,y,z) { y, z },
-#include <sys/_sigdefs.h>
- { 0, NULL }
-};
-
extern "C" const char* __strsignal(int signal_number, char* buf, size_t buf_len) {
- const char* signal_name = __code_string_lookup(_sys_signal_strings, signal_number);
+ const char* signal_name = __strsignal_lookup(signal_number);
if (signal_name != NULL) {
return signal_name;
}
diff --git a/libc/bionic/strsignal.cpp b/libc/bionic/strsignal.cpp
index 1cbec9b..9b046d4 100644
--- a/libc/bionic/strsignal.cpp
+++ b/libc/bionic/strsignal.cpp
@@ -29,11 +29,18 @@
#include <string.h>
#include "ThreadLocalBuffer.h"
+extern "C" const char* __strsignal_lookup(int);
extern "C" const char* __strsignal(int, char*, size_t);
GLOBAL_INIT_THREAD_LOCAL_BUFFER(strsignal);
char* strsignal(int signal_number) {
+ // Just return the original constant in the easy cases.
+ char* result = const_cast<char*>(__strsignal_lookup(signal_number));
+ if (result != NULL) {
+ return result;
+ }
+
LOCAL_INIT_THREAD_LOCAL_BUFFER(char*, strsignal, NL_TEXTMAX);
return const_cast<char*>(__strsignal(signal_number, strsignal_buffer, strsignal_buffer_size));
}