[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 02/16] x86: fix: make atomic_read() param const
Hi Andrew, On 7/11/2016 6:18 PM, Andrew Cooper wrote: On 09/07/16 05:12, Corneliu ZUZU wrote:This wouldn't let me make a param of a function that used atomic_read() const. Signed-off-by: Corneliu ZUZU <czuzu@xxxxxxxxxxxxxxx>This is a good improvement, but you must make an identical adjustment to the arm code, otherwise you will end up with subtle build failures. Right, didn't even realize it was X86-specific. If you are really feeling up to it, having a common xen/atomic.h with typedef struct { int counter; } atomic_t; #define ATOMIC_INIT(i) { (i) } and some prototypes such as: static inline int atomic_read(const atomic_t *v); would be great, but this looks like it has the possibility to turn into a rats nest. If it does, then just doubling up this code for arm is ok. ~Andrew Yes, that might be more complicated than we expect and I don't know if making code such as this common would be a good idea, usually these functions are always architecture-specific. It might be better to keep them separate - they don't add much anyway since their implementation is short - than risk unexpected different behavior on a future arch. But then again I don't know much details of their implementation, so anyway, I'd surely prefer to do this kind of change in a separate patch. --- xen/include/asm-x86/atomic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-x86/atomic.h b/xen/include/asm-x86/atomic.h index d246b70..0b250c8 100644 --- a/xen/include/asm-x86/atomic.h +++ b/xen/include/asm-x86/atomic.h @@ -94,7 +94,7 @@ typedef struct { int counter; } atomic_t; * * Atomically reads the value of @v. */ -static inline int atomic_read(atomic_t *v) +static inline int atomic_read(const atomic_t *v) { return read_atomic(&v->counter); } @@ -105,7 +105,7 @@ static inline int atomic_read(atomic_t *v) * * Non-atomically reads the value of @v */ -static inline int _atomic_read(atomic_t v) +static inline int _atomic_read(const atomic_t v) { return v.counter; } Thanks, Zuzu C. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |