diff --git a/Build.md b/Build.md index 3c2e8534..92cc5e1a 100644 --- a/Build.md +++ b/Build.md @@ -1,11 +1,11 @@ # Build instructions -These compilers and OSs are regularly tested: +These compilers and OSs are regularly tested by CI: -- [GCC](https://gcc.gnu.org/) 9.4 (Linux 5.x x64) -- [Clang](https://clang.llvm.org/) 11 (Linux 5.x x64) -- Xcode 13.2 (macOS 11 x64) -- Visual Studio 2022 (Windows Server 2022 x64). +- [GCC](https://gcc.gnu.org/) on Linux +- [Clang](https://clang.llvm.org/) on Linux +- Xcode on Mac OS +- Visual Studio on Windows Other compilers, architectures and OSs may work, but are not tested regularly. You will need a working [Filesystem TS](https://en.cppreference.com/w/cpp/experimental/fs) @@ -91,7 +91,7 @@ To build and test on POSIX (`make`, `ninja` etc): mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release -cmake --build . +cmake --build . --parallel ctest -R llfio_sl ~~~ @@ -101,7 +101,7 @@ To build and test on Windows or Mac OS (Visual Studio, XCode etc): mkdir build cd build cmake .. -G -cmake --build . --config Release +cmake --build . --parallel --config Release ctest -C Release -R llfio_sl ~~~ @@ -115,7 +115,7 @@ To build and test on POSIX (`make`, `ninja` etc): mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release -cmake --build . -- _dl +cmake --build . --parallel -- _dl ctest -R llfio_dl ~~~ @@ -125,16 +125,57 @@ To build and test on Windows or Mac OS (Visual Studio, XCode etc): mkdir build cd build cmake .. -G -cmake --build . --config Release --target _dl +cmake --build . --parallel --config Release --target _dl ctest -C Release -R llfio_dl ~~~ ## Installing libraries from source +If you add llfio as a subdirectory in cmake (`add_subdirectory()`), +you can link to its exported targets and everything 'just works'. The +dependencies quickcpplib and outcome will be automatically downloaded +into the build directory and used. + +If you really want to install llfio into a directory, you can also: + ~~~ +git config --system core.longpaths true + +git clone --recursive https://github.com/ned14/quickcpplib.git +cd quickcpplib mkdir build cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -cmake --build . -- _dl _sl _hl +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local +cmake --build . --parallel +cmake --build . --target install +cd ../.. + +git clone --recursive https://github.com/ned14/outcome.git +cd outcome +mkdir build +cd build +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local +cmake --build . --parallel +cmake --build . --target install +cd ../.. + +git clone --recursive https://github.com/ned14/llfio.git +cd llfio +mkdir build +cd build +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local +cmake --build . --parallel -- _dl _sl _hl cmake --build . --target install +cd ../.. ~~~ + +If you chose a different `CMAKE_INSTALL_PREFIX` then it will need +to be supplied to the compiler: + +~~~ +cd example +g++ -std=c++17 -o test map_file.cpp -I/Users/ned/testinstall/inst/include +~~~ + +The above also works on Microsoft Windows, but paths etc will need to +be adjusted. diff --git a/include/llfio/v2.0/config.hpp b/include/llfio/v2.0/config.hpp index b092952d..a0e83a5e 100644 --- a/include/llfio/v2.0/config.hpp +++ b/include/llfio/v2.0/config.hpp @@ -1,5 +1,5 @@ /* Configures LLFIO -(C) 2015-2020 Niall Douglas (24 commits) +(C) 2015-2024 Niall Douglas (24 commits) File Created: Dec 2015 @@ -25,10 +25,10 @@ Distributed under the Boost Software License, Version 1.0. #ifndef LLFIO_CONFIG_HPP #define LLFIO_CONFIG_HPP -//#include -//#define LLFIO_LOG_TO_OSTREAM std::cerr -//#define LLFIO_LOGGING_LEVEL 1 -//#define LLFIO_DISABLE_PATHS_IN_FAILURE_INFO +// #include +// #define LLFIO_LOG_TO_OSTREAM std::cerr +// #define LLFIO_LOGGING_LEVEL 1 +// #define LLFIO_DISABLE_PATHS_IN_FAILURE_INFO //! \file config.hpp Configures a compiler environment for LLFIO header and source code @@ -85,6 +85,17 @@ Distributed under the Boost Software License, Version 1.0. #define LLFIO_EXPERIMENTAL_STATUS_CODE 0 #endif +// Exclude deprecated stuff by default +#ifndef LLFIO_EXCLUDE_DYNAMIC_THREAD_POOL_GROUP +#define LLFIO_EXCLUDE_DYNAMIC_THREAD_POOL_GROUP 1 +#endif +#ifndef LLFIO_EXCLUDE_NETWORKING +#define LLFIO_EXCLUDE_NETWORKING 1 +#endif +#ifndef LLFIO_DISABLE_OPENSSL +#define LLFIO_DISABLE_OPENSSL 1 +#endif + #if defined(_WIN32) #if !defined(_WIN32_WINNT) @@ -106,6 +117,18 @@ Distributed under the Boost Software License, Version 1.0. #include <_mingw.h> #endif +#ifdef __has_include +#if !__has_include("quickcpplib/cpp_feature.h") && !__has_include("outcome/try.hpp") +#error "Could not find quickcpplib nor outcome. If you installed LLFIO, did you also install quickcpplib and outcome?" +#endif +#if !__has_include("quickcpplib/cpp_feature.h") +#error "Could not find quickcpplib. If you installed LLFIO, did you also install quickcpplib?" +#endif +#if !__has_include("outcome/try.hpp") +#error "Could not find outcome. If you installed LLFIO, did you also install outcome?" +#endif +#endif + #include "quickcpplib/cpp_feature.h" #ifndef STANDARDESE_IS_IN_THE_HOUSE @@ -181,15 +204,15 @@ namespace starting with `v2_` inside the `boost::llfio` namespace. /*! \brief Expands into the appropriate namespace markup to enter the LLFIO v2 namespace. \ingroup config */ -#define LLFIO_V2_NAMESPACE_BEGIN \ - namespace llfio_v2_xxx \ +#define LLFIO_V2_NAMESPACE_BEGIN \ + namespace llfio_v2_xxx \ { /*! \brief Expands into the appropriate namespace markup to enter the C++ module exported LLFIO v2 namespace. \ingroup config */ -#define LLFIO_V2_NAMESPACE_EXPORT_BEGIN \ - export namespace llfio_v2_xxx \ +#define LLFIO_V2_NAMESPACE_EXPORT_BEGIN \ + export namespace llfio_v2_xxx \ { /*! \brief Expands into the appropriate namespace markup to exit the LLFIO v2 namespace. \ingroup config @@ -266,7 +289,8 @@ LLFIO_V2_NAMESPACE_END #endif #if LLFIO_USING_EXPERIMENTAL_FILESYSTEM && !LLFIO_DISABLE_USING_EXPERIMENTAL_FILESYSTEM_WARNING #ifdef _MSC_VER -#pragma message("WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO.") +#pragma message( \ +"WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO.") #else #warning WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO. #endif @@ -364,7 +388,8 @@ LLFIO_V2_NAMESPACE_END // Bring in a function_ptr implementation #include "quickcpplib/function_ptr.hpp" LLFIO_V2_NAMESPACE_BEGIN -template using function_ptr = QUICKCPPLIB_NAMESPACE::function_ptr::function_ptr; +template +using function_ptr = QUICKCPPLIB_NAMESPACE::function_ptr::function_ptr; using QUICKCPPLIB_NAMESPACE::function_ptr::emplace_function_ptr; using QUICKCPPLIB_NAMESPACE::function_ptr::emplace_function_ptr_nothrow; using QUICKCPPLIB_NAMESPACE::function_ptr::make_function_ptr; @@ -396,7 +421,7 @@ LLFIO_V2_NAMESPACE_END #include "quickcpplib/spinlock.hpp" LLFIO_V2_NAMESPACE_BEGIN using spinlock = QUICKCPPLIB_NAMESPACE::configurable_spinlock::spinlock; -using QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard; +using QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard; LLFIO_V2_NAMESPACE_END // Bring in a memory resource implementation #include "quickcpplib/memory_resource.hpp" @@ -412,13 +437,22 @@ namespace detail // Used to cast an unknown input to some unsigned integer LLFIO_TEMPLATE(class T, class U) LLFIO_TREQUIRES(LLFIO_TPRED(std::is_unsigned::value && !std::is_same, std::nullptr_t>::value)) - inline T unsigned_integer_cast(U &&v) { return static_cast(v); } + inline T unsigned_integer_cast(U &&v) + { + return static_cast(v); + } LLFIO_TEMPLATE(class T) LLFIO_TREQUIRES(LLFIO_TPRED(std::is_unsigned::value)) - inline T unsigned_integer_cast(std::nullptr_t /* unused */) { return static_cast(0); } + inline T unsigned_integer_cast(std::nullptr_t /* unused */) + { + return static_cast(0); + } LLFIO_TEMPLATE(class T, class U) LLFIO_TREQUIRES(LLFIO_TPRED(std::is_unsigned::value)) - inline T unsigned_integer_cast(U *v) { return static_cast(reinterpret_cast(v)); } + inline T unsigned_integer_cast(U *v) + { + return static_cast(reinterpret_cast(v)); + } } // namespace detail LLFIO_V2_NAMESPACE_END @@ -437,10 +471,10 @@ namespace win LLFIO_V2_NAMESPACE_END -//#define BOOST_THREAD_VERSION 4 -//#define BOOST_THREAD_PROVIDES_VARIADIC_THREAD -//#define BOOST_THREAD_DONT_PROVIDE_FUTURE -//#define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK +// #define BOOST_THREAD_VERSION 4 +// #define BOOST_THREAD_PROVIDES_VARIADIC_THREAD +// #define BOOST_THREAD_DONT_PROVIDE_FUTURE +// #define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK #if LLFIO_HEADERS_ONLY == 1 && !defined(LLFIO_SOURCE) /*! \brief Expands into the appropriate markup to declare an `extern` function exported from the LLFIO DLL if not building headers only. @@ -483,7 +517,9 @@ namespace detail { if(sizeof(LLFIO_V2_NAMESPACE::filesystem::path) != sizeof_filesystem_path()) { - fprintf(stderr, "FATAL: sizeof(filesystem::path) = %u differs in the translation unit '%s' to the sizeof(filesystem::path) = %u as when LLFIO was built!\n", (unsigned) sizeof(LLFIO_V2_NAMESPACE::filesystem::path), filepath, (unsigned) sizeof_filesystem_path()); + fprintf(stderr, + "FATAL: sizeof(filesystem::path) = %u differs in the translation unit '%s' to the sizeof(filesystem::path) = %u as when LLFIO was built!\n", + (unsigned) sizeof(LLFIO_V2_NAMESPACE::filesystem::path), filepath, (unsigned) sizeof_filesystem_path()); abort(); } } diff --git a/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp b/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp index 04bb431e..54246bb5 100644 --- a/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp @@ -29,7 +29,7 @@ http://www.boost.org/LICENSE_1_0.txt) #include "quickcpplib/valgrind/memcheck.h" // from quickcpplib include directory #define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b) VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE((a), (b)) #else -#define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b) +#define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b) (0) #endif #include /* Defines DT_* constants */ @@ -443,7 +443,7 @@ result directory_handle::read(io_request(reinterpret_cast(dent) + dent->d_reclen)) {