1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#define PyGetInt(item, value) \
if (PyInt_Check(item)){ \
value = (uint64_t)PyInt_AsLong(item); \
} \
else if (PyLong_Check(item)){ \
value = (uint64_t)PyLong_AsUnsignedLongLong(item); \
} \
else{ \
RAISE(PyExc_TypeError,"arg must be int"); \
} \
#define PyGetInt_ret0(item, value) \
if (PyInt_Check(item)){ \
value = (uint64_t)PyInt_AsLong(item); \
} \
else if (PyLong_Check(item)){ \
value = (uint64_t)PyLong_AsUnsignedLongLong(item); \
} \
else{ \
printf("error\n"); return 0; \
} \
#define getset_reg_u64(regname) \
static PyObject *JitCpu_get_ ## regname (JitCpu *self, void *closure) \
{ \
return PyLong_FromUnsignedLongLong((uint64_t)(self->vmcpu. regname )); \
} \
static int JitCpu_set_ ## regname (JitCpu *self, PyObject *value, void *closure) \
{ \
uint64_t val; \
PyGetInt_ret0(value, val); \
self->vmcpu. regname = val; \
return 0; \
}
#define getset_reg_u32(regname) \
static PyObject *JitCpu_get_ ## regname (JitCpu *self, void *closure) \
{ \
return PyLong_FromUnsignedLongLong((uint32_t)(self->vmcpu. regname )); \
} \
static int JitCpu_set_ ## regname (JitCpu *self, PyObject *value, void *closure) \
{ \
uint32_t val; \
PyGetInt_ret0(value, val); \
self->vmcpu. regname = val; \
return 0; \
}
#define getset_reg_u16(regname) \
static PyObject *JitCpu_get_ ## regname (JitCpu *self, void *closure) \
{ \
return PyLong_FromUnsignedLongLong((uint16_t)(self->vmcpu. regname )); \
} \
static int JitCpu_set_ ## regname (JitCpu *self, PyObject *value, void *closure) \
{ \
uint16_t val; \
PyGetInt_ret0(value, val); \
self->vmcpu. regname = val; \
return 0; \
}
|