mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
This commit is contained in:
parent
bd25030019
commit
f95a1b3c53
248 changed files with 113361 additions and 113361 deletions
|
@ -101,7 +101,7 @@ PyAPI_FUNC(void) PyObject_Free(void *);
|
|||
|
||||
/* Macros */
|
||||
#ifdef WITH_PYMALLOC
|
||||
#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */
|
||||
#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */
|
||||
PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes);
|
||||
PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes);
|
||||
PyAPI_FUNC(void) _PyObject_DebugFree(void *p);
|
||||
|
@ -115,28 +115,28 @@ PyAPI_FUNC(void) _PyObject_DebugCheckAddressApi(char api, const void *p);
|
|||
PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes);
|
||||
PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes);
|
||||
PyAPI_FUNC(void) _PyMem_DebugFree(void *p);
|
||||
#define PyObject_MALLOC _PyObject_DebugMalloc
|
||||
#define PyObject_Malloc _PyObject_DebugMalloc
|
||||
#define PyObject_REALLOC _PyObject_DebugRealloc
|
||||
#define PyObject_Realloc _PyObject_DebugRealloc
|
||||
#define PyObject_FREE _PyObject_DebugFree
|
||||
#define PyObject_Free _PyObject_DebugFree
|
||||
#define PyObject_MALLOC _PyObject_DebugMalloc
|
||||
#define PyObject_Malloc _PyObject_DebugMalloc
|
||||
#define PyObject_REALLOC _PyObject_DebugRealloc
|
||||
#define PyObject_Realloc _PyObject_DebugRealloc
|
||||
#define PyObject_FREE _PyObject_DebugFree
|
||||
#define PyObject_Free _PyObject_DebugFree
|
||||
|
||||
#else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
|
||||
#define PyObject_MALLOC PyObject_Malloc
|
||||
#define PyObject_REALLOC PyObject_Realloc
|
||||
#define PyObject_FREE PyObject_Free
|
||||
#else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
|
||||
#define PyObject_MALLOC PyObject_Malloc
|
||||
#define PyObject_REALLOC PyObject_Realloc
|
||||
#define PyObject_FREE PyObject_Free
|
||||
#endif
|
||||
|
||||
#else /* ! WITH_PYMALLOC */
|
||||
#define PyObject_MALLOC PyMem_MALLOC
|
||||
#define PyObject_REALLOC PyMem_REALLOC
|
||||
#define PyObject_FREE PyMem_FREE
|
||||
#else /* ! WITH_PYMALLOC */
|
||||
#define PyObject_MALLOC PyMem_MALLOC
|
||||
#define PyObject_REALLOC PyMem_REALLOC
|
||||
#define PyObject_FREE PyMem_FREE
|
||||
|
||||
#endif /* WITH_PYMALLOC */
|
||||
#endif /* WITH_PYMALLOC */
|
||||
|
||||
#define PyObject_Del PyObject_Free
|
||||
#define PyObject_DEL PyObject_FREE
|
||||
#define PyObject_Del PyObject_Free
|
||||
#define PyObject_DEL PyObject_FREE
|
||||
|
||||
/*
|
||||
* Generic object allocator interface
|
||||
|
@ -151,16 +151,16 @@ PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);
|
|||
PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
|
||||
#define PyObject_New(type, typeobj) \
|
||||
( (type *) _PyObject_New(typeobj) )
|
||||
( (type *) _PyObject_New(typeobj) )
|
||||
#define PyObject_NewVar(type, typeobj, n) \
|
||||
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
||||
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
||||
|
||||
/* Macros trading binary compatibility for speed. See also pymem.h.
|
||||
Note that these macros expect non-NULL object pointers.*/
|
||||
#define PyObject_INIT(op, typeobj) \
|
||||
( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
#define PyObject_INIT_VAR(op, typeobj, size) \
|
||||
( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) )
|
||||
( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) )
|
||||
|
||||
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
|
||||
|
||||
|
@ -178,17 +178,17 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
|||
# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2"
|
||||
#endif
|
||||
|
||||
#define _PyObject_VAR_SIZE(typeobj, nitems) \
|
||||
(size_t) \
|
||||
( ( (typeobj)->tp_basicsize + \
|
||||
(nitems)*(typeobj)->tp_itemsize + \
|
||||
(SIZEOF_VOID_P - 1) \
|
||||
) & ~(SIZEOF_VOID_P - 1) \
|
||||
)
|
||||
#define _PyObject_VAR_SIZE(typeobj, nitems) \
|
||||
(size_t) \
|
||||
( ( (typeobj)->tp_basicsize + \
|
||||
(nitems)*(typeobj)->tp_itemsize + \
|
||||
(SIZEOF_VOID_P - 1) \
|
||||
) & ~(SIZEOF_VOID_P - 1) \
|
||||
)
|
||||
|
||||
#define PyObject_NEW(type, typeobj) \
|
||||
( (type *) PyObject_Init( \
|
||||
(PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) )
|
||||
(PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) )
|
||||
|
||||
#define PyObject_NEW_VAR(type, typeobj, n) \
|
||||
( (type *) PyObject_InitVar( \
|
||||
|
@ -200,7 +200,7 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
|||
distinction between two steps (at least):
|
||||
1) the actual allocation of the object storage;
|
||||
2) the initialization of the Python specific fields
|
||||
in this storage with PyObject_{Init, InitVar}.
|
||||
in this storage with PyObject_{Init, InitVar}.
|
||||
|
||||
PyObject *
|
||||
YourObject_New(...)
|
||||
|
@ -209,7 +209,7 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
|||
|
||||
op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct));
|
||||
if (op == NULL)
|
||||
return PyErr_NoMemory();
|
||||
return PyErr_NoMemory();
|
||||
|
||||
PyObject_Init(op, &YourTypeStruct);
|
||||
|
||||
|
@ -236,44 +236,44 @@ PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
|
|||
|
||||
/* Test if an object has a GC head */
|
||||
#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \
|
||||
(Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
|
||||
(Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
|
||||
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
|
||||
#define PyObject_GC_Resize(type, op, n) \
|
||||
( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) )
|
||||
( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) )
|
||||
|
||||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_GC_Del PyObject_GC_Del
|
||||
|
||||
/* GC information is stored BEFORE the object structure. */
|
||||
typedef union _gc_head {
|
||||
struct {
|
||||
union _gc_head *gc_next;
|
||||
union _gc_head *gc_prev;
|
||||
Py_ssize_t gc_refs;
|
||||
} gc;
|
||||
long double dummy; /* force worst-case alignment */
|
||||
struct {
|
||||
union _gc_head *gc_next;
|
||||
union _gc_head *gc_prev;
|
||||
Py_ssize_t gc_refs;
|
||||
} gc;
|
||||
long double dummy; /* force worst-case alignment */
|
||||
} PyGC_Head;
|
||||
|
||||
extern PyGC_Head *_PyGC_generation0;
|
||||
|
||||
#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1)
|
||||
|
||||
#define _PyGC_REFS_UNTRACKED (-2)
|
||||
#define _PyGC_REFS_REACHABLE (-3)
|
||||
#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4)
|
||||
#define _PyGC_REFS_UNTRACKED (-2)
|
||||
#define _PyGC_REFS_REACHABLE (-3)
|
||||
#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4)
|
||||
|
||||
/* Tell the GC to track this object. NB: While the object is tracked the
|
||||
* collector it must be safe to call the ob_traverse method. */
|
||||
#define _PyObject_GC_TRACK(o) do { \
|
||||
PyGC_Head *g = _Py_AS_GC(o); \
|
||||
if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \
|
||||
Py_FatalError("GC object already tracked"); \
|
||||
g->gc.gc_refs = _PyGC_REFS_REACHABLE; \
|
||||
g->gc.gc_next = _PyGC_generation0; \
|
||||
g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \
|
||||
g->gc.gc_prev->gc.gc_next = g; \
|
||||
_PyGC_generation0->gc.gc_prev = g; \
|
||||
PyGC_Head *g = _Py_AS_GC(o); \
|
||||
if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \
|
||||
Py_FatalError("GC object already tracked"); \
|
||||
g->gc.gc_refs = _PyGC_REFS_REACHABLE; \
|
||||
g->gc.gc_next = _PyGC_generation0; \
|
||||
g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \
|
||||
g->gc.gc_prev->gc.gc_next = g; \
|
||||
_PyGC_generation0->gc.gc_prev = g; \
|
||||
} while (0);
|
||||
|
||||
/* Tell the GC to stop tracking this object.
|
||||
|
@ -281,23 +281,23 @@ extern PyGC_Head *_PyGC_generation0;
|
|||
* way to provoke memory errors if calling code is confused.
|
||||
*/
|
||||
#define _PyObject_GC_UNTRACK(o) do { \
|
||||
PyGC_Head *g = _Py_AS_GC(o); \
|
||||
assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \
|
||||
g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \
|
||||
g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \
|
||||
g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \
|
||||
g->gc.gc_next = NULL; \
|
||||
PyGC_Head *g = _Py_AS_GC(o); \
|
||||
assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \
|
||||
g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \
|
||||
g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \
|
||||
g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \
|
||||
g->gc.gc_next = NULL; \
|
||||
} while (0);
|
||||
|
||||
/* True if the object is currently tracked by the GC. */
|
||||
#define _PyObject_GC_IS_TRACKED(o) \
|
||||
((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED)
|
||||
|
||||
((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED)
|
||||
|
||||
/* True if the object may be tracked by the GC in the future, or already is.
|
||||
This can be useful to implement some optimizations. */
|
||||
#define _PyObject_GC_MAY_BE_TRACKED(obj) \
|
||||
(PyObject_IS_GC(obj) && \
|
||||
(!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
|
||||
(PyObject_IS_GC(obj) && \
|
||||
(!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
|
||||
|
@ -308,9 +308,9 @@ PyAPI_FUNC(void) PyObject_GC_UnTrack(void *);
|
|||
PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
||||
|
||||
#define PyObject_GC_New(type, typeobj) \
|
||||
( (type *) _PyObject_GC_New(typeobj) )
|
||||
( (type *) _PyObject_GC_New(typeobj) )
|
||||
#define PyObject_GC_NewVar(type, typeobj, n) \
|
||||
( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
|
||||
( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
|
||||
|
||||
|
||||
/* Utility macro to help write tp_traverse functions.
|
||||
|
@ -318,14 +318,14 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
|||
* "visit" and "arg". This is intended to keep tp_traverse functions
|
||||
* looking as much alike as possible.
|
||||
*/
|
||||
#define Py_VISIT(op) \
|
||||
do { \
|
||||
if (op) { \
|
||||
int vret = visit((PyObject *)(op), arg); \
|
||||
if (vret) \
|
||||
return vret; \
|
||||
} \
|
||||
} while (0)
|
||||
#define Py_VISIT(op) \
|
||||
do { \
|
||||
if (op) { \
|
||||
int vret = visit((PyObject *)(op), arg); \
|
||||
if (vret) \
|
||||
return vret; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* This is here for the sake of backwards compatibility. Extensions that
|
||||
* use the old GC API will still compile but the objects will not be
|
||||
|
@ -341,7 +341,7 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
|||
#define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
|
||||
|
||||
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
|
||||
((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
|
||||
((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue