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

View File

@ -12,17 +12,16 @@
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 device { class file {
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);
@ -34,7 +33,6 @@ namespace cruft::rand {
private: private:
cruft::posix::fd m_fd; cruft::posix::fd m_fd;
}; };
}
using system = linux::device; using system = file;
} }