guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Guile garbage collector on ia64-linux


From: stefan
Subject: Guile garbage collector on ia64-linux
Date: Wed, 25 Jun 2003 04:58:59 +0200 (CEST)

Hello David,

some time ago I was asking about the use of setcontext()/getcontext() on
ia64-linux for porting the garbage collector of GNU Guile to ia64 and with
your help I was able to write code something like this which initially
worked fine for Guile.

=========================================================================

/* This declares us ucontext_t but leaves setcontext()/getcontext()
   undeclared. */

#ifdef __ia64__
#include <signal.h>
#include <sys/ucontext.h>
extern unsigned long * __libc_ia64_register_backing_store_base;
#endif /* __ia64__ */

/* [ ... ] */

#ifdef __ia64__
/* Extern declaration of getcontext()/setcontext() in order to redefine
   getcontext() since on ia64-linux the second return value indicates
whether
   it returned from getcontext() itself or by running setcontext(). */
struct rv
{
  long retval;
  long first_return;
};
extern struct rv getcontext (ucontext_t *);
extern int setcontext (ucontext_t *);
#endif /* __ia64__ */

#ifdef __ia64__
  rv = getcontext (&continuation->ctx);
  if (rv.first_return)
    {
      continuation->backing_store_size =
        continuation->ctx.uc_mcontext.sc_ar_bsp -
        (unsigned long) __libc_ia64_register_backing_store_base;
      continuation->backing_store = NULL;
      continuation->backing_store =
        scm_gc_malloc (continuation->backing_store_size,
                       "continuation backing store");
      memcpy (continuation->backing_store,
              (void *) __libc_ia64_register_backing_store_base,
              continuation->backing_store_size);
      *first = 1;
      return cont;
    }
  else
    {
      SCM ret = continuation->throw_value;
      *first = 0;
      continuation->throw_value = SCM_BOOL_F;
      return ret;
    }
#else /* !__ia64__ */

/* [ ... ] */

#endif /* !__ia64__ */

=========================================================================

This piece of code worked perfectly for us determining the location and
size of the backing store of the machine.

With newer installations this has changed and the code does not work
anymore.  I know you stated somewhere in the past the set of
functions/structures has been introduced in glibc-2.2.3.  I do not know
exactly which version is current know.  The problem we need to solve for
the Guile garbage collection are as follows:

 * have some header where ucontext_t is declared but
   setcontext()/getcontext() is not -> so we can redeclare it to make
   getcontext() return the 'struct rv'.

 * determination of the size and location of the backing store; this has
   been previously achieved by:
     ctx.uc_mcontext.sc_ar_bsp -> the top
     __libc_ia64_register_backing_store_base -> the bottom
   Newer glibc headers don't have 'sc_ar_bsp', but things like
   'ar_bsp_base' or 'ar_bspstore'.  Can something in the structure
   ucontext_t be used to achieve the same?  Will this change often in the
   future?

Thanks in advance,
        address@hidden

PS: I also CC'ed this to guile-devel, because the issue is a debian bug
    for guile-1.6.4 and is still unresolved.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]