This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: [PATCH 1/2] Optimize generic spinlock code and use C11 like atomic macros.


On Tue, 2017-04-11 at 09:06 +0200, Stefan Liebler wrote:
> On 04/10/2017 03:36 PM, Andreas Schwab wrote:
> > On Apr 10 2017, Stefan Liebler <stli@linux.vnet.ibm.com> wrote:
> >
> >> On 04/10/2017 10:17 AM, Andreas Schwab wrote:
> >>> On Apr 07 2017, Stefan Liebler <stli@linux.vnet.ibm.com> wrote:
> >>>
> >>>> /* ATOMIC_EXCHANGE_USES_CAS is equal to 1 if atomic_exchange operations
> >>>
> >>> Why 1 exactly, and not just non-zero?
> >>>
> >>> Andreas.
> >>>
> >>
> >> This points out that there is only a true/false choice and
> >> all architectures have to define it.
> >
> > That doesn't answer my question.  Why do you need the dance of checking
> > for 1 explicitly?
> >
> > Andreas.
> >
> At the moment there is only a choice between 0 and 1.

This is fine.  There is no reason to allow a different value even if
this is just a boolean.

> The check ensures that ATOMIC_EXCHANGE_USES_CAS is defined and it has a 
> specific value.
> If someone defines it to another value, he will get an error here.
> Then the check and the comment is hopefully updated, too.

The comments make it clear that it has to be 0 or 1, and can be used
without explicitly checking the value.

We can add the explicit check once, as you did in atomic.h, but I don't
think it's neither required nor a bad thing to do.


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