summaryrefslogtreecommitdiff
path: root/gpxe/src/arch/x86_64/include/bits/byteswap.h
blob: 9ed85e8f8af80b5b114c8ac5a151092db07b20e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef _BITS_BYTESWAP_H
#define _BITS_BYTESWAP_H

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, const )) uint32_t
__bswap_variable_32 ( uint32_t x ) {
	__asm__ ( "bswapl %k0" : "=r" ( x ) : "0" ( x ) );
	return x;
}

static inline __attribute__ (( always_inline, const )) uint64_t
__bswap_variable_64 ( uint64_t x ) {
	__asm__ ( "bswapq %q0" : "=r" ( x ) : "0" ( x ) );
	return x;
}

#endif /* _BITS_BYTESWAP_H */