$OpenBSD$
--- src/boehm-gc/os_dep.c.orig	Mon Feb 13 18:14:20 2006
+++ src/boehm-gc/os_dep.c	Tue Jun 27 12:28:21 2006
@@ -93,7 +93,7 @@
 #  endif
 #endif
 
-#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__) \
+#if defined(NETBSD)  && defined(__ELF__) \
     && !defined(NEED_FIND_LIMIT)
    /* Used by GC_init_netbsd_elf() below.	*/
 #  define NEED_FIND_LIMIT
@@ -382,7 +382,7 @@ static void *tiny_sbrk(ptrdiff_t increme
 #define sbrk tiny_sbrk
 # endif /* ECOS */
 
-#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
+#if defined(NETBSD) && defined(__ELF__)
   ptr_t GC_data_start;
 
   void GC_init_netbsd_elf()
@@ -395,6 +395,46 @@ static void *tiny_sbrk(ptrdiff_t increme
   }
 #endif
 
+
+#if defined(OPENBSD)
+#undef	OPENBSD_USING_INTERNAL_FINDLIMIT		/* use boehm-gc find-limit tools */
+#undef	OPENBSD_USING_EXTERNAL_FINDLIMIT	/* use external find-limit tools */
+#endif
+
+#define	OPENBSD_USING_INTERNAL_FINDLIMIT
+
+
+#if defined(OPENBSD) && defined(OPENBSD_USING_INTERNAL_FINDLIMIT)
+
+/* GC_init_openbsd_elf **************************************************
+
+ This would be the simple way, except it does not work
+
+ ************************************************************************/
+
+extern ptr_t GC_stackbottom;
+
+ptr_t GC_data_start;
+
+void GC_init_openbsd_elf()
+{
+	int dummy = 0;
+    extern ptr_t GC_find_limit();
+
+	GC_data_start = GC_find_limit( (ptr_t) &end, FALSE);
+	GC_stackbottom = GC_find_limit( (ptr_t) &dummy, TRUE);
+
+#ifdef DEBUG_THREADS
+	GC_printf1("openbsd GC_data_start: %p\n", GC_data_start );
+	GC_printf1("openbsd GC_data_end:   %p\n", (void*) &end );
+	GC_printf1("openbsd GC_stackbottom: %p\n", GC_stackbottom );
+#endif
+
+}
+#endif
+
+
+
 # ifdef OS2
 
 # include <stddef.h>
@@ -535,6 +575,11 @@ static SIGSET_T dummy;
 
 void GC_disable_signals()
 {
+
+#if !defined(NO_DEBUGGING)
+	GC_printf0("GC_disable_signals: enter\n");
+#endif
+
     if (!mask_initialized) {
     	SIG_FILL(new_mask);
 
@@ -558,17 +603,36 @@ void GC_disable_signals()
 #   ifdef CHECK_SIGNALS
 	if (GC_sig_disabled != 0) ABORT("Nested disables");
 	GC_sig_disabled++;
+#	else
+#	warning not checking signal disenabling/enabling
 #   endif
     SIGSETMASK(old_mask,new_mask);
+
+#if !defined(NO_DEBUGGING)
+	GC_printf0("GC_disable_signals: leave\n");
+#endif
+
 }
 
 void GC_enable_signals()
 {
+
+#if !defined(NO_DEBUGGING)
+	GC_printf0("GC_enable_signals: enter\n");
+#endif
+
 #   ifdef CHECK_SIGNALS
 	if (GC_sig_disabled != 1) ABORT("Unmatched enable");
 	GC_sig_disabled--;
+#	else
+#	warning not checking signal disabling/enabling
 #   endif
     SIGSETMASK(dummy,old_mask);
+
+#if !defined(NO_DEBUGGING)
+	GC_printf0("GC_enable_signals: leave\n");
+#endif
+
 }
 
 #  endif  /* !PCR */
@@ -684,6 +748,15 @@ ptr_t GC_get_stack_base()
 #   undef GC_AMIGA_SB
 # endif /* AMIGA */
 
+# if defined(OPENBSD) && defined(OPENBSD_USING_EXTERNAL_FINDLIMIT)
+/* these macros are not needed beyond this point */
+/* OpenBSD would be normally considered to be "unix like" */
+/* The "find limit" tools have some issues */
+# undef UNIX_LIKE
+# undef NEED_FIND_LIMIT
+# include "openbsd.c"
+# endif
+
 # if defined(NEED_FIND_LIMIT) || defined(UNIX_LIKE)
 
 #   ifdef __STDC__
@@ -693,10 +766,10 @@ ptr_t GC_get_stack_base()
 #   endif
 
 #   if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \
-    || defined(HURD) || defined(NETBSD)
+    || defined(HURD) || defined(NETBSD)	|| defined(OPENBSD)
 	static struct sigaction old_segv_act;
 #	if defined(IRIX5) || defined(HPUX) \
-	|| defined(HURD) || defined(NETBSD)
+	|| defined(HURD) || defined(NETBSD) || defined(OPENBSD)
 	    static struct sigaction old_bus_act;
 #	endif
 #   else
@@ -711,7 +784,7 @@ ptr_t GC_get_stack_base()
 #   endif
     {
 #	if defined(SUNOS5SIGS) || defined(IRIX5)  \
-        || defined(OSF1) || defined(HURD) || defined(NETBSD)
+        || defined(OSF1) || defined(HURD) || defined(NETBSD) || defined(OPENBSD)
 	  struct sigaction	act;
 
 	  act.sa_handler	= h;
@@ -719,7 +792,13 @@ ptr_t GC_get_stack_base()
 	       /* NetBSD bugs.						*/
             act.sa_flags          = SA_RESTART | SA_NODEFER;
 #         else
-            act.sa_flags          = SA_RESTART;
+            act.sa_flags = 
+#if defined(OPENBSD)
+				SA_ONSTACK | SA_NODEFER
+#else
+					SA_RESTART
+#endif
+			;
 #	  endif
 
 	  (void) sigemptyset(&act.sa_mask);
@@ -769,10 +848,10 @@ ptr_t GC_get_stack_base()
     void GC_reset_fault_handler()
     {
 #       if defined(SUNOS5SIGS) || defined(IRIX5) \
-	   || defined(OSF1) || defined(HURD) || defined(NETBSD)
+	   || defined(OSF1) || defined(HURD) || defined(NETBSD) || defined(OPENBSD)
 	  (void) sigaction(SIGSEGV, &old_segv_act, 0);
 #	  if defined(IRIX5) \
-	     || defined(HPUX) || defined(HURD) || defined(NETBSD)
+	     || defined(HPUX) || defined(HURD) || defined(NETBSD) || defined(OPENBSD)
 	      (void) sigaction(SIGBUS, &old_bus_act, 0);
 #	  endif
 #       else
@@ -803,11 +882,11 @@ ptr_t GC_get_stack_base()
 			      & ~(MIN_PAGE_SIZE-1));
 	    for (;;) {
  	        if (up) {
-		    result += MIN_PAGE_SIZE;
+		   	 result += MIN_PAGE_SIZE;
  	        } else {
-		    result -= MIN_PAGE_SIZE;
+		     result -= MIN_PAGE_SIZE;
  	        }
-		GC_noop1((word)(*result));
+			GC_noop1((word)(*result));
 	    }
 	}
 	GC_reset_fault_handler();
