Skip to content

Commit 1a6630d

Browse files
Anselm KruisAnselm Kruis
Anselm Kruis
authored and
Anselm Kruis
committed
Stackless issue python#185: cleanup header files for runtime state.
Move the definition of struct _stackless_runtime_state from stackless_tstate.h to the new file stackless_pystate.h. Now internal/pystate.h includes stackless_pystate.h and pystate.h includes stackless_tstate.h.
1 parent 3c7c314 commit 1a6630d

File tree

7 files changed

+68
-41
lines changed

7 files changed

+68
-41
lines changed

Include/internal/pystate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ extern "C" {
1212
#include "internal/ceval.h"
1313
#include "internal/warnings.h"
1414

15+
#ifdef STACKLESS
16+
#include "core/stackless_pystate.h"
17+
#endif
1518

1619
/* GIL state */
1720

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ PYTHON_HEADERS= \
10471047
$(srcdir)/Stackless/core/stackless_impl.h \
10481048
$(srcdir)/Stackless/core/stackless_structs.h \
10491049
$(srcdir)/Stackless/core/stackless_tstate.h \
1050+
$(srcdir)/Stackless/core/stackless_pystate.h \
10501051
$(srcdir)/Stackless/module/channelobject.h \
10511052
$(srcdir)/Stackless/pickling/prickelpit.h \
10521053
$(srcdir)/Stackless/platf/slp_platformselect.h \

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
<ClInclude Include="..\Stackless\core\stackless_methods.h" />
220220
<ClInclude Include="..\Stackless\core\stackless_structs.h" />
221221
<ClInclude Include="..\Stackless\core\stackless_tstate.h" />
222+
<ClInclude Include="..\Stackless\core\stackless_pystate.h" />
222223
<ClInclude Include="..\Stackless\module\channelobject.h" />
223224
<ClInclude Include="..\Stackless\pickling\prickelpit.h" />
224225
<ClInclude Include="..\Stackless\platf\slp_platformselect.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@
474474
<ClInclude Include="..\Stackless\core\stackless_tstate.h">
475475
<Filter>Stackless\core</Filter>
476476
</ClInclude>
477+
<ClInclude Include="..\Stackless\core\stackless_pystate.h">
478+
<Filter>Stackless\core</Filter>
479+
</ClInclude>
477480
<ClInclude Include="..\Stackless\module\channelobject.h">
478481
<Filter>Stackless\module</Filter>
479482
</ClInclude>

Stackless/core/stackless_pystate.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 */

Stackless/core/stackless_tstate.h

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#ifndef Py_LIMITED_API
1+
/* This include file is included from pystate.h only */
22

3-
#ifdef Py_BUILD_CORE
4-
#include "platf/slp_platformselect.h"
5-
#endif
3+
#ifndef Py_LIMITED_API
64

75
/*** addition to tstate ***/
86
#ifdef Py_DEBUG
@@ -187,41 +185,5 @@ void slp_kill_tasks_with_stacks(struct _ts *tstate);
187185
tstate->st.thread.is_blocked = 0; \
188186
tstate->st.thread.is_idle = 0;
189187

190-
/*
191-
* Stackless runtime state
192-
*
193-
* Initialized by
194-
* void slp_initialize(struct _stackless_runtime_state * state)
195-
* in stackless_util.c
196-
*/
197-
struct _stackless_runtime_state {
198-
/*
199-
* flag whether the next call should try to be stackless.
200-
* The protocol is: This flag may be only set if the called
201-
* thing supports it. It doesn't matter whether it uses the
202-
* chance, but it *must* set it to zero before returning.
203-
* This flags in a way serves as a parameter that we don't have.
204-
*
205-
* As long as the GIL is shared between sub-interpreters,
206-
* try_stackless can be a field in the runtime state.
207-
*/
208-
int try_stackless;
209-
210-
/* Used to manage free C-stack objects, see stacklesseval.c */
211-
int cstack_cachecount;
212-
struct _cstack *cstack_cache[CSTACK_SLOTS];
213-
214-
/*
215-
* Used during a hard switch.
216-
*/
217-
struct {
218-
struct _cstack **cstprev;
219-
struct _cstack *cst;
220-
struct _tasklet *prev;
221-
} transfer;
222-
};
223-
224-
void slp_initialize(struct _stackless_runtime_state *);
225-
226188
#endif /* #ifdef Py_BUILD_CORE */
227189
#endif /* #ifndef Py_LIMITED_API */

Tools/msi/dev/dev_files.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<?endforeach ?>
6464

6565
<!-- Stackless\core\*.h -->
66-
<?foreach header in cframeobject.h;slp_exttype.h;stackless_impl.h;stackless_methods.h;stackless_structs.h;stackless_tstate.h?>
66+
<?foreach header in cframeobject.h;slp_exttype.h;stackless_impl.h;stackless_methods.h;stackless_structs.h;stackless_tstate.h;stackless_pystate.h?>
6767
<Component Id="include_Stackless_core_$(var.header)" Directory="include_Stackless_core" Guid="*">
6868
<File Id="include_Stackless_core_$(var.header)" Name="$(var.header)" Source="!(bindpath.src)Stackless\core\$(var.header)" />
6969
</Component>

0 commit comments

Comments
 (0)