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>
|
#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 ():
|
file::file ():
|
||||||
device (default_source ())
|
file (default_source ())
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
device::device (std::string const &token)
|
file::file (std::string const &token)
|
||||||
: m_fd (token, O_RDONLY | O_BINARY)
|
: m_fd (token, O_RDONLY | O_BINARY)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
device::result_type
|
file::result_type
|
||||||
device::operator() (void)
|
file::operator() (void)
|
||||||
{
|
{
|
||||||
result_type res;
|
result_type res;
|
||||||
cruft::read (m_fd, cruft::make_byte_view<u08> (res));
|
cruft::read (m_fd, cruft::make_byte_view<u08> (res));
|
||||||
@ -50,7 +50,7 @@ device::operator() (void)
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
double
|
double
|
||||||
device::entropy () const noexcept
|
file::entropy () const noexcept
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
|
@ -12,29 +12,27 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace cruft::rand {
|
namespace cruft::rand {
|
||||||
namespace linux {
|
/// Models std::random_device and is suitable as a drop-in replacement.
|
||||||
/// Models std::random_device and is suitable as a drop-in replacement.
|
class file {
|
||||||
class device {
|
public:
|
||||||
public:
|
using result_type = unsigned;
|
||||||
using result_type = unsigned;
|
|
||||||
|
|
||||||
device ();
|
file ();
|
||||||
device (std::string const&);
|
file (std::string const&);
|
||||||
device (device const &) = delete;
|
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 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 max (void) { return std::numeric_limits<result_type>::max (); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cruft::posix::fd m_fd;
|
cruft::posix::fd m_fd;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
using system = linux::device;
|
using system = file;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user