Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/platform 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_platform
0005 #define tools_platform
0006 
0007 // We do not byteswap on intel (LE) (common platform).
0008 // We have then a better compression on these machines.
0009 // NOTE : this is the contrary to what is done in CERN-ROOT (and Rio).
0010 
0011 namespace tools {
0012 
0013 inline bool is_little_endian() {
0014   unsigned int i = 1;
0015   unsigned char* b = (unsigned char*)&i;
0016   // BE = Big Endian, LE = Little Endian.
0017   // The Intels x86 are LE.
0018   // Mac PPC b[3] is 1 (BE)
0019   // Mac Intel b[0] is 1 (LE)
0020   // Linux i386 b[0] is 1 (LE)
0021   // Linux x86_64 b[0] is 1 (LE)
0022   return (b[0]==1?true:false);
0023 }
0024 
0025 }
0026 
0027 #if defined(__APPLE__)
0028 #include <TargetConditionals.h>
0029 #endif
0030 
0031 namespace tools {
0032 namespace device {
0033 
0034 #if TARGET_OS_IPHONE
0035 inline bool is_iOS() {return true;}
0036 #else
0037 inline bool is_iOS() {return false;}
0038 #endif
0039 
0040 #ifdef ANDROID
0041 inline bool is_Android() {return true;}
0042 #else
0043 inline bool is_Android() {return false;}
0044 #endif
0045 
0046 #ifdef EMSCRIPTEN
0047 inline bool is_emscripten() {return true;}
0048 #else
0049 inline bool is_emscripten() {return false;}
0050 #endif
0051 
0052 
0053 #if defined(ANDROID) || TARGET_OS_IPHONE
0054 inline bool small_screen()     {return true;}
0055 //inline bool no_cursor()        {return true;}
0056 inline bool stop_app_button()  {return true;} //the device has a button to stop the app.
0057 #elif defined(EMSCRIPTEN)
0058 inline bool small_screen()     {return false;}
0059 //inline bool no_cursor()        {return false;}
0060 inline bool stop_app_button()  {return true;} //the device has a button to stop the app.
0061 #else
0062 inline bool small_screen()     {return false;}
0063 //inline bool no_cursor()        {return false;}
0064 inline bool stop_app_button()  {return false;}
0065 #endif
0066 #if TARGET_OS_IPHONE
0067 inline bool slow_cpu()         {return true;}
0068 #else
0069 inline bool slow_cpu()         {return false;}
0070 #endif
0071 
0072 inline unsigned int tex_mem_limit() {
0073   // glGet(GL_MAX_TEXTURE_SIZE) :
0074   //   MacBookPro : it returns 8192.
0075   //   SGS : it returns 2048.
0076   //   iPad1 : it returns 2048.
0077   //   iPod : it returns ?
0078   //   Nexus 10 : it returns ?
0079 
0080   // 1024*1024  //*3 =   3 145 728
0081   // 2048*2048  //*3 =  12 582 912
0082   // 4096*4096  //*3 =  50 331 648
0083   // 8192*8192  //*3 = 201 326 592
0084   // 8192*4096  //*3 = 100 663 296
0085   if(small_screen()) {
0086     //iOS : Apple says that max 2D tex size is 1024*1024 with two units
0087     //      texture available. From doc on PowerVR MBX.
0088     return 2048*2048*3;
0089   } else {
0090     //limit = 4096*4096*3; //=8192*2048 //permit to pass ATLAS big image.
0091     //permit to pass fete_science_2010/power2/image_0.jpg
0092     return 8192*4096*3; //100663296
0093   }
0094 }
0095 
0096 }}
0097 
0098 ///////////////////////////////////////////////////////////////////
0099 /// backcomp : for OnX/source/Core/atat.cxx : /////////////////////
0100 ///////////////////////////////////////////////////////////////////
0101 
0102 //NOTE : we avoid to have std includes here to be sure
0103 //       that in the below ifdef things come only from the compiler.
0104 
0105 namespace tools {
0106 
0107 inline const char* os() {
0108 
0109 #if TARGET_OS_IPHONE
0110   static const char s_s[] = "iOS";
0111 #elif defined(ANDROID)
0112   static const char s_s[] = "Android";
0113 #elif defined(EMSCRIPTEN)
0114   static const char s_s[] = "emscripten";
0115 #elif defined(_WIN32)
0116   static const char s_s[] = "Windows_NT";
0117 #elif __APPLE__
0118   static const char s_s[] = "Darwin";
0119 #elif defined(__linux)
0120   static const char s_s[] = "Linux";
0121 #elif defined(__alpha)
0122   static const char s_s[] = "OSF1";
0123 #elif defined(__CYGWIN__)
0124   static const char s_s[] = "CYGWIN";
0125 #else
0126   static const char s_s[] = "unknown";
0127 #endif
0128   return s_s;
0129 }
0130 
0131 inline bool _WIN32_defined() {
0132 #ifdef _WIN32
0133   return true;
0134 #else
0135   return false;
0136 #endif
0137 }
0138 
0139 inline const char* processor() {
0140 
0141 #if defined(__GNUC__)
0142 
0143 #if defined(__ppc__)
0144   static const char s_s[] = "ppc";
0145 #elif defined(__ppc64__)
0146   static const char s_s[] = "ppc64";
0147 #elif defined(__i386__)
0148   static const char s_s[] = "i386";
0149 #elif defined(__x86_64__)
0150   static const char s_s[] = "x86_64";
0151 #elif defined(__ia64__)
0152   static const char s_s[] = "ia64";
0153 #else
0154   static const char s_s[] = "unknown";
0155 #endif
0156 
0157 #elif defined(_MSC_VER)
0158 
0159 #if defined(_M_IX86)
0160   static const char s_s[] = "ix86";
0161 #elif defined(_M_X64)
0162   static const char s_s[] = "x64";
0163 #else
0164   static const char s_s[] = "unknown";
0165 #endif
0166 
0167 #elif defined(__alpha)
0168   static const char s_s[] = "alpha";
0169 
0170 #else
0171   static const char s_s[] = "unknown";
0172 #endif
0173   return s_s;
0174 }
0175 
0176 inline const char* compiler_name() {
0177 
0178 #if defined(__clang__)
0179   static const char s_s[] = "clang";
0180 #elif defined(__GNUC__)
0181   static const char s_s[] = "gcc";
0182 #elif defined(_MSC_VER)
0183   static const char s_s[] = "cl";
0184 #elif defined(__alpha)
0185   static const char s_s[] = "cxx";
0186 #else
0187   static const char s_s[] = "unknown";
0188 #endif
0189   return s_s;
0190 }
0191 
0192 }
0193 
0194 #include "tosu" //does not bring any std include.
0195 
0196 namespace tools {
0197 
0198 inline void compiler(char a_s[128]) {
0199   char* pos = a_s;
0200   unsigned int l;
0201   toss(compiler_name(),pos,l);pos += l;
0202 
0203 #if defined(__clang__)
0204   *pos = '_';pos++;
0205   tosu<unsigned int>(__clang_major__,pos,l);pos += l;
0206   tosu<unsigned int>(__clang_minor__,pos,l);pos += l;
0207   tosu<unsigned int>(__clang_patchlevel__,pos,l);pos += l;
0208 #elif defined(__GNUC__)
0209   *pos = '_';pos++;
0210   tosu<unsigned int>(__GNUC__,pos,l);pos += l;
0211   tosu<unsigned int>(__GNUC_MINOR__,pos,l);pos += l;
0212   tosu<unsigned int>(__GNUC_PATCHLEVEL__,pos,l);pos += l;
0213 #elif defined(_MSC_VER)
0214   *pos = '_';pos++;
0215   tosu<unsigned int>(_MSC_VER,pos,l);pos += l;
0216   //_mfc_
0217   //tosu<unsigned int>(_MFC_VER,pos,l);pos += l;
0218 #elif defined(__alpha)
0219 #else
0220 #endif
0221   *pos = 0;
0222 }
0223 
0224 }
0225 
0226 #endif
0227 
0228 
0229 /* We prefer to handle endianity dynamically, but with cpp macro
0230    it would looks like (from luaconf.h) :
0231 #if defined(__i386__) || defined(__i386) || \
0232     defined(__X86__)  || defined (__x86_64)
0233 #define TOOLS_IS_BE 0
0234 #define TOOLS_IS_LE 1
0235 #elif defined(__POWERPC__) || defined(__ppc__)
0236 #define TOOLS_IS_BE 1
0237 #define TOOLS_IS_LE 0
0238 #endif
0239 */