File indexing completed on 2025-12-13 10:07:21
0001 #ifndef BOOST_UUID_DETAIL_RANDOM_DEVICE_HPP_INCLUDED
0002 #define BOOST_UUID_DETAIL_RANDOM_DEVICE_HPP_INCLUDED
0003
0004
0005
0006
0007
0008 #if defined(__MINGW32__)
0009
0010
0011
0012
0013
0014 #include <boost/throw_exception.hpp>
0015 #include <system_error>
0016 #include <limits>
0017 #include <stdlib.h>
0018
0019 extern "C" int __cdecl rand_s( unsigned int *randomValue );
0020
0021 namespace boost {
0022 namespace uuids {
0023 namespace detail {
0024
0025 struct random_device
0026 {
0027
0028 random_device() = default;
0029 random_device( random_device&& ) = delete;
0030 random_device& operator=( random_device&& ) = delete;
0031
0032 using result_type = unsigned;
0033
0034 static constexpr result_type min()
0035 {
0036 return std::numeric_limits<result_type>::min();
0037 }
0038
0039 static constexpr result_type max()
0040 {
0041 return std::numeric_limits<result_type>::max();
0042 }
0043
0044 result_type operator()()
0045 {
0046 unsigned v;
0047
0048 auto r = rand_s( &v );
0049
0050 if( r != 0 )
0051 {
0052 BOOST_THROW_EXCEPTION( std::system_error( r, std::generic_category(), "rand_s" ) );
0053 }
0054
0055 return v;
0056 }
0057 };
0058
0059 }
0060 }
0061 }
0062
0063 #else
0064
0065 #include <random>
0066
0067 namespace boost {
0068 namespace uuids {
0069 namespace detail {
0070
0071 using std::random_device;
0072
0073 }
0074 }
0075 }
0076
0077 #endif
0078
0079 #endif