stackchk.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* classes: h_files */
  2. #ifndef SCM_STACKCHK_H
  3. #define SCM_STACKCHK_H
  4. /* Copyright (C) 1995,1996,1998,2000, 2003, 2006, 2008, 2009, 2010, 2011, 2014 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. #if defined BUILDING_LIBGUILE
  28. #include "libguile/private-options.h"
  29. # if SCM_STACK_GROWS_UP
  30. # define SCM_STACK_OVERFLOW_P(s)\
  31. ((SCM_STACK_PTR (s) - SCM_I_CURRENT_THREAD->base) > SCM_STACK_LIMIT)
  32. # else
  33. # define SCM_STACK_OVERFLOW_P(s)\
  34. ((SCM_I_CURRENT_THREAD->base - SCM_STACK_PTR (s)) > 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
  45. SCM_API int scm_stack_checking_enabled_p;
  46. SCM_API long scm_stack_size (SCM_STACKITEM *start);
  47. SCM_API void scm_stack_report (void);
  48. SCM_API SCM scm_sys_get_stack_size (void);
  49. SCM_INTERNAL void scm_init_stackchk (void);
  50. #endif /* SCM_STACKCHK_H */
  51. /*
  52. Local Variables:
  53. c-file-style: "gnu"
  54. End:
  55. */