8000 BUG: define "uint-alignment", fixes complex64 alignment by ahaldane · Pull Request #6377 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: define "uint-alignment", fixes complex64 alignment #6377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 30, 2018
Prev Previous commit
MAINT: remove unneeded test in npy_is_aligned
  • Loading branch information
ahaldane committed Sep 27, 2018
commit 12bd7c372ab5eeeff8bd2a46d765ccf28c6ce486
13 changes: 5 additions & 8 deletions numpy/core/src/multiarray/common.h
907C
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,12 @@ static NPY_INLINE int
npy_is_aligned(const void * p, const npy_uintp alignment)
{
/*
* alignment is usually a power of two
* the test is faster than a direct modulo
* Assumes alignment is a power of two, as required by the C standard.
* Assumes cast from pointer to uintp gives a sensible representation we
* can use bitwise & on (not required by C standard, but used by glibc).
* This test is faster than a direct modulo.
*/
if (NPY_LIKELY((alignment & (alignment - 1)) == 0)) {
return ((npy_uintp)(p) & ((alignment) - 1)) == 0;
}
else {
return ((npy_uintp)(p) % alignment) == 0;
}
return ((npy_uintp)(p) & ((alignment) - 1)) == 0;
}

/* Get equivalent "uint" alignment given an itemsize, for use in copy code */
Expand Down
0