1 /******************************************************************************
2 ###############################################################################
3 # Copyright (c) [2017-2020] [ICT/CAS] #
4 # Licensed under the ORAN Software License v1.0 (License) #
5 ###############################################################################
6 ******************************************************************************/
10 #ifndef _VOS_BYTEORDER_H_
11 #define _VOS_BYTEORDER_H_
15 #endif /* __cplusplus */
18 * 下面两个宏为RPU软件定义另外字节顺序,也是
19 * 两个互斥的宏。各个产品应该根据所采用CPU的类别恰当地设置
20 * default endian is little??
21 * #include <arpa/inet.h> for ntohl, ntohs, htons, htonl
23 #include <arpa/inet.h>
25 #define VOS_LITTLE_ENDIAN (1)
26 #define VOS_BIG_ENDIAN (0)
27 #include <arpa/inet.h>
32 #ifndef VOS_NTOHL /* 4字节 */
34 #define VOS_NTOHL(x) ((((x) & 0xFF000000)>>24) | (((x) & 0x00FF0000)>>8) | \
35 (((x) & 0x0000FF00)<<8 ) | (((x) & 0x000000FF)<<24))
37 #define VOS_NTOHL(x) ntohl(x)
41 #define VOS_NTOHS(x) ntohs(x)
44 #ifndef VOS_HTONL /* 4字节 */
45 #define VOS_HTONL(x) htonl(x)
49 #define VOS_HTONS(x) htons(x)
55 #define VOS_NTOHL(x) (x)
59 #define VOS_NTOHS(x) (x)
63 #define VOS_HTONL(x) (x)
67 #define VOS_HTONS(x) (x)
70 "BYTEORDER not defined"
71 #endif /* VOS_LITTLE_ENDIAN */
76 #define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8))
81 #define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16))
86 #define LOWORD(l) ((WORD)(l))
91 #define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
96 #define LOBYTE(w) ((BYTE)(w))
101 #define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
106 #endif /* __cplusplus */
108 #endif /* _VOS_BYTEORDER_H_ */