From: Joerg Sonnenberger Date: Sat, 23 Jul 2005 23:14:44 +0000 (+0000) Subject: Merge __sFILEX into __FILE. Let __fpending handle the ungetc buffer X-Git-Tag: v2.0.1~6507 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/43f82d703285fa46b33d3916159665b079c83d8a Merge __sFILEX into __FILE. Let __fpending handle the ungetc buffer correctly. --- diff --git a/lib/libc/stdio/__fpending.c b/lib/libc/stdio/__fpending.c index fa2b68bace..8c2e5ae3e2 100644 --- a/lib/libc/stdio/__fpending.c +++ b/lib/libc/stdio/__fpending.c @@ -31,15 +31,19 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libc/stdio/__fpending.c,v 1.1 2005/07/23 20:23:05 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/__fpending.c,v 1.2 2005/07/23 23:14:44 joerg Exp $ */ #include #include "priv_stdio.h" +#include "local.h" __ssize_t __fpending(FILE *fp) { - return(fp->pub._p - fp->_bf._base); + if (HASUB(fp)) + return(fp->_up - fp->_bf._base); + else + return(fp->pub._p - fp->_bf._base); } diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c index 02c4816b88..c055a25048 100644 --- a/lib/libc/stdio/_flock_stub.c +++ b/lib/libc/stdio/_flock_stub.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/stdio/_flock_stub.c,v 1.3 1999/08/28 00:00:55 peter Exp $ - * $DragonFly: src/lib/libc/stdio/_flock_stub.c,v 1.9 2005/07/23 20:23:05 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/_flock_stub.c,v 1.10 2005/07/23 23:14:44 joerg Exp $ * */ @@ -58,23 +58,21 @@ __weak_reference(__ftrylockfile, _ftrylockfile); __weak_reference(__funlockfile, funlockfile); __weak_reference(__funlockfile, _funlockfile); -#define _lock _extra - void __flockfile(FILE *fp) { pthread_t curthread = _pthread_self(); - if (fp->_lock->fl_owner == curthread) - fp->_lock->fl_count++; + if (fp->fl_owner == curthread) + fp->fl_count++; else { /* * Make sure this mutex is treated as a private * internal mutex: */ - _pthread_mutex_lock(&fp->_lock->fl_mutex); - fp->_lock->fl_owner = curthread; - fp->_lock->fl_count = 1; + _pthread_mutex_lock(&fp->fl_mutex); + fp->fl_owner = curthread; + fp->fl_count = 1; } } @@ -90,15 +88,15 @@ __ftrylockfile(FILE *fp) pthread_t curthread = _pthread_self(); int ret = 0; - if (fp->_lock->fl_owner == curthread) - fp->_lock->fl_count++; + if (fp->fl_owner == curthread) + fp->fl_count++; /* * Make sure this mutex is treated as a private * internal mutex: */ - else if (_pthread_mutex_trylock(&fp->_lock->fl_mutex) == 0) { - fp->_lock->fl_owner = curthread; - fp->_lock->fl_count = 1; + else if (_pthread_mutex_trylock(&fp->fl_mutex) == 0) { + fp->fl_owner = curthread; + fp->fl_count = 1; } else ret = -1; @@ -113,26 +111,26 @@ __funlockfile(FILE *fp) /* * Check if this file is owned by the current thread: */ - if (fp->_lock->fl_owner == curthread) { + if (fp->fl_owner == curthread) { /* * Check if this thread has locked the FILE * more than once: */ - if (fp->_lock->fl_count > 1) + if (fp->fl_count > 1) /* * Decrement the count of the number of * times the running thread has locked this * file: */ - fp->_lock->fl_count--; + fp->fl_count--; else { /* * The running thread will release the * lock now: */ - fp->_lock->fl_count = 0; - fp->_lock->fl_owner = NULL; - _pthread_mutex_unlock(&fp->_lock->fl_mutex); + fp->fl_count = 0; + fp->fl_owner = NULL; + _pthread_mutex_unlock(&fp->fl_mutex); } } } diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c index e700cf3360..e2d6c2a206 100644 --- a/lib/libc/stdio/asprintf.c +++ b/lib/libc/stdio/asprintf.c @@ -27,7 +27,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/lib/libc/stdio/asprintf.c,v 1.6 1999/08/28 00:00:55 peter Exp $ - * $DragonFly: src/lib/libc/stdio/asprintf.c,v 1.6 2005/07/23 20:23:05 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/asprintf.c,v 1.7 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -44,7 +44,6 @@ asprintf(char **str, char const *fmt, ...) int ret; va_list ap; FILE f; - struct __sFILEX ext; f.pub._fileno = -1; f.pub._flags = __SWR | __SSTR | __SALC; @@ -55,8 +54,10 @@ asprintf(char **str, char const *fmt, ...) return (-1); } f._bf._size = f.pub._w = 127; /* Leave room for the NUL */ - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; va_start(ap, fmt); ret = __vfprintf(&f, fmt, ap); /* Use unlocked __vfprintf */ va_end(ap); diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index ec6638db1d..8e283ae843 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -35,7 +35,7 @@ * * @(#)findfp.c 8.2 (Berkeley) 1/4/94 * $FreeBSD: src/lib/libc/stdio/findfp.c,v 1.7.2.3 2001/08/17 02:56:31 peter Exp $ - * $DragonFly: src/lib/libc/stdio/findfp.c,v 1.8 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/findfp.c,v 1.9 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -57,17 +57,14 @@ int __sdidinit; #define std(flags, file) \ {{0,flags,file,0,0,0},{NULL, 0},__sF+file,__sclose,__sread,__sseek,__swrite, \ - {NULL,0}, __sFX + file, 0, {0,0,0}, {0}, {NULL,0}, 0,0 } + {NULL,0}, 0, {0,0,0}, {0}, {NULL,0}, 0,0, NULL, PTHREAD_MUTEX_INITIALIZER, NULL, 0 } /* p flags file r w _bf cookie close read seek write */ -/* _ub _extra */ +/* _ub */ /* the usual - (stdin + stdout + stderr) */ static FILE usual[FOPEN_MAX - 3]; -static struct __sFILEX usual_extra[FOPEN_MAX - 3]; static struct glue uglue = { NULL, FOPEN_MAX - 3, usual }; -static struct __sFILEX __sFX[3]; - FILE __sF[3] = { std(__SRD, STDIN_FILENO), /* stdin */ std(__SWR, STDOUT_FILENO), /* stdout */ @@ -109,24 +106,18 @@ moreglue(int n) { struct glue *g; static FILE empty; - static struct __sFILEX emptyx; FILE *p; - struct __sFILEX *fx; - g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE) + - n * sizeof(struct __sFILEX)); + g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE)); if (g == NULL) return (NULL); p = (FILE *)ALIGN(g + 1); - fx = (struct __sFILEX *)&p[n]; g->next = NULL; g->niobs = n; g->iobs = p; while (--n >= 0) { *p = empty; - p->_extra = fx; - *p->_extra = emptyx; - p++, fx++; + p++; } return (g); } @@ -174,6 +165,10 @@ found: fp->_ub._size = 0; fp->_lb._base = NULL; /* no line buffer */ fp->_lb._size = 0; + fp->_up = NULL; + fp->fl_mutex = PTHREAD_MUTEX_INITIALIZER; + fp->fl_owner = NULL; + fp->fl_count = 0; /* fp->_lock = NULL; */ return (fp); } @@ -229,14 +224,8 @@ _cleanup(void) void __sinit(void) { - int i; - THREAD_LOCK(); if (__sdidinit == 0) { - /* Set _extra for the usual suspects. */ - for (i = 0; i < FOPEN_MAX - 3; i++) - usual[i]._extra = &usual_extra[i]; - /* Make sure we clean up on exit. */ __cleanup = _cleanup; /* conservative */ __sdidinit = 1; diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index 60db812d77..afdf199d3d 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -35,7 +35,7 @@ * * @(#)fseek.c 8.3 (Berkeley) 1/2/94 * $FreeBSD: src/lib/libc/stdio/fseek.c,v 1.9.2.1 2001/03/05 10:56:58 obrien Exp $ - * $DragonFly: src/lib/libc/stdio/fseek.c,v 1.8 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/fseek.c,v 1.9 2005/07/23 23:14:44 joerg Exp $ */ #include "namespace.h" @@ -197,7 +197,7 @@ _fseeko(FILE *fp, off_t offset, int whence) */ if (HASUB(fp)) { curoff += fp->pub._r; /* kill off ungetc */ - n = fp->_extra->_up - fp->_bf._base; + n = fp->_up - fp->_bf._base; curoff -= n; n += fp->_ur; } else { diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h index afc5f218bc..63be29b811 100644 --- a/lib/libc/stdio/local.h +++ b/lib/libc/stdio/local.h @@ -36,11 +36,10 @@ * @(#)local.h 8.3 (Berkeley) 7/3/94 * * $FreeBSD: src/lib/libc/stdio/local.h,v 1.1.1.2.6.1 2001/03/05 11:27:49 obrien Exp $ - * $DragonFly: src/lib/libc/stdio/local.h,v 1.7 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/local.h,v 1.8 2005/07/23 23:14:44 joerg Exp $ */ #include /* for off_t */ -#include #ifndef _MACHINE_STDINT_H_ #include /* __size_t */ @@ -70,14 +69,6 @@ extern int __vfprintf(FILE *, const char *, __va_list); extern int __sdidinit; -/* hold a buncha junk that would grow the ABI */ -struct __sFILEX { - unsigned char *_up; /* saved _p when _p is doing ungetc data */ - pthread_mutex_t fl_mutex; /* used for MT-safety */ - pthread_t fl_owner; /* current owner */ - int fl_count; /* recursive lock count */ -}; - /* * Return true iff the given FILE cannot be written now. */ @@ -104,11 +95,3 @@ struct __sFILEX { free((char *)(fp)->_lb._base); \ (fp)->_lb._base = NULL; \ } - -#define INITEXTRA(fp) { \ - (fp)->_extra->_up = NULL; \ - (fp)->_extra->fl_mutex = PTHREAD_MUTEX_INITIALIZER; \ - (fp)->_extra->fl_owner = NULL; \ - (fp)->_extra->fl_count = 0; \ -} - diff --git a/lib/libc/stdio/priv_stdio.h b/lib/libc/stdio/priv_stdio.h index 3a100ab777..4082dbe500 100644 --- a/lib/libc/stdio/priv_stdio.h +++ b/lib/libc/stdio/priv_stdio.h @@ -30,20 +30,20 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libc/stdio/priv_stdio.h,v 1.1 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/priv_stdio.h,v 1.2 2005/07/23 23:14:44 joerg Exp $ */ #ifndef _LIBC_PRIV_STDIO_H_ #define _LIBC_PRIV_STDIO_H_ +#include + /* stdio buffers */ struct __sbuf { unsigned char *_base; int _size; }; -struct __sFILEX; - /* * _ub, _up, and _ur are used when ungetc() pushes back more characters * than fit in the current _bf, or when ungetc() pushes back a character @@ -65,7 +65,6 @@ struct __FILE { /* separate buffer for long sequences of ungetc() */ struct __sbuf _ub; /* ungetc buffer */ - struct __sFILEX *_extra; int _ur; /* saved _r when _r is counting ungetc data */ /* tricks to meet minimum requirements even when malloc() fails */ @@ -78,6 +77,11 @@ struct __FILE { /* Unix stdio files get aligned to block boundaries on fseek() */ int _blksize; /* stat.st_blksize (may be != _bf._size) */ fpos_t _offset; /* current lseek offset (see WARNING) */ + + unsigned char *_up; /* saved _p when _p is doing ungetc data */ + pthread_mutex_t fl_mutex; /* used for MT-safety */ + pthread_t fl_owner; /* current owner */ + int fl_count; /* recursive lock count */ }; /* diff --git a/lib/libc/stdio/refill.c b/lib/libc/stdio/refill.c index 008a75064f..28ce6bf9fc 100644 --- a/lib/libc/stdio/refill.c +++ b/lib/libc/stdio/refill.c @@ -35,7 +35,7 @@ * * @(#)refill.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/refill.c,v 1.8.2.1 2001/03/05 11:27:49 obrien Exp $ - * $DragonFly: src/lib/libc/stdio/refill.c,v 1.8 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/refill.c,v 1.9 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -100,7 +100,7 @@ __srefill(FILE *fp) if (HASUB(fp)) { FREEUB(fp); if ((fp->pub._r = fp->_ur) != 0) { - fp->pub._p = fp->_extra->_up; + fp->pub._p = fp->_up; return (0); } } diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c index 917baa2f7f..29adcfb556 100644 --- a/lib/libc/stdio/snprintf.c +++ b/lib/libc/stdio/snprintf.c @@ -35,7 +35,7 @@ * * @(#)snprintf.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/snprintf.c,v 1.12 1999/08/28 00:01:16 peter Exp $ - * $DragonFly: src/lib/libc/stdio/snprintf.c,v 1.5 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/snprintf.c,v 1.6 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -52,7 +52,6 @@ snprintf(char *str, size_t n, char const *fmt, ...) int ret; va_list ap; FILE f; - struct __sFILEX ext; on = n; if (n != 0) @@ -64,8 +63,10 @@ snprintf(char *str, size_t n, char const *fmt, ...) f.pub._flags = __SWR | __SSTR; f._bf._base = f.pub._p = (unsigned char *)str; f._bf._size = f.pub._w = n; - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; ret = __vfprintf(&f, fmt, ap); /* Use unlocked __vfprintf */ if (on > 0) *f.pub._p = '\0'; diff --git a/lib/libc/stdio/sprintf.c b/lib/libc/stdio/sprintf.c index 59ac99c688..8a8999eb85 100644 --- a/lib/libc/stdio/sprintf.c +++ b/lib/libc/stdio/sprintf.c @@ -35,7 +35,7 @@ * * @(#)sprintf.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/sprintf.c,v 1.6 1999/08/28 00:01:17 peter Exp $ - * $DragonFly: src/lib/libc/stdio/sprintf.c,v 1.5 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/sprintf.c,v 1.6 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -51,14 +51,15 @@ sprintf(char *str, char const *fmt, ...) int ret; va_list ap; FILE f; - struct __sFILEX ext; f.pub._fileno = -1; f.pub._flags = __SWR | __SSTR; f._bf._base = f.pub._p = (unsigned char *)str; f._bf._size = f.pub._w = INT_MAX; - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; va_start(ap, fmt); ret = __vfprintf(&f, fmt, ap); /* Use unlocked __vfprintf */ va_end(ap); diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c index 69d0a6cd01..ac5dcd7d29 100644 --- a/lib/libc/stdio/sscanf.c +++ b/lib/libc/stdio/sscanf.c @@ -35,7 +35,7 @@ * * @(#)sscanf.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/sscanf.c,v 1.6 1999/08/28 00:01:17 peter Exp $ - * $DragonFly: src/lib/libc/stdio/sscanf.c,v 1.6 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/sscanf.c,v 1.7 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -61,7 +61,6 @@ sscanf(const char *str, char const *fmt, ...) int ret; va_list ap; FILE f; - struct __sFILEX ext; f.pub._fileno = -1; f.pub._flags = __SRD; @@ -70,8 +69,10 @@ sscanf(const char *str, char const *fmt, ...) f._read = eofread; f._ub._base = NULL; f._lb._base = NULL; - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; va_start(ap, fmt); ret = __svfscanf(&f, fmt, ap); va_end(ap); diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c index 3a5f1dcd03..3643e02db9 100644 --- a/lib/libc/stdio/ungetc.c +++ b/lib/libc/stdio/ungetc.c @@ -35,7 +35,7 @@ * * @(#)ungetc.c 8.2 (Berkeley) 11/3/93 * $FreeBSD: src/lib/libc/stdio/ungetc.c,v 1.7.2.1 2001/03/05 11:27:49 obrien Exp $ - * $DragonFly: src/lib/libc/stdio/ungetc.c,v 1.6 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/ungetc.c,v 1.7 2005/07/23 23:14:44 joerg Exp $ */ #include "namespace.h" @@ -165,7 +165,7 @@ __ungetc(int c, FILE *fp) * Initially, we will use the `reserve' buffer. */ fp->_ur = fp->pub._r; - fp->_extra->_up = fp->pub._p; + fp->_up = fp->pub._p; fp->_ub._base = fp->_ubuf; fp->_ub._size = sizeof(fp->_ubuf); fp->_ubuf[sizeof(fp->_ubuf) - 1] = c; diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c index d3e503ffc2..864501eb76 100644 --- a/lib/libc/stdio/vasprintf.c +++ b/lib/libc/stdio/vasprintf.c @@ -27,7 +27,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/lib/libc/stdio/vasprintf.c,v 1.11 1999/08/28 00:01:19 peter Exp $ - * $DragonFly: src/lib/libc/stdio/vasprintf.c,v 1.6 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/vasprintf.c,v 1.7 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -43,7 +43,6 @@ vasprintf(char **str, const char *fmt, va_list ap) { int ret; FILE f; - struct __sFILEX ext; f.pub._fileno = -1; f.pub._flags = __SWR | __SSTR | __SALC; @@ -54,8 +53,10 @@ vasprintf(char **str, const char *fmt, va_list ap) return (-1); } f._bf._size = f.pub._w = 127; /* Leave room for the NULL */ - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; ret = __vfprintf(&f, fmt, ap); *f.pub._p = '\0'; f._bf._base = reallocf(f._bf._base, f._bf._size + 1); diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 23fd9568bb..c4a5ed3b76 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -35,7 +35,7 @@ * * @(#)vfprintf.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/vfprintf.c,v 1.34 2001/12/13 19:45:41 phantom Exp $ - * $DragonFly: src/lib/libc/stdio/vfprintf.c,v 1.10 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/vfprintf.c,v 1.11 2005/07/23 23:14:44 joerg Exp $ */ /* @@ -157,7 +157,11 @@ __sbprintf(FILE *fp, const char *fmt, va_list ap) fake.pub._fileno = fp->pub._fileno; fake._cookie = fp->_cookie; fake._write = fp->_write; - fake._extra = fp->_extra; + + fake._up = fp->_up; + fake.fl_mutex = fp->fl_mutex; + fake.fl_owner = fp->fl_owner; + fake.fl_count = fp->fl_count; /* set up the buffer */ fake._bf._base = fake.pub._p = buf; diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c index df481832a4..abb28c2fcf 100644 --- a/lib/libc/stdio/vsnprintf.c +++ b/lib/libc/stdio/vsnprintf.c @@ -35,7 +35,7 @@ * * @(#)vsnprintf.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/vsnprintf.c,v 1.12.2.1 2002/09/23 06:58:17 maxim Exp $ - * $DragonFly: src/lib/libc/stdio/vsnprintf.c,v 1.6 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/vsnprintf.c,v 1.7 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -52,7 +52,6 @@ vsnprintf(char *str, size_t n, const char *fmt, va_list ap) int ret; char dummy; FILE f; - struct __sFILEX ext; on = n; if (n != 0) @@ -68,8 +67,10 @@ vsnprintf(char *str, size_t n, const char *fmt, va_list ap) f.pub._flags = __SWR | __SSTR; f._bf._base = f.pub._p = (unsigned char *)str; f._bf._size = f.pub._w = n; - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; ret = __vfprintf(&f, fmt, ap); if (on > 0) *f.pub._p = '\0'; diff --git a/lib/libc/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c index 823fc9f274..896379915b 100644 --- a/lib/libc/stdio/vsprintf.c +++ b/lib/libc/stdio/vsprintf.c @@ -35,7 +35,7 @@ * * @(#)vsprintf.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/vsprintf.c,v 1.6 1999/08/28 00:01:21 peter Exp $ - * $DragonFly: src/lib/libc/stdio/vsprintf.c,v 1.6 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/vsprintf.c,v 1.7 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -50,14 +50,15 @@ vsprintf(char *str, const char *fmt, va_list ap) { int ret; FILE f; - struct __sFILEX ext; f.pub._fileno = -1; f.pub._flags = __SWR | __SSTR; f._bf._base = f.pub._p = (unsigned char *)str; f._bf._size = f.pub._w = INT_MAX; - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; ret = __vfprintf(&f, fmt, ap); *f.pub._p = 0; return (ret); diff --git a/lib/libc/stdio/vsscanf.c b/lib/libc/stdio/vsscanf.c index bfe0db9b58..2726c67925 100644 --- a/lib/libc/stdio/vsscanf.c +++ b/lib/libc/stdio/vsscanf.c @@ -35,7 +35,7 @@ * * @(#)vsscanf.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/vsscanf.c,v 1.7 1999/08/28 00:01:22 peter Exp $ - * $DragonFly: src/lib/libc/stdio/vsscanf.c,v 1.7 2005/07/23 20:23:06 joerg Exp $ + * $DragonFly: src/lib/libc/stdio/vsscanf.c,v 1.8 2005/07/23 23:14:44 joerg Exp $ */ #include @@ -60,7 +60,6 @@ int vsscanf(const char *str, const char *fmt, va_list ap) { FILE f; - struct __sFILEX ext; f.pub._fileno = -1; f.pub._flags = __SRD; @@ -69,7 +68,9 @@ vsscanf(const char *str, const char *fmt, va_list ap) f._read = eofread; f._ub._base = NULL; f._lb._base = NULL; - f._extra = &ext; - INITEXTRA(&f); + f._up = NULL; + f.fl_mutex = PTHREAD_MUTEX_INITIALIZER; + f.fl_owner = NULL; + f.fl_count = 0; return (__svfscanf(&f, fmt, ap)); }