Non gcc fixes.

This commit is contained in:
ehofman
2005-04-19 12:30:12 +00:00
parent 8ea41af5c4
commit ec4fc265e0
4 changed files with 10 additions and 6 deletions

View File

@@ -107,13 +107,14 @@ static void initContext(struct Context* c)
static void initGlobals()
{
int i;
struct Context* c;
globals = (struct Globals*)naAlloc(sizeof(struct Globals));
naBZero(globals, sizeof(struct Globals));
globals->sem = naNewSem();
globals->lock = naNewLock();
int i;
globals->allocCount = 256; // reasonable starting value
for(i=0; i<NUM_NASAL_TYPES; i++)
naGC_init(&(globals->pools[i]), i);
@@ -124,7 +125,7 @@ static void initGlobals()
// Initialize a single context
globals->freeContexts = 0;
globals->allContexts = 0;
struct Context* c = naNewContext();
c = naNewContext();
globals->symbols = naNewHash(c);
globals->save = naNewVector(c);
@@ -140,11 +141,12 @@ static void initGlobals()
struct Context* naNewContext()
{
int dummy;
struct Context* c;
if(globals == 0)
initGlobals();
LOCK();
struct Context* c = globals->freeContexts;
c = globals->freeContexts;
if(c) {
globals->freeContexts = c->nextFree;
c->nextFree = 0;

View File

@@ -33,7 +33,7 @@ enum { T_STR, T_VEC, T_HASH, T_CODE, T_FUNC, T_CCODE, T_GHOST,
// implementing objects to pack in 16 bits worth of data "for free".
#define GC_HEADER \
unsigned char mark; \
unsigned char type; \
unsigned char type
struct naObj {
GC_HEADER;

View File

@@ -49,8 +49,9 @@ static naRef pop(naContext c, naRef me, int argc, naRef* args)
static naRef setsize(naContext c, naRef me, int argc, naRef* args)
{
int sz;
if(argc < 2) return naNil();
int sz = (int)naNumValue(args[1]).num;
sz = (int)naNumValue(args[1]).num;
if(!naIsVector(args[0])) return naNil();
naVec_setsize(args[0], sz);
return args[0];

View File

@@ -49,10 +49,11 @@ naRef naStringValue(naContext c, naRef r)
naRef naNew(struct Context* c, int type)
{
naRef result;
if(c->nfree[type] == 0)
c->free[type] = naGC_get(&globals->pools[type],
OBJ_CACHE_SZ, &c->nfree[type]);
naRef result = naObj(type, c->free[type][--c->nfree[type]]);
result = naObj(type, c->free[type][--c->nfree[type]]);
naVec_append(c->temps, result);
return result;
}