diff options
author | Jason Evans <jasone@canonware.com> | 2016-10-27 21:26:33 -0700 |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-11-15 14:04:35 -0800 |
commit | 87004d238cc8db5ea531ef1900a5e6386ccd3daf (patch) | |
tree | da90655b30cd0fb8c140bdc0c35763068ca6125d /include | |
parent | 2379479225e5be5f93626e13a37577c76a670fb3 (diff) | |
download | jemalloc-87004d238cc8db5ea531ef1900a5e6386ccd3daf.tar.gz |
Avoid negation of unsigned numbers.
Rather than relying on two's complement negation for alignment mask
generation, use bitwise not and addition. This dodges warnings from
MSVC, and should be strength-reduced by compiler optimization anyway.
Diffstat (limited to 'include')
-rw-r--r-- | include/jemalloc/internal/jemalloc_internal.h.in | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in index fdc8fef..e7ace7d 100644 --- a/include/jemalloc/internal/jemalloc_internal.h.in +++ b/include/jemalloc/internal/jemalloc_internal.h.in @@ -337,7 +337,7 @@ typedef unsigned szind_t; /* Return the nearest aligned address at or below a. */ #define ALIGNMENT_ADDR2BASE(a, alignment) \ - ((void *)((uintptr_t)(a) & (-(alignment)))) + ((void *)((uintptr_t)(a) & ((~(alignment)) + 1))) /* Return the offset between a and the nearest aligned address at or below a. */ #define ALIGNMENT_ADDR2OFFSET(a, alignment) \ @@ -345,7 +345,7 @@ typedef unsigned szind_t; /* Return the smallest alignment multiple that is >= s. */ #define ALIGNMENT_CEILING(s, alignment) \ - (((s) + (alignment - 1)) & (-(alignment))) + (((s) + (alignment - 1)) & ((~(alignment)) + 1)) /* Declare a variable-length array. */ #if __STDC_VERSION__ < 199901L |