Add a NetBSD PAL.

Currently untested, but identical to the FreeBSD one so should work...
The NetBSD man pages for `madvise` and `mmap` mention the flags that we
use.
This commit is contained in:
David Chisnall
2019-08-01 11:41:08 +01:00
parent fd88b8464b
commit 2b44b6b5ea
2 changed files with 32 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ namespace snmalloc
# include "pal_free_bsd_kernel.h"
# include "pal_freebsd.h"
# include "pal_linux.h"
# include "pal_netbsd.h"
# include "pal_openbsd.h"
# include "pal_windows.h"
#endif
@@ -33,6 +34,8 @@ namespace snmalloc
PALFreeBSDKernel;
# elif defined(__FreeBSD__)
PALFBSD;
# elif defined(__NetBSD__)
PALNetBSD;
# elif defined(__OpenBSD__)
PALOBSD;
# else

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

@@ -0,0 +1,29 @@
#pragma once
#ifdef __NetBSD__
# include "pal_bsd_aligned.h"
namespace snmalloc
{
/**
* NetBSD-specific platform abstraction layer.
*
* This adds NetBSD-specific aligned allocation to the generic BSD
* implementation.
*/
class PALNetBSD : public PALBSD_Aligned<PALFBSD>
{
public:
/**
* Bitmap of PalFeatures flags indicating the optional features that this
* PAL supports.
*
* The NetBSD PAL does not currently add any features beyond those of a
* generic BSD with support for arbitrary alignment from `mmap`. This
* field is declared explicitly to remind anyone modifying this class to
* add new features that they should add any required feature flags.
*/
static constexpr uint64_t pal_features = PALBSD_Aligned::pal_features;
};
} // namespace snmalloc
#endif