Revert "Remove __sinit and __sdidinit."
This reverts commit 4371961e00ad83fca033992c8a19c7d262fe6f84.
This broke booting; ueventd crashes with a null pointer dereference
somewhere in __sfp (but the kernel doesn't unwind, so I don't know
what was calling __sfp).
Change-Id: I65375fdfdf1d339a06558b4057b580cacd6324e2
diff --git a/libc/bionic/flockfile.cpp b/libc/bionic/flockfile.cpp
index db53828..db68801 100644
--- a/libc/bionic/flockfile.cpp
+++ b/libc/bionic/flockfile.cpp
@@ -36,12 +36,20 @@
// 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) {
@@ -52,6 +60,10 @@
}
void funlockfile(FILE* fp) {
+ if (!__sdidinit) {
+ __sinit();
+ }
+
if (fp != nullptr) {
pthread_mutex_unlock(&_FLOCK(fp));
}