From c6197cb5f2f61cb9de6c9796bfa66971cd01922e Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 8 Jul 2020 15:35:28 +0100 Subject: [PATCH] Illumos systems/Solaris support. (#226) MAP_NORESERVE flag usage for memory over commit permitted only in the mmap context. --- src/pal/pal.h | 3 +++ src/pal/pal_posix.h | 1 + src/pal/pal_solaris.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/pal/pal_solaris.h diff --git a/src/pal/pal.h b/src/pal/pal.h index 64e7f33..47f30e0 100644 --- a/src/pal/pal.h +++ b/src/pal/pal.h @@ -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 diff --git a/src/pal/pal_posix.h b/src/pal/pal_posix.h index cb25acc..bab9835 100644 --- a/src/pal/pal_posix.h +++ b/src/pal/pal_posix.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/src/pal/pal_solaris.h b/src/pal/pal_solaris.h new file mode 100644 index 0000000..5965760 --- /dev/null +++ b/src/pal/pal_solaris.h @@ -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 + { + 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