From 45e7b8bef403dc01abe0243a2bc049060a6f4483 Mon Sep 17 00:00:00 2001
From: Greg V <greg@unrelenting.technology>
Date: Sun, 29 Dec 2019 23:18:53 +0000
Subject: [PATCH] FreeBSD: fix SIGSTKSZ on arm/aarch64 / add MINSIGSTKSZ

---
 src/unix/bsd/freebsdlike/freebsd/aarch64.rs    | 1 +
 src/unix/bsd/freebsdlike/freebsd/arm.rs        | 1 +
 src/unix/bsd/freebsdlike/freebsd/mod.rs        | 4 ++--
 src/unix/bsd/freebsdlike/freebsd/powerpc64.rs  | 1 +
 src/unix/bsd/freebsdlike/freebsd/x86.rs        | 1 +
 src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 1 +
 6 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
index 2ac6d4fb..7138c86b 100644
--- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs
@@ -16,3 +16,4 @@ cfg_if! {
 }
 
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs
index b7480aa7..e49de8ad 100644
--- a/src/unix/bsd/freebsdlike/freebsd/arm.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs
@@ -45,3 +45,4 @@ cfg_if! {
     }
 }
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index bd626754..1e7f1566 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -323,9 +323,9 @@ pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
 pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
 
 pub const RAND_MAX: ::c_int = 0x7fff_fffd;
-pub const PTHREAD_STACK_MIN: ::size_t = 2048;
+pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ;
 pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
-pub const SIGSTKSZ: ::size_t = 34816;
+pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + 32768;
 pub const SF_NODISKIO: ::c_int = 0x00000001;
 pub const SF_MNOWAIT: ::c_int = 0x00000002;
 pub const SF_SYNC: ::c_int = 0x00000004;
diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
index 5c0c6e7f..39b38a56 100644
--- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
@@ -42,3 +42,4 @@ cfg_if! {
 }
 
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs
index adec88cb..8fee4344 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs
@@ -41,3 +41,4 @@ cfg_if! {
         pub const _ALIGNBYTES: usize = 8 - 1;
     }
 }
+pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
index ff8f9a9d..6049c1a8 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
@@ -185,6 +185,7 @@ cfg_if! {
     }
 }
 pub const MAP_32BIT: ::c_int = 0x00080000;
+pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4
 
 cfg_if! {
     if #[cfg(libc_align)] {
-- 
GitLab