* return true if pointer is aligned to 'alignment' */
| 201 | * return true if pointer is aligned to 'alignment' |
| 202 | */ |
| 203 | static inline int |
| 204 | npy_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 */ |
| 217 | static inline npy_uintp |
no outgoing calls
no test coverage detected