diff options
author | cvs2svn <> | 2012-08-10 13:37:35 +0400 |
---|---|---|
committer | cvs2svn <> | 2012-08-10 13:37:35 +0400 |
commit | 316eee31fe861ecb6db3905a85719fd536f984be (patch) | |
tree | 504dc9042e08d314c2b0222092d0a63314981e7e /newlib/libc/stdio | |
parent | c0956742a74d194b9c18c7a91aa6d6010beb4cd3 (diff) |
This commit was manufactured by cvs2svn to create tag 'cygwin-cygwin-1_7_11-release
1_7_11-release'.
Sprout from cygwin-64bit-branch 2012-08-10 09:37:33 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch 'cygwin-64bit-'
Cherrypick from master 2012-02-25 10:51:32 UTC Corinna Vinschen <corinna@vinschen.de> ' * new-features.sgml (ov-new1.7.11): Add two more changes to the list.':
COPYING.LIBGLOSS
COPYING.NEWLIB
COPYING3
COPYING3.LIB
ChangeLog
MAINTAINERS
compile
config.rpath
config.sub
config/ChangeLog
config/mh-darwin
config/mh-interix
config/mh-ppc-aix
config/mt-alphaieee
config/mt-sde
config/picflag.m4
config/stdint.m4
config/tcl.m4
configure
configure.ac
include/ChangeLog
include/bfdlink.h
include/dis-asm.h
include/dwarf2.h
include/elf/ChangeLog
include/elf/avr.h
include/elf/common.h
include/elf/m68hc11.h
include/elf/mn10300.h
include/elf/ppc.h
include/elf/s390.h
include/elf/sparc.h
include/elf/tilegx.h
include/elf/tilepro.h
include/filenames.h
include/gdb/ChangeLog
include/gdb/callback.h
include/gdb/signals.def
include/gdb/signals.h
include/mach-o/ChangeLog
include/mach-o/codesign.h
include/mach-o/external.h
include/mach-o/loader.h
include/mach-o/reloc.h
include/mach-o/x86-64.h
include/opcode/ChangeLog
include/opcode/avr.h
include/opcode/crx.h
include/opcode/m68hc11.h
include/opcode/mips.h
include/opcode/ppc.h
include/opcode/sparc.h
include/opcode/tilegx.h
include/opcode/tilepro.h
include/plugin-api.h
include/splay-tree.h
include/vms/ChangeLog
include/vms/lbr.h
ltgcc.m4
ltoptions.m4
ltversion.m4
lt~obsolete.m4
newlib/ChangeLog
newlib/doc/Makefile.am
newlib/doc/Makefile.in
newlib/libc/include/machine/setjmp-dj.h
newlib/libc/include/stdio.h
newlib/libc/include/string.h
newlib/libc/include/sys/signal.h
newlib/libc/include/sys/stat.h
newlib/libc/include/sys/time.h
newlib/libc/include/sys/times.h
newlib/libc/include/sys/types.h
newlib/libc/include/sys/unistd.h
newlib/libc/include/sys/wait.h
newlib/libc/locale/lmessages.c
newlib/libc/locale/lmonetary.c
newlib/libc/locale/locale.c
newlib/libc/locale/nl_langinfo.c
newlib/libc/machine/arm/access.c
newlib/libc/machine/cr16/sys/asm.h
newlib/libc/machine/epiphany/Makefile.am
newlib/libc/machine/epiphany/Makefile.in
newlib/libc/machine/epiphany/aclocal.m4
newlib/libc/machine/epiphany/configure
newlib/libc/machine/epiphany/configure.in
newlib/libc/machine/epiphany/machine/stdlib.h
newlib/libc/machine/epiphany/setjmp.S
newlib/libc/machine/i386/setjmp.S
newlib/libc/machine/rl78/Makefile.am
newlib/libc/machine/rl78/Makefile.in
newlib/libc/machine/rl78/aclocal.m4
newlib/libc/machine/rl78/configure
newlib/libc/machine/rl78/configure.in
newlib/libc/machine/rl78/setjmp.S
newlib/libc/posix/collate.c
newlib/libc/posix/engine.c
newlib/libc/posix/glob.c
newlib/libc/posix/popen.c
newlib/libc/posix/readdir.c
newlib/libc/posix/readdir_r.c
newlib/libc/posix/regcomp.c
newlib/libc/posix/telldir.c
newlib/libc/posix/wordexp.c
newlib/libc/reent/mkdirr.c
newlib/libc/reent/renamer.c
newlib/libc/search/hash.c
newlib/libc/search/hash_bigkey.c
newlib/libc/search/hash_page.c
newlib/libc/search/hcreate_r.c
newlib/libc/stdio/asiprintf.c
newlib/libc/stdio/asprintf.c
newlib/libc/stdio/clearerr.c
newlib/libc/stdio/fclose.c
newlib/libc/stdio/fdopen.c
newlib/libc/stdio/feof.c
newlib/libc/stdio/ferror.c
newlib/libc/stdio/fflush.c
newlib/libc/stdio/fgetc.c
newlib/libc/stdio/fgets.c
newlib/libc/stdio/fgetwc.c
newlib/libc/stdio/fgetws.c
newlib/libc/stdio/fileno.c
newlib/libc/stdio/findfp.c
newlib/libc/stdio/fmemopen.c
newlib/libc/stdio/fopen.c
newlib/libc/stdio/fopencookie.c
newlib/libc/stdio/fpurge.c
newlib/libc/stdio/fputc.c
newlib/libc/stdio/fputs.c
newlib/libc/stdio/fputwc.c
newlib/libc/stdio/fputws.c
newlib/libc/stdio/fread.c
newlib/libc/stdio/freopen.c
newlib/libc/stdio/fseek.c
newlib/libc/stdio/ftell.c
newlib/libc/stdio/funopen.c
newlib/libc/stdio/fwide.c
newlib/libc/stdio/fwrite.c
newlib/libc/stdio/getc.c
newlib/libc/stdio/getdelim.c
newlib/libc/stdio/gets.c
newlib/libc/stdio/local.h
newlib/libc/stdio/mktemp.c
newlib/libc/stdio/open_memstream.c
newlib/libc/stdio/putc.c
newlib/libc/stdio/setvbuf.c
newlib/libc/stdio/ungetc.c
newlib/libc/stdio/ungetwc.c
newlib/libc/stdio/vasiprintf.c
newlib/libc/stdio/vasprintf.c
newlib/libc/stdio/vfprintf.c
newlib/libc/stdio/vfscanf.c
newlib/libc/stdio/vfwprintf.c
newlib/libc/stdio/vfwscanf.c
newlib/libc/stdio64/fdopen64.c
newlib/libc/stdio64/fopen64.c
newlib/libc/stdio64/freopen64.c
newlib/libc/stdio64/fseeko64.c
newlib/libc/stdio64/ftello64.c
newlib/libc/stdlib/mbtowc_r.c
newlib/libc/stdlib/mprec.h
newlib/libc/stdlib/wctomb_r.c
newlib/libc/string/Makefile.am
newlib/libc/string/Makefile.in
newlib/libc/string/strcasestr.c
newlib/libc/sys/epiphany/Makefile.am
newlib/libc/sys/epiphany/Makefile.in
newlib/libc/sys/epiphany/aclocal.m4
newlib/libc/sys/epiphany/configure
newlib/libc/sys/epiphany/configure.in
newlib/libc/sys/epiphany/e_printf.c
newlib/libc/sys/h8300hms/sys/file.h
newlib/libc/sys/linux/machine/i386/setjmp.S
newlib/libc/sys/rtems/crt0.c
newlib/libc/sys/rtems/machine/_types.h
newlib/libc/sys/sysmec/access.c
newlib/libc/sys/sysnecv850/access.c
newlib/libc/sys/sysnecv850/crt0.S
newlib/libc/time/strptime.c
newlib/libm/common/sf_round.c
newlib/libm/math/e_atan2.c
newlib/libm/math/e_exp.c
newlib/libm/math/e_pow.c
newlib/libm/math/e_rem_pio2.c
newlib/libm/math/ef_exp.c
newlib/libm/math/ef_pow.c
newlib/libm/math/er_lgamma.c
newlib/libm/math/erf_lgamma.c
newlib/testsuite/newlib.stdio/stdio.exp
newlib/testsuite/newlib.stdio/swprintf.c
newlib/testsuite/newlib.string/strcmp-1.c
winsup/ChangeLog
winsup/Makefile.common
winsup/cygserver/ChangeLog
winsup/cygserver/client.cc
winsup/cygserver/woutsup.h
winsup/cygwin/ChangeLog
winsup/cygwin/Makefile.in
winsup/cygwin/advapi32.cc
winsup/cygwin/child_info.h
winsup/cygwin/configure.in
winsup/cygwin/cygheap.cc
winsup/cygwin/cygheap.h
winsup/cygwin/cygprops.h
winsup/cygwin/cygserver_ipc.h
winsup/cygwin/cygthread.cc
winsup/cygwin/cygtls.cc
winsup/cygwin/cygtls.h
winsup/cygwin/cygwin.din
winsup/cygwin/cygwin.sc
winsup/cygwin/dcrt0.cc
winsup/cygwin/devices.cc
winsup/cygwin/devices.h
winsup/cygwin/devices.in
winsup/cygwin/dir.cc
winsup/cygwin/dll_init.cc
winsup/cygwin/dll_init.h
winsup/cygwin/dtable.cc
winsup/cygwin/dtable.h
winsup/cygwin/environ.cc
winsup/cygwin/exceptions.cc
winsup/cygwin/external.cc
winsup/cygwin/fenv.cc
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_clipboard.cc
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_disk_file.cc
winsup/cygwin/fhandler_dsp.cc
winsup/cygwin/fhandler_fifo.cc
winsup/cygwin/fhandler_floppy.cc
winsup/cygwin/fhandler_mem.cc
winsup/cygwin/fhandler_nodevice.cc
winsup/cygwin/fhandler_process.cc
winsup/cygwin/fhandler_procnet.cc
winsup/cygwin/fhandler_registry.cc
winsup/cygwin/fhandler_serial.cc
winsup/cygwin/fhandler_socket.cc
winsup/cygwin/fhandler_tape.cc
winsup/cygwin/fhandler_termios.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/fhandler_virtual.cc
winsup/cygwin/fhandler_windows.cc
winsup/cygwin/flock.cc
winsup/cygwin/fork.cc
winsup/cygwin/gendef
winsup/cygwin/gendevices
winsup/cygwin/gentls_offsets
winsup/cygwin/glob.cc
winsup/cygwin/globals.cc
winsup/cygwin/heap.cc
winsup/cygwin/hires.h
winsup/cygwin/hookapi.cc
winsup/cygwin/include/cygwin/if.h
winsup/cygwin/include/cygwin/in.h
winsup/cygwin/include/cygwin/socket.h
winsup/cygwin/include/cygwin/version.h
winsup/cygwin/include/elf.h
winsup/cygwin/include/inttypes.h
winsup/cygwin/include/mntent.h
winsup/cygwin/include/netdb.h
winsup/cygwin/include/stdint.h
winsup/cygwin/include/sys/elf32.h
winsup/cygwin/include/sys/elf64.h
winsup/cygwin/include/sys/elf_common.h
winsup/cygwin/include/sys/elf_generic.h
winsup/cygwin/include/sys/termios.h
winsup/cygwin/include/sys/wait.h
winsup/cygwin/init.cc
winsup/cygwin/kernel32.cc
winsup/cygwin/lib/_cygwin_crt0_common.cc
winsup/cygwin/lib/crt0.h
winsup/cygwin/libc/inet_addr.c
winsup/cygwin/libc/inet_network.c
winsup/cygwin/libc/minires-os-if.c
winsup/cygwin/libc/minires.h
winsup/cygwin/libc/rcmd.cc
winsup/cygwin/miscfuncs.cc
winsup/cygwin/miscfuncs.h
winsup/cygwin/mkglobals_h
winsup/cygwin/mkvers.sh
winsup/cygwin/mmap.cc
winsup/cygwin/mount.cc
winsup/cygwin/mount.h
winsup/cygwin/net.cc
winsup/cygwin/ntdll.h
winsup/cygwin/passwd.cc
winsup/cygwin/path.cc
winsup/cygwin/path.h
winsup/cygwin/pinfo.cc
winsup/cygwin/pinfo.h
winsup/cygwin/pipe.cc
winsup/cygwin/poll.cc
winsup/cygwin/posix.sgml
winsup/cygwin/posix_ipc.cc
winsup/cygwin/pseudo-reloc.cc
winsup/cygwin/regex/regcomp.c
winsup/cygwin/registry.cc
winsup/cygwin/release/1.7.10
winsup/cygwin/release/1.7.11
winsup/cygwin/sched.cc
winsup/cygwin/sec_acl.cc
winsup/cygwin/sec_helper.cc
winsup/cygwin/security.cc
winsup/cygwin/security.h
winsup/cygwin/select.cc
winsup/cygwin/select.h
winsup/cygwin/shared.cc
winsup/cygwin/signal.cc
winsup/cygwin/sigproc.cc
winsup/cygwin/sigproc.h
winsup/cygwin/smallprint.cc
winsup/cygwin/spawn.cc
winsup/cygwin/strace.cc
winsup/cygwin/strfuncs.cc
winsup/cygwin/sync.h
winsup/cygwin/syscalls.cc
winsup/cygwin/sysconf.cc
winsup/cygwin/syslog.cc
winsup/cygwin/termios.cc
winsup/cygwin/thread.cc
winsup/cygwin/thread.h
winsup/cygwin/times.cc
winsup/cygwin/tlsoffsets.h
winsup/cygwin/wait.cc
winsup/cygwin/winbase.h
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h
winsup/cygwin/winlean.h
winsup/cygwin/winsup.h
winsup/cygwin/winver.rc
winsup/doc/ChangeLog
winsup/doc/configure
winsup/doc/cygwinenv.sgml
winsup/doc/faq-programming.xml
winsup/doc/faq-using.xml
winsup/doc/new-features.sgml
winsup/doc/overview2.sgml
winsup/doc/pathnames.sgml
winsup/doc/setup-net.sgml
winsup/doc/using.sgml
winsup/lsaauth/ChangeLog
winsup/lsaauth/Makefile.in
winsup/lsaauth/cyglsa.c
winsup/lsaauth/cyglsa64.dll
winsup/lsaauth/make-64bit-version-with-mingw-w64.sh
winsup/mingw/ChangeLog
winsup/mingw/configure
winsup/mingw/configure.in
winsup/mingw/include/_mingw.h
winsup/mingw/include/excpt.h
winsup/mingw/include/inttypes.h
winsup/mingw/include/limits.h
winsup/mingw/include/process.h
winsup/mingw/include/stdint.h
winsup/mingw/include/stdio.h
winsup/mingw/include/stdlib.h
winsup/mingw/include/sys/param.h
winsup/mingw/include/wchar.h
winsup/mingw/mingwex/Makefile.in
winsup/mingw/mingwex/gdtoa/gd_qnan.h
winsup/mingw/mingwex/tsearch.c
winsup/mingw/profile/Makefile.in
winsup/testsuite/ChangeLog
winsup/testsuite/configure
winsup/utils/ChangeLog
winsup/utils/Makefile.in
winsup/utils/bloda.cc
winsup/utils/cygcheck.cc
winsup/utils/cygpath.cc
winsup/utils/dump_setup.cc
winsup/utils/dumper.cc
winsup/utils/locale.cc
winsup/utils/mkgroup.c
winsup/utils/mkpasswd.c
winsup/utils/ps.cc
winsup/utils/regtool.cc
winsup/utils/strace.cc
winsup/w32api/ChangeLog
winsup/w32api/include/routprot.h
winsup/w32api/include/setupapi.h
winsup/w32api/include/winbase.h
winsup/w32api/include/windows.h
winsup/w32api/include/winnt.h
winsup/w32api/include/winsock.h
winsup/w32api/include/winsock2.h
winsup/w32api/include/winuser.h
winsup/w32api/include/winver.h
winsup/w32api/include/wtsapi32.h
winsup/w32api/lib/Makefile.in
winsup/w32api/lib/kernel32.def
winsup/w32api/lib/wtsapi32.def
Delete:
config/asmcfi.m4
config/math.m4
config/mmap.m4
config/weakref.m4
include/dwarf2.def
include/elf/xgate.h
include/gdb/gdb-index.h
include/leb128.h
include/opcode/xgate.h
newlib/libc/string/memrchr.c
winsup/cygwin/DevNotes
winsup/cygwin/cygwait.cc
winsup/cygwin/cygwait.h
winsup/cygwin/fhandler_dev.cc
winsup/cygwin/include/machine/elf.h
winsup/cygwin/include/sys/elf.h
winsup/mingw/mingwex/membarrier.c
winsup/w32api/include/sdkddkver.h
winsup/w32api/include/shobjidl.h
winsup/w32api/lib/shobjidl-uuid.c
Diffstat (limited to 'newlib/libc/stdio')
45 files changed, 169 insertions, 293 deletions
diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c index 0c363d5ea..97474fd1a 100644 --- a/newlib/libc/stdio/asiprintf.c +++ b/newlib/libc/stdio/asiprintf.c @@ -45,7 +45,7 @@ _DEFUN(_asiprintf_r, (ptr, strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = (char *) f._bf._base; + *strp = f._bf._base; } return (ret); } @@ -72,7 +72,7 @@ _DEFUN(asiprintf, (strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = (char *) f._bf._base; + *strp = f._bf._base; } return (ret); } diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index 7b26d9f29..59a08c808 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -45,7 +45,7 @@ _DEFUN(_asprintf_r, (ptr, strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = (char *) f._bf._base; + *strp = f._bf._base; } return (ret); } @@ -72,7 +72,7 @@ _DEFUN(asprintf, (strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = (char *) f._bf._base; + *strp = f._bf._base; } return (ret); } diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c index ed4603ba2..d3b620bed 100644 --- a/newlib/libc/stdio/clearerr.c +++ b/newlib/libc/stdio/clearerr.c @@ -65,7 +65,7 @@ _DEFUN(clearerr, (fp), FILE * fp) { CHECK_INIT(_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); __sclearerr (fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); } diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c index 790496413..3c8868a51 100644 --- a/newlib/libc/stdio/fclose.c +++ b/newlib/libc/stdio/fclose.c @@ -76,20 +76,11 @@ _DEFUN(_fclose_r, (rptr, fp), CHECK_INIT (rptr, fp); - /* We can't use the _newlib_flockfile_XXX macros here due to the - interlocked locking with the sfp_lock. */ -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) - int __oldcancel; - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); -#endif _flockfile (fp); if (fp->_flags == 0) /* not open! */ { _funlockfile (fp); -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) - pthread_setcancelstate (__oldcancel, &__oldcancel); -#endif return (0); } /* Unconditionally flush to allow special handling for seekable read @@ -112,9 +103,6 @@ _DEFUN(_fclose_r, (rptr, fp), #endif __sfp_lock_release (); -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) - pthread_setcancelstate (__oldcancel, &__oldcancel); -#endif return (r); } diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index 77f599b65..aa764c372 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -93,7 +93,7 @@ _DEFUN(_fdopen_r, (ptr, fd, mode), if ((fp = __sfp (ptr)) == 0) return 0; - _newlib_flockfile_start (fp); + _flockfile (fp); fp->_flags = flags; /* POSIX recommends setting the O_APPEND bit on fd to match append @@ -127,7 +127,7 @@ _DEFUN(_fdopen_r, (ptr, fd, mode), fp->_flags |= __SCLE; #endif - _newlib_flockfile_end (fp); + _funlockfile (fp); return fp; } diff --git a/newlib/libc/stdio/feof.c b/newlib/libc/stdio/feof.c index c0216ffed..e8db65b86 100644 --- a/newlib/libc/stdio/feof.c +++ b/newlib/libc/stdio/feof.c @@ -58,8 +58,8 @@ _DEFUN(feof, (fp), { int result; CHECK_INIT(_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sfeof (fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c index 0cd3c3089..72b7ce2c5 100644 --- a/newlib/libc/stdio/ferror.c +++ b/newlib/libc/stdio/ferror.c @@ -67,8 +67,8 @@ _DEFUN(ferror, (fp), { int result; CHECK_INIT(_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sferror (fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index b2bde7af5..130c148c9 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -226,9 +226,9 @@ _DEFUN(_fflush_r, (ptr, fp), if (!fp->_flags) return 0; - _newlib_flockfile_start (fp); + _flockfile (fp); ret = __sflush_r (ptr, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return ret; } diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c index 99d8330fe..e275cfeeb 100644 --- a/newlib/libc/stdio/fgetc.c +++ b/newlib/libc/stdio/fgetc.c @@ -78,9 +78,9 @@ _DEFUN(_fgetc_r, (ptr, fp), { int result; CHECK_INIT(ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sgetc_r (ptr, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; } @@ -93,9 +93,9 @@ _DEFUN(fgetc, (fp), #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) int result; CHECK_INIT(_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sgetc_r (_REENT, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; #else return _fgetc_r (_REENT, fp); diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c index 1644fba6a..7f02e3fcb 100644 --- a/newlib/libc/stdio/fgets.c +++ b/newlib/libc/stdio/fgets.c @@ -98,7 +98,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp), CHECK_INIT(ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); #ifdef __SCLE if (fp->_flags & __SCLE) { @@ -112,11 +112,11 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp), } if (c == EOF && s == buf) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return NULL; } *s = 0; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return buf; } #endif @@ -134,7 +134,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp), /* EOF: stop with partial or no line */ if (s == buf) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return 0; } break; @@ -159,7 +159,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp), fp->_p = t; _CAST_VOID memcpy ((_PTR) s, (_PTR) p, len); s[len] = 0; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (buf); } fp->_r -= len; @@ -169,7 +169,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp), } while ((n -= len) != 0); *s = 0; - _newlib_flockfile_end (fp); + _funlockfile (fp); return buf; } diff --git a/newlib/libc/stdio/fgetwc.c b/newlib/libc/stdio/fgetwc.c index 0eaaecb2f..38a79bc7c 100644 --- a/newlib/libc/stdio/fgetwc.c +++ b/newlib/libc/stdio/fgetwc.c @@ -164,10 +164,10 @@ _DEFUN(_fgetwc_r, (ptr, fp), { wint_t r; - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT(fp, 1); r = __fgetwc (ptr, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return r; } diff --git a/newlib/libc/stdio/fgetws.c b/newlib/libc/stdio/fgetws.c index 3cf45a976..2784f1513 100644 --- a/newlib/libc/stdio/fgetws.c +++ b/newlib/libc/stdio/fgetws.c @@ -93,7 +93,7 @@ _DEFUN(_fgetws_r, (ptr, ws, n, fp), const char *src; unsigned char *nl; - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, 1); if (n <= 0) @@ -110,13 +110,9 @@ _DEFUN(_fgetws_r, (ptr, ws, n, fp), { src = (char *) fp->_p; nl = memchr (fp->_p, '\n', fp->_r); - nconv = _mbsnrtowcs_r (ptr, wsp, &src, - /* Read all bytes up to the next NL, or up to the - end of the buffer if there is no NL. */ - nl != NULL ? (nl - fp->_p + 1) : fp->_r, - /* But never more than n - 1 wide chars. */ - n - 1, - &fp->_mbstate); + nconv = _mbsrtowcs_r (ptr, wsp, &src, + nl != NULL ? (nl - fp->_p + 1) : fp->_r, + &fp->_mbstate); if (nconv == (size_t) -1) /* Conversion error */ goto error; @@ -146,11 +142,11 @@ _DEFUN(_fgetws_r, (ptr, ws, n, fp), /* Incomplete character */ goto error; *wsp++ = L'\0'; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return ws; error: - _newlib_flockfile_end (fp); + _funlockfile (fp); return NULL; } diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c index be8f3d66a..db399eb12 100644 --- a/newlib/libc/stdio/fileno.c +++ b/newlib/libc/stdio/fileno.c @@ -47,7 +47,6 @@ Supporting OS subroutines required: none. #include <_ansi.h> #include <stdio.h> -#include <errno.h> #include "local.h" int @@ -56,14 +55,8 @@ _DEFUN(fileno, (f), { int result; CHECK_INIT (_REENT, f); - _newlib_flockfile_start (f); - if (f->_flags) - result = __sfileno (f); - else - { - result = -1; - _REENT->_errno = EBADF; - } - _newlib_flockfile_end (f); + _flockfile (f); + result = __sfileno (f); + _funlockfile (f); return result; } diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 0beb1e5b0..570fd457e 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -108,7 +108,7 @@ _DEFUN(__sfp, (d), int n; struct _glue *g; - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); if (!_GLOBAL_REENT->__sdidinit) __sinit (_GLOBAL_REENT); @@ -121,7 +121,7 @@ _DEFUN(__sfp, (d), (g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL) break; } - _newlib_sfp_lock_exit (); + __sfp_lock_release (); d->_errno = ENOMEM; return NULL; @@ -132,7 +132,7 @@ found: #ifndef __SINGLE_THREAD__ __lock_init_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); fp->_p = NULL; /* no current pointer */ fp->_w = 0; /* nothing to read or write */ @@ -192,6 +192,7 @@ _DEFUN(__sinit, (s), /* make sure we clean up on exit */ s->__cleanup = _cleanup_r; /* conservative */ + s->__sdidinit = 1; s->__sglue._next = NULL; #ifndef _REENT_SMALL @@ -200,11 +201,6 @@ _DEFUN(__sinit, (s), #else s->__sglue._niobs = 0; s->__sglue._iobs = NULL; - /* Avoid infinite recursion when calling __sfp for _GLOBAL_REENT. The - problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls - __sinit if it's 0. */ - if (s == _GLOBAL_REENT) - s->__sdidinit = 1; s->_stdin = __sfp(s); s->_stdout = __sfp(s); s->_stderr = __sfp(s); @@ -228,8 +224,6 @@ _DEFUN(__sinit, (s), when the underlying fd 2 is write-only. */ std (s->_stderr, __SRW | __SNBF, 2, s); - s->__sdidinit = 1; - __sinit_lock_release (); } diff --git a/newlib/libc/stdio/fmemopen.c b/newlib/libc/stdio/fmemopen.c index acfb23c1b..5218e8a98 100644 --- a/newlib/libc/stdio/fmemopen.c +++ b/newlib/libc/stdio/fmemopen.c @@ -291,12 +291,12 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode), if ((c = (fmemcookie *) _malloc_r (ptr, sizeof *c + (buf ? 0 : size))) == NULL) { - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); fp->_flags = 0; /* release */ #ifndef __SINGLE_THREAD__ __lock_close_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); return NULL; } @@ -343,7 +343,7 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode), } } - _newlib_flockfile_start (fp); + _flockfile (fp); fp->_file = -1; fp->_flags = flags; fp->_cookie = c; @@ -355,7 +355,7 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode), fp->_flags |= __SL64; #endif fp->_close = fmemcloser; - _newlib_flockfile_end (fp); + _funlockfile (fp); return fp; } diff --git a/newlib/libc/stdio/fopen.c b/newlib/libc/stdio/fopen.c index 27d4bc810..64c24e7ef 100644 --- a/newlib/libc/stdio/fopen.c +++ b/newlib/libc/stdio/fopen.c @@ -140,16 +140,16 @@ _DEFUN(_fopen_r, (ptr, file, mode), if ((f = _open_r (ptr, file, oflags, 0666)) < 0) { - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); fp->_flags = 0; /* release */ #ifndef __SINGLE_THREAD__ __lock_close_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); return NULL; } - _newlib_flockfile_start (fp); + _flockfile (fp); fp->_file = f; fp->_flags = flags; @@ -167,7 +167,7 @@ _DEFUN(_fopen_r, (ptr, file, mode), fp->_flags |= __SCLE; #endif - _newlib_flockfile_end (fp); + _funlockfile (fp); return fp; } diff --git a/newlib/libc/stdio/fopencookie.c b/newlib/libc/stdio/fopencookie.c index f08d13289..5148c8a1a 100644 --- a/newlib/libc/stdio/fopencookie.c +++ b/newlib/libc/stdio/fopencookie.c @@ -219,16 +219,16 @@ _DEFUN(_fopencookie_r, (ptr, cookie, mode, functions), return NULL; if ((c = (fccookie *) _malloc_r (ptr, sizeof *c)) == NULL) { - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); fp->_flags = 0; /* release */ #ifndef __SINGLE_THREAD__ __lock_close_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); return NULL; } - _newlib_flockfile_start (fp); + _flockfile (fp); fp->_file = -1; fp->_flags = flags; c->cookie = cookie; @@ -246,7 +246,7 @@ _DEFUN(_fopencookie_r, (ptr, cookie, mode, functions), #endif c->closefn = functions.close; fp->_close = fccloser; - _newlib_flockfile_end (fp); + _funlockfile (fp); return fp; } diff --git a/newlib/libc/stdio/fpurge.c b/newlib/libc/stdio/fpurge.c index dc052e85b..7e23bb7fd 100644 --- a/newlib/libc/stdio/fpurge.c +++ b/newlib/libc/stdio/fpurge.c @@ -68,13 +68,13 @@ _DEFUN(_fpurge_r, (ptr, fp), CHECK_INIT (ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); t = fp->_flags; if (!t) { ptr->_errno = EBADF; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } fp->_p = fp->_bf._base; @@ -86,7 +86,7 @@ _DEFUN(_fpurge_r, (ptr, fp), } else fp->_w = t & (__SLBF | __SNBF) ? 0 : fp->_bf._size; - _newlib_flockfile_end (fp); + _funlockfile (fp); return 0; } diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c index 6af79d470..777a34242 100644 --- a/newlib/libc/stdio/fputc.c +++ b/newlib/libc/stdio/fputc.c @@ -83,9 +83,9 @@ _DEFUN(_fputc_r, (ptr, ch, file), { int result; CHECK_INIT(ptr, file); - _newlib_flockfile_start (file); + _flockfile (file); result = _putc_r (ptr, ch, file); - _newlib_flockfile_end (file); + _funlockfile (file); return result; } @@ -98,9 +98,9 @@ _DEFUN(fputc, (ch, file), #if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED) int result; CHECK_INIT(_REENT, file); - _newlib_flockfile_start (file); + _flockfile (file); result = _putc_r (_REENT, ch, file); - _newlib_flockfile_end (file); + _funlockfile (file); return result; #else return _fputc_r (_REENT, ch, file); diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c index 6e623a530..a32dea4e2 100644 --- a/newlib/libc/stdio/fputs.c +++ b/newlib/libc/stdio/fputs.c @@ -88,10 +88,10 @@ _DEFUN(_fputs_r, (ptr, s, fp), CHECK_INIT(ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, -1); result = __sfvwrite_r (ptr, fp, &uio); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/fputwc.c b/newlib/libc/stdio/fputwc.c index 74e7a452c..f32d56675 100644 --- a/newlib/libc/stdio/fputwc.c +++ b/newlib/libc/stdio/fputwc.c @@ -160,10 +160,10 @@ _DEFUN(_fputwc_r, (ptr, wc, fp), { wint_t r; - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT(fp, 1); r = __fputwc(ptr, wc, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return r; } diff --git a/newlib/libc/stdio/fputws.c b/newlib/libc/stdio/fputws.c index c88111cb0..b8e5d1e0b 100644 --- a/newlib/libc/stdio/fputws.c +++ b/newlib/libc/stdio/fputws.c @@ -87,7 +87,7 @@ _DEFUN(_fputws_r, (ptr, ws, fp), struct __suio uio; struct __siov iov; - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, 1); if (cantwrite (ptr, fp) != 0) goto error; @@ -104,11 +104,11 @@ _DEFUN(_fputws_r, (ptr, ws, fp), goto error; } while (ws != NULL); - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (0); error: - _newlib_flockfile_end(fp); + _funlockfile(fp); return (-1); } diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c index 07fe0af5c..a39e9d85f 100644 --- a/newlib/libc/stdio/fread.c +++ b/newlib/libc/stdio/fread.c @@ -146,7 +146,7 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), CHECK_INIT(ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, -1); if (fp->_r < 0) fp->_r = 0; @@ -195,11 +195,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), #ifdef __SCLE if (fp->_flags & __SCLE) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return crlf_r (ptr, fp, buf, total-resid, 1) / size; } #endif - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (total - resid) / size; } } @@ -220,11 +220,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), #ifdef __SCLE if (fp->_flags & __SCLE) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return crlf_r (ptr, fp, buf, total-resid, 1) / size; } #endif - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (total - resid) / size; } } @@ -237,11 +237,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), #ifdef __SCLE if (fp->_flags & __SCLE) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return crlf_r(ptr, fp, buf, total, 0) / size; } #endif - _newlib_flockfile_end (fp); + _funlockfile (fp); return count; } diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index b33eb1e22..172006259 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -100,20 +100,11 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), CHECK_INIT (ptr, fp); - /* We can't use the _newlib_flockfile_XXX macros here due to the - interlocked locking with the sfp_lock. */ -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) - int __oldcancel; - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel); -#endif _flockfile (fp); if ((flags = __sflags (ptr, mode, &oflags)) == 0) { _funlockfile (fp); -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) - pthread_setcancelstate (__oldcancel, &__oldcancel); -#endif _fclose_r (ptr, fp); return NULL; } @@ -208,7 +199,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), if (HASLB (fp)) FREELB (ptr, fp); fp->_lb._size = 0; - fp->_flags &= ~__SORD; + fp->_flags & ~__SORD; fp->_flags2 = 0; memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); @@ -222,9 +213,6 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), __lock_close_recursive (fp->_lock); #endif __sfp_lock_release (); -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) - pthread_setcancelstate (__oldcancel, &__oldcancel); -#endif return NULL; } @@ -242,9 +230,6 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), #endif _funlockfile (fp); -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) - pthread_setcancelstate (__oldcancel, &__oldcancel); -#endif return fp; } diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 099a95892..c78d2b26c 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -138,7 +138,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), CHECK_INIT (ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); /* If we've been doing some writing, and we're in append mode then we don't really know where the filepos is. */ @@ -154,7 +154,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), if ((seekfn = fp->_seek) == NULL) { ptr->_errno = ESPIPE; /* ??? */ - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } @@ -179,7 +179,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), curoff = seekfn (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR); if (curoff == -1L) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } } @@ -204,7 +204,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), default: ptr->_errno = EINVAL; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (EOF); } @@ -263,7 +263,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), if ((long)target != target) { ptr->_errno = EOVERFLOW; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } @@ -319,7 +319,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), FREEUB (ptr, fp); fp->_flags &= ~__SEOF; memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); - _newlib_flockfile_exit (fp); + _funlockfile (fp); return 0; } @@ -349,7 +349,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence), fp->_r -= n; } memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); - _newlib_flockfile_exit (fp); + _funlockfile (fp); return 0; /* @@ -361,7 +361,7 @@ dumb: if (_fflush_r (ptr, fp) || seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } /* success: clear EOF indicator and discard ungetc() data */ @@ -379,7 +379,7 @@ dumb: is performed. */ fp->_flags &= ~__SNPT; memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); - _newlib_flockfile_end (fp); + _funlockfile (fp); return 0; } diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index 54a656c09..816cafa76 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -109,12 +109,12 @@ _DEFUN(_ftell_r, (ptr, fp), CHECK_INIT (ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); if (fp->_seek == NULL) { ptr->_errno = ESPIPE; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return -1L; } @@ -131,7 +131,7 @@ _DEFUN(_ftell_r, (ptr, fp), pos = fp->_seek (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR); if (pos == -1L) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return pos; } } @@ -156,7 +156,7 @@ _DEFUN(_ftell_r, (ptr, fp), pos += fp->_p - fp->_bf._base; } - _newlib_flockfile_end (fp); + _funlockfile (fp); if ((long)pos != pos) { pos = -1; diff --git a/newlib/libc/stdio/funopen.c b/newlib/libc/stdio/funopen.c index 065ed93d7..35a274f7b 100644 --- a/newlib/libc/stdio/funopen.c +++ b/newlib/libc/stdio/funopen.c @@ -214,16 +214,16 @@ _DEFUN(_funopen_r, (ptr, cookie, readfn, writefn, seekfn, closefn), return NULL; if ((c = (funcookie *) _malloc_r (ptr, sizeof *c)) == NULL) { - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); fp->_flags = 0; /* release */ #ifndef __SINGLE_THREAD__ __lock_close_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); return NULL; } - _newlib_flockfile_start (fp); + _flockfile (fp); fp->_file = -1; c->cookie = (void *) cookie; /* cast away const */ fp->_cookie = c; @@ -260,7 +260,7 @@ _DEFUN(_funopen_r, (ptr, cookie, readfn, writefn, seekfn, closefn), #endif c->closefn = closefn; fp->_close = funcloser; - _newlib_flockfile_end (fp); + _funlockfile (fp); return fp; } diff --git a/newlib/libc/stdio/fwide.c b/newlib/libc/stdio/fwide.c index a060d8f65..e298f911a 100644 --- a/newlib/libc/stdio/fwide.c +++ b/newlib/libc/stdio/fwide.c @@ -68,7 +68,7 @@ _DEFUN(_fwide_r, (ptr, fp, mode), CHECK_INIT(ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); if (mode != 0) { ORIENT (fp, mode); } @@ -76,7 +76,7 @@ _DEFUN(_fwide_r, (ptr, fp, mode), ret = 0; else ret = (fp->_flags2 & __SWID) ? 1 : -1; - _newlib_flockfile_end (fp); + _funlockfile (fp); return ret; } diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c index dc218050e..ce77c8dc1 100644 --- a/newlib/libc/stdio/fwrite.c +++ b/newlib/libc/stdio/fwrite.c @@ -119,14 +119,14 @@ _DEFUN(_fwrite_r, (ptr, buf, size, count, fp), CHECK_INIT(ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, -1); if (__sfvwrite_r (ptr, fp, &uio) == 0) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return count; } - _newlib_flockfile_end (fp); + _funlockfile (fp); return (n - uio.uio_resid) / size; } diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c index 355b19131..5b1fa888a 100644 --- a/newlib/libc/stdio/getc.c +++ b/newlib/libc/stdio/getc.c @@ -92,9 +92,9 @@ _DEFUN(_getc_r, (ptr, fp), { int result; CHECK_INIT (ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sgetc_r (ptr, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; } @@ -106,9 +106,9 @@ _DEFUN(getc, (fp), { int result; CHECK_INIT (_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sgetc_r (_REENT, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c index 63a579a79..23fc50218 100644 --- a/newlib/libc/stdio/getdelim.c +++ b/newlib/libc/stdio/getdelim.c @@ -81,7 +81,7 @@ _DEFUN(__getdelim, (bufptr, n, delim, fp), CHECK_INIT (_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); numbytes = *n; ptr = buf; @@ -129,7 +129,7 @@ _DEFUN(__getdelim, (bufptr, n, delim, fp), } } - _newlib_flockfile_end (fp); + _funlockfile (fp); /* if no input data, return failure */ if (ptr == buf) diff --git a/newlib/libc/stdio/gets.c b/newlib/libc/stdio/gets.c index f51d46196..17d144316 100644 --- a/newlib/libc/stdio/gets.c +++ b/newlib/libc/stdio/gets.c @@ -70,7 +70,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <_ansi.h> #include <reent.h> #include <stdio.h> -#include "local.h" char * _DEFUN(_gets_r, (ptr, buf), @@ -80,12 +79,12 @@ _DEFUN(_gets_r, (ptr, buf), register int c; register char *s = buf; - _newlib_flockfile_start (stdin); + _flockfile (stdin); while ((c = __sgetc_r (ptr, stdin)) != '\n') if (c == EOF) if (s == buf) { - _newlib_flockfile_exit (stdin); + _funlockfile (stdin); return NULL; } else @@ -93,7 +92,7 @@ _DEFUN(_gets_r, (ptr, buf), else *s++ = c; *s = 0; - _newlib_flockfile_end (stdin); + _funlockfile (stdin); return buf; } diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index b4bc5e01a..187f7d858 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -32,83 +32,6 @@ # include <io.h> #endif -/* The following macros are supposed to replace calls to _flockfile/_funlockfile - and __sfp_lock_acquire/__sfp_lock_release. In case of multi-threaded - environments using pthreads, it's not sufficient to lock the stdio functions - against concurrent threads accessing the same data, the locking must also be - secured against thread cancellation. - - The below macros have to be used in pairs. The _newlib_XXX_start macro - starts with a opening curly brace, the _newlib_XXX_end macro ends with a - closing curly brace, so the start macro and the end macro mark the code - start and end of a critical section. In case the code leaves the critical - section before reaching the end of the critical section's code end, use - the appropriate _newlib_XXX_exit macro. */ - -#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) -#include <pthread.h> - -/* Start a stream oriented critical section: */ -# define _newlib_flockfile_start(_fp) \ - { \ - int __oldfpcancel; \ - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldfpcancel); \ - _flockfile (_fp) - -/* Exit from a stream oriented critical section prematurely: */ -# define _newlib_flockfile_exit(_fp) \ - _funlockfile (_fp); \ - pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); - -/* End a stream oriented critical section: */ -# define _newlib_flockfile_end(_fp) \ - _funlockfile (_fp); \ - pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); \ - } - -/* Start a stream list oriented critical section: */ -# define _newlib_sfp_lock_start() \ - { \ - int __oldsfpcancel; \ - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldsfpcancel); \ - __sfp_lock_acquire () - -/* Exit from a stream list oriented critical section prematurely: */ -# define _newlib_sfp_lock_exit() \ - __sfp_lock_release (); \ - pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); - -/* End a stream list oriented critical section: */ -# define _newlib_sfp_lock_end() \ - __sfp_lock_release (); \ - pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \ - } - -#else /* __SINGLE_THREAD__ || !_POSIX_THREADS */ - -# define _newlib_flockfile_start(_fp) \ - { \ - _flockfile(_fp) - -# define _newlib_flockfile_exit(_fp) \ - _funlockfile(_fp); \ - -# define _newlib_flockfile_end(_fp) \ - _funlockfile(_fp); \ - } - -# define _newlib_sfp_lock_start() \ - { \ - __sfp_lock_acquire () - -# define _newlib_sfp_lock_exit() \ - __sfp_lock_release (); - -# define _newlib_sfp_lock_end() \ - __sfp_lock_release (); \ - } - -#endif /* !__SINGLE_THREAD__ && _POSIX_THREADS */ extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c index ecbc7afea..1c5d76db4 100644 --- a/newlib/libc/stdio/mktemp.c +++ b/newlib/libc/stdio/mktemp.c @@ -247,7 +247,7 @@ _DEFUN(_gettemp, (ptr, path, doopen, domkdir, suffixlen, flags), else { /* Safe, since it only encounters 7-bit characters. */ - if (isdigit ((unsigned char) *trv)) + if (isdigit (*trv)) *trv = 'a'; else ++ * trv; diff --git a/newlib/libc/stdio/open_memstream.c b/newlib/libc/stdio/open_memstream.c index 0b58720a1..a53bdef2f 100644 --- a/newlib/libc/stdio/open_memstream.c +++ b/newlib/libc/stdio/open_memstream.c @@ -313,12 +313,12 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide), return NULL; if ((c = (memstream *) _malloc_r (ptr, sizeof *c)) == NULL) { - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); fp->_flags = 0; /* release */ #ifndef __SINGLE_THREAD__ __lock_close_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); return NULL; } /* Use *size as a hint for initial sizing, but bound the initial @@ -338,12 +338,12 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide), *buf = _malloc_r (ptr, c->max); if (!*buf) { - _newlib_sfp_lock_start (); + __sfp_lock_acquire (); fp->_flags = 0; /* release */ #ifndef __SINGLE_THREAD__ __lock_close_recursive (fp->_lock); #endif - _newlib_sfp_lock_end (); + __sfp_lock_release (); _free_r (ptr, c); return NULL; } @@ -359,7 +359,7 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide), c->saved.w = L'\0'; c->wide = (int8_t) wide; - _newlib_flockfile_start (fp); + _flockfile (fp); fp->_file = -1; fp->_flags = __SWR; fp->_cookie = c; @@ -372,7 +372,7 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide), #endif fp->_close = memcloser; ORIENT (fp, wide); - _newlib_flockfile_end (fp); + _funlockfile (fp); return fp; } diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c index 1115bf40d..667324d9d 100644 --- a/newlib/libc/stdio/putc.c +++ b/newlib/libc/stdio/putc.c @@ -97,9 +97,9 @@ _DEFUN(_putc_r, (ptr, c, fp), { int result; CHECK_INIT (ptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sputc_r (ptr, c, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; } @@ -112,9 +112,9 @@ _DEFUN(putc, (c, fp), #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) int result; CHECK_INIT (_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); result = __sputc_r (_REENT, c, fp); - _newlib_flockfile_end (fp); + _funlockfile (fp); return result; #else return _putc_r (_REENT, c, fp); diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c index 63f1f80db..583a081f4 100644 --- a/newlib/libc/stdio/setvbuf.c +++ b/newlib/libc/stdio/setvbuf.c @@ -106,7 +106,7 @@ _DEFUN(setvbuf, (fp, buf, mode, size), CHECK_INIT (_REENT, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); /* * Verify arguments. The `int' limit on `size' is due to this @@ -115,7 +115,7 @@ _DEFUN(setvbuf, (fp, buf, mode, size), if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (EOF); } @@ -158,7 +158,7 @@ nbf: fp->_w = 0; fp->_bf._base = fp->_p = fp->_nbuf; fp->_bf._size = 1; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (ret); } fp->_flags |= __SMBF; @@ -193,6 +193,6 @@ nbf: if (fp->_flags & __SWR) fp->_w = fp->_flags & (__SLBF | __SNBF) ? 0 : size; - _newlib_flockfile_end (fp); + _funlockfile (fp); return 0; } diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c index e385ce8fb..0339a3d0c 100644 --- a/newlib/libc/stdio/ungetc.c +++ b/newlib/libc/stdio/ungetc.c @@ -125,7 +125,7 @@ _DEFUN(_ungetc_r, (rptr, c, fp), CHECK_INIT (rptr, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, -1); @@ -140,14 +140,14 @@ _DEFUN(_ungetc_r, (rptr, c, fp), */ if ((fp->_flags & __SRW) == 0) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } if (fp->_flags & __SWR) { if (_fflush_r (rptr, fp)) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } fp->_flags &= ~__SWR; @@ -167,12 +167,12 @@ _DEFUN(_ungetc_r, (rptr, c, fp), { if (fp->_r >= fp->_ub._size && __submore (rptr, fp)) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; } *--fp->_p = c; fp->_r++; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return c; } @@ -186,7 +186,7 @@ _DEFUN(_ungetc_r, (rptr, c, fp), { fp->_p--; fp->_r++; - _newlib_flockfile_exit (fp); + _funlockfile (fp); return c; } @@ -202,7 +202,7 @@ _DEFUN(_ungetc_r, (rptr, c, fp), fp->_ubuf[sizeof (fp->_ubuf) - 1] = c; fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1]; fp->_r = 1; - _newlib_flockfile_end (fp); + _funlockfile (fp); return c; } diff --git a/newlib/libc/stdio/ungetwc.c b/newlib/libc/stdio/ungetwc.c index ee0d7fc75..234d2f7ef 100644 --- a/newlib/libc/stdio/ungetwc.c +++ b/newlib/libc/stdio/ungetwc.c @@ -82,7 +82,7 @@ _DEFUN(_ungetwc_r, (ptr, wc, fp), char buf[MB_LEN_MAX]; size_t len; - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, 1); if (wc == WEOF) wc = WEOF; @@ -98,7 +98,7 @@ _DEFUN(_ungetwc_r, (ptr, wc, fp), wc = WEOF; break; } - _newlib_flockfile_end (fp); + _funlockfile (fp); return wc; } diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c index f96de0d79..15310cce9 100644 --- a/newlib/libc/stdio/vasiprintf.c +++ b/newlib/libc/stdio/vasiprintf.c @@ -59,7 +59,7 @@ _DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap), if (ret >= 0) { *f._p = 0; - *strp = (char *) f._bf._base; + *strp = f._bf._base; } return ret; } diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index fbb54cbe8..b89f4dbd7 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -59,7 +59,7 @@ _DEFUN(_vasprintf_r, (ptr, strp, fmt, ap), if (ret >= 0) { *f._p = 0; - *strp = (char *) f._bf._base; + *strp = f._bf._base; } return ret; } diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 4b165e021..e3fc099d3 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -567,9 +567,9 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), char sign; /* sign prefix (' ', '+', '-', or \0) */ #ifdef _WANT_IO_C99_FORMATS /* locale specific numeric grouping */ - char *thousands_sep = NULL; - size_t thsnd_len = 0; - const char *grouping = NULL; + char *thousands_sep; + size_t thsnd_len; + const char *grouping; #endif #ifdef FLOATING_POINT char *decimal_point = _localeconv_r (data)->decimal_point; @@ -585,7 +585,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), #if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) int ndig = 0; /* actual number of digits returned by cvt */ #endif -#if defined (FLOATING_POINT) && defined (_WANT_IO_C99_FORMATS) +#ifdef _WANT_IO_C99_FORMATS int nseps; /* number of group separators with ' */ int nrepeats; /* number of repeats of the last group */ #endif @@ -708,20 +708,20 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), #ifndef STRING_ONLY /* Initialize std streams if not dealing with sprintf family. */ CHECK_INIT (data, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT(fp, -1); /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ if (cantwrite (data, fp)) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (EOF); } /* optimise fprintf(stderr) (and other unbuffered Unix files) */ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && fp->_file >= 0) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (__sbprintf (data, fp, fmt0, ap)); } #else /* STRING_ONLY */ @@ -793,10 +793,10 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), sign = '\0'; #ifdef FLOATING_POINT lead = 0; +#endif #ifdef _WANT_IO_C99_FORMATS nseps = nrepeats = 0; #endif -#endif #ifndef _NO_POS_ARGS N = arg_index; is_pos_arg = 0; @@ -1633,7 +1633,7 @@ error: if (malloc_buf != NULL) _free_r (data, malloc_buf); #ifndef STRING_ONLY - _newlib_flockfile_end (fp); + _funlockfile (fp); #endif return (__sferror (fp) ? EOF : ret); /* NOTREACHED */ diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index e967719b7..32a132a93 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -148,12 +148,10 @@ Supporting OS subroutines required: #endif #ifdef STRING_ONLY -#undef _newlib_flockfile_start -#undef _newlib_flockfile_exit -#undef _newlib_flockfile_end -#define _newlib_flockfile_start(x) {} -#define _newlib_flockfile_exit(x) {} -#define _newlib_flockfile_end(x) {} +#undef _flockfile +#undef _funlockfile +#define _flockfile(x) {} +#define _funlockfile(x) {} #define _ungetc_r _sungetc_r #define __srefill_r __ssrefill_r #define _fread_r _sfread_r @@ -243,7 +241,10 @@ static void * get_arg (int, va_list *, int *, void **); #define CT_INT 3 /* integer, i.e., strtol or strtoul */ #define CT_FLOAT 4 /* floating, i.e., strtod */ +#if 0 #define u_char unsigned char +#endif +#define u_char char #define u_long unsigned long #ifndef _NO_LONGLONG @@ -495,7 +496,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), # define GET_ARG(n, ap, type) (va_arg (ap, type)) #endif - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, -1); @@ -510,8 +511,8 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), #ifndef _MB_CAPABLE wc = *fmt; #else - nbytes = __mbtowc (rptr, &wc, (char *) fmt, MB_CUR_MAX, - __locale_charset (), &state); + nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (), + &state); if (nbytes < 0) { wc = 0xFFFD; /* Unicode replacement character */ nbytes = 1; @@ -794,7 +795,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), * Disgusting backwards compatibility hacks. XXX */ case '\0': /* compat */ - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; default: /* compat */ @@ -1594,12 +1595,12 @@ input_failure: should have been set prior to here. On EOF failure (including invalid format string), return EOF if no matches yet, else number of matches made prior to failure. */ - _newlib_flockfile_exit (fp); + _funlockfile (fp); return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF; match_failure: all_done: /* Return number of matches, which can be 0 on match failure. */ - _newlib_flockfile_end (fp); + _funlockfile (fp); return nassigned; } diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c index 968c218b5..d76fff0d6 100644 --- a/newlib/libc/stdio/vfwprintf.c +++ b/newlib/libc/stdio/vfwprintf.c @@ -396,11 +396,10 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), wchar_t sign; /* sign prefix (' ', '+', '-', or \0) */ #ifdef _WANT_IO_C99_FORMATS /* locale specific numeric grouping */ - wchar_t thousands_sep = L'\0'; - const char *grouping = NULL; + wchar_t thousands_sep; + const char *grouping; #endif -#if defined (_MB_CAPABLE) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) \ - && (defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS)) +#ifdef _MB_CAPABLE mbstate_t state; /* mbtowc calls from library must not change state */ #endif #ifdef FLOATING_POINT @@ -416,7 +415,7 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), #if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) int ndig = 0; /* actual number of digits returned by cvt */ #endif -#if defined (FLOATING_POINT) && defined (_WANT_IO_C99_FORMATS) +#ifdef _WANT_IO_C99_FORMATS int nseps; /* number of group separators with ' */ int nrepeats; /* number of repeats of the last group */ #endif @@ -554,20 +553,20 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), #ifndef STRING_ONLY /* Initialize std streams if not dealing with sprintf family. */ CHECK_INIT (data, fp); - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT(fp, 1); /* sorry, fwprintf(read_only_file, "") returns EOF, not 0 */ if (cantwrite (data, fp)) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (EOF); } /* optimise fwprintf(stderr) (and other unbuffered Unix files) */ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && fp->_file >= 0) { - _newlib_flockfile_exit (fp); + _funlockfile (fp); return (__sbwprintf (data, fp, fmt0, ap)); } #else /* STRING_ONLY */ @@ -620,10 +619,10 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), sign = L'\0'; #ifdef FLOATING_POINT lead = 0; +#endif #ifdef _WANT_IO_C99_FORMATS nseps = nrepeats = 0; #endif -#endif #ifndef _NO_POS_ARGS N = arg_index; is_pos_arg = 0; @@ -1466,7 +1465,7 @@ error: if (malloc_buf != NULL) _free_r (data, malloc_buf); #ifndef STRING_ONLY - _newlib_flockfile_end (fp); + _funlockfile (fp); #endif return (__sferror (fp) ? EOF : ret); /* NOTREACHED */ diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c index 5d2388df8..49ccf2f4b 100644 --- a/newlib/libc/stdio/vfwscanf.c +++ b/newlib/libc/stdio/vfwscanf.c @@ -145,12 +145,10 @@ C99, POSIX-1.2008 #endif #ifdef STRING_ONLY -#undef _newlib_flockfile_start -#undef _newlib_flockfile_exit -#undef _newlib_flockfile_end -#define _newlib_flockfile_start(x) {} -#define _newlib_flockfile_exit(x) {} -#define _newlib_flockfile_end(x) {} +#undef _flockfile +#undef _funlockfile +#define _flockfile(x) {} +#define _funlockfile(x) {} #define _ungetwc_r _sungetwc_r #define __srefill_r __ssrefill_r #define _fgetwc_r _sfgetwc_r @@ -436,7 +434,7 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap), # define GET_ARG(n, ap, type) (va_arg (ap, type)) #endif - _newlib_flockfile_start (fp); + _flockfile (fp); ORIENT (fp, 1); @@ -714,7 +712,7 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap), * Disgusting backwards compatibility hacks. XXX */ case L'\0': /* compat */ - _newlib_flockfile_exit (fp); + _funlockfile (fp); return EOF; default: /* compat */ @@ -1442,12 +1440,12 @@ input_failure: should have been set prior to here. On EOF failure (including invalid format string), return EOF if no matches yet, else number of matches made prior to failure. */ - _newlib_flockfile_exit (fp); + _funlockfile (fp); return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF; match_failure: all_done: /* Return number of matches, which can be 0 on match failure. */ - _newlib_flockfile_end (fp); + _funlockfile (fp); return nassigned; } |