From: John Levon Subject: [PATCH] compile fix for RING_HAS_UNCONSUMED_REQUESTS Date: Tue, 17 Oct 2006 14:29:53 +0100 Message-ID: <20061017132953.GA7307@totally.trollied.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User john.levon@sun.com # Date 1161091691 25200 # Node ID ae762c159e7311a5a19e6b29227a665994a1325b # Parent a58e7e6dde6b1f6094ea07917b3db794082c409b fixes to compile ring.h on solaris with Sun's cc Signed-off-by: Mark Johnson diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h --- a/xen/include/public/io/ring.h +++ b/xen/include/public/io/ring.h @@ -27,6 +27,12 @@ typedef unsigned int RING_IDX; #define __RING_SIZE(_s, _sz) \ (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) +/* Solaris equivalents */ +#ifdef _SOLARIS +#define wmb membar_producer +#define mb membar_enter +#endif + /* * Macros to make the correct C datatypes for a new kind of ring. * @@ -166,12 +172,10 @@ typedef struct __name##_back_ring __name ((_r)->sring->rsp_prod - (_r)->rsp_cons) #define RING_HAS_UNCONSUMED_REQUESTS(_r) \ - ({ \ - unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \ - unsigned int rsp = RING_SIZE(_r) - \ - ((_r)->req_cons - (_r)->rsp_prod_pvt); \ - req < rsp ? req : rsp; \ - }) + (((_r)->sring->req_prod - (_r)->req_cons) < \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \ + ((_r)->sring->req_prod - (_r)->req_cons) : \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)) /* Direct access to individual ring elements, by index. */ #define RING_GET_REQUEST(_r, _idx) \