Common: Provide a MAP_FIXED_NOREPLACE define for FreeBSD

This commit is contained in:
TheLastRar 2024-05-22 01:25:52 +01:00 committed by Connor McLaughlin
parent 19d5d5c485
commit 63a5a15c37
1 changed files with 6 additions and 0 deletions

View File

@ -37,6 +37,12 @@
#define MAP_FIXED_NOREPLACE MAP_FIXED
#endif
// FreeBSD does not have MAP_FIXED_NOREPLACE, but does have MAP_EXCL.
// MAP_FIXED combined with MAP_EXCL behaves like MAP_FIXED_NOREPLACE.
#if defined(__FreeBSD__) && !defined(MAP_FIXED_NOREPLACE)
#define MAP_FIXED_NOREPLACE MAP_FIXED | MAP_EXCL
#endif
#include <cerrno>
#include <fcntl.h>
#include <sys/mman.h>