summaryrefslogtreecommitdiff
path: root/Python/pyarena.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-09-29 14:14:19 -0400
committerBenjamin Peterson <benjamin@python.org>2012-09-29 14:14:19 -0400
commit14fb44e1bab9db128770f1d91d244916a669e7c3 (patch)
tree278d9ccc8f819b05f8114c3154087c70b88ed69c /Python/pyarena.c
parent1764c80925795b6f059e961c5a352c5ece5a7fff (diff)
parent99a247fd01c1cd780c0c3ee1116657627f1ee744 (diff)
downloadcpython-git-14fb44e1bab9db128770f1d91d244916a669e7c3.tar.gz
merge mostly from default
Diffstat (limited to 'Python/pyarena.c')
-rw-r--r--Python/pyarena.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Python/pyarena.c b/Python/pyarena.c
index 5a255ae497..bb2fd1e42a 100644
--- a/Python/pyarena.c
+++ b/Python/pyarena.c
@@ -12,8 +12,6 @@
#define DEFAULT_BLOCK_SIZE 8192
#define ALIGNMENT 8
-#define ALIGNMENT_MASK (ALIGNMENT - 1)
-#define ROUNDUP(x) (((x) + ALIGNMENT_MASK) & ~ALIGNMENT_MASK)
typedef struct _block {
/* Total number of bytes owned by this block available to pass out.
@@ -85,8 +83,8 @@ block_new(size_t size)
b->ab_size = size;
b->ab_mem = (void *)(b + 1);
b->ab_next = NULL;
- b->ab_offset = ROUNDUP((Py_uintptr_t)(b->ab_mem)) -
- (Py_uintptr_t)(b->ab_mem);
+ b->ab_offset = (char *)_Py_ALIGN_UP(b->ab_mem, ALIGNMENT) -
+ (char *)(b->ab_mem);
return b;
}
@@ -104,7 +102,7 @@ block_alloc(block *b, size_t size)
{
void *p;
assert(b);
- size = ROUNDUP(size);
+ size = _Py_SIZE_ROUND_UP(size, ALIGNMENT);
if (b->ab_offset + size > b->ab_size) {
/* If we need to allocate more memory than will fit in
the default block, allocate a one-off block that is