Commit | Line | Data |
---|---|---|
7e2fd4e7 | 1 | /* Copyright (C) 1995,1996,1997, 2000, 2001, 2006, 2008, 2010, 2011, 2014 Free Software Foundation, Inc. |
0f2d19dd | 2 | * |
73be1d9e | 3 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
4 | * modify it under the terms of the GNU Lesser General Public License |
5 | * as published by the Free Software Foundation; either version 3 of | |
6 | * the License, or (at your option) any later version. | |
0f2d19dd | 7 | * |
53befeb7 NJ |
8 | * This library is distributed in the hope that it will be useful, but |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
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 | |
53befeb7 NJ |
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
16 | * 02110-1301 USA | |
73be1d9e | 17 | */ |
6e8d25a6 | 18 | |
6e8d25a6 | 19 | |
0f2d19dd | 20 | \f |
dbb605f5 LC |
21 | #ifdef HAVE_CONFIG_H |
22 | # include <config.h> | |
23 | #endif | |
0f2d19dd | 24 | |
a0599745 MD |
25 | #include "libguile/_scm.h" |
26 | #include "libguile/ports.h" | |
27 | #include "libguile/root.h" | |
d8b6e191 | 28 | #include "libguile/threads.h" |
138bf22d | 29 | #include "libguile/dynwind.h" |
0f2d19dd | 30 | |
a0599745 | 31 | #include "libguile/stackchk.h" |
0f2d19dd JB |
32 | \f |
33 | ||
34 | /* {Stack Checking} | |
35 | */ | |
36 | ||
39f1ef51 | 37 | int scm_stack_checking_enabled_p; |
0f2d19dd | 38 | |
1be6b49c | 39 | long |
6e8d25a6 | 40 | scm_stack_size (SCM_STACKITEM *start) |
0f2d19dd JB |
41 | { |
42 | SCM_STACKITEM stack; | |
8dda3eea | 43 | #if SCM_STACK_GROWS_UP |
0f2d19dd JB |
44 | return &stack - start; |
45 | #else | |
46 | return start - &stack; | |
8dda3eea | 47 | #endif /* SCM_STACK_GROWS_UP */ |
0f2d19dd JB |
48 | } |
49 | ||
1cc91f1b | 50 | |
0f2d19dd JB |
51 | void |
52 | scm_stack_report () | |
0f2d19dd | 53 | { |
9de87eea | 54 | SCM port = scm_current_error_port (); |
0f2d19dd | 55 | SCM_STACKITEM stack; |
9de87eea MV |
56 | scm_i_thread *thread = SCM_I_CURRENT_THREAD; |
57 | ||
58 | scm_uintprint ((scm_stack_size (thread->continuation_base) | |
59 | * sizeof (SCM_STACKITEM)), | |
60 | 16, port); | |
0607ebbf | 61 | scm_puts_unlocked (" of stack: 0x", port); |
9de87eea | 62 | scm_uintprint ((scm_t_bits) thread->continuation_base, 16, port); |
0607ebbf | 63 | scm_puts_unlocked (" - 0x", port); |
9de87eea | 64 | scm_uintprint ((scm_t_bits) &stack, 16, port); |
0607ebbf | 65 | scm_puts_unlocked ("\n", port); |
0f2d19dd JB |
66 | } |
67 | ||
d8b6e191 NJ |
68 | |
69 | SCM_DEFINE (scm_sys_get_stack_size, "%get-stack-size", 0, 0, 0, | |
70 | (), | |
71 | "Return the current thread's C stack size (in Scheme objects).") | |
72 | #define FUNC_NAME s_scm_sys_get_stack_size | |
73 | { | |
74 | return scm_from_long (scm_stack_size (SCM_I_CURRENT_THREAD->base)); | |
75 | } | |
76 | #undef FUNC_NAME | |
77 | ||
78 | ||
0f2d19dd JB |
79 | void |
80 | scm_init_stackchk () | |
0f2d19dd | 81 | { |
a0599745 | 82 | #include "libguile/stackchk.x" |
0f2d19dd | 83 | } |
89e00824 ML |
84 | |
85 | /* | |
86 | Local Variables: | |
87 | c-file-style: "gnu" | |
88 | End: | |
89 | */ |