• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #define _RESOLVE_MODINIT_FUNC_NAME(NAME) \
3     PyInit_ ## NAME
4 #define RESOLVE_MODINIT_FUNC_NAME(NAME) \
5     _RESOLVE_MODINIT_FUNC_NAME(NAME)
6 
7 
8 static int
ensure_xid_class(PyTypeObject * cls,crossinterpdatafunc getdata)9 ensure_xid_class(PyTypeObject *cls, crossinterpdatafunc getdata)
10 {
11     //assert(cls->tp_flags & Py_TPFLAGS_HEAPTYPE);
12     return _PyCrossInterpreterData_RegisterClass(cls, getdata);
13 }
14 
15 #ifdef REGISTERS_HEAP_TYPES
16 static int
clear_xid_class(PyTypeObject * cls)17 clear_xid_class(PyTypeObject *cls)
18 {
19     return _PyCrossInterpreterData_UnregisterClass(cls);
20 }
21 #endif
22 
23 
24 static inline int64_t
_get_interpid(_PyCrossInterpreterData * data)25 _get_interpid(_PyCrossInterpreterData *data)
26 {
27     int64_t interpid;
28     if (data != NULL) {
29         interpid = _PyCrossInterpreterData_INTERPID(data);
30         assert(!PyErr_Occurred());
31     }
32     else {
33         interpid = PyInterpreterState_GetID(PyInterpreterState_Get());
34     }
35     return interpid;
36 }
37 
38 
39 /* unbound items ************************************************************/
40 
41 #ifdef HAS_UNBOUND_ITEMS
42 
43 #define UNBOUND_REMOVE 1
44 #define UNBOUND_ERROR 2
45 #define UNBOUND_REPLACE 3
46 
47 // It would also be possible to add UNBOUND_REPLACE where the replacement
48 // value is user-provided.  There would be some limitations there, though.
49 // Another possibility would be something like UNBOUND_COPY, where the
50 // object is released but the underlying data is copied (with the "raw"
51 // allocator) and used when the item is popped off the queue.
52 
53 static int
check_unbound(int unboundop)54 check_unbound(int unboundop)
55 {
56     switch (unboundop) {
57     case UNBOUND_REMOVE:
58     case UNBOUND_ERROR:
59     case UNBOUND_REPLACE:
60         return 1;
61     default:
62         return 0;
63     }
64 }
65 
66 #endif
67