inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/os
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_os
00005 #define inlib_os
00006 
00007 //NOTE : we avoid to have std includes here to be sure
00008 //       that in the below ifdef things come only from the compiler.
00009 
00010 namespace inlib {
00011 
00012 inline const char* os() {
00013 
00014 #if defined(__APPLE__)
00015 
00016 #include <TargetConditionals.h>
00017 #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR || TARGET_OS_EMBEDDED
00018   static const char s[] = "iPhone";
00019 #else
00020   static const char s[] = "Darwin";
00021 #endif
00022 
00023 #elif defined(_WIN32)
00024   static const char s[] = "Windows_NT";
00025 #elif defined(__linux)
00026   static const char s[] = "Linux";
00027 #elif defined(__alpha)
00028   static const char s[] = "OSF1";
00029 #elif defined(__CYGWIN__)
00030   static const char s[] = "CYGWIN";
00031 #else
00032   static const char s[] = "unknown";
00033 #endif
00034   return s;
00035 }
00036 
00037 inline const char* processor() {
00038 
00039 #if defined(__GNUC__)
00040 
00041 #if defined(__ppc__)
00042   static const char s[] = "ppc";
00043 #elif defined(__ppc64__)
00044   static const char s[] = "ppc64";
00045 #elif defined(__i386__)
00046   static const char s[] = "i386";
00047 #elif defined(__x86_64__)
00048   static const char s[] = "x86_64";
00049 #elif defined(__ia64__)
00050   static const char s[] = "ia64";
00051 #else
00052   static const char s[] = "unknown";
00053 #endif
00054 
00055 #elif defined(_MSC_VER)
00056 
00057 #if defined(_M_IX86)
00058   static const char s[] = "ix86";
00059 #elif defined(_M_X64)
00060   static const char s[] = "x64";
00061 #else
00062   static const char s[] = "unknown";
00063 #endif
00064 
00065 #elif defined(__alpha)
00066   static const char s[] = "alpha";
00067 
00068 #else
00069   static const char s[] = "unknown";
00070 #endif
00071   return s;
00072 }
00073 
00074 inline const char* compiler_name() {
00075 
00076 #if defined(__GNUC__)
00077   static const char s[] = "gcc";
00078 #elif defined(_MSC_VER)
00079   static const char s[] = "cl";
00080 #elif defined(__alpha)
00081   static const char s[] = "cxx";
00082 #else
00083   static const char s[] = "unknown";
00084 #endif
00085   return s;
00086 }
00087 
00088 }
00089 
00090 #include "tosu" //does not bring any std include.
00091 
00092 namespace inlib {
00093 
00094 inline char* compiler() {
00095   static char s[64];
00096   char* pos = s;
00097   unsigned int l;
00098   toss(compiler_name(),pos,l);pos += l;
00099 
00100 #if defined(__GNUC__)
00101   *pos++ = '_';
00102   tosu<unsigned int>(__GNUC__,pos,l);pos += l;  
00103   tosu<unsigned int>(__GNUC_MINOR__,pos,l);pos += l;
00104   tosu<unsigned int>(__GNUC_PATCHLEVEL__,pos,l);pos += l;
00105 #elif defined(_MSC_VER)
00106   *pos++ = '_';
00107   tosu<unsigned int>(_MSC_VER,pos,l);pos += l;  
00108   //_mfc_
00109   //tosu<unsigned int>(_MFC_VER,pos,l);pos += l;
00110 #elif defined(__alpha)
00111 #else
00112 #endif
00113   return s;
00114 }
00115 
00116 }
00117 
00118 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines