pycore_context.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef Py_INTERNAL_CONTEXT_H
  2. #define Py_INTERNAL_CONTEXT_H
  3. #ifndef Py_BUILD_CORE
  4. # error "this header requires Py_BUILD_CORE define"
  5. #endif
  6. #include "pycore_hamt.h" /* PyHamtObject */
  7. extern PyTypeObject _PyContextTokenMissing_Type;
  8. /* runtime lifecycle */
  9. PyStatus _PyContext_Init(PyInterpreterState *);
  10. void _PyContext_Fini(PyInterpreterState *);
  11. /* other API */
  12. typedef struct {
  13. PyObject_HEAD
  14. } _PyContextTokenMissing;
  15. #ifndef WITH_FREELISTS
  16. // without freelists
  17. # define PyContext_MAXFREELIST 0
  18. #endif
  19. #ifndef PyContext_MAXFREELIST
  20. # define PyContext_MAXFREELIST 255
  21. #endif
  22. struct _Py_context_state {
  23. #if PyContext_MAXFREELIST > 0
  24. // List of free PyContext objects
  25. PyContext *freelist;
  26. int numfree;
  27. #endif
  28. };
  29. struct _pycontextobject {
  30. PyObject_HEAD
  31. PyContext *ctx_prev;
  32. PyHamtObject *ctx_vars;
  33. PyObject *ctx_weakreflist;
  34. int ctx_entered;
  35. };
  36. struct _pycontextvarobject {
  37. PyObject_HEAD
  38. PyObject *var_name;
  39. PyObject *var_default;
  40. PyObject *var_cached;
  41. uint64_t var_cached_tsid;
  42. uint64_t var_cached_tsver;
  43. Py_hash_t var_hash;
  44. };
  45. struct _pycontexttokenobject {
  46. PyObject_HEAD
  47. PyContext *tok_ctx;
  48. PyContextVar *tok_var;
  49. PyObject *tok_oldval;
  50. int tok_used;
  51. };
  52. #endif /* !Py_INTERNAL_CONTEXT_H */