Merge "Reserve enough user request stack space in pthread_create."
diff --git a/libc/bionic/bionic_systrace.cpp b/libc/bionic/bionic_systrace.cpp
index f5be415..c74a52c 100644
--- a/libc/bionic/bionic_systrace.cpp
+++ b/libc/bionic/bionic_systrace.cpp
@@ -15,6 +15,7 @@
*/
#include <cutils/trace.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/libc/bionic/chown.cpp b/libc/bionic/chown.cpp
index bc2e605..dce1673 100644
--- a/libc/bionic/chown.cpp
+++ b/libc/bionic/chown.cpp
@@ -29,6 +29,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <unistd.h>
int chown(const char* path, uid_t uid, gid_t gid) {
return fchownat(AT_FDCWD, path, uid, gid, 0);
diff --git a/libc/bionic/lchown.cpp b/libc/bionic/lchown.cpp
index 95251db..24611a5 100644
--- a/libc/bionic/lchown.cpp
+++ b/libc/bionic/lchown.cpp
@@ -29,6 +29,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <unistd.h>
int lchown(const char* path, uid_t uid, gid_t gid) {
return fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW);
diff --git a/libc/bionic/poll.cpp b/libc/bionic/poll.cpp
index ebb318d..d267229 100644
--- a/libc/bionic/poll.cpp
+++ b/libc/bionic/poll.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <sys/poll.h>
#include <sys/select.h>
diff --git a/libc/bionic/raise.cpp b/libc/bionic/raise.cpp
index 0dd0ad7..b134b5a 100644
--- a/libc/bionic/raise.cpp
+++ b/libc/bionic/raise.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <pthread.h>
#include <signal.h>
diff --git a/libc/bionic/readlink.cpp b/libc/bionic/readlink.cpp
index a2c5e91..3bb7bc1 100644
--- a/libc/bionic/readlink.cpp
+++ b/libc/bionic/readlink.cpp
@@ -29,6 +29,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <unistd.h>
ssize_t readlink(const char* path, char* buf, size_t size) {
return readlinkat(AT_FDCWD, path, buf, size);
diff --git a/libc/bionic/sigaddset.cpp b/libc/bionic/sigaddset.cpp
index 33ec6f8..6ade3b1 100644
--- a/libc/bionic/sigaddset.cpp
+++ b/libc/bionic/sigaddset.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <signal.h>
int sigaddset(sigset_t* set, int signum) {
diff --git a/libc/bionic/sigdelset.cpp b/libc/bionic/sigdelset.cpp
index 9eea250..3582f0d 100644
--- a/libc/bionic/sigdelset.cpp
+++ b/libc/bionic/sigdelset.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <signal.h>
int sigdelset(sigset_t* set, int signum) {
diff --git a/libc/bionic/sigemptyset.cpp b/libc/bionic/sigemptyset.cpp
index 2993169..8d8033f 100644
--- a/libc/bionic/sigemptyset.cpp
+++ b/libc/bionic/sigemptyset.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <signal.h>
int sigemptyset(sigset_t* set) {
diff --git a/libc/bionic/sigfillset.cpp b/libc/bionic/sigfillset.cpp
index 7b7cbb8..37792e5 100644
--- a/libc/bionic/sigfillset.cpp
+++ b/libc/bionic/sigfillset.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <signal.h>
int sigfillset(sigset_t* set) {
diff --git a/libc/bionic/sigismember.cpp b/libc/bionic/sigismember.cpp
index 0dc73ac..16acd09 100644
--- a/libc/bionic/sigismember.cpp
+++ b/libc/bionic/sigismember.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <signal.h>
int sigismember(const sigset_t* set, int signum) {
diff --git a/libc/bionic/termios.cpp b/libc/bionic/termios.cpp
index 082dcdc..44ae643 100644
--- a/libc/bionic/termios.cpp
+++ b/libc/bionic/termios.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <termios.h>
#include <unistd.h>
diff --git a/libc/bionic/utimes.cpp b/libc/bionic/utimes.cpp
index 65f2d0b..0b66e6c 100644
--- a/libc/bionic/utimes.cpp
+++ b/libc/bionic/utimes.cpp
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 1089788..4c4cfbd 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -33,8 +33,8 @@
#include <sys/types.h>
#include <linux/fadvise.h>
#include <linux/fcntl.h>
+#include <linux/stat.h>
#include <linux/uio.h>
-#include <unistd.h> /* this is not required, but makes client code much happier */
__BEGIN_DECLS
diff --git a/libc/include/signal.h b/libc/include/signal.h
index 9519f6d..8988888 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -30,7 +30,6 @@
#define _SIGNAL_H_
#include <asm/sigcontext.h>
-#include <errno.h>
#include <limits.h>
#include <machine/pthread_types.h>
#include <machine/timespec.h>
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 6f238a9..21d59fa 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -77,7 +77,9 @@
#define __GNUC_PREREQ(x, y) 0
#endif
-#include <sys/cdefs_elf.h>
+#define __strong_alias(alias, sym) \
+ __asm__(".global " #alias "\n" \
+ #alias " = " #sym);
#if defined(__cplusplus)
#define __BEGIN_DECLS extern "C" {
@@ -263,13 +265,6 @@
#endif
#endif /* !(__STDC_VERSION__ >= 199901L) */
-#if defined(_KERNEL)
-#if defined(NO_KERNEL_RCSIDS)
-#undef __KERNEL_RCSID
-#define __KERNEL_RCSID(_n, _s) /* nothing */
-#endif /* NO_KERNEL_RCSIDS */
-#endif /* _KERNEL */
-
/*
* A barrier to stop the optimizer from moving code or assume live
* register values. This is gcc specific, the version is more or less
diff --git a/libc/include/sys/cdefs_elf.h b/libc/include/sys/cdefs_elf.h
deleted file mode 100644
index a40a867..0000000
--- a/libc/include/sys/cdefs_elf.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $NetBSD: cdefs_elf.h,v 1.22 2005/02/26 22:25:34 perry Exp $ */
-
-/*
- * Copyright (c) 1995, 1996 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#ifndef _SYS_CDEFS_ELF_H_
-#define _SYS_CDEFS_ELF_H_
-
-#define __strong_alias(alias, sym) \
- __asm__(".global " #alias "\n" \
- #alias " = " #sym);
-
-/* We use __warnattr instead of __warn_references.
- * TODO: remove this and put an empty definition in one of the upstream-* compatibility headers.
- */
-#define __warn_references(sym,msg) \
- /*__asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");*/
-
-#endif /* !_SYS_CDEFS_ELF_H_ */
diff --git a/libc/upstream-netbsd/android/include/fd_setsize.h b/libc/upstream-netbsd/android/include/fd_setsize.h
index e69de29..41bfcb7 100644
--- a/libc/upstream-netbsd/android/include/fd_setsize.h
+++ b/libc/upstream-netbsd/android/include/fd_setsize.h
@@ -0,0 +1 @@
+#include <sys/select.h>
diff --git a/libc/upstream-openbsd/android/include/openbsd-compat.h b/libc/upstream-openbsd/android/include/openbsd-compat.h
index 8386ba5..8783467 100644
--- a/libc/upstream-openbsd/android/include/openbsd-compat.h
+++ b/libc/upstream-openbsd/android/include/openbsd-compat.h
@@ -35,6 +35,9 @@
/* Ignore all __weak_alias in OpenBSD. */
#define __weak_alias(alias,sym)
+/* Ignore all __warn_references in OpenBSD. */
+#define __warn_references(sym,msg)
+
/* OpenBSD's <ctype.h> uses these names, which conflicted with stlport.
* Additionally, we changed the numeric/digit type from N to D for libcxx.
*/
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vfprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vfprintf.c
index 7f8ff31..5f4fb7f 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/vfprintf.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/vfprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfprintf.c,v 1.66 2014/05/03 12:36:45 deraadt Exp $ */
+/* $OpenBSD: vfprintf.c,v 1.67 2014/12/21 00:23:30 daniel Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -753,10 +753,9 @@
if (signflag)
sign = '-';
if (expt == INT_MAX) { /* inf or nan */
- if (*cp == 'N') {
+ if (*cp == 'N')
cp = (ch >= 'a') ? "nan" : "NAN";
- sign = '\0';
- } else
+ else
cp = (ch >= 'a') ? "inf" : "INF";
size = 3;
flags &= ~ZEROPAD;
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vfwprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vfwprintf.c
index ef0ca43..a6f4123 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/vfwprintf.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/vfwprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfwprintf.c,v 1.11 2014/06/04 07:45:25 stsp Exp $ */
+/* $OpenBSD: vfwprintf.c,v 1.12 2014/12/21 00:23:30 daniel Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -731,10 +731,9 @@
if (signflag)
sign = '-';
if (expt == INT_MAX) { /* inf or nan */
- if (*cp == 'N') {
+ if (*cp == 'N')
cp = (ch >= 'a') ? L"nan" : L"NAN";
- sign = '\0';
- } else
+ else
cp = (ch >= 'a') ? L"inf" : L"INF";
size = 3;
flags &= ~ZEROPAD;
diff --git a/libm/freebsd-compat.h b/libm/freebsd-compat.h
index 1481cc2..a4dd6c2 100644
--- a/libm/freebsd-compat.h
+++ b/libm/freebsd-compat.h
@@ -26,6 +26,8 @@
#define __strong_reference(sym,aliassym) \
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
+#define __warn_references(sym,msg) /* ignored */
+
/* digittoint is in BSD's <ctype.h>. */
int digittoint(char ch);
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 854fc7b..de5eea3 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -364,22 +364,52 @@
EXPECT_STREQ("print_me_twice print_me_twice", buf);
}
-TEST(stdio, snprintf_f_special) {
- char buf[BUFSIZ];
- snprintf(buf, sizeof(buf), "%f", nanf(""));
- EXPECT_STRCASEEQ("NaN", buf);
+template <typename T>
+void CheckInfNan(int snprintf_fn(T*, size_t, const T*, ...),
+ const T* fmt, const T* fmt_plus,
+ const T* minus_inf, const T* inf_, const T* plus_inf,
+ const T* minus_nan, const T* nan_, const T* plus_nan) {
+ T buf[BUFSIZ];
- snprintf(buf, sizeof(buf), "%f", HUGE_VALF);
- EXPECT_STRCASEEQ("Inf", buf);
+ snprintf_fn(buf, sizeof(buf), fmt, nan(""));
+ EXPECT_STREQ(nan_, buf) << fmt;
+ snprintf_fn(buf, sizeof(buf), fmt, -nan(""));
+ EXPECT_STREQ(minus_nan, buf) << fmt;
+ snprintf_fn(buf, sizeof(buf), fmt_plus, nan(""));
+ EXPECT_STREQ(plus_nan, buf) << fmt_plus;
+ snprintf_fn(buf, sizeof(buf), fmt_plus, -nan(""));
+ EXPECT_STREQ(minus_nan, buf) << fmt_plus;
+
+ snprintf_fn(buf, sizeof(buf), fmt, HUGE_VAL);
+ EXPECT_STREQ(inf_, buf) << fmt;
+ snprintf_fn(buf, sizeof(buf), fmt, -HUGE_VAL);
+ EXPECT_STREQ(minus_inf, buf) << fmt;
+ snprintf_fn(buf, sizeof(buf), fmt_plus, HUGE_VAL);
+ EXPECT_STREQ(plus_inf, buf) << fmt_plus;
+ snprintf_fn(buf, sizeof(buf), fmt_plus, -HUGE_VAL);
+ EXPECT_STREQ(minus_inf, buf) << fmt_plus;
}
-TEST(stdio, snprintf_g_special) {
- char buf[BUFSIZ];
- snprintf(buf, sizeof(buf), "%g", nan(""));
- EXPECT_STRCASEEQ("NaN", buf);
+TEST(stdio, snprintf_inf_nan) {
+ CheckInfNan(snprintf, "%a", "%+a", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
+ CheckInfNan(snprintf, "%A", "%+A", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
+ CheckInfNan(snprintf, "%e", "%+e", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
+ CheckInfNan(snprintf, "%E", "%+E", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
+ CheckInfNan(snprintf, "%f", "%+f", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
+ CheckInfNan(snprintf, "%F", "%+F", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
+ CheckInfNan(snprintf, "%g", "%+g", "-inf", "inf", "+inf", "-nan", "nan", "+nan");
+ CheckInfNan(snprintf, "%G", "%+G", "-INF", "INF", "+INF", "-NAN", "NAN", "+NAN");
+}
- snprintf(buf, sizeof(buf), "%g", HUGE_VAL);
- EXPECT_STRCASEEQ("Inf", buf);
+TEST(stdio, wsprintf_inf_nan) {
+ CheckInfNan(swprintf, L"%a", L"%+a", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
+ CheckInfNan(swprintf, L"%A", L"%+A", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
+ CheckInfNan(swprintf, L"%e", L"%+e", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
+ CheckInfNan(swprintf, L"%E", L"%+E", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
+ CheckInfNan(swprintf, L"%f", L"%+f", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
+ CheckInfNan(swprintf, L"%F", L"%+F", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
+ CheckInfNan(swprintf, L"%g", L"%+g", L"-inf", L"inf", L"+inf", L"-nan", L"nan", L"+nan");
+ CheckInfNan(swprintf, L"%G", L"%+G", L"-INF", L"INF", L"+INF", L"-NAN", L"NAN", L"+NAN");
}
TEST(stdio, snprintf_d_INT_MAX) {
@@ -439,8 +469,22 @@
TEST(stdio, snprintf_negative_zero_5084292) {
char buf[BUFSIZ];
+ snprintf(buf, sizeof(buf), "%e", -0.0);
+ EXPECT_STREQ("-0.000000e+00", buf);
+ snprintf(buf, sizeof(buf), "%E", -0.0);
+ EXPECT_STREQ("-0.000000E+00", buf);
snprintf(buf, sizeof(buf), "%f", -0.0);
EXPECT_STREQ("-0.000000", buf);
+ snprintf(buf, sizeof(buf), "%F", -0.0);
+ EXPECT_STREQ("-0.000000", buf);
+ snprintf(buf, sizeof(buf), "%g", -0.0);
+ EXPECT_STREQ("-0", buf);
+ snprintf(buf, sizeof(buf), "%G", -0.0);
+ EXPECT_STREQ("-0", buf);
+ snprintf(buf, sizeof(buf), "%a", -0.0);
+ EXPECT_STREQ("-0x0p+0", buf);
+ snprintf(buf, sizeof(buf), "%A", -0.0);
+ EXPECT_STREQ("-0X0P+0", buf);
}
TEST(stdio, snprintf_utf8_15439554) {