1 /******************************************************************************* 2 * msvc.h 3 * 4 * --------------------------------------------------------------------------- 5 * Persistence of Vision Ray Tracer ('POV-Ray') version 3.7. 6 * Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd. 7 * 8 * POV-Ray is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License as 10 * published by the Free Software Foundation, either version 3 of the 11 * License, or (at your option) any later version. 12 * 13 * POV-Ray is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Affero General Public License for more details. 17 * 18 * You should have received a copy of the GNU Affero General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * --------------------------------------------------------------------------- 21 * POV-Ray is based on the popular DKB raytracer version 2.12. 22 * DKBTrace was originally written by David K. Buck. 23 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. 24 * --------------------------------------------------------------------------- 25 * $File: //depot/public/povray/3.x/vfe/win/compilers/msvc.h $ 26 * $Revision: #1 $ 27 * $Change: 6069 $ 28 * $DateTime: 2013/11/06 11:59:40 $ 29 * $Author: chrisc $ 30 *******************************************************************************/ 31 32 #ifndef __MSVC_H__ 33 #define __MSVC_H__ 34 35 #if _MSC_VER < 1400 36 #error minimum Visual C++ version supported is 14.0 (supplied with VS 2005) 37 #endif 38 39 #undef USE_AVX_FMA4_FOR_NOISE 40 #if _MSC_FULL_VER >= 160040219 41 // MS Visual C++ 2010 (aka 10.0) SP1 42 #define USE_AVX_FMA4_FOR_NOISE 43 #endif 44 45 #include <direct.h> 46 #include <stdio.h> 47 #include <intrin.h> 48 49 #pragma auto_inline(on) 50 #pragma warning(disable : 4018) /* signed/unsigned mismatch */ 51 #pragma warning(disable : 4305) /* truncation from 'type1' to 'type2' (mostly double to float) */ 52 #pragma warning(disable : 4244) /* possible loss of data (converting ints to shorts) */ 53 54 #ifdef __INTEL_COMPILER 55 56 #pragma warning(disable : 1899) /* multicharacter character literal */ 57 58 #if __INTEL_COMPILER < 1010 59 #error minimum Intel C++ version supported is 10.1 60 #endif 61 62 #if __INTEL_COMPILER >= 1000 && __INTEL_COMPILER < 1100 63 #define COMPILER_VER ".icl10" 64 #define METADATA_COMPILER_STRING "icl 10" 65 #elif __INTEL_COMPILER >= 1100 && __INTEL_COMPILER < 1200 66 #define COMPILER_VER ".icl11" 67 #define METADATA_COMPILER_STRING "icl 11" 68 #else 69 #error Please update msvc.h to include this version of ICL 70 #endif 71 #define COMPILER_NAME "Intel C++ Compiler" 72 #define COMPILER_VERSION __INTEL_COMPILER 73 74 #ifdef BUILD_SSE2 75 #define METADATA_X86_FPU_STRING "-sse2" 76 #else 77 #define METADATA_X86_FPU_STRING "" 78 #endif 79 80 #else 81 82 #pragma inline_recursion(on) 83 #pragma inline_depth(255) 84 85 #if _MSC_VER >= 1400 && _MSC_VER < 1500 && !defined (_WIN64) 86 // MS Visual C++ 2005 (aka 8.0), compiling for 32 bit target 87 #define COMPILER_VER ".msvc8" 88 #define METADATA_COMPILER_STRING "msvc 8" 89 #elif _MSC_VER >= 1400 && _MSC_VER < 1500 && defined (_WIN64) 90 // MS Visual C++ 2005 (aka 8.0), compiling for 64 bit target 91 #define COMPILER_VER ".msvc8" 92 #define METADATA_COMPILER_STRING "msvc 8" 93 #define ALIGN16 __declspec(align(16)) max(const int & _X,const int & _Y)94 inline const int& max(const int& _X, const int& _Y) {return (_X < _Y ? _Y : _X); } min(const int & _X,const int & _Y)95 inline const int& min(const int& _X, const int& _Y) {return (_Y < _X ? _Y : _X); } max(const unsigned int & _X,const unsigned int & _Y)96 inline const unsigned int& max(const unsigned int& _X, const unsigned int& _Y) {return (_X < _Y ? _Y : _X); } min(const unsigned int & _X,const unsigned int & _Y)97 inline const unsigned int& min(const unsigned int& _X, const unsigned int& _Y) {return (_Y < _X ? _Y : _X); } max(const long & _X,const long & _Y)98 inline const long& max(const long& _X, const long& _Y) {return (_X < _Y ? _Y : _X); } min(const long & _X,const long & _Y)99 inline const long& min(const long& _X, const long& _Y) {return (_Y < _X ? _Y : _X); } max(const unsigned long & _X,const unsigned long & _Y)100 inline const unsigned long& max(const unsigned long& _X, const unsigned long& _Y) {return (_X < _Y ? _Y : _X); } min(const unsigned long & _X,const unsigned long & _Y)101 inline const unsigned long& min(const unsigned long& _X, const unsigned long& _Y) {return (_Y < _X ? _Y : _X); } 102 #elif _MSC_VER >= 1500 && _MSC_VER < 1600 103 // MS Visual C++ 2008 (aka 9.0) 104 #define COMPILER_VER ".msvc9" 105 #define METADATA_COMPILER_STRING "msvc 9" 106 #elif _MSC_VER >= 1600 && _MSC_VER < 1700 107 // MS Visual C++ 2010 (aka 10.0) 108 #define COMPILER_VER ".msvc10" 109 #define METADATA_COMPILER_STRING "msvc 10" 110 // msvc10 defines std::hash<> as a class, while boost's flyweight_fwd.hpp may declare it as a struct; 111 // this is valid according to the C++ standard, but causes msvc10 to issue warnings. 112 #pragma warning(disable : 4099) 113 #elif _MSC_VER >= 1900 && _MSC_VER < 2000 114 // MS Visual C++ 2015 (aka 14.0) 115 #define COMPILER_VER ".msvc14" 116 #define METADATA_COMPILER_STRING "msvc 14" 117 #else 118 #error Please update msvc.h to include this version of MSVC 119 #endif 120 #define COMPILER_NAME "Microsoft Visual C++" 121 #define COMPILER_VERSION _MSC_VER 122 123 #define NEED_INVHYP 124 125 // boost will define these for us otherwise 126 #ifdef NOT_USING_BOOST 127 #if !defined (_WIN64) 128 extern "C" 129 { 130 __declspec(dllimport) long __stdcall _InterlockedIncrement(long volatile *Addend); 131 __declspec(dllimport) long __stdcall _InterlockedDecrement(long volatile *Addend); 132 __declspec(dllimport) long __stdcall _InterlockedCompareExchange(long volatile *Dest, long Exchange, long Comp); 133 __declspec(dllimport) long __stdcall _InterlockedExchange(long volatile *Target, long Value); 134 __declspec(dllimport) long __stdcall _InterlockedExchangeAdd(long volatile *Addend, long Value); 135 } 136 137 #pragma intrinsic (_InterlockedCompareExchange) 138 #define InterlockedCompareExchange _InterlockedCompareExchange 139 140 #pragma intrinsic (_InterlockedExchange) 141 #define InterlockedExchange _InterlockedExchange 142 143 #pragma intrinsic (_InterlockedExchangeAdd) 144 #define InterlockedExchangeAdd _InterlockedExchangeAdd 145 146 #pragma intrinsic (_InterlockedIncrement) 147 #define InterlockedIncrement _InterlockedIncrement 148 149 #pragma intrinsic (_InterlockedDecrement) 150 #define InterlockedDecrement _InterlockedDecrement 151 #endif 152 #endif 153 154 #endif 155 156 #ifdef _WIN64 157 #if defined(_M_X64) 158 #define METADATA_PLATFORM_STRING "x86_64-pc-win" 159 #else 160 #error Please update msvc.h to include this 64-bit architecture 161 #endif 162 #elif defined _WIN32 163 #if !defined(METADATA_X86_FPU_STRING) 164 #if defined(_M_IX86_FP) 165 #if (_M_IX86_FP == 0) 166 #define METADATA_X86_FPU_STRING "" 167 #elif (_M_IX86_FP == 1) 168 #define METADATA_X86_FPU_STRING "-sse" 169 #elif (_M_IX86_FP == 2) 170 #define METADATA_X86_FPU_STRING "-sse2" 171 #else 172 #error Please update msvc.h to include this x86 FPU generation 173 #endif 174 #else 175 #error Please update msvc.h to detect x86 FPU generation for your compiler 176 #endif 177 #endif 178 #if defined(_M_IX86) 179 #if (_M_IX86 == 300) 180 #define METADATA_PLATFORM_STRING "i386-pc-win" METADATA_X86_FPU_STRING 181 #elif (_M_IX86 == 400) 182 #define METADATA_PLATFORM_STRING "i486-pc-win" METADATA_X86_FPU_STRING 183 #elif (_M_IX86 == 500) 184 #define METADATA_PLATFORM_STRING "i586-pc-win" METADATA_X86_FPU_STRING 185 #elif (_M_IX86 == 600) 186 #define METADATA_PLATFORM_STRING "i686-pc-win" METADATA_X86_FPU_STRING 187 #elif (_M_IX86 == 700) 188 #define METADATA_PLATFORM_STRING "i786-pc-win" METADATA_X86_FPU_STRING 189 #else 190 #error Please update msvc.h to include this x86 CPU generation 191 #endif 192 #else 193 #error Please update msvc.h to include this 32-bit architecture 194 #endif 195 #endif 196 197 #define QSORT(a,b,c,d) qsort(reinterpret_cast<void *>(a), (size_t) b, (size_t) c, d) 198 #define POV_LONG __int64 199 #define FORCEINLINE __forceinline 200 201 #undef ReturnAddress 202 #define ReturnAddress() _ReturnAddress() 203 204 #define DECLARE_THREAD_LOCAL_PTR(ptrType, ptrName) __declspec(thread) ptrType *ptrName 205 #define IMPLEMENT_THREAD_LOCAL_PTR(ptrType, ptrName, ignore) __declspec(thread) ptrType *ptrName 206 #define GET_THREAD_LOCAL_PTR(ptrName) (ptrName) 207 #define SET_THREAD_LOCAL_PTR(ptrName, ptrValue) (ptrName = ptrValue) 208 209 #endif 210