diff --git a/Misc/NEWS.d/next/Build/2018-05-16-15-34-16.bpo-33351.8c-SEp.rst b/Misc/NEWS.d/next/Build/2018-05-16-15-34-16.bpo-33351.8c-SEp.rst new file mode 100644 index 00000000000000..c574d0aab4610c --- /dev/null +++ b/Misc/NEWS.d/next/Build/2018-05-16-15-34-16.bpo-33351.8c-SEp.rst @@ -0,0 +1,4 @@ +Add struct packing for pointer_t and fix struct packing under clang-cl for +frame_t. + +Patch by Ethan Smith diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index e07022cce2bc9c..b3ee5f3047fc53 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -67,7 +67,10 @@ static PyThread_type_lock tables_lock; #define DEFAULT_DOMAIN 0 -/* Pack the frame_t structure to reduce the memory footprint. */ +/* Pack the pointer_t structure to reduce the memory footprint. */ +#if defined(_MSC_VER) +#pragma pack(push, 4) +#endif typedef struct #ifdef __GNUC__ __attribute__((packed)) @@ -76,14 +79,18 @@ __attribute__((packed)) uintptr_t ptr; unsigned int domain; } pointer_t; +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* Pack the frame_t structure to reduce the memory footprint on 64-bit architectures: 12 bytes instead of 16. */ +#if defined(_MSC_VER) +#pragma pack(push, 4) +#endif typedef struct #ifdef __GNUC__ __attribute__((packed)) -#elif defined(_MSC_VER) -#pragma pack(push, 4) #endif { /* filename cannot be NULL: "" is used if the Python frame