Created pal_consts.h. New exported functions are now prefixed with "snmalloc_".
This commit is contained in:
@@ -4,40 +4,6 @@
|
|||||||
|
|
||||||
namespace snmalloc
|
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),
|
|
||||||
/**
|
|
||||||
* This PAL natively supports allocation with a guaranteed alignment. If
|
|
||||||
* this is not supported, then we will over-allocate and round the
|
|
||||||
* allocation.
|
|
||||||
*
|
|
||||||
* A PAL that does supports this must expose a `request()` method that takes
|
|
||||||
* a size and alignment. A PAL that does *not* support it must expose a
|
|
||||||
* `request()` method that takes only a size.
|
|
||||||
*/
|
|
||||||
AlignedAllocation = (1 << 1)
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ZeroMem
|
|
||||||
{
|
|
||||||
NoZero,
|
|
||||||
YesZero
|
|
||||||
};
|
|
||||||
|
|
||||||
// 0 intermediate bits results in power of 2 small allocs. 1 intermediate
|
// 0 intermediate bits results in power of 2 small allocs. 1 intermediate
|
||||||
// bit gives additional sizeclasses at the midpoint between each power of 2.
|
// bit gives additional sizeclasses at the midpoint between each power of 2.
|
||||||
// 2 intermediate bits gives 3 intermediate sizeclasses, etc.
|
// 2 intermediate bits gives 3 intermediate sizeclasses, etc.
|
||||||
|
|||||||
@@ -205,16 +205,20 @@ extern "C"
|
|||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNMALLOC_EXPORT void* SNMALLOC_NAME_MANGLE(get_global_pagemap)(void)
|
#ifdef SNMALLOC_EXPOSE_PAGEMAP
|
||||||
|
SNMALLOC_EXPORT void* SNMALLOC_NAME_MANGLE(snmalloc_get_global_pagemap)(void)
|
||||||
{
|
{
|
||||||
return &snmalloc::global_pagemap;
|
return &snmalloc::global_pagemap;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SNMALLOC_EXPOSE_RESERVE
|
||||||
SNMALLOC_EXPORT void*
|
SNMALLOC_EXPORT void*
|
||||||
SNMALLOC_NAME_MANGLE(reserve_shared)(size_t* size, size_t align)
|
SNMALLOC_NAME_MANGLE(snmalloc_reserve_shared)(size_t* size, size_t align)
|
||||||
{
|
{
|
||||||
return snmalloc::default_memory_provider.reserve<true>(size, align);
|
return snmalloc::default_memory_provider.reserve<true>(size, align);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(__PIC__) && !defined(NO_BOOTSTRAP_ALLOCATOR)
|
#if !defined(__PIC__) && !defined(NO_BOOTSTRAP_ALLOCATOR)
|
||||||
// The following functions are required to work before TLS is set up, in
|
// The following functions are required to work before TLS is set up, in
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "pal_consts.h"
|
||||||
|
|
||||||
|
namespace snmalloc
|
||||||
|
{
|
||||||
|
void error(const char* const str);
|
||||||
|
}
|
||||||
|
|
||||||
// If simultating OE, then we need the underlying platform
|
// If simultating OE, then we need the underlying platform
|
||||||
#if !defined(OPEN_ENCLAVE) || defined(OPEN_ENCLAVE_SIMULATION)
|
#if !defined(OPEN_ENCLAVE) || defined(OPEN_ENCLAVE_SIMULATION)
|
||||||
# include "pal_apple.h"
|
# include "pal_apple.h"
|
||||||
|
|||||||
34
src/pal/pal_consts.h
Normal file
34
src/pal/pal_consts.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
namespace snmalloc
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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),
|
||||||
|
/**
|
||||||
|
* This PAL natively supports allocation with a guaranteed alignment. If
|
||||||
|
* this is not supported, then we will over-allocate and round the
|
||||||
|
* allocation.
|
||||||
|
*
|
||||||
|
* A PAL that does supports this must expose a `request()` method that takes
|
||||||
|
* a size and alignment. A PAL that does *not* support it must expose a
|
||||||
|
* `request()` method that takes only a size.
|
||||||
|
*/
|
||||||
|
AlignedAllocation = (1 << 1)
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ZeroMem
|
||||||
|
{
|
||||||
|
NoZero,
|
||||||
|
YesZero
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user