[syslinux:master] com32, bitops: an "m" constraint takes an object, not a pointer to one

syslinux-bot for H. Peter Anvin hpa at zytor.com
Mon Apr 4 10:39:05 PDT 2011


Commit-ID:  47158504d44a151c61461ba1acdef5b4240bdc30
Gitweb:     http://syslinux.zytor.com/commit/47158504d44a151c61461ba1acdef5b4240bdc30
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 4 Apr 2011 10:36:12 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 4 Apr 2011 10:37:24 -0700

com32, bitops: an "m" constraint takes an object, not a pointer to one

The argument to an "m" constraint is an object, not a pointer to an
object.  For a void pointer it needs to be cast to an indirectable
type (like char) and then indirected.

Reported-by: Matt Fleming <matt.fleming at intel.com>
Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/include/sys/bitops.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/com32/include/sys/bitops.h b/com32/include/sys/bitops.h
index bfc09d7..33bb0aa 100644
--- a/com32/include/sys/bitops.h
+++ b/com32/include/sys/bitops.h
@@ -38,12 +38,16 @@
 
 static inline void set_bit(long __bit, void *__bitmap)
 {
-    asm volatile("btsl %1,%0" : "+m" (__bitmap) : "Ir" (__bit) : "memory");
+    asm volatile("btsl %1,%0"
+		 : "+m" (*(unsigned char *)__bitmap)
+		 : "Ir" (__bit) : "memory");
 }
 
 static inline void clr_bit(long __bit, void *__bitmap)
 {
-    asm volatile("btcl %1,%0" : "+m" (__bitmap) : "Ir" (__bit) : "memory");
+    asm volatile("btcl %1,%0"
+		 : "+m" (*(unsigned char *)__bitmap)
+		 : "Ir" (__bit) : "memory");
 }
 
 static inline int __purefunc test_bit(long __bit, const void *__bitmap)
@@ -51,7 +55,7 @@ static inline int __purefunc test_bit(long __bit, const void *__bitmap)
     unsigned char __r;
     asm("btl %2,%1; setc %0"
 	: "=r" (__r)
-	: "m" (__bitmap), "Ir" (__bit));
+	: "m" (*(const unsigned char *)__bitmap), "Ir" (__bit));
     return __r;
 }
 



More information about the Syslinux-commits mailing list