MCPcopy Create free account
hub / github.com/numpy/numpy / npy_is_aligned

Function npy_is_aligned

numpy/core/src/multiarray/common.h:203–214  ·  view source on GitHub ↗

* return true if pointer is aligned to 'alignment' */

Source from the content-addressed store, hash-verified

201 * return true if pointer is aligned to 'alignment'
202 */
203static inline int
204npy_is_aligned(const void * p, const npy_uintp alignment)
205{
206 /*
207 * Assumes alignment is a power of two, as required by the C standard.
208 * Assumes cast from pointer to uintp gives a sensible representation we
209 * can use bitwise & on (not required by C standard, but used by glibc).
210 * This test is faster than a direct modulo.
211 * Note alignment value of 0 is allowed and returns False.
212 */
213 return ((npy_uintp)(p) & ((alignment) - 1)) == 0;
214}
215
216/* Get equivalent "uint" alignment given an itemsize, for use in copy code */
217static inline npy_uintp

Callers 7

_strided_byte_swapFunction · 0.85
raw_array_assign_scalarFunction · 0.85
PyArray_AssignRawScalarFunction · 0.85
count_nonzero_u8Function · 0.85
pack_innerFunction · 0.85
raw_array_is_alignedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected