Etterna
0.74.4
Loading...
Searching...
No Matches
src
archutils
Common
gcc_byte_swaps.h
1
#ifndef GCC_BYTE_SWAPS_H
2
#define GCC_BYTE_SWAPS_H
3
4
#if defined(__i386__)
5
6
#if defined(HAVE_STDINT_H)
7
#include <stdint.h>
8
#endif
9
10
inline
uint32_t
11
ArchSwap32(uint32_t n)
12
{
13
asm
(
"xchg %b0, %h0\n"
14
"rorl $16, %0\n"
15
"xchg %b0, %h0"
16
:
"=q"
(n)
17
:
"0"
(n));
18
return
n;
19
}
20
21
inline
uint32_t
22
ArchSwap24(uint32_t n)
23
{
24
asm
(
"xchg %b0, %h0\n"
25
"rorl $16, %0\n"
26
"xchg %b0, %h0\n"
27
"shrl $8, %0\n"
28
:
"=q"
(n)
29
:
"0"
(n));
30
return
n;
31
}
32
33
inline
uint16_t
34
ArchSwap16(uint16_t n)
35
{
36
asm
(
"xchg %b0, %h0\n"
:
"=q"
(n) :
"0"
(n));
37
return
n;
38
}
39
40
#define HAVE_BYTE_SWAPS
41
#endif
42
43
#endif
Generated by
1.9.8