From 0fb03e979bd1cd1fabe5ab8256d154e0459469ad Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Sun, 24 Jan 2021 10:47:40 -0700 Subject: [PATCH] Cleanup patches --- gdl-python3.patch | 182 ---------------------------------------------- gdl-std.patch | 53 -------------- gdl.spec | 7 -- 3 files changed, 242 deletions(-) delete mode 100644 gdl-python3.patch delete mode 100644 gdl-std.patch diff --git a/gdl-python3.patch b/gdl-python3.patch deleted file mode 100644 index 8327f6b..0000000 --- a/gdl-python3.patch +++ /dev/null @@ -1,182 +0,0 @@ -diff --git a/src/datatypes.cpp b/src/datatypes.cpp -index 1a8d126..e8b08a1 100644 ---- a/src/datatypes.cpp -+++ b/src/datatypes.cpp -@@ -18,6 +18,7 @@ - #include "includefirst.hpp" - - #if defined(USE_PYTHON) || defined(PYTHON_MODULE) -+#include - #include - #endif - -diff --git a/src/gdlpython.cpp b/src/gdlpython.cpp -index 7835ec9..dd17598 100644 ---- a/src/gdlpython.cpp -+++ b/src/gdlpython.cpp -@@ -32,18 +32,32 @@ - - using namespace std; - -+#if PY_MAJOR_VERSION >= 3 -+int PythonInit() -+{ -+ if( Py_IsInitialized()) return NULL; -+#else - void PythonInit() - { - if( Py_IsInitialized()) return; -+#endif - Py_Initialize(); // signal handlers? - - static int argc = 1; -+#if PY_MAJOR_VERSION >= 3 -+ static wchar_t* arg0 = Py_DecodeLocale("./py/python.exe",NULL); -+ static wchar_t* argv[] = {arg0}; -+#else - static char* arg0 = (char*)"./py/python.exe"; - static char* argv[] = {arg0}; -+#endif - PySys_SetArgv(argc, argv); - - // http://docs.scipy.org/doc/numpy/reference/c-api.array.html#miscellaneous - import_array(); -+#if PY_MAJOR_VERSION >= 3 -+ return NULL; -+#endif - } - - void PythonEnd() -@@ -71,6 +85,12 @@ BaseGDL* FromPython( PyObject* pyObj) - { - if( !PyArray_Check( pyObj)) - { -+#if PY_MAJOR_VERSION >= 3 -+ if( PyUnicode_Check( pyObj)) -+ { -+ return new DStringGDL( PyUnicode_AsUTF8( pyObj)); -+ } -+#else - if( PyString_Check( pyObj)) - { - return new DStringGDL( PyString_AsString( pyObj)); -@@ -79,6 +99,7 @@ BaseGDL* FromPython( PyObject* pyObj) - { - return new DLongGDL( PyInt_AsLong( pyObj)); - } -+#endif - if( PyLong_Check( pyObj)) - { - return new DLongGDL( PyLong_AsLong( pyObj)); -@@ -174,11 +195,19 @@ namespace lib { - e->Throw( "ARGV keyword must be of type STRING."); - - int argc = argvS->N_Elements(); -+#if PY_MAJOR_VERSION >= 3 -+ wchar_t** argv = new wchar_t*[ argc]; -+#else - char** argv = new char*[ argc]; -+#endif - -- // pyhton copies the value -> threats it as const -+ // python copies the value -> treats it as const - for( int i=0; i= 3 -+ argv[i] = Py_DecodeLocale(const_cast((*argvS)[ i].c_str()), NULL); -+#else - argv[i] = const_cast((*argvS)[ i].c_str()); -+#endif - - PySys_SetArgv(argc, argv); - delete[] argv; -diff --git a/src/gdlpython.hpp b/src/gdlpython.hpp -index 45ef436..cb53bd7 100644 ---- a/src/gdlpython.hpp -+++ b/src/gdlpython.hpp -@@ -18,7 +18,11 @@ - #ifndef GDLPYTHON_HPP_ - #define GDLPYTHON_HPP_ - -+#if PY_MAJOR_VERSION >= 3 -+int PythonInit(); -+#else - void PythonInit(); -+#endif - void PythonEnd(); - BaseGDL* FromPython( PyObject* pyObj); - -diff --git a/src/pythongdl.cpp b/src/pythongdl.cpp -index a3b5afd..e541ba5 100644 ---- a/src/pythongdl.cpp -+++ b/src/pythongdl.cpp -@@ -191,14 +191,22 @@ bool CopyArgFromPython( vector& parRef, - for( SizeT k=0; k= 3 -+ int keyIsString = PyUnicode_Check( key); -+#else - int keyIsString = PyString_Check( key); -+#endif - if( !keyIsString) - { - PyErr_SetString( gdlError, - "Keywords must be of type string"); - return false; - } -+#if PY_MAJOR_VERSION >= 3 -+ const char* keyChar = PyUnicode_AsUTF8( key); -+#else - const char* keyChar = PyString_AsString( key); -+#endif - string keyString = StrUpCase( keyChar); - int kwIx = e.GetPro()->FindKey( keyString); - if( kwIx == -1) -@@ -523,6 +531,35 @@ extern "C" { - {NULL, NULL, 0, NULL} // Sentinel - }; - -+#if PY_MAJOR_VERSION >= 3 -+ struct module_state { -+ PyObject *error; -+ }; -+ -+ #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) -+ -+ static int GDL_traverse(PyObject *m, visitproc visit, void *arg) { -+ Py_VISIT(GETSTATE(m)->error); -+ return 0; -+ } -+ -+ static int GDL_clear(PyObject *m) { -+ Py_CLEAR(GETSTATE(m)->error); -+ return 0; -+ } -+ -+ static struct PyModuleDef moduledef = { -+ PyModuleDef_HEAD_INIT, -+ "GDL", -+ NULL, -+ sizeof(struct module_state), -+ GDLMethods, -+ NULL, -+ GDL_traverse, -+ GDL_clear, -+ NULL -+ }; -+#endif - - // python GDL module init function - PyMODINIT_FUNC initGDL() -@@ -552,7 +589,11 @@ extern "C" { - } - SysVar::SetGDLPath( gdlPath); - -+#if PY_MAJOR_VERSION >= 3 -+ PyObject* m = PyModule_Create(&moduledef); -+#else - PyObject* m = Py_InitModule("GDL", GDLMethods); -+#endif - - gdlError = PyErr_NewException((char*)"GDL.error", NULL, NULL); - Py_INCREF(gdlError); diff --git a/gdl-std.patch b/gdl-std.patch deleted file mode 100644 index ec36255..0000000 --- a/gdl-std.patch +++ /dev/null @@ -1,53 +0,0 @@ -diff -up gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT-common.h.std gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT-common.h ---- gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT-common.h.std 2019-09-16 03:51:53.000000000 -0600 -+++ gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT-common.h 2019-09-16 21:15:07.887885236 -0600 -@@ -44,25 +44,25 @@ static const union X128I_T sse2_param_ma - #if defined(HAVE_ALTIVEC) - inline static void do_recursion(w128_t *r, w128_t *a, w128_t * b, - w128_t *lung) { -- const vector unsigned char sl1 = ALTI_SL1; -- const vector unsigned char sl1_perm = ALTI_SL1_PERM; -- const vector unsigned int sl1_msk = ALTI_SL1_MSK; -- const vector unsigned char sr1 = ALTI_SR; -- const vector unsigned char sr1_perm = ALTI_SR_PERM; -- const vector unsigned int sr1_msk = ALTI_SR_MSK; -- const vector unsigned char perm = ALTI_PERM; -- const vector unsigned int msk1 = ALTI_MSK; -- vector unsigned int w, x, y, z; -+ const __vector unsigned char sl1 = ALTI_SL1; -+ const __vector unsigned char sl1_perm = ALTI_SL1_PERM; -+ const __vector unsigned int sl1_msk = ALTI_SL1_MSK; -+ const __vector unsigned char sr1 = ALTI_SR; -+ const __vector unsigned char sr1_perm = ALTI_SR_PERM; -+ const __vector unsigned int sr1_msk = ALTI_SR_MSK; -+ const __vector unsigned char perm = ALTI_PERM; -+ const __vector unsigned int msk1 = ALTI_MSK; -+ __vector unsigned int w, x, y, z; - - z = a->s; - w = lung->s; -- x = vec_perm(w, (vector unsigned int)perm, perm); -- y = vec_perm(z, (vector unsigned int)sl1_perm, sl1_perm); -+ x = vec_perm(w, (__vector unsigned int)perm, perm); -+ y = vec_perm(z, (__vector unsigned int)sl1_perm, sl1_perm); - y = vec_sll(y, sl1); - y = vec_and(y, sl1_msk); - w = vec_xor(x, b->s); - w = vec_xor(w, y); -- x = vec_perm(w, (vector unsigned int)sr1_perm, sr1_perm); -+ x = vec_perm(w, (__vector unsigned int)sr1_perm, sr1_perm); - x = vec_srl(x, sr1); - x = vec_and(x, sr1_msk); - y = vec_and(w, msk1); -diff -up gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT.h.std gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT.h ---- gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT.h.std 2019-09-16 03:51:53.000000000 -0600 -+++ gdl-287007567ba3998b4b70119025c3def86bdef649/src/dSFMT/dSFMT.h 2019-09-16 21:15:07.887885236 -0600 -@@ -143,7 +143,7 @@ extern "C" { - - /** 128-bit data structure */ - union W128_T { -- vector unsigned int s; -+ __vector unsigned int s; - uint64_t u[2]; - uint32_t u32[4]; - double d[2]; diff --git a/gdl.spec b/gdl.spec index 5865e75..e289674 100644 --- a/gdl.spec +++ b/gdl.spec @@ -17,11 +17,6 @@ Source4: xorg.conf # Build with system antlr library. Request for upstream change here: # https://sourceforge.net/tracker/index.php?func=detail&aid=2685215&group_id=97659&atid=618686 Patch1: gdl-antlr.patch -# Fix multiple template instantiations with include guard -Patch2: gdl-guard.patch -# Fix conflict with std::vector and ALTIVEC vector -# https://github.com/gnudatalanguage/gdl/pull/535 -#Patch4: gdl-std.patch # Build fails on armv7hl # https://bugzilla.redhat.com/show_bug.cgi?id=1919680 @@ -144,8 +139,6 @@ rm -rf src/antlr # Not yet possible to build with external dSFMT #rm -r src/dSFMT %patch1 -p1 -b .antlr -#patch2 -p1 -b .guard -#patch4 -p1 -b .std pushd src for f in *.g