Speed up __sfileext initialization.
The internal uses don't need to actually initialize a mutex since they'll
never escape and don't need locking. It's a small saving, but easy.
Before:
BM_stdio_scanf_d 465 ns 465 ns 1507891
BM_stdio_scanf_maps 1836 ns 1836 ns 381082
BM_stdio_scanf_maps_baseline 846 ns 845 ns 830881
BM_stdio_scanf_s 419 ns 419 ns 1671979
After:
BM_stdio_scanf_d 434 ns 434 ns 1612930
BM_stdio_scanf_maps 1815 ns 1815 ns 386470
BM_stdio_scanf_maps_baseline 875 ns 873 ns 803304
BM_stdio_scanf_s 382 ns 382 ns 1833198
Bug: http://b/70862888
Test: ran tests, benchmarks
Change-Id: Ic8822aaca5d8ca1a73390089153d0fe35d91673e
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index d627556..d3ac043 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -170,7 +170,10 @@
fp->_lb._base = nullptr; /* no line buffer */
fp->_lb._size = 0;
- _FILEEXT_INIT(fp);
+
+ memset(_EXT(fp), 0, sizeof(struct __sfileext));
+ _FLOCK(fp) = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+ _EXT(fp)->_caller_handles_locking = false;
// Caller sets cookie, _read/_write etc.
// We explicitly clear _seek and _seek64 to prevent subtle bugs.