[libvirt] [PATCH 4/4] cpu: Avoid c99 style of assembler

Michal Privoznik mprivozn at redhat.com
Thu Apr 27 07:02:00 UTC 2017


In c89 - the standard we claim to support - there is no asm()
rather than __asm__(). Switch from the former to the latter.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/cpu/cpu_ppc64.c |  4 ++--
 src/cpu/cpu_x86.c   | 44 ++++++++++++++++++++++----------------------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index f64592b..5d65929 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -732,8 +732,8 @@ virCPUppc64GetHost(virCPUDefPtr cpu,
     data->len = 1;
 
 #if defined(__powerpc__) || defined(__powerpc64__)
-    asm("mfpvr %0"
-        : "=r" (data->pvr[0].value));
+    __asm__("mfpvr %0"
+            : "=r" (data->pvr[0].value));
 #endif
     data->pvr[0].mask = 0xfffffffful;
 
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 53359ff..c971aa3 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2085,32 +2085,32 @@ static inline void
 cpuidCall(virCPUx86CPUID *cpuid)
 {
 # if __x86_64__
-    asm("xor %%ebx, %%ebx;" /* clear the other registers as some cpuid */
-        "xor %%edx, %%edx;" /* functions may use them as additional arguments */
-        "cpuid;"
-        : "=a" (cpuid->eax),
-          "=b" (cpuid->ebx),
-          "=c" (cpuid->ecx),
-          "=d" (cpuid->edx)
-        : "a" (cpuid->eax_in),
-          "c" (cpuid->ecx_in));
+    __asm__("xor %%ebx, %%ebx;" /* clear the other registers as some cpuid */
+            "xor %%edx, %%edx;" /* functions may use them as additional arguments */
+            "cpuid;"
+            : "=a" (cpuid->eax),
+              "=b" (cpuid->ebx),
+              "=c" (cpuid->ecx),
+              "=d" (cpuid->edx)
+            : "a" (cpuid->eax_in),
+              "c" (cpuid->ecx_in));
 # else
     /* we need to avoid direct use of ebx for CPUID output as it is used
      * for global offset table on i386 with -fPIC
      */
-    asm("push %%ebx;"
-        "xor %%ebx, %%ebx;" /* clear the other registers as some cpuid */
-        "xor %%edx, %%edx;" /* functions may use them as additional arguments */
-        "cpuid;"
-        "mov %%ebx, %1;"
-        "pop %%ebx;"
-        : "=a" (cpuid->eax),
-          "=r" (cpuid->ebx),
-          "=c" (cpuid->ecx),
-          "=d" (cpuid->edx)
-        : "a" (cpuid->eax_in),
-          "c" (cpuid->ecx_in)
-        : "cc");
+    __asm__("push %%ebx;"
+            "xor %%ebx, %%ebx;" /* clear the other registers as some cpuid */
+            "xor %%edx, %%edx;" /* functions may use them as additional arguments */
+            "cpuid;"
+            "mov %%ebx, %1;"
+            "pop %%ebx;"
+            : "=a" (cpuid->eax),
+              "=r" (cpuid->ebx),
+              "=c" (cpuid->ecx),
+              "=d" (cpuid->edx)
+            : "a" (cpuid->eax_in),
+              "c" (cpuid->ecx_in)
+            : "cc");
 # endif
 }
 
-- 
2.10.2




More information about the libvir-list mailing list