]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[x86_64] Provide __bswap_{16,32,64}s()
authorMichael Brown <mcb30@ipxe.org>
Sun, 4 Mar 2012 15:28:44 +0000 (15:28 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sun, 4 Mar 2012 15:29:24 +0000 (15:29 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86_64/include/bits/byteswap.h

index 9ed85e8f8af80b5b114c8ac5a151092db07b20e6..113b327874a74e4447b74ca8261eab92a510c869 100644 (file)
@@ -1,22 +1,47 @@
 #ifndef _BITS_BYTESWAP_H
 #define _BITS_BYTESWAP_H
 
+/** @file
+ *
+ * Byte-order swapping functions
+ *
+ */
+
+#include <stdint.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
 static inline __attribute__ (( always_inline, const )) uint16_t
 __bswap_variable_16 ( uint16_t x ) {
        __asm__ ( "xchgb %b0,%h0" : "=Q" ( x ) : "0" ( x ) );
        return x;
 }
 
+static inline __attribute__ (( always_inline )) void
+__bswap_16s ( uint16_t *x ) {
+       __asm__ ( "rorw $8, %0" : "=g" ( *x ) : "0" ( *x ) );
+}
+
 static inline __attribute__ (( always_inline, const )) uint32_t
 __bswap_variable_32 ( uint32_t x ) {
        __asm__ ( "bswapl %k0" : "=r" ( x ) : "0" ( x ) );
        return x;
 }
 
+static inline __attribute__ (( always_inline )) void
+__bswap_32s ( uint32_t *x ) {
+       __asm__ ( "bswapl %k0" : "=r" ( *x ) : "0" ( *x ) );
+}
+
 static inline __attribute__ (( always_inline, const )) uint64_t
 __bswap_variable_64 ( uint64_t x ) {
        __asm__ ( "bswapq %q0" : "=r" ( x ) : "0" ( x ) );
        return x;
 }
 
+static inline __attribute__ (( always_inline )) void
+__bswap_64s ( uint64_t *x ) {
+       __asm__ ( "bswapq %q0" : "=r" ( *x ) : "0" ( *x ) );
+}
+
 #endif /* _BITS_BYTESWAP_H */