pycore_atexit.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef Py_INTERNAL_ATEXIT_H
  2. #define Py_INTERNAL_ATEXIT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #ifndef Py_BUILD_CORE
  7. # error "this header requires Py_BUILD_CORE define"
  8. #endif
  9. //###############
  10. // runtime atexit
  11. typedef void (*atexit_callbackfunc)(void);
  12. struct _atexit_runtime_state {
  13. PyThread_type_lock mutex;
  14. #define NEXITFUNCS 32
  15. atexit_callbackfunc callbacks[NEXITFUNCS];
  16. int ncallbacks;
  17. };
  18. //###################
  19. // interpreter atexit
  20. struct atexit_callback;
  21. typedef struct atexit_callback {
  22. atexit_datacallbackfunc func;
  23. void *data;
  24. struct atexit_callback *next;
  25. } atexit_callback;
  26. typedef struct {
  27. PyObject *func;
  28. PyObject *args;
  29. PyObject *kwargs;
  30. } atexit_py_callback;
  31. struct atexit_state {
  32. atexit_callback *ll_callbacks;
  33. atexit_callback *last_ll_callback;
  34. // XXX The rest of the state could be moved to the atexit module state
  35. // and a low-level callback added for it during module exec.
  36. // For the moment we leave it here.
  37. atexit_py_callback **callbacks;
  38. int ncallbacks;
  39. int callback_len;
  40. };
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif /* !Py_INTERNAL_ATEXIT_H */