lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Apr 01, 2014 at 04:40:03PM -0300, Roberto Ierusalimschy wrote:
> > _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.
> 
> Maybe a better sollution is to change liolib.c like this:
> 
<snip>
> -#if defined(LUA_USE_POSIX)
> +#if defined(LUA_USE_POSIX) && (!defined(__sun) || defined(_REENTRANT))

I prefer just adding _REENTRANT to the Solaris target CPPFLAGS, otherwise
people will needlessly get different behavior on Solaris than on other Unix
systems. Few will know to enable it, and there's no indication that they're
getting less-than-desirable behavior. At least with -work3 compilation
fails.

I wish I could test on HP/UX or AIX, to see if it's needed there, but those
companies don't make life easy for open source developers doing portability
work. But I'm fairly confident just setting _REENTRANT unconditionally on
all POSIX platforms would work without problems, given the extensive history
of its usage. My only hesitation is that on platforms I haven't tested, it
might require linking to the threading library. But I unconditionally define
_REENTRANT in all my projects, and I regularly build and test them on Linux,
NetBSD, FreeBSD, OpenBSD, OS X, and Solaris.

In any event, this is only being done for Solaris, where _REENTRANT is still
a commonly used idiom, and where it does not trigger a requirement to link
in any additional libraries.