From bfdc958899e8b57510f2eb57ffdd8e93c2ac1d02 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 16 Apr 2019 10:53:12 +0900 Subject: [PATCH 1/3] bpo-27987: pymalloc: align by 16bytes on 64bit platform --- Objects/obmalloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 3ee143549d217f..0451d265aabc3e 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -795,8 +795,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) From ed6b7fd4a8cff3376b30cfb487ca4b0d36dcaa04 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 16 Apr 2019 11:52:24 +0900 Subject: [PATCH 2/3] add news entry --- .../Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst new file mode 100644 index 00000000000000..fdd3a2f901b4f1 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst @@ -0,0 +1,3 @@ +pymalloc returns memory blocks aligned by 16 bytes instead of 8 bytes on 64 +bit platforms, as recent compilers assume malloc returns 16 byte aligned +memory block. Patch by Inada Naoki. From b8b714afe62e29dbea8072c7532ac653b719eb49 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Tue, 16 Apr 2019 20:12:29 +0900 Subject: [PATCH 3/3] Update 2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst --- .../2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst index fdd3a2f901b4f1..b0f32a5c6c3f41 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2019-04-16-11-52-21.bpo-27987.n2_DcQ.rst @@ -1,3 +1,3 @@ -pymalloc returns memory blocks aligned by 16 bytes instead of 8 bytes on 64 -bit platforms, as recent compilers assume malloc returns 16 byte aligned -memory block. Patch by Inada Naoki. +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.