continuations.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /* Copyright (C) 1995,1996,1998,2000,2001,2004, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public License
  5. * as published by the Free Software Foundation; either version 3 of
  6. * the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. * 02110-1301 USA
  17. */
  18. #ifdef HAVE_CONFIG_H
  19. # include <config.h>
  20. #endif
  21. #include "libguile/_scm.h"
  22. #include <assert.h>
  23. #include <string.h>
  24. #include <stdio.h>
  25. #include "libguile/async.h"
  26. #include "libguile/debug.h"
  27. #include "libguile/root.h"
  28. #include "libguile/stackchk.h"
  29. #include "libguile/smob.h"
  30. #include "libguile/ports.h"
  31. #include "libguile/dynstack.h"
  32. #include "libguile/eval.h"
  33. #include "libguile/vm.h"
  34. #include "libguile/instructions.h"
  35. #include "libguile/validate.h"
  36. #include "libguile/continuations.h"
  37. static scm_t_bits tc16_continuation;
  38. #define SCM_CONTREGSP(x) SCM_TYP16_PREDICATE (tc16_continuation, x)
  39. #define SCM_CONTREGS(x) ((scm_t_contregs *) SCM_SMOB_DATA_1 (x))
  40. #define SCM_CONTINUATION_LENGTH(x) (SCM_CONTREGS (x)->num_stack_items)
  41. #define SCM_SET_CONTINUATION_LENGTH(x, n)\
  42. (SCM_CONTREGS (x)->num_stack_items = (n))
  43. #define SCM_JMPBUF(x) ((SCM_CONTREGS (x))->jmpbuf)
  44. #define SCM_CONTINUATION_ROOT(x) ((SCM_CONTREGS (x))->root)
  45. #define SCM_DFRAME(x) ((SCM_CONTREGS (x))->dframe)
  46. /* scm_i_make_continuation will return a procedure whose objcode contains an
  47. instruction to reinstate the continuation. Here, as in gsubr.c and smob.c, we
  48. define the form of that trampoline function.
  49. */
  50. #ifdef WORDS_BIGENDIAN
  51. #define OBJCODE_HEADER(main,meta) 0, 0, 0, main, 0, 0, 0, meta+8
  52. #define META_HEADER(meta) 0, 0, 0, meta, 0, 0, 0, 0
  53. #else
  54. #define OBJCODE_HEADER(main,meta) main, 0, 0, 0, meta+8, 0, 0, 0
  55. #define META_HEADER(meta) meta, 0, 0, 0, 0, 0, 0, 0
  56. #endif
  57. #define OBJCODE_TAG SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_STATIC, 0)
  58. #if defined (SCM_ALIGNED) && 0
  59. #define SCM_DECLARE_STATIC_ALIGNED_ARRAY(type, sym) \
  60. static const type sym[]
  61. #define SCM_STATIC_ALIGNED_ARRAY(alignment, type, sym) \
  62. static SCM_ALIGNED (alignment) const type sym[]
  63. #define SCM_STATIC_OBJCODE(sym) \
  64. SCM_DECLARE_STATIC_ALIGNED_ARRAY (scm_t_uint8, sym##__bytecode); \
  65. SCM_STATIC_ALIGNED_ARRAY (8, scm_t_cell, sym##__cells) = { \
  66. { SCM_PACK (OBJCODE_TAG), SCM_PACK (sym##__bytecode) }, \
  67. { SCM_BOOL_F, SCM_PACK (0) } \
  68. }; \
  69. static const SCM sym = SCM_PACK (sym##__cells); \
  70. SCM_STATIC_ALIGNED_ARRAY (8, scm_t_uint8, sym##__bytecode)
  71. #else
  72. #define SCM_STATIC_OBJCODE(sym) \
  73. static SCM sym; \
  74. static scm_t_uint8 *sym##_bytecode; \
  75. SCM_SNARF_INIT(sym##_bytecode = scm_gc_malloc_pointerless (sizeof(sym##_bytecode__unaligned), "partial continuation stub"); \
  76. memcpy (sym##_bytecode, sym##_bytecode__unaligned, sizeof(sym##_bytecode__unaligned));) \
  77. SCM_SNARF_INIT(sym = scm_double_cell (OBJCODE_TAG, \
  78. (scm_t_bits)sym##_bytecode, \
  79. SCM_UNPACK (SCM_BOOL_F), \
  80. 0);) \
  81. static const scm_t_uint8 sym##_bytecode__unaligned[]
  82. #endif
  83. SCM_STATIC_OBJCODE (cont_objcode) = {
  84. /* This code is the same as in gsubr.c, except we use continuation_call
  85. instead of subr_call. */
  86. OBJCODE_HEADER (8, 19),
  87. /* leave args on the stack */
  88. /* 0 */ scm_op_object_ref, 0, /* push scm_t_contregs smob */
  89. /* 2 */ scm_op_continuation_call, /* and longjmp (whee) */
  90. /* 3 */ scm_op_nop, /* pad to 8 bytes */
  91. /* 4 */ scm_op_nop, scm_op_nop, scm_op_nop, scm_op_nop,
  92. /* 8 */
  93. /* We could put some meta-info to say that this proc is a continuation. Not sure
  94. how to do that, though. */
  95. META_HEADER (19),
  96. /* 0 */ scm_op_make_eol, /* bindings */
  97. /* 1 */ scm_op_make_eol, /* sources */
  98. /* 2 */ scm_op_make_int8, 0, scm_op_make_int8, 3, /* arity: from ip 0 to ip 3 */
  99. /* 6 */ scm_op_make_int8_0, /* the arity is 0 required args */
  100. /* 7 */ scm_op_make_int8_0, /* 0 optionals */
  101. /* 8 */ scm_op_make_true, /* and a rest arg */
  102. /* 9 */ scm_op_list, 0, 5, /* make a list of those 5 vals */
  103. /* 12 */ scm_op_list, 0, 1, /* and the arities will be a list of that one list */
  104. /* 15 */ scm_op_list, 0, 3, /* pack bindings, sources, and arities into list */
  105. /* 18 */ scm_op_return /* and return */
  106. /* 19 */
  107. };
  108. SCM_STATIC_OBJCODE (call_cc_objcode) = {
  109. /* Before Scheme's call/cc is compiled, eval.c will use this hand-coded
  110. call/cc. */
  111. OBJCODE_HEADER (8, 17),
  112. /* 0 */ scm_op_assert_nargs_ee, 0, 1, /* assert that nargs==1 */
  113. /* 3 */ scm_op_local_ref, 0, /* push the proc */
  114. /* 5 */ scm_op_tail_call_cc, /* and call/cc */
  115. /* 6 */ scm_op_nop, scm_op_nop, /* pad to 8 bytes */
  116. /* 8 */
  117. META_HEADER (17),
  118. /* 0 */ scm_op_make_eol, /* bindings */
  119. /* 1 */ scm_op_make_eol, /* sources */
  120. /* 2 */ scm_op_make_int8, 3, scm_op_make_int8, 6, /* arity: from ip 0 to ip 6 */
  121. /* 6 */ scm_op_make_int8_1, /* the arity is 0 required args */
  122. /* 7 */ scm_op_list, 0, 3, /* make a list of those 5 vals */
  123. /* 10 */ scm_op_list, 0, 1, /* and the arities will be a list of that one list */
  124. /* 13 */ scm_op_list, 0, 3, /* pack bindings, sources, and arities into list */
  125. /* 16 */ scm_op_return /* and return */
  126. /* 17 */
  127. };
  128. static SCM
  129. make_continuation_trampoline (SCM contregs)
  130. {
  131. SCM ret = scm_make_program (cont_objcode,
  132. scm_c_make_vector (1, contregs),
  133. SCM_BOOL_F);
  134. SCM_SET_CELL_WORD_0 (ret,
  135. SCM_CELL_WORD_0 (ret) | SCM_F_PROGRAM_IS_CONTINUATION);
  136. return ret;
  137. }
  138. /* {Continuations}
  139. */
  140. static int
  141. continuation_print (SCM obj, SCM port, scm_print_state *state SCM_UNUSED)
  142. {
  143. scm_t_contregs *continuation = SCM_CONTREGS (obj);
  144. scm_puts_unlocked ("#<continuation ", port);
  145. scm_intprint (continuation->num_stack_items, 10, port);
  146. scm_puts_unlocked (" @ ", port);
  147. scm_uintprint (SCM_SMOB_DATA_1 (obj), 16, port);
  148. scm_putc_unlocked ('>', port);
  149. return 1;
  150. }
  151. /* James Clark came up with this neat one instruction fix for
  152. * continuations on the SPARC. It flushes the register windows so
  153. * that all the state of the process is contained in the stack.
  154. */
  155. #if defined (sparc) || defined (__sparc__) || defined (__sparc)
  156. # define SCM_FLUSH_REGISTER_WINDOWS asm("ta 3")
  157. #else
  158. # define SCM_FLUSH_REGISTER_WINDOWS /* empty */
  159. #endif
  160. /* this may return more than once: the first time with the escape
  161. procedure, then subsequently with SCM_UNDEFINED (the vals already having been
  162. placed on the VM stack). */
  163. #define FUNC_NAME "scm_i_make_continuation"
  164. SCM
  165. scm_i_make_continuation (int *first, SCM vm, SCM vm_cont)
  166. {
  167. scm_i_thread *thread = SCM_I_CURRENT_THREAD;
  168. SCM cont;
  169. scm_t_contregs *continuation;
  170. long stack_size;
  171. SCM_STACKITEM * src;
  172. SCM_FLUSH_REGISTER_WINDOWS;
  173. stack_size = scm_stack_size (thread->continuation_base);
  174. continuation = scm_gc_malloc (sizeof (scm_t_contregs)
  175. + (stack_size - 1) * sizeof (SCM_STACKITEM),
  176. "continuation");
  177. continuation->num_stack_items = stack_size;
  178. continuation->root = thread->continuation_root;
  179. src = thread->continuation_base;
  180. #if ! SCM_STACK_GROWS_UP
  181. src -= stack_size;
  182. #endif
  183. continuation->offset = continuation->stack - src;
  184. memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size);
  185. continuation->vm = vm;
  186. continuation->vm_cont = vm_cont;
  187. SCM_NEWSMOB (cont, tc16_continuation, continuation);
  188. *first = !SCM_I_SETJMP (continuation->jmpbuf);
  189. if (*first)
  190. {
  191. #ifdef __ia64__
  192. continuation->backing_store_size =
  193. (char *) scm_ia64_ar_bsp(&continuation->jmpbuf.ctx)
  194. -
  195. (char *) thread->register_backing_store_base;
  196. continuation->backing_store = NULL;
  197. continuation->backing_store =
  198. scm_gc_malloc (continuation->backing_store_size,
  199. "continuation backing store");
  200. memcpy (continuation->backing_store,
  201. (void *) thread->register_backing_store_base,
  202. continuation->backing_store_size);
  203. #endif /* __ia64__ */
  204. return make_continuation_trampoline (cont);
  205. }
  206. else
  207. return SCM_UNDEFINED;
  208. }
  209. #undef FUNC_NAME
  210. SCM
  211. scm_i_call_with_current_continuation (SCM proc)
  212. {
  213. static SCM call_cc = SCM_BOOL_F;
  214. if (scm_is_false (call_cc))
  215. call_cc = scm_make_program (call_cc_objcode, SCM_BOOL_F, SCM_BOOL_F);
  216. return scm_call_1 (call_cc, proc);
  217. }
  218. SCM
  219. scm_i_continuation_to_frame (SCM continuation)
  220. {
  221. SCM contregs;
  222. scm_t_contregs *cont;
  223. contregs = scm_c_vector_ref (scm_program_objects (continuation), 0);
  224. cont = SCM_CONTREGS (contregs);
  225. if (scm_is_true (cont->vm_cont))
  226. {
  227. struct scm_vm_cont *data = SCM_VM_CONT_DATA (cont->vm_cont);
  228. return scm_c_make_frame (cont->vm_cont,
  229. data->fp + data->reloc,
  230. data->sp + data->reloc,
  231. data->ra,
  232. data->reloc);
  233. }
  234. else
  235. return SCM_BOOL_F;
  236. }
  237. SCM
  238. scm_i_contregs_vm (SCM contregs)
  239. {
  240. return SCM_CONTREGS (contregs)->vm;
  241. }
  242. SCM
  243. scm_i_contregs_vm_cont (SCM contregs)
  244. {
  245. return SCM_CONTREGS (contregs)->vm_cont;
  246. }
  247. /* {Apply}
  248. */
  249. /* Invoking a continuation proceeds as follows:
  250. *
  251. * - the stack is made large enough for the called continuation
  252. * - the old windchain is unwound down to the branching point
  253. * - the continuation stack is copied into place
  254. * - the windchain is rewound up to the continuation's context
  255. * - the continuation is invoked via longjmp (or setcontext)
  256. *
  257. * This order is important so that unwind and rewind handlers are run
  258. * with their correct stack.
  259. */
  260. static void scm_dynthrow (SCM);
  261. /* Grow the stack by a fixed amount to provide space to copy in the
  262. * continuation. Possibly this function has to be called several times
  263. * recursively before enough space is available. Make sure the compiler does
  264. * not optimize the growth array away by storing it's address into a global
  265. * variable.
  266. */
  267. static scm_t_bits scm_i_dummy;
  268. static void
  269. grow_stack (SCM cont)
  270. {
  271. scm_t_bits growth[100];
  272. scm_i_dummy = (scm_t_bits) growth;
  273. scm_dynthrow (cont);
  274. }
  275. /* Copy the continuation stack into the current stack. Calling functions from
  276. * within this function is safe, since only stack frames below this function's
  277. * own frame are overwritten. Thus, memcpy can be used for best performance.
  278. */
  279. static void
  280. copy_stack_and_call (scm_t_contregs *continuation,
  281. SCM_STACKITEM * dst)
  282. {
  283. scm_t_dynstack *dynstack;
  284. scm_t_bits *joint;
  285. scm_i_thread *thread = SCM_I_CURRENT_THREAD;
  286. dynstack = SCM_VM_CONT_DATA (continuation->vm_cont)->dynstack;
  287. joint = scm_dynstack_unwind_fork (&thread->dynstack, dynstack);
  288. memcpy (dst, continuation->stack,
  289. sizeof (SCM_STACKITEM) * continuation->num_stack_items);
  290. #ifdef __ia64__
  291. thread->pending_rbs_continuation = continuation;
  292. #endif
  293. scm_dynstack_wind (&thread->dynstack, joint);
  294. SCM_I_LONGJMP (continuation->jmpbuf, 1);
  295. }
  296. #ifdef __ia64__
  297. void
  298. scm_ia64_longjmp (scm_i_jmp_buf *JB, int VAL)
  299. {
  300. scm_i_thread *t = SCM_I_CURRENT_THREAD;
  301. if (t->pending_rbs_continuation)
  302. {
  303. memcpy (t->register_backing_store_base,
  304. t->pending_rbs_continuation->backing_store,
  305. t->pending_rbs_continuation->backing_store_size);
  306. t->pending_rbs_continuation = NULL;
  307. }
  308. setcontext (&JB->ctx);
  309. }
  310. #endif
  311. /* Call grow_stack until the stack space is large enough, then, as the current
  312. * stack frame might get overwritten, let copy_stack_and_call perform the
  313. * actual copying and continuation calling.
  314. */
  315. static void
  316. scm_dynthrow (SCM cont)
  317. {
  318. scm_i_thread *thread = SCM_I_CURRENT_THREAD;
  319. scm_t_contregs *continuation = SCM_CONTREGS (cont);
  320. SCM_STACKITEM *dst = thread->continuation_base;
  321. SCM_STACKITEM stack_top_element;
  322. if (thread->critical_section_level)
  323. {
  324. fprintf (stderr, "continuation invoked from within critical section.\n");
  325. abort ();
  326. }
  327. #if SCM_STACK_GROWS_UP
  328. if (dst + continuation->num_stack_items >= &stack_top_element)
  329. grow_stack (cont);
  330. #else
  331. dst -= continuation->num_stack_items;
  332. if (dst <= &stack_top_element)
  333. grow_stack (cont);
  334. #endif /* def SCM_STACK_GROWS_UP */
  335. SCM_FLUSH_REGISTER_WINDOWS;
  336. copy_stack_and_call (continuation, dst);
  337. }
  338. void
  339. scm_i_check_continuation (SCM cont)
  340. {
  341. scm_i_thread *thread = SCM_I_CURRENT_THREAD;
  342. scm_t_contregs *continuation = SCM_CONTREGS (cont);
  343. if (!scm_is_eq (continuation->root, thread->continuation_root))
  344. scm_misc_error
  345. ("%continuation-call",
  346. "invoking continuation would cross continuation barrier: ~A",
  347. scm_list_1 (cont));
  348. }
  349. void
  350. scm_i_reinstate_continuation (SCM cont)
  351. {
  352. scm_dynthrow (cont);
  353. }
  354. SCM
  355. scm_i_with_continuation_barrier (scm_t_catch_body body,
  356. void *body_data,
  357. scm_t_catch_handler handler,
  358. void *handler_data,
  359. scm_t_catch_handler pre_unwind_handler,
  360. void *pre_unwind_handler_data)
  361. {
  362. SCM_STACKITEM stack_item;
  363. scm_i_thread *thread = SCM_I_CURRENT_THREAD;
  364. SCM old_controot;
  365. SCM_STACKITEM *old_contbase;
  366. SCM result;
  367. /* Establish a fresh continuation root.
  368. */
  369. old_controot = thread->continuation_root;
  370. old_contbase = thread->continuation_base;
  371. thread->continuation_root = scm_cons (thread->handle, old_controot);
  372. thread->continuation_base = &stack_item;
  373. /* Call FUNC inside a catch all. This is now guaranteed to return
  374. directly and exactly once.
  375. */
  376. result = scm_c_catch (SCM_BOOL_T,
  377. body, body_data,
  378. handler, handler_data,
  379. pre_unwind_handler, pre_unwind_handler_data);
  380. /* Return to old continuation root.
  381. */
  382. thread->continuation_base = old_contbase;
  383. thread->continuation_root = old_controot;
  384. return result;
  385. }
  386. static int
  387. should_print_backtrace (SCM tag, SCM stack)
  388. {
  389. return SCM_BACKTRACE_P
  390. && scm_is_true (stack)
  391. && scm_initialized_p
  392. /* It's generally not useful to print backtraces for errors reading
  393. or expanding code in these fallback catch statements. */
  394. && !scm_is_eq (tag, scm_from_latin1_symbol ("read-error"))
  395. && !scm_is_eq (tag, scm_from_latin1_symbol ("syntax-error"));
  396. }
  397. static void
  398. print_exception_and_backtrace (SCM port, SCM tag, SCM args)
  399. {
  400. SCM stack, frame;
  401. /* We get here via a throw to a catch-all. In that case there is the
  402. throw frame active, and this catch closure, so narrow by two
  403. frames. */
  404. stack = scm_make_stack (SCM_BOOL_T, scm_list_1 (scm_from_int (2)));
  405. frame = scm_is_true (stack) ? scm_stack_ref (stack, SCM_INUM0) : SCM_BOOL_F;
  406. if (should_print_backtrace (tag, stack))
  407. {
  408. scm_puts_unlocked ("Backtrace:\n", port);
  409. scm_display_backtrace_with_highlights (stack, port,
  410. SCM_BOOL_F, SCM_BOOL_F,
  411. SCM_EOL);
  412. scm_newline (port);
  413. }
  414. scm_print_exception (port, frame, tag, args);
  415. }
  416. struct c_data {
  417. void *(*func) (void *);
  418. void *data;
  419. void *result;
  420. };
  421. static SCM
  422. c_body (void *d)
  423. {
  424. struct c_data *data = (struct c_data *)d;
  425. data->result = data->func (data->data);
  426. return SCM_UNSPECIFIED;
  427. }
  428. static SCM
  429. c_handler (void *d, SCM tag, SCM args)
  430. {
  431. struct c_data *data;
  432. /* If TAG is `quit', exit() the process. */
  433. if (scm_is_eq (tag, scm_from_latin1_symbol ("quit")))
  434. exit (scm_exit_status (args));
  435. data = (struct c_data *)d;
  436. data->result = NULL;
  437. return SCM_UNSPECIFIED;
  438. }
  439. static SCM
  440. pre_unwind_handler (void *error_port, SCM tag, SCM args)
  441. {
  442. /* Print the exception unless TAG is `quit'. */
  443. if (!scm_is_eq (tag, scm_from_latin1_symbol ("quit")))
  444. print_exception_and_backtrace (SCM_PACK_POINTER (error_port), tag, args);
  445. return SCM_UNSPECIFIED;
  446. }
  447. void *
  448. scm_c_with_continuation_barrier (void *(*func) (void *), void *data)
  449. {
  450. struct c_data c_data;
  451. c_data.func = func;
  452. c_data.data = data;
  453. scm_i_with_continuation_barrier (c_body, &c_data,
  454. c_handler, &c_data,
  455. pre_unwind_handler,
  456. SCM_UNPACK_POINTER (scm_current_error_port ()));
  457. return c_data.result;
  458. }
  459. struct scm_data {
  460. SCM proc;
  461. };
  462. static SCM
  463. scm_body (void *d)
  464. {
  465. struct scm_data *data = (struct scm_data *)d;
  466. return scm_call_0 (data->proc);
  467. }
  468. static SCM
  469. scm_handler (void *d, SCM tag, SCM args)
  470. {
  471. /* Print a message. Note that if TAG is `quit', this will exit() the
  472. process. */
  473. scm_handle_by_message_noexit (NULL, tag, args);
  474. return SCM_BOOL_F;
  475. }
  476. SCM_DEFINE (scm_with_continuation_barrier, "with-continuation-barrier", 1,0,0,
  477. (SCM proc),
  478. "Call @var{proc} and return its result. Do not allow the invocation of\n"
  479. "continuations that would leave or enter the dynamic extent of the call\n"
  480. "to @code{with-continuation-barrier}. Such an attempt causes an error\n"
  481. "to be signaled.\n"
  482. "\n"
  483. "Throws (such as errors) that are not caught from within @var{proc} are\n"
  484. "caught by @code{with-continuation-barrier}. In that case, a short\n"
  485. "message is printed to the current error port and @code{#f} is returned.\n"
  486. "\n"
  487. "Thus, @code{with-continuation-barrier} returns exactly once.\n")
  488. #define FUNC_NAME s_scm_with_continuation_barrier
  489. {
  490. struct scm_data scm_data;
  491. scm_data.proc = proc;
  492. return scm_i_with_continuation_barrier (scm_body, &scm_data,
  493. scm_handler, &scm_data,
  494. pre_unwind_handler,
  495. SCM_UNPACK_POINTER (scm_current_error_port ()));
  496. }
  497. #undef FUNC_NAME
  498. void
  499. scm_init_continuations ()
  500. {
  501. tc16_continuation = scm_make_smob_type ("continuation", 0);
  502. scm_set_smob_print (tc16_continuation, continuation_print);
  503. #include "libguile/continuations.x"
  504. }
  505. /*
  506. Local Variables:
  507. c-file-style: "gnu"
  508. End:
  509. */