* commit 'b06e125c01ff30cc3835d6c8c025e256a82356bf': Switch x86 and x86-64 to __builtin_bswap*.
This commit is contained in:
commit
308c4d3fb1
@ -27,33 +27,14 @@
|
|||||||
#ifndef _MACHINE_ENDIAN_H_
|
#ifndef _MACHINE_ENDIAN_H_
|
||||||
#define _MACHINE_ENDIAN_H_
|
#define _MACHINE_ENDIAN_H_
|
||||||
|
|
||||||
#ifdef __GNUC__
|
/* Use GCC builtins */
|
||||||
|
#define __swap16md(x) __builtin_bswap16(x)
|
||||||
#define __swap32md(x) __statement({ \
|
#define __swap32md(x) __builtin_bswap32(x)
|
||||||
uint32_t __swap32md_x = (x); \
|
#define __swap64md(x) __builtin_bswap64(x)
|
||||||
\
|
|
||||||
__asm ("bswap %0" : "+r" (__swap32md_x)); \
|
|
||||||
__swap32md_x; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define __swap64md(x) __statement({ \
|
|
||||||
uint64_t __swap64md_x = (x); \
|
|
||||||
\
|
|
||||||
(uint64_t)__swap32md(__swap64md_x >> 32) | \
|
|
||||||
(uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
|
|
||||||
})
|
|
||||||
#define __swap16md(x) __statement({ \
|
|
||||||
uint16_t __swap16md_x = (x); \
|
|
||||||
\
|
|
||||||
__asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
|
|
||||||
__swap16md_x; \
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Tell sys/endian.h we have MD variants of the swap macros. */
|
/* Tell sys/endian.h we have MD variants of the swap macros. */
|
||||||
#define MD_SWAP
|
#define MD_SWAP
|
||||||
|
|
||||||
#endif /* __GNUC__ */
|
|
||||||
|
|
||||||
#define _BYTE_ORDER _LITTLE_ENDIAN
|
#define _BYTE_ORDER _LITTLE_ENDIAN
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
|
@ -27,34 +27,14 @@
|
|||||||
#ifndef _MACHINE_ENDIAN_H_
|
#ifndef _MACHINE_ENDIAN_H_
|
||||||
#define _MACHINE_ENDIAN_H_
|
#define _MACHINE_ENDIAN_H_
|
||||||
|
|
||||||
#ifdef __GNUC__
|
/* Use GCC builtins */
|
||||||
|
#define __swap16md(x) __builtin_bswap16(x)
|
||||||
#define __swap32md(x) __statement({ \
|
#define __swap32md(x) __builtin_bswap32(x)
|
||||||
u_int32_t __swap32md_x = (x); \
|
#define __swap64md(x) __builtin_bswap64(x)
|
||||||
\
|
|
||||||
__asm ("bswap %0" : "+r" (__swap32md_x)); \
|
|
||||||
__swap32md_x; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define __swap64md(x) __statement({ \
|
|
||||||
u_int64_t __swap64md_x = (x); \
|
|
||||||
\
|
|
||||||
__asm ("bswapq %0" : "+r" (__swap64md_x)); \
|
|
||||||
__swap64md_x; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define __swap16md(x) __statement({ \
|
|
||||||
u_int16_t __swap16md_x = (x); \
|
|
||||||
\
|
|
||||||
__asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
|
|
||||||
__swap16md_x; \
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Tell sys/endian.h we have MD variants of the swap macros. */
|
/* Tell sys/endian.h we have MD variants of the swap macros. */
|
||||||
#define MD_SWAP
|
#define MD_SWAP
|
||||||
|
|
||||||
#endif /* __GNUC__ */
|
|
||||||
|
|
||||||
#define _BYTE_ORDER _LITTLE_ENDIAN
|
#define _BYTE_ORDER _LITTLE_ENDIAN
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user