#include "scheme.h"

#include <sys/types.h>

#define MONSTART 2

static monitoring;

static Object P_Monitor (on) Object on; {
    char *brk;
    extern caddr_t sbrk();

    Check_Type (on, T_Boolean);
    if (Truep (on)) {
	if (!monitoring) {
	    brk = sbrk (0);
	    monstartup ((int (*)())MONSTART, (int (*)())brk);
	    monitoring = 1;
	}
    } else {
	monitor (0);
	monitoring = 0;
    }
    return Void;
}

init_lib_monitor () {
    Define_Primitive (P_Monitor, "monitor", 1, 1, EVAL);
}
