1717#include < stdlib.h>
1818#include < memory.h>
1919#include < string.h>
20+ #include " globalincs/toolchain.h"
2021
2122#if defined( __x86_64__ ) || defined( _WIN64 )
2223#define IAM_64BIT 1
@@ -63,39 +64,6 @@ typedef unsigned short ushort;
6364typedef unsigned int uint;
6465typedef unsigned long ulong;
6566
66- // Format specifier macros
67- #ifdef DOXYGEN
68- // Documentation macros, only used by DOXYGEN
69- /* *
70- * @brief Identifies a printf-style format string
71- */
72- #define SCP_FORMAT_STRING
73-
74- /* *
75- * @brief Specifies which arguments are involved in printf-style string formatting
76- *
77- * @details Expands to a compiler specific attribute which specify where the
78- * format arguments are located. Parameters are 1-based which also includes
79- * the 'this' parameter at position 1 for class methods.
80- *
81- * @param formatArg The location of the format string argument in the argument list
82- * @param varArgs The location where the variable arguments begin
83- */
84- #define SCP_FORMAT_STRING_ARGS (formatArg, varArgs )
85- #elif defined(_MSC_VER)
86- #include < sal.h>
87-
88- #define SCP_FORMAT_STRING _Printf_format_string_
89- #define SCP_FORMAT_STRING_ARGS (x, y )
90- #elif defined(__GNUC__) || defined(__clang__)
91- // GCC and clang use function attributes
92- #define SCP_FORMAT_STRING
93- #define SCP_FORMAT_STRING_ARGS (x, y ) __attribute__ ((format (printf, x, y)))
94- #else
95- #define SCP_FORMAT_STRING
96- #define SCP_FORMAT_STRING_ARGS (x, y )
97- #endif
98-
9967#define HARDWARE_ONLY
10068
10169// Stucture to store clipping codes in a word
@@ -264,11 +232,6 @@ extern int Global_error_count;
264232
265233#include " osapi/outwnd.h"
266234
267- // remove __attribute__ on non-GCC compilers
268- #ifndef __GNUC__
269- # define __attribute__ (x ) /* NOTHING*/
270- #endif
271-
272235// To debug printf do this:
273236// mprintf(( "Error opening %s\n", filename ));
274237#ifndef NDEBUG
@@ -290,22 +253,10 @@ extern int Global_error_count;
290253// Please never uncomment the functionality of Assert in debug
291254// The code, as with all development like this is littered with Asserts which are designed to throw
292255// up an error message if variables are out of range.
293-
294- #define ASSUME (x )
295-
296256// Disabling this functionality is dangerous, crazy values can run rampent unchecked and the longer its disabled
297257// the more likely you are to have problems getting it working again.
298258#if defined(NDEBUG)
299259# define Assert (expr ) do { ASSUME (expr); } while (0 )
300- # ifndef _MSC_VER // non MS compilers
301- # define Assertion (expr, msg, ...) do {} while (0 )
302- # else
303- # if _MSC_VER >= 1400 // VC 2005 or greater
304- # define Assertion (expr, msg, ...) do { ASSUME (expr); } while (0 )
305- # else
306- # define Assertion (expr, msg ) do {} while (0 )
307- # endif
308- # endif
309260#else
310261 void gr_activate (int );
311262# define Assert (expr ) do {\
@@ -314,30 +265,6 @@ extern int Global_error_count;
314265 }\
315266 ASSUME ( expr );\
316267 } while (0 )
317-
318- // Assertion can only use its proper fuctionality in compilers that support variadic macro
319- # ifndef _MSC_VER // non MS compilers
320- # define Assertion (expr, msg, ...) do {\
321- if (!(expr)) {\
322- WinAssert (#expr,__FILE__,__LINE__, msg , ##__VA_ARGS__ );\
323- }\
324- } while (0 )
325- # else
326- # if _MSC_VER >= 1400 // VC 2005 or greater
327- # define Assertion (expr, msg, ...) do {\
328- if (!(expr)) {\
329- WinAssert (#expr,__FILE__,__LINE__, msg, __VA_ARGS__ );\
330- }\
331- ASSUME (expr);\
332- } while (0 )
333- # else // older MSVC compilers
334- # define Assertion (expr, msg ) do {\
335- if (!(expr)) {\
336- WinAssert (#expr,__FILE__,__LINE__);\
337- }\
338- } while (0 )
339- # endif
340- # endif
341268#endif
342269/* ******************NEVER COMMENT Assert ************************************************/
343270
@@ -693,79 +620,9 @@ class camid
693620 bool isValid ();
694621};
695622
696- /* Restrict keyword semantics are different under VC and GCC */
697-
698- #ifndef NO_RESTRICT_USE
699- # ifdef _MSC_VER
700- # if _MSC_VER >= 1400
701- # define RESTRICT __restrict
702- # else
703- # define RESTRICT
704- # endif
705- # else
706- # define RESTRICT restrict
707- # endif
708- #else
709- # define RESTRICT
710- #endif
711-
712623#include " globalincs/vmallocator.h"
713624#include " globalincs/safe_strings.h"
714625
715- // Macros for portable printf argument specification
716- #ifdef DOXYGEN
717- // Special section for doxygen
718- /* *
719- * @brief Format specifier for a @c size_t argument
720- * Due to different runtimes using different format specifier for these types
721- * it's necessary to hide these changes behind a macro. Use this in place of %zu
722- */
723- #define SIZE_T_ARG
724- /* *
725- * @brief Format specifier for a @c ptrdiff_t argument
726- * Due to different runtimes using different format specifier for these types
727- * it's necessary to hide these changes behind a macro. Use this in place of %zd
728- */
729- #define PTRDIFF_T_ARG
730- #elif defined(_MSC_VER)
731- #define SIZE_T_ARG " %Iu"
732- #define PTRDIFF_T_ARG " %Id"
733- #else
734- // Asume C99 compatibility for everyone else
735- #define SIZE_T_ARG " %zu"
736- #define PTRDIFF_T_ARG " %zd"
737- #endif
738-
739- // c++11 standard detection
740- // for GCC with autotools, see AX_CXX_COMPILE_STDCXX_11 macro in configure.ac
741- // this sets HAVE_CXX11 & -std=c++0x or -std=c++11 appropriately
742-
743- #ifndef HAVE_CXX11
744- // Use the visual studio version to detect C++11 support
745- #if _MSC_VER >= 1600
746- # define HAVE_CXX11
747- #endif
748- // clang doesn't seem to have a feature check for is_trivial
749- // oh well, assume it'll be covered by one of the other two checks...
750- // http://clang.llvm.org/docs/LanguageExtensions.html#feature_check
751- #if defined(__clang__)
752- #if __has_feature(cxx_static_assert)
753- #if __has_feature(cxx_auto_type)
754- #define HAVE_CXX11
755- #endif // __has_feature(cxx_auto_type)
756- #endif // __has_feature(cxx_static_assert)
757- #endif // defined(__clang__)
758- // TODO: sort out cmake/gcc
759- #endif // HAVE_CXX11
760-
761- // In compilers before VS 2015, the noexcept keyword isn't defined. Nonetheless, we need to define it in VS 2015 and non-MS compilers.
762- #if defined(_MSC_VER) && _MSC_VER < 1900
763- # define NOEXCEPT
764- #else
765- # define NOEXCEPT noexcept
766- #endif
767-
768-
769626// DEBUG compile time catch for dangerous uses of memset/memcpy/memmove
770627// would prefer std::is_trivially_copyable but it's not supported by gcc yet
771628// ref: http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html
0 commit comments