Browse Source

[i386] Fix building on older versions of gcc

Fix a strict-aliasing error on certain versions of gcc.

Reported-by: Marko Myllynen <myllynen@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
e187de7239
1 changed files with 7 additions and 3 deletions
  1. 7
    3
      src/arch/i386/include/bits/byteswap.h

+ 7
- 3
src/arch/i386/include/bits/byteswap.h View File

@@ -52,7 +52,10 @@ __bswap_variable_64 ( uint64_t x ) {
52 52
 
53 53
 static inline __attribute__ (( always_inline )) void
54 54
 __bswap_64s ( uint64_t *x ) {
55
-	uint32_t __attribute__ (( may_alias )) *dwords = ( ( void * ) x );
55
+	struct {
56
+		uint32_t low;
57
+		uint32_t high;
58
+	} __attribute__ (( may_alias )) *dwords = ( ( void * ) x );
56 59
 	uint32_t discard;
57 60
 
58 61
 	__asm__ ( "movl %0,%2\n\t"
@@ -60,8 +63,9 @@ __bswap_64s ( uint64_t *x ) {
60 63
 		  "xchgl %2,%1\n\t"
61 64
 		  "bswapl %2\n\t"
62 65
 		  "movl %2,%0\n\t"
63
-		  : "=g" ( dwords[0] ), "=g" ( dwords[1] ), "=r" ( discard )
64
-		  : "0" ( dwords[0] ), "1" ( dwords[1] ) );
66
+		  : "=g" ( dwords->low ), "=g" ( dwords->high ),
67
+		    "=r" ( discard )
68
+		  : "0" ( dwords->low ), "1" ( dwords->high ) );
65 69
 }
66 70
 
67 71
 #endif /* _BITS_BYTESWAP_H */

Loading…
Cancel
Save