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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 31 by william, Tue Sep 7 03:24:11 2010 UTC revision 62 by william, Tue Sep 7 11:08:22 2010 UTC
# Line 16  Line 16 
16  #ifndef __PCSX2TYPES_H__  #ifndef __PCSX2TYPES_H__
17  #define __PCSX2TYPES_H__  #define __PCSX2TYPES_H__
18    
19  /*  // --------------------------------------------------------------------------------------
20   *  Based on PS2E Definitions by  //  Forward declarations
21             linuzappz@hotmail.com,  // --------------------------------------------------------------------------------------
22   *          shadowpcsx2@yahoo.gr,  // Forward declarations for wxWidgets-supporting features.
23   *          and florinsasu@hotmail.com  // If you aren't linking against wxWidgets libraries, then functions that
24   */  // depend on these types will not be usable (they will yield linker errors).
25    
26    #ifdef __cplusplus
27            class wxString;
28            class FastFormatAscii;
29            class FastFormatUnicode;
30    #endif
31    
32    
33  //////////////////////////////////////////////////////////////////////////////////////////  // --------------------------------------------------------------------------------------
34  //                                 Basic Atomic Types  //  Basic Atomic Types
35    // --------------------------------------------------------------------------------------
36    
37  #if defined(_MSC_VER)  #if defined(_MSC_VER)
38    
# Line 102  typedef s32 sptr; Line 109  typedef s32 sptr;
109  #endif  #endif
110  #endif  #endif
111    
112  //////////////////////////////////////////////////////////////////////////////////////////  // --------------------------------------------------------------------------------------
113  // A rough-and-ready cross platform 128-bit datatype, Non-SSE style.  //  u128 / s128 - A rough-and-ready cross platform 128-bit datatype, Non-SSE style.
114  //  // --------------------------------------------------------------------------------------
115  // Note: These structs don't provide any additional constructors because C++ doesn't allow  // Note: These structs don't provide any additional constructors because C++ doesn't allow
116  // the use of datatypes with constructors in unions (and since unions aren't the primary  // the use of datatypes with constructors in unions (and since unions aren't the primary
117  // uses of these types, that means we can't have constructors). Embedded functions for  // uses of these types, that means we can't have constructors). Embedded functions for
118  // performing explicit conversion from 64 and 32 bit values are provided instead.  // performing explicit conversion from 64 and 32 bit values are provided instead.
119  //  //
120  #ifdef __cplusplus  #ifdef __cplusplus
121  struct u128  union u128
122  {  {
123          u64 lo;          struct  
124          u64 hi;          {
125                    u64 lo;
126                    u64 hi;
127            };
128    
129            u64 _u64[2];
130            u32 _u32[4];
131            u16 _u16[8];
132            u8  _u8[16];
133    
134          // Explicit conversion from u64          // Explicit conversion from u64. Zero-extends the source through 128 bits.
135          static u128 From64( u64 src )          static u128 From64( u64 src )
136          {          {
137                  u128 retval = { src, 0 };                  u128 retval;
138                    retval.lo = src;
139                    retval.hi = 0;
140                  return retval;                  return retval;
141          }          }
142    
143          // Explicit conversion from u32          // Explicit conversion from u32. Zero-extends the source through 128 bits.
144          static u128 From32( u32 src )          static u128 From32( u32 src )
145          {          {
146                  u128 retval = { src, 0 };                  u128 retval;
147                    retval._u32[0] = src;
148                    retval._u32[1] = 0;
149                    retval.hi = 0;
150                  return retval;                  return retval;
151          }          }
152    
153            operator u32() const { return _u32[0]; }
154            operator u16() const { return _u16[0]; }
155            operator u8() const { return _u8[0]; }
156            
157            bool operator==( const u128& right ) const
158            {
159                    return (lo == right.lo) && (hi == right.hi);
160            }
161    
162            bool operator!=( const u128& right ) const
163            {
164                    return (lo != right.lo) && (hi != right.hi);
165            }
166    
167            // In order for the following ToString() and WriteTo methods to be available, you must
168            // be linking to both wxWidgets and the pxWidgets extension library.  If you are not
169            // using them, then you will need to provide your own implementations of these methods.
170            wxString ToString() const;
171            wxString ToString64() const;
172            wxString ToString8() const;
173            
174            void WriteTo( FastFormatAscii& dest ) const;
175            void WriteTo8( FastFormatAscii& dest ) const;
176            void WriteTo64( FastFormatAscii& dest ) const;
177  };  };
178    
179  struct s128  struct s128
# Line 149  struct s128 Line 194  struct s128
194                  s128 retval = { src, (src < 0) ? -1 : 0 };                  s128 retval = { src, (src < 0) ? -1 : 0 };
195                  return retval;                  return retval;
196          }          }
197    
198            operator u32() const { return (s32)lo; }
199            operator u16() const { return (s16)lo; }
200            operator u8() const { return (s8)lo; }
201    
202            bool operator==( const s128& right ) const
203            {
204                    return (lo == right.lo) && (hi == right.hi);
205            }
206    
207            bool operator!=( const s128& right ) const
208            {
209                    return (lo != right.lo) && (hi != right.hi);
210            }
211  };  };
212    
213  #else  #else
214    
215  typedef union _u128_t  typedef union _u128_t
216  {  {
217          u64 lo;          struct  
218          u64 hi;          {
219                    u64 lo;
220                    u64 hi;
221            };
222    
223            u64 _u64[2];
224            u32 _u32[4];
225            u16 _u16[8];
226            u8  _u8[16];
227  } u128;  } u128;
228    
229  typedef union _s128_t  typedef union _s128_t
230  {  {
231          s64 lo;          u64 lo;
232          s64 hi;          s64 hi;
233  } s128;  } s128;
234    

Legend:
Removed from v.31  
changed lines
  Added in v.62

  ViewVC Help
Powered by ViewVC 1.1.22