X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=Include%2Fvos_byteorder.h;fp=Include%2Fvos_byteorder.h;h=0e5aa5cf0e3b8b72d595ea182ec9e34ac9d26177;hb=1f71b9a76eacf92b39c1ce6f782f8404a34f60a9;hp=0000000000000000000000000000000000000000;hpb=254694245736881ecfff4eb0d1503bf3f49a21be;p=scp%2Focu%2F5gnr.git diff --git a/Include/vos_byteorder.h b/Include/vos_byteorder.h new file mode 100644 index 0000000..0e5aa5c --- /dev/null +++ b/Include/vos_byteorder.h @@ -0,0 +1,108 @@ +/****************************************************************************** +############################################################################### +# Copyright (c) [2017-2020] [ICT/CAS] # +# Licensed under the ORAN Software License v1.0 (License) # +############################################################################### +******************************************************************************/ + + + +#ifndef _VOS_BYTEORDER_H_ +#define _VOS_BYTEORDER_H_ + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + +/* + * 下面两个宏为RPU软件定义另外字节顺序,也是 + * 两个互斥的宏。各个产品应该根据所采用CPU的类别恰当地设置 + * default endian is little?? + * #include for ntohl, ntohs, htons, htonl + */ +#include + +#define VOS_LITTLE_ENDIAN (1) +#define VOS_BIG_ENDIAN (0) +#include + + +#if VOS_LITTLE_ENDIAN + +#ifndef VOS_NTOHL /* 4字节 */ +#if 0 +#define VOS_NTOHL(x) ((((x) & 0xFF000000)>>24) | (((x) & 0x00FF0000)>>8) | \ + (((x) & 0x0000FF00)<<8 ) | (((x) & 0x000000FF)<<24)) +#endif +#define VOS_NTOHL(x) ntohl(x) +#endif + +#ifndef VOS_NTOHS +#define VOS_NTOHS(x) ntohs(x) +#endif + +#ifndef VOS_HTONL /* 4字节 */ +#define VOS_HTONL(x) htonl(x) +#endif + +#ifndef VOS_HTONS +#define VOS_HTONS(x) htons(x) +#endif + +#elif VOS_BIG_ENDIAN + +#ifndef VOS_NTOHL +#define VOS_NTOHL(x) (x) +#endif + +#ifndef VOS_NTOHS +#define VOS_NTOHS(x) (x) +#endif + +#ifndef VOS_HTONL +#define VOS_HTONL(x) (x) +#endif + +#ifndef VOS_HTONS +#define VOS_HTONS(x) (x) +#endif +#else +"BYTEORDER not defined" +#endif /* VOS_LITTLE_ENDIAN */ + + +#ifndef HAVE_MAKEWORD +#define HAVE_MAKEWORD +#define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8)) +#endif + +#ifndef HAVE_MAKELONG +#define HAVE_MAKELONG +#define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16)) +#endif + +#ifndef HAVE_LOWORD +#define HAVE_LOWORD +#define LOWORD(l) ((WORD)(l)) +#endif + +#ifndef HAVE_HIWORD +#define HAVE_HIWORD +#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF)) +#endif + +#ifndef HAVE_LOBYTE +#define HAVE_LOBYTE +#define LOBYTE(w) ((BYTE)(w)) +#endif + +#ifndef HAVE_HIBYTE +#define HAVE_HIBYTE +#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF)) +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _VOS_BYTEORDER_H_ */