diff options
author | jb <jb@FreeBSD.org> | 1998-04-11 07:40:47 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1998-04-11 07:40:47 +0000 |
commit | 0ff63017b40dda207b2aadc9881e0c93e7fd2753 (patch) | |
tree | 4819eff8a5c9bc5ae04aaf772d0d5b4f7bfaaebc /lib/libc/stdio/vfprintf.c | |
parent | 525c97c21dbcb3fd61a8a530a3f8df5e901bf1ab (diff) | |
download | FreeBSD-src-0ff63017b40dda207b2aadc9881e0c93e7fd2753.zip FreeBSD-src-0ff63017b40dda207b2aadc9881e0c93e7fd2753.tar.gz |
Add FILE locking stubs for libc.
Change the FILE locking to support kernel threads when linked with
libpthread (which you haven't see yet). This requires that libc become
thread-safe and thread-aware, testing __isthreaded before attempting
to do lock/unlock calls. The impact on non-threaded programs is minor.
This change works with libc_r, so it's the best compromise.
Diffstat (limited to 'lib/libc/stdio/vfprintf.c')
-rw-r--r-- | lib/libc/stdio/vfprintf.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index dd3f743..5a3a25b 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: vfprintf.c,v 1.16 1997/12/25 00:32:17 ache Exp $"; + "$Id: vfprintf.c,v 1.17 1998/01/04 22:28:47 ache Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -63,10 +63,7 @@ static const char rcsid[] = #include "local.h" #include "fvwrite.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h" /* Define FLOATING_POINT to get floating point. */ #define FLOATING_POINT @@ -421,23 +418,17 @@ vfprintf(fp, fmt0, ap) } -#ifdef _THREAD_SAFE - _thread_flockfile(fp,__FILE__,__LINE__); -#endif + FLOCKFILE(fp); /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ if (cantwrite(fp)) { -#ifdef _THREAD_SAFE - _thread_funlockfile(fp); -#endif + FUNLOCKFILE(fp); return (EOF); } /* optimise fprintf(stderr) (and other unbuffered Unix files) */ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && fp->_file >= 0) { -#ifdef _THREAD_SAFE - _thread_funlockfile(fp); -#endif + FUNLOCKFILE(fp); return (__sbprintf(fp, fmt0, ap)); } @@ -873,9 +864,7 @@ done: error: if (__sferror(fp)) ret = EOF; -#ifdef _THREAD_SAFE - _thread_funlockfile(fp); -#endif + FUNLOCKFILE(fp); if ((argtable != NULL) && (argtable != statargtable)) free (argtable); return (ret); |