1 /*---------------------------------------------------------------------------* 2 Project: Cafe 3 File: types.h 4 5 Copyright (C) Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 *---------------------------------------------------------------------------*/ 14 15 // There are many types.h files; this one comes from src/*/include/types.h 16 17 /* 18 Expected possible predefinitions are 19 __ghs__ - Green Hills 20 __CWCC__ - CodeWarrior (replaces __MWERKS__) 21 __GNUC__ - gcc 22 _WIN32 || _WIN64 - msvc/visual studio 23 */ 24 25 #ifndef __TYPES_H__ 26 #define __TYPES_H__ 27 28 #define _CHECK_TYPES_H_ // temporary; to test that this types.h was included 29 30 // Compiler-specific sections ------------------------------------------------- 31 32 #ifdef __ghs__ // for Green Hills compiler ----------------------------------- 33 #include <ghs_null.h> 34 typedef signed char s8; 35 typedef signed short s16; 36 typedef signed int s32; 37 typedef signed long long s64; 38 typedef unsigned char u8; 39 typedef unsigned short u16; 40 typedef unsigned int u32; 41 typedef unsigned long long u64; 42 43 #define PACKED_STRUCT_BEGIN _Pragma("pack(1)") 44 #define PACKED_STRUCT_END _Pragma("pack()") 45 #define PACKED_STRUCT_ATTRIBUTE 46 47 #define PRAGMA(...) _Pragma(#__VA_ARGS__ ) 48 #define ALIGNVAR(x) PRAGMA( alignvar(x) ) 49 #define ALIGNED_VAR(varType, varAlign, varDef) \ 50 ALIGNVAR(varAlign) \ 51 varType varDef 52 53 // typedef name has already been declared (with same type) 54 #define FORWARD_DECLARE_STRUCT_TYPE(__declname__) \ 55 PRAGMA(ghs nowarning 301) \ 56 typedef struct __declname__ __declname__; \ 57 PRAGMA(ghs endnowarning 301) 58 59 #define CHANGE_SEC(sec, name) PRAGMA( ghs section sec = name ) 60 61 #define SET_STRUCT_ALIGN(x) PRAGMA(ghs struct_min_alignment(x)) 62 #define ATTRIB_STRUCT_ALIGN(x) 63 64 // remove the following definitions after addressing all the compiler warnings 65 #ifdef GHS_DISABLE_NON_CRITICAL_WARNINGS 66 #pragma ghs nowarning 1822 // "multibyte is implementation defined" (yes we know) 67 #pragma ghs nowarning 177 // "static symbol was declared but never referenced" (remove at cleanup) 68 #pragma ghs nowarning 68 // "integer conversion resulted in a change of sign" 69 // (happens with pointer arithmetic using hex constants) 70 //#pragma ghs nowarning 228 // "trailing comma is nonstandard" (in enum defs) 71 //#pragma ghs nowarning 1545 // "address taken of a packed structure member with insufficient alignment" 72 // (Per the GH Multi document, this warning will always 73 // appear if address is taken of a packed member. 74 // Developer should understand what it means to pack a 75 // structure and potential access considerations.) 76 #endif 77 78 #define __cntlzw __CLZ32 79 80 #if !defined(__cplusplus) && !defined(_WCHAR_T) && !defined(_WCHAR_T_DEFINED) 81 #define _WCHAR_T 82 #define _WCHAR_T_DEFINED 83 typedef unsigned short wchar_t; 84 #endif 85 86 #ifndef __CHAR16_DEFINED 87 #define __CHAR16_DEFINED 88 typedef wchar_t char16; 89 #endif 90 91 #else // else from: #ifdef __ghs__ // leaving CW, GCC, WIN32/WIN64 92 #ifdef __CWCC__ // for CodeWarrior compiler ---------------------------------- 93 typedef signed char s8; 94 typedef signed short s16; 95 typedef signed int s32; 96 typedef signed long long s64; 97 typedef unsigned char u8; 98 typedef unsigned short u16; 99 typedef unsigned int u32; 100 typedef unsigned long long u64; 101 102 #define PACKED_STRUCT_BEGIN _Pragma("pack(1)") /* This pragma syntax is C99 compliant */ 103 #define PACKED_STRUCT_END _Pragma("pack()") 104 #define PACKED_STRUCT_ATTRIBUTE /* CW does not use an attribute for packing */ 105 #define ALIGNED_VAR(varType, varAlign, varDef) varType __attribute((aligned (varAlign))) varDef 106 #define CHANGE_SEC(sec, name) 107 #define SET_STRUCT_ALIGN(x) 108 #define ATTRIB_STRUCT_ALIGN(x) __attribute((aligned (x))) 109 110 #pragma warn_unusedvar off // turned off while converting tree to GHS 111 #pragma warn_unusedarg off 112 113 #else // else from: #ifdef __CWCC__ // leaving GCC, WIN32/WIN64 114 #ifdef __GNUC__ // for GCC --------------------------------------------------- 115 typedef unsigned long long u64; 116 typedef signed long long s64; 117 typedef unsigned int u32; 118 typedef signed int s32; 119 typedef unsigned short u16; 120 typedef signed short s16; 121 typedef unsigned char u8; 122 typedef signed char s8; 123 124 #define PACKED_STRUCT_BEGIN /* GNU does not use pragma style packing */ 125 #define PACKED_STRUCT_END /* GNU does not use pragma style packing */ 126 #define PACKED_STRUCT_ATTRIBUTE __attribute__((packed)) 127 #define ALIGNED_VAR(varType, varAlign, varDef) varType __attribute((aligned (varAlign))) varDef 128 129 #define SET_STRUCT_ALIGN(x) 130 #define ATTRIB_STRUCT_ALIGN(x) __attribute((aligned (x))) 131 132 #else // else from: #ifdef __GNUC__ // leaving WIN32/WIN64 133 #if defined _WIN32 || defined _WIN64 // for MSVC ----------------------------- 134 typedef __int8 s8; 135 typedef __int16 s16; 136 typedef __int32 s32; 137 typedef __int64 s64; 138 typedef unsigned __int8 u8; 139 typedef unsigned __int16 u16; 140 typedef unsigned __int32 u32; 141 typedef unsigned __int64 u64; 142 143 #define PACKED_STRUCT_BEGIN /* WIN32 does not use pragma style packing */ 144 #define PACKED_STRUCT_END /* WIN32 does not use pragma style packing */ 145 #define PACKED_STRUCT_ATTRIBUTE /* WIN32 does not use an attribute for packing */ 146 #define ALIGNED_VAR(varType, varAlign, varDef) varType varDef 147 #define CHANGE_SEC(sec, name) 148 #define SET_STRUCT_ALIGN(x) 149 #define ATTRIB_STRUCT_ALIGN(x) 150 151 #else // -------------------------------------------------------------------- 152 #error Unknown build system 153 #endif // #if defined _WIN32 || defined _WIN64 154 #endif // #ifdef __GNUC__ 155 #endif // #ifdef __MWERKS__ 156 #endif // #ifdef __ghs__ 157 158 // Non-compiler-specific section ---------------------------------------------- 159 160 typedef volatile u8 vu8; 161 typedef volatile u16 vu16; 162 typedef volatile u32 vu32; 163 typedef volatile u64 vu64; 164 typedef volatile s8 vs8; 165 typedef volatile s16 vs16; 166 typedef volatile s32 vs32; 167 typedef volatile s64 vs64; 168 169 typedef float f32; 170 typedef double f64; 171 typedef volatile f32 vf32; 172 typedef volatile f64 vf64; 173 174 #ifndef BOOL 175 typedef int BOOL; 176 #endif // BOOL 177 178 #ifndef TRUE 179 #define TRUE 1 // Any nonzero value is considered TRUE 180 #endif // TRUE 181 182 #ifndef FALSE 183 #define FALSE 0 184 #endif // FALSE 185 186 #ifndef NULL 187 #ifdef __cplusplus 188 #define NULL 0 189 #else // __cplusplus 190 #define NULL ((void *)0) 191 #endif // __cplusplus 192 #endif // NULL 193 194 // SN-Phil: AT ADDRESS MACRO 195 // Use the following pragma wherever a fixed address is required for 196 // static variables. 197 #define AT_ADDRESS(xyz) : (xyz) 198 199 #include <ppc_upid.h> 200 201 #endif // __TYPES_H__ 202