Warning, /include/Geant4/tools/typedefs is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_typedefs
0005 #define tools_typedefs
0006
0007 // Similar to AIDA/v3r3p0/Types.h
0008
0009 //NOTE : we avoid to have std includes here to be sure
0010 // that in the below ifdef things come only from the compiler.
0011
0012 //NOTE : if adding new platform here, look at ./s2int64 too.
0013
0014 namespace tools {
0015
0016 #ifdef _MSC_VER
0017
0018 typedef int int32;
0019 typedef __int64 int64;
0020 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
0021 inline const char* int64_format() {static const char s_v[] = "%ld";return s_v;}
0022
0023 typedef unsigned int uint32;
0024 typedef unsigned __int64 uint64;
0025 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
0026 inline const char* uint64_format() {static const char s_v[] = "%lu";return s_v;}
0027
0028 #ifdef _WIN64
0029 typedef unsigned long long upointer;
0030 inline const char* upointer_format() {static const char s_v[] = "%llu";return s_v;}
0031 inline const char* upointer_format_x() {static const char s_v[] = "0x%llx";return s_v;}
0032 typedef unsigned long long diff_pointer_t;
0033 #else
0034 typedef unsigned long upointer;
0035 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
0036 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
0037 typedef unsigned long diff_pointer_t;
0038 #endif
0039
0040 #elif defined(__MINGW32__)
0041
0042 typedef int int32;
0043 typedef long long int64;
0044 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
0045 inline const char* int64_format() {static const char s_v[] = "%ld";return s_v;}
0046
0047 typedef unsigned int uint32;
0048 typedef unsigned long long uint64;
0049 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
0050 inline const char* uint64_format() {static const char s_v[] = "%lu";return s_v;}
0051
0052 #ifdef __MINGW64__
0053 typedef unsigned long long upointer;
0054 inline const char* upointer_format() {static const char s_v[] = "%llu";return s_v;}
0055 inline const char* upointer_format_x() {static const char s_v[] = "0x%llx";return s_v;}
0056 typedef unsigned long long diff_pointer_t;
0057 #else
0058 typedef unsigned long upointer;
0059 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
0060 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
0061 typedef unsigned long diff_pointer_t;
0062 #endif
0063
0064 #elif defined(_LP64)
0065
0066 // 64 Bit Platforms
0067 typedef int int32;
0068 typedef long int64;
0069 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
0070 inline const char* int64_format() {static const char s_v[] = "%ld";return s_v;}
0071
0072 typedef unsigned int uint32;
0073 typedef unsigned long uint64;
0074 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
0075 inline const char* uint64_format() {static const char s_v[] = "%lu";return s_v;}
0076
0077 typedef unsigned long diff_pointer_t;
0078
0079 typedef unsigned long upointer;
0080 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
0081 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
0082
0083 #else
0084
0085 // 32-Bit Platforms
0086 typedef int int32;
0087 typedef long long int64;
0088 inline const char* int32_format() {static const char s_v[] = "%d";return s_v;}
0089 inline const char* int64_format() {static const char s_v[] = "%lld";return s_v;}
0090
0091 typedef unsigned int uint32;
0092 typedef unsigned long long uint64;
0093 inline const char* uint32_format() {static const char s_v[] = "%u";return s_v;}
0094 inline const char* uint64_format() {static const char s_v[] = "%llu";return s_v;}
0095
0096 typedef unsigned long diff_pointer_t;
0097
0098 typedef unsigned long upointer;
0099 inline const char* upointer_format() {static const char s_v[] = "%lu";return s_v;}
0100 inline const char* upointer_format_x() {static const char s_v[] = "0x%lx";return s_v;}
0101
0102 #endif
0103
0104 inline uint32 uint32_mx() { //4 294 967 295
0105 uint32 n = 0;
0106 for(unsigned int i=0;i<32;i++) n += 1<<i;
0107 return n;
0108 }
0109 inline uint64 uint64_mx() { //18 446 744 073 709 551 615
0110 uint64 one = 1;
0111 uint64 n = 0;
0112 for(unsigned int i=0;i<64;i++) n += one<<i;
0113 return n;
0114 }
0115
0116 typedef unsigned char byte;
0117
0118 //for ./io :
0119 typedef unsigned char uchar;
0120 typedef short int16;
0121 typedef unsigned short ushort;
0122 typedef unsigned short uint16;
0123 typedef uint32 ref;
0124 typedef char* cstr_t;
0125 typedef const char* const_cstr_t;
0126
0127 class fits_bit {public:char m_c;}; //for exlib/cfitsio
0128 class csv_time {public:long m_l;}; //for rcsv_ntuple
0129
0130 inline unsigned int size_char() {return 1;}
0131 inline unsigned int size_short() {return 2;}
0132 inline unsigned int size_int() {return 4;}
0133 inline unsigned int size_int64() {return 8;}
0134 inline unsigned int size_float() {return 4;}
0135 inline unsigned int size_double() {return 8;}
0136
0137 // used in arrout :
0138 inline const char* type_format(float) {static const char s_v[] = "%g";return s_v;}
0139 inline const char* type_format(double) {static const char s_v[] = "%g";return s_v;}
0140
0141 inline const char* type_format(char) {static const char s_v[] = "%d";return s_v;}
0142 inline const char* type_format(short) {static const char s_v[] = "%d";return s_v;}
0143 inline const char* type_format(int) {static const char s_v[] = "%d";return s_v;}
0144 inline const char* type_format(int64) {return int64_format();}
0145
0146 inline const char* type_format(unsigned char) {static const char s_v[] = "%u";return s_v;}
0147 inline const char* type_format(unsigned short) {static const char s_v[] = "%u";return s_v;}
0148 inline const char* type_format(unsigned int) {static const char s_v[] = "%u";return s_v;}
0149 inline const char* type_format(uint64) {return uint64_format();}
0150
0151 typedef unsigned int key_code;
0152
0153 }
0154
0155 #endif