continuations.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* classes: h_files */
  2. #ifndef CONTINUATIONSH
  3. #define CONTINUATIONSH
  4. /* Copyright (C) 1995, 1996, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this software; see the file COPYING. If not, write to
  18. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301 USA
  20. *
  21. * As a special exception, the Free Software Foundation gives permission
  22. * for additional uses of the text contained in its release of GUILE.
  23. *
  24. * The exception is that, if you link the GUILE library with other files
  25. * to produce an executable, this does not by itself cause the
  26. * resulting executable to be covered by the GNU General Public License.
  27. * Your use of that executable is in no way restricted on account of
  28. * linking the GUILE library code into it.
  29. *
  30. * This exception does not however invalidate any other reasons why
  31. * the executable file might be covered by the GNU General Public License.
  32. *
  33. * This exception applies only to the code released by the
  34. * Free Software Foundation under the name GUILE. If you copy
  35. * code from other Free Software Foundation releases into a copy of
  36. * GUILE, as the General Public License permits, the exception does
  37. * not apply to the code that you add in this way. To avoid misleading
  38. * anyone as to the status of such modified files, you must delete
  39. * this exception notice from them.
  40. *
  41. * If you write modifications of your own for GUILE, it is your choice
  42. * whether to permit this exception to apply to your modifications.
  43. * If you do not wish that, delete this exception notice. */
  44. #include "libguile/__scm.h"
  45. #ifdef __ia64__
  46. #include <ucontext.h>
  47. extern unsigned long __libc_ia64_register_backing_store_base;
  48. #endif
  49. /* a continuation SCM is a non-immediate pointing to a heap cell with:
  50. word 0: bits 0-15: smob type tag: scm_tc16_continuation.
  51. bits 16-31: unused.
  52. word 1: malloc block containing an scm_t_contregs structure with a
  53. tail array of SCM_STACKITEM. the size of the array is stored
  54. in the num_stack_items field of the structure.
  55. */
  56. extern scm_t_bits scm_tc16_continuation;
  57. typedef struct
  58. {
  59. SCM throw_value;
  60. jmp_buf jmpbuf;
  61. SCM dynenv;
  62. #ifdef __ia64__
  63. ucontext_t ctx;
  64. void *backing_store;
  65. unsigned long backing_store_size;
  66. #endif /* __ia64__ */
  67. SCM_STACKITEM *base; /* base of the live stack, before it was saved. */
  68. size_t num_stack_items; /* size of the saved stack. */
  69. unsigned long seq; /* dynamic root identifier. */
  70. /* The offset from the live stack location and this copy. This is
  71. used to adjust pointers from within the copied stack to the stack
  72. itself.
  73. Thus, when you read a pointer from the copied stack that points
  74. into the live stack, you need to add OFFSET to that it points
  75. into the copy.
  76. */
  77. long offset;
  78. #ifdef DEBUG_EXTENSIONS
  79. /* The most recently created debug frame on the live stack, before
  80. it was saved. This needs to be adjusted with OFFSET, above.
  81. */
  82. struct scm_t_debug_frame *dframe;
  83. #endif
  84. SCM_STACKITEM stack[1]; /* copied stack of size num_stack_items. */
  85. } scm_t_contregs;
  86. #if (SCM_DEBUG_DEPRECATED == 0)
  87. # define scm_contregs scm_t_contregs
  88. #endif
  89. #define SCM_CONTINUATIONP(x) SCM_TYP16_PREDICATE (scm_tc16_continuation, x)
  90. #define SCM_CONTREGS(x) ((scm_t_contregs *) SCM_CELL_WORD_1 (x))
  91. #define SCM_CONTINUATION_LENGTH(x) (SCM_CONTREGS (x)->num_stack_items)
  92. #define SCM_SET_CONTINUATION_LENGTH(x,n)\
  93. (SCM_CONTREGS (x)->num_stack_items = (n))
  94. #define SCM_JMPBUF(x) ((SCM_CONTREGS (x))->jmpbuf)
  95. #define SCM_DYNENV(x) ((SCM_CONTREGS (x))->dynenv)
  96. #define SCM_THROW_VALUE(x) ((SCM_CONTREGS (x))->throw_value)
  97. #define SCM_BASE(x) ((SCM_CONTREGS (x))->base)
  98. #define SCM_SEQ(x) ((SCM_CONTREGS (x))->seq)
  99. #define SCM_DFRAME(x) ((SCM_CONTREGS (x))->dframe)
  100. extern SCM scm_make_continuation (int *first);
  101. extern void scm_init_continuations (void);
  102. #endif /* CONTINUATIONSH */
  103. /*
  104. Local Variables:
  105. c-file-style: "gnu"
  106. End:
  107. */