From: Feng Wu <feng.wu@intel.com>
To: xen-devel@lists.xen.org
Cc: Feng Wu <feng.wu@intel.com>,
ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org,
keir.xen@gmail.com, stefano.stabellini@citrix.com,
JBeulich@suse.com, boris.ostrovsky@oracle.com
Subject: [PATCH v3 1/5] Use __stringify() as the only method for performing preprocessor stringificaion
Date: Fri, 30 May 2014 16:56:21 +0800 [thread overview]
Message-ID: <1401440185-11266-2-git-send-email-feng.wu@intel.com> (raw)
In-Reply-To: <1401440185-11266-1-git-send-email-feng.wu@intel.com>
There are two ways of performing preprocessor stringificaion in the
current code: __stringify() from stringify.h, and STR() from config.h.
This patch consolidates down to one.
Signed-off-by: Feng Wu <feng.wu@intel.com>
---
xen/arch/x86/bitops.c | 9 ++--
xen/arch/x86/hvm/svm/svm.c | 2 +-
xen/arch/x86/usercopy.c | 20 +++----
xen/include/asm-arm/current.h | 4 +-
xen/include/asm-x86/multicall.h | 115 ++++++++++++++++++++--------------------
xen/include/asm-x86/system.h | 9 ++--
xen/include/xen/config.h | 3 --
7 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/xen/arch/x86/bitops.c b/xen/arch/x86/bitops.c
index c037567..824a9d6 100644
--- a/xen/arch/x86/bitops.c
+++ b/xen/arch/x86/bitops.c
@@ -1,6 +1,7 @@
#include <xen/bitops.h>
#include <xen/lib.h>
+#include <xen/stringify.h>
unsigned int __find_first_bit(
const unsigned long *addr, unsigned int size)
@@ -11,9 +12,9 @@ unsigned int __find_first_bit(
"1: xor %%eax,%%eax\n\t" /* also ensures ZF==1 if size==0 */
" repe; scas"__OS"\n\t"
" je 2f\n\t"
- " bsf -"STR(BITS_PER_LONG/8)"(%2),%0\n\t"
+ " bsf -"__stringify(BITS_PER_LONG/8)"(%2),%0\n\t"
" jz 1b\n\t"
- " lea -"STR(BITS_PER_LONG/8)"(%2),%2\n\t"
+ " lea -"__stringify(BITS_PER_LONG/8)"(%2),%2\n\t"
"2: sub %%ebx,%%edi\n\t"
" shl $3,%%edi\n\t"
" add %%edi,%%eax"
@@ -60,10 +61,10 @@ unsigned int __find_first_zero_bit(
" xor %%edx,%%edx\n\t" /* also ensures ZF==1 if size==0 */
" repe; scas"__OS"\n\t"
" je 2f\n\t"
- " xor -"STR(BITS_PER_LONG/8)"(%2),%3\n\t"
+ " xor -"__stringify(BITS_PER_LONG/8)"(%2),%3\n\t"
" jz 1b\n\t"
" bsf %3,%0\n\t"
- " lea -"STR(BITS_PER_LONG/8)"(%2),%2\n\t"
+ " lea -"__stringify(BITS_PER_LONG/8)"(%2),%2\n\t"
"2: sub %%ebx,%%edi\n\t"
" shl $3,%%edi\n\t"
" add %%edi,%%edx"
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 870e4ee..16b0d6d 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -72,7 +72,7 @@ u32 svm_feature_flags;
bool_t cpu_has_lmsl;
#define set_segment_register(name, value) \
- asm volatile ( "movw %%ax ,%%" STR(name) "" : : "a" (value) )
+ asm volatile ( "movw %%ax ,%%" __stringify(name) "" : : "a" (value) )
static void svm_update_guest_efer(struct vcpu *);
diff --git a/xen/arch/x86/usercopy.c b/xen/arch/x86/usercopy.c
index 4cc78f5..9af9771 100644
--- a/xen/arch/x86/usercopy.c
+++ b/xen/arch/x86/usercopy.c
@@ -16,16 +16,16 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned n)
stac();
asm volatile (
- " cmp $"STR(2*BYTES_PER_LONG-1)",%0\n"
+ " cmp $"__stringify(2*BYTES_PER_LONG-1)",%0\n"
" jbe 1f\n"
" mov %1,%0\n"
" neg %0\n"
- " and $"STR(BYTES_PER_LONG-1)",%0\n"
+ " and $"__stringify(BYTES_PER_LONG-1)",%0\n"
" sub %0,%3\n"
"4: rep movsb\n" /* make 'to' address aligned */
" mov %3,%0\n"
- " shr $"STR(LONG_BYTEORDER)",%0\n"
- " and $"STR(BYTES_PER_LONG-1)",%3\n"
+ " shr $"__stringify(LONG_BYTEORDER)",%0\n"
+ " and $"__stringify(BYTES_PER_LONG-1)",%3\n"
" .align 2,0x90\n"
"0: rep movs"__OS"\n" /* as many words as possible... */
" mov %3,%0\n"
@@ -34,7 +34,7 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned n)
".section .fixup,\"ax\"\n"
"5: add %3,%0\n"
" jmp 2b\n"
- "3: lea 0(%3,%0,"STR(BYTES_PER_LONG)"),%0\n"
+ "3: lea 0(%3,%0,"__stringify(BYTES_PER_LONG)"),%0\n"
" jmp 2b\n"
".previous\n"
_ASM_EXTABLE(4b, 5b)
@@ -55,16 +55,16 @@ __copy_from_user_ll(void *to, const void __user *from, unsigned n)
stac();
asm volatile (
- " cmp $"STR(2*BYTES_PER_LONG-1)",%0\n"
+ " cmp $"__stringify(2*BYTES_PER_LONG-1)",%0\n"
" jbe 1f\n"
" mov %1,%0\n"
" neg %0\n"
- " and $"STR(BYTES_PER_LONG-1)",%0\n"
+ " and $"__stringify(BYTES_PER_LONG-1)",%0\n"
" sub %0,%3\n"
"4: rep; movsb\n" /* make 'to' address aligned */
" mov %3,%0\n"
- " shr $"STR(LONG_BYTEORDER)",%0\n"
- " and $"STR(BYTES_PER_LONG-1)",%3\n"
+ " shr $"__stringify(LONG_BYTEORDER)",%0\n"
+ " and $"__stringify(BYTES_PER_LONG-1)",%3\n"
" .align 2,0x90\n"
"0: rep; movs"__OS"\n" /* as many words as possible... */
" mov %3,%0\n"
@@ -73,7 +73,7 @@ __copy_from_user_ll(void *to, const void __user *from, unsigned n)
".section .fixup,\"ax\"\n"
"5: add %3,%0\n"
" jmp 6f\n"
- "3: lea 0(%3,%0,"STR(BYTES_PER_LONG)"),%0\n"
+ "3: lea 0(%3,%0,"__stringify(BYTES_PER_LONG)"),%0\n"
"6: push %0\n"
" push %%"__OP"ax\n"
" xor %%eax,%%eax\n"
diff --git a/xen/include/asm-arm/current.h b/xen/include/asm-arm/current.h
index 65c0cdf..f4d5b61 100644
--- a/xen/include/asm-arm/current.h
+++ b/xen/include/asm-arm/current.h
@@ -1,12 +1,12 @@
#ifndef __ARM_CURRENT_H__
#define __ARM_CURRENT_H__
-#include <xen/config.h>
#include <xen/percpu.h>
#include <public/xen.h>
#include <asm/percpu.h>
#include <asm/processor.h>
+#include <xen/stringify.h>
#ifndef __ASSEMBLY__
@@ -34,7 +34,7 @@ static inline struct cpu_info *get_cpu_info(void)
#define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)
#define switch_stack_and_jump(stack, fn) \
- asm volatile ("mov sp,%0; b " STR(fn) : : "r" (stack) : "memory" )
+ asm volatile ("mov sp,%0; b " __stringify(fn) : : "r" (stack) : "memory" )
#define reset_stack_and_jump(fn) switch_stack_and_jump(get_cpu_info(), fn)
diff --git a/xen/include/asm-x86/multicall.h b/xen/include/asm-x86/multicall.h
index a09ac5a..3b414ef 100644
--- a/xen/include/asm-x86/multicall.h
+++ b/xen/include/asm-x86/multicall.h
@@ -6,65 +6,66 @@
#define __ASM_X86_MULTICALL_H__
#include <xen/errno.h>
+#include <xen/stringify.h>
-#define do_multicall_call(_call) \
- do { \
- __asm__ __volatile__ ( \
- " movq %c1(%0),%%rax; " \
- " leaq hypercall_table(%%rip),%%rdi; " \
- " cmpq $("STR(NR_hypercalls)"),%%rax; " \
- " jae 2f; " \
- " movq (%%rdi,%%rax,8),%%rax; " \
- " movq %c2+0*%c3(%0),%%rdi; " \
- " movq %c2+1*%c3(%0),%%rsi; " \
- " movq %c2+2*%c3(%0),%%rdx; " \
- " movq %c2+3*%c3(%0),%%rcx; " \
- " movq %c2+4*%c3(%0),%%r8; " \
- " movq %c2+5*%c3(%0),%%r9; " \
- " callq *%%rax; " \
- "1: movq %%rax,%c4(%0)\n" \
- ".section .fixup,\"ax\"\n" \
- "2: movq $-"STR(ENOSYS)",%%rax\n" \
- " jmp 1b\n" \
- ".previous\n" \
- : \
- : "b" (_call), \
- "i" (offsetof(__typeof__(*_call), op)), \
- "i" (offsetof(__typeof__(*_call), args)), \
- "i" (sizeof(*(_call)->args)), \
- "i" (offsetof(__typeof__(*_call), result)) \
- /* all the caller-saves registers */ \
- : "rax", "rcx", "rdx", "rsi", "rdi", \
- "r8", "r9", "r10", "r11" ); \
+#define do_multicall_call(_call) \
+ do { \
+ __asm__ __volatile__ ( \
+ " movq %c1(%0),%%rax; " \
+ " leaq hypercall_table(%%rip),%%rdi; " \
+ " cmpq $("__stringify(NR_hypercalls)"),%%rax; " \
+ " jae 2f; " \
+ " movq (%%rdi,%%rax,8),%%rax; " \
+ " movq %c2+0*%c3(%0),%%rdi; " \
+ " movq %c2+1*%c3(%0),%%rsi; " \
+ " movq %c2+2*%c3(%0),%%rdx; " \
+ " movq %c2+3*%c3(%0),%%rcx; " \
+ " movq %c2+4*%c3(%0),%%r8; " \
+ " movq %c2+5*%c3(%0),%%r9; " \
+ " callq *%%rax; " \
+ "1: movq %%rax,%c4(%0)\n" \
+ ".section .fixup,\"ax\"\n" \
+ "2: movq $-"__stringify(ENOSYS)",%%rax\n" \
+ " jmp 1b\n" \
+ ".previous\n" \
+ : \
+ : "b" (_call), \
+ "i" (offsetof(__typeof__(*_call), op)), \
+ "i" (offsetof(__typeof__(*_call), args)), \
+ "i" (sizeof(*(_call)->args)), \
+ "i" (offsetof(__typeof__(*_call), result)) \
+ /* all the caller-saves registers */ \
+ : "rax", "rcx", "rdx", "rsi", "rdi", \
+ "r8", "r9", "r10", "r11" ); \
} while ( 0 )
-#define compat_multicall_call(_call) \
- __asm__ __volatile__ ( \
- " movl %c1(%0),%%eax; " \
- " leaq compat_hypercall_table(%%rip),%%rdi; "\
- " cmpl $("STR(NR_hypercalls)"),%%eax; " \
- " jae 2f; " \
- " movq (%%rdi,%%rax,8),%%rax; " \
- " movl %c2+0*%c3(%0),%%edi; " \
- " movl %c2+1*%c3(%0),%%esi; " \
- " movl %c2+2*%c3(%0),%%edx; " \
- " movl %c2+3*%c3(%0),%%ecx; " \
- " movl %c2+4*%c3(%0),%%r8d; " \
- " movl %c2+5*%c3(%0),%%r9d; " \
- " callq *%%rax; " \
- "1: movl %%eax,%c4(%0)\n" \
- ".section .fixup,\"ax\"\n" \
- "2: movl $-"STR(ENOSYS)",%%eax\n" \
- " jmp 1b\n" \
- ".previous\n" \
- : \
- : "b" (_call), \
- "i" (offsetof(__typeof__(*_call), op)), \
- "i" (offsetof(__typeof__(*_call), args)), \
- "i" (sizeof(*(_call)->args)), \
- "i" (offsetof(__typeof__(*_call), result)) \
- /* all the caller-saves registers */ \
- : "rax", "rcx", "rdx", "rsi", "rdi", \
- "r8", "r9", "r10", "r11" ) \
+#define compat_multicall_call(_call) \
+ __asm__ __volatile__ ( \
+ " movl %c1(%0),%%eax; " \
+ " leaq compat_hypercall_table(%%rip),%%rdi; " \
+ " cmpl $("__stringify(NR_hypercalls)"),%%eax; " \
+ " jae 2f; " \
+ " movq (%%rdi,%%rax,8),%%rax; " \
+ " movl %c2+0*%c3(%0),%%edi; " \
+ " movl %c2+1*%c3(%0),%%esi; " \
+ " movl %c2+2*%c3(%0),%%edx; " \
+ " movl %c2+3*%c3(%0),%%ecx; " \
+ " movl %c2+4*%c3(%0),%%r8d; " \
+ " movl %c2+5*%c3(%0),%%r9d; " \
+ " callq *%%rax; " \
+ "1: movl %%eax,%c4(%0)\n" \
+ ".section .fixup,\"ax\"\n" \
+ "2: movl $-"__stringify(ENOSYS)",%%eax\n" \
+ " jmp 1b\n" \
+ ".previous\n" \
+ : \
+ : "b" (_call), \
+ "i" (offsetof(__typeof__(*_call), op)), \
+ "i" (offsetof(__typeof__(*_call), args)), \
+ "i" (sizeof(*(_call)->args)), \
+ "i" (offsetof(__typeof__(*_call), result)) \
+ /* all the caller-saves registers */ \
+ : "rax", "rcx", "rdx", "rsi", "rdi", \
+ "r8", "r9", "r10", "r11" ) \
#endif /* __ASM_X86_MULTICALL_H__ */
diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
index 7111329..b80aca9 100644
--- a/xen/include/asm-x86/system.h
+++ b/xen/include/asm-x86/system.h
@@ -4,11 +4,12 @@
#include <xen/lib.h>
#include <xen/bitops.h>
#include <asm/processor.h>
+#include <xen/stringify.h>
-#define read_segment_register(name) \
-({ u16 __sel; \
- asm volatile ( "movw %%" STR(name) ",%0" : "=r" (__sel) ); \
- __sel; \
+#define read_segment_register(name) \
+({ u16 __sel; \
+ asm volatile ( "movw %%" __stringify(name) ",%0" : "=r" (__sel) ); \
+ __sel; \
})
#define wbinvd() \
diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h
index 7bef8a6..03a11e3 100644
--- a/xen/include/xen/config.h
+++ b/xen/include/xen/config.h
@@ -82,9 +82,6 @@
#endif /* !__ASSEMBLY__ */
-#define __STR(...) #__VA_ARGS__
-#define STR(...) __STR(__VA_ARGS__)
-
#ifndef __ASSEMBLY__
/* Turn a plain number into a C unsigned long constant. */
#define __mk_unsigned_long(x) x ## UL
--
1.8.3.1
next prev parent reply other threads:[~2014-05-30 8:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 8:56 [PATCH v3 0/5] x86: Use alternative mechanism to define CLAC/STAC Feng Wu
2014-05-30 8:56 ` Feng Wu [this message]
2014-05-30 11:35 ` [PATCH v3 1/5] Use __stringify() as the only method for performing preprocessor stringificaion Jan Beulich
2014-06-03 0:42 ` Wu, Feng
2014-06-03 12:37 ` Wu, Feng
2014-06-03 13:05 ` Jan Beulich
2014-06-03 13:13 ` Wu, Feng
2014-05-30 8:56 ` [PATCH v3 2/5] x86: Add definitions for NOP operation Feng Wu
2014-05-30 8:56 ` [PATCH v3 3/5] x86: Make set_nmi_callback return the old nmi callback Feng Wu
2014-05-30 8:56 ` [PATCH v3 4/5] x86: Port the basic alternative mechanism from Linux to Xen Feng Wu
2014-06-03 10:00 ` Jan Beulich
2014-06-03 10:13 ` Wu, Feng
2014-06-03 10:25 ` Jan Beulich
2014-06-03 10:35 ` Wu, Feng
2014-06-03 10:51 ` Jan Beulich
2014-06-03 11:42 ` Wu, Feng
2014-06-03 11:59 ` Jan Beulich
2014-06-03 13:05 ` Wu, Feng
2014-06-03 13:10 ` Jan Beulich
2014-06-03 13:27 ` Wu, Feng
2014-05-30 8:56 ` [PATCH v3 5/5] x86: Use alternative mechanism to define CLAC/STAC Feng Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401440185-11266-2-git-send-email-feng.wu@intel.com \
--to=feng.wu@intel.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=ian.campbell@citrix.com \
--cc=keir.xen@gmail.com \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).