Commit | Line | Data |
---|---|---|
58ade102 | 1 | /* Copyright (C) 1995,1996,1997, 2000, 2001 Free Software Foundation, Inc. |
0f2d19dd | 2 | * |
73be1d9e MV |
3 | * This library is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU Lesser General Public | |
5 | * License as published by the Free Software Foundation; either | |
6 | * version 2.1 of the License, or (at your option) any later version. | |
0f2d19dd | 7 | * |
73be1d9e MV |
8 | * This library 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 GNU | |
11 | * Lesser General Public License for more details. | |
0f2d19dd | 12 | * |
73be1d9e MV |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
16 | */ | |
6e8d25a6 | 17 | |
6e8d25a6 | 18 | |
0f2d19dd JB |
19 | \f |
20 | ||
a0599745 MD |
21 | #include "libguile/_scm.h" |
22 | #include "libguile/ports.h" | |
23 | #include "libguile/root.h" | |
0f2d19dd | 24 | |
a0599745 | 25 | #include "libguile/stackchk.h" |
0f2d19dd JB |
26 | \f |
27 | ||
28 | /* {Stack Checking} | |
29 | */ | |
30 | ||
39f1ef51 MD |
31 | #ifdef STACK_CHECKING |
32 | int scm_stack_checking_enabled_p; | |
0f2d19dd | 33 | |
523f5266 GH |
34 | SCM_SYMBOL (scm_stack_overflow_key, "stack-overflow"); |
35 | ||
0f2d19dd JB |
36 | void |
37 | scm_report_stack_overflow () | |
38 | { | |
39f1ef51 | 39 | scm_stack_checking_enabled_p = 0; |
01f61221 | 40 | scm_error (scm_stack_overflow_key, |
f5bf2977 GH |
41 | NULL, |
42 | "Stack overflow", | |
43 | SCM_BOOL_F, | |
44 | SCM_BOOL_F); | |
0f2d19dd JB |
45 | } |
46 | ||
47 | #endif | |
1cc91f1b | 48 | |
1be6b49c | 49 | long |
6e8d25a6 | 50 | scm_stack_size (SCM_STACKITEM *start) |
0f2d19dd JB |
51 | { |
52 | SCM_STACKITEM stack; | |
8dda3eea | 53 | #if SCM_STACK_GROWS_UP |
0f2d19dd JB |
54 | return &stack - start; |
55 | #else | |
56 | return start - &stack; | |
8dda3eea | 57 | #endif /* SCM_STACK_GROWS_UP */ |
0f2d19dd JB |
58 | } |
59 | ||
1cc91f1b | 60 | |
0f2d19dd JB |
61 | void |
62 | scm_stack_report () | |
0f2d19dd JB |
63 | { |
64 | SCM_STACKITEM stack; | |
65 | scm_intprint (scm_stack_size (SCM_BASE (scm_rootcont)) * sizeof (SCM_STACKITEM), | |
66 | 16, scm_cur_errp); | |
b7f3516f | 67 | scm_puts (" of stack: 0x", scm_cur_errp); |
0f2d19dd | 68 | scm_intprint ((long) SCM_BASE (scm_rootcont), 16, scm_cur_errp); |
b7f3516f | 69 | scm_puts (" - 0x", scm_cur_errp); |
0f2d19dd | 70 | scm_intprint ((long) &stack, 16, scm_cur_errp); |
b7f3516f | 71 | scm_puts ("\n", scm_cur_errp); |
0f2d19dd JB |
72 | } |
73 | ||
74 | ||
75 | ||
1cc91f1b | 76 | |
0f2d19dd JB |
77 | void |
78 | scm_init_stackchk () | |
0f2d19dd | 79 | { |
a0599745 | 80 | #include "libguile/stackchk.x" |
0f2d19dd | 81 | } |
89e00824 ML |
82 | |
83 | /* | |
84 | Local Variables: | |
85 | c-file-style: "gnu" | |
86 | End: | |
87 | */ |