Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:51

0001 /*   $Source: bitbucket.org:berkeleylab/gasnet.git/other/portable_platform.h $
0002  * Description: Portable platform detection header
0003  * Copyright 2006, Dan Bonachea 
0004  * Copyright 2018, The Regents of the University of California
0005  * Terms of Use: In ADDITION to the license information in license.txt, 
0006  *  anyone redistributing this header agrees not to change any part of this notice, or
0007  *  the version handshake in the header versioning section below. 
0008  *  Furthermore, redistributed copies of any portion of this header must
0009  *  not appear within files named "portable_platform.h" or "gasnet_portable_platform.h",
0010  *  unless it is embedded within a complete copy of the GASNet distribution.
0011  *  These restrictions are designed to prevent conflicts for end users 
0012  *  who compose multiple projects using the PLATFORM_ namespace.
0013  *
0014  * The canonical version of this header is hosted in the GASNet project at:
0015  *   https://bitbucket.org/berkeleylab/gasnet   
0016  *
0017  * Developers who clone this header into their own project are HIGHLY encouraged to  
0018  * contribute any improvements (especially addition of new platforms) back to the 
0019  * canonical version, for the benefit of the community. 
0020  * Contributions and bug reports should be directed to:
0021  *   https://gasnet-bugs.lbl.gov or gasnet-staff@lbl.gov
0022  */
0023 /* ------------------------------------------------------------------------------------ */
0024 /* Header versioning: DO NOT CHANGE ANYTHING IN THIS SECTION 
0025  * The license terms for this header prohibit modifying this section in ANY way.
0026    Clones should continue to advertise a PLATFORM_HEADER_VERSION equal to the canonical version they cloned,
0027    and should not modify the handshake logic which ensures the highest canonical header version is used.
0028  */
0029 /* Publish and enforce version number for the public interface to this header */
0030 /* YOU ARE NOT PERMITTED TO CHANGE THIS SECTION WITHOUT DIRECT APPROVAL FROM DAN BONACHEA */
0031 #if _PORTABLE_PLATFORM_H != PLATFORM_HEADER_VERSION \
0032      || PLATFORM_HEADER_VERSION < 16
0033 #undef  PLATFORM_HEADER_VERSION 
0034 #define PLATFORM_HEADER_VERSION 16
0035 #undef  _PORTABLE_PLATFORM_H
0036 #define _PORTABLE_PLATFORM_H PLATFORM_HEADER_VERSION
0037 /* End Header versioning handshake */
0038 /* ------------------------------------------------------------------------------------ */
0039 
0040 /* make sure that previously-included older/broken clones of this header do not pollute our namespace */
0041 #undef PLATFORM_COMPILER_FAMILYNAME
0042 #undef PLATFORM_COMPILER_FAMILYID
0043 #undef PLATFORM_COMPILER_ID
0044 #undef PLATFORM_COMPILER_VERSION
0045 #undef PLATFORM_COMPILER_VERSION_STR
0046 #undef PLATFORM_COMPILER_VERSION_INT
0047 #undef PLATFORM_COMPILER_IDSTR
0048 #undef PLATFORM_COMPILER_VERSION_GT
0049 #undef PLATFORM_COMPILER_VERSION_GE
0050 #undef PLATFORM_COMPILER_VERSION_EQ
0051 #undef PLATFORM_COMPILER_VERSION_LE
0052 #undef PLATFORM_COMPILER_VERSION_LT
0053 #undef PLATFORM_COMPILER_C_LANGLVL
0054 #undef PLATFORM_COMPILER_CXX_LANGLVL
0055 #undef PLATFORM_COMPILER_INTEL
0056 #undef PLATFORM_COMPILER_INTEL_C
0057 #undef PLATFORM_COMPILER_INTEL_CXX
0058 #undef PLATFORM_COMPILER_PATHSCALE
0059 #undef PLATFORM_COMPILER_PATHSCALE_C
0060 #undef PLATFORM_COMPILER_PATHSCALE_CXX
0061 #undef PLATFORM_COMPILER_PGI
0062 #undef PLATFORM_COMPILER_PGI_C
0063 #undef PLATFORM_COMPILER_PGI_CXX
0064 #undef PLATFORM_COMPILER_XLC
0065 #undef PLATFORM_COMPILER_XLC_C
0066 #undef PLATFORM_COMPILER_XLC_CXX
0067 #undef PLATFORM_COMPILER_COMPAQ
0068 #undef PLATFORM_COMPILER_COMPAQ_C
0069 #undef PLATFORM_COMPILER_COMPAQ_CXX
0070 #undef PLATFORM_COMPILER_SUN
0071 #undef PLATFORM_COMPILER_SUN_C
0072 #undef PLATFORM_COMPILER_SUN_CXX
0073 #undef PLATFORM_COMPILER_HP
0074 #undef PLATFORM_COMPILER_HP_C
0075 #undef PLATFORM_COMPILER_HP_CXX
0076 #undef PLATFORM_COMPILER_SGI
0077 #undef PLATFORM_COMPILER_SGI_C
0078 #undef PLATFORM_COMPILER_SGI_CXX
0079 #undef PLATFORM_COMPILER_CRAY
0080 #undef PLATFORM_COMPILER_CRAY_C
0081 #undef PLATFORM_COMPILER_CRAY_CXX
0082 #undef PLATFORM_COMPILER_KAI
0083 #undef PLATFORM_COMPILER_KAI_C
0084 #undef PLATFORM_COMPILER_KAI_CXX
0085 #undef PLATFORM_COMPILER_MTA
0086 #undef PLATFORM_COMPILER_MTA_C
0087 #undef PLATFORM_COMPILER_MTA_CXX
0088 #undef PLATFORM_COMPILER_NECSX
0089 #undef PLATFORM_COMPILER_NECSX_C
0090 #undef PLATFORM_COMPILER_NECSX_CXX
0091 #undef PLATFORM_COMPILER_MICROSOFT
0092 #undef PLATFORM_COMPILER_MICROSOFT_C
0093 #undef PLATFORM_COMPILER_MICROSOFT_CXX
0094 #undef PLATFORM_COMPILER_TINY
0095 #undef PLATFORM_COMPILER_TINY_C
0096 #undef PLATFORM_COMPILER_TINY_CXX
0097 #undef PLATFORM_COMPILER_LCC
0098 #undef PLATFORM_COMPILER_LCC_C
0099 #undef PLATFORM_COMPILER_LCC_CXX
0100 #undef PLATFORM_COMPILER_OPEN64
0101 #undef PLATFORM_COMPILER_OPEN64_C
0102 #undef PLATFORM_COMPILER_OPEN64_CXX
0103 #undef PLATFORM_COMPILER_PCC
0104 #undef PLATFORM_COMPILER_PCC_C
0105 #undef PLATFORM_COMPILER_PCC_CXX
0106 #undef PLATFORM_COMPILER_CLANG
0107 #undef PLATFORM_COMPILER_CLANG_C
0108 #undef PLATFORM_COMPILER_CLANG_CXX
0109 #undef PLATFORM_COMPILER_NVHPC
0110 #undef PLATFORM_COMPILER_NVHPC_C
0111 #undef PLATFORM_COMPILER_NVHPC_CXX
0112 #undef PLATFORM_COMPILER_GNU
0113 #undef PLATFORM_COMPILER_GNU_C
0114 #undef PLATFORM_COMPILER_GNU_CXX
0115 #undef PLATFORM_COMPILER_UNKNOWN
0116 
0117 #undef PLATFORM_OS_FAMILYNAME
0118 #undef PLATFORM_OS_CATAMOUNT
0119 #undef PLATFORM_OS_CNL
0120 #undef PLATFORM_OS_BGP
0121 #undef PLATFORM_OS_BGQ
0122 #undef PLATFORM_OS_WSL
0123 #undef PLATFORM_OS_K42
0124 #undef PLATFORM_OS_UCLINUX
0125 #undef PLATFORM_OS_LINUX
0126 #undef PLATFORM_OS_BLRTS
0127 #undef PLATFORM_OS_CYGWIN
0128 #undef PLATFORM_OS_MSWINDOWS
0129 #undef PLATFORM_OS_AIX
0130 #undef PLATFORM_OS_TRU64
0131 #undef PLATFORM_OS_FREEBSD
0132 #undef PLATFORM_OS_NETBSD
0133 #undef PLATFORM_OS_OPENBSD
0134 #undef PLATFORM_OS_SOLARIS
0135 #undef PLATFORM_OS_DARWIN
0136 #undef PLATFORM_OS_IRIX
0137 #undef PLATFORM_OS_HPUX
0138 #undef PLATFORM_OS_UNICOS
0139 #undef PLATFORM_OS_MTA
0140 #undef PLATFORM_OS_SUPERUX
0141 #undef PLATFORM_OS_UNKNOWN
0142 
0143 #undef PLATFORM_ARCH_FAMILYNAME
0144 #undef PLATFORM_ARCH_32
0145 #undef _PLATFORM_ARCH_32
0146 #undef PLATFORM_ARCH_64
0147 #undef _PLATFORM_ARCH_64
0148 #undef PLATFORM_ARCH_BIG_ENDIAN
0149 #undef _PLATFORM_ARCH_BIG_ENDIAN
0150 #undef PLATFORM_ARCH_LITTLE_ENDIAN
0151 #undef _PLATFORM_ARCH_LITTLE_ENDIAN
0152 #undef PLATFORM_ARCH_POWERPC
0153 #undef PLATFORM_ARCH_MIC
0154 #undef PLATFORM_ARCH_X86_64
0155 #undef PLATFORM_ARCH_IA64
0156 #undef PLATFORM_ARCH_X86
0157 #undef PLATFORM_ARCH_ALPHA
0158 #undef PLATFORM_ARCH_MIPS
0159 #undef PLATFORM_ARCH_SPARC
0160 #undef PLATFORM_ARCH_PARISC
0161 #undef PLATFORM_ARCH_CRAYX1
0162 #undef PLATFORM_ARCH_CRAYT3E
0163 #undef PLATFORM_ARCH_MTA
0164 #undef PLATFORM_ARCH_NECSX
0165 #undef PLATFORM_ARCH_MICROBLAZE
0166 #undef PLATFORM_ARCH_ARM
0167 #undef PLATFORM_ARCH_AARCH64
0168 #undef PLATFORM_ARCH_TILE
0169 #undef PLATFORM_ARCH_S390
0170 #undef PLATFORM_ARCH_UNKNOWN
0171 
0172 /* prevent known old/broken versions of this header from loading */
0173 #undef  OMPI_PORTABLE_PLATFORM_H
0174 #define OMPI_PORTABLE_PLATFORM_H
0175 #undef  OPAL_PORTABLE_PLATFORM_H
0176 #define OPAL_PORTABLE_PLATFORM_H
0177 
0178 /* ------------------------------------------------------------------------------------ */
0179 /* most of this file was written based on information in vendor documents, system headers,
0180    and inspecting verbose compiler output. 
0181    Another useful source of information: http://predef.sourceforge.net/
0182 */
0183 
0184 /* ------------------------------------------------------------------------------------ */
0185 /* helpers */
0186 
0187 #undef  _PLATFORM_STRINGIFY_HELPER
0188 #define _PLATFORM_STRINGIFY_HELPER(x) #x
0189 #undef  PLATFORM_STRINGIFY
0190 #define PLATFORM_STRINGIFY(x) _PLATFORM_STRINGIFY_HELPER(x)
0191 
0192 /* ------------------------------------------------------------------------------------ */
0193 /* Compiler detection */
0194 /* 
0195   PLATFORM_COMPILER_<family>:
0196      defined to 1 if compiler is a given family, undef otherwise
0197   PLATFORM_COMPILER_<family>_C
0198   PLATFORM_COMPILER_<family>_CXX
0199      defined to 1 if compiler is a given family, and is the C or C++ compiler, respectively
0200   PLATFORM_COMPILER_FAMILYNAME:
0201      unquoted token which provides the compiler family name
0202   PLATFORM_COMPILER_FAMILYID:
0203      defined to a positive integral value which is unique to a given compiler family
0204      or zero if the compiler is unrecognized
0205   PLATFORM_COMPILER_ID:
0206      same as PLATFORM_COMPILER_FAMILYID, except C and C++ compilers are differentiated
0207   PLATFORM_COMPILER_VERSION:
0208      defined to an integral expression which is guaranteed to be monotonically non-decreasing 
0209      with increasing compiler versions. Will be zero for unrecognized compilers.
0210      The exact encoding of compiler version tuples into this constant may occasionally
0211      change when this header is upgraded, so code should use the (in)equality macros below
0212      to check against particular compiler versions, instead of embedding an encoded constant.
0213   PLATFORM_COMPILER_VERSION_STR:
0214      A string representation of the compiler version, which may contain additional info
0215   PLATFORM_COMPILER_VERSION_[GT,GE,EQ,LE,LT](maj,min,pat):
0216      evaluate to non-zero iff the compiler version in use is respectively 
0217      greater-than, greater-or-equal, equal, less-or-equal, less-than 
0218      the provided version components
0219   PLATFORM_COMPILER_IDSTR:
0220      a string which uniquely identifies recognized compilers
0221   PLATFORM_COMPILER_C_LANGLVL and PLATFORM_COMPILER_CXX_LANGLVL: (in PLATFORM_HEADER_VERSION >= 5)
0222      defined to a positive integral value corresponding to the C or C++ (respectively) 
0223      language standard to which the current compiler advertises conformance.
0224      Otherwise undef (in particular at most one of these is defined in a given compilation).
0225 */
0226 
0227 #if defined(__INTEL_COMPILER)
0228   #define PLATFORM_COMPILER_INTEL  1
0229   #define PLATFORM_COMPILER_FAMILYNAME INTEL
0230   #define PLATFORM_COMPILER_FAMILYID 2
0231   #ifdef __cplusplus
0232     #define PLATFORM_COMPILER_INTEL_CXX  1
0233   #else
0234     #define PLATFORM_COMPILER_INTEL_C  1
0235   #endif
0236   /* Intel compiler version "patch number"
0237    * -------------------------------------
0238    * Intel compiler versioning is unfortunately complicated by behavioral changes.
0239    * Versions prior to Intel 14.0.0 (Sept 2013) lacked a preprocessor symbol to supply the "update" number.
0240    * Version 14.0.0 and later supply a __INTEL_COMPILER_UPDATE symbol, but sadly several releases of Version 19 
0241    * report the wrong value in this field (bug 3876).
0242    * For now, the "patch" field of the PLATFORM_COMPILER_VERSION for Intel is the release package BUILD DATE,
0243    * in the same decimal YYYYMMDD format as __INTEL_COMPILER_BUILD_DATE, as this is the only indicator that has
0244    * remained reliably stable/correct across versions. 
0245    * So for example to check for icc --version "19.0.1.144 20181018" or later, pass:
0246    *   PLATFORM_COMPILER_VERSION_GE(19, 0, 20181018)
0247    * NOTE 1: this build-date is unfortunately OS-DEPENDENT, sometimes differing by several days or weeks 
0248    * between the Linux and OSX releases. For a complete mapping, see:
0249    * https://software.intel.com/en-us/articles/intel-compiler-and-composer-update-version-numbers-to-compiler-version-number-mapping
0250    * NOTE 2: some of the build-date entries in the table linked above have been observed to be incorrect,
0251    * so when possible it's safest to verify the build-date from `icc --version` on both Linux and macOS.
0252    */
0253   #undef  _PLATFORM_INTEL_COMPILER_BUILD_DATE
0254   #undef  _PLATFORM_COMPILER_INTEL_MIN_BUILDDATE
0255   #define _PLATFORM_COMPILER_INTEL_MIN_BUILDDATE 19900000 /* year 1990: corresponds roughly to Intel v4.5 (1992) */
0256   /* MIN_BUILDDATE is used to normalize build dates to a bit-saving range for the encoding
0257    * Intel officially supports the current release and two prior (currently back to 2016)
0258    * Our 1990 floor corresponds to Intel v4.x that only worked on MS-DOS and predates both Linux and BSD-based macOS
0259    */
0260   #ifdef __INTEL_COMPILER_BUILD_DATE
0261     #define _PLATFORM_INTEL_COMPILER_BUILD_DATE __INTEL_COMPILER_BUILD_DATE
0262   #else
0263     #define _PLATFORM_INTEL_COMPILER_BUILD_DATE _PLATFORM_COMPILER_INTEL_MIN_BUILDDATE
0264   #endif
0265   /* Intel patch number is a decimal build date: YYYYMMDD - do NOT pass the "update number" */
0266   #define PLATFORM_COMPILER_VERSION_INT(maj,min,pat)         \
0267         (((((maj) * 100) + (min)) << 19) |                    \
0268            ((pat) < _PLATFORM_COMPILER_INTEL_MIN_BUILDDATE ? \
0269              0 : ((pat)-_PLATFORM_COMPILER_INTEL_MIN_BUILDDATE)))
0270   #undef _PLATFORM__INTEL_COMPILER
0271   #if __INTEL_COMPILER == 9999  /* Seen in 20110811 release of 12.1.0 - overflows VERSION_INT() */
0272     #define _PLATFORM__INTEL_COMPILER 1201
0273   #else
0274     #define _PLATFORM__INTEL_COMPILER __INTEL_COMPILER
0275   #endif
0276   #define PLATFORM_COMPILER_VERSION \
0277           PLATFORM_COMPILER_VERSION_INT(_PLATFORM__INTEL_COMPILER/100, _PLATFORM__INTEL_COMPILER%100, _PLATFORM_INTEL_COMPILER_BUILD_DATE)
0278   #define PLATFORM_COMPILER_VERSION_STR \
0279           PLATFORM_STRINGIFY(_PLATFORM__INTEL_COMPILER) "." PLATFORM_STRINGIFY(_PLATFORM_INTEL_COMPILER_BUILD_DATE)
0280 
0281 #elif defined(__PATHSCALE__)
0282   #define PLATFORM_COMPILER_PATHSCALE  1
0283   #define PLATFORM_COMPILER_FAMILYNAME PATHSCALE
0284   #define PLATFORM_COMPILER_FAMILYID 3
0285   #ifdef __cplusplus
0286     #define PLATFORM_COMPILER_PATHSCALE_CXX  1
0287   #else
0288     #define PLATFORM_COMPILER_PATHSCALE_C  1
0289   #endif
0290   #define PLATFORM_COMPILER_VERSION \
0291           PLATFORM_COMPILER_VERSION_INT(__PATHCC__,__PATHCC_MINOR__,__PATHCC_PATCHLEVEL__+0)
0292   #define PLATFORM_COMPILER_VERSION_STR __PATHSCALE__
0293 
0294 #elif defined(__NVCOMPILER) // Must occur prior to PGI and CLANG
0295   #define PLATFORM_COMPILER_NVHPC  1
0296   #define PLATFORM_COMPILER_FAMILYNAME NVHPC
0297   #define PLATFORM_COMPILER_FAMILYID 20
0298   #ifdef __cplusplus
0299     #define PLATFORM_COMPILER_NVHPC_CXX  1
0300   #else
0301     #define PLATFORM_COMPILER_NVHPC_C  1
0302   #endif
0303   #define PLATFORM_COMPILER_VERSION \
0304           PLATFORM_COMPILER_VERSION_INT(__NVCOMPILER_MAJOR__,__NVCOMPILER_MINOR__,__NVCOMPILER_PATCHLEVEL__)
0305   #define PLATFORM_COMPILER_VERSION_STR \
0306       PLATFORM_STRINGIFY(__NVCOMPILER_MAJOR__) "." PLATFORM_STRINGIFY(__NVCOMPILER_MINOR__) "-" PLATFORM_STRINGIFY(__NVCOMPILER_PATCHLEVEL__)
0307 
0308 #elif defined(__PGI)
0309   #define PLATFORM_COMPILER_PGI  1
0310   #define PLATFORM_COMPILER_FAMILYNAME PGI
0311   #define PLATFORM_COMPILER_FAMILYID 4
0312   #ifdef __cplusplus
0313     #define PLATFORM_COMPILER_PGI_CXX  1
0314   #else
0315     #define PLATFORM_COMPILER_PGI_C  1
0316   #endif
0317   #if __PGIC__ == 99 
0318     /* bug 2230: PGI versioning was broken for some platforms in 7.0
0319                  no way to know exact version, but provide something slightly more accurate */
0320     #define PLATFORM_COMPILER_VERSION 0x070000
0321     #define PLATFORM_COMPILER_VERSION_STR "7.?-?"
0322   #elif defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
0323     #define PLATFORM_COMPILER_VERSION \
0324             PLATFORM_COMPILER_VERSION_INT(__PGIC__,__PGIC_MINOR__,__PGIC_PATCHLEVEL__)
0325     #define PLATFORM_COMPILER_VERSION_STR \
0326             PLATFORM_STRINGIFY(__PGIC__) "." PLATFORM_STRINGIFY(__PGIC_MINOR__) "-" PLATFORM_STRINGIFY(__PGIC_PATCHLEVEL__)
0327   #else
0328     /* PGI before 6.1-4 lacks any version ID preprocessor macros - so use this filthy hack */
0329     #ifdef PLATFORM_PGI_IS_ANCIENT
0330       /* Include below might fail for ancient versions lacking this header, but testing shows it
0331          works back to at least 5.1-3 (Nov 2003), and based on docs probably back to 3.2 (Sep 2000) */
0332         #define PLATFORM_COMPILER_VERSION 0       
0333     #elif defined(__x86_64__) /* bug 1753 - 64-bit omp.h upgrade happened in <6.0-8,6.1-1] */
0334       #include "omp.h"
0335       #if defined(_PGOMP_H)
0336         /* 6.1.1 or newer */
0337         #define PLATFORM_COMPILER_VERSION 0x060101
0338         #define PLATFORM_COMPILER_VERSION_STR ">=6.1-1"
0339       #else
0340         /* 6.0.8 or older */
0341         #define PLATFORM_COMPILER_VERSION 0
0342         #define PLATFORM_COMPILER_VERSION_STR "<=6.0-8"
0343       #endif
0344     #else /* 32-bit omp.h upgrade happened in <5.2-4,6.0-8] */
0345       #include "omp.h"
0346       #if defined(_PGOMP_H)
0347         /* 6.0-8 or newer */
0348         #define PLATFORM_COMPILER_VERSION 0x060008
0349         #define PLATFORM_COMPILER_VERSION_STR ">=6.0-8"
0350       #else
0351         /* 5.2-4 or older */
0352         #define PLATFORM_COMPILER_VERSION 0
0353         #define PLATFORM_COMPILER_VERSION_STR "<=5.2-4"
0354       #endif
0355     #endif
0356   #endif
0357 
0358 #elif defined(__xlC__) || defined(__ibmxl__)
0359   #define PLATFORM_COMPILER_XLC  1
0360   #define PLATFORM_COMPILER_FAMILYNAME XLC
0361   #define PLATFORM_COMPILER_FAMILYID 5
0362   #ifdef __cplusplus
0363     #define PLATFORM_COMPILER_XLC_CXX  1
0364   #else
0365     #define PLATFORM_COMPILER_XLC_C  1
0366   #endif
0367   #ifdef __ibmxl_version__
0368     #define PLATFORM_COMPILER_VERSION \
0369       (__ibmxl_version__ << 24 | __ibmxl_release__ << 16 | \
0370        __ibmxl_modification__ << 8 | __ibmxl_ptf_fix_level__)
0371     #define PLATFORM_COMPILER_VERSION_STR \
0372       PLATFORM_STRINGIFY(__ibmxl_version__) "." PLATFORM_STRINGIFY(__ibmxl_release__) "." PLATFORM_STRINGIFY(__ibmxl_modification__) "." PLATFORM_STRINGIFY(__ibmxl_ptf_fix_level__)
0373   #else
0374     #ifdef __xlC_ver__
0375       #define PLATFORM_COMPILER_VERSION (__xlC__ << 16 | __xlC_ver__)
0376     #else
0377       #define PLATFORM_COMPILER_VERSION (__xlC__ << 16)
0378     #endif
0379     #ifdef __xlc__
0380       #define PLATFORM_COMPILER_VERSION_STR __xlc__
0381     #else
0382       #define PLATFORM_COMPILER_VERSION_STR PLATFORM_STRINGIFY(__xlC__)
0383     #endif
0384   #endif
0385   #define PLATFORM_COMPILER_VERSION_INT(maj,min,pat) \
0386         ( ((maj) << 24) | ((min) << 16) | ((pat) << 8) )
0387 
0388 #elif defined(__DECC) || defined(__DECCXX)
0389   #define PLATFORM_COMPILER_COMPAQ  1
0390   #define PLATFORM_COMPILER_FAMILYNAME COMPAQ
0391   #define PLATFORM_COMPILER_FAMILYID 6
0392   #ifdef __cplusplus
0393     #define PLATFORM_COMPILER_COMPAQ_CXX  1
0394   #else
0395     #define PLATFORM_COMPILER_COMPAQ_C  1
0396   #endif
0397   #if defined(__DECC_VER)
0398     #define PLATFORM_COMPILER_VERSION __DECC_VER
0399   #elif defined(__DECCXX_VER)
0400     #define PLATFORM_COMPILER_VERSION __DECCXX_VER
0401   #endif
0402 
0403   #define PLATFORM_COMPILER_VERSION_INT(maj,min,pat) \
0404         ( ((maj) * 10000000) + ((min) * 100000) + (90000) + (pat) )
0405   /* 90000 = official ver, 80000 = customer special ver, 60000 = field test ver */
0406 
0407 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
0408   #define PLATFORM_COMPILER_SUN  1
0409   #define PLATFORM_COMPILER_FAMILYNAME SUN
0410   #define PLATFORM_COMPILER_FAMILYID 7
0411   #ifdef __cplusplus
0412     #define PLATFORM_COMPILER_SUN_CXX  1
0413   #else
0414     #define PLATFORM_COMPILER_SUN_C  1
0415   #endif
0416   #if defined(__SUNPRO_C) && __SUNPRO_C > 0
0417     #define PLATFORM_COMPILER_VERSION __SUNPRO_C
0418   #elif defined(__SUNPRO_CC) && __SUNPRO_CC > 0
0419     #define PLATFORM_COMPILER_VERSION __SUNPRO_CC
0420   #endif
0421   /* Sun version numbers look like hex but are actually a sloppy concatenation of decimal version numbers
0422    * leading to weird discontinuities in the version space, luckily it remains monotonic (so far)
0423    */
0424   #define PLATFORM_COMPILER_VERSION_INT(maj,min,pat) ( \
0425         (min) < 10 ?                                   \
0426         ( ((maj) << 8) | ((min) << 4) | (pat) ) :      \
0427         ( ((maj) << 12) | (((min)/10) << 8) | (((min)%10) << 4) | (pat) )  )
0428 
0429 #elif defined(__HP_cc) || defined(__HP_aCC)
0430   #define PLATFORM_COMPILER_HP  1
0431   #define PLATFORM_COMPILER_FAMILYNAME HP
0432   #define PLATFORM_COMPILER_FAMILYID 8
0433   #ifdef __cplusplus
0434     #define PLATFORM_COMPILER_HP_CXX  1
0435   #else
0436     #define PLATFORM_COMPILER_HP_C  1
0437   #endif
0438   #if defined(__HP_cc) && __HP_cc > 0
0439     #define PLATFORM_COMPILER_VERSION __HP_cc
0440   #elif defined(__HP_aCC) && __HP_aCC > 0
0441     #define PLATFORM_COMPILER_VERSION __HP_aCC
0442   #endif
0443   #define PLATFORM_COMPILER_VERSION_INT(maj,min,pat) \
0444         ( ((maj) << 16) | ((min) << 8) | (pat) )
0445 
0446 #elif defined(_SGI_COMPILER_VERSION) || \
0447    (defined(_COMPILER_VERSION) && defined(__sgi) && !defined(__GNUC__)) /* 7.3.0 and earlier lack _SGI_COMPILER_VERSION */
0448   #define PLATFORM_COMPILER_SGI  1
0449   #define PLATFORM_COMPILER_FAMILYNAME SGI
0450   #define PLATFORM_COMPILER_FAMILYID 9
0451   #ifdef __cplusplus
0452     #define PLATFORM_COMPILER_SGI_CXX  1
0453   #else
0454     #define PLATFORM_COMPILER_SGI_C  1
0455   #endif
0456   #if defined(_SGI_COMPILER_VERSION) && _SGI_COMPILER_VERSION > 0
0457     #define PLATFORM_COMPILER_VERSION _SGI_COMPILER_VERSION
0458   #elif defined(_COMPILER_VERSION) && _COMPILER_VERSION > 0
0459     #define PLATFORM_COMPILER_VERSION _COMPILER_VERSION
0460   #endif
0461   #define PLATFORM_COMPILER_VERSION_INT(maj,min,pat) \
0462         ( ((maj) << 8) | ((min) << 4) | (pat) )
0463 
0464 #elif defined(_CRAYC) 
0465   #define PLATFORM_COMPILER_CRAY  1
0466   #define PLATFORM_COMPILER_FAMILYNAME CRAY
0467   #define PLATFORM_COMPILER_FAMILYID 10
0468   #ifdef __cplusplus
0469     #define PLATFORM_COMPILER_CRAY_CXX  1
0470   #else
0471     #define PLATFORM_COMPILER_CRAY_C  1
0472   #endif
0473   #if defined(_RELEASE_MAJOR) && defined(_RELEASE_MINOR) /* XE, XK, XC */
0474     #define PLATFORM_COMPILER_VERSION \
0475             PLATFORM_COMPILER_VERSION_INT(_RELEASE_MAJOR,_RELEASE_MINOR,0)
0476   #elif defined(_RELEASE) && defined(_RELEASE_MINOR) /* X1 and XT */
0477     #define PLATFORM_COMPILER_VERSION \
0478             PLATFORM_COMPILER_VERSION_INT(_RELEASE,_RELEASE_MINOR,0)
0479   #elif defined(_RELEASE) /* T3E */
0480     #define PLATFORM_COMPILER_VERSION \
0481             PLATFORM_COMPILER_VERSION_INT(_RELEASE,0,0)
0482   #endif
0483   #ifdef _RELEASE_STRING /* X1 and XT, XK, XC */
0484     #define PLATFORM_COMPILER_VERSION_STR _RELEASE_STRING
0485   #endif
0486 
0487 #elif defined(__KCC)
0488   #define PLATFORM_COMPILER_KAI  1
0489   #define PLATFORM_COMPILER_FAMILYNAME KAI
0490   #define PLATFORM_COMPILER_FAMILYID 11
0491   #ifdef __cplusplus
0492     #define PLATFORM_COMPILER_KAI_CXX  1
0493   #else
0494     #define PLATFORM_COMPILER_KAI_C  1
0495   #endif
0496 
0497 #elif defined(__MTA__)
0498   #define PLATFORM_COMPILER_MTA  1
0499   #define PLATFORM_COMPILER_FAMILYNAME MTA
0500   #define PLATFORM_COMPILER_FAMILYID 12
0501   #ifdef __cplusplus
0502     #define PLATFORM_COMPILER_MTA_CXX  1
0503   #else
0504     #define PLATFORM_COMPILER_MTA_C  1
0505   #endif
0506 
0507 #elif defined(_SX)
0508   #define PLATFORM_COMPILER_NECSX  1
0509   #define PLATFORM_COMPILER_FAMILYNAME NECSX
0510   #define PLATFORM_COMPILER_FAMILYID 13
0511   #ifdef __cplusplus
0512     #define PLATFORM_COMPILER_NECSX_CXX  1
0513   #else
0514     #define PLATFORM_COMPILER_NECSX_C  1
0515   #endif
0516 
0517 #elif defined(_MSC_VER)
0518   #define PLATFORM_COMPILER_MICROSOFT  1
0519   #define PLATFORM_COMPILER_FAMILYNAME MICROSOFT
0520   #define PLATFORM_COMPILER_FAMILYID 14
0521   #ifdef __cplusplus
0522     #define PLATFORM_COMPILER_MICROSOFT_CXX  1
0523   #else
0524     #define PLATFORM_COMPILER_MICROSOFT_C  1
0525   #endif
0526   #define PLATFORM_COMPILER_VERSION _MSC_VER
0527 
0528 #elif defined(__TINYC__)
0529   #define PLATFORM_COMPILER_TINY  1
0530   #define PLATFORM_COMPILER_FAMILYNAME TINY
0531   #define PLATFORM_COMPILER_FAMILYID 15
0532   #ifdef __cplusplus
0533     #define PLATFORM_COMPILER_TINY_CXX  1
0534   #else
0535     #define PLATFORM_COMPILER_TINY_C  1
0536   #endif
0537 
0538 #elif defined(__LCC__)
0539   #define PLATFORM_COMPILER_LCC 1
0540   #define PLATFORM_COMPILER_FAMILYNAME LCC
0541   #define PLATFORM_COMPILER_FAMILYID 16
0542   #ifdef __cplusplus
0543     #define PLATFORM_COMPILER_LCC_CXX  1
0544   #else
0545     #define PLATFORM_COMPILER_LCC_C  1
0546   #endif
0547 
0548 #elif defined(__OPENCC__)
0549   #define PLATFORM_COMPILER_OPEN64  1
0550   #define PLATFORM_COMPILER_FAMILYNAME OPEN64
0551   #define PLATFORM_COMPILER_FAMILYID 17
0552   #ifdef __cplusplus
0553     #define PLATFORM_COMPILER_OPEN64_CXX  1
0554   #else
0555     #define PLATFORM_COMPILER_OPEN64_C  1
0556   #endif
0557   /* Note: can't use __OPENCC_PATCHLEVEL__ because it is sometimes non-integer (eg 3.2).
0558      Adding a cast would not result in a preprocessor constant expression. */
0559   #define PLATFORM_COMPILER_VERSION \
0560           PLATFORM_COMPILER_VERSION_INT(__OPENCC__,__OPENCC_MINOR__,0)
0561   #define PLATFORM_COMPILER_VERSION_STR __OPEN64__
0562 
0563 #elif defined(__PCC__)
0564   #define PLATFORM_COMPILER_PCC  1
0565   #define PLATFORM_COMPILER_FAMILYNAME PCC
0566   #define PLATFORM_COMPILER_FAMILYID 18
0567   #ifdef __cplusplus
0568     #define PLATFORM_COMPILER_PCC_CXX  1
0569   #else
0570     #define PLATFORM_COMPILER_PCC_C  1
0571   #endif
0572   #define PLATFORM_COMPILER_VERSION \
0573           PLATFORM_COMPILER_VERSION_INT(__PCC__,__PCC_MINOR__,__PCC_MINORMINOR__)
0574   #define PLATFORM_COMPILER_VERSION_STR \
0575       PLATFORM_STRINGIFY(__PCC__) "." PLATFORM_STRINGIFY(__PCC_MINOR__) "." PLATFORM_STRINGIFY(__PCC_MINORMINOR__)
0576 
0577 #elif defined(__clang__)
0578   #define PLATFORM_COMPILER_CLANG  1
0579   #define PLATFORM_COMPILER_FAMILYNAME CLANG
0580   #define PLATFORM_COMPILER_FAMILYID 19
0581   #ifdef __cplusplus
0582     #define PLATFORM_COMPILER_CLANG_CXX  1
0583   #else
0584     #define PLATFORM_COMPILER_CLANG_C  1
0585   #endif
0586   #ifdef __clang_version__
0587     /* clang 2.7 (gcc 4.2.1 compliant) and earlier lacked specific version identification */
0588     #define PLATFORM_COMPILER_VERSION \
0589             PLATFORM_COMPILER_VERSION_INT(__clang_major__,__clang_minor__,__clang_patchlevel__)
0590     #define PLATFORM_COMPILER_VERSION_STR __clang_version__
0591   #endif
0592 
0593 // NOTE: PLATFORM_COMPILER_FAMILYID "20" is allocated to NVHPC, appearing earlier
0594 
0595 #else /* unknown compiler */
0596   #define PLATFORM_COMPILER_UNKNOWN  1
0597 #endif
0598 
0599 /* this stanza comes last, because many vendor compilers lie and claim 
0600    to be GNU C for compatibility reasons and/or because they share a frontend */ 
0601 #undef _PLATFORM_COMPILER_GNU_VERSION_STR
0602 #undef __PLATFORM_COMPILER_GNU_VERSION_STR
0603 #if defined(__GNUC__)
0604   #undef PLATFORM_COMPILER_UNKNOWN
0605   #ifndef PLATFORM_COMPILER_FAMILYID
0606     #define PLATFORM_COMPILER_GNU  1
0607     #define PLATFORM_COMPILER_FAMILYNAME GNU
0608     #define PLATFORM_COMPILER_FAMILYID 1
0609     #ifdef __cplusplus
0610       #define PLATFORM_COMPILER_GNU_CXX  1
0611     #else
0612       #define PLATFORM_COMPILER_GNU_C  1
0613     #endif
0614    #if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
0615     #define PLATFORM_COMPILER_VERSION \
0616             PLATFORM_COMPILER_VERSION_INT(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__)
0617    #elif defined(__GNUC_MINOR__) /* older versions of egcs lack __GNUC_PATCHLEVEL__ */
0618     #define PLATFORM_COMPILER_VERSION \
0619             PLATFORM_COMPILER_VERSION_INT(__GNUC__,__GNUC_MINOR__,0)
0620    #else
0621     #define PLATFORM_COMPILER_VERSION \
0622             PLATFORM_COMPILER_VERSION_INT(__GNUC__,0,0)
0623    #endif
0624     #define PLATFORM_COMPILER_VERSION_STR __PLATFORM_COMPILER_GNU_VERSION_STR
0625   #else
0626     #define _PLATFORM_COMPILER_GNU_VERSION_STR __PLATFORM_COMPILER_GNU_VERSION_STR
0627   #endif
0628   /* gather any advertised GNU version number info, even for non-gcc compilers */
0629   #if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
0630     #define __PLATFORM_COMPILER_GNU_VERSION_STR \
0631       PLATFORM_STRINGIFY(__GNUC__) "." PLATFORM_STRINGIFY(__GNUC_MINOR__) "." PLATFORM_STRINGIFY(__GNUC_PATCHLEVEL__)
0632   #elif defined(__GNUC_MINOR__)
0633     #define __PLATFORM_COMPILER_GNU_VERSION_STR \
0634       PLATFORM_STRINGIFY(__GNUC__) "." PLATFORM_STRINGIFY(__GNUC_MINOR__) ".?"
0635   #else
0636     #define __PLATFORM_COMPILER_GNU_VERSION_STR \
0637       PLATFORM_STRINGIFY(__GNUC__) ".?.?"
0638   #endif
0639 #elif defined(PLATFORM_COMPILER_UNKNOWN) /* unknown compiler */
0640   #define PLATFORM_COMPILER_FAMILYNAME UNKNOWN
0641   #define PLATFORM_COMPILER_FAMILYID 0 
0642 #endif
0643 
0644 /* defaulting */
0645 
0646 #ifndef PLATFORM_COMPILER_VERSION
0647 #define PLATFORM_COMPILER_VERSION 0 /* don't know */
0648 #endif
0649 
0650 #ifndef PLATFORM_COMPILER_VERSION_STR
0651 #define PLATFORM_COMPILER_VERSION_STR PLATFORM_STRINGIFY(PLATFORM_COMPILER_VERSION)
0652 #endif
0653 
0654 #ifndef PLATFORM_COMPILER_VERSION_INT
0655 #define PLATFORM_COMPILER_VERSION_INT(maj,min,pat) \
0656         (((maj) << 16) | ((min) << 8) | (pat))
0657 #endif
0658 
0659 /* version check macros */
0660 
0661 #define PLATFORM_COMPILER_VERSION_GT(maj,min,pat) \
0662         PLATFORM_COMPILER_VERSION >  PLATFORM_COMPILER_VERSION_INT(maj,min,pat)
0663 #define PLATFORM_COMPILER_VERSION_GE(maj,min,pat) \
0664         PLATFORM_COMPILER_VERSION >= PLATFORM_COMPILER_VERSION_INT(maj,min,pat)
0665 #define PLATFORM_COMPILER_VERSION_EQ(maj,min,pat) \
0666         PLATFORM_COMPILER_VERSION == PLATFORM_COMPILER_VERSION_INT(maj,min,pat)
0667 #define PLATFORM_COMPILER_VERSION_LE(maj,min,pat) \
0668         PLATFORM_COMPILER_VERSION <= PLATFORM_COMPILER_VERSION_INT(maj,min,pat)
0669 #define PLATFORM_COMPILER_VERSION_LT(maj,min,pat) \
0670         PLATFORM_COMPILER_VERSION <  PLATFORM_COMPILER_VERSION_INT(maj,min,pat)
0671 
0672 /* misc feature detection */
0673 
0674 #ifdef __cplusplus
0675   #define PLATFORM_COMPILER_ID (10000+PLATFORM_COMPILER_FAMILYID)
0676 #else
0677   #define PLATFORM_COMPILER_ID PLATFORM_COMPILER_FAMILYID
0678 #endif
0679 
0680 /* default language spec conformance detection */
0681 #if !defined(PLATFORM_COMPILER_C_LANGLVL) && !defined(PLATFORM_COMPILER_CXX_LANGLVL)
0682   #if defined(__cplusplus) && (__cplusplus > 0)  /* C++98 or newer */
0683     #define PLATFORM_COMPILER_CXX_LANGLVL  __cplusplus
0684   #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 0)  /* C95 or newer */
0685     #define PLATFORM_COMPILER_C_LANGLVL  __STDC_VERSION__
0686   #elif defined(__STDC__) && !defined(__cplusplus) && !defined(__STDC_VERSION__) /* C89/C90 */
0687     #define PLATFORM_COMPILER_C_LANGLVL  199000L
0688   #else 
0689     /* unknown - leave both undef */
0690   #endif
0691 #endif
0692 
0693 #undef _PLATFORM_COMPILER_STD_STDC
0694 #ifdef __STDC__
0695   #define _PLATFORM_COMPILER_STD_STDC "__STDC__"
0696 #else
0697   #define _PLATFORM_COMPILER_STD_STDC "-"
0698 #endif
0699 #undef _PLATFORM_COMPILER_STD_STDC_VERSION
0700 #ifdef __STDC_VERSION__
0701   #define _PLATFORM_COMPILER_STD_STDC_VERSION ",__STDC_VERSION__=" PLATFORM_STRINGIFY(__STDC_VERSION__)
0702 #else
0703   #define _PLATFORM_COMPILER_STD_STDC_VERSION
0704 #endif
0705 #undef _PLATFORM_COMPILER_STD_STDC_EXT
0706 #ifdef __STDC_EXT__
0707   #define _PLATFORM_COMPILER_STD_STDC_EXT ",__STDC_EXT__=" PLATFORM_STRINGIFY(__STDC_EXT__)
0708 #else
0709   #define _PLATFORM_COMPILER_STD_STDC_EXT 
0710 #endif
0711 #undef _PLATFORM_COMPILER_STD_CPLUSPLUS
0712 #ifdef __cplusplus
0713   #define _PLATFORM_COMPILER_STD_CPLUSPLUS ",__cplusplus=" PLATFORM_STRINGIFY(__cplusplus)
0714 #else
0715   #define _PLATFORM_COMPILER_STD_CPLUSPLUS 
0716 #endif
0717 
0718 #undef _PLATFORM_COMPILER_MISC_VERSION_STR
0719 #ifndef _PLATFORM_COMPILER_MISC_VERSION_STR
0720   #ifdef __VERSION__
0721     #define _PLATFORM_COMPILER_MISC_VERSION_STR "|misc:" __VERSION__
0722   #else
0723     #define _PLATFORM_COMPILER_MISC_VERSION_STR
0724   #endif
0725 #endif
0726 #undef _PLATFORM_COMPILER_GNU_VERSION_STR_HELP
0727 #ifdef _PLATFORM_COMPILER_GNU_VERSION_STR
0728     #define _PLATFORM_COMPILER_GNU_VERSION_STR_HELP "|GNU:" _PLATFORM_COMPILER_GNU_VERSION_STR
0729 #else
0730     #define _PLATFORM_COMPILER_GNU_VERSION_STR_HELP
0731 #endif
0732 
0733 #define PLATFORM_COMPILER_IDSTR                                      \
0734         "|COMPILER_FAMILY:"                                          \
0735           PLATFORM_STRINGIFY(PLATFORM_COMPILER_FAMILYNAME)           \
0736         "|COMPILER_VERSION:" PLATFORM_COMPILER_VERSION_STR           \
0737         "|COMPILER_FAMILYID:"                                        \
0738           PLATFORM_STRINGIFY(PLATFORM_COMPILER_FAMILYID)             \
0739          _PLATFORM_COMPILER_GNU_VERSION_STR_HELP                     \
0740         "|STD:" _PLATFORM_COMPILER_STD_STDC                          \
0741                 _PLATFORM_COMPILER_STD_STDC_VERSION                  \
0742                 _PLATFORM_COMPILER_STD_STDC_EXT                      \
0743                 _PLATFORM_COMPILER_STD_CPLUSPLUS                     \
0744          _PLATFORM_COMPILER_MISC_VERSION_STR                         \
0745         "|"
0746 
0747 /* ------------------------------------------------------------------------------------ */
0748 /* OS detection */
0749 /* 
0750    PLATFORM_OS_<family>:
0751      defined to a positive value if OS belongs to a given family, undef otherwise
0752    PLATFORM_OS_FAMILYNAME:
0753      unquoted token which provides the compiler family name
0754 */
0755 
0756 #if defined(__LIBCATAMOUNT__) || defined(__QK_USER__)
0757   #define PLATFORM_OS_CATAMOUNT 1
0758   #define PLATFORM_OS_FAMILYNAME CATAMOUNT
0759 
0760 #elif defined(__CRAYXT_COMPUTE_LINUX_TARGET)
0761   #define PLATFORM_OS_CNL 1
0762   #define PLATFORM_OS_FAMILYNAME CNL
0763 
0764 #elif defined(GASNETI_ARCH_BGP) || defined(__bgp__)
0765   #define PLATFORM_OS_BGP 1
0766   #define PLATFORM_OS_FAMILYNAME BGP
0767 
0768 #elif defined(GASNETI_ARCH_BGQ) || defined(__bgq__)
0769   #define PLATFORM_OS_BGQ 1
0770   #define PLATFORM_OS_FAMILYNAME BGQ
0771 
0772 #elif defined(GASNETI_ARCH_WSL)
0773   #define PLATFORM_OS_WSL 1
0774   #define PLATFORM_OS_FAMILYNAME WSL
0775 
0776 #elif defined(__K42)
0777   #define PLATFORM_OS_K42 1
0778   #define PLATFORM_OS_FAMILYNAME K42
0779 
0780 #elif defined(__uClinux__)
0781   #define PLATFORM_OS_UCLINUX 1
0782   #define PLATFORM_OS_FAMILYNAME UCLINUX
0783 
0784 #elif defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
0785   #define PLATFORM_OS_LINUX 1
0786   #define PLATFORM_OS_FAMILYNAME LINUX
0787 
0788 #elif defined(__blrts) || defined(__blrts__) || defined(__gnu_blrts__)
0789   #define PLATFORM_OS_BLRTS 1
0790   #define PLATFORM_OS_FAMILYNAME BLRTS
0791 
0792 #elif defined(__CYGWIN__)
0793   #define PLATFORM_OS_CYGWIN 1
0794   #define PLATFORM_OS_FAMILYNAME CYGWIN
0795 
0796 #elif defined(_WIN32)
0797   #define PLATFORM_OS_MSWINDOWS 1
0798   #define PLATFORM_OS_FAMILYNAME MSWINDOWS
0799 
0800 #elif defined(_AIX)
0801   #define PLATFORM_OS_AIX 1
0802   #define PLATFORM_OS_FAMILYNAME AIX
0803 
0804 #elif defined(__osf__) || defined(__digital__)
0805   #define PLATFORM_OS_TRU64 1
0806   #define PLATFORM_OS_FAMILYNAME TRU64
0807 
0808 #elif defined(__FreeBSD) || defined(__FreeBSD__)
0809   #define PLATFORM_OS_FREEBSD 1
0810   #define PLATFORM_OS_FAMILYNAME FREEBSD
0811 
0812 #elif defined(__NetBSD) || defined(__NetBSD__)
0813   #define PLATFORM_OS_NETBSD 1
0814   #define PLATFORM_OS_FAMILYNAME NETBSD
0815 
0816 #elif defined(__OpenBSD__)
0817   #define PLATFORM_OS_OPENBSD 1
0818   #define PLATFORM_OS_FAMILYNAME OPENBSD
0819 
0820 #elif defined(__sun) || defined(__sun__)
0821   #define PLATFORM_OS_SOLARIS 1
0822   #define PLATFORM_OS_FAMILYNAME SOLARIS
0823 
0824 #elif (defined(__APPLE__) && defined(__MACH__)) || \
0825       defined(__osx86__) /* PGI on OSX */
0826   #define PLATFORM_OS_DARWIN 1
0827   #define PLATFORM_OS_FAMILYNAME DARWIN
0828 
0829 #elif defined(__sgi) || defined(__sgi__)
0830   #define PLATFORM_OS_IRIX 1
0831   #define PLATFORM_OS_FAMILYNAME IRIX
0832 
0833 #elif defined(__hpux) || defined(__hpux__)
0834   #define PLATFORM_OS_HPUX 1
0835   #define PLATFORM_OS_FAMILYNAME HPUX
0836 
0837 #elif defined(_CRAY) || defined(_UNICOSMP)
0838   #define PLATFORM_OS_UNICOS 1
0839   #define PLATFORM_OS_FAMILYNAME UNICOS
0840 
0841 #elif defined(__MTA__)
0842   #define PLATFORM_OS_MTA 1
0843   #define PLATFORM_OS_FAMILYNAME MTA
0844 
0845 #elif defined(_SX)
0846   #define PLATFORM_OS_SUPERUX 1
0847   #define PLATFORM_OS_FAMILYNAME SUPERUX
0848 
0849 #else
0850   #define PLATFORM_OS_UNKNOWN 1
0851   #define PLATFORM_OS_FAMILYNAME UNKNOWN
0852 #endif
0853 
0854 /* ------------------------------------------------------------------------------------ */
0855 /* Architecture detection */
0856 /* 
0857    PLATFORM_ARCH_<family>:
0858      defined to positive value if CPU belongs to a given family, undef otherwise
0859    PLATFORM_ARCH_FAMILYNAME:
0860      unquoted token which provides the CPU family name
0861 
0862    PLATFORM_ARCH_32              - 32-bit pointers
0863    PLATFORM_ARCH_64              - 64-bit pointers
0864    PLATFORM_ARCH_BIG_ENDIAN      - big-endian word order
0865    PLATFORM_ARCH_LITTLE_ENDIAN   - little-endian word order
0866      defined to positive value if CPU is known to have the indicated property, undef otherwise
0867  */
0868 
0869 #if defined(__ppc64) || defined(__ppc64__) || \
0870     defined(__PPC64) || defined(__PPC64__) || \
0871     defined(__powerpc64) || defined(__powerpc64__) 
0872   #define PLATFORM_ARCH_POWERPC 1
0873   #define PLATFORM_ARCH_FAMILYNAME POWERPC
0874   #define _PLATFORM_ARCH_64 1
0875   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0876 
0877 #elif defined(_POWER) || \
0878       defined(__PPC)  || defined(__PPC__) || \
0879       defined(__powerpc) || defined(__powerpc__) || \
0880       defined(__ppc) || defined(__ppc__) || \
0881       defined(__POWERPC__)
0882   #define PLATFORM_ARCH_POWERPC 1
0883   #define PLATFORM_ARCH_FAMILYNAME POWERPC
0884   #define _PLATFORM_ARCH_32 1
0885   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0886 
0887 #elif defined(_ARCH_PPC) || defined(_ARCH_PPC64)
0888   #define PLATFORM_ARCH_POWERPC 1
0889   #define PLATFORM_ARCH_FAMILYNAME POWERPC
0890   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0891 
0892 #elif defined(__KNC__) || defined(__MIC__)
0893   #define PLATFORM_ARCH_MIC 1
0894   #define PLATFORM_ARCH_FAMILYNAME MIC
0895   #define _PLATFORM_ARCH_64 1
0896   #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
0897 
0898 #elif defined(__x86_64) || defined(__x86_64__) || \
0899     defined(__athlon) || defined(__athlon__) || \
0900     defined(__amd64)  || defined(__amd64__)
0901   #define PLATFORM_ARCH_X86_64 1
0902   #define PLATFORM_ARCH_FAMILYNAME X86_64
0903   #define _PLATFORM_ARCH_64 1
0904   #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
0905 
0906 #elif defined(__ia64__) || defined(__ia64)
0907   #define PLATFORM_ARCH_IA64 1
0908   #define PLATFORM_ARCH_FAMILYNAME IA64
0909   #define _PLATFORM_ARCH_64 1
0910   #if defined(PLATFORM_OS_LINUX) || defined(PLATFORM_OS_FREEBSD)
0911     #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
0912   #elif defined(PLATFORM_OS_HPUX)
0913     #define _PLATFORM_ARCH_BIG_ENDIAN 1
0914   #else
0915     /* Unknown.  Hope one of the other mechanisms can sort it out. */
0916   #endif
0917 
0918 #elif defined(__i386__) || defined(__i386) || \
0919       defined(__i486__) || defined(__i486) || \
0920       defined(__i586__) || defined(__i586) || \
0921       defined(__i686__) || defined(__i686) || \
0922       defined(__pentiumpro) || defined(__pentiumpro__) || \
0923       defined(_M_IX86)
0924   #define PLATFORM_ARCH_X86 1
0925   #define PLATFORM_ARCH_FAMILYNAME X86
0926   #define _PLATFORM_ARCH_32 1
0927   #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
0928 
0929 #elif defined(__alpha) || defined(__alpha__)
0930   #define PLATFORM_ARCH_ALPHA 1
0931   #define PLATFORM_ARCH_FAMILYNAME ALPHA
0932   #define _PLATFORM_ARCH_64 1
0933   #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
0934 
0935 #elif defined(_mips) || defined(__mips) || defined(__mips__) || \
0936     defined(__host_mips) || defined(__host_mips__) || \
0937     defined(_MIPS_ARCH) || defined(__R4000)
0938   #define PLATFORM_ARCH_MIPS 1
0939   #define PLATFORM_ARCH_FAMILYNAME MIPS
0940   #ifdef _MIPSEL /* MIPS cores support both little and big endian modes */
0941     /* SiCortex */
0942     #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
0943   #else
0944     /* IRIX */
0945     #define _PLATFORM_ARCH_BIG_ENDIAN 1
0946   #endif
0947   #ifdef _MIPS_SZPTR
0948     #if _MIPS_SZPTR == 32
0949       #define _PLATFORM_ARCH_32 1
0950     #elif _MIPS_SZPTR == 64
0951       #define _PLATFORM_ARCH_64 1
0952     #endif
0953   #endif
0954 
0955 #elif defined(__sparc) || defined(__sparc__) || \
0956     defined(__sparclet__) || defined(__sparclite__) || \
0957     defined(__sparcv8) || defined(__sparcv9)
0958   #define PLATFORM_ARCH_SPARC 1
0959   #define PLATFORM_ARCH_FAMILYNAME SPARC
0960   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0961 
0962 #elif defined(__hppa) || defined(__hppa__) || \
0963     defined(__parisc) || defined(__parisc__) || \
0964     defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
0965   #define PLATFORM_ARCH_PARISC 1
0966   #define PLATFORM_ARCH_FAMILYNAME PARISC
0967   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0968 
0969 #elif defined(__crayx1)
0970   #define PLATFORM_ARCH_CRAYX1 1
0971   #define PLATFORM_ARCH_FAMILYNAME CRAYX1
0972   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0973   #define _PLATFORM_ARCH_64 1
0974 
0975 #elif defined(_CRAYT3E)
0976   #define PLATFORM_ARCH_CRAYT3E 1
0977   #define PLATFORM_ARCH_FAMILYNAME CRAYT3E
0978   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0979   #define _PLATFORM_ARCH_64 1
0980 
0981 #elif defined(__MTA__)
0982   #define PLATFORM_ARCH_MTA 1
0983   #define PLATFORM_ARCH_FAMILYNAME MTA
0984 
0985 #elif defined(_SX)
0986   #define PLATFORM_ARCH_NECSX 1
0987   #define PLATFORM_ARCH_FAMILYNAME NECSX
0988 
0989 #elif defined(__MICROBLAZE__)
0990   #define PLATFORM_ARCH_MICROBLAZE 1
0991   #define PLATFORM_ARCH_FAMILYNAME MICROBLAZE
0992   #define _PLATFORM_ARCH_BIG_ENDIAN 1
0993   #define _PLATFORM_ARCH_32 1
0994 
0995 #elif defined(__arm__)
0996   #define PLATFORM_ARCH_ARM 1
0997   #define PLATFORM_ARCH_FAMILYNAME ARM
0998   #define _PLATFORM_ARCH_32 1
0999   #if defined(__ARMEB__)
1000     #define _PLATFORM_ARCH_BIG_ENDIAN 1
1001   #elif defined(__ARMEL__)
1002     #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
1003   #endif
1004 
1005 #elif defined(__aarch64__)
1006   #define PLATFORM_ARCH_AARCH64 1
1007   #define PLATFORM_ARCH_FAMILYNAME AARCH64
1008   #if defined(__AARCH64EB__)
1009     #define _PLATFORM_ARCH_BIG_ENDIAN 1
1010   #elif defined(__AARCH64EL__)
1011     #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
1012   #endif
1013 
1014 #elif defined(__tile__)
1015   #define PLATFORM_ARCH_TILE 1
1016   #define PLATFORM_ARCH_FAMILYNAME TILE
1017   #define _PLATFORM_ARCH_LITTLE_ENDIAN 1
1018   #if defined(__tilegx__)
1019     #define _PLATFORM_ARCH_64 1
1020   #else
1021     #define _PLATFORM_ARCH_32 1
1022   #endif
1023 
1024 #elif defined(__s390__)
1025   #define PLATFORM_ARCH_S390 1
1026   #define PLATFORM_ARCH_FAMILYNAME S390
1027   #define _PLATFORM_ARCH_BIG_ENDIAN 1
1028   #if defined(__s390x__)
1029     #define _PLATFORM_ARCH_64 1
1030   #else
1031     #define _PLATFORM_ARCH_32 1
1032   #endif
1033 
1034 #else /* unknown CPU */
1035   #define PLATFORM_ARCH_UNKNOWN 1
1036   #define PLATFORM_ARCH_FAMILYNAME UNKNOWN
1037 #endif
1038 
1039 /* generic chip properties */
1040 
1041 #if defined(PLATFORM_ARCH_BIG_ENDIAN) || defined(PLATFORM_ARCH_LITTLE_ENDIAN)
1042   #error internal error in endianness configuration
1043 #endif
1044 
1045 /* PLATFORM_ARCH_{BIG,LITTLE}_ENDIAN:
1046     first detect common preprocessor defines
1047     then default to any arch-specific value provided
1048  */
1049 
1050 #if defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN) || \
1051     ( __BYTE_ORDER__ > 0 && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ )
1052   #define PLATFORM_ARCH_BIG_ENDIAN 1
1053 #elif defined(__LITTLE_ENDIAN__) || defined(WORDS_LITTLEENDIAN) || \
1054     ( __BYTE_ORDER__ > 0 && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ )
1055   #define PLATFORM_ARCH_LITTLE_ENDIAN 1
1056 #elif defined(_PLATFORM_ARCH_BIG_ENDIAN)
1057   #define PLATFORM_ARCH_BIG_ENDIAN 1
1058 #elif defined(_PLATFORM_ARCH_LITTLE_ENDIAN)
1059   #define PLATFORM_ARCH_LITTLE_ENDIAN 1
1060 #endif
1061 #undef _PLATFORM_ARCH_BIG_ENDIAN
1062 #undef _PLATFORM_ARCH_LITTLE_ENDIAN
1063 
1064 #if defined(PLATFORM_ARCH_BIG_ENDIAN) && defined(PLATFORM_ARCH_LITTLE_ENDIAN)
1065   #error conflicting endianness information
1066 #endif
1067 
1068 /* PLATFORM_ARCH_{32,64}: 
1069     first trust SIZEOF_VOID_P, which is most likely to be accurate
1070     next, detect common 32/64 preprocessor defines
1071     finally default to any arch-specific value provided
1072  */
1073 #if defined(PLATFORM_ARCH_64) || defined(PLATFORM_ARCH_32)
1074   #error internal error in bit width configuration
1075 #endif
1076 
1077 #if SIZEOF_VOID_P == 8
1078   #define PLATFORM_ARCH_64 1
1079 #elif SIZEOF_VOID_P == 4
1080   #define PLATFORM_ARCH_32 1
1081 #elif defined(_LP64) || defined(__LP64__) || \
1082       defined(__arch64__) || defined(__64BIT__) || \
1083       __INTPTR_MAX__ > 2147483647
1084   #define PLATFORM_ARCH_64 1
1085 #elif defined(_ILP32) || defined(__ILP32__) || \
1086       defined(__arch32__) || defined(__32BIT__) || \
1087       __INTPTR_MAX__ == 2147483647
1088   #define PLATFORM_ARCH_32 1
1089 #elif defined(_PLATFORM_ARCH_64)
1090   #define PLATFORM_ARCH_64 1
1091 #elif defined(_PLATFORM_ARCH_32)
1092   #define PLATFORM_ARCH_32 1
1093 #endif
1094 #undef _PLATFORM_ARCH_64
1095 #undef _PLATFORM_ARCH_32
1096 
1097 #if defined(PLATFORM_ARCH_64) && defined(PLATFORM_ARCH_32)
1098   #error conflicting bit width information
1099 #elif !defined(PLATFORM_ARCH_64) && !defined(PLATFORM_ARCH_32)
1100   #error missing bit width information
1101 #endif
1102 
1103 /* ------------------------------------------------------------------------------------ */
1104 /* handy test code that can be parsed after preprocess or executed to show platform results */
1105 #ifdef PLATFORM_SHOW
1106 #include <stdio.h>
1107 #include <assert.h>
1108 const char *
1109 COMPILER_FAMILYNAME = PLATFORM_STRINGIFY(PLATFORM_COMPILER_FAMILYNAME)
1110 , *
1111 COMPILER_FAMILYID = PLATFORM_STRINGIFY(PLATFORM_COMPILER_FAMILYID)
1112 , *
1113 COMPILER_VERSION_STR = PLATFORM_COMPILER_VERSION_STR
1114 , *
1115 COMPILER_IDSTR = PLATFORM_COMPILER_IDSTR
1116 , *
1117 OS_FAMILYNAME = PLATFORM_STRINGIFY(PLATFORM_OS_FAMILYNAME)
1118 , *
1119 ARCH_FAMILYNAME = PLATFORM_STRINGIFY(PLATFORM_ARCH_FAMILYNAME)
1120 ;
1121 int main(void) {
1122   #define PLATFORM_DISP(x) printf("PLATFORM_"#x"=%s\n",x)
1123   #define PLATFORM_DISPI(x) printf("PLATFORM_"#x"=%li\n",(long int)PLATFORM_##x)
1124   #define PLATFORM_DISPX(x) printf("PLATFORM_"#x"=0x%lx\n",(long int)PLATFORM_##x)
1125   PLATFORM_DISP(COMPILER_FAMILYNAME);
1126   PLATFORM_DISP(COMPILER_FAMILYID);
1127   PLATFORM_DISPI(COMPILER_ID);
1128   PLATFORM_DISPX(COMPILER_VERSION);
1129   PLATFORM_DISP(COMPILER_VERSION_STR);
1130   PLATFORM_DISP(COMPILER_IDSTR);
1131   #if PLATFORM_COMPILER_C_LANGLVL
1132     PLATFORM_DISPI(COMPILER_C_LANGLVL);
1133   #elif PLATFORM_COMPILER_CXX_LANGLVL
1134     PLATFORM_DISPI(COMPILER_CXX_LANGLVL);
1135   #else
1136     printf("WARNING: Missing PLATFORM_COMPILER_C(XX)_LANGLVL!");
1137   #endif
1138   PLATFORM_DISP(OS_FAMILYNAME);
1139   PLATFORM_DISP(ARCH_FAMILYNAME);
1140   #if PLATFORM_ARCH_32
1141     PLATFORM_DISPI(ARCH_32);
1142     assert(sizeof(void *) == 4);
1143   #else
1144     PLATFORM_DISPI(ARCH_64);
1145     assert(sizeof(void *) == 8);
1146   #endif
1147   { int x = 0x00FF;
1148     unsigned char *p = (unsigned char *)&x;
1149   #if PLATFORM_ARCH_BIG_ENDIAN
1150     PLATFORM_DISPI(ARCH_BIG_ENDIAN);
1151     assert(*p == 0);
1152   #else
1153     PLATFORM_DISPI(ARCH_LITTLE_ENDIAN);
1154     assert(*p == 0xFF);
1155   #endif
1156   }
1157   return 0;
1158 }
1159 #endif
1160 /* ------------------------------------------------------------------------------------ */
1161 #endif