Illumos systems/Solaris support. (#226)

MAP_NORESERVE flag usage for memory over commit permitted only
 in the mmap context.
This commit is contained in:
David CARLIER
2020-07-08 15:35:28 +01:00
committed by GitHub
parent 5ebda5288d
commit c6197cb5f2
3 changed files with 33 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
# include "pal_linux.h"
# include "pal_netbsd.h"
# include "pal_openbsd.h"
# include "pal_solaris.h"
# include "pal_windows.h"
#endif
#include "pal_plain.h"
@@ -38,6 +39,8 @@ namespace snmalloc
PALNetBSD;
# elif defined(__OpenBSD__)
PALOpenBSD;
# elif defined(__sun)
PALSolaris;
# else
# error Unsupported platform
# endif

View File

@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/mman.h>
#include <unistd.h>
#include <utility>

29
src/pal/pal_solaris.h Normal file
View File

@@ -0,0 +1,29 @@
#pragma once
#if defined(__sun)
# include "pal_posix.h"
namespace snmalloc
{
/**
* Platform abstraction layer for Solaris. This provides features for this
* system.
*/
class PALSolaris : public PALPOSIX<PALSolaris>
{
public:
/**
* Bitmap of PalFeatures flags indicating the optional features that this
* PAL supports.
*
*/
static constexpr uint64_t pal_features = PALPOSIX::pal_features;
/**
* Solaris requires an explicit no-reserve flag in `mmap` to guarantee lazy
* commit.
*/
static constexpr int default_mmap_flags = MAP_NORESERVE;
};
} // namespace snmalloc
#endif