From 15601e09a327277a316b781d7a11f1055b2dcc49 Mon Sep 17 00:00:00 2001
From: Sergey Bronnikov <sergeyb@tarantool.org>
Date: Thu, 23 Apr 2020 23:02:27 +0300
Subject: [PATCH] Fix building of tt_pthread_attr_getstack() on OpenBSD

Part of #4967
---
 src/tt_pthread.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/tt_pthread.h b/src/tt_pthread.h
index 6bb19eb23c..70f6050912 100644
--- a/src/tt_pthread.h
+++ b/src/tt_pthread.h
@@ -37,9 +37,13 @@
 #include <stdio.h>
 #include <errno.h>
 #include <pthread.h>
-#if HAVE_PTHREAD_NP_H
+#if HAVE_PTHREAD_NP_H || (__OpenBSD__)
 #include <pthread_np.h>
 #endif
+#if (__OpenBSD__)
+#include <signal.h>
+#include <sys/signal.h>
+#endif
 #include "say.h"
 
 /**
@@ -358,6 +362,11 @@ tt_pthread_attr_getstack(pthread_t thread, void **stackaddr, size_t *stacksize)
 	/* Old macOS */
 	*stacksize = pthread_get_stacksize_np(thread);
 	*stackaddr = pthread_get_stackaddr_np(thread);
+#elif (__OpenBSD__)
+	stack_t *sinfo = (stack_t*)malloc(sizeof(stack_t));
+	pthread_stackseg_np(thread, sinfo);
+	*stacksize = sinfo->ss_size;
+	*stackaddr = sinfo->ss_sp;
 #else
 #error Unable to get thread stack
 #endif
-- 
GitLab