diff options
author | Jack Lloyd <[email protected]> | 2018-01-09 10:07:31 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-01-09 10:07:31 -0500 |
commit | 92749094c285d14a683b490042d79a960991490c (patch) | |
tree | f31e6c7a144c2f8c1ac2b8e323de7c5c0a819f71 /src | |
parent | d220c13939be5102b7916d36c1031b77a07f972c (diff) | |
parent | f0575ecf644a583afb491d14df1f7b03dae7bd32 (diff) |
Merge GH #1378 Use OS feature flags instead of OS name for enabling system specific code
Diffstat (limited to 'src')
40 files changed, 161 insertions, 225 deletions
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index 10b03ca70..9333cfb8a 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -45,9 +45,6 @@ /* Target identification and feature test macros */ #define BOTAN_TARGET_OS_IS_%{os_name|upper} -%{if os_type} -#define BOTAN_TARGET_OS_TYPE_IS_%{os_type|upper} -%{endif} %{for os_features} #define BOTAN_TARGET_OS_HAS_%{i|upper} diff --git a/src/build-data/os/aix.txt b/src/build-data/os/aix.txt index b12685c61..caf94fdd4 100644 --- a/src/build-data/os/aix.txt +++ b/src/build-data/os/aix.txt @@ -1,14 +1,14 @@ -os_type unix soname_suffix "so" use_stack_protector no <target_features> +posix1 clock_gettime -gmtime_r -dlopen -readdir +dev_random +proc_fs + sockets threads filesystem diff --git a/src/build-data/os/android.txt b/src/build-data/os/android.txt index 79031d4f7..b45287b54 100644 --- a/src/build-data/os/android.txt +++ b/src/build-data/os/android.txt @@ -1,16 +1,17 @@ -os_type unix soname_suffix "so" <target_features> +posix1 + +dev_random clock_gettime -posix_mlock -gmtime_r + # getauxval is available in Android NDK for min API 18 and in Crystax NDK -# for all min API levels. Comment out if older API levels must be supported. +# for all min API levels. Use --without-os-feature=getauxval to disable getauxval -dlopen -readdir + +sockets threads filesystem </target_features> diff --git a/src/build-data/os/cygwin.txt b/src/build-data/os/cygwin.txt index f4118aedb..1d106b06c 100644 --- a/src/build-data/os/cygwin.txt +++ b/src/build-data/os/cygwin.txt @@ -1,4 +1,3 @@ -os_type unix program_suffix .exe @@ -10,7 +9,10 @@ install_root c:\Botan doc_dir docs <target_features> -readdir +posix1 +dev_random + +sockets threads filesystem </target_features> diff --git a/src/build-data/os/darwin.txt b/src/build-data/os/darwin.txt index acc59f2c2..3c221e0b9 100644 --- a/src/build-data/os/darwin.txt +++ b/src/build-data/os/darwin.txt @@ -1,4 +1,3 @@ -os_type unix soname_pattern_base "libbotan-{version_major}.dylib" soname_pattern_abi "libbotan-{version_major}.{abi_rev}.dylib" @@ -11,13 +10,14 @@ so_post_link_command "install_name_tool -change '$(INSTALLED_LIB_DIR)/{soname_ab doc_dir doc <target_features> +posix1 arc4random -dlopen -filesystem -gmtime_r -readdir +dev_random +security_framework + sockets threads +filesystem </target_features> <aliases> diff --git a/src/build-data/os/dragonfly.txt b/src/build-data/os/dragonfly.txt index 9a5590d89..257b2ef6b 100644 --- a/src/build-data/os/dragonfly.txt +++ b/src/build-data/os/dragonfly.txt @@ -1,13 +1,14 @@ -os_type unix soname_suffix "so" <target_features> +posix1 clock_gettime -posix_mlock +proc_fs +dev_random +arc4random + sockets threads filesystem -readdir -dlopen </target_features> diff --git a/src/build-data/os/freebsd.txt b/src/build-data/os/freebsd.txt index 17cad3ac0..4de44a318 100644 --- a/src/build-data/os/freebsd.txt +++ b/src/build-data/os/freebsd.txt @@ -1,13 +1,12 @@ -os_type unix soname_suffix "so" <target_features> +posix1 clock_gettime -posix_mlock -gmtime_r -dlopen -readdir +dev_random +arc4random + sockets threads filesystem diff --git a/src/build-data/os/haiku.txt b/src/build-data/os/haiku.txt index 37f3d862f..e203a0d26 100644 --- a/src/build-data/os/haiku.txt +++ b/src/build-data/os/haiku.txt @@ -1,4 +1,3 @@ -os_type unix soname_suffix "so" @@ -10,10 +9,10 @@ doc_dir system/documentation use_stack_protector no <target_features> +posix1 clock_gettime -gmtime_r -dlopen -readdir +dev_random + sockets threads filesystem diff --git a/src/build-data/os/hpux.txt b/src/build-data/os/hpux.txt index 86a79e5ca..112ad1ea3 100644 --- a/src/build-data/os/hpux.txt +++ b/src/build-data/os/hpux.txt @@ -1,9 +1,13 @@ -os_type unix # It is "sl" on HP-PA, but HP-UX on PA is EOL soname_suffix "so" <target_features> +posix1 +clock_gettime +dev_random + +sockets threads filesystem </target_features> diff --git a/src/build-data/os/hurd.txt b/src/build-data/os/hurd.txt index 846117805..29ca47490 100644 --- a/src/build-data/os/hurd.txt +++ b/src/build-data/os/hurd.txt @@ -1,9 +1,12 @@ -os_type unix soname_suffix "so" <target_features> -posix_mlock +posix1 +dev_random +clock_gettime + +sockets threads filesystem </target_features> diff --git a/src/build-data/os/includeos.txt b/src/build-data/os/includeos.txt index cabcec6b9..7d2ebfdc9 100644 --- a/src/build-data/os/includeos.txt +++ b/src/build-data/os/includeos.txt @@ -1,5 +1,4 @@ -os_type unikernel - - <target_features> +posix1 +dev_random </target_features> diff --git a/src/build-data/os/ios.txt b/src/build-data/os/ios.txt index c0195fa9e..e5729fed8 100644 --- a/src/build-data/os/ios.txt +++ b/src/build-data/os/ios.txt @@ -1,4 +1,3 @@ -os_type unix soname_pattern_base "libbotan-{version_major}.{version_minor}.dylib" soname_pattern_abi "libbotan-{version_major}.{version_minor}.{abi_rev}.dylib" @@ -7,13 +6,12 @@ soname_pattern_patch "libbotan-{version_major}.{version_minor}.{abi_rev}.{versio doc_dir doc <target_features> +posix1 arc4random -dlopen -filesystem -gmtime_r -readdir + sockets threads +filesystem </target_features> <aliases> diff --git a/src/build-data/os/linux.txt b/src/build-data/os/linux.txt index 99bcf21eb..7029adbef 100644 --- a/src/build-data/os/linux.txt +++ b/src/build-data/os/linux.txt @@ -1,14 +1,14 @@ -os_type unix soname_suffix "so" <target_features> +posix1 + +dev_random +proc_fs clock_gettime -posix_mlock -gmtime_r -dlopen getauxval -readdir + sockets threads filesystem diff --git a/src/build-data/os/mingw.txt b/src/build-data/os/mingw.txt index b0e98e166..b74aa2d49 100644 --- a/src/build-data/os/mingw.txt +++ b/src/build-data/os/mingw.txt @@ -1,4 +1,3 @@ -os_type windows program_suffix .exe obj_suffix o @@ -16,9 +15,10 @@ mingw32.* </aliases> <target_features> +win32 cryptgenrandom -loadlibrary virtual_lock + threads filesystem </target_features> diff --git a/src/build-data/os/netbsd.txt b/src/build-data/os/netbsd.txt index 21f388e29..4de44a318 100644 --- a/src/build-data/os/netbsd.txt +++ b/src/build-data/os/netbsd.txt @@ -1,13 +1,13 @@ -os_type unix soname_suffix "so" <target_features> +posix1 clock_gettime -posix_mlock -gmtime_r -dlopen -readdir +dev_random +arc4random + +sockets threads filesystem </target_features> diff --git a/src/build-data/os/openbsd.txt b/src/build-data/os/openbsd.txt index a5db3fd8e..99a3edf79 100644 --- a/src/build-data/os/openbsd.txt +++ b/src/build-data/os/openbsd.txt @@ -1,17 +1,16 @@ -os_type unix soname_pattern_base "libbotan-{version_major}.so" soname_pattern_abi "libbotan-{version_major}.so.{abi_rev}" soname_pattern_patch "libbotan-{version_major}.so.{abi_rev}.{version_minor}" <target_features> -arc4random +posix1 clock_gettime +dev_random +arc4random +getentropy explicit_bzero -posix_mlock -gmtime_r -dlopen -readdir + sockets threads filesystem diff --git a/src/build-data/os/qnx.txt b/src/build-data/os/qnx.txt index 65fd8acf0..70810d2d9 100644 --- a/src/build-data/os/qnx.txt +++ b/src/build-data/os/qnx.txt @@ -1,13 +1,11 @@ -# not really, but for our purposes -os_type unix - soname_suffix "so" <target_features> +posix1 clock_gettime -posix_mlock -gmtime_r -dlopen +dev_random + +sockets threads filesystem </target_features> diff --git a/src/build-data/os/solaris.txt b/src/build-data/os/solaris.txt index 7c89e4ad9..f2bfca616 100644 --- a/src/build-data/os/solaris.txt +++ b/src/build-data/os/solaris.txt @@ -1,11 +1,14 @@ -os_type unix soname_suffix "so" <target_features> -posix_mlock +posix1 +clock_gettime +dev_random +proc_fs + threads -readdir +sockets filesystem </target_features> diff --git a/src/build-data/os/windows.txt b/src/build-data/os/windows.txt index 639b0512d..8fb8bc586 100644 --- a/src/build-data/os/windows.txt +++ b/src/build-data/os/windows.txt @@ -1,4 +1,3 @@ -os_type windows cli_exe_name botan-cli @@ -17,16 +16,17 @@ install_root c:\\Botan doc_dir docs <target_features> +win32 +winsock2 + cryptgenrandom -gmtime_s -loadlibrary -query_perf_counter -virtual_lock rtlsecurezeromemory + +virtual_lock stl_filesystem_msvc + threads filesystem -sockets </target_features> <aliases> diff --git a/src/build-data/os/winphone.txt b/src/build-data/os/winphone.txt index 34f2e0f5f..bc0179c12 100644 --- a/src/build-data/os/winphone.txt +++ b/src/build-data/os/winphone.txt @@ -1,4 +1,3 @@ -os_type windows # ? program_suffix .exe @@ -9,13 +8,12 @@ install_root c:\\Botan doc_dir docs <target_features> +win32 +winsock2 + crypto_ng -gmtime_s -loadlibrary -query_perf_counter rtlsecurezeromemory -#stl_filesystem_msvc + threads filesystem -sockets </target_features> diff --git a/src/cli/socket_utils.h b/src/cli/socket_utils.h index a8e2a51a6..d7eb4382e 100644 --- a/src/cli/socket_utils.h +++ b/src/cli/socket_utils.h @@ -11,7 +11,7 @@ #include <botan/build.h> #include "cli_exceptions.h" -#if defined(BOTAN_TARGET_OS_IS_WINDOWS) +#if defined(BOTAN_TARGET_OS_HAS_WINSOCK2) #include <winsock2.h> #include <WS2tcpip.h> @@ -57,7 +57,7 @@ inline int send(int s, const uint8_t* buf, size_t len, int flags) return ::send(s, reinterpret_cast<const char*>(buf), static_cast<int>(len), flags); } -#else +#elif defined(BOTAN_TARGET_OS_HAS_POSIX1) #include <sys/types.h> #include <sys/time.h> diff --git a/src/cli/tls_client.cpp b/src/cli/tls_client.cpp index ddc443614..7a9633fca 100644 --- a/src/cli/tls_client.cpp +++ b/src/cli/tls_client.cpp @@ -8,7 +8,7 @@ #include "cli.h" -#if defined(BOTAN_HAS_TLS) && defined(BOTAN_TARGET_OS_HAS_SOCKETS) +#if defined(BOTAN_HAS_TLS) && (defined(BOTAN_TARGET_OS_HAS_SOCKETS) || defined(BOTAN_TARGET_OS_HAS_WINSOCK2)) #include <botan/tls_client.h> #include <botan/tls_policy.h> diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp index 44c69bf17..7127b2020 100644 --- a/src/cli/tls_server.cpp +++ b/src/cli/tls_server.cpp @@ -8,7 +8,7 @@ #include "cli.h" -#if defined(BOTAN_HAS_TLS) && defined(BOTAN_TARGET_OS_HAS_SOCKETS) +#if defined(BOTAN_HAS_TLS) && (defined(BOTAN_TARGET_OS_HAS_SOCKETS) || defined(BOTAN_TARGET_OS_HAS_WINSOCK2)) #include <botan/tls_server.h> #include <botan/tls_policy.h> diff --git a/src/lib/entropy/darwin_secrandom/info.txt b/src/lib/entropy/darwin_secrandom/info.txt index 477818818..c1943a04a 100644 --- a/src/lib/entropy/darwin_secrandom/info.txt +++ b/src/lib/entropy/darwin_secrandom/info.txt @@ -6,10 +6,9 @@ ENTROPY_SRC_DARWIN_SECRANDOM -> 20150925 darwin_secrandom.h </header:internal> -<os> -darwin -ios -</os> +<os_features> +security_framework +</os_features> <frameworks> darwin -> Security diff --git a/src/lib/entropy/dev_random/info.txt b/src/lib/entropy/dev_random/info.txt index d22f18211..3872411f3 100644 --- a/src/lib/entropy/dev_random/info.txt +++ b/src/lib/entropy/dev_random/info.txt @@ -6,19 +6,6 @@ ENTROPY_SRC_DEV_RANDOM -> 20131128 dev_random.h </header:internal> -<os> -aix -android -cygwin -darwin -dragonfly -freebsd -haiku -hpux -hurd -linux -netbsd -openbsd -qnx -solaris -</os> +<os_features> +dev_random,posix1 +</os_features> diff --git a/src/lib/entropy/getentropy/info.txt b/src/lib/entropy/getentropy/info.txt index a44299cbe..886e57151 100644 --- a/src/lib/entropy/getentropy/info.txt +++ b/src/lib/entropy/getentropy/info.txt @@ -6,6 +6,6 @@ ENTROPY_SRC_GETENTROPY -> 20170327 getentropy.h </header:internal> -<os> -openbsd -</os> +<os_features> +getentropy +</os_features> diff --git a/src/lib/entropy/proc_walk/info.txt b/src/lib/entropy/proc_walk/info.txt index f93d0cb3f..2bba7e276 100644 --- a/src/lib/entropy/proc_walk/info.txt +++ b/src/lib/entropy/proc_walk/info.txt @@ -6,16 +6,6 @@ ENTROPY_SRC_PROC_WALKER -> 20131128 proc_walk.h </header:internal> -<os> -android -aix -cygwin -darwin -dragonfly -hpux -hurd -linux -netbsd -qnx -solaris -</os> +<os_features> +posix1,proc_fs +</os_features> diff --git a/src/lib/entropy/win32_stats/info.txt b/src/lib/entropy/win32_stats/info.txt index 7c84fc235..68abae34e 100644 --- a/src/lib/entropy/win32_stats/info.txt +++ b/src/lib/entropy/win32_stats/info.txt @@ -6,11 +6,9 @@ ENTROPY_SRC_WIN32 -> 20131128 es_win32.h </header:internal> -<os> -windows -cygwin -mingw -</os> +<os_features> +win32 +</os_features> <libs> windows -> user32.lib diff --git a/src/lib/filters/fd_unix/info.txt b/src/lib/filters/fd_unix/info.txt index 4679cb4d5..41e7a23a5 100644 --- a/src/lib/filters/fd_unix/info.txt +++ b/src/lib/filters/fd_unix/info.txt @@ -4,18 +4,6 @@ PIPE_UNIXFD_IO -> 20131128 load_on auto -<os> -android -aix -cygwin -darwin -dragonfly -freebsd -haiku -hpux -linux -netbsd -openbsd -qnx -solaris -</os> +<os_features> +posix1 +</os_features> diff --git a/src/lib/rng/system_rng/info.txt b/src/lib/rng/system_rng/info.txt index 0c04fa21c..8f25bf84c 100644 --- a/src/lib/rng/system_rng/info.txt +++ b/src/lib/rng/system_rng/info.txt @@ -2,27 +2,12 @@ SYSTEM_RNG -> 20141202 </defines> -<os> -aix -android -cygwin -darwin -dragonfly -freebsd -haiku -hpux -hurd -includeos -ios -linux -mingw -netbsd -openbsd -qnx -solaris -windows -winphone -</os> +<os_features> +dev_random,posix1 +arc4random +crypto_ng +cryptgenrandom +</os_features> <libs> windows -> advapi32.lib diff --git a/src/lib/utils/calendar.cpp b/src/lib/utils/calendar.cpp index e902e411d..fe04f1d23 100644 --- a/src/lib/utils/calendar.cpp +++ b/src/lib/utils/calendar.cpp @@ -21,9 +21,9 @@ std::tm do_gmtime(std::time_t time_val) { std::tm tm; -#if defined(BOTAN_TARGET_OS_HAS_GMTIME_S) +#if defined(BOTAN_TARGET_OS_HAS_WIN32) ::gmtime_s(&tm, &time_val); // Windows -#elif defined(BOTAN_TARGET_OS_HAS_GMTIME_R) +#elif defined(BOTAN_TARGET_OS_HAS_POSIX1) ::gmtime_r(&time_val, &tm); // Unix/SUSv2 #else std::tm* tm_p = std::gmtime(&time_val); diff --git a/src/lib/utils/dyn_load/dyn_load.cpp b/src/lib/utils/dyn_load/dyn_load.cpp index 33288b8d1..b7f2649ef 100644 --- a/src/lib/utils/dyn_load/dyn_load.cpp +++ b/src/lib/utils/dyn_load/dyn_load.cpp @@ -8,9 +8,9 @@ #include <botan/dyn_load.h> #include <botan/exceptn.h> -#if defined(BOTAN_TARGET_OS_HAS_DLOPEN) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) #include <dlfcn.h> -#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) #define NOMINMAX 1 #define _WINSOCKAPI_ // stop windows.h including winsock.h #include <windows.h> @@ -24,7 +24,7 @@ void raise_runtime_loader_exception(const std::string& lib_name, const char* msg) { throw Exception("Failed to load " + lib_name + ": " + - (msg ? msg : "Unknown error")); + (msg ? msg : "Unknown error")); } } @@ -33,13 +33,13 @@ Dynamically_Loaded_Library::Dynamically_Loaded_Library( const std::string& library) : m_lib_name(library), m_lib(nullptr) { -#if defined(BOTAN_TARGET_OS_HAS_DLOPEN) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) m_lib = ::dlopen(m_lib_name.c_str(), RTLD_LAZY); if(!m_lib) raise_runtime_loader_exception(m_lib_name, ::dlerror()); -#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) m_lib = ::LoadLibraryA(m_lib_name.c_str()); if(!m_lib) @@ -52,9 +52,9 @@ Dynamically_Loaded_Library::Dynamically_Loaded_Library( Dynamically_Loaded_Library::~Dynamically_Loaded_Library() { -#if defined(BOTAN_TARGET_OS_HAS_DLOPEN) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) ::dlclose(m_lib); -#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) ::FreeLibrary((HMODULE)m_lib); #endif } @@ -63,11 +63,10 @@ void* Dynamically_Loaded_Library::resolve_symbol(const std::string& symbol) { void* addr = nullptr; -#if defined(BOTAN_TARGET_OS_HAS_DLOPEN) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) addr = ::dlsym(m_lib, symbol.c_str()); -#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY) - addr = reinterpret_cast<void*>(::GetProcAddress((HMODULE)m_lib, - symbol.c_str())); +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) + addr = reinterpret_cast<void*>(::GetProcAddress((HMODULE)m_lib, symbol.c_str())); #endif if(!addr) diff --git a/src/lib/utils/dyn_load/info.txt b/src/lib/utils/dyn_load/info.txt index 2caeac728..4dd4932a0 100644 --- a/src/lib/utils/dyn_load/info.txt +++ b/src/lib/utils/dyn_load/info.txt @@ -4,17 +4,10 @@ DYNAMIC_LOADER -> 20160310 load_on dep -<os> -android -freebsd -linux -netbsd -openbsd -qnx -solaris -windows -darwin -</os> +<os_features> +posix1 +win32 +</os_features> <libs> android -> dl diff --git a/src/lib/utils/filesystem.cpp b/src/lib/utils/filesystem.cpp index fd4aee1f0..29f73fcb3 100644 --- a/src/lib/utils/filesystem.cpp +++ b/src/lib/utils/filesystem.cpp @@ -13,14 +13,14 @@ #include <filesystem> #elif defined(BOTAN_HAS_BOOST_FILESYSTEM) #include <boost/filesystem.hpp> -#elif defined(BOTAN_TARGET_OS_HAS_READDIR) +#elif defined(BOTAN_TARGET_OS_HAS_POSIX1) #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <deque> #include <memory> #include <functional> -#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) #define NOMINMAX 1 #define _WINSOCKAPI_ // stop windows.h including winsock.h #include <windows.h> @@ -74,7 +74,8 @@ std::vector<std::string> impl_boost_filesystem(const std::string& dir_path) return out; } -#elif defined(BOTAN_TARGET_OS_HAS_READDIR) +#elif defined(BOTAN_TARGET_OS_HAS_POSIX1) + std::vector<std::string> impl_readdir(const std::string& dir_path) { std::vector<std::string> out; @@ -113,7 +114,7 @@ std::vector<std::string> impl_readdir(const std::string& dir_path) return out; } -#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) std::vector<std::string> impl_win32(const std::string& dir_path) { @@ -167,9 +168,9 @@ std::vector<std::string> get_files_recursive(const std::string& dir) files = impl_stl_filesystem(dir); #elif defined(BOTAN_HAS_BOOST_FILESYSTEM) files = impl_boost_filesystem(dir); -#elif defined(BOTAN_TARGET_OS_HAS_READDIR) +#elif defined(BOTAN_TARGET_OS_HAS_POSIX1) files = impl_readdir(dir); -#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) files = impl_win32(dir); #else BOTAN_UNUSED(dir); diff --git a/src/lib/utils/locking_allocator/info.txt b/src/lib/utils/locking_allocator/info.txt index 5f848f62d..7dc3c059d 100644 --- a/src/lib/utils/locking_allocator/info.txt +++ b/src/lib/utils/locking_allocator/info.txt @@ -2,10 +2,7 @@ LOCKING_ALLOCATOR -> 20131128 </defines> -<os> -linux -freebsd -openbsd -netbsd -windows -</os> +<os_features> +posix1 +virtual_lock +</os_features> diff --git a/src/lib/utils/mutex.h b/src/lib/utils/mutex.h index 6e24815bb..34fed5c81 100644 --- a/src/lib/utils/mutex.h +++ b/src/lib/utils/mutex.h @@ -20,7 +20,7 @@ typedef std::mutex mutex_type; } -#elif defined(BOTAN_TARGET_OS_TYPE_IS_UNIKERNEL) || defined(BOTAN_TARGET_OS_IS_LLVM) +#else // No threads @@ -53,8 +53,6 @@ template<typename T> using lock_guard_type = lock_guard<T>; } -#else - #error "Threads unexpectedly disabled in non unikernel build" #endif #endif diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp index 48890964a..0f3ab7a32 100644 --- a/src/lib/utils/os_utils.cpp +++ b/src/lib/utils/os_utils.cpp @@ -18,7 +18,7 @@ #include <string.h> #endif -#if defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) #include <sys/types.h> #include <sys/resource.h> #include <sys/mman.h> @@ -26,7 +26,7 @@ #include <setjmp.h> #include <unistd.h> #include <errno.h> -#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) #define NOMINMAX 1 #include <windows.h> #endif @@ -63,11 +63,11 @@ void secure_scrub_memory(void* ptr, size_t n) uint32_t OS::get_process_id() { -#if defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) return ::getpid(); -#elif defined(BOTAN_TARGET_OS_IS_WINDOWS) || defined(BOTAN_TARGET_OS_IS_MINGW) +#elif defined(BOTAN_TARGET_OS_HAS_WIN32) return ::GetCurrentProcessId(); -#elif defined(BOTAN_TARGET_OS_TYPE_IS_UNIKERNEL) || defined(BOTAN_TARGET_OS_IS_LLVM) +#elif defined(BOTAN_TARGET_OS_IS_INCLUDEOS) || defined(BOTAN_TARGET_OS_IS_LLVM) return 0; // truly no meaningful value #else #error "Missing get_process_id" @@ -78,7 +78,7 @@ uint64_t OS::get_processor_timestamp() { uint64_t rtc = 0; -#if defined(BOTAN_TARGET_OS_HAS_QUERY_PERF_COUNTER) +#if defined(BOTAN_TARGET_OS_HAS_WIN32) LARGE_INTEGER tv; ::QueryPerformanceCounter(&tv); rtc = tv.QuadPart; @@ -196,7 +196,7 @@ uint64_t OS::get_system_timestamp_ns() size_t OS::get_memory_locking_limit() { -#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) /* * Linux defaults to only 64 KiB of mlockable memory per process * (too small) but BSDs offer a small fraction of total RAM (more @@ -282,7 +282,7 @@ size_t OS::get_memory_locking_limit() void* OS::allocate_locked_pages(size_t length) { -#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) #if !defined(MAP_NOCORE) #define MAP_NOCORE 0 @@ -342,11 +342,11 @@ void OS::free_locked_pages(void* ptr, size_t length) if(ptr == nullptr || length == 0) return; -#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) secure_scrub_memory(ptr, length); ::munlock(ptr, length); ::munmap(ptr, length); -#elif defined BOTAN_TARGET_OS_HAS_VIRTUAL_LOCK +#elif defined(BOTAN_TARGET_OS_HAS_VIRTUAL_LOCK) secure_scrub_memory(ptr, length); ::VirtualUnlock(ptr, length); ::VirtualFree(ptr, 0, MEM_RELEASE); @@ -356,7 +356,7 @@ void OS::free_locked_pages(void* ptr, size_t length) #endif } -#if defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) namespace { static ::sigjmp_buf g_sigill_jmp_buf; @@ -373,7 +373,7 @@ int OS::run_cpu_instruction_probe(std::function<int ()> probe_fn) { volatile int probe_result = -3; -#if defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) struct sigaction old_sigaction; struct sigaction sigaction; diff --git a/src/lib/utils/socket/socket.cpp b/src/lib/utils/socket/socket.cpp index 1020a2f5d..b75b4981c 100644 --- a/src/lib/utils/socket/socket.cpp +++ b/src/lib/utils/socket/socket.cpp @@ -20,7 +20,7 @@ #include <boost/asio.hpp> #include <boost/asio/system_timer.hpp> -#elif defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) +#elif defined(BOTAN_TARGET_OS_HAS_SOCKETS) #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> @@ -30,7 +30,7 @@ #include <errno.h> #include <fcntl.h> -#elif defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) && !defined(BOTAN_TARGET_OS_IS_MINGW) +#elif defined(BOTAN_TARGET_OS_HAS_WINSOCK2) #define NOMINMAX 1 #include <winsock2.h> #include <ws2tcpip.h> @@ -136,12 +136,12 @@ class Asio_Socket final : public OS::Socket boost::asio::ip::tcp::socket m_tcp; }; -#elif defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) || (defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) && !defined(BOTAN_TARGET_OS_IS_MINGW)) +#elif defined(BOTAN_TARGET_OS_HAS_SOCKETS) || defined(BOTAN_TARGET_OS_HAS_WINSOCK2) class BSD_Socket final : public OS::Socket { private: -#if defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) +#if defined(BOTAN_TARGET_OS_HAS_WINSOCK2) typedef SOCKET socket_type; typedef int socket_op_ret_type; static socket_type invalid_socket() { return INVALID_SOCKET; } @@ -356,7 +356,7 @@ OS::open_socket(const std::string& hostname, #if defined(BOTAN_HAS_BOOST_ASIO) return std::unique_ptr<OS::Socket>(new Asio_Socket(hostname, service, timeout)); -#elif defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) || (defined(BOTAN_TARGET_OS_TYPE_IS_WINDOWS) && !defined(BOTAN_TARGET_OS_IS_MINGW)) +#elif defined(BOTAN_TARGET_OS_HAS_SOCKETS) || defined(BOTAN_TARGET_OS_HAS_WINSOCK2) return std::unique_ptr<OS::Socket>(new BSD_Socket(hostname, service, timeout)); #else diff --git a/src/tests/test_os_utils.cpp b/src/tests/test_os_utils.cpp index 6707e8960..1c159ca75 100644 --- a/src/tests/test_os_utils.cpp +++ b/src/tests/test_os_utils.cpp @@ -55,8 +55,8 @@ class OS_Utils_Tests final : public Test result.test_eq("PID same across calls", static_cast<size_t>(pid1), static_cast<size_t>(pid2)); -#if defined(BOTAN_TARGET_OS_TYPE_IS_UNIKERNEL) - result.test_eq("PID is zero on unikernel systems", pid1, 0); +#if defined(BOTAN_TARGET_OS_IS_INCLUDEOS) || defined(BOTAN_TARGET_OS_IS_LLVM) + result.test_eq("PID is expected to be zero on this platform", pid1, 0); #else result.test_ne("PID is non-zero on systems with processes", pid1, 0); #endif diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp index 193a94379..a7a83134f 100644 --- a/src/tests/test_rng.cpp +++ b/src/tests/test_rng.cpp @@ -37,7 +37,7 @@ #include <botan/entropy_src.h> #endif -#if defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) #include <unistd.h> #include <sys/wait.h> #endif @@ -273,7 +273,7 @@ class Stateful_RNG_Tests : public Test { Test::Result result(rng_name() + " Fork Safety"); -#if defined(BOTAN_TARGET_OS_TYPE_IS_UNIX) +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) const size_t reseed_interval = 1024; // make sure rng is reseeded after every fork |