* Return non-zero if a type is aligned in each item in the given array, * AND, the descr element size is a multiple of the alignment, * AND, the array data is positioned to alignment granularity. */
| 138 | * AND, the array data is positioned to alignment granularity. |
| 139 | */ |
| 140 | static inline int |
| 141 | _is_natively_aligned_at(PyArray_Descr *descr, |
| 142 | PyArrayObject *arr, Py_ssize_t offset) |
| 143 | { |
| 144 | int k; |
| 145 | |
| 146 | if (NPY_LIKELY(descr == PyArray_DESCR(arr))) { |
| 147 | /* |
| 148 | * If the descriptor is the arrays descriptor we can assume the |
| 149 | * array's alignment is correct. |
| 150 | */ |
| 151 | assert(offset == 0); |
| 152 | if (PyArray_ISALIGNED(arr)) { |
| 153 | assert(descr->elsize % descr->alignment == 0); |
| 154 | return 1; |
| 155 | } |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | if ((Py_ssize_t)(PyArray_DATA(arr)) % descr->alignment != 0) { |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | if (offset % descr->alignment != 0) { |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | if (descr->elsize % descr->alignment) { |
| 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | for (k = 0; k < PyArray_NDIM(arr); ++k) { |
| 172 | if (PyArray_DIM(arr, k) > 1) { |
| 173 | if (PyArray_STRIDE(arr, k) % descr->alignment != 0) { |
| 174 | return 0; |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | return 1; |
| 180 | } |
| 181 | |
| 182 | /* |
| 183 | * Fill in str with an appropriate PEP 3118 format string, based on |
no test coverage detected