This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: libio bitflags help please


Michael Meissner wrote:

> On Wed, Jun 27, 2001 at 10:11:27PM -0400, Robert Schweikert wrote:
> > I am trying to port some code to Linux. THe code uses some bitflags from
> > stdio.h. These are defined on the other OS as follows
> >
> > #define _IOFBF  0000 /* full buffered */
> > #define _IOLBF  0100 /* line buffered */
> > #define _IONBF  0004 /* not buffered */
> > #define _IOEOF  0020 /* EOF reached on read */
> > #define _IOERR  0040 /* I/O error from system */
> >
> > #define _IOREAD  0001 /* currently reading */
> > #define _IOWRT  0002 /* currently writing */
> > #define _IORW  0200 /* opened for reading and writing */
> >
> > Looking in  stdio.h I can find the following
> >
> > #define _IOFBF 0   /* Fully buffered.  */
> > #define _IOLBF 1  /* Line buffered.  */
> > #define _IONBF 2  /* No buffering.  */
> >
> > thus I have a 1 to 1 relation of the names for the buffering flags. Then
> > looking in libio.h I can find the following
> >
> > #define _IO_NO_READS 4 /* Reading not allowed */
> > #define _IO_NO_WRITES 8 /* Writing not allowd */
> > #define _IO_EOF_SEEN 0x10
> > #define _IO_ERR_SEEN 0x20
> >
> > thus I can establish the following in the code I am trying to port
> >
> > #idef LINUX
> > #define _IOEOF       _IO_EOF_SEEN
> > #define _IOERR       _IO_ERR_SEEN
> > #define _IOREAD    ~_IO_NO_READS
> > #define _IOWRT      ~_IO_NO_WRITES
> > #endif
> >
> > But what do I do with _IORW?
>
> You stop writing code that peers into FILE structures.

Well, I didn't write it, and I agree with you, this shouldn't have been done. How
can I do this better?

Thanks,
Robert

> The only macros listed
> above that you can use portably are:
>
>         _IOFBF
>         _IOLBF
>         _IONBF
>
> and you can only use those in calling the setvbuf function.  Anything else, and
> you are justing asking for trouble about making non-portable assumptions.  It
> may work on another OS, and it may work when you upgrade your Linux system, but
> all bets are off.
>
> --
> Michael Meissner, Red Hat, Inc.  (GCC group)
> PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
> Work:     meissner@redhat.com           phone: +1 978-486-9304
> Non-work: meissner@spectacle-pond.org   fax:   +1 978-692-4482

--
Robert Schweikert                      MAY THE SOURCE BE WITH YOU
rjschwei@mindspring.com                         LINUX




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