summaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-12-20 08:53:49 -0800
committerElliott Hughes <enh@google.com>2017-12-20 08:53:49 -0800
commit1a56a26f1169da432de36016ee3d2f37c71b4eef (patch)
tree560c2beefecee676f192a3d4325480773e044c38 /libc/stdio/stdio.cpp
parent28f768d4e78851a20c9e222389d72cf3cf085141 (diff)
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
Diffstat (limited to 'libc/stdio/stdio.cpp')
-rw-r--r--libc/stdio/stdio.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index d6275569c..d3ac0436e 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -170,7 +170,10 @@ found:
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.