Remove __sinit and __sdidinit.

We're eagerly initializing stdio now, so this can all be simplified.

Change-Id: Icb288f8dd0ee08f02bea0d23670f75e78bed6b99
diff --git a/libc/bionic/flockfile.cpp b/libc/bionic/flockfile.cpp
index db68801..db53828 100644
--- a/libc/bionic/flockfile.cpp
+++ b/libc/bionic/flockfile.cpp
@@ -36,20 +36,12 @@
 // struct __sfileext (see fileext.h).
 
 void flockfile(FILE* fp) {
-  if (!__sdidinit) {
-    __sinit();
-  }
-
   if (fp != nullptr) {
     pthread_mutex_lock(&_FLOCK(fp));
   }
 }
 
 int ftrylockfile(FILE* fp) {
-  if (!__sdidinit) {
-    __sinit();
-  }
-
   // The specification for ftrylockfile() says it returns 0 on success,
   // or non-zero on error. So return an errno code directly on error.
   if (fp == nullptr) {
@@ -60,10 +52,6 @@
 }
 
 void funlockfile(FILE* fp) {
-  if (!__sdidinit) {
-    __sinit();
-  }
-
   if (fp != nullptr) {
     pthread_mutex_unlock(&_FLOCK(fp));
   }
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 91e210e..8f210ea 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -54,7 +54,7 @@
 extern "C" int __system_properties_init(void);
 extern "C" int __set_tls(void* ptr);
 extern "C" int __set_tid_address(int* tid_address);
-extern "C" int __sinit(void);
+extern "C" int __libc_init_stdio(void);
 
 __LIBC_HIDDEN__ WriteProtected<libc_globals> __libc_globals;
 
@@ -134,9 +134,9 @@
   __pthread_internal_add(main_thread);
 
   __system_properties_init(); // Requires 'environ'.
-  // Initialize stdio here to get rid of data races caused by lazy initialization.
-  // TODO: Remove other calls to __sinit().
-  __sinit();
+
+  // Initialize stdio to avoid data races caused by BSD-style lazy initialization.
+  __libc_init_stdio();
 }
 
 __noreturn static void __early_abort(int line) {
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index d6b8e8f..6609470 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -286,6 +286,12 @@
   return r.rlim_cur;
 }
 
+// A leaked BSD stdio implementation detail that's now a no-op.
+extern "C" void __sinit() {
+}
+
+extern "C" int __sdidinit = 1;
+
 // Only used by ftime, which was removed from POSIX 2008.
 struct timeb {
   time_t          time;