ack/util/ego/share/init_glob.c
George Koehler 9037d137f5 Add prototypes, void in util/ego/share
This uncovers a problem in il/il_aux.c: it passes 3 arguments to
getlines(), but the function expects 4 arguments.  I add FALSE as the
4th argument.  TRUE would fill in the list of mesregs.  IL uses
mesregs during phase 1, but this call to getlines() is in phase 2.
TRUE would leak memory unless I added a call to Ldeleteset(mesregs).
So I pass FALSE.

Functions passed to go() now have a `void *` parameter because
no_action() now takes a `void *`.
2017-11-15 17:19:56 -05:00

64 lines
1.4 KiB
C

/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* S H A R E D F I L E
*
* I N I T _ G L O B L S
*
*/
#include "types.h"
#include "debug.h"
#include "global.h"
#include "alloc.h"
#include "map.h"
extern short nrglobals;
/* ARGSUSED */
void init_globals(void *vp)
{
/* Assign a 'global variable number (o_globnr) to
* every global variable for which we want to
* maintain ud-info. We do not maintain ud-info
* for a global variable if:
* - it is part of a ROM data block (so it will never be changed)
* - it's size is not known
* - it overlaps another variable (e.g. LOE X+2 ; LDE X)
*/
dblock_p d;
obj_p obj, prev = 0;
short nr = 1;
offset ill_zone, x;
for (d = fdblock; d != (dblock_p) 0; d = d->d_next) {
ill_zone = (offset) 0;
for (obj = d->d_objlist; obj != (obj_p) 0; obj = obj->o_next) {
if (d->d_pseudo == DROM ||
obj->o_size == UNKNOWN_SIZE) {
obj->o_globnr = 0; /* var. not considered */
continue;
}
if (obj->o_off < ill_zone) {
obj->o_globnr = 0; /* var. not considered */
if (prev != (obj_p) 0 && prev->o_globnr != 0) {
prev->o_globnr = 0;
nr--;
}
} else {
obj->o_globnr = nr++;
}
if ((x = obj->o_off + obj->o_size) > ill_zone) {
ill_zone = x;
}
prev = obj;
}
}
nrglobals = nr -1;
}