bpo-27987: pymalloc: align by 16bytes on 64bit platform (GH-12850)

(cherry picked from commit f0be4bbb9b)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-05-25 10:18:34 -07:00 committed by GitHub
parent 2156fec1f7
commit 1b85f4ec45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,3 @@
pymalloc returns memory blocks aligned by 16 bytes, instead of 8 bytes, on
64-bit platforms to conform x86-64 ABI. Recent compilers assume this alignment
more often. Patch by Inada Naoki.

View File

@ -788,8 +788,14 @@ static int running_on_valgrind = -1;
*
* You shouldn't change this unless you know what you are doing.
*/
#if SIZEOF_VOID_P > 4
#define ALIGNMENT 16 /* must be 2^N */
#define ALIGNMENT_SHIFT 4
#else
#define ALIGNMENT 8 /* must be 2^N */
#define ALIGNMENT_SHIFT 3
#endif
/* Return the number of bytes in size class I, as a uint. */
#define INDEX2SIZE(I) (((uint)(I) + 1) << ALIGNMENT_SHIFT)