summaryrefslogtreecommitdiff
path: root/Modules/_ctypes/libffi/src/ia64
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2013-03-18 17:11:20 -0700
committerGregory P. Smith <greg@krypto.org>2013-03-18 17:11:20 -0700
commit886edc68f41f74b07fb0e3a72d00ef979d8ea623 (patch)
tree05c30cd51c5b77445b07b9c6bf14009c2053f4ce /Modules/_ctypes/libffi/src/ia64
parent5a43c024aa5d5ad981bf71362e26c0080b4a2e6f (diff)
downloadcpython-886edc68f41f74b07fb0e3a72d00ef979d8ea623.tar.gz
Fixes issue #17192: Update the ctypes module's libffi to v3.0.13. This
specifically addresses a stack misalignment issue on x86 and issues on some more recent platforms.
Diffstat (limited to 'Modules/_ctypes/libffi/src/ia64')
-rw-r--r--Modules/_ctypes/libffi/src/ia64/ffi.c20
-rw-r--r--Modules/_ctypes/libffi/src/ia64/ffitarget.h11
2 files changed, 21 insertions, 10 deletions
diff --git a/Modules/_ctypes/libffi/src/ia64/ffi.c b/Modules/_ctypes/libffi/src/ia64/ffi.c
index f637834111..9533ef68b5 100644
--- a/Modules/_ctypes/libffi/src/ia64/ffi.c
+++ b/Modules/_ctypes/libffi/src/ia64/ffi.c
@@ -1,6 +1,7 @@
/* -----------------------------------------------------------------------
- ffi.c - Copyright (c) 1998, 2007, 2008 Red Hat, Inc.
+ ffi.c - Copyright (c) 1998, 2007, 2008, 2012 Red Hat, Inc.
Copyright (c) 2000 Hewlett Packard Company
+ Copyright (c) 2011 Anthony Green
IA64 Foreign Function Interface
@@ -84,7 +85,7 @@ endian_adjust (void *addr, size_t len)
#define ldf_fill(result, addr) \
asm ("ldf.fill %0 = %1%P1" : "=f"(result) : "m"(*addr));
-/* Return the size of the C type associated with TYPE, which will
+/* Return the size of the C type associated with with TYPE. Which will
be one of the FFI_IA64_TYPE_HFA_* values. */
static size_t
@@ -184,7 +185,7 @@ hfa_element_type (ffi_type *type, int nested)
break;
case FFI_TYPE_LONGDOUBLE:
- /* Similarly, except that HFA is true for double extended,
+ /* Similarly, except that that HFA is true for double extended,
but not quad precision. Both have sizeof == 16, so tell the
difference based on the precision. */
if (LDBL_MANT_DIG == 64 && nested)
@@ -225,7 +226,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
int flags;
/* Adjust cif->bytes to include space for the bits of the ia64_args frame
- that preceeds the integer register portion. The estimate that the
+ that precedes the integer register portion. The estimate that the
generic bits did for the argument space required is good enough for the
integer component. */
cif->bytes += offsetof(struct ia64_args, gp_regs[0]);
@@ -324,13 +325,17 @@ ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
case FFI_TYPE_FLOAT:
if (gpcount < 8 && fpcount < 8)
stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]);
- stack->gp_regs[gpcount++] = *(UINT32 *)avalue[i];
+ {
+ UINT32 tmp;
+ memcpy (&tmp, avalue[i], sizeof (UINT32));
+ stack->gp_regs[gpcount++] = tmp;
+ }
break;
case FFI_TYPE_DOUBLE:
if (gpcount < 8 && fpcount < 8)
stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]);
- stack->gp_regs[gpcount++] = *(UINT64 *)avalue[i];
+ memcpy (&stack->gp_regs[gpcount++], avalue[i], sizeof (UINT64));
break;
case FFI_TYPE_LONGDOUBLE:
@@ -425,7 +430,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
struct ffi_ia64_trampoline_struct *tramp;
struct ia64_fd *fd;
- FFI_ASSERT (cif->abi == FFI_UNIX);
+ if (cif->abi != FFI_UNIX)
+ return FFI_BAD_ABI;
tramp = (struct ffi_ia64_trampoline_struct *)closure->tramp;
fd = (struct ia64_fd *)(void *)ffi_closure_unix;
diff --git a/Modules/_ctypes/libffi/src/ia64/ffitarget.h b/Modules/_ctypes/libffi/src/ia64/ffitarget.h
index d85c049ba3..e68cea6154 100644
--- a/Modules/_ctypes/libffi/src/ia64/ffitarget.h
+++ b/Modules/_ctypes/libffi/src/ia64/ffitarget.h
@@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*-
- ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
Target configuration macros for IA-64.
Permission is hereby granted, free of charge, to any person obtaining
@@ -27,6 +28,10 @@
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
#ifndef LIBFFI_ASM
typedef unsigned long long ffi_arg;
typedef signed long long ffi_sarg;
@@ -34,8 +39,8 @@ typedef signed long long ffi_sarg;
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
FFI_UNIX, /* Linux and all Unix variants use the same conventions */
- FFI_DEFAULT_ABI = FFI_UNIX,
- FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_UNIX
} ffi_abi;
#endif