diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e9dd44..81c928c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,7 +258,8 @@ set(ASMJIT_SRC_LIST asmjit/asmjit.h asmjit/core.h - asmjit/core/build.h + asmjit/core/api-build_p.h + asmjit/core/api-config.h asmjit/core/arch.cpp asmjit/core/arch.h asmjit/core/assembler.cpp diff --git a/README.md b/README.md index 47de201..60d0f02 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ Supported Environments * **Clang** - tested by Travis-CI - Clang 3.9+ (with C++11 enabled) is officially supported (older Clang versions having C++11 support are probably fine, but are not regularly tested). * **GNU** - tested by Travis-CI - GCC 4.8+ (with C++11 enabled) is officially supported. * **MINGW** - tested by Travis-CI - Use the latest version, if possible. - * **MSVC** - tested by Travis-CI - VS2017+ is officially supported, VC2015 is reported to work. + * **MSVC** - tested by Travis-CI - VS2017+ is officially supported, VS2015 is reported to work. * Untested: * **Intel** - no maintainers and no CI environment to regularly test this compiler. * Other c++ compilers would require basic support in [core/build.h](./src/asmjit/core/build.h). diff --git a/src/asmjit/core/api-build_p.h b/src/asmjit/core/api-build_p.h new file mode 100644 index 0000000..f1fcd50 --- /dev/null +++ b/src/asmjit/core/api-build_p.h @@ -0,0 +1,25 @@ +// [AsmJit] +// Machine Code Generation for C++. +// +// [License] +// Zlib - See LICENSE.md file in the package. + +#ifndef _ASMJIT_CORE_API_BUILD_P_H +#define _ASMJIT_CORE_API_BUILD_P_H + +#define ASMJIT_EXPORTS + +// Dependencies only required for asmjit build, but never exposed through public headers. +#ifdef _WIN32 + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN + #endif + #ifndef NOMINMAX + #define NOMINMAX + #endif + #include +#endif + +#include "./api-config.h" + +#endif // _ASMJIT_CORE_API_BUILD_P_H diff --git a/src/asmjit/core/build.h b/src/asmjit/core/api-config.h similarity index 97% rename from src/asmjit/core/build.h rename to src/asmjit/core/api-config.h index 74c1413..8b4a0d7 100644 --- a/src/asmjit/core/build.h +++ b/src/asmjit/core/api-config.h @@ -4,8 +4,8 @@ // [License] // Zlib - See LICENSE.md file in the package. -#ifndef _ASMJIT_CORE_BUILD_H -#define _ASMJIT_CORE_BUILD_H +#ifndef _ASMJIT_CORE_API_CONFIG_H +#define _ASMJIT_CORE_API_CONFIG_H // ============================================================================ // [asmjit::Version] @@ -96,25 +96,7 @@ #include #include -#if defined(_WIN32) - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #define ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN - #endif - #ifndef NOMINMAX - #define NOMINMAX - #define ASMJIT_UNDEF_NOMINMAX - #endif - #include - #ifdef ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN - #undef WIN32_LEAN_AND_MEAN - #undef ASMJIT_UNDEF_WIN32_LEAN_AND_MEAN - #endif - #ifdef ASMJIT_UNDEF_NOMINMAX - #undef NOMINMAX - #undef ASMJIT_UNDEF_NOMINMAX - #endif -#else +#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) #include #endif @@ -316,13 +298,13 @@ // API (Export / Import). #if !defined(ASMJIT_STATIC) #if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__)) - #if defined(ASMJIT_EXPORTS) + #ifdef ASMJIT_EXPORTS #define ASMJIT_API __declspec(dllexport) #else #define ASMJIT_API __declspec(dllimport) #endif #elif defined(_WIN32) && defined(__GNUC__) - #if defined(ASMJIT_EXPORTS) + #ifdef ASMJIT_EXPORTS #define ASMJIT_API __attribute__((__dllexport__)) #else #define ASMJIT_API __attribute__((__dllimport__)) @@ -399,6 +381,12 @@ #define ASMJIT_ALIGN_TYPE(TYPE, N) TYPE #endif +#if defined(__GNUC__) + #define ASMJIT_MAY_ALIAS __attribute__((__may_alias__)) +#else + #define ASMJIT_MAY_ALIAS +#endif + // Annotations. #if defined(__GNUC__) #define ASMJIT_LIKELY(...) __builtin_expect(!!(__VA_ARGS__), 1) @@ -563,4 +551,4 @@ #include "../../../test/broken.h" #endif -#endif // _ASMJIT_CORE_BUILD_H +#endif // _ASMJIT_CORE_API_CONFIG_H diff --git a/src/asmjit/core/arch.cpp b/src/asmjit/core/arch.cpp index 0f94a53..0eabbaf 100644 --- a/src/asmjit/core/arch.cpp +++ b/src/asmjit/core/arch.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/arch.h" #include "../core/support.h" #include "../core/type.h" diff --git a/src/asmjit/core/assembler.cpp b/src/asmjit/core/assembler.cpp index ce2f262..8590f09 100644 --- a/src/asmjit/core/assembler.cpp +++ b/src/asmjit/core/assembler.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/assembler.h" #include "../core/codebufferwriter_p.h" #include "../core/constpool.h" diff --git a/src/asmjit/core/builder.cpp b/src/asmjit/core/builder.cpp index 541d053..5008f25 100644 --- a/src/asmjit/core/builder.cpp +++ b/src/asmjit/core/builder.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_BUILDER #include "../core/builder.h" diff --git a/src/asmjit/core/builder.h b/src/asmjit/core/builder.h index 5087ec6..aaf6bf8 100644 --- a/src/asmjit/core/builder.h +++ b/src/asmjit/core/builder.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_BUILDER_H #define _ASMJIT_CORE_BUILDER_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_BUILDER #include "../core/assembler.h" diff --git a/src/asmjit/core/callconv.cpp b/src/asmjit/core/callconv.cpp index b9d6d65..3872f91 100644 --- a/src/asmjit/core/callconv.cpp +++ b/src/asmjit/core/callconv.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/arch.h" #include "../core/func.h" #include "../core/type.h" diff --git a/src/asmjit/core/codeholder.cpp b/src/asmjit/core/codeholder.cpp index 4f98d88..d662dfd 100644 --- a/src/asmjit/core/codeholder.cpp +++ b/src/asmjit/core/codeholder.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/assembler.h" #include "../core/logging.h" #include "../core/support.h" diff --git a/src/asmjit/core/compiler.cpp b/src/asmjit/core/compiler.cpp index 4c31fdb..5b7e0db 100644 --- a/src/asmjit/core/compiler.cpp +++ b/src/asmjit/core/compiler.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_COMPILER #include "../core/assembler.h" diff --git a/src/asmjit/core/compiler.h b/src/asmjit/core/compiler.h index 67229a8..0447345 100644 --- a/src/asmjit/core/compiler.h +++ b/src/asmjit/core/compiler.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_COMPILER_H #define _ASMJIT_CORE_COMPILER_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/assembler.h" diff --git a/src/asmjit/core/constpool.cpp b/src/asmjit/core/constpool.cpp index 0d1cdb8..84f3c32 100644 --- a/src/asmjit/core/constpool.cpp +++ b/src/asmjit/core/constpool.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/constpool.h" #include "../core/support.h" diff --git a/src/asmjit/core/cpuinfo.cpp b/src/asmjit/core/cpuinfo.cpp index 3f41576..1c0f2cf 100644 --- a/src/asmjit/core/cpuinfo.cpp +++ b/src/asmjit/core/cpuinfo.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/cpuinfo.h" #if !defined(_WIN32) diff --git a/src/asmjit/core/emitter.cpp b/src/asmjit/core/emitter.cpp index f319020..878d47b 100644 --- a/src/asmjit/core/emitter.cpp +++ b/src/asmjit/core/emitter.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/logging.h" #include "../core/support.h" diff --git a/src/asmjit/core/func.cpp b/src/asmjit/core/func.cpp index 248b291..4a117de 100644 --- a/src/asmjit/core/func.cpp +++ b/src/asmjit/core/func.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/arch.h" #include "../core/func.h" #include "../core/type.h" diff --git a/src/asmjit/core/globals.cpp b/src/asmjit/core/globals.cpp index 5a16de4..cbfd231 100644 --- a/src/asmjit/core/globals.cpp +++ b/src/asmjit/core/globals.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/globals.h" #include "../core/support.h" diff --git a/src/asmjit/core/globals.h b/src/asmjit/core/globals.h index f03ede5..bef57e0 100644 --- a/src/asmjit/core/globals.h +++ b/src/asmjit/core/globals.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_GLOBALS_H #define _ASMJIT_CORE_GLOBALS_H -#include "../core/build.h" +#include "../core/api-config.h" ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/inst.cpp b/src/asmjit/core/inst.cpp index f5a2bf9..cdc147e 100644 --- a/src/asmjit/core/inst.cpp +++ b/src/asmjit/core/inst.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifdef ASMJIT_BUILD_X86 #include "../core/arch.h" diff --git a/src/asmjit/core/jitallocator.cpp b/src/asmjit/core/jitallocator.cpp index d8139d1..c1f0529 100644 --- a/src/asmjit/core/jitallocator.cpp +++ b/src/asmjit/core/jitallocator.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_JIT #include "../core/arch.h" @@ -601,7 +599,7 @@ JitAllocator::Statistics JitAllocator::statistics() const noexcept { if (ASMJIT_LIKELY(_impl != &JitAllocatorImpl_none)) { JitAllocatorPrivateImpl* impl = static_cast(_impl); - ScopedLock locked(impl->lock); + LockGuard guard(impl->lock); size_t poolCount = impl->poolCount; for (size_t poolId = 0; poolId < poolCount; poolId++) { @@ -638,7 +636,7 @@ Error JitAllocator::alloc(void** roPtrOut, void** rwPtrOut, size_t size) noexcep if (ASMJIT_UNLIKELY(size > std::numeric_limits::max() / 2)) return DebugUtils::errored(kErrorTooLarge); - ScopedLock locked(impl->lock); + LockGuard guard(impl->lock); JitAllocatorPool* pool = &impl->pools[JitAllocatorImpl_sizeToPoolId(impl, size)]; uint32_t areaIndex = kNoIndex; @@ -763,7 +761,7 @@ Error JitAllocator::release(void* ro) noexcept { return DebugUtils::errored(kErrorInvalidArgument); JitAllocatorPrivateImpl* impl = static_cast(_impl); - ScopedLock locked(impl->lock); + LockGuard guard(impl->lock); JitAllocatorBlock* block = impl->tree.get(static_cast(ro)); if (ASMJIT_UNLIKELY(!block)) @@ -822,7 +820,7 @@ Error JitAllocator::shrink(void* ro, size_t newSize) noexcept { return release(ro); JitAllocatorPrivateImpl* impl = static_cast(_impl); - ScopedLock locked(impl->lock); + LockGuard guard(impl->lock); JitAllocatorBlock* block = impl->tree.get(static_cast(ro)); if (ASMJIT_UNLIKELY(!block)) diff --git a/src/asmjit/core/jitallocator.h b/src/asmjit/core/jitallocator.h index e5531f8..4aa83b4 100644 --- a/src/asmjit/core/jitallocator.h +++ b/src/asmjit/core/jitallocator.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_JITALLOCATOR_H #define _ASMJIT_CORE_JITALLOCATOR_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_JIT #include "../core/globals.h" diff --git a/src/asmjit/core/jitruntime.cpp b/src/asmjit/core/jitruntime.cpp index f8d23c9..c3fd1e8 100644 --- a/src/asmjit/core/jitruntime.cpp +++ b/src/asmjit/core/jitruntime.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_JIT #include "../core/cpuinfo.h" diff --git a/src/asmjit/core/jitruntime.h b/src/asmjit/core/jitruntime.h index 242d1bb..7a1798e 100644 --- a/src/asmjit/core/jitruntime.h +++ b/src/asmjit/core/jitruntime.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_JITRUNTIME_H #define _ASMJIT_CORE_JITRUNTIME_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_JIT #include "../core/codeholder.h" diff --git a/src/asmjit/core/logging.cpp b/src/asmjit/core/logging.cpp index 6039a47..6238deb 100644 --- a/src/asmjit/core/logging.cpp +++ b/src/asmjit/core/logging.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_LOGGING #include "../core/builder.h" diff --git a/src/asmjit/core/logging.h b/src/asmjit/core/logging.h index 16e8b97..9a4c048 100644 --- a/src/asmjit/core/logging.h +++ b/src/asmjit/core/logging.h @@ -316,7 +316,7 @@ struct Logging { #endif // Only used by AsmJit internals, not available to users. - #if defined(ASMJIT_EXPORTS) + #ifdef ASMJIT_EXPORTS enum { // Has to be big to be able to hold all metadata compiler can assign to a // single instruction. diff --git a/src/asmjit/core/misc_p.h b/src/asmjit/core/misc_p.h index f8548f1..a23830a 100644 --- a/src/asmjit/core/misc_p.h +++ b/src/asmjit/core/misc_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_MISC_P_H #define _ASMJIT_CORE_MISC_P_H -#include "../core/build.h" +#include "../core/api-config.h" ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/operand.cpp b/src/asmjit/core/operand.cpp index 36f0c6f..92fba59 100644 --- a/src/asmjit/core/operand.cpp +++ b/src/asmjit/core/operand.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/operand.h" ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/osutils.cpp b/src/asmjit/core/osutils.cpp index 3115101..c62ef8b 100644 --- a/src/asmjit/core/osutils.cpp +++ b/src/asmjit/core/osutils.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/osutils.h" #include "../core/support.h" diff --git a/src/asmjit/core/osutils.h b/src/asmjit/core/osutils.h index 4b82231..887bef7 100644 --- a/src/asmjit/core/osutils.h +++ b/src/asmjit/core/osutils.h @@ -31,63 +31,89 @@ namespace OSUtils { //! \cond INTERNAL //! Lock. +//! +//! Lock is internal, it cannot be used outside of AsmJit, however, its internal +//! layout is exposed as it's used by some other public classes. class Lock { public: ASMJIT_NONCOPYABLE(Lock) - #if defined(_WIN32) - - typedef CRITICAL_SECTION Handle; +#if defined(_WIN32) +#pragma pack(push, 8) + struct ASMJIT_MAY_ALIAS Handle { + void* DebugInfo; + long LockCount; + long RecursionCount; + void* OwningThread; + void* LockSemaphore; + unsigned long* SpinCount; + }; Handle _handle; - - inline Lock() noexcept { InitializeCriticalSection(&_handle); } - inline ~Lock() noexcept { DeleteCriticalSection(&_handle); } - - inline void lock() noexcept { EnterCriticalSection(&_handle); } - inline void unlock() noexcept { LeaveCriticalSection(&_handle); } - - #elif !defined(__EMSCRIPTEN__) - +#pragma pack(pop) +#elif !defined(__EMSCRIPTEN__) typedef pthread_mutex_t Handle; Handle _handle; +#endif - inline Lock() noexcept { pthread_mutex_init(&_handle, nullptr); } - inline ~Lock() noexcept { pthread_mutex_destroy(&_handle); } + inline Lock() noexcept; + inline ~Lock() noexcept; - inline void lock() noexcept { pthread_mutex_lock(&_handle); } - inline void unlock() noexcept { pthread_mutex_unlock(&_handle); } - - #else - - // Browser or other unsupported OS. - inline Lock() noexcept {} - inline ~Lock() noexcept {} - - inline void lock() noexcept {} - inline void unlock() noexcept {} - - #endif + inline void lock() noexcept; + inline void unlock() noexcept; }; +#ifdef ASMJIT_EXPORTS +#if defined(_WIN32) + +// Win32 implementation. +static_assert(sizeof(Lock::Handle) == sizeof(CRITICAL_SECTION), "asmjit::Lock::Handle layout must match CRITICAL_SECTION"); +static_assert(alignof(Lock::Handle) == alignof(CRITICAL_SECTION), "asmjit::Lock::Handle alignment must match CRITICAL_SECTION"); + +inline Lock::Lock() noexcept { InitializeCriticalSection(reinterpret_cast(&_handle)); } +inline Lock::~Lock() noexcept { DeleteCriticalSection(reinterpret_cast(&_handle)); } +inline void Lock::lock() noexcept { EnterCriticalSection(reinterpret_cast(&_handle)); } +inline void Lock::unlock() noexcept { LeaveCriticalSection(reinterpret_cast(&_handle)); } + +#elif !defined(__EMSCRIPTEN__) + +// PThread implementation. +inline Lock::Lock() noexcept { pthread_mutex_init(&_handle, nullptr); } +inline Lock::~Lock() noexcept { pthread_mutex_destroy(&_handle); } +inline void Lock::lock() noexcept { pthread_mutex_lock(&_handle); } +inline void Lock::unlock() noexcept { pthread_mutex_unlock(&_handle); } + +#else + +// Dummy implementation - Emscripten or other unsupported platform. +inline Lock::Lock() noexcept {} +inline Lock::~Lock() noexcept {} +inline void Lock::lock() noexcept {} +inline void Lock::unlock() noexcept {} + +#endif +#endif + //! \endcond // ============================================================================ -// [asmjit::ScopedLock] +// [asmjit::LockGuard] // ============================================================================ +#ifdef ASMJIT_EXPORTS //! \cond INTERNAL //! Scoped lock. -struct ScopedLock { - ASMJIT_NONCOPYABLE(ScopedLock) +struct LockGuard { + ASMJIT_NONCOPYABLE(LockGuard) Lock& _target; - inline ScopedLock(Lock& target) noexcept : _target(target) { _target.lock(); } - inline ~ScopedLock() noexcept { _target.unlock(); } + inline LockGuard(Lock& target) noexcept : _target(target) { _target.lock(); } + inline ~LockGuard() noexcept { _target.unlock(); } }; //! \endcond +#endif //! \} diff --git a/src/asmjit/core/raassignment_p.h b/src/asmjit/core/raassignment_p.h index 664e899..1ca0df4 100644 --- a/src/asmjit/core/raassignment_p.h +++ b/src/asmjit/core/raassignment_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_RAASSIGNMENT_P_H #define _ASMJIT_CORE_RAASSIGNMENT_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/radefs_p.h" diff --git a/src/asmjit/core/rabuilders_p.h b/src/asmjit/core/rabuilders_p.h index cb1eac8..2b5e8af 100644 --- a/src/asmjit/core/rabuilders_p.h +++ b/src/asmjit/core/rabuilders_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_RABUILDERS_P_H #define _ASMJIT_CORE_RABUILDERS_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/rapass_p.h" diff --git a/src/asmjit/core/radefs_p.h b/src/asmjit/core/radefs_p.h index 484bb7a..a7b146d 100644 --- a/src/asmjit/core/radefs_p.h +++ b/src/asmjit/core/radefs_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_RADEFS_P_H #define _ASMJIT_CORE_RADEFS_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/compiler.h" diff --git a/src/asmjit/core/ralocal.cpp b/src/asmjit/core/ralocal.cpp index b803148..1c5008d 100644 --- a/src/asmjit/core/ralocal.cpp +++ b/src/asmjit/core/ralocal.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_COMPILER #include "../core/ralocal_p.h" diff --git a/src/asmjit/core/ralocal_p.h b/src/asmjit/core/ralocal_p.h index 36e6a30..d06f228 100644 --- a/src/asmjit/core/ralocal_p.h +++ b/src/asmjit/core/ralocal_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_RALOCAL_P_H #define _ASMJIT_CORE_RALOCAL_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/raassignment_p.h" diff --git a/src/asmjit/core/rapass.cpp b/src/asmjit/core/rapass.cpp index 7d02168..0c0ea73 100644 --- a/src/asmjit/core/rapass.cpp +++ b/src/asmjit/core/rapass.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_COMPILER #include "../core/ralocal_p.h" diff --git a/src/asmjit/core/rapass_p.h b/src/asmjit/core/rapass_p.h index e873bd7..0fba4a1 100644 --- a/src/asmjit/core/rapass_p.h +++ b/src/asmjit/core/rapass_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_RAPASS_P_H #define _ASMJIT_CORE_RAPASS_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/raassignment_p.h" diff --git a/src/asmjit/core/rastack.cpp b/src/asmjit/core/rastack.cpp index dd035b9..3652ae7 100644 --- a/src/asmjit/core/rastack.cpp +++ b/src/asmjit/core/rastack.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_COMPILER #include "../core/rastack_p.h" diff --git a/src/asmjit/core/rastack_p.h b/src/asmjit/core/rastack_p.h index 96276b3..4f8cf22 100644 --- a/src/asmjit/core/rastack_p.h +++ b/src/asmjit/core/rastack_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_RASTACK_P_H #define _ASMJIT_CORE_RASTACK_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/radefs_p.h" diff --git a/src/asmjit/core/string.cpp b/src/asmjit/core/string.cpp index da2fa05..3963223 100644 --- a/src/asmjit/core/string.cpp +++ b/src/asmjit/core/string.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/string.h" #include "../core/support.h" diff --git a/src/asmjit/core/support.cpp b/src/asmjit/core/support.cpp index 77d11f9..fb0557c 100644 --- a/src/asmjit/core/support.cpp +++ b/src/asmjit/core/support.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/support.h" ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/target.cpp b/src/asmjit/core/target.cpp index 4bdbc84..87b6573 100644 --- a/src/asmjit/core/target.cpp +++ b/src/asmjit/core/target.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/target.h" ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/type.cpp b/src/asmjit/core/type.cpp index 018af39..7f195ed 100644 --- a/src/asmjit/core/type.cpp +++ b/src/asmjit/core/type.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/misc_p.h" #include "../core/type.h" diff --git a/src/asmjit/core/virtmem.cpp b/src/asmjit/core/virtmem.cpp index c19799f..ee40b28 100644 --- a/src/asmjit/core/virtmem.cpp +++ b/src/asmjit/core/virtmem.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_JIT #include "../core/osutils.h" diff --git a/src/asmjit/core/virtmem.h b/src/asmjit/core/virtmem.h index 8ff2427..7174c96 100644 --- a/src/asmjit/core/virtmem.h +++ b/src/asmjit/core/virtmem.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_CORE_VIRTMEM_H #define _ASMJIT_CORE_VIRTMEM_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_JIT #include "../core/globals.h" diff --git a/src/asmjit/core/zone.cpp b/src/asmjit/core/zone.cpp index 105d214..58204bd 100644 --- a/src/asmjit/core/zone.cpp +++ b/src/asmjit/core/zone.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/support.h" #include "../core/zone.h" diff --git a/src/asmjit/core/zonehash.cpp b/src/asmjit/core/zonehash.cpp index 54fb328..d6b0662 100644 --- a/src/asmjit/core/zonehash.cpp +++ b/src/asmjit/core/zonehash.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/support.h" #include "../core/zone.h" #include "../core/zonehash.h" diff --git a/src/asmjit/core/zonelist.cpp b/src/asmjit/core/zonelist.cpp index 557feb8..2f8e427 100644 --- a/src/asmjit/core/zonelist.cpp +++ b/src/asmjit/core/zonelist.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/zone.h" #include "../core/zonelist.h" diff --git a/src/asmjit/core/zonestack.cpp b/src/asmjit/core/zonestack.cpp index d11e92a..11937f1 100644 --- a/src/asmjit/core/zonestack.cpp +++ b/src/asmjit/core/zonestack.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/zone.h" #include "../core/zonestack.h" diff --git a/src/asmjit/core/zonetree.cpp b/src/asmjit/core/zonetree.cpp index 95237fb..55a85ed 100644 --- a/src/asmjit/core/zonetree.cpp +++ b/src/asmjit/core/zonetree.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/support.h" #include "../core/zone.h" #include "../core/zonetree.h" diff --git a/src/asmjit/core/zonevector.cpp b/src/asmjit/core/zonevector.cpp index 29c4c2d..c942847 100644 --- a/src/asmjit/core/zonevector.cpp +++ b/src/asmjit/core/zonevector.cpp @@ -4,8 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - +#include "../core/api-build_p.h" #include "../core/support.h" #include "../core/zone.h" #include "../core/zonevector.h" diff --git a/src/asmjit/x86/x86assembler.cpp b/src/asmjit/x86/x86assembler.cpp index ee76a25..3be3a4d 100644 --- a/src/asmjit/x86/x86assembler.cpp +++ b/src/asmjit/x86/x86assembler.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifdef ASMJIT_BUILD_X86 #include "../core/codebufferwriter_p.h" diff --git a/src/asmjit/x86/x86builder.cpp b/src/asmjit/x86/x86builder.cpp index 448dd04..a2f2747 100644 --- a/src/asmjit/x86/x86builder.cpp +++ b/src/asmjit/x86/x86builder.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER) #include "../x86/x86assembler.h" diff --git a/src/asmjit/x86/x86builder.h b/src/asmjit/x86/x86builder.h index 6640dff..9426389 100644 --- a/src/asmjit/x86/x86builder.h +++ b/src/asmjit/x86/x86builder.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_X86_X86BUILDER_H #define _ASMJIT_X86_X86BUILDER_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_BUILDER #include "../core/builder.h" diff --git a/src/asmjit/x86/x86callconv.cpp b/src/asmjit/x86/x86callconv.cpp index c4db9a8..4f70eb6 100644 --- a/src/asmjit/x86/x86callconv.cpp +++ b/src/asmjit/x86/x86callconv.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifdef ASMJIT_BUILD_X86 #include "../x86/x86callconv_p.h" diff --git a/src/asmjit/x86/x86compiler.cpp b/src/asmjit/x86/x86compiler.cpp index ac7a7f3..cd5deb9 100644 --- a/src/asmjit/x86/x86compiler.cpp +++ b/src/asmjit/x86/x86compiler.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER) #include "../x86/x86assembler.h" diff --git a/src/asmjit/x86/x86compiler.h b/src/asmjit/x86/x86compiler.h index 098cb99..4f3519d 100644 --- a/src/asmjit/x86/x86compiler.h +++ b/src/asmjit/x86/x86compiler.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_X86_X86COMPILER_H #define _ASMJIT_X86_X86COMPILER_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/compiler.h" diff --git a/src/asmjit/x86/x86features.cpp b/src/asmjit/x86/x86features.cpp index 5069134..dc01d87 100644 --- a/src/asmjit/x86/x86features.cpp +++ b/src/asmjit/x86/x86features.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #if defined(ASMJIT_BUILD_X86) && ASMJIT_ARCH_X86 #include "../core/cpuinfo.h" diff --git a/src/asmjit/x86/x86instapi.cpp b/src/asmjit/x86/x86instapi.cpp index 6b170dc..c344609 100644 --- a/src/asmjit/x86/x86instapi.cpp +++ b/src/asmjit/x86/x86instapi.cpp @@ -22,9 +22,7 @@ // (including registers and flags), and all indexes to all tables. // ---------------------------------------------------------------------------- -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifdef ASMJIT_BUILD_X86 #include "../core/cpuinfo.h" diff --git a/src/asmjit/x86/x86instdb.cpp b/src/asmjit/x86/x86instdb.cpp index 0152314..f0f4312 100644 --- a/src/asmjit/x86/x86instdb.cpp +++ b/src/asmjit/x86/x86instdb.cpp @@ -22,9 +22,7 @@ // (including registers and flags), and all indexes to all tables. // ---------------------------------------------------------------------------- -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifdef ASMJIT_BUILD_X86 #include "../core/cpuinfo.h" diff --git a/src/asmjit/x86/x86internal.cpp b/src/asmjit/x86/x86internal.cpp index 1361782..7f22530 100644 --- a/src/asmjit/x86/x86internal.cpp +++ b/src/asmjit/x86/x86internal.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifdef ASMJIT_BUILD_X86 #include "../core/logging.h" diff --git a/src/asmjit/x86/x86internal_p.h b/src/asmjit/x86/x86internal_p.h index 0218064..8b50f2b 100644 --- a/src/asmjit/x86/x86internal_p.h +++ b/src/asmjit/x86/x86internal_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_X86_X86INTERNAL_P_H #define _ASMJIT_X86_X86INTERNAL_P_H -#include "../core/build.h" +#include "../core/api-config.h" #include "../core/func.h" #include "../x86/x86emitter.h" diff --git a/src/asmjit/x86/x86logging.cpp b/src/asmjit/x86/x86logging.cpp index 80ae853..5f38e94 100644 --- a/src/asmjit/x86/x86logging.cpp +++ b/src/asmjit/x86/x86logging.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifndef ASMJIT_NO_LOGGING #include "../core/misc_p.h" diff --git a/src/asmjit/x86/x86logging_p.h b/src/asmjit/x86/x86logging_p.h index e104425..897d235 100644 --- a/src/asmjit/x86/x86logging_p.h +++ b/src/asmjit/x86/x86logging_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_X86_X86LOGGING_P_H #define _ASMJIT_X86_X86LOGGING_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_LOGGING #include "../core/logging.h" diff --git a/src/asmjit/x86/x86operand.cpp b/src/asmjit/x86/x86operand.cpp index 3e64494..99c0c2d 100644 --- a/src/asmjit/x86/x86operand.cpp +++ b/src/asmjit/x86/x86operand.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #ifdef ASMJIT_BUILD_X86 #include "../core/misc_p.h" diff --git a/src/asmjit/x86/x86rapass.cpp b/src/asmjit/x86/x86rapass.cpp index 4e4c052..30bdc86 100644 --- a/src/asmjit/x86/x86rapass.cpp +++ b/src/asmjit/x86/x86rapass.cpp @@ -4,9 +4,7 @@ // [License] // Zlib - See LICENSE.md file in the package. -#define ASMJIT_EXPORTS - -#include "../core/build.h" +#include "../core/api-build_p.h" #if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER) #include "../core/cpuinfo.h" diff --git a/src/asmjit/x86/x86rapass_p.h b/src/asmjit/x86/x86rapass_p.h index f8df94c..ccc4169 100644 --- a/src/asmjit/x86/x86rapass_p.h +++ b/src/asmjit/x86/x86rapass_p.h @@ -7,7 +7,7 @@ #ifndef _ASMJIT_X86_X86RAPASS_P_H #define _ASMJIT_X86_X86RAPASS_P_H -#include "../core/build.h" +#include "../core/api-config.h" #ifndef ASMJIT_NO_COMPILER #include "../core/compiler.h" diff --git a/test/asmjit_test_x86_cc.cpp b/test/asmjit_test_x86_cc.cpp index 6fb144e..6617c7d 100644 --- a/test/asmjit_test_x86_cc.cpp +++ b/test/asmjit_test_x86_cc.cpp @@ -12,6 +12,11 @@ #include "./asmjit.h" #include "./asmjit_test_misc.h" +#ifdef _MSC_VER +// Interaction between '_setjmp' and C++ object destruction is non-portable. +#pragma warning(disable: 4611) +#endif + using namespace asmjit; // ============================================================================ @@ -174,10 +179,11 @@ int X86TestApp::run() { x86::Compiler cc(&code); test->compile(cc); + void* func = nullptr; Error err = errorHandler._err; + if (!err) err = cc.finalize(); - void* func; #ifndef ASMJIT_NO_LOGGING if (_dumpAsm) { diff --git a/test/asmjit_test_x86_sections.cpp b/test/asmjit_test_x86_sections.cpp index a60b763..e94742b 100644 --- a/test/asmjit_test_x86_sections.cpp +++ b/test/asmjit_test_x86_sections.cpp @@ -48,8 +48,8 @@ int main(int argc, char* argv[]) { code.init(codeInfo); code.setLogger(&logger); - Section* section; - Error err = code.newSection(§ion, ".data", SIZE_MAX, 0, 8); + Section* dataSection; + Error err = code.newSection(&dataSection, ".data", SIZE_MAX, 0, 8); if (err) { fail("Failed to create a .data section", err); @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) { a.emitEpilog(frame); - a.section(section); + a.section(dataSection); a.bind(data); a.embed(dataArray, sizeof(dataArray));