Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:44

0001 #ifndef Py_INTERNAL_ATEXIT_H
0002 #define Py_INTERNAL_ATEXIT_H
0003 
0004 #include "pycore_lock.h"        // PyMutex
0005 
0006 #ifdef __cplusplus
0007 extern "C" {
0008 #endif
0009 
0010 #ifndef Py_BUILD_CORE
0011 #  error "this header requires Py_BUILD_CORE define"
0012 #endif
0013 
0014 
0015 //###############
0016 // runtime atexit
0017 
0018 typedef void (*atexit_callbackfunc)(void);
0019 
0020 struct _atexit_runtime_state {
0021     PyMutex mutex;
0022 #define NEXITFUNCS 32
0023     atexit_callbackfunc callbacks[NEXITFUNCS];
0024     int ncallbacks;
0025 };
0026 
0027 
0028 //###################
0029 // interpreter atexit
0030 
0031 typedef void (*atexit_datacallbackfunc)(void *);
0032 
0033 typedef struct atexit_callback {
0034     atexit_datacallbackfunc func;
0035     void *data;
0036     struct atexit_callback *next;
0037 } atexit_callback;
0038 
0039 typedef struct {
0040     PyObject *func;
0041     PyObject *args;
0042     PyObject *kwargs;
0043 } atexit_py_callback;
0044 
0045 struct atexit_state {
0046     atexit_callback *ll_callbacks;
0047     // Kept for ABI compatibility--do not use! (See GH-127791.)
0048     atexit_callback *last_ll_callback;
0049 
0050     // XXX The rest of the state could be moved to the atexit module state
0051     // and a low-level callback added for it during module exec.
0052     // For the moment we leave it here.
0053     atexit_py_callback **callbacks;
0054     int ncallbacks;
0055     int callback_len;
0056 };
0057 
0058 // Export for '_interpchannels' shared extension
0059 PyAPI_FUNC(int) _Py_AtExit(
0060     PyInterpreterState *interp,
0061     atexit_datacallbackfunc func,
0062     void *data);
0063 
0064 #ifdef __cplusplus
0065 }
0066 #endif
0067 #endif /* !Py_INTERNAL_ATEXIT_H */