forked from microsoft/snmalloc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpal_haiku.h
41 lines (36 loc) · 1007 Bytes
/
pal_haiku.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#if defined(__HAIKU__)
# include "pal_posix.h"
# include <sys/mman.h>
namespace snmalloc
{
/**
* Platform abstraction layer for Haiku. This provides features for this
* system.
*/
class PALHaiku : public PALPOSIX<PALHaiku>
{
public:
/**
* Bitmap of PalFeatures flags indicating the optional features that this
* PAL supports.
*
*/
static constexpr uint64_t pal_features = PALPOSIX::pal_features;
/**
* Haiku requires an explicit no-reserve flag in `mmap` to guarantee lazy
* commit.
*/
static constexpr int default_mmap_flags = MAP_NORESERVE;
/**
* Notify platform that we will not be needing these pages.
* Haiku does not provide madvise call per say only the posix equivalent.
*/
void notify_not_using(void* p, size_t size) noexcept
{
SNMALLOC_ASSERT(is_aligned_block<page_size>(p, size));
posix_madvise(p, size, POSIX_MADV_DONTNEED);
}
};
} // namespace snmalloc
#endif