From 886edc68f41f74b07fb0e3a72d00ef979d8ea623 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Mon, 18 Mar 2013 17:11:20 -0700 Subject: 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. --- Modules/_ctypes/libffi/src/ia64/ffi.c | 20 +++++++++++++------- Modules/_ctypes/libffi/src/ia64/ffitarget.h | 11 ++++++++--- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'Modules/_ctypes/libffi/src/ia64') 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 -- cgit v1.2.1