Re: better atomics - v0.6 - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: better atomics - v0.6
Date
Msg-id 5422E987.7080906@vmware.com
Whole thread Raw
In response to Re: better atomics - v0.6  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: better atomics - v0.6  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
On 09/24/2014 03:37 PM, Andres Freund wrote:
>>> > >+/*
>>> > >+ * pg_fetch_add_until_u32 - saturated addition to variable
>>> > >+ *
>>> > >+ * Returns the the value of ptr after the arithmetic operation.
>>> > >+ *
>>> > >+ * Full barrier semantics.
>>> > >+ */
>>> > >+STATIC_IF_INLINE uint32
>>> > >+pg_atomic_fetch_add_until_u32(volatile pg_atomic_uint32 *ptr, int32 add_,
>>> > >+                              uint32 until)
>>> > >+{
>>> > >+    CHECK_POINTER_ALIGNMENT(ptr, 4);
>>> > >+    return pg_atomic_fetch_add_until_u32_impl(ptr, add_, until);
>>> > >+}
>>> > >+
>> >
>> >This was a surprise to me, I don't recall discussion of an "fetch-add-until"
>> >operation, and hadn't actually ever heard of it before.
> It was included from the first version on, and I'd mentioned it a couple
> times.

There doesn't seem to be any hardware implementations of that in the 
patch. Is there any architecture that has an instruction or compiler 
intrinsic for that?

- Heikki



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [v9.5] Custom Plan API
Next
From: Andres Freund
Date:
Subject: Re: better atomics - v0.6