diff --git a/CMakeLists.txt b/CMakeLists.txt index e4fc768..ce44cfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,5 +8,15 @@ set(CMAKE_D_FLAGS_DEBUG "${CMAKE_D_FLAGS_DEBUG} -funittest -g -O0 -Wall -Wdeprec set(CMAKE_D_FLAGS_RELEASE "${CMAKE_D_FLAGS_RELEASE} -O3 -Wall -Wdeprecated") option(REFERENCE_TIGER "Use the reference implementation of the tiger algorithm." OFF) +set(READ_BUFF_SIZE "1024 * 16") + +#Just here to nicely print how big the read buffer will be, it doesn't really +#do anything important. +math(EXPR READ_BUFF_SIZE_RESULT "(${READ_BUFF_SIZE} / 64) * 64") +if (${READ_BUFF_SIZE_RESULT} LESS 64) + set(READ_BUFF_SIZE_RESULT 64) +endif() +message(STATUS "Read buffer size will be ${READ_BUFF_SIZE_RESULT} bytes") +unset(READ_BUFF_SIZE_RESULT) add_subdirectory(src) diff --git a/src/tiger.d b/src/tiger.d index ab54e68..18288d5 100644 --- a/src/tiger.d +++ b/src/tiger.d @@ -20,6 +20,8 @@ import std.string; import std.array, std.range; import std.algorithm; +mixin(import("tigersumConfig.d")); + private extern(C) void tiger (char* parMessage, ulong parLength, out ulong[3] parOut, char parPadding); private extern(C) void tiger_init (out ulong[3] parOut); private extern(C) void tiger_chunk (char* parMessage, ulong parLength, out ulong[3] parOut); @@ -48,7 +50,7 @@ public ulong[3] getTiger (in string parData, bool parV2) { } public ulong[3] getTiger (ref File parData, bool parV2) { - const auto buff_length = 64 * 128; + const auto buff_length = 64 * READ_BUFF_BLOCKS; char[] unaligned = new char[buff_length + ulong.alignof - 1]; size_t offset = ((cast(size_t)unaligned.ptr + (ulong.alignof - 1)) & ~cast(size_t)(ulong.alignof - 1)) - cast(size_t)unaligned.ptr; assert(offset >= 0 && offset < ulong.alignof); diff --git a/src/tigersumConfig.d.in b/src/tigersumConfig.d.in index 1b832ab..816aae2 100644 --- a/src/tigersumConfig.d.in +++ b/src/tigersumConfig.d.in @@ -6,3 +6,5 @@ const string PROGRAM_NAME = "@PROJECT_NAME@"; const string BACKEND_WEBSITE = "@BACKEND_WEBSITE@"; const string BACKEND_NAME = "@BACKEND_NAME@"; const string BACKEND_AUTHOR = "@BACKEND_AUTHOR@"; + +const int READ_BUFF_BLOCKS = ((@READ_BUFF_SIZE@) / 64 < 1 ? 1 : (@READ_BUFF_SIZE@) / 64);