summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/Common/Common.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/lzma/CPP/Common/Common.h')
-rw-r--r--3rdparty/lzma/CPP/Common/Common.h308
1 files changed, 304 insertions, 4 deletions
diff --git a/3rdparty/lzma/CPP/Common/Common.h b/3rdparty/lzma/CPP/Common/Common.h
index 9dd30f4bef2..0c77ab439f2 100644
--- a/3rdparty/lzma/CPP/Common/Common.h
+++ b/3rdparty/lzma/CPP/Common/Common.h
@@ -1,13 +1,313 @@
// Common.h
-#ifndef __COMMON_COMMON_H
-#define __COMMON_COMMON_H
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#pragma warning(disable : 4464) // relative include path contains '..'
+#endif
+
+#ifndef ZIP7_INC_COMMON_H
+#define ZIP7_INC_COMMON_H
#include "../../C/Compiler.h"
-#include "MyWindows.h"
+/*
+This file is included to all cpp files in 7-Zip.
+Each folder contains StdAfx.h file that includes "Common.h".
+So 7-Zip includes "Common.h" in both modes:
+ with precompiled StdAfx.h
+and
+ without precompiled StdAfx.h
+
+If you use 7-Zip code, you must include "Common.h" before other h files of 7-zip.
+If you don't need some things that are used in 7-Zip,
+you can change this h file or h files included in this file.
+*/
+
+#ifdef _MSC_VER
+ #pragma warning(disable : 4710) // function not inlined
+ // 'CUncopyable::CUncopyable':
+ #pragma warning(disable : 4514) // unreferenced inline function has been removed
+ #if _MSC_VER < 1300
+ #pragma warning(disable : 4702) // unreachable code
+ #pragma warning(disable : 4714) // function marked as __forceinline not inlined
+ #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
+ #endif
+ #if _MSC_VER < 1400
+ #pragma warning(disable : 4511) // copy constructor could not be generated // #pragma warning(disable : 4512) // assignment operator could not be generated
+ #pragma warning(disable : 4512) // assignment operator could not be generated
+ #endif
+ #if _MSC_VER > 1400 && _MSC_VER <= 1900
+ // #pragma warning(disable : 4996)
+ // strcat: This function or variable may be unsafe
+ // GetVersion was declared deprecated
+ #endif
+
+#if _MSC_VER > 1200
+// -Wall warnings
+
+#if _MSC_VER <= 1600
+#pragma warning(disable : 4917) // 'OLE_HANDLE' : a GUID can only be associated with a class, interface or namespace
+#endif
+
+// #pragma warning(disable : 4061) // enumerator '' in switch of enum '' is not explicitly handled by a case label
+// #pragma warning(disable : 4266) // no override available for virtual member function from base ''; function is hidden
+#pragma warning(disable : 4625) // copy constructor was implicitly defined as deleted
+#pragma warning(disable : 4626) // assignment operator was implicitly defined as deleted
+#if _MSC_VER >= 1600 && _MSC_VER < 1920
+#pragma warning(disable : 4571) // Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
+#endif
+#if _MSC_VER >= 1600
+#pragma warning(disable : 4365) // 'initializing' : conversion from 'int' to 'unsigned int', signed / unsigned mismatch
+#endif
+#if _MSC_VER < 1800
+// we disable the warning, if we don't use 'final' in class
+#pragma warning(disable : 4265) // class has virtual functions, but destructor is not virtual
+#endif
+
+#if _MSC_VER >= 1900
+#pragma warning(disable : 5026) // move constructor was implicitly defined as deleted
+#pragma warning(disable : 5027) // move assignment operator was implicitly defined as deleted
+#endif
+#if _MSC_VER >= 1912
+#pragma warning(disable : 5039) // pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception.
+#endif
+#if _MSC_VER >= 1925
+// #pragma warning(disable : 5204) // 'ISequentialInStream' : class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly
+#endif
+#if _MSC_VER >= 1934
+// #pragma warning(disable : 5264) // const variable is not used
+#endif
+
+#endif // _MSC_VER > 1200
+#endif // _MSC_VER
+
+
+#if defined(_MSC_VER) // && !defined(__clang__)
+#define Z7_DECLSPEC_NOTHROW __declspec(nothrow)
+#elif defined(__clang__) || defined(__GNUC__)
+#define Z7_DECLSPEC_NOTHROW __attribute__((nothrow))
+#else
+#define Z7_DECLSPEC_NOTHROW
+#endif
+
+/*
+#if defined (_MSC_VER) && _MSC_VER >= 1900 \
+ || defined(__clang__) && __clang_major__ >= 6 \
+ || defined(__GNUC__) && __GNUC__ >= 6
+ #define Z7_noexcept noexcept
+#else
+ #define Z7_noexcept throw()
+#endif
+*/
+
+
+#if defined(__clang__)
+
+// noexcept, final, = delete
+#pragma GCC diagnostic ignored "-Wc++98-compat"
+#if __clang_major__ >= 4
+// throw() dynamic exception specifications are deprecated
+#pragma GCC diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
+#endif
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#pragma GCC diagnostic ignored "-Wglobal-constructors"
+#pragma GCC diagnostic ignored "-Wexit-time-destructors"
+
+// #pragma GCC diagnostic ignored "-Wunused-private-field"
+// #pragma GCC diagnostic ignored "-Wnonportable-system-include-path"
+// #pragma GCC diagnostic ignored "-Wsuggest-override"
+// #pragma GCC diagnostic ignored "-Wsign-conversion"
+// #pragma GCC diagnostic ignored "-Winconsistent-missing-override"
+// #pragma GCC diagnostic ignored "-Wsuggest-destructor-override"
+// #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+// #pragma GCC diagnostic ignored "-Wdeprecated-copy-with-user-provided-dtor"
+// #pragma GCC diagnostic ignored "-Wdeprecated-copy-dtor"
+// #ifndef _WIN32
+// #pragma GCC diagnostic ignored "-Wweak-vtables"
+// #endif
+/*
+#if defined(Z7_GCC_VERSION) && (Z7_GCC_VERSION >= 40400) \
+ || defined(Z7_CLANG_VERSION) && (Z7_CLANG_VERSION >= 30000)
+// enumeration values not explicitly handled in switch
+#pragma GCC diagnostic ignored "-Wswitch-enum"
+#endif
+*/
+#endif // __clang__
+
+
+#ifdef __GNUC__
+// #pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
+#endif
+
+
+/* There is BUG in MSVC 6.0 compiler for operator new[]:
+ It doesn't check overflow, when it calculates size in bytes for allocated array.
+ So we can use Z7_ARRAY_NEW macro instead of new[] operator. */
+
+#if defined(_MSC_VER) && (_MSC_VER == 1200) && !defined(_WIN64)
+ #define Z7_ARRAY_NEW(p, T, size) p = new T[((size) > (unsigned)0xFFFFFFFF / sizeof(T)) ? (unsigned)0xFFFFFFFF / sizeof(T) : (size)];
+#else
+ #define Z7_ARRAY_NEW(p, T, size) p = new T[size];
+#endif
+
+#if (defined(__GNUC__) && (__GNUC__ >= 8))
+ #define Z7_ATTR_NORETURN __attribute__((noreturn))
+#elif (defined(__clang__) && (__clang_major__ >= 3))
+ #if __has_feature(cxx_attributes)
+ #define Z7_ATTR_NORETURN [[noreturn]]
+ #else
+ #define Z7_ATTR_NORETURN __attribute__((noreturn))
+ #endif
+#elif (defined(_MSC_VER) && (_MSC_VER >= 1900))
+ #define Z7_ATTR_NORETURN [[noreturn]]
+#else
+ #define Z7_ATTR_NORETURN
+#endif
+
+
+// final in "GCC 4.7.0"
+// In C++98 and C++03 code the alternative spelling __final can be used instead (this is a GCC extension.)
+
+#if defined (__cplusplus) && __cplusplus >= 201103L \
+ || defined(_MSC_VER) && _MSC_VER >= 1800 \
+ || defined(__clang__) && __clang_major__ >= 4 \
+ /* || defined(__GNUC__) && __GNUC__ >= 9 */
+ #define Z7_final final
+ #if defined(__clang__) && __cplusplus < 201103L
+ #pragma GCC diagnostic ignored "-Wc++11-extensions"
+ #endif
+#elif defined (__cplusplus) && __cplusplus >= 199711L \
+ && defined(__GNUC__) && __GNUC__ >= 4 && !defined(__clang__)
+ #define Z7_final __final
+#else
+ #define Z7_final
+ #if defined(__clang__) && __clang_major__ >= 4 \
+ || defined(__GNUC__) && __GNUC__ >= 4
+ #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+ #pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
+ #endif
+#endif
+
+#define Z7_class_final(c) class c Z7_final
+
+
+#if defined (__cplusplus) && __cplusplus >= 201103L \
+ || (defined(_MSC_VER) && _MSC_VER >= 1800)
+ #define Z7_CPP_IS_SUPPORTED_default
+ #define Z7_eq_delete = delete
+ // #define Z7_DECL_DEFAULT_COPY_CONSTRUCTOR_IF_SUPPORTED(c) c(const c& k) = default;
+#else
+ #define Z7_eq_delete
+ // #define Z7_DECL_DEFAULT_COPY_CONSTRUCTOR_IF_SUPPORTED(c)
+#endif
+
+
+#if defined(__cplusplus) && (__cplusplus >= 201103L) \
+ || defined(_MSC_VER) && (_MSC_VER >= 1400) /* && (_MSC_VER != 1600) */ \
+ || defined(__clang__) && __clang_major__ >= 4
+ #if defined(_MSC_VER) && (_MSC_VER == 1600) /* && (_MSC_VER != 1600) */
+ #pragma warning(disable : 4481) // nonstandard extension used: override specifier 'override'
+ #define Z7_DESTRUCTOR_override
+ #else
+ #define Z7_DESTRUCTOR_override override
+ #endif
+ #define Z7_override override
+#else
+ #define Z7_override
+ #define Z7_DESTRUCTOR_override
+#endif
+
+
+
+#define Z7_CLASS_NO_COPY(cls) \
+ private: \
+ cls(const cls &) Z7_eq_delete; \
+ cls &operator=(const cls &) Z7_eq_delete;
+
+class CUncopyable
+{
+protected:
+ CUncopyable() {} // allow constructor
+ // ~CUncopyable() {}
+ Z7_CLASS_NO_COPY(CUncopyable)
+};
+
+#define MY_UNCOPYABLE :private CUncopyable
+// #define MY_UNCOPYABLE
+
+
+typedef void (*Z7_void_Function)(void);
+
+#if defined(__clang__) || defined(__GNUC__)
+#define Z7_CAST_FUNC(t, e) reinterpret_cast<t>(reinterpret_cast<Z7_void_Function>(e))
+#else
+#define Z7_CAST_FUNC(t, e) reinterpret_cast<t>(reinterpret_cast<void*>(e))
+// #define Z7_CAST_FUNC(t, e) reinterpret_cast<t>(e)
+#endif
+
+#define Z7_GET_PROC_ADDRESS(func_type, hmodule, func_name) \
+ Z7_CAST_FUNC(func_type, GetProcAddress(hmodule, func_name))
+
+// || defined(__clang__)
+// || defined(__GNUC__)
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#define Z7_DECLSPEC_NOVTABLE __declspec(novtable)
+#else
+#define Z7_DECLSPEC_NOVTABLE
+#endif
+
+#ifdef __clang__
+#define Z7_PURE_INTERFACES_BEGIN \
+_Pragma("GCC diagnostic push") \
+_Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"")
+_Pragma("GCC diagnostic ignored \"-Wweak-vtables\"")
+#define Z7_PURE_INTERFACES_END \
+_Pragma("GCC diagnostic pop")
+#else
+#define Z7_PURE_INTERFACES_BEGIN
+#define Z7_PURE_INTERFACES_END
+#endif
+
+// NewHandler.h and NewHandler.cpp redefine operator new() to throw exceptions, if compiled with old MSVC compilers
#include "NewHandler.h"
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[1]))
+/*
+// #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) Z7_ARRAY_SIZE(a)
+#endif
+*/
+
+#endif // ZIP7_INC_COMMON_H
+
+
+// #define Z7_REDEFINE_NULL
+
+#if defined(Z7_REDEFINE_NULL) /* && (!defined(__clang__) || defined(_MSC_VER)) */
+
+// NULL is defined in <stddef.h>
+#include <stddef.h>
+#undef NULL
+
+#ifdef __cplusplus
+ #if defined (__cplusplus) && __cplusplus >= 201103L \
+ || (defined(_MSC_VER) && _MSC_VER >= 1800)
+ #define NULL nullptr
+ #else
+ #define NULL 0
+ #endif
+#else
+ #define NULL ((void *)0)
#endif
+
+#else // Z7_REDEFINE_NULL
+
+#if defined(__clang__) && __clang_major__ >= 5
+#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
+#endif
+
+#endif // Z7_REDEFINE_NULL
+
+// for precompiler:
+#include "MyWindows.h"