Skip to content

Commit f0be4bb

Browse files
authored
bpo-27987: pymalloc: align by 16bytes on 64bit platform (GH-12850)
1 parent c923c34 commit f0be4bb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pymalloc returns memory blocks aligned by 16 bytes, instead of 8 bytes, on
2+
64-bit platforms to conform x86-64 ABI. Recent compilers assume this alignment
3+
more often. Patch by Inada Naoki.

Objects/obmalloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,14 @@ static int running_on_valgrind = -1;
795795
*
796796
* You shouldn't change this unless you know what you are doing.
797797
*/
798+
799+
#if SIZEOF_VOID_P > 4
800+
#define ALIGNMENT 16 /* must be 2^N */
801+
#define ALIGNMENT_SHIFT 4
802+
#else
798803
#define ALIGNMENT 8 /* must be 2^N */
799804
#define ALIGNMENT_SHIFT 3
805+
#endif
800806

801807
/* Return the number of bytes in size class I, as a uint. */
802808
#define INDEX2SIZE(I) (((uint)(I) + 1) << ALIGNMENT_SHIFT)

0 commit comments

Comments
 (0)