This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/31117] c++locale.o thread-unsafe in libstdc++
- From: "craig dot lawson at centrify dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Mar 2007 23:44:17 -0000
- Subject: [Bug libstdc++/31117] c++locale.o thread-unsafe in libstdc++
- References: <bug-31117-9156@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #28 from craig dot lawson at centrify dot com 2007-03-22 23:44 -------
For HP-UX, SunOS, and Irix:
#if !defined(_POSIX_C_SOURCE)
# define _POSIX_C_SOURCE 199506L
#elif _POSIX_C_SOURCE<199506L
# error "Conflict"
#endif
(why would anyone compile C++ with POSIX < 1995.06?)
For AIX, either:
#define _THREAD_SAFE
or
#define _THREAD_SAFE_ERRNO
Details:
HP-UX 11.00, 11.11, 11.22, 11.23:
errno.h:
#ifdef _REENTRANT
# ifdef _PROTOTYPES
extern int *__errno(void);
# else
extern int *__errno();
# endif
...
However, errno.h includes <sys/stdsyms.h> which contains:
/* _REENTRANT selects Posix 1c threads unless draft4 selected.
* This usage is obsolescent, "-D_POSIX_C_SOURCE=199506" is preferred */
...
#if (_POSIX_C_SOURCE >= 199506) && !defined(_REENTRANT)
# define _REENTRANT
#endif /* _POSIX_C_SOURCE >= 199506 && !_REENTRANT */
It appears _POSIX_C_SOURCE=199506 is the desired symbol and value, but
there will be a conflict if intentionally set to something lower (higher
is OK).
Confirm using test program:
#include <cerrno>
int main() {
return errno;
}
Confirmed: -D_POSIX_C_SOURCE=199506 works.
SunOS 2.6, 7, 5.8, 5.9, 5.10:
errno.h:
#if (defined(_REENTRANT) || defined(_TS_ERRNO) || \
_POSIX_C_SOURCE - 0 >= 199506L) && !(defined(lint) || defined(__lint))
Confirmed: -D_POSIX_C_SOURCE=199506 works.
AIX 4.3.3, 5.1:
errno.h:
#include <standards.h>
#ifdef _ANSI_C_SOURCE
# if defined(_THREAD_SAFE) || defined(_THREAD_SAFE_ERRNO)
# define errno (*_Errno())
standards.h:
defines _ANSI_C_SOURCE unless overridden by some other model.
Confirmed: -D_THREAD_SAFE works.
Confirmed: -D_THREAD_SAFE_ERRNO works.
AIX 5.2:
errno.h: similar to 4.3.3
standards.h:
#if defined(_UNIX03)
# define _THREAD_SAFE
...
#if _XOPEN_SOURCE==600
# define _THREAD_SAFE
...
Due to statement ordering in this file, if _POSIX_C_SOURCE==200112L before
including this file, then _THREAD_SAFE will be set. Otherwise, this file
sets _POSIX_C_SOURCE==200112L and does not set _THREAD_SAFE.
Confirmed: -D_THREAD_SAFE works.
Confirmed: -D_THREAD_SAFE_ERRNO works.
Confirmed: -D_UNIX03 works. Size effect: sets _POSIX_C_SOURCE==200112L
Irix 6.5:
errno.h:
#if defined(_SGI_MP_SOURCE) || (_POSIX_C_SOURCE >= 199506L) \
|| (_XOPEN_SOURCE+0 >= 500)
extern int *__oserror(void);
...
Confirmed: -D_POSIX_C_SOURCE=199506 works.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31117