ack/util/int/proctab.c

80 lines
1.6 KiB
C
Raw Permalink Normal View History

2019-03-17 14:42:00 +00:00
/** @file
proctable management routines.
1988-06-22 16:57:09 +00:00
*/
1994-06-24 11:31:16 +00:00
/* $Id$ */
1988-06-22 16:57:09 +00:00
#include "logging.h"
#include "global.h"
#include "log.h"
2019-03-17 14:42:00 +00:00
#include "io.h"
1988-06-22 16:57:09 +00:00
#include "alloc.h"
#include "proctab.h"
2019-03-17 14:42:00 +00:00
/** Procedure table */
1988-06-22 16:57:09 +00:00
struct proc *proctab;
PRIVATE long pr_cnt;
2019-03-17 14:42:00 +00:00
/** Allocates and initializes the procedure table. */
void init_proctab(void)
1988-06-22 16:57:09 +00:00
{
proctab = (struct proc *)
Malloc(NProc * sizeof (struct proc), "proctable");
pr_cnt = 0;
}
2019-03-17 14:42:00 +00:00
/** Add a procedure to the procedure entry table.
* "ep" is the pointer to the entry point of the
* procedure to add.
*/
void add_proc(size nloc, ptr ep)
1988-06-22 16:57:09 +00:00
{
register struct proc *pr = &proctab[pr_cnt++];
register struct proc *p;
register ptr ff = DB;
LOG((" r6 add_proc: pr_cnt = %ld, nloc = %lu, ep = %lu",
pr_cnt-1, nloc, ep));
if (ep > DB)
fatal("procedure entry point outside text segment");
pr->pr_nloc = nloc;
pr->pr_ep = ep;
/* examine all old proc descriptors */
for (p = &proctab[0]; p < pr; p++) {
if ( /* the old one starts earlier */
p->pr_ep < pr->pr_ep
&& /* it seems to end later */
p->pr_ff > pr->pr_ep
) { /* update its limit */
p->pr_ff = pr->pr_ep;
}
if ( /* the old one starts later */
p->pr_ep > pr->pr_ep
&& /* our limit is beyond the old procedure entry point*/
ff > p->pr_ep
) { /* update our limit */
ff = p->pr_ep;
}
}
pr->pr_ff = ff;
}
2019-03-17 14:42:00 +00:00
void end_init_proctab(void)
1988-06-22 16:57:09 +00:00
{
#ifdef LOGGING
register long p;
if (!check_log(" r6"))
return;
for (p = 0; p < NProc; p++) {
register struct proc *pr = &proctab[p];
LOG((" r5: proctab[%ld]: nloc = %d, ep = %lu, ff = %lu",
p, pr->pr_nloc, pr->pr_ep, pr->pr_ff));
}
#endif /* LOGGING */
1988-06-22 16:57:09 +00:00
}