direct-io.hg

changeset 11789:317e71a06828

[SOLARIS] Provide non-gcc-specific defn. of RING_HAS_UNCONSUMED_REQUESTS.
From: Mark Johnson <mark.johnson@sun.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Oct 17 19:04:46 2006 +0100 (2006-10-17)
parents cd2a7dd45787
children b99d11877ba1
files xen/include/public/io/ring.h
line diff
     1.1 --- a/xen/include/public/io/ring.h	Tue Oct 17 19:03:47 2006 +0100
     1.2 +++ b/xen/include/public/io/ring.h	Tue Oct 17 19:04:46 2006 +0100
     1.3 @@ -152,7 +152,7 @@ typedef struct __name##_back_ring __name
     1.4      ((_r)->nr_ents)
     1.5  
     1.6  /* Number of free requests (for use on front side only). */
     1.7 -#define RING_FREE_REQUESTS(_r)						\
     1.8 +#define RING_FREE_REQUESTS(_r)                                          \
     1.9      (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
    1.10  
    1.11  /* Test if there is an empty slot available on the front ring.
    1.12 @@ -165,13 +165,21 @@ typedef struct __name##_back_ring __name
    1.13  #define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
    1.14      ((_r)->sring->rsp_prod - (_r)->rsp_cons)
    1.15  
    1.16 +#ifdef __GNUC__
    1.17 +#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({                             \
    1.18 +    unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;          \
    1.19 +    unsigned int rsp = RING_SIZE(_r) -                                  \
    1.20 +        ((_r)->req_cons - (_r)->rsp_prod_pvt);                          \
    1.21 +    req < rsp ? req : rsp;                                              \
    1.22 +})
    1.23 +#else
    1.24 +/* Same as above, but without the nice GCC ({ ... }) syntax. */
    1.25  #define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
    1.26 -    ({									\
    1.27 -	unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;	\
    1.28 -	unsigned int rsp = RING_SIZE(_r) -				\
    1.29 -			   ((_r)->req_cons - (_r)->rsp_prod_pvt);	\
    1.30 -	req < rsp ? req : rsp;						\
    1.31 -    })
    1.32 +    ((((_r)->sring->req_prod - (_r)->req_cons) <                        \
    1.33 +      (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ?        \
    1.34 +     ((_r)->sring->req_prod - (_r)->req_cons) :                         \
    1.35 +     (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
    1.36 +#endif
    1.37  
    1.38  /* Direct access to individual ring elements, by index. */
    1.39  #define RING_GET_REQUEST(_r, _idx)                                      \