stackchk.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* classes: h_files */
  2. #ifndef SCM_STACKCHK_H
  3. #define SCM_STACKCHK_H
  4. /* Copyright (C) 1995,1996,1998,2000, 2003, 2006, 2008 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #include "libguile/__scm.h"
  22. #include "libguile/continuations.h"
  23. #include "libguile/debug.h"
  24. /* With debug options we have the possibility to disable stack checking.
  25. */
  26. #define SCM_STACK_CHECKING_P SCM_STACK_LIMIT
  27. #ifdef STACK_CHECKING
  28. # if SCM_STACK_GROWS_UP
  29. # define SCM_STACK_OVERFLOW_P(s)\
  30. (SCM_STACK_PTR (s) \
  31. > (SCM_I_CURRENT_THREAD->base + SCM_STACK_LIMIT))
  32. # else
  33. # define SCM_STACK_OVERFLOW_P(s)\
  34. (SCM_STACK_PTR (s) \
  35. < (SCM_I_CURRENT_THREAD->base - SCM_STACK_LIMIT))
  36. # endif
  37. # define SCM_CHECK_STACK\
  38. {\
  39. SCM_STACKITEM stack;\
  40. if (SCM_STACK_OVERFLOW_P (&stack) && scm_stack_checking_enabled_p)\
  41. scm_report_stack_overflow ();\
  42. }
  43. #else
  44. # define SCM_CHECK_STACK /**/
  45. #endif /* STACK_CHECKING */
  46. SCM_API int scm_stack_checking_enabled_p;
  47. SCM_API void scm_report_stack_overflow (void);
  48. SCM_API long scm_stack_size (SCM_STACKITEM *start);
  49. SCM_API void scm_stack_report (void);
  50. SCM_API SCM scm_sys_get_stack_size (void);
  51. SCM_INTERNAL void scm_init_stackchk (void);
  52. #endif /* SCM_STACKCHK_H */
  53. /*
  54. Local Variables:
  55. c-file-style: "gnu"
  56. End:
  57. */