3 uint16_t gffi_get_uint_16_swapped (uint8_t* location, int offset)
6 buf[1] = location[offset];
7 buf[0] = location[offset + 1];
8 return *(uint16_t*)buf;
11 void gffi_set_uint_16_swapped (uint8_t* location, int offset, uint16_t value)
13 uint8_t *buf = (uint8_t*)&value;
15 location[offset + 0] = buf[1];
16 location[offset + 1] = buf[0];
19 uint32_t gffi_get_uint_32_swapped (uint8_t* location, int offset)
22 buf[3] = location[offset];
23 buf[2] = location[offset + 1];
24 buf[1] = location[offset + 2];
25 buf[0] = location[offset + 3];
26 return *(uint32_t*)buf;
29 void gffi_set_uint_32_swapped (uint8_t* location, int offset, uint32_t value)
31 uint8_t *buf = (uint8_t*)&value;
33 location[offset + 0] = buf[3];
34 location[offset + 1] = buf[2];
35 location[offset + 2] = buf[1];
36 location[offset + 3] = buf[0];
39 uint64_t gffi_get_uint_64_swapped (uint8_t* location, int offset)
42 buf[7] = location[offset];
43 buf[6] = location[offset + 1];
44 buf[5] = location[offset + 2];
45 buf[4] = location[offset + 3];
46 buf[3] = location[offset + 4];
47 buf[2] = location[offset + 5];
48 buf[1] = location[offset + 6];
49 buf[0] = location[offset + 7];
50 return *(uint64_t*)buf;
53 void gffi_set_uint_64_swapped (uint8_t* location, int offset, uint64_t value)
55 uint8_t *buf = (uint8_t*)&value;
57 location[offset + 0] = buf[7];
58 location[offset + 1] = buf[6];
59 location[offset + 2] = buf[5];
60 location[offset + 3] = buf[4];
61 location[offset + 4] = buf[3];
62 location[offset + 5] = buf[2];
63 location[offset + 6] = buf[1];
64 location[offset + 7] = buf[0];
67 int16_t gffi_get_int_16_swapped (int8_t* location, int offset)
70 buf[1] = location[offset];
71 buf[0] = location[offset + 1];
72 return *(int16_t*)buf;
75 void gffi_set_int_16_swapped (uint8_t* location, int offset, int16_t value)
77 uint8_t *buf = (uint8_t*)&value;
79 location[offset + 0] = buf[1];
80 location[offset + 1] = buf[0];
83 int32_t gffi_get_int_32_swapped (int8_t* location, int offset)
86 buf[3] = location[offset];
87 buf[2] = location[offset + 1];
88 buf[1] = location[offset + 2];
89 buf[0] = location[offset + 3];
90 return *(int32_t*)buf;
93 void gffi_set_int_32_swapped (uint8_t* location, int offset, int32_t value)
95 uint8_t *buf = (uint8_t*)&value;
97 location[offset + 0] = buf[3];
98 location[offset + 1] = buf[2];
99 location[offset + 2] = buf[1];
100 location[offset + 3] = buf[0];
103 int64_t gffi_get_int_64_swapped (int8_t* location, int offset)
106 buf[7] = location[offset];
107 buf[6] = location[offset + 1];
108 buf[5] = location[offset + 2];
109 buf[4] = location[offset + 3];
110 buf[3] = location[offset + 4];
111 buf[2] = location[offset + 5];
112 buf[1] = location[offset + 6];
113 buf[0] = location[offset + 7];
114 return *(int64_t*)buf;
117 void gffi_set_int_64_swapped (uint8_t* location, int offset, int64_t value)
119 uint8_t *buf = (uint8_t*)&value;
121 location[offset + 0] = buf[7];
122 location[offset + 1] = buf[6];
123 location[offset + 2] = buf[5];
124 location[offset + 3] = buf[4];
125 location[offset + 4] = buf[3];
126 location[offset + 5] = buf[2];
127 location[offset + 6] = buf[1];
128 location[offset + 7] = buf[0];
131 float gffi_get_single_float_swapped (int8_t* location, int offset)
134 buf[3] = location[offset];
135 buf[2] = location[offset + 1];
136 buf[1] = location[offset + 2];
137 buf[0] = location[offset + 3];
141 void gffi_set_single_float_swapped (uint8_t* location, int offset, float value)
143 uint8_t *buf = (uint8_t*)&value;
145 location[offset + 0] = buf[3];
146 location[offset + 1] = buf[2];
147 location[offset + 2] = buf[1];
148 location[offset + 3] = buf[0];
151 double gffi_get_double_float_swapped (int8_t* location, int offset)
154 buf[7] = location[offset];
155 buf[6] = location[offset + 1];
156 buf[5] = location[offset + 2];
157 buf[4] = location[offset + 3];
158 buf[3] = location[offset + 4];
159 buf[2] = location[offset + 5];
160 buf[1] = location[offset + 6];
161 buf[0] = location[offset + 7];
162 return *(double*)buf;
165 void gffi_set_double_float_swapped (uint8_t* location, int offset, double value)
167 uint8_t *buf = (uint8_t*)&value;
169 location[offset + 0] = buf[7];
170 location[offset + 1] = buf[6];
171 location[offset + 2] = buf[5];
172 location[offset + 3] = buf[4];
173 location[offset + 4] = buf[3];
174 location[offset + 5] = buf[2];
175 location[offset + 6] = buf[1];
176 location[offset + 7] = buf[0];