This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

_REENT_SMALL IO broken


On _REENT_SMALL targets stdin/out/err are initialized to dummy values. The 
read FILE structures are then allocated the first time the IO functions are 
used.

However this doesn't work because the IO routines don't do any translation 
between the initial dummy structures and the real FILE structures. This means 
the first call to an IO routine fails.

If fact if the user creates a local copy of stdout before writing to it, then 
uses that all IO will fail.

I see a few possibilities for fixing this:

a) Every use of a file descriptor needs to check if it has the read FD, or a 
dummy copy. In this case there's no point having the dummy structure, we can 
just assign stdin/out/err magic values. As a bonus _reent gets even smaller, 
at the expense of a small code size increase.
b) Split __FILE into static (__sFILE_fake) and dynamic (the rest) sections. 
This introduces an extra level of indirection for acessing the dynamic 
fields.
c) Decide it's not worth the effort and allocate the full FILE structure in 
_reent.

(c) is the easiest to implement. (b) should be fairly straightforward because 
any missed bits will cause build failures. (c) is the most work because it 
requires manually auditing the IO code.

Any preference, or suggestions of better solutions?

Paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]