| 1 |
|
| #include <stdint.h> |
| 2 |
|
| #include "define.h" |
| 3 |
|
| |
| 4 |
103 |
| static inline void bswap8(unsigned char *input) |
| 5 |
|
| { |
| 6 |
103 |
▶ | if (IS_BIG_ENDIAN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (IS_BIG_ENDIAN) |
0 |
103 |
103 |
|
| 7 |
0 |
| return; |
| 8 |
|
| |
| 9 |
|
| unsigned char tmp; |
| 10 |
|
| |
| 11 |
103 |
| tmp = input[0]; |
| 12 |
103 |
| input[0] = input[7]; |
| 13 |
103 |
| input[7] = tmp; |
| 14 |
|
| |
| 15 |
103 |
| tmp = input[1]; |
| 16 |
103 |
| input[1] = input[6]; |
| 17 |
103 |
| input[6] = tmp; |
| 18 |
|
| |
| 19 |
103 |
| tmp = input[2]; |
| 20 |
103 |
| input[2] = input[5]; |
| 21 |
103 |
| input[5] = tmp; |
| 22 |
|
| |
| 23 |
103 |
| tmp = input[3]; |
| 24 |
103 |
| input[3] = input[4]; |
| 25 |
103 |
| input[4] = tmp; |
| 26 |
|
| } |
| 27 |
|
| |
| 28 |
5 |
| static inline void bswap4(unsigned char *input) |
| 29 |
|
| { |
| 30 |
5 |
▶ | if (IS_BIG_ENDIAN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (IS_BIG_ENDIAN) |
0 |
5 |
5 |
|
| 31 |
0 |
| return; |
| 32 |
|
| |
| 33 |
5 |
| uint32_t *the_num= (uint32_t*)input; |
| 34 |
5 |
| *the_num= ntohl(*the_num); |
| 35 |
|
| } |
| 36 |
|
| |
| 37 |
|
| static inline void bswap2(unsigned char *input) |
| 38 |
|
| { |
| 39 |
|
| if (IS_BIG_ENDIAN) |
| 40 |
|
| return; |
| 41 |
|
| |
| 42 |
|
| uint16_t *the_num= (uint16_t*)input; |
| 43 |
|
| *the_num= ntohs(*the_num); |
| 44 |
|
| } |
| 45 |
|
| |