summaryrefslogtreecommitdiff
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-01-13 09:20:31 -0500
committerBenjamin Peterson <benjamin@python.org>2015-01-13 09:20:31 -0500
commit5e89d93c8253f75f4b8dfcd9c972d8f2b18f5d86 (patch)
treea1ee70f2587b4de99afcb5b97acb92e0546d975f /Modules/_ctypes
parentf13a88399f22ed55a0085c76971bda507f4bbca6 (diff)
parent805cf71afda85ab6fe7618d4f0ca54b876e78f62 (diff)
downloadcpython-5e89d93c8253f75f4b8dfcd9c972d8f2b18f5d86.tar.gz
merge 3.4 (#23221)
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/callproc.c2
-rw-r--r--Modules/_ctypes/libffi_msvc/ffi.c37
2 files changed, 29 insertions, 10 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 8daeffca93..03a911fa06 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1603,7 +1603,7 @@ resize(PyObject *self, PyObject *args)
"Memory cannot be resized because this object doesn't own it");
return NULL;
}
- if (size <= sizeof(obj->b_value)) {
+ if ((size_t)size <= sizeof(obj->b_value)) {
/* internal default buffer is large enough */
obj->b_size = size;
goto done;
diff --git a/Modules/_ctypes/libffi_msvc/ffi.c b/Modules/_ctypes/libffi_msvc/ffi.c
index 76cb03efcd..b7586c70eb 100644
--- a/Modules/_ctypes/libffi_msvc/ffi.c
+++ b/Modules/_ctypes/libffi_msvc/ffi.c
@@ -65,37 +65,56 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
argp = (char *) ALIGN(argp, sizeof(void *));
z = (*p_arg)->size;
- if (z < sizeof(int))
+ if (z < sizeof(intptr_t))
{
- z = sizeof(int);
+ z = sizeof(intptr_t);
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
- *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ *(intptr_t *) argp = (intptr_t)*(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
- *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ *(uintptr_t *) argp = (uintptr_t)*(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
- *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ *(intptr_t *) argp = (intptr_t)*(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
- *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ *(uintptr_t *) argp = (uintptr_t)*(UINT16 *)(* p_argv);
break;
case FFI_TYPE_SINT32:
- *(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
+ *(intptr_t *) argp = (intptr_t)*(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
- *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ *(uintptr_t *) argp = (uintptr_t)*(UINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ *(uintptr_t *) argp = 0;
+ *(float *) argp = *(float *)(* p_argv);
+ break;
+
+ // 64-bit value cases should never be used for x86 and AMD64 builds
+ case FFI_TYPE_SINT64:
+ *(intptr_t *) argp = (intptr_t)*(SINT64 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT64:
+ *(uintptr_t *) argp = (uintptr_t)*(UINT64 *)(* p_argv);
break;
case FFI_TYPE_STRUCT:
- *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ *(uintptr_t *) argp = (uintptr_t)*(UINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ *(uintptr_t *) argp = 0;
+ *(double *) argp = *(double *)(* p_argv);
break;
default: