mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 00:27:55 +08:00
[core] fix old windows build
This commit is contained in:
parent
6ae08c3a70
commit
20ee8340dd
@ -58,6 +58,8 @@ The Apache License, Version 2.0 (the "License");
|
|||||||
# define EASY_ALIGNMENT_SIZE alignof(std::max_align_t)
|
# define EASY_ALIGNMENT_SIZE alignof(std::max_align_t)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EASY_CONSTEXPR auto EASY_ALIGN_SIZE = EASY_ALIGNMENT_SIZE;
|
||||||
|
|
||||||
#if EASY_ENABLE_ALIGNMENT == 0
|
#if EASY_ENABLE_ALIGNMENT == 0
|
||||||
# define EASY_ALIGNED(TYPE, VAR, A) TYPE VAR
|
# define EASY_ALIGNED(TYPE, VAR, A) TYPE VAR
|
||||||
# define EASY_MALLOC(MEMSIZE, A) malloc(MEMSIZE)
|
# define EASY_MALLOC(MEMSIZE, A) malloc(MEMSIZE)
|
||||||
@ -386,26 +388,26 @@ struct aligned_size<N, true, dummy> {
|
|||||||
|
|
||||||
template <const uint16_t N>
|
template <const uint16_t N>
|
||||||
struct aligned_size<N, false, true> {
|
struct aligned_size<N, false, true> {
|
||||||
EASY_STATIC_CONSTEXPR uint16_t Size = static_cast<uint16_t>(N - (N % EASY_ALIGNMENT_SIZE));
|
EASY_STATIC_CONSTEXPR uint16_t Size = static_cast<uint16_t>(N - (N % EASY_ALIGN_SIZE));
|
||||||
};
|
};
|
||||||
|
|
||||||
template <const uint16_t N>
|
template <const uint16_t N>
|
||||||
struct aligned_size<N, false, false> {
|
struct aligned_size<N, false, false> {
|
||||||
EASY_STATIC_CONSTEXPR uint16_t Size = static_cast<uint16_t>(N + EASY_ALIGNMENT_SIZE - (N % EASY_ALIGNMENT_SIZE));
|
EASY_STATIC_CONSTEXPR uint16_t Size = static_cast<uint16_t>(N + EASY_ALIGN_SIZE - (N % EASY_ALIGN_SIZE));
|
||||||
};
|
};
|
||||||
|
|
||||||
template <const size_t N>
|
template <const size_t N>
|
||||||
struct get_aligned_size {
|
struct get_aligned_size {
|
||||||
EASY_STATIC_CONSTEXPR uint16_t Size =
|
EASY_STATIC_CONSTEXPR uint16_t Size =
|
||||||
aligned_size<static_cast<uint16_t>(N), (N % EASY_ALIGNMENT_SIZE) == 0, (N > (65536 - EASY_ALIGNMENT_SIZE))>::Size;
|
aligned_size<static_cast<uint16_t>(N), (N % EASY_ALIGN_SIZE) == 0, (N > (65536 - EASY_ALIGN_SIZE))>::Size;
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(get_aligned_size<EASY_ALIGNMENT_SIZE - 3>::Size == EASY_ALIGNMENT_SIZE, "wrong get_aligned_size");
|
static_assert(get_aligned_size<EASY_ALIGN_SIZE - 3>::Size == EASY_ALIGN_SIZE, "wrong get_aligned_size");
|
||||||
static_assert(get_aligned_size<2 * EASY_ALIGNMENT_SIZE - 3>::Size == 2 * EASY_ALIGNMENT_SIZE, "wrong get_aligned_size");
|
static_assert(get_aligned_size<2 * EASY_ALIGN_SIZE - 3>::Size == 2 * EASY_ALIGN_SIZE, "wrong get_aligned_size");
|
||||||
static_assert(get_aligned_size<65530>::Size == 65536 - EASY_ALIGNMENT_SIZE, "wrong get_aligned_size");
|
static_assert(get_aligned_size<65530>::Size == 65536 - EASY_ALIGN_SIZE, "wrong get_aligned_size");
|
||||||
static_assert(get_aligned_size<65526>::Size == 65536 - EASY_ALIGNMENT_SIZE, "wrong get_aligned_size");
|
static_assert(get_aligned_size<65526>::Size == 65536 - EASY_ALIGN_SIZE, "wrong get_aligned_size");
|
||||||
static_assert(get_aligned_size<65536 - EASY_ALIGNMENT_SIZE>::Size == 65536 - EASY_ALIGNMENT_SIZE, "wrong get_aligned_size");
|
static_assert(get_aligned_size<65536 - EASY_ALIGN_SIZE>::Size == 65536 - EASY_ALIGN_SIZE, "wrong get_aligned_size");
|
||||||
static_assert(get_aligned_size<65536 + 3 - EASY_ALIGNMENT_SIZE * 2>::Size == 65536 - EASY_ALIGNMENT_SIZE, "wrong get_aligned_size");
|
static_assert(get_aligned_size<65536 + 3 - EASY_ALIGN_SIZE * 2>::Size == 65536 - EASY_ALIGN_SIZE, "wrong get_aligned_size");
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ static_assert(((int)SIZEOF_CSWITCH * (int)BLOCKS_IN_CHUNK) < 65536, "Chunk size
|
|||||||
EASY_CONSTEXPR uint16_t BLOCK_CHUNK_SIZE = get_aligned_size<SIZEOF_BLOCK * BLOCKS_IN_CHUNK>::Size;
|
EASY_CONSTEXPR uint16_t BLOCK_CHUNK_SIZE = get_aligned_size<SIZEOF_BLOCK * BLOCKS_IN_CHUNK>::Size;
|
||||||
EASY_CONSTEXPR uint16_t CSWITCH_CHUNK_SIZE = get_aligned_size<SIZEOF_BLOCK * BLOCKS_IN_CHUNK>::Size;
|
EASY_CONSTEXPR uint16_t CSWITCH_CHUNK_SIZE = get_aligned_size<SIZEOF_BLOCK * BLOCKS_IN_CHUNK>::Size;
|
||||||
|
|
||||||
static_assert((BLOCK_CHUNK_SIZE % EASY_ALIGNMENT_SIZE) == 0, "BLOCK_CHUNK_SIZE not aligned");
|
static_assert((BLOCK_CHUNK_SIZE % EASY_ALIGN_SIZE) == 0, "BLOCK_CHUNK_SIZE not aligned");
|
||||||
static_assert((CSWITCH_CHUNK_SIZE % EASY_ALIGNMENT_SIZE) == 0, "CSWITCH_CHUNK_SIZE not aligned");
|
static_assert((CSWITCH_CHUNK_SIZE % EASY_ALIGN_SIZE) == 0, "CSWITCH_CHUNK_SIZE not aligned");
|
||||||
static_assert(BLOCK_CHUNK_SIZE > 2048, "wrong BLOCK_CHUNK_SIZE");
|
static_assert(BLOCK_CHUNK_SIZE > 2048, "wrong BLOCK_CHUNK_SIZE");
|
||||||
static_assert(CSWITCH_CHUNK_SIZE > 2048, "wrong CSWITCH_CHUNK_SIZE");
|
static_assert(CSWITCH_CHUNK_SIZE > 2048, "wrong CSWITCH_CHUNK_SIZE");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user