unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Guile garbage collector on ia64-linux
       [not found] <15307.10445.674412.197780@napali.hpl.hp.com>
@ 2003-06-25  2:58 ` stefan
  2003-06-25  9:34   ` [Linux-ia64] " Andreas Schwab
  2003-06-25 16:58   ` David Mosberger
  0 siblings, 2 replies; 6+ messages in thread
From: stefan @ 2003-06-25  2:58 UTC (permalink / raw)
  Cc: guile-devel

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,
	stefan@lkcc.org

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.



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Linux-ia64] Guile garbage collector on ia64-linux
  2003-06-25  2:58 ` Guile garbage collector on ia64-linux stefan
@ 2003-06-25  9:34   ` Andreas Schwab
  2003-06-25 16:58   ` David Mosberger
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2003-06-25  9:34 UTC (permalink / raw)
  Cc: guile-devel

stefan <stefan@lkcc.org> writes:

|> 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'.

Alternatively you could name getcontext differently on the C level, but
give it getcontext as the assembler name, like this:

extern struct rv ia64_getcontext (ucontext_t *) __asm__ ("getcontext");

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Guile garbage collector on ia64-linux
  2003-06-25  2:58 ` Guile garbage collector on ia64-linux stefan
  2003-06-25  9:34   ` [Linux-ia64] " Andreas Schwab
@ 2003-06-25 16:58   ` David Mosberger
  2003-06-25 18:03     ` stefan
  2003-06-25 18:07     ` stefan
  1 sibling, 2 replies; 6+ messages in thread
From: David Mosberger @ 2003-06-25 16:58 UTC (permalink / raw)
  Cc: David Mosberger, linux-ia64, guile-devel

>>>>> On Wed, 25 Jun 2003 04:58:59 +0200 (CEST), stefan <stefan@lkcc.org> said:

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

One way of achieving this is to do:

	#define getcontext hide_getcontext
	#include <ucontext.h>
	#undef getcontext

Andreas suggested another method.  Both have their ups and downs.

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

This doesn't sound right.  There were no member-name changes "struct
sigcontext".  I just checked the current libc CVS tree and it has:

struct sigcontext
{
    :
  unsigned long int sc_ar_bsp;  /* backing store pointer */

So I don't know why this isn't working for you.  What distro are you
using?

	--david

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Guile garbage collector on ia64-linux
  2003-06-25 16:58   ` David Mosberger
@ 2003-06-25 18:03     ` stefan
  2003-06-25 18:07     ` stefan
  1 sibling, 0 replies; 6+ messages in thread
From: stefan @ 2003-06-25 18:03 UTC (permalink / raw)
  Cc: linux-ia64, guile-devel

On Wed, 25 Jun 2003, David Mosberger wrote:

> >>>>> On Wed, 25 Jun 2003 04:58:59 +0200 (CEST), stefan <stefan@lkcc.org> said:
>
>   Stefan>  * have some header where ucontext_t is declared but
>   Stefan> setcontext()/getcontext() is not -> so we can redeclare it
>   Stefan> to make getcontext() return the 'struct rv'.
>
> One way of achieving this is to do:
>
> 	#define getcontext hide_getcontext
> 	#include <ucontext.h>
> 	#undef getcontext
>
> Andreas suggested another method.  Both have their ups and downs.
>
>   Stefan>  * determination of the size and location of the backing
>   Stefan> store; this has been previously achieved by:
>   Stefan> ctx.uc_mcontext.sc_ar_bsp -> the top
>   Stefan> __libc_ia64_register_backing_store_base -> the bottom Newer
>   Stefan> glibc headers don't have 'sc_ar_bsp', but things like
>   Stefan> 'ar_bsp_base' or 'ar_bspstore'.  Can something in the
>   Stefan> structure ucontext_t be used to achieve the same?  Will this
>   Stefan> change often in the future?
>
> This doesn't sound right.  There were no member-name changes "struct
> sigcontext".  I just checked the current libc CVS tree and it has:
>
> struct sigcontext
> {
>     :
>   unsigned long int sc_ar_bsp;  /* backing store pointer */
>
> So I don't know why this isn't working for you.  What distro are you
> using?

I've been using the Compaq testdrive account

 'SuSE Linux 7.2a (ia64) - Kernel 2.4.4-SMP (2)'

... looks like a glibc 2.2.2

Well may be too an old one.

Thanks for the quick response,
	stefan@lkcc.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Guile garbage collector on ia64-linux
  2003-06-25 16:58   ` David Mosberger
  2003-06-25 18:03     ` stefan
@ 2003-06-25 18:07     ` stefan
  2003-09-12 15:35       ` Marius Vollmer
  1 sibling, 1 reply; 6+ messages in thread
From: stefan @ 2003-06-25 18:07 UTC (permalink / raw)


[-- Attachment #1: Type: TEXT/PLAIN, Size: 1449 bytes --]

On Wed, 25 Jun 2003, David Mosberger wrote:

> >>>>> On Wed, 25 Jun 2003 04:58:59 +0200 (CEST), stefan <stefan@lkcc.org> said:
>
>   Stefan>  * have some header where ucontext_t is declared but
>   Stefan> setcontext()/getcontext() is not -> so we can redeclare it
>   Stefan> to make getcontext() return the 'struct rv'.
>
> One way of achieving this is to do:
>
> 	#define getcontext hide_getcontext
> 	#include <ucontext.h>
> 	#undef getcontext
>
> Andreas suggested another method.  Both have their ups and downs.
>
>   Stefan>  * determination of the size and location of the backing
>   Stefan> store; this has been previously achieved by:
>   Stefan> ctx.uc_mcontext.sc_ar_bsp -> the top
>   Stefan> __libc_ia64_register_backing_store_base -> the bottom Newer
>   Stefan> glibc headers don't have 'sc_ar_bsp', but things like
>   Stefan> 'ar_bsp_base' or 'ar_bspstore'.  Can something in the
>   Stefan> structure ucontext_t be used to achieve the same?  Will this
>   Stefan> change often in the future?
>
> This doesn't sound right.  There were no member-name changes "struct
> sigcontext".  I just checked the current libc CVS tree and it has:
>
> struct sigcontext
> {
>     :
>   unsigned long int sc_ar_bsp;  /* backing store pointer */

Finally I applied a patch to CVS Guile.  This should work now.  Could
please someone backport it (attached) to Guile 1.6.x recent?  Then the
Debian builders may succeed...

Cheers,
	stefan@lkcc.org

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1519 bytes --]

? g.diff
Index: libguile/continuations.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/continuations.c,v
retrieving revision 1.49
diff -u -r1.49 continuations.c
--- libguile/continuations.c	20 Apr 2003 07:19:38 -0000	1.49
+++ libguile/continuations.c	25 Jun 2003 18:07:12 -0000
@@ -97,8 +97,7 @@
   long retval;
   long first_return;
 };
-extern struct rv getcontext (ucontext_t *);
-extern int setcontext (ucontext_t *);
+extern struct rv ia64_getcontext (ucontext_t *) __asm__ ("getcontext");
 #endif /* __ia64__ */
 
 /* this may return more than once: the first time with the escape
@@ -138,7 +137,7 @@
   memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size);
 
 #ifdef __ia64__
-  rv = getcontext (&continuation->ctx);
+  rv = ia64_getcontext (&continuation->ctx);
   if (rv.first_return)
     {
       continuation->backing_store_size = 
Index: libguile/continuations.h
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/continuations.h,v
retrieving revision 1.30
diff -u -r1.30 continuations.h
--- libguile/continuations.h	20 Apr 2003 07:19:38 -0000	1.30
+++ libguile/continuations.h	25 Jun 2003 18:07:12 -0000
@@ -26,7 +26,7 @@
 
 #ifdef __ia64__
 #include <signal.h>
-#include <sys/ucontext.h>
+#include <ucontext.h>
 extern unsigned long * __libc_ia64_register_backing_store_base;
 #endif /* __ia64__ */
 \f

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Guile garbage collector on ia64-linux
  2003-06-25 18:07     ` stefan
@ 2003-09-12 15:35       ` Marius Vollmer
  0 siblings, 0 replies; 6+ messages in thread
From: Marius Vollmer @ 2003-09-12 15:35 UTC (permalink / raw)
  Cc: guile-devel

stefan <stefan@lkcc.org> writes:

> Finally I applied a patch to CVS Guile.  This should work now.  Could
> please someone backport it (attached) to Guile 1.6.x recent?  Then the
> Debian builders may succeed...

Done, thanks!

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-09-12 15:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <15307.10445.674412.197780@napali.hpl.hp.com>
2003-06-25  2:58 ` Guile garbage collector on ia64-linux stefan
2003-06-25  9:34   ` [Linux-ia64] " Andreas Schwab
2003-06-25 16:58   ` David Mosberger
2003-06-25 18:03     ` stefan
2003-06-25 18:07     ` stefan
2003-09-12 15:35       ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).