[Stackless] Build stackless python for openwrt
Wilhelm Shen
wileishn at gmail.com
Tue Apr 8 08:23:46 CEST 2008
On 08-4-6,Richard Tew<richard.m.tew at gmail.com> wrote:
> On Sat, Apr 5, 2008 at 11:49 AM, Wilhelm Shen <wileishn at gmail.com> wrote:
> > Re-make is OK, now I get the python, but just the python not stackless python.
> > I find the stackless module has not been built in.
> >
> > Can anyone help me?
>
> Stackless at its core relies on having assembly language support for
> stack switching. If this assembly language support is not present for
> the platform it is being compiled on, then Stackless will compile as
> normal Python instead of having the functionality it would otherwise
> have.
>
> You can see this logic here:
> http://svn.python.org/view/stackless/branches/release25-maint/Stackless/stackless.h?rev=55048&view=markup
>
> Cheers,
>
> Richard.
Thank you, now I get my stackless, it works on my asus wl-hdd well :)
Here is the patch for stackless-2.5.2:
# stackless-2.52.mips.xcompile.patch
diff -Nur stackless-2.52/configure stackless-2.52.mips.xcompile/configure
--- stackless-2.52/configure 2008-02-18 23:54:55.000000000 +0800
+++ stackless-2.52.mips.xcompile/configure 2008-04-04 22:02:09.000000000 +0800
@@ -22518,94 +22518,28 @@
-{ echo "$as_me:$LINENO: checking for %zd printf() format support" >&5
-echo $ECHO_N "checking for %zd printf() format support... $ECHO_C" >&6; }
-if test "$cross_compiling" = yes; then
- { { echo "$as_me:$LINENO: error: cannot run test program while
cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdio.h>
-#include <stddef.h>
-#include <string.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_SSIZE_T
-typedef ssize_t Py_ssize_t;
-#elif SIZEOF_VOID_P == SIZEOF_LONG
-typedef long Py_ssize_t;
-#else
-typedef int Py_ssize_t;
-#endif
-
-int main()
-{
- char buffer[256];
-
- if(sprintf(buffer, "%zd", (size_t)123) < 0)
- return 1;
-
- if (strcmp(buffer, "123"))
- return 1;
-
- if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
- return 1;
-
- if (strcmp(buffer, "-123"))
- return 1;
-
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-
-cat >>confdefs.h <<\_ACEOF
-#define PY_FORMAT_SIZE_T "z"
-_ACEOF
-
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext
conftest.$ac_objext conftest.$ac_ext
-fi
+#AC_CHECK_FILE(/dev/ptmx, AC_DEFINE(HAVE_DEV_PTMX, 1, [Define if we
have /dev/ptmx.]))
+#AC_CHECK_FILE(/dev/ptc, AC_DEFINE(HAVE_DEV_PTC, 1, [Define if we
have /dev/ptc.]))
+#AC_MSG_CHECKING(for %zd printf() format support)
+#AC_TRY_RUN([#include <stdio.h>
+##include <stddef.h>
+##include <string.h>
+#
+#int main()
+#{
+# char buffer[4];
+#
+# if(sprintf(buffer, "%zd", (size_t)123) < 0)
+# return 1;
+#
+# if (strncmp(buffer, "123", 3))
+# return 1;
+#
+# return 0;
+#}],
+#[AC_MSG_RESULT(yes)
+# AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier
for Py_ssize_t])],
+# AC_MSG_RESULT(no))
diff -Nur stackless-2.52/Makefile.pre.in
stackless-2.52.mips.xcompile/Makefile.pre.in
--- stackless-2.52/Makefile.pre.in 2008-02-01 01:00:55.000000000 +0800
+++ stackless-2.52.mips.xcompile/Makefile.pre.in 2008-04-08
13:39:43.000000000 +0800
@@ -28,8 +28,8 @@
srcdir= @srcdir@
VPATH= @srcdir@
-CC= @CC@
-CXX= @CXX@
+CC= @CC@ -pthread
+CXX= @CXX@ -pthread
MAINCC= @MAINCC@
LINKCC= @LINKCC@
AR= @AR@
@@ -56,13 +56,13 @@
# Compiler options
OPT= @OPT@
-BASECFLAGS= @BASECFLAGS@
+BASECFLAGS= -fno-strict-aliasing @BASECFLAGS@
CFLAGS= $(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)
# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
# be able to build extension modules using the directories specified in the
# environment variables
CPPFLAGS= -I. -IInclude -I$(srcdir)/Include -I$(srcdir)/Stackless @CPPFLAGS@
-LDFLAGS= @LDFLAGS@
+LDFLAGS= # @LDFLAGS@
LDLAST= @LDLAST@
SGI_ABI= @SGI_ABI@
CCSHARED= @CCSHARED@
@@ -72,7 +72,7 @@
# C flags used for building the interpreter object files
PY_CFLAGS= $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
# Special C flags for slp_transfer.c
-SLPFLAGS= @SLPFLAGS@
+SLPFLAGS= -O2 # @SLPFLAGS@
# Machine-dependent subdirectories
MACHDEP= @MACHDEP@
@@ -166,7 +166,7 @@
INSTSONAME= @INSTSONAME@
-LIBS= @LIBS@
+LIBS= -lpthread -ldl -lutil # @LIBS@
LIBM= @LIBM@
LIBC= @LIBC@
SYSLIBS= $(LIBM) $(LIBC)
@@ -180,6 +180,9 @@
PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)
+HOSTPYTHON= python2.5
+
+CROSS_COMPILE= yes
# === Definitions added by makesetup ===
@@ -359,14 +362,16 @@
$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
platform: $(BUILDPYTHON)
- $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from
distutils.util import get_platform ; print
get_platform()+"-"+sys.version[0:3]' >platform
+ $(RUNSHARED) $(HOSTPYTHON) -E -c 'import sys ; from distutils.util
import get_platform ; print get_platform()+"-"+sys.version[0:3]'
>platform
# Build the shared modules
sharedmods: $(BUILDPYTHON)
case $$MAKEFLAGS in \
- *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)'
./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)'
./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
+ *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)'
CROSS_COMPILE='$(CROSS_COMPILE)' \
+ $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
+ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)'
CROSS_COMPILE='$(CROSS_COMPILE)' \
+ $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
esac
# Build static library
@@ -615,7 +620,7 @@
TESTOPTS= -l $(EXTRATESTOPTS)
TESTPROG= $(srcdir)/Lib/test/regrtest.py
-TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt
+TESTPYTHON= $(RUNSHARED) $(HOSTPYTHON) -E -tt
test: all platform
-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
@@ -627,7 +632,7 @@
$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
teststackless: all platform
- pushd Stackless/unittests; $(RUNSHARED) ../../$(BUILDPYTHON) -E -tt
runAll.py; popd
+ pushd Stackless/unittests; $(RUNSHARED) $(HOSTPYTHON) -E -tt runAll.py; popd
# Run the unitests for both architectures in a Universal build on OSX
# Must be run on an Intel box.
@@ -639,7 +644,7 @@
-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
- $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt
$(TESTPROG) $(TESTOPTS) -uall
+ $(RUNSHARED) /usr/libexec/oah/translate $(HOSTPYTHON) -E -tt
$(TESTPROG) $(TESTOPTS) -uall
# Like testall, but with a single pass only
@@ -824,19 +829,19 @@
done
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
@@ -949,7 +954,8 @@
# Install the dynamically loadable modules
# This goes into $(exec_prefix)
sharedinstall:
- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
+ CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)'
CROSS_COMPILE='$(CROSS_COMPILE)' \
+ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
--prefix=$(prefix) \
--install-scripts=$(BINDIR) \
--install-platlib=$(DESTSHARED) \
@@ -1023,7 +1029,7 @@
# This installs a few of the useful scripts in Tools/scripts
scriptsinstall:
SRCDIR=$(srcdir) $(RUNSHARED) \
- ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
+ $(HOSTPYTHON) $(srcdir)/Tools/scripts/setup.py install \
--prefix=$(prefix) \
--install-scripts=$(BINDIR) \
--root=/$(DESTDIR)
diff -Nur stackless-2.52/Python/import.c
stackless-2.52.mips.xcompile/Python/import.c
--- stackless-2.52/Python/import.c 2007-10-20 19:40:57.000000000 +0800
+++ stackless-2.52.mips.xcompile/Python/import.c 2008-04-07
21:18:09.000000000 +0800
@@ -871,7 +871,8 @@
{
FILE *fp;
- fp = open_exclusive(cpathname);
+ fp = NULL;
+
if (fp == NULL) {
if (Py_VerboseFlag)
PySys_WriteStderr(
diff -Nur stackless-2.52/Python/sysmodule.c
stackless-2.52.mips.xcompile/Python/sysmodule.c
--- stackless-2.52/Python/sysmodule.c 2007-05-01 21:00:13.000000000 +0800
+++ stackless-2.52.mips.xcompile/Python/sysmodule.c 2008-04-04
22:17:33.000000000 +0800
@@ -974,64 +974,9 @@
static void
svnversion_init(void)
{
- const char *python, *br_start, *br_end, *br_end2, *svnversion;
- Py_ssize_t len;
- int istag;
-
- if (svn_initialized)
- return;
-
-#if defined(STACKLESS) || defined(STACKLESS_OFF)
- python = strstr(headurl, "/stackless/");
-#else
- python = strstr(headurl, "/python/");
-#endif
- if (!python)
- Py_FatalError("subversion keywords missing");
-
- br_start = python + 11;
- br_end = strchr(br_start, '/');
- assert(br_end);
-
- /* Works even for trunk,
- as we are in trunk/Python/sysmodule.c */
- br_end2 = strchr(br_end+1, '/');
-
- istag = strncmp(br_start, "tags", 4) == 0;
- if (strncmp(br_start, "trunk", 5) == 0) {
- strcpy(branch, "trunk");
- strcpy(shortbranch, "trunk");
-
- }
- else if (istag || strncmp(br_start, "branches", 8) == 0) {
- len = br_end2 - br_start;
- strncpy(branch, br_start, len);
- branch[len] = '\0';
-
- len = br_end2 - (br_end + 1);
- strncpy(shortbranch, br_end + 1, len);
- shortbranch[len] = '\0';
- }
- else {
- Py_FatalError("bad HeadURL");
- return;
- }
-
-
- svnversion = _Py_svnversion();
- if (strcmp(svnversion, "exported") != 0)
- svn_revision = svnversion;
- else if (istag) {
- len = strlen(_patchlevel_revision);
- strncpy(patchlevel_revision, _patchlevel_revision + 11,
- len - 13);
- patchlevel_revision[len - 13] = '\0';
- svn_revision = patchlevel_revision;
- }
- else
- svn_revision = "";
-
+ svn_revision = "";
svn_initialized = 1;
+ return;
}
/* Return svnversion output if available.
diff -Nur stackless-2.52/setup.py stackless-2.52.mips.xcompile/setup.py
--- stackless-2.52/setup.py 2008-02-18 23:48:02.000000000 +0800
+++ stackless-2.52.mips.xcompile/setup.py 2008-04-07 21:31:01.000000000 +0800
@@ -15,7 +15,14 @@
from distutils.command.install_lib import install_lib
# This global variable is used to hold the list of modules to be disabled.
-disabled_module_list = []
+try:
+ disabled_module_list = os.environ["PYTHON_DISABLE_MODULES"].split()
+except KeyError:
+ disabled_module_list = ['_ctypes']
+try:
+ disable_ssl = os.environ["PYTHON_DISABLE_SSL"]
+except KeyError:
+ disable_ssl = 0
def add_dir_to_list(dirlist, dir):
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
@@ -203,32 +210,41 @@
self.announce('WARNING: skipping import check for
Cygwin-based "%s"'
% ext.name)
return
+
+ if os.environ.get('CROSS_COMPILE') == 'yes':
+ return
+
ext_filename = os.path.join(
self.build_lib,
self.get_ext_filename(self.get_ext_fullname(ext.name)))
try:
imp.load_dynamic(ext.name, ext_filename)
except ImportError, why:
- self.announce('*** WARNING: renaming "%s" since importing it'
- ' failed: %s' % (ext.name, why), level=3)
- assert not self.inplace
- basename, tail = os.path.splitext(ext_filename)
- newname = basename + "_failed" + tail
- if os.path.exists(newname):
- os.remove(newname)
- os.rename(ext_filename, newname)
-
- # XXX -- This relies on a Vile HACK in
- # distutils.command.build_ext.build_extension(). The
- # _built_objects attribute is stored there strictly for
- # use here.
- # If there is a failure, _built_objects may not be there,
- # so catch the AttributeError and move on.
- try:
- for filename in self._built_objects:
- os.remove(filename)
- except AttributeError:
- self.announce('unable to remove files (ignored)')
+ if os.environ.get('CROSS_COMPILE') != "yes":
+ self.announce('*** WARNING: renaming "%s" since importing it'
+ ' failed: %s' % (ext.name, why), level=3)
+ assert not self.inplace
+ basename, tail = os.path.splitext(ext_filename)
+ newname = basename + "_failed" + tail
+ if os.path.exists(newname):
+ os.remove(newname)
+ os.rename(ext_filename, newname)
+
+ # XXX -- This relies on a Vile HACK in
+ # distutils.command.build_ext.build_extension(). The
+ # _built_objects attribute is stored there strictly for
+ # use here.
+ # If there is a failure, _built_objects may not be there,
+ # so catch the AttributeError and move on.
+ try:
+ for filename in self._built_objects:
+ os.remove(filename)
+ except AttributeError:
+ self.announce('unable to remove files (ignored)')
+ else:
+ self.announce('WARNING: "%s" failed importing, but we
leave it '
+ 'because we are cross-compiling' %
+ ext.name)
except:
exc_type, why, tb = sys.exc_info()
self.announce('*** WARNING: importing extension "%s" '
@@ -243,9 +259,19 @@
return sys.platform
def detect_modules(self):
- # Ensure that /usr/local is always used
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+ global disable_ssl
+ try:
+ modules_include_dirs = os.environ["PYTHON_MODULES_INCLUDE"].split()
+ except KeyError:
+ modules_include_dirs = ['/usr/include']
+ try:
+ modules_lib_dirs = os.environ["PYTHON_MODULES_LIB"].split()
+ except KeyError:
+ modules_lib_dirs = ['/usr/lib']
+ for dir in modules_include_dirs:
+ add_dir_to_list(self.compiler.include_dirs, dir)
+ for dir in modules_lib_dirs:
+ add_dir_to_list(self.compiler.library_dirs, dir)
# Add paths specified in the environment variables LDFLAGS and
# CPPFLAGS for header and library files.
@@ -280,12 +306,6 @@
for directory in reversed(options.dirs):
add_dir_to_list(dir_list, directory)
- if os.path.normpath(sys.prefix) != '/usr':
- add_dir_to_list(self.compiler.library_dirs,
- sysconfig.get_config_var("LIBDIR"))
- add_dir_to_list(self.compiler.include_dirs,
- sysconfig.get_config_var("INCLUDEDIR"))
-
try:
have_unicode = unicode
except NameError:
@@ -294,11 +314,8 @@
# lib_dirs and inc_dirs are used to search for files;
# if a file is found in one of those directories, it can
# be assumed that no additional -I,-L directives are needed.
- lib_dirs = self.compiler.library_dirs + [
- '/lib64', '/usr/lib64',
- '/lib', '/usr/lib',
- ]
- inc_dirs = self.compiler.include_dirs + ['/usr/include']
+ lib_dirs = self.compiler.library_dirs
+ inc_dirs = self.compiler.include_dirs
exts = []
config_h = sysconfig.get_config_h_filename()
@@ -538,7 +555,8 @@
] )
if (ssl_incs is not None and
- ssl_libs is not None):
+ ssl_libs is not None and
+ not disable_ssl):
exts.append( Extension('_ssl', ['_ssl.c'],
include_dirs = ssl_incs,
library_dirs = ssl_libs,
@@ -570,7 +588,7 @@
if (ssl_incs is not None and
ssl_libs is not None and
- openssl_ver >= 0x00907000):
+ openssl_ver >= 0x00907000 and False):
# The _hashlib module wraps optimized implementations
# of hash functions from the OpenSSL library.
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
@@ -587,7 +605,7 @@
sources = ['md5module.c', 'md5.c'],
depends = ['md5.h']) )
- if (openssl_ver < 0x00908000):
+ if (True or openssl_ver < 0x00908000):
# OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash
exts.append( Extension('_sha256', ['sha256module.c']) )
exts.append( Extension('_sha512', ['sha512module.c']) )
diff -Nur stackless-2.52/Stackless/platf/slp_platformselect.h
stackless-2.52.mips.xcompile/Stackless/platf/slp_platformselect.h
--- stackless-2.52/Stackless/platf/slp_platformselect.h 2006-09-04
03:10:03.000000000 +0800
+++ stackless-2.52.mips.xcompile/Stackless/platf/slp_platformselect.h 2008-04-06
15:32:14.000000000 +0800
@@ -24,6 +24,8 @@
#include "switch_arm_thumb_gcc.h" /* gcc using arm thumb */
#elif defined(__GNUC__) && defined(__arm32__)
#include "switch_arm32_gcc.h" /* gcc using arm32 */
+#elif defined(__GNUC__) && defined(__mips__) && defined(__linux__)
+#include "switch_mips_unix.h" /* MIPS */
#endif
/* default definitions if not defined in above files */
diff -Nur stackless-2.52/Stackless/platf/switch_mips_unix.h
stackless-2.52.mips.xcompile/Stackless/platf/switch_mips_unix.h
--- stackless-2.52/Stackless/platf/switch_mips_unix.h 1970-01-01
08:00:00.000000000 +0800
+++ stackless-2.52.mips.xcompile/Stackless/platf/switch_mips_unix.h 2008-04-06
15:08:49.000000000 +0800
@@ -0,0 +1,56 @@
+/*
+ * this is the internal transfer function.
+ *
+ * HISTORY
+ * 05-Jan-08 Thiemo Seufer <ths at debian.org>
+ * Ported from ppc.
+ */
+
+#define STACK_REFPLUS 1
+
+#ifdef SLP_EVAL
+
+#define STACK_MAGIC 0
+
+#ifdef __mips64
+#define REGS_TO_SAVE "$16", "$17", "$18", "$19", "$20", "$21", "$22", \
+ "$23", "$28", "$30"
+#else
+#define REGS_TO_SAVE "$16", "$17", "$18", "$19", "$20", "$21", "$22", \
+ "$23", "$30"
+#endif
+static int
+slp_switch(void)
+{
+ register int *stackref, stsizediff;
+ /* __asm__ __volatile__ ("" : : : REGS_TO_SAVE); */
+ __asm__ ("move %0, $29" : "=r" (stackref) : );
+ {
+ SLP_SAVE_STATE(stackref, stsizediff);
+ __asm__ __volatile__ (
+#ifdef __mips64
+ "daddu $29, %0\n"
+#else
+ "addu $29, %0\n"
+#endif
+ : /* no outputs */
+ : "r" (stsizediff)
+ );
+ SLP_RESTORE_STATE();
+ }
+ /* __asm__ __volatile__ ("" : : : REGS_TO_SAVE); */
+ return 0;
+}
+
+#endif
+
+/*
+ * further self-processing support
+ */
+
+/*
+ * if you want to add self-inspection tools, place them
+ * here. See the x86_msvc for the necessary defines.
+ * These features are highly experimental und not
+ * essential yet.
+ */
diff -Nur stackless-2.52/Stackless/stackless.h
stackless-2.52.mips.xcompile/Stackless/stackless.h
--- stackless-2.52/Stackless/stackless.h 2007-05-01 21:03:06.000000000 +0800
+++ stackless-2.52.mips.xcompile/Stackless/stackless.h 2008-04-06
15:30:07.000000000 +0800
@@ -57,6 +57,8 @@
/* Linux/S390 */
#elif defined(__GNUC__) && defined(__s390x__) && defined(__linux__)
/* Linux/S390 zSeries */
+#elif defined(__GNUC__) && defined(__mips__) && defined(__linux__)
+ /* MIPS */
#else
/* no supported platform */
#undef STACKLESS
More information about the Stackless
mailing list