make some tweaks for netbsd compiling
This commit is contained in:
parent
995459dc92
commit
76f83f2bf6
|
@ -2067,7 +2067,7 @@ static int OP_SWPB(const u32 i) { return op_swp_(i, 1); }
|
|||
//-----------------------------------------------------------------------------
|
||||
// LDMIA / LDMIB / LDMDA / LDMDB / STMIA / STMIB / STMDA / STMDB
|
||||
//-----------------------------------------------------------------------------
|
||||
static u32 popcount(u32 x)
|
||||
static u32 popregcount(u32 x)
|
||||
{
|
||||
uint32_t pop = 0;
|
||||
for(; x; x>>=1)
|
||||
|
@ -2233,7 +2233,7 @@ static void call_ldm_stm(GpVar adr, u32 bitmask, bool store, int dir)
|
|||
if(bitmask)
|
||||
{
|
||||
GpVar n = c.newGpVar(kX86VarTypeGpd);
|
||||
c.mov(n, popcount(bitmask));
|
||||
c.mov(n, popregcount(bitmask));
|
||||
#ifdef ASMJIT_X64
|
||||
GpVar regs = c.newGpVar(kX86VarTypeGpz);
|
||||
c.mov(regs, get_reg_list(bitmask, dir));
|
||||
|
@ -2267,7 +2267,7 @@ static int op_bx_thumb(Mem srcreg, bool blx, bool test_thumb);
|
|||
static int op_ldm_stm(u32 i, bool store, int dir, bool before, bool writeback)
|
||||
{
|
||||
u32 bitmask = i & 0xFFFF;
|
||||
u32 pop = popcount(bitmask);
|
||||
u32 pop = popregcount(bitmask);
|
||||
|
||||
GpVar adr = c.newGpVar(kX86VarTypeGpd);
|
||||
c.mov(adr, reg_pos_ptr(16));
|
||||
|
@ -2326,7 +2326,7 @@ static int OP_STMDB_W(const u32 i) { return op_ldm_stm(i, 1, -1, 1, 1); }
|
|||
static int op_ldm_stm2(u32 i, bool store, int dir, bool before, bool writeback)
|
||||
{
|
||||
u32 bitmask = i & 0xFFFF;
|
||||
u32 pop = popcount(bitmask);
|
||||
u32 pop = popregcount(bitmask);
|
||||
bool bit15 = BIT15(i);
|
||||
|
||||
//printf("ARM%c: %s R%d:%08X, bitmask %02X\n", PROCNUM?'7':'9', (store?"STM":"LDM"), REG_POS(i, 16), cpu->R[REG_POS(i, 16)], bitmask);
|
||||
|
@ -3615,7 +3615,7 @@ static int OP_LDR_PCREL(const u32 i)
|
|||
static int op_ldm_stm_thumb(u32 i, bool store)
|
||||
{
|
||||
u32 bitmask = i & 0xFF;
|
||||
u32 pop = popcount(bitmask);
|
||||
u32 pop = popregcount(bitmask);
|
||||
|
||||
//if (BIT_N(i, _REG_NUM(i, 8)))
|
||||
// printf("WARNING - %sIA with Rb in Rlist (THUMB)\n", store?"STM":"LDM");
|
||||
|
@ -3656,7 +3656,7 @@ static int op_push_pop(u32 i, bool store, bool pc_lr)
|
|||
{
|
||||
u32 bitmask = (i & 0xFF);
|
||||
bitmask |= pc_lr << (store ? 14 : 15);
|
||||
u32 pop = popcount(bitmask);
|
||||
u32 pop = popregcount(bitmask);
|
||||
int dir = store ? -1 : 1;
|
||||
|
||||
GpVar adr = c.newGpVar(kX86VarTypeGpd);
|
||||
|
|
|
@ -55,12 +55,15 @@ inline T SIGNED_OVERFLOW(T a,T b,T c) { return BIT31(((a)&(b)&(~c)) | ((~a)&(~(b
|
|||
template<typename T>
|
||||
inline T SIGNED_UNDERFLOW(T a,T b,T c) { return BIT31(((a)&(~(b))&(~c)) | ((~a)&(b)&(c))); }
|
||||
|
||||
#if !defined(bswap32)
|
||||
#define bswap32(val) \
|
||||
( (val << 24) & 0xFF000000) | \
|
||||
( (val << 8) & 0x00FF0000) | \
|
||||
( (val >> 8) & 0x0000FF00) | \
|
||||
( (val >> 24) & 0x000000FF)
|
||||
#endif
|
||||
|
||||
#if !defined(bswap64)
|
||||
#define bswap64(x) \
|
||||
( (x << 56) & 0xff00000000000000ULL ) | \
|
||||
( (x << 40) & 0x00ff000000000000ULL ) | \
|
||||
|
@ -70,6 +73,7 @@ inline T SIGNED_UNDERFLOW(T a,T b,T c) { return BIT31(((a)&(~(b))&(~c)) | ((~a)&
|
|||
( (x >> 24) & 0x0000000000ff0000ULL ) | \
|
||||
( (x >> 40) & 0x000000000000ff00ULL ) | \
|
||||
( (x >> 56) & 0x00000000000000ffULL )
|
||||
#endif
|
||||
|
||||
// ============================= CPRS flags funcs
|
||||
inline bool CarryFrom(s32 left, s32 right)
|
||||
|
|
|
@ -1,197 +1,199 @@
|
|||
// [AsmJit]
|
||||
// Complete JIT Assembler for C++ Language.
|
||||
//
|
||||
// [License]
|
||||
// Zlib - See COPYING file in this package.
|
||||
|
||||
// [Guard]
|
||||
#ifndef _ASMJIT_CORE_STRINGBUILDER_H
|
||||
#define _ASMJIT_CORE_STRINGBUILDER_H
|
||||
|
||||
// [Dependencies - AsmJit]
|
||||
#include "../core/assert.h"
|
||||
#include "../core/defs.h"
|
||||
|
||||
namespace AsmJit {
|
||||
|
||||
//! @addtogroup AsmJit_Core
|
||||
//! @{
|
||||
|
||||
// ============================================================================
|
||||
// [AsmJit::StringBuilder]
|
||||
// ============================================================================
|
||||
|
||||
//! @brief String builder.
|
||||
//!
|
||||
//! String builder was designed to be able to build a string using append like
|
||||
//! operation to append numbers, other strings, or signle characters. It can
|
||||
//! allocate it's own buffer or use a buffer created on the stack.
|
||||
//!
|
||||
//! String builder contains method specific to AsmJit functionality, used for
|
||||
//! logging or HTML output.
|
||||
struct StringBuilder
|
||||
{
|
||||
ASMJIT_NO_COPY(StringBuilder)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Construction / Destruction]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
ASMJIT_API StringBuilder();
|
||||
ASMJIT_API ~StringBuilder();
|
||||
|
||||
inline StringBuilder(const _DontInitialize&) {}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Accessors]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Get string builder capacity.
|
||||
inline size_t getCapacity() const
|
||||
{ return _capacity; }
|
||||
|
||||
//! @brief Get length.
|
||||
inline size_t getLength() const
|
||||
{ return _length; }
|
||||
|
||||
//! @brief Get null-terminated string data.
|
||||
inline char* getData()
|
||||
{ return _data; }
|
||||
|
||||
//! @brief Get null-terminated string data (const).
|
||||
inline const char* getData() const
|
||||
{ return _data; }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Prepare / Reserve]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Prepare to set/append.
|
||||
ASMJIT_API char* prepare(uint32_t op, size_t len);
|
||||
|
||||
//! @brief Reserve @a to bytes in string builder.
|
||||
ASMJIT_API bool reserve(size_t to);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Clear]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Clear the content in String builder.
|
||||
ASMJIT_API void clear();
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Methods]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
ASMJIT_API bool _opString(uint32_t op, const char* str, size_t len = kInvalidSize);
|
||||
ASMJIT_API bool _opVFormat(uint32_t op, const char* fmt, va_list ap);
|
||||
ASMJIT_API bool _opChars(uint32_t op, char c, size_t len);
|
||||
ASMJIT_API bool _opNumber(uint32_t op, uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0);
|
||||
ASMJIT_API bool _opHex(uint32_t op, const void* data, size_t length);
|
||||
|
||||
//! @brief Replace the current content by @a str of @a len.
|
||||
inline bool setString(const char* str, size_t len = kInvalidSize)
|
||||
{ return _opString(kStringBuilderOpSet, str, len); }
|
||||
|
||||
//! @brief Replace the current content by formatted string @a fmt.
|
||||
inline bool setVFormat(const char* fmt, va_list ap)
|
||||
{ return _opVFormat(kStringBuilderOpSet, fmt, ap); }
|
||||
|
||||
//! @brief Replace the current content by formatted string @a fmt.
|
||||
ASMJIT_API bool setFormat(const char* fmt, ...);
|
||||
|
||||
//! @brief Replace the current content by @a c of @a len.
|
||||
inline bool setChars(char c, size_t len)
|
||||
{ return _opChars(kStringBuilderOpSet, c, len); }
|
||||
|
||||
//! @brief Replace the current content by @a i..
|
||||
inline bool setNumber(uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0)
|
||||
{ return _opNumber(kStringBuilderOpSet, i, base, width, flags); }
|
||||
|
||||
//! @brief Append @a str of @a len.
|
||||
inline bool appendString(const char* str, size_t len = kInvalidSize)
|
||||
{ return _opString(kStringBuilderOpAppend, str, len); }
|
||||
|
||||
//! @brief Append a formatted string @a fmt to the current content.
|
||||
inline bool appendVFormat(const char* fmt, va_list ap)
|
||||
{ return _opVFormat(kStringBuilderOpAppend, fmt, ap); }
|
||||
|
||||
//! @brief Append a formatted string @a fmt to the current content.
|
||||
ASMJIT_API bool appendFormat(const char* fmt, ...);
|
||||
|
||||
//! @brief Append @a c of @a len.
|
||||
inline bool appendChars(char c, size_t len)
|
||||
{ return _opChars(kStringBuilderOpAppend, c, len); }
|
||||
|
||||
//! @brief Append @a i.
|
||||
inline bool appendNumber(uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0)
|
||||
{ return _opNumber(kStringBuilderOpAppend, i, base, width, flags); }
|
||||
|
||||
//! @brief Check for equality with other @a str.
|
||||
ASMJIT_API bool eq(const char* str, size_t len = kInvalidSize) const;
|
||||
|
||||
//! @brief Check for equality with StringBuilder @a other.
|
||||
inline bool eq(const StringBuilder& other) const
|
||||
{ return eq(other._data); }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Operator Overload]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
inline bool operator==(const StringBuilder& other) const { return eq(other); }
|
||||
inline bool operator!=(const StringBuilder& other) const { return !eq(other); }
|
||||
|
||||
inline bool operator==(const char* str) const { return eq(str); }
|
||||
inline bool operator!=(const char* str) const { return !eq(str); }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Members]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief String data.
|
||||
char* _data;
|
||||
//! @brief Length.
|
||||
size_t _length;
|
||||
//! @brief Capacity.
|
||||
size_t _capacity;
|
||||
//! @brief Whether the string can be freed.
|
||||
size_t _canFree;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// [AsmJit::StringBuilderT]
|
||||
// ============================================================================
|
||||
|
||||
template<size_t N>
|
||||
struct StringBuilderT : public StringBuilder
|
||||
{
|
||||
ASMJIT_NO_COPY(StringBuilderT<N>)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Construction / Destruction]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
inline StringBuilderT() :
|
||||
StringBuilder(_DontInitialize())
|
||||
{
|
||||
_data = _embeddedData;
|
||||
_data[0] = 0;
|
||||
|
||||
_length = 0;
|
||||
_capacity = 0;
|
||||
_canFree = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Members]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Embedded data.
|
||||
char _embeddedData[(N + sizeof(uintptr_t)) & ~(sizeof(uintptr_t) - 1)];
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
} // AsmJit namespace
|
||||
|
||||
#endif // _ASMJIT_CORE_STRINGBUILDER_H
|
||||
// [AsmJit]
|
||||
// Complete JIT Assembler for C++ Language.
|
||||
//
|
||||
// [License]
|
||||
// Zlib - See COPYING file in this package.
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
// [Guard]
|
||||
#ifndef _ASMJIT_CORE_STRINGBUILDER_H
|
||||
#define _ASMJIT_CORE_STRINGBUILDER_H
|
||||
|
||||
// [Dependencies - AsmJit]
|
||||
#include "../core/assert.h"
|
||||
#include "../core/defs.h"
|
||||
|
||||
namespace AsmJit {
|
||||
|
||||
//! @addtogroup AsmJit_Core
|
||||
//! @{
|
||||
|
||||
// ============================================================================
|
||||
// [AsmJit::StringBuilder]
|
||||
// ============================================================================
|
||||
|
||||
//! @brief String builder.
|
||||
//!
|
||||
//! String builder was designed to be able to build a string using append like
|
||||
//! operation to append numbers, other strings, or signle characters. It can
|
||||
//! allocate it's own buffer or use a buffer created on the stack.
|
||||
//!
|
||||
//! String builder contains method specific to AsmJit functionality, used for
|
||||
//! logging or HTML output.
|
||||
struct StringBuilder
|
||||
{
|
||||
ASMJIT_NO_COPY(StringBuilder)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Construction / Destruction]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
ASMJIT_API StringBuilder();
|
||||
ASMJIT_API ~StringBuilder();
|
||||
|
||||
inline StringBuilder(const _DontInitialize&) {}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Accessors]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Get string builder capacity.
|
||||
inline size_t getCapacity() const
|
||||
{ return _capacity; }
|
||||
|
||||
//! @brief Get length.
|
||||
inline size_t getLength() const
|
||||
{ return _length; }
|
||||
|
||||
//! @brief Get null-terminated string data.
|
||||
inline char* getData()
|
||||
{ return _data; }
|
||||
|
||||
//! @brief Get null-terminated string data (const).
|
||||
inline const char* getData() const
|
||||
{ return _data; }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Prepare / Reserve]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Prepare to set/append.
|
||||
ASMJIT_API char* prepare(uint32_t op, size_t len);
|
||||
|
||||
//! @brief Reserve @a to bytes in string builder.
|
||||
ASMJIT_API bool reserve(size_t to);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Clear]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Clear the content in String builder.
|
||||
ASMJIT_API void clear();
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Methods]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
ASMJIT_API bool _opString(uint32_t op, const char* str, size_t len = kInvalidSize);
|
||||
ASMJIT_API bool _opVFormat(uint32_t op, const char* fmt, va_list ap);
|
||||
ASMJIT_API bool _opChars(uint32_t op, char c, size_t len);
|
||||
ASMJIT_API bool _opNumber(uint32_t op, uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0);
|
||||
ASMJIT_API bool _opHex(uint32_t op, const void* data, size_t length);
|
||||
|
||||
//! @brief Replace the current content by @a str of @a len.
|
||||
inline bool setString(const char* str, size_t len = kInvalidSize)
|
||||
{ return _opString(kStringBuilderOpSet, str, len); }
|
||||
|
||||
//! @brief Replace the current content by formatted string @a fmt.
|
||||
inline bool setVFormat(const char* fmt, va_list ap)
|
||||
{ return _opVFormat(kStringBuilderOpSet, fmt, ap); }
|
||||
|
||||
//! @brief Replace the current content by formatted string @a fmt.
|
||||
ASMJIT_API bool setFormat(const char* fmt, ...);
|
||||
|
||||
//! @brief Replace the current content by @a c of @a len.
|
||||
inline bool setChars(char c, size_t len)
|
||||
{ return _opChars(kStringBuilderOpSet, c, len); }
|
||||
|
||||
//! @brief Replace the current content by @a i..
|
||||
inline bool setNumber(uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0)
|
||||
{ return _opNumber(kStringBuilderOpSet, i, base, width, flags); }
|
||||
|
||||
//! @brief Append @a str of @a len.
|
||||
inline bool appendString(const char* str, size_t len = kInvalidSize)
|
||||
{ return _opString(kStringBuilderOpAppend, str, len); }
|
||||
|
||||
//! @brief Append a formatted string @a fmt to the current content.
|
||||
inline bool appendVFormat(const char* fmt, va_list ap)
|
||||
{ return _opVFormat(kStringBuilderOpAppend, fmt, ap); }
|
||||
|
||||
//! @brief Append a formatted string @a fmt to the current content.
|
||||
ASMJIT_API bool appendFormat(const char* fmt, ...);
|
||||
|
||||
//! @brief Append @a c of @a len.
|
||||
inline bool appendChars(char c, size_t len)
|
||||
{ return _opChars(kStringBuilderOpAppend, c, len); }
|
||||
|
||||
//! @brief Append @a i.
|
||||
inline bool appendNumber(uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0)
|
||||
{ return _opNumber(kStringBuilderOpAppend, i, base, width, flags); }
|
||||
|
||||
//! @brief Check for equality with other @a str.
|
||||
ASMJIT_API bool eq(const char* str, size_t len = kInvalidSize) const;
|
||||
|
||||
//! @brief Check for equality with StringBuilder @a other.
|
||||
inline bool eq(const StringBuilder& other) const
|
||||
{ return eq(other._data); }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Operator Overload]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
inline bool operator==(const StringBuilder& other) const { return eq(other); }
|
||||
inline bool operator!=(const StringBuilder& other) const { return !eq(other); }
|
||||
|
||||
inline bool operator==(const char* str) const { return eq(str); }
|
||||
inline bool operator!=(const char* str) const { return !eq(str); }
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Members]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief String data.
|
||||
char* _data;
|
||||
//! @brief Length.
|
||||
size_t _length;
|
||||
//! @brief Capacity.
|
||||
size_t _capacity;
|
||||
//! @brief Whether the string can be freed.
|
||||
size_t _canFree;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// [AsmJit::StringBuilderT]
|
||||
// ============================================================================
|
||||
|
||||
template<size_t N>
|
||||
struct StringBuilderT : public StringBuilder
|
||||
{
|
||||
ASMJIT_NO_COPY(StringBuilderT<N>)
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Construction / Destruction]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
inline StringBuilderT() :
|
||||
StringBuilder(_DontInitialize())
|
||||
{
|
||||
_data = _embeddedData;
|
||||
_data[0] = 0;
|
||||
|
||||
_length = 0;
|
||||
_capacity = 0;
|
||||
_canFree = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Members]
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
//! @brief Embedded data.
|
||||
char _embeddedData[(N + sizeof(uintptr_t)) & ~(sizeof(uintptr_t) - 1)];
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
} // AsmJit namespace
|
||||
|
||||
#endif // _ASMJIT_CORE_STRINGBUILDER_H
|
||||
|
|
|
@ -42,7 +42,7 @@ int getOnlineCores (void)
|
|||
#elif defined HOST_BSD
|
||||
int cores;
|
||||
const int mib[4] = { CTL_HW, HW_NCPU, 0, 0 };
|
||||
const size_t len = sizeof(cores);
|
||||
size_t len = sizeof(cores); //don't make this const, i guess sysctl can't take a const *
|
||||
sysctl(mib, 2, &cores, &len, NULL, 0);
|
||||
return (cores < 1) ? 1 : cores;
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue