Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 27 Mar 2016 18:27:45 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH 1/2] add 64bit atomics on top of 64bit ll/sc
 primitives

On Sun, Mar 27, 2016 at 04:20:18PM -0500, Bobby Bingham wrote:
> ---
>  src/internal/atomic.h | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/src/internal/atomic.h b/src/internal/atomic.h
> index 6f37d25..43a8a00 100644
> --- a/src/internal/atomic.h
> +++ b/src/internal/atomic.h
> @@ -99,6 +99,34 @@ static inline void *a_cas_p(volatile void *p, void *t, void *s)
>  
>  #endif
>  
> +#ifdef a_ll_64
> +
> +#ifndef a_and_64
> +#define a_and_64 a_and_64
> +static inline void a_and_64(volatile uint64_t *p, uint64_t v)
> +{
> +	uint64_t old;
> +	a_pre_llsc();
> +	do old = a_ll_64(p);
> +	while (!a_sc_64(p, old & v));
> +	a_post_llsc();
> +}
> +#endif
> +
> +#ifndef a_or_64
> +#define a_or_64 a_or_64
> +static inline void a_or_64(volatile uint64_t *p, uint64_t v)
> +{
> +	uint64_t old;
> +	a_pre_llsc();
> +	do old = a_ll_64(p);
> +	while (!a_sc_64(p, old | v));
> +	a_post_llsc();
> +}
> +#endif

I think we can do without these. a_and_64 and a_or_64 are simply
misnamed (they're only usable as atomic bitset/bitclear, not
necessarily atomic on the whole 64-bit unit since they only operate on
one bit at a time) and I don't think there's any measurable gain to be
had by doing them with 64-bit hardware atomics. They'll probably be
dropped at some point in the future anyway; malloc is essentially the
only user.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.