Improved AsmJit public API to not depend on <windows.h> header

This commit is contained in:
kobalicek
2020-04-29 10:22:26 +02:00
parent 13367b59c2
commit 9057aa30b6
68 changed files with 173 additions and 190 deletions

View File

@@ -258,7 +258,8 @@ set(ASMJIT_SRC_LIST
asmjit/asmjit.h asmjit/asmjit.h
asmjit/core.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.cpp
asmjit/core/arch.h asmjit/core/arch.h
asmjit/core/assembler.cpp asmjit/core/assembler.cpp

View File

@@ -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). * **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. * **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. * **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: * Untested:
* **Intel** - no maintainers and no CI environment to regularly test this compiler. * **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). * Other c++ compilers would require basic support in [core/build.h](./src/asmjit/core/build.h).

View File

@@ -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 <windows.h>
#endif
#include "./api-config.h"
#endif // _ASMJIT_CORE_API_BUILD_P_H

View File

@@ -4,8 +4,8 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#ifndef _ASMJIT_CORE_BUILD_H #ifndef _ASMJIT_CORE_API_CONFIG_H
#define _ASMJIT_CORE_BUILD_H #define _ASMJIT_CORE_API_CONFIG_H
// ============================================================================ // ============================================================================
// [asmjit::Version] // [asmjit::Version]
@@ -96,25 +96,7 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#if defined(_WIN32) #if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
#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 <windows.h>
#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
#include <pthread.h> #include <pthread.h>
#endif #endif
@@ -316,13 +298,13 @@
// API (Export / Import). // API (Export / Import).
#if !defined(ASMJIT_STATIC) #if !defined(ASMJIT_STATIC)
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__)) #if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))
#if defined(ASMJIT_EXPORTS) #ifdef ASMJIT_EXPORTS
#define ASMJIT_API __declspec(dllexport) #define ASMJIT_API __declspec(dllexport)
#else #else
#define ASMJIT_API __declspec(dllimport) #define ASMJIT_API __declspec(dllimport)
#endif #endif
#elif defined(_WIN32) && defined(__GNUC__) #elif defined(_WIN32) && defined(__GNUC__)
#if defined(ASMJIT_EXPORTS) #ifdef ASMJIT_EXPORTS
#define ASMJIT_API __attribute__((__dllexport__)) #define ASMJIT_API __attribute__((__dllexport__))
#else #else
#define ASMJIT_API __attribute__((__dllimport__)) #define ASMJIT_API __attribute__((__dllimport__))
@@ -399,6 +381,12 @@
#define ASMJIT_ALIGN_TYPE(TYPE, N) TYPE #define ASMJIT_ALIGN_TYPE(TYPE, N) TYPE
#endif #endif
#if defined(__GNUC__)
#define ASMJIT_MAY_ALIAS __attribute__((__may_alias__))
#else
#define ASMJIT_MAY_ALIAS
#endif
// Annotations. // Annotations.
#if defined(__GNUC__) #if defined(__GNUC__)
#define ASMJIT_LIKELY(...) __builtin_expect(!!(__VA_ARGS__), 1) #define ASMJIT_LIKELY(...) __builtin_expect(!!(__VA_ARGS__), 1)
@@ -563,4 +551,4 @@
#include "../../../test/broken.h" #include "../../../test/broken.h"
#endif #endif
#endif // _ASMJIT_CORE_BUILD_H #endif // _ASMJIT_CORE_API_CONFIG_H

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/arch.h" #include "../core/arch.h"
#include "../core/support.h" #include "../core/support.h"
#include "../core/type.h" #include "../core/type.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/assembler.h" #include "../core/assembler.h"
#include "../core/codebufferwriter_p.h" #include "../core/codebufferwriter_p.h"
#include "../core/constpool.h" #include "../core/constpool.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_BUILDER #ifndef ASMJIT_NO_BUILDER
#include "../core/builder.h" #include "../core/builder.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_BUILDER_H #ifndef _ASMJIT_CORE_BUILDER_H
#define _ASMJIT_CORE_BUILDER_H #define _ASMJIT_CORE_BUILDER_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_BUILDER #ifndef ASMJIT_NO_BUILDER
#include "../core/assembler.h" #include "../core/assembler.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/arch.h" #include "../core/arch.h"
#include "../core/func.h" #include "../core/func.h"
#include "../core/type.h" #include "../core/type.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/assembler.h" #include "../core/assembler.h"
#include "../core/logging.h" #include "../core/logging.h"
#include "../core/support.h" #include "../core/support.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/assembler.h" #include "../core/assembler.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_COMPILER_H #ifndef _ASMJIT_CORE_COMPILER_H
#define _ASMJIT_CORE_COMPILER_H #define _ASMJIT_CORE_COMPILER_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/assembler.h" #include "../core/assembler.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/constpool.h" #include "../core/constpool.h"
#include "../core/support.h" #include "../core/support.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/cpuinfo.h" #include "../core/cpuinfo.h"
#if !defined(_WIN32) #if !defined(_WIN32)

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/logging.h" #include "../core/logging.h"
#include "../core/support.h" #include "../core/support.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/arch.h" #include "../core/arch.h"
#include "../core/func.h" #include "../core/func.h"
#include "../core/type.h" #include "../core/type.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/globals.h" #include "../core/globals.h"
#include "../core/support.h" #include "../core/support.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_GLOBALS_H #ifndef _ASMJIT_CORE_GLOBALS_H
#define _ASMJIT_CORE_GLOBALS_H #define _ASMJIT_CORE_GLOBALS_H
#include "../core/build.h" #include "../core/api-config.h"
ASMJIT_BEGIN_NAMESPACE ASMJIT_BEGIN_NAMESPACE

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifdef ASMJIT_BUILD_X86 #ifdef ASMJIT_BUILD_X86
#include "../core/arch.h" #include "../core/arch.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_JIT #ifndef ASMJIT_NO_JIT
#include "../core/arch.h" #include "../core/arch.h"
@@ -601,7 +599,7 @@ JitAllocator::Statistics JitAllocator::statistics() const noexcept {
if (ASMJIT_LIKELY(_impl != &JitAllocatorImpl_none)) { if (ASMJIT_LIKELY(_impl != &JitAllocatorImpl_none)) {
JitAllocatorPrivateImpl* impl = static_cast<JitAllocatorPrivateImpl*>(_impl); JitAllocatorPrivateImpl* impl = static_cast<JitAllocatorPrivateImpl*>(_impl);
ScopedLock locked(impl->lock); LockGuard guard(impl->lock);
size_t poolCount = impl->poolCount; size_t poolCount = impl->poolCount;
for (size_t poolId = 0; poolId < poolCount; poolId++) { 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<uint32_t>::max() / 2)) if (ASMJIT_UNLIKELY(size > std::numeric_limits<uint32_t>::max() / 2))
return DebugUtils::errored(kErrorTooLarge); return DebugUtils::errored(kErrorTooLarge);
ScopedLock locked(impl->lock); LockGuard guard(impl->lock);
JitAllocatorPool* pool = &impl->pools[JitAllocatorImpl_sizeToPoolId(impl, size)]; JitAllocatorPool* pool = &impl->pools[JitAllocatorImpl_sizeToPoolId(impl, size)];
uint32_t areaIndex = kNoIndex; uint32_t areaIndex = kNoIndex;
@@ -763,7 +761,7 @@ Error JitAllocator::release(void* ro) noexcept {
return DebugUtils::errored(kErrorInvalidArgument); return DebugUtils::errored(kErrorInvalidArgument);
JitAllocatorPrivateImpl* impl = static_cast<JitAllocatorPrivateImpl*>(_impl); JitAllocatorPrivateImpl* impl = static_cast<JitAllocatorPrivateImpl*>(_impl);
ScopedLock locked(impl->lock); LockGuard guard(impl->lock);
JitAllocatorBlock* block = impl->tree.get(static_cast<uint8_t*>(ro)); JitAllocatorBlock* block = impl->tree.get(static_cast<uint8_t*>(ro));
if (ASMJIT_UNLIKELY(!block)) if (ASMJIT_UNLIKELY(!block))
@@ -822,7 +820,7 @@ Error JitAllocator::shrink(void* ro, size_t newSize) noexcept {
return release(ro); return release(ro);
JitAllocatorPrivateImpl* impl = static_cast<JitAllocatorPrivateImpl*>(_impl); JitAllocatorPrivateImpl* impl = static_cast<JitAllocatorPrivateImpl*>(_impl);
ScopedLock locked(impl->lock); LockGuard guard(impl->lock);
JitAllocatorBlock* block = impl->tree.get(static_cast<uint8_t*>(ro)); JitAllocatorBlock* block = impl->tree.get(static_cast<uint8_t*>(ro));
if (ASMJIT_UNLIKELY(!block)) if (ASMJIT_UNLIKELY(!block))

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_JITALLOCATOR_H #ifndef _ASMJIT_CORE_JITALLOCATOR_H
#define _ASMJIT_CORE_JITALLOCATOR_H #define _ASMJIT_CORE_JITALLOCATOR_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_JIT #ifndef ASMJIT_NO_JIT
#include "../core/globals.h" #include "../core/globals.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_JIT #ifndef ASMJIT_NO_JIT
#include "../core/cpuinfo.h" #include "../core/cpuinfo.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_JITRUNTIME_H #ifndef _ASMJIT_CORE_JITRUNTIME_H
#define _ASMJIT_CORE_JITRUNTIME_H #define _ASMJIT_CORE_JITRUNTIME_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_JIT #ifndef ASMJIT_NO_JIT
#include "../core/codeholder.h" #include "../core/codeholder.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
#include "../core/builder.h" #include "../core/builder.h"

View File

@@ -316,7 +316,7 @@ struct Logging {
#endif #endif
// Only used by AsmJit internals, not available to users. // Only used by AsmJit internals, not available to users.
#if defined(ASMJIT_EXPORTS) #ifdef ASMJIT_EXPORTS
enum { enum {
// Has to be big to be able to hold all metadata compiler can assign to a // Has to be big to be able to hold all metadata compiler can assign to a
// single instruction. // single instruction.

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_MISC_P_H #ifndef _ASMJIT_CORE_MISC_P_H
#define _ASMJIT_CORE_MISC_P_H #define _ASMJIT_CORE_MISC_P_H
#include "../core/build.h" #include "../core/api-config.h"
ASMJIT_BEGIN_NAMESPACE ASMJIT_BEGIN_NAMESPACE

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/operand.h" #include "../core/operand.h"
ASMJIT_BEGIN_NAMESPACE ASMJIT_BEGIN_NAMESPACE

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/osutils.h" #include "../core/osutils.h"
#include "../core/support.h" #include "../core/support.h"

View File

@@ -31,63 +31,89 @@ namespace OSUtils {
//! \cond INTERNAL //! \cond INTERNAL
//! Lock. //! 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 { class Lock {
public: public:
ASMJIT_NONCOPYABLE(Lock) ASMJIT_NONCOPYABLE(Lock)
#if defined(_WIN32) #if defined(_WIN32)
#pragma pack(push, 8)
typedef CRITICAL_SECTION Handle; struct ASMJIT_MAY_ALIAS Handle {
void* DebugInfo;
long LockCount;
long RecursionCount;
void* OwningThread;
void* LockSemaphore;
unsigned long* SpinCount;
};
Handle _handle; Handle _handle;
#pragma pack(pop)
#elif !defined(__EMSCRIPTEN__)
typedef pthread_mutex_t Handle;
Handle _handle;
#endif
inline Lock() noexcept { InitializeCriticalSection(&_handle); } inline Lock() noexcept;
inline ~Lock() noexcept { DeleteCriticalSection(&_handle); } inline ~Lock() noexcept;
inline void lock() noexcept { EnterCriticalSection(&_handle); } inline void lock() noexcept;
inline void unlock() noexcept { LeaveCriticalSection(&_handle); } 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<CRITICAL_SECTION*>(&_handle)); }
inline Lock::~Lock() noexcept { DeleteCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&_handle)); }
inline void Lock::lock() noexcept { EnterCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&_handle)); }
inline void Lock::unlock() noexcept { LeaveCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&_handle)); }
#elif !defined(__EMSCRIPTEN__) #elif !defined(__EMSCRIPTEN__)
typedef pthread_mutex_t Handle; // PThread implementation.
Handle _handle; inline Lock::Lock() noexcept { pthread_mutex_init(&_handle, nullptr); }
inline Lock::~Lock() noexcept { pthread_mutex_destroy(&_handle); }
inline Lock() noexcept { pthread_mutex_init(&_handle, nullptr); } inline void Lock::lock() noexcept { pthread_mutex_lock(&_handle); }
inline ~Lock() noexcept { pthread_mutex_destroy(&_handle); } inline void Lock::unlock() noexcept { pthread_mutex_unlock(&_handle); }
inline void lock() noexcept { pthread_mutex_lock(&_handle); }
inline void unlock() noexcept { pthread_mutex_unlock(&_handle); }
#else #else
// Browser or other unsupported OS. // Dummy implementation - Emscripten or other unsupported platform.
inline Lock() noexcept {} inline Lock::Lock() noexcept {}
inline ~Lock() noexcept {} inline Lock::~Lock() noexcept {}
inline void Lock::lock() noexcept {}
inline void lock() noexcept {} inline void Lock::unlock() noexcept {}
inline void unlock() noexcept {}
#endif #endif
}; #endif
//! \endcond //! \endcond
// ============================================================================ // ============================================================================
// [asmjit::ScopedLock] // [asmjit::LockGuard]
// ============================================================================ // ============================================================================
#ifdef ASMJIT_EXPORTS
//! \cond INTERNAL //! \cond INTERNAL
//! Scoped lock. //! Scoped lock.
struct ScopedLock { struct LockGuard {
ASMJIT_NONCOPYABLE(ScopedLock) ASMJIT_NONCOPYABLE(LockGuard)
Lock& _target; Lock& _target;
inline ScopedLock(Lock& target) noexcept : _target(target) { _target.lock(); } inline LockGuard(Lock& target) noexcept : _target(target) { _target.lock(); }
inline ~ScopedLock() noexcept { _target.unlock(); } inline ~LockGuard() noexcept { _target.unlock(); }
}; };
//! \endcond //! \endcond
#endif
//! \} //! \}

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_RAASSIGNMENT_P_H #ifndef _ASMJIT_CORE_RAASSIGNMENT_P_H
#define _ASMJIT_CORE_RAASSIGNMENT_P_H #define _ASMJIT_CORE_RAASSIGNMENT_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/radefs_p.h" #include "../core/radefs_p.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_RABUILDERS_P_H #ifndef _ASMJIT_CORE_RABUILDERS_P_H
#define _ASMJIT_CORE_RABUILDERS_P_H #define _ASMJIT_CORE_RABUILDERS_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/rapass_p.h" #include "../core/rapass_p.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_RADEFS_P_H #ifndef _ASMJIT_CORE_RADEFS_P_H
#define _ASMJIT_CORE_RADEFS_P_H #define _ASMJIT_CORE_RADEFS_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/compiler.h" #include "../core/compiler.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/ralocal_p.h" #include "../core/ralocal_p.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_RALOCAL_P_H #ifndef _ASMJIT_CORE_RALOCAL_P_H
#define _ASMJIT_CORE_RALOCAL_P_H #define _ASMJIT_CORE_RALOCAL_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/raassignment_p.h" #include "../core/raassignment_p.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/ralocal_p.h" #include "../core/ralocal_p.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_RAPASS_P_H #ifndef _ASMJIT_CORE_RAPASS_P_H
#define _ASMJIT_CORE_RAPASS_P_H #define _ASMJIT_CORE_RAPASS_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/raassignment_p.h" #include "../core/raassignment_p.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/rastack_p.h" #include "../core/rastack_p.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_RASTACK_P_H #ifndef _ASMJIT_CORE_RASTACK_P_H
#define _ASMJIT_CORE_RASTACK_P_H #define _ASMJIT_CORE_RASTACK_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/radefs_p.h" #include "../core/radefs_p.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/string.h" #include "../core/string.h"
#include "../core/support.h" #include "../core/support.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/support.h" #include "../core/support.h"
ASMJIT_BEGIN_NAMESPACE ASMJIT_BEGIN_NAMESPACE

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/target.h" #include "../core/target.h"
ASMJIT_BEGIN_NAMESPACE ASMJIT_BEGIN_NAMESPACE

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/misc_p.h" #include "../core/misc_p.h"
#include "../core/type.h" #include "../core/type.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_JIT #ifndef ASMJIT_NO_JIT
#include "../core/osutils.h" #include "../core/osutils.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_CORE_VIRTMEM_H #ifndef _ASMJIT_CORE_VIRTMEM_H
#define _ASMJIT_CORE_VIRTMEM_H #define _ASMJIT_CORE_VIRTMEM_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_JIT #ifndef ASMJIT_NO_JIT
#include "../core/globals.h" #include "../core/globals.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/support.h" #include "../core/support.h"
#include "../core/zone.h" #include "../core/zone.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/support.h" #include "../core/support.h"
#include "../core/zone.h" #include "../core/zone.h"
#include "../core/zonehash.h" #include "../core/zonehash.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/zone.h" #include "../core/zone.h"
#include "../core/zonelist.h" #include "../core/zonelist.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/zone.h" #include "../core/zone.h"
#include "../core/zonestack.h" #include "../core/zonestack.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/support.h" #include "../core/support.h"
#include "../core/zone.h" #include "../core/zone.h"
#include "../core/zonetree.h" #include "../core/zonetree.h"

View File

@@ -4,8 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/support.h" #include "../core/support.h"
#include "../core/zone.h" #include "../core/zone.h"
#include "../core/zonevector.h" #include "../core/zonevector.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifdef ASMJIT_BUILD_X86 #ifdef ASMJIT_BUILD_X86
#include "../core/codebufferwriter_p.h" #include "../core/codebufferwriter_p.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER) #if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER)
#include "../x86/x86assembler.h" #include "../x86/x86assembler.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_X86_X86BUILDER_H #ifndef _ASMJIT_X86_X86BUILDER_H
#define _ASMJIT_X86_X86BUILDER_H #define _ASMJIT_X86_X86BUILDER_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_BUILDER #ifndef ASMJIT_NO_BUILDER
#include "../core/builder.h" #include "../core/builder.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifdef ASMJIT_BUILD_X86 #ifdef ASMJIT_BUILD_X86
#include "../x86/x86callconv_p.h" #include "../x86/x86callconv_p.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER) #if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER)
#include "../x86/x86assembler.h" #include "../x86/x86assembler.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_X86_X86COMPILER_H #ifndef _ASMJIT_X86_X86COMPILER_H
#define _ASMJIT_X86_X86COMPILER_H #define _ASMJIT_X86_X86COMPILER_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/compiler.h" #include "../core/compiler.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#if defined(ASMJIT_BUILD_X86) && ASMJIT_ARCH_X86 #if defined(ASMJIT_BUILD_X86) && ASMJIT_ARCH_X86
#include "../core/cpuinfo.h" #include "../core/cpuinfo.h"

View File

@@ -22,9 +22,7 @@
// (including registers and flags), and all indexes to all tables. // (including registers and flags), and all indexes to all tables.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifdef ASMJIT_BUILD_X86 #ifdef ASMJIT_BUILD_X86
#include "../core/cpuinfo.h" #include "../core/cpuinfo.h"

View File

@@ -22,9 +22,7 @@
// (including registers and flags), and all indexes to all tables. // (including registers and flags), and all indexes to all tables.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifdef ASMJIT_BUILD_X86 #ifdef ASMJIT_BUILD_X86
#include "../core/cpuinfo.h" #include "../core/cpuinfo.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifdef ASMJIT_BUILD_X86 #ifdef ASMJIT_BUILD_X86
#include "../core/logging.h" #include "../core/logging.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_X86_X86INTERNAL_P_H #ifndef _ASMJIT_X86_X86INTERNAL_P_H
#define _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 "../core/func.h"
#include "../x86/x86emitter.h" #include "../x86/x86emitter.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
#include "../core/misc_p.h" #include "../core/misc_p.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_X86_X86LOGGING_P_H #ifndef _ASMJIT_X86_X86LOGGING_P_H
#define _ASMJIT_X86_X86LOGGING_P_H #define _ASMJIT_X86_X86LOGGING_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
#include "../core/logging.h" #include "../core/logging.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#ifdef ASMJIT_BUILD_X86 #ifdef ASMJIT_BUILD_X86
#include "../core/misc_p.h" #include "../core/misc_p.h"

View File

@@ -4,9 +4,7 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
#define ASMJIT_EXPORTS #include "../core/api-build_p.h"
#include "../core/build.h"
#if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER) #if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_NO_COMPILER)
#include "../core/cpuinfo.h" #include "../core/cpuinfo.h"

View File

@@ -7,7 +7,7 @@
#ifndef _ASMJIT_X86_X86RAPASS_P_H #ifndef _ASMJIT_X86_X86RAPASS_P_H
#define _ASMJIT_X86_X86RAPASS_P_H #define _ASMJIT_X86_X86RAPASS_P_H
#include "../core/build.h" #include "../core/api-config.h"
#ifndef ASMJIT_NO_COMPILER #ifndef ASMJIT_NO_COMPILER
#include "../core/compiler.h" #include "../core/compiler.h"

View File

@@ -12,6 +12,11 @@
#include "./asmjit.h" #include "./asmjit.h"
#include "./asmjit_test_misc.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; using namespace asmjit;
// ============================================================================ // ============================================================================
@@ -174,10 +179,11 @@ int X86TestApp::run() {
x86::Compiler cc(&code); x86::Compiler cc(&code);
test->compile(cc); test->compile(cc);
void* func = nullptr;
Error err = errorHandler._err; Error err = errorHandler._err;
if (!err) if (!err)
err = cc.finalize(); err = cc.finalize();
void* func;
#ifndef ASMJIT_NO_LOGGING #ifndef ASMJIT_NO_LOGGING
if (_dumpAsm) { if (_dumpAsm) {

View File

@@ -48,8 +48,8 @@ int main(int argc, char* argv[]) {
code.init(codeInfo); code.init(codeInfo);
code.setLogger(&logger); code.setLogger(&logger);
Section* section; Section* dataSection;
Error err = code.newSection(&section, ".data", SIZE_MAX, 0, 8); Error err = code.newSection(&dataSection, ".data", SIZE_MAX, 0, 8);
if (err) { if (err) {
fail("Failed to create a .data section", err); fail("Failed to create a .data section", err);
@@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
a.emitEpilog(frame); a.emitEpilog(frame);
a.section(section); a.section(dataSection);
a.bind(data); a.bind(data);
a.embed(dataArray, sizeof(dataArray)); a.embed(dataArray, sizeof(dataArray));