2009-04-24 Jeff johnston <jjohnstn@redhat.com>
+ * libc/stdio/fgetc.c: Make sure sfp lock is acquired before the
+ file lock and released before the file lock to avoid a deadlock
+ scenario.
+ * libc/stdio/fgets.c: Ditto.
+ * libc/stdio/fgetwc.c: Ditto.
+ * libc/stdio/fgetws.c: Ditto.
+ * libc/stdio/fread.c: Ditto.
+ * libc/stdio/fseek.c: Ditto.
+ * libc/stdio/getc.c: Ditto.
+ * libc/stdio/getdelim.c: Ditto.
+ * libc/stdio/gets.c: Ditto.
+
+2009-04-24 Jeff johnston <jjohnstn@redhat.com>
+
* configure.in: Add configuration test for long double equals dbl
and set flag _LDBL_EQ_DBL if true.
* configure: Regenerated.
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
int result;
CHECK_INIT(_REENT, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
result = __sgetc_r (_REENT, fp);
_funlockfile (fp);
+ __sfp_lock_release ();
return result;
#else
return _fgetc_r (_REENT, fp);
CHECK_INIT(ptr, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
#ifdef __SCLE
if (fp->_flags & __SCLE)
if (c == EOF && s == buf)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return NULL;
}
*s = 0;
_funlockfile (fp);
+ __sfp_lock_release ();
return buf;
}
#endif
if (s == buf)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return 0;
}
break;
_CAST_VOID memcpy ((_PTR) s, (_PTR) p, len);
s[len] = 0;
_funlockfile (fp);
+ __sfp_lock_release ();
return (buf);
}
fp->_r -= len;
while ((n -= len) != 0);
*s = 0;
_funlockfile (fp);
+ __sfp_lock_release ();
return buf;
}
{
wint_t r;
+ __sfp_lock_acquire ();
_flockfile (fp);
ORIENT(fp, 1);
r = __fgetwc (ptr, fp);
_funlockfile (fp);
+ __sfp_lock_release ();
return r;
}
const char *src;
unsigned char *nl;
+ __sfp_lock_acquire ();
_flockfile (fp);
ORIENT (fp, 1);
goto error;
*wsp++ = L'\0';
_funlockfile (fp);
+ __sfp_lock_release ();
return ws;
error:
_funlockfile (fp);
+ __sfp_lock_release ();
return NULL;
}
CHECK_INIT(ptr, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
ORIENT (fp, -1);
if (fp->_r < 0)
if (fp->_flags & __SCLE)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return crlf_r (ptr, fp, buf, total-resid, 1) / size;
}
#endif
_funlockfile (fp);
+ __sfp_lock_release ();
return (total - resid) / size;
}
}
if (fp->_flags & __SCLE)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return crlf_r (ptr, fp, buf, total-resid, 1) / size;
}
#endif
_funlockfile (fp);
+ __sfp_lock_release ();
return (total - resid) / size;
}
}
if (fp->_flags & __SCLE)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return crlf_r(ptr, fp, buf, total, 0) / size;
}
#endif
_funlockfile (fp);
+ __sfp_lock_release ();
return count;
}
CHECK_INIT (ptr, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
/* If we've been doing some writing, and we're in append mode
{
ptr->_errno = ESPIPE; /* ??? */
_funlockfile (fp);
+ __sfp_lock_release ();
return EOF;
}
if (curoff == -1L)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return EOF;
}
}
default:
ptr->_errno = EINVAL;
_funlockfile (fp);
+ __sfp_lock_release ();
return (EOF);
}
if ((long)target != target)
{
ptr->_errno = EOVERFLOW;
+ _funlockfile (fp);
+ __sfp_lock_release ();
return EOF;
}
fp->_flags &= ~__SEOF;
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
_funlockfile (fp);
+ __sfp_lock_release ();
return 0;
}
}
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
_funlockfile (fp);
+ __sfp_lock_release ();
return 0;
/*
|| seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR)
{
_funlockfile (fp);
+ __sfp_lock_release ();
return EOF;
}
/* success: clear EOF indicator and discard ungetc() data */
fp->_flags &= ~__SNPT;
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
_funlockfile (fp);
+ __sfp_lock_release ();
return 0;
}
{
int result;
CHECK_INIT (ptr, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
result = __sgetc_r (ptr, fp);
_funlockfile (fp);
+ __sfp_lock_release ();
return result;
}
{
int result;
CHECK_INIT (_REENT, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
result = __sgetc_r (_REENT, fp);
_funlockfile (fp);
+ __sfp_lock_release ();
return result;
}
CHECK_INIT (_REENT, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
numbytes = *n;
}
_funlockfile (fp);
+ __sfp_lock_release ();
/* if no input data, return failure */
if (ptr == buf)
register int c;
register char *s = buf;
+ __sfp_lock_acquire ();
_flockfile (stdin);
while ((c = __sgetc_r (ptr, stdin)) != '\n')
if (c == EOF)
if (s == buf)
{
_funlockfile (stdin);
+ __sfp_lock_release ();
return NULL;
}
else
*s++ = c;
*s = 0;
_funlockfile (stdin);
+ __sfp_lock_release ();
return buf;
}