From 20ee8340dda729e0242de276d65240a7caad0196 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Wed, 30 Oct 2019 09:19:10 +0300 Subject: [PATCH] [core] fix old windows build --- easy_profiler_core/chunk_allocator.h | 24 +++++++++++++----------- easy_profiler_core/thread_storage.h | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/easy_profiler_core/chunk_allocator.h b/easy_profiler_core/chunk_allocator.h index d3cc258..466f30a 100644 --- a/easy_profiler_core/chunk_allocator.h +++ b/easy_profiler_core/chunk_allocator.h @@ -58,6 +58,8 @@ The Apache License, Version 2.0 (the "License"); # define EASY_ALIGNMENT_SIZE alignof(std::max_align_t) #endif +EASY_CONSTEXPR auto EASY_ALIGN_SIZE = EASY_ALIGNMENT_SIZE; + #if EASY_ENABLE_ALIGNMENT == 0 # define EASY_ALIGNED(TYPE, VAR, A) TYPE VAR # define EASY_MALLOC(MEMSIZE, A) malloc(MEMSIZE) @@ -381,31 +383,31 @@ struct aligned_size; template struct aligned_size { - EASY_STATIC_CONSTEXPR uint16_t Size = N; + EASY_STATIC_CONSTEXPR uint16_t Size = N; }; template struct aligned_size { - EASY_STATIC_CONSTEXPR uint16_t Size = static_cast(N - (N % EASY_ALIGNMENT_SIZE)); + EASY_STATIC_CONSTEXPR uint16_t Size = static_cast(N - (N % EASY_ALIGN_SIZE)); }; template struct aligned_size { - EASY_STATIC_CONSTEXPR uint16_t Size = static_cast(N + EASY_ALIGNMENT_SIZE - (N % EASY_ALIGNMENT_SIZE)); + EASY_STATIC_CONSTEXPR uint16_t Size = static_cast(N + EASY_ALIGN_SIZE - (N % EASY_ALIGN_SIZE)); }; template struct get_aligned_size { - EASY_STATIC_CONSTEXPR uint16_t Size = - aligned_size(N), (N % EASY_ALIGNMENT_SIZE) == 0, (N > (65536 - EASY_ALIGNMENT_SIZE))>::Size; + EASY_STATIC_CONSTEXPR uint16_t Size = + aligned_size(N), (N % EASY_ALIGN_SIZE) == 0, (N > (65536 - EASY_ALIGN_SIZE))>::Size; }; -static_assert(get_aligned_size::Size == EASY_ALIGNMENT_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<65530>::Size == 65536 - EASY_ALIGNMENT_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<65536 - EASY_ALIGNMENT_SIZE>::Size == 65536 - EASY_ALIGNMENT_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::Size == EASY_ALIGN_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_ALIGN_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_ALIGN_SIZE>::Size == 65536 - EASY_ALIGN_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"); ////////////////////////////////////////////////////////////////////////// diff --git a/easy_profiler_core/thread_storage.h b/easy_profiler_core/thread_storage.h index 9cc6f32..c8385cb 100644 --- a/easy_profiler_core/thread_storage.h +++ b/easy_profiler_core/thread_storage.h @@ -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::Size; EASY_CONSTEXPR uint16_t CSWITCH_CHUNK_SIZE = get_aligned_size::Size; -static_assert((BLOCK_CHUNK_SIZE % EASY_ALIGNMENT_SIZE) == 0, "BLOCK_CHUNK_SIZE not aligned"); -static_assert((CSWITCH_CHUNK_SIZE % EASY_ALIGNMENT_SIZE) == 0, "CSWITCH_CHUNK_SIZE not aligned"); +static_assert((BLOCK_CHUNK_SIZE % EASY_ALIGN_SIZE) == 0, "BLOCK_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(CSWITCH_CHUNK_SIZE > 2048, "wrong CSWITCH_CHUNK_SIZE");