Ruby: mjit_c.c Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

mjit_c.c
1/**********************************************************************
2
3 mjit_c.c - C helpers for MJIT
4
5 Copyright (C) 2017 Takashi Kokubun <k0kubun@ruby-lang.org>.
6
7**********************************************************************/
8
9#include "ruby/internal/config.h" // defines USE_MJIT
10
11#if USE_MJIT
12
13#include "mjit.h"
14#include "mjit_c.h"
15#include "internal.h"
16#include "internal/compile.h"
17#include "internal/hash.h"
18#include "yjit.h"
19#include "vm_insnhelper.h"
20
21#include "insns.inc"
22#include "insns_info.inc"
23
24#include "mjit_sp_inc.inc"
25
26#if SIZEOF_LONG == SIZEOF_VOIDP
27#define NUM2PTR(x) NUM2ULONG(x)
28#define PTR2NUM(x) ULONG2NUM(x)
29#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
30#define NUM2PTR(x) NUM2ULL(x)
31#define PTR2NUM(x) ULL2NUM(x)
32#endif
33
34// An offsetof implementation that works for unnamed struct and union.
35// Multiplying 8 for compatibility with libclang's offsetof.
36#define OFFSETOF(ptr, member) RB_SIZE2NUM(((char *)&ptr.member - (char*)&ptr) * 8)
37
38#define SIZEOF(type) RB_SIZE2NUM(sizeof(type))
39#define SIGNED_TYPE_P(type) RBOOL((type)(-1) < (type)(1))
40
41#include "mjit_c.rbinc"
42
43#endif // USE_MJIT