Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Include/internal/pycore_atexit.h
12 views
1
#ifndef Py_INTERNAL_ATEXIT_H
2
#define Py_INTERNAL_ATEXIT_H
3
#ifdef __cplusplus
4
extern "C" {
5
#endif
6
7
#ifndef Py_BUILD_CORE
8
# error "this header requires Py_BUILD_CORE define"
9
#endif
10
11
12
//###############
13
// runtime atexit
14
15
typedef void (*atexit_callbackfunc)(void);
16
17
struct _atexit_runtime_state {
18
PyThread_type_lock mutex;
19
#define NEXITFUNCS 32
20
atexit_callbackfunc callbacks[NEXITFUNCS];
21
int ncallbacks;
22
};
23
24
25
//###################
26
// interpreter atexit
27
28
struct atexit_callback;
29
typedef struct atexit_callback {
30
atexit_datacallbackfunc func;
31
void *data;
32
struct atexit_callback *next;
33
} atexit_callback;
34
35
typedef struct {
36
PyObject *func;
37
PyObject *args;
38
PyObject *kwargs;
39
} atexit_py_callback;
40
41
struct atexit_state {
42
atexit_callback *ll_callbacks;
43
atexit_callback *last_ll_callback;
44
45
// XXX The rest of the state could be moved to the atexit module state
46
// and a low-level callback added for it during module exec.
47
// For the moment we leave it here.
48
atexit_py_callback **callbacks;
49
int ncallbacks;
50
int callback_len;
51
};
52
53
54
#ifdef __cplusplus
55
}
56
#endif
57
#endif /* !Py_INTERNAL_ATEXIT_H */
58
59