RTXI 1.3
plugins/ni_device/osiTypes.h
Go to the documentation of this file.
00001 /*
00002    osiTypes.h
00003    
00004    Contains the constants and macros needed for ChipObjects 
00005    and the iBus implementation.
00006    
00007    $DateTime: 2006/07/27 23:51:45 $
00008    
00009 */
00010 #ifndef ___osiTypes_h___
00011 #define ___osiTypes_h___
00012 
00013 #define kLittleEndian 1
00014 
00015 // Note: these different typedef's may be different
00016 // depending on you system.  On a 32 bit processor with a 32 bit
00017 // OS, these will probably not need to be modified.
00018 
00019 typedef signed char     i8;
00020 typedef unsigned char   u8;
00021 typedef short            i16;
00022 typedef unsigned short  u16;
00023 typedef signed int      i32;
00024 typedef unsigned int    u32;
00025 typedef float            f32;
00026 typedef double           f64;
00027 typedef char             tText;
00028 typedef char             tChar;
00029 typedef i32               tStatus;
00030 
00031 typedef u32               tBoolean;
00032 
00033 typedef void *           ptr_t;
00034 typedef unsigned long    ptr_uint_t;
00035 
00036 enum { kFalse = 0, kTrue = 1};
00037 
00038 //
00039 // Set to match the target endianness of the target platform
00040 //
00041 
00042 inline u32 SwitchEndianU32(u32 x)
00043 {
00044    volatile u32 rval;
00045    u8  *tmpPtr;
00046 
00047    rval = x;
00048 
00049    tmpPtr = (u8 *)(&rval);
00050    tmpPtr[0] ^= tmpPtr[3];
00051    tmpPtr[3] ^= tmpPtr[0];
00052    tmpPtr[0] ^= tmpPtr[3];
00053 
00054    tmpPtr[1] ^= tmpPtr[2];
00055    tmpPtr[2] ^= tmpPtr[1];
00056    tmpPtr[1] ^= tmpPtr[2];
00057 
00058    return rval;
00059 }
00060 
00061 inline u16 SwitchEndianU16(u16 x)
00062 {
00063    volatile u16 rval;
00064    u8  *tmpPtr;
00065     
00066    rval = x;
00067 
00068    tmpPtr = (u8 *)(&rval);
00069     
00070    tmpPtr[0] ^= tmpPtr[1];
00071    tmpPtr[1] ^= tmpPtr[0];
00072    tmpPtr[0] ^= tmpPtr[1];
00073     
00074    return rval;
00075 }
00076 
00077 /*
00078    kLittleEndian=1 or kBigEndian=1 is defined in the 
00079    OS specific makefile or project
00080 */
00081 
00082 #if kLittleEndian
00083 
00084    #define ReadLittleEndianU32(x) (x)
00085    #define ReadLittleEndianU16(x) (x)
00086 
00087    #define ReadBigEndianU32(x) (SwitchEndianU32(x))
00088    #define ReadBigEndianU16(x) (SwitchEndianU16(x))
00089 
00090 #elif kBigEndian
00091 
00092    #define ReadLittleEndianU32(x) (SwitchEndianU32(x))
00093    #define ReadLittleEndianU16(x) (SwitchEndianU16(x))
00094 
00095    #define ReadBigEndianU32(x) (x)
00096    #define ReadBigEndianU16(x) (x)
00097 
00098 #else 
00099 
00100    /*
00101       In your build project define
00102          kLittleEndian=1
00103       or
00104          kBigEndian=1
00105       to specify your platform's endianness
00106    */
00107    
00108    #error target endianness not specified
00109 #endif
00110 
00111 #define  markAsUnused(type,variable)   {type* _variable = (type*) &variable;}
00112 #define  kStatusOffset                    -50000
00113 #define  kStatusSuccess                   0
00114 #define  kStatusBadWindowType             (-16  + kStatusOffset)
00115 
00116 #ifndef NULL
00117  #define  NULL 0
00118 #endif
00119 
00120 #endif // ___osiTypes_h___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines