summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2014-12-18 14:55:21 +0000
committerYaakov Selkowitz <yselkowi@redhat.com>2014-12-18 14:55:21 +0000
commit968738f9b133c8bda7d5ced178fd92f4445d791c (patch)
tree667f72df8e0f4f52a48057450be0c1a4a5bb31b8
parent2a06c6dcc483361d5af4080e33825cb9d0138c82 (diff)
downloadcygnal-968738f9b133c8bda7d5ced178fd92f4445d791c.tar.gz
cygnal-968738f9b133c8bda7d5ced178fd92f4445d791c.tar.bz2
cygnal-968738f9b133c8bda7d5ced178fd92f4445d791c.zip
Implement BSD/GNU unlocked stdio extensions.
* libc/include/stdio.h (clearerr_unlocked, feof_unlocked, ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked, fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked, fwrite_unlocked): Declare. * libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked, fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked, putwc_unlocked, putwchar_unlocked): Declare. * libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c, feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c, fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c, fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c. Add necessary dependencies. * libc/stdio/Makefile.in: Regenerate. * libc/stdio/clearerr.c: Document unlocked variant. * libc/stdio/clearerr_u.c: New file. * libc/stdio/feof.c: Document unlocked variant. * libc/stdio/feof_u.c: New file. * libc/stdio/ferror.c: Document unlocked variant. * libc/stdio/ferror_u.c: New file. * libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides. Document unlocked variants. * libc/stdio/fflush_u.c: New file. * libc/stdio/fgetc.c: Document unlocked variants. * libc/stdio/fgetc_u.c: New file. * libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides. Document unlocked variants. * libc/stdio/fgets_u.c: New file. * libc/stdio/fgetwc.c: Document unlocked variants. (__fgetwc): Make non-static. * libc/stdio/fgetwc_u.c: New file. * libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides. Document unlocked variants. * libc/stdio/fgetws_u.c: New file. * libc/stdio/fileno.c: Document unlocked variant. * libc/stdio/fileno_u.c: New file. * libc/stdio/fputc.c: Document unlocked variants. * libc/stdio/fputc_u.c: New file. * libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides. Document unlocked variants. * libc/stdio/fputs_u.c: New file. * libc/stdio/fputwc.c: Document unlocked variants. (__fputwc): Make non-static. * libc/stdio/fputwc_u.c: New file. * libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides. Document unlocked variants. * libc/stdio/fputws_u.c: New file. * libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides. Document unlocked variants. * libc/stdio/fread_u.c: New file. * libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides. Document unlocked variants. * libc/stdio/fwrite_u.c: New file. * libc/stdio/getwc_u.c: New file. * libc/stdio/getwchar.c: Document unlocked variants. * libc/stdio/getwchar_u.c: New file. * libc/stdio/local.h: Define locking macros as empty ifdef __IMPL_UNLOCKED__. (__fgetwc, __fputwc): Declare. * libc/stdio/putwc_u.c: New file. * libc/stdio/putwchar.c: Document unlocked variants. * libc/stdio/putwchar_u.c: New file.
-rw-r--r--newlib/ChangeLog65
-rw-r--r--newlib/libc/include/stdio.h36
-rw-r--r--newlib/libc/include/wchar.h28
-rw-r--r--newlib/libc/stdio/Makefile.am45
-rw-r--r--newlib/libc/stdio/Makefile.in197
-rw-r--r--newlib/libc/stdio/clearerr.c23
-rw-r--r--newlib/libc/stdio/clearerr_u.c41
-rw-r--r--newlib/libc/stdio/feof.c24
-rw-r--r--newlib/libc/stdio/feof_u.c40
-rw-r--r--newlib/libc/stdio/ferror.c24
-rw-r--r--newlib/libc/stdio/ferror_u.c41
-rw-r--r--newlib/libc/stdio/fflush.c40
-rw-r--r--newlib/libc/stdio/fflush_u.c28
-rw-r--r--newlib/libc/stdio/fgetc.c42
-rw-r--r--newlib/libc/stdio/fgetc_u.c56
-rw-r--r--newlib/libc/stdio/fgets.c49
-rw-r--r--newlib/libc/stdio/fgets_u.c28
-rw-r--r--newlib/libc/stdio/fgetwc.c79
-rw-r--r--newlib/libc/stdio/fgetwc_u.c49
-rw-r--r--newlib/libc/stdio/fgetws.c51
-rw-r--r--newlib/libc/stdio/fgetws_u.c28
-rw-r--r--newlib/libc/stdio/fileno.c24
-rw-r--r--newlib/libc/stdio/fileno_u.c46
-rw-r--r--newlib/libc/stdio/fputc.c41
-rw-r--r--newlib/libc/stdio/fputc_u.c56
-rw-r--r--newlib/libc/stdio/fputs.c46
-rw-r--r--newlib/libc/stdio/fputs_u.c28
-rw-r--r--newlib/libc/stdio/fputwc.c83
-rw-r--r--newlib/libc/stdio/fputwc_u.c51
-rw-r--r--newlib/libc/stdio/fputws.c48
-rw-r--r--newlib/libc/stdio/fputws_u.c28
-rw-r--r--newlib/libc/stdio/fread.c51
-rw-r--r--newlib/libc/stdio/fread_u.c28
-rw-r--r--newlib/libc/stdio/fwrite.c51
-rw-r--r--newlib/libc/stdio/fwrite_u.c28
-rw-r--r--newlib/libc/stdio/getwc_u.c53
-rw-r--r--newlib/libc/stdio/getwchar.c41
-rw-r--r--newlib/libc/stdio/getwchar_u.c51
-rw-r--r--newlib/libc/stdio/local.h26
-rw-r--r--newlib/libc/stdio/putwc_u.c54
-rw-r--r--newlib/libc/stdio/putwchar.c41
-rw-r--r--newlib/libc/stdio/putwchar_u.c53
42 files changed, 1865 insertions, 77 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index fbb83c34a..d718c8ed6 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,68 @@
+2014-12-18 Yaakov Selkowitz <yselkowi@redhat.com>
+
+ Implement BSD/GNU unlocked stdio extensions.
+ * libc/include/stdio.h (clearerr_unlocked, feof_unlocked,
+ ferror_unlocked, fflush_unlocked, fgetc_unlocked, fgets_unlocked,
+ fileno_unlocked, fputc_unlocked, fputs_unlocked, fread_unlocked,
+ fwrite_unlocked): Declare.
+ * libc/include/wchar.h (fgetwc_unlocked, fgetws_unlocked,
+ fputwc_unlocked, fputws_unlocked, getwc_unlocked, getwchar_unlocked,
+ putwc_unlocked, putwchar_unlocked): Declare.
+ * libc/stdio/Makefile.am (ELIX_4_SOURCES): Add clearerr_u.c,
+ feof_u.c, ferror_u.c, fflush_u.c, fgetc_u.c, fgets_u.c, fgetwc_u.c,
+ fgetws_u.c, fileno_u.c, fputc_u.c, fputs_u.c, fputwc_u.c, fputws_u.c,
+ fread_u.c, fwrite_u.c, getwc_u.c, getwchar_u.c, putwc_u.c, putwchar_u.c.
+ Add necessary dependencies.
+ * libc/stdio/Makefile.in: Regenerate.
+ * libc/stdio/clearerr.c: Document unlocked variant.
+ * libc/stdio/clearerr_u.c: New file.
+ * libc/stdio/feof.c: Document unlocked variant.
+ * libc/stdio/feof_u.c: New file.
+ * libc/stdio/ferror.c: Document unlocked variant.
+ * libc/stdio/ferror_u.c: New file.
+ * libc/stdio/fflush.c: Add __IMPL_UNLOCKED__ overrides.
+ Document unlocked variants.
+ * libc/stdio/fflush_u.c: New file.
+ * libc/stdio/fgetc.c: Document unlocked variants.
+ * libc/stdio/fgetc_u.c: New file.
+ * libc/stdio/fgets.c: Add __IMPL_UNLOCKED__ overrides.
+ Document unlocked variants.
+ * libc/stdio/fgets_u.c: New file.
+ * libc/stdio/fgetwc.c: Document unlocked variants.
+ (__fgetwc): Make non-static.
+ * libc/stdio/fgetwc_u.c: New file.
+ * libc/stdio/fgetws.c: Add __IMPL_UNLOCKED__ overrides.
+ Document unlocked variants.
+ * libc/stdio/fgetws_u.c: New file.
+ * libc/stdio/fileno.c: Document unlocked variant.
+ * libc/stdio/fileno_u.c: New file.
+ * libc/stdio/fputc.c: Document unlocked variants.
+ * libc/stdio/fputc_u.c: New file.
+ * libc/stdio/fputs.c: Add __IMPL_UNLOCKED__ overrides.
+ Document unlocked variants.
+ * libc/stdio/fputs_u.c: New file.
+ * libc/stdio/fputwc.c: Document unlocked variants.
+ (__fputwc): Make non-static.
+ * libc/stdio/fputwc_u.c: New file.
+ * libc/stdio/fputws.c: Add __IMPL_UNLOCKED__ overrides.
+ Document unlocked variants.
+ * libc/stdio/fputws_u.c: New file.
+ * libc/stdio/fread.c: Add __IMPL_UNLOCKED__ overrides.
+ Document unlocked variants.
+ * libc/stdio/fread_u.c: New file.
+ * libc/stdio/fwrite.c: Add __IMPL_UNLOCKED__ overrides.
+ Document unlocked variants.
+ * libc/stdio/fwrite_u.c: New file.
+ * libc/stdio/getwc_u.c: New file.
+ * libc/stdio/getwchar.c: Document unlocked variants.
+ * libc/stdio/getwchar_u.c: New file.
+ * libc/stdio/local.h: Define locking macros as empty ifdef
+ __IMPL_UNLOCKED__.
+ (__fgetwc, __fputwc): Declare.
+ * libc/stdio/putwc_u.c: New file.
+ * libc/stdio/putwchar.c: Document unlocked variants.
+ * libc/stdio/putwchar_u.c: New file.
+
2014-12-18 Corinna Vinschen <vinschen@redhat.com>
* stdio.tex: Add menu entries for __fsetlocking and stdio_ext.
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index eb2d24939..e336ee6eb 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -371,7 +371,9 @@ int _EXFUN(_fcloseall_r, (struct _reent *));
FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *));
int _EXFUN(_fflush_r, (struct _reent *, FILE *));
int _EXFUN(_fgetc_r, (struct _reent *, FILE *));
+int _EXFUN(_fgetc_unlocked_r, (struct _reent *, FILE *));
char * _EXFUN(_fgets_r, (struct _reent *, char *__restrict, int, FILE *__restrict));
+char * _EXFUN(_fgets_unlocked_r, (struct _reent *, char *__restrict, int, FILE *__restrict));
#ifdef _COMPILING_NEWLIB
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *__restrict, _fpos_t *__restrict));
int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const _fpos_t *));
@@ -390,8 +392,11 @@ int _EXFUN(_fprintf_r, (struct _reent *, FILE *__restrict, const char *__restric
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
int _EXFUN(_fpurge_r, (struct _reent *, FILE *));
int _EXFUN(_fputc_r, (struct _reent *, int, FILE *));
+int _EXFUN(_fputc_unlocked_r, (struct _reent *, int, FILE *));
int _EXFUN(_fputs_r, (struct _reent *, const char *__restrict, FILE *__restrict));
+int _EXFUN(_fputs_unlocked_r, (struct _reent *, const char *__restrict, FILE *__restrict));
size_t _EXFUN(_fread_r, (struct _reent *, _PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
+size_t _EXFUN(_fread_unlocked_r, (struct _reent *, _PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
int _EXFUN(_fscanf_r, (struct _reent *, FILE *__restrict, const char *__restrict, ...)
_ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int));
@@ -400,6 +405,7 @@ long _EXFUN(_ftell_r, (struct _reent *, FILE *));
_off_t _EXFUN(_ftello_r,(struct _reent *, FILE *));
void _EXFUN(_rewind_r, (struct _reent *, FILE *));
size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
+size_t _EXFUN(_fwrite_unlocked_r, (struct _reent *, const _PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
int _EXFUN(_getc_r, (struct _reent *, FILE *));
int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *));
int _EXFUN(_getchar_r, (struct _reent *));
@@ -486,6 +492,23 @@ int _EXFUN(fpurge, (FILE *));
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *));
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
+#if __BSD_VISIBLE
+void _EXFUN(clearerr_unlocked, (FILE *));
+int _EXFUN(feof_unlocked, (FILE *));
+int _EXFUN(ferror_unlocked, (FILE *));
+int _EXFUN(fileno_unlocked, (FILE *));
+int _EXFUN(fflush_unlocked, (FILE *));
+int _EXFUN(fgetc_unlocked, (FILE *));
+int _EXFUN(fputc_unlocked, (int, FILE *));
+size_t _EXFUN(fread_unlocked, (_PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
+size_t _EXFUN(fwrite_unlocked, (const _PTR __restrict , size_t _size, size_t _n, FILE *));
+#endif
+
+#if __GNU_VISIBLE
+char * _EXFUN(fgets_unlocked, (char *__restrict, int, FILE *__restrict));
+int _EXFUN(fputs_unlocked, (const char *__restrict, FILE *__restrict));
+#endif
+
#ifdef __LARGE64_FILES
#if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB)
FILE * _EXFUN(fdopen64, (int, const char *));
@@ -659,7 +682,13 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define feof(p) __sfeof(p)
#define ferror(p) __sferror(p)
#define clearerr(p) __sclearerr(p)
-#endif
+
+#if __BSD_VISIBLE
+#define feof_unlocked(p) __sfeof(p)
+#define ferror_unlocked(p) __sferror(p)
+#define clearerr_unlocked(p) __sclearerr(p)
+#endif /* __BSD_VISIBLE */
+#endif /* _REENT_SMALL */
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
#define fileno(p) __sfileno(p)
@@ -688,6 +717,11 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define getchar() getc(stdin)
#define putchar(x) putc(x, stdout)
+#ifndef __STRICT_ANSI__
+#define getchar_unlocked() getc_unlocked(stdin)
+#define putchar_unlocked(x) putc_unlocked(x, stdout)
+#endif
+
_END_STD_C
#endif /* _STDIO_H_ */
diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h
index 4f9a60705..596cce698 100644
--- a/newlib/libc/include/wchar.h
+++ b/newlib/libc/include/wchar.h
@@ -16,7 +16,7 @@
/* For _mbstate_t definition. */
#include <sys/_types.h>
-
+#include <sys/cdefs.h>
/* For __STDC_ISO_10646__ */
#include <sys/features.h>
@@ -160,16 +160,35 @@ wint_t _EXFUN(putwchar, (wchar_t));
wint_t _EXFUN (ungetwc, (wint_t wc, __FILE *));
wint_t _EXFUN(_fgetwc_r, (struct _reent *, __FILE *));
+wint_t _EXFUN(_fgetwc_unlocked_r, (struct _reent *, __FILE *));
wchar_t *_EXFUN(_fgetws_r, (struct _reent *, wchar_t *, int, __FILE *));
+wchar_t *_EXFUN(_fgetws_unlocked_r, (struct _reent *, wchar_t *, int, __FILE *));
wint_t _EXFUN(_fputwc_r, (struct _reent *, wchar_t, __FILE *));
+wint_t _EXFUN(_fputwc_unlocked_r, (struct _reent *, wchar_t, __FILE *));
int _EXFUN(_fputws_r, (struct _reent *, const wchar_t *, __FILE *));
+int _EXFUN(_fputws_unlocked_r, (struct _reent *, const wchar_t *, __FILE *));
int _EXFUN (_fwide_r, (struct _reent *, __FILE *, int));
wint_t _EXFUN (_getwc_r, (struct _reent *, __FILE *));
+wint_t _EXFUN (_getwc_unlocked_r, (struct _reent *, __FILE *));
wint_t _EXFUN (_getwchar_r, (struct _reent *ptr));
+wint_t _EXFUN (_getwchar_unlocked_r, (struct _reent *ptr));
wint_t _EXFUN(_putwc_r, (struct _reent *, wchar_t, __FILE *));
+wint_t _EXFUN(_putwc_unlocked_r, (struct _reent *, wchar_t, __FILE *));
wint_t _EXFUN(_putwchar_r, (struct _reent *, wchar_t));
+wint_t _EXFUN(_putwchar_unlocked_r, (struct _reent *, wchar_t));
wint_t _EXFUN (_ungetwc_r, (struct _reent *, wint_t wc, __FILE *));
+#if __GNU_VISIBLE
+wint_t _EXFUN(fgetwc_unlocked, (__FILE *));
+wchar_t *_EXFUN(fgetws_unlocked, (wchar_t *__restrict, int, __FILE *__restrict));
+wint_t _EXFUN(fputwc_unlocked, (wchar_t, __FILE *));
+int _EXFUN(fputws_unlocked, (const wchar_t *__restrict, __FILE *__restrict));
+wint_t _EXFUN(getwc_unlocked, (__FILE *));
+wint_t _EXFUN(getwchar_unlocked, (void));
+wint_t _EXFUN(putwc_unlocked, (wchar_t, __FILE *));
+wint_t _EXFUN(putwchar_unlocked, (wchar_t));
+#endif
+
__FILE *_EXFUN (open_wmemstream, (wchar_t **, size_t *));
__FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *));
@@ -220,6 +239,13 @@ int _EXFUN(_wscanf_r, (struct _reent *, const wchar_t *, ...));
#define getwchar() fgetwc(_REENT->_stdin)
#define putwchar(wc) fputwc((wc), _REENT->_stdout)
+#if __GNU_VISIBLE
+#define getwc_unlocked(fp) fgetwc_unlocked(fp)
+#define putwc_unlocked(wc,fp) fputwc_unlocked((wc), (fp))
+#define getwchar_unlocked() fgetwc_unlocked(_REENT->_stdin)
+#define putwchar_unlocked(wc) fputwc_unlocked((wc), _REENT->_stdout)
+#endif
+
_END_STD_C
#endif /* _WCHAR_H_ */
diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am
index 360d0de4b..3cee16b60 100644
--- a/newlib/libc/stdio/Makefile.am
+++ b/newlib/libc/stdio/Makefile.am
@@ -138,24 +138,43 @@ endif !NEWLIB_NANO_FORMATTED_IO
ELIX_4_SOURCES = \
$(ELIX_4_INT_FORMATTED_IO_SOURCES) \
asnprintf.c \
+ clearerr_u.c \
dprintf.c \
+ feof_u.c \
+ ferror_u.c \
+ fflush_u.c \
+ fgetc_u.c \
+ fgets_u.c \
fgetwc.c \
+ fgetwc_u.c \
fgetws.c \
+ fgetws_u.c \
+ fileno_u.c \
fmemopen.c \
fopencookie.c \
fpurge.c \
+ fputc_u.c \
+ fputs_u.c \
fputwc.c \
+ fputwc_u.c \
fputws.c \
+ fputws_u.c \
+ fread_u.c \
fsetlocking.c \
funopen.c \
fwide.c \
fwprintf.c \
+ fwrite_u.c \
fwscanf.c \
getwc.c \
+ getwc_u.c \
getwchar.c \
+ getwchar_u.c \
open_memstream.c \
putwc.c \
+ putwc_u.c \
putwchar.c \
+ putwchar_u.c \
stdio_ext.c \
swprintf.c \
swscanf.c \
@@ -419,20 +438,41 @@ doc: $(CHEWOUT_FILES)
CLEANFILES = $(CHEWOUT_FILES) *.ref
+$(lpfx)clearerr.$(oext): local.h
+$(lpfx)clearerr_u.$(oext): local.h
$(lpfx)fclose.$(oext): local.h
$(lpfx)fdopen.$(oext): local.h
+$(lpfx)feof.$(oext): local.h
+$(lpfx)feof_u.$(oext): local.h
+$(lpfx)ferror.$(oext): local.h
+$(lpfx)ferror_u.$(oext): local.h
$(lpfx)fflush.$(oext): local.h
+$(lpfx)fflush_u.$(oext): fflush.c
+$(lpfx)fgetc.$(oext): local.h
+$(lpfx)fgetc_u.$(oext): local.h
+$(lpfx)fgets.$(oext): local.h
+$(lpfx)fgets_u.$(oext): fgets.c
$(lpfx)fgetwc.$(oext): local.h
+$(lpfx)fgetwc_u.$(oext): local.h
$(lpfx)fgetws.$(oext): local.h
+$(lpfx)fgetws_u.$(oext): fgetws.c
+$(lpfx)fileno.$(oext): local.h
+$(lpfx)fileno_u.$(oext): local.h
$(lpfx)findfp.$(oext): local.h
$(lpfx)fmemopen.$(oext): local.h
$(lpfx)fopen.$(oext): local.h
$(lpfx)fopencookie.$(oext): local.h
$(lpfx)fpurge.$(oext): local.h
+$(lpfx)fputc.$(oext): local.h
+$(lpfx)fputc_u.$(oext): local.h
$(lpfx)fputs.$(oext): fvwrite.h
+$(lpfx)fputs_u.$(oext): fputs.c
$(lpfx)fputwc.$(oext): local.h
+$(lpfx)fputwc_u.$(oext): local.h
$(lpfx)fputws.$(oext): local.h fvwrite.h
+$(lpfx)fputws_u.$(oext): fputws.c
$(lpfx)fread.$(oext): local.h
+$(lpfx)fread_u.$(oext): fread.c
$(lpfx)freopen.$(oext): local.h
$(lpfx)fseek.$(oext): local.h
$(lpfx)fsetlocking.$(oext): local.h
@@ -443,15 +483,20 @@ $(lpfx)fwalk.$(oext): local.h
$(lpfx)fwide.$(oext): local.h
$(lpfx)fwprintf.$(oext): local.h
$(lpfx)fwrite.$(oext): local.h fvwrite.h
+$(lpfx)fwrite_u.$(oext): fwrite.c
$(lpfx)fwscanf.$(oext): local.h
$(lpfx)getwc.$(oext): local.h
+$(lpfx)getwc_u.$(oext): local.h
$(lpfx)getwchar.$(oext): local.h
+$(lpfx)getwchar_u.$(oext): local.h
$(lpfx)iscanf.$(oext): local.h
$(lpfx)makebuf.$(oext): local.h
$(lpfx)open_memstream.$(oext): local.h
$(lpfx)puts.$(oext): fvwrite.h
$(lpfx)putwc.$(oext): local.h
+$(lpfx)putwc_u.$(oext): local.h
$(lpfx)putwchar.$(oext): local.h
+$(lpfx)putwchar_u.$(oext): local.h
$(lpfx)refill.$(oext): local.h
$(lpfx)scanf.$(oext): local.h
$(lpfx)setbuf.$(oext): local.h
diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in
index 72b386e18..23c4fbe7d 100644
--- a/newlib/libc/stdio/Makefile.in
+++ b/newlib/libc/stdio/Makefile.in
@@ -135,24 +135,43 @@ am__objects_2 = $(am__objects_1) lib_a-clearerr.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-vasniprintf.$(OBJEXT)
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_6 = $(am__objects_5) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-asnprintf.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-clearerr_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-dprintf.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-feof_u.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-ferror_u.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fflush_u.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgetc_u.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgets_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgetwc.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgetwc_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgetws.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgetws_u.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fileno_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fmemopen.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fopencookie.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fpurge.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fputc_u.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fputs_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fputwc.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fputwc_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fputws.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fputws_u.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fread_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fsetlocking.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-funopen.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fwide.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fwprintf.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fwrite_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fwscanf.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-getwc.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-getwc_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-getwchar.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-getwchar_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-open_memstream.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-putwc.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-putwc_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-putwchar.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-putwchar_u.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-stdio_ext.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-swprintf.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-swscanf.$(OBJEXT) \
@@ -199,24 +218,43 @@ am__objects_8 = $(am__objects_7) clearerr.lo fclose.lo fdopen.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ vasniprintf.lo
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_12 = $(am__objects_11) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ asnprintf.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ clearerr_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ dprintf.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ feof_u.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ferror_u.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fflush_u.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetc_u.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgets_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetwc.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetwc_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetws.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetws_u.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fileno_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fmemopen.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fopencookie.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fpurge.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputc_u.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputs_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputwc.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputwc_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputws.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputws_u.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fread_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fsetlocking.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ funopen.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwide.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwprintf.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwrite_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwscanf.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwc.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwc_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwchar.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwchar_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ open_memstream.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwc.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwc_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwchar.lo \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwchar_u.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ stdio_ext.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swprintf.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.lo \
@@ -508,24 +546,43 @@ GENERAL_SOURCES = \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ELIX_4_SOURCES = \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(ELIX_4_INT_FORMATTED_IO_SOURCES) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ asnprintf.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ clearerr_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ dprintf.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ feof_u.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ferror_u.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fflush_u.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetc_u.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgets_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetwc.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetwc_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetws.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetws_u.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fileno_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fmemopen.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fopencookie.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fpurge.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputc_u.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputs_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputwc.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputwc_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputws.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fputws_u.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fread_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fsetlocking.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ funopen.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwide.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwprintf.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwrite_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fwscanf.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwc.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwc_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwchar.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ getwchar_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ open_memstream.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwc.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwc_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwchar.c \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwchar_u.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ stdio_ext.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swprintf.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.c \
@@ -1311,24 +1368,78 @@ lib_a-asnprintf.o: asnprintf.c
lib_a-asnprintf.obj: asnprintf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asnprintf.obj `if test -f 'asnprintf.c'; then $(CYGPATH_W) 'asnprintf.c'; else $(CYGPATH_W) '$(srcdir)/asnprintf.c'; fi`
+lib_a-clearerr_u.o: clearerr_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-clearerr_u.o `test -f 'clearerr_u.c' || echo '$(srcdir)/'`clearerr_u.c
+
+lib_a-clearerr_u.obj: clearerr_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-clearerr_u.obj `if test -f 'clearerr_u.c'; then $(CYGPATH_W) 'clearerr_u.c'; else $(CYGPATH_W) '$(srcdir)/clearerr_u.c'; fi`
+
lib_a-dprintf.o: dprintf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dprintf.o `test -f 'dprintf.c' || echo '$(srcdir)/'`dprintf.c
lib_a-dprintf.obj: dprintf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dprintf.obj `if test -f 'dprintf.c'; then $(CYGPATH_W) 'dprintf.c'; else $(CYGPATH_W) '$(srcdir)/dprintf.c'; fi`
+lib_a-feof_u.o: feof_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feof_u.o `test -f 'feof_u.c' || echo '$(srcdir)/'`feof_u.c
+
+lib_a-feof_u.obj: feof_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feof_u.obj `if test -f 'feof_u.c'; then $(CYGPATH_W) 'feof_u.c'; else $(CYGPATH_W) '$(srcdir)/feof_u.c'; fi`
+
+lib_a-ferror_u.o: ferror_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ferror_u.o `test -f 'ferror_u.c' || echo '$(srcdir)/'`ferror_u.c
+
+lib_a-ferror_u.obj: ferror_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ferror_u.obj `if test -f 'ferror_u.c'; then $(CYGPATH_W) 'ferror_u.c'; else $(CYGPATH_W) '$(srcdir)/ferror_u.c'; fi`
+
+lib_a-fflush_u.o: fflush_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fflush_u.o `test -f 'fflush_u.c' || echo '$(srcdir)/'`fflush_u.c
+
+lib_a-fflush_u.obj: fflush_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fflush_u.obj `if test -f 'fflush_u.c'; then $(CYGPATH_W) 'fflush_u.c'; else $(CYGPATH_W) '$(srcdir)/fflush_u.c'; fi`
+
+lib_a-fgetc_u.o: fgetc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetc_u.o `test -f 'fgetc_u.c' || echo '$(srcdir)/'`fgetc_u.c
+
+lib_a-fgetc_u.obj: fgetc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetc_u.obj `if test -f 'fgetc_u.c'; then $(CYGPATH_W) 'fgetc_u.c'; else $(CYGPATH_W) '$(srcdir)/fgetc_u.c'; fi`
+
+lib_a-fgets_u.o: fgets_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgets_u.o `test -f 'fgets_u.c' || echo '$(srcdir)/'`fgets_u.c
+
+lib_a-fgets_u.obj: fgets_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgets_u.obj `if test -f 'fgets_u.c'; then $(CYGPATH_W) 'fgets_u.c'; else $(CYGPATH_W) '$(srcdir)/fgets_u.c'; fi`
+
lib_a-fgetwc.o: fgetwc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetwc.o `test -f 'fgetwc.c' || echo '$(srcdir)/'`fgetwc.c
lib_a-fgetwc.obj: fgetwc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetwc.obj `if test -f 'fgetwc.c'; then $(CYGPATH_W) 'fgetwc.c'; else $(CYGPATH_W) '$(srcdir)/fgetwc.c'; fi`
+lib_a-fgetwc_u.o: fgetwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetwc_u.o `test -f 'fgetwc_u.c' || echo '$(srcdir)/'`fgetwc_u.c
+
+lib_a-fgetwc_u.obj: fgetwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetwc_u.obj `if test -f 'fgetwc_u.c'; then $(CYGPATH_W) 'fgetwc_u.c'; else $(CYGPATH_W) '$(srcdir)/fgetwc_u.c'; fi`
+
lib_a-fgetws.o: fgetws.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetws.o `test -f 'fgetws.c' || echo '$(srcdir)/'`fgetws.c
lib_a-fgetws.obj: fgetws.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetws.obj `if test -f 'fgetws.c'; then $(CYGPATH_W) 'fgetws.c'; else $(CYGPATH_W) '$(srcdir)/fgetws.c'; fi`
+lib_a-fgetws_u.o: fgetws_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetws_u.o `test -f 'fgetws_u.c' || echo '$(srcdir)/'`fgetws_u.c
+
+lib_a-fgetws_u.obj: fgetws_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fgetws_u.obj `if test -f 'fgetws_u.c'; then $(CYGPATH_W) 'fgetws_u.c'; else $(CYGPATH_W) '$(srcdir)/fgetws_u.c'; fi`
+
+lib_a-fileno_u.o: fileno_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fileno_u.o `test -f 'fileno_u.c' || echo '$(srcdir)/'`fileno_u.c
+
+lib_a-fileno_u.obj: fileno_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fileno_u.obj `if test -f 'fileno_u.c'; then $(CYGPATH_W) 'fileno_u.c'; else $(CYGPATH_W) '$(srcdir)/fileno_u.c'; fi`
+
lib_a-fmemopen.o: fmemopen.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fmemopen.o `test -f 'fmemopen.c' || echo '$(srcdir)/'`fmemopen.c
@@ -1347,18 +1458,48 @@ lib_a-fpurge.o: fpurge.c
lib_a-fpurge.obj: fpurge.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fpurge.obj `if test -f 'fpurge.c'; then $(CYGPATH_W) 'fpurge.c'; else $(CYGPATH_W) '$(srcdir)/fpurge.c'; fi`
+lib_a-fputc_u.o: fputc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputc_u.o `test -f 'fputc_u.c' || echo '$(srcdir)/'`fputc_u.c
+
+lib_a-fputc_u.obj: fputc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputc_u.obj `if test -f 'fputc_u.c'; then $(CYGPATH_W) 'fputc_u.c'; else $(CYGPATH_W) '$(srcdir)/fputc_u.c'; fi`
+
+lib_a-fputs_u.o: fputs_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputs_u.o `test -f 'fputs_u.c' || echo '$(srcdir)/'`fputs_u.c
+
+lib_a-fputs_u.obj: fputs_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputs_u.obj `if test -f 'fputs_u.c'; then $(CYGPATH_W) 'fputs_u.c'; else $(CYGPATH_W) '$(srcdir)/fputs_u.c'; fi`
+
lib_a-fputwc.o: fputwc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputwc.o `test -f 'fputwc.c' || echo '$(srcdir)/'`fputwc.c
lib_a-fputwc.obj: fputwc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputwc.obj `if test -f 'fputwc.c'; then $(CYGPATH_W) 'fputwc.c'; else $(CYGPATH_W) '$(srcdir)/fputwc.c'; fi`
+lib_a-fputwc_u.o: fputwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputwc_u.o `test -f 'fputwc_u.c' || echo '$(srcdir)/'`fputwc_u.c
+
+lib_a-fputwc_u.obj: fputwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputwc_u.obj `if test -f 'fputwc_u.c'; then $(CYGPATH_W) 'fputwc_u.c'; else $(CYGPATH_W) '$(srcdir)/fputwc_u.c'; fi`
+
lib_a-fputws.o: fputws.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputws.o `test -f 'fputws.c' || echo '$(srcdir)/'`fputws.c
lib_a-fputws.obj: fputws.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputws.obj `if test -f 'fputws.c'; then $(CYGPATH_W) 'fputws.c'; else $(CYGPATH_W) '$(srcdir)/fputws.c'; fi`
+lib_a-fputws_u.o: fputws_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputws_u.o `test -f 'fputws_u.c' || echo '$(srcdir)/'`fputws_u.c
+
+lib_a-fputws_u.obj: fputws_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputws_u.obj `if test -f 'fputws_u.c'; then $(CYGPATH_W) 'fputws_u.c'; else $(CYGPATH_W) '$(srcdir)/fputws_u.c'; fi`
+
+lib_a-fread_u.o: fread_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fread_u.o `test -f 'fread_u.c' || echo '$(srcdir)/'`fread_u.c
+
+lib_a-fread_u.obj: fread_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fread_u.obj `if test -f 'fread_u.c'; then $(CYGPATH_W) 'fread_u.c'; else $(CYGPATH_W) '$(srcdir)/fread_u.c'; fi`
+
lib_a-fsetlocking.o: fsetlocking.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fsetlocking.o `test -f 'fsetlocking.c' || echo '$(srcdir)/'`fsetlocking.c
@@ -1383,6 +1524,12 @@ lib_a-fwprintf.o: fwprintf.c
lib_a-fwprintf.obj: fwprintf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwprintf.obj `if test -f 'fwprintf.c'; then $(CYGPATH_W) 'fwprintf.c'; else $(CYGPATH_W) '$(srcdir)/fwprintf.c'; fi`
+lib_a-fwrite_u.o: fwrite_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwrite_u.o `test -f 'fwrite_u.c' || echo '$(srcdir)/'`fwrite_u.c
+
+lib_a-fwrite_u.obj: fwrite_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwrite_u.obj `if test -f 'fwrite_u.c'; then $(CYGPATH_W) 'fwrite_u.c'; else $(CYGPATH_W) '$(srcdir)/fwrite_u.c'; fi`
+
lib_a-fwscanf.o: fwscanf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwscanf.o `test -f 'fwscanf.c' || echo '$(srcdir)/'`fwscanf.c
@@ -1395,12 +1542,24 @@ lib_a-getwc.o: getwc.c
lib_a-getwc.obj: getwc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getwc.obj `if test -f 'getwc.c'; then $(CYGPATH_W) 'getwc.c'; else $(CYGPATH_W) '$(srcdir)/getwc.c'; fi`
+lib_a-getwc_u.o: getwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getwc_u.o `test -f 'getwc_u.c' || echo '$(srcdir)/'`getwc_u.c
+
+lib_a-getwc_u.obj: getwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getwc_u.obj `if test -f 'getwc_u.c'; then $(CYGPATH_W) 'getwc_u.c'; else $(CYGPATH_W) '$(srcdir)/getwc_u.c'; fi`
+
lib_a-getwchar.o: getwchar.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getwchar.o `test -f 'getwchar.c' || echo '$(srcdir)/'`getwchar.c
lib_a-getwchar.obj: getwchar.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getwchar.obj `if test -f 'getwchar.c'; then $(CYGPATH_W) 'getwchar.c'; else $(CYGPATH_W) '$(srcdir)/getwchar.c'; fi`
+lib_a-getwchar_u.o: getwchar_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getwchar_u.o `test -f 'getwchar_u.c' || echo '$(srcdir)/'`getwchar_u.c
+
+lib_a-getwchar_u.obj: getwchar_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getwchar_u.obj `if test -f 'getwchar_u.c'; then $(CYGPATH_W) 'getwchar_u.c'; else $(CYGPATH_W) '$(srcdir)/getwchar_u.c'; fi`
+
lib_a-open_memstream.o: open_memstream.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-open_memstream.o `test -f 'open_memstream.c' || echo '$(srcdir)/'`open_memstream.c
@@ -1413,12 +1572,24 @@ lib_a-putwc.o: putwc.c
lib_a-putwc.obj: putwc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwc.obj `if test -f 'putwc.c'; then $(CYGPATH_W) 'putwc.c'; else $(CYGPATH_W) '$(srcdir)/putwc.c'; fi`
+lib_a-putwc_u.o: putwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwc_u.o `test -f 'putwc_u.c' || echo '$(srcdir)/'`putwc_u.c
+
+lib_a-putwc_u.obj: putwc_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwc_u.obj `if test -f 'putwc_u.c'; then $(CYGPATH_W) 'putwc_u.c'; else $(CYGPATH_W) '$(srcdir)/putwc_u.c'; fi`
+
lib_a-putwchar.o: putwchar.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwchar.o `test -f 'putwchar.c' || echo '$(srcdir)/'`putwchar.c
lib_a-putwchar.obj: putwchar.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwchar.obj `if test -f 'putwchar.c'; then $(CYGPATH_W) 'putwchar.c'; else $(CYGPATH_W) '$(srcdir)/putwchar.c'; fi`
+lib_a-putwchar_u.o: putwchar_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwchar_u.o `test -f 'putwchar_u.c' || echo '$(srcdir)/'`putwchar_u.c
+
+lib_a-putwchar_u.obj: putwchar_u.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwchar_u.obj `if test -f 'putwchar_u.c'; then $(CYGPATH_W) 'putwchar_u.c'; else $(CYGPATH_W) '$(srcdir)/putwchar_u.c'; fi`
+
lib_a-stdio_ext.o: stdio_ext.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stdio_ext.o `test -f 'stdio_ext.c' || echo '$(srcdir)/'`stdio_ext.c
@@ -1766,20 +1937,41 @@ $(lpfx)svfiwscanf.$(oext): vfwscanf.c
doc: $(CHEWOUT_FILES)
cat $(srcdir)/stdio.tex >> $(TARGETDOC)
+$(lpfx)clearerr.$(oext): local.h
+$(lpfx)clearerr_u.$(oext): local.h
$(lpfx)fclose.$(oext): local.h
$(lpfx)fdopen.$(oext): local.h
+$(lpfx)feof.$(oext): local.h
+$(lpfx)feof_u.$(oext): local.h
+$(lpfx)ferror.$(oext): local.h
+$(lpfx)ferror_u.$(oext): local.h
$(lpfx)fflush.$(oext): local.h
+$(lpfx)fflush_u.$(oext): fflush.c
+$(lpfx)fgetc.$(oext): local.h
+$(lpfx)fgetc_u.$(oext): local.h
+$(lpfx)fgets.$(oext): local.h
+$(lpfx)fgets_u.$(oext): fgets.c
$(lpfx)fgetwc.$(oext): local.h
+$(lpfx)fgetwc_u.$(oext): local.h
$(lpfx)fgetws.$(oext): local.h
+$(lpfx)fgetws_u.$(oext): fgetws.c
+$(lpfx)fileno.$(oext): local.h
+$(lpfx)fileno_u.$(oext): local.h
$(lpfx)findfp.$(oext): local.h
$(lpfx)fmemopen.$(oext): local.h
$(lpfx)fopen.$(oext): local.h
$(lpfx)fopencookie.$(oext): local.h
$(lpfx)fpurge.$(oext): local.h
+$(lpfx)fputc.$(oext): local.h
+$(lpfx)fputc_u.$(oext): local.h
$(lpfx)fputs.$(oext): fvwrite.h
+$(lpfx)fputs_u.$(oext): fputs.c
$(lpfx)fputwc.$(oext): local.h
+$(lpfx)fputwc_u.$(oext): local.h
$(lpfx)fputws.$(oext): local.h fvwrite.h
+$(lpfx)fputws_u.$(oext): fputws.c
$(lpfx)fread.$(oext): local.h
+$(lpfx)fread_u.$(oext): fread.c
$(lpfx)freopen.$(oext): local.h
$(lpfx)fseek.$(oext): local.h
$(lpfx)fsetlocking.$(oext): local.h
@@ -1790,15 +1982,20 @@ $(lpfx)fwalk.$(oext): local.h
$(lpfx)fwide.$(oext): local.h
$(lpfx)fwprintf.$(oext): local.h
$(lpfx)fwrite.$(oext): local.h fvwrite.h
+$(lpfx)fwrite_u.$(oext): fwrite.c
$(lpfx)fwscanf.$(oext): local.h
$(lpfx)getwc.$(oext): local.h
+$(lpfx)getwc_u.$(oext): local.h
$(lpfx)getwchar.$(oext): local.h
+$(lpfx)getwchar_u.$(oext): local.h
$(lpfx)iscanf.$(oext): local.h
$(lpfx)makebuf.$(oext): local.h
$(lpfx)open_memstream.$(oext): local.h
$(lpfx)puts.$(oext): fvwrite.h
$(lpfx)putwc.$(oext): local.h
+$(lpfx)putwc_u.$(oext): local.h
$(lpfx)putwchar.$(oext): local.h
+$(lpfx)putwchar_u.$(oext): local.h
$(lpfx)refill.$(oext): local.h
$(lpfx)scanf.$(oext): local.h
$(lpfx)setbuf.$(oext): local.h
diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c
index ed4603ba2..9bf0837f5 100644
--- a/newlib/libc/stdio/clearerr.c
+++ b/newlib/libc/stdio/clearerr.c
@@ -17,20 +17,31 @@
/*
FUNCTION
-<<clearerr>>---clear file or stream error indicator
+<<clearerr>>, <<clearerr_unlocked>>---clear file or stream error indicator
INDEX
clearerr
+INDEX
+ clearerr_unlocked
ANSI_SYNOPSIS
#include <stdio.h>
void clearerr(FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ void clearerr_unlocked(FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
void clearerr(<[fp]>)
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ void clearerr_unlocked(<[fp]>)
+ FILE *<[fp]>;
+
DESCRIPTION
The <<stdio>> functions maintain an error indicator with each file
pointer <[fp]>, to record whether any read or write errors have
@@ -42,6 +53,14 @@ Use <<clearerr>> to reset both of these indicators.
See <<ferror>> and <<feof>> to query the two indicators.
+<<clearerr_unlocked>> is a non-thread-safe version of <<clearerr>>.
+<<clearerr_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<clearerr_unlocked>> is equivalent to <<clearerr>>.
RETURNS
<<clearerr>> does not return a result.
@@ -49,6 +68,8 @@ RETURNS
PORTABILITY
ANSI C requires <<clearerr>>.
+<<clearerr_unlocked>> is a BSD extension also provided by GNU libc.
+
No supporting OS subroutines are required.
*/
diff --git a/newlib/libc/stdio/clearerr_u.c b/newlib/libc/stdio/clearerr_u.c
new file mode 100644
index 000000000..00c5e8efa
--- /dev/null
+++ b/newlib/libc/stdio/clearerr_u.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <_ansi.h>
+#include <stdio.h>
+#include "local.h"
+
+/* A subroutine version of the macro clearerr_unlocked. */
+
+#undef clearerr_unlocked
+
+_VOID
+_DEFUN(clearerr_unlocked, (fp),
+ FILE * fp)
+{
+ CHECK_INIT(_REENT, fp);
+ __sclearerr (fp);
+}
diff --git a/newlib/libc/stdio/feof.c b/newlib/libc/stdio/feof.c
index c0216ffed..7aadd8209 100644
--- a/newlib/libc/stdio/feof.c
+++ b/newlib/libc/stdio/feof.c
@@ -17,24 +17,44 @@
/*
FUNCTION
-<<feof>>---test for end of file
+<<feof>>, <<feof_unlocked>>---test for end of file
INDEX
feof
+INDEX
+ feof_unlocked
ANSI_SYNOPSIS
#include <stdio.h>
int feof(FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int feof_unlocked(FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
int feof(<[fp]>)
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int feof_unlocked(<[fp]>)
+ FILE *<[fp]>;
+
DESCRIPTION
<<feof>> tests whether or not the end of the file identified by <[fp]>
has been reached.
+<<feof_unlocked>> is a non-thread-safe version of <<feof>>.
+<<feof_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<feof_unlocked>> is equivalent to <<feof>>.
+
RETURNS
<<feof>> returns <<0>> if the end of file has not yet been reached; if
at end of file, the result is nonzero.
@@ -42,6 +62,8 @@ at end of file, the result is nonzero.
PORTABILITY
<<feof>> is required by ANSI C.
+<<feof_unlocked>> is a BSD extension also provided by GNU libc.
+
No supporting OS subroutines are required.
*/
diff --git a/newlib/libc/stdio/feof_u.c b/newlib/libc/stdio/feof_u.c
new file mode 100644
index 000000000..48fc4af47
--- /dev/null
+++ b/newlib/libc/stdio/feof_u.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <stdio.h>
+#include "local.h"
+
+/* A subroutine version of the macro feof_unlocked. */
+
+#undef feof_unlocked
+
+int
+_DEFUN(feof_unlocked, (fp),
+ FILE * fp)
+{
+ CHECK_INIT(_REENT, fp);
+ return __sfeof (fp);
+}
diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c
index 0cd3c3089..f93063d71 100644
--- a/newlib/libc/stdio/ferror.c
+++ b/newlib/libc/stdio/ferror.c
@@ -17,20 +17,31 @@
/*
FUNCTION
-<<ferror>>---test whether read/write error has occurred
+<<ferror>>, <<ferror_unlocked>>---test whether read/write error has occurred
INDEX
ferror
+INDEX
+ ferror_unlocked
ANSI_SYNOPSIS
#include <stdio.h>
int ferror(FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int ferror_unlocked(FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
int ferror(<[fp]>)
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int ferror_unlocked(<[fp]>)
+ FILE *<[fp]>;
+
DESCRIPTION
The <<stdio>> functions maintain an error indicator with each file
pointer <[fp]>, to record whether any read or write errors have
@@ -39,6 +50,15 @@ Use <<ferror>> to query this indicator.
See <<clearerr>> to reset the error indicator.
+<<ferror_unlocked>> is a non-thread-safe version of <<ferror>>.
+<<ferror_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<ferror_unlocked>> is equivalent to <<ferror>>.
+
RETURNS
<<ferror>> returns <<0>> if no errors have occurred; it returns a
nonzero value otherwise.
@@ -46,6 +66,8 @@ nonzero value otherwise.
PORTABILITY
ANSI C requires <<ferror>>.
+<<ferror_unlocked>> is a BSD extension also provided by GNU libc.
+
No supporting OS subroutines are required.
*/
diff --git a/newlib/libc/stdio/ferror_u.c b/newlib/libc/stdio/ferror_u.c
new file mode 100644
index 000000000..9b9edba24
--- /dev/null
+++ b/newlib/libc/stdio/ferror_u.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <_ansi.h>
+#include <stdio.h>
+#include "local.h"
+
+/* A subroutine version of the macro ferror_unlocked. */
+
+#undef ferror_unlocked
+
+int
+_DEFUN(ferror_unlocked, (fp),
+ FILE * fp)
+{
+ CHECK_INIT(_REENT, fp);
+ return __sferror (fp);
+}
diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c
index 2286e3878..a4e639e72 100644
--- a/newlib/libc/stdio/fflush.c
+++ b/newlib/libc/stdio/fflush.c
@@ -17,19 +17,32 @@
/*
FUNCTION
-<<fflush>>---flush buffered file output
+<<fflush>>, <<fflush_unlocked>>---flush buffered file output
INDEX
fflush
INDEX
+ fflush_unlocked
+INDEX
_fflush_r
+INDEX
+ _fflush_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
int fflush(FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int fflush_unlocked(FILE *<[fp]>);
+
+ #include <stdio.h>
int _fflush_r(struct _reent *<[reent]>, FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int _fflush_unlocked_r(struct _reent *<[reent]>, FILE *<[fp]>);
+
DESCRIPTION
The <<stdio>> output functions can buffer output before delivering it
to the host system, in order to minimize the overhead of system calls.
@@ -45,9 +58,18 @@ descriptor, set the position of the file descriptor to match next
unread byte, useful for obeying POSIX semantics when ending a process
without consuming all input from the stream.
-The alternate function <<_fflush_r>> is a reentrant version, where the
-extra argument <[reent]> is a pointer to a reentrancy structure, and
-<[fp]> must not be NULL.
+<<fflush_unlocked>> is a non-thread-safe version of <<fflush>>.
+<<fflush_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fflush_unlocked>> is equivalent to <<fflush>>.
+
+The alternate functions <<_fflush_r>> and <<_fflush_unlocked_r>> are
+reentrant versions, where the extra argument <[reent]> is a pointer to
+a reentrancy structure, and <[fp]> must not be NULL.
RETURNS
<<fflush>> returns <<0>> unless it encounters a write error; in that
@@ -57,6 +79,8 @@ PORTABILITY
ANSI C requires <<fflush>>. The behavior on input streams is only
specified by POSIX, and not all implementations follow POSIX rules.
+<<fflush_unlocked>> is a BSD extension also provided by GNU libc.
+
No supporting OS subroutines are required.
*/
@@ -65,6 +89,12 @@ No supporting OS subroutines are required.
#include <errno.h>
#include "local.h"
+#ifdef __IMPL_UNLOCKED__
+#define _fflush_r _fflush_unlocked_r
+#define fflush fflush_unlocked
+#endif
+
+#ifndef __IMPL_UNLOCKED__
/* Flush a single file, or (if fp is NULL) all files. */
/* Core function which does not lock file pointer. This gets called
@@ -217,6 +247,8 @@ _DEFUN(__sflushw_r, (ptr, fp),
}
#endif
+#endif /* __IMPL_UNLOCKED__ */
+
int
_DEFUN(_fflush_r, (ptr, fp),
struct _reent *ptr _AND
diff --git a/newlib/libc/stdio/fflush_u.c b/newlib/libc/stdio/fflush_u.c
new file mode 100644
index 000000000..adcc46063
--- /dev/null
+++ b/newlib/libc/stdio/fflush_u.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __IMPL_UNLOCKED__
+#include "fflush.c"
diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c
index 20492d24b..34447a2c8 100644
--- a/newlib/libc/stdio/fgetc.c
+++ b/newlib/libc/stdio/fgetc.c
@@ -17,30 +17,53 @@
/*
FUNCTION
-<<fgetc>>---get a character from a file or stream
+<<fgetc>>, <<fgetc_unlocked>>---get a character from a file or stream
INDEX
fgetc
INDEX
+ fgetc_unlocked
+INDEX
_fgetc_r
+INDEX
+ _fgetc_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
int fgetc(FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int fgetc_unlocked(FILE *<[fp]>);
+
#include <stdio.h>
int _fgetc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int _fgetc_unlocked_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
int fgetc(<[fp]>)
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int fgetc_unlocked(<[fp]>)
+ FILE *<[fp]>;
+
#include <stdio.h>
int _fgetc_r(<[ptr]>, <[fp]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int _fgetc_unlocked_r(<[ptr]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ FILE *<[fp]>;
+
DESCRIPTION
Use <<fgetc>> to get the next single character from the file or stream
identified by <[fp]>. As a side effect, <<fgetc>> advances the file's
@@ -48,9 +71,18 @@ current position indicator.
For a macro version of this function, see <<getc>>.
-The function <<_fgetc_r>> is simply a reentrant version of
-<<fgetc>> that is passed the additional reentrant structure
-pointer argument: <[ptr]>.
+<<fgetc_unlocked>> is a non-thread-safe version of <<fgetc>>.
+<<fgetc_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fgetc_unlocked>> is equivalent to <<fgetc>>.
+
+The functions <<_fgetc_r>> and <<_fgetc_unlocked_r>> are simply reentrant
+versions that are passed the additional reentrant structure pointer
+argument: <[ptr]>.
RETURNS
The next character (read as an <<unsigned char>>, and cast to
@@ -63,6 +95,8 @@ using the <<ferror>> and <<feof>> functions.
PORTABILITY
ANSI C requires <<fgetc>>.
+<<fgetc_unlocked>> is a BSD extension also provided by GNU libc.
+
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
diff --git a/newlib/libc/stdio/fgetc_u.c b/newlib/libc/stdio/fgetc_u.c
new file mode 100644
index 000000000..5bbd5a549
--- /dev/null
+++ b/newlib/libc/stdio/fgetc_u.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <_ansi.h>
+#include <stdio.h>
+#include "local.h"
+
+int
+_DEFUN(_fgetc_unlocked_r, (ptr, fp),
+ struct _reent * ptr _AND
+ FILE * fp)
+{
+ CHECK_INIT(ptr, fp);
+ return __sgetc_r (ptr, fp);
+}
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN(fgetc_unlocked, (fp),
+ FILE * fp)
+{
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
+ struct _reent *reent = _REENT;
+
+ CHECK_INIT(reent, fp);
+ return __sgetc_r (reent, fp);
+#else
+ return _fgetc_unlocked_r (_REENT, fp);
+#endif
+}
+
+#endif /* !_REENT_ONLY */
diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c
index 0280ea0c5..f7c8a0300 100644
--- a/newlib/libc/stdio/fgets.c
+++ b/newlib/libc/stdio/fgets.c
@@ -17,20 +17,31 @@
/*
FUNCTION
-<<fgets>>---get character string from a file or stream
+<<fgets>>, <<fgets_unlocked>>---get character string from a file or stream
INDEX
fgets
INDEX
+ fgets_unlocked
+INDEX
_fgets_r
+INDEX
+ _fgets_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
char *fgets(char *restrict <[buf]>, int <[n]>, FILE *restrict <[fp]>);
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ char *fgets_unlocked(char *restrict <[buf]>, int <[n]>, FILE *restrict <[fp]>);
+
#include <stdio.h>
char *_fgets_r(struct _reent *<[ptr]>, char *restrict <[buf]>, int <[n]>, FILE *restrict <[fp]>);
+ #include <stdio.h>
+ char *_fgets_unlocked_r(struct _reent *<[ptr]>, char *restrict <[buf]>, int <[n]>, FILE *restrict <[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
char *fgets(<[buf]>,<[n]>,<[fp]>)
@@ -38,6 +49,13 @@ TRAD_SYNOPSIS
int <[n]>;
FILE *<[fp]>;
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ char *fgets_unlocked(<[buf]>,<[n]>,<[fp]>)
+ char *<[buf]>;
+ int <[n]>;
+ FILE *<[fp]>;
+
#include <stdio.h>
char *_fgets_r(<[ptr]>, <[buf]>,<[n]>,<[fp]>)
struct _reent *<[ptr]>;
@@ -45,14 +63,30 @@ TRAD_SYNOPSIS
int <[n]>;
FILE *<[fp]>;
+ #include <stdio.h>
+ char *_fgets_unlocked_r(<[ptr]>, <[buf]>,<[n]>,<[fp]>)
+ struct _reent *<[ptr]>;
+ char *<[buf]>;
+ int <[n]>;
+ FILE *<[fp]>;
+
DESCRIPTION
Reads at most <[n-1]> characters from <[fp]> until a newline
is found. The characters including to the newline are stored
in <[buf]>. The buffer is terminated with a 0.
- The <<_fgets_r>> function is simply the reentrant version of
- <<fgets>> and is passed an additional reentrancy structure
- pointer: <[ptr]>.
+ <<fgets_unlocked>> is a non-thread-safe version of <<fgets>>.
+ <<fgets_unlocked>> may only safely be used within a scope
+ protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+ function may safely be used in a multi-threaded program if and only
+ if they are called while the invoking thread owns the (FILE *)
+ object, as is the case after a successful call to the flockfile() or
+ ftrylockfile() functions. If threads are disabled, then
+ <<fgets_unlocked>> is equivalent to <<fgets>>.
+
+ The functions <<_fgets_r>> and <<_fgets_unlocked_r>> are simply
+ reentrant versions that are passed the additional reentrant structure
+ pointer argument: <[ptr]>.
RETURNS
<<fgets>> returns the buffer passed to it, with the data
@@ -65,6 +99,8 @@ PORTABILITY
that <<fgets>> returns all of the data, while <<gets>> removes
the trailing newline (with no indication that it has done so.)
+ <<fgets_unlocked>> is a GNU extension.
+
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
@@ -74,6 +110,11 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <string.h>
#include "local.h"
+#ifdef __IMPL_UNLOCKED__
+#define _fgets_r _fgets_unlocked_r
+#define fgets fgets_unlocked
+#endif
+
/*
* Read at most n-1 characters from the given file.
* Stop when a newline has been read, or the count runs out.
diff --git a/newlib/libc/stdio/fgets_u.c b/newlib/libc/stdio/fgets_u.c
new file mode 100644
index 000000000..b36748da1
--- /dev/null
+++ b/newlib/libc/stdio/fgets_u.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __IMPL_UNLOCKED__
+#include "fgets.c"
diff --git a/newlib/libc/stdio/fgetwc.c b/newlib/libc/stdio/fgetwc.c
index 14c554786..e89404be8 100644
--- a/newlib/libc/stdio/fgetwc.c
+++ b/newlib/libc/stdio/fgetwc.c
@@ -26,40 +26,72 @@
/*
FUNCTION
-<<fgetwc>>, <<getwc>>---get a wide character from a file or stream
+<<fgetwc>>, <<getwc>>, <<fgetwc_unlocked>>, <<getwc_unlocked>>---get a wide character from a file or stream
INDEX
fgetwc
INDEX
+ fgetwc_unlocked
+INDEX
_fgetwc_r
INDEX
+ _fgetwc_unlocked_r
+INDEX
getwc
INDEX
+ getwc_unlocked
+INDEX
_getwc_r
+INDEX
+ _getwc_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
#include <wchar.h>
wint_t fgetwc(FILE *<[fp]>);
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t fgetwc_unlocked(FILE *<[fp]>);
+
#include <stdio.h>
#include <wchar.h>
wint_t _fgetwc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
#include <stdio.h>
#include <wchar.h>
+ wint_t _fgetwc_unlocked_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+
+ #include <stdio.h>
+ #include <wchar.h>
wint_t getwc(FILE *<[fp]>);
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t getwc_unlocked(FILE *<[fp]>);
+
#include <stdio.h>
#include <wchar.h>
wint_t _getwc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t _getwc_unlocked_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
#include <wchar.h>
wint_t fgetwc(<[fp]>)
FILE *<[fp]>;
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t fgetwc_unlocked(<[fp]>)
+ FILE *<[fp]>;
+
#include <stdio.h>
#include <wchar.h>
wint_t _fgetwc_r(<[ptr]>, <[fp]>)
@@ -68,27 +100,54 @@ TRAD_SYNOPSIS
#include <stdio.h>
#include <wchar.h>
+ wint_t _fgetwc_unlocked_r(<[ptr]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ FILE *<[fp]>;
+
+ #include <stdio.h>
+ #include <wchar.h>
wint_t getwc(<[fp]>)
FILE *<[fp]>;
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t getwc_unlocked(<[fp]>)
+ FILE *<[fp]>;
+
#include <stdio.h>
#include <wchar.h>
wint_t _getwc_r(<[ptr]>, <[fp]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t _getwc_unlocked_r(<[ptr]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ FILE *<[fp]>;
+
DESCRIPTION
Use <<fgetwc>> to get the next wide character from the file or stream
identified by <[fp]>. As a side effect, <<fgetwc>> advances the file's
current position indicator.
-The <<getwc>> function or macro functions identically to <<fgetwc>>. It
-may be implemented as a macro, and may evaluate its argument more than
-once. There is no reason ever to use it.
+<<fgetwc_unlocked>> is a non-thread-safe version of <<fgetwc>>.
+<<fgetwc_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fgetwc_unlocked>> is equivalent to <<fgetwc>>.
+
+The <<getwc>> and <<getwc_unlocked>> functions or macros functions identically
+to <<fgetwc>> and <<fgetwc_unlocked>>. It may be implemented as a macro, and
+may evaluate its argument more than once. There is no reason ever to use it.
-<<_fgetwc_r>> and <<_getwc_r>> are simply reentrant versions of
-<<fgetwc>> and <<getwc>> that are passed the additional reentrant
-structure pointer argument: <[ptr]>.
+<<_fgetwc_r>>, <<_getwc_r>>, <<_fgetwc_unlocked_r>>, and <<_getwc_unlocked_r>>
+are simply reentrant versions of the above functions that are passed the
+additional reentrant structure pointer argument: <[ptr]>.
RETURNS
The next wide character cast to <<wint_t>>), unless there is no more data,
@@ -99,7 +158,9 @@ You can distinguish the two situations that cause an <<EOF>> result by
using the <<ferror>> and <<feof>> functions.
PORTABILITY
-C99, POSIX.1-2001
+<<fgetwc>> and <<getwc>> are required by C99 and POSIX.1-2001.
+
+<<fgetwc_unlocked>> and <<getwc_unlocked>> are GNU extensions.
*/
#include <_ansi.h>
@@ -110,7 +171,7 @@ C99, POSIX.1-2001
#include <wchar.h>
#include "local.h"
-static wint_t
+wint_t
_DEFUN(__fgetwc, (ptr, fp),
struct _reent *ptr _AND
register FILE *fp)
diff --git a/newlib/libc/stdio/fgetwc_u.c b/newlib/libc/stdio/fgetwc_u.c
new file mode 100644
index 000000000..4ccd5765c
--- /dev/null
+++ b/newlib/libc/stdio/fgetwc_u.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <_ansi.h>
+#include <stdio.h>
+#include <wchar.h>
+#include "local.h"
+
+wint_t
+_DEFUN(_fgetwc_unlocked_r, (ptr, fp),
+ struct _reent *ptr _AND
+ register FILE *fp)
+{
+ ORIENT(fp, 1);
+ return __fgetwc (ptr, fp);
+}
+
+wint_t
+_DEFUN(fgetwc_unlocked, (fp),
+ FILE *fp)
+{
+ struct _reent *reent = _REENT;
+
+ CHECK_INIT(reent, fp);
+ return _fgetwc_unlocked_r (reent, fp);
+}
diff --git a/newlib/libc/stdio/fgetws.c b/newlib/libc/stdio/fgetws.c
index dfd7fe9cc..ae1f48e66 100644
--- a/newlib/libc/stdio/fgetws.c
+++ b/newlib/libc/stdio/fgetws.c
@@ -26,22 +26,35 @@
/*
FUNCTION
-<<fgetws>>---get wide character string from a file or stream
+<<fgetws>>, <<fgetws_unlocked>>---get wide character string from a file or stream
INDEX
fgetws
INDEX
+ fgetws_unlocked
+INDEX
_fgetws_r
+INDEX
+ _fgetws_unlocked_r
ANSI_SYNOPSIS
#include <wchar.h>
wchar_t *fgetws(wchar_t *__restrict <[ws]>, int <[n]>,
FILE *__restrict <[fp]>);
+ #define _GNU_SOURCE
+ #include <wchar.h>
+ wchar_t *fgetws_unlocked(wchar_t *__restrict <[ws]>, int <[n]>,
+ FILE *__restrict <[fp]>);
+
#include <wchar.h>
wchar_t *_fgetws_r(struct _reent *<[ptr]>, wchar_t *<[ws]>,
int <[n]>, FILE *<[fp]>);
+ #include <wchar.h>
+ wchar_t *_fgetws_unlocked_r(struct _reent *<[ptr]>, wchar_t *<[ws]>,
+ int <[n]>, FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <wchar.h>
wchar_t *fgetws(<[ws]>,<[n]>,<[fp]>)
@@ -49,6 +62,13 @@ TRAD_SYNOPSIS
int <[n]>;
FILE *__restrict <[fp]>;
+ #define _GNU_SOURCE
+ #include <wchar.h>
+ wchar_t *fgetws_unlocked(<[ws]>,<[n]>,<[fp]>)
+ wchar_t *__restrict <[ws]>;
+ int <[n]>;
+ FILE *__restrict <[fp]>;
+
#include <wchar.h>
wchar_t *_fgetws_r(<[ptr]>, <[ws]>,<[n]>,<[fp]>)
struct _reent *<[ptr]>;
@@ -56,13 +76,29 @@ TRAD_SYNOPSIS
int <[n]>;
FILE *<[fp]>;
+ #include <wchar.h>
+ wchar_t *_fgetws_unlocked_r(<[ptr]>, <[ws]>,<[n]>,<[fp]>)
+ struct _reent *<[ptr]>;
+ wchar_t *<[ws]>;
+ int <[n]>;
+ FILE *<[fp]>;
+
DESCRIPTION
Reads at most <[n-1]> wide characters from <[fp]> until a newline
is found. The wide characters including to the newline are stored
in <[ws]>. The buffer is terminated with a 0.
-The <<_fgetws_r>> function is simply the reentrant version of
-<<fgetws>> and is passed an additional reentrancy structure
+<<fgetws_unlocked>> is a non-thread-safe version of <<fgetws>>.
+<<fgetws_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fgetws_unlocked>> is equivalent to <<fgetws>>.
+
+The <<_fgetws_r>> and <<_fgetws_unlocked_r>> functions are simply reentrant
+version of the above and are passed an additional reentrancy structure
pointer: <[ptr]>.
RETURNS
@@ -72,7 +108,9 @@ accumulated, the data is returned with no other indication. If
no data are read, NULL is returned instead.
PORTABILITY
-C99, POSIX.1-2001
+<<fgetws>> is required by C99 and POSIX.1-2001.
+
+<<fgetws_unlocked>> is a GNU extension.
*/
#include <_ansi.h>
@@ -83,6 +121,11 @@ C99, POSIX.1-2001
#include <wchar.h>
#include "local.h"
+#ifdef __IMPL_UNLOCKED__
+#define _fgetws_r _fgetws_unlocked_r
+#define fgetws fgetws_unlocked
+#endif
+
wchar_t *
_DEFUN(_fgetws_r, (ptr, ws, n, fp),
struct _reent *ptr _AND
diff --git a/newlib/libc/stdio/fgetws_u.c b/newlib/libc/stdio/fgetws_u.c
new file mode 100644
index 000000000..ae4d7d9c2
--- /dev/null
+++ b/newlib/libc/stdio/fgetws_u.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __IMPL_UNLOCKED__
+#include "fgetws.c"
diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c
index be8f3d66a..7b505827d 100644
--- a/newlib/libc/stdio/fileno.c
+++ b/newlib/libc/stdio/fileno.c
@@ -17,23 +17,43 @@
/*
FUNCTION
-<<fileno>>---return file descriptor associated with stream
+<<fileno>>, <<fileno_unlocked>>---return file descriptor associated with stream
INDEX
fileno
+INDEX
+ fileno_unlocked
ANSI_SYNOPSIS
#include <stdio.h>
int fileno(FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int fileno_unlocked(FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
int fileno(<[fp]>)
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int fileno_unlocked(<[fp]>)
+ FILE *<[fp]>;
+
DESCRIPTION
You can use <<fileno>> to return the file descriptor identified by <[fp]>.
+<<fileno_unlocked>> is a non-thread-safe version of <<fileno>>.
+<<fileno_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fileno_unlocked>> is equivalent to <<fileno>>.
+
RETURNS
<<fileno>> returns a non-negative integer when successful.
If <[fp]> is not an open stream, <<fileno>> returns -1.
@@ -42,6 +62,8 @@ PORTABILITY
<<fileno>> is not part of ANSI C.
POSIX requires <<fileno>>.
+<<fileno_unlocked>> is a BSD extension also provided by GNU libc.
+
Supporting OS subroutines required: none.
*/
diff --git a/newlib/libc/stdio/fileno_u.c b/newlib/libc/stdio/fileno_u.c
new file mode 100644
index 000000000..468d1127e
--- /dev/null
+++ b/newlib/libc/stdio/fileno_u.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <_ansi.h>
+#include <stdio.h>
+#include <errno.h>
+#include "local.h"
+
+int
+_DEFUN(fileno_unlocked, (f),
+ FILE * f)
+{
+ int result;
+ CHECK_INIT (_REENT, f);
+ if (f->_flags)
+ result = __sfileno (f);
+ else
+ {
+ result = -1;
+ _REENT->_errno = EBADF;
+ }
+ return result;
+}
diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c
index f380717d1..0aad0a9f7 100644
--- a/newlib/libc/stdio/fputc.c
+++ b/newlib/libc/stdio/fputc.c
@@ -17,32 +17,55 @@
/*
FUNCTION
-<<fputc>>---write a character on a stream or file
+<<fputc>>, <<fputc_unlocked>>---write a character on a stream or file
INDEX
fputc
INDEX
+ fputc_unlocked
+INDEX
_fputc_r
+INDEX
+ _fputc_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
int fputc(int <[ch]>, FILE *<[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int fputc_unlocked(int <[ch]>, FILE *<[fp]>);
+
#include <stdio.h>
int _fputc_r(struct _rent *<[ptr]>, int <[ch]>, FILE *<[fp]>);
+ #include <stdio.h>
+ int _fputc_unlocked_r(struct _rent *<[ptr]>, int <[ch]>, FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
int fputc(<[ch]>, <[fp]>)
int <[ch]>;
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ int fputc_unlocked(<[ch]>, <[fp]>)
+ int <[ch]>;
+ FILE *<[fp]>;
+
#include <stdio.h>
int _fputc_r(<[ptr]>, <[ch]>, <[fp]>)
struct _reent *<[ptr]>;
int <[ch]>;
FILE *<[fp]>;
+ #include <stdio.h>
+ int _fputc_unlocked_r(<[ptr]>, <[ch]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ int <[ch]>;
+ FILE *<[fp]>;
+
DESCRIPTION
<<fputc>> converts the argument <[ch]> from an <<int>> to an
<<unsigned char>>, then writes it to the file or stream identified by
@@ -56,8 +79,18 @@ oadvances by one.
For a macro version of this function, see <<putc>>.
-The <<_fputc_r>> function is simply a reentrant version of <<fputc>>
-that takes an additional reentrant structure argument: <[ptr]>.
+<<fputc_unlocked>> is a non-thread-safe version of <<fputc>>.
+<<fputc_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fputc_unlocked>> is equivalent to <<fputc>>.
+
+The <<_fputc_r>> and <<_fputc_unlocked_r>> functions are simply reentrant
+versions of the above that take an additional reentrant structure
+argument: <[ptr]>.
RETURNS
If successful, <<fputc>> returns its argument <[ch]>. If an error
@@ -67,6 +100,8 @@ query for errors.
PORTABILITY
<<fputc>> is required by ANSI C.
+<<fputc_unlocked>> is a BSD extension also provided by GNU libc.
+
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
diff --git a/newlib/libc/stdio/fputc_u.c b/newlib/libc/stdio/fputc_u.c
new file mode 100644
index 000000000..ac64b0bc2
--- /dev/null
+++ b/newlib/libc/stdio/fputc_u.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <_ansi.h>
+#include <stdio.h>
+#include "local.h"
+
+int
+_DEFUN(_fputc_unlocked_r, (ptr, ch, file),
+ struct _reent *ptr _AND
+ int ch _AND
+ FILE * file)
+{
+ CHECK_INIT(ptr, file);
+ return _putc_unlocked_r (ptr, ch, file);
+}
+
+#ifndef _REENT_ONLY
+int
+_DEFUN(fputc_unlocked, (ch, file),
+ int ch _AND
+ FILE * file)
+{
+#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED)
+ struct _reent *reent = _REENT;
+
+ CHECK_INIT(reent, file);
+ return _putc_unlocked_r (reent, ch, file);
+#else
+ return _fputc_unlocked_r (_REENT, ch, file);
+#endif
+}
+#endif /* !_REENT_ONLY */
diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c
index 7c1888f93..75f65d96e 100644
--- a/newlib/libc/stdio/fputs.c
+++ b/newlib/libc/stdio/fputs.c
@@ -17,38 +17,70 @@
/*
FUNCTION
-<<fputs>>---write a character string in a file or stream
+<<fputs>>, <<fputs_unlocked>>---write a character string in a file or stream
INDEX
fputs
INDEX
+ fputs_unlocked
+INDEX
_fputs_r
+INDEX
+ _fputs_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
int fputs(const char *restrict <[s]>, FILE *restrict <[fp]>);
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ int fputs_unlocked(const char *restrict <[s]>, FILE *restrict <[fp]>);
+
#include <stdio.h>
int _fputs_r(struct _reent *<[ptr]>, const char *restrict <[s]>, FILE *restrict <[fp]>);
+ #include <stdio.h>
+ int _fputs_unlocked_r(struct _reent *<[ptr]>, const char *restrict <[s]>, FILE *restrict <[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
int fputs(<[s]>, <[fp]>)
char *<[s]>;
FILE *<[fp]>;
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ int fputs_unlocked(<[s]>, <[fp]>)
+ char *<[s]>;
+ FILE *<[fp]>;
+
#include <stdio.h>
int _fputs_r(<[ptr]>, <[s]>, <[fp]>)
struct _reent *<[ptr]>;
char *<[s]>;
FILE *<[fp]>;
+ #include <stdio.h>
+ int _fputs_unlocked_r(<[ptr]>, <[s]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ char *<[s]>;
+ FILE *<[fp]>;
+
DESCRIPTION
<<fputs>> writes the string at <[s]> (but without the trailing null)
to the file or stream identified by <[fp]>.
-<<_fputs_r>> is simply the reentrant version of <<fputs>> that takes
-an additional reentrant struct pointer argument: <[ptr]>.
+<<fputs_unlocked>> is a non-thread-safe version of <<fputs>>.
+<<fputs_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fputs_unlocked>> is equivalent to <<fputs>>.
+
+<<_fputs_r>> and <<_fputs_unlocked_r>> are simply reentrant versions of the
+above that take an additional reentrant struct pointer argument: <[ptr]>.
RETURNS
If successful, the result is <<0>>; otherwise, the result is <<EOF>>.
@@ -57,6 +89,8 @@ PORTABILITY
ANSI C requires <<fputs>>, but does not specify that the result on
success must be <<0>>; any non-negative value is permitted.
+<<fputs_unlocked>> is a GNU extension.
+
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
@@ -67,10 +101,14 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include "fvwrite.h"
#include "local.h"
+#ifdef __IMPL_UNLOCKED__
+#define _fputs_r _fputs_unlocked_r
+#define fputs fputs_unlocked
+#endif
+
/*
* Write the given string to the given file.
*/
-
int
_DEFUN(_fputs_r, (ptr, s, fp),
struct _reent * ptr _AND
diff --git a/newlib/libc/stdio/fputs_u.c b/newlib/libc/stdio/fputs_u.c
new file mode 100644
index 000000000..3b03cecdb
--- /dev/null
+++ b/newlib/libc/stdio/fputs_u.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __IMPL_UNLOCKED__
+#include "fputs.c"
diff --git a/newlib/libc/stdio/fputwc.c b/newlib/libc/stdio/fputwc.c
index 5ec85d1ab..9c2ef6c3b 100644
--- a/newlib/libc/stdio/fputwc.c
+++ b/newlib/libc/stdio/fputwc.c
@@ -26,34 +26,60 @@
/*
FUNCTION
-<<fputwc>>, <<putwc>>---write a wide character on a stream or file
+<<fputwc>>, <<putwc>>, <<fputwc_unlocked>>, <<putwc_unlocked>>---write a wide character on a stream or file
INDEX
fputwc
INDEX
+ fputwc_unlocked
+INDEX
_fputwc_r
INDEX
+ _fputwc_unlocked_r
+INDEX
putwc
INDEX
+ putwc_unlocked
+INDEX
_putwc_r
+INDEX
+ _putwc_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
#include <wchar.h>
wint_t fputwc(wchar_t <[wc]>, FILE *<[fp]>);
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t fputwc_unlocked(wchar_t <[wc]>, FILE *<[fp]>);
+
#include <stdio.h>
#include <wchar.h>
wint_t _fputwc_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>);
#include <stdio.h>
#include <wchar.h>
+ wint_t _fputwc_unlocked_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>);
+
+ #include <stdio.h>
+ #include <wchar.h>
wint_t putwc(wchar_t <[wc]>, FILE *<[fp]>);
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t putwc_unlocked(wchar_t <[wc]>, FILE *<[fp]>);
+
#include <stdio.h>
#include <wchar.h>
wint_t _putwc_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>);
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t _putwc_unlocked_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
#include <wchar.h>
@@ -61,6 +87,13 @@ TRAD_SYNOPSIS
wchar_t <[wc]>;
FILE *<[fp]>;
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t fputwc_unlocked(<[wc]>, <[fp]>)
+ wchar_t <[wc]>;
+ FILE *<[fp]>;
+
#include <stdio.h>
#include <wchar.h>
wint_t _fputwc_r(<[ptr]>, <[wc]>, <[fp]>)
@@ -70,10 +103,24 @@ TRAD_SYNOPSIS
#include <stdio.h>
#include <wchar.h>
+ wint_t _fputwc_unlocked_r(<[ptr]>, <[wc]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ wchar_t <[wc]>;
+ FILE *<[fp]>;
+
+ #include <stdio.h>
+ #include <wchar.h>
wint_t putwc(<[wc]>, <[fp]>)
wchar_t <[wc]>;
FILE *<[fp]>;
+ #define _GNU_SOURCE
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t putwc_unlocked(<[wc]>, <[fp]>)
+ wchar_t <[wc]>;
+ FILE *<[fp]>;
+
#include <stdio.h>
#include <wchar.h>
wint_t _putwc_r(<[ptr]>, <[wc]>, <[fp]>)
@@ -81,6 +128,13 @@ TRAD_SYNOPSIS
wchar_t <[wc]>;
FILE *<[fp]>;
+ #include <stdio.h>
+ #include <wchar.h>
+ wint_t _putwc_unlocked_r(<[ptr]>, <[wc]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ wchar_t <[wc]>;
+ FILE *<[fp]>;
+
DESCRIPTION
<<fputwc>> writes the wide character argument <[wc]> to the file or
stream identified by <[fp]>.
@@ -91,13 +145,22 @@ file or stream. Otherwise, the new wide character is written at the
current value of the position indicator, and the position indicator
oadvances by one.
-The <<putwc>> function or macro functions identically to <<fputwc>>. It
-may be implemented as a macro, and may evaluate its argument more than
-once. There is no reason ever to use it.
+<<fputwc_unlocked>> is a non-thread-safe version of <<fputwc>>.
+<<fputwc_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fputwc_unlocked>> is equivalent to <<fputwc>>.
+
+The <<putwc>> and <<putwc_unlocked>> functions or macros function identically
+to <<fputwc>> and <<fputwc_unlocked>>. They may be implemented as a macro, and
+may evaluate its argument more than once. There is no reason ever to use them.
-The <<_fputwc_r>> and <<_putwc_r>> functions are simply reentrant versions
-of <<fputwc>> and <<putwc>> that take an additional reentrant structure
-argument: <[ptr]>.
+The <<_fputwc_r>>, <<_putwc_r>>, <<_fputwc_unlocked_r>>, and
+<<_putwc_unlocked_r>> functions are simply reentrant versions of the above
+that take an additional reentrant structure argument: <[ptr]>.
RETURNS
If successful, <<fputwc>> and <<putwc>> return their argument <[wc]>.
@@ -105,7 +168,9 @@ If an error intervenes, the result is <<EOF>>. You can use
`<<ferror(<[fp]>)>>' to query for errors.
PORTABILITY
-C99, POSIX.1-2001
+<<fputwc>> and <<putwc>> are required by C99 and POSIX.1-2001.
+
+<<fputwc_unlocked>> and <<putwc_unlocked>> are GNU extensions.
*/
#include <_ansi.h>
@@ -117,7 +182,7 @@ C99, POSIX.1-2001
#include <wchar.h>
#include "local.h"
-static wint_t
+wint_t
_DEFUN(__fputwc, (ptr, wc, fp),
struct _reent *ptr _AND
wchar_t wc _AND
diff --git a/newlib/libc/stdio/fputwc_u.c b/newlib/libc/stdio/fputwc_u.c
new file mode 100644
index 000000000..43be648f7
--- /dev/null
+++ b/newlib/libc/stdio/fputwc_u.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <_ansi.h>
+#include <stdio.h>
+#include <wchar.h>
+#include "local.h"
+
+wint_t
+_DEFUN(_fputwc_unlocked_r, (ptr, wc, fp),
+ struct _reent *ptr _AND
+ wchar_t wc _AND
+ FILE *fp)
+{
+ ORIENT(fp, 1);
+ return __fputwc(ptr, wc, fp);
+}
+
+wint_t
+_DEFUN(fputwc_unlocked, (wc, fp),
+ wchar_t wc _AND
+ FILE *fp)
+{
+ struct _reent *reent = _REENT;
+
+ CHECK_INIT(reent, fp);
+ return _fputwc_unlocked_r (reent, wc, fp);
+}
diff --git a/newlib/libc/stdio/fputws.c b/newlib/libc/stdio/fputws.c
index 82945996f..bb2fa6dbe 100644
--- a/newlib/libc/stdio/fputws.c
+++ b/newlib/libc/stdio/fputws.c
@@ -26,46 +26,81 @@
/*
FUNCTION
-<<fputws>>---write a wide character string in a file or stream
+<<fputws>>, <<fputws_unlocked>>---write a wide character string in a file or stream
INDEX
fputws
INDEX
+ fputws_unlocked
+INDEX
_fputws_r
+INDEX
+ _fputws_unlocked_r
ANSI_SYNOPSIS
#include <wchar.h>
int fputws(const wchar_t *__restrict <[ws]>, FILE *__restrict <[fp]>);
+ #define _GNU_SOURCE
+ #include <wchar.h>
+ int fputws_unlocked(const wchar_t *__restrict <[ws]>, FILE *__restrict <[fp]>);
+
#include <wchar.h>
int _fputws_r(struct _reent *<[ptr]>, const wchar_t *<[ws]>,
FILE *<[fp]>);
+ #include <wchar.h>
+ int _fputws_unlocked_r(struct _reent *<[ptr]>, const wchar_t *<[ws]>,
+ FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <wchar.h>
int fputws(<[ws]>, <[fp]>)
wchar_t *__restrict <[ws]>;
FILE *__restrict <[fp]>;
+ #define _GNU_SOURCE
+ #include <wchar.h>
+ int fputws_unlocked(<[ws]>, <[fp]>)
+ wchar_t *__restrict <[ws]>;
+ FILE *__restrict <[fp]>;
+
#include <wchar.h>
int _fputws_r(<[ptr]>, <[ws]>, <[fp]>)
struct _reent *<[ptr]>;
wchar_t *<[ws]>;
FILE *<[fp]>;
+ #include <wchar.h>
+ int _fputws_unlocked_r(<[ptr]>, <[ws]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ wchar_t *<[ws]>;
+ FILE *<[fp]>;
+
DESCRIPTION
<<fputws>> writes the wide character string at <[ws]> (but without the
trailing null) to the file or stream identified by <[fp]>.
-<<_fputws_r>> is simply the reentrant version of <<fputws>> that takes
-an additional reentrant struct pointer argument: <[ptr]>.
+<<fputws_unlocked>> is a non-thread-safe version of <<fputws>>.
+<<fputws_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fputws_unlocked>> is equivalent to <<fputws>>.
+
+<<_fputws_r>> and <<_fputws_unlocked_r>> are simply reentrant versions of the
+above that take an additional reentrant struct pointer argument: <[ptr]>.
RETURNS
If successful, the result is a non-negative integer; otherwise, the result
is <<-1>> to indicate an error.
PORTABILITY
-C99, POSIX.1-2001
+<<fputws>> is required by C99 and POSIX.1-2001.
+
+<<fputws_unlocked>> is a GNU extension.
*/
#include <_ansi.h>
@@ -77,6 +112,11 @@ C99, POSIX.1-2001
#include "fvwrite.h"
#include "local.h"
+#ifdef __IMPL_UNLOCKED__
+#define _fputws_r _fputws_unlocked_r
+#define fputws fputws_unlocked
+#endif
+
int
_DEFUN(_fputws_r, (ptr, ws, fp),
struct _reent *ptr _AND
diff --git a/newlib/libc/stdio/fputws_u.c b/newlib/libc/stdio/fputws_u.c
new file mode 100644
index 000000000..0583e79fa
--- /dev/null
+++ b/newlib/libc/stdio/fputws_u.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __IMPL_UNLOCKED__
+#include "fputws.c"
diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c
index cf9ab40b7..d55ff66d8 100644
--- a/newlib/libc/stdio/fread.c
+++ b/newlib/libc/stdio/fread.c
@@ -17,22 +17,35 @@
/*
FUNCTION
-<<fread>>---read array elements from a file
+<<fread>>. <<fread_unlocked>>---read array elements from a file
INDEX
fread
INDEX
+ fread_unlocked
+INDEX
_fread_r
+INDEX
+ _fread_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
size_t fread(void *restrict <[buf]>, size_t <[size]>, size_t <[count]>,
FILE *restrict <[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ size_t fread_unlocked(void *restrict <[buf]>, size_t <[size]>, size_t <[count]>,
+ FILE *restrict <[fp]>);
+
#include <stdio.h>
size_t _fread_r(struct _reent *<[ptr]>, void *restrict <[buf]>,
size_t <[size]>, size_t <[count]>, FILE *restrict <[fp]>);
+ #include <stdio.h>
+ size_t _fread_unlocked_r(struct _reent *<[ptr]>, void *restrict <[buf]>,
+ size_t <[size]>, size_t <[count]>, FILE *restrict <[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
size_t fread(<[buf]>, <[size]>, <[count]>, <[fp]>)
@@ -41,6 +54,14 @@ TRAD_SYNOPSIS
size_t <[count]>;
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ size_t fread_unlocked(<[buf]>, <[size]>, <[count]>, <[fp]>)
+ char *<[buf]>;
+ size_t <[size]>;
+ size_t <[count]>;
+ FILE *<[fp]>;
+
#include <stdio.h>
size_t _fread_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>)
struct _reent *<[ptr]>;
@@ -49,6 +70,14 @@ TRAD_SYNOPSIS
size_t <[count]>;
FILE *<[fp]>;
+ #include <stdio.h>
+ size_t _fread_unlocked_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ char *<[buf]>;
+ size_t <[size]>;
+ size_t <[count]>;
+ FILE *<[fp]>;
+
DESCRIPTION
<<fread>> attempts to copy, from the file or stream identified by
<[fp]>, <[count]> elements (each of size <[size]>) into memory,
@@ -58,8 +87,17 @@ starting at <[buf]>. <<fread>> may copy fewer elements than
<<fread>> also advances the file position indicator (if any) for
<[fp]> by the number of @emph{characters} actually read.
-<<_fread_r>> is simply the reentrant version of <<fread>> that
-takes an additional reentrant structure pointer argument: <[ptr]>.
+<<fread_unlocked>> is a non-thread-safe version of <<fread>>.
+<<fread_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fread_unlocked>> is equivalent to <<fread>>.
+
+<<_fread_r>> and <<_fread_unlocked_r>> are simply reentrant versions of the
+above that take an additional reentrant structure pointer argument: <[ptr]>.
RETURNS
The result of <<fread>> is the number of elements it succeeded in
@@ -68,6 +106,8 @@ reading.
PORTABILITY
ANSI C requires <<fread>>.
+<<fread_unlocked>> is a BSD extension also provided by GNU libc.
+
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
@@ -78,6 +118,11 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <malloc.h>
#include "local.h"
+#ifdef __IMPL_UNLOCKED__
+#define _fread_r _fread_unlocked_r
+#define fread fread_unlocked
+#endif
+
#ifdef __SCLE
static size_t
_DEFUN(crlf_r, (ptr, fp, buf, count, eof),
diff --git a/newlib/libc/stdio/fread_u.c b/newlib/libc/stdio/fread_u.c
new file mode 100644
index 000000000..48239a9aa
--- /dev/null
+++ b/newlib/libc/stdio/fread_u.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __IMPL_UNLOCKED__
+#include "fread.c"
diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c
index f460ae38f..6b3ff9015 100644
--- a/newlib/libc/stdio/fwrite.c
+++ b/newlib/libc/stdio/fwrite.c
@@ -17,22 +17,35 @@
/*
FUNCTION
-<<fwrite>>---write array elements
+<<fwrite>>, <<fwrite_unlocked>>---write array elements
INDEX
fwrite
INDEX
+ fwrite_unlocked
+INDEX
_fwrite_r
+INDEX
+ _fwrite_unlocked_r
ANSI_SYNOPSIS
#include <stdio.h>
size_t fwrite(const void *restrict <[buf]>, size_t <[size]>,
size_t <[count]>, FILE *restrict <[fp]>);
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ size_t fwrite_unlocked(const void *restrict <[buf]>, size_t <[size]>,
+ size_t <[count]>, FILE *restrict <[fp]>);
+
#include <stdio.h>
size_t _fwrite_r(struct _reent *<[ptr]>, const void *restrict <[buf]>, size_t <[size]>,
size_t <[count]>, FILE *restrict <[fp]>);
+ #include <stdio.h>
+ size_t _fwrite_unlocked_r(struct _reent *<[ptr]>, const void *restrict <[buf]>, size_t <[size]>,
+ size_t <[count]>, FILE *restrict <[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
size_t fwrite(<[buf]>, <[size]>, <[count]>, <[fp]>)
@@ -41,6 +54,14 @@ TRAD_SYNOPSIS
size_t <[count]>;
FILE *<[fp]>;
+ #define _BSD_SOURCE
+ #include <stdio.h>
+ size_t fwrite_unlocked(<[buf]>, <[size]>, <[count]>, <[fp]>)
+ char *<[buf]>;
+ size_t <[size]>;
+ size_t <[count]>;
+ FILE *<[fp]>;
+
#include <stdio.h>
size_t _fwrite_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>)
struct _reent *<[ptr]>;
@@ -49,6 +70,14 @@ TRAD_SYNOPSIS
size_t <[count]>;
FILE *<[fp]>;
+ #include <stdio.h>
+ size_t _fwrite_unlocked_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ char *<[buf]>;
+ size_t <[size]>;
+ size_t <[count]>;
+ FILE *<[fp]>;
+
DESCRIPTION
<<fwrite>> attempts to copy, starting from the memory location
<[buf]>, <[count]> elements (each of size <[size]>) into the file or
@@ -58,8 +87,17 @@ stream identified by <[fp]>. <<fwrite>> may copy fewer elements than
<<fwrite>> also advances the file position indicator (if any) for
<[fp]> by the number of @emph{characters} actually written.
-<<_fwrite_r>> is simply the reentrant version of <<fwrite>> that
-takes an additional reentrant structure argument: <[ptr]>.
+<<fwrite_unlocked>> is a non-thread-safe version of <<fwrite>>.
+<<fwrite_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<fwrite_unlocked>> is equivalent to <<fwrite>>.
+
+<<_fwrite_r>> and <<_fwrite_unlocked_r>> are simply reentrant versions of the
+above that take an additional reentrant structure argument: <[ptr]>.
RETURNS
If <<fwrite>> succeeds in writing all the elements you specify, the
@@ -70,6 +108,8 @@ the file.
PORTABILITY
ANSI C requires <<fwrite>>.
+<<fwrite_unlocked>> is a BSD extension also provided by GNU libc.
+
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
@@ -89,6 +129,11 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include "fvwrite.h"
#endif
+#ifdef __IMPL_UNLOCKED__
+#define _fwrite_r _fwrite_unlocked_r
+#define fwrite fwrite_unlocked
+#endif
+
/*
* Write `count' objects (each size `size') from memory to the given file.
* Return the number of whole objects written.
diff --git a/newlib/libc/stdio/fwrite_u.c b/newlib/libc/stdio/fwrite_u.c
new file mode 100644
index 000000000..80154a0bf
--- /dev/null
+++ b/newlib/libc/stdio/fwrite_u.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __IMPL_UNLOCKED__
+#include "fwrite.c"
diff --git a/newlib/libc/stdio/getwc_u.c b/newlib/libc/stdio/getwc_u.c
new file mode 100644
index 000000000..613b69eca
--- /dev/null
+++ b/newlib/libc/stdio/getwc_u.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <wchar.h>
+#include "local.h"
+
+#undef getwc_unlocked
+
+wint_t
+_DEFUN(_getwc_unlocked_r, (ptr, fp),
+ struct _reent *ptr _AND
+ FILE *fp)
+{
+ return _fgetwc_unlocked_r (ptr, fp);
+}
+
+/*
+ * Synonym for fgetwc_unlocked(). The only difference is that getwc(), if it is
+ * a macro, may evaluate `fp' more than once.
+ */
+wint_t
+_DEFUN(getwc_unlocked, (fp),
+ FILE *fp)
+{
+ return fgetwc_unlocked(fp);
+}
diff --git a/newlib/libc/stdio/getwchar.c b/newlib/libc/stdio/getwchar.c
index f559c7677..7ab230a4c 100644
--- a/newlib/libc/stdio/getwchar.c
+++ b/newlib/libc/stdio/getwchar.c
@@ -26,34 +26,65 @@
/*
FUNCTION
-<<getwchar>>---read a wide character from standard input
+<<getwchar>>, <<getwchar_unlocked>>---read a wide character from standard input
INDEX
getwchar
INDEX
+ getwchar_unlocked
+INDEX
_getwchar_r
+INDEX
+ _getwchar_unlocked_r
ANSI_SYNOPSIS
#include <wchar.h>
wint_t getwchar(void);
+ #define _GNU_SOURCE
+ #include <wchar.h>
+ wint_t getwchar_unlocked(void);
+
+ #include <wchar.h>
wint_t _getwchar_r(struct _reent *<[reent]>);
+ #include <wchar.h>
+ wint_t _getwchar_unlocked_r(struct _reent *<[reent]>);
+
TRAD_SYNOPSIS
#include <wchar.h>
wint_t getwchar();
+ #define _GNU_SOURCE
+ #include <wchar.h>
+ wint_t getwchar_unlocked();
+
+ #include <wchar.h>
wint_t _getwchar_r(<[reent]>)
char * <[reent]>;
+ #include <wchar.h>
+ wint_t _getwchar_unlocked_r(<[reent]>)
+ char * <[reent]>;
+
DESCRIPTION
<<getwchar>> function or macro is the wide character equivalent of
the <<getchar>> function. You can use <<getwchar>> to get the next
wide character from the standard input stream. As a side effect,
<<getwchar>> advances the standard input's current position indicator.
-The alternate function <<_getwchar_r>> is a reentrant version. The
-extra argument <[reent]> is a pointer to a reentrancy structure.
+<<getwchar_unlocked>> is a non-thread-safe version of <<getwchar>>.
+<<getwchar_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<getwchar_unlocked>> is equivalent to <<getwchar>>.
+
+The alternate functions <<_getwchar_r>> and <<_getwchar_unlocked_r>> are
+reentrant versions of the above. The extra argument <[reent]> is a pointer to
+a reentrancy structure.
RETURNS
The next wide character cast to <<wint_t>>, unless there is no more
@@ -64,7 +95,9 @@ You can distinguish the two situations that cause an <<WEOF>> result by
using `<<ferror(stdin)>>' and `<<feof(stdin)>>'.
PORTABILITY
-C99
+<<getwchar>> is required by C99.
+
+<<getwchar_unlocked>> is a GNU extension.
*/
#include <_ansi.h>
diff --git a/newlib/libc/stdio/getwchar_u.c b/newlib/libc/stdio/getwchar_u.c
new file mode 100644
index 000000000..f5c50cced
--- /dev/null
+++ b/newlib/libc/stdio/getwchar_u.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <wchar.h>
+#include "local.h"
+
+#undef getwchar_unlocked
+
+wint_t
+_DEFUN (_getwchar_unlocked_r, (ptr),
+ struct _reent *ptr)
+{
+ return _fgetwc_unlocked_r (ptr, stdin);
+}
+
+/*
+ * Synonym for fgetwc_unlocked(stdin).
+ */
+wint_t
+_DEFUN_VOID (getwchar_unlocked)
+{
+ _REENT_SMALL_CHECK_INIT (_REENT);
+ return fgetwc_unlocked (stdin);
+}
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h
index 434d3f85c..cf8e6a921 100644
--- a/newlib/libc/stdio/local.h
+++ b/newlib/libc/stdio/local.h
@@ -60,7 +60,16 @@
#define _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
#endif
-#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
+#if defined(__SINGLE_THREAD__) || defined(__IMPL_UNLOCKED__)
+
+# define _newlib_flockfile_start(_fp)
+# define _newlib_flockfile_exit(_fp)
+# define _newlib_flockfile_end(_fp)
+# define _newlib_sfp_lock_start()
+# define _newlib_sfp_lock_exit()
+# define _newlib_sfp_lock_end()
+
+#elif defined(_STDIO_WITH_THREAD_CANCELLATION_SUPPORT)
#include <pthread.h>
/* Start a stream oriented critical section: */
@@ -102,7 +111,7 @@
pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \
}
-#elif !defined(__SINGLE_THREAD__) /* !_STDIO_WITH_THREAD_CANCELLATION_SUPPORT */
+#else /* !__SINGLE_THREAD__ && !__IMPL_UNLOCKED__ && !_STDIO_WITH_THREAD_CANCELLATION_SUPPORT */
# define _newlib_flockfile_start(_fp) \
{ \
@@ -129,17 +138,10 @@
__sfp_lock_release (); \
}
-#else /* __SINGLE_THREAD__ */
-
-# define _newlib_flockfile_start(_fp)
-# define _newlib_flockfile_exit(_fp)
-# define _newlib_flockfile_end(_fp)
-# define _newlib_sfp_lock_start()
-# define _newlib_sfp_lock_exit()
-# define _newlib_sfp_lock_end()
-
-#endif /* _STDIO_WITH_THREAD_CANCELLATION_SUPPORT */
+#endif /* __SINGLE_THREAD__ || __IMPL_UNLOCKED__ */
+extern wint_t _EXFUN(__fgetwc, (struct _reent *, FILE *));
+extern wint_t _EXFUN(__fputwc, (struct _reent *, wchar_t, FILE *));
extern u_char *_EXFUN(__sccl, (char *, u_char *fmt));
extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
extern int _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
diff --git a/newlib/libc/stdio/putwc_u.c b/newlib/libc/stdio/putwc_u.c
new file mode 100644
index 000000000..bb71acc2a
--- /dev/null
+++ b/newlib/libc/stdio/putwc_u.c
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <wchar.h>
+#include "local.h"
+
+#undef putwc_unlocked
+
+wint_t
+_DEFUN(_putwc_unlocked_r, (ptr, wc, fp),
+ struct _reent *ptr _AND
+ wchar_t wc _AND
+ FILE *fp)
+{
+ return _fputwc_unlocked_r (ptr, wc, fp);
+}
+/*
+ * Synonym for fputwc_unlocked(). The only difference is that putwc_unlocked(),
+ * if it is a macro, may evaluate `fp' more than once.
+ */
+wint_t
+_DEFUN(putwc_unlocked, (wc, fp),
+ wchar_t wc _AND
+ FILE *fp)
+{
+ return fputwc_unlocked (wc, fp);
+}
diff --git a/newlib/libc/stdio/putwchar.c b/newlib/libc/stdio/putwchar.c
index fcb0a7dba..cdd254217 100644
--- a/newlib/libc/stdio/putwchar.c
+++ b/newlib/libc/stdio/putwchar.c
@@ -26,34 +26,65 @@
/*
FUNCTION
-<<putwchar>>---write a wide character to standard output
+<<putwchar>>, <<putwchar_unlocked>>---write a wide character to standard output
INDEX
putwchar
INDEX
+ putwchar_unlocked
+INDEX
_putwchar_r
+INDEX
+ _putwchar_unlocked_r
ANSI_SYNOPSIS
#include <wchar.h>
wint_t putwchar(wchar_t <[wc]>);
+ #include <wchar.h>
+ wint_t putwchar_unlocked(wchar_t <[wc]>);
+
+ #include <wchar.h>
wint_t _putwchar_r(struct _reent *<[reent]>, wchar_t <[wc]>);
+ #include <wchar.h>
+ wint_t _putwchar_unlocked_r(struct _reent *<[reent]>, wchar_t <[wc]>);
+
TRAD_SYNOPSIS
#include <wchar.h>
wint_t putwchar(<[wc]>)
wchar_t <[wc]>;
+ #include <wchar.h>
+ wint_t putwchar_unlocked(<[wc]>)
+ wchar_t <[wc]>;
+
+ #include <wchar.h>
wint_t _putwchar_r(<[reent]>, <[wc]>)
struct _reent *<[reent]>;
wchar_t <[wc]>;
+ #include <wchar.h>
+ wint_t _putwchar_unlocked_r(<[reent]>, <[wc]>)
+ struct _reent *<[reent]>;
+ wchar_t <[wc]>;
+
DESCRIPTION
The <<putwchar>> function or macro is the wide-character equivalent of
the <<putchar>> function. It writes the wide character wc to stdout.
-The alternate function <<_putwchar_r>> is a reentrant version. The
-extra argument <[reent]> is a pointer to a reentrancy structure.
+<<putwchar_unlocked>> is a non-thread-safe version of <<putwchar>>.
+<<putwchar_unlocked>> may only safely be used within a scope
+protected by flockfile() (or ftrylockfile()) and funlockfile(). This
+function may safely be used in a multi-threaded program if and only
+if they are called while the invoking thread owns the (FILE *)
+object, as is the case after a successful call to the flockfile() or
+ftrylockfile() functions. If threads are disabled, then
+<<putwchar_unlocked>> is equivalent to <<putwchar>>.
+
+The alternate functions <<_putwchar_r>> and <<_putwchar_unlocked_r>> are
+reentrant versions of the above. The extra argument <[reent]> is a pointer
+to a reentrancy structure.
RETURNS
If successful, <<putwchar>> returns its argument <[wc]>. If an error
@@ -61,7 +92,9 @@ intervenes, the result is <<EOF>>. You can use `<<ferror(stdin)>>' to
query for errors.
PORTABILITY
-C99
+<<putwchar>> is required by C99.
+
+<<putwchar_unlocked>> is a GNU extension.
*/
#include <_ansi.h>
diff --git a/newlib/libc/stdio/putwchar_u.c b/newlib/libc/stdio/putwchar_u.c
new file mode 100644
index 000000000..3235472a2
--- /dev/null
+++ b/newlib/libc/stdio/putwchar_u.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <wchar.h>
+#include "local.h"
+
+#undef putwchar_unlocked
+
+wint_t
+_DEFUN(_putwchar_unlocked_r, (ptr, wc),
+ struct _reent *ptr _AND
+ wchar_t wc)
+{
+ return _fputwc_unlocked_r (ptr, wc, stdout);
+}
+
+/*
+ * Synonym for fputwc_unlocked(wc, stdout).
+ */
+wint_t
+_DEFUN(putwchar_unlocked, (wc),
+ wchar_t wc)
+{
+ _REENT_SMALL_CHECK_INIT (_REENT);
+ return fputwc_unlocked (wc, stdout);
+}