xref: /haiku/src/build/libroot/byteorder.cpp (revision bc3955fea5b07e2e94a27fc05e4bb58fe6f0319b)
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 uint16
11 __swap_int16(uint16 value)
12 {
13 	return (value >> 8) | (value << 8);
14 }
15 
16 uint32
17 __swap_int32(uint32 value)
18 {
19 	return (value >> 24) | ((value & 0xff0000) >> 8) | ((value & 0xff00) << 8)
20 		| (value << 24);
21 }
22 
23 uint64
24 __swap_int64(uint64 value)
25 {
26 	return uint64(__swap_int32(uint32(value >> 32)))
27 		| (uint64(__swap_int32(uint32(value))) << 32);
28 }
29