Skip to content

ALIGN_DOWN produces wrong address on VS 2015 / x64 build #46

Closed
@tobias-loew

Description

@tobias-loew

On x64 builds with VS 2015 the ALIGN_DOWN macro produces wrong addresses if the address is larger than 2^32. VS 2015 also produces a warning
MemoryModule.c(247): warning C4319: '~': zero extending 'DWORD' to 'uintptr_t' of greater size
The same applies to ALIGN_VALUE_UP.
A possible solution could be replacing the definition of ALIGN_DOWN and ALIGN_VALUE_UP by

define ALIGN_DOWN(address, alignment) (LPVOID)((uintptr_t)(address) & ~(((uintptr_t)(alignment)) - 1))

define ALIGN_VALUE_UP(value, alignment) (((value) + ((uintptr_t)(alignment)) - 1) & ~(((uintptr_t)(alignment)) - 1))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions