From 16527634cc9b0092e15d1a1b2a9cf1796817a950 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Marie?= <semarie@users.noreply.github.com>
Date: Mon, 19 Mar 2018 06:02:50 +0100
Subject: [PATCH] Add MAP_STACK constant to OpenBSD

The mmap(2) flag indicate that the mapping is used as a stack.

https://man.openbsd.org/mmap.2#MAP_STACK
https://marc.info/?l=openbsd-tech&m=152035796722258&w=2
---
 libc-test/build.rs                                 | 5 ++++-
 src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libc-test/build.rs b/libc-test/build.rs
index a96bcfd4..0f4efdca 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -526,9 +526,12 @@ fn main() {
             "KERN_USERMOUNT" |
             "KERN_ARND" if openbsd => true,
 
-            // These constats were added in OpenBSD 6.2
+            // These constants were added in OpenBSD 6.2
             "EV_RECEIPT" | "EV_DISPATCH" if openbsd => true,
 
+            // These constants were added in OpenBSD 6.3
+            "MAP_STACK" if openbsd => true,
+
             // These are either unimplemented or optionally built into uClibc
             "LC_CTYPE_MASK" | "LC_NUMERIC_MASK" | "LC_TIME_MASK" | "LC_COLLATE_MASK" | "LC_MONETARY_MASK" | "LC_MESSAGES_MASK" |
             "MADV_MERGEABLE" | "MADV_UNMERGEABLE" | "MADV_HWPOISON" | "IPV6_ADD_MEMBERSHIP" | "IPV6_DROP_MEMBERSHIP" | "IPV6_MULTICAST_LOOP" | "IPV6_V6ONLY" |
diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs
index 0761a188..ede9d85b 100644
--- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs
@@ -27,6 +27,8 @@ s! {
     }
 }
 
+pub const MAP_STACK : ::c_int = 0x4000;
+
 // https://github.com/openbsd/src/blob/master/sys/net/if.h#L187
 pub const IFF_UP: ::c_int = 0x1; // interface is up
 pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
-- 
GitLab