Skip to contentSkip to conversation

virtio tools: use ansi versions of asm and volatile

PATCH In review Ramkumar Ramachandra 2 participants 3 messages Oct 15, 2013 – Oct 17, 2013 virtio core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio tools: use ansi versions of asm and volatile

asm and volatile are provided for backward compatibility; use the ansi versions __asm__ and __volatile__.

Cc Rusty Russell <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 tools/virtio/asm/barrier.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtio/asm/barrier.h +1 -1
index aff61e1..b2fbbfc 100644
@@ -1,5 +1,5 @@
 #if defined(__i386__) || defined(__x86_64__)
-#define barrier() asm volatile("" ::: "memory")
+#define barrier() __asm__ __volatile__("" ::: "memory")
 #define mb() __sync_synchronize()
 
 #define smp_mb()	mb()
Signature · 1 line
1.8.4.477.g5d89aa9
#1 lore raw
Quoted 2 lines · Ramkumar Ramachandra

asm and volatile are provided for backward compatibility; use the ansi versions __asm__ and __volatile__.

Really? I don't see that in the gcc documentation. In fact, I didn't know __volatile__ at all:

If you are writing a header file that should be includable in ISO C programs, write __asm__' instead of asm'. *Note Alternate Keywords::.

We're not...

Cheers,
Rusty.

Quoted 20 lines
Cc Rusty Russell <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 tools/virtio/asm/barrier.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtio/asm/barrier.h +1 -1
index aff61e1..b2fbbfc 100644
@@ -1,5 +1,5 @@
 #if defined(__i386__) || defined(__x86_64__)
-#define barrier() asm volatile("" ::: "memory")
+#define barrier() __asm__ __volatile__("" ::: "memory")
 #define mb() __sync_synchronize()
 
 #define smp_mb()	mb()
Signature · 1 line
1.8.4.477.g5d89aa9
#2 lore raw
Quoted 6 lines · Rusty Russell
Quoted 2 lines · Ramkumar Ramachandra

asm and volatile are provided for backward compatibility; use the ansi versions __asm__ and __volatile__.

Really? I don't see that in the gcc documentation. In fact, I didn't know __volatile__ at all:

Try compiling the program with gcc -ansi, and you'll see that "asm" and "volatile" are undeclared. The motivation for my patch comes from barrier() being declared differently in compiler-gcc.h.

However, the tree is polluted with the non-ansi versions anyway; compilers will continue to support them for decades. So, I'd request you to drop the patch.

Thanks.