[uClibc]FILE->bufpos

Manuel Novoa III mjn3 at codepoet.org
Wed Apr 3 16:05:29 UTC 2002


Trevor,

On Wed, Apr 03, 2002 at 10:23:23AM -0500, trevor wrote:
> i'm trying to build ruby-1.6.7 against uClibc-0.9.10 and i've ended up with 
> the following problem. basically the ruby sources are aware of uClibc and 
> define a macro for FILE handling:
> 
> --- from io.c ---
> #elif defined(__UCLIBC__)
> #  define READ_DATA_PENDING(fp) ((fp)->bufpos < (fp)->bufend)
> --- end ---

The stdio code for uClibc was completely rewritten and the new code went
into cvs a couple of weeks ago.  But that doesn't look right even for
the old code.  For the old code, the above would test if the in-buffer
position had reached the physical end of the buffer... which isn't the
same as the end of the valid readable data.  That would have tested
((fp)->bufpos < (fp)->bufread).

> problem is that during the compile i get errors like the following:
> 
> ../ruby-1.6.7/io.c: In function `rb_read_pending':
> ../ruby-1.6.7/io.c:178: structure has no member named `bufpos'
> 
> ...
> 
> performing a "grep -r -i bufpos *" at the base of my uClibc "include" 
> directory doesn't turn anything up.

If what you're trying to do is see if there is any buffered data to read
for the stream with the new stdio implementation, you could try the
(untested) code:

#elif defined(__UCLIC__)
#  define READ_DATA_PENDING(fp) \
	( ((fp)->modeflags & __FLAG_READING) \
	  && ( ((fp)->bufrpos < (fp)->bufwpos) \
	      || ((fp)->modeflags & __MASK_UNGOT) ) )

but be aware that the above is only valid if stdio is built with
buffering and without thread support and (in the near future) the stream
isn't wide oriented.

Now, if you know the stream is read-only, you can get rid of the
__FLAG_READING test.  Similarly, if you never call ungetc() or *scanf()
on the stream, you can get rid of the __MASK_UNGOT test.

Currently, there aren't any official macros to test for some features
(stdio built with/without buffering and stdio built with wide support).
That will change when Erik gets the new configuration system in place
and I enable stdio build-feature selection.

Manuel




More information about the uClibc mailing list