/src/Python-3.8.3/Modules/clinic/gcmodule.c.h
Line  | Count  | Source  | 
1  |  | /*[clinic input]  | 
2  |  | preserve  | 
3  |  | [clinic start generated code]*/  | 
4  |  |  | 
5  |  | PyDoc_STRVAR(gc_enable__doc__,  | 
6  |  | "enable($module, /)\n"  | 
7  |  | "--\n"  | 
8  |  | "\n"  | 
9  |  | "Enable automatic garbage collection.");  | 
10  |  |  | 
11  |  | #define GC_ENABLE_METHODDEF    \  | 
12  |  |     {"enable", (PyCFunction)gc_enable, METH_NOARGS, gc_enable__doc__}, | 
13  |  |  | 
14  |  | static PyObject *  | 
15  |  | gc_enable_impl(PyObject *module);  | 
16  |  |  | 
17  |  | static PyObject *  | 
18  |  | gc_enable(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
19  | 0  | { | 
20  | 0  |     return gc_enable_impl(module);  | 
21  | 0  | }  | 
22  |  |  | 
23  |  | PyDoc_STRVAR(gc_disable__doc__,  | 
24  |  | "disable($module, /)\n"  | 
25  |  | "--\n"  | 
26  |  | "\n"  | 
27  |  | "Disable automatic garbage collection.");  | 
28  |  |  | 
29  |  | #define GC_DISABLE_METHODDEF    \  | 
30  |  |     {"disable", (PyCFunction)gc_disable, METH_NOARGS, gc_disable__doc__}, | 
31  |  |  | 
32  |  | static PyObject *  | 
33  |  | gc_disable_impl(PyObject *module);  | 
34  |  |  | 
35  |  | static PyObject *  | 
36  |  | gc_disable(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
37  | 0  | { | 
38  | 0  |     return gc_disable_impl(module);  | 
39  | 0  | }  | 
40  |  |  | 
41  |  | PyDoc_STRVAR(gc_isenabled__doc__,  | 
42  |  | "isenabled($module, /)\n"  | 
43  |  | "--\n"  | 
44  |  | "\n"  | 
45  |  | "Returns true if automatic garbage collection is enabled.");  | 
46  |  |  | 
47  |  | #define GC_ISENABLED_METHODDEF    \  | 
48  |  |     {"isenabled", (PyCFunction)gc_isenabled, METH_NOARGS, gc_isenabled__doc__}, | 
49  |  |  | 
50  |  | static int  | 
51  |  | gc_isenabled_impl(PyObject *module);  | 
52  |  |  | 
53  |  | static PyObject *  | 
54  |  | gc_isenabled(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
55  | 0  | { | 
56  | 0  |     PyObject *return_value = NULL;  | 
57  | 0  |     int _return_value;  | 
58  |  | 
  | 
59  | 0  |     _return_value = gc_isenabled_impl(module);  | 
60  | 0  |     if ((_return_value == -1) && PyErr_Occurred()) { | 
61  | 0  |         goto exit;  | 
62  | 0  |     }  | 
63  | 0  |     return_value = PyBool_FromLong((long)_return_value);  | 
64  |  | 
  | 
65  | 0  | exit:  | 
66  | 0  |     return return_value;  | 
67  | 0  | }  | 
68  |  |  | 
69  |  | PyDoc_STRVAR(gc_collect__doc__,  | 
70  |  | "collect($module, /, generation=2)\n"  | 
71  |  | "--\n"  | 
72  |  | "\n"  | 
73  |  | "Run the garbage collector.\n"  | 
74  |  | "\n"  | 
75  |  | "With no arguments, run a full collection.  The optional argument\n"  | 
76  |  | "may be an integer specifying which generation to collect.  A ValueError\n"  | 
77  |  | "is raised if the generation number is invalid.\n"  | 
78  |  | "\n"  | 
79  |  | "The number of unreachable objects is returned.");  | 
80  |  |  | 
81  |  | #define GC_COLLECT_METHODDEF    \  | 
82  |  |     {"collect", (PyCFunction)(void(*)(void))gc_collect, METH_FASTCALL|METH_KEYWORDS, gc_collect__doc__}, | 
83  |  |  | 
84  |  | static Py_ssize_t  | 
85  |  | gc_collect_impl(PyObject *module, int generation);  | 
86  |  |  | 
87  |  | static PyObject *  | 
88  |  | gc_collect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)  | 
89  | 0  | { | 
90  | 0  |     PyObject *return_value = NULL;  | 
91  | 0  |     static const char * const _keywords[] = {"generation", NULL}; | 
92  | 0  |     static _PyArg_Parser _parser = {NULL, _keywords, "collect", 0}; | 
93  | 0  |     PyObject *argsbuf[1];  | 
94  | 0  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;  | 
95  | 0  |     int generation = NUM_GENERATIONS - 1;  | 
96  | 0  |     Py_ssize_t _return_value;  | 
97  |  | 
  | 
98  | 0  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);  | 
99  | 0  |     if (!args) { | 
100  | 0  |         goto exit;  | 
101  | 0  |     }  | 
102  | 0  |     if (!noptargs) { | 
103  | 0  |         goto skip_optional_pos;  | 
104  | 0  |     }  | 
105  | 0  |     if (PyFloat_Check(args[0])) { | 
106  | 0  |         PyErr_SetString(PyExc_TypeError,  | 
107  | 0  |                         "integer argument expected, got float" );  | 
108  | 0  |         goto exit;  | 
109  | 0  |     }  | 
110  | 0  |     generation = _PyLong_AsInt(args[0]);  | 
111  | 0  |     if (generation == -1 && PyErr_Occurred()) { | 
112  | 0  |         goto exit;  | 
113  | 0  |     }  | 
114  | 0  | skip_optional_pos:  | 
115  | 0  |     _return_value = gc_collect_impl(module, generation);  | 
116  | 0  |     if ((_return_value == -1) && PyErr_Occurred()) { | 
117  | 0  |         goto exit;  | 
118  | 0  |     }  | 
119  | 0  |     return_value = PyLong_FromSsize_t(_return_value);  | 
120  |  | 
  | 
121  | 0  | exit:  | 
122  | 0  |     return return_value;  | 
123  | 0  | }  | 
124  |  |  | 
125  |  | PyDoc_STRVAR(gc_set_debug__doc__,  | 
126  |  | "set_debug($module, flags, /)\n"  | 
127  |  | "--\n"  | 
128  |  | "\n"  | 
129  |  | "Set the garbage collection debugging flags.\n"  | 
130  |  | "\n"  | 
131  |  | "  flags\n"  | 
132  |  | "    An integer that can have the following bits turned on:\n"  | 
133  |  | "      DEBUG_STATS - Print statistics during collection.\n"  | 
134  |  | "      DEBUG_COLLECTABLE - Print collectable objects found.\n"  | 
135  |  | "      DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects\n"  | 
136  |  | "        found.\n"  | 
137  |  | "      DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.\n"  | 
138  |  | "      DEBUG_LEAK - Debug leaking programs (everything but STATS).\n"  | 
139  |  | "\n"  | 
140  |  | "Debugging information is written to sys.stderr.");  | 
141  |  |  | 
142  |  | #define GC_SET_DEBUG_METHODDEF    \  | 
143  |  |     {"set_debug", (PyCFunction)gc_set_debug, METH_O, gc_set_debug__doc__}, | 
144  |  |  | 
145  |  | static PyObject *  | 
146  |  | gc_set_debug_impl(PyObject *module, int flags);  | 
147  |  |  | 
148  |  | static PyObject *  | 
149  |  | gc_set_debug(PyObject *module, PyObject *arg)  | 
150  | 0  | { | 
151  | 0  |     PyObject *return_value = NULL;  | 
152  | 0  |     int flags;  | 
153  |  | 
  | 
154  | 0  |     if (PyFloat_Check(arg)) { | 
155  | 0  |         PyErr_SetString(PyExc_TypeError,  | 
156  | 0  |                         "integer argument expected, got float" );  | 
157  | 0  |         goto exit;  | 
158  | 0  |     }  | 
159  | 0  |     flags = _PyLong_AsInt(arg);  | 
160  | 0  |     if (flags == -1 && PyErr_Occurred()) { | 
161  | 0  |         goto exit;  | 
162  | 0  |     }  | 
163  | 0  |     return_value = gc_set_debug_impl(module, flags);  | 
164  |  | 
  | 
165  | 0  | exit:  | 
166  | 0  |     return return_value;  | 
167  | 0  | }  | 
168  |  |  | 
169  |  | PyDoc_STRVAR(gc_get_debug__doc__,  | 
170  |  | "get_debug($module, /)\n"  | 
171  |  | "--\n"  | 
172  |  | "\n"  | 
173  |  | "Get the garbage collection debugging flags.");  | 
174  |  |  | 
175  |  | #define GC_GET_DEBUG_METHODDEF    \  | 
176  |  |     {"get_debug", (PyCFunction)gc_get_debug, METH_NOARGS, gc_get_debug__doc__}, | 
177  |  |  | 
178  |  | static int  | 
179  |  | gc_get_debug_impl(PyObject *module);  | 
180  |  |  | 
181  |  | static PyObject *  | 
182  |  | gc_get_debug(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
183  | 0  | { | 
184  | 0  |     PyObject *return_value = NULL;  | 
185  | 0  |     int _return_value;  | 
186  |  | 
  | 
187  | 0  |     _return_value = gc_get_debug_impl(module);  | 
188  | 0  |     if ((_return_value == -1) && PyErr_Occurred()) { | 
189  | 0  |         goto exit;  | 
190  | 0  |     }  | 
191  | 0  |     return_value = PyLong_FromLong((long)_return_value);  | 
192  |  | 
  | 
193  | 0  | exit:  | 
194  | 0  |     return return_value;  | 
195  | 0  | }  | 
196  |  |  | 
197  |  | PyDoc_STRVAR(gc_get_threshold__doc__,  | 
198  |  | "get_threshold($module, /)\n"  | 
199  |  | "--\n"  | 
200  |  | "\n"  | 
201  |  | "Return the current collection thresholds.");  | 
202  |  |  | 
203  |  | #define GC_GET_THRESHOLD_METHODDEF    \  | 
204  |  |     {"get_threshold", (PyCFunction)gc_get_threshold, METH_NOARGS, gc_get_threshold__doc__}, | 
205  |  |  | 
206  |  | static PyObject *  | 
207  |  | gc_get_threshold_impl(PyObject *module);  | 
208  |  |  | 
209  |  | static PyObject *  | 
210  |  | gc_get_threshold(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
211  | 0  | { | 
212  | 0  |     return gc_get_threshold_impl(module);  | 
213  | 0  | }  | 
214  |  |  | 
215  |  | PyDoc_STRVAR(gc_get_count__doc__,  | 
216  |  | "get_count($module, /)\n"  | 
217  |  | "--\n"  | 
218  |  | "\n"  | 
219  |  | "Return a three-tuple of the current collection counts.");  | 
220  |  |  | 
221  |  | #define GC_GET_COUNT_METHODDEF    \  | 
222  |  |     {"get_count", (PyCFunction)gc_get_count, METH_NOARGS, gc_get_count__doc__}, | 
223  |  |  | 
224  |  | static PyObject *  | 
225  |  | gc_get_count_impl(PyObject *module);  | 
226  |  |  | 
227  |  | static PyObject *  | 
228  |  | gc_get_count(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
229  | 0  | { | 
230  | 0  |     return gc_get_count_impl(module);  | 
231  | 0  | }  | 
232  |  |  | 
233  |  | PyDoc_STRVAR(gc_get_objects__doc__,  | 
234  |  | "get_objects($module, /, generation=None)\n"  | 
235  |  | "--\n"  | 
236  |  | "\n"  | 
237  |  | "Return a list of objects tracked by the collector (excluding the list returned).\n"  | 
238  |  | "\n"  | 
239  |  | "  generation\n"  | 
240  |  | "    Generation to extract the objects from.\n"  | 
241  |  | "\n"  | 
242  |  | "If generation is not None, return only the objects tracked by the collector\n"  | 
243  |  | "that are in that generation.");  | 
244  |  |  | 
245  |  | #define GC_GET_OBJECTS_METHODDEF    \  | 
246  |  |     {"get_objects", (PyCFunction)(void(*)(void))gc_get_objects, METH_FASTCALL|METH_KEYWORDS, gc_get_objects__doc__}, | 
247  |  |  | 
248  |  | static PyObject *  | 
249  |  | gc_get_objects_impl(PyObject *module, Py_ssize_t generation);  | 
250  |  |  | 
251  |  | static PyObject *  | 
252  |  | gc_get_objects(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)  | 
253  | 0  | { | 
254  | 0  |     PyObject *return_value = NULL;  | 
255  | 0  |     static const char * const _keywords[] = {"generation", NULL}; | 
256  | 0  |     static _PyArg_Parser _parser = {NULL, _keywords, "get_objects", 0}; | 
257  | 0  |     PyObject *argsbuf[1];  | 
258  | 0  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;  | 
259  | 0  |     Py_ssize_t generation = -1;  | 
260  |  | 
  | 
261  | 0  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);  | 
262  | 0  |     if (!args) { | 
263  | 0  |         goto exit;  | 
264  | 0  |     }  | 
265  | 0  |     if (!noptargs) { | 
266  | 0  |         goto skip_optional_pos;  | 
267  | 0  |     }  | 
268  | 0  |     if (!_Py_convert_optional_to_ssize_t(args[0], &generation)) { | 
269  | 0  |         goto exit;  | 
270  | 0  |     }  | 
271  | 0  | skip_optional_pos:  | 
272  | 0  |     return_value = gc_get_objects_impl(module, generation);  | 
273  |  | 
  | 
274  | 0  | exit:  | 
275  | 0  |     return return_value;  | 
276  | 0  | }  | 
277  |  |  | 
278  |  | PyDoc_STRVAR(gc_get_stats__doc__,  | 
279  |  | "get_stats($module, /)\n"  | 
280  |  | "--\n"  | 
281  |  | "\n"  | 
282  |  | "Return a list of dictionaries containing per-generation statistics.");  | 
283  |  |  | 
284  |  | #define GC_GET_STATS_METHODDEF    \  | 
285  |  |     {"get_stats", (PyCFunction)gc_get_stats, METH_NOARGS, gc_get_stats__doc__}, | 
286  |  |  | 
287  |  | static PyObject *  | 
288  |  | gc_get_stats_impl(PyObject *module);  | 
289  |  |  | 
290  |  | static PyObject *  | 
291  |  | gc_get_stats(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
292  | 0  | { | 
293  | 0  |     return gc_get_stats_impl(module);  | 
294  | 0  | }  | 
295  |  |  | 
296  |  | PyDoc_STRVAR(gc_is_tracked__doc__,  | 
297  |  | "is_tracked($module, obj, /)\n"  | 
298  |  | "--\n"  | 
299  |  | "\n"  | 
300  |  | "Returns true if the object is tracked by the garbage collector.\n"  | 
301  |  | "\n"  | 
302  |  | "Simple atomic objects will return false.");  | 
303  |  |  | 
304  |  | #define GC_IS_TRACKED_METHODDEF    \  | 
305  |  |     {"is_tracked", (PyCFunction)gc_is_tracked, METH_O, gc_is_tracked__doc__}, | 
306  |  |  | 
307  |  | PyDoc_STRVAR(gc_freeze__doc__,  | 
308  |  | "freeze($module, /)\n"  | 
309  |  | "--\n"  | 
310  |  | "\n"  | 
311  |  | "Freeze all current tracked objects and ignore them for future collections.\n"  | 
312  |  | "\n"  | 
313  |  | "This can be used before a POSIX fork() call to make the gc copy-on-write friendly.\n"  | 
314  |  | "Note: collection before a POSIX fork() call may free pages for future allocation\n"  | 
315  |  | "which can cause copy-on-write.");  | 
316  |  |  | 
317  |  | #define GC_FREEZE_METHODDEF    \  | 
318  |  |     {"freeze", (PyCFunction)gc_freeze, METH_NOARGS, gc_freeze__doc__}, | 
319  |  |  | 
320  |  | static PyObject *  | 
321  |  | gc_freeze_impl(PyObject *module);  | 
322  |  |  | 
323  |  | static PyObject *  | 
324  |  | gc_freeze(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
325  | 0  | { | 
326  | 0  |     return gc_freeze_impl(module);  | 
327  | 0  | }  | 
328  |  |  | 
329  |  | PyDoc_STRVAR(gc_unfreeze__doc__,  | 
330  |  | "unfreeze($module, /)\n"  | 
331  |  | "--\n"  | 
332  |  | "\n"  | 
333  |  | "Unfreeze all objects in the permanent generation.\n"  | 
334  |  | "\n"  | 
335  |  | "Put all objects in the permanent generation back into oldest generation.");  | 
336  |  |  | 
337  |  | #define GC_UNFREEZE_METHODDEF    \  | 
338  |  |     {"unfreeze", (PyCFunction)gc_unfreeze, METH_NOARGS, gc_unfreeze__doc__}, | 
339  |  |  | 
340  |  | static PyObject *  | 
341  |  | gc_unfreeze_impl(PyObject *module);  | 
342  |  |  | 
343  |  | static PyObject *  | 
344  |  | gc_unfreeze(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
345  | 0  | { | 
346  | 0  |     return gc_unfreeze_impl(module);  | 
347  | 0  | }  | 
348  |  |  | 
349  |  | PyDoc_STRVAR(gc_get_freeze_count__doc__,  | 
350  |  | "get_freeze_count($module, /)\n"  | 
351  |  | "--\n"  | 
352  |  | "\n"  | 
353  |  | "Return the number of objects in the permanent generation.");  | 
354  |  |  | 
355  |  | #define GC_GET_FREEZE_COUNT_METHODDEF    \  | 
356  |  |     {"get_freeze_count", (PyCFunction)gc_get_freeze_count, METH_NOARGS, gc_get_freeze_count__doc__}, | 
357  |  |  | 
358  |  | static Py_ssize_t  | 
359  |  | gc_get_freeze_count_impl(PyObject *module);  | 
360  |  |  | 
361  |  | static PyObject *  | 
362  |  | gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored))  | 
363  | 0  | { | 
364  | 0  |     PyObject *return_value = NULL;  | 
365  | 0  |     Py_ssize_t _return_value;  | 
366  |  | 
  | 
367  | 0  |     _return_value = gc_get_freeze_count_impl(module);  | 
368  | 0  |     if ((_return_value == -1) && PyErr_Occurred()) { | 
369  | 0  |         goto exit;  | 
370  | 0  |     }  | 
371  | 0  |     return_value = PyLong_FromSsize_t(_return_value);  | 
372  |  | 
  | 
373  | 0  | exit:  | 
374  | 0  |     return return_value;  | 
375  | 0  | }  | 
376  |  | /*[clinic end generated code: output=e40d384b1f0d513c input=a9049054013a1b77]*/  |