The 0xf I think was copied from the Linux headers a long time ago, since
BSD doesn't define this. In FreeBSD, there's only two bits of this low
nibble that are used for the sharing type (linux has 2 more types
encoded in these low bits). The kernel rejects bogus flags (0xc part of
0xf mask), so it's better to have just these two bits here.

Signed-off-by: Warner Losh <[email protected]>
---
 bsd-user/syscall_defs.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index 506aea3e27..c4fd5f5589 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -121,7 +121,14 @@ struct target_msgbuf {
 /*
  *  sys/mman.h
  */
-#define MAP_TYPE                        0xf
+/*
+ * FreeBSD doesn't define this, but Linux does. In Linux, it's only MAP_PRIVATE
+ * and MAP_SHARED and a few Linux-specific types (0xf). FreeBSD allows other
+ * types of mapping with MAP_ANON, MAP_GUARD, and MAP_STACK. The mask on Linux
+ * excludes these: They don't have MAP_GUARD, and MAP_STACK and MAP_ANON have
+ * similar flags with different names that aren't in it's 0xf MAP_TYPE.
+ */
+#define MAP_TYPE (MAP_PRIVATE | MAP_SHARED)
 
 /*
  * sys/time.h

-- 
2.55.0


Reply via email to