# HG changeset patch # User Armin Rigo # Date 1536839482 -7200 # Node ID 3184b0a675fc425b821b528d7fdf744b2f08dadf # Parent 97a61f7b0bcd48eb74f136280ffd8733e829f153 Issue 378 Workaround for a GCC bug diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -892,11 +892,21 @@ return 0; } +#ifdef __GNUC__ +/* This is a workaround for what I think is a GCC bug on several + platforms. See issue #378. */ +__attribute__((noinline)) +#endif +void _cffi_memcpy(char *target, const void *src, size_t size) +{ + memcpy(target, src, size); +} + #define _write_raw_data(type) \ do { \ if (size == sizeof(type)) { \ type r = (type)source; \ - memcpy(target, &r, sizeof(type)); \ + _cffi_memcpy(target, &r, sizeof(type)); \ return; \ } \ } while(0) @@ -970,8 +980,8 @@ if (size == 2*sizeof(type)) { \ type r = (type)source.real; \ type i = (type)source.imag; \ - memcpy(target, &r, sizeof(type)); \ - memcpy(target+sizeof(type), &i, sizeof(type)); \ + _cffi_memcpy(target, &r, sizeof(type)); \ + _cffi_memcpy(target+sizeof(type), &i, sizeof(type)); \ return; \ } \ } while(0)