Skip to content

Commit 855d4c1

Browse files
Anselm KruisAnselm Kruis
authored andcommitted
Stackless issue python#185: preliminarily resolve the name collision
caused by the previous merge commit. Move the definition of struct _stackless_runtime_state from stackless_structs.h to stackless_tstate.h and remove the include of stackless_structs.h from pystate.h. Resolve conflicts/warnigs caused by including "platf/slp_platformselect.h" into stackless_tstate.h Unfortunately the new test for subinterpreters still fails.
1 parent bc11911 commit 855d4c1

File tree

8 files changed

+44
-49
lines changed

8 files changed

+44
-49
lines changed

Include/internal/pystate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ extern "C" {
1111
#include "internal/mem.h"
1212
#include "internal/ceval.h"
1313
#include "internal/warnings.h"
14-
#include "core/stackless_structs.h"
1514

1615

1716
/* GIL state */

Modules/_pickle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifdef STACKLESS
1212
#define SLP_BUILD_CORE
1313
#include "core/stackless_impl.h"
14+
#include "platf/slp_platformselect.h" /* for stack saving */
1415
/* rename these because otherwise we will conflict with windows.h */
1516
#define FLOAT OP_FLOAT
1617
#define INT OP_INT

Stackless/core/stackless_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ int slp_schedule_task(PyObject **result,
691691
void slp_thread_unblock(PyThreadState *ts);
692692

693693
int slp_initialize_main_and_current(void);
694-
void slp_initialize(struct _stackless_runtime_state *);
695694

696695
/* setting the tasklet's tempval, optimized for no change */
697696

Stackless/core/stackless_structs.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extern "C" {
99
#define SLP_BUILD_CORE
1010
#endif
1111

12-
#include "platf/slp_platformselect.h"
1312
#include "frameobject.h"
1413

1514
#ifdef STACKLESS
@@ -261,39 +260,6 @@ PyAPI_DATA(PyTypeObject) PyChannel_Type;
261260
#define PyChannel_Check(op) PyObject_TypeCheck(op, &PyChannel_Type)
262261
#define PyChannel_CheckExact(op) (Py_TYPE(op) == PyChannel_TypePtr)
263262

264-
/*
265-
* Stackless runtime state
266-
*
267-
* Initialized by
268-
* void slp_initialize(struct _stackless_runtime_state * state)
269-
* in stackless_util.c
270-
*/
271-
struct _stackless_runtime_state {
272-
/*
273-
* flag whether the next call should try to be stackless.
274-
* The protocol is: This flag may be only set if the called
275-
* thing supports it. It doesn't matter whether it uses the
276-
* chance, but it *must* set it to zero before returning.
277-
* This flags in a way serves as a parameter that we don't have.
278-
*
279-
* As long as the GIL is shared between sub-interpreters,
280-
* try_stackless can be a field in the runtime state.
281-
*/
282-
int try_stackless;
283-
284-
/* Used to manage free C-stack objects, see stacklesseval.c */
285-
int cstack_cachecount;
286-
PyCStackObject *cstack_cache[CSTACK_SLOTS];
287-
288-
/*
289-
* Used during a hard switch.
290-
*/
291-
struct {
292-
PyCStackObject **cstprev;
293-
PyCStackObject *cst;
294-
PyTaskletObject *prev;
295-
} transfer;
296-
};
297263

298264
#else /* #ifdef SLP_BUILD_CORE */
299265

Stackless/core/stackless_tstate.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#ifndef Py_LIMITED_API
22

3+
#ifdef Py_BUILD_CORE
4+
#include "platf/slp_platformselect.h"
5+
#endif
6+
37
/*** addition to tstate ***/
48
#ifdef Py_DEBUG
59
#ifndef SLP_WITH_FRAME_REF_DEBUG
@@ -178,5 +182,41 @@ void slp_kill_tasks_with_stacks(struct _ts *tstate);
178182
tstate->st.thread.is_blocked = 0; \
179183
tstate->st.thread.is_idle = 0;
180184

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

Stackless/module/_teststackless.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
#include "Python.h"
1919
#include "stackless_api.h"
20+
#ifdef MS_WINDOWS
21+
#include "malloc.h" /* for alloca */
22+
#endif
2023

2124
/******************************************************
2225

Stackless/platf/switch_x64_msvc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#define STACKLESS_SPY
4545

4646
#ifdef IMPLEMENT_STACKLESSMODULE
47-
#include "Windows.h"
4847
#define CANNOT_READ_MEM(p, bytes) IsBadReadPtr(p, bytes)
4948

5049
static int IS_ON_STACK(void*p)

Stackless/platf/switch_x86_msvc.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@
2424

2525
#define SLP_USE_NATIVE_BITFIELD_LAYOUT 1
2626

27-
/* for the SEH things */
28-
#ifndef _WINDOWS_
29-
#define WIN32_LEAN_AND_MEAN
30-
#ifdef BYTE
31-
#undef BYTE
32-
#endif
33-
#ifdef Yield
34-
#undef Yield /* remove definition from Python_ast.h to avoid conflict */
35-
#endif
36-
#include <windows.h>
37-
#endif
3827
#define _SEH32
3928

4029
#define alloca _alloca
@@ -80,7 +69,6 @@ slp_switch(void)
8069
#define STACKLESS_SPY
8170

8271
#ifdef IMPLEMENT_STACKLESSMODULE
83-
#include "Windows.h"
8472
#define CANNOT_READ_MEM(p, bytes) IsBadReadPtr(p, bytes)
8573

8674
static int IS_ON_STACK(void*p)

0 commit comments

Comments
 (0)