atomic-fxbox-/fetch! clarification Shiro Kawai (14 Nov 2024 22:04 UTC)
Re: atomic-fxbox-/fetch! clarification Marc Nieper-Wißkirchen (15 Nov 2024 06:55 UTC)
Re: atomic-fxbox-/fetch! clarification Shiro Kawai (15 Nov 2024 07:39 UTC)
Re: atomic-fxbox-/fetch! clarification Marc Nieper-Wißkirchen (15 Nov 2024 07:49 UTC)
Re: atomic-fxbox-/fetch! clarification Shiro Kawai (16 Nov 2024 05:08 UTC)
Re: atomic-fxbox-/fetch! clarification Arthur A. Gleckler (16 Nov 2024 07:29 UTC)

Re: atomic-fxbox-/fetch! clarification Marc Nieper-Wißkirchen 15 Nov 2024 07:49 UTC

Am Fr., 15. Nov. 2024 um 08:39 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>
> I wasn't sure because (- previous-content fx) can be realized by (atomic-fxbox+/fetch! fxbox (- fx)), except the boundary case.    Yet, aligning with stdatomic.h makes more sense.
>
> I wrote tests for srfi-230.  I can make PR for it with the fix of the reference implementation.

That would be great, including the tests! Thanks! Please also add
yourself to the Acknowledgement section in this PR.

Marc

>
>
> On Thu, Nov 14, 2024 at 8:55 PM Marc Nieper-Wißkirchen <xxxxxx@gmail.com> wrote:
>>
>> Dear Shiro,
>>
>> Am Do., 14. Nov. 2024 um 23:04 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>> >
>> > The srfi text says the content is set to "the difference of the previous content and fx".   Does it mean (- previous-content fx), (- fx previous-content), or even (abs (- fx previous-content))?
>> > Reference implementation is (- fx previous-content) . When I read the srfi I took it as (- previous-content fx) so it was a bit of a surprise.  (Maybe I'm conditioned to old CPU's SUB instructions).
>>
>> You were right when you read it as "(- previous-content fx)". The
>> sample implementation is wrong.
>>
>> The SRFI was modelled after the C's <stdatomic.h> (so that it can be
>> efficiently implemented on architectures that can efficiently
>> implement the C interface).  The C version of the atomic subtraction
>> is atomic_fetch_sub.
>>
>> Thanks,
>>
>> Marc
>>
>> >
>> > The wording can be clarified, e.g. "the subtraction of previous-content from fx"?
>> >
>> > --shiro
>> >
>> >