summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorPaul Monson <paulmon@users.noreply.github.com>2019-04-18 01:09:16 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2019-04-18 01:09:16 (GMT)
commit11efd79076559cc6e4034bb36db73e5e4293f02d (patch)
tree13fb73b3d06b903cf857431d2622846131e829c0 /Modules/_ctypes
parent264a0b40b030fc0ff919b8294df91bdaac853bfb (diff)
downloadcpython-11efd79076559cc6e4034bb36db73e5e4293f02d.zip
cpython-11efd79076559cc6e4034bb36db73e5e4293f02d.tar.gz
cpython-11efd79076559cc6e4034bb36db73e5e4293f02d.tar.bz2
bpo-36071 Add support for Windows ARM32 in ctypes/libffi (GH-12059)
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/callbacks.c2
-rw-r--r--Modules/_ctypes/callproc.c11
-rw-r--r--Modules/_ctypes/malloc_closure.c5
3 files changed, 14 insertions, 4 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 2b7cb06..9f793c2 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -380,7 +380,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
}
cc = FFI_DEFAULT_ABI;
-#if defined(MS_WIN32) && !defined(_WIN32_WCE) && !defined(MS_WIN64)
+#if defined(MS_WIN32) && !defined(_WIN32_WCE) && !defined(MS_WIN64) && !defined(_M_ARM)
if ((flags & FUNCFLAG_CDECL) == 0)
cc = FFI_STDCALL;
#endif
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 5a943d3..1ad842e 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -737,12 +737,17 @@ of 1, 2, 4, 8, 16, 32, or 64 bits
*/
int can_return_struct_as_int(size_t s)
{
- return s == 1 || s == 2 || s == 4;
+ return s == 1 || s == 2 || s == 4;
}
int can_return_struct_as_sint64(size_t s)
{
- return s == 8;
+#ifdef _M_ARM
+ // 8 byte structs cannot be returned in a register on ARM32
+ return 0;
+#else
+ return s == 8;
+#endif
}
#endif
@@ -807,7 +812,7 @@ static int _call_function_pointer(int flags,
}
cc = FFI_DEFAULT_ABI;
-#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(_WIN32_WCE)
+#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(_WIN32_WCE) && !defined(_M_ARM)
if ((flags & FUNCFLAG_CDECL) == 0)
cc = FFI_STDCALL;
#endif
diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c
index 8ad7649..f9cdb33 100644
--- a/Modules/_ctypes/malloc_closure.c
+++ b/Modules/_ctypes/malloc_closure.c
@@ -106,6 +106,11 @@ void *ffi_closure_alloc(size_t ignored, void** codeloc)
return NULL;
item = free_list;
free_list = item->next;
+#ifdef _M_ARM
+ // set Thumb bit so that blx is called correctly
+ *codeloc = (ITEM*)((uintptr_t)item | 1);
+#else
*codeloc = (void *)item;
+#endif
return (void *)item;
}