rand/system_linux: avoid the 'linux' symbol as it's a platform define
This commit is contained in:
parent
0df4fd4bfa
commit
2089893124
@ -15,7 +15,7 @@
|
||||
#include <linux/random.h>
|
||||
|
||||
|
||||
using cruft::rand::linux::device;
|
||||
using cruft::rand::file;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -27,20 +27,20 @@ static std::string const& default_source (void)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
device::device ():
|
||||
device (default_source ())
|
||||
file::file ():
|
||||
file (default_source ())
|
||||
{ ; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
device::device (std::string const &token)
|
||||
file::file (std::string const &token)
|
||||
: m_fd (token, O_RDONLY | O_BINARY)
|
||||
{ ; }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
device::result_type
|
||||
device::operator() (void)
|
||||
file::result_type
|
||||
file::operator() (void)
|
||||
{
|
||||
result_type res;
|
||||
cruft::read (m_fd, cruft::make_byte_view<u08> (res));
|
||||
@ -50,7 +50,7 @@ device::operator() (void)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
double
|
||||
device::entropy () const noexcept
|
||||
file::entropy () const noexcept
|
||||
{
|
||||
int val;
|
||||
|
||||
|
@ -12,29 +12,27 @@
|
||||
|
||||
|
||||
namespace cruft::rand {
|
||||
namespace linux {
|
||||
/// Models std::random_device and is suitable as a drop-in replacement.
|
||||
class device {
|
||||
public:
|
||||
using result_type = unsigned;
|
||||
/// Models std::random_device and is suitable as a drop-in replacement.
|
||||
class file {
|
||||
public:
|
||||
using result_type = unsigned;
|
||||
|
||||
device ();
|
||||
device (std::string const&);
|
||||
device (device const &) = delete;
|
||||
file ();
|
||||
file (std::string const&);
|
||||
file (file const &) = delete;
|
||||
|
||||
device& operator= (device const&) = delete;
|
||||
file& operator= (file const&) = delete;
|
||||
|
||||
result_type operator() (void);
|
||||
result_type operator() (void);
|
||||
|
||||
double entropy (void) const noexcept;
|
||||
double entropy (void) const noexcept;
|
||||
|
||||
static constexpr result_type min (void) { return std::numeric_limits<result_type>::min (); }
|
||||
static constexpr result_type max (void) { return std::numeric_limits<result_type>::max (); }
|
||||
static constexpr result_type min (void) { return std::numeric_limits<result_type>::min (); }
|
||||
static constexpr result_type max (void) { return std::numeric_limits<result_type>::max (); }
|
||||
|
||||
private:
|
||||
cruft::posix::fd m_fd;
|
||||
};
|
||||
}
|
||||
private:
|
||||
cruft::posix::fd m_fd;
|
||||
};
|
||||
|
||||
using system = linux::device;
|
||||
using system = file;
|
||||
}
|
Loading…
Reference in New Issue
Block a user