1 /*---------------------------------------------------------------------------* 2 Project: compress/uncompress library 3 File: CXUtil.h 4 Programmer: HIRATSU Daisuke 5 6 Copyright 2005 Nintendo. All rights reserved. 7 8 These coded instructions, statements, and computer programs contain 9 proprietary information of Nintendo of America Inc. and/or Nintendo 10 Company Ltd., and are protected by Federal copyright law. They may 11 not be disclosed to third parties or copied or duplicated in any form, 12 in whole or in part, without the prior written consent of Nintendo. 13 *---------------------------------------------------------------------------*/ 14 15 #ifndef CX_UTIL_H__ 16 #define CX_UTIL_H__ 17 18 #include <dolphin/types.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #define CX_PLATFORM_IS_BIGENDIAN 25 26 CXiConvertEndian_(u32 x)27static inline u32 CXiConvertEndian_( u32 x ) 28 { 29 #if defined( CX_PLATFORM_IS_BIGENDIAN ) 30 // Reflect the endianness on a big-endian platform 31 return ((x & 0xFF000000) >> 24) | 32 ((x & 0x00FF0000) >> 8) | 33 ((x & 0x0000FF00) << 8) | 34 ((x & 0x000000FF) << 24); 35 #else 36 return x; 37 #endif 38 } 39 40 CXiConvertEndian16_(u16 x)41static inline u16 CXiConvertEndian16_( u16 x ) 42 { 43 #if defined( CX_PLATFORM_IS_BIGENDIAN ) 44 // Reflect the endianness on a big-endian platform 45 return (u16)( ((x & 0xFF00) >> 8) | 46 ((x & 0x00FF) << 8) ); 47 #else 48 return x; 49 #endif 50 } 51 52 53 #ifdef __cplusplus 54 } /* extern "C" */ 55 #endif 56 57 #endif // end of CX_UTIL_H__ 58