Skip to content

Add is_aligned for both C and C++ APIs #58

@vianney-st

Description

@vianney-st
// C
int is_aligned(const void* const ptr) {
#if NSIMD_WORD_SIZE == 32
const u32 val = (u32)ptr;
#else
const u64 val = (u64)ptr;
#endif
return val % (NSIMD_MAX_ALIGNMENT / CHAR_BIT) == 0;
}

// C++
template<typename T>
bool is_aligned(const T* const ptr) {
#if NSIMD_WORD_SIZE == 32
u32 val = (u32)ptr;
#else
u64 val = (u64)ptr;
#endif
return val % (NSIMD_MAX_ALIGNMENT / CHAR_BIT) == 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions