Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd00156a

Browse files
committed
gh-131776: Expose functions called from the interpreter loop via PyAPI_FUNC
1 parentc45e661 commitd00156a

8 files changed

+53
-31
lines changed

‎Include/internal/pycore_call.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ _PyObject_CallNoArgs(PyObject *func) {
186186
}
187187

188188

189-
externPyObject*const*
189+
PyAPI_FUNC(PyObject*const*)
190190
_PyStack_UnpackDict(PyThreadState*tstate,
191191
PyObject*const*args,Py_ssize_tnargs,
192192
PyObject*kwargs,PyObject**p_kwnames);
@@ -196,7 +196,7 @@ extern void _PyStack_UnpackDict_Free(
196196
Py_ssize_tnargs,
197197
PyObject*kwnames);
198198

199-
externvoid_PyStack_UnpackDict_FreeNoDecRef(
199+
PyAPI_FUNC(void)_PyStack_UnpackDict_FreeNoDecRef(
200200
PyObject*const*stack,
201201
PyObject*kwnames);
202202

‎Include/internal/pycore_ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ PyAPI_FUNC(int) _Py_CheckRecursiveCall(
208208
PyThreadState*tstate,
209209
constchar*where);
210210

211-
int_Py_CheckRecursiveCallPy(
211+
PyAPI_FUNC(int)_Py_CheckRecursiveCallPy(
212212
PyThreadState*tstate);
213213

214214
staticinlineint_Py_EnterRecursiveCallTstate(PyThreadState*tstate,

‎Include/internal/pycore_code.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ extern PyObject* _PyCode_GetFreevars(PyCodeObject *);
262262
externPyObject*_PyCode_GetCode(PyCodeObject*);
263263

264264
/** API for initializing the line number tables. */
265-
externint_PyCode_InitAddressRange(PyCodeObject*co,PyCodeAddressRange*bounds);
265+
PyAPI_FUNC(int)_PyCode_InitAddressRange(PyCodeObject*co,PyCodeAddressRange*bounds);
266266

267267
/** Out of process API for initializing the location table. */
268268
externvoid_PyLineTable_InitAddressRange(
@@ -272,7 +272,7 @@ extern void _PyLineTable_InitAddressRange(
272272
PyCodeAddressRange*range);
273273

274274
/** API for traversing the line number table. */
275-
externint_PyLineTable_NextAddressRange(PyCodeAddressRange*range);
275+
PyAPI_FUNC(int)_PyLineTable_NextAddressRange(PyCodeAddressRange*range);
276276
externint_PyLineTable_PreviousAddressRange(PyCodeAddressRange*range);
277277

278278
/** API for executors */
@@ -291,33 +291,34 @@ extern void _PyCode_Clear_Executors(PyCodeObject *code);
291291
#defineENABLE_SPECIALIZATION_FT ENABLE_SPECIALIZATION
292292
#endif
293293

294-
/* Specialization functions */
294+
/* Specialization functions, these are exported only for other re-generated
295+
* interpreters to call */
295296

296-
externvoid_Py_Specialize_LoadSuperAttr(_PyStackRefglobal_super,_PyStackRefcls,
297+
PyAPI_FUNC(void)_Py_Specialize_LoadSuperAttr(_PyStackRefglobal_super,_PyStackRefcls,
297298
_Py_CODEUNIT*instr,intload_method);
298-
externvoid_Py_Specialize_LoadAttr(_PyStackRefowner,_Py_CODEUNIT*instr,
299+
PyAPI_FUNC(void)_Py_Specialize_LoadAttr(_PyStackRefowner,_Py_CODEUNIT*instr,
299300
PyObject*name);
300-
externvoid_Py_Specialize_StoreAttr(_PyStackRefowner,_Py_CODEUNIT*instr,
301+
PyAPI_FUNC(void)_Py_Specialize_StoreAttr(_PyStackRefowner,_Py_CODEUNIT*instr,
301302
PyObject*name);
302-
externvoid_Py_Specialize_LoadGlobal(PyObject*globals,PyObject*builtins,
303+
PyAPI_FUNC(void)_Py_Specialize_LoadGlobal(PyObject*globals,PyObject*builtins,
303304
_Py_CODEUNIT*instr,PyObject*name);
304-
externvoid_Py_Specialize_StoreSubscr(_PyStackRefcontainer,_PyStackRefsub,
305+
PyAPI_FUNC(void)_Py_Specialize_StoreSubscr(_PyStackRefcontainer,_PyStackRefsub,
305306
_Py_CODEUNIT*instr);
306-
externvoid_Py_Specialize_Call(_PyStackRefcallable,_Py_CODEUNIT*instr,
307+
PyAPI_FUNC(void)_Py_Specialize_Call(_PyStackRefcallable,_Py_CODEUNIT*instr,
307308
intnargs);
308-
externvoid_Py_Specialize_CallKw(_PyStackRefcallable,_Py_CODEUNIT*instr,
309+
PyAPI_FUNC(void)_Py_Specialize_CallKw(_PyStackRefcallable,_Py_CODEUNIT*instr,
309310
intnargs);
310-
externvoid_Py_Specialize_BinaryOp(_PyStackReflhs,_PyStackRefrhs,_Py_CODEUNIT*instr,
311+
PyAPI_FUNC(void)_Py_Specialize_BinaryOp(_PyStackReflhs,_PyStackRefrhs,_Py_CODEUNIT*instr,
311312
intoparg,_PyStackRef*locals);
312-
externvoid_Py_Specialize_CompareOp(_PyStackReflhs,_PyStackRefrhs,
313+
PyAPI_FUNC(void)_Py_Specialize_CompareOp(_PyStackReflhs,_PyStackRefrhs,
313314
_Py_CODEUNIT*instr,intoparg);
314-
externvoid_Py_Specialize_UnpackSequence(_PyStackRefseq,_Py_CODEUNIT*instr,
315+
PyAPI_FUNC(void)_Py_Specialize_UnpackSequence(_PyStackRefseq,_Py_CODEUNIT*instr,
315316
intoparg);
316-
externvoid_Py_Specialize_ForIter(_PyStackRefiter,_Py_CODEUNIT*instr,intoparg);
317-
externvoid_Py_Specialize_Send(_PyStackRefreceiver,_Py_CODEUNIT*instr);
318-
externvoid_Py_Specialize_ToBool(_PyStackRefvalue,_Py_CODEUNIT*instr);
319-
externvoid_Py_Specialize_ContainsOp(_PyStackRefvalue,_Py_CODEUNIT*instr);
320-
externvoid_Py_GatherStats_GetIter(_PyStackRefiterable);
317+
PyAPI_FUNC(void)_Py_Specialize_ForIter(_PyStackRefiter,_Py_CODEUNIT*instr,intoparg);
318+
PyAPI_FUNC(void)_Py_Specialize_Send(_PyStackRefreceiver,_Py_CODEUNIT*instr);
319+
PyAPI_FUNC(void)_Py_Specialize_ToBool(_PyStackRefvalue,_Py_CODEUNIT*instr);
320+
PyAPI_FUNC(void)_Py_Specialize_ContainsOp(_PyStackRefvalue,_Py_CODEUNIT*instr);
321+
PyAPI_FUNC(void)_Py_GatherStats_GetIter(_PyStackRefiterable);
321322

322323
// Utility functions for reading/writing 32/64-bit values in the inline caches.
323324
// Great care should be taken to ensure that these functions remain correct and
@@ -509,7 +510,7 @@ typedef struct {
509510

510511
#defineCOMPARISON_NOT_EQUALS (COMPARISON_UNORDERED | COMPARISON_LESS_THAN | COMPARISON_GREATER_THAN)
511512

512-
externint_Py_Instrument(PyCodeObject*co,PyInterpreterState*interp);
513+
PyAPI_FUNC(int)_Py_Instrument(PyCodeObject*co,PyInterpreterState*interp);
513514

514515
extern_Py_CODEUNIT_Py_GetBaseCodeUnit(PyCodeObject*code,intoffset);
515516

‎Include/internal/pycore_dict.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ PyAPI_FUNC(int) _PyDict_SetItem_KnownHash_LockHeld(PyDictObject *mp, PyObject *k
142142
PyAPI_FUNC(int)_PyDict_GetItemRef_KnownHash_LockHeld(PyDictObject*op,PyObject*key,Py_hash_thash,PyObject**result);
143143
externint_PyDict_GetItemRef_KnownHash(PyDictObject*op,PyObject*key,Py_hash_thash,PyObject**result);
144144
externint_PyDict_GetItemRef_Unicode_LockHeld(PyDictObject*op,PyObject*key,PyObject**result);
145-
externint_PyObjectDict_SetItem(PyTypeObject*tp,PyObject*obj,PyObject**dictptr,PyObject*name,PyObject*value);
145+
PyAPI_FUNC(int)_PyObjectDict_SetItem(PyTypeObject*tp,PyObject*obj,PyObject**dictptr,PyObject*name,PyObject*value);
146146

147147
externint_PyDict_Pop_KnownHash(
148148
PyDictObject*dict,

‎Include/internal/pycore_genobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
3131
PyAPI_FUNC(int)_PyGen_FetchStopIterationValue(PyObject**);
3232

3333
PyAPI_FUNC(PyObject*)_PyCoro_GetAwaitableIter(PyObject*o);
34-
externPyObject*_PyAsyncGenValueWrapperNew(PyThreadState*state,PyObject*);
34+
PyAPI_FUNC(PyObject*)_PyAsyncGenValueWrapperNew(PyThreadState*state,PyObject*);
3535

3636
externPyTypeObject_PyCoroWrapper_Type;
3737
externPyTypeObject_PyAsyncGenWrappedValue_Type;

‎Include/internal/pycore_instruments.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,34 @@ int _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events);
3333
int_PyMonitoring_SetLocalEvents(PyCodeObject*code,inttool_id,_PyMonitoringEventSetevents);
3434
int_PyMonitoring_GetLocalEvents(PyCodeObject*code,inttool_id,_PyMonitoringEventSet*events);
3535

36-
externint
36+
37+
// these are exported only for other re-generated interpreters to call
38+
PyAPI_FUNC(int)
3739
_Py_call_instrumentation(PyThreadState*tstate,intevent,
3840
_PyInterpreterFrame*frame,_Py_CODEUNIT*instr);
3941

40-
externint
42+
PyAPI_FUNC(int)
4143
_Py_call_instrumentation_line(PyThreadState*tstate,_PyInterpreterFrame*frame,
4244
_Py_CODEUNIT*instr,_Py_CODEUNIT*prev);
4345

44-
externint
46+
PyAPI_FUNC(int)
4547
_Py_call_instrumentation_instruction(
4648
PyThreadState*tstate,_PyInterpreterFrame*frame,_Py_CODEUNIT*instr);
4749

48-
_Py_CODEUNIT*
50+
PyAPI_FUNC(_Py_CODEUNIT*)
4951
_Py_call_instrumentation_jump(
5052
_Py_CODEUNIT*instr,PyThreadState*tstate,intevent,
5153
_PyInterpreterFrame*frame,_Py_CODEUNIT*src,_Py_CODEUNIT*dest);
5254

53-
externint
55+
PyAPI_FUNC(int)
5456
_Py_call_instrumentation_arg(PyThreadState*tstate,intevent,
5557
_PyInterpreterFrame*frame,_Py_CODEUNIT*instr,PyObject*arg);
5658

57-
externint
59+
PyAPI_FUNC(int)
5860
_Py_call_instrumentation_2args(PyThreadState*tstate,intevent,
5961
_PyInterpreterFrame*frame,_Py_CODEUNIT*instr,PyObject*arg0,PyObject*arg1);
6062

61-
externvoid
63+
PyAPI_FUNC(void)
6264
_Py_call_instrumentation_exc2(PyThreadState*tstate,intevent,
6365
_PyInterpreterFrame*frame,_Py_CODEUNIT*instr,PyObject*arg0,PyObject*arg1);
6466

‎Include/internal/pycore_typeobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ _PyType_GetModuleState(PyTypeObject *type)
8989
// function
9090
PyAPI_FUNC(PyObject*)_PyType_GetDict(PyTypeObject*);
9191

92+
PyAPI_FUNC(PyObject*)_PyType_LookupSubclasses(PyTypeObject*);
93+
PyAPI_FUNC(PyObject*)_PyType_InitSubclasses(PyTypeObject*);
94+
9295
externPyObject*_PyType_GetBases(PyTypeObject*type);
9396
externPyObject*_PyType_GetMRO(PyTypeObject*type);
9497
externPyObject*_PyType_GetSubclasses(PyTypeObject*);

‎Objects/typeobject.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,22 @@ lookup_tp_subclasses(PyTypeObject *self)
650650
return (PyObject*)self->tp_subclasses;
651651
}
652652

653+
PyObject*
654+
_PyType_LookupSubclasses(PyTypeObject*self)
655+
{
656+
returnlookup_tp_subclasses(self);
657+
}
658+
659+
PyObject*
660+
_PyType_InitSubclasses(PyTypeObject*self)
661+
{
662+
PyObject*existing=lookup_tp_subclasses(self);
663+
if (existing!=NULL) {
664+
returnexisting;
665+
}
666+
returninit_tp_subclasses(self);
667+
}
668+
653669
int
654670
_PyType_HasSubclasses(PyTypeObject*self)
655671
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp