|
| 1 | +/* |
| 2 | + * Copyright 2018 Anselm Kruis <[email protected]> |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/* This include file is included from internal/pystate.h only */ |
| 18 | + |
| 19 | +#include "platf/slp_platformselect.h" /* for CSTACK_SLOTS */ |
| 20 | + |
| 21 | +/* |
| 22 | + * Stackless runtime state |
| 23 | + * |
| 24 | + * Initialized by |
| 25 | + * void slp_initialize(struct _stackless_runtime_state * state) |
| 26 | + * in stackless_util.c |
| 27 | + */ |
| 28 | +struct _stackless_runtime_state { |
| 29 | + /* |
| 30 | + * flag whether the next call should try to be stackless. |
| 31 | + * The protocol is: This flag may be only set if the called |
| 32 | + * thing supports it. It doesn't matter whether it uses the |
| 33 | + * chance, but it *must* set it to zero before returning. |
| 34 | + * This flags in a way serves as a parameter that we don't have. |
| 35 | + * |
| 36 | + * As long as the GIL is shared between sub-interpreters, |
| 37 | + * try_stackless can be a field in the runtime state. |
| 38 | + */ |
| 39 | + int try_stackless; |
| 40 | + |
| 41 | + /* Used to manage free C-stack objects, see stacklesseval.c */ |
| 42 | + int cstack_cachecount; |
| 43 | + struct _cstack *cstack_cache[CSTACK_SLOTS]; |
| 44 | + |
| 45 | + /* |
| 46 | + * Used during a hard switch. |
| 47 | + */ |
| 48 | + struct { |
| 49 | + struct _cstack **cstprev; |
| 50 | + struct _cstack *cst; |
| 51 | + struct _tasklet *prev; |
| 52 | + } transfer; |
| 53 | +}; |
| 54 | + |
| 55 | +#ifdef Py_BUILD_CORE |
| 56 | +void slp_initialize(struct _stackless_runtime_state *); |
| 57 | +#endif /* #ifdef Py_BUILD_CORE */ |
0 commit comments