@@ -16,6 +16,8 @@ typedef struct _PyLegacyEventHandler {
16
16
int event ;
17
17
} _PyLegacyEventHandler ;
18
18
19
+ #define _PyLegacyEventHandler_CAST (op ) ((_PyLegacyEventHandler *)(op))
20
+
19
21
#ifdef Py_GIL_DISABLED
20
22
#define LOCK_SETUP () PyMutex_Lock(&_PyRuntime.ceval.sys_trace_profile_mutex);
21
23
#define UNLOCK_SETUP () PyMutex_Unlock(&_PyRuntime.ceval.sys_trace_profile_mutex);
@@ -54,51 +56,56 @@ call_profile_func(_PyLegacyEventHandler *self, PyObject *arg)
54
56
55
57
static PyObject *
56
58
sys_profile_start (
57
- _PyLegacyEventHandler * self , PyObject * const * args ,
59
+ PyObject * op , PyObject * const * args ,
58
60
size_t nargsf , PyObject * kwnames
59
61
) {
60
62
assert (kwnames == NULL );
61
63
assert (PyVectorcall_NARGS (nargsf ) == 2 );
64
+ _PyLegacyEventHandler * self = _PyLegacyEventHandler_CAST (op );
62
65
return call_profile_func (self , Py_None );
63
66
}
64
67
65
68
static PyObject *
66
69
sys_profile_throw (
67
- _PyLegacyEventHandler * self , PyObject * const * args ,
70
+ PyObject * op , PyObject * const * args ,
68
71
size_t nargsf , PyObject * kwnames
69
72
) {
70
73
assert (kwnames == NULL );
71
74
assert (PyVectorcall_NARGS (nargsf ) == 3 );
75
+ _PyLegacyEventHandler * self = _PyLegacyEventHandler_CAST (op );
72
76
return call_profile_func (self , Py_None );
73
77
}
74
78
75
79
static PyObject *
76
80
sys_profile_return (
77
- _PyLegacyEventHandler * self , PyObject * const * args ,
81
+ PyObject * op , PyObject * const * args ,
78
82
size_t nargsf , PyObject * kwnames
79
83
) {
80
84
assert (kwnames == NULL );
81
85
assert (PyVectorcall_NARGS (nargsf ) == 3 );
86
+ _PyLegacyEventHandler * self = _PyLegacyEventHandler_CAST (op );
82
87
return call_profile_func (self , args [2 ]);
83
88
}
84
89
85
90
static PyObject *
86
91
sys_profile_unwind (
87
- _PyLegacyEventHandler * self , PyObject * const * args ,
92
+ PyObject * op , PyObject * const * args ,
88
93
size_t nargsf , PyObject * kwnames
89
94
) {
90
95
assert (kwnames == NULL );
91
96
assert (PyVectorcall_NARGS (nargsf ) == 3 );
92
- return call_profile_func (self , NULL );
97
+ _PyLegacyEventHandler * self = _PyLegacyEventHandler_CAST (op );
98
+ return call_profile_func (self , NULL );
93
99
}
94
100
95
101
static PyObject *
96
102
sys_profile_call_or_return (
97
- _PyLegacyEventHandler * self , PyObject * const * args ,
103
+ PyObject * op , PyObject * const * args ,
98
104
size_t nargsf , PyObject * kwnames
99
105
) {
100
106
assert (kwnames == NULL );
101
107
assert (PyVectorcall_NARGS (nargsf ) == 4 );
108
+ _PyLegacyEventHandler * self = _PyLegacyEventHandler_CAST (op );
102
109
PyObject * callable = args [2 ];
103
110
if (PyCFunction_Check (callable )) {
104
111
return call_profile_func (self , callable );
@@ -428,38 +435,38 @@ setup_profile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg, PyObject
428
435
if (!tstate -> interp -> sys_profile_initialized ) {
429
436
tstate -> interp -> sys_profile_initialized = true;
430
437
if (set_callbacks (PY_MONITORING_SYS_PROFILE_ID ,
431
- ( vectorcallfunc ) sys_profile_start , PyTrace_CALL ,
432
- PY_MONITORING_EVENT_PY_START , PY_MONITORING_EVENT_PY_RESUME )) {
438
+ sys_profile_start , PyTrace_CALL ,
439
+ PY_MONITORING_EVENT_PY_START , PY_MONITORING_EVENT_PY_RESUME )) {
433
440
return -1 ;
434
441
}
435
442
if (set_callbacks (PY_MONITORING_SYS_PROFILE_ID ,
436
- ( vectorcallfunc ) sys_profile_throw , PyTrace_CALL ,
437
- PY_MONITORING_EVENT_PY_THROW , -1 )) {
443
+ sys_profile_throw , PyTrace_CALL ,
444
+ PY_MONITORING_EVENT_PY_THROW , -1 )) {
438
445
return -1 ;
439
446
}
440
447
if (set_callbacks (PY_MONITORING_SYS_PROFILE_ID ,
441
- ( vectorcallfunc ) sys_profile_return , PyTrace_RETURN ,
442
- PY_MONITORING_EVENT_PY_RETURN , PY_MONITORING_EVENT_PY_YIELD )) {
448
+ sys_profile_return , PyTrace_RETURN ,
449
+ PY_MONITORING_EVENT_PY_RETURN , PY_MONITORING_EVENT_PY_YIELD )) {
443
450
return -1 ;
444
451
}
445
452
if (set_callbacks (PY_MONITORING_SYS_PROFILE_ID ,
446
- ( vectorcallfunc ) sys_profile_unwind , PyTrace_RETURN ,
447
- PY_MONITORING_EVENT_PY_UNWIND , -1 )) {
453
+ sys_profile_unwind , PyTrace_RETURN ,
454
+ PY_MONITORING_EVENT_PY_UNWIND , -1 )) {
448
455
return -1 ;
449
456
}
450
457
if (set_callbacks (PY_MONITORING_SYS_PROFILE_ID ,
451
- ( vectorcallfunc ) sys_profile_call_or_return , PyTrace_C_CALL ,
452
- PY_MONITORING_EVENT_CALL , -1 )) {
458
+ sys_profile_call_or_return , PyTrace_C_CALL ,
459
+ PY_MONITORING_EVENT_CALL , -1 )) {
453
460
return -1 ;
454
461
}
455
462
if (set_callbacks (PY_MONITORING_SYS_PROFILE_ID ,
456
- ( vectorcallfunc ) sys_profile_call_or_return , PyTrace_C_RETURN ,
457
- PY_MONITORING_EVENT_C_RETURN , -1 )) {
463
+ sys_profile_call_or_return , PyTrace_C_RETURN ,
464
+ PY_MONITORING_EVENT_C_RETURN , -1 )) {
458
465
return -1 ;
459
466
}
460
467
if (set_callbacks (PY_MONITORING_SYS_PROFILE_ID ,
461
- ( vectorcallfunc ) sys_profile_call_or_return , PyTrace_C_EXCEPTION ,
462
- PY_MONITORING_EVENT_C_RAISE , -1 )) {
468
+ sys_profile_call_or_return , PyTrace_C_EXCEPTION ,
469
+ PY_MONITORING_EVENT_C_RAISE , -1 )) {
463
470
return -1 ;
464
471
}
465
472
}
0 commit comments