Mail Archives: cygwin-developers/2001/04/23/22:53:52
Did the following patch get applied to CVS ? If not, why not? (I don't
think Robert Collins' message (partially quoted below) was intended as
an argument against it, especially given his second message (also
quoted)) It's also not clear whether Robert was commenting on my
*original* changes which Jeff later modified and accepted, or the newer
changes against Jeff's update.
Robert Collins wrote:
> A __cursory__ conde read through gives me the impression that
> simultaneous calls with the same file may result in undefined results.
>
> buffer wise it should be ok, but don't use the same handle twice. I
> don't know that the SUS has to say about the _r function w.r.t. the file
> in use, but I would expect that two calls from two threads to one of the
> _r functions should result in one blocking until the other finishes
> scnaning, not them interleaving fread calls.
>
> I may be completely off-base here though.
Robert Collins later wrote:
> I'm looking at the original function that you are wrapping: I don't
> think your changes will make it worse, just that the _r functions may be
> reentrant, but not threadsafe. That may be an issue with increasing
> threaded applications on cygwin...
>
> I don't think this should stop the code going in, just that someone
> should go through that code carefully.
--Chuck
Charles Wilson wrote:
> ChangeLog
>
> Fri Apr 20 23:48:00 2001 Charles Wilson <cwilson AT ece DOT gatech DOT edu
>
> * libc/stdio/vprintf.c (vprintf): fix signature to use _DEFUN
> * libc/stdio/vprintf.c (_vprintf_r): new function
> * libc/stdio/vsnprintf.c (vsnprintf): fix signature to use _DEFUN
> * libc/stdio/vsnprintf.c (_vsnprintf_r): fix signature to use
> _DEFUN, and call _vfprintf_r, not vfprintf.
> * libc/stdio/vsprintf.c (vsprintf.c): fix signature to use _DEFUN
> * libc/stdio/vsnprintf.c (_vsprintf_r): fix signature to use
> _DEFUN, and call _vfprintf_r, not vfprintf.
>
> Index: libc/stdio/vprintf.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/stdio/vprintf.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 old/libc/stdio/vprintf.c new/libc/stdio/vprintf.c
> --- old/libc/stdio/vprintf.c 2000/02/17 19:39:47 1.1.1.1
> +++ new/libc/stdio/vprintf.c 2001/04/21 03:43:55
> @@ -27,9 +27,18 @@
> #endif
>
> int
> -vprintf (fmt, ap)
> - char _CONST *fmt;
> - va_list ap;
> +_DEFUN (vprintf, (fmt, ap),
> + _CONST char *fmt _AND
> + va_list ap)
> {
> return vfprintf (stdout, fmt, ap);
> +}
> +
> +int
> +_DEFUN (_vprintf_r, (ptr, fmt, ap),
> + struct _reent *ptr _AND
> + _CONST char *fmt _AND
> + va_list ap)
> +{
> + return _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
> }
> Index: libc/stdio/vsnprintf.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/stdio/vsnprintf.c,v
> retrieving revision 1.2
> diff -u -r1.2 old/libc/stdio/vsnprintf.c new/libc/stdio/vsnprintf.c
> --- old/libc/stdio/vsnprintf.c 2000/08/08 19:01:02 1.2
> +++ new/libc/stdio/vsnprintf.c 2001/04/21 03:43:55
> @@ -34,11 +34,11 @@
> #endif
>
> int
> -vsnprintf (str, size, fmt, ap)
> - char *str;
> - size_t size;
> - char _CONST *fmt;
> - va_list ap;
> +_DEFUN (vsnprintf, (str, size, fmt, ap),
> + char *str _AND
> + size_t size _AND
> + _CONST char *fmt _AND
> + va_list ap)
> {
> int ret;
> FILE f;
> @@ -54,12 +54,12 @@
> }
>
> int
> -vsnprintf_r (ptr, str, size, fmt, ap)
> - struct _reent *ptr;
> - char *str;
> - size_t size;
> - char _CONST *fmt;
> - va_list ap;
> +_DEFUN (_vsnprintf_r, (ptr, str, size, fmt, ap),
> + struct _reent *ptr _AND
> + char *str _AND
> + size_t size _AND
> + _CONST char *fmt _AND
> + va_list ap)
> {
> int ret;
> FILE f;
> @@ -68,7 +68,7 @@
> f._bf._base = f._p = (unsigned char *) str;
> f._bf._size = f._w = (size > 0 ? size - 1 : 0);
> f._data = ptr;
> - ret = vfprintf (&f, fmt, ap);
> + ret = _vfprintf_r (ptr, &f, fmt, ap);
> if (size > 0)
> *f._p = 0;
> return ret;
> Index: libc/stdio/vsprintf.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/stdio/vsprintf.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 old/libc/stdio/vsprintf.c new/libc/stdio/vsprintf.c
> --- old/libc/stdio/vsprintf.c 2000/02/17 19:39:47 1.1.1.1
> +++ new/libc/stdio/vsprintf.c 2001/04/21 03:43:57
> @@ -32,10 +32,10 @@
> #endif
>
> int
> -vsprintf (str, fmt, ap)
> - char *str;
> - char _CONST *fmt;
> - va_list ap;
> +_DEFUN (vsprintf, (str, fmt, ap),
> + char *str _AND
> + _CONST char *fmt _AND
> + va_list ap)
> {
> int ret;
> FILE f;
> @@ -50,11 +50,11 @@
> }
>
> int
> -vsprintf_r (ptr, str, fmt, ap)
> - struct _reent *ptr;
> - char *str;
> - char _CONST *fmt;
> - va_list ap;
> +_DEFUN (_vsprintf_r, (ptr, str, fmt, ap),
> + struct _reent *ptr _AND
> + char *str _AND
> + _CONST char *fmt _AND
> + va_list ap)
> {
> int ret;
> FILE f;
> @@ -63,7 +63,7 @@
> f._bf._base = f._p = (unsigned char *) str;
> f._bf._size = f._w = INT_MAX;
> f._data = ptr;
> - ret = vfprintf (&f, fmt, ap);
> + ret = _vfprintf_r (ptr, &f, fmt, ap);
> *f._p = 0;
> return ret;
> }
- Raw text -