Provide a generic PAL feature detection mechanism.
We can support up to 64 optional features, currently only one is used.
This commit is contained in:
committed by
David Chisnall
parent
80630a359f
commit
a24e6270cc
@@ -3,6 +3,23 @@
|
||||
namespace snmalloc
|
||||
{
|
||||
void error(const char* const str);
|
||||
|
||||
/**
|
||||
* Flags in a bitfield of optional features that a PAL may support. These
|
||||
* should be set in the PAL's `pal_features` static constexpr field.
|
||||
*/
|
||||
enum PalFeatures : uint64_t
|
||||
{
|
||||
/**
|
||||
* This PAL supports low memory notifications. It must implement a
|
||||
* `low_memory_epoch` method that returns a `uint64_t` of the number of
|
||||
* times that a low-memory notification has been raised and an
|
||||
* `expensive_low_memory_check()` method that returns a `bool` indicating
|
||||
* whether low memory conditions are still in effect.
|
||||
*/
|
||||
LowMemoryNotification = (1 << 0)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// If simultating OE, then we need the underlying platform
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace snmalloc
|
||||
|
||||
public:
|
||||
/**
|
||||
* Flag indicating that this PAL does not support low pressure
|
||||
* notifications.
|
||||
* Bitmap of PalFeatures flags indicating the optional features that this
|
||||
* PAL supports.
|
||||
*/
|
||||
static constexpr bool supports_low_memory_notification = false;
|
||||
static constexpr uint64_t pal_features = 0;
|
||||
void error(const char* const str)
|
||||
{
|
||||
panic("snmalloc error: %s", str);
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace snmalloc
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Flag indicating that this PAL does not support low pressure
|
||||
* notifications.
|
||||
* Bitmap of PalFeatures flags indicating the optional features that this
|
||||
* PAL supports.
|
||||
*/
|
||||
static constexpr bool supports_low_memory_notification = false;
|
||||
static constexpr uint64_t pal_features = 0;
|
||||
static void error(const char* const str)
|
||||
{
|
||||
puts(str);
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace snmalloc
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Flag indicating that this PAL does not support low pressure
|
||||
* notifications.
|
||||
* Bitmap of PalFeatures flags indicating the optional features that this
|
||||
* PAL supports.
|
||||
*/
|
||||
static constexpr bool supports_low_memory_notification = false;
|
||||
static constexpr uint64_t pal_features = 0;
|
||||
static void error(const char* const str)
|
||||
{
|
||||
puts(str);
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace snmalloc
|
||||
|
||||
public:
|
||||
/**
|
||||
* Flag indicating that this PAL does not support low pressure
|
||||
* notifications.
|
||||
* Bitmap of PalFeatures flags indicating the optional features that this
|
||||
* PAL supports.
|
||||
*/
|
||||
static constexpr bool supports_low_memory_notification = false;
|
||||
static constexpr uint64_t pal_features = 0;
|
||||
static void error(const char* const str)
|
||||
{
|
||||
UNUSED(str);
|
||||
|
||||
@@ -65,9 +65,10 @@ namespace snmalloc
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Flag indicating that this PAL supports the low pressure notification.
|
||||
* Bitmap of PalFeatures flags indicating the optional features that this
|
||||
* PAL supports. This PAL supports low-memory notifications.
|
||||
*/
|
||||
static constexpr bool supports_low_memory_notification = true;
|
||||
static constexpr uint64_t pal_features = LowMemoryNotification;
|
||||
/**
|
||||
* Counter values for the number of times that a low-pressure notification
|
||||
* has been delivered. Callers should compare this with a previous value
|
||||
|
||||
Reference in New Issue
Block a user