From 96e1a4c2e481e7f7868cc3e8e4769729bf99b7a4 Mon Sep 17 00:00:00 2001
From: davem <davem@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sun, 17 Apr 2005 22:01:21 +0000
Subject: [PATCH] 2005-04-17  David S. Miller  <davem@davemloft.net>

	* include/private/gcconfig.h (sparc-linux): Use LINUX_STACKBOTTOM.
	* os_dep.c (GC_linux_stack_base): Check for bug present in some
	Sparc glibc variants where __libc_stack_end is erroneously set
	to "1".  Fallback to procfs code in that case.


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

diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog
index bc73cc4f86c6..87ca45c771dc 100644
--- a/boehm-gc/ChangeLog
+++ b/boehm-gc/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-17  David S. Miller  <davem@davemloft.net>
+
+	* include/private/gcconfig.h (sparc-linux): Use LINUX_STACKBOTTOM.
+	* os_dep.c (GC_linux_stack_base): Check for bug present in some
+	Sparc glibc variants where __libc_stack_end is erroneously set
+	to "1".  Fallback to procfs code in that case.
+
 2005-04-12  Mike Stump  <mrs@apple.com>
 
 	* configure: Regenerate.
diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h
index 7f3b63e4a2cf..a9ed7176ba6e 100644
--- a/boehm-gc/include/private/gcconfig.h
+++ b/boehm-gc/include/private/gcconfig.h
@@ -924,12 +924,10 @@
       extern ptr_t GC_SysVGetDataStart();
 #     ifdef __arch64__
 #	define DATASTART GC_SysVGetDataStart(0x100000, _etext)
-	/* libc_stack_end is not set reliably for sparc64 */
-#       define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
 #     else
 #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
-#	define LINUX_STACKBOTTOM
 #     endif
+#     define LINUX_STACKBOTTOM
 #   endif
 #   ifdef OPENBSD
 #     define OS_TYPE "OPENBSD"
diff --git a/boehm-gc/os_dep.c b/boehm-gc/os_dep.c
index 21d05635ab81..30c2b8bc4ab8 100644
--- a/boehm-gc/os_dep.c
+++ b/boehm-gc/os_dep.c
@@ -945,7 +945,16 @@ ptr_t GC_get_stack_base()
 	  } /* Otherwise it's not safe to add 16 bytes and we fall	*/
 	    /* back to using /proc.					*/
 #	else 
+#	ifdef SPARC
+	  /* Older versions of glibc for 64-bit Sparc do not set
+	   * this variable correctly, it gets set to either zero
+	   * or one.
+	   */
+	  if (__libc_stack_end != (ptr_t) (unsigned long)0x1)
+	    return __libc_stack_end;
+#	else
 	  return __libc_stack_end;
+#	endif
 #	endif
       }
     f = open("/proc/self/stat", O_RDONLY);
-- 
GitLab