Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Include/objimpl.h

    r2 r388  
    102102/* Macros */
    103103#ifdef WITH_PYMALLOC
    104 #ifdef PYMALLOC_DEBUG   /* WITH_PYMALLOC && PYMALLOC_DEBUG */
     104#ifdef PYMALLOC_DEBUG   /* WITH_PYMALLOC && PYMALLOC_DEBUG */
    105105PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes);
    106106PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes);
     
    109109PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p);
    110110PyAPI_FUNC(void) _PyObject_DebugMallocStats(void);
    111 #define PyObject_MALLOC         _PyObject_DebugMalloc
    112 #define PyObject_Malloc         _PyObject_DebugMalloc
    113 #define PyObject_REALLOC        _PyObject_DebugRealloc
    114 #define PyObject_Realloc        _PyObject_DebugRealloc
    115 #define PyObject_FREE           _PyObject_DebugFree
    116 #define PyObject_Free           _PyObject_DebugFree
    117 
    118 #else   /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
    119 #define PyObject_MALLOC         PyObject_Malloc
    120 #define PyObject_REALLOC        PyObject_Realloc
    121 #define PyObject_FREE           PyObject_Free
     111PyAPI_FUNC(void *) _PyObject_DebugMallocApi(char api, size_t nbytes);
     112PyAPI_FUNC(void *) _PyObject_DebugReallocApi(char api, void *p, size_t nbytes);
     113PyAPI_FUNC(void) _PyObject_DebugFreeApi(char api, void *p);
     114PyAPI_FUNC(void) _PyObject_DebugCheckAddressApi(char api, const void *p);
     115PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes);
     116PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes);
     117PyAPI_FUNC(void) _PyMem_DebugFree(void *p);
     118#define PyObject_MALLOC         _PyObject_DebugMalloc
     119#define PyObject_Malloc         _PyObject_DebugMalloc
     120#define PyObject_REALLOC        _PyObject_DebugRealloc
     121#define PyObject_Realloc        _PyObject_DebugRealloc
     122#define PyObject_FREE           _PyObject_DebugFree
     123#define PyObject_Free           _PyObject_DebugFree
     124
     125#else   /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
     126#define PyObject_MALLOC         PyObject_Malloc
     127#define PyObject_REALLOC        PyObject_Realloc
     128#define PyObject_FREE           PyObject_Free
    122129#endif
    123130
    124 #else   /* ! WITH_PYMALLOC */
    125 #define PyObject_MALLOC         PyMem_MALLOC
    126 #define PyObject_REALLOC        PyMem_REALLOC
    127 #define PyObject_FREE           PyMem_FREE
    128 
    129 #endif  /* WITH_PYMALLOC */
    130 
    131 #define PyObject_Del            PyObject_Free
    132 #define PyObject_DEL            PyObject_FREE
     131#else   /* ! WITH_PYMALLOC */
     132#define PyObject_MALLOC         PyMem_MALLOC
     133#define PyObject_REALLOC        PyMem_REALLOC
     134#define PyObject_FREE           PyMem_FREE
     135
     136#endif  /* WITH_PYMALLOC */
     137
     138#define PyObject_Del            PyObject_Free
     139#define PyObject_DEL            PyObject_FREE
    133140
    134141/* for source compatibility with 2.2 */
    135 #define _PyObject_Del           PyObject_Free
     142#define _PyObject_Del           PyObject_Free
    136143
    137144/*
     
    148155
    149156#define PyObject_New(type, typeobj) \
    150                 ( (type *) _PyObject_New(typeobj) )
     157                ( (type *) _PyObject_New(typeobj) )
    151158#define PyObject_NewVar(type, typeobj, n) \
    152                 ( (type *) _PyObject_NewVar((typeobj), (n)) )
     159                ( (type *) _PyObject_NewVar((typeobj), (n)) )
    153160
    154161/* Macros trading binary compatibility for speed. See also pymem.h.
    155162   Note that these macros expect non-NULL object pointers.*/
    156163#define PyObject_INIT(op, typeobj) \
    157         ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
     164    ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
    158165#define PyObject_INIT_VAR(op, typeobj, size) \
    159         ( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) )
     166    ( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) )
    160167
    161168#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
     
    175182#endif
    176183
    177 #define _PyObject_VAR_SIZE(typeobj, nitems)     \
    178         (size_t)                                \
    179         ( ( (typeobj)->tp_basicsize +           \
    180             (nitems)*(typeobj)->tp_itemsize +   \
    181             (SIZEOF_VOID_P - 1)                 \
    182           ) & ~(SIZEOF_VOID_P - 1)              \
    183         )
     184#define _PyObject_VAR_SIZE(typeobj, nitems)     \
     185    (size_t)                                    \
     186    ( ( (typeobj)->tp_basicsize +               \
     187        (nitems)*(typeobj)->tp_itemsize +       \
     188        (SIZEOF_VOID_P - 1)                     \
     189      ) & ~(SIZEOF_VOID_P - 1)                  \
     190    )
    184191
    185192#define PyObject_NEW(type, typeobj) \
    186193( (type *) PyObject_Init( \
    187         (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) )
     194    (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) )
    188195
    189196#define PyObject_NEW_VAR(type, typeobj, n) \
     
    197204       1) the actual allocation of the object storage;
    198205       2) the initialization of the Python specific fields
    199           in this storage with PyObject_{Init, InitVar}.
     206      in this storage with PyObject_{Init, InitVar}.
    200207
    201208   PyObject *
     
    206213       op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct));
    207214       if (op == NULL)
    208            return PyErr_NoMemory();
     215       return PyErr_NoMemory();
    209216
    210217       PyObject_Init(op, &YourTypeStruct);
     
    233240/* Test if an object has a GC head */
    234241#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \
    235         (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
     242    (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
    236243
    237244PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
    238245#define PyObject_GC_Resize(type, op, n) \
    239                 ( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) )
     246                ( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) )
    240247
    241248/* for source compatibility with 2.2 */
     
    244251/* GC information is stored BEFORE the object structure. */
    245252typedef union _gc_head {
    246         struct {
    247                 union _gc_head *gc_next;
    248                 union _gc_head *gc_prev;
    249                 Py_ssize_t gc_refs;
    250         } gc;
    251         long double dummy;  /* force worst-case alignment */
     253    struct {
     254        union _gc_head *gc_next;
     255        union _gc_head *gc_prev;
     256        Py_ssize_t gc_refs;
     257    } gc;
     258    long double dummy;  /* force worst-case alignment */
    252259} PyGC_Head;
    253260
     
    256263#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1)
    257264
    258 #define _PyGC_REFS_UNTRACKED                    (-2)
    259 #define _PyGC_REFS_REACHABLE                    (-3)
    260 #define _PyGC_REFS_TENTATIVELY_UNREACHABLE      (-4)
     265#define _PyGC_REFS_UNTRACKED                    (-2)
     266#define _PyGC_REFS_REACHABLE                    (-3)
     267#define _PyGC_REFS_TENTATIVELY_UNREACHABLE      (-4)
    261268
    262269/* Tell the GC to track this object.  NB: While the object is tracked the
    263270 * collector it must be safe to call the ob_traverse method. */
    264271#define _PyObject_GC_TRACK(o) do { \
    265         PyGC_Head *g = _Py_AS_GC(o); \
    266         if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \
    267                 Py_FatalError("GC object already tracked"); \
    268         g->gc.gc_refs = _PyGC_REFS_REACHABLE; \
    269         g->gc.gc_next = _PyGC_generation0; \
    270         g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \
    271         g->gc.gc_prev->gc.gc_next = g; \
    272         _PyGC_generation0->gc.gc_prev = g; \
     272    PyGC_Head *g = _Py_AS_GC(o); \
     273    if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \
     274        Py_FatalError("GC object already tracked"); \
     275    g->gc.gc_refs = _PyGC_REFS_REACHABLE; \
     276    g->gc.gc_next = _PyGC_generation0; \
     277    g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \
     278    g->gc.gc_prev->gc.gc_next = g; \
     279    _PyGC_generation0->gc.gc_prev = g; \
    273280    } while (0);
    274281
     
    278285 */
    279286#define _PyObject_GC_UNTRACK(o) do { \
    280         PyGC_Head *g = _Py_AS_GC(o); \
    281         assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \
    282         g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \
    283         g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \
    284         g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \
    285         g->gc.gc_next = NULL; \
     287    PyGC_Head *g = _Py_AS_GC(o); \
     288    assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \
     289    g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \
     290    g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \
     291    g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \
     292    g->gc.gc_next = NULL; \
    286293    } while (0);
     294
     295/* True if the object is currently tracked by the GC. */
     296#define _PyObject_GC_IS_TRACKED(o) \
     297    ((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED)
     298
     299/* True if the object may be tracked by the GC in the future, or already is.
     300   This can be useful to implement some optimizations. */
     301#define _PyObject_GC_MAY_BE_TRACKED(obj) \
     302    (PyObject_IS_GC(obj) && \
     303        (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
     304
    287305
    288306PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
     
    294312
    295313#define PyObject_GC_New(type, typeobj) \
    296                 ( (type *) _PyObject_GC_New(typeobj) )
     314                ( (type *) _PyObject_GC_New(typeobj) )
    297315#define PyObject_GC_NewVar(type, typeobj, n) \
    298                 ( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
     316                ( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
    299317
    300318
     
    304322 * looking as much alike as possible.
    305323 */
    306 #define Py_VISIT(op)                                                    \
    307         do {                                                            \
    308                 if (op) {                                               \
    309                         int vret = visit((PyObject *)(op), arg);        \
    310                         if (vret)                                       \
    311                                 return vret;                            \
    312                 }                                                       \
    313         } while (0)
     324#define Py_VISIT(op)                                                    \
     325    do {                                                                \
     326        if (op) {                                                       \
     327            int vret = visit((PyObject *)(op), arg);                    \
     328            if (vret)                                                   \
     329                return vret;                                            \
     330        }                                                               \
     331    } while (0)
    314332
    315333/* This is here for the sake of backwards compatibility.  Extensions that
     
    325343/* Test if a type supports weak references */
    326344#define PyType_SUPPORTS_WEAKREFS(t) \
    327         (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \
    328          && ((t)->tp_weaklistoffset > 0))
     345    (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \
     346     && ((t)->tp_weaklistoffset > 0))
    329347
    330348#define PyObject_GET_WEAKREFS_LISTPTR(o) \
    331         ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
     349    ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
    332350
    333351#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.