$OpenBSD: patch-runtime_flangrti_trace_lin_c,v 1.4 2020/07/12 18:06:48 bcallah Exp $

We don't have sys/ucontext.h
No gregset_t, make them void
Remove the /proc dance they need for Linux

Index: runtime/flangrti/trace_lin.c
--- runtime/flangrti/trace_lin.c.orig
+++ runtime/flangrti/trace_lin.c
@@ -7,7 +7,9 @@
 
 #include <stdint.h>
 #include <signal.h>
+#if !defined(__OpenBSD__)
 #include <sys/ucontext.h>
+#endif
 #include <execinfo.h>
 #include <stdioInterf.h>
 #include "dumpregs.h"
@@ -15,7 +17,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <linux/limits.h>
+#include <limits.h>
 #include <inttypes.h>
 
 /* codes and strings for signals */
@@ -82,7 +84,7 @@ static struct sigs sigs[] = {
     {0, CODNULL, NULL} /* end of list */
 };
 
-static gregset_t *regs; /* pointer to regs at signal  */
+static void *regs; /* pointer to regs at signal  */
 
 extern char **__io_get_argv();
 static char ** saved_argv = NULL;
@@ -105,6 +107,7 @@ print_back_trace_line(char * bt_str, void const * cons
     saved_argv = __io_get_argv();
   }
 
+#ifndef __OpenBSD__
   if (NULL == saved_argv) {
     /*
      * Most likely a C program where __io_set_argv() was not called on startup.
@@ -133,6 +136,7 @@ print_back_trace_line(char * bt_str, void const * cons
     fclose(f);
     saved_argv = &pexec_name;
   }
+#endif
 
   sprintf(addr2line_cmd,"addr2line -e %s %p", saved_argv[0], addr);
 
@@ -172,7 +176,7 @@ __abort_trace(int skip)
   char **strings;
   size_t i;
 
-  if (regs != (gregset_t *)0) {
+  if (regs != (void *)0) {
     dumpregs(regs);
   }
 
