From 11b4f29a3ac806752f8de43d37ca2b3533b7807e Mon Sep 17 00:00:00 2001
From: ljrittle <ljrittle@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 22 Mar 2002 02:40:32 +0000
Subject: [PATCH] 	* include/private/gcconfig.h: Add unified test for
 FreeBSD. 	Support FreeBSD/alpha. 	* os_dep.c: Do not include
 <machine/trap.h> unless available. 	(GC_freebsd_stack_base): Fix types.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51159 138bc75d-0d04-0410-961f-82ee72b054a4
---
 boehm-gc/ChangeLog                  |  7 +++++++
 boehm-gc/include/private/gcconfig.h | 30 ++++++++++++++++++++++++++---
 boehm-gc/os_dep.c                   | 12 ++++++------
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog
index c0b897ca72c2..5f1c1e121bcf 100644
--- a/boehm-gc/ChangeLog
+++ b/boehm-gc/ChangeLog
@@ -1,3 +1,10 @@
+2002-03-21  Loren J. Rittle  <ljrittle@acm.org>
+
+	* include/private/gcconfig.h: Add unified test for FreeBSD.
+	Support FreeBSD/alpha.
+	* os_dep.c: Do not include <machine/trap.h> unless available.
+	(GC_freebsd_stack_base): Fix types.
+
 2002-03-17  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
 
 	* Makefile.am: Make a convenience library.
diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h
index e06cc4abc569..14aa8cb2edb0 100644
--- a/boehm-gc/include/private/gcconfig.h
+++ b/boehm-gc/include/private/gcconfig.h
@@ -38,6 +38,11 @@
 #    define OPENBSD
 # endif
 
+/* And one for FreeBSD: */
+# if defined(__FreeBSD__)
+#    define FREEBSD
+# endif
+
 /* Determine the machine type: */
 # if defined(__XSCALE__)
 #    define ARM32
@@ -214,7 +219,7 @@
 # endif
 # if defined(__alpha) || defined(__alpha__)
 #   define ALPHA
-#   if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD)
+#   if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
 #     define OSF1	/* a.k.a Digital Unix */
 #   endif
 #   define mach_type_known
@@ -262,9 +267,8 @@
 #   define OPENBSD
 #   define mach_type_known
 # endif
-# if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
+# if defined(FREEBSD) && (defined(i386) || defined(__i386__))
 #   define I386
-#   define FREEBSD
 #   define mach_type_known
 # endif
 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
@@ -1330,6 +1334,26 @@
 #   	   define DATASTART ((ptr_t) 0x140000000)
 #   	endif
 #   endif
+#   ifdef FREEBSD
+#	define OS_TYPE "FREEBSD"
+/* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
+#	define SIG_SUSPEND SIGUSR1
+#	define SIG_THR_RESTART SIGUSR2
+#	define FREEBSD_STACKBOTTOM
+#	ifdef __ELF__
+#	    define DYNAMIC_LOADING
+#	endif
+/* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
+	extern char etext;
+	extern char edata;
+	extern char end;
+#	define NEED_FIND_LIMIT
+#	define DATASTART ((ptr_t)(&etext))
+#	define DATAEND (GC_find_limit (DATASTART, TRUE))
+#	define DATASTART2 ((ptr_t)(&edata))
+#	define DATAEND2 ((ptr_t)(&end))
+#	define CPP_WORDSZ 64
+#   endif
 #   ifdef OSF1
 #	define OS_TYPE "OSF1"
 #   	define DATASTART ((ptr_t) 0x140000000)
diff --git a/boehm-gc/os_dep.c b/boehm-gc/os_dep.c
index b8f4cf84c3c3..88194fe82db7 100644
--- a/boehm-gc/os_dep.c
+++ b/boehm-gc/os_dep.c
@@ -84,7 +84,7 @@
 #   include <setjmp.h>
 #endif
 
-#ifdef FREEBSD
+#if defined(FREEBSD) && defined(I386)
 #  include <machine/trap.h>
 #endif
 
@@ -747,14 +747,14 @@ ptr_t GC_get_stack_base()
 
   ptr_t GC_freebsd_stack_base(void)
   {
-    int nm[2] = { CTL_KERN, KERN_USRSTACK}, base, len, r;
-    
-    len = sizeof(int);
-    r = sysctl(nm, 2, &base, &len, NULL, 0);
+    int nm[2] = {CTL_KERN, KERN_USRSTACK};
+    ptr_t base;
+    size_t len = sizeof(ptr_t);
+    int r = sysctl(nm, 2, &base, &len, NULL, 0);
     
     if (r) ABORT("Error getting stack base");
 
-    return (ptr_t)base;
+    return base;
   }
 
 #endif /* FREEBSD_STACKBOTTOM */
-- 
GitLab