2006-11-16 03:02:42 +00:00
|
|
|
#ifndef _INCLUDE_PLATFORM_H_
|
|
|
|
#define _INCLUDE_PLATFORM_H_
|
|
|
|
|
|
|
|
#if (!defined __EXPORT__)
|
|
|
|
#define __EXPORT__
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (defined __WATCOMC__)
|
|
|
|
#define snprintf _snprintf
|
|
|
|
#endif
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static __inline uint16_t _swap16(uint16_t D)
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
|
|
|
#if PLATFORM_MACOSX
|
2009-01-09 09:29:17 +00:00
|
|
|
register uint16_t returnValue;
|
2006-11-16 03:02:42 +00:00
|
|
|
__asm__ volatile("lhbrx %0,0,%1"
|
|
|
|
: "=r" (returnValue)
|
|
|
|
: "r" (&D)
|
|
|
|
);
|
|
|
|
return returnValue;
|
|
|
|
#else
|
|
|
|
return((D<<8)|(D>>8));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static __inline uint32_t _swap32(uint32_t D)
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
|
|
|
#if PLATFORM_MACOSX
|
2009-01-09 09:29:17 +00:00
|
|
|
register uint32_t returnValue;
|
2006-11-16 03:02:42 +00:00
|
|
|
__asm__ volatile("lwbrx %0,0,%1"
|
|
|
|
: "=r" (returnValue)
|
|
|
|
: "r" (&D)
|
|
|
|
);
|
|
|
|
return returnValue;
|
|
|
|
#else
|
|
|
|
return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if PLATFORM_MACOSX
|
|
|
|
#define PLATFORM_BIGENDIAN 1
|
|
|
|
#define BUILDSWAP_INTEL16(x) _swap16(x)
|
|
|
|
#define BUILDSWAP_INTEL32(x) _swap32(x)
|
|
|
|
#else
|
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
#define PLATFORM_LITTLEENDIAN 1
|
|
|
|
#define BUILDSWAP_INTEL16(x) (x)
|
|
|
|
#define BUILDSWAP_INTEL32(x) (x)
|
|
|
|
#else
|
|
|
|
#define PLATFORM_BIGENDIAN 1
|
|
|
|
#define BUILDSWAP_INTEL16(x) _swap16(x)
|
|
|
|
#define BUILDSWAP_INTEL32(x) _swap32(x)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t has_altivec; /* PowerPC-specific. */
|
2006-11-16 03:02:42 +00:00
|
|
|
|
|
|
|
#endif /* !defined _INCLUDE_PLATFORM_H_ */
|
|
|
|
|
|
|
|
/* end of platform.h ... */
|
|
|
|
|