[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1314097172.8002.30.camel@twins>
Date: Tue, 23 Aug 2011 12:59:32 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jeremy Fitzhardinge <jeremy@...p.org>
Cc: "H. Peter Anvin" <hpa@...or.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>,
the arch/x86 maintainers <x86@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Nick Piggin <npiggin@...nel.dk>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
Subject: Re: [PATCH 07/15] x86: add xadd helper macro
What you could do is something like:
#define CASE_B case 1
#define CASE_W case 2
#define CASE_L case 4
#ifdef CONFIG_64BIT
# define CASE_Q case 8
#else
# define CASE_Q case -1 /* sizeof() won't ever return this */
#endif
> +#define xadd(ptr, inc) \
> + do { \
> + switch (sizeof(*(ptr))) { \
CASE_B: \
> + asm volatile (LOCK_PREFIX "xaddb %b0, %1\n" \
> + : "+r" (inc), "+m" (*(ptr)) \
> + : : "memory", "cc"); \
> + break; \
CASE_W: \
> + asm volatile (LOCK_PREFIX "xaddw %w0, %1\n" \
> + : "+r" (inc), "+m" (*(ptr)) \
> + : : "memory", "cc"); \
> + break; \
CASE_L: \
> + asm volatile (LOCK_PREFIX "xaddl %0, %1\n" \
> + : "+r" (inc), "+m" (*(ptr)) \
> + : : "memory", "cc"); \
> + break; \
CASE_Q: \
> + asm volatile (LOCK_PREFIX "xaddq %q0, %1\n" \
> + : "+r" (inc), "+m" (*(ptr)) \
> + : : "memory", "cc"); \
> + break; \
default: \
__xadd_wrong_size(); \
> + } \
> + } while(0)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists