From 97084119ee95deef8f90766564e3fe3e7a8d81af Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sun, 28 Jan 2007 16:36:38 +0000 Subject: [PATCH] Merge of IA64 fix from CVS HEAD. --- ChangeLog | 20 +++++++++++++------ configure.in | 2 ++ libguile/ChangeLog | 36 +++++++++++++++++++++++++++++++++ libguile/_scm.h | 3 +++ libguile/continuations.c | 36 ++++++++++----------------------- libguile/continuations.h | 2 +- libguile/coop-pthreads.c | 5 +++-- libguile/gc.c | 43 +++++++++++++++++++++++++++++++++++----- libguile/gc.h | 5 +++++ libguile/threads.c | 4 ++-- 10 files changed, 114 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75505eed4..e33120a81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,11 +52,19 @@ * configure.in (AM_PROG_CC_C_O): New macro, needed by automake 1.10 for per-target cflags in libguile/Makefile.am. -2006-11-08 Ludovic Courtès +2006-11-08 Ludovic Courtès * configure.in: Pass `bug-guile@gnu.org' as a third argument to `AC_INIT'. +2006-10-25 Neil Jerram + + (Merged from CVS HEAD on 2007-01-28.) + + IA64 HP-UX patch from Hrvoje NikÅ¡ić. (Thanks!) + + * configure.in: New check for uca lib (needed for IA64 on HP-UX). + 2006-10-06 Rob Browning Guile 1.8.1 released. @@ -82,7 +90,7 @@ * configure.in (complex.h, complex double, csqrt): New tests. -2006-09-20 Ludovic Courtès +2006-09-20 Ludovic Courtès * configure.in: Check for `isblank ()'. @@ -108,7 +116,7 @@ * configure.in (AC_CHECK_MEMBERS): Test struct tm.tm_gmtoff. -2006-06-13 Ludovic Courtès +2006-06-13 Ludovic Courtès * NEWS: Mentioned the new behavior of `equal?' for structures. @@ -309,7 +317,7 @@ * acinclude.m4 (ACX_PTHREAD): New. * configure.in: Use it instead of simply looking for -lpthread. - Thanks to Andreas Vögele! + Thanks to Andreas Vögele! 2004-09-08 Marius Vollmer @@ -362,7 +370,7 @@ 2004-07-09 Marius Vollmer * configure.in: Bugfix: set SCM_I_GSC_T_UINTMAX, not - SCM_I_GSC_T_INTMAX in two places. Thanks to Andreas Vögele! + SCM_I_GSC_T_INTMAX in two places. Thanks to Andreas Vögele! 2004-07-07 Marius Vollmer @@ -2081,7 +2089,7 @@ Tue Dec 14 09:12:22 1999 Greg J. Badros 1999-07-19 Jim Blandy - Fixes for EMX from Mikael Ståldal. + Fixes for EMX from Mikael StÃ¥ldal. * configure.in: Check for . * configure: Regenerated. diff --git a/configure.in b/configure.in index 43ffb4e70..dd0628ff1 100644 --- a/configure.in +++ b/configure.in @@ -221,6 +221,7 @@ if test "$enable_elisp" = yes; then else SCM_I_GSC_ENABLE_ELISP=0 fi +AC_CHECK_LIB(uca, __uc_get_ar_bsp) AC_C_CONST @@ -233,6 +234,7 @@ if test "$ac_cv_c_inline" != no; then else SCM_I_GSC_C_INLINE=NULL fi +AC_CHECK_LIB(uca, __uc_get_ar_bsp) AC_C_BIGENDIAN diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 5314805ab..5f20fdda0 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -171,6 +171,42 @@ "shared array" example in `vectors.test'). Reported by Szavai Gyula. +2006-10-25 Neil Jerram + + (Merged from CVS HEAD on 2007-01-28.) + + IA64 HP-UX GC patch from Hrvoje NikÅ¡ić. (Thanks!) + + * threads.c (SCM_MARK_BACKING_STORE): Use scm_ia64_ar_bsp() and + scm_ia64_register_backing_store_base() instead of Linux-specific + implementations. + + * gc.h (scm_ia64_register_backing_store_base, scm_ia64_ar_bsp): + New declarations. + + * gc.c (__libc_ia64_register_backing_store_base): Declaration + removed. + (scm_ia64_register_backing_store_base, scm_ia64_ar_bsp): New, with + implementations for Linux and HP-UX. + + * coop-pthreads.c (SCM_MARK_BACKING_STORE): Use scm_ia64_ar_bsp() + and scm_ia64_register_backing_store_base() instead of + Linux-specific implementations. + + * continuations.h (__libc_ia64_register_backing_store_base): + Declaration removed. + (scm_t_contregs): New "fresh" field. + + * continuations.c (ia64_getcontext): Removed. + (scm_make_continuation): Use continuation fresh field instead of + interpreting getcontext return values (which isn't portable). Use + scm_ia64_ar_bsp() and scm_ia64_register_backing_store_base() + instead of Linux-specific implementations. + (copy_stack_and_call): Use scm_ia64_register_backing_store_base() + instead of Linux-specific implementation. + + * _scm.h (__ia64__): Also detect __ia64. + 2006-10-03 Kevin Ryde * eval.c (SCM_APPLY): For scm_tc7_subr_2o, throw wrong-num-args on 0 diff --git a/libguile/_scm.h b/libguile/_scm.h index 906de3780..fd05770c2 100644 --- a/libguile/_scm.h +++ b/libguile/_scm.h @@ -54,6 +54,9 @@ and differences between _scm.h and __scm.h. **********************************************************************/ +#if defined(__ia64) && !defined(__ia64__) +# define __ia64__ +#endif #if HAVE_CONFIG_H # include diff --git a/libguile/continuations.c b/libguile/continuations.c index 5ae89d836..39785a528 100644 --- a/libguile/continuations.c +++ b/libguile/continuations.c @@ -92,22 +92,6 @@ continuation_print (SCM obj, SCM port, scm_print_state *state SCM_UNUSED) return 1; } -#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; -}; - -#ifdef __GNUC__ -__attribute__ ((returns_twice)) -#endif /* __GNUC__ */ -extern struct rv ia64_getcontext (ucontext_t *) __asm__ ("getcontext"); -#endif /* __ia64__ */ - /* this may return more than once: the first time with the escape procedure, then subsequently with the value to be passed to the continuation. */ @@ -120,9 +104,6 @@ scm_make_continuation (int *first) scm_t_contregs *continuation; long stack_size; SCM_STACKITEM * src; -#ifdef __ia64__ - struct rv rv; -#endif /* __ia64__ */ SCM_FLUSH_REGISTER_WINDOWS; stack_size = scm_stack_size (thread->continuation_base); @@ -144,20 +125,23 @@ scm_make_continuation (int *first) memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size); #ifdef __ia64__ - rv = ia64_getcontext (&continuation->ctx); - if (rv.first_return) + continuation->fresh = 1; + getcontext (&continuation->ctx); + if (continuation->fresh) { - continuation->backing_store_size = - continuation->ctx.uc_mcontext.sc_ar_bsp - - (unsigned long) __libc_ia64_register_backing_store_base; + continuation->backing_store_size = + (char *) scm_ia64_ar_bsp(&continuation->ctx) + - + (char *) scm_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, + (void *) scm_ia64_register_backing_store_base (), continuation->backing_store_size); *first = 1; + continuation->fresh = 0; return cont; } else @@ -252,7 +236,7 @@ copy_stack_and_call (scm_t_contregs *continuation, SCM val, continuation->throw_value = val; #ifdef __ia64__ - memcpy ((void *) __libc_ia64_register_backing_store_base, + memcpy (scm_ia64_register_backing_store_base (), continuation->backing_store, continuation->backing_store_size); setcontext (&continuation->ctx); diff --git a/libguile/continuations.h b/libguile/continuations.h index d10297956..0274c1b2d 100644 --- a/libguile/continuations.h +++ b/libguile/continuations.h @@ -27,7 +27,6 @@ #ifdef __ia64__ #include #include -extern unsigned long * __libc_ia64_register_backing_store_base; #endif /* __ia64__ */ @@ -48,6 +47,7 @@ typedef struct SCM dynenv; #ifdef __ia64__ ucontext_t ctx; + int fresh; void *backing_store; unsigned long backing_store_size; #endif /* __ia64__ */ diff --git a/libguile/coop-pthreads.c b/libguile/coop-pthreads.c index a9b1b86e7..b1759f9ed 100644 --- a/libguile/coop-pthreads.c +++ b/libguile/coop-pthreads.c @@ -31,6 +31,7 @@ #include "libguile/eval.h" #include "libguile/async.h" #include "libguile/ports.h" +#include "libguile/gc.h" #undef DEBUG @@ -847,8 +848,8 @@ scm_threads_init (SCM_STACKITEM *base) scm_mark_locations ((SCM_STACKITEM *) &ctx.uc_mcontext, \ ((size_t) (sizeof (SCM_STACKITEM) - 1 + sizeof ctx.uc_mcontext) \ / sizeof (SCM_STACKITEM))); \ - bot = (SCM_STACKITEM *) __libc_ia64_register_backing_store_base; \ - top = (SCM_STACKITEM *) ctx.uc_mcontext.sc_ar_bsp; \ + bot = (SCM_STACKITEM *) scm_ia64_register_backing_store_base (); \ + top = (SCM_STACKITEM *) scm_ia64_ar_bsp (&ctx); \ scm_mark_locations (bot, top - bot); } while (0) #else # define SCM_MARK_BACKING_STORE() diff --git a/libguile/gc.c b/libguile/gc.c index f045bcc90..19653c74f 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -28,11 +28,6 @@ #include #include -#ifdef __ia64__ -#include -extern unsigned long * __libc_ia64_register_backing_store_base; -#endif - #include "libguile/_scm.h" #include "libguile/eval.h" #include "libguile/stime.h" @@ -1030,6 +1025,44 @@ scm_init_gc () #include "libguile/gc.x" } +#ifdef __ia64__ +# ifdef __hpux +# include +# include +void * +scm_ia64_register_backing_store_base (void) +{ + struct pst_vm_status vm_status; + int i = 0; + while (pstat_getprocvm (&vm_status, sizeof (vm_status), 0, i++) == 1) + if (vm_status.pst_type == PS_RSESTACK) + return (void *) vm_status.pst_vaddr; + abort (); +} +void * +scm_ia64_ar_bsp (const void *ctx) +{ + uint64_t bsp; + __uc_get_ar_bsp(ctx, &bsp); + return (void *) bsp; +} +# endif /* hpux */ +# ifdef linux +# include +void * +scm_ia64_register_backing_store_base (void) +{ + extern void *__libc_ia64_register_backing_store_base; + return __libc_ia64_register_backing_store_base; +} +void * +scm_ia64_ar_bsp (const void *opaque) +{ + ucontext_t *ctx = opaque; + return (void *) ctx->uc_mcontext.sc_ar_bsp; +} +# endif /* linux */ +#endif /* __ia64__ */ void scm_gc_sweep (void) diff --git a/libguile/gc.h b/libguile/gc.h index 821d174d6..3cedeb4eb 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -246,6 +246,11 @@ SCM_API scm_i_pthread_mutex_t scm_i_gc_admin_mutex; #define scm_gc_running_p (SCM_I_CURRENT_THREAD->gc_running_p) SCM_API scm_i_pthread_mutex_t scm_i_sweep_mutex; +#ifdef __ia64__ +void *scm_ia64_register_backing_store_base (void); +void *scm_ia64_ar_bsp (const void *); +#endif + #if (SCM_ENABLE_DEPRECATED == 1) diff --git a/libguile/threads.c b/libguile/threads.c index 38f9f689e..7e1bfde7f 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -1352,8 +1352,8 @@ SCM_DEFINE (scm_broadcast_condition_variable, "broadcast-condition-variable", 1, scm_mark_locations ((SCM_STACKITEM *) &ctx.uc_mcontext, \ ((size_t) (sizeof (SCM_STACKITEM) - 1 + sizeof ctx.uc_mcontext) \ / sizeof (SCM_STACKITEM))); \ - bot = (SCM_STACKITEM *) __libc_ia64_register_backing_store_base; \ - top = (SCM_STACKITEM *) ctx.uc_mcontext.sc_ar_bsp; \ + bot = (SCM_STACKITEM *) scm_ia64_register_backing_store_base (); \ + top = (SCM_STACKITEM *) scm_ia64_ar_bsp (&ctx); \ scm_mark_locations (bot, top - bot); } while (0) #else # define SCM_MARK_BACKING_STORE()