From 73bd0903fe1ba8189c8657c1583796f08c8028bb Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 21 Mar 2002 09:17:51 +0000 Subject: Compile in flockfile and friends by default -Erik --- libc/stdio/Makefile | 2 +- libc/stdio/stdio.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'libc/stdio') diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile index c2a557a45..14fdb7029 100644 --- a/libc/stdio/Makefile +++ b/libc/stdio/Makefile @@ -54,7 +54,7 @@ MOBJ = fclose.o fflush.o fopen.o freopen.o perror.o remove.o \ __fbufsize.o __freading.o __fwriting.o __freadable.o __fwritable.o \ __flbf.o __fpurge.o __fpending.o _flushlbf.o \ fopencookie.o fmemopen.o open_memstream.o \ - __fsetlocking.o \ + __fsetlocking.o flockfile.o ftrylockfile.o funlockfile.o \ _stdio_fopen.o _stdio_fread.o _stdio_fwrite.o _stdio_adjpos.o \ _stdio_lseek.o _stdio_init.o \ _stdio_fsfopen.o _stdio_fdout.o _uintmaxtostr.o diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c index 49d2a74c6..8ee1a16e2 100644 --- a/libc/stdio/stdio.c +++ b/libc/stdio/stdio.c @@ -1007,7 +1007,9 @@ int __fsetlocking(FILE *stream, int locking_mode) void flockfile(FILE *stream) { +#ifdef __STDIO_THREADSAFE pthread_mutex_lock(&stream->lock); +#endif } #endif @@ -1016,7 +1018,11 @@ void flockfile(FILE *stream) int ftrylockfile(FILE *stream) { +#ifdef __STDIO_THREADSAFE return pthread_mutex_trylock(&stream->lock); +#else + return 1; +#endif } #endif @@ -1025,7 +1031,9 @@ int ftrylockfile(FILE *stream) void funlockfile(FILE *stream) { +#ifdef __STDIO_THREADSAFE pthread_mutex_unlock(&stream->lock); +#endif } #endif -- cgit v1.2.3