summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-09-29 07:27:15 (GMT)
committerGeorg Brandl <georg@python.org>2012-09-29 07:27:15 (GMT)
commit99a247fd01c1cd780c0c3ee1116657627f1ee744 (patch)
tree319e33cb6612c3fafb2eb82e15c5e85e3d771e4f /Include
parent1628eaa5dc8892ff381ca7558cc7c8d80fac494d (diff)
parent8ed677db129171317b8ee7cd45b39b9013f5a2d6 (diff)
downloadcpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.zip
cpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.tar.gz
cpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.tar.bz2
Merge with main repo default branch.
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h2
-rw-r--r--Include/objimpl.h9
-rw-r--r--Include/pyfpe.h8
-rw-r--r--Include/pymacro.h14
4 files changed, 22 insertions, 11 deletions
diff --git a/Include/object.h b/Include/object.h
index 3aabb3b..387cadb 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -962,7 +962,7 @@ with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL.
*/
/* This is the old private API, invoked by the macros before 3.2.4.
- Kept for binary compatibility of extensions. */
+ Kept for binary compatibility of extensions using the stable ABI. */
PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*);
PyAPI_FUNC(void) _PyTrash_destroy_chain(void);
PyAPI_DATA(int) _PyTrash_delete_nesting;
diff --git a/Include/objimpl.h b/Include/objimpl.h
index b1a624c..3d5f509 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -181,12 +181,9 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
#endif
#define _PyObject_VAR_SIZE(typeobj, nitems) \
- (size_t) \
- ( ( (typeobj)->tp_basicsize + \
- (nitems)*(typeobj)->tp_itemsize + \
- (SIZEOF_VOID_P - 1) \
- ) & ~(SIZEOF_VOID_P - 1) \
- )
+ _Py_SIZE_ROUND_UP((typeobj)->tp_basicsize + \
+ (nitems)*(typeobj)->tp_itemsize, \
+ SIZEOF_VOID_P)
#define PyObject_NEW(type, typeobj) \
( (type *) PyObject_Init( \
diff --git a/Include/pyfpe.h b/Include/pyfpe.h
index 19110ab..e957119 100644
--- a/Include/pyfpe.h
+++ b/Include/pyfpe.h
@@ -4,8 +4,8 @@
extern "C" {
#endif
/*
- ---------------------------------------------------------------------
- / Copyright (c) 1996. \
+ ---------------------------------------------------------------------
+ / Copyright (c) 1996. \
| The Regents of the University of California. |
| All rights reserved. |
| |
@@ -37,8 +37,8 @@ extern "C" {
| opinions of authors expressed herein do not necessarily state or |
| reflect those of the United States Government or the University |
| of California, and shall not be used for advertising or product |
- \ endorsement purposes. /
- ---------------------------------------------------------------------
+ \ endorsement purposes. /
+ ---------------------------------------------------------------------
*/
/*
diff --git a/Include/pymacro.h b/Include/pymacro.h
index f3001f4..52e8ee3 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -52,4 +52,18 @@
#define PyDoc_STR(str) ""
#endif
+/* Below "a" is a power of 2. */
+/* Round down size "n" to be a multiple of "a". */
+#define _Py_SIZE_ROUND_DOWN(n, a) ((size_t)(n) & ~(size_t)((a) - 1))
+/* Round up size "n" to be a multiple of "a". */
+#define _Py_SIZE_ROUND_UP(n, a) (((size_t)(n) + \
+ (size_t)((a) - 1)) & ~(size_t)((a) - 1))
+/* Round pointer "p" down to the closest "a"-aligned address <= "p". */
+#define _Py_ALIGN_DOWN(p, a) ((void *)((Py_uintptr_t)(p) & ~(Py_uintptr_t)((a) - 1)))
+/* Round pointer "p" up to the closest "a"-aligned address >= "p". */
+#define _Py_ALIGN_UP(p, a) ((void *)(((Py_uintptr_t)(p) + \
+ (Py_uintptr_t)((a) - 1)) & ~(Py_uintptr_t)((a) - 1)))
+/* Check if pointer "p" is aligned to "a"-bytes boundary. */
+#define _Py_IS_ALIGNED(p, a) (!((Py_uintptr_t)(p) & (Py_uintptr_t)((a) - 1)))
+
#endif /* Py_PYMACRO_H */