rand/system_linux: avoid the 'linux' symbol as it's a platform define

This commit is contained in:
Danny Robson 2019-06-29 08:18:59 +10:00
parent 0df4fd4bfa
commit 2089893124
2 changed files with 23 additions and 25 deletions

View File

@ -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;

View File

@ -12,17 +12,16 @@
namespace cruft::rand {
namespace linux {
/// Models std::random_device and is suitable as a drop-in replacement.
class device {
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);
@ -34,7 +33,6 @@ namespace cruft::rand {
private:
cruft::posix::fd m_fd;
};
}
using system = linux::device;
using system = file;
}