home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
kaffe-0.5p4-src.tgz
/
tar.out
/
contrib
/
kaffe
/
kaffevm
/
jit
/
seq.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-28
|
1KB
|
65 lines
/* seq.c
* Pseudo instruction sequences.
*
* Copyright (c) 1996 Systems Architecture Research Centre,
* City University, London, UK.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* Written by Tim Wilkinson <tim@sarc.city.ac.uk>, July 1996.
*/
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include "gtypes.h"
#include "seq.h"
sequence* firstSeq;
sequence* lastSeq;
sequence* currSeq;
/*
* Reset the sequence list.
*/
void
initSeq(void)
{
currSeq = firstSeq;
}
/*
* Allocate a new sequence element.
*/
sequence*
nextSeq(void)
{
int i;
sequence* ret = currSeq;
if (ret == 0) {
/* Allocate chunk of sequence elements */
ret = calloc(ALLOCSEQNR, sizeof(sequence));
assert(ret != 0);
/* Attach to current chain */
if (lastSeq == 0) {
firstSeq = ret;
}
else {
lastSeq->next = ret;
}
lastSeq = &ret[ALLOCSEQNR-1];
/* Link elements into list */
for (i = 0; i < ALLOCSEQNR-1; i++) {
ret[i].next = &ret[i+1];
}
ret[ALLOCSEQNR-1].next = 0;
}
currSeq = ret->next;
ret->ref = 1;
return (ret);
}