1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Convert custom HeadSpin integer types to standard types from stdint.h

This commit is contained in:
2012-01-19 21:19:26 -05:00
parent a0d54e2644
commit 5027b5a4ac
1301 changed files with 14497 additions and 14532 deletions

View File

@ -126,7 +126,7 @@ void CNtWaitHandle::SignalObject () const {
static void INtOpDispatch (
NtObject * ntObj,
Operation * op,
dword bytes
uint32_t bytes
) {
for (;;) {
switch (op->opType) {
@ -143,12 +143,12 @@ static void INtOpDispatch (
return;
case kOpSocketRead:
ASSERT(bytes != (dword) -1);
ASSERT(bytes != (uint32_t) -1);
INtSocketOpCompleteSocketRead((NtSock *) ntObj, bytes);
return;
case kOpSocketWrite:
ASSERT(bytes != (dword) -1);
ASSERT(bytes != (uint32_t) -1);
INtSocketOpCompleteSocketWrite((NtSock *) ntObj, (NtOpSocketWrite *) op);
break;
@ -161,7 +161,7 @@ static void INtOpDispatch (
case kOpFileRead:
case kOpFileWrite:
ASSERT(bytes != (dword) -1);
ASSERT(bytes != (uint32_t) -1);
if (!INtFileOpCompleteReadWrite((NtFile *) ntObj, (NtOpFileReadWrite *) op, bytes))
return;
break;
@ -238,7 +238,7 @@ static void INtOpDispatch (
// can only be dispatched when they are completed normally. To ensure that
// we're not accidentally processing an operation that shouldn't be executed,
// set the bytes field to an invalid value.
bytes = (dword) -1;
bytes = (uint32_t) -1;
}
}

View File

@ -83,7 +83,7 @@ struct NtFile : NtObject {
LINK(NtFile) pendLink; // protected by s_fileCrit
unsigned queueWrites;
unsigned sectorSizeMask;
wchar fullPath[MAX_PATH];
wchar_t fullPath[MAX_PATH];
NtFile ();
~NtFile ();
@ -179,8 +179,8 @@ static void HandleFailedOp (
for (; position < op->rw.bytes; ++subOperations) {
NtOpFileReadWrite * childOp = NEW(NtOpFileReadWrite);
childOp->overlapped.hEvent = op->overlapped.hEvent ? CreateEvent(nil, true, false, nil) : nil;
childOp->overlapped.Offset = (dword) ((op->rw.offset + position) & 0xffffffff);
childOp->overlapped.OffsetHigh = (dword) ((op->rw.offset + position) >> 32);
childOp->overlapped.Offset = (uint32_t) ((op->rw.offset + position) & 0xffffffff);
childOp->overlapped.OffsetHigh = (uint32_t) ((op->rw.offset + position) >> 32);
childOp->opType = op->opType;
childOp->asyncId = 0;
childOp->notify = false;
@ -312,9 +312,9 @@ static void HandleFailedOp (
}
//===========================================================================
static void InternalFileSetSize (NtObject * file, qword size) {
static void InternalFileSetSize (NtObject * file, uint64_t size) {
LONG sizeHigh = (long) (size >> 32);
DWORD seek = SetFilePointer(file->handle, (dword) size, &sizeHigh, FILE_BEGIN);
DWORD seek = SetFilePointer(file->handle, (uint32_t) size, &sizeHigh, FILE_BEGIN);
if ((seek != (DWORD) -1) || (GetLastError() == NO_ERROR))
SetEndOfFile(file->handle);
}
@ -547,15 +547,15 @@ void INtFileOpCompleteSequence (
//===========================================================================
AsyncFile NtFileOpen (
const wchar fullPath[],
const wchar_t fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags,
void * userState,
qword * fileSize,
qword * fileLastWriteTime
uint64_t * fileSize,
uint64_t * fileLastWriteTime
) {
unsigned attributeFlags = 0;
attributeFlags |= FILE_FLAG_OVERLAPPED;
@ -590,9 +590,9 @@ AsyncFile NtFileOpen (
CloseHandle(handle);
return nil;
}
const qword size = ((qword) sizeHi << (qword) 32) | (qword) sizeLo;
const uint64_t size = ((uint64_t) sizeHi << (uint64_t) 32) | (uint64_t) sizeLo;
qword lastWriteTime;
uint64_t lastWriteTime;
ASSERT(sizeof(lastWriteTime) >= sizeof(FILETIME));
GetFileTime(handle, nil, nil, (FILETIME *) &lastWriteTime);
@ -632,7 +632,7 @@ AsyncFile NtFileOpen (
//===========================================================================
AsyncId NtFileRead (
AsyncFile conn,
qword offset,
uint64_t offset,
void * buffer,
unsigned bytes,
unsigned flags,
@ -644,7 +644,7 @@ AsyncId NtFileRead (
ASSERT((flags & (kAsyncFileRwNotify|kAsyncFileRwSync)) != (kAsyncFileRwNotify|kAsyncFileRwSync));
ASSERT(! (offset & file->sectorSizeMask));
ASSERT(! (bytes & file->sectorSizeMask));
ASSERT(! ((unsigned_ptr) buffer & file->sectorSizeMask));
ASSERT(! ((uintptr_t) buffer & file->sectorSizeMask));
// Normally, I/O events do not complete until both the WIN32 operation has completed
// and the callback notification has occurred. A deadlock can occur if a thread attempts
@ -655,8 +655,8 @@ AsyncId NtFileRead (
// into the Overlapped structure, because the event will be signaled prior to the
// potentially deadlocking callback notification.
NtOpFileReadWrite * op = NEW(NtOpFileReadWrite);
op->overlapped.Offset = (dword) (offset & 0xffffffff);
op->overlapped.OffsetHigh = (dword) (offset >> 32);
op->overlapped.Offset = (uint32_t) (offset & 0xffffffff);
op->overlapped.OffsetHigh = (uint32_t) (offset >> 32);
op->overlapped.hEvent = (flags & kAsyncFileRwSync) ? CreateEvent(nil, true, false, nil) : nil;
op->opType = kOpFileRead;
op->notify = (flags & kAsyncFileRwNotify) != 0;
@ -666,7 +666,7 @@ AsyncId NtFileRead (
op->win32Bytes = bytes;
op->rw.param = param;
op->rw.offset = offset;
op->rw.buffer = (byte *) buffer;
op->rw.buffer = (uint8_t *) buffer;
op->rw.bytes = bytes;
InterlockedIncrement(&file->ioCount);
@ -686,7 +686,7 @@ AsyncId NtFileRead (
// buffer must stay valid until I/O is completed
AsyncId NtFileWrite (
AsyncFile conn,
qword offset,
uint64_t offset,
const void * buffer,
unsigned bytes,
unsigned flags,
@ -698,7 +698,7 @@ AsyncId NtFileWrite (
ASSERT((flags & (kAsyncFileRwNotify|kAsyncFileRwSync)) != (kAsyncFileRwNotify|kAsyncFileRwSync));
ASSERT(! (offset & file->sectorSizeMask));
ASSERT(! (bytes & file->sectorSizeMask));
ASSERT(! ((unsigned_ptr) buffer & file->sectorSizeMask));
ASSERT(! ((uintptr_t) buffer & file->sectorSizeMask));
// Normally, I/O events do not complete until both the WIN32 operation has completed
// and the callback notification has occurred. A deadlock can occur if a thread attempts
@ -709,8 +709,8 @@ AsyncId NtFileWrite (
// into the Overlapped structure, because the event will be signaled prior to the
// potentially deadlocking callback notification.
NtOpFileReadWrite * op = NEW(NtOpFileReadWrite);
op->overlapped.Offset = (dword) (offset & 0xffffffff);
op->overlapped.OffsetHigh = (dword) (offset >> 32);
op->overlapped.Offset = (uint32_t) (offset & 0xffffffff);
op->overlapped.OffsetHigh = (uint32_t) (offset >> 32);
op->overlapped.hEvent = (flags & kAsyncFileRwSync) ? CreateEvent(nil, true, false, nil) : nil;
op->opType = kOpFileWrite;
op->notify = (flags & kAsyncFileRwNotify) != 0;
@ -720,7 +720,7 @@ AsyncId NtFileWrite (
op->win32Bytes = bytes;
op->rw.param = param;
op->rw.offset = offset;
op->rw.buffer = (byte *) buffer;
op->rw.buffer = (uint8_t *) buffer;
op->rw.bytes = bytes;
InterlockedIncrement(&file->ioCount);
@ -745,7 +745,7 @@ AsyncId NtFileWrite (
//===========================================================================
AsyncId NtFileFlushBuffers (
AsyncFile conn,
qword truncateSize,
uint64_t truncateSize,
bool notify,
void * param
) {
@ -799,7 +799,7 @@ AsyncId NtFileFlushBuffers (
//===========================================================================
void NtFileClose (
AsyncFile conn,
qword truncateSize
uint64_t truncateSize
) {
NtFile * file = (NtFile *) conn;
ASSERT(file);
@ -853,7 +853,7 @@ void NtFileClose (
//===========================================================================
void NtFileSetLastWriteTime (
AsyncFile conn,
qword lastWriteTime
uint64_t lastWriteTime
) {
NtFile * file = (NtFile *) conn;
ASSERT(file);
@ -866,12 +866,12 @@ void NtFileSetLastWriteTime (
}
//===========================================================================
qword NtFileGetLastWriteTime (
const wchar fileName[]
uint64_t NtFileGetLastWriteTime (
const wchar_t fileName[]
) {
WIN32_FILE_ATTRIBUTE_DATA info;
bool f = GetFileAttributesExW(fileName, GetFileExInfoStandard, &info);
return f ? *((qword *) &info.ftLastWriteTime) : 0;
return f ? *((uint64_t *) &info.ftLastWriteTime) : 0;
}
//===========================================================================
@ -988,7 +988,7 @@ bool NtFileWaitId (AsyncFile conn, AsyncId asyncId, unsigned timeoutMs) {
//============================================================================
bool NtFileSeek (
AsyncFile conn,
qword distance,
uint64_t distance,
EFileSeekFrom from
) {
COMPILER_ASSERT(kFileSeekFromBegin == FILE_BEGIN);
@ -998,8 +998,8 @@ bool NtFileSeek (
NtFile * file = (NtFile *) conn;
LONG low = (LONG)(distance % 0x100000000ul);
LONG high = (LONG)(distance / 0x100000000ul);
dword result = SetFilePointer(file->handle, low, &high, from);
if ((result == (dword)-1) && (GetLastError() != NO_ERROR)) {
uint32_t result = SetFilePointer(file->handle, low, &high, from);
if ((result == (uint32_t)-1) && (GetLastError() != NO_ERROR)) {
LogMsg(kLogFatal, "failed: SetFilePointer");
return false;
}

View File

@ -229,36 +229,36 @@ void NtSignalShutdown ();
void NtWaitForShutdown ();
void NtSleep (unsigned sleepMs);
AsyncFile NtFileOpen (
const wchar fullPath[],
const wchar_t fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags,
void * userState,
qword * fileSize,
qword * fileLastWriteTime
uint64_t * fileSize,
uint64_t * fileLastWriteTime
);
void NtFileClose (
AsyncFile file,
qword truncateSize
uint64_t truncateSize
);
void NtFileSetLastWriteTime (
AsyncFile file,
qword lastWriteTime
uint64_t lastWriteTime
);
qword NtFileGetLastWriteTime (
const wchar fileName[]
uint64_t NtFileGetLastWriteTime (
const wchar_t fileName[]
);
AsyncId NtFileFlushBuffers (
AsyncFile file,
qword truncateSize,
uint64_t truncateSize,
bool notify,
void * param
);
AsyncId NtFileRead (
AsyncFile file,
qword offset,
uint64_t offset,
void * buffer,
unsigned bytes,
unsigned flags,
@ -266,7 +266,7 @@ AsyncId NtFileRead (
);
AsyncId NtFileWrite (
AsyncFile file,
qword offset,
uint64_t offset,
const void *buffer,
unsigned bytes,
unsigned flags,
@ -279,7 +279,7 @@ AsyncId NtFileCreateSequence (
);
bool NtFileSeek (
AsyncFile file,
qword distance,
uint64_t distance,
EFileSeekFrom from
);
void NtSocketConnect (

View File

@ -97,7 +97,7 @@ struct NtOpConnAttempt : Operation {
SOCKET hSocket;
unsigned failTimeMs;
unsigned sendBytes;
byte sendData[1]; // actually [sendBytes]
uint8_t sendData[1]; // actually [sendBytes]
// no additional fields
};
@ -121,7 +121,7 @@ struct NtSock : NtObject {
NtOpSocketRead opRead;
unsigned backlogAlloc;
unsigned initTimeMs;
byte buffer[kAsyncSocketBufferSize];
uint8_t buffer[kAsyncSocketBufferSize];
NtSock ();
~NtSock ();
@ -291,7 +291,7 @@ static bool SocketDispatchRead (NtSock * sock) {
//===========================================================================
static NtOpSocketWrite * SocketQueueAsyncWrite (
NtSock * sock,
const byte * data,
const uint8_t * data,
unsigned bytes
) {
// check for data backlog
@ -367,7 +367,7 @@ static NtOpSocketWrite * SocketQueueAsyncWrite (
op->bytesAlloc = bytesAlloc;
op->write.param = nil;
op->write.asyncId = asyncId;
op->write.buffer = (byte *) (op + 1);
op->write.buffer = (uint8_t *) (op + 1);
op->write.bytes = bytes;
op->write.bytesProcessed = bytes;
MemCopy(op->write.buffer, data, bytes);
@ -546,11 +546,11 @@ static SOCKET ListenSocket (NetAddress * listenAddr) {
// bind socket to port
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons((word)port);
addr.sin_port = htons((uint16_t)port);
addr.sin_addr.S_un.S_addr = htonl(node);
MemZero(addr.sin_zero, sizeof(addr.sin_zero));
if (bind(s, (sockaddr *) &addr, sizeof(addr))) {
wchar str[32];
wchar_t str[32];
NetAddressToString(*listenAddr, str, arrsize(str), kNetAddressFormatAll);
LogMsg(kLogError, "bind to addr %s failed (err %u)", str, WSAGetLastError());
break;
@ -630,7 +630,7 @@ static SOCKET ConnectSocket (unsigned localPort, const NetAddress & addr) {
if (localPort) {
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons((word) localPort);
addr.sin_port = htons((uint16_t) localPort);
addr.sin_addr.S_un.S_addr = INADDR_ANY;
MemZero(addr.sin_zero, sizeof(addr.sin_zero));
if (bind(s, (sockaddr *) &addr, sizeof(addr))) {
@ -800,13 +800,13 @@ static void StartListenThread () {
#ifdef HS_DEBUGGING
#include <StdIo.h>
static void __cdecl DumpInvalidData (
const wchar filename[],
const wchar_t filename[],
unsigned bytes,
const byte data[],
const uint8_t data[],
const char fmt[],
...
) {
wchar path[MAX_PATH];
wchar_t path[MAX_PATH];
PathGetProgramDirectory(path, arrsize(path));
PathAddFilename(path, path, L"Log", arrsize(path));
PathAddFilename(path, path, filename, arrsize(path));
@ -1351,7 +1351,7 @@ bool NtSocketSend (
break;
// subtract the data we already sent
data = (const byte *) data + bytesSent;
data = (const uint8_t *) data + bytesSent;
bytes -= bytesSent;
// and queue it below
}
@ -1363,7 +1363,7 @@ bool NtSocketSend (
}
}
NtOpSocketWrite * op = SocketQueueAsyncWrite(sock, (const byte *) data, bytes);
NtOpSocketWrite * op = SocketQueueAsyncWrite(sock, (const uint8_t *) data, bytes);
if (op && !dataQueued)
result = INtSocketOpCompleteQueuedSocketWrite(sock, op);
else
@ -1415,7 +1415,7 @@ bool NtSocketWrite (
op->bytesAlloc = bytes;
op->write.param = param;
op->write.asyncId = op->asyncId;
op->write.buffer = (byte *) buffer;
op->write.buffer = (uint8_t *) buffer;
op->write.bytes = bytes;
op->write.bytesProcessed = bytes;
PerfAddCounter(kAsyncPerfSocketBytesWaitQueued, bytes);