Skip to content

Commit 58f239a

Browse files
committed
Stackless issue python#185: rename macros without Stackless prefix
Now all macros defined by Stackless start with SLP_ or STACKLESS_ or contain STACKLESS in their name.
1 parent 45e1f15 commit 58f239a

25 files changed

Lines changed: 129 additions & 123 deletions

‎Modules/_pickle.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,9 +3954,9 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
39543954
#ifdef STACKLESS
39553955
/* but we save the stack after a fixed watermark */
39563956
{
3957-
/* use a variable, because CSTACK_SAVE_NOW evaluates ts several times. */
3957+
/* use a variable, because SLP_CSTACK_SAVE_NOW evaluates ts several times. */
39583958
PyThreadState *ts = PyThreadState_GET();
3959-
if (CSTACK_SAVE_NOW(ts, self)) {
3959+
if (SLP_CSTACK_SAVE_NOW(ts, self)) {
39603960
int res;
39613961
if (Py_EnterRecursiveCall(" while pickling an object"))
39623962
return -1;

‎Python/ceval.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4032,7 +4032,7 @@ PyEval_EvalFrameEx_slp(PyFrameObject *f, int throwflag, PyObject *retval)
40324032
* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
40334033
*/
40344034

4035-
if (CSTACK_SAVE_NOW(tstate, f))
4035+
if (SLP_CSTACK_SAVE_NOW(tstate, f))
40364036
return slp_eval_frame_newstack(f, throwflag, retval);
40374037

40384038
/* push frame */

‎Stackless/core/cframeobject.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ static PyObject * run_cframe(PyFrameObject *f, int exc, PyObject *retval)
247247
return retval;
248248
}
249249

250-
DEF_INVALID_EXEC(run_cframe)
250+
SLP_DEF_INVALID_EXEC(run_cframe)
251251

252252
PyCFrameObject *
253253
slp_cframe_newfunc(PyObject *func, PyObject *args, PyObject *kwds, unsigned int linked)
@@ -326,7 +326,7 @@ int slp_init_cframetype(void)
326326
return -1;
327327
/* register the cframe exec func */
328328
return slp_register_execute(&PyCFrame_Type, "run_cframe",
329-
run_cframe, REF_INVALID_EXEC(run_cframe));
329+
run_cframe, SLP_REF_INVALID_EXEC(run_cframe));
330330
}
331331

332332
/* Clear out the free list */

‎Stackless/core/slp_transfer.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#define SLP_SAVE_STATE(stackref, stsizediff) \
2121
intptr_t stsizeb; \
22-
stackref += STACK_MAGIC; \
22+
stackref += SLP_STACK_MAGIC; \
2323
if (_cstprev != NULL) { \
2424
if (slp_cstack_new(_cstprev, (intptr_t *)stackref, _prev) == NULL) __return(-1); \
2525
stsizeb = slp_cstack_save(*_cstprev); \
@@ -52,10 +52,10 @@ or disable the STACKLESS flag.
5252

5353
SLP_DO_NOT_OPTIMIZE_AWAY_DEFINITIONS
5454

55-
#ifdef EXTERNAL_ASM
55+
#ifdef SLP_EXTERNAL_ASM
5656
/* CCP addition: Make these functions, to be called from assembler.
5757
* The token include file for the given platform should enable the
58-
* EXTERNAL_ASM define so that this is included.
58+
* SLP_EXTERNAL_ASM define so that this is included.
5959
*/
6060

6161
/* There are two cases where slp_save_state would return 0, the

‎Stackless/core/stackless_impl.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
#undef STACKLESS_SPY
2626
/*
2727
* if a platform wants to support self-inspection via _peek,
28-
* it must provide a function or macro CANNOT_READ_MEM(adr, len)
28+
* it must provide a function or macro SLP_CANNOT_READ_MEM(adr, len)
2929
* which allows to spy at memory without causing exceptions.
3030
* This would usually be done in place with the assembly macros.
3131
*/

‎Stackless/core/stackless_pystate.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* This include file is included from internal/pystate.h only */
1818

19-
#include "platf/slp_platformselect.h" /* for CSTACK_SLOTS */
19+
#include "platf/slp_platformselect.h" /* for SLP_CSTACK_SLOTS */
2020

2121
/*
2222
* Stackless runtime state
@@ -40,7 +40,7 @@ struct _stackless_runtime_state {
4040

4141
/* Used to manage free C-stack objects, see stacklesseval.c */
4242
int cstack_cachecount;
43-
struct _cstack *cstack_cache[CSTACK_SLOTS];
43+
struct _cstack *cstack_cache[SLP_CSTACK_SLOTS];
4444

4545
/*
4646
* Used during a hard switch.

‎Stackless/core/stackless_structs.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ typedef struct _cstack {
149149
struct _tasklet *task;
150150
int nesting_level;
151151
PyThreadState *tstate;
152-
#ifdef _SEH32
152+
#ifdef SLP_SEH32
153153
/* SEH handler on Win32
154154
* The correct type is DWORD, but we do not want to include <windows.h>.
155155
* Instead we use a compile time assertion to ensure, that we use an
@@ -159,7 +159,7 @@ typedef struct _cstack {
159159
#endif
160160
intptr_t *startaddr;
161161
intptr_t stack[
162-
#if defined(_WINDOWS_) && defined(_SEH32)
162+
#if defined(_WINDOWS_) && defined(SLP_SEH32)
163163
/* Assert the equivalence of DWORD and unsigned long. If <windows.h>
164164
* is included, _WINDOWS_ is defined.
165165
* Py_BUILD_ASSERT_EXPR needs an expression and this is the only one.

‎Stackless/core/stacklesseval.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void slp_cstack_cacheclear(void)
2828
int i;
2929
PyCStackObject *stack;
3030

31-
for (i=0; i < CSTACK_SLOTS; i++) {
31+
for (i=0; i < SLP_CSTACK_SLOTS; i++) {
3232
while ((_PyRuntime.st.cstack_cache)[i] != NULL) {
3333
stack = (_PyRuntime.st.cstack_cache)[i];
3434
(_PyRuntime.st.cstack_cache)[i] = (PyCStackObject *) stack->startaddr;
@@ -48,11 +48,11 @@ cstack_dealloc(PyCStackObject *cst)
4848
#ifdef Py_REF_DEBUG
4949
PyObject_Del(cst);
5050
#else
51-
if (Py_SIZE(cst) >= CSTACK_SLOTS) {
51+
if (Py_SIZE(cst) >= SLP_CSTACK_SLOTS) {
5252
PyObject_Del(cst);
5353
}
5454
else {
55-
if ((_PyRuntime.st.cstack_cachecount) >= CSTACK_MAXCACHE)
55+
if ((_PyRuntime.st.cstack_cachecount) >= SLP_CSTACK_MAXCACHE)
5656
slp_cstack_cacheclear();
5757
cst->startaddr = (intptr_t *) (_PyRuntime.st.cstack_cache)[Py_SIZE(cst)];
5858
(_PyRuntime.st.cstack_cache)[Py_SIZE(cst)] = cst;
@@ -91,7 +91,7 @@ slp_cstack_new(PyCStackObject **cst, intptr_t *stackref, PyTaskletObject *task)
9191
(*cst)->task = NULL;
9292
Py_DECREF(*cst);
9393
}
94-
if (size < CSTACK_SLOTS && ((*cst) = (_PyRuntime.st.cstack_cache)[size])) {
94+
if (size < SLP_CSTACK_SLOTS && ((*cst) = (_PyRuntime.st.cstack_cache)[size])) {
9595
/* take stack from cache */
9696
(_PyRuntime.st.cstack_cache)[size] = (PyCStackObject *) (*cst)->startaddr;
9797
--(_PyRuntime.st.cstack_cachecount);
@@ -108,7 +108,7 @@ slp_cstack_new(PyCStackObject **cst, intptr_t *stackref, PyTaskletObject *task)
108108
(*cst)->task = task;
109109
(*cst)->tstate = ts;
110110
(*cst)->nesting_level = ts->st.nesting_level;
111-
#ifdef _SEH32
111+
#ifdef SLP_SEH32
112112
//save the SEH handler
113113
(*cst)->exception_list = 0;
114114
#endif
@@ -122,7 +122,7 @@ slp_cstack_save(PyCStackObject *cstprev)
122122

123123
memcpy((cstprev)->stack, (cstprev)->startaddr -
124124
Py_SIZE(cstprev), stsizeb);
125-
#ifdef _SEH32
125+
#ifdef SLP_SEH32
126126
//save the SEH handler
127127
cstprev->exception_list = (DWORD)
128128
__readfsdword(FIELD_OFFSET(NT_TIB, ExceptionList));
@@ -132,7 +132,7 @@ slp_cstack_save(PyCStackObject *cstprev)
132132
}
133133

134134
void
135-
#ifdef _SEH32
135+
#ifdef SLP_SEH32
136136
#pragma warning(disable:4733) /* disable warning about modifying FS[0] */
137137
#endif
138138
slp_cstack_restore(PyCStackObject *cst)
@@ -142,7 +142,7 @@ slp_cstack_restore(PyCStackObject *cst)
142142
cst->task = NULL;
143143
memcpy(cst->startaddr - Py_SIZE(cst), &cst->stack,
144144
Py_SIZE(cst) * sizeof(intptr_t));
145-
#ifdef _SEH32
145+
#ifdef SLP_SEH32
146146
//restore the SEH handler
147147
assert(cst->exception_list);
148148
__writefsdword(FIELD_OFFSET(NT_TIB, ExceptionList), (DWORD)(cst->exception_list));
@@ -343,9 +343,9 @@ slp_eval_frame(PyFrameObject *f)
343343
}
344344

345345
/* mark the stack base */
346-
stackref = STACK_REFPLUS + (intptr_t *) &f;
346+
stackref = SLP_STACK_REFPLUS + (intptr_t *) &f;
347347
if (ts->st.cstack_base == NULL)
348-
ts->st.cstack_base = stackref - CSTACK_GOODGAP;
348+
ts->st.cstack_base = stackref - SLP_CSTACK_GOODGAP;
349349
if (stackref > ts->st.cstack_base) {
350350
PyCStackObject *cst;
351351
retval = climb_stack_and_eval_frame(f);
@@ -863,7 +863,7 @@ eval_frame_callback(PyFrameObject *f, int exc, PyObject *retval)
863863
* ourselves in an infinite loop of stack spilling.
864864
*/
865865
saved_base = ts->st.cstack_root;
866-
ts->st.cstack_root = STACK_REFPLUS + (intptr_t *) &f;
866+
ts->st.cstack_root = SLP_STACK_REFPLUS + (intptr_t *) &f;
867867

868868
/* pull in the right retval and tempval from the arguments */
869869
Py_SETREF(retval, cf->ob1);
@@ -926,14 +926,14 @@ slp_eval_frame_newstack(PyFrameObject *f, int exc, PyObject *retval)
926926
* magic here will clear that exception.
927927
*/
928928
intptr_t *old = ts->st.cstack_root;
929-
ts->st.cstack_root = STACK_REFPLUS + (intptr_t *) &f;
929+
ts->st.cstack_root = SLP_STACK_REFPLUS + (intptr_t *) &f;
930930
retval = PyEval_EvalFrameEx_slp(f, exc, retval);
931931
ts->st.cstack_root = old;
932932
return retval;
933933
}
934934
if (ts->st.cstack_root == NULL) {
935935
/* this is a toplevel call. Store the root of stack spilling */
936-
ts->st.cstack_root = STACK_REFPLUS + (intptr_t *) &f;
936+
ts->st.cstack_root = SLP_STACK_REFPLUS + (intptr_t *) &f;
937937
retval = PyEval_EvalFrameEx_slp(f, exc, retval);
938938
/* and reset it. We may reenter stackless at a completely different
939939
* depth later

‎Stackless/module/stacklessmodule.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,15 +1405,15 @@ _peek(PyObject *self, PyObject *v)
14051405
if (!PyLong_Check(v)) goto noobject;
14061406
o = (PyObject*) PyLong_AsVoidPtr(v);
14071407
/* this is plain heuristics, use for now */
1408-
if (CANNOT_READ_MEM(o, sizeof(PyObject))) goto noobject;
1409-
if (IS_ON_STACK(o)) goto noobject;
1408+
if (SLP_CANNOT_READ_MEM(o, sizeof(PyObject))) goto noobject;
1409+
if (SLP_IS_ON_STACK(o)) goto noobject;
14101410
if (Py_REFCNT(o) < 1 || Py_REFCNT(o) > 10000) goto noobject;
14111411
t = Py_TYPE(o);
14121412
for (i=0; i<100; i++) {
14131413
if (t == &PyType_Type)
14141414
break;
1415-
if (CANNOT_READ_MEM(t, sizeof(PyTypeObject))) goto noobject;
1416-
if (IS_ON_STACK(o)) goto noobject;
1415+
if (SLP_CANNOT_READ_MEM(t, sizeof(PyTypeObject))) goto noobject;
1416+
if (SLP_IS_ON_STACK(o)) goto noobject;
14171417
if (Py_REFCNT(t) < 1 || Py_REFCNT(t) > 10000) goto noobject;
14181418
if (!(isalpha(t->tp_name[0])||t->tp_name[0]=='_'))
14191419
goto noobject;

‎Stackless/pickling/prickelpit.c‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -835,15 +835,15 @@ static int init_functype(PyObject * mod)
835835

836836
#define frametuplefmt "O)(OiSOiOOiiOO"
837837

838-
DEF_INVALID_EXEC(eval_frame)
839-
DEF_INVALID_EXEC(eval_frame_value)
840-
DEF_INVALID_EXEC(eval_frame_noval)
841-
DEF_INVALID_EXEC(eval_frame_iter)
842-
DEF_INVALID_EXEC(eval_frame_setup_with)
843-
DEF_INVALID_EXEC(eval_frame_with_cleanup)
844-
DEF_INVALID_EXEC(slp_channel_seq_callback)
845-
DEF_INVALID_EXEC(slp_restore_tracing)
846-
DEF_INVALID_EXEC(slp_tp_init_callback)
838+
SLP_DEF_INVALID_EXEC(eval_frame)
839+
SLP_DEF_INVALID_EXEC(eval_frame_value)
840+
SLP_DEF_INVALID_EXEC(eval_frame_noval)
841+
SLP_DEF_INVALID_EXEC(eval_frame_iter)
842+
SLP_DEF_INVALID_EXEC(eval_frame_setup_with)
843+
SLP_DEF_INVALID_EXEC(eval_frame_with_cleanup)
844+
SLP_DEF_INVALID_EXEC(slp_channel_seq_callback)
845+
SLP_DEF_INVALID_EXEC(slp_restore_tracing)
846+
SLP_DEF_INVALID_EXEC(slp_tp_init_callback)
847847

848848
static PyTypeObject wrap_PyFrame_Type;
849849

@@ -1193,23 +1193,23 @@ MAKE_WRAPPERTYPE(PyFrame_Type, frame, "frame", frameobject_reduce, frame_new, fr
11931193
static int init_frametype(PyObject * mod)
11941194
{
11951195
return slp_register_execute(&PyFrame_Type, "eval_frame",
1196-
PyEval_EvalFrameEx_slp, REF_INVALID_EXEC(eval_frame))
1196+
PyEval_EvalFrameEx_slp, SLP_REF_INVALID_EXEC(eval_frame))
11971197
|| slp_register_execute(&PyFrame_Type, "eval_frame_value",
1198-
slp_eval_frame_value, REF_INVALID_EXEC(eval_frame_value))
1198+
slp_eval_frame_value, SLP_REF_INVALID_EXEC(eval_frame_value))
11991199
|| slp_register_execute(&PyFrame_Type, "eval_frame_noval",
1200-
slp_eval_frame_noval, REF_INVALID_EXEC(eval_frame_noval))
1200+
slp_eval_frame_noval, SLP_REF_INVALID_EXEC(eval_frame_noval))
12011201
|| slp_register_execute(&PyFrame_Type, "eval_frame_iter",
1202-
slp_eval_frame_iter, REF_INVALID_EXEC(eval_frame_iter))
1202+
slp_eval_frame_iter, SLP_REF_INVALID_EXEC(eval_frame_iter))
12031203
|| slp_register_execute(&PyFrame_Type, "eval_frame_setup_with",
1204-
slp_eval_frame_setup_with, REF_INVALID_EXEC(eval_frame_setup_with))
1204+
slp_eval_frame_setup_with, SLP_REF_INVALID_EXEC(eval_frame_setup_with))
12051205
|| slp_register_execute(&PyFrame_Type, "eval_frame_with_cleanup",
1206-
slp_eval_frame_with_cleanup, REF_INVALID_EXEC(eval_frame_with_cleanup))
1206+
slp_eval_frame_with_cleanup, SLP_REF_INVALID_EXEC(eval_frame_with_cleanup))
12071207
|| slp_register_execute(&PyCFrame_Type, "channel_seq_callback",
1208-
slp_channel_seq_callback, REF_INVALID_EXEC(slp_channel_seq_callback))
1208+
slp_channel_seq_callback, SLP_REF_INVALID_EXEC(slp_channel_seq_callback))
12091209
|| slp_register_execute(&PyCFrame_Type, "slp_restore_tracing",
1210-
slp_restore_tracing, REF_INVALID_EXEC(slp_restore_tracing))
1210+
slp_restore_tracing, SLP_REF_INVALID_EXEC(slp_restore_tracing))
12111211
|| slp_register_execute(&PyCFrame_Type, "slp_tp_init_callback",
1212-
slp_tp_init_callback, REF_INVALID_EXEC(slp_tp_init_callback))
1212+
slp_tp_init_callback, SLP_REF_INVALID_EXEC(slp_tp_init_callback))
12131213
|| init_type(&wrap_PyFrame_Type, initchain, mod);
12141214
}
12151215
#undef initchain
@@ -1825,7 +1825,7 @@ gen_setstate(PyObject *self, PyObject *args)
18251825
MAKE_WRAPPERTYPE(PyGen_Type, gen, "generator", gen_reduce,
18261826
gen_new, gen_setstate)
18271827

1828-
DEF_INVALID_EXEC(gen_iternext_callback)
1828+
SLP_DEF_INVALID_EXEC(gen_iternext_callback)
18291829

18301830
static int init_generatortype(PyObject * mod)
18311831
{
@@ -1841,7 +1841,7 @@ static int init_generatortype(PyObject * mod)
18411841
cbframe = gen->gi_frame->f_back;
18421842
res = slp_register_execute(Py_TYPE(cbframe), "gen_iternext_callback",
18431843
gen->gi_frame->f_back->f_execute,
1844-
REF_INVALID_EXEC(gen_iternext_callback))
1844+
SLP_REF_INVALID_EXEC(gen_iternext_callback))
18451845
|| init_type(&wrap_PyGen_Type, initchain, mod);
18461846

18471847
assert(gen_exhausted_frame == NULL);

0 commit comments

Comments
 (0)