[RFC/patch] New iteration at fixing 9533

Paolo Carlini pcarlini@unitus.it
Sun Mar 23 13:41:00 GMT 2003


Nathan Myers wrote:

>"S_ISREG(m)" is the preferred interface.  When S_ISREG isn't defined,
>you have to use "(S_IFREG & (m))" instead.  An expression "S_IFREG(m)"
>would expand to "0100000(m)", a syntax error.  Of course you haven't
>seen this, because where you test, you have had S_ISREG() defined.
>
Ah, ok, but you didn't tell me about this before!
If AC_DEFINE actually supports the syntax you suggested

    AC_DEFINE(_GLIBCPP_S_ISREG_OR_S_IFREG(m), (S_IFREG & (m)))

it's easy, but I'm not sure. Are you?

>BTW, Stevens seems to suggest that some targets have <ioctl.h> but
>not <sys/ioctl.h>.  Sorry to be a pest.
>
Well, you are welcome, but then please be a pest also with the libjava 
people not only with me! ;)
See, e.g., libjava/java/net/natPlainSocketImplPosix.cc.

>  The problem is that this
>sort of thing would not show up in testing; instead, ./configure
>would just not find FIONREAD, then.
>
What has configure to do with FIONREAD???
Configure looks for sys/ioctl.h and sys/filio.h. Then this code:

#ifdef _GLIBCPP_HAVE_SYS_IOCTL_H
#define BSD_COMP /* Get FIONREAD on Solaris2. */
#include <sys/ioctl.h>
#endif

// Pick up FIONREAD on Solaris 2.5.
#ifdef _GLIBCPP_HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif

includes the correct header. Below:

#ifdef FIONREAD
    // Pipes and sockets.    
    int __num = 0;
    int __r = ioctl(this->fd(), FIONREAD, &__num);
    if (!__r && __num >= 0)
      return __num; 
#endif  

if FIONREAD is not defined, there is no ioctl call at all!

Paolo.



More information about the Libstdc++ mailing list