1 /*
2  * Part of Scheme 48 1.9.  See file COPYING for notices and license.
3  *
4  * Authors: Richard Kelsey, Jonathan Rees, Mike Sperber, Marcus Crestani
5  */
6 
7 /*
8  * Externally visible objects defined in scheme48vm.c.
9  */
10 
11 #include "scheme48.h"
12 #include "c-mods.h"
13 
14 /* initializing */
15 extern void		s48_init(void);
16 extern long		s48_initialize(int *argc, char ***argv);
17 extern void		s48_initialize_vm(char *, long);
18 
19 /* running */
20 extern long		s48_call_startup_procedure(char **, long);
21 extern s48_value	s48_restart(s48_value proc, long nargs);
22 extern s48_value	s48_Scallback_return_stack_blockS;
23 
24 /* for extension.c */
25 extern void		s48_set_extension_valueB(s48_value);
26 extern s48_value	s48_Sextension_valueS;
27 
28 /* interrupts */
29 extern void		s48_note_event(void);
30 extern psbool		s48_Spending_eventsPS;
31 extern char *		s48_Sstack_limitS;
32 extern void		s48_disable_interruptsB(void);
33 extern void		s48_enable_interruptsB(void);
34 extern void		s48_set_os_signals(s48_value list);
35 extern void		s48_reset_interruptsB();
36 extern char		s48_os_signal_pending(void);
37 extern void		s48_note_external_eventBUunsafe(long);
38 extern char		s48_external_event_readyPUunsafe(void);
39 extern char		s48_external_event_pendingPUunsafe(void);
40 extern long		s48_dequeue_external_eventBUunsafe(char*);
41 
42 /* imported and exported bindings */
43 S48_EXTERN s48_value	s48_define_exported_binding(char *, s48_value);
44 S48_EXTERN s48_value	s48_get_imported_binding(char *);
45 
46 /* for raising exceptions in external code */
47 extern void		s48_setup_external_exception(s48_value exception,
48 						     long nargs);
49 extern s48_value	s48_resetup_external_exception(s48_value exception,
50 						       long additional_nargs);
51 extern void		s48_argument_type_violation(s48_value value);
52 extern void		s48_range_violation(s48_value value, s48_value min, s48_value max);
53 extern void		s48_push(s48_value value);
54 extern s48_value	s48_stack_ref(long offset);
55 extern void		s48_stack_setB(long offset, s48_value value);
56 
57 /* strings */
58 
59 S48_EXTERN s48_value	s48_allocate_string(long l);
60 
61 extern s48_value s48_enter_string_utf_16beU(char *);
62 extern s48_value s48_enter_string_utf_16be_nU(char *, long);
63 extern long s48_copy_string_to_utf_16beU(s48_value, char *);
64 extern long s48_copy_string_to_utf_16be_nU(s48_value, long, long, char *);
65 
66 extern s48_value s48_enter_string_utf_16leU(char *);
67 extern s48_value s48_enter_string_utf_16le_nU(char *, long);
68 extern long s48_copy_string_to_utf_16leU(s48_value, char *);
69 extern long s48_copy_string_to_utf_16le_nU(s48_value, long, long, char *);
70 
71 /* called when writing an image */
72 extern s48_value	s48_symbol_table(void);
73 extern s48_value	*s48_channels(void);
74 extern long		s48_channel_count(void);
75 extern s48_value	s48_imported_bindings(void);
76 extern s48_value	s48_exported_bindings(void);
77 
78 /* for initializion on SMP machines */
79 extern void		s48_initialize_shared_registersB(long, long, long, long);
80 
81 /* manipulating channels */
82 S48_EXTERN void		s48_close_channel(long);
83 S48_EXTERN s48_value	s48_set_channel_os_index(s48_value, long);
84 extern s48_value	s48_really_add_channel(s48_value, s48_value, long);
85 
86 /* external allocation and GC roots */
87 extern void		s48_gc_root(void);
88 extern long		s48_gc_run_time(long *);
89 extern s48_value	s48_allocate_stob(long type, long size);
90 extern s48_value	s48_allocate_weak_stob(long type, long size);
91 extern s48_value	s48_allocate_unmovable_stob(long type, long size);
92 extern psbool		s48_unmovableP(s48_value);
93 extern psbool		s48_gc_can_allocate_unmovableP(void);
94 S48_EXTERN void		s48_push_gc_rootsB(char *, long);
95 S48_EXTERN psbool	s48_pop_gc_rootsB(void);
96 extern char *		s48_set_gc_roots_baseB(void);
97 extern psbool		s48_release_gc_roots_baseB(char *);
98 S48_EXTERN char *	s48_register_gc_rootB(char *);
99 S48_EXTERN void		s48_unregister_gc_rootB(char *);
100 extern void		s48_reset_external_rootsB(void);
101 extern void		s48_post_gc_cleanup(psbool, psbool);
102 extern void		s48_trace_external_calls(void);
103 
104 /* for native code */
105 extern void		s48_copy_stack_into_heap();
106 
107 /* variables for native code (the names need to be fixed) */
108 extern s48_value	StemplateS;
109 extern char *		Scode_pointerS;
110 extern char *		ScontS;
111 extern char *		SstackS;
112 extern s48_value	SenvS;
113 extern s48_value	SvalS;
114 extern long	        s48_Snative_protocolS;
115