proctab.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Handling the proctable
  3. */
  4. /* $Id$ */
  5. #include "logging.h"
  6. #include "global.h"
  7. #include "log.h"
  8. #include "alloc.h"
  9. #include "proctab.h"
  10. struct proc *proctab;
  11. PRIVATE long pr_cnt;
  12. init_proctab()
  13. {
  14. proctab = (struct proc *)
  15. Malloc(NProc * sizeof (struct proc), "proctable");
  16. pr_cnt = 0;
  17. }
  18. add_proc(nloc, ep)
  19. size nloc;
  20. ptr ep;
  21. {
  22. register struct proc *pr = &proctab[pr_cnt++];
  23. register struct proc *p;
  24. register ptr ff = DB;
  25. LOG((" r6 add_proc: pr_cnt = %ld, nloc = %lu, ep = %lu",
  26. pr_cnt-1, nloc, ep));
  27. if (ep > DB)
  28. fatal("procedure entry point outside text segment");
  29. pr->pr_nloc = nloc;
  30. pr->pr_ep = ep;
  31. /* examine all old proc descriptors */
  32. for (p = &proctab[0]; p < pr; p++) {
  33. if ( /* the old one starts earlier */
  34. p->pr_ep < pr->pr_ep
  35. && /* it seems to end later */
  36. p->pr_ff > pr->pr_ep
  37. ) { /* update its limit */
  38. p->pr_ff = pr->pr_ep;
  39. }
  40. if ( /* the old one starts later */
  41. p->pr_ep > pr->pr_ep
  42. && /* our limit is beyond the old procedure entry point*/
  43. ff > p->pr_ep
  44. ) { /* update our limit */
  45. ff = p->pr_ep;
  46. }
  47. }
  48. pr->pr_ff = ff;
  49. }
  50. end_init_proctab()
  51. {
  52. #ifdef LOGGING
  53. register long p;
  54. if (!check_log(" r6"))
  55. return;
  56. for (p = 0; p < NProc; p++) {
  57. register struct proc *pr = &proctab[p];
  58. LOG((" r5: proctab[%ld]: nloc = %d, ep = %lu, ff = %lu",
  59. p, pr->pr_nloc, pr->pr_ep, pr->pr_ff));
  60. }
  61. #endif /* LOGGING */
  62. }