Non gcc fixes.
This commit is contained in:
@@ -107,13 +107,14 @@ static void initContext(struct Context* c)
|
|||||||
|
|
||||||
static void initGlobals()
|
static void initGlobals()
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
struct Context* c;
|
||||||
globals = (struct Globals*)naAlloc(sizeof(struct Globals));
|
globals = (struct Globals*)naAlloc(sizeof(struct Globals));
|
||||||
naBZero(globals, sizeof(struct Globals));
|
naBZero(globals, sizeof(struct Globals));
|
||||||
|
|
||||||
globals->sem = naNewSem();
|
globals->sem = naNewSem();
|
||||||
globals->lock = naNewLock();
|
globals->lock = naNewLock();
|
||||||
|
|
||||||
int i;
|
|
||||||
globals->allocCount = 256; // reasonable starting value
|
globals->allocCount = 256; // reasonable starting value
|
||||||
for(i=0; i<NUM_NASAL_TYPES; i++)
|
for(i=0; i<NUM_NASAL_TYPES; i++)
|
||||||
naGC_init(&(globals->pools[i]), i);
|
naGC_init(&(globals->pools[i]), i);
|
||||||
@@ -124,7 +125,7 @@ static void initGlobals()
|
|||||||
// Initialize a single context
|
// Initialize a single context
|
||||||
globals->freeContexts = 0;
|
globals->freeContexts = 0;
|
||||||
globals->allContexts = 0;
|
globals->allContexts = 0;
|
||||||
struct Context* c = naNewContext();
|
c = naNewContext();
|
||||||
|
|
||||||
globals->symbols = naNewHash(c);
|
globals->symbols = naNewHash(c);
|
||||||
globals->save = naNewVector(c);
|
globals->save = naNewVector(c);
|
||||||
@@ -140,11 +141,12 @@ static void initGlobals()
|
|||||||
struct Context* naNewContext()
|
struct Context* naNewContext()
|
||||||
{
|
{
|
||||||
int dummy;
|
int dummy;
|
||||||
|
struct Context* c;
|
||||||
if(globals == 0)
|
if(globals == 0)
|
||||||
initGlobals();
|
initGlobals();
|
||||||
|
|
||||||
LOCK();
|
LOCK();
|
||||||
struct Context* c = globals->freeContexts;
|
c = globals->freeContexts;
|
||||||
if(c) {
|
if(c) {
|
||||||
globals->freeContexts = c->nextFree;
|
globals->freeContexts = c->nextFree;
|
||||||
c->nextFree = 0;
|
c->nextFree = 0;
|
||||||
|
|||||||
@@ -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".
|
// implementing objects to pack in 16 bits worth of data "for free".
|
||||||
#define GC_HEADER \
|
#define GC_HEADER \
|
||||||
unsigned char mark; \
|
unsigned char mark; \
|
||||||
unsigned char type; \
|
unsigned char type
|
||||||
|
|
||||||
struct naObj {
|
struct naObj {
|
||||||
GC_HEADER;
|
GC_HEADER;
|
||||||
|
|||||||
+2
-1
@@ -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)
|
static naRef setsize(naContext c, naRef me, int argc, naRef* args)
|
||||||
{
|
{
|
||||||
|
int sz;
|
||||||
if(argc < 2) return naNil();
|
if(argc < 2) return naNil();
|
||||||
int sz = (int)naNumValue(args[1]).num;
|
sz = (int)naNumValue(args[1]).num;
|
||||||
if(!naIsVector(args[0])) return naNil();
|
if(!naIsVector(args[0])) return naNil();
|
||||||
naVec_setsize(args[0], sz);
|
naVec_setsize(args[0], sz);
|
||||||
return args[0];
|
return args[0];
|
||||||
|
|||||||
@@ -49,10 +49,11 @@ naRef naStringValue(naContext c, naRef r)
|
|||||||
|
|
||||||
naRef naNew(struct Context* c, int type)
|
naRef naNew(struct Context* c, int type)
|
||||||
{
|
{
|
||||||
|
naRef result;
|
||||||
if(c->nfree[type] == 0)
|
if(c->nfree[type] == 0)
|
||||||
c->free[type] = naGC_get(&globals->pools[type],
|
c->free[type] = naGC_get(&globals->pools[type],
|
||||||
OBJ_CACHE_SZ, &c->nfree[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);
|
naVec_append(c->temps, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user