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: "dave at hiauly1 dot hia dot nrc dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Mar 2007 00:56:50 -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 #30 from dave at hiauly1 dot hia dot nrc dot ca 2007-03-23 00:56 -------
Subject: Re: c++locale.o thread-unsafe in libstdc++
> ------- Comment #29 from pcarlini at suse dot de 2007-03-23 00:29 -------
> Thanks a lot Craig. Touching _POSIX_C_SOURCE makes me a little nervous, in
> particular if that ends up changing _REENTRANT, as happens on HP-UX. I'd like
> to ask Dave opinion about it, whether to his best knowledge there is a safe,
> minimal way to have a thread-safe errno on HP-UX. Otherwise, probably for now
> we have to be contect to fix only SunOS and AIX (with _THREAD_SAFE_ERRNO), all
> in all the most important targets these days besides Linux and Darwin.
This is how _POSIX_C_SOURCE affects _REENTRANT on 11.11:
# if (_POSIX_C_SOURCE >= 199506) && !defined(_REENTRANT)
# define _REENTRANT
# endif /* _POSIX_C_SOURCE >= 199506 && !_REENTRANT */
In sys/errno.h:
# if defined(_REENTRANT) && !defined(_PTHREADS_DRAFT4)
/* Get errno definition by including <errno.h> not <sys/errno.h> */
# else /* ! _REENTRANT || _PTHREADS_DRAFT4 */
extern int errno;
# endif /* ! _REENTRANT || _PTHREADS_DRAFT4 */
In errno.h, errno is defined as follows when _REENTRANT is defined:
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
#ifdef _PROTOTYPES
extern int *__errno(void);
#else
extern int *__errno();
#endif
#define errno (*__errno())
...
Don't see a thread safe implementation in HP-UX 10. I'd be hesitant
about using __errno directly.
Dave
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31117