/[pcsx2_0.9.7]/trunk/common/include/Pcsx2Types.h
ViewVC logotype

Contents of /trunk/common/include/Pcsx2Types.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download)
Mon Sep 6 11:40:06 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 3981 byte(s)
exported r3113 from ./upstream/trunk
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #ifndef __PCSX2TYPES_H__
17 #define __PCSX2TYPES_H__
18
19 /*
20 * Based on PS2E Definitions by
21 linuzappz@hotmail.com,
22 * shadowpcsx2@yahoo.gr,
23 * and florinsasu@hotmail.com
24 */
25
26
27 //////////////////////////////////////////////////////////////////////////////////////////
28 // Basic Atomic Types
29
30 #if defined(_MSC_VER)
31
32 typedef __int8 s8;
33 typedef __int16 s16;
34 typedef __int32 s32;
35 typedef __int64 s64;
36
37 typedef unsigned __int8 u8;
38 typedef unsigned __int16 u16;
39 typedef unsigned __int32 u32;
40 typedef unsigned __int64 u64;
41
42 typedef unsigned int uint;
43
44 #else // _MSC_VER*/
45
46 #ifdef __LINUX__
47
48 #ifdef HAVE_STDINT_H
49 #include "stdint.h"
50
51 // note: char and int8_t are not interchangable types on gcc, because int8_t apparently
52 // maps to 'signed char' which (due to 1's compliment or something) is its own unique
53 // type. This creates cross-compiler inconsistencies, in addition to being entirely
54 // unexpected behavior to any sane programmer, so we typecast s8 to char instead. :)
55
56 //typedef int8_t s8;
57 typedef char s8;
58 typedef int16_t s16;
59 typedef int32_t s32;
60 typedef int64_t s64;
61
62 typedef uint8_t u8;
63 typedef uint16_t u16;
64 typedef uint32_t u32;
65 typedef uint64_t u64;
66
67 typedef uintptr_t uptr;
68 typedef intptr_t sptr;
69
70 #else // HAVE_STDINT_H
71
72 typedef char s8;
73 typedef short s16;
74 typedef int s32;
75 typedef long long s64;
76
77 typedef unsigned char u8;
78 typedef unsigned short u16;
79 typedef unsigned int u32;
80 typedef unsigned long long u64;
81
82 #endif // HAVE_STDINT_H
83
84 typedef unsigned int uint;
85
86 #define LONG long
87 typedef union _LARGE_INTEGER
88 {
89 long long QuadPart;
90 } LARGE_INTEGER;
91
92 #endif // __LINUX__
93 #endif //_MSC_VER
94
95 #if !defined(__LINUX__) || !defined(HAVE_STDINT_H)
96 #if defined(__x86_64__)
97 typedef u64 uptr;
98 typedef s64 sptr;
99 #else
100 typedef u32 uptr;
101 typedef s32 sptr;
102 #endif
103 #endif
104
105 //////////////////////////////////////////////////////////////////////////////////////////
106 // A rough-and-ready cross platform 128-bit datatype, Non-SSE style.
107 //
108 // Note: These structs don't provide any additional constructors because C++ doesn't allow
109 // the use of datatypes with constructors in unions (and since unions aren't the primary
110 // uses of these types, that means we can't have constructors). Embedded functions for
111 // performing explicit conversion from 64 and 32 bit values are provided instead.
112 //
113 #ifdef __cplusplus
114 struct u128
115 {
116 u64 lo;
117 u64 hi;
118
119 // Explicit conversion from u64
120 static u128 From64( u64 src )
121 {
122 u128 retval = { src, 0 };
123 return retval;
124 }
125
126 // Explicit conversion from u32
127 static u128 From32( u32 src )
128 {
129 u128 retval = { src, 0 };
130 return retval;
131 }
132 };
133
134 struct s128
135 {
136 s64 lo;
137 s64 hi;
138
139 // explicit conversion from s64, with sign extension.
140 static s128 From64( s64 src )
141 {
142 s128 retval = { src, (src < 0) ? -1 : 0 };
143 return retval;
144 }
145
146 // explicit conversion from s32, with sign extension.
147 static s128 From64( s32 src )
148 {
149 s128 retval = { src, (src < 0) ? -1 : 0 };
150 return retval;
151 }
152 };
153
154 #else
155
156 typedef union _u128_t
157 {
158 u64 lo;
159 u64 hi;
160 } u128;
161
162 typedef union _s128_t
163 {
164 s64 lo;
165 s64 hi;
166 } s128;
167
168 #endif
169
170 #endif

  ViewVC Help
Powered by ViewVC 1.1.22