Message ID | CAGWvnynCSzSfJensW4g2yoipF9U4Vxmwrh9Wd84713=Qt180kA@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Sep 8, 2015, at 6:53 AM, David Edelsohn <dje.gcc@gmail.com> wrote: > On Tue, Sep 8, 2015 at 9:51 AM, FX <fxcoudert@gmail.com> wrote: >>> #define _FCLOEXEC 0x0000001000000000L >>> #define O_CLOEXEC _FCLOEXEC /* sets FD_CLOEXEC on open */ >> >> That’s weird, and definitely an AIX bug: http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html > > Welcome to AIX :-/ > >> How does that even work? open() takes int as second arg. > > No one else uses it? ;-) > > The following kluge works: > > Index: posix.c > =================================================================== > --- posix.c (revision 227528) > +++ posix.c (working copy) > @@ -45,6 +45,10 @@ > #define O_BINARY 0 > #endif > > +#ifdef _AIX > +#undef O_CLOEXEC > +#endif > + Not a big issue, but slightly better if (O_CLOEXEC>>32) != 0 is also true. See, if AIX should ever define this to a sensible value, the above would disappear the feature. However, if they did, then this expression should then be false.
> Not a big issue, but slightly better if (O_CLOEXEC>>32) != 0 is also true. See, if AIX should ever define this to a sensible value, the above would disappear the feature. However, if they did, then this expression should then be false.
Sounds good.
This being a libbacktrace patch, you need Ian to approve it, it’s his area.
FX
Mike Stump <mikestump@comcast.net> writes: > Not a big issue, but slightly better if (O_CLOEXEC>>32) != 0 is also > true. See, if AIX should ever define this to a sensible value, the > above would disappear the feature. However, if they did, then this > expression should then be false. Yes, I think this might be even better in code. How about something like /* On some versions of AIX O_CLOEXEC does not fit in int, so use a cast to force it. */ descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); Does that work on AIX? Ian
On Wed, Sep 9, 2015 at 12:12 AM, Ian Lance Taylor <ian@airs.com> wrote: > Mike Stump <mikestump@comcast.net> writes: > >> Not a big issue, but slightly better if (O_CLOEXEC>>32) != 0 is also >> true. See, if AIX should ever define this to a sensible value, the >> above would disappear the feature. However, if they did, then this >> expression should then be false. > > Yes, I think this might be even better in code. How about something > like > > /* On some versions of AIX O_CLOEXEC does not fit in int, so use a > cast to force it. */ > descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); > > Does that work on AIX? Yes, that approach also fixes the warning and the build failure. Thanks, David
On Sep 8, 2015, at 9:12 PM, Ian Lance Taylor <ian@airs.com> wrote: > Yes, I think this might be even better in code. How about something > like > > /* On some versions of AIX O_CLOEXEC does not fit in int, so use a > cast to force it. */ > descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); How about: descriptor = open (filename, /* AIX */ (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); ? It makes it removable in the nearer term. :-)
On Wed, Sep 9, 2015 at 12:12 AM, Ian Lance Taylor <ian@airs.com> wrote: > Mike Stump <mikestump@comcast.net> writes: > >> Not a big issue, but slightly better if (O_CLOEXEC>>32) != 0 is also >> true. See, if AIX should ever define this to a sensible value, the >> above would disappear the feature. However, if they did, then this >> expression should then be false. > > Yes, I think this might be even better in code. How about something > like > > /* On some versions of AIX O_CLOEXEC does not fit in int, so use a > cast to force it. */ > descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); > > Does that work on AIX? Any decision about this patch? Thanks, David
On Thu, Sep 17, 2015 at 7:08 AM, David Edelsohn <dje.gcc@gmail.com> wrote: > On Wed, Sep 9, 2015 at 12:12 AM, Ian Lance Taylor <ian@airs.com> wrote: >> Mike Stump <mikestump@comcast.net> writes: >> >>> Not a big issue, but slightly better if (O_CLOEXEC>>32) != 0 is also >>> true. See, if AIX should ever define this to a sensible value, the >>> above would disappear the feature. However, if they did, then this >>> expression should then be false. >> >> Yes, I think this might be even better in code. How about something >> like >> >> /* On some versions of AIX O_CLOEXEC does not fit in int, so use a >> cast to force it. */ >> descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); >> >> Does that work on AIX? > > Any decision about this patch? This patch is OK if it works. Ian
Index: posix.c =================================================================== --- posix.c (revision 227528) +++ posix.c (working copy) @@ -45,6 +45,10 @@ #define O_BINARY 0 #endif +#ifdef _AIX +#undef O_CLOEXEC +#endif + #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif