Diff
Not logged in

Differences From Artifact [6b4c74dd4b]:

To Artifact [a7aba98686]:


211
212
213
214
215
216
217

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236







237

238
239
240
241
242
243
244
245

246
247
248
249
250
251
252
211
212
213
214
215
216
217
218
219
220
221

222
223
224
225
226
227
228
229
230
231
232
233
234

235
236
237
238
239
240
241
242

243
244
245
246
247
248


249
250
251
252
253
254
255
256
257







+



-













-

+
+
+
+
+
+
+
-
+





-
-

+







 *
 *----------------------------------------------------------------------
 */

int
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. */
    size_t stackSize;

    if (pthread_attr_init(&threadAttr) != 0) {
	return -1;
    }
    if (TclpPthreadGetAttrs(pthread_self(), &threadAttr) != 0) {
	pthread_attr_destroy(&threadAttr);
	return -1;
    }
    if (pthread_attr_getstacksize(&threadAttr, &stackSize) != 0) {
	pthread_attr_destroy(&threadAttr);
	return -1;
    }
    pthread_attr_destroy(&threadAttr);
    return (int) stackSize;
#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
    return (int) pthread_get_stacksize_np(pthread_self());
    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.
     */

    return 0;
#endif
    return (int) stackSize;
}
#endif /* TCL_THREADS */

/*
 *----------------------------------------------------------------------
 *
 * Tcl_GetCurrentThread --