8000 Stackless issue #283: Concentrate platform code in slp_transfer.c · akruis/cpython@aab7c93 · GitHub
[go: up one dir, main page]

Skip to content

Commit aab7c93

Browse files
author
Anselm Kruis
committed
Stackless issue python#283: Concentrate platform code in slp_transfer.c
Integrate include "pycore_slp_platformselect.h" into slp_transfer.c and remove this include.
1 parent a5e69d5 commit aab7c93

File tree

5 files changed

+79
-94
lines changed

5 files changed

+79
-94
lines changed

Include/internal/pycore_slp_platformselect.h

Lines changed: 0 additions & 73 deletions
This file was deleted.

Makefile.pre.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,6 @@ PYTHON_HEADERS= \
10931093
$(srcdir)/Include/internal/pycore_stackless.h \
10941094
$(srcdir)/Include/internal/pycore_slp_pystate.h \
10951095
$(srcdir)/Include/internal/pycore_slp_prickelpit.h \
1096-
$(srcdir)/Include/internal/pycore_slp_platformselect.h \
10971096
$(srcdir)/Include/internal/pycore_slp_switch_amd64_unix.h \
10981097
$(srcdir)/Include/internal/pycore_slp_switch_arm32_gcc.h \
10991098
$(srcdir)/Include/internal/pycore_slp_switch_arm_thumb_gcc.h \

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@
238238
<ClInclude Include="..\Include\internal\pycore_stackless.h" />
239239
<ClInclude Include="..\Include\internal\pycore_slp_pystate.h" />
240240
<ClInclude Include="..\Include\internal\pycore_slp_prickelpit.h" />
241-
<ClInclude Include="..\Include\internal\pycore_slp_platformselect.h" />
242241
<ClInclude Include="..\Include\internal\pycore_slp_switch_x64_msvc.h" />
243242
<ClInclude Include="..\Include\internal\pycore_slp_switch_x86_msvc.h" />
244243
<ClInclude Include="..\Include\stackless.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,6 @@
525525
<ClInclude Include="..\Include\internal\pycore_slp_pystate.h">
526526
<Filter>Include</Filter>
527527
</ClInclude>
528-
<ClInclude Include="..\Include\internal\pycore_slp_platformselect.h">
529-
<Filter>Include</Filter>
530-
</ClInclude>
531528
<ClInclude Include="..\Include\internal\pycore_slp_switch_x64_msvc.h">
532529
<Filter>Include</Filter>
533530
</ClInclude>

Stackless/core/slp_transfer.c

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,37 @@
3535
}
3636

3737
/*
38-
* Include pycore_slp_platformselect.h with SLP_EVAL defined.
39-
* If the macro SLP_EVAL is defined, pycore_slp_platformselect.h defines
40-
* the static function int slp_switch(void).
38+
* Platform Selection for Stackless
4139
*/
42-
#define SLP_EVAL
43-
#ifdef PYCORE_SLP_PLATFORMSELECT_H
44-
#undef PYCORE_SLP_PLATFORMSELECT_H
40+
#define SLP_EVAL /* enable code generation in the included header */
41+
42+
#if defined(MS_WIN32) && !defined(MS_WIN64) && defined(_M_IX86)
43+
#include "pycore_slp_switch_x86_msvc.h" /* MS Visual Studio on X86 */
44+
#elif defined(MS_WIN64) && defined(_M_X64)
45+
#include "pycore_slp_switch_x64_msvc.h" /* MS Visual Studio on X64 */
46+
#elif defined(__GNUC__) && defined(__i386__)
47+
#include "pycore_slp_switch_x86_unix.h" /* gcc on X86 */
48+
#elif defined(__GNUC__) && defined(__amd64__)
49+
#include "pycore_slp_switch_amd64_unix.h" /* gcc on amd64 */
50+
#elif defined(__GNUC__) && defined(__PPC__) && defined(__linux__)
51+
#include "pycore_slp_switch_ppc_unix.h" /* gcc on PowerPC */
52+
#elif defined(__GNUC__) && defined(__ppc__) && defined(__APPLE__)
53+
#include "pycore_slp_switch_ppc_macosx.h" /* Apple MacOS X on PowerPC */
54+
#elif defined(__GNUC__) && defined(sparc) && defined(sun)
55+
#include "pycore_slp_switch_sparc_sun_gcc.h" /* SunOS sparc with gcc */
56+
#elif defined(__GNUC__) && defined(__s390__) && defined(__linux__)
57+
#include "pycore_slp_switch_s390_unix.h" /* Linux/S390 */
58+
#elif defined(__GNUC__) && defined(__s390x__) && defined(__linux__)
59+
#include "pycore_slp_switch_s390_unix.h" /* Linux/S390 zSeries (identical) */
60+
#elif defined(__GNUC__) && defined(__arm__) && defined(__thumb__)
61+
#include "pycore_slp_switch_arm_thumb_gcc.h" /* gcc using arm thumb */
62+
#elif defined(__GNUC__) && defined(__arm32__)
63+
#include "pycore_slp_switch_arm32_gcc.h" /* gcc using arm32 */
64+
#elif defined(__GNUC__) && defined(__mips__) && defined(__linux__)
65+
#include "pycore_slp_switch_mips_unix.h" /* MIPS */
66+
#elif defined(SN_TARGET_PS3)
67+
#include "pycore_slp_switch_ps3_SNTools.h" /* Sony PS3 */
4568
#endif
46-
#include "pycore_slp_platformselect.h"
47-
4869
#ifndef STACKLESS
4970
**********
5071
If you see this error message,
@@ -54,6 +75,30 @@ or disable the STACKLESS flag.
5475
**********
5576
#endif
5677

78+
/* default definitions if not defined in above files */
79+
80+
81+
/* a good estimate how much the cstack level differs between
82+
initialisation and main C-Python(r) code. Not critical, but saves time.
83+
Note that this will vanish with the greenlet approach. */
84+
85+
#ifndef SLP_CSTACK_GOODGAP
86+
#define SLP_CSTACK_GOODGAP 4096
87+
#endif
88+
89+
/* stack size in pointer to trigger stack spilling */
90+
91+
#ifndef SLP_CSTACK_WATERMARK
92+
#define SLP_CSTACK_WATERMARK 16384
93+
#endif
94+
95+
/* define direction of stack growth */
96+
97+
#ifndef SLP_CSTACK_DOWNWARDS
98+
#define SLP_CSTACK_DOWNWARDS 1 /* 0 for upwards */
99+
#endif
100+
101+
57102
/*
58103
* Call SLP_DO_NOT_OPTIMIZE_AWAY(pointer) to ensure that pointer will be
59104
* computed even post-optimization. Use it for pointers that are computed but
@@ -101,6 +146,24 @@ extern uint8_t* volatile slp_do_not_opimize_away_sink;
101146
#endif
102147
#endif /* #ifndef SLP_DO_NOT_OPTIMIZE_AWAY */
103148

149+
/**************************************************************
150+
151+
Don't change definitions below, please.
152+
153+
**************************************************************/
154+
155+
#if SLP_CSTACK_DOWNWARDS == 1
156+
#define SLP_CSTACK_COMPARE(a, b) (a) < (b)
157+
#define SLP_CSTACK_SUBTRACT(a, b) (a) - (b)
158+
#else
159+
#define SLP_CSTACK_COMPARE(a, b) (a) > (b)
160+
#define SLP_CSTACK_SUBTRACT(a, b) (b) - (a)
161+
#endif
162+
163+
/**************************************************************
164+
* End of definitions
165+
***************************************************************/
166+
104167
SLP_DO_NOT_OPTIMIZE_AWAY_DEFINITIONS
105168

106169
#ifdef SLP_EXTERNAL_ASM
@@ -262,6 +325,14 @@ slp_transfer(PyCStackObject **cstprev, PyCStackObject *cst,
262325
return result;
263326
}
264327

328+
#ifdef Py_DEBUG
329+
int
330+
slp_transfer_return(PyCStackObject *cst)
331+
{
332+
return slp_transfer(NULL, cst, NULL);
333+
}
334+
#endif
335+
265336
int
266337
slp_cstack_save_now(const PyThreadState *tstate, const void * pstackvar)
267338
{
@@ -293,12 +364,4 @@ slp_cstack_set_base_and_goodgap(PyThreadState *tstate, const void * pstackvar, P
293364
return (void *)1;
294365
}
295366

296-
#ifdef Py_DEBUG
297-
int
298-
slp_transfer_return(PyCStackObject *cst)
299-
{
300-
return slp_transfer(NULL, cst, NULL);
301-
}
302-
#endif
303-
304367
#endif

0 commit comments

Comments
 (0)
0