summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/findfp.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2001-02-16 06:11:22 +0000
committerimp <imp@FreeBSD.org>2001-02-16 06:11:22 +0000
commit51cffb6bac86b91ac5ec606a7c085d25242b8a7e (patch)
tree89de43324c841cd9d2a9fe23a5b1531d67fed290 /lib/libc/stdio/findfp.c
parent778f80298c10621f10b64d201250c6fcb00793d8 (diff)
downloadFreeBSD-src-51cffb6bac86b91ac5ec606a7c085d25242b8a7e.zip
FreeBSD-src-51cffb6bac86b91ac5ec606a7c085d25242b8a7e.tar.gz
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.
Diffstat (limited to 'lib/libc/stdio/findfp.c')
-rw-r--r--lib/libc/stdio/findfp.c39
1 files changed, 25 insertions, 14 deletions
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);
}
OpenPOWER on IntegriCloud