forked from zltl/simple_gmsm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendian.h
34 lines (30 loc) · 948 Bytes
/
endian.h
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
#ifndef QLGMSM_SM_ENDIAN_H_
#define QLGMSM_SM_ENDIAN_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* 32-bit integer manipulation macros (big endian)
*/
#ifndef GETU32
#define GETU32(n, b, i) \
{ \
(n) = ((unsigned long)(b)[(i)] << 24) | \
((unsigned long)(b)[(i) + 1] << 16) | \
((unsigned long)(b)[(i) + 2] << 8) | \
((unsigned long)(b)[(i) + 3]); \
}
#endif
#ifndef PUTU32
#define PUTU32(n, b, i) \
{ \
(b)[(i)] = (unsigned char)((n) >> 24); \
(b)[(i) + 1] = (unsigned char)((n) >> 16); \
(b)[(i) + 2] = (unsigned char)((n) >> 8); \
(b)[(i) + 3] = (unsigned char)((n)); \
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* QLGMSM_SM_ENDIAN_H_ */