This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: [RFC/patch] New iteration at fixing 9533


On Sun, Mar 23, 2003 at 12:25:15PM +0100, Paolo Carlini wrote:
> Nathan Myers wrote:
> 
> >On Sat, Mar 22, 2003 at 08:03:18PM +0100, Paolo Carlini wrote:
> > 
> >
> >>this is the second try.
> >>...
> >>+dnl
> >>+dnl Check whether S_ISREG (Posix) or S_IFREG is available in 
> >><sys/stat.h>.
> >>+dnl
> >>+
> >>+AC_DEFUN(GLIBCPP_CHECK_S_ISREG_OR_S_IFREG, [
> >>...
> >>+  AC_CACHE_VAL(glibcpp_cv_S_IFREG, [
> >>+    AC_TRY_LINK([#include <sys/stat.h>],
> >>+                [struct stat buffer; fstat(0, &buffer); 
> >>S_IFREG(buffer.st_mode); ],
> >>+                [glibcpp_cv_S_IFREG=yes],
> >>+                [glibcpp_cv_S_IFREG=no])
> >>+  ])
> >>+  if test x$glibcpp_cv_S_ISREG = xyes; then
> >>+    AC_DEFINE(_GLIBCPP_S_ISREG_OR_S_IFREG, S_ISREG)
> >>+  elif test x$glibcpp_cv_S_IFREG = xyes; then
> >>+    AC_DEFINE(_GLIBCPP_S_ISREG_OR_S_IFREG, S_IFREG)
> >>+  fi
> >>+])
> >>   
> >>
> >I think S_IFREG is a regular numeric constant, so we should be testing
> >the expression (S_IFREG & buffer.st_mode), and the macro should (somehow) 
> >end up as "#define _GLIBCPP_S_ISREG_OR_S_IFREG(m) (S_IFREG & (m))".  
> >Maybe that's
> >
> >  AC_DEFINE(_GLIBCPP_S_ISREG_OR_S_IFREG(m), (S_IFREG & (m)))
> >
> I'm not sure to understand what you mean. What's the role of S_ISREG here?

"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.

BTW, Stevens seems to suggest that some targets have <ioctl.h> but
not <sys/ioctl.h>.  Sorry to be a pest.  The problem is that this
sort of thing would not show up in testing; instead, ./configure
would just not find FIONREAD, then.  Did you know you can say

  #include _GLIBCPP_IOCTL_H

and define _GLIBCPP_IOCTL_H as either <ioctl.h> or <sys/ioctl.h>,
according to what configure finds?

Nathan Myers
ncm-nospam at cantrip dot org


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