Commit | Line | Data |
---|---|---|
dbb605f5 | 1 | /* Copyright (C) 1995,1996,1997, 2000, 2001, 2006, 2008 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 | |
92205699 | 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
73be1d9e | 16 | */ |
6e8d25a6 | 17 | |
6e8d25a6 | 18 | |
0f2d19dd | 19 | \f |
dbb605f5 LC |
20 | #ifdef HAVE_CONFIG_H |
21 | # include <config.h> | |
22 | #endif | |
0f2d19dd | 23 | |
a0599745 MD |
24 | #include "libguile/_scm.h" |
25 | #include "libguile/ports.h" | |
26 | #include "libguile/root.h" | |
0f2d19dd | 27 | |
a0599745 | 28 | #include "libguile/stackchk.h" |
0f2d19dd JB |
29 | \f |
30 | ||
31 | /* {Stack Checking} | |
32 | */ | |
33 | ||
39f1ef51 MD |
34 | #ifdef STACK_CHECKING |
35 | int scm_stack_checking_enabled_p; | |
0f2d19dd | 36 | |
523f5266 GH |
37 | SCM_SYMBOL (scm_stack_overflow_key, "stack-overflow"); |
38 | ||
0f2d19dd JB |
39 | void |
40 | scm_report_stack_overflow () | |
41 | { | |
39f1ef51 | 42 | scm_stack_checking_enabled_p = 0; |
01f61221 | 43 | scm_error (scm_stack_overflow_key, |
f5bf2977 GH |
44 | NULL, |
45 | "Stack overflow", | |
46 | SCM_BOOL_F, | |
47 | SCM_BOOL_F); | |
0f2d19dd JB |
48 | } |
49 | ||
50 | #endif | |
1cc91f1b | 51 | |
1be6b49c | 52 | long |
6e8d25a6 | 53 | scm_stack_size (SCM_STACKITEM *start) |
0f2d19dd JB |
54 | { |
55 | SCM_STACKITEM stack; | |
8dda3eea | 56 | #if SCM_STACK_GROWS_UP |
0f2d19dd JB |
57 | return &stack - start; |
58 | #else | |
59 | return start - &stack; | |
8dda3eea | 60 | #endif /* SCM_STACK_GROWS_UP */ |
0f2d19dd JB |
61 | } |
62 | ||
1cc91f1b | 63 | |
0f2d19dd JB |
64 | void |
65 | scm_stack_report () | |
0f2d19dd | 66 | { |
9de87eea | 67 | SCM port = scm_current_error_port (); |
0f2d19dd | 68 | SCM_STACKITEM stack; |
9de87eea MV |
69 | scm_i_thread *thread = SCM_I_CURRENT_THREAD; |
70 | ||
71 | scm_uintprint ((scm_stack_size (thread->continuation_base) | |
72 | * sizeof (SCM_STACKITEM)), | |
73 | 16, port); | |
74 | scm_puts (" of stack: 0x", port); | |
75 | scm_uintprint ((scm_t_bits) thread->continuation_base, 16, port); | |
76 | scm_puts (" - 0x", port); | |
77 | scm_uintprint ((scm_t_bits) &stack, 16, port); | |
78 | scm_puts ("\n", port); | |
0f2d19dd JB |
79 | } |
80 | ||
0f2d19dd JB |
81 | void |
82 | scm_init_stackchk () | |
0f2d19dd | 83 | { |
a0599745 | 84 | #include "libguile/stackchk.x" |
0f2d19dd | 85 | } |
89e00824 ML |
86 | |
87 | /* | |
88 | Local Variables: | |
89 | c-file-style: "gnu" | |
90 | End: | |
91 | */ |