root.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* classes: h_files */
  2. #ifndef ROOTH
  3. #define ROOTH
  4. /* Copyright (C) 1996,1998, 2000, 2002 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., 59 Temple Place, Suite 330,
  19. * Boston, MA 02111-1307 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. #include "libguile/debug.h"
  46. #include "libguile/throw.h"
  47. #define scm_flo0 scm_sys_protects[0]
  48. #define scm_listofnull scm_sys_protects[1]
  49. #define scm_undefineds scm_sys_protects[2]
  50. #define scm_nullvect scm_sys_protects[3]
  51. #define scm_nullstr scm_sys_protects[4]
  52. #define scm_symhash scm_sys_protects[5]
  53. #define scm_weak_symhash scm_sys_protects[6]
  54. #define scm_symhash_vars scm_sys_protects[7]
  55. #define scm_keyword_obarray scm_sys_protects[8]
  56. #define scm_type_obj_list scm_sys_protects[9]
  57. #define scm_first_type scm_sys_protects[10]
  58. #define scm_stand_in_procs scm_sys_protects[11]
  59. #define scm_object_whash scm_sys_protects[12]
  60. #define scm_permobjs scm_sys_protects[13]
  61. #define scm_asyncs scm_sys_protects[14]
  62. #define scm_protects scm_sys_protects[15]
  63. #ifdef DEBUG_EXTENSIONS
  64. #define scm_source_whash scm_sys_protects[16]
  65. #define SCM_NUM_PROTECTS 17
  66. #else
  67. #define SCM_NUM_PROTECTS 16
  68. #endif
  69. extern SCM scm_sys_protects[];
  70. extern long scm_tc16_root;
  71. #define SCM_ROOTP(obj) (SCM_NIMP(obj) && (scm_tc16_root == SCM_TYP16 (obj)))
  72. #define SCM_ROOT_STATE(root) ((scm_root_state *) SCM_CELL_WORD_1 (root))
  73. typedef struct scm_root_state
  74. {
  75. SCM_STACKITEM * stack_base;
  76. jmp_buf save_regs_gc_mark;
  77. int errjmp_bad;
  78. SCM rootcont;
  79. SCM dynwinds;
  80. SCM continuation_stack;
  81. SCM continuation_stack_ptr;
  82. #ifdef DEBUG_EXTENSIONS
  83. /* It is very inefficient to have this variable in the root state. */
  84. scm_debug_frame *last_debug_frame;
  85. #endif
  86. SCM progargs; /* vestigial */
  87. SCM exitval; /* vestigial */
  88. SCM cur_inp;
  89. SCM cur_outp;
  90. SCM cur_errp;
  91. SCM def_inp;
  92. SCM def_outp;
  93. SCM def_errp;
  94. SCM cur_loadp;
  95. SCM fluids;
  96. SCM system_transformer;
  97. SCM top_level_lookup_closure_var;
  98. SCM handle; /* The root object for this root state */
  99. SCM parent; /* The parent root object */
  100. } scm_root_state;
  101. #define scm_stack_base (scm_root->stack_base)
  102. #define scm_save_regs_gc_mark (scm_root->save_regs_gc_mark)
  103. #define scm_errjmp_bad (scm_root->errjmp_bad)
  104. #define scm_rootcont (scm_root->rootcont)
  105. #define scm_dynwinds (scm_root->dynwinds)
  106. #define scm_continuation_stack (scm_root->continuation_stack)
  107. #define scm_continuation_stack_ptr (scm_root->continuation_stack_ptr)
  108. #define scm_progargs (scm_root->progargs)
  109. #ifdef USE_THREADS
  110. #define scm_last_debug_frame (scm_root->last_debug_frame)
  111. #endif
  112. #define scm_exitval (scm_root->exitval)
  113. #define scm_cur_inp (scm_root->cur_inp)
  114. #define scm_cur_outp (scm_root->cur_outp)
  115. #define scm_cur_errp (scm_root->cur_errp)
  116. #define scm_def_inp (scm_root->def_inp)
  117. #define scm_def_outp (scm_root->def_outp)
  118. #define scm_def_errp (scm_root->def_errp)
  119. #define scm_cur_loadp (scm_root->cur_loadp)
  120. #define scm_top_level_lookup_closure_var \
  121. (scm_root->top_level_lookup_closure_var)
  122. #define scm_system_transformer (scm_root->system_transformer)
  123. #ifdef USE_THREADS
  124. #define scm_root ((scm_root_state *) SCM_THREAD_LOCAL_DATA)
  125. #define scm_set_root(new_root) SCM_SET_THREAD_LOCAL_DATA (new_root)
  126. #else /* USE_THREADS */
  127. extern struct scm_root_state *scm_root;
  128. #define scm_set_root(new_root) (scm_root = (new_root))
  129. #endif /* USE_THREADS */
  130. extern SCM scm_make_root (SCM parent);
  131. extern SCM scm_internal_cwdr (scm_catch_body_t body,
  132. void *body_data,
  133. scm_catch_handler_t handler,
  134. void *handler_data,
  135. SCM_STACKITEM *stack_start);
  136. extern SCM scm_call_with_dynamic_root (SCM thunk, SCM handler);
  137. extern SCM scm_dynamic_root (void);
  138. extern SCM scm_apply_with_dynamic_root (SCM proc, SCM a1, SCM args, SCM handler);
  139. extern SCM scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), void * closure);
  140. extern void scm_init_root (void);
  141. #endif /* ROOTH */
  142. /*
  143. Local Variables:
  144. c-file-style: "gnu"
  145. End:
  146. */