pro.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* pro.c Copyright (C) 1989-96 Codemist Ltd */
  2. /* Watcom C stack checking code */
  3. /* Signature: 464b2e46 13-Sep-1996 */
  4. #include <stdarg.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include "machine.h"
  8. #include "tags.h"
  9. #include "externs.h"
  10. #include "arith.h"
  11. #include "read.h"
  12. #include "stream.h"
  13. #include "entries.h"
  14. #include "version.h"
  15. #include "cslerror.h"
  16. static int spset = 0;
  17. static int32 spbase = 0, spmin;
  18. static FILE *stack_log = NULL;
  19. #pragma aux __PRO modify [];
  20. #pragma aux __PRO "__PRO";
  21. extern int pusha(void);
  22. #pragma aux pusha = "push eax" "push ecx" "push edx" value [eax] modify [];
  23. extern int popa(void);
  24. #pragma aux popa = "pop edx" "pop ecx" "pop eax" value [eax] modify [eax ecx edx];
  25. void __PRO()
  26. {
  27. int32 temp;
  28. pusha();
  29. temp = (int32)&temp;
  30. if (!spset)
  31. { spbase = spmin = temp;
  32. spset = 1;
  33. }
  34. if (stack_log == NULL) stack_log = fopen("stack.log", "w");
  35. if (temp <= spmin-64) /* Only check at granularity of 64 bytes */
  36. {
  37. fprintf(stack_log, "Stack depth %d\n", spbase-temp);
  38. spmin = temp;
  39. }
  40. popa();
  41. return;
  42. }
  43. /* End of pro.c */