Implement __fsetlocking.
The old __isthreaded hack was never very useful on Android because all user
code runs in a VM where there are lots of threads running. But __fsetlocking
lets a caller say "I'll worry about the locking for this FILE*", which is
useful for the normal case where you don't share a FILE* between threads
so you don't need any locking.
Bug: 17154740
Bug: 18593728
Change-Id: I2a8dddc29d3edff39a3d7d793387f2253608a68d
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 46b11f1..7033eda 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -111,8 +111,8 @@
(fp)->_lb._base = NULL; \
}
-#define FLOCKFILE(fp) flockfile(fp)
-#define FUNLOCKFILE(fp) funlockfile(fp)
+#define FLOCKFILE(fp) if (_EXT(fp)->_stdio_handles_locking) flockfile(fp)
+#define FUNLOCKFILE(fp) if (_EXT(fp)->_stdio_handles_locking) funlockfile(fp)
#define FLOATING_POINT
#define PRINTF_WIDE_CHAR