Skip to content

Commit 0927a2b

Browse files
authored
pythonGH-103082: Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS (python#107069)
Rename private C API constants: * Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS * Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS
1 parent b7dc795 commit 0927a2b

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

Include/cpython/code.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ extern "C" {
1010

1111

1212
/* Count of all "real" monitoring events (not derived from other events) */
13-
#define PY_MONITORING_UNGROUPED_EVENTS 14
13+
#define _PY_MONITORING_UNGROUPED_EVENTS 14
1414
/* Count of all monitoring events */
15-
#define PY_MONITORING_EVENTS 16
15+
#define _PY_MONITORING_EVENTS 16
1616

1717
/* Table of which tools are active for each monitored event. */
1818
typedef struct _Py_Monitors {
19-
uint8_t tools[PY_MONITORING_UNGROUPED_EVENTS];
19+
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
2020
} _Py_Monitors;
2121

2222
/* Each instruction in a code object is a fixed-width value,

Include/internal/pycore_interp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
#include "pycore_gc.h" // struct _gc_runtime_state
2626
#include "pycore_global_objects.h" // struct _Py_interp_static_objects
2727
#include "pycore_import.h" // struct _import_state
28-
#include "pycore_instruments.h" // PY_MONITORING_EVENTS
28+
#include "pycore_instruments.h" // _PY_MONITORING_EVENTS
2929
#include "pycore_list.h" // struct _Py_list_state
3030
#include "pycore_object_state.h" // struct _py_object_state
3131
#include "pycore_obmalloc.h" // struct obmalloc_state
@@ -190,7 +190,7 @@ struct _is {
190190
bool sys_trace_initialized;
191191
Py_ssize_t sys_profiling_threads; /* Count of threads with c_profilefunc set */
192192
Py_ssize_t sys_tracing_threads; /* Count of threads with c_tracefunc set */
193-
PyObject *monitoring_callables[PY_MONITORING_TOOL_IDS][PY_MONITORING_EVENTS];
193+
PyObject *monitoring_callables[PY_MONITORING_TOOL_IDS][_PY_MONITORING_EVENTS];
194194
PyObject *monitoring_tool_names[PY_MONITORING_TOOL_IDS];
195195

196196
struct _Py_interp_cached_objects cached_objects;

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ static int
19141914
do_monitor_exc(PyThreadState *tstate, _PyInterpreterFrame *frame,
19151915
_Py_CODEUNIT *instr, int event)
19161916
{
1917-
assert(event < PY_MONITORING_UNGROUPED_EVENTS);
1917+
assert(event < _PY_MONITORING_UNGROUPED_EVENTS);
19181918
PyObject *exc = PyErr_GetRaisedException();
19191919
assert(exc != NULL);
19201920
int err = _Py_call_instrumentation_arg(tstate, event, frame, instr, exc);

Python/instrumentation.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ is_instrumented(int opcode)
137137
static inline bool
138138
monitors_equals(_Py_Monitors a, _Py_Monitors b)
139139
{
140-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
140+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
141141
if (a.tools[i] != b.tools[i]) {
142142
return false;
143143
}
@@ -150,7 +150,7 @@ static inline _Py_Monitors
150150
monitors_sub(_Py_Monitors a, _Py_Monitors b)
151151
{
152152
_Py_Monitors res;
153-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
153+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
154154
res.tools[i] = a.tools[i] & ~b.tools[i];
155155
}
156156
return res;
@@ -161,7 +161,7 @@ static inline _Py_Monitors
161161
monitors_and(_Py_Monitors a, _Py_Monitors b)
162162
{
163163
_Py_Monitors res;
164-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
164+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
165165
res.tools[i] = a.tools[i] & b.tools[i];
166166
}
167167
return res;
@@ -172,7 +172,7 @@ static inline _Py_Monitors
172172
monitors_or(_Py_Monitors a, _Py_Monitors b)
173173
{
174174
_Py_Monitors res;
175-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
175+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
176176
res.tools[i] = a.tools[i] | b.tools[i];
177177
}
178178
return res;
@@ -181,7 +181,7 @@ monitors_or(_Py_Monitors a, _Py_Monitors b)
181181
static inline bool
182182
monitors_are_empty(_Py_Monitors m)
183183
{
184-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
184+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
185185
if (m.tools[i]) {
186186
return false;
187187
}
@@ -192,7 +192,7 @@ monitors_are_empty(_Py_Monitors m)
192192
static inline bool
193193
multiple_tools(_Py_Monitors *m)
194194
{
195-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
195+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
196196
if (_Py_popcount32(m->tools[i]) > 1) {
197197
return true;
198198
}
@@ -204,7 +204,7 @@ static inline _PyMonitoringEventSet
204204
get_events(_Py_Monitors *m, int tool_id)
205205
{
206206
_PyMonitoringEventSet result = 0;
207-
for (int e = 0; e < PY_MONITORING_UNGROUPED_EVENTS; e++) {
207+
for (int e = 0; e < _PY_MONITORING_UNGROUPED_EVENTS; e++) {
208208
if ((m->tools[e] >> tool_id) & 1) {
209209
result |= (1 << e);
210210
}
@@ -339,7 +339,7 @@ static void
339339
dump_monitors(const char *prefix, _Py_Monitors monitors, FILE*out)
340340
{
341341
fprintf(out, "%s monitors:\n", prefix);
342-
for (int event = 0; event < PY_MONITORING_UNGROUPED_EVENTS; event++) {
342+
for (int event = 0; event < _PY_MONITORING_UNGROUPED_EVENTS; event++) {
343343
fprintf(out, " Event %d: Tools %x\n", event, monitors.tools[event]);
344344
}
345345
}
@@ -907,7 +907,7 @@ get_tools_for_instruction(PyCodeObject *code, PyInterpreterState *interp, int i,
907907
uint8_t tools;
908908
assert(event != PY_MONITORING_EVENT_LINE);
909909
assert(event != PY_MONITORING_EVENT_INSTRUCTION);
910-
if (event >= PY_MONITORING_UNGROUPED_EVENTS) {
910+
if (event >= _PY_MONITORING_UNGROUPED_EVENTS) {
911911
assert(event == PY_MONITORING_EVENT_C_RAISE ||
912912
event == PY_MONITORING_EVENT_C_RETURN);
913913
event = PY_MONITORING_EVENT_CALL;
@@ -1220,7 +1220,7 @@ _PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj)
12201220
{
12211221
PyInterpreterState *is = _PyInterpreterState_GET();
12221222
assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
1223-
assert(0 <= event_id && event_id < PY_MONITORING_EVENTS);
1223+
assert(0 <= event_id && event_id < _PY_MONITORING_EVENTS);
12241224
PyObject *callback = is->monitoring_callables[tool_id][event_id];
12251225
is->monitoring_callables[tool_id][event_id] = Py_XNewRef(obj);
12261226
return callback;
@@ -1653,7 +1653,7 @@ static void
16531653
set_events(_Py_Monitors *m, int tool_id, _PyMonitoringEventSet events)
16541654
{
16551655
assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
1656-
for (int e = 0; e < PY_MONITORING_UNGROUPED_EVENTS; e++) {
1656+
for (int e = 0; e < _PY_MONITORING_UNGROUPED_EVENTS; e++) {
16571657
uint8_t *tools = &m->tools[e];
16581658
int val = (events >> e) & 1;
16591659
*tools &= ~(1 << tool_id);
@@ -1678,7 +1678,7 @@ _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events)
16781678
{
16791679
assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
16801680
PyInterpreterState *interp = _PyInterpreterState_GET();
1681-
assert(events < (1 << PY_MONITORING_UNGROUPED_EVENTS));
1681+
assert(events < (1 << _PY_MONITORING_UNGROUPED_EVENTS));
16821682
if (check_tool(interp, tool_id)) {
16831683
return -1;
16841684
}
@@ -1696,7 +1696,7 @@ _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEvent
16961696
{
16971697
assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
16981698
PyInterpreterState *interp = _PyInterpreterState_GET();
1699-
assert(events < (1 << PY_MONITORING_UNGROUPED_EVENTS));
1699+
assert(events < (1 << _PY_MONITORING_UNGROUPED_EVENTS));
17001700
if (check_tool(interp, tool_id)) {
17011701
return -1;
17021702
}
@@ -1835,7 +1835,7 @@ monitoring_register_callback_impl(PyObject *module, int tool_id, int event,
18351835
return NULL;
18361836
}
18371837
int event_id = _Py_bit_length(event)-1;
1838-
if (event_id < 0 || event_id >= PY_MONITORING_EVENTS) {
1838+
if (event_id < 0 || event_id >= _PY_MONITORING_EVENTS) {
18391839
PyErr_Format(PyExc_ValueError, "invalid event %d", event);
18401840
return NULL;
18411841
}
@@ -1885,7 +1885,7 @@ monitoring_set_events_impl(PyObject *module, int tool_id, int event_set)
18851885
if (check_valid_tool(tool_id)) {
18861886
return NULL;
18871887
}
1888-
if (event_set < 0 || event_set >= (1 << PY_MONITORING_EVENTS)) {
1888+
if (event_set < 0 || event_set >= (1 << _PY_MONITORING_EVENTS)) {
18891889
PyErr_Format(PyExc_ValueError, "invalid event set 0x%x", event_set);
18901890
return NULL;
18911891
}
@@ -1927,7 +1927,7 @@ monitoring_get_local_events_impl(PyObject *module, int tool_id,
19271927
_PyMonitoringEventSet event_set = 0;
19281928
_PyCoMonitoringData *data = ((PyCodeObject *)code)->_co_monitoring;
19291929
if (data != NULL) {
1930-
for (int e = 0; e < PY_MONITORING_UNGROUPED_EVENTS; e++) {
1930+
for (int e = 0; e < _PY_MONITORING_UNGROUPED_EVENTS; e++) {
19311931
if ((data->local_monitors.tools[e] >> tool_id) & 1) {
19321932
event_set |= (1 << e);
19331933
}
@@ -1961,7 +1961,7 @@ monitoring_set_local_events_impl(PyObject *module, int tool_id,
19611961
if (check_valid_tool(tool_id)) {
19621962
return NULL;
19631963
}
1964-
if (event_set < 0 || event_set >= (1 << PY_MONITORING_EVENTS)) {
1964+
if (event_set < 0 || event_set >= (1 << _PY_MONITORING_EVENTS)) {
19651965
PyErr_Format(PyExc_ValueError, "invalid event set 0x%x", event_set);
19661966
return NULL;
19671967
}
@@ -2042,7 +2042,7 @@ monitoring__all_events_impl(PyObject *module)
20422042
if (res == NULL) {
20432043
return NULL;
20442044
}
2045-
for (int e = 0; e < PY_MONITORING_UNGROUPED_EVENTS; e++) {
2045+
for (int e = 0; e < _PY_MONITORING_UNGROUPED_EVENTS; e++) {
20462046
uint8_t tools = interp->monitors.tools[e];
20472047
if (tools == 0) {
20482048
continue;
@@ -2101,7 +2101,7 @@ PyObject *_Py_CreateMonitoringObject(void)
21012101
if (err) {
21022102
goto error;
21032103
}
2104-
for (int i = 0; i < PY_MONITORING_EVENTS; i++) {
2104+
for (int i = 0; i < _PY_MONITORING_EVENTS; i++) {
21052105
if (add_power2_constant(events, event_names[i], i)) {
21062106
goto error;
21072107
}

Python/pystate.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,11 @@ init_interpreter(PyInterpreterState *interp,
679679
_PyGC_InitState(&interp->gc);
680680
PyConfig_InitPythonConfig(&interp->config);
681681
_PyType_InitCache(interp);
682-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
682+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
683683
interp->monitors.tools[i] = 0;
684684
}
685685
for (int t = 0; t < PY_MONITORING_TOOL_IDS; t++) {
686-
for (int e = 0; e < PY_MONITORING_EVENTS; e++) {
686+
for (int e = 0; e < _PY_MONITORING_EVENTS; e++) {
687687
interp->monitoring_callables[t][e] = NULL;
688688

689689
}
@@ -841,11 +841,11 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
841841

842842
Py_CLEAR(interp->audit_hooks);
843843

844-
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
844+
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
845845
interp->monitors.tools[i] = 0;
846846
}
847847
for (int t = 0; t < PY_MONITORING_TOOL_IDS; t++) {
848-
for (int e = 0; e < PY_MONITORING_EVENTS; e++) {
848+
for (int e = 0; e < _PY_MONITORING_EVENTS; e++) {
849849
Py_CLEAR(interp->monitoring_callables[t][e]);
850850
}
851851
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy