This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] libstdc++/49745 (review required for the gthr-posix.h changes)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Paolo Carlini <paolo dot carlini at oracle dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, libstdc++ <libstdc++ at gcc dot gnu dot org>, Ian Lance Taylor <iant at google dot com>
- Date: Fri, 15 Jul 2011 15:45:40 +0200
- Subject: Re: [v3] libstdc++/49745 (review required for the gthr-posix.h changes)
- References: <4E2036FA.8020901@oracle.com> <4E204270.5050508@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jul 15, 2011 at 09:36:48AM -0400, Jason Merrill wrote:
> On 07/15/2011 08:47 AM, Paolo Carlini wrote:
> >The patch should be in general quite conservative and safe, in
> >particular, the gthr-posix.h changes, which I cannot approve myself,
> >touch bits only used by libstdc++-v3 + the macro avoiding the
> >unconditional inclusion of <unistd.h>, which, according to Jakub's
> >analysis, should be required only by objc.
>
> I'm a little uncomfortable with defining a macro in libstdc++ to be
> used by the gthr files in gcc. I would lean more toward a
> gthr-posix-conf.h generated by GCC configure.
gthr-posix.h already uses other macros defined by other library
headers, like _LIBOBJC. gthr-posix-conf.h looks like an overkill to me,
but if e.g. libstdc++ headers defined a 0/1 macro always
(_GTHREAD_USE_TIMEDLOCK 0 would mean don't define it, _GTHREAD_USE_TIMEDLOCK 1
would mean you can safely assume timedlock is available, and not presence
of that macro would lead to inclusion of unistd.h and deciding itself
based on _POSIX_TIMEOUTS:
#ifndef _GTHREAD_USE_TIMEDLOCK
#include <unistd.h>
#ifdef _POSIX_TIMEOUTS
#if _POSIX_TIMEOUTS >= 0
#define _GTHREAD_USE_TIMEDLOCK 1
#else
#define _GTHREAD_USE_TIMEDLOCK 0
#else
#define _GTHREAD_USE_TIMEDLOCK 0
#endif
and use
#if _GTHREAD_USE_TIMEDLOCK
...
#endif
then when gthr.h is used outside of libstdc++ it wouldn't depend on
libstdc++ configury.
Jakub