[Stackless] Stackless python 2.5 (patches for nits)

Jeff Senn senn at maya.com
Thu Sep 21 21:20:39 CEST 2006


On Sep 21, 2006, at 12:52 PM, Richard Tew wrote:

> On 9/21/06, Carlos Eduardo de Paula <cedepaula at yahoo.com.br> wrote:
>> I just installed Stackless 2.5

I also get the bsddb_test errors on OS/X-ppc and OS/X-intel.
Though I do not get the others.  (I haven't looked into this very
much, as (like Richard) I haven't bothered with bsddb... though I
notice that test might involve a yield out of a C-extension object
which may not be otherwise well tested...)

Another subject:

In a bout of anality, I looked through the core compile warnings and  
discovered
a couple of (probably very minor) nits with Stackless 2.5.

The doc string for channel.send_sequence was wrong (probably a cut-n- 
paste typo
that has been there forever...).

There were some missing int --> Py_ssize_t changes for prickelpit  
(which I suppose
will only cause problems if your tuple or set sizes >= 1^31 on a 64- 
bit system)

A bunch of random strict-typing and unused var warnings;
most of which have obvious fixes (should not affect runtime behavior).

I also added a configure option --enable-stacklessfewerregisters  
which can
be used to choose the platform switch code that preserves fewer  
registers.
Usually that is some sort of frame pointer.  I think for now the  
default should be
to try to save lots of registers (because that's what usually causes  
a build error)
and then the builder can choose to re-config if they know what they  
are doing.

Later when we know more about this we could have configure choose  
properly
based on the platform...

I didn't do all the changes to switch_*.h -- just the ones
I can test.  It should be obvious from my example how to do the rest...

Richard- I've included patches here (more important ones first).
Take any of them you feel like including...

-Jas



Index: Stackless/module/channelobject.c
===================================================================
--- Stackless/module/channelobject.c	(revision 51948)
+++ Stackless/module/channelobject.c	(working copy)
@@ -825,7 +825,7 @@
{
	STACKLESS_GETARG();
	PyThreadState *ts = PyThreadState_GET();
-	PyChannel_HeapType *t = (PyChannel_HeapType *) self->ob_type;
+	/*unused: PyChannel_HeapType *t = (PyChannel_HeapType *) self- 
 >ob_type;*/
	PyObject *it;
	PyCFrameObject *f;
@@ -981,7 +981,8 @@
	{"__setstate__",	(PCF)channel_setstate,	    METH_O,
	 channel_setstate__doc__},
	{"send_sequence",   (PCF)channel_send_sequence,	  METH_OS,
-	 channel_send__doc__},
+	 channel_send_sequence__doc__},
+
	{NULL,		    NULL}             /* sentinel */
};
Index: Stackless/pickling/prickelpit.c
===================================================================
--- Stackless/pickling/prickelpit.c	(revision 51948)
+++ Stackless/pickling/prickelpit.c	(working copy)
@@ -1376,8 +1376,8 @@
typedef struct {
	PyObject_HEAD
	PyDictObject *di_dict; /* Set to NULL when iterator is exhausted */
-	int di_used;
-	int di_pos;
+	Py_ssize_t di_used;
+	Py_ssize_t di_pos;
	binaryfunc di_select;
} dictiterobject;
@@ -1393,7 +1393,7 @@
dictiterkey_reduce(dictiterobject *di)
{
      PyObject *tup, *list, *key;
-    int i;
+    Py_ssize_t i;
      list = PyList_New(0);
      if (list == NULL)
@@ -1433,7 +1433,7 @@
dictitervalue_reduce(dictiterobject *di)
{
      PyObject *tup, *list, *value;
-    int i;
+    Py_ssize_t i;
      list = PyList_New(0);
      if (list == NULL)
@@ -1473,7 +1473,7 @@
dictiteritem_reduce(dictiterobject *di)
{
      PyObject *tup, *list, *key, *value, *res;
-    int i;
+    Py_ssize_t i;
      list = PyList_New(0);
      if (list == NULL)
@@ -1579,7 +1579,7 @@
setiter_reduce(setiterobject *it)
{
      PyObject *list, *set, *elem;
-    int i;
+    Py_ssize_t i;
      list = PyList_New(0);
      if (list == NULL)
Index: Stackless/module/flextype.c
===================================================================
--- Stackless/module/flextype.c	(revision 51948)
+++ Stackless/module/flextype.c	(working copy)
@@ -41,7 +41,7 @@
}
static PyObject *
-builddict(char *modulename, char *doc)
+builddict(const char *modulename, const char *doc)
{
	return Py_BuildValue("{s:s,s:s,s:[]}",
			     "__module__", modulename,
@@ -145,7 +145,7 @@
static PyTypeObject *
-type_clone(PyTypeObject *meta, PyTypeObject *base, char *typename,  
PyObject *dict,
+type_clone(PyTypeObject *meta, PyTypeObject *base, const char  
*typename, PyObject *dict,
	   size_t type_size, PyCMethodDef *ml)
{
          PyObject *args = Py_BuildValue("(s(O)O)", typename, base,  
dict);
@@ -171,7 +171,7 @@
}
static PyTypeObject *
-make_meta(char *modulename, char *type_name, size_t type_size)
+make_meta(const char *modulename, const char *type_name, size_t  
type_size)
{
	char metaname[200];
	PyObject *dict;
@@ -188,9 +188,9 @@
	return meta;
}
-PyTypeObject * PyFlexType_Build( char *modulename,
-				 char *type_name,
-				 char *doc,
+PyTypeObject * PyFlexType_Build( const char *modulename,
+				 const char *type_name,
+				 const char *doc,
				 PyTypeObject *base,
				 size_t type_size,
				 PyCMethodDef *ml )
Index: Stackless/module/flextype.h
===================================================================
--- Stackless/module/flextype.h	(revision 51948)
+++ Stackless/module/flextype.h	(working copy)
@@ -55,9 +55,9 @@
/* build a new type and its meta-type */
-PyAPI_FUNC(PyTypeObject *) PyFlexType_Build( char *modulename,
-					     char *type_name,
-					     char *doc,
+PyAPI_FUNC(PyTypeObject *) PyFlexType_Build( const char *modulename,
+					     const char *type_name,
+					     const char *doc,
					     PyTypeObject *base,
					     size_t type_size,
					     PyCMethodDef *ml );
Index: Stackless/module/scheduling.c
===================================================================
--- Stackless/module/scheduling.c	(revision 51948)
+++ Stackless/module/scheduling.c	(working copy)
@@ -1020,7 +1020,7 @@
}
/* defined in pythonrun.c */
-extern void PyStackless_HandleSystemExit();
+extern void PyStackless_HandleSystemExit(void);
static PyObject *
tasklet_end(PyObject *retval)
Index: Stackless/core/slp_transfer.c
===================================================================
--- Stackless/core/slp_transfer.c	(revision 51948)
+++ Stackless/core/slp_transfer.c	(working copy)
@@ -28,7 +28,7 @@
      intptr_t stsizeb; \
	stackref += STACK_MAGIC; \
	if (_cstprev != NULL) { \
-        if (slp_cstack_new(_cstprev, stackref, _prev) == NULL)  
__return(-1); \
+	  if (slp_cstack_new(_cstprev, (intptr_t*) stackref, _prev) ==  
NULL) __return(-1); \
		stsizeb = slp_cstack_save(*_cstprev); \
	} \
	else \
@@ -168,7 +168,7 @@
	\
	stackref += STACK_MAGIC; \
	if (_cstprev != NULL) { \
-		if (slp_cstack_new(_cstprev, stackref, _prev) == NULL) \
+	        if (slp_cstack_new(_cstprev, (intptr_t*)stackref, _prev) ==  
NULL)	\
			return -1; \
		stsizeb = slp_cstack_save(*_cstprev); \
	} \
Index: Stackless/core/stackless_impl.h
===================================================================
--- Stackless/core/stackless_impl.h	(revision 51948)
+++ Stackless/core/stackless_impl.h	(working copy)
@@ -356,7 +356,7 @@
					 PyTaskletObject *next,
					 int stackless);
-PyAPI_FUNC(int) initialize_main_and_current();
+PyAPI_FUNC(int) initialize_main_and_current(void);
/* setting the tasklet's tempval, optimized for no change */
Index: Mac/BuildScript/resources/ReadMe.txt
===================================================================
--- Mac/BuildScript/resources/ReadMe.txt        (revision 51948)
+++ Mac/BuildScript/resources/ReadMe.txt        (working copy)
@@ -1,3 +1,12 @@
+This is the Stackless (http://www.stackless.com/)
+version of Python.  It will replace the non-stackless
+Python of the same version.  Other than additional
+features it should be compatible with normal Python.
+
+Everything below this point is from the original
+Python ReadMe.txt
+----------------------------
+
This package will install MacPython $FULL_VERSION for Mac OS X
$MACOSX_DEPLOYMENT_TARGET for the following
architecture(s): $ARCHITECTURES.
Index: configure
===================================================================
--- configure	(revision 51948)
+++ configure	(working copy)
@@ -312,7 +312,7 @@
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME  
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix  
program_transform_name bindir sbindir libexecdir datadir sysconfdir  
sharedstatedir localstatedir libdir includedir oldincludedir infodir  
mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T  
LIBS VERSION SOVERSION CONFIG_ARGS UNIVERSALSDK PYTHONFRAMEWORK  
PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR  
FRAMEWORKINSTALLFIRST FRAMEWORKINSTALLLAST FRAMEWORKALTINSTALLFIRST  
FRAMEWORKALTINSTALLLAST FRAMEWORKUNIXTOOLSPREFIX MACHDEP SGI_ABI  
EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET  
EXPORT_MACOSX_DEPLOYMENT_TARGET CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC  
EXEEXT OBJEXT CXX MAINCC CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY  
DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB  
ac_ct_RANLIB AR SVNVERSION INSTALL_PROGRAM INSTALL_SCRIPT  
INSTALL_DATA LN OPT BASECFLAGS OTHER_LIBTOOL_OPT LIBTOOL_CRUFT SO  
LDSHARED BLDSHARED CCSHARED LINKFORSHARED CFLAGSFORSHARED SHLIBS  
USE_SIGNAL_MODULE SIGNAL_OBJS USE_THREAD_MODULE LDLAST THREADOBJ  
DLINCLDIR DYNLOADFILE MACHDEP_OBJS TRUE LIBOBJS  
HAVE_GETHOSTBYNAME_R_6_ARG HAVE_GETHOSTBYNAME_R_5_ARG  
HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R HAVE_GETHOSTBYNAME  
LIBM LIBC UNICODE_OBJS THREADHEADERS SRCDIRS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME  
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix  
program_transform_name bindir sbindir libexecdir datadir sysconfdir  
sharedstatedir localstatedir libdir includedir oldincludedir infodir  
mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T  
LIBS VERSION SOVERSION CONFIG_ARGS UNIVERSALSDK STACKLESS_FRHACK  
PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX  
PYTHONFRAMEWORKINSTALLDIR FRAMEWORKINSTALLFIRST FRAMEWORKINSTALLLAST  
FRAMEWORKALTINSTALLFIRST FRAMEWORKALTINSTALLLAST  
FRAMEWORKUNIXTOOLSPREFIX MACHDEP SGI_ABI EXTRAPLATDIR  
EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET  
EXPORT_MACOSX_DEPLOYMENT_TARGET CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC  
EXEEXT OBJEXT CXX MAINCC CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY  
DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB  
ac_ct_RANLIB AR SVNVERSION INSTALL_PROGRAM INSTALL_SCRIPT  
INSTALL_DATA LN OPT BASECFLAGS OTHER_LIBTOOL_OPT LIBTOOL_CRUFT SO  
LDSHARED BLDSHARED CCSHARED LINKFORSHARED CFLAGSFORSHARED SHLIBS  
USE_SIGNAL_MODULE SIGNAL_OBJS USE_THREAD_MODULE LDLAST THREADOBJ  
DLINCLDIR DYNLOADFILE MACHDEP_OBJS TRUE LIBOBJS  
HAVE_GETHOSTBYNAME_R_6_ARG HAVE_GETHOSTBYNAME_R_5_ARG  
HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R HAVE_GETHOSTBYNAME  
LIBM LIBC UNICODE_OBJS THREADHEADERS SRCDIRS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -847,6 +847,8 @@
    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
    --enable-universalsdk[SDKDIR]
                            Build agains Mac OS X 10.4u SDK (ppc/i386)
+  --enable-stacklessfewerregisters
+                          save fewer registers building c-stack  
switching
    --enable-framework[=INSTALLDIR]
                            Build (MacOSX|Darwin) framework
    --enable-shared         disable/enable building shared python  
library
@@ -1428,6 +1430,13 @@
fi;
+# Check whether --enable-stacklessfewerregisters or --disable- 
stacklessfewerregisters was given.
+if test "${enable_stacklessfewerregisters+set}" = set; then
+  enableval="$enable_stacklessfewerregisters"
+  STACKLESS_FRHACK=1
+else
+   STACKLESS_FRHACK=0
+fi;
# Check whether --enable-framework or --disable-framework was given.
if test "${enable_framework+set}" = set; then
@@ -3888,6 +3897,7 @@
      then
        BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
      fi
+    BASECFLAGS="$BASECFLAGS -DSTACKLESS_FRHACK=${STACKLESS_FRHACK}"
      case $ac_sys_system in
	SCO_SV*)
	    BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
@@ -22743,6 +22753,7 @@
s, at SOVERSION@,$SOVERSION,;t t
s, at CONFIG_ARGS@,$CONFIG_ARGS,;t t
s, at UNIVERSALSDK@,$UNIVERSALSDK,;t t
+s, at STACKLESS_FRHACK@,$STACKLESS_FRHACK,;t t
s, at PYTHONFRAMEWORK@,$PYTHONFRAMEWORK,;t t
s, at PYTHONFRAMEWORKDIR@,$PYTHONFRAMEWORKDIR,;t t
s, at PYTHONFRAMEWORKPREFIX@,$PYTHONFRAMEWORKPREFIX,;t t
Index: configure.in
===================================================================
--- configure.in	(revision 51948)
+++ configure.in	(working copy)
@@ -83,6 +83,11 @@
])
AC_SUBST(UNIVERSALSDK)
+AC_ARG_ENABLE(stacklessfewerregisters,
+	AC_HELP_STRING(--enable-stacklessfewerregisters, save fewer  
registers building c-stack switching),
+[STACKLESS_FRHACK=1],[ STACKLESS_FRHACK=0 ])
+AC_SUBST(STACKLESS_FRHACK)
+
dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
AC_ARG_ENABLE(framework,
                AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@,  
Build (MacOSX|Darwin) framework),
@@ -814,6 +819,7 @@
      then
        BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
      fi
+    BASECFLAGS="${BASECFLAGS} -DSTACKLESS_FRHACK=${STACKLESS_FRHACK}"
      case $ac_sys_system in
	SCO_SV*)
	    BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
Index: Stackless/platf/switch_x86_unix.h
===================================================================
--- Stackless/platf/switch_x86_unix.h	(revision 51948)
+++ Stackless/platf/switch_x86_unix.h	(working copy)
@@ -31,10 +31,14 @@
slp_switch(void)
{
	register int *stackref, stsizediff;
+#if STACKLESS_FRHACK
+	__asm__ volatile ("" : : : "esi", "edi");
+#else
	__asm__ volatile ("" : : : "ebx", "esi", "edi");
+#endif
	__asm__ ("movl %%esp, %0" : "=g" (stackref));
	{
-		SLP_SAVE_STATE(stackref, stsizediff);
+ 		SLP_SAVE_STATE(stackref, stsizediff);
		__asm__ volatile (
		    "addl %0, %%esp\n"
		    "addl %0, %%ebp\n"
@@ -44,9 +48,14 @@
		SLP_RESTORE_STATE();
		return 0;
	}
+#if STACKLESS_FRHACK
+	__asm__ volatile ("" : : : "esi", "edi");
+#else
	__asm__ volatile ("" : : : "ebx", "esi", "edi");
+#endif
}
+
#endif
/*
Index: Stackless/platf/switch_ppc_macosx.h
===================================================================
--- Stackless/platf/switch_ppc_macosx.h	(revision 51948)
+++ Stackless/platf/switch_ppc_macosx.h	(working copy)
@@ -32,9 +32,15 @@
#define STACK_MAGIC 3
+#if STACKLESS_FRHACK
#define REGS_TO_SAVE "r13", "r14", "r15", "r16", "r17", "r18", "r19",  
"r20", \
         "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28",  
"r29", \
         "cr2", "cr3", "cr4"
+#else
+#define REGS_TO_SAVE "r13", "r14", "r15", "r16", "r17", "r18",  
"r19", "r20", \
+       "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28",  
"r29", "r31", \
+       "cr2", "cr3", "cr4"
+#endif
static int
slp_switch(void)
Index: Mac/BuildScript/build-installer.py
===================================================================
--- Mac/BuildScript/build-installer.py	(revision 51948)
+++ Mac/BuildScript/build-installer.py	(working copy)
@@ -628,7 +628,7 @@
      version = getVersion()
      print "Running configure..."
-    runCommand("%s -C --enable-framework --enable-universalsdk=%s  
LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/ 
usr/local/include' 2>&1"%(
+    runCommand("%s -C --enable-framework --enable- 
stacklessfewerregisters --enable-universalsdk=%s LDFLAGS='-g -L%s/ 
libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/ 
include' 2>&1"%(
          shellQuote(os.path.join(SRCDIR, 'configure')),
          shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1],
          shellQuote(WORKDIR)[1:-1]))


_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list