From 51cffb6bac86b91ac5ec606a7c085d25242b8a7e Mon Sep 17 00:00:00 2001 From: imp Date: Fri, 16 Feb 2001 06:11:22 +0000 Subject: Fix the current libc breakage in current: o Back out the __std* stuff. Can't figure out how to do this right now, so we'll save it for late. o use _up as a pointer for extra fields that we need to access. o back out the libc major version bump. Submitted by: green reviewed by: peter, imp, green, obrien (to varying degrees). We'll fix the "how do we stop encoding sizeof(FILE) in binaries" part later. --- lib/libc/Makefile | 2 +- lib/libc/stdio/_flock_stub.c | 10 ++++++++++ lib/libc/stdio/findfp.c | 39 +++++++++++++++++++++++++-------------- lib/libc/stdio/fseek.c | 2 +- lib/libc/stdio/refill.c | 2 +- lib/libc/stdio/ungetc.c | 2 +- 6 files changed, 39 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/libc/Makefile b/lib/libc/Makefile index 3b6ea2a..cdb5011 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -7,7 +7,7 @@ # from CFLAGS below. To remove these strings from just the system call # stubs, remove just -DSYSLIBC_RCS from CFLAGS. LIB=c -SHLIB_MAJOR= 5.20010213 +SHLIB_MAJOR= 5 SHLIB_MINOR= 0 CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/include AINC= -I${.CURDIR}/${MACHINE_ARCH} diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c index 8bea66d..a77fad9 100644 --- a/lib/libc/stdio/_flock_stub.c +++ b/lib/libc/stdio/_flock_stub.c @@ -68,6 +68,16 @@ struct __file_lock { }; /* + * We need to retain binary compatibility for a while. So pretend + * that _lock is part of FILE * even though it is dereferenced off + * _extra now. When we stop encoding the size of FILE into binaries + * this can be changed in stdio.h. This will reduce the amount of + * code that has to change in the future (just remove this comment + * and #define). + */ +#define _lock _extra->_mtlock + +/* * Allocate and initialize a file lock. */ static int diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index 48eb5b5..e0f0e29 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -59,21 +59,24 @@ int __sdidinit; #define NDYNAMIC 10 /* add ten more whenever necessary */ -#define std(handle, flags, file) \ -FILE handle = {0,0,0,flags,file,{0},0,&handle,__sclose,__sread,__sseek,__swrite} -/* p r w flags file _bf z cookie close read seek write */ - +#define std(flags, file) \ + {0,0,0,flags,file,{0},0,__sF+file,__sclose,__sread,__sseek,__swrite, \ + {0}, __sFX + file} + /* p r w flags file _bf z cookie close read seek write */ + /* _ub _extra */ /* the usual - (stdin + stdout + stderr) */ static FILE usual[FOPEN_MAX - 3]; static struct glue uglue = { NULL, FOPEN_MAX - 3, usual }; -std(__stdin, __SRD, STDIN_FILENO); -std(__stdout, __SWR, STDOUT_FILENO); -std(__stderr, __SWR|__SNBF, STDERR_FILENO); +static struct __sFILEX __sFX[3]; + +FILE __sF[3] = { + std(__SRD, STDIN_FILENO), + std(__SWR, STDOUT_FILENO), + std(__SWR|__SNBF, STDERR_FILENO) +}; -static struct glue sglue2 = { &uglue, 1, &__stderr }; -static struct glue sglue1 = { &sglue2, 1, &__stdout }; -struct glue __sglue = { &sglue1, 1, &__stdin }; +struct glue __sglue = { &uglue, 3, __sF }; static struct glue *lastglue = &uglue; static struct glue * moreglue __P((int)); @@ -93,18 +96,26 @@ moreglue(n) int n; { struct glue *g; - FILE *p; static FILE empty; + static struct __sFILEX emptyx; + FILE *p; + struct __sFILEX *fx; - g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE)); + g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE) + + n * sizeof(struct __sFILEX)); 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; + while (--n >= 0) { + *p = empty; + p->_extra = fx; + *p->_extra = emptyx; + p++, fx++; + } return (g); } diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index f873975..b434350 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -204,7 +204,7 @@ _fseeko(fp, offset, whence) */ if (HASUB(fp)) { curoff += fp->_r; /* kill off ungetc */ - n = fp->_up - fp->_bf._base; + n = fp->_extra->_up - fp->_bf._base; curoff -= n; n += fp->_ur; } else { diff --git a/lib/libc/stdio/refill.c b/lib/libc/stdio/refill.c index b597f97..2adb3a7 100644 --- a/lib/libc/stdio/refill.c +++ b/lib/libc/stdio/refill.c @@ -109,7 +109,7 @@ __srefill(FILE *fp) if (HASUB(fp)) { FREEUB(fp); if ((fp->_r = fp->_ur) != 0) { - fp->_p = fp->_up; + fp->_p = fp->_extra->_up; return (0); } } diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c index 872abad..f70fb42 100644 --- a/lib/libc/stdio/ungetc.c +++ b/lib/libc/stdio/ungetc.c @@ -164,7 +164,7 @@ __ungetc(int c, FILE *fp) * Initially, we will use the `reserve' buffer. */ fp->_ur = fp->_r; - fp->_up = fp->_p; + fp->_extra->_up = fp->_p; fp->_ub._base = fp->_ubuf; fp->_ub._size = sizeof(fp->_ubuf); fp->_ubuf[sizeof(fp->_ubuf) - 1] = c; -- cgit v1.1