From c0b8734987176a93588909739af143c6b0a1a6ff Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Mon, 15 Feb 2021 13:54:24 +0000 Subject: use size literals in vespalib --- staging_vespalib/src/tests/directio/directio.cpp | 13 +++++++------ .../util/process_memory_stats/process_memory_stats_test.cpp | 5 +++-- .../src/vespa/vespalib/util/scheduledexecutor.cpp | 3 ++- .../src/vespa/vespalib/util/sequencedtaskexecutor.cpp | 3 ++- 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'staging_vespalib') diff --git a/staging_vespalib/src/tests/directio/directio.cpp b/staging_vespalib/src/tests/directio/directio.cpp index 04155f71f94..7877216b191 100644 --- a/staging_vespalib/src/tests/directio/directio.cpp +++ b/staging_vespalib/src/tests/directio/directio.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -21,12 +22,12 @@ TEST("that DirectIOException is thrown on unaligned buf.") { FastOS_File f("staging_vespalib_directio_test_app"); f.EnableDirectIO(); EXPECT_TRUE(f.OpenReadOnly()); - DataBuffer buf(10000, 4096); + DataBuffer buf(10000, 4_Ki); bool caught(false); try { - f.ReadBuf(buf.getFree()+1, 4096, 0); + f.ReadBuf(buf.getFree()+1, 4_Ki, 0); } catch (const DirectIOException & e) { - EXPECT_EQUAL(4096u, e.getLength()); + EXPECT_EQUAL(4_Ki, e.getLength()); EXPECT_EQUAL(0u, e.getOffset()); EXPECT_EQUAL(buf.getFree()+1, e.getBuffer()); EXPECT_EQUAL(string(f.GetFileName()), e.getFileName()); @@ -39,12 +40,12 @@ TEST("that DirectIOException is thrown on unaligned offset.") { FastOS_File f("staging_vespalib_directio_test_app"); f.EnableDirectIO(); EXPECT_TRUE(f.OpenReadOnly()); - DataBuffer buf(10000, 4096); + DataBuffer buf(10000, 4_Ki); bool caught(false); try { - f.ReadBuf(buf.getFree(), 4096, 1); + f.ReadBuf(buf.getFree(), 4_Ki, 1); } catch (const DirectIOException & e) { - EXPECT_EQUAL(4096u, e.getLength()); + EXPECT_EQUAL(4_Ki, e.getLength()); EXPECT_EQUAL(1u, e.getOffset()); EXPECT_EQUAL(buf.getFree(), e.getBuffer()); EXPECT_EQUAL(string(f.GetFileName()), e.getFileName()); diff --git a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp index e4274664336..0d33a27edbf 100644 --- a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp +++ b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,7 @@ TEST("grow anonymous memory") { ProcessMemoryStats stats1(ProcessMemoryStats::create(SIZE_EPSILON)); std::cout << toString(stats1) << std::endl; - size_t mapLen = 64 * 1024; + size_t mapLen = 64_Ki; void *mapAddr = mmap(nullptr, mapLen, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); EXPECT_NOT_EQUAL(reinterpret_cast(-1), mapAddr); @@ -59,7 +60,7 @@ TEST("grow anonymous memory") TEST("grow mapped memory") { std::ofstream of("mapfile"); - size_t mapLen = 64 * 1024; + size_t mapLen = 64_Ki; std::vector buf(mapLen, 4); of.write(&buf[0], buf.size()); of.close(); diff --git a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp index 3f5b3b79656..9cd2ff59b49 100644 --- a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace vespalib { @@ -35,7 +36,7 @@ public: }; ScheduledExecutor::ScheduledExecutor() - : _threadPool(128 * 1024), + : _threadPool(128_Ki), _transport(new FNET_Transport()), _lock(), _taskList() diff --git a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp index b0c67e14c5b..102fdeb1d4e 100644 --- a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp @@ -4,6 +4,7 @@ #include "adaptive_sequenced_executor.h" #include "singleexecutor.h" #include +#include #include #include @@ -11,7 +12,7 @@ namespace vespalib { namespace { -constexpr uint32_t stackSize = 128 * 1024; +constexpr uint32_t stackSize = 128_Ki; constexpr uint8_t MAGIC = 255; bool -- cgit v1.2.3