Skip to content

Commit 7fbb404

Browse files
committed
Update numpy 1.26.4 patch
1 parent 03d0e48 commit 7fbb404

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

graalpython/lib-graalpython/patches/numpy/numpy-1.26.4.patch

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h
22
index d4b73eb..af90a68 100644
3-
--- a/vendored-meson/meson/mesonbuild/utils/universal.py
4-
+++ b/vendored-meson/meson/mesonbuild/utils/universal.py
5-
@@ -727,6 +727,7 @@ def windows_detect_native_arch() -> str:
6-
"""
7-
if sys.platform != 'win32':
8-
return ''
9-
+ return 'amd64' # Workaround for GraalPy bug on Windows with kernel32.GetCurrentProcess()
10-
try:
11-
import ctypes
12-
process_arch = ctypes.c_ushort()
133
--- a/numpy/core/include/numpy/ndarrayobject.h
144
+++ b/numpy/core/include/numpy/ndarrayobject.h
155
@@ -225,7 +225,7 @@ NPY_TITLE_KEY_check(PyObject *key, PyObject *value)
@@ -71,46 +61,46 @@ index 2890406..353a657 100644
7161
#include <feature_detection_misc.h>
7262

7363
diff --git a/numpy/core/src/npymath/ieee754.c.src b/numpy/core/src/npymath/ieee754.c.src
74-
index 8fccc9a..e7f79e1 100644
64+
index 8fccc9a..3bb9cf0 100644
7565
--- a/numpy/core/src/npymath/ieee754.c.src
7666
+++ b/numpy/core/src/npymath/ieee754.c.src
77-
@@ -362,6 +362,17 @@ int npy_get_floatstatus_barrier(char* param)
67+
@@ -362,6 +362,11 @@ int npy_get_floatstatus_barrier(char* param)
7868
* By using a volatile, the compiler cannot reorder this call
7969
*/
8070
if (param != NULL) {
8171
+ // GraalPy change: the pointer needs to be dereferenced to establish
8272
+ // a data dependency to to ensure the compiler won't reorder the call
83-
+#define HANDLE_BASE 0x8000000000000000ULL
84-
+#define points_to_py_handle_space(PTR) ((((uintptr_t) (PTR)) & HANDLE_BASE) != 0)
85-
+#define pointer_to_stub(PTR) ((PyObject *)(((uintptr_t) (PTR)) & ~HANDLE_BASE))
8673
+ if (points_to_py_handle_space(param)) {
87-
+ param = pointer_to_stub(param);
74+
+ param = (char*)pointer_to_stub(param);
8875
+ }
89-
+#undef points_to_py_handle_space
90-
+#undef pointer_to_stub
91-
+#undef HANDLE_BASE
9276
volatile char NPY_UNUSED(c) = *(char*)param;
9377
}
9478

9579
diff --git a/numpy/core/src/npymath/ieee754.cpp b/numpy/core/src/npymath/ieee754.cpp
96-
index 1c59bf3..131985e 100644
80+
index 1c59bf3..519fabc 100644
9781
--- a/numpy/core/src/npymath/ieee754.cpp
9882
+++ b/numpy/core/src/npymath/ieee754.cpp
99-
@@ -428,6 +428,17 @@ npy_get_floatstatus_barrier(char *param)
83+
@@ -428,6 +428,11 @@ npy_get_floatstatus_barrier(char *param)
10084
* By using a volatile, the compiler cannot reorder this call
10185
*/
10286
if (param != NULL) {
10387
+ // GraalPy change: the pointer needs to be dereferenced to establish
10488
+ // a data dependency to to ensure the compiler won't reorder the call
105-
+#define HANDLE_BASE 0x8000000000000000ULL
106-
+#define points_to_py_handle_space(PTR) ((((uintptr_t) (PTR)) & HANDLE_BASE) != 0)
107-
+#define pointer_to_stub(PTR) ((PyObject *)(((uintptr_t) (PTR)) & ~HANDLE_BASE))
10889
+ if (points_to_py_handle_space(param)) {
109-
+ param = pointer_to_stub(param);
90+
+ param = (char*)pointer_to_stub(param);
11091
+ }
111-
+#undef points_to_py_handle_space
112-
+#undef pointer_to_stub
113-
+#undef HANDLE_BASE
11492
volatile char NPY_UNUSED(c) = *(char *)param;
11593
}
11694

95+
diff --git a/vendored-meson/meson/mesonbuild/utils/universal.py b/vendored-meson/meson/mesonbuild/utils/universal.py
96+
index 1694912..a555fe3 100644
97+
--- a/vendored-meson/meson/mesonbuild/utils/universal.py
98+
+++ b/vendored-meson/meson/mesonbuild/utils/universal.py
99+
@@ -727,6 +727,7 @@ def windows_detect_native_arch() -> str:
100+
"""
101+
if sys.platform != 'win32':
102+
return ''
103+
+ return 'amd64' # Workaround for GraalPy bug on Windows with kernel32.GetCurrentProcess()
104+
try:
105+
import ctypes
106+
process_arch = ctypes.c_ushort()

0 commit comments

Comments
 (0)