1 /* 2 * PearPC 3 * types.h 4 * 5 * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 * Copyright (C) 1999-2004 Stefan Weyergraf 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 22 #ifndef __TYPES_H__ 23 #define __TYPES_H__ 24 25 #ifdef FSUAE 26 #else 27 #define HAVE_CONFIG_H 28 #endif 29 #ifdef HAVE_CONFIG_H 30 #include "pearpc_config.h" 31 #endif 32 33 #ifdef MIN 34 #undef MIN 35 #endif 36 #ifdef MAX 37 #undef MAX 38 #endif 39 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 40 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 41 42 /* 43 * compiler magic 44 */ 45 46 #ifdef FSUAE 47 #include <stdint.h> 48 typedef uint64_t uint64; 49 typedef int64_t sint64; 50 typedef unsigned int uint32; 51 typedef signed int sint32; 52 typedef unsigned short uint16; 53 typedef signed short sint16; 54 typedef unsigned char uint8; 55 typedef signed char sint8; 56 typedef unsigned char byte; 57 58 typedef unsigned int uint; 59 #endif 60 61 #ifdef __GNUC__ 62 63 // FIXME: configure 64 # ifdef __i386__ 65 # define FASTCALL __attribute__((regparm (3))) 66 # else 67 # define FASTCALL 68 # endif 69 70 # define FUNCTION_CONST __attribute__((const)) 71 # define PACKED __attribute__((packed)) 72 # define UNUSED __attribute__((unused)) 73 # define DEPRECATED __attribute__((deprecated)) 74 #ifndef NORETURN 75 # define NORETURN __attribute__((noreturn)) 76 #endif 77 # define ALIGN_STRUCT(n) __attribute__((aligned(n))) 78 # define FORCE_INLINE __attribute__((always_inline)) 79 80 #elif _MSC_VER 81 82 #define FORCE_INLINE __forceinline 83 #define NOINLINE __declspec(noinline) 84 85 # define FASTCALL 86 # define FUNCTION_CONST 87 # define PACKED __attribute__((packed)) 88 # define UNUSED __attribute__((unused)) 89 # define DEPRECATED 90 # define ALIGN_STRUCT(n) __attribute__((aligned(n))) 91 # define NORETURN __declspec(noreturn) 92 93 typedef unsigned long long uint64; 94 typedef signed long long sint64; 95 typedef unsigned int uint32; 96 typedef signed int sint32; 97 typedef unsigned short uint16; 98 typedef signed short sint16; 99 typedef unsigned char uint8; 100 typedef signed char sint8; 101 typedef unsigned char byte; 102 103 typedef unsigned int uint; 104 105 #ifndef mode_t 106 #define mode_t int 107 #endif 108 109 #endif /* !__GNUC__ */ 110 111 /* 112 * integers 113 */ 114 115 //#include SYSTEM_OSAPI_SPECIFIC_TYPES_HDR 116 117 /* 118 * NULL 119 */ 120 121 #ifndef NULL 122 # define NULL 0 123 #endif 124 125 //FIXME: configure somehow (?) 126 #ifndef UINT128 127 # define UINT128 128 typedef struct uint128 { 129 uint64 l; 130 uint64 h; 131 } uint128; 132 typedef struct sint128 { 133 sint64 l; 134 sint64 h; 135 } sint128; 136 #endif 137 138 union float_uint32 { 139 uint32 u; 140 float f; 141 }; 142 143 union double_uint64 { 144 uint64 u; 145 double d; 146 }; 147 148 #endif 149