this is a more "clean" conversion to 64 bit than the type-fixups branch, which does borrow some elements from it but has far less find and replace...it is about 98-99% done, notes to follow later

This commit is contained in:
DarthArgus
2017-01-24 03:35:59 +00:00
parent 42b949c3dc
commit 36686348e9
458 changed files with 2282 additions and 2367 deletions
@@ -10,7 +10,7 @@ namespace Base
{
BlockAllocator::BlockAllocator()
{
for(unsigned i = 0; i < 31; i++)
for(baType i = 0; i < 31; i++)
{
m_blocks[i] = nullptr;
}
@@ -19,12 +19,12 @@ namespace Base
BlockAllocator::~BlockAllocator()
{
// free all allocated memory blocks
for(unsigned i = 0; i < 31; i++)
for(baType i = 0; i < 31; i++)
{
while(m_blocks[i] != nullptr)
{
unsigned *tmp = m_blocks[i];
m_blocks[i] = (unsigned *)*m_blocks[i];
baType *tmp = m_blocks[i];
m_blocks[i] = (baType *)*m_blocks[i];
free(tmp);
}
}
@@ -33,10 +33,10 @@ namespace Base
// Allocate a block that is the next power of two greater than the # of bytes passed.
// 33 bytes yields a 64 byte block of memory and so forth.
void *BlockAllocator::getBlock(unsigned bytes)
void *BlockAllocator::getBlock(baType bytes)
{
unsigned accum = 16, bits = 16;
unsigned *handle = nullptr;
baType accum = 16, bits = 16;
baType *handle = nullptr;
// Perform a binary search looking for the highest bit.
@@ -44,14 +44,14 @@ namespace Base
{
// If bytes is less than the bit we're testing for, subtract half
// from the bit value and repeat
if(bytes < (unsigned)(1 << accum))
if(bytes < (baType)(1 << accum))
{
bits /= 2;
accum -= bits;
}
// If bytes is greater than the bit we're testing for, add half
// from the but value and repeat
else if(bytes > (unsigned)(1 << accum))
else if(bytes > (baType)(1 << accum))
{
bits /= 2;
accum += bits;
@@ -79,7 +79,7 @@ namespace Base
if(m_blocks[accum] == 0)
{
// remove the pre allocated block from the linked list
handle = (unsigned *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned));
handle = (baType *)calloc(((1 << accum) / 4) + 2, sizeof(baType));
handle[1] = accum;
handle[0] = 0;
}
@@ -87,20 +87,20 @@ namespace Base
{
// Allocate a new block
handle = m_blocks[accum];
m_blocks[accum] = (unsigned *)handle[0];
m_blocks[accum] = (baType *)handle[0];
handle[0] = 0;
}
// return a pointer that skips over the header used for the allocator's purposes
return(handle + 2);
}
void BlockAllocator::returnBlock(unsigned *handle)
void BlockAllocator::returnBlock(baType *handle)
{
// C++ allows for safe deletion of a nullptr pointer
if(handle)
{
// Update the allocator linked list, insert this entry at the head
*(handle - 2) = (unsigned)m_blocks[*(handle - 1)];
*(handle - 2) = (baType)m_blocks[*(handle - 1)];
// Add this entry to the proper linked list node
m_blocks[*(handle - 1)] = (handle - 2);
}
@@ -11,7 +11,7 @@
#ifndef BASE_LINUX_TYPES_H
#define BASE_LINUX_TYPES_H
#include <sys/bitypes.h>
#include <stdint.h>
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
@@ -21,19 +21,24 @@ namespace NAMESPACE
namespace Base
{
//#define INT32_MAX 0x7FFFFFFF
//#define INT32_MIN 0x80000000
//#define UINT32_MAX 0xFFFFFFFF
typedef signed char int8;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
#ifndef INT32_MAX
#define INT32_MAX 0x7FFFFFFF
#define INT32_MIN 0x80000000
#define UINT32_MAX 0xFFFFFFFF
#endif
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef u_int32_t uint32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef u_int64_t uint64;
typedef uint64_t uint64;
}
#ifdef EXTERNAL_DISTRO
};