From 2b618987fee88c4b3253d840a59f52680bfec2a6 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Mon, 13 Aug 2001 21:48:44 +0000 Subject: [PATCH] Rip out the old __stdin/out/err stuff. It was completely 100% useless. :-( It was foiled because of dynamic copy relocations that caused compile-time space to be reserved in .bss and at run time a blob of data was copied to that space and everything used the .bss version.. The problem is that the space is reserved at compile time, not runtime... So we *still* could not change the size of FILE. Sigh. :-( Replace it with something that does actually work and really does let us make 'FILE' extendable. It also happens to be the same as Linux does in glibc, but has the slight cost of a pointer. Note that this is the same cost that 'fp = fopen(), fprintf(fp, ...); fclose(fp);' has. Fortunately, actual references to stdin/out/err are not all that common since we have implicit stdin/out/err-using versions of functions (printf() vs. fprintf()). --- include/stdio.h | 10 ++++++++++ lib/libc/Makefile | 3 ++- lib/libc/stdio/findfp.c | 21 ++++++--------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/stdio.h b/include/stdio.h index 431eab0e6852..d60ed88a8d88 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -132,6 +132,9 @@ typedef struct __sFILE { __BEGIN_DECLS extern FILE __sF[]; +extern FILE *__stdinp; +extern FILE *__stdoutp; +extern FILE *__stderrp; __END_DECLS #define __SLBF 0x0001 /* line buffered */ @@ -194,9 +197,16 @@ __END_DECLS #define SEEK_END 2 /* set file offset to EOF plus offset */ #endif +/* To be removed by 5.0-RELEASE */ +#if (defined(__i386__) || defined(__alpha__)) && !defined(_FIXED_STDIO) #define stdin (&__sF[0]) #define stdout (&__sF[1]) #define stderr (&__sF[2]) +#else +#define stdin __stdinp +#define stdout __stdoutp +#define stderr __stderrp +#endif /* * Functions defined in ANSI C standard. diff --git a/lib/libc/Makefile b/lib/libc/Makefile index cdb5011c3571..9ac83d97cf5c 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -9,7 +9,8 @@ LIB=c SHLIB_MAJOR= 5 SHLIB_MINOR= 0 -CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/include +CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/include -I${.CURDIR}/../../include +CFLAGS+=-DLIBC_MAJOR=${SHLIB_MAJOR} AINC= -I${.CURDIR}/${MACHINE_ARCH} CLEANFILES+=tags INSTALL_PIC_ARCHIVE= yes diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index 9e7bc28f1182..8b284318a0db 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -71,6 +71,9 @@ static struct glue uglue = { NULL, FOPEN_MAX - 3, usual }; static struct __sFILEX __sFX[3]; +#if LIBC_MAJOR >= 6 +static +#endif FILE __sF[3] = { std(__SRD, STDIN_FILENO), std(__SWR, STDOUT_FILENO), @@ -84,18 +87,9 @@ FILE __sF[3] = { * symbols and expects libc to provide them. We only have need to support * i386 and alpha because they are the only "old" systems we have deployed. */ -#if defined(__i386__) -#define FILE_SIZE 88 -#elif defined(__alpha__) -#define FILE_SIZE 152 -#endif -#ifndef FILE_SIZE -#error "You must define FILE_SIZE for this platform" -#endif -#define X(loc, sym) __strong_reference(loc, sym) -X(__sF + FILE_SIZE * 0, __stdin); -X(__sF + FILE_SIZE * 1, __stdout); -X(__sF + FILE_SIZE * 2, __stderr); +FILE *__stdinp = &__sF[0]; +FILE *__stdoutp = &__sF[1]; +FILE *__stderrp = &__sF[2]; struct glue __sglue = { &uglue, 3, __sF }; static struct glue *lastglue = &uglue; @@ -233,14 +227,11 @@ _cleanup() /* * __sinit() is called whenever stdio's internal variables must be set up. */ -#define SIZEMSG "WARNING: FILE_SIZE != sizeof(FILE)\n" void __sinit() { int i; - if (FILE_SIZE != sizeof(FILE)) - write(2, SIZEMSG, sizeof(SIZEMSG) - 1); THREAD_LOCK(); if (__sdidinit == 0) { /* Set _extra for the usual suspects. */