FreeBSD/src fda0a14 (r320472)lib/libc/stdio freopen.c local.h

Make stdio deferred cancel-safe.

If used with fopen(3)/fdopen(3)-ed FILEs, stdio accurately uses
non-cancellable internal versions of the functions, i.e. it seems to
be fine with regard to cancellation.  But if the funopen(3) and
f{r,w}open(3) functions were used to open the FILE, and corresponding
user functions create cancellation points (they typically have no
other choice), then stdio code at least leaks FILE' lock.

The change installs cleanup handler which unlocks FILE.  Some minimal
restructuring of the code was required to make it use common return
place to satisfy hand-rolled pthread_cleanup_pop() requirements.

Noted by:       eugen
Reviewed by:    eugen, vangyzen
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      2 weeks
Differential revision:  https://reviews.freebsd.org/D11246
DeltaFile
+15-14lib/libc/stdio/freopen.c
+26-0lib/libc/stdio/local.h
+12-10lib/libc/stdio/fgets.c
+11-11lib/libc/stdio/fgetln.c
+10-10lib/libc/stdio/fputws.c
+10-7lib/libc/stdio/gets.c
+8-5lib/libc/stdio/fgetwln.c
+7-6lib/libc/stdio/getdelim.c
+7-5lib/libc/stdio/fgetws.c
+4-4lib/libc/stdio/fclose.c
+4-4lib/libc/stdio/fflush.c
+4-4lib/libc/stdio/fscanf.c
+4-4lib/libc/stdio/fseek.c
+4-4lib/libc/stdio/scanf.c
+4-4lib/libc/stdio/setvbuf.c
+8-0lib/libc/stdio/stdio.c
+4-4lib/libc/stdio/vfscanf.c
+3-2lib/libc/stdio/putw.c
+2-2lib/libc/stdio/getchar.c
+2-2lib/libc/stdio/fputc.c
+2-2lib/libc/stdio/fgetwc.c
+2-2lib/libc/stdio/fgetc.c
+2-2lib/libc/stdio/perror.c
+2-2lib/libc/stdio/putc.c
+2-2lib/libc/stdio/putchar.c
+2-2lib/libc/stdio/puts.c
+2-2lib/libc/stdio/refill.c
+2-2lib/libc/stdio/vscanf.c
+2-2lib/libc/stdio/vfwprintf.c
+2-2lib/libc/stdio/vfwscanf.c
+2-2lib/libc/stdio/ungetc.c
+2-2lib/libc/stdio/fputwc.c
+2-2lib/libc/stdio/fread.c
+2-2lib/libc/stdio/fputs.c
+2-2lib/libc/stdio/ungetwc.c
+2-2lib/libc/stdio/vfprintf.c
+2-2lib/libc/stdio/getc.c
+2-2lib/libc/stdio/fwrite.c
+185-13838 files

UnifiedSplitRaw