From 2467c4f815629c1042ee54de9db6a89e26ae5739 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 23 Apr 2023 19:23:47 +0200 Subject: [PATCH] Make use of platform-specific APIs for optimizing CopyHelper configurable There might be unexpected limitations like https://github.com/Martchus/cpp-utilities/issues/24. To be able to at least workaround those limitations it makes sense to allow disabling the optimization completely. --- CMakeLists.txt | 6 ++++++ io/copy.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 763d654..65d4d45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,6 +195,12 @@ if (NOT ENABLE_THREAD_LOCAL) PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_NO_THREAD_LOCAL) endif () +# configure use of platform-specific APIs for optimizing CopyHelper +option(USE_PLATFORM_SPECIFIC_API_FOR_OPTIMIZING_COPY_HELPER "enables use of platform-specific APIs for optimizing CopyHelper" ON) +if (USE_PLATFORM_SPECIFIC_API_FOR_OPTIMIZING_COPY_HELPER) + list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_PLATFORM_SPECIFIC_API_FOR_OPTIMIZING_COPY_HELPER) +endif () + # include modules to apply configuration include(BasicConfig) include(WindowsResources) diff --git a/io/copy.h b/io/copy.h index 6edae23..134484b 100644 --- a/io/copy.h +++ b/io/copy.h @@ -2,7 +2,7 @@ #define IOUTILITIES_COPY_H #include "./nativefilestream.h" -#if defined(CPP_UTILITIES_USE_NATIVE_FILE_BUFFER) && defined(PLATFORM_LINUX) +#if defined(CPP_UTILITIES_USE_PLATFORM_SPECIFIC_API_FOR_OPTIMIZING_COPY_HELPER) && defined(CPP_UTILITIES_USE_NATIVE_FILE_BUFFER) && defined(PLATFORM_LINUX) #define CPP_UTILITIES_USE_SEND_FILE #include "../conversion/stringbuilder.h" #endif