From: Andrew Cooper Subject: Re: [PATCH v3 8/8] asm-x86/atomic.h: implement missing, add common prototypes Date: Thu, 14 Jul 2016 10:44:12 +0100 Message-ID: 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="===============7576064199873288032==" Return-path: In-Reply-To: <7b0bacae-aa5b-6427-28bd-49bbe81b16b5@bitdefender.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Corneliu ZUZU , xen-devel@lists.xen.org Cc: Jan Beulich List-Id: xen-devel@lists.xenproject.org --===============7576064199873288032== Content-Type: multipart/alternative; boundary="------------E5E166EB6B743F78EF33DF0F" --------------E5E166EB6B743F78EF33DF0F Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 --------------E5E166EB6B743F78EF33DF0F Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit
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
--------------E5E166EB6B743F78EF33DF0F-- --===============7576064199873288032== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============7576064199873288032==--