#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
+#include <unistd.h>
#include <out.h>
#include "const.h"
#include "assert.h"
#include "debug.h"
#include "memory.h"
+#include "object.h"
-static copy_down();
-static copy_up();
-static free_saved_moduls();
+static void copy_down(struct memory* mem, ind_t dist);
+static void copy_up(struct memory* mem, ind_t dist);
+static void free_saved_moduls(void);
struct memory mems[NMEMS];
static char *BASE;
static ind_t refused;
-sbreak(incr)
- ind_t incr;
+static int sbreak(ind_t incr)
{
unsigned int inc;
* Initialize some pieces of core. We hope that this will be our last
* real allocation, meaning we've made the right choices.
*/
-init_core()
+void init_core(void)
{
register char *base;
register ind_t total_size;
register struct memory *mem;
- extern char *sbrk();
#include "mach.h"
#define ALIGN 8 /* minimum alignment for pieces */
* enough bytes, the first or the second time.
*/
static bool
-compact(piece, incr, flag)
- register int piece;
- register ind_t incr;
+compact(int piece, ind_t incr, int flag)
#define NORMAL 0
#define FREEZE 1
#define FORCED 2
* overlap with the old area, but we do not want to overwrite them before they
* are copied.
*/
-static
-copy_down(mem, dist)
- register struct memory *mem;
- ind_t dist;
+static void
+copy_down(struct memory* mem, ind_t dist)
{
register char *old;
register char *new;
* overlap with the old area, but we do not want to overwrite them before they
* are copied.
*/
-static
-copy_up(mem, dist)
- register struct memory *mem;
- ind_t dist;
+static void copy_up(struct memory* mem, ind_t dist)
{
register char *old;
register char *new;
* how many times the area is moved, because of another allocate, this offset
* remains valid.
*/
-ind_t
-alloc(piece, size)
- int piece;
- register long size;
+ind_t alloc(int piece, long size)
{
register ind_t incr = 0;
ind_t left = mems[piece].mem_left;
* attempt fails, release the space occupied by other pieces and try again.
*/
ind_t
-hard_alloc(piece, size)
- register int piece;
- register long size;
+hard_alloc(int piece, long size)
{
register ind_t ret;
register int i;
* at the start of the piece allocated for module contents, thereby
* overwriting the saved modules, and release its space.
*/
-static
-free_saved_moduls()
+static void
+free_saved_moduls(void)
{
register ind_t size;
register char *old, *new;
* To transform the various pieces of the output in core to the file format,
* we must order the bytes in the unsigned shorts and longs as ACK prescribes.
*/
-write_bytes()
+void write_bytes(void)
{
unsigned short nsect;
long offchar;
}
}
-namecpy(name, nname, offchar)
- register struct outname *name;
- register unsigned nname;
- register long offchar;
+void namecpy(struct outname* name, unsigned nname, long offchar)
{
while (nname--) {
if (name->on_foff)
#define int_align(sz) (((sz)+(sizeof(int)-1))&~(int)(sizeof(int)-1))
extern ind_t core_position;
-extern ind_t hard_alloc();
-extern ind_t alloc();
+extern void init_core(void);
+extern ind_t hard_alloc(int piece, long size);
+extern ind_t alloc(int piece, long size);
extern void dealloc(int piece);
extern void core_free(int piece, char* p);
+extern void write_bytes(void);
+extern void namecpy(struct outname* name, unsigned nname, long offchar);
all_alloc(void)
{
struct outhead head;
- extern ind_t hard_alloc();
if (hard_alloc(ALLOMODL, (long)sizeof(struct outhead)) == BADOFF)
fatal("no space for module header");
register struct outsect *sects;
unsigned short nsect = head->oh_nsect;
long size, rest;
- extern ind_t hard_alloc();
- extern ind_t alloc();
#ifdef SYMDBUG
rest = nsect * sizeof(ind_t) + sizeof(ind_t) + sizeof(ind_t);
{
long flen;
ind_t emitindex;
- extern ind_t alloc();
static long zeros[MAXSECT];
register long zero = zeros[allopiece - ALLOEMIT];
putreloindex(ind_t relooff, long nrelobytes)
{
ind_t reloindex;
- extern ind_t alloc();
if ((reloindex = alloc(ALLORELO, nrelobytes)) != BADOFF) {
*(ind_t *)modulptr(relooff) = reloindex;
putdbugindex(ind_t dbugoff, long ndbugbytes)
{
ind_t dbugindex;
- extern ind_t alloc();
if ((dbugindex = alloc(ALLODBUG, ndbugbytes)) != BADOFF) {
*(ind_t *)modulptr(dbugoff) = dbugindex;
unsigned short nsect, nname;
long size;
long nchar;
- extern ind_t hard_alloc();
assert(passnumber == SECOND);
assert(!incore);