Arrange so that `SCM_I_CURRENT_THREAD' is not accessed outside of libguile.
[bpt/guile.git] / libguile / stackchk.h
CommitLineData
0f2d19dd
JB
1/* classes: h_files */
2
0527e687
DH
3#ifndef SCM_STACKCHK_H
4#define SCM_STACKCHK_H
5
46935a1f 6/* Copyright (C) 1995,1996,1998,2000, 2003, 2006, 2008, 2009 Free Software Foundation, Inc.
0527e687 7 *
73be1d9e 8 * This library is free software; you can redistribute it and/or
53befeb7
NJ
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
0527e687 12 *
53befeb7
NJ
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
73be1d9e
MV
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
0527e687 17 *
73be1d9e
MV
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
53befeb7
NJ
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301 USA
73be1d9e 22 */
0527e687 23
0f2d19dd 24\f
0527e687 25
b4309c3c 26#include "libguile/__scm.h"
0f2d19dd 27
dfc40e20 28#include "libguile/continuations.h"
dfc40e20 29#include "libguile/debug.h"
d0f6ceb8 30
0f2d19dd
JB
31\f
32
d0f6ceb8 33/* With debug options we have the possibility to disable stack checking.
39f1ef51 34 */
39f1ef51 35#define SCM_STACK_CHECKING_P SCM_STACK_LIMIT
39f1ef51 36
46935a1f 37#if defined BUILDING_LIBGUILE && defined STACK_CHECKING
6c4eb8e1 38# if SCM_STACK_GROWS_UP
39f1ef51 39# define SCM_STACK_OVERFLOW_P(s)\
79f55b7c 40 (SCM_STACK_PTR (s) \
9de87eea 41 > (SCM_I_CURRENT_THREAD->base + SCM_STACK_LIMIT))
0f2d19dd 42# else
39f1ef51 43# define SCM_STACK_OVERFLOW_P(s)\
79f55b7c 44 (SCM_STACK_PTR (s) \
9de87eea 45 < (SCM_I_CURRENT_THREAD->base - SCM_STACK_LIMIT))
0f2d19dd
JB
46# endif
47# define SCM_CHECK_STACK\
48 {\
49 SCM_STACKITEM stack;\
39f1ef51 50 if (SCM_STACK_OVERFLOW_P (&stack) && scm_stack_checking_enabled_p)\
0f2d19dd
JB
51 scm_report_stack_overflow ();\
52 }
53#else
54# define SCM_CHECK_STACK /**/
46935a1f 55#endif
0f2d19dd 56
33b001fd 57SCM_API int scm_stack_checking_enabled_p;
0f2d19dd
JB
58
59\f
0f2d19dd 60
33b001fd
MV
61SCM_API void scm_report_stack_overflow (void);
62SCM_API long scm_stack_size (SCM_STACKITEM *start);
63SCM_API void scm_stack_report (void);
d8b6e191 64SCM_API SCM scm_sys_get_stack_size (void);
102dbb6f 65SCM_INTERNAL void scm_init_stackchk (void);
0f2d19dd 66
0527e687 67#endif /* SCM_STACKCHK_H */
89e00824
ML
68
69/*
70 Local Variables:
71 c-file-style: "gnu"
72 End:
73*/