~jtaylor/ubuntu/precise/python-numpy/multiarch-fix-818867

« back to all changes in this revision

Viewing changes to numpy/core/include/numpy/ndarrayobject.h

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2010-10-07 10:19:13 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101007101913-8b1kmt8ho4upcl9s
Tags: 1:1.4.1-5
* debian/patches/10_use_local_python.org_object.inv_sphinx.diff
  - fixed small typo in description
* debian/patches/changeset_r8364.diff
  - fix memory corruption (double free); thanks to Joseph Barillari for the
    report and to Michael Gilbert for pushing resolution; Closes: #581058

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
/* ... otherwise a semi-smart identer (like emacs) tries to indent
14
14
       everything when you're typing */
15
15
#endif
 
16
 
16
17
/* This is auto-generated by the installer */
17
18
#include "numpyconfig.h"
18
19
 
 
20
#ifdef NPY_ENABLE_SEPARATE_COMPILATION
 
21
        #define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN
 
22
#else
 
23
        #define NPY_NO_EXPORT static
 
24
#endif
 
25
 
19
26
/* Only use thread if configured in config and python supports it */
20
27
#if defined WITH_THREAD && !NPY_NO_SMP
21
28
        #define NPY_ALLOW_THREADS 1
46
53
   whenever the C-API is changed such that binary compatibility is
47
54
   broken, i.e. whenever a recompile of extension modules is
48
55
   needed. */
49
 
#define NPY_VERSION 0x01000009
 
56
#define NPY_VERSION NPY_ABI_VERSION
50
57
 
51
58
/* Minor API version.  This number is increased whenever a change is
52
59
   made to the C-API -- whether it breaks binary compatibility or not.
56
63
   would be increased.  Whenever binary compatibility is broken, both
57
64
   NPY_VERSION and NPY_FEATURE_VERSION should be increased.
58
65
 */
59
 
#define NPY_FEATURE_VERSION 0x00000001
 
66
#define NPY_FEATURE_VERSION NPY_API_VERSION
60
67
 
61
68
#include "npy_common.h"
62
69
 
77
84
                    NPY_USERDEF=256  /* leave room for characters */
78
85
};
79
86
 
 
87
#define NPY_METADATA_DTSTR "__frequency__"
 
88
 
80
89
/* basetype array priority */
81
90
#define NPY_PRIORITY 0.0
82
91
 
121
130
                        NPY_STRINGLTR2 = 'a',
122
131
                        NPY_UNICODELTR = 'U',
123
132
                        NPY_VOIDLTR = 'V',
 
133
                        NPY_DATETIMELTR = 'M',
 
134
                        NPY_TIMEDELTALTR = 'm',
124
135
                        NPY_CHARLTR = 'c',
125
136
 
126
137
                        /* No Descriptor, just a define -- this let's
175
186
        NPY_RAISE=2
176
187
} NPY_CLIPMODE;
177
188
 
 
189
typedef enum {
 
190
        NPY_FR_Y,
 
191
        NPY_FR_M,
 
192
        NPY_FR_W,
 
193
        NPY_FR_B,
 
194
        NPY_FR_D,
 
195
        NPY_FR_h,
 
196
        NPY_FR_m,
 
197
        NPY_FR_s,
 
198
        NPY_FR_ms,
 
199
        NPY_FR_us,
 
200
        NPY_FR_ns,
 
201
        NPY_FR_ps,
 
202
        NPY_FR_fs,
 
203
        NPY_FR_as
 
204
} NPY_DATETIMEUNIT;
 
205
 
 
206
#define NPY_DATETIME_NUMUNITS (NPY_FR_as + 1)
 
207
#define NPY_DATETIME_DEFAULTUNIT NPY_FR_us
 
208
 
 
209
#define NPY_STR_Y "Y"
 
210
#define NPY_STR_M "M"
 
211
#define NPY_STR_W "W"
 
212
#define NPY_STR_B "B"
 
213
#define NPY_STR_D "D"
 
214
#define NPY_STR_h "h"
 
215
#define NPY_STR_m "m"
 
216
#define NPY_STR_s "s"
 
217
#define NPY_STR_ms "ms"
 
218
#define NPY_STR_us "us"
 
219
#define NPY_STR_ns "ns"
 
220
#define NPY_STR_ps "ps"
 
221
#define NPY_STR_fs "fs"
 
222
#define NPY_STR_as "as"
 
223
 
178
224
 
179
225
/* This is to typedef npy_intp to the appropriate pointer size for this
180
226
 * platform.  Py_intptr_t, Py_uintptr_t are defined in pyport.h. */
234
280
/* We can only use C99 formats for npy_int_p if it is the same as intp_t, hence
235
281
 * the condition on HAVE_UNITPTR_T */
236
282
#if (NPY_USE_C99_FORMATS) == 1 \
237
 
        && (defined HAVE_UINTPTR_T) \
238
 
        && (defined HAVE_INTTYPES_H)
239
 
        #include <inttypes.h>
 
283
        && (defined HAVE_UINTPTR_T) \
 
284
        && (defined HAVE_INTTYPES_H)
 
285
        #include <inttypes.h>
240
286
        #undef NPY_INTP_FMT
241
287
        #define NPY_INTP_FMT PRIdPTR
242
288
#endif
471
517
 
472
518
        PyArray_ArrFuncs *f;     /* a table of functions specific for each
473
519
                                    basic data descriptor */
 
520
 
 
521
        PyObject *metadata;     /* Metadata about this dtype */
474
522
} PyArray_Descr;
475
523
 
476
524
typedef struct _arr_descr {
525
573
        int flags;
526
574
} PyArray_Chunk;
527
575
 
 
576
#define PyDataType_GetDatetimeMetaData(descr) ((descr->metadata == NULL) ? NULL : ((PyArray_DatetimeMetaData *)(PyCObject_AsVoidPtr(PyDict_GetItemString(descr->metadata, NPY_METADATA_DTSTR)))))
 
577
 
528
578
typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
529
579
 
530
580
/* Means c-style contiguous (last index varies the fastest). The
666
716
#define NPY_DISABLE_C_API
667
717
#endif
668
718
 
669
 
typedef struct {
 
719
/*****************************
 
720
 * Basic iterator object
 
721
 *****************************/
 
722
 
 
723
/* FWD declaration */
 
724
typedef struct PyArrayIterObject_tag PyArrayIterObject;
 
725
 
 
726
/* type of the function which translates a set of coordinates to a pointer to
 
727
 * the data */
 
728
typedef char* (*npy_iter_get_dataptr_t)(PyArrayIterObject* iter, npy_intp*);
 
729
 
 
730
struct PyArrayIterObject_tag {
670
731
        PyObject_HEAD
671
732
        int               nd_m1;            /* number of dimensions - 1 */
672
733
        npy_intp          index, size;
678
739
        PyArrayObject     *ao;
679
740
        char              *dataptr;        /* pointer to current item*/
680
741
        npy_bool          contiguous;
681
 
} PyArrayIterObject;
 
742
 
 
743
        npy_intp          bounds[NPY_MAXDIMS][2];
 
744
        npy_intp          limits[NPY_MAXDIMS][2];
 
745
        npy_intp          limits_sizes[NPY_MAXDIMS];
 
746
        npy_iter_get_dataptr_t translate;
 
747
} ;
682
748
 
683
749
 
684
750
/* Iterator API */
689
755
        _PyAIT(it)->index = 0;                                          \
690
756
        _PyAIT(it)->dataptr = _PyAIT(it)->ao->data;                     \
691
757
        memset(_PyAIT(it)->coordinates, 0,                              \
692
 
               (_PyAIT(it)->nd_m1+1)*sizeof(npy_intp));                 \
 
758
               (_PyAIT(it)->nd_m1+1)*sizeof(npy_intp));                 \
693
759
}
694
760
 
695
761
#define _PyArray_ITER_NEXT1(it) {                                       \
737
803
                _PyArray_ITER_NEXT1(_PyAIT(it));                           \
738
804
        }                                                                  \
739
805
        else if (_PyAIT(it)->contiguous)                                   \
740
 
                _PyAIT(it)->dataptr += _PyAIT(it)->ao->descr->elsize;      \
 
806
                _PyAIT(it)->dataptr += _PyAIT(it)->ao->descr->elsize;      \
741
807
        else if (_PyAIT(it)->nd_m1 == 1) {                                 \
742
808
                _PyArray_ITER_NEXT2(_PyAIT(it));                           \
743
809
        }                                                                  \
902
968
 
903
969
} PyArrayMapIterObject;
904
970
 
 
971
enum {
 
972
    NPY_NEIGHBORHOOD_ITER_ZERO_PADDING,
 
973
    NPY_NEIGHBORHOOD_ITER_ONE_PADDING,
 
974
    NPY_NEIGHBORHOOD_ITER_CONSTANT_PADDING,
 
975
    NPY_NEIGHBORHOOD_ITER_CIRCULAR_PADDING,
 
976
    NPY_NEIGHBORHOOD_ITER_MIRROR_PADDING
 
977
};
 
978
 
 
979
typedef struct {
 
980
    PyObject_HEAD
 
981
 
 
982
    /*
 
983
     * PyArrayIterObject part: keep this in this exact order
 
984
     */
 
985
    int               nd_m1;            /* number of dimensions - 1 */
 
986
    npy_intp          index, size;
 
987
    npy_intp          coordinates[NPY_MAXDIMS];/* N-dimensional loop */
 
988
    npy_intp          dims_m1[NPY_MAXDIMS];    /* ao->dimensions - 1 */
 
989
    npy_intp          strides[NPY_MAXDIMS];    /* ao->strides or fake */
 
990
    npy_intp          backstrides[NPY_MAXDIMS];/* how far to jump back */
 
991
    npy_intp          factors[NPY_MAXDIMS];     /* shape factors */
 
992
    PyArrayObject     *ao;
 
993
    char              *dataptr;        /* pointer to current item*/
 
994
    npy_bool          contiguous;
 
995
 
 
996
    npy_intp          bounds[NPY_MAXDIMS][2];
 
997
    npy_intp          limits[NPY_MAXDIMS][2];
 
998
    npy_intp          limits_sizes[NPY_MAXDIMS];
 
999
    npy_iter_get_dataptr_t translate;
 
1000
 
 
1001
    /*
 
1002
     * New members
 
1003
     */
 
1004
    npy_intp nd;
 
1005
 
 
1006
    /* Dimensions is the dimension of the array */
 
1007
    npy_intp dimensions[NPY_MAXDIMS];
 
1008
 
 
1009
    /* Neighborhood points coordinates are computed relatively to the point pointed
 
1010
     * by _internal_iter */
 
1011
    PyArrayIterObject* _internal_iter;
 
1012
    /* To keep a reference to the representation of the constant value for
 
1013
     * constant padding */
 
1014
    char* constant;
 
1015
 
 
1016
    int mode;
 
1017
} PyArrayNeighborhoodIterObject;
 
1018
 
 
1019
/*
 
1020
 * Neighborhood iterator API
 
1021
 */
 
1022
 
 
1023
/* General: those work for any mode */
 
1024
static NPY_INLINE int
 
1025
PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter);
 
1026
static NPY_INLINE int
 
1027
PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter);
 
1028
#if 0
 
1029
static NPY_INLINE int
 
1030
PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter);
 
1031
#endif
 
1032
 
 
1033
/* Include inline implementations - functions defined there are not considered
 
1034
 * public API */
 
1035
#define _NPY_INCLUDE_NEIGHBORHOOD_IMP
 
1036
#include "_neighborhood_iterator_imp.h"
 
1037
#undef _NPY_INCLUDE_NEIGHBORHOOD_IMP
 
1038
 
905
1039
/* The default array type
906
1040
 */
907
1041
#define NPY_DEFAULT_TYPE NPY_DOUBLE
982
1116
#define PyTypeNum_ISFLEXIBLE(type) (((type) >=NPY_STRING) &&  \
983
1117
                                    ((type) <=NPY_VOID))
984
1118
 
 
1119
#define PyTypeNum_ISDATETIME(type) (((type) >=NPY_DATETIME) &&  \
 
1120
                                    ((type) <=NPY_TIMEDELTA))
 
1121
 
985
1122
#define PyTypeNum_ISUSERDEF(type) (((type) >= NPY_USERDEF) && \
986
1123
                                   ((type) < NPY_USERDEF+     \
987
1124
                                    NPY_NUMUSERTYPES))
1002
1139
#define PyDataType_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(((PyArray_Descr*)(obj))->type_num)
1003
1140
#define PyDataType_ISPYTHON(obj) PyTypeNum_ISPYTHON(((PyArray_Descr*)(obj))->type_num)
1004
1141
#define PyDataType_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(((PyArray_Descr*)(obj))->type_num)
 
1142
#define PyDataType_ISDATETIME(obj) PyTypeNum_ISDATETIME(((PyArray_Descr*)(obj))->type_num)
1005
1143
#define PyDataType_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(((PyArray_Descr*)(obj))->type_num)
1006
1144
#define PyDataType_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(((PyArray_Descr*)(obj))->type_num)
1007
1145
#define PyDataType_ISOBJECT(obj) PyTypeNum_ISOBJECT(((PyArray_Descr*)(obj))->type_num)
1017
1155
#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))
1018
1156
#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))
1019
1157
#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))
 
1158
#define PyArray_ISDATETIME(obj) PyTypeNum_ISDATETIME(PyArray_TYPE(obj))
1020
1159
#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))
1021
1160
#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))
1022
1161
#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))
1038
1177
#define NPY_SWAP 's'
1039
1178
#define NPY_IGNORE '|'
1040
1179
 
1041
 
#ifdef NPY_BIG_ENDIAN
 
1180
#if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
1042
1181
#define NPY_NATBYTE NPY_BIG
1043
1182
#define NPY_OPPBYTE NPY_LITTLE
1044
1183
#else
1137
1276
#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) ||           \
1138
1277
                                     PyArray_CheckScalar(obj))
1139
1278
 
 
1279
#define PyArray_IsIntegerScalar(obj) (PyInt_Check(obj)                        \
 
1280
              || PyLong_Check(obj)                                            \
 
1281
              || PyArray_IsScalar((obj), Integer))
 
1282
 
 
1283
 
1140
1284
#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ?                   \
1141
1285
                                  Py_INCREF(m), (m) :                         \
1142
1286
                                  (PyArrayObject *)(PyArray_Copy(m)))
1274
1418
 
1275
1419
#include "old_defines.h"
1276
1420
 
1277
 
/* 
1278
 
   Check to see if this key in the dictionary is the "title" 
 
1421
/*
 
1422
   Check to see if this key in the dictionary is the "title"
1279
1423
   entry of the tuple (i.e. a duplicate dictionary entry in the fields
1280
 
   dict. 
 
1424
   dict.
1281
1425
*/
1282
1426
 
1283
1427
#define NPY_TITLE_KEY(key, value) ((PyTuple_GET_SIZE((value))==3) && \
1284
 
                                   (PyTuple_GET_ITEM((value), 2) == (key)))
 
1428
                                   (PyTuple_GET_ITEM((value), 2) == (key)))
1285
1429
 
1286
1430
 
1287
1431
/* Define python version independent deprecation macro */