ROSE  0.11.54.0
ByteOrder.h
1 #ifndef ROSE_ByteOrder_H
2 #define ROSE_ByteOrder_H
3 
4 #include <featureTests.h>
5 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 
7 namespace ByteOrder {
8 
9 // Caution: the symbols LITTLE_ENDIAN and BIG_ENDIAN are already defined on some systems, so we use other names in ROSE.
10 enum Endianness {
12  ORDER_LSB,
13  ORDER_MSB
14 };
15 
17 Endianness host_order();
18 
20 void convert(void *bytes_, size_t nbytes, Endianness from, Endianness to);
21 
24 int8_t swap_bytes(int8_t n);
25 uint8_t swap_bytes(uint8_t n);
26 int16_t swap_bytes(int16_t n);
27 uint16_t swap_bytes(uint16_t n);
28 int32_t swap_bytes(int32_t n);
29 uint32_t swap_bytes(uint32_t n);
30 int64_t swap_bytes(int64_t n);
31 uint64_t swap_bytes(uint64_t n);
36 int8_t le_to_host(int8_t n);
37 uint8_t le_to_host(uint8_t n);
38 int16_t le_to_host(int16_t n);
39 uint16_t le_to_host(uint16_t n);
40 int32_t le_to_host(int32_t n);
41 uint32_t le_to_host(uint32_t n);
42 int64_t le_to_host(int64_t n);
43 uint64_t le_to_host(uint64_t n);
48 void host_to_le(unsigned h, uint8_t *n);
49 void host_to_le(unsigned h, uint16_t *n);
50 void host_to_le(unsigned h, uint32_t *n);
51 void host_to_le(rose_addr_t h, uint64_t *n);
52 void host_to_le(rose_rva_t h, uint32_t *n);
53 void host_to_le(rose_rva_t h, uint64_t *n);
54 void host_to_le(int h, int8_t *n);
55 void host_to_le(int h, int16_t *n);
56 void host_to_le(int h, int32_t *n);
57 void host_to_le(int64_t h, int64_t *n);
62 uint8_t be_to_host(uint8_t n);
63 uint16_t be_to_host(uint16_t n);
64 uint32_t be_to_host(uint32_t n);
65 uint64_t be_to_host(uint64_t n);
66 int8_t be_to_host(int8_t n);
67 int16_t be_to_host(int16_t n);
68 int32_t be_to_host(int32_t n);
69 int64_t be_to_host(int64_t n);
74 void host_to_be(unsigned h, uint8_t *n);
75 void host_to_be(unsigned h, uint16_t *n);
76 void host_to_be(unsigned h, uint32_t *n);
77 void host_to_be(rose_addr_t h, uint64_t *n);
78 void host_to_be(rose_rva_t h, uint32_t *n);
79 void host_to_be(rose_rva_t h, uint64_t *n);
80 void host_to_be(int h, int8_t *n);
81 void host_to_be(int h, int16_t *n);
82 void host_to_be(int h, int32_t *n);
83 void host_to_be(int64_t h, int64_t *n);
88 uint8_t disk_to_host(Endianness sex, uint8_t n);
89 uint16_t disk_to_host(Endianness sex, uint16_t n);
90 uint32_t disk_to_host(Endianness sex, uint32_t n);
91 uint64_t disk_to_host(Endianness sex, uint64_t n);
92 int8_t disk_to_host(Endianness sex, int8_t n);
93 int16_t disk_to_host(Endianness sex, int16_t n);
94 int32_t disk_to_host(Endianness sex, int32_t n);
95 int64_t disk_to_host(Endianness sex, int64_t n);
96 
98 void host_to_disk(Endianness sex, unsigned h, uint8_t *np);
99 void host_to_disk(Endianness sex, unsigned h, uint16_t *np);
100 void host_to_disk(Endianness sex, unsigned h, uint32_t *np);
101 void host_to_disk(Endianness sex, rose_addr_t h, uint64_t *np);
102 void host_to_disk(Endianness sex, rose_rva_t h, uint64_t *np);
103 void host_to_disk(Endianness sex, int h, int8_t *np);
104 void host_to_disk(Endianness sex, int h, int16_t *np);
105 void host_to_disk(Endianness sex, int h, int32_t *np);
106 void host_to_disk(Endianness sex, int64_t h, int64_t *np);
109 } // namespace
110 
111 #endif
112 #endif
UnsignedTarget convert(UnsignedSource x, bool b=false)
Extend or truncate a value.
Definition: Rose/BitOps.h:249
A relative virtual address optionally associated with a SgAsmSection.
Definition: Cxx_Grammar.h:8014
Stack parameter order is unknown or unspecified.