From: Corneliu ZUZU Subject: Re: [PATCH v3 8/8] asm-x86/atomic.h: implement missing, add common prototypes Date: Thu, 14 Jul 2016 12:48:17 +0300 Message-ID: <90a51dc5-3d39-90d8-b800-e1ddf67088fa@bitdefender.com> References: <1468487370-12345-1-git-send-email-czuzu@bitdefender.com> <1468487697-12705-1-git-send-email-czuzu@bitdefender.com> <69de8af9-1c5b-383a-adce-c60c85d7d3f2@citrix.com> <7b0bacae-aa5b-6427-28bd-49bbe81b16b5@bitdefender.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0295519809258215263==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Andrew Cooper , xen-devel@lists.xen.org Cc: Jan Beulich List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --===============0295519809258215263== Content-Type: multipart/alternative; boundary="------------7A286CC24F25F570C94D7E82" This is a multi-part message in MIME format. --------------7A286CC24F25F570C94D7E82 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 7/14/2016 12:44 PM, Andrew Cooper wrote: > On 14/07/16 10:39, Corneliu ZUZU wrote: >> On 7/14/2016 12:29 PM, Andrew Cooper wrote: >>> On 14/07/16 10:14, Corneliu ZUZU wrote: >>>> - implement missing functions atomic_{sub,inc,dec}_return(), atomic_add_unless() >>>> on X86 and also add prototypes for them in common >>>> >>>> - add missing macro atomic_xchg for X86 >>>> >>>> Signed-off-by: Corneliu ZUZU >>> >>> Reviewed-by: Andrew Cooper >> >> I'm not sure about atomic_sub_return(int i, atomic_t *v) >> implementation - is it ok? (calling arch_fetch_and_add(&v->counter, >> -i) with 2nd argument negative). > > Looks ok to me. Everything is signed integers in the internals. > > There is a boundary condition when passing INT_MIN, but those exist > elsewhere as well. > > ~Andrew Thanks, thought so too - there should be no difference bit-wise when adding an unsigned int converted from an int vs adding the int directly. Zuzu C. --------------7A286CC24F25F570C94D7E82 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 7/14/2016 12:44 PM, Andrew Cooper wrote:
On 14/07/16 10:39, Corneliu ZUZU wrote:
On 7/14/2016 12:29 PM, Andrew Cooper wrote:
On 14/07/16 10:14, Corneliu ZUZU wrote:
- implement missing functions atomic_{sub,inc,dec}_return(), atomic_add_unless()
  on X86 and also add prototypes for them in common <xen/atomic.h>

- add missing macro atomic_xchg for X86

Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

I'm not sure about atomic_sub_return(int i, atomic_t *v) implementation - is it ok? (calling arch_fetch_and_add(&v->counter, -i) with 2nd argument negative).

Looks ok to me.  Everything is signed integers in the internals.

There is a boundary condition when passing INT_MIN, but those exist elsewhere as well.

~Andrew

Thanks, thought so too - there should be no difference bit-wise when adding an unsigned int converted from an int vs adding the int directly.

Zuzu C.
--------------7A286CC24F25F570C94D7E82-- --===============0295519809258215263== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============0295519809258215263==--