--- tcl8.5a5/generic/tclInt.h.jj	2006-09-30 15:00:12.000000000 -0400
+++ tcl8.5a5/generic/tclInt.h	2007-02-04 13:59:08.000000000 -0500
@@ -2215,7 +2215,7 @@ MODULE_SCOPE void *	TclpThreadDataKeyGet
 MODULE_SCOPE void	TclpThreadDataKeySet(Tcl_ThreadDataKey *keyPtr,
 			    void *data);
 MODULE_SCOPE void	TclpThreadExit(int status);
-MODULE_SCOPE int	TclpThreadGetStackSize(void);
+MODULE_SCOPE size_t	TclpThreadGetStackSize(void);
 MODULE_SCOPE void	TclRememberCondition(Tcl_Condition *mutex);
 MODULE_SCOPE void	TclRememberJoinableThread(Tcl_ThreadId id);
 MODULE_SCOPE void	TclRememberMutex(Tcl_Mutex *mutex);
--- tcl8.5a5/unix/tclUnixThrd.c.jj	2006-10-16 14:41:25.000000000 -0400
+++ tcl8.5a5/unix/tclUnixThrd.c	2007-02-04 14:01:43.000000000 -0500
@@ -204,7 +204,7 @@ TclpThreadExit(
  *	This procedure returns the size of the current thread's stack.
  *
  * Results:
- *	Stack size (in bytes?) or -1 for error or 0 for undeterminable.
+ *	Stack size (in bytes?) or (size_t) -1 for error or 0 for undeterminable.
  *
  * Side effects:
  *	None.
@@ -212,7 +212,7 @@ TclpThreadExit(
  *----------------------------------------------------------------------
  */
 
-int
+size_t
 TclpThreadGetStackSize(void)
 {
     size_t stackSize = 0;
@@ -221,15 +221,15 @@ TclpThreadGetStackSize(void)
 				 * the current thread. */
 
     if (pthread_attr_init(&threadAttr) != 0) {
-	return -1;
+	return (size_t) -1;
     }
     if (TclpPthreadGetAttrs(pthread_self(), &threadAttr) != 0) {
 	pthread_attr_destroy(&threadAttr);
-	return -1;
+	return (size_t) -1;
     }
     if (pthread_attr_getstacksize(&threadAttr, &stackSize) != 0) {
 	pthread_attr_destroy(&threadAttr);
-	return -1;
+	return (size_t) -1;
     }
     pthread_attr_destroy(&threadAttr);
 #elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP)
@@ -247,7 +247,7 @@ TclpThreadGetStackSize(void)
      * want to try looking at the process accounting limits instead.
      */
 #endif
-    return (int) stackSize;
+    return stackSize;
 }
 #endif /* TCL_THREADS */
 
--- tcl8.5a5/unix/tclUnixInit.c.jj	2006-09-10 13:04:07.000000000 -0400
+++ tcl8.5a5/unix/tclUnixInit.c	2007-02-04 14:11:12.000000000 -0500
@@ -1059,9 +1059,14 @@ TclpCheckStackSpace(void)
 	 * process accounting limit. Note that we assume that stack sizes do
 	 * not change throughout the lifespan of the thread/process; this is
 	 * almost always true.
+	 * The check below relies on size_t being at least as wide as
+	 * ptrdiff_t.  If it is not (is there such arch?), punt.
 	 */
 
-	tsdPtr->stackDetermineResult = GetStackSize(&tsdPtr->stackSize);
+	if (sizeof (size_t) < sizeof (ptrdiff_t))
+	    tsdPtr->stackDetermineResult = TCL_CONTINUE;
+	else
+	    tsdPtr->stackDetermineResult = GetStackSize(&tsdPtr->stackSize);
 	tsdPtr->initialised = 1;
     }
 
@@ -1089,13 +1094,13 @@ TclpCheckStackSpace(void)
      * Now we perform the actual check. Are we about to blow our stack frame?
      */
 
-    if (stackUsed < (ptrdiff_t) tsdPtr->stackSize) {
-	STACK_DEBUG(("stack OK\tin:%p\tout:%p\tuse:%04X\tmax:%04X\n",
-		&localVar, tsdPtr->outerVarPtr, stackUsed, tsdPtr->stackSize));
+    if ((size_t) stackUsed < tsdPtr->stackSize) {
+	STACK_DEBUG(("stack OK\tin:%p\tout:%p\tuse:%04lX\tmax:%04lX\n",
+		&localVar, tsdPtr->outerVarPtr, (long int) stackUsed, (long int) tsdPtr->stackSize));
 	return 1;
     } else {
-	STACK_DEBUG(("stack OVERFLOW\tin:%p\tout:%p\tuse:%04X\tmax:%04X\n",
-		&localVar, tsdPtr->outerVarPtr, stackUsed, tsdPtr->stackSize));
+	STACK_DEBUG(("stack OVERFLOW\tin:%p\tout:%p\tuse:%04lX\tmax:%04lX\n",
+		&localVar, tsdPtr->outerVarPtr, (long int) stackUsed, (long int) tsdPtr->stackSize));
 	return 0;
     }
 #endif /* TCL_NO_STACK_CHECK */
@@ -1133,7 +1138,7 @@ GetStackSize(
     struct rlimit rLimit;	/* The result from getrlimit(). */
 
 #ifdef TCL_THREADS
-    rawStackSize = (size_t) TclpThreadGetStackSize();
+    rawStackSize = TclpThreadGetStackSize();
     if (rawStackSize == (size_t) -1) {
 	/*
 	 * Some kind of confirmed error?!
