bcmendian.h
资源名称:bcm4702.rar [点击查看]
上传用户:yuanda199
上传日期:2022-06-26
资源大小:412k
文件大小:2k
源码类别:
VxWorks
开发平台:
C/C++
- /*
- Copyright 2001, Broadcom Corporation
- All Rights Reserved.
- This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
- the contents of this file may not be disclosed to third parties, copied or
- duplicated in any form, in whole or in part, without the prior written
- permission of Broadcom Corporation.
- */
- /*******************************************************************************
- * $Id: bcmendian.h,v 1.1 Broadcom SDK $
- * local version of endian.h - byte order defines
- ******************************************************************************/
- #ifndef _BCMENDIAN_H_
- #define _BCMENDIAN_H_
- #include <hnbutypedefs.h>
- /* Byte swap a 16 bit value */
- #define BCMSWAP16(val)
- ((uint16)(
- (((uint16)(val) & (uint16)0x00ffU) << 8) |
- (((uint16)(val) & (uint16)0xff00U) >> 8) ))
- /* Byte swap a 32 bit value */
- #define BCMSWAP32(val)
- ((uint32)(
- (((uint32)(val) & (uint32)0x000000ffUL) << 24) |
- (((uint32)(val) & (uint32)0x0000ff00UL) << 8) |
- (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) |
- (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
- static INLINE uint16
- bcmswap16(uint16 val)
- {
- return BCMSWAP16(val);
- }
- static INLINE uint32
- bcmswap32(uint32 val)
- {
- return BCMSWAP32(val);
- }
- /* buf - start of buffer of shorts to swap */
- /* len - byte length of buffer */
- static INLINE void
- bcmswap16_buf(uint16 *buf, uint len)
- {
- len = len/2;
- while(len--){
- *buf = bcmswap16(*buf);
- buf++;
- }
- }
- #ifndef hton16
- #ifndef IL_BIGENDIAN
- #define HTON16(i) BCMSWAP16(i)
- #define hton16(i) bcmswap16(i)
- #define hton32(i) bcmswap32(i)
- #define ntoh16(i) bcmswap16(i)
- #define ntoh32(i) bcmswap32(i)
- #define ltoh16(i) (i)
- #define ltoh32(i) (i)
- #define htol16(i) (i)
- #define htol32(i) (i)
- #else
- #define HTON16(i) (i)
- #define hton16(i) (i)
- #define hton32(i) (i)
- #define ntoh16(i) (i)
- #define ntoh32(i) (i)
- #define ltoh16(i) bcmswap16(i)
- #define ltoh32(i) bcmswap32(i)
- #define htol16(i) bcmswap16(i)
- #define htol32(i) bcmswap32(i)
- #endif
- #endif
- #ifndef IL_BIGENDIAN
- #define ltoh16_buf(buf, i)
- #define htol16_buf(buf, i)
- #else
- #define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
- #define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
- #endif
- #endif /* _BCMENDIAN_H_ */