/*---------------------------------------------------------------------------* Project: compress/uncompress library File: CXUtil.h Programmer: HIRATSU Daisuke Copyright 2005 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef CX_UTIL_H__ #define CX_UTIL_H__ #include #ifdef __cplusplus extern "C" { #endif #define CX_PLATFORM_IS_BIGENDIAN static inline u32 CXiConvertEndian_( u32 x ) { #if defined( CX_PLATFORM_IS_BIGENDIAN ) // Reflect the endianness on a big-endian platform return ((x & 0xFF000000) >> 24) | ((x & 0x00FF0000) >> 8) | ((x & 0x0000FF00) << 8) | ((x & 0x000000FF) << 24); #else return x; #endif } static inline u16 CXiConvertEndian16_( u16 x ) { #if defined( CX_PLATFORM_IS_BIGENDIAN ) // Reflect the endianness on a big-endian platform return (u16)( ((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8) ); #else return x; #endif } #ifdef __cplusplus } /* extern "C" */ #endif #endif // end of CX_UTIL_H__