aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.py47
-rw-r--r--doc/os.rst20
-rw-r--r--src/build-data/buildh.in3
-rw-r--r--src/build-data/os/aix.txt8
-rw-r--r--src/build-data/os/android.txt13
-rw-r--r--src/build-data/os/cygwin.txt6
-rw-r--r--src/build-data/os/darwin.txt10
-rw-r--r--src/build-data/os/dragonfly.txt9
-rw-r--r--src/build-data/os/freebsd.txt9
-rw-r--r--src/build-data/os/haiku.txt7
-rw-r--r--src/build-data/os/hpux.txt6
-rw-r--r--src/build-data/os/hurd.txt7
-rw-r--r--src/build-data/os/includeos.txt5
-rw-r--r--src/build-data/os/ios.txt8
-rw-r--r--src/build-data/os/linux.txt10
-rw-r--r--src/build-data/os/mingw.txt4
-rw-r--r--src/build-data/os/netbsd.txt10
-rw-r--r--src/build-data/os/openbsd.txt11
-rw-r--r--src/build-data/os/qnx.txt10
-rw-r--r--src/build-data/os/solaris.txt9
-rw-r--r--src/build-data/os/windows.txt12
-rw-r--r--src/build-data/os/winphone.txt10
-rw-r--r--src/cli/socket_utils.h4
-rw-r--r--src/cli/tls_client.cpp2
-rw-r--r--src/cli/tls_server.cpp2
-rw-r--r--src/lib/entropy/darwin_secrandom/info.txt7
-rw-r--r--src/lib/entropy/dev_random/info.txt19
-rw-r--r--src/lib/entropy/getentropy/info.txt6
-rw-r--r--src/lib/entropy/proc_walk/info.txt16
-rw-r--r--src/lib/entropy/win32_stats/info.txt8
-rw-r--r--src/lib/filters/fd_unix/info.txt18
-rw-r--r--src/lib/rng/system_rng/info.txt27
-rw-r--r--src/lib/utils/calendar.cpp4
-rw-r--r--src/lib/utils/dyn_load/dyn_load.cpp21
-rw-r--r--src/lib/utils/dyn_load/info.txt15
-rw-r--r--src/lib/utils/filesystem.cpp13
-rw-r--r--src/lib/utils/locking_allocator/info.txt11
-rw-r--r--src/lib/utils/mutex.h4
-rw-r--r--src/lib/utils/os_utils.cpp24
-rw-r--r--src/lib/utils/socket/socket.cpp10
-rw-r--r--src/tests/test_os_utils.cpp4
-rw-r--r--src/tests/test_rng.cpp4
42 files changed, 203 insertions, 250 deletions
diff --git a/configure.py b/configure.py
index 2c4f7b5de..760b866c4 100755
--- a/configure.py
+++ b/configure.py
@@ -730,7 +730,7 @@ class ModuleInfo(InfoObject):
lex = lex_me_harder(
infofile,
['header:internal', 'header:public', 'header:external', 'requires',
- 'os', 'arch', 'cc', 'libs', 'frameworks', 'comment', 'warning'
+ 'os_features', 'arch', 'cc', 'libs', 'frameworks', 'comment', 'warning'
],
['defines'],
{
@@ -792,7 +792,7 @@ class ModuleInfo(InfoObject):
self.libs = convert_lib_list(lex.libs)
self.load_on = lex.load_on
self.need_isa = lex.need_isa.split(',') if lex.need_isa else []
- self.os = lex.os
+ self.os_features = lex.os_features
self.requires = lex.requires
self.warning = ' '.join(lex.warning) if lex.warning else None
@@ -825,10 +825,12 @@ class ModuleInfo(InfoObject):
if not re.match('^[0-9]{8}$', value):
raise InternalError('Module defines value has invalid format: "%s"' % value)
- def cross_check(self, arch_info, os_info, cc_info):
- for supp_os in self.os:
- if supp_os not in os_info:
- raise InternalError('Module %s mentions unknown OS %s' % (self.infofile, supp_os))
+ def cross_check(self, arch_info, os_info, cc_info, all_os_features):
+
+ for feat in set(flatten([o.split(',') for o in self.os_features])):
+ if feat not in all_os_features:
+ logging.error("Module %s uses an OS feature (%s) which no OS supports", self.infofile, feat)
+
for supp_cc in self.cc:
if supp_cc not in cc_info:
colon_idx = supp_cc.find(':')
@@ -873,8 +875,23 @@ class ModuleInfo(InfoObject):
return True
- def compatible_os(self, os_name):
- return self.os == [] or os_name in self.os
+ def compatible_os(self, os_data, options):
+ if not self.os_features:
+ return True
+
+ def has_all(needed, provided):
+ for n in needed:
+ if n not in provided:
+ return False
+ return True
+
+ provided_features = os_data.enabled_features(options)
+
+ for feature_set in self.os_features:
+ if has_all(feature_set.split(','), provided_features):
+ return True
+
+ return False
def compatible_compiler(self, ccinfo, cc_min_version, arch):
# Check if this compiler supports the flags we need
@@ -1268,7 +1285,6 @@ class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes
['aliases', 'target_features'],
[],
{
- 'os_type': None,
'program_suffix': '',
'obj_suffix': 'o',
'soname_suffix': '',
@@ -1331,7 +1347,6 @@ class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.library_name = lex.library_name
self.man_dir = lex.man_dir
self.obj_suffix = lex.obj_suffix
- self.os_type = lex.os_type
self.program_suffix = lex.program_suffix
self.so_post_link_command = lex.so_post_link_command
self.static_suffix = lex.static_suffix
@@ -1893,7 +1908,6 @@ def create_template_vars(source_paths, build_config, options, modules, cc, arch,
'os_features': osinfo.enabled_features(options),
'os_name': osinfo.basename,
- 'os_type': osinfo.os_type,
'cpu_features': arch.supported_isa_extensions(cc, options),
'house_ecc_curve_defines': house_ecc_curve_macros(options.house_curve),
@@ -1950,10 +1964,11 @@ class ModulesChooser(object):
Determine which modules to load based on options, target, etc
"""
- def __init__(self, modules, module_policy, archinfo, ccinfo, cc_min_version, options):
+ def __init__(self, modules, module_policy, archinfo, osinfo, ccinfo, cc_min_version, options):
self._modules = modules
self._module_policy = module_policy
self._archinfo = archinfo
+ self._osinfo = osinfo
self._ccinfo = ccinfo
self._cc_min_version = cc_min_version
self._options = options
@@ -1968,7 +1983,7 @@ class ModulesChooser(object):
self._modules, self._options.enabled_modules, self._options.disabled_modules)
def _check_usable(self, module, modname):
- if not module.compatible_os(self._options.os):
+ if not module.compatible_os(self._osinfo, self._options):
self._not_using_because['incompatible OS'].add(modname)
return False
elif not module.compatible_compiler(self._ccinfo, self._cc_min_version, self._archinfo.basename):
@@ -2799,7 +2814,7 @@ def validate_options(options, info_os, info_cc, available_module_policies):
def prepare_configure_build(info_modules, source_paths, options,
cc, cc_min_version, arch, osinfo, module_policy):
- loaded_module_names = ModulesChooser(info_modules, module_policy, arch, cc, cc_min_version, options).choose()
+ loaded_module_names = ModulesChooser(info_modules, module_policy, arch, osinfo, cc, cc_min_version, options).choose()
using_mods = [info_modules[modname] for modname in loaded_module_names]
build_config = BuildPaths(source_paths, options, using_mods)
@@ -2969,8 +2984,10 @@ def main(argv):
info_cc = load_build_data_info_files(source_paths, 'compiler info', 'cc', CompilerInfo)
info_module_policies = load_build_data_info_files(source_paths, 'module policy', 'policy', ModulePolicyInfo)
+ all_os_features = set(flatten([o.target_features for o in info_os.values()]))
+
for mod in info_modules.values():
- mod.cross_check(info_arch, info_os, info_cc)
+ mod.cross_check(info_arch, info_os, info_cc, all_os_features)
for policy in info_module_policies.values():
policy.cross_check(info_modules)
diff --git a/doc/os.rst b/doc/os.rst
index f1baa7cde..2d869138b 100644
--- a/doc/os.rst
+++ b/doc/os.rst
@@ -33,25 +33,25 @@ A summary of OS features as defined in ``src/build-data/os``.
.. csv-table::
:header: "Feature", "a", "a", "c", "d", "d", "f", "h", "h", "h", "i", "i", "l", "l", "m", "n", "n", "o", "q", "s", "w", "w"
- "arc4random", " ", " ", " ", "X", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " ", " ", "X", " ", " ", " ", " "
- "clock_gettime", "X", "X", " ", " ", "X", "X", " ", " ", " ", " ", " ", "X", " ", " ", " ", "X", "X", "X", " ", " ", " "
+ "arc4random", " ", " ", " ", "X", "X", "X", " ", " ", " ", " ", "X", " ", " ", " ", " ", "X", "X", " ", " ", " ", " "
+ "clock_gettime", "X", "X", " ", " ", "X", "X", " ", "X", " ", " ", " ", "X", " ", " ", " ", "X", "X", "X", "X", " ", " "
"cryptgenrandom", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " ", " ", "X", " "
"crypto_ng", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X"
- "dlopen", "X", "X", " ", "X", "X", "X", " ", " ", " ", " ", "X", "X", " ", " ", " ", "X", "X", "X", " ", " ", " "
+ "dev_random", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", " ", "X", " ", " ", " ", "X", "X", "X", "X", " ", " "
"explicit_bzero", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " "
"filesystem", "X", "X", "X", "X", "X", "X", "X", "X", "X", " ", "X", "X", "X", "X", " ", "X", "X", "X", "X", "X", "X"
"getauxval", " ", "X", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " ", " ", " ", " ", " ", " "
- "gmtime_r", "X", "X", " ", "X", " ", "X", "X", " ", " ", " ", "X", "X", " ", " ", " ", "X", "X", "X", " ", " ", " "
- "gmtime_s", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", "X"
- "loadlibrary", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " ", " ", "X", "X"
- "posix_mlock", " ", "X", " ", " ", "X", "X", " ", " ", "X", " ", " ", "X", " ", " ", " ", "X", "X", "X", "X", " ", " "
- "query_perf_counter", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", "X"
- "readdir", "X", "X", "X", "X", "X", "X", " ", " ", " ", " ", "X", "X", " ", " ", " ", "X", "X", " ", "X", " ", " "
+ "getentropy", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " "
+ "posix1", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", " ", " ", " ", "X", "X", "X", "X", " ", " "
+ "proc_fs", "X", " ", " ", " ", "X", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " ", " ", " ", "X", " ", " "
"rtlsecurezeromemory", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", "X"
- "sockets", "X", " ", " ", "X", "X", "X", " ", " ", " ", " ", "X", "X", " ", " ", " ", " ", "X", " ", " ", "X", "X"
+ "security_framework", " ", " ", " ", "X", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "
+ "sockets", "X", "X", "X", "X", "X", "X", "X", "X", "X", " ", "X", "X", " ", "X", " ", "X", "X", "X", "X", "X", "X"
"stl_filesystem_msvc", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " "
"threads", "X", "X", "X", "X", "X", "X", "X", "X", "X", " ", "X", "X", " ", "X", "X", "X", "X", "X", "X", "X", "X"
"virtual_lock", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " ", " ", "X", " "
+ "win32", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", " ", " ", " ", " ", " ", "X", "X"
+ "winsock2", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "X", "X"
.. note::
This file is auto generated by ``src/scripts/update_docs.py``. Dont modify it manually.
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in
index d4972af15..9c4879312 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