From 52695dffb624847963ae531097ed52668843cb50 Mon Sep 17 00:00:00 2001 From: "Karl E. Nelson" Date: Sun, 17 Oct 2021 10:26:30 -0700 Subject: [PATCH 1/4] Fix for ssize_t issue on windows --- native/common/include/jp_booleantype.h | 4 ++-- native/common/include/jp_bytetype.h | 4 ++-- native/common/include/jp_chartype.h | 4 ++-- native/common/include/jp_doubletype.h | 4 ++-- native/common/include/jp_floattype.h | 4 ++-- native/common/include/jp_inttype.h | 4 ++-- native/common/include/jp_longtype.h | 4 ++-- native/common/include/jp_primitivetype.h | 4 ++-- native/common/include/jp_shorttype.h | 4 ++-- native/common/include/jp_voidtype.h | 4 ++-- native/common/jp_array.cpp | 4 ++-- native/common/jp_booleantype.cpp | 2 +- native/common/jp_bytetype.cpp | 2 +- native/common/jp_chartype.cpp | 2 +- native/common/jp_doubletype.cpp | 2 +- native/common/jp_floattype.cpp | 2 +- native/common/jp_gc.cpp | 4 ++-- native/common/jp_inttype.cpp | 2 +- native/common/jp_longtype.cpp | 2 +- native/common/jp_shorttype.cpp | 2 +- native/common/jp_voidtype.cpp | 4 ++-- 21 files changed, 34 insertions(+), 34 deletions(-) diff --git a/native/common/include/jp_booleantype.h b/native/common/include/jp_booleantype.h index b0215ad49..6b19e0954 100755 --- a/native/common/include/jp_booleantype.h +++ b/native/common/include/jp_booleantype.h @@ -84,7 +84,7 @@ class JPBooleanType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -94,4 +94,4 @@ class JPBooleanType : public JPPrimitiveType } ; -#endif // _JP_BOOLEAN_TYPE_H_ \ No newline at end of file +#endif // _JP_BOOLEAN_TYPE_H_ diff --git a/native/common/include/jp_bytetype.h b/native/common/include/jp_bytetype.h index 0f35aec9d..d4ee8586d 100755 --- a/native/common/include/jp_bytetype.h +++ b/native/common/include/jp_bytetype.h @@ -87,7 +87,7 @@ class JPByteType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -100,4 +100,4 @@ class JPByteType : public JPPrimitiveType static const jlong _Byte_Max = -128; } ; -#endif // _JPBYTE_TYPE_H_ \ No newline at end of file +#endif // _JPBYTE_TYPE_H_ diff --git a/native/common/include/jp_chartype.h b/native/common/include/jp_chartype.h index acd140105..730d57f22 100755 --- a/native/common/include/jp_chartype.h +++ b/native/common/include/jp_chartype.h @@ -80,7 +80,7 @@ class JPCharType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -90,4 +90,4 @@ class JPCharType : public JPPrimitiveType } ; -#endif // _JP-CHAR_TYPE_H_ \ No newline at end of file +#endif // _JP-CHAR_TYPE_H_ diff --git a/native/common/include/jp_doubletype.h b/native/common/include/jp_doubletype.h index 9e0e6222f..209a204d2 100755 --- a/native/common/include/jp_doubletype.h +++ b/native/common/include/jp_doubletype.h @@ -84,7 +84,7 @@ class JPDoubleType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -93,4 +93,4 @@ class JPDoubleType : public JPPrimitiveType JPPyBuffer& view, int subs, int base, jobject dims) override; } ; -#endif // _JP_DOUBLE_TYPE_H_ \ No newline at end of file +#endif // _JP_DOUBLE_TYPE_H_ diff --git a/native/common/include/jp_floattype.h b/native/common/include/jp_floattype.h index 56edb90f9..b0c73f4cf 100755 --- a/native/common/include/jp_floattype.h +++ b/native/common/include/jp_floattype.h @@ -84,7 +84,7 @@ class JPFloatType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -94,4 +94,4 @@ class JPFloatType : public JPPrimitiveType } ; -#endif // _JP_FLOAT_TYPE_H_ \ No newline at end of file +#endif // _JP_FLOAT_TYPE_H_ diff --git a/native/common/include/jp_inttype.h b/native/common/include/jp_inttype.h index 2d7876a83..590be95bb 100755 --- a/native/common/include/jp_inttype.h +++ b/native/common/include/jp_inttype.h @@ -89,7 +89,7 @@ class JPIntType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -99,4 +99,4 @@ class JPIntType : public JPPrimitiveType } ; -#endif // _JP_INT_TYPE_H_ \ No newline at end of file +#endif // _JP_INT_TYPE_H_ diff --git a/native/common/include/jp_longtype.h b/native/common/include/jp_longtype.h index 6319ac60d..0c2be13a0 100755 --- a/native/common/include/jp_longtype.h +++ b/native/common/include/jp_longtype.h @@ -88,7 +88,7 @@ class JPLongType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -98,4 +98,4 @@ class JPLongType : public JPPrimitiveType } ; -#endif // _JP_LONG_TYPE_H_ \ No newline at end of file +#endif // _JP_LONG_TYPE_H_ diff --git a/native/common/include/jp_primitivetype.h b/native/common/include/jp_primitivetype.h index 654251fed..281bebf71 100644 --- a/native/common/include/jp_primitivetype.h +++ b/native/common/include/jp_primitivetype.h @@ -41,7 +41,7 @@ class JPPrimitiveType : public JPClass virtual void getView(JPArrayView& view) = 0; virtual void releaseView(JPArrayView& view) = 0; virtual const char* getBufferFormat() = 0; - virtual ssize_t getItemSize() = 0; + virtual Py_ssize_t getItemSize() = 0; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) = 0; @@ -53,4 +53,4 @@ class JPPrimitiveType : public JPClass PyObject *convertLong(PyTypeObject* wrapper, PyLongObject* tmp); } ; -#endif \ No newline at end of file +#endif diff --git a/native/common/include/jp_shorttype.h b/native/common/include/jp_shorttype.h index ab9448a34..5a919cb1a 100755 --- a/native/common/include/jp_shorttype.h +++ b/native/common/include/jp_shorttype.h @@ -88,7 +88,7 @@ class JPShortType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -98,4 +98,4 @@ class JPShortType : public JPPrimitiveType } ; -#endif // _JP_SHORT_TYPE_H_ \ No newline at end of file +#endif // _JP_SHORT_TYPE_H_ diff --git a/native/common/include/jp_voidtype.h b/native/common/include/jp_voidtype.h index 98ed741cc..039119798 100755 --- a/native/common/include/jp_voidtype.h +++ b/native/common/include/jp_voidtype.h @@ -54,7 +54,7 @@ class JPVoidType : public JPPrimitiveType virtual void getView(JPArrayView& view) override; virtual void releaseView(JPArrayView& view) override; virtual const char* getBufferFormat() override; - virtual ssize_t getItemSize() override; + virtual Py_ssize_t getItemSize() override; virtual void copyElements(JPJavaFrame &frame, jarray a, jsize start, jsize len, void* memory, int offset) override; @@ -62,4 +62,4 @@ class JPVoidType : public JPPrimitiveType JPPyBuffer& view, int subs, int base, jobject dims) override; } ; -#endif // _JP_VOID_TYPE_H_ \ No newline at end of file +#endif // _JP_VOID_TYPE_H_ diff --git a/native/common/jp_array.cpp b/native/common/jp_array.cpp index 8b62444c2..2adf57e90 100644 --- a/native/common/jp_array.cpp +++ b/native/common/jp_array.cpp @@ -178,8 +178,8 @@ JPArrayView::JPArrayView(JPArray* array, jobject collection) // Second element is the shape of the array from which we compute the // memory size, the shape, and strides int dims; - ssize_t itemsize; - ssize_t sz; + Py_ssize_t itemsize; + Py_ssize_t sz; { JPPrimitiveArrayAccessor accessor(frame, (jintArray) item1, &JPJavaFrame::GetIntArrayElements, &JPJavaFrame::ReleaseIntArrayElements); diff --git a/native/common/jp_booleantype.cpp b/native/common/jp_booleantype.cpp index 07226e578..25a6317ce 100644 --- a/native/common/jp_booleantype.cpp +++ b/native/common/jp_booleantype.cpp @@ -333,7 +333,7 @@ const char* JPBooleanType::getBufferFormat() return "?"; } -ssize_t JPBooleanType::getItemSize() +Py_ssize_t JPBooleanType::getItemSize() { return sizeof (jboolean); } diff --git a/native/common/jp_bytetype.cpp b/native/common/jp_bytetype.cpp index 68a93b921..a81db8407 100644 --- a/native/common/jp_bytetype.cpp +++ b/native/common/jp_bytetype.cpp @@ -271,7 +271,7 @@ const char* JPByteType::getBufferFormat() return "b"; } -ssize_t JPByteType::getItemSize() +Py_ssize_t JPByteType::getItemSize() { return sizeof (jbyte); } diff --git a/native/common/jp_chartype.cpp b/native/common/jp_chartype.cpp index ff7c48dfb..24094bea5 100644 --- a/native/common/jp_chartype.cpp +++ b/native/common/jp_chartype.cpp @@ -274,7 +274,7 @@ const char* JPCharType::getBufferFormat() return "H"; } -ssize_t JPCharType::getItemSize() +Py_ssize_t JPCharType::getItemSize() { return sizeof (jchar); } diff --git a/native/common/jp_doubletype.cpp b/native/common/jp_doubletype.cpp index 7a5f4a81b..ab7c0643c 100644 --- a/native/common/jp_doubletype.cpp +++ b/native/common/jp_doubletype.cpp @@ -312,7 +312,7 @@ const char* JPDoubleType::getBufferFormat() return "d"; } -ssize_t JPDoubleType::getItemSize() +Py_ssize_t JPDoubleType::getItemSize() { return sizeof (jdouble); } diff --git a/native/common/jp_floattype.cpp b/native/common/jp_floattype.cpp index a8d7ed690..317e88f17 100644 --- a/native/common/jp_floattype.cpp +++ b/native/common/jp_floattype.cpp @@ -295,7 +295,7 @@ const char* JPFloatType::getBufferFormat() return "f"; } -ssize_t JPFloatType::getItemSize() +Py_ssize_t JPFloatType::getItemSize() { return sizeof (jfloat); } diff --git a/native/common/jp_gc.cpp b/native/common/jp_gc.cpp index 968a1da9b..8b711f997 100644 --- a/native/common/jp_gc.cpp +++ b/native/common/jp_gc.cpp @@ -234,9 +234,9 @@ void JPGarbageCollection::onEnd() } // Predict if we will cross the limit soon. - ssize_t pred = current + 2 * (current - last); + Py_ssize_t pred = current + 2 * (current - last); last = current; - if ((ssize_t) pred > (ssize_t) limit) + if ((Py_ssize_t) pred > (Py_ssize_t) limit) run_gc = 2; // printf("consider gc %d (%ld, %ld, %ld, %ld) %ld\n", run_gc, diff --git a/native/common/jp_inttype.cpp b/native/common/jp_inttype.cpp index 07d4bcdcd..5a42f98a5 100644 --- a/native/common/jp_inttype.cpp +++ b/native/common/jp_inttype.cpp @@ -298,7 +298,7 @@ const char* JPIntType::getBufferFormat() return "i"; } -ssize_t JPIntType::getItemSize() +Py_ssize_t JPIntType::getItemSize() { return sizeof (jfloat); } diff --git a/native/common/jp_longtype.cpp b/native/common/jp_longtype.cpp index d5cb995b7..cba98cfc4 100644 --- a/native/common/jp_longtype.cpp +++ b/native/common/jp_longtype.cpp @@ -297,7 +297,7 @@ const char* JPLongType::getBufferFormat() return "q"; } -ssize_t JPLongType::getItemSize() +Py_ssize_t JPLongType::getItemSize() { return sizeof (jlong); } diff --git a/native/common/jp_shorttype.cpp b/native/common/jp_shorttype.cpp index 372c8b829..12e60d979 100644 --- a/native/common/jp_shorttype.cpp +++ b/native/common/jp_shorttype.cpp @@ -294,7 +294,7 @@ const char* JPShortType::getBufferFormat() return "h"; } -ssize_t JPShortType::getItemSize() +Py_ssize_t JPShortType::getItemSize() { return sizeof (jshort); } diff --git a/native/common/jp_voidtype.cpp b/native/common/jp_voidtype.cpp index 2ab201acb..fcbe9cff3 100644 --- a/native/common/jp_voidtype.cpp +++ b/native/common/jp_voidtype.cpp @@ -122,7 +122,7 @@ const char* JPVoidType::getBufferFormat() return NULL; } -ssize_t JPVoidType::getItemSize() +Py_ssize_t JPVoidType::getItemSize() { return 0; } @@ -154,4 +154,4 @@ PyObject *JPVoidType::newMultiArray(JPJavaFrame &frame, return NULL; } -// GCOVR_EXCL_STOP \ No newline at end of file +// GCOVR_EXCL_STOP From 8c71b7c3dacc3d9c2e5f489b691da1ff8593ffa5 Mon Sep 17 00:00:00 2001 From: "Karl E. Nelson" Date: Mon, 18 Oct 2021 08:58:26 -0700 Subject: [PATCH 2/4] Missed one. --- doc/CHANGELOG.rst | 3 +++ native/python/include/jp_pythontypes.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/CHANGELOG.rst b/doc/CHANGELOG.rst index ad1039609..b782d44ad 100644 --- a/doc/CHANGELOG.rst +++ b/doc/CHANGELOG.rst @@ -5,6 +5,9 @@ This changelog *only* contains changes from the *first* pypi release (0.5.4.3) o Latest Changes: - **1.3.1_dev0 - 2021-06-05** + + - Fixed issue with ssize_t on Windows for Python 3.10. + - **1.3.0 - 2021-05-19** - Fixes for memory issues found when upgrading to Python 3.10 beta. diff --git a/native/python/include/jp_pythontypes.h b/native/python/include/jp_pythontypes.h index 93e91d8e0..58575cd1e 100755 --- a/native/python/include/jp_pythontypes.h +++ b/native/python/include/jp_pythontypes.h @@ -281,7 +281,7 @@ class JPPyObjectVector return m_Contents.size(); } - PyObject* operator[](ssize_t i) + PyObject* operator[](Py_ssize_t i) { return m_Contents[i].get(); } From 0b8b7e740c354b39380b1d39c5bc1a4ee9fd9fb8 Mon Sep 17 00:00:00 2001 From: "Karl E. Nelson" Date: Fri, 22 Oct 2021 15:32:46 -0700 Subject: [PATCH 3/4] Trivial change to see why CI failed to complete. --- native/common/jp_class.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/native/common/jp_class.cpp b/native/common/jp_class.cpp index 5e220635b..3ff941aad 100644 --- a/native/common/jp_class.cpp +++ b/native/common/jp_class.cpp @@ -424,7 +424,6 @@ void JPClass::getConversionInfo(JPConversionInfo &info) JP_TRACE_OUT; } - // // From 9325d3715fc3140204ba9178c5cf71cc9b2dd914 Mon Sep 17 00:00:00 2001 From: "Karl E. Nelson" Date: Fri, 22 Oct 2021 15:35:33 -0700 Subject: [PATCH 4/4] Try to update image. --- .azure/build.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.azure/build.yml b/.azure/build.yml index 374edb661..5538848d7 100644 --- a/.azure/build.yml +++ b/.azure/build.yml @@ -22,19 +22,19 @@ variables: jobs: - job: Deps pool: - vmImage: "ubuntu-16.04" + vmImage: "ubuntu-latest" steps: - template: scripts/ivy.yml - job: Documentation pool: - vmImage: "ubuntu-16.04" + vmImage: "ubuntu-latest" steps: - template: scripts/documentation.yml - job: Coverage pool: - vmImage: "ubuntu-16.04" + vmImage: "ubuntu-latest" dependsOn: Deps steps: - template: scripts/deps.yml @@ -42,7 +42,7 @@ jobs: - job: Tracing pool: - vmImage: "ubuntu-16.04" + vmImage: "ubuntu-latest" steps: - template: scripts/tracing.yml @@ -51,19 +51,19 @@ jobs: strategy: matrix: linux-3.5: - imageName: "ubuntu-16.04" + imageName: "ubuntu-latest" python.version: '3.5' linux-3.6: - imageName: "ubuntu-16.04" + imageName: "ubuntu-latest" python.version: '3.6' linux-3.7: - imageName: "ubuntu-16.04" + imageName: "ubuntu-latest" python.version: '3.7' linux-3.8: - imageName: "ubuntu-16.04" + imageName: "ubuntu-latest" python.version: '3.8' linux-3.9: - imageName: "ubuntu-16.04" + imageName: "ubuntu-latest" python.version: '3.9' windows-3.5: imageName: "vs2017-win2016"