#include "ext_headers.h"
Go to the source code of this file.
|
#define | LC_MEM_COMMON_ALIGNMENT (8) |
|
#define | LC_ALIGNED_BUFFER(name, size, alignment) |
| Allocate aligned stack memory.
|
|
#define | LC_ALIGNMENT_MASK(alignment) (alignment - 1) |
|
#define | LC_ALIGN_APPLY(x, mask) (((x) + (mask)) & ~(mask)) |
|
#define | LC_ALIGN(x, a) LC_ALIGN_APPLY((x), (uintptr_t)(a)) |
|
#define | LC_ALIGN_PTR_64(p, a) ((uint64_t *)LC_ALIGN((uintptr_t)(p), (a))); |
| Align pointer interpreted as 64 bit variable.
|
|
#define | LC_ALIGN_PTR_32(p, a) ((uint32_t *)LC_ALIGN((uintptr_t)(p), (a))) |
| Align pointer interpreted as 32 bit variable.
|
|
#define | LC_ALIGN_PTR_16(p, a) ((uint16_t *)LC_ALIGN((uintptr_t)(p), (a))) |
| Align pointer interpreted as 16 bit variable.
|
|
#define | LC_ALIGN_PTR_8(p, a) ((uint8_t *)LC_ALIGN((uintptr_t)(p), (a))) |
| Align pointer interpreted as 8 bit variable.
|
|
#define | LC_XOR_MIN_ALIGNMENT(min, requested) ((min < requested) ? (requested) : (min)) |
|
#define | LC_DEF_HOST_X86_64 |
|
#define | LC_XOR_AVX2_ALIGNMENT (sizeof(uint64_t)) |
|
#define | LC_XOR_ALIGNMENT(min) LC_XOR_MIN_ALIGNMENT(min, LC_XOR_AVX2_ALIGNMENT) |
|
|
int | lc_alloc_aligned (void **memptr, size_t alignment, size_t size) |
| allocate aligned memory up to 8 bytes alignment
|
|
int | lc_alloc_aligned_secure (void **memptr, size_t alignment, size_t size) |
| allocate aligned memory up to 8 bytes alignment with additional security precautions
|
|
int | lc_alloc_high_aligned (void **memptr, size_t alignment, size_t size) |
| allocate aligned memory with arbitrary alignment
|
|
void | lc_free (void *ptr) |
| free the memory allocated with lc_alloc_aligned
|
|
void | lc_free_high_aligned (void *ptr, size_t size) |
| free the memory allocated with lc_alloc_high_aligned
|
|
static int | lc_mem_aligned (const uint8_t *ptr, uint32_t alignmask) |
| Check if memory pointer is aligned to given alignment mask.
|
|
◆ LC_ALIGN
◆ LC_ALIGN_APPLY
#define LC_ALIGN_APPLY |
( |
| x, |
|
|
| mask ) (((x) + (mask)) & ~(mask)) |
◆ LC_ALIGN_PTR_16
#define LC_ALIGN_PTR_16 |
( |
| p, |
|
|
| a ) ((uint16_t *)LC_ALIGN((uintptr_t)(p), (a))) |
Align pointer interpreted as 16 bit variable.
- Parameters
-
Definition at line 72 of file lc_memory_support.h.
◆ LC_ALIGN_PTR_32
#define LC_ALIGN_PTR_32 |
( |
| p, |
|
|
| a ) ((uint32_t *)LC_ALIGN((uintptr_t)(p), (a))) |
Align pointer interpreted as 32 bit variable.
- Parameters
-
Definition at line 64 of file lc_memory_support.h.
◆ LC_ALIGN_PTR_64
#define LC_ALIGN_PTR_64 |
( |
| p, |
|
|
| a ) ((uint64_t *)LC_ALIGN((uintptr_t)(p), (a))); |
Align pointer interpreted as 64 bit variable.
- Parameters
-
Definition at line 56 of file lc_memory_support.h.
◆ LC_ALIGN_PTR_8
#define LC_ALIGN_PTR_8 |
( |
| p, |
|
|
| a ) ((uint8_t *)LC_ALIGN((uintptr_t)(p), (a))) |
Align pointer interpreted as 8 bit variable.
- Parameters
-
Definition at line 80 of file lc_memory_support.h.
◆ LC_ALIGNED_BUFFER
#define LC_ALIGNED_BUFFER |
( |
| name, |
|
|
| size, |
|
|
| alignment ) |
Value: uint64_t name[(size + sizeof(uint64_t) - 1) / sizeof(uint64_t)] \
__attribute__((aligned(alignment)))
Allocate aligned stack memory.
The variable can be casted to any structure
- Parameters
-
name | variable name |
size | size of the buffer |
alignment | alignment of the buffer |
Definition at line 41 of file lc_memory_support.h.
◆ LC_ALIGNMENT_MASK
#define LC_ALIGNMENT_MASK |
( |
| alignment | ) |
(alignment - 1) |
◆ LC_DEF_HOST_X86_64
#define LC_DEF_HOST_X86_64 |
◆ LC_MEM_COMMON_ALIGNMENT
#define LC_MEM_COMMON_ALIGNMENT (8) |
◆ LC_XOR_ALIGNMENT
◆ LC_XOR_AVX2_ALIGNMENT
#define LC_XOR_AVX2_ALIGNMENT (sizeof(uint64_t)) |
◆ LC_XOR_MIN_ALIGNMENT
#define LC_XOR_MIN_ALIGNMENT |
( |
| min, |
|
|
| requested ) ((min < requested) ? (requested) : (min)) |
◆ lc_alloc_aligned()
int lc_alloc_aligned |
( |
void ** | memptr, |
|
|
size_t | alignment, |
|
|
size_t | size ) |
allocate aligned memory up to 8 bytes alignment
- Parameters
-
[out] | memptr | pointer to the newly allocated memory |
[in] | alignment | alignment of the memory |
[in] | size | size of the memory buffer |
◆ lc_alloc_aligned_secure()
int lc_alloc_aligned_secure |
( |
void ** | memptr, |
|
|
size_t | alignment, |
|
|
size_t | size ) |
allocate aligned memory up to 8 bytes alignment with additional security precautions
- Parameters
-
[out] | memptr | pointer to the newly allocated memory |
[in] | alignment | alignment of the memory |
[in] | size | size of the memory buffer |
◆ lc_alloc_high_aligned()
int lc_alloc_high_aligned |
( |
void ** | memptr, |
|
|
size_t | alignment, |
|
|
size_t | size ) |
allocate aligned memory with arbitrary alignment
- Parameters
-
[out] | memptr | pointer to the newly allocated memory |
[in] | alignment | alignment of the memory |
[in] | size | size of the memory buffer |
◆ lc_free()
void lc_free |
( |
void * | ptr | ) |
|
free the memory allocated with lc_alloc_aligned
The memory is NOT zeroized.
- Parameters
-
[in] | ptr | memory pointer to free |
◆ lc_free_high_aligned()
void lc_free_high_aligned |
( |
void * | ptr, |
|
|
size_t | size ) |
free the memory allocated with lc_alloc_high_aligned
The memory is NOT zeroized.
- Parameters
-
[in] | ptr | memory pointer to free |
[in] | size | size of the memory to free |
◆ lc_mem_aligned()
static int lc_mem_aligned |
( |
const uint8_t * | ptr, |
|
|
uint32_t | alignmask ) |
|
inlinestatic |
Check if memory pointer is aligned to given alignment mask.
- Parameters
-
[in] | ptr | memory pointer to check |
[in] | alignmask | alignment mask to check for |
- Returns
- 1 if pointer is aligned, 0 if not aligned
Definition at line 173 of file lc_memory_support.h.