1 /******************************************************************************
3 * Copyright (c) 2020 ICT/CAS.
5 * Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * https://www.o-ran.org/software
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
22 #ifndef _VOS_BYTEORDER_H_
23 #define _VOS_BYTEORDER_H_
27 #endif /* __cplusplus */
30 * 下面两个宏为RPU软件定义另外字节顺序,也是
31 * 两个互斥的宏。各个产品应该根据所采用CPU的类别恰当地设置
32 * default endian is little??
33 * #include <arpa/inet.h> for ntohl, ntohs, htons, htonl
35 #include <arpa/inet.h>
37 #define VOS_LITTLE_ENDIAN (1)
38 #define VOS_BIG_ENDIAN (0)
39 #include <arpa/inet.h>
44 #ifndef VOS_NTOHL /* 4字节 */
46 #define VOS_NTOHL(x) ((((x) & 0xFF000000)>>24) | (((x) & 0x00FF0000)>>8) | \
47 (((x) & 0x0000FF00)<<8 ) | (((x) & 0x000000FF)<<24))
49 #define VOS_NTOHL(x) ntohl(x)
53 #define VOS_NTOHS(x) ntohs(x)
56 #ifndef VOS_HTONL /* 4字节 */
57 #define VOS_HTONL(x) htonl(x)
61 #define VOS_HTONS(x) htons(x)
67 #define VOS_NTOHL(x) (x)
71 #define VOS_NTOHS(x) (x)
75 #define VOS_HTONL(x) (x)
79 #define VOS_HTONS(x) (x)
82 "BYTEORDER not defined"
83 #endif /* VOS_LITTLE_ENDIAN */
88 #define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8))
93 #define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16))
98 #define LOWORD(l) ((WORD)(l))
103 #define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
108 #define LOBYTE(w) ((BYTE)(w))
113 #define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
118 #endif /* __cplusplus */
120 #endif /* _VOS_BYTEORDER_H_ */