Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r--newlib/libc/stdio/asiprintf.c4
-rw-r--r--newlib/libc/stdio/asprintf.c4
-rw-r--r--newlib/libc/stdio/clearerr.c4
-rw-r--r--newlib/libc/stdio/fclose.c12
-rw-r--r--newlib/libc/stdio/fdopen.c4
-rw-r--r--newlib/libc/stdio/feof.c4
-rw-r--r--newlib/libc/stdio/ferror.c4
-rw-r--r--newlib/libc/stdio/fflush.c4
-rw-r--r--newlib/libc/stdio/fgetc.c8
-rw-r--r--newlib/libc/stdio/fgets.c12
-rw-r--r--newlib/libc/stdio/fgetwc.c4
-rw-r--r--newlib/libc/stdio/fgetws.c16
-rw-r--r--newlib/libc/stdio/fileno.c13
-rw-r--r--newlib/libc/stdio/findfp.c11
-rw-r--r--newlib/libc/stdio/fmemopen.c8
-rw-r--r--newlib/libc/stdio/fopen.c8
-rw-r--r--newlib/libc/stdio/fopencookie.c8
-rw-r--r--newlib/libc/stdio/fpurge.c6
-rw-r--r--newlib/libc/stdio/fputc.c8
-rw-r--r--newlib/libc/stdio/fputs.c4
-rw-r--r--newlib/libc/stdio/fputwc.c4
-rw-r--r--newlib/libc/stdio/fputws.c6
-rw-r--r--newlib/libc/stdio/fread.c14
-rw-r--r--newlib/libc/stdio/freopen.c17
-rw-r--r--newlib/libc/stdio/fseek.c18
-rw-r--r--newlib/libc/stdio/ftell.c8
-rw-r--r--newlib/libc/stdio/funopen.c8
-rw-r--r--newlib/libc/stdio/fwide.c4
-rw-r--r--newlib/libc/stdio/fwrite.c6
-rw-r--r--newlib/libc/stdio/getc.c8
-rw-r--r--newlib/libc/stdio/getdelim.c4
-rw-r--r--newlib/libc/stdio/gets.c7
-rw-r--r--newlib/libc/stdio/local.h77
-rw-r--r--newlib/libc/stdio/mktemp.c2
-rw-r--r--newlib/libc/stdio/open_memstream.c12
-rw-r--r--newlib/libc/stdio/putc.c8
-rw-r--r--newlib/libc/stdio/setvbuf.c8
-rw-r--r--newlib/libc/stdio/ungetc.c14
-rw-r--r--newlib/libc/stdio/ungetwc.c4
-rw-r--r--newlib/libc/stdio/vasiprintf.c2
-rw-r--r--newlib/libc/stdio/vasprintf.c2
-rw-r--r--newlib/libc/stdio/vfprintf.c18
-rw-r--r--newlib/libc/stdio/vfscanf.c25
-rw-r--r--newlib/libc/stdio/vfwprintf.c19
-rw-r--r--newlib/libc/stdio/vfwscanf.c18
45 files changed, 168 insertions, 291 deletions
diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c
index 0c363d5ea..97474fd1a 100644
--- a/newlib/libc/stdio/asiprintf.c
+++ b/newlib/libc/stdio/asiprintf.c
@@ -45,7 +45,7 @@ _DEFUN(_asiprintf_r, (ptr, strp, fmt),
if (ret >= 0)
{
*f._p = 0;
- *strp = (char *) f._bf._base;
+ *strp = f._bf._base;
}
return (ret);
}
@@ -72,7 +72,7 @@ _DEFUN(asiprintf, (strp, fmt),
if (ret >= 0)
{
*f._p = 0;
- *strp = (char *) f._bf._base;
+ *strp = f._bf._base;
}
return (ret);
}
diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c
index 7b26d9f29..59a08c808 100644
--- a/newlib/libc/stdio/asprintf.c
+++ b/newlib/libc/stdio/asprintf.c
@@ -45,7 +45,7 @@ _DEFUN(_asprintf_r, (ptr, strp, fmt),
if (ret >= 0)
{
*f._p = 0;
- *strp = (char *) f._bf._base;
+ *strp = f._bf._base;
}
return (ret);
}
@@ -72,7 +72,7 @@ _DEFUN(asprintf, (strp, fmt),
if (ret >= 0)
{
*f._p = 0;
- *strp = (char *) f._bf._base;
+ *strp = f._bf._base;
}
return (ret);
}
diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c
index ed4603ba2..d3b620bed 100644
--- a/newlib/libc/stdio/clearerr.c
+++ b/newlib/libc/stdio/clearerr.c
@@ -65,7 +65,7 @@ _DEFUN(clearerr, (fp),
FILE * fp)
{
CHECK_INIT(_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
__sclearerr (fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
}
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index 790496413..3c8868a51 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -76,20 +76,11 @@ _DEFUN(_fclose_r, (rptr, fp),
CHECK_INIT (rptr, fp);
- /* We can't use the _newlib_flockfile_XXX macros here due to the
- interlocked locking with the sfp_lock. */
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
- int __oldcancel;
- pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
-#endif
_flockfile (fp);
if (fp->_flags == 0) /* not open! */
{
_funlockfile (fp);
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
- pthread_setcancelstate (__oldcancel, &__oldcancel);
-#endif
return (0);
}
/* Unconditionally flush to allow special handling for seekable read
@@ -112,9 +103,6 @@ _DEFUN(_fclose_r, (rptr, fp),
#endif
__sfp_lock_release ();
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
- pthread_setcancelstate (__oldcancel, &__oldcancel);
-#endif
return (r);
}
diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c
index 77f599b65..aa764c372 100644
--- a/newlib/libc/stdio/fdopen.c
+++ b/newlib/libc/stdio/fdopen.c
@@ -93,7 +93,7 @@ _DEFUN(_fdopen_r, (ptr, fd, mode),
if ((fp = __sfp (ptr)) == 0)
return 0;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
fp->_flags = flags;
/* POSIX recommends setting the O_APPEND bit on fd to match append
@@ -127,7 +127,7 @@ _DEFUN(_fdopen_r, (ptr, fd, mode),
fp->_flags |= __SCLE;
#endif
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return fp;
}
diff --git a/newlib/libc/stdio/feof.c b/newlib/libc/stdio/feof.c
index c0216ffed..e8db65b86 100644
--- a/newlib/libc/stdio/feof.c
+++ b/newlib/libc/stdio/feof.c
@@ -58,8 +58,8 @@ _DEFUN(feof, (fp),
{
int result;
CHECK_INIT(_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sfeof (fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
}
diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c
index 0cd3c3089..72b7ce2c5 100644
--- a/newlib/libc/stdio/ferror.c
+++ b/newlib/libc/stdio/ferror.c
@@ -67,8 +67,8 @@ _DEFUN(ferror, (fp),
{
int result;
CHECK_INIT(_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sferror (fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
}
diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c
index b2bde7af5..130c148c9 100644
--- a/newlib/libc/stdio/fflush.c
+++ b/newlib/libc/stdio/fflush.c
@@ -226,9 +226,9 @@ _DEFUN(_fflush_r, (ptr, fp),
if (!fp->_flags)
return 0;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ret = __sflush_r (ptr, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return ret;
}
diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c
index 99d8330fe..e275cfeeb 100644
--- a/newlib/libc/stdio/fgetc.c
+++ b/newlib/libc/stdio/fgetc.c
@@ -78,9 +78,9 @@ _DEFUN(_fgetc_r, (ptr, fp),
{
int result;
CHECK_INIT(ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sgetc_r (ptr, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
}
@@ -93,9 +93,9 @@ _DEFUN(fgetc, (fp),
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
int result;
CHECK_INIT(_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sgetc_r (_REENT, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
#else
return _fgetc_r (_REENT, fp);
diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c
index 1644fba6a..7f02e3fcb 100644
--- a/newlib/libc/stdio/fgets.c
+++ b/newlib/libc/stdio/fgets.c
@@ -98,7 +98,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
CHECK_INIT(ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
#ifdef __SCLE
if (fp->_flags & __SCLE)
{
@@ -112,11 +112,11 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
}
if (c == EOF && s == buf)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return NULL;
}
*s = 0;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return buf;
}
#endif
@@ -134,7 +134,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
/* EOF: stop with partial or no line */
if (s == buf)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return 0;
}
break;
@@ -159,7 +159,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
fp->_p = t;
_CAST_VOID memcpy ((_PTR) s, (_PTR) p, len);
s[len] = 0;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (buf);
}
fp->_r -= len;
@@ -169,7 +169,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
}
while ((n -= len) != 0);
*s = 0;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return buf;
}
diff --git a/newlib/libc/stdio/fgetwc.c b/newlib/libc/stdio/fgetwc.c
index 0eaaecb2f..38a79bc7c 100644
--- a/newlib/libc/stdio/fgetwc.c
+++ b/newlib/libc/stdio/fgetwc.c
@@ -164,10 +164,10 @@ _DEFUN(_fgetwc_r, (ptr, fp),
{
wint_t r;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT(fp, 1);
r = __fgetwc (ptr, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return r;
}
diff --git a/newlib/libc/stdio/fgetws.c b/newlib/libc/stdio/fgetws.c
index 3cf45a976..2784f1513 100644
--- a/newlib/libc/stdio/fgetws.c
+++ b/newlib/libc/stdio/fgetws.c
@@ -93,7 +93,7 @@ _DEFUN(_fgetws_r, (ptr, ws, n, fp),
const char *src;
unsigned char *nl;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, 1);
if (n <= 0)
@@ -110,13 +110,9 @@ _DEFUN(_fgetws_r, (ptr, ws, n, fp),
{
src = (char *) fp->_p;
nl = memchr (fp->_p, '\n', fp->_r);
- nconv = _mbsnrtowcs_r (ptr, wsp, &src,
- /* Read all bytes up to the next NL, or up to the
- end of the buffer if there is no NL. */
- nl != NULL ? (nl - fp->_p + 1) : fp->_r,
- /* But never more than n - 1 wide chars. */
- n - 1,
- &fp->_mbstate);
+ nconv = _mbsrtowcs_r (ptr, wsp, &src,
+ nl != NULL ? (nl - fp->_p + 1) : fp->_r,
+ &fp->_mbstate);
if (nconv == (size_t) -1)
/* Conversion error */
goto error;
@@ -146,11 +142,11 @@ _DEFUN(_fgetws_r, (ptr, ws, n, fp),
/* Incomplete character */
goto error;
*wsp++ = L'\0';
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return ws;
error:
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return NULL;
}
diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c
index be8f3d66a..db399eb12 100644
--- a/newlib/libc/stdio/fileno.c
+++ b/newlib/libc/stdio/fileno.c
@@ -47,7 +47,6 @@ Supporting OS subroutines required: none.
#include <_ansi.h>
#include <stdio.h>
-#include <errno.h>
#include "local.h"
int
@@ -56,14 +55,8 @@ _DEFUN(fileno, (f),
{
int result;
CHECK_INIT (_REENT, f);
- _newlib_flockfile_start (f);
- if (f->_flags)
- result = __sfileno (f);
- else
- {
- result = -1;
- _REENT->_errno = EBADF;
- }
- _newlib_flockfile_end (f);
+ _flockfile (f);
+ result = __sfileno (f);
+ _funlockfile (f);
return result;
}
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index 0beb1e5b0..d81241434 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -108,7 +108,7 @@ _DEFUN(__sfp, (d),
int n;
struct _glue *g;
- _newlib_sfp_lock_start ();
+ __sfp_lock_acquire ();
if (!_GLOBAL_REENT->__sdidinit)
__sinit (_GLOBAL_REENT);
@@ -121,7 +121,7 @@ _DEFUN(__sfp, (d),
(g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL)
break;
}
- _newlib_sfp_lock_exit ();
+ __sfp_lock_release ();
d->_errno = ENOMEM;
return NULL;
@@ -132,7 +132,7 @@ found:
#ifndef __SINGLE_THREAD__
__lock_init_recursive (fp->_lock);
#endif
- _newlib_sfp_lock_end ();
+ __sfp_lock_release ();
fp->_p = NULL; /* no current pointer */
fp->_w = 0; /* nothing to read or write */
@@ -200,11 +200,6 @@ _DEFUN(__sinit, (s),
#else
s->__sglue._niobs = 0;
s->__sglue._iobs = NULL;
- /* Avoid infinite recursion when calling __sfp for _GLOBAL_REENT. The
- problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls
- __sinit if it's 0. */
- if (s == _GLOBAL_REENT)
- s->__sdidinit = 1;
s->_stdin = __sfp(s);
s->_stdout = __sfp(s);
s->_stderr = __sfp(s);
diff --git a/newlib/libc/stdio/fmemopen.c b/newlib/libc/stdio/fmemopen.c
index acfb23c1b..5218e8a98 100644
--- a/newlib/libc/stdio/fmemopen.c
+++ b/newlib/libc/stdio/fmemopen.c
@@ -291,12 +291,12 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode),
if ((c = (fmemcookie *) _malloc_r (ptr, sizeof *c + (buf ? 0 : size)))
== NULL)
{
- _newlib_sfp_lock_start ();
+ __sfp_lock_acquire ();
fp->_flags = 0; /* release */
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
- _newlib_sfp_lock_end ();
+ __sfp_lock_release ();
return NULL;
}
@@ -343,7 +343,7 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode),
}
}
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
fp->_file = -1;
fp->_flags = flags;
fp->_cookie = c;
@@ -355,7 +355,7 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode),
fp->_flags |= __SL64;
#endif
fp->_close = fmemcloser;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return fp;
}
diff --git a/newlib/libc/stdio/fopen.c b/newlib/libc/stdio/fopen.c
index 27d4bc810..64c24e7ef 100644
--- a/newlib/libc/stdio/fopen.c
+++ b/newlib/libc/stdio/fopen.c
@@ -140,16 +140,16 @@ _DEFUN(_fopen_r, (ptr, file, mode),
if ((f = _open_r (ptr, file, oflags, 0666)) < 0)
{
- _newlib_sfp_lock_start ();
+ __sfp_lock_acquire ();
fp->_flags = 0; /* release */
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
- _newlib_sfp_lock_end ();
+ __sfp_lock_release ();
return NULL;
}
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
fp->_file = f;
fp->_flags = flags;
@@ -167,7 +167,7 @@ _DEFUN(_fopen_r, (ptr, file, mode),
fp->_flags |= __SCLE;
#endif
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return fp;
}
diff --git a/newlib/libc/stdio/fopencookie.c b/newlib/libc/stdio/fopencookie.c
index f08d13289..5148c8a1a 100644
--- a/newlib/libc/stdio/fopencookie.c
+++ b/newlib/libc/stdio/fopencookie.c
@@ -219,16 +219,16 @@ _DEFUN(_fopencookie_r, (ptr, cookie, mode, functions),
return NULL;
if ((c = (fccookie *) _malloc_r (ptr, sizeof *c)) == NULL)
{
- _newlib_sfp_lock_start ();
+ __sfp_lock_acquire ();
fp->_flags = 0; /* release */
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
- _newlib_sfp_lock_end ();
+ __sfp_lock_release ();
return NULL;
}
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
fp->_file = -1;
fp->_flags = flags;
c->cookie = cookie;
@@ -246,7 +246,7 @@ _DEFUN(_fopencookie_r, (ptr, cookie, mode, functions),
#endif
c->closefn = functions.close;
fp->_close = fccloser;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return fp;
}
diff --git a/newlib/libc/stdio/fpurge.c b/newlib/libc/stdio/fpurge.c
index dc052e85b..7e23bb7fd 100644
--- a/newlib/libc/stdio/fpurge.c
+++ b/newlib/libc/stdio/fpurge.c
@@ -68,13 +68,13 @@ _DEFUN(_fpurge_r, (ptr, fp),
CHECK_INIT (ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
t = fp->_flags;
if (!t)
{
ptr->_errno = EBADF;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
fp->_p = fp->_bf._base;
@@ -86,7 +86,7 @@ _DEFUN(_fpurge_r, (ptr, fp),
}
else
fp->_w = t & (__SLBF | __SNBF) ? 0 : fp->_bf._size;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return 0;
}
diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c
index 6af79d470..777a34242 100644
--- a/newlib/libc/stdio/fputc.c
+++ b/newlib/libc/stdio/fputc.c
@@ -83,9 +83,9 @@ _DEFUN(_fputc_r, (ptr, ch, file),
{
int result;
CHECK_INIT(ptr, file);
- _newlib_flockfile_start (file);
+ _flockfile (file);
result = _putc_r (ptr, ch, file);
- _newlib_flockfile_end (file);
+ _funlockfile (file);
return result;
}
@@ -98,9 +98,9 @@ _DEFUN(fputc, (ch, file),
#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED)
int result;
CHECK_INIT(_REENT, file);
- _newlib_flockfile_start (file);
+ _flockfile (file);
result = _putc_r (_REENT, ch, file);
- _newlib_flockfile_end (file);
+ _funlockfile (file);
return result;
#else
return _fputc_r (_REENT, ch, file);
diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c
index 6e623a530..a32dea4e2 100644
--- a/newlib/libc/stdio/fputs.c
+++ b/newlib/libc/stdio/fputs.c
@@ -88,10 +88,10 @@ _DEFUN(_fputs_r, (ptr, s, fp),
CHECK_INIT(ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, -1);
result = __sfvwrite_r (ptr, fp, &uio);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
}
diff --git a/newlib/libc/stdio/fputwc.c b/newlib/libc/stdio/fputwc.c
index 74e7a452c..f32d56675 100644
--- a/newlib/libc/stdio/fputwc.c
+++ b/newlib/libc/stdio/fputwc.c
@@ -160,10 +160,10 @@ _DEFUN(_fputwc_r, (ptr, wc, fp),
{
wint_t r;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT(fp, 1);
r = __fputwc(ptr, wc, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return r;
}
diff --git a/newlib/libc/stdio/fputws.c b/newlib/libc/stdio/fputws.c
index c88111cb0..b8e5d1e0b 100644
--- a/newlib/libc/stdio/fputws.c
+++ b/newlib/libc/stdio/fputws.c
@@ -87,7 +87,7 @@ _DEFUN(_fputws_r, (ptr, ws, fp),
struct __suio uio;
struct __siov iov;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, 1);
if (cantwrite (ptr, fp) != 0)
goto error;
@@ -104,11 +104,11 @@ _DEFUN(_fputws_r, (ptr, ws, fp),
goto error;
}
while (ws != NULL);
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (0);
error:
- _newlib_flockfile_end(fp);
+ _funlockfile(fp);
return (-1);
}
diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c
index 07fe0af5c..a39e9d85f 100644
--- a/newlib/libc/stdio/fread.c
+++ b/newlib/libc/stdio/fread.c
@@ -146,7 +146,7 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
CHECK_INIT(ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, -1);
if (fp->_r < 0)
fp->_r = 0;
@@ -195,11 +195,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
#ifdef __SCLE
if (fp->_flags & __SCLE)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return crlf_r (ptr, fp, buf, total-resid, 1) / size;
}
#endif
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (total - resid) / size;
}
}
@@ -220,11 +220,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
#ifdef __SCLE
if (fp->_flags & __SCLE)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return crlf_r (ptr, fp, buf, total-resid, 1) / size;
}
#endif
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (total - resid) / size;
}
}
@@ -237,11 +237,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
#ifdef __SCLE
if (fp->_flags & __SCLE)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return crlf_r(ptr, fp, buf, total, 0) / size;
}
#endif
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return count;
}
diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c
index b33eb1e22..172006259 100644
--- a/newlib/libc/stdio/freopen.c
+++ b/newlib/libc/stdio/freopen.c
@@ -100,20 +100,11 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
CHECK_INIT (ptr, fp);
- /* We can't use the _newlib_flockfile_XXX macros here due to the
- interlocked locking with the sfp_lock. */
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
- int __oldcancel;
- pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
-#endif
_flockfile (fp);
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
{
_funlockfile (fp);
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
- pthread_setcancelstate (__oldcancel, &__oldcancel);
-#endif
_fclose_r (ptr, fp);
return NULL;
}
@@ -208,7 +199,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
if (HASLB (fp))
FREELB (ptr, fp);
fp->_lb._size = 0;
- fp->_flags &= ~__SORD;
+ fp->_flags & ~__SORD;
fp->_flags2 = 0;
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
@@ -222,9 +213,6 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
__lock_close_recursive (fp->_lock);
#endif
__sfp_lock_release ();
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
- pthread_setcancelstate (__oldcancel, &__oldcancel);
-#endif
return NULL;
}
@@ -242,9 +230,6 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
#endif
_funlockfile (fp);
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
- pthread_setcancelstate (__oldcancel, &__oldcancel);
-#endif
return fp;
}
diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c
index 099a95892..c78d2b26c 100644
--- a/newlib/libc/stdio/fseek.c
+++ b/newlib/libc/stdio/fseek.c
@@ -138,7 +138,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
CHECK_INIT (ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
/* If we've been doing some writing, and we're in append mode
then we don't really know where the filepos is. */
@@ -154,7 +154,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
if ((seekfn = fp->_seek) == NULL)
{
ptr->_errno = ESPIPE; /* ??? */
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
@@ -179,7 +179,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
curoff = seekfn (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR);
if (curoff == -1L)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
}
@@ -204,7 +204,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
default:
ptr->_errno = EINVAL;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (EOF);
}
@@ -263,7 +263,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
if ((long)target != target)
{
ptr->_errno = EOVERFLOW;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
@@ -319,7 +319,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
FREEUB (ptr, fp);
fp->_flags &= ~__SEOF;
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return 0;
}
@@ -349,7 +349,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
fp->_r -= n;
}
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return 0;
/*
@@ -361,7 +361,7 @@ dumb:
if (_fflush_r (ptr, fp)
|| seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
/* success: clear EOF indicator and discard ungetc() data */
@@ -379,7 +379,7 @@ dumb:
is performed. */
fp->_flags &= ~__SNPT;
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return 0;
}
diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c
index 54a656c09..816cafa76 100644
--- a/newlib/libc/stdio/ftell.c
+++ b/newlib/libc/stdio/ftell.c
@@ -109,12 +109,12 @@ _DEFUN(_ftell_r, (ptr, fp),
CHECK_INIT (ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
if (fp->_seek == NULL)
{
ptr->_errno = ESPIPE;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return -1L;
}
@@ -131,7 +131,7 @@ _DEFUN(_ftell_r, (ptr, fp),
pos = fp->_seek (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR);
if (pos == -1L)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return pos;
}
}
@@ -156,7 +156,7 @@ _DEFUN(_ftell_r, (ptr, fp),
pos += fp->_p - fp->_bf._base;
}
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
if ((long)pos != pos)
{
pos = -1;
diff --git a/newlib/libc/stdio/funopen.c b/newlib/libc/stdio/funopen.c
index 065ed93d7..35a274f7b 100644
--- a/newlib/libc/stdio/funopen.c
+++ b/newlib/libc/stdio/funopen.c
@@ -214,16 +214,16 @@ _DEFUN(_funopen_r, (ptr, cookie, readfn, writefn, seekfn, closefn),
return NULL;
if ((c = (funcookie *) _malloc_r (ptr, sizeof *c)) == NULL)
{
- _newlib_sfp_lock_start ();
+ __sfp_lock_acquire ();
fp->_flags = 0; /* release */
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
- _newlib_sfp_lock_end ();
+ __sfp_lock_release ();
return NULL;
}
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
fp->_file = -1;
c->cookie = (void *) cookie; /* cast away const */
fp->_cookie = c;
@@ -260,7 +260,7 @@ _DEFUN(_funopen_r, (ptr, cookie, readfn, writefn, seekfn, closefn),
#endif
c->closefn = closefn;
fp->_close = funcloser;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return fp;
}
diff --git a/newlib/libc/stdio/fwide.c b/newlib/libc/stdio/fwide.c
index a060d8f65..e298f911a 100644
--- a/newlib/libc/stdio/fwide.c
+++ b/newlib/libc/stdio/fwide.c
@@ -68,7 +68,7 @@ _DEFUN(_fwide_r, (ptr, fp, mode),
CHECK_INIT(ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
if (mode != 0) {
ORIENT (fp, mode);
}
@@ -76,7 +76,7 @@ _DEFUN(_fwide_r, (ptr, fp, mode),
ret = 0;
else
ret = (fp->_flags2 & __SWID) ? 1 : -1;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return ret;
}
diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c
index dc218050e..ce77c8dc1 100644
--- a/newlib/libc/stdio/fwrite.c
+++ b/newlib/libc/stdio/fwrite.c
@@ -119,14 +119,14 @@ _DEFUN(_fwrite_r, (ptr, buf, size, count, fp),
CHECK_INIT(ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, -1);
if (__sfvwrite_r (ptr, fp, &uio) == 0)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return count;
}
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return (n - uio.uio_resid) / size;
}
diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c
index 355b19131..5b1fa888a 100644
--- a/newlib/libc/stdio/getc.c
+++ b/newlib/libc/stdio/getc.c
@@ -92,9 +92,9 @@ _DEFUN(_getc_r, (ptr, fp),
{
int result;
CHECK_INIT (ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sgetc_r (ptr, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
}
@@ -106,9 +106,9 @@ _DEFUN(getc, (fp),
{
int result;
CHECK_INIT (_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sgetc_r (_REENT, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
}
diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c
index 63a579a79..23fc50218 100644
--- a/newlib/libc/stdio/getdelim.c
+++ b/newlib/libc/stdio/getdelim.c
@@ -81,7 +81,7 @@ _DEFUN(__getdelim, (bufptr, n, delim, fp),
CHECK_INIT (_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
numbytes = *n;
ptr = buf;
@@ -129,7 +129,7 @@ _DEFUN(__getdelim, (bufptr, n, delim, fp),
}
}
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
/* if no input data, return failure */
if (ptr == buf)
diff --git a/newlib/libc/stdio/gets.c b/newlib/libc/stdio/gets.c
index f51d46196..17d144316 100644
--- a/newlib/libc/stdio/gets.c
+++ b/newlib/libc/stdio/gets.c
@@ -70,7 +70,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
-#include "local.h"
char *
_DEFUN(_gets_r, (ptr, buf),
@@ -80,12 +79,12 @@ _DEFUN(_gets_r, (ptr, buf),
register int c;
register char *s = buf;
- _newlib_flockfile_start (stdin);
+ _flockfile (stdin);
while ((c = __sgetc_r (ptr, stdin)) != '\n')
if (c == EOF)
if (s == buf)
{
- _newlib_flockfile_exit (stdin);
+ _funlockfile (stdin);
return NULL;
}
else
@@ -93,7 +92,7 @@ _DEFUN(_gets_r, (ptr, buf),
else
*s++ = c;
*s = 0;
- _newlib_flockfile_end (stdin);
+ _funlockfile (stdin);
return buf;
}
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h
index b4bc5e01a..187f7d858 100644
--- a/newlib/libc/stdio/local.h
+++ b/newlib/libc/stdio/local.h
@@ -32,83 +32,6 @@
# include <io.h>
#endif
-/* The following macros are supposed to replace calls to _flockfile/_funlockfile
- and __sfp_lock_acquire/__sfp_lock_release. In case of multi-threaded
- environments using pthreads, it's not sufficient to lock the stdio functions
- against concurrent threads accessing the same data, the locking must also be
- secured against thread cancellation.
-
- The below macros have to be used in pairs. The _newlib_XXX_start macro
- starts with a opening curly brace, the _newlib_XXX_end macro ends with a
- closing curly brace, so the start macro and the end macro mark the code
- start and end of a critical section. In case the code leaves the critical
- section before reaching the end of the critical section's code end, use
- the appropriate _newlib_XXX_exit macro. */
-
-#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
-#include <pthread.h>
-
-/* Start a stream oriented critical section: */
-# define _newlib_flockfile_start(_fp) \
- { \
- int __oldfpcancel; \
- pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldfpcancel); \
- _flockfile (_fp)
-
-/* Exit from a stream oriented critical section prematurely: */
-# define _newlib_flockfile_exit(_fp) \
- _funlockfile (_fp); \
- pthread_setcancelstate (__oldfpcancel, &__oldfpcancel);
-
-/* End a stream oriented critical section: */
-# define _newlib_flockfile_end(_fp) \
- _funlockfile (_fp); \
- pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); \
- }
-
-/* Start a stream list oriented critical section: */
-# define _newlib_sfp_lock_start() \
- { \
- int __oldsfpcancel; \
- pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldsfpcancel); \
- __sfp_lock_acquire ()
-
-/* Exit from a stream list oriented critical section prematurely: */
-# define _newlib_sfp_lock_exit() \
- __sfp_lock_release (); \
- pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel);
-
-/* End a stream list oriented critical section: */
-# define _newlib_sfp_lock_end() \
- __sfp_lock_release (); \
- pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \
- }
-
-#else /* __SINGLE_THREAD__ || !_POSIX_THREADS */
-
-# define _newlib_flockfile_start(_fp) \
- { \
- _flockfile(_fp)
-
-# define _newlib_flockfile_exit(_fp) \
- _funlockfile(_fp); \
-
-# define _newlib_flockfile_end(_fp) \
- _funlockfile(_fp); \
- }
-
-# define _newlib_sfp_lock_start() \
- { \
- __sfp_lock_acquire ()
-
-# define _newlib_sfp_lock_exit() \
- __sfp_lock_release ();
-
-# define _newlib_sfp_lock_end() \
- __sfp_lock_release (); \
- }
-
-#endif /* !__SINGLE_THREAD__ && _POSIX_THREADS */
extern u_char *_EXFUN(__sccl, (char *, u_char *fmt));
extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c
index ecbc7afea..1c5d76db4 100644
--- a/newlib/libc/stdio/mktemp.c
+++ b/newlib/libc/stdio/mktemp.c
@@ -247,7 +247,7 @@ _DEFUN(_gettemp, (ptr, path, doopen, domkdir, suffixlen, flags),
else
{
/* Safe, since it only encounters 7-bit characters. */
- if (isdigit ((unsigned char) *trv))
+ if (isdigit (*trv))
*trv = 'a';
else
++ * trv;
diff --git a/newlib/libc/stdio/open_memstream.c b/newlib/libc/stdio/open_memstream.c
index 0b58720a1..a53bdef2f 100644
--- a/newlib/libc/stdio/open_memstream.c
+++ b/newlib/libc/stdio/open_memstream.c
@@ -313,12 +313,12 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
return NULL;
if ((c = (memstream *) _malloc_r (ptr, sizeof *c)) == NULL)
{
- _newlib_sfp_lock_start ();
+ __sfp_lock_acquire ();
fp->_flags = 0; /* release */
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
- _newlib_sfp_lock_end ();
+ __sfp_lock_release ();
return NULL;
}
/* Use *size as a hint for initial sizing, but bound the initial
@@ -338,12 +338,12 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
*buf = _malloc_r (ptr, c->max);
if (!*buf)
{
- _newlib_sfp_lock_start ();
+ __sfp_lock_acquire ();
fp->_flags = 0; /* release */
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif
- _newlib_sfp_lock_end ();
+ __sfp_lock_release ();
_free_r (ptr, c);
return NULL;
}
@@ -359,7 +359,7 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
c->saved.w = L'\0';
c->wide = (int8_t) wide;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
fp->_file = -1;
fp->_flags = __SWR;
fp->_cookie = c;
@@ -372,7 +372,7 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
#endif
fp->_close = memcloser;
ORIENT (fp, wide);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return fp;
}
diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c
index 1115bf40d..667324d9d 100644
--- a/newlib/libc/stdio/putc.c
+++ b/newlib/libc/stdio/putc.c
@@ -97,9 +97,9 @@ _DEFUN(_putc_r, (ptr, c, fp),
{
int result;
CHECK_INIT (ptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sputc_r (ptr, c, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
}
@@ -112,9 +112,9 @@ _DEFUN(putc, (c, fp),
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
int result;
CHECK_INIT (_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
result = __sputc_r (_REENT, c, fp);
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return result;
#else
return _putc_r (_REENT, c, fp);
diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c
index 63f1f80db..583a081f4 100644
--- a/newlib/libc/stdio/setvbuf.c
+++ b/newlib/libc/stdio/setvbuf.c
@@ -106,7 +106,7 @@ _DEFUN(setvbuf, (fp, buf, mode, size),
CHECK_INIT (_REENT, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
/*
* Verify arguments. The `int' limit on `size' is due to this
@@ -115,7 +115,7 @@ _DEFUN(setvbuf, (fp, buf, mode, size),
if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (EOF);
}
@@ -158,7 +158,7 @@ nbf:
fp->_w = 0;
fp->_bf._base = fp->_p = fp->_nbuf;
fp->_bf._size = 1;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (ret);
}
fp->_flags |= __SMBF;
@@ -193,6 +193,6 @@ nbf:
if (fp->_flags & __SWR)
fp->_w = fp->_flags & (__SLBF | __SNBF) ? 0 : size;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return 0;
}
diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c
index e385ce8fb..0339a3d0c 100644
--- a/newlib/libc/stdio/ungetc.c
+++ b/newlib/libc/stdio/ungetc.c
@@ -125,7 +125,7 @@ _DEFUN(_ungetc_r, (rptr, c, fp),
CHECK_INIT (rptr, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, -1);
@@ -140,14 +140,14 @@ _DEFUN(_ungetc_r, (rptr, c, fp),
*/
if ((fp->_flags & __SRW) == 0)
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
if (fp->_flags & __SWR)
{
if (_fflush_r (rptr, fp))
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
fp->_flags &= ~__SWR;
@@ -167,12 +167,12 @@ _DEFUN(_ungetc_r, (rptr, c, fp),
{
if (fp->_r >= fp->_ub._size && __submore (rptr, fp))
{
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
}
*--fp->_p = c;
fp->_r++;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return c;
}
@@ -186,7 +186,7 @@ _DEFUN(_ungetc_r, (rptr, c, fp),
{
fp->_p--;
fp->_r++;
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return c;
}
@@ -202,7 +202,7 @@ _DEFUN(_ungetc_r, (rptr, c, fp),
fp->_ubuf[sizeof (fp->_ubuf) - 1] = c;
fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1];
fp->_r = 1;
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return c;
}
diff --git a/newlib/libc/stdio/ungetwc.c b/newlib/libc/stdio/ungetwc.c
index ee0d7fc75..234d2f7ef 100644
--- a/newlib/libc/stdio/ungetwc.c
+++ b/newlib/libc/stdio/ungetwc.c
@@ -82,7 +82,7 @@ _DEFUN(_ungetwc_r, (ptr, wc, fp),
char buf[MB_LEN_MAX];
size_t len;
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, 1);
if (wc == WEOF)
wc = WEOF;
@@ -98,7 +98,7 @@ _DEFUN(_ungetwc_r, (ptr, wc, fp),
wc = WEOF;
break;
}
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return wc;
}
diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c
index f96de0d79..15310cce9 100644
--- a/newlib/libc/stdio/vasiprintf.c
+++ b/newlib/libc/stdio/vasiprintf.c
@@ -59,7 +59,7 @@ _DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap),
if (ret >= 0)
{
*f._p = 0;
- *strp = (char *) f._bf._base;
+ *strp = f._bf._base;
}
return ret;
}
diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c
index fbb54cbe8..b89f4dbd7 100644
--- a/newlib/libc/stdio/vasprintf.c
+++ b/newlib/libc/stdio/vasprintf.c
@@ -59,7 +59,7 @@ _DEFUN(_vasprintf_r, (ptr, strp, fmt, ap),
if (ret >= 0)
{
*f._p = 0;
- *strp = (char *) f._bf._base;
+ *strp = f._bf._base;
}
return ret;
}
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index 4b165e021..e3fc099d3 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -567,9 +567,9 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
char sign; /* sign prefix (' ', '+', '-', or \0) */
#ifdef _WANT_IO_C99_FORMATS
/* locale specific numeric grouping */
- char *thousands_sep = NULL;
- size_t thsnd_len = 0;
- const char *grouping = NULL;
+ char *thousands_sep;
+ size_t thsnd_len;
+ const char *grouping;
#endif
#ifdef FLOATING_POINT
char *decimal_point = _localeconv_r (data)->decimal_point;
@@ -585,7 +585,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
#if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS)
int ndig = 0; /* actual number of digits returned by cvt */
#endif
-#if defined (FLOATING_POINT) && defined (_WANT_IO_C99_FORMATS)
+#ifdef _WANT_IO_C99_FORMATS
int nseps; /* number of group separators with ' */
int nrepeats; /* number of repeats of the last group */
#endif
@@ -708,20 +708,20 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
#ifndef STRING_ONLY
/* Initialize std streams if not dealing with sprintf family. */
CHECK_INIT (data, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT(fp, -1);
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
if (cantwrite (data, fp)) {
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (EOF);
}
/* optimise fprintf(stderr) (and other unbuffered Unix files) */
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
fp->_file >= 0) {
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (__sbprintf (data, fp, fmt0, ap));
}
#else /* STRING_ONLY */
@@ -793,10 +793,10 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
sign = '\0';
#ifdef FLOATING_POINT
lead = 0;
+#endif
#ifdef _WANT_IO_C99_FORMATS
nseps = nrepeats = 0;
#endif
-#endif
#ifndef _NO_POS_ARGS
N = arg_index;
is_pos_arg = 0;
@@ -1633,7 +1633,7 @@ error:
if (malloc_buf != NULL)
_free_r (data, malloc_buf);
#ifndef STRING_ONLY
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
#endif
return (__sferror (fp) ? EOF : ret);
/* NOTREACHED */
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index e967719b7..32a132a93 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -148,12 +148,10 @@ Supporting OS subroutines required:
#endif
#ifdef STRING_ONLY
-#undef _newlib_flockfile_start
-#undef _newlib_flockfile_exit
-#undef _newlib_flockfile_end
-#define _newlib_flockfile_start(x) {}
-#define _newlib_flockfile_exit(x) {}
-#define _newlib_flockfile_end(x) {}
+#undef _flockfile
+#undef _funlockfile
+#define _flockfile(x) {}
+#define _funlockfile(x) {}
#define _ungetc_r _sungetc_r
#define __srefill_r __ssrefill_r
#define _fread_r _sfread_r
@@ -243,7 +241,10 @@ static void * get_arg (int, va_list *, int *, void **);
#define CT_INT 3 /* integer, i.e., strtol or strtoul */
#define CT_FLOAT 4 /* floating, i.e., strtod */
+#if 0
#define u_char unsigned char
+#endif
+#define u_char char
#define u_long unsigned long
#ifndef _NO_LONGLONG
@@ -495,7 +496,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
# define GET_ARG(n, ap, type) (va_arg (ap, type))
#endif
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, -1);
@@ -510,8 +511,8 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
#ifndef _MB_CAPABLE
wc = *fmt;
#else
- nbytes = __mbtowc (rptr, &wc, (char *) fmt, MB_CUR_MAX,
- __locale_charset (), &state);
+ nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (),
+ &state);
if (nbytes < 0) {
wc = 0xFFFD; /* Unicode replacement character */
nbytes = 1;
@@ -794,7 +795,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
* Disgusting backwards compatibility hacks. XXX
*/
case '\0': /* compat */
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
default: /* compat */
@@ -1594,12 +1595,12 @@ input_failure:
should have been set prior to here. On EOF failure (including
invalid format string), return EOF if no matches yet, else number
of matches made prior to failure. */
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF;
match_failure:
all_done:
/* Return number of matches, which can be 0 on match failure. */
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return nassigned;
}
diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c
index 968c218b5..d76fff0d6 100644
--- a/newlib/libc/stdio/vfwprintf.c
+++ b/newlib/libc/stdio/vfwprintf.c
@@ -396,11 +396,10 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap),
wchar_t sign; /* sign prefix (' ', '+', '-', or \0) */
#ifdef _WANT_IO_C99_FORMATS
/* locale specific numeric grouping */
- wchar_t thousands_sep = L'\0';
- const char *grouping = NULL;
+ wchar_t thousands_sep;
+ const char *grouping;
#endif
-#if defined (_MB_CAPABLE) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) \
- && (defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS))
+#ifdef _MB_CAPABLE
mbstate_t state; /* mbtowc calls from library must not change state */
#endif
#ifdef FLOATING_POINT
@@ -416,7 +415,7 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap),
#if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS)
int ndig = 0; /* actual number of digits returned by cvt */
#endif
-#if defined (FLOATING_POINT) && defined (_WANT_IO_C99_FORMATS)
+#ifdef _WANT_IO_C99_FORMATS
int nseps; /* number of group separators with ' */
int nrepeats; /* number of repeats of the last group */
#endif
@@ -554,20 +553,20 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap),
#ifndef STRING_ONLY
/* Initialize std streams if not dealing with sprintf family. */
CHECK_INIT (data, fp);
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT(fp, 1);
/* sorry, fwprintf(read_only_file, "") returns EOF, not 0 */
if (cantwrite (data, fp)) {
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (EOF);
}
/* optimise fwprintf(stderr) (and other unbuffered Unix files) */
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
fp->_file >= 0) {
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return (__sbwprintf (data, fp, fmt0, ap));
}
#else /* STRING_ONLY */
@@ -620,10 +619,10 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap),
sign = L'\0';
#ifdef FLOATING_POINT
lead = 0;
+#endif
#ifdef _WANT_IO_C99_FORMATS
nseps = nrepeats = 0;
#endif
-#endif
#ifndef _NO_POS_ARGS
N = arg_index;
is_pos_arg = 0;
@@ -1466,7 +1465,7 @@ error:
if (malloc_buf != NULL)
_free_r (data, malloc_buf);
#ifndef STRING_ONLY
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
#endif
return (__sferror (fp) ? EOF : ret);
/* NOTREACHED */
diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c
index 5d2388df8..49ccf2f4b 100644
--- a/newlib/libc/stdio/vfwscanf.c
+++ b/newlib/libc/stdio/vfwscanf.c
@@ -145,12 +145,10 @@ C99, POSIX-1.2008
#endif
#ifdef STRING_ONLY
-#undef _newlib_flockfile_start
-#undef _newlib_flockfile_exit
-#undef _newlib_flockfile_end
-#define _newlib_flockfile_start(x) {}
-#define _newlib_flockfile_exit(x) {}
-#define _newlib_flockfile_end(x) {}
+#undef _flockfile
+#undef _funlockfile
+#define _flockfile(x) {}
+#define _funlockfile(x) {}
#define _ungetwc_r _sungetwc_r
#define __srefill_r __ssrefill_r
#define _fgetwc_r _sfgetwc_r
@@ -436,7 +434,7 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap),
# define GET_ARG(n, ap, type) (va_arg (ap, type))
#endif
- _newlib_flockfile_start (fp);
+ _flockfile (fp);
ORIENT (fp, 1);
@@ -714,7 +712,7 @@ _DEFUN(__SVFWSCANF_R, (rptr, fp, fmt0, ap),
* Disgusting backwards compatibility hacks. XXX
*/
case L'\0': /* compat */
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return EOF;
default: /* compat */
@@ -1442,12 +1440,12 @@ input_failure:
should have been set prior to here. On EOF failure (including
invalid format string), return EOF if no matches yet, else number
of matches made prior to failure. */
- _newlib_flockfile_exit (fp);
+ _funlockfile (fp);
return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF;
match_failure:
all_done:
/* Return number of matches, which can be 0 on match failure. */
- _newlib_flockfile_end (fp);
+ _funlockfile (fp);
return nassigned;
}