00001 #if !defined(_MSC_VER) && !defined(_EVC_VER) 00002 #include <stdint.h> 00003 typedef int64_t t_int64; 00004 typedef uint64_t t_uint64; 00005 typedef int32_t t_int32; 00006 typedef uint32_t t_uint32; 00007 typedef int16_t t_int16; 00008 typedef uint16_t t_uint16; 00009 typedef int8_t t_int8; 00010 typedef uint8_t t_uint8; 00011 #else 00012 typedef __int64 t_int64; 00013 typedef unsigned __int64 t_uint64; 00014 typedef __int32 t_int32; 00015 typedef unsigned __int32 t_uint32; 00016 typedef __int16 t_int16; 00017 typedef unsigned __int16 t_uint16; 00018 typedef __int8 t_int8; 00019 typedef unsigned __int8 t_uint8; 00020 #endif 00021 00022 typedef int t_int; 00023 typedef unsigned int t_uint; 00024 00025 typedef float t_float32; 00026 typedef double t_float64; 00027 00028 00029 00030 #if defined(_WIN32) && !defined(_WIN64) 00031 #define __PFC_WP64 __w64 00032 #else 00033 #define __PFC_WP64 00034 #endif 00035 00036 00037 namespace pfc { 00038 template<unsigned t_bytes> 00039 class sized_int_t; 00040 00041 template<> class sized_int_t<1> { 00042 public: 00043 typedef t_uint8 t_unsigned; 00044 typedef t_int8 t_signed; 00045 }; 00046 00047 template<> class sized_int_t<2> { 00048 public: 00049 typedef t_uint16 t_unsigned; 00050 typedef t_int16 t_signed; 00051 }; 00052 00053 template<> class sized_int_t<4> { 00054 public: 00055 typedef t_uint32 t_unsigned; 00056 typedef t_int32 t_signed; 00057 }; 00058 00059 template<> class sized_int_t<8> { 00060 public: 00061 typedef t_uint64 t_unsigned; 00062 typedef t_int64 t_signed; 00063 }; 00064 } 00065 00066 00067 typedef pfc::sized_int_t<sizeof(void*)>::t_unsigned __PFC_WP64 t_size; 00068 typedef pfc::sized_int_t<sizeof(void*)>::t_signed __PFC_WP64 t_ssize; 00069 00070 00071 #define infinite (~0) 00072 00073 const t_uint16 infinite16 = (t_uint16)(~0); 00074 const t_uint32 infinite32 = (t_uint32)(~0); 00075 const t_uint64 infinite64 = (t_uint64)(~0); 00076 const t_size infinite_size = (t_size)(~0); 00077 00078 00079 #if defined(_WIN32) && !defined(_WIN64) 00080 inline t_size MulDiv_Size(t_size x,t_size y,t_size z) {return (t_size) ( ((t_uint64)x * (t_uint64)y) / (t_uint64)z );} 00081 #elif defined(_WIN64) 00082 inline t_size MulDiv_Size(t_size x,t_size y,t_size z) {return (x*y)/z;} 00083 #else 00084 #error portme 00085 #endif 00086 00087 00088 namespace pfc { 00089 template<typename T> class int_specs_t; 00090 00091 template<typename T> 00092 class int_specs_signed_t { 00093 public: 00094 inline static T get_min() {return ((T)1<<(sizeof(T)*8-1));} 00095 inline static T get_max() {return ~((T)1<<(sizeof(T)*8-1));} 00096 enum {is_signed = true}; 00097 }; 00098 00099 template<typename T> 00100 class int_specs_unsigned_t { 00101 public: 00102 inline static T get_min() {return (T)0;} 00103 inline static T get_max() {return (T)~0;} 00104 enum {is_signed = false}; 00105 }; 00106 00107 template<> class int_specs_t<char> : public int_specs_signed_t<char> {}; 00108 template<> class int_specs_t<unsigned char> : public int_specs_unsigned_t<unsigned char> {}; 00109 template<> class int_specs_t<short> : public int_specs_signed_t<short> {}; 00110 template<> class int_specs_t<unsigned short> : public int_specs_unsigned_t<unsigned short> {}; 00111 template<> class int_specs_t<int> : public int_specs_signed_t<int> {}; 00112 template<> class int_specs_t<unsigned int> : public int_specs_unsigned_t<unsigned int> {}; 00113 template<> class int_specs_t<long> : public int_specs_signed_t<long> {}; 00114 template<> class int_specs_t<unsigned long> : public int_specs_unsigned_t<unsigned long> {}; 00115 template<> class int_specs_t<long long> : public int_specs_signed_t<long long> {}; 00116 template<> class int_specs_t<unsigned long long> : public int_specs_unsigned_t<unsigned long long> {}; 00117 00118 template<> class int_specs_t<wchar_t> : public int_specs_unsigned_t<wchar_t> {}; 00119 00120 };
1.5.5