diff options
author | peter <peter@FreeBSD.org> | 2001-02-20 01:56:52 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-02-20 01:56:52 +0000 |
commit | f64981b39c5749e3ac5f623486862d9aa4fbd128 (patch) | |
tree | b36dad284b8b696a4c71698e13a77dcd78c2c0ad /lib | |
parent | 0a9dc4546f3795ce82db64112b0b7be37cb4c246 (diff) | |
download | FreeBSD-src-f64981b39c5749e3ac5f623486862d9aa4fbd128.zip FreeBSD-src-f64981b39c5749e3ac5f623486862d9aa4fbd128.tar.gz |
Place some hooks (__stdin, __stdout, __stderr) into libc for a future
ABI change. There is some serious evilness here to work around some
gcc weaknesses. We need to know the sizeof(FILE) manually until __sF
goes away in the next major bump. We have the size for Alpha and i386,
missing is ia64, ppc and sparc* (and i386 with 64 bit longs).
At some point down the track we can change the stdin etc #defines to
stop hard coding the size of FILE into application binaries.
Lots of head scratching and ideas and testing by: green, imp
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdio/findfp.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index 4911400..3754258 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -77,6 +77,26 @@ FILE __sF[3] = { std(__SWR|__SNBF, STDERR_FILENO) }; +/* + * The following kludge is done to ensure enough binary compatibility + * with future versions of libc. Or rather it allows us to work with + * libraries that have been built with a newer libc that defines these + * 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); + struct glue __sglue = { &uglue, 3, __sF }; static struct glue *lastglue = &uglue; @@ -213,11 +233,14 @@ _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. */ |