Skip to content

Commit

Permalink
headers/lang: some int type fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Blechmann <tim@klingt.org>
  • Loading branch information
timblechmann committed Sep 8, 2012
1 parent 860e5ef commit 7e6396d
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 273 deletions.
16 changes: 8 additions & 8 deletions include/common/SC_AllocPool.h
Expand Up @@ -178,10 +178,10 @@ class AllocPool
else return (sizePlusOverhead + kAlignMask) & ~kAlignMask;
}

static int SmallBinIndex(size_t inSize)
static size_t SmallBinIndex(size_t inSize)
{ return inSize >> 4; }

static int BinIndex2(size_t inSize)
static size_t BinIndex2(size_t inSize)
{
return
((inSize < 1024) ? (inSize>>4):
Expand All @@ -195,7 +195,7 @@ class AllocPool
(inSize < 262144) ? 112 + (inSize>>14):127);
}

static int BinIndex(size_t inSize)
static size_t BinIndex(size_t inSize)
{
if (inSize < 1024) return inSize >> 4;
if (inSize >= 262144) return 127;
Expand All @@ -211,11 +211,11 @@ class AllocPool
mBinBlocks[word] |= bitValue;
}

void ClearBinBlock(int inIndex)
void ClearBinBlock(size_t inIndex)
{
unsigned long word = inIndex >> 5;
unsigned long bitPosition = inIndex & 31;
unsigned long bitValue = 1L << bitPosition;
size_t word = inIndex >> 5;
size_t bitPosition = inIndex & 31;
size_t bitValue = 1L << bitPosition;
mBinBlocks[word] &= ~bitValue;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ class AllocPool
{
inChunk->RemoveLeaveDangling();
size_t size = inChunk->Size();
int index = BinIndex(size);
size_t index = BinIndex(size);
AllocChunkPtr bin = mBins + index;
if (bin->IsEmpty()) ClearBinBlock(index);
}
Expand Down
6 changes: 3 additions & 3 deletions include/common/clz.h
Expand Up @@ -130,15 +130,15 @@ inline bool ISPOWEROFTWO(int32 x)
// next power of two greater than or equal to x
inline int32 NEXTPOWEROFTWO(int32 x)
{
return 1L << LOG2CEIL(x);
return (int32)1L << LOG2CEIL(x);
}

// previous power of two less than or equal to x
inline int32 PREVIOUSPOWEROFTWO(int32 x)
{
if (ISPOWEROFTWO(x))
return x;
return 1L << (LOG2CEIL(x) - 1);
return (int32)1L << (LOG2CEIL(x) - 1);
}

// input a series of counting integers, outputs a series of gray codes .
Expand Down Expand Up @@ -168,7 +168,7 @@ inline int32 MSBitPos(int32 x)
// find most significant bit
inline int32 MSBit(int32 x)
{
return 1L << MSBitPos(x);
return (int32)1L << MSBitPos(x);
}

// count number of one bits
Expand Down
2 changes: 1 addition & 1 deletion include/common/scsynthsend.h
Expand Up @@ -134,7 +134,7 @@ struct scpacket {
skip(size4);
wrpos[-1] = 0;
}
int size() { return (char*)wrpos - (char*)buf; }
size_t size() { return (char*)wrpos - (char*)buf; }
char* data() { return (char*)buf; }

void OpenBundle(int64 time)
Expand Down
6 changes: 3 additions & 3 deletions include/lang/GC.h
Expand Up @@ -155,7 +155,7 @@ class PyrGC
void Free(PyrObjectHdr* inObj);


int32 StackDepth() { return mVMGlobals->sp - mStack->slots + 1; }
long StackDepth() { return mVMGlobals->sp - mStack->slots + 1; }
PyrObject* Stack() { return mStack; }
void SetStack(PyrObject* inStack) { mStack = inStack; }

Expand Down Expand Up @@ -343,10 +343,10 @@ inline PyrObject * PyrGC::Allocate(size_t inNumBytes, int32 sizeclass, bool inCo
} else {
if (sizeclass > kMaxPoolSet) {
SweepBigObjects();
int32 allocSize = sizeof(PyrObjectHdr) + (sizeof(PyrSlot) << sizeclass);
size_t allocSize = sizeof(PyrObjectHdr) + (sizeof(PyrSlot) << sizeclass);
obj = (PyrObject*)mPool->Alloc(allocSize);
} else {
int32 allocSize = sizeof(PyrObjectHdr) + (sizeof(PyrSlot) << sizeclass);
size_t allocSize = sizeof(PyrObjectHdr) + (sizeof(PyrSlot) << sizeclass);
obj = (PyrObject*)mNewPool.Alloc(allocSize);
}
if (!obj)
Expand Down
7 changes: 4 additions & 3 deletions include/lang/PyrDeepCopier.h
Expand Up @@ -77,12 +77,13 @@ class PyrDeepCopier

private:

void recurse(PyrObject *obj, int n)
void recurse(PyrObject *obj, size_t n)
{
//post("->recurse %s %08X\n", obj->classptr->name.us->name, obj);
PyrSlot *slot = obj->slots;
for (int i=0; i<n; ++i, ++slot) {
if (IsObj(slot)) constructObjectArray(slotRawObject(slot));
for (size_t i=0; i<n; ++i, ++slot) {
if (IsObj(slot))
constructObjectArray(slotRawObject(slot));
}
//post("<-recurse %s %08X\n", obj->classptr->name.us->name, obj);
}
Expand Down
4 changes: 2 additions & 2 deletions include/lang/PyrObject.h
Expand Up @@ -281,12 +281,12 @@ void getIndexedSlot(struct PyrObject *obj, PyrSlot *a, int index);
int putIndexedSlot(struct VMGlobals *g, struct PyrObject *obj, PyrSlot *c, int index);
int putIndexedFloat(PyrObject *obj, double val, int index);

inline int ARRAYMAXINDEXSIZE(PyrObjectHdr* obj)
inline long ARRAYMAXINDEXSIZE(PyrObjectHdr* obj)
{
return (1L << obj->obj_sizeclass);
}

inline int MAXINDEXSIZE(PyrObjectHdr* obj)
inline long MAXINDEXSIZE(PyrObjectHdr* obj)
{
return ((1L << obj->obj_sizeclass) * gFormatElemCapc[ obj->obj_format ]);
}
Expand Down
2 changes: 1 addition & 1 deletion include/lang/PyrSymbolTable.h
Expand Up @@ -65,7 +65,7 @@ class SymbolTable
PyrSymbol* Make(const char *inName);
PyrSymbol* MakeNew(const char *inName, int inHash, int inLength);

int StrHash(const char *inName, int *outLength);
int StrHash(const char *inName, size_t *outLength);
void AllocTable();
void Grow();
PyrSymbol* Find(const char *inName, int inHash);
Expand Down

0 comments on commit 7e6396d

Please sign in to comment.