xref: /haiku/src/build/libroot/byteorder.cpp (revision 204ec4dec691a2d637997c13c6d8d9ecc66c97ce)
1 
2 #ifdef BUILDING_FS_SHELL
3 #	include "compat.h"
4 #else
5 #	include <BeOSBuildCompatibility.h>
6 #endif
7 
8 #include <ByteOrder.h>
9 
10 #if __GNUC__ < 4
11 uint16
__swap_int16(uint16 value)12 __swap_int16(uint16 value)
13 {
14 	return (value >> 8) | (value << 8);
15 }
16 
17 uint32
__swap_int32(uint32 value)18 __swap_int32(uint32 value)
19 {
20 	return (value >> 24) | ((value & 0xff0000) >> 8) | ((value & 0xff00) << 8)
21 		| (value << 24);
22 }
23 
24 uint64
__swap_int64(uint64 value)25 __swap_int64(uint64 value)
26 {
27 	return uint64(__swap_int32(uint32(value >> 32)))
28 		| (uint64(__swap_int32(uint32(value))) << 32);
29 }
30 #endif
31