Skip to content

Commit

Permalink
Fix alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jun 26, 2024
1 parent 54fb8b6 commit 2dae764
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libpopcnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
if (cpuid & LIBPOPCNT_BIT_POPCNT)
#endif
{
if (i + 8 < size)
if (i + 8 <= size)
{
/* Align &ptr[i] to an 8 byte boundary */
uintptr_t rem = ((uintptr_t) &ptr[i]) % 8;
Expand Down Expand Up @@ -619,7 +619,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
#if !defined(LIBPOPCNT_HAVE_POPCNT) || \
!defined(__POPCNT__)

if (i + 8 < size)
if (i + 8 <= size)
{
/* Align &ptr[i] to an 8 byte boundary */
uintptr_t rem = ((uintptr_t) &ptr[i]) % 8;
Expand Down Expand Up @@ -764,7 +764,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
cnt += tmp[1];
}

if (i + 8 < size)
if (i + 8 <= size)
{
/* Align &ptr[i] to an 8 byte boundary */
uintptr_t rem = ((uintptr_t) &ptr[i]) % 8;
Expand Down Expand Up @@ -806,7 +806,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t cnt = 0;
const uint8_t* ptr = (const uint8_t*) data;

if (i + 8 < size)
if (i + 8 <= size)
{
/* Align &ptr[i] to an 8 byte boundary */
uintptr_t rem = ((uintptr_t) &ptr[i]) % 8;
Expand Down

0 comments on commit 2dae764

Please sign in to comment.