Skip to content

Commit f24a9f3

Browse files
authored
bpo-27987: pymalloc: align by 16bytes on 64bit platform (GH-12850) (GH-13319)
(cherry picked from commit f0be4bb)
1 parent 353f8d2 commit f24a9f3

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
@@ -154,8 +154,14 @@ static int running_on_valgrind = -1;
154154
*
155155
* You shouldn't change this unless you know what you are doing.
156156
*/
157+
158+
#if SIZEOF_VOID_P > 4
159+
#define ALIGNMENT 16 /* must be 2^N */
160+
#define ALIGNMENT_SHIFT 4
161+
#else
157162
#define ALIGNMENT 8 /* must be 2^N */
158163
#define ALIGNMENT_SHIFT 3
164+
#endif
159165
#define ALIGNMENT_MASK (ALIGNMENT - 1)
160166

161167
/* Return the number of bytes in size class I, as a uint. */

0 commit comments

Comments
 (0)