stackchk.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* classes: h_files */
  2. #ifndef SCM_STACKCHK_H
  3. #define SCM_STACKCHK_H
  4. /* Copyright (C) 1995,1996,1998,2000, 2003, 2006 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
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but 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 02110-1301 USA
  19. */
  20. #include "libguile/__scm.h"
  21. #include "libguile/continuations.h"
  22. #include "libguile/debug.h"
  23. /* With debug options we have the possibility to disable stack checking.
  24. */
  25. #define SCM_STACK_CHECKING_P SCM_STACK_LIMIT
  26. #ifdef STACK_CHECKING
  27. # if SCM_STACK_GROWS_UP
  28. # define SCM_STACK_OVERFLOW_P(s)\
  29. (SCM_STACK_PTR (s) \
  30. > (SCM_I_CURRENT_THREAD->base + SCM_STACK_LIMIT))
  31. # else
  32. # define SCM_STACK_OVERFLOW_P(s)\
  33. (SCM_STACK_PTR (s) \
  34. < (SCM_I_CURRENT_THREAD->base - SCM_STACK_LIMIT))
  35. # endif
  36. # define SCM_CHECK_STACK\
  37. {\
  38. SCM_STACKITEM stack;\
  39. if (SCM_STACK_OVERFLOW_P (&stack) && scm_stack_checking_enabled_p)\
  40. scm_report_stack_overflow ();\
  41. }
  42. #else
  43. # define SCM_CHECK_STACK /**/
  44. #endif /* STACK_CHECKING */
  45. SCM_API int scm_stack_checking_enabled_p;
  46. SCM_API void scm_report_stack_overflow (void);
  47. SCM_API long scm_stack_size (SCM_STACKITEM *start);
  48. SCM_API void scm_stack_report (void);
  49. SCM_API SCM scm_sys_get_stack_size (void);
  50. SCM_API void scm_init_stackchk (void);
  51. #endif /* SCM_STACKCHK_H */
  52. /*
  53. Local Variables:
  54. c-file-style: "gnu"
  55. End:
  56. */