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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef tools_typedefs
  5 #define tools_typedefs
  6 
  7 // Similar to AIDA/v3r3p0/Types.h
  8 
  9 //NOTE : we avoid to have std includes here to be sure
 10 //       that in the below ifdef things come only from the compiler.
 11 
 12 //NOTE : if adding new platform here, look at ./s2int64 too.
 13 
 14 namespace tools {
 15 
 16 #ifdef _MSC_VER
 17 
 18 typedef int int32;
 19 typedef __int64 int64;
 20 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
 21 inline const char* int64_format() {static const char s_v[] = "%ld";return s_v;}
 22 
 23 typedef unsigned int uint32;
 24 typedef unsigned __int64 uint64;
 25 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
 26 inline const char* uint64_format() {static const char s_v[] = "%lu";return s_v;}
 27 
 28 #ifdef _WIN64
 29 typedef unsigned long long upointer;
 30 inline const char* upointer_format() {static const char s_v[] = "%llu";return s_v;}
 31 inline const char* upointer_format_x() {static const char s_v[] = "0x%llx";return s_v;}
 32 typedef unsigned long long diff_pointer_t;
 33 #else
 34 typedef unsigned long upointer;
 35 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
 36 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
 37 typedef unsigned long diff_pointer_t;
 38 #endif
 39 
 40 #elif defined(__MINGW32__)
 41 
 42 typedef int int32;
 43 typedef long long int64;
 44 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
 45 inline const char* int64_format() {static const char s_v[] = "%ld";return s_v;}
 46 
 47 typedef unsigned int uint32;
 48 typedef unsigned long long uint64;
 49 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
 50 inline const char* uint64_format() {static const char s_v[] = "%lu";return s_v;}
 51 
 52 #ifdef __MINGW64__
 53 typedef unsigned long long upointer;
 54 inline const char* upointer_format() {static const char s_v[] = "%llu";return s_v;}
 55 inline const char* upointer_format_x() {static const char s_v[] = "0x%llx";return s_v;}
 56 typedef unsigned long long diff_pointer_t;
 57 #else
 58 typedef unsigned long upointer;
 59 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
 60 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
 61 typedef unsigned long diff_pointer_t;
 62 #endif
 63 
 64 #elif defined(_LP64)
 65 
 66 // 64 Bit Platforms
 67 typedef int int32;
 68 typedef long int64;
 69 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
 70 inline const char* int64_format() {static const char s_v[] = "%ld";return s_v;}
 71 
 72 typedef unsigned int uint32;
 73 typedef unsigned long uint64;
 74 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
 75 inline const char* uint64_format() {static const char s_v[] = "%lu";return s_v;}
 76 
 77 typedef unsigned long diff_pointer_t;
 78 
 79 typedef unsigned long upointer;
 80 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
 81 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
 82 
 83 #else
 84 
 85 // 32-Bit Platforms
 86 typedef int int32;
 87 typedef long long int64;
 88 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
 89 inline const char* int64_format() {static const char s_v[] = "%lld";return s_v;}
 90 
 91 typedef unsigned int uint32;
 92 typedef unsigned long long uint64;
 93 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
 94 inline const char* uint64_format() {static const char s_v[] = "%llu";return s_v;}
 95 
 96 typedef unsigned long diff_pointer_t;
 97 
 98 typedef unsigned long upointer;
 99 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
100 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
101 
102 #endif
103 
104 inline uint32 uint32_mx() { //4 294 967 295
105   uint32 n = 0;
106   for(unsigned int i=0;i<32;i++)  n += 1<<i;
107   return n;
108 }
109 inline uint64 uint64_mx() { //18 446 744 073 709 551 615
110   uint64 one = 1;
111   uint64 n = 0;
112   for(unsigned int i=0;i<64;i++)  n += one<<i;
113   return n;
114 }
115 
116 typedef unsigned char byte;
117 
118 //for ./io :
119 typedef unsigned char uchar;
120 typedef short int16;
121 typedef unsigned short ushort;
122 typedef unsigned short uint16;
123 typedef uint32 ref;
124 typedef char* cstr_t;
125 typedef const char* const_cstr_t;
126 
127 class fits_bit {public:char m_c;}; //for exlib/cfitsio
128 class csv_time {public:long m_l;}; //for rcsv_ntuple
129 
130 inline unsigned int size_char()   {return 1;}
131 inline unsigned int size_short()  {return 2;}
132 inline unsigned int size_int()    {return 4;}
133 inline unsigned int size_int64()  {return 8;}
134 inline unsigned int size_float()  {return 4;}
135 inline unsigned int size_double() {return 8;}
136 
137 // used in arrout :
138 inline const char* type_format(float)  {static const char s_v[] = "%g";return s_v;}
139 inline const char* type_format(double) {static const char s_v[] = "%g";return s_v;}
140 
141 inline const char* type_format(char)   {static const char s_v[] = "%d";return s_v;}
142 inline const char* type_format(short)  {static const char s_v[] = "%d";return s_v;}
143 inline const char* type_format(int)    {static const char s_v[] = "%d";return s_v;}
144 inline const char* type_format(int64)  {return int64_format();}
145 
146 inline const char* type_format(unsigned char)  {static const char s_v[] = "%u";return s_v;}
147 inline const char* type_format(unsigned short) {static const char s_v[] = "%u";return s_v;}
148 inline const char* type_format(unsigned int)   {static const char s_v[] = "%u";return s_v;}
149 inline const char* type_format(uint64)         {return uint64_format();}
150 
151 typedef unsigned int key_code;
152 
153 }
154 
155 #endif