diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index 09d31bb3b0a2..3daddcfd8fa4 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -6175,6 +6175,7 @@ ./usr/share/man/cat3/circleq_remove.0 comp-obsolete obsolete ./usr/share/man/cat3/clear.0 comp-c-catman .cat ./usr/share/man/cat3/clearerr.0 comp-c-catman .cat +./usr/share/man/cat3/clearerr_unlocked.0 comp-c-catman .cat ./usr/share/man/cat3/clearok.0 comp-c-catman .cat ./usr/share/man/cat3/clnt_broadcast.0 comp-c-catman .cat ./usr/share/man/cat3/clnt_call.0 comp-c-catman .cat @@ -6923,8 +6924,10 @@ ./usr/share/man/cat3/feholdexcept.0 comp-c-catman .cat ./usr/share/man/cat3/fenv.0 comp-c-catman .cat ./usr/share/man/cat3/feof.0 comp-c-catman .cat +./usr/share/man/cat3/feof_unlocked.0 comp-c-catman .cat ./usr/share/man/cat3/feraiseexcept.0 comp-c-catman .cat ./usr/share/man/cat3/ferror.0 comp-c-catman .cat +./usr/share/man/cat3/ferror_unlocked.0 comp-c-catman .cat ./usr/share/man/cat3/feseteexcpetflag.0 comp-obsolete obsolete ./usr/share/man/cat3/fesetenv.0 comp-c-catman .cat ./usr/share/man/cat3/fesetexceptflag.0 comp-c-catman .cat @@ -6962,6 +6965,7 @@ ./usr/share/man/cat3/field_type.0 comp-c-catman .cat ./usr/share/man/cat3/field_userptr.0 comp-c-catman .cat ./usr/share/man/cat3/fileno.0 comp-c-catman .cat +./usr/share/man/cat3/fileno_unlocked.0 comp-c-catman .cat ./usr/share/man/cat3/filter.0 comp-c-catman .cat ./usr/share/man/cat3/finite.0 comp-c-catman .cat ./usr/share/man/cat3/finitef.0 comp-c-catman .cat @@ -14175,6 +14179,7 @@ ./usr/share/man/html3/cimagl.html comp-c-htmlman complex,html ./usr/share/man/html3/clear.html comp-c-htmlman html ./usr/share/man/html3/clearerr.html comp-c-htmlman html +./usr/share/man/html3/clearerr_unlocked.html comp-c-htmlman html ./usr/share/man/html3/clearok.html comp-c-htmlman html ./usr/share/man/html3/clnt_broadcast.html comp-c-htmlman html ./usr/share/man/html3/clnt_call.html comp-c-htmlman html @@ -14932,8 +14937,10 @@ ./usr/share/man/html3/feholdexcept.html comp-c-htmlman html ./usr/share/man/html3/fenv.html comp-c-htmlman html ./usr/share/man/html3/feof.html comp-c-htmlman html +./usr/share/man/html3/feof_unlocked.html comp-c-htmlman html ./usr/share/man/html3/feraiseexcept.html comp-c-htmlman html ./usr/share/man/html3/ferror.html comp-c-htmlman html +./usr/share/man/html3/ferror_unlocked.html comp-c-htmlman html ./usr/share/man/html3/feseteexcpetflag.html comp-obsolete obsolete ./usr/share/man/html3/fesetenv.html comp-c-htmlman html ./usr/share/man/html3/fesetexceptflag.html comp-c-htmlman html @@ -14970,6 +14977,7 @@ ./usr/share/man/html3/field_type.html comp-c-htmlman html ./usr/share/man/html3/field_userptr.html comp-c-htmlman html ./usr/share/man/html3/fileno.html comp-c-htmlman html +./usr/share/man/html3/fileno_unlocked.html comp-c-htmlman html ./usr/share/man/html3/filter.html comp-c-htmlman html ./usr/share/man/html3/finite.html comp-c-htmlman html ./usr/share/man/html3/finitef.html comp-c-htmlman html @@ -22118,6 +22126,7 @@ ./usr/share/man/man3/circleq_remove.3 comp-obsolete obsolete ./usr/share/man/man3/clear.3 comp-c-man .man ./usr/share/man/man3/clearerr.3 comp-c-man .man +./usr/share/man/man3/clearerr_unlocked.3 comp-c-man .man ./usr/share/man/man3/clearok.3 comp-c-man .man ./usr/share/man/man3/clnt_broadcast.3 comp-c-man .man ./usr/share/man/man3/clnt_call.3 comp-c-man .man @@ -22877,8 +22886,10 @@ ./usr/share/man/man3/feholdexcept.3 comp-c-man .man ./usr/share/man/man3/fenv.3 comp-c-man .man ./usr/share/man/man3/feof.3 comp-c-man .man +./usr/share/man/man3/feof_unlocked.3 comp-c-man .man ./usr/share/man/man3/feraiseexcept.3 comp-c-man .man ./usr/share/man/man3/ferror.3 comp-c-man .man +./usr/share/man/man3/ferror_unlocked.3 comp-c-man .man ./usr/share/man/man3/feseteexcpetflag.3 comp-obsolete obsolete ./usr/share/man/man3/fesetenv.3 comp-c-man .man ./usr/share/man/man3/fesetexceptflag.3 comp-c-man .man @@ -22916,6 +22927,7 @@ ./usr/share/man/man3/field_type.3 comp-c-man .man ./usr/share/man/man3/field_userptr.3 comp-c-man .man ./usr/share/man/man3/fileno.3 comp-c-man .man +./usr/share/man/man3/fileno_unlocked.3 comp-c-man .man ./usr/share/man/man3/filter.3 comp-c-man .man ./usr/share/man/man3/finite.3 comp-c-man .man ./usr/share/man/man3/finitef.3 comp-c-man .man diff --git a/external/gpl2/diffutils/include/config.h b/external/gpl2/diffutils/include/config.h index c292e7c7ec61..63e4e1574431 100644 --- a/external/gpl2/diffutils/include/config.h +++ b/external/gpl2/diffutils/include/config.h @@ -69,15 +69,15 @@ /* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_CLEARERR_UNLOCKED 0 +#define HAVE_DECL_CLEARERR_UNLOCKED 1 /* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_FEOF_UNLOCKED 0 +#define HAVE_DECL_FEOF_UNLOCKED 1 /* Define to 1 if you have the declaration of `ferror_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_FERROR_UNLOCKED 0 +#define HAVE_DECL_FERROR_UNLOCKED 1 /* Define to 1 if you have the declaration of `fflush_unlocked', and to 0 if you don't. */ diff --git a/external/gpl2/gettext/include/config.h b/external/gpl2/gettext/include/config.h index ff64e7191176..aeb0ae2f3543 100644 --- a/external/gpl2/gettext/include/config.h +++ b/external/gpl2/gettext/include/config.h @@ -120,15 +120,15 @@ /* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_CLEARERR_UNLOCKED 0 +#define HAVE_DECL_CLEARERR_UNLOCKED 1 /* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_FEOF_UNLOCKED 0 +#define HAVE_DECL_FEOF_UNLOCKED 1 /* Define to 1 if you have the declaration of `ferror_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_FERROR_UNLOCKED 0 +#define HAVE_DECL_FERROR_UNLOCKED 1 /* Define to 1 if you have the declaration of `fflush_unlocked', and to 0 if you don't. */ @@ -906,4 +906,3 @@ #ifdef __EMX__ # include "intl/os2compat.h" #endif - diff --git a/external/gpl2/xcvs/include/config.h b/external/gpl2/xcvs/include/config.h index a8218dca2565..214545f74668 100644 --- a/external/gpl2/xcvs/include/config.h +++ b/external/gpl2/xcvs/include/config.h @@ -156,15 +156,15 @@ /* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_CLEARERR_UNLOCKED 0 +#define HAVE_DECL_CLEARERR_UNLOCKED 1 /* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_FEOF_UNLOCKED 0 +#define HAVE_DECL_FEOF_UNLOCKED 1 /* Define to 1 if you have the declaration of `ferror_unlocked', and to 0 if you don't. */ -#define HAVE_DECL_FERROR_UNLOCKED 0 +#define HAVE_DECL_FERROR_UNLOCKED 1 /* Define to 1 if you have the declaration of `fflush_unlocked', and to 0 if you don't. */ diff --git a/include/netdb.h b/include/netdb.h index 122e997f8d53..10d5cf00393b 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -133,11 +133,8 @@ typedef _BSD_SIZE_T_ size_t; #endif __BEGIN_DECLS -extern int h_errno; extern int * __h_errno(void); -#ifdef _REENTRANT #define h_errno (*__h_errno()) -#endif __END_DECLS /*% diff --git a/include/stdio.h b/include/stdio.h index a7e86a700df2..fcb4f86f6224 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -308,7 +308,7 @@ __END_DECLS * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 */ #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ - defined(_REENTRANT) || defined(_NETBSD_SOURCE) + defined(_NETBSD_SOURCE) __BEGIN_DECLS void flockfile(FILE *); int ftrylockfile(FILE *); @@ -487,27 +487,14 @@ static __inline int __sputc(int _c, FILE *_p) { #define __sfileno(p) \ ((p)->_file == -1 ? -1 : (int)(unsigned short)(p)->_file) -#if !defined(__lint__) && !defined(__cplusplus) -#if !defined(_REENTRANT) && !defined(_PTHREADS) -#define feof(p) __sfeof(p) -#define ferror(p) __sferror(p) -#define clearerr(p) __sclearerr(p) - -#define getc(fp) __sgetc(fp) -#define putc(x, fp) __sputc(x, fp) -#endif /* !_REENTRANT && !_PTHREADS */ - -#define getchar() getc(stdin) -#define putchar(x) putc(x, stdout) - -#endif /* !__lint__ && !__cplusplus */ - -#if (defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ - defined(_NETBSD_SOURCE)) && !defined(__cplusplus) -#if !defined(_REENTRANT) && !defined(_PTHREADS) -#define fileno(p) __sfileno(p) -#endif /* !_REENTRANT && !_PTHREADS */ -#endif /* !_ANSI_SOURCE && !__cplusplus*/ +#if defined(_NETBSD_SOURCE) +__BEGIN_DECLS +int feof_unlocked(FILE *); +int ferror_unlocked(FILE *); +void clearerr_unlocked(FILE *); +int fileno_unlocked(FILE *); +__END_DECLS +#endif /* defined(_NETBSD_SOURCE) */ #if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) __BEGIN_DECLS @@ -518,15 +505,6 @@ int dprintf(int, const char * __restrict, ...) __END_DECLS #endif /* (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE) */ -#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ - defined(_REENTRANT) || defined(_NETBSD_SOURCE) && !defined(__cplusplus) -#define getc_unlocked(fp) __sgetc(fp) -#define putc_unlocked(x, fp) __sputc(x, fp) - -#define getchar_unlocked() getc_unlocked(stdin) -#define putchar_unlocked(x) putc_unlocked(x, stdout) -#endif /* _POSIX_C_SOURCE >= 199506 || _XOPEN_SOURCE >= 500 || _REENTRANT... */ - #if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \ defined(_NETBSD_SOURCE) __BEGIN_DECLS diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc index 1bf62e0df3ab..3469bc6416a0 100644 --- a/lib/libc/stdio/Makefile.inc +++ b/lib/libc/stdio/Makefile.inc @@ -34,6 +34,8 @@ MAN+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fgetwln.3 fgetws.3 \ tmpnam.3 ungetc.3 ungetwc.3 wprintf.3 wscanf.3 open_memstream.3 MLINKS+=ferror.3 clearerr.3 ferror.3 feof.3 ferror.3 fileno.3 +MLINKS+=ferror.3 ferror_unlocked.3 ferror.3 clearerr_unlocked.3 +MLINKS+=ferror.3 feof_unlocked.3 ferror.3 fileno_unlocked.3 MLINKS+=fflush.3 fpurge.3 MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3 MLINKS+=fgets.3 gets.3 @@ -73,4 +75,3 @@ MLINKS+=printf_l.3 asprintf_l.3 printf_l.3 fprintf_l.3 printf_l.3 snprintf_l.3 \ printf_l.3 vsprintf_l.3 MLINKS+=scanf_l.3 fscanf_l.3 scanf_l.3 sscanf_l.3 scanf_l.3 vfscanf_l.3 \ scanf_l.3 vscanf_l.3 scanf_l.3 vsscanf_l.3 - diff --git a/lib/libc/stdio/clrerr.c b/lib/libc/stdio/clrerr.c index 2cec89244f43..f3030f47068a 100644 --- a/lib/libc/stdio/clrerr.c +++ b/lib/libc/stdio/clrerr.c @@ -45,7 +45,6 @@ __RCSID("$NetBSD: clrerr.c,v 1.11 2012/03/15 18:22:30 christos Exp $"); #include "reentrant.h" #include "local.h" -#undef clearerr void clearerr(FILE *fp) @@ -56,3 +55,11 @@ clearerr(FILE *fp) __sclearerr(fp); FUNLOCKFILE(fp); } + +void +clearerr_unlocked(FILE *fp) +{ + _DIAGASSERT(fp != NULL); + + __sclearerr(fp); +} diff --git a/lib/libc/stdio/feof.c b/lib/libc/stdio/feof.c index 1d25eae90e2c..d26f27bcc51e 100644 --- a/lib/libc/stdio/feof.c +++ b/lib/libc/stdio/feof.c @@ -46,10 +46,6 @@ __RCSID("$NetBSD: feof.c,v 1.12 2012/03/15 18:22:30 christos Exp $"); #include "reentrant.h" #include "local.h" -/* - * A subroutine version of the macro feof. - */ -#undef feof int feof(FILE *fp) @@ -63,3 +59,12 @@ feof(FILE *fp) FUNLOCKFILE(fp); return r; } + +int +feof_unlocked(FILE *fp) +{ + + _DIAGASSERT(fp != NULL); + + return __sfeof(fp); +} diff --git a/lib/libc/stdio/ferror.3 b/lib/libc/stdio/ferror.3 index 270a76607de4..4decb13ba1d1 100644 --- a/lib/libc/stdio/ferror.3 +++ b/lib/libc/stdio/ferror.3 @@ -38,9 +38,13 @@ .Os .Sh NAME .Nm clearerr , +.Nm clearerr_unlocked , .Nm feof , +.Nm feof_unlocked , .Nm ferror , -.Nm fileno +.Nm ferror_unlocked , +.Nm fileno , +.Nm fileno_unlocked .Nd check and reset stream status .Sh LIBRARY .Lb libc @@ -48,12 +52,20 @@ .In stdio.h .Ft void .Fn clearerr "FILE *stream" +.Ft void +.Fn clearerr_unlocked "FILE *stream" .Ft int .Fn feof "FILE *stream" .Ft int +.Fn feof_unlocked "FILE *stream" +.Ft int .Fn ferror "FILE *stream" .Ft int +.Fn ferror_unlocked "FILE *stream" +.Ft int .Fn fileno "FILE *stream" +.Ft int +.Fn fileno_unlocked "FILE *stream" .Sh DESCRIPTION The function .Fn clearerr @@ -83,6 +95,14 @@ The function examines the argument .Fa stream and returns its integer descriptor. +.Pp +The +.Fn clearerr_unlocked , +.Fn feof_unlocked , +.Fn ferror_unlocked +and +.Fn fileno_unlocked +functions do not use implicit locking. .Sh ERRORS The functions .Fn clearerr , @@ -119,3 +139,13 @@ The function .Fn fileno conforms to .St -p1003.1-90 . +.Pp +The +.Fn clearerr_unlocked , +.Fn feof_unlocked , +.Fn ferror_unlocked +and +.Fn fileno_unlocked +functions are +.Nx +extensions. diff --git a/lib/libc/stdio/ferror.c b/lib/libc/stdio/ferror.c index 2e4beaef99d4..8a4c7be8a4ff 100644 --- a/lib/libc/stdio/ferror.c +++ b/lib/libc/stdio/ferror.c @@ -46,10 +46,6 @@ __RCSID("$NetBSD: ferror.c,v 1.12 2012/03/15 18:22:30 christos Exp $"); #include "reentrant.h" #include "local.h" -/* - * A subroutine version of the macro ferror. - */ -#undef ferror int ferror(FILE *fp) @@ -63,3 +59,12 @@ ferror(FILE *fp) FUNLOCKFILE(fp); return r; } + +int +ferror_unlocked(FILE *fp) +{ + + _DIAGASSERT(fp != NULL); + + return __sferror(fp); +} diff --git a/lib/libc/stdio/fileno.c b/lib/libc/stdio/fileno.c index 0b6e7ba3ff1e..710571231a03 100644 --- a/lib/libc/stdio/fileno.c +++ b/lib/libc/stdio/fileno.c @@ -48,10 +48,6 @@ __RCSID("$NetBSD: fileno.c,v 1.13 2012/03/15 18:22:30 christos Exp $"); #include "reentrant.h" #include "local.h" -/* - * A subroutine version of the macro fileno. - */ -#undef fileno int _fileno(FILE *); /* XXX */ __weak_alias(fileno,_fileno) @@ -68,3 +64,12 @@ _fileno(FILE *fp) FUNLOCKFILE(fp); return r; } + +int +fileno_unlocked(FILE *fp) +{ + + _DIAGASSERT(fp != NULL); + + return __sfileno(fp); +} diff --git a/lib/libc/stdio/getc.c b/lib/libc/stdio/getc.c index 7a487f3321d1..a4f7d31b0c7f 100644 --- a/lib/libc/stdio/getc.c +++ b/lib/libc/stdio/getc.c @@ -47,11 +47,6 @@ __RCSID("$NetBSD: getc.c,v 1.12 2012/03/15 18:22:30 christos Exp $"); #include "reentrant.h" #include "local.h" -/* - * A subroutine version of the macro getc. - */ -#undef getc -#undef getc_unlocked int getc(FILE *fp) diff --git a/lib/libc/stdio/getchar.c b/lib/libc/stdio/getchar.c index bd692d141bae..cc835dd02fc0 100644 --- a/lib/libc/stdio/getchar.c +++ b/lib/libc/stdio/getchar.c @@ -48,9 +48,6 @@ __RCSID("$NetBSD: getchar.c,v 1.10 2012/03/15 18:22:30 christos Exp $"); #include "reentrant.h" #include "local.h" -#undef getchar -#undef getchar_unlocked - int getchar(void) { diff --git a/lib/libc/stdio/putc.c b/lib/libc/stdio/putc.c index ad57090e2fd4..eb4c08842c96 100644 --- a/lib/libc/stdio/putc.c +++ b/lib/libc/stdio/putc.c @@ -47,11 +47,6 @@ __RCSID("$NetBSD: putc.c,v 1.13 2018/02/04 01:13:45 mrg Exp $"); #include "reentrant.h" #include "local.h" -/* - * A subroutine version of the macro putc. - */ -#undef putc -#undef putc_unlocked int putc(int c, FILE *fp) diff --git a/lib/libc/stdio/putchar.c b/lib/libc/stdio/putchar.c index 86aa6bf30e21..15deade1d751 100644 --- a/lib/libc/stdio/putchar.c +++ b/lib/libc/stdio/putchar.c @@ -45,12 +45,7 @@ __RCSID("$NetBSD: putchar.c,v 1.10 2012/03/15 18:22:30 christos Exp $"); #include "reentrant.h" #include "local.h" -#undef putchar -#undef putchar_unlocked -/* - * A subroutine version of the macro putchar - */ int putchar(int c) { diff --git a/lib/libc/stdio/stdio.3 b/lib/libc/stdio/stdio.3 index aa517df1a91f..67ad50dafb49 100644 --- a/lib/libc/stdio/stdio.3 +++ b/lib/libc/stdio/stdio.3 @@ -154,12 +154,17 @@ function. .Sh IMPLEMENTATION NOTES In multi-threaded applications, operations on streams perform implicit locking, except for the +.Fn clearerr_unlocked , +.Fn feof_unlocked , +.Fn ferror_unlocked , +.Fn fileno_unlocked , .Fn getc_unlocked , .Fn getchar_unlocked , -.Fn putc_unlocked , +.Fn putc_unlocked and .Fn putchar_unlocked functions. +.Pp Explicit control of stream locking is available through the .Fn flockfile , .Fn ftrylockfile , @@ -182,39 +187,17 @@ without first removing their current definitions with .Dv SEEK_SET , .Dv SEE_CUR , .Dv TMP_MAX , -.Fn clearerr , -.Fn feof , -.Fn ferror , -.Fn fileno , -.Fn freopen , +.Fn fropen , +.Fn fropen2 , .Fn fwopen , -.Fn getc , +.Fn fwopen2 , .Fn getc_unlocked , -.Fn getchar , .Fn getchar_unlocked , -.Fn putc , .Fn putc_unlocked , -.Fn putchar , .Fn putchar_unlocked , .Dv stderr , .Dv stdin , .Dv stdout . -.Pp -Function versions of the macro functions -.Fn feof , -.Fn ferror , -.Fn clearerr , -.Fn fileno , -.Fn getc , -.Fn getc_unlocked , -.Fn getchar , -.Fn getchar_unlocked , -.Fn putc , -.Fn putc_unlocked , -.Fn putchar , -and -.Fn putchar_unlocked -exist and will be used if the macros definitions are explicitly removed. .Sh SEE ALSO .Xr close 2 , .Xr open 2 , @@ -231,12 +214,18 @@ library conforms to .It asprintf formatted output conversion with allocation .It asprintf_l formatted output conversion with allocation .It clearerr check and reset stream status +.It clearerr_unlocked check and reset stream status +.It Ta (no implicit locking) .It dprintf formatted output conversion .It dprintf_l formatted output conversion .It fclose close a stream .It fdopen stream open functions .It feof check and reset stream status +.It feof_unlocked check and reset stream status +.It Ta (no implicit locking) .It ferror check and reset stream status +.It ferror_unlocked check and reset stream status +.It Ta (no implicit locking) .It fflush flush a stream .It fgetc get next character or word from input stream .It fgetln get a line from a stream @@ -244,6 +233,8 @@ library conforms to .It fgets get a line from a stream .It fgetwc get next wide character from input stream .It fileno check and reset stream status +.It fileno_unlocked check and reset stream status +.It Ta (no implicit locking) .It flockfile lock a stream .It fmemopen open a stream that points to a memory buffer .It fopen stream open functions @@ -256,6 +247,7 @@ library conforms to .It fread binary stream input/output .It freopen stream open functions .It fropen open a stream +.It fropen2 open a stream .It fscanf input format conversion .It fscanf_l input format conversion .It fseek reposition a stream @@ -269,6 +261,7 @@ library conforms to .It funopen2 open a stream, with flush support .It fwide set/get orientation of a stream .It fwopen open a stream +.It fwopen2 open a stream .It fwrite binary stream input/output .It getc get next character or word from input stream .It getc_unlocked get next character or word from input stream