[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available
- From: William Ahern <william@...>
- Date: Tue, 1 Apr 2014 11:51:32 -0700
On Tue, Apr 01, 2014 at 12:51:41PM -0400, Sean Conner wrote:
> It was thus said that the Great Roberto Ierusalimschy once stated:
> > > It was thus said that the Great Roberto Ierusalimschy once stated:
> > > > > On Solaris flockfile and friends aren't visible by default. [...]
> > > >
> > > > Do you know a reliable environment variable that can be used to detect
> > > > Solaris and friends?
> > >
> > > When compiling C code, I check for __SunOS. As for environment variable,
> > > I just logged into our Solaris systems and found
> > >
> > > $HOSTTYPE
> > > $MACHTYPE
> > >
> > > set ("sparc" and "sparc-sun-solaris2.10" respectively). I don't know if
> > > those will always be set.
> >
> > Can you check whether Lua compiles if you define
> > -D_POSIX_C_SOURCE=199506L (or just -D_POSIX_C_SOURCE),
> > instead of -D_REENTRANT? Would you have any reason to prefer
> > one to another?
<snip>
> Using -D_GNU_SOURCE fixed the mkstemp() declaration, but we got warnings
> for the implicit declaration of flockfile(), getc_unlocked() and
> funlockfile(). Defining both _GNU_SOURCE and _POSIX_C_SOURCE=199506L still
> left mkstemp() implicitely declared:
>
> gcc -O2 -Wall -Wextra -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_GNU_SOURCE -D_POSIX_C_SOURCE=199506L -c -o loslib.o loslib.c
> loslib.c: In function _tmpname':
> loslib.c:132: warning: implicit declaration of function `mkstemp'
>
> I'm at a loss.
>
It's been my experience that using POSIX features macros hinders
portability. Most portable software uses non-standard extensions which are
nonetheless nearly universal. Setting POSIX macros hides those, and there's
no easy way to get them back again; certainly not portably, and not without
digging into the header files and untangling the mess of #ifdefs.
Also, a system might only support an older POSIX standard even though it
implements most of the interfaces from a more recent edition. mkstemp falls
into this category. mkstemp is in the most recent edition of POSIX, but
Solaris doesn't yet support this edition, although it does have mkstemp.
_REENTRANT is a very common way to signal use of a threaded environment, and
it's orthogonal to the other feature macros on a platform, so you don't run
the risk of accidentally triggering a conformance mode.
FWIW, I got flockfile to appear with -D_POSIX_C_SOURCE=199506L, but then
mkstemp disappeared. I'm using Solaris 11 (aka SunOS 5.11) with
Solaris-packaged GCC 4.5.2.
I also got Lua 5.3 to compile using the native Solaris Studio compiler. I
just needed to remove the GCC CFLAGS flags, and of course I had to define
_REENTRANT. The only warnings I got were:
"lstrlib.c", line 1043: warning: integer overflow detected: op "<<"
"lstrlib.c", line 1043: warning: integer overflow detected: op "<<"
"lstrlib.c", line 1044: warning: integer overflow detected: op "<<"
"lstrlib.c", line 1044: warning: integer overflow detected: op "<<"
"lstrlib.c", line 1044: warning: integer overflow detected: op "<<"
"lstrlib.c", line 1044: warning: integer overflow detected: op "<<"
"lstrlib.c", line 1045: warning: integer overflow detected: op "<<"