This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tsan] Instrument atomics


On Tue, Nov 27, 2012 at 04:35:33PM +0400, Dmitry Vyukov wrote:
> On Tue, Nov 27, 2012 at 4:27 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Tue, Nov 27, 2012 at 09:23:30AM +0100, Jakub Jelinek wrote:
> >> On Tue, Nov 27, 2012 at 12:13:42PM +0400, Dmitry Vyukov wrote:
> >> > I've added 128-bit atomic ops:
> >> > http://llvm.org/viewvc/llvm-project?view=rev&revision=168683
> >>
> >> Thanks.
> >
> > +#if (defined(__clang__) && defined(__clang_major__) \
> > +      && defined(__clang_minor__) && __clang__ >= 1 && __clang_major__ >= 3 \
> > +      && __clang_minor__ >= 3) \
> > +    || (defined(__GNUC__) && defined(__GNUC_MINOR__) \
> > +      && defined(__GNUC_PATCHLEVEL__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 \
> > +      && __GNUC_PATCHLEVEL__ >= 3)
> >
> > is wrong, one thing is that __int128 is available only on a couple of
> > architectures (i?86/x86_64/ia64 or so), and more importantly, the above
> > isn't true for say GCC 4.7.0, because __GNUC_PATCHLEVEL__ is then < 3.
> > So, either you want something like
> > #define GCC_VERSION ((__GNUC__) * 10000 + (__GNUC_MINOR__) * 100 + (__GNUC_PATCHLEVEL__))
> > and then you can test like #if GCC_VERSION >= 40603
> > or, for the int128 case, much better just to test
> > defined(__GNUC__) && defined(__SIZEOF_INT128__)
> > (no idea if clang doesn't define the same macro, if it does, you could
> > just test for presence of the sizeof macro).
> 
> clang does not support the macro.
> what about
> #if defined(__SIZEOF_INT128__) || defined(__clang__)
> ?

Then for __clang__ you need to do a version check I guess (and, the same
what I wrote applies, consider clang 4.0; don't care about that though),
but for GCC sure, just the #ifdef __SIZEOF_INT128__ is what lots of tests do.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]