diff -ru Python-2.7.1.orig/Modules/_multiprocessing/multiprocessing.c Python-2.7.1/Modules/_multiprocessing/multiprocessing.c --- Python-2.7.1.orig/Modules/_multiprocessing/multiprocessing.c 2011-04-27 14:49:16 +0200 +++ Python-2.7.1/Modules/_multiprocessing/multiprocessing.c 2011-04-27 14:49:59 +0200 @@ -8,11 +8,13 @@ #include "multiprocessing.h" +#ifndef HAVE_FD_TRANSFER #ifdef SCM_RIGHTS #define HAVE_FD_TRANSFER 1 #else #define HAVE_FD_TRANSFER 0 #endif +#endif PyObject *create_win32_namespace(void); diff -ru Python-2.7.1.orig/Modules/mathmodule.c Python-2.7.1/Modules/mathmodule.c --- Python-2.7.1.orig/Modules/mathmodule.c 2011-04-27 14:50:18 +0200 +++ Python-2.7.1/Modules/mathmodule.c 2011-04-27 14:38:05 +0200 @@ -1167,6 +1167,9 @@ else { PyFPE_START_PROTECT("in math_frexp", return 0); x = frexp(x, &i); +#ifdef __INTERIX + if(x >= 1.0) { x /= 2.0; ++i; } +#endif PyFPE_END_PROTECT(x); } return Py_BuildValue("(di)", x, i); diff -ru Python-2.7.1.orig/Modules/posixmodule.c Python-2.7.1/Modules/posixmodule.c --- Python-2.7.1.orig/Modules/posixmodule.c 2011-04-27 14:50:18 +0200 +++ Python-2.7.1/Modules/posixmodule.c 2011-04-27 14:38:05 +0200 @@ -9170,6 +9170,8 @@ /* These come from sysexits.h */ #ifdef EX_OK if (ins(d, "EX_OK", (long)EX_OK)) return -1; +#else /* !EX_OK */ + if (ins(d, "EX_OK", (long)0)) return -1; #endif /* EX_OK */ #ifdef EX_USAGE if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1; diff -ru Python-2.7.1.orig/Objects/floatobject.c Python-2.7.1/Objects/floatobject.c --- Python-2.7.1.orig/Objects/floatobject.c 2011-04-27 14:50:18 +0200 +++ Python-2.7.1/Objects/floatobject.c 2011-04-27 14:38:05 +0200 @@ -460,6 +460,7 @@ int wsign = _PyLong_Sign(w); size_t nbits; int exponent; + double mant; if (vsign != wsign) { /* Magnitudes are irrelevant -- the signs alone @@ -504,7 +505,12 @@ op = _Py_SwappedOp[op]; } assert(i > 0.0); - (void) frexp(i, &exponent); + mant = frexp(i, &exponent); + +#ifdef __INTERIX + if(mant >= 1.0) { mant /= 2.0; ++exponent; } +#endif + /* exponent is the # of bits in v before the radix point; * we know that nbits (the # of bits in w) > 48 at this point */ @@ -1106,6 +1112,11 @@ /* find 2-valuation val of x */ m = frexp(x, &val); + +#ifdef __INTERIX + if(m >= 1.0) { m /= 2.0; ++val; } +#endif + while (m != floor(m)) { m *= 2.0; val--; @@ -1354,6 +1365,11 @@ } m = frexp(fabs(x), &e); + +#ifdef __INTERIX + if(m >= 1.0) { m /= 2.0; ++e; } +#endif + shift = 1 - MAX(DBL_MIN_EXP - e, 0); m = ldexp(m, shift); e -= shift; @@ -1706,6 +1722,11 @@ PyFPE_START_PROTECT("as_integer_ratio", goto error); float_part = frexp(self, &exponent); /* self == float_part * 2**exponent exactly */ + +#ifdef __INTERIX + if(float_part >= 1.0) { float_part /= 2.0; ++exponent; } +#endif + PyFPE_END_PROTECT(float_part); for (i=0; i<300 && float_part != floor(float_part) ; i++) { @@ -2320,6 +2341,10 @@ f = frexp(x, &e); +#ifdef __INTERIX + if(f >= 1.0) { f /= 2.0; ++e; } +#endif + /* Normalize f to be in the range [1.0, 2.0) */ if (0.5 <= f && f < 1.0) { f *= 2.0; @@ -2425,6 +2450,10 @@ f = frexp(x, &e); +#ifdef __INTERIX + if(f >= 1.0) { f /= 2.0; ++e; } +#endif + /* Normalize f to be in the range [1.0, 2.0) */ if (0.5 <= f && f < 1.0) { f *= 2.0; diff -ru Python-2.7.1.orig/Objects/longobject.c Python-2.7.1/Objects/longobject.c --- Python-2.7.1.orig/Objects/longobject.c 2011-04-27 14:50:18 +0200 +++ Python-2.7.1/Objects/longobject.c 2011-04-27 14:38:05 +0200 @@ -190,6 +190,11 @@ dval = -dval; } frac = frexp(dval, &expo); /* dval = frac*2**expo; 0.0 <= frac < 1.0 */ + +#ifdef __INTERIX + if(frac >= 1.0) { frac /= 2.0; ++expo; } +#endif + if (expo <= 0) return PyLong_FromLong(0L); ndig = (expo-1) / PyLong_SHIFT + 1; /* Number of 'digits' in result */ diff -ru Python-2.7.1.orig/Python/dynload_shlib.c Python-2.7.1/Python/dynload_shlib.c --- Python-2.7.1.orig/Python/dynload_shlib.c 2011-04-27 14:50:18 +0200 +++ Python-2.7.1/Python/dynload_shlib.c 2011-04-27 14:38:05 +0200 @@ -132,6 +132,33 @@ pathname = pathbuf; #endif +#ifdef __INTERIX + /* ARG: This made me search 3 days! The interix loader has a problem: + * If you try to load the same shared lib two times, once with absolute, + * and once with relative path, it doesn't see, that both are the same + * and tries to really load it a second time, which makes the __init + * function crash (since the lib is inited allready...). So whatever + * we do here, in any case we expand the path to an absolute one! + * (markus duft) */ + + { + char buffer[PATH_MAX]; + + if(!realpath(pathname, buffer)) { + PyErr_SetString(PyExc_ImportError, strerror(errno)); + return NULL; + } + + if(strlen(buffer) >= 260) { + PyErr_SetString(PyExc_ImportError, "absolute path too long!"); + return NULL; + } + + strncpy(pathbuf, buffer, sizeof(pathbuf)); + pathname = pathbuf; + } +#endif + handle = dlopen(pathname, dlopenflags); if (handle == NULL) { diff -ru Python-2.7.1.orig/configure.in Python-2.7.1/configure.in --- Python-2.7.1.orig/configure.in 2011-04-27 14:50:18 +0200 +++ Python-2.7.1/configure.in 2011-04-27 14:38:06 +0200 @@ -790,6 +790,12 @@ RUNSHARED=LD_LIBRARYN32_PATH=`pwd`:${LD_LIBRARYN32_PATH} INSTSONAME="$LDLIBRARY".$SOVERSION ;; + Interix*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-L. -lpython$(VERSION)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} + INSTSONAME="$LDLIBRARY" + ;; Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*) LDLIBRARY='libpython$(VERSION).so' BLDLIBRARY='-L. -lpython$(VERSION)' @@ -1357,6 +1363,11 @@ dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional]) dnl AC_MSG_RESULT($cpp_type) +# on interix, disallow stropts.h, as the file is just empty. +case "$ac_sys_system" in +Interix*) export ac_cv_header_stropts_h=no ;; +esac + # checks for header files AC_HEADER_STDC AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ @@ -1896,6 +1907,9 @@ atheos*) LDSHARED="gcc -shared" LDCXXSHARED="g++ -shared";; + Interix*) + LDSHARED='$(CC) -shared' + LDCXXSHARED='$(CXX) -shared' ;; *) LDSHARED="ld";; esac fi @@ -1951,6 +1965,7 @@ # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; + Interix*) LINKFORSHARED="-Xlinker -export-dynamic";; # -u libsys_s pulls in all symbols in libsys Darwin/*) # -u _PyMac_Error is needed to pull in the mac toolbox glue, diff -ru Python-2.7.1.orig/setup.py Python-2.7.1/setup.py --- Python-2.7.1.orig/setup.py 2011-04-27 14:50:18 +0200 +++ Python-2.7.1/setup.py 2011-04-27 14:38:05 +0200 @@ -1252,7 +1252,9 @@ if sys.maxint == 0x7fffffff: # This requires sizeof(int) == sizeof(long) == sizeof(char*) dl_inc = find_file('dlfcn.h', [], inc_dirs) - if (dl_inc is not None) and (platform not in ['atheos']): + # interix note: dlfcn.h is in a compiler private dir, which this + # script doesn't seem to see - so overriding manually. + if ((dl_inc is not None) and (platform not in ['atheos'])) or (platform.startswith('interix')): exts.append( Extension('dl', ['dlmodule.c']) ) else: missing.append('dl') @@ -1296,7 +1298,13 @@ HAVE_FD_TRANSFER=1, ) libraries = [] - + elif platform.startswith('interix'): + macros = dict( + HAVE_SEM_OPEN=1, + HAVE_SEM_TIMEDWAIT=1, + HAVE_FD_TRANSFER=0, + ) + libraries = [] else: # Linux and other unices macros = dict() libraries = ['rt']