Changed license terms to the plain LGPL thru-out.
[bpt/guile.git] / libguile / stackchk.h
1 /* classes: h_files */
2
3 #ifndef SCM_STACKCHK_H
4 #define SCM_STACKCHK_H
5
6 /* Copyright (C) 1995,1996,1998,2000 Free Software Foundation, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 \f
24
25 #include "libguile/__scm.h"
26
27 #include "libguile/continuations.h"
28 #ifdef DEBUG_EXTENSIONS
29 #include "libguile/debug.h"
30 #endif
31 \f
32
33 /* With debug extensions we have the possibility to use the debug options
34 * to disable stack checking.
35 */
36 #ifdef DEBUG_EXTENSIONS
37 #define SCM_STACK_CHECKING_P SCM_STACK_LIMIT
38 #else
39 /* *fixme* This option should be settable also without debug extensions. */
40 #define SCM_STACK_LIMIT 100000
41 #define SCM_STACK_CHECKING_P 1
42 #endif
43
44 #ifdef STACK_CHECKING
45 # if SCM_STACK_GROWS_UP
46 # define SCM_STACK_OVERFLOW_P(s)\
47 (s > ((SCM_STACKITEM *) SCM_BASE (scm_rootcont) + SCM_STACK_LIMIT))
48 # else
49 # define SCM_STACK_OVERFLOW_P(s)\
50 (s < ((SCM_STACKITEM *) SCM_BASE (scm_rootcont) - SCM_STACK_LIMIT))
51 # endif
52 # define SCM_CHECK_STACK\
53 {\
54 SCM_STACKITEM stack;\
55 if (SCM_STACK_OVERFLOW_P (&stack) && scm_stack_checking_enabled_p)\
56 scm_report_stack_overflow ();\
57 }
58 #else
59 # define SCM_CHECK_STACK /**/
60 #endif /* STACK_CHECKING */
61
62 SCM_API int scm_stack_checking_enabled_p;
63
64 \f
65
66 SCM_API void scm_report_stack_overflow (void);
67 SCM_API long scm_stack_size (SCM_STACKITEM *start);
68 SCM_API void scm_stack_report (void);
69 SCM_API void scm_init_stackchk (void);
70
71 #endif /* SCM_STACKCHK_H */
72
73 /*
74 Local Variables:
75 c-file-style: "gnu"
76 End:
77 */