------- 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

Reply via email to