Use re-entrant locks on stdio

This commit is contained in:
Justine Tunney 2022-05-22 08:13:13 -07:00
parent 4e9662cbc7
commit 1f229e4efc
78 changed files with 427 additions and 179 deletions

View file

@ -18,6 +18,7 @@
*/
#include "libc/calls/calls.h"
#include "libc/stdio/stdio.h"
#include "libc/testlib/ezbench.h"
#include "libc/testlib/testlib.h"
FILE *f;
@ -60,3 +61,13 @@ TEST(fgetc, testUnbuffered) {
EXPECT_TRUE(feof(f));
EXPECT_NE(-1, fclose(f));
}
BENCH(fputc, bench) {
FILE *f;
ASSERT_NE(NULL, (f = fopen("/dev/null", "w")));
EZBENCH2("fputc", donothing, fputc('E', f));
flockfile(f);
EZBENCH2("fputc_unlocked", donothing, fputc_unlocked('E', f));
funlockfile(f);
fclose(f);
}