Permalink
Browse files

headers/lang: some int type fixes

Signed-off-by: Tim Blechmann <tim@klingt.org>
  • Loading branch information...
1 parent 860e5ef commit 7e6396de09887c651b88ae59dfa3ec73837399f9 @timblechmann timblechmann committed Sep 8, 2012
@@ -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):
@@ -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;
@@ -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;
}
@@ -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);
}
@@ -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 .
@@ -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
@@ -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)
View
@@ -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; }
@@ -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)
@@ -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);
}
@@ -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 ]);
}
@@ -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);
Oops, something went wrong.

0 comments on commit 7e6396d

Please sign in to comment.