1
0
mirror of https://github.com/prirun/p50em.git synced 2026-01-13 23:26:13 +00:00

Add an inline swab option to swap.h

This commit is contained in:
Jim 2011-06-19 08:56:11 -04:00
parent e8528a2233
commit 78aaf1753d

10
swap.h
View File

@ -1,5 +1,15 @@
#include <stdint.h>
/*** Another swap option:
#include <stdint.h>
inline uint32_t bswap2(uint32_t val)
{
__asm__("bswap %0" : "+r" (val));
return val;
}
See: http://objectmix.com/asm-x86-asm-370/69484-x86-inline-assembly-bswap.html
***/
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
# error Either __BIG_ENDIAN__ or __LITTLE_ENDIAN__ must be defined.
#endif