Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-internal.h view on Meta::CPAN
#endif
#if defined(HAVE_MEMCMP)
# define jit_memcmp(s1, s2, len) (memcmp((s1), (s2), (len)))
#elif defined(HAVE_BCMP)
# define jit_memcmp(s1, s2, len) (bcmp((char *)(s1), (char *)(s2), (len)))
#endif
#if defined(HAVE_MEMCHR)
# define jit_memchr(s, c, len) (memchr((s), (c), (len)))
#endif
/*
* We need the apply rules for "jit_redirector_size".
*/
#include "jit-apply-func.h"
/*
* Include the thread routines.
*/
#include "jit-thread.h"
/*
* Include varint encoding for bytecode offset data.
*/
#include "jit-varint.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* The following is some macro magic that attempts to detect
* the best alignment to use on the target platform. The final
* value, "JIT_BEST_ALIGNMENT", will be a compile-time constant.
*/
#define _JIT_ALIGN_CHECK_TYPE(type,name) \
struct _JIT_align_##name { \
jit_sbyte pad; \
type field; \
}
#define _JIT_ALIGN_FOR_TYPE(name) \
((jit_nuint)(&(((struct _JIT_align_##name *)0)->field)))
#define _JIT_ALIGN_MAX(a,b) \
((a) > (b) ? (a) : (b))
#define _JIT_ALIGN_MAX3(a,b,c) \
(_JIT_ALIGN_MAX((a), _JIT_ALIGN_MAX((b), (c))))
_JIT_ALIGN_CHECK_TYPE(jit_sbyte, sbyte);
_JIT_ALIGN_CHECK_TYPE(jit_short, short);
_JIT_ALIGN_CHECK_TYPE(jit_int, int);
_JIT_ALIGN_CHECK_TYPE(jit_long, long);
_JIT_ALIGN_CHECK_TYPE(jit_ptr, ptr);
_JIT_ALIGN_CHECK_TYPE(jit_float32, float);
_JIT_ALIGN_CHECK_TYPE(jit_float64, double);
_JIT_ALIGN_CHECK_TYPE(jit_nfloat, nfloat);
#if defined(JIT_X86)
/* Sometimes the code below guesses wrong on Win32 platforms */
#define JIT_BEST_ALIGNMENT 4
#else
#define JIT_BEST_ALIGNMENT \
_JIT_ALIGN_MAX(_JIT_ALIGN_MAX3(_JIT_ALIGN_FOR_TYPE(int), \
_JIT_ALIGN_FOR_TYPE(long), \
_JIT_ALIGN_FOR_TYPE(ptr)), \
_JIT_ALIGN_MAX3(_JIT_ALIGN_FOR_TYPE(float), \
_JIT_ALIGN_FOR_TYPE(double), \
_JIT_ALIGN_FOR_TYPE(nfloat)))
#endif
/*
* Get the alignment values for various system types.
* These will also be compile-time constants.
*/
#define JIT_ALIGN_SBYTE _JIT_ALIGN_FOR_TYPE(sbyte)
#define JIT_ALIGN_UBYTE _JIT_ALIGN_FOR_TYPE(sbyte)
#define JIT_ALIGN_SHORT _JIT_ALIGN_FOR_TYPE(short)
#define JIT_ALIGN_USHORT _JIT_ALIGN_FOR_TYPE(short)
#define JIT_ALIGN_CHAR _JIT_ALIGN_FOR_TYPE(char)
#define JIT_ALIGN_INT _JIT_ALIGN_FOR_TYPE(int)
#define JIT_ALIGN_UINT _JIT_ALIGN_FOR_TYPE(int)
#define JIT_ALIGN_NINT _JIT_ALIGN_FOR_TYPE(ptr)
#define JIT_ALIGN_NUINT _JIT_ALIGN_FOR_TYPE(ptr)
#define JIT_ALIGN_LONG _JIT_ALIGN_FOR_TYPE(long)
#define JIT_ALIGN_ULONG _JIT_ALIGN_FOR_TYPE(long)
#define JIT_ALIGN_FLOAT32 _JIT_ALIGN_FOR_TYPE(float)
#define JIT_ALIGN_FLOAT64 _JIT_ALIGN_FOR_TYPE(double)
#define JIT_ALIGN_NFLOAT _JIT_ALIGN_FOR_TYPE(nfloat)
#define JIT_ALIGN_PTR _JIT_ALIGN_FOR_TYPE(ptr)
/*
* Structure of a memory pool.
*/
typedef struct jit_pool_block *jit_pool_block_t;
struct jit_pool_block
{
jit_pool_block_t next;
char data[1];
};
typedef struct
{
unsigned int elem_size;
unsigned int elems_per_block;
unsigned int elems_in_last;
jit_pool_block_t blocks;
void *free_list;
} jit_memory_pool;
/*
* Initialize a memory pool.
*/
void _jit_memory_pool_init(jit_memory_pool *pool, unsigned int elem_size);
#define jit_memory_pool_init(pool,type) \
_jit_memory_pool_init((pool), sizeof(type))
/*
* Free the contents of a memory pool.
*/
( run in 2.310 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )