diff options
author | Nicolás Reynolds <fauno@endefensadelsl.org> | 2013-05-07 22:31:25 -0300 |
---|---|---|
committer | Nicolás Reynolds <fauno@endefensadelsl.org> | 2013-05-07 22:31:25 -0300 |
commit | 9f7fb9c12e84f20cd108b933f1a51e216f76cd98 (patch) | |
tree | 06520d9024b40745b94f02d0d3419386e6496863 /extra/boost/boost-1.53.0-python3.patch | |
parent | 6cc893589a6bd208f2b7711f985e17df7a6df816 (diff) | |
parent | a86ff663185661ee304bb1f6d00d982102dd706d (diff) |
Merge branch 'master' of gparabola:abslibre-mips64el
Diffstat (limited to 'extra/boost/boost-1.53.0-python3.patch')
-rw-r--r-- | extra/boost/boost-1.53.0-python3.patch | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/extra/boost/boost-1.53.0-python3.patch b/extra/boost/boost-1.53.0-python3.patch new file mode 100644 index 000000000..8d2f59269 --- /dev/null +++ b/extra/boost/boost-1.53.0-python3.patch @@ -0,0 +1,96 @@ +diff -Naur boost_1_53_0.ori/libs/mpi/src/python/datatypes.cpp boost_1_53_0/libs/mpi/src/python/datatypes.cpp +--- boost_1_53_0.ori/libs/mpi/src/python/datatypes.cpp 2007-11-25 13:38:02.000000000 -0500 ++++ boost_1_53_0/libs/mpi/src/python/datatypes.cpp 2013-03-11 20:59:57.171732691 -0400 +@@ -13,6 +13,10 @@ + #include <boost/mpi/python/serialize.hpp> + #include <boost/mpi.hpp> + ++#if PY_MAJOR_VERSION >= 3 ++#define PyInt_Type PyLong_Type ++#endif ++ + namespace boost { namespace mpi { namespace python { + + void export_datatypes() +diff -Naur boost_1_53_0.ori/libs/mpi/src/python/py_environment.cpp boost_1_53_0/libs/mpi/src/python/py_environment.cpp +--- boost_1_53_0.ori/libs/mpi/src/python/py_environment.cpp 2007-11-25 13:38:02.000000000 -0500 ++++ boost_1_53_0/libs/mpi/src/python/py_environment.cpp 2013-03-11 21:02:12.961737401 -0400 +@@ -11,6 +11,9 @@ + * This file reflects the Boost.MPI "environment" class into Python + * methods at module level. + */ ++ ++#include <locale> ++#include <string> + #include <boost/python.hpp> + #include <boost/mpi.hpp> + +@@ -50,11 +53,65 @@ + + // If anything changed, convert C-style argc/argv into Python argv + if (mpi_argv != my_argv) ++ { ++#if PY_MAJOR_VERSION >= 3 ++ // Code stolen from py3k/Modules/python.c. ++ ++ wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*mpi_argc); ++ /* We need a second copies, as Python might modify the first one. */ ++ wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*mpi_argc); ++ ++ if (!argv_copy || !argv_copy2) { ++ fprintf(stderr, "out of memory\n"); ++ return false; ++ } ++ ++ std::locale mylocale; ++ mbstate_t mystate; ++ ++ const std::codecvt<char, wchar_t, mbstate_t>& myfacet = ++ std::use_facet<std::codecvt<char, wchar_t, mbstate_t> >(mylocale); ++ ++ for (int i = 0; i < mpi_argc; i++) ++ { ++ size_t length = strlen(mpi_argv[i]); ++ ++ wchar_t *dest = (wchar_t *) PyMem_Malloc(sizeof(wchar_t) * (length + 1)); ++ ++ const char *from_next; ++ wchar_t *to_next; ++ ++ std::codecvt<wchar_t,char,mbstate_t>::result myresult = ++ myfacet.out(mystate, ++ mpi_argv[i], mpi_argv[i] + length + 1, from_next, ++ dest, dest+length+1, to_next); ++ ++ if (myresult != std::codecvt<wchar_t,char,mbstate_t>::ok ) ++ { ++ fprintf(stderr, "failure translating argv\n"); ++ return 1; ++ } ++ ++ argv_copy2[i] = argv_copy[i] = dest; ++ if (!argv_copy[i]) ++ return false; ++ } ++ ++ PySys_SetArgv(mpi_argc, argv_copy); ++ ++ for (int i = 0; i < mpi_argc; i++) { ++ PyMem_Free(argv_copy2[i]); ++ } ++ PyMem_Free(argv_copy); ++ PyMem_Free(argv_copy2); ++#else + PySys_SetArgv(mpi_argc, mpi_argv); ++#endif ++ } + +- for (int arg = 0; arg < my_argc; ++arg) +- free(my_argv[arg]); +- delete [] my_argv; ++ for (int arg = 0; arg < mpi_argc; ++arg) ++ free(mpi_argv[arg]); ++ delete [] mpi_argv; + + return true; + } |