1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-21 20:20:24 +02:00

* threads.c (get_thread_stack_base): Use scm_get_stack_base

instead of accessing __libc_stack_end directly, and only do this
when pthread_attr_getstack is known not to work for the main
thread or when not using pthreads at all.

* gc_os_dep.c (scm_get_stack_base): Abort when the machine type is
unknown instead of returning NULL.
This commit is contained in:
Marius Vollmer 2006-03-25 22:24:21 +00:00
parent d48f1dffa7
commit 50a64877dd
3 changed files with 21 additions and 12 deletions

View file

@ -1,3 +1,13 @@
2006-03-26 Marius Vollmer <mvo@zagadka.de>
* threads.c (get_thread_stack_base): Use scm_get_stack_base
instead of accessing __libc_stack_end directly, and only do this
when pthread_attr_getstack is known not to work for the main
thread or when not using pthreads at all.
* gc_os_dep.c (scm_get_stack_base): Abort when the machine type is
unknown instead of returning NULL.
2006-03-21 Ludovic Courtès <ludovic.courtes@laas.fr>
* numbers.c (scm_i_mem2number): Renamed to

View file

@ -401,6 +401,7 @@ typedef int GC_bool;
void *
scm_get_stack_base ()
{
ABORT ("Can't determine stack base");
return NULL;
}

View file

@ -41,6 +41,7 @@
#include "libguile/iselect.h"
#include "libguile/fluids.h"
#include "libguile/continuations.h"
#include "libguile/gc.h"
#include "libguile/init.h"
#ifdef __MINGW32__
@ -564,10 +565,6 @@ scm_i_init_thread_for_guile (SCM_STACKITEM *base, SCM parent)
}
}
#ifdef HAVE_LIBC_STACK_END
extern void *__libc_stack_end;
#if SCM_USE_PTHREAD_THREADS
#ifdef HAVE_PTHREAD_ATTR_GETSTACK
@ -580,18 +577,20 @@ get_thread_stack_base ()
void *start, *end;
size_t size;
/* XXX - pthread_getattr_np from LinuxThreads does not seem to work
for the main thread, but we can use __libc_stack_end in that
case.
*/
pthread_getattr_np (pthread_self (), &attr);
pthread_attr_getstack (&attr, &start, &size);
end = (char *)start + size;
/* XXX - pthread_getattr_np from LinuxThreads does not seem to work
for the main thread, but we can use scm_get_stack_base in that
case.
*/
#ifndef PTHREAD_ATTR_GETSTACK_WORKS
if ((void *)&attr < start || (void *)&attr >= end)
return __libc_stack_end;
return scm_get_stack_base ();
else
#endif
{
#if SCM_STACK_GROWS_UP
return start;
@ -610,11 +609,10 @@ get_thread_stack_base ()
static SCM_STACKITEM *
get_thread_stack_base ()
{
return __libc_stack_end;
return scm_get_stack_base ();
}
#endif /* !SCM_USE_PTHREAD_THREADS */
#endif /* HAVE_LIBC_STACK_END */
#ifdef HAVE_GET_THREAD_STACK_BASE