diff options
| author | John Birrell <jb@FreeBSD.org> | 1998-04-11 07:40:47 +0000 | 
|---|---|---|
| committer | John Birrell <jb@FreeBSD.org> | 1998-04-11 07:40:47 +0000 | 
| commit | ec216c263498f3ab7c5554f5c5571125b57024b8 (patch) | |
| tree | e65c59eb392b5a151bd78ac3768fcc00c26b4e6e /lib | |
| parent | af3c7c8d85b67eb82f9391b60743091a227323a1 (diff) | |
Notes
Diffstat (limited to 'lib')
28 files changed, 211 insertions, 337 deletions
| diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc index dbceec49f801..3e5ecf15a407 100644 --- a/lib/libc/stdio/Makefile.inc +++ b/lib/libc/stdio/Makefile.inc @@ -1,10 +1,11 @@  #	@(#)Makefile.inc	8.3 (Berkeley) 4/17/94 -#	$Id: Makefile.inc,v 1.12 1998/02/13 02:13:23 imp Exp $ +#	$Id: Makefile.inc,v 1.13 1998/03/12 12:05:14 bde Exp $  # stdio sources  .PATH: ${.CURDIR}/../libc/stdio -SRCS+=	asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c \ +SRCS+=	_flock_stub.c \ +	asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c \  	fgetc.c fgetln.c fgetpos.c fgets.c fileno.c findfp.c flags.c fopen.c \  	fprintf.c fpurge.c fputc.c fputs.c fread.c freopen.c fscanf.c \  	fseek.c fsetpos.c ftell.c funopen.c fvwrite.c fwalk.c fwrite.c \ @@ -12,9 +13,16 @@ SRCS+=	asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c \  	printf.c putc.c putchar.c puts.c putw.c refill.c remove.c rewind.c \  	rget.c scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c \  	sscanf.c stdio.c tempnam.c tmpfile.c tmpnam.c ungetc.c vasprintf.c \ -	vfprintf.c vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c \ +	vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c \  	vsscanf.c wbuf.c wsetup.c +.if defined(NETBSD_SYSCALLS) +#  XXX Temporary until FreeBSD's vfprintf is ported +SRCS+=	netbsd_vfprintf.c +.else +SRCS+=	vfprintf.c +.endif +  .if ${LIB} == "c"  MAN3+=	fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fopen.3 fputs.3 \  	fread.3 fseek.3 funopen.3 getc.3 mktemp.3 printf.3 putc.3 remove.3 \ diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c new file mode 100644 index 000000000000..5915c4676004 --- /dev/null +++ b/lib/libc/stdio/_flock_stub.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *    notice, this list of conditions and the following disclaimer in the + *    documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + *    must display the following acknowledgement: + *	This product includes software developed by John Birrell. + * 4. Neither the name of the author nor the names of any co-contributors + *    may be used to endorse or promote products derived from this software + *    without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + * + */ + +#include <stdio.h> + +/* + * Declare weak references in case the application is not linked + * with libpthread. + */ +#pragma weak _flockfile=_flockfile_stub +#pragma weak _flockfile_debug=_flockfile_debug_stub +#pragma weak _ftrylockfile=_ftrylockfile_stub +#pragma weak _funlockfile=_funlockfile_stub + +/* + * This function is a stub for the _flockfile function in libpthread. + */ +void +_flockfile_stub(FILE *fp) +{ +} + +/* + * This function is a stub for the _flockfile_debug function in libpthread. + */ +void +_flockfile_debug_stub(FILE *fp, char *fname, int lineno) +{ +} + +/* + * This function is a stub for the _ftrylockfile function in libpthread. + */ +int +_ftrylockfile_stub(FILE *fp) +{ +	return(0); +} + +/* + * This function is a stub for the _funlockfile function in libpthread. + */ +void +_funlockfile_stub(FILE *fp) +{ +} diff --git a/lib/libc/stdio/clrerr.c b/lib/libc/stdio/clrerr.c index a230119a6e80..7710be80d7d5 100644 --- a/lib/libc/stdio/clrerr.c +++ b/lib/libc/stdio/clrerr.c @@ -39,25 +39,18 @@  static char sccsid[] = "@(#)clrerr.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: clrerr.c,v 1.5 1997/02/22 15:01:46 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #undef	clearerr -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  void  clearerr(fp)  	FILE *fp;  { -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	__sclearerr(fp); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  } diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c index 1104bd08a78d..5919ce079c69 100644 --- a/lib/libc/stdio/fclose.c +++ b/lib/libc/stdio/fclose.c @@ -39,17 +39,14 @@  static char sccsid[] = "@(#)fclose.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fclose.c,v 1.5 1997/02/22 15:01:47 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <errno.h>  #include <stdio.h>  #include <stdlib.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  int  fclose(fp) @@ -61,9 +58,7 @@ fclose(fp)  		errno = EBADF;  		return (EOF);  	} -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	r = fp->_flags & __SWR ? __sflush(fp) : 0;  	if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0)  		r = EOF; @@ -73,9 +68,7 @@ fclose(fp)  		FREEUB(fp);  	if (HASLB(fp))  		FREELB(fp); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	fp->_flags = 0;		/* Release this FILE for reuse. */  	fp->_file = -1;  	fp->_r = fp->_w = 0;	/* Mess up if reaccessed. */ diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c index aed57ec852c1..f5c89e776de6 100644 --- a/lib/libc/stdio/fflush.c +++ b/lib/libc/stdio/fflush.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)fflush.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fflush.c,v 1.5 1997/02/22 15:01:50 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <errno.h>  #include <stdio.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /* Flush a single file, or (if fp is NULL) all files.  */  int @@ -59,18 +56,14 @@ fflush(fp)  	if (fp == NULL)  		return (_fwalk(__sflush)); -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	if ((fp->_flags & (__SWR | __SRW)) == 0) {  		errno = EBADF;  		retval = EOF;  	} else {  		retval = __sflush(fp);  	} -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/fgetc.c b/lib/libc/stdio/fgetc.c index f93a0046209f..42ce2bb1daf1 100644 --- a/lib/libc/stdio/fgetc.c +++ b/lib/libc/stdio/fgetc.c @@ -39,26 +39,19 @@  static char sccsid[] = "@(#)fgetc.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fgetc.c,v 1.5 1997/02/22 15:01:51 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  int  fgetc(fp)  	FILE *fp;  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	retval = __sgetc(fp); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/fgetpos.c b/lib/libc/stdio/fgetpos.c index ab8a9e50ceaa..7cac82eeab6b 100644 --- a/lib/libc/stdio/fgetpos.c +++ b/lib/libc/stdio/fgetpos.c @@ -39,14 +39,11 @@  static char sccsid[] = "@(#)fgetpos.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fgetpos.c,v 1.5 1997/02/22 15:01:53 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  int  fgetpos(fp, pos) @@ -54,12 +51,8 @@ fgetpos(fp, pos)  	fpos_t *pos;  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	retval = (*pos = ftell(fp)) == (fpos_t)-1; -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return(retval);  } diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c index 434fc07cdec2..a1833d2ccf5c 100644 --- a/lib/libc/stdio/fgets.c +++ b/lib/libc/stdio/fgets.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)fgets.c	8.2 (Berkeley) 12/22/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fgets.c,v 1.7 1997/02/22 15:01:53 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include <string.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * Read at most n-1 characters from the given file. @@ -68,9 +65,7 @@ fgets(buf, n, fp)  	if (n <= 0)		/* sanity check */  		return (NULL); -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	s = buf;  	n--;			/* leave space for NUL */  	while (n != 0) { @@ -81,9 +76,7 @@ fgets(buf, n, fp)  			if (__srefill(fp)) {  				/* EOF/error: stop with partial or no line */  				if (s == buf) { -#ifdef _THREAD_SAFE -					_thread_funlockfile(fp); -#endif +					FUNLOCKFILE(fp);  					return (NULL);  				}  				break; @@ -107,9 +100,7 @@ fgets(buf, n, fp)  			fp->_p = t;  			(void)memcpy((void *)s, (void *)p, len);  			s[len] = 0; -#ifdef _THREAD_SAFE -			_thread_funlockfile(fp); -#endif +			FUNLOCKFILE(fp);  			return (buf);  		}  		fp->_r -= len; @@ -119,8 +110,6 @@ fgets(buf, n, fp)  		n -= len;  	}  	*s = 0; -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (buf);  } diff --git a/lib/libc/stdio/fpurge.c b/lib/libc/stdio/fpurge.c index d1d9e876258f..97d0651a01f5 100644 --- a/lib/libc/stdio/fpurge.c +++ b/lib/libc/stdio/fpurge.c @@ -39,17 +39,14 @@  static char sccsid[] = "@(#)fpurge.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fpurge.c,v 1.5 1997/02/22 15:01:58 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <errno.h>  #include <stdio.h>  #include <stdlib.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * fpurge: like fflush, but without writing anything: leave the @@ -60,9 +57,7 @@ fpurge(fp)  	register FILE *fp;  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	if (!fp->_flags) {  		errno = EBADF;  		retval = EOF; @@ -74,8 +69,6 @@ fpurge(fp)  		fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size;  		retval = 0;  	} -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c index 89b138d15a0a..d1f5e6c079a8 100644 --- a/lib/libc/stdio/fputc.c +++ b/lib/libc/stdio/fputc.c @@ -39,14 +39,11 @@  static char sccsid[] = "@(#)fputc.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fputc.c,v 1.5 1997/02/22 15:02:00 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  int  fputc(c, fp) @@ -54,12 +51,8 @@ fputc(c, fp)  	register FILE *fp;  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	retval = putc(c, fp); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/fputs.c b/lib/libc/stdio/fputs.c index 537c34895deb..b2ef3a9164d0 100644 --- a/lib/libc/stdio/fputs.c +++ b/lib/libc/stdio/fputs.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)fputs.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fputs.c,v 1.5 1997/02/22 15:02:02 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include <string.h>  #include "fvwrite.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * Write the given string to the given file. @@ -66,12 +63,8 @@ fputs(s, fp)  	iov.iov_len = uio.uio_resid = strlen(s);  	uio.uio_iov = &iov;  	uio.uio_iovcnt = 1; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	retval = __sfvwrite(fp, &uio); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c index 4f67fbf4134f..34db38ff8762 100644 --- a/lib/libc/stdio/fread.c +++ b/lib/libc/stdio/fread.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)fread.c	8.2 (Berkeley) 12/11/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fread.c,v 1.5 1997/02/22 15:02:03 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include <string.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  size_t  fread(buf, size, count, fp) @@ -68,9 +65,7 @@ fread(buf, size, count, fp)  	 */  	if ((resid = count * size) == 0)  		return (0); -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	if (fp->_r < 0)  		fp->_r = 0;  	total = resid; @@ -83,14 +78,13 @@ fread(buf, size, count, fp)  		resid -= r;  		if (__srefill(fp)) {  			/* no more input: return partial result */ +			FUNLOCKFILE(fp);  			return ((total - resid) / size);  		}  	}  	(void)memcpy((void *)p, (void *)fp->_p, resid);  	fp->_r -= resid;  	fp->_p += resid; -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (count);  } diff --git a/lib/libc/stdio/fscanf.c b/lib/libc/stdio/fscanf.c index 8513f801cea6..a8b10a48c70b 100644 --- a/lib/libc/stdio/fscanf.c +++ b/lib/libc/stdio/fscanf.c @@ -39,7 +39,7 @@  static char sccsid[] = "@(#)fscanf.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fscanf.c,v 1.5 1997/02/22 15:02:04 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> @@ -48,10 +48,7 @@ static const char rcsid[] =  #else  #include <varargs.h>  #endif -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  #if __STDC__  int @@ -72,13 +69,9 @@ fscanf(fp, fmt, va_alist)  	va_start(ap);  #endif -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	ret = __svfscanf(fp, fmt, ap);  	va_end(ap); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (ret);  } diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index c6707dfb34f6..808d3ae3a153 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -39,7 +39,7 @@  static char sccsid[] = "@(#)fseek.c	8.3 (Berkeley) 1/2/94";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fseek.c,v 1.6 1997/02/22 15:02:05 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <sys/types.h> @@ -49,10 +49,7 @@ static const char rcsid[] =  #include <stdlib.h>  #include <errno.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  #define	POS_ERR	(-(fpos_t)1) @@ -76,14 +73,13 @@ fseek(fp, offset, whence)  	if (!__sdidinit)  		__sinit(); -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	/*  	 * Have to be able to seek.  	 */  	if ((seekfn = fp->_seek) == NULL) {  		errno = ESPIPE;			/* historic practice */ +		FUNLOCKFILE(fp);  		return (EOF);  	} @@ -104,9 +100,7 @@ fseek(fp, offset, whence)  		else {  			curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR);  			if (curoff == -1) { -#ifdef _THREAD_SAFE -				_thread_funlockfile(fp); -#endif +				FUNLOCKFILE(fp);  				return (EOF);  			}  		} @@ -130,9 +124,7 @@ fseek(fp, offset, whence)  	default:  		errno = EINVAL; -#ifdef _THREAD_SAFE -		_thread_funlockfile(fp); -#endif +		FUNLOCKFILE(fp);  		return (EOF);  	} @@ -216,9 +208,7 @@ fseek(fp, offset, whence)  		if (HASUB(fp))  			FREEUB(fp);  		fp->_flags &= ~__SEOF; -#ifdef _THREAD_SAFE -		_thread_funlockfile(fp); -#endif +		FUNLOCKFILE(fp);  		return (0);  	} @@ -245,9 +235,7 @@ fseek(fp, offset, whence)  		fp->_p += n;  		fp->_r -= n;  	} -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (0);  	/* @@ -257,9 +245,7 @@ fseek(fp, offset, whence)  dumb:  	if (__sflush(fp) ||  	    (*seekfn)(fp->_cookie, (fpos_t)offset, whence) == POS_ERR) { -#ifdef _THREAD_SAFE -		_thread_funlockfile(fp); -#endif +		FUNLOCKFILE(fp);  		return (EOF);  	}  	/* success: clear EOF indicator and discard ungetc() data */ @@ -269,8 +255,6 @@ dumb:  	fp->_r = 0;  	/* fp->_w = 0; */	/* unnecessary (I think...) */  	fp->_flags &= ~__SEOF; -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (0);  } diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c index 9b85ee0ceb07..34da2713321b 100644 --- a/lib/libc/stdio/ftell.c +++ b/lib/libc/stdio/ftell.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)ftell.c	8.2 (Berkeley) 5/4/95";  #endif  static const char rcsid[] = -		"$Id: ftell.c,v 1.7 1997/02/22 15:02:07 peter Exp $"; +		"$Id: ftell.c,v 1.8 1997/03/11 11:40:40 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include <errno.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * ftell: return current offset. @@ -64,9 +61,7 @@ ftell(fp)  		return (-1L);  	} -#ifdef _THREAD_SAFE -	_thread_flockfile(fp, __FILE__, __LINE__); -#endif +	FLOCKFILE(fp);  	/*  	 * Find offset of underlying I/O object, then  	 * adjust for buffered bytes. @@ -76,9 +71,7 @@ ftell(fp)  	else {  		pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR);  		if (pos == -1) { -#ifdef _THREAD_SAFE -			_thread_funlockfile(fp); -#endif +			FUNLOCKFILE(fp);  			return (pos);  		}  	} @@ -99,8 +92,6 @@ ftell(fp)  		 */  		pos += fp->_p - fp->_bf._base;  	} -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (pos);  } diff --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c index ba8540d4af96..d2dadd838074 100644 --- a/lib/libc/stdio/fwrite.c +++ b/lib/libc/stdio/fwrite.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)fwrite.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: fwrite.c,v 1.5 1997/02/22 15:02:10 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include "local.h"  #include "fvwrite.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * Write `count' objects (each size `size') from memory to the given file. @@ -69,9 +66,7 @@ fwrite(buf, size, count, fp)  	uio.uio_iov = &iov;  	uio.uio_iovcnt = 1; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	/*  	 * The usual case is success (__sfvwrite returns 0);  	 * skip the divide if this happens, since divides are @@ -79,8 +74,6 @@ fwrite(buf, size, count, fp)  	 */  	if (__sfvwrite(fp, &uio) != 0)  	    count = (n - uio.uio_resid) / size; -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (count);  } diff --git a/lib/libc/stdio/getc.c b/lib/libc/stdio/getc.c index ced796b8919a..436a93f097f8 100644 --- a/lib/libc/stdio/getc.c +++ b/lib/libc/stdio/getc.c @@ -39,14 +39,11 @@  static char sccsid[] = "@(#)getc.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: getc.c,v 1.5 1997/02/22 15:02:11 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * A subroutine version of the macro getc. @@ -58,12 +55,8 @@ getc(fp)  	register FILE *fp;  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	retval = __sgetc(fp); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/getchar.c b/lib/libc/stdio/getchar.c index 0bcbd3a69494..ee3f809620c6 100644 --- a/lib/libc/stdio/getchar.c +++ b/lib/libc/stdio/getchar.c @@ -39,17 +39,14 @@  static char sccsid[] = "@(#)getchar.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: getchar.c,v 1.5 1997/02/22 15:02:12 peter Exp $";  #endif /* LIBC_SCCS and not lint */  /*   * A subroutine version of the macro getchar.   */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  #undef getchar @@ -57,12 +54,8 @@ int  getchar()  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(stdin,__FILE__,__LINE__); -#endif +	FLOCKFILE(stdin);  	retval = getc(stdin); -#ifdef _THREAD_SAFE -	_thread_funlockfile(stdin); -#endif +	FUNLOCKFILE(stdin);  	return (retval);  } diff --git a/lib/libc/stdio/putc.c b/lib/libc/stdio/putc.c index a1b081464249..e231d0e3b7d9 100644 --- a/lib/libc/stdio/putc.c +++ b/lib/libc/stdio/putc.c @@ -39,14 +39,11 @@  static char sccsid[] = "@(#)putc.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: putc.c,v 1.5 1997/02/22 15:02:17 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * A subroutine version of the macro putc. @@ -59,12 +56,8 @@ putc(c, fp)  	register FILE *fp;  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	retval = __sputc(c, fp); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/putchar.c b/lib/libc/stdio/putchar.c index 99439aca10e7..57400d300c73 100644 --- a/lib/libc/stdio/putchar.c +++ b/lib/libc/stdio/putchar.c @@ -39,14 +39,11 @@  static char sccsid[] = "@(#)putchar.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: putchar.c,v 1.5 1997/02/22 15:02:19 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  #undef putchar @@ -60,12 +57,8 @@ putchar(c)  	int retval;  	register FILE *so = stdout; -#ifdef _THREAD_SAFE -	_thread_flockfile(so,__FILE__,__LINE__); -#endif +	FLOCKFILE(so);  	retval = __sputc(c, so); -#ifdef _THREAD_SAFE -	_thread_funlockfile(so); -#endif +	FUNLOCKFILE(so);  	return (retval);  } diff --git a/lib/libc/stdio/puts.c b/lib/libc/stdio/puts.c index 91a20de975ae..13a0fdf01a00 100644 --- a/lib/libc/stdio/puts.c +++ b/lib/libc/stdio/puts.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)puts.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: puts.c,v 1.5 1997/02/22 15:02:20 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include <string.h>  #include "fvwrite.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * Write the given string to stdout, appending a newline. @@ -69,12 +66,8 @@ puts(s)  	uio.uio_resid = c + 1;  	uio.uio_iov = &iov[0];  	uio.uio_iovcnt = 2; -#ifdef _THREAD_SAFE -	_thread_flockfile(stdout,__FILE__,__LINE__); -#endif +	FLOCKFILE(stdout);  	retval = __sfvwrite(stdout, &uio) ? EOF : '\n'; -#ifdef _THREAD_SAFE -	_thread_funlockfile(stdout); -#endif +	FUNLOCKFILE(stdout);  	return (retval);  } diff --git a/lib/libc/stdio/putw.c b/lib/libc/stdio/putw.c index 946a311ac337..140b8d41bd54 100644 --- a/lib/libc/stdio/putw.c +++ b/lib/libc/stdio/putw.c @@ -39,15 +39,12 @@  static char sccsid[] = "@(#)putw.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: putw.c,v 1.5 1997/02/22 15:02:21 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include "fvwrite.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  int  putw(w, fp) @@ -62,12 +59,8 @@ putw(w, fp)  	iov.iov_len = uio.uio_resid = sizeof(w);  	uio.uio_iov = &iov;  	uio.uio_iovcnt = 1; -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	retval = __sfvwrite(fp, &uio); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (retval);  } diff --git a/lib/libc/stdio/rewind.c b/lib/libc/stdio/rewind.c index f6609d69f576..c95adc7a1e24 100644 --- a/lib/libc/stdio/rewind.c +++ b/lib/libc/stdio/rewind.c @@ -39,27 +39,20 @@  static char sccsid[] = "@(#)rewind.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: rewind.c,v 1.5 1997/02/22 15:02:24 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <errno.h>  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  void  rewind(fp)  	register FILE *fp;  { -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	(void) fseek(fp, 0L, SEEK_SET);  	clearerr(fp); -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	errno = 0;      /* not required, but seems reasonable */  } diff --git a/lib/libc/stdio/scanf.c b/lib/libc/stdio/scanf.c index 7a8bd65990fa..94f77beb424f 100644 --- a/lib/libc/stdio/scanf.c +++ b/lib/libc/stdio/scanf.c @@ -39,7 +39,7 @@  static char sccsid[] = "@(#)scanf.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: scanf.c,v 1.5 1997/02/22 15:02:25 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> @@ -48,10 +48,7 @@ static const char rcsid[] =  #else  #include <varargs.h>  #endif -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  #if __STDC__  int @@ -71,13 +68,9 @@ scanf(fmt, va_alist)  #else  	va_start(ap);  #endif -#ifdef _THREAD_SAFE -	_thread_flockfile(stdin,__FILE__,__LINE__); -#endif +	FLOCKFILE(stdin);  	ret = __svfscanf(stdin, fmt, ap); +	FUNLOCKFILE(stdin);  	va_end(ap); -#ifdef _THREAD_SAFE -	_thread_funlockfile(stdin); -#endif  	return (ret);  } diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c index 9cc6bb6ee65e..a0c6512dbb14 100644 --- a/lib/libc/stdio/setvbuf.c +++ b/lib/libc/stdio/setvbuf.c @@ -39,16 +39,13 @@  static char sccsid[] = "@(#)setvbuf.c	8.2 (Berkeley) 11/16/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: setvbuf.c,v 1.5 1997/02/22 15:02:27 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include <stdlib.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  /*   * Set one of the three kinds of buffering, optionally including @@ -74,9 +71,7 @@ setvbuf(fp, buf, mode, size)  		if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0)  			return (EOF); -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	/*  	 * Write current buffer, if any.  Discard unread input (including  	 * ungetc data), cancel line buffering, and free old buffer if @@ -128,9 +123,7 @@ nbf:  			fp->_w = 0;  			fp->_bf._base = fp->_p = fp->_nbuf;  			fp->_bf._size = 1; -#ifdef _THREAD_SAFE -			_thread_funlockfile(fp); -#endif +			FUNLOCKFILE(fp);  			return (ret);  		}  		flags |= __SMBF; @@ -171,8 +164,6 @@ nbf:  	}  	__cleanup = _cleanup; -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (ret);  } diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c index c0355b7f6410..db3ff83d024f 100644 --- a/lib/libc/stdio/ungetc.c +++ b/lib/libc/stdio/ungetc.c @@ -39,17 +39,14 @@  static char sccsid[] = "@(#)ungetc.c	8.2 (Berkeley) 11/3/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: ungetc.c,v 1.5 1997/02/22 15:02:38 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h>  #include <stdlib.h>  #include <string.h>  #include "local.h" -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  static int __submore __P((FILE *)); @@ -101,25 +98,19 @@ ungetc(c, fp)  		return (EOF);  	if (!__sdidinit)  		__sinit(); -#ifdef _THREAD_SAFE -	_thread_flockfile(fp,__FILE__,__LINE__); -#endif +	FLOCKFILE(fp);  	if ((fp->_flags & __SRD) == 0) {  		/*  		 * Not already reading: no good unless reading-and-writing.  		 * Otherwise, flush any current write stuff.  		 */  		if ((fp->_flags & __SRW) == 0) { -#ifdef _THREAD_SAFE -			_thread_funlockfile(fp); -#endif +			FUNLOCKFILE(fp);  			return (EOF);  		}  		if (fp->_flags & __SWR) {  			if (__sflush(fp)) { -#ifdef _THREAD_SAFE -				_thread_funlockfile(fp); -#endif +				FUNLOCKFILE(fp);  				return (EOF);  			}  			fp->_flags &= ~__SWR; @@ -136,16 +127,12 @@ ungetc(c, fp)  	 */  	if (HASUB(fp)) {  		if (fp->_r >= fp->_ub._size && __submore(fp)) { -#ifdef _THREAD_SAFE -			_thread_funlockfile(fp); -#endif +			FUNLOCKFILE(fp);  			return (EOF);  		}  		*--fp->_p = c;  		fp->_r++; -#ifdef _THREAD_SAFE -		_thread_funlockfile(fp); -#endif +		FUNLOCKFILE(fp);  		return (c);  	}  	fp->_flags &= ~__SEOF; @@ -159,9 +146,7 @@ ungetc(c, fp)  	    fp->_p[-1] == c) {  		fp->_p--;  		fp->_r++; -#ifdef _THREAD_SAFE -		_thread_funlockfile(fp); -#endif +		FUNLOCKFILE(fp);  		return (c);  	} @@ -176,8 +161,6 @@ ungetc(c, fp)  	fp->_ubuf[sizeof(fp->_ubuf) - 1] = c;  	fp->_p = &fp->_ubuf[sizeof(fp->_ubuf) - 1];  	fp->_r = 1; -#ifdef _THREAD_SAFE -	_thread_funlockfile(fp); -#endif +	FUNLOCKFILE(fp);  	return (c);  } diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index dd3f743d5ff4..5a3a25be9511 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); diff --git a/lib/libc/stdio/vscanf.c b/lib/libc/stdio/vscanf.c index 9381710f301a..729098b6c88d 100644 --- a/lib/libc/stdio/vscanf.c +++ b/lib/libc/stdio/vscanf.c @@ -39,14 +39,11 @@  static char sccsid[] = "@(#)vscanf.c	8.1 (Berkeley) 6/4/93";  #endif  static const char rcsid[] = -		"$Id$"; +		"$Id: vscanf.c,v 1.5 1997/02/22 15:02:43 peter Exp $";  #endif /* LIBC_SCCS and not lint */  #include <stdio.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -#endif +#include "libc_private.h"  int  vscanf(fmt, ap) @@ -55,12 +52,8 @@ vscanf(fmt, ap)  {  	int retval; -#ifdef _THREAD_SAFE -	_thread_flockfile(stdin,__FILE__,__LINE__); -#endif +	FLOCKFILE(stdin);  	retval = __svfscanf(stdin, fmt, ap); -#ifdef _THREAD_SAFE -	_thread_funlockfile(stdin); -#endif +	FUNLOCKFILE(stdin);  	return (retval);  } | 
