Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to CloudABI. #20

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/random_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,29 @@ class boost::random::random_device::impl
const std::string provider;
};

#elif defined(__CloudABI__)

#include <stdlib.h>

namespace {
const char * const default_token = "";
}

// CloudABI does not provide access to the global filesystem namespace.
// The only way to obtain random data is by calling arcrandom_buf().

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant "arc4random_buf" instead. I.e. with the 4 included.

class boost::random::random_device::impl
{
public:
impl(const std::string & token) {}
~impl() {}

unsigned int next() {
unsigned int result;
arc4random_buf(&result, sizeof(result));
return result;
}
};

#else

namespace {
Expand Down