diff --git a/.github/workflows/feature_ci.yml b/.github/workflows/feature_ci.yml index f251c9f..a479a46 100644 --- a/.github/workflows/feature_ci.yml +++ b/.github/workflows/feature_ci.yml @@ -16,6 +16,7 @@ jobs: - gcc5 - clang10 - clang40 + sharedlibs: [OFF, ON] runs-on: ubuntu-latest container: @@ -29,7 +30,7 @@ jobs: - name: Configure working-directory: build/ - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}} - name: Build working-directory: build/ run: cmake --build . --config Debug @@ -42,6 +43,7 @@ jobs: fail-fast: false matrix: xcode: ['11', '13'] + sharedlibs: [OFF, ON] runs-on: macos-latest @@ -55,7 +57,7 @@ jobs: - name: Configure working-directory: build/ - run: cmake $GITHUB_WORKSPACE + run: cmake $GITHUB_WORKSPACE -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}} - name: Build working-directory: build/ run: cmake --build . @@ -64,17 +66,21 @@ jobs: run: ctest --output-on-failure windows: - runs-on: windows-latest + strategy: + fail-fast: false + matrix: + sharedlibs: [OFF, ON] + + runs-on: windows-2019 steps: - uses: actions/checkout@v2 - name: Create Build Environment run: cmake -E make_directory build - - name: Configure shell: bash working-directory: build/ - run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" + run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}} - name: Build working-directory: build/ run: cmake --build . --config Debug diff --git a/.github/workflows/main_ci.yml b/.github/workflows/main_ci.yml index 4aab235..32e0120 100644 --- a/.github/workflows/main_ci.yml +++ b/.github/workflows/main_ci.yml @@ -25,6 +25,7 @@ jobs: - clang50 - clang40 build_type: [Debug, Release] + sharedlibs: [OFF, ON] runs-on: ubuntu-latest container: @@ -35,10 +36,9 @@ jobs: - uses: actions/checkout@v2 - name: Create Build Environment run: cmake -E make_directory build - - name: Configure working-directory: build/ - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}} - name: Build working-directory: build/ run: cmake --build . --config ${{matrix.build_type}} @@ -54,6 +54,7 @@ jobs: - '11' - '12' - '13' + sharedlibs: [OFF, ON] runs-on: macos-latest @@ -64,10 +65,9 @@ jobs: xcode-version: ${{matrix.xcode}} - name: Create Build Environment run: cmake -E make_directory build - - name: Configure working-directory: build/ - run: cmake $GITHUB_WORKSPACE + run: cmake $GITHUB_WORKSPACE -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}} - name: Build working-directory: build/ run: cmake --build . @@ -80,18 +80,18 @@ jobs: fail-fast: false matrix: build_type: [Debug, Release] + sharedlibs: [OFF, ON] - runs-on: windows-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v2 - name: Create Build Environment run: cmake -E make_directory build - - name: Configure shell: bash working-directory: build/ - run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" + run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}} - name: Build working-directory: build/ run: cmake --build . --config ${{matrix.build_type}} diff --git a/CMakeLists.txt b/CMakeLists.txt index ed6d029..a2243a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ elseif(WIN32) set(FOONATHAN_MEMORY_CMAKE_CONFIG_INSTALL_DIR "share/foonathan_memory/cmake") set(FOONATHAN_MEMORY_ADDITIONAL_FILES_INSTALL_DIR "share/foonathan_memory") set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") else() message(FATAL_ERROR "Could not set install folders for this platform!") endif() diff --git a/include/foonathan/memory/virtual_memory.hpp b/include/foonathan/memory/virtual_memory.hpp index ee58ef9..e0db0fe 100644 --- a/include/foonathan/memory/virtual_memory.hpp +++ b/include/foonathan/memory/virtual_memory.hpp @@ -38,8 +38,15 @@ namespace foonathan /// All virtual memory allocations must be multiple of this size. /// It is usually 4KiB. /// \ingroup allocator + /// \deprecated use \ref get_virtual_memory_page_size instead. extern const std::size_t virtual_memory_page_size; + /// \returns the page size of the virtual memory. + /// All virtual memory allocations must be multiple of this size. + /// It is usually 4KiB. + /// \ingroup allocator + std::size_t get_virtual_memory_page_size() noexcept; + /// Reserves virtual memory. /// \effects Reserves the given number of pages. /// Each page is \ref virtual_memory_page_size big. diff --git a/src/virtual_memory.cpp b/src/virtual_memory.cpp index 0ddfa90..5e42d28 100644 --- a/src/virtual_memory.cpp +++ b/src/virtual_memory.cpp @@ -141,6 +141,11 @@ void foonathan::memory::virtual_memory_decommit(void* memory, std::size_t no_pag #warning "virtual memory functions not available on your platform, define your own" #endif +std::size_t foonathan::memory::get_virtual_memory_page_size() noexcept +{ + return virtual_memory_page_size; +} + namespace { std::size_t calc_no_pages(std::size_t size) noexcept diff --git a/test/default_allocator.cpp b/test/default_allocator.cpp index 4d3ac5d..10f3959 100644 --- a/test/default_allocator.cpp +++ b/test/default_allocator.cpp @@ -71,5 +71,5 @@ TEST_CASE("static_allocator") TEST_CASE("virtual_memory_allocator") { virtual_memory_allocator alloc; - check_default_allocator(alloc, virtual_memory_page_size); + check_default_allocator(alloc, get_virtual_memory_page_size()); }