/home/mdboom/Work/builds/cpython/Modules/clinic/gcmodule.c.h
Line | Count | Source (jump to first uncovered line) |
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 | { |
20 | return gc_enable_impl(module); |
21 | } |
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 | { |
38 | return gc_disable_impl(module); |
39 | } |
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 | { |
56 | PyObject *return_value = NULL; |
57 | int _return_value; |
58 | |
59 | _return_value = gc_isenabled_impl(module); |
60 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (60:9): [True: 0, False: 410]
Branch (60:34): [True: 0, False: 0]
|
61 | goto exit; |
62 | } |
63 | return_value = PyBool_FromLong((long)_return_value); |
64 | |
65 | exit: |
66 | return return_value; |
67 | } |
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_CAST(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 | { |
90 | PyObject *return_value = NULL; |
91 | static const char * const _keywords[] = {"generation", NULL}; |
92 | static _PyArg_Parser _parser = {NULL, _keywords, "collect", 0}; |
93 | PyObject *argsbuf[1]; |
94 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE3 (kwnames) : 012.4k ) - 0; Branch (94:36): [True: 3, False: 12.4k]
|
95 | int generation = NUM_GENERATIONS - 1; |
96 | Py_ssize_t _return_value; |
97 | |
98 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
99 | if (!args) { Branch (99:9): [True: 0, False: 12.4k]
|
100 | goto exit; |
101 | } |
102 | if (!noptargs) { Branch (102:9): [True: 12.1k, False: 306]
|
103 | goto skip_optional_pos; |
104 | } |
105 | generation = _PyLong_AsInt(args[0]); |
106 | if (generation == -1 && PyErr_Occurred()0 ) { Branch (106:9): [True: 0, False: 306]
Branch (106:29): [True: 0, False: 0]
|
107 | goto exit; |
108 | } |
109 | skip_optional_pos: |
110 | _return_value = gc_collect_impl(module, generation); |
111 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (111:9): [True: 0, False: 12.4k]
Branch (111:34): [True: 0, False: 0]
|
112 | goto exit; |
113 | } |
114 | return_value = PyLong_FromSsize_t(_return_value); |
115 | |
116 | exit: |
117 | return return_value; |
118 | } |
119 | |
120 | PyDoc_STRVAR(gc_set_debug__doc__, |
121 | "set_debug($module, flags, /)\n" |
122 | "--\n" |
123 | "\n" |
124 | "Set the garbage collection debugging flags.\n" |
125 | "\n" |
126 | " flags\n" |
127 | " An integer that can have the following bits turned on:\n" |
128 | " DEBUG_STATS - Print statistics during collection.\n" |
129 | " DEBUG_COLLECTABLE - Print collectable objects found.\n" |
130 | " DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects\n" |
131 | " found.\n" |
132 | " DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.\n" |
133 | " DEBUG_LEAK - Debug leaking programs (everything but STATS).\n" |
134 | "\n" |
135 | "Debugging information is written to sys.stderr."); |
136 | |
137 | #define GC_SET_DEBUG_METHODDEF \ |
138 | {"set_debug", (PyCFunction)gc_set_debug, METH_O, gc_set_debug__doc__}, |
139 | |
140 | static PyObject * |
141 | gc_set_debug_impl(PyObject *module, int flags); |
142 | |
143 | static PyObject * |
144 | gc_set_debug(PyObject *module, PyObject *arg) |
145 | { |
146 | PyObject *return_value = NULL; |
147 | int flags; |
148 | |
149 | flags = _PyLong_AsInt(arg); |
150 | if (flags == -1 && PyErr_Occurred()0 ) { Branch (150:9): [True: 0, False: 10]
Branch (150:24): [True: 0, False: 0]
|
151 | goto exit; |
152 | } |
153 | return_value = gc_set_debug_impl(module, flags); |
154 | |
155 | exit: |
156 | return return_value; |
157 | } |
158 | |
159 | PyDoc_STRVAR(gc_get_debug__doc__, |
160 | "get_debug($module, /)\n" |
161 | "--\n" |
162 | "\n" |
163 | "Get the garbage collection debugging flags."); |
164 | |
165 | #define GC_GET_DEBUG_METHODDEF \ |
166 | {"get_debug", (PyCFunction)gc_get_debug, METH_NOARGS, gc_get_debug__doc__}, |
167 | |
168 | static int |
169 | gc_get_debug_impl(PyObject *module); |
170 | |
171 | static PyObject * |
172 | gc_get_debug(PyObject *module, PyObject *Py_UNUSED(ignored)) |
173 | { |
174 | PyObject *return_value = NULL; |
175 | int _return_value; |
176 | |
177 | _return_value = gc_get_debug_impl(module); |
178 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (178:9): [True: 0, False: 5]
Branch (178:34): [True: 0, False: 0]
|
179 | goto exit; |
180 | } |
181 | return_value = PyLong_FromLong((long)_return_value); |
182 | |
183 | exit: |
184 | return return_value; |
185 | } |
186 | |
187 | PyDoc_STRVAR(gc_get_threshold__doc__, |
188 | "get_threshold($module, /)\n" |
189 | "--\n" |
190 | "\n" |
191 | "Return the current collection thresholds."); |
192 | |
193 | #define GC_GET_THRESHOLD_METHODDEF \ |
194 | {"get_threshold", (PyCFunction)gc_get_threshold, METH_NOARGS, gc_get_threshold__doc__}, |
195 | |
196 | static PyObject * |
197 | gc_get_threshold_impl(PyObject *module); |
198 | |
199 | static PyObject * |
200 | gc_get_threshold(PyObject *module, PyObject *Py_UNUSED(ignored)) |
201 | { |
202 | return gc_get_threshold_impl(module); |
203 | } |
204 | |
205 | PyDoc_STRVAR(gc_get_count__doc__, |
206 | "get_count($module, /)\n" |
207 | "--\n" |
208 | "\n" |
209 | "Return a three-tuple of the current collection counts."); |
210 | |
211 | #define GC_GET_COUNT_METHODDEF \ |
212 | {"get_count", (PyCFunction)gc_get_count, METH_NOARGS, gc_get_count__doc__}, |
213 | |
214 | static PyObject * |
215 | gc_get_count_impl(PyObject *module); |
216 | |
217 | static PyObject * |
218 | gc_get_count(PyObject *module, PyObject *Py_UNUSED(ignored)) |
219 | { |
220 | return gc_get_count_impl(module); |
221 | } |
222 | |
223 | PyDoc_STRVAR(gc_get_objects__doc__, |
224 | "get_objects($module, /, generation=None)\n" |
225 | "--\n" |
226 | "\n" |
227 | "Return a list of objects tracked by the collector (excluding the list returned).\n" |
228 | "\n" |
229 | " generation\n" |
230 | " Generation to extract the objects from.\n" |
231 | "\n" |
232 | "If generation is not None, return only the objects tracked by the collector\n" |
233 | "that are in that generation."); |
234 | |
235 | #define GC_GET_OBJECTS_METHODDEF \ |
236 | {"get_objects", _PyCFunction_CAST(gc_get_objects), METH_FASTCALL|METH_KEYWORDS, gc_get_objects__doc__}, |
237 | |
238 | static PyObject * |
239 | gc_get_objects_impl(PyObject *module, Py_ssize_t generation); |
240 | |
241 | static PyObject * |
242 | gc_get_objects(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
243 | { |
244 | PyObject *return_value = NULL; |
245 | static const char * const _keywords[] = {"generation", NULL}; |
246 | static _PyArg_Parser _parser = {NULL, _keywords, "get_objects", 0}; |
247 | PyObject *argsbuf[1]; |
248 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE13 (kwnames) : 09 ) - 0; Branch (248:36): [True: 13, False: 9]
|
249 | Py_ssize_t generation = -1; |
250 | |
251 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
252 | if (!args) { Branch (252:9): [True: 0, False: 22]
|
253 | goto exit; |
254 | } |
255 | if (!noptargs) { Branch (255:9): [True: 5, False: 17]
|
256 | goto skip_optional_pos; |
257 | } |
258 | if (!_Py_convert_optional_to_ssize_t(args[0], &generation)) { Branch (258:9): [True: 2, False: 15]
|
259 | goto exit; |
260 | } |
261 | skip_optional_pos: |
262 | return_value = gc_get_objects_impl(module, generation); |
263 | |
264 | exit: |
265 | return return_value; |
266 | } |
267 | |
268 | PyDoc_STRVAR(gc_get_stats__doc__, |
269 | "get_stats($module, /)\n" |
270 | "--\n" |
271 | "\n" |
272 | "Return a list of dictionaries containing per-generation statistics."); |
273 | |
274 | #define GC_GET_STATS_METHODDEF \ |
275 | {"get_stats", (PyCFunction)gc_get_stats, METH_NOARGS, gc_get_stats__doc__}, |
276 | |
277 | static PyObject * |
278 | gc_get_stats_impl(PyObject *module); |
279 | |
280 | static PyObject * |
281 | gc_get_stats(PyObject *module, PyObject *Py_UNUSED(ignored)) |
282 | { |
283 | return gc_get_stats_impl(module); |
284 | } |
285 | |
286 | PyDoc_STRVAR(gc_is_tracked__doc__, |
287 | "is_tracked($module, obj, /)\n" |
288 | "--\n" |
289 | "\n" |
290 | "Returns true if the object is tracked by the garbage collector.\n" |
291 | "\n" |
292 | "Simple atomic objects will return false."); |
293 | |
294 | #define GC_IS_TRACKED_METHODDEF \ |
295 | {"is_tracked", (PyCFunction)gc_is_tracked, METH_O, gc_is_tracked__doc__}, |
296 | |
297 | PyDoc_STRVAR(gc_is_finalized__doc__, |
298 | "is_finalized($module, obj, /)\n" |
299 | "--\n" |
300 | "\n" |
301 | "Returns true if the object has been already finalized by the GC."); |
302 | |
303 | #define GC_IS_FINALIZED_METHODDEF \ |
304 | {"is_finalized", (PyCFunction)gc_is_finalized, METH_O, gc_is_finalized__doc__}, |
305 | |
306 | PyDoc_STRVAR(gc_freeze__doc__, |
307 | "freeze($module, /)\n" |
308 | "--\n" |
309 | "\n" |
310 | "Freeze all current tracked objects and ignore them for future collections.\n" |
311 | "\n" |
312 | "This can be used before a POSIX fork() call to make the gc copy-on-write friendly.\n" |
313 | "Note: collection before a POSIX fork() call may free pages for future allocation\n" |
314 | "which can cause copy-on-write."); |
315 | |
316 | #define GC_FREEZE_METHODDEF \ |
317 | {"freeze", (PyCFunction)gc_freeze, METH_NOARGS, gc_freeze__doc__}, |
318 | |
319 | static PyObject * |
320 | gc_freeze_impl(PyObject *module); |
321 | |
322 | static PyObject * |
323 | gc_freeze(PyObject *module, PyObject *Py_UNUSED(ignored)) |
324 | { |
325 | return gc_freeze_impl(module); |
326 | } |
327 | |
328 | PyDoc_STRVAR(gc_unfreeze__doc__, |
329 | "unfreeze($module, /)\n" |
330 | "--\n" |
331 | "\n" |
332 | "Unfreeze all objects in the permanent generation.\n" |
333 | "\n" |
334 | "Put all objects in the permanent generation back into oldest generation."); |
335 | |
336 | #define GC_UNFREEZE_METHODDEF \ |
337 | {"unfreeze", (PyCFunction)gc_unfreeze, METH_NOARGS, gc_unfreeze__doc__}, |
338 | |
339 | static PyObject * |
340 | gc_unfreeze_impl(PyObject *module); |
341 | |
342 | static PyObject * |
343 | gc_unfreeze(PyObject *module, PyObject *Py_UNUSED(ignored)) |
344 | { |
345 | return gc_unfreeze_impl(module); |
346 | } |
347 | |
348 | PyDoc_STRVAR(gc_get_freeze_count__doc__, |
349 | "get_freeze_count($module, /)\n" |
350 | "--\n" |
351 | "\n" |
352 | "Return the number of objects in the permanent generation."); |
353 | |
354 | #define GC_GET_FREEZE_COUNT_METHODDEF \ |
355 | {"get_freeze_count", (PyCFunction)gc_get_freeze_count, METH_NOARGS, gc_get_freeze_count__doc__}, |
356 | |
357 | static Py_ssize_t |
358 | gc_get_freeze_count_impl(PyObject *module); |
359 | |
360 | static PyObject * |
361 | gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored)) |
362 | { |
363 | PyObject *return_value = NULL; |
364 | Py_ssize_t _return_value; |
365 | |
366 | _return_value = gc_get_freeze_count_impl(module); |
367 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (367:9): [True: 0, False: 2]
Branch (367:34): [True: 0, False: 0]
|
368 | goto exit; |
369 | } |
370 | return_value = PyLong_FromSsize_t(_return_value); |
371 | |
372 | exit: |
373 | return return_value; |
374 | } |
375 | /*[clinic end generated code: output=71f7136d6e3f2323 input=a9049054013a1b77]*/ |