RFA: Fix PowerPC version of vfprintf.c
Jeff Johnston
jjohnstn@redhat.com
Wed Mar 28 20:42:00 GMT 2007
Yes, please do.
-- Jeff J.
Nick Clifton wrote:
> Hi Jeff,
>
> The PowerPC specific version of the vfprintf.c file needs a few
> fixes so that it will compile with the latest newlib sources. The
> attached patch takes care of this. Is it OK to apply ?
>
> Cheers
> Nick
>
> newlib/ChangeLog
> 2007-03-20 Nick Clifton <nickc@redhat.com>
>
> Reflect changes made to generic vfprintf.c:
> * libc/machine/powerpc/vfprintf.c (__sprint): Rename to __sprint_r
> and add a "struct reent *" argument.
> (__sbprintf): Rename to __sbprintf_r, add a "struct reent *"
> argument and call _VFPRINTF_R instead of VFPRINTF.
> (_VFPRINTF_R): Add data pointer to call to cantwrite().
> Fix uses of __sprint() and __sbprintf.
>
> Index: newlib/libc/machine/powerpc/vfprintf.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/machine/powerpc/vfprintf.c,v
> retrieving revision 1.12
> diff -c -3 -p -r1.12 vfprintf.c
> *** newlib/libc/machine/powerpc/vfprintf.c 26 Sep 2006 21:22:19 -0000 1.12
> --- newlib/libc/machine/powerpc/vfprintf.c 20 Mar 2007 15:40:57 -0000
> *************** typedef union
> *** 207,213 ****
> * then reset it so that it can be reused.
> */
> static int
> ! __sprint(fp, uio)
> FILE *fp;
> register struct __suio *uio;
> {
> --- 207,214 ----
> * then reset it so that it can be reused.
> */
> static int
> ! __sprint_r(rptr, fp, uio)
> ! struct _reent *rptr;
> FILE *fp;
> register struct __suio *uio;
> {
> *************** __sprint(fp, uio)
> *** 217,223 ****
> uio->uio_iovcnt = 0;
> return (0);
> }
> ! err = __sfvwrite(fp, uio);
> uio->uio_resid = 0;
> uio->uio_iovcnt = 0;
> return (err);
> --- 218,224 ----
> uio->uio_iovcnt = 0;
> return (0);
> }
> ! err = __sfvwrite_r(rptr, fp, uio);
> uio->uio_resid = 0;
> uio->uio_iovcnt = 0;
> return (err);
> *************** __sprint(fp, uio)
> *** 229,235 ****
> * worries about ungetc buffers and so forth.
> */
> static int
> ! __sbprintf(fp, fmt, ap)
> register FILE *fp;
> const char *fmt;
> va_list ap;
> --- 230,237 ----
> * worries about ungetc buffers and so forth.
> */
> static int
> ! __sbprintf_r(rptr, fp, fmt, ap)
> ! struct _reent *rptr;
> register FILE *fp;
> const char *fmt;
> va_list ap;
> *************** __sbprintf(fp, fmt, ap)
> *** 250,256 ****
> fake._lbfsize = 0; /* not actually used, but Just In Case */
>
> /* do the work, then copy any error status */
> ! ret = VFPRINTF(&fake, fmt, ap);
> if (ret >= 0 && fflush(&fake))
> ret = EOF;
> if (fake._flags & __SERR)
> --- 252,258 ----
> fake._lbfsize = 0; /* not actually used, but Just In Case */
>
> /* do the work, then copy any error status */
> ! ret = _VFPRINTF_R(rptr, &fake, fmt, ap);
> if (ret >= 0 && fflush(&fake))
> ret = EOF;
> if (fake._flags & __SERR)
> *************** _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap
> *** 410,416 ****
> uio.uio_resid += (len); \
> iovp++; \
> if (++uio.uio_iovcnt >= NIOV) { \
> ! if (__sprint(fp, &uio)) \
> goto error; \
> iovp = iov; \
> } \
> --- 412,418 ----
> uio.uio_resid += (len); \
> iovp++; \
> if (++uio.uio_iovcnt >= NIOV) { \
> ! if (__sprint_r(data, fp, &uio)) \
> goto error; \
> iovp = iov; \
> } \
> *************** _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap
> *** 425,431 ****
> } \
> }
> #define FLUSH() { \
> ! if (uio.uio_resid && __sprint(fp, &uio)) \
> goto error; \
> uio.uio_iovcnt = 0; \
> iovp = iov; \
> --- 427,433 ----
> } \
> }
> #define FLUSH() { \
> ! if (uio.uio_resid && __sprint_r(data, fp, &uio)) \
> goto error; \
> uio.uio_iovcnt = 0; \
> iovp = iov; \
> *************** _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap
> *** 520,532 ****
> memset (&state, '\0', sizeof (state));
>
> /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
> ! if (cantwrite(fp))
> return (EOF);
>
> /* optimise fprintf(stderr) (and other unbuffered Unix files) */
> if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
> fp->_file >= 0)
> ! return (__sbprintf(fp, fmt0, ap));
>
> fmt = (char *)fmt0;
> uio.uio_iov = iovp = iov;
> --- 522,536 ----
> memset (&state, '\0', sizeof (state));
>
> /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
> ! if (cantwrite (data, fp)) {
> ! _funlockfile (fp);
> return (EOF);
> + }
>
> /* optimise fprintf(stderr) (and other unbuffered Unix files) */
> if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
> fp->_file >= 0)
> ! return (__sbprintf_r(data, fp, fmt0, ap));
>
> fmt = (char *)fmt0;
> uio.uio_iov = iovp = iov;
More information about the Newlib
mailing list