~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to libguile/continuations.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-06-04 19:01:38 UTC
  • mfrom: (8.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090604190138-1ao3t6sj31cqvcfe
Tags: 1.8.6+1-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build with -Wno-error.
  - Build with thread support. Some guile-using programs like autogen need it.
  - Add debian/guile-1.8-libs.shlibs: Thread support breaks ABI, bump the soname.
* Dropped changes:
  - libltdl3-dev -> libltdl7-dev: current libltdl-dev Provides: both.
  - debian/patches/libtool-ftbfs.diff: integrated upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1995,1996,1998,2000,2001,2004, 2006 Free Software Foundation, Inc.
 
1
/* Copyright (C) 1995,1996,1998,2000,2001,2004, 2006, 2008 Free Software Foundation, Inc.
2
2
 * 
3
3
 * This library is free software; you can redistribute it and/or
4
4
 * modify it under the terms of the GNU Lesser General Public
17
17
 
18
18
 
19
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
# include <config.h>
 
22
#endif
20
23
 
21
24
#include "libguile/_scm.h"
22
25
 
124
127
  continuation->offset = continuation->stack - src;
125
128
  memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size);
126
129
 
 
130
  *first = !setjmp (continuation->jmpbuf);
 
131
  if (*first)
 
132
    {
127
133
#ifdef __ia64__
128
 
  continuation->fresh = 1;
129
 
  getcontext (&continuation->ctx);
130
 
  if (continuation->fresh)
131
 
    {
132
134
      continuation->backing_store_size =
133
 
        (char *) scm_ia64_ar_bsp(&continuation->ctx)
 
135
        (char *) scm_ia64_ar_bsp(&continuation->jmpbuf.ctx)
134
136
        -
135
 
        (char *) scm_ia64_register_backing_store_base ();
 
137
        (char *) thread->register_backing_store_base;
136
138
      continuation->backing_store = NULL;
137
139
      continuation->backing_store = 
138
140
        scm_gc_malloc (continuation->backing_store_size,
139
141
                       "continuation backing store");
140
142
      memcpy (continuation->backing_store, 
141
 
              (void *) scm_ia64_register_backing_store_base (), 
 
143
              (void *) thread->register_backing_store_base, 
142
144
              continuation->backing_store_size);
143
 
      *first = 1;
144
 
      continuation->fresh = 0;
145
 
      return cont;
146
 
    }
147
 
  else
148
 
    {
149
 
      SCM ret = continuation->throw_value;
150
 
      *first = 0;
151
 
      continuation->throw_value = SCM_BOOL_F;
152
 
      return ret;
153
 
    }
154
 
#else /* !__ia64__ */
155
 
  if (setjmp (continuation->jmpbuf))
156
 
    {
157
 
      SCM ret = continuation->throw_value;
158
 
      *first = 0;
159
 
      continuation->throw_value = SCM_BOOL_F;
160
 
      return ret;
161
 
    }
162
 
  else
163
 
    {
164
 
      *first = 1;
165
 
      return cont;
166
 
    }
167
 
#endif /* !__ia64__ */
 
145
#endif /* __ia64__ */
 
146
      return cont;
 
147
    }
 
148
  else
 
149
    {
 
150
      SCM ret = continuation->throw_value;
 
151
      continuation->throw_value = SCM_BOOL_F;
 
152
      return ret;
 
153
    }
168
154
}
169
155
#undef FUNC_NAME
170
156
 
218
204
  copy_stack_data *d = (copy_stack_data *)data;
219
205
  memcpy (d->dst, d->continuation->stack,
220
206
          sizeof (SCM_STACKITEM) * d->continuation->num_stack_items);
 
207
#ifdef __ia64__
 
208
  SCM_I_CURRENT_THREAD->pending_rbs_continuation = d->continuation;
 
209
#endif
221
210
}
222
211
 
223
212
static void
235
224
  scm_i_set_last_debug_frame (continuation->dframe);
236
225
 
237
226
  continuation->throw_value = val;
238
 
#ifdef __ia64__
239
 
  memcpy (scm_ia64_register_backing_store_base (),
240
 
          continuation->backing_store,
241
 
          continuation->backing_store_size);
242
 
  setcontext (&continuation->ctx);
243
 
#else
244
227
  longjmp (continuation->jmpbuf, 1);
 
228
}
 
229
 
 
230
#ifdef __ia64__
 
231
void
 
232
scm_ia64_longjmp (jmp_buf *JB, int VAL)
 
233
{
 
234
  scm_i_thread *t = SCM_I_CURRENT_THREAD;
 
235
 
 
236
  if (t->pending_rbs_continuation)
 
237
    {
 
238
      memcpy (t->register_backing_store_base,
 
239
              t->pending_rbs_continuation->backing_store,
 
240
              t->pending_rbs_continuation->backing_store_size);
 
241
      t->pending_rbs_continuation = NULL;
 
242
    }
 
243
  setcontext (&JB->ctx);
 
244
}
245
245
#endif
246
 
}
247
246
 
248
247
/* Call grow_stack until the stack space is large enough, then, as the current
249
248
 * stack frame might get overwritten, let copy_stack_and_call perform the