Add fmemopen_unlocked() and use unlocked ops in fuzzers and some other tests

This might make things marginially faster. I didn't benchmark though.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-04-12 11:44:57 +02:00
parent 2fe21124a6
commit 673a1e6fb9
14 changed files with 40 additions and 30 deletions
+10
View File
@@ -65,6 +65,16 @@ FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc) {
return f;
}
FILE* fmemopen_unlocked(void *buf, size_t size, const char *mode) {
FILE *f = fmemopen(buf, size, mode);
if (!f)
return NULL;
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
return f;
}
int write_string_stream_ts(
FILE *f,
const char *line,
+1
View File
@@ -36,6 +36,7 @@ typedef enum {
int fopen_unlocked(const char *path, const char *options, FILE **ret);
int fdopen_unlocked(int fd, const char *options, FILE **ret);
FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc);
FILE* fmemopen_unlocked(void *buf, size_t size, const char *mode);
int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts);
static inline int write_string_stream(FILE *f, const char *line, WriteStringFileFlags flags) {