*** empty log message ***
[bpt/guile.git] / libguile / init.c
CommitLineData
16d35552 1/* Copyright (C) 1995,1996,1997,1998,1999, 2000 Free Software Foundation, Inc.
0f2d19dd
JB
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
82892bed
JB
15 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16 * Boston, MA 02111-1307 USA
0f2d19dd
JB
17 *
18 * As a special exception, the Free Software Foundation gives permission
19 * for additional uses of the text contained in its release of GUILE.
20 *
21 * The exception is that, if you link the GUILE library with other files
22 * to produce an executable, this does not by itself cause the
23 * resulting executable to be covered by the GNU General Public License.
24 * Your use of that executable is in no way restricted on account of
25 * linking the GUILE library code into it.
26 *
27 * This exception does not however invalidate any other reasons why
28 * the executable file might be covered by the GNU General Public License.
29 *
30 * This exception applies only to the code released by the
31 * Free Software Foundation under the name GUILE. If you copy
32 * code from other Free Software Foundation releases into a copy of
33 * GUILE, as the General Public License permits, the exception does
34 * not apply to the code that you add in this way. To avoid misleading
35 * anyone as to the status of such modified files, you must delete
36 * this exception notice from them.
37 *
38 * If you write modifications of your own for GUILE, it is your choice
39 * whether to permit this exception to apply to your modifications.
82892bed 40 * If you do not wish that, delete this exception notice. */
1bbd0b84
GB
41
42/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
43 gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
44
0f2d19dd 45\f
bdca1083
JB
46/* Include the headers for just about everything.
47 We call all their initialization functions. */
0f2d19dd
JB
48
49#include <stdio.h>
0a48b624
MV
50#include <sys/stat.h>
51#include <fcntl.h>
52
0f2d19dd
JB
53#include "_scm.h"
54
20e6290e
JB
55/* Everybody has an init function. */
56#include "alist.h"
20e6290e
JB
57#include "arbiters.h"
58#include "async.h"
0e44fcca 59#include "backtrace.h"
20e6290e
JB
60#include "boolean.h"
61#include "chars.h"
62#include "continuations.h"
63#ifdef DEBUG_EXTENSIONS
64#include "debug.h"
65#endif
6b815f1a
MD
66#ifdef GUILE_DEBUG_MALLOC
67#include "debug-malloc.h"
68#endif
70122cd3 69#include "dynl.h"
20e6290e
JB
70#include "dynwind.h"
71#include "eq.h"
72#include "error.h"
73#include "eval.h"
27a69f93 74#include "evalext.h"
20e6290e 75#include "feature.h"
20e6290e 76#include "filesys.h"
ee3ea81d 77#include "fluids.h"
20e6290e
JB
78#include "fports.h"
79#include "gc.h"
80#include "gdbint.h"
81#include "gsubr.h"
82#include "hash.h"
83#include "hashtab.h"
44e8413c
MD
84#ifdef GUILE_ISELECT
85#include "iselect.h"
86#endif
20e6290e 87#include "ioext.h"
0e76bf66 88#include "keywords.h"
397daa3d 89#include "lang.h"
20e6290e
JB
90#include "list.h"
91#include "load.h"
27a69f93 92#include "macros.h"
20e6290e 93#include "mallocs.h"
345acb39 94#include "modules.h"
370312ae 95#include "net_db.h"
20e6290e 96#include "numbers.h"
0c32d76c 97#include "objects.h"
20e6290e
JB
98#include "objprop.h"
99#include "options.h"
100#include "pairs.h"
101#include "ports.h"
102#include "posix.h"
f255378e
JB
103#ifdef HAVE_REGCOMP
104#include "regex-posix.h"
105#endif
20e6290e
JB
106#include "print.h"
107#include "procprop.h"
108#include "procs.h"
109#include "ramap.h"
26ade7a2 110#include "random.h"
20e6290e
JB
111#include "read.h"
112#include "scmsigs.h"
964edde7 113#include "script.h"
20e6290e 114#include "simpos.h"
a8be22fe 115#include "smob.h"
20e6290e 116#include "socket.h"
26ade7a2 117#include "sort.h"
20e6290e
JB
118#include "srcprop.h"
119#include "stackchk.h"
0e44fcca 120#include "stacks.h"
20e6290e
JB
121#include "stime.h"
122#include "strings.h"
123#include "strop.h"
124#include "strorder.h"
125#include "strports.h"
126#include "struct.h"
127#include "symbols.h"
128#include "tag.h"
129#include "throw.h"
130#include "unif.h"
131#include "variable.h"
132#include "vectors.h"
133#include "version.h"
134#include "vports.h"
135#include "weaks.h"
f28b85f2 136#include "guardians.h"
20e6290e 137
a8be22fe
JB
138#include "init.h"
139
95b88819
GH
140#ifdef HAVE_STRING_H
141#include <string.h>
142#endif
143#ifdef HAVE_UNISTD_H
144#include <unistd.h>
145#endif
0f2d19dd 146\f
bdca1083 147/* Setting up the stack. */
0f2d19dd 148
1bbd0b84
GB
149static void
150restart_stack (void *base)
151{
152 scm_dynwinds = SCM_EOL;
153 SCM_DYNENV (scm_rootcont) = SCM_EOL;
154 SCM_THROW_VALUE (scm_rootcont) = SCM_EOL;
155#ifdef DEBUG_EXTENSIONS
156 SCM_DFRAME (scm_rootcont) = scm_last_debug_frame = 0;
157#endif
158 SCM_BASE (scm_rootcont) = base;
159 scm_continuation_stack_ptr = SCM_MAKINUM (0);
160}
1cdaaafb
JB
161
162static void
1bbd0b84 163start_stack (void *base)
0f2d19dd 164{
9ef3d0ee 165 SCM root;
0f2d19dd 166
9ef3d0ee
MD
167 root = scm_permanent_object (scm_make_root (SCM_UNDEFINED));
168 scm_set_root (SCM_ROOT_STATE (root));
0f2d19dd
JB
169 scm_stack_base = base;
170
0f2d19dd
JB
171 scm_exitval = SCM_BOOL_F; /* vestigial */
172
dc19d1d2 173 scm_top_level_lookup_closure_var = SCM_BOOL_F;
0f2d19dd
JB
174 scm_system_transformer = SCM_BOOL_F;
175
ee3ea81d
MV
176 scm_root->fluids = scm_make_initial_fluids ();
177
0f2d19dd
JB
178 /* Create an object to hold the root continuation.
179 */
180 SCM_NEWCELL (scm_rootcont);
8b3bda20
DH
181 SCM_SET_CONTREGS (scm_rootcont, scm_must_malloc (sizeof (scm_contregs),
182 "continuation"));
54778cd3 183 SCM_SET_CELL_TYPE (scm_rootcont, scm_tc7_contin);
4b5166ac 184 SCM_SEQ (scm_rootcont) = 0;
a4156763 185 /* The root continuation if further initialized by restart_stack. */
0f2d19dd
JB
186
187 /* Create the look-aside stack for variables that are shared between
188 * captured continuations.
189 */
a8741caa 190 scm_continuation_stack = scm_make_vector (SCM_MAKINUM (512), SCM_UNDEFINED);
a4156763 191 /* The continuation stack is further initialized by restart_stack. */
0f2d19dd 192
1cdaaafb
JB
193 /* The remainder of stack initialization is factored out to another
194 * function so that if this stack is ever exitted, it can be
a4156763
MD
195 * re-entered using restart_stack. */
196 restart_stack (base);
0f2d19dd
JB
197}
198
199
0f2d19dd
JB
200#if 0
201static char remsg[] = "remove\n#define ", addmsg[] = "add\n#define ";
202
1cc91f1b 203
0f2d19dd 204static void
1bbd0b84 205fixconfig (char *s1,char *s2,int s)
0f2d19dd
JB
206{
207 fputs (s1, stderr);
208 fputs (s2, stderr);
209 fputs ("\nin ", stderr);
210 fputs (s ? "setjump" : "scmfig", stderr);
211 fputs (".h and recompile scm\n", stderr);
212 exit (1);
213}
214
215
0f2d19dd 216static void
1bbd0b84 217check_config (void)
0f2d19dd
JB
218{
219 scm_sizet j;
220
221 j = HEAP_SEG_SIZE;
222 if (HEAP_SEG_SIZE != j)
223 fixconfig ("reduce", "size of HEAP_SEG_SIZE", 0);
224
0f2d19dd
JB
225#ifdef SCM_BIGDIG
226 if (2 * SCM_BITSPERDIG / SCM_CHAR_BIT > sizeof (long))
227 fixconfig (remsg, "SCM_BIGDIG", 0);
228#ifndef SCM_DIGSTOOBIG
229 if (SCM_DIGSPERLONG * sizeof (SCM_BIGDIG) > sizeof (long))
230 fixconfig (addmsg, "SCM_DIGSTOOBIG", 0);
231#endif
232#endif
233
234#ifdef SCM_STACK_GROWS_UP
235 if (((SCM_STACKITEM *) & j - stack_start_ptr) < 0)
236 fixconfig (remsg, "SCM_STACK_GROWS_UP", 1);
237#else
238 if ((stack_start_ptr - (SCM_STACKITEM *) & j) < 0)
239 fixconfig (addmsg, "SCM_STACK_GROWS_UP", 1);
240#endif
241}
242#endif
243
244
245\f
1cdaaafb
JB
246/* initializing standard and current I/O ports */
247
19b27fa2
GH
248typedef struct
249{
250 int fdes;
251 char *mode;
252 char *name;
253} stream_body_data;
254
255/* proc to be called in scope of exception handler stream_handler. */
ee149d03 256static SCM
19b27fa2 257stream_body (void *data)
ee149d03 258{
19b27fa2
GH
259 stream_body_data *body_data = (stream_body_data *) data;
260 SCM port = scm_fdes_to_port (body_data->fdes, body_data->mode,
261 scm_makfrom0str (body_data->name));
0a48b624 262
19b27fa2
GH
263 SCM_REVEALED (port) = 1;
264 return port;
265}
266
267/* exception handler for stream_body. */
268static SCM
269stream_handler (void *data, SCM tag, SCM throw_args)
270{
271 return SCM_BOOL_F;
272}
273
274/* Convert a file descriptor to a port, using scm_fdes_to_port.
275 - NAME is a C string, not a Guile string
276 - set the revealed count for FILE's file descriptor to 1, so
277 that fdes won't be closed when the port object is GC'd.
278 - catch exceptions: allow Guile to be able to start up even
70df8af6
GH
279 if it has been handed bogus stdin/stdout/stderr. replace the
280 bad ports with void ports. */
19b27fa2
GH
281static SCM
282scm_standard_stream_to_port (int fdes, char *mode, char *name)
283{
284 SCM port;
285 stream_body_data body_data;
286
287 body_data.fdes = fdes;
288 body_data.mode = mode;
289 body_data.name = name;
290 port = scm_internal_catch (SCM_BOOL_T, stream_body, &body_data,
291 stream_handler, NULL);
292 if (SCM_FALSEP (port))
70df8af6 293 port = scm_void_port (mode);
19b27fa2 294 return port;
ee149d03
JB
295}
296
297/* Create standard ports from stdin, stdout, and stderr. */
1cdaaafb
JB
298static void
299scm_init_standard_ports ()
300{
94754080
JB
301 /* From the SCSH manual:
302
303 It can be useful to turn I/O buffering off in some cases, for
304 example when an I/O stream is to be shared by multiple
305 subprocesses. For this reason, scsh allocates an unbuffered port
306 for file descriptor 0 at start-up time.
307
308 Because shells frequently share stdin with subprocesses, if the
309 shell does buffered reads, it might ``steal'' input intended for
310 a subprocess. For this reason, all shells, including sh, csh,
311 and scsh, read stdin unbuffered. Applications that can tolerate
312 buffered input on stdin can reset \ex{(current-input-port)} to
313 block buffering for higher performance. */
ee149d03 314
bc45012d 315 scm_def_inp
ee149d03
JB
316 = scm_standard_stream_to_port (0,
317 isatty (0) ? "r0" : "r",
1cdaaafb 318 "standard input");
ee149d03 319 scm_def_outp = scm_standard_stream_to_port (1,
720e8692 320 isatty (1) ? "w0" : "w",
ee149d03
JB
321 "standard output");
322 scm_def_errp = scm_standard_stream_to_port (2,
323 isatty (2) ? "w0" : "w",
324 "standard error");
1cdaaafb
JB
325
326 scm_cur_inp = scm_def_inp;
327 scm_cur_outp = scm_def_outp;
328 scm_cur_errp = scm_def_errp;
1a64191e 329 scm_cur_loadp = SCM_BOOL_F;
1cdaaafb
JB
330}
331
332
333\f
bdca1083
JB
334/* Loading the startup Scheme files. */
335
336/* The boot code "ice-9/boot-9" is only loaded by scm_boot_guile when
337 this is false. The unexec code uses this, to keep ice_9 from being
338 loaded into dumped guile executables. */
339int scm_ice_9_already_loaded = 0;
340
341void
342scm_load_startup_files ()
343{
344 /* We want a path only containing directories from GUILE_LOAD_PATH,
345 SCM_SITE_DIR and SCM_LIBRARY_DIR when searching for the site init
346 file, so we do this before loading Ice-9. */
347 SCM init_path = scm_sys_search_load_path (scm_makfrom0str ("init.scm"));
348
349 /* Load Ice-9. */
350 if (!scm_ice_9_already_loaded)
b505860d
MD
351 {
352 scm_primitive_load_path (scm_makfrom0str ("ice-9/boot-9.scm"));
bdca1083 353
b505860d
MD
354 /* Load the init.scm file. */
355 if (SCM_NFALSEP (init_path))
356 scm_primitive_load (init_path);
357
358 scm_post_boot_init_modules ();
359 }
bdca1083
JB
360}
361
5a551542 362#ifdef GUILE_NEW_GC_SCHEME
de1bc449
MD
363/* Get an integer from an environment variable. */
364static int
365scm_i_getenv_int (const char *var, int def)
366{
367 char *end, *val = getenv (var);
368 long res;
369 if (!val)
370 return def;
371 res = strtol (val, &end, 10);
372 if (end == val)
373 return def;
374 return res;
375}
376#endif /* GUILE_DEBUG */
bdca1083
JB
377
378\f
379/* The main init code. */
380
0f2d19dd
JB
381#ifdef _UNICOS
382typedef int setjmp_type;
383#else
384typedef long setjmp_type;
385#endif
386
816a6f06
JB
387/* All the data needed to invoke the main function. */
388struct main_func_closure
389{
390 /* the function to call */
1bbd0b84 391 void (*main_func)(void *closure, int argc, char **argv);
816a6f06
JB
392 void *closure; /* dummy data to pass it */
393 int argc;
394 char **argv; /* the argument list it should receive */
395};
396
397
1bbd0b84
GB
398static void scm_boot_guile_1(SCM_STACKITEM *base, struct main_func_closure *closure);
399static SCM invoke_main_func(void *body_data);
1cdaaafb
JB
400
401
402/* Fire up the Guile Scheme interpreter.
403
404 Call MAIN_FUNC, passing it CLOSURE, ARGC, and ARGV. MAIN_FUNC
405 should do all the work of the program (initializing other packages,
406 reading user input, etc.) before returning. When MAIN_FUNC
407 returns, call exit (0); this function never returns. If you want
408 some other exit value, MAIN_FUNC may call exit itself.
0f2d19dd 409
1cdaaafb
JB
410 scm_boot_guile arranges for program-arguments to return the strings
411 given by ARGC and ARGV. If MAIN_FUNC modifies ARGC/ARGV, should
412 call scm_set_program_arguments with the final list, so Scheme code
413 will know which arguments have been processed.
c275ddc7 414
816a6f06
JB
415 scm_boot_guile establishes a catch-all catch handler which prints
416 an error message and exits the process. This means that Guile
417 exits in a coherent way when system errors occur and the user isn't
418 prepared to handle it. If the user doesn't like this behavior,
419 they can establish their own universal catcher to shadow this one.
420
1cdaaafb
JB
421 Why must the caller do all the real work from MAIN_FUNC? The
422 garbage collector assumes that all local variables of type SCM will
423 be above scm_boot_guile's stack frame on the stack. If you try to
424 manipulate SCM values after this function returns, it's the luck of
425 the draw whether the GC will be able to find the objects you
426 allocate. So, scm_boot_guile function exits, rather than
427 returning, to discourage people from making that mistake. */
428
429
430void
6e8d25a6 431scm_boot_guile (int argc, char ** argv, void (*main_func) (), void *closure)
c275ddc7 432{
1cdaaafb
JB
433 /* The garbage collector uses the address of this variable as one
434 end of the stack, and the address of one of its own local
435 variables as the other end. */
c275ddc7 436 SCM_STACKITEM dummy;
816a6f06 437 struct main_func_closure c;
c275ddc7 438
816a6f06
JB
439 c.main_func = main_func;
440 c.closure = closure;
441 c.argc = argc;
442 c.argv = argv;
443
1595aa56 444 scm_boot_guile_1 (&dummy, &c);
c275ddc7
JB
445}
446
816a6f06 447
70122cd3
MV
448/* Record here whether SCM_BOOT_GUILE_1 has already been called. This
449 variable is now here and not inside SCM_BOOT_GUILE_1 so that one
450 can tweak it. This is necessary for unexec to work. (Hey, "1-live"
451 is the name of a local radiostation...) */
452
453int scm_boot_guile_1_live = 0;
1cdaaafb
JB
454
455static void
6e8d25a6 456scm_boot_guile_1 (SCM_STACKITEM *base, struct main_func_closure *closure)
0f2d19dd
JB
457{
458 static int initialized = 0;
70122cd3 459 /* static int live = 0; */
0f2d19dd 460 setjmp_type setjmp_val;
0f2d19dd 461
1cdaaafb 462 /* This function is not re-entrant. */
70122cd3 463 if (scm_boot_guile_1_live)
1cdaaafb 464 abort ();
0f2d19dd 465
70122cd3 466 scm_boot_guile_1_live = 1;
0f2d19dd
JB
467
468 scm_ints_disabled = 1;
469 scm_block_gc = 1;
470
471 if (initialized)
472 {
a4156763 473 restart_stack (base);
0f2d19dd
JB
474 }
475 else
476 {
477 scm_ports_prehistory ();
478 scm_smob_prehistory ();
479 scm_tables_prehistory ();
6b815f1a
MD
480#ifdef GUILE_DEBUG_MALLOC
481 scm_debug_malloc_prehistory ();
482#endif
5a551542 483#if defined (GUILE_NEW_GC_SCHEME)
08f77a44 484 scm_init_storage (scm_i_getenv_int ("GUILE_INIT_SEGMENT_SIZE_1", 0),
70a95005 485 scm_i_getenv_int ("GUILE_MIN_YIELD_1", 0),
08f77a44 486 scm_i_getenv_int ("GUILE_INIT_SEGMENT_SIZE_2", 0),
70a95005 487 scm_i_getenv_int ("GUILE_MIN_YIELD_2", 0),
08f77a44 488 scm_i_getenv_int ("GUILE_MAX_SEGMENT_SIZE", 0));
de1bc449 489#else
069fe425 490 scm_init_storage (0, 0);
de1bc449 491#endif
9de33deb 492 scm_init_subr_table ();
9ef3d0ee
MD
493 scm_init_root ();
494#ifdef USE_THREADS
a239e35b 495 scm_init_threads (base);
9ef3d0ee 496#endif
a4156763 497 start_stack (base);
0f2d19dd
JB
498 scm_init_gsubr ();
499 scm_init_feature ();
500 scm_init_alist ();
0f2d19dd
JB
501 scm_init_arbiters ();
502 scm_init_async ();
503 scm_init_boolean ();
504 scm_init_chars ();
505 scm_init_continuations ();
6b815f1a
MD
506#ifdef GUILE_DEBUG_MALLOC
507 scm_init_debug_malloc ();
508#endif
0f2d19dd
JB
509 scm_init_dynwind ();
510 scm_init_eq ();
511 scm_init_error ();
ee3ea81d 512 scm_init_fluids ();
a5d6d578 513 scm_init_backtrace (); /* Requires fluids */
0f2d19dd 514 scm_init_fports ();
0f2d19dd 515 scm_init_gc ();
68cd9c71 516 scm_init_gdbint ();
0f2d19dd
JB
517 scm_init_hash ();
518 scm_init_hashtab ();
44e8413c
MD
519#ifdef GUILE_ISELECT
520 scm_init_iselect ();
521#endif
0f2d19dd 522 scm_init_ioext ();
0e76bf66 523 scm_init_keywords ();
0f2d19dd 524 scm_init_list ();
27a69f93 525 scm_init_macros ();
0f2d19dd 526 scm_init_mallocs ();
345acb39 527 scm_init_modules ();
0f2d19dd
JB
528 scm_init_numbers ();
529 scm_init_objprop ();
4e1caa79 530 scm_init_options ();
0f2d19dd
JB
531 scm_init_pairs ();
532 scm_init_ports ();
52cfc69b
GH
533#ifdef HAVE_POSIX
534 scm_init_filesys ();
0f2d19dd 535 scm_init_posix ();
52cfc69b 536#endif
f255378e
JB
537#ifdef HAVE_REGCOMP
538 scm_init_regex_posix ();
539#endif
0f2d19dd
JB
540 scm_init_procs ();
541 scm_init_procprop ();
0f2d19dd 542 scm_init_scmsigs ();
52cfc69b
GH
543#ifdef HAVE_NETWORKING
544 scm_init_net_db ();
0f2d19dd 545 scm_init_socket ();
52cfc69b 546#endif
26ade7a2 547 scm_init_sort ();
4e1caa79
MD
548#ifdef DEBUG_EXTENSIONS
549 scm_init_srcprop ();
550#endif
0f2d19dd 551 scm_init_stackchk ();
7439c0b9 552 scm_init_struct (); /* Requires struct */
0e44fcca 553 scm_init_stacks ();
0f2d19dd 554 scm_init_strports ();
0f2d19dd
JB
555 scm_init_symbols ();
556 scm_init_tag ();
557 scm_init_load ();
0c32d76c 558 scm_init_objects (); /* Requires struct */
90b826c9 559 scm_init_print (); /* Requires struct */
0f2d19dd 560 scm_init_read ();
0f2d19dd
JB
561 scm_init_stime ();
562 scm_init_strings ();
563 scm_init_strorder ();
0f2d19dd
JB
564 scm_init_strop ();
565 scm_init_throw ();
566 scm_init_variable ();
567 scm_init_vectors ();
9d7e1edf 568 scm_init_version ();
0f2d19dd 569 scm_init_weaks ();
f28b85f2 570 scm_init_guardian ();
0f2d19dd
JB
571 scm_init_vports ();
572 scm_init_eval ();
27a69f93 573 scm_init_evalext ();
0e44fcca
MD
574#ifdef DEBUG_EXTENSIONS
575 scm_init_debug (); /* Requires macro smobs */
576#endif
26ade7a2 577 scm_init_random ();
afe5177e
GH
578#ifdef HAVE_ARRAYS
579 scm_init_ramap ();
0f2d19dd 580 scm_init_unif ();
afe5177e 581#endif
0f2d19dd 582 scm_init_simpos ();
24f93c27 583 scm_init_load_path ();
1cdaaafb 584 scm_init_standard_ports ();
70122cd3 585 scm_init_dynamic_linking ();
397daa3d 586 scm_init_lang ();
0487b82f 587 scm_init_script ();
0f2d19dd
JB
588 initialized = 1;
589 }
590
591 scm_block_gc = 0; /* permit the gc to run */
592 /* ints still disabled */
593
1cdaaafb
JB
594#ifdef STACK_CHECKING
595 scm_stack_checking_enabled_p = SCM_STACK_CHECKING_P;
596#endif
0f2d19dd 597
1cdaaafb
JB
598 setjmp_val = setjmp (SCM_JMPBUF (scm_rootcont));
599 if (!setjmp_val)
600 {
816a6f06 601 scm_set_program_arguments (closure->argc, closure->argv, 0);
f64056d1
JB
602 scm_internal_lazy_catch (SCM_BOOL_T, invoke_main_func, closure,
603 scm_handle_by_message, 0);
1cdaaafb 604 }
0f2d19dd 605
1cdaaafb 606 scm_restore_signals ();
0f2d19dd 607
1cdaaafb
JB
608 /* This tick gives any pending
609 * asyncs a chance to run. This must be done after
610 * the call to scm_restore_signals.
611 */
612 SCM_ASYNC_TICK;
613
614 /* If the caller doesn't want this, they should return from
615 main_func themselves. */
616 exit (0);
0f2d19dd 617}
816a6f06
JB
618
619
620static SCM
6e8d25a6 621invoke_main_func (void *body_data)
816a6f06
JB
622{
623 struct main_func_closure *closure = (struct main_func_closure *) body_data;
624
bdca1083
JB
625 scm_load_startup_files ();
626
816a6f06
JB
627 (*closure->main_func) (closure->closure, closure->argc, closure->argv);
628
629 /* never reached */
630 return SCM_UNDEFINED;
631}
89e00824
ML
632
633/*
634 Local Variables:
635 c-file-style: "gnu"
636 End:
637*/