Simple pass over the codebase to standardize the platform types.

This commit is contained in:
cpusci 2013-08-04 16:26:01 -05:00
parent c75d6feb20
commit 4c35fd37af
189 changed files with 824 additions and 824 deletions

View file

@ -412,7 +412,7 @@ namespace Platform
//------------------------------------------------------------------------------
// Misc StdLib functions
#define QSORT_CALLBACK FN_CDECL
inline void dQsort(void *base, U32 nelem, U32 width, int (QSORT_CALLBACK *fcmp)(const void *, const void *))
inline void dQsort(void *base, U32 nelem, U32 width, S32 (QSORT_CALLBACK *fcmp)(const void *, const void *))
{
qsort(base, nelem, width, fcmp);
}
@ -507,7 +507,7 @@ extern void* dRealloc_r(void* in_pResize, dsize_t in_size, const char*, const ds
extern void* dRealMalloc(dsize_t);
extern void dRealFree(void*);
extern void *dMalloc_aligned(dsize_t in_size, int alignment);
extern void *dMalloc_aligned(dsize_t in_size, S32 alignment);
extern void dFree_aligned(void *);
@ -525,8 +525,8 @@ template<class T,class S> void dCopyArray(T *dst, const S *src, dsize_t size)
extern void* dMemcpy(void *dst, const void *src, dsize_t size);
extern void* dMemmove(void *dst, const void *src, dsize_t size);
extern void* dMemset(void *dst, int c, dsize_t size);
extern int dMemcmp(const void *ptr1, const void *ptr2, dsize_t size);
extern void* dMemset(void *dst, S32 c, dsize_t size);
extern S32 dMemcmp(const void *ptr1, const void *ptr2, dsize_t size);
// Special case of the above function when the arrays are the same type (use memcpy)
template<class T> void dCopyArray(T *dst, const T *src, dsize_t size)
@ -565,8 +565,8 @@ enum DFILE_STATUS
extern FILE_HANDLE dOpenFileRead(const char *name, DFILE_STATUS &error);
extern FILE_HANDLE dOpenFileReadWrite(const char *name, bool append, DFILE_STATUS &error);
extern int dFileRead(FILE_HANDLE handle, U32 bytes, char *dst, DFILE_STATUS &error);
extern int dFileWrite(FILE_HANDLE handle, U32 bytes, const char *dst, DFILE_STATUS &error);
extern S32 dFileRead(FILE_HANDLE handle, U32 bytes, char *dst, DFILE_STATUS &error);
extern S32 dFileWrite(FILE_HANDLE handle, U32 bytes, const char *dst, DFILE_STATUS &error);
extern void dFileClose(FILE_HANDLE handle);
extern StringTableEntry osGetTemporaryDirectory();

View file

@ -80,13 +80,13 @@ namespace CPUInfo {
#ifndef TORQUE_OS_MAC
static unsigned int CpuIDSupported(void);
static unsigned int find_maskwidth(unsigned int);
static unsigned int HWD_MTSupported(void);
static unsigned int MaxLogicalProcPerPhysicalProc(void);
static unsigned int MaxCorePerPhysicalProc(void);
static unsigned char GetAPIC_ID(void);
static unsigned char GetNzbSubID(unsigned char, unsigned char, unsigned char);
static U32 CpuIDSupported(void);
static U32 find_maskwidth(unsigned int);
static U32 HWD_MTSupported(void);
static U32 MaxLogicalProcPerPhysicalProc(void);
static U32 MaxCorePerPhysicalProc(void);
static U8 GetAPIC_ID(void);
static U8 GetNzbSubID(U8, U8, U8);
#endif
static char g_s3Levels[2048];
@ -97,9 +97,9 @@ namespace CPUInfo {
// CpuIDSupported will return 0 if CPUID instruction is unavailable. Otherwise, it will return
// the maximum supported standard function.
//
static unsigned int CpuIDSupported(void)
static U32 CpuIDSupported(void)
{
unsigned int MaxInputValue;
U32 MaxInputValue;
// If CPUID instruction is supported
#ifdef TORQUE_COMPILER_GCC
try
@ -153,12 +153,12 @@ namespace CPUInfo {
// maximum value.
//
static unsigned int MaxCorePerPhysicalProc(void)
static U32 MaxCorePerPhysicalProc(void)
{
unsigned int Regeax = 0;
U32 Regeax = 0;
if (!HWD_MTSupported()) return (unsigned int) 1; // Single core
if (!HWD_MTSupported()) return (U32) 1; // Single core
#ifdef TORQUE_COMPILER_GCC
{
asm
@ -209,7 +209,7 @@ multi_core:
#else
# error Not implemented.
#endif
return (unsigned int)((Regeax & NUM_CORE_BITS) >> 26)+1;
return (U32)((Regeax & NUM_CORE_BITS) >> 26)+1;
}
@ -218,11 +218,11 @@ multi_core:
//
// The function returns 0 when the hardware multi-threaded bit is not set.
//
static unsigned int HWD_MTSupported(void)
static U32 HWD_MTSupported(void)
{
unsigned int Regedx = 0;
U32 Regedx = 0;
if ((CpuIDSupported() >= 1))
@ -262,12 +262,12 @@ multi_core:
// AVAILABLE logical processors per physical to be used by an application might be less than this
// maximum value.
//
static unsigned int MaxLogicalProcPerPhysicalProc(void)
static U32 MaxLogicalProcPerPhysicalProc(void)
{
unsigned int Regebx = 0;
U32 Regebx = 0;
if (!HWD_MTSupported()) return (unsigned int) 1;
if (!HWD_MTSupported()) return (U32) 1;
#ifdef TORQUE_COMPILER_GCC
asm
(
@ -292,10 +292,10 @@ multi_core:
}
static unsigned char GetAPIC_ID(void)
static U8 GetAPIC_ID(void)
{
unsigned int Regebx = 0;
U32 Regebx = 0;
#ifdef TORQUE_COMPILER_GCC
asm
(
@ -324,9 +324,9 @@ multi_core:
//
// Determine the width of the bit field that can represent the value count_item.
//
unsigned int find_maskwidth(unsigned int CountItem)
U32 find_maskwidth(U32 CountItem)
{
unsigned int MaskWidth,
U32 MaskWidth,
count = CountItem;
#ifdef TORQUE_COMPILER_GCC
asm
@ -392,16 +392,16 @@ next:
//
// Extract the subset of bit field from the 8-bit value FullID. It returns the 8-bit sub ID value
//
static unsigned char GetNzbSubID(unsigned char FullID,
unsigned char MaxSubIDValue,
unsigned char ShiftCount)
static U8 GetNzbSubID(U8 FullID,
U8 MaxSubIDValue,
U8 ShiftCount)
{
unsigned int MaskWidth;
unsigned char MaskBits;
U32 MaskWidth;
U8 MaskBits;
MaskWidth = find_maskwidth((unsigned int) MaxSubIDValue);
MaskWidth = find_maskwidth((U32) MaxSubIDValue);
MaskBits = (0xff << ShiftCount) ^
((unsigned char) (0xff << (ShiftCount + MaskWidth)));
((U8) (0xff << (ShiftCount + MaskWidth)));
return (FullID & MaskBits);
}
@ -420,8 +420,8 @@ next:
TotAvailCore = 1;
PhysicalNum = 1;
unsigned int numLPEnabled = 0;
int MaxLPPerCore = 1;
U32 numLPEnabled = 0;
S32 MaxLPPerCore = 1;
#ifdef TORQUE_OS_MAC
@ -430,8 +430,8 @@ next:
// like there isn't a way to do this that's working across all OSX incarnations
// and machine configurations anyway.
int numCPUs;
int numPackages;
S32 numCPUs;
S32 numPackages;
// Get the number of CPUs.
@ -450,9 +450,9 @@ next:
#else
U32 dwAffinityMask;
int j = 0;
unsigned char apicID, PackageIDMask;
unsigned char tblPkgID[256], tblCoreID[256], tblSMTID[256];
S32 j = 0;
U8 apicID, PackageIDMask;
U8 tblPkgID[256], tblCoreID[256], tblSMTID[256];
char tmp[256];
#ifdef TORQUE_OS_LINUX
@ -464,14 +464,14 @@ next:
// Linux doesn't easily allow us to look at the Affinity Bitmask directly,
// but it does provide an API to test affinity maskbits of the current process
// against each logical processor visible under OS.
int sysNumProcs = sysconf(_SC_NPROCESSORS_CONF); //This will tell us how many
S32 sysNumProcs = sysconf(_SC_NPROCESSORS_CONF); //This will tell us how many
//CPUs are currently enabled.
//this will tell us which processors this process can run on.
cpu_set_t allowedCPUs;
sched_getaffinity(0, sizeof(allowedCPUs), &allowedCPUs);
for (int i = 0; i < sysNumProcs; i++ )
for (S32 i = 0; i < sysNumProcs; i++ )
{
if ( CPU_ISSET(i, &allowedCPUs) == 0 )
return CONFIG_UserConfigIssue;
@ -522,8 +522,8 @@ next:
// processors per core
tblSMTID[j] = GetNzbSubID(apicID, MaxLPPerCore, 0);
unsigned char maxCorePPP = MaxCorePerPhysicalProc();
unsigned char maskWidth = find_maskwidth(MaxLPPerCore);
U8 maxCorePPP = MaxCorePerPhysicalProc();
U8 maskWidth = find_maskwidth(MaxLPPerCore);
tblCoreID[j] = GetNzbSubID(apicID, maxCorePPP, maskWidth);
// Extract package ID, assume single cluster.
@ -560,9 +560,9 @@ next:
//
// Count available cores (TotAvailCore) in the system
//
unsigned char CoreIDBucket[256];
U8 CoreIDBucket[256];
DWORD ProcessorMask, pCoreMask[256];
unsigned int i, ProcessorNum;
U32 i, ProcessorNum;
CoreIDBucket[0] = tblPkgID[0] | tblCoreID[0];
ProcessorMask = 1;
@ -598,7 +598,7 @@ next:
//
// Count physical processor (PhysicalNum) in the system
//
unsigned char PackageIDBucket[256];
U8 PackageIDBucket[256];
DWORD pPackageMask[256];
PackageIDBucket[0] = tblPkgID[0];

View file

@ -367,7 +367,7 @@ static U32 validateTreeRecurse(TreeNode *tree)
if(tree == NIL)
return 1;
// check my left tree
int lcount, rcount, nc = 0;
S32 lcount, rcount, nc = 0;
if(tree->color == Red)
{
@ -1588,7 +1588,7 @@ dsize_t getMemoryUsed()
}
#ifdef TORQUE_DEBUG_GUARD
DefineEngineFunction( dumpAlloc, void, ( int allocNum ),,
DefineEngineFunction( dumpAlloc, void, ( S32 allocNum ),,
"@brief Dumps information about the given allocated memory block.\n\n"
"@param allocNum Memory block to dump information about."
"@note Available in debug builds only. "

View file

@ -30,7 +30,7 @@
#define EINPROGRESS WSAEINPROGRESS
#define ioctl ioctlsocket
typedef int socklen_t;
typedef S32 socklen_t;
#elif defined ( TORQUE_OS_MAC )
@ -84,7 +84,7 @@ typedef in_addr IN_ADDR;
#define TORQUE_USE_WINSOCK
#define EINPROGRESS WSAEINPROGRESS
#define ioctl ioctlsocket
typedef int socklen_t;
typedef S32 socklen_t;
DWORD _getLastErrorAndClear()
{
@ -99,7 +99,7 @@ DWORD _getLastErrorAndClear()
#endif
#if defined(TORQUE_USE_WINSOCK)
static const char* strerror_wsa( int code )
static const char* strerror_wsa( S32 code )
{
switch( code )
{
@ -137,7 +137,7 @@ static const char* strerror_wsa( int code )
static Net::Error getLastError();
static S32 defaultPort = 28000;
static S32 netPort = 0;
static int udpSocket = InvalidSocket;
static S32 udpSocket = InvalidSocket;
ConnectionNotifyEvent Net::smConnectionNotify;
ConnectionAcceptedEvent Net::smConnectionAccept;
@ -441,7 +441,7 @@ void Net::closeConnectTo(NetSocket sock)
return;
// if this socket is in the list of polled sockets, remove it
for (int i = 0; i < gPolledSockets.size(); ++i)
for (S32 i = 0; i < gPolledSockets.size(); ++i)
{
if (gPolledSockets[i]->fd == sock)
{
@ -454,7 +454,7 @@ void Net::closeConnectTo(NetSocket sock)
closeSocket(sock);
}
Net::Error Net::sendtoSocket(NetSocket socket, const U8 *buffer, int bufferSize)
Net::Error Net::sendtoSocket(NetSocket socket, const U8 *buffer, S32 bufferSize)
{
if(Journal::IsPlaying())
{
@ -480,7 +480,7 @@ bool Net::openPort(S32 port, bool doBind)
// we turn off VDP in non-release builds because VDP does not support broadcast packets
// which are required for LAN queries (PC->Xbox connectivity). The wire protocol still
// uses the VDP packet structure, though.
int protocol = 0;
S32 protocol = 0;
bool useVDP = false;
#ifdef TORQUE_DISABLE_PC_CONNECTIVITY
// Xbox uses a VDP (voice/data protocol) socket for networking
@ -617,7 +617,7 @@ void Net::process()
sockaddr_in ipAddr;
NetSocket incoming = InvalidSocket;
char out_h_addr[1024];
int out_h_length = 0;
S32 out_h_length = 0;
RawData readBuff;
for (S32 i = 0; i < gPolledSockets.size();
@ -727,7 +727,7 @@ void Net::process()
if(::connect(currentSock->fd, (struct sockaddr *)&ipAddr,
sizeof(ipAddr)) == -1)
{
int errorCode;
S32 errorCode;
#if defined(TORQUE_USE_WINSOCK)
errorCode = WSAGetLastError();
if( errorCode == WSAEINPROGRESS || errorCode == WSAEWOULDBLOCK )
@ -786,7 +786,7 @@ void Net::process()
NetSocket Net::openSocket()
{
int retSocket;
S32 retSocket;
retSocket = socket(AF_INET, SOCK_STREAM, 0);
if(retSocket == InvalidSocket)
@ -831,7 +831,7 @@ NetSocket Net::accept(NetSocket acceptSocket, NetAddress *remoteAddress)
sockaddr_in socketAddress;
socklen_t addrLen = sizeof(socketAddress);
int retVal = ::accept(acceptSocket, (sockaddr *) &socketAddress, &addrLen);
S32 retVal = ::accept(acceptSocket, (sockaddr *) &socketAddress, &addrLen);
if(retVal != InvalidSocket)
{
IPSocketToNetAddress(&socketAddress, remoteAddress);

View file

@ -31,14 +31,14 @@
#define MAXPACKETSIZE 1500
#endif
typedef int NetConnectionId;
typedef S32 NetConnectionId;
/// Generic network address
///
/// This is used to represent IP addresses.
struct NetAddress
{
int type; ///< Type of address (IPAddress currently)
S32 type; ///< Type of address (IPAddress currently)
/// Acceptable NetAddress types.
enum
@ -93,7 +93,7 @@ struct Net
TCPProtocol
};
static const int MaxPacketDataSize = MAXPACKETSIZE;
static const S32 MaxPacketDataSize = MAXPACKETSIZE;
static ConnectionNotifyEvent smConnectionNotify;
static ConnectionAcceptedEvent smConnectionAccept;

View file

@ -48,7 +48,7 @@ struct NetAsync::NameLookupRequest
NetSocket sock;
char remoteAddr[4096];
char out_h_addr[4096];
int out_h_length;
S32 out_h_length;
bool complete;
NameLookupRequest()
@ -140,7 +140,7 @@ void NetAsync::queueLookup(const char* remoteAddr, NetSocket socket)
{
// do we have it already?
unsigned int i = 0;
U32 i = 0;
for (i = 0; i < mLookupRequests.size(); ++i)
{
if (mLookupRequests[i].sock == socket)
@ -160,7 +160,7 @@ void NetAsync::queueLookup(const char* remoteAddr, NetSocket socket)
}
bool NetAsync::checkLookup(NetSocket socket, char* out_h_addr,
int* out_h_length, int out_h_addr_size)
S32* out_h_length, S32 out_h_addr_size)
{
bool found = false;

View file

@ -54,7 +54,7 @@ class NetAsync
// out_h_length will be set appropriately. if out_h_length is -1, then
// name could not be resolved. otherwise, it provides the number of
// address bytes copied into out_h_addr.
bool checkLookup(NetSocket socket, char* out_h_addr, int* out_h_length, int out_h_addr_size);
bool checkLookup(NetSocket socket, char* out_h_addr, int* out_h_length, S32 out_h_addr_size);
};
// the global net async object

View file

@ -311,7 +311,7 @@ CreateUnitTest( SemaphoreWaitTest, "Platform/Threads/SemaphoreWaitTest")
void *mMutex;
U32 mDoneCount;
const static int csmThreadCount = 10;
const static S32 csmThreadCount = 10;
void run()
{
@ -381,7 +381,7 @@ CreateUnitTest( MutexWaitTest, "Platform/Threads/MutexWaitTest")
void *mMutex;
U32 mDoneCount;
const static int csmThreadCount = 10;
const static S32 csmThreadCount = 10;
void run()
{