blob: 3c77b460c244d387cdea3ae61706888f29510a76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*************************************************
* Byte Swapping Operations Header File *
* (C) 1999-2008 Jack Lloyd *
*************************************************/
#ifndef BOTAN_BSWAP_H__
#define BOTAN_BSWAP_H__
#include <botan/types.h>
#include <botan/rotate.h>
namespace Botan {
/*************************************************
* Byte Swapping Functions *
*************************************************/
inline u16bit reverse_bytes(u16bit input)
{
return rotate_left(input, 8);
}
inline u32bit reverse_bytes(u32bit input)
{
asm("bswapl %0" : "=r" (input) : "0" (input));
return input;
}
inline u64bit reverse_bytes(u64bit input)
{
asm("bswapq %0" : "=r" (input) : "0" (input));
return input;
}
}
#endif
|