Cleaning up FILE in stdio..
Peter Jeremy
peterjeremy at optushome.com.au
Wed Feb 27 06:59:31 UTC 2008
On Tue, Feb 26, 2008 at 11:55:16PM -0500, John Baldwin wrote:
>Yes, I discovered the macros today while working on my fd as short problem.
Macros and __inline functions mean that a significant proportion of
software compiled on FreeBSD has the existing definition of FILE
compiled into it.
>However, I can't fix the fact that our stdio can't handle fd's > SHRT_MAX
>(again, glibc handles this just fine) w/o making a royal mess.
I don't think a versioned FILE is practical so we are stuck with a
16-bit _file for the immediate future.
>What I've gone with instead to fix the SHRT_MAX problem is to change
>fopen/fdopen/freopen to fail to use fd's > SHRT_MAX with an error.
You could change _file from 'short' to 'unsigned short' without breaking
the ABI - this would allow either 65535 or 65536 file descriptors (I'm
not sure whether _file == -1 is special or not). This would postpone
the problem for some time.
My suggestion would be:
Now:
a) change _file to 'unsigned short' and add checks as proposed
b) merge __sFILEX into FILE
c) Remove the macros and inlines that poke around inside FILE
d) Note that directly accessing FILE innards is deprecated and
move the definition of struct __sFILE into libc/stdio/local.h
Once RELENG_8 is branched:
e) Don asbestos underwear and re-arrange struct __sFILE to grow _file etc.
--
Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20080227/3a922094/attachment.pgp
More information about the freebsd-arch
mailing list