Improve BSDs support.
This commit is contained in:
committed by
Matthew Parkinson
parent
5419e58633
commit
0377fd88d4
@@ -1,4 +1,5 @@
|
||||
#include "../ds/address.h"
|
||||
#include "../pal/pal.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
|
||||
@@ -25,6 +25,19 @@ namespace snmalloc
|
||||
* to add new features that they should add any required feature flags.
|
||||
*/
|
||||
static constexpr uint64_t pal_features = PALPOSIX::pal_features;
|
||||
|
||||
/**
|
||||
* Source of Entropy
|
||||
*
|
||||
* DragonflyBSD does not have getentropy, so use getrandom instead.
|
||||
*/
|
||||
static uint64_t get_entropy64()
|
||||
{
|
||||
uint64_t result;
|
||||
if (getrandom(&result, sizeof(result), 0) != sizeof(result))
|
||||
error("Failed to get system randomness");
|
||||
return result;
|
||||
}
|
||||
};
|
||||
} // namespace snmalloc
|
||||
#endif
|
||||
|
||||
@@ -22,8 +22,13 @@ namespace snmalloc
|
||||
* generic BSD with support for arbitrary alignment from `mmap`. This
|
||||
* field is declared explicitly to remind anyone modifying this class to
|
||||
* add new features that they should add any required feature flags.
|
||||
*
|
||||
* We disable the default implementation of randomness on NetBSD as it
|
||||
* does not have the getentropy call. This will currently fallback to
|
||||
* C++ libraries std::random_device.
|
||||
*/
|
||||
static constexpr uint64_t pal_features = PALBSD_Aligned::pal_features;
|
||||
static constexpr uint64_t pal_features =
|
||||
PALBSD_Aligned::pal_features & ~Entropy;
|
||||
};
|
||||
} // namespace snmalloc
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user