Tcl Source Code

Artifact [cca23809bd]
Login

Artifact cca23809bd0768782f98cdf0c63af3cb525c203f:

Attachment "2017264.patch" to ticket [2017264fff] added by jenglish 2008-08-05 15:01:54.
diff --git a/generic/tclInt.h b/generic/tclInt.h
index edc8017..547e3fc 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2754,7 +2754,6 @@ MODULE_SCOPE void *	TclThreadStorageKeyGet(Tcl_ThreadDataKey *keyPtr);
 MODULE_SCOPE void	TclThreadStorageKeySet(Tcl_ThreadDataKey *keyPtr,
 			    void *data);
 MODULE_SCOPE void	TclpThreadExit(int status);
-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);
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 1659a12..6ca5be2 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -676,44 +676,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [
 
 	# Does the pthread-implementation provide
 	# 'pthread_attr_setstacksize' ?
-
-	ac_saved_libs=$LIBS
-	LIBS="$LIBS $THREADS_LIBS"
 	AC_CHECK_FUNCS(pthread_attr_setstacksize)
-	AC_CHECK_FUNC(pthread_attr_get_np,tcl_ok=yes,tcl_ok=no)
-	if test $tcl_ok = yes ; then
-	    AC_DEFINE(HAVE_PTHREAD_ATTR_GET_NP, 1,
-		[Do we want a BSD-like thread-attribute interface?])
-	    AC_CACHE_CHECK([for pthread_attr_get_np declaration],
-		tcl_cv_grep_pthread_attr_get_np, [
-		AC_EGREP_HEADER(pthread_attr_get_np, pthread.h,
-		    tcl_cv_grep_pthread_attr_get_np=present,
-		    tcl_cv_grep_pthread_attr_get_np=missing)])
-	    if test $tcl_cv_grep_pthread_attr_get_np = missing ; then
-		AC_DEFINE(ATTRGETNP_NOT_DECLARED, 1,
-		    [Is pthread_attr_get_np() declared in <pthread.h>?])
-	    fi
-	else
-	    AC_CHECK_FUNC(pthread_getattr_np,tcl_ok=yes,tcl_ok=no)
-	    if test $tcl_ok = yes ; then
-		AC_DEFINE(HAVE_PTHREAD_GETATTR_NP, 1,
-		    [Do we want a Linux-like thread-attribute interface?])
-		AC_CACHE_CHECK([for pthread_getattr_np declaration],
-		    tcl_cv_grep_pthread_getattr_np, [
-		    AC_EGREP_HEADER(pthread_getattr_np, pthread.h,
-			tcl_cv_grep_pthread_getattr_np=present,
-			tcl_cv_grep_pthread_getattr_np=missing)])
-		if test $tcl_cv_grep_pthread_getattr_np = missing ; then
-		    AC_DEFINE(GETATTRNP_NOT_DECLARED, 1,
-			[Is pthread_getattr_np declared in <pthread.h>?])
-		fi
-	    fi
-	fi
-	if test $tcl_ok = no; then
-	    # Darwin thread stacksize API
-	    AC_CHECK_FUNCS(pthread_get_stacksize_np)
-	fi
-	LIBS=$ac_saved_libs
     else
 	TCL_THREADS=0
     fi
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index f925b49..2653c53 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -602,24 +602,6 @@ EXTERN char *          	TclpInetNtoa(struct in_addr);
  * #define gmtime(x)	TclpGmtime(x)    */
 #   undef inet_ntoa
 #   define inet_ntoa(x)	TclpInetNtoa(x)
-#   ifdef HAVE_PTHREAD_ATTR_GET_NP
-#	define TclpPthreadGetAttrs	pthread_attr_get_np
-#	ifdef ATTRGETNP_NOT_DECLARED
-/*
- * Assume it is in pthread_np.h if it isn't in pthread.h. [Bug 1064882]
- * We might need to revisit this in the future. :^(
- */
-#	    include <pthread.h>
-#	    include <pthread_np.h>
-#	endif
-#   else
-#	ifdef HAVE_PTHREAD_GETATTR_NP
-#	    define TclpPthreadGetAttrs	pthread_getattr_np
-#	    ifdef GETATTRNP_NOT_DECLARED
-EXTERN int pthread_getattr_np _ANSI_ARGS_((pthread_t, pthread_attr_t *));
-#	    endif
-#	endif /* HAVE_PTHREAD_GETATTR_NP */
-#   endif /* HAVE_PTHREAD_ATTR_GET_NP */
 #endif /* TCL_THREADS */
 
 /*
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index e9bca30..8c44b15 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -200,99 +200,6 @@ TclpThreadExit(
 }
 #endif /* TCL_THREADS */
 
-#ifdef TCL_THREADS
-/*
- *----------------------------------------------------------------------
- *
- * TclpThreadGetStackSize --
- *
- *	This procedure returns the size of the current thread's stack.
- *
- * Results:
- *	Stack size (in bytes?) or -1 for error or 0 for undeterminable.
- *
- * Side effects:
- *	None.
- *
- *----------------------------------------------------------------------
- */
-
-size_t
-TclpThreadGetStackSize(void)
-{
-    size_t stackSize = 0;
-#if defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && defined(TclpPthreadGetAttrs)
-    pthread_attr_t threadAttr;	/* This will hold the thread attributes for
-				 * the current thread. */
-#ifdef __GLIBC__
-    /*
-     * Fix for [Bug 1815573]
-     *
-     * DESCRIPTION:
-     * On linux TclpPthreadGetAttrs (which is pthread_attr_get_np) may return
-     * bogus values on the initial thread.
-     *
-     * ASSUMPTIONS:
-     * There seems to be no api to determine if we are on the initial
-     * thread. The simple scheme implemented here assumes:
-     *   1. The first Tcl interp to be created lives in the initial thread. If
-     *      this assumption is not true, the fix is to call
-     *      TclpThreadGetStackSize from the initial thread previous to
-     *      creating any Tcl interpreter. In this case, especially if another
-     *      Tcl interpreter may be created in the initial thread, it might be
-     *      better to enable the second branch in the #if below
-     *   2. There will be no races in creating the first Tcl interp - ie, the
-     *      second Tcl interp will be created only after the first call to
-     *      Tcl_CreateInterp returns.
-     *
-     * These assumptions are satisfied by tclsh. Embedders on linux may want
-     * to check their validity, and possibly adapt the code on failing to meet
-     * them.
-     */
-
-    static int initialized = 0;
-
-    if (!initialized) {
-	initialized = 1;
-	return 0;
-    } else {
-#else
-    {
-#endif
-	if (pthread_attr_init(&threadAttr) != 0) {
-	    return -1;
-	}
-	if (TclpPthreadGetAttrs(pthread_self(), &threadAttr) != 0) {
-	    pthread_attr_destroy(&threadAttr);
-	    return (size_t)-1;
-	}
-    }
-
-
-    if (pthread_attr_getstacksize(&threadAttr, &stackSize) != 0) {
-	pthread_attr_destroy(&threadAttr);
-	return (size_t)-1;
-    }
-    pthread_attr_destroy(&threadAttr);
-#elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP)
-#ifdef __APPLE__
-    /*
-     * On Darwin, the API below does not return the correct stack size for the
-     * main thread (which is not a real pthread), so fallback to getrlimit().
-     */
-    if (!pthread_main_np())
-#endif
-    stackSize = pthread_get_stacksize_np(pthread_self());
-#else
-    /*
-     * Cannot determine the real stack size of this thread. The caller might
-     * want to try looking at the process accounting limits instead.
-     */
-#endif
-    return stackSize;
-}
-#endif /* TCL_THREADS */
-
 /*
  *----------------------------------------------------------------------
  *